use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.EvpnChoice 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.rev171213.evpn.EvpnChoice in project bgpcep by opendaylight.
the class EthSegRParserTest method parserTest.
@Test
public void parserTest() {
final EsRouteCase expected = new EsRouteCaseBuilder().setEsRoute(new EsRouteBuilder().setEsi(LAN_AUT_GEN_CASE).setOrigRouteIp(IP).build()).build();
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 DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifier, ChoiceNode> choice = Builders.choiceBuilder();
choice.withNodeIdentifier(EthSegRParser.ES_ROUTE_NID);
final ContainerNode arbitraryC = createContBuilder(EthSegRParser.ES_ROUTE_NID).addChild(LanParserTest.createLanChoice()).addChild(createValueBuilder(IP_MODEL, ORI_NID).build()).build();
final EvpnChoice modelResult = this.parser.serializeEvpnModel(arbitraryC);
assertEquals(expected, modelResult);
final EvpnChoice keyResult = this.parser.createRouteKey(arbitraryC);
assertEquals(expected, keyResult);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.EvpnChoice 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.EvpnChoice in project bgpcep by opendaylight.
the class EthADRParser method serializeBody.
@Override
public ByteBuf serializeBody(final EvpnChoice evpnChoice) {
Preconditions.checkArgument(evpnChoice instanceof EthernetADRouteCase, "Unknown evpn instance. Passed %s. Needed EthernetADRouteCase.", evpnChoice.getClass());
final EthernetADRoute evpn = ((EthernetADRouteCase) evpnChoice).getEthernetADRoute();
final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
SimpleEsiTypeRegistry.getInstance().serializeEsi(evpn.getEsi(), body);
ByteBufWriteUtil.writeUnsignedInt(evpn.getEthernetTagId().getVlanId(), body);
final MplsLabel mpls = evpn.getMplsLabel();
if (mpls != null) {
body.writeBytes(byteBufForMplsLabel(evpn.getMplsLabel()));
}
return body;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.EvpnChoice in project bgpcep by opendaylight.
the class EthADRParser method parseEvpn.
@Override
public EvpnChoice parseEvpn(final ByteBuf buffer) {
Preconditions.checkArgument(buffer.readableBytes() == CONTENT_LENGTH, "Wrong length of array of bytes. Passed: %s ;", buffer);
final Esi esi = SimpleEsiTypeRegistry.getInstance().parseEsi(buffer.readSlice(ESI_SIZE));
final EthernetTagId eti = new EthernetTagIdBuilder().setVlanId(buffer.readUnsignedInt()).build();
final MplsLabel label = mplsLabelForByteBuf(buffer);
final EthernetADRouteBuilder builder = new EthernetADRouteBuilder().setEsi(esi).setEthernetTagId(eti).setMplsLabel(label);
return new EthernetADRouteCaseBuilder().setEthernetADRoute(builder.build()).build();
}
Aggregations