use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.inet4.specific.extended.community.common.Inet4SpecificExtendedCommunityCommon in project bgpcep by opendaylight.
the class Ipv4SpecificEcHandler method serializeExtendedCommunity.
@Override
public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) {
checkArgument(extendedCommunity instanceof Inet4SpecificExtendedCommunityCase, "The extended community %s is not Inet4SpecificExtendedCommunityCase type.", extendedCommunity);
final Inet4SpecificExtendedCommunity inet4SpecificExtendedCommunity = ((Inet4SpecificExtendedCommunityCase) extendedCommunity).getInet4SpecificExtendedCommunity();
final Inet4SpecificExtendedCommunityCommon common = inet4SpecificExtendedCommunity.getInet4SpecificExtendedCommunityCommon();
if (common != null) {
serializeCommon(inet4SpecificExtendedCommunity.getInet4SpecificExtendedCommunityCommon(), byteAggregator);
} else {
Ipv4Util.writeIpv4Address(inet4SpecificExtendedCommunity.getGlobalAdministrator(), byteAggregator);
byteAggregator.writeBytes(inet4SpecificExtendedCommunity.getLocalAdministrator());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.inet4.specific.extended.community.common.Inet4SpecificExtendedCommunityCommon in project bgpcep by opendaylight.
the class Inet4SpecificExtendedCommunityCommonUtilTest method testHandle.
@Test
public void testHandle() {
final Inet4SpecificExtendedCommunityCommon expected = new Inet4SpecificExtendedCommunityCommonBuilder().setGlobalAdministrator(new Ipv4AddressNoZone("12.51.2.5")).setLocalAdministrator(new byte[] { 21, 45 }).build();
final Inet4SpecificExtendedCommunityCommon exComm = Inet4SpecificExtendedCommunityCommonUtil.parseCommon(Unpooled.copiedBuffer(INPUT));
Assert.assertEquals(expected, exComm);
final ByteBuf output = Unpooled.buffer(INPUT.length);
Inet4SpecificExtendedCommunityCommonUtil.serializeCommon(expected, output);
Assert.assertArrayEquals(INPUT, output.array());
}
Aggregations