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);
107 final ByteArrayOutputStream bis = new ByteArrayOutputStream();
108 final byte[] data = new byte[MAX_SIZE];
110 while ((nRead = is.read(data, 0, data.length)) != -1) {
111 bis.write(data, 0, nRead);
115 inputBytes.add(bis.toByteArray());
120 public void testResource() {
121 assertNotNull(inputBytes);
125 * Tests IPv4 NEXT_HOP, ATOMIC_AGGREGATE, COMMUNITY, NLRI
127 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
128 * 00 54 <- length (84) - including header
130 * 00 00 <- withdrawn routes length
131 * 00 31 <- total path attribute length (49)
132 * 40 <- attribute flags
133 * 01 <- attribute type code (origin)
134 * 01 <- attribute length
135 * 00 <- Origin value (IGP)
136 * 40 <- attribute flags
137 * 02 <- attribute type code (as path)
138 * 06 <- attribute length
140 * 01 <- path segment count
141 * 00 00 fd ea <- path segment value (65002)
142 * 40 <- attribute flags
143 * 03 <- attribute type code (Next Hop)
144 * 04 <- attribute length
145 * 10 00 00 02 <- value (10.0.0.2)
146 * 80 <- attribute flags
147 * 04 <- attribute type code (multi exit disc)
148 * 04 <- attribute length
149 * 00 00 00 00 <- value
150 * 64 <- attribute flags
151 * 06 <- attribute type code (atomic aggregate)
152 * 00 <- attribute length
153 * 64 <- attribute flags
154 * 08 <- attribute type code (community)
155 * 10 <- attribute length FF FF FF
156 * 01 <- value (NO_EXPORT)
157 * FF FF FF 02 <- value (NO_ADVERTISE)
158 * FF FF FF 03 <- value (NO_EXPORT_SUBCONFED)
159 * FF FF FF 10 <- unknown Community
162 * 18 ac 11 02 <- IPv4 Prefix (172.17.2.0 / 24)
163 * 18 ac 11 01 <- IPv4 Prefix (172.17.1.0 / 24)
164 * 18 ac 11 00 <- IPv4 Prefix (172.17.0.0 / 24)
167 public void testGetUpdateMessage1() throws Exception {
169 final byte[] body = ByteArray.cutBytes(inputBytes.get(0), BGPMessageFactoryImpl.COMMON_HEADER_LENGTH);
170 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(0), BGPMessageFactoryImpl.MARKER_LENGTH,
171 BGPMessageFactoryImpl.LENGTH_FIELD_LENGTH));
172 final BGPUpdateEvent ret = BGPUpdateMessageParser.parse(body, messageLength);
174 assertTrue(ret instanceof BGPUpdateMessage);
175 final BGPUpdateMessage message = (BGPUpdateMessage) ret;
179 assertEquals(Collections.EMPTY_SET, message.getRemovedObjects());
183 final ASPath asPath = new ASPath(Lists.newArrayList(new ASNumber(65002)));
185 final IPv4NextHop nextHop = IPv4NextHop.forString("10.0.0.2");
187 final Set<Community> comms = Sets.newHashSet(Community.NO_EXPORT, Community.NO_ADVERTISE, Community.NO_EXPORT_SUBCONFED,
188 new Community(new ASNumber(0xFFFF), 0xFF10));
190 // check path attributes
192 // final PathAttribute originAttr = new PathAttribute(TypeCode.ORIGIN, false,
193 // true, false, false, BGPOrigin.IGP);
194 // assertEquals(originAttr, attrs.get(0));
196 // final PathAttribute asPathAttr = new PathAttribute(TypeCode.AS_PATH, false,
197 // true, false, false, asPath);
198 // assertEquals(asPathAttr, attrs.get(1));
200 // final PathAttribute nextHopAttr = new PathAttribute(TypeCode.NEXT_HOP, false,
201 // true, false, false, nextHop);
202 // assertEquals(nextHopAttr, attrs.get(2));
204 // final PathAttribute multiExitDisc = new PathAttribute(
205 // TypeCode.MULTI_EXIT_DISC, true, false, false, false, 0);
206 // assertEquals(multiExitDisc, attrs.get(3));
208 // final PathAttribute atomic = new PathAttribute(TypeCode.ATOMIC_AGGREGATE, false,
209 // true, true, false, null);
210 // assertEquals(atomic, attrs.get(4));
212 // final PathAttribute comm = new PathAttribute(TypeCode.COMMUNITIES, false,
213 // true, true, false, comms);
214 // assertEquals(comm, attrs.get(5));
218 // final Set<IPv4Prefix> nlri = Sets.newHashSet(pref1, pref2, pref3);
219 // assertEquals(nlri, ret.getBgpUpdateMessageBuilder().getNlri());
221 final BaseBGPObjectState state = new BaseBGPObjectState(BGPOrigin.IGP, null);
222 final NetworkRouteState<IPv4Address> routeState = new NetworkRouteState<>(new NetworkObjectState(asPath, comms, Collections.<ExtendedCommunity> emptySet()), nextHop);
226 final Set<BGPObject> addedObjects = Sets.newHashSet();
228 final BGPRoute<IPv4Address> route1 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("172.17.2.0/24"), state, routeState);
230 addedObjects.add(route1);
232 final BGPRoute<IPv4Address> route2 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("172.17.1.0/24"), state, routeState);
234 addedObjects.add(route2);
236 final BGPRoute<IPv4Address> route3 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("172.17.0.0/24"), state, routeState);
238 addedObjects.add(route3);
240 final BGPUpdateMessage expectedMessage = new BGPUpdateMessageImpl(addedObjects, Collections.<Identifier> emptySet());
242 assertEquals(expectedMessage, message);
247 * Tests IPv6 NEXT_HOP, NLRI, ORIGIN.IGP, MULTI_EXIT_DISC, ORIGINATOR-ID, CLUSTER_LIST.
249 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
250 * 00 80 <- length (128) - including header
252 * 00 00 <- withdrawn routes length
253 * 00 69 <- total path attribute length (105)
254 * 40 <- attribute flags
255 * 01 <- attribute type code (origin)
256 * 01 <- attribute length
257 * 00 <- Origin value (IGP)
258 * 40 <- attribute flags
259 * 02 <- attribute type code (as path)
260 * 06 <- attribute length
262 * 01 <- path segment count
263 * 00 00 fd e9 <- path segment value (65001)
264 * 80 <- attribute flags
265 * 04 <- attribute type code (multi exit disc)
266 * 04 <- attribute length
267 * 00 00 00 00 <- value
268 * 80 <- attribute flags
269 * 09 <- attribute type code (originator id)
270 * 04 <- attribute length
271 * 7f 00 00 01 <- value (localhost ip)
272 * 80 <- attribute flags
273 * 0a <- attribute type code (cluster list)
274 * 08 <- attribute length
275 * 01 02 03 04 <- value
276 * 05 06 07 08 <- value
277 * 80 <- attribute flags
278 * 0e <- attribute type code (mp reach nlri)
279 * 40 <- attribute length
280 * 00 02 <- AFI (Ipv6)
281 * 01 <- SAFI (Unicast)
282 * 20 <- length of next hop
283 * 20 01 0d b8 00 00 00 00 00 00 00 00 00 00 00 01 <- global
284 * fe 80 00 00 00 00 00 00 c0 01 0b ff fe 7e 00 <- link local
288 * 40 20 01 0d b8 00 01 00 02 <- IPv6 Prefix (2001:db8:1:2:: / 64)
289 * 40 20 01 0d b8 00 01 00 01 <- IPv6 Prefix (2001:db8:1:1:: / 64)
290 * 40 20 01 0d b8 00 01 00 00 <- IPv6 Prefix (2001:db8:1:: / 64)
294 public void testGetUpdateMessage2() throws Exception {
295 final byte[] body = ByteArray.cutBytes(inputBytes.get(1), BGPMessageFactoryImpl.COMMON_HEADER_LENGTH);
296 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(1), BGPMessageFactoryImpl.MARKER_LENGTH,
297 BGPMessageFactoryImpl.LENGTH_FIELD_LENGTH));
298 final BGPUpdateEvent ret = BGPUpdateMessageParser.parse(body, messageLength);
300 assertTrue(ret instanceof BGPUpdateMessage);
301 final BGPUpdateMessage message = (BGPUpdateMessage) ret;
305 assertEquals(Collections.EMPTY_SET, message.getRemovedObjects());
309 final ASPath asPath = new ASPath(Lists.newArrayList(new ASNumber(65001)));
311 final IPv6NextHop nextHop = IPv6NextHop.forString("2001:db8::1", "fe80::c001:bff:fe7e:0");
313 // final List<ClusterIdentifier> clusters = Lists.newArrayList(
314 // new ClusterIdentifier(new byte[] { 1, 2, 3, 4}),
315 // new ClusterIdentifier(new byte[] { 5, 6, 7, 8}));
317 // check path attributes
319 // final PathAttribute originAttr = new PathAttribute(TypeCode.ORIGIN, false,
320 // true, false, false, BGPOrigin.IGP);
321 // assertEquals(originAttr, attrs.get(0));
323 // final PathAttribute asPathAttr = new PathAttribute(TypeCode.AS_PATH, false,
324 // true, false, false, asPath);
325 // assertEquals(asPathAttr, attrs.get(1));
327 // final PathAttribute multiExitDisc = new PathAttribute(
328 // TypeCode.MULTI_EXIT_DISC, true, false, false, false, 0);
329 // assertEquals(multiExitDisc, attrs.get(2));
331 // final PathAttribute originatorAttr = new PathAttribute(
332 // TypeCode.ORIGINATOR_ID, true, false, false, false, IPv4.FAMILY.addressForString("127.0.0.1"));
333 // assertEquals(originatorAttr, attrs.get(3));
335 // final PathAttribute clusterAttr = new PathAttribute(
336 // TypeCode.CLUSTER_LIST, true, false, false, false, clusters);
337 // assertEquals(clusterAttr, attrs.get(4));
339 final BaseBGPObjectState state = new BaseBGPObjectState(BGPOrigin.IGP, null);
340 final NetworkRouteState<IPv6Address> routeState = new NetworkRouteState<>(new NetworkObjectState(asPath, Collections.<Community> emptySet(), Collections.<ExtendedCommunity> emptySet()), nextHop);
344 final Set<BGPObject> addedObjects = Sets.newHashSet();
346 final BGPRoute<IPv6Address> route1 = new BGPIPv6RouteImpl(IPv6.FAMILY.prefixForString("2001:db8:1:2::/64"), state, routeState);
348 addedObjects.add(route1);
350 final BGPRoute<IPv6Address> route2 = new BGPIPv6RouteImpl(IPv6.FAMILY.prefixForString("2001:db8:1:1::/64"), state, routeState);
352 addedObjects.add(route2);
354 final BGPRoute<IPv6Address> route3 = new BGPIPv6RouteImpl(IPv6.FAMILY.prefixForString("2001:db8:1::/64"), state, routeState);
356 addedObjects.add(route3);
358 final BGPUpdateMessage expectedMessage = new BGPUpdateMessageImpl(addedObjects, Collections.<Identifier> emptySet());
360 assertEquals(expectedMessage, message);
364 * Tests more AS Numbers in AS_PATH, AGGREGATOR, ORIGIN.INCOMPLETE
366 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
367 * 00 4b <- length (75) - including header
369 * 00 00 <- withdrawn routes length
370 * 00 30 <- total path attribute length (48)
371 * 40 <- attribute flags
372 * 01 <- attribute type code (origin)
373 * 01 <- attribute length
374 * 02 <- Origin value (Incomplete)
375 * 40 <- attribute flags
376 * 02 <- attribute type code (as path)
377 * 10 <- attribute length
379 * 01 <- path segment count
380 * 00 00 00 1e <- path segment value (30)
382 * 02 <- path segment count
383 * 00 00 00 0a <- path segment value (10)
384 * 00 00 00 14 <- path segment value (20)
385 * 40 <- attribute flags
386 * 03 <- attribute type (Next hop)
387 * 04 <- attribute length
388 * 0a 00 00 09 <- value (10.0.0.9)
389 * 80 <- attribute flags
390 * 04 <- attribute type code (multi exit disc)
391 * 04 <- attribute length
392 * 00 00 00 00 <- value
393 * c0 <- attribute flags
394 * 07 <- attribute type (Aggregator)
395 * 08 <- attribute length
396 * 00 00 00 1e <- value (AS number = 30)
397 * 0a 00 00 09 <- value (IP address = 10.0.0.9)
400 * 15 ac 10 00 <- IPv4 Prefix (172.16.0.0 / 21)
403 public void testGetUpdateMessage3() throws Exception {
404 final byte[] body = ByteArray.cutBytes(inputBytes.get(2), BGPMessageFactoryImpl.COMMON_HEADER_LENGTH);
405 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(2), BGPMessageFactoryImpl.MARKER_LENGTH,
406 BGPMessageFactoryImpl.LENGTH_FIELD_LENGTH));
407 final BGPUpdateEvent ret = BGPUpdateMessageParser.parse(body, messageLength);
408 assertTrue(ret instanceof BGPUpdateMessage);
409 final BGPUpdateMessage message = (BGPUpdateMessage) ret;
412 assertEquals(Collections.EMPTY_SET, message.getRemovedObjects());
416 final ASPath asPath = new ASPath(Lists.newArrayList(new ASNumber(30)), Sets.newHashSet(new ASNumber(10), new ASNumber(20)));
418 final BGPAggregator aggregator = new BGPAggregatorImpl<IPv4Address>(new ASNumber(30), IPv4.FAMILY.addressForString("10.0.0.9"));
419 final IPv4NextHop nextHop = IPv4NextHop.forString("10.0.0.9");
421 final IPv4Prefix pref1 = IPv4.FAMILY.prefixForString("172.16.0.0/21");
423 // check path attributes
425 // final PathAttribute originAttr = new PathAttribute(TypeCode.ORIGIN, false,
426 // true, false, false, BGPOrigin.INCOMPLETE);
427 // assertEquals(originAttr, attrs.get(0));
429 // final PathAttribute asPathAttr = new PathAttribute(TypeCode.AS_PATH, false,
430 // true, false, false, asPath);
431 // assertEquals(asPathAttr, attrs.get(1));
433 // final PathAttribute nextHopAttr = new PathAttribute(TypeCode.NEXT_HOP, false,
434 // true, false, false, nextHop);
435 // assertEquals(nextHopAttr, attrs.get(2));
437 // final PathAttribute multiExitDisc = new PathAttribute(
438 // TypeCode.MULTI_EXIT_DISC, true, false, false, false, 0);
439 // assertEquals(multiExitDisc, attrs.get(3));
441 // final PathAttribute agg = new PathAttribute(TypeCode.AGGREGATOR, true, true,
442 // false, false, aggregator);
443 // assertEquals(agg, attrs.get(4));
447 // final Set<IPv4Prefix> nlri = Sets.newHashSet(pref1);
448 // assertEquals(nlri, ret.getBgpUpdateMessageBuilder().getNlri());
450 final BaseBGPObjectState state = new BaseBGPObjectState(BGPOrigin.INCOMPLETE, aggregator);
451 final NetworkRouteState<IPv4Address> routeState = new NetworkRouteState<>(new NetworkObjectState(asPath, Collections.<Community> emptySet(), Collections.<ExtendedCommunity> emptySet()), nextHop);
455 final Set<BGPObject> addedObjects = Sets.newHashSet();
457 final BGPRoute<IPv4Address> route1 = new BGPIPv4RouteImpl(pref1, state, routeState);
459 addedObjects.add(route1);
461 final BGPUpdateMessage expectedMessage = new BGPUpdateMessageImpl(addedObjects, Collections.<Identifier> emptySet());
463 assertEquals(expectedMessage, message);
468 * Tests empty AS_PATH, ORIGIN.EGP, LOCAL_PREF, EXTENDED_COMMUNITIES (Ipv4 Addr specific)
470 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
471 * 00 4A <- length (73) - including header
473 * 00 00 <- withdrawn routes length
474 * 00 27 <- total path attribute length (39)
475 * 40 <- attribute flags
476 * 01 <- attribute type code (Origin)
477 * 01 <- attribute length
478 * 01 <- Origin value (EGP)
479 * 40 <- attribute flags
480 * 02 <- attribute type code (As path)
481 * 00 <- attribute length
482 * 40 <- attribute flags
483 * 03 <- attribute type (Next hop)
484 * 04 <- attribute length
485 * 03 03 03 03 <- value (3.3.3.3)
486 * 80 <- attribute flags
487 * 04 <- attribute type code (Multi exit disc)
488 * 04 <- attribute length
489 * 00 00 00 00 <- value
490 * 40 <- attribute flags
491 * 05 <- attribute type (Local Pref)
492 * 04 <- attribute length
493 * 00 00 00 64 <- value (100)
494 * 80 <- attribute flags
495 * 10 <- attribute type (extended community)
496 * 08 <- attribute length
497 * 01 04 <- value (type - Ipv4 Address Specific Extended Community)
498 * c0 a8 01 00 <- value (global adm. 198.162.1.0)
499 * 12 34 <- value (local adm. 4660)
502 * 18 0a 1e 03 <- IPv4 Prefix (10.30.3.0 / 24)
503 * 18 0a 1e 02 <- IPv4 Prefix (10.30.2.0 / 24)
504 * 18 0a 1e 01 <- IPv4 Prefix (10.30.1.0 / 24)
507 public void testGetUpdateMessage4() throws Exception {
508 final byte[] body = ByteArray.cutBytes(inputBytes.get(3), BGPMessageFactoryImpl.COMMON_HEADER_LENGTH);
509 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(3), BGPMessageFactoryImpl.MARKER_LENGTH,
510 BGPMessageFactoryImpl.LENGTH_FIELD_LENGTH));
511 final BGPUpdateEvent ret = BGPUpdateMessageParser.parse(body, messageLength);
513 assertTrue(ret instanceof BGPUpdateMessage);
514 final BGPUpdateMessage message = (BGPUpdateMessage) ret;
518 assertEquals(Collections.EMPTY_SET, message.getRemovedObjects());
522 final IPv4NextHop nextHop = IPv4NextHop.forString("3.3.3.3");
524 final Set<ExtendedCommunity> comms = Sets.newHashSet((ExtendedCommunity) new Inet4SpecificExtendedCommunity(false, 4, IPv4.FAMILY.addressForString("192.168.1.0"), new byte[] {
527 // check path attributes
529 // final PathAttribute originAttr = new PathAttribute(TypeCode.ORIGIN, false,
530 // true, false, false, BGPOrigin.EGP);
531 // assertEquals(originAttr, attrs.get(0));
533 // final PathAttribute asPathAttr = new PathAttribute(TypeCode.AS_PATH, false,
534 // true, false, false, asPath);
535 // assertEquals(asPathAttr, attrs.get(1));
537 // final PathAttribute nextHopAttr = new PathAttribute(TypeCode.NEXT_HOP, false,
538 // true, false, false, nextHop);
539 // assertEquals(nextHopAttr, attrs.get(2));
541 // final PathAttribute multiExitDisc = new PathAttribute(
542 // TypeCode.MULTI_EXIT_DISC, true, false, false, false, 0);
543 // assertEquals(multiExitDisc, attrs.get(3));
545 // final PathAttribute localPref = new PathAttribute(TypeCode.LOCAL_PREF, false,
546 // true, false, false, 100);
547 // assertEquals(localPref, attrs.get(4));
551 // final Set<IPv4Prefix> nlri = Sets.newHashSet(pref1, pref2, pref3);
552 // assertEquals(nlri, ret.getBgpUpdateMessageBuilder().getNlri());
554 final BaseBGPObjectState state = new BaseBGPObjectState(BGPOrigin.EGP, null);
555 final NetworkRouteState<IPv4Address> routeState = new NetworkRouteState<>(new NetworkObjectState(ASPath.EMPTY, Collections.<Community> emptySet(), comms), nextHop);
559 final Set<BGPObject> addedObjects = Sets.newHashSet();
561 final BGPRoute<IPv4Address> route1 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("10.30.3.0/24"), state, routeState);
563 addedObjects.add(route1);
565 final BGPRoute<IPv4Address> route2 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("10.30.2.0/24"), state, routeState);
567 addedObjects.add(route2);
569 final BGPRoute<IPv4Address> route3 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("10.30.1.0/24"), state, routeState);
571 addedObjects.add(route3);
573 final BGPUpdateMessage expectedMessage = new BGPUpdateMessageImpl(addedObjects, Collections.<Identifier> emptySet());
575 assertEquals(expectedMessage, message);
579 * Tests withdrawn routes.
581 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
582 * 00 1c <- length (28) - including header
584 * 00 05 <- withdrawn routes length (5)
585 * 1e ac 10 00 04 <- route (172.16.0.4)
586 * 00 00 <- total path attribute length
589 public void testGetUpdateMessage5() throws Exception {
590 final byte[] body = ByteArray.cutBytes(inputBytes.get(4), BGPMessageFactoryImpl.COMMON_HEADER_LENGTH);
591 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(4), BGPMessageFactoryImpl.MARKER_LENGTH,
592 BGPMessageFactoryImpl.LENGTH_FIELD_LENGTH));
593 final BGPUpdateEvent ret = BGPUpdateMessageParser.parse(body, messageLength);
595 assertTrue(ret instanceof BGPUpdateMessage);
596 final BGPUpdateMessage message = (BGPUpdateMessage) ret;
600 final IPv4Prefix pref1 = IPv4.FAMILY.prefixForString("172.16.0.4/30");
604 final BGPUpdateEvent expectedMessage = new BGPUpdateMessageImpl(Collections.<BGPObject> emptySet(), Sets.newHashSet((Identifier) pref1));
606 assertEquals(expectedMessage, message);
612 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
613 * 00 17 <- length (23) - including header
615 * 00 00 <- withdrawn routes length
616 * 00 00 <- total path attribute length
619 public void testEORIpv4() throws Exception {
620 final byte[] body = ByteArray.cutBytes(inputBytes.get(5), BGPMessageFactoryImpl.COMMON_HEADER_LENGTH);
621 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(5), BGPMessageFactoryImpl.MARKER_LENGTH,
622 BGPMessageFactoryImpl.LENGTH_FIELD_LENGTH));
623 final BGPUpdateEvent ret = BGPUpdateMessageParser.parse(body, messageLength);
625 assertTrue(ret instanceof BGPUpdateSynchronized);
626 final BGPUpdateSynchronized message = (BGPUpdateSynchronized) ret;
628 final BGPUpdateSynchronized expectedMessage = new BGPUpdateSynchronized() {
630 private static final long serialVersionUID = -5128220996581568885L;
633 public BGPTableType getTableType() {
634 return new BGPTableType(BGPAddressFamily.IPv4, BGPSubsequentAddressFamily.Unicast);
637 assertEquals(expectedMessage.getTableType(), message.getTableType());
641 * End of Rib for Ipv6 consists of empty MP_UNREACH_NLRI, with AFI 2 and SAFI 1
643 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
644 * 00 1d <- length (29) - including header
646 * 00 00 <- withdrawn routes length
647 * 00 06 <- total path attribute length
648 * 80 <- attribute flags
649 * 0f <- attribute type (15 - MP_UNREACH_NLRI)
650 * 03 <- attribute length
651 * 00 02 <- value (AFI 2: IPv6)
652 * 01 <- value (SAFI 1)
655 public void testEORIpv6() throws Exception {
656 final byte[] body = ByteArray.cutBytes(inputBytes.get(6), BGPMessageFactoryImpl.COMMON_HEADER_LENGTH);
657 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(6), BGPMessageFactoryImpl.MARKER_LENGTH,
658 BGPMessageFactoryImpl.LENGTH_FIELD_LENGTH));
659 final BGPUpdateEvent ret = BGPUpdateMessageParser.parse(body, messageLength);
661 assertTrue(ret instanceof BGPUpdateSynchronized);
662 final BGPUpdateSynchronized message = (BGPUpdateSynchronized) ret;
666 final BGPUpdateSynchronized expectedMessage = new BGPUpdateSynchronized() {
668 private static final long serialVersionUID = -4811827044855997014L;
671 public BGPTableType getTableType() {
672 return new BGPTableType(BGPAddressFamily.IPv6, BGPSubsequentAddressFamily.Unicast);
675 assertEquals(expectedMessage.getTableType(), message.getTableType());
679 * End of Rib for LS consists of empty MP_UNREACH_NLRI, with AFI 16388 and SAFI 71
681 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
682 * 00 1d <- length (29) - including header
684 * 00 00 <- withdrawn routes length
685 * 00 06 <- total path attribute length
686 * 80 <- attribute flags
687 * 0f <- attribute type (15 - MP_UNREACH_NLRI)
688 * 03 <- attribute length
689 * 40 04 <- value (AFI 16388: LS)
690 * 47 <- value (SAFI 71)
693 public void testEORLS() throws Exception {
694 final byte[] body = ByteArray.cutBytes(inputBytes.get(7), BGPMessageFactoryImpl.COMMON_HEADER_LENGTH);
695 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(7), BGPMessageFactoryImpl.MARKER_LENGTH,
696 BGPMessageFactoryImpl.LENGTH_FIELD_LENGTH));
697 final BGPUpdateEvent ret = BGPUpdateMessageParser.parse(body, messageLength);
699 assertTrue(ret instanceof BGPUpdateSynchronized);
700 final BGPUpdateSynchronized message = (BGPUpdateSynchronized) ret;
704 final BGPUpdateSynchronized expectedMessage = new BGPUpdateSynchronized() {
706 private static final long serialVersionUID = 3677704232769769042L;
709 public BGPTableType getTableType() {
710 return new BGPTableType(BGPAddressFamily.LinkState, BGPSubsequentAddressFamily.Unicast);
714 assertEquals(expectedMessage.getTableType(), message.getTableType());
718 * Tests BGP Link Ipv4
720 00 00 <- withdrawn routes length
721 01 48 <- total path attribute length (328)
722 90 <- attribute flags
723 0e <- attribute type code (MP reach)
724 01 2c <- attribute extended length (300)
725 40 04 <- AFI (16388 - Linkstate)
726 47 <- SAFI (71 - Linkstate)
727 04 <- next hop length
728 19 19 19 01 <- nexthop (25.25.25.1)
731 00 02 <- NLRI type (2 - linkNLRI)
732 00 5d <- NLRI length (93)
733 03 <- ProtocolID - OSPF
734 00 00 00 00 00 00 00 01 <- identifier
736 01 00 <- local node descriptor type (256)
738 02 00 <- node descriptor type (member AS - 512)
740 00 00 00 64 <- value (100)
741 02 01 <- node descriptor type (bgpId - 513)
743 19 19 19 01 <- bgpId (25.25.25.1)
744 02 02 <- node descriptor type (areaId - 514)
747 02 03 <- node descriptor type (routeId - 515)
749 03 03 03 04 0b 0b 0b 03 <- OSPF Router Id
751 01 01 <- remote node descriptor type (257)
753 02 00 <- node descriptor type (member AS - 512)
755 00 00 00 64 <- value (100)
756 02 01 <- node descriptor type (bgpId - 513)
758 19 19 19 01 <- bgpId (25.25.25.1)
759 02 02 <- node descriptor type (areaId - 514)
762 02 03 <- node descriptor type (routeId - 515)
764 03 03 03 04 <- OSPF Router Id
766 01 03 <- link descriptor type (IPv4 interface address - 259)
768 0b 0b 0b 03 <- value (11.11.11.3)
770 00 02 <- NLRI type (2 - linkNLRI)
771 00 5d <- NLRI length (93)
772 03 <- ProtocolID - OSPF
773 00 00 00 00 00 00 00 01 <- identifier
775 01 00 <- local node descriptor type (256)
777 02 00 <- node descriptor type (member AS - 512)
779 00 00 00 64 <- value (100)
780 02 01 <- node descriptor type (bgpId - 513)
782 19 19 19 01 <- bgpId (25.25.25.1)
783 02 02 <- node descriptor type (areaId - 514)
786 02 03 <- node descriptor type (routeId - 515)
788 03 03 03 04 0b 0b 0b 03 <- OSPF Router Id
790 01 01 <- remote node descriptor type (257)
792 02 00 <- node descriptor type (member AS - 512)
794 00 00 00 64 <- value (100)
795 02 01 <- node descriptor type (bgpId - 513)
797 19 19 19 01 <- bgpId (25.25.25.1)
798 02 02 <- node descriptor type (areaId - 514)
801 02 03 <- node descriptor type (routeId - 515)
803 01 01 01 02 <- OSPF Router Id
805 01 03 <- link descriptor type (IPv4 interface address - 259)
807 0b 0b 0b 01 <- value (11.11.11.1)
809 00 02 <- NLRI type (2 - linkNLRI)
810 00 5d <- NLRI length (93)
811 03 <- ProtocolID - OSPF
812 00 00 00 00 00 00 00 01 <- identifier
814 01 00 <- local node descriptor type (256)
816 02 00 <- node descriptor type (member AS - 512)
818 00 00 00 64 <- value (100)
819 02 01 <- node descriptor type (bgpId - 513)
821 19 19 19 01 <- bgpId (25.25.25.1)
822 02 02 <- node descriptor type (areaId - 514)
825 02 03 <- node descriptor type (routeId - 515)
827 01 01 01 02 <- OSPF Router Id
829 01 01 <- remote node descriptor type (257)
831 02 00 <- node descriptor type (member AS - 512)
833 00 00 00 64 <- value (100)
834 02 01 <- node descriptor type (bgpId - 513)
836 19 19 19 01 <- bgpId (25.25.25.1)
837 02 02 <- node descriptor type (areaId - 514)
840 02 03 <- node descriptor type (routeId - 515)
842 03 03 03 04 0b 0b 0b 03 <- OSPF Router Id
844 01 03 <- link descriptor type (IPv4 interface address - 259)
846 0b 0b 0b 01 <- value (11.11.11.1)
848 40 <- attribute flags
849 01 <- attribute type (Origin)
850 01 <- attribute length
852 40 <- attribute flags
853 02 <- attribute type (AS Path)
855 40 <- attribute flags
856 05 <- attribute type (local pref)
859 c0 <- attribute flags
860 63 <- attribute type (Link STATE - 99)
862 04 47 <- link attribute (1095 - Metric)
867 public void testBGPLink() throws Exception {
868 final byte[] body = ByteArray.cutBytes(inputBytes.get(8), BGPMessageFactoryImpl.COMMON_HEADER_LENGTH);
869 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(8), BGPMessageFactoryImpl.MARKER_LENGTH,
870 BGPMessageFactoryImpl.LENGTH_FIELD_LENGTH));
871 final BGPUpdateEvent ret = BGPUpdateMessageParser.parse(body, messageLength);
873 assertTrue(ret instanceof BGPUpdateMessage);
874 final BGPUpdateMessage message = (BGPUpdateMessage) ret;
878 assertEquals(Collections.EMPTY_SET, message.getRemovedObjects());
880 // network object state
881 final NetworkObjectState objState = new NetworkObjectState(ASPath.EMPTY, Collections.<Community> emptySet(), Collections.<ExtendedCommunity> emptySet());
882 final BaseBGPObjectState state = new BaseBGPObjectState(BGPOrigin.IGP, null);
884 // network link state
885 final DefaultingTypesafeContainer<Metric<?>> container = new DefaultingTypesafeContainer<Metric<?>>();
886 container.setDefaultEntry(new IGPMetric(1));
887 final NetworkLinkState linkState = new NetworkLinkState(objState, container, null, LinkProtectionType.UNPROTECTED, null, null, null);
889 final NodeIdentifierFactory f100 = new NodeIdentifierFactory(new ASNumber(100), new DomainIdentifier(new byte[] { 25, 25, 25, 1 }), new AreaIdentifier(new byte[] {
892 final NodeIdentifier nodeid1 = f100.identifierForRouter(new OSPFv3LANIdentifier(new OSPFRouterIdentifier(new byte[] { 3, 3, 3, 4 }), new OSPFInterfaceIdentifier(new byte[] {
893 0x0b, 0x0b, 0x0b, 0x03 })));
894 final NodeIdentifier nodeid2 = f100.identifierForRouter(new OSPFRouterIdentifier(new byte[] { 3, 3, 3, 4 }));
896 final NodeIdentifier nodeid3 = f100.identifierForRouter(new OSPFRouterIdentifier(new byte[] { 1, 1, 1, 2 }));
900 final LinkIdentifier linkId1 = new LinkIdentifier(null, new LinkAnchor(nodeid1, new IPv4InterfaceIdentifier(IPv4.FAMILY.addressForString("11.11.11.3"))), new LinkAnchor(nodeid2, null));
901 final LinkIdentifier linkId2 = new LinkIdentifier(null, new LinkAnchor(nodeid1, new IPv4InterfaceIdentifier(IPv4.FAMILY.addressForString("11.11.11.1"))), new LinkAnchor(nodeid3, null));
902 final LinkIdentifier linkId3 = new LinkIdentifier(null, new LinkAnchor(nodeid3, new IPv4InterfaceIdentifier(IPv4.FAMILY.addressForString("11.11.11.1"))), new LinkAnchor(nodeid1, null));
904 final BGPLink link1 = new BGPLinkImpl(state, linkId1, linkState);
905 final BGPLink link2 = new BGPLinkImpl(state, linkId2, linkState);
906 final BGPLink link3 = new BGPLinkImpl(state, linkId3, linkState);
908 final BGPUpdateMessage expectedMessage = new BGPUpdateMessageImpl(Sets.newHashSet((BGPObject) link1, (BGPObject) link2,
909 (BGPObject) link3), Collections.<Identifier> emptySet());
911 assertEquals(expectedMessage, message);
917 * 00 00 <- withdrawn routes length
918 00 b2 <- total path attribute length (178)
919 90 <- attribute flags
920 0e <- attribute type code (MP reach)
921 00 a0 <- attribute extended length (160)
922 40 04 <- AFI (16388 - Linkstate)
923 47 <- SAFI (71 - Linkstate)
924 04 <- next hop length
925 19 19 19 01 - nexthop (25.25.25.1)
927 00 01 <- NLRI type (1 - nodeNLRI)
928 00 31 <- NLRI length (49)
929 03 <- ProtocolID - OSPF
930 00 00 00 00 00 00 00 01 <- identifier
932 01 00 <- local node descriptor type (256)
934 02 00 <- node descriptor type (member AS - 512)
936 00 00 00 64 <- value (100)
937 02 01 <- node descriptor type (bgpId - 513)
939 19 19 19 01 <- bgpId (25.25.25.1)
940 02 02 <- node descriptor type (areaId - 514)
943 02 03 <- node descriptor type (routeId - 515)
945 03 03 03 04 0b 0b 0b 03 <- OSPF Router Id
947 00 01 <- NLRI type (1 - nodeNLRI)
948 00 2d <- NLRI length (45)
949 03 <- ProtocolID - OSPF
950 00 00 00 00 00 00 00 01 <- identifier
952 01 00 <- local node descriptor type (256)
954 02 00 <- node descriptor type (member AS - 512)
956 00 00 00 64 <- value (100)
957 02 01 <- node descriptor type (bgpId - 513)
959 19 19 19 01 <- bgpId (25.25.25.1)
960 02 02 <- node descriptor type (areaId - 514)
963 02 03 <- node descriptor type (routeId - 515)
965 03 03 03 04 <- OSPF Router Id
967 00 01 <- NLRI type (1 - nodeNLRI)
968 00 2d <- NLRI length (45)
969 03 <- ProtocolID - OSPF
970 00 00 00 00 00 00 00 01 <- identifier
971 01 00 <- local node descriptor type (256)
973 02 00 <- node descriptor type (member AS - 512)
975 00 00 00 64 <- value (100)
976 02 01 <- node descriptor type (bgpId - 513)
978 19 19 19 01 <- bgpId (25.25.25.1)
979 02 02 <- node descriptor type (areaId - 514)
982 02 03 <- node descriptor type (routeId - 515)
984 01 01 01 02 <- OSPF Router Id
986 40 <- attribute flags
987 01 <- attribute type (Origin)
988 01 <- attribute length
990 40 <- attribute flags
991 02 <- attribute type (AS Path)
993 40 <- attribute flags
994 05 <- attribute type (local pref)
999 public void testBGPNode() throws Exception {
1000 final byte[] body = ByteArray.cutBytes(inputBytes.get(9), BGPMessageFactoryImpl.COMMON_HEADER_LENGTH);
1001 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(9), BGPMessageFactoryImpl.MARKER_LENGTH,
1002 BGPMessageFactoryImpl.LENGTH_FIELD_LENGTH));
1003 final BGPUpdateEvent ret = BGPUpdateMessageParser.parse(body, messageLength);
1005 assertTrue(ret instanceof BGPUpdateMessage);
1006 final BGPUpdateMessage message = (BGPUpdateMessage) ret;
1010 assertEquals(Collections.EMPTY_SET, message.getRemovedObjects());
1012 // network object state
1013 final NetworkObjectState objState = new NetworkObjectState(ASPath.EMPTY, Collections.<Community> emptySet(), Collections.<ExtendedCommunity> emptySet());
1014 final BaseBGPObjectState state = new BaseBGPObjectState(BGPOrigin.IGP, null);
1015 final NetworkNodeState nstate = new NetworkNodeState(objState, Collections.<TopologyIdentifier> emptySet(), Collections.<ISISAreaIdentifier> emptySet(), false, false, false, false, Collections.<RouterIdentifier> emptySet(), null);
1017 // network link state
1019 final NodeIdentifierFactory f100 = new NodeIdentifierFactory(new ASNumber(100), new DomainIdentifier(new byte[] { 25, 25, 25, 1 }), new AreaIdentifier(new byte[] {
1022 final NodeIdentifier nodeid1 = f100.identifierForRouter(new OSPFv3LANIdentifier(new OSPFRouterIdentifier(new byte[] { 3, 3, 3, 4 }), new OSPFInterfaceIdentifier(new byte[] {
1023 0x0b, 0x0b, 0x0b, 0x03 })));
1024 final NodeIdentifier nodeid2 = f100.identifierForRouter(new OSPFRouterIdentifier(new byte[] { 3, 3, 3, 4 }));
1026 final NodeIdentifier nodeid3 = f100.identifierForRouter(new OSPFRouterIdentifier(new byte[] { 1, 1, 1, 2 }));
1028 // check API message
1030 final BGPNode node1 = new BGPNodeImpl(state, nodeid1, nstate);
1031 final BGPNode node2 = new BGPNodeImpl(state, nodeid2, nstate);
1032 final BGPNode node3 = new BGPNodeImpl(state, nodeid3, nstate);
1034 final BGPUpdateMessage expectedMessage = new BGPUpdateMessageImpl(Sets.newHashSet((BGPObject) node1, (BGPObject) node2,
1035 (BGPObject) node3), Collections.<Identifier> emptySet());
1037 assertEquals(expectedMessage, message);
1041 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
1042 * 00 98 <- length (69) - including header
1043 * 01 <- message type
1045 * 00 64 <- My AS Number (AS TRANS in this case)
1046 * 00 b4 <- Hold Time
1047 * 00 00 00 00 <- BGP Identifier
1048 * 28 <- Optional Parameters Length
1049 * 02 <- opt. param. type (capabilities)
1051 * 01 <- capability code (MP Extensions for BGP4)
1053 * 00 01 00 01 <- AFI 1, SAFI 1
1054 * 02 <- opt. param. type (capabilities)
1056 * 01 <- capability code (MP Extensions for BGP4)
1058 * 00 02 00 01 <- AFI 2, SAFI 1
1059 * 02 <- opt. param. type (capabilities)
1061 * 01 <- capability code (MP Extensions for BGP4)
1063 * 40 04 00 47 <- AFI 16388, SAFI 71
1064 * 02 <- opt. param. type (capabilities)
1066 * 80 <- capability code (private)
1068 * 02 <- opt. param. type (capabilities)
1070 * 02 <- capability code (Route refresh)
1072 * 02 <- opt. param. type (capabilities)
1074 * 41 <- capability code (AS4 octet support)
1076 * 00 00 00 64 <- AS number
1079 public void testOpenMessage() throws Exception {
1080 final BGPMessageFactoryImpl msgFactory = new BGPMessageFactoryImpl();
1081 final BGPOpenMessage open = (BGPOpenMessage) msgFactory.parse(inputBytes.get(13)).get(0);
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());