Priyanka B
Committed by Gerrit Code Review

Adj-In RIB code fix

Change-Id: Ice870ab1aff068cc27a5337a3f4ff7090a53d84d
Showing 54 changed files with 560 additions and 106 deletions
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
15 */ 15 */
16 package org.onosproject.bgpio.protocol; 16 package org.onosproject.bgpio.protocol;
17 17
18 -import java.util.LinkedList; 18 +import java.util.List;
19 19
20 import org.onosproject.bgpio.types.BgpValueType; 20 import org.onosproject.bgpio.types.BgpValueType;
21 import org.onosproject.bgpio.protocol.linkstate.NodeDescriptors; 21 import org.onosproject.bgpio.protocol.linkstate.NodeDescriptors;
...@@ -36,5 +36,5 @@ public interface BgpPrefixLSNlri extends BgpLSNlri { ...@@ -36,5 +36,5 @@ public interface BgpPrefixLSNlri extends BgpLSNlri {
36 * 36 *
37 * @return list of Prefix descriptor 37 * @return list of Prefix descriptor
38 */ 38 */
39 - LinkedList<BgpValueType> getPrefixdescriptor(); 39 + List<BgpValueType> getPrefixdescriptor();
40 } 40 }
......
...@@ -18,6 +18,7 @@ package org.onosproject.bgpio.protocol.linkstate; ...@@ -18,6 +18,7 @@ package org.onosproject.bgpio.protocol.linkstate;
18 import java.util.Iterator; 18 import java.util.Iterator;
19 import java.util.LinkedList; 19 import java.util.LinkedList;
20 import java.util.List; 20 import java.util.List;
21 +import java.util.ListIterator;
21 import java.util.Objects; 22 import java.util.Objects;
22 23
23 import org.jboss.netty.buffer.ChannelBuffer; 24 import org.jboss.netty.buffer.ChannelBuffer;
...@@ -28,6 +29,7 @@ import org.onosproject.bgpio.types.IPv4AddressTlv; ...@@ -28,6 +29,7 @@ import org.onosproject.bgpio.types.IPv4AddressTlv;
28 import org.onosproject.bgpio.types.IPv6AddressTlv; 29 import org.onosproject.bgpio.types.IPv6AddressTlv;
29 import org.onosproject.bgpio.types.LinkLocalRemoteIdentifiersTlv; 30 import org.onosproject.bgpio.types.LinkLocalRemoteIdentifiersTlv;
30 import org.onosproject.bgpio.types.attr.BgpAttrNodeMultiTopologyId; 31 import org.onosproject.bgpio.types.attr.BgpAttrNodeMultiTopologyId;
32 +import org.onosproject.bgpio.util.Constants;
31 import org.onosproject.bgpio.util.UnSupportedAttribute; 33 import org.onosproject.bgpio.util.UnSupportedAttribute;
32 import org.slf4j.Logger; 34 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory; 35 import org.slf4j.LoggerFactory;
...@@ -38,13 +40,12 @@ import com.google.common.base.Preconditions; ...@@ -38,13 +40,12 @@ import com.google.common.base.Preconditions;
38 /** 40 /**
39 * Implementation of local node descriptors, remote node descriptors and link descriptors. 41 * Implementation of local node descriptors, remote node descriptors and link descriptors.
40 */ 42 */
41 -public class BgpLinkLSIdentifier { 43 +public class BgpLinkLSIdentifier implements Comparable<Object> {
42 private static final Logger log = LoggerFactory.getLogger(BgpLinkLSIdentifier.class); 44 private static final Logger log = LoggerFactory.getLogger(BgpLinkLSIdentifier.class);
43 public static final short IPV4_INTERFACE_ADDRESS_TYPE = 259; 45 public static final short IPV4_INTERFACE_ADDRESS_TYPE = 259;
44 public static final short IPV4_NEIGHBOR_ADDRESS_TYPE = 260; 46 public static final short IPV4_NEIGHBOR_ADDRESS_TYPE = 260;
45 public static final short IPV6_INTERFACE_ADDRESS_TYPE = 261; 47 public static final short IPV6_INTERFACE_ADDRESS_TYPE = 261;
46 public static final short IPV6_NEIGHBOR_ADDRESS_TYPE = 262; 48 public static final short IPV6_NEIGHBOR_ADDRESS_TYPE = 262;
47 - public static final int TYPE_AND_LEN = 4;
48 49
49 private NodeDescriptors localNodeDescriptors; 50 private NodeDescriptors localNodeDescriptors;
50 private NodeDescriptors remoteNodeDescriptors; 51 private NodeDescriptors remoteNodeDescriptors;
...@@ -107,12 +108,13 @@ public class BgpLinkLSIdentifier { ...@@ -107,12 +108,13 @@ public class BgpLinkLSIdentifier {
107 */ 108 */
108 public static NodeDescriptors parseNodeDescriptors(ChannelBuffer cb, short desType, byte protocolId) 109 public static NodeDescriptors parseNodeDescriptors(ChannelBuffer cb, short desType, byte protocolId)
109 throws BgpParseException { 110 throws BgpParseException {
110 - ChannelBuffer tempBuf = cb; 111 + log.debug("parse Node descriptors");
112 + ChannelBuffer tempBuf = cb.copy();
111 short type = cb.readShort(); 113 short type = cb.readShort();
112 short length = cb.readShort(); 114 short length = cb.readShort();
113 if (cb.readableBytes() < length) { 115 if (cb.readableBytes() < length) {
114 throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR, 116 throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR,
115 - tempBuf.readBytes(cb.readableBytes() + TYPE_AND_LEN)); 117 + tempBuf.readBytes(cb.readableBytes() + Constants.TYPE_AND_LEN_AS_SHORT));
116 } 118 }
117 NodeDescriptors nodeIdentifier = new NodeDescriptors(); 119 NodeDescriptors nodeIdentifier = new NodeDescriptors();
118 ChannelBuffer tempCb = cb.readBytes(length); 120 ChannelBuffer tempCb = cb.readBytes(length);
...@@ -138,12 +140,12 @@ public class BgpLinkLSIdentifier { ...@@ -138,12 +140,12 @@ public class BgpLinkLSIdentifier {
138 int count = 0; 140 int count = 0;
139 141
140 while (cb.readableBytes() > 0) { 142 while (cb.readableBytes() > 0) {
141 - ChannelBuffer tempBuf = cb; 143 + ChannelBuffer tempBuf = cb.copy();
142 short type = cb.readShort(); 144 short type = cb.readShort();
143 short length = cb.readShort(); 145 short length = cb.readShort();
144 if (cb.readableBytes() < length) { 146 if (cb.readableBytes() < length) {
145 throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR, 147 throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR,
146 - tempBuf.readBytes(cb.readableBytes() + TYPE_AND_LEN)); 148 + tempBuf.readBytes(cb.readableBytes() + Constants.TYPE_AND_LEN_AS_SHORT));
147 } 149 }
148 ChannelBuffer tempCb = cb.readBytes(length); 150 ChannelBuffer tempCb = cb.readBytes(length);
149 switch (type) { 151 switch (type) {
...@@ -170,7 +172,7 @@ public class BgpLinkLSIdentifier { ...@@ -170,7 +172,7 @@ public class BgpLinkLSIdentifier {
170 //length + 4 implies data contains type, length and value 172 //length + 4 implies data contains type, length and value
171 throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, 173 throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
172 BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR, tempBuf.readBytes(length 174 BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR, tempBuf.readBytes(length
173 - + TYPE_AND_LEN)); 175 + + Constants.TYPE_AND_LEN_AS_SHORT));
174 } 176 }
175 break; 177 break;
176 default: 178 default:
...@@ -231,8 +233,12 @@ public class BgpLinkLSIdentifier { ...@@ -231,8 +233,12 @@ public class BgpLinkLSIdentifier {
231 } else { 233 } else {
232 while (objListIterator.hasNext() && isCommonSubTlv) { 234 while (objListIterator.hasNext() && isCommonSubTlv) {
233 BgpValueType subTlv = objListIterator.next(); 235 BgpValueType subTlv = objListIterator.next();
234 - isCommonSubTlv = Objects.equals(linkDescriptor.contains(subTlv), 236 + if (linkDescriptor.contains(subTlv) && other.linkDescriptor.contains(subTlv)) {
235 - other.linkDescriptor.contains(subTlv)); 237 + isCommonSubTlv = Objects.equals(linkDescriptor.get(linkDescriptor.indexOf(subTlv)),
238 + other.linkDescriptor.get(other.linkDescriptor.indexOf(subTlv)));
239 + } else {
240 + isCommonSubTlv = false;
241 + }
236 } 242 }
237 return isCommonSubTlv && Objects.equals(this.localNodeDescriptors, other.localNodeDescriptors) 243 return isCommonSubTlv && Objects.equals(this.localNodeDescriptors, other.localNodeDescriptors)
238 && Objects.equals(this.remoteNodeDescriptors, other.remoteNodeDescriptors); 244 && Objects.equals(this.remoteNodeDescriptors, other.remoteNodeDescriptors);
...@@ -249,4 +255,42 @@ public class BgpLinkLSIdentifier { ...@@ -249,4 +255,42 @@ public class BgpLinkLSIdentifier {
249 .add("linkDescriptor", linkDescriptor) 255 .add("linkDescriptor", linkDescriptor)
250 .toString(); 256 .toString();
251 } 257 }
258 +
259 + @Override
260 + public int compareTo(Object o) {
261 + if (this.equals(o)) {
262 + return 0;
263 + }
264 + int result = this.localNodeDescriptors.compareTo(((BgpLinkLSIdentifier) o).localNodeDescriptors);
265 + if (result != 0) {
266 + return result;
267 + } else if (this.remoteNodeDescriptors.compareTo(((BgpLinkLSIdentifier) o).remoteNodeDescriptors) != 0) {
268 + return this.remoteNodeDescriptors.compareTo(((BgpLinkLSIdentifier) o).remoteNodeDescriptors);
269 + } else {
270 + int countOtherSubTlv = ((BgpLinkLSIdentifier) o).linkDescriptor.size();
271 + int countObjSubTlv = linkDescriptor.size();
272 + if (countOtherSubTlv != countObjSubTlv) {
273 + if (countOtherSubTlv > countObjSubTlv) {
274 + return 1;
275 + } else {
276 + return -1;
277 + }
278 + }
279 + ListIterator<BgpValueType> listIterator = linkDescriptor.listIterator();
280 + ListIterator<BgpValueType> listIteratorOther = ((BgpLinkLSIdentifier) o).linkDescriptor.listIterator();
281 + while (listIterator.hasNext()) {
282 + BgpValueType tlv = listIterator.next();
283 + BgpValueType tlv1 = listIteratorOther.next();
284 + if (linkDescriptor.contains(tlv) && ((BgpLinkLSIdentifier) o).linkDescriptor.contains(tlv1)) {
285 + int res = linkDescriptor.get(linkDescriptor.indexOf(tlv)).compareTo(
286 + ((BgpLinkLSIdentifier) o).linkDescriptor.get(((BgpLinkLSIdentifier) o).linkDescriptor
287 + .indexOf(tlv1)));
288 + if (res != 0) {
289 + return res;
290 + }
291 + }
292 + }
293 + }
294 + return 0;
295 + }
252 } 296 }
......
...@@ -29,9 +29,9 @@ import com.google.common.base.MoreObjects; ...@@ -29,9 +29,9 @@ import com.google.common.base.MoreObjects;
29 /** 29 /**
30 * Implementation of Node Identifier which includes local node descriptor/remote node descriptors. 30 * Implementation of Node Identifier which includes local node descriptor/remote node descriptors.
31 */ 31 */
32 -public class BgpNodeLSIdentifier { 32 +public class BgpNodeLSIdentifier implements Comparable<Object> {
33 33
34 - protected static final Logger log = LoggerFactory.getLogger(BgpNodeLSIdentifier.class); 34 + private static final Logger log = LoggerFactory.getLogger(BgpNodeLSIdentifier.class);
35 private NodeDescriptors nodeDescriptors; 35 private NodeDescriptors nodeDescriptors;
36 36
37 /** 37 /**
...@@ -60,7 +60,8 @@ public class BgpNodeLSIdentifier { ...@@ -60,7 +60,8 @@ public class BgpNodeLSIdentifier {
60 */ 60 */
61 public static BgpNodeLSIdentifier parseLocalNodeDescriptors(ChannelBuffer cb, byte protocolId) 61 public static BgpNodeLSIdentifier parseLocalNodeDescriptors(ChannelBuffer cb, byte protocolId)
62 throws BgpParseException { 62 throws BgpParseException {
63 - ChannelBuffer tempBuf = cb; 63 + log.debug("parse Local node descriptor");
64 + ChannelBuffer tempBuf = cb.copy();
64 short type = cb.readShort(); 65 short type = cb.readShort();
65 short length = cb.readShort(); 66 short length = cb.readShort();
66 if (cb.readableBytes() < length) { 67 if (cb.readableBytes() < length) {
...@@ -110,4 +111,12 @@ public class BgpNodeLSIdentifier { ...@@ -110,4 +111,12 @@ public class BgpNodeLSIdentifier {
110 .add("NodeDescriptors", nodeDescriptors) 111 .add("NodeDescriptors", nodeDescriptors)
111 .toString(); 112 .toString();
112 } 113 }
114 +
115 + @Override
116 + public int compareTo(Object o) {
117 + if (this.equals(o)) {
118 + return 0;
119 + }
120 + return this.nodeDescriptors.compareTo(((BgpNodeLSIdentifier) o).nodeDescriptors);
121 + }
113 } 122 }
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
15 */ 15 */
16 package org.onosproject.bgpio.protocol.linkstate; 16 package org.onosproject.bgpio.protocol.linkstate;
17 17
18 -import java.util.LinkedList; 18 +import java.util.List;
19 19
20 import org.jboss.netty.buffer.ChannelBuffer; 20 import org.jboss.netty.buffer.ChannelBuffer;
21 import org.onosproject.bgpio.exceptions.BgpParseException; 21 import org.onosproject.bgpio.exceptions.BgpParseException;
...@@ -188,7 +188,7 @@ public class BgpPrefixIPv4LSNlriVer4 implements BgpPrefixLSNlri { ...@@ -188,7 +188,7 @@ public class BgpPrefixIPv4LSNlriVer4 implements BgpPrefixLSNlri {
188 } 188 }
189 189
190 @Override 190 @Override
191 - public LinkedList<BgpValueType> getPrefixdescriptor() { 191 + public List<BgpValueType> getPrefixdescriptor() {
192 return this.bgpPrefixLSIdentifier.getPrefixdescriptor(); 192 return this.bgpPrefixLSIdentifier.getPrefixdescriptor();
193 } 193 }
194 194
......
...@@ -18,6 +18,8 @@ package org.onosproject.bgpio.protocol.linkstate; ...@@ -18,6 +18,8 @@ package org.onosproject.bgpio.protocol.linkstate;
18 18
19 import java.util.Iterator; 19 import java.util.Iterator;
20 import java.util.LinkedList; 20 import java.util.LinkedList;
21 +import java.util.List;
22 +import java.util.ListIterator;
21 import java.util.Objects; 23 import java.util.Objects;
22 24
23 import org.jboss.netty.buffer.ChannelBuffer; 25 import org.jboss.netty.buffer.ChannelBuffer;
...@@ -36,12 +38,12 @@ import com.google.common.base.MoreObjects; ...@@ -36,12 +38,12 @@ import com.google.common.base.MoreObjects;
36 /** 38 /**
37 * Provides Implementation of Local node descriptors and prefix descriptors. 39 * Provides Implementation of Local node descriptors and prefix descriptors.
38 */ 40 */
39 -public class BgpPrefixLSIdentifier { 41 +public class BgpPrefixLSIdentifier implements Comparable<Object> {
40 42
41 protected static final Logger log = LoggerFactory.getLogger(BgpPrefixLSIdentifier.class); 43 protected static final Logger log = LoggerFactory.getLogger(BgpPrefixLSIdentifier.class);
42 public static final int TYPE_AND_LEN = 4; 44 public static final int TYPE_AND_LEN = 4;
43 private NodeDescriptors localNodeDescriptors; 45 private NodeDescriptors localNodeDescriptors;
44 - private LinkedList<BgpValueType> prefixDescriptor; 46 + private List<BgpValueType> prefixDescriptor;
45 47
46 /** 48 /**
47 * Resets parameters. 49 * Resets parameters.
...@@ -57,7 +59,7 @@ public class BgpPrefixLSIdentifier { ...@@ -57,7 +59,7 @@ public class BgpPrefixLSIdentifier {
57 * @param localNodeDescriptors Local node descriptors 59 * @param localNodeDescriptors Local node descriptors
58 * @param prefixDescriptor Prefix Descriptors 60 * @param prefixDescriptor Prefix Descriptors
59 */ 61 */
60 - public BgpPrefixLSIdentifier(NodeDescriptors localNodeDescriptors, LinkedList<BgpValueType> prefixDescriptor) { 62 + public BgpPrefixLSIdentifier(NodeDescriptors localNodeDescriptors, List<BgpValueType> prefixDescriptor) {
61 this.localNodeDescriptors = localNodeDescriptors; 63 this.localNodeDescriptors = localNodeDescriptors;
62 this.prefixDescriptor = prefixDescriptor; 64 this.prefixDescriptor = prefixDescriptor;
63 } 65 }
...@@ -77,7 +79,7 @@ public class BgpPrefixLSIdentifier { ...@@ -77,7 +79,7 @@ public class BgpPrefixLSIdentifier {
77 localNodeDescriptors = parseLocalNodeDescriptors(cb, protocolId); 79 localNodeDescriptors = parseLocalNodeDescriptors(cb, protocolId);
78 80
79 //Parse Prefix descriptor 81 //Parse Prefix descriptor
80 - LinkedList<BgpValueType> prefixDescriptor = new LinkedList<>(); 82 + List<BgpValueType> prefixDescriptor = new LinkedList<>();
81 prefixDescriptor = parsePrefixDescriptors(cb); 83 prefixDescriptor = parsePrefixDescriptors(cb);
82 return new BgpPrefixLSIdentifier(localNodeDescriptors, prefixDescriptor); 84 return new BgpPrefixLSIdentifier(localNodeDescriptors, prefixDescriptor);
83 } 85 }
...@@ -92,7 +94,7 @@ public class BgpPrefixLSIdentifier { ...@@ -92,7 +94,7 @@ public class BgpPrefixLSIdentifier {
92 */ 94 */
93 public static NodeDescriptors parseLocalNodeDescriptors(ChannelBuffer cb, byte protocolId) 95 public static NodeDescriptors parseLocalNodeDescriptors(ChannelBuffer cb, byte protocolId)
94 throws BgpParseException { 96 throws BgpParseException {
95 - ChannelBuffer tempBuf = cb; 97 + ChannelBuffer tempBuf = cb.copy();
96 short type = cb.readShort(); 98 short type = cb.readShort();
97 short length = cb.readShort(); 99 short length = cb.readShort();
98 if (cb.readableBytes() < length) { 100 if (cb.readableBytes() < length) {
...@@ -119,7 +121,7 @@ public class BgpPrefixLSIdentifier { ...@@ -119,7 +121,7 @@ public class BgpPrefixLSIdentifier {
119 * @return list of prefix descriptors 121 * @return list of prefix descriptors
120 * @throws BgpParseException while parsing list of prefix descriptors 122 * @throws BgpParseException while parsing list of prefix descriptors
121 */ 123 */
122 - public static LinkedList<BgpValueType> parsePrefixDescriptors(ChannelBuffer cb) throws BgpParseException { 124 + public static List<BgpValueType> parsePrefixDescriptors(ChannelBuffer cb) throws BgpParseException {
123 LinkedList<BgpValueType> prefixDescriptor = new LinkedList<>(); 125 LinkedList<BgpValueType> prefixDescriptor = new LinkedList<>();
124 BgpValueType tlv = null; 126 BgpValueType tlv = null;
125 boolean isIpReachInfo = false; 127 boolean isIpReachInfo = false;
...@@ -127,7 +129,7 @@ public class BgpPrefixLSIdentifier { ...@@ -127,7 +129,7 @@ public class BgpPrefixLSIdentifier {
127 int count = 0; 129 int count = 0;
128 130
129 while (cb.readableBytes() > 0) { 131 while (cb.readableBytes() > 0) {
130 - ChannelBuffer tempBuf = cb; 132 + ChannelBuffer tempBuf = cb.copy();
131 short type = cb.readShort(); 133 short type = cb.readShort();
132 short length = cb.readShort(); 134 short length = cb.readShort();
133 if (cb.readableBytes() < length) { 135 if (cb.readableBytes() < length) {
...@@ -180,7 +182,7 @@ public class BgpPrefixLSIdentifier { ...@@ -180,7 +182,7 @@ public class BgpPrefixLSIdentifier {
180 * 182 *
181 * @return Prefix descriptors 183 * @return Prefix descriptors
182 */ 184 */
183 - public LinkedList<BgpValueType> getPrefixdescriptor() { 185 + public List<BgpValueType> getPrefixdescriptor() {
184 return this.prefixDescriptor; 186 return this.prefixDescriptor;
185 } 187 }
186 188
...@@ -209,8 +211,12 @@ public class BgpPrefixLSIdentifier { ...@@ -209,8 +211,12 @@ public class BgpPrefixLSIdentifier {
209 } else { 211 } else {
210 while (objListIterator.hasNext() && isCommonSubTlv) { 212 while (objListIterator.hasNext() && isCommonSubTlv) {
211 BgpValueType subTlv = objListIterator.next(); 213 BgpValueType subTlv = objListIterator.next();
212 - isCommonSubTlv = Objects.equals(prefixDescriptor.contains(subTlv), 214 + if (prefixDescriptor.contains(subTlv) && other.prefixDescriptor.contains(subTlv)) {
213 - other.prefixDescriptor.contains(subTlv)); 215 + isCommonSubTlv = Objects.equals(prefixDescriptor.get(prefixDescriptor.indexOf(subTlv)),
216 + other.prefixDescriptor.get(other.prefixDescriptor.indexOf(subTlv)));
217 + } else {
218 + isCommonSubTlv = false;
219 + }
214 } 220 }
215 return isCommonSubTlv && Objects.equals(this.localNodeDescriptors, other.localNodeDescriptors); 221 return isCommonSubTlv && Objects.equals(this.localNodeDescriptors, other.localNodeDescriptors);
216 } 222 }
...@@ -225,4 +231,41 @@ public class BgpPrefixLSIdentifier { ...@@ -225,4 +231,41 @@ public class BgpPrefixLSIdentifier {
225 .add("prefixDescriptor", prefixDescriptor) 231 .add("prefixDescriptor", prefixDescriptor)
226 .toString(); 232 .toString();
227 } 233 }
234 +
235 + @Override
236 + public int compareTo(Object o) {
237 + if (this.equals(o)) {
238 + return 0;
239 + }
240 + int result = this.localNodeDescriptors.compareTo(((BgpPrefixLSIdentifier) o).localNodeDescriptors);
241 + if (result != 0) {
242 + return result;
243 + } else {
244 + int countOtherSubTlv = ((BgpPrefixLSIdentifier) o).prefixDescriptor.size();
245 + int countObjSubTlv = prefixDescriptor.size();
246 + if (countOtherSubTlv != countObjSubTlv) {
247 + if (countOtherSubTlv > countObjSubTlv) {
248 + return 1;
249 + } else {
250 + return -1;
251 + }
252 + }
253 +
254 + ListIterator<BgpValueType> listIterator = prefixDescriptor.listIterator();
255 + ListIterator<BgpValueType> listIteratorOther = ((BgpPrefixLSIdentifier) o).prefixDescriptor.listIterator();
256 + while (listIterator.hasNext()) {
257 + BgpValueType tlv = listIterator.next();
258 + BgpValueType tlv1 = listIteratorOther.next();
259 + if (prefixDescriptor.contains(tlv) && ((BgpPrefixLSIdentifier) o).prefixDescriptor.contains(tlv1)) {
260 + int res = prefixDescriptor.get(prefixDescriptor.indexOf(tlv)).compareTo(
261 + ((BgpPrefixLSIdentifier) o).prefixDescriptor
262 + .get(((BgpPrefixLSIdentifier) o).prefixDescriptor.indexOf(tlv1)));
263 + if (res != 0) {
264 + return res;
265 + }
266 + }
267 + }
268 + }
269 + return 0;
270 + }
228 } 271 }
......
...@@ -18,6 +18,8 @@ package org.onosproject.bgpio.protocol.linkstate; ...@@ -18,6 +18,8 @@ package org.onosproject.bgpio.protocol.linkstate;
18 18
19 import java.util.Iterator; 19 import java.util.Iterator;
20 import java.util.LinkedList; 20 import java.util.LinkedList;
21 +import java.util.List;
22 +import java.util.ListIterator;
21 import java.util.Objects; 23 import java.util.Objects;
22 24
23 import org.jboss.netty.buffer.ChannelBuffer; 25 import org.jboss.netty.buffer.ChannelBuffer;
...@@ -57,7 +59,7 @@ public class NodeDescriptors { ...@@ -57,7 +59,7 @@ public class NodeDescriptors {
57 Figure : Local or Remote Node Descriptors TLV format 59 Figure : Local or Remote Node Descriptors TLV format
58 */ 60 */
59 61
60 - protected static final Logger log = LoggerFactory.getLogger(NodeDescriptors.class); 62 + private static final Logger log = LoggerFactory.getLogger(NodeDescriptors.class);
61 63
62 public static final short LOCAL_NODE_DES_TYPE = 256; 64 public static final short LOCAL_NODE_DES_TYPE = 256;
63 public static final short REMOTE_NODE_DES_TYPE = 257; 65 public static final short REMOTE_NODE_DES_TYPE = 257;
...@@ -71,7 +73,7 @@ public class NodeDescriptors { ...@@ -71,7 +73,7 @@ public class NodeDescriptors {
71 public static final int ISISPSEUDONODE_LEN = 7; 73 public static final int ISISPSEUDONODE_LEN = 7;
72 public static final int OSPFNONPSEUDONODE_LEN = 4; 74 public static final int OSPFNONPSEUDONODE_LEN = 4;
73 public static final int OSPFPSEUDONODE_LEN = 8; 75 public static final int OSPFPSEUDONODE_LEN = 8;
74 - private LinkedList<BgpValueType> subTlvs; 76 + private List<BgpValueType> subTlvs;
75 private short deslength; 77 private short deslength;
76 private short desType; 78 private short desType;
77 79
...@@ -91,7 +93,7 @@ public class NodeDescriptors { ...@@ -91,7 +93,7 @@ public class NodeDescriptors {
91 * @param deslength Descriptors length 93 * @param deslength Descriptors length
92 * @param desType local node descriptor or remote node descriptor type 94 * @param desType local node descriptor or remote node descriptor type
93 */ 95 */
94 - public NodeDescriptors(LinkedList<BgpValueType> subTlvs, short deslength, short desType) { 96 + public NodeDescriptors(List<BgpValueType> subTlvs, short deslength, short desType) {
95 this.subTlvs = subTlvs; 97 this.subTlvs = subTlvs;
96 this.deslength = deslength; 98 this.deslength = deslength;
97 this.desType = desType; 99 this.desType = desType;
...@@ -102,7 +104,7 @@ public class NodeDescriptors { ...@@ -102,7 +104,7 @@ public class NodeDescriptors {
102 * 104 *
103 * @return subTlvs list of subTlvs 105 * @return subTlvs list of subTlvs
104 */ 106 */
105 - public LinkedList<BgpValueType> getSubTlvs() { 107 + public List<BgpValueType> getSubTlvs() {
106 return subTlvs; 108 return subTlvs;
107 } 109 }
108 110
...@@ -130,7 +132,12 @@ public class NodeDescriptors { ...@@ -130,7 +132,12 @@ public class NodeDescriptors {
130 } else { 132 } else {
131 while (objListIterator.hasNext() && isCommonSubTlv) { 133 while (objListIterator.hasNext() && isCommonSubTlv) {
132 BgpValueType subTlv = objListIterator.next(); 134 BgpValueType subTlv = objListIterator.next();
133 - isCommonSubTlv = Objects.equals(subTlvs.contains(subTlv), other.subTlvs.contains(subTlv)); 135 + if (subTlvs.contains(subTlv) && other.subTlvs.contains(subTlv)) {
136 + isCommonSubTlv = Objects.equals(subTlvs.get(subTlvs.indexOf(subTlv)),
137 + other.subTlvs.get(other.subTlvs.indexOf(subTlv)));
138 + } else {
139 + isCommonSubTlv = false;
140 + }
134 } 141 }
135 return isCommonSubTlv; 142 return isCommonSubTlv;
136 } 143 }
...@@ -150,12 +157,12 @@ public class NodeDescriptors { ...@@ -150,12 +157,12 @@ public class NodeDescriptors {
150 */ 157 */
151 public static NodeDescriptors read(ChannelBuffer cb, short desLength, short desType, byte protocolId) 158 public static NodeDescriptors read(ChannelBuffer cb, short desLength, short desType, byte protocolId)
152 throws BgpParseException { 159 throws BgpParseException {
153 - LinkedList<BgpValueType> subTlvs; 160 + log.debug("Read NodeDescriptor");
154 - subTlvs = new LinkedList<>(); 161 + List<BgpValueType> subTlvs = new LinkedList<>();
155 BgpValueType tlv = null; 162 BgpValueType tlv = null;
156 163
157 while (cb.readableBytes() > 0) { 164 while (cb.readableBytes() > 0) {
158 - ChannelBuffer tempBuf = cb; 165 + ChannelBuffer tempBuf = cb.copy();
159 short type = cb.readShort(); 166 short type = cb.readShort();
160 short length = cb.readShort(); 167 short length = cb.readShort();
161 if (cb.readableBytes() < length) { 168 if (cb.readableBytes() < length) {
...@@ -222,4 +229,34 @@ public class NodeDescriptors { ...@@ -222,4 +229,34 @@ public class NodeDescriptors {
222 .add("subTlvs", subTlvs) 229 .add("subTlvs", subTlvs)
223 .toString(); 230 .toString();
224 } 231 }
232 +
233 + public int compareTo(Object o) {
234 + if (this.equals(o)) {
235 + return 0;
236 + }
237 + ListIterator<BgpValueType> listIterator = subTlvs.listIterator();
238 + ListIterator<BgpValueType> listIteratorOther = ((NodeDescriptors) o).subTlvs.listIterator();
239 + int countOtherSubTlv = ((NodeDescriptors) o).subTlvs.size();
240 + int countObjSubTlv = subTlvs.size();
241 + if (countOtherSubTlv != countObjSubTlv) {
242 + if (countOtherSubTlv > countObjSubTlv) {
243 + return 1;
244 + } else {
245 + return -1;
246 + }
247 + } else {
248 + while (listIterator.hasNext()) {
249 + BgpValueType tlv = listIterator.next();
250 + BgpValueType tlv1 = listIteratorOther.next();
251 + if (subTlvs.contains(tlv) && ((NodeDescriptors) o).subTlvs.contains(tlv1)) {
252 + int result = subTlvs.get(subTlvs.indexOf(tlv)).compareTo(
253 + ((NodeDescriptors) o).subTlvs.get(((NodeDescriptors) o).subTlvs.indexOf(tlv1)));
254 + if (result != 0) {
255 + return result;
256 + }
257 + }
258 + }
259 + }
260 + return 0;
261 + }
225 } 262 }
......
...@@ -18,8 +18,6 @@ package org.onosproject.bgpio.types; ...@@ -18,8 +18,6 @@ package org.onosproject.bgpio.types;
18 import java.util.Objects; 18 import java.util.Objects;
19 19
20 import org.jboss.netty.buffer.ChannelBuffer; 20 import org.jboss.netty.buffer.ChannelBuffer;
21 -import org.slf4j.Logger;
22 -import org.slf4j.LoggerFactory;
23 21
24 import com.google.common.base.MoreObjects; 22 import com.google.common.base.MoreObjects;
25 23
...@@ -38,8 +36,6 @@ public class AreaIDTlv implements BgpValueType { ...@@ -38,8 +36,6 @@ public class AreaIDTlv implements BgpValueType {
38 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 36 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
39 */ 37 */
40 38
41 - protected static final Logger log = LoggerFactory.getLogger(AreaIDTlv.class);
42 -
43 public static final short TYPE = 514; 39 public static final short TYPE = 514;
44 public static final short LENGTH = 4; 40 public static final short LENGTH = 4;
45 41
...@@ -116,6 +112,14 @@ public class AreaIDTlv implements BgpValueType { ...@@ -116,6 +112,14 @@ public class AreaIDTlv implements BgpValueType {
116 } 112 }
117 113
118 @Override 114 @Override
115 + public int compareTo(Object o) {
116 + if (this.equals(o)) {
117 + return 0;
118 + }
119 + return ((Integer) (this.areaID)).compareTo((Integer) (((AreaIDTlv) o).areaID));
120 + }
121 +
122 + @Override
119 public String toString() { 123 public String toString() {
120 return MoreObjects.toStringHelper(getClass()) 124 return MoreObjects.toStringHelper(getClass())
121 .add("Type", TYPE) 125 .add("Type", TYPE)
......
...@@ -166,4 +166,10 @@ public class As4Path implements BgpValueType { ...@@ -166,4 +166,10 @@ public class As4Path implements BgpValueType {
166 //Not required to Implement as of now 166 //Not required to Implement as of now
167 return 0; 167 return 0;
168 } 168 }
169 +
170 + @Override
171 + public int compareTo(Object o) {
172 + // TODO Auto-generated method stub
173 + return 0;
174 + }
169 } 175 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -205,4 +205,10 @@ public class AsPath implements BgpValueType { ...@@ -205,4 +205,10 @@ public class AsPath implements BgpValueType {
205 //Not required to Implement as of now 205 //Not required to Implement as of now
206 return 0; 206 return 0;
207 } 207 }
208 +
209 + @Override
210 + public int compareTo(Object o) {
211 + // TODO Auto-generated method stub
212 + return 0;
213 + }
208 } 214 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -18,8 +18,6 @@ package org.onosproject.bgpio.types; ...@@ -18,8 +18,6 @@ package org.onosproject.bgpio.types;
18 import java.util.Objects; 18 import java.util.Objects;
19 19
20 import org.jboss.netty.buffer.ChannelBuffer; 20 import org.jboss.netty.buffer.ChannelBuffer;
21 -import org.slf4j.Logger;
22 -import org.slf4j.LoggerFactory;
23 21
24 import com.google.common.base.MoreObjects; 22 import com.google.common.base.MoreObjects;
25 23
...@@ -38,8 +36,6 @@ public class AutonomousSystemTlv implements BgpValueType { ...@@ -38,8 +36,6 @@ public class AutonomousSystemTlv implements BgpValueType {
38 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 36 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
39 */ 37 */
40 38
41 - protected static final Logger log = LoggerFactory.getLogger(AutonomousSystemTlv.class);
42 -
43 public static final short TYPE = 512; 39 public static final short TYPE = 512;
44 public static final short LENGTH = 4; 40 public static final short LENGTH = 4;
45 41
...@@ -116,6 +112,14 @@ public class AutonomousSystemTlv implements BgpValueType { ...@@ -116,6 +112,14 @@ public class AutonomousSystemTlv implements BgpValueType {
116 } 112 }
117 113
118 @Override 114 @Override
115 + public int compareTo(Object o) {
116 + if (this.equals(o)) {
117 + return 0;
118 + }
119 + return ((Integer) (this.asNum)).compareTo((Integer) (((AutonomousSystemTlv) o).asNum));
120 + }
121 +
122 + @Override
119 public String toString() { 123 public String toString() {
120 return MoreObjects.toStringHelper(getClass()) 124 return MoreObjects.toStringHelper(getClass())
121 .add("Type", TYPE) 125 .add("Type", TYPE)
......
...@@ -19,8 +19,6 @@ package org.onosproject.bgpio.types; ...@@ -19,8 +19,6 @@ package org.onosproject.bgpio.types;
19 import java.util.Objects; 19 import java.util.Objects;
20 20
21 import org.jboss.netty.buffer.ChannelBuffer; 21 import org.jboss.netty.buffer.ChannelBuffer;
22 -import org.slf4j.Logger;
23 -import org.slf4j.LoggerFactory;
24 22
25 import com.google.common.base.MoreObjects; 23 import com.google.common.base.MoreObjects;
26 24
...@@ -39,30 +37,28 @@ public class BgpLSIdentifierTlv implements BgpValueType { ...@@ -39,30 +37,28 @@ public class BgpLSIdentifierTlv implements BgpValueType {
39 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 37 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 */ 38 */
41 39
42 - protected static final Logger log = LoggerFactory.getLogger(BgpLSIdentifierTlv.class);
43 -
44 public static final short TYPE = 513; 40 public static final short TYPE = 513;
45 public static final short LENGTH = 4; 41 public static final short LENGTH = 4;
46 42
47 - private final int bgpLSIdentifier; 43 + private final int bgpLsIdentifier;
48 44
49 /** 45 /**
50 - * Constructor to initialize bgpLSIdentifier. 46 + * Constructor to initialize bgpLsIdentifier.
51 * 47 *
52 - * @param bgpLSIdentifier BGPLS-Identifier 48 + * @param bgpLsIdentifier BGPLS-Identifier
53 */ 49 */
54 - public BgpLSIdentifierTlv(int bgpLSIdentifier) { 50 + public BgpLSIdentifierTlv(int bgpLsIdentifier) {
55 - this.bgpLSIdentifier = bgpLSIdentifier; 51 + this.bgpLsIdentifier = bgpLsIdentifier;
56 } 52 }
57 53
58 /** 54 /**
59 - * Returns object of this class with specified rbgpLSIdentifier. 55 + * Returns object of this class with specified bgpLsIdentifier.
60 * 56 *
61 - * @param bgpLSIdentifier BGPLS-Identifier 57 + * @param bgpLsIdentifier BGPLS-Identifier
62 * @return BGPLS-Identifier 58 * @return BGPLS-Identifier
63 */ 59 */
64 - public static BgpLSIdentifierTlv of(final int bgpLSIdentifier) { 60 + public static BgpLSIdentifierTlv of(final int bgpLsIdentifier) {
65 - return new BgpLSIdentifierTlv(bgpLSIdentifier); 61 + return new BgpLSIdentifierTlv(bgpLsIdentifier);
66 } 62 }
67 63
68 /** 64 /**
...@@ -70,13 +66,13 @@ public class BgpLSIdentifierTlv implements BgpValueType { ...@@ -70,13 +66,13 @@ public class BgpLSIdentifierTlv implements BgpValueType {
70 * 66 *
71 * @return opaque value of BGPLS-Identifier 67 * @return opaque value of BGPLS-Identifier
72 */ 68 */
73 - public int getBgpLSIdentifier() { 69 + public int getBgpLsIdentifier() {
74 - return bgpLSIdentifier; 70 + return bgpLsIdentifier;
75 } 71 }
76 72
77 @Override 73 @Override
78 public int hashCode() { 74 public int hashCode() {
79 - return Objects.hash(bgpLSIdentifier); 75 + return Objects.hash(bgpLsIdentifier);
80 } 76 }
81 77
82 @Override 78 @Override
...@@ -87,7 +83,7 @@ public class BgpLSIdentifierTlv implements BgpValueType { ...@@ -87,7 +83,7 @@ public class BgpLSIdentifierTlv implements BgpValueType {
87 83
88 if (obj instanceof BgpLSIdentifierTlv) { 84 if (obj instanceof BgpLSIdentifierTlv) {
89 BgpLSIdentifierTlv other = (BgpLSIdentifierTlv) obj; 85 BgpLSIdentifierTlv other = (BgpLSIdentifierTlv) obj;
90 - return Objects.equals(bgpLSIdentifier, other.bgpLSIdentifier); 86 + return Objects.equals(bgpLsIdentifier, other.bgpLsIdentifier);
91 } 87 }
92 return false; 88 return false;
93 } 89 }
...@@ -97,7 +93,7 @@ public class BgpLSIdentifierTlv implements BgpValueType { ...@@ -97,7 +93,7 @@ public class BgpLSIdentifierTlv implements BgpValueType {
97 int iLenStartIndex = c.writerIndex(); 93 int iLenStartIndex = c.writerIndex();
98 c.writeShort(TYPE); 94 c.writeShort(TYPE);
99 c.writeShort(LENGTH); 95 c.writeShort(LENGTH);
100 - c.writeInt(bgpLSIdentifier); 96 + c.writeInt(bgpLsIdentifier);
101 return c.writerIndex() - iLenStartIndex; 97 return c.writerIndex() - iLenStartIndex;
102 } 98 }
103 99
...@@ -117,11 +113,19 @@ public class BgpLSIdentifierTlv implements BgpValueType { ...@@ -117,11 +113,19 @@ public class BgpLSIdentifierTlv implements BgpValueType {
117 } 113 }
118 114
119 @Override 115 @Override
116 + public int compareTo(Object o) {
117 + if (this.equals(o)) {
118 + return 0;
119 + }
120 + return ((Integer) (this.bgpLsIdentifier)).compareTo((Integer) (((BgpLSIdentifierTlv) o).bgpLsIdentifier));
121 + }
122 +
123 + @Override
120 public String toString() { 124 public String toString() {
121 return MoreObjects.toStringHelper(getClass()) 125 return MoreObjects.toStringHelper(getClass())
122 .add("Type", TYPE) 126 .add("Type", TYPE)
123 .add("Length", LENGTH) 127 .add("Length", LENGTH)
124 - .add("Value", bgpLSIdentifier) 128 + .add("Value", bgpLsIdentifier)
125 .toString(); 129 .toString();
126 } 130 }
127 } 131 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -36,4 +36,12 @@ public interface BgpValueType { ...@@ -36,4 +36,12 @@ public interface BgpValueType {
36 * @return length written to channel buffer 36 * @return length written to channel buffer
37 */ 37 */
38 int write(ChannelBuffer cb); 38 int write(ChannelBuffer cb);
39 +
40 + /**
41 + * Compares two objects.
42 + *
43 + * @param o object
44 + * @return result after comparing two objects
45 + */
46 + int compareTo(Object o);
39 } 47 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -111,4 +111,10 @@ public class FourOctetAsNumCapabilityTlv implements BgpValueType { ...@@ -111,4 +111,10 @@ public class FourOctetAsNumCapabilityTlv implements BgpValueType {
111 .add("Length", LENGTH) 111 .add("Length", LENGTH)
112 .add("Value", rawValue).toString(); 112 .add("Value", rawValue).toString();
113 } 113 }
114 +
115 + @Override
116 + public int compareTo(Object o) {
117 + // TODO Auto-generated method stub
118 + return 0;
119 + }
114 } 120 }
......
...@@ -15,14 +15,13 @@ ...@@ -15,14 +15,13 @@
15 */ 15 */
16 package org.onosproject.bgpio.types; 16 package org.onosproject.bgpio.types;
17 17
18 +import java.nio.ByteBuffer;
18 import java.util.Arrays; 19 import java.util.Arrays;
19 import java.util.Objects; 20 import java.util.Objects;
20 21
21 import org.jboss.netty.buffer.ChannelBuffer; 22 import org.jboss.netty.buffer.ChannelBuffer;
22 import org.onlab.packet.IpPrefix; 23 import org.onlab.packet.IpPrefix;
23 import org.onosproject.bgpio.util.Validation; 24 import org.onosproject.bgpio.util.Validation;
24 -import org.slf4j.Logger;
25 -import org.slf4j.LoggerFactory;
26 25
27 import com.google.common.base.MoreObjects; 26 import com.google.common.base.MoreObjects;
28 27
...@@ -45,10 +44,9 @@ public class IPReachabilityInformationTlv implements BgpValueType { ...@@ -45,10 +44,9 @@ public class IPReachabilityInformationTlv implements BgpValueType {
45 Figure 14: IP Reachability Information TLV Format 44 Figure 14: IP Reachability Information TLV Format
46 */ 45 */
47 46
48 - protected static final Logger log = LoggerFactory.getLogger(IPReachabilityInformationTlv.class);
49 -
50 public static final short TYPE = 265; 47 public static final short TYPE = 265;
51 public static final int ONE_BYTE_LEN = 8; 48 public static final int ONE_BYTE_LEN = 8;
49 +
52 private byte prefixLen; 50 private byte prefixLen;
53 private byte[] ipPrefix; 51 private byte[] ipPrefix;
54 public short length; 52 public short length;
...@@ -146,6 +144,16 @@ public class IPReachabilityInformationTlv implements BgpValueType { ...@@ -146,6 +144,16 @@ public class IPReachabilityInformationTlv implements BgpValueType {
146 } 144 }
147 145
148 @Override 146 @Override
147 + public int compareTo(Object o) {
148 + if (this.equals(o)) {
149 + return 0;
150 + }
151 + ByteBuffer value1 = ByteBuffer.wrap(this.ipPrefix);
152 + ByteBuffer value2 = ByteBuffer.wrap(((IPReachabilityInformationTlv) o).ipPrefix);
153 + return value1.compareTo(value2);
154 + }
155 +
156 + @Override
149 public String toString() { 157 public String toString() {
150 return MoreObjects.toStringHelper(getClass()) 158 return MoreObjects.toStringHelper(getClass())
151 .add("Type", TYPE) 159 .add("Type", TYPE)
......
...@@ -22,8 +22,6 @@ import org.jboss.netty.buffer.ChannelBuffer; ...@@ -22,8 +22,6 @@ import org.jboss.netty.buffer.ChannelBuffer;
22 import org.onlab.packet.Ip4Address; 22 import org.onlab.packet.Ip4Address;
23 import org.onosproject.bgpio.exceptions.BgpParseException; 23 import org.onosproject.bgpio.exceptions.BgpParseException;
24 import org.onosproject.bgpio.util.Validation; 24 import org.onosproject.bgpio.util.Validation;
25 -import org.slf4j.Logger;
26 -import org.slf4j.LoggerFactory;
27 25
28 import com.google.common.base.MoreObjects; 26 import com.google.common.base.MoreObjects;
29 import com.google.common.base.Preconditions; 27 import com.google.common.base.Preconditions;
...@@ -32,7 +30,6 @@ import com.google.common.base.Preconditions; ...@@ -32,7 +30,6 @@ import com.google.common.base.Preconditions;
32 * Provides Implementation of IPv4AddressTlv. 30 * Provides Implementation of IPv4AddressTlv.
33 */ 31 */
34 public class IPv4AddressTlv implements BgpValueType { 32 public class IPv4AddressTlv implements BgpValueType {
35 - private static final Logger log = LoggerFactory.getLogger(IPv4AddressTlv.class);
36 private static final int LENGTH = 4; 33 private static final int LENGTH = 4;
37 34
38 private Ip4Address address; 35 private Ip4Address address;
...@@ -118,6 +115,14 @@ public class IPv4AddressTlv implements BgpValueType { ...@@ -118,6 +115,14 @@ public class IPv4AddressTlv implements BgpValueType {
118 } 115 }
119 116
120 @Override 117 @Override
118 + public int compareTo(Object o) {
119 + if (this.equals(o)) {
120 + return 0;
121 + }
122 + return ((Ip4Address) (this.address)).compareTo((Ip4Address) (((IPv4AddressTlv) o).address));
123 + }
124 +
125 + @Override
121 public String toString() { 126 public String toString() {
122 return MoreObjects.toStringHelper(getClass()) 127 return MoreObjects.toStringHelper(getClass())
123 .add("type", type) 128 .add("type", type)
......
...@@ -22,8 +22,6 @@ import org.jboss.netty.buffer.ChannelBuffer; ...@@ -22,8 +22,6 @@ import org.jboss.netty.buffer.ChannelBuffer;
22 import org.onlab.packet.Ip6Address; 22 import org.onlab.packet.Ip6Address;
23 import org.onosproject.bgpio.exceptions.BgpParseException; 23 import org.onosproject.bgpio.exceptions.BgpParseException;
24 import org.onosproject.bgpio.util.Validation; 24 import org.onosproject.bgpio.util.Validation;
25 -import org.slf4j.Logger;
26 -import org.slf4j.LoggerFactory;
27 25
28 import com.google.common.base.MoreObjects; 26 import com.google.common.base.MoreObjects;
29 import com.google.common.base.Preconditions; 27 import com.google.common.base.Preconditions;
...@@ -32,7 +30,6 @@ import com.google.common.base.Preconditions; ...@@ -32,7 +30,6 @@ import com.google.common.base.Preconditions;
32 * Provides Implementation of IPv6AddressTlv. 30 * Provides Implementation of IPv6AddressTlv.
33 */ 31 */
34 public class IPv6AddressTlv implements BgpValueType { 32 public class IPv6AddressTlv implements BgpValueType {
35 - private static final Logger log = LoggerFactory.getLogger(IPv6AddressTlv.class);
36 private static final int LENGTH = 16; 33 private static final int LENGTH = 16;
37 34
38 private final Ip6Address address; 35 private final Ip6Address address;
...@@ -118,6 +115,14 @@ public class IPv6AddressTlv implements BgpValueType { ...@@ -118,6 +115,14 @@ public class IPv6AddressTlv implements BgpValueType {
118 } 115 }
119 116
120 @Override 117 @Override
118 + public int compareTo(Object o) {
119 + if (this.equals(o)) {
120 + return 0;
121 + }
122 + return ((Ip6Address) (this.address)).compareTo((Ip6Address) (((IPv6AddressTlv) o).address));
123 + }
124 +
125 + @Override
121 public String toString() { 126 public String toString() {
122 return MoreObjects.toStringHelper(getClass()) 127 return MoreObjects.toStringHelper(getClass())
123 .add("type", type) 128 .add("type", type)
......
...@@ -15,12 +15,11 @@ ...@@ -15,12 +15,11 @@
15 */ 15 */
16 package org.onosproject.bgpio.types; 16 package org.onosproject.bgpio.types;
17 17
18 +import java.nio.ByteBuffer;
18 import java.util.Arrays; 19 import java.util.Arrays;
19 20
20 import org.jboss.netty.buffer.ChannelBuffer; 21 import org.jboss.netty.buffer.ChannelBuffer;
21 import org.onosproject.bgpio.protocol.IGPRouterID; 22 import org.onosproject.bgpio.protocol.IGPRouterID;
22 -import org.slf4j.Logger;
23 -import org.slf4j.LoggerFactory;
24 23
25 import com.google.common.base.MoreObjects; 24 import com.google.common.base.MoreObjects;
26 25
...@@ -28,8 +27,6 @@ import com.google.common.base.MoreObjects; ...@@ -28,8 +27,6 @@ import com.google.common.base.MoreObjects;
28 * Provides Implementation of IsIsNonPseudonode Tlv. 27 * Provides Implementation of IsIsNonPseudonode Tlv.
29 */ 28 */
30 public class IsIsNonPseudonode implements IGPRouterID, BgpValueType { 29 public class IsIsNonPseudonode implements IGPRouterID, BgpValueType {
31 - private static final Logger log = LoggerFactory.getLogger(IsIsNonPseudonode.class);
32 -
33 public static final short TYPE = 515; 30 public static final short TYPE = 515;
34 public static final short LENGTH = 6; 31 public static final short LENGTH = 6;
35 32
...@@ -107,6 +104,16 @@ public class IsIsNonPseudonode implements IGPRouterID, BgpValueType { ...@@ -107,6 +104,16 @@ public class IsIsNonPseudonode implements IGPRouterID, BgpValueType {
107 } 104 }
108 105
109 @Override 106 @Override
107 + public int compareTo(Object o) {
108 + if (this.equals(o)) {
109 + return 0;
110 + }
111 + ByteBuffer value1 = ByteBuffer.wrap(this.isoNodeID);
112 + ByteBuffer value2 = ByteBuffer.wrap(((IsIsNonPseudonode) o).isoNodeID);
113 + return value1.compareTo(value2);
114 + }
115 +
116 + @Override
110 public String toString() { 117 public String toString() {
111 return MoreObjects.toStringHelper(getClass()) 118 return MoreObjects.toStringHelper(getClass())
112 .add("Type", TYPE) 119 .add("Type", TYPE)
......
...@@ -15,13 +15,12 @@ ...@@ -15,13 +15,12 @@
15 */ 15 */
16 package org.onosproject.bgpio.types; 16 package org.onosproject.bgpio.types;
17 17
18 +import java.nio.ByteBuffer;
18 import java.util.Arrays; 19 import java.util.Arrays;
19 import java.util.Objects; 20 import java.util.Objects;
20 21
21 import org.jboss.netty.buffer.ChannelBuffer; 22 import org.jboss.netty.buffer.ChannelBuffer;
22 import org.onosproject.bgpio.protocol.IGPRouterID; 23 import org.onosproject.bgpio.protocol.IGPRouterID;
23 -import org.slf4j.Logger;
24 -import org.slf4j.LoggerFactory;
25 24
26 import com.google.common.base.MoreObjects; 25 import com.google.common.base.MoreObjects;
27 26
...@@ -29,8 +28,6 @@ import com.google.common.base.MoreObjects; ...@@ -29,8 +28,6 @@ import com.google.common.base.MoreObjects;
29 * Provides implementation of IsIsPseudonode Tlv. 28 * Provides implementation of IsIsPseudonode Tlv.
30 */ 29 */
31 public class IsIsPseudonode implements IGPRouterID, BgpValueType { 30 public class IsIsPseudonode implements IGPRouterID, BgpValueType {
32 - private static final Logger log = LoggerFactory.getLogger(IsIsPseudonode.class);
33 -
34 public static final short TYPE = 515; 31 public static final short TYPE = 515;
35 public static final short LENGTH = 7; 32 public static final short LENGTH = 7;
36 33
...@@ -125,6 +122,19 @@ public class IsIsPseudonode implements IGPRouterID, BgpValueType { ...@@ -125,6 +122,19 @@ public class IsIsPseudonode implements IGPRouterID, BgpValueType {
125 } 122 }
126 123
127 @Override 124 @Override
125 + public int compareTo(Object o) {
126 + if (this.equals(o)) {
127 + return 0;
128 + }
129 + ByteBuffer value1 = ByteBuffer.wrap(this.isoNodeID);
130 + ByteBuffer value2 = ByteBuffer.wrap(((IsIsPseudonode) o).isoNodeID);
131 + if (value1.compareTo(value2) != 0) {
132 + return value1.compareTo(value2);
133 + }
134 + return ((Byte) (this.psnIdentifier)).compareTo((Byte) (((IsIsPseudonode) o).psnIdentifier));
135 + }
136 +
137 + @Override
128 public String toString() { 138 public String toString() {
129 return MoreObjects.toStringHelper(getClass()) 139 return MoreObjects.toStringHelper(getClass())
130 .add("Type", TYPE) 140 .add("Type", TYPE)
......
...@@ -18,8 +18,6 @@ package org.onosproject.bgpio.types; ...@@ -18,8 +18,6 @@ package org.onosproject.bgpio.types;
18 import java.util.Objects; 18 import java.util.Objects;
19 19
20 import org.jboss.netty.buffer.ChannelBuffer; 20 import org.jboss.netty.buffer.ChannelBuffer;
21 -import org.slf4j.Logger;
22 -import org.slf4j.LoggerFactory;
23 21
24 import com.google.common.base.MoreObjects; 22 import com.google.common.base.MoreObjects;
25 23
...@@ -27,7 +25,6 @@ import com.google.common.base.MoreObjects; ...@@ -27,7 +25,6 @@ import com.google.common.base.MoreObjects;
27 * Provides Implementation of Link Local/Remote IdentifiersTlv. 25 * Provides Implementation of Link Local/Remote IdentifiersTlv.
28 */ 26 */
29 public class LinkLocalRemoteIdentifiersTlv implements BgpValueType { 27 public class LinkLocalRemoteIdentifiersTlv implements BgpValueType {
30 - private static final Logger log = LoggerFactory.getLogger(LinkLocalRemoteIdentifiersTlv.class);
31 public static final short TYPE = 258; 28 public static final short TYPE = 258;
32 private static final int LENGTH = 8; 29 private static final int LENGTH = 8;
33 30
...@@ -120,6 +117,20 @@ public class LinkLocalRemoteIdentifiersTlv implements BgpValueType { ...@@ -120,6 +117,20 @@ public class LinkLocalRemoteIdentifiersTlv implements BgpValueType {
120 } 117 }
121 118
122 @Override 119 @Override
120 + public int compareTo(Object o) {
121 + if (this.equals(o)) {
122 + return 0;
123 + }
124 + int result = ((Integer) (this.linkLocalIdentifer))
125 + .compareTo((Integer) (((LinkLocalRemoteIdentifiersTlv) o).linkLocalIdentifer));
126 + if (result != 0) {
127 + return result;
128 + }
129 + return ((Integer) (this.linkRemoteIdentifer))
130 + .compareTo((Integer) (((LinkLocalRemoteIdentifiersTlv) o).linkRemoteIdentifer));
131 + }
132 +
133 + @Override
123 public String toString() { 134 public String toString() {
124 return MoreObjects.toStringHelper(getClass()) 135 return MoreObjects.toStringHelper(getClass())
125 .add("TYPE", TYPE) 136 .add("TYPE", TYPE)
......
...@@ -305,4 +305,10 @@ public class LinkStateAttributes implements BgpValueType { ...@@ -305,4 +305,10 @@ public class LinkStateAttributes implements BgpValueType {
305 return MoreObjects.toStringHelper(getClass()).omitNullValues() 305 return MoreObjects.toStringHelper(getClass()).omitNullValues()
306 .add("linkStateAttribList", linkStateAttribList).toString(); 306 .add("linkStateAttribList", linkStateAttribList).toString();
307 } 307 }
308 +
309 + @Override
310 + public int compareTo(Object o) {
311 + // TODO Auto-generated method stub
312 + return 0;
313 + }
308 } 314 }
......
...@@ -112,4 +112,10 @@ public class LocalPref implements BgpValueType { ...@@ -112,4 +112,10 @@ public class LocalPref implements BgpValueType {
112 //Not to implement as of now 112 //Not to implement as of now
113 return 0; 113 return 0;
114 } 114 }
115 +
116 + @Override
117 + public int compareTo(Object o) {
118 + // TODO Auto-generated method stub
119 + return 0;
120 + }
115 } 121 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -112,4 +112,10 @@ public class Med implements BgpValueType { ...@@ -112,4 +112,10 @@ public class Med implements BgpValueType {
112 //Not to implement as of now 112 //Not to implement as of now
113 return 0; 113 return 0;
114 } 114 }
115 +
116 + @Override
117 + public int compareTo(Object o) {
118 + // TODO Auto-generated method stub
119 + return 0;
120 + }
115 } 121 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -216,4 +216,10 @@ public class MpReachNlri implements BgpValueType { ...@@ -216,4 +216,10 @@ public class MpReachNlri implements BgpValueType {
216 .add("length", length) 216 .add("length", length)
217 .toString(); 217 .toString();
218 } 218 }
219 +
220 + @Override
221 + public int compareTo(Object o) {
222 + // TODO Auto-generated method stub
223 + return 0;
224 + }
219 } 225 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -193,6 +193,12 @@ public class MpUnReachNlri implements BgpValueType { ...@@ -193,6 +193,12 @@ public class MpUnReachNlri implements BgpValueType {
193 } 193 }
194 194
195 @Override 195 @Override
196 + public int compareTo(Object o) {
197 + // TODO Auto-generated method stub
198 + return 0;
199 + }
200 +
201 + @Override
196 public String toString() { 202 public String toString() {
197 return MoreObjects.toStringHelper(getClass()) 203 return MoreObjects.toStringHelper(getClass())
198 .add("mpReachNlri", mpUnReachNlri) 204 .add("mpReachNlri", mpUnReachNlri)
......
...@@ -157,4 +157,10 @@ public class MultiProtocolExtnCapabilityTlv implements BgpValueType { ...@@ -157,4 +157,10 @@ public class MultiProtocolExtnCapabilityTlv implements BgpValueType {
157 .add("Reserved", res) 157 .add("Reserved", res)
158 .add("SAFI", safi).toString(); 158 .add("SAFI", safi).toString();
159 } 159 }
160 +
161 + @Override
162 + public int compareTo(Object o) {
163 + // TODO Auto-generated method stub
164 + return 0;
165 + }
160 } 166 }
......
...@@ -130,4 +130,10 @@ public class NextHop implements BgpValueType { ...@@ -130,4 +130,10 @@ public class NextHop implements BgpValueType {
130 .add("nextHop", nextHop) 130 .add("nextHop", nextHop)
131 .toString(); 131 .toString();
132 } 132 }
133 +
134 + @Override
135 + public int compareTo(Object o) {
136 + // TODO Auto-generated method stub
137 + return 0;
138 + }
133 } 139 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -20,8 +20,6 @@ import java.util.Objects; ...@@ -20,8 +20,6 @@ import java.util.Objects;
20 20
21 import org.jboss.netty.buffer.ChannelBuffer; 21 import org.jboss.netty.buffer.ChannelBuffer;
22 import org.onosproject.bgpio.protocol.IGPRouterID; 22 import org.onosproject.bgpio.protocol.IGPRouterID;
23 -import org.slf4j.Logger;
24 -import org.slf4j.LoggerFactory;
25 23
26 import com.google.common.base.MoreObjects; 24 import com.google.common.base.MoreObjects;
27 25
...@@ -29,9 +27,6 @@ import com.google.common.base.MoreObjects; ...@@ -29,9 +27,6 @@ import com.google.common.base.MoreObjects;
29 * Provides implementation of OSPFNonPseudonode Tlv. 27 * Provides implementation of OSPFNonPseudonode Tlv.
30 */ 28 */
31 public class OSPFNonPseudonode implements IGPRouterID, BgpValueType { 29 public class OSPFNonPseudonode implements IGPRouterID, BgpValueType {
32 -
33 - protected static final Logger log = LoggerFactory.getLogger(OSPFNonPseudonode.class);
34 -
35 public static final short TYPE = 515; 30 public static final short TYPE = 515;
36 public static final short LENGTH = 4; 31 public static final short LENGTH = 4;
37 32
...@@ -108,6 +103,14 @@ public class OSPFNonPseudonode implements IGPRouterID, BgpValueType { ...@@ -108,6 +103,14 @@ public class OSPFNonPseudonode implements IGPRouterID, BgpValueType {
108 } 103 }
109 104
110 @Override 105 @Override
106 + public int compareTo(Object o) {
107 + if (this.equals(o)) {
108 + return 0;
109 + }
110 + return ((Integer) (this.routerID)).compareTo((Integer) (((OSPFNonPseudonode) o).routerID));
111 + }
112 +
113 + @Override
111 public String toString() { 114 public String toString() {
112 return MoreObjects.toStringHelper(getClass()) 115 return MoreObjects.toStringHelper(getClass())
113 .add("Type", TYPE) 116 .add("Type", TYPE)
......
...@@ -20,8 +20,6 @@ import java.util.Objects; ...@@ -20,8 +20,6 @@ import java.util.Objects;
20 import org.jboss.netty.buffer.ChannelBuffer; 20 import org.jboss.netty.buffer.ChannelBuffer;
21 import org.onlab.packet.Ip4Address; 21 import org.onlab.packet.Ip4Address;
22 import org.onosproject.bgpio.protocol.IGPRouterID; 22 import org.onosproject.bgpio.protocol.IGPRouterID;
23 -import org.slf4j.Logger;
24 -import org.slf4j.LoggerFactory;
25 23
26 import com.google.common.base.MoreObjects; 24 import com.google.common.base.MoreObjects;
27 25
...@@ -29,9 +27,6 @@ import com.google.common.base.MoreObjects; ...@@ -29,9 +27,6 @@ import com.google.common.base.MoreObjects;
29 * Provides implementation of OSPFPseudonode Tlv. 27 * Provides implementation of OSPFPseudonode Tlv.
30 */ 28 */
31 public class OSPFPseudonode implements IGPRouterID, BgpValueType { 29 public class OSPFPseudonode implements IGPRouterID, BgpValueType {
32 -
33 - protected static final Logger log = LoggerFactory.getLogger(OSPFPseudonode.class);
34 -
35 public static final short TYPE = 515; 30 public static final short TYPE = 515;
36 public static final short LENGTH = 8; 31 public static final short LENGTH = 8;
37 32
...@@ -114,6 +109,18 @@ public class OSPFPseudonode implements IGPRouterID, BgpValueType { ...@@ -114,6 +109,18 @@ public class OSPFPseudonode implements IGPRouterID, BgpValueType {
114 } 109 }
115 110
116 @Override 111 @Override
112 + public int compareTo(Object o) {
113 + if (this.equals(o)) {
114 + return 0;
115 + }
116 + int result = ((Integer) (this.routerID)).compareTo((Integer) (((OSPFPseudonode) o).routerID));
117 + if (result != 0) {
118 + return this.drInterface.compareTo(((OSPFPseudonode) o).drInterface);
119 + }
120 + return result;
121 + }
122 +
123 + @Override
117 public String toString() { 124 public String toString() {
118 return MoreObjects.toStringHelper(getClass()) 125 return MoreObjects.toStringHelper(getClass())
119 .add("Type", TYPE) 126 .add("Type", TYPE)
......
...@@ -19,8 +19,6 @@ import java.util.Objects; ...@@ -19,8 +19,6 @@ import java.util.Objects;
19 19
20 import org.jboss.netty.buffer.ChannelBuffer; 20 import org.jboss.netty.buffer.ChannelBuffer;
21 import org.onosproject.bgpio.exceptions.BgpParseException; 21 import org.onosproject.bgpio.exceptions.BgpParseException;
22 -import org.slf4j.Logger;
23 -import org.slf4j.LoggerFactory;
24 22
25 import com.google.common.base.MoreObjects; 23 import com.google.common.base.MoreObjects;
26 24
...@@ -41,8 +39,6 @@ public class OSPFRouteTypeTlv implements BgpValueType { ...@@ -41,8 +39,6 @@ public class OSPFRouteTypeTlv implements BgpValueType {
41 Figure : OSPF Route Type TLV Format 39 Figure : OSPF Route Type TLV Format
42 */ 40 */
43 41
44 - protected static final Logger log = LoggerFactory.getLogger(OSPFRouteTypeTlv.class);
45 -
46 public static final short TYPE = 264; 42 public static final short TYPE = 264;
47 public static final short LENGTH = 1; 43 public static final short LENGTH = 1;
48 public static final int INTRA_AREA_TYPE = 1; 44 public static final int INTRA_AREA_TYPE = 1;
...@@ -51,15 +47,16 @@ public class OSPFRouteTypeTlv implements BgpValueType { ...@@ -51,15 +47,16 @@ public class OSPFRouteTypeTlv implements BgpValueType {
51 public static final short EXTERNAL_TYPE_2 = 4; 47 public static final short EXTERNAL_TYPE_2 = 4;
52 public static final short NSSA_TYPE_1 = 5; 48 public static final short NSSA_TYPE_1 = 5;
53 public static final short NSSA_TYPE_2 = 6; 49 public static final short NSSA_TYPE_2 = 6;
50 +
54 private final byte routeType; 51 private final byte routeType;
55 52
56 /** 53 /**
57 * Enum for Route Type. 54 * Enum for Route Type.
58 */ 55 */
59 - public enum ROUTETYPE { 56 + public enum RouteType {
60 Intra_Area(1), Inter_Area(2), External_1(3), External_2(4), NSSA_1(5), NSSA_2(6); 57 Intra_Area(1), Inter_Area(2), External_1(3), External_2(4), NSSA_1(5), NSSA_2(6);
61 int value; 58 int value;
62 - ROUTETYPE(int val) { 59 + RouteType(int val) {
63 value = val; 60 value = val;
64 } 61 }
65 public byte getType() { 62 public byte getType() {
...@@ -92,20 +89,20 @@ public class OSPFRouteTypeTlv implements BgpValueType { ...@@ -92,20 +89,20 @@ public class OSPFRouteTypeTlv implements BgpValueType {
92 * @return RouteType 89 * @return RouteType
93 * @throws BgpParseException if routeType is not matched 90 * @throws BgpParseException if routeType is not matched
94 */ 91 */
95 - public ROUTETYPE getValue() throws BgpParseException { 92 + public RouteType getValue() throws BgpParseException {
96 switch (routeType) { 93 switch (routeType) {
97 case INTRA_AREA_TYPE: 94 case INTRA_AREA_TYPE:
98 - return ROUTETYPE.Intra_Area; 95 + return RouteType.Intra_Area;
99 case INTER_AREA_TYPE: 96 case INTER_AREA_TYPE:
100 - return ROUTETYPE.Inter_Area; 97 + return RouteType.Inter_Area;
101 case EXTERNAL_TYPE_1: 98 case EXTERNAL_TYPE_1:
102 - return ROUTETYPE.External_1; 99 + return RouteType.External_1;
103 case EXTERNAL_TYPE_2: 100 case EXTERNAL_TYPE_2:
104 - return ROUTETYPE.External_2; 101 + return RouteType.External_2;
105 case NSSA_TYPE_1: 102 case NSSA_TYPE_1:
106 - return ROUTETYPE.NSSA_1; 103 + return RouteType.NSSA_1;
107 case NSSA_TYPE_2: 104 case NSSA_TYPE_2:
108 - return ROUTETYPE.NSSA_2; 105 + return RouteType.NSSA_2;
109 default: 106 default:
110 throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, (byte) 0, null); 107 throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, (byte) 0, null);
111 } 108 }
...@@ -153,6 +150,14 @@ public class OSPFRouteTypeTlv implements BgpValueType { ...@@ -153,6 +150,14 @@ public class OSPFRouteTypeTlv implements BgpValueType {
153 } 150 }
154 151
155 @Override 152 @Override
153 + public int compareTo(Object o) {
154 + if (this.equals(o)) {
155 + return 0;
156 + }
157 + return ((Byte) (this.routeType)).compareTo((Byte) (((OSPFRouteTypeTlv) o).routeType));
158 + }
159 +
160 + @Override
156 public String toString() { 161 public String toString() {
157 return MoreObjects.toStringHelper(getClass()) 162 return MoreObjects.toStringHelper(getClass())
158 .add("Type", TYPE) 163 .add("Type", TYPE)
......
...@@ -159,4 +159,10 @@ public class Origin implements BgpValueType { ...@@ -159,4 +159,10 @@ public class Origin implements BgpValueType {
159 .add("origin", origin) 159 .add("origin", origin)
160 .toString(); 160 .toString();
161 } 161 }
162 +
163 + @Override
164 + public int compareTo(Object o) {
165 + // TODO Auto-generated method stub
166 + return 0;
167 + }
162 } 168 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -18,10 +18,12 @@ package org.onosproject.bgpio.types; ...@@ -18,10 +18,12 @@ package org.onosproject.bgpio.types;
18 18
19 import org.jboss.netty.buffer.ChannelBuffer; 19 import org.jboss.netty.buffer.ChannelBuffer;
20 20
21 +import com.google.common.base.MoreObjects;
22 +
21 /** 23 /**
22 * Implementation of RouteDistinguisher. 24 * Implementation of RouteDistinguisher.
23 */ 25 */
24 -public class RouteDistinguisher { 26 +public class RouteDistinguisher implements Comparable<RouteDistinguisher> {
25 27
26 private long routeDistinguisher; 28 private long routeDistinguisher;
27 29
...@@ -59,4 +61,19 @@ public class RouteDistinguisher { ...@@ -59,4 +61,19 @@ public class RouteDistinguisher {
59 public long getRouteDistinguisher() { 61 public long getRouteDistinguisher() {
60 return this.routeDistinguisher; 62 return this.routeDistinguisher;
61 } 63 }
64 +
65 + @Override
66 + public int compareTo(RouteDistinguisher rd) {
67 + if (this.equals(rd)) {
68 + return 0;
69 + }
70 + return ((Long) (this.getRouteDistinguisher())).compareTo((Long) (rd.getRouteDistinguisher()));
71 + }
72 +
73 + @Override
74 + public String toString() {
75 + return MoreObjects.toStringHelper(getClass())
76 + .add("routeDistinguisher", routeDistinguisher)
77 + .toString();
78 + }
62 } 79 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -190,4 +190,10 @@ public final class BgpAttrNodeFlagBitTlv implements BgpValueType { ...@@ -190,4 +190,10 @@ public final class BgpAttrNodeFlagBitTlv implements BgpValueType {
190 .add("bExternalBit", bExternalBit).add("bAbrBit", bAbrBit) 190 .add("bExternalBit", bExternalBit).add("bAbrBit", bAbrBit)
191 .toString(); 191 .toString();
192 } 192 }
193 +
194 + @Override
195 + public int compareTo(Object o) {
196 + // TODO Auto-generated method stub
197 + return 0;
198 + }
193 } 199 }
......
...@@ -127,4 +127,10 @@ public class BgpAttrNodeIsIsAreaId implements BgpValueType { ...@@ -127,4 +127,10 @@ public class BgpAttrNodeIsIsAreaId implements BgpValueType {
127 return MoreObjects.toStringHelper(getClass()).omitNullValues() 127 return MoreObjects.toStringHelper(getClass()).omitNullValues()
128 .add("isisAreaId", isisAreaId).toString(); 128 .add("isisAreaId", isisAreaId).toString();
129 } 129 }
130 +
131 + @Override
132 + public int compareTo(Object o) {
133 + // TODO Auto-generated method stub
134 + return 0;
135 + }
130 } 136 }
......
...@@ -17,6 +17,7 @@ package org.onosproject.bgpio.types.attr; ...@@ -17,6 +17,7 @@ package org.onosproject.bgpio.types.attr;
17 17
18 import java.util.ArrayList; 18 import java.util.ArrayList;
19 import java.util.List; 19 import java.util.List;
20 +import java.util.ListIterator;
20 import java.util.Objects; 21 import java.util.Objects;
21 22
22 import org.jboss.netty.buffer.ChannelBuffer; 23 import org.jboss.netty.buffer.ChannelBuffer;
...@@ -134,4 +135,30 @@ public class BgpAttrNodeMultiTopologyId implements BgpValueType { ...@@ -134,4 +135,30 @@ public class BgpAttrNodeMultiTopologyId implements BgpValueType {
134 .add("multiTopologyId", multiTopologyId) 135 .add("multiTopologyId", multiTopologyId)
135 .toString(); 136 .toString();
136 } 137 }
138 +
139 + @Override
140 + public int compareTo(Object o) {
141 + if (this.equals(o)) {
142 + return 0;
143 + }
144 + int countOtherSubTlv = ((BgpAttrNodeMultiTopologyId) o).multiTopologyId.size();
145 + int countObjSubTlv = multiTopologyId.size();
146 + if (countOtherSubTlv != countObjSubTlv) {
147 + if (countOtherSubTlv > countObjSubTlv) {
148 + return 1;
149 + } else {
150 + return -1;
151 + }
152 + }
153 + ListIterator<Short> listIterator = multiTopologyId.listIterator();
154 + ListIterator<Short> listIteratorOther = ((BgpAttrNodeMultiTopologyId) o).multiTopologyId.listIterator();
155 + while (listIterator.hasNext()) {
156 + short id = listIterator.next();
157 + short id1 = listIteratorOther.next();
158 + if (((Short) id).compareTo((Short) id1) != 0) {
159 + return ((Short) id).compareTo((Short) id1);
160 + }
161 + }
162 + return 0;
163 + }
137 } 164 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -126,4 +126,10 @@ public class BgpAttrNodeName implements BgpValueType { ...@@ -126,4 +126,10 @@ public class BgpAttrNodeName implements BgpValueType {
126 return MoreObjects.toStringHelper(getClass()).omitNullValues() 126 return MoreObjects.toStringHelper(getClass()).omitNullValues()
127 .add("nodeName", nodeName).toString(); 127 .add("nodeName", nodeName).toString();
128 } 128 }
129 +
130 + @Override
131 + public int compareTo(Object o) {
132 + // TODO Auto-generated method stub
133 + return 0;
134 + }
129 } 135 }
......
...@@ -130,4 +130,9 @@ public class BgpAttrOpaqueNode implements BgpValueType { ...@@ -130,4 +130,9 @@ public class BgpAttrOpaqueNode implements BgpValueType {
130 .add("opaqueNodeAttribute", opaqueNodeAttribute).toString(); 130 .add("opaqueNodeAttribute", opaqueNodeAttribute).toString();
131 } 131 }
132 132
133 + @Override
134 + public int compareTo(Object o) {
135 + // TODO Auto-generated method stub
136 + return 0;
137 + }
133 } 138 }
......
...@@ -131,4 +131,10 @@ public final class BgpAttrRouterIdV4 implements BgpValueType { ...@@ -131,4 +131,10 @@ public final class BgpAttrRouterIdV4 implements BgpValueType {
131 return MoreObjects.toStringHelper(getClass()).omitNullValues() 131 return MoreObjects.toStringHelper(getClass()).omitNullValues()
132 .add("ip4RouterId", ip4RouterId).toString(); 132 .add("ip4RouterId", ip4RouterId).toString();
133 } 133 }
134 +
135 + @Override
136 + public int compareTo(Object o) {
137 + // TODO Auto-generated method stub
138 + return 0;
139 + }
134 } 140 }
......
...@@ -134,4 +134,10 @@ public final class BgpAttrRouterIdV6 implements BgpValueType { ...@@ -134,4 +134,10 @@ public final class BgpAttrRouterIdV6 implements BgpValueType {
134 return MoreObjects.toStringHelper(getClass()).omitNullValues() 134 return MoreObjects.toStringHelper(getClass()).omitNullValues()
135 .add("ip6RouterId", ip6RouterId).toString(); 135 .add("ip6RouterId", ip6RouterId).toString();
136 } 136 }
137 +
138 + @Override
139 + public int compareTo(Object o) {
140 + // TODO Auto-generated method stub
141 + return 0;
142 + }
137 } 143 }
......
...@@ -169,4 +169,10 @@ public class BgpLinkAttrIgpMetric implements BgpValueType { ...@@ -169,4 +169,10 @@ public class BgpLinkAttrIgpMetric implements BgpValueType {
169 .add("igpMetric", igpMetric).add("igpMetricLen", igpMetricLen) 169 .add("igpMetric", igpMetric).add("igpMetricLen", igpMetricLen)
170 .toString(); 170 .toString();
171 } 171 }
172 +
173 + @Override
174 + public int compareTo(Object o) {
175 + // TODO Auto-generated method stub
176 + return 0;
177 + }
172 } 178 }
......
...@@ -127,4 +127,10 @@ public final class BgpLinkAttrIsIsAdminstGrp implements BgpValueType { ...@@ -127,4 +127,10 @@ public final class BgpLinkAttrIsIsAdminstGrp implements BgpValueType {
127 return MoreObjects.toStringHelper(getClass()) 127 return MoreObjects.toStringHelper(getClass())
128 .add("isisAdminGrp", isisAdminGrp).toString(); 128 .add("isisAdminGrp", isisAdminGrp).toString();
129 } 129 }
130 +
131 + @Override
132 + public int compareTo(Object o) {
133 + // TODO Auto-generated method stub
134 + return 0;
135 + }
130 } 136 }
......
...@@ -147,4 +147,10 @@ public final class BgpLinkAttrMaxLinkBandwidth implements BgpValueType { ...@@ -147,4 +147,10 @@ public final class BgpLinkAttrMaxLinkBandwidth implements BgpValueType {
147 return MoreObjects.toStringHelper(getClass()) 147 return MoreObjects.toStringHelper(getClass())
148 .add("maxBandwidth", maxBandwidth).toString(); 148 .add("maxBandwidth", maxBandwidth).toString();
149 } 149 }
150 +
151 + @Override
152 + public int compareTo(Object o) {
153 + // TODO Auto-generated method stub
154 + return 0;
155 + }
150 } 156 }
......
...@@ -149,4 +149,10 @@ public class BgpLinkAttrMplsProtocolMask implements BgpValueType { ...@@ -149,4 +149,10 @@ public class BgpLinkAttrMplsProtocolMask implements BgpValueType {
149 return MoreObjects.toStringHelper(getClass()) 149 return MoreObjects.toStringHelper(getClass())
150 .add("bLdp", bLdp).add("bRsvpTe", bRsvpTe).toString(); 150 .add("bLdp", bLdp).add("bRsvpTe", bRsvpTe).toString();
151 } 151 }
152 +
153 + @Override
154 + public int compareTo(Object o) {
155 + // TODO Auto-generated method stub
156 + return 0;
157 + }
152 } 158 }
......
...@@ -125,4 +125,10 @@ public class BgpLinkAttrName implements BgpValueType { ...@@ -125,4 +125,10 @@ public class BgpLinkAttrName implements BgpValueType {
125 return MoreObjects.toStringHelper(getClass()).omitNullValues() 125 return MoreObjects.toStringHelper(getClass()).omitNullValues()
126 .add("linkName", linkName).toString(); 126 .add("linkName", linkName).toString();
127 } 127 }
128 +
129 + @Override
130 + public int compareTo(Object o) {
131 + // TODO Auto-generated method stub
132 + return 0;
133 + }
128 } 134 }
......
...@@ -130,4 +130,10 @@ public final class BgpLinkAttrOpaqLnkAttrib implements BgpValueType { ...@@ -130,4 +130,10 @@ public final class BgpLinkAttrOpaqLnkAttrib implements BgpValueType {
130 return MoreObjects.toStringHelper(getClass()).omitNullValues() 130 return MoreObjects.toStringHelper(getClass()).omitNullValues()
131 .add("opaqueLinkAttribute", opaqueLinkAttribute).toString(); 131 .add("opaqueLinkAttribute", opaqueLinkAttribute).toString();
132 } 132 }
133 +
134 + @Override
135 + public int compareTo(Object o) {
136 + // TODO Auto-generated method stub
137 + return 0;
138 + }
133 } 139 }
......
...@@ -237,4 +237,10 @@ public final class BgpLinkAttrProtectionType implements BgpValueType { ...@@ -237,4 +237,10 @@ public final class BgpLinkAttrProtectionType implements BgpValueType {
237 .add("bDedOnePlusOne", bDedOnePlusOne) 237 .add("bDedOnePlusOne", bDedOnePlusOne)
238 .add("bEnhanced", bEnhanced).toString(); 238 .add("bEnhanced", bEnhanced).toString();
239 } 239 }
240 +
241 + @Override
242 + public int compareTo(Object o) {
243 + // TODO Auto-generated method stub
244 + return 0;
245 + }
240 } 246 }
......
...@@ -127,4 +127,10 @@ public class BgpLinkAttrSrlg implements BgpValueType { ...@@ -127,4 +127,10 @@ public class BgpLinkAttrSrlg implements BgpValueType {
127 public String toString() { 127 public String toString() {
128 return MoreObjects.toStringHelper(getClass()).omitNullValues().add("sRlg", sRlg).toString(); 128 return MoreObjects.toStringHelper(getClass()).omitNullValues().add("sRlg", sRlg).toString();
129 } 129 }
130 +
131 + @Override
132 + public int compareTo(Object o) {
133 + // TODO Auto-generated method stub
134 + return 0;
135 + }
130 } 136 }
......
...@@ -129,4 +129,10 @@ public class BgpLinkAttrTeDefaultMetric implements BgpValueType { ...@@ -129,4 +129,10 @@ public class BgpLinkAttrTeDefaultMetric implements BgpValueType {
129 return MoreObjects.toStringHelper(getClass()) 129 return MoreObjects.toStringHelper(getClass())
130 .add("linkTEMetric", linkTeMetric).toString(); 130 .add("linkTEMetric", linkTeMetric).toString();
131 } 131 }
132 +
133 + @Override
134 + public int compareTo(Object o) {
135 + // TODO Auto-generated method stub
136 + return 0;
137 + }
132 } 138 }
......
...@@ -154,4 +154,10 @@ public class BgpLinkAttrUnRsrvdLinkBandwidth implements BgpValueType { ...@@ -154,4 +154,10 @@ public class BgpLinkAttrUnRsrvdLinkBandwidth implements BgpValueType {
154 return MoreObjects.toStringHelper(getClass()).omitNullValues() 154 return MoreObjects.toStringHelper(getClass()).omitNullValues()
155 .add("maxUnResBandwidth", maxUnResBandwidth).toString(); 155 .add("maxUnResBandwidth", maxUnResBandwidth).toString();
156 } 156 }
157 +
158 + @Override
159 + public int compareTo(Object o) {
160 + // TODO Auto-generated method stub
161 + return 0;
162 + }
157 } 163 }
......
...@@ -136,4 +136,10 @@ public class BgpPrefixAttrExtRouteTag implements BgpValueType { ...@@ -136,4 +136,10 @@ public class BgpPrefixAttrExtRouteTag implements BgpValueType {
136 return MoreObjects.toStringHelper(getClass()).omitNullValues() 136 return MoreObjects.toStringHelper(getClass()).omitNullValues()
137 .add("pfxExtRouteTag", pfxExtRouteTag).toString(); 137 .add("pfxExtRouteTag", pfxExtRouteTag).toString();
138 } 138 }
139 +
140 + @Override
141 + public int compareTo(Object o) {
142 + // TODO Auto-generated method stub
143 + return 0;
144 + }
139 } 145 }
......
...@@ -195,4 +195,10 @@ public final class BgpPrefixAttrIgpFlags implements BgpValueType { ...@@ -195,4 +195,10 @@ public final class BgpPrefixAttrIgpFlags implements BgpValueType {
195 .add("bOspfLclAddrBit", bOspfLclAddrBit) 195 .add("bOspfLclAddrBit", bOspfLclAddrBit)
196 .add("bOspfNSSABit", bOspfNSSABit).toString(); 196 .add("bOspfNSSABit", bOspfNSSABit).toString();
197 } 197 }
198 +
199 + @Override
200 + public int compareTo(Object o) {
201 + // TODO Auto-generated method stub
202 + return 0;
203 + }
198 } 204 }
......
...@@ -128,4 +128,10 @@ public class BgpPrefixAttrMetric implements BgpValueType { ...@@ -128,4 +128,10 @@ public class BgpPrefixAttrMetric implements BgpValueType {
128 return MoreObjects.toStringHelper(getClass()) 128 return MoreObjects.toStringHelper(getClass())
129 .add("linkPfxMetric", linkPfxMetric).toString(); 129 .add("linkPfxMetric", linkPfxMetric).toString();
130 } 130 }
131 +
132 + @Override
133 + public int compareTo(Object o) {
134 + // TODO Auto-generated method stub
135 + return 0;
136 + }
131 } 137 }
......
...@@ -131,4 +131,9 @@ public final class BgpPrefixAttrOpaqueData implements BgpValueType { ...@@ -131,4 +131,9 @@ public final class BgpPrefixAttrOpaqueData implements BgpValueType {
131 .toString(); 131 .toString();
132 } 132 }
133 133
134 + @Override
135 + public int compareTo(Object o) {
136 + // TODO Auto-generated method stub
137 + return 0;
138 + }
134 } 139 }
......
...@@ -184,4 +184,10 @@ public class BgpPrefixAttrOspfFwdAddr implements BgpValueType { ...@@ -184,4 +184,10 @@ public class BgpPrefixAttrOspfFwdAddr implements BgpValueType {
184 .add("ip6RouterId", ip6RouterId).toString(); 184 .add("ip6RouterId", ip6RouterId).toString();
185 } 185 }
186 } 186 }
187 +
188 + @Override
189 + public int compareTo(Object o) {
190 + // TODO Auto-generated method stub
191 + return 0;
192 + }
187 } 193 }
......
...@@ -133,4 +133,10 @@ public class BgpPrefixAttrRouteTag implements BgpValueType { ...@@ -133,4 +133,10 @@ public class BgpPrefixAttrRouteTag implements BgpValueType {
133 return MoreObjects.toStringHelper(getClass()).omitNullValues() 133 return MoreObjects.toStringHelper(getClass()).omitNullValues()
134 .add("pfxRouteTag", pfxRouteTag).toString(); 134 .add("pfxRouteTag", pfxRouteTag).toString();
135 } 135 }
136 +
137 + @Override
138 + public int compareTo(Object o) {
139 + // TODO Auto-generated method stub
140 + return 0;
141 + }
136 } 142 }
......