本文整理匯總了Java中org.jboss.netty.buffer.ChannelBuffer.readShort方法的典型用法代碼示例。如果您正苦於以下問題:Java ChannelBuffer.readShort方法的具體用法?Java ChannelBuffer.readShort怎麽用?Java ChannelBuffer.readShort使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jboss.netty.buffer.ChannelBuffer
的用法示例。
在下文中一共展示了ChannelBuffer.readShort方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parseErrSpecSubObj
import org.jboss.netty.buffer.ChannelBuffer; //導入方法依賴的package包/類
private static LinkedList<PcepValueType> parseErrSpecSubObj(ChannelBuffer cb) throws PcepParseException {
LinkedList<PcepValueType> llRsvpUserSpecSubObj = new LinkedList<>();
while (0 < cb.readableBytes()) {
PcepValueType tlv = null;
short hType = cb.readShort();
int iValue = 0;
//short hLength = cb.readShort();
switch (hType) {
case AutonomousSystemSubTlv.TYPE:
iValue = cb.readInt();
tlv = new AutonomousSystemSubTlv(iValue);
break;
default:
throw new PcepParseException("Unsupported Sub TLV type :" + hType);
}
llRsvpUserSpecSubObj.add(tlv);
}
return llRsvpUserSpecSubObj;
}
示例2: read
import org.jboss.netty.buffer.ChannelBuffer; //導入方法依賴的package包/類
/**
* Reads the Extended Tag.
*
* @param cb ChannelBuffer
* @return object of BgpPrefixAttrExtRouteTag
* @throws BgpParseException while parsing BgpPrefixAttrExtRouteTag
*/
public static BgpPrefixAttrExtRouteTag read(ChannelBuffer cb)
throws BgpParseException {
ArrayList<Long> pfxExtRouteTag = new ArrayList<Long>();
long temp;
short lsAttrLength = cb.readShort();
int len = lsAttrLength / ATTR_PREFIX_EXT_LEN;
if (cb.readableBytes() < lsAttrLength) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
for (int i = 0; i < len; i++) {
temp = cb.readLong();
pfxExtRouteTag.add(new Long(temp));
}
return new BgpPrefixAttrExtRouteTag(pfxExtRouteTag);
}
示例3: read
import org.jboss.netty.buffer.ChannelBuffer; //導入方法依賴的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);
}
示例4: read
import org.jboss.netty.buffer.ChannelBuffer; //導入方法依賴的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.jboss.netty.buffer.ChannelBuffer; //導入方法依賴的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);
}
示例6: readValue
import org.jboss.netty.buffer.ChannelBuffer; //導入方法依賴的package包/類
private long readValue(ChannelBuffer buf, int length, boolean signed) {
switch (length) {
case 1:
return signed ? buf.readByte() : buf.readUnsignedByte();
case 2:
return signed ? buf.readShort() : buf.readUnsignedShort();
case 4:
return signed ? buf.readInt() : buf.readUnsignedInt();
default:
return buf.readLong();
}
}
示例7: read
import org.jboss.netty.buffer.ChannelBuffer; //導入方法依賴的package包/類
/**
* Reads the channel buffer and returns object of WideCommunityIpV4Neighbour.
*
* @param c ChannelBuffer
* @return object of WideCommunityIpV4Neighbour
* @throws BgpParseException on read error
*/
public static WideCommunityIpV4Neighbour read(ChannelBuffer c) throws BgpParseException {
WideCommunityIpV4Neighbour wideCommNeighbour = new WideCommunityIpV4Neighbour();
short length;
if (c.readableBytes() == 0) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
c.readableBytes());
}
length = c.readShort();
if (c.readableBytes() == 0) {
return wideCommNeighbour;
}
if (c.readableBytes() < length) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
c.readableBytes());
}
while (c.readableBytes() > 0) {
if (c.readableBytes() < IPV4_NEIGHBOUR_SIZE) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
c.readableBytes());
}
IpAddress localSpeaker = IpAddress.valueOf(c.readInt());
IpAddress remoteSpeaker = IpAddress.valueOf(c.readInt());
wideCommNeighbour.add(localSpeaker, remoteSpeaker);
}
return wideCommNeighbour;
}
示例8: read
import org.jboss.netty.buffer.ChannelBuffer; //導入方法依賴的package包/類
/**
* Reads the channel buffer and returns object.
*
* @param cb channelBuffer
* @return object of flow spec action traffic rate
* @throws BgpParseException while parsing BgpFsActionTrafficRate
*/
public static BgpFsActionTrafficRate read(ChannelBuffer cb) throws BgpParseException {
short asn;
float rate;
asn = cb.readShort();
rate = cb.readFloat();
return new BgpFsActionTrafficRate(asn, rate);
}
示例9: read
import org.jboss.netty.buffer.ChannelBuffer; //導入方法依賴的package包/類
/**
* Reads the IGP Flags.
*
* @param cb ChannelBuffer
* @return object of BgpPrefixAttrIGPFlags
* @throws BgpParseException while parsing BgpPrefixAttrIGPFlags
*/
public static BgpPrefixAttrIgpFlags read(ChannelBuffer cb)
throws BgpParseException {
boolean bisisUpDownBit = false;
boolean bOspfNoUnicastBit = false;
boolean bOspfLclAddrBit = false;
boolean bOspfNssaBit = false;
short lsAttrLength = cb.readShort();
if ((lsAttrLength != ATTR_PREFIX_FLAG_LEN)
|| (cb.readableBytes() < lsAttrLength)) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
byte nodeFlagBits = cb.readByte();
bisisUpDownBit = ((nodeFlagBits & FIRST_BIT) == FIRST_BIT);
bOspfNoUnicastBit = ((nodeFlagBits & SECOND_BIT) == SECOND_BIT);
bOspfLclAddrBit = ((nodeFlagBits & THIRD_BIT) == THIRD_BIT);
bOspfNssaBit = ((nodeFlagBits & FOURTH_BIT) == FOURTH_BIT);
return BgpPrefixAttrIgpFlags.of(bisisUpDownBit, bOspfNoUnicastBit,
bOspfLclAddrBit, bOspfNssaBit);
}
示例10: processBgpOpen
import org.jboss.netty.buffer.ChannelBuffer; //導入方法依賴的package包/類
/**
* Processes BGP open message.
*
* @param ctx Channel handler context
* @param message open message
*/
private void processBgpOpen(ChannelHandlerContext ctx,
ChannelBuffer message) {
int minLength =
MINIMUM_OPEN_MSG_LENGTH - MINIMUM_COMMON_HEADER_LENGTH;
if (message.readableBytes() < minLength) {
log.debug("Error: Bad message length");
ctx.getChannel().close();
return;
}
message.readByte(); // read version
message.readShort(); // read AS number
message.readShort(); // read Hold timer
message.readInt(); // read BGP Identifier
// Optional Parameters
int optParamLen = message.readUnsignedByte();
if (message.readableBytes() < optParamLen) {
log.debug("Error: Bad message length");
ctx.getChannel().close();
return;
}
message.readBytes(optParamLen);
// Open message received
receivedOpenMessageLatch.countDown();
}
示例11: read
import org.jboss.netty.buffer.ChannelBuffer; //導入方法依賴的package包/類
/**
* Reads the channel buffer and returns object of PcepRsvpErrorSpec.
*
* @param cb of type channel buffer
* @return object of PcepRsvpErrorSpec
* @throws PcepParseException when expected object is not received
*/
public static PcepRsvpErrorSpec read(ChannelBuffer cb) throws PcepParseException {
PcepRsvpSpecObjHeader objHeader;
int enterpriseNum;
byte subOrg;
byte errDescLen;
short userErrorValue;
byte[] errDesc;
LinkedList<PcepValueType> llRsvpUserSpecSubObj = null;
objHeader = PcepRsvpSpecObjHeader.read(cb);
if (objHeader.getObjClassNum() != CLASS_NUM || objHeader.getObjClassType() != CLASS_TYPE) {
throw new PcepParseException("Expected PcepRsvpUserErrorSpec object.");
}
enterpriseNum = cb.readInt();
subOrg = cb.readByte();
errDescLen = cb.readByte();
userErrorValue = cb.readShort();
errDesc = new byte[errDescLen];
cb.readBytes(errDesc, 0, errDescLen);
llRsvpUserSpecSubObj = parseErrSpecSubObj(cb);
return new PcepRsvpUserErrorSpec(objHeader, enterpriseNum, subOrg, errDescLen, userErrorValue, errDesc,
llRsvpUserSpecSubObj);
}
示例12: read
import org.jboss.netty.buffer.ChannelBuffer; //導入方法依賴的package包/類
/**
* Reads the PcepRsvpObjectHeader.
*
* @param cb input channel buffer
* @return PcepRsvpObjectHeader
*/
public static PcepRsvpObjectHeader read(ChannelBuffer cb) {
log.debug("read ");
byte objClassNum;
byte objClassType;
short objLen;
objLen = cb.readShort();
objClassNum = cb.readByte();
objClassType = cb.readByte();
return new PcepRsvpObjectHeader(objClassNum, objClassType, objLen);
}
示例13: read
import org.jboss.netty.buffer.ChannelBuffer; //導入方法依賴的package包/類
/**
* Reads PCPE RSVP error spec from channel buffer and returns PCEP rsvp IPv4 error spec object.
*
* @param cb channel buffer
* @return PCEP rsvp IPv4 error spec object
*/
public static PcepRsvpErrorSpec read(ChannelBuffer cb) {
PcepRsvpSpecObjHeader objHeader;
int ipv4Addr;
byte flags;
byte errCode;
short errValue;
objHeader = PcepRsvpSpecObjHeader.read(cb);
ipv4Addr = cb.readInt();
flags = cb.readByte();
errCode = cb.readByte();
errValue = cb.readShort();
return new PcepRsvpIpv4ErrorSpec(objHeader, ipv4Addr, flags, errCode, errValue);
}
示例14: read
import org.jboss.netty.buffer.ChannelBuffer; //導入方法依賴的package包/類
/**
* Read from channel buffer and Returns BGP header.
*
* @param cb ChannelBuffer
* @return object of BGPHeader
*/
public static BgpHeader read(ChannelBuffer cb) {
byte[] marker = new byte[MARKER_LENGTH];
byte type;
short length;
cb.readBytes(marker, 0, MARKER_LENGTH);
length = cb.readShort();
type = cb.readByte();
return new BgpHeader(marker, length, type);
}
示例15: read
import org.jboss.netty.buffer.ChannelBuffer; //導入方法依賴的package包/類
/**
* Reads the channel buffer and returns object of WideCommunityInteger.
*
* @param c ChannelBuffer
* @return object of WideCommunityInteger
* @throws BgpParseException on read error
*/
public static WideCommunityInteger read(ChannelBuffer c) throws BgpParseException {
List<Integer> integer = new ArrayList<>();
short length;
if (c.readableBytes() < 2) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
c.readableBytes());
}
length = c.readShort();
if (length == 0) {
return new WideCommunityInteger(integer);
}
if (c.readableBytes() < length) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
c.readableBytes());
}
while (c.readableBytes() > 0) {
if (c.readableBytes() < 4) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
c.readableBytes());
}
integer.add(c.readInt());
}
return new WideCommunityInteger(integer);
}