Search in sources :

Example 1 with MacIpAdvRouteCase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.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 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);
}
Also used : MacIpAdvRouteCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.evpn.choice.MacIpAdvRouteCaseBuilder) MacIpAdvRouteBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.mac.ip.adv.route.MacIpAdvRouteBuilder) MacIpAdvRouteCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.evpn.choice.MacIpAdvRouteCase) EvpnChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.EvpnChoice) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) LanParserTest(org.opendaylight.protocol.bgp.evpn.impl.esi.types.LanParserTest) Test(org.junit.Test)

Example 2 with MacIpAdvRouteCase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.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);
    }
    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;
}
Also used : MacIpAdvRoute(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.mac.ip.adv.route.MacIpAdvRoute) MacIpAdvRouteCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.evpn.choice.MacIpAdvRouteCase) MplsLabelUtil.byteBufForMplsLabel(org.opendaylight.protocol.util.MplsLabelUtil.byteBufForMplsLabel) MplsLabel(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.MplsLabel) NlriModelUtil.extractMplsLabel(org.opendaylight.protocol.bgp.evpn.impl.nlri.NlriModelUtil.extractMplsLabel) Esi(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.esi.Esi) MplsLabelUtil.mplsLabelForByteBuf(org.opendaylight.protocol.util.MplsLabelUtil.mplsLabelForByteBuf) ByteBuf(io.netty.buffer.ByteBuf) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)

Example 3 with MacIpAdvRouteCase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.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);
}
Also used : MacIpAdvRouteCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.evpn.choice.MacIpAdvRouteCase) EvpnChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.EvpnChoice) LanParserTest(org.opendaylight.protocol.bgp.evpn.impl.esi.types.LanParserTest) Test(org.junit.Test)

Aggregations

MacIpAdvRouteCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.evpn.choice.MacIpAdvRouteCase)3 Test (org.junit.Test)2 LanParserTest (org.opendaylight.protocol.bgp.evpn.impl.esi.types.LanParserTest)2 EvpnChoice (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.EvpnChoice)2 ByteBuf (io.netty.buffer.ByteBuf)1 NlriModelUtil.extractMplsLabel (org.opendaylight.protocol.bgp.evpn.impl.nlri.NlriModelUtil.extractMplsLabel)1 MplsLabelUtil.byteBufForMplsLabel (org.opendaylight.protocol.util.MplsLabelUtil.byteBufForMplsLabel)1 MplsLabelUtil.mplsLabelForByteBuf (org.opendaylight.protocol.util.MplsLabelUtil.mplsLabelForByteBuf)1 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)1 Esi (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.esi.Esi)1 MacIpAdvRouteCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.evpn.choice.MacIpAdvRouteCaseBuilder)1 MacIpAdvRoute (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.mac.ip.adv.route.MacIpAdvRoute)1 MacIpAdvRouteBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.mac.ip.adv.route.MacIpAdvRouteBuilder)1 MplsLabel (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.MplsLabel)1 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)1