use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Community in project bgpcep by opendaylight.
the class RedirectAsTwoOctetEcHandler method serializeExtendedCommunity.
@Override
public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) {
Preconditions.checkArgument(extendedCommunity instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.RedirectExtendedCommunity, "The extended community %s is not RedirectExtendedCommunityCase type.", extendedCommunity);
final RedirectExtendedCommunity redirect = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.RedirectExtendedCommunity) extendedCommunity).getRedirectExtendedCommunity();
ByteBufWriteUtil.writeUnsignedShort(redirect.getGlobalAdministrator().getValue().intValue(), byteAggregator);
byteAggregator.writeBytes(redirect.getLocalAdministrator());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Community in project bgpcep by opendaylight.
the class RedirectIpv4EcHandler method serializeExtendedCommunity.
@Override
public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) {
Preconditions.checkArgument(extendedCommunity instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.RedirectIpv4ExtendedCommunity, "The extended community %s is not RedirectIpv4ExtendedCommunityCase type.", extendedCommunity);
final RedirectIpv4 redirect = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.RedirectIpv4ExtendedCommunity) extendedCommunity).getRedirectIpv4();
ByteBufWriteUtil.writeIpv4Address(redirect.getGlobalAdministrator(), byteAggregator);
ByteBufWriteUtil.writeUnsignedShort(redirect.getLocalAdministrator(), byteAggregator);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Community in project bgpcep by opendaylight.
the class TrafficActionEcHandler method serializeExtendedCommunity.
@Override
public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) {
Preconditions.checkArgument(extendedCommunity instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.TrafficActionExtendedCommunity, "The extended community %s is not TrafficActionExtendedCommunityCase type.", extendedCommunity);
final TrafficActionExtendedCommunity trafficAction = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.TrafficActionExtendedCommunity) extendedCommunity).getTrafficActionExtendedCommunity();
byteAggregator.writeZero(RESERVED);
final BitArray flags = new BitArray(FLAGS_SIZE);
flags.set(SAMPLE_BIT, trafficAction.isSample());
flags.set(TERMINAL_BIT, trafficAction.isTerminalAction());
flags.toByteBuf(byteAggregator);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.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());
Mockito.verify(this.serializer, Mockito.never()).serializeExtendedCommunity(Mockito.any(ExtendedCommunity.class), Mockito.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
Assert.assertNull(noExtCommunity);
Mockito.verify(this.parser, Mockito.never()).parseExtendedCommunity(Mockito.any(ByteBuf.class));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.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