2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.protocol.bgp.parser.impl;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertTrue;
14 import java.io.ByteArrayOutputStream;
15 import java.io.IOException;
16 import java.io.InputStream;
17 import java.net.UnknownHostException;
18 import java.util.ArrayList;
19 import java.util.Collections;
20 import java.util.List;
23 import org.junit.BeforeClass;
24 import org.junit.Test;
25 import org.opendaylight.protocol.bgp.concepts.ASPath;
26 import org.opendaylight.protocol.bgp.concepts.BGPAddressFamily;
27 import org.opendaylight.protocol.bgp.concepts.BGPAggregator;
28 import org.opendaylight.protocol.bgp.concepts.BGPObject;
29 import org.opendaylight.protocol.bgp.concepts.BGPOrigin;
30 import org.opendaylight.protocol.bgp.concepts.BGPSubsequentAddressFamily;
31 import org.opendaylight.protocol.bgp.concepts.BGPTableType;
32 import org.opendaylight.protocol.bgp.concepts.BaseBGPObjectState;
33 import org.opendaylight.protocol.bgp.concepts.Community;
34 import org.opendaylight.protocol.bgp.concepts.ExtendedCommunity;
35 import org.opendaylight.protocol.bgp.concepts.IPv4NextHop;
36 import org.opendaylight.protocol.bgp.concepts.IPv6NextHop;
37 import org.opendaylight.protocol.bgp.concepts.Inet4SpecificExtendedCommunity;
38 import org.opendaylight.protocol.bgp.linkstate.AreaIdentifier;
39 import org.opendaylight.protocol.bgp.linkstate.DomainIdentifier;
40 import org.opendaylight.protocol.bgp.linkstate.IPv4InterfaceIdentifier;
41 import org.opendaylight.protocol.bgp.linkstate.ISISAreaIdentifier;
42 import org.opendaylight.protocol.bgp.linkstate.LinkAnchor;
43 import org.opendaylight.protocol.bgp.linkstate.LinkIdentifier;
44 import org.opendaylight.protocol.bgp.linkstate.LinkProtectionType;
45 import org.opendaylight.protocol.bgp.linkstate.NetworkLinkState;
46 import org.opendaylight.protocol.bgp.linkstate.NetworkNodeState;
47 import org.opendaylight.protocol.bgp.linkstate.NetworkObjectState;
48 import org.opendaylight.protocol.bgp.linkstate.NetworkRouteState;
49 import org.opendaylight.protocol.bgp.linkstate.NodeIdentifier;
50 import org.opendaylight.protocol.bgp.linkstate.NodeIdentifierFactory;
51 import org.opendaylight.protocol.bgp.linkstate.OSPFInterfaceIdentifier;
52 import org.opendaylight.protocol.bgp.linkstate.OSPFRouterIdentifier;
53 import org.opendaylight.protocol.bgp.linkstate.OSPFv3LANIdentifier;
54 import org.opendaylight.protocol.bgp.linkstate.RouterIdentifier;
55 import org.opendaylight.protocol.bgp.linkstate.TopologyIdentifier;
56 import org.opendaylight.protocol.bgp.parser.BGPLink;
57 import org.opendaylight.protocol.bgp.parser.BGPNode;
58 import org.opendaylight.protocol.bgp.parser.BGPParameter;
59 import org.opendaylight.protocol.bgp.parser.BGPRoute;
60 import org.opendaylight.protocol.bgp.parser.BGPUpdateEvent;
61 import org.opendaylight.protocol.bgp.parser.BGPUpdateMessage;
62 import org.opendaylight.protocol.bgp.parser.BGPUpdateSynchronized;
63 import org.opendaylight.protocol.bgp.parser.impl.PathAttribute.TypeCode;
64 import org.opendaylight.protocol.bgp.parser.impl.message.BGPUpdateMessageParser;
65 import org.opendaylight.protocol.bgp.parser.message.BGPOpenMessage;
66 import org.opendaylight.protocol.bgp.parser.parameter.MultiprotocolCapability;
67 import org.opendaylight.protocol.bgp.util.BGPIPv4RouteImpl;
68 import org.opendaylight.protocol.bgp.util.BGPIPv6RouteImpl;
69 import org.opendaylight.protocol.bgp.util.BGPLinkImpl;
70 import org.opendaylight.protocol.bgp.util.BGPNodeImpl;
71 import org.opendaylight.protocol.concepts.ASNumber;
72 import org.opendaylight.protocol.concepts.IGPMetric;
73 import org.opendaylight.protocol.concepts.IPv4;
74 import org.opendaylight.protocol.concepts.IPv4Address;
75 import org.opendaylight.protocol.concepts.IPv4Prefix;
76 import org.opendaylight.protocol.concepts.IPv6;
77 import org.opendaylight.protocol.concepts.IPv6Address;
78 import org.opendaylight.protocol.concepts.Identifier;
79 import org.opendaylight.protocol.concepts.Metric;
80 import org.opendaylight.protocol.util.ByteArray;
81 import org.opendaylight.protocol.util.DefaultingTypesafeContainer;
83 import com.google.common.collect.Lists;
84 import com.google.common.collect.Sets;
86 public class BGPParserTest {
89 * Used by other tests as well
91 static final List<byte[]> inputBytes = new ArrayList<byte[]>();
93 private static int COUNTER = 17;
95 private static int MAX_SIZE = 300;
98 public static void setUp() throws Exception {
100 for (int i = 1; i <= COUNTER; i++) {
101 final String name = "/up" + i + ".bin";
102 final InputStream is = BGPParserTest.class.getResourceAsStream(name);
104 throw new IOException("Failed to get resource " + name);
106 final ByteArrayOutputStream bis = new ByteArrayOutputStream();
107 final byte[] data = new byte[MAX_SIZE];
109 while ((nRead = is.read(data, 0, data.length)) != -1) {
110 bis.write(data, 0, nRead);
114 inputBytes.add(bis.toByteArray());
119 public void testResource() {
120 assertNotNull(inputBytes);
124 * Tests IPv4 NEXT_HOP, ATOMIC_AGGREGATE, COMMUNITY, NLRI
126 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
127 * 00 54 <- length (84) - including header
129 * 00 00 <- withdrawn routes length
130 * 00 31 <- total path attribute length (49)
131 * 40 <- attribute flags
132 * 01 <- attribute type code (origin)
133 * 01 <- attribute length
134 * 00 <- Origin value (IGP)
135 * 40 <- attribute flags
136 * 02 <- attribute type code (as path)
137 * 06 <- attribute length
139 * 01 <- path segment count
140 * 00 00 fd ea <- path segment value (65002)
141 * 40 <- attribute flags
142 * 03 <- attribute type code (Next Hop)
143 * 04 <- attribute length
144 * 10 00 00 02 <- value (10.0.0.2)
145 * 80 <- attribute flags
146 * 04 <- attribute type code (multi exit disc)
147 * 04 <- attribute length
148 * 00 00 00 00 <- value
149 * 64 <- attribute flags
150 * 06 <- attribute type code (atomic aggregate)
151 * 00 <- attribute length
152 * 64 <- attribute flags
153 * 08 <- attribute type code (community)
154 * 10 <- attribute length FF FF FF
155 * 01 <- value (NO_EXPORT)
156 * FF FF FF 02 <- value (NO_ADVERTISE)
157 * FF FF FF 03 <- value (NO_EXPORT_SUBCONFED)
158 * FF FF FF 10 <- unknown Community
161 * 18 ac 11 02 <- IPv4 Prefix (172.17.2.0 / 24)
162 * 18 ac 11 01 <- IPv4 Prefix (172.17.1.0 / 24)
163 * 18 ac 11 00 <- IPv4 Prefix (172.17.0.0 / 24)
166 public void testGetUpdateMessage1() throws Exception {
168 final byte[] body = ByteArray.cutBytes(inputBytes.get(0), BGPMessageFactory.COMMON_HEADER_LENGTH);
169 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(0), BGPMessageFactory.MARKER_LENGTH,
170 BGPMessageFactory.LENGTH_FIELD_LENGTH));
171 final BGPUpdateEvent ret = BGPUpdateMessageParser.parse(body, messageLength);
173 assertTrue(ret instanceof BGPUpdateMessage);
174 final BGPUpdateMessage message = (BGPUpdateMessage) ret;
178 assertEquals(Collections.EMPTY_SET, message.getRemovedObjects());
182 final ASPath asPath = new ASPath(Lists.newArrayList(new ASNumber(65002)));
184 final IPv4NextHop nextHop = IPv4NextHop.forString("10.0.0.2");
186 final Set<Community> comms = Sets.newHashSet(Community.NO_EXPORT, Community.NO_ADVERTISE, Community.NO_EXPORT_SUBCONFED,
187 new Community(new ASNumber(0xFFFF), 0xFF10));
189 // check path attributes
191 // final PathAttribute originAttr = new PathAttribute(TypeCode.ORIGIN, false,
192 // true, false, false, BGPOrigin.IGP);
193 // assertEquals(originAttr, attrs.get(0));
195 // final PathAttribute asPathAttr = new PathAttribute(TypeCode.AS_PATH, false,
196 // true, false, false, asPath);
197 // assertEquals(asPathAttr, attrs.get(1));
199 // final PathAttribute nextHopAttr = new PathAttribute(TypeCode.NEXT_HOP, false,
200 // true, false, false, nextHop);
201 // assertEquals(nextHopAttr, attrs.get(2));
203 // final PathAttribute multiExitDisc = new PathAttribute(
204 // TypeCode.MULTI_EXIT_DISC, true, false, false, false, 0);
205 // assertEquals(multiExitDisc, attrs.get(3));
207 // final PathAttribute atomic = new PathAttribute(TypeCode.ATOMIC_AGGREGATE, false,
208 // true, true, false, null);
209 // assertEquals(atomic, attrs.get(4));
211 // final PathAttribute comm = new PathAttribute(TypeCode.COMMUNITIES, false,
212 // true, true, false, comms);
213 // assertEquals(comm, attrs.get(5));
217 // final Set<IPv4Prefix> nlri = Sets.newHashSet(pref1, pref2, pref3);
218 // assertEquals(nlri, ret.getBgpUpdateMessageBuilder().getNlri());
220 final BaseBGPObjectState state = new BaseBGPObjectState(BGPOrigin.IGP, null);
221 final NetworkRouteState<IPv4Address> routeState = new NetworkRouteState<>(new NetworkObjectState(asPath, comms, Collections.<ExtendedCommunity> emptySet()), nextHop);
225 final Set<BGPObject> addedObjects = Sets.newHashSet();
227 final BGPRoute<IPv4Address> route1 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("172.17.2.0/24"), state, routeState);
229 addedObjects.add(route1);
231 final BGPRoute<IPv4Address> route2 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("172.17.1.0/24"), state, routeState);
233 addedObjects.add(route2);
235 final BGPRoute<IPv4Address> route3 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("172.17.0.0/24"), state, routeState);
237 addedObjects.add(route3);
239 final BGPUpdateMessage expectedMessage = new BGPUpdateMessageImpl(addedObjects, Collections.<Identifier> emptySet());
241 assertEquals(expectedMessage, message);
246 * Tests IPv6 NEXT_HOP, NLRI, ORIGIN.IGP, MULTI_EXIT_DISC, ORIGINATOR-ID, CLUSTER_LIST.
248 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
249 * 00 80 <- length (128) - including header
251 * 00 00 <- withdrawn routes length
252 * 00 69 <- total path attribute length (105)
253 * 40 <- attribute flags
254 * 01 <- attribute type code (origin)
255 * 01 <- attribute length
256 * 00 <- Origin value (IGP)
257 * 40 <- attribute flags
258 * 02 <- attribute type code (as path)
259 * 06 <- attribute length
261 * 01 <- path segment count
262 * 00 00 fd e9 <- path segment value (65001)
263 * 80 <- attribute flags
264 * 04 <- attribute type code (multi exit disc)
265 * 04 <- attribute length
266 * 00 00 00 00 <- value
267 * 80 <- attribute flags
268 * 09 <- attribute type code (originator id)
269 * 04 <- attribute length
270 * 7f 00 00 01 <- value (localhost ip)
271 * 80 <- attribute flags
272 * 0a <- attribute type code (cluster list)
273 * 08 <- attribute length
274 * 01 02 03 04 <- value
275 * 05 06 07 08 <- value
276 * 80 <- attribute flags
277 * 0e <- attribute type code (mp reach nlri)
278 * 40 <- attribute length
279 * 00 02 <- AFI (Ipv6)
280 * 01 <- SAFI (Unicast)
281 * 20 <- length of next hop
282 * 20 01 0d b8 00 00 00 00 00 00 00 00 00 00 00 01 <- global
283 * fe 80 00 00 00 00 00 00 c0 01 0b ff fe 7e 00 <- link local
287 * 40 20 01 0d b8 00 01 00 02 <- IPv6 Prefix (2001:db8:1:2:: / 64)
288 * 40 20 01 0d b8 00 01 00 01 <- IPv6 Prefix (2001:db8:1:1:: / 64)
289 * 40 20 01 0d b8 00 01 00 00 <- IPv6 Prefix (2001:db8:1:: / 64)
293 public void testGetUpdateMessage2() throws Exception {
294 final byte[] body = ByteArray.cutBytes(inputBytes.get(1), BGPMessageFactory.COMMON_HEADER_LENGTH);
295 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(1), BGPMessageFactory.MARKER_LENGTH,
296 BGPMessageFactory.LENGTH_FIELD_LENGTH));
297 final BGPUpdateEvent ret = BGPUpdateMessageParser.parse(body, messageLength);
299 assertTrue(ret instanceof BGPUpdateMessage);
300 final BGPUpdateMessage message = (BGPUpdateMessage) ret;
304 assertEquals(Collections.EMPTY_SET, message.getRemovedObjects());
308 final ASPath asPath = new ASPath(Lists.newArrayList(new ASNumber(65001)));
310 final IPv6NextHop nextHop = IPv6NextHop.forString("2001:db8::1", "fe80::c001:bff:fe7e:0");
312 // final List<ClusterIdentifier> clusters = Lists.newArrayList(
313 // new ClusterIdentifier(new byte[] { 1, 2, 3, 4}),
314 // new ClusterIdentifier(new byte[] { 5, 6, 7, 8}));
316 // check path attributes
318 // final PathAttribute originAttr = new PathAttribute(TypeCode.ORIGIN, false,
319 // true, false, false, BGPOrigin.IGP);
320 // assertEquals(originAttr, attrs.get(0));
322 // final PathAttribute asPathAttr = new PathAttribute(TypeCode.AS_PATH, false,
323 // true, false, false, asPath);
324 // assertEquals(asPathAttr, attrs.get(1));
326 // final PathAttribute multiExitDisc = new PathAttribute(
327 // TypeCode.MULTI_EXIT_DISC, true, false, false, false, 0);
328 // assertEquals(multiExitDisc, attrs.get(2));
330 // final PathAttribute originatorAttr = new PathAttribute(
331 // TypeCode.ORIGINATOR_ID, true, false, false, false, IPv4.FAMILY.addressForString("127.0.0.1"));
332 // assertEquals(originatorAttr, attrs.get(3));
334 // final PathAttribute clusterAttr = new PathAttribute(
335 // TypeCode.CLUSTER_LIST, true, false, false, false, clusters);
336 // assertEquals(clusterAttr, attrs.get(4));
338 final BaseBGPObjectState state = new BaseBGPObjectState(BGPOrigin.IGP, null);
339 final NetworkRouteState<IPv6Address> routeState = new NetworkRouteState<>(new NetworkObjectState(asPath, Collections.<Community> emptySet(), Collections.<ExtendedCommunity> emptySet()), nextHop);
343 final Set<BGPObject> addedObjects = Sets.newHashSet();
345 final BGPRoute<IPv6Address> route1 = new BGPIPv6RouteImpl(IPv6.FAMILY.prefixForString("2001:db8:1:2::/64"), state, routeState);
347 addedObjects.add(route1);
349 final BGPRoute<IPv6Address> route2 = new BGPIPv6RouteImpl(IPv6.FAMILY.prefixForString("2001:db8:1:1::/64"), state, routeState);
351 addedObjects.add(route2);
353 final BGPRoute<IPv6Address> route3 = new BGPIPv6RouteImpl(IPv6.FAMILY.prefixForString("2001:db8:1::/64"), state, routeState);
355 addedObjects.add(route3);
357 final BGPUpdateMessage expectedMessage = new BGPUpdateMessageImpl(addedObjects, Collections.<Identifier> emptySet());
359 assertEquals(expectedMessage, message);
363 * Tests more AS Numbers in AS_PATH, AGGREGATOR, ORIGIN.INCOMPLETE
365 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
366 * 00 4b <- length (75) - including header
368 * 00 00 <- withdrawn routes length
369 * 00 30 <- total path attribute length (48)
370 * 40 <- attribute flags
371 * 01 <- attribute type code (origin)
372 * 01 <- attribute length
373 * 02 <- Origin value (Incomplete)
374 * 40 <- attribute flags
375 * 02 <- attribute type code (as path)
376 * 10 <- attribute length
378 * 01 <- path segment count
379 * 00 00 00 1e <- path segment value (30)
381 * 02 <- path segment count
382 * 00 00 00 0a <- path segment value (10)
383 * 00 00 00 14 <- path segment value (20)
384 * 40 <- attribute flags
385 * 03 <- attribute type (Next hop)
386 * 04 <- attribute length
387 * 0a 00 00 09 <- value (10.0.0.9)
388 * 80 <- attribute flags
389 * 04 <- attribute type code (multi exit disc)
390 * 04 <- attribute length
391 * 00 00 00 00 <- value
392 * c0 <- attribute flags
393 * 07 <- attribute type (Aggregator)
394 * 08 <- attribute length
395 * 00 00 00 1e <- value (AS number = 30)
396 * 0a 00 00 09 <- value (IP address = 10.0.0.9)
399 * 15 ac 10 00 <- IPv4 Prefix (172.16.0.0 / 21)
402 public void testGetUpdateMessage3() throws Exception {
403 final byte[] body = ByteArray.cutBytes(inputBytes.get(2), BGPMessageFactory.COMMON_HEADER_LENGTH);
404 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(2), BGPMessageFactory.MARKER_LENGTH,
405 BGPMessageFactory.LENGTH_FIELD_LENGTH));
406 final BGPUpdateEvent ret = BGPUpdateMessageParser.parse(body, messageLength);
407 assertTrue(ret instanceof BGPUpdateMessage);
408 final BGPUpdateMessage message = (BGPUpdateMessage) ret;
411 assertEquals(Collections.EMPTY_SET, message.getRemovedObjects());
415 final ASPath asPath = new ASPath(Lists.newArrayList(new ASNumber(30)), Sets.newHashSet(new ASNumber(10), new ASNumber(20)));
417 final BGPAggregator aggregator = new BGPAggregatorImpl<IPv4Address>(new ASNumber(30), IPv4.FAMILY.addressForString("10.0.0.9"));
418 final IPv4NextHop nextHop = IPv4NextHop.forString("10.0.0.9");
420 final IPv4Prefix pref1 = IPv4.FAMILY.prefixForString("172.16.0.0/21");
422 // check path attributes
424 // final PathAttribute originAttr = new PathAttribute(TypeCode.ORIGIN, false,
425 // true, false, false, BGPOrigin.INCOMPLETE);
426 // assertEquals(originAttr, attrs.get(0));
428 // final PathAttribute asPathAttr = new PathAttribute(TypeCode.AS_PATH, false,
429 // true, false, false, asPath);
430 // assertEquals(asPathAttr, attrs.get(1));
432 // final PathAttribute nextHopAttr = new PathAttribute(TypeCode.NEXT_HOP, false,
433 // true, false, false, nextHop);
434 // assertEquals(nextHopAttr, attrs.get(2));
436 // final PathAttribute multiExitDisc = new PathAttribute(
437 // TypeCode.MULTI_EXIT_DISC, true, false, false, false, 0);
438 // assertEquals(multiExitDisc, attrs.get(3));
440 // final PathAttribute agg = new PathAttribute(TypeCode.AGGREGATOR, true, true,
441 // false, false, aggregator);
442 // assertEquals(agg, attrs.get(4));
446 // final Set<IPv4Prefix> nlri = Sets.newHashSet(pref1);
447 // assertEquals(nlri, ret.getBgpUpdateMessageBuilder().getNlri());
449 final BaseBGPObjectState state = new BaseBGPObjectState(BGPOrigin.INCOMPLETE, aggregator);
450 final NetworkRouteState<IPv4Address> routeState = new NetworkRouteState<>(new NetworkObjectState(asPath, Collections.<Community> emptySet(), Collections.<ExtendedCommunity> emptySet()), nextHop);
454 final Set<BGPObject> addedObjects = Sets.newHashSet();
456 final BGPRoute<IPv4Address> route1 = new BGPIPv4RouteImpl(pref1, state, routeState);
458 addedObjects.add(route1);
460 final BGPUpdateMessage expectedMessage = new BGPUpdateMessageImpl(addedObjects, Collections.<Identifier> emptySet());
462 assertEquals(expectedMessage, message);
467 * Tests empty AS_PATH, ORIGIN.EGP, LOCAL_PREF, EXTENDED_COMMUNITIES (Ipv4 Addr specific)
469 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
470 * 00 4A <- length (73) - including header
472 * 00 00 <- withdrawn routes length
473 * 00 27 <- total path attribute length (39)
474 * 40 <- attribute flags
475 * 01 <- attribute type code (Origin)
476 * 01 <- attribute length
477 * 01 <- Origin value (EGP)
478 * 40 <- attribute flags
479 * 02 <- attribute type code (As path)
480 * 00 <- attribute length
481 * 40 <- attribute flags
482 * 03 <- attribute type (Next hop)
483 * 04 <- attribute length
484 * 03 03 03 03 <- value (3.3.3.3)
485 * 80 <- attribute flags
486 * 04 <- attribute type code (Multi exit disc)
487 * 04 <- attribute length
488 * 00 00 00 00 <- value
489 * 40 <- attribute flags
490 * 05 <- attribute type (Local Pref)
491 * 04 <- attribute length
492 * 00 00 00 64 <- value (100)
493 * 80 <- attribute flags
494 * 10 <- attribute type (extended community)
495 * 08 <- attribute length
496 * 01 04 <- value (type - Ipv4 Address Specific Extended Community)
497 * c0 a8 01 00 <- value (global adm. 198.162.1.0)
498 * 12 34 <- value (local adm. 4660)
501 * 18 0a 1e 03 <- IPv4 Prefix (10.30.3.0 / 24)
502 * 18 0a 1e 02 <- IPv4 Prefix (10.30.2.0 / 24)
503 * 18 0a 1e 01 <- IPv4 Prefix (10.30.1.0 / 24)
506 public void testGetUpdateMessage4() throws Exception {
507 final byte[] body = ByteArray.cutBytes(inputBytes.get(3), BGPMessageFactory.COMMON_HEADER_LENGTH);
508 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(3), BGPMessageFactory.MARKER_LENGTH,
509 BGPMessageFactory.LENGTH_FIELD_LENGTH));
510 final BGPUpdateEvent ret = BGPUpdateMessageParser.parse(body, messageLength);
512 assertTrue(ret instanceof BGPUpdateMessage);
513 final BGPUpdateMessage message = (BGPUpdateMessage) ret;
517 assertEquals(Collections.EMPTY_SET, message.getRemovedObjects());
521 final IPv4NextHop nextHop = IPv4NextHop.forString("3.3.3.3");
523 final Set<ExtendedCommunity> comms = Sets.newHashSet((ExtendedCommunity) new Inet4SpecificExtendedCommunity(false, 4, IPv4.FAMILY.addressForString("192.168.1.0"), new byte[] {
526 // check path attributes
528 // final PathAttribute originAttr = new PathAttribute(TypeCode.ORIGIN, false,
529 // true, false, false, BGPOrigin.EGP);
530 // assertEquals(originAttr, attrs.get(0));
532 // final PathAttribute asPathAttr = new PathAttribute(TypeCode.AS_PATH, false,
533 // true, false, false, asPath);
534 // assertEquals(asPathAttr, attrs.get(1));
536 // final PathAttribute nextHopAttr = new PathAttribute(TypeCode.NEXT_HOP, false,
537 // true, false, false, nextHop);
538 // assertEquals(nextHopAttr, attrs.get(2));
540 // final PathAttribute multiExitDisc = new PathAttribute(
541 // TypeCode.MULTI_EXIT_DISC, true, false, false, false, 0);
542 // assertEquals(multiExitDisc, attrs.get(3));
544 // final PathAttribute localPref = new PathAttribute(TypeCode.LOCAL_PREF, false,
545 // true, false, false, 100);
546 // assertEquals(localPref, attrs.get(4));
550 // final Set<IPv4Prefix> nlri = Sets.newHashSet(pref1, pref2, pref3);
551 // assertEquals(nlri, ret.getBgpUpdateMessageBuilder().getNlri());
553 final BaseBGPObjectState state = new BaseBGPObjectState(BGPOrigin.EGP, null);
554 final NetworkRouteState<IPv4Address> routeState = new NetworkRouteState<>(new NetworkObjectState(ASPath.EMPTY, Collections.<Community> emptySet(), comms), nextHop);
558 final Set<BGPObject> addedObjects = Sets.newHashSet();
560 final BGPRoute<IPv4Address> route1 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("10.30.3.0/24"), state, routeState);
562 addedObjects.add(route1);
564 final BGPRoute<IPv4Address> route2 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("10.30.2.0/24"), state, routeState);
566 addedObjects.add(route2);
568 final BGPRoute<IPv4Address> route3 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("10.30.1.0/24"), state, routeState);
570 addedObjects.add(route3);
572 final BGPUpdateMessage expectedMessage = new BGPUpdateMessageImpl(addedObjects, Collections.<Identifier> emptySet());
574 assertEquals(expectedMessage, message);
578 * Tests withdrawn routes.
580 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
581 * 00 1c <- length (28) - including header
583 * 00 05 <- withdrawn routes length (5)
584 * 1e ac 10 00 04 <- route (172.16.0.4)
585 * 00 00 <- total path attribute length
588 public void testGetUpdateMessage5() throws Exception {
589 final byte[] body = ByteArray.cutBytes(inputBytes.get(4), BGPMessageFactory.COMMON_HEADER_LENGTH);
590 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(4), BGPMessageFactory.MARKER_LENGTH,
591 BGPMessageFactory.LENGTH_FIELD_LENGTH));
592 final BGPUpdateEvent ret = BGPUpdateMessageParser.parse(body, messageLength);
594 assertTrue(ret instanceof BGPUpdateMessage);
595 final BGPUpdateMessage message = (BGPUpdateMessage) ret;
599 final IPv4Prefix pref1 = IPv4.FAMILY.prefixForString("172.16.0.4/30");
603 final BGPUpdateEvent expectedMessage = new BGPUpdateMessageImpl(Collections.<BGPObject> emptySet(), Sets.newHashSet((Identifier) pref1));
605 assertEquals(expectedMessage, message);
611 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
612 * 00 17 <- length (23) - including header
614 * 00 00 <- withdrawn routes length
615 * 00 00 <- total path attribute length
618 public void testEORIpv4() throws Exception {
619 final byte[] body = ByteArray.cutBytes(inputBytes.get(5), BGPMessageFactory.COMMON_HEADER_LENGTH);
620 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(5), BGPMessageFactory.MARKER_LENGTH,
621 BGPMessageFactory.LENGTH_FIELD_LENGTH));
622 final BGPUpdateEvent ret = BGPUpdateMessageParser.parse(body, messageLength);
624 assertTrue(ret instanceof BGPUpdateSynchronized);
625 final BGPUpdateSynchronized message = (BGPUpdateSynchronized) ret;
627 final BGPUpdateSynchronized expectedMessage = new BGPUpdateSynchronized() {
629 private static final long serialVersionUID = -5128220996581568885L;
632 public BGPTableType getTableType() {
633 return new BGPTableType(BGPAddressFamily.IPv4, BGPSubsequentAddressFamily.Unicast);
636 assertEquals(expectedMessage.getTableType(), message.getTableType());
640 * End of Rib for Ipv6 consists of empty MP_UNREACH_NLRI, with AFI 2 and SAFI 1
642 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
643 * 00 1d <- length (29) - including header
645 * 00 00 <- withdrawn routes length
646 * 00 06 <- total path attribute length
647 * 80 <- attribute flags
648 * 0f <- attribute type (15 - MP_UNREACH_NLRI)
649 * 03 <- attribute length
650 * 00 02 <- value (AFI 2: IPv6)
651 * 01 <- value (SAFI 1)
654 public void testEORIpv6() throws Exception {
655 final byte[] body = ByteArray.cutBytes(inputBytes.get(6), BGPMessageFactory.COMMON_HEADER_LENGTH);
656 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(6), BGPMessageFactory.MARKER_LENGTH,
657 BGPMessageFactory.LENGTH_FIELD_LENGTH));
658 final BGPUpdateEvent ret = BGPUpdateMessageParser.parse(body, messageLength);
660 assertTrue(ret instanceof BGPUpdateSynchronized);
661 final BGPUpdateSynchronized message = (BGPUpdateSynchronized) ret;
665 final BGPUpdateSynchronized expectedMessage = new BGPUpdateSynchronized() {
667 private static final long serialVersionUID = -4811827044855997014L;
670 public BGPTableType getTableType() {
671 return new BGPTableType(BGPAddressFamily.IPv6, BGPSubsequentAddressFamily.Unicast);
674 assertEquals(expectedMessage.getTableType(), message.getTableType());
678 * End of Rib for LS consists of empty MP_UNREACH_NLRI, with AFI 16388 and SAFI 71
680 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
681 * 00 1d <- length (29) - including header
683 * 00 00 <- withdrawn routes length
684 * 00 06 <- total path attribute length
685 * 80 <- attribute flags
686 * 0f <- attribute type (15 - MP_UNREACH_NLRI)
687 * 03 <- attribute length
688 * 40 04 <- value (AFI 16388: LS)
689 * 47 <- value (SAFI 71)
692 public void testEORLS() throws Exception {
693 final byte[] body = ByteArray.cutBytes(inputBytes.get(7), BGPMessageFactory.COMMON_HEADER_LENGTH);
694 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(7), BGPMessageFactory.MARKER_LENGTH,
695 BGPMessageFactory.LENGTH_FIELD_LENGTH));
696 final BGPUpdateEvent ret = BGPUpdateMessageParser.parse(body, messageLength);
698 assertTrue(ret instanceof BGPUpdateSynchronized);
699 final BGPUpdateSynchronized message = (BGPUpdateSynchronized) ret;
703 final BGPUpdateSynchronized expectedMessage = new BGPUpdateSynchronized() {
705 private static final long serialVersionUID = 3677704232769769042L;
708 public BGPTableType getTableType() {
709 return new BGPTableType(BGPAddressFamily.LinkState, BGPSubsequentAddressFamily.Unicast);
713 assertEquals(expectedMessage.getTableType(), message.getTableType());
717 * Tests BGP Link Ipv4
719 00 00 <- withdrawn routes length
720 01 48 <- total path attribute length (328)
721 90 <- attribute flags
722 0e <- attribute type code (MP reach)
723 01 2c <- attribute extended length (300)
724 40 04 <- AFI (16388 - Linkstate)
725 47 <- SAFI (71 - Linkstate)
726 04 <- next hop length
727 19 19 19 01 <- nexthop (25.25.25.1)
730 00 02 <- NLRI type (2 - linkNLRI)
731 00 5d <- NLRI length (93)
732 03 <- ProtocolID - OSPF
733 00 00 00 00 00 00 00 01 <- identifier
735 01 00 <- local node descriptor type (256)
737 02 00 <- node descriptor type (member AS - 512)
739 00 00 00 64 <- value (100)
740 02 01 <- node descriptor type (bgpId - 513)
742 19 19 19 01 <- bgpId (25.25.25.1)
743 02 02 <- node descriptor type (areaId - 514)
746 02 03 <- node descriptor type (routeId - 515)
748 03 03 03 04 0b 0b 0b 03 <- OSPF Router Id
750 01 01 <- remote node descriptor type (257)
752 02 00 <- node descriptor type (member AS - 512)
754 00 00 00 64 <- value (100)
755 02 01 <- node descriptor type (bgpId - 513)
757 19 19 19 01 <- bgpId (25.25.25.1)
758 02 02 <- node descriptor type (areaId - 514)
761 02 03 <- node descriptor type (routeId - 515)
763 03 03 03 04 <- OSPF Router Id
765 01 03 <- link descriptor type (IPv4 interface address - 259)
767 0b 0b 0b 03 <- value (11.11.11.3)
769 00 02 <- NLRI type (2 - linkNLRI)
770 00 5d <- NLRI length (93)
771 03 <- ProtocolID - OSPF
772 00 00 00 00 00 00 00 01 <- identifier
774 01 00 <- local node descriptor type (256)
776 02 00 <- node descriptor type (member AS - 512)
778 00 00 00 64 <- value (100)
779 02 01 <- node descriptor type (bgpId - 513)
781 19 19 19 01 <- bgpId (25.25.25.1)
782 02 02 <- node descriptor type (areaId - 514)
785 02 03 <- node descriptor type (routeId - 515)
787 03 03 03 04 0b 0b 0b 03 <- OSPF Router Id
789 01 01 <- remote node descriptor type (257)
791 02 00 <- node descriptor type (member AS - 512)
793 00 00 00 64 <- value (100)
794 02 01 <- node descriptor type (bgpId - 513)
796 19 19 19 01 <- bgpId (25.25.25.1)
797 02 02 <- node descriptor type (areaId - 514)
800 02 03 <- node descriptor type (routeId - 515)
802 01 01 01 02 <- OSPF Router Id
804 01 03 <- link descriptor type (IPv4 interface address - 259)
806 0b 0b 0b 01 <- value (11.11.11.1)
808 00 02 <- NLRI type (2 - linkNLRI)
809 00 5d <- NLRI length (93)
810 03 <- ProtocolID - OSPF
811 00 00 00 00 00 00 00 01 <- identifier
813 01 00 <- local node descriptor type (256)
815 02 00 <- node descriptor type (member AS - 512)
817 00 00 00 64 <- value (100)
818 02 01 <- node descriptor type (bgpId - 513)
820 19 19 19 01 <- bgpId (25.25.25.1)
821 02 02 <- node descriptor type (areaId - 514)
824 02 03 <- node descriptor type (routeId - 515)
826 01 01 01 02 <- OSPF Router Id
828 01 01 <- remote node descriptor type (257)
830 02 00 <- node descriptor type (member AS - 512)
832 00 00 00 64 <- value (100)
833 02 01 <- node descriptor type (bgpId - 513)
835 19 19 19 01 <- bgpId (25.25.25.1)
836 02 02 <- node descriptor type (areaId - 514)
839 02 03 <- node descriptor type (routeId - 515)
841 03 03 03 04 0b 0b 0b 03 <- OSPF Router Id
843 01 03 <- link descriptor type (IPv4 interface address - 259)
845 0b 0b 0b 01 <- value (11.11.11.1)
847 40 <- attribute flags
848 01 <- attribute type (Origin)
849 01 <- attribute length
851 40 <- attribute flags
852 02 <- attribute type (AS Path)
854 40 <- attribute flags
855 05 <- attribute type (local pref)
858 c0 <- attribute flags
859 63 <- attribute type (Link STATE - 99)
861 04 47 <- link attribute (1095 - Metric)
866 public void testBGPLink() throws Exception {
867 final byte[] body = ByteArray.cutBytes(inputBytes.get(8), BGPMessageFactory.COMMON_HEADER_LENGTH);
868 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(8), BGPMessageFactory.MARKER_LENGTH,
869 BGPMessageFactory.LENGTH_FIELD_LENGTH));
870 final BGPUpdateEvent ret = BGPUpdateMessageParser.parse(body, messageLength);
872 assertTrue(ret instanceof BGPUpdateMessage);
873 final BGPUpdateMessage message = (BGPUpdateMessage) ret;
877 assertEquals(Collections.EMPTY_SET, message.getRemovedObjects());
879 // network object state
880 final NetworkObjectState objState = new NetworkObjectState(ASPath.EMPTY, Collections.<Community> emptySet(), Collections.<ExtendedCommunity> emptySet());
881 final BaseBGPObjectState state = new BaseBGPObjectState(BGPOrigin.IGP, null);
883 // network link state
884 final DefaultingTypesafeContainer<Metric<?>> container = new DefaultingTypesafeContainer<Metric<?>>();
885 container.setDefaultEntry(new IGPMetric(1));
886 final NetworkLinkState linkState = new NetworkLinkState(objState, container, null, LinkProtectionType.UNPROTECTED, null, null, null);
888 final NodeIdentifierFactory f100 = new NodeIdentifierFactory(new ASNumber(100), new DomainIdentifier(new byte[] { 25, 25, 25, 1 }), new AreaIdentifier(new byte[] {
891 final NodeIdentifier nodeid1 = f100.identifierForRouter(new OSPFv3LANIdentifier(new OSPFRouterIdentifier(new byte[] { 3, 3, 3, 4 }), new OSPFInterfaceIdentifier(new byte[] {
892 0x0b, 0x0b, 0x0b, 0x03 })));
893 final NodeIdentifier nodeid2 = f100.identifierForRouter(new OSPFRouterIdentifier(new byte[] { 3, 3, 3, 4 }));
895 final NodeIdentifier nodeid3 = f100.identifierForRouter(new OSPFRouterIdentifier(new byte[] { 1, 1, 1, 2 }));
899 final LinkIdentifier linkId1 = new LinkIdentifier(null, new LinkAnchor(nodeid1, new IPv4InterfaceIdentifier(IPv4.FAMILY.addressForString("11.11.11.3"))), new LinkAnchor(nodeid2, null));
900 final LinkIdentifier linkId2 = new LinkIdentifier(null, new LinkAnchor(nodeid1, new IPv4InterfaceIdentifier(IPv4.FAMILY.addressForString("11.11.11.1"))), new LinkAnchor(nodeid3, null));
901 final LinkIdentifier linkId3 = new LinkIdentifier(null, new LinkAnchor(nodeid3, new IPv4InterfaceIdentifier(IPv4.FAMILY.addressForString("11.11.11.1"))), new LinkAnchor(nodeid1, null));
903 final BGPLink link1 = new BGPLinkImpl(state, linkId1, linkState);
904 final BGPLink link2 = new BGPLinkImpl(state, linkId2, linkState);
905 final BGPLink link3 = new BGPLinkImpl(state, linkId3, linkState);
907 final BGPUpdateMessage expectedMessage = new BGPUpdateMessageImpl(Sets.newHashSet((BGPObject) link1, (BGPObject) link2,
908 (BGPObject) link3), Collections.<Identifier> emptySet());
910 assertEquals(expectedMessage, message);
916 * 00 00 <- withdrawn routes length
917 00 b2 <- total path attribute length (178)
918 90 <- attribute flags
919 0e <- attribute type code (MP reach)
920 00 a0 <- attribute extended length (160)
921 40 04 <- AFI (16388 - Linkstate)
922 47 <- SAFI (71 - Linkstate)
923 04 <- next hop length
924 19 19 19 01 - nexthop (25.25.25.1)
926 00 01 <- NLRI type (1 - nodeNLRI)
927 00 31 <- NLRI length (49)
928 03 <- ProtocolID - OSPF
929 00 00 00 00 00 00 00 01 <- identifier
931 01 00 <- local node descriptor type (256)
933 02 00 <- node descriptor type (member AS - 512)
935 00 00 00 64 <- value (100)
936 02 01 <- node descriptor type (bgpId - 513)
938 19 19 19 01 <- bgpId (25.25.25.1)
939 02 02 <- node descriptor type (areaId - 514)
942 02 03 <- node descriptor type (routeId - 515)
944 03 03 03 04 0b 0b 0b 03 <- OSPF Router Id
946 00 01 <- NLRI type (1 - nodeNLRI)
947 00 2d <- NLRI length (45)
948 03 <- ProtocolID - OSPF
949 00 00 00 00 00 00 00 01 <- identifier
951 01 00 <- local node descriptor type (256)
953 02 00 <- node descriptor type (member AS - 512)
955 00 00 00 64 <- value (100)
956 02 01 <- node descriptor type (bgpId - 513)
958 19 19 19 01 <- bgpId (25.25.25.1)
959 02 02 <- node descriptor type (areaId - 514)
962 02 03 <- node descriptor type (routeId - 515)
964 03 03 03 04 <- OSPF Router Id
966 00 01 <- NLRI type (1 - nodeNLRI)
967 00 2d <- NLRI length (45)
968 03 <- ProtocolID - OSPF
969 00 00 00 00 00 00 00 01 <- identifier
970 01 00 <- local node descriptor type (256)
972 02 00 <- node descriptor type (member AS - 512)
974 00 00 00 64 <- value (100)
975 02 01 <- node descriptor type (bgpId - 513)
977 19 19 19 01 <- bgpId (25.25.25.1)
978 02 02 <- node descriptor type (areaId - 514)
981 02 03 <- node descriptor type (routeId - 515)
983 01 01 01 02 <- OSPF Router Id
985 40 <- attribute flags
986 01 <- attribute type (Origin)
987 01 <- attribute length
989 40 <- attribute flags
990 02 <- attribute type (AS Path)
992 40 <- attribute flags
993 05 <- attribute type (local pref)
998 public void testBGPNode() throws Exception {
999 final byte[] body = ByteArray.cutBytes(inputBytes.get(9), BGPMessageFactory.COMMON_HEADER_LENGTH);
1000 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(9), BGPMessageFactory.MARKER_LENGTH,
1001 BGPMessageFactory.LENGTH_FIELD_LENGTH));
1002 final BGPUpdateEvent ret = BGPUpdateMessageParser.parse(body, messageLength);
1004 assertTrue(ret instanceof BGPUpdateMessage);
1005 final BGPUpdateMessage message = (BGPUpdateMessage) ret;
1009 assertEquals(Collections.EMPTY_SET, message.getRemovedObjects());
1011 // network object state
1012 final NetworkObjectState objState = new NetworkObjectState(ASPath.EMPTY, Collections.<Community> emptySet(), Collections.<ExtendedCommunity> emptySet());
1013 final BaseBGPObjectState state = new BaseBGPObjectState(BGPOrigin.IGP, null);
1014 final NetworkNodeState nstate = new NetworkNodeState(objState, Collections.<TopologyIdentifier> emptySet(), Collections.<ISISAreaIdentifier> emptySet(), false, false, Collections.<RouterIdentifier> emptySet(), null);
1016 // network link state
1018 final NodeIdentifierFactory f100 = new NodeIdentifierFactory(new ASNumber(100), new DomainIdentifier(new byte[] { 25, 25, 25, 1 }), new AreaIdentifier(new byte[] {
1021 final NodeIdentifier nodeid1 = f100.identifierForRouter(new OSPFv3LANIdentifier(new OSPFRouterIdentifier(new byte[] { 3, 3, 3, 4 }), new OSPFInterfaceIdentifier(new byte[] {
1022 0x0b, 0x0b, 0x0b, 0x03 })));
1023 final NodeIdentifier nodeid2 = f100.identifierForRouter(new OSPFRouterIdentifier(new byte[] { 3, 3, 3, 4 }));
1025 final NodeIdentifier nodeid3 = f100.identifierForRouter(new OSPFRouterIdentifier(new byte[] { 1, 1, 1, 2 }));
1027 // check API message
1029 final BGPNode node1 = new BGPNodeImpl(state, nodeid1, nstate);
1030 final BGPNode node2 = new BGPNodeImpl(state, nodeid2, nstate);
1031 final BGPNode node3 = new BGPNodeImpl(state, nodeid3, nstate);
1033 final BGPUpdateMessage expectedMessage = new BGPUpdateMessageImpl(Sets.newHashSet((BGPObject) node1, (BGPObject) node2,
1034 (BGPObject) node3), Collections.<Identifier> emptySet());
1036 assertEquals(expectedMessage, message);
1040 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
1041 * 00 98 <- length (69) - including header
1042 * 01 <- message type
1044 * 00 64 <- My AS Number (AS TRANS in this case)
1045 * 00 b4 <- Hold Time
1046 * 00 00 00 00 <- BGP Identifier
1047 * 28 <- Optional Parameters Length
1048 * 02 <- opt. param. type (capabilities)
1050 * 01 <- capability code (MP Extensions for BGP4)
1052 * 00 01 00 01 <- AFI 1, SAFI 1
1053 * 02 <- opt. param. type (capabilities)
1055 * 01 <- capability code (MP Extensions for BGP4)
1057 * 00 02 00 01 <- AFI 2, SAFI 1
1058 * 02 <- opt. param. type (capabilities)
1060 * 01 <- capability code (MP Extensions for BGP4)
1062 * 40 04 00 47 <- AFI 16388, SAFI 71
1063 * 02 <- opt. param. type (capabilities)
1065 * 80 <- capability code (private)
1067 * 02 <- opt. param. type (capabilities)
1069 * 02 <- capability code (Route refresh)
1071 * 02 <- opt. param. type (capabilities)
1073 * 41 <- capability code (AS4 octet support)
1075 * 00 00 00 64 <- AS number
1078 public void testOpenMessage() throws Exception {
1079 final BGPMessageFactory msgFactory = new BGPMessageFactory();
1080 final BGPOpenMessage open = (BGPOpenMessage) msgFactory.parse(ByteArray.cutBytes(inputBytes.get(13),
1081 BGPMessageFactory.MARKER_LENGTH));
1082 final Set<BGPTableType> types = Sets.newHashSet();
1083 for (final BGPParameter param : open.getOptParams()) {
1084 if (param instanceof MultiprotocolCapability) {
1085 types.add(((MultiprotocolCapability) param).getTableType());
1088 final Set<BGPTableType> expected = Sets.newHashSet(new BGPTableType(BGPAddressFamily.IPv4, BGPSubsequentAddressFamily.Unicast),
1089 new BGPTableType(BGPAddressFamily.IPv6, BGPSubsequentAddressFamily.Unicast),
1090 new BGPTableType(BGPAddressFamily.LinkState, BGPSubsequentAddressFamily.Linkstate));
1091 assertEquals(expected, types);
1095 public void testHashCodeEquals() throws UnknownHostException {
1096 final BGPAggregator agg1 = new BGPAggregatorImpl<IPv4Address>(new ASNumber(6), IPv4.FAMILY.addressForString("10.0.0.9"));
1098 final BGPAggregator agg2 = new BGPAggregatorImpl<IPv4Address>(new ASNumber(6), IPv4.FAMILY.addressForString("10.0.0.9"));
1100 assertEquals(agg1, agg2);
1101 assertEquals("HashCodes should be equal", agg1.hashCode(), agg2.hashCode());
1102 assertEquals("toString should be equal", agg1.toString(), agg2.toString());
1104 final IPv4MP mp41 = new IPv4MP(false, new IPv4NextHop(IPv4.FAMILY.addressForString("10.0.0.9")), null);
1106 final IPv4MP mp42 = new IPv4MP(false, new IPv4NextHop(IPv4.FAMILY.addressForString("10.0.0.9")), null);
1108 assertEquals(mp41, mp42);
1109 assertEquals("HashCodes should be equal", mp41.hashCode(), mp42.hashCode());
1110 assertEquals("toString should be equal", mp41.toString(), mp42.toString());
1112 final IPv6MP mp61 = new IPv6MP(false, new IPv6NextHop(IPv6.FAMILY.addressForString("fe80::c001:bff:fe7e:0")), null);
1114 final IPv6MP mp62 = new IPv6MP(false, new IPv6NextHop(IPv6.FAMILY.addressForString("fe80::c001:bff:fe7e:0")), null);
1116 assertEquals(mp61, mp62);
1117 assertEquals("HashCodes should be equal", mp61.hashCode(), mp62.hashCode());
1118 assertEquals("toString should be equal", mp61.toString(), mp62.toString());
1120 final PathAttribute localPref1 = new PathAttribute(TypeCode.LOCAL_PREF, false, true, false, false, 100);
1122 final PathAttribute localPref2 = new PathAttribute(TypeCode.LOCAL_PREF, false, true, false, false, 100);
1124 assertEquals(localPref1, localPref2);
1125 assertEquals("HashCodes should be equal", localPref1.hashCode(), localPref2.hashCode());
1126 assertEquals("toString should be equal", localPref1.toString(), localPref2.toString());