python: Port unixctl to Python.
[openvswitch] / lib / ofp-util.c
index 6f8b033eceda8b9936b15af3add5f40911b7c5f9..0f3fdb214756d158cfec97d1b625143a29eaddf6 100644 (file)
@@ -400,6 +400,14 @@ ofputil_decode_vendor(const struct ofp_header *oh, size_t length,
         { OFPUTIL_NXT_FLOW_AGE, OFP10_VERSION,
           NXT_FLOW_AGE, "NXT_FLOW_AGE",
           sizeof(struct nicira_header), 0 },
+
+        { OFPUTIL_NXT_SET_ASYNC_CONFIG, OFP10_VERSION,
+          NXT_SET_ASYNC_CONFIG, "NXT_SET_ASYNC_CONFIG",
+          sizeof(struct nx_async_config), 0 },
+
+        { OFPUTIL_NXT_SET_CONTROLLER_ID, OFP10_VERSION,
+          NXT_SET_CONTROLLER_ID, "NXT_SET_CONTROLLER_ID",
+          sizeof(struct nx_controller_id), 0 },
     };
 
     static const struct ofputil_msg_category nxt_category = {
@@ -1780,6 +1788,41 @@ ofputil_encode_packet_in(const struct ofputil_packet_in *pin,
     return packet;
 }
 
+const char *
+ofputil_packet_in_reason_to_string(enum ofp_packet_in_reason reason)
+{
+    static char s[INT_STRLEN(int) + 1];
+
+    switch (reason) {
+    case OFPR_NO_MATCH:
+        return "no_match";
+    case OFPR_ACTION:
+        return "action";
+    case OFPR_INVALID_TTL:
+        return "invalid_ttl";
+
+    case OFPR_N_REASONS:
+    default:
+        sprintf(s, "%d", (int) reason);
+        return s;
+    }
+}
+
+bool
+ofputil_packet_in_reason_from_string(const char *s,
+                                     enum ofp_packet_in_reason *reason)
+{
+    int i;
+
+    for (i = 0; i < OFPR_N_REASONS; i++) {
+        if (!strcasecmp(s, ofputil_packet_in_reason_to_string(i))) {
+            *reason = i;
+            return true;
+        }
+    }
+    return false;
+}
+
 enum ofperr
 ofputil_decode_packet_out(struct ofputil_packet_out *po,
                           const struct ofp_packet_out *opo)
@@ -2248,6 +2291,15 @@ make_echo_reply(const struct ofp_header *rq)
     return out;
 }
 
+struct ofpbuf *
+ofputil_encode_barrier_request(void)
+{
+    struct ofpbuf *msg;
+
+    make_openflow(sizeof(struct ofp_header), OFPT_BARRIER_REQUEST, &msg);
+    return msg;
+}
+
 const char *
 ofputil_frag_handling_to_string(enum ofp_config_flags flags)
 {
@@ -2479,6 +2531,12 @@ validate_actions(const union ofp_action *actions, size_t n_actions,
             error = learn_check((const struct nx_action_learn *) a, flow);
             break;
 
+        case OFPUTIL_NXAST_CONTROLLER:
+            if (((const struct nx_action_controller *) a)->zero) {
+                error = OFPERR_NXBAC_MUST_BE_ZERO;
+            }
+            break;
+
         case OFPUTIL_OFPAT_STRIP_VLAN:
         case OFPUTIL_OFPAT_SET_NW_SRC:
         case OFPUTIL_OFPAT_SET_NW_DST:
@@ -2495,6 +2553,7 @@ validate_actions(const union ofp_action *actions, size_t n_actions,
         case OFPUTIL_NXAST_SET_TUNNEL64:
         case OFPUTIL_NXAST_EXIT:
         case OFPUTIL_NXAST_DEC_TTL:
+        case OFPUTIL_NXAST_FIN_TIMEOUT:
             break;
         }