Search in sources :

Example 16 with Esi

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.esi.Esi in project bgpcep by opendaylight.

the class ASGenParser method serializeBody.

@Override
public ByteBuf serializeBody(final Esi esi, final ByteBuf body) {
    checkArgument(esi instanceof AsGeneratedCase, "Unknown esi instance. Passed %s. Needed AsGeneratedCase.", esi);
    final AsGenerated asGen = ((AsGeneratedCase) esi).getAsGenerated();
    ByteBufUtils.write(body, asGen.getAs().getValue());
    ByteBufUtils.writeOrZero(body, asGen.getLocalDiscriminator());
    return body.writeByte(0);
}
Also used : AsGeneratedCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.esi.esi.AsGeneratedCase) AsGenerated(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.esi.esi.as.generated._case.AsGenerated)

Example 17 with Esi

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.esi.Esi in project bgpcep by opendaylight.

the class MacParser method serializeBody.

@Override
public ByteBuf serializeBody(final Esi esi, final ByteBuf body) {
    checkArgument(esi instanceof MacAutoGeneratedCase, "Unknown esi instance. Passed %s. Needed MacAutoGeneratedCase.", esi.getClass());
    final MacAutoGenerated macAuto = ((MacAutoGeneratedCase) esi).getMacAutoGenerated();
    body.writeBytes(IetfYangUtil.INSTANCE.macAddressBytes(macAuto.getSystemMacAddress()));
    RFC8294ByteBufUtils.writeUint24(body, macAuto.getLocalDiscriminator());
    return body;
}
Also used : MacAutoGenerated(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.esi.esi.mac.auto.generated._case.MacAutoGenerated) MacAutoGeneratedCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.esi.esi.MacAutoGeneratedCase)

Example 18 with Esi

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.esi.Esi 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 19 with Esi

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.esi.Esi in project bgpcep by opendaylight.

the class RouterIdParserTest method parserTest.

@Test
public void parserTest() {
    final ByteBuf buff = Unpooled.buffer(VALUE_SIZE);
    this.parser.serializeEsi(ROUTE_ID_CASE, buff);
    assertArrayEquals(RESULT, ByteArray.getAllBytes(buff));
    final Esi acResult = this.parser.parseEsi(Unpooled.wrappedBuffer(VALUE));
    assertEquals(ROUTE_ID_CASE, acResult);
    final Esi acmResult = this.parser.serializeEsi(RouterIdParserTest.createRouteContainer());
    assertEquals(ROUTE_ID_CASE, acmResult);
}
Also used : Esi(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.esi.Esi) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 20 with Esi

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.esi.Esi in project bgpcep by opendaylight.

the class LacpParserTest method parserTest.

@Test
public void parserTest() {
    final ByteBuf buff = Unpooled.buffer(VALUE_SIZE);
    final LacpAutoGeneratedCase lanAuto = new LacpAutoGeneratedCaseBuilder().setLacpAutoGenerated(new LacpAutoGeneratedBuilder().setCeLacpMacAddress(MAC).setCeLacpPortKey(PORT).build()).build();
    this.parser.serializeEsi(lanAuto, buff);
    assertArrayEquals(RESULT, ByteArray.getAllBytes(buff));
    final Esi acResult = this.parser.parseEsi(Unpooled.wrappedBuffer(VALUE));
    assertEquals(lanAuto, acResult);
    final ContainerNode cont = createContBuilder(new NodeIdentifier(LacpAutoGenerated.QNAME)).addChild(createValueBuilder(MAC_MODEL, LACP_MAC_NID).build()).addChild(createValueBuilder(PORT, PK_NID).build()).build();
    final Esi acmResult = this.parser.serializeEsi(cont);
    assertEquals(lanAuto, acmResult);
}
Also used : LacpAutoGeneratedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.esi.esi.lacp.auto.generated._case.LacpAutoGeneratedBuilder) LacpAutoGeneratedCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.esi.esi.LacpAutoGeneratedCaseBuilder) LacpAutoGeneratedCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.esi.esi.LacpAutoGeneratedCase) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) Esi(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.esi.Esi) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Aggregations

Esi (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.esi.Esi)10 ByteBuf (io.netty.buffer.ByteBuf)7 Test (org.junit.Test)6 NlriModelUtil.extractMplsLabel (org.opendaylight.protocol.bgp.evpn.impl.nlri.NlriModelUtil.extractMplsLabel)3 MplsLabelUtil.byteBufForMplsLabel (org.opendaylight.protocol.util.MplsLabelUtil.byteBufForMplsLabel)3 MplsLabel (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.MplsLabel)3 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)3 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)3 IpAddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone)2 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 SocketException (java.net.SocketException)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 TApplicationException (org.apache.thrift.TApplicationException)1 TException (org.apache.thrift.TException)1 TransactionCommitFailedException (org.opendaylight.mdsal.common.api.TransactionCommitFailedException)1 CandidateAlreadyRegisteredException (org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException)1 BgpRouter (org.opendaylight.netvirt.bgpmanager.thrift.client.BgpRouter)1 BgpRouterException (org.opendaylight.netvirt.bgpmanager.thrift.client.BgpRouterException)1