本文整理汇总了Java中org.jboss.netty.buffer.ChannelBuffer.setShort方法的典型用法代码示例。如果您正苦于以下问题:Java ChannelBuffer.setShort方法的具体用法?Java ChannelBuffer.setShort怎么用?Java ChannelBuffer.setShort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jboss.netty.buffer.ChannelBuffer
的用法示例。
在下文中一共展示了ChannelBuffer.setShort方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: write
import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
@Override
public int write(ChannelBuffer cb) throws PcepParseException {
//write Object header
int objStartIndex = cb.writerIndex();
int objLenIndex = metricObjHeader.write(cb);
if (objLenIndex <= 0) {
throw new PcepParseException("Error: ObjectLength is " + objLenIndex);
}
int iFlag = (bCFlag) ? CFLAG_SET : CFLAG_RESET;
int iTemp = iFlag << IFLAG_SHIFT_VALUE;
iFlag = (bBFlag) ? BFLAG_SET : BFLAG_RESET;
iTemp = iTemp | (iFlag << BTYPE_SHIFT_VALUE);
iTemp = iTemp | bType;
cb.writeInt(iTemp);
cb.writeInt(iMetricVal);
short hLength = (short) (cb.writerIndex() - objStartIndex);
cb.setShort(objLenIndex, hLength);
//will be helpful during print().
metricObjHeader.setObjLen(hLength);
return hLength;
}
示例2: write
import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
@Override
public int write(ChannelBuffer cb) throws PcepParseException {
int objStartIndex = cb.writerIndex();
//Write common header
int objLenIndex = fecObjHeader.write(cb);
cb.writeInt(localNodeID);
cb.writeInt(localInterfaceID);
cb.writeInt(remoteNodeID);
cb.writeInt(remoteInterfaceID);
//Now write FEC IPv4 Unnumbered Adjacency Object Length
cb.setShort(objLenIndex, (short) (cb.writerIndex() - objStartIndex));
return cb.writerIndex();
}
示例3: write
import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
@Override
public void write(ChannelBuffer cb, PcepLabelUpdateMsgVer1 message) throws PcepParseException {
int startIndex = cb.writerIndex();
// first 3 bits set to version
cb.writeByte((byte) (PACKET_VERSION << PcepMessageVer1.SHIFT_FLAG));
// message type
cb.writeByte(MSG_TYPE.getType());
// Length will be set after calculating length, but currently set it as 0.
int msgLenIndex = cb.writerIndex();
cb.writeShort((short) 0);
ListIterator<PcepLabelUpdate> listIterator = message.llPcLabelUpdateList.listIterator();
while (listIterator.hasNext()) {
PcepLabelUpdate labelUpdate = listIterator.next();
labelUpdate.write(cb);
}
// update message length field
int length = cb.writerIndex() - startIndex;
cb.setShort(msgLenIndex, (short) length);
}
示例4: write
import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
@Override
public int write(ChannelBuffer cb) throws PcepParseException {
int objStartIndex = cb.writerIndex();
//write common header
int objLenIndex = fecObjHeader.write(cb);
cb.writeInt(nodeID);
//now write FEC IPv4 Object Length
cb.setShort(objLenIndex, (short) (cb.writerIndex() - objStartIndex));
return cb.writerIndex();
}
示例5: write
import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
@Override
public int write(ChannelBuffer c) {
int tlvStartIndex = c.writerIndex();
c.writeShort(TYPE);
int tlvLenIndex = c.writerIndex();
hLength = 0;
c.writeShort(hLength);
ListIterator<PcepValueType> listIterator = llNodeAttributesSubTLVs.listIterator();
while (listIterator.hasNext()) {
PcepValueType tlv = listIterator.next();
tlv.write(c);
// need to take care of padding
int pad = tlv.getLength() % 4;
if (0 != pad) {
pad = 4 - pad;
for (int i = 0; i < pad; ++i) {
c.writeByte((byte) 0);
}
}
}
hLength = (short) (c.writerIndex() - tlvStartIndex);
c.setShort(tlvLenIndex, (hLength - TLV_HEADER_LENGTH));
return c.writerIndex() - tlvStartIndex;
}
示例6: write
import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
@Override
public int write(ChannelBuffer cb) throws PcepParseException {
int objStartIndex = cb.writerIndex();
//write common header
int objLenIndex = fecObjHeader.write(cb);
cb.writeBytes(nodeID);
//now write FEC IPv4 Object Length
cb.setShort(objLenIndex, (short) (cb.writerIndex() - objStartIndex));
return cb.writerIndex();
}
示例7: write
import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
@Override
public int write(ChannelBuffer c) {
int tlvStartIndex = c.writerIndex();
c.writeShort(TYPE);
int tlvLenIndex = c.writerIndex();
hLength = 0;
c.writeShort(0);
ListIterator<PcepValueType> listIterator = llNodeDescriptorSubTLVs.listIterator();
while (listIterator.hasNext()) {
PcepValueType tlv = listIterator.next();
if (tlv == null) {
log.debug("TLV is null from subTlv list");
continue;
}
tlv.write(c);
// need to take care of padding
int pad = tlv.getLength() % 4;
if (0 != pad) {
pad = 4 - pad;
for (int i = 0; i < pad; ++i) {
c.writeByte((byte) 0);
}
}
}
hLength = (short) (c.writerIndex() - tlvStartIndex);
c.setShort(tlvLenIndex, (hLength - TLV_HEADER_LENGTH));
return c.writerIndex() - tlvStartIndex;
}
示例8: write
import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
@Override
public int write(ChannelBuffer cb) throws PcepParseException {
int objStartIndex = cb.writerIndex();
//write common header
int objLenIndex = srpObjHeader.write(cb);
//write Flags
byte bFlag;
bFlag = (bRFlag) ? BBIT_SET : BBIT_RESET;
bFlag |= (((bSFlag) ? BBIT_SET : BBIT_RESET) << 1);
cb.writeInt(bFlag);
//write SrpId
cb.writeInt(srpId);
// Add optional TLV
if (!packOptionalTlv(cb)) {
throw new PcepParseException("Failed to write srp tlv to channel buffer.");
}
//now write SRP Object Length
cb.setShort(objLenIndex, (short) (cb.writerIndex() - objStartIndex));
return cb.writerIndex();
}
示例9: write
import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
@Override
public void write(ChannelBuffer cb, PcepUpdateMsgVer1 message) throws PcepParseException {
int startIndex = cb.writerIndex();
// first 3 bits set to version
cb.writeByte((byte) (PACKET_VERSION << PcepMessageVer1.SHIFT_FLAG));
// message type
cb.writeByte(MSG_TYPE.getType());
/* length is length of variable message, will be updated at the end
* Store the position of message
* length in buffer
*/
int msgLenIndex = cb.writerIndex();
cb.writeShort((short) 0);
ListIterator<PcepUpdateRequest> listIterator = message.llUpdateRequestList.listIterator();
while (listIterator.hasNext()) {
PcepUpdateRequest updateReq = listIterator.next();
//SRP object is mandatory
PcepSrpObject srpObj = updateReq.getSrpObject();
srpObj.write(cb);
//LSP object is mandatory
PcepLspObject lspObj = updateReq.getLspObject();
lspObj.write(cb);
//PATH object is mandatory
PcepMsgPath msgPath = updateReq.getMsgPath();
msgPath.write(cb);
}
// update message length field
int length = cb.writerIndex() - startIndex;
cb.setShort(msgLenIndex, (short) length);
}
示例10: write
import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
@Override
public int write(ChannelBuffer c) {
int tlvStartIndex = c.writerIndex();
c.writeShort(TYPE);
int tlvLenIndex = c.writerIndex();
hLength = 0;
c.writeShort(hLength);
ListIterator<PcepValueType> listIterator = llLinkAttributesSubTLVs.listIterator();
while (listIterator.hasNext()) {
PcepValueType tlv = listIterator.next();
if (tlv == null) {
log.debug("TLV is null from subTlv list");
continue;
}
tlv.write(c);
// need to take care of padding
int pad = tlv.getLength() % 4;
if (0 != pad) {
pad = 4 - pad;
for (int i = 0; i < pad; ++i) {
c.writeByte((byte) 0);
}
}
}
hLength = (short) (c.writerIndex() - tlvStartIndex);
c.setShort(tlvLenIndex, (hLength - TLV_HEADER_LENGTH));
return c.writerIndex() - tlvStartIndex;
}
示例11: write
import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
@Override
public int write(ChannelBuffer cb) throws PcepParseException {
//write Object header
int objStartIndex = cb.writerIndex();
int objLenIndex = rroObjHeader.write(cb);
if (objLenIndex <= 0) {
throw new PcepParseException(" object Length Index" + objLenIndex);
}
ListIterator<PcepValueType> listIterator = llSubObjects.listIterator();
while (listIterator.hasNext()) {
listIterator.next().write(cb);
}
//Update object length now
int length = cb.writerIndex() - objStartIndex;
cb.setShort(objLenIndex, (short) length);
//will be helpful during print().
rroObjHeader.setObjLen((short) length);
//As per RFC the length of object should be multiples of 4
int pad = length % 4;
if (0 != pad) {
pad = 4 - pad;
for (int i = 0; i < pad; i++) {
cb.writeByte((byte) 0);
}
length = length + pad;
}
objLenIndex = cb.writerIndex();
return objLenIndex;
}
示例12: write
import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
@Override
public int write(ChannelBuffer cb) throws PcepParseException {
//write Object header
int objStartIndex = cb.writerIndex();
int objLenIndex = bandwidthObjHeader.write(cb);
if (objLenIndex <= 0) {
throw new PcepParseException("Failed to write bandwidth object header. Index " + objLenIndex);
}
//Convert to bytes per second
float bwBytes = iBandwidth / 8.0f;
//Bytes/sec to IEEE floating format
int bandwidth = Float.floatToIntBits(bwBytes);
cb.writeByte(bandwidth >>> 24);
cb.writeByte(bandwidth >> 16 & 0xff);
cb.writeByte(bandwidth >> 8 & 0xff);
cb.writeByte(bandwidth & 0xff);
short hLength = (short) (cb.writerIndex() - objStartIndex);
cb.setShort(objLenIndex, hLength);
//will be helpful during print().
bandwidthObjHeader.setObjLen(hLength);
return cb.writerIndex() - objStartIndex;
}
示例13: write
import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
@Override
public int write(ChannelBuffer c) {
int tlvStartIndex = c.writerIndex();
c.writeShort(TYPE);
int tlvLenIndex = c.writerIndex();
hLength = 0;
c.writeShort(hLength);
ListIterator<PcepValueType> listIterator = llRemoteTENodeDescriptorSubTLVs.listIterator();
while (listIterator.hasNext()) {
PcepValueType tlv = listIterator.next();
if (tlv == null) {
log.debug("TLV is null from subTlv list");
continue;
}
tlv.write(c);
// need to take care of padding
int pad = tlv.getLength() % 4;
if (0 != pad) {
pad = 4 - pad;
for (int i = 0; i < pad; ++i) {
c.writeByte((byte) 0);
}
}
}
hLength = (short) (c.writerIndex() - tlvStartIndex);
c.setShort(tlvLenIndex, (hLength - TLV_HEADER_LENGTH));
return c.writerIndex() - tlvStartIndex;
}
示例14: write
import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
@Override
public int write(ChannelBuffer cb) {
int objLenIndex = objHeader.write(cb);
cb.writeBytes(ipv6Addr);
cb.writeByte(flags);
cb.writeByte(errCode);
cb.writeShort(errValue);
short objLen = (short) (cb.writerIndex() - objLenIndex);
cb.setShort(objLenIndex, objLen);
return objLen;
}
示例15: write
import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
/**
* Write path attributes to channelBuffer.
*
* @param cb channelBuffer
* @return object of BgpPathAttributes
* @throws BgpParseException while parsing BGP path attributes
*/
public int write(ChannelBuffer cb)
throws BgpParseException {
if (pathAttribute == null) {
return 0;
}
int iLenStartIndex = cb.writerIndex();
ListIterator<BgpValueType> iterator = pathAttribute.listIterator();
int pathAttributeIndx = cb.writerIndex();
cb.writeShort(0);
while (iterator.hasNext()) {
BgpValueType attr = iterator.next();
switch (attr.getType()) {
case Origin.ORIGIN_TYPE:
Origin origin = (Origin) attr;
origin.write(cb);
break;
case AsPath.ASPATH_TYPE:
AsPath asPath = (AsPath) attr;
asPath.write(cb);
break;
case As4Path.AS4PATH_TYPE:
As4Path as4Path = (As4Path) attr;
as4Path.write(cb);
break;
case NextHop.NEXTHOP_TYPE:
NextHop nextHop = (NextHop) attr;
nextHop.write(cb);
break;
case Med.MED_TYPE:
Med med = (Med) attr;
med.write(cb);
break;
case LocalPref.LOCAL_PREF_TYPE:
LocalPref localPref = (LocalPref) attr;
localPref.write(cb);
break;
case Constants.BGP_EXTENDED_COMMUNITY:
BgpExtendedCommunity extendedCommunity = (BgpExtendedCommunity) attr;
extendedCommunity.write(cb);
break;
case WideCommunity.TYPE:
WideCommunity wideCommunity = (WideCommunity) attr;
wideCommunity.write(cb);
break;
case MpReachNlri.MPREACHNLRI_TYPE:
MpReachNlri mpReach = (MpReachNlri) attr;
mpReach.write(cb);
break;
case MpUnReachNlri.MPUNREACHNLRI_TYPE:
MpUnReachNlri mpUnReach = (MpUnReachNlri) attr;
mpUnReach.write(cb);
break;
case LINK_STATE_ATTRIBUTE_TYPE:
LinkStateAttributes linkState = (LinkStateAttributes) attr;
linkState.write(cb);
break;
default:
return cb.writerIndex() - iLenStartIndex;
}
}
int pathAttrLen = cb.writerIndex() - pathAttributeIndx;
cb.setShort(pathAttributeIndx, (short) (pathAttrLen - 2));
return cb.writerIndex() - iLenStartIndex;
}