本文整理汇总了Java中org.onosproject.bgpio.util.Validation.validateLen方法的典型用法代码示例。如果您正苦于以下问题:Java Validation.validateLen方法的具体用法?Java Validation.validateLen怎么用?Java Validation.validateLen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.onosproject.bgpio.util.Validation
的用法示例。
在下文中一共展示了Validation.validateLen方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: read
import org.onosproject.bgpio.util.Validation; //导入方法依赖的package包/类
/**
* Reads the Multi-topology ID of Node attribute.
*
* @param cb ChannelBuffer
* @return Constructor of BgpAttrNodeMultiTopologyId
* @throws BgpParseException while parsing BgpAttrNodeMultiTopologyId
*/
public static BgpAttrNodeMultiTopologyId read(ChannelBuffer cb)
throws BgpParseException {
ArrayList<Short> multiTopologyId = new ArrayList<Short>();
short tempMultiTopologyId;
short lsAttrLength = cb.readShort();
int len = lsAttrLength / 2; // Length is 2*n and n is the number of MT-IDs
if (cb.readableBytes() < lsAttrLength) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
for (int i = 0; i < len; i++) {
tempMultiTopologyId = cb.readShort();
multiTopologyId.add(new Short(tempMultiTopologyId));
}
return new BgpAttrNodeMultiTopologyId(multiTopologyId);
}
示例2: 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);
}
示例3: read
import org.onosproject.bgpio.util.Validation; //导入方法依赖的package包/类
/**
* Reads the BGP link attributes Opaque link attribute.
*
* @param cb Channel buffer
* @return object of type BgpLinkAttrOpaqLnkAttrib
* @throws BgpParseException while parsing BgpLinkAttrOpaqLnkAttrib
*/
public static BgpLinkAttrOpaqLnkAttrib read(ChannelBuffer cb)
throws BgpParseException {
byte[] opaqueLinkAttribute;
short lsAttrLength = cb.readShort();
if (cb.readableBytes() < lsAttrLength) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
opaqueLinkAttribute = new byte[lsAttrLength];
cb.readBytes(opaqueLinkAttribute);
return BgpLinkAttrOpaqLnkAttrib.of(opaqueLinkAttribute);
}
示例4: read
import org.onosproject.bgpio.util.Validation; //导入方法依赖的package包/类
/**
* Reads the Opaque Prefix Attribute.
*
* @param cb ChannelBuffer
* @return object of BgpPrefixAttrOpaqueData
* @throws BgpParseException while parsing BgpPrefixAttrOpaqueData
*/
public static BgpPrefixAttrOpaqueData read(ChannelBuffer cb)
throws BgpParseException {
byte[] opaquePrefixAttribute;
short lsAttrLength = cb.readShort();
opaquePrefixAttribute = new byte[lsAttrLength];
if (cb.readableBytes() < lsAttrLength) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
cb.readBytes(opaquePrefixAttribute);
return BgpPrefixAttrOpaqueData.of(opaquePrefixAttribute);
}
示例5: 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);
}
示例6: read
import org.onosproject.bgpio.util.Validation; //导入方法依赖的package包/类
/**
* Reads the BGP link attributes MPLS protocol mask.
*
* @param cb Channel buffer
* @return object of type BgpLinkAttrMPLSProtocolMask
* @throws BgpParseException while parsing BgpLinkAttrMplsProtocolMask
*/
public static BgpLinkAttrMplsProtocolMask read(ChannelBuffer cb)
throws BgpParseException {
boolean bLdp = false;
boolean bRsvpTe = false;
short lsAttrLength = cb.readShort();
if ((lsAttrLength != MASK_BYTE_LEN)
|| (cb.readableBytes() < lsAttrLength)) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
byte flags = cb.readByte();
bLdp = ((flags & (byte) FIRST_BIT) == FIRST_BIT);
bRsvpTe = ((flags & (byte) SECOND_BIT) == SECOND_BIT);
return BgpLinkAttrMplsProtocolMask.of(bLdp, bRsvpTe);
}
示例7: 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);
}
示例8: read
import org.onosproject.bgpio.util.Validation; //导入方法依赖的package包/类
/**
* Reads the BGP link attributes of Maximum link bandwidth.
*
* @param cb Channel buffer
* @param sType returns the tag value
* @return object of type BgpLinkAttrMaxLinkBandwidth
* @throws BgpParseException while parsing BgpLinkAttrMaxLinkBandwidth
*/
public static BgpLinkAttrUnRsrvdLinkBandwidth read(ChannelBuffer cb,
short sType)
throws BgpParseException {
ArrayList<Float> maxUnResBandwidth = new ArrayList<Float>();
float tmp;
short lsAttrLength = cb.readShort();
if ((lsAttrLength != MAX_BANDWIDTH_LEN * NO_OF_PRIORITY)
|| (cb.readableBytes() < lsAttrLength)) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
for (int i = 0; i < NO_OF_PRIORITY; i++) {
tmp = ieeeToFloatRead(cb.readInt()) * NO_OF_BITS;
maxUnResBandwidth.add(new Float(tmp));
}
return BgpLinkAttrUnRsrvdLinkBandwidth.of(maxUnResBandwidth, sType);
}
示例9: read
import org.onosproject.bgpio.util.Validation; //导入方法依赖的package包/类
/**
* Reads the BGP link attributes Shared Risk link group data.
*
* @param cb Channel buffer
* @return object of type BgpLinkAttrSrlg
* @throws BgpParseException while parsing BgpLinkAttrSrlg
*/
public static BgpLinkAttrSrlg read(ChannelBuffer cb)
throws BgpParseException {
int tempSrlg;
ArrayList<Integer> sRlg = new ArrayList<Integer>();
short lsAttrLength = cb.readShort();
int len = lsAttrLength / SIZE; // each element is of 4 octets
if (cb.readableBytes() < lsAttrLength) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
for (int i = 0; i < len; i++) {
tempSrlg = cb.readInt();
sRlg.add(new Integer(tempSrlg));
}
return BgpLinkAttrSrlg.of(sRlg);
}
示例10: read
import org.onosproject.bgpio.util.Validation; //导入方法依赖的package包/类
/**
* Reads the Route Tag.
*
* @param cb ChannelBuffer
* @return object of BgpPrefixAttrRouteTag
* @throws BgpParseException while parsing BgpPrefixAttrRouteTag
*/
public static BgpPrefixAttrRouteTag read(ChannelBuffer cb)
throws BgpParseException {
int tmp;
ArrayList<Integer> pfxRouteTag = new ArrayList<Integer>();
short lsAttrLength = cb.readShort();
int len = lsAttrLength / SIZE;
if (cb.readableBytes() < lsAttrLength) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
for (int i = 0; i < len; i++) {
tmp = cb.readInt();
pfxRouteTag.add(new Integer(tmp));
}
return BgpPrefixAttrRouteTag.of(pfxRouteTag);
}
示例11: read
import org.onosproject.bgpio.util.Validation; //导入方法依赖的package包/类
/**
* Reads the BGP link attributes of TE default metric.
*
* @param cb Channel buffer
* @return object of type BgpLinkAttrTeDefaultMetric
* @throws BgpParseException while parsing BgpLinkAttrTeDefaultMetric
*/
public static BgpLinkAttrTeDefaultMetric read(ChannelBuffer cb)
throws BgpParseException {
int linkTeMetric;
short lsAttrLength = cb.readShort();
if ((lsAttrLength != TE_DATA_LEN)
|| (cb.readableBytes() < lsAttrLength)) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
linkTeMetric = cb.readInt();
return new BgpLinkAttrTeDefaultMetric(linkTeMetric);
}
示例12: read
import org.onosproject.bgpio.util.Validation; //导入方法依赖的package包/类
/**
* Reads the BGP link attributes Name.
*
* @param cb Channel buffer
* @return object of type BgpLinkAttrName
* @throws BgpParseException while parsing BgpLinkAttrName
*/
public static BgpLinkAttrName read(ChannelBuffer cb)
throws BgpParseException {
byte[] linkName;
short lsAttrLength = cb.readShort();
if (cb.readableBytes() < lsAttrLength) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
linkName = new byte[lsAttrLength];
cb.readBytes(linkName);
return BgpLinkAttrName.of(linkName);
}
示例13: read
import org.onosproject.bgpio.util.Validation; //导入方法依赖的package包/类
/**
* Reads the Prefix Metric.
*
* @param cb ChannelBuffer
* @return object of BgpPrefixAttrMetric
* @throws BgpParseException while parsing BgpPrefixAttrMetric
*/
public static BgpPrefixAttrMetric read(ChannelBuffer cb)
throws BgpParseException {
int linkPfxMetric;
short lsAttrLength = cb.readShort(); // 4 Bytes
if ((lsAttrLength != ATTR_PREFIX_LEN)
|| (cb.readableBytes() < lsAttrLength)) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
linkPfxMetric = cb.readInt();
return BgpPrefixAttrMetric.of(linkPfxMetric);
}
示例14: read
import org.onosproject.bgpio.util.Validation; //导入方法依赖的package包/类
/**
* Reads the IPv4 Router-ID.
*
* @param cb ChannelBuffer
* @param sType tag type
* @return object of BgpAttrRouterIdV4
* @throws BgpParseException while parsing BgpAttrRouterIdV4
*/
public static BgpAttrRouterIdV4 read(ChannelBuffer cb, short sType)
throws BgpParseException {
short lsAttrLength = cb.readShort();
if ((lsAttrLength != 4) || (cb.readableBytes() < lsAttrLength)) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
byte[] ipBytes = new byte[lsAttrLength];
cb.readBytes(ipBytes, 0, lsAttrLength);
Ip4Address ip4RouterId = Ip4Address.valueOf(ipBytes);
return BgpAttrRouterIdV4.of(ip4RouterId, sType);
}
示例15: read
import org.onosproject.bgpio.util.Validation; //导入方法依赖的package包/类
/**
* Reads the BGP link attributes of ISIS administrative group area.
*
* @param cb Channel buffer
* @return object of type BgpLinkAttrIsIsAdminstGrp
* @throws BgpParseException while parsing BgpLinkAttrIsIsAdminstGrp
*/
public static BgpLinkAttrIsIsAdminstGrp read(ChannelBuffer cb)
throws BgpParseException {
long isisAdminGrp;
short lsAttrLength = cb.readShort();
if ((lsAttrLength != ISIS_ADMIN_DATA_LEN)
|| (cb.readableBytes() < lsAttrLength)) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
isisAdminGrp = cb.readUnsignedInt();
return BgpLinkAttrIsIsAdminstGrp.of(isisAdminGrp);
}