本文整理汇总了Java中org.onosproject.bgpio.util.Validation类的典型用法代码示例。如果您正苦于以下问题:Java Validation类的具体用法?Java Validation怎么用?Java Validation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Validation类属于org.onosproject.bgpio.util包,在下文中一共展示了Validation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 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);
}
示例5: read
import org.onosproject.bgpio.util.Validation; //导入依赖的package包/类
/**
* Reads the Opaque Node Properties.
*
* @param cb ChannelBuffer
* @return object of BgpAttrOpaqueNode
* @throws BgpParseException while parsing BgpAttrOpaqueNode
*/
public static BgpAttrOpaqueNode read(ChannelBuffer cb)
throws BgpParseException {
byte[] opaqueNodeAttribute;
short lsAttrLength = cb.readShort();
if (cb.readableBytes() < lsAttrLength) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
opaqueNodeAttribute = new byte[lsAttrLength];
cb.readBytes(opaqueNodeAttribute);
return BgpAttrOpaqueNode.of(opaqueNodeAttribute);
}
示例6: 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);
}
示例7: 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);
}
示例8: read
import org.onosproject.bgpio.util.Validation; //导入依赖的package包/类
/**
* Reads the IS-IS Area Identifier.
*
* @param cb ChannelBuffer
* @return object of BgpAttrNodeIsIsAreaId
* @throws BgpParseException while parsing BgpAttrNodeIsIsAreaId
*/
public static BgpAttrNodeIsIsAreaId read(ChannelBuffer cb)
throws BgpParseException {
byte[] isisAreaId;
short lsAttrLength = cb.readShort();
if (cb.readableBytes() < lsAttrLength) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
isisAreaId = new byte[lsAttrLength];
cb.readBytes(isisAreaId);
return BgpAttrNodeIsIsAreaId.of(isisAreaId);
}
示例9: 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);
}
示例10: read
import org.onosproject.bgpio.util.Validation; //导入依赖的package包/类
/**
* Reads the Node Flag Bits.
*
* @param cb ChannelBuffer
* @return attribute node flag bit tlv
* @throws BgpParseException while parsing BgpAttrNodeFlagBitTlv
*/
public static BgpAttrNodeFlagBitTlv read(ChannelBuffer cb)
throws BgpParseException {
boolean bOverloadBit = false;
boolean bAttachedBit = false;
boolean bExternalBit = false;
boolean bAbrBit = false;
short lsAttrLength = cb.readShort();
if ((lsAttrLength != 1) || (cb.readableBytes() < lsAttrLength)) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
byte nodeFlagBits = cb.readByte();
bOverloadBit = ((nodeFlagBits & FIRST_BIT) == FIRST_BIT);
bAttachedBit = ((nodeFlagBits & SECOND_BIT) == SECOND_BIT);
bExternalBit = ((nodeFlagBits & THIRD_BIT) == THIRD_BIT);
bAbrBit = ((nodeFlagBits & FOURTH_BIT) == FOURTH_BIT);
return BgpAttrNodeFlagBitTlv.of(bOverloadBit, bAttachedBit,
bExternalBit, bAbrBit);
}
示例11: read
import org.onosproject.bgpio.util.Validation; //导入依赖的package包/类
/**
* Reads the IPv6 Router-ID.
*
* @param cb ChannelBuffer
* @param sType TLV type
* @return object of BgpAttrRouterIdV6
* @throws BgpParseException while parsing BgpAttrRouterIdV6
*/
public static BgpAttrRouterIdV6 read(ChannelBuffer cb, short sType)
throws BgpParseException {
byte[] ipBytes;
Ip6Address ip6RouterId;
short lsAttrLength = cb.readShort();
if ((lsAttrLength != 16) || (cb.readableBytes() < lsAttrLength)) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
ipBytes = new byte[lsAttrLength];
cb.readBytes(ipBytes);
ip6RouterId = Ip6Address.valueOf(ipBytes);
return BgpAttrRouterIdV6.of(ip6RouterId, sType);
}
示例12: 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);
}
示例13: 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);
}
示例14: read
import org.onosproject.bgpio.util.Validation; //导入依赖的package包/类
/**
* Reads the LS attribute node name.
*
* @param cb ChannelBuffer
* @return object of BgpAttrNodeName
* @throws BgpParseException while parsing BgpAttrNodeName
*/
public static BgpAttrNodeName read(ChannelBuffer cb)
throws BgpParseException {
byte[] nodeName;
short lsAttrLength = cb.readShort();
if (cb.readableBytes() < lsAttrLength) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
nodeName = new byte[lsAttrLength];
cb.readBytes(nodeName);
return BgpAttrNodeName.of(nodeName);
}
示例15: 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);
}