- if (!strcasecmp(act, "mod_vlan_vid")) {
- struct ofp_action_vlan_vid *va;
- va = put_action(b, sizeof *va, OFPAT_SET_VLAN_VID);
- va->vlan_vid = htons(str_to_u32(arg));
- } else if (!strcasecmp(act, "mod_vlan_pcp")) {
- struct ofp_action_vlan_pcp *va;
- va = put_action(b, sizeof *va, OFPAT_SET_VLAN_PCP);
- va->vlan_pcp = str_to_u32(arg);
- } else if (!strcasecmp(act, "strip_vlan")) {
- struct ofp_action_header *ah;
- ah = put_action(b, sizeof *ah, OFPAT_STRIP_VLAN);
- ah->type = htons(OFPAT_STRIP_VLAN);
- } else if (!strcasecmp(act, "mod_dl_src")) {
- put_dl_addr_action(b, OFPAT_SET_DL_SRC, arg);
- } else if (!strcasecmp(act, "mod_dl_dst")) {
- put_dl_addr_action(b, OFPAT_SET_DL_DST, arg);
- } else if (!strcasecmp(act, "mod_nw_src")) {
- struct ofp_action_nw_addr *na;
- na = put_action(b, sizeof *na, OFPAT_SET_NW_SRC);
- str_to_ip(arg, &na->nw_addr);
- } else if (!strcasecmp(act, "mod_nw_dst")) {
- struct ofp_action_nw_addr *na;
- na = put_action(b, sizeof *na, OFPAT_SET_NW_DST);
- str_to_ip(arg, &na->nw_addr);
- } else if (!strcasecmp(act, "mod_tp_src")) {
- struct ofp_action_tp_port *ta;
- ta = put_action(b, sizeof *ta, OFPAT_SET_TP_SRC);
- ta->tp_port = htons(str_to_u32(arg));
- } else if (!strcasecmp(act, "mod_tp_dst")) {
- struct ofp_action_tp_port *ta;
- ta = put_action(b, sizeof *ta, OFPAT_SET_TP_DST);
- ta->tp_port = htons(str_to_u32(arg));
- } else if (!strcasecmp(act, "mod_nw_tos")) {
- struct ofp_action_nw_tos *nt;
- nt = put_action(b, sizeof *nt, OFPAT_SET_NW_TOS);
- nt->nw_tos = str_to_u32(arg);
- } else if (!strcasecmp(act, "resubmit")) {
- struct nx_action_resubmit *nar;
- nar = put_action(b, sizeof *nar, OFPAT_VENDOR);
- nar->vendor = htonl(NX_VENDOR_ID);
- nar->subtype = htons(NXAST_RESUBMIT);
- nar->in_port = htons(str_to_u32(arg));
- } else if (!strcasecmp(act, "set_tunnel")) {
- struct nx_action_set_tunnel *nast;
- nast = put_action(b, sizeof *nast, OFPAT_VENDOR);
- nast->vendor = htonl(NX_VENDOR_ID);
- nast->subtype = htons(NXAST_SET_TUNNEL);
- nast->tun_id = htonl(str_to_u32(arg));
- } else if (!strcasecmp(act, "drop_spoofed_arp")) {
- struct nx_action_header *nah;
- nah = put_action(b, sizeof *nah, OFPAT_VENDOR);
- nah->vendor = htonl(NX_VENDOR_ID);
- nah->subtype = htons(NXAST_DROP_SPOOFED_ARP);
- } else if (!strcasecmp(act, "set_queue")) {
- struct nx_action_set_queue *nasq;
- nasq = put_action(b, sizeof *nasq, OFPAT_VENDOR);
- nasq->vendor = htonl(NX_VENDOR_ID);
- nasq->subtype = htons(NXAST_SET_QUEUE);
- nasq->queue_id = htonl(str_to_u32(arg));
- } else if (!strcasecmp(act, "pop_queue")) {
- struct nx_action_header *nah;
- nah = put_action(b, sizeof *nah, OFPAT_VENDOR);
- nah->vendor = htonl(NX_VENDOR_ID);
- nah->subtype = htons(NXAST_POP_QUEUE);
- } else if (!strcasecmp(act, "output")) {
- put_output_action(b, str_to_u32(arg));
- } else if (!strcasecmp(act, "enqueue")) {
- char *sp = NULL;
- char *port_s = strtok_r(arg, ":q", &sp);
- char *queue = strtok_r(NULL, "", &sp);
- if (port_s == NULL || queue == NULL) {
- ovs_fatal(0, "\"enqueue\" syntax is \"enqueue:PORT:QUEUE\"");
- }
- put_enqueue_action(b, str_to_u32(port_s), str_to_u32(queue));
+ case OFPUTIL_OFPAT12_SET_FIELD:
+ set_field_parse(arg, ofpacts);
+ break;
+
+ case OFPUTIL_OFPAT10_STRIP_VLAN:
+ ofpact_put_STRIP_VLAN(ofpacts);
+ break;
+
+ case OFPUTIL_OFPAT10_SET_DL_SRC:
+ case OFPUTIL_OFPAT11_SET_DL_SRC:
+ str_to_mac(arg, ofpact_put_SET_ETH_SRC(ofpacts)->mac);
+ break;
+
+ case OFPUTIL_OFPAT10_SET_DL_DST:
+ case OFPUTIL_OFPAT11_SET_DL_DST:
+ str_to_mac(arg, ofpact_put_SET_ETH_DST(ofpacts)->mac);
+ break;
+
+ case OFPUTIL_OFPAT10_SET_NW_SRC:
+ case OFPUTIL_OFPAT11_SET_NW_SRC:
+ str_to_ip(arg, &ip);
+ ofpact_put_SET_IPV4_SRC(ofpacts)->ipv4 = ip;
+ break;
+
+ case OFPUTIL_OFPAT10_SET_NW_DST:
+ case OFPUTIL_OFPAT11_SET_NW_DST:
+ str_to_ip(arg, &ip);
+ ofpact_put_SET_IPV4_DST(ofpacts)->ipv4 = ip;
+ break;
+
+ case OFPUTIL_OFPAT10_SET_NW_TOS:
+ case OFPUTIL_OFPAT11_SET_NW_TOS:
+ tos = str_to_u32(arg);
+ if (tos & ~IP_DSCP_MASK) {
+ ovs_fatal(0, "%s: not a valid TOS", arg);
+ }
+ ofpact_put_SET_IPV4_DSCP(ofpacts)->dscp = tos;
+ break;
+
+ case OFPUTIL_OFPAT10_SET_TP_SRC:
+ case OFPUTIL_OFPAT11_SET_TP_SRC:
+ ofpact_put_SET_L4_SRC_PORT(ofpacts)->port = str_to_u32(arg);
+ break;
+
+ case OFPUTIL_OFPAT10_SET_TP_DST:
+ case OFPUTIL_OFPAT11_SET_TP_DST:
+ ofpact_put_SET_L4_DST_PORT(ofpacts)->port = str_to_u32(arg);
+ break;
+
+ case OFPUTIL_OFPAT10_ENQUEUE:
+ parse_enqueue(arg, ofpacts);
+ break;
+
+ case OFPUTIL_NXAST_RESUBMIT:
+ parse_resubmit(arg, ofpacts);
+ break;
+
+ case OFPUTIL_NXAST_SET_TUNNEL:
+ case OFPUTIL_NXAST_SET_TUNNEL64:
+ tunnel = ofpact_put_SET_TUNNEL(ofpacts);
+ tunnel->ofpact.compat = code;
+ tunnel->tun_id = str_to_u64(arg);
+ break;
+
+ case OFPUTIL_NXAST_SET_QUEUE:
+ ofpact_put_SET_QUEUE(ofpacts)->queue_id = str_to_u32(arg);
+ break;
+
+ case OFPUTIL_NXAST_POP_QUEUE:
+ ofpact_put_POP_QUEUE(ofpacts);
+ break;
+
+ case OFPUTIL_NXAST_REG_MOVE:
+ nxm_parse_reg_move(ofpact_put_REG_MOVE(ofpacts), arg);
+ break;
+
+ case OFPUTIL_NXAST_REG_LOAD:
+ nxm_parse_reg_load(ofpact_put_REG_LOAD(ofpacts), arg);
+ break;
+
+ case OFPUTIL_NXAST_NOTE:
+ parse_note(arg, ofpacts);
+ break;
+
+ case OFPUTIL_NXAST_MULTIPATH:
+ multipath_parse(ofpact_put_MULTIPATH(ofpacts), arg);
+ break;
+
+ case OFPUTIL_NXAST_AUTOPATH__DEPRECATED:
+ autopath_parse(ofpact_put_AUTOPATH(ofpacts), arg);
+ break;
+
+ case OFPUTIL_NXAST_BUNDLE:
+ bundle_parse(arg, ofpacts);
+ break;
+
+ case OFPUTIL_NXAST_BUNDLE_LOAD:
+ bundle_parse_load(arg, ofpacts);
+ break;
+
+ case OFPUTIL_NXAST_RESUBMIT_TABLE:
+ case OFPUTIL_NXAST_OUTPUT_REG:
+ case OFPUTIL_NXAST_DEC_TTL_CNT_IDS:
+ NOT_REACHED();
+
+ case OFPUTIL_NXAST_LEARN:
+ learn_parse(arg, flow, ofpacts);
+ break;
+
+ case OFPUTIL_NXAST_EXIT:
+ ofpact_put_EXIT(ofpacts);
+ break;
+
+ case OFPUTIL_NXAST_DEC_TTL:
+ parse_dec_ttl(ofpacts, arg);
+ break;
+
+ case OFPUTIL_NXAST_FIN_TIMEOUT:
+ parse_fin_timeout(ofpacts, arg);
+ break;
+
+ case OFPUTIL_NXAST_CONTROLLER:
+ parse_controller(ofpacts, arg);
+ break;
+ }
+}
+
+static void
+str_to_ofpacts(const struct flow *flow, char *str, struct ofpbuf *ofpacts)
+{
+ char *pos, *act, *arg;
+ int n_actions;
+
+ pos = str;
+ n_actions = 0;
+ while (ofputil_parse_key_value(&pos, &act, &arg)) {
+ int code = ofputil_action_code_from_name(act);
+ if (code >= 0) {
+ parse_named_action(code, flow, arg, ofpacts);