aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types')
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AreaIDTlv.java14
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/As4Path.java22
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AsPath.java22
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AutonomousSystemTlv.java14
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpErrorType.java (renamed from framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BGPErrorType.java)4
-rwxr-xr-xframework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpHeader.java (renamed from framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BGPHeader.java)12
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpLSIdentifierTlv.java (renamed from framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BGPLSIdentifierTlv.java)58
-rw-r--r--[-rwxr-xr-x]framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpValueType.java (renamed from framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BGPValueType.java)10
-rw-r--r--[-rwxr-xr-x]framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/FourOctetAsNumCapabilityTlv.java8
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPReachabilityInformationTlv.java18
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPv4AddressTlv.java27
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPv6AddressTlv.java27
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IsIsNonPseudonode.java27
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IsIsPseudonode.java72
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/LinkLocalRemoteIdentifiersTlv.java19
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/LinkStateAttributes.java314
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/LocalPref.java18
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/Med.java18
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/MpReachNlri.java50
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/MpUnReachNlri.java52
-rw-r--r--[-rwxr-xr-x]framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/MultiProtocolExtnCapabilityTlv.java10
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/NextHop.java20
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFNonPseudonode.java15
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFPseudonode.java19
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFRouteTypeTlv.java39
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/Origin.java20
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/RouteDistinguisher.java19
-rwxr-xr-xframework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeFlagBitTlv.java22
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeIsIsAreaId.java136
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeMultiTopologyId.java43
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeName.java135
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrOpaqueNode.java138
-rw-r--r--[-rwxr-xr-x]framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV4.java22
-rw-r--r--[-rwxr-xr-x]framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV6.java22
-rw-r--r--[-rwxr-xr-x]framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrIgpMetric.java22
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrIsIsAdminstGrp.java22
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrMaxLinkBandwidth.java22
-rw-r--r--[-rwxr-xr-x]framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrMplsProtocolMask.java22
-rw-r--r--[-rwxr-xr-x]framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrName.java22
-rw-r--r--[-rwxr-xr-x]framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrOpaqLnkAttrib.java22
-rw-r--r--[-rwxr-xr-x]framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrProtectionType.java22
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrSrlg.java136
-rw-r--r--[-rwxr-xr-x]framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrTeDefaultMetric.java22
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrUnRsrvdLinkBandwidth.java163
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrExtRouteTag.java145
-rw-r--r--[-rwxr-xr-x]framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrIgpFlags.java22
-rw-r--r--[-rwxr-xr-x]framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrMetric.java22
-rw-r--r--[-rwxr-xr-x]framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrOpaqueData.java21
-rw-r--r--[-rwxr-xr-x]framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrOspfFwdAddr.java22
-rw-r--r--[-rwxr-xr-x]framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrRouteTag.java22
50 files changed, 1807 insertions, 388 deletions
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AreaIDTlv.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AreaIDTlv.java
index 52bae466..842c6f02 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AreaIDTlv.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AreaIDTlv.java
@@ -18,15 +18,13 @@ package org.onosproject.bgpio.types;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
/**
* Provides AreaID Tlv which contains opaque value (32 Bit Area-ID).
*/
-public class AreaIDTlv implements BGPValueType {
+public class AreaIDTlv implements BgpValueType {
/* Reference :draft-ietf-idr-ls-distribution-11
* 0 1 2 3
@@ -38,8 +36,6 @@ public class AreaIDTlv implements BGPValueType {
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
- protected static final Logger log = LoggerFactory.getLogger(AreaIDTlv.class);
-
public static final short TYPE = 514;
public static final short LENGTH = 4;
@@ -116,6 +112,14 @@ public class AreaIDTlv implements BGPValueType {
}
@Override
+ public int compareTo(Object o) {
+ if (this.equals(o)) {
+ return 0;
+ }
+ return ((Integer) (this.areaID)).compareTo((Integer) (((AreaIDTlv) o).areaID));
+ }
+
+ @Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("Type", TYPE)
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/As4Path.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/As4Path.java
index e9df3999..3ceca2ce 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/As4Path.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/As4Path.java
@@ -20,7 +20,7 @@ import java.util.List;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BGPParseException;
+import org.onosproject.bgpio.exceptions.BgpParseException;
import org.onosproject.bgpio.util.Constants;
import org.onosproject.bgpio.util.Validation;
import org.slf4j.Logger;
@@ -31,7 +31,7 @@ import com.google.common.base.MoreObjects;
/**
* Provides Implementation of As4Path BGP Path Attribute.
*/
-public class As4Path implements BGPValueType {
+public class As4Path implements BgpValueType {
private static final Logger log = LoggerFactory.getLogger(AsPath.class);
public static final byte AS4PATH_TYPE = 17;
public static final byte ASNUM_SIZE = 4;
@@ -63,16 +63,16 @@ public class As4Path implements BGPValueType {
*
* @param cb ChannelBuffer
* @return object of As4Path
- * @throws BGPParseException while parsing As4Path
+ * @throws BgpParseException while parsing As4Path
*/
- public static As4Path read(ChannelBuffer cb) throws BGPParseException {
+ public static As4Path read(ChannelBuffer cb) throws BgpParseException {
List<Integer> as4pathSet = new ArrayList<>();
List<Integer> as4pathSeq = new ArrayList<>();
ChannelBuffer tempCb = cb.copy();
Validation validation = Validation.parseAttributeHeader(cb);
if (cb.readableBytes() < validation.getLength()) {
- Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR, BGPErrorType.ATTRIBUTE_LENGTH_ERROR,
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
validation.getLength());
}
//if fourth bit is set length is read as short otherwise as byte , len includes type, length and value
@@ -80,7 +80,7 @@ public class As4Path implements BGPValueType {
.getLength() + Constants.TYPE_AND_LEN_AS_BYTE;
ChannelBuffer data = tempCb.readBytes(len);
if (validation.getFirstBit() && !validation.getSecondBit() && validation.getThirdBit()) {
- throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, BGPErrorType.ATTRIBUTE_FLAGS_ERROR, data);
+ throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_FLAGS_ERROR, data);
}
ChannelBuffer tempBuf = cb.readBytes(validation.getLength());
@@ -91,8 +91,8 @@ public class As4Path implements BGPValueType {
//length = no of Ases * ASnum size (4 bytes)
int length = pathSegLen * ASNUM_SIZE;
if (tempBuf.readableBytes() < length) {
- Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR,
- BGPErrorType.ATTRIBUTE_LENGTH_ERROR, length);
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.ATTRIBUTE_LENGTH_ERROR, length);
}
ChannelBuffer aspathBuf = tempBuf.readBytes(length);
while (aspathBuf.readableBytes() > 0) {
@@ -166,4 +166,10 @@ public class As4Path implements BGPValueType {
//Not required to Implement as of now
return 0;
}
+
+ @Override
+ public int compareTo(Object o) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
} \ No newline at end of file
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AsPath.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AsPath.java
index e3eb2c51..2a050c44 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AsPath.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AsPath.java
@@ -21,7 +21,7 @@ import java.util.List;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BGPParseException;
+import org.onosproject.bgpio.exceptions.BgpParseException;
import org.onosproject.bgpio.util.Constants;
import org.onosproject.bgpio.util.Validation;
import org.slf4j.Logger;
@@ -32,7 +32,7 @@ import com.google.common.base.MoreObjects;
/**
* Provides Implementation of AsPath mandatory BGP Path Attribute.
*/
-public class AsPath implements BGPValueType {
+public class AsPath implements BgpValueType {
/**
* Enum to provide AS types.
*/
@@ -94,16 +94,16 @@ public class AsPath implements BGPValueType {
*
* @param cb ChannelBuffer
* @return object of AsPath
- * @throws BGPParseException while parsing AsPath
+ * @throws BgpParseException while parsing AsPath
*/
- public static AsPath read(ChannelBuffer cb) throws BGPParseException {
+ public static AsPath read(ChannelBuffer cb) throws BgpParseException {
List<Short> aspathSet = new ArrayList<>();
List<Short> aspathSeq = new ArrayList<>();
ChannelBuffer tempCb = cb.copy();
Validation validation = Validation.parseAttributeHeader(cb);
if (cb.readableBytes() < validation.getLength()) {
- Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR, BGPErrorType.ATTRIBUTE_LENGTH_ERROR,
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
validation.getLength());
}
//if fourth bit is set, length is read as short otherwise as byte , len includes type, length and value
@@ -111,7 +111,7 @@ public class AsPath implements BGPValueType {
.getLength() + Constants.TYPE_AND_LEN_AS_BYTE;
ChannelBuffer data = tempCb.readBytes(len);
if (validation.getFirstBit() && !validation.getSecondBit() && validation.getThirdBit()) {
- throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, BGPErrorType.ATTRIBUTE_FLAGS_ERROR, data);
+ throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_FLAGS_ERROR, data);
}
ChannelBuffer tempBuf = cb.readBytes(validation.getLength());
@@ -121,8 +121,8 @@ public class AsPath implements BGPValueType {
byte pathSegLen = tempBuf.readByte();
int length = pathSegLen * ASNUM_SIZE;
if (tempBuf.readableBytes() < length) {
- Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR,
- BGPErrorType.ATTRIBUTE_LENGTH_ERROR, length);
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.ATTRIBUTE_LENGTH_ERROR, length);
}
ChannelBuffer aspathBuf = tempBuf.readBytes(length);
while (aspathBuf.readableBytes() > 0) {
@@ -205,4 +205,10 @@ public class AsPath implements BGPValueType {
//Not required to Implement as of now
return 0;
}
+
+ @Override
+ public int compareTo(Object o) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
} \ No newline at end of file
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AutonomousSystemTlv.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AutonomousSystemTlv.java
index 5d8a9193..119926c8 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AutonomousSystemTlv.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AutonomousSystemTlv.java
@@ -18,15 +18,13 @@ package org.onosproject.bgpio.types;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
/**
* Provides Autonomous System Tlv which contains opaque value (32 Bit AS Number).
*/
-public class AutonomousSystemTlv implements BGPValueType {
+public class AutonomousSystemTlv implements BgpValueType {
/* Reference :draft-ietf-idr-ls-distribution-11
* 0 1 2 3
@@ -38,8 +36,6 @@ public class AutonomousSystemTlv implements BGPValueType {
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
- protected static final Logger log = LoggerFactory.getLogger(AutonomousSystemTlv.class);
-
public static final short TYPE = 512;
public static final short LENGTH = 4;
@@ -116,6 +112,14 @@ public class AutonomousSystemTlv implements BGPValueType {
}
@Override
+ public int compareTo(Object o) {
+ if (this.equals(o)) {
+ return 0;
+ }
+ return ((Integer) (this.asNum)).compareTo((Integer) (((AutonomousSystemTlv) o).asNum));
+ }
+
+ @Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("Type", TYPE)
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BGPErrorType.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpErrorType.java
index dfcfc9dc..c0932ebe 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BGPErrorType.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpErrorType.java
@@ -19,8 +19,8 @@ package org.onosproject.bgpio.types;
/**
* BgpErrorType class defines all errorCodes and error Subcodes required for Notification message.
*/
-public final class BGPErrorType {
- private BGPErrorType() {
+public final class BgpErrorType {
+ private BgpErrorType() {
}
//Error Codes
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BGPHeader.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpHeader.java
index 6acda0d6..ad637753 100755
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BGPHeader.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpHeader.java
@@ -23,7 +23,7 @@ import org.slf4j.LoggerFactory;
* Provides BGP Message Header which is common for all the Messages.
*/
-public class BGPHeader {
+public class BgpHeader {
/* 0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
@@ -40,7 +40,7 @@ public class BGPHeader {
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
- protected static final Logger log = LoggerFactory.getLogger(BGPHeader.class);
+ protected static final Logger log = LoggerFactory.getLogger(BgpHeader.class);
public static final int MARKER_LENGTH = 16;
public static final short DEFAULT_HEADER_LENGTH = 19;
@@ -52,7 +52,7 @@ public class BGPHeader {
/**
* Reset fields.
*/
- public BGPHeader() {
+ public BgpHeader() {
this.marker = null;
this.length = 0;
this.type = 0;
@@ -65,7 +65,7 @@ public class BGPHeader {
* @param length message length
* @param type message type
*/
- public BGPHeader(byte[] marker, short length, byte type) {
+ public BgpHeader(byte[] marker, short length, byte type) {
this.marker = marker;
this.length = length;
this.type = type;
@@ -148,7 +148,7 @@ public class BGPHeader {
* @param cb ChannelBuffer
* @return object of BGPHeader
*/
- public static BGPHeader read(ChannelBuffer cb) {
+ public static BgpHeader read(ChannelBuffer cb) {
byte[] marker = new byte[MARKER_LENGTH];
byte type;
@@ -156,6 +156,6 @@ public class BGPHeader {
cb.readBytes(marker, 0, MARKER_LENGTH);
length = cb.readShort();
type = cb.readByte();
- return new BGPHeader(marker, length, type);
+ return new BgpHeader(marker, length, type);
}
} \ No newline at end of file
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BGPLSIdentifierTlv.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpLSIdentifierTlv.java
index f723d2ca..58645d4f 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BGPLSIdentifierTlv.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpLSIdentifierTlv.java
@@ -19,15 +19,13 @@ package org.onosproject.bgpio.types;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
/**
* Provides BGPLSIdentifier Tlv which contains opaque value (32 Bit BGPLS-Identifier).
*/
-public class BGPLSIdentifierTlv implements BGPValueType {
+public class BgpLSIdentifierTlv implements BgpValueType {
/* Reference :draft-ietf-idr-ls-distribution-11
* 0 1 2 3
@@ -39,44 +37,42 @@ public class BGPLSIdentifierTlv implements BGPValueType {
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
- protected static final Logger log = LoggerFactory.getLogger(BGPLSIdentifierTlv.class);
-
public static final short TYPE = 513;
public static final short LENGTH = 4;
- private final int bgpLSIdentifier;
+ private final int bgpLsIdentifier;
/**
- * Constructor to initialize bgpLSIdentifier.
+ * Constructor to initialize bgpLsIdentifier.
*
- * @param bgpLSIdentifier BgpLS-Identifier
+ * @param bgpLsIdentifier BGPLS-Identifier
*/
- public BGPLSIdentifierTlv(int bgpLSIdentifier) {
- this.bgpLSIdentifier = bgpLSIdentifier;
+ public BgpLSIdentifierTlv(int bgpLsIdentifier) {
+ this.bgpLsIdentifier = bgpLsIdentifier;
}
/**
- * Returns object of this class with specified rbgpLSIdentifier.
+ * Returns object of this class with specified bgpLsIdentifier.
*
- * @param bgpLSIdentifier BgpLS-Identifier
- * @return BgpLS-Identifier
+ * @param bgpLsIdentifier BGPLS-Identifier
+ * @return BGPLS-Identifier
*/
- public static BGPLSIdentifierTlv of(final int bgpLSIdentifier) {
- return new BGPLSIdentifierTlv(bgpLSIdentifier);
+ public static BgpLSIdentifierTlv of(final int bgpLsIdentifier) {
+ return new BgpLSIdentifierTlv(bgpLsIdentifier);
}
/**
- * Returns opaque value of BgpLS-Identifier.
+ * Returns opaque value of BGPLS-Identifier.
*
- * @return opaque value of BgpLS-Identifier
+ * @return opaque value of BGPLS-Identifier
*/
- public int getBgpLSIdentifier() {
- return bgpLSIdentifier;
+ public int getBgpLsIdentifier() {
+ return bgpLsIdentifier;
}
@Override
public int hashCode() {
- return Objects.hash(bgpLSIdentifier);
+ return Objects.hash(bgpLsIdentifier);
}
@Override
@@ -85,9 +81,9 @@ public class BGPLSIdentifierTlv implements BGPValueType {
return true;
}
- if (obj instanceof BGPLSIdentifierTlv) {
- BGPLSIdentifierTlv other = (BGPLSIdentifierTlv) obj;
- return Objects.equals(bgpLSIdentifier, other.bgpLSIdentifier);
+ if (obj instanceof BgpLSIdentifierTlv) {
+ BgpLSIdentifierTlv other = (BgpLSIdentifierTlv) obj;
+ return Objects.equals(bgpLsIdentifier, other.bgpLsIdentifier);
}
return false;
}
@@ -97,7 +93,7 @@ public class BGPLSIdentifierTlv implements BGPValueType {
int iLenStartIndex = c.writerIndex();
c.writeShort(TYPE);
c.writeShort(LENGTH);
- c.writeInt(bgpLSIdentifier);
+ c.writeInt(bgpLsIdentifier);
return c.writerIndex() - iLenStartIndex;
}
@@ -107,8 +103,8 @@ public class BGPLSIdentifierTlv implements BGPValueType {
* @param cb ChannelBuffer
* @return object of BGPLSIdentifierTlv
*/
- public static BGPLSIdentifierTlv read(ChannelBuffer cb) {
- return BGPLSIdentifierTlv.of(cb.readInt());
+ public static BgpLSIdentifierTlv read(ChannelBuffer cb) {
+ return BgpLSIdentifierTlv.of(cb.readInt());
}
@Override
@@ -117,11 +113,19 @@ public class BGPLSIdentifierTlv implements BGPValueType {
}
@Override
+ public int compareTo(Object o) {
+ if (this.equals(o)) {
+ return 0;
+ }
+ return ((Integer) (this.bgpLsIdentifier)).compareTo((Integer) (((BgpLSIdentifierTlv) o).bgpLsIdentifier));
+ }
+
+ @Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("Type", TYPE)
.add("Length", LENGTH)
- .add("Value", bgpLSIdentifier)
+ .add("Value", bgpLsIdentifier)
.toString();
}
} \ No newline at end of file
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BGPValueType.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpValueType.java
index 54a8b43c..af7f4b75 100755..100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BGPValueType.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpValueType.java
@@ -21,7 +21,7 @@ import org.jboss.netty.buffer.ChannelBuffer;
/**
* Abstraction which Provides the BGP of TLV format.
*/
-public interface BGPValueType {
+public interface BgpValueType {
/**
* Returns the Type of BGP Message.
*
@@ -36,4 +36,12 @@ public interface BGPValueType {
* @return length written to channel buffer
*/
int write(ChannelBuffer cb);
+
+ /**
+ * Compares two objects.
+ *
+ * @param o object
+ * @return result after comparing two objects
+ */
+ int compareTo(Object o);
} \ No newline at end of file
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/FourOctetAsNumCapabilityTlv.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/FourOctetAsNumCapabilityTlv.java
index 61570285..59db3318 100755..100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/FourOctetAsNumCapabilityTlv.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/FourOctetAsNumCapabilityTlv.java
@@ -26,7 +26,7 @@ import com.google.common.base.MoreObjects;
/**
* Provides FourOctetAsNumCapabilityTlv Capability Tlv.
*/
-public class FourOctetAsNumCapabilityTlv implements BGPValueType {
+public class FourOctetAsNumCapabilityTlv implements BgpValueType {
/**
* support to indicate its support for four-octet AS numbers -CAPABILITY TLV format.
@@ -111,4 +111,10 @@ public class FourOctetAsNumCapabilityTlv implements BGPValueType {
.add("Length", LENGTH)
.add("Value", rawValue).toString();
}
+
+ @Override
+ public int compareTo(Object o) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPReachabilityInformationTlv.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPReachabilityInformationTlv.java
index 59afbed6..d97537e8 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPReachabilityInformationTlv.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPReachabilityInformationTlv.java
@@ -15,21 +15,20 @@
*/
package org.onosproject.bgpio.types;
+import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onlab.packet.IpPrefix;
import org.onosproject.bgpio.util.Validation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
/**
* Provides IP Reachability InformationTlv Tlv which contains IP Prefix.
*/
-public class IPReachabilityInformationTlv implements BGPValueType {
+public class IPReachabilityInformationTlv implements BgpValueType {
/*
* Reference :draft-ietf-idr-ls-distribution-11
@@ -45,10 +44,9 @@ public class IPReachabilityInformationTlv implements BGPValueType {
Figure 14: IP Reachability Information TLV Format
*/
- protected static final Logger log = LoggerFactory.getLogger(IPReachabilityInformationTlv.class);
-
public static final short TYPE = 265;
public static final int ONE_BYTE_LEN = 8;
+
private byte prefixLen;
private byte[] ipPrefix;
public short length;
@@ -146,6 +144,16 @@ public class IPReachabilityInformationTlv implements BGPValueType {
}
@Override
+ public int compareTo(Object o) {
+ if (this.equals(o)) {
+ return 0;
+ }
+ ByteBuffer value1 = ByteBuffer.wrap(this.ipPrefix);
+ ByteBuffer value2 = ByteBuffer.wrap(((IPReachabilityInformationTlv) o).ipPrefix);
+ return value1.compareTo(value2);
+ }
+
+ @Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("Type", TYPE)
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPv4AddressTlv.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPv4AddressTlv.java
index d5f03268..4efde70e 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPv4AddressTlv.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPv4AddressTlv.java
@@ -20,9 +20,8 @@ import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onlab.packet.Ip4Address;
-import org.onosproject.bgpio.exceptions.BGPParseException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.onosproject.bgpio.exceptions.BgpParseException;
+import org.onosproject.bgpio.util.Validation;
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
@@ -30,8 +29,7 @@ import com.google.common.base.Preconditions;
/**
* Provides Implementation of IPv4AddressTlv.
*/
-public class IPv4AddressTlv implements BGPValueType {
- private static final Logger log = LoggerFactory.getLogger(IPv4AddressTlv.class);
+public class IPv4AddressTlv implements BgpValueType {
private static final int LENGTH = 4;
private Ip4Address address;
@@ -53,7 +51,7 @@ public class IPv4AddressTlv implements BGPValueType {
*
* @return Ipv4 address of interface/neighbor
*/
- public Ip4Address getValue() {
+ public Ip4Address address() {
return address;
}
@@ -94,13 +92,12 @@ public class IPv4AddressTlv implements BGPValueType {
* @param cb channelBuffer
* @param type address type
* @return object of IPv4AddressTlv
- * @throws BGPParseException while parsing IPv4AddressTlv
+ * @throws BgpParseException while parsing IPv4AddressTlv
*/
- public static IPv4AddressTlv read(ChannelBuffer cb, short type) throws BGPParseException {
- //TODO: use Validation.toInetAddress once Validation is merged
- InetAddress ipAddress = (InetAddress) cb.readBytes(LENGTH);
+ public static IPv4AddressTlv read(ChannelBuffer cb, short type) throws BgpParseException {
+ InetAddress ipAddress = Validation.toInetAddress(LENGTH, cb);
if (ipAddress.isMulticastAddress()) {
- throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, (byte) 0, null);
+ throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, (byte) 0, null);
}
Ip4Address address = Ip4Address.valueOf(ipAddress);
return IPv4AddressTlv.of(address, type);
@@ -118,6 +115,14 @@ public class IPv4AddressTlv implements BGPValueType {
}
@Override
+ public int compareTo(Object o) {
+ if (this.equals(o)) {
+ return 0;
+ }
+ return ((Ip4Address) (this.address)).compareTo((Ip4Address) (((IPv4AddressTlv) o).address));
+ }
+
+ @Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("type", type)
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPv6AddressTlv.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPv6AddressTlv.java
index 65b7c16d..087cd5c6 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPv6AddressTlv.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPv6AddressTlv.java
@@ -20,9 +20,8 @@ import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onlab.packet.Ip6Address;
-import org.onosproject.bgpio.exceptions.BGPParseException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.onosproject.bgpio.exceptions.BgpParseException;
+import org.onosproject.bgpio.util.Validation;
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
@@ -30,8 +29,7 @@ import com.google.common.base.Preconditions;
/**
* Provides Implementation of IPv6AddressTlv.
*/
-public class IPv6AddressTlv implements BGPValueType {
- private static final Logger log = LoggerFactory.getLogger(IPv6AddressTlv.class);
+public class IPv6AddressTlv implements BgpValueType {
private static final int LENGTH = 16;
private final Ip6Address address;
@@ -53,7 +51,7 @@ public class IPv6AddressTlv implements BGPValueType {
*
* @return Ipv6 address of interface/neighbor
*/
- public Ip6Address getValue() {
+ public Ip6Address address() {
return address;
}
@@ -94,13 +92,12 @@ public class IPv6AddressTlv implements BGPValueType {
* @param cb channelBuffer
* @param type address type
* @return object of IPv6AddressTlv
- * @throws BGPParseException while parsing IPv6AddressTlv
+ * @throws BgpParseException while parsing IPv6AddressTlv
*/
- public static IPv6AddressTlv read(ChannelBuffer cb, short type) throws BGPParseException {
- //TODO: use Validation.toInetAddress once Validation is merged
- InetAddress ipAddress = (InetAddress) cb.readBytes(LENGTH);
+ public static IPv6AddressTlv read(ChannelBuffer cb, short type) throws BgpParseException {
+ InetAddress ipAddress = Validation.toInetAddress(LENGTH, cb);
if (ipAddress.isMulticastAddress()) {
- throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, (byte) 0, null);
+ throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, (byte) 0, null);
}
Ip6Address address = Ip6Address.valueOf(ipAddress);
return IPv6AddressTlv.of(address, type);
@@ -118,6 +115,14 @@ public class IPv6AddressTlv implements BGPValueType {
}
@Override
+ public int compareTo(Object o) {
+ if (this.equals(o)) {
+ return 0;
+ }
+ return ((Ip6Address) (this.address)).compareTo((Ip6Address) (((IPv6AddressTlv) o).address));
+ }
+
+ @Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("type", type)
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IsIsNonPseudonode.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IsIsNonPseudonode.java
index d5f3e7f3..427aa929 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IsIsNonPseudonode.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IsIsNonPseudonode.java
@@ -15,21 +15,18 @@
*/
package org.onosproject.bgpio.types;
-import java.util.Objects;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.bgpio.protocol.IGPRouterID;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
/**
* Provides Implementation of IsIsNonPseudonode Tlv.
*/
-public class IsIsNonPseudonode implements IGPRouterID, BGPValueType {
- protected static final Logger log = LoggerFactory.getLogger(IsIsNonPseudonode.class);
-
+public class IsIsNonPseudonode implements IGPRouterID, BgpValueType {
public static final short TYPE = 515;
public static final short LENGTH = 6;
@@ -41,7 +38,7 @@ public class IsIsNonPseudonode implements IGPRouterID, BGPValueType {
* @param isoNodeID ISO system-ID
*/
public IsIsNonPseudonode(byte[] isoNodeID) {
- this.isoNodeID = isoNodeID;
+ this.isoNodeID = Arrays.copyOf(isoNodeID, isoNodeID.length);
}
/**
@@ -65,7 +62,7 @@ public class IsIsNonPseudonode implements IGPRouterID, BGPValueType {
@Override
public int hashCode() {
- return Objects.hash(isoNodeID);
+ return Arrays.hashCode(isoNodeID);
}
@Override
@@ -75,7 +72,7 @@ public class IsIsNonPseudonode implements IGPRouterID, BGPValueType {
}
if (obj instanceof IsIsNonPseudonode) {
IsIsNonPseudonode other = (IsIsNonPseudonode) obj;
- return Objects.equals(isoNodeID, other.isoNodeID);
+ return Arrays.equals(isoNodeID, other.isoNodeID);
}
return false;
}
@@ -97,7 +94,7 @@ public class IsIsNonPseudonode implements IGPRouterID, BGPValueType {
*/
public static IsIsNonPseudonode read(ChannelBuffer cb) {
byte[] isoNodeID = new byte[LENGTH];
- cb.readBytes(isoNodeID, 0, LENGTH);
+ cb.readBytes(isoNodeID);
return IsIsNonPseudonode.of(isoNodeID);
}
@@ -107,6 +104,16 @@ public class IsIsNonPseudonode implements IGPRouterID, BGPValueType {
}
@Override
+ public int compareTo(Object o) {
+ if (this.equals(o)) {
+ return 0;
+ }
+ ByteBuffer value1 = ByteBuffer.wrap(this.isoNodeID);
+ ByteBuffer value2 = ByteBuffer.wrap(((IsIsNonPseudonode) o).isoNodeID);
+ return value1.compareTo(value2);
+ }
+
+ @Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("Type", TYPE)
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IsIsPseudonode.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IsIsPseudonode.java
index 35fd2493..094c4382 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IsIsPseudonode.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IsIsPseudonode.java
@@ -15,28 +15,23 @@
*/
package org.onosproject.bgpio.types;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.bgpio.protocol.IGPRouterID;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
/**
* Provides implementation of IsIsPseudonode Tlv.
*/
-public class IsIsPseudonode implements IGPRouterID, BGPValueType {
- private static final Logger log = LoggerFactory.getLogger(IsIsPseudonode.class);
-
+public class IsIsPseudonode implements IGPRouterID, BgpValueType {
public static final short TYPE = 515;
public static final short LENGTH = 7;
- private final List<Byte> isoNodeID;
+ private final byte[] isoNodeID;
private byte psnIdentifier;
/**
@@ -45,8 +40,8 @@ public class IsIsPseudonode implements IGPRouterID, BGPValueType {
* @param isoNodeID ISO system-ID
* @param psnIdentifier PSN identifier
*/
- public IsIsPseudonode(List<Byte> isoNodeID, byte psnIdentifier) {
- this.isoNodeID = isoNodeID;
+ public IsIsPseudonode(byte[] isoNodeID, byte psnIdentifier) {
+ this.isoNodeID = Arrays.copyOf(isoNodeID, isoNodeID.length);
this.psnIdentifier = psnIdentifier;
}
@@ -57,7 +52,7 @@ public class IsIsPseudonode implements IGPRouterID, BGPValueType {
* @param psnIdentifier PSN identifier
* @return object of IsIsPseudonode
*/
- public static IsIsPseudonode of(final List<Byte> isoNodeID,
+ public static IsIsPseudonode of(final byte[] isoNodeID,
final byte psnIdentifier) {
return new IsIsPseudonode(isoNodeID, psnIdentifier);
}
@@ -67,7 +62,7 @@ public class IsIsPseudonode implements IGPRouterID, BGPValueType {
*
* @return ISO NodeID
*/
- public List<Byte> getISONodeID() {
+ public byte[] getISONodeID() {
return isoNodeID;
}
@@ -82,7 +77,7 @@ public class IsIsPseudonode implements IGPRouterID, BGPValueType {
@Override
public int hashCode() {
- return Objects.hash(isoNodeID) & Objects.hash(psnIdentifier);
+ return Arrays.hashCode(isoNodeID) & Objects.hash(psnIdentifier);
}
@Override
@@ -91,27 +86,9 @@ public class IsIsPseudonode implements IGPRouterID, BGPValueType {
return true;
}
if (obj instanceof IsIsPseudonode) {
- int countObjSubTlv = 0;
- int countOtherSubTlv = 0;
- boolean isCommonSubTlv = true;
IsIsPseudonode other = (IsIsPseudonode) obj;
- Iterator<Byte> objListIterator = other.isoNodeID.iterator();
- countOtherSubTlv = other.isoNodeID.size();
- countObjSubTlv = isoNodeID.size();
- if (countObjSubTlv != countOtherSubTlv) {
- return false;
- } else {
- while (objListIterator.hasNext() && isCommonSubTlv) {
- Byte subTlv = objListIterator.next();
- if (isoNodeID.contains(subTlv) && other.isoNodeID.contains(subTlv)) {
- isCommonSubTlv = Objects.equals(isoNodeID.get(isoNodeID.indexOf(subTlv)),
- other.isoNodeID.get(other.isoNodeID.indexOf(subTlv)));
- } else {
- isCommonSubTlv = false;
- }
- }
- return isCommonSubTlv && Objects.equals(psnIdentifier, other.psnIdentifier);
- }
+ return Arrays.equals(isoNodeID, other.isoNodeID)
+ && Objects.equals(psnIdentifier, other.psnIdentifier);
}
return false;
}
@@ -121,11 +98,7 @@ public class IsIsPseudonode implements IGPRouterID, BGPValueType {
int iLenStartIndex = c.writerIndex();
c.writeShort(TYPE);
c.writeShort(LENGTH);
- Iterator<Byte> objListIterator = isoNodeID.iterator();
- while (objListIterator.hasNext()) {
- byte value = objListIterator.next();
- c.writeByte(value);
- }
+ c.writeBytes(isoNodeID, 0, LENGTH - 1);
c.writeByte(psnIdentifier);
return c.writerIndex() - iLenStartIndex;
}
@@ -137,12 +110,8 @@ public class IsIsPseudonode implements IGPRouterID, BGPValueType {
* @return object of IsIsPseudonode
*/
public static IsIsPseudonode read(ChannelBuffer cb) {
- List<Byte> isoNodeID = new ArrayList<Byte>();
- byte value;
- for (int i = 0; i < LENGTH; i++) {
- value = cb.readByte();
- isoNodeID.add(value);
- }
+ byte[] isoNodeID = new byte[LENGTH - 1];
+ cb.readBytes(isoNodeID);
byte psnIdentifier = cb.readByte();
return IsIsPseudonode.of(isoNodeID, psnIdentifier);
}
@@ -153,6 +122,19 @@ public class IsIsPseudonode implements IGPRouterID, BGPValueType {
}
@Override
+ public int compareTo(Object o) {
+ if (this.equals(o)) {
+ return 0;
+ }
+ ByteBuffer value1 = ByteBuffer.wrap(this.isoNodeID);
+ ByteBuffer value2 = ByteBuffer.wrap(((IsIsPseudonode) o).isoNodeID);
+ if (value1.compareTo(value2) != 0) {
+ return value1.compareTo(value2);
+ }
+ return ((Byte) (this.psnIdentifier)).compareTo((Byte) (((IsIsPseudonode) o).psnIdentifier));
+ }
+
+ @Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("Type", TYPE)
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/LinkLocalRemoteIdentifiersTlv.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/LinkLocalRemoteIdentifiersTlv.java
index 988925f5..0c412432 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/LinkLocalRemoteIdentifiersTlv.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/LinkLocalRemoteIdentifiersTlv.java
@@ -18,16 +18,13 @@ package org.onosproject.bgpio.types;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
/**
* Provides Implementation of Link Local/Remote IdentifiersTlv.
*/
-public class LinkLocalRemoteIdentifiersTlv implements BGPValueType {
- private static final Logger log = LoggerFactory.getLogger(LinkLocalRemoteIdentifiersTlv.class);
+public class LinkLocalRemoteIdentifiersTlv implements BgpValueType {
public static final short TYPE = 258;
private static final int LENGTH = 8;
@@ -120,6 +117,20 @@ public class LinkLocalRemoteIdentifiersTlv implements BGPValueType {
}
@Override
+ public int compareTo(Object o) {
+ if (this.equals(o)) {
+ return 0;
+ }
+ int result = ((Integer) (this.linkLocalIdentifer))
+ .compareTo((Integer) (((LinkLocalRemoteIdentifiersTlv) o).linkLocalIdentifer));
+ if (result != 0) {
+ return result;
+ }
+ return ((Integer) (this.linkRemoteIdentifer))
+ .compareTo((Integer) (((LinkLocalRemoteIdentifiersTlv) o).linkRemoteIdentifer));
+ }
+
+ @Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("TYPE", TYPE)
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/LinkStateAttributes.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/LinkStateAttributes.java
new file mode 100644
index 00000000..cdf6ebeb
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/LinkStateAttributes.java
@@ -0,0 +1,314 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.onosproject.bgpio.types;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.bgpio.exceptions.BgpParseException;
+import org.onosproject.bgpio.types.attr.BgpAttrNodeFlagBitTlv;
+import org.onosproject.bgpio.types.attr.BgpAttrNodeIsIsAreaId;
+import org.onosproject.bgpio.types.attr.BgpAttrNodeMultiTopologyId;
+import org.onosproject.bgpio.types.attr.BgpAttrNodeName;
+import org.onosproject.bgpio.types.attr.BgpAttrOpaqueNode;
+import org.onosproject.bgpio.types.attr.BgpAttrRouterIdV4;
+import org.onosproject.bgpio.types.attr.BgpAttrRouterIdV6;
+import org.onosproject.bgpio.types.attr.BgpLinkAttrIgpMetric;
+import org.onosproject.bgpio.types.attr.BgpLinkAttrIsIsAdminstGrp;
+import org.onosproject.bgpio.types.attr.BgpLinkAttrMplsProtocolMask;
+import org.onosproject.bgpio.types.attr.BgpLinkAttrMaxLinkBandwidth;
+import org.onosproject.bgpio.types.attr.BgpLinkAttrName;
+import org.onosproject.bgpio.types.attr.BgpLinkAttrOpaqLnkAttrib;
+import org.onosproject.bgpio.types.attr.BgpLinkAttrProtectionType;
+import org.onosproject.bgpio.types.attr.BgpLinkAttrSrlg;
+import org.onosproject.bgpio.types.attr.BgpLinkAttrTeDefaultMetric;
+import org.onosproject.bgpio.types.attr.BgpLinkAttrUnRsrvdLinkBandwidth;
+import org.onosproject.bgpio.types.attr.BgpPrefixAttrExtRouteTag;
+import org.onosproject.bgpio.types.attr.BgpPrefixAttrIgpFlags;
+import org.onosproject.bgpio.types.attr.BgpPrefixAttrMetric;
+import org.onosproject.bgpio.types.attr.BgpPrefixAttrOspfFwdAddr;
+import org.onosproject.bgpio.types.attr.BgpPrefixAttrOpaqueData;
+import org.onosproject.bgpio.types.attr.BgpPrefixAttrRouteTag;
+import org.onosproject.bgpio.util.Validation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Implements BGP Link state attribute.
+ */
+public class LinkStateAttributes implements BgpValueType {
+
+ protected static final Logger log = LoggerFactory
+ .getLogger(LinkStateAttributes.class);
+
+ /* Node Attributes */
+ public static final short ATTR_NODE_MT_TOPOLOGY_ID = 263;
+ public static final short ATTR_NODE_FLAG_BITS = 1024;
+ public static final short ATTR_NODE_OPAQUE_NODE = 1025;
+ public static final short ATTR_NODE_NAME = 1026;
+ public static final short ATTR_NODE_ISIS_AREA_ID = 1027;
+ public static final short ATTR_NODE_IPV4_LOCAL_ROUTER_ID = 1028;
+ public static final short ATTR_NODE_IPV6_LOCAL_ROUTER_ID = 1029;
+
+ /* Link Attributes */
+ public static final short ATTR_LINK_IPV4_REMOTE_ROUTER_ID = 1030;
+ public static final short ATTR_LINK_IPV6_REMOTE_ROUTER_ID = 1031;
+ public static final short ATTR_LINK_ADMINISTRATIVE_GRPS = 1088;
+ public static final short ATTR_LINK_MAX_BANDWIDTH = 1089;
+ public static final short ATTR_LINK_MAX_RES_BANDWIDTH = 1090;
+ public static final short ATTR_LINK_UNRES_BANDWIDTH = 1091;
+ public static final short ATTR_LINK_TE_DEFAULT_METRIC = 1092;
+ public static final short ATTR_LINK_PROTECTION_TYPE = 1093;
+ public static final short ATTR_LINK_MPLS_PROTOCOL_MASK = 1094;
+ public static final short ATTR_LINK_IGP_METRIC = 1095;
+ public static final short ATTR_LINK_SHR_RISK_GRP = 1096;
+ public static final short ATTR_LINK_OPAQUE_ATTR = 1097;
+ public static final short ATTR_LINK_NAME_ATTR = 1098;
+
+ /* Prefix Attributes */
+ public static final short ATTR_PREFIX_IGP_FLAG = 1152;
+ public static final short ATTR_PREFIX_ROUTE_TAG = 1153;
+ public static final short ATTR_PREFIX_EXTENDED_TAG = 1154;
+ public static final short ATTR_PREFIX_METRIC = 1155;
+ public static final short ATTR_PREFIX_OSPF_FWD_ADDR = 1156;
+ public static final short ATTR_PREFIX_OPAQUE_ATTR = 1157;
+
+ public static final byte LINKSTATE_ATTRIB_TYPE = 50;
+ public static final byte TYPE_AND_LEN = 4;
+ private boolean isLinkStateAttribute = false;
+ private List<BgpValueType> linkStateAttribList;
+
+ /**
+ * Constructor to reset parameters.
+ */
+ LinkStateAttributes() {
+ this.linkStateAttribList = null;
+ }
+
+ /**
+ * Constructor to initialize parameters.
+ *
+ * @param linkStateAttribList Linked list of Link, Node and Prefix TLVs
+ */
+ LinkStateAttributes(List<BgpValueType> linkStateAttribList) {
+ this.linkStateAttribList = linkStateAttribList;
+ this.isLinkStateAttribute = true;
+ }
+
+ /**
+ * Returns linked list of Link, Node and Prefix TLVs.
+ *
+ * @return linked list of Link, Node and Prefix TLVs
+ */
+ public List<BgpValueType> linkStateAttributes() {
+ return this.linkStateAttribList;
+ }
+
+ /**
+ * Returns if the Link state attributes are set or not.
+ *
+ * @return a boolean value to to check if the LS attributes are set or not
+ */
+ public boolean isLinkStateAttributeSet() {
+ return this.isLinkStateAttribute;
+ }
+
+ /**
+ * Reads the Link state attribute TLVs.
+ *
+ * @param cb ChannelBuffer
+ * @return constructor of LinkStateAttributes
+ * @throws BgpParseException while parsing link state attributes
+ */
+ public static LinkStateAttributes read(ChannelBuffer cb)
+ throws BgpParseException {
+
+ ChannelBuffer tempBuf = cb;
+ Validation parseFlags = Validation.parseAttributeHeader(cb);
+ int len = parseFlags.isShort() ? parseFlags.getLength() + TYPE_AND_LEN
+ : parseFlags.getLength() + 3;
+
+ ChannelBuffer data = tempBuf.readBytes(len);
+ if (!parseFlags.getFirstBit() || parseFlags.getSecondBit()
+ || parseFlags.getThirdBit()) {
+ throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.ATTRIBUTE_FLAGS_ERROR,
+ data);
+ }
+
+ if (cb.readableBytes() < parseFlags.getLength()) {
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.BAD_MESSAGE_LENGTH,
+ parseFlags.getLength());
+ }
+
+ BgpValueType bgpLSAttrib = null;
+ LinkedList<BgpValueType> linkStateAttribList;
+ linkStateAttribList = new LinkedList<BgpValueType>();
+ ChannelBuffer tempCb = cb.readBytes(parseFlags.getLength());
+ while (tempCb.readableBytes() > 0) {
+ short tlvCodePoint = tempCb.readShort();
+ switch (tlvCodePoint) {
+
+ /********* 7 NODE ATTRIBUTES ********/
+ case ATTR_NODE_MT_TOPOLOGY_ID: /* 263 Multi-Topology Identifier*/
+ bgpLSAttrib = BgpAttrNodeMultiTopologyId.read(tempCb);
+ break;
+
+ case ATTR_NODE_FLAG_BITS: /*Node flag bit TLV*/
+ bgpLSAttrib = BgpAttrNodeFlagBitTlv.read(tempCb);
+ break;
+
+ case ATTR_NODE_OPAQUE_NODE: /*Opaque Node Attribute*/
+ bgpLSAttrib = BgpAttrOpaqueNode.read(tempCb);
+ break;
+
+ case ATTR_NODE_NAME: /*Node Name*/
+ bgpLSAttrib = BgpAttrNodeName.read(tempCb);
+ break;
+
+ case ATTR_NODE_ISIS_AREA_ID: /*IS-IS Area Identifier TLV*/
+ bgpLSAttrib = BgpAttrNodeIsIsAreaId.read(tempCb);
+ break;
+
+ case ATTR_NODE_IPV4_LOCAL_ROUTER_ID: /*IPv4 Router-ID of Local Node*/
+ bgpLSAttrib = BgpAttrRouterIdV4.read(tempCb, (short) ATTR_NODE_IPV4_LOCAL_ROUTER_ID);
+ break;
+
+ case ATTR_NODE_IPV6_LOCAL_ROUTER_ID: /*IPv6 Router-ID of Local Node*/
+ bgpLSAttrib = BgpAttrRouterIdV6.read(tempCb, (short) ATTR_NODE_IPV6_LOCAL_ROUTER_ID);
+ break;
+
+ /********* 15 LINK ATTRIBUTES ********/
+
+ case ATTR_LINK_IPV4_REMOTE_ROUTER_ID: /*IPv4 Router-ID of Remote Node*/
+ bgpLSAttrib = BgpAttrRouterIdV4.read(tempCb, (short) 1030);
+ break;
+
+ case ATTR_LINK_IPV6_REMOTE_ROUTER_ID: /*IPv6 Router-ID of Remote Node*/
+ bgpLSAttrib = BgpAttrRouterIdV6.read(tempCb, (short) 1031);
+ break;
+
+ case ATTR_LINK_ADMINISTRATIVE_GRPS: /*ISIS Administrative group STLV 3*/
+ bgpLSAttrib = BgpLinkAttrIsIsAdminstGrp.read(tempCb);
+ break;
+
+ case ATTR_LINK_MAX_BANDWIDTH: /*Maximum link bandwidth*/
+ bgpLSAttrib = BgpLinkAttrMaxLinkBandwidth.read(tempCb,
+ (short) 1089);
+ break;
+
+ case ATTR_LINK_MAX_RES_BANDWIDTH: /* Maximum Reservable link bandwidth */
+ bgpLSAttrib = BgpLinkAttrMaxLinkBandwidth.read(tempCb,
+ (short) 1090);
+ break;
+
+ case ATTR_LINK_UNRES_BANDWIDTH: /* UnReserved link bandwidth */
+ bgpLSAttrib = BgpLinkAttrUnRsrvdLinkBandwidth
+ .read(tempCb, (short) 1091);
+ break;
+
+ case ATTR_LINK_TE_DEFAULT_METRIC: /* TE Default Metric */
+ bgpLSAttrib = BgpLinkAttrTeDefaultMetric.read(tempCb);
+ break;
+
+ case ATTR_LINK_PROTECTION_TYPE:/* Link Protection type */
+ bgpLSAttrib = BgpLinkAttrProtectionType.read(tempCb);
+ break;
+
+ case ATTR_LINK_MPLS_PROTOCOL_MASK: /* MPLS Protocol Mask */
+ bgpLSAttrib = BgpLinkAttrMplsProtocolMask.read(tempCb); // 2
+ break;
+
+ case ATTR_LINK_IGP_METRIC: /* IGP Metric */
+ bgpLSAttrib = BgpLinkAttrIgpMetric.read(tempCb); // 2
+ break;
+
+ case ATTR_LINK_SHR_RISK_GRP: /* Shared Risk Link Group */
+ bgpLSAttrib = BgpLinkAttrSrlg.read(tempCb); // 3
+ break;
+
+ case ATTR_LINK_OPAQUE_ATTR: /* Opaque link attribute */
+ bgpLSAttrib = BgpLinkAttrOpaqLnkAttrib.read(tempCb);
+ break;
+
+ case ATTR_LINK_NAME_ATTR: /* Link Name attribute */
+ bgpLSAttrib = BgpLinkAttrName.read(tempCb);
+ break;
+
+ /********* 6 PREFIX ATTRIBUTES ********/
+
+ case ATTR_PREFIX_IGP_FLAG: /* IGP Flags */
+ bgpLSAttrib = BgpPrefixAttrIgpFlags.read(tempCb);
+ break;
+
+ case ATTR_PREFIX_ROUTE_TAG: /* Route Tag */
+ bgpLSAttrib = BgpPrefixAttrRouteTag.read(tempCb);
+ break;
+
+ case ATTR_PREFIX_EXTENDED_TAG: /* Extended Tag */
+ bgpLSAttrib = BgpPrefixAttrExtRouteTag.read(tempCb);
+ break;
+
+ case ATTR_PREFIX_METRIC: /* Prefix Metric */
+ bgpLSAttrib = BgpPrefixAttrMetric.read(tempCb);
+ break;
+
+ case ATTR_PREFIX_OSPF_FWD_ADDR: /* OSPF Forwarding Address */
+ bgpLSAttrib = BgpPrefixAttrOspfFwdAddr.read(tempCb);
+ break;
+
+ case ATTR_PREFIX_OPAQUE_ATTR: /* Opaque Prefix Attribute */
+ bgpLSAttrib = BgpPrefixAttrOpaqueData.read(tempCb);
+ break;
+
+ default:
+ throw new BgpParseException(
+ "The Bgp-LS Attribute is not supported : "
+ + tlvCodePoint);
+ }
+
+ linkStateAttribList.add(bgpLSAttrib);
+ }
+ return new LinkStateAttributes(linkStateAttribList);
+ }
+
+ @Override
+ public short getType() {
+ return LINKSTATE_ATTRIB_TYPE;
+ }
+
+ @Override
+ public int write(ChannelBuffer cb) {
+ // TODO This will be implemented in the next version
+ return 0;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).omitNullValues()
+ .add("linkStateAttribList", linkStateAttribList).toString();
+ }
+
+ @Override
+ public int compareTo(Object o) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/LocalPref.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/LocalPref.java
index 0f78ab77..36793c18 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/LocalPref.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/LocalPref.java
@@ -18,7 +18,7 @@ package org.onosproject.bgpio.types;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BGPParseException;
+import org.onosproject.bgpio.exceptions.BgpParseException;
import org.onosproject.bgpio.util.Constants;
import org.onosproject.bgpio.util.Validation;
@@ -27,7 +27,7 @@ import com.google.common.base.MoreObjects;
/**
* Provides implementation of LocalPref BGP Path Attribute.
*/
-public class LocalPref implements BGPValueType {
+public class LocalPref implements BgpValueType {
public static final byte LOCAL_PREF_TYPE = 5;
public static final byte LOCAL_PREF_MAX_LEN = 4;
@@ -56,14 +56,14 @@ public class LocalPref implements BGPValueType {
*
* @param cb channelBuffer
* @return object of LocalPref
- * @throws BGPParseException while parsing localPref attribute
+ * @throws BgpParseException while parsing localPref attribute
*/
- public static LocalPref read(ChannelBuffer cb) throws BGPParseException {
+ public static LocalPref read(ChannelBuffer cb) throws BgpParseException {
int localPref;
ChannelBuffer tempCb = cb.copy();
Validation parseFlags = Validation.parseAttributeHeader(cb);
if ((parseFlags.getLength() > LOCAL_PREF_MAX_LEN) || cb.readableBytes() < parseFlags.getLength()) {
- Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR, BGPErrorType.ATTRIBUTE_LENGTH_ERROR,
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
parseFlags.getLength());
}
@@ -71,7 +71,7 @@ public class LocalPref implements BGPValueType {
Constants.TYPE_AND_LEN_AS_SHORT : parseFlags.getLength() + Constants.TYPE_AND_LEN_AS_BYTE;
ChannelBuffer data = tempCb.readBytes(len);
if (parseFlags.getFirstBit()) {
- throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, BGPErrorType.ATTRIBUTE_FLAGS_ERROR, data);
+ throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_FLAGS_ERROR, data);
}
localPref = cb.readInt();
@@ -112,4 +112,10 @@ public class LocalPref implements BGPValueType {
//Not to implement as of now
return 0;
}
+
+ @Override
+ public int compareTo(Object o) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
} \ No newline at end of file
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/Med.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/Med.java
index 23402c26..7f1ab53f 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/Med.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/Med.java
@@ -18,7 +18,7 @@ package org.onosproject.bgpio.types;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BGPParseException;
+import org.onosproject.bgpio.exceptions.BgpParseException;
import org.onosproject.bgpio.util.Constants;
import org.onosproject.bgpio.util.Validation;
@@ -27,7 +27,7 @@ import com.google.common.base.MoreObjects;
/**
* Provides Implementation of Med BGP Path Attribute.
*/
-public class Med implements BGPValueType {
+public class Med implements BgpValueType {
public static final byte MED_TYPE = 4;
public static final byte MED_MAX_LEN = 4;
@@ -56,22 +56,22 @@ public class Med implements BGPValueType {
*
* @param cb ChannelBuffer
* @return object of Med
- * @throws BGPParseException while parsing Med path attribute
+ * @throws BgpParseException while parsing Med path attribute
*/
- public static Med read(ChannelBuffer cb) throws BGPParseException {
+ public static Med read(ChannelBuffer cb) throws BgpParseException {
int med;
ChannelBuffer tempCb = cb.copy();
Validation parseFlags = Validation.parseAttributeHeader(cb);
if ((parseFlags.getLength() > MED_MAX_LEN) || cb.readableBytes() < parseFlags.getLength()) {
- Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR, BGPErrorType.ATTRIBUTE_LENGTH_ERROR,
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
parseFlags.getLength());
}
int len = parseFlags.isShort() ? parseFlags.getLength() + Constants.TYPE_AND_LEN_AS_SHORT : parseFlags
.getLength() + Constants.TYPE_AND_LEN_AS_BYTE;
ChannelBuffer data = tempCb.readBytes(len);
if (!parseFlags.getFirstBit() && parseFlags.getSecondBit() && parseFlags.getThirdBit()) {
- throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, BGPErrorType.ATTRIBUTE_FLAGS_ERROR, data);
+ throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_FLAGS_ERROR, data);
}
med = cb.readInt();
@@ -112,4 +112,10 @@ public class Med implements BGPValueType {
//Not to implement as of now
return 0;
}
+
+ @Override
+ public int compareTo(Object o) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
} \ No newline at end of file
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/MpReachNlri.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/MpReachNlri.java
index fe99d28d..689f30ea 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/MpReachNlri.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/MpReachNlri.java
@@ -22,10 +22,10 @@ import java.util.List;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onlab.packet.Ip4Address;
-import org.onosproject.bgpio.exceptions.BGPParseException;
-import org.onosproject.bgpio.protocol.BGPLSNlri;
-import org.onosproject.bgpio.protocol.linkstate.BGPPrefixIPv4LSNlriVer4;
-import org.onosproject.bgpio.protocol.linkstate.BGPNodeLSNlriVer4;
+import org.onosproject.bgpio.exceptions.BgpParseException;
+import org.onosproject.bgpio.protocol.BgpLSNlri;
+import org.onosproject.bgpio.protocol.linkstate.BgpPrefixIPv4LSNlriVer4;
+import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4;
import org.onosproject.bgpio.protocol.linkstate.BgpLinkLsNlriVer4;
import org.onosproject.bgpio.util.Constants;
import org.onosproject.bgpio.util.Validation;
@@ -37,14 +37,14 @@ import com.google.common.base.MoreObjects;
/*
* Provides Implementation of MpReach Nlri BGP Path Attribute.
*/
-public class MpReachNlri implements BGPValueType {
+public class MpReachNlri implements BgpValueType {
private static final Logger log = LoggerFactory.getLogger(MpReachNlri.class);
public static final byte MPREACHNLRI_TYPE = 14;
public static final byte LINK_NLRITYPE = 2;
private boolean isMpReachNlri = false;
- private final List<BGPLSNlri> mpReachNlri;
+ private final List<BgpLSNlri> mpReachNlri;
private final int length;
private final short afi;
private final byte safi;
@@ -59,7 +59,7 @@ public class MpReachNlri implements BGPValueType {
* @param ipNextHop nexthop IpAddress
* @param length of MpReachNlri
*/
- public MpReachNlri(List<BGPLSNlri> mpReachNlri, short afi, byte safi, Ip4Address ipNextHop, int length) {
+ public MpReachNlri(List<BgpLSNlri> mpReachNlri, short afi, byte safi, Ip4Address ipNextHop, int length) {
this.mpReachNlri = mpReachNlri;
this.isMpReachNlri = true;
this.ipNextHop = ipNextHop;
@@ -82,7 +82,7 @@ public class MpReachNlri implements BGPValueType {
*
* @return list of MpReach Nlri
*/
- public List<BGPLSNlri> mpReachNlri() {
+ public List<BgpLSNlri> mpReachNlri() {
return this.mpReachNlri;
}
@@ -100,9 +100,9 @@ public class MpReachNlri implements BGPValueType {
*
* @param cb channelBuffer
* @return object of MpReachNlri
- * @throws BGPParseException while parsing MpReachNlri
+ * @throws BgpParseException while parsing MpReachNlri
*/
- public static MpReachNlri read(ChannelBuffer cb) throws BGPParseException {
+ public static MpReachNlri read(ChannelBuffer cb) throws BgpParseException {
ChannelBuffer tempBuf = cb.copy();
Validation parseFlags = Validation.parseAttributeHeader(cb);
int len = parseFlags.isShort() ? parseFlags.getLength() + Constants.TYPE_AND_LEN_AS_SHORT :
@@ -110,15 +110,15 @@ public class MpReachNlri implements BGPValueType {
ChannelBuffer data = tempBuf.readBytes(len);
if (cb.readableBytes() < parseFlags.getLength()) {
- Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR, BGPErrorType.ATTRIBUTE_LENGTH_ERROR,
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
parseFlags.getLength());
}
if (!parseFlags.getFirstBit() && parseFlags.getSecondBit() && parseFlags.getThirdBit()) {
- throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, BGPErrorType.ATTRIBUTE_FLAGS_ERROR, data);
+ throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_FLAGS_ERROR, data);
}
- BGPLSNlri bgpLSNlri = null;
- List<BGPLSNlri> mpReachNlri = new LinkedList<>();
+ BgpLSNlri bgpLSNlri = null;
+ List<BgpLSNlri> mpReachNlri = new LinkedList<>();
ChannelBuffer tempCb = cb.readBytes(parseFlags.getLength());
short afi = 0;
byte safi = 0;
@@ -133,7 +133,7 @@ public class MpReachNlri implements BGPValueType {
byte nextHopLen = tempCb.readByte();
InetAddress ipAddress = Validation.toInetAddress(nextHopLen, cb);
if (ipAddress.isMulticastAddress()) {
- throw new BGPParseException("Multicast not supported");
+ throw new BgpParseException("Multicast not supported");
}
ipNextHop = Ip4Address.valueOf(ipAddress);
byte reserved = tempCb.readByte();
@@ -142,19 +142,19 @@ public class MpReachNlri implements BGPValueType {
short nlriType = tempCb.readShort();
short totNlriLen = tempCb.readShort();
if (tempCb.readableBytes() < totNlriLen) {
- Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR,
- BGPErrorType.ATTRIBUTE_LENGTH_ERROR, totNlriLen);
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.ATTRIBUTE_LENGTH_ERROR, totNlriLen);
}
tempBuf = tempCb.readBytes(totNlriLen);
switch (nlriType) {
- case BGPNodeLSNlriVer4.NODE_NLRITYPE:
- bgpLSNlri = BGPNodeLSNlriVer4.read(tempBuf, afi, safi);
+ case BgpNodeLSNlriVer4.NODE_NLRITYPE:
+ bgpLSNlri = BgpNodeLSNlriVer4.read(tempBuf, afi, safi);
break;
case BgpLinkLsNlriVer4.LINK_NLRITYPE:
bgpLSNlri = BgpLinkLsNlriVer4.read(tempBuf, afi, safi);
break;
- case BGPPrefixIPv4LSNlriVer4.PREFIX_IPV4_NLRITYPE:
- bgpLSNlri = BGPPrefixIPv4LSNlriVer4.read(tempBuf, afi, safi);
+ case BgpPrefixIPv4LSNlriVer4.PREFIX_IPV4_NLRITYPE:
+ bgpLSNlri = BgpPrefixIPv4LSNlriVer4.read(tempBuf, afi, safi);
break;
default:
log.debug("nlriType not supported" + nlriType);
@@ -162,7 +162,7 @@ public class MpReachNlri implements BGPValueType {
mpReachNlri.add(bgpLSNlri);
}
} else {
- throw new BGPParseException("Not Supporting afi " + afi + "safi " + safi);
+ throw new BgpParseException("Not Supporting afi " + afi + "safi " + safi);
}
}
return new MpReachNlri(mpReachNlri, afi, safi, ipNextHop, parseFlags.getLength());
@@ -216,4 +216,10 @@ public class MpReachNlri implements BGPValueType {
.add("length", length)
.toString();
}
+
+ @Override
+ public int compareTo(Object o) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
} \ No newline at end of file
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/MpUnReachNlri.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/MpUnReachNlri.java
index 8763ec59..f354b3ea 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/MpUnReachNlri.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/MpUnReachNlri.java
@@ -20,10 +20,10 @@ import java.util.LinkedList;
import java.util.List;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BGPParseException;
-import org.onosproject.bgpio.protocol.BGPLSNlri;
-import org.onosproject.bgpio.protocol.linkstate.BGPNodeLSNlriVer4;
-import org.onosproject.bgpio.protocol.linkstate.BGPPrefixIPv4LSNlriVer4;
+import org.onosproject.bgpio.exceptions.BgpParseException;
+import org.onosproject.bgpio.protocol.BgpLSNlri;
+import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4;
+import org.onosproject.bgpio.protocol.linkstate.BgpPrefixIPv4LSNlriVer4;
import org.onosproject.bgpio.protocol.linkstate.BgpLinkLsNlriVer4;
import org.onosproject.bgpio.util.Constants;
import org.onosproject.bgpio.util.Validation;
@@ -35,7 +35,7 @@ import com.google.common.base.MoreObjects;
/**
* Provides Implementation of MpUnReach Nlri BGP Path Attribute.
*/
-public class MpUnReachNlri implements BGPValueType {
+public class MpUnReachNlri implements BgpValueType {
private static final Logger log = LoggerFactory.getLogger(MpUnReachNlri.class);
public static final byte MPUNREACHNLRI_TYPE = 15;
@@ -44,7 +44,7 @@ public class MpUnReachNlri implements BGPValueType {
private boolean isMpUnReachNlri = false;
private final short afi;
private final byte safi;
- private final List<BGPLSNlri> mpUnReachNlri;
+ private final List<BgpLSNlri> mpUnReachNlri;
private final int length;
/**
@@ -55,7 +55,7 @@ public class MpUnReachNlri implements BGPValueType {
* @param safi subsequent address family identifier
* @param length of MpUnReachNlri
*/
- public MpUnReachNlri(List<BGPLSNlri> mpUnReachNlri, short afi, byte safi,
+ public MpUnReachNlri(List<BgpLSNlri> mpUnReachNlri, short afi, byte safi,
int length) {
this.mpUnReachNlri = mpUnReachNlri;
this.isMpUnReachNlri = true;
@@ -69,9 +69,9 @@ public class MpUnReachNlri implements BGPValueType {
*
* @param cb ChannelBuffer
* @return object of MpUnReachNlri
- * @throws BGPParseException while parsing MpUnReachNlri
+ * @throws BgpParseException while parsing MpUnReachNlri
*/
- public static MpUnReachNlri read(ChannelBuffer cb) throws BGPParseException {
+ public static MpUnReachNlri read(ChannelBuffer cb) throws BgpParseException {
ChannelBuffer tempBuf = cb.copy();
Validation parseFlags = Validation.parseAttributeHeader(cb);
int len = parseFlags.isShort() ? parseFlags.getLength() + Constants.TYPE_AND_LEN_AS_SHORT
@@ -80,17 +80,17 @@ public class MpUnReachNlri implements BGPValueType {
if (!parseFlags.getFirstBit() && parseFlags.getSecondBit()
&& parseFlags.getThirdBit()) {
- throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR,
- BGPErrorType.ATTRIBUTE_FLAGS_ERROR, data);
+ throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.ATTRIBUTE_FLAGS_ERROR, data);
}
if (cb.readableBytes() < parseFlags.getLength()) {
- Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR,
- BGPErrorType.ATTRIBUTE_LENGTH_ERROR, parseFlags.getLength());
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.ATTRIBUTE_LENGTH_ERROR, parseFlags.getLength());
}
- LinkedList<BGPLSNlri> mpUnReachNlri = new LinkedList<>();
- BGPLSNlri bgpLSNlri = null;
+ LinkedList<BgpLSNlri> mpUnReachNlri = new LinkedList<>();
+ BgpLSNlri bgpLSNlri = null;
short afi = 0;
byte safi = 0;
ChannelBuffer tempCb = cb.readBytes(parseFlags.getLength());
@@ -106,19 +106,19 @@ public class MpUnReachNlri implements BGPValueType {
short totNlriLen = tempCb.readShort();
if (tempCb.readableBytes() < totNlriLen) {
Validation.validateLen(
- BGPErrorType.UPDATE_MESSAGE_ERROR,
- BGPErrorType.ATTRIBUTE_LENGTH_ERROR, totNlriLen);
+ BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.ATTRIBUTE_LENGTH_ERROR, totNlriLen);
}
tempBuf = tempCb.readBytes(totNlriLen);
switch (nlriType) {
- case BGPNodeLSNlriVer4.NODE_NLRITYPE:
- bgpLSNlri = BGPNodeLSNlriVer4.read(tempBuf, afi, safi);
+ case BgpNodeLSNlriVer4.NODE_NLRITYPE:
+ bgpLSNlri = BgpNodeLSNlriVer4.read(tempBuf, afi, safi);
break;
case BgpLinkLsNlriVer4.LINK_NLRITYPE:
bgpLSNlri = BgpLinkLsNlriVer4.read(tempBuf, afi, safi);
break;
- case BGPPrefixIPv4LSNlriVer4.PREFIX_IPV4_NLRITYPE:
- bgpLSNlri = BGPPrefixIPv4LSNlriVer4.read(tempBuf, afi,
+ case BgpPrefixIPv4LSNlriVer4.PREFIX_IPV4_NLRITYPE:
+ bgpLSNlri = BgpPrefixIPv4LSNlriVer4.read(tempBuf, afi,
safi);
break;
default:
@@ -128,7 +128,7 @@ public class MpUnReachNlri implements BGPValueType {
}
} else {
//TODO: check with the values got from capability
- throw new BGPParseException("Not Supporting afi " + afi
+ throw new BgpParseException("Not Supporting afi " + afi
+ "safi " + safi);
}
}
@@ -164,7 +164,7 @@ public class MpUnReachNlri implements BGPValueType {
*
* @return list of MpUnReach Nlri
*/
- public List<BGPLSNlri> mpUnReachNlri() {
+ public List<BgpLSNlri> mpUnReachNlri() {
return this.mpUnReachNlri;
}
@@ -193,6 +193,12 @@ public class MpUnReachNlri implements BGPValueType {
}
@Override
+ public int compareTo(Object o) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("mpReachNlri", mpUnReachNlri)
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/MultiProtocolExtnCapabilityTlv.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/MultiProtocolExtnCapabilityTlv.java
index 9beff68c..7082483e 100755..100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/MultiProtocolExtnCapabilityTlv.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/MultiProtocolExtnCapabilityTlv.java
@@ -25,7 +25,7 @@ import com.google.common.base.MoreObjects;
/**
* Provides MultiProtocolExtnCapabilityTlv.
*/
-public class MultiProtocolExtnCapabilityTlv implements BGPValueType {
+public class MultiProtocolExtnCapabilityTlv implements BgpValueType {
/*
0 7 15 23 31
@@ -141,7 +141,7 @@ public class MultiProtocolExtnCapabilityTlv implements BGPValueType {
* @param cb of type channel buffer
* @return object of MultiProtocolExtnCapabilityTlv
*/
- public static BGPValueType read(ChannelBuffer cb) {
+ public static BgpValueType read(ChannelBuffer cb) {
short afi = cb.readShort();
byte res = cb.readByte();
byte safi = cb.readByte();
@@ -157,4 +157,10 @@ public class MultiProtocolExtnCapabilityTlv implements BGPValueType {
.add("Reserved", res)
.add("SAFI", safi).toString();
}
+
+ @Override
+ public int compareTo(Object o) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/NextHop.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/NextHop.java
index 1d083b72..806efe52 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/NextHop.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/NextHop.java
@@ -20,7 +20,7 @@ import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onlab.packet.Ip4Address;
-import org.onosproject.bgpio.exceptions.BGPParseException;
+import org.onosproject.bgpio.exceptions.BgpParseException;
import org.onosproject.bgpio.util.Constants;
import org.onosproject.bgpio.util.Validation;
@@ -30,7 +30,7 @@ import com.google.common.base.Preconditions;
/**
* Implementation of NextHop BGP Path Attribute.
*/
-public class NextHop implements BGPValueType {
+public class NextHop implements BgpValueType {
public static final byte NEXTHOP_TYPE = 3;
private boolean isNextHop = false;
@@ -60,27 +60,27 @@ public class NextHop implements BGPValueType {
*
* @param cb ChannelBuffer
* @return object of NextHop
- * @throws BGPParseException while parsing nexthop attribute
+ * @throws BgpParseException while parsing nexthop attribute
*/
- public static NextHop read(ChannelBuffer cb) throws BGPParseException {
+ public static NextHop read(ChannelBuffer cb) throws BgpParseException {
Ip4Address nextHop;
ChannelBuffer tempCb = cb.copy();
Validation parseFlags = Validation.parseAttributeHeader(cb);
if (cb.readableBytes() < parseFlags.getLength()) {
- Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR, BGPErrorType.ATTRIBUTE_LENGTH_ERROR,
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
parseFlags.getLength());
}
int len = parseFlags.isShort() ? parseFlags.getLength() + Constants.TYPE_AND_LEN_AS_SHORT : parseFlags
.getLength() + Constants.TYPE_AND_LEN_AS_BYTE;
ChannelBuffer data = tempCb.readBytes(len);
if (parseFlags.getFirstBit() && !parseFlags.getSecondBit() && parseFlags.getThirdBit()) {
- throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, BGPErrorType.ATTRIBUTE_FLAGS_ERROR, data);
+ throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_FLAGS_ERROR, data);
}
InetAddress ipAddress = Validation.toInetAddress(parseFlags.getLength(), cb);
if (ipAddress.isMulticastAddress()) {
- throw new BGPParseException("Multicast address is not supported");
+ throw new BgpParseException("Multicast address is not supported");
}
nextHop = Ip4Address.valueOf(ipAddress);
@@ -130,4 +130,10 @@ public class NextHop implements BGPValueType {
.add("nextHop", nextHop)
.toString();
}
+
+ @Override
+ public int compareTo(Object o) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
} \ No newline at end of file
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFNonPseudonode.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFNonPseudonode.java
index 6d8282b7..d281a4ef 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFNonPseudonode.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFNonPseudonode.java
@@ -20,18 +20,13 @@ import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.bgpio.protocol.IGPRouterID;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
/**
* Provides implementation of OSPFNonPseudonode Tlv.
*/
-public class OSPFNonPseudonode implements IGPRouterID, BGPValueType {
-
- protected static final Logger log = LoggerFactory.getLogger(OSPFNonPseudonode.class);
-
+public class OSPFNonPseudonode implements IGPRouterID, BgpValueType {
public static final short TYPE = 515;
public static final short LENGTH = 4;
@@ -108,6 +103,14 @@ public class OSPFNonPseudonode implements IGPRouterID, BGPValueType {
}
@Override
+ public int compareTo(Object o) {
+ if (this.equals(o)) {
+ return 0;
+ }
+ return ((Integer) (this.routerID)).compareTo((Integer) (((OSPFNonPseudonode) o).routerID));
+ }
+
+ @Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("Type", TYPE)
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFPseudonode.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFPseudonode.java
index 82a39bd1..0d17651a 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFPseudonode.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFPseudonode.java
@@ -20,18 +20,13 @@ import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onlab.packet.Ip4Address;
import org.onosproject.bgpio.protocol.IGPRouterID;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
/**
* Provides implementation of OSPFPseudonode Tlv.
*/
-public class OSPFPseudonode implements IGPRouterID, BGPValueType {
-
- protected static final Logger log = LoggerFactory.getLogger(OSPFPseudonode.class);
-
+public class OSPFPseudonode implements IGPRouterID, BgpValueType {
public static final short TYPE = 515;
public static final short LENGTH = 8;
@@ -114,6 +109,18 @@ public class OSPFPseudonode implements IGPRouterID, BGPValueType {
}
@Override
+ public int compareTo(Object o) {
+ if (this.equals(o)) {
+ return 0;
+ }
+ int result = ((Integer) (this.routerID)).compareTo((Integer) (((OSPFPseudonode) o).routerID));
+ if (result != 0) {
+ return this.drInterface.compareTo(((OSPFPseudonode) o).drInterface);
+ }
+ return result;
+ }
+
+ @Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("Type", TYPE)
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFRouteTypeTlv.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFRouteTypeTlv.java
index 20fffbfa..be321c95 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFRouteTypeTlv.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFRouteTypeTlv.java
@@ -18,16 +18,14 @@ package org.onosproject.bgpio.types;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BGPParseException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.onosproject.bgpio.exceptions.BgpParseException;
import com.google.common.base.MoreObjects;
/**
* Provides OSPF Route Type Tlv which contains route type.
*/
-public class OSPFRouteTypeTlv implements BGPValueType {
+public class OSPFRouteTypeTlv implements BgpValueType {
/* Reference :draft-ietf-idr-ls-distribution-11
0 1 2 3
@@ -41,8 +39,6 @@ public class OSPFRouteTypeTlv implements BGPValueType {
Figure : OSPF Route Type TLV Format
*/
- protected static final Logger log = LoggerFactory.getLogger(OSPFRouteTypeTlv.class);
-
public static final short TYPE = 264;
public static final short LENGTH = 1;
public static final int INTRA_AREA_TYPE = 1;
@@ -51,15 +47,16 @@ public class OSPFRouteTypeTlv implements BGPValueType {
public static final short EXTERNAL_TYPE_2 = 4;
public static final short NSSA_TYPE_1 = 5;
public static final short NSSA_TYPE_2 = 6;
+
private final byte routeType;
/**
* Enum for Route Type.
*/
- public enum ROUTETYPE {
+ public enum RouteType {
Intra_Area(1), Inter_Area(2), External_1(3), External_2(4), NSSA_1(5), NSSA_2(6);
int value;
- ROUTETYPE(int val) {
+ RouteType(int val) {
value = val;
}
public byte getType() {
@@ -90,24 +87,24 @@ public class OSPFRouteTypeTlv implements BGPValueType {
* Returns RouteType.
*
* @return RouteType
- * @throws BGPParseException if routeType is not matched
+ * @throws BgpParseException if routeType is not matched
*/
- public ROUTETYPE getValue() throws BGPParseException {
+ public RouteType getValue() throws BgpParseException {
switch (routeType) {
case INTRA_AREA_TYPE:
- return ROUTETYPE.Intra_Area;
+ return RouteType.Intra_Area;
case INTER_AREA_TYPE:
- return ROUTETYPE.Inter_Area;
+ return RouteType.Inter_Area;
case EXTERNAL_TYPE_1:
- return ROUTETYPE.External_1;
+ return RouteType.External_1;
case EXTERNAL_TYPE_2:
- return ROUTETYPE.External_2;
+ return RouteType.External_2;
case NSSA_TYPE_1:
- return ROUTETYPE.NSSA_1;
+ return RouteType.NSSA_1;
case NSSA_TYPE_2:
- return ROUTETYPE.NSSA_2;
+ return RouteType.NSSA_2;
default:
- throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, (byte) 0, null);
+ throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, (byte) 0, null);
}
}
@@ -153,6 +150,14 @@ public class OSPFRouteTypeTlv implements BGPValueType {
}
@Override
+ public int compareTo(Object o) {
+ if (this.equals(o)) {
+ return 0;
+ }
+ return ((Byte) (this.routeType)).compareTo((Byte) (((OSPFRouteTypeTlv) o).routeType));
+ }
+
+ @Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("Type", TYPE)
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/Origin.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/Origin.java
index 2052e965..d642d83c 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/Origin.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/Origin.java
@@ -18,7 +18,7 @@ package org.onosproject.bgpio.types;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BGPParseException;
+import org.onosproject.bgpio.exceptions.BgpParseException;
import org.onosproject.bgpio.util.Constants;
import org.onosproject.bgpio.util.Validation;
@@ -27,7 +27,7 @@ import com.google.common.base.MoreObjects;
/**
* Provides Implementation of mandatory BGP Origin path attribute.
*/
-public class Origin implements BGPValueType {
+public class Origin implements BgpValueType {
/**
* Enum to provide ORIGIN types.
@@ -99,9 +99,9 @@ public class Origin implements BGPValueType {
*
* @param cb ChannelBuffer
* @return object of Origin
- * @throws BGPParseException while parsing Origin path attribute
+ * @throws BgpParseException while parsing Origin path attribute
*/
- public static Origin read(ChannelBuffer cb) throws BGPParseException {
+ public static Origin read(ChannelBuffer cb) throws BgpParseException {
ChannelBuffer tempCb = cb.copy();
Validation parseFlags = Validation.parseAttributeHeader(cb);
@@ -109,18 +109,18 @@ public class Origin implements BGPValueType {
.getLength() + Constants.TYPE_AND_LEN_AS_BYTE;
ChannelBuffer data = tempCb.readBytes(len);
if ((parseFlags.getLength() > ORIGIN_VALUE_LEN) || (cb.readableBytes() < parseFlags.getLength())) {
- Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR, BGPErrorType.ATTRIBUTE_LENGTH_ERROR,
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
parseFlags.getLength());
}
if (parseFlags.getFirstBit() && !parseFlags.getSecondBit() && parseFlags.getThirdBit()) {
- throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, BGPErrorType.ATTRIBUTE_FLAGS_ERROR, data);
+ throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_FLAGS_ERROR, data);
}
byte originValue;
originValue = cb.readByte();
if ((originValue != ORIGINTYPE.INCOMPLETE.value) && (originValue != ORIGINTYPE.IGP.value) &&
(originValue != ORIGINTYPE.EGP.value)) {
- throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, BGPErrorType.INVALID_ORIGIN_ATTRIBUTE, data);
+ throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.INVALID_ORIGIN_ATTRIBUTE, data);
}
return new Origin(originValue);
}
@@ -159,4 +159,10 @@ public class Origin implements BGPValueType {
.add("origin", origin)
.toString();
}
+
+ @Override
+ public int compareTo(Object o) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
} \ No newline at end of file
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/RouteDistinguisher.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/RouteDistinguisher.java
index d0267092..37632ad8 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/RouteDistinguisher.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/RouteDistinguisher.java
@@ -18,10 +18,12 @@ package org.onosproject.bgpio.types;
import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.base.MoreObjects;
+
/**
* Implementation of RouteDistinguisher.
*/
-public class RouteDistinguisher {
+public class RouteDistinguisher implements Comparable<RouteDistinguisher> {
private long routeDistinguisher;
@@ -59,4 +61,19 @@ public class RouteDistinguisher {
public long getRouteDistinguisher() {
return this.routeDistinguisher;
}
+
+ @Override
+ public int compareTo(RouteDistinguisher rd) {
+ if (this.equals(rd)) {
+ return 0;
+ }
+ return ((Long) (this.getRouteDistinguisher())).compareTo((Long) (rd.getRouteDistinguisher()));
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("routeDistinguisher", routeDistinguisher)
+ .toString();
+ }
} \ No newline at end of file
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeFlagBitTlv.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeFlagBitTlv.java
index e7f4a4c0..e0fef7c8 100755
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeFlagBitTlv.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeFlagBitTlv.java
@@ -18,9 +18,9 @@ package org.onosproject.bgpio.types.attr;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BGPParseException;
-import org.onosproject.bgpio.types.BGPErrorType;
-import org.onosproject.bgpio.types.BGPValueType;
+import org.onosproject.bgpio.exceptions.BgpParseException;
+import org.onosproject.bgpio.types.BgpErrorType;
+import org.onosproject.bgpio.types.BgpValueType;
import org.onosproject.bgpio.util.Validation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,7 +30,7 @@ import com.google.common.base.MoreObjects;
/**
* Implements BGP attribute node flag.
*/
-public final class BgpAttrNodeFlagBitTlv implements BGPValueType {
+public final class BgpAttrNodeFlagBitTlv implements BgpValueType {
protected static final Logger log = LoggerFactory
.getLogger(BgpAttrNodeFlagBitTlv.class);
@@ -86,10 +86,10 @@ public final class BgpAttrNodeFlagBitTlv implements BGPValueType {
*
* @param cb ChannelBuffer
* @return attribute node flag bit tlv
- * @throws BGPParseException while parsing BgpAttrNodeFlagBitTlv
+ * @throws BgpParseException while parsing BgpAttrNodeFlagBitTlv
*/
public static BgpAttrNodeFlagBitTlv read(ChannelBuffer cb)
- throws BGPParseException {
+ throws BgpParseException {
boolean bOverloadBit = false;
boolean bAttachedBit = false;
boolean bExternalBit = false;
@@ -98,8 +98,8 @@ public final class BgpAttrNodeFlagBitTlv implements BGPValueType {
short lsAttrLength = cb.readShort();
if ((lsAttrLength != 1) || (cb.readableBytes() < lsAttrLength)) {
- Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR,
- BGPErrorType.ATTRIBUTE_LENGTH_ERROR,
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
@@ -190,4 +190,10 @@ public final class BgpAttrNodeFlagBitTlv implements BGPValueType {
.add("bExternalBit", bExternalBit).add("bAbrBit", bAbrBit)
.toString();
}
+
+ @Override
+ public int compareTo(Object o) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeIsIsAreaId.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeIsIsAreaId.java
new file mode 100644
index 00000000..0435a65f
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeIsIsAreaId.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.onosproject.bgpio.types.attr;
+
+import java.util.Arrays;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.bgpio.exceptions.BgpParseException;
+import org.onosproject.bgpio.types.BgpErrorType;
+import org.onosproject.bgpio.types.BgpValueType;
+import org.onosproject.bgpio.util.Validation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Implements BGP attribute ISIS Area Identifier.
+ */
+public class BgpAttrNodeIsIsAreaId implements BgpValueType {
+
+ protected static final Logger log = LoggerFactory
+ .getLogger(BgpAttrNodeIsIsAreaId.class);
+
+ public static final int ATTRNODE_ISISAREAID = 1027;
+
+ /* IS-IS Area Identifier TLV */
+ private byte[] isisAreaId;
+
+ /**
+ * Constructor to initialize value.
+ *
+ * @param isisAreaId ISIS area Identifier
+ */
+ public BgpAttrNodeIsIsAreaId(byte[] isisAreaId) {
+ this.isisAreaId = Arrays.copyOf(isisAreaId, isisAreaId.length);
+ }
+
+ /**
+ * Returns object of this class with specified values.
+ *
+ * @param isisAreaId ISIS area Identifier
+ * @return object of BgpAttrNodeIsIsAreaId
+ */
+ public static BgpAttrNodeIsIsAreaId of(final byte[] isisAreaId) {
+ return new BgpAttrNodeIsIsAreaId(isisAreaId);
+ }
+
+ /**
+ * Reads the IS-IS Area Identifier.
+ *
+ * @param cb ChannelBuffer
+ * @return object of BgpAttrNodeIsIsAreaId
+ * @throws BgpParseException while parsing BgpAttrNodeIsIsAreaId
+ */
+ public static BgpAttrNodeIsIsAreaId read(ChannelBuffer cb)
+ throws BgpParseException {
+ byte[] isisAreaId;
+
+ short lsAttrLength = cb.readShort();
+
+ if (cb.readableBytes() < lsAttrLength) {
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
+ lsAttrLength);
+ }
+
+ isisAreaId = new byte[lsAttrLength];
+ cb.readBytes(isisAreaId);
+
+ return BgpAttrNodeIsIsAreaId.of(isisAreaId);
+ }
+
+ /**
+ * Returns ISIS area Identifier.
+ *
+ * @return Area ID
+ */
+ public byte[] attrNodeIsIsAreaId() {
+ return isisAreaId;
+ }
+
+ @Override
+ public short getType() {
+ return ATTRNODE_ISISAREAID;
+ }
+
+ @Override
+ public int hashCode() {
+ return Arrays.hashCode(isisAreaId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj instanceof BgpAttrNodeIsIsAreaId) {
+ BgpAttrNodeIsIsAreaId other = (BgpAttrNodeIsIsAreaId) obj;
+ return Arrays.equals(isisAreaId, other.isisAreaId);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer cb) {
+ // TODO This will be implemented in the next version
+ return 0;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).omitNullValues()
+ .add("isisAreaId", isisAreaId).toString();
+ }
+
+ @Override
+ public int compareTo(Object o) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeMultiTopologyId.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeMultiTopologyId.java
index 4b704fb0..31d855db 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeMultiTopologyId.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeMultiTopologyId.java
@@ -17,12 +17,13 @@ package org.onosproject.bgpio.types.attr;
import java.util.ArrayList;
import java.util.List;
+import java.util.ListIterator;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BGPParseException;
-import org.onosproject.bgpio.types.BGPErrorType;
-import org.onosproject.bgpio.types.BGPValueType;
+import org.onosproject.bgpio.exceptions.BgpParseException;
+import org.onosproject.bgpio.types.BgpErrorType;
+import org.onosproject.bgpio.types.BgpValueType;
import org.onosproject.bgpio.util.Validation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -32,7 +33,7 @@ import com.google.common.base.MoreObjects;
/**
* BGP Multi-Topology ID of the LS attribute.
*/
-public class BgpAttrNodeMultiTopologyId implements BGPValueType {
+public class BgpAttrNodeMultiTopologyId implements BgpValueType {
private static final Logger log = LoggerFactory
.getLogger(BgpAttrNodeMultiTopologyId.class);
@@ -66,18 +67,18 @@ public class BgpAttrNodeMultiTopologyId implements BGPValueType {
*
* @param cb ChannelBuffer
* @return Constructor of BgpAttrNodeMultiTopologyId
- * @throws BGPParseException while parsing BgpAttrNodeMultiTopologyId
+ * @throws BgpParseException while parsing BgpAttrNodeMultiTopologyId
*/
public static BgpAttrNodeMultiTopologyId read(ChannelBuffer cb)
- throws BGPParseException {
+ throws BgpParseException {
ArrayList<Short> multiTopologyId = new ArrayList<Short>();
short tempMultiTopologyId;
short lsAttrLength = cb.readShort();
int len = lsAttrLength / 2; // Length is 2*n and n is the number of MT-IDs
if (cb.readableBytes() < lsAttrLength) {
- Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR,
- BGPErrorType.ATTRIBUTE_LENGTH_ERROR,
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
@@ -134,4 +135,30 @@ public class BgpAttrNodeMultiTopologyId implements BGPValueType {
.add("multiTopologyId", multiTopologyId)
.toString();
}
+
+ @Override
+ public int compareTo(Object o) {
+ if (this.equals(o)) {
+ return 0;
+ }
+ int countOtherSubTlv = ((BgpAttrNodeMultiTopologyId) o).multiTopologyId.size();
+ int countObjSubTlv = multiTopologyId.size();
+ if (countOtherSubTlv != countObjSubTlv) {
+ if (countOtherSubTlv > countObjSubTlv) {
+ return 1;
+ } else {
+ return -1;
+ }
+ }
+ ListIterator<Short> listIterator = multiTopologyId.listIterator();
+ ListIterator<Short> listIteratorOther = ((BgpAttrNodeMultiTopologyId) o).multiTopologyId.listIterator();
+ while (listIterator.hasNext()) {
+ short id = listIterator.next();
+ short id1 = listIteratorOther.next();
+ if (((Short) id).compareTo((Short) id1) != 0) {
+ return ((Short) id).compareTo((Short) id1);
+ }
+ }
+ return 0;
+ }
} \ No newline at end of file
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeName.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeName.java
new file mode 100644
index 00000000..2e1c7a05
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeName.java
@@ -0,0 +1,135 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.onosproject.bgpio.types.attr;
+
+import java.util.Arrays;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.bgpio.exceptions.BgpParseException;
+import org.onosproject.bgpio.types.BgpErrorType;
+import org.onosproject.bgpio.types.BgpValueType;
+import org.onosproject.bgpio.util.Validation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Implements BGP attribute node name.
+ */
+public class BgpAttrNodeName implements BgpValueType {
+
+ protected static final Logger log = LoggerFactory
+ .getLogger(BgpAttrNodeName.class);
+
+ public static final int ATTRNODE_NAME = 1026;
+
+ /* Node Name */
+ private byte[] nodeName;
+
+ /**
+ * Constructor to initialize value.
+ *
+ * @param nodeName node name
+ */
+ public BgpAttrNodeName(byte[] nodeName) {
+ this.nodeName = Arrays.copyOf(nodeName, nodeName.length);
+ }
+
+ /**
+ * Returns object of this class with specified values.
+ *
+ * @param nodeName node name
+ * @return object of BgpAttrNodeName
+ */
+ public static BgpAttrNodeName of(final byte[] nodeName) {
+ return new BgpAttrNodeName(nodeName);
+ }
+
+ /**
+ * Reads the LS attribute node name.
+ *
+ * @param cb ChannelBuffer
+ * @return object of BgpAttrNodeName
+ * @throws BgpParseException while parsing BgpAttrNodeName
+ */
+ public static BgpAttrNodeName read(ChannelBuffer cb)
+ throws BgpParseException {
+ byte[] nodeName;
+
+ short lsAttrLength = cb.readShort();
+
+ if (cb.readableBytes() < lsAttrLength) {
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
+ lsAttrLength);
+ }
+
+ nodeName = new byte[lsAttrLength];
+ cb.readBytes(nodeName);
+ return BgpAttrNodeName.of(nodeName);
+ }
+
+ /**
+ * Returns LS attribute node name.
+ *
+ * @return node name
+ */
+ public byte[] attrNodeName() {
+ return nodeName;
+ }
+
+ @Override
+ public short getType() {
+ return ATTRNODE_NAME;
+ }
+
+ @Override
+ public int hashCode() {
+ return Arrays.hashCode(nodeName);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj instanceof BgpAttrNodeName) {
+ BgpAttrNodeName other = (BgpAttrNodeName) obj;
+ return Arrays.equals(nodeName, other.nodeName);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer cb) {
+ // TODO This will be implemented in the next version
+ return 0;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).omitNullValues()
+ .add("nodeName", nodeName).toString();
+ }
+
+ @Override
+ public int compareTo(Object o) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrOpaqueNode.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrOpaqueNode.java
new file mode 100644
index 00000000..545755a7
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrOpaqueNode.java
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.onosproject.bgpio.types.attr;
+
+import java.util.Arrays;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.bgpio.exceptions.BgpParseException;
+import org.onosproject.bgpio.types.BgpErrorType;
+import org.onosproject.bgpio.types.BgpValueType;
+import org.onosproject.bgpio.util.Validation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Implements BGP attribute opaque node.
+ */
+public class BgpAttrOpaqueNode implements BgpValueType {
+
+ protected static final Logger log = LoggerFactory
+ .getLogger(BgpAttrOpaqueNode.class);
+
+ public static final int ATTRNODE_OPAQUEDATA = 1025;
+
+ /* Opaque Node Attribute */
+ private byte[] opaqueNodeAttribute;
+
+ /**
+ * Constructor to initialize parameter.
+ *
+ * @param opaqueNodeAttribute opaque node attribute
+ */
+ public BgpAttrOpaqueNode(byte[] opaqueNodeAttribute) {
+ this.opaqueNodeAttribute = Arrays.copyOf(opaqueNodeAttribute, opaqueNodeAttribute.length);
+ }
+
+ /**
+ * Returns object of this class with specified values.
+ *
+ * @param opaqueNodeAttribute Prefix Metric
+ * @return object of BgpAttrOpaqueNode
+ */
+ public static BgpAttrOpaqueNode of(byte[] opaqueNodeAttribute) {
+ return new BgpAttrOpaqueNode(opaqueNodeAttribute);
+ }
+
+ /**
+ * Reads the Opaque Node Properties.
+ *
+ * @param cb ChannelBuffer
+ * @return object of BgpAttrOpaqueNode
+ * @throws BgpParseException while parsing BgpAttrOpaqueNode
+ */
+ public static BgpAttrOpaqueNode read(ChannelBuffer cb)
+ throws BgpParseException {
+
+ byte[] opaqueNodeAttribute;
+
+ short lsAttrLength = cb.readShort();
+
+ if (cb.readableBytes() < lsAttrLength) {
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
+ lsAttrLength);
+ }
+
+ opaqueNodeAttribute = new byte[lsAttrLength];
+ cb.readBytes(opaqueNodeAttribute);
+
+ return BgpAttrOpaqueNode.of(opaqueNodeAttribute);
+ }
+
+ /**
+ * Returns opaque node attribute.
+ *
+ * @return LS node attribute value
+ */
+ public byte[] attrOpaqueNode() {
+ return opaqueNodeAttribute;
+ }
+
+ @Override
+ public short getType() {
+ return ATTRNODE_OPAQUEDATA;
+ }
+
+ @Override
+ public int hashCode() {
+ return Arrays.hashCode(opaqueNodeAttribute);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj instanceof BgpAttrOpaqueNode) {
+ BgpAttrOpaqueNode other = (BgpAttrOpaqueNode) obj;
+ return Arrays
+ .equals(opaqueNodeAttribute, other.opaqueNodeAttribute);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer cb) {
+ // TODO This will be implemented in the next version
+ return 0;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).omitNullValues()
+ .add("opaqueNodeAttribute", opaqueNodeAttribute).toString();
+ }
+
+ @Override
+ public int compareTo(Object o) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV4.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV4.java
index a10d167a..f3c0d17b 100755..100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV4.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV4.java
@@ -19,9 +19,9 @@ import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onlab.packet.Ip4Address;
-import org.onosproject.bgpio.exceptions.BGPParseException;
-import org.onosproject.bgpio.types.BGPErrorType;
-import org.onosproject.bgpio.types.BGPValueType;
+import org.onosproject.bgpio.exceptions.BgpParseException;
+import org.onosproject.bgpio.types.BgpErrorType;
+import org.onosproject.bgpio.types.BgpValueType;
import org.onosproject.bgpio.util.Validation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -31,7 +31,7 @@ import com.google.common.base.MoreObjects;
/**
* Implements BGP attribute node router ID.
*/
-public final class BgpAttrRouterIdV4 implements BGPValueType {
+public final class BgpAttrRouterIdV4 implements BgpValueType {
protected static final Logger log = LoggerFactory
.getLogger(BgpAttrRouterIdV4.class);
@@ -70,15 +70,15 @@ public final class BgpAttrRouterIdV4 implements BGPValueType {
* @param cb ChannelBuffer
* @param sType tag type
* @return object of BgpAttrRouterIdV4
- * @throws BGPParseException while parsing BgpAttrRouterIdV4
+ * @throws BgpParseException while parsing BgpAttrRouterIdV4
*/
public static BgpAttrRouterIdV4 read(ChannelBuffer cb, short sType)
- throws BGPParseException {
+ throws BgpParseException {
short lsAttrLength = cb.readShort();
if ((lsAttrLength != 4) || (cb.readableBytes() < lsAttrLength)) {
- Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR,
- BGPErrorType.ATTRIBUTE_LENGTH_ERROR,
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
@@ -131,4 +131,10 @@ public final class BgpAttrRouterIdV4 implements BGPValueType {
return MoreObjects.toStringHelper(getClass()).omitNullValues()
.add("ip4RouterId", ip4RouterId).toString();
}
+
+ @Override
+ public int compareTo(Object o) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV6.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV6.java
index ea63c379..648fd56e 100755..100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV6.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV6.java
@@ -19,9 +19,9 @@ import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onlab.packet.Ip6Address;
-import org.onosproject.bgpio.exceptions.BGPParseException;
-import org.onosproject.bgpio.types.BGPErrorType;
-import org.onosproject.bgpio.types.BGPValueType;
+import org.onosproject.bgpio.exceptions.BgpParseException;
+import org.onosproject.bgpio.types.BgpErrorType;
+import org.onosproject.bgpio.types.BgpValueType;
import org.onosproject.bgpio.util.Validation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -31,7 +31,7 @@ import com.google.common.base.MoreObjects;
/**
* Implements BGP attribute IPv6 router ID.
*/
-public final class BgpAttrRouterIdV6 implements BGPValueType {
+public final class BgpAttrRouterIdV6 implements BgpValueType {
protected static final Logger log = LoggerFactory
.getLogger(BgpAttrRouterIdV6.class);
@@ -70,18 +70,18 @@ public final class BgpAttrRouterIdV6 implements BGPValueType {
* @param cb ChannelBuffer
* @param sType TLV type
* @return object of BgpAttrRouterIdV6
- * @throws BGPParseException while parsing BgpAttrRouterIdV6
+ * @throws BgpParseException while parsing BgpAttrRouterIdV6
*/
public static BgpAttrRouterIdV6 read(ChannelBuffer cb, short sType)
- throws BGPParseException {
+ throws BgpParseException {
byte[] ipBytes;
Ip6Address ip6RouterId;
short lsAttrLength = cb.readShort();
if ((lsAttrLength != 16) || (cb.readableBytes() < lsAttrLength)) {
- Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR,
- BGPErrorType.ATTRIBUTE_LENGTH_ERROR,
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
@@ -134,4 +134,10 @@ public final class BgpAttrRouterIdV6 implements BGPValueType {
return MoreObjects.toStringHelper(getClass()).omitNullValues()
.add("ip6RouterId", ip6RouterId).toString();
}
+
+ @Override
+ public int compareTo(Object o) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrIgpMetric.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrIgpMetric.java
index c1cb299c..5721cf6c 100755..100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrIgpMetric.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrIgpMetric.java
@@ -18,9 +18,9 @@ package org.onosproject.bgpio.types.attr;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BGPParseException;
-import org.onosproject.bgpio.types.BGPErrorType;
-import org.onosproject.bgpio.types.BGPValueType;
+import org.onosproject.bgpio.exceptions.BgpParseException;
+import org.onosproject.bgpio.types.BgpErrorType;
+import org.onosproject.bgpio.types.BgpValueType;
import org.onosproject.bgpio.util.Validation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,7 +30,7 @@ import com.google.common.base.MoreObjects;
/**
* Implements BGP link IGP metric attribute.
*/
-public class BgpLinkAttrIgpMetric implements BGPValueType {
+public class BgpLinkAttrIgpMetric implements BgpValueType {
protected static final Logger log = LoggerFactory
.getLogger(BgpLinkAttrIgpMetric.class);
@@ -75,10 +75,10 @@ public class BgpLinkAttrIgpMetric implements BGPValueType {
*
* @param cb Channel buffer
* @return object of type BgpLinkAttrIgpMetric
- * @throws BGPParseException while parsing BgpLinkAttrIgpMetric
+ * @throws BgpParseException while parsing BgpLinkAttrIgpMetric
*/
public static BgpLinkAttrIgpMetric read(ChannelBuffer cb)
- throws BGPParseException {
+ throws BgpParseException {
short linkigp;
int igpMetric = 0;
@@ -88,8 +88,8 @@ public class BgpLinkAttrIgpMetric implements BGPValueType {
if (cb.readableBytes() < lsAttrLength
|| lsAttrLength > ATTRLINK_MAX_LEN) {
- Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR,
- BGPErrorType.ATTRIBUTE_LENGTH_ERROR,
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
@@ -169,4 +169,10 @@ public class BgpLinkAttrIgpMetric implements BGPValueType {
.add("igpMetric", igpMetric).add("igpMetricLen", igpMetricLen)
.toString();
}
+
+ @Override
+ public int compareTo(Object o) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrIsIsAdminstGrp.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrIsIsAdminstGrp.java
index 086e8b06..448f1e58 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrIsIsAdminstGrp.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrIsIsAdminstGrp.java
@@ -18,9 +18,9 @@ package org.onosproject.bgpio.types.attr;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BGPParseException;
-import org.onosproject.bgpio.types.BGPErrorType;
-import org.onosproject.bgpio.types.BGPValueType;
+import org.onosproject.bgpio.exceptions.BgpParseException;
+import org.onosproject.bgpio.types.BgpErrorType;
+import org.onosproject.bgpio.types.BgpValueType;
import org.onosproject.bgpio.util.Validation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,7 +30,7 @@ import com.google.common.base.MoreObjects;
/**
* Implements BGP attribute Is Is Administrative area.
*/
-public final class BgpLinkAttrIsIsAdminstGrp implements BGPValueType {
+public final class BgpLinkAttrIsIsAdminstGrp implements BgpValueType {
protected static final Logger log = LoggerFactory
.getLogger(BgpLinkAttrIsIsAdminstGrp.class);
@@ -65,17 +65,17 @@ public final class BgpLinkAttrIsIsAdminstGrp implements BGPValueType {
*
* @param cb Channel buffer
* @return object of type BgpLinkAttrIsIsAdminstGrp
- * @throws BGPParseException while parsing BgpLinkAttrIsIsAdminstGrp
+ * @throws BgpParseException while parsing BgpLinkAttrIsIsAdminstGrp
*/
public static BgpLinkAttrIsIsAdminstGrp read(ChannelBuffer cb)
- throws BGPParseException {
+ throws BgpParseException {
long isisAdminGrp;
short lsAttrLength = cb.readShort();
if ((lsAttrLength != ISIS_ADMIN_DATA_LEN)
|| (cb.readableBytes() < lsAttrLength)) {
- Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR,
- BGPErrorType.ATTRIBUTE_LENGTH_ERROR,
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
@@ -127,4 +127,10 @@ public final class BgpLinkAttrIsIsAdminstGrp implements BGPValueType {
return MoreObjects.toStringHelper(getClass())
.add("isisAdminGrp", isisAdminGrp).toString();
}
+
+ @Override
+ public int compareTo(Object o) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrMaxLinkBandwidth.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrMaxLinkBandwidth.java
index a1f0198b..2711ca94 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrMaxLinkBandwidth.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrMaxLinkBandwidth.java
@@ -18,9 +18,9 @@ package org.onosproject.bgpio.types.attr;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BGPParseException;
-import org.onosproject.bgpio.types.BGPErrorType;
-import org.onosproject.bgpio.types.BGPValueType;
+import org.onosproject.bgpio.exceptions.BgpParseException;
+import org.onosproject.bgpio.types.BgpErrorType;
+import org.onosproject.bgpio.types.BgpValueType;
import org.onosproject.bgpio.util.Validation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,7 +30,7 @@ import com.google.common.base.MoreObjects;
/**
* Implements BGP attribute Max Link bandwidth.
*/
-public final class BgpLinkAttrMaxLinkBandwidth implements BGPValueType {
+public final class BgpLinkAttrMaxLinkBandwidth implements BgpValueType {
protected static final Logger log = LoggerFactory
.getLogger(BgpLinkAttrMaxLinkBandwidth.class);
@@ -72,17 +72,17 @@ public final class BgpLinkAttrMaxLinkBandwidth implements BGPValueType {
* @param cb Channel buffer
* @param type type of this tlv
* @return object of type BgpLinkAttrMaxLinkBandwidth
- * @throws BGPParseException while parsing BgpLinkAttrMaxLinkBandwidth
+ * @throws BgpParseException while parsing BgpLinkAttrMaxLinkBandwidth
*/
public static BgpLinkAttrMaxLinkBandwidth read(ChannelBuffer cb, short type)
- throws BGPParseException {
+ throws BgpParseException {
float maxBandwidth;
short lsAttrLength = cb.readShort();
if ((lsAttrLength != MAX_BANDWIDTH_LEN)
|| (cb.readableBytes() < lsAttrLength)) {
- Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR,
- BGPErrorType.ATTRIBUTE_LENGTH_ERROR,
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
@@ -147,4 +147,10 @@ public final class BgpLinkAttrMaxLinkBandwidth implements BGPValueType {
return MoreObjects.toStringHelper(getClass())
.add("maxBandwidth", maxBandwidth).toString();
}
+
+ @Override
+ public int compareTo(Object o) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrMplsProtocolMask.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrMplsProtocolMask.java
index 61143fae..2bf1a59d 100755..100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrMplsProtocolMask.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrMplsProtocolMask.java
@@ -18,9 +18,9 @@ package org.onosproject.bgpio.types.attr;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BGPParseException;
-import org.onosproject.bgpio.types.BGPErrorType;
-import org.onosproject.bgpio.types.BGPValueType;
+import org.onosproject.bgpio.exceptions.BgpParseException;
+import org.onosproject.bgpio.types.BgpErrorType;
+import org.onosproject.bgpio.types.BgpValueType;
import org.onosproject.bgpio.util.Validation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,7 +30,7 @@ import com.google.common.base.MoreObjects;
/**
* Implements BGP MPLS protocol mask attribute.
*/
-public class BgpLinkAttrMplsProtocolMask implements BGPValueType {
+public class BgpLinkAttrMplsProtocolMask implements BgpValueType {
protected static final Logger log = LoggerFactory
.getLogger(BgpLinkAttrMplsProtocolMask.class);
@@ -72,10 +72,10 @@ public class BgpLinkAttrMplsProtocolMask implements BGPValueType {
*
* @param cb Channel buffer
* @return object of type BgpLinkAttrMPLSProtocolMask
- * @throws BGPParseException while parsing BgpLinkAttrMplsProtocolMask
+ * @throws BgpParseException while parsing BgpLinkAttrMplsProtocolMask
*/
public static BgpLinkAttrMplsProtocolMask read(ChannelBuffer cb)
- throws BGPParseException {
+ throws BgpParseException {
boolean bLdp = false;
boolean bRsvpTe = false;
@@ -83,8 +83,8 @@ public class BgpLinkAttrMplsProtocolMask implements BGPValueType {
if ((lsAttrLength != MASK_BYTE_LEN)
|| (cb.readableBytes() < lsAttrLength)) {
- Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR,
- BGPErrorType.ATTRIBUTE_LENGTH_ERROR,
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
@@ -149,4 +149,10 @@ public class BgpLinkAttrMplsProtocolMask implements BGPValueType {
return MoreObjects.toStringHelper(getClass())
.add("bLdp", bLdp).add("bRsvpTe", bRsvpTe).toString();
}
+
+ @Override
+ public int compareTo(Object o) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrName.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrName.java
index e44ba7e1..856ffc36 100755..100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrName.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrName.java
@@ -18,9 +18,9 @@ package org.onosproject.bgpio.types.attr;
import java.util.Arrays;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BGPParseException;
-import org.onosproject.bgpio.types.BGPErrorType;
-import org.onosproject.bgpio.types.BGPValueType;
+import org.onosproject.bgpio.exceptions.BgpParseException;
+import org.onosproject.bgpio.types.BgpErrorType;
+import org.onosproject.bgpio.types.BgpValueType;
import org.onosproject.bgpio.util.Validation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,7 +30,7 @@ import com.google.common.base.MoreObjects;
/**
* Implements BGP link name attribute.
*/
-public class BgpLinkAttrName implements BGPValueType {
+public class BgpLinkAttrName implements BgpValueType {
protected static final Logger log = LoggerFactory
.getLogger(BgpLinkAttrName.class);
@@ -64,16 +64,16 @@ public class BgpLinkAttrName implements BGPValueType {
*
* @param cb Channel buffer
* @return object of type BgpLinkAttrName
- * @throws BGPParseException while parsing BgpLinkAttrName
+ * @throws BgpParseException while parsing BgpLinkAttrName
*/
public static BgpLinkAttrName read(ChannelBuffer cb)
- throws BGPParseException {
+ throws BgpParseException {
byte[] linkName;
short lsAttrLength = cb.readShort();
if (cb.readableBytes() < lsAttrLength) {
- Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR,
- BGPErrorType.ATTRIBUTE_LENGTH_ERROR,
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
@@ -125,4 +125,10 @@ public class BgpLinkAttrName implements BGPValueType {
return MoreObjects.toStringHelper(getClass()).omitNullValues()
.add("linkName", linkName).toString();
}
+
+ @Override
+ public int compareTo(Object o) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrOpaqLnkAttrib.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrOpaqLnkAttrib.java
index 258598be..275b85be 100755..100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrOpaqLnkAttrib.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrOpaqLnkAttrib.java
@@ -18,9 +18,9 @@ package org.onosproject.bgpio.types.attr;
import java.util.Arrays;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BGPParseException;
-import org.onosproject.bgpio.types.BGPErrorType;
-import org.onosproject.bgpio.types.BGPValueType;
+import org.onosproject.bgpio.exceptions.BgpParseException;
+import org.onosproject.bgpio.types.BgpErrorType;
+import org.onosproject.bgpio.types.BgpValueType;
import org.onosproject.bgpio.util.Validation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,7 +30,7 @@ import com.google.common.base.MoreObjects;
/**
* Implements BGP link opaque attribute.
*/
-public final class BgpLinkAttrOpaqLnkAttrib implements BGPValueType {
+public final class BgpLinkAttrOpaqLnkAttrib implements BgpValueType {
protected static final Logger log = LoggerFactory
.getLogger(BgpLinkAttrOpaqLnkAttrib.class);
@@ -65,18 +65,18 @@ public final class BgpLinkAttrOpaqLnkAttrib implements BGPValueType {
*
* @param cb Channel buffer
* @return object of type BgpLinkAttrOpaqLnkAttrib
- * @throws BGPParseException while parsing BgpLinkAttrOpaqLnkAttrib
+ * @throws BgpParseException while parsing BgpLinkAttrOpaqLnkAttrib
*/
public static BgpLinkAttrOpaqLnkAttrib read(ChannelBuffer cb)
- throws BGPParseException {
+ throws BgpParseException {
byte[] opaqueLinkAttribute;
short lsAttrLength = cb.readShort();
if (cb.readableBytes() < lsAttrLength) {
- Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR,
- BGPErrorType.ATTRIBUTE_LENGTH_ERROR,
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
@@ -130,4 +130,10 @@ public final class BgpLinkAttrOpaqLnkAttrib implements BGPValueType {
return MoreObjects.toStringHelper(getClass()).omitNullValues()
.add("opaqueLinkAttribute", opaqueLinkAttribute).toString();
}
+
+ @Override
+ public int compareTo(Object o) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrProtectionType.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrProtectionType.java
index b45d95b8..59011d97 100755..100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrProtectionType.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrProtectionType.java
@@ -18,9 +18,9 @@ package org.onosproject.bgpio.types.attr;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BGPParseException;
-import org.onosproject.bgpio.types.BGPErrorType;
-import org.onosproject.bgpio.types.BGPValueType;
+import org.onosproject.bgpio.exceptions.BgpParseException;
+import org.onosproject.bgpio.types.BgpErrorType;
+import org.onosproject.bgpio.types.BgpValueType;
import org.onosproject.bgpio.util.Validation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,7 +30,7 @@ import com.google.common.base.MoreObjects;
/**
* Implements BGP link protection type attribute.
*/
-public final class BgpLinkAttrProtectionType implements BGPValueType {
+public final class BgpLinkAttrProtectionType implements BgpValueType {
protected static final Logger log = LoggerFactory
.getLogger(BgpLinkAttrProtectionType.class);
@@ -102,10 +102,10 @@ public final class BgpLinkAttrProtectionType implements BGPValueType {
*
* @param cb Channel buffer
* @return object of type BgpLinkAttrProtectionType
- * @throws BGPParseException while parsing BgpLinkAttrProtectionType
+ * @throws BgpParseException while parsing BgpLinkAttrProtectionType
*/
public static BgpLinkAttrProtectionType read(ChannelBuffer cb)
- throws BGPParseException {
+ throws BgpParseException {
short linkProtectionType;
byte higherByte;
short lsAttrLength = cb.readShort();
@@ -119,8 +119,8 @@ public final class BgpLinkAttrProtectionType implements BGPValueType {
if ((lsAttrLength != LINK_PROTECTION_LEN)
|| (cb.readableBytes() < lsAttrLength)) {
- Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR,
- BGPErrorType.ATTRIBUTE_LENGTH_ERROR,
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
@@ -237,4 +237,10 @@ public final class BgpLinkAttrProtectionType implements BGPValueType {
.add("bDedOnePlusOne", bDedOnePlusOne)
.add("bEnhanced", bEnhanced).toString();
}
+
+ @Override
+ public int compareTo(Object o) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrSrlg.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrSrlg.java
new file mode 100644
index 00000000..4a6f23f9
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrSrlg.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.onosproject.bgpio.types.attr;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.bgpio.exceptions.BgpParseException;
+import org.onosproject.bgpio.types.BgpErrorType;
+import org.onosproject.bgpio.types.BgpValueType;
+import org.onosproject.bgpio.util.Validation;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Implements BGP link Shared Risk Link Group attribute.
+ */
+public class BgpLinkAttrSrlg implements BgpValueType {
+
+ public static final short ATTRNODE_SRLG = 1097;
+
+ /* Shared Risk Link Group */
+ private List<Integer> sRlg = new ArrayList<Integer>();
+
+ /**
+ * Constructor to initialize the date.
+ *
+ * @param sRlg Shared Risk link group data
+ */
+ public BgpLinkAttrSrlg(List<Integer> sRlg) {
+ this.sRlg = sRlg;
+ }
+
+ /**
+ * Returns object of this class with specified values.
+ *
+ * @param sRlg Shared Risk link group data
+ * @return object of BgpLinkAttrSrlg
+ */
+ public static BgpLinkAttrSrlg of(ArrayList<Integer> sRlg) {
+ return new BgpLinkAttrSrlg(sRlg);
+ }
+
+ /**
+ * Reads the BGP link attributes Shared Risk link group data.
+ *
+ * @param cb Channel buffer
+ * @return object of type BgpLinkAttrSrlg
+ * @throws BgpParseException while parsing BgpLinkAttrSrlg
+ */
+ public static BgpLinkAttrSrlg read(ChannelBuffer cb)
+ throws BgpParseException {
+ int tempSrlg;
+ ArrayList<Integer> sRlg = new ArrayList<Integer>();
+
+ short lsAttrLength = cb.readShort();
+ int len = lsAttrLength / Integer.SIZE; // each element is of 4 octets
+
+ if (cb.readableBytes() < lsAttrLength) {
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
+ lsAttrLength);
+ }
+
+ for (int i = 0; i < len; i++) {
+ tempSrlg = cb.readInt();
+ sRlg.add(new Integer(tempSrlg));
+ }
+
+ return BgpLinkAttrSrlg.of(sRlg);
+ }
+
+ /**
+ * Returns the Shared Risk link group data.
+ *
+ * @return array of Shared Risk link group data
+ */
+ public List<Integer> attrSrlg() {
+ return sRlg;
+ }
+
+ @Override
+ public short getType() {
+ return ATTRNODE_SRLG;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(sRlg);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj instanceof BgpLinkAttrSrlg) {
+ BgpLinkAttrSrlg other = (BgpLinkAttrSrlg) obj;
+ return Objects.equals(sRlg, other.sRlg);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer cb) {
+ // TODO This will be implemented in the next version
+ return 0;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).omitNullValues().add("sRlg", sRlg).toString();
+ }
+
+ @Override
+ public int compareTo(Object o) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrTeDefaultMetric.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrTeDefaultMetric.java
index 7febe3c3..1ae7ecc5 100755..100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrTeDefaultMetric.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrTeDefaultMetric.java
@@ -18,9 +18,9 @@ package org.onosproject.bgpio.types.attr;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BGPParseException;
-import org.onosproject.bgpio.types.BGPErrorType;
-import org.onosproject.bgpio.types.BGPValueType;
+import org.onosproject.bgpio.exceptions.BgpParseException;
+import org.onosproject.bgpio.types.BgpErrorType;
+import org.onosproject.bgpio.types.BgpValueType;
import org.onosproject.bgpio.util.Validation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,7 +30,7 @@ import com.google.common.base.MoreObjects;
/**
* Implements BGP link state Default TE metric link attribute.
*/
-public class BgpLinkAttrTeDefaultMetric implements BGPValueType {
+public class BgpLinkAttrTeDefaultMetric implements BgpValueType {
protected static final Logger log = LoggerFactory
.getLogger(BgpLinkAttrTeDefaultMetric.class);
@@ -66,18 +66,18 @@ public class BgpLinkAttrTeDefaultMetric implements BGPValueType {
*
* @param cb Channel buffer
* @return object of type BgpLinkAttrTeDefaultMetric
- * @throws BGPParseException while parsing BgpLinkAttrTeDefaultMetric
+ * @throws BgpParseException while parsing BgpLinkAttrTeDefaultMetric
*/
public static BgpLinkAttrTeDefaultMetric read(ChannelBuffer cb)
- throws BGPParseException {
+ throws BgpParseException {
int linkTeMetric;
short lsAttrLength = cb.readShort();
if ((lsAttrLength != TE_DATA_LEN)
|| (cb.readableBytes() < lsAttrLength)) {
- Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR,
- BGPErrorType.ATTRIBUTE_LENGTH_ERROR,
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
@@ -129,4 +129,10 @@ public class BgpLinkAttrTeDefaultMetric implements BGPValueType {
return MoreObjects.toStringHelper(getClass())
.add("linkTEMetric", linkTeMetric).toString();
}
+
+ @Override
+ public int compareTo(Object o) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrUnRsrvdLinkBandwidth.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrUnRsrvdLinkBandwidth.java
new file mode 100644
index 00000000..c927eea5
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrUnRsrvdLinkBandwidth.java
@@ -0,0 +1,163 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.onosproject.bgpio.types.attr;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.bgpio.exceptions.BgpParseException;
+import org.onosproject.bgpio.types.BgpErrorType;
+import org.onosproject.bgpio.types.BgpValueType;
+import org.onosproject.bgpio.util.Validation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Implements BGP unreserved bandwidth attribute.
+ */
+public class BgpLinkAttrUnRsrvdLinkBandwidth implements BgpValueType {
+
+ protected static final Logger log = LoggerFactory
+ .getLogger(BgpLinkAttrUnRsrvdLinkBandwidth.class);
+
+ public static final int MAX_BANDWIDTH_LEN = 4;
+ public static final int NO_OF_BITS = 8;
+ public static final int NO_OF_PRIORITY = 8;
+
+ public short sType;
+
+ /* ISIS administrative group */
+ private List<Float> maxUnResBandwidth = new ArrayList<Float>();
+
+ /**
+ * Constructor to initialize the values.
+ *
+ * @param maxUnResBandwidth Maximum Unreserved bandwidth
+ * @param sType returns the tag value
+ */
+ public BgpLinkAttrUnRsrvdLinkBandwidth(List<Float> maxUnResBandwidth,
+ short sType) {
+ this.maxUnResBandwidth = maxUnResBandwidth;
+ this.sType = sType;
+ }
+
+ /**
+ * Returns object of this class with specified values.
+ *
+ * @param linkPfxMetric Prefix Metric
+ * @param sType returns the tag value
+ * @return object of BgpLinkAttrUnRsrvdLinkBandwidth
+ */
+ public static BgpLinkAttrUnRsrvdLinkBandwidth of(List<Float> linkPfxMetric, short sType) {
+ return new BgpLinkAttrUnRsrvdLinkBandwidth(linkPfxMetric, sType);
+ }
+
+ /**
+ * Reads the BGP link attributes of Maximum link bandwidth.
+ *
+ * @param cb Channel buffer
+ * @return object of type BgpLinkAttrMaxLinkBandwidth
+ * @throws BgpParseException while parsing BgpLinkAttrMaxLinkBandwidth
+ */
+ public static BgpLinkAttrUnRsrvdLinkBandwidth read(ChannelBuffer cb,
+ short sType)
+ throws BgpParseException {
+ ArrayList<Float> maxUnResBandwidth = new ArrayList<Float>();
+ float tmp;
+ short lsAttrLength = cb.readShort();
+
+ if ((lsAttrLength != MAX_BANDWIDTH_LEN * NO_OF_PRIORITY)
+ || (cb.readableBytes() < lsAttrLength)) {
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
+ lsAttrLength);
+ }
+
+ for (int i = 0; i < NO_OF_PRIORITY; i++) {
+ tmp = ieeeToFloatRead(cb.readInt()) * NO_OF_BITS;
+ maxUnResBandwidth.add(new Float(tmp));
+ }
+
+ return BgpLinkAttrUnRsrvdLinkBandwidth.of(maxUnResBandwidth, sType);
+ }
+
+ /**
+ * Returns maximum unreserved bandwidth.
+ *
+ * @return unreserved bandwidth.
+ */
+ public List<Float> getLinkAttrUnRsrvdLinkBandwidth() {
+ return maxUnResBandwidth;
+ }
+
+ /**
+ * Parse the IEEE floating point notation and returns it in normal float.
+ *
+ * @param iVal IEEE floating point number
+ * @return normal float
+ */
+ static float ieeeToFloatRead(int iVal) {
+ iVal = (((iVal & 0xFF) << 24) | ((iVal & 0xFF00) << 8)
+ | ((iVal & 0xFF0000) >> 8) | ((iVal >> 24) & 0xFF));
+
+ return Float.intBitsToFloat(iVal);
+ }
+
+ @Override
+ public short getType() {
+ return this.sType;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(maxUnResBandwidth);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj instanceof BgpLinkAttrUnRsrvdLinkBandwidth) {
+ BgpLinkAttrUnRsrvdLinkBandwidth other = (BgpLinkAttrUnRsrvdLinkBandwidth) obj;
+ return Objects.equals(maxUnResBandwidth, other.maxUnResBandwidth);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer cb) {
+ // TODO This will be implemented in the next version
+ return 0;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).omitNullValues()
+ .add("maxUnResBandwidth", maxUnResBandwidth).toString();
+ }
+
+ @Override
+ public int compareTo(Object o) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrExtRouteTag.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrExtRouteTag.java
new file mode 100644
index 00000000..a2d7c57e
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrExtRouteTag.java
@@ -0,0 +1,145 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.onosproject.bgpio.types.attr;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.bgpio.exceptions.BgpParseException;
+import org.onosproject.bgpio.types.BgpErrorType;
+import org.onosproject.bgpio.types.BgpValueType;
+import org.onosproject.bgpio.util.Validation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Implements BGP prefix route Extended tag attribute.
+ */
+public class BgpPrefixAttrExtRouteTag implements BgpValueType {
+
+ protected static final Logger log = LoggerFactory
+ .getLogger(BgpPrefixAttrExtRouteTag.class);
+
+ public static final int ATTR_PREFIX_EXTROUTETAG = 1154;
+ public static final int ATTR_PREFIX_EXT_LEN = 8;
+
+ /* Prefix Route Tag */
+ private List<Long> pfxExtRouteTag = new ArrayList<Long>();
+
+ /**
+ * Constructor to initialize the values.
+ *
+ * @param pfxExtRouteTag Extended route tag
+ */
+ public BgpPrefixAttrExtRouteTag(List<Long> pfxExtRouteTag) {
+ this.pfxExtRouteTag = checkNotNull(pfxExtRouteTag);
+ }
+
+ /**
+ * Returns object of this class with specified values.
+ *
+ * @param pfxExtRouteTag Prefix Metric
+ * @return object of BgpPrefixAttrMetric
+ */
+ public static BgpPrefixAttrExtRouteTag of(ArrayList<Long> pfxExtRouteTag) {
+ return new BgpPrefixAttrExtRouteTag(pfxExtRouteTag);
+ }
+
+ /**
+ * Reads the Extended Tag.
+ *
+ * @param cb ChannelBuffer
+ * @return object of BgpPrefixAttrExtRouteTag
+ * @throws BgpParseException while parsing BgpPrefixAttrExtRouteTag
+ */
+ public static BgpPrefixAttrExtRouteTag read(ChannelBuffer cb)
+ throws BgpParseException {
+ ArrayList<Long> pfxExtRouteTag = new ArrayList<Long>();
+ long temp;
+
+ short lsAttrLength = cb.readShort();
+ int len = lsAttrLength / ATTR_PREFIX_EXT_LEN;
+
+ if (cb.readableBytes() < lsAttrLength) {
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
+ lsAttrLength);
+ }
+
+ for (int i = 0; i < len; i++) {
+ temp = cb.readLong();
+ pfxExtRouteTag.add(new Long(temp));
+ }
+
+ return new BgpPrefixAttrExtRouteTag(pfxExtRouteTag);
+ }
+
+ /**
+ * Returns Extended route tag.
+ *
+ * @return route tag
+ */
+ public List<Long> pfxExtRouteTag() {
+ return pfxExtRouteTag;
+ }
+
+ @Override
+ public short getType() {
+ return ATTR_PREFIX_EXTROUTETAG;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(pfxExtRouteTag);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj instanceof BgpPrefixAttrExtRouteTag) {
+ BgpPrefixAttrExtRouteTag other = (BgpPrefixAttrExtRouteTag) obj;
+ return Objects.equals(pfxExtRouteTag, other.pfxExtRouteTag);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer cb) {
+ // TODO This will be implemented in the next version
+ return 0;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).omitNullValues()
+ .add("pfxExtRouteTag", pfxExtRouteTag).toString();
+ }
+
+ @Override
+ public int compareTo(Object o) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrIgpFlags.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrIgpFlags.java
index a215e6f1..4e84191a 100755..100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrIgpFlags.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrIgpFlags.java
@@ -18,9 +18,9 @@ package org.onosproject.bgpio.types.attr;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BGPParseException;
-import org.onosproject.bgpio.types.BGPErrorType;
-import org.onosproject.bgpio.types.BGPValueType;
+import org.onosproject.bgpio.exceptions.BgpParseException;
+import org.onosproject.bgpio.types.BgpErrorType;
+import org.onosproject.bgpio.types.BgpValueType;
import org.onosproject.bgpio.util.Validation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,7 +30,7 @@ import com.google.common.base.MoreObjects;
/**
* Implements BGP prefix IGP Flag attribute.
*/
-public final class BgpPrefixAttrIgpFlags implements BGPValueType {
+public final class BgpPrefixAttrIgpFlags implements BgpValueType {
protected static final Logger log = LoggerFactory
.getLogger(BgpPrefixAttrIgpFlags.class);
@@ -88,10 +88,10 @@ public final class BgpPrefixAttrIgpFlags implements BGPValueType {
*
* @param cb ChannelBuffer
* @return object of BgpPrefixAttrIGPFlags
- * @throws BGPParseException while parsing BgpPrefixAttrIGPFlags
+ * @throws BgpParseException while parsing BgpPrefixAttrIGPFlags
*/
public static BgpPrefixAttrIgpFlags read(ChannelBuffer cb)
- throws BGPParseException {
+ throws BgpParseException {
boolean bisisUpDownBit = false;
boolean bOspfNoUnicastBit = false;
boolean bOspfLclAddrBit = false;
@@ -101,8 +101,8 @@ public final class BgpPrefixAttrIgpFlags implements BGPValueType {
if ((lsAttrLength != ATTR_PREFIX_FLAG_LEN)
|| (cb.readableBytes() < lsAttrLength)) {
- Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR,
- BGPErrorType.ATTRIBUTE_LENGTH_ERROR,
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
@@ -195,4 +195,10 @@ public final class BgpPrefixAttrIgpFlags implements BGPValueType {
.add("bOspfLclAddrBit", bOspfLclAddrBit)
.add("bOspfNSSABit", bOspfNSSABit).toString();
}
+
+ @Override
+ public int compareTo(Object o) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrMetric.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrMetric.java
index 0678b81f..1886102c 100755..100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrMetric.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrMetric.java
@@ -18,9 +18,9 @@ package org.onosproject.bgpio.types.attr;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BGPParseException;
-import org.onosproject.bgpio.types.BGPErrorType;
-import org.onosproject.bgpio.types.BGPValueType;
+import org.onosproject.bgpio.exceptions.BgpParseException;
+import org.onosproject.bgpio.types.BgpErrorType;
+import org.onosproject.bgpio.types.BgpValueType;
import org.onosproject.bgpio.util.Validation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,7 +30,7 @@ import com.google.common.base.MoreObjects;
/**
* Implements BGP prefix metric attribute.
*/
-public class BgpPrefixAttrMetric implements BGPValueType {
+public class BgpPrefixAttrMetric implements BgpValueType {
protected static final Logger log = LoggerFactory
.getLogger(BgpPrefixAttrMetric.class);
@@ -65,18 +65,18 @@ public class BgpPrefixAttrMetric implements BGPValueType {
*
* @param cb ChannelBuffer
* @return object of BgpPrefixAttrMetric
- * @throws BGPParseException while parsing BgpPrefixAttrMetric
+ * @throws BgpParseException while parsing BgpPrefixAttrMetric
*/
public static BgpPrefixAttrMetric read(ChannelBuffer cb)
- throws BGPParseException {
+ throws BgpParseException {
int linkPfxMetric;
short lsAttrLength = cb.readShort(); // 4 Bytes
if ((lsAttrLength != ATTR_PREFIX_LEN)
|| (cb.readableBytes() < lsAttrLength)) {
- Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR,
- BGPErrorType.ATTRIBUTE_LENGTH_ERROR,
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
@@ -128,4 +128,10 @@ public class BgpPrefixAttrMetric implements BGPValueType {
return MoreObjects.toStringHelper(getClass())
.add("linkPfxMetric", linkPfxMetric).toString();
}
+
+ @Override
+ public int compareTo(Object o) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrOpaqueData.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrOpaqueData.java
index c7008ca1..6f7a74bb 100755..100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrOpaqueData.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrOpaqueData.java
@@ -18,9 +18,9 @@ package org.onosproject.bgpio.types.attr;
import java.util.Arrays;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BGPParseException;
-import org.onosproject.bgpio.types.BGPErrorType;
-import org.onosproject.bgpio.types.BGPValueType;
+import org.onosproject.bgpio.exceptions.BgpParseException;
+import org.onosproject.bgpio.types.BgpErrorType;
+import org.onosproject.bgpio.types.BgpValueType;
import org.onosproject.bgpio.util.Validation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,7 +30,7 @@ import com.google.common.base.MoreObjects;
/**
* Implements BGP prefix opaque data attribute.
*/
-public final class BgpPrefixAttrOpaqueData implements BGPValueType {
+public final class BgpPrefixAttrOpaqueData implements BgpValueType {
protected static final Logger log = LoggerFactory
.getLogger(BgpPrefixAttrOpaqueData.class);
@@ -65,18 +65,18 @@ public final class BgpPrefixAttrOpaqueData implements BGPValueType {
*
* @param cb ChannelBuffer
* @return object of BgpPrefixAttrOpaqueData
- * @throws BGPParseException while parsing BgpPrefixAttrOpaqueData
+ * @throws BgpParseException while parsing BgpPrefixAttrOpaqueData
*/
public static BgpPrefixAttrOpaqueData read(ChannelBuffer cb)
- throws BGPParseException {
+ throws BgpParseException {
byte[] opaquePrefixAttribute;
short lsAttrLength = cb.readShort();
opaquePrefixAttribute = new byte[lsAttrLength];
if (cb.readableBytes() < lsAttrLength) {
- Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR,
- BGPErrorType.ATTRIBUTE_LENGTH_ERROR,
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
@@ -131,4 +131,9 @@ public final class BgpPrefixAttrOpaqueData implements BGPValueType {
.toString();
}
+ @Override
+ public int compareTo(Object o) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrOspfFwdAddr.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrOspfFwdAddr.java
index cf043046..4e9db1ee 100755..100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrOspfFwdAddr.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrOspfFwdAddr.java
@@ -20,9 +20,9 @@ import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onlab.packet.Ip4Address;
import org.onlab.packet.Ip6Address;
-import org.onosproject.bgpio.exceptions.BGPParseException;
-import org.onosproject.bgpio.types.BGPErrorType;
-import org.onosproject.bgpio.types.BGPValueType;
+import org.onosproject.bgpio.exceptions.BgpParseException;
+import org.onosproject.bgpio.types.BgpErrorType;
+import org.onosproject.bgpio.types.BgpValueType;
import org.onosproject.bgpio.util.Validation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -32,7 +32,7 @@ import com.google.common.base.MoreObjects;
/**
* Implements BGP prefix OSPF Forwarding address attribute.
*/
-public class BgpPrefixAttrOspfFwdAddr implements BGPValueType {
+public class BgpPrefixAttrOspfFwdAddr implements BgpValueType {
protected static final Logger log = LoggerFactory
.getLogger(BgpPrefixAttrOspfFwdAddr.class);
@@ -80,10 +80,10 @@ public class BgpPrefixAttrOspfFwdAddr implements BGPValueType {
*
* @param cb ChannelBuffer
* @return object of BgpPrefixAttrOSPFFwdAddr
- * @throws BGPParseException while parsing BgpPrefixAttrOspfFwdAddr
+ * @throws BgpParseException while parsing BgpPrefixAttrOspfFwdAddr
*/
public static BgpPrefixAttrOspfFwdAddr read(ChannelBuffer cb)
- throws BGPParseException {
+ throws BgpParseException {
short lsAttrLength;
byte[] ipBytes;
Ip4Address ip4RouterId = null;
@@ -93,8 +93,8 @@ public class BgpPrefixAttrOspfFwdAddr implements BGPValueType {
ipBytes = new byte[lsAttrLength];
if ((cb.readableBytes() < lsAttrLength)) {
- Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR,
- BGPErrorType.ATTRIBUTE_LENGTH_ERROR,
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
@@ -184,4 +184,10 @@ public class BgpPrefixAttrOspfFwdAddr implements BGPValueType {
.add("ip6RouterId", ip6RouterId).toString();
}
}
+
+ @Override
+ public int compareTo(Object o) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrRouteTag.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrRouteTag.java
index 426eb274..3894c003 100755..100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrRouteTag.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrRouteTag.java
@@ -20,9 +20,9 @@ import java.util.List;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BGPParseException;
-import org.onosproject.bgpio.types.BGPErrorType;
-import org.onosproject.bgpio.types.BGPValueType;
+import org.onosproject.bgpio.exceptions.BgpParseException;
+import org.onosproject.bgpio.types.BgpErrorType;
+import org.onosproject.bgpio.types.BgpValueType;
import org.onosproject.bgpio.util.Validation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -32,7 +32,7 @@ import com.google.common.base.MoreObjects;
/**
* Implements BGP prefix route tag attribute.
*/
-public class BgpPrefixAttrRouteTag implements BGPValueType {
+public class BgpPrefixAttrRouteTag implements BgpValueType {
protected static final Logger log = LoggerFactory
.getLogger(BgpPrefixAttrRouteTag.class);
@@ -66,10 +66,10 @@ public class BgpPrefixAttrRouteTag implements BGPValueType {
*
* @param cb ChannelBuffer
* @return object of BgpPrefixAttrRouteTag
- * @throws BGPParseException while parsing BgpPrefixAttrRouteTag
+ * @throws BgpParseException while parsing BgpPrefixAttrRouteTag
*/
public static BgpPrefixAttrRouteTag read(ChannelBuffer cb)
- throws BGPParseException {
+ throws BgpParseException {
int tmp;
ArrayList<Integer> pfxRouteTag = new ArrayList<Integer>();
@@ -77,8 +77,8 @@ public class BgpPrefixAttrRouteTag implements BGPValueType {
int len = lsAttrLength / Integer.SIZE;
if (cb.readableBytes() < lsAttrLength) {
- Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR,
- BGPErrorType.ATTRIBUTE_LENGTH_ERROR,
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
@@ -133,4 +133,10 @@ public class BgpPrefixAttrRouteTag implements BGPValueType {
return MoreObjects.toStringHelper(getClass()).omitNullValues()
.add("pfxRouteTag", pfxRouteTag).toString();
}
+
+ @Override
+ public int compareTo(Object o) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
}