本文整理汇总了Java中org.onosproject.bgpio.util.Validation.getFirstBit方法的典型用法代码示例。如果您正苦于以下问题:Java Validation.getFirstBit方法的具体用法?Java Validation.getFirstBit怎么用?Java Validation.getFirstBit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.onosproject.bgpio.util.Validation
的用法示例。
在下文中一共展示了Validation.getFirstBit方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: read
import org.onosproject.bgpio.util.Validation; //导入方法依赖的package包/类
/**
* Reads the channel buffer and returns object of Med.
*
* @param cb ChannelBuffer
* @return object of Med
* @throws BgpParseException while parsing Med path attribute
*/
public static Med read(ChannelBuffer cb) throws BgpParseException {
int med;
ChannelBuffer tempCb = cb.copy();
Validation parseFlags = Validation.parseAttributeHeader(cb);
if ((parseFlags.getLength() > MED_MAX_LEN) || cb.readableBytes() < parseFlags.getLength()) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
parseFlags.getLength());
}
int len = parseFlags.isShort() ? parseFlags.getLength() + Constants.TYPE_AND_LEN_AS_SHORT : parseFlags
.getLength() + Constants.TYPE_AND_LEN_AS_BYTE;
ChannelBuffer data = tempCb.readBytes(len);
if (!parseFlags.getFirstBit() && parseFlags.getSecondBit() && parseFlags.getThirdBit()) {
throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_FLAGS_ERROR, data);
}
med = cb.readInt();
return new Med(med);
}
示例2: read
import org.onosproject.bgpio.util.Validation; //导入方法依赖的package包/类
/**
* Reads the channel buffer and returns object of LocalPref.
*
* @param cb channelBuffer
* @return object of LocalPref
* @throws BgpParseException while parsing localPref attribute
*/
public static LocalPref read(ChannelBuffer cb) throws BgpParseException {
int localPref;
ChannelBuffer tempCb = cb.copy();
Validation parseFlags = Validation.parseAttributeHeader(cb);
if ((parseFlags.getLength() > LOCAL_PREF_MAX_LEN) || cb.readableBytes() < parseFlags.getLength()) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
parseFlags.getLength());
}
int len = parseFlags.isShort() ? parseFlags.getLength() +
Constants.TYPE_AND_LEN_AS_SHORT : parseFlags.getLength() + Constants.TYPE_AND_LEN_AS_BYTE;
ChannelBuffer data = tempCb.readBytes(len);
if (parseFlags.getFirstBit()) {
throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_FLAGS_ERROR, data);
}
localPref = cb.readInt();
return new LocalPref(localPref);
}
示例3: read
import org.onosproject.bgpio.util.Validation; //导入方法依赖的package包/类
/**
* Reads from ChannelBuffer and parses NextHop.
*
* @param cb ChannelBuffer
* @return object of NextHop
* @throws BgpParseException while parsing nexthop attribute
*/
public static NextHop read(ChannelBuffer cb) throws BgpParseException {
Ip4Address nextHop;
ChannelBuffer tempCb = cb.copy();
Validation parseFlags = Validation.parseAttributeHeader(cb);
if (cb.readableBytes() < parseFlags.getLength()) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
parseFlags.getLength());
}
int len = parseFlags.isShort() ? parseFlags.getLength() + Constants.TYPE_AND_LEN_AS_SHORT : parseFlags
.getLength() + Constants.TYPE_AND_LEN_AS_BYTE;
ChannelBuffer data = tempCb.readBytes(len);
if (parseFlags.getFirstBit() && !parseFlags.getSecondBit() && parseFlags.getThirdBit()) {
throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_FLAGS_ERROR, data);
}
InetAddress ipAddress = Validation.toInetAddress(parseFlags.getLength(), cb);
if (ipAddress.isMulticastAddress()) {
throw new BgpParseException("Multicast address is not supported");
}
nextHop = Ip4Address.valueOf(ipAddress);
return new NextHop(nextHop);
}
示例4: read
import org.onosproject.bgpio.util.Validation; //导入方法依赖的package包/类
/**
* Reads from ChannelBuffer and parses Origin.
*
* @param cb ChannelBuffer
* @return object of Origin
* @throws BgpParseException while parsing Origin path attribute
*/
public static Origin read(ChannelBuffer cb) throws BgpParseException {
ChannelBuffer tempCb = cb.copy();
Validation parseFlags = Validation.parseAttributeHeader(cb);
int len = parseFlags.isShort() ? parseFlags.getLength() + Constants.TYPE_AND_LEN_AS_SHORT : parseFlags
.getLength() + Constants.TYPE_AND_LEN_AS_BYTE;
ChannelBuffer data = tempCb.readBytes(len);
if ((parseFlags.getLength() > ORIGIN_VALUE_LEN) || (cb.readableBytes() < parseFlags.getLength())) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
parseFlags.getLength());
}
if (parseFlags.getFirstBit() && !parseFlags.getSecondBit() && parseFlags.getThirdBit()) {
throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_FLAGS_ERROR, data);
}
byte originValue;
originValue = cb.readByte();
if ((originValue != OriginType.INCOMPLETE.value) && (originValue != OriginType.IGP.value) &&
(originValue != OriginType.EGP.value)) {
throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.INVALID_ORIGIN_ATTRIBUTE, data);
}
return new Origin(originValue);
}
示例5: read
import org.onosproject.bgpio.util.Validation; //导入方法依赖的package包/类
/**
* Reads from the channel buffer and parses As4Path.
*
* @param cb ChannelBuffer
* @return object of As4Path
* @throws BgpParseException while parsing As4Path
*/
public static As4Path read(ChannelBuffer cb) throws BgpParseException {
List<Integer> as4pathSet = new ArrayList<>();
List<Integer> as4pathSeq = new ArrayList<>();
ChannelBuffer tempCb = cb.copy();
Validation validation = Validation.parseAttributeHeader(cb);
if (cb.readableBytes() < validation.getLength()) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
validation.getLength());
}
//if fourth bit is set length is read as short otherwise as byte , len includes type, length and value
int len = validation.isShort() ? validation.getLength() + Constants.TYPE_AND_LEN_AS_SHORT : validation
.getLength() + Constants.TYPE_AND_LEN_AS_BYTE;
ChannelBuffer data = tempCb.readBytes(len);
if (validation.getFirstBit() && !validation.getSecondBit() && validation.getThirdBit()) {
throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_FLAGS_ERROR, data);
}
ChannelBuffer tempBuf = cb.readBytes(validation.getLength());
while (tempBuf.readableBytes() > 0) {
byte pathSegType = tempBuf.readByte();
//no of ASes
byte pathSegLen = tempBuf.readByte();
//length = no of Ases * ASnum size (4 bytes)
int length = pathSegLen * ASNUM_SIZE;
if (tempBuf.readableBytes() < length) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.ATTRIBUTE_LENGTH_ERROR, length);
}
ChannelBuffer aspathBuf = tempBuf.readBytes(length);
while (aspathBuf.readableBytes() > 0) {
int asNum;
asNum = aspathBuf.readInt();
switch (pathSegType) {
case AsPath.ASPATH_SET_TYPE:
as4pathSet.add(asNum);
break;
case AsPath.ASPATH_SEQ_TYPE:
as4pathSeq.add(asNum);
break;
default: log.debug("Other type Not Supported:" + pathSegType);
}
}
}
return new As4Path(as4pathSet, as4pathSeq);
}
示例6: read
import org.onosproject.bgpio.util.Validation; //导入方法依赖的package包/类
/**
* Reads from the channel buffer and parses extended community.
*
* @param cb ChannelBuffer
* @return object of BgpExtendedCommunity
* @throws BgpParseException while parsing extended community
*/
public static BgpExtendedCommunity read(ChannelBuffer cb) throws BgpParseException {
ChannelBuffer tempCb = cb.copy();
Validation validation = Validation.parseAttributeHeader(cb);
List<BgpValueType> fsActionTlvs = new LinkedList<>();
if (cb.readableBytes() < validation.getLength()) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
validation.getLength());
}
//if fourth bit is set, length is read as short otherwise as byte , len includes type, length and value
int len = validation.isShort() ? validation.getLength() + Constants.TYPE_AND_LEN_AS_SHORT : validation
.getLength() + Constants.TYPE_AND_LEN_AS_BYTE;
ChannelBuffer data = tempCb.readBytes(len);
if (validation.getFirstBit() && !validation.getSecondBit() && validation.getThirdBit()) {
throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_FLAGS_ERROR, data);
}
ChannelBuffer tempBuf = cb.readBytes(validation.getLength());
if (tempBuf.readableBytes() > 0) {
BgpValueType fsActionTlv = null;
ChannelBuffer actionBuf = tempBuf.readBytes(validation.getLength());
while (actionBuf.readableBytes() > 0) {
short actionType = actionBuf.readShort();
switch (actionType) {
case Constants.BGP_FLOWSPEC_ACTION_TRAFFIC_ACTION:
fsActionTlv = BgpFsActionTrafficAction.read(actionBuf);
break;
case Constants.BGP_FLOWSPEC_ACTION_TRAFFIC_MARKING:
fsActionTlv = BgpFsActionTrafficMarking.read(actionBuf);
break;
case Constants.BGP_FLOWSPEC_ACTION_TRAFFIC_RATE:
fsActionTlv = BgpFsActionTrafficRate.read(actionBuf);
break;
case Constants.BGP_FLOWSPEC_ACTION_TRAFFIC_REDIRECT:
fsActionTlv = BgpFsActionReDirect.read(actionBuf);
break;
default: log.debug("Other type Not Supported:" + actionType);
break;
}
if (fsActionTlv != null) {
fsActionTlvs.add(fsActionTlv);
}
}
}
return new BgpExtendedCommunity(fsActionTlvs);
}
示例7: read
import org.onosproject.bgpio.util.Validation; //导入方法依赖的package包/类
/**
* Reads from the channel buffer and parses AsPath.
*
* @param cb ChannelBuffer
* @return object of AsPath
* @throws BgpParseException while parsing AsPath
*/
public static AsPath read(ChannelBuffer cb) throws BgpParseException {
List<Short> aspathSet = new ArrayList<>();
List<Short> aspathSeq = new ArrayList<>();
ChannelBuffer tempCb = cb.copy();
Validation validation = Validation.parseAttributeHeader(cb);
if (cb.readableBytes() < validation.getLength()) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
validation.getLength());
}
//if fourth bit is set, length is read as short otherwise as byte , len includes type, length and value
int len = validation.isShort() ? validation.getLength() + Constants.TYPE_AND_LEN_AS_SHORT : validation
.getLength() + Constants.TYPE_AND_LEN_AS_BYTE;
ChannelBuffer data = tempCb.readBytes(len);
if (validation.getFirstBit() && !validation.getSecondBit() && validation.getThirdBit()) {
throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_FLAGS_ERROR, data);
}
ChannelBuffer tempBuf = cb.readBytes(validation.getLength());
while (tempBuf.readableBytes() > 0) {
byte pathSegType = tempBuf.readByte();
//no of ASes
byte pathSegLen = tempBuf.readByte();
int length = pathSegLen * ASNUM_SIZE;
if (tempBuf.readableBytes() < length) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.ATTRIBUTE_LENGTH_ERROR, length);
}
ChannelBuffer aspathBuf = tempBuf.readBytes(length);
while (aspathBuf.readableBytes() > 0) {
short asNum;
asNum = aspathBuf.readShort();
switch (pathSegType) {
case ASPATH_SET_TYPE:
aspathSet.add(asNum);
break;
case ASPATH_SEQ_TYPE:
aspathSeq.add(asNum);
break;
default: log.debug("Other type Not Supported:" + pathSegType);
}
}
}
return new AsPath(aspathSet, aspathSeq);
}
示例8: read
import org.onosproject.bgpio.util.Validation; //导入方法依赖的package包/类
/**
* Reads from the channel buffer and parses extended community.
*
* @param cb ChannelBuffer
* @return object of BgpExtendedCommunity
* @throws BgpParseException while parsing extended community
*/
public static BgpExtendedCommunity read(ChannelBuffer cb) throws BgpParseException {
ChannelBuffer tempCb = cb.copy();
Validation validation = Validation.parseAttributeHeader(cb);
List<BgpValueType> fsActionTlvs = new LinkedList<>();
if (cb.readableBytes() < validation.getLength()) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
validation.getLength());
}
//if fourth bit is set, length is read as short otherwise as byte , len includes type, length and value
int len = validation.isShort() ? validation.getLength() + Constants.TYPE_AND_LEN_AS_SHORT : validation
.getLength() + Constants.TYPE_AND_LEN_AS_BYTE;
ChannelBuffer data = tempCb.readBytes(len);
if (validation.getFirstBit() && !validation.getSecondBit() && validation.getThirdBit()) {
throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_FLAGS_ERROR, data);
}
ChannelBuffer tempBuf = cb.readBytes(validation.getLength());
if (tempBuf.readableBytes() > 0) {
BgpValueType fsActionTlv = null;
ChannelBuffer actionBuf = tempBuf.readBytes(validation.getLength());
while (actionBuf.readableBytes() > 0) {
short actionType = actionBuf.readShort();
switch (actionType) {
case Constants.BGP_ROUTE_TARGET_AS:
case Constants.BGP_ROUTE_TARGET_IP:
case Constants.BGP_ROUTE_TARGET_LARGEAS:
fsActionTlv = RouteTarget.read(actionType, actionBuf);
break;
case Constants.BGP_FLOWSPEC_ACTION_TRAFFIC_ACTION:
fsActionTlv = BgpFsActionTrafficAction.read(actionBuf);
break;
case Constants.BGP_FLOWSPEC_ACTION_TRAFFIC_MARKING:
fsActionTlv = BgpFsActionTrafficMarking.read(actionBuf);
break;
case Constants.BGP_FLOWSPEC_ACTION_TRAFFIC_RATE:
fsActionTlv = BgpFsActionTrafficRate.read(actionBuf);
break;
case Constants.BGP_FLOWSPEC_ACTION_TRAFFIC_REDIRECT:
fsActionTlv = BgpFsActionReDirect.read(actionBuf);
break;
default:
log.debug("Other type Not Supported:" + actionType);
break;
}
if (fsActionTlv != null) {
fsActionTlvs.add(fsActionTlv);
}
}
}
return new BgpExtendedCommunity(fsActionTlvs);
}