diff --git a/src/main/java/net/floodlightcontroller/staticflowentry/StaticFlowEntries.java b/src/main/java/net/floodlightcontroller/staticflowentry/StaticFlowEntries.java index 2386090f2d1444eb575eb3aabbe45f65554f7c05..19a220c646a00fa284738d553a04fb94b4d04b34 100644 --- a/src/main/java/net/floodlightcontroller/staticflowentry/StaticFlowEntries.java +++ b/src/main/java/net/floodlightcontroller/staticflowentry/StaticFlowEntries.java @@ -460,13 +460,13 @@ public class StaticFlowEntries { case StaticFlowEntryPusher.COLUMN_MPLS_TC: entry.put(StaticFlowEntryPusher.COLUMN_MPLS_TC, jp.getText()); break; - case StaticFlowEntryPusher.COLUMN_MPLS_BOS: // not supported as match in loxi right now + case StaticFlowEntryPusher.COLUMN_MPLS_BOS: entry.put(StaticFlowEntryPusher.COLUMN_MPLS_BOS, jp.getText()); break; case StaticFlowEntryPusher.COLUMN_METADATA: entry.put(StaticFlowEntryPusher.COLUMN_METADATA, jp.getText()); break; - case StaticFlowEntryPusher.COLUMN_TUNNEL_ID: // not supported as match in loxi right now + case StaticFlowEntryPusher.COLUMN_TUNNEL_ID: entry.put(StaticFlowEntryPusher.COLUMN_TUNNEL_ID, jp.getText()); break; case StaticFlowEntryPusher.COLUMN_PBB_ISID: // not supported as match in loxi right now diff --git a/src/main/java/net/floodlightcontroller/util/ActionUtils.java b/src/main/java/net/floodlightcontroller/util/ActionUtils.java index bcaac2a7f183adbea61950753373ba70bca27f2f..2979af2de14ad288c1e981fceabca57ecacff160 100644 --- a/src/main/java/net/floodlightcontroller/util/ActionUtils.java +++ b/src/main/java/net/floodlightcontroller/util/ActionUtils.java @@ -71,6 +71,7 @@ import org.projectfloodlight.openflow.types.IpDscp; import org.projectfloodlight.openflow.types.IpEcn; import org.projectfloodlight.openflow.types.IpProtocol; import org.projectfloodlight.openflow.types.MacAddress; +import org.projectfloodlight.openflow.types.OFBooleanValue; import org.projectfloodlight.openflow.types.OFGroup; import org.projectfloodlight.openflow.types.OFMetadata; import org.projectfloodlight.openflow.types.OFPort; @@ -100,27 +101,27 @@ public class ActionUtils { public static final String STR_VLAN_STRIP = "strip_vlan"; public static final String STR_VLAN_POP = "pop_vlan"; public static final String STR_VLAN_PUSH = "push_vlan"; - public static final String STR_VLAN_SET_PCP = "mod_vlan_pcp"; - public static final String STR_VLAN_SET_VID = "mod_vlan_vid"; + public static final String STR_VLAN_SET_PCP = "set_vlan_pcp"; + public static final String STR_VLAN_SET_VID = "set_vlan_vid"; public static final String STR_QUEUE_SET = "set_queue"; - public static final String STR_DL_SRC_SET = "mod_dl_src"; - public static final String STR_DL_DST_SET = "mod_dl_dst"; - public static final String STR_NW_SRC_SET = "mod_nw_src"; - public static final String STR_NW_DST_SET = "mod_nw_dst"; - public static final String STR_NW_ECN_SET = "mod_nw_ecn"; - public static final String STR_NW_TOS_SET = "mod_nw_tos"; - public static final String STR_NW_TTL_SET = "mod_nw_ttl"; - public static final String STR_NW_TTL_DEC = "dec_ttl"; + public static final String STR_DL_SRC_SET = "set_eth_src"; + public static final String STR_DL_DST_SET = "set_eth_dst"; + public static final String STR_NW_SRC_SET = "set_ipv4_src"; + public static final String STR_NW_DST_SET = "set_ipv4_dst"; + public static final String STR_NW_ECN_SET = "set_ip_ecn"; + public static final String STR_NW_TOS_SET = "set_ip_tos"; + public static final String STR_NW_TTL_SET = "set_ip_ttl"; + public static final String STR_NW_TTL_DEC = "dec_ip_ttl"; + public static final String STR_TTL_IN_COPY = "copy_ip_ttl_in"; + public static final String STR_TTL_OUT_COPY = "copy_ip_ttl_out"; public static final String STR_MPLS_LABEL_SET = "set_mpls_label"; public static final String STR_MPLS_TC_SET = "set_mpls_tc"; public static final String STR_MPLS_TTL_SET = "set_mpls_ttl"; public static final String STR_MPLS_TTL_DEC = "dec_mpls_ttl"; public static final String STR_MPLS_PUSH = "push_mpls"; public static final String STR_MPLS_POP = "pop_mpls"; - public static final String STR_TP_SRC_SET = "mod_tp_src"; - public static final String STR_TP_DST_SET = "mod_tp_dst"; - public static final String STR_TTL_IN_COPY = "copy_ttl_in"; - public static final String STR_TTL_OUT_COPY = "copy_ttl_out"; + public static final String STR_TP_SRC_SET = "set_tp_src"; + public static final String STR_TP_DST_SET = "set_tp_dst"; public static final String STR_PBB_PUSH = "push_pbb"; public static final String STR_PBB_POP = "pop_pbb"; public static final String STR_GROUP = "group"; @@ -375,6 +376,7 @@ public class ActionUtils { break; case STR_EXPERIMENTER: //no-op. Not implemented + log.error("OFAction EXPERIMENTER not implemented."); break; case STR_FIELD_SET: /* ONLY OF1.1+ should get in here. These should only be header fields valid within a set-field. */ String[] actionData = pair.split(MatchUtils.SET_FIELD_DELIM); @@ -383,9 +385,15 @@ public class ActionUtils { } switch (actionData[0]) { case MatchUtils.STR_ARP_OPCODE: - a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() - .setField(OFFactories.getFactory(fmb.getVersion()).oxms().buildArpOp().setValue(ArpOpcode.of(Integer.parseInt(actionData[1]))).build()) - .build(); + if (actionData[1].startsWith("0x")) { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() + .setField(OFFactories.getFactory(fmb.getVersion()).oxms().buildArpOp().setValue(ArpOpcode.of(Integer.parseInt(actionData[1].replaceFirst("0x", ""), 16))).build()) + .build(); + } else { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() + .setField(OFFactories.getFactory(fmb.getVersion()).oxms().buildArpOp().setValue(ArpOpcode.of(Integer.parseInt(actionData[1]))).build()) + .build(); + } break; case MatchUtils.STR_ARP_SHA: a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() @@ -408,9 +416,15 @@ public class ActionUtils { .build(); break; case MatchUtils.STR_DL_TYPE: - a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() - .setField(OFFactories.getFactory(fmb.getVersion()).oxms().buildEthType().setValue(EthType.of(Integer.parseInt(actionData[1]))).build()) - .build(); + if (actionData[1].startsWith("0x")) { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() + .setField(OFFactories.getFactory(fmb.getVersion()).oxms().buildEthType().setValue(EthType.of(Integer.parseInt(actionData[1].replaceFirst("0x", ""), 16))).build()) + .build(); + } else { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() + .setField(OFFactories.getFactory(fmb.getVersion()).oxms().buildEthType().setValue(EthType.of(Integer.parseInt(actionData[1]))).build()) + .build(); + } break; case MatchUtils.STR_DL_SRC: a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() @@ -423,29 +437,59 @@ public class ActionUtils { .build(); break; case MatchUtils.STR_DL_VLAN: - a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() - .setField(OFFactories.getFactory(fmb.getVersion()).oxms().buildVlanVid().setValue(OFVlanVidMatch.ofVlan(Integer.parseInt(actionData[1]))).build()) - .build(); + if (actionData[1].startsWith("0x")) { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() + .setField(OFFactories.getFactory(fmb.getVersion()).oxms().buildVlanVid().setValue(OFVlanVidMatch.ofVlan(Integer.parseInt(actionData[1].replaceFirst("0x", ""), 16))).build()) + .build(); + } else { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() + .setField(OFFactories.getFactory(fmb.getVersion()).oxms().buildVlanVid().setValue(OFVlanVidMatch.ofVlan(Integer.parseInt(actionData[1]))).build()) + .build(); + } break; case MatchUtils.STR_DL_VLAN_PCP: - a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() - .setField(OFFactories.getFactory(fmb.getVersion()).oxms().buildVlanPcp().setValue(VlanPcp.of(Byte.parseByte(actionData[1]))).build()) - .build(); + if (actionData[1].startsWith("0x")) { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() + .setField(OFFactories.getFactory(fmb.getVersion()).oxms().buildVlanPcp().setValue(VlanPcp.of(Byte.parseByte(actionData[1].replaceFirst("0x", ""), 16))).build()) + .build(); + } else { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() + .setField(OFFactories.getFactory(fmb.getVersion()).oxms().buildVlanPcp().setValue(VlanPcp.of(Byte.parseByte(actionData[1]))).build()) + .build(); + } break; case MatchUtils.STR_ICMP_CODE: - a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() - .setField(OFFactories.getFactory(fmb.getVersion()).oxms().buildIcmpv4Code().setValue(ICMPv4Code.of(Short.parseShort(actionData[1]))).build()) - .build(); + if (actionData[1].startsWith("0x")) { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() + .setField(OFFactories.getFactory(fmb.getVersion()).oxms().buildIcmpv4Code().setValue(ICMPv4Code.of(Short.parseShort(actionData[1].replaceFirst("0x", ""), 16))).build()) + .build(); + } else { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() + .setField(OFFactories.getFactory(fmb.getVersion()).oxms().buildIcmpv4Code().setValue(ICMPv4Code.of(Short.parseShort(actionData[1]))).build()) + .build(); + } break; case MatchUtils.STR_ICMP_TYPE: - a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() - .setField(OFFactories.getFactory(fmb.getVersion()).oxms().buildIcmpv4Type().setValue(ICMPv4Type.of(Short.parseShort(actionData[1]))).build()) - .build(); + if (actionData[1].startsWith("0x")) { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() + .setField(OFFactories.getFactory(fmb.getVersion()).oxms().buildIcmpv4Type().setValue(ICMPv4Type.of(Short.parseShort(actionData[1].replaceFirst("0x", ""), 16))).build()) + .build(); + } else { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() + .setField(OFFactories.getFactory(fmb.getVersion()).oxms().buildIcmpv4Type().setValue(ICMPv4Type.of(Short.parseShort(actionData[1]))).build()) + .build(); + } break; case MatchUtils.STR_NW_PROTO: - a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() - .setField(OFFactories.getFactory(fmb.getVersion()).oxms().buildIpProto().setValue(IpProtocol.of(Short.parseShort(actionData[1]))).build()) - .build(); + if (actionData[1].startsWith("0x")) { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() + .setField(OFFactories.getFactory(fmb.getVersion()).oxms().buildIpProto().setValue(IpProtocol.of(Short.parseShort(actionData[1].replaceFirst("0x", ""), 16))).build()) + .build(); + } else { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() + .setField(OFFactories.getFactory(fmb.getVersion()).oxms().buildIpProto().setValue(IpProtocol.of(Short.parseShort(actionData[1]))).build()) + .build(); + } break; case MatchUtils.STR_NW_SRC: a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() @@ -458,14 +502,26 @@ public class ActionUtils { .build(); break; case MatchUtils.STR_NW_ECN: - a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() - .setField(OFFactories.getFactory(fmb.getVersion()).oxms().buildIpEcn().setValue(IpEcn.of(Byte.parseByte(actionData[1]))).build()) - .build(); + if (actionData[1].startsWith("0x")) { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() + .setField(OFFactories.getFactory(fmb.getVersion()).oxms().buildIpEcn().setValue(IpEcn.of(Byte.parseByte(actionData[1].replaceFirst("0x", ""), 16))).build()) + .build(); + } else { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() + .setField(OFFactories.getFactory(fmb.getVersion()).oxms().buildIpEcn().setValue(IpEcn.of(Byte.parseByte(actionData[1]))).build()) + .build(); + } break; case MatchUtils.STR_NW_DSCP: - a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() - .setField(OFFactories.getFactory(fmb.getVersion()).oxms().buildIpDscp().setValue(IpDscp.of(Byte.parseByte(actionData[1]))).build()) - .build(); + if (actionData[1].startsWith("0x")) { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() + .setField(OFFactories.getFactory(fmb.getVersion()).oxms().buildIpDscp().setValue(IpDscp.of(Byte.parseByte(actionData[1].replaceFirst("0x", ""), 16))).build()) + .build(); + } else { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() + .setField(OFFactories.getFactory(fmb.getVersion()).oxms().buildIpDscp().setValue(IpDscp.of(Byte.parseByte(actionData[1]))).build()) + .build(); + } break; case MatchUtils.STR_SCTP_SRC: a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() @@ -498,19 +554,42 @@ public class ActionUtils { .build(); break; case MatchUtils.STR_MPLS_LABEL: - a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() - .setField(OFFactories.getFactory(fmb.getVersion()).oxms().buildMplsLabel().setValue(U32.of(Long.parseLong(actionData[1]))).build()) - .build(); + if (actionData[1].startsWith("0x")) { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() + .setField(OFFactories.getFactory(fmb.getVersion()).oxms().buildMplsLabel().setValue(U32.of(Long.parseLong(actionData[1].replaceFirst("0x", ""), 16))).build()) + .build(); + } else { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() + .setField(OFFactories.getFactory(fmb.getVersion()).oxms().buildMplsLabel().setValue(U32.of(Long.parseLong(actionData[1]))).build()) + .build(); + } break; case MatchUtils.STR_MPLS_TC: + if (actionData[1].startsWith("0x")) { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() + .setField(OFFactories.getFactory(fmb.getVersion()).oxms().buildMplsTc().setValue(U8.of(Short.parseShort(actionData[1].replaceFirst("0x", ""), 16))).build()) + .build(); + } else { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() + .setField(OFFactories.getFactory(fmb.getVersion()).oxms().buildMplsTc().setValue(U8.of(Short.parseShort(actionData[1]))).build()) + .build(); + } + break; + case MatchUtils.STR_MPLS_BOS: a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() - .setField(OFFactories.getFactory(fmb.getVersion()).oxms().buildMplsTc().setValue(U8.of(Short.parseShort(actionData[1]))).build()) - .build(); + .setField(OFFactories.getFactory(fmb.getVersion()).oxms().buildMplsBos().setValue(OFBooleanValue.of(Boolean.parseBoolean(actionData[1]))).build()) // interprets anything other than "true" as false + .build(); break; case MatchUtils.STR_METADATA: - a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() - .setField(OFFactories.getFactory(fmb.getVersion()).oxms().buildMetadata().setValue(OFMetadata.of(U64.of(Long.parseLong(actionData[1])))).build()) - .build(); + if (actionData[1].startsWith("0x")) { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() + .setField(OFFactories.getFactory(fmb.getVersion()).oxms().buildMetadata().setValue(OFMetadata.of(U64.of(Long.parseLong(actionData[1].replaceFirst("0x", ""), 16)))).build()) + .build(); + } else { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetField() + .setField(OFFactories.getFactory(fmb.getVersion()).oxms().buildMetadata().setValue(OFMetadata.of(U64.of(Long.parseLong(actionData[1])))).build()) + .build(); + } break; default: log.error("UNEXPECTED OF1.3 SET-FIELD '{}'", actionData); @@ -518,37 +597,73 @@ public class ActionUtils { } break; case STR_GROUP: - a = OFFactories.getFactory(fmb.getVersion()).actions().buildGroup() - .setGroup(OFGroup.of(Integer.parseInt(pair))) - .build(); + if (pair.startsWith("0x")) { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildGroup() + .setGroup(OFGroup.of(Integer.parseInt(pair.replaceFirst("0x", ""), 16))) + .build(); + } else { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildGroup() + .setGroup(OFGroup.of(Integer.parseInt(pair))) + .build(); + } break; case STR_MPLS_LABEL_SET: - a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetMplsLabel() - .setMplsLabel(Long.parseLong(pair)) - .build(); + if (pair.startsWith("0x")) { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetMplsLabel() + .setMplsLabel(Long.parseLong(pair.replaceFirst("0x", ""), 16)) + .build(); + } else { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetMplsLabel() + .setMplsLabel(Long.parseLong(pair)) + .build(); + } break; case STR_MPLS_POP: - a = OFFactories.getFactory(fmb.getVersion()).actions().buildPopMpls() - .setEthertype(EthType.of(Integer.parseInt(pair))) - .build(); + if (pair.startsWith("0x")) { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildPopMpls() + .setEthertype(EthType.of(Integer.parseInt(pair.replaceFirst("0x", ""), 16))) + .build(); + } else { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildPopMpls() + .setEthertype(EthType.of(Integer.parseInt(pair))) + .build(); + } break; case STR_MPLS_PUSH: - a = OFFactories.getFactory(fmb.getVersion()).actions().buildPushMpls() - .setEthertype(EthType.of(Integer.parseInt(pair))) - .build(); + if (pair.startsWith("0x")) { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildPushMpls() + .setEthertype(EthType.of(Integer.parseInt(pair.replaceFirst("0x", ""), 16))) + .build(); + } else { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildPushMpls() + .setEthertype(EthType.of(Integer.parseInt(pair))) + .build(); + } break; case STR_MPLS_TC_SET: - a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetMplsTc() - .setMplsTc(Short.parseShort(pair)) - .build(); + if (pair.startsWith("0x")) { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetMplsTc() + .setMplsTc(Short.parseShort(pair.replaceFirst("0x", ""), 16)) + .build(); + } else { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetMplsTc() + .setMplsTc(Short.parseShort(pair)) + .build(); + } break; case STR_MPLS_TTL_DEC: a = OFFactories.getFactory(fmb.getVersion()).actions().decMplsTtl(); break; case STR_MPLS_TTL_SET: - a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetMplsTtl() - .setMplsTtl(Short.parseShort(pair)) - .build(); + if (pair.startsWith("0x")) { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetMplsTtl() + .setMplsTtl(Short.parseShort(pair.replaceFirst("0x", ""), 16)) + .build(); + } else { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetMplsTtl() + .setMplsTtl(Short.parseShort(pair)) + .build(); + } break; case STR_NW_TOS_SET: a = decode_set_tos_bits(pair, fmb.getVersion(), log); // should only be used by OF1.0 @@ -559,31 +674,55 @@ public class ActionUtils { case STR_NW_DST_SET: a = decode_set_dst_ip(pair, fmb.getVersion(), log); break; - case STR_NW_ECN_SET: // loxi does not support DSCP set for OF1.3 - a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetNwEcn() - .setNwEcn(IpEcn.of(Byte.parseByte(pair))) - .build(); + case STR_NW_ECN_SET: // loxi does not support DSCP set for OF1.1 + if (pair.startsWith("0x")) { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetNwEcn() + .setNwEcn(IpEcn.of(Byte.parseByte(pair.replaceFirst("0x", ""), 16))) + .build(); + } else { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetNwEcn() + .setNwEcn(IpEcn.of(Byte.parseByte(pair))) + .build(); + } break; case STR_NW_TTL_DEC: a = OFFactories.getFactory(fmb.getVersion()).actions().decNwTtl(); break; case STR_NW_TTL_SET: - a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetNwTtl() - .setNwTtl(Short.parseShort(pair)) - .build(); + if (pair.startsWith("0x")) { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetNwTtl() + .setNwTtl(Short.parseShort(pair.replaceFirst("0x", ""), 16)) + .build(); + } else { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetNwTtl() + .setNwTtl(Short.parseShort(pair)) + .build(); + } break; case STR_PBB_POP: a = OFFactories.getFactory(fmb.getVersion()).actions().popPbb(); break; case STR_PBB_PUSH: - a = OFFactories.getFactory(fmb.getVersion()).actions().buildPushPbb() - .setEthertype(EthType.of(Integer.parseInt(pair))) - .build(); + if (pair.startsWith("0x")) { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildPushPbb() + .setEthertype(EthType.of(Integer.parseInt(pair.replaceFirst("0x", ""), 16))) + .build(); + } else { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildPushPbb() + .setEthertype(EthType.of(Integer.parseInt(pair))) + .build(); + } break; case STR_QUEUE_SET: - a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetQueue() - .setQueueId(Long.parseLong(pair)) - .build(); + if (pair.startsWith("0x")) { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetQueue() + .setQueueId(Long.parseLong(pair.replaceFirst("0x", ""), 16)) + .build(); + } else { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildSetQueue() + .setQueueId(Long.parseLong(pair)) + .build(); + } break; case STR_TP_SRC_SET: a = decode_set_src_port(pair, fmb.getVersion(), log); @@ -601,9 +740,15 @@ public class ActionUtils { a = OFFactories.getFactory(fmb.getVersion()).actions().popVlan(); break; case STR_VLAN_PUSH: - a = OFFactories.getFactory(fmb.getVersion()).actions().buildPushVlan() - .setEthertype(EthType.of(Integer.parseInt(pair))) - .build(); + if (pair.startsWith("0x")) { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildPushVlan() + .setEthertype(EthType.of(Integer.parseInt(pair.replaceFirst("0x", ""), 16))) + .build(); + } else { + a = OFFactories.getFactory(fmb.getVersion()).actions().buildPushVlan() + .setEthertype(EthType.of(Integer.parseInt(pair))) + .build(); + } break; case STR_VLAN_STRIP: a = OFFactories.getFactory(fmb.getVersion()).actions().stripVlan(); @@ -775,7 +920,7 @@ public class ActionUtils { if (n.group(1) != null) { try { VlanPcp prior = VlanPcp.of(get_byte(n.group(1))); - OFActionSetVlanPcp.Builder ab = OFFactories.getFactory(OFVersion.OF_13).actions().buildSetVlanPcp(); + OFActionSetVlanPcp.Builder ab = OFFactories.getFactory(version).actions().buildSetVlanPcp(); ab.setVlanPcp(prior); log.debug("action {}", ab.build()); return ab.build(); diff --git a/src/main/java/net/floodlightcontroller/util/InstructionUtils.java b/src/main/java/net/floodlightcontroller/util/InstructionUtils.java index 8a42a83e405dec3727b63e180c4f90fde5e7bcdd..013c87d36073f4b7d8f189822f4779a39d0d1882 100644 --- a/src/main/java/net/floodlightcontroller/util/InstructionUtils.java +++ b/src/main/java/net/floodlightcontroller/util/InstructionUtils.java @@ -28,7 +28,7 @@ import sun.reflect.generics.reflectiveObjects.NotImplementedException; * */ public class InstructionUtils { - public static final String STR_GOTO_TABLE = "instruction_goto_table"; + public static final String STR_GOTO_TABLE = "goto_table"; public static final String STR_WRITE_METADATA = "instruction_write_metadata"; public static final String STR_WRITE_ACTIONS = "instruction_write_actions"; public static final String STR_APPLY_ACTIONS = "instruction_apply_actions"; diff --git a/src/main/java/net/floodlightcontroller/util/MatchUtils.java b/src/main/java/net/floodlightcontroller/util/MatchUtils.java index 7cab4f7b4211cc5534ae66faa29d71754e4e8351..66af59b9a647cdf9ad710fd3267a4b6073cbf649 100644 --- a/src/main/java/net/floodlightcontroller/util/MatchUtils.java +++ b/src/main/java/net/floodlightcontroller/util/MatchUtils.java @@ -17,11 +17,13 @@ import org.projectfloodlight.openflow.types.IpDscp; import org.projectfloodlight.openflow.types.IpEcn; import org.projectfloodlight.openflow.types.IpProtocol; import org.projectfloodlight.openflow.types.MacAddress; +import org.projectfloodlight.openflow.types.OFBooleanValue; import org.projectfloodlight.openflow.types.OFMetadata; import org.projectfloodlight.openflow.types.OFPort; import org.projectfloodlight.openflow.types.OFVlanVidMatch; import org.projectfloodlight.openflow.types.TransportPort; import org.projectfloodlight.openflow.types.U32; +import org.projectfloodlight.openflow.types.U64; import org.projectfloodlight.openflow.types.U8; import org.projectfloodlight.openflow.types.VlanPcp; @@ -50,24 +52,24 @@ public class MatchUtils { public static final String STR_IN_PORT = "in_port"; public static final String STR_IN_PHYS_PORT = "in_phys_port"; - public static final String STR_DL_DST = "dl_dst"; - public static final String STR_DL_SRC = "dl_src"; - public static final String STR_DL_TYPE = "dl_type"; - public static final String STR_DL_VLAN = "dl_vlan"; - public static final String STR_DL_VLAN_PCP = "dl_vlan_pcp"; + public static final String STR_DL_DST = "eth_dst"; + public static final String STR_DL_SRC = "eth_src"; + public static final String STR_DL_TYPE = "eth_type"; + public static final String STR_DL_VLAN = "eth_vlan_vid"; + public static final String STR_DL_VLAN_PCP = "eth_vlan_pcp"; - public static final String STR_NW_DST = "nw_dst"; - public static final String STR_NW_SRC = "nw_src"; // should change these to IP, since they don't apply to anything else really + public static final String STR_NW_DST = "ipv4_dst"; + public static final String STR_NW_SRC = "ipv4_src"; public static final String STR_IPV6_DST = "ipv6_dst"; public static final String STR_IPV6_SRC = "ipv6_src"; public static final String STR_IPV6_FLOW_LABEL = "ipv6_label"; - public static final String STR_IPV6_ND_SSL = "nd_ssl"; - public static final String STR_IPV6_ND_TARGET = "nd_target"; - public static final String STR_IPV6_ND_TTL = "nd_ttl"; - public static final String STR_NW_PROTO = "nw_proto"; - public static final String STR_NW_TOS = "nw_tos"; - public static final String STR_NW_ECN = "nw_ecn"; - public static final String STR_NW_DSCP = "nw_dscp"; + public static final String STR_IPV6_ND_SSL = "ipv6_nd_ssl"; + public static final String STR_IPV6_ND_TARGET = "ipv6_nd_target"; + public static final String STR_IPV6_ND_TTL = "ipv6_nd_ttl"; + public static final String STR_NW_PROTO = "ip_proto"; + public static final String STR_NW_TOS = "ip_tos"; + public static final String STR_NW_ECN = "ip_ecn"; + public static final String STR_NW_DSCP = "ip_dscp"; public static final String STR_SCTP_DST = "sctp_dst"; public static final String STR_SCTP_SRC = "sctp_src"; @@ -78,8 +80,8 @@ public class MatchUtils { public static final String STR_TP_DST = "tp_dst"; // support for OF1.0 generic transport ports (possibly sent from the rest api). Only use these to read them in, but store them as the type of port their IpProto is set to. public static final String STR_TP_SRC = "tp_src"; - public static final String STR_ICMP_TYPE = "icmp_type"; - public static final String STR_ICMP_CODE = "icmp_code"; + public static final String STR_ICMP_TYPE = "icmpv4_type"; + public static final String STR_ICMP_CODE = "icmpv4_code"; public static final String STR_ICMPV6_TYPE = "icmpv6_type"; public static final String STR_ICMPV6_CODE = "icmpv6_code"; @@ -382,7 +384,11 @@ public class MatchUtils { } break; case STR_DL_VLAN_PCP: - mb.setExact(MatchField.VLAN_PCP, VlanPcp.of(U8.t(Short.valueOf(key_value[1])))); + if (key_value[1].startsWith("0x")) { + mb.setExact(MatchField.VLAN_PCP, VlanPcp.of(U8.t(Short.valueOf(key_value[1].replaceFirst("0x", ""), 16)))); + } else { + mb.setExact(MatchField.VLAN_PCP, VlanPcp.of(U8.t(Short.valueOf(key_value[1])))); + } break; case STR_NW_DST: mb.setMasked(MatchField.IPV4_DST, IPv4AddressWithMask.of(key_value[1])); @@ -391,17 +397,34 @@ public class MatchUtils { mb.setMasked(MatchField.IPV4_SRC, IPv4AddressWithMask.of(key_value[1])); break; case STR_NW_PROTO: - mb.setExact(MatchField.IP_PROTO, IpProtocol.of(Short.valueOf(key_value[1]))); + if (key_value[1].startsWith("0x")) { + mb.setExact(MatchField.IP_PROTO, IpProtocol.of(Short.valueOf(key_value[1].replaceFirst("0x", ""), 16))); + } else { + mb.setExact(MatchField.IP_PROTO, IpProtocol.of(Short.valueOf(key_value[1]))); + } break; case STR_NW_TOS: - mb.setExact(MatchField.IP_ECN, IpEcn.of(U8.t(Short.valueOf(key_value[1])))); - mb.setExact(MatchField.IP_DSCP, IpDscp.of(U8.t(Short.valueOf(key_value[1])))); + if (key_value[1].startsWith("0x")) { + mb.setExact(MatchField.IP_ECN, IpEcn.of(U8.t(Short.valueOf(key_value[1].replaceFirst("0x", ""), 16)))); + mb.setExact(MatchField.IP_DSCP, IpDscp.of(U8.t(Short.valueOf(key_value[1].replaceFirst("0x", ""), 16)))); + } else { + mb.setExact(MatchField.IP_ECN, IpEcn.of(U8.t(Short.valueOf(key_value[1])))); + mb.setExact(MatchField.IP_DSCP, IpDscp.of(U8.t(Short.valueOf(key_value[1])))); + } break; case STR_NW_ECN: - mb.setExact(MatchField.IP_ECN, IpEcn.of(U8.t(Short.valueOf(key_value[1])))); + if (key_value[1].startsWith("0x")) { + mb.setExact(MatchField.IP_ECN, IpEcn.of(U8.t(Short.valueOf(key_value[1].replaceFirst("0x", ""), 16)))); + } else { + mb.setExact(MatchField.IP_ECN, IpEcn.of(U8.t(Short.valueOf(key_value[1])))); + } break; case STR_NW_DSCP: - mb.setExact(MatchField.IP_DSCP, IpDscp.of(U8.t(Short.valueOf(key_value[1])))); + if (key_value[1].startsWith("0x")) { + mb.setExact(MatchField.IP_DSCP, IpDscp.of(U8.t(Short.valueOf(key_value[1].replaceFirst("0x", ""), 16)))); + } else { + mb.setExact(MatchField.IP_DSCP, IpDscp.of(U8.t(Short.valueOf(key_value[1])))); + } break; case STR_SCTP_DST: // for transport ports, if we don't know the transport protocol yet, postpone parsing this [key, value] pair until we know. Put it at the back of the queue. if (mb.get(MatchField.IP_PROTO) == null) { @@ -468,13 +491,25 @@ public class MatchUtils { } break; case STR_ICMP_TYPE: - mb.setExact(MatchField.ICMPV4_TYPE, ICMPv4Type.of(Short.parseShort(key_value[1]))); + if (key_value[1].startsWith("0x")) { + mb.setExact(MatchField.ICMPV4_TYPE, ICMPv4Type.of(Short.parseShort(key_value[1].replaceFirst("0x", ""), 16))); + } else { + mb.setExact(MatchField.ICMPV4_TYPE, ICMPv4Type.of(Short.parseShort(key_value[1]))); + } break; case STR_ICMP_CODE: - mb.setExact(MatchField.ICMPV4_CODE, ICMPv4Code.of(Short.parseShort(key_value[1]))); + if (key_value[1].startsWith("0x")) { + mb.setExact(MatchField.ICMPV4_CODE, ICMPv4Code.of(Short.parseShort(key_value[1].replaceFirst("0x", ""), 16))); + } else { + mb.setExact(MatchField.ICMPV4_CODE, ICMPv4Code.of(Short.parseShort(key_value[1]))); + } break; case STR_ARP_OPCODE: - mb.setExact(MatchField.ARP_OP, ArpOpcode.of(Integer.parseInt(key_value[1]))); + if (key_value[1].startsWith("0x")) { + mb.setExact(MatchField.ARP_OP, ArpOpcode.of(Integer.parseInt(key_value[1].replaceFirst("0x", ""), 16))); + } else { + mb.setExact(MatchField.ARP_OP, ArpOpcode.of(Integer.parseInt(key_value[1]))); + } break; case STR_ARP_SHA: mb.setExact(MatchField.ARP_SHA, MacAddress.of(key_value[1])); @@ -489,22 +524,43 @@ public class MatchUtils { mb.setExact(MatchField.ARP_TPA, IPv4Address.of(key_value[1])); break; case STR_MPLS_LABEL: - mb.setExact(MatchField.MPLS_LABEL, U32.of(Long.parseLong(key_value[1]))); + if (key_value[1].startsWith("0x")) { + mb.setExact(MatchField.MPLS_LABEL, U32.of(Long.parseLong(key_value[1].replaceFirst("0x", ""), 16))); + } else { + mb.setExact(MatchField.MPLS_LABEL, U32.of(Long.parseLong(key_value[1]))); + } break; case STR_MPLS_TC: - mb.setExact(MatchField.MPLS_TC, U8.of(Short.parseShort(key_value[1]))); + if (key_value[1].startsWith("0x")) { + mb.setExact(MatchField.MPLS_TC, U8.of(Short.parseShort(key_value[1].replaceFirst("0x", ""), 16))); + } else { + mb.setExact(MatchField.MPLS_TC, U8.of(Short.parseShort(key_value[1]))); + } break; case STR_MPLS_BOS: - //no-op. Not implemented. + mb.setExact(MatchField.MPLS_BOS, key_value[1].equalsIgnoreCase("true") ? OFBooleanValue.TRUE : OFBooleanValue.FALSE); break; case STR_METADATA: - mb.setExact(MatchField.METADATA, OFMetadata.ofRaw(Long.parseLong(key_value[1]))); + if (key_value[1].startsWith("0x")) { + mb.setExact(MatchField.METADATA, OFMetadata.ofRaw(Long.parseLong(key_value[1].replaceFirst("0x", ""), 16))); + } else { + mb.setExact(MatchField.METADATA, OFMetadata.ofRaw(Long.parseLong(key_value[1]))); + } break; case STR_TUNNEL_ID: - //no-op. Not implemented. + if (key_value[1].startsWith("0x")) { + mb.setExact(MatchField.TUNNEL_ID, U64.of(Long.parseLong(key_value[1].replaceFirst("0x", ""), 16))); + } else { + mb.setExact(MatchField.TUNNEL_ID, U64.of(Long.parseLong(key_value[1]))); + } break; case STR_PBB_ISID: - //no-op. Not implemented. + /*TODO no-op. Not implemented. + if (key_value[1].startsWith("0x")) { + mb.setExact(MatchField., U64.of(Long.parseLong(key_value[1].replaceFirst("0x", ""), 16))); + } else { + mb.setExact(MatchField., U64.of(Long.parseLong(key_value[1]))); + } */ break; default: throw new IllegalArgumentException("unknown token " + key_value + " parsing " + match); diff --git a/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImplTest.java b/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImplTest.java index 98944b8c8d76f305ffaa01d5985bf9a64a6f11c3..55dba93e1014d6b30a714e0497faeaa8b8b1aed9 100644 --- a/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImplTest.java +++ b/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImplTest.java @@ -74,8 +74,6 @@ import net.floodlightcontroller.devicemanager.internal.DeviceSyncRepresentation. import net.floodlightcontroller.devicemanager.test.MockEntityClassifier; import net.floodlightcontroller.devicemanager.test.MockEntityClassifierMac; import net.floodlightcontroller.devicemanager.test.MockFlexEntityClassifier; -import net.floodlightcontroller.flowcache.FlowReconcileManager; -import net.floodlightcontroller.flowcache.IFlowReconcileService; import net.floodlightcontroller.packet.ARP; import net.floodlightcontroller.packet.Data; import net.floodlightcontroller.packet.Ethernet; @@ -128,7 +126,6 @@ public class DeviceManagerImplTest extends FloodlightTestCase { DeviceManagerImpl deviceManager; MemoryStorageSource storageSource; - FlowReconcileManager flowReconcileMgr; IDebugCounterService debugCounterService; IDebugEventService debugEventService; @@ -187,14 +184,12 @@ public class DeviceManagerImplTest extends FloodlightTestCase { deviceManager = new DeviceManagerImpl(); - flowReconcileMgr = new FlowReconcileManager(); DefaultEntityClassifier entityClassifier = new DefaultEntityClassifier(); fmc.addService(IDeviceService.class, deviceManager); storageSource = new MemoryStorageSource(); fmc.addService(IStorageSourceService.class, storageSource); fmc.addService(IFloodlightProviderService.class, mockFloodlightProvider); fmc.addService(IRestApiService.class, restApi); - fmc.addService(IFlowReconcileService.class, flowReconcileMgr); fmc.addService(IEntityClassifierService.class, entityClassifier); fmc.addService(ITopologyService.class, topology); fmc.addService(ISyncService.class, syncService); @@ -204,12 +199,10 @@ public class DeviceManagerImplTest extends FloodlightTestCase { restApi.init(fmc); storageSource.init(fmc); deviceManager.init(fmc); - flowReconcileMgr.init(fmc); entityClassifier.init(fmc); syncService.init(fmc); storageSource.startUp(fmc); deviceManager.startUp(fmc); - flowReconcileMgr.startUp(fmc); tp.startUp(fmc); entityClassifier.startUp(fmc); syncService.startUp(fmc); diff --git a/src/test/java/net/floodlightcontroller/staticflowentry/StaticFlowTests.java b/src/test/java/net/floodlightcontroller/staticflowentry/StaticFlowTests.java index 93c4430bfff84304f88e0776bad4c69488e89c92..562edb123c31bba2224b5e30c3f0a6c5d3c4d42a 100644 --- a/src/test/java/net/floodlightcontroller/staticflowentry/StaticFlowTests.java +++ b/src/test/java/net/floodlightcontroller/staticflowentry/StaticFlowTests.java @@ -80,7 +80,7 @@ public class StaticFlowTests extends FloodlightTestCase { // setup match Match match; TestRule1.put(COLUMN_DL_DST, "00:20:30:40:50:60"); - match = MatchUtils.fromString("dl_dst=00:20:30:40:50:60", factory.getVersion()); + match = MatchUtils.fromString("eth_dst=00:20:30:40:50:60", factory.getVersion()); // setup actions List<OFAction> actions = new LinkedList<OFAction>(); TestRule1.put(COLUMN_ACTIONS, "output=1"); @@ -107,7 +107,7 @@ public class StaticFlowTests extends FloodlightTestCase { Match match; TestRule2.put(COLUMN_DL_TYPE, "0x800"); TestRule2.put(COLUMN_NW_DST, "192.168.1.0/24"); - match = MatchUtils.fromString("dl_type=0x800,nw_dst=192.168.1.0/24", factory.getVersion()); + match = MatchUtils.fromString("eth_type=0x800,ipv4_dst=192.168.1.0/24", factory.getVersion()); // setup actions List<OFAction> actions = new LinkedList<OFAction>(); TestRule2.put(COLUMN_ACTIONS, "output=1"); @@ -142,7 +142,7 @@ public class StaticFlowTests extends FloodlightTestCase { Match match; TestRule3.put(COLUMN_DL_DST, "00:20:30:40:50:60"); TestRule3.put(COLUMN_DL_VLAN, 96); - match = MatchUtils.fromString("dl_dst=00:20:30:40:50:60,dl_vlan=96", factory.getVersion()); + match = MatchUtils.fromString("eth_dst=00:20:30:40:50:60,eth_vlan_vid=96", factory.getVersion()); // setup actions TestRule3.put(COLUMN_ACTIONS, "output=controller"); List<OFAction> actions = new LinkedList<OFAction>(); @@ -317,7 +317,7 @@ public class StaticFlowTests extends FloodlightTestCase { FlowMod3 = FlowModUtils.toFlowDeleteStrict(FlowMod3); verifyFlowMod(removeFlowMod, FlowMod3); FlowMod3 = FlowModUtils.toFlowAdd(FlowMod3); - FlowMod3 = FlowMod3.createBuilder().setMatch(MatchUtils.fromString("dl_dst=00:20:30:40:50:60,dl_vlan=333", factory.getVersion())).setXid(14).build(); + FlowMod3 = FlowMod3.createBuilder().setMatch(MatchUtils.fromString("eth_dst=00:20:30:40:50:60,eth_vlan_vid=333", factory.getVersion())).setXid(14).build(); OFFlowMod updateFlowMod = (OFFlowMod) outList.get(1); verifyFlowMod(updateFlowMod, FlowMod3); writeCaptureList.reset();