use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10 in project openflowplugin by opendaylight.
the class OF10StatsRequestInputFactory method serializeAggregateBody.
private void serializeAggregateBody(final MultipartRequestBody multipartRequestBody, final ByteBuf output) {
MultipartRequestAggregateCase aggregateCase = (MultipartRequestAggregateCase) multipartRequestBody;
MultipartRequestAggregate aggregate = aggregateCase.getMultipartRequestAggregate();
OFSerializer<MatchV10> matchSerializer = registry.getSerializer(new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, MatchV10.class));
matchSerializer.serialize(aggregate.getMatchV10(), output);
output.writeByte(aggregate.getTableId().shortValue());
output.writeZero(PADDING_IN_MULTIPART_REQUEST_AGGREGATE_BODY);
output.writeShort(aggregate.getOutPort().intValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10 in project openflowplugin by opendaylight.
the class OF10MatchSerializerTest method test.
/**
* Testing correct serialization of ofp_match.
*/
@Test
public void test() {
final ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
MatchV10Builder builder = new MatchV10Builder();
builder.setWildcards(new FlowWildcardsV10(false, false, true, false, false, true, false, true, true, true));
builder.setNwSrcMask((short) 24);
builder.setNwDstMask((short) 16);
builder.setInPort(6653);
builder.setDlSrc(new MacAddress("01:01:01:01:01:01"));
builder.setDlDst(new MacAddress("02:02:02:02:02:02"));
builder.setDlVlan(128);
builder.setDlVlanPcp((short) 2);
builder.setDlType(15);
builder.setNwTos((short) 14);
builder.setNwProto((short) 85);
builder.setNwSrc(new Ipv4Address("1.1.1.2"));
builder.setNwDst(new Ipv4Address("32.16.8.1"));
builder.setTpSrc(2048);
builder.setTpDst(4096);
MatchV10 match = builder.build();
matchSerializer.serialize(match, out);
Assert.assertEquals("Wrong wildcards", 2361553, out.readUnsignedInt());
Assert.assertEquals("Wrong in-port", 6653, out.readUnsignedShort());
byte[] dlSrc = new byte[6];
out.readBytes(dlSrc);
Assert.assertEquals("Wrong dl-src", "01:01:01:01:01:01", ByteBufUtils.macAddressToString(dlSrc));
byte[] dlDst = new byte[6];
out.readBytes(dlDst);
Assert.assertEquals("Wrong dl-dst", "02:02:02:02:02:02", ByteBufUtils.macAddressToString(dlDst));
Assert.assertEquals("Wrong dl-vlan", 128, out.readUnsignedShort());
Assert.assertEquals("Wrong dl-vlan-pcp", 2, out.readUnsignedByte());
out.skipBytes(1);
Assert.assertEquals("Wrong dl-type", 15, out.readUnsignedShort());
Assert.assertEquals("Wrong nw-tos", 14, out.readUnsignedByte());
Assert.assertEquals("Wrong nw-proto", 85, out.readUnsignedByte());
out.skipBytes(2);
Assert.assertEquals("Wrong nw-src", 16843010, out.readUnsignedInt());
Assert.assertEquals("Wrong nw-dst", 537921537, out.readUnsignedInt());
Assert.assertEquals("Wrong tp-src", 2048, out.readUnsignedShort());
Assert.assertEquals("Wrong tp-dst", 4096, out.readUnsignedShort());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10 in project openflowplugin by opendaylight.
the class OF10MatchSerializerTest method test2.
/**
* Testing correct serialization of ofp_match.
*/
@Test
public void test2() {
final ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
MatchV10Builder builder = new MatchV10Builder();
builder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true));
builder.setNwSrcMask((short) 0);
builder.setNwDstMask((short) 0);
builder.setInPort(6653);
builder.setDlSrc(new MacAddress("01:01:01:01:01:01"));
builder.setDlDst(new MacAddress("02:02:02:02:02:02"));
builder.setDlVlan(128);
builder.setDlVlanPcp((short) 2);
builder.setDlType(15);
builder.setNwTos((short) 14);
builder.setNwProto((short) 85);
builder.setNwSrc(new Ipv4Address("1.1.1.2"));
builder.setNwDst(new Ipv4Address("32.16.8.1"));
builder.setTpSrc(2048);
builder.setTpDst(4096);
MatchV10 match = builder.build();
matchSerializer.serialize(match, out);
Assert.assertEquals("Wrong wildcards", 3678463, out.readUnsignedInt());
Assert.assertEquals("Wrong in-port", 6653, out.readUnsignedShort());
byte[] dlSrc = new byte[6];
out.readBytes(dlSrc);
Assert.assertEquals("Wrong dl-src", "01:01:01:01:01:01", ByteBufUtils.macAddressToString(dlSrc));
byte[] dlDst = new byte[6];
out.readBytes(dlDst);
Assert.assertEquals("Wrong dl-dst", "02:02:02:02:02:02", ByteBufUtils.macAddressToString(dlDst));
Assert.assertEquals("Wrong dl-vlan", 128, out.readUnsignedShort());
Assert.assertEquals("Wrong dl-vlan-pcp", 2, out.readUnsignedByte());
out.skipBytes(1);
Assert.assertEquals("Wrong dl-type", 15, out.readUnsignedShort());
Assert.assertEquals("Wrong nw-tos", 14, out.readUnsignedByte());
Assert.assertEquals("Wrong nw-proto", 85, out.readUnsignedByte());
out.skipBytes(2);
Assert.assertEquals("Wrong nw-src", 16843010, out.readUnsignedInt());
Assert.assertEquals("Wrong nw-dst", 537921537, out.readUnsignedInt());
Assert.assertEquals("Wrong tp-src", 2048, out.readUnsignedShort());
Assert.assertEquals("Wrong tp-dst", 4096, out.readUnsignedShort());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10 in project openflowplugin by opendaylight.
the class OF10StatsReplyMessageFactory method serializeFlowBody.
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((byte) flowStats.getTableId().longValue());
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);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10 in project openflowplugin by opendaylight.
the class SerializerRegistryImpl method init.
@Override
public void init() {
registry = new HashMap<>();
// Openflow message type serializers
MessageFactoryInitializer.registerMessageSerializers(this);
// Register Additional serializers
AdditionalMessageFactoryInitializer.registerMessageSerializers(this);
// match structure serializers
registerSerializer(new MessageTypeKey<>(OF10, MatchV10.class), new OF10MatchSerializer());
registerSerializer(new MessageTypeKey<>(OF13, Match.class), new OF13MatchSerializer());
// match entry serializers
MatchEntriesInitializer.registerMatchEntrySerializers(this);
// action serializers
ActionsInitializer.registerActionSerializers(this);
// instruction serializers
InstructionsInitializer.registerInstructionSerializers(this);
}
Aggregations