本文整理汇总了Java中org.onosproject.bgpio.types.MpReachNlri.read方法的典型用法代码示例。如果您正苦于以下问题:Java MpReachNlri.read方法的具体用法?Java MpReachNlri.read怎么用?Java MpReachNlri.read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.onosproject.bgpio.types.MpReachNlri
的用法示例。
在下文中一共展示了MpReachNlri.read方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: read
import org.onosproject.bgpio.types.MpReachNlri; //导入方法依赖的package包/类
/**
* Reads from channelBuffer and parses BGP path attributes.
*
* @param cb channelBuffer
* @return object of BgpPathAttributes
* @throws BgpParseException while parsing BGP path attributes
*/
public static BgpPathAttributes read(ChannelBuffer cb)
throws BgpParseException {
BgpValueType pathAttribute = null;
List<BgpValueType> pathAttributeList = new LinkedList<>();
boolean isOrigin = false;
boolean isAsPath = false;
boolean isNextHop = false;
boolean isMpReach = false;
boolean isMpUnReach = false;
while (cb.readableBytes() > 0) {
cb.markReaderIndex();
byte flags = cb.readByte();
byte typeCode = cb.readByte();
cb.resetReaderIndex();
switch (typeCode) {
case Origin.ORIGIN_TYPE:
pathAttribute = Origin.read(cb);
isOrigin = ((Origin) pathAttribute).isOriginSet();
break;
case AsPath.ASPATH_TYPE:
pathAttribute = AsPath.read(cb);
isAsPath = ((AsPath) pathAttribute).isaspathSet();
break;
case As4Path.AS4PATH_TYPE:
pathAttribute = As4Path.read(cb);
break;
case NextHop.NEXTHOP_TYPE:
pathAttribute = NextHop.read(cb);
isNextHop = ((NextHop) pathAttribute).isNextHopSet();
break;
case Med.MED_TYPE:
pathAttribute = Med.read(cb);
break;
case LocalPref.LOCAL_PREF_TYPE:
pathAttribute = LocalPref.read(cb);
break;
case MpReachNlri.MPREACHNLRI_TYPE:
pathAttribute = MpReachNlri.read(cb);
isMpReach = ((MpReachNlri) pathAttribute).isMpReachNlriSet();
break;
case MpUnReachNlri.MPUNREACHNLRI_TYPE:
pathAttribute = MpUnReachNlri.read(cb);
isMpUnReach = ((MpUnReachNlri) pathAttribute)
.isMpUnReachNlriSet();
break;
case LINK_STATE_ATTRIBUTE_TYPE:
pathAttribute = LinkStateAttributes.read(cb);
break;
case EXTENDED_COMMUNITY_TYPE:
pathAttribute = BgpExtendedCommunity.read(cb);
break;
case WideCommunity.TYPE:
pathAttribute = WideCommunity.read(cb);
break;
default:
//skip bytes for unsupported attribute types
UnSupportedAttribute.read(cb);
}
pathAttributeList.add(pathAttribute);
}
checkMandatoryAttr(isOrigin, isAsPath, isNextHop, isMpReach, isMpUnReach);
//TODO:if mp_reach or mp_unreach not present ignore the packet
return new BgpPathAttributes(pathAttributeList);
}
示例2: read
import org.onosproject.bgpio.types.MpReachNlri; //导入方法依赖的package包/类
/**
* Reads from channelBuffer and parses BGP path attributes.
*
* @param cb channelBuffer
* @return object of BgpPathAttributes
* @throws BgpParseException while parsing BGP path attributes
*/
public static BgpPathAttributes read(ChannelBuffer cb)
throws BgpParseException {
BgpValueType pathAttribute = null;
List<BgpValueType> pathAttributeList = new LinkedList<>();
boolean isOrigin = false;
boolean isAsPath = false;
boolean isNextHop = false;
boolean isMpReach = false;
boolean isMpUnReach = false;
while (cb.readableBytes() > 0) {
cb.markReaderIndex();
byte flags = cb.readByte();
byte typeCode = cb.readByte();
cb.resetReaderIndex();
switch (typeCode) {
case Origin.ORIGIN_TYPE:
pathAttribute = Origin.read(cb);
isOrigin = ((Origin) pathAttribute).isOriginSet();
break;
case AsPath.ASPATH_TYPE:
pathAttribute = AsPath.read(cb);
isAsPath = ((AsPath) pathAttribute).isaspathSet();
break;
case As4Path.AS4PATH_TYPE:
pathAttribute = As4Path.read(cb);
break;
case NextHop.NEXTHOP_TYPE:
pathAttribute = NextHop.read(cb);
isNextHop = ((NextHop) pathAttribute).isNextHopSet();
break;
case Med.MED_TYPE:
pathAttribute = Med.read(cb);
break;
case LocalPref.LOCAL_PREF_TYPE:
pathAttribute = LocalPref.read(cb);
break;
case MpReachNlri.MPREACHNLRI_TYPE:
pathAttribute = MpReachNlri.read(cb);
isMpReach = ((MpReachNlri) pathAttribute).isMpReachNlriSet();
break;
case MpUnReachNlri.MPUNREACHNLRI_TYPE:
pathAttribute = MpUnReachNlri.read(cb);
isMpUnReach = ((MpUnReachNlri) pathAttribute)
.isMpUnReachNlriSet();
break;
case LINK_STATE_ATTRIBUTE_TYPE:
pathAttribute = LinkStateAttributes.read(cb);
break;
case EXTENDED_COMMUNITY_TYPE:
pathAttribute = BgpExtendedCommunity.read(cb);
break;
case WideCommunity.TYPE:
pathAttribute = WideCommunity.read(cb);
break;
default:
log.debug("Skip bytes for unsupported attribute types");
UnSupportedAttribute.read(cb);
}
pathAttributeList.add(pathAttribute);
}
checkMandatoryAttr(isOrigin, isAsPath, isNextHop, isMpReach, isMpUnReach);
//TODO:if mp_reach or mp_unreach not present ignore the packet
return new BgpPathAttributes(pathAttributeList);
}