List of usage examples for io.netty.buffer ByteBuf writeLong
public abstract ByteBuf writeLong(long value);
From source file:org.opendaylight.netide.openflowjava.protocol.impl.serialization.factories.MultipartReplyMessageFactory.java
License:Open Source License
private void serializeFlowBody(MultipartReplyBody body, ByteBuf outBuffer, MultipartReplyMessage message) { MultipartReplyFlowCase flowCase = (MultipartReplyFlowCase) body; MultipartReplyFlow flow = flowCase.getMultipartReplyFlow(); for (FlowStats flowStats : flow.getFlowStats()) { ByteBuf flowStatsBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); flowStatsBuff.writeShort(EncodeConstants.EMPTY_LENGTH); flowStatsBuff.writeByte(new Long(flowStats.getTableId()).byteValue()); flowStatsBuff.writeZero(FLOW_STATS_PADDING_1); flowStatsBuff.writeInt(flowStats.getDurationSec().intValue()); flowStatsBuff.writeInt(flowStats.getDurationNsec().intValue()); flowStatsBuff.writeShort(flowStats.getPriority()); flowStatsBuff.writeShort(flowStats.getIdleTimeout()); flowStatsBuff.writeShort(flowStats.getHardTimeout()); flowStatsBuff.writeZero(FLOW_STATS_PADDING_2); flowStatsBuff.writeLong(flowStats.getCookie().longValue()); flowStatsBuff.writeLong(flowStats.getPacketCount().longValue()); flowStatsBuff.writeLong(flowStats.getByteCount().longValue()); OFSerializer<Match> matchSerializer = registry.<Match, OFSerializer<Match>>getSerializer( new MessageTypeKey<>(message.getVersion(), Match.class)); matchSerializer.serialize(flowStats.getMatch(), flowStatsBuff); ListSerializer.serializeList(flowStats.getInstruction(), TypeKeyMakerFactory.createInstructionKeyMaker(message.getVersion()), registry, flowStatsBuff); flowStatsBuff.setShort(FLOW_STATS_LENGTH_INDEX, flowStatsBuff.readableBytes()); outBuffer.writeBytes(flowStatsBuff); }/*from www . ja v a2 s .c o m*/ }
From source file:org.opendaylight.netide.openflowjava.protocol.impl.serialization.factories.OF10FeaturesReplyMessageFactory.java
License:Open Source License
@Override public void serialize(GetFeaturesOutput message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeLong(message.getDatapathId().longValue()); outBuffer.writeInt(message.getBuffers().intValue()); outBuffer.writeByte(message.getTables().intValue()); outBuffer.writeZero(PADDING);/*from w ww . java2s. c o m*/ outBuffer.writeInt(createCapabilities(message.getCapabilitiesV10())); outBuffer.writeInt(createActionsV10(message.getActionsV10())); for (PhyPort port : message.getPhyPort()) { outBuffer.writeShort(port.getPortNo().intValue()); writeMacAddress(port.getHwAddr().getValue(), outBuffer); writeName(port.getName(), outBuffer); writePortConfig(port.getConfigV10(), outBuffer); writePortState(port.getStateV10(), outBuffer); writePortFeature(port.getCurrentFeaturesV10(), outBuffer); writePortFeature(port.getAdvertisedFeaturesV10(), outBuffer); writePortFeature(port.getSupportedFeaturesV10(), outBuffer); writePortFeature(port.getPeerFeaturesV10(), outBuffer); } ByteBufUtils.updateOFHeaderLength(outBuffer); }
From source file:org.opendaylight.netide.openflowjava.protocol.impl.serialization.factories.OF10FlowRemovedMessageFactory.java
License:Open Source License
@Override public void serialize(FlowRemovedMessage message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); OFSerializer<MatchV10> matchSerializer = registry .getSerializer(new MessageTypeKey<>(message.getVersion(), MatchV10.class)); matchSerializer.serialize(message.getMatchV10(), outBuffer); outBuffer.writeLong(message.getCookie().longValue()); outBuffer.writeShort(message.getPriority()); outBuffer.writeByte(message.getReason().getIntValue()); outBuffer.writeZero(PADDING);/* w w w .java2s .c o m*/ outBuffer.writeInt(message.getDurationSec().intValue()); outBuffer.writeInt(message.getDurationNsec().intValue()); outBuffer.writeShort(message.getIdleTimeout()); outBuffer.writeZero(PADDING); outBuffer.writeZero(PADDING); outBuffer.writeLong(message.getPacketCount().longValue()); outBuffer.writeLong(message.getByteCount().longValue()); ByteBufUtils.updateOFHeaderLength(outBuffer); }
From source file:org.opendaylight.netide.openflowjava.protocol.impl.serialization.factories.OF10StatsReplyMessageFactory.java
License:Open Source License
private void serializeQueueBody(MultipartReplyBody body, ByteBuf outBuffer) { MultipartReplyQueueCase queueCase = (MultipartReplyQueueCase) body; MultipartReplyQueue queue = queueCase.getMultipartReplyQueue(); for (QueueStats queueStats : queue.getQueueStats()) { ByteBuf queueStatsBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); queueStatsBuff.writeShort(EncodeConstants.EMPTY_LENGTH); queueStatsBuff.writeZero(QUEUE_PADDING); queueStatsBuff.writeInt(queueStats.getQueueId().intValue()); queueStatsBuff.writeLong(queueStats.getTxBytes().longValue()); queueStatsBuff.writeLong(queueStats.getTxPackets().longValue()); queueStatsBuff.writeLong(queueStats.getTxErrors().longValue()); queueStatsBuff.setShort(QUEUE_STATS_LENGTH_INDEX, queueStatsBuff.readableBytes()); outBuffer.writeBytes(queueStatsBuff); }//from w ww . j ava 2 s . c o m }
From source file:org.opendaylight.netide.openflowjava.protocol.impl.serialization.factories.OF10StatsReplyMessageFactory.java
License:Open Source License
private void serializePortStatsBody(MultipartReplyBody body, ByteBuf outBuffer) { MultipartReplyPortStatsCase portStatsCase = (MultipartReplyPortStatsCase) body; MultipartReplyPortStats portStats = portStatsCase.getMultipartReplyPortStats(); for (PortStats portStat : portStats.getPortStats()) { outBuffer.writeInt(portStat.getPortNo().intValue()); outBuffer.writeZero(PORT_STATS_PADDING); outBuffer.writeLong(portStat.getRxPackets().longValue()); outBuffer.writeLong(portStat.getTxPackets().longValue()); outBuffer.writeLong(portStat.getRxBytes().longValue()); outBuffer.writeLong(portStat.getTxBytes().longValue()); outBuffer.writeLong(portStat.getRxDropped().longValue()); outBuffer.writeLong(portStat.getTxDropped().longValue()); outBuffer.writeLong(portStat.getRxErrors().longValue()); outBuffer.writeLong(portStat.getTxErrors().longValue()); outBuffer.writeLong(portStat.getRxFrameErr().longValue()); outBuffer.writeLong(portStat.getRxOverErr().longValue()); outBuffer.writeLong(portStat.getRxCrcErr().longValue()); outBuffer.writeLong(portStat.getCollisions().longValue()); }// ww w . j av a 2 s . c om }
From source file:org.opendaylight.netide.openflowjava.protocol.impl.serialization.factories.OF10StatsReplyMessageFactory.java
License:Open Source License
private void serializeTableBody(MultipartReplyBody body, ByteBuf outBuffer) { MultipartReplyTableCase tableCase = (MultipartReplyTableCase) body; MultipartReplyTable table = tableCase.getMultipartReplyTable(); for (TableStats tableStats : table.getTableStats()) { outBuffer.writeByte(tableStats.getTableId()); outBuffer.writeZero(TABLE_PADDING); write16String(tableStats.getName(), outBuffer); writeFlowWildcardsV10(tableStats.getWildcards(), outBuffer); outBuffer.writeInt(tableStats.getMaxEntries().intValue()); outBuffer.writeInt(tableStats.getActiveCount().intValue()); outBuffer.writeLong(tableStats.getLookupCount().longValue()); outBuffer.writeLong(tableStats.getMatchedCount().longValue()); }/*from w w w . j a v a 2 s . c o m*/ }
From source file:org.opendaylight.netide.openflowjava.protocol.impl.serialization.factories.OF10StatsReplyMessageFactory.java
License:Open Source License
private void serializeFlowBody(MultipartReplyBody body, ByteBuf outBuffer, MultipartReplyMessage message) { MultipartReplyFlowCase flowCase = (MultipartReplyFlowCase) body; MultipartReplyFlow flow = flowCase.getMultipartReplyFlow(); for (FlowStats flowStats : flow.getFlowStats()) { ByteBuf flowStatsBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); flowStatsBuff.writeShort(EncodeConstants.EMPTY_LENGTH); flowStatsBuff.writeByte(new Long(flowStats.getTableId()).byteValue()); flowStatsBuff.writeZero(FLOW_STATS_PADDING_1); OFSerializer<MatchV10> matchSerializer = registry .getSerializer(new MessageTypeKey<>(message.getVersion(), MatchV10.class)); matchSerializer.serialize(flowStats.getMatchV10(), flowStatsBuff); flowStatsBuff.writeInt(flowStats.getDurationSec().intValue()); flowStatsBuff.writeInt(flowStats.getDurationNsec().intValue()); flowStatsBuff.writeShort(flowStats.getPriority()); flowStatsBuff.writeShort(flowStats.getIdleTimeout()); flowStatsBuff.writeShort(flowStats.getHardTimeout()); flowStatsBuff.writeZero(FLOW_STATS_PADDING_2); flowStatsBuff.writeLong(flowStats.getCookie().longValue()); flowStatsBuff.writeLong(flowStats.getPacketCount().longValue()); flowStatsBuff.writeLong(flowStats.getByteCount().longValue()); ListSerializer.serializeList(flowStats.getAction(), ACTION_KEY_MAKER, registry, flowStatsBuff); flowStatsBuff.setShort(FLOW_STATS_LENGTH_INDEX, flowStatsBuff.readableBytes()); outBuffer.writeBytes(flowStatsBuff); }/*from w w w . j av a2 s. c o m*/ }
From source file:org.opendaylight.netide.openflowjava.protocol.impl.serialization.factories.PacketInMessageFactory.java
License:Open Source License
@Override public void serialize(PacketInMessage message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeInt(message.getBufferId().intValue()); outBuffer.writeShort(message.getTotalLen().intValue()); outBuffer.writeByte(message.getReason().getIntValue()); outBuffer.writeByte(message.getTableId().getValue().byteValue()); outBuffer.writeLong(message.getCookie().longValue()); OFSerializer<Match> matchSerializer = registry .<Match, OFSerializer<Match>>getSerializer(new MessageTypeKey<>(message.getVersion(), Match.class)); matchSerializer.serialize(message.getMatch(), outBuffer); outBuffer.writeZero(PADDING);//from w ww . j a v a2 s.c o m byte[] data = message.getData(); if (data != null) { outBuffer.writeBytes(data); } ByteBufUtils.updateOFHeaderLength(outBuffer); }
From source file:org.opendaylight.netide.openflowjava.protocol.impl.serialization.factories.RoleReplyMessageFactory.java
License:Open Source License
@Override public void serialize(RoleRequestOutput message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeInt(message.getRole().getIntValue()); outBuffer.writeZero(PADDING);/* www. j av a 2 s .c o m*/ outBuffer.writeLong(message.getGenerationId().longValue()); ByteBufUtils.updateOFHeaderLength(outBuffer); }
From source file:org.opendaylight.openflowjava.nx.codec.action.LearnCodecTest.java
License:Open Source License
private void createBufer(ByteBuf message) { message.writeShort(EncodeConstants.EXPERIMENTER_VALUE); message.writeShort(LEARN_HEADER_LEN + 56); message.writeInt(NiciraConstants.NX_VENDOR_ID.intValue()); message.writeShort(NXAST_LEARN_SUBTYPE); message.writeShort(1);/*from w w w . jav a 2 s . c o m*/ message.writeShort(2); message.writeShort(3); message.writeLong(4); message.writeShort(5); message.writeByte(6); message.writeZero(1); message.writeShort(7); message.writeShort(8); toFlowModSpecHeader(message, 0, 0); message.writeInt(9); message.writeShort(10); message.writeInt(11); message.writeShort(12); toFlowModSpecHeader(message, 0, 1); message.writeInt(9); message.writeShort(10); message.writeInt(11); message.writeShort(12); toFlowModSpecHeader(message, 1, 1); message.writeShort(9); message.writeInt(10); message.writeShort(11); toFlowModSpecHeader(message, 1, 0); message.writeShort(9); message.writeInt(10); message.writeShort(11); toFlowModSpecHeader(message, 0, 2); message.writeInt(9); message.writeShort(10); }