本文整理汇总了Java中org.onosproject.bgpio.util.UnSupportedAttribute.skipBytes方法的典型用法代码示例。如果您正苦于以下问题:Java UnSupportedAttribute.skipBytes方法的具体用法?Java UnSupportedAttribute.skipBytes怎么用?Java UnSupportedAttribute.skipBytes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.onosproject.bgpio.util.UnSupportedAttribute
的用法示例。
在下文中一共展示了UnSupportedAttribute.skipBytes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: read
import org.onosproject.bgpio.util.UnSupportedAttribute; //导入方法依赖的package包/类
/**
* Reads node descriptors Sub-TLVs.
*
* @param cb ChannelBuffer
* @param desLength node descriptor length
* @param desType local node descriptor or remote node descriptor type
* @param protocolId protocol ID
* @return object of NodeDescriptors
* @throws BgpParseException while parsing node descriptors
*/
public static NodeDescriptors read(ChannelBuffer cb, short desLength, short desType, byte protocolId)
throws BgpParseException {
log.debug("Read NodeDescriptor");
List<BgpValueType> subTlvs = new LinkedList<>();
BgpValueType tlv = null;
while (cb.readableBytes() > 0) {
ChannelBuffer tempBuf = cb.copy();
short type = cb.readShort();
short length = cb.readShort();
if (cb.readableBytes() < length) {
throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR,
tempBuf.readBytes(cb.readableBytes() + TYPE_AND_LEN));
}
ChannelBuffer tempCb = cb.readBytes(length);
switch (type) {
case AutonomousSystemTlv.TYPE:
tlv = AutonomousSystemTlv.read(tempCb);
break;
case BgpLSIdentifierTlv.TYPE:
tlv = BgpLSIdentifierTlv.read(tempCb);
break;
case AreaIDTlv.TYPE:
tlv = AreaIDTlv.read(tempCb);
break;
case IGP_ROUTERID_TYPE:
if (protocolId == IS_IS_LEVEL_1_PROTOCOL_ID || protocolId == IS_IS_LEVEL_2_PROTOCOL_ID) {
boolean isNonPseudoNode = true;
if ((length == ISISPSEUDONODE_LEN) && (tempCb.getByte(ISISPSEUDONODE_LEN - 1) != 0)) {
isNonPseudoNode = false;
}
if (isNonPseudoNode) {
tlv = IsIsNonPseudonode.read(tempCb);
} else {
tlv = IsIsPseudonode.read(tempCb);
}
} else if (protocolId == OSPF_V2_PROTOCOL_ID || protocolId == OSPF_V3_PROTOCOL_ID) {
if (length == OSPFNONPSEUDONODE_LEN) {
tlv = OspfNonPseudonode.read(tempCb);
} else if (length == OSPFPSEUDONODE_LEN) {
tlv = OspfPseudonode.read(tempCb);
}
}
break;
default:
UnSupportedAttribute.skipBytes(tempCb, length);
}
subTlvs.add(tlv);
}
return new NodeDescriptors(subTlvs, desLength, desType);
}
示例2: parseLinkDescriptors
import org.onosproject.bgpio.util.UnSupportedAttribute; //导入方法依赖的package包/类
/**
* Parses link descriptors.
*
* @param cb ChannelBuffer
* @return list of link descriptors
* @throws BgpParseException while parsing link descriptors
*/
public static LinkedList<BgpValueType> parseLinkDescriptors(ChannelBuffer cb) throws BgpParseException {
LinkedList<BgpValueType> linkDescriptor = new LinkedList<>();
BgpValueType tlv = null;
int count = 0;
while (cb.readableBytes() > 0) {
ChannelBuffer tempBuf = cb.copy();
short type = cb.readShort();
short length = cb.readShort();
if (cb.readableBytes() < length) {
throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR,
tempBuf.readBytes(cb.readableBytes() + Constants.TYPE_AND_LEN_AS_SHORT));
}
ChannelBuffer tempCb = cb.readBytes(length);
switch (type) {
case LinkLocalRemoteIdentifiersTlv.TYPE:
tlv = LinkLocalRemoteIdentifiersTlv.read(tempCb);
break;
case IPV4_INTERFACE_ADDRESS_TYPE:
tlv = IPv4AddressTlv.read(tempCb, IPV4_INTERFACE_ADDRESS_TYPE);
break;
case IPV4_NEIGHBOR_ADDRESS_TYPE:
tlv = IPv4AddressTlv.read(tempCb, IPV4_NEIGHBOR_ADDRESS_TYPE);
break;
case IPV6_INTERFACE_ADDRESS_TYPE:
tlv = IPv6AddressTlv.read(tempCb, IPV6_INTERFACE_ADDRESS_TYPE);
break;
case IPV6_NEIGHBOR_ADDRESS_TYPE:
tlv = IPv6AddressTlv.read(tempCb, IPV6_NEIGHBOR_ADDRESS_TYPE);
break;
case BgpAttrNodeMultiTopologyId.ATTRNODE_MULTITOPOLOGY:
tlv = BgpAttrNodeMultiTopologyId.read(tempCb);
count = count++;
//MultiTopologyId TLV cannot repeat more than once
if (count > 1) {
//length + 4 implies data contains type, length and value
throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR, tempBuf.readBytes(length
+ Constants.TYPE_AND_LEN_AS_SHORT));
}
break;
default:
UnSupportedAttribute.skipBytes(tempCb, length);
}
linkDescriptor.add(tlv);
}
return linkDescriptor;
}
示例3: parsePrefixDescriptors
import org.onosproject.bgpio.util.UnSupportedAttribute; //导入方法依赖的package包/类
/**
* Parse list of prefix descriptors.
*
* @param cb ChannelBuffer
* @return list of prefix descriptors
* @throws BgpParseException while parsing list of prefix descriptors
*/
public static List<BgpValueType> parsePrefixDescriptors(ChannelBuffer cb) throws BgpParseException {
LinkedList<BgpValueType> prefixDescriptor = new LinkedList<>();
BgpValueType tlv = null;
boolean isIpReachInfo = false;
ChannelBuffer tempCb;
int count = 0;
while (cb.readableBytes() > 0) {
ChannelBuffer tempBuf = cb.copy();
short type = cb.readShort();
short length = cb.readShort();
if (cb.readableBytes() < length) {
//length + 4 implies data contains type, length and value
throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR,
tempBuf.readBytes(cb.readableBytes() + TYPE_AND_LEN));
}
tempCb = cb.readBytes(length);
switch (type) {
case OspfRouteTypeTlv.TYPE:
tlv = OspfRouteTypeTlv.read(tempCb);
break;
case IPReachabilityInformationTlv.TYPE:
tlv = IPReachabilityInformationTlv.read(tempCb, length);
isIpReachInfo = true;
break;
case BgpAttrNodeMultiTopologyId.ATTRNODE_MULTITOPOLOGY:
tlv = BgpAttrNodeMultiTopologyId.read(tempCb);
count = count + 1;
if (count > 1) {
//length + 4 implies data contains type, length and value
throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR, tempBuf.readBytes(length + TYPE_AND_LEN));
}
break;
default:
UnSupportedAttribute.skipBytes(tempCb, length);
}
prefixDescriptor.add(tlv);
}
if (!isIpReachInfo) {
throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR,
null);
}
return prefixDescriptor;
}
示例4: parseLinkDescriptors
import org.onosproject.bgpio.util.UnSupportedAttribute; //导入方法依赖的package包/类
/**
* Parses link descriptors.
*
* @param cb ChannelBuffer
* @return list of link descriptors
* @throws BgpParseException while parsing link descriptors
*/
public static LinkedList<BgpValueType> parseLinkDescriptors(ChannelBuffer cb) throws BgpParseException {
LinkedList<BgpValueType> linkDescriptor = new LinkedList<>();
BgpValueType tlv = null;
int count = 0;
while (cb.readableBytes() > 0) {
ChannelBuffer tempBuf = cb.copy();
short type = cb.readShort();
short length = cb.readShort();
if (cb.readableBytes() < length) {
throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR,
tempBuf.readBytes(cb.readableBytes() + Constants.TYPE_AND_LEN_AS_SHORT));
}
ChannelBuffer tempCb = cb.readBytes(length);
switch (type) {
case LinkLocalRemoteIdentifiersTlv.TYPE:
tlv = LinkLocalRemoteIdentifiersTlv.read(tempCb);
break;
case IPV4_INTERFACE_ADDRESS_TYPE:
tlv = IPv4AddressTlv.read(tempCb, IPV4_INTERFACE_ADDRESS_TYPE);
break;
case IPV4_NEIGHBOR_ADDRESS_TYPE:
tlv = IPv4AddressTlv.read(tempCb, IPV4_NEIGHBOR_ADDRESS_TYPE);
break;
case IPV6_INTERFACE_ADDRESS_TYPE:
tlv = IPv6AddressTlv.read(tempCb, IPV6_INTERFACE_ADDRESS_TYPE);
break;
case IPV6_NEIGHBOR_ADDRESS_TYPE:
tlv = IPv6AddressTlv.read(tempCb, IPV6_NEIGHBOR_ADDRESS_TYPE);
break;
case BgpAttrNodeMultiTopologyId.ATTRNODE_MULTITOPOLOGY:
tlv = BgpAttrNodeMultiTopologyId.read(tempCb);
count++;
log.debug("MultiTopologyId TLV cannot repeat more than once");
if (count > 1) {
//length + 4 implies data contains type, length and value
throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR, tempBuf.readBytes(length
+ Constants.TYPE_AND_LEN_AS_SHORT));
}
break;
default:
UnSupportedAttribute.skipBytes(tempCb, length);
}
linkDescriptor.add(tlv);
}
return linkDescriptor;
}