List of usage examples for io.netty.buffer ByteBuf skipBytes
public abstract ByteBuf skipBytes(int length);
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10HelloMessageFactory.java
License:Open Source License
@Override public HelloMessage bufferToMessage(ByteBuf rawMessage, short version) { HelloMessageBuilder builder = new HelloMessageBuilder(); builder.setVersion(version);//from w ww .ja v a 2 s . c o m builder.setXid(rawMessage.readUnsignedInt()); if (rawMessage.readableBytes() > 0) { rawMessage.skipBytes(rawMessage.readableBytes()); } return builder.build(); }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10PacketInMessageFactory.java
License:Open Source License
@Override public PacketInMessage bufferToMessage(ByteBuf rawMessage, short version) { PacketInMessageBuilder builder = new PacketInMessageBuilder(); builder.setVersion(version);//from w w w. ja va 2s . c o m builder.setXid(rawMessage.readUnsignedInt()); builder.setBufferId(rawMessage.readUnsignedInt()); builder.setTotalLen(rawMessage.readUnsignedShort()); builder.setInPort(rawMessage.readUnsignedShort()); builder.setReason(PacketInReason.forValue(rawMessage.readUnsignedByte())); rawMessage.skipBytes(PADDING_IN_PACKET_IN_HEADER); int remainingBytes = rawMessage.readableBytes(); if (remainingBytes > 0) { builder.setData(rawMessage.readBytes(remainingBytes).array()); } return builder.build(); }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10PortStatusMessageFactory.java
License:Open Source License
@Override public PortStatusMessage bufferToMessage(ByteBuf rawMessage, short version) { PortStatusMessageBuilder builder = new PortStatusMessageBuilder(); builder.setVersion(version);// w w w . j a v a 2 s .co m builder.setXid(rawMessage.readUnsignedInt()); builder.setReason(PortReason.forValue(rawMessage.readUnsignedByte())); rawMessage.skipBytes(PADDING_IN_PORT_STATUS_HEADER); deserializePort(rawMessage, builder); return builder.build(); }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10QueueGetConfigReplyMessageFactory.java
License:Open Source License
@Override public GetQueueConfigOutput bufferToMessage(ByteBuf rawMessage, short version) { GetQueueConfigOutputBuilder builder = new GetQueueConfigOutputBuilder(); builder.setVersion(version);/*www . j av a 2s . c om*/ builder.setXid((rawMessage.readUnsignedInt())); builder.setPort(new PortNumber((long) rawMessage.readUnsignedShort())); rawMessage.skipBytes(PADDING_IN_QUEUE_GET_CONFIG_REPLY_HEADER); builder.setQueues(createQueuesList(rawMessage)); return builder.build(); }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10QueueGetConfigReplyMessageFactory.java
License:Open Source License
private static List<Queues> createQueuesList(ByteBuf input) { List<Queues> queuesList = new ArrayList<>(); while (input.readableBytes() > 0) { QueuesBuilder queueBuilder = new QueuesBuilder(); queueBuilder.setQueueId(new QueueId(input.readUnsignedInt())); int length = input.readUnsignedShort(); input.skipBytes(PADDING_IN_PACKET_QUEUE_HEADER); queueBuilder.setQueueProperty(createPropertiesList(input, length - PACKET_QUEUE_HEADER_LENGTH)); queuesList.add(queueBuilder.build()); }// w w w .j a va 2s . com return queuesList; }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10QueueGetConfigReplyMessageFactory.java
License:Open Source License
private static List<QueueProperty> createPropertiesList(ByteBuf input, int length) { int propertiesLength = length; List<QueueProperty> propertiesList = new ArrayList<>(); while (propertiesLength > 0) { QueuePropertyBuilder propertiesBuilder = new QueuePropertyBuilder(); QueueProperties property = QueueProperties.forValue(input.readUnsignedShort()); propertiesBuilder.setProperty(property); propertiesLength -= input.readUnsignedShort(); input.skipBytes(PADDING_IN_QUEUE_PROPERTY_HEADER); if (property.equals(QueueProperties.OFPQTMINRATE)) { RateQueuePropertyBuilder rateBuilder = new RateQueuePropertyBuilder(); rateBuilder.setRate(input.readUnsignedShort()); propertiesBuilder.addAugmentation(RateQueueProperty.class, rateBuilder.build()); input.skipBytes(PADDING_IN_RATE_QUEUE_PROPERTY); }/*ww w. java 2 s . com*/ propertiesList.add(propertiesBuilder.build()); } return propertiesList; }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10StatsReplyMessageFactory.java
License:Open Source License
private static MultipartReplyFlowCase setFlow(ByteBuf input) { MultipartReplyFlowCaseBuilder caseBuilder = new MultipartReplyFlowCaseBuilder(); MultipartReplyFlowBuilder flowBuilder = new MultipartReplyFlowBuilder(); List<FlowStats> flowStatsList = new ArrayList<>(); while (input.readableBytes() > 0) { FlowStatsBuilder flowStatsBuilder = new FlowStatsBuilder(); int length = input.readUnsignedShort(); flowStatsBuilder.setTableId(input.readUnsignedByte()); input.skipBytes(PADDING_IN_FLOW_STATS_HEADER); flowStatsBuilder.setMatchV10(OF10MatchDeserializer.createMatchV10(input)); flowStatsBuilder.setDurationSec(input.readUnsignedInt()); flowStatsBuilder.setDurationNsec(input.readUnsignedInt()); flowStatsBuilder.setPriority(input.readUnsignedShort()); flowStatsBuilder.setIdleTimeout(input.readUnsignedShort()); flowStatsBuilder.setHardTimeout(input.readUnsignedShort()); input.skipBytes(PADDING_IN_FLOW_STATS_HEADER_02); byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(cookie);//from ww w . j a v a2 s . c om flowStatsBuilder.setCookie(new BigInteger(1, cookie)); byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(packetCount); flowStatsBuilder.setPacketCount(new BigInteger(1, packetCount)); byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(byteCount); flowStatsBuilder.setByteCount(new BigInteger(1, byteCount)); flowStatsBuilder .setAction(OF10ActionsDeserializer.createActionsList(input, length - LENGTH_OF_FLOW_STATS)); flowStatsList.add(flowStatsBuilder.build()); } flowBuilder.setFlowStats(flowStatsList); caseBuilder.setMultipartReplyFlow(flowBuilder.build()); return caseBuilder.build(); }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10StatsReplyMessageFactory.java
License:Open Source License
private static MultipartReplyTableCase setTable(ByteBuf input) { MultipartReplyTableCaseBuilder caseBuilder = new MultipartReplyTableCaseBuilder(); MultipartReplyTableBuilder builder = new MultipartReplyTableBuilder(); List<TableStats> tableStatsList = new ArrayList<>(); // TODO - replace ">= TABLE_STATS_LENGTH" with "> 0" after fix in OVS switch while (input.readableBytes() >= TABLE_STATS_LENGTH) { TableStatsBuilder tableStatsBuilder = new TableStatsBuilder(); tableStatsBuilder.setTableId(input.readUnsignedByte()); input.skipBytes(PADDING_IN_TABLE_HEADER); tableStatsBuilder.setName(ByteBufUtils.decodeNullTerminatedString(input, MAX_TABLE_NAME_LENGTH)); long wildcards = input.readUnsignedInt(); tableStatsBuilder.setWildcards(OF10MatchDeserializer.createWildcards(wildcards)); tableStatsBuilder.setNwSrcMask(OF10MatchDeserializer.decodeNwSrcMask(wildcards)); tableStatsBuilder.setNwDstMask(OF10MatchDeserializer.decodeNwDstMask(wildcards)); tableStatsBuilder.setMaxEntries(input.readUnsignedInt()); tableStatsBuilder.setActiveCount(input.readUnsignedInt()); byte[] lookupCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(lookupCount);//from w ww . ja v a2 s . com tableStatsBuilder.setLookupCount(new BigInteger(1, lookupCount)); byte[] matchedCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(matchedCount); tableStatsBuilder.setMatchedCount(new BigInteger(1, matchedCount)); tableStatsList.add(tableStatsBuilder.build()); } input.skipBytes(input.readableBytes()); builder.setTableStats(tableStatsList); caseBuilder.setMultipartReplyTable(builder.build()); return caseBuilder.build(); }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10StatsReplyMessageFactory.java
License:Open Source License
private static MultipartReplyPortStatsCase setPortStats(ByteBuf input) { MultipartReplyPortStatsCaseBuilder caseBuilder = new MultipartReplyPortStatsCaseBuilder(); MultipartReplyPortStatsBuilder builder = new MultipartReplyPortStatsBuilder(); List<PortStats> portStatsList = new ArrayList<>(); while (input.readableBytes() > 0) { PortStatsBuilder portStatsBuilder = new PortStatsBuilder(); portStatsBuilder.setPortNo((long) input.readUnsignedShort()); input.skipBytes(PADDING_IN_PORT_STATS_HEADER); byte[] rxPackets = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(rxPackets);//from w ww .j a v a 2s. c o m portStatsBuilder.setRxPackets(new BigInteger(1, rxPackets)); byte[] txPackets = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(txPackets); portStatsBuilder.setTxPackets(new BigInteger(1, txPackets)); byte[] rxBytes = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(rxBytes); portStatsBuilder.setRxBytes(new BigInteger(1, rxBytes)); byte[] txBytes = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(txBytes); portStatsBuilder.setTxBytes(new BigInteger(1, txBytes)); byte[] rxDropped = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(rxDropped); portStatsBuilder.setRxDropped(new BigInteger(1, rxDropped)); byte[] txDropped = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(txDropped); portStatsBuilder.setTxDropped(new BigInteger(1, txDropped)); byte[] rxErrors = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(rxErrors); portStatsBuilder.setRxErrors(new BigInteger(1, rxErrors)); byte[] txErrors = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(txErrors); portStatsBuilder.setTxErrors(new BigInteger(1, txErrors)); byte[] rxFrameErr = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(rxFrameErr); portStatsBuilder.setRxFrameErr(new BigInteger(1, rxFrameErr)); byte[] rxOverErr = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(rxOverErr); portStatsBuilder.setRxOverErr(new BigInteger(1, rxOverErr)); byte[] rxCrcErr = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(rxCrcErr); portStatsBuilder.setRxCrcErr(new BigInteger(1, rxCrcErr)); byte[] collisions = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(collisions); portStatsBuilder.setCollisions(new BigInteger(1, collisions)); portStatsList.add(portStatsBuilder.build()); } builder.setPortStats(portStatsList); caseBuilder.setMultipartReplyPortStats(builder.build()); return caseBuilder.build(); }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10StatsReplyMessageFactory.java
License:Open Source License
private static MultipartReplyQueueCase setQueue(ByteBuf input) { MultipartReplyQueueCaseBuilder caseBuilder = new MultipartReplyQueueCaseBuilder(); MultipartReplyQueueBuilder builder = new MultipartReplyQueueBuilder(); List<QueueStats> queueStatsList = new ArrayList<>(); while (input.readableBytes() > 0) { QueueStatsBuilder queueStatsBuilder = new QueueStatsBuilder(); queueStatsBuilder.setPortNo((long) input.readUnsignedShort()); input.skipBytes(PADDING_IN_QUEUE_HEADER); queueStatsBuilder.setQueueId(input.readUnsignedInt()); byte[] txBytes = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(txBytes);/*from w w w . j a v a 2 s . c om*/ queueStatsBuilder.setTxBytes(new BigInteger(1, txBytes)); byte[] txPackets = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(txPackets); queueStatsBuilder.setTxPackets(new BigInteger(1, txPackets)); byte[] txErrors = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(txErrors); queueStatsBuilder.setTxErrors(new BigInteger(1, txErrors)); queueStatsList.add(queueStatsBuilder.build()); } builder.setQueueStats(queueStatsList); caseBuilder.setMultipartReplyQueue(builder.build()); return caseBuilder.build(); }