Removed the old openflowj protocol library
Change-Id: I4fcd0399c6eb0d9089116e365b55505042ded1fc
diff --git a/conf/checkstyle/onos_suppressions.xml b/conf/checkstyle/onos_suppressions.xml
index 7f7d569..3375113 100644
--- a/conf/checkstyle/onos_suppressions.xml
+++ b/conf/checkstyle/onos_suppressions.xml
@@ -13,7 +13,6 @@
<!-- Suppressions for ONOS -->
<suppress files="edu.stanford.ramcloud.*" checks="[_a-zA-Z0-9]*"/>
<suppress files="net.floodlightcontroller.*" checks="[_a-zA-Z0-9]*"/>
- <suppress files="org.openflow.*" checks="[_a-zA-Z0-9]*"/>
<suppress files="net.onrc.onos.core.datastore.serializers.*" checks="[_a-zA-Z0-9]*"/>
<!-- BigSwitch packet code is designed to use parameter names that override
diff --git a/conf/findbugs/exclude.xml b/conf/findbugs/exclude.xml
index 4c536ad..b6035a3 100644
--- a/conf/findbugs/exclude.xml
+++ b/conf/findbugs/exclude.xml
@@ -15,7 +15,4 @@
<Match>
<Class name="~.*net\.floodlightcontroller\..*"/>
</Match>
- <Match>
- <Class name="~.*org\.openflow\..*"/>
- </Match>
</FindBugsFilter>
diff --git a/pom.xml b/pom.xml
index 036ad4a..83fad6b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -167,7 +167,7 @@
<charset>UTF-8</charset>
<locale>en</locale>
<author>false</author>
- <excludePackageNames>net.floodlightcontroller.*:org.openflow.*:net.onrc.onos.core.datastore.serializers</excludePackageNames>
+ <excludePackageNames>net.floodlightcontroller.*:net.onrc.onos.core.datastore.serializers</excludePackageNames>
</configuration>
</plugin>
<!-- Remove me when we're sure that system test no longer need JaCoCo
@@ -272,7 +272,6 @@
</ignores>
<excludes>
<exclude>edu/stanford/ramcloud/**/*.class</exclude>
- <exclude>org/openflow/**/*.class</exclude>
<exclude>net/floodlightcontroller/**/web/**/*.class</exclude>
</excludes>
</instrumentation>
@@ -321,7 +320,6 @@
<exclude>**/datastore/serializers/**</exclude>
<exclude>**/edu/stanford/**</exclude>
<exclude>**/net/floodlightcontroller/**</exclude>
- <exclude>**/org/openflow/**</exclude>
</excludes>
<rulesets>
<ruleset>${basedir}/conf/pmd/onos_ruleset.xml</ruleset>
@@ -477,7 +475,6 @@
<exclude>**/datastore/serializers/**</exclude>
<exclude>**/edu/stanford/**</exclude>
<exclude>**/net/floodlightcontroller/**</exclude>
- <exclude>**/org/openflow/**</exclude>
</excludes>
<rulesets>
<ruleset>${basedir}/conf/pmd/onos_ruleset.xml</ruleset>
diff --git a/src/main/java/net/floodlightcontroller/core/web/AllSwitchStatisticsResource.java b/src/main/java/net/floodlightcontroller/core/web/AllSwitchStatisticsResource.java
index 276215b..b312ca0 100644
--- a/src/main/java/net/floodlightcontroller/core/web/AllSwitchStatisticsResource.java
+++ b/src/main/java/net/floodlightcontroller/core/web/AllSwitchStatisticsResource.java
@@ -17,21 +17,6 @@
package net.floodlightcontroller.core.web;
-import java.lang.Thread.State;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import net.floodlightcontroller.core.IFloodlightProviderService;
-
-import org.openflow.protocol.OFFeaturesReply;
-import org.openflow.protocol.statistics.OFStatistics;
-import org.openflow.protocol.statistics.OFStatisticsType;
-import org.openflow.util.HexString;
-import org.restlet.resource.Get;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* Return switch statistics information for all switches
@@ -39,7 +24,7 @@
* @author readams
*/
public class AllSwitchStatisticsResource extends SwitchResourceBase {
- protected final static Logger log =
+ /*protected final static Logger log =
LoggerFactory.getLogger(AllSwitchStatisticsResource.class);
@Get("json")
@@ -93,7 +78,7 @@
// Join all the threads after the timeout. Set a hard timeout
// of 12 seconds for the threads to finish. If the thread has not
- // finished the switch has not replied yet and therefore we won't
+ // finished the switch has not replied yet and therefore we won't
// add the switch's stats to the reply.
for (int iSleepCycles = 0; iSleepCycles < 12; iSleepCycles++) {
for (GetConcurrentStatsThread curThread : activeThreads) {
@@ -164,5 +149,5 @@
featuresReply = getSwitchFeaturesReply(switchId);
}
}
- }
+ }*/
}
diff --git a/src/main/java/net/floodlightcontroller/core/web/ControllerSwitchesResource.java b/src/main/java/net/floodlightcontroller/core/web/ControllerSwitchesResource.java
index 223da56..1e115ac 100644
--- a/src/main/java/net/floodlightcontroller/core/web/ControllerSwitchesResource.java
+++ b/src/main/java/net/floodlightcontroller/core/web/ControllerSwitchesResource.java
@@ -24,7 +24,7 @@
import net.floodlightcontroller.core.IOFSwitch;
import net.floodlightcontroller.util.FilterIterator;
-import org.openflow.util.HexString;
+import org.projectfloodlight.openflow.util.HexString;
import org.restlet.data.Form;
import org.restlet.data.Status;
import org.restlet.resource.Get;
diff --git a/src/main/java/net/floodlightcontroller/core/web/SwitchResourceBase.java b/src/main/java/net/floodlightcontroller/core/web/SwitchResourceBase.java
index d5b534d..176e357 100644
--- a/src/main/java/net/floodlightcontroller/core/web/SwitchResourceBase.java
+++ b/src/main/java/net/floodlightcontroller/core/web/SwitchResourceBase.java
@@ -17,30 +17,7 @@
package net.floodlightcontroller.core.web;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-
-import net.floodlightcontroller.core.IFloodlightProviderService;
-import net.floodlightcontroller.core.IOFSwitch;
-import net.floodlightcontroller.core.annotations.LogMessageDoc;
-
-import org.openflow.protocol.OFFeaturesReply;
-import org.openflow.protocol.OFMatch;
-import org.openflow.protocol.OFPort;
-import org.openflow.protocol.OFStatisticsRequest;
-import org.openflow.protocol.statistics.OFAggregateStatisticsRequest;
-import org.openflow.protocol.statistics.OFFlowStatisticsRequest;
-import org.openflow.protocol.statistics.OFPortStatisticsRequest;
-import org.openflow.protocol.statistics.OFQueueStatisticsRequest;
-import org.openflow.protocol.statistics.OFStatistics;
-import org.openflow.protocol.statistics.OFStatisticsType;
-import org.openflow.util.HexString;
-import org.restlet.resource.ResourceException;
import org.restlet.resource.ServerResource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* Base class for server resources related to switches
@@ -49,7 +26,7 @@
*/
public class SwitchResourceBase extends ServerResource {
- protected final static Logger log = LoggerFactory.getLogger(SwitchResourceBase.class);
+ /*protected final static Logger log = LoggerFactory.getLogger(SwitchResourceBase.class);
public enum REQUESTTYPE {
OFSTATS,
@@ -118,12 +95,12 @@
}
req.setLengthU(requestLength);
// XXX S fix when we fix stats
- /*try {
+ try {
future = sw.getStatistics(req);
values = future.get(10, TimeUnit.SECONDS);
} catch (Exception e) {
log.error("Failure retrieving statistics from switch " + sw, e);
- }*/
+ }
}
return values;
}
@@ -141,13 +118,13 @@
Future<OFFeaturesReply> future;
OFFeaturesReply featuresReply = null;
if (sw != null) {
- // XXX S fix when we fix stats
- /*try {
+ // XXX S fix when we fix stats
+ try {
future = sw.getFeaturesReplyFromSwitch();
featuresReply = future.get(10, TimeUnit.SECONDS);
} catch (Exception e) {
log.error("Failure getting features reply from switch" + sw, e);
- }*/
+ }
}
return featuresReply;
@@ -155,6 +132,6 @@
protected OFFeaturesReply getSwitchFeaturesReply(String switchId) {
return getSwitchFeaturesReply(HexString.toLong(switchId));
- }
+ }*/
}
diff --git a/src/main/java/net/floodlightcontroller/core/web/SwitchRoleResource.java b/src/main/java/net/floodlightcontroller/core/web/SwitchRoleResource.java
index d598005..f85b75e 100644
--- a/src/main/java/net/floodlightcontroller/core/web/SwitchRoleResource.java
+++ b/src/main/java/net/floodlightcontroller/core/web/SwitchRoleResource.java
@@ -5,7 +5,7 @@
import net.floodlightcontroller.core.IFloodlightProviderService;
import net.floodlightcontroller.core.IOFSwitch;
-import org.openflow.util.HexString;
+import org.projectfloodlight.openflow.util.HexString;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
import org.slf4j.Logger;
diff --git a/src/main/java/net/floodlightcontroller/core/web/SwitchStatisticsResource.java b/src/main/java/net/floodlightcontroller/core/web/SwitchStatisticsResource.java
index 468a50e..cb8860e 100644
--- a/src/main/java/net/floodlightcontroller/core/web/SwitchStatisticsResource.java
+++ b/src/main/java/net/floodlightcontroller/core/web/SwitchStatisticsResource.java
@@ -17,13 +17,6 @@
package net.floodlightcontroller.core.web;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.openflow.protocol.statistics.OFStatisticsType;
-import org.restlet.resource.Get;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* Return switch statistics information for specific switches
@@ -31,7 +24,7 @@
* @author readams
*/
public class SwitchStatisticsResource extends SwitchResourceBase {
- protected final static Logger log =
+ /*protected final static Logger log =
LoggerFactory.getLogger(SwitchStatisticsResource.class);
@Get("json")
@@ -60,5 +53,5 @@
result.put(switchId, values);
return result;
- }
+ }*/
}
diff --git a/src/main/java/net/floodlightcontroller/core/web/serializers/ByteArrayMACSerializer.java b/src/main/java/net/floodlightcontroller/core/web/serializers/ByteArrayMACSerializer.java
index 35f810b..674e1e0 100644
--- a/src/main/java/net/floodlightcontroller/core/web/serializers/ByteArrayMACSerializer.java
+++ b/src/main/java/net/floodlightcontroller/core/web/serializers/ByteArrayMACSerializer.java
@@ -23,7 +23,7 @@
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.JsonSerializer;
import org.codehaus.jackson.map.SerializerProvider;
-import org.openflow.util.HexString;
+import org.projectfloodlight.openflow.util.HexString;
/**
* Serialize a MAC as colon-separated hexadecimal
diff --git a/src/main/java/net/floodlightcontroller/core/web/serializers/DPIDSerializer.java b/src/main/java/net/floodlightcontroller/core/web/serializers/DPIDSerializer.java
index 304e835..a85a10d 100644
--- a/src/main/java/net/floodlightcontroller/core/web/serializers/DPIDSerializer.java
+++ b/src/main/java/net/floodlightcontroller/core/web/serializers/DPIDSerializer.java
@@ -23,7 +23,7 @@
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.JsonSerializer;
import org.codehaus.jackson.map.SerializerProvider;
-import org.openflow.util.HexString;
+import org.projectfloodlight.openflow.util.HexString;
/**
* Serialize a DPID as colon-separated hexadecimal
diff --git a/src/main/java/net/floodlightcontroller/core/web/serializers/MACSerializer.java b/src/main/java/net/floodlightcontroller/core/web/serializers/MACSerializer.java
index eacf515..8f86a4b 100644
--- a/src/main/java/net/floodlightcontroller/core/web/serializers/MACSerializer.java
+++ b/src/main/java/net/floodlightcontroller/core/web/serializers/MACSerializer.java
@@ -23,7 +23,7 @@
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.JsonSerializer;
import org.codehaus.jackson.map.SerializerProvider;
-import org.openflow.util.HexString;
+import org.projectfloodlight.openflow.util.HexString;
/**
* Serialize a MAC as colon-separated hexadecimal
diff --git a/src/main/java/net/floodlightcontroller/debugevent/Event.java b/src/main/java/net/floodlightcontroller/debugevent/Event.java
index b3e284e..229902f 100644
--- a/src/main/java/net/floodlightcontroller/debugevent/Event.java
+++ b/src/main/java/net/floodlightcontroller/debugevent/Event.java
@@ -6,13 +6,14 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import net.floodlightcontroller.debugevent.IDebugEventService.EventColumn;
import net.onrc.onos.core.packet.IPv4;
import net.onrc.onos.core.util.SwitchPort;
-import org.openflow.protocol.OFFlowMod;
-import org.openflow.util.HexString;
+import org.projectfloodlight.openflow.protocol.OFFlowModFlags;
+import org.projectfloodlight.openflow.util.HexString;
public class Event {
long timestamp;
@@ -117,19 +118,20 @@
retMap.put(ec.name(), net.onrc.onos.core.packet.IPv4.fromIPv4Address((Integer) obj));
break;
case FLOW_MOD_FLAGS:
- int flags = (Integer)obj;
+ @SuppressWarnings("unchecked")
+ Set<OFFlowModFlags> flags = (Set<OFFlowModFlags>) obj;
StringBuilder builder = new StringBuilder();
- if (flags == 0) {
+ if (flags.isEmpty()) {
builder.append("None");
}
else {
- if ((flags & OFFlowMod.OFPFF_SEND_FLOW_REM) != 0) {
+ if (flags.contains(OFFlowModFlags.SEND_FLOW_REM)) {
builder.append("SEND_FLOW_REM ");
}
- if ((flags & OFFlowMod.OFPFF_CHECK_OVERLAP) != 0) {
+ if (flags.contains(OFFlowModFlags.CHECK_OVERLAP)) {
builder.append("CHECK_OVERLAP ");
}
- if ((flags & OFFlowMod.OFPFF_EMERG) != 0) {
+ if (flags.contains(OFFlowModFlags.EMERG)) {
builder.append("EMERG ");
}
}
diff --git a/src/main/java/net/floodlightcontroller/util/MACAddress.java b/src/main/java/net/floodlightcontroller/util/MACAddress.java
index f3ac52b..7f0e9f5 100644
--- a/src/main/java/net/floodlightcontroller/util/MACAddress.java
+++ b/src/main/java/net/floodlightcontroller/util/MACAddress.java
@@ -8,7 +8,7 @@
import org.codehaus.jackson.map.annotate.JsonDeserialize;
import org.codehaus.jackson.map.annotate.JsonSerialize;
-import org.openflow.util.HexString;
+import org.projectfloodlight.openflow.util.HexString;
/**
* The class representing MAC address.
diff --git a/src/main/java/net/floodlightcontroller/util/OFMessageDamper.java b/src/main/java/net/floodlightcontroller/util/OFMessageDamper.java
deleted file mode 100644
index 90bee76..0000000
--- a/src/main/java/net/floodlightcontroller/util/OFMessageDamper.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright Big Switch Networks 2012
- */
-
-package net.floodlightcontroller.util;
-
-import java.io.IOException;
-import java.util.EnumSet;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-import net.floodlightcontroller.core.FloodlightContext;
-import net.floodlightcontroller.core.IOFSwitch;
-
-import org.openflow.protocol.OFMessage;
-import org.openflow.protocol.OFType;
-
-/**
- * Dampens OFMessages sent to an OF switch. A message is only written to
- * a switch if the same message (as defined by .equals()) has not been written
- * in the last n milliseconds. Timer granularity is based on TimedCache
- *
- * @author gregor
- */
-public class OFMessageDamper {
- /**
- * An entry in the TimedCache. A cache entry consists of the sent message
- * as well as the switch to which the message was sent.
- * <p/>
- * NOTE: We currently use the full OFMessage object. To save space, we
- * could use a cryptographic hash (e.g., SHA-1). However, this would
- * obviously be more time-consuming....
- * <p/>
- * We also store a reference to the actual IOFSwitch object and /not/
- * the switch DPID. This way we are guarnteed to not dampen messages if
- * a switch disconnects and then reconnects.
- *
- * @author gregor
- */
- protected static class DamperEntry {
- OFMessage msg;
- IOFSwitch sw;
-
- public DamperEntry(OFMessage msg, IOFSwitch sw) {
- super();
- this.msg = msg;
- this.sw = sw;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((msg == null) ? 0 : msg.hashCode());
- result = prime * result + ((sw == null) ? 0 : sw.hashCode());
- return result;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) return true;
- if (obj == null) return false;
- if (getClass() != obj.getClass()) return false;
- DamperEntry other = (DamperEntry) obj;
- if (msg == null) {
- if (other.msg != null) return false;
- } else if (!msg.equals(other.msg)) return false;
- if (sw == null) {
- if (other.sw != null) return false;
- } else if (!sw.equals(other.sw)) return false;
- return true;
- }
-
-
- }
-
- TimedCache<DamperEntry> cache;
- EnumSet<OFType> msgTypesToCache;
- // executor for invalidate task
- private static ExecutorService executor = Executors.newFixedThreadPool(1);
-
- /**
- * @param capacity the maximum number of messages that should be
- * kept
- * @param typesToDampen The set of OFMessageTypes that should be
- * dampened by this instance. Other types will be passed through
- * @param timeout The dampening timeout. A message will only be
- * written if the last write for the an equal message more than
- * timeout ms ago.
- */
- public OFMessageDamper(int capacity,
- Set<OFType> typesToDampen,
- int timeout) {
- cache = new TimedCache<DamperEntry>(capacity, timeout);
- msgTypesToCache = EnumSet.copyOf(typesToDampen);
- }
-
- /**
- * write the messag to the switch according to our dampening settings
- *
- * @param sw
- * @param msg
- * @param cntx
- * @return true if the message was written to the switch, false if
- * the message was dampened.
- * @throws IOException
- */
- public boolean write(IOFSwitch sw, OFMessage msg, FloodlightContext cntx)
- throws IOException {
- return write(sw, msg, cntx, false);
- }
-
- /**
- * write the messag to the switch according to our dampening settings
- *
- * @param sw
- * @param msg
- * @param cntx
- * @param flush true to flush the packet immidiately
- * @return true if the message was written to the switch, false if
- * the message was dampened.
- * @throws IOException
- */
- public boolean write(IOFSwitch sw, OFMessage msg,
- FloodlightContext cntx, boolean flush)
- throws IOException {
- if (!msgTypesToCache.contains(msg.getType())) {
- // XXX S commenting out old message writes
- //sw.write(msg, cntx);
- if (flush) {
- sw.flush();
- }
- return true;
- }
-
- DamperEntry entry = new DamperEntry(msg, sw);
- if (cache.update(entry)) {
- // entry exists in cache. Dampening.
- return false;
- } else {
- // XXX S commenting out old message writes
- // sw.write(msg, cntx);
- if (flush) {
- sw.flush();
- }
- return true;
- }
- }
-
- /**
- * Invalidates all the damper cache entries for the specified switch.
- *
- * @param sw switch connection to invalidate
- */
- public void invalidate(final IOFSwitch sw) {
- executor.submit(new Runnable() {
- @Override
- public void run() {
- Iterator<DamperEntry> it = cache.getCachedEntries().iterator();
- while (it.hasNext()) {
- DamperEntry entry = it.next();
- if (entry.sw == sw) {
- it.remove();
- }
- }
- }
- });
- }
-}
diff --git a/src/main/java/net/onrc/onos/apps/forwarding/Forwarding.java b/src/main/java/net/onrc/onos/apps/forwarding/Forwarding.java
index a2a8e48..d88a296 100644
--- a/src/main/java/net/onrc/onos/apps/forwarding/Forwarding.java
+++ b/src/main/java/net/onrc/onos/apps/forwarding/Forwarding.java
@@ -40,7 +40,7 @@
import net.onrc.onos.core.util.PortNumber;
import net.onrc.onos.core.util.SwitchPort;
-import org.openflow.util.HexString;
+import org.projectfloodlight.openflow.util.HexString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/src/main/java/net/onrc/onos/apps/proxyarp/ProxyArpManager.java b/src/main/java/net/onrc/onos/apps/proxyarp/ProxyArpManager.java
index 28efb33..2593a59 100644
--- a/src/main/java/net/onrc/onos/apps/proxyarp/ProxyArpManager.java
+++ b/src/main/java/net/onrc/onos/apps/proxyarp/ProxyArpManager.java
@@ -37,7 +37,7 @@
import net.onrc.onos.core.util.PortNumber;
import net.onrc.onos.core.util.SwitchPort;
-import org.openflow.util.HexString;
+import org.projectfloodlight.openflow.util.HexString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/src/main/java/net/onrc/onos/apps/sdnip/Configuration.java b/src/main/java/net/onrc/onos/apps/sdnip/Configuration.java
index 28f195c..b834603 100644
--- a/src/main/java/net/onrc/onos/apps/sdnip/Configuration.java
+++ b/src/main/java/net/onrc/onos/apps/sdnip/Configuration.java
@@ -6,7 +6,7 @@
import net.floodlightcontroller.util.MACAddress;
import org.codehaus.jackson.annotate.JsonProperty;
-import org.openflow.util.HexString;
+import org.projectfloodlight.openflow.util.HexString;
/**
* Contains the configuration data for SDN-IP that has been read from a
diff --git a/src/main/java/net/onrc/onos/apps/sdnip/FlowCache.java b/src/main/java/net/onrc/onos/apps/sdnip/FlowCache.java
deleted file mode 100644
index dc9182c..0000000
--- a/src/main/java/net/onrc/onos/apps/sdnip/FlowCache.java
+++ /dev/null
@@ -1,166 +0,0 @@
-package net.onrc.onos.apps.sdnip;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import net.floodlightcontroller.core.IFloodlightProviderService;
-import net.floodlightcontroller.core.IOFSwitch;
-
-import org.openflow.protocol.OFFlowMod;
-import org.openflow.protocol.OFMessage;
-import org.openflow.protocol.OFPort;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class FlowCache {
- private static final Logger log = LoggerFactory.getLogger(FlowCache.class);
-
- private final IFloodlightProviderService floodlightProvider;
-
- private final Map<Long, List<OFFlowMod>> flowCacheMap;
-
- private final Comparator<OFFlowMod> cookieComparator =
- new Comparator<OFFlowMod>() {
- @Override
- public int compare(OFFlowMod fm1, OFFlowMod fm2) {
- long difference = fm2.getCookie() - fm1.getCookie();
-
- if (difference > 0) {
- return 1;
- } else if (difference < 0) {
- return -1;
- } else {
- return 0;
- }
- }
- };
-
- public FlowCache(IFloodlightProviderService floodlightProvider) {
- this.floodlightProvider = floodlightProvider;
-
- flowCacheMap = new HashMap<Long, List<OFFlowMod>>();
- }
-
- public void write(long dpid, OFFlowMod flowMod) {
- synchronized (this) {
- List<OFFlowMod> flowModList = new ArrayList<OFFlowMod>(1);
- flowModList.add(flowMod);
- write(dpid, flowModList);
- }
- }
-
- public void write(long dpid, List<OFFlowMod> flowMods) {
- synchronized (this) {
- ensureCacheForSwitch(dpid);
-
- List<OFFlowMod> clones = new ArrayList<OFFlowMod>(flowMods.size());
-
- // Somehow the OFFlowMods we get passed in will change later on.
- // No idea how this happens, but we can just clone to prevent problems
- try {
- for (OFFlowMod fm : flowMods) {
- clones.add(fm.clone());
- }
- } catch (CloneNotSupportedException e) {
- log.debug("Clone exception", e);
- }
-
- flowCacheMap.get(dpid).addAll(clones);
-
- IOFSwitch sw = floodlightProvider.getSwitches().get(dpid);
-
- if (sw == null) {
- log.debug("Switch not found when writing flow mods");
- return;
- }
-
- List<OFMessage> msgList = new ArrayList<OFMessage>(clones.size());
- msgList.addAll(clones);
-
- // XXX S commenting out the old message writes
- /*try {
- sw.write(msgList, null);
- } catch (IOException e) {
- log.error("Error writing to switch", e);
- }*/
- }
- }
-
- public void delete(long dpid, OFFlowMod flowMod) {
- synchronized (this) {
- List<OFFlowMod> flowModList = new ArrayList<OFFlowMod>(1);
- flowModList.add(flowMod);
- delete(dpid, flowModList);
- }
- }
-
- public void delete(long dpid, List<OFFlowMod> flowMods) {
- synchronized (this) {
- ensureCacheForSwitch(dpid);
-
- // Remove the flow mods from the cache first before we alter them
- flowCacheMap.get(dpid).removeAll(flowMods);
-
- // Alter the original flow mods to make them delete flow mods
- for (OFFlowMod fm : flowMods) {
- fm.setCommand(OFFlowMod.OFPFC_DELETE_STRICT)
- .setOutPort(OFPort.OFPP_NONE)
- .setLengthU(OFFlowMod.MINIMUM_LENGTH);
-
- fm.getActions().clear();
- }
-
- IOFSwitch sw = floodlightProvider.getSwitches().get(dpid);
- if (sw == null) {
- log.debug("Switch not found when writing flow mods");
- return;
- }
-
- List<OFMessage> msgList = new ArrayList<OFMessage>(flowMods.size());
- msgList.addAll(flowMods);
-
- // XXX S commenting out old message writes
- /*try {
- sw.write(msgList, null);
- } catch (IOException e) {
- log.error("Error writing to switch", e);
- }*/
- }
- }
-
- public void switchConnected(IOFSwitch sw) {
- synchronized (this) {
- log.debug("Switch connected: {}", sw);
-
- ensureCacheForSwitch(sw.getId());
-
- List<OFFlowMod> flowMods = flowCacheMap.get(sw.getId());
-
- Collections.sort(flowMods, cookieComparator);
-
- sw.clearAllFlowMods();
-
- List<OFMessage> messages = new ArrayList<OFMessage>(flowMods.size());
- messages.addAll(flowMods);
-
- // XXX S commenting out old message writes
- /* try {
- sw.write(messages, null);
- } catch (IOException e) {
- log.error("Failure writing flow mods to switch {}",
- HexString.toHexString(sw.getId()));
- }
- */
- }
- }
-
- private void ensureCacheForSwitch(long dpid) {
- if (!flowCacheMap.containsKey(dpid)) {
- flowCacheMap.put(dpid, new ArrayList<OFFlowMod>());
- }
- }
-}
diff --git a/src/main/java/net/onrc/onos/apps/sdnip/Interface.java b/src/main/java/net/onrc/onos/apps/sdnip/Interface.java
index de3b48c..463cac8 100644
--- a/src/main/java/net/onrc/onos/apps/sdnip/Interface.java
+++ b/src/main/java/net/onrc/onos/apps/sdnip/Interface.java
@@ -8,7 +8,7 @@
import org.codehaus.jackson.annotate.JsonCreator;
import org.codehaus.jackson.annotate.JsonProperty;
-import org.openflow.util.HexString;
+import org.projectfloodlight.openflow.util.HexString;
import com.google.common.net.InetAddresses;
diff --git a/src/main/java/net/onrc/onos/apps/sdnip/Path.java b/src/main/java/net/onrc/onos/apps/sdnip/Path.java
index 28b632b..7a6dd27 100644
--- a/src/main/java/net/onrc/onos/apps/sdnip/Path.java
+++ b/src/main/java/net/onrc/onos/apps/sdnip/Path.java
@@ -1,8 +1,6 @@
package net.onrc.onos.apps.sdnip;
import java.net.InetAddress;
-import java.util.Collections;
-import java.util.List;
/**
* A {@link Path} represents paths within a network that forward traffic from
@@ -35,7 +33,8 @@
private final InetAddress dstIpAddress;
private int numUsers; // initialized to 0
- private List<PushedFlowMod> flowMods; // initialized to null
+ // XXX PushedFlowMod has been removed
+ //private List<PushedFlowMod> flowMods; // initialized to null
private boolean permanent; // initialized to false
/**
@@ -97,9 +96,10 @@
*
* @return the list of {@link PushedFlowMod}s
*/
- public List<PushedFlowMod> getFlowMods() {
+ // XXX PushedFlowMod has been removed
+ /*public List<PushedFlowMod> getFlowMods() {
return Collections.unmodifiableList(flowMods);
- }
+ }*/
/**
* Sets the list of flow mods that were installed to realize this path in
@@ -107,9 +107,10 @@
*
* @param flowMods the list of {@link PushedFlowMod}s
*/
- public void setFlowMods(List<PushedFlowMod> flowMods) {
+ // XXX PushedFlowMod has been removed
+ /*public void setFlowMods(List<PushedFlowMod> flowMods) {
this.flowMods = flowMods;
- }
+ }*/
/**
* Signifies whether the path is permanent and shouldn't be deleted when
diff --git a/src/main/java/net/onrc/onos/apps/sdnip/PushedFlowMod.java b/src/main/java/net/onrc/onos/apps/sdnip/PushedFlowMod.java
deleted file mode 100644
index 38ac37f..0000000
--- a/src/main/java/net/onrc/onos/apps/sdnip/PushedFlowMod.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package net.onrc.onos.apps.sdnip;
-
-import org.openflow.protocol.OFFlowMod;
-
-// TODO This functionality should be handled by ONOS's flow layer in future.
-/**
- * Collects together the DPID and OFFlowMod of a pushed flow mod. This
- * information is used if the flow mod has to be deleted in the future.
- */
-public class PushedFlowMod {
- private final long dpid;
- private OFFlowMod flowMod;
-
- /**
- * Class constructor, taking a DPID and a flow mod.
- *
- * @param dpid the DPID of the switch the flow mod was pushed to
- * @param flowMod the OFFlowMod that was pushed to the switch
- */
- public PushedFlowMod(long dpid, OFFlowMod flowMod) {
- this.dpid = dpid;
- try {
- this.flowMod = flowMod.clone();
- } catch (CloneNotSupportedException e) {
- this.flowMod = flowMod;
- }
- }
-
- /**
- * Gets the DPID of the switch the flow mod was pushed to.
- *
- * @return the DPID of the switch
- */
- public long getDpid() {
- return dpid;
- }
-
- /**
- * Gets the OFFlowMod that was pushed to the switch.
- *
- * @return the OFFlowMod object
- */
- public OFFlowMod getFlowMod() {
- return flowMod;
- }
-}
diff --git a/src/main/java/net/onrc/onos/apps/sdnip/SdnIp.java b/src/main/java/net/onrc/onos/apps/sdnip/SdnIp.java
index 135d0a7..49128ea 100644
--- a/src/main/java/net/onrc/onos/apps/sdnip/SdnIp.java
+++ b/src/main/java/net/onrc/onos/apps/sdnip/SdnIp.java
@@ -62,13 +62,6 @@
import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
-import org.openflow.protocol.OFFlowMod;
-import org.openflow.protocol.OFMatch;
-import org.openflow.protocol.OFPacketOut;
-import org.openflow.protocol.OFPort;
-import org.openflow.protocol.action.OFAction;
-import org.openflow.protocol.action.OFActionOutput;
-import org.openflow.util.HexString;
import org.projectfloodlight.openflow.protocol.OFPortDesc;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -160,7 +153,8 @@
// private Multimap<Prefix, PushedFlowMod> pushedFlows;
private Multimap<Prefix, FlowId> pushedFlowIds;
- private FlowCache flowCache;
+ // XXX FlowCache has been removed
+ //private FlowCache flowCache;
// TODO: Fix for the new Topology Network Graph
// private volatile Topology topology = null;
@@ -305,7 +299,7 @@
// pushedFlows = HashMultimap.<Prefix, PushedFlowMod>create();
pushedFlowIds = HashMultimap.create();
- flowCache = new FlowCache(floodlightProvider);
+ //flowCache = new FlowCache(floodlightProvider);
bgpUpdatesExecutor = Executors.newSingleThreadExecutor(
new ThreadFactoryBuilder().setNameFormat("bgp-updates-%d").build());
@@ -1162,8 +1156,8 @@
}
}
- // TODO wait the priority module of the flow Manager
- private void setupArpFlows() {
+ // XXX OpenFlow message classes have been removed
+ /*private void setupArpFlows() {
OFMatch match = new OFMatch();
match.setDataLayerType(Ethernet.TYPE_ARP);
match.setWildcards(match.getWildcards() & ~OFMatch.OFPFW_DL_TYPE);
@@ -1191,7 +1185,6 @@
}
}
- // TODO need update, waiting for the priority feature from flow Manager
private void setupDefaultDropFlows() {
OFFlowMod fm = new OFFlowMod();
fm.setMatch(new OFMatch());
@@ -1247,7 +1240,7 @@
for (String strdpid : switches) {
flowCache.write(HexString.toLong(strdpid), flowModList);
}
- }
+ }*/
private void beginRouting() {
log.debug("Topology is now ready, beginning routing function");
@@ -1469,7 +1462,7 @@
sw.clearAllFlowMods();
}
- flowCache.switchConnected(sw);
+ //flowCache.switchConnected(sw);
}
@Override
diff --git a/src/main/java/net/onrc/onos/core/flowprogrammer/FlowProgrammer.java b/src/main/java/net/onrc/onos/core/flowprogrammer/FlowProgrammer.java
index 4a62947..5711287 100644
--- a/src/main/java/net/onrc/onos/core/flowprogrammer/FlowProgrammer.java
+++ b/src/main/java/net/onrc/onos/core/flowprogrammer/FlowProgrammer.java
@@ -160,7 +160,6 @@
synchronizer.interrupt(sw);
}
pusher.deleteQueue(sw, true);
- pusher.invalidate(sw);
}
@Override
diff --git a/src/main/java/net/onrc/onos/core/flowprogrammer/FlowPusher.java b/src/main/java/net/onrc/onos/core/flowprogrammer/FlowPusher.java
index 17bbc1a..419dc43 100644
--- a/src/main/java/net/onrc/onos/core/flowprogrammer/FlowPusher.java
+++ b/src/main/java/net/onrc/onos/core/flowprogrammer/FlowPusher.java
@@ -24,7 +24,6 @@
import net.floodlightcontroller.core.internal.OFMessageFuture;
import net.floodlightcontroller.core.module.FloodlightModuleContext;
import net.floodlightcontroller.threadpool.IThreadPoolService;
-import net.floodlightcontroller.util.OFMessageDamper;
import net.onrc.onos.core.intent.FlowEntry;
import net.onrc.onos.core.util.Pair;
@@ -55,13 +54,6 @@
private static final Logger log = LoggerFactory.getLogger(FlowPusher.class);
protected static final int DEFAULT_NUMBER_THREAD = 1;
- // TODO: Values copied from elsewhere (class LearningSwitch).
- // The local copy should go away!
- //
- protected static final int OFMESSAGE_DAMPER_CAPACITY = 10000; // TODO: find
- // sweet spot
- protected static final int OFMESSAGE_DAMPER_TIMEOUT = 250; // ms
-
// Number of messages sent to switch at once
protected static final int MAX_MESSAGE_SEND = 100;
@@ -251,7 +243,6 @@
}
private FloodlightModuleContext context = null;
- private OFMessageDamper messageDamper = null;
private IThreadPoolService threadPool = null;
private IFloodlightProviderService floodlightProvider = null;
protected Map<OFVersion, OFFactory> ofFactoryMap = null;
@@ -346,8 +337,6 @@
OFMessage msg = queueEntry.getOFMessage();
try {
- // TODO BOC do we need to use the message damper?
- // messageDamper.write(sw, msg, context);
sw.write(msg, null);
if (log.isTraceEnabled()) {
log.trace("Pusher sends message to switch {}: {}", sw.getStringId(), msg);
@@ -415,22 +404,11 @@
this.floodlightProvider = context
.getServiceImpl(IFloodlightProviderService.class);
this.threadPool = context.getServiceImpl(IThreadPoolService.class);
- this.messageDamper = null;
ofFactoryMap = new HashMap<>();
ofFactoryMap.put(OFVersion.OF_10, floodlightProvider.getOFMessageFactory_10());
ofFactoryMap.put(OFVersion.OF_13, floodlightProvider.getOFMessageFactory_13());
floodlightProvider.addOFMessageListener(OFType.BARRIER_REPLY, this);
-
- // TODO BOC message damper may not be needed...
- // if (damper != null) {
- // messageDamper = damper;
- // } else {
- // use default values
- /*messageDamper = new OFMessageDamper(OFMESSAGE_DAMPER_CAPACITY,
- EnumSet.of(OFType.FLOW_MOD),
- OFMESSAGE_DAMPER_TIMEOUT);*/
- // }
}
/**
@@ -584,16 +562,6 @@
}
}
- /**
- * Invalidate.
- * <p>
- * @param sw switch
- * @see OFMessageDamper#invalidate(IOFSwitch)
- */
- public void invalidate(IOFSwitch sw) {
- // messageDamper.invalidate(sw); currently a null ptr - commenting out
- }
-
@Override
public boolean add(IOFSwitch sw, OFMessage msg) {
return add(sw, msg, MsgPriority.NORMAL);
diff --git a/src/main/java/net/onrc/onos/core/flowprogrammer/FlowSynchronizer.java b/src/main/java/net/onrc/onos/core/flowprogrammer/FlowSynchronizer.java
index 7b2bfd0..0441ddc 100644
--- a/src/main/java/net/onrc/onos/core/flowprogrammer/FlowSynchronizer.java
+++ b/src/main/java/net/onrc/onos/core/flowprogrammer/FlowSynchronizer.java
@@ -1,9 +1,7 @@
package net.onrc.onos.core.flowprogrammer;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Callable;
@@ -11,16 +9,7 @@
import java.util.concurrent.FutureTask;
import net.floodlightcontroller.core.IOFSwitch;
-import net.onrc.onos.core.util.FlowEntryId;
-import org.openflow.protocol.OFFlowMod;
-import org.openflow.protocol.OFMatch;
-import org.openflow.protocol.OFPort;
-import org.openflow.protocol.OFStatisticsRequest;
-import org.openflow.protocol.statistics.OFFlowStatisticsReply;
-import org.openflow.protocol.statistics.OFFlowStatisticsRequest;
-import org.openflow.protocol.statistics.OFStatistics;
-import org.openflow.protocol.statistics.OFStatisticsType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -193,7 +182,7 @@
*/
private Set<FlowEntryWrapper> getFlowEntriesFromSwitch() {
- int lengthU = 0;
+ /*int lengthU = 0;
OFMatch match = new OFMatch();
match.setWildcards(OFMatch.OFPFW_ALL);
@@ -209,7 +198,7 @@
req.setStatisticType(OFStatisticsType.FLOW);
req.setStatistics(stats);
lengthU += req.getLengthU();
- req.setLengthU(lengthU);
+ req.setLengthU(lengthU);*/
//List<OFStatistics> entries = null;
// XXX S when we fix stats, we fix this
@@ -245,10 +234,10 @@
* by FlowEntryId (from GraphDB) or OFFlowStatisticsReply (from switch).
*/
static class FlowEntryWrapper {
- FlowEntryId flowEntryId;
+ //FlowEntryId flowEntryId;
// TODO: fix when FlowSynchronizer is refactored
// IFlowEntry iFlowEntry;
- OFFlowStatisticsReply statisticsReply;
+ //OFFlowStatisticsReply statisticsReply;
// TODO: fix when FlowSynchronizer is refactored
@@ -259,10 +248,10 @@
}
*/
- public FlowEntryWrapper(OFFlowStatisticsReply entry) {
+ /*public FlowEntryWrapper(OFFlowStatisticsReply entry) {
flowEntryId = new FlowEntryId(entry.getCookie());
statisticsReply = entry;
- }
+ }*/
/**
* Install this FlowEntry to a switch via FlowPusher.
@@ -272,13 +261,13 @@
double dbTime, extractTime, pushTime;
public void addToSwitch(IOFSwitch sw) {
- if (statisticsReply != null) {
+ /*if (statisticsReply != null) {
log.error("Error adding existing flow entry {} to sw {}",
statisticsReply.getCookie(), sw.getId());
return;
}
- double startDB = System.nanoTime();
+ double startDB = System.nanoTime();*/
// Get the Flow Entry state from the Network Graph
// TODO: fix when FlowSynchronizer is refactored
/*
@@ -293,7 +282,7 @@
}
}
*/
- dbTime = System.nanoTime() - startDB;
+ //dbTime = System.nanoTime() - startDB;
//
// TODO: The old FlowDatabaseOperation class is gone, so the code
@@ -321,7 +310,7 @@
* @param sw Switch from which flow will be removed.
*/
public void removeFromSwitch(IOFSwitch sw) {
- if (statisticsReply == null) {
+ /*if (statisticsReply == null) {
log.error("Error removing non-existent flow entry {} from sw {}",
flowEntryId, sw.getId());
return;
@@ -334,7 +323,7 @@
fm.setLengthU(OFFlowMod.MINIMUM_LENGTH);
fm.setMatch(statisticsReply.getMatch());
fm.setPriority(statisticsReply.getPriority());
- fm.setOutPort(OFPort.OFPP_NONE);
+ fm.setOutPort(OFPort.OFPP_NONE);*/
// XXX BOC commented out pending FlowSync refactor
//pusher.add(sw, fm, MsgPriority.HIGH);
@@ -345,7 +334,8 @@
*/
@Override
public int hashCode() {
- return flowEntryId.hashCode();
+ //return flowEntryId.hashCode();
+ return 0;
}
/**
@@ -358,16 +348,18 @@
@Override
public boolean equals(Object obj) {
if (obj != null && obj.getClass() == this.getClass()) {
- FlowEntryWrapper entry = (FlowEntryWrapper) obj;
+ //FlowEntryWrapper entry = (FlowEntryWrapper) obj;
// TODO: we need to actually compare the match + actions
- return this.flowEntryId.equals(entry.flowEntryId);
+ //return this.flowEntryId.equals(entry.flowEntryId);
+ return true;
}
return false;
}
@Override
public String toString() {
- return flowEntryId.toString();
+ //return flowEntryId.toString();
+ return "";
}
}
}
diff --git a/src/main/java/net/onrc/onos/core/flowprogrammer/web/DoInterruptResource.java b/src/main/java/net/onrc/onos/core/flowprogrammer/web/DoInterruptResource.java
index f2b4631..537167b 100644
--- a/src/main/java/net/onrc/onos/core/flowprogrammer/web/DoInterruptResource.java
+++ b/src/main/java/net/onrc/onos/core/flowprogrammer/web/DoInterruptResource.java
@@ -2,7 +2,7 @@
import net.floodlightcontroller.core.IOFSwitch;
-import org.openflow.util.HexString;
+import org.projectfloodlight.openflow.util.HexString;
import org.restlet.resource.Get;
/**
diff --git a/src/main/java/net/onrc/onos/core/flowprogrammer/web/DoSynchronizeResource.java b/src/main/java/net/onrc/onos/core/flowprogrammer/web/DoSynchronizeResource.java
index 51d39d8..956a7fb 100644
--- a/src/main/java/net/onrc/onos/core/flowprogrammer/web/DoSynchronizeResource.java
+++ b/src/main/java/net/onrc/onos/core/flowprogrammer/web/DoSynchronizeResource.java
@@ -2,7 +2,7 @@
import net.floodlightcontroller.core.IOFSwitch;
-import org.openflow.util.HexString;
+import org.projectfloodlight.openflow.util.HexString;
import org.restlet.resource.Get;
/**
diff --git a/src/main/java/net/onrc/onos/core/flowprogrammer/web/ResumePusherResource.java b/src/main/java/net/onrc/onos/core/flowprogrammer/web/ResumePusherResource.java
index a9e6c81..ecfec7e 100644
--- a/src/main/java/net/onrc/onos/core/flowprogrammer/web/ResumePusherResource.java
+++ b/src/main/java/net/onrc/onos/core/flowprogrammer/web/ResumePusherResource.java
@@ -2,7 +2,7 @@
import net.floodlightcontroller.core.IOFSwitch;
-import org.openflow.util.HexString;
+import org.projectfloodlight.openflow.util.HexString;
import org.restlet.resource.Get;
/**
diff --git a/src/main/java/net/onrc/onos/core/flowprogrammer/web/SendBarrierResource.java b/src/main/java/net/onrc/onos/core/flowprogrammer/web/SendBarrierResource.java
index 4fc6782..bdcdcb6 100644
--- a/src/main/java/net/onrc/onos/core/flowprogrammer/web/SendBarrierResource.java
+++ b/src/main/java/net/onrc/onos/core/flowprogrammer/web/SendBarrierResource.java
@@ -2,8 +2,8 @@
import net.floodlightcontroller.core.IOFSwitch;
-import org.openflow.util.HexString;
import org.projectfloodlight.openflow.protocol.OFBarrierReply;
+import org.projectfloodlight.openflow.util.HexString;
import org.restlet.resource.Get;
/**
diff --git a/src/main/java/net/onrc/onos/core/flowprogrammer/web/SetPushRateResource.java b/src/main/java/net/onrc/onos/core/flowprogrammer/web/SetPushRateResource.java
index a2993a5..63717a1 100644
--- a/src/main/java/net/onrc/onos/core/flowprogrammer/web/SetPushRateResource.java
+++ b/src/main/java/net/onrc/onos/core/flowprogrammer/web/SetPushRateResource.java
@@ -2,7 +2,7 @@
import net.floodlightcontroller.core.IOFSwitch;
-import org.openflow.util.HexString;
+import org.projectfloodlight.openflow.util.HexString;
import org.restlet.resource.Get;
/**
diff --git a/src/main/java/net/onrc/onos/core/flowprogrammer/web/SuspendPusherResource.java b/src/main/java/net/onrc/onos/core/flowprogrammer/web/SuspendPusherResource.java
index ba752e6..e1aa320 100644
--- a/src/main/java/net/onrc/onos/core/flowprogrammer/web/SuspendPusherResource.java
+++ b/src/main/java/net/onrc/onos/core/flowprogrammer/web/SuspendPusherResource.java
@@ -2,7 +2,7 @@
import net.floodlightcontroller.core.IOFSwitch;
-import org.openflow.util.HexString;
+import org.projectfloodlight.openflow.util.HexString;
import org.restlet.resource.Get;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/src/main/java/net/onrc/onos/core/intent/runtime/web/serializers/ShortestPathIntentSerializer.java b/src/main/java/net/onrc/onos/core/intent/runtime/web/serializers/ShortestPathIntentSerializer.java
index ce0709e..be316ac 100644
--- a/src/main/java/net/onrc/onos/core/intent/runtime/web/serializers/ShortestPathIntentSerializer.java
+++ b/src/main/java/net/onrc/onos/core/intent/runtime/web/serializers/ShortestPathIntentSerializer.java
@@ -1,15 +1,17 @@
package net.onrc.onos.core.intent.runtime.web.serializers;
-import com.google.common.net.InetAddresses;
+import java.io.IOException;
+
import net.floodlightcontroller.util.MACAddress;
import net.onrc.onos.core.intent.ShortestPathIntent;
+
import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.map.SerializerProvider;
import org.codehaus.jackson.map.ser.std.SerializerBase;
-import org.openflow.util.HexString;
+import org.projectfloodlight.openflow.util.HexString;
-import java.io.IOException;
+import com.google.common.net.InetAddresses;
/**
* JSON serializer for ShortestPathIntents.
diff --git a/src/main/java/net/onrc/onos/core/linkdiscovery/Link.java b/src/main/java/net/onrc/onos/core/linkdiscovery/Link.java
index 2d1508f..193db07 100644
--- a/src/main/java/net/onrc/onos/core/linkdiscovery/Link.java
+++ b/src/main/java/net/onrc/onos/core/linkdiscovery/Link.java
@@ -22,7 +22,7 @@
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonSerialize;
-import org.openflow.util.HexString;
+import org.projectfloodlight.openflow.util.HexString;
public final class Link {
private final long src;
diff --git a/src/main/java/net/onrc/onos/core/linkdiscovery/NodePortTuple.java b/src/main/java/net/onrc/onos/core/linkdiscovery/NodePortTuple.java
index 9288dad..cff6633 100644
--- a/src/main/java/net/onrc/onos/core/linkdiscovery/NodePortTuple.java
+++ b/src/main/java/net/onrc/onos/core/linkdiscovery/NodePortTuple.java
@@ -5,7 +5,7 @@
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonSerialize;
-import org.openflow.util.HexString;
+import org.projectfloodlight.openflow.util.HexString;
/**
* A NodePortTuple is similar to a SwitchPortTuple
diff --git a/src/main/java/net/onrc/onos/core/linkdiscovery/web/LinkWithType.java b/src/main/java/net/onrc/onos/core/linkdiscovery/web/LinkWithType.java
index 01a1539..8c4a7a8d 100644
--- a/src/main/java/net/onrc/onos/core/linkdiscovery/web/LinkWithType.java
+++ b/src/main/java/net/onrc/onos/core/linkdiscovery/web/LinkWithType.java
@@ -10,7 +10,7 @@
import org.codehaus.jackson.map.JsonSerializer;
import org.codehaus.jackson.map.SerializerProvider;
import org.codehaus.jackson.map.annotate.JsonSerialize;
-import org.openflow.util.HexString;
+import org.projectfloodlight.openflow.util.HexString;
/**
* This class is both the datastructure and the serializer
diff --git a/src/main/java/net/onrc/onos/core/main/config/DefaultConfiguration.java b/src/main/java/net/onrc/onos/core/main/config/DefaultConfiguration.java
index 13b9b53..219cdf3 100644
--- a/src/main/java/net/onrc/onos/core/main/config/DefaultConfiguration.java
+++ b/src/main/java/net/onrc/onos/core/main/config/DefaultConfiguration.java
@@ -13,7 +13,7 @@
import net.floodlightcontroller.util.MACAddress;
import net.onrc.onos.apps.sdnip.Interface;
-import org.openflow.util.HexString;
+import org.projectfloodlight.openflow.util.HexString;
public class DefaultConfiguration implements IConfigInfoService, IFloodlightModule {
diff --git a/src/main/java/net/onrc/onos/core/packet/BSNPROBE.java b/src/main/java/net/onrc/onos/core/packet/BSNPROBE.java
index c64d1a5..b007cd9 100644
--- a/src/main/java/net/onrc/onos/core/packet/BSNPROBE.java
+++ b/src/main/java/net/onrc/onos/core/packet/BSNPROBE.java
@@ -23,7 +23,7 @@
import java.util.Arrays;
import org.apache.commons.lang.ArrayUtils;
-import org.openflow.util.HexString;
+import org.projectfloodlight.openflow.util.HexString;
// CHECKSTYLE IGNORE WriteTag FOR NEXT 2 LINES
/**
diff --git a/src/main/java/net/onrc/onos/core/packet/Ethernet.java b/src/main/java/net/onrc/onos/core/packet/Ethernet.java
index e75822f..62e30f5 100644
--- a/src/main/java/net/onrc/onos/core/packet/Ethernet.java
+++ b/src/main/java/net/onrc/onos/core/packet/Ethernet.java
@@ -24,7 +24,7 @@
import net.floodlightcontroller.util.MACAddress;
-import org.openflow.util.HexString;
+import org.projectfloodlight.openflow.util.HexString;
// CHECKSTYLE IGNORE WriteTag FOR NEXT 2 LINES
/**
diff --git a/src/main/java/net/onrc/onos/core/registry/StandaloneRegistry.java b/src/main/java/net/onrc/onos/core/registry/StandaloneRegistry.java
index bec8bb4..97e445f 100644
--- a/src/main/java/net/onrc/onos/core/registry/StandaloneRegistry.java
+++ b/src/main/java/net/onrc/onos/core/registry/StandaloneRegistry.java
@@ -18,7 +18,7 @@
import net.onrc.onos.core.util.OnosInstanceId;
import org.apache.commons.lang.NotImplementedException;
-import org.openflow.util.HexString;
+import org.projectfloodlight.openflow.util.HexString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/src/main/java/net/onrc/onos/core/registry/ZookeeperRegistry.java b/src/main/java/net/onrc/onos/core/registry/ZookeeperRegistry.java
index fb7b573..5bb7f00 100644
--- a/src/main/java/net/onrc/onos/core/registry/ZookeeperRegistry.java
+++ b/src/main/java/net/onrc/onos/core/registry/ZookeeperRegistry.java
@@ -44,7 +44,7 @@
import org.apache.curator.x.discovery.ServiceDiscovery;
import org.apache.curator.x.discovery.ServiceDiscoveryBuilder;
import org.apache.curator.x.discovery.ServiceInstance;
-import org.openflow.util.HexString;
+import org.projectfloodlight.openflow.util.HexString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/src/main/java/net/onrc/onos/core/util/Dpid.java b/src/main/java/net/onrc/onos/core/util/Dpid.java
index 1abd0f1..e157975 100644
--- a/src/main/java/net/onrc/onos/core/util/Dpid.java
+++ b/src/main/java/net/onrc/onos/core/util/Dpid.java
@@ -5,7 +5,7 @@
import org.codehaus.jackson.map.annotate.JsonDeserialize;
import org.codehaus.jackson.map.annotate.JsonSerialize;
-import org.openflow.util.HexString;
+import org.projectfloodlight.openflow.util.HexString;
/**
* The class representing a network switch DPID.
diff --git a/src/main/java/net/onrc/onos/core/util/FlowEntryAction.java b/src/main/java/net/onrc/onos/core/util/FlowEntryAction.java
index d5ad674..0cc1d6d 100644
--- a/src/main/java/net/onrc/onos/core/util/FlowEntryAction.java
+++ b/src/main/java/net/onrc/onos/core/util/FlowEntryAction.java
@@ -3,7 +3,7 @@
import net.floodlightcontroller.util.MACAddress;
import org.codehaus.jackson.annotate.JsonProperty;
-import org.openflow.protocol.OFPort;
+import org.projectfloodlight.openflow.types.OFPort;
/**
* The class representing a single Flow Entry action.
@@ -1212,7 +1212,7 @@
* @param maxLen the maximum length (in bytes) to send to controller.
*/
public void setActionOutputToController(short maxLen) {
- PortNumber port = new PortNumber(OFPort.OFPP_CONTROLLER.getValue());
+ PortNumber port = new PortNumber(OFPort.CONTROLLER.getShortPortNumber());
actionOutput = new ActionOutput(port, maxLen);
actionType = ActionValues.ACTION_OUTPUT;
}
diff --git a/src/main/java/net/onrc/onos/core/util/IPv6.java b/src/main/java/net/onrc/onos/core/util/IPv6.java
index 986fd11..cd1a192 100644
--- a/src/main/java/net/onrc/onos/core/util/IPv6.java
+++ b/src/main/java/net/onrc/onos/core/util/IPv6.java
@@ -5,7 +5,7 @@
import org.codehaus.jackson.map.annotate.JsonDeserialize;
import org.codehaus.jackson.map.annotate.JsonSerialize;
-import org.openflow.util.HexString;
+import org.projectfloodlight.openflow.util.HexString;
/**
* The class representing an IPv6 address.
diff --git a/src/main/java/org/openflow/protocol/Instantiable.java b/src/main/java/org/openflow/protocol/Instantiable.java
deleted file mode 100644
index 1358ba7..0000000
--- a/src/main/java/org/openflow/protocol/Instantiable.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-/**
- *
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-public interface Instantiable<E> {
-
- /**
- * Create a new instance of a given subclass.
- * @return the new instance.
- */
- public E instantiate();
-}
diff --git a/src/main/java/org/openflow/protocol/OFBarrierReply.java b/src/main/java/org/openflow/protocol/OFBarrierReply.java
deleted file mode 100644
index a79a15f..0000000
--- a/src/main/java/org/openflow/protocol/OFBarrierReply.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-import org.openflow.util.U16;
-
-/**
- * Represents an OFPT_BARRIER_REPLY message
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-public class OFBarrierReply extends OFMessage {
- public OFBarrierReply() {
- super();
- this.type = OFType.BARRIER_REPLY;
- this.length = U16.t(OFMessage.MINIMUM_LENGTH);
- }
-}
diff --git a/src/main/java/org/openflow/protocol/OFBarrierRequest.java b/src/main/java/org/openflow/protocol/OFBarrierRequest.java
deleted file mode 100644
index 9992186..0000000
--- a/src/main/java/org/openflow/protocol/OFBarrierRequest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-import org.openflow.util.U16;
-
-/**
- * Represents an OFPT_BARRIER_REQUEST message
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-public class OFBarrierRequest extends OFMessage {
- public OFBarrierRequest() {
- super();
- this.type = OFType.BARRIER_REQUEST;
- this.length = U16.t(OFMessage.MINIMUM_LENGTH);
- }
-}
diff --git a/src/main/java/org/openflow/protocol/OFEchoReply.java b/src/main/java/org/openflow/protocol/OFEchoReply.java
deleted file mode 100644
index 3e282a7..0000000
--- a/src/main/java/org/openflow/protocol/OFEchoReply.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-import org.openflow.util.U16;
-
-/**
- * Represents an ofp_echo_reply message
- *
- * @author Rob Sherwood (rob.sherwood@stanford.edu)
- */
-
-public class OFEchoReply extends OFEchoRequest {
- public static int MINIMUM_LENGTH = 8;
-
- public OFEchoReply() {
- super();
- this.type = OFType.ECHO_REPLY;
- this.length = U16.t(MINIMUM_LENGTH);
- }
-}
diff --git a/src/main/java/org/openflow/protocol/OFEchoRequest.java b/src/main/java/org/openflow/protocol/OFEchoRequest.java
deleted file mode 100644
index 295a397..0000000
--- a/src/main/java/org/openflow/protocol/OFEchoRequest.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-
-import java.util.Arrays;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.openflow.util.U16;
-
-/**
- * Represents an ofp_echo_request message
- *
- * @author Rob Sherwood (rob.sherwood@stanford.edu)
- */
-
-public class OFEchoRequest extends OFMessage {
- public static int MINIMUM_LENGTH = 8;
- byte[] payload;
-
- public OFEchoRequest() {
- super();
- this.type = OFType.ECHO_REQUEST;
- this.length = U16.t(MINIMUM_LENGTH);
- }
-
- @Override
- public void readFrom(ChannelBuffer bb) {
- super.readFrom(bb);
- int datalen = this.getLengthU() - MINIMUM_LENGTH;
- if (datalen > 0) {
- this.payload = new byte[datalen];
- bb.readBytes(payload);
- }
- }
-
- /**
- * @return the payload
- */
- public byte[] getPayload() {
- return payload;
- }
-
- /**
- * @param payload
- * the payload to set
- */
- public void setPayload(byte[] payload) {
- this.payload = payload;
- }
-
- @Override
- public void writeTo(ChannelBuffer bb) {
- super.writeTo(bb);
- if (payload != null)
- bb.writeBytes(payload);
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = super.hashCode();
- result = prime * result + Arrays.hashCode(payload);
- return result;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (!super.equals(obj))
- return false;
- if (getClass() != obj.getClass())
- return false;
- OFEchoRequest other = (OFEchoRequest) obj;
- if (!Arrays.equals(payload, other.payload))
- return false;
- return true;
- }
-}
diff --git a/src/main/java/org/openflow/protocol/OFError.java b/src/main/java/org/openflow/protocol/OFError.java
deleted file mode 100644
index f936bfb..0000000
--- a/src/main/java/org/openflow/protocol/OFError.java
+++ /dev/null
@@ -1,319 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.openflow.protocol.factory.MessageParseException;
-import org.openflow.protocol.factory.OFMessageFactory;
-import org.openflow.protocol.factory.OFMessageFactoryAware;
-import org.openflow.util.U16;
-
-/**
- * Represents an ofp_error_msg
- *
- * @author David Erickson (daviderickson@cs.stanford.edu)
- * @author Rob Sherwood (rob.sherwood@stanford.edu)
- */
-public class OFError extends OFMessage implements OFMessageFactoryAware {
- public static int MINIMUM_LENGTH = 12;
-
- public enum OFErrorType {
- // OFPET_VENDOR_ERROR is an extension that was added in Open vSwitch and isn't
- // in the OF 1.0 spec, but it was easier to add it here instead of adding
- // generic support for extensible vendor-defined error messages.
- // It uses the random value 0xb0c2 to avoid conflicts with other possible new
- // error types. Support for vendor-defined extended errors has been standardized
- // in the OF 1.2 spec, so this workaround is only needed for 1.0.
- OFPET_HELLO_FAILED, OFPET_BAD_REQUEST, OFPET_BAD_ACTION, OFPET_FLOW_MOD_FAILED, OFPET_PORT_MOD_FAILED, OFPET_QUEUE_OP_FAILED, OFPET_VENDOR_ERROR((short)0xb0c2);
-
- protected short value;
-
- private OFErrorType() {
- this.value = (short) this.ordinal();
- }
-
- private OFErrorType(short value) {
- this.value = value;
- }
-
- public short getValue() {
- return value;
- }
- }
-
- public enum OFHelloFailedCode {
- OFPHFC_INCOMPATIBLE, OFPHFC_EPERM
- }
-
- public enum OFBadRequestCode {
- OFPBRC_BAD_VERSION, OFPBRC_BAD_TYPE, OFPBRC_BAD_STAT, OFPBRC_BAD_VENDOR, OFPBRC_BAD_SUBTYPE, OFPBRC_EPERM, OFPBRC_BAD_LEN, OFPBRC_BUFFER_EMPTY, OFPBRC_BUFFER_UNKNOWN
- }
-
- public enum OFBadActionCode {
- OFPBAC_BAD_TYPE, OFPBAC_BAD_LEN, OFPBAC_BAD_VENDOR, OFPBAC_BAD_VENDOR_TYPE, OFPBAC_BAD_OUT_PORT, OFPBAC_BAD_ARGUMENT, OFPBAC_EPERM, OFPBAC_TOO_MANY, OFPBAC_BAD_QUEUE
- }
-
- public enum OFFlowModFailedCode {
- OFPFMFC_ALL_TABLES_FULL, OFPFMFC_OVERLAP, OFPFMFC_EPERM, OFPFMFC_BAD_EMERG_TIMEOUT, OFPFMFC_BAD_COMMAND, OFPFMFC_UNSUPPORTED
- }
-
- public enum OFPortModFailedCode {
- OFPPMFC_BAD_PORT, OFPPMFC_BAD_HW_ADDR
- }
-
- public enum OFQueueOpFailedCode {
- OFPQOFC_BAD_PORT, OFPQOFC_BAD_QUEUE, OFPQOFC_EPERM
- }
-
- protected short errorType;
- protected short errorCode;
- protected int vendor;
- protected int vendorErrorType;
- protected short vendorErrorCode;
- protected OFMessageFactory factory;
- protected byte[] error;
- protected boolean errorIsAscii;
-
- public OFError() {
- super();
- this.type = OFType.ERROR;
- this.length = U16.t(MINIMUM_LENGTH);
- }
-
- /**
- * @return the errorType
- */
- public short getErrorType() {
- return errorType;
- }
-
- /**
- * @param errorType
- * the errorType to set
- */
- public void setErrorType(short errorType) {
- this.errorType = errorType;
- }
-
- public void setErrorType(OFErrorType type) {
- this.errorType = type.getValue();
- }
-
- /**
- * @return true if the error is an extended vendor error
- */
- public boolean isVendorError() {
- return errorType == OFErrorType.OFPET_VENDOR_ERROR.getValue();
- }
-
- /**
- * @return the errorCode
- */
- public short getErrorCode() {
- return errorCode;
- }
-
- /**
- * @param code
- * the errorCode to set
- */
- public void setErrorCode(OFHelloFailedCode code) {
- this.errorCode = (short) code.ordinal();
- }
-
- public void setErrorCode(short errorCode) {
- this.errorCode = errorCode;
- }
-
- public void setErrorCode(OFBadRequestCode code) {
- this.errorCode = (short) code.ordinal();
- }
-
- public void setErrorCode(OFBadActionCode code) {
- this.errorCode = (short) code.ordinal();
- }
-
- public void setErrorCode(OFFlowModFailedCode code) {
- this.errorCode = (short) code.ordinal();
- }
-
- public void setErrorCode(OFPortModFailedCode code) {
- this.errorCode = (short) code.ordinal();
- }
-
- public void setErrorCode(OFQueueOpFailedCode code) {
- this.errorCode = (short) code.ordinal();
- }
-
- public int getVendorErrorType() {
- return vendorErrorType;
- }
-
- public void setVendorErrorType(int vendorErrorType) {
- this.vendorErrorType = vendorErrorType;
- }
-
- public short getVendorErrorCode() {
- return vendorErrorCode;
- }
-
- public void setVendorErrorCode(short vendorErrorCode) {
- this.vendorErrorCode = vendorErrorCode;
- }
-
- public OFMessage getOffendingMsg() throws MessageParseException {
- // should only have one message embedded; if more than one, just
- // grab first
- if (this.error == null)
- return null;
- ChannelBuffer errorMsg = ChannelBuffers.wrappedBuffer(this.error);
- if (factory == null)
- throw new RuntimeException("MessageFactory not set");
-
- List<OFMessage> msglist = this.factory.parseMessage(errorMsg);
- if (msglist == null)
- return null;
- return msglist.get(0);
- }
-
- /**
- * Write this offending message into the payload of the Error message
- *
- * @param offendingMsg
- */
-
- public void setOffendingMsg(OFMessage offendingMsg) {
- if (offendingMsg == null) {
- super.setLengthU(MINIMUM_LENGTH);
- } else {
- this.error = new byte[offendingMsg.getLengthU()];
- ChannelBuffer data = ChannelBuffers.wrappedBuffer(this.error);
- data.writerIndex(0);
- offendingMsg.writeTo(data);
- super.setLengthU(MINIMUM_LENGTH + offendingMsg.getLengthU());
- }
- }
-
- public OFMessageFactory getFactory() {
- return factory;
- }
-
- @Override
- public void setMessageFactory(OFMessageFactory factory) {
- this.factory = factory;
- }
-
- /**
- * @return the error
- */
- public byte[] getError() {
- return error;
- }
-
- /**
- * @param error
- * the error to set
- */
- public void setError(byte[] error) {
- this.error = error;
- }
-
- /**
- * @return the errorIsAscii
- */
- public boolean isErrorIsAscii() {
- return errorIsAscii;
- }
-
- /**
- * @param errorIsAscii
- * the errorIsAscii to set
- */
- public void setErrorIsAscii(boolean errorIsAscii) {
- this.errorIsAscii = errorIsAscii;
- }
-
- @Override
- public void readFrom(ChannelBuffer data) {
- super.readFrom(data);
- this.errorType = data.readShort();
- this.errorCode = data.readShort();
- int dataLength = this.getLengthU() - MINIMUM_LENGTH;
- if (dataLength > 0) {
- this.error = new byte[dataLength];
- data.readBytes(this.error);
- if (this.errorType == OFErrorType.OFPET_HELLO_FAILED.getValue())
- this.errorIsAscii = true;
- }
- }
-
- @Override
- public void writeTo(ChannelBuffer data) {
- super.writeTo(data);
- data.writeShort(errorType);
- data.writeShort(errorCode);
- if (error != null)
- data.writeBytes(error);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = super.hashCode();
- result = prime * result + Arrays.hashCode(error);
- result = prime * result + errorCode;
- result = prime * result + (errorIsAscii ? 1231 : 1237);
- result = prime * result + errorType;
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (!super.equals(obj))
- return false;
- if (getClass() != obj.getClass())
- return false;
- OFError other = (OFError) obj;
- if (!Arrays.equals(error, other.error))
- return false;
- if (errorCode != other.errorCode)
- return false;
- if (errorIsAscii != other.errorIsAscii)
- return false;
- if (errorType != other.errorType)
- return false;
- return true;
- }
-
-}
diff --git a/src/main/java/org/openflow/protocol/OFFeaturesReply.java b/src/main/java/org/openflow/protocol/OFFeaturesReply.java
deleted file mode 100644
index f5a836e..0000000
--- a/src/main/java/org/openflow/protocol/OFFeaturesReply.java
+++ /dev/null
@@ -1,257 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.openflow.protocol.serializers.OFFeaturesReplyJSONSerializer;
-import org.openflow.util.U16;
-
-
-/**
- * Represents a features reply message
- * @author David Erickson (daviderickson@cs.stanford.edu)
- *
- */
-@JsonSerialize(using=OFFeaturesReplyJSONSerializer.class)
-public class OFFeaturesReply extends OFMessage {
- public static int MINIMUM_LENGTH = 32;
-
- /**
- * Corresponds to bits on the capabilities field
- */
- public enum OFCapabilities {
- OFPC_FLOW_STATS (1 << 0),
- OFPC_TABLE_STATS (1 << 1),
- OFPC_PORT_STATS (1 << 2),
- OFPC_STP (1 << 3),
- OFPC_RESERVED (1 << 4),
- OFPC_IP_REASM (1 << 5),
- OFPC_QUEUE_STATS (1 << 6),
- OFPC_ARP_MATCH_IP (1 << 7);
-
- protected int value;
-
- private OFCapabilities(int value) {
- this.value = value;
- }
-
- /**
- * @return the value
- */
- public int getValue() {
- return value;
- }
- }
-
- protected long datapathId;
- protected int buffers;
- protected byte tables;
- protected int capabilities;
- protected int actions;
- protected List<OFPhysicalPort> ports;
-
- public OFFeaturesReply() {
- super();
- this.type = OFType.FEATURES_REPLY;
- this.length = U16.t(MINIMUM_LENGTH);
- }
-
- /**
- * @return the datapathId
- */
- public long getDatapathId() {
- return datapathId;
- }
-
- /**
- * @param datapathId the datapathId to set
- */
- public void setDatapathId(long datapathId) {
- this.datapathId = datapathId;
- }
-
- /**
- * @return the buffers
- */
- public int getBuffers() {
- return buffers;
- }
-
- /**
- * @param buffers the buffers to set
- */
- public void setBuffers(int buffers) {
- this.buffers = buffers;
- }
-
- /**
- * @return the tables
- */
- public byte getTables() {
- return tables;
- }
-
- /**
- * @param tables the tables to set
- */
- public void setTables(byte tables) {
- this.tables = tables;
- }
-
- /**
- * @return the capabilities
- */
- public int getCapabilities() {
- return capabilities;
- }
-
- /**
- * @param capabilities the capabilities to set
- */
- public void setCapabilities(int capabilities) {
- this.capabilities = capabilities;
- }
-
- /**
- * @return the actions
- */
- public int getActions() {
- return actions;
- }
-
- /**
- * @param actions the actions to set
- */
- public void setActions(int actions) {
- this.actions = actions;
- }
-
- /**
- * @return the ports
- */
- public List<OFPhysicalPort> getPorts() {
- return ports;
- }
-
- /**
- * @param ports the ports to set
- */
- public void setPorts(List<OFPhysicalPort> ports) {
- this.ports = ports;
- if (ports == null) {
- this.setLengthU(MINIMUM_LENGTH);
- } else {
- this.setLengthU(MINIMUM_LENGTH + ports.size()
- * OFPhysicalPort.MINIMUM_LENGTH);
- }
- }
-
- @Override
- public void readFrom(ChannelBuffer data) {
- super.readFrom(data);
- this.datapathId = data.readLong();
- this.buffers = data.readInt();
- this.tables = data.readByte();
- data.readerIndex(data.readerIndex() + 3); // pad
- this.capabilities = data.readInt();
- this.actions = data.readInt();
- if (this.ports == null) {
- this.ports = new ArrayList<OFPhysicalPort>();
- } else {
- this.ports.clear();
- }
- int portCount = (super.getLengthU() - 32)
- / OFPhysicalPort.MINIMUM_LENGTH;
- OFPhysicalPort port;
- for (int i = 0; i < portCount; ++i) {
- port = new OFPhysicalPort();
- port.readFrom(data);
- this.ports.add(port);
- }
- }
-
- @Override
- public void writeTo(ChannelBuffer data) {
- super.writeTo(data);
- data.writeLong(this.datapathId);
- data.writeInt(this.buffers);
- data.writeByte(this.tables);
- data.writeShort((short) 0); // pad
- data.writeByte((byte) 0); // pad
- data.writeInt(this.capabilities);
- data.writeInt(this.actions);
- if (this.ports != null)
- for (OFPhysicalPort port : this.ports) {
- port.writeTo(data);
- }
- }
-
- @Override
- public int hashCode() {
- final int prime = 139;
- int result = super.hashCode();
- result = prime * result + actions;
- result = prime * result + buffers;
- result = prime * result + capabilities;
- result = prime * result + (int) (datapathId ^ (datapathId >>> 32));
- result = prime * result + ((ports == null) ? 0 : ports.hashCode());
- result = prime * result + tables;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (!(obj instanceof OFFeaturesReply)) {
- return false;
- }
- OFFeaturesReply other = (OFFeaturesReply) obj;
- if (actions != other.actions) {
- return false;
- }
- if (buffers != other.buffers) {
- return false;
- }
- if (capabilities != other.capabilities) {
- return false;
- }
- if (datapathId != other.datapathId) {
- return false;
- }
- if (ports == null) {
- if (other.ports != null) {
- return false;
- }
- } else if (!ports.equals(other.ports)) {
- return false;
- }
- if (tables != other.tables) {
- return false;
- }
- return true;
- }
-}
diff --git a/src/main/java/org/openflow/protocol/OFFeaturesRequest.java b/src/main/java/org/openflow/protocol/OFFeaturesRequest.java
deleted file mode 100644
index 0a89e4f..0000000
--- a/src/main/java/org/openflow/protocol/OFFeaturesRequest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-import org.openflow.util.U16;
-
-
-/**
- * Represents a features request message
- * @author David Erickson (daviderickson@cs.stanford.edu)
- *
- */
-public class OFFeaturesRequest extends OFMessage {
- public static int MINIMUM_LENGTH = 8;
-
- public OFFeaturesRequest() {
- super();
- this.type = OFType.FEATURES_REQUEST;
- this.length = U16.t(MINIMUM_LENGTH);
- }
-}
diff --git a/src/main/java/org/openflow/protocol/OFFlowMod.java b/src/main/java/org/openflow/protocol/OFFlowMod.java
deleted file mode 100644
index 0ec8be9..0000000
--- a/src/main/java/org/openflow/protocol/OFFlowMod.java
+++ /dev/null
@@ -1,388 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.openflow.protocol.action.OFAction;
-import org.openflow.protocol.factory.OFActionFactory;
-import org.openflow.protocol.factory.OFActionFactoryAware;
-import org.openflow.util.U16;
-
-/**
- * Represents an ofp_flow_mod message
- * @author David Erickson (daviderickson@cs.stanford.edu)
- *
- */
-public class OFFlowMod extends OFMessage implements OFActionFactoryAware, Cloneable {
- public static int MINIMUM_LENGTH = 72;
-
- public static final short OFPFC_ADD = 0; /* New flow. */
- public static final short OFPFC_MODIFY = 1; /* Modify all matching flows. */
- public static final short OFPFC_MODIFY_STRICT = 2; /* Modify entry strictly matching wildcards */
- public static final short OFPFC_DELETE=3; /* Delete all matching flows. */
- public static final short OFPFC_DELETE_STRICT =4; /* Strictly match wildcards and priority. */
-
- // Open Flow Flow Mod Flags. Use "or" operation to set multiple flags
- public static final short OFPFF_SEND_FLOW_REM = 0x1; // 1 << 0
- public static final short OFPFF_CHECK_OVERLAP = 0x2; // 1 << 1
- public static final short OFPFF_EMERG = 0x4; // 1 << 2
-
- protected OFActionFactory actionFactory;
- protected OFMatch match;
- protected long cookie;
- protected short command;
- protected short idleTimeout;
- protected short hardTimeout;
- protected short priority;
- protected int bufferId;
- protected short outPort;
- protected short flags;
- protected List<OFAction> actions;
-
- public OFFlowMod() {
- super();
- this.type = OFType.FLOW_MOD;
- this.length = U16.t(MINIMUM_LENGTH);
- }
-
- /**
- * Get buffer_id
- * @return
- */
- public int getBufferId() {
- return this.bufferId;
- }
-
- /**
- * Set buffer_id
- * @param bufferId
- */
- public OFFlowMod setBufferId(int bufferId) {
- this.bufferId = bufferId;
- return this;
- }
-
- /**
- * Get cookie
- * @return
- */
- public long getCookie() {
- return this.cookie;
- }
-
- /**
- * Set cookie
- * @param cookie
- */
- public OFFlowMod setCookie(long cookie) {
- this.cookie = cookie;
- return this;
- }
-
- /**
- * Get command
- * @return
- */
- public short getCommand() {
- return this.command;
- }
-
- /**
- * Set command
- * @param command
- */
- public OFFlowMod setCommand(short command) {
- this.command = command;
- return this;
- }
-
- /**
- * Get flags
- * @return
- */
- public short getFlags() {
- return this.flags;
- }
-
- /**
- * Set flags
- * @param flags
- */
- public OFFlowMod setFlags(short flags) {
- this.flags = flags;
- return this;
- }
-
- /**
- * Get hard_timeout
- * @return
- */
- public short getHardTimeout() {
- return this.hardTimeout;
- }
-
- /**
- * Set hard_timeout
- * @param hardTimeout
- */
- public OFFlowMod setHardTimeout(short hardTimeout) {
- this.hardTimeout = hardTimeout;
- return this;
- }
-
- /**
- * Get idle_timeout
- * @return
- */
- public short getIdleTimeout() {
- return this.idleTimeout;
- }
-
- /**
- * Set idle_timeout
- * @param idleTimeout
- */
- public OFFlowMod setIdleTimeout(short idleTimeout) {
- this.idleTimeout = idleTimeout;
- return this;
- }
-
- /**
- * Gets a copy of the OFMatch object for this FlowMod, changes to this
- * object do not modify the FlowMod
- * @return
- */
- public OFMatch getMatch() {
- return this.match;
- }
-
- /**
- * Set match
- * @param match
- */
- public OFFlowMod setMatch(OFMatch match) {
- this.match = match;
- return this;
- }
-
- /**
- * Get out_port
- * @return
- */
- public short getOutPort() {
- return this.outPort;
- }
-
- /**
- * Set out_port
- * @param outPort
- */
- public OFFlowMod setOutPort(short outPort) {
- this.outPort = outPort;
- return this;
- }
-
- /**
- * Set out_port
- * @param port
- */
- public OFFlowMod setOutPort(OFPort port) {
- this.outPort = port.getValue();
- return this;
- }
-
- /**
- * Get priority
- * @return
- */
- public short getPriority() {
- return this.priority;
- }
-
- /**
- * Set priority
- * @param priority
- */
- public OFFlowMod setPriority(short priority) {
- this.priority = priority;
- return this;
- }
-
- /**
- * Returns read-only copies of the actions contained in this Flow Mod
- * @return a list of ordered OFAction objects
- */
- public List<OFAction> getActions() {
- return this.actions;
- }
-
- /**
- * Sets the list of actions this Flow Mod contains
- * @param actions a list of ordered OFAction objects
- */
- public OFFlowMod setActions(List<OFAction> actions) {
- this.actions = actions;
- return this;
- }
-
- @Override
- public void readFrom(ChannelBuffer data) {
- super.readFrom(data);
- if (this.match == null)
- this.match = new OFMatch();
- this.match.readFrom(data);
- this.cookie = data.readLong();
- this.command = data.readShort();
- this.idleTimeout = data.readShort();
- this.hardTimeout = data.readShort();
- this.priority = data.readShort();
- this.bufferId = data.readInt();
- this.outPort = data.readShort();
- this.flags = data.readShort();
- if (this.actionFactory == null)
- throw new RuntimeException("OFActionFactory not set");
- this.actions = this.actionFactory.parseActions(data, getLengthU() -
- MINIMUM_LENGTH);
- }
-
- @Override
- public void writeTo(ChannelBuffer data) {
- super.writeTo(data);
- this.match.writeTo(data);
- data.writeLong(cookie);
- data.writeShort(command);
- data.writeShort(idleTimeout);
- data.writeShort(hardTimeout);
- data.writeShort(priority);
- data.writeInt(bufferId);
- data.writeShort(outPort);
- data.writeShort(flags);
- if (actions != null) {
- for (OFAction action : actions) {
- action.writeTo(data);
- }
- }
- }
-
- @Override
- public void setActionFactory(OFActionFactory actionFactory) {
- this.actionFactory = actionFactory;
- }
-
- @Override
- public int hashCode() {
- final int prime = 227;
- int result = super.hashCode();
- result = prime * result + ((actions == null) ? 0 : actions.hashCode());
- result = prime * result + bufferId;
- result = prime * result + command;
- result = prime * result + (int) (cookie ^ (cookie >>> 32));
- result = prime * result + flags;
- result = prime * result + hardTimeout;
- result = prime * result + idleTimeout;
- result = prime * result + ((match == null) ? 0 : match.hashCode());
- result = prime * result + outPort;
- result = prime * result + priority;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (!(obj instanceof OFFlowMod)) {
- return false;
- }
- OFFlowMod other = (OFFlowMod) obj;
- if (actions == null) {
- if (other.actions != null) {
- return false;
- }
- } else if (!actions.equals(other.actions)) {
- return false;
- }
- if (bufferId != other.bufferId) {
- return false;
- }
- if (command != other.command) {
- return false;
- }
- if (cookie != other.cookie) {
- return false;
- }
- if (flags != other.flags) {
- return false;
- }
- if (hardTimeout != other.hardTimeout) {
- return false;
- }
- if (idleTimeout != other.idleTimeout) {
- return false;
- }
- if (match == null) {
- if (other.match != null) {
- return false;
- }
- } else if (!match.equals(other.match)) {
- return false;
- }
- if (outPort != other.outPort) {
- return false;
- }
- if (priority != other.priority) {
- return false;
- }
- return true;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#clone()
- */
- @Override
- public OFFlowMod clone() throws CloneNotSupportedException {
- OFMatch neoMatch = match.clone();
- OFFlowMod flowMod= (OFFlowMod) super.clone();
- flowMod.setMatch(neoMatch);
- List<OFAction> neoActions = new LinkedList<OFAction>();
- for(OFAction action: this.actions)
- neoActions.add(action.clone());
- flowMod.setActions(neoActions);
- return flowMod;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "OFFlowMod [actionFactory=" + actionFactory + ", actions="
- + actions + ", bufferId=" + bufferId + ", command=" + command
- + ", cookie=" + cookie + ", flags=" + flags + ", hardTimeout="
- + hardTimeout + ", idleTimeout=" + idleTimeout + ", match="
- + match + ", outPort=" + outPort + ", priority=" + priority
- + ", length=" + length + ", type=" + type + ", version="
- + version + ", xid=" + xid + "]";
- }
-}
diff --git a/src/main/java/org/openflow/protocol/OFFlowRemoved.java b/src/main/java/org/openflow/protocol/OFFlowRemoved.java
deleted file mode 100644
index 4f4e0c7..0000000
--- a/src/main/java/org/openflow/protocol/OFFlowRemoved.java
+++ /dev/null
@@ -1,290 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.openflow.util.U16;
-
-/**
- * Represents an ofp_flow_removed message
- * @author David Erickson (daviderickson@cs.stanford.edu)
- *
- */
-public class OFFlowRemoved extends OFMessage {
- public static int MINIMUM_LENGTH = 88;
-
- public enum OFFlowRemovedReason {
- OFPRR_IDLE_TIMEOUT,
- OFPRR_HARD_TIMEOUT,
- OFPRR_DELETE
- }
-
- protected OFMatch match;
- protected long cookie;
- protected short priority;
- protected OFFlowRemovedReason reason;
- protected int durationSeconds;
- protected int durationNanoseconds;
- protected short idleTimeout;
- protected long packetCount;
- protected long byteCount;
-
- public OFFlowRemoved() {
- super();
- this.type = OFType.FLOW_REMOVED;
- this.length = U16.t(MINIMUM_LENGTH);
- }
-
- /**
- * Get cookie
- * @return
- */
- public long getCookie() {
- return this.cookie;
- }
-
- /**
- * Set cookie
- * @param cookie
- */
- public void setCookie(long cookie) {
- this.cookie = cookie;
- }
-
- /**
- * Get idle_timeout
- * @return
- */
- public short getIdleTimeout() {
- return this.idleTimeout;
- }
-
- /**
- * Set idle_timeout
- * @param idleTimeout
- */
- public void setIdleTimeout(short idleTimeout) {
- this.idleTimeout = idleTimeout;
- }
-
- /**
- * Gets a copy of the OFMatch object for this FlowMod, changes to this
- * object do not modify the FlowMod
- * @return
- */
- public OFMatch getMatch() {
- return this.match;
- }
-
- /**
- * Set match
- * @param match
- */
- public void setMatch(OFMatch match) {
- this.match = match;
- }
-
- /**
- * Get priority
- * @return
- */
- public short getPriority() {
- return this.priority;
- }
-
- /**
- * Set priority
- * @param priority
- */
- public void setPriority(short priority) {
- this.priority = priority;
- }
-
- /**
- * @return the reason
- */
- public OFFlowRemovedReason getReason() {
- return reason;
- }
-
- /**
- * @param reason the reason to set
- */
- public void setReason(OFFlowRemovedReason reason) {
- this.reason = reason;
- }
-
- /**
- * @return the durationSeconds
- */
- public int getDurationSeconds() {
- return durationSeconds;
- }
-
- /**
- * @param durationSeconds the durationSeconds to set
- */
- public void setDurationSeconds(int durationSeconds) {
- this.durationSeconds = durationSeconds;
- }
-
- /**
- * @return the durationNanoseconds
- */
- public int getDurationNanoseconds() {
- return durationNanoseconds;
- }
-
- /**
- * @param durationNanoseconds the durationNanoseconds to set
- */
- public void setDurationNanoseconds(int durationNanoseconds) {
- this.durationNanoseconds = durationNanoseconds;
- }
-
- /**
- * @return the packetCount
- */
- public long getPacketCount() {
- return packetCount;
- }
-
- /**
- * @param packetCount the packetCount to set
- */
- public void setPacketCount(long packetCount) {
- this.packetCount = packetCount;
- }
-
- /**
- * @return the byteCount
- */
- public long getByteCount() {
- return byteCount;
- }
-
- /**
- * @param byteCount the byteCount to set
- */
- public void setByteCount(long byteCount) {
- this.byteCount = byteCount;
- }
-
- @Override
- public void readFrom(ChannelBuffer data) {
- super.readFrom(data);
- if (this.match == null)
- this.match = new OFMatch();
- this.match.readFrom(data);
- this.cookie = data.readLong();
- this.priority = data.readShort();
- this.reason = OFFlowRemovedReason.values()[(0xff & data.readByte())];
- data.readByte(); // pad
- this.durationSeconds = data.readInt();
- this.durationNanoseconds = data.readInt();
- this.idleTimeout = data.readShort();
- data.readByte(); // pad
- data.readByte(); // pad
- this.packetCount = data.readLong();
- this.byteCount = data.readLong();
- }
-
- @Override
- public void writeTo(ChannelBuffer data) {
- super.writeTo(data);
- this.match.writeTo(data);
- data.writeLong(cookie);
- data.writeShort(priority);
- data.writeByte((byte) this.reason.ordinal());
- data.writeByte((byte) 0);
- data.writeInt(this.durationSeconds);
- data.writeInt(this.durationNanoseconds);
- data.writeShort(idleTimeout);
- data.writeByte((byte) 0); // pad
- data.writeByte((byte) 0); // pad
- data.writeLong(this.packetCount);
- data.writeLong(this.byteCount);
- }
-
- @Override
- public int hashCode() {
- final int prime = 271;
- int result = super.hashCode();
- result = prime * result + (int) (byteCount ^ (byteCount >>> 32));
- result = prime * result + (int) (cookie ^ (cookie >>> 32));
- result = prime * result + durationNanoseconds;
- result = prime * result + durationSeconds;
- result = prime * result + idleTimeout;
- result = prime * result + ((match == null) ? 0 : match.hashCode());
- result = prime * result + (int) (packetCount ^ (packetCount >>> 32));
- result = prime * result + priority;
- result = prime * result + ((reason == null) ? 0 : reason.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (!(obj instanceof OFFlowRemoved)) {
- return false;
- }
- OFFlowRemoved other = (OFFlowRemoved) obj;
- if (byteCount != other.byteCount) {
- return false;
- }
- if (cookie != other.cookie) {
- return false;
- }
- if (durationNanoseconds != other.durationNanoseconds) {
- return false;
- }
- if (durationSeconds != other.durationSeconds) {
- return false;
- }
- if (idleTimeout != other.idleTimeout) {
- return false;
- }
- if (match == null) {
- if (other.match != null) {
- return false;
- }
- } else if (!match.equals(other.match)) {
- return false;
- }
- if (packetCount != other.packetCount) {
- return false;
- }
- if (priority != other.priority) {
- return false;
- }
- if (reason == null) {
- if (other.reason != null) {
- return false;
- }
- } else if (!reason.equals(other.reason)) {
- return false;
- }
- return true;
- }
-}
diff --git a/src/main/java/org/openflow/protocol/OFGetConfigReply.java b/src/main/java/org/openflow/protocol/OFGetConfigReply.java
deleted file mode 100644
index 257867a..0000000
--- a/src/main/java/org/openflow/protocol/OFGetConfigReply.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-/**
- * Represents an OFPT_GET_CONFIG_REPLY type message
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-public class OFGetConfigReply extends OFSwitchConfig {
- public OFGetConfigReply() {
- super();
- this.type = OFType.GET_CONFIG_REPLY;
- }
-}
diff --git a/src/main/java/org/openflow/protocol/OFGetConfigRequest.java b/src/main/java/org/openflow/protocol/OFGetConfigRequest.java
deleted file mode 100644
index 85c7499..0000000
--- a/src/main/java/org/openflow/protocol/OFGetConfigRequest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-import org.openflow.util.U16;
-
-/**
- * Represents an OFPT_GET_CONFIG_REQUEST type message
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-public class OFGetConfigRequest extends OFMessage {
- public OFGetConfigRequest() {
- super();
- this.type = OFType.GET_CONFIG_REQUEST;
- this.length = U16.t(OFMessage.MINIMUM_LENGTH);
- }
-}
diff --git a/src/main/java/org/openflow/protocol/OFHello.java b/src/main/java/org/openflow/protocol/OFHello.java
deleted file mode 100644
index e702ca4..0000000
--- a/src/main/java/org/openflow/protocol/OFHello.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-import org.openflow.util.U16;
-
-
-/**
- * Represents an ofp_hello message
- *
- * @author David Erickson (daviderickson@cs.stanford.edu) - Feb 8, 2010
- */
-public class OFHello extends OFMessage {
- public static int MINIMUM_LENGTH = 8;
-
- /**
- * Construct a ofp_hello message
- */
- public OFHello() {
- super();
- this.type = OFType.HELLO;
- this.length = U16.t(MINIMUM_LENGTH);
- }
-}
diff --git a/src/main/java/org/openflow/protocol/OFMatch.java b/src/main/java/org/openflow/protocol/OFMatch.java
deleted file mode 100644
index 3faeb73..0000000
--- a/src/main/java/org/openflow/protocol/OFMatch.java
+++ /dev/null
@@ -1,944 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-import java.io.Serializable;
-import java.nio.ByteBuffer;
-import java.util.Arrays;
-
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.openflow.protocol.serializers.OFMatchJSONSerializer;
-import org.openflow.util.HexString;
-import org.openflow.util.U16;
-import org.openflow.util.U8;
-
-/**
- * Represents an ofp_match structure
- *
- * @author David Erickson (daviderickson@cs.stanford.edu)
- * @author Rob Sherwood (rob.sherwood@stanford.edu)
- *
- */
-@JsonSerialize(using=OFMatchJSONSerializer.class)
-public class OFMatch implements Cloneable, Serializable {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- public static int MINIMUM_LENGTH = 40;
- final public static int OFPFW_ALL = ((1 << 22) - 1);
-
- final public static int OFPFW_IN_PORT = 1 << 0; /* Switch input port. */
- final public static int OFPFW_DL_VLAN = 1 << 1; /* VLAN id. */
- final public static int OFPFW_DL_SRC = 1 << 2; /* Ethernet source address. */
- final public static int OFPFW_DL_DST = 1 << 3; /*
- * Ethernet destination
- * address.
- */
- final public static int OFPFW_DL_TYPE = 1 << 4; /* Ethernet frame type. */
- final public static int OFPFW_NW_PROTO = 1 << 5; /* IP protocol. */
- final public static int OFPFW_TP_SRC = 1 << 6; /* TCP/UDP source port. */
- final public static int OFPFW_TP_DST = 1 << 7; /* TCP/UDP destination port. */
-
- /*
- * IP source address wildcard bit count. 0 is exact match, 1 ignores the
- * LSB, 2 ignores the 2 least-significant bits, ..., 32 and higher wildcard
- * the entire field. This is the *opposite* of the usual convention where
- * e.g. /24 indicates that 8 bits (not 24 bits) are wildcarded.
- */
- final public static int OFPFW_NW_SRC_SHIFT = 8;
- final public static int OFPFW_NW_SRC_BITS = 6;
- final public static int OFPFW_NW_SRC_MASK = ((1 << OFPFW_NW_SRC_BITS) - 1) << OFPFW_NW_SRC_SHIFT;
- final public static int OFPFW_NW_SRC_ALL = 32 << OFPFW_NW_SRC_SHIFT;
-
- /* IP destination address wildcard bit count. Same format as source. */
- final public static int OFPFW_NW_DST_SHIFT = 14;
- final public static int OFPFW_NW_DST_BITS = 6;
- final public static int OFPFW_NW_DST_MASK = ((1 << OFPFW_NW_DST_BITS) - 1) << OFPFW_NW_DST_SHIFT;
- final public static int OFPFW_NW_DST_ALL = 32 << OFPFW_NW_DST_SHIFT;
-
- final public static int OFPFW_DL_VLAN_PCP = 1 << 20; /* VLAN priority. */
- final public static int OFPFW_NW_TOS = 1 << 21; /*
- * IP ToS (DSCP field, 6
- * bits).
- */
-
- /* List of Strings for marshalling and unmarshalling to human readable forms */
- final public static String STR_IN_PORT = "in_port";
- final public static String STR_DL_DST = "dl_dst";
- final public static String STR_DL_SRC = "dl_src";
- final public static String STR_DL_TYPE = "dl_type";
- final public static String STR_DL_VLAN = "dl_vlan";
- final public static String STR_DL_VLAN_PCP = "dl_vlan_pcp";
- final public static String STR_NW_DST = "nw_dst";
- final public static String STR_NW_SRC = "nw_src";
- final public static String STR_NW_PROTO = "nw_proto";
- final public static String STR_NW_TOS = "nw_tos";
- final public static String STR_TP_DST = "tp_dst";
- final public static String STR_TP_SRC = "tp_src";
-
- protected int wildcards;
- protected short inputPort;
- protected byte[] dataLayerSource;
- protected byte[] dataLayerDestination;
- protected short dataLayerVirtualLan;
- protected byte dataLayerVirtualLanPriorityCodePoint;
- protected short dataLayerType;
- protected byte networkTypeOfService;
- protected byte networkProtocol;
- protected int networkSource;
- protected int networkDestination;
- protected short transportSource;
- protected short transportDestination;
-
- /**
- * By default, create a OFMatch that matches everything
- *
- * (mostly because it's the least amount of work to make a valid OFMatch)
- */
- public OFMatch() {
- this.wildcards = OFPFW_ALL;
- this.dataLayerDestination = new byte[] {0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
- this.dataLayerSource = new byte[] {0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
- this.dataLayerVirtualLan = -1;
- this.dataLayerVirtualLanPriorityCodePoint = 0;
- this.dataLayerType = 0;
- this.inputPort = 0;
- this.networkProtocol = 0;
- this.networkTypeOfService = 0;
- this.networkSource = 0;
- this.networkDestination = 0;
- this.transportDestination = 0;
- this.transportSource = 0;
- }
-
- /**
- * Get dl_dst
- *
- * @return an arrays of bytes
- */
- public byte[] getDataLayerDestination() {
- return this.dataLayerDestination;
- }
-
- /**
- * Set dl_dst
- *
- * @param dataLayerDestination
- */
- public OFMatch setDataLayerDestination(byte[] dataLayerDestination) {
- this.dataLayerDestination = dataLayerDestination;
- return this;
- }
-
- /**
- * Set dl_dst, but first translate to byte[] using HexString
- *
- * @param mac
- * A colon separated string of 6 pairs of octets, e..g.,
- * "00:17:42:EF:CD:8D"
- */
- public OFMatch setDataLayerDestination(String mac) {
- byte bytes[] = HexString.fromHexString(mac);
- if (bytes.length != 6)
- throw new IllegalArgumentException(
- "expected string with 6 octets, got '" + mac + "'");
- this.dataLayerDestination = bytes;
- return this;
- }
-
- /**
- * Get dl_src
- *
- * @return an array of bytes
- */
- public byte[] getDataLayerSource() {
- return this.dataLayerSource;
- }
-
- /**
- * Set dl_src
- *
- * @param dataLayerSource
- */
- public OFMatch setDataLayerSource(byte[] dataLayerSource) {
- this.dataLayerSource = dataLayerSource;
- return this;
- }
-
- /**
- * Set dl_src, but first translate to byte[] using HexString
- *
- * @param mac
- * A colon separated string of 6 pairs of octets, e..g.,
- * "00:17:42:EF:CD:8D"
- */
- public OFMatch setDataLayerSource(String mac) {
- byte bytes[] = HexString.fromHexString(mac);
- if (bytes.length != 6)
- throw new IllegalArgumentException(
- "expected string with 6 octets, got '" + mac + "'");
- this.dataLayerSource = bytes;
- return this;
- }
-
- /**
- * Get dl_type
- *
- * @return ether_type
- */
- public short getDataLayerType() {
- return this.dataLayerType;
- }
-
- /**
- * Set dl_type
- *
- * @param dataLayerType
- */
- public OFMatch setDataLayerType(short dataLayerType) {
- this.dataLayerType = dataLayerType;
- return this;
- }
-
- /**
- * Get dl_vlan
- *
- * @return vlan tag; VLAN_NONE == no tag
- */
- public short getDataLayerVirtualLan() {
- return this.dataLayerVirtualLan;
- }
-
- /**
- * Set dl_vlan
- *
- * @param dataLayerVirtualLan
- */
- public OFMatch setDataLayerVirtualLan(short dataLayerVirtualLan) {
- this.dataLayerVirtualLan = dataLayerVirtualLan;
- return this;
- }
-
- /**
- * Get dl_vlan_pcp
- *
- * @return
- */
- public byte getDataLayerVirtualLanPriorityCodePoint() {
- return this.dataLayerVirtualLanPriorityCodePoint;
- }
-
- /**
- * Set dl_vlan_pcp
- *
- * @param pcp
- */
- public OFMatch setDataLayerVirtualLanPriorityCodePoint(byte pcp) {
- this.dataLayerVirtualLanPriorityCodePoint = pcp;
- return this;
- }
-
- /**
- * Get in_port
- *
- * @return
- */
- public short getInputPort() {
- return this.inputPort;
- }
-
- /**
- * Set in_port
- *
- * @param inputPort
- */
- public OFMatch setInputPort(short inputPort) {
- this.inputPort = inputPort;
- return this;
- }
-
- /**
- * Get nw_dst
- *
- * @return
- */
- public int getNetworkDestination() {
- return this.networkDestination;
- }
-
- /**
- * Set nw_dst
- *
- * @param networkDestination
- */
- public OFMatch setNetworkDestination(int networkDestination) {
- this.networkDestination = networkDestination;
- return this;
- }
-
- /**
- * Parse this match's wildcard fields and return the number of significant
- * bits in the IP destination field.
- *
- * NOTE: this returns the number of bits that are fixed, i.e., like CIDR,
- * not the number of bits that are free like OpenFlow encodes.
- *
- * @return a number between 0 (matches all IPs) and 63 ( 32>= implies exact
- * match)
- */
- public int getNetworkDestinationMaskLen() {
- return Math
- .max(32 - ((wildcards & OFPFW_NW_DST_MASK) >> OFPFW_NW_DST_SHIFT),
- 0);
- }
-
- /**
- * Parse this match's wildcard fields and return the number of significant
- * bits in the IP destination field.
- *
- * NOTE: this returns the number of bits that are fixed, i.e., like CIDR,
- * not the number of bits that are free like OpenFlow encodes.
- *
- * @return a number between 0 (matches all IPs) and 32 (exact match)
- */
- public int getNetworkSourceMaskLen() {
- return Math
- .max(32 - ((wildcards & OFPFW_NW_SRC_MASK) >> OFPFW_NW_SRC_SHIFT),
- 0);
- }
-
- /**
- * Get nw_proto
- *
- * @return
- */
- public byte getNetworkProtocol() {
- return this.networkProtocol;
- }
-
- /**
- * Set nw_proto
- *
- * @param networkProtocol
- */
- public OFMatch setNetworkProtocol(byte networkProtocol) {
- this.networkProtocol = networkProtocol;
- return this;
- }
-
- /**
- * Get nw_src
- *
- * @return
- */
- public int getNetworkSource() {
- return this.networkSource;
- }
-
- /**
- * Set nw_src
- *
- * @param networkSource
- */
- public OFMatch setNetworkSource(int networkSource) {
- this.networkSource = networkSource;
- return this;
- }
-
- /**
- * Get nw_tos
- * OFMatch stores the ToS bits as top 6-bits, so right shift by 2 bits
- * before returning the value
- *
- * @return : 6-bit DSCP value (0-63)
- */
- public byte getNetworkTypeOfService() {
- return (byte) ((this.networkTypeOfService >> 2) & 0x3f);
- }
-
- /**
- * Set nw_tos
- * OFMatch stores the ToS bits as top 6-bits, so left shift by 2 bits
- * before storing the value
- *
- * @param networkTypeOfService : 6-bit DSCP value (0-63)
- */
- public OFMatch setNetworkTypeOfService(byte networkTypeOfService) {
- this.networkTypeOfService = (byte)(networkTypeOfService << 2);
- return this;
- }
-
-
- /**
- * Get tp_dst
- *
- * @return
- */
- public short getTransportDestination() {
- return this.transportDestination;
- }
-
- /**
- * Set tp_dst
- *
- * @param transportDestination
- */
- public OFMatch setTransportDestination(short transportDestination) {
- this.transportDestination = transportDestination;
- return this;
- }
-
- /**
- * Get tp_src
- *
- * @return
- */
- public short getTransportSource() {
- return this.transportSource;
- }
-
- /**
- * Set tp_src
- *
- * @param transportSource
- */
- public OFMatch setTransportSource(short transportSource) {
- this.transportSource = transportSource;
- return this;
- }
-
- /**
- * Get wildcards
- *
- * @return
- */
- public int getWildcards() {
- return this.wildcards;
- }
-
- /**
- * Set wildcards
- *
- * @param wildcards
- */
- public OFMatch setWildcards(int wildcards) {
- this.wildcards = wildcards;
- return this;
- }
-
- /**
- * Initializes this OFMatch structure with the corresponding data from the
- * specified packet.
- *
- * Must specify the input port, to ensure that this.in_port is set
- * correctly.
- *
- * Specify OFPort.NONE or OFPort.ANY if input port not applicable or
- * available
- *
- * @param packetData
- * The packet's data
- * @param inputPort
- * the port the packet arrived on
- */
- public OFMatch loadFromPacket(byte[] packetData, short inputPort) {
- short scratch;
- int transportOffset = 34;
- ByteBuffer packetDataBB = ByteBuffer.wrap(packetData);
- int limit = packetDataBB.limit();
-
- this.wildcards = 0; // all fields have explicit entries
-
- this.inputPort = inputPort;
-
- if (inputPort == OFPort.OFPP_ALL.getValue())
- this.wildcards |= OFPFW_IN_PORT;
-
- assert (limit >= 14);
- // dl dst
- this.dataLayerDestination = new byte[6];
- packetDataBB.get(this.dataLayerDestination);
- // dl src
- this.dataLayerSource = new byte[6];
- packetDataBB.get(this.dataLayerSource);
- // dl type
- this.dataLayerType = packetDataBB.getShort();
-
- if (getDataLayerType() != (short) 0x8100) { // need cast to avoid signed
- // bug
- setDataLayerVirtualLan((short) 0xffff);
- setDataLayerVirtualLanPriorityCodePoint((byte) 0);
- } else {
- // has vlan tag
- scratch = packetDataBB.getShort();
- setDataLayerVirtualLan((short) (0xfff & scratch));
- setDataLayerVirtualLanPriorityCodePoint((byte) ((0xe000 & scratch) >> 13));
- this.dataLayerType = packetDataBB.getShort();
- }
-
- switch (getDataLayerType()) {
- case 0x0800:
- // ipv4
- // check packet length
- scratch = packetDataBB.get();
- scratch = (short) (0xf & scratch);
- transportOffset = (packetDataBB.position() - 1) + (scratch * 4);
- // nw tos (dscp)
- scratch = packetDataBB.get();
- setNetworkTypeOfService((byte) ((0xfc & scratch) >> 2));
- // nw protocol
- packetDataBB.position(packetDataBB.position() + 7);
- this.networkProtocol = packetDataBB.get();
- // nw src
- packetDataBB.position(packetDataBB.position() + 2);
- this.networkSource = packetDataBB.getInt();
- // nw dst
- this.networkDestination = packetDataBB.getInt();
- packetDataBB.position(transportOffset);
- break;
- case 0x0806:
- // arp
- int arpPos = packetDataBB.position();
- // opcode
- scratch = packetDataBB.getShort(arpPos + 6);
- setNetworkProtocol((byte) (0xff & scratch));
-
- scratch = packetDataBB.getShort(arpPos + 2);
- // if ipv4 and addr len is 4
- if (scratch == 0x800 && packetDataBB.get(arpPos + 5) == 4) {
- // nw src
- this.networkSource = packetDataBB.getInt(arpPos + 14);
- // nw dst
- this.networkDestination = packetDataBB.getInt(arpPos + 24);
- } else {
- setNetworkSource(0);
- setNetworkDestination(0);
- }
- break;
- default:
- setNetworkTypeOfService((byte) 0);
- setNetworkProtocol((byte) 0);
- setNetworkSource(0);
- setNetworkDestination(0);
- break;
- }
-
- switch (getNetworkProtocol()) {
- case 0x01:
- // icmp
- // type
- this.transportSource = U8.f(packetDataBB.get());
- // code
- this.transportDestination = U8.f(packetDataBB.get());
- break;
- case 0x06:
- // tcp
- // tcp src
- this.transportSource = packetDataBB.getShort();
- // tcp dest
- this.transportDestination = packetDataBB.getShort();
- break;
- case 0x11:
- // udp
- // udp src
- this.transportSource = packetDataBB.getShort();
- // udp dest
- this.transportDestination = packetDataBB.getShort();
- break;
- default:
- setTransportDestination((short) 0);
- setTransportSource((short) 0);
- break;
- }
- return this;
- }
-
- /**
- * Read this message off the wire from the specified ByteBuffer
- *
- * @param data
- */
- public void readFrom(ChannelBuffer data) {
- this.wildcards = data.readInt();
- this.inputPort = data.readShort();
- this.dataLayerSource = new byte[6];
- data.readBytes(this.dataLayerSource);
- this.dataLayerDestination = new byte[6];
- data.readBytes(this.dataLayerDestination);
- this.dataLayerVirtualLan = data.readShort();
- this.dataLayerVirtualLanPriorityCodePoint = data.readByte();
- data.readByte(); // pad
- this.dataLayerType = data.readShort();
- this.networkTypeOfService = data.readByte();
- this.networkProtocol = data.readByte();
- data.readByte(); // pad
- data.readByte(); // pad
- this.networkSource = data.readInt();
- this.networkDestination = data.readInt();
- this.transportSource = data.readShort();
- this.transportDestination = data.readShort();
- }
-
- /**
- * Write this message's binary format to the specified ByteBuffer
- *
- * @param data
- */
- public void writeTo(ChannelBuffer data) {
- data.writeInt(wildcards);
- data.writeShort(inputPort);
- data.writeBytes(this.dataLayerSource);
- data.writeBytes(this.dataLayerDestination);
- data.writeShort(dataLayerVirtualLan);
- data.writeByte(dataLayerVirtualLanPriorityCodePoint);
- data.writeByte((byte) 0x0); // pad
- data.writeShort(dataLayerType);
- data.writeByte(networkTypeOfService);
- data.writeByte(networkProtocol);
- data.writeByte((byte) 0x0); // pad
- data.writeByte((byte) 0x0); // pad
- data.writeInt(networkSource);
- data.writeInt(networkDestination);
- data.writeShort(transportSource);
- data.writeShort(transportDestination);
- }
-
- @Override
- public int hashCode() {
- final int prime = 131;
- int result = 1;
- result = prime * result + Arrays.hashCode(dataLayerDestination);
- result = prime * result + Arrays.hashCode(dataLayerSource);
- result = prime * result + dataLayerType;
- result = prime * result + dataLayerVirtualLan;
- result = prime * result + dataLayerVirtualLanPriorityCodePoint;
- result = prime * result + inputPort;
- result = prime * result + networkDestination;
- result = prime * result + networkProtocol;
- result = prime * result + networkSource;
- result = prime * result + networkTypeOfService;
- result = prime * result + transportDestination;
- result = prime * result + transportSource;
- result = prime * result + wildcards;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof OFMatch)) {
- return false;
- }
- OFMatch other = (OFMatch) obj;
- if (!Arrays.equals(dataLayerDestination, other.dataLayerDestination)) {
- return false;
- }
- if (!Arrays.equals(dataLayerSource, other.dataLayerSource)) {
- return false;
- }
- if (dataLayerType != other.dataLayerType) {
- return false;
- }
- if (dataLayerVirtualLan != other.dataLayerVirtualLan) {
- return false;
- }
- if (dataLayerVirtualLanPriorityCodePoint != other.dataLayerVirtualLanPriorityCodePoint) {
- return false;
- }
- if (inputPort != other.inputPort) {
- return false;
- }
- if (networkDestination != other.networkDestination) {
- return false;
- }
- if (networkProtocol != other.networkProtocol) {
- return false;
- }
- if (networkSource != other.networkSource) {
- return false;
- }
- if (networkTypeOfService != other.networkTypeOfService) {
- return false;
- }
- if (transportDestination != other.transportDestination) {
- return false;
- }
- if (transportSource != other.transportSource) {
- return false;
- }
- if ((wildcards & OFMatch.OFPFW_ALL) != (other.wildcards & OFPFW_ALL)) { // only
- // consider
- // allocated
- // part
- // of
- // wildcards
- return false;
- }
- return true;
- }
-
- /**
- * Implement clonable interface
- */
- @Override
- public OFMatch clone() {
- try {
- OFMatch ret = (OFMatch) super.clone();
- ret.dataLayerDestination = this.dataLayerDestination.clone();
- ret.dataLayerSource = this.dataLayerSource.clone();
- return ret;
- } catch (CloneNotSupportedException e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * Output a dpctl-styled string, i.e., only list the elements that are not
- * wildcarded
- *
- * A match-everything OFMatch outputs "OFMatch[]"
- *
- * @return
- * "OFMatch[dl_src:00:20:01:11:22:33,nw_src:192.168.0.0/24,tp_dst:80]"
- */
- @Override
- public String toString() {
- String str = "";
-
- // l1
- if ((wildcards & OFPFW_IN_PORT) == 0)
- str += "," + STR_IN_PORT + "=" + U16.f(this.inputPort);
-
- // l2
- if ((wildcards & OFPFW_DL_DST) == 0)
- str += "," + STR_DL_DST + "="
- + HexString.toHexString(this.dataLayerDestination);
- if ((wildcards & OFPFW_DL_SRC) == 0)
- str += "," + STR_DL_SRC + "="
- + HexString.toHexString(this.dataLayerSource);
- if ((wildcards & OFPFW_DL_TYPE) == 0)
- str += "," + STR_DL_TYPE + "=0x"
- + Integer.toHexString(U16.f(this.dataLayerType));
- if ((wildcards & OFPFW_DL_VLAN) == 0)
- str += "," + STR_DL_VLAN + "=0x"
- + Integer.toHexString(U16.f(this.dataLayerVirtualLan));
- if ((wildcards & OFPFW_DL_VLAN_PCP) == 0)
- str += ","
- + STR_DL_VLAN_PCP
- + "="
- + Integer.toHexString(U8
- .f(this.dataLayerVirtualLanPriorityCodePoint));
-
- // l3
- if (getNetworkDestinationMaskLen() > 0)
- str += ","
- + STR_NW_DST
- + "="
- + cidrToString(networkDestination,
- getNetworkDestinationMaskLen());
- if (getNetworkSourceMaskLen() > 0)
- str += "," + STR_NW_SRC + "="
- + cidrToString(networkSource, getNetworkSourceMaskLen());
- if ((wildcards & OFPFW_NW_PROTO) == 0)
- str += "," + STR_NW_PROTO + "=" + this.networkProtocol;
- if ((wildcards & OFPFW_NW_TOS) == 0)
- str += "," + STR_NW_TOS + "=" + this.getNetworkTypeOfService();
-
- // l4
- if ((wildcards & OFPFW_TP_DST) == 0)
- str += "," + STR_TP_DST + "=" + this.transportDestination;
- if ((wildcards & OFPFW_TP_SRC) == 0)
- str += "," + STR_TP_SRC + "=" + this.transportSource;
- if ((str.length() > 0) && (str.charAt(0) == ','))
- str = str.substring(1); // trim the leading ","
- // done
- return "OFMatch[" + str + "]";
- }
-
- private String cidrToString(int ip, int prefix) {
- String str;
- if (prefix >= 32) {
- str = ipToString(ip);
- } else {
- // use the negation of mask to fake endian magic
- int mask = ~((1 << (32 - prefix)) - 1);
- str = ipToString(ip & mask) + "/" + prefix;
- }
-
- return str;
- }
-
- /**
- * Set this OFMatch's parameters based on a comma-separated key=value pair
- * dpctl-style string, e.g., from the output of OFMatch.toString() <br>
- * <p>
- * Supported keys/values include <br>
- * <p>
- * <TABLE border=1>
- * <TR>
- * <TD>KEY(s)
- * <TD>VALUE
- * </TR>
- * <TR>
- * <TD>"in_port","input_port"
- * <TD>integer
- * </TR>
- * <TR>
- * <TD>"dl_src","eth_src", "dl_dst","eth_dst"
- * <TD>hex-string
- * </TR>
- * <TR>
- * <TD>"dl_type", "dl_vlan", "dl_vlan_pcp"
- * <TD>integer
- * </TR>
- * <TR>
- * <TD>"nw_src", "nw_dst", "ip_src", "ip_dst"
- * <TD>CIDR-style netmask
- * </TR>
- * <TR>
- * <TD>"tp_src","tp_dst"
- * <TD>integer (max 64k)
- * </TR>
- * </TABLE>
- * <p>
- * The CIDR-style netmasks assume 32 netmask if none given, so:
- * "128.8.128.118/32" is the same as "128.8.128.118"
- *
- * @param match
- * a key=value comma separated string, e.g.
- * "in_port=5,ip_dst=192.168.0.0/16,tp_src=80"
- * @throws IllegalArgumentException
- * on unexpected key or value
- */
-
- public void fromString(String match) throws IllegalArgumentException {
- if (match.equals("") || match.equalsIgnoreCase("any")
- || match.equalsIgnoreCase("all") || match.equals("[]"))
- match = "OFMatch[]";
- String[] tokens = match.split("[\\[,\\]]");
- String[] values;
- int initArg = 0;
- if (tokens[0].equals("OFMatch"))
- initArg = 1;
- this.wildcards = OFPFW_ALL;
- int i;
- for (i = initArg; i < tokens.length; i++) {
- values = tokens[i].split("=");
- if (values.length != 2)
- throw new IllegalArgumentException("Token " + tokens[i]
- + " does not have form 'key=value' parsing " + match);
- values[0] = values[0].toLowerCase(); // try to make this case insens
- if (values[0].equals(STR_IN_PORT) || values[0].equals("input_port")) {
- this.inputPort = U16.t(Integer.valueOf(values[1]));
- this.wildcards &= ~OFPFW_IN_PORT;
- } else if (values[0].equals(STR_DL_DST) || values[0].equals("eth_dst")) {
- this.dataLayerDestination = HexString.fromHexString(values[1]);
- this.wildcards &= ~OFPFW_DL_DST;
- } else if (values[0].equals(STR_DL_SRC) || values[0].equals("eth_src")) {
- this.dataLayerSource = HexString.fromHexString(values[1]);
- this.wildcards &= ~OFPFW_DL_SRC;
- } else if (values[0].equals(STR_DL_TYPE) || values[0].equals("eth_type")) {
- if (values[1].startsWith("0x"))
- this.dataLayerType = U16.t(Integer.valueOf(
- values[1].replaceFirst("0x", ""), 16));
- else
- this.dataLayerType = U16.t(Integer.valueOf(values[1]));
- this.wildcards &= ~OFPFW_DL_TYPE;
- } else if (values[0].equals(STR_DL_VLAN)) {
- if (values[1].startsWith("0x"))
- this.dataLayerVirtualLan = U16.t(Integer.valueOf(
- values[1].replaceFirst("0x", ""),16));
- else
- this.dataLayerVirtualLan = U16.t(Integer.valueOf(values[1]));
- this.wildcards &= ~OFPFW_DL_VLAN;
- } else if (values[0].equals(STR_DL_VLAN_PCP)) {
- this.dataLayerVirtualLanPriorityCodePoint = U8.t(Short
- .valueOf(values[1]));
- this.wildcards &= ~OFPFW_DL_VLAN_PCP;
- } else if (values[0].equals(STR_NW_DST) || values[0].equals("ip_dst")) {
- setFromCIDR(values[1], STR_NW_DST);
- } else if (values[0].equals(STR_NW_SRC) || values[0].equals("ip_src")) {
- setFromCIDR(values[1], STR_NW_SRC);
- } else if (values[0].equals(STR_NW_PROTO)) {
- this.networkProtocol = U8.t(Short.valueOf(values[1]));
- this.wildcards &= ~OFPFW_NW_PROTO;
- } else if (values[0].equals(STR_NW_TOS)) {
- this.setNetworkTypeOfService(U8.t(Short.valueOf(values[1])));
- this.wildcards &= ~OFPFW_NW_TOS;
- } else if (values[0].equals(STR_TP_DST)) {
- this.transportDestination = U16.t(Integer.valueOf(values[1]));
- this.wildcards &= ~OFPFW_TP_DST;
- } else if (values[0].equals(STR_TP_SRC)) {
- this.transportSource = U16.t(Integer.valueOf(values[1]));
- this.wildcards &= ~OFPFW_TP_SRC;
- } else {
- throw new IllegalArgumentException("unknown token " + tokens[i]
- + " parsing " + match);
- }
- }
- }
-
- /**
- * Set the networkSource or networkDestionation address and their wildcards
- * from the CIDR string
- *
- * @param cidr
- * "192.168.0.0/16" or "172.16.1.5"
- * @param which
- * one of STR_NW_DST or STR_NW_SRC
- * @throws IllegalArgumentException
- */
- public void setFromCIDR(String cidr, String which)
- throws IllegalArgumentException {
- String values[] = cidr.split("/");
- String[] ip_str = values[0].split("\\.");
- int ip = 0;
- ip += Integer.valueOf(ip_str[0]) << 24;
- ip += Integer.valueOf(ip_str[1]) << 16;
- ip += Integer.valueOf(ip_str[2]) << 8;
- ip += Integer.valueOf(ip_str[3]);
- int prefix = 32; // all bits are fixed, by default
-
- if (values.length >= 2)
- prefix = Integer.valueOf(values[1]);
- int mask = 32 - prefix;
- if (which.equals(STR_NW_DST)) {
- this.networkDestination = ip;
- this.wildcards = (wildcards & ~OFPFW_NW_DST_MASK)
- | (mask << OFPFW_NW_DST_SHIFT);
- } else if (which.equals(STR_NW_SRC)) {
- this.networkSource = ip;
- this.wildcards = (wildcards & ~OFPFW_NW_SRC_MASK)
- | (mask << OFPFW_NW_SRC_SHIFT);
- }
- }
-
- protected static String ipToString(int ip) {
- return Integer.toString(U8.f((byte) ((ip & 0xff000000) >> 24))) + "."
- + Integer.toString((ip & 0x00ff0000) >> 16) + "."
- + Integer.toString((ip & 0x0000ff00) >> 8) + "."
- + Integer.toString(ip & 0x000000ff);
- }
-}
diff --git a/src/main/java/org/openflow/protocol/OFMatchBeanInfo.java b/src/main/java/org/openflow/protocol/OFMatchBeanInfo.java
deleted file mode 100644
index 5309ce0..0000000
--- a/src/main/java/org/openflow/protocol/OFMatchBeanInfo.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-import java.beans.IntrospectionException;
-import java.beans.PropertyDescriptor;
-import java.beans.SimpleBeanInfo;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * Extra info for how to treat OFMatch as a JavaBean
- *
- * For some (inane!) reason, using chained setters in OFMatch breaks a lot of the JavaBean defaults.
- *
- * We don't really use OFMatch as a java bean, but there are a lot of nice XML utils that work for
- * free if OFMatch follows the java bean paradigm.
- *
- * @author Rob Sherwood (rob.sherwood@stanford.edu)
- *
- */
-@SuppressWarnings("rawtypes")
-public class OFMatchBeanInfo extends SimpleBeanInfo {
-
- @Override
- public PropertyDescriptor[] getPropertyDescriptors() {
- List<PropertyDescriptor> descs = new LinkedList<PropertyDescriptor>();
- Field[] fields = OFMatch.class.getDeclaredFields();
- String name;
- for (int i=0; i< fields.length; i++) {
- int mod = fields[i].getModifiers();
- if(Modifier.isFinal(mod) || // don't expose static or final fields
- Modifier.isStatic(mod))
- continue;
-
- name = fields[i].getName();
- Class<?> type = fields[i].getType();
-
- try {
- descs.add(new PropertyDescriptor(name,
- name2getter(OFMatch.class, name),
- name2setter(OFMatch.class, name, type)));
- } catch (IntrospectionException e) {
- e.printStackTrace();
- throw new RuntimeException(e);
- }
- }
-
- return descs.toArray(new PropertyDescriptor[0]);
- }
-
-
- private Method name2setter(Class<OFMatch> c, String name, Class<?> type) {
- String mName = "set" + toLeadingCaps(name);
- Method m = null;
- try {
- m = c.getMethod(mName, new Class[]{ type});
- } catch (SecurityException e) {
- e.printStackTrace();
- throw new RuntimeException(e);
- } catch (NoSuchMethodException e) {
- e.printStackTrace();
- throw new RuntimeException(e);
- }
- return m;
- }
-
- private Method name2getter(Class<OFMatch> c, String name) {
- String mName= "get" + toLeadingCaps(name);
- Method m = null;
- try {
- m = c.getMethod(mName, new Class[]{});
- } catch (SecurityException e) {
- e.printStackTrace();
- throw new RuntimeException(e);
- } catch (NoSuchMethodException e) {
- e.printStackTrace();
- throw new RuntimeException(e);
- }
- return m;
- }
-
- private String toLeadingCaps(String s) {
- char[] array = s.toCharArray();
- array[0] = Character.toUpperCase(array[0]);
- return String.valueOf(array, 0, array.length);
- }
-}
diff --git a/src/main/java/org/openflow/protocol/OFMatchWithSwDpid.java b/src/main/java/org/openflow/protocol/OFMatchWithSwDpid.java
deleted file mode 100644
index 052a652..0000000
--- a/src/main/java/org/openflow/protocol/OFMatchWithSwDpid.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package org.openflow.protocol;
-
-import org.openflow.util.HexString;
-
-public class OFMatchWithSwDpid {
- protected OFMatch ofMatch;
- protected long switchDataPathId;
-
- public OFMatchWithSwDpid() {
- this.ofMatch = new OFMatch();
- this.switchDataPathId = 0;
- }
-
- public OFMatchWithSwDpid(OFMatch ofm, long swDpid) {
- this.ofMatch = ofm.clone();
- this.switchDataPathId = swDpid;
- }
- public OFMatch getOfMatch() {
- return ofMatch;
- }
-
- public void setOfMatch(OFMatch ofMatch) {
- this.ofMatch = ofMatch.clone();
- }
-
- public long getSwitchDataPathId() {
- return this.switchDataPathId;
- }
-
- public OFMatchWithSwDpid setSwitchDataPathId(long dpid) {
- this.switchDataPathId = dpid;
- return this;
- }
-
- @Override
- public String toString() {
- return "OFMatchWithSwDpid [" + HexString.toHexString(switchDataPathId) + ofMatch + "]";
- }
-}
diff --git a/src/main/java/org/openflow/protocol/OFMessage.java b/src/main/java/org/openflow/protocol/OFMessage.java
deleted file mode 100644
index 578e95b..0000000
--- a/src/main/java/org/openflow/protocol/OFMessage.java
+++ /dev/null
@@ -1,334 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.concurrent.ConcurrentHashMap;
-
-import net.floodlightcontroller.core.FloodlightContext;
-import net.floodlightcontroller.core.IFloodlightProviderService;
-import net.floodlightcontroller.core.IOFSwitch;
-import net.onrc.onos.core.packet.Ethernet;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.openflow.util.HexString;
-import org.openflow.util.U16;
-import org.openflow.util.U32;
-import org.openflow.util.U8;
-
-/**
- * The base class for all OpenFlow protocol messages. This class contains the
- * equivalent of the ofp_header which is present in all OpenFlow messages.
- *
- * @author David Erickson (daviderickson@cs.stanford.edu) - Feb 3, 2010
- * @author Rob Sherwood (rob.sherwood@stanford.edu) - Feb 3, 2010
- */
-public class OFMessage {
- public static byte OFP_VERSION = 0x01;
- public static int MINIMUM_LENGTH = 8;
-
- protected byte version;
- protected OFType type;
- protected short length;
- protected int xid;
-
- private ConcurrentHashMap<String, Object> storage;
-
- public OFMessage() {
- storage = null;
- this.version = OFP_VERSION;
- }
-
- protected synchronized ConcurrentHashMap<String, Object> getMessageStore() {
- if (storage == null) {
- storage = new ConcurrentHashMap<String, Object>();
- }
- return storage;
- }
-
- /**
- * Get the length of this message
- *
- * @return
- */
- public short getLength() {
- return length;
- }
-
- /**
- * Get the length of this message, unsigned
- *
- * @return
- */
- public int getLengthU() {
- return U16.f(length);
- }
-
- /**
- * Set the length of this message
- *
- * @param length
- */
- public OFMessage setLength(short length) {
- this.length = length;
- return this;
- }
-
- /**
- * Set the length of this message, unsigned
- *
- * @param length
- */
- public OFMessage setLengthU(int length) {
- this.length = U16.t(length);
- return this;
- }
-
- /**
- * Get the type of this message
- *
- * @return
- */
- public OFType getType() {
- return type;
- }
-
- /**
- * Set the type of this message
- *
- * @param type
- */
- public void setType(OFType type) {
- this.type = type;
- }
-
- /**
- * Get the OpenFlow version of this message
- *
- * @return
- */
- public byte getVersion() {
- return version;
- }
-
- /**
- * Set the OpenFlow version of this message
- *
- * @param version
- */
- public void setVersion(byte version) {
- this.version = version;
- }
-
- /**
- * Get the transaction id of this message
- *
- * @return
- */
- public int getXid() {
- return xid;
- }
-
- /**
- * Set the transaction id of this message
- *
- * @param xid
- */
- public void setXid(int xid) {
- this.xid = xid;
- }
-
- /**
- * Read this message off the wire from the specified ByteBuffer
- * @param data
- */
- public void readFrom(ChannelBuffer data) {
- this.version = data.readByte();
- this.type = OFType.valueOf(data.readByte());
- this.length = data.readShort();
- this.xid = data.readInt();
- }
-
- /**
- * Write this message's binary format to the specified ByteBuffer
- * @param data
- */
- public void writeTo(ChannelBuffer data) {
- data.writeByte(version);
- data.writeByte(type.getTypeValue());
- data.writeShort(length);
- data.writeInt(xid);
- }
-
- /**
- * Returns a summary of the message
- * @return "ofmsg=v=$version;t=$type:l=$len:xid=$xid"
- */
- public String toString() {
- return "ofmsg" +
- ":v=" + U8.f(this.getVersion()) +
- ";t=" + this.getType() +
- ";l=" + this.getLengthU() +
- ";x=" + U32.f(this.getXid());
- }
-
- @Override
- public int hashCode() {
- final int prime = 97;
- int result = 1;
- result = prime * result + length;
- result = prime * result + ((type == null) ? 0 : type.hashCode());
- result = prime * result + version;
- result = prime * result + xid;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof OFMessage)) {
- return false;
- }
- OFMessage other = (OFMessage) obj;
- if (length != other.length) {
- return false;
- }
- if (type == null) {
- if (other.type != null) {
- return false;
- }
- } else if (!type.equals(other.type)) {
- return false;
- }
- if (version != other.version) {
- return false;
- }
- if (xid != other.xid) {
- return false;
- }
- return true;
- }
-
- public static String getDataAsString(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
-
- Ethernet eth;
- StringBuffer sb = new StringBuffer("");
-
- DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss.SSS");
- Date date = new Date();
-
- sb.append(dateFormat.format(date));
- sb.append(" ");
-
- switch (msg.getType()) {
- case PACKET_IN:
- OFPacketIn pktIn = (OFPacketIn) msg;
- sb.append("packet_in [ ");
- sb.append(sw.getStringId());
- sb.append(" -> Controller");
- sb.append(" ]");
-
- sb.append("\ntotal length: ");
- sb.append(pktIn.getTotalLength());
- sb.append("\nin_port: ");
- sb.append(pktIn.getInPort());
- sb.append("\ndata_length: ");
- sb.append(pktIn.getTotalLength() - OFPacketIn.MINIMUM_LENGTH);
- sb.append("\nbuffer: ");
- sb.append(pktIn.getBufferId());
-
- // If the conext is not set by floodlight, then ignore.
- if (cntx != null) {
- // packet type icmp, arp, etc.
- eth = IFloodlightProviderService.bcStore.get(cntx,
- IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
- if (eth != null)
- sb.append(eth.toString());
- }
- break;
-
- case PACKET_OUT:
- OFPacketOut pktOut = (OFPacketOut) msg;
- sb.append("packet_out [ ");
- sb.append("Controller -> ");
- sb.append(HexString.toHexString(sw.getId()));
- sb.append(" ]");
-
- sb.append("\nin_port: ");
- sb.append(pktOut.getInPort());
- sb.append("\nactions_len: ");
- sb.append(pktOut.getActionsLength());
- if (pktOut.getActions() != null) {
- sb.append("\nactions: ");
- sb.append(pktOut.getActions().toString());
- }
- break;
-
- case FLOW_MOD:
- OFFlowMod fm = (OFFlowMod) msg;
- sb.append("flow_mod [ ");
- sb.append("Controller -> ");
- sb.append(HexString.toHexString(sw.getId()));
- sb.append(" ]");
-
- // If the conext is not set by floodlight, then ignore.
- if (cntx != null) {
- eth = IFloodlightProviderService.bcStore.get(cntx,
- IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
- if (eth != null)
- sb.append(eth.toString());
- }
-
- sb.append("\nADD: cookie: ");
- sb.append(fm.getCookie());
- sb.append(" idle: ");
- sb.append(fm.getIdleTimeout());
- sb.append(" hard: ");
- sb.append(fm.getHardTimeout());
- sb.append(" pri: ");
- sb.append(fm.getPriority());
- sb.append(" buf: ");
- sb.append(fm.getBufferId());
- sb.append(" flg: ");
- sb.append(fm.getFlags());
- if (fm.getActions() != null) {
- sb.append("\nactions: ");
- sb.append(fm.getActions().toString());
- }
- break;
-
- default:
- sb.append("[Unknown Packet]");
- }
-
- sb.append("\n\n");
- return sb.toString();
-
- }
-
- public static byte[] getData(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
- return OFMessage.getDataAsString(sw, msg, cntx).getBytes();
- }
-}
diff --git a/src/main/java/org/openflow/protocol/OFMessageContextStore.java b/src/main/java/org/openflow/protocol/OFMessageContextStore.java
deleted file mode 100644
index c326320..0000000
--- a/src/main/java/org/openflow/protocol/OFMessageContextStore.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-
-public class OFMessageContextStore<V> {
- protected OFMessage msg;
- String namespace;
-
- public OFMessageContextStore(OFMessage msg, String namespace) {
- this.msg = msg;
- this.namespace = namespace;
- }
-
- @SuppressWarnings("unchecked")
- public V get(String key) {
- return (V)msg.getMessageStore().get(namespace + "|" + key);
- }
-
- public void put(String key, V value) {
- msg.getMessageStore().put(namespace + "|" + key, value);
- }
-}
diff --git a/src/main/java/org/openflow/protocol/OFPacketIn.java b/src/main/java/org/openflow/protocol/OFPacketIn.java
deleted file mode 100644
index c37c918..0000000
--- a/src/main/java/org/openflow/protocol/OFPacketIn.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-import java.util.Arrays;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.openflow.util.U16;
-import org.openflow.util.U32;
-import org.openflow.util.U8;
-
-/**
- * Represents an ofp_packet_in
- *
- * @author David Erickson (daviderickson@cs.stanford.edu) - Feb 8, 2010
- */
-public class OFPacketIn extends OFMessage {
- public static short MINIMUM_LENGTH = 18;
-
- public enum OFPacketInReason {
- NO_MATCH, ACTION
- }
-
- protected int bufferId;
- protected short totalLength;
- protected short inPort;
- protected OFPacketInReason reason;
- protected byte[] packetData;
-
- public OFPacketIn() {
- super();
- this.type = OFType.PACKET_IN;
- this.length = U16.t(MINIMUM_LENGTH);
- }
-
- /**
- * Get buffer_id
- * @return
- */
- public int getBufferId() {
- return this.bufferId;
- }
-
- /**
- * Set buffer_id
- * @param bufferId
- */
- public OFPacketIn setBufferId(int bufferId) {
- this.bufferId = bufferId;
- return this;
- }
-
- /**
- * Returns the packet data
- * @return
- */
- public byte[] getPacketData() {
- return this.packetData;
- }
-
- /**
- * Sets the packet data, and updates the length of this message
- * @param packetData
- */
- public OFPacketIn setPacketData(byte[] packetData) {
- this.packetData = packetData;
- this.length = U16.t(OFPacketIn.MINIMUM_LENGTH + packetData.length);
- return this;
- }
-
- /**
- * Get in_port
- * @return
- */
- public short getInPort() {
- return this.inPort;
- }
-
- /**
- * Set in_port
- * @param inPort
- */
- public OFPacketIn setInPort(short inPort) {
- this.inPort = inPort;
- return this;
- }
-
- /**
- * Get reason
- * @return
- */
- public OFPacketInReason getReason() {
- return this.reason;
- }
-
- /**
- * Set reason
- * @param reason
- */
- public OFPacketIn setReason(OFPacketInReason reason) {
- this.reason = reason;
- return this;
- }
-
- /**
- * Get total_len
- * @return
- */
- public short getTotalLength() {
- return this.totalLength;
- }
-
- /**
- * Set total_len
- * @param totalLength
- */
- public OFPacketIn setTotalLength(short totalLength) {
- this.totalLength = totalLength;
- return this;
- }
-
- @Override
- public void readFrom(ChannelBuffer data) {
- super.readFrom(data);
- this.bufferId = data.readInt();
- this.totalLength = data.readShort();
- this.inPort = data.readShort();
- this.reason = OFPacketInReason.values()[U8.f(data.readByte())];
- data.readByte(); // pad
- this.packetData = new byte[getLengthU() - MINIMUM_LENGTH];
- data.readBytes(this.packetData);
- }
-
- @Override
- public void writeTo(ChannelBuffer data) {
- super.writeTo(data);
- data.writeInt(bufferId);
- data.writeShort(totalLength);
- data.writeShort(inPort);
- data.writeByte((byte) reason.ordinal());
- data.writeByte((byte) 0x0); // pad
- data.writeBytes(this.packetData);
- }
-
- @Override
- public int hashCode() {
- final int prime = 283;
- int result = super.hashCode();
- result = prime * result + bufferId;
- result = prime * result + inPort;
- result = prime * result + Arrays.hashCode(packetData);
- result = prime * result + ((reason == null) ? 0 : reason.hashCode());
- result = prime * result + totalLength;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (!(obj instanceof OFPacketIn)) {
- return false;
- }
- OFPacketIn other = (OFPacketIn) obj;
- if (bufferId != other.bufferId) {
- return false;
- }
- if (inPort != other.inPort) {
- return false;
- }
- if (!Arrays.equals(packetData, other.packetData)) {
- return false;
- }
- if (reason == null) {
- if (other.reason != null) {
- return false;
- }
- } else if (!reason.equals(other.reason)) {
- return false;
- }
- if (totalLength != other.totalLength) {
- return false;
- }
- return true;
- }
-
- public String toString() {
- String myStr = super.toString();
- return "packetIn" +
- ":bufferId=" + U32.f(this.bufferId) + myStr;
- }
-}
diff --git a/src/main/java/org/openflow/protocol/OFPacketOut.java b/src/main/java/org/openflow/protocol/OFPacketOut.java
deleted file mode 100644
index 2b45e8a..0000000
--- a/src/main/java/org/openflow/protocol/OFPacketOut.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.openflow.protocol.action.OFAction;
-import org.openflow.protocol.factory.OFActionFactory;
-import org.openflow.protocol.factory.OFActionFactoryAware;
-import org.openflow.util.U16;
-
-/**
- * Represents an ofp_packet_out message
- *
- * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 12, 2010
- */
-public class OFPacketOut extends OFMessage implements OFActionFactoryAware {
- public static int MINIMUM_LENGTH = 16;
- public static int BUFFER_ID_NONE = 0xffffffff;
-
- protected OFActionFactory actionFactory;
- protected int bufferId;
- protected short inPort;
- protected short actionsLength;
- protected List<OFAction> actions;
- protected byte[] packetData;
-
- public OFPacketOut() {
- super();
- this.type = OFType.PACKET_OUT;
- this.length = U16.t(MINIMUM_LENGTH);
- }
-
- /**
- * Get buffer_id
- * @return
- */
- public int getBufferId() {
- return this.bufferId;
- }
-
- /**
- * Set buffer_id
- * @param bufferId
- */
- public OFPacketOut setBufferId(int bufferId) {
- this.bufferId = bufferId;
- return this;
- }
-
- /**
- * Returns the packet data
- * @return
- */
- public byte[] getPacketData() {
- return this.packetData;
- }
-
- /**
- * Sets the packet data
- * @param packetData
- */
- public OFPacketOut setPacketData(byte[] packetData) {
- this.packetData = packetData;
- return this;
- }
-
- /**
- * Get in_port
- * @return
- */
- public short getInPort() {
- return this.inPort;
- }
-
- /**
- * Set in_port
- * @param inPort
- */
- public OFPacketOut setInPort(short inPort) {
- this.inPort = inPort;
- return this;
- }
-
- /**
- * Set in_port. Convenience method using OFPort enum.
- * @param inPort
- */
- public OFPacketOut setInPort(OFPort inPort) {
- this.inPort = inPort.getValue();
- return this;
- }
-
- /**
- * Get actions_len
- * @return
- */
- public short getActionsLength() {
- return this.actionsLength;
- }
-
- /**
- * Get actions_len, unsigned
- * @return
- */
- public int getActionsLengthU() {
- return U16.f(this.actionsLength);
- }
-
- /**
- * Set actions_len
- * @param actionsLength
- */
- public OFPacketOut setActionsLength(short actionsLength) {
- this.actionsLength = actionsLength;
- return this;
- }
-
- /**
- * Returns the actions contained in this message
- * @return a list of ordered OFAction objects
- */
- public List<OFAction> getActions() {
- return this.actions;
- }
-
- /**
- * Sets the list of actions on this message
- * @param actions a list of ordered OFAction objects
- */
- public OFPacketOut setActions(List<OFAction> actions) {
- this.actions = actions;
- return this;
- }
-
- @Override
- public void setActionFactory(OFActionFactory actionFactory) {
- this.actionFactory = actionFactory;
- }
-
- @Override
- public void readFrom(ChannelBuffer data) {
- super.readFrom(data);
- this.bufferId = data.readInt();
- this.inPort = data.readShort();
- this.actionsLength = data.readShort();
- if ( this.actionFactory == null)
- throw new RuntimeException("ActionFactory not set");
- this.actions = this.actionFactory.parseActions(data, getActionsLengthU());
- this.packetData = new byte[getLengthU() - MINIMUM_LENGTH - getActionsLengthU()];
- data.readBytes(this.packetData);
- }
-
- @Override
- public void writeTo(ChannelBuffer data) {
- super.writeTo(data);
- data.writeInt(bufferId);
- data.writeShort(inPort);
- data.writeShort(actionsLength);
- for (OFAction action : actions) {
- action.writeTo(data);
- }
- if (this.packetData != null)
- data.writeBytes(this.packetData);
- }
-
- @Override
- public int hashCode() {
- final int prime = 293;
- int result = super.hashCode();
- result = prime * result + ((actions == null) ? 0 : actions.hashCode());
- result = prime * result + actionsLength;
- result = prime * result + bufferId;
- result = prime * result + inPort;
- result = prime * result + Arrays.hashCode(packetData);
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (!(obj instanceof OFPacketOut)) {
- return false;
- }
- OFPacketOut other = (OFPacketOut) obj;
- if (actions == null) {
- if (other.actions != null) {
- return false;
- }
- } else if (!actions.equals(other.actions)) {
- return false;
- }
- if (actionsLength != other.actionsLength) {
- return false;
- }
- if (bufferId != other.bufferId) {
- return false;
- }
- if (inPort != other.inPort) {
- return false;
- }
- if (!Arrays.equals(packetData, other.packetData)) {
- return false;
- }
- return true;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "OFPacketOut [actionFactory=" + actionFactory + ", actions="
- + actions + ", actionsLength=" + actionsLength + ", bufferId=0x"
- + Integer.toHexString(bufferId) + ", inPort=" + inPort + ", packetData="
- + Arrays.toString(packetData) + "]";
- }
-}
diff --git a/src/main/java/org/openflow/protocol/OFPhysicalPort.java b/src/main/java/org/openflow/protocol/OFPhysicalPort.java
deleted file mode 100644
index 58fdae5..0000000
--- a/src/main/java/org/openflow/protocol/OFPhysicalPort.java
+++ /dev/null
@@ -1,470 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-import java.io.UnsupportedEncodingException;
-import java.nio.charset.Charset;
-import java.util.Arrays;
-
-import net.floodlightcontroller.core.web.serializers.ByteArrayMACSerializer;
-import net.floodlightcontroller.core.web.serializers.UShortSerializer;
-
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-import org.jboss.netty.buffer.ChannelBuffer;
-
-/**
- * Represents ofp_phy_port
- * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 25, 2010
- */
-public class OFPhysicalPort {
- public static int MINIMUM_LENGTH = 48;
- public static int OFP_ETH_ALEN = 6;
-
- public enum OFPortConfig {
- OFPPC_PORT_DOWN (1 << 0) {
- public String toString() {
- return "port-down (0x1)";
- }
- },
- OFPPC_NO_STP (1 << 1) {
- public String toString() {
- return "no-stp (0x2)";
- }
- },
- OFPPC_NO_RECV (1 << 2) {
- public String toString() {
- return "no-recv (0x4)";
- }
- },
- OFPPC_NO_RECV_STP (1 << 3) {
- public String toString() {
- return "no-recv-stp (0x8)";
- }
- },
- OFPPC_NO_FLOOD (1 << 4) {
- public String toString() {
- return "no-flood (0x10)";
- }
- },
- OFPPC_NO_FWD (1 << 5) {
- public String toString() {
- return "no-fwd (0x20)";
- }
- },
- OFPPC_NO_PACKET_IN (1 << 6) {
- public String toString() {
- return "no-pkt-in (0x40)";
- }
- };
-
- protected int value;
-
- private OFPortConfig(int value) {
- this.value = value;
- }
-
- /**
- * @return the value
- */
- public int getValue() {
- return value;
- }
- }
-
- public enum OFPortState {
- OFPPS_LINK_DOWN (1 << 0) {
- public String toString() {
- return "link-down (0x1)";
- }
- },
- OFPPS_STP_LISTEN (0 << 8) {
- public String toString() {
- return "listen (0x0)";
- }
- },
- OFPPS_STP_LEARN (1 << 8) {
- public String toString() {
- return "learn-no-relay (0x100)";
- }
- },
- OFPPS_STP_FORWARD (2 << 8) {
- public String toString() {
- return "forward (0x200)";
- }
- },
- OFPPS_STP_BLOCK (3 << 8) {
- public String toString() {
- return "block-broadcast (0x300)";
- }
- },
- OFPPS_STP_MASK (3 << 8) {
- public String toString() {
- return "block-broadcast (0x300)";
- }
- };
-
- protected int value;
-
- private OFPortState(int value) {
- this.value = value;
- }
-
- /**
- * @return the value
- */
- public int getValue() {
- return value;
- }
- }
-
- public enum OFPortFeatures {
- OFPPF_10MB_HD (1 << 0) {
- public String toString() {
- return "10mb-hd (0x1)";
- }
- },
- OFPPF_10MB_FD (1 << 1) {
- public String toString() {
- return "10mb-fd (0x2)";
- }
- },
- OFPPF_100MB_HD (1 << 2) {
- public String toString() {
- return "100mb-hd (0x4)";
- }
- },
- OFPPF_100MB_FD (1 << 3) {
- public String toString() {
- return "100mb-fd (0x8)";
- }
- },
- OFPPF_1GB_HD (1 << 4) {
- public String toString() {
- return "1gb-hd (0x10)";
- }
- },
- OFPPF_1GB_FD (1 << 5) {
- public String toString() {
- return "1gb-fd (0x20)";
- }
- },
- OFPPF_10GB_FD (1 << 6) {
- public String toString() {
- return "10gb-fd (0x40)";
- }
- },
- OFPPF_COPPER (1 << 7) {
- public String toString() {
- return "copper (0x80)";
- }
- },
- OFPPF_FIBER (1 << 8) {
- public String toString() {
- return "fiber (0x100)";
- }
- },
- OFPPF_AUTONEG (1 << 9) {
- public String toString() {
- return "autoneg (0x200)";
- }
- },
- OFPPF_PAUSE (1 << 10) {
- public String toString() {
- return "pause (0x400)";
- }
- },
- OFPPF_PAUSE_ASYM (1 << 11) {
- public String toString() {
- return "pause-asym (0x800)";
- }
- };
-
- protected int value;
-
- private OFPortFeatures(int value) {
- this.value = value;
- }
-
- /**
- * @return the value
- */
- public int getValue() {
- return value;
- }
- }
-
- protected short portNumber;
- protected byte[] hardwareAddress;
- protected String name;
- protected int config;
- protected int state;
- protected int currentFeatures;
- protected int advertisedFeatures;
- protected int supportedFeatures;
- protected int peerFeatures;
-
- /**
- * @return the portNumber
- */
- @JsonSerialize(using=UShortSerializer.class)
- public short getPortNumber() {
- return portNumber;
- }
-
- /**
- * @param portNumber the portNumber to set
- */
- public void setPortNumber(short portNumber) {
- this.portNumber = portNumber;
- }
-
- /**
- * @return the hardwareAddress
- */
- @JsonSerialize(using=ByteArrayMACSerializer.class)
- public byte[] getHardwareAddress() {
- return hardwareAddress;
- }
-
- /**
- * @param hardwareAddress the hardwareAddress to set
- */
- public void setHardwareAddress(byte[] hardwareAddress) {
- if (hardwareAddress.length != OFP_ETH_ALEN)
- throw new RuntimeException("Hardware address must have length "
- + OFP_ETH_ALEN);
- this.hardwareAddress = hardwareAddress;
- }
-
- /**
- * @return the name
- */
- public String getName() {
- return name;
- }
-
- /**
- * @param name the name to set
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * @return the config
- */
- public int getConfig() {
- return config;
- }
-
- /**
- * @param config the config to set
- */
- public void setConfig(int config) {
- this.config = config;
- }
-
- /**
- * @return the state
- */
- public int getState() {
- return state;
- }
-
- /**
- * @param state the state to set
- */
- public void setState(int state) {
- this.state = state;
- }
-
- /**
- * @return the currentFeatures
- */
- public int getCurrentFeatures() {
- return currentFeatures;
- }
-
- /**
- * @param currentFeatures the currentFeatures to set
- */
- public void setCurrentFeatures(int currentFeatures) {
- this.currentFeatures = currentFeatures;
- }
-
- /**
- * @return the advertisedFeatures
- */
- public int getAdvertisedFeatures() {
- return advertisedFeatures;
- }
-
- /**
- * @param advertisedFeatures the advertisedFeatures to set
- */
- public void setAdvertisedFeatures(int advertisedFeatures) {
- this.advertisedFeatures = advertisedFeatures;
- }
-
- /**
- * @return the supportedFeatures
- */
- public int getSupportedFeatures() {
- return supportedFeatures;
- }
-
- /**
- * @param supportedFeatures the supportedFeatures to set
- */
- public void setSupportedFeatures(int supportedFeatures) {
- this.supportedFeatures = supportedFeatures;
- }
-
- /**
- * @return the peerFeatures
- */
- public int getPeerFeatures() {
- return peerFeatures;
- }
-
- /**
- * @param peerFeatures the peerFeatures to set
- */
- public void setPeerFeatures(int peerFeatures) {
- this.peerFeatures = peerFeatures;
- }
-
- /**
- * Read this message off the wire from the specified ByteBuffer
- * @param data
- */
- public void readFrom(ChannelBuffer data) {
- this.portNumber = data.readShort();
- if (this.hardwareAddress == null)
- this.hardwareAddress = new byte[OFP_ETH_ALEN];
- data.readBytes(this.hardwareAddress);
- byte[] name = new byte[16];
- data.readBytes(name);
- // find the first index of 0
- int index = 0;
- for (byte b : name) {
- if (0 == b)
- break;
- ++index;
- }
- this.name = new String(Arrays.copyOf(name, index),
- Charset.forName("ascii"));
- this.config = data.readInt();
- this.state = data.readInt();
- this.currentFeatures = data.readInt();
- this.advertisedFeatures = data.readInt();
- this.supportedFeatures = data.readInt();
- this.peerFeatures = data.readInt();
- }
-
- /**
- * Write this message's binary format to the specified ByteBuffer
- * @param data
- */
- public void writeTo(ChannelBuffer data) {
- data.writeShort(this.portNumber);
- data.writeBytes(hardwareAddress);
- try {
- byte[] name = this.name.getBytes("ASCII");
- if (name.length < 16) {
- data.writeBytes(name);
- for (int i = name.length; i < 16; ++i) {
- data.writeByte((byte) 0);
- }
- } else {
- data.writeBytes(name, 0, 15);
- data.writeByte((byte) 0);
- }
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException(e);
- }
- data.writeInt(this.config);
- data.writeInt(this.state);
- data.writeInt(this.currentFeatures);
- data.writeInt(this.advertisedFeatures);
- data.writeInt(this.supportedFeatures);
- data.writeInt(this.peerFeatures);
- }
-
- @Override
- public int hashCode() {
- final int prime = 307;
- int result = 1;
- result = prime * result + advertisedFeatures;
- result = prime * result + config;
- result = prime * result + currentFeatures;
- result = prime * result + Arrays.hashCode(hardwareAddress);
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- result = prime * result + peerFeatures;
- result = prime * result + portNumber;
- result = prime * result + state;
- result = prime * result + supportedFeatures;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof OFPhysicalPort)) {
- return false;
- }
- OFPhysicalPort other = (OFPhysicalPort) obj;
- if (advertisedFeatures != other.advertisedFeatures) {
- return false;
- }
- if (config != other.config) {
- return false;
- }
- if (currentFeatures != other.currentFeatures) {
- return false;
- }
- if (!Arrays.equals(hardwareAddress, other.hardwareAddress)) {
- return false;
- }
- if (name == null) {
- if (other.name != null) {
- return false;
- }
- } else if (!name.equals(other.name)) {
- return false;
- }
- if (peerFeatures != other.peerFeatures) {
- return false;
- }
- if (portNumber != other.portNumber) {
- return false;
- }
- if (state != other.state) {
- return false;
- }
- if (supportedFeatures != other.supportedFeatures) {
- return false;
- }
- return true;
- }
-}
diff --git a/src/main/java/org/openflow/protocol/OFPort.java b/src/main/java/org/openflow/protocol/OFPort.java
deleted file mode 100644
index 93301bc..0000000
--- a/src/main/java/org/openflow/protocol/OFPort.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-public enum OFPort {
- OFPP_MAX ((short)0xff00),
- OFPP_IN_PORT ((short)0xfff8),
- OFPP_TABLE ((short)0xfff9),
- OFPP_NORMAL ((short)0xfffa),
- OFPP_FLOOD ((short)0xfffb),
- OFPP_ALL ((short)0xfffc),
- OFPP_CONTROLLER ((short)0xfffd),
- OFPP_LOCAL ((short)0xfffe),
- OFPP_NONE ((short)0xffff);
-
- protected short value;
-
- private OFPort(short value) {
- this.value = value;
- }
-
- /**
- * @return the value
- */
- public short getValue() {
- return value;
- }
-}
diff --git a/src/main/java/org/openflow/protocol/OFPortMod.java b/src/main/java/org/openflow/protocol/OFPortMod.java
deleted file mode 100644
index 876e856..0000000
--- a/src/main/java/org/openflow/protocol/OFPortMod.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-import java.util.Arrays;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.openflow.util.U16;
-
-/**
- * Represents an ofp_port_mod message
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-public class OFPortMod extends OFMessage {
- public static int MINIMUM_LENGTH = 32;
-
- protected short portNumber;
- protected byte[] hardwareAddress;
- protected int config;
- protected int mask;
- protected int advertise;
-
- public OFPortMod() {
- super();
- this.type = OFType.PORT_MOD;
- this.length = U16.t(MINIMUM_LENGTH);
- }
-
- /**
- * @return the portNumber
- */
- public short getPortNumber() {
- return portNumber;
- }
-
- /**
- * @param portNumber the portNumber to set
- */
- public void setPortNumber(short portNumber) {
- this.portNumber = portNumber;
- }
-
- /**
- * @return the hardwareAddress
- */
- public byte[] getHardwareAddress() {
- return hardwareAddress;
- }
-
- /**
- * @param hardwareAddress the hardwareAddress to set
- */
- public void setHardwareAddress(byte[] hardwareAddress) {
- if (hardwareAddress.length != OFPhysicalPort.OFP_ETH_ALEN)
- throw new RuntimeException("Hardware address must have length "
- + OFPhysicalPort.OFP_ETH_ALEN);
- this.hardwareAddress = hardwareAddress;
- }
-
- /**
- * @return the config
- */
- public int getConfig() {
- return config;
- }
-
- /**
- * @param config the config to set
- */
- public void setConfig(int config) {
- this.config = config;
- }
-
- /**
- * @return the mask
- */
- public int getMask() {
- return mask;
- }
-
- /**
- * @param mask the mask to set
- */
- public void setMask(int mask) {
- this.mask = mask;
- }
-
- /**
- * @return the advertise
- */
- public int getAdvertise() {
- return advertise;
- }
-
- /**
- * @param advertise the advertise to set
- */
- public void setAdvertise(int advertise) {
- this.advertise = advertise;
- }
-
- @Override
- public void readFrom(ChannelBuffer data) {
- super.readFrom(data);
- this.portNumber = data.readShort();
- if (this.hardwareAddress == null)
- this.hardwareAddress = new byte[OFPhysicalPort.OFP_ETH_ALEN];
- data.readBytes(this.hardwareAddress);
- this.config = data.readInt();
- this.mask = data.readInt();
- this.advertise = data.readInt();
- data.readInt(); // pad
- }
-
- @Override
- public void writeTo(ChannelBuffer data) {
- super.writeTo(data);
- data.writeShort(this.portNumber);
- data.writeBytes(this.hardwareAddress);
- data.writeInt(this.config);
- data.writeInt(this.mask);
- data.writeInt(this.advertise);
- data.writeInt(0); // pad
- }
-
- @Override
- public int hashCode() {
- final int prime = 311;
- int result = super.hashCode();
- result = prime * result + advertise;
- result = prime * result + config;
- result = prime * result + Arrays.hashCode(hardwareAddress);
- result = prime * result + mask;
- result = prime * result + portNumber;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (!(obj instanceof OFPortMod)) {
- return false;
- }
- OFPortMod other = (OFPortMod) obj;
- if (advertise != other.advertise) {
- return false;
- }
- if (config != other.config) {
- return false;
- }
- if (!Arrays.equals(hardwareAddress, other.hardwareAddress)) {
- return false;
- }
- if (mask != other.mask) {
- return false;
- }
- if (portNumber != other.portNumber) {
- return false;
- }
- return true;
- }
-}
diff --git a/src/main/java/org/openflow/protocol/OFPortStatus.java b/src/main/java/org/openflow/protocol/OFPortStatus.java
deleted file mode 100644
index 8bde6e7..0000000
--- a/src/main/java/org/openflow/protocol/OFPortStatus.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.openflow.util.U16;
-
-/**
- * Represents an ofp_port_status message
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-public class OFPortStatus extends OFMessage {
- public static int MINIMUM_LENGTH = 64;
-
- public enum OFPortReason {
- OFPPR_ADD,
- OFPPR_DELETE,
- OFPPR_MODIFY
- }
-
- protected byte reason;
- protected OFPhysicalPort desc;
-
- /**
- * @return the reason
- */
- public byte getReason() {
- return reason;
- }
-
- /**
- * @param reason the reason to set
- */
- public void setReason(byte reason) {
- this.reason = reason;
- }
-
- /**
- * @return the desc
- */
- public OFPhysicalPort getDesc() {
- return desc;
- }
-
- /**
- * @param desc the desc to set
- */
- public void setDesc(OFPhysicalPort desc) {
- this.desc = desc;
- }
-
- public OFPortStatus() {
- super();
- this.type = OFType.PORT_STATUS;
- this.length = U16.t(MINIMUM_LENGTH);
- }
-
- @Override
- public void readFrom(ChannelBuffer data) {
- super.readFrom(data);
- this.reason = data.readByte();
- data.readerIndex(data.readerIndex() + 7); // skip 7 bytes of padding
- if (this.desc == null)
- this.desc = new OFPhysicalPort();
- this.desc.readFrom(data);
- }
-
- @Override
- public void writeTo(ChannelBuffer data) {
- super.writeTo(data);
- data.writeByte(this.reason);
- for (int i = 0; i < 7; ++i)
- data.writeByte((byte) 0);
- this.desc.writeTo(data);
- }
-
- @Override
- public int hashCode() {
- final int prime = 313;
- int result = super.hashCode();
- result = prime * result + ((desc == null) ? 0 : desc.hashCode());
- result = prime * result + reason;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (!(obj instanceof OFPortStatus)) {
- return false;
- }
- OFPortStatus other = (OFPortStatus) obj;
- if (desc == null) {
- if (other.desc != null) {
- return false;
- }
- } else if (!desc.equals(other.desc)) {
- return false;
- }
- if (reason != other.reason) {
- return false;
- }
- return true;
- }
-}
diff --git a/src/main/java/org/openflow/protocol/OFSetConfig.java b/src/main/java/org/openflow/protocol/OFSetConfig.java
deleted file mode 100644
index 4b23564..0000000
--- a/src/main/java/org/openflow/protocol/OFSetConfig.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-/**
- * Represents an OFPT_SET_CONFIG type message
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-public class OFSetConfig extends OFSwitchConfig {
- public OFSetConfig() {
- super();
- this.type = OFType.SET_CONFIG;
- }
-}
diff --git a/src/main/java/org/openflow/protocol/OFStatisticsMessageBase.java b/src/main/java/org/openflow/protocol/OFStatisticsMessageBase.java
deleted file mode 100644
index cf6ace3..0000000
--- a/src/main/java/org/openflow/protocol/OFStatisticsMessageBase.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-import java.util.List;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.openflow.protocol.factory.OFStatisticsFactory;
-import org.openflow.protocol.factory.OFStatisticsFactoryAware;
-import org.openflow.protocol.statistics.OFStatistics;
-import org.openflow.protocol.statistics.OFStatisticsType;
-
-
-/**
- * Base class for statistics requests/replies
- *
- * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 27, 2010
- */
-public abstract class OFStatisticsMessageBase extends OFMessage implements
- OFStatisticsFactoryAware {
- public static int MINIMUM_LENGTH = 12;
-
- protected OFStatisticsFactory statisticsFactory;
- protected OFStatisticsType statisticType;
- protected short flags;
- protected List<OFStatistics> statistics;
-
- /**
- * @return the statisticType
- */
- public OFStatisticsType getStatisticType() {
- return statisticType;
- }
-
- /**
- * @param statisticType the statisticType to set
- */
- public void setStatisticType(OFStatisticsType statisticType) {
- this.statisticType = statisticType;
- }
-
- /**
- * @return the flags
- */
- public short getFlags() {
- return flags;
- }
-
- /**
- * @param flags the flags to set
- */
- public void setFlags(short flags) {
- this.flags = flags;
- }
-
- /**
- * @return the statistics
- */
- public List<OFStatistics> getStatistics() {
- return statistics;
- }
-
- /**
- * @param statistics the statistics to set
- */
- public void setStatistics(List<OFStatistics> statistics) {
- this.statistics = statistics;
- }
-
- @Override
- public void setStatisticsFactory(OFStatisticsFactory statisticsFactory) {
- this.statisticsFactory = statisticsFactory;
- }
-
- @Override
- public void readFrom(ChannelBuffer data) {
- super.readFrom(data);
- this.statisticType = OFStatisticsType.valueOf(data.readShort(), this
- .getType());
- this.flags = data.readShort();
- if (this.statisticsFactory == null)
- throw new RuntimeException("OFStatisticsFactory not set");
- this.statistics = statisticsFactory.parseStatistics(this.getType(),
- this.statisticType, data, super.getLengthU() - MINIMUM_LENGTH);
- }
-
- @Override
- public void writeTo(ChannelBuffer data) {
- super.writeTo(data);
- data.writeShort(this.statisticType.getTypeValue());
- data.writeShort(this.flags);
- if (this.statistics != null) {
- for (OFStatistics statistic : this.statistics) {
- statistic.writeTo(data);
- }
- }
- }
-
- @Override
- public int hashCode() {
- final int prime = 317;
- int result = super.hashCode();
- result = prime * result + flags;
- result = prime * result
- + ((statisticType == null) ? 0 : statisticType.hashCode());
- result = prime * result
- + ((statistics == null) ? 0 : statistics.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (!(obj instanceof OFStatisticsMessageBase)) {
- return false;
- }
- OFStatisticsMessageBase other = (OFStatisticsMessageBase) obj;
- if (flags != other.flags) {
- return false;
- }
- if (statisticType == null) {
- if (other.statisticType != null) {
- return false;
- }
- } else if (!statisticType.equals(other.statisticType)) {
- return false;
- }
- if (statistics == null) {
- if (other.statistics != null) {
- return false;
- }
- } else if (!statistics.equals(other.statistics)) {
- return false;
- }
- return true;
- }
-}
diff --git a/src/main/java/org/openflow/protocol/OFStatisticsReply.java b/src/main/java/org/openflow/protocol/OFStatisticsReply.java
deleted file mode 100644
index ddc7267..0000000
--- a/src/main/java/org/openflow/protocol/OFStatisticsReply.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-import org.openflow.util.U16;
-
-/**
- * Represents an ofp_stats_reply message
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-public class OFStatisticsReply extends OFStatisticsMessageBase {
- public enum OFStatisticsReplyFlags {
- REPLY_MORE (1 << 0);
-
- protected short type;
-
- OFStatisticsReplyFlags(int type) {
- this.type = (short) type;
- }
-
- public short getTypeValue() {
- return type;
- }
- }
-
- public OFStatisticsReply() {
- super();
- this.type = OFType.STATS_REPLY;
- this.length = U16.t(OFStatisticsMessageBase.MINIMUM_LENGTH);
- }
-}
diff --git a/src/main/java/org/openflow/protocol/OFStatisticsRequest.java b/src/main/java/org/openflow/protocol/OFStatisticsRequest.java
deleted file mode 100644
index d1d8010..0000000
--- a/src/main/java/org/openflow/protocol/OFStatisticsRequest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-import org.openflow.util.U16;
-
-/**
- * Represents an ofp_stats_request message
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-public class OFStatisticsRequest extends OFStatisticsMessageBase {
- public OFStatisticsRequest() {
- super();
- this.type = OFType.STATS_REQUEST;
- this.length = U16.t(OFStatisticsMessageBase.MINIMUM_LENGTH);
- }
-}
diff --git a/src/main/java/org/openflow/protocol/OFSwitchConfig.java b/src/main/java/org/openflow/protocol/OFSwitchConfig.java
deleted file mode 100644
index e04e3fa..0000000
--- a/src/main/java/org/openflow/protocol/OFSwitchConfig.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-
-import org.jboss.netty.buffer.ChannelBuffer;
-
-/**
- * Base class representing ofp_switch_config based messages
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-public abstract class OFSwitchConfig extends OFMessage {
- public static int MINIMUM_LENGTH = 12;
-
- public enum OFConfigFlags {
- OFPC_FRAG_NORMAL,
- OFPC_FRAG_DROP,
- OFPC_FRAG_REASM,
- OFPC_FRAG_MASK
- }
-
- protected short flags;
- protected short missSendLength;
-
- public OFSwitchConfig() {
- super();
- super.setLengthU(MINIMUM_LENGTH);
- }
-
- /**
- * @return the flags
- */
- public short getFlags() {
- return flags;
- }
-
- /**
- * @param flags the flags to set
- */
- public OFSwitchConfig setFlags(short flags) {
- this.flags = flags;
- return this;
- }
-
- /**
- * @return the missSendLength
- */
- public short getMissSendLength() {
- return missSendLength;
- }
-
- /**
- * @param missSendLength the missSendLength to set
- */
- public OFSwitchConfig setMissSendLength(short missSendLength) {
- this.missSendLength = missSendLength;
- return this;
- }
-
- @Override
- public void readFrom(ChannelBuffer data) {
- super.readFrom(data);
- this.flags = data.readShort();
- this.missSendLength = data.readShort();
- }
-
- @Override
- public void writeTo(ChannelBuffer data) {
- super.writeTo(data);
- data.writeShort(this.flags);
- data.writeShort(this.missSendLength);
- }
-
- @Override
- public int hashCode() {
- final int prime = 331;
- int result = super.hashCode();
- result = prime * result + flags;
- result = prime * result + missSendLength;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (!(obj instanceof OFSwitchConfig)) {
- return false;
- }
- OFSwitchConfig other = (OFSwitchConfig) obj;
- if (flags != other.flags) {
- return false;
- }
- if (missSendLength != other.missSendLength) {
- return false;
- }
- return true;
- }
-}
diff --git a/src/main/java/org/openflow/protocol/OFType.java b/src/main/java/org/openflow/protocol/OFType.java
deleted file mode 100644
index 7428c9c..0000000
--- a/src/main/java/org/openflow/protocol/OFType.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-import java.lang.reflect.Constructor;
-
-/**
- * List of OpenFlow types and mappings to wire protocol value and derived
- * classes
- *
- * @author Rob Sherwood (rob.sherwood@stanford.edu)
- * @author David Erickson (daviderickson@cs.stanford.edu)
- *
- */
-@SuppressWarnings("rawtypes")
-public enum OFType {
- HELLO (0, OFHello.class, new Instantiable<OFMessage>() {
- @Override
- public OFMessage instantiate() {
- return new OFHello();
- }}),
- ERROR (1, OFError.class, new Instantiable<OFMessage>() {
- @Override
- public OFMessage instantiate() {
- return new OFError();
- }}),
- ECHO_REQUEST (2, OFEchoRequest.class, new Instantiable<OFMessage>() {
- @Override
- public OFMessage instantiate() {
- return new OFEchoRequest();
- }}),
- ECHO_REPLY (3, OFEchoReply.class, new Instantiable<OFMessage>() {
- @Override
- public OFMessage instantiate() {
- return new OFEchoReply();
- }}),
- VENDOR (4, OFVendor.class, new Instantiable<OFMessage>() {
- @Override
- public OFMessage instantiate() {
- return new OFVendor();
- }}),
- FEATURES_REQUEST (5, OFFeaturesRequest.class, new Instantiable<OFMessage>() {
- @Override
- public OFMessage instantiate() {
- return new OFFeaturesRequest();
- }}),
- FEATURES_REPLY (6, OFFeaturesReply.class, new Instantiable<OFMessage>() {
- @Override
- public OFMessage instantiate() {
- return new OFFeaturesReply();
- }}),
- GET_CONFIG_REQUEST (7, OFGetConfigRequest.class, new Instantiable<OFMessage>() {
- @Override
- public OFMessage instantiate() {
- return new OFGetConfigRequest();
- }}),
- GET_CONFIG_REPLY (8, OFGetConfigReply.class, new Instantiable<OFMessage>() {
- @Override
- public OFMessage instantiate() {
- return new OFGetConfigReply();
- }}),
- SET_CONFIG (9, OFSetConfig.class, new Instantiable<OFMessage>() {
- @Override
- public OFMessage instantiate() {
- return new OFSetConfig();
- }}),
- PACKET_IN (10, OFPacketIn.class, new Instantiable<OFMessage>() {
- @Override
- public OFMessage instantiate() {
- return new OFPacketIn();
- }}),
- FLOW_REMOVED (11, OFFlowRemoved.class, new Instantiable<OFMessage>() {
- @Override
- public OFMessage instantiate() {
- return new OFFlowRemoved();
- }}),
- PORT_STATUS (12, OFPortStatus.class, new Instantiable<OFMessage>() {
- @Override
- public OFMessage instantiate() {
- return new OFPortStatus();
- }}),
- PACKET_OUT (13, OFPacketOut.class, new Instantiable<OFMessage>() {
- @Override
- public OFMessage instantiate() {
- return new OFPacketOut();
- }}),
- FLOW_MOD (14, OFFlowMod.class, new Instantiable<OFMessage>() {
- @Override
- public OFMessage instantiate() {
- return new OFFlowMod();
- }}),
- PORT_MOD (15, OFPortMod.class, new Instantiable<OFMessage>() {
- @Override
- public OFMessage instantiate() {
- return new OFPortMod();
- }}),
- STATS_REQUEST (16, OFStatisticsRequest.class, new Instantiable<OFMessage>() {
- @Override
- public OFMessage instantiate() {
- return new OFStatisticsRequest();
- }}),
- STATS_REPLY (17, OFStatisticsReply.class, new Instantiable<OFMessage>() {
- @Override
- public OFMessage instantiate() {
- return new OFStatisticsReply();
- }}),
- BARRIER_REQUEST (18, OFBarrierRequest.class, new Instantiable<OFMessage>() {
- @Override
- public OFMessage instantiate() {
- return new OFBarrierRequest();
- }}),
- BARRIER_REPLY (19, OFBarrierReply.class, new Instantiable<OFMessage>() {
- @Override
- public OFMessage instantiate() {
- return new OFBarrierReply();
- }});
-
- static OFType[] mapping;
-
- protected Class<? extends OFMessage> clazz;
- protected Constructor<? extends OFMessage> constructor;
- protected Instantiable<OFMessage> instantiable;
- protected byte type;
-
- /**
- * Store some information about the OpenFlow type, including wire protocol
- * type number, length, and derived class
- *
- * @param type Wire protocol number associated with this OFType
- * @param clazz The Java class corresponding to this type of OpenFlow
- * message
- * @param instantiator An Instantiator<OFMessage> implementation that creates an
- * instance of the specified OFMessage
- */
- OFType(int type, Class<? extends OFMessage> clazz, Instantiable<OFMessage> instantiator) {
- this.type = (byte) type;
- this.clazz = clazz;
- this.instantiable = instantiator;
- try {
- this.constructor = clazz.getConstructor(new Class[]{});
- } catch (Exception e) {
- throw new RuntimeException(
- "Failure getting constructor for class: " + clazz, e);
- }
- OFType.addMapping(this.type, this);
- }
-
- /**
- * Adds a mapping from type value to OFType enum
- *
- * @param i OpenFlow wire protocol type
- * @param t type
- */
- static public void addMapping(byte i, OFType t) {
- if (mapping == null)
- mapping = new OFType[32];
- OFType.mapping[i] = t;
- }
-
- /**
- * Remove a mapping from type value to OFType enum
- *
- * @param i OpenFlow wire protocol type
- */
- static public void removeMapping(byte i) {
- OFType.mapping[i] = null;
- }
-
- /**
- * Given a wire protocol OpenFlow type number, return the OFType associated
- * with it
- *
- * @param i wire protocol number
- * @return OFType enum type
- */
-
- static public OFType valueOf(Byte i) {
- return OFType.mapping[i];
- }
-
- /**
- * @return Returns the wire protocol value corresponding to this OFType
- */
- public byte getTypeValue() {
- return this.type;
- }
-
- /**
- * @return return the OFMessage subclass corresponding to this OFType
- */
- public Class<? extends OFMessage> toClass() {
- return clazz;
- }
-
- /**
- * Returns the no-argument Constructor of the implementation class for
- * this OFType
- * @return the constructor
- */
- public Constructor<? extends OFMessage> getConstructor() {
- return constructor;
- }
-
- /**
- * Returns a new instance of the OFMessage represented by this OFType
- * @return the new object
- */
- public OFMessage newInstance() {
- return instantiable.instantiate();
- }
-
- /**
- * @return the instantiable
- */
- public Instantiable<OFMessage> getInstantiable() {
- return instantiable;
- }
-
- /**
- * @param instantiable the instantiable to set
- */
- public void setInstantiable(Instantiable<OFMessage> instantiable) {
- this.instantiable = instantiable;
- }
-}
diff --git a/src/main/java/org/openflow/protocol/OFVendor.java b/src/main/java/org/openflow/protocol/OFVendor.java
deleted file mode 100644
index 0178c18..0000000
--- a/src/main/java/org/openflow/protocol/OFVendor.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.openflow.protocol.factory.OFVendorDataFactory;
-import org.openflow.protocol.factory.OFVendorDataFactoryAware;
-import org.openflow.protocol.vendor.OFVendorData;
-import org.openflow.util.U16;
-
-/**
- * Represents ofp_vendor_header
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-public class OFVendor extends OFMessage implements OFVendorDataFactoryAware {
- public static int MINIMUM_LENGTH = 12;
-
- protected int vendor;
- protected OFVendorData vendorData;
- protected OFVendorDataFactory vendorDataFactory;
-
- public OFVendor() {
- super();
- this.type = OFType.VENDOR;
- this.length = U16.t(MINIMUM_LENGTH);
- }
-
- /**
- * @return the vendor
- */
- public int getVendor() {
- return vendor;
- }
-
- /**
- * @param vendor the vendor to set
- */
- public void setVendor(int vendor) {
- this.vendor = vendor;
- }
-
- /**
- * @return the data
- */
- public OFVendorData getVendorData() {
- return vendorData;
- }
-
- /**
- * @param data the data to set
- */
- public void setVendorData(OFVendorData vendorData) {
- this.vendorData = vendorData;
- }
-
- @Override
- public void setVendorDataFactory(OFVendorDataFactory vendorDataFactory) {
- this.vendorDataFactory = vendorDataFactory;
- }
-
- @Override
- public void readFrom(ChannelBuffer data) {
- super.readFrom(data);
- this.vendor = data.readInt();
- if (vendorDataFactory == null)
- throw new RuntimeException("OFVendorDataFactory not set");
-
- this.vendorData = vendorDataFactory.parseVendorData(vendor,
- data, super.getLengthU() - MINIMUM_LENGTH);
- }
-
- @Override
- public void writeTo(ChannelBuffer data) {
- super.writeTo(data);
- data.writeInt(this.vendor);
- if (vendorData != null)
- vendorData.writeTo(data);
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 337;
- int result = super.hashCode();
- result = prime * result + vendor;
- if (vendorData != null)
- result = prime * result + vendorData.hashCode();
- return result;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (!super.equals(obj))
- return false;
- if (getClass() != obj.getClass())
- return false;
- OFVendor other = (OFVendor) obj;
- if (vendor != other.vendor)
- return false;
- if (vendorData == null) {
- if (other.vendorData != null) {
- return false;
- }
- } else if (!vendorData.equals(other.vendorData)) {
- return false;
- }
- return true;
- }
-}
diff --git a/src/main/java/org/openflow/protocol/action/OFAction.java b/src/main/java/org/openflow/protocol/action/OFAction.java
deleted file mode 100644
index 57b5dc1..0000000
--- a/src/main/java/org/openflow/protocol/action/OFAction.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol.action;
-
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.openflow.util.U16;
-
-/**
- * The base class for all OpenFlow Actions.
- *
- * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010
- */
-public class OFAction implements Cloneable {
- /**
- * Note the true minimum length for this header is 8 including a pad to 64
- * bit alignment, however as this base class is used for demuxing an
- * incoming Action, it is only necessary to read the first 4 bytes. All
- * Actions extending this class are responsible for reading/writing the
- * first 8 bytes, including the pad if necessary.
- */
- public static int MINIMUM_LENGTH = 4;
- public static int OFFSET_LENGTH = 2;
- public static int OFFSET_TYPE = 0;
-
- protected OFActionType type;
- protected short length;
-
- /**
- * Get the length of this message
- *
- * @return
- */
- public short getLength() {
- return length;
- }
-
- /**
- * Get the length of this message, unsigned
- *
- * @return
- */
- public int getLengthU() {
- return U16.f(length);
- }
-
- /**
- * Set the length of this message
- *
- * @param length
- */
- public OFAction setLength(short length) {
- this.length = length;
- return this;
- }
-
- /**
- * Get the type of this message
- *
- * @return OFActionType enum
- */
- public OFActionType getType() {
- return this.type;
- }
-
- /**
- * Set the type of this message
- *
- * @param type
- */
- public void setType(OFActionType type) {
- this.type = type;
- }
-
- /**
- * Returns a summary of the message
- * @return "ofmsg=v=$version;t=$type:l=$len:xid=$xid"
- */
- public String toString() {
- return "ofaction" +
- ";t=" + this.getType() +
- ";l=" + this.getLength();
- }
-
- /**
- * Given the output from toString(),
- * create a new OFAction
- * @param val
- * @return
- */
- public static OFAction fromString(String val) {
- String tokens[] = val.split(";");
- if (!tokens[0].equals("ofaction"))
- throw new IllegalArgumentException("expected 'ofaction' but got '" +
- tokens[0] + "'");
- String type_tokens[] = tokens[1].split("=");
- String len_tokens[] = tokens[2].split("=");
- OFAction action = new OFAction();
- action.setLength(Short.valueOf(len_tokens[1]));
- action.setType(OFActionType.valueOf(type_tokens[1]));
- return action;
- }
-
- public void readFrom(ChannelBuffer data) {
- this.type = OFActionType.valueOf(data.readShort());
- this.length = data.readShort();
- // Note missing PAD, see MINIMUM_LENGTH comment for details
- }
-
- public void writeTo(ChannelBuffer data) {
- data.writeShort(type.getTypeValue());
- data.writeShort(length);
- // Note missing PAD, see MINIMUM_LENGTH comment for details
- }
-
- @Override
- public int hashCode() {
- final int prime = 347;
- int result = 1;
- result = prime * result + length;
- result = prime * result + ((type == null) ? 0 : type.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof OFAction)) {
- return false;
- }
- OFAction other = (OFAction) obj;
- if (length != other.length) {
- return false;
- }
- if (type == null) {
- if (other.type != null) {
- return false;
- }
- } else if (!type.equals(other.type)) {
- return false;
- }
- return true;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#clone()
- */
- @Override
- public OFAction clone() throws CloneNotSupportedException {
- return (OFAction) super.clone();
- }
-
-}
diff --git a/src/main/java/org/openflow/protocol/action/OFActionDataLayer.java b/src/main/java/org/openflow/protocol/action/OFActionDataLayer.java
deleted file mode 100644
index 6832728..0000000
--- a/src/main/java/org/openflow/protocol/action/OFActionDataLayer.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-/**
- * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010
- */
-package org.openflow.protocol.action;
-
-import java.util.Arrays;
-
-import net.floodlightcontroller.core.web.serializers.ByteArrayMACSerializer;
-
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.openflow.protocol.OFPhysicalPort;
-
-/**
- * Represents an ofp_action_dl_addr
- * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010
- */
-public abstract class OFActionDataLayer extends OFAction {
- public static int MINIMUM_LENGTH = 16;
-
- protected byte[] dataLayerAddress;
-
- /**
- * @return the dataLayerAddress
- */
- @JsonSerialize(using=ByteArrayMACSerializer.class)
- public byte[] getDataLayerAddress() {
- return dataLayerAddress;
- }
-
- /**
- * @param dataLayerAddress the dataLayerAddress to set
- */
- public void setDataLayerAddress(byte[] dataLayerAddress) {
- this.dataLayerAddress = dataLayerAddress;
- }
-
- @Override
- public void readFrom(ChannelBuffer data) {
- super.readFrom(data);
- if (this.dataLayerAddress == null)
- this.dataLayerAddress = new byte[OFPhysicalPort.OFP_ETH_ALEN];
- data.readBytes(this.dataLayerAddress);
- data.readInt();
- data.readShort();
- }
-
- @Override
- public void writeTo(ChannelBuffer data) {
- super.writeTo(data);
- data.writeBytes(this.dataLayerAddress);
- data.writeInt(0);
- data.writeShort((short) 0);
- }
-
- @Override
- public int hashCode() {
- final int prime = 347;
- int result = super.hashCode();
- result = prime * result + Arrays.hashCode(dataLayerAddress);
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (!(obj instanceof OFActionDataLayer)) {
- return false;
- }
- OFActionDataLayer other = (OFActionDataLayer) obj;
- if (!Arrays.equals(dataLayerAddress, other.dataLayerAddress)) {
- return false;
- }
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/openflow/protocol/action/OFActionDataLayerDestination.java b/src/main/java/org/openflow/protocol/action/OFActionDataLayerDestination.java
deleted file mode 100644
index 48b8d0f..0000000
--- a/src/main/java/org/openflow/protocol/action/OFActionDataLayerDestination.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol.action;
-
-/**
- *
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-public class OFActionDataLayerDestination extends OFActionDataLayer {
- public OFActionDataLayerDestination() {
- super();
- super.setType(OFActionType.SET_DL_DST);
- super.setLength((short) OFActionDataLayer.MINIMUM_LENGTH);
- }
-
- public OFActionDataLayerDestination(byte[] address) {
- this();
- this.dataLayerAddress = address;
- }
-}
diff --git a/src/main/java/org/openflow/protocol/action/OFActionDataLayerSource.java b/src/main/java/org/openflow/protocol/action/OFActionDataLayerSource.java
deleted file mode 100644
index e04561c..0000000
--- a/src/main/java/org/openflow/protocol/action/OFActionDataLayerSource.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol.action;
-
-/**
- *
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-public class OFActionDataLayerSource extends OFActionDataLayer {
- public OFActionDataLayerSource() {
- super();
- super.setType(OFActionType.SET_DL_SRC);
- super.setLength((short) OFActionDataLayer.MINIMUM_LENGTH);
- }
-
- public OFActionDataLayerSource(byte[] address) {
- this();
- this.dataLayerAddress = address;
- }
-}
diff --git a/src/main/java/org/openflow/protocol/action/OFActionEnqueue.java b/src/main/java/org/openflow/protocol/action/OFActionEnqueue.java
deleted file mode 100644
index 0ec2fa3..0000000
--- a/src/main/java/org/openflow/protocol/action/OFActionEnqueue.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-/**
- * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010
- */
-package org.openflow.protocol.action;
-
-
-import org.jboss.netty.buffer.ChannelBuffer;
-
-/**
- * Represents an ofp_action_enqueue
- * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010
- */
-public class OFActionEnqueue extends OFAction {
- public static int MINIMUM_LENGTH = 16;
-
- protected short port;
- protected int queueId;
-
- public OFActionEnqueue() {
- super.setType(OFActionType.OPAQUE_ENQUEUE);
- super.setLength((short) MINIMUM_LENGTH);
- }
-
- public OFActionEnqueue(short port, int queueId) {
- this();
- this.port = port;
- this.queueId = queueId;
- }
-
- /**
- * Get the output port
- * @return
- */
- public short getPort() {
- return this.port;
- }
-
- /**
- * Set the output port
- * @param port
- */
- public void setPort(short port) {
- this.port = port;
- }
-
- /**
- * @return the queueId
- */
- public int getQueueId() {
- return queueId;
- }
-
- /**
- * @param queueId the queueId to set
- */
- public void setQueueId(int queueId) {
- this.queueId = queueId;
- }
-
- @Override
- public void readFrom(ChannelBuffer data) {
- super.readFrom(data);
- this.port = data.readShort();
- data.readShort();
- data.readInt();
- this.queueId = data.readInt();
- }
-
- @Override
- public void writeTo(ChannelBuffer data) {
- super.writeTo(data);
- data.writeShort(this.port);
- data.writeShort((short) 0);
- data.writeInt(0);
- data.writeInt(this.queueId);
- }
-
- @Override
- public int hashCode() {
- final int prime = 349;
- int result = super.hashCode();
- result = prime * result + port;
- result = prime * result + queueId;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (!(obj instanceof OFActionEnqueue)) {
- return false;
- }
- OFActionEnqueue other = (OFActionEnqueue) obj;
- if (port != other.port) {
- return false;
- }
- if (queueId != other.queueId) {
- return false;
- }
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/openflow/protocol/action/OFActionNetworkLayerAddress.java b/src/main/java/org/openflow/protocol/action/OFActionNetworkLayerAddress.java
deleted file mode 100644
index dc65ae9..0000000
--- a/src/main/java/org/openflow/protocol/action/OFActionNetworkLayerAddress.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-/**
- * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010
- */
-package org.openflow.protocol.action;
-
-
-import org.jboss.netty.buffer.ChannelBuffer;
-
-/**
- * Represents an ofp_action_nw_addr
- * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010
- */
-public abstract class OFActionNetworkLayerAddress extends OFAction {
- public static int MINIMUM_LENGTH = 8;
-
- protected int networkAddress;
-
- /**
- * @return the networkAddress
- */
- public int getNetworkAddress() {
- return networkAddress;
- }
-
- /**
- * @param networkAddress the networkAddress to set
- */
- public void setNetworkAddress(int networkAddress) {
- this.networkAddress = networkAddress;
- }
-
- @Override
- public void readFrom(ChannelBuffer data) {
- super.readFrom(data);
- this.networkAddress = data.readInt();
- }
-
- @Override
- public void writeTo(ChannelBuffer data) {
- super.writeTo(data);
- data.writeInt(this.networkAddress);
- }
-
- @Override
- public int hashCode() {
- final int prime = 353;
- int result = super.hashCode();
- result = prime * result + networkAddress;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (!(obj instanceof OFActionNetworkLayerAddress)) {
- return false;
- }
- OFActionNetworkLayerAddress other = (OFActionNetworkLayerAddress) obj;
- if (networkAddress != other.networkAddress) {
- return false;
- }
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/openflow/protocol/action/OFActionNetworkLayerDestination.java b/src/main/java/org/openflow/protocol/action/OFActionNetworkLayerDestination.java
deleted file mode 100644
index 13c14ff..0000000
--- a/src/main/java/org/openflow/protocol/action/OFActionNetworkLayerDestination.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol.action;
-
-/**
- *
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-public class OFActionNetworkLayerDestination extends OFActionNetworkLayerAddress {
- public OFActionNetworkLayerDestination() {
- super();
- super.setType(OFActionType.SET_NW_DST);
- super.setLength((short) OFActionNetworkLayerAddress.MINIMUM_LENGTH);
- }
-
- public OFActionNetworkLayerDestination(int ip) {
- this();
- this.networkAddress = ip;
- }
-}
diff --git a/src/main/java/org/openflow/protocol/action/OFActionNetworkLayerSource.java b/src/main/java/org/openflow/protocol/action/OFActionNetworkLayerSource.java
deleted file mode 100644
index ef1d005..0000000
--- a/src/main/java/org/openflow/protocol/action/OFActionNetworkLayerSource.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol.action;
-
-/**
- *
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-public class OFActionNetworkLayerSource extends OFActionNetworkLayerAddress {
- public OFActionNetworkLayerSource() {
- super();
- super.setType(OFActionType.SET_NW_SRC);
- super.setLength((short) OFActionNetworkLayerAddress.MINIMUM_LENGTH);
- }
-
- public OFActionNetworkLayerSource(int ip) {
- this();
- this.networkAddress = ip;
- }
-}
diff --git a/src/main/java/org/openflow/protocol/action/OFActionNetworkTypeOfService.java b/src/main/java/org/openflow/protocol/action/OFActionNetworkTypeOfService.java
deleted file mode 100644
index 0d38180..0000000
--- a/src/main/java/org/openflow/protocol/action/OFActionNetworkTypeOfService.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-/**
- * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010
- */
-package org.openflow.protocol.action;
-
-
-import org.jboss.netty.buffer.ChannelBuffer;
-
-/**
- * Represents an ofp_action_enqueue
- * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010
- */
-public class OFActionNetworkTypeOfService extends OFAction {
- public static int MINIMUM_LENGTH = 8;
-
- protected byte networkTypeOfService;
-
- public OFActionNetworkTypeOfService() {
- super.setType(OFActionType.SET_NW_TOS);
- super.setLength((short) MINIMUM_LENGTH);
- }
-
- public OFActionNetworkTypeOfService(byte tos) {
- this();
- this.networkTypeOfService = tos;
- }
-
-
- /**
- * @return the networkTypeOfService
- */
- public byte getNetworkTypeOfService() {
- return networkTypeOfService;
- }
-
- /**
- * @param networkTypeOfService the networkTypeOfService to set
- */
- public void setNetworkTypeOfService(byte networkTypeOfService) {
- this.networkTypeOfService = networkTypeOfService;
- }
-
- @Override
- public void readFrom(ChannelBuffer data) {
- super.readFrom(data);
- this.networkTypeOfService = data.readByte();
- data.readShort();
- data.readByte();
- }
-
- @Override
- public void writeTo(ChannelBuffer data) {
- super.writeTo(data);
- data.writeByte(this.networkTypeOfService);
- data.writeShort((short) 0);
- data.writeByte((byte) 0);
- }
-
- @Override
- public int hashCode() {
- final int prime = 359;
- int result = super.hashCode();
- result = prime * result + networkTypeOfService;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (!(obj instanceof OFActionNetworkTypeOfService)) {
- return false;
- }
- OFActionNetworkTypeOfService other = (OFActionNetworkTypeOfService) obj;
- if (networkTypeOfService != other.networkTypeOfService) {
- return false;
- }
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/openflow/protocol/action/OFActionOutput.java b/src/main/java/org/openflow/protocol/action/OFActionOutput.java
deleted file mode 100644
index b9521d0..0000000
--- a/src/main/java/org/openflow/protocol/action/OFActionOutput.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-/**
- * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010
- */
-package org.openflow.protocol.action;
-
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.openflow.util.U16;
-
-/**
- * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010
- * @author Rob Sherwood (rob.sherwood@stanford.edu)
- */
-public class OFActionOutput extends OFAction implements Cloneable {
- public static int MINIMUM_LENGTH = 8;
-
- protected short port;
- protected short maxLength;
-
- public OFActionOutput() {
- super.setType(OFActionType.OUTPUT);
- super.setLength((short) MINIMUM_LENGTH);
- }
-
- /**
- * Create an Output Action sending packets out the specified
- * OpenFlow port.
- *
- * This is the most common creation pattern for OFActions.
- *
- * @param port
- */
-
- public OFActionOutput(short port) {
- this(port, (short) 65535);
- }
-
- /**
- * Create an Output Action specifying both the port AND
- * the snaplen of the packet to send out that port.
- * The length field is only meaningful when port == OFPort.OFPP_CONTROLLER
- * @param port
- * @param maxLength The maximum number of bytes of the packet to send.
- * Most hardware only supports this value for OFPP_CONTROLLER
- */
-
- public OFActionOutput(short port, short maxLength) {
- super();
- super.setType(OFActionType.OUTPUT);
- super.setLength((short) MINIMUM_LENGTH);
- this.port = port;
- this.maxLength = maxLength;
- }
-
- /**
- * Get the output port
- * @return
- */
- public short getPort() {
- return this.port;
- }
-
- /**
- * Set the output port
- * @param port
- */
- public OFActionOutput setPort(short port) {
- this.port = port;
- return this;
- }
-
- /**
- * Get the max length to send to the controller
- * @return
- */
- public short getMaxLength() {
- return this.maxLength;
- }
-
- /**
- * Set the max length to send to the controller
- * @param maxLength
- */
- public OFActionOutput setMaxLength(short maxLength) {
- this.maxLength = maxLength;
- return this;
- }
-
- @Override
- public void readFrom(ChannelBuffer data) {
- super.readFrom(data);
- this.port = data.readShort();
- this.maxLength = data.readShort();
- }
-
- @Override
- public void writeTo(ChannelBuffer data) {
- super.writeTo(data);
- data.writeShort(port);
- data.writeShort(maxLength);
- }
-
- @Override
- public int hashCode() {
- final int prime = 367;
- int result = super.hashCode();
- result = prime * result + maxLength;
- result = prime * result + port;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (!(obj instanceof OFActionOutput)) {
- return false;
- }
- OFActionOutput other = (OFActionOutput) obj;
- if (maxLength != other.maxLength) {
- return false;
- }
- if (port != other.port) {
- return false;
- }
- return true;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "OFActionOutput [maxLength=" + maxLength + ", port=" + U16.f(port)
- + ", length=" + length + ", type=" + type + "]";
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/openflow/protocol/action/OFActionStripVirtualLan.java b/src/main/java/org/openflow/protocol/action/OFActionStripVirtualLan.java
deleted file mode 100644
index 7d6b849..0000000
--- a/src/main/java/org/openflow/protocol/action/OFActionStripVirtualLan.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-/**
- * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010
- */
-package org.openflow.protocol.action;
-
-
-import org.jboss.netty.buffer.ChannelBuffer;
-
-
-/**
- * Represents an ofp_action_strip_vlan
- * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010
- */
-public class OFActionStripVirtualLan extends OFAction {
- public static int MINIMUM_LENGTH = 8;
-
- public OFActionStripVirtualLan() {
- super();
- super.setType(OFActionType.STRIP_VLAN);
- super.setLength((short) MINIMUM_LENGTH);
- }
-
- @Override
- public void readFrom(ChannelBuffer data) {
- super.readFrom(data);
- // PAD
- data.readInt();
- }
-
- @Override
- public void writeTo(ChannelBuffer data) {
- super.writeTo(data);
- // PAD
- data.writeInt(0);
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/openflow/protocol/action/OFActionTransportLayer.java b/src/main/java/org/openflow/protocol/action/OFActionTransportLayer.java
deleted file mode 100644
index 0bc09c9..0000000
--- a/src/main/java/org/openflow/protocol/action/OFActionTransportLayer.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-/**
- * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010
- */
-package org.openflow.protocol.action;
-
-
-import org.jboss.netty.buffer.ChannelBuffer;
-
-/**
- * Represents an ofp_action_tp_port
- * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010
- */
-public abstract class OFActionTransportLayer extends OFAction {
- public static int MINIMUM_LENGTH = 8;
-
- protected short transportPort;
-
- /**
- * @return the transportPort
- */
- public short getTransportPort() {
- return transportPort;
- }
-
- /**
- * @param transportPort the transportPort to set
- */
- public void setTransportPort(short transportPort) {
- this.transportPort = transportPort;
- }
-
- @Override
- public void readFrom(ChannelBuffer data) {
- super.readFrom(data);
- this.transportPort = data.readShort();
- data.readShort();
- }
-
- @Override
- public void writeTo(ChannelBuffer data) {
- super.writeTo(data);
- data.writeShort(this.transportPort);
- data.writeShort((short) 0);
- }
-
- @Override
- public int hashCode() {
- final int prime = 373;
- int result = super.hashCode();
- result = prime * result + transportPort;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (!(obj instanceof OFActionTransportLayer)) {
- return false;
- }
- OFActionTransportLayer other = (OFActionTransportLayer) obj;
- if (transportPort != other.transportPort) {
- return false;
- }
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/openflow/protocol/action/OFActionTransportLayerDestination.java b/src/main/java/org/openflow/protocol/action/OFActionTransportLayerDestination.java
deleted file mode 100644
index 7e7b0f1..0000000
--- a/src/main/java/org/openflow/protocol/action/OFActionTransportLayerDestination.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol.action;
-
-/**
- *
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-public class OFActionTransportLayerDestination extends OFActionTransportLayer {
- public OFActionTransportLayerDestination() {
- super();
- super.setType(OFActionType.SET_TP_DST);
- super.setLength((short) OFActionTransportLayer.MINIMUM_LENGTH);
- }
-
- public OFActionTransportLayerDestination(short port) {
- this();
- this.transportPort = port;
- }
-}
diff --git a/src/main/java/org/openflow/protocol/action/OFActionTransportLayerSource.java b/src/main/java/org/openflow/protocol/action/OFActionTransportLayerSource.java
deleted file mode 100644
index 385aa53..0000000
--- a/src/main/java/org/openflow/protocol/action/OFActionTransportLayerSource.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol.action;
-
-/**
- *
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-public class OFActionTransportLayerSource extends OFActionTransportLayer {
- public OFActionTransportLayerSource() {
- super();
- super.setType(OFActionType.SET_TP_SRC);
- super.setLength((short) OFActionTransportLayer.MINIMUM_LENGTH);
- }
-
- public OFActionTransportLayerSource(short port) {
- this();
- this.transportPort = port;
- }
-}
diff --git a/src/main/java/org/openflow/protocol/action/OFActionType.java b/src/main/java/org/openflow/protocol/action/OFActionType.java
deleted file mode 100644
index 84c0801..0000000
--- a/src/main/java/org/openflow/protocol/action/OFActionType.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-/**
- *
- */
-package org.openflow.protocol.action;
-
-import java.lang.reflect.Constructor;
-
-import org.openflow.protocol.Instantiable;
-
-/**
- * List of OpenFlow Action types and mappings to wire protocol value and
- * derived classes
- *
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-@SuppressWarnings("rawtypes")
-public enum OFActionType {
- OUTPUT (0, OFActionOutput.class, new Instantiable<OFAction>() {
- @Override
- public OFAction instantiate() {
- return new OFActionOutput();
- }}),
- SET_VLAN_ID (1, OFActionVirtualLanIdentifier.class, new Instantiable<OFAction>() {
- @Override
- public OFAction instantiate() {
- return new OFActionVirtualLanIdentifier();
- }}),
- SET_VLAN_PCP (2, OFActionVirtualLanPriorityCodePoint.class, new Instantiable<OFAction>() {
- @Override
- public OFAction instantiate() {
- return new OFActionVirtualLanPriorityCodePoint();
- }}),
- STRIP_VLAN (3, OFActionStripVirtualLan.class, new Instantiable<OFAction>() {
- @Override
- public OFAction instantiate() {
- return new OFActionStripVirtualLan();
- }}),
- SET_DL_SRC (4, OFActionDataLayerSource.class, new Instantiable<OFAction>() {
- @Override
- public OFAction instantiate() {
- return new OFActionDataLayerSource();
- }}),
- SET_DL_DST (5, OFActionDataLayerDestination.class, new Instantiable<OFAction>() {
- @Override
- public OFAction instantiate() {
- return new OFActionDataLayerDestination();
- }}),
- SET_NW_SRC (6, OFActionNetworkLayerSource.class, new Instantiable<OFAction>() {
- @Override
- public OFAction instantiate() {
- return new OFActionNetworkLayerSource();
- }}),
- SET_NW_DST (7, OFActionNetworkLayerDestination.class, new Instantiable<OFAction>() {
- @Override
- public OFAction instantiate() {
- return new OFActionNetworkLayerDestination();
- }}),
- SET_NW_TOS (8, OFActionNetworkTypeOfService.class, new Instantiable<OFAction>() {
- @Override
- public OFAction instantiate() {
- return new OFActionNetworkTypeOfService();
- }}),
- SET_TP_SRC (9, OFActionTransportLayerSource.class, new Instantiable<OFAction>() {
- @Override
- public OFAction instantiate() {
- return new OFActionTransportLayerSource();
- }}),
- SET_TP_DST (10, OFActionTransportLayerDestination.class, new Instantiable<OFAction>() {
- @Override
- public OFAction instantiate() {
- return new OFActionTransportLayerDestination();
- }}),
- OPAQUE_ENQUEUE (11, OFActionEnqueue.class, new Instantiable<OFAction>() {
- @Override
- public OFAction instantiate() {
- return new OFActionEnqueue();
- }}),
- VENDOR (0xffff, OFActionVendor.class, new Instantiable<OFAction>() {
- @Override
- public OFAction instantiate() {
- return new OFActionVendor();
- }});
-
- protected static OFActionType[] mapping;
-
- protected Class<? extends OFAction> clazz;
- protected Constructor<? extends OFAction> constructor;
- protected Instantiable<OFAction> instantiable;
- protected int minLen;
- protected short type;
-
- /**
- * Store some information about the OpenFlow Action type, including wire
- * protocol type number, length, and derrived class
- *
- * @param type Wire protocol number associated with this OFType
- * @param clazz The Java class corresponding to this type of OpenFlow Action
- * @param instantiable the instantiable for the OFAction this type represents
- */
- OFActionType(int type, Class<? extends OFAction> clazz, Instantiable<OFAction> instantiable) {
- this.type = (short) type;
- this.clazz = clazz;
- this.instantiable = instantiable;
- try {
- this.constructor = clazz.getConstructor(new Class[]{});
- } catch (Exception e) {
- throw new RuntimeException(
- "Failure getting constructor for class: " + clazz, e);
- }
- OFActionType.addMapping(this.type, this);
- }
-
- /**
- * Adds a mapping from type value to OFActionType enum
- *
- * @param i OpenFlow wire protocol Action type value
- * @param t type
- */
- static public void addMapping(short i, OFActionType t) {
- if (mapping == null)
- mapping = new OFActionType[16];
- // bring higher mappings down to the edge of our array
- if (i < 0)
- i = (short) (16 + i);
- OFActionType.mapping[i] = t;
- }
-
- /**
- * Given a wire protocol OpenFlow type number, return the OFType associated
- * with it
- *
- * @param i wire protocol number
- * @return OFType enum type
- */
-
- static public OFActionType valueOf(short i) {
- if (i < 0)
- i = (short) (16+i);
- return OFActionType.mapping[i];
- }
-
- /**
- * @return Returns the wire protocol value corresponding to this
- * OFActionType
- */
- public short getTypeValue() {
- return this.type;
- }
-
- /**
- * @return return the OFAction subclass corresponding to this OFActionType
- */
- public Class<? extends OFAction> toClass() {
- return clazz;
- }
-
- /**
- * Returns the no-argument Constructor of the implementation class for
- * this OFActionType
- * @return the constructor
- */
- public Constructor<? extends OFAction> getConstructor() {
- return constructor;
- }
-
- /**
- * Returns a new instance of the OFAction represented by this OFActionType
- * @return the new object
- */
- public OFAction newInstance() {
- return instantiable.instantiate();
- }
-
- /**
- * @return the instantiable
- */
- public Instantiable<OFAction> getInstantiable() {
- return instantiable;
- }
-
- /**
- * @param instantiable the instantiable to set
- */
- public void setInstantiable(Instantiable<OFAction> instantiable) {
- this.instantiable = instantiable;
- }
-}
diff --git a/src/main/java/org/openflow/protocol/action/OFActionVendor.java b/src/main/java/org/openflow/protocol/action/OFActionVendor.java
deleted file mode 100644
index b5a15c2..0000000
--- a/src/main/java/org/openflow/protocol/action/OFActionVendor.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol.action;
-
-
-import org.jboss.netty.buffer.ChannelBuffer;
-
-/**
- *
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-public class OFActionVendor extends OFAction {
- public static int MINIMUM_LENGTH = 8;
-
- protected int vendor;
-
- public OFActionVendor() {
- super();
- super.setType(OFActionType.VENDOR);
- super.setLength((short) MINIMUM_LENGTH);
- }
-
- /**
- * @return the vendor
- */
- public int getVendor() {
- return vendor;
- }
-
- /**
- * @param vendor the vendor to set
- */
- public void setVendor(int vendor) {
- this.vendor = vendor;
- }
-
- @Override
- public void readFrom(ChannelBuffer data) {
- super.readFrom(data);
- this.vendor = data.readInt();
- }
-
- @Override
- public void writeTo(ChannelBuffer data) {
- super.writeTo(data);
- data.writeInt(this.vendor);
- }
-
- @Override
- public int hashCode() {
- final int prime = 379;
- int result = super.hashCode();
- result = prime * result + vendor;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (!(obj instanceof OFActionVendor)) {
- return false;
- }
- OFActionVendor other = (OFActionVendor) obj;
- if (vendor != other.vendor) {
- return false;
- }
- return true;
- }
-}
diff --git a/src/main/java/org/openflow/protocol/action/OFActionVirtualLanIdentifier.java b/src/main/java/org/openflow/protocol/action/OFActionVirtualLanIdentifier.java
deleted file mode 100644
index 5bd0e0b..0000000
--- a/src/main/java/org/openflow/protocol/action/OFActionVirtualLanIdentifier.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-/**
- * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010
- */
-package org.openflow.protocol.action;
-
-
-import org.jboss.netty.buffer.ChannelBuffer;
-
-/**
- * Represents an ofp_action_vlan_vid
- * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010
- */
-public class OFActionVirtualLanIdentifier extends OFAction {
- public static int MINIMUM_LENGTH = 8;
-
- protected short virtualLanIdentifier;
-
- public OFActionVirtualLanIdentifier() {
- super.setType(OFActionType.SET_VLAN_ID);
- super.setLength((short) MINIMUM_LENGTH);
- }
-
- public OFActionVirtualLanIdentifier(short vlanId) {
- this();
- this.virtualLanIdentifier = vlanId;
- }
-
- /**
- * @return the virtualLanIdentifier
- */
- public short getVirtualLanIdentifier() {
- return virtualLanIdentifier;
- }
-
- /**
- * @param virtualLanIdentifier the virtualLanIdentifier to set
- */
- public void setVirtualLanIdentifier(short virtualLanIdentifier) {
- this.virtualLanIdentifier = virtualLanIdentifier;
- }
-
- @Override
- public void readFrom(ChannelBuffer data) {
- super.readFrom(data);
- this.virtualLanIdentifier = data.readShort();
- data.readShort();
- }
-
- @Override
- public void writeTo(ChannelBuffer data) {
- super.writeTo(data);
- data.writeShort(this.virtualLanIdentifier);
- data.writeShort((short) 0);
- }
-
- @Override
- public int hashCode() {
- final int prime = 383;
- int result = super.hashCode();
- result = prime * result + virtualLanIdentifier;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (!(obj instanceof OFActionVirtualLanIdentifier)) {
- return false;
- }
- OFActionVirtualLanIdentifier other = (OFActionVirtualLanIdentifier) obj;
- if (virtualLanIdentifier != other.virtualLanIdentifier) {
- return false;
- }
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/openflow/protocol/action/OFActionVirtualLanPriorityCodePoint.java b/src/main/java/org/openflow/protocol/action/OFActionVirtualLanPriorityCodePoint.java
deleted file mode 100644
index 9202df3..0000000
--- a/src/main/java/org/openflow/protocol/action/OFActionVirtualLanPriorityCodePoint.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-/**
- * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010
- */
-package org.openflow.protocol.action;
-
-
-import org.jboss.netty.buffer.ChannelBuffer;
-
-/**
- * Represents an ofp_action_vlan_pcp
- * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010
- */
-public class OFActionVirtualLanPriorityCodePoint extends OFAction {
- public static int MINIMUM_LENGTH = 8;
-
- protected byte virtualLanPriorityCodePoint;
-
- public OFActionVirtualLanPriorityCodePoint() {
- super.setType(OFActionType.SET_VLAN_PCP);
- super.setLength((short) MINIMUM_LENGTH);
- }
-
- public OFActionVirtualLanPriorityCodePoint(byte priority) {
- this();
- this.virtualLanPriorityCodePoint = priority;
- }
-
- /**
- * @return the virtualLanPriorityCodePoint
- */
- public byte getVirtualLanPriorityCodePoint() {
- return virtualLanPriorityCodePoint;
- }
-
- /**
- * @param virtualLanPriorityCodePoint the virtualLanPriorityCodePoint to set
- */
- public void setVirtualLanPriorityCodePoint(byte virtualLanPriorityCodePoint) {
- this.virtualLanPriorityCodePoint = virtualLanPriorityCodePoint;
- }
-
- @Override
- public void readFrom(ChannelBuffer data) {
- super.readFrom(data);
- this.virtualLanPriorityCodePoint = data.readByte();
- data.readShort(); // pad
- data.readByte(); // pad
- }
-
- @Override
- public void writeTo(ChannelBuffer data) {
- super.writeTo(data);
- data.writeByte(this.virtualLanPriorityCodePoint);
- data.writeShort((short) 0);
- data.writeByte((byte) 0);
- }
-
- @Override
- public int hashCode() {
- final int prime = 389;
- int result = super.hashCode();
- result = prime * result + virtualLanPriorityCodePoint;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (!(obj instanceof OFActionVirtualLanPriorityCodePoint)) {
- return false;
- }
- OFActionVirtualLanPriorityCodePoint other = (OFActionVirtualLanPriorityCodePoint) obj;
- if (virtualLanPriorityCodePoint != other.virtualLanPriorityCodePoint) {
- return false;
- }
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/openflow/protocol/factory/BasicFactory.java b/src/main/java/org/openflow/protocol/factory/BasicFactory.java
deleted file mode 100644
index 7b15e82..0000000
--- a/src/main/java/org/openflow/protocol/factory/BasicFactory.java
+++ /dev/null
@@ -1,294 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol.factory;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.openflow.protocol.OFMessage;
-import org.openflow.protocol.OFType;
-import org.openflow.protocol.action.OFAction;
-import org.openflow.protocol.action.OFActionType;
-import org.openflow.protocol.statistics.OFStatistics;
-import org.openflow.protocol.statistics.OFStatisticsType;
-import org.openflow.protocol.statistics.OFVendorStatistics;
-import org.openflow.protocol.vendor.OFByteArrayVendorData;
-import org.openflow.protocol.vendor.OFVendorData;
-import org.openflow.protocol.vendor.OFVendorDataType;
-import org.openflow.protocol.vendor.OFVendorId;
-
-
-/**
- * A basic OpenFlow factory that supports naive creation of both Messages and
- * Actions.
- *
- * @author David Erickson (daviderickson@cs.stanford.edu)
- * @author Rob Sherwood (rob.sherwood@stanford.edu)
- *
- */
-public class BasicFactory implements OFMessageFactory, OFActionFactory,
- OFStatisticsFactory, OFVendorDataFactory {
- @Override
- public OFMessage getMessage(OFType t) {
- return t.newInstance();
- }
-
- @Override
- public List<OFMessage> parseMessage(ChannelBuffer data) throws MessageParseException {
- List<OFMessage> msglist = new ArrayList<OFMessage>();
- OFMessage msg = null;
-
- while (data.readableBytes() >= OFMessage.MINIMUM_LENGTH) {
- data.markReaderIndex();
- msg = this.parseMessageOne(data);
- if (msg == null) {
- data.resetReaderIndex();
- break;
- }
- else {
- msglist.add(msg);
- }
- }
-
- if (msglist.size() == 0) {
- return null;
- }
- return msglist;
-
- }
-
- public OFMessage parseMessageOne(ChannelBuffer data) throws MessageParseException {
- try {
- OFMessage demux = new OFMessage();
- OFMessage ofm = null;
-
- if (data.readableBytes() < OFMessage.MINIMUM_LENGTH)
- return ofm;
-
- data.markReaderIndex();
- demux.readFrom(data);
- data.resetReaderIndex();
-
- if (demux.getLengthU() > data.readableBytes())
- return ofm;
-
- ofm = getMessage(demux.getType());
- if (ofm == null)
- return null;
-
- if (ofm instanceof OFActionFactoryAware) {
- ((OFActionFactoryAware)ofm).setActionFactory(this);
- }
- if (ofm instanceof OFMessageFactoryAware) {
- ((OFMessageFactoryAware)ofm).setMessageFactory(this);
- }
- if (ofm instanceof OFStatisticsFactoryAware) {
- ((OFStatisticsFactoryAware)ofm).setStatisticsFactory(this);
- }
- if (ofm instanceof OFVendorDataFactoryAware) {
- ((OFVendorDataFactoryAware)ofm).setVendorDataFactory(this);
- }
- ofm.readFrom(data);
- if (OFMessage.class.equals(ofm.getClass())) {
- // advance the position for un-implemented messages
- data.readerIndex(data.readerIndex()+(ofm.getLengthU() -
- OFMessage.MINIMUM_LENGTH));
- }
-
- return ofm;
- } catch (Exception e) {
- /* Write the offending data along with the error message */
- data.resetReaderIndex();
- String msg =
- "Message Parse Error for packet:" + dumpBuffer(data) +
- "\nException: " + e.toString();
- data.resetReaderIndex();
-
- throw new MessageParseException(msg, e);
- }
- }
-
- @Override
- public OFAction getAction(OFActionType t) {
- return t.newInstance();
- }
-
- @Override
- public List<OFAction> parseActions(ChannelBuffer data, int length) {
- return parseActions(data, length, 0);
- }
-
- @Override
- public List<OFAction> parseActions(ChannelBuffer data, int length, int limit) {
- List<OFAction> results = new ArrayList<OFAction>();
- OFAction demux = new OFAction();
- OFAction ofa;
- int end = data.readerIndex() + length;
-
- while (limit == 0 || results.size() <= limit) {
- if ((data.readableBytes() < OFAction.MINIMUM_LENGTH ||
- (data.readerIndex() + OFAction.MINIMUM_LENGTH) > end))
- return results;
-
- data.markReaderIndex();
- demux.readFrom(data);
- data.resetReaderIndex();
-
- if ((demux.getLengthU() > data.readableBytes() ||
- (data.readerIndex() + demux.getLengthU()) > end))
- return results;
-
- ofa = getAction(demux.getType());
- ofa.readFrom(data);
- if (OFAction.class.equals(ofa.getClass())) {
- // advance the position for un-implemented messages
- data.readerIndex(data.readerIndex()+(ofa.getLengthU() -
- OFAction.MINIMUM_LENGTH));
- }
- results.add(ofa);
- }
-
- return results;
- }
-
- @Override
- public OFActionFactory getActionFactory() {
- return this;
- }
-
- @Override
- public OFStatistics getStatistics(OFType t, OFStatisticsType st) {
- return st.newInstance(t);
- }
-
- @Override
- public List<OFStatistics> parseStatistics(OFType t, OFStatisticsType st,
- ChannelBuffer data, int length) {
- return parseStatistics(t, st, data, length, 0);
- }
-
- /**
- * @param t
- * OFMessage type: should be one of stats_request or stats_reply
- * @param st
- * statistics type of this message, e.g., DESC, TABLE
- * @param data
- * buffer to read from
- * @param length
- * length of statistics
- * @param limit
- * number of statistics to grab; 0 == all
- *
- * @return list of statistics
- */
-
- @Override
- public List<OFStatistics> parseStatistics(OFType t, OFStatisticsType st,
- ChannelBuffer data, int length, int limit) {
- List<OFStatistics> results = new ArrayList<OFStatistics>();
- OFStatistics statistics = getStatistics(t, st);
-
- int start = data.readerIndex();
- int count = 0;
-
- while (limit == 0 || results.size() <= limit) {
- // TODO Create a separate MUX/DEMUX path for vendor stats
- if (statistics instanceof OFVendorStatistics)
- ((OFVendorStatistics)statistics).setLength(length);
-
- /**
- * can't use data.remaining() here, b/c there could be other data
- * buffered past this message
- */
- if ((length - count) >= statistics.getLength()) {
- if (statistics instanceof OFActionFactoryAware)
- ((OFActionFactoryAware)statistics).setActionFactory(this);
- statistics.readFrom(data);
- results.add(statistics);
- count += statistics.getLength();
- statistics = getStatistics(t, st);
- } else {
- if (count < length) {
- /**
- * Nasty case: partial/incomplete statistic found even
- * though we have a full message. Found when NOX sent
- * agg_stats request with wrong agg statistics length (52
- * instead of 56)
- *
- * just throw the rest away, or we will break framing
- */
- data.readerIndex(start + length);
- }
- return results;
- }
- }
- return results; // empty; no statistics at all
- }
-
-
- @Override
- public OFVendorData getVendorData(OFVendorId vendorId,
- OFVendorDataType vendorDataType) {
- if (vendorDataType == null)
- return null;
-
- return vendorDataType.newInstance();
- }
-
- /**
- * Attempts to parse and return the OFVendorData contained in the given
- * ChannelBuffer, beginning right after the vendor id.
- * @param vendor the vendor id that was parsed from the OFVendor message.
- * @param data the ChannelBuffer from which to parse the vendor data
- * @param length the length to the end of the enclosing message.
- * @return an OFVendorData instance
- */
- public OFVendorData parseVendorData(int vendor, ChannelBuffer data,
- int length) {
- OFVendorDataType vendorDataType = null;
- OFVendorId vendorId = OFVendorId.lookupVendorId(vendor);
- if (vendorId != null) {
- data.markReaderIndex();
- vendorDataType = vendorId.parseVendorDataType(data, length);
- data.resetReaderIndex();
- }
-
- OFVendorData vendorData = getVendorData(vendorId, vendorDataType);
- if (vendorData == null)
- vendorData = new OFByteArrayVendorData();
-
- vendorData.readFrom(data, length);
-
- return vendorData;
- }
-
- public static String dumpBuffer(ChannelBuffer data) {
- // NOTE: Reads all the bytes in buffer from current read offset.
- // Set/Reset ReaderIndex if you want to read from a different location
- int len = data.readableBytes();
- StringBuffer sb = new StringBuffer();
- for (int i=0 ; i<len; i++) {
- if (i%32 == 0) sb.append("\n");
- if (i%4 == 0) sb.append(" ");
- sb.append(String.format("%02x", data.getUnsignedByte(i)));
- }
- return sb.toString();
- }
-
-}
diff --git a/src/main/java/org/openflow/protocol/factory/MessageParseException.java b/src/main/java/org/openflow/protocol/factory/MessageParseException.java
deleted file mode 100644
index b685e5d..0000000
--- a/src/main/java/org/openflow/protocol/factory/MessageParseException.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.openflow.protocol.factory;
-
-/**
- * Exception thrown when an openflow message fails to parse properly
- */
-public class MessageParseException extends Exception {
- /**
- *
- */
- private static final long serialVersionUID = -75893812926304726L;
-
- public MessageParseException() {
- super();
- }
-
- public MessageParseException(String message, Throwable cause) {
- super(message, cause);
- this.setStackTrace(cause.getStackTrace());
- }
-
- public MessageParseException(String message) {
- super(message);
- }
-
- public MessageParseException(Throwable cause) {
- super(cause);
- this.setStackTrace(cause.getStackTrace());
- }
-}
diff --git a/src/main/java/org/openflow/protocol/factory/OFActionFactory.java b/src/main/java/org/openflow/protocol/factory/OFActionFactory.java
deleted file mode 100644
index c3cd062..0000000
--- a/src/main/java/org/openflow/protocol/factory/OFActionFactory.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol.factory;
-
-import java.util.List;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.openflow.protocol.action.OFAction;
-import org.openflow.protocol.action.OFActionType;
-
-
-/**
- * The interface to factories used for retrieving OFAction instances. All
- * methods are expected to be thread-safe.
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-public interface OFActionFactory {
- /**
- * Retrieves an OFAction instance corresponding to the specified
- * OFActionType
- * @param t the type of the OFAction to be retrieved
- * @return an OFAction instance
- */
- public OFAction getAction(OFActionType t);
-
- /**
- * Attempts to parse and return all OFActions contained in the given
- * ByteBuffer, beginning at the ByteBuffer's position, and ending at
- * position+length.
- * @param data the ChannelBuffer to parse for OpenFlow actions
- * @param length the number of Bytes to examine for OpenFlow actions
- * @return a list of OFAction instances
- */
- public List<OFAction> parseActions(ChannelBuffer data, int length);
-
- /**
- * Attempts to parse and return all OFActions contained in the given
- * ByteBuffer, beginning at the ByteBuffer's position, and ending at
- * position+length.
- * @param data the ChannelBuffer to parse for OpenFlow actions
- * @param length the number of Bytes to examine for OpenFlow actions
- * @param limit the maximum number of messages to return, 0 means no limit
- * @return a list of OFAction instances
- */
- public List<OFAction> parseActions(ChannelBuffer data, int length, int limit);
-}
diff --git a/src/main/java/org/openflow/protocol/factory/OFActionFactoryAware.java b/src/main/java/org/openflow/protocol/factory/OFActionFactoryAware.java
deleted file mode 100644
index a97a95c..0000000
--- a/src/main/java/org/openflow/protocol/factory/OFActionFactoryAware.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol.factory;
-
-/**
- * Objects implementing this interface are expected to be instantiated with an
- * instance of an OFActionFactory
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-public interface OFActionFactoryAware {
- /**
- * Sets the OFActionFactory
- * @param actionFactory
- */
- public void setActionFactory(OFActionFactory actionFactory);
-}
diff --git a/src/main/java/org/openflow/protocol/factory/OFMessageFactory.java b/src/main/java/org/openflow/protocol/factory/OFMessageFactory.java
deleted file mode 100644
index 8bb7045..0000000
--- a/src/main/java/org/openflow/protocol/factory/OFMessageFactory.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol.factory;
-
-import java.util.List;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.openflow.protocol.OFMessage;
-import org.openflow.protocol.OFType;
-
-
-/**
- * The interface to factories used for retrieving OFMessage instances. All
- * methods are expected to be thread-safe.
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-public interface OFMessageFactory {
- /**
- * Retrieves an OFMessage instance corresponding to the specified OFType
- * @param t the type of the OFMessage to be retrieved
- * @return an OFMessage instance
- */
- public OFMessage getMessage(OFType t);
-
- /**
- * Attempts to parse and return a OFMessages contained in the given
- * ChannelBuffer, beginning at the ChannelBuffer's position, and ending at the
- * after the first parsed message
- * @param data the ChannelBuffer to parse for an OpenFlow message
- * @return a list of OFMessage instances
- * @throws MessageParseException
- */
- public List<OFMessage> parseMessage(ChannelBuffer data) throws MessageParseException;
-
- /**
- * Retrieves an OFActionFactory
- * @return an OFActionFactory
- */
- public OFActionFactory getActionFactory();
-}
diff --git a/src/main/java/org/openflow/protocol/factory/OFMessageFactoryAware.java b/src/main/java/org/openflow/protocol/factory/OFMessageFactoryAware.java
deleted file mode 100644
index adb1421..0000000
--- a/src/main/java/org/openflow/protocol/factory/OFMessageFactoryAware.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-/**
- *
- */
-package org.openflow.protocol.factory;
-
-/**
- * @author Rob Sherwood (rob.sherwood@stanford.edu)
- *
- */
-public interface OFMessageFactoryAware {
-
- /**
- * Sets the message factory for this object
- *
- * @param factory
- */
- void setMessageFactory(OFMessageFactory factory);
-}
diff --git a/src/main/java/org/openflow/protocol/factory/OFStatisticsFactory.java b/src/main/java/org/openflow/protocol/factory/OFStatisticsFactory.java
deleted file mode 100644
index 32eb3cb..0000000
--- a/src/main/java/org/openflow/protocol/factory/OFStatisticsFactory.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol.factory;
-
-import java.util.List;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.openflow.protocol.OFType;
-import org.openflow.protocol.statistics.OFStatistics;
-import org.openflow.protocol.statistics.OFStatisticsType;
-
-
-/**
- * The interface to factories used for retrieving OFStatistics instances. All
- * methods are expected to be thread-safe.
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-public interface OFStatisticsFactory {
- /**
- * Retrieves an OFStatistics instance corresponding to the specified
- * OFStatisticsType
- * @param t the type of the containing OFMessage, only accepts statistics
- * request or reply
- * @param st the type of the OFStatistics to be retrieved
- * @return an OFStatistics instance
- */
- public OFStatistics getStatistics(OFType t, OFStatisticsType st);
-
- /**
- * Attempts to parse and return all OFStatistics contained in the given
- * ByteBuffer, beginning at the ByteBuffer's position, and ending at
- * position+length.
- * @param t the type of the containing OFMessage, only accepts statistics
- * request or reply
- * @param st the type of the OFStatistics to be retrieved
- * @param data the ChannelBuffer to parse for OpenFlow Statistics
- * @param length the number of Bytes to examine for OpenFlow Statistics
- * @return a list of OFStatistics instances
- */
- public List<OFStatistics> parseStatistics(OFType t,
- OFStatisticsType st, ChannelBuffer data, int length);
-
- /**
- * Attempts to parse and return all OFStatistics contained in the given
- * ByteBuffer, beginning at the ByteBuffer's position, and ending at
- * position+length.
- * @param t the type of the containing OFMessage, only accepts statistics
- * request or reply
- * @param st the type of the OFStatistics to be retrieved
- * @param data the ChannelBuffer to parse for OpenFlow Statistics
- * @param length the number of Bytes to examine for OpenFlow Statistics
- * @param limit the maximum number of messages to return, 0 means no limit
- * @return a list of OFStatistics instances
- */
- public List<OFStatistics> parseStatistics(OFType t,
- OFStatisticsType st, ChannelBuffer data, int length, int limit);
-}
diff --git a/src/main/java/org/openflow/protocol/factory/OFStatisticsFactoryAware.java b/src/main/java/org/openflow/protocol/factory/OFStatisticsFactoryAware.java
deleted file mode 100644
index 52ab09a..0000000
--- a/src/main/java/org/openflow/protocol/factory/OFStatisticsFactoryAware.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol.factory;
-
-/**
- * Objects implementing this interface are expected to be instantiated with an
- * instance of an OFStatisticsFactory
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-public interface OFStatisticsFactoryAware {
- /**
- * Sets the OFStatisticsFactory
- * @param statisticsFactory
- */
- public void setStatisticsFactory(OFStatisticsFactory statisticsFactory);
-}
diff --git a/src/main/java/org/openflow/protocol/factory/OFVendorDataFactory.java b/src/main/java/org/openflow/protocol/factory/OFVendorDataFactory.java
deleted file mode 100644
index d754a4a..0000000
--- a/src/main/java/org/openflow/protocol/factory/OFVendorDataFactory.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
-* Copyright 2011, Big Switch Networks, Inc.
-* Originally created by David Erickson & Rob Sherwood, Stanford University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol.factory;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.openflow.protocol.vendor.OFVendorData;
-import org.openflow.protocol.vendor.OFVendorDataType;
-import org.openflow.protocol.vendor.OFVendorId;
-
-/**
- * The interface to factories used for parsing/creating OFVendorData instances.
- * All methods are expected to be thread-safe.
- *
- * @author Rob Vaterlaus (rob.vaterlaus@bigswitch.com)
- */
-public interface OFVendorDataFactory {
- /**
- * Retrieves an OFVendorData instance corresponding to the specified
- * OFVendorId and OFVendorDataType. There are 3 possible cases for
- * how this will be called:
- *
- * 1) If the vendor id in the OFVendor message is an unknown value,
- * then this method is called with both vendorId and vendorDataType
- * set to null. In this case typically the factory method should
- * return an instance of OFGenericVendorData that just contains
- * the raw byte array of the vendor data.
- *
- * 2) If the vendor id is known but no vendor data type has been
- * registered for the data in the message, then vendorId is set to
- * the appropriate OFVendorId instance and OFVendorDataType is set
- * to null. This would typically be handled the same way as #1
- *
- * 3) If both the vendor id and and vendor data type are known, then
- * typically you'd just call the method in OFVendorDataType to
- * instantiate the appropriate subclass of OFVendorData.
- *
- * @param vendorId the vendorId of the containing OFVendor message
- * @param vendorDataType the type of the OFVendorData to be retrieved
- * @return an OFVendorData instance
- */
- public OFVendorData getVendorData(OFVendorId vendorId,
- OFVendorDataType vendorDataType);
-
- /**
- * Attempts to parse and return the OFVendorData contained in the given
- * ChannelBuffer, beginning right after the vendor id.
- * @param vendorId the vendor id that was parsed from the OFVendor message.
- * @param data the ChannelBuffer from which to parse the vendor data
- * @param length the length to the end of the enclosing message.
- * @return an OFVendorData instance
- */
- public OFVendorData parseVendorData(int vendorId, ChannelBuffer data,
- int length);
-}
diff --git a/src/main/java/org/openflow/protocol/factory/OFVendorDataFactoryAware.java b/src/main/java/org/openflow/protocol/factory/OFVendorDataFactoryAware.java
deleted file mode 100644
index 23614b0..0000000
--- a/src/main/java/org/openflow/protocol/factory/OFVendorDataFactoryAware.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
-* Copyright 2011, Big Switch Networks, Inc.
-* Originally created by David Erickson & Rob Sherwood, Stanford University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol.factory;
-
-/**
- * Classes implementing this interface are expected to be instantiated with an
- * instance of an OFVendorDataFactory
- *
- * @author Rob Vaterlaus (rob.vaterlaus@bigswitch.com)
- */
-public interface OFVendorDataFactoryAware {
- public void setVendorDataFactory(OFVendorDataFactory vendorDataFactory);
-}
diff --git a/src/main/java/org/openflow/protocol/serializers/OFFeaturesReplyJSONSerializer.java b/src/main/java/org/openflow/protocol/serializers/OFFeaturesReplyJSONSerializer.java
deleted file mode 100644
index ad57312..0000000
--- a/src/main/java/org/openflow/protocol/serializers/OFFeaturesReplyJSONSerializer.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
-* Copyright 2011, Big Switch Networks, Inc.
-* Originally created by David Erickson, Stanford University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol.serializers;
-
-import java.io.IOException;
-
-import org.codehaus.jackson.JsonGenerator;
-import org.codehaus.jackson.JsonProcessingException;
-import org.codehaus.jackson.map.JsonSerializer;
-import org.codehaus.jackson.map.SerializerProvider;
-import org.openflow.protocol.OFFeaturesReply;
-import org.openflow.util.HexString;
-
-public class OFFeaturesReplyJSONSerializer extends JsonSerializer<OFFeaturesReply> {
-
- /**
- * Performs the serialization of a OFFeaturesReply object
- */
- @Override
- public void serialize(OFFeaturesReply reply, JsonGenerator jGen, SerializerProvider serializer) throws IOException, JsonProcessingException {
- jGen.writeStartObject();
- jGen.writeNumberField("actions", reply.getActions());
- jGen.writeNumberField("buffers", reply.getBuffers());
- jGen.writeNumberField("capabilities", reply.getCapabilities());
- jGen.writeStringField("datapathId", HexString.toHexString(reply.getDatapathId()));
- jGen.writeNumberField("length", reply.getLength());
- serializer.defaultSerializeField("ports", reply.getPorts(), jGen);
- jGen.writeNumberField("tables", reply.getTables());
- jGen.writeStringField("type", reply.getType().toString());
- jGen.writeNumberField("version", reply.getVersion());
- jGen.writeNumberField("xid", reply.getXid());
- jGen.writeEndObject();
- }
-
- /**
- * Tells SimpleModule that we are the serializer for OFFeaturesReply
- */
- @Override
- public Class<OFFeaturesReply> handledType() {
- return OFFeaturesReply.class;
- }
-}
diff --git a/src/main/java/org/openflow/protocol/serializers/OFMatchJSONSerializer.java b/src/main/java/org/openflow/protocol/serializers/OFMatchJSONSerializer.java
deleted file mode 100644
index 69312fe..0000000
--- a/src/main/java/org/openflow/protocol/serializers/OFMatchJSONSerializer.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
-* Copyright 2011, Big Switch Networks, Inc.
-* Originally created by David Erickson, Stanford University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol.serializers;
-
-import java.io.IOException;
-
-import org.codehaus.jackson.JsonGenerator;
-import org.codehaus.jackson.JsonProcessingException;
-import org.codehaus.jackson.map.JsonSerializer;
-import org.codehaus.jackson.map.SerializerProvider;
-import org.openflow.protocol.OFMatch;
-import org.openflow.util.HexString;
-
-public class OFMatchJSONSerializer extends JsonSerializer<OFMatch> {
-
- /**
- * Converts an IP in a 32 bit integer to a dotted-decimal string
- * @param i The IP address in a 32 bit integer
- * @return An IP address string in dotted-decimal
- */
- private String intToIp(int i) {
- return ((i >> 24 ) & 0xFF) + "." +
- ((i >> 16 ) & 0xFF) + "." +
- ((i >> 8 ) & 0xFF) + "." +
- ( i & 0xFF);
- }
-
- /**
- * Performs the serialization of a OFMatch object
- */
- @Override
- public void serialize(OFMatch match, JsonGenerator jGen,
- SerializerProvider serializer)
- throws IOException, JsonProcessingException {
- jGen.writeStartObject();
- jGen.writeStringField("dataLayerDestination",
- HexString.toHexString(match.getDataLayerDestination()));
- jGen.writeStringField("dataLayerSource",
- HexString.toHexString(match.getDataLayerSource()));
- String dataType = Integer.toHexString(match.getDataLayerType());
- while (dataType.length() < 4) {
- dataType = "0".concat(dataType);
- }
- jGen.writeStringField("dataLayerType", "0x" + dataType);
- jGen.writeNumberField("dataLayerVirtualLan",
- match.getDataLayerVirtualLan());
- jGen.writeNumberField("dataLayerVirtualLanPriorityCodePoint",
- match.getDataLayerVirtualLanPriorityCodePoint());
- jGen.writeNumberField("inputPort", match.getInputPort());
- jGen.writeStringField("networkDestination",
- intToIp(match.getNetworkDestination()));
- jGen.writeNumberField("networkDestinationMaskLen",
- match.getNetworkDestinationMaskLen());
- jGen.writeNumberField("networkProtocol", match.getNetworkProtocol());
- jGen.writeStringField("networkSource",
- intToIp(match.getNetworkSource()));
- jGen.writeNumberField("networkSourceMaskLen",
- match.getNetworkSourceMaskLen());
- jGen.writeNumberField("networkTypeOfService",
- match.getNetworkTypeOfService());
- jGen.writeNumberField("transportDestination",
- match.getTransportDestination());
- jGen.writeNumberField("transportSource",
- match.getTransportSource());
- jGen.writeNumberField("wildcards", match.getWildcards());
- jGen.writeEndObject();
- }
-
- /**
- * Tells SimpleModule that we are the serializer for OFMatch
- */
- @Override
- public Class<OFMatch> handledType() {
- return OFMatch.class;
- }
-}
diff --git a/src/main/java/org/openflow/protocol/statistics/OFAggregateStatisticsReply.java b/src/main/java/org/openflow/protocol/statistics/OFAggregateStatisticsReply.java
deleted file mode 100644
index 7dec16b..0000000
--- a/src/main/java/org/openflow/protocol/statistics/OFAggregateStatisticsReply.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol.statistics;
-
-
-import org.codehaus.jackson.annotate.JsonIgnore;
-import org.jboss.netty.buffer.ChannelBuffer;
-
-/**
- * Represents an ofp_aggregate_stats_reply structure
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-public class OFAggregateStatisticsReply implements OFStatistics {
- protected long packetCount;
- protected long byteCount;
- protected int flowCount;
-
- /**
- * @return the packetCount
- */
- public long getPacketCount() {
- return packetCount;
- }
-
- /**
- * @param packetCount the packetCount to set
- */
- public void setPacketCount(long packetCount) {
- this.packetCount = packetCount;
- }
-
- /**
- * @return the byteCount
- */
- public long getByteCount() {
- return byteCount;
- }
-
- /**
- * @param byteCount the byteCount to set
- */
- public void setByteCount(long byteCount) {
- this.byteCount = byteCount;
- }
-
- /**
- * @return the flowCount
- */
- public int getFlowCount() {
- return flowCount;
- }
-
- /**
- * @param flowCount the flowCount to set
- */
- public void setFlowCount(int flowCount) {
- this.flowCount = flowCount;
- }
-
- @Override
- @JsonIgnore
- public int getLength() {
- return 24;
- }
-
- @Override
- public void readFrom(ChannelBuffer data) {
- this.packetCount = data.readLong();
- this.byteCount = data.readLong();
- this.flowCount = data.readInt();
- data.readInt(); // pad
- }
-
- @Override
- public void writeTo(ChannelBuffer data) {
- data.writeLong(this.packetCount);
- data.writeLong(this.byteCount);
- data.writeInt(this.flowCount);
- data.writeInt(0); // pad
- }
-
- @Override
- public int hashCode() {
- final int prime = 397;
- int result = 1;
- result = prime * result + (int) (byteCount ^ (byteCount >>> 32));
- result = prime * result + flowCount;
- result = prime * result + (int) (packetCount ^ (packetCount >>> 32));
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof OFAggregateStatisticsReply)) {
- return false;
- }
- OFAggregateStatisticsReply other = (OFAggregateStatisticsReply) obj;
- if (byteCount != other.byteCount) {
- return false;
- }
- if (flowCount != other.flowCount) {
- return false;
- }
- if (packetCount != other.packetCount) {
- return false;
- }
- return true;
- }
-}
diff --git a/src/main/java/org/openflow/protocol/statistics/OFAggregateStatisticsRequest.java b/src/main/java/org/openflow/protocol/statistics/OFAggregateStatisticsRequest.java
deleted file mode 100644
index f41a4f1..0000000
--- a/src/main/java/org/openflow/protocol/statistics/OFAggregateStatisticsRequest.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol.statistics;
-
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.openflow.protocol.OFMatch;
-
-/**
- * Represents an ofp_aggregate_stats_request structure
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-public class OFAggregateStatisticsRequest implements OFStatistics {
- protected OFMatch match;
- protected byte tableId;
- protected short outPort;
-
- /**
- * @return the match
- */
- public OFMatch getMatch() {
- return match;
- }
-
- /**
- * @param match the match to set
- */
- public void setMatch(OFMatch match) {
- this.match = match;
- }
-
- /**
- * @return the tableId
- */
- public byte getTableId() {
- return tableId;
- }
-
- /**
- * @param tableId the tableId to set
- */
- public void setTableId(byte tableId) {
- this.tableId = tableId;
- }
-
- /**
- * @return the outPort
- */
- public short getOutPort() {
- return outPort;
- }
-
- /**
- * @param outPort the outPort to set
- */
- public void setOutPort(short outPort) {
- this.outPort = outPort;
- }
-
- @Override
- public int getLength() {
- return 44;
- }
-
- @Override
- public void readFrom(ChannelBuffer data) {
- if (this.match == null)
- this.match = new OFMatch();
- this.match.readFrom(data);
- this.tableId = data.readByte();
- data.readByte(); // pad
- this.outPort = data.readShort();
- }
-
- @Override
- public void writeTo(ChannelBuffer data) {
- this.match.writeTo(data);
- data.writeByte(this.tableId);
- data.writeByte((byte) 0);
- data.writeShort(this.outPort);
- }
-
- @Override
- public int hashCode() {
- final int prime = 401;
- int result = 1;
- result = prime * result + ((match == null) ? 0 : match.hashCode());
- result = prime * result + outPort;
- result = prime * result + tableId;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof OFAggregateStatisticsRequest)) {
- return false;
- }
- OFAggregateStatisticsRequest other = (OFAggregateStatisticsRequest) obj;
- if (match == null) {
- if (other.match != null) {
- return false;
- }
- } else if (!match.equals(other.match)) {
- return false;
- }
- if (outPort != other.outPort) {
- return false;
- }
- if (tableId != other.tableId) {
- return false;
- }
- return true;
- }
-}
diff --git a/src/main/java/org/openflow/protocol/statistics/OFDescriptionStatistics.java b/src/main/java/org/openflow/protocol/statistics/OFDescriptionStatistics.java
deleted file mode 100644
index 6799fa3..0000000
--- a/src/main/java/org/openflow/protocol/statistics/OFDescriptionStatistics.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol.statistics;
-
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.openflow.util.StringByteSerializer;
-
-/**
- * Represents an ofp_desc_stats structure
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-public class OFDescriptionStatistics implements OFStatistics {
- public static int DESCRIPTION_STRING_LENGTH = 256;
- public static int SERIAL_NUMBER_LENGTH = 32;
-
- protected String manufacturerDescription;
- protected String hardwareDescription;
- protected String softwareDescription;
- protected String serialNumber;
- protected String datapathDescription;
-
- /**
- * @return the manufacturerDescription
- */
- public String getManufacturerDescription() {
- return manufacturerDescription;
- }
-
- /**
- * @param manufacturerDescription the manufacturerDescription to set
- */
- public void setManufacturerDescription(String manufacturerDescription) {
- this.manufacturerDescription = manufacturerDescription;
- }
-
- /**
- * @return the hardwareDescription
- */
- public String getHardwareDescription() {
- return hardwareDescription;
- }
-
- /**
- * @param hardwareDescription the hardwareDescription to set
- */
- public void setHardwareDescription(String hardwareDescription) {
- this.hardwareDescription = hardwareDescription;
- }
-
- /**
- * @return the softwareDescription
- */
- public String getSoftwareDescription() {
- return softwareDescription;
- }
-
- /**
- * @param softwareDescription the softwareDescription to set
- */
- public void setSoftwareDescription(String softwareDescription) {
- this.softwareDescription = softwareDescription;
- }
-
- /**
- * @return the serialNumber
- */
- public String getSerialNumber() {
- return serialNumber;
- }
-
- /**
- * @param serialNumber the serialNumber to set
- */
- public void setSerialNumber(String serialNumber) {
- this.serialNumber = serialNumber;
- }
-
- /**
- * @return the datapathDescription
- */
- public String getDatapathDescription() {
- return datapathDescription;
- }
-
- /**
- * @param datapathDescription the datapathDescription to set
- */
- public void setDatapathDescription(String datapathDescription) {
- this.datapathDescription = datapathDescription;
- }
-
- @Override
- public int getLength() {
- return 1056;
- }
-
- @Override
- public void readFrom(ChannelBuffer data) {
- this.manufacturerDescription = StringByteSerializer.readFrom(data,
- DESCRIPTION_STRING_LENGTH);
- this.hardwareDescription = StringByteSerializer.readFrom(data,
- DESCRIPTION_STRING_LENGTH);
- this.softwareDescription = StringByteSerializer.readFrom(data,
- DESCRIPTION_STRING_LENGTH);
- this.serialNumber = StringByteSerializer.readFrom(data,
- SERIAL_NUMBER_LENGTH);
- this.datapathDescription = StringByteSerializer.readFrom(data,
- DESCRIPTION_STRING_LENGTH);
- }
-
- @Override
- public void writeTo(ChannelBuffer data) {
- StringByteSerializer.writeTo(data, DESCRIPTION_STRING_LENGTH,
- this.manufacturerDescription);
- StringByteSerializer.writeTo(data, DESCRIPTION_STRING_LENGTH,
- this.hardwareDescription);
- StringByteSerializer.writeTo(data, DESCRIPTION_STRING_LENGTH,
- this.softwareDescription);
- StringByteSerializer.writeTo(data, SERIAL_NUMBER_LENGTH,
- this.serialNumber);
- StringByteSerializer.writeTo(data, DESCRIPTION_STRING_LENGTH,
- this.datapathDescription);
- }
-
- @Override
- public int hashCode() {
- final int prime = 409;
- int result = 1;
- result = prime
- * result
- + ((datapathDescription == null) ? 0 : datapathDescription
- .hashCode());
- result = prime
- * result
- + ((hardwareDescription == null) ? 0 : hardwareDescription
- .hashCode());
- result = prime
- * result
- + ((manufacturerDescription == null) ? 0
- : manufacturerDescription.hashCode());
- result = prime * result
- + ((serialNumber == null) ? 0 : serialNumber.hashCode());
- result = prime
- * result
- + ((softwareDescription == null) ? 0 : softwareDescription
- .hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof OFDescriptionStatistics)) {
- return false;
- }
- OFDescriptionStatistics other = (OFDescriptionStatistics) obj;
- if (datapathDescription == null) {
- if (other.datapathDescription != null) {
- return false;
- }
- } else if (!datapathDescription.equals(other.datapathDescription)) {
- return false;
- }
- if (hardwareDescription == null) {
- if (other.hardwareDescription != null) {
- return false;
- }
- } else if (!hardwareDescription.equals(other.hardwareDescription)) {
- return false;
- }
- if (manufacturerDescription == null) {
- if (other.manufacturerDescription != null) {
- return false;
- }
- } else if (!manufacturerDescription
- .equals(other.manufacturerDescription)) {
- return false;
- }
- if (serialNumber == null) {
- if (other.serialNumber != null) {
- return false;
- }
- } else if (!serialNumber.equals(other.serialNumber)) {
- return false;
- }
- if (softwareDescription == null) {
- if (other.softwareDescription != null) {
- return false;
- }
- } else if (!softwareDescription.equals(other.softwareDescription)) {
- return false;
- }
- return true;
- }
-}
diff --git a/src/main/java/org/openflow/protocol/statistics/OFFlowStatisticsReply.java b/src/main/java/org/openflow/protocol/statistics/OFFlowStatisticsReply.java
deleted file mode 100644
index bea7f1e..0000000
--- a/src/main/java/org/openflow/protocol/statistics/OFFlowStatisticsReply.java
+++ /dev/null
@@ -1,359 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol.statistics;
-
-import java.util.List;
-
-import org.codehaus.jackson.annotate.JsonIgnore;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.openflow.protocol.OFMatch;
-import org.openflow.protocol.action.OFAction;
-import org.openflow.protocol.factory.OFActionFactory;
-import org.openflow.protocol.factory.OFActionFactoryAware;
-import org.openflow.util.U16;
-
-/**
- * Represents an ofp_flow_stats structure
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-public class OFFlowStatisticsReply implements OFStatistics, OFActionFactoryAware {
- public static int MINIMUM_LENGTH = 88;
-
- protected OFActionFactory actionFactory;
- protected short length = (short) MINIMUM_LENGTH;
- protected byte tableId;
- protected OFMatch match;
- protected int durationSeconds;
- protected int durationNanoseconds;
- protected short priority;
- protected short idleTimeout;
- protected short hardTimeout;
- protected long cookie;
- protected long packetCount;
- protected long byteCount;
- protected List<OFAction> actions;
-
- /**
- * @return the tableId
- */
- public byte getTableId() {
- return tableId;
- }
-
- /**
- * @param tableId the tableId to set
- */
- public void setTableId(byte tableId) {
- this.tableId = tableId;
- }
-
- /**
- * @return the match
- */
- public OFMatch getMatch() {
- return match;
- }
-
- /**
- * @param match the match to set
- */
- public void setMatch(OFMatch match) {
- this.match = match;
- }
-
- /**
- * @return the durationSeconds
- */
- public int getDurationSeconds() {
- return durationSeconds;
- }
-
- /**
- * @param durationSeconds the durationSeconds to set
- */
- public void setDurationSeconds(int durationSeconds) {
- this.durationSeconds = durationSeconds;
- }
-
- /**
- * @return the durationNanoseconds
- */
- public int getDurationNanoseconds() {
- return durationNanoseconds;
- }
-
- /**
- * @param durationNanoseconds the durationNanoseconds to set
- */
- public void setDurationNanoseconds(int durationNanoseconds) {
- this.durationNanoseconds = durationNanoseconds;
- }
-
- /**
- * @return the priority
- */
- public short getPriority() {
- return priority;
- }
-
- /**
- * @param priority the priority to set
- */
- public void setPriority(short priority) {
- this.priority = priority;
- }
-
- /**
- * @return the idleTimeout
- */
- public short getIdleTimeout() {
- return idleTimeout;
- }
-
- /**
- * @param idleTimeout the idleTimeout to set
- */
- public void setIdleTimeout(short idleTimeout) {
- this.idleTimeout = idleTimeout;
- }
-
- /**
- * @return the hardTimeout
- */
- public short getHardTimeout() {
- return hardTimeout;
- }
-
- /**
- * @param hardTimeout the hardTimeout to set
- */
- public void setHardTimeout(short hardTimeout) {
- this.hardTimeout = hardTimeout;
- }
-
- /**
- * @return the cookie
- */
- public long getCookie() {
- return cookie;
- }
-
- /**
- * @param cookie the cookie to set
- */
- public void setCookie(long cookie) {
- this.cookie = cookie;
- }
-
- /**
- * @return the packetCount
- */
- public long getPacketCount() {
- return packetCount;
- }
-
- /**
- * @param packetCount the packetCount to set
- */
- public void setPacketCount(long packetCount) {
- this.packetCount = packetCount;
- }
-
- /**
- * @return the byteCount
- */
- public long getByteCount() {
- return byteCount;
- }
-
- /**
- * @param byteCount the byteCount to set
- */
- public void setByteCount(long byteCount) {
- this.byteCount = byteCount;
- }
-
- /**
- * @param length the length to set
- */
- public void setLength(short length) {
- this.length = length;
- }
-
- @Override
- @JsonIgnore
- public int getLength() {
- return U16.f(length);
- }
-
- /**
- * @param actionFactory the actionFactory to set
- */
- @Override
- public void setActionFactory(OFActionFactory actionFactory) {
- this.actionFactory = actionFactory;
- }
-
- /**
- * @return the actions
- */
- public List<OFAction> getActions() {
- return actions;
- }
-
- /**
- * @param actions the actions to set
- */
- public void setActions(List<OFAction> actions) {
- this.actions = actions;
- }
-
- @Override
- public void readFrom(ChannelBuffer data) {
- this.length = data.readShort();
- this.tableId = data.readByte();
- data.readByte(); // pad
- if (this.match == null)
- this.match = new OFMatch();
- this.match.readFrom(data);
- this.durationSeconds = data.readInt();
- this.durationNanoseconds = data.readInt();
- this.priority = data.readShort();
- this.idleTimeout = data.readShort();
- this.hardTimeout = data.readShort();
- data.readInt(); // pad
- data.readShort(); // pad
- this.cookie = data.readLong();
- this.packetCount = data.readLong();
- this.byteCount = data.readLong();
- if (this.actionFactory == null)
- throw new RuntimeException("OFActionFactory not set");
- this.actions = this.actionFactory.parseActions(data, getLength() -
- MINIMUM_LENGTH);
- }
-
- @Override
- public void writeTo(ChannelBuffer data) {
- data.writeShort(this.length);
- data.writeByte(this.tableId);
- data.writeByte((byte) 0);
- this.match.writeTo(data);
- data.writeInt(this.durationSeconds);
- data.writeInt(this.durationNanoseconds);
- data.writeShort(this.priority);
- data.writeShort(this.idleTimeout);
- data.writeShort(this.hardTimeout);
- data.writeInt(0); // pad
- data.writeShort((short)0); // pad
- data.writeLong(this.cookie);
- data.writeLong(this.packetCount);
- data.writeLong(this.byteCount);
- if (actions != null) {
- for (OFAction action : actions) {
- action.writeTo(data);
- }
- }
- }
-
- @Override
- public String toString() {
- String str = "match=" + this.match;
- str += " tableId=" + this.tableId;
- str += " durationSeconds=" + this.durationSeconds;
- str += " durationNanoseconds=" + this.durationNanoseconds;
- str += " priority=" + this.priority;
- str += " idleTimeout=" + this.idleTimeout;
- str += " hardTimeout=" + this.hardTimeout;
- str += " cookie=" + this.cookie;
- str += " packetCount=" + this.packetCount;
- str += " byteCount=" + this.byteCount;
- str += " action=" + this.actions;
-
- return str;
- }
-
- @Override
- public int hashCode() {
- final int prime = 419;
- int result = 1;
- result = prime * result + (int) (byteCount ^ (byteCount >>> 32));
- result = prime * result + (int) (cookie ^ (cookie >>> 32));
- result = prime * result + durationNanoseconds;
- result = prime * result + durationSeconds;
- result = prime * result + hardTimeout;
- result = prime * result + idleTimeout;
- result = prime * result + length;
- result = prime * result + ((match == null) ? 0 : match.hashCode());
- result = prime * result + (int) (packetCount ^ (packetCount >>> 32));
- result = prime * result + priority;
- result = prime * result + tableId;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof OFFlowStatisticsReply)) {
- return false;
- }
- OFFlowStatisticsReply other = (OFFlowStatisticsReply) obj;
- if (byteCount != other.byteCount) {
- return false;
- }
- if (cookie != other.cookie) {
- return false;
- }
- if (durationNanoseconds != other.durationNanoseconds) {
- return false;
- }
- if (durationSeconds != other.durationSeconds) {
- return false;
- }
- if (hardTimeout != other.hardTimeout) {
- return false;
- }
- if (idleTimeout != other.idleTimeout) {
- return false;
- }
- if (length != other.length) {
- return false;
- }
- if (match == null) {
- if (other.match != null) {
- return false;
- }
- } else if (!match.equals(other.match)) {
- return false;
- }
- if (packetCount != other.packetCount) {
- return false;
- }
- if (priority != other.priority) {
- return false;
- }
- if (tableId != other.tableId) {
- return false;
- }
- return true;
- }
-}
diff --git a/src/main/java/org/openflow/protocol/statistics/OFFlowStatisticsRequest.java b/src/main/java/org/openflow/protocol/statistics/OFFlowStatisticsRequest.java
deleted file mode 100644
index b21de0c..0000000
--- a/src/main/java/org/openflow/protocol/statistics/OFFlowStatisticsRequest.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol.statistics;
-
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.openflow.protocol.OFMatch;
-
-/**
- * Represents an ofp_flow_stats_request structure
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-public class OFFlowStatisticsRequest implements OFStatistics {
- protected OFMatch match;
- protected byte tableId;
- protected short outPort;
-
- /**
- * @return the match
- */
- public OFMatch getMatch() {
- return match;
- }
-
- /**
- * @param match the match to set
- */
- public void setMatch(OFMatch match) {
- this.match = match;
- }
-
- /**
- * @return the tableId
- */
- public byte getTableId() {
- return tableId;
- }
-
- /**
- * @param tableId the tableId to set
- */
- public void setTableId(byte tableId) {
- this.tableId = tableId;
- }
-
- /**
- * @return the outPort
- */
- public short getOutPort() {
- return outPort;
- }
-
- /**
- * @param outPort the outPort to set
- */
- public void setOutPort(short outPort) {
- this.outPort = outPort;
- }
-
- @Override
- public int getLength() {
- return 44;
- }
-
- @Override
- public void readFrom(ChannelBuffer data) {
- if (this.match == null)
- this.match = new OFMatch();
- this.match.readFrom(data);
- this.tableId = data.readByte();
- data.readByte(); // pad
- this.outPort = data.readShort();
- }
-
- @Override
- public void writeTo(ChannelBuffer data) {
- this.match.writeTo(data);
- data.writeByte(this.tableId);
- data.writeByte((byte) 0);
- data.writeShort(this.outPort);
- }
-
- @Override
- public int hashCode() {
- final int prime = 421;
- int result = 1;
- result = prime * result + ((match == null) ? 0 : match.hashCode());
- result = prime * result + outPort;
- result = prime * result + tableId;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof OFFlowStatisticsRequest)) {
- return false;
- }
- OFFlowStatisticsRequest other = (OFFlowStatisticsRequest) obj;
- if (match == null) {
- if (other.match != null) {
- return false;
- }
- } else if (!match.equals(other.match)) {
- return false;
- }
- if (outPort != other.outPort) {
- return false;
- }
- if (tableId != other.tableId) {
- return false;
- }
- return true;
- }
-}
diff --git a/src/main/java/org/openflow/protocol/statistics/OFPortStatisticsReply.java b/src/main/java/org/openflow/protocol/statistics/OFPortStatisticsReply.java
deleted file mode 100644
index 87a2465..0000000
--- a/src/main/java/org/openflow/protocol/statistics/OFPortStatisticsReply.java
+++ /dev/null
@@ -1,352 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol.statistics;
-
-
-import org.codehaus.jackson.annotate.JsonIgnore;
-import org.jboss.netty.buffer.ChannelBuffer;
-
-/**
- * Represents an ofp_port_stats structure
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-public class OFPortStatisticsReply implements OFStatistics {
- protected short portNumber;
- protected long receivePackets;
- protected long transmitPackets;
- protected long receiveBytes;
- protected long transmitBytes;
- protected long receiveDropped;
- protected long transmitDropped;
- protected long receiveErrors;
- protected long transmitErrors;
- protected long receiveFrameErrors;
- protected long receiveOverrunErrors;
- protected long receiveCRCErrors;
- protected long collisions;
-
- /**
- * @return the portNumber
- */
- public short getPortNumber() {
- return portNumber;
- }
-
- /**
- * @param portNumber the portNumber to set
- */
- public void setPortNumber(short portNumber) {
- this.portNumber = portNumber;
- }
-
- /**
- * @return the receivePackets
- */
- public long getreceivePackets() {
- return receivePackets;
- }
-
- /**
- * @param receivePackets the receivePackets to set
- */
- public void setreceivePackets(long receivePackets) {
- this.receivePackets = receivePackets;
- }
-
- /**
- * @return the transmitPackets
- */
- public long getTransmitPackets() {
- return transmitPackets;
- }
-
- /**
- * @param transmitPackets the transmitPackets to set
- */
- public void setTransmitPackets(long transmitPackets) {
- this.transmitPackets = transmitPackets;
- }
-
- /**
- * @return the receiveBytes
- */
- public long getReceiveBytes() {
- return receiveBytes;
- }
-
- /**
- * @param receiveBytes the receiveBytes to set
- */
- public void setReceiveBytes(long receiveBytes) {
- this.receiveBytes = receiveBytes;
- }
-
- /**
- * @return the transmitBytes
- */
- public long getTransmitBytes() {
- return transmitBytes;
- }
-
- /**
- * @param transmitBytes the transmitBytes to set
- */
- public void setTransmitBytes(long transmitBytes) {
- this.transmitBytes = transmitBytes;
- }
-
- /**
- * @return the receiveDropped
- */
- public long getReceiveDropped() {
- return receiveDropped;
- }
-
- /**
- * @param receiveDropped the receiveDropped to set
- */
- public void setReceiveDropped(long receiveDropped) {
- this.receiveDropped = receiveDropped;
- }
-
- /**
- * @return the transmitDropped
- */
- public long getTransmitDropped() {
- return transmitDropped;
- }
-
- /**
- * @param transmitDropped the transmitDropped to set
- */
- public void setTransmitDropped(long transmitDropped) {
- this.transmitDropped = transmitDropped;
- }
-
- /**
- * @return the receiveErrors
- */
- public long getreceiveErrors() {
- return receiveErrors;
- }
-
- /**
- * @param receiveErrors the receiveErrors to set
- */
- public void setreceiveErrors(long receiveErrors) {
- this.receiveErrors = receiveErrors;
- }
-
- /**
- * @return the transmitErrors
- */
- public long getTransmitErrors() {
- return transmitErrors;
- }
-
- /**
- * @param transmitErrors the transmitErrors to set
- */
- public void setTransmitErrors(long transmitErrors) {
- this.transmitErrors = transmitErrors;
- }
-
- /**
- * @return the receiveFrameErrors
- */
- public long getReceiveFrameErrors() {
- return receiveFrameErrors;
- }
-
- /**
- * @param receiveFrameErrors the receiveFrameErrors to set
- */
- public void setReceiveFrameErrors(long receiveFrameErrors) {
- this.receiveFrameErrors = receiveFrameErrors;
- }
-
- /**
- * @return the receiveOverrunErrors
- */
- public long getReceiveOverrunErrors() {
- return receiveOverrunErrors;
- }
-
- /**
- * @param receiveOverrunErrors the receiveOverrunErrors to set
- */
- public void setReceiveOverrunErrors(long receiveOverrunErrors) {
- this.receiveOverrunErrors = receiveOverrunErrors;
- }
-
- /**
- * @return the receiveCRCErrors
- */
- public long getReceiveCRCErrors() {
- return receiveCRCErrors;
- }
-
- /**
- * @param receiveCRCErrors the receiveCRCErrors to set
- */
- public void setReceiveCRCErrors(long receiveCRCErrors) {
- this.receiveCRCErrors = receiveCRCErrors;
- }
-
- /**
- * @return the collisions
- */
- public long getCollisions() {
- return collisions;
- }
-
- /**
- * @param collisions the collisions to set
- */
- public void setCollisions(long collisions) {
- this.collisions = collisions;
- }
-
- @Override
- @JsonIgnore
- public int getLength() {
- return 104;
- }
-
- @Override
- public void readFrom(ChannelBuffer data) {
- this.portNumber = data.readShort();
- data.readShort(); // pad
- data.readInt(); // pad
- this.receivePackets = data.readLong();
- this.transmitPackets = data.readLong();
- this.receiveBytes = data.readLong();
- this.transmitBytes = data.readLong();
- this.receiveDropped = data.readLong();
- this.transmitDropped = data.readLong();
- this.receiveErrors = data.readLong();
- this.transmitErrors = data.readLong();
- this.receiveFrameErrors = data.readLong();
- this.receiveOverrunErrors = data.readLong();
- this.receiveCRCErrors = data.readLong();
- this.collisions = data.readLong();
- }
-
- @Override
- public void writeTo(ChannelBuffer data) {
- data.writeShort(this.portNumber);
- data.writeShort((short) 0); // pad
- data.writeInt(0); // pad
- data.writeLong(this.receivePackets);
- data.writeLong(this.transmitPackets);
- data.writeLong(this.receiveBytes);
- data.writeLong(this.transmitBytes);
- data.writeLong(this.receiveDropped);
- data.writeLong(this.transmitDropped);
- data.writeLong(this.receiveErrors);
- data.writeLong(this.transmitErrors);
- data.writeLong(this.receiveFrameErrors);
- data.writeLong(this.receiveOverrunErrors);
- data.writeLong(this.receiveCRCErrors);
- data.writeLong(this.collisions);
- }
-
- @Override
- public int hashCode() {
- final int prime = 431;
- int result = 1;
- result = prime * result + (int) (collisions ^ (collisions >>> 32));
- result = prime * result + portNumber;
- result = prime * result
- + (int) (receivePackets ^ (receivePackets >>> 32));
- result = prime * result + (int) (receiveBytes ^ (receiveBytes >>> 32));
- result = prime * result
- + (int) (receiveCRCErrors ^ (receiveCRCErrors >>> 32));
- result = prime * result
- + (int) (receiveDropped ^ (receiveDropped >>> 32));
- result = prime * result
- + (int) (receiveFrameErrors ^ (receiveFrameErrors >>> 32));
- result = prime * result
- + (int) (receiveOverrunErrors ^ (receiveOverrunErrors >>> 32));
- result = prime * result
- + (int) (receiveErrors ^ (receiveErrors >>> 32));
- result = prime * result
- + (int) (transmitBytes ^ (transmitBytes >>> 32));
- result = prime * result
- + (int) (transmitDropped ^ (transmitDropped >>> 32));
- result = prime * result
- + (int) (transmitErrors ^ (transmitErrors >>> 32));
- result = prime * result
- + (int) (transmitPackets ^ (transmitPackets >>> 32));
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof OFPortStatisticsReply)) {
- return false;
- }
- OFPortStatisticsReply other = (OFPortStatisticsReply) obj;
- if (collisions != other.collisions) {
- return false;
- }
- if (portNumber != other.portNumber) {
- return false;
- }
- if (receivePackets != other.receivePackets) {
- return false;
- }
- if (receiveBytes != other.receiveBytes) {
- return false;
- }
- if (receiveCRCErrors != other.receiveCRCErrors) {
- return false;
- }
- if (receiveDropped != other.receiveDropped) {
- return false;
- }
- if (receiveFrameErrors != other.receiveFrameErrors) {
- return false;
- }
- if (receiveOverrunErrors != other.receiveOverrunErrors) {
- return false;
- }
- if (receiveErrors != other.receiveErrors) {
- return false;
- }
- if (transmitBytes != other.transmitBytes) {
- return false;
- }
- if (transmitDropped != other.transmitDropped) {
- return false;
- }
- if (transmitErrors != other.transmitErrors) {
- return false;
- }
- if (transmitPackets != other.transmitPackets) {
- return false;
- }
- return true;
- }
-}
diff --git a/src/main/java/org/openflow/protocol/statistics/OFPortStatisticsRequest.java b/src/main/java/org/openflow/protocol/statistics/OFPortStatisticsRequest.java
deleted file mode 100644
index c07a895..0000000
--- a/src/main/java/org/openflow/protocol/statistics/OFPortStatisticsRequest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol.statistics;
-
-
-import org.jboss.netty.buffer.ChannelBuffer;
-
-/**
- * Represents an ofp_port_stats_request structure
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-public class OFPortStatisticsRequest implements OFStatistics {
- protected short portNumber;
-
- /**
- * @return the portNumber
- */
- public short getPortNumber() {
- return portNumber;
- }
-
- /**
- * @param portNumber the portNumber to set
- */
- public void setPortNumber(short portNumber) {
- this.portNumber = portNumber;
- }
-
- @Override
- public int getLength() {
- return 8;
- }
-
- @Override
- public void readFrom(ChannelBuffer data) {
- this.portNumber = data.readShort();
- data.readShort(); // pad
- data.readInt(); // pad
- }
-
- @Override
- public void writeTo(ChannelBuffer data) {
- data.writeShort(this.portNumber);
- data.writeShort((short) 0); // pad
- data.writeInt(0); // pad
- }
-
- @Override
- public int hashCode() {
- final int prime = 433;
- int result = 1;
- result = prime * result + portNumber;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof OFPortStatisticsRequest)) {
- return false;
- }
- OFPortStatisticsRequest other = (OFPortStatisticsRequest) obj;
- if (portNumber != other.portNumber) {
- return false;
- }
- return true;
- }
-}
diff --git a/src/main/java/org/openflow/protocol/statistics/OFQueueStatisticsReply.java b/src/main/java/org/openflow/protocol/statistics/OFQueueStatisticsReply.java
deleted file mode 100644
index 03cbb9c..0000000
--- a/src/main/java/org/openflow/protocol/statistics/OFQueueStatisticsReply.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol.statistics;
-
-
-import org.codehaus.jackson.annotate.JsonIgnore;
-import org.jboss.netty.buffer.ChannelBuffer;
-
-/**
- * Represents an ofp_queue_stats structure
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-public class OFQueueStatisticsReply implements OFStatistics {
- protected short portNumber;
- protected int queueId;
- protected long transmitBytes;
- protected long transmitPackets;
- protected long transmitErrors;
-
- /**
- * @return the portNumber
- */
- public short getPortNumber() {
- return portNumber;
- }
-
- /**
- * @param portNumber the portNumber to set
- */
- public void setPortNumber(short portNumber) {
- this.portNumber = portNumber;
- }
-
- /**
- * @return the queueId
- */
- public int getQueueId() {
- return queueId;
- }
-
- /**
- * @param queueId the queueId to set
- */
- public void setQueueId(int queueId) {
- this.queueId = queueId;
- }
-
- /**
- * @return the transmitBytes
- */
- public long getTransmitBytes() {
- return transmitBytes;
- }
-
- /**
- * @param transmitBytes the transmitBytes to set
- */
- public void setTransmitBytes(long transmitBytes) {
- this.transmitBytes = transmitBytes;
- }
-
- /**
- * @return the transmitPackets
- */
- public long getTransmitPackets() {
- return transmitPackets;
- }
-
- /**
- * @param transmitPackets the transmitPackets to set
- */
- public void setTransmitPackets(long transmitPackets) {
- this.transmitPackets = transmitPackets;
- }
-
- /**
- * @return the transmitErrors
- */
- public long getTransmitErrors() {
- return transmitErrors;
- }
-
- /**
- * @param transmitErrors the transmitErrors to set
- */
- public void setTransmitErrors(long transmitErrors) {
- this.transmitErrors = transmitErrors;
- }
-
- @Override
- @JsonIgnore
- public int getLength() {
- return 32;
- }
-
- @Override
- public void readFrom(ChannelBuffer data) {
- this.portNumber = data.readShort();
- data.readShort(); // pad
- this.queueId = data.readInt();
- this.transmitBytes = data.readLong();
- this.transmitPackets = data.readLong();
- this.transmitErrors = data.readLong();
- }
-
- @Override
- public void writeTo(ChannelBuffer data) {
- data.writeShort(this.portNumber);
- data.writeShort((short) 0); // pad
- data.writeInt(this.queueId);
- data.writeLong(this.transmitBytes);
- data.writeLong(this.transmitPackets);
- data.writeLong(this.transmitErrors);
- }
-
- @Override
- public int hashCode() {
- final int prime = 439;
- int result = 1;
- result = prime * result + portNumber;
- result = prime * result + queueId;
- result = prime * result
- + (int) (transmitBytes ^ (transmitBytes >>> 32));
- result = prime * result
- + (int) (transmitErrors ^ (transmitErrors >>> 32));
- result = prime * result
- + (int) (transmitPackets ^ (transmitPackets >>> 32));
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof OFQueueStatisticsReply)) {
- return false;
- }
- OFQueueStatisticsReply other = (OFQueueStatisticsReply) obj;
- if (portNumber != other.portNumber) {
- return false;
- }
- if (queueId != other.queueId) {
- return false;
- }
- if (transmitBytes != other.transmitBytes) {
- return false;
- }
- if (transmitErrors != other.transmitErrors) {
- return false;
- }
- if (transmitPackets != other.transmitPackets) {
- return false;
- }
- return true;
- }
-}
diff --git a/src/main/java/org/openflow/protocol/statistics/OFQueueStatisticsRequest.java b/src/main/java/org/openflow/protocol/statistics/OFQueueStatisticsRequest.java
deleted file mode 100644
index 3331453..0000000
--- a/src/main/java/org/openflow/protocol/statistics/OFQueueStatisticsRequest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol.statistics;
-
-
-import org.jboss.netty.buffer.ChannelBuffer;
-
-/**
- * Represents an ofp_queue_stats_request structure
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-public class OFQueueStatisticsRequest implements OFStatistics {
- protected short portNumber;
- protected int queueId;
-
- /**
- * @return the portNumber
- */
- public short getPortNumber() {
- return portNumber;
- }
-
- /**
- * @param portNumber the portNumber to set
- */
- public void setPortNumber(short portNumber) {
- this.portNumber = portNumber;
- }
-
- /**
- * @return the queueId
- */
- public int getQueueId() {
- return queueId;
- }
-
- /**
- * @param queueId the queueId to set
- */
- public void setQueueId(int queueId) {
- this.queueId = queueId;
- }
-
- @Override
- public int getLength() {
- return 8;
- }
-
- @Override
- public void readFrom(ChannelBuffer data) {
- this.portNumber = data.readShort();
- data.readShort(); // pad
- this.queueId = data.readInt();
- }
-
- @Override
- public void writeTo(ChannelBuffer data) {
- data.writeShort(this.portNumber);
- data.writeShort((short) 0); // pad
- data.writeInt(this.queueId);
- }
-
- @Override
- public int hashCode() {
- final int prime = 443;
- int result = 1;
- result = prime * result + portNumber;
- result = prime * result + queueId;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof OFQueueStatisticsRequest)) {
- return false;
- }
- OFQueueStatisticsRequest other = (OFQueueStatisticsRequest) obj;
- if (portNumber != other.portNumber) {
- return false;
- }
- if (queueId != other.queueId) {
- return false;
- }
- return true;
- }
-}
diff --git a/src/main/java/org/openflow/protocol/statistics/OFStatistics.java b/src/main/java/org/openflow/protocol/statistics/OFStatistics.java
deleted file mode 100644
index 5e8f4dd..0000000
--- a/src/main/java/org/openflow/protocol/statistics/OFStatistics.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol.statistics;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-
-/**
- * The base class for all OpenFlow statistics.
- *
- * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010
- */
-public interface OFStatistics {
- /**
- * Returns the wire length of this message in bytes
- * @return the length
- */
- public int getLength();
-
- /**
- * Read this message off the wire from the specified ByteBuffer
- * @param data
- */
- public void readFrom(ChannelBuffer data);
-
- /**
- * Write this message's binary format to the specified ByteBuffer
- * @param data
- */
- public void writeTo(ChannelBuffer data);
-}
diff --git a/src/main/java/org/openflow/protocol/statistics/OFStatisticsType.java b/src/main/java/org/openflow/protocol/statistics/OFStatisticsType.java
deleted file mode 100644
index 4a84674..0000000
--- a/src/main/java/org/openflow/protocol/statistics/OFStatisticsType.java
+++ /dev/null
@@ -1,318 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol.statistics;
-
-import java.lang.reflect.Constructor;
-
-import org.openflow.protocol.Instantiable;
-import org.openflow.protocol.OFType;
-
-@SuppressWarnings("rawtypes")
-public enum OFStatisticsType {
- DESC (0, OFDescriptionStatistics.class, OFDescriptionStatistics.class,
- new Instantiable<OFStatistics>() {
- @Override
- public OFStatistics instantiate() {
- return new OFDescriptionStatistics();
- }
- },
- new Instantiable<OFStatistics>() {
- @Override
- public OFStatistics instantiate() {
- return new OFDescriptionStatistics();
- }
- }),
- FLOW (1, OFFlowStatisticsRequest.class, OFFlowStatisticsReply.class,
- new Instantiable<OFStatistics>() {
- @Override
- public OFStatistics instantiate() {
- return new OFFlowStatisticsRequest();
- }
- },
- new Instantiable<OFStatistics>() {
- @Override
- public OFStatistics instantiate() {
- return new OFFlowStatisticsReply();
- }
- }),
- AGGREGATE (2, OFAggregateStatisticsRequest.class, OFAggregateStatisticsReply.class,
- new Instantiable<OFStatistics>() {
- @Override
- public OFStatistics instantiate() {
- return new OFAggregateStatisticsRequest();
- }
- },
- new Instantiable<OFStatistics>() {
- @Override
- public OFStatistics instantiate() {
- return new OFAggregateStatisticsReply();
- }
- }),
- TABLE (3, OFTableStatistics.class, OFTableStatistics.class,
- new Instantiable<OFStatistics>() {
- @Override
- public OFStatistics instantiate() {
- return new OFTableStatistics();
- }
- },
- new Instantiable<OFStatistics>() {
- @Override
- public OFStatistics instantiate() {
- return new OFTableStatistics();
- }
- }),
- PORT (4, OFPortStatisticsRequest.class, OFPortStatisticsReply.class,
- new Instantiable<OFStatistics>() {
- @Override
- public OFStatistics instantiate() {
- return new OFPortStatisticsRequest();
- }
- },
- new Instantiable<OFStatistics>() {
- @Override
- public OFStatistics instantiate() {
- return new OFPortStatisticsReply();
- }
- }),
- QUEUE (5, OFQueueStatisticsRequest.class, OFQueueStatisticsReply.class,
- new Instantiable<OFStatistics>() {
- @Override
- public OFStatistics instantiate() {
- return new OFQueueStatisticsRequest();
- }
- },
- new Instantiable<OFStatistics>() {
- @Override
- public OFStatistics instantiate() {
- return new OFQueueStatisticsReply();
- }
- }),
- VENDOR (0xffff, OFVendorStatistics.class, OFVendorStatistics.class,
- new Instantiable<OFStatistics>() {
- @Override
- public OFStatistics instantiate() {
- return new OFVendorStatistics();
- }
- },
- new Instantiable<OFStatistics>() {
- @Override
- public OFStatistics instantiate() {
- return new OFVendorStatistics();
- }
- });
-
- static OFStatisticsType[] requestMapping;
- static OFStatisticsType[] replyMapping;
-
- protected Class<? extends OFStatistics> requestClass;
- protected Constructor<? extends OFStatistics> requestConstructor;
- protected Instantiable<OFStatistics> requestInstantiable;
- protected Class<? extends OFStatistics> replyClass;
- protected Constructor<? extends OFStatistics> replyConstructor;
- protected Instantiable<OFStatistics> replyInstantiable;
- protected short type;
-
- /**
- * Store some information about the OpenFlow Statistic type, including wire
- * protocol type number, and derived class
- *
- * @param type Wire protocol number associated with this OFStatisticsType
- * @param requestClass The Statistics Java class to return when the
- * containing OFType is STATS_REQUEST
- * @param replyClass The Statistics Java class to return when the
- * containing OFType is STATS_REPLY
- */
- OFStatisticsType(int type, Class<? extends OFStatistics> requestClass,
- Class<? extends OFStatistics> replyClass,
- Instantiable<OFStatistics> requestInstantiable,
- Instantiable<OFStatistics> replyInstantiable) {
- this.type = (short) type;
- this.requestClass = requestClass;
- try {
- this.requestConstructor = requestClass.getConstructor(new Class[]{});
- } catch (Exception e) {
- throw new RuntimeException(
- "Failure getting constructor for class: " + requestClass, e);
- }
-
- this.replyClass = replyClass;
- try {
- this.replyConstructor = replyClass.getConstructor(new Class[]{});
- } catch (Exception e) {
- throw new RuntimeException(
- "Failure getting constructor for class: " + replyClass, e);
- }
- this.requestInstantiable = requestInstantiable;
- this.replyInstantiable = replyInstantiable;
- OFStatisticsType.addMapping(this.type, OFType.STATS_REQUEST, this);
- OFStatisticsType.addMapping(this.type, OFType.STATS_REPLY, this);
- }
-
- /**
- * Adds a mapping from type value to OFStatisticsType enum
- *
- * @param i OpenFlow wire protocol type
- * @param t type of containing OFMessage, only accepts STATS_REQUEST or
- * STATS_REPLY
- * @param st type
- */
- static public void addMapping(short i, OFType t, OFStatisticsType st) {
- if (i < 0)
- i = (short) (16+i);
- if (t == OFType.STATS_REQUEST) {
- if (requestMapping == null)
- requestMapping = new OFStatisticsType[16];
- OFStatisticsType.requestMapping[i] = st;
- } else if (t == OFType.STATS_REPLY){
- if (replyMapping == null)
- replyMapping = new OFStatisticsType[16];
- OFStatisticsType.replyMapping[i] = st;
- } else {
- throw new RuntimeException(t.toString() + " is an invalid OFType");
- }
- }
-
- /**
- * Remove a mapping from type value to OFStatisticsType enum
- *
- * @param i OpenFlow wire protocol type
- * @param t type of containing OFMessage, only accepts STATS_REQUEST or
- * STATS_REPLY
- */
- static public void removeMapping(short i, OFType t) {
- if (i < 0)
- i = (short) (16+i);
- if (t == OFType.STATS_REQUEST) {
- requestMapping[i] = null;
- } else if (t == OFType.STATS_REPLY){
- replyMapping[i] = null;
- } else {
- throw new RuntimeException(t.toString() + " is an invalid OFType");
- }
- }
-
- /**
- * Given a wire protocol OpenFlow type number, return the OFStatisticsType
- * associated with it
- *
- * @param i wire protocol number
- * @param t type of containing OFMessage, only accepts STATS_REQUEST or
- * STATS_REPLY
- * @return OFStatisticsType enum type
- */
- static public OFStatisticsType valueOf(short i, OFType t) {
- if (i < 0)
- i = (short) (16+i);
- if (t == OFType.STATS_REQUEST) {
- return requestMapping[i];
- } else if (t == OFType.STATS_REPLY){
- return replyMapping[i];
- } else {
- throw new RuntimeException(t.toString() + " is an invalid OFType");
- }
- }
-
- /**
- * @return Returns the wire protocol value corresponding to this
- * OFStatisticsType
- */
- public short getTypeValue() {
- return this.type;
- }
-
- /**
- * @param t type of containing OFMessage, only accepts STATS_REQUEST or
- * STATS_REPLY
- * @return return the OFMessage subclass corresponding to this
- * OFStatisticsType
- */
- public Class<? extends OFStatistics> toClass(OFType t) {
- if (t == OFType.STATS_REQUEST) {
- return requestClass;
- } else if (t == OFType.STATS_REPLY){
- return replyClass;
- } else {
- throw new RuntimeException(t.toString() + " is an invalid OFType");
- }
- }
-
- /**
- * Returns the no-argument Constructor of the implementation class for
- * this OFStatisticsType, either request or reply based on the supplied
- * OFType
- *
- * @param t
- * @return
- */
- public Constructor<? extends OFStatistics> getConstructor(OFType t) {
- if (t == OFType.STATS_REQUEST) {
- return requestConstructor;
- } else if (t == OFType.STATS_REPLY) {
- return replyConstructor;
- } else {
- throw new RuntimeException(t.toString() + " is an invalid OFType");
- }
- }
-
- /**
- * @return the requestInstantiable
- */
- public Instantiable<OFStatistics> getRequestInstantiable() {
- return requestInstantiable;
- }
-
- /**
- * @param requestInstantiable the requestInstantiable to set
- */
- public void setRequestInstantiable(
- Instantiable<OFStatistics> requestInstantiable) {
- this.requestInstantiable = requestInstantiable;
- }
-
- /**
- * @return the replyInstantiable
- */
- public Instantiable<OFStatistics> getReplyInstantiable() {
- return replyInstantiable;
- }
-
- /**
- * @param replyInstantiable the replyInstantiable to set
- */
- public void setReplyInstantiable(Instantiable<OFStatistics> replyInstantiable) {
- this.replyInstantiable = replyInstantiable;
- }
-
- /**
- * Returns a new instance of the implementation class for
- * this OFStatisticsType, either request or reply based on the supplied
- * OFType
- *
- * @param t
- * @return
- */
- public OFStatistics newInstance(OFType t) {
- if (t == OFType.STATS_REQUEST) {
- return requestInstantiable.instantiate();
- } else if (t == OFType.STATS_REPLY) {
- return replyInstantiable.instantiate();
- } else {
- throw new RuntimeException(t.toString() + " is an invalid OFType");
- }
- }
-}
diff --git a/src/main/java/org/openflow/protocol/statistics/OFTableStatistics.java b/src/main/java/org/openflow/protocol/statistics/OFTableStatistics.java
deleted file mode 100644
index 9e6d34e..0000000
--- a/src/main/java/org/openflow/protocol/statistics/OFTableStatistics.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol.statistics;
-
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.openflow.util.StringByteSerializer;
-
-/**
- * Represents an ofp_table_stats structure
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-public class OFTableStatistics implements OFStatistics {
- public static int MAX_TABLE_NAME_LEN = 32;
-
- protected byte tableId;
- protected String name;
- protected int wildcards;
- protected int maximumEntries;
- protected int activeCount;
- protected long lookupCount;
- protected long matchedCount;
-
- /**
- * @return the tableId
- */
- public byte getTableId() {
- return tableId;
- }
-
- /**
- * @param tableId the tableId to set
- */
- public void setTableId(byte tableId) {
- this.tableId = tableId;
- }
-
- /**
- * @return the name
- */
- public String getName() {
- return name;
- }
-
- /**
- * @param name the name to set
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * @return the wildcards
- */
- public int getWildcards() {
- return wildcards;
- }
-
- /**
- * @param wildcards the wildcards to set
- */
- public void setWildcards(int wildcards) {
- this.wildcards = wildcards;
- }
-
- /**
- * @return the maximumEntries
- */
- public int getMaximumEntries() {
- return maximumEntries;
- }
-
- /**
- * @param maximumEntries the maximumEntries to set
- */
- public void setMaximumEntries(int maximumEntries) {
- this.maximumEntries = maximumEntries;
- }
-
- /**
- * @return the activeCount
- */
- public int getActiveCount() {
- return activeCount;
- }
-
- /**
- * @param activeCount the activeCount to set
- */
- public void setActiveCount(int activeCount) {
- this.activeCount = activeCount;
- }
-
- /**
- * @return the lookupCount
- */
- public long getLookupCount() {
- return lookupCount;
- }
-
- /**
- * @param lookupCount the lookupCount to set
- */
- public void setLookupCount(long lookupCount) {
- this.lookupCount = lookupCount;
- }
-
- /**
- * @return the matchedCount
- */
- public long getMatchedCount() {
- return matchedCount;
- }
-
- /**
- * @param matchedCount the matchedCount to set
- */
- public void setMatchedCount(long matchedCount) {
- this.matchedCount = matchedCount;
- }
-
- @Override
- public int getLength() {
- return 64;
- }
-
- @Override
- public void readFrom(ChannelBuffer data) {
- this.tableId = data.readByte();
- data.readByte(); // pad
- data.readByte(); // pad
- data.readByte(); // pad
- this.name = StringByteSerializer.readFrom(data, MAX_TABLE_NAME_LEN);
- this.wildcards = data.readInt();
- this.maximumEntries = data.readInt();
- this.activeCount = data.readInt();
- this.lookupCount = data.readLong();
- this.matchedCount = data.readLong();
- }
-
- @Override
- public void writeTo(ChannelBuffer data) {
- data.writeByte(this.tableId);
- data.writeByte((byte) 0); // pad
- data.writeByte((byte) 0); // pad
- data.writeByte((byte) 0); // pad
- StringByteSerializer.writeTo(data, MAX_TABLE_NAME_LEN, this.name);
- data.writeInt(this.wildcards);
- data.writeInt(this.maximumEntries);
- data.writeInt(this.activeCount);
- data.writeLong(this.lookupCount);
- data.writeLong(this.matchedCount);
- }
-
- @Override
- public int hashCode() {
- final int prime = 449;
- int result = 1;
- result = prime * result + activeCount;
- result = prime * result + (int) (lookupCount ^ (lookupCount >>> 32));
- result = prime * result + (int) (matchedCount ^ (matchedCount >>> 32));
- result = prime * result + maximumEntries;
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- result = prime * result + tableId;
- result = prime * result + wildcards;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof OFTableStatistics)) {
- return false;
- }
- OFTableStatistics other = (OFTableStatistics) obj;
- if (activeCount != other.activeCount) {
- return false;
- }
- if (lookupCount != other.lookupCount) {
- return false;
- }
- if (matchedCount != other.matchedCount) {
- return false;
- }
- if (maximumEntries != other.maximumEntries) {
- return false;
- }
- if (name == null) {
- if (other.name != null) {
- return false;
- }
- } else if (!name.equals(other.name)) {
- return false;
- }
- if (tableId != other.tableId) {
- return false;
- }
- if (wildcards != other.wildcards) {
- return false;
- }
- return true;
- }
-}
diff --git a/src/main/java/org/openflow/protocol/statistics/OFVendorStatistics.java b/src/main/java/org/openflow/protocol/statistics/OFVendorStatistics.java
deleted file mode 100644
index 0257a6a..0000000
--- a/src/main/java/org/openflow/protocol/statistics/OFVendorStatistics.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol.statistics;
-
-
-import org.jboss.netty.buffer.ChannelBuffer;
-
-/**
- * The base class for vendor implemented statistics
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-public class OFVendorStatistics implements OFStatistics {
- protected int vendor;
- protected byte[] body;
-
- // non-message fields
- protected int length = 0;
-
- @Override
- public void readFrom(ChannelBuffer data) {
- this.vendor = data.readInt();
- if (body == null)
- body = new byte[length - 4];
- data.readBytes(body);
- }
-
- @Override
- public void writeTo(ChannelBuffer data) {
- data.writeInt(this.vendor);
- if (body != null)
- data.writeBytes(body);
- }
-
- @Override
- public int hashCode() {
- final int prime = 457;
- int result = 1;
- result = prime * result + vendor;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof OFVendorStatistics)) {
- return false;
- }
- OFVendorStatistics other = (OFVendorStatistics) obj;
- if (vendor != other.vendor) {
- return false;
- }
- return true;
- }
-
- @Override
- public int getLength() {
- return length;
- }
-
- public void setLength(int length) {
- this.length = length;
- }
-}
diff --git a/src/main/java/org/openflow/protocol/vendor/OFBasicVendorDataType.java b/src/main/java/org/openflow/protocol/vendor/OFBasicVendorDataType.java
deleted file mode 100644
index 1f0e14b..0000000
--- a/src/main/java/org/openflow/protocol/vendor/OFBasicVendorDataType.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
-* Copyright 2011, Big Switch Networks, Inc.
-* Originally created by David Erickson & Rob Sherwood, Stanford University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol.vendor;
-
-import org.openflow.protocol.Instantiable;
-
-/**
- * Subclass of OFVendorDataType that works with any vendor data format that
- * begins with a integral value to indicate the format of the remaining data.
- * It maps from the per-vendor-id integral data type code to the object
- * used to instantiate the class associated with that vendor data type.
- *
- * @author Rob Vaterlaus (rob.vaterlaus@bigswitch.com)
- */
-public class OFBasicVendorDataType extends OFVendorDataType {
-
- /**
- * The data type value at the beginning of the vendor data.
- */
- protected long type;
-
- /**
- * Construct an empty (i.e. no specified data type value) vendor data type.
- */
- public OFBasicVendorDataType() {
- super();
- this.type = 0;
- }
-
- /**
- * Store some information about the vendor data type, including wire protocol
- * type number, derived class and instantiator.
- *
- * @param type Wire protocol number associated with this vendor data type
- * @param instantiator An Instantiator<OFVendorData> implementation that
- * creates an instance of an appropriate subclass of OFVendorData.
- */
- public OFBasicVendorDataType(long type, Instantiable<OFVendorData> instantiator) {
- super(instantiator);
- this.type = type;
- }
-
- /**
- * @return Returns the wire protocol value corresponding to this OFVendorDataType
- */
- public long getTypeValue() {
- return this.type;
- }
-
- /**
- * @param type the wire protocol value for this data type
- */
- public void setTypeValue(long type) {
- this.type = type;
- }
-}
diff --git a/src/main/java/org/openflow/protocol/vendor/OFBasicVendorId.java b/src/main/java/org/openflow/protocol/vendor/OFBasicVendorId.java
deleted file mode 100644
index 33bb0bd..0000000
--- a/src/main/java/org/openflow/protocol/vendor/OFBasicVendorId.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/**
-* Copyright 2011, Big Switch Networks, Inc.
-* Originally created by David Erickson & Rob Sherwood, Stanford University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol.vendor;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.openflow.protocol.Instantiable;
-
-/**
- * Basic subclass of OFVendorId that works with any vendor data format where
- * the data begins with an integral data type value.
- *
- * @author Rob Vaterlaus (rob.vaterlaus@bigswitch.com)
- */
-public class OFBasicVendorId extends OFVendorId {
-
- /**
- * The size of the data type value at the beginning of all vendor
- * data associated with this vendor id. The data type size must be
- * either 1, 2, 4 or 8.
- */
- protected int dataTypeSize;
-
- /**
- * Map of the vendor data types that have been registered for this
- * vendor id.
- */
- protected Map<Long, OFBasicVendorDataType> dataTypeMap =
- new HashMap<Long, OFBasicVendorDataType>();
-
- /**
- * Construct an OFVendorId that where the vendor data begins
- * with a data type value whose size is dataTypeSize.
- * @param id the id of the vendor, typically the OUI of a vendor
- * prefixed with 0.
- * @param dataTypeSize the size of the integral data type value
- * at the beginning of the vendor data. The value must be the
- * size of an integeral data type (i.e. either 1,2,4 or 8).
- */
- public OFBasicVendorId(int id, int dataTypeSize) {
- super(id);
- assert (dataTypeSize == 1) || (dataTypeSize == 2) ||
- (dataTypeSize == 4) || (dataTypeSize == 8);
- this.dataTypeSize = dataTypeSize;
- }
-
- /**
- * Get the size of the data type value at the beginning of the vendor
- * data. OFBasicVendorId assumes that this value is common across all of
- * the vendor data formats associated with a given vendor id.
- * @return
- */
- public int getDataTypeSize() {
- return dataTypeSize;
- }
-
- /**
- * Register a vendor data type with this vendor id.
- * @param vendorDataType
- */
- public void registerVendorDataType(OFBasicVendorDataType vendorDataType) {
- dataTypeMap.put(vendorDataType.getTypeValue(), vendorDataType);
- }
-
- /**
- * Lookup the OFVendorDataType instance that has been registered with
- * this vendor id.
- *
- * @param vendorDataType the integer code that was parsed from the
- * @return
- */
- public OFVendorDataType lookupVendorDataType(int vendorDataType) {
- return dataTypeMap.get((long)vendorDataType);
- }
-
- /**
- * This function parses enough of the data from the buffer to be able
- * to determine the appropriate OFVendorDataType for the data. It is meant
- * to be a reasonably generic implementation that will work for most
- * formats of vendor extensions. If the vendor data doesn't fit the
- * assumptions listed below, then this method will need to be overridden
- * to implement custom parsing.
- *
- * This implementation assumes that the vendor data begins with a data
- * type code that is used to distinguish different formats of vendor
- * data associated with a particular vendor ID.
- * The exact format of the data is vendor-defined, so we don't know how
- * how big the code is (or really even if there is a code). This code
- * assumes that the common case will be that the data does include
- * an initial type code (i.e. so that the vendor can have multiple
- * message/data types) and that the size is either 1, 2 or 4 bytes.
- * The size of the initial type code is configured by the subclass of
- * OFVendorId.
- *
- * @param data the channel buffer containing the vendor data.
- * @param length the length to the end of the enclosing message
- * @return the OFVendorDataType that can be used to instantiate the
- * appropriate subclass of OFVendorData.
- */
- public OFVendorDataType parseVendorDataType(ChannelBuffer data, int length) {
- OFVendorDataType vendorDataType = null;
-
- // Parse out the type code from the vendor data.
- long dataTypeValue = 0;
- if ((length == 0) || (length >= dataTypeSize)) {
- switch (dataTypeSize) {
- case 1:
- dataTypeValue = data.readByte();
- break;
- case 2:
- dataTypeValue = data.readShort();
- break;
- case 4:
- dataTypeValue = data.readInt();
- break;
- case 8:
- dataTypeValue = data.readLong();
- break;
- default:
- // This would be indicative of a coding error where the
- // dataTypeSize was specified incorrectly. This should have been
- // caught in the constructor for OFVendorId.
- assert false;
- }
-
- vendorDataType = dataTypeMap.get(dataTypeValue);
- }
-
- // If we weren't able to parse/map the data to a known OFVendorDataType,
- // then map it to a generic vendor data type.
- if (vendorDataType == null) {
- vendorDataType = new OFBasicVendorDataType(dataTypeValue,
- new Instantiable<OFVendorData>() {
- @Override
- public OFVendorData instantiate() {
- return new OFByteArrayVendorData();
- }
- }
- );
- }
-
- return vendorDataType;
- }
-
-}
diff --git a/src/main/java/org/openflow/protocol/vendor/OFByteArrayVendorData.java b/src/main/java/org/openflow/protocol/vendor/OFByteArrayVendorData.java
deleted file mode 100644
index 08fa003..0000000
--- a/src/main/java/org/openflow/protocol/vendor/OFByteArrayVendorData.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
-* Copyright 2011, Big Switch Networks, Inc.
-* Originally created by David Erickson & Rob Sherwood, Stanford University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol.vendor;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-
-/**
- * Basic implementation of OFVendorData that just treats the data as a
- * byte array. This is used if there's an OFVendor message where there's
- * no registered OFVendorId or no specific OFVendorDataType that can be
- * determined from the data.
- *
- * @author Rob Vaterlaus (rob.vaterlaus@bigswitch.com)
- */
-public class OFByteArrayVendorData implements OFVendorData {
-
- protected byte[] bytes;
-
- /**
- * Construct vendor data with an empty byte array.
- */
- public OFByteArrayVendorData() {
- }
-
- /**
- * Construct vendor data with the specified byte array.
- * @param bytes
- */
- public OFByteArrayVendorData(byte[] bytes) {
- this.bytes = bytes;
- }
-
- /**
- * Get the associated byte array for this vendor data.
- * @return the byte array containing the raw vendor data.
- */
- public byte[] getBytes() {
- return bytes;
- }
-
- /**
- * Set the byte array for the vendor data.
- * @param bytes the raw byte array containing the vendor data.
- */
- public void setBytes(byte[] bytes) {
- this.bytes = bytes;
- }
-
- /**
- * Get the length of the vendor data. In this case it's just then length
- * of the underlying byte array.
- * @return the length of the vendor data
- */
- @Override
- public int getLength() {
- return (bytes != null) ? bytes.length : 0;
- }
-
- /**
- * Read the vendor data from the ChannelBuffer into the byte array.
- * @param data the channel buffer from which we're deserializing
- * @param length the length to the end of the enclosing message
- */
- @Override
- public void readFrom(ChannelBuffer data, int length) {
- bytes = new byte[length];
- data.readBytes(bytes);
- }
-
- /**
- * Write the vendor data bytes to the ChannelBuffer
- * @param data the channel buffer to which we're serializing
- */
- @Override
- public void writeTo(ChannelBuffer data) {
- if (bytes != null)
- data.writeBytes(bytes);
- }
-}
diff --git a/src/main/java/org/openflow/protocol/vendor/OFVendorData.java b/src/main/java/org/openflow/protocol/vendor/OFVendorData.java
deleted file mode 100644
index 6dfb4e6..0000000
--- a/src/main/java/org/openflow/protocol/vendor/OFVendorData.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
-* Copyright 2011, Big Switch Networks, Inc.
-* Originally created by David Erickson & Rob Sherwood, Stanford University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol.vendor;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-
-/**
- * The base class for all vendor data.
- *
- * @author Rob Vaterlaus (rob.vaterlaus@bigswitch.com)
- */
-public interface OFVendorData {
- /**
- * @return length of the data
- */
- public int getLength();
-
- /**
- * Read the vendor data from the specified ChannelBuffer
- * @param data
- */
- public void readFrom(ChannelBuffer data, int length);
-
- /**
- * Write the vendor data to the specified ChannelBuffer
- * @param data
- */
- public void writeTo(ChannelBuffer data);
-}
diff --git a/src/main/java/org/openflow/protocol/vendor/OFVendorDataType.java b/src/main/java/org/openflow/protocol/vendor/OFVendorDataType.java
deleted file mode 100644
index ecae482..0000000
--- a/src/main/java/org/openflow/protocol/vendor/OFVendorDataType.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
-* Copyright 2011, Big Switch Networks, Inc.
-* Originally created by David Erickson & Rob Sherwood, Stanford University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol.vendor;
-
-import org.openflow.protocol.Instantiable;
-
-/**
- * Class that represents a specific vendor data type format in an
- * OFVendor message. Typically the vendor data will begin with an integer
- * code that determines the format of the rest of the data, but this
- * class does not assume that. It's basically just a holder for an
- * instantiator of the appropriate subclass of OFVendorData.
- *
- * @author Rob Vaterlaus (rob.vaterlaus@bigswitch.com)
- */
-public class OFVendorDataType {
-
- /**
- * Object that instantiates the subclass of OFVendorData
- * associated with this data type.
- */
- protected Instantiable<OFVendorData> instantiable;
-
- /**
- * Construct an empty vendor data type.
- */
- public OFVendorDataType() {
- super();
- }
-
- /**
- * Construct a vendor data type with the specified instantiable.
- * @param instantiable object that creates the subclass of OFVendorData
- * associated with this data type.
- */
- public OFVendorDataType(Instantiable<OFVendorData> instantiable) {
- this.instantiable = instantiable;
- }
-
- /**
- * Returns a new instance of a subclass of OFVendorData associated with
- * this OFVendorDataType.
- *
- * @return the new object
- */
- public OFVendorData newInstance() {
- return instantiable.instantiate();
- }
-
- /**
- * @return the instantiable
- */
- public Instantiable<OFVendorData> getInstantiable() {
- return instantiable;
- }
-
- /**
- * @param instantiable the instantiable to set
- */
- public void setInstantiable(Instantiable<OFVendorData> instantiable) {
- this.instantiable = instantiable;
- }
-
-}
diff --git a/src/main/java/org/openflow/protocol/vendor/OFVendorId.java b/src/main/java/org/openflow/protocol/vendor/OFVendorId.java
deleted file mode 100644
index f0af8a7..0000000
--- a/src/main/java/org/openflow/protocol/vendor/OFVendorId.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
-* Copyright 2011, Big Switch Networks, Inc.
-* Originally created by David Erickson & Rob Sherwood, Stanford University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol.vendor;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-
-/**
- * Base class for the vendor ID corresponding to vendor extensions from a
- * given vendor. It is responsible for knowing how to parse out some sort of
- * data type value from the vendor data in an OFVendor message so that we can
- * dispatch to the different subclasses of OFVendorData corresponding to the
- * different formats of data for the vendor extensions.
- *
- * @author Rob Vaterlaus (rob.vaterlaus@bigswitch.com)
- */
-public abstract class OFVendorId {
- static Map<Integer, OFVendorId> mapping = new HashMap<Integer, OFVendorId>();
-
- /**
- * The vendor id value, typically the OUI of the vendor prefixed with 0.
- */
- protected int id;
-
- /**
- * Register a new vendor id.
- * @param vendorId the vendor id to register
- */
- public static void registerVendorId(OFVendorId vendorId) {
- mapping.put(vendorId.getId(), vendorId);
- }
-
- /**
- * Lookup the OFVendorId instance corresponding to the given id value.
- * @param id the integer vendor id value
- * @return the corresponding OFVendorId that's been registered for the
- * given value, or null if there id has not been registered.
- */
- public static OFVendorId lookupVendorId(int id) {
- return mapping.get(id);
- }
-
- /**
- * Create an OFVendorId with the give vendor id value
- * @param id
- */
- public OFVendorId(int id) {
- this.id = id;
- }
-
- /**
- * @return the vendor id value
- */
- public int getId() {
- return id;
- }
-
- /**
- * This function parses enough of the data from the channel buffer to be
- * able to determine the appropriate OFVendorDataType for the data.
- *
- * @param data the channel buffer containing the vendor data.
- * @param length the length to the end of the enclosing message
- * @return the OFVendorDataType that can be used to instantiate the
- * appropriate subclass of OFVendorData.
- */
- public abstract OFVendorDataType parseVendorDataType(ChannelBuffer data, int length);
-}
diff --git a/src/main/java/org/openflow/util/HexString.java b/src/main/java/org/openflow/util/HexString.java
deleted file mode 100644
index 08b05cd..0000000
--- a/src/main/java/org/openflow/util/HexString.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.util;
-
-import java.math.BigInteger;
-
-public class HexString {
- /**
- * Convert a string of bytes to a ':' separated hex string
- * @param bytes byte array to be converted to a hex string
- * @return "0f:ca:fe:de:ad:be:ef"
- */
- public static String toHexString(byte[] bytes) {
- int i;
- StringBuilder ret = new StringBuilder(8*2+7);
- String tmp;
- for(i=0; i< bytes.length; i++) {
- if(i> 0)
- ret.append(':');
- tmp = Integer.toHexString(U8.f(bytes[i]));
- if (tmp.length() == 1)
- ret.append('0');
- ret.append(tmp);
- }
- return ret.toString();
- }
-
- public static String toHexString(long val, int padTo) {
- char arr[] = Long.toHexString(val).toCharArray();
- StringBuilder ret = new StringBuilder(8*2+7);
- // prepend the right number of leading zeros
- int i = 0;
- for (; i < (padTo * 2 - arr.length); i++) {
- ret.append('0');
- if ((i & 1) == 1)
- ret.append(':');
- }
- for (int j = 0; j < arr.length; j++) {
- ret.append(arr[j]);
- if ((((i + j) & 1) == 1) && (j < (arr.length - 1)))
- ret.append(':');
- }
- return ret.toString();
- }
-
- public static String toHexString(long val) {
- return toHexString(val, 8);
- }
-
-
- /**
- * Convert a string of hex values into a string of bytes
- * @param values "0f:ca:fe:de:ad:be:ef"
- * @return [15, 5 ,2, 5, 17]
- * @throws NumberFormatException If the string can not be parsed
- */
- public static byte[] fromHexString(String values) throws NumberFormatException {
- String[] octets = values.split(":");
- byte[] ret = new byte[octets.length];
-
- for(int i = 0; i < octets.length; i++) {
- if (octets[i].length() > 2)
- throw new NumberFormatException("Invalid octet length");
- ret[i] = Integer.valueOf(octets[i], 16).byteValue();
- }
- return ret;
- }
-
- public static long toLong(String values) throws NumberFormatException {
- // Long.parseLong() can't handle HexStrings with MSB set. Sigh.
- BigInteger bi = new BigInteger(values.replaceAll(":", ""),16);
- if (bi.bitLength() > 64)
- throw new NumberFormatException("Input string too big to fit in long: " + values);
- return bi.longValue();
- }
-
-}
diff --git a/src/main/java/org/openflow/util/LRULinkedHashMap.java b/src/main/java/org/openflow/util/LRULinkedHashMap.java
deleted file mode 100644
index 7f05381..0000000
--- a/src/main/java/org/openflow/util/LRULinkedHashMap.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.util;
-
-import java.util.LinkedHashMap;
-
-public class LRULinkedHashMap<K, V> extends LinkedHashMap<K, V> {
- private static final long serialVersionUID = -2964986094089626647L;
- protected int maximumCapacity;
-
- public LRULinkedHashMap(int initialCapacity, int maximumCapacity) {
- super(initialCapacity, 0.75f, true);
- this.maximumCapacity = maximumCapacity;
- }
-
- public LRULinkedHashMap(int maximumCapacity) {
- super(16, 0.75f, true);
- this.maximumCapacity = maximumCapacity;
- }
-
- @Override
- protected boolean removeEldestEntry(java.util.Map.Entry<K, V> eldest) {
- if (this.size() > maximumCapacity)
- return true;
- return false;
- }
-}
diff --git a/src/main/java/org/openflow/util/StringByteSerializer.java b/src/main/java/org/openflow/util/StringByteSerializer.java
deleted file mode 100644
index 9287fd2..0000000
--- a/src/main/java/org/openflow/util/StringByteSerializer.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.util;
-
-import java.io.UnsupportedEncodingException;
-import java.nio.charset.Charset;
-import java.util.Arrays;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-
-public class StringByteSerializer {
- public static String readFrom(ChannelBuffer data, int length) {
- byte[] stringBytes = new byte[length];
- data.readBytes(stringBytes);
- // find the first index of 0
- int index = 0;
- for (byte b : stringBytes) {
- if (0 == b)
- break;
- ++index;
- }
- return new String(Arrays.copyOf(stringBytes, index),
- Charset.forName("ascii"));
- }
-
- public static void writeTo(ChannelBuffer data, int length, String value) {
- try {
- byte[] name = value.getBytes("ASCII");
- if (name.length < length) {
- data.writeBytes(name);
- for (int i = name.length; i < length; ++i) {
- data.writeByte((byte) 0);
- }
- } else {
- data.writeBytes(name, 0, length-1);
- data.writeByte((byte) 0);
- }
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException(e);
- }
-
- }
-}
diff --git a/src/main/java/org/openflow/util/U16.java b/src/main/java/org/openflow/util/U16.java
deleted file mode 100644
index 0d8917d..0000000
--- a/src/main/java/org/openflow/util/U16.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.util;
-
-public class U16 {
- public static int f(short i) {
- return (int)i & 0xffff;
- }
-
- public static short t(int l) {
- return (short) l;
- }
-}
diff --git a/src/main/java/org/openflow/util/U32.java b/src/main/java/org/openflow/util/U32.java
deleted file mode 100644
index 3aab400..0000000
--- a/src/main/java/org/openflow/util/U32.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.util;
-
-public class U32 {
- public static long f(int i) {
- return (long)i & 0xffffffffL;
- }
-
- public static int t(long l) {
- return (int) l;
- }
-}
diff --git a/src/main/java/org/openflow/util/U64.java b/src/main/java/org/openflow/util/U64.java
deleted file mode 100644
index c6ae0f7..0000000
--- a/src/main/java/org/openflow/util/U64.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.util;
-
-import java.math.BigInteger;
-
-public class U64 {
- public static BigInteger f(long i) {
- return new BigInteger(Long.toBinaryString(i), 2);
- }
-
- public static long t(BigInteger l) {
- return l.longValue();
- }
-}
diff --git a/src/main/java/org/openflow/util/U8.java b/src/main/java/org/openflow/util/U8.java
deleted file mode 100644
index 0b575ad..0000000
--- a/src/main/java/org/openflow/util/U8.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.util;
-
-public class U8 {
- public static short f(byte i) {
- return (short) ((short)i & 0xff);
- }
-
- public static byte t(short l) {
- return (byte) l;
- }
-}
diff --git a/src/main/java/org/openflow/util/Unsigned.java b/src/main/java/org/openflow/util/Unsigned.java
deleted file mode 100644
index 0754a3f..0000000
--- a/src/main/java/org/openflow/util/Unsigned.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.util;
-
-import java.math.BigInteger;
-import java.nio.ByteBuffer;
-
-/*****
- * A util library class for dealing with the lack of unsigned datatypes in Java
- *
- * @author Rob Sherwood (rob.sherwood@stanford.edu)
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-
-public class Unsigned {
- /**
- * Get an unsigned byte from the current position of the ByteBuffer
- *
- * @param bb ByteBuffer to get the byte from
- * @return an unsigned byte contained in a short
- */
- public static short getUnsignedByte(ByteBuffer bb) {
- return ((short) (bb.get() & (short) 0xff));
- }
-
- /**
- * Get an unsigned byte from the specified offset in the ByteBuffer
- *
- * @param bb ByteBuffer to get the byte from
- * @param offset the offset to get the byte from
- * @return an unsigned byte contained in a short
- */
- public static short getUnsignedByte(ByteBuffer bb, int offset) {
- return ((short) (bb.get(offset) & (short) 0xff));
- }
-
- /**
- * Put an unsigned byte into the specified ByteBuffer at the current
- * position
- *
- * @param bb ByteBuffer to put the byte into
- * @param v the short containing the unsigned byte
- */
- public static void putUnsignedByte(ByteBuffer bb, short v) {
- bb.put((byte) (v & 0xff));
- }
-
- /**
- * Put an unsigned byte into the specified ByteBuffer at the specified
- * offset
- *
- * @param bb ByteBuffer to put the byte into
- * @param v the short containing the unsigned byte
- * @param offset the offset to insert the unsigned byte at
- */
- public static void putUnsignedByte(ByteBuffer bb, short v, int offset) {
- bb.put(offset, (byte) (v & 0xff));
- }
-
- /**
- * Get an unsigned short from the current position of the ByteBuffer
- *
- * @param bb ByteBuffer to get the byte from
- * @return an unsigned short contained in a int
- */
- public static int getUnsignedShort(ByteBuffer bb) {
- return (bb.getShort() & 0xffff);
- }
-
- /**
- * Get an unsigned short from the specified offset in the ByteBuffer
- *
- * @param bb ByteBuffer to get the short from
- * @param offset the offset to get the short from
- * @return an unsigned short contained in a int
- */
- public static int getUnsignedShort(ByteBuffer bb, int offset) {
- return (bb.getShort(offset) & 0xffff);
- }
-
- /**
- * Put an unsigned short into the specified ByteBuffer at the current
- * position
- *
- * @param bb ByteBuffer to put the short into
- * @param v the int containing the unsigned short
- */
- public static void putUnsignedShort(ByteBuffer bb, int v) {
- bb.putShort((short) (v & 0xffff));
- }
-
- /**
- * Put an unsigned short into the specified ByteBuffer at the specified
- * offset
- *
- * @param bb ByteBuffer to put the short into
- * @param v the int containing the unsigned short
- * @param offset the offset to insert the unsigned short at
- */
- public static void putUnsignedShort(ByteBuffer bb, int v, int offset) {
- bb.putShort(offset, (short) (v & 0xffff));
- }
-
- /**
- * Get an unsigned int from the current position of the ByteBuffer
- *
- * @param bb ByteBuffer to get the int from
- * @return an unsigned int contained in a long
- */
- public static long getUnsignedInt(ByteBuffer bb) {
- return ((long) bb.getInt() & 0xffffffffL);
- }
-
- /**
- * Get an unsigned int from the specified offset in the ByteBuffer
- *
- * @param bb ByteBuffer to get the int from
- * @param offset the offset to get the int from
- * @return an unsigned int contained in a long
- */
- public static long getUnsignedInt(ByteBuffer bb, int offset) {
- return ((long) bb.getInt(offset) & 0xffffffffL);
- }
-
- /**
- * Put an unsigned int into the specified ByteBuffer at the current position
- *
- * @param bb ByteBuffer to put the int into
- * @param v the long containing the unsigned int
- */
- public static void putUnsignedInt(ByteBuffer bb, long v) {
- bb.putInt((int) (v & 0xffffffffL));
- }
-
- /**
- * Put an unsigned int into the specified ByteBuffer at the specified offset
- *
- * @param bb ByteBuffer to put the int into
- * @param v the long containing the unsigned int
- * @param offset the offset to insert the unsigned int at
- */
- public static void putUnsignedInt(ByteBuffer bb, long v, int offset) {
- bb.putInt(offset, (int) (v & 0xffffffffL));
- }
-
- /**
- * Get an unsigned long from the current position of the ByteBuffer
- *
- * @param bb ByteBuffer to get the long from
- * @return an unsigned long contained in a BigInteger
- */
- public static BigInteger getUnsignedLong(ByteBuffer bb) {
- byte[] v = new byte[8];
- for (int i = 0; i < 8; ++i) {
- v[i] = bb.get(i);
- }
- return new BigInteger(1, v);
- }
-
- /**
- * Get an unsigned long from the specified offset in the ByteBuffer
- *
- * @param bb ByteBuffer to get the long from
- * @param offset the offset to get the long from
- * @return an unsigned long contained in a BigInteger
- */
- public static BigInteger getUnsignedLong(ByteBuffer bb, int offset) {
- byte[] v = new byte[8];
- for (int i = 0; i < 8; ++i) {
- v[i] = bb.get(offset+i);
- }
- return new BigInteger(1, v);
- }
-
- /**
- * Put an unsigned long into the specified ByteBuffer at the current
- * position
- *
- * @param bb ByteBuffer to put the long into
- * @param v the BigInteger containing the unsigned long
- */
- public static void putUnsignedLong(ByteBuffer bb, BigInteger v) {
- bb.putLong(v.longValue());
- }
-
- /**
- * Put an unsigned long into the specified ByteBuffer at the specified
- * offset
- *
- * @param bb ByteBuffer to put the long into
- * @param v the BigInteger containing the unsigned long
- * @param offset the offset to insert the unsigned long at
- */
- public static void putUnsignedLong(ByteBuffer bb, BigInteger v, int offset) {
- bb.putLong(offset, v.longValue());
- }
-}
diff --git a/src/main/java/org/openflow/vendor/nicira/OFNiciraVendorData.java b/src/main/java/org/openflow/vendor/nicira/OFNiciraVendorData.java
deleted file mode 100644
index 687d544..0000000
--- a/src/main/java/org/openflow/vendor/nicira/OFNiciraVendorData.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/**
-* Copyright 2011, Big Switch Networks, Inc.
-* Originally created by David Erickson & Rob Sherwood, Stanford University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.vendor.nicira;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.openflow.protocol.vendor.OFVendorData;
-
-/**
- * Base class for vendor data corresponding to a Nicira vendor extension.
- * Nicira vendor data always starts with a 4-byte integer data type value.
- *
- * @author Rob Vaterlaus (rob.vaterlaus@bigswitch.com)
- */
-public class OFNiciraVendorData implements OFVendorData {
-
- public static final int NX_VENDOR_ID = 0x00002320;
- /**
- * The value of the integer data type at the beginning of the vendor data
- */
- protected int dataType;
-
- /**
- * Construct empty (i.e. unspecified data type) Nicira vendor data.
- */
- public OFNiciraVendorData() {
- }
-
- /**
- * Contruct Nicira vendor data with the specified data type
- * @param dataType the data type value at the beginning of the vendor data.
- */
- public OFNiciraVendorData(int dataType) {
- this.dataType = dataType;
- }
-
- /**
- * Get the data type value at the beginning of the vendor data
- * @return the integer data type value
- */
- public int getDataType() {
- return dataType;
- }
-
- /**
- * Set the data type value
- * @param dataType the integer data type value at the beginning of the
- * vendor data.
- */
- public void setDataType(int dataType) {
- this.dataType = dataType;
- }
-
- /**
- * Get the length of the vendor data. This implementation will normally
- * be the superclass for another class that will override this to return
- * the overall vendor data length. This implementation just returns the
- * length of the part that includes the 4-byte integer data type value
- * at the beginning of the vendor data.
- */
- @Override
- public int getLength() {
- return 4;
- }
-
- /**
- * Read the vendor data from the ChannelBuffer
- * @param data the channel buffer from which we're deserializing
- * @param length the length to the end of the enclosing message
- */
- @Override
- public void readFrom(ChannelBuffer data, int length) {
- dataType = data.readInt();
- }
-
- /**
- * Write the vendor data to the ChannelBuffer
- * @param data the channel buffer to which we're serializing
- */
- @Override
- public void writeTo(ChannelBuffer data) {
- data.writeInt(dataType);
- }
-}
diff --git a/src/main/java/org/openflow/vendor/nicira/OFRoleReplyVendorData.java b/src/main/java/org/openflow/vendor/nicira/OFRoleReplyVendorData.java
deleted file mode 100644
index fa28c71..0000000
--- a/src/main/java/org/openflow/vendor/nicira/OFRoleReplyVendorData.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
-* Copyright 2011, Big Switch Networks, Inc.
-* Originally created by David Erickson & Rob Sherwood, Stanford University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.vendor.nicira;
-
-import org.openflow.protocol.Instantiable;
-import org.openflow.protocol.vendor.OFVendorData;
-
-/**
- * Subclass of OFVendorData representing the vendor data associated with
- * a role reply vendor extension.
- *
- * @author Rob Vaterlaus (rob.vaterlaus@bigswitch.com)
- */
-public class OFRoleReplyVendorData extends OFRoleVendorData {
-
- protected static Instantiable<OFVendorData> instantiable =
- new Instantiable<OFVendorData>() {
- public OFVendorData instantiate() {
- return new OFRoleReplyVendorData();
- }
- };
-
- /**
- * @return a subclass of Instantiable<OFVendorData> that instantiates
- * an instance of OFRoleReplyVendorData.
- */
- public static Instantiable<OFVendorData> getInstantiable() {
- return instantiable;
- }
-
- /**
- * The data type value for a role reply
- */
- public static final int NXT_ROLE_REPLY = 11;
-
- /**
- * Construct a role reply vendor data with an unspecified role value.
- */
- public OFRoleReplyVendorData() {
- super(NXT_ROLE_REPLY);
- }
-
- /**
- * Construct a role reply vendor data with the specified role value.
- * @param role the role value for the role reply. Should be one of
- * NX_ROLE_OTHER, NX_ROLE_MASTER or NX_ROLE_SLAVE.
- */
- public OFRoleReplyVendorData(int role) {
- super(NXT_ROLE_REPLY, role);
- }
-}
diff --git a/src/main/java/org/openflow/vendor/nicira/OFRoleRequestVendorData.java b/src/main/java/org/openflow/vendor/nicira/OFRoleRequestVendorData.java
deleted file mode 100644
index e7dbe71..0000000
--- a/src/main/java/org/openflow/vendor/nicira/OFRoleRequestVendorData.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
-* Copyright 2011, Big Switch Networks, Inc.
-* Originally created by David Erickson & Rob Sherwood, Stanford University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.vendor.nicira;
-
-import org.openflow.protocol.Instantiable;
-import org.openflow.protocol.vendor.OFVendorData;
-
-/**
- * Subclass of OFVendorData representing the vendor data associated with
- * a role request vendor extension.
- *
- * @author Rob Vaterlaus (rob.vaterlaus@bigswitch.com)
- */
-public class OFRoleRequestVendorData extends OFRoleVendorData {
-
- protected static Instantiable<OFVendorData> instantiable =
- new Instantiable<OFVendorData>() {
- public OFVendorData instantiate() {
- return new OFRoleRequestVendorData();
- }
- };
-
- /**
- * @return a subclass of Instantiable<OFVendorData> that instantiates
- * an instance of OFRoleRequestVendorData.
- */
- public static Instantiable<OFVendorData> getInstantiable() {
- return instantiable;
- }
-
- /**
- * The data type value for a role request
- */
- public static final int NXT_ROLE_REQUEST = 10;
-
- /**
- * Construct a role request vendor data with an unspecified role value.
- */
- public OFRoleRequestVendorData() {
- super(NXT_ROLE_REQUEST);
- }
-
- /**
- * Construct a role request vendor data with the specified role value.
- * @param role the role value for the role request. Should be one of
- * NX_ROLE_OTHER, NX_ROLE_MASTER or NX_ROLE_SLAVE.
- */
- public OFRoleRequestVendorData(int role) {
- super(NXT_ROLE_REQUEST, role);
- }
-}
diff --git a/src/main/java/org/openflow/vendor/nicira/OFRoleVendorData.java b/src/main/java/org/openflow/vendor/nicira/OFRoleVendorData.java
deleted file mode 100644
index e7c8bf2..0000000
--- a/src/main/java/org/openflow/vendor/nicira/OFRoleVendorData.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/**
-* Copyright 2011, Big Switch Networks, Inc.
-* Originally created by David Erickson & Rob Sherwood, Stanford University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.vendor.nicira;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-
-/**
- * Class that represents the vendor data in the role request
- * extension implemented by Open vSwitch to support high availability.
- *
- * @author Rob Vaterlaus (rob.vaterlaus@bigswitch.com)
- */
-public class OFRoleVendorData extends OFNiciraVendorData {
-
- /**
- * Role value indicating that the controller is in the OTHER role.
- */
- public static final int NX_ROLE_OTHER = 0;
-
- /**
- * Role value indicating that the controller is in the MASTER role.
- */
- public static final int NX_ROLE_MASTER = 1;
-
- /**
- * Role value indicating that the controller is in the SLAVE role.
- */
- public static final int NX_ROLE_SLAVE = 2;
-
- protected int role;
-
- /**
- * Construct an uninitialized OFRoleVendorData
- */
- public OFRoleVendorData() {
- super();
- }
-
- /**
- * Construct an OFRoleVendorData with the specified data type
- * (i.e. either request or reply) and an unspecified role.
- * @param dataType
- */
- public OFRoleVendorData(int dataType) {
- super(dataType);
- }
-
- /**
- * Construct an OFRoleVendorData with the specified data type
- * (i.e. either request or reply) and role (i.e. one of of
- * master, slave, or other).
- * @param dataType either role request or role reply data type
- */
- public OFRoleVendorData(int dataType, int role) {
- super(dataType);
- this.role = role;
- }
- /**
- * @return the role value of the role vendor data
- */
- public int getRole() {
- return role;
- }
-
- /**
- * @param role the role value of the role vendor data
- */
- public void setRole(int role) {
- this.role = role;
- }
-
- /**
- * @return the total length of the role vendor data
- */
- @Override
- public int getLength() {
- return super.getLength() + 4;
- }
-
- /**
- * Read the role vendor data from the ChannelBuffer
- * @param data the channel buffer from which we're deserializing
- * @param length the length to the end of the enclosing message
- */
- public void readFrom(ChannelBuffer data, int length) {
- super.readFrom(data, length);
- role = data.readInt();
- }
-
- /**
- * Write the role vendor data to the ChannelBuffer
- * @param data the channel buffer to which we're serializing
- */
- public void writeTo(ChannelBuffer data) {
- super.writeTo(data);
- data.writeInt(role);
- }
-}
diff --git a/src/test/java/net/onrc/onos/core/registry/StandaloneRegistryTest.java b/src/test/java/net/onrc/onos/core/registry/StandaloneRegistryTest.java
index 88a1177..79cc0e8 100644
--- a/src/test/java/net/onrc/onos/core/registry/StandaloneRegistryTest.java
+++ b/src/test/java/net/onrc/onos/core/registry/StandaloneRegistryTest.java
@@ -24,7 +24,7 @@
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
-import org.openflow.util.HexString;
+import org.projectfloodlight.openflow.util.HexString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/src/test/java/net/onrc/onos/core/registry/ZookeeperRegistryTest.java b/src/test/java/net/onrc/onos/core/registry/ZookeeperRegistryTest.java
index 5490162..3ac2c96 100644
--- a/src/test/java/net/onrc/onos/core/registry/ZookeeperRegistryTest.java
+++ b/src/test/java/net/onrc/onos/core/registry/ZookeeperRegistryTest.java
@@ -35,10 +35,10 @@
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.openflow.util.HexString;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
+import org.projectfloodlight.openflow.util.HexString;
/**
* Unit test for {@link ZookeeperRegistry}.
diff --git a/src/test/java/net/onrc/onos/core/util/FlowEntryActionTest.java b/src/test/java/net/onrc/onos/core/util/FlowEntryActionTest.java
index 7048697..fbba92c 100644
--- a/src/test/java/net/onrc/onos/core/util/FlowEntryActionTest.java
+++ b/src/test/java/net/onrc/onos/core/util/FlowEntryActionTest.java
@@ -13,7 +13,7 @@
import net.onrc.onos.core.util.FlowEntryAction.ActionStripVlan;
import org.junit.Test;
-import org.openflow.protocol.OFPort;
+import org.projectfloodlight.openflow.types.OFPort;
public class FlowEntryActionTest {
@@ -56,7 +56,7 @@
act.setActionOutputToController((short) 0);
FlowEntryAction actCopy = new FlowEntryAction();
- actCopy.setActionOutput(new PortNumber(OFPort.OFPP_CONTROLLER.getValue()));
+ actCopy.setActionOutput(new PortNumber(OFPort.CONTROLLER.getShortPortNumber()));
FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
diff --git a/src/test/java/org/openflow/protocol/BasicFactoryTest.java b/src/test/java/org/openflow/protocol/BasicFactoryTest.java
deleted file mode 100644
index 49b2df9..0000000
--- a/src/test/java/org/openflow/protocol/BasicFactoryTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.openflow.protocol.factory.BasicFactory;
-import org.openflow.protocol.factory.MessageParseException;
-import org.openflow.util.U16;
-
-public class BasicFactoryTest extends TestCase {
-
- public void testCreateAndParse() throws MessageParseException {
- BasicFactory factory = new BasicFactory();
- OFMessage m = factory.getMessage(OFType.HELLO);
- m.setVersion((byte) 1);
- m.setType(OFType.ECHO_REQUEST);
- m.setLength(U16.t(8));
- m.setXid(0xdeadbeef);
- ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
- ChannelBuffer bb2 = ChannelBuffers.dynamicBuffer();
- m.writeTo(bb);
- bb2.writeBytes(bb, bb.readableBytes()-1);
- TestCase.assertNull(factory.parseMessage(bb2));
- bb2.writeByte(bb.readByte());
- List<OFMessage> message = factory.parseMessage(bb2);
- TestCase.assertNotNull(message);
- TestCase.assertEquals(message.size(), 1);
- TestCase.assertTrue(message.get(0).getType() == OFType.ECHO_REQUEST);
- }
-
- public void testInvalidMsgParse() throws MessageParseException {
- BasicFactory factory = new BasicFactory();
- OFMessage m = factory.getMessage(OFType.HELLO);
- m.setVersion((byte) 1);
- m.setType(OFType.ECHO_REQUEST);
- m.setLength(U16.t(16));
- m.setXid(0xdeadbeef);
- ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
- m.writeTo(bb);
- List<OFMessage> message = factory.parseMessage(bb);
- TestCase.assertNull(message);
- }
-
- public void testCurrouptedMsgParse() throws MessageParseException {
- BasicFactory factory = new BasicFactory();
- OFMessage m = factory.getMessage(OFType.HELLO);
- m.setVersion((byte) 1);
- m.setType(OFType.ERROR);
- m.setLength(U16.t(8));
- m.setXid(0xdeadbeef);
- ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
- m.writeTo(bb);
- try {
- factory.parseMessage(bb);
- }
- catch(Exception e) {
- TestCase.assertEquals(MessageParseException.class, e.getClass());
- }
- }
-
-}
diff --git a/src/test/java/org/openflow/protocol/OFActionTypeTest.java b/src/test/java/org/openflow/protocol/OFActionTypeTest.java
deleted file mode 100644
index 2c9827e..0000000
--- a/src/test/java/org/openflow/protocol/OFActionTypeTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-
-import junit.framework.TestCase;
-
-import org.junit.Test;
-import org.openflow.protocol.action.OFActionType;
-
-
-public class OFActionTypeTest extends TestCase {
- @Test
- public void testMapping() throws Exception {
- TestCase.assertEquals(OFActionType.OUTPUT,
- OFActionType.valueOf((short) 0));
- TestCase.assertEquals(OFActionType.OPAQUE_ENQUEUE,
- OFActionType.valueOf((short) 11));
- TestCase.assertEquals(OFActionType.VENDOR,
- OFActionType.valueOf((short) 0xffff));
- }
-}
diff --git a/src/test/java/org/openflow/protocol/OFBarrierReplyTest.java b/src/test/java/org/openflow/protocol/OFBarrierReplyTest.java
deleted file mode 100644
index 7e447bb..0000000
--- a/src/test/java/org/openflow/protocol/OFBarrierReplyTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-import junit.framework.TestCase;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.openflow.util.OFTestCase;
-
-public class OFBarrierReplyTest extends OFTestCase {
- public void testWriteRead() throws Exception {
- OFBarrierReply msg = (OFBarrierReply) messageFactory
- .getMessage(OFType.BARRIER_REPLY);
- ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
- bb.clear();
- msg.writeTo(bb);
- msg.readFrom(bb);
- TestCase.assertEquals(OFType.BARRIER_REPLY, msg.getType());
- }
-}
diff --git a/src/test/java/org/openflow/protocol/OFBarrierRequestTest.java b/src/test/java/org/openflow/protocol/OFBarrierRequestTest.java
deleted file mode 100644
index 3aa9cb4..0000000
--- a/src/test/java/org/openflow/protocol/OFBarrierRequestTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-import junit.framework.TestCase;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.openflow.util.OFTestCase;
-
-public class OFBarrierRequestTest extends OFTestCase {
- public void testWriteRead() throws Exception {
- OFBarrierRequest msg = (OFBarrierRequest) messageFactory
- .getMessage(OFType.BARRIER_REQUEST);
- ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
- bb.clear();
- msg.writeTo(bb);
- msg.readFrom(bb);
- TestCase.assertEquals(OFType.BARRIER_REQUEST, msg.getType());
- }
-}
diff --git a/src/test/java/org/openflow/protocol/OFErrorTest.java b/src/test/java/org/openflow/protocol/OFErrorTest.java
deleted file mode 100644
index 7acd727..0000000
--- a/src/test/java/org/openflow/protocol/OFErrorTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.openflow.protocol.OFError.OFErrorType;
-import org.openflow.protocol.OFError.OFHelloFailedCode;
-import org.openflow.protocol.factory.BasicFactory;
-import org.openflow.protocol.factory.MessageParseException;
-import org.openflow.protocol.factory.OFMessageFactory;
-import org.openflow.util.OFTestCase;
-
-public class OFErrorTest extends OFTestCase {
- public void testWriteRead() throws Exception {
- OFError msg = (OFError) messageFactory.getMessage(OFType.ERROR);
- msg.setMessageFactory(messageFactory);
- msg.setErrorType(OFErrorType.OFPET_HELLO_FAILED.getValue());
- msg.setErrorCode((short) OFHelloFailedCode.OFPHFC_INCOMPATIBLE
- .ordinal());
- ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
- bb.clear();
- msg.writeTo(bb);
- msg.readFrom(bb);
- TestCase.assertEquals(OFErrorType.OFPET_HELLO_FAILED.getValue(),
- msg.getErrorType());
- TestCase.assertEquals((short) OFHelloFailedCode.OFPHFC_INCOMPATIBLE
- .ordinal(), msg.getErrorType());
- TestCase.assertNull(msg.getOffendingMsg());
-
- msg.setOffendingMsg(new OFHello());
- bb.clear();
- msg.writeTo(bb);
- msg.readFrom(bb);
- TestCase.assertEquals(OFErrorType.OFPET_HELLO_FAILED.getValue(),
- msg.getErrorType());
- TestCase.assertEquals((short) OFHelloFailedCode.OFPHFC_INCOMPATIBLE
- .ordinal(), msg.getErrorType());
- TestCase.assertNotNull(msg.getOffendingMsg());
- TestCase.assertEquals(OFHello.MINIMUM_LENGTH,
- msg.getOffendingMsg().length);
- }
-
- public void testGarbageAtEnd() throws MessageParseException {
- // This is a OFError msg (12 bytes), that encaps a OFVendor msg (24
- // bytes)
- // AND some zeros at the end (40 bytes) for a total of 76 bytes
- // THIS is what an NEC sends in reply to Nox's VENDOR request
- byte[] oferrorRaw = { 0x01, 0x01, 0x00, 0x4c, 0x00, 0x00, 0x10,
- (byte) 0xcc, 0x00, 0x01, 0x00, 0x01, 0x01, 0x04, 0x00, 0x18,
- 0x00, 0x00, 0x10, (byte) 0xcc, 0x00, 0x00, 0x23, 0x20, 0x00,
- 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00 };
- OFMessageFactory factory = new BasicFactory();
- ChannelBuffer oferrorBuf =
- ChannelBuffers.wrappedBuffer(oferrorRaw);
- List<OFMessage> msg = factory.parseMessage(oferrorBuf);
- TestCase.assertNotNull(msg);
- TestCase.assertEquals(msg.size(), 1);
- TestCase.assertEquals(76, msg.get(0).getLengthU());
- ChannelBuffer out = ChannelBuffers.dynamicBuffer();
- msg.get(0).writeTo(out);
- TestCase.assertEquals(76, out.readableBytes());
- }
-}
diff --git a/src/test/java/org/openflow/protocol/OFFeaturesReplyTest.java b/src/test/java/org/openflow/protocol/OFFeaturesReplyTest.java
deleted file mode 100644
index 62e491a..0000000
--- a/src/test/java/org/openflow/protocol/OFFeaturesReplyTest.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.openflow.util.OFTestCase;
-
-
-public class OFFeaturesReplyTest extends OFTestCase {
- public void testWriteRead() throws Exception {
- OFFeaturesReply ofr = (OFFeaturesReply) messageFactory
- .getMessage(OFType.FEATURES_REPLY);
- List<OFPhysicalPort> ports = new ArrayList<OFPhysicalPort>();
- OFPhysicalPort port = new OFPhysicalPort();
- port.setHardwareAddress(new byte[6]);
- port.setName("eth0");
- ports.add(port);
- ofr.setPorts(ports);
- ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
- bb.clear();
- ofr.writeTo(bb);
- ofr.readFrom(bb);
- TestCase.assertEquals(1, ofr.getPorts().size());
- TestCase.assertEquals("eth0", ofr.getPorts().get(0).getName());
-
- // test a 15 character name
- ofr.getPorts().get(0).setName("012345678901234");
- bb.clear();
- ofr.writeTo(bb);
- ofr.readFrom(bb);
- TestCase.assertEquals("012345678901234", ofr.getPorts().get(0).getName());
-
- // test a 16 character name getting truncated
- ofr.getPorts().get(0).setName("0123456789012345");
- bb.clear();
- ofr.writeTo(bb);
- ofr.readFrom(bb);
- TestCase.assertEquals("012345678901234", ofr.getPorts().get(0).getName());
- }
-}
diff --git a/src/test/java/org/openflow/protocol/OFFlowRemovedTest.java b/src/test/java/org/openflow/protocol/OFFlowRemovedTest.java
deleted file mode 100644
index 11746e7..0000000
--- a/src/test/java/org/openflow/protocol/OFFlowRemovedTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-import junit.framework.TestCase;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.openflow.protocol.OFFlowRemoved.OFFlowRemovedReason;
-import org.openflow.util.OFTestCase;
-
-public class OFFlowRemovedTest extends OFTestCase {
- public void testWriteRead() throws Exception {
- OFFlowRemoved msg = (OFFlowRemoved) messageFactory
- .getMessage(OFType.FLOW_REMOVED);
- msg.setMatch(new OFMatch());
- byte[] hwAddr = new byte[6];
- msg.getMatch().setDataLayerDestination(hwAddr);
- msg.getMatch().setDataLayerSource(hwAddr);
- msg.setReason(OFFlowRemovedReason.OFPRR_DELETE);
- ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
- bb.clear();
- msg.writeTo(bb);
- msg.readFrom(bb);
- TestCase.assertEquals(OFType.FLOW_REMOVED, msg.getType());
- TestCase.assertEquals(OFFlowRemovedReason.OFPRR_DELETE, msg.getReason());
- }
-}
diff --git a/src/test/java/org/openflow/protocol/OFGetConfigReplyTest.java b/src/test/java/org/openflow/protocol/OFGetConfigReplyTest.java
deleted file mode 100644
index c1f1f67..0000000
--- a/src/test/java/org/openflow/protocol/OFGetConfigReplyTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-import junit.framework.TestCase;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.openflow.util.OFTestCase;
-
-public class OFGetConfigReplyTest extends OFTestCase {
- public void testWriteRead() throws Exception {
- OFSetConfig msg = (OFSetConfig) messageFactory
- .getMessage(OFType.SET_CONFIG);
- msg.setFlags((short) 1);
- ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
- bb.clear();
- msg.writeTo(bb);
- msg.readFrom(bb);
- TestCase.assertEquals(OFType.SET_CONFIG, msg.getType());
- TestCase.assertEquals((short)1, msg.getFlags());
- }
-}
diff --git a/src/test/java/org/openflow/protocol/OFGetConfigRequestTest.java b/src/test/java/org/openflow/protocol/OFGetConfigRequestTest.java
deleted file mode 100644
index 94d9036..0000000
--- a/src/test/java/org/openflow/protocol/OFGetConfigRequestTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-import junit.framework.TestCase;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.openflow.util.OFTestCase;
-
-public class OFGetConfigRequestTest extends OFTestCase {
- public void testWriteRead() throws Exception {
- OFGetConfigRequest msg = (OFGetConfigRequest) messageFactory
- .getMessage(OFType.GET_CONFIG_REQUEST);
- ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
- bb.clear();
- msg.writeTo(bb);
- msg.readFrom(bb);
- TestCase.assertEquals(OFType.GET_CONFIG_REQUEST, msg.getType());
- }
-}
diff --git a/src/test/java/org/openflow/protocol/OFMatchTest.java b/src/test/java/org/openflow/protocol/OFMatchTest.java
deleted file mode 100644
index fd7863a..0000000
--- a/src/test/java/org/openflow/protocol/OFMatchTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-import junit.framework.TestCase;
-
-public class OFMatchTest extends TestCase {
- public void testFromString() {
- OFMatch correct = new OFMatch();
- OFMatch tester = new OFMatch();
-
- // Various combinations of "all"/"any"
- tester.fromString("OFMatch[]");
- // correct is already wildcarded
- TestCase.assertEquals(correct, tester);
- tester.fromString("all");
- TestCase.assertEquals(correct, tester);
- tester.fromString("ANY");
- TestCase.assertEquals(correct, tester);
- tester.fromString("");
- TestCase.assertEquals(correct, tester);
- tester.fromString("[]");
- TestCase.assertEquals(correct, tester);
-
- // ip_src
- correct.setWildcards(~OFMatch.OFPFW_NW_SRC_MASK);
- correct.setNetworkSource(0x01010203);
- tester.fromString("nw_src=1.1.2.3");
- TestCase.assertEquals(correct.getNetworkSourceMaskLen(), tester
- .getNetworkSourceMaskLen());
- TestCase.assertEquals(correct, tester);
- tester.fromString("IP_sRc=1.1.2.3");
- TestCase.assertEquals(correct.getNetworkSourceMaskLen(), tester
- .getNetworkSourceMaskLen());
- TestCase.assertEquals(correct, tester);
-
- // 0xVlan
- correct = new OFMatch();
- correct.setDataLayerVirtualLan((short)65535);
- correct.setWildcards(~OFMatch.OFPFW_DL_VLAN);
- tester = new OFMatch();
- tester.fromString("dl_vlan=0xffff");
- TestCase.assertEquals(correct, tester);
- }
-
- public void testToString() {
- OFMatch match = new OFMatch();
- match.fromString("nw_dst=3.4.5.6/8");
- TestCase.assertEquals(8, match.getNetworkDestinationMaskLen());
- String correct = "OFMatch[nw_dst=3.0.0.0/8]";
- String tester = match.toString();
-
- TestCase.assertEquals(correct, tester);
- tester = "OFMatch[dl_type=35020]";
- correct = "OFMatch[dl_type=0x88cc]";
- match = new OFMatch();
- match.fromString(tester);
- TestCase.assertEquals(correct, match.toString());
- OFMatch match2 = new OFMatch();
- match2.fromString(correct);
- TestCase.assertEquals(match, match2);
- }
-
- public void testClone() {
- OFMatch match1 = new OFMatch();
- OFMatch match2 = match1.clone();
- TestCase.assertEquals(match1, match2);
- match2.setNetworkProtocol((byte) 4);
- match2.setWildcards(match2.getWildcards() & ~OFMatch.OFPFW_NW_PROTO);
- TestCase.assertNotSame(match1, match2);
- }
-
- public void testIpToString() {
- String test = OFMatch.ipToString(-1);
- TestCase.assertEquals("255.255.255.255", test);
- }
-}
diff --git a/src/test/java/org/openflow/protocol/OFMessageContextStoreTest.java b/src/test/java/org/openflow/protocol/OFMessageContextStoreTest.java
deleted file mode 100644
index 60a9e73..0000000
--- a/src/test/java/org/openflow/protocol/OFMessageContextStoreTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-import junit.framework.TestCase;
-
-public class OFMessageContextStoreTest extends TestCase {
- public void testStoreAndGet() {
- OFMessage msg = new OFMessage();
- OFMessageContextStore<String> store = new OFMessageContextStore<String>(msg, this.getName());
- String key = "mykey";
- String value = "myvalue";
- store.put(key, value);
- TestCase.assertEquals(value, store.get(key));
- }
-}
diff --git a/src/test/java/org/openflow/protocol/OFPortConfigTest.java b/src/test/java/org/openflow/protocol/OFPortConfigTest.java
deleted file mode 100644
index 9b115eb..0000000
--- a/src/test/java/org/openflow/protocol/OFPortConfigTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-import junit.framework.TestCase;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.openflow.util.OFTestCase;
-
-public class OFPortConfigTest extends OFTestCase {
- public void testWriteRead() throws Exception {
- OFPortMod msg = (OFPortMod) messageFactory
- .getMessage(OFType.PORT_MOD);
- msg.setHardwareAddress(new byte[6]);
- msg.portNumber = 1;
- ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
- bb.clear();
- msg.writeTo(bb);
- msg.readFrom(bb);
- TestCase.assertEquals(OFType.PORT_MOD, msg.getType());
- TestCase.assertEquals(1, msg.getPortNumber());
- }
-}
diff --git a/src/test/java/org/openflow/protocol/OFPortStatusTest.java b/src/test/java/org/openflow/protocol/OFPortStatusTest.java
deleted file mode 100644
index 4fab64e..0000000
--- a/src/test/java/org/openflow/protocol/OFPortStatusTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-import junit.framework.TestCase;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.openflow.protocol.OFPortStatus.OFPortReason;
-import org.openflow.util.OFTestCase;
-
-public class OFPortStatusTest extends OFTestCase {
- public void testWriteRead() throws Exception {
- OFPortStatus msg = (OFPortStatus) messageFactory
- .getMessage(OFType.PORT_STATUS);
- msg.setDesc(new OFPhysicalPort());
- msg.getDesc().setHardwareAddress(new byte[6]);
- msg.getDesc().setName("eth0");
- msg.setReason((byte) OFPortReason.OFPPR_ADD.ordinal());
- ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
- bb.clear();
- msg.writeTo(bb);
- msg.readFrom(bb);
- TestCase.assertEquals(OFType.PORT_STATUS, msg.getType());
- TestCase.assertEquals((byte) OFPortReason.OFPPR_ADD.ordinal(), msg
- .getReason());
- TestCase.assertNotNull(msg.getDesc());
- }
-}
diff --git a/src/test/java/org/openflow/protocol/OFSetConfigTest.java b/src/test/java/org/openflow/protocol/OFSetConfigTest.java
deleted file mode 100644
index 2a9e86f..0000000
--- a/src/test/java/org/openflow/protocol/OFSetConfigTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-import junit.framework.TestCase;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.openflow.util.OFTestCase;
-
-public class OFSetConfigTest extends OFTestCase {
- public void testWriteRead() throws Exception {
- OFGetConfigReply msg = (OFGetConfigReply) messageFactory
- .getMessage(OFType.GET_CONFIG_REPLY);
- msg.setFlags((short) 1);
- ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
- bb.clear();
- msg.writeTo(bb);
- msg.readFrom(bb);
- TestCase.assertEquals(OFType.GET_CONFIG_REPLY, msg.getType());
- TestCase.assertEquals((short)1, msg.getFlags());
- }
-}
diff --git a/src/test/java/org/openflow/protocol/OFStatisticsReplyTest.java b/src/test/java/org/openflow/protocol/OFStatisticsReplyTest.java
deleted file mode 100644
index 50bac8f..0000000
--- a/src/test/java/org/openflow/protocol/OFStatisticsReplyTest.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.openflow.protocol.factory.BasicFactory;
-import org.openflow.protocol.factory.OFMessageFactory;
-import org.openflow.protocol.statistics.OFStatisticsType;
-import org.openflow.util.OFTestCase;
-
-public class OFStatisticsReplyTest extends OFTestCase {
- public void testOFFlowStatisticsReply() throws Exception {
- byte[] packet = new byte[] { 0x01, 0x11, 0x01, 0x2c, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, (byte) 0xff,
- (byte) 0xff, 0x00, 0x00, 0x08, 0x00, 0x00, 0x01, 0x00, 0x00,
- 0x0a, 0x00, 0x00, 0x03, 0x0a, 0x00, 0x00, 0x02, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3a, (byte) 0xa6,
- (byte) 0xa6, 0x00, (byte) 0xff, (byte) 0xff, 0x00, 0x05, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- (byte) 0xc4, 0x00, 0x00, 0x00, 0x08, 0x00, 0x01, 0x00, 0x00,
- 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x02, (byte) 0xff, (byte) 0xff, 0x00, 0x00, 0x08, 0x06,
- 0x00, 0x02, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x03, 0x0a, 0x00,
- 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x3b, 0x2f, (byte) 0xfa, 0x40, (byte) 0xff, (byte) 0xff, 0x00,
- 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x08, 0x00, 0x01, 0x00,
- 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x03, (byte) 0xff, (byte) 0xff, 0x00, 0x62, 0x08,
- 0x00, 0x00, 0x01, 0x62, 0x37, 0x0a, 0x00, 0x00, 0x02, 0x0a,
- 0x00, 0x00, 0x03, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x3a, (byte) 0xc5, 0x2a, (byte) 0x80, (byte) 0xff,
- (byte) 0xff, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, (byte) 0xc4, 0x00, 0x00, 0x00,
- 0x08, 0x00, 0x02, 0x00, 0x00 };
-
- OFMessageFactory factory = new BasicFactory();
- ChannelBuffer packetBuf = ChannelBuffers.wrappedBuffer(packet);
- List<OFMessage> msg = factory.parseMessage(packetBuf);
- TestCase.assertNotNull(msg);
- TestCase.assertEquals(msg.size(), 1);
- TestCase.assertTrue(msg.get(0) instanceof OFStatisticsReply);
- OFStatisticsReply sr = (OFStatisticsReply) msg.get(0);
- TestCase.assertEquals(OFStatisticsType.FLOW, sr.getStatisticType());
- TestCase.assertEquals(3, sr.getStatistics().size());
- }
-}
diff --git a/src/test/java/org/openflow/protocol/OFStatisticsRequestTest.java b/src/test/java/org/openflow/protocol/OFStatisticsRequestTest.java
deleted file mode 100644
index 74af6f4..0000000
--- a/src/test/java/org/openflow/protocol/OFStatisticsRequestTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.openflow.protocol.factory.BasicFactory;
-import org.openflow.protocol.factory.OFMessageFactory;
-import org.openflow.protocol.statistics.OFFlowStatisticsRequest;
-import org.openflow.protocol.statistics.OFStatisticsType;
-import org.openflow.protocol.statistics.OFVendorStatistics;
-import org.openflow.util.OFTestCase;
-
-public class OFStatisticsRequestTest extends OFTestCase {
- public void testOFFlowStatisticsRequest() throws Exception {
- byte[] packet = new byte[] { 0x01, 0x10, 0x00, 0x38, 0x00, 0x00, 0x00,
- 0x16, 0x00, 0x01, 0x00, 0x00, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- (byte) 0xff, 0x00, (byte) 0xff, (byte) 0xff };
-
- OFMessageFactory factory = new BasicFactory();
- ChannelBuffer packetBuf = ChannelBuffers.wrappedBuffer(packet);
- List<OFMessage> msg = factory.parseMessage(packetBuf);
- TestCase.assertNotNull(msg);
- TestCase.assertEquals(msg.size(), 1);
- TestCase.assertTrue(msg.get(0) instanceof OFStatisticsRequest);
- OFStatisticsRequest sr = (OFStatisticsRequest) msg.get(0);
- TestCase.assertEquals(OFStatisticsType.FLOW, sr.getStatisticType());
- TestCase.assertEquals(1, sr.getStatistics().size());
- TestCase.assertTrue(sr.getStatistics().get(0) instanceof OFFlowStatisticsRequest);
- }
-
- public void testOFStatisticsRequestVendor() throws Exception {
- byte[] packet = new byte[] { 0x01, 0x10, 0x00, 0x50, 0x00, 0x00, 0x00,
- 0x63, (byte) 0xff, (byte) 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x4c, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x20,
- (byte) 0xe0, 0x00, 0x11, 0x00, 0x0c, 0x29, (byte) 0xc5,
- (byte) 0x95, 0x57, 0x02, 0x25, 0x5c, (byte) 0xca, 0x00, 0x02,
- (byte) 0xff, (byte) 0xff, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x50, 0x04,
- 0x00, 0x00, 0x00, 0x00, (byte) 0xff, 0x00, 0x00, 0x00,
- (byte) 0xff, (byte) 0xff, 0x4e, 0x20 };
-
- OFMessageFactory factory = new BasicFactory();
- ChannelBuffer packetBuf = ChannelBuffers.wrappedBuffer(packet);
- List<OFMessage> msg = factory.parseMessage(packetBuf);
- TestCase.assertNotNull(msg);
- TestCase.assertEquals(msg.size(), 1);
- TestCase.assertTrue(msg.get(0) instanceof OFStatisticsRequest);
- OFStatisticsRequest sr = (OFStatisticsRequest) msg.get(0);
- TestCase.assertEquals(OFStatisticsType.VENDOR, sr.getStatisticType());
- TestCase.assertEquals(1, sr.getStatistics().size());
- TestCase.assertTrue(sr.getStatistics().get(0) instanceof OFVendorStatistics);
- TestCase.assertEquals(68, ((OFVendorStatistics)sr.getStatistics().get(0)).getLength());
- }
-}
diff --git a/src/test/java/org/openflow/protocol/OFStatisticsTypeTest.java b/src/test/java/org/openflow/protocol/OFStatisticsTypeTest.java
deleted file mode 100644
index d44ef7f..0000000
--- a/src/test/java/org/openflow/protocol/OFStatisticsTypeTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-
-import junit.framework.TestCase;
-
-import org.junit.Test;
-import org.openflow.protocol.statistics.OFStatisticsType;
-
-
-public class OFStatisticsTypeTest extends TestCase {
- @Test
- public void testMapping() throws Exception {
- TestCase.assertEquals(OFStatisticsType.DESC,
- OFStatisticsType.valueOf((short) 0, OFType.STATS_REQUEST));
- TestCase.assertEquals(OFStatisticsType.QUEUE,
- OFStatisticsType.valueOf((short) 5, OFType.STATS_REQUEST));
- TestCase.assertEquals(OFStatisticsType.VENDOR,
- OFStatisticsType.valueOf((short) 0xffff, OFType.STATS_REQUEST));
- }
-}
diff --git a/src/test/java/org/openflow/protocol/OFTypeTest.java b/src/test/java/org/openflow/protocol/OFTypeTest.java
deleted file mode 100644
index c6bf0a3..0000000
--- a/src/test/java/org/openflow/protocol/OFTypeTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-
-import junit.framework.TestCase;
-
-import org.junit.Test;
-
-
-public class OFTypeTest extends TestCase {
-
- public void testOFTypeCreate() throws Exception {
- OFType foo = OFType.HELLO;
- Class<? extends OFMessage> c = foo.toClass();
- TestCase.assertEquals(c, OFHello.class);
- }
-
- @Test
- public void testMapping() throws Exception {
- TestCase.assertEquals(OFType.HELLO, OFType.valueOf((byte) 0));
- TestCase.assertEquals(OFType.BARRIER_REPLY, OFType.valueOf((byte) 19));
- }
-}
diff --git a/src/test/java/org/openflow/protocol/OFVendorTest.java b/src/test/java/org/openflow/protocol/OFVendorTest.java
deleted file mode 100644
index 1516a02..0000000
--- a/src/test/java/org/openflow/protocol/OFVendorTest.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.protocol;
-
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.openflow.protocol.factory.BasicFactory;
-import org.openflow.protocol.vendor.OFBasicVendorDataType;
-import org.openflow.protocol.vendor.OFBasicVendorId;
-import org.openflow.protocol.vendor.OFByteArrayVendorData;
-import org.openflow.protocol.vendor.OFVendorData;
-import org.openflow.protocol.vendor.OFVendorId;
-import org.openflow.util.OFTestCase;
-
-public class OFVendorTest extends OFTestCase {
-
- public static int ACME_VENDOR_ID = 0x00112233;
-
- static class AcmeVendorData implements OFVendorData {
- protected int dataType;
-
- public int getLength() {
- return 4;
- }
-
- public void readFrom(ChannelBuffer data, int length) {
- dataType = data.readInt();
- }
-
- public void writeTo(ChannelBuffer data) {
- data.writeInt(dataType);
- }
- }
-
- static class AcmeVendorData1 extends AcmeVendorData {
- public short flags;
- public short value;
-
- public static int DATA_TYPE = 1;
-
- public AcmeVendorData1() {
- }
-
- public AcmeVendorData1(short flags, short value) {
- this.dataType = DATA_TYPE;
- this.flags = flags;
- this.value = value;
- }
-
- public short getFlags() {
- return flags;
- }
-
- public short getValue() {
- return value;
- }
-
- public int getLength() {
- return 8;
- }
-
- public void readFrom(ChannelBuffer data, int length) {
- super.readFrom(data, length);
- flags = data.readShort();
- value = data.readShort();
-
- }
- public void writeTo(ChannelBuffer data) {
- super.writeTo(data);
- data.writeShort(flags);
- data.writeShort(value);
- }
-
- public static Instantiable<OFVendorData> getInstantiable() {
- return new Instantiable<OFVendorData>() {
- public OFVendorData instantiate() {
- return new AcmeVendorData1();
- }
- };
- }
- }
-
- static class AcmeVendorData2 extends AcmeVendorData {
- public int type;
- public int subtype;
-
- public static int DATA_TYPE = 2;
-
- public AcmeVendorData2() {
- }
-
- public AcmeVendorData2(int type, int subtype) {
- this.dataType = DATA_TYPE;
- this.type = type;
- this.subtype = subtype;
- }
-
- public int getType() {
- return type;
- }
-
- public int getSubtype() {
- return subtype;
- }
-
- public int getLength() {
- return 12;
- }
-
- public void readFrom(ChannelBuffer data, int length) {
- super.readFrom(data, length);
- type = data.readShort();
- subtype = data.readShort();
-
- }
- public void writeTo(ChannelBuffer data) {
- super.writeTo(data);
- data.writeShort(type);
- data.writeShort(subtype);
- }
-
- public static Instantiable<OFVendorData> getInstantiable() {
- return new Instantiable<OFVendorData>() {
- public OFVendorData instantiate() {
- return new AcmeVendorData2();
- }
- };
- }
- }
-
- {
- OFBasicVendorId acmeVendorId = new OFBasicVendorId(ACME_VENDOR_ID, 4);
- OFVendorId.registerVendorId(acmeVendorId);
- OFBasicVendorDataType acmeVendorData1 = new OFBasicVendorDataType(
- AcmeVendorData1.DATA_TYPE, AcmeVendorData1.getInstantiable());
- acmeVendorId.registerVendorDataType(acmeVendorData1);
- OFBasicVendorDataType acmeVendorData2 = new OFBasicVendorDataType(
- AcmeVendorData2.DATA_TYPE, AcmeVendorData2.getInstantiable());
- acmeVendorId.registerVendorDataType(acmeVendorData2);
- }
-
- private OFVendor makeVendorMessage(int vendor) {
- OFVendor msg = (OFVendor) messageFactory.getMessage(OFType.VENDOR);
- msg.setVendorDataFactory(new BasicFactory());
- msg.setVendor(vendor);
- return msg;
- }
-
- public void testWriteRead() throws Exception {
- OFVendor msg = makeVendorMessage(1);
- ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
- bb.clear();
- msg.writeTo(bb);
- msg.readFrom(bb);
- TestCase.assertEquals(1, msg.getVendor());
- }
-
- public void testVendorData() throws Exception {
- OFVendor msg = makeVendorMessage(ACME_VENDOR_ID);
- OFVendorData vendorData = new AcmeVendorData1((short)11, (short)22);
- msg.setVendorData(vendorData);
- msg.setLengthU(OFVendor.MINIMUM_LENGTH + vendorData.getLength());
- ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
- bb.clear();
- msg.writeTo(bb);
- msg.readFrom(bb);
- assertEquals(ACME_VENDOR_ID, msg.getVendor());
- AcmeVendorData1 vendorData1 = (AcmeVendorData1) msg.getVendorData();
- assertEquals(11, vendorData1.getFlags());
- assertEquals(22, vendorData1.getValue());
-
- vendorData = new AcmeVendorData2(33, 44);
- msg.setVendorData(vendorData);
- msg.setLengthU(OFVendor.MINIMUM_LENGTH + vendorData.getLength());
- bb.clear();
- msg.writeTo(bb);
- msg.readFrom(bb);
- assertEquals(ACME_VENDOR_ID, msg.getVendor());
- AcmeVendorData2 vendorData2 = (AcmeVendorData2) msg.getVendorData();
- assertEquals(33, vendorData2.getType());
- assertEquals(44, vendorData2.getSubtype());
-
- final int DUMMY_VENDOR_ID = 55;
- msg.setVendor(DUMMY_VENDOR_ID);
- byte[] genericVendorDataBytes = new byte[] {0x55, 0x66};
- vendorData = new OFByteArrayVendorData(genericVendorDataBytes);
- msg.setVendorData(vendorData);
- msg.setLengthU(OFVendor.MINIMUM_LENGTH + vendorData.getLength());
- bb.clear();
- msg.writeTo(bb);
- msg.readFrom(bb);
- assertEquals(DUMMY_VENDOR_ID, msg.getVendor());
- OFByteArrayVendorData genericVendorData = (OFByteArrayVendorData) msg.getVendorData();
- assertTrue(Arrays.equals(genericVendorDataBytes, genericVendorData.getBytes()));
- }
-}
diff --git a/src/test/java/org/openflow/util/HexStringTest.java b/src/test/java/org/openflow/util/HexStringTest.java
deleted file mode 100644
index 9e1fabb..0000000
--- a/src/test/java/org/openflow/util/HexStringTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.util;
-
-import junit.framework.TestCase;
-
-import org.junit.Test;
-
-/**
- * Does hexstring conversion work?
- *
- * @author Rob Sherwood (rob.sherwood@stanford.edu)
- *
- */
-
-public class HexStringTest extends TestCase {
-
- @Test
- public void testMarshalling() throws Exception {
- String dpidStr = "00:00:00:23:20:2d:16:71";
- long dpid = HexString.toLong(dpidStr);
- String testStr = HexString.toHexString(dpid);
- TestCase.assertEquals(dpidStr, testStr);
- }
-
- @Test
- public void testToLong() {
- String dpidStr = "3e:1f:01:fc:72:8c:63:31";
- long valid = 0x3e1f01fc728c6331L;
- long testLong = HexString.toLong(dpidStr);
- TestCase.assertEquals(valid, testLong);
- }
-
- @Test
- public void testToLongMSB() {
- String dpidStr = "ca:7c:5e:d1:64:7a:95:9b";
- long valid = -3856102927509056101L;
- long testLong = HexString.toLong(dpidStr);
- TestCase.assertEquals(valid, testLong);
- }
-
- @Test
- public void testToLongError() {
- String dpidStr = "09:08:07:06:05:04:03:02:01";
- try {
- HexString.toLong(dpidStr);
- fail("HexString.toLong() should have thrown a NumberFormatException");
- }
- catch (NumberFormatException expected) {
- // do nothing
- }
- }
-
- @Test
- public void testToStringBytes() {
- byte[] dpid = { 0, 0, 0, 0, 0, 0, 0, -1 };
- String valid = "00:00:00:00:00:00:00:ff";
- String testString = HexString.toHexString(dpid);
- TestCase.assertEquals(valid, testString);
- }
-
- @Test
- public void testFromHexStringError() {
- String invalidStr = "00:00:00:00:00:00:ffff";
- try {
- HexString.fromHexString(invalidStr);
- fail("HexString.fromHexString() should have thrown a NumberFormatException");
- }
- catch (NumberFormatException expected) {
- // do nothing
- }
- }
-}
diff --git a/src/test/java/org/openflow/util/OFTestCase.java b/src/test/java/org/openflow/util/OFTestCase.java
deleted file mode 100644
index bf2f2ab..0000000
--- a/src/test/java/org/openflow/util/OFTestCase.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.util;
-
-import junit.framework.TestCase;
-
-import org.openflow.protocol.factory.BasicFactory;
-import org.openflow.protocol.factory.OFMessageFactory;
-
-public class OFTestCase extends TestCase {
- public OFMessageFactory messageFactory;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- messageFactory = new BasicFactory();
- }
-
- public void test() throws Exception {
- }
-}
diff --git a/src/test/java/org/openflow/util/U16Test.java b/src/test/java/org/openflow/util/U16Test.java
deleted file mode 100644
index ba87e7b..0000000
--- a/src/test/java/org/openflow/util/U16Test.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.util;
-
-import junit.framework.TestCase;
-
-public class U16Test extends TestCase {
- /**
- * Tests that we correctly translate unsigned values in and out of a short
- * @throws Exception
- */
- public void test() throws Exception {
- int val = 0xffff;
- TestCase.assertEquals((short)-1, U16.t(val));
- TestCase.assertEquals((short)32767, U16.t(0x7fff));
- TestCase.assertEquals(val, U16.f((short)-1));
- }
-}
diff --git a/src/test/java/org/openflow/util/U32Test.java b/src/test/java/org/openflow/util/U32Test.java
deleted file mode 100644
index 223c103..0000000
--- a/src/test/java/org/openflow/util/U32Test.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.util;
-
-import junit.framework.TestCase;
-
-public class U32Test extends TestCase {
- /**
- * Tests that we correctly translate unsigned values in and out of an int
- * @throws Exception
- */
- public void test() throws Exception {
- long val = 0xffffffffL;
- TestCase.assertEquals(-1, U32.t(val));
- TestCase.assertEquals(val, U32.f(-1));
- }
-}
diff --git a/src/test/java/org/openflow/util/U64Test.java b/src/test/java/org/openflow/util/U64Test.java
deleted file mode 100644
index 0a97e30..0000000
--- a/src/test/java/org/openflow/util/U64Test.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.util;
-
-import java.math.BigInteger;
-
-import junit.framework.TestCase;
-
-public class U64Test extends TestCase {
- /**
- * Tests that we correctly translate unsigned values in and out of a long
- * @throws Exception
- */
- public void test() throws Exception {
- BigInteger val = new BigInteger("ffffffffffffffff", 16);
- TestCase.assertEquals(-1, U64.t(val));
- TestCase.assertEquals(val, U64.f(-1));
- }
-}
diff --git a/src/test/java/org/openflow/util/U8Test.java b/src/test/java/org/openflow/util/U8Test.java
deleted file mode 100644
index 2c06c4d..0000000
--- a/src/test/java/org/openflow/util/U8Test.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.util;
-
-import junit.framework.TestCase;
-
-public class U8Test extends TestCase {
- /**
- * Tests that we correctly translate unsigned values in and out of a byte
- * @throws Exception
- */
- public void test() throws Exception {
- short val = 0xff;
- TestCase.assertEquals(-1, U8.t(val));
- TestCase.assertEquals(val, U8.f((byte)-1));
- }
-}
diff --git a/src/test/java/org/openflow/util/UnsignedTest.java b/src/test/java/org/openflow/util/UnsignedTest.java
deleted file mode 100644
index 7cdf739..0000000
--- a/src/test/java/org/openflow/util/UnsignedTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
-
-package org.openflow.util;
-
-import java.math.BigInteger;
-import java.nio.ByteBuffer;
-
-import junit.framework.TestCase;
-
-public class UnsignedTest extends TestCase {
- public static String ULONG_MAX = "18446744073709551615";
-
- /**
- * Tests that we correctly extract an unsigned long into a BigInteger
- * @throws Exception
- */
- public void testGetUnsignedLong() throws Exception {
- ByteBuffer bb = ByteBuffer.allocate(8);
- bb.put((byte)0xff).put((byte)0xff).put((byte)0xff).put((byte)0xff);
- bb.put((byte)0xff).put((byte)0xff).put((byte)0xff).put((byte)0xff);
- bb.position(0);
- bb.limit(8);
- BigInteger bi = Unsigned.getUnsignedLong(bb);
- BigInteger uLongMax = new BigInteger(ULONG_MAX);
- for (int i = 0; i < uLongMax.bitCount(); ++i) {
- TestCase.assertTrue("Bit: " + i + " should be: " + uLongMax.testBit(i),
- uLongMax.testBit(i) == bi.testBit(i));
- }
- TestCase.assertEquals(ULONG_MAX, bi.toString());
-
- bb = ByteBuffer.allocate(10);
- bb.put((byte)0x00);
- bb.put((byte)0xff).put((byte)0xff).put((byte)0xff).put((byte)0xff);
- bb.put((byte)0xff).put((byte)0xff).put((byte)0xff).put((byte)0xff);
- bb.put((byte)0x00);
- bb.position(0);
- bb.limit(10);
- bi = Unsigned.getUnsignedLong(bb, 1);
- uLongMax = new BigInteger(ULONG_MAX);
- for (int i = 0; i < uLongMax.bitCount(); ++i) {
- TestCase.assertTrue("Bit: " + i + " should be: " + uLongMax.testBit(i),
- uLongMax.testBit(i) == bi.testBit(i));
- }
- TestCase.assertEquals(ULONG_MAX, bi.toString());
- }
-
- /**
- * Tests that we correctly put an unsigned long into a ByteBuffer
- * @throws Exception
- */
- public void testPutUnsignedLong() throws Exception {
- ByteBuffer bb = ByteBuffer.allocate(8);
- BigInteger uLongMax = new BigInteger(ULONG_MAX);
- Unsigned.putUnsignedLong(bb, uLongMax);
- for (int i = 0; i < 8; ++i) {
- TestCase.assertTrue("Byte: " + i + " should be 0xff, was: " + bb.get(i),
- (bb.get(i) & (short)0xff) == 0xff);
- }
-
- bb = ByteBuffer.allocate(10);
- Unsigned.putUnsignedLong(bb, uLongMax, 1);
- int offset = 1;
- for (int i = 0; i < 8; ++i) {
- TestCase.assertTrue("Byte: " + i + " should be 0xff, was: " +
- bb.get(offset+i), (bb.get(offset+i) & (short)0xff) == 0xff);
- }
- }
-}