Skip to content
Snippets Groups Projects
Commit e85b0bbb authored by Ryan Izard's avatar Ryan Izard
Browse files

Merge pull request #544 from rizard/master

Fixed a couple SFP bugs and a long-time unit test dependency bug
parents 973d0ed0 91cbd8e4
No related branches found
No related tags found
No related merge requests found
...@@ -41,7 +41,6 @@ import org.projectfloodlight.openflow.protocol.oxm.OFOxmEthSrc; ...@@ -41,7 +41,6 @@ import org.projectfloodlight.openflow.protocol.oxm.OFOxmEthSrc;
import org.projectfloodlight.openflow.protocol.oxm.OFOxmEthType; import org.projectfloodlight.openflow.protocol.oxm.OFOxmEthType;
import org.projectfloodlight.openflow.protocol.oxm.OFOxmIcmpv4Code; import org.projectfloodlight.openflow.protocol.oxm.OFOxmIcmpv4Code;
import org.projectfloodlight.openflow.protocol.oxm.OFOxmIcmpv4Type; import org.projectfloodlight.openflow.protocol.oxm.OFOxmIcmpv4Type;
import org.projectfloodlight.openflow.protocol.oxm.OFOxmIcmpv6Code; import org.projectfloodlight.openflow.protocol.oxm.OFOxmIcmpv6Code;
import org.projectfloodlight.openflow.protocol.oxm.OFOxmIcmpv6Type; import org.projectfloodlight.openflow.protocol.oxm.OFOxmIcmpv6Type;
import org.projectfloodlight.openflow.protocol.oxm.OFOxmIpDscp; import org.projectfloodlight.openflow.protocol.oxm.OFOxmIpDscp;
...@@ -49,7 +48,6 @@ import org.projectfloodlight.openflow.protocol.oxm.OFOxmIpEcn; ...@@ -49,7 +48,6 @@ import org.projectfloodlight.openflow.protocol.oxm.OFOxmIpEcn;
import org.projectfloodlight.openflow.protocol.oxm.OFOxmIpProto; import org.projectfloodlight.openflow.protocol.oxm.OFOxmIpProto;
import org.projectfloodlight.openflow.protocol.oxm.OFOxmIpv4Dst; import org.projectfloodlight.openflow.protocol.oxm.OFOxmIpv4Dst;
import org.projectfloodlight.openflow.protocol.oxm.OFOxmIpv4Src; import org.projectfloodlight.openflow.protocol.oxm.OFOxmIpv4Src;
import org.projectfloodlight.openflow.protocol.oxm.OFOxmIpv6Dst; import org.projectfloodlight.openflow.protocol.oxm.OFOxmIpv6Dst;
import org.projectfloodlight.openflow.protocol.oxm.OFOxmIpv6Flabel; import org.projectfloodlight.openflow.protocol.oxm.OFOxmIpv6Flabel;
import org.projectfloodlight.openflow.protocol.oxm.OFOxmIpv6NdSll; import org.projectfloodlight.openflow.protocol.oxm.OFOxmIpv6NdSll;
...@@ -105,190 +103,199 @@ public class OFActionListSerializer extends JsonSerializer<List<OFAction>> { ...@@ -105,190 +103,199 @@ public class OFActionListSerializer extends JsonSerializer<List<OFAction>> {
* @throws JsonProcessingException * @throws JsonProcessingException
*/ */
public static void serializeActions(JsonGenerator jsonGenerator, List<OFAction> actions) throws IOException, JsonProcessingException { public static void serializeActions(JsonGenerator jsonGenerator, List<OFAction> actions) throws IOException, JsonProcessingException {
if (actions.isEmpty()) { StringBuilder sb = new StringBuilder();
jsonGenerator.writeStringField("none", "drop"); int len = actions.size();
} int pos = 0;
for (OFAction a : actions) { for (OFAction a : actions) {
switch (a.getType()) { switch (a.getType()) {
case OUTPUT: case OUTPUT:
jsonGenerator.writeStringField(ActionUtils.STR_OUTPUT, ((OFActionOutput)a).getPort().toString()); sb.append(ActionUtils.STR_OUTPUT).append("=").append(((OFActionOutput)a).getPort().toString());
break; break;
/* begin OF1.0 ONLY actions */ /* begin OF1.0 ONLY actions */
case SET_VLAN_VID: case SET_VLAN_VID:
jsonGenerator.writeNumberField(ActionUtils.STR_VLAN_SET_VID, ((OFActionSetVlanVid)a).getVlanVid().getVlan()); sb.append(ActionUtils.STR_VLAN_SET_VID).append("=").append(((OFActionSetVlanVid)a).getVlanVid().getVlan());
break; break;
case SET_VLAN_PCP: case SET_VLAN_PCP:
jsonGenerator.writeNumberField(ActionUtils.STR_VLAN_SET_PCP, ((OFActionSetVlanPcp)a).getVlanPcp().getValue()); sb.append(ActionUtils.STR_VLAN_SET_PCP).append("=").append(((OFActionSetVlanPcp)a).getVlanPcp().getValue());
break; break;
case SET_QUEUE: case SET_QUEUE:
jsonGenerator.writeNumberField(ActionUtils.STR_QUEUE_SET, ((OFActionSetQueue)a).getQueueId()); sb.append(ActionUtils.STR_QUEUE_SET).append("=").append(((OFActionSetQueue)a).getQueueId());
break; break;
case SET_DL_SRC: case SET_DL_SRC:
jsonGenerator.writeStringField(ActionUtils.STR_DL_SRC_SET, ((OFActionSetDlSrc)a).getDlAddr().toString()); sb.append(ActionUtils.STR_DL_SRC_SET).append("=").append(((OFActionSetDlSrc)a).getDlAddr().toString());
break; break;
case SET_DL_DST: case SET_DL_DST:
jsonGenerator.writeStringField(ActionUtils.STR_DL_DST_SET, ((OFActionSetDlDst)a).getDlAddr().toString()); sb.append(ActionUtils.STR_DL_DST_SET).append("=").append(((OFActionSetDlDst)a).getDlAddr().toString());
break; break;
case SET_NW_SRC: case SET_NW_SRC:
jsonGenerator.writeStringField(ActionUtils.STR_NW_SRC_SET, ((OFActionSetNwSrc)a).getNwAddr().toString()); sb.append(ActionUtils.STR_NW_SRC_SET).append("=").append(((OFActionSetNwSrc)a).getNwAddr().toString());
break; break;
case SET_NW_DST: case SET_NW_DST:
jsonGenerator.writeStringField(ActionUtils.STR_NW_DST_SET, ((OFActionSetNwDst)a).getNwAddr().toString()); sb.append(ActionUtils.STR_NW_DST_SET).append("=").append(((OFActionSetNwDst)a).getNwAddr().toString());
break; break;
case SET_NW_TOS: case SET_NW_TOS:
jsonGenerator.writeNumberField(ActionUtils.STR_NW_TOS_SET, ((OFActionSetNwTos)a).getNwTos()); sb.append(ActionUtils.STR_NW_TOS_SET).append("=").append(((OFActionSetNwTos)a).getNwTos());
break; break;
case SET_TP_SRC: case SET_TP_SRC:
jsonGenerator.writeNumberField(ActionUtils.STR_TP_SRC_SET, ((OFActionSetTpSrc)a).getTpPort().getPort()); sb.append(ActionUtils.STR_TP_SRC_SET).append("=").append(((OFActionSetTpSrc)a).getTpPort().getPort());
break; break;
case SET_TP_DST: case SET_TP_DST:
jsonGenerator.writeNumberField(ActionUtils.STR_TP_DST_SET, ((OFActionSetTpDst)a).getTpPort().getPort()); sb.append(ActionUtils.STR_TP_DST_SET).append("=").append(((OFActionSetTpDst)a).getTpPort().getPort());
break; break;
/* end OF1.0 ONLY actions; begin OF1.1+ actions */ /* end OF1.0 ONLY actions; begin OF1.1+ actions */
case ENQUEUE: case ENQUEUE:
jsonGenerator.writeNumberField(ActionUtils.STR_ENQUEUE, ((OFActionEnqueue)a).getPort().getPortNumber()); sb.append(ActionUtils.STR_ENQUEUE).append("=").append(((OFActionEnqueue)a).getPort().getPortNumber());
break; break;
case GROUP: case GROUP:
jsonGenerator.writeStringField(ActionUtils.STR_GROUP, ((OFActionGroup)a).getGroup().toString()); sb.append(ActionUtils.STR_GROUP).append("=").append(((OFActionGroup)a).getGroup().toString());
break; break;
case STRIP_VLAN: case STRIP_VLAN:
jsonGenerator.writeStringField(ActionUtils.STR_VLAN_STRIP, ActionUtils.STR_NOT_APPLICABLE); sb.append(ActionUtils.STR_VLAN_STRIP).append("=").append(ActionUtils.STR_NOT_APPLICABLE);
break; break;
case PUSH_VLAN: case PUSH_VLAN:
jsonGenerator.writeNumberField(ActionUtils.STR_VLAN_PUSH, ((OFActionPushVlan)a).getEthertype().getValue()); sb.append(ActionUtils.STR_VLAN_PUSH).append("=").append(((OFActionPushVlan)a).getEthertype().getValue());
break; break;
case PUSH_MPLS: case PUSH_MPLS:
jsonGenerator.writeNumberField(ActionUtils.STR_MPLS_PUSH, ((OFActionPushMpls)a).getEthertype().getValue()); sb.append(ActionUtils.STR_MPLS_PUSH).append("=").append(((OFActionPushMpls)a).getEthertype().getValue());
break; break;
case PUSH_PBB: case PUSH_PBB:
jsonGenerator.writeNumberField(ActionUtils.STR_PBB_PUSH, ((OFActionPushPbb)a).getEthertype().getValue()); sb.append(ActionUtils.STR_PBB_PUSH).append("=").append(((OFActionPushPbb)a).getEthertype().getValue());
break; break;
case POP_VLAN: case POP_VLAN:
jsonGenerator.writeStringField(ActionUtils.STR_VLAN_POP, ActionUtils.STR_NOT_APPLICABLE); sb.append(ActionUtils.STR_VLAN_POP).append("=").append(ActionUtils.STR_NOT_APPLICABLE);
break; break;
case POP_MPLS: case POP_MPLS:
jsonGenerator.writeNumberField(ActionUtils.STR_MPLS_POP, ((OFActionPopMpls)a).getEthertype().getValue()); sb.append(ActionUtils.STR_MPLS_POP).append("=").append(((OFActionPopMpls)a).getEthertype().getValue());
break; break;
case POP_PBB: case POP_PBB:
jsonGenerator.writeStringField(ActionUtils.STR_PBB_POP, ActionUtils.STR_NOT_APPLICABLE); sb.append(ActionUtils.STR_PBB_POP).append("=").append(ActionUtils.STR_NOT_APPLICABLE);
break; break;
case COPY_TTL_IN: case COPY_TTL_IN:
jsonGenerator.writeStringField(ActionUtils.STR_TTL_IN_COPY, ActionUtils.STR_NOT_APPLICABLE); sb.append(ActionUtils.STR_TTL_IN_COPY).append("=").append(ActionUtils.STR_NOT_APPLICABLE);
break; break;
case COPY_TTL_OUT: case COPY_TTL_OUT:
jsonGenerator.writeStringField(ActionUtils.STR_TTL_OUT_COPY, ActionUtils.STR_NOT_APPLICABLE); sb.append(ActionUtils.STR_TTL_OUT_COPY).append("=").append(ActionUtils.STR_NOT_APPLICABLE);
break; break;
case DEC_NW_TTL: case DEC_NW_TTL:
jsonGenerator.writeStringField(ActionUtils.STR_NW_TTL_DEC, ActionUtils.STR_NOT_APPLICABLE); sb.append(ActionUtils.STR_NW_TTL_DEC).append("=").append(ActionUtils.STR_NOT_APPLICABLE);
break; break;
case DEC_MPLS_TTL: case DEC_MPLS_TTL:
jsonGenerator.writeStringField(ActionUtils.STR_MPLS_TTL_DEC, ActionUtils.STR_NOT_APPLICABLE); sb.append(ActionUtils.STR_MPLS_TTL_DEC).append("=").append(ActionUtils.STR_NOT_APPLICABLE);
break; break;
case SET_MPLS_LABEL: case SET_MPLS_LABEL:
jsonGenerator.writeNumberField(ActionUtils.STR_MPLS_LABEL_SET, ((OFActionSetMplsLabel)a).getMplsLabel()); sb.append(ActionUtils.STR_MPLS_LABEL_SET).append("=").append(((OFActionSetMplsLabel)a).getMplsLabel());
break; break;
case SET_MPLS_TC: case SET_MPLS_TC:
jsonGenerator.writeNumberField(ActionUtils.STR_MPLS_TC_SET, ((OFActionSetMplsTc)a).getMplsTc()); sb.append(ActionUtils.STR_MPLS_TC_SET).append("=").append(((OFActionSetMplsTc)a).getMplsTc());
break; break;
case SET_MPLS_TTL: case SET_MPLS_TTL:
jsonGenerator.writeNumberField(ActionUtils.STR_MPLS_TTL_SET, ((OFActionSetMplsTtl)a).getMplsTtl()); sb.append(ActionUtils.STR_MPLS_TTL_SET).append("=").append(((OFActionSetMplsTtl)a).getMplsTtl());
break; break;
case SET_NW_ECN: case SET_NW_ECN:
jsonGenerator.writeNumberField(ActionUtils.STR_NW_ECN_SET, ((OFActionSetNwEcn)a).getNwEcn().getEcnValue()); sb.append(ActionUtils.STR_NW_ECN_SET).append("=").append(((OFActionSetNwEcn)a).getNwEcn().getEcnValue());
break; break;
case SET_NW_TTL: case SET_NW_TTL:
jsonGenerator.writeNumberField(ActionUtils.STR_NW_TTL_SET, ((OFActionSetNwTtl)a).getNwTtl()); sb.append(ActionUtils.STR_NW_TTL_SET).append("=").append(((OFActionSetNwTtl)a).getNwTtl());
break; break;
case EXPERIMENTER: case EXPERIMENTER:
jsonGenerator.writeNumberField(ActionUtils.STR_EXPERIMENTER, ((OFActionExperimenter)a).getExperimenter()); sb.append(ActionUtils.STR_EXPERIMENTER).append("=").append(((OFActionExperimenter)a).getExperimenter());
break; break;
case SET_FIELD: case SET_FIELD:
if (((OFActionSetField)a).getField() instanceof OFOxmArpOp) { if (((OFActionSetField)a).getField() instanceof OFOxmArpOp) {
jsonGenerator.writeNumberField(MatchUtils.STR_ARP_OPCODE, ((OFOxmArpOp) ((OFActionSetField) a).getField()).getValue().getOpcode()); sb.append(MatchUtils.STR_ARP_OPCODE).append("=").append(((OFOxmArpOp) ((OFActionSetField) a).getField()).getValue().getOpcode());
} else if (((OFActionSetField)a).getField() instanceof OFOxmArpSha) { } else if (((OFActionSetField)a).getField() instanceof OFOxmArpSha) {
jsonGenerator.writeStringField(MatchUtils.STR_ARP_SHA, ((OFOxmArpSha) ((OFActionSetField) a).getField()).getValue().toString()); // macaddress formats string already sb.append(MatchUtils.STR_ARP_SHA).append("=").append(((OFOxmArpSha) ((OFActionSetField) a).getField()).getValue().toString()); // macaddress formats string already
} else if (((OFActionSetField)a).getField() instanceof OFOxmArpTha) { } else if (((OFActionSetField)a).getField() instanceof OFOxmArpTha) {
jsonGenerator.writeStringField(MatchUtils.STR_ARP_DHA, ((OFOxmArpTha) ((OFActionSetField) a).getField()).getValue().toString()); sb.append(MatchUtils.STR_ARP_DHA).append("=").append(((OFOxmArpTha) ((OFActionSetField) a).getField()).getValue().toString());
} else if (((OFActionSetField)a).getField() instanceof OFOxmArpSpa) { } else if (((OFActionSetField)a).getField() instanceof OFOxmArpSpa) {
jsonGenerator.writeStringField(MatchUtils.STR_ARP_SPA, ((OFOxmArpSpa) ((OFActionSetField) a).getField()).getValue().toString()); // ipaddress formats string already sb.append(MatchUtils.STR_ARP_SPA).append("=").append(((OFOxmArpSpa) ((OFActionSetField) a).getField()).getValue().toString()); // ipaddress formats string already
} else if (((OFActionSetField)a).getField() instanceof OFOxmArpTpa) { } else if (((OFActionSetField)a).getField() instanceof OFOxmArpTpa) {
jsonGenerator.writeStringField(MatchUtils.STR_ARP_DPA, ((OFOxmArpTpa) ((OFActionSetField) a).getField()).getValue().toString()); sb.append(MatchUtils.STR_ARP_DPA).append("=").append(((OFOxmArpTpa) ((OFActionSetField) a).getField()).getValue().toString());
} else if (((OFActionSetField)a).getField() instanceof OFOxmIpv6NdSll) { } else if (((OFActionSetField)a).getField() instanceof OFOxmIpv6NdSll) {
jsonGenerator.writeStringField(MatchUtils.STR_IPV6_ND_SSL, ((OFOxmIpv6NdSll) ((OFActionSetField) a).getField()).getValue().toString()); sb.append(MatchUtils.STR_IPV6_ND_SSL).append("=").append(((OFOxmIpv6NdSll) ((OFActionSetField) a).getField()).getValue().toString());
} else if (((OFActionSetField)a).getField() instanceof OFOxmIpv6NdTll) { } else if (((OFActionSetField)a).getField() instanceof OFOxmIpv6NdTll) {
jsonGenerator.writeStringField(MatchUtils.STR_IPV6_ND_TTL, ((OFOxmIpv6NdTll) ((OFActionSetField) a).getField()).getValue().toString()); sb.append(MatchUtils.STR_IPV6_ND_TTL).append("=").append(((OFOxmIpv6NdTll) ((OFActionSetField) a).getField()).getValue().toString());
} else if (((OFActionSetField)a).getField() instanceof OFOxmIpv6NdTarget) { } else if (((OFActionSetField)a).getField() instanceof OFOxmIpv6NdTarget) {
jsonGenerator.writeStringField(MatchUtils.STR_IPV6_ND_TARGET, ((OFOxmIpv6NdTarget) ((OFActionSetField) a).getField()).getValue().toString()); sb.append(MatchUtils.STR_IPV6_ND_TARGET).append("=").append(((OFOxmIpv6NdTarget) ((OFActionSetField) a).getField()).getValue().toString());
} }
/* DATA LAYER */ /* DATA LAYER */
else if (((OFActionSetField)a).getField() instanceof OFOxmEthType) { else if (((OFActionSetField)a).getField() instanceof OFOxmEthType) {
jsonGenerator.writeNumberField(MatchUtils.STR_DL_TYPE, ((OFOxmEthType) ((OFActionSetField) a).getField()).getValue().getValue()); sb.append(MatchUtils.STR_DL_TYPE).append("=").append(((OFOxmEthType) ((OFActionSetField) a).getField()).getValue().getValue());
} else if (((OFActionSetField)a).getField() instanceof OFOxmEthSrc) { } else if (((OFActionSetField)a).getField() instanceof OFOxmEthSrc) {
jsonGenerator.writeStringField(MatchUtils.STR_DL_SRC, ((OFOxmEthSrc) ((OFActionSetField) a).getField()).getValue().toString()); sb.append(MatchUtils.STR_DL_SRC).append("=").append(((OFOxmEthSrc) ((OFActionSetField) a).getField()).getValue().toString());
} else if (((OFActionSetField)a).getField() instanceof OFOxmEthDst) { } else if (((OFActionSetField)a).getField() instanceof OFOxmEthDst) {
jsonGenerator.writeStringField(MatchUtils.STR_DL_DST, ((OFOxmEthDst) ((OFActionSetField) a).getField()).getValue().toString()); sb.append(MatchUtils.STR_DL_DST).append("=").append(((OFOxmEthDst) ((OFActionSetField) a).getField()).getValue().toString());
} else if (((OFActionSetField)a).getField() instanceof OFOxmVlanVid) { } else if (((OFActionSetField)a).getField() instanceof OFOxmVlanVid) {
jsonGenerator.writeNumberField(MatchUtils.STR_DL_VLAN, ((OFOxmVlanVid) ((OFActionSetField) a).getField()).getValue().getVlan()); sb.append(MatchUtils.STR_DL_VLAN).append("=").append(((OFOxmVlanVid) ((OFActionSetField) a).getField()).getValue().getVlan());
} else if (((OFActionSetField)a).getField() instanceof OFOxmVlanPcp) { } else if (((OFActionSetField)a).getField() instanceof OFOxmVlanPcp) {
} }
/* ICMP */ /* ICMP */
else if (((OFActionSetField)a).getField() instanceof OFOxmIcmpv4Code) { else if (((OFActionSetField)a).getField() instanceof OFOxmIcmpv4Code) {
jsonGenerator.writeNumberField(MatchUtils.STR_ICMP_CODE, ((OFOxmIcmpv4Code) ((OFActionSetField) a).getField()).getValue().getCode()); sb.append(MatchUtils.STR_ICMP_CODE).append("=").append(((OFOxmIcmpv4Code) ((OFActionSetField) a).getField()).getValue().getCode());
} else if (((OFActionSetField)a).getField() instanceof OFOxmIcmpv4Type) { } else if (((OFActionSetField)a).getField() instanceof OFOxmIcmpv4Type) {
jsonGenerator.writeNumberField(MatchUtils.STR_ICMP_TYPE, ((OFOxmIcmpv4Type) ((OFActionSetField) a).getField()).getValue().getType()); sb.append(MatchUtils.STR_ICMP_TYPE).append("=").append(((OFOxmIcmpv4Type) ((OFActionSetField) a).getField()).getValue().getType());
} else if (((OFActionSetField)a).getField() instanceof OFOxmIcmpv6Code) { } else if (((OFActionSetField)a).getField() instanceof OFOxmIcmpv6Code) {
jsonGenerator.writeNumberField(MatchUtils.STR_ICMPV6_CODE, ((OFOxmIcmpv6Code) ((OFActionSetField) a).getField()).getValue().getRaw()); sb.append(MatchUtils.STR_ICMPV6_CODE).append("=").append(((OFOxmIcmpv6Code) ((OFActionSetField) a).getField()).getValue().getRaw());
} else if (((OFActionSetField)a).getField() instanceof OFOxmIcmpv6Type) { } else if (((OFActionSetField)a).getField() instanceof OFOxmIcmpv6Type) {
jsonGenerator.writeNumberField(MatchUtils.STR_ICMPV6_TYPE, ((OFOxmIcmpv6Type) ((OFActionSetField) a).getField()).getValue().getRaw()); sb.append(MatchUtils.STR_ICMPV6_TYPE).append("=").append(((OFOxmIcmpv6Type) ((OFActionSetField) a).getField()).getValue().getRaw());
} }
/* NETWORK LAYER */ /* NETWORK LAYER */
else if (((OFActionSetField)a).getField() instanceof OFOxmIpProto) { else if (((OFActionSetField)a).getField() instanceof OFOxmIpProto) {
jsonGenerator.writeNumberField(MatchUtils.STR_NW_PROTO, ((OFOxmIpProto) ((OFActionSetField) a).getField()).getValue().getIpProtocolNumber()); sb.append(MatchUtils.STR_NW_PROTO).append("=").append(((OFOxmIpProto) ((OFActionSetField) a).getField()).getValue().getIpProtocolNumber());
} else if (((OFActionSetField)a).getField() instanceof OFOxmIpv4Src) { } else if (((OFActionSetField)a).getField() instanceof OFOxmIpv4Src) {
jsonGenerator.writeStringField(MatchUtils.STR_NW_SRC, ((OFOxmIpv4Src) ((OFActionSetField) a).getField()).getValue().toString()); sb.append(MatchUtils.STR_NW_SRC).append("=").append(((OFOxmIpv4Src) ((OFActionSetField) a).getField()).getValue().toString());
} else if (((OFActionSetField)a).getField() instanceof OFOxmIpv4Dst) { } else if (((OFActionSetField)a).getField() instanceof OFOxmIpv4Dst) {
jsonGenerator.writeStringField(MatchUtils.STR_NW_DST, ((OFOxmIpv4Dst) ((OFActionSetField) a).getField()).getValue().toString()); sb.append(MatchUtils.STR_NW_DST).append("=").append(((OFOxmIpv4Dst) ((OFActionSetField) a).getField()).getValue().toString());
} else if (((OFActionSetField)a).getField() instanceof OFOxmIpv6Src) { } else if (((OFActionSetField)a).getField() instanceof OFOxmIpv6Src) {
jsonGenerator.writeStringField(MatchUtils.STR_IPV6_SRC, ((OFOxmIpv6Src) ((OFActionSetField) a).getField()).getValue().toString()); sb.append(MatchUtils.STR_IPV6_SRC).append("=").append(((OFOxmIpv6Src) ((OFActionSetField) a).getField()).getValue().toString());
} else if (((OFActionSetField)a).getField() instanceof OFOxmIpv6Dst) { } else if (((OFActionSetField)a).getField() instanceof OFOxmIpv6Dst) {
jsonGenerator.writeStringField(MatchUtils.STR_IPV6_DST, ((OFOxmIpv6Dst) ((OFActionSetField) a).getField()).getValue().toString()); sb.append(MatchUtils.STR_IPV6_DST).append("=").append(((OFOxmIpv6Dst) ((OFActionSetField) a).getField()).getValue().toString());
} else if (((OFActionSetField)a).getField() instanceof OFOxmIpv6Flabel) { } else if (((OFActionSetField)a).getField() instanceof OFOxmIpv6Flabel) {
jsonGenerator.writeStringField(MatchUtils.STR_IPV6_FLOW_LABEL, ((OFOxmIpv6Flabel) ((OFActionSetField) a).getField()).getValue().toString()); sb.append(MatchUtils.STR_IPV6_FLOW_LABEL).append("=").append(((OFOxmIpv6Flabel) ((OFActionSetField) a).getField()).getValue().toString());
} else if (((OFActionSetField)a).getField() instanceof OFOxmIpEcn) { } else if (((OFActionSetField)a).getField() instanceof OFOxmIpEcn) {
jsonGenerator.writeNumberField(MatchUtils.STR_NW_ECN, ((OFOxmIpEcn) ((OFActionSetField) a).getField()).getValue().getEcnValue()); sb.append(MatchUtils.STR_NW_ECN).append("=").append(((OFOxmIpEcn) ((OFActionSetField) a).getField()).getValue().getEcnValue());
} else if (((OFActionSetField)a).getField() instanceof OFOxmIpDscp) { } else if (((OFActionSetField)a).getField() instanceof OFOxmIpDscp) {
jsonGenerator.writeNumberField(MatchUtils.STR_NW_DSCP, ((OFOxmIpDscp) ((OFActionSetField) a).getField()).getValue().getDscpValue()); sb.append(MatchUtils.STR_NW_DSCP).append("=").append(((OFOxmIpDscp) ((OFActionSetField) a).getField()).getValue().getDscpValue());
} }
/* TRANSPORT LAYER, TCP, UDP, and SCTP */ /* TRANSPORT LAYER, TCP, UDP, and SCTP */
else if (((OFActionSetField)a).getField() instanceof OFOxmTcpSrc) { else if (((OFActionSetField)a).getField() instanceof OFOxmTcpSrc) {
jsonGenerator.writeNumberField(MatchUtils.STR_TCP_SRC, ((OFOxmTcpSrc) ((OFActionSetField) a).getField()).getValue().getPort()); sb.append(MatchUtils.STR_TCP_SRC).append("=").append(((OFOxmTcpSrc) ((OFActionSetField) a).getField()).getValue().getPort());
} else if (((OFActionSetField)a).getField() instanceof OFOxmTcpDst) { } else if (((OFActionSetField)a).getField() instanceof OFOxmTcpDst) {
jsonGenerator.writeNumberField(MatchUtils.STR_TCP_DST, ((OFOxmTcpDst) ((OFActionSetField) a).getField()).getValue().getPort()); sb.append(MatchUtils.STR_TCP_DST).append("=").append(((OFOxmTcpDst) ((OFActionSetField) a).getField()).getValue().getPort());
} else if (((OFActionSetField)a).getField() instanceof OFOxmUdpSrc) { } else if (((OFActionSetField)a).getField() instanceof OFOxmUdpSrc) {
jsonGenerator.writeNumberField(MatchUtils.STR_UDP_SRC, ((OFOxmUdpSrc) ((OFActionSetField) a).getField()).getValue().getPort()); sb.append(MatchUtils.STR_UDP_SRC).append("=").append(((OFOxmUdpSrc) ((OFActionSetField) a).getField()).getValue().getPort());
} else if (((OFActionSetField)a).getField() instanceof OFOxmUdpDst) { } else if (((OFActionSetField)a).getField() instanceof OFOxmUdpDst) {
jsonGenerator.writeNumberField(MatchUtils.STR_UDP_DST, ((OFOxmUdpDst) ((OFActionSetField) a).getField()).getValue().getPort()); sb.append(MatchUtils.STR_UDP_DST).append("=").append(((OFOxmUdpDst) ((OFActionSetField) a).getField()).getValue().getPort());
} else if (((OFActionSetField)a).getField() instanceof OFOxmSctpSrc) { } else if (((OFActionSetField)a).getField() instanceof OFOxmSctpSrc) {
jsonGenerator.writeNumberField(MatchUtils.STR_SCTP_SRC, ((OFOxmSctpSrc) ((OFActionSetField) a).getField()).getValue().getPort()); sb.append(MatchUtils.STR_SCTP_SRC).append("=").append(((OFOxmSctpSrc) ((OFActionSetField) a).getField()).getValue().getPort());
} else if (((OFActionSetField)a).getField() instanceof OFOxmSctpDst) { } else if (((OFActionSetField)a).getField() instanceof OFOxmSctpDst) {
jsonGenerator.writeNumberField(MatchUtils.STR_SCTP_DST, ((OFOxmSctpDst) ((OFActionSetField) a).getField()).getValue().getPort()); sb.append(MatchUtils.STR_SCTP_DST).append("=").append(((OFOxmSctpDst) ((OFActionSetField) a).getField()).getValue().getPort());
} }
/* MPLS */ /* MPLS */
else if (((OFActionSetField)a).getField() instanceof OFOxmMplsLabel) { else if (((OFActionSetField)a).getField() instanceof OFOxmMplsLabel) {
jsonGenerator.writeNumberField(MatchUtils.STR_MPLS_LABEL, ((OFOxmMplsLabel) ((OFActionSetField) a).getField()).getValue().getValue()); sb.append(MatchUtils.STR_MPLS_LABEL).append("=").append(((OFOxmMplsLabel) ((OFActionSetField) a).getField()).getValue().getValue());
} else if (((OFActionSetField)a).getField() instanceof OFOxmMplsTc) { } else if (((OFActionSetField)a).getField() instanceof OFOxmMplsTc) {
jsonGenerator.writeNumberField(MatchUtils.STR_MPLS_TC, ((OFOxmMplsTc) ((OFActionSetField) a).getField()).getValue().getValue()); sb.append(MatchUtils.STR_MPLS_TC).append("=").append(((OFOxmMplsTc) ((OFActionSetField) a).getField()).getValue().getValue());
} else if (((OFActionSetField)a).getField() instanceof OFOxmMplsBos) { } else if (((OFActionSetField)a).getField() instanceof OFOxmMplsBos) {
jsonGenerator.writeStringField(MatchUtils.STR_MPLS_TC, ((OFOxmMplsBos) ((OFActionSetField) a).getField()).getValue().toString()); sb.append(MatchUtils.STR_MPLS_TC).append("=").append(((OFOxmMplsBos) ((OFActionSetField) a).getField()).getValue().toString());
} }
/* METADATA */ /* METADATA */
else if (((OFActionSetField)a).getField() instanceof OFOxmMetadata) { else if (((OFActionSetField)a).getField() instanceof OFOxmMetadata) {
jsonGenerator.writeNumberField(MatchUtils.STR_METADATA, ((OFOxmMetadata) ((OFActionSetField) a).getField()).getValue().getValue().getValue()); sb.append(MatchUtils.STR_METADATA).append("=").append(((OFOxmMetadata) ((OFActionSetField) a).getField()).getValue().getValue().getValue());
} else { } else {
logger.error("Could not decode Set-Field action field: {}", ((OFActionSetField) a)); logger.error("Could not decode Set-Field action field: {}", ((OFActionSetField) a));
// need to get a logger in here somehow log.error("Could not decode Set-Field action field: {}", ((OFActionSetField) a));
} }
} // end switch over action type } // end switch over action type
pos++;
if (pos < len) {
sb.append(",");
}
} // end for over all actions } // end for over all actions
if (actions.isEmpty()) {
jsonGenerator.writeStringField("none", "drop");
} else {
jsonGenerator.writeStringField("actions", sb.toString());
}
} // end method } // end method
} }
...@@ -362,7 +362,14 @@ implements IOFSwitchListener, IFloodlightModule, IStaticFlowEntryPusherService, ...@@ -362,7 +362,14 @@ implements IOFSwitchListener, IFloodlightModule, IStaticFlowEntryPusherService,
} }
// get the correct builder for the OF version supported by the switch // get the correct builder for the OF version supported by the switch
fmb = OFFactories.getFactory(switchService.getSwitch(DatapathId.of(switchName)).getOFFactory().getVersion()).buildFlowModify(); try {
fmb = OFFactories.getFactory(switchService.getSwitch(DatapathId.of(switchName)).getOFFactory().getVersion()).buildFlowModify();
} catch (NullPointerException e) {
/* switch was not connected/known */
storageSourceService.deleteRowAsync(TABLE_NAME, entryName);
log.error("Deleting entry {}. Switch {} was not connected to the controller, and we need to know the OF protocol version to compose the flow mod.", entryName, switchName);
return;
}
StaticFlowEntries.initDefaultFlowMod(fmb, entryName); StaticFlowEntries.initDefaultFlowMod(fmb, entryName);
...@@ -587,16 +594,20 @@ implements IOFSwitchListener, IFloodlightModule, IStaticFlowEntryPusherService, ...@@ -587,16 +594,20 @@ implements IOFSwitchListener, IFloodlightModule, IStaticFlowEntryPusherService,
} }
// send flow_mod delete // send flow_mod delete
OFFlowDeleteStrict flowMod = FlowModUtils.toFlowDeleteStrict(entriesFromStorage.get(dpid).get(entryName)); if (switchService.getSwitch(DatapathId.of(dpid)) != null) {
OFFlowDeleteStrict flowMod = FlowModUtils.toFlowDeleteStrict(entriesFromStorage.get(dpid).get(entryName));
if (entriesFromStorage.containsKey(dpid) && entriesFromStorage.get(dpid).containsKey(entryName)) {
entriesFromStorage.get(dpid).remove(entryName);
} else {
log.debug("Tried to delete non-existent entry {} for switch {}", entryName, dpid);
return;
}
if (entriesFromStorage.containsKey(dpid) && entriesFromStorage.get(dpid).containsKey(entryName)) { writeFlowModToSwitch(DatapathId.of(dpid), flowMod);
entriesFromStorage.get(dpid).remove(entryName);
} else { } else {
log.debug("Tried to delete non-existent entry {} for switch {}", entryName, dpid); log.debug("Not sending flow delete for disconnected switch.");
return;
} }
writeFlowModToSwitch(DatapathId.of(dpid), flowMod);
return; return;
} }
...@@ -735,14 +746,14 @@ implements IOFSwitchListener, IFloodlightModule, IStaticFlowEntryPusherService, ...@@ -735,14 +746,14 @@ implements IOFSwitchListener, IFloodlightModule, IStaticFlowEntryPusherService,
msg.getMatch().equals(entry.getValue().getMatch()) && msg.getMatch().equals(entry.getValue().getMatch()) &&
msg.getPriority() == entry.getValue().getPriority() && msg.getPriority() == entry.getValue().getPriority() &&
msg.getTableId().equals(entry.getValue().getTableId()) msg.getTableId().equals(entry.getValue().getTableId())
) { ) {
flowToRemove = entry.getKey(); flowToRemove = entry.getKey();
break; break;
} }
} }
log.debug("Flow to Remove: {}", flowToRemove); log.debug("Flow to Remove: {}", flowToRemove);
/* /*
* Remove the flow. This will send the delete message to the switch, * Remove the flow. This will send the delete message to the switch,
* since we cannot tell the storage listener rowsdeleted() that we * since we cannot tell the storage listener rowsdeleted() that we
......
...@@ -115,7 +115,7 @@ public abstract class OFSwitchHandlerTestBase { ...@@ -115,7 +115,7 @@ public abstract class OFSwitchHandlerTestBase {
} }
} }
@Before
public void setUpFeaturesReply() { public void setUpFeaturesReply() {
getFeaturesReply(); getFeaturesReply();
this.featuresReply = getFeaturesReply(); this.featuresReply = getFeaturesReply();
...@@ -132,6 +132,12 @@ public abstract class OFSwitchHandlerTestBase { ...@@ -132,6 +132,12 @@ public abstract class OFSwitchHandlerTestBase {
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
/*
* This needs to be called explicitly to ensure the featuresReply is not null.
* Otherwise, there is no guarantee @Before will for setUpFeaturesReply() will
* call that function before our @Before setUp() here.
*/
setUpFeaturesReply();
switchManager = createMock(IOFSwitchManager.class); switchManager = createMock(IOFSwitchManager.class);
roleManager = createMock(RoleManager.class); roleManager = createMock(RoleManager.class);
sw = createMock(IOFSwitchBackend.class); sw = createMock(IOFSwitchBackend.class);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment