diff --git a/lib/openflowj-0.9.0-SNAPSHOT-javadoc.jar b/lib/openflowj-0.9.0-SNAPSHOT-javadoc.jar new file mode 100644 index 0000000000000000000000000000000000000000..9e685f2be1d758a4564fba5acf01bdbb4b237dac Binary files /dev/null and b/lib/openflowj-0.9.0-SNAPSHOT-javadoc.jar differ diff --git a/lib/openflowj-0.9.0-SNAPSHOT-sources.jar b/lib/openflowj-0.9.0-SNAPSHOT-sources.jar new file mode 100644 index 0000000000000000000000000000000000000000..bd732775843be73ff338598b296ecfb9510e40b1 Binary files /dev/null and b/lib/openflowj-0.9.0-SNAPSHOT-sources.jar differ diff --git a/lib/openflowj-0.9.0-SNAPSHOT.jar b/lib/openflowj-0.9.0-SNAPSHOT.jar new file mode 100644 index 0000000000000000000000000000000000000000..bef1d780013e3943927c357a4adb2173215e4753 Binary files /dev/null and b/lib/openflowj-0.9.0-SNAPSHOT.jar differ diff --git a/src/main/java/net/floodlightcontroller/core/OFConnectionCounters.java b/src/main/java/net/floodlightcontroller/core/OFConnectionCounters.java index b88d55c29f0847ac3ea15b02060eab6dc15152ee..aef32b24d9743be5bf8528d3c02714cfdf425eb4 100644 --- a/src/main/java/net/floodlightcontroller/core/OFConnectionCounters.java +++ b/src/main/java/net/floodlightcontroller/core/OFConnectionCounters.java @@ -37,8 +37,8 @@ public class OFConnectionCounters { private final IDebugCounter ctrWriteGetConfigReply; private final IDebugCounter ctrWriteSetConfig; private final IDebugCounter ctrWritePacketIn; - private final IDebugCounter ctrWritePacketOut; private final IDebugCounter ctrWriteFlowRemoved; + private final IDebugCounter ctrWritePacketOut; private final IDebugCounter ctrWritePortStatus; private final IDebugCounter ctrWriteFlowMod; private final IDebugCounter ctrWritePortMod; @@ -46,16 +46,21 @@ public class OFConnectionCounters { private final IDebugCounter ctrWriteStatsReply; private final IDebugCounter ctrWriteBarrierRequest; private final IDebugCounter ctrWriteBarrierReply; - private final IDebugCounter ctrWriteGetAsyncReply; - private final IDebugCounter ctrWriteGetAsyncRequest; - private final IDebugCounter ctrWriteGroupMod; - private final IDebugCounter ctrWriteMeterMod; - private final IDebugCounter ctrWriteQueueGetConfigReply; private final IDebugCounter ctrWriteQueueGetConfigRequest; + private final IDebugCounter ctrWriteQueueGetConfigReply; + private final IDebugCounter ctrWriteGroupMod; + private final IDebugCounter ctrWriteTableMod; private final IDebugCounter ctrWriteRoleRequest; private final IDebugCounter ctrWriteRoleReply; + private final IDebugCounter ctrWriteGetAsyncRequest; + private final IDebugCounter ctrWriteGetAsyncReply; private final IDebugCounter ctrWriteSetAsync; - private final IDebugCounter ctrWriteTableMod; + private final IDebugCounter ctrWriteMeterMod; + private final IDebugCounter ctrWriteRoleStatus; + private final IDebugCounter ctrWriteTableStatus; + private final IDebugCounter ctrWriteRequestForward; + private final IDebugCounter ctrWriteBundleControl; + private final IDebugCounter ctrWriteBundleAdd; // Read Counters // @@ -89,6 +94,11 @@ public class OFConnectionCounters { private final IDebugCounter ctrReadRoleReply; private final IDebugCounter ctrReadSetAsync; private final IDebugCounter ctrReadTableMod; + private final IDebugCounter ctrReadRoleStatus; + private final IDebugCounter ctrReadTableStatus; + private final IDebugCounter ctrReadBundleAdd; + private final IDebugCounter ctrReadBundleControl; + private final IDebugCounter ctrReadRequestForward; private static final Logger logger = LoggerFactory.getLogger(OFConnectionCounters.class); @@ -287,6 +297,36 @@ public class OFConnectionCounters { hierarchy, stringId, OFType.TABLE_MOD.toString()); + + ctrWriteBundleAdd = + registerCounterLocal(counters, + hierarchy, + stringId, + OFType.BUNDLE_ADD_MESSAGE.toString()); + + ctrWriteBundleControl = + registerCounterLocal(counters, + hierarchy, + stringId, + OFType.BUNDLE_CONTROL.toString()); + + ctrWriteRequestForward = + registerCounterLocal(counters, + hierarchy, + stringId, + OFType.REQUESTFORWARD.toString()); + + ctrWriteRoleStatus = + registerCounterLocal(counters, + hierarchy, + stringId, + OFType.ROLE_STATUS.toString()); + + ctrWriteTableStatus = + registerCounterLocal(counters, + hierarchy, + stringId, + OFType.TABLE_STATUS.toString()); // Register Read Counters // @@ -446,6 +486,36 @@ public class OFConnectionCounters { hierarchy, stringId, OFType.TABLE_MOD.toString()); + + ctrReadBundleAdd = + registerCounterLocal(counters, + hierarchy, + stringId, + OFType.BUNDLE_ADD_MESSAGE.toString()); + + ctrReadBundleControl = + registerCounterLocal(counters, + hierarchy, + stringId, + OFType.BUNDLE_CONTROL.toString()); + + ctrReadRequestForward = + registerCounterLocal(counters, + hierarchy, + stringId, + OFType.REQUESTFORWARD.toString()); + + ctrReadRoleStatus = + registerCounterLocal(counters, + hierarchy, + stringId, + OFType.ROLE_STATUS.toString()); + + ctrReadTableStatus = + registerCounterLocal(counters, + hierarchy, + stringId, + OFType.TABLE_STATUS.toString()); } /** @@ -583,7 +653,27 @@ public class OFConnectionCounters { case TABLE_MOD: ctrWriteTableMod.increment(); break; - + + case BUNDLE_ADD_MESSAGE: + ctrWriteBundleAdd.increment(); + break; + + case BUNDLE_CONTROL: + ctrWriteBundleControl.increment(); + break; + + case REQUESTFORWARD: + ctrWriteRequestForward.increment(); + break; + + case ROLE_STATUS: + ctrWriteRoleStatus.increment(); + break; + + case TABLE_STATUS: + ctrWriteTableStatus.increment(); + break; + default: logger.warn(ofm.getType().toString() + ": Invalid OpenFlow Messaqe!"); @@ -716,6 +806,26 @@ public class OFConnectionCounters { case TABLE_MOD: ctrReadTableMod.increment(); break; + + case BUNDLE_ADD_MESSAGE: + ctrReadBundleAdd.increment(); + break; + + case BUNDLE_CONTROL: + ctrReadBundleControl.increment(); + break; + + case REQUESTFORWARD: + ctrReadRequestForward.increment(); + break; + + case ROLE_STATUS: + ctrReadRoleStatus.increment(); + break; + + case TABLE_STATUS: + ctrReadTableStatus.increment(); + break; default: logger.warn(ofm.getType().toString() + diff --git a/src/main/java/net/floodlightcontroller/core/web/SwitchResourceBase.java b/src/main/java/net/floodlightcontroller/core/web/SwitchResourceBase.java index 1609818f4bc836e3b8cfb0e9a0e9d968105af368..1a235085d4b3b58f7840bbe2abbdc0dba49858cb 100644 --- a/src/main/java/net/floodlightcontroller/core/web/SwitchResourceBase.java +++ b/src/main/java/net/floodlightcontroller/core/web/SwitchResourceBase.java @@ -119,6 +119,9 @@ public class SwitchResourceBase extends ServerResource { req = sw.getOFFactory().buildDescStatsRequest() .build(); break; + case PORT_DESC: + req = sw.getOFFactory().buildPortDescStatsRequest() + .build(); case EXPERIMENTER: //TODO @Ryan support new OF1.1+ stats types case GROUP: case GROUP_DESC: @@ -126,9 +129,6 @@ public class SwitchResourceBase extends ServerResource { case METER: case METER_CONFIG: case METER_FEATURES: - case PORT_DESC: - req = sw.getOFFactory().buildPortDescStatsRequest() - .build(); case TABLE_FEATURES: default: log.error("Stats Request Type {} not implemented yet", statType.name()); diff --git a/src/main/java/net/floodlightcontroller/core/web/serializers/StatsReplySerializer.java b/src/main/java/net/floodlightcontroller/core/web/serializers/StatsReplySerializer.java index 0f0eb71a0421ba3d23f956899908f603004bddd4..e001f62f8bec506d89ebb9bea34e8e8081219e36 100644 --- a/src/main/java/net/floodlightcontroller/core/web/serializers/StatsReplySerializer.java +++ b/src/main/java/net/floodlightcontroller/core/web/serializers/StatsReplySerializer.java @@ -40,30 +40,33 @@ import org.projectfloodlight.openflow.protocol.OFPortStatsReply; import org.projectfloodlight.openflow.protocol.OFPortStatsEntry; import org.projectfloodlight.openflow.protocol.OFPortDescStatsReply; import org.projectfloodlight.openflow.protocol.OFPortDesc; - -//Use the loxigen's serializer +import org.projectfloodlight.openflow.protocol.ver13.OFFlowModFlagsSerializerVer13; +// Use Loxigen's serializer import org.projectfloodlight.openflow.protocol.ver13.OFPortFeaturesSerializerVer13; +import org.projectfloodlight.openflow.protocol.ver12.OFFlowModFlagsSerializerVer12; import org.projectfloodlight.openflow.protocol.ver12.OFPortFeaturesSerializerVer12; +import org.projectfloodlight.openflow.protocol.ver11.OFFlowModFlagsSerializerVer11; import org.projectfloodlight.openflow.protocol.ver11.OFPortFeaturesSerializerVer11; +import org.projectfloodlight.openflow.protocol.ver10.OFFlowModFlagsSerializerVer10; import org.projectfloodlight.openflow.protocol.ver10.OFPortFeaturesSerializerVer10; import org.projectfloodlight.openflow.protocol.ver13.OFPortStateSerializerVer13; import org.projectfloodlight.openflow.protocol.ver12.OFPortStateSerializerVer12; import org.projectfloodlight.openflow.protocol.ver11.OFPortStateSerializerVer11; import org.projectfloodlight.openflow.protocol.ver10.OFPortStateSerializerVer10; import org.projectfloodlight.openflow.protocol.ver13.OFPortConfigSerializerVer13; +import org.projectfloodlight.openflow.protocol.ver14.OFFlowModFlagsSerializerVer14; import org.projectfloodlight.openflow.protocol.ver12.OFPortConfigSerializerVer12; import org.projectfloodlight.openflow.protocol.ver11.OFPortConfigSerializerVer11; import org.projectfloodlight.openflow.protocol.ver10.OFPortConfigSerializerVer10; - import org.projectfloodlight.openflow.protocol.OFAggregateStatsReply; import org.projectfloodlight.openflow.protocol.OFVersion; import org.projectfloodlight.openflow.protocol.match.*; import org.projectfloodlight.openflow.protocol.oxm.*; import org.projectfloodlight.openflow.protocol.instruction.*; import org.projectfloodlight.openflow.protocol.action.*; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; + /** * Serialize a DPID as colon-separated hexadecimal */ @@ -200,7 +203,27 @@ public class StatsReplySerializer extends JsonSerializer<StatsReply> { jGen.writeNumberField("priority", entry.getPriority()); jGen.writeNumberField("idleTimeoutSec", entry.getIdleTimeout()); jGen.writeNumberField("hardTimeoutSec", entry.getHardTimeout()); - jGen.writeNumberField("flags", entry.getFlags()); + switch (entry.getVersion()) { + case OF_10: + jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer10.toWireValue(entry.getFlags())); + break; + case OF_11: + jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer11.toWireValue(entry.getFlags())); + break; + case OF_12: + jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer12.toWireValue(entry.getFlags())); + break; + case OF_13: + jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer13.toWireValue(entry.getFlags())); + break; + case OF_14: + jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer14.toWireValue(entry.getFlags())); + break; + default: + logger.error("Could not decode OFVersion {}", entry.getVersion()); + break; + } + // list flow matches jGen.writeObjectFieldStart("match"); Iterator<MatchField<?>> mi = entry.getMatch().getMatchFields().iterator(); // get iter to any match field type @@ -622,6 +645,9 @@ public class StatsReplySerializer extends JsonSerializer<StatsReply> { jGen.writeNumberField("supportedFeatures", OFPortFeaturesSerializerVer13.toWireValue(entry.getSupported())); jGen.writeNumberField("peerFeatures", OFPortFeaturesSerializerVer13.toWireValue(entry.getPeer())); break; + case OF_14: + // TODO + logger.error("OF1.4 OFPortDesc serializer not implemented"); } if (OFVersion.OF_10 != entry.getVersion()) { jGen.writeNumberField("currSpeed",entry.getCurrSpeed()); diff --git a/src/main/java/net/floodlightcontroller/firewall/Firewall.java b/src/main/java/net/floodlightcontroller/firewall/Firewall.java index ff752cd3eabf044ff3c7cc5bbac3bab027d3f045..0b2a849b2d4f936d9d3a49bf6f3e8cbdcb6265e2 100644 --- a/src/main/java/net/floodlightcontroller/firewall/Firewall.java +++ b/src/main/java/net/floodlightcontroller/firewall/Firewall.java @@ -208,13 +208,13 @@ public class Firewall implements IFirewallService, IOFMessageListener, } else if (key.equals(COLUMN_DL_TYPE)) { r.dl_type = EthType.of(Integer.parseInt((String) row.get(COLUMN_DL_TYPE))); } else if (key.equals(COLUMN_NW_SRC_PREFIX)) { - r.nw_src_prefix_and_mask = IPv4AddressWithMask.of(Integer.parseInt((String) row.get(COLUMN_NW_SRC_PREFIX)), r.nw_src_prefix_and_mask.getMask().getInt()); + r.nw_src_prefix_and_mask = IPv4AddressWithMask.of(IPv4Address.of(Integer.parseInt((String) row.get(COLUMN_NW_SRC_PREFIX))), r.nw_src_prefix_and_mask.getMask()); } else if (key.equals(COLUMN_NW_SRC_MASKBITS)) { - r.nw_src_prefix_and_mask = IPv4AddressWithMask.of(r.nw_src_prefix_and_mask.getValue().getInt(), Integer.parseInt((String) row.get(COLUMN_NW_SRC_MASKBITS))); + r.nw_src_prefix_and_mask = IPv4AddressWithMask.of(r.nw_src_prefix_and_mask.getValue(), IPv4Address.of(Integer.parseInt((String) row.get(COLUMN_NW_SRC_MASKBITS)))); } else if (key.equals(COLUMN_NW_DST_PREFIX)) { - r.nw_dst_prefix_and_mask = IPv4AddressWithMask.of(Integer.parseInt((String) row.get(COLUMN_NW_DST_PREFIX)), r.nw_dst_prefix_and_mask.getMask().getInt()); + r.nw_dst_prefix_and_mask = IPv4AddressWithMask.of(IPv4Address.of(Integer.parseInt((String) row.get(COLUMN_NW_DST_PREFIX))), r.nw_dst_prefix_and_mask.getMask()); } else if (key.equals(COLUMN_NW_DST_MASKBITS)) { - r.nw_dst_prefix_and_mask = IPv4AddressWithMask.of(r.nw_dst_prefix_and_mask.getValue().getInt(), Integer.parseInt((String) row.get(COLUMN_NW_DST_MASKBITS))); + r.nw_dst_prefix_and_mask = IPv4AddressWithMask.of(r.nw_dst_prefix_and_mask.getValue(), IPv4Address.of(Integer.parseInt((String) row.get(COLUMN_NW_DST_MASKBITS)))); } else if (key.equals(COLUMN_NW_PROTO)) { r.nw_proto = IpProtocol.of(Short.parseShort((String) row.get(COLUMN_NW_PROTO))); } else if (key.equals(COLUMN_TP_SRC)) { diff --git a/src/test/java/net/floodlightcontroller/debugcounter/OFConnectionCountersTest.java b/src/test/java/net/floodlightcontroller/debugcounter/OFConnectionCountersTest.java index 64a2c3431af8a52659a8363f627dde1b765c0a3a..c82eb132c050eef6b9acedc0cde5936dd2545154 100644 --- a/src/test/java/net/floodlightcontroller/debugcounter/OFConnectionCountersTest.java +++ b/src/test/java/net/floodlightcontroller/debugcounter/OFConnectionCountersTest.java @@ -2,16 +2,24 @@ package net.floodlightcontroller.debugcounter; import static org.junit.Assert.assertEquals; +import java.util.ArrayList; + import org.junit.Before; import org.junit.Test; + import net.floodlightcontroller.core.OFConnectionCounters; + import org.projectfloodlight.openflow.protocol.OFAsyncGetReply; import org.projectfloodlight.openflow.protocol.OFAsyncGetRequest; import org.projectfloodlight.openflow.protocol.OFAsyncSet; import org.projectfloodlight.openflow.protocol.OFBadRequestCode; import org.projectfloodlight.openflow.protocol.OFBarrierReply; import org.projectfloodlight.openflow.protocol.OFBarrierRequest; +import org.projectfloodlight.openflow.protocol.OFBundleAddMsg; +import org.projectfloodlight.openflow.protocol.OFBundleCtrlMsg; +import org.projectfloodlight.openflow.protocol.OFBundleCtrlType; import org.projectfloodlight.openflow.protocol.OFControllerRole; +import org.projectfloodlight.openflow.protocol.OFControllerRoleReason; import org.projectfloodlight.openflow.protocol.OFEchoReply; import org.projectfloodlight.openflow.protocol.OFEchoRequest; import org.projectfloodlight.openflow.protocol.OFErrorMsg; @@ -27,6 +35,7 @@ import org.projectfloodlight.openflow.protocol.OFGetConfigRequest; import org.projectfloodlight.openflow.protocol.OFGroupMod; import org.projectfloodlight.openflow.protocol.OFGroupType; import org.projectfloodlight.openflow.protocol.OFHello; +import org.projectfloodlight.openflow.protocol.OFHelloElem; import org.projectfloodlight.openflow.protocol.OFMessage; import org.projectfloodlight.openflow.protocol.OFMeterMod; import org.projectfloodlight.openflow.protocol.OFPacketIn; @@ -38,19 +47,27 @@ import org.projectfloodlight.openflow.protocol.OFPortReason; import org.projectfloodlight.openflow.protocol.OFPortStatus; import org.projectfloodlight.openflow.protocol.OFQueueGetConfigReply; import org.projectfloodlight.openflow.protocol.OFQueueGetConfigRequest; +import org.projectfloodlight.openflow.protocol.OFRequestforward; import org.projectfloodlight.openflow.protocol.OFRoleReply; import org.projectfloodlight.openflow.protocol.OFRoleRequest; +import org.projectfloodlight.openflow.protocol.OFRoleStatus; import org.projectfloodlight.openflow.protocol.OFSetConfig; import org.projectfloodlight.openflow.protocol.OFStatsReply; import org.projectfloodlight.openflow.protocol.OFStatsRequest; import org.projectfloodlight.openflow.protocol.OFTableMod; +import org.projectfloodlight.openflow.protocol.OFTableReason; +import org.projectfloodlight.openflow.protocol.OFTableStatus; import org.projectfloodlight.openflow.protocol.OFType; import org.projectfloodlight.openflow.protocol.OFVersion; +import org.projectfloodlight.openflow.types.BundleId; import org.projectfloodlight.openflow.types.DatapathId; import org.projectfloodlight.openflow.types.OFAuxId; import org.projectfloodlight.openflow.types.OFGroup; import org.projectfloodlight.openflow.types.OFPort; +import org.projectfloodlight.openflow.types.TableId; + import net.floodlightcontroller.test.FloodlightTestCase; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -132,13 +149,13 @@ public class OFConnectionCountersTest extends FloodlightTestCase { //Echo Reply // - OFEchoReply echorepMsg = factory.echoReply(null); + OFEchoReply echorepMsg = factory.echoReply(new byte[1]); updateAndTestCounter(echorepMsg,OFType.ECHO_REPLY.toString()); // Echo Request // - OFEchoRequest echoreqMsg = factory.echoRequest(null); + OFEchoRequest echoreqMsg = factory.echoRequest(new byte[1]); updateAndTestCounter(echoreqMsg,OFType.ECHO_REQUEST.toString()); // Error @@ -209,7 +226,7 @@ public class OFConnectionCountersTest extends FloodlightTestCase { // Hello // - OFHello helloMsg = factory.hello(null); + OFHello helloMsg = factory.hello(new ArrayList<OFHelloElem>()); updateAndTestCounter(helloMsg,OFType.HELLO.toString()); // meter mod @@ -248,7 +265,7 @@ public class OFConnectionCountersTest extends FloodlightTestCase { // Queue get config request // - OFQueueGetConfigRequest queueConfReq = factory.queueGetConfigRequest(null); + OFQueueGetConfigRequest queueConfReq = factory.queueGetConfigRequest(OFPort.ZERO); updateAndTestCounter(queueConfReq,OFType.QUEUE_GET_CONFIG_REQUEST.toString()); // Role Reply @@ -285,6 +302,44 @@ public class OFConnectionCountersTest extends FloodlightTestCase { // OFTableMod tableMod = factory.buildTableMod().build(); updateAndTestCounter(tableMod,OFType.TABLE_MOD.toString()); + + factory = OFFactories.getFactory(OFVersion.OF_14); + + // Request Forward + // + OFRequestforward requestForward = factory.buildRequestforward().build(); + updateAndTestCounter(requestForward,OFType.REQUESTFORWARD.toString()); + + // Bundle Add + // + OFBundleAddMsg bundleAdd = factory.buildBundleAddMsg() + .setBundleId(BundleId.NONE) + .setData(factory.buildPacketIn().setReason(OFPacketInReason.NO_MATCH).build()) + .build(); + updateAndTestCounter(bundleAdd,OFType.BUNDLE_ADD_MESSAGE.toString()); + + // Bundle Control + // + OFBundleCtrlMsg bundleControl = factory.buildBundleCtrlMsg() + .setBundleId(BundleId.NONE) + .setBundleCtrlType(OFBundleCtrlType.OPEN_REQUEST) + .build(); + updateAndTestCounter(bundleControl,OFType.BUNDLE_CONTROL.toString()); + + // Role Status + // + OFRoleStatus roleStatus = factory.buildRoleStatus() + .setReason(OFControllerRoleReason.CONFIG) + .build(); + updateAndTestCounter(roleStatus,OFType.ROLE_STATUS.toString()); + + // Table Status + // + OFTableStatus tableStatus = factory.buildTableStatus() + .setReason(OFTableReason.VACANCY_DOWN) + .setTable(factory.buildTableDesc().setTableId(TableId.ZERO).build()) + .build(); + updateAndTestCounter(tableStatus,OFType.TABLE_STATUS.toString()); } }