Search in sources :

Example 11 with MatchV10Builder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder in project openflowplugin by opendaylight.

the class OF10FlowRemovedMessageFactoryTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    FlowRemovedMessageBuilder builder = new FlowRemovedMessageBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
    MatchV10Builder matchBuilder = new MatchV10Builder();
    matchBuilder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true));
    matchBuilder.setNwSrcMask((short) 0);
    matchBuilder.setNwDstMask((short) 0);
    matchBuilder.setInPort(58);
    matchBuilder.setDlSrc(new MacAddress("01:01:01:01:01:01"));
    matchBuilder.setDlDst(new MacAddress("ff:ff:ff:ff:ff:ff"));
    matchBuilder.setDlVlan(18);
    matchBuilder.setDlVlanPcp((short) 5);
    matchBuilder.setDlType(42);
    matchBuilder.setNwTos((short) 4);
    matchBuilder.setNwProto((short) 7);
    matchBuilder.setNwSrc(new Ipv4Address("8.8.8.8"));
    matchBuilder.setNwDst(new Ipv4Address("16.16.16.16"));
    matchBuilder.setTpSrc(6653);
    matchBuilder.setTpDst(6633);
    builder.setMatchV10(matchBuilder.build());
    byte[] cookie = new byte[] { (byte) 0xFF, 0x01, 0x04, 0x01, 0x01, 0x01, 0x04, 0x01 };
    builder.setCookie(new BigInteger(1, cookie));
    builder.setPriority(1);
    builder.setReason(FlowRemovedReason.forValue(1));
    builder.setDurationSec(1L);
    builder.setDurationNsec(1L);
    builder.setIdleTimeout(12);
    builder.setPacketCount(BigInteger.valueOf(1L));
    builder.setByteCount(BigInteger.valueOf(2L));
    FlowRemovedMessage message = builder.build();
    ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, serializedBuffer);
    BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 88);
    Assert.assertEquals("Wrong wildcards", 3678463, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong inPort", 58, serializedBuffer.readUnsignedShort());
    byte[] dlSrc = new byte[6];
    serializedBuffer.readBytes(dlSrc);
    Assert.assertEquals("Wrong dlSrc", "01:01:01:01:01:01", ByteBufUtils.macAddressToString(dlSrc));
    byte[] dlDst = new byte[6];
    serializedBuffer.readBytes(dlDst);
    Assert.assertEquals("Wrong dlDst", "FF:FF:FF:FF:FF:FF", ByteBufUtils.macAddressToString(dlDst));
    Assert.assertEquals("Wrong dlVlan", 18, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong dlVlanPcp", 5, serializedBuffer.readUnsignedByte());
    serializedBuffer.skipBytes(1);
    Assert.assertEquals("Wrong dlType", 42, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong nwTos", 4, serializedBuffer.readUnsignedByte());
    Assert.assertEquals("Wrong nwProto", 7, serializedBuffer.readUnsignedByte());
    serializedBuffer.skipBytes(2);
    Assert.assertEquals("Wrong nwSrc", 134744072, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong nwDst", 269488144, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong tpSrc", 6653, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong tpDst", 6633, serializedBuffer.readUnsignedShort());
    byte[] cookieRead = new byte[8];
    serializedBuffer.readBytes(cookieRead);
    Assert.assertArrayEquals("Wrong cookie", cookie, cookieRead);
    Assert.assertEquals("Wrong priority", 1, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong reason", 1, serializedBuffer.readUnsignedByte());
    serializedBuffer.skipBytes(1);
    Assert.assertEquals("Wrong duration", 1L, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong duration nsec", 1L, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong idle timeout", 12, serializedBuffer.readUnsignedShort());
    serializedBuffer.skipBytes(2);
    Assert.assertEquals("Wrong packet count", 1L, serializedBuffer.readLong());
    Assert.assertEquals("Wrong byte count", 2L, serializedBuffer.readLong());
}
Also used : FlowRemovedMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage) FlowWildcardsV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10) MatchV10Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder) BigInteger(java.math.BigInteger) FlowRemovedMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) ByteBuf(io.netty.buffer.ByteBuf) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Test(org.junit.Test)

Example 12 with MatchV10Builder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder in project openflowplugin by opendaylight.

the class OF10StatsReplyMessageFactoryTest method createFlowStats.

private static List<FlowStats> createFlowStats() {
    FlowStatsBuilder builder = new FlowStatsBuilder();
    builder.setTableId((short) 1);
    MatchV10Builder matchBuilder = new MatchV10Builder();
    matchBuilder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true));
    matchBuilder.setNwSrcMask((short) 0);
    matchBuilder.setNwDstMask((short) 0);
    matchBuilder.setInPort(58);
    matchBuilder.setDlSrc(new MacAddress("01:01:01:01:01:01"));
    matchBuilder.setDlDst(new MacAddress("ff:ff:ff:ff:ff:ff"));
    matchBuilder.setDlVlan(18);
    matchBuilder.setDlVlanPcp((short) 5);
    matchBuilder.setDlType(42);
    matchBuilder.setNwTos((short) 4);
    matchBuilder.setNwProto((short) 7);
    matchBuilder.setNwSrc(new Ipv4Address("8.8.8.8"));
    matchBuilder.setNwDst(new Ipv4Address("16.16.16.16"));
    matchBuilder.setTpSrc(6653);
    matchBuilder.setTpDst(6633);
    builder.setMatchV10(matchBuilder.build());
    builder.setDurationSec(1L);
    builder.setDurationNsec(2L);
    builder.setPriority(1);
    builder.setIdleTimeout(1);
    builder.setHardTimeout(1);
    builder.setCookie(BigInteger.valueOf(1234L));
    builder.setPacketCount(BigInteger.valueOf(1234L));
    builder.setByteCount(BigInteger.valueOf(1234L));
    final List<Action> actions = new ArrayList<>();
    final ActionBuilder actionBuilder = new ActionBuilder();
    OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder();
    OutputActionBuilder outputBuilder = new OutputActionBuilder();
    outputBuilder.setPort(new PortNumber(42L));
    outputBuilder.setMaxLength(50);
    caseBuilder.setOutputAction(outputBuilder.build());
    actionBuilder.setActionChoice(caseBuilder.build());
    actions.add(actionBuilder.build());
    builder.setAction(actions);
    List<FlowStats> list = new ArrayList<>();
    list.add(builder.build());
    return list;
}
Also used : OutputActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action) OutputActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder) ArrayList(java.util.ArrayList) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) FlowStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats) FlowStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStatsBuilder) FlowWildcardsV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10) MatchV10Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder) OutputActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)

Example 13 with MatchV10Builder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder in project openflowplugin by opendaylight.

the class OF10StatsRequestAggregateTest method test.

/**
 * Tests {@link OF10StatsRequestInputFactory} for correct serialization.
 */
@Test
public void test() throws Exception {
    MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
    builder.setType(MultipartType.OFPMPAGGREGATE);
    builder.setFlags(new MultipartRequestFlags(false));
    final MultipartRequestAggregateCaseBuilder caseBuilder = new MultipartRequestAggregateCaseBuilder();
    final MultipartRequestAggregateBuilder aggBuilder = new MultipartRequestAggregateBuilder();
    MatchV10Builder matchBuilder = new MatchV10Builder();
    matchBuilder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true));
    matchBuilder.setNwSrcMask((short) 8);
    matchBuilder.setNwDstMask((short) 16);
    matchBuilder.setInPort(51);
    matchBuilder.setDlSrc(new MacAddress("00:01:02:03:04:05"));
    matchBuilder.setDlDst(new MacAddress("05:04:03:02:01:00"));
    matchBuilder.setDlVlan(52);
    matchBuilder.setDlVlanPcp((short) 53);
    matchBuilder.setDlType(54);
    matchBuilder.setNwTos((short) 55);
    matchBuilder.setNwProto((short) 56);
    matchBuilder.setNwSrc(new Ipv4Address("10.0.0.1"));
    matchBuilder.setNwDst(new Ipv4Address("10.0.0.2"));
    matchBuilder.setTpSrc(57);
    matchBuilder.setTpDst(58);
    aggBuilder.setMatchV10(matchBuilder.build());
    aggBuilder.setTableId((short) 5);
    aggBuilder.setOutPort(42L);
    caseBuilder.setMultipartRequestAggregate(aggBuilder.build());
    builder.setMultipartRequestBody(caseBuilder.build());
    MultipartRequestInput message = builder.build();
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    statsFactory.serialize(message, out);
    BufferHelper.checkHeaderV10(out, (byte) 16, 56);
    Assert.assertEquals("Wrong type", 2, out.readUnsignedShort());
    Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort());
    // skip match check
    out.skipBytes(40);
    Assert.assertEquals("Wrong table-id", 5, out.readUnsignedByte());
    out.skipBytes(1);
    Assert.assertEquals("Wrong out port", 42, out.readUnsignedShort());
}
Also used : MultipartRequestInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder) FlowWildcardsV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10) MultipartRequestAggregateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder) MatchV10Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder) MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) MultipartRequestAggregateCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) ByteBuf(io.netty.buffer.ByteBuf) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) MultipartRequestInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput) Test(org.junit.Test)

Example 14 with MatchV10Builder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder in project openflowplugin by opendaylight.

the class MatchUtilTest method createEmptyV10MatchTest.

@Test
public void createEmptyV10MatchTest() {
    MatchV10Builder expectedV10Match = expectedV10Match();
    MatchV10Builder emptyV10Match = MatchUtil.createEmptyV10Match();
    assertEquals(expectedV10Match.build(), emptyV10Match.build());
}
Also used : MatchV10Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder) Test(org.junit.Test)

Example 15 with MatchV10Builder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder in project openflowplugin by opendaylight.

the class MatchUtilTest method expectedV10Match.

private MatchV10Builder expectedV10Match() {
    Short zeroShort = Short.valueOf("0");
    Integer zeroInteger = 0;
    MatchV10Builder matchV10Builder = new MatchV10Builder();
    matchV10Builder.setDlDst(ZERO_MAC_ADDRESS);
    matchV10Builder.setDlSrc(ZERO_MAC_ADDRESS);
    matchV10Builder.setDlType(zeroInteger);
    matchV10Builder.setDlVlan(zeroInteger);
    matchV10Builder.setDlVlanPcp(zeroShort);
    matchV10Builder.setInPort(zeroInteger);
    matchV10Builder.setNwDst(ZERO_IPV4_ADDRESS);
    matchV10Builder.setNwDstMask(zeroShort);
    matchV10Builder.setNwProto(zeroShort);
    matchV10Builder.setNwSrc(ZERO_IPV4_ADDRESS);
    matchV10Builder.setNwSrcMask(zeroShort);
    matchV10Builder.setNwTos(zeroShort);
    matchV10Builder.setTpDst(zeroInteger);
    matchV10Builder.setTpSrc(zeroInteger);
    FlowWildcardsV10 flowWildcardsV10 = new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true);
    matchV10Builder.setWildcards(flowWildcardsV10);
    return matchV10Builder;
}
Also used : FlowWildcardsV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10) MatchV10Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder)

Aggregations

MatchV10Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder)27 FlowWildcardsV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10)23 Test (org.junit.Test)17 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)16 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)14 MatchV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10)12 BigInteger (java.math.BigInteger)10 EthernetMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch)10 IpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch)10 Ipv4Match (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match)10 VersionDatapathIdConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)9 Match (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match)9 Icmpv4Match (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4Match)9 TcpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch)9 UdpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch)9 ByteBuf (io.netty.buffer.ByteBuf)7 MultipartRequestFlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder)5 MultipartRequestAggregateCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder)3 MultipartRequestFlowCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder)3 MultipartRequestAggregateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder)3