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);
}
}
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());
}
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);
}
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));
}
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());
}
Aggregations