use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.Tlv in project bgpcep by opendaylight.
the class LinkAttributesParser method serializeUnreservedBw.
private static void serializeUnreservedBw(final List<UnreservedBandwidth> ubList, final ByteBuf byteAggregator) {
// this sub-TLV contains eight 32-bit IEEE floating point numbers
if (ubList != null) {
final ByteBuf unreservedBandwithBuf = Unpooled.buffer();
for (final UnreservedBandwidth unreservedBandwidth : ubList) {
unreservedBandwithBuf.writeBytes(unreservedBandwidth.getBandwidth().getValue());
}
TlvUtil.writeTLV(UNRESERVED_BANDWIDTH, unreservedBandwithBuf, byteAggregator);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.Tlv in project bgpcep by opendaylight.
the class PrefixAttributesParser method parsePrefixAttributes.
/**
* Parse prefix attributes.
*
* @param attributes key is the tlv type and value are the value bytes of the tlv
* @param protocolId to differentiate parsing methods
* @return {@link LinkStateAttribute}
*/
static LinkStateAttribute parsePrefixAttributes(final Multimap<Integer, ByteBuf> attributes, final ProtocolId protocolId) {
final PrefixAttributesBuilder builder = new PrefixAttributesBuilder();
final List<RouteTag> routeTags = new ArrayList<>();
final List<ExtendedRouteTag> exRouteTags = new ArrayList<>();
for (final Entry<Integer, ByteBuf> entry : attributes.entries()) {
final int key = entry.getKey();
final ByteBuf value = entry.getValue();
LOG.trace("Prefix attribute TLV {}", key);
parseAttribute(key, value, protocolId, builder, routeTags, exRouteTags);
}
LOG.trace("Finished parsing Prefix Attributes.");
builder.setRouteTags(routeTags);
builder.setExtendedTags(exRouteTags);
return new PrefixAttributesCaseBuilder().setPrefixAttributes(builder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.Tlv 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;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.Tlv in project bgpcep by opendaylight.
the class LinkstateNlriParser method parseNlri.
/**
* Parses common parts for Link State Nodes, Links and Prefixes, that includes protocol ID and identifier tlv.
*
* @param nlri as byte array
* @return {@link CLinkstateDestination}
*/
private List<CLinkstateDestination> parseNlri(final ByteBuf nlri) {
final List<CLinkstateDestination> dests = new ArrayList<>();
while (nlri.isReadable()) {
final CLinkstateDestination destination = this.nlriTypeReg.parseNlriType(nlri);
if (destination == null) {
continue;
}
dests.add(destination);
}
return dests;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.Tlv in project bgpcep by opendaylight.
the class OriginatorSrgbTlvParser method serializeBgpPrefixSidTlv.
@Override
public void serializeBgpPrefixSidTlv(final BgpPrefixSidTlv tlv, final ByteBuf valueBuf) {
Preconditions.checkArgument(tlv instanceof LuOriginatorSrgbTlv, "Incoming TLV is not LuOriginatorSrgbTlv");
final LuOriginatorSrgbTlv luTlv = (LuOriginatorSrgbTlv) tlv;
valueBuf.writeZero(ORIGINATOR_FLAGS_BYTES);
for (final SrgbValue val : luTlv.getSrgbValue()) {
valueBuf.writeMedium(val.getBase().getValue().intValue());
valueBuf.writeMedium(val.getRange().getValue().intValue());
}
}
Aggregations