Search in sources :

Example 1 with OpaqueValueBuilder

use of 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 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((short) 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.rev160812.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.rev160812.Opaque) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 2 with OpaqueValueBuilder

use of 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 in project bgpcep by opendaylight.

the class OpaqueUtil method parseOpaque.

public static Opaque parseOpaque(final ByteBuf buffer) {
    final Uint8 type = ByteBufUtils.readUint8(buffer);
    final OpaqueValueBuilder builder = new OpaqueValueBuilder();
    switch(type.toJava()) {
        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;
    }
    return builder.setOpaqueType(type).build();
}
Also used : Uint8(org.opendaylight.yangtools.yang.common.Uint8) 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)

Example 3 with OpaqueValueBuilder

use of 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 in project bgpcep by opendaylight.

the class PMSITunnelAttributeHandlerTestUtil method buildNoSupportedOpaqueAttribute.

static Attributes buildNoSupportedOpaqueAttribute() {
    final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
    final List<OpaqueValue> nonSupported = singletonList(new OpaqueValueBuilder().setOpaque(OPAQUE_TEST).setOpaqueType(NO_SUPPORTED_OPAQUE).build());
    pmsiTunnelBuilder.setTunnelIdentifier(buildMldpP2mpLsp(IP_ADDRESS, Ipv4AddressFamily.class, nonSupported));
    return buildAttribute(pmsiTunnelBuilder);
}
Also used : OpaqueValue(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.OpaqueValue) 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) PmsiTunnelBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.PmsiTunnelBuilder) Ipv4AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily)

Example 4 with OpaqueValueBuilder

use of 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 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 5 with OpaqueValueBuilder

use of 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 in project bgpcep by opendaylight.

the class OpaqueUtil method buildExtended.

private static void buildExtended(final OpaqueValueBuilder builder, final ByteBuf buffer) {
    final int extendedType = buffer.readUnsignedShort();
    final HexString opaqueValue = buildOpaqueValue(buffer);
    builder.setOpaqueExtendedType(extendedType).setOpaque(opaqueValue);
}
Also used : HexString(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.HexString)

Aggregations

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)3 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)3 ByteBuf (io.netty.buffer.ByteBuf)2 Test (org.junit.Test)2 HexString (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.HexString)2 Ipv4AddressFamily (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily)1 Ipv4AddressFamily (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv4AddressFamily)1 Opaque (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.Opaque)1 PmsiTunnelBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.PmsiTunnelBuilder)1 OpaqueValue (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.OpaqueValue)1 Opaque (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev200120.Opaque)1 PmsiTunnelBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev200120.pmsi.tunnel.PmsiTunnelBuilder)1 OpaqueValue (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.OpaqueValue)1 Uint16 (org.opendaylight.yangtools.yang.common.Uint16)1 Uint8 (org.opendaylight.yangtools.yang.common.Uint8)1