Merge branch 'master' of ssh://gerrit.onlab.us:29418/onos-next
diff --git a/of/api/src/main/java/org/onlab/onos/of/controller/DefaultPacketContext.java b/of/api/src/main/java/org/onlab/onos/of/controller/DefaultPacketContext.java
index 41c8adc..bb6640c 100644
--- a/of/api/src/main/java/org/onlab/onos/of/controller/DefaultPacketContext.java
+++ b/of/api/src/main/java/org/onlab/onos/of/controller/DefaultPacketContext.java
@@ -1,8 +1,12 @@
package org.onlab.onos.of.controller;
+import java.util.Collections;
+
import org.onlab.packet.Ethernet;
import org.projectfloodlight.openflow.protocol.OFPacketIn;
import org.projectfloodlight.openflow.protocol.OFPacketOut;
+import org.projectfloodlight.openflow.protocol.action.OFAction;
+import org.projectfloodlight.openflow.types.OFBufferId;
import org.projectfloodlight.openflow.types.OFPort;
public final class DefaultPacketContext implements PacketContext {
@@ -11,7 +15,7 @@
private boolean isBuilt = false;
private final OpenFlowSwitch sw;
private final OFPacketIn pktin;
- private final OFPacketOut pktout = null;
+ private OFPacketOut pktout = null;
private DefaultPacketContext(OpenFlowSwitch s, OFPacketIn pkt) {
this.sw = s;
@@ -39,20 +43,32 @@
@Override
public void build(Ethernet ethFrame, OFPort outPort) {
- // TODO Auto-generated method stub
-
+ if (isBuilt) {
+ return;
+ }
+ OFPacketOut.Builder builder = sw.factory().buildPacketOut();
+ OFAction act = sw.factory().actions()
+ .buildOutput()
+ .setPort(OFPort.of(outPort.getPortNumber()))
+ .build();
+ pktout = builder.setXid(pktin.getXid())
+ .setBufferId(OFBufferId.NO_BUFFER)
+ .setActions(Collections.singletonList(act))
+ .setData(ethFrame.serialize())
+ .build();
+ isBuilt = true;
}
@Override
public Ethernet parsed() {
- // TODO Auto-generated method stub
- return null;
+ Ethernet eth = new Ethernet();
+ eth.deserialize(pktin.getData(), 0, pktin.getTotalLen());
+ return eth;
}
@Override
public Dpid dpid() {
- // TODO Auto-generated method stub
- return null;
+ return new Dpid(sw.getId());
}
public static PacketContext packetContextFromPacketIn(OpenFlowSwitch s, OFPacketIn pkt) {
diff --git a/providers/of/link/src/main/java/org/onlab/onos/provider/of/link/impl/OpenFlowLinkProvider.java b/providers/of/link/src/main/java/org/onlab/onos/provider/of/link/impl/OpenFlowLinkProvider.java
index ed9d970..84b7f44 100644
--- a/providers/of/link/src/main/java/org/onlab/onos/provider/of/link/impl/OpenFlowLinkProvider.java
+++ b/providers/of/link/src/main/java/org/onlab/onos/provider/of/link/impl/OpenFlowLinkProvider.java
@@ -12,9 +12,12 @@
import org.onlab.onos.net.link.LinkProviderService;
import org.onlab.onos.net.provider.AbstractProvider;
import org.onlab.onos.net.provider.ProviderId;
+import org.onlab.onos.of.controller.Dpid;
import org.onlab.onos.of.controller.OpenFlowController;
+import org.onlab.onos.of.controller.OpenFlowSwitchListener;
import org.onlab.onos.of.controller.PacketContext;
import org.onlab.onos.of.controller.PacketListener;
+import org.projectfloodlight.openflow.protocol.OFPortStatus;
import org.slf4j.Logger;
/**
@@ -34,7 +37,7 @@
private LinkProviderService providerService;
- private final PacketListener listener = new InternalLinkProvider();
+ private final InternalLinkProvider listener = new InternalLinkProvider();
/**
* Creates an OpenFlow link provider.
@@ -46,6 +49,7 @@
@Activate
public void activate() {
providerService = providerRegistry.register(this);
+ controller.addListener(listener);
controller.addPacketListener(0, listener);
log.info("Started");
}
@@ -53,19 +57,38 @@
@Deactivate
public void deactivate() {
providerRegistry.unregister(this);
+ controller.removeListener(listener);
controller.removePacketListener(listener);
providerService = null;
log.info("Stopped");
}
- private class InternalLinkProvider implements PacketListener {
+ private class InternalLinkProvider implements PacketListener, OpenFlowSwitchListener {
@Override
public void handlePacket(PacketContext pktCtx) {
}
+ @Override
+ public void switchAdded(Dpid dpid) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void switchRemoved(Dpid dpid) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void portChanged(Dpid dpid, OFPortStatus status) {
+ // TODO Auto-generated method stub
+
+ }
+
}
}
diff --git a/utils/misc/pom.xml b/utils/misc/pom.xml
index c39fd32..2ff34ec 100644
--- a/utils/misc/pom.xml
+++ b/utils/misc/pom.xml
@@ -22,10 +22,10 @@
<artifactId>guava-testlib</artifactId>
<scope>test</scope>
</dependency>
-
<dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
+ <groupId>io.netty</groupId>
+ <artifactId>netty</artifactId>
+ <version>3.9.0.Final</version>
</dependency>
</dependencies>
diff --git a/utils/misc/src/main/java/org/onlab/packet/OVXLLDP.java b/utils/misc/src/main/java/org/onlab/packet/ONLabLddp.java
similarity index 95%
rename from utils/misc/src/main/java/org/onlab/packet/OVXLLDP.java
rename to utils/misc/src/main/java/org/onlab/packet/ONLabLddp.java
index f1a4b5f..b3aba43 100644
--- a/utils/misc/src/main/java/org/onlab/packet/OVXLLDP.java
+++ b/utils/misc/src/main/java/org/onlab/packet/ONLabLddp.java
@@ -29,7 +29,7 @@
*
*/
@SuppressWarnings("rawtypes")
-public class OVXLLDP extends LLDP {
+public class ONLabLddp extends LLDP {
// ON.Lab OUI and OVX name for organizationally specific TLVs
public static final byte[] ONLAB_OUI = {(byte) 0xa4, 0x23, 0x05};
@@ -58,7 +58,7 @@
private static final byte NAME_TLV_TYPE = 127;
// 4 = OUI (3) + subtype (1)
- private static final byte NAME_TLV_SIZE = (byte) (4 + OVXLLDP.OVX_NAME.length());
+ private static final byte NAME_TLV_SIZE = (byte) (4 + ONLabLddp.OVX_NAME.length());
private static final byte NAME_TLV_SUBTYPE = 1;
private static final short NAME_TLV_OFFSET = 32;
private static final short NAME_TLV_HEADER = (short) ((NAME_TLV_TYPE << 9) | NAME_TLV_SIZE);
@@ -119,7 +119,7 @@
/**
* Instantiates a new OVX LDDP message.
*/
- public OVXLLDP() {
+ public ONLabLddp() {
// Create TLVs
this.chassisTLV = new LLDPTLV();
this.portTLV = new LLDPTLV();
@@ -140,7 +140,7 @@
this.setChassisTLV(DEFAULT_DPID);
this.setPortTLV(DEFAULT_PORT);
this.setTTLTLV(DEFAULT_TTL);
- this.setOUIName(OVXLLDP.OVX_NAME);
+ this.setOUIName(ONLabLddp.OVX_NAME);
this.setOUIDpid(DEFAULT_DPID);
}
@@ -198,7 +198,7 @@
*/
private void setOUIName(final String name) {
this.bb = ByteBuffer.wrap(ouiName);
- this.bb.put(OVXLLDP.ONLAB_OUI);
+ this.bb.put(ONLabLddp.ONLAB_OUI);
this.bb.put(NAME_TLV_SUBTYPE);
this.bb.put(name.getBytes());
@@ -214,7 +214,7 @@
*/
private void setOUIDpid(final byte[] dpid) {
this.bb = ByteBuffer.wrap(ouiDpid);
- this.bb.put(OVXLLDP.ONLAB_OUI);
+ this.bb.put(ONLabLddp.ONLAB_OUI);
this.bb.put(DPID_TLV_SUBTYPE);
this.bb.put(dpid);
@@ -272,9 +272,9 @@
final byte[] dst = new byte[6];
bb.get(dst);
- if (!(Arrays.equals(dst, OVXLLDP.LLDP_NICIRA)
- || Arrays.equals(dst, OVXLLDP.LLDP_MULTICAST) || Arrays.equals(
- dst, OVXLLDP.BDDP_MULTICAST))) {
+ if (!(Arrays.equals(dst, ONLabLddp.LLDP_NICIRA)
+ || Arrays.equals(dst, ONLabLddp.LLDP_MULTICAST) || Arrays.equals(
+ dst, ONLabLddp.BDDP_MULTICAST))) {
return false;
}