use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.mac.ip.adv.route.MacIpAdvRouteBuilder in project bgpcep by opendaylight.
the class MACIpAdvRParser method parseEvpn.
@Override
public EvpnChoice parseEvpn(final ByteBuf buffer) {
final Esi esi = SimpleEsiTypeRegistry.getInstance().parseEsi(buffer.readSlice(ESI_SIZE));
final EthernetTagId eti = new EthernetTagIdBuilder().setVlanId(ByteBufUtils.readUint32(buffer)).build();
buffer.skipBytes(1);
final MacAddress mac = IetfYangUtil.INSTANCE.macAddressFor(ByteArray.readBytes(buffer, MAC_ADDRESS_LENGTH));
final IpAddressNoZone ip = parseIp(buffer);
final MplsLabel label1 = mplsLabelForByteBuf(buffer);
MplsLabel label2;
if (buffer.readableBytes() > 0) {
label2 = mplsLabelForByteBuf(buffer);
} else {
label2 = null;
}
final MacIpAdvRouteBuilder builder = new MacIpAdvRouteBuilder().setEsi(esi).setEthernetTagId(eti).setMacAddress(mac).setIpAddress(ip).setMplsLabel1(label1).setMplsLabel2(label2);
return new MacIpAdvRouteCaseBuilder().setMacIpAdvRoute(builder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.mac.ip.adv.route.MacIpAdvRouteBuilder in project bgpcep by opendaylight.
the class MACIpAdvRParser method serializeEvpnModel.
@Override
public EvpnChoice serializeEvpnModel(final ContainerNode evpn) {
final MacIpAdvRouteBuilder builder = serializeKeyModel(evpn);
builder.setEsi(serializeEsi(evpn));
builder.setMplsLabel1(extractMplsLabel(evpn, MPLS1_NID));
builder.setMplsLabel2(extractMplsLabel(evpn, MPLS2_NID));
return new MacIpAdvRouteCaseBuilder().setMacIpAdvRoute(builder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.mac.ip.adv.route.MacIpAdvRouteBuilder in project bgpcep by opendaylight.
the class MACIpAdvRParserTest method parserCase2Test.
@Test
public void parserCase2Test() {
final MacIpAdvRouteCase expected = new MacIpAdvRouteCaseBuilder().setMacIpAdvRoute(new MacIpAdvRouteBuilder().setEsi(LAN_AUT_GEN_CASE).setEthernetTagId(ETI).setMacAddress(MAC).setIpAddress(IPV6).setMplsLabel1(MPLS_LABEL).build()).build();
assertArrayEquals(RESULT2, ByteArray.getAllBytes(this.parser.serializeEvpn(expected, Unpooled.wrappedBuffer(ROUDE_DISTIN))));
final EvpnChoice result = this.parser.parseEvpn(Unpooled.wrappedBuffer(VALUE2));
assertEquals(expected, result);
final ContainerNode macIp = createContBuilder(MACIpAdvRParser.MAC_IP_ADV_ROUTE_NID).addChild(LanParserTest.createLanChoice()).addChild(createEti()).addChild(createValueBuilder(MAC_MODEL, MAC_NID).build()).addChild(createValueBuilder(IPV6_MODEL, IP_NID).build()).addChild(createValueBuilder(MPLS_LABEL_MODEL, MPLS1_NID).build()).build();
final EvpnChoice modelResult = this.parser.serializeEvpnModel(macIp);
assertEquals(expected, modelResult);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.mac.ip.adv.route.MacIpAdvRouteBuilder in project bgpcep by opendaylight.
the class MACIpAdvRParser method serializeKeyModel.
private static MacIpAdvRouteBuilder serializeKeyModel(final ContainerNode evpn) {
final MacIpAdvRouteBuilder builder = new MacIpAdvRouteBuilder();
builder.setEthernetTagId(extractETI(evpn));
builder.setMacAddress(extractMAC(evpn));
builder.setIpAddress(extractIp(evpn));
return builder;
}
Aggregations