Search in sources :

Example 71 with Tlv

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.Tlv in project bgpcep by opendaylight.

the class SimpleRegistryTest method testSimpleBgpPrefixSidTlvRegistry.

@Test
public void testSimpleBgpPrefixSidTlvRegistry() {
    final BgpPrefixSidTlvRegistry sidTlvReg = this.ctx.getBgpPrefixSidTlvRegistry();
    final byte[] tlvBytes = { 0x00, 0x03, 0x00, 0x00, 0x00 };
    final BgpPrefixSidTlv tlv = mock(BgpPrefixSidTlv.class);
    doReturn(BgpPrefixSidTlv.class).when(tlv).implementedInterface();
    final ByteBuf buffer = Unpooled.buffer(tlvBytes.length);
    sidTlvReg.serializeBgpPrefixSidTlv(tlv, buffer);
    verify(this.activator.sidTlvSerializer, times(1)).serializeBgpPrefixSidTlv(any(BgpPrefixSidTlv.class), any(ByteBuf.class));
    sidTlvReg.parseBgpPrefixSidTlv(BgpTestActivator.TYPE, Unpooled.wrappedBuffer(tlvBytes));
    verify(this.activator.sidTlvParser, times(1)).parseBgpPrefixSidTlv(any(ByteBuf.class));
}
Also used : BgpPrefixSidTlv(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.bgp.prefix.sid.bgp.prefix.sid.tlvs.BgpPrefixSidTlv) BgpPrefixSidTlvRegistry(org.opendaylight.protocol.bgp.parser.spi.BgpPrefixSidTlvRegistry) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 72 with Tlv

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.Tlv in project bgpcep by opendaylight.

the class SrAttributeParserTest method testRangeTlv.

// tools.ietf.org/html/draft-gredler-idr-bgp-ls-segment-routing-ext-00#section-2.3.2
@Test
public void testRangeTlv() {
    final byte[] tested = { 0, 0, 0, 5, // sid
    4, // sid
    (byte) 0x89, // sid
    0, // sid
    4, // sid
    1, // sid
    2, // sid
    3, // sid
    4, // prefix + mpls label
    4, // prefix + mpls label
    (byte) 0x86, // prefix + mpls label
    0, // prefix + mpls label
    7, // prefix + mpls label
    (byte) 0xac, // prefix + mpls label
    1, // prefix + mpls label
    0, // prefix + mpls label
    0, // prefix + mpls label
    1, // prefix + mpls label
    2, // prefix + mpls label
    0, // binding sid
    4, // binding sid
    (byte) 0x88, // binding sid
    0, // binding sid
    0x58, // binding sid
    5, // binding sid
    0x48, // binding sid
    0, // binding sid
    0, // prefix
    4, // prefix
    (byte) 0x86, // prefix
    0, // prefix
    8, // prefix
    (byte) 0xa0, // prefix
    1, // prefix
    0, // prefix
    0, // prefix
    1, // prefix
    2, // prefix
    3, // prefix
    4, // sid
    4, // sid
    (byte) 0x89, // sid
    0, // sid
    4, // sid
    1, // sid
    2, // sid
    3, // sid
    4, // ero metric
    4, // ero metric
    (byte) 0x8a, // ero metric
    0, // ero metric
    4, // ero metric
    0, // ero metric
    0, // ero metric
    0, // ero metric
    6, // IPv4 ERO
    4, // IPv4 ERO
    (byte) 0x8b, // IPv4 ERO
    0, // IPv4 ERO
    8, // IPv4 ERO
    0, // IPv4 ERO
    0, // IPv4 ERO
    0, // IPv4 ERO
    0, // IPv4 ERO
    9, // IPv4 ERO
    8, // IPv4 ERO
    7, // IPv4 ERO
    6, // Unnumbered Interface ID ERO Sub-TLV
    4, // Unnumbered Interface ID ERO Sub-TLV
    (byte) 0x8d, // Unnumbered Interface ID ERO Sub-TLV
    0, // Unnumbered Interface ID ERO Sub-TLV
    0x0c, // Unnumbered Interface ID ERO Sub-TLV
    0, // Unnumbered Interface ID ERO Sub-TLV
    0, // Unnumbered Interface ID ERO Sub-TLV
    0, // Unnumbered Interface ID ERO Sub-TLV
    0, // Unnumbered Interface ID ERO Sub-TLV
    1, // Unnumbered Interface ID ERO Sub-TLV
    1, // Unnumbered Interface ID ERO Sub-TLV
    1, // Unnumbered Interface ID ERO Sub-TLV
    1, // Unnumbered Interface ID ERO Sub-TLV
    2, // Unnumbered Interface ID ERO Sub-TLV
    2, // Unnumbered Interface ID ERO Sub-TLV
    2, // Unnumbered Interface ID ERO Sub-TLV
    2, // IPv4 ERO backup
    4, // IPv4 ERO backup
    (byte) 0x8e, // IPv4 ERO backup
    0, // IPv4 ERO backup
    8, // IPv4 ERO backup
    0, // IPv4 ERO backup
    0, // IPv4 ERO backup
    0, // IPv4 ERO backup
    0, // IPv4 ERO backup
    3, // IPv4 ERO backup
    4, // IPv4 ERO backup
    5, // IPv4 ERO backup
    6, // Unnumbered Interface ID ERO Sub-TLV Backup
    4, // Unnumbered Interface ID ERO Sub-TLV Backup
    (byte) 0x90, // Unnumbered Interface ID ERO Sub-TLV Backup
    0, // Unnumbered Interface ID ERO Sub-TLV Backup
    0x0c, // Unnumbered Interface ID ERO Sub-TLV Backup
    0, // Unnumbered Interface ID ERO Sub-TLV Backup
    0, // Unnumbered Interface ID ERO Sub-TLV Backup
    0, // Unnumbered Interface ID ERO Sub-TLV Backup
    0, // Unnumbered Interface ID ERO Sub-TLV Backup
    3, // Unnumbered Interface ID ERO Sub-TLV Backup
    3, // Unnumbered Interface ID ERO Sub-TLV Backup
    3, // Unnumbered Interface ID ERO Sub-TLV Backup
    3, // Unnumbered Interface ID ERO Sub-TLV Backup
    4, // Unnumbered Interface ID ERO Sub-TLV Backup
    4, // Unnumbered Interface ID ERO Sub-TLV Backup
    4, // Unnumbered Interface ID ERO Sub-TLV Backup
    4 };
    final SrRange parsedRange = RangeTlvParser.parseSrRange(Unpooled.wrappedBuffer(tested), ProtocolId.IsisLevel1);
    final List<SubTlvs> rangeSubTlvs = new ArrayList<>();
    addSubTlvs(rangeSubTlvs);
    final SrRange expected = new SrRangeBuilder().setInterArea(Boolean.FALSE).setRangeSize(Uint16.valueOf(5)).setSubTlvs(rangeSubTlvs).build();
    assertEquals(expected, parsedRange);
    final ByteBuf serializedRange = Unpooled.buffer();
    RangeTlvParser.serializeSrRange(parsedRange, serializedRange);
    assertArrayEquals(tested, ByteArray.getAllBytes(serializedRange));
}
Also used : SrRange(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.prefix.state.SrRange) SrRangeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.prefix.state.SrRangeBuilder) ArrayList(java.util.ArrayList) BindingSubTlvs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.binding.sid.tlv.BindingSubTlvs) SubTlvs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.range.tlv.SubTlvs) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 73 with Tlv

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.Tlv in project bgpcep by opendaylight.

the class SimpleBindingSubTlvsRegistry method serializeBindingSubTlvs.

public void serializeBindingSubTlvs(final List<BindingSubTlvs> bindingSubTlvs, final ByteBuf aggregator) {
    if (bindingSubTlvs != null) {
        for (final BindingSubTlvs subTlv : bindingSubTlvs) {
            final BindingSubTlv bindingSubTlv = subTlv.getBindingSubTlv();
            final BindingSubTlvsSerializer serializer = handlers.getSerializer(bindingSubTlv.implementedInterface());
            if (serializer == null) {
                LOG.info("Unknown binding sub Tlv type {}", subTlv);
                return;
            }
            serializer.serializeSubTlv(bindingSubTlv, aggregator);
        }
    }
}
Also used : BindingSubTlvsSerializer(org.opendaylight.protocol.bgp.linkstate.spi.BindingSubTlvsSerializer) BindingSubTlv(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.binding.sub.tlvs.BindingSubTlv) BindingSubTlvs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.binding.sid.tlv.BindingSubTlvs)

Example 74 with Tlv

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.Tlv in project bgpcep by opendaylight.

the class LinkstateNlriParser method parseNlri.

/**
 * Parses common parts for Link State Nodes, Links and Prefixes, that includes protocol ID and identifier tlv.
 *
 * @param nlri as byte array
 * @return {@link CLinkstateDestination}
 */
private List<CLinkstateDestination> parseNlri(final ByteBuf nlri) {
    final List<CLinkstateDestination> dests = new ArrayList<>();
    while (nlri.isReadable()) {
        final CLinkstateDestination destination = this.nlriTypeReg.parseNlriType(nlri);
        if (destination == null) {
            continue;
        }
        dests.add(destination);
    }
    return dests;
}
Also used : ArrayList(java.util.ArrayList) CLinkstateDestination(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.destination.CLinkstateDestination)

Example 75 with Tlv

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.Tlv in project bgpcep by opendaylight.

the class PCEPTlvParserTest method testSymbolicNameTlv.

@Test
public void testSymbolicNameTlv() throws PCEPDeserializerException {
    final StatefulLspSymbolicNameTlvParser parser = new StatefulLspSymbolicNameTlvParser();
    final SymbolicPathName tlv = new SymbolicPathNameBuilder().setPathName(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.SymbolicPathName("Med test of symbolic nameeee".getBytes())).build();
    assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(SYMBOLIC_NAME_BYTES, 4))));
    final ByteBuf buff = Unpooled.buffer();
    parser.serializeTlv(tlv, buff);
    assertArrayEquals(SYMBOLIC_NAME_BYTES, ByteArray.getAllBytes(buff));
}
Also used : SymbolicPathNameBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.symbolic.path.name.tlv.SymbolicPathNameBuilder) SymbolicPathName(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.symbolic.path.name.tlv.SymbolicPathName) ByteBuf(io.netty.buffer.ByteBuf) StatefulLspSymbolicNameTlvParser(org.opendaylight.protocol.pcep.ietf.stateful.StatefulLspSymbolicNameTlvParser) Test(org.junit.Test)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)59 Test (org.junit.Test)28 Tlv (es.gob.jmulticard.asn1.Tlv)11 ArrayList (java.util.ArrayList)10 TunnelId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.TunnelId)8 LspId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId)7 TlvException (es.gob.jmulticard.asn1.TlvException)6 Stateful (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.stateful.capability.tlv.Stateful)5 Ipv4ExtendedTunnelId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.Ipv4ExtendedTunnelId)5 Asn1Exception (es.gob.jmulticard.asn1.Asn1Exception)4 DecoderObject (es.gob.jmulticard.asn1.DecoderObject)4 BitArray (org.opendaylight.protocol.util.BitArray)4 Ipv6ExtendedTunnelId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.Ipv6ExtendedTunnelId)4 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)3 EnterpriseNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber)3 Stateful (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.Stateful)3 LspIdentifiers (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.LspIdentifiers)3 LspIdentifiersBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.LspIdentifiersBuilder)3 AddressFamily (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.lsp.identifiers.AddressFamily)3 RsvpErrorSpec (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.rsvp.error.spec.tlv.RsvpErrorSpec)3