use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.esi.Esi in project bgpcep by opendaylight.
the class ASGenParser method serializeBody.
@Override
public ByteBuf serializeBody(final Esi esi, final ByteBuf body) {
checkArgument(esi instanceof AsGeneratedCase, "Unknown esi instance. Passed %s. Needed AsGeneratedCase.", esi);
final AsGenerated asGen = ((AsGeneratedCase) esi).getAsGenerated();
ByteBufUtils.write(body, asGen.getAs().getValue());
ByteBufUtils.writeOrZero(body, asGen.getLocalDiscriminator());
return body.writeByte(0);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.esi.Esi in project bgpcep by opendaylight.
the class MacParser method serializeBody.
@Override
public ByteBuf serializeBody(final Esi esi, final ByteBuf body) {
checkArgument(esi instanceof MacAutoGeneratedCase, "Unknown esi instance. Passed %s. Needed MacAutoGeneratedCase.", esi.getClass());
final MacAutoGenerated macAuto = ((MacAutoGeneratedCase) esi).getMacAutoGenerated();
body.writeBytes(IetfYangUtil.INSTANCE.macAddressBytes(macAuto.getSystemMacAddress()));
RFC8294ByteBufUtils.writeUint24(body, macAuto.getLocalDiscriminator());
return body;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.esi.Esi in project bgpcep by opendaylight.
the class MACIpAdvRParser method serializeBody.
@Override
public ByteBuf serializeBody(final EvpnChoice evpnChoice) {
Preconditions.checkArgument(evpnChoice instanceof MacIpAdvRouteCase, "Unknown evpn instance. Passed %s. Needed MacIpAdvRouteCase.", evpnChoice.getClass());
final ByteBuf body = Unpooled.buffer();
final MacIpAdvRoute evpn = ((MacIpAdvRouteCase) evpnChoice).getMacIpAdvRoute();
final Esi esi = evpn.getEsi();
if (esi != null) {
SimpleEsiTypeRegistry.getInstance().serializeEsi(evpn.getEsi(), body);
}
ByteBufUtils.writeOrZero(body, evpn.getEthernetTagId().getVlanId());
final MacAddress mac = evpn.getMacAddress();
body.writeByte(MAC_ADDRESS_LENGTH * BITS_SIZE);
body.writeBytes(IetfYangUtil.INSTANCE.macAddressBytes(mac));
final ByteBuf ipAddress = serializeIp(evpn.getIpAddress());
Preconditions.checkArgument(ipAddress.readableBytes() > 0);
body.writeBytes(ipAddress);
final MplsLabel mpls1 = evpn.getMplsLabel1();
if (mpls1 != null) {
body.writeBytes(byteBufForMplsLabel(mpls1));
}
final MplsLabel mpls2 = evpn.getMplsLabel2();
if (mpls2 != null) {
body.writeBytes(byteBufForMplsLabel(mpls2));
}
return body;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.esi.Esi in project bgpcep by opendaylight.
the class RouterIdParserTest method parserTest.
@Test
public void parserTest() {
final ByteBuf buff = Unpooled.buffer(VALUE_SIZE);
this.parser.serializeEsi(ROUTE_ID_CASE, buff);
assertArrayEquals(RESULT, ByteArray.getAllBytes(buff));
final Esi acResult = this.parser.parseEsi(Unpooled.wrappedBuffer(VALUE));
assertEquals(ROUTE_ID_CASE, acResult);
final Esi acmResult = this.parser.serializeEsi(RouterIdParserTest.createRouteContainer());
assertEquals(ROUTE_ID_CASE, acmResult);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.esi.Esi in project bgpcep by opendaylight.
the class LacpParserTest method parserTest.
@Test
public void parserTest() {
final ByteBuf buff = Unpooled.buffer(VALUE_SIZE);
final LacpAutoGeneratedCase lanAuto = new LacpAutoGeneratedCaseBuilder().setLacpAutoGenerated(new LacpAutoGeneratedBuilder().setCeLacpMacAddress(MAC).setCeLacpPortKey(PORT).build()).build();
this.parser.serializeEsi(lanAuto, buff);
assertArrayEquals(RESULT, ByteArray.getAllBytes(buff));
final Esi acResult = this.parser.parseEsi(Unpooled.wrappedBuffer(VALUE));
assertEquals(lanAuto, acResult);
final ContainerNode cont = createContBuilder(new NodeIdentifier(LacpAutoGenerated.QNAME)).addChild(createValueBuilder(MAC_MODEL, LACP_MAC_NID).build()).addChild(createValueBuilder(PORT, PK_NID).build()).build();
final Esi acmResult = this.parser.serializeEsi(cont);
assertEquals(lanAuto, acmResult);
}
Aggregations