Java Code Examples for org.jboss.netty.buffer.ChannelBuffer#writeInt()
The following examples show how to use
org.jboss.netty.buffer.ChannelBuffer#writeInt() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BgpOpen.java From onos with Apache License 2.0 | 6 votes |
/** * Prepares BGP OPEN message. * * @param localInfo the BGP Session local information to use * @return the message to transmit (BGP header included) */ static ChannelBuffer prepareBgpOpen(BgpSessionInfo localInfo) { ChannelBuffer message = ChannelBuffers.buffer(BgpConstants.BGP_MESSAGE_MAX_LENGTH); // // Prepare the OPEN message payload // message.writeByte(localInfo.bgpVersion()); message.writeShort((int) localInfo.asNumber()); message.writeShort((int) localInfo.holdtime()); message.writeInt(localInfo.bgpId().toInt()); // Prepare the optional BGP Capabilities ChannelBuffer capabilitiesMessage = prepareBgpOpenCapabilities(localInfo); message.writeByte(capabilitiesMessage.readableBytes()); message.writeBytes(capabilitiesMessage); return BgpMessage.prepareBgpMessage(BgpConstants.BGP_TYPE_OPEN, message); }
Example 2
Source File: BgpEvpnRouteType2Nlri.java From onos with Apache License 2.0 | 6 votes |
@Override public int write(ChannelBuffer cb) { int iLenStartIndex = cb.writerIndex(); cb.writeLong(rd.getRouteDistinguisher()); esi.write(cb); cb.writeInt(ethernetTagID); cb.writeByte(macAddressLength); cb.writeBytes(macAddress.toBytes()); cb.writeByte(ipAddressLength); if (ipAddressLength > 0) { cb.writeBytes(ipAddress.getAddress()); } mplsLabel1.write(cb); if (mplsLabel2 != null) { mplsLabel2.write(cb); } return cb.writerIndex() - iLenStartIndex; }
Example 3
Source File: OpKillCursors.java From usergrid with Apache License 2.0 | 6 votes |
@Override public ChannelBuffer encode( ChannelBuffer buffer ) { int l = 24; // (6 ints * 4 bytes) numberOfCursorIDs = 0; if ( cursorIDs != null ) { numberOfCursorIDs = cursorIDs.size(); l += numberOfCursorIDs * 8; } messageLength = l; buffer = super.encode( buffer ); buffer.writeInt( 0 ); buffer.writeInt( numberOfCursorIDs ); if ( cursorIDs != null ) { for ( Long cursorID : cursorIDs ) { buffer.writeLong( cursorID ); } } return buffer; }
Example 4
Source File: PcepFecObjectIPv4UnnumberedAdjacencyVer1.java From onos with Apache License 2.0 | 6 votes |
@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(); }
Example 5
Source File: PcepLabelRangeObjectVer1.java From onos with Apache License 2.0 | 6 votes |
@Override public int write(ChannelBuffer cb) throws PcepParseException { int objStartIndex = cb.writerIndex(); //write common header int objLenIndex = labelRangeObjHeader.write(cb); int temp = 0; temp = labelType; temp = temp << 24; temp = temp | rangeSize; cb.writeInt(temp); // Add optional TLV if (!packOptionalTlv(cb)) { throw new PcepParseException("Error while writing Optional tlv."); } //now write LabelRange Object Length cb.setShort(objLenIndex, (short) (cb.writerIndex() - objStartIndex)); return cb.writerIndex() - objStartIndex; }
Example 6
Source File: OFTableStatistics.java From floodlight_with_topoguard with Apache License 2.0 | 5 votes |
@Override public void writeTo(ChannelBuffer data) { data.writeByte(this.tableId); data.writeByte((byte) 0); // pad data.writeByte((byte) 0); // pad data.writeByte((byte) 0); // pad StringByteSerializer.writeTo(data, MAX_TABLE_NAME_LEN, this.name); data.writeInt(this.wildcards); data.writeInt(this.maximumEntries); data.writeInt(this.activeCount); data.writeLong(this.lookupCount); data.writeLong(this.matchedCount); }
Example 7
Source File: FourOctetAsNumCapabilityTlv.java From onos with Apache License 2.0 | 5 votes |
@Override public int write(ChannelBuffer cb) { int iLenStartIndex = cb.writerIndex(); cb.writeByte(TYPE); cb.writeByte(LENGTH); cb.writeInt(rawValue); return cb.writerIndex() - iLenStartIndex; }
Example 8
Source File: PcepRsvpUserErrorSpec.java From onos with Apache License 2.0 | 5 votes |
@Override public int write(ChannelBuffer cb) { int objLenIndex = objHeader.write(cb); cb.writeInt(enterpriseNum); cb.writeByte(subOrg); cb.writeByte(errDescLen); cb.writeShort(userErrorValue); cb.writeBytes(errDesc); if (llRsvpUserSpecSubObj != null) { ListIterator<PcepValueType> listIterator = llRsvpUserSpecSubObj.listIterator(); while (listIterator.hasNext()) { PcepValueType tlv = listIterator.next(); if (tlv == null) { continue; } tlv.write(cb); // need to take care of padding int pad = tlv.getLength() % 4; if (0 != pad) { pad = 4 - pad; for (int i = 0; i < pad; ++i) { cb.writeByte((byte) 0); } } } } short objLen = (short) (cb.writerIndex() - objLenIndex); cb.setShort(objLenIndex, objLen); return objLen; }
Example 9
Source File: PcepInterLayerObjectVer1.java From onos with Apache License 2.0 | 5 votes |
@Override public int write(ChannelBuffer cb) throws PcepParseException { //write Object header int objStartIndex = cb.writerIndex(); int objLenIndex = interLayerObjHeader.write(cb); if (objLenIndex <= 0) { throw new PcepParseException(" ObjectLength Index is " + objLenIndex); } int iTemp = 0; if (bIFlag) { iTemp = iTemp | (byte) IFLAG_SHIFT_VALUE; } if (bNFlag) { iTemp = iTemp | (byte) NFLAG_SHIFT_VALUE; } cb.writeInt(iTemp); //Update object length now int length = cb.writerIndex() - objStartIndex; //will be helpful during print(). interLayerObjHeader.setObjLen((short) length); cb.setShort(objLenIndex, (short) length); objLenIndex = cb.writerIndex(); return objLenIndex; }
Example 10
Source File: OFPortMod.java From floodlight_with_topoguard with Apache License 2.0 | 5 votes |
@Override public void writeTo(ChannelBuffer data) { super.writeTo(data); data.writeShort(this.portNumber); data.writeBytes(this.hardwareAddress); data.writeInt(this.config); data.writeInt(this.mask); data.writeInt(this.advertise); data.writeInt(0); // pad }
Example 11
Source File: BgpLSIdentifierTlv.java From onos with Apache License 2.0 | 5 votes |
@Override public int write(ChannelBuffer c) { int iLenStartIndex = c.writerIndex(); c.writeShort(TYPE); c.writeShort(LENGTH); c.writeInt(bgpLsIdentifier); return c.writerIndex() - iLenStartIndex; }
Example 12
Source File: SrPceCapabilityTlv.java From onos with Apache License 2.0 | 5 votes |
@Override public int write(ChannelBuffer c) { int iLenStartIndex = c.writerIndex(); c.writeShort(TYPE); c.writeShort(LENGTH); c.writeInt(msd); return c.writerIndex() - iLenStartIndex; }
Example 13
Source File: RouteAttributePriority.java From onos with Apache License 2.0 | 5 votes |
/** * Encode the RouteAttributePriority contents into the ChannelBuffer. * * @param cb channelbuffer to be filled in */ @Override public void encode(ChannelBuffer cb) { super.encode(cb); cb.writeInt(Integer.reverseBytes((int) priority)); }
Example 14
Source File: StatefulIPv4LspIdentifiersTlv.java From onos with Apache License 2.0 | 5 votes |
@Override public int write(ChannelBuffer c) { int iLenStartIndex = c.writerIndex(); c.writeShort(TYPE); c.writeShort(LENGTH); c.writeInt(ipv4IngressAddress); c.writeShort(lspId); c.writeShort(tunnelId); c.writeInt(extendedTunnelId); c.writeInt(ipv4EgressAddress); return c.writerIndex() - iLenStartIndex; }
Example 15
Source File: BgpLsIdentifierSubTlv.java From onos with Apache License 2.0 | 5 votes |
@Override public int write(ChannelBuffer c) { int iLenStartIndex = c.writerIndex(); c.writeShort(TYPE); c.writeShort(LENGTH); c.writeInt(rawValue); return c.writerIndex() - iLenStartIndex; }
Example 16
Source File: OFBsnL2TableVendorData.java From floodlight_with_topoguard with Apache License 2.0 | 5 votes |
@Override public void writeTo(ChannelBuffer data) { super.writeTo(data); data.writeByte(isL2TableEnabled() ? 1 : 0); data.writeByte(0); // pad data.writeShort(l2TablePriority); data.writeInt(0); // 4 pad bytes }
Example 17
Source File: AdministrativeGroupSubTlv.java From onos with Apache License 2.0 | 5 votes |
@Override public int write(ChannelBuffer c) { int iLenStartIndex = c.writerIndex(); c.writeShort(TYPE); c.writeShort(LENGTH); c.writeInt(rawValue); return c.writerIndex() - iLenStartIndex; }
Example 18
Source File: PathSetupTypeTlv.java From onos with Apache License 2.0 | 5 votes |
@Override public int write(ChannelBuffer c) { int iLenStartIndex = c.writerIndex(); c.writeShort(TYPE); c.writeShort(LENGTH); c.writeInt(pst); return c.writerIndex() - iLenStartIndex; }
Example 19
Source File: OFQueueStatisticsRequest.java From floodlight_with_topoguard with Apache License 2.0 | 4 votes |
@Override public void writeTo(ChannelBuffer data) { data.writeShort(this.portNumber); data.writeShort((short) 0); // pad data.writeInt(this.queueId); }
Example 20
Source File: OpQuery.java From usergrid with Apache License 2.0 | 3 votes |
@Override public ChannelBuffer encode( ChannelBuffer buffer ) { int l = 28; // 7 ints * 4 bytes ByteBuffer fullCollectionNameBytes = getCString( fullCollectionName ); l += fullCollectionNameBytes.capacity(); ByteBuffer queryBytes = encodeDocument( query ); l += queryBytes.capacity(); ByteBuffer returnFieldSelectorBytes = encodeDocument( returnFieldSelector ); l += returnFieldSelectorBytes.capacity(); messageLength = l; buffer = super.encode( buffer ); buffer.writeInt( flags ); buffer.writeBytes( fullCollectionNameBytes ); buffer.writeInt( numberToSkip ); buffer.writeInt( numberToReturn ); buffer.writeBytes( queryBytes ); buffer.writeBytes( returnFieldSelectorBytes ); return buffer; }