use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.range.tlv.SubTlvsBuilder in project bgpcep by opendaylight.
the class SrAttributeParserTest method addSubTlvs.
private static void addSubTlvs(final List<SubTlvs> rangeSubTlvs) {
rangeSubTlvs.add(new SubTlvsBuilder().setRangeSubTlv(new SidLabelTlvCaseBuilder().setSidLabelIndex(new SidCaseBuilder().setSid(16909060L).build()).build()).build());
rangeSubTlvs.add(new SubTlvsBuilder().setRangeSubTlv(new PrefixSidTlvCaseBuilder().setFlags(ISIS_PREFIX_FLAGS).setAlgorithm(Algorithm.StrictShortestPathFirst).setSidLabelIndex(new LocalLabelCaseBuilder().setLocalLabel(new MplsLabel(66048L)).build()).build()).build());
final List<BindingSubTlvs> bindingSubTlvs = new ArrayList<>();
addBindingSubTlvs(bindingSubTlvs);
rangeSubTlvs.add(new SubTlvsBuilder().setRangeSubTlv(new BindingSidTlvCaseBuilder().setWeight(new Weight((short) 5)).setFlags(BINDING_FLAGS).setBindingSubTlvs(bindingSubTlvs).build()).build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.range.tlv.SubTlvsBuilder in project bgpcep by opendaylight.
the class SrAttributeParserTest method testRangeTlvIpv6.
@Test
public void testRangeTlvIpv6() {
final byte[] tested = Bytes.concat(new byte[] { 0, 0, 0, 5, // binding sid
4, // binding sid
(byte) 0x88, // binding sid
0, // binding sid
0x34, // binding sid
5, // binding sid
0x48, // binding sid
0, // binding sid
0, // binding sub-tlvs
4, (byte) 0x8c, 0, 0x14, 0, 0, 0, // IPv6 ERO
0 }, // IPv6 ERO
IPV6_A_BYTES, // IPv6 ERO backup
new byte[] { 4, (byte) 0x8f, 0, 0x14, 0, 0, 0, 0 }, // IPv6 ERO backup
IPV6_B_BYTES);
final SrRange parsedRange = RangeTlvParser.parseSrRange(Unpooled.wrappedBuffer(tested), ProtocolId.IsisLevel1);
final List<SubTlvs> rangeSubTlvs = new ArrayList<>();
final List<BindingSubTlvs> bindingSubTlvs = new ArrayList<>();
bindingSubTlvs.add(new BindingSubTlvsBuilder().setBindingSubTlv(new Ipv6EroCaseBuilder().setLoose(Boolean.FALSE).setAddress(new Ipv6Address(IPV6_A)).build()).build());
bindingSubTlvs.add(new BindingSubTlvsBuilder().setBindingSubTlv(new Ipv6EroBackupCaseBuilder().setLoose(Boolean.FALSE).setAddress(new Ipv6Address(IPV6_B)).build()).build());
rangeSubTlvs.add(new SubTlvsBuilder().setRangeSubTlv(new BindingSidTlvCaseBuilder().setWeight(new Weight((short) 5)).setFlags(BINDING_FLAGS).setBindingSubTlvs(bindingSubTlvs).build()).build());
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.bgp.segment.routing.ext.rev151014.range.tlv.SubTlvsBuilder in project bgpcep by opendaylight.
the class RangeTlvParser method parseRangeSubTlvs.
private static List<SubTlvs> parseRangeSubTlvs(final ByteBuf buffer, final ProtocolId protocolId) {
final List<SubTlvs> subTlvs = new ArrayList<>();
while (buffer.isReadable()) {
final SubTlvsBuilder subTlv = new SubTlvsBuilder();
final RangeSubTlv subTlvCase;
final int type = buffer.readUnsignedShort();
final int length = buffer.readUnsignedShort();
switch(type) {
case PREFIX_SID:
subTlvCase = new PrefixSidTlvCaseBuilder(SrPrefixAttributesParser.parseSrPrefix(buffer.readSlice(length), protocolId)).build();
break;
case IPV6_PREFIX_SID:
subTlvCase = new Ipv6PrefixSidTlvCaseBuilder(Ipv6SrPrefixAttributesParser.parseSrIpv6Prefix(buffer.readSlice(length))).build();
break;
case BINDING_SID:
subTlvCase = new BindingSidTlvCaseBuilder(BindingSidLabelParser.parseBindingSidLabel(buffer.readSlice(length), protocolId)).build();
break;
case SID_TYPE:
subTlvCase = new SidLabelTlvCaseBuilder().setSidLabelIndex(SidLabelIndexParser.parseSidLabelIndex(Size.forValue(length), buffer.readSlice(length))).build();
break;
default:
LOG.info("Unknown type of range sub-tlv: {}", type);
buffer.skipBytes(length);
continue;
}
subTlvs.add(subTlv.setRangeSubTlv(subTlvCase).build());
}
return subTlvs;
}
Aggregations