List of usage examples for io.netty.buffer ByteBuf writeLong
public abstract ByteBuf writeLong(long value);
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartReplyMessageFactory.java
License:Open Source License
private void serializeTableBody(final MultipartReplyBody body, final ByteBuf outBuffer) { MultipartReplyTableCase tableCase = (MultipartReplyTableCase) body; MultipartReplyTable table = tableCase.getMultipartReplyTable(); for (TableStats tableStats : table.getTableStats()) { outBuffer.writeByte(tableStats.getTableId()); outBuffer.writeZero(TABLE_PADDING); outBuffer.writeInt(tableStats.getActiveCount().intValue()); outBuffer.writeLong(tableStats.getLookupCount().longValue()); outBuffer.writeLong(tableStats.getMatchedCount().longValue()); }//from www . j a v a2s . c o m }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartReplyMessageFactory.java
License:Open Source License
private void serializeAggregateBody(final MultipartReplyBody body, final ByteBuf outBuffer) { MultipartReplyAggregateCase aggregateCase = (MultipartReplyAggregateCase) body; MultipartReplyAggregate aggregate = aggregateCase.getMultipartReplyAggregate(); outBuffer.writeLong(aggregate.getPacketCount().longValue()); outBuffer.writeLong(aggregate.getByteCount().longValue()); outBuffer.writeInt(aggregate.getFlowCount().intValue()); outBuffer.writeZero(AGGREGATE_PADDING); }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartReplyMessageFactory.java
License:Open Source License
private void serializeFlowBody(final MultipartReplyBody body, final ByteBuf outBuffer, final 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 w w w . ja v a2 s .c om }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory.java
License:Open Source License
private static void encodeFlowBody(MultipartRequestBody multipartRequestBody, ByteBuf output) { MultipartRequestFlowCase flowCase = (MultipartRequestFlowCase) multipartRequestBody; MultipartRequestFlow flow = flowCase.getMultipartRequestFlow(); output.writeByte(flow.getTableId().byteValue()); ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_01, output); output.writeInt(flow.getOutPort().intValue()); output.writeInt(flow.getOutGroup().intValue()); ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_02, output); output.writeLong(flow.getCookie().longValue()); output.writeLong(flow.getCookieMask().longValue()); MatchSerializer.encodeMatch(flow.getMatch(), output); }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory.java
License:Open Source License
private static void encodeAggregateBody(MultipartRequestBody multipartRequestBody, ByteBuf output) { MultipartRequestAggregateCase aggregateCase = (MultipartRequestAggregateCase) multipartRequestBody; MultipartRequestAggregate aggregate = aggregateCase.getMultipartRequestAggregate(); output.writeByte(aggregate.getTableId().byteValue()); ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_AGREGGATE_BODY_01, output); output.writeInt(aggregate.getOutPort().intValue()); output.writeInt(aggregate.getOutGroup().intValue()); ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_AGREGGATE_BODY_02, output); output.writeLong(aggregate.getCookie().longValue()); output.writeLong(aggregate.getCookieMask().longValue()); MatchSerializer.encodeMatch(aggregate.getMatch(), output); }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory.java
License:Open Source License
private static void encodeTableFeaturesBody(MultipartRequestBody multipartRequestBody, ByteBuf output) { if (multipartRequestBody != null) { MultipartRequestTableFeaturesCase tableFeaturesCase = (MultipartRequestTableFeaturesCase) multipartRequestBody; MultipartRequestTableFeatures tableFeatures = tableFeaturesCase.getMultipartRequestTableFeatures(); if (tableFeatures.getTableFeatures() != null) { for (TableFeatures currTableFeature : tableFeatures.getTableFeatures()) { int length = computeSingleTableFeatureLength(currTableFeature); length += paddingNeeded(length); output.writeShort(length); output.writeByte(currTableFeature.getTableId()); ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_TABLE_FEATURES_BODY, output); output.writeBytes(currTableFeature.getName().getBytes()); ByteBufUtils.padBuffer((32 - currTableFeature.getName().getBytes().length), output); output.writeLong(currTableFeature.getMetadataMatch().longValue()); output.writeLong(currTableFeature.getMetadataWrite().longValue()); output.writeInt(createTableConfigBitmask(currTableFeature.getConfig())); output.writeInt(currTableFeature.getMaxEntries().intValue()); writeTableFeatureProperties(output, currTableFeature.getTableFeatureProperties()); }//ww w . ja v a2 s . com } } }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10FeaturesReplyMessageFactory.java
License:Open Source License
@Override public void serialize(final GetFeaturesOutput message, final 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 www.ja v a2 s .c om outBuffer.writeInt(createCapabilities(message.getCapabilitiesV10())); outBuffer.writeInt(createActionsV10(message.getActionsV10())); for (PhyPort port : message.getPhyPort()) { outBuffer.writeShort(port.getPortNo().intValue()); outBuffer.writeBytes(IetfYangUtil.INSTANCE.bytesFor(port.getHwAddr())); 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.openflowjava.protocol.impl.serialization.factories.OF10FlowModInputMessageFactory.java
License:Open Source License
@Override public void messageToBuffer(short version, ByteBuf out, FlowModInput message) { ByteBufUtils.writeOFHeader(instance, message, out); OF10MatchSerializer.encodeMatchV10(out, message.getMatchV10()); out.writeLong(message.getCookie().longValue()); out.writeShort(message.getCommand().getIntValue()); out.writeShort(message.getIdleTimeout().intValue()); out.writeShort(message.getHardTimeout().intValue()); out.writeShort(message.getPriority()); out.writeInt(message.getBufferId().intValue()); out.writeShort(message.getOutPort().getValue().intValue()); out.writeShort(createFlowModFlagsBitmask(message.getFlagsV10())); OF10ActionsSerializer.encodeActionsV10(out, message.getAction()); }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.RoleRequestInputMessageFactory.java
License:Open Source License
@Override public void messageToBuffer(short version, ByteBuf out, RoleRequestInput message) { ByteBufUtils.writeOFHeader(instance, message, out); out.writeInt(message.getRole().getIntValue()); ByteBufUtils.padBuffer(PADDING_IN_ROLE_REQUEST_MESSAGE, out); out.writeLong(message.getGenerationId().longValue()); }
From source file:org.opendaylight.protocol.bgp.flowspec.handlers.Util.java
License:Open Source License
/** * Given the integer values, this method instead of writing the value * in 4B field, compresses the value to lowest required byte field * depending on the value.//w w w .ja v a 2 s . co m * * @param value integer to be written * @param buffer ByteBuf where the value will be written */ public static void writeShortest(final int value, final ByteBuf buffer) { if (value <= Values.UNSIGNED_BYTE_MAX_VALUE) { buffer.writeByte(UnsignedBytes.checkedCast(value)); } else if (value <= Values.UNSIGNED_SHORT_MAX_VALUE) { ByteBufWriteUtil.writeUnsignedShort(value, buffer); } else if (value <= Values.UNSIGNED_INT_MAX_VALUE) { ByteBufWriteUtil.writeUnsignedInt(UnsignedInts.toLong(value), buffer); } else { buffer.writeLong(value); } }