Search in sources :

Example 6 with Opaque

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev200120.Opaque in project bgpcep by opendaylight.

the class OpaqueUtil method parseOpaque.

static Opaque parseOpaque(final ByteBuf buffer) {
    final short type = buffer.readUnsignedByte();
    final OpaqueValueBuilder builder = new OpaqueValueBuilder();
    switch(type) {
        case GENERIC_LSP_IDENTIFIER:
            builder.setOpaque(buildOpaqueValue(buffer));
            break;
        case EXTENDED_TYPE:
            buildExtended(builder, buffer);
            break;
        default:
            final int length = buffer.readUnsignedShort();
            buffer.skipBytes(length);
            LOG.debug("Skipping parsing of Opaque Value {}", buffer);
            return null;
    }
    builder.setOpaqueType(type);
    return builder.build();
}
Also used : OpaqueValueBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.p2mp.lsp.mldp.p2mp.lsp.OpaqueValueBuilder)

Example 7 with Opaque

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev200120.Opaque in project bgpcep by opendaylight.

the class MldpMp2mpLspParser method parse.

@Override
public TunnelIdentifier parse(final ByteBuf buffer) {
    final Opaque opaque = OpaqueUtil.parseOpaque(buffer);
    if (opaque == null) {
        return null;
    }
    final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.mp2mp.lsp.MldpMp2mpLsp mldpMp2mpLsp = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.mp2mp.lsp.MldpMp2mpLspBuilder(opaque).build();
    return new MldpMp2mpLspBuilder().setMldpMp2mpLsp(mldpMp2mpLsp).build();
}
Also used : Opaque(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.Opaque) MldpMp2mpLspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.MldpMp2mpLspBuilder)

Example 8 with Opaque

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev200120.Opaque in project bgpcep by opendaylight.

the class OpaqueUtilTest method serializeOpaque.

@Test
public void serializeOpaque() {
    final ByteBuf actualOpaque = Unpooled.buffer();
    OpaqueUtil.serializeOpaque(OPAQUE, actualOpaque);
    assertArrayEquals(OPAQUE_EXPECTED, ByteArray.readAllBytes(actualOpaque));
    final ByteBuf actualOpaqueExt = Unpooled.buffer();
    OpaqueUtil.serializeOpaque(OPAQUE_EXTENDED, actualOpaqueExt);
    assertArrayEquals(OPAQUE_EXT_EXPECTED, ByteArray.readAllBytes(actualOpaqueExt));
    final ByteBuf empty = Unpooled.buffer();
    OpaqueUtil.serializeOpaque(new OpaqueValueBuilder().setOpaqueType(Uint8.valueOf(5)).build(), actualOpaqueExt);
    assertArrayEquals(new byte[0], ByteArray.readAllBytes(empty));
    final Opaque opaque = OpaqueUtil.parseOpaque(Unpooled.wrappedBuffer(OPAQUE_EXPECTED));
    assertEquals(OPAQUE, opaque);
    final Opaque opaqueExt = OpaqueUtil.parseOpaque(Unpooled.wrappedBuffer(OPAQUE_EXT_EXPECTED));
    assertEquals(OPAQUE_EXTENDED, opaqueExt);
    assertNull(OpaqueUtil.parseOpaque(Unpooled.wrappedBuffer(OPAQUE_WRONG)));
}
Also used : OpaqueValueBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev200120.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.p2mp.lsp.mldp.p2mp.lsp.OpaqueValueBuilder) Opaque(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev200120.Opaque) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 9 with Opaque

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev200120.Opaque in project bgpcep by opendaylight.

the class MldpMp2mpLspParser method parse.

@Override
public MldpMp2mpLsp parse(final ByteBuf buffer) {
    final Opaque opaque = OpaqueUtil.parseOpaque(buffer);
    if (opaque == null) {
        return null;
    }
    final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev200120.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.mp2mp.lsp.MldpMp2mpLsp mldpMp2mpLsp = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev200120.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.mp2mp.lsp.MldpMp2mpLspBuilder(opaque).build();
    return new MldpMp2mpLspBuilder().setMldpMp2mpLsp(mldpMp2mpLsp).build();
}
Also used : Opaque(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev200120.Opaque) MldpMp2mpLspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev200120.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.MldpMp2mpLspBuilder)

Example 10 with Opaque

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev200120.Opaque in project bgpcep by opendaylight.

the class CommunitiesBuilder method createExtComm.

static List<ExtendedCommunities> createExtComm(final List<String> extCom) {
    final List<ExtendedCommunities> extendedCommunities = new ArrayList<>();
    for (String ec : extCom) {
        ExtendedCommunity community = null;
        switch(ec) {
            case "as-4-generic-spec-extended-community":
                community = CommunitiesBuilder.as4GenSpecBuild();
                break;
            case "as-4-route-target-extended-community":
                community = CommunitiesBuilder.as4RTBuild();
                break;
            case "as-4-route-origin-extended-community":
                community = CommunitiesBuilder.as4ROBuild();
                break;
            case "route-origin":
                community = CommunitiesBuilder.rOBuild();
                break;
            case "route-target":
                community = CommunitiesBuilder.rTBuild();
                break;
            case "route-origin-extended-community":
                community = CommunitiesBuilder.rOECBuild();
                break;
            case "route-target-extended-community":
                community = CommunitiesBuilder.rTECBuild();
                break;
            case "link-bandwidth-extended-community":
                community = CommunitiesBuilder.linkBandBuild();
                break;
            case "opaque-extended-community":
                community = CommunitiesBuilder.opaqueBuild();
                break;
            case "inet4-specific-extended-community":
                community = CommunitiesBuilder.inet4Build();
                break;
            case "as-specific-extended-community":
                community = CommunitiesBuilder.asSpecBuild();
                break;
            default:
                LOG.debug("Not recognized Extended Community {}", ec);
                break;
        }
        extendedCommunities.add(new ExtendedCommunitiesBuilder().setTransitive(true).setExtendedCommunity(community).build());
    }
    return extendedCommunities;
}
Also used : ExtendedCommunities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ExtendedCommunities) ArrayList(java.util.ArrayList) ExtendedCommunity(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.extended.community.ExtendedCommunity) ExtendedCommunitiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ExtendedCommunitiesBuilder)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)4 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)2 Ipv4RouterIdentifier (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Ipv4RouterIdentifier)2 Ipv6RouterIdentifier (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Ipv6RouterIdentifier)2 Opaque (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.Opaque)2 OpaqueValueBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.p2mp.lsp.mldp.p2mp.lsp.OpaqueValueBuilder)2 Opaque (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev200120.Opaque)2 OpaqueValueBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev200120.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.p2mp.lsp.mldp.p2mp.lsp.OpaqueValueBuilder)2 BitArray (org.opendaylight.protocol.util.BitArray)1 IpAddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone)1 AdministrativeGroup (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.AdministrativeGroup)1 Delay (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Delay)1 IsisAreaIdentifier (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.IsisAreaIdentifier)1 Loss (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Loss)1 MplsProtocolMask (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.MplsProtocolMask)1 TopologyIdentifier (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.TopologyIdentifier)1 LinkMinMaxDelay (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.attribute.LinkMinMaxDelay)1 LinkMinMaxDelayBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.attribute.LinkMinMaxDelayBuilder)1 PeerAdjSidBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.attribute.PeerAdjSidBuilder)1