use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Community in project bgpcep by opendaylight.
the class CommunityTest method testToString.
@Test
public void testToString() {
final Community c = this.util.create(10, 222);
assertNotNull(c.toString());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Community in project bgpcep by opendaylight.
the class CommunityTest method testCommunity.
@Test
public void testCommunity() {
this.util.create(10, 222);
final Community c = this.util.create(12, 12);
assertEquals(12, c.getAsNumber().getValue().intValue());
assertEquals(12, c.getSemantics().intValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Community in project bgpcep by opendaylight.
the class RouteTargetIpv4EcHandler method serializeExtendedCommunity.
@Override
public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) {
Preconditions.checkArgument(extendedCommunity instanceof RouteTargetIpv4Case, "The extended community %s is not RouteTargetAsTwoOctetCase type.", extendedCommunity);
final RouteTargetIpv4 routeTarget = ((RouteTargetIpv4Case) extendedCommunity).getRouteTargetIpv4();
RouteTargetIpv4Handler.serialize(routeTarget, byteAggregator);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Community in project bgpcep by opendaylight.
the class SimpleExtendedCommunityRegistryTest method testExtendedCommunityRegistryUnknown.
@Test
public void testExtendedCommunityRegistryUnknown() throws BGPDocumentedException, BGPParsingException {
final ByteBuf output = Unpooled.buffer();
this.register.serializeExtendedCommunity(new ExtendedCommunitiesBuilder().setTransitive(false).setExtendedCommunity(new RouteOriginIpv4CaseBuilder().build()).build(), output);
// no ex. community was serialized
Assert.assertEquals(0, output.readableBytes());
verify(this.serializer, never()).serializeExtendedCommunity(any(ExtendedCommunity.class), any(ByteBuf.class));
final ExtendedCommunities noExtCommunity = this.register.parseExtendedCommunity(Unpooled.copiedBuffer(new byte[] { 0, 1, 0, 0, 0, 0, 0, 0 }));
// no ext. community was parsed
assertNull(noExtCommunity);
verify(this.parser, never()).parseExtendedCommunity(any(ByteBuf.class));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Community in project bgpcep by opendaylight.
the class SimpleExtendedCommunityRegistry method parseExtendedCommunity.
@Override
public ExtendedCommunities parseExtendedCommunity(final ByteBuf buffer) throws BGPDocumentedException, BGPParsingException {
final short type = buffer.readUnsignedByte();
final short subtype = buffer.readUnsignedByte();
final ExtendedCommunityParser parser = this.handlers.getParser(createKey(type, subtype));
if (parser == null) {
buffer.skipBytes(EXTENDED_COMMUNITY_LENGTH);
LOG.info("Skipping unknown extended-community type/sub-type {}/{}.", type, subtype);
return null;
}
return new ExtendedCommunitiesBuilder().setTransitive(isTransitive(type)).setExtendedCommunity(parser.parseExtendedCommunity(buffer)).build();
}
Aggregations