final BitSet flags = BitSet.valueOf(ByteArray.readAllBytes(value));
builder.setNodeFlags(new NodeFlagBits(flags.get(OVERLOAD_BIT), flags.get(ATTACHED_BIT), flags.get(EXTERNAL_BIT), flags.get(ABBR_BIT)));
LOG.debug("Parsed Overload bit: {}, attached bit: {}, external bit: {}, area border router: {}.",
- flags.get(OVERLOAD_BIT), flags.get(ATTACHED_BIT), flags.get(EXTERNAL_BIT), flags.get(ABBR_BIT));
+ flags.get(OVERLOAD_BIT), flags.get(ATTACHED_BIT), flags.get(EXTERNAL_BIT), flags.get(ABBR_BIT));
break;
case TlvCode.NODE_OPAQUE:
LOG.debug("Ignoring opaque value: {}.", ByteBufUtil.hexDump(value));
LOG.debug("Parsed Metric: {}", metric);
break;
case TlvCode.FORWARDING_ADDRESS:
- IpAddress fwdAddress = parseForwardingAddress(value);
+ final IpAddress fwdAddress = parseForwardingAddress(value);
builder.setOspfForwardingAddress(fwdAddress);
LOG.debug("Parsed FWD Address: {}", fwdAddress);
break;
writeTLV(TlvCode.MAX_RESERVABLE_BANDWIDTH, Unpooled.wrappedBuffer(linkAttributes.getMaxReservableBandwidth().getValue()), byteAggregator);
}
// this sub-TLV contains eight 32-bit IEEE floating point numbers
- if (linkAttributes.getUnreservedBandwidth() != null) {
+ final List<UnreservedBandwidth> ubList = linkAttributes.getUnreservedBandwidth();
+ if (ubList != null && !ubList.isEmpty()) {
final ByteBuf unreservedBandwithBuf = Unpooled.buffer();
- for (final UnreservedBandwidth unreservedBandwidth : linkAttributes.getUnreservedBandwidth()) {
+ for (final UnreservedBandwidth unreservedBandwidth : ubList) {
unreservedBandwithBuf.writeBytes(unreservedBandwidth.getBandwidth().getValue());
}
writeTLV(TlvCode.UNRESERVED_BANDWIDTH, unreservedBandwithBuf, byteAggregator);
// size of metric can be 1,2 or 3 depending on the protocol
writeTLV(TlvCode.METRIC, Unpooled.copyMedium(linkAttributes.getMetric().getValue().intValue()), byteAggregator);
}
- if (linkAttributes.getSharedRiskLinkGroups() != null) {
+ final List<SrlgId> srlgList = linkAttributes.getSharedRiskLinkGroups();
+ if (srlgList != null && !srlgList.isEmpty()) {
final ByteBuf sharedRLGBuf = Unpooled.buffer();
- for (final SrlgId srlgId : linkAttributes.getSharedRiskLinkGroups()) {
+ for (final SrlgId srlgId : srlgList) {
sharedRLGBuf.writeInt(srlgId.getValue().intValue());
}
writeTLV(TlvCode.SHARED_RISK_LINK_GROUP, sharedRLGBuf, byteAggregator);
private void serializeNodeAttributes(final NodeAttributesCase nodeAttributesCase, final ByteBuf byteAggregator) {
LOG.trace("Started serializing Node Attributes");
final NodeAttributes nodeAttributes = nodeAttributesCase.getNodeAttributes();
- if (nodeAttributes.getTopologyIdentifier() != null) {
+ final List<TopologyIdentifier> topList = nodeAttributes.getTopologyIdentifier();
+ if (topList != null && !topList.isEmpty()) {
final ByteBuf mpIdBuf = Unpooled.buffer();
- for (final TopologyIdentifier topologyIdentifier : nodeAttributes.getTopologyIdentifier()) {
+ for (final TopologyIdentifier topologyIdentifier : topList) {
mpIdBuf.writeShort(topologyIdentifier.getValue());
}
writeTLV(TlvCode.MULTI_TOPOLOGY_ID, mpIdBuf, byteAggregator);
if (nodeAttributes.getDynamicHostname() != null) {
writeTLV(TlvCode.DYNAMIC_HOSTNAME, Unpooled.wrappedBuffer(nodeAttributes.getDynamicHostname().getBytes()), byteAggregator);
}
- if (nodeAttributes.getIsisAreaId() != null) {
- for (final IsisAreaIdentifier isisAreaIdentifier : nodeAttributes.getIsisAreaId()) {
+ final List<IsisAreaIdentifier> isisList = nodeAttributes.getIsisAreaId();
+ if (isisList != null && !isisList.isEmpty()) {
+ for (final IsisAreaIdentifier isisAreaIdentifier : isisList) {
writeTLV(TlvCode.ISIS_AREA_IDENTIFIER, Unpooled.wrappedBuffer(isisAreaIdentifier.getValue()), byteAggregator);
}
}
}
writeTLV(TlvCode.ROUTE_TAG, routeTagsBuf, byteAggregator);
}
- if (prefixAtrributes.getExtendedTags() != null) {
+ final List<ExtendedRouteTag> routeTagList = prefixAtrributes.getExtendedTags();
+ if (routeTagList != null && !routeTagList.isEmpty()) {
final ByteBuf extendedBuf = Unpooled.buffer();
- for (final ExtendedRouteTag extendedRouteTag : prefixAtrributes.getExtendedTags()) {
+ for (final ExtendedRouteTag extendedRouteTag : routeTagList) {
extendedBuf.writeBytes(extendedRouteTag.getValue());
}
writeTLV(TlvCode.EXTENDED_ROUTE_TAG, extendedBuf, byteAggregator);