use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.EvpnChoice in project bgpcep by opendaylight.
the class IncMultEthTagRParser method serializeModel.
private static EvpnChoice serializeModel(final ContainerNode evpn) {
final IncMultiEthernetTagResBuilder builder = new IncMultiEthernetTagResBuilder();
builder.setEthernetTagId(extractETI(evpn));
builder.setOrigRouteIp(extractOrigRouteIp(evpn));
return new IncMultiEthernetTagResCaseBuilder().setIncMultiEthernetTagRes(builder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.EvpnChoice in project bgpcep by opendaylight.
the class IncMultEthTagRParser method parseEvpn.
@Override
public EvpnChoice parseEvpn(final ByteBuf buffer) {
Preconditions.checkArgument(buffer.readableBytes() == CONTENT_LENGTH || buffer.readableBytes() == CONTENT_LENGTH2, "Wrong length of array of bytes. Passed: %s ;", buffer);
final EthernetTagId eti = new EthernetTagIdBuilder().setVlanId(ByteBufUtils.readUint32(buffer)).build();
final IpAddressNoZone ip = IpAddressUtil.addressForByteBuf(buffer);
final IncMultiEthernetTagResBuilder builder = new IncMultiEthernetTagResBuilder().setEthernetTagId(eti).setOrigRouteIp(ip);
return new IncMultiEthernetTagResCaseBuilder().setIncMultiEthernetTagRes(builder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.EvpnChoice 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.evpn.EvpnChoice in project bgpcep by opendaylight.
the class EthADRParserTest method parserTest.
@Test
public void parserTest() {
final ByteBuf buff = this.parser.serializeEvpn(ETHERNET_AD_ROUTE_CASE, Unpooled.wrappedBuffer(ROUDE_DISTIN));
assertArrayEquals(RESULT, ByteArray.getAllBytes(buff));
final EvpnChoice result = this.parser.parseEvpn(Unpooled.wrappedBuffer(VALUE));
assertEquals(ETHERNET_AD_ROUTE_CASE, result);
final EvpnChoice modelResult = this.parser.serializeEvpnModel(EthADRParserTest.createArbitraryContainer());
assertEquals(ETHERNET_AD_ROUTE_CASE, modelResult);
final EvpnChoice keyResult = this.parser.createRouteKey(EthADRParserTest.createArbitraryContainer());
assertEquals(ETHERNET_AD_ROUTE_CASE_KEY, keyResult);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.EvpnChoice in project bgpcep by opendaylight.
the class SimpleEvpnNlriRegistryTest method registryTest.
@Test
public void registryTest() {
final ByteBuf buff = SimpleEvpnNlriRegistry.getInstance().serializeEvpn(ETHERNET_AD_ROUTE_CASE, Unpooled.wrappedBuffer(ROUDE_DISTIN));
assertArrayEquals(EthADRParserTest.RESULT, ByteArray.getAllBytes(buff));
final EvpnChoice resultModel = SimpleEvpnNlriRegistry.getInstance().serializeEvpnModel(createEthADRModel());
assertEquals(ETHERNET_AD_ROUTE_CASE, resultModel);
final NlriType type = NlriType.forValue(buff.readUnsignedByte());
// length + RD
buff.skipBytes(VALUE_SIZE);
assertEquals(ETHERNET_AD_ROUTE_CASE, SimpleEvpnNlriRegistry.getInstance().parseEvpn(type, buff));
}
Aggregations