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.assertNull;
14 import java.io.ByteArrayOutputStream;
15 import java.io.IOException;
16 import java.io.InputStream;
17 import java.util.ArrayList;
18 import java.util.HashSet;
19 import java.util.List;
22 import org.junit.BeforeClass;
23 import org.junit.Ignore;
24 import org.junit.Test;
25 import org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl;
26 import org.opendaylight.protocol.bgp.parser.impl.message.BGPUpdateMessageParser;
27 import org.opendaylight.protocol.bgp.parser.spi.MessageRegistry;
28 import org.opendaylight.protocol.bgp.parser.spi.MessageUtil;
29 import org.opendaylight.protocol.concepts.IGPMetric;
30 import org.opendaylight.protocol.concepts.IPv4;
31 import org.opendaylight.protocol.concepts.IPv4Prefix;
32 import org.opendaylight.protocol.concepts.Metric;
33 import org.opendaylight.protocol.util.ByteArray;
34 import org.opendaylight.protocol.util.DefaultingTypesafeContainer;
35 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
36 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
37 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
38 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev130918.LinkstateAddressFamily;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev130918.LinkstateSubsequentAddressFamily;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.Open;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.Update;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.UpdateBuilder;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.open.BgpParameters;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.open.bgp.parameters.CParameters;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.path.attributes.AggregatorBuilder;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.path.attributes.as.path.SegmentsBuilder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.update.WithdrawnRoutesBuilder;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130918.BgpTableType;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130918.PathAttributes1;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130918.open.bgp.parameters.c.parameters.CMultiprotocol;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.AddressFamily;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.AsPathSegment;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpAggregator;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Community;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv6AddressFamily;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.SubsequentAddressFamily;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.as.path.segment.c.segment.CAListBuilder;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.as.path.segment.c.segment.CASetBuilder;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.as.path.segment.c.segment.c.a.list.AsSequence;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.as.path.segment.c.segment.c.a.list.AsSequenceBuilder;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.ExtendedCommunity;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.extended.community.CInet4SpecificExtendedCommunityBuilder;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.extended.community.c.inet4.specific.extended.community.Inet4SpecificExtendedCommunityBuilder;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.CIpv4NextHop;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.CIpv4NextHopBuilder;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.CIpv6NextHop;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.CIpv6NextHopBuilder;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.c.ipv4.next.hop.Ipv4NextHopBuilder;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.c.ipv6.next.hop.Ipv6NextHopBuilder;
74 import com.google.common.collect.Lists;
75 import com.google.common.collect.Sets;
77 public class BGPParserTest {
80 * Used by other tests as well
82 static final List<byte[]> inputBytes = new ArrayList<byte[]>();
84 private static int COUNTER = 17;
86 private static int MAX_SIZE = 300;
88 private static BGPUpdateMessageParser updateParser;
91 public static void setUp() throws Exception {
92 updateParser = new BGPUpdateMessageParser(SingletonProviderContext.getInstance().getAttributeRegistry());
94 for (int i = 1; i <= COUNTER; i++) {
95 final String name = "/up" + i + ".bin";
96 final InputStream is = BGPParserTest.class.getResourceAsStream(name);
98 throw new IOException("Failed to get resource " + name);
101 final ByteArrayOutputStream bis = new ByteArrayOutputStream();
102 final byte[] data = new byte[MAX_SIZE];
104 while ((nRead = is.read(data, 0, data.length)) != -1) {
105 bis.write(data, 0, nRead);
109 inputBytes.add(bis.toByteArray());
114 public void testResource() {
115 assertNotNull(inputBytes);
119 * Tests IPv4 NEXT_HOP, ATOMIC_AGGREGATE, COMMUNITY, NLRI
121 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
122 * 00 54 <- length (84) - including header
124 * 00 00 <- withdrawn routes length
125 * 00 31 <- total path attribute length (49)
126 * 40 <- attribute flags
127 * 01 <- attribute type code (origin)
128 * 01 <- attribute length
129 * 00 <- Origin value (IGP)
130 * 40 <- attribute flags
131 * 02 <- attribute type code (as path)
132 * 06 <- attribute length
134 * 01 <- path segment count
135 * 00 00 fd ea <- path segment value (65002)
136 * 40 <- attribute flags
137 * 03 <- attribute type code (Next Hop)
138 * 04 <- attribute length
139 * 10 00 00 02 <- value (10.0.0.2)
140 * 80 <- attribute flags
141 * 04 <- attribute type code (multi exit disc)
142 * 04 <- attribute length
143 * 00 00 00 00 <- value
144 * 64 <- attribute flags
145 * 06 <- attribute type code (atomic aggregate)
146 * 00 <- attribute length
147 * 64 <- attribute flags
148 * 08 <- attribute type code (community)
149 * 10 <- attribute length FF FF FF
150 * 01 <- value (NO_EXPORT)
151 * FF FF FF 02 <- value (NO_ADVERTISE)
152 * FF FF FF 03 <- value (NO_EXPORT_SUBCONFED)
153 * FF FF FF 10 <- unknown Community
156 * 18 ac 11 02 <- IPv4 Prefix (172.17.2.0 / 24)
157 * 18 ac 11 01 <- IPv4 Prefix (172.17.1.0 / 24)
158 * 18 ac 11 00 <- IPv4 Prefix (172.17.0.0 / 24)
162 // FIXME: to be fixed in testing phase
163 public void testGetUpdateMessage1() throws Exception {
165 final byte[] body = ByteArray.cutBytes(inputBytes.get(0), MessageUtil.COMMON_HEADER_LENGTH);
166 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(0), MessageUtil.MARKER_LENGTH,
167 MessageUtil.LENGTH_FIELD_LENGTH));
168 final Update message = updateParser.parseMessageBody(body, messageLength);
172 assertNull(message.getWithdrawnRoutes());
176 final List<AsSequence> asnums = Lists.newArrayList(new AsSequenceBuilder().setAs(new AsNumber(65002L)).build());
177 final List<AsPathSegment> asPath = Lists.newArrayList();
178 asPath.add(new SegmentsBuilder().setCSegment(new CAListBuilder().setAsSequence(asnums).build()).build());
180 final CIpv4NextHop nextHop = new CIpv4NextHopBuilder().setIpv4NextHop(
181 new Ipv4NextHopBuilder().setGlobal(new Ipv4Address("10.0.0.2")).build()).build();
183 final Set<Community> comms = new HashSet<>();
184 comms.add(CommunityUtil.NO_EXPORT);
185 comms.add(CommunityUtil.NO_ADVERTISE);
186 comms.add(CommunityUtil.NO_EXPORT_SUBCONFED);
187 comms.add(CommunityUtil.create(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 routeState = new NetworkRouteState(new NetworkObjectState(asPath, comms, Collections.<ExtendedCommunity> emptySet()), nextHop);
225 // final Set<BGPObject> addedObjects = Sets.newHashSet();
227 // final BGPRoute route1 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("172.17.2.0/24"), state, routeState);
229 // addedObjects.add(route1);
231 // final BGPRoute route2 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("172.17.1.0/24"), state, routeState);
233 // addedObjects.add(route2);
235 // final BGPRoute route3 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("172.17.0.0/24"), state, routeState);
237 // addedObjects.add(route3);
241 * Tests IPv6 NEXT_HOP, NLRI, ORIGIN.IGP, MULTI_EXIT_DISC, ORIGINATOR-ID, CLUSTER_LIST.
243 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
244 * 00 80 <- length (128) - including header
246 * 00 00 <- withdrawn routes length
247 * 00 69 <- total path attribute length (105)
248 * 40 <- attribute flags
249 * 01 <- attribute type code (origin)
250 * 01 <- attribute length
251 * 00 <- Origin value (IGP)
252 * 40 <- attribute flags
253 * 02 <- attribute type code (as path)
254 * 06 <- attribute length
256 * 01 <- path segment count
257 * 00 00 fd e9 <- path segment value (65001)
258 * 80 <- attribute flags
259 * 04 <- attribute type code (multi exit disc)
260 * 04 <- attribute length
261 * 00 00 00 00 <- value
262 * 80 <- attribute flags
263 * 09 <- attribute type code (originator id)
264 * 04 <- attribute length
265 * 7f 00 00 01 <- value (localhost ip)
266 * 80 <- attribute flags
267 * 0a <- attribute type code (cluster list)
268 * 08 <- attribute length
269 * 01 02 03 04 <- value
270 * 05 06 07 08 <- value
271 * 80 <- attribute flags
272 * 0e <- attribute type code (mp reach nlri)
273 * 40 <- attribute length
274 * 00 02 <- AFI (Ipv6)
275 * 01 <- SAFI (Unicast)
276 * 20 <- length of next hop
277 * 20 01 0d b8 00 00 00 00 00 00 00 00 00 00 00 01 <- global
278 * fe 80 00 00 00 00 00 00 c0 01 0b ff fe 7e 00 <- link local
282 * 40 20 01 0d b8 00 01 00 02 <- IPv6 Prefix (2001:db8:1:2:: / 64)
283 * 40 20 01 0d b8 00 01 00 01 <- IPv6 Prefix (2001:db8:1:1:: / 64)
284 * 40 20 01 0d b8 00 01 00 00 <- IPv6 Prefix (2001:db8:1:: / 64)
289 // FIXME: to be fixed in testing phase
290 public void testGetUpdateMessage2() throws Exception {
291 final byte[] body = ByteArray.cutBytes(inputBytes.get(1), MessageUtil.COMMON_HEADER_LENGTH);
292 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(1), MessageUtil.MARKER_LENGTH,
293 MessageUtil.LENGTH_FIELD_LENGTH));
294 final Update message = updateParser.parseMessageBody(body, messageLength);
297 assertNull(message.getWithdrawnRoutes());
300 final List<AsSequence> asnums = Lists.newArrayList(new AsSequenceBuilder().setAs(new AsNumber(65001L)).build());
301 final List<AsPathSegment> asPath = Lists.newArrayList();
302 asPath.add(new SegmentsBuilder().setCSegment(new CAListBuilder().setAsSequence(asnums).build()).build());
304 final CIpv6NextHop nextHop = new CIpv6NextHopBuilder().setIpv6NextHop(
305 new Ipv6NextHopBuilder().setGlobal(new Ipv6Address("2001:db8::1")).setLinkLocal(new Ipv6Address("fe80::c001:bff:fe7e:0")).build()).build();
307 // final List<ClusterIdentifier> clusters = Lists.newArrayList(
308 // new ClusterIdentifier(new byte[] { 1, 2, 3, 4}),
309 // new ClusterIdentifier(new byte[] { 5, 6, 7, 8}));
311 // check path attributes
313 // final PathAttribute originAttr = new PathAttribute(TypeCode.ORIGIN, false,
314 // true, false, false, BGPOrigin.IGP);
315 // assertEquals(originAttr, attrs.get(0));
317 // final PathAttribute asPathAttr = new PathAttribute(TypeCode.AS_PATH, false,
318 // true, false, false, asPath);
319 // assertEquals(asPathAttr, attrs.get(1));
321 // final PathAttribute multiExitDisc = new PathAttribute(
322 // TypeCode.MULTI_EXIT_DISC, true, false, false, false, 0);
323 // assertEquals(multiExitDisc, attrs.get(2));
325 // final PathAttribute originatorAttr = new PathAttribute(
326 // TypeCode.ORIGINATOR_ID, true, false, false, false, IPv4.FAMILY.addressForString("127.0.0.1"));
327 // assertEquals(originatorAttr, attrs.get(3));
329 // final PathAttribute clusterAttr = new PathAttribute(
330 // TypeCode.CLUSTER_LIST, true, false, false, false, clusters);
331 // assertEquals(clusterAttr, attrs.get(4));
333 // final BaseBGPObjectState state = new BaseBGPObjectState(BgpOrigin.Igp, null);
334 // final NetworkRouteState routeState = new NetworkRouteState(new NetworkObjectState(asPath, Collections.<Community> emptySet(), Collections.<ExtendedCommunity> emptySet()), nextHop);
338 // final Set<BGPObject> addedObjects = Sets.newHashSet();
340 // final BGPRoute route1 = new BGPIPv6RouteImpl(IPv6.FAMILY.prefixForString("2001:db8:1:2::/64"), state, routeState);
342 // addedObjects.add(route1);
344 // final BGPRoute route2 = new BGPIPv6RouteImpl(IPv6.FAMILY.prefixForString("2001:db8:1:1::/64"), state, routeState);
346 // addedObjects.add(route2);
348 // final BGPRoute route3 = new BGPIPv6RouteImpl(IPv6.FAMILY.prefixForString("2001:db8:1::/64"), state, routeState);
350 // addedObjects.add(route3);
354 * Tests more AS Numbers in AS_PATH, AGGREGATOR, ORIGIN.INCOMPLETE
356 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
357 * 00 4b <- length (75) - including header
359 * 00 00 <- withdrawn routes length
360 * 00 30 <- total path attribute length (48)
361 * 40 <- attribute flags
362 * 01 <- attribute type code (origin)
363 * 01 <- attribute length
364 * 02 <- Origin value (Incomplete)
365 * 40 <- attribute flags
366 * 02 <- attribute type code (as path)
367 * 10 <- attribute length
369 * 01 <- path segment count
370 * 00 00 00 1e <- path segment value (30)
372 * 02 <- path segment count
373 * 00 00 00 0a <- path segment value (10)
374 * 00 00 00 14 <- path segment value (20)
375 * 40 <- attribute flags
376 * 03 <- attribute type (Next hop)
377 * 04 <- attribute length
378 * 0a 00 00 09 <- value (10.0.0.9)
379 * 80 <- attribute flags
380 * 04 <- attribute type code (multi exit disc)
381 * 04 <- attribute length
382 * 00 00 00 00 <- value
383 * c0 <- attribute flags
384 * 07 <- attribute type (Aggregator)
385 * 08 <- attribute length
386 * 00 00 00 1e <- value (AS number = 30)
387 * 0a 00 00 09 <- value (IP address = 10.0.0.9)
390 * 15 ac 10 00 <- IPv4 Prefix (172.16.0.0 / 21)
394 // FIXME: to be fixed in testing phase
395 public void testGetUpdateMessage3() throws Exception {
396 final byte[] body = ByteArray.cutBytes(inputBytes.get(2), MessageUtil.COMMON_HEADER_LENGTH);
397 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(2), MessageUtil.MARKER_LENGTH,
398 MessageUtil.LENGTH_FIELD_LENGTH));
399 final Update message = updateParser.parseMessageBody(body, messageLength);
402 assertNull(message.getWithdrawnRoutes());
406 final List<AsSequence> asnums = Lists.newArrayList(new AsSequenceBuilder().setAs(new AsNumber(30L)).build());
407 final List<AsPathSegment> asPath = Lists.newArrayList();
408 asPath.add(new SegmentsBuilder().setCSegment(new CAListBuilder().setAsSequence(asnums).build()).build());
409 asPath.add(new SegmentsBuilder().setCSegment(
410 new CASetBuilder().setAsSet(Lists.newArrayList(new AsNumber(10L), new AsNumber(20L))).build()).build());
412 final BgpAggregator aggregator = new AggregatorBuilder().setAsNumber(new AsNumber((long) 30)).setNetworkAddress(
413 new Ipv4Address("10.0.0.9")).build();
414 final CIpv4NextHop nextHop = new CIpv4NextHopBuilder().setIpv4NextHop(
415 new Ipv4NextHopBuilder().setGlobal(new Ipv4Address("10.0.0.9")).build()).build();
417 final IPv4Prefix pref1 = IPv4.FAMILY.prefixForString("172.16.0.0/21");
419 // check path attributes
421 // final PathAttribute originAttr = new PathAttribute(TypeCode.ORIGIN, false,
422 // true, false, false, BGPOrigin.INCOMPLETE);
423 // assertEquals(originAttr, attrs.get(0));
425 // final PathAttribute asPathAttr = new PathAttribute(TypeCode.AS_PATH, false,
426 // true, false, false, asPath);
427 // assertEquals(asPathAttr, attrs.get(1));
429 // final PathAttribute nextHopAttr = new PathAttribute(TypeCode.NEXT_HOP, false,
430 // true, false, false, nextHop);
431 // assertEquals(nextHopAttr, attrs.get(2));
433 // final PathAttribute multiExitDisc = new PathAttribute(
434 // TypeCode.MULTI_EXIT_DISC, true, false, false, false, 0);
435 // assertEquals(multiExitDisc, attrs.get(3));
437 // final PathAttribute agg = new PathAttribute(TypeCode.AGGREGATOR, true, true,
438 // false, false, aggregator);
439 // assertEquals(agg, attrs.get(4));
443 // final Set<IPv4Prefix> nlri = Sets.newHashSet(pref1);
444 // assertEquals(nlri, ret.getBgpUpdateMessageBuilder().getNlri());
446 // final BaseBGPObjectState state = new BaseBGPObjectState(BgpOrigin.Incomplete, aggregator);
447 // final NetworkRouteState routeState = new NetworkRouteState(new NetworkObjectState(asPath, Collections.<Community> emptySet(), Collections.<ExtendedCommunity> emptySet()), nextHop);
451 // final Set<BGPObject> addedObjects = Sets.newHashSet();
453 // final BGPRoute route1 = new BGPIPv4RouteImpl(pref1, state, routeState);
455 // addedObjects.add(route1);
459 * Tests empty AS_PATH, ORIGIN.EGP, LOCAL_PREF, EXTENDED_COMMUNITIES (Ipv4 Addr specific)
461 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
462 * 00 4A <- length (73) - including header
464 * 00 00 <- withdrawn routes length
465 * 00 27 <- total path attribute length (39)
466 * 40 <- attribute flags
467 * 01 <- attribute type code (Origin)
468 * 01 <- attribute length
469 * 01 <- Origin value (EGP)
470 * 40 <- attribute flags
471 * 02 <- attribute type code (As path)
472 * 00 <- attribute length
473 * 40 <- attribute flags
474 * 03 <- attribute type (Next hop)
475 * 04 <- attribute length
476 * 03 03 03 03 <- value (3.3.3.3)
477 * 80 <- attribute flags
478 * 04 <- attribute type code (Multi exit disc)
479 * 04 <- attribute length
480 * 00 00 00 00 <- value
481 * 40 <- attribute flags
482 * 05 <- attribute type (Local Pref)
483 * 04 <- attribute length
484 * 00 00 00 64 <- value (100)
485 * 80 <- attribute flags
486 * 10 <- attribute type (extended community)
487 * 08 <- attribute length
488 * 01 04 <- value (type - Ipv4 Address Specific Extended Community)
489 * c0 a8 01 00 <- value (global adm. 198.162.1.0)
490 * 12 34 <- value (local adm. 4660)
493 * 18 0a 1e 03 <- IPv4 Prefix (10.30.3.0 / 24)
494 * 18 0a 1e 02 <- IPv4 Prefix (10.30.2.0 / 24)
495 * 18 0a 1e 01 <- IPv4 Prefix (10.30.1.0 / 24)
499 // FIXME: to be fixed in testing phase
500 public void testGetUpdateMessage4() throws Exception {
501 final byte[] body = ByteArray.cutBytes(inputBytes.get(3), MessageUtil.COMMON_HEADER_LENGTH);
502 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(3), MessageUtil.MARKER_LENGTH,
503 MessageUtil.LENGTH_FIELD_LENGTH));
504 final Update message = updateParser.parseMessageBody(body, messageLength);
508 assertNull(message.getWithdrawnRoutes());
512 final CIpv4NextHop nextHop = new CIpv4NextHopBuilder().setIpv4NextHop(
513 new Ipv4NextHopBuilder().setGlobal(new Ipv4Address("3.3.3.3")).build()).build();
515 final Set<ExtendedCommunity> comms = Sets.newHashSet();
516 comms.add(new CInet4SpecificExtendedCommunityBuilder().setInet4SpecificExtendedCommunity(
517 new Inet4SpecificExtendedCommunityBuilder().setTransitive(false).setGlobalAdministrator(new Ipv4Address("192.168.1.0")).setLocalAdministrator(
518 new byte[] { 0x12, 0x34 }).build()).build());
520 // check path attributes
522 // final PathAttribute originAttr = new PathAttribute(TypeCode.ORIGIN, false,
523 // true, false, false, BGPOrigin.EGP);
524 // assertEquals(originAttr, attrs.get(0));
526 // final PathAttribute asPathAttr = new PathAttribute(TypeCode.AS_PATH, false,
527 // true, false, false, asPath);
528 // assertEquals(asPathAttr, attrs.get(1));
530 // final PathAttribute nextHopAttr = new PathAttribute(TypeCode.NEXT_HOP, false,
531 // true, false, false, nextHop);
532 // assertEquals(nextHopAttr, attrs.get(2));
534 // final PathAttribute multiExitDisc = new PathAttribute(
535 // TypeCode.MULTI_EXIT_DISC, true, false, false, false, 0);
536 // assertEquals(multiExitDisc, attrs.get(3));
538 // final PathAttribute localPref = new PathAttribute(TypeCode.LOCAL_PREF, false,
539 // true, false, false, 100);
540 // assertEquals(localPref, attrs.get(4));
544 // final Set<IPv4Prefix> nlri = Sets.newHashSet(pref1, pref2, pref3);
545 // assertEquals(nlri, ret.getBgpUpdateMessageBuilder().getNlri());
547 // final BaseBGPObjectState state = new BaseBGPObjectState(BgpOrigin.Egp, null);
548 // final NetworkRouteState routeState = new NetworkRouteState(new NetworkObjectState(Collections.<AsPathSegment> emptyList(), Collections.<Community> emptySet(), comms), nextHop);
552 // final Set<BGPObject> addedObjects = Sets.newHashSet();
554 // final BGPRoute route1 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("10.30.3.0/24"), state, routeState);
556 // addedObjects.add(route1);
558 // final BGPRoute route2 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("10.30.2.0/24"), state, routeState);
560 // addedObjects.add(route2);
562 // final BGPRoute route3 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("10.30.1.0/24"), state, routeState);
564 // addedObjects.add(route3);
568 * Tests withdrawn routes.
570 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
571 * 00 1c <- length (28) - including header
573 * 00 05 <- withdrawn routes length (5)
574 * 1e ac 10 00 04 <- route (172.16.0.4)
575 * 00 00 <- total path attribute length
579 // FIXME: to be fixed in testing phase
580 public void testGetUpdateMessage5() throws Exception {
581 final byte[] body = ByteArray.cutBytes(inputBytes.get(4), MessageUtil.COMMON_HEADER_LENGTH);
582 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(4), MessageUtil.MARKER_LENGTH,
583 MessageUtil.LENGTH_FIELD_LENGTH));
584 final Update message = updateParser.parseMessageBody(body, messageLength);
588 List<Ipv4Prefix> prefs = Lists.newArrayList(new Ipv4Prefix("172.16.0.4/30"));
592 final Update expectedMessage = new UpdateBuilder().setWithdrawnRoutes(new WithdrawnRoutesBuilder().setWithdrawnRoutes(prefs).build()).build();
594 assertEquals(expectedMessage.getWithdrawnRoutes().getWithdrawnRoutes().get(0).toString(), message.getWithdrawnRoutes().getWithdrawnRoutes().get(0).toString());
600 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
601 * 00 17 <- length (23) - including header
603 * 00 00 <- withdrawn routes length
604 * 00 00 <- total path attribute length
607 public void testEORIpv4() throws Exception {
608 final byte[] body = ByteArray.cutBytes(inputBytes.get(5), MessageUtil.COMMON_HEADER_LENGTH);
609 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(5), MessageUtil.MARKER_LENGTH,
610 MessageUtil.LENGTH_FIELD_LENGTH));
611 final Update message = updateParser.parseMessageBody(body, messageLength);
613 assertEquals(new UpdateBuilder().build(), message);
617 * End of Rib for Ipv6 consists of empty MP_UNREACH_NLRI, with AFI 2 and SAFI 1
619 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
620 * 00 1d <- length (29) - including header
622 * 00 00 <- withdrawn routes length
623 * 00 06 <- total path attribute length
624 * 80 <- attribute flags
625 * 0f <- attribute type (15 - MP_UNREACH_NLRI)
626 * 03 <- attribute length
627 * 00 02 <- value (AFI 2: IPv6)
628 * 01 <- value (SAFI 1)
632 //FIXME: to be fixed in testing phase
633 public void testEORIpv6() throws Exception {
634 final byte[] body = ByteArray.cutBytes(inputBytes.get(6), MessageUtil.COMMON_HEADER_LENGTH);
635 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(6), MessageUtil.MARKER_LENGTH,
636 MessageUtil.LENGTH_FIELD_LENGTH));
637 final Update message = updateParser.parseMessageBody(body, messageLength);
641 Class<? extends AddressFamily> afi = message.getPathAttributes().getAugmentation(PathAttributes1.class).getMpReachNlri().getAfi();
642 SubsequentAddressFamily safi = message.getPathAttributes().getAugmentation(PathAttributes1.class).getMpReachNlri().getSafi().newInstance();
644 assertEquals(Ipv6AddressFamily.class, afi);
645 assertEquals(UnicastSubsequentAddressFamily.INSTANCE, safi);
649 * End of Rib for LS consists of empty MP_UNREACH_NLRI, with AFI 16388 and SAFI 71
651 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
652 * 00 1d <- length (29) - including header
654 * 00 00 <- withdrawn routes length
655 * 00 06 <- total path attribute length
656 * 80 <- attribute flags
657 * 0f <- attribute type (15 - MP_UNREACH_NLRI)
658 * 03 <- attribute length
659 * 40 04 <- value (AFI 16388: LS)
660 * 47 <- value (SAFI 71)
664 //FIXME: to be fixed in testing phase
665 public void testEORLS() throws Exception {
666 final byte[] body = ByteArray.cutBytes(inputBytes.get(7), MessageUtil.COMMON_HEADER_LENGTH);
667 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(7), MessageUtil.MARKER_LENGTH,
668 MessageUtil.LENGTH_FIELD_LENGTH));
669 final Update message = updateParser.parseMessageBody(body, messageLength);
671 Class<? extends AddressFamily> afi = message.getPathAttributes().getAugmentation(PathAttributes1.class).getMpReachNlri().getAfi();
672 SubsequentAddressFamily safi = message.getPathAttributes().getAugmentation(PathAttributes1.class).getMpReachNlri().getSafi().newInstance();
674 assertEquals(LinkstateAddressFamily.class, afi);
675 assertEquals(LinkstateSubsequentAddressFamily.INSTANCE, safi);
679 * Tests BGP Link Ipv4
681 00 00 <- withdrawn routes length
682 01 48 <- total path attribute length (328)
683 90 <- attribute flags
684 0e <- attribute type code (MP reach)
685 01 2c <- attribute extended length (300)
686 40 04 <- AFI (16388 - Linkstate)
687 47 <- SAFI (71 - Linkstate)
688 04 <- next hop length
689 19 19 19 01 <- nexthop (25.25.25.1)
692 00 02 <- NLRI type (2 - linkNLRI)
693 00 5d <- NLRI length (93)
694 03 <- ProtocolID - OSPF
695 00 00 00 00 00 00 00 01 <- identifier
697 01 00 <- local node descriptor type (256)
699 02 00 <- node descriptor type (member AS - 512)
701 00 00 00 64 <- value (100)
702 02 01 <- node descriptor type (bgpId - 513)
704 19 19 19 01 <- bgpId (25.25.25.1)
705 02 02 <- node descriptor type (areaId - 514)
708 02 03 <- node descriptor type (routeId - 515)
710 03 03 03 04 0b 0b 0b 03 <- OSPF Router Id
712 01 01 <- remote node descriptor type (257)
714 02 00 <- node descriptor type (member AS - 512)
716 00 00 00 64 <- value (100)
717 02 01 <- node descriptor type (bgpId - 513)
719 19 19 19 01 <- bgpId (25.25.25.1)
720 02 02 <- node descriptor type (areaId - 514)
723 02 03 <- node descriptor type (routeId - 515)
725 03 03 03 04 <- OSPF Router Id
727 01 03 <- link descriptor type (IPv4 interface address - 259)
729 0b 0b 0b 03 <- value (11.11.11.3)
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 01 01 01 02 <- OSPF Router Id
766 01 03 <- link descriptor type (IPv4 interface address - 259)
768 0b 0b 0b 01 <- value (11.11.11.1)
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 01 01 01 02 <- 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 03 03 03 04 0b 0b 0b 03 <- OSPF Router Id
805 01 03 <- link descriptor type (IPv4 interface address - 259)
807 0b 0b 0b 01 <- value (11.11.11.1)
809 40 <- attribute flags
810 01 <- attribute type (Origin)
811 01 <- attribute length
813 40 <- attribute flags
814 02 <- attribute type (AS Path)
816 40 <- attribute flags
817 05 <- attribute type (local pref)
820 c0 <- attribute flags
821 63 <- attribute type (Link STATE - 99)
823 04 47 <- link attribute (1095 - Metric)
829 // FIXME: to be fixed in testing phase
830 public void testBGPLink() throws Exception {
831 final byte[] body = ByteArray.cutBytes(inputBytes.get(8), MessageUtil.COMMON_HEADER_LENGTH);
832 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(8), MessageUtil.MARKER_LENGTH,
833 MessageUtil.LENGTH_FIELD_LENGTH));
834 final Update message = updateParser.parseMessageBody(body, messageLength);
838 assertNull(message.getWithdrawnRoutes());
840 // network object state
841 // final NetworkObjectState objState = new NetworkObjectState(Collections.<AsPathSegment> emptyList(), Collections.<Community> emptySet(), Collections.<ExtendedCommunity> emptySet());
842 // final BaseBGPObjectState state = new BaseBGPObjectState(BgpOrigin.Igp, null);
844 // network link state
845 final DefaultingTypesafeContainer<Metric<?>> container = new DefaultingTypesafeContainer<Metric<?>>();
846 container.setDefaultEntry(new IGPMetric(1));
847 //final NetworkLinkState linkState = new NetworkLinkState(objState, container, null, LinkProtectionType.UNPROTECTED, null, null, null);
849 // final NodeIdentifierFactory f100 = new NodeIdentifierFactory(new AsNumber((long) 100), new DomainIdentifier(new byte[] { 25, 25,
850 // 25, 1 }), new AreaIdentifier(new byte[] { 0, 0, 0, 0 }));
852 // final NodeIdentifier nodeid1 = f100.identifierForRouter(new OSPFv3LANIdentifier(new OSPFRouterIdentifier(new byte[] { 3, 3, 3, 4 }), new OSPFInterfaceIdentifier(new byte[] {
853 // 0x0b, 0x0b, 0x0b, 0x03 })));
854 // final NodeIdentifier nodeid2 = f100.identifierForRouter(new OSPFRouterIdentifier(new byte[] { 3, 3, 3, 4 }));
856 // final NodeIdentifier nodeid3 = f100.identifierForRouter(new OSPFRouterIdentifier(new byte[] { 1, 1, 1, 2 }));
860 // final LinkIdentifier linkId1 = new LinkIdentifier(null, new LinkAnchor(nodeid1, new IPv4InterfaceIdentifier(IPv4.FAMILY.addressForString("11.11.11.3"))), new LinkAnchor(nodeid2, null));
861 // final LinkIdentifier linkId2 = new LinkIdentifier(null, new LinkAnchor(nodeid1, new IPv4InterfaceIdentifier(IPv4.FAMILY.addressForString("11.11.11.1"))), new LinkAnchor(nodeid3, null));
862 // final LinkIdentifier linkId3 = new LinkIdentifier(null, new LinkAnchor(nodeid3, new IPv4InterfaceIdentifier(IPv4.FAMILY.addressForString("11.11.11.1"))), new LinkAnchor(nodeid1, null));
864 // final BGPLink link1 = new BGPLinkImpl(state, linkId1, linkState);
865 // final BGPLink link2 = new BGPLinkImpl(state, linkId2, linkState);
866 // final BGPLink link3 = new BGPLinkImpl(state, linkId3, linkState);
868 // final BGPUpdateMessage expectedMessage = new BGPUpdateMessageImpl(Sets.newHashSet((BGPObject) link1, (BGPObject) link2,
869 // (BGPObject) link3), Collections.<Identifier> emptySet());
871 // assertEquals(expectedMessage, message);
877 * 00 00 <- withdrawn routes length
878 00 b2 <- total path attribute length (178)
879 90 <- attribute flags
880 0e <- attribute type code (MP reach)
881 00 a0 <- attribute extended length (160)
882 40 04 <- AFI (16388 - Linkstate)
883 47 <- SAFI (71 - Linkstate)
884 04 <- next hop length
885 19 19 19 01 - nexthop (25.25.25.1)
887 00 01 <- NLRI type (1 - nodeNLRI)
888 00 31 <- NLRI length (49)
889 03 <- ProtocolID - OSPF
890 00 00 00 00 00 00 00 01 <- identifier
892 01 00 <- local node descriptor type (256)
894 02 00 <- node descriptor type (member AS - 512)
896 00 00 00 64 <- value (100)
897 02 01 <- node descriptor type (bgpId - 513)
899 19 19 19 01 <- bgpId (25.25.25.1)
900 02 02 <- node descriptor type (areaId - 514)
903 02 03 <- node descriptor type (routeId - 515)
905 03 03 03 04 0b 0b 0b 03 <- OSPF Router Id
907 00 01 <- NLRI type (1 - nodeNLRI)
908 00 2d <- NLRI length (45)
909 03 <- ProtocolID - OSPF
910 00 00 00 00 00 00 00 01 <- identifier
912 01 00 <- local node descriptor type (256)
914 02 00 <- node descriptor type (member AS - 512)
916 00 00 00 64 <- value (100)
917 02 01 <- node descriptor type (bgpId - 513)
919 19 19 19 01 <- bgpId (25.25.25.1)
920 02 02 <- node descriptor type (areaId - 514)
923 02 03 <- node descriptor type (routeId - 515)
925 03 03 03 04 <- OSPF Router Id
927 00 01 <- NLRI type (1 - nodeNLRI)
928 00 2d <- NLRI length (45)
929 03 <- ProtocolID - OSPF
930 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 01 01 01 02 <- OSPF Router Id
946 40 <- attribute flags
947 01 <- attribute type (Origin)
948 01 <- attribute length
950 40 <- attribute flags
951 02 <- attribute type (AS Path)
953 40 <- attribute flags
954 05 <- attribute type (local pref)
960 // FIXME: to be fixed in testing phase
961 public void testBGPNode() throws Exception {
962 final byte[] body = ByteArray.cutBytes(inputBytes.get(9), MessageUtil.COMMON_HEADER_LENGTH);
963 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(9), MessageUtil.MARKER_LENGTH,
964 MessageUtil.LENGTH_FIELD_LENGTH));
965 final Update message = updateParser.parseMessageBody(body, messageLength);
969 assertNull(message.getWithdrawnRoutes());
971 // network object state
972 // final NetworkObjectState objState = new NetworkObjectState(Collections.<AsPathSegment> emptyList(), Collections.<Community> emptySet(), Collections.<ExtendedCommunity> emptySet());
973 // final BaseBGPObjectState state = new BaseBGPObjectState(BgpOrigin.Igp, null);
974 // final NetworkNodeState nstate = new NetworkNodeState(objState, Collections.<TopologyIdentifier> emptySet(), Collections.<ISISAreaIdentifier> emptySet(), false, false, false, false, Collections.<RouterIdentifier> emptySet(), null);
976 // network link state
978 // final NodeIdentifierFactory f100 = new NodeIdentifierFactory(new AsNumber((long) 100), new DomainIdentifier(new byte[] { 25, 25,
979 // 25, 1 }), new AreaIdentifier(new byte[] { 0, 0, 0, 0 }));
981 // final NodeIdentifier nodeid1 = f100.identifierForRouter(new OSPFv3LANIdentifier(new OSPFRouterIdentifier(new byte[] { 3, 3, 3, 4 }), new OSPFInterfaceIdentifier(new byte[] {
982 // 0x0b, 0x0b, 0x0b, 0x03 })));
983 // final NodeIdentifier nodeid2 = f100.identifierForRouter(new OSPFRouterIdentifier(new byte[] { 3, 3, 3, 4 }));
985 // final NodeIdentifier nodeid3 = f100.identifierForRouter(new OSPFRouterIdentifier(new byte[] { 1, 1, 1, 2 }));
989 // final BGPNode node1 = new BGPNodeImpl(state, nodeid1, nstate);
990 // final BGPNode node2 = new BGPNodeImpl(state, nodeid2, nstate);
991 // final BGPNode node3 = new BGPNodeImpl(state, nodeid3, nstate);
993 // final BGPUpdateMessage expectedMessage = new BGPUpdateMessageImpl(Sets.newHashSet((BGPObject) node1, (BGPObject) node2,
994 // (BGPObject) node3), Collections.<Identifier> emptySet());
996 // assertEquals(expectedMessage, message);
1000 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
1001 * 00 98 <- length (69) - including header
1002 * 01 <- message type
1004 * 00 64 <- My AS Number (AS TRANS in this case)
1005 * 00 b4 <- Hold Time
1006 * 00 00 00 00 <- BGP Identifier
1007 * 28 <- Optional Parameters Length
1008 * 02 <- opt. param. type (capabilities)
1010 * 01 <- capability code (MP Extensions for BGP4)
1012 * 00 01 00 01 <- AFI 1, SAFI 1
1013 * 02 <- opt. param. type (capabilities)
1015 * 01 <- capability code (MP Extensions for BGP4)
1017 * 00 02 00 01 <- AFI 2, SAFI 1
1018 * 02 <- opt. param. type (capabilities)
1020 * 01 <- capability code (MP Extensions for BGP4)
1022 * 40 04 00 47 <- AFI 16388, SAFI 71
1023 * 02 <- opt. param. type (capabilities)
1025 * 80 <- capability code (private)
1027 * 02 <- opt. param. type (capabilities)
1029 * 02 <- capability code (Route refresh)
1031 * 02 <- opt. param. type (capabilities)
1033 * 41 <- capability code (AS4 octet support)
1035 * 00 00 00 64 <- AS number
1038 public void testOpenMessage() throws Exception {
1039 final MessageRegistry msgReg = SingletonProviderContext.getInstance().getMessageRegistry();
1040 final Open open = (Open) msgReg.parseMessage(inputBytes.get(13));
1041 final Set<BgpTableType> types = Sets.newHashSet();
1042 for (final BgpParameters param : open.getBgpParameters()) {
1043 final CParameters p = param.getCParameters();
1044 if (p instanceof CMultiprotocol) {
1045 final BgpTableType type = new BgpTableTypeImpl(((CMultiprotocol) p).getMultiprotocolCapability().getAfi(), ((CMultiprotocol) p).getMultiprotocolCapability().getSafi());
1049 final Set<BgpTableType> expected = Sets.newHashSet();
1050 expected.add(new BgpTableTypeImpl(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class));
1051 expected.add(new BgpTableTypeImpl(Ipv6AddressFamily.class, UnicastSubsequentAddressFamily.class));
1052 expected.add(new BgpTableTypeImpl(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class));
1053 assertEquals(expected, types);