Search in sources :

Example 71 with Tlv

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv in project bgpcep by opendaylight.

the class BgpPrefixSidAttributeParser method serializeAttribute.

@Override
public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) {
    Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a PathAttribute object.");
    final Attributes pathAttributes = (Attributes) attribute;
    final BgpPrefixSid prefixSid = pathAttributes.getBgpPrefixSid();
    if (prefixSid == null) {
        return;
    }
    for (final BgpPrefixSidTlvs tlv : prefixSid.getBgpPrefixSidTlvs()) {
        this.reg.serializeBgpPrefixSidTlv(tlv.getBgpPrefixSidTlv(), byteAggregator);
    }
}
Also used : BgpPrefixSidTlvs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.bgp.prefix.sid.BgpPrefixSidTlvs) Attributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes) BgpPrefixSid(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.BgpPrefixSid)

Example 72 with Tlv

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv in project bgpcep by opendaylight.

the class BgpPrefixSidAttributeParser method parseAttribute.

@Override
public void parseAttribute(final ByteBuf buffer, final AttributesBuilder builder) throws BGPDocumentedException, BGPParsingException {
    final BgpPrefixSidBuilder sid = new BgpPrefixSidBuilder();
    final List<BgpPrefixSidTlvs> tlvList = new ArrayList<>();
    while (buffer.isReadable()) {
        final BgpPrefixSidTlv tlv = this.reg.parseBgpPrefixSidTlv(buffer.readUnsignedByte(), buffer);
        tlvList.add(new BgpPrefixSidTlvsBuilder().setBgpPrefixSidTlv(tlv).build());
    }
    builder.setBgpPrefixSid(sid.setBgpPrefixSidTlvs(tlvList).build());
}
Also used : BgpPrefixSidTlv(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.bgp.prefix.sid.bgp.prefix.sid.tlvs.BgpPrefixSidTlv) BgpPrefixSidTlvs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.bgp.prefix.sid.BgpPrefixSidTlvs) ArrayList(java.util.ArrayList) BgpPrefixSidBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.BgpPrefixSidBuilder) BgpPrefixSidTlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.bgp.prefix.sid.BgpPrefixSidTlvsBuilder)

Example 73 with Tlv

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv in project bgpcep by opendaylight.

the class AbstractVendorInformationTlvParser method serializeTlv.

@Override
public final void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
    Preconditions.checkArgument(tlv instanceof VendorInformationTlv, "Vendor Specific Tlv is mandatory.");
    final VendorInformationTlv viTlv = (VendorInformationTlv) tlv;
    final ByteBuf body = Unpooled.buffer();
    writeUnsignedInt(getEnterpriseNumber().getValue(), body);
    serializeEnterpriseSpecificInformation(viTlv.getEnterpriseSpecificInformation(), body);
    TlvUtil.formatTlv(VENDOR_INFORMATION_TLV_TYPE, body, buffer);
}
Also used : VendorInformationTlv(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.tlvs.VendorInformationTlv) ByteBuf(io.netty.buffer.ByteBuf)

Example 74 with Tlv

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.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(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.rev171207.prefix.state.SrRange) SrRangeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.prefix.state.SrRangeBuilder) ArrayList(java.util.ArrayList) SubTlvs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.range.tlv.SubTlvs) BindingSubTlvs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.binding.sid.tlv.BindingSubTlvs) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 75 with Tlv

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv in project bgpcep by opendaylight.

the class BgpPrefixSidTlvsTest method testOriginatorParser.

@Test
public void testOriginatorParser() {
    final OriginatorSrgbTlvParser parser = new OriginatorSrgbTlvParser();
    final List<SrgbValue> list = new ArrayList<>();
    final Srgb srgb1 = new Srgb(1L);
    final Srgb srgb2 = new Srgb(2L);
    list.add(new SrgbValueBuilder().setBase(srgb1).setRange(srgb2).build());
    list.add(new SrgbValueBuilder().setBase(srgb2).setRange(srgb1).build());
    final LuOriginatorSrgbTlv tlv = new LuOriginatorSrgbTlvBuilder().setSrgbValue(list).build();
    final ByteBuf serialized = Unpooled.buffer(14);
    parser.serializeBgpPrefixSidTlv(tlv, serialized);
    final byte[] expected = new byte[] { 0, 0, 0, 0, 1, 0, 0, 2, 0, 0, 2, 0, 0, 1 };
    assertArrayEquals(expected, serialized.array());
    final LuOriginatorSrgbTlv parsed = parser.parseBgpPrefixSidTlv(serialized);
    assertEquals(tlv.getSrgbValue().size(), parsed.getSrgbValue().size());
    assertTrue(tlv.getSrgbValue().get(0).getBase().equals(srgb1));
    assertTrue(tlv.getSrgbValue().get(0).getRange().equals(srgb2));
    assertTrue(tlv.getSrgbValue().get(1).getBase().equals(srgb2));
    assertTrue(tlv.getSrgbValue().get(1).getRange().equals(srgb1));
    assertEquals(3, parser.getType());
}
Also used : LuOriginatorSrgbTlvBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.update.attributes.bgp.prefix.sid.bgp.prefix.sid.tlvs.bgp.prefix.sid.tlv.LuOriginatorSrgbTlvBuilder) ArrayList(java.util.ArrayList) LuOriginatorSrgbTlv(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.update.attributes.bgp.prefix.sid.bgp.prefix.sid.tlvs.bgp.prefix.sid.tlv.LuOriginatorSrgbTlv) SrgbValue(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.originator.srgb.tlv.SrgbValue) SrgbValueBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.originator.srgb.tlv.SrgbValueBuilder) ByteBuf(io.netty.buffer.ByteBuf) Srgb(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.Srgb) Test(org.junit.Test)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)53 Test (org.junit.Test)29 Tlv (es.gob.jmulticard.asn1.Tlv)11 ArrayList (java.util.ArrayList)8 TlvException (es.gob.jmulticard.asn1.TlvException)6 Asn1Exception (es.gob.jmulticard.asn1.Asn1Exception)4 DecoderObject (es.gob.jmulticard.asn1.DecoderObject)4 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)4 LspIdentifiersBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.LspIdentifiersBuilder)4 Stateful (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.Stateful)4 LspId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId)4 TunnelId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.TunnelId)4 EnterpriseNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber)3 LspIdentifiers (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.LspIdentifiers)3 RsvpErrorSpec (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.rsvp.error.spec.tlv.RsvpErrorSpec)3 VendorInformationTlv (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.tlvs.VendorInformationTlv)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 BmpDeserializationException (org.opendaylight.protocol.bmp.spi.parser.BmpDeserializationException)2 Stateful07RSVPErrorSpecTlvParser (org.opendaylight.protocol.pcep.ietf.stateful07.Stateful07RSVPErrorSpecTlvParser)2 BitArray (org.opendaylight.protocol.util.BitArray)2