List of usage examples for io.netty.buffer ByteBuf readUnsignedInt
public abstract long readUnsignedInt();
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10StatsReplyMessageFactory.java
License:Open Source License
@Override public MultipartReplyMessage bufferToMessage(ByteBuf rawMessage, short version) { MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder(); builder.setVersion(version);/*from www . ja v a 2s . co m*/ builder.setXid(rawMessage.readUnsignedInt()); int type = rawMessage.readUnsignedShort(); builder.setType(MultipartType.forValue(type)); builder.setFlags(new MultipartRequestFlags((rawMessage.readUnsignedShort() & 0x01) != 0)); switch (type) { case 0: builder.setMultipartReplyBody(setDesc(rawMessage)); break; case 1: builder.setMultipartReplyBody(setFlow(rawMessage)); break; case 2: builder.setMultipartReplyBody(setAggregate(rawMessage)); break; case 3: builder.setMultipartReplyBody(setTable(rawMessage)); break; case 4: builder.setMultipartReplyBody(setPortStats(rawMessage)); break; case 5: builder.setMultipartReplyBody(setQueue(rawMessage)); break; case 0xFFFF: builder.setMultipartReplyBody(setExperimenter(rawMessage)); break; default: break; } return builder.build(); }
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 w w w . ja va2 s . c o m*/ 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);// w ww. j a v a 2s. c o m 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 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);/*w w w . jav a 2 s .c o m*/ 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(); }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10StatsReplyMessageFactory.java
License:Open Source License
private static MultipartReplyExperimenterCase setExperimenter(ByteBuf input) { MultipartReplyExperimenterCaseBuilder caseBuilder = new MultipartReplyExperimenterCaseBuilder(); MultipartReplyExperimenterBuilder builder = new MultipartReplyExperimenterBuilder(); builder.setExperimenter(input.readUnsignedInt()); byte[] data = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(data);/*from ww w . j a va2 s . com*/ builder.setData(data); caseBuilder.setMultipartReplyExperimenter(builder.build()); return caseBuilder.build(); }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10VendorMessageFactory.java
License:Open Source License
@Override public ExperimenterMessage bufferToMessage(ByteBuf rawMessage, short version) { ExperimenterMessageBuilder builder = new ExperimenterMessageBuilder(); builder.setVersion(version);//from ww w .ja v a2 s. c o m builder.setXid(rawMessage.readUnsignedInt()); builder.setExperimenter(rawMessage.readUnsignedInt()); 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.PacketInMessageFactory.java
License:Open Source License
@Override public PacketInMessage bufferToMessage(ByteBuf rawMessage, short version) { PacketInMessageBuilder builder = new PacketInMessageBuilder(); builder.setVersion(version);/*from w w w . j a v a 2s . co m*/ builder.setXid(rawMessage.readUnsignedInt()); builder.setBufferId(rawMessage.readUnsignedInt()); builder.setTotalLen(rawMessage.readUnsignedShort()); builder.setReason(PacketInReason.forValue(rawMessage.readUnsignedByte())); builder.setTableId(new TableId((long) rawMessage.readUnsignedByte())); byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; rawMessage.readBytes(cookie); builder.setCookie(new BigInteger(1, cookie)); builder.setMatch(MatchDeserializer.createMatch(rawMessage)); rawMessage.skipBytes(PADDING_IN_PACKET_IN_HEADER); builder.setData(rawMessage.readBytes(rawMessage.readableBytes()).array()); return builder.build(); }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.PacketOutInputMessageFactory.java
License:Open Source License
@Override public PacketOutInput deserialize(ByteBuf rawMessage) { PacketOutInputBuilder builder = new PacketOutInputBuilder(); builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); builder.setXid(rawMessage.readUnsignedInt()); builder.setBufferId(rawMessage.readUnsignedInt()); builder.setInPort(new PortNumber(rawMessage.readUnsignedInt())); int actions_len = rawMessage.readShort(); rawMessage.skipBytes(PADDING);/*from ww w . ja v a 2s . c o m*/ CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID); List<Action> actions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, actions_len, rawMessage, keyMaker, registry); builder.setAction(actions); byte[] data = new byte[rawMessage.readableBytes()]; rawMessage.readBytes(data); if (data != null) { builder.setData(data); } return builder.build(); }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.PortModInputMessageFactory.java
License:Open Source License
@Override public PortModInput deserialize(final ByteBuf rawMessage) { PortModInputBuilder builder = new PortModInputBuilder(); builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); builder.setXid(rawMessage.readUnsignedInt()); builder.setPortNo(new PortNumber(rawMessage.readUnsignedInt())); rawMessage.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_1); builder.setHwAddress(ByteBufUtils.readIetfMacAddress(rawMessage)); rawMessage.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_2); builder.setConfig(createPortConfig(rawMessage.readUnsignedInt())); builder.setMask(createPortConfig(rawMessage.readUnsignedInt())); builder.setAdvertise(createPortFeatures(rawMessage.readUnsignedInt())); rawMessage.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_3); return builder.build(); }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.PortStatusMessageFactory.java
License:Open Source License
@Override public PortStatusMessage bufferToMessage(ByteBuf rawMessage, short version) { PortStatusMessageBuilder builder = new PortStatusMessageBuilder(); builder.setVersion(version);/*from ww w. j a v a 2 s . com*/ builder.setXid(rawMessage.readUnsignedInt()); builder.setReason(PortReason.forValue(rawMessage.readUnsignedByte())); rawMessage.skipBytes(PADDING_IN_PORT_STATUS_HEADER); builder.setPortNo(rawMessage.readUnsignedInt()); rawMessage.skipBytes(PADDING_IN_OFP_PORT_HEADER_1); byte[] hwAddress = new byte[EncodeConstants.MAC_ADDRESS_LENGTH]; rawMessage.readBytes(hwAddress); builder.setHwAddr(new MacAddress(ByteBufUtils.macAddressToString(hwAddress))); rawMessage.skipBytes(PADDING_IN_OFP_PORT_HEADER_2); builder.setName(ByteBufUtils.decodeNullTerminatedString(rawMessage, EncodeConstants.MAX_PORT_NAME_LENGTH)); builder.setConfig(createPortConfig(rawMessage.readUnsignedInt())); builder.setState(createPortState(rawMessage.readUnsignedInt())); builder.setCurrentFeatures(createPortFeatures(rawMessage.readUnsignedInt())); builder.setAdvertisedFeatures(createPortFeatures(rawMessage.readUnsignedInt())); builder.setSupportedFeatures(createPortFeatures(rawMessage.readUnsignedInt())); builder.setPeerFeatures(createPortFeatures(rawMessage.readUnsignedInt())); builder.setCurrSpeed(rawMessage.readUnsignedInt()); builder.setMaxSpeed(rawMessage.readUnsignedInt()); return builder.build(); }