use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.routes.evpn.routes.evpn.route.attributes.extended.communities.extended.community.Layer2AttributesExtendedCommunityCaseBuilder in project bgpcep by opendaylight.
the class Layer2AttributesExtCom method parseExtendedCommunity.
@Override
public ExtendedCommunity parseExtendedCommunity(final ByteBuf body) {
final Layer2AttributesExtendedCommunityBuilder builder = new Layer2AttributesExtendedCommunityBuilder();
final BitArray flags = BitArray.valueOf(body, FLAGS_SIZE);
builder.setBackupPe(flags.get(BACKUP_PE_OFFSET));
builder.setPrimaryPe(flags.get(PRIMARY_PE_OFFSET));
builder.setControlWord(flags.get(CONTROL_WORD_OFFSET));
builder.setModeOfOperation(OperationalMode.forValue(getFlagShort(flags, MODE_OF_OPERATION)));
builder.setOperatingPer(NormalizationType.forValue(getFlagShort(flags, NORMALIZATION_TYPE)));
builder.setL2Mtu(body.readUnsignedShort());
body.skipBytes(RESERVED);
return new Layer2AttributesExtendedCommunityCaseBuilder().setLayer2AttributesExtendedCommunity(builder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.routes.evpn.routes.evpn.route.attributes.extended.communities.extended.community.Layer2AttributesExtendedCommunityCaseBuilder in project bgpcep by opendaylight.
the class Layer2AttributesExtComTest method evpnVpwsTest.
@Test
public void evpnVpwsTest() throws BGPParsingException, BGPDocumentedException {
final ByteBuf buff = Unpooled.buffer(COMMUNITY_VALUE_SIZE);
final Layer2AttributesExtendedCommunityCase expected = new Layer2AttributesExtendedCommunityCaseBuilder().setLayer2AttributesExtendedCommunity(new Layer2AttributesExtendedCommunityBuilder().setBackupPe(true).setControlWord(true).setPrimaryPe(true).setL2Mtu(257).setModeOfOperation(OperationalMode.VlanAwareFxc).setOperatingPer(NormalizationType.SingleVid).build()).build();
this.parser.serializeExtendedCommunity(expected, buff);
final byte[] resultByte = ByteArray.getAllBytes(buff);
assertArrayEquals(EVPN_VPWS, resultByte);
final ExtendedCommunity result = this.parser.parseExtendedCommunity(Unpooled.wrappedBuffer(EVPN_VPWS));
assertEquals(expected, result);
final ByteBuf buff2 = Unpooled.buffer(COMMUNITY_VALUE_SIZE);
final Layer2AttributesExtendedCommunityCase expected2 = new Layer2AttributesExtendedCommunityCaseBuilder().setLayer2AttributesExtendedCommunity(new Layer2AttributesExtendedCommunityBuilder().setBackupPe(true).setControlWord(true).setPrimaryPe(true).setL2Mtu(257).setModeOfOperation(OperationalMode.VlanUnawareFxc).setOperatingPer(NormalizationType.DoubleVid).build()).build();
this.parser.serializeExtendedCommunity(expected2, buff2);
final byte[] resultByte2 = ByteArray.getAllBytes(buff2);
assertArrayEquals(EVPN_VPWS_2, resultByte2);
final ExtendedCommunity result2 = this.parser.parseExtendedCommunity(Unpooled.wrappedBuffer(EVPN_VPWS_2));
assertEquals(expected2, result2);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.routes.evpn.routes.evpn.route.attributes.extended.communities.extended.community.Layer2AttributesExtendedCommunityCaseBuilder in project bgpcep by opendaylight.
the class Layer2AttributesExtComTest method handlerTest.
@Test
public void handlerTest() throws BGPParsingException, BGPDocumentedException {
final ByteBuf buff = Unpooled.buffer(COMMUNITY_VALUE_SIZE);
final Layer2AttributesExtendedCommunityCase expected = new Layer2AttributesExtendedCommunityCaseBuilder().setLayer2AttributesExtendedCommunity(new Layer2AttributesExtendedCommunityBuilder().setBackupPe(true).setControlWord(true).setPrimaryPe(true).setL2Mtu(257).build()).build();
this.parser.serializeExtendedCommunity(expected, buff);
final byte[] resultByte = ByteArray.getAllBytes(buff);
assertArrayEquals(EXPECTEDS, resultByte);
final ExtendedCommunity result = this.parser.parseExtendedCommunity(Unpooled.wrappedBuffer(EXPECTEDS));
assertEquals(expected, result);
}
Aggregations