use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.range.sub.tlvs.RangeSubTlv in project bgpcep by opendaylight.
the class RangeTlvParser method serializeSubTlvs.
private static void serializeSubTlvs(final ByteBuf aggregator, final List<SubTlvs> subTlvs) {
for (final SubTlvs subTlv : subTlvs) {
ByteBuf buffer = Unpooled.buffer();
final RangeSubTlv rangeSubTlv = subTlv.getRangeSubTlv();
if (rangeSubTlv instanceof PrefixSidTlvCase) {
final PrefixSidTlv prefixSidTlv = ((PrefixSidTlvCase) rangeSubTlv).getPrefixSidTlv();
SrPrefixAttributesParser.serializePrefixAttributes(prefixSidTlv.getFlags(), prefixSidTlv.getAlgorithm(), prefixSidTlv.getSidLabelIndex(), buffer);
TlvUtil.writeTLV(PREFIX_SID, buffer, aggregator);
} else if (rangeSubTlv instanceof Ipv6PrefixSidTlvCase) {
final Ipv6PrefixSidTlv prefixSidTlv = ((Ipv6PrefixSidTlvCase) rangeSubTlv).getIpv6PrefixSidTlv();
Ipv6SrPrefixAttributesParser.serializePrefixAttributes(prefixSidTlv.getAlgorithm(), buffer);
TlvUtil.writeTLV(IPV6_PREFIX_SID, buffer, aggregator);
} else if (rangeSubTlv instanceof BindingSidTlvCase) {
final BindingSidTlvCase rangeTlv = (BindingSidTlvCase) rangeSubTlv;
BindingSidLabelParser.serializeBindingSidAttributes(rangeTlv.getWeight(), rangeTlv.getFlags(), rangeTlv.getBindingSubTlvs(), buffer);
TlvUtil.writeTLV(BINDING_SID, buffer, aggregator);
} else if (rangeSubTlv instanceof SidLabelTlvCase) {
buffer = SidLabelIndexParser.serializeSidValue(((SidLabelTlvCase) rangeSubTlv).getSidLabelIndex());
TlvUtil.writeTLV(SID_TYPE, buffer, aggregator);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.range.sub.tlvs.RangeSubTlv 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 RangeSubTlv subTlvCase;
final int type = buffer.readUnsignedShort();
final int length = buffer.readUnsignedShort();
switch(type) {
case PREFIX_SID:
subTlvCase = new PrefixSidTlvCaseBuilder().setPrefixSidTlv(new PrefixSidTlvBuilder(SrPrefixAttributesParser.parseSrPrefix(buffer.readSlice(length), protocolId)).build()).build();
break;
case IPV6_PREFIX_SID:
subTlvCase = new Ipv6PrefixSidTlvCaseBuilder().setIpv6PrefixSidTlv(new Ipv6PrefixSidTlvBuilder(Ipv6SrPrefixAttributesParser.parseSrIpv6Prefix(buffer.readSlice(length))).build()).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(new SubTlvsBuilder().setRangeSubTlv(subTlvCase).build());
}
return subTlvs;
}
Aggregations