Removed packet classes that we don't use
Change-Id: I5ba69e02a611648c88f51e2e5b156c90eeb7959e
diff --git a/src/main/java/net/onrc/onos/core/packet/BPDU.java b/src/main/java/net/onrc/onos/core/packet/BPDU.java
deleted file mode 100644
index 6e8324a..0000000
--- a/src/main/java/net/onrc/onos/core/packet/BPDU.java
+++ /dev/null
@@ -1,139 +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 net.onrc.onos.core.packet;
-
-import java.nio.ByteBuffer;
-
-/**
- * This class is a Rapid Spanning Tree Protocol
- * Bridge Protocol Data Unit.
- * <!-- CHECKSTYLE IGNORE WriteTag FOR NEXT 1 LINES -->
- * @author alexreimers
- */
-public class BPDU extends BasePacket {
- public enum BPDUType {
- CONFIG,
- TOPOLOGY_CHANGE;
- }
-
- private static final long DEST_MAC = 0x0180c2000000L; // 01-80-c2-00-00-00
-
- // TODO - check this for RSTP
- private LLC llcHeader;
- private short protocolId = 0;
- private byte version = 0;
- private byte type;
- private byte flags;
- private byte[] rootBridgeId;
- private int rootPathCost;
- private byte[] senderBridgeId; // switch cluster MAC
- private short portId; // port it was transmitted from
- private short messageAge; // 256ths of a second
- private short maxAge; // 256ths of a second
- private short helloTime; // 256ths of a second
- private short forwardDelay; // 256ths of a second
-
- public BPDU(BPDUType type) {
- rootBridgeId = new byte[8];
- senderBridgeId = new byte[8];
-
- llcHeader = new LLC();
- llcHeader.setDsap((byte) 0x42);
- llcHeader.setSsap((byte) 0x42);
- llcHeader.setCtrl((byte) 0x03);
-
- switch (type) {
- case CONFIG:
- this.type = 0x0;
- break;
- case TOPOLOGY_CHANGE:
- this.type = (byte) 0x80; // 1000 0000
- break;
- default:
- this.type = 0;
- break;
- }
- }
-
- @Override
- public byte[] serialize() {
- byte[] data;
- // TODO check these
- if (type == 0x0) {
- // config
- data = new byte[38];
- } else {
- // topology change
- data = new byte[7]; // LLC + TC notification
- }
-
- ByteBuffer bb = ByteBuffer.wrap(data);
- // Serialize the LLC header
- byte[] llc = llcHeader.serialize();
- bb.put(llc, 0, llc.length);
- bb.putShort(protocolId);
- bb.put(version);
- bb.put(type);
-
- if (type == 0x0) {
- bb.put(flags);
- bb.put(rootBridgeId, 0, rootBridgeId.length);
- bb.putInt(rootPathCost);
- bb.put(senderBridgeId, 0, senderBridgeId.length);
- bb.putShort(portId);
- bb.putShort(messageAge);
- bb.putShort(maxAge);
- bb.putShort(helloTime);
- bb.putShort(forwardDelay);
- }
-
- return data;
- }
-
- @Override
- public IPacket deserialize(byte[] data, int offset, int length) {
- ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
-
- // LLC header
- llcHeader.deserialize(data, offset, 3);
-
- this.protocolId = bb.getShort();
- this.version = bb.get();
- this.type = bb.get();
-
- // These fields only exist if it's a configuration BPDU
- if (this.type == 0x0) {
- this.flags = bb.get();
- bb.get(rootBridgeId, 0, 6);
- this.rootPathCost = bb.getInt();
- bb.get(this.senderBridgeId, 0, 6);
- this.portId = bb.getShort();
- this.messageAge = bb.getShort();
- this.maxAge = bb.getShort();
- this.helloTime = bb.getShort();
- this.forwardDelay = bb.getShort();
- }
- // TODO should we set other fields to 0?
-
- return this;
- }
-
- public long getDestMac() {
- return DEST_MAC;
- }
-}
diff --git a/src/main/java/net/onrc/onos/core/packet/BSN.java b/src/main/java/net/onrc/onos/core/packet/BSN.java
deleted file mode 100644
index 5ac7110..0000000
--- a/src/main/java/net/onrc/onos/core/packet/BSN.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/**
- * Copyright 2012, Big Switch Networks, Inc.
- *
- * 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 net.onrc.onos.core.packet;
-
-import java.nio.ByteBuffer;
-import java.util.HashMap;
-import java.util.Map;
-
-// CHECKSTYLE IGNORE WriteTag FOR NEXT 2 LINES
-/**
- * @author Shudong Zhou (shudong.zhou@bigswitch.com)
- */
-public class BSN extends BasePacket {
- public static final int BSN_MAGIC = 0x20000604;
- public static final short BSN_VERSION_CURRENT = 0x0;
- public static final short BSN_TYPE_PROBE = 0x1;
- public static final short BSN_TYPE_BDDP = 0x2;
- public static final Map<Short, Class<? extends IPacket>> TYPE_CLASS_MAP;
-
- static {
- TYPE_CLASS_MAP = new HashMap<Short, Class<? extends IPacket>>();
- TYPE_CLASS_MAP.put(BSN_TYPE_PROBE, BSNPROBE.class);
- TYPE_CLASS_MAP.put(BSN_TYPE_BDDP, LLDP.class);
- }
-
- protected short type;
- protected short version;
-
- public BSN() {
- version = BSN_VERSION_CURRENT;
- }
-
- public BSN(short type) {
- this.type = type;
- version = BSN_VERSION_CURRENT;
- }
-
- public short getType() {
- return type;
- }
-
- public BSN setType(short type) {
- this.type = type;
- return this;
- }
-
- public short getVersion() {
- return version;
- }
-
- public BSN setVersion(short version) {
- this.version = version;
- return this;
- }
-
- @Override
- public byte[] serialize() {
- short length = 4 /* magic */ + 2 /* type */ + 2 /* version */;
-
- byte[] payloadData = null;
- if (this.payload != null) {
- payload.setParent(this);
- payloadData = payload.serialize();
- length += payloadData.length;
- }
-
- byte[] data = new byte[length];
- ByteBuffer bb = ByteBuffer.wrap(data);
- bb.putInt(BSN_MAGIC);
- bb.putShort(this.type);
- bb.putShort(this.version);
- if (payloadData != null) {
- bb.put(payloadData);
- }
-
- if (this.parent != null && this.parent instanceof Ethernet) {
- ((Ethernet) this.parent).setEtherType(Ethernet.TYPE_BSN);
- }
-
- return data;
- }
-
- @Override
- public IPacket deserialize(byte[] data, int offset, int length) {
- ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
-
- int magic = bb.getInt();
- if (magic != BSN_MAGIC) {
- throw new RuntimeException("Invalid BSN magic " + magic);
- }
-
- this.type = bb.getShort();
- this.version = bb.getShort();
- if (this.version != BSN_VERSION_CURRENT) {
- throw new RuntimeException(
- "Invalid BSN packet version " + this.version + ", should be "
- + BSN_VERSION_CURRENT);
- }
-
- IPacket payload;
- if (TYPE_CLASS_MAP.containsKey(this.type)) {
- Class<? extends IPacket> clazz = TYPE_CLASS_MAP.get(this.type);
- try {
- payload = clazz.newInstance();
- } catch (Exception e) {
- throw new RuntimeException("Error parsing payload for BSN packet" + e);
- }
- } else {
- payload = new Data();
- }
-
- this.payload = new Data();
- this.payload = payload.deserialize(data, bb.position(), bb.limit() - bb.position());
- this.payload.setParent(this);
-
- return this;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 883;
- int result = super.hashCode();
- result = prime * result + version;
- result = prime * result + type;
- 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 (!(obj instanceof BSN)) {
- return false;
- }
- BSN other = (BSN) obj;
- return (type == other.type &&
- version == other.version);
- }
-
- @Override
- public String toString() {
- StringBuffer sb = new StringBuffer("\n");
- sb.append("BSN packet");
- if (TYPE_CLASS_MAP.containsKey(this.type)) {
- sb.append(" type: " + TYPE_CLASS_MAP.get(this.type).getCanonicalName());
- } else {
- sb.append(" type: " + this.type);
- }
-
-
- return sb.toString();
- }
-}
diff --git a/src/main/java/net/onrc/onos/core/packet/BSNPROBE.java b/src/main/java/net/onrc/onos/core/packet/BSNPROBE.java
deleted file mode 100644
index b007cd9..0000000
--- a/src/main/java/net/onrc/onos/core/packet/BSNPROBE.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/**
- * Copyright 2012, Big Switch Networks, Inc.
- *
- * 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 net.onrc.onos.core.packet;
-
-import java.nio.ByteBuffer;
-import java.util.Arrays;
-
-import org.apache.commons.lang.ArrayUtils;
-import org.projectfloodlight.openflow.util.HexString;
-
-// CHECKSTYLE IGNORE WriteTag FOR NEXT 2 LINES
-/**
- * @author Shudong Zhou (shudong.zhou@bigswitch.com)
- */
-public class BSNPROBE extends BasePacket {
- protected long controllerId;
- protected int sequenceId;
- protected byte[] srcMac;
- protected byte[] dstMac;
- protected long srcSwDpid;
- protected int srcPortNo;
-
- public BSNPROBE() {
- srcMac = new byte[6];
- dstMac = new byte[6];
- }
-
-
- public long getControllerId() {
- return this.controllerId;
- }
-
- public BSNPROBE setControllerId(long controllerId) {
- this.controllerId = controllerId;
- return this;
- }
-
- public int getSequenceId() {
- return sequenceId;
- }
-
- public BSNPROBE setSequenceId(int sequenceId) {
- this.sequenceId = sequenceId;
- return this;
- }
-
- public byte[] getSrcMac() {
- return ArrayUtils.clone(this.srcMac);
- }
-
- public BSNPROBE setSrcMac(byte[] srcMac) {
- this.srcMac = ArrayUtils.clone(srcMac);
- return this;
- }
-
- public byte[] getDstMac() {
- return ArrayUtils.clone(this.dstMac);
- }
-
- public BSNPROBE setDstMac(byte[] dstMac) {
- this.dstMac = ArrayUtils.clone(dstMac);
- return this;
- }
-
- public long getSrcSwDpid() {
- return srcSwDpid;
- }
-
- public BSNPROBE setSrcSwDpid(long srcSwDpid) {
- this.srcSwDpid = srcSwDpid;
- return this;
- }
-
- public int getSrcPortNo() {
- return srcPortNo;
- }
-
- public BSNPROBE setSrcPortNo(int srcPortNo) {
- this.srcPortNo = srcPortNo;
- return this;
- }
-
- @Override
- public byte[] serialize() {
- short length = 8 /* controllerId */ + 4 /* seqId */
- + 12 /* srcMac dstMac */ + 8 /* srcSwDpid */ + 4 /* srcPortNo */;
-
- byte[] payloadData = null;
- if (this.payload != null) {
- payload.setParent(this);
- payloadData = payload.serialize();
- length += payloadData.length;
- }
-
- byte[] data = new byte[length];
- ByteBuffer bb = ByteBuffer.wrap(data);
- bb.putLong(this.controllerId);
- bb.putInt(this.sequenceId);
- bb.put(this.srcMac);
- bb.put(this.dstMac);
- bb.putLong(this.srcSwDpid);
- bb.putInt(this.srcPortNo);
- if (payloadData != null) {
- bb.put(payloadData);
- }
-
- if (this.parent != null && this.parent instanceof BSN) {
- ((BSN) this.parent).setType(BSN.BSN_TYPE_PROBE);
- }
-
- return data;
- }
-
- @Override
- public IPacket deserialize(byte[] data, int offset, int length) {
- ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
-
- controllerId = bb.getLong();
- sequenceId = bb.getInt();
- bb.get(this.srcMac, 0, 6);
- bb.get(this.dstMac, 0, 6);
- this.srcSwDpid = bb.getLong();
- this.srcPortNo = bb.getInt();
-
- if (bb.hasRemaining()) {
- this.payload = new Data();
- this.payload = payload.deserialize(data, bb.position(), bb.limit() - bb.position());
- this.payload.setParent(this);
- }
-
- return this;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 883;
- int result = super.hashCode();
- result = prime * result + Arrays.hashCode(srcMac);
- result = prime * result + Arrays.hashCode(dstMac);
- result = prime * result + (int) (srcSwDpid >> 32) + (int) srcSwDpid;
- result = prime * result + srcPortNo;
- 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 (!(obj instanceof BSNPROBE)) {
- return false;
- }
- BSNPROBE other = (BSNPROBE) obj;
- if (!Arrays.equals(srcMac, other.srcMac)) {
- return false;
- }
- if (!Arrays.equals(dstMac, other.dstMac)) {
- return false;
- }
- return (sequenceId == other.sequenceId &&
- srcSwDpid == other.srcSwDpid &&
- srcPortNo == other.srcPortNo
- );
- }
-
- @Override
- public String toString() {
- StringBuffer sb = new StringBuffer("\n");
- sb.append("BSN Probe packet");
- sb.append("\nSource Mac: ");
- sb.append(HexString.toHexString(srcMac));
- sb.append("\nDestination Mac: ");
- sb.append(HexString.toHexString(dstMac));
- sb.append("\nSource Switch: ");
- sb.append(HexString.toHexString(srcSwDpid));
- sb.append(" port: " + srcPortNo);
- sb.append("\nSequence No.:" + sequenceId);
-
- return sb.toString();
- }
-}
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 62e30f5..1eb6d69 100644
--- a/src/main/java/net/onrc/onos/core/packet/Ethernet.java
+++ b/src/main/java/net/onrc/onos/core/packet/Ethernet.java
@@ -47,7 +47,6 @@
ETHER_TYPE_CLASS_MAP.put(TYPE_RARP, ARP.class);
ETHER_TYPE_CLASS_MAP.put(TYPE_IPV4, IPv4.class);
ETHER_TYPE_CLASS_MAP.put(TYPE_LLDP, LLDP.class);
- ETHER_TYPE_CLASS_MAP.put(TYPE_BSN, BSN.class);
}
protected MACAddress destinationMACAddress;
@@ -477,8 +476,6 @@
sb.append("\ndata packet");
} else if (pkt instanceof LLC) {
sb.append("\nllc packet");
- } else if (pkt instanceof BPDU) {
- sb.append("\nbpdu packet");
} else {
sb.append("\nunknown packet");
}
diff --git a/src/main/java/net/onrc/onos/core/packet/LLDPOrganizationalTLV.java b/src/main/java/net/onrc/onos/core/packet/LLDPOrganizationalTLV.java
deleted file mode 100644
index 6f995c5..0000000
--- a/src/main/java/net/onrc/onos/core/packet/LLDPOrganizationalTLV.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/**
- * 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 net.onrc.onos.core.packet;
-
-import java.nio.ByteBuffer;
-import java.nio.charset.Charset;
-import java.util.Arrays;
-
-/**
- * The class representing LLDP Organizationally Specific TLV.
- *
- * <!-- CHECKSTYLE IGNORE WriteTag FOR NEXT 1 LINES -->
- * @author Sho Shimizu (sho.shimizu@gmail.com)
- */
-public class LLDPOrganizationalTLV extends LLDPTLV {
- public static final int OUI_LENGTH = 3;
- public static final int SUBTYPE_LENGTH = 1;
- public static final byte ORGANIZATIONAL_TLV_TYPE = 127;
- public static final int MAX_INFOSTRING_LENGTH = 507;
-
- protected byte[] oui;
- protected byte subType;
- private byte[] infoString;
-
- public LLDPOrganizationalTLV() {
- type = ORGANIZATIONAL_TLV_TYPE;
- }
-
- /**
- * Set the value of OUI.
- *
- * @param oui The value of OUI to be set.
- * @return This LLDP Organizationally Specific TLV.
- */
- public LLDPOrganizationalTLV setOUI(byte[] oui) {
- if (oui.length != OUI_LENGTH) {
- throw new IllegalArgumentException("The length of OUI must be " + OUI_LENGTH +
- ", but it is " + oui.length);
- }
- this.oui = Arrays.copyOf(oui, oui.length);
- return this;
- }
-
- /**
- * Returns the value of the OUI.
- *
- * @return The value of the OUI .
- */
- public byte[] getOUI() {
- return Arrays.copyOf(oui, oui.length);
- }
-
- /**
- * Set the value of sub type.
- *
- * @param subType The value of sub type to be set.
- * @return This LLDP Organizationally Specific TLV.
- */
- public LLDPOrganizationalTLV setSubType(byte subType) {
- this.subType = subType;
- return this;
- }
-
- /**
- * Returns the value of the sub type.
- *
- * @return The value of the sub type.
- */
- public byte getSubType() {
- return subType;
- }
-
- /**
- * Set the value of information string.
- *
- * @param infoString the byte array of the value of information string.
- * @return This LLDP Organizationally Specific TLV.
- */
- public LLDPOrganizationalTLV setInfoString(byte[] infoString) {
- if (infoString.length > MAX_INFOSTRING_LENGTH) {
- throw new IllegalArgumentException("The length of infoString cannot exceed " + MAX_INFOSTRING_LENGTH);
- }
- this.infoString = Arrays.copyOf(infoString, infoString.length);
- return this;
- }
-
- /**
- * Set the value of information string.
- * The String value is automatically converted into byte array with UTF-8 encoding.
- *
- * @param infoString the String value of information string.
- * @return This LLDP Organizationally Specific TLV.
- */
- public LLDPOrganizationalTLV setInfoString(String infoString) {
- byte[] infoStringBytes = infoString.getBytes(Charset.forName("UTF-8"));
- return setInfoString(infoStringBytes);
- }
-
- /**
- * Returns the value of information string.
- *
- * @return the value of information string.
- */
- public byte[] getInfoString() {
- return Arrays.copyOf(infoString, infoString.length);
- }
-
- @Override
- public byte[] serialize() {
- int valueLength = OUI_LENGTH + SUBTYPE_LENGTH + infoString.length;
- value = new byte[valueLength];
- ByteBuffer bb = ByteBuffer.wrap(value);
- bb.put(oui);
- bb.put(subType);
- bb.put(infoString);
- return super.serialize();
- }
-
- @Override
- public LLDPTLV deserialize(ByteBuffer bb) {
- super.deserialize(bb);
- ByteBuffer optionalField = ByteBuffer.wrap(value);
-
- byte[] oui = new byte[OUI_LENGTH];
- optionalField.get(oui);
- setOUI(oui);
-
- setSubType(optionalField.get());
-
- byte[] infoString = new byte[getLength() - OUI_LENGTH - SUBTYPE_LENGTH];
- optionalField.get(infoString);
- setInfoString(infoString);
- return this;
- }
-
- @Override
- public int hashCode() {
- final int prime = 1423;
- int result = 1;
- result = prime * result + type;
- result = prime * result + length;
- result = prime * result + Arrays.hashCode(oui);
- result = prime * result + subType;
- result = prime * result + Arrays.hashCode(infoString);
- return result;
- }
-
- @Override
- public boolean equals(Object o) {
- if (o == this) {
- return true;
- }
- if (!super.equals(o)) {
- return false;
- }
- //
- // NOTE: Subclasses are are considered as change of identity, hence
- // equals() will return false if the class type doesn't match.
- //
- if (getClass() != o.getClass()) {
- return false;
- }
- LLDPOrganizationalTLV other = (LLDPOrganizationalTLV) o;
- if (this.type != other.type) {
- return false;
- }
- if (this.length != other.length) {
- return false;
- }
- if (!Arrays.equals(this.oui, other.oui)) {
- return false;
- }
- if (this.subType != other.subType) {
- return false;
- }
- if (!Arrays.equals(this.infoString, other.infoString)) {
- return false;
- }
-
- return true;
- }
-}
diff --git a/src/test/java/net/onrc/onos/core/packet/BSNTest.java b/src/test/java/net/onrc/onos/core/packet/BSNTest.java
deleted file mode 100644
index ab28baf..0000000
--- a/src/test/java/net/onrc/onos/core/packet/BSNTest.java
+++ /dev/null
@@ -1,79 +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 net.onrc.onos.core.packet;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Arrays;
-
-import org.junit.Test;
-
-// CHECKSTYLE IGNORE WriteTag FOR NEXT 2 LINES
-/**
- * @author David Erickson (daviderickson@cs.stanford.edu)
- */
-public class BSNTest {
- protected byte[] probePkt = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, // src mac
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, // dst mac
- (byte) 0x89, 0x42, // BSN type
- 0x20, 0x00, 0x06, 0x04, 0x00, 0x01, 0x00, 0x00, // BSN header
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // controller id
- 0x00, 0x00, 0x00, 0x03, // sequence id
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, // src mac
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, // dst mac
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, // switch dpid
- 0x00, 0x00, 0x00, 0x01 // port number
- };
-
- protected Ethernet getProbePacket() {
- return (Ethernet) new Ethernet()
- .setSourceMACAddress("00:00:00:00:00:04")
- .setDestinationMACAddress("00:00:00:00:00:01")
- .setEtherType(Ethernet.TYPE_BSN)
- .setPayload(new BSN(BSN.BSN_TYPE_PROBE)
- .setPayload(new BSNPROBE()
- .setSequenceId(3)
- .setSrcMac(new byte[]{0x00, 0x00, 0x00, 0x00, 0x00, 0x01})
- .setDstMac(new byte[]{0x00, 0x00, 0x00, 0x00, 0x00, 0x04})
- .setSrcSwDpid(0x06)
- .setSrcPortNo(0x01)
- )
- );
- }
-
- @Test
- public void testSerialize() throws Exception {
- Ethernet pkt = getProbePacket();
- byte[] serialized = pkt.serialize();
- assertTrue(Arrays.equals(probePkt, serialized));
- }
-
- @Test
- public void testDeserialize() throws Exception {
- Ethernet pkt = (Ethernet) new Ethernet().deserialize(probePkt, 0, probePkt.length);
- assertTrue(Arrays.equals(probePkt, pkt.serialize()));
-
- Ethernet expected = getProbePacket();
- assertEquals(expected, pkt);
- }
-}
diff --git a/src/test/java/net/onrc/onos/core/packet/LLDPOrganizationalTLVTest.java b/src/test/java/net/onrc/onos/core/packet/LLDPOrganizationalTLVTest.java
deleted file mode 100644
index f680e93..0000000
--- a/src/test/java/net/onrc/onos/core/packet/LLDPOrganizationalTLVTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/**
- * 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 net.onrc.onos.core.packet;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-import java.nio.ByteBuffer;
-import java.nio.charset.Charset;
-
-import org.junit.Test;
-
-public class LLDPOrganizationalTLVTest {
- private final byte[] expected = new byte[]{
- // Type: 127, Length: 13
- (byte) 254, 13,
- // OpenFlow OUI: 00-26-E1
- 0x0, 0x26, (byte) 0xe1,
- // SubType: 12
- 0xc,
- // Bytes in "ExtraInfo"
- 0x45, 0x78, 0x74, 0x72, 0x61, 0x49, 0x6e, 0x66, 0x6f
- };
-
- @Test(expected = IllegalArgumentException.class)
- public void testShortOUI() {
- LLDPOrganizationalTLV tlv = new LLDPOrganizationalTLV();
- tlv.setOUI(new byte[2]);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testLongOUI() {
- LLDPOrganizationalTLV tlv = new LLDPOrganizationalTLV();
- tlv.setOUI(new byte[4]);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testLongInfoString() {
- LLDPOrganizationalTLV tlv = new LLDPOrganizationalTLV();
- tlv.setInfoString(new byte[LLDPOrganizationalTLV.MAX_INFOSTRING_LENGTH + 1]);
- }
-
- @Test
- public void testMaxInfoString() {
- LLDPOrganizationalTLV tlv = new LLDPOrganizationalTLV();
- tlv.setInfoString(new byte[LLDPOrganizationalTLV.MAX_INFOSTRING_LENGTH]);
- }
-
- @Test
- public void testInfoString() {
- LLDPOrganizationalTLV tlv = new LLDPOrganizationalTLV();
- tlv.setInfoString("ExtraInfo");
- assertThat(tlv.getInfoString(), is("ExtraInfo".getBytes(Charset.forName("UTF-8"))));
- }
-
- @Test
- public void testSerialize() {
- LLDPOrganizationalTLV tlv = new LLDPOrganizationalTLV();
- tlv.setLength((short) 13);
- // OpenFlow OUI is 00-26-E1
- tlv.setOUI(new byte[]{0x0, 0x26, (byte) 0xe1});
- tlv.setSubType((byte) 12);
- tlv.setInfoString("ExtraInfo".getBytes(Charset.forName("UTF-8")));
-
- assertThat(tlv.getType(), is((byte) 127));
- assertThat(tlv.getLength(), is((short) 13));
- assertThat(tlv.getOUI(), is(new byte[]{0x0, 0x26, (byte) 0xe1}));
- assertThat(tlv.getSubType(), is((byte) 12));
- assertThat(tlv.serialize(), is(expected));
- }
-
- @Test
- public void testDeserialize() {
- LLDPOrganizationalTLV tlv = new LLDPOrganizationalTLV();
- tlv.deserialize(ByteBuffer.wrap(expected));
-
- assertThat(tlv.getType(), is((byte) 127));
- assertThat(tlv.getLength(), is((short) 13));
- assertThat(tlv.getOUI(), is(new byte[]{0x0, 0x26, (byte) 0xe1}));
- assertThat(tlv.getSubType(), is((byte) 12));
- assertThat(tlv.getInfoString(), is("ExtraInfo".getBytes(Charset.forName("UTF-8"))));
- }
-}