use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.binding.sid.tlv.BindingSubTlvs in project bgpcep by opendaylight.
the class SimpleBindingSubTlvsRegistry method parseBindingSubTlvs.
public List<BindingSubTlvs> parseBindingSubTlvs(final ByteBuf buffer, final ProtocolId protocolId) {
final List<BindingSubTlvs> subTlvs = new ArrayList<>();
if (buffer != null) {
while (buffer.isReadable()) {
final int type = buffer.readUnsignedShort();
final int length = buffer.readUnsignedShort();
final ByteBuf slice = buffer.readSlice(length);
final BindingSubTlvsParser parser = this.handlers.getParser(type);
if (parser == null) {
return null;
}
subTlvs.add(new BindingSubTlvsBuilder().setBindingSubTlv(parser.parseSubTlv(slice, protocolId)).build());
}
}
return subTlvs;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.binding.sid.tlv.BindingSubTlvs 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(Uint32.valueOf(16909060L)).build()).build()).build());
rangeSubTlvs.add(new SubTlvsBuilder().setRangeSubTlv(new PrefixSidTlvCaseBuilder().setPrefixSidTlv(new PrefixSidTlvBuilder().setFlags(ISIS_PREFIX_FLAGS).setAlgorithm(Algorithm.StrictShortestPathFirst).setSidLabelIndex(new LocalLabelCaseBuilder().setLocalLabel(new MplsLabel(Uint32.valueOf(66048))).build()).build()).build()).build());
final List<BindingSubTlvs> bindingSubTlvs = new ArrayList<>();
addBindingSubTlvs(bindingSubTlvs);
rangeSubTlvs.add(new SubTlvsBuilder().setRangeSubTlv(new BindingSidTlvCaseBuilder().setWeight(new Weight(Uint8.valueOf(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.rev200120.binding.sid.tlv.BindingSubTlvs in project bgpcep by opendaylight.
the class SrAttributeParserTest method addBindingSubTlvs.
private static void addBindingSubTlvs(final List<BindingSubTlvs> bindingSubTlvs) {
bindingSubTlvs.add(new BindingSubTlvsBuilder().setBindingSubTlv(new PrefixSidCaseBuilder().setPrefixSid(new PrefixSidBuilder().setFlags(ISIS_PREFIX_FLAGS).setAlgorithm(Algorithm.StrictShortestPathFirst).setSidLabelIndex(new SidCaseBuilder().setSid(Uint32.valueOf(16909060L)).build()).build()).build()).build());
bindingSubTlvs.add(new BindingSubTlvsBuilder().setBindingSubTlv(new SidLabelCaseBuilder().setSidLabelIndex(new SidCaseBuilder().setSid(Uint32.valueOf(16909060L)).build()).build()).build());
bindingSubTlvs.add(new BindingSubTlvsBuilder().setBindingSubTlv(new EroMetricCaseBuilder().setEroMetric(new TeMetric(Uint32.valueOf(6))).build()).build());
bindingSubTlvs.add(new BindingSubTlvsBuilder().setBindingSubTlv(new Ipv4EroCaseBuilder().setIpv4Ero(new Ipv4EroBuilder().setLoose(Boolean.FALSE).setAddress(new Ipv4AddressNoZone("9.8.7.6")).build()).build()).build());
bindingSubTlvs.add(new BindingSubTlvsBuilder().setBindingSubTlv(new UnnumberedInterfaceIdEroCaseBuilder().setUnnumberedInterfaceIdEro(new UnnumberedInterfaceIdEroBuilder().setLoose(Boolean.FALSE).setRouterId(Uint32.valueOf(16843009L)).setInterfaceId(Uint32.valueOf(33686018L)).build()).build()).build());
bindingSubTlvs.add(new BindingSubTlvsBuilder().setBindingSubTlv(new Ipv4EroBackupCaseBuilder().setIpv4EroBackup(new Ipv4EroBackupBuilder().setLoose(Boolean.FALSE).setAddress(new Ipv4AddressNoZone("3.4.5.6")).build()).build()).build());
bindingSubTlvs.add(new BindingSubTlvsBuilder().setBindingSubTlv(new UnnumberedInterfaceIdBackupEroCaseBuilder().setUnnumberedInterfaceIdBackupEro(new UnnumberedInterfaceIdBackupEroBuilder().setLoose(Boolean.FALSE).setRouterId(Uint32.valueOf(50529027L)).setInterfaceId(Uint32.valueOf(67372036L)).build()).build()).build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.binding.sid.tlv.BindingSubTlvs 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().setIpv6Ero(new Ipv6EroBuilder().setLoose(Boolean.FALSE).setAddress(new Ipv6AddressNoZone(IPV6_A)).build()).build()).build());
bindingSubTlvs.add(new BindingSubTlvsBuilder().setBindingSubTlv(new Ipv6EroBackupCaseBuilder().setIpv6EroBackup(new Ipv6EroBackupBuilder().setLoose(Boolean.FALSE).setAddress(new Ipv6AddressNoZone(IPV6_B)).build()).build()).build());
rangeSubTlvs.add(new SubTlvsBuilder().setRangeSubTlv(new BindingSidTlvCaseBuilder().setWeight(new Weight(Uint8.valueOf(5))).setFlags(BINDING_FLAGS).setBindingSubTlvs(bindingSubTlvs).build()).build());
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));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.binding.sid.tlv.BindingSubTlvs 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);
}
}
}
Aggregations