use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.evpn.choice.MacIpAdvRouteCase 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 DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> choice = Builders.choiceBuilder();
choice.withNodeIdentifier(MACIpAdvRParser.MAC_IP_ADV_ROUTE_NID);
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.rev171213.evpn.evpn.choice.MacIpAdvRouteCase in project bgpcep by opendaylight.
the class MACIpAdvRParserTest method parserCase1Test.
@Test
public void parserCase1Test() {
final MacIpAdvRouteCase expected = createdExpectedResult();
assertArrayEquals(RESULT, ByteArray.getAllBytes(this.parser.serializeEvpn(expected, Unpooled.wrappedBuffer(ROUDE_DISTIN))));
final EvpnChoice result = this.parser.parseEvpn(Unpooled.wrappedBuffer(VALUE));
assertEquals(expected, result);
final EvpnChoice modelResult = this.parser.serializeEvpnModel(createMacIpCont());
assertEquals(expected, modelResult);
final EvpnChoice keyResult = this.parser.createRouteKey(createMacIpCont());
assertEquals(createdExpectedRouteKey(), keyResult);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.evpn.choice.MacIpAdvRouteCase 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);
}
ByteBufWriteUtil.writeUnsignedInt(evpn.getEthernetTagId().getVlanId(), body);
final MacAddress mac = evpn.getMacAddress();
body.writeByte(MAC_ADDRESS_LENGTH * BITS_SIZE);
body.writeBytes(IetfYangUtil.INSTANCE.bytesFor(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;
}
Aggregations