List of usage examples for io.netty.buffer ByteBuf writeZero
public abstract ByteBuf writeZero(int length);
From source file:org.opendaylight.netide.openflowjava.protocol.impl.serialization.factories.MultipartReplyMessageFactory.java
License:Open Source License
private void serializePortDescBody(MultipartReplyBody body, ByteBuf outBuffer) { MultipartReplyPortDescCase portCase = (MultipartReplyPortDescCase) body; MultipartReplyPortDesc portDesc = portCase.getMultipartReplyPortDesc(); for (Ports port : portDesc.getPorts()) { outBuffer.writeInt(port.getPortNo().intValue()); // Assuming PortNo // = PortId outBuffer.writeZero(PORT_DESC_PADDING_1); writeMacAddress(port.getHwAddr().getValue(), outBuffer); outBuffer.writeZero(PORT_DESC_PADDING_2); writeName(port.getName(), outBuffer); writePortConfig(port.getConfig(), outBuffer); writePortState(port.getState(), outBuffer); writePortFeatures(port.getCurrentFeatures(), outBuffer); writePortFeatures(port.getAdvertisedFeatures(), outBuffer); writePortFeatures(port.getSupportedFeatures(), outBuffer); writePortFeatures(port.getPeerFeatures(), outBuffer); outBuffer.writeInt(port.getCurrSpeed().intValue()); outBuffer.writeInt(port.getMaxSpeed().intValue()); }// w w w. j a v a 2 s . c o m }
From source file:org.opendaylight.netide.openflowjava.protocol.impl.serialization.factories.NetIdePacketOutInputMessageFactory.java
License:Open Source License
@Override public void serialize(PacketOutInput message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeInt(message.getBufferId().intValue()); outBuffer.writeInt(message.getInPort().getValue().intValue()); int actionsLengthIndex = outBuffer.writerIndex(); outBuffer.writeShort(message.getAction().size()); outBuffer.writeZero(PADDING_IN_PACKET_OUT_MESSAGE); int actionsStartIndex = outBuffer.writerIndex(); ListSerializer.serializeList(message.getAction(), TypeKeyMakerFactory.createActionKeyMaker(message.getVersion()), registry, outBuffer); outBuffer.setShort(actionsLengthIndex, outBuffer.writerIndex() - actionsStartIndex); byte[] data = message.getData(); if (data != null) { outBuffer.writeBytes(data);//from ww w. j av a 2 s. co m } ByteBufUtils.updateOFHeaderLength(outBuffer); }
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); 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); }// w w w . j a v a 2 s . com 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); outBuffer.writeInt(message.getDurationSec().intValue()); outBuffer.writeInt(message.getDurationNsec().intValue()); outBuffer.writeShort(message.getIdleTimeout()); outBuffer.writeZero(PADDING);/* w w w . j a v a2s . co m*/ 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.OF10PacketInMessageFactory.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.writeShort(message.getInPort()); outBuffer.writeByte(message.getReason().getIntValue()); outBuffer.writeZero(PADDING); byte[] data = message.getData(); if (data != null) { outBuffer.writeBytes(data);//w w w .j a v a 2 s. com } ByteBufUtils.updateOFHeaderLength(outBuffer); }
From source file:org.opendaylight.netide.openflowjava.protocol.impl.serialization.factories.OF10PortStatusMessageFactory.java
License:Open Source License
@Override public void serialize(PortStatusMessage message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeByte(message.getReason().getIntValue()); outBuffer.writeZero(PADDING); outBuffer.writeShort(message.getPortNo().intValue()); writeMacAddress(message.getHwAddr().getValue(), outBuffer); writeName(message.getName(), outBuffer); writePortConfig(message.getConfigV10(), outBuffer); writePortState(message.getStateV10(), outBuffer); writePortFeature(message.getCurrentFeaturesV10(), outBuffer); writePortFeature(message.getAdvertisedFeaturesV10(), outBuffer); writePortFeature(message.getSupportedFeaturesV10(), outBuffer); writePortFeature(message.getPeerFeaturesV10(), outBuffer); ByteBufUtils.updateOFHeaderLength(outBuffer); }
From source file:org.opendaylight.netide.openflowjava.protocol.impl.serialization.factories.OF10QueueGetConfigReplyMessageFactory.java
License:Open Source License
@Override public void serialize(GetQueueConfigOutput message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeShort(message.getPort().getValue().intValue()); outBuffer.writeZero(PADDING); for (Queues queue : message.getQueues()) { ByteBuf queueBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); queueBuff.writeInt(queue.getQueueId().getValue().intValue()); queueBuff.writeShort(EncodeConstants.EMPTY_LENGTH); queueBuff.writeZero(QUEUE_PADDING); for (QueueProperty queueProperty : queue.getQueueProperty()) { ByteBuf queuePropertyBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); queuePropertyBuff.writeShort(queueProperty.getProperty().getIntValue()); queuePropertyBuff.writeShort(EncodeConstants.EMPTY_LENGTH); queuePropertyBuff.writeZero(4); if (queueProperty.getProperty() == QueueProperties.OFPQTMINRATE) { RateQueueProperty body = queueProperty.getAugmentation(RateQueueProperty.class); queuePropertyBuff.writeShort(body.getRate().intValue()); queuePropertyBuff.writeZero(QUEUE_PROPERTY_PADDING); }//from w w w .j a v a2s. co m queuePropertyBuff.setShort(QUEUE_PROPERTY_LENGTH_INDEX, queuePropertyBuff.readableBytes()); queueBuff.writeBytes(queuePropertyBuff); } queueBuff.setShort(QUEUE_LENGTH_INDEX, queueBuff.readableBytes()); outBuffer.writeBytes(queueBuff); } 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 ww w. j av 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 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()); }//from w ww .j a v a2 s. co m }
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*/ }