Search in sources :

Example 1 with MacIpAdvRouteCaseBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.evpn.choice.MacIpAdvRouteCaseBuilder 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);
}
Also used : MacIpAdvRouteCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.evpn.choice.MacIpAdvRouteCaseBuilder) MacIpAdvRouteBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.mac.ip.adv.route.MacIpAdvRouteBuilder) MacIpAdvRouteCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.evpn.choice.MacIpAdvRouteCase) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) ChoiceNode(org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode) EvpnChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.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 MacIpAdvRouteCaseBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.evpn.choice.MacIpAdvRouteCaseBuilder 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(buffer.readUnsignedInt()).build();
    buffer.skipBytes(1);
    final MacAddress mac = IetfYangUtil.INSTANCE.macAddressFor(ByteArray.readBytes(buffer, MAC_ADDRESS_LENGTH));
    final IpAddress 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();
}
Also used : MacIpAdvRouteCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.evpn.choice.MacIpAdvRouteCaseBuilder) MacIpAdvRouteBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.mac.ip.adv.route.MacIpAdvRouteBuilder) EthernetTagIdBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.ethernet.tag.id.EthernetTagIdBuilder) 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.rev171213.esi.Esi) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) EthernetTagId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.ethernet.tag.id.EthernetTagId)

Example 3 with MacIpAdvRouteCaseBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.evpn.choice.MacIpAdvRouteCaseBuilder 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();
}
Also used : MacIpAdvRouteCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.evpn.choice.MacIpAdvRouteCaseBuilder) MacIpAdvRouteBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.mac.ip.adv.route.MacIpAdvRouteBuilder)

Aggregations

MacIpAdvRouteCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.evpn.choice.MacIpAdvRouteCaseBuilder)3 MacIpAdvRouteBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.mac.ip.adv.route.MacIpAdvRouteBuilder)3 Test (org.junit.Test)1 LanParserTest (org.opendaylight.protocol.bgp.evpn.impl.esi.types.LanParserTest)1 NlriModelUtil.extractMplsLabel (org.opendaylight.protocol.bgp.evpn.impl.nlri.NlriModelUtil.extractMplsLabel)1 MplsLabelUtil.byteBufForMplsLabel (org.opendaylight.protocol.util.MplsLabelUtil.byteBufForMplsLabel)1 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)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.rev171213.esi.Esi)1 EthernetTagId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.ethernet.tag.id.EthernetTagId)1 EthernetTagIdBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.ethernet.tag.id.EthernetTagIdBuilder)1 EvpnChoice (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.EvpnChoice)1 MacIpAdvRouteCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.evpn.choice.MacIpAdvRouteCase)1 MplsLabel (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.MplsLabel)1 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)1 ChoiceNode (org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode)1 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)1