use of org.onosproject.bgpio.types.attr.WideCommunity in project onos by opennetworkinglab.
the class BgpPathAttributes method write.
/**
* Write path attributes to channelBuffer.
*
* @param cb channelBuffer
* @return object of BgpPathAttributes
* @throws BgpParseException while parsing BGP path attributes
*/
public int write(ChannelBuffer cb) throws BgpParseException {
if (pathAttribute == null) {
return 0;
}
int iLenStartIndex = cb.writerIndex();
ListIterator<BgpValueType> iterator = pathAttribute.listIterator();
int pathAttributeIndx = cb.writerIndex();
cb.writeShort(0);
while (iterator.hasNext()) {
BgpValueType attr = iterator.next();
switch(attr.getType()) {
case Origin.ORIGIN_TYPE:
Origin origin = (Origin) attr;
origin.write(cb);
break;
case AsPath.ASPATH_TYPE:
AsPath asPath = (AsPath) attr;
asPath.write(cb);
break;
case As4Path.AS4PATH_TYPE:
As4Path as4Path = (As4Path) attr;
as4Path.write(cb);
break;
case NextHop.NEXTHOP_TYPE:
NextHop nextHop = (NextHop) attr;
nextHop.write(cb);
break;
case Med.MED_TYPE:
Med med = (Med) attr;
med.write(cb);
break;
case LocalPref.LOCAL_PREF_TYPE:
LocalPref localPref = (LocalPref) attr;
localPref.write(cb);
break;
case Constants.BGP_EXTENDED_COMMUNITY:
BgpExtendedCommunity extendedCommunity = (BgpExtendedCommunity) attr;
extendedCommunity.write(cb);
break;
case WideCommunity.TYPE:
WideCommunity wideCommunity = (WideCommunity) attr;
wideCommunity.write(cb);
break;
case MpReachNlri.MPREACHNLRI_TYPE:
MpReachNlri mpReach = (MpReachNlri) attr;
mpReach.write(cb);
break;
case MpUnReachNlri.MPUNREACHNLRI_TYPE:
MpUnReachNlri mpUnReach = (MpUnReachNlri) attr;
mpUnReach.write(cb);
break;
case LINK_STATE_ATTRIBUTE_TYPE:
LinkStateAttributes linkState = (LinkStateAttributes) attr;
linkState.write(cb);
break;
default:
return cb.writerIndex() - iLenStartIndex;
}
}
int pathAttrLen = cb.writerIndex() - pathAttributeIndx;
cb.setShort(pathAttributeIndx, (short) (pathAttrLen - 2));
return cb.writerIndex() - iLenStartIndex;
}
Aggregations