final AttributeRegistry attrReg = context.getAttributeRegistry();
regs.add(context.registerAttributeParser(OriginAttributeParser.TYPE, new OriginAttributeParser()));
- regs.add(context.registerAttributeParser(AsPathAttributeParser.TYPE, new AsPathAttributeParser()));
+ regs.add(context.registerAttributeParser(AsPathAttributeParser.TYPE, new AsPathAttributeParser(context.getReferenceCache())));
regs.add(context.registerAttributeParser(NextHopAttributeParser.TYPE, new NextHopAttributeParser()));
regs.add(context.registerAttributeParser(MultiExitDiscriminatorAttributeParser.TYPE, new MultiExitDiscriminatorAttributeParser()));
regs.add(context.registerAttributeParser(LocalPreferenceAttributeParser.TYPE, new LocalPreferenceAttributeParser()));
regs.add(context.registerAttributeParser(AtomicAggregateAttributeParser.TYPE, new AtomicAggregateAttributeParser()));
- regs.add(context.registerAttributeParser(AggregatorAttributeParser.TYPE, new AggregatorAttributeParser()));
- regs.add(context.registerAttributeParser(CommunitiesAttributeParser.TYPE, new CommunitiesAttributeParser()));
+ regs.add(context.registerAttributeParser(AggregatorAttributeParser.TYPE, new AggregatorAttributeParser(context.getReferenceCache())));
+ regs.add(context.registerAttributeParser(CommunitiesAttributeParser.TYPE, new CommunitiesAttributeParser(context.getReferenceCache())));
regs.add(context.registerAttributeParser(OriginatorIdAttributeParser.TYPE, new OriginatorIdAttributeParser()));
regs.add(context.registerAttributeParser(ClusterIdAttributeParser.TYPE, new ClusterIdAttributeParser()));
regs.add(context.registerAttributeParser(MPReachAttributeParser.TYPE, new MPReachAttributeParser(nlriReg)));
regs.add(context.registerAttributeParser(MPUnreachAttributeParser.TYPE, new MPUnreachAttributeParser(nlriReg)));
- regs.add(context.registerAttributeParser(ExtendedCommunitiesAttributeParser.TYPE, new ExtendedCommunitiesAttributeParser()));
+ regs.add(context.registerAttributeParser(ExtendedCommunitiesAttributeParser.TYPE, new ExtendedCommunitiesAttributeParser(context.getReferenceCache())));
regs.add(context.registerAttributeParser(AS4AggregatorAttributeParser.TYPE, new AS4AggregatorAttributeParser()));
regs.add(context.registerAttributeParser(AS4PathAttributeParser.TYPE, new AS4PathAttributeParser()));
import org.opendaylight.protocol.bgp.parser.spi.AttributeParser;
import org.opendaylight.protocol.concepts.Ipv4Util;
import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ReferenceCache;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.Aggregator;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.AggregatorBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.update.PathAttributesBuilder;
+import com.google.common.base.Preconditions;
+
public final class AggregatorAttributeParser implements AttributeParser {
public static final int TYPE = 7;
+ private final ReferenceCache refCache;
+
+ public AggregatorAttributeParser(final ReferenceCache refCache) {
+ this.refCache = Preconditions.checkNotNull(refCache);
+ }
+
/**
* Parse AGGREGATOR from bytes
*
* @param bytes byte array to be parsed
* @return {@link Aggregator} BGP Aggregator
*/
- private static Aggregator parseAggregator(final byte[] bytes) {
- final AsNumber asNumber = new AsNumber(ByteArray.bytesToLong(ByteArray.subByte(bytes, 0, AsPathSegmentParser.AS_NUMBER_LENGTH)));
+ private Aggregator parseAggregator(final byte[] bytes) {
+ final AsNumber asNumber = refCache.getSharedReference(new AsNumber(ByteArray.bytesToLong(ByteArray.subByte(bytes, 0, AsPathSegmentParser.AS_NUMBER_LENGTH))));
final Ipv4Address address = Ipv4Util.addressForBytes(ByteArray.subByte(bytes, AsPathSegmentParser.AS_NUMBER_LENGTH, 4));
return new AggregatorBuilder().setAsNumber(asNumber).setNetworkAddress(address).build();
}
import org.opendaylight.protocol.bgp.parser.impl.message.update.AsPathSegmentParser.SegmentType;
import org.opendaylight.protocol.bgp.parser.spi.AttributeParser;
import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ReferenceCache;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.AsPath;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.AsPathBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.as.path.segment.c.segment.a.list._case.a.list.AsSequence;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.as.path.segment.c.segment.a.set._case.ASetBuilder;
+import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import com.google.common.primitives.UnsignedBytes;
public final class AsPathAttributeParser implements AttributeParser {
public static final int TYPE = 2;
+ private final ReferenceCache refCache;
+
+ public AsPathAttributeParser(final ReferenceCache refCache) {
+ this.refCache = Preconditions.checkNotNull(refCache);
+ }
/**
* Parses AS_PATH from bytes.
* @throws BGPDocumentedException if there is no AS_SEQUENCE present (mandatory)
* @throws BGPParsingException
*/
- private static AsPath parseAsPath(final byte[] bytes) throws BGPDocumentedException, BGPParsingException {
+ private static AsPath parseAsPath(final ReferenceCache refCache, final byte[] bytes) throws BGPDocumentedException, BGPParsingException {
int byteOffset = 0;
final List<Segments> ases = Lists.newArrayList();
boolean isSequence = false;
byteOffset += AsPathSegmentParser.LENGTH_SIZE;
if (segmentType == SegmentType.AS_SEQUENCE) {
- final List<AsSequence> numbers = AsPathSegmentParser.parseAsSequence(count,
+ final List<AsSequence> numbers = AsPathSegmentParser.parseAsSequence(refCache, count,
ByteArray.subByte(bytes, byteOffset, count * AsPathSegmentParser.AS_NUMBER_LENGTH));
ases.add(new SegmentsBuilder().setCSegment(
new AListCaseBuilder().setAList(new AListBuilder().setAsSequence(numbers).build()).build()).build());
isSequence = true;
} else {
- final List<AsNumber> list = AsPathSegmentParser.parseAsSet(count,
+ final List<AsNumber> list = AsPathSegmentParser.parseAsSet(refCache, count,
ByteArray.subByte(bytes, byteOffset, count * AsPathSegmentParser.AS_NUMBER_LENGTH));
ases.add(new SegmentsBuilder().setCSegment(new ASetCaseBuilder().setASet(new ASetBuilder().setAsSet(list).build()).build()).build());
@Override
public void parseAttribute(final byte[] bytes, final PathAttributesBuilder builder) throws BGPDocumentedException, BGPParsingException {
- builder.setAsPath(parseAsPath(bytes));
+ builder.setAsPath(parseAsPath(refCache, bytes));
}
}
\ No newline at end of file
import java.util.List;
import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ReferenceCache;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.as.path.segment.c.segment.a.list._case.a.list.AsSequence;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.as.path.segment.c.segment.a.list._case.a.list.AsSequenceBuilder;
}
}
- static List<AsSequence> parseAsSequence(final int count, final byte[] bytes) {
+ static List<AsSequence> parseAsSequence(final ReferenceCache refCache, final int count, final byte[] bytes) {
final List<AsSequence> coll = new ArrayList<>();
int byteOffset = 0;
for (int i = 0; i < count; i++) {
- coll.add(new AsSequenceBuilder().setAs(
- new AsNumber(ByteArray.bytesToLong(ByteArray.subByte(bytes, byteOffset, AS_NUMBER_LENGTH)))).build());
+ coll.add(
+ refCache.getSharedReference(
+ new AsSequenceBuilder().setAs(
+ refCache.getSharedReference(
+ new AsNumber(ByteArray.bytesToLong(ByteArray.subByte(bytes, byteOffset, AS_NUMBER_LENGTH))))).build()));
byteOffset += AS_NUMBER_LENGTH;
}
return coll;
}
- static List<AsNumber> parseAsSet(final int count, final byte[] bytes) {
+ static List<AsNumber> parseAsSet(final ReferenceCache refCache, final int count, final byte[] bytes) {
final List<AsNumber> coll = new ArrayList<>();
int byteOffset = 0;
for (int i = 0; i < count; i++) {
- coll.add(new AsNumber(ByteArray.bytesToLong(ByteArray.subByte(bytes, byteOffset, AS_NUMBER_LENGTH))));
+ coll.add(refCache.getSharedReference(
+ new AsNumber(ByteArray.bytesToLong(ByteArray.subByte(bytes, byteOffset, AS_NUMBER_LENGTH)))));
byteOffset += AS_NUMBER_LENGTH;
}
return coll;
import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
import org.opendaylight.protocol.bgp.parser.spi.AttributeParser;
import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ReferenceCache;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.Communities;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.update.PathAttributesBuilder;
+import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
public final class CommunitiesAttributeParser implements AttributeParser {
public static final int TYPE = 8;
+ private final ReferenceCache refCache;
+
+ public CommunitiesAttributeParser(final ReferenceCache refCache) {
+ this.refCache = Preconditions.checkNotNull(refCache);
+ }
+
@Override
public void parseAttribute(final byte[] bytes, final PathAttributesBuilder builder) throws BGPDocumentedException {
final List<Communities> set = Lists.newArrayList();
int i = 0;
while (i < bytes.length) {
- set.add((Communities) CommunitiesParser.parseCommunity(ByteArray.subByte(bytes, i, CommunitiesParser.COMMUNITY_LENGTH)));
+ set.add((Communities) CommunitiesParser.parseCommunity(refCache, ByteArray.subByte(bytes, i, CommunitiesParser.COMMUNITY_LENGTH)));
i += CommunitiesParser.COMMUNITY_LENGTH;
}
import org.opendaylight.protocol.bgp.parser.BGPError;
import org.opendaylight.protocol.concepts.Ipv4Util;
import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ReferenceCache;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.ExtendedCommunities;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.ExtendedCommunitiesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Community;
/**
* Parse known Community, if unknown, a new one will be created.
+ * @param refCache
*
* @param bytes byte array to be parsed
* @return new Community
* @throws BGPDocumentedException
*/
- static Community parseCommunity(final byte[] bytes) throws BGPDocumentedException {
+ static Community parseCommunity(final ReferenceCache refCache, final byte[] bytes) throws BGPDocumentedException {
if (bytes.length != COMMUNITY_LENGTH) {
throw new BGPDocumentedException("Community with wrong length: " + bytes.length, BGPError.OPT_ATTR_ERROR);
}
} else if (Arrays.equals(bytes, NO_EXPORT_SUBCONFED)) {
return CommunityUtil.NO_EXPORT_SUBCONFED;
}
- return CommunityUtil.create((ByteArray.bytesToLong(Arrays.copyOfRange(bytes, 0, AS_NUMBER_LENGTH))),
+ return CommunityUtil.create(refCache, ByteArray.bytesToLong(Arrays.copyOfRange(bytes, 0, AS_NUMBER_LENGTH)),
ByteArray.bytesToInt(Arrays.copyOfRange(bytes, AS_NUMBER_LENGTH, AS_NUMBER_LENGTH + AS_NUMBER_LENGTH)));
}
* @throws BGPDocumentedException if the type is not recognized
*/
@VisibleForTesting
- public static ExtendedCommunities parseExtendedCommunity(final byte[] bytes) throws BGPDocumentedException {
+ public static ExtendedCommunities parseExtendedCommunity(final ReferenceCache refCache, final byte[] bytes) throws BGPDocumentedException {
final int type = UnsignedBytes.toInt(bytes[0]);
final int subType = UnsignedBytes.toInt(bytes[1]);
final byte[] value = ByteArray.subByte(bytes, TYPE_LENGTH, bytes.length - TYPE_LENGTH);
*/
package org.opendaylight.protocol.bgp.parser.impl.message.update;
+import org.opendaylight.protocol.util.NoopReferenceCache;
+import org.opendaylight.protocol.util.ReferenceCache;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.CommunitiesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Community;
+import com.google.common.base.Preconditions;
+
/**
* Object representation of a RFC1997 Community tag. Communities are a way for the advertising entity to attach semantic
* meaning/policy to advertised objects.
* advertised outside a BGP confederation boundary (a stand-alone autonomous system that is not part of a
* confederation should be considered a confederation itself).
*/
- public static final Community NO_EXPORT = CommunityUtil.create(0xFFFF, 0xFF01);
+ public static final Community NO_EXPORT =
+ CommunityUtil.create(NoopReferenceCache.getInstance(), 0xFFFF, 0xFF01);
/**
* NO_ADVERTISE community. All routes received carrying a communities attribute containing this value MUST NOT be
* advertised to other BGP peers.
*/
- public static final Community NO_ADVERTISE = CommunityUtil.create(0xFFFF, 0xFF02);
+ public static final Community NO_ADVERTISE =
+ CommunityUtil.create(NoopReferenceCache.getInstance(), 0xFFFF, 0xFF02);
/**
* NO_EXPORT_SUBCONFED community. All routes received carrying a communities attribute containing this value MUST
* NOT be advertised to external BGP peers (this includes peers in other members autonomous systems inside a BGP
* confederation).
*/
- public static final Community NO_EXPORT_SUBCONFED = CommunityUtil.create(0xFFFF, 0xFF03);
+ public static final Community NO_EXPORT_SUBCONFED =
+ CommunityUtil.create(NoopReferenceCache.getInstance(), 0xFFFF, 0xFF03);
+
+ private final ReferenceCache refCache;
- private CommunityUtil() {
+ public CommunityUtil(final ReferenceCache refCache) {
+ this.refCache = Preconditions.checkNotNull(refCache);
+ }
+
+ /**
+ * Creates a new Community given AS number value and semantics using generated CommunitiesBuilder.
+ *
+ * @param asn long
+ * @param semantics long
+ * @return new Community
+ */
+ public Community create(final long asn, final int semantics) {
+ return create(refCache, asn, semantics);
+ }
+ /**
+ * Creates a Community from its String representation.
+ *
+ * @param string String representation of a community
+ * @return new Community
+ */
+ public Community valueOf(final String string) {
+ return valueOf(refCache, string);
}
/**
* Creates a new Community given AS number value and semantics using generated CommunitiesBuilder.
*
+ * @param refCache reference cache to use
* @param asn long
* @param semantics long
* @return new Community
*/
- public static Community create(final long asn, final int semantics) {
+ public static Community create(final ReferenceCache refCache, final long asn, final int semantics) {
final CommunitiesBuilder builder = new CommunitiesBuilder();
- builder.setAsNumber(new AsNumber(asn));
- builder.setSemantics(semantics);
- return builder.build();
+ builder.setAsNumber(refCache.getSharedReference(new AsNumber(asn)));
+ builder.setSemantics(refCache.getSharedReference(semantics));
+ return refCache.getSharedReference(builder.build());
}
/**
* Creates a Community from its String representation.
*
+ * @param refCache reference cache to use
* @param string String representation of a community
* @return new Community
*/
- public static Community valueOf(final String string) {
+ public static Community valueOf(final ReferenceCache refCache, final String string) {
final String[] parts = string.split(":", 2);
final CommunitiesBuilder builder = new CommunitiesBuilder();
- builder.setAsNumber(new AsNumber(Long.valueOf(parts[0])));
- builder.setSemantics(Integer.valueOf(parts[1]));
- return builder.build();
+ builder.setAsNumber(refCache.getSharedReference(new AsNumber(Long.valueOf(parts[0]))));
+ builder.setSemantics(refCache.getSharedReference(Integer.valueOf(parts[1])));
+ return refCache.getSharedReference(builder.build());
}
}
import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
import org.opendaylight.protocol.bgp.parser.spi.AttributeParser;
import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ReferenceCache;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.ExtendedCommunities;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.update.PathAttributesBuilder;
+import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
public final class ExtendedCommunitiesAttributeParser implements AttributeParser {
public static final int TYPE = 16;
+ private final ReferenceCache refCache;
+
+ public ExtendedCommunitiesAttributeParser(final ReferenceCache refCache) {
+ this.refCache = Preconditions.checkNotNull(refCache);
+ }
+
@Override
public void parseAttribute(final byte[] bytes, final PathAttributesBuilder builder) throws BGPDocumentedException {
final List<ExtendedCommunities> set = Lists.newArrayList();
int i = 0;
while (i < bytes.length) {
- final ExtendedCommunities comm = CommunitiesParser.parseExtendedCommunity(ByteArray.subByte(bytes, i,
+ final ExtendedCommunities comm = CommunitiesParser.parseExtendedCommunity(refCache, ByteArray.subByte(bytes, i,
CommunitiesParser.EXTENDED_COMMUNITY_LENGTH));
i += CommunitiesParser.EXTENDED_COMMUNITY_LENGTH;
set.add(comm);
import org.opendaylight.protocol.bgp.parser.spi.MessageUtil;
import org.opendaylight.protocol.bgp.parser.spi.pojo.ServiceLoaderBGPExtensionProviderContext;
import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.NoopReferenceCache;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
comms.add((Communities) CommunityUtil.NO_EXPORT);
comms.add((Communities) CommunityUtil.NO_ADVERTISE);
comms.add((Communities) CommunityUtil.NO_EXPORT_SUBCONFED);
- comms.add((Communities) CommunityUtil.create(0xFFFF, 0xFF10));
+ comms.add((Communities) CommunityUtil.create(NoopReferenceCache.getInstance(), 0xFFFF, 0xFF10));
final UpdateBuilder builder = new UpdateBuilder();
import org.junit.Test;
import org.opendaylight.protocol.bgp.parser.impl.message.update.CommunityUtil;
+import org.opendaylight.protocol.util.NoopReferenceCache;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Community;
public class CommunityTest {
+ final CommunityUtil util = new CommunityUtil(NoopReferenceCache.getInstance());
@Test
public void testCommunity() {
- CommunityUtil.create(10, 222);
- final Community c = CommunityUtil.create(12, 12);
+ util.create(10, 222);
+ final Community c = util.create(12, 12);
assertEquals(12, c.getAsNumber().getValue().intValue());
assertEquals(12, c.getSemantics().intValue());
}
@Test
public void testOverflows() {
try {
- CommunityUtil.create(10, -2);
+ util.create(10, -2);
fail("Semantics under range.");
} catch (final IllegalArgumentException e) {
assertEquals("Invalid range: -2, expected: [[0‥65535]].", e.getMessage());
}
try {
- CommunityUtil.create(10, 65536);
+ util.create(10, 65536);
fail("Semantics above range.");
} catch (final IllegalArgumentException e) {
assertEquals("Invalid range: 65536, expected: [[0‥65535]].", e.getMessage());
@Test
public void testToString() {
- final Community c = CommunityUtil.create(10, 222);
+ final Community c = util.create(10, 222);
assertNotNull(c.toString());
}
@Test
public void testValueOf() {
- final Community comm = CommunityUtil.valueOf("12:50");
+ final Community comm = util.valueOf("12:50");
assertEquals(12, comm.getAsNumber().getValue().intValue());
assertEquals(50, comm.getSemantics().intValue());
}
import org.opendaylight.protocol.bgp.parser.spi.MessageRegistry;
import org.opendaylight.protocol.bgp.parser.spi.pojo.ServiceLoaderBGPExtensionProviderContext;
import org.opendaylight.protocol.util.ByteList;
+import org.opendaylight.protocol.util.NoopReferenceCache;
+import org.opendaylight.protocol.util.ReferenceCache;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.LinkstateAddressFamily;
public class ComplementaryTest {
+ private final ReferenceCache ref = NoopReferenceCache.getInstance();
+
@Test
public void testBGPParameter() {
public void testCommunitiesParser() {
ExtendedCommunities as = null;
try {
- as = CommunitiesParser.parseExtendedCommunity(new byte[] { 0, 5, 0, 54, 0, 0, 1, 76 });
+ as = CommunitiesParser.parseExtendedCommunity(ref, new byte[] { 0, 5, 0, 54, 0, 0, 1, 76 });
} catch (final BGPDocumentedException e1) {
fail("Not expected exception: " + e1);
}
assertEquals(0, as.getCommType().intValue());
try {
- as = CommunitiesParser.parseExtendedCommunity(new byte[] { 40, 5, 0, 54, 0, 0, 1, 76 });
+ as = CommunitiesParser.parseExtendedCommunity(ref, new byte[] { 40, 5, 0, 54, 0, 0, 1, 76 });
} catch (final BGPDocumentedException e1) {
fail("Not expected exception: " + e1);
}
ExtendedCommunities rtc = null;
try {
- rtc = CommunitiesParser.parseExtendedCommunity(new byte[] { 1, 2, 0, 35, 4, 2, 8, 7 });
+ rtc = CommunitiesParser.parseExtendedCommunity(ref, new byte[] { 1, 2, 0, 35, 4, 2, 8, 7 });
} catch (final BGPDocumentedException e1) {
fail("Not expected exception: " + e1);
}
ExtendedCommunities roc = null;
try {
- roc = CommunitiesParser.parseExtendedCommunity(new byte[] { 0, 3, 0, 24, 4, 2, 8, 7 });
+ roc = CommunitiesParser.parseExtendedCommunity(ref, new byte[] { 0, 3, 0, 24, 4, 2, 8, 7 });
} catch (final BGPDocumentedException e1) {
fail("Not expected exception: " + e1);
}
ExtendedCommunities sec = null;
try {
- sec = CommunitiesParser.parseExtendedCommunity(new byte[] { 41, 6, 12, 51, 2, 5, 21, 45 });
+ sec = CommunitiesParser.parseExtendedCommunity(ref, new byte[] { 41, 6, 12, 51, 2, 5, 21, 45 });
} catch (final BGPDocumentedException e1) {
fail("Not expected exception: " + e1);
}
ExtendedCommunities oec = null;
try {
- oec = CommunitiesParser.parseExtendedCommunity(new byte[] { 3, 6, 21, 45, 5, 4, 3, 1 });
+ oec = CommunitiesParser.parseExtendedCommunity(ref, new byte[] { 3, 6, 21, 45, 5, 4, 3, 1 });
} catch (final BGPDocumentedException e1) {
fail("Not expected exception: " + e1);
}
assertEquals(3, oec.getCommType().intValue());
try {
- oec = CommunitiesParser.parseExtendedCommunity(new byte[] { 43, 6, 21, 45, 5, 4, 3, 1 });
+ oec = CommunitiesParser.parseExtendedCommunity(ref, new byte[] { 43, 6, 21, 45, 5, 4, 3, 1 });
} catch (final BGPDocumentedException e1) {
fail("Not expected exception: " + e1);
}
assertEquals(43, oec.getCommType().intValue());
try {
- CommunitiesParser.parseExtendedCommunity(new byte[] { 11, 11, 21, 45, 5, 4, 3, 1 });
+ CommunitiesParser.parseExtendedCommunity(ref, new byte[] { 11, 11, 21, 45, 5, 4, 3, 1 });
fail("Exception should have occured.");
} catch (final BGPDocumentedException e) {
assertEquals("Could not parse Extended Community type: 11", e.getMessage());