aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate')
-rw-r--r--[-rwxr-xr-x]framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpLinkLSIdentifier.java (renamed from framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BGPLinkLSIdentifier.java)118
-rwxr-xr-xframework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpLinkLsNlriVer4.java210
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpNodeLSIdentifier.java (renamed from framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BGPNodeLSIdentifier.java)39
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpNodeLSNlriVer4.java (renamed from framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BGPNodeLSNlriVer4.java)52
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpPrefixIPv4LSNlriVer4.java (renamed from framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BGPPrefixIPv4LSNlriVer4.java)52
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpPrefixLSIdentifier.java (renamed from framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BGPPrefixLSIdentifier.java)113
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/NodeDescriptors.java77
-rwxr-xr-xframework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/PathAttrNlriDetails.java135
-rwxr-xr-xframework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/PathAttrNlriDetailsLocalRib.java122
9 files changed, 759 insertions, 159 deletions
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BGPLinkLSIdentifier.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpLinkLSIdentifier.java
index ffea74db..3967a221 100755..100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BGPLinkLSIdentifier.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpLinkLSIdentifier.java
@@ -18,16 +18,18 @@ package org.onosproject.bgpio.protocol.linkstate;
import java.util.Iterator;
import java.util.LinkedList;
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.types.IPv4AddressTlv;
import org.onosproject.bgpio.types.IPv6AddressTlv;
import org.onosproject.bgpio.types.LinkLocalRemoteIdentifiersTlv;
import org.onosproject.bgpio.types.attr.BgpAttrNodeMultiTopologyId;
+import org.onosproject.bgpio.util.Constants;
import org.onosproject.bgpio.util.UnSupportedAttribute;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -38,22 +40,21 @@ import com.google.common.base.Preconditions;
/**
* Implementation of local node descriptors, remote node descriptors and link descriptors.
*/
-public class BGPLinkLSIdentifier {
- private static final Logger log = LoggerFactory.getLogger(BGPLinkLSIdentifier.class);
+public class BgpLinkLSIdentifier implements Comparable<Object> {
+ private static final Logger log = LoggerFactory.getLogger(BgpLinkLSIdentifier.class);
public static final short IPV4_INTERFACE_ADDRESS_TYPE = 259;
public static final short IPV4_NEIGHBOR_ADDRESS_TYPE = 260;
public static final short IPV6_INTERFACE_ADDRESS_TYPE = 261;
public static final short IPV6_NEIGHBOR_ADDRESS_TYPE = 262;
- public static final int TYPE_AND_LEN = 4;
private NodeDescriptors localNodeDescriptors;
private NodeDescriptors remoteNodeDescriptors;
- private List<BGPValueType> linkDescriptor;
+ private List<BgpValueType> linkDescriptor;
/**
* Initialize fields.
*/
- public BGPLinkLSIdentifier() {
+ public BgpLinkLSIdentifier() {
this.localNodeDescriptors = null;
this.remoteNodeDescriptors = null;
this.linkDescriptor = null;
@@ -66,8 +67,8 @@ public class BGPLinkLSIdentifier {
* @param remoteNodeDescriptors remote node descriptors
* @param linkDescriptor link descriptors
*/
- public BGPLinkLSIdentifier(NodeDescriptors localNodeDescriptors, NodeDescriptors remoteNodeDescriptors,
- LinkedList<BGPValueType> linkDescriptor) {
+ public BgpLinkLSIdentifier(NodeDescriptors localNodeDescriptors, NodeDescriptors remoteNodeDescriptors,
+ LinkedList<BgpValueType> linkDescriptor) {
this.localNodeDescriptors = Preconditions.checkNotNull(localNodeDescriptors);
this.remoteNodeDescriptors = Preconditions.checkNotNull(remoteNodeDescriptors);
this.linkDescriptor = Preconditions.checkNotNull(linkDescriptor);
@@ -79,9 +80,9 @@ public class BGPLinkLSIdentifier {
* @param cb ChannelBuffer
* @param protocolId in linkstate nlri
* @return object of BGPLinkLSIdentifier
- * @throws BGPParseException while parsing link identifier
+ * @throws BgpParseException while parsing link identifier
*/
- public static BGPLinkLSIdentifier parseLinkIdendifier(ChannelBuffer cb, byte protocolId) throws BGPParseException {
+ public static BgpLinkLSIdentifier parseLinkIdendifier(ChannelBuffer cb, byte protocolId) throws BgpParseException {
//Parse local node descriptor
NodeDescriptors localNodeDescriptors = new NodeDescriptors();
localNodeDescriptors = parseNodeDescriptors(cb, NodeDescriptors.LOCAL_NODE_DES_TYPE, protocolId);
@@ -91,9 +92,9 @@ public class BGPLinkLSIdentifier {
remoteNodeDescriptors = parseNodeDescriptors(cb, NodeDescriptors.REMOTE_NODE_DES_TYPE, protocolId);
//Parse link descriptor
- LinkedList<BGPValueType> linkDescriptor = new LinkedList<>();
+ LinkedList<BgpValueType> linkDescriptor = new LinkedList<>();
linkDescriptor = parseLinkDescriptors(cb);
- return new BGPLinkLSIdentifier(localNodeDescriptors, remoteNodeDescriptors, linkDescriptor);
+ return new BgpLinkLSIdentifier(localNodeDescriptors, remoteNodeDescriptors, linkDescriptor);
}
/**
@@ -103,16 +104,17 @@ public class BGPLinkLSIdentifier {
* @param desType descriptor type
* @param protocolId protocol identifier
* @return object of NodeDescriptors
- * @throws BGPParseException while parsing Local/Remote node descriptors
+ * @throws BgpParseException while parsing Local/Remote node descriptors
*/
public static NodeDescriptors parseNodeDescriptors(ChannelBuffer cb, short desType, byte protocolId)
- throws BGPParseException {
- ChannelBuffer tempBuf = cb;
+ throws BgpParseException {
+ log.debug("parse Node descriptors");
+ ChannelBuffer tempBuf = cb.copy();
short type = cb.readShort();
short length = cb.readShort();
if (cb.readableBytes() < length) {
- throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, BGPErrorType.OPTIONAL_ATTRIBUTE_ERROR,
- tempBuf.readBytes(cb.readableBytes() + TYPE_AND_LEN));
+ throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR,
+ tempBuf.readBytes(cb.readableBytes() + Constants.TYPE_AND_LEN_AS_SHORT));
}
NodeDescriptors nodeIdentifier = new NodeDescriptors();
ChannelBuffer tempCb = cb.readBytes(length);
@@ -120,7 +122,7 @@ public class BGPLinkLSIdentifier {
if (type == desType) {
nodeIdentifier = NodeDescriptors.read(tempCb, length, desType, protocolId);
} else {
- throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, BGPErrorType.MALFORMED_ATTRIBUTE_LIST, null);
+ throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.MALFORMED_ATTRIBUTE_LIST, null);
}
return nodeIdentifier;
}
@@ -130,20 +132,20 @@ public class BGPLinkLSIdentifier {
*
* @param cb ChannelBuffer
* @return list of link descriptors
- * @throws BGPParseException while parsing link descriptors
+ * @throws BgpParseException while parsing link descriptors
*/
- public static LinkedList<BGPValueType> parseLinkDescriptors(ChannelBuffer cb) throws BGPParseException {
- LinkedList<BGPValueType> linkDescriptor = new LinkedList<>();
- BGPValueType tlv = null;
+ public static LinkedList<BgpValueType> parseLinkDescriptors(ChannelBuffer cb) throws BgpParseException {
+ LinkedList<BgpValueType> linkDescriptor = new LinkedList<>();
+ BgpValueType tlv = null;
int count = 0;
while (cb.readableBytes() > 0) {
- ChannelBuffer tempBuf = cb;
+ ChannelBuffer tempBuf = cb.copy();
short type = cb.readShort();
short length = cb.readShort();
if (cb.readableBytes() < length) {
- throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, BGPErrorType.OPTIONAL_ATTRIBUTE_ERROR,
- tempBuf.readBytes(cb.readableBytes() + TYPE_AND_LEN));
+ throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR,
+ tempBuf.readBytes(cb.readableBytes() + Constants.TYPE_AND_LEN_AS_SHORT));
}
ChannelBuffer tempCb = cb.readBytes(length);
switch (type) {
@@ -168,9 +170,9 @@ public class BGPLinkLSIdentifier {
//MultiTopologyId TLV cannot repeat more than once
if (count > 1) {
//length + 4 implies data contains type, length and value
- throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR,
- BGPErrorType.OPTIONAL_ATTRIBUTE_ERROR, tempBuf.readBytes(length
- + TYPE_AND_LEN));
+ throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR, tempBuf.readBytes(length
+ + Constants.TYPE_AND_LEN_AS_SHORT));
}
break;
default:
@@ -204,7 +206,7 @@ public class BGPLinkLSIdentifier {
*
* @return link descriptors
*/
- public List<BGPValueType> linkDescriptors() {
+ public List<BgpValueType> linkDescriptors() {
return this.linkDescriptor;
}
@@ -218,21 +220,25 @@ public class BGPLinkLSIdentifier {
if (this == obj) {
return true;
}
- if (obj instanceof BGPLinkLSIdentifier) {
+ if (obj instanceof BgpLinkLSIdentifier) {
int countObjSubTlv = 0;
int countOtherSubTlv = 0;
boolean isCommonSubTlv = true;
- BGPLinkLSIdentifier other = (BGPLinkLSIdentifier) obj;
- Iterator<BGPValueType> objListIterator = other.linkDescriptor.iterator();
+ BgpLinkLSIdentifier other = (BgpLinkLSIdentifier) obj;
+ Iterator<BgpValueType> objListIterator = other.linkDescriptor.iterator();
countOtherSubTlv = other.linkDescriptor.size();
countObjSubTlv = linkDescriptor.size();
if (countObjSubTlv != countOtherSubTlv) {
return false;
} else {
while (objListIterator.hasNext() && isCommonSubTlv) {
- BGPValueType subTlv = objListIterator.next();
- isCommonSubTlv = Objects.equals(linkDescriptor.contains(subTlv),
- other.linkDescriptor.contains(subTlv));
+ BgpValueType subTlv = objListIterator.next();
+ if (linkDescriptor.contains(subTlv) && other.linkDescriptor.contains(subTlv)) {
+ isCommonSubTlv = Objects.equals(linkDescriptor.get(linkDescriptor.indexOf(subTlv)),
+ other.linkDescriptor.get(other.linkDescriptor.indexOf(subTlv)));
+ } else {
+ isCommonSubTlv = false;
+ }
}
return isCommonSubTlv && Objects.equals(this.localNodeDescriptors, other.localNodeDescriptors)
&& Objects.equals(this.remoteNodeDescriptors, other.remoteNodeDescriptors);
@@ -249,4 +255,42 @@ public class BGPLinkLSIdentifier {
.add("linkDescriptor", linkDescriptor)
.toString();
}
+
+ @Override
+ public int compareTo(Object o) {
+ if (this.equals(o)) {
+ return 0;
+ }
+ int result = this.localNodeDescriptors.compareTo(((BgpLinkLSIdentifier) o).localNodeDescriptors);
+ if (result != 0) {
+ return result;
+ } else if (this.remoteNodeDescriptors.compareTo(((BgpLinkLSIdentifier) o).remoteNodeDescriptors) != 0) {
+ return this.remoteNodeDescriptors.compareTo(((BgpLinkLSIdentifier) o).remoteNodeDescriptors);
+ } else {
+ int countOtherSubTlv = ((BgpLinkLSIdentifier) o).linkDescriptor.size();
+ int countObjSubTlv = linkDescriptor.size();
+ if (countOtherSubTlv != countObjSubTlv) {
+ if (countOtherSubTlv > countObjSubTlv) {
+ return 1;
+ } else {
+ return -1;
+ }
+ }
+ ListIterator<BgpValueType> listIterator = linkDescriptor.listIterator();
+ ListIterator<BgpValueType> listIteratorOther = ((BgpLinkLSIdentifier) o).linkDescriptor.listIterator();
+ while (listIterator.hasNext()) {
+ BgpValueType tlv = listIterator.next();
+ BgpValueType tlv1 = listIteratorOther.next();
+ if (linkDescriptor.contains(tlv) && ((BgpLinkLSIdentifier) o).linkDescriptor.contains(tlv1)) {
+ int res = linkDescriptor.get(linkDescriptor.indexOf(tlv)).compareTo(
+ ((BgpLinkLSIdentifier) o).linkDescriptor.get(((BgpLinkLSIdentifier) o).linkDescriptor
+ .indexOf(tlv1)));
+ if (res != 0) {
+ return res;
+ }
+ }
+ }
+ }
+ return 0;
+ }
}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpLinkLsNlriVer4.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpLinkLsNlriVer4.java
new file mode 100755
index 00000000..01d369e4
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpLinkLsNlriVer4.java
@@ -0,0 +1,210 @@
+/*
+ * 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.protocol.linkstate;
+
+import java.util.List;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.bgpio.exceptions.BgpParseException;
+import org.onosproject.bgpio.protocol.BgpLinkLsNlri;
+import org.onosproject.bgpio.protocol.NlriType;
+import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4.ProtocolType;
+import org.onosproject.bgpio.types.BgpErrorType;
+import org.onosproject.bgpio.types.BgpValueType;
+import org.onosproject.bgpio.types.RouteDistinguisher;
+import org.onosproject.bgpio.util.Constants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Implementation of Link LS NLRI.
+ */
+public class BgpLinkLsNlriVer4 implements BgpLinkLsNlri {
+
+ /*
+ * REFERENCE : draft-ietf-idr-ls-distribution-11
+ 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
+ +-+-+-+-+-+-+-+-+
+ | Protocol-ID |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Identifier |
+ | (64 bits) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ // Local Node Descriptors (variable) //
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ // Remote Node Descriptors (variable) //
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ // Link Descriptors (variable) //
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ Figure : The Link NLRI format
+ */
+ private static final Logger log = LoggerFactory.getLogger(BgpLinkLsNlriVer4.class);
+ public static final int LINK_NLRITYPE = 2;
+
+ private BgpLinkLSIdentifier linkLSIdentifier;
+ private byte protocolId;
+ private long identifier;
+ private RouteDistinguisher routeDistinguisher;
+ private boolean isVpn;
+
+ /**
+ * Initialize fields.
+ */
+ public BgpLinkLsNlriVer4() {
+ this.protocolId = 0;
+ this.identifier = 0;
+ this.linkLSIdentifier = null;
+ this.routeDistinguisher = null;
+ this.isVpn = false;
+ }
+
+ /**
+ * Constructor to initialize parameters for BGP LinkLSNlri.
+ *
+ * @param protocolId protocol Id
+ * @param identifier field in BGP LinkLSNlri
+ * @param linkLSIdentifier link LS identifier
+ * @param routeDistinguisher route distinguisher from message
+ * @param isVpn vpn info availability in message
+ */
+ public BgpLinkLsNlriVer4(byte protocolId, long identifier, BgpLinkLSIdentifier linkLSIdentifier,
+ RouteDistinguisher routeDistinguisher, boolean isVpn) {
+ this.protocolId = protocolId;
+ this.identifier = identifier;
+ this.linkLSIdentifier = linkLSIdentifier;
+ this.routeDistinguisher = routeDistinguisher;
+ this.isVpn = isVpn;
+ }
+
+ /**
+ * Reads from channelBuffer and parses Link LS Nlri.
+ *
+ * @param cb ChannelBuffer
+ * @param afi Address Family Identifier
+ * @param safi Subsequent Address Family Identifier
+ * @return object of this class
+ * @throws BgpParseException while parsing Link LS NLRI
+ */
+ public static BgpLinkLsNlriVer4 read(ChannelBuffer cb, short afi, byte safi) throws BgpParseException {
+ boolean isVpn = false;
+ RouteDistinguisher routeDistinguisher = null;
+ if ((afi == Constants.AFI_VALUE) && (safi == Constants.VPN_SAFI_VALUE)) {
+ routeDistinguisher = new RouteDistinguisher();
+ routeDistinguisher = RouteDistinguisher.read(cb);
+ isVpn = true;
+ } else {
+ isVpn = false;
+ }
+ byte protocolId = cb.readByte();
+ long identifier = cb.readLong();
+
+ BgpLinkLSIdentifier linkLSIdentifier = new BgpLinkLSIdentifier();
+ linkLSIdentifier = BgpLinkLSIdentifier.parseLinkIdendifier(cb, protocolId);
+ return new BgpLinkLsNlriVer4(protocolId, identifier, linkLSIdentifier, routeDistinguisher, isVpn);
+ }
+
+ @Override
+ public NlriType getNlriType() {
+ return NlriType.LINK;
+ }
+
+ @Override
+ public long getIdentifier() {
+ return this.identifier;
+ }
+
+ /**
+ * Set the link LS identifier.
+ *
+ * @param linkLSIdentifier link LS identifier to set
+ */
+ public void setLinkLSIdentifier(BgpLinkLSIdentifier linkLSIdentifier) {
+ this.linkLSIdentifier = linkLSIdentifier;
+ }
+
+ @Override
+ public ProtocolType getProtocolId() throws BgpParseException {
+ switch (protocolId) {
+ case Constants.ISIS_LEVELONE:
+ return ProtocolType.ISIS_LEVEL_ONE;
+ case Constants.ISIS_LEVELTWO:
+ return ProtocolType.ISIS_LEVEL_TWO;
+ case Constants.OSPFV2:
+ return ProtocolType.OSPF_V2;
+ case Constants.DIRECT:
+ return ProtocolType.DIRECT;
+ case Constants.STATIC_CONFIGURATION:
+ return ProtocolType.STATIC_CONFIGURATION;
+ case Constants.OSPFV3:
+ return ProtocolType.OSPF_V3;
+ default:
+ throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, (byte) 0, null);
+ }
+ }
+
+ @Override
+ public NodeDescriptors localNodeDescriptors() {
+ return this.linkLSIdentifier.localNodeDescriptors();
+ }
+
+ @Override
+ public NodeDescriptors remoteNodeDescriptors() {
+ return this.linkLSIdentifier.remoteNodeDescriptors();
+ }
+
+ /**
+ * Returns whether VPN is present or not.
+ *
+ * @return whether VPN is present or not
+ */
+ public boolean isVpnPresent() {
+ return this.isVpn;
+ }
+
+ @Override
+ public RouteDistinguisher getRouteDistinguisher() {
+ return this.routeDistinguisher;
+ }
+
+ /**
+ * Returns link identifier.
+ *
+ * @return link identifier
+ */
+ public BgpLinkLSIdentifier getLinkIdentifier() {
+ return this.linkLSIdentifier;
+ }
+
+ @Override
+ public List<BgpValueType> linkDescriptors() {
+ return this.linkLSIdentifier.linkDescriptors();
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .omitNullValues()
+ .add("protocolId", protocolId)
+ .add("identifier", identifier)
+ .add("RouteDistinguisher ", routeDistinguisher)
+ .add("linkLSIdentifier", linkLSIdentifier)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BGPNodeLSIdentifier.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpNodeLSIdentifier.java
index 603bf6ec..6c2c96d9 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BGPNodeLSIdentifier.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpNodeLSIdentifier.java
@@ -18,8 +18,8 @@ package org.onosproject.bgpio.protocol.linkstate;
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.exceptions.BgpParseException;
+import org.onosproject.bgpio.types.BgpErrorType;
import org.onosproject.bgpio.util.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -29,15 +29,15 @@ import com.google.common.base.MoreObjects;
/**
* Implementation of Node Identifier which includes local node descriptor/remote node descriptors.
*/
-public class BGPNodeLSIdentifier {
+public class BgpNodeLSIdentifier implements Comparable<Object> {
- protected static final Logger log = LoggerFactory.getLogger(BGPNodeLSIdentifier.class);
+ private static final Logger log = LoggerFactory.getLogger(BgpNodeLSIdentifier.class);
private NodeDescriptors nodeDescriptors;
/**
* Resets fields.
*/
- public BGPNodeLSIdentifier() {
+ public BgpNodeLSIdentifier() {
this.nodeDescriptors = null;
}
@@ -46,7 +46,7 @@ public class BGPNodeLSIdentifier {
*
* @param nodeDescriptors local/remote node descriptor
*/
- public BGPNodeLSIdentifier(NodeDescriptors nodeDescriptors) {
+ public BgpNodeLSIdentifier(NodeDescriptors nodeDescriptors) {
this.nodeDescriptors = nodeDescriptors;
}
@@ -56,15 +56,16 @@ public class BGPNodeLSIdentifier {
* @param cb ChannelBuffer
* @param protocolId protocol identifier
* @return object of this BGPNodeLSIdentifier
- * @throws BGPParseException while parsing local node descriptors
+ * @throws BgpParseException while parsing local node descriptors
*/
- public static BGPNodeLSIdentifier parseLocalNodeDescriptors(ChannelBuffer cb, byte protocolId)
- throws BGPParseException {
- ChannelBuffer tempBuf = cb;
+ public static BgpNodeLSIdentifier parseLocalNodeDescriptors(ChannelBuffer cb, byte protocolId)
+ throws BgpParseException {
+ log.debug("parse Local node descriptor");
+ ChannelBuffer tempBuf = cb.copy();
short type = cb.readShort();
short length = cb.readShort();
if (cb.readableBytes() < length) {
- throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, BGPErrorType.OPTIONAL_ATTRIBUTE_ERROR,
+ throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR,
tempBuf.readBytes(cb.readableBytes() + Constants.TYPE_AND_LEN));
}
NodeDescriptors nodeDescriptors = new NodeDescriptors();
@@ -73,9 +74,9 @@ public class BGPNodeLSIdentifier {
if (type == NodeDescriptors.LOCAL_NODE_DES_TYPE) {
nodeDescriptors = NodeDescriptors.read(tempCb, length, type, protocolId);
} else {
- throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, BGPErrorType.MALFORMED_ATTRIBUTE_LIST, null);
+ throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.MALFORMED_ATTRIBUTE_LIST, null);
}
- return new BGPNodeLSIdentifier(nodeDescriptors);
+ return new BgpNodeLSIdentifier(nodeDescriptors);
}
/**
@@ -92,8 +93,8 @@ public class BGPNodeLSIdentifier {
if (this == obj) {
return true;
}
- if (obj instanceof BGPNodeLSIdentifier) {
- BGPNodeLSIdentifier other = (BGPNodeLSIdentifier) obj;
+ if (obj instanceof BgpNodeLSIdentifier) {
+ BgpNodeLSIdentifier other = (BgpNodeLSIdentifier) obj;
return Objects.equals(nodeDescriptors, other.nodeDescriptors);
}
return false;
@@ -110,4 +111,12 @@ public class BGPNodeLSIdentifier {
.add("NodeDescriptors", nodeDescriptors)
.toString();
}
+
+ @Override
+ public int compareTo(Object o) {
+ if (this.equals(o)) {
+ return 0;
+ }
+ return this.nodeDescriptors.compareTo(((BgpNodeLSIdentifier) o).nodeDescriptors);
+ }
}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BGPNodeLSNlriVer4.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpNodeLSNlriVer4.java
index 54837ee8..b27096cf 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BGPNodeLSNlriVer4.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpNodeLSNlriVer4.java
@@ -16,10 +16,10 @@
package org.onosproject.bgpio.protocol.linkstate;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.bgpio.exceptions.BGPParseException;
-import org.onosproject.bgpio.protocol.BGPNodeLSNlri;
+import org.onosproject.bgpio.exceptions.BgpParseException;
+import org.onosproject.bgpio.protocol.BgpNodeLSNlri;
import org.onosproject.bgpio.protocol.NlriType;
-import org.onosproject.bgpio.types.BGPErrorType;
+import org.onosproject.bgpio.types.BgpErrorType;
import org.onosproject.bgpio.types.RouteDistinguisher;
import org.onosproject.bgpio.util.Constants;
import org.slf4j.Logger;
@@ -30,7 +30,7 @@ import com.google.common.base.MoreObjects;
/**
* Implementation of Node LS NLRI.
*/
-public class BGPNodeLSNlriVer4 implements BGPNodeLSNlri {
+public class BgpNodeLSNlriVer4 implements BgpNodeLSNlri {
/*
*REFERENCE : draft-ietf-idr-ls-distribution-11
@@ -48,21 +48,21 @@ public class BGPNodeLSNlriVer4 implements BGPNodeLSNlri {
Figure : The Node NLRI format
*/
- protected static final Logger log = LoggerFactory.getLogger(BGPNodeLSNlriVer4.class);
+ protected static final Logger log = LoggerFactory.getLogger(BgpNodeLSNlriVer4.class);
public static final int NODE_NLRITYPE = 1;
public static final int IDENTIFIER_LENGTH = 16;
private long identifier;
private byte protocolId;
- private BGPNodeLSIdentifier localNodeDescriptors;
+ private BgpNodeLSIdentifier localNodeDescriptors;
private RouteDistinguisher routeDistinguisher;
private boolean isVpn;
/**
* Enum to provide PROTOCOLTYPE.
*/
- public enum PROTOCOLTYPE {
- ISIS_LevelOne(1), ISIS_LevelTwo(2), OSPFv2(3), Direct(4), Static_Configuration(5), OSPFv3(6);
+ public enum ProtocolType {
+ ISIS_LEVEL_ONE(1), ISIS_LEVEL_TWO(2), OSPF_V2(3), DIRECT(4), STATIC_CONFIGURATION(5), OSPF_V3(6);
int value;
/**
@@ -70,7 +70,7 @@ public class BGPNodeLSNlriVer4 implements BGPNodeLSNlri {
*
* @param val protocol type
*/
- PROTOCOLTYPE(int val) {
+ ProtocolType(int val) {
value = val;
}
@@ -87,7 +87,7 @@ public class BGPNodeLSNlriVer4 implements BGPNodeLSNlri {
/**
* Reset fields.
*/
- public BGPNodeLSNlriVer4() {
+ public BgpNodeLSNlriVer4() {
this.identifier = 0;
this.protocolId = 0;
this.localNodeDescriptors = null;
@@ -104,7 +104,7 @@ public class BGPNodeLSNlriVer4 implements BGPNodeLSNlri {
* @param isVpn true if VPN info is present
* @param routeDistinguisher unique for each VPN
*/
- BGPNodeLSNlriVer4(long identifier, byte protocolId, BGPNodeLSIdentifier localNodeDescriptors, boolean isVpn,
+ public BgpNodeLSNlriVer4(long identifier, byte protocolId, BgpNodeLSIdentifier localNodeDescriptors, boolean isVpn,
RouteDistinguisher routeDistinguisher) {
this.identifier = identifier;
this.protocolId = protocolId;
@@ -120,9 +120,9 @@ public class BGPNodeLSNlriVer4 implements BGPNodeLSNlri {
* @param afi Address Family Identifier
* @param safi Subsequent Address Family Identifier
* @return object of this class
- * @throws BGPParseException while parsing node descriptors
+ * @throws BgpParseException while parsing node descriptors
*/
- public static BGPNodeLSNlriVer4 read(ChannelBuffer cb, short afi, byte safi) throws BGPParseException {
+ public static BgpNodeLSNlriVer4 read(ChannelBuffer cb, short afi, byte safi) throws BgpParseException {
boolean isVpn = false;
RouteDistinguisher routeDistinguisher = null;
if ((afi == Constants.AFI_VALUE) && (safi == Constants.VPN_SAFI_VALUE)) {
@@ -136,9 +136,9 @@ public class BGPNodeLSNlriVer4 implements BGPNodeLSNlri {
long identifier = cb.readLong();
// Parse Local Node Descriptors
- BGPNodeLSIdentifier localNodeDescriptors = new BGPNodeLSIdentifier();
- localNodeDescriptors = BGPNodeLSIdentifier.parseLocalNodeDescriptors(cb, protocolId);
- return new BGPNodeLSNlriVer4(identifier, protocolId, localNodeDescriptors, isVpn, routeDistinguisher);
+ BgpNodeLSIdentifier localNodeDescriptors = new BgpNodeLSIdentifier();
+ localNodeDescriptors = BgpNodeLSIdentifier.parseLocalNodeDescriptors(cb, protocolId);
+ return new BgpNodeLSNlriVer4(identifier, protocolId, localNodeDescriptors, isVpn, routeDistinguisher);
}
@Override
@@ -147,7 +147,7 @@ public class BGPNodeLSNlriVer4 implements BGPNodeLSNlri {
}
@Override
- public BGPNodeLSIdentifier getLocalNodeDescriptors() {
+ public BgpNodeLSIdentifier getLocalNodeDescriptors() {
return this.localNodeDescriptors;
}
@@ -175,27 +175,27 @@ public class BGPNodeLSNlriVer4 implements BGPNodeLSNlri {
*
* @param localNodeDescriptors node LS identifier to set
*/
- public void setNodeLSIdentifier(BGPNodeLSIdentifier localNodeDescriptors) {
+ public void setNodeLSIdentifier(BgpNodeLSIdentifier localNodeDescriptors) {
this.localNodeDescriptors = localNodeDescriptors;
}
@Override
- public PROTOCOLTYPE getProtocolId() throws BGPParseException {
+ public ProtocolType getProtocolId() throws BgpParseException {
switch (protocolId) {
case Constants.ISIS_LEVELONE:
- return PROTOCOLTYPE.ISIS_LevelOne;
+ return ProtocolType.ISIS_LEVEL_ONE;
case Constants.ISIS_LEVELTWO:
- return PROTOCOLTYPE.ISIS_LevelTwo;
+ return ProtocolType.ISIS_LEVEL_TWO;
case Constants.OSPFV2:
- return PROTOCOLTYPE.OSPFv2;
+ return ProtocolType.OSPF_V2;
case Constants.DIRECT:
- return PROTOCOLTYPE.Direct;
+ return ProtocolType.DIRECT;
case Constants.STATIC_CONFIGURATION:
- return PROTOCOLTYPE.Static_Configuration;
+ return ProtocolType.STATIC_CONFIGURATION;
case Constants.OSPFV3:
- return PROTOCOLTYPE.OSPFv3;
+ return ProtocolType.OSPF_V3;
default:
- throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, (byte) 0, null);
+ throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, (byte) 0, null);
}
}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BGPPrefixIPv4LSNlriVer4.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpPrefixIPv4LSNlriVer4.java
index 6d6f48b1..49cb74bd 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BGPPrefixIPv4LSNlriVer4.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpPrefixIPv4LSNlriVer4.java
@@ -15,14 +15,14 @@
*/
package org.onosproject.bgpio.protocol.linkstate;
-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.BGPPrefixLSNlri;
+import org.onosproject.bgpio.exceptions.BgpParseException;
+import org.onosproject.bgpio.protocol.BgpPrefixLSNlri;
import org.onosproject.bgpio.protocol.NlriType;
-import org.onosproject.bgpio.protocol.linkstate.BGPNodeLSNlriVer4.PROTOCOLTYPE;
-import org.onosproject.bgpio.types.BGPValueType;
+import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4.ProtocolType;
+import org.onosproject.bgpio.types.BgpValueType;
import org.onosproject.bgpio.types.RouteDistinguisher;
import org.onosproject.bgpio.util.Constants;
import org.slf4j.Logger;
@@ -33,7 +33,7 @@ import com.google.common.base.MoreObjects;
/**
* Implementation of Prefix IPV4 LS NLRI.
*/
-public class BGPPrefixIPv4LSNlriVer4 implements BGPPrefixLSNlri {
+public class BgpPrefixIPv4LSNlriVer4 implements BgpPrefixLSNlri {
/*
* REFERENCE : draft-ietf-idr-ls-distribution-11
@@ -53,7 +53,7 @@ public class BGPPrefixIPv4LSNlriVer4 implements BGPPrefixLSNlri {
Figure : The IPv4/IPv6 Topology Prefix NLRI format
*/
- protected static final Logger log = LoggerFactory.getLogger(BGPPrefixIPv4LSNlriVer4.class);
+ protected static final Logger log = LoggerFactory.getLogger(BgpPrefixIPv4LSNlriVer4.class);
public static final int PREFIX_IPV4_NLRITYPE = 3;
public static final int IDENTIFIER_LENGTH = 16;
@@ -61,12 +61,12 @@ public class BGPPrefixIPv4LSNlriVer4 implements BGPPrefixLSNlri {
private byte protocolId;
private RouteDistinguisher routeDistinguisher;
private boolean isVpn;
- private BGPPrefixLSIdentifier bgpPrefixLSIdentifier;
+ private BgpPrefixLSIdentifier bgpPrefixLSIdentifier;
/**
* Resets parameters.
*/
- public BGPPrefixIPv4LSNlriVer4() {
+ public BgpPrefixIPv4LSNlriVer4() {
this.identifier = 0;
this.protocolId = 0;
this.bgpPrefixLSIdentifier = null;
@@ -83,7 +83,7 @@ public class BGPPrefixIPv4LSNlriVer4 implements BGPPrefixLSNlri {
* @param routeDistinguisher RouteDistinguisher
* @param isVpn vpn availability in message
*/
- public BGPPrefixIPv4LSNlriVer4(long identifier, byte protocolId, BGPPrefixLSIdentifier bgpPrefixLSIdentifier,
+ public BgpPrefixIPv4LSNlriVer4(long identifier, byte protocolId, BgpPrefixLSIdentifier bgpPrefixLSIdentifier,
RouteDistinguisher routeDistinguisher, boolean isVpn) {
this.identifier = identifier;
this.protocolId = protocolId;
@@ -99,9 +99,9 @@ public class BGPPrefixIPv4LSNlriVer4 implements BGPPrefixLSNlri {
* @param afi Address family identifier
* @param safi Subsequent address family identifier
* @return object of BGPPrefixIPv4LSNlriVer4
- * @throws BGPParseException while parsing Prefix LS Nlri
+ * @throws BgpParseException while parsing Prefix LS Nlri
*/
- public static BGPPrefixIPv4LSNlriVer4 read(ChannelBuffer cb, short afi, byte safi) throws BGPParseException {
+ public static BgpPrefixIPv4LSNlriVer4 read(ChannelBuffer cb, short afi, byte safi) throws BgpParseException {
boolean isVpn = false;
RouteDistinguisher routeDistinguisher = null;
@@ -115,9 +115,9 @@ public class BGPPrefixIPv4LSNlriVer4 implements BGPPrefixLSNlri {
byte protocolId = cb.readByte();
long identifier = cb.readLong();
- BGPPrefixLSIdentifier bgpPrefixLSIdentifier = new BGPPrefixLSIdentifier();
- bgpPrefixLSIdentifier = BGPPrefixLSIdentifier.parsePrefixIdendifier(cb, protocolId);
- return new BGPPrefixIPv4LSNlriVer4(identifier, protocolId, bgpPrefixLSIdentifier, routeDistinguisher, isVpn);
+ BgpPrefixLSIdentifier bgpPrefixLSIdentifier = new BgpPrefixLSIdentifier();
+ bgpPrefixLSIdentifier = BgpPrefixLSIdentifier.parsePrefixIdendifier(cb, protocolId);
+ return new BgpPrefixIPv4LSNlriVer4(identifier, protocolId, bgpPrefixLSIdentifier, routeDistinguisher, isVpn);
}
@Override
@@ -140,27 +140,27 @@ public class BGPPrefixIPv4LSNlriVer4 implements BGPPrefixLSNlri {
*
* @param bgpPrefixLSIdentifier prefix identifier to set
*/
- public void setPrefixLSIdentifier(BGPPrefixLSIdentifier bgpPrefixLSIdentifier) {
+ public void setPrefixLSIdentifier(BgpPrefixLSIdentifier bgpPrefixLSIdentifier) {
this.bgpPrefixLSIdentifier = bgpPrefixLSIdentifier;
}
@Override
- public PROTOCOLTYPE getProtocolId() throws BGPParseException {
+ public ProtocolType getProtocolId() throws BgpParseException {
switch (protocolId) {
case Constants.ISIS_LEVELONE:
- return PROTOCOLTYPE.ISIS_LevelOne;
+ return ProtocolType.ISIS_LEVEL_ONE;
case Constants.ISIS_LEVELTWO:
- return PROTOCOLTYPE.ISIS_LevelTwo;
+ return ProtocolType.ISIS_LEVEL_TWO;
case Constants.OSPFV2:
- return PROTOCOLTYPE.OSPFv2;
+ return ProtocolType.OSPF_V2;
case Constants.DIRECT:
- return PROTOCOLTYPE.Direct;
+ return ProtocolType.DIRECT;
case Constants.STATIC_CONFIGURATION:
- return PROTOCOLTYPE.Static_Configuration;
+ return ProtocolType.STATIC_CONFIGURATION;
case Constants.OSPFV3:
- return PROTOCOLTYPE.OSPFv3;
+ return ProtocolType.OSPF_V3;
default:
- throw new BGPParseException("protocol id not valid");
+ throw new BgpParseException("protocol id not valid");
}
}
@@ -178,7 +178,7 @@ public class BGPPrefixIPv4LSNlriVer4 implements BGPPrefixLSNlri {
*
* @return Prefix Identifier
*/
- public BGPPrefixLSIdentifier getPrefixIdentifier() {
+ public BgpPrefixLSIdentifier getPrefixIdentifier() {
return this.bgpPrefixLSIdentifier;
}
@@ -188,7 +188,7 @@ public class BGPPrefixIPv4LSNlriVer4 implements BGPPrefixLSNlri {
}
@Override
- public LinkedList<BGPValueType> getPrefixdescriptor() {
+ public List<BgpValueType> getPrefixdescriptor() {
return this.bgpPrefixLSIdentifier.getPrefixdescriptor();
}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BGPPrefixLSIdentifier.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpPrefixLSIdentifier.java
index 23f41794..d3beaaee 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BGPPrefixLSIdentifier.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpPrefixLSIdentifier.java
@@ -18,12 +18,14 @@ package org.onosproject.bgpio.protocol.linkstate;
import java.util.Iterator;
import java.util.LinkedList;
+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.types.IPReachabilityInformationTlv;
import org.onosproject.bgpio.types.OSPFRouteTypeTlv;
import org.onosproject.bgpio.types.attr.BgpAttrNodeMultiTopologyId;
@@ -36,17 +38,17 @@ import com.google.common.base.MoreObjects;
/**
* Provides Implementation of Local node descriptors and prefix descriptors.
*/
-public class BGPPrefixLSIdentifier {
+public class BgpPrefixLSIdentifier implements Comparable<Object> {
- protected static final Logger log = LoggerFactory.getLogger(BGPPrefixLSIdentifier.class);
+ protected static final Logger log = LoggerFactory.getLogger(BgpPrefixLSIdentifier.class);
public static final int TYPE_AND_LEN = 4;
private NodeDescriptors localNodeDescriptors;
- private LinkedList<BGPValueType> prefixDescriptor;
+ private List<BgpValueType> prefixDescriptor;
/**
* Resets parameters.
*/
- public BGPPrefixLSIdentifier() {
+ public BgpPrefixLSIdentifier() {
this.localNodeDescriptors = null;
this.prefixDescriptor = null;
}
@@ -57,7 +59,7 @@ public class BGPPrefixLSIdentifier {
* @param localNodeDescriptors Local node descriptors
* @param prefixDescriptor Prefix Descriptors
*/
- public BGPPrefixLSIdentifier(NodeDescriptors localNodeDescriptors, LinkedList<BGPValueType> prefixDescriptor) {
+ public BgpPrefixLSIdentifier(NodeDescriptors localNodeDescriptors, List<BgpValueType> prefixDescriptor) {
this.localNodeDescriptors = localNodeDescriptors;
this.prefixDescriptor = prefixDescriptor;
}
@@ -68,18 +70,18 @@ public class BGPPrefixLSIdentifier {
* @param cb ChannelBuffer
* @param protocolId protocol ID
* @return object of this class
- * @throws BGPParseException while parsing Prefix Identifier
+ * @throws BgpParseException while parsing Prefix Identifier
*/
- public static BGPPrefixLSIdentifier parsePrefixIdendifier(ChannelBuffer cb, byte protocolId)
- throws BGPParseException {
+ public static BgpPrefixLSIdentifier parsePrefixIdendifier(ChannelBuffer cb, byte protocolId)
+ throws BgpParseException {
//Parse Local Node descriptor
NodeDescriptors localNodeDescriptors = new NodeDescriptors();
localNodeDescriptors = parseLocalNodeDescriptors(cb, protocolId);
//Parse Prefix descriptor
- LinkedList<BGPValueType> prefixDescriptor = new LinkedList<>();
+ List<BgpValueType> prefixDescriptor = new LinkedList<>();
prefixDescriptor = parsePrefixDescriptors(cb);
- return new BGPPrefixLSIdentifier(localNodeDescriptors, prefixDescriptor);
+ return new BgpPrefixLSIdentifier(localNodeDescriptors, prefixDescriptor);
}
/**
@@ -88,16 +90,16 @@ public class BGPPrefixLSIdentifier {
* @param cb ChannelBuffer
* @param protocolId protocol identifier
* @return LocalNodeDescriptors
- * @throws BGPParseException while parsing local node descriptors
+ * @throws BgpParseException while parsing local node descriptors
*/
public static NodeDescriptors parseLocalNodeDescriptors(ChannelBuffer cb, byte protocolId)
- throws BGPParseException {
- ChannelBuffer tempBuf = cb;
+ throws BgpParseException {
+ ChannelBuffer tempBuf = cb.copy();
short type = cb.readShort();
short length = cb.readShort();
if (cb.readableBytes() < length) {
//length + 4 implies data contains type, length and value
- throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, BGPErrorType.OPTIONAL_ATTRIBUTE_ERROR,
+ throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR,
tempBuf.readBytes(cb.readableBytes() + TYPE_AND_LEN));
}
NodeDescriptors localNodeDescriptors = new NodeDescriptors();
@@ -106,8 +108,8 @@ public class BGPPrefixLSIdentifier {
if (type == NodeDescriptors.LOCAL_NODE_DES_TYPE) {
localNodeDescriptors = NodeDescriptors.read(tempCb, length, type, protocolId);
} else {
- throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR,
- BGPErrorType.MALFORMED_ATTRIBUTE_LIST, null);
+ throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.MALFORMED_ATTRIBUTE_LIST, null);
}
return localNodeDescriptors;
}
@@ -117,22 +119,22 @@ public class BGPPrefixLSIdentifier {
*
* @param cb ChannelBuffer
* @return list of prefix descriptors
- * @throws BGPParseException while parsing list of prefix descriptors
+ * @throws BgpParseException while parsing list of prefix descriptors
*/
- public static LinkedList<BGPValueType> parsePrefixDescriptors(ChannelBuffer cb) throws BGPParseException {
- LinkedList<BGPValueType> prefixDescriptor = new LinkedList<>();
- BGPValueType tlv = null;
+ public static List<BgpValueType> parsePrefixDescriptors(ChannelBuffer cb) throws BgpParseException {
+ LinkedList<BgpValueType> prefixDescriptor = new LinkedList<>();
+ BgpValueType tlv = null;
boolean isIpReachInfo = false;
ChannelBuffer tempCb;
int count = 0;
while (cb.readableBytes() > 0) {
- ChannelBuffer tempBuf = cb;
+ ChannelBuffer tempBuf = cb.copy();
short type = cb.readShort();
short length = cb.readShort();
if (cb.readableBytes() < length) {
//length + 4 implies data contains type, length and value
- throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, BGPErrorType.OPTIONAL_ATTRIBUTE_ERROR,
+ throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR,
tempBuf.readBytes(cb.readableBytes() + TYPE_AND_LEN));
}
tempCb = cb.readBytes(length);
@@ -149,8 +151,8 @@ public class BGPPrefixLSIdentifier {
count = count + 1;
if (count > 1) {
//length + 4 implies data contains type, length and value
- throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR,
- BGPErrorType.OPTIONAL_ATTRIBUTE_ERROR, tempBuf.readBytes(length + TYPE_AND_LEN));
+ throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR, tempBuf.readBytes(length + TYPE_AND_LEN));
}
break;
default:
@@ -160,7 +162,7 @@ public class BGPPrefixLSIdentifier {
}
if (!isIpReachInfo) {
- throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, BGPErrorType.OPTIONAL_ATTRIBUTE_ERROR,
+ throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR,
null);
}
return prefixDescriptor;
@@ -180,7 +182,7 @@ public class BGPPrefixLSIdentifier {
*
* @return Prefix descriptors
*/
- public LinkedList<BGPValueType> getPrefixdescriptor() {
+ public List<BgpValueType> getPrefixdescriptor() {
return this.prefixDescriptor;
}
@@ -195,22 +197,26 @@ public class BGPPrefixLSIdentifier {
return true;
}
- if (obj instanceof BGPPrefixLSIdentifier) {
+ if (obj instanceof BgpPrefixLSIdentifier) {
int countObjSubTlv = 0;
int countOtherSubTlv = 0;
boolean isCommonSubTlv = true;
- BGPPrefixLSIdentifier other = (BGPPrefixLSIdentifier) obj;
+ BgpPrefixLSIdentifier other = (BgpPrefixLSIdentifier) obj;
- Iterator<BGPValueType> objListIterator = other.prefixDescriptor.iterator();
+ Iterator<BgpValueType> objListIterator = other.prefixDescriptor.iterator();
countOtherSubTlv = other.prefixDescriptor.size();
countObjSubTlv = prefixDescriptor.size();
if (countObjSubTlv != countOtherSubTlv) {
return false;
} else {
while (objListIterator.hasNext() && isCommonSubTlv) {
- BGPValueType subTlv = objListIterator.next();
- isCommonSubTlv = Objects.equals(prefixDescriptor.contains(subTlv),
- other.prefixDescriptor.contains(subTlv));
+ BgpValueType subTlv = objListIterator.next();
+ if (prefixDescriptor.contains(subTlv) && other.prefixDescriptor.contains(subTlv)) {
+ isCommonSubTlv = Objects.equals(prefixDescriptor.get(prefixDescriptor.indexOf(subTlv)),
+ other.prefixDescriptor.get(other.prefixDescriptor.indexOf(subTlv)));
+ } else {
+ isCommonSubTlv = false;
+ }
}
return isCommonSubTlv && Objects.equals(this.localNodeDescriptors, other.localNodeDescriptors);
}
@@ -225,4 +231,41 @@ public class BGPPrefixLSIdentifier {
.add("prefixDescriptor", prefixDescriptor)
.toString();
}
+
+ @Override
+ public int compareTo(Object o) {
+ if (this.equals(o)) {
+ return 0;
+ }
+ int result = this.localNodeDescriptors.compareTo(((BgpPrefixLSIdentifier) o).localNodeDescriptors);
+ if (result != 0) {
+ return result;
+ } else {
+ int countOtherSubTlv = ((BgpPrefixLSIdentifier) o).prefixDescriptor.size();
+ int countObjSubTlv = prefixDescriptor.size();
+ if (countOtherSubTlv != countObjSubTlv) {
+ if (countOtherSubTlv > countObjSubTlv) {
+ return 1;
+ } else {
+ return -1;
+ }
+ }
+
+ ListIterator<BgpValueType> listIterator = prefixDescriptor.listIterator();
+ ListIterator<BgpValueType> listIteratorOther = ((BgpPrefixLSIdentifier) o).prefixDescriptor.listIterator();
+ while (listIterator.hasNext()) {
+ BgpValueType tlv = listIterator.next();
+ BgpValueType tlv1 = listIteratorOther.next();
+ if (prefixDescriptor.contains(tlv) && ((BgpPrefixLSIdentifier) o).prefixDescriptor.contains(tlv1)) {
+ int res = prefixDescriptor.get(prefixDescriptor.indexOf(tlv)).compareTo(
+ ((BgpPrefixLSIdentifier) o).prefixDescriptor
+ .get(((BgpPrefixLSIdentifier) o).prefixDescriptor.indexOf(tlv1)));
+ if (res != 0) {
+ return res;
+ }
+ }
+ }
+ }
+ return 0;
+ }
}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/NodeDescriptors.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/NodeDescriptors.java
index 74637c7e..7fb1b316 100644
--- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/NodeDescriptors.java
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/NodeDescriptors.java
@@ -18,15 +18,17 @@ package org.onosproject.bgpio.protocol.linkstate;
import java.util.Iterator;
import java.util.LinkedList;
+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.exceptions.BgpParseException;
import org.onosproject.bgpio.types.AreaIDTlv;
import org.onosproject.bgpio.types.AutonomousSystemTlv;
-import org.onosproject.bgpio.types.BGPErrorType;
-import org.onosproject.bgpio.types.BGPLSIdentifierTlv;
-import org.onosproject.bgpio.types.BGPValueType;
+import org.onosproject.bgpio.types.BgpErrorType;
+import org.onosproject.bgpio.types.BgpLSIdentifierTlv;
+import org.onosproject.bgpio.types.BgpValueType;
import org.onosproject.bgpio.types.IsIsNonPseudonode;
import org.onosproject.bgpio.types.IsIsPseudonode;
import org.onosproject.bgpio.types.OSPFNonPseudonode;
@@ -57,7 +59,7 @@ public class NodeDescriptors {
Figure : Local or Remote Node Descriptors TLV format
*/
- protected static final Logger log = LoggerFactory.getLogger(NodeDescriptors.class);
+ private static final Logger log = LoggerFactory.getLogger(NodeDescriptors.class);
public static final short LOCAL_NODE_DES_TYPE = 256;
public static final short REMOTE_NODE_DES_TYPE = 257;
@@ -71,7 +73,7 @@ public class NodeDescriptors {
public static final int ISISPSEUDONODE_LEN = 7;
public static final int OSPFNONPSEUDONODE_LEN = 4;
public static final int OSPFPSEUDONODE_LEN = 8;
- private LinkedList<BGPValueType> subTlvs;
+ private List<BgpValueType> subTlvs;
private short deslength;
private short desType;
@@ -91,7 +93,7 @@ public class NodeDescriptors {
* @param deslength Descriptors length
* @param desType local node descriptor or remote node descriptor type
*/
- public NodeDescriptors(LinkedList<BGPValueType> subTlvs, short deslength, short desType) {
+ public NodeDescriptors(List<BgpValueType> subTlvs, short deslength, short desType) {
this.subTlvs = subTlvs;
this.deslength = deslength;
this.desType = desType;
@@ -102,7 +104,7 @@ public class NodeDescriptors {
*
* @return subTlvs list of subTlvs
*/
- public LinkedList<BGPValueType> getSubTlvs() {
+ public List<BgpValueType> getSubTlvs() {
return subTlvs;
}
@@ -122,15 +124,20 @@ public class NodeDescriptors {
int countOtherSubTlv = 0;
boolean isCommonSubTlv = true;
NodeDescriptors other = (NodeDescriptors) obj;
- Iterator<BGPValueType> objListIterator = other.subTlvs.iterator();
+ Iterator<BgpValueType> objListIterator = other.subTlvs.iterator();
countOtherSubTlv = other.subTlvs.size();
countObjSubTlv = subTlvs.size();
if (countObjSubTlv != countOtherSubTlv) {
return false;
} else {
while (objListIterator.hasNext() && isCommonSubTlv) {
- BGPValueType subTlv = objListIterator.next();
- isCommonSubTlv = Objects.equals(subTlvs.contains(subTlv), other.subTlvs.contains(subTlv));
+ BgpValueType subTlv = objListIterator.next();
+ if (subTlvs.contains(subTlv) && other.subTlvs.contains(subTlv)) {
+ isCommonSubTlv = Objects.equals(subTlvs.get(subTlvs.indexOf(subTlv)),
+ other.subTlvs.get(other.subTlvs.indexOf(subTlv)));
+ } else {
+ isCommonSubTlv = false;
+ }
}
return isCommonSubTlv;
}
@@ -146,20 +153,20 @@ public class NodeDescriptors {
* @param desType local node descriptor or remote node descriptor type
* @param protocolId protocol ID
* @return object of NodeDescriptors
- * @throws BGPParseException while parsing node descriptors
+ * @throws BgpParseException while parsing node descriptors
*/
public static NodeDescriptors read(ChannelBuffer cb, short desLength, short desType, byte protocolId)
- throws BGPParseException {
- LinkedList<BGPValueType> subTlvs;
- subTlvs = new LinkedList<>();
- BGPValueType tlv = null;
+ throws BgpParseException {
+ log.debug("Read NodeDescriptor");
+ List<BgpValueType> subTlvs = new LinkedList<>();
+ BgpValueType tlv = null;
while (cb.readableBytes() > 0) {
- ChannelBuffer tempBuf = cb;
+ ChannelBuffer tempBuf = cb.copy();
short type = cb.readShort();
short length = cb.readShort();
if (cb.readableBytes() < length) {
- throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, BGPErrorType.OPTIONAL_ATTRIBUTE_ERROR,
+ throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR,
tempBuf.readBytes(cb.readableBytes() + TYPE_AND_LEN));
}
ChannelBuffer tempCb = cb.readBytes(length);
@@ -167,8 +174,8 @@ public class NodeDescriptors {
case AutonomousSystemTlv.TYPE:
tlv = AutonomousSystemTlv.read(tempCb);
break;
- case BGPLSIdentifierTlv.TYPE:
- tlv = BGPLSIdentifierTlv.read(tempCb);
+ case BgpLSIdentifierTlv.TYPE:
+ tlv = BgpLSIdentifierTlv.read(tempCb);
break;
case AreaIDTlv.TYPE:
tlv = AreaIDTlv.read(tempCb);
@@ -222,4 +229,34 @@ public class NodeDescriptors {
.add("subTlvs", subTlvs)
.toString();
}
+
+ public int compareTo(Object o) {
+ if (this.equals(o)) {
+ return 0;
+ }
+ ListIterator<BgpValueType> listIterator = subTlvs.listIterator();
+ ListIterator<BgpValueType> listIteratorOther = ((NodeDescriptors) o).subTlvs.listIterator();
+ int countOtherSubTlv = ((NodeDescriptors) o).subTlvs.size();
+ int countObjSubTlv = subTlvs.size();
+ if (countOtherSubTlv != countObjSubTlv) {
+ if (countOtherSubTlv > countObjSubTlv) {
+ return 1;
+ } else {
+ return -1;
+ }
+ } else {
+ while (listIterator.hasNext()) {
+ BgpValueType tlv = listIterator.next();
+ BgpValueType tlv1 = listIteratorOther.next();
+ if (subTlvs.contains(tlv) && ((NodeDescriptors) o).subTlvs.contains(tlv1)) {
+ int result = subTlvs.get(subTlvs.indexOf(tlv)).compareTo(
+ ((NodeDescriptors) o).subTlvs.get(((NodeDescriptors) o).subTlvs.indexOf(tlv1)));
+ if (result != 0) {
+ return result;
+ }
+ }
+ }
+ }
+ return 0;
+ }
}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/PathAttrNlriDetails.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/PathAttrNlriDetails.java
new file mode 100755
index 00000000..9578ccfe
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/PathAttrNlriDetails.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.protocol.linkstate;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Objects;
+
+import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4.ProtocolType;
+import org.onosproject.bgpio.types.BgpValueType;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * This Class stores path Attributes, protocol ID and Identifier of LinkState NLRI.
+ */
+public class PathAttrNlriDetails {
+ private List<BgpValueType> pathAttributes;
+ private ProtocolType protocolID;
+ private long identifier;
+
+ /**
+ * Sets path attribute with specified path attribute.
+ *
+ * @param pathAttributes in update message
+ */
+ public void setPathAttribute(List<BgpValueType> pathAttributes) {
+ this.pathAttributes = pathAttributes;
+ }
+
+ /**
+ * Returns path attributes.
+ *
+ * @return path attributes
+ */
+ public List<BgpValueType> pathAttributes() {
+ return this.pathAttributes;
+ }
+
+ /**
+ * Sets protocolID with specified protocolID.
+ *
+ * @param protocolID in linkstate nlri
+ */
+ public void setProtocolID(ProtocolType protocolID) {
+ this.protocolID = protocolID;
+ }
+
+ /**
+ * Returns protocolID.
+ *
+ * @return protocolID
+ */
+ public ProtocolType protocolID() {
+ return this.protocolID;
+ }
+
+ /**
+ * Sets identifier with specified identifier.
+ *
+ * @param identifier in linkstate nlri
+ */
+ public void setIdentifier(long identifier) {
+ this.identifier = identifier;
+ }
+
+ /**
+ * Returns Identifier.
+ *
+ * @return Identifier
+ */
+ public long identifier() {
+ return this.identifier;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(pathAttributes, protocolID, identifier);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj instanceof PathAttrNlriDetails) {
+ int countObjSubTlv = 0;
+ int countOtherSubTlv = 0;
+ boolean isCommonSubTlv = true;
+ PathAttrNlriDetails other = (PathAttrNlriDetails) obj;
+ Iterator<BgpValueType> objListIterator = other.pathAttributes.iterator();
+ countOtherSubTlv = other.pathAttributes.size();
+ countObjSubTlv = pathAttributes.size();
+ if (countObjSubTlv != countOtherSubTlv) {
+ return false;
+ } else {
+ while (objListIterator.hasNext() && isCommonSubTlv) {
+ BgpValueType subTlv = objListIterator.next();
+ if (pathAttributes.contains(subTlv) && other.pathAttributes.contains(subTlv)) {
+ isCommonSubTlv = Objects.equals(pathAttributes.get(pathAttributes.indexOf(subTlv)),
+ other.pathAttributes.get(other.pathAttributes.indexOf(subTlv)));
+ } else {
+ isCommonSubTlv = false;
+ }
+ }
+ return isCommonSubTlv && Objects.equals(identifier, other.identifier)
+ && Objects.equals(protocolID, other.protocolID);
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("identifier", identifier)
+ .add("protocolID", protocolID)
+ .add("pathAttributes", pathAttributes)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/PathAttrNlriDetailsLocalRib.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/PathAttrNlriDetailsLocalRib.java
new file mode 100755
index 00000000..4172ae46
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/PathAttrNlriDetailsLocalRib.java
@@ -0,0 +1,122 @@
+/*
+ * 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.protocol.linkstate;
+
+import java.util.Objects;
+
+import org.onlab.packet.IpAddress;
+import com.google.common.base.MoreObjects;
+
+/**
+ * This Class stores path Attributes, protocol ID and Identifier of LinkState nlri.
+ */
+public class PathAttrNlriDetailsLocalRib {
+
+ private IpAddress localRibIpAddress;
+ private long localRibAsNum;
+ private int localRibIdentifier;
+ private boolean isLocalRibIbgpSession;
+ private PathAttrNlriDetails localRibNlridetails;
+
+ /**
+ * Constructor to initialize parameter.
+ *
+ * @param localRibIpAddress peer ip address
+ * @param localRibIdentifier peer identifier
+ * @param localRibAsNum peer As number
+ * @param isLocalRibIbgpSession flag to indicate is Ibgp session
+ * @param localRibNlridetails Nlri details
+ *
+ */
+ public PathAttrNlriDetailsLocalRib(IpAddress localRibIpAddress, int localRibIdentifier, long localRibAsNum,
+ boolean isLocalRibIbgpSession, PathAttrNlriDetails localRibNlridetails) {
+ this.localRibIpAddress = localRibIpAddress;
+ this.localRibAsNum = localRibAsNum;
+ this.localRibIdentifier = localRibIdentifier;
+ this.isLocalRibIbgpSession = isLocalRibIbgpSession;
+ this.localRibNlridetails = localRibNlridetails;
+ }
+
+ /**
+ * Gets the Ipaddress updated in local rib.
+ *
+ * @return localRibIpAddress ip address
+ */
+ public IpAddress localRibIpAddress() {
+ return localRibIpAddress;
+ }
+
+ /**
+ * Gets the autonomous system number updated in local rib.
+ *
+ * @return localRibAsNum autonomous system number
+ */
+ public long localRibAsNum() {
+ return localRibAsNum;
+ }
+
+ /**
+ * Gets the indetifier updated in local rib.
+ *
+ * @return localRibIdentifier identifier
+ */
+ public int localRibIdentifier() {
+ return localRibIdentifier;
+ }
+
+ /**
+ * Gets the bgp session type updated in local rib.
+ *
+ * @return isLocalRibIbgpSession session type
+ */
+ public boolean isLocalRibIbgpSession() {
+ return isLocalRibIbgpSession;
+ }
+
+ /**
+ * Returns local RIB Nlri details.
+ *
+ * @return localRibNlridetails Nlri details in local rib
+ */
+ public PathAttrNlriDetails localRibNlridetails() {
+ return this.localRibNlridetails;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(localRibIpAddress, localRibIdentifier, localRibAsNum, isLocalRibIbgpSession,
+ localRibNlridetails.hashCode());
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof PathAttrNlriDetailsLocalRib) {
+ PathAttrNlriDetailsLocalRib other = (PathAttrNlriDetailsLocalRib) obj;
+ return Objects.equals(localRibIpAddress, other.localRibIpAddress)
+ && Objects.equals(localRibIdentifier, other.localRibIdentifier)
+ && Objects.equals(localRibAsNum, other.localRibAsNum)
+ && Objects.equals(isLocalRibIbgpSession, other.isLocalRibIbgpSession)
+ && Objects.equals(localRibNlridetails, other.localRibNlridetails);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).add("peerIdentifier", localRibIdentifier)
+ .add("localRibpathAttributes", localRibNlridetails.pathAttributes()).toString();
+ }
+}