use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.ProtocolId 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.bgp.linkstate.rev171207.ProtocolId in project bgpcep by opendaylight.
the class PrefixAttributesParser method parseBindingSid.
private static void parseBindingSid(final PrefixAttributesBuilder builder, final ByteBuf value, final ProtocolId protocolId) {
final List<SrBindingSidLabels> labels;
if (builder.getSrBindingSidLabels() != null) {
labels = builder.getSrBindingSidLabels();
} else {
labels = new ArrayList<>();
builder.setSrBindingSidLabels(labels);
}
final SrBindingSidLabels label = BindingSidLabelParser.parseBindingSidLabel(value, protocolId);
labels.add(label);
LOG.debug("Parsed SR Binding SID {}", label);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.ProtocolId in project bgpcep by opendaylight.
the class RangeTlvParser method parseSrRange.
public static SrRange parseSrRange(final ByteBuf buffer, final ProtocolId protocolId) {
final BitArray flags = BitArray.valueOf(buffer, FLAGS_SIZE);
final SrRangeBuilder range = new SrRangeBuilder();
if (protocolId.equals(ProtocolId.Ospf)) {
range.setInterArea(flags.get(INNER_AREA));
} else {
range.setInterArea(Boolean.FALSE);
}
buffer.skipBytes(RESERVED);
range.setRangeSize(buffer.readUnsignedShort());
range.setSubTlvs(parseRangeSubTlvs(buffer, protocolId));
return range.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.ProtocolId 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.bgp.linkstate.rev171207.ProtocolId in project bgpcep by opendaylight.
the class SrLinkAttributesParser method parseLanAdjacencySegmentIdentifier.
public static SrLanAdjIds parseLanAdjacencySegmentIdentifier(final ByteBuf buffer, final ProtocolId protocolId) {
if (!buffer.isReadable()) {
return new SrLanAdjIdsBuilder().build();
}
final SrLanAdjIdsBuilder srLanAdjIdBuilder = new SrLanAdjIdsBuilder();
final BitArray flags = BitArray.valueOf(buffer, FLAGS_BITS_SIZE);
srLanAdjIdBuilder.setFlags(parseFlags(flags, protocolId));
srLanAdjIdBuilder.setWeight(new Weight(buffer.readUnsignedByte()));
buffer.skipBytes(RESERVED);
switch(protocolId) {
case IsisLevel1:
case IsisLevel2:
srLanAdjIdBuilder.setIsoSystemId(new IsoSystemIdentifier(ByteArray.readBytes(buffer, ISO_SYSTEM_ID_SIZE)));
break;
case Ospf:
case OspfV3:
srLanAdjIdBuilder.setNeighborId(Ipv4Util.addressForByteBuf(buffer));
break;
default:
return null;
}
// length determines a type of next field, which is used for parsing
srLanAdjIdBuilder.setSidLabelIndex(SidLabelIndexParser.parseSidLabelIndex(Size.forValue(buffer.readableBytes()), buffer));
return srLanAdjIdBuilder.build();
}
Aggregations