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.bgp.parser.spi.pojo.BGPExtensionConsumerContextImpl;
30 import org.opendaylight.protocol.util.ByteArray;
31 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
32 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
33 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
34 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev130918.LinkstateAddressFamily;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev130918.LinkstateSubsequentAddressFamily;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.Open;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.Update;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.UpdateBuilder;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.open.BgpParameters;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.open.bgp.parameters.CParameters;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.path.attributes.AggregatorBuilder;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.path.attributes.as.path.SegmentsBuilder;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.update.WithdrawnRoutesBuilder;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130918.BgpTableType;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130918.PathAttributes1;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130918.open.bgp.parameters.c.parameters.CMultiprotocol;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.AddressFamily;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.AsPathSegment;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpAggregator;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Community;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv6AddressFamily;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.SubsequentAddressFamily;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.as.path.segment.c.segment.CAListBuilder;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.as.path.segment.c.segment.CASetBuilder;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.as.path.segment.c.segment.c.a.list.AsSequence;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.as.path.segment.c.segment.c.a.list.AsSequenceBuilder;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.ExtendedCommunity;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.extended.community.CInet4SpecificExtendedCommunityBuilder;
62 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;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.CIpv4NextHop;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.CIpv4NextHopBuilder;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.CIpv6NextHop;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.CIpv6NextHopBuilder;
67 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;
68 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;
70 import com.google.common.collect.Lists;
71 import com.google.common.collect.Sets;
73 public class BGPParserTest {
76 * Used by other tests as well
78 static final List<byte[]> inputBytes = new ArrayList<byte[]>();
80 private static int COUNTER = 17;
82 private static int MAX_SIZE = 300;
84 private static BGPUpdateMessageParser updateParser;
87 public static void setUp() throws Exception {
88 updateParser = new BGPUpdateMessageParser(BGPExtensionConsumerContextImpl.getSingletonInstance().getAttributeRegistry());
90 for (int i = 1; i <= COUNTER; i++) {
91 final String name = "/up" + i + ".bin";
92 final InputStream is = BGPParserTest.class.getResourceAsStream(name);
94 throw new IOException("Failed to get resource " + name);
97 final ByteArrayOutputStream bis = new ByteArrayOutputStream();
98 final byte[] data = new byte[MAX_SIZE];
100 while ((nRead = is.read(data, 0, data.length)) != -1) {
101 bis.write(data, 0, nRead);
105 inputBytes.add(bis.toByteArray());
110 public void testResource() {
111 assertNotNull(inputBytes);
115 * Tests IPv4 NEXT_HOP, ATOMIC_AGGREGATE, COMMUNITY, NLRI
117 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
118 * 00 54 <- length (84) - including header
120 * 00 00 <- withdrawn routes length
121 * 00 31 <- total path attribute length (49)
122 * 40 <- attribute flags
123 * 01 <- attribute type code (origin)
124 * 01 <- attribute length
125 * 00 <- Origin value (IGP)
126 * 40 <- attribute flags
127 * 02 <- attribute type code (as path)
128 * 06 <- attribute length
130 * 01 <- path segment count
131 * 00 00 fd ea <- path segment value (65002)
132 * 40 <- attribute flags
133 * 03 <- attribute type code (Next Hop)
134 * 04 <- attribute length
135 * 10 00 00 02 <- value (10.0.0.2)
136 * 80 <- attribute flags
137 * 04 <- attribute type code (multi exit disc)
138 * 04 <- attribute length
139 * 00 00 00 00 <- value
140 * 64 <- attribute flags
141 * 06 <- attribute type code (atomic aggregate)
142 * 00 <- attribute length
143 * 64 <- attribute flags
144 * 08 <- attribute type code (community)
145 * 10 <- attribute length FF FF FF
146 * 01 <- value (NO_EXPORT)
147 * FF FF FF 02 <- value (NO_ADVERTISE)
148 * FF FF FF 03 <- value (NO_EXPORT_SUBCONFED)
149 * FF FF FF 10 <- unknown Community
152 * 18 ac 11 02 <- IPv4 Prefix (172.17.2.0 / 24)
153 * 18 ac 11 01 <- IPv4 Prefix (172.17.1.0 / 24)
154 * 18 ac 11 00 <- IPv4 Prefix (172.17.0.0 / 24)
158 // FIXME: to be fixed in testing phase
159 public void testGetUpdateMessage1() throws Exception {
161 final byte[] body = ByteArray.cutBytes(inputBytes.get(0), MessageUtil.COMMON_HEADER_LENGTH);
162 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(0), MessageUtil.MARKER_LENGTH,
163 MessageUtil.LENGTH_FIELD_LENGTH));
164 final Update message = BGPParserTest.updateParser.parseMessageBody(body, messageLength);
168 assertNull(message.getWithdrawnRoutes());
172 final List<AsSequence> asnums = Lists.newArrayList(new AsSequenceBuilder().setAs(new AsNumber(65002L)).build());
173 final List<AsPathSegment> asPath = Lists.newArrayList();
174 asPath.add(new SegmentsBuilder().setCSegment(new CAListBuilder().setAsSequence(asnums).build()).build());
176 final CIpv4NextHop nextHop = new CIpv4NextHopBuilder().setIpv4NextHop(
177 new Ipv4NextHopBuilder().setGlobal(new Ipv4Address("10.0.0.2")).build()).build();
179 final Set<Community> comms = new HashSet<>();
180 comms.add(CommunityUtil.NO_EXPORT);
181 comms.add(CommunityUtil.NO_ADVERTISE);
182 comms.add(CommunityUtil.NO_EXPORT_SUBCONFED);
183 comms.add(CommunityUtil.create(0xFFFF, 0xFF10));
185 // check path attributes
187 // final PathAttribute originAttr = new PathAttribute(TypeCode.ORIGIN, false,
188 // true, false, false, BGPOrigin.IGP);
189 // assertEquals(originAttr, attrs.get(0));
191 // final PathAttribute asPathAttr = new PathAttribute(TypeCode.AS_PATH, false,
192 // true, false, false, asPath);
193 // assertEquals(asPathAttr, attrs.get(1));
195 // final PathAttribute nextHopAttr = new PathAttribute(TypeCode.NEXT_HOP, false,
196 // true, false, false, nextHop);
197 // assertEquals(nextHopAttr, attrs.get(2));
199 // final PathAttribute multiExitDisc = new PathAttribute(
200 // TypeCode.MULTI_EXIT_DISC, true, false, false, false, 0);
201 // assertEquals(multiExitDisc, attrs.get(3));
203 // final PathAttribute atomic = new PathAttribute(TypeCode.ATOMIC_AGGREGATE, false,
204 // true, true, false, null);
205 // assertEquals(atomic, attrs.get(4));
207 // final PathAttribute comm = new PathAttribute(TypeCode.COMMUNITIES, false,
208 // true, true, false, comms);
209 // assertEquals(comm, attrs.get(5));
213 // final Set<IPv4Prefix> nlri = Sets.newHashSet(pref1, pref2, pref3);
214 // assertEquals(nlri, ret.getBgpUpdateMessageBuilder().getNlri());
216 // final BaseBGPObjectState state = new BaseBGPObjectState(BgpOrigin.Igp, null);
217 // final NetworkRouteState routeState = new NetworkRouteState(new NetworkObjectState(asPath, comms,
218 // Collections.<ExtendedCommunity> emptySet()), nextHop);
222 // final Set<BGPObject> addedObjects = Sets.newHashSet();
224 // final BGPRoute route1 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("172.17.2.0/24"), state,
227 // addedObjects.add(route1);
229 // final BGPRoute route2 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("172.17.1.0/24"), state,
232 // addedObjects.add(route2);
234 // final BGPRoute route3 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("172.17.0.0/24"), state,
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 = BGPParserTest.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,
335 // Collections.<Community> emptySet(), Collections.<ExtendedCommunity> emptySet()), nextHop);
339 // final Set<BGPObject> addedObjects = Sets.newHashSet();
341 // final BGPRoute route1 = new BGPIPv6RouteImpl(IPv6.FAMILY.prefixForString("2001:db8:1:2::/64"), state,
344 // addedObjects.add(route1);
346 // final BGPRoute route2 = new BGPIPv6RouteImpl(IPv6.FAMILY.prefixForString("2001:db8:1:1::/64"), state,
349 // addedObjects.add(route2);
351 // final BGPRoute route3 = new BGPIPv6RouteImpl(IPv6.FAMILY.prefixForString("2001:db8:1::/64"), state,
354 // addedObjects.add(route3);
358 * Tests more AS Numbers in AS_PATH, AGGREGATOR, ORIGIN.INCOMPLETE
360 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
361 * 00 4b <- length (75) - including header
363 * 00 00 <- withdrawn routes length
364 * 00 30 <- total path attribute length (48)
365 * 40 <- attribute flags
366 * 01 <- attribute type code (origin)
367 * 01 <- attribute length
368 * 02 <- Origin value (Incomplete)
369 * 40 <- attribute flags
370 * 02 <- attribute type code (as path)
371 * 10 <- attribute length
373 * 01 <- path segment count
374 * 00 00 00 1e <- path segment value (30)
376 * 02 <- path segment count
377 * 00 00 00 0a <- path segment value (10)
378 * 00 00 00 14 <- path segment value (20)
379 * 40 <- attribute flags
380 * 03 <- attribute type (Next hop)
381 * 04 <- attribute length
382 * 0a 00 00 09 <- value (10.0.0.9)
383 * 80 <- attribute flags
384 * 04 <- attribute type code (multi exit disc)
385 * 04 <- attribute length
386 * 00 00 00 00 <- value
387 * c0 <- attribute flags
388 * 07 <- attribute type (Aggregator)
389 * 08 <- attribute length
390 * 00 00 00 1e <- value (AS number = 30)
391 * 0a 00 00 09 <- value (IP address = 10.0.0.9)
394 * 15 ac 10 00 <- IPv4 Prefix (172.16.0.0 / 21)
398 // FIXME: to be fixed in testing phase
399 public void testGetUpdateMessage3() throws Exception {
400 final byte[] body = ByteArray.cutBytes(inputBytes.get(2), MessageUtil.COMMON_HEADER_LENGTH);
401 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(2), MessageUtil.MARKER_LENGTH,
402 MessageUtil.LENGTH_FIELD_LENGTH));
403 final Update message = BGPParserTest.updateParser.parseMessageBody(body, messageLength);
406 assertNull(message.getWithdrawnRoutes());
410 final List<AsSequence> asnums = Lists.newArrayList(new AsSequenceBuilder().setAs(new AsNumber(30L)).build());
411 final List<AsPathSegment> asPath = Lists.newArrayList();
412 asPath.add(new SegmentsBuilder().setCSegment(new CAListBuilder().setAsSequence(asnums).build()).build());
413 asPath.add(new SegmentsBuilder().setCSegment(
414 new CASetBuilder().setAsSet(Lists.newArrayList(new AsNumber(10L), new AsNumber(20L))).build()).build());
416 final BgpAggregator aggregator = new AggregatorBuilder().setAsNumber(new AsNumber((long) 30)).setNetworkAddress(
417 new Ipv4Address("10.0.0.9")).build();
418 final CIpv4NextHop nextHop = new CIpv4NextHopBuilder().setIpv4NextHop(
419 new Ipv4NextHopBuilder().setGlobal(new Ipv4Address("10.0.0.9")).build()).build();
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 routeState = new NetworkRouteState(new NetworkObjectState(asPath,
452 // Collections.<Community> emptySet(), Collections.<ExtendedCommunity> emptySet()), nextHop);
456 // final Set<BGPObject> addedObjects = Sets.newHashSet();
458 // final BGPRoute route1 = new BGPIPv4RouteImpl(pref1, state, routeState);
460 // addedObjects.add(route1);
464 * Tests empty AS_PATH, ORIGIN.EGP, LOCAL_PREF, EXTENDED_COMMUNITIES (Ipv4 Addr specific)
466 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
467 * 00 4A <- length (73) - including header
469 * 00 00 <- withdrawn routes length
470 * 00 27 <- total path attribute length (39)
471 * 40 <- attribute flags
472 * 01 <- attribute type code (Origin)
473 * 01 <- attribute length
474 * 01 <- Origin value (EGP)
475 * 40 <- attribute flags
476 * 02 <- attribute type code (As path)
477 * 00 <- attribute length
478 * 40 <- attribute flags
479 * 03 <- attribute type (Next hop)
480 * 04 <- attribute length
481 * 03 03 03 03 <- value (3.3.3.3)
482 * 80 <- attribute flags
483 * 04 <- attribute type code (Multi exit disc)
484 * 04 <- attribute length
485 * 00 00 00 00 <- value
486 * 40 <- attribute flags
487 * 05 <- attribute type (Local Pref)
488 * 04 <- attribute length
489 * 00 00 00 64 <- value (100)
490 * 80 <- attribute flags
491 * 10 <- attribute type (extended community)
492 * 08 <- attribute length
493 * 01 04 <- value (type - Ipv4 Address Specific Extended Community)
494 * c0 a8 01 00 <- value (global adm. 198.162.1.0)
495 * 12 34 <- value (local adm. 4660)
498 * 18 0a 1e 03 <- IPv4 Prefix (10.30.3.0 / 24)
499 * 18 0a 1e 02 <- IPv4 Prefix (10.30.2.0 / 24)
500 * 18 0a 1e 01 <- IPv4 Prefix (10.30.1.0 / 24)
504 // FIXME: to be fixed in testing phase
505 public void testGetUpdateMessage4() throws Exception {
506 final byte[] body = ByteArray.cutBytes(inputBytes.get(3), MessageUtil.COMMON_HEADER_LENGTH);
507 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(3), MessageUtil.MARKER_LENGTH,
508 MessageUtil.LENGTH_FIELD_LENGTH));
509 final Update message = BGPParserTest.updateParser.parseMessageBody(body, messageLength);
513 assertNull(message.getWithdrawnRoutes());
517 final CIpv4NextHop nextHop = new CIpv4NextHopBuilder().setIpv4NextHop(
518 new Ipv4NextHopBuilder().setGlobal(new Ipv4Address("3.3.3.3")).build()).build();
520 final Set<ExtendedCommunity> comms = Sets.newHashSet();
521 comms.add(new CInet4SpecificExtendedCommunityBuilder().setInet4SpecificExtendedCommunity(
522 new Inet4SpecificExtendedCommunityBuilder().setTransitive(false).setGlobalAdministrator(new Ipv4Address("192.168.1.0")).setLocalAdministrator(
523 new byte[] { 0x12, 0x34 }).build()).build());
525 // check path attributes
527 // final PathAttribute originAttr = new PathAttribute(TypeCode.ORIGIN, false,
528 // true, false, false, BGPOrigin.EGP);
529 // assertEquals(originAttr, attrs.get(0));
531 // final PathAttribute asPathAttr = new PathAttribute(TypeCode.AS_PATH, false,
532 // true, false, false, asPath);
533 // assertEquals(asPathAttr, attrs.get(1));
535 // final PathAttribute nextHopAttr = new PathAttribute(TypeCode.NEXT_HOP, false,
536 // true, false, false, nextHop);
537 // assertEquals(nextHopAttr, attrs.get(2));
539 // final PathAttribute multiExitDisc = new PathAttribute(
540 // TypeCode.MULTI_EXIT_DISC, true, false, false, false, 0);
541 // assertEquals(multiExitDisc, attrs.get(3));
543 // final PathAttribute localPref = new PathAttribute(TypeCode.LOCAL_PREF, false,
544 // true, false, false, 100);
545 // assertEquals(localPref, attrs.get(4));
549 // final Set<IPv4Prefix> nlri = Sets.newHashSet(pref1, pref2, pref3);
550 // assertEquals(nlri, ret.getBgpUpdateMessageBuilder().getNlri());
552 // final BaseBGPObjectState state = new BaseBGPObjectState(BgpOrigin.Egp, null);
553 // final NetworkRouteState routeState = new NetworkRouteState(new NetworkObjectState(Collections.<AsPathSegment>
554 // emptyList(), Collections.<Community> emptySet(), comms), nextHop);
558 // final Set<BGPObject> addedObjects = Sets.newHashSet();
560 // final BGPRoute route1 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("10.30.3.0/24"), state, routeState);
562 // addedObjects.add(route1);
564 // final BGPRoute route2 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("10.30.2.0/24"), state, routeState);
566 // addedObjects.add(route2);
568 // final BGPRoute route3 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("10.30.1.0/24"), state, routeState);
570 // addedObjects.add(route3);
574 * Tests withdrawn routes.
576 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
577 * 00 1c <- length (28) - including header
579 * 00 05 <- withdrawn routes length (5)
580 * 1e ac 10 00 04 <- route (172.16.0.4)
581 * 00 00 <- total path attribute length
585 // FIXME: to be fixed in testing phase
586 public void testGetUpdateMessage5() throws Exception {
587 final byte[] body = ByteArray.cutBytes(inputBytes.get(4), MessageUtil.COMMON_HEADER_LENGTH);
588 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(4), MessageUtil.MARKER_LENGTH,
589 MessageUtil.LENGTH_FIELD_LENGTH));
590 final Update message = BGPParserTest.updateParser.parseMessageBody(body, messageLength);
594 final List<Ipv4Prefix> prefs = Lists.newArrayList(new Ipv4Prefix("172.16.0.4/30"));
598 final Update expectedMessage = new UpdateBuilder().setWithdrawnRoutes(
599 new WithdrawnRoutesBuilder().setWithdrawnRoutes(prefs).build()).build();
601 assertEquals(expectedMessage.getWithdrawnRoutes().getWithdrawnRoutes().get(0).toString(),
602 message.getWithdrawnRoutes().getWithdrawnRoutes().get(0).toString());
608 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
609 * 00 17 <- length (23) - including header
611 * 00 00 <- withdrawn routes length
612 * 00 00 <- total path attribute length
615 public void testEORIpv4() throws Exception {
616 final byte[] body = ByteArray.cutBytes(inputBytes.get(5), MessageUtil.COMMON_HEADER_LENGTH);
617 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(5), MessageUtil.MARKER_LENGTH,
618 MessageUtil.LENGTH_FIELD_LENGTH));
619 final Update message = BGPParserTest.updateParser.parseMessageBody(body, messageLength);
621 assertEquals(new UpdateBuilder().build(), message);
625 * End of Rib for Ipv6 consists of empty MP_UNREACH_NLRI, with AFI 2 and SAFI 1
627 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
628 * 00 1d <- length (29) - including header
630 * 00 00 <- withdrawn routes length
631 * 00 06 <- total path attribute length
632 * 80 <- attribute flags
633 * 0f <- attribute type (15 - MP_UNREACH_NLRI)
634 * 03 <- attribute length
635 * 00 02 <- value (AFI 2: IPv6)
636 * 01 <- value (SAFI 1)
640 // FIXME: to be fixed in testing phase
641 public void testEORIpv6() throws Exception {
642 final byte[] body = ByteArray.cutBytes(inputBytes.get(6), MessageUtil.COMMON_HEADER_LENGTH);
643 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(6), MessageUtil.MARKER_LENGTH,
644 MessageUtil.LENGTH_FIELD_LENGTH));
645 final Update message = BGPParserTest.updateParser.parseMessageBody(body, messageLength);
649 final Class<? extends AddressFamily> afi = message.getPathAttributes().getAugmentation(PathAttributes1.class).getMpReachNlri().getAfi();
650 final SubsequentAddressFamily safi = message.getPathAttributes().getAugmentation(PathAttributes1.class).getMpReachNlri().getSafi().newInstance();
652 assertEquals(Ipv6AddressFamily.class, afi);
653 assertEquals(UnicastSubsequentAddressFamily.INSTANCE, safi);
657 * End of Rib for LS consists of empty MP_UNREACH_NLRI, with AFI 16388 and SAFI 71
659 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
660 * 00 1d <- length (29) - including header
662 * 00 00 <- withdrawn routes length
663 * 00 06 <- total path attribute length
664 * 80 <- attribute flags
665 * 0f <- attribute type (15 - MP_UNREACH_NLRI)
666 * 03 <- attribute length
667 * 40 04 <- value (AFI 16388: LS)
668 * 47 <- value (SAFI 71)
672 // FIXME: to be fixed in testing phase
673 public void testEORLS() throws Exception {
674 final byte[] body = ByteArray.cutBytes(inputBytes.get(7), MessageUtil.COMMON_HEADER_LENGTH);
675 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(7), MessageUtil.MARKER_LENGTH,
676 MessageUtil.LENGTH_FIELD_LENGTH));
677 final Update message = BGPParserTest.updateParser.parseMessageBody(body, messageLength);
679 final Class<? extends AddressFamily> afi = message.getPathAttributes().getAugmentation(PathAttributes1.class).getMpReachNlri().getAfi();
680 final SubsequentAddressFamily safi = message.getPathAttributes().getAugmentation(PathAttributes1.class).getMpReachNlri().getSafi().newInstance();
682 assertEquals(LinkstateAddressFamily.class, afi);
683 assertEquals(LinkstateSubsequentAddressFamily.INSTANCE, safi);
687 * Tests BGP Link Ipv4
689 00 00 <- withdrawn routes length
690 01 48 <- total path attribute length (328)
691 90 <- attribute flags
692 0e <- attribute type code (MP reach)
693 01 2c <- attribute extended length (300)
694 40 04 <- AFI (16388 - Linkstate)
695 47 <- SAFI (71 - Linkstate)
696 04 <- next hop length
697 19 19 19 01 <- nexthop (25.25.25.1)
700 00 02 <- NLRI type (2 - linkNLRI)
701 00 5d <- NLRI length (93)
702 03 <- ProtocolID - OSPF
703 00 00 00 00 00 00 00 01 <- identifier
705 01 00 <- local node descriptor type (256)
707 02 00 <- node descriptor type (member AS - 512)
709 00 00 00 64 <- value (100)
710 02 01 <- node descriptor type (bgpId - 513)
712 19 19 19 01 <- bgpId (25.25.25.1)
713 02 02 <- node descriptor type (areaId - 514)
716 02 03 <- node descriptor type (routeId - 515)
718 03 03 03 04 0b 0b 0b 03 <- OSPF Router Id
720 01 01 <- remote node descriptor type (257)
722 02 00 <- node descriptor type (member AS - 512)
724 00 00 00 64 <- value (100)
725 02 01 <- node descriptor type (bgpId - 513)
727 19 19 19 01 <- bgpId (25.25.25.1)
728 02 02 <- node descriptor type (areaId - 514)
731 02 03 <- node descriptor type (routeId - 515)
733 03 03 03 04 <- OSPF Router Id
735 01 03 <- link descriptor type (IPv4 interface address - 259)
737 0b 0b 0b 03 <- value (11.11.11.3)
739 00 02 <- NLRI type (2 - linkNLRI)
740 00 5d <- NLRI length (93)
741 03 <- ProtocolID - OSPF
742 00 00 00 00 00 00 00 01 <- identifier
744 01 00 <- local node descriptor type (256)
746 02 00 <- node descriptor type (member AS - 512)
748 00 00 00 64 <- value (100)
749 02 01 <- node descriptor type (bgpId - 513)
751 19 19 19 01 <- bgpId (25.25.25.1)
752 02 02 <- node descriptor type (areaId - 514)
755 02 03 <- node descriptor type (routeId - 515)
757 03 03 03 04 0b 0b 0b 03 <- OSPF Router Id
759 01 01 <- remote node descriptor type (257)
761 02 00 <- node descriptor type (member AS - 512)
763 00 00 00 64 <- value (100)
764 02 01 <- node descriptor type (bgpId - 513)
766 19 19 19 01 <- bgpId (25.25.25.1)
767 02 02 <- node descriptor type (areaId - 514)
770 02 03 <- node descriptor type (routeId - 515)
772 01 01 01 02 <- OSPF Router Id
774 01 03 <- link descriptor type (IPv4 interface address - 259)
776 0b 0b 0b 01 <- value (11.11.11.1)
778 00 02 <- NLRI type (2 - linkNLRI)
779 00 5d <- NLRI length (93)
780 03 <- ProtocolID - OSPF
781 00 00 00 00 00 00 00 01 <- identifier
783 01 00 <- local node descriptor type (256)
785 02 00 <- node descriptor type (member AS - 512)
787 00 00 00 64 <- value (100)
788 02 01 <- node descriptor type (bgpId - 513)
790 19 19 19 01 <- bgpId (25.25.25.1)
791 02 02 <- node descriptor type (areaId - 514)
794 02 03 <- node descriptor type (routeId - 515)
796 01 01 01 02 <- OSPF Router Id
798 01 01 <- remote node descriptor type (257)
800 02 00 <- node descriptor type (member AS - 512)
802 00 00 00 64 <- value (100)
803 02 01 <- node descriptor type (bgpId - 513)
805 19 19 19 01 <- bgpId (25.25.25.1)
806 02 02 <- node descriptor type (areaId - 514)
809 02 03 <- node descriptor type (routeId - 515)
811 03 03 03 04 0b 0b 0b 03 <- OSPF Router Id
813 01 03 <- link descriptor type (IPv4 interface address - 259)
815 0b 0b 0b 01 <- value (11.11.11.1)
817 40 <- attribute flags
818 01 <- attribute type (Origin)
819 01 <- attribute length
821 40 <- attribute flags
822 02 <- attribute type (AS Path)
824 40 <- attribute flags
825 05 <- attribute type (local pref)
828 c0 <- attribute flags
829 63 <- attribute type (Link STATE - 99)
831 04 47 <- link attribute (1095 - Metric)
837 // FIXME: to be fixed in testing phase
838 public void testBGPLink() throws Exception {
839 final byte[] body = ByteArray.cutBytes(inputBytes.get(8), MessageUtil.COMMON_HEADER_LENGTH);
840 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(8), MessageUtil.MARKER_LENGTH,
841 MessageUtil.LENGTH_FIELD_LENGTH));
842 final Update message = BGPParserTest.updateParser.parseMessageBody(body, messageLength);
846 assertNull(message.getWithdrawnRoutes());
848 // network object state
849 // final NetworkObjectState objState = new NetworkObjectState(Collections.<AsPathSegment> emptyList(),
850 // Collections.<Community> emptySet(), Collections.<ExtendedCommunity> emptySet());
851 // final BaseBGPObjectState state = new BaseBGPObjectState(BgpOrigin.Igp, null);
853 // network link state
854 // final DefaultingTypesafeContainer<Metric<?>> container = new DefaultingTypesafeContainer<Metric<?>>();
855 // container.setDefaultEntry(new IGPMetric(1));
856 // final NetworkLinkState linkState = new NetworkLinkState(objState, container, null,
857 // LinkProtectionType.UNPROTECTED, null, null, null);
859 // final NodeIdentifierFactory f100 = new NodeIdentifierFactory(new AsNumber((long) 100), new
860 // DomainIdentifier(new byte[] { 25, 25,
861 // 25, 1 }), new AreaIdentifier(new byte[] { 0, 0, 0, 0 }));
863 // final NodeIdentifier nodeid1 = f100.identifierForRouter(new OSPFv3LANIdentifier(new OSPFRouterIdentifier(new
864 // byte[] { 3, 3, 3, 4 }), new OSPFInterfaceIdentifier(new byte[] {
865 // 0x0b, 0x0b, 0x0b, 0x03 })));
866 // final NodeIdentifier nodeid2 = f100.identifierForRouter(new OSPFRouterIdentifier(new byte[] { 3, 3, 3, 4 }));
868 // final NodeIdentifier nodeid3 = f100.identifierForRouter(new OSPFRouterIdentifier(new byte[] { 1, 1, 1, 2 }));
872 // final LinkIdentifier linkId1 = new LinkIdentifier(null, new LinkAnchor(nodeid1, new
873 // IPv4InterfaceIdentifier(IPv4.FAMILY.addressForString("11.11.11.3"))), new LinkAnchor(nodeid2, null));
874 // final LinkIdentifier linkId2 = new LinkIdentifier(null, new LinkAnchor(nodeid1, new
875 // IPv4InterfaceIdentifier(IPv4.FAMILY.addressForString("11.11.11.1"))), new LinkAnchor(nodeid3, null));
876 // final LinkIdentifier linkId3 = new LinkIdentifier(null, new LinkAnchor(nodeid3, new
877 // IPv4InterfaceIdentifier(IPv4.FAMILY.addressForString("11.11.11.1"))), new LinkAnchor(nodeid1, null));
879 // final BGPLink link1 = new BGPLinkImpl(state, linkId1, linkState);
880 // final BGPLink link2 = new BGPLinkImpl(state, linkId2, linkState);
881 // final BGPLink link3 = new BGPLinkImpl(state, linkId3, linkState);
883 // final BGPUpdateMessage expectedMessage = new BGPUpdateMessageImpl(Sets.newHashSet((BGPObject) link1,
884 // (BGPObject) link2,
885 // (BGPObject) link3), Collections.<Identifier> emptySet());
887 // assertEquals(expectedMessage, message);
893 * 00 00 <- withdrawn routes length
894 00 b2 <- total path attribute length (178)
895 90 <- attribute flags
896 0e <- attribute type code (MP reach)
897 00 a0 <- attribute extended length (160)
898 40 04 <- AFI (16388 - Linkstate)
899 47 <- SAFI (71 - Linkstate)
900 04 <- next hop length
901 19 19 19 01 - nexthop (25.25.25.1)
903 00 01 <- NLRI type (1 - nodeNLRI)
904 00 31 <- NLRI length (49)
905 03 <- ProtocolID - OSPF
906 00 00 00 00 00 00 00 01 <- identifier
908 01 00 <- local node descriptor type (256)
910 02 00 <- node descriptor type (member AS - 512)
912 00 00 00 64 <- value (100)
913 02 01 <- node descriptor type (bgpId - 513)
915 19 19 19 01 <- bgpId (25.25.25.1)
916 02 02 <- node descriptor type (areaId - 514)
919 02 03 <- node descriptor type (routeId - 515)
921 03 03 03 04 0b 0b 0b 03 <- OSPF Router Id
923 00 01 <- NLRI type (1 - nodeNLRI)
924 00 2d <- NLRI length (45)
925 03 <- ProtocolID - OSPF
926 00 00 00 00 00 00 00 01 <- identifier
928 01 00 <- local node descriptor type (256)
930 02 00 <- node descriptor type (member AS - 512)
932 00 00 00 64 <- value (100)
933 02 01 <- node descriptor type (bgpId - 513)
935 19 19 19 01 <- bgpId (25.25.25.1)
936 02 02 <- node descriptor type (areaId - 514)
939 02 03 <- node descriptor type (routeId - 515)
941 03 03 03 04 <- OSPF Router Id
943 00 01 <- NLRI type (1 - nodeNLRI)
944 00 2d <- NLRI length (45)
945 03 <- ProtocolID - OSPF
946 00 00 00 00 00 00 00 01 <- identifier
947 01 00 <- local node descriptor type (256)
949 02 00 <- node descriptor type (member AS - 512)
951 00 00 00 64 <- value (100)
952 02 01 <- node descriptor type (bgpId - 513)
954 19 19 19 01 <- bgpId (25.25.25.1)
955 02 02 <- node descriptor type (areaId - 514)
958 02 03 <- node descriptor type (routeId - 515)
960 01 01 01 02 <- OSPF Router Id
962 40 <- attribute flags
963 01 <- attribute type (Origin)
964 01 <- attribute length
966 40 <- attribute flags
967 02 <- attribute type (AS Path)
969 40 <- attribute flags
970 05 <- attribute type (local pref)
976 // FIXME: to be fixed in testing phase
977 public void testBGPNode() throws Exception {
978 final byte[] body = ByteArray.cutBytes(inputBytes.get(9), MessageUtil.COMMON_HEADER_LENGTH);
979 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(9), MessageUtil.MARKER_LENGTH,
980 MessageUtil.LENGTH_FIELD_LENGTH));
981 final Update message = BGPParserTest.updateParser.parseMessageBody(body, messageLength);
985 assertNull(message.getWithdrawnRoutes());
987 // network object state
988 // final NetworkObjectState objState = new NetworkObjectState(Collections.<AsPathSegment> emptyList(),
989 // Collections.<Community> emptySet(), Collections.<ExtendedCommunity> emptySet());
990 // final BaseBGPObjectState state = new BaseBGPObjectState(BgpOrigin.Igp, null);
991 // final NetworkNodeState nstate = new NetworkNodeState(objState, Collections.<TopologyIdentifier> emptySet(),
992 // Collections.<ISISAreaIdentifier> emptySet(), false, false, false, false, Collections.<RouterIdentifier>
993 // emptySet(), null);
995 // network link state
997 // final NodeIdentifierFactory f100 = new NodeIdentifierFactory(new AsNumber((long) 100), new
998 // DomainIdentifier(new byte[] { 25, 25,
999 // 25, 1 }), new AreaIdentifier(new byte[] { 0, 0, 0, 0 }));
1001 // final NodeIdentifier nodeid1 = f100.identifierForRouter(new OSPFv3LANIdentifier(new OSPFRouterIdentifier(new
1002 // byte[] { 3, 3, 3, 4 }), new OSPFInterfaceIdentifier(new byte[] {
1003 // 0x0b, 0x0b, 0x0b, 0x03 })));
1004 // final NodeIdentifier nodeid2 = f100.identifierForRouter(new OSPFRouterIdentifier(new byte[] { 3, 3, 3, 4 }));
1006 // final NodeIdentifier nodeid3 = f100.identifierForRouter(new OSPFRouterIdentifier(new byte[] { 1, 1, 1, 2 }));
1008 // check API message
1010 // final BGPNode node1 = new BGPNodeImpl(state, nodeid1, nstate);
1011 // final BGPNode node2 = new BGPNodeImpl(state, nodeid2, nstate);
1012 // final BGPNode node3 = new BGPNodeImpl(state, nodeid3, nstate);
1014 // final BGPUpdateMessage expectedMessage = new BGPUpdateMessageImpl(Sets.newHashSet((BGPObject) node1,
1015 // (BGPObject) node2,
1016 // (BGPObject) node3), Collections.<Identifier> emptySet());
1018 // assertEquals(expectedMessage, message);
1022 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
1023 * 00 98 <- length (69) - including header
1024 * 01 <- message type
1026 * 00 64 <- My AS Number (AS TRANS in this case)
1027 * 00 b4 <- Hold Time
1028 * 00 00 00 00 <- BGP Identifier
1029 * 28 <- Optional Parameters Length
1030 * 02 <- opt. param. type (capabilities)
1032 * 01 <- capability code (MP Extensions for BGP4)
1034 * 00 01 00 01 <- AFI 1, SAFI 1
1035 * 02 <- opt. param. type (capabilities)
1037 * 01 <- capability code (MP Extensions for BGP4)
1039 * 00 02 00 01 <- AFI 2, SAFI 1
1040 * 02 <- opt. param. type (capabilities)
1042 * 01 <- capability code (MP Extensions for BGP4)
1044 * 40 04 00 47 <- AFI 16388, SAFI 71
1045 * 02 <- opt. param. type (capabilities)
1047 * 80 <- capability code (private)
1049 * 02 <- opt. param. type (capabilities)
1051 * 02 <- capability code (Route refresh)
1053 * 02 <- opt. param. type (capabilities)
1055 * 41 <- capability code (AS4 octet support)
1057 * 00 00 00 64 <- AS number
1060 public void testOpenMessage() throws Exception {
1061 final MessageRegistry msgReg = BGPExtensionConsumerContextImpl.getSingletonInstance().getMessageRegistry();
1062 final Open open = (Open) msgReg.parseMessage(inputBytes.get(13));
1063 final Set<BgpTableType> types = Sets.newHashSet();
1064 for (final BgpParameters param : open.getBgpParameters()) {
1065 final CParameters p = param.getCParameters();
1066 if (p instanceof CMultiprotocol) {
1067 final BgpTableType type = new BgpTableTypeImpl(((CMultiprotocol) p).getMultiprotocolCapability().getAfi(), ((CMultiprotocol) p).getMultiprotocolCapability().getSafi());
1071 final Set<BgpTableType> expected = Sets.newHashSet();
1072 expected.add(new BgpTableTypeImpl(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class));
1073 expected.add(new BgpTableTypeImpl(Ipv6AddressFamily.class, UnicastSubsequentAddressFamily.class));
1074 expected.add(new BgpTableTypeImpl(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class));
1075 assertEquals(expected, types);