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.BGPMessageFactory;
26 import org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl;
27 import org.opendaylight.protocol.bgp.parser.impl.message.BGPUpdateMessageParser;
28 import org.opendaylight.protocol.bgp.parser.impl.message.update.SimpleAttributeRegistry;
29 import org.opendaylight.protocol.bgp.parser.spi.MessageRegistry;
30 import org.opendaylight.protocol.bgp.parser.spi.MessageUtil;
31 import org.opendaylight.protocol.concepts.IGPMetric;
32 import org.opendaylight.protocol.concepts.IPv4;
33 import org.opendaylight.protocol.concepts.IPv4Prefix;
34 import org.opendaylight.protocol.concepts.Metric;
35 import org.opendaylight.protocol.util.ByteArray;
36 import org.opendaylight.protocol.util.DefaultingTypesafeContainer;
37 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
38 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
39 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
40 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev130918.LinkstateAddressFamily;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev130918.LinkstateSubsequentAddressFamily;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.Open;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.Update;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.UpdateBuilder;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.open.BgpParameters;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.open.bgp.parameters.CParameters;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.path.attributes.AggregatorBuilder;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.path.attributes.as.path.SegmentsBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.update.WithdrawnRoutesBuilder;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130918.BgpTableType;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130918.PathAttributes1;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130918.open.bgp.parameters.c.parameters.CMultiprotocol;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.AddressFamily;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.AsPathSegment;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpAggregator;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Community;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv6AddressFamily;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.SubsequentAddressFamily;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.as.path.segment.c.segment.CAListBuilder;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.as.path.segment.c.segment.CASetBuilder;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.as.path.segment.c.segment.c.a.list.AsSequence;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.as.path.segment.c.segment.c.a.list.AsSequenceBuilder;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.ExtendedCommunity;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.extended.community.CInet4SpecificExtendedCommunityBuilder;
68 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;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.CIpv4NextHop;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.CIpv4NextHopBuilder;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.CIpv6NextHop;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.CIpv6NextHopBuilder;
73 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;
74 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;
76 import com.google.common.collect.Lists;
77 import com.google.common.collect.Sets;
79 public class BGPParserTest {
82 * Used by other tests as well
84 static final List<byte[]> inputBytes = new ArrayList<byte[]>();
86 private static int COUNTER = 17;
88 private static int MAX_SIZE = 300;
90 private static MessageRegistry reg;
92 private static BGPUpdateMessageParser updateParser;
95 public static void setUp() throws Exception {
96 reg = SimpleBGPMessageFactory.getInstance();
97 updateParser = new BGPUpdateMessageParser(SimpleAttributeRegistry.getInstance());
99 for (int i = 1; i <= COUNTER; i++) {
100 final String name = "/up" + i + ".bin";
101 final InputStream is = BGPParserTest.class.getResourceAsStream(name);
103 throw new IOException("Failed to get resource " + name);
106 final ByteArrayOutputStream bis = new ByteArrayOutputStream();
107 final byte[] data = new byte[MAX_SIZE];
109 while ((nRead = is.read(data, 0, data.length)) != -1) {
110 bis.write(data, 0, nRead);
114 inputBytes.add(bis.toByteArray());
119 public void testResource() {
120 assertNotNull(inputBytes);
124 * Tests IPv4 NEXT_HOP, ATOMIC_AGGREGATE, COMMUNITY, NLRI
126 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
127 * 00 54 <- length (84) - including header
129 * 00 00 <- withdrawn routes length
130 * 00 31 <- total path attribute length (49)
131 * 40 <- attribute flags
132 * 01 <- attribute type code (origin)
133 * 01 <- attribute length
134 * 00 <- Origin value (IGP)
135 * 40 <- attribute flags
136 * 02 <- attribute type code (as path)
137 * 06 <- attribute length
139 * 01 <- path segment count
140 * 00 00 fd ea <- path segment value (65002)
141 * 40 <- attribute flags
142 * 03 <- attribute type code (Next Hop)
143 * 04 <- attribute length
144 * 10 00 00 02 <- value (10.0.0.2)
145 * 80 <- attribute flags
146 * 04 <- attribute type code (multi exit disc)
147 * 04 <- attribute length
148 * 00 00 00 00 <- value
149 * 64 <- attribute flags
150 * 06 <- attribute type code (atomic aggregate)
151 * 00 <- attribute length
152 * 64 <- attribute flags
153 * 08 <- attribute type code (community)
154 * 10 <- attribute length FF FF FF
155 * 01 <- value (NO_EXPORT)
156 * FF FF FF 02 <- value (NO_ADVERTISE)
157 * FF FF FF 03 <- value (NO_EXPORT_SUBCONFED)
158 * FF FF FF 10 <- unknown Community
161 * 18 ac 11 02 <- IPv4 Prefix (172.17.2.0 / 24)
162 * 18 ac 11 01 <- IPv4 Prefix (172.17.1.0 / 24)
163 * 18 ac 11 00 <- IPv4 Prefix (172.17.0.0 / 24)
167 // FIXME: to be fixed in testing phase
168 public void testGetUpdateMessage1() throws Exception {
170 final byte[] body = ByteArray.cutBytes(inputBytes.get(0), MessageUtil.COMMON_HEADER_LENGTH);
171 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(0), MessageUtil.MARKER_LENGTH,
172 MessageUtil.LENGTH_FIELD_LENGTH));
173 final Update message = updateParser.parseMessageBody(body, messageLength);
177 assertNull(message.getWithdrawnRoutes());
181 final List<AsSequence> asnums = Lists.newArrayList(new AsSequenceBuilder().setAs(new AsNumber(65002L)).build());
182 final List<AsPathSegment> asPath = Lists.newArrayList();
183 asPath.add(new SegmentsBuilder().setCSegment(new CAListBuilder().setAsSequence(asnums).build()).build());
185 final CIpv4NextHop nextHop = new CIpv4NextHopBuilder().setIpv4NextHop(
186 new Ipv4NextHopBuilder().setGlobal(new Ipv4Address("10.0.0.2")).build()).build();
188 final Set<Community> comms = new HashSet<>();
189 comms.add(CommunityUtil.NO_EXPORT);
190 comms.add(CommunityUtil.NO_ADVERTISE);
191 comms.add(CommunityUtil.NO_EXPORT_SUBCONFED);
192 comms.add(CommunityUtil.create(0xFFFF, 0xFF10));
194 // check path attributes
196 // final PathAttribute originAttr = new PathAttribute(TypeCode.ORIGIN, false,
197 // true, false, false, BGPOrigin.IGP);
198 // assertEquals(originAttr, attrs.get(0));
200 // final PathAttribute asPathAttr = new PathAttribute(TypeCode.AS_PATH, false,
201 // true, false, false, asPath);
202 // assertEquals(asPathAttr, attrs.get(1));
204 // final PathAttribute nextHopAttr = new PathAttribute(TypeCode.NEXT_HOP, false,
205 // true, false, false, nextHop);
206 // assertEquals(nextHopAttr, attrs.get(2));
208 // final PathAttribute multiExitDisc = new PathAttribute(
209 // TypeCode.MULTI_EXIT_DISC, true, false, false, false, 0);
210 // assertEquals(multiExitDisc, attrs.get(3));
212 // final PathAttribute atomic = new PathAttribute(TypeCode.ATOMIC_AGGREGATE, false,
213 // true, true, false, null);
214 // assertEquals(atomic, attrs.get(4));
216 // final PathAttribute comm = new PathAttribute(TypeCode.COMMUNITIES, false,
217 // true, true, false, comms);
218 // assertEquals(comm, attrs.get(5));
222 // final Set<IPv4Prefix> nlri = Sets.newHashSet(pref1, pref2, pref3);
223 // assertEquals(nlri, ret.getBgpUpdateMessageBuilder().getNlri());
225 // final BaseBGPObjectState state = new BaseBGPObjectState(BgpOrigin.Igp, null);
226 // final NetworkRouteState routeState = new NetworkRouteState(new NetworkObjectState(asPath, comms, Collections.<ExtendedCommunity> emptySet()), nextHop);
230 // final Set<BGPObject> addedObjects = Sets.newHashSet();
232 // final BGPRoute route1 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("172.17.2.0/24"), state, routeState);
234 // addedObjects.add(route1);
236 // final BGPRoute route2 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("172.17.1.0/24"), state, routeState);
238 // addedObjects.add(route2);
240 // final BGPRoute route3 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("172.17.0.0/24"), state, routeState);
242 // addedObjects.add(route3);
246 * Tests IPv6 NEXT_HOP, NLRI, ORIGIN.IGP, MULTI_EXIT_DISC, ORIGINATOR-ID, CLUSTER_LIST.
248 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
249 * 00 80 <- length (128) - including header
251 * 00 00 <- withdrawn routes length
252 * 00 69 <- total path attribute length (105)
253 * 40 <- attribute flags
254 * 01 <- attribute type code (origin)
255 * 01 <- attribute length
256 * 00 <- Origin value (IGP)
257 * 40 <- attribute flags
258 * 02 <- attribute type code (as path)
259 * 06 <- attribute length
261 * 01 <- path segment count
262 * 00 00 fd e9 <- path segment value (65001)
263 * 80 <- attribute flags
264 * 04 <- attribute type code (multi exit disc)
265 * 04 <- attribute length
266 * 00 00 00 00 <- value
267 * 80 <- attribute flags
268 * 09 <- attribute type code (originator id)
269 * 04 <- attribute length
270 * 7f 00 00 01 <- value (localhost ip)
271 * 80 <- attribute flags
272 * 0a <- attribute type code (cluster list)
273 * 08 <- attribute length
274 * 01 02 03 04 <- value
275 * 05 06 07 08 <- value
276 * 80 <- attribute flags
277 * 0e <- attribute type code (mp reach nlri)
278 * 40 <- attribute length
279 * 00 02 <- AFI (Ipv6)
280 * 01 <- SAFI (Unicast)
281 * 20 <- length of next hop
282 * 20 01 0d b8 00 00 00 00 00 00 00 00 00 00 00 01 <- global
283 * fe 80 00 00 00 00 00 00 c0 01 0b ff fe 7e 00 <- link local
287 * 40 20 01 0d b8 00 01 00 02 <- IPv6 Prefix (2001:db8:1:2:: / 64)
288 * 40 20 01 0d b8 00 01 00 01 <- IPv6 Prefix (2001:db8:1:1:: / 64)
289 * 40 20 01 0d b8 00 01 00 00 <- IPv6 Prefix (2001:db8:1:: / 64)
294 // FIXME: to be fixed in testing phase
295 public void testGetUpdateMessage2() throws Exception {
296 final byte[] body = ByteArray.cutBytes(inputBytes.get(1), MessageUtil.COMMON_HEADER_LENGTH);
297 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(1), MessageUtil.MARKER_LENGTH,
298 MessageUtil.LENGTH_FIELD_LENGTH));
299 final Update message = updateParser.parseMessageBody(body, messageLength);
302 assertNull(message.getWithdrawnRoutes());
305 final List<AsSequence> asnums = Lists.newArrayList(new AsSequenceBuilder().setAs(new AsNumber(65001L)).build());
306 final List<AsPathSegment> asPath = Lists.newArrayList();
307 asPath.add(new SegmentsBuilder().setCSegment(new CAListBuilder().setAsSequence(asnums).build()).build());
309 final CIpv6NextHop nextHop = new CIpv6NextHopBuilder().setIpv6NextHop(
310 new Ipv6NextHopBuilder().setGlobal(new Ipv6Address("2001:db8::1")).setLinkLocal(new Ipv6Address("fe80::c001:bff:fe7e:0")).build()).build();
312 // final List<ClusterIdentifier> clusters = Lists.newArrayList(
313 // new ClusterIdentifier(new byte[] { 1, 2, 3, 4}),
314 // new ClusterIdentifier(new byte[] { 5, 6, 7, 8}));
316 // check path attributes
318 // final PathAttribute originAttr = new PathAttribute(TypeCode.ORIGIN, false,
319 // true, false, false, BGPOrigin.IGP);
320 // assertEquals(originAttr, attrs.get(0));
322 // final PathAttribute asPathAttr = new PathAttribute(TypeCode.AS_PATH, false,
323 // true, false, false, asPath);
324 // assertEquals(asPathAttr, attrs.get(1));
326 // final PathAttribute multiExitDisc = new PathAttribute(
327 // TypeCode.MULTI_EXIT_DISC, true, false, false, false, 0);
328 // assertEquals(multiExitDisc, attrs.get(2));
330 // final PathAttribute originatorAttr = new PathAttribute(
331 // TypeCode.ORIGINATOR_ID, true, false, false, false, IPv4.FAMILY.addressForString("127.0.0.1"));
332 // assertEquals(originatorAttr, attrs.get(3));
334 // final PathAttribute clusterAttr = new PathAttribute(
335 // TypeCode.CLUSTER_LIST, true, false, false, false, clusters);
336 // assertEquals(clusterAttr, attrs.get(4));
338 // final BaseBGPObjectState state = new BaseBGPObjectState(BgpOrigin.Igp, null);
339 // final NetworkRouteState routeState = new NetworkRouteState(new NetworkObjectState(asPath, Collections.<Community> emptySet(), Collections.<ExtendedCommunity> emptySet()), nextHop);
343 // final Set<BGPObject> addedObjects = Sets.newHashSet();
345 // final BGPRoute route1 = new BGPIPv6RouteImpl(IPv6.FAMILY.prefixForString("2001:db8:1:2::/64"), state, routeState);
347 // addedObjects.add(route1);
349 // final BGPRoute route2 = new BGPIPv6RouteImpl(IPv6.FAMILY.prefixForString("2001:db8:1:1::/64"), state, routeState);
351 // addedObjects.add(route2);
353 // final BGPRoute route3 = new BGPIPv6RouteImpl(IPv6.FAMILY.prefixForString("2001:db8:1::/64"), state, routeState);
355 // addedObjects.add(route3);
359 * Tests more AS Numbers in AS_PATH, AGGREGATOR, ORIGIN.INCOMPLETE
361 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
362 * 00 4b <- length (75) - including header
364 * 00 00 <- withdrawn routes length
365 * 00 30 <- total path attribute length (48)
366 * 40 <- attribute flags
367 * 01 <- attribute type code (origin)
368 * 01 <- attribute length
369 * 02 <- Origin value (Incomplete)
370 * 40 <- attribute flags
371 * 02 <- attribute type code (as path)
372 * 10 <- attribute length
374 * 01 <- path segment count
375 * 00 00 00 1e <- path segment value (30)
377 * 02 <- path segment count
378 * 00 00 00 0a <- path segment value (10)
379 * 00 00 00 14 <- path segment value (20)
380 * 40 <- attribute flags
381 * 03 <- attribute type (Next hop)
382 * 04 <- attribute length
383 * 0a 00 00 09 <- value (10.0.0.9)
384 * 80 <- attribute flags
385 * 04 <- attribute type code (multi exit disc)
386 * 04 <- attribute length
387 * 00 00 00 00 <- value
388 * c0 <- attribute flags
389 * 07 <- attribute type (Aggregator)
390 * 08 <- attribute length
391 * 00 00 00 1e <- value (AS number = 30)
392 * 0a 00 00 09 <- value (IP address = 10.0.0.9)
395 * 15 ac 10 00 <- IPv4 Prefix (172.16.0.0 / 21)
399 // FIXME: to be fixed in testing phase
400 public void testGetUpdateMessage3() throws Exception {
401 final byte[] body = ByteArray.cutBytes(inputBytes.get(2), MessageUtil.COMMON_HEADER_LENGTH);
402 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(2), MessageUtil.MARKER_LENGTH,
403 MessageUtil.LENGTH_FIELD_LENGTH));
404 final Update message = updateParser.parseMessageBody(body, messageLength);
407 assertNull(message.getWithdrawnRoutes());
411 final List<AsSequence> asnums = Lists.newArrayList(new AsSequenceBuilder().setAs(new AsNumber(30L)).build());
412 final List<AsPathSegment> asPath = Lists.newArrayList();
413 asPath.add(new SegmentsBuilder().setCSegment(new CAListBuilder().setAsSequence(asnums).build()).build());
414 asPath.add(new SegmentsBuilder().setCSegment(
415 new CASetBuilder().setAsSet(Lists.newArrayList(new AsNumber(10L), new AsNumber(20L))).build()).build());
417 final BgpAggregator aggregator = new AggregatorBuilder().setAsNumber(new AsNumber((long) 30)).setNetworkAddress(
418 new Ipv4Address("10.0.0.9")).build();
419 final CIpv4NextHop nextHop = new CIpv4NextHopBuilder().setIpv4NextHop(
420 new Ipv4NextHopBuilder().setGlobal(new Ipv4Address("10.0.0.9")).build()).build();
422 final IPv4Prefix pref1 = IPv4.FAMILY.prefixForString("172.16.0.0/21");
424 // check path attributes
426 // final PathAttribute originAttr = new PathAttribute(TypeCode.ORIGIN, false,
427 // true, false, false, BGPOrigin.INCOMPLETE);
428 // assertEquals(originAttr, attrs.get(0));
430 // final PathAttribute asPathAttr = new PathAttribute(TypeCode.AS_PATH, false,
431 // true, false, false, asPath);
432 // assertEquals(asPathAttr, attrs.get(1));
434 // final PathAttribute nextHopAttr = new PathAttribute(TypeCode.NEXT_HOP, false,
435 // true, false, false, nextHop);
436 // assertEquals(nextHopAttr, attrs.get(2));
438 // final PathAttribute multiExitDisc = new PathAttribute(
439 // TypeCode.MULTI_EXIT_DISC, true, false, false, false, 0);
440 // assertEquals(multiExitDisc, attrs.get(3));
442 // final PathAttribute agg = new PathAttribute(TypeCode.AGGREGATOR, true, true,
443 // false, false, aggregator);
444 // assertEquals(agg, attrs.get(4));
448 // final Set<IPv4Prefix> nlri = Sets.newHashSet(pref1);
449 // assertEquals(nlri, ret.getBgpUpdateMessageBuilder().getNlri());
451 // final BaseBGPObjectState state = new BaseBGPObjectState(BgpOrigin.Incomplete, aggregator);
452 // final NetworkRouteState routeState = new NetworkRouteState(new NetworkObjectState(asPath, 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 = 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> emptyList(), Collections.<Community> emptySet(), comms), nextHop);
557 // final Set<BGPObject> addedObjects = Sets.newHashSet();
559 // final BGPRoute route1 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("10.30.3.0/24"), state, routeState);
561 // addedObjects.add(route1);
563 // final BGPRoute route2 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("10.30.2.0/24"), state, routeState);
565 // addedObjects.add(route2);
567 // final BGPRoute route3 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("10.30.1.0/24"), state, routeState);
569 // addedObjects.add(route3);
573 * Tests withdrawn routes.
575 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
576 * 00 1c <- length (28) - including header
578 * 00 05 <- withdrawn routes length (5)
579 * 1e ac 10 00 04 <- route (172.16.0.4)
580 * 00 00 <- total path attribute length
584 // FIXME: to be fixed in testing phase
585 public void testGetUpdateMessage5() throws Exception {
586 final byte[] body = ByteArray.cutBytes(inputBytes.get(4), MessageUtil.COMMON_HEADER_LENGTH);
587 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(4), MessageUtil.MARKER_LENGTH,
588 MessageUtil.LENGTH_FIELD_LENGTH));
589 final Update message = updateParser.parseMessageBody(body, messageLength);
593 List<Ipv4Prefix> prefs = Lists.newArrayList(new Ipv4Prefix("172.16.0.4/30"));
597 final Update expectedMessage = new UpdateBuilder().setWithdrawnRoutes(new WithdrawnRoutesBuilder().setWithdrawnRoutes(prefs).build()).build();
599 assertEquals(expectedMessage.getWithdrawnRoutes().getWithdrawnRoutes().get(0).toString(), message.getWithdrawnRoutes().getWithdrawnRoutes().get(0).toString());
605 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
606 * 00 17 <- length (23) - including header
608 * 00 00 <- withdrawn routes length
609 * 00 00 <- total path attribute length
612 public void testEORIpv4() throws Exception {
613 final byte[] body = ByteArray.cutBytes(inputBytes.get(5), MessageUtil.COMMON_HEADER_LENGTH);
614 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(5), MessageUtil.MARKER_LENGTH,
615 MessageUtil.LENGTH_FIELD_LENGTH));
616 final Update message = updateParser.parseMessageBody(body, messageLength);
618 assertEquals(new UpdateBuilder().build(), message);
622 * End of Rib for Ipv6 consists of empty MP_UNREACH_NLRI, with AFI 2 and SAFI 1
624 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
625 * 00 1d <- length (29) - including header
627 * 00 00 <- withdrawn routes length
628 * 00 06 <- total path attribute length
629 * 80 <- attribute flags
630 * 0f <- attribute type (15 - MP_UNREACH_NLRI)
631 * 03 <- attribute length
632 * 00 02 <- value (AFI 2: IPv6)
633 * 01 <- value (SAFI 1)
637 //FIXME: to be fixed in testing phase
638 public void testEORIpv6() throws Exception {
639 final byte[] body = ByteArray.cutBytes(inputBytes.get(6), MessageUtil.COMMON_HEADER_LENGTH);
640 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(6), MessageUtil.MARKER_LENGTH,
641 MessageUtil.LENGTH_FIELD_LENGTH));
642 final Update message = updateParser.parseMessageBody(body, messageLength);
646 Class<? extends AddressFamily> afi = message.getPathAttributes().getAugmentation(PathAttributes1.class).getMpReachNlri().getAfi();
647 SubsequentAddressFamily safi = message.getPathAttributes().getAugmentation(PathAttributes1.class).getMpReachNlri().getSafi().newInstance();
649 assertEquals(Ipv6AddressFamily.class, afi);
650 assertEquals(UnicastSubsequentAddressFamily.INSTANCE, safi);
654 * End of Rib for LS consists of empty MP_UNREACH_NLRI, with AFI 16388 and SAFI 71
656 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
657 * 00 1d <- length (29) - including header
659 * 00 00 <- withdrawn routes length
660 * 00 06 <- total path attribute length
661 * 80 <- attribute flags
662 * 0f <- attribute type (15 - MP_UNREACH_NLRI)
663 * 03 <- attribute length
664 * 40 04 <- value (AFI 16388: LS)
665 * 47 <- value (SAFI 71)
669 //FIXME: to be fixed in testing phase
670 public void testEORLS() throws Exception {
671 final byte[] body = ByteArray.cutBytes(inputBytes.get(7), MessageUtil.COMMON_HEADER_LENGTH);
672 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(7), MessageUtil.MARKER_LENGTH,
673 MessageUtil.LENGTH_FIELD_LENGTH));
674 final Update message = updateParser.parseMessageBody(body, messageLength);
676 Class<? extends AddressFamily> afi = message.getPathAttributes().getAugmentation(PathAttributes1.class).getMpReachNlri().getAfi();
677 SubsequentAddressFamily safi = message.getPathAttributes().getAugmentation(PathAttributes1.class).getMpReachNlri().getSafi().newInstance();
679 assertEquals(LinkstateAddressFamily.class, afi);
680 assertEquals(LinkstateSubsequentAddressFamily.INSTANCE, safi);
684 * Tests BGP Link Ipv4
686 00 00 <- withdrawn routes length
687 01 48 <- total path attribute length (328)
688 90 <- attribute flags
689 0e <- attribute type code (MP reach)
690 01 2c <- attribute extended length (300)
691 40 04 <- AFI (16388 - Linkstate)
692 47 <- SAFI (71 - Linkstate)
693 04 <- next hop length
694 19 19 19 01 <- nexthop (25.25.25.1)
697 00 02 <- NLRI type (2 - linkNLRI)
698 00 5d <- NLRI length (93)
699 03 <- ProtocolID - OSPF
700 00 00 00 00 00 00 00 01 <- identifier
702 01 00 <- local node descriptor type (256)
704 02 00 <- node descriptor type (member AS - 512)
706 00 00 00 64 <- value (100)
707 02 01 <- node descriptor type (bgpId - 513)
709 19 19 19 01 <- bgpId (25.25.25.1)
710 02 02 <- node descriptor type (areaId - 514)
713 02 03 <- node descriptor type (routeId - 515)
715 03 03 03 04 0b 0b 0b 03 <- OSPF Router Id
717 01 01 <- remote node descriptor type (257)
719 02 00 <- node descriptor type (member AS - 512)
721 00 00 00 64 <- value (100)
722 02 01 <- node descriptor type (bgpId - 513)
724 19 19 19 01 <- bgpId (25.25.25.1)
725 02 02 <- node descriptor type (areaId - 514)
728 02 03 <- node descriptor type (routeId - 515)
730 03 03 03 04 <- OSPF Router Id
732 01 03 <- link descriptor type (IPv4 interface address - 259)
734 0b 0b 0b 03 <- value (11.11.11.3)
736 00 02 <- NLRI type (2 - linkNLRI)
737 00 5d <- NLRI length (93)
738 03 <- ProtocolID - OSPF
739 00 00 00 00 00 00 00 01 <- identifier
741 01 00 <- local node descriptor type (256)
743 02 00 <- node descriptor type (member AS - 512)
745 00 00 00 64 <- value (100)
746 02 01 <- node descriptor type (bgpId - 513)
748 19 19 19 01 <- bgpId (25.25.25.1)
749 02 02 <- node descriptor type (areaId - 514)
752 02 03 <- node descriptor type (routeId - 515)
754 03 03 03 04 0b 0b 0b 03 <- OSPF Router Id
756 01 01 <- remote node descriptor type (257)
758 02 00 <- node descriptor type (member AS - 512)
760 00 00 00 64 <- value (100)
761 02 01 <- node descriptor type (bgpId - 513)
763 19 19 19 01 <- bgpId (25.25.25.1)
764 02 02 <- node descriptor type (areaId - 514)
767 02 03 <- node descriptor type (routeId - 515)
769 01 01 01 02 <- OSPF Router Id
771 01 03 <- link descriptor type (IPv4 interface address - 259)
773 0b 0b 0b 01 <- value (11.11.11.1)
775 00 02 <- NLRI type (2 - linkNLRI)
776 00 5d <- NLRI length (93)
777 03 <- ProtocolID - OSPF
778 00 00 00 00 00 00 00 01 <- identifier
780 01 00 <- local node descriptor type (256)
782 02 00 <- node descriptor type (member AS - 512)
784 00 00 00 64 <- value (100)
785 02 01 <- node descriptor type (bgpId - 513)
787 19 19 19 01 <- bgpId (25.25.25.1)
788 02 02 <- node descriptor type (areaId - 514)
791 02 03 <- node descriptor type (routeId - 515)
793 01 01 01 02 <- OSPF Router Id
795 01 01 <- remote node descriptor type (257)
797 02 00 <- node descriptor type (member AS - 512)
799 00 00 00 64 <- value (100)
800 02 01 <- node descriptor type (bgpId - 513)
802 19 19 19 01 <- bgpId (25.25.25.1)
803 02 02 <- node descriptor type (areaId - 514)
806 02 03 <- node descriptor type (routeId - 515)
808 03 03 03 04 0b 0b 0b 03 <- OSPF Router Id
810 01 03 <- link descriptor type (IPv4 interface address - 259)
812 0b 0b 0b 01 <- value (11.11.11.1)
814 40 <- attribute flags
815 01 <- attribute type (Origin)
816 01 <- attribute length
818 40 <- attribute flags
819 02 <- attribute type (AS Path)
821 40 <- attribute flags
822 05 <- attribute type (local pref)
825 c0 <- attribute flags
826 63 <- attribute type (Link STATE - 99)
828 04 47 <- link attribute (1095 - Metric)
834 // FIXME: to be fixed in testing phase
835 public void testBGPLink() throws Exception {
836 final byte[] body = ByteArray.cutBytes(inputBytes.get(8), MessageUtil.COMMON_HEADER_LENGTH);
837 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(8), MessageUtil.MARKER_LENGTH,
838 MessageUtil.LENGTH_FIELD_LENGTH));
839 final Update message = updateParser.parseMessageBody(body, messageLength);
843 assertNull(message.getWithdrawnRoutes());
845 // network object state
846 // final NetworkObjectState objState = new NetworkObjectState(Collections.<AsPathSegment> emptyList(), Collections.<Community> emptySet(), Collections.<ExtendedCommunity> emptySet());
847 // final BaseBGPObjectState state = new BaseBGPObjectState(BgpOrigin.Igp, null);
849 // network link state
850 final DefaultingTypesafeContainer<Metric<?>> container = new DefaultingTypesafeContainer<Metric<?>>();
851 container.setDefaultEntry(new IGPMetric(1));
852 //final NetworkLinkState linkState = new NetworkLinkState(objState, container, null, LinkProtectionType.UNPROTECTED, null, null, null);
854 // final NodeIdentifierFactory f100 = new NodeIdentifierFactory(new AsNumber((long) 100), new DomainIdentifier(new byte[] { 25, 25,
855 // 25, 1 }), new AreaIdentifier(new byte[] { 0, 0, 0, 0 }));
857 // final NodeIdentifier nodeid1 = f100.identifierForRouter(new OSPFv3LANIdentifier(new OSPFRouterIdentifier(new byte[] { 3, 3, 3, 4 }), new OSPFInterfaceIdentifier(new byte[] {
858 // 0x0b, 0x0b, 0x0b, 0x03 })));
859 // final NodeIdentifier nodeid2 = f100.identifierForRouter(new OSPFRouterIdentifier(new byte[] { 3, 3, 3, 4 }));
861 // final NodeIdentifier nodeid3 = f100.identifierForRouter(new OSPFRouterIdentifier(new byte[] { 1, 1, 1, 2 }));
865 // final LinkIdentifier linkId1 = new LinkIdentifier(null, new LinkAnchor(nodeid1, new IPv4InterfaceIdentifier(IPv4.FAMILY.addressForString("11.11.11.3"))), new LinkAnchor(nodeid2, null));
866 // final LinkIdentifier linkId2 = new LinkIdentifier(null, new LinkAnchor(nodeid1, new IPv4InterfaceIdentifier(IPv4.FAMILY.addressForString("11.11.11.1"))), new LinkAnchor(nodeid3, null));
867 // final LinkIdentifier linkId3 = new LinkIdentifier(null, new LinkAnchor(nodeid3, new IPv4InterfaceIdentifier(IPv4.FAMILY.addressForString("11.11.11.1"))), new LinkAnchor(nodeid1, null));
869 // final BGPLink link1 = new BGPLinkImpl(state, linkId1, linkState);
870 // final BGPLink link2 = new BGPLinkImpl(state, linkId2, linkState);
871 // final BGPLink link3 = new BGPLinkImpl(state, linkId3, linkState);
873 // final BGPUpdateMessage expectedMessage = new BGPUpdateMessageImpl(Sets.newHashSet((BGPObject) link1, (BGPObject) link2,
874 // (BGPObject) link3), Collections.<Identifier> emptySet());
876 // assertEquals(expectedMessage, message);
882 * 00 00 <- withdrawn routes length
883 00 b2 <- total path attribute length (178)
884 90 <- attribute flags
885 0e <- attribute type code (MP reach)
886 00 a0 <- attribute extended length (160)
887 40 04 <- AFI (16388 - Linkstate)
888 47 <- SAFI (71 - Linkstate)
889 04 <- next hop length
890 19 19 19 01 - nexthop (25.25.25.1)
892 00 01 <- NLRI type (1 - nodeNLRI)
893 00 31 <- NLRI length (49)
894 03 <- ProtocolID - OSPF
895 00 00 00 00 00 00 00 01 <- identifier
897 01 00 <- local node descriptor type (256)
899 02 00 <- node descriptor type (member AS - 512)
901 00 00 00 64 <- value (100)
902 02 01 <- node descriptor type (bgpId - 513)
904 19 19 19 01 <- bgpId (25.25.25.1)
905 02 02 <- node descriptor type (areaId - 514)
908 02 03 <- node descriptor type (routeId - 515)
910 03 03 03 04 0b 0b 0b 03 <- OSPF Router Id
912 00 01 <- NLRI type (1 - nodeNLRI)
913 00 2d <- NLRI length (45)
914 03 <- ProtocolID - OSPF
915 00 00 00 00 00 00 00 01 <- identifier
917 01 00 <- local node descriptor type (256)
919 02 00 <- node descriptor type (member AS - 512)
921 00 00 00 64 <- value (100)
922 02 01 <- node descriptor type (bgpId - 513)
924 19 19 19 01 <- bgpId (25.25.25.1)
925 02 02 <- node descriptor type (areaId - 514)
928 02 03 <- node descriptor type (routeId - 515)
930 03 03 03 04 <- OSPF Router Id
932 00 01 <- NLRI type (1 - nodeNLRI)
933 00 2d <- NLRI length (45)
934 03 <- ProtocolID - OSPF
935 00 00 00 00 00 00 00 01 <- identifier
936 01 00 <- local node descriptor type (256)
938 02 00 <- node descriptor type (member AS - 512)
940 00 00 00 64 <- value (100)
941 02 01 <- node descriptor type (bgpId - 513)
943 19 19 19 01 <- bgpId (25.25.25.1)
944 02 02 <- node descriptor type (areaId - 514)
947 02 03 <- node descriptor type (routeId - 515)
949 01 01 01 02 <- OSPF Router Id
951 40 <- attribute flags
952 01 <- attribute type (Origin)
953 01 <- attribute length
955 40 <- attribute flags
956 02 <- attribute type (AS Path)
958 40 <- attribute flags
959 05 <- attribute type (local pref)
965 // FIXME: to be fixed in testing phase
966 public void testBGPNode() throws Exception {
967 final byte[] body = ByteArray.cutBytes(inputBytes.get(9), MessageUtil.COMMON_HEADER_LENGTH);
968 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(9), MessageUtil.MARKER_LENGTH,
969 MessageUtil.LENGTH_FIELD_LENGTH));
970 final Update message = updateParser.parseMessageBody(body, messageLength);
974 assertNull(message.getWithdrawnRoutes());
976 // network object state
977 // final NetworkObjectState objState = new NetworkObjectState(Collections.<AsPathSegment> emptyList(), Collections.<Community> emptySet(), Collections.<ExtendedCommunity> emptySet());
978 // final BaseBGPObjectState state = new BaseBGPObjectState(BgpOrigin.Igp, null);
979 // final NetworkNodeState nstate = new NetworkNodeState(objState, Collections.<TopologyIdentifier> emptySet(), Collections.<ISISAreaIdentifier> emptySet(), false, false, false, false, Collections.<RouterIdentifier> emptySet(), null);
981 // network link state
983 // final NodeIdentifierFactory f100 = new NodeIdentifierFactory(new AsNumber((long) 100), new DomainIdentifier(new byte[] { 25, 25,
984 // 25, 1 }), new AreaIdentifier(new byte[] { 0, 0, 0, 0 }));
986 // final NodeIdentifier nodeid1 = f100.identifierForRouter(new OSPFv3LANIdentifier(new OSPFRouterIdentifier(new byte[] { 3, 3, 3, 4 }), new OSPFInterfaceIdentifier(new byte[] {
987 // 0x0b, 0x0b, 0x0b, 0x03 })));
988 // final NodeIdentifier nodeid2 = f100.identifierForRouter(new OSPFRouterIdentifier(new byte[] { 3, 3, 3, 4 }));
990 // final NodeIdentifier nodeid3 = f100.identifierForRouter(new OSPFRouterIdentifier(new byte[] { 1, 1, 1, 2 }));
994 // final BGPNode node1 = new BGPNodeImpl(state, nodeid1, nstate);
995 // final BGPNode node2 = new BGPNodeImpl(state, nodeid2, nstate);
996 // final BGPNode node3 = new BGPNodeImpl(state, nodeid3, nstate);
998 // final BGPUpdateMessage expectedMessage = new BGPUpdateMessageImpl(Sets.newHashSet((BGPObject) node1, (BGPObject) node2,
999 // (BGPObject) node3), Collections.<Identifier> emptySet());
1001 // assertEquals(expectedMessage, message);
1005 * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
1006 * 00 98 <- length (69) - including header
1007 * 01 <- message type
1009 * 00 64 <- My AS Number (AS TRANS in this case)
1010 * 00 b4 <- Hold Time
1011 * 00 00 00 00 <- BGP Identifier
1012 * 28 <- Optional Parameters Length
1013 * 02 <- opt. param. type (capabilities)
1015 * 01 <- capability code (MP Extensions for BGP4)
1017 * 00 01 00 01 <- AFI 1, SAFI 1
1018 * 02 <- opt. param. type (capabilities)
1020 * 01 <- capability code (MP Extensions for BGP4)
1022 * 00 02 00 01 <- AFI 2, SAFI 1
1023 * 02 <- opt. param. type (capabilities)
1025 * 01 <- capability code (MP Extensions for BGP4)
1027 * 40 04 00 47 <- AFI 16388, SAFI 71
1028 * 02 <- opt. param. type (capabilities)
1030 * 80 <- capability code (private)
1032 * 02 <- opt. param. type (capabilities)
1034 * 02 <- capability code (Route refresh)
1036 * 02 <- opt. param. type (capabilities)
1038 * 41 <- capability code (AS4 octet support)
1040 * 00 00 00 64 <- AS number
1043 public void testOpenMessage() throws Exception {
1044 final BGPMessageFactory msgFactory = SimpleBGPMessageFactory.getInstance();
1045 final Open open = (Open) msgFactory.parse(inputBytes.get(13)).get(0);
1046 final Set<BgpTableType> types = Sets.newHashSet();
1047 for (final BgpParameters param : open.getBgpParameters()) {
1048 final CParameters p = param.getCParameters();
1049 if (p instanceof CMultiprotocol) {
1050 final BgpTableType type = new BgpTableTypeImpl(((CMultiprotocol) p).getMultiprotocolCapability().getAfi(), ((CMultiprotocol) p).getMultiprotocolCapability().getSafi());
1054 final Set<BgpTableType> expected = Sets.newHashSet();
1055 expected.add(new BgpTableTypeImpl(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class));
1056 expected.add(new BgpTableTypeImpl(Ipv6AddressFamily.class, UnicastSubsequentAddressFamily.class));
1057 expected.add(new BgpTableTypeImpl(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class));
1058 assertEquals(expected, types);