Search in sources :

Example 86 with TableId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId in project openflowplugin by opendaylight.

the class PacketInMessageFactoryTest method test.

/**
 * Testing {@link PacketInMessageFactory} for correct translation into POJO.
 */
@Test
public void test() {
    ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 01 02 01 04 00 01 02 03 04 05 06 07 00 01 00 0C" + " 80 00 02 04 00 00 00 01 00 00 00 00 00 00 01 02 03 04");
    PacketInMessage builtByFactory = BufferHelper.deserialize(packetInFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong bufferID", 0x00010203L, builtByFactory.getBufferId().longValue());
    Assert.assertEquals("Wrong totalLength", 0x0102, builtByFactory.getTotalLen().intValue());
    Assert.assertEquals("Wrong reason", PacketInReason.OFPRACTION, builtByFactory.getReason());
    Assert.assertEquals("Wrong tableID", new TableId(4L), builtByFactory.getTableId());
    Assert.assertEquals("Wrong cookie", 0x0001020304050607L, builtByFactory.getCookie().longValue());
    Assert.assertArrayEquals("Wrong data", ByteBufUtils.hexStringToBytes("01 02 03 04"), builtByFactory.getData());
}
Also used : TableId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId) PacketInMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 87 with TableId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId in project openflowplugin by opendaylight.

the class FlowRemovedMessageFactoryTest method test.

/**
 * Testing {@link FlowRemovedMessageFactory} for correct translation into POJO.
 */
@Test
public void test() {
    ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 04 05 06 07 00 03 02 04 00 00 00 02" + " 00 00 00 05 00 01 00 03 00 01 02 03 04 05 06 07 00 01 02 03 04 05 06 07");
    FlowRemovedMessage builtByFactory = BufferHelper.deserialize(flowFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertTrue(builtByFactory.getCookie().longValue() == 0x0001020304050607L);
    Assert.assertTrue(builtByFactory.getPriority() == 0x03);
    Assert.assertEquals("Wrong reason", 0x02, builtByFactory.getReason().getIntValue());
    Assert.assertEquals("Wrong tableId", new TableId(4L), builtByFactory.getTableId());
    Assert.assertEquals("Wrong durationSec", 0x02L, builtByFactory.getDurationSec().longValue());
    Assert.assertEquals("Wrong durationNsec", 0x05L, builtByFactory.getDurationNsec().longValue());
    Assert.assertEquals("Wrong idleTimeout", 0x01, builtByFactory.getIdleTimeout().intValue());
    Assert.assertEquals("Wrong hardTimeout", 0x03, builtByFactory.getHardTimeout().intValue());
    Assert.assertEquals("Wrong packetCount", 0x0001020304050607L, builtByFactory.getPacketCount().longValue());
    Assert.assertEquals("Wrong byteCount", 0x0001020304050607L, builtByFactory.getByteCount().longValue());
}
Also used : TableId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId) FlowRemovedMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 88 with TableId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId in project openflowplugin by opendaylight.

the class FlowRegistryKeyFactory method create.

@Nonnull
public static FlowRegistryKey create(final short version, @Nonnull final Flow flow) {
    // TODO: mandatory flow input values (or default values) should be specified via yang model
    final short tableId = Preconditions.checkNotNull(flow.getTableId(), "flow tableId must not be null");
    final int priority = MoreObjects.firstNonNull(flow.getPriority(), OFConstants.DEFAULT_FLOW_PRIORITY);
    final BigInteger cookie = MoreObjects.firstNonNull(flow.getCookie(), OFConstants.DEFAULT_FLOW_COOKIE).getValue();
    Match match = MatchNormalizationUtil.normalizeMatch(MoreObjects.firstNonNull(flow.getMatch(), OFConstants.EMPTY_MATCH), version);
    return new FlowRegistryKeyDto(tableId, priority, cookie, match);
}
Also used : BigInteger(java.math.BigInteger) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match) Nonnull(javax.annotation.Nonnull)

Example 89 with TableId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId in project openflowplugin by opendaylight.

the class MultiLayerAggregateFlowMultipartService method buildRequest.

@Override
protected OfHeader buildRequest(final Xid xid, final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input) throws ServiceException {
    final MultipartRequestAggregateCaseBuilder multipartRequestAggregateCaseBuilder = new MultipartRequestAggregateCaseBuilder();
    final MultipartRequestAggregateBuilder mprAggregateRequestBuilder = new MultipartRequestAggregateBuilder();
    final short tableId = MoreObjects.firstNonNull(input.getTableId(), OFConstants.OFPTT_ALL);
    mprAggregateRequestBuilder.setTableId(tableId);
    long outputPortValue = MoreObjects.firstNonNull(input.getOutPort(), OFConstants.OFPP_ANY).longValue();
    mprAggregateRequestBuilder.setOutPort(outputPortValue);
    final short version = getVersion();
    if (version == OFConstants.OFP_VERSION_1_3) {
        if (input.getCookie() == null) {
            mprAggregateRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
        } else {
            mprAggregateRequestBuilder.setCookie(MoreObjects.firstNonNull(input.getCookie().getValue(), OFConstants.DEFAULT_COOKIE));
        }
        if (input.getCookieMask() == null) {
            mprAggregateRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
        } else {
            mprAggregateRequestBuilder.setCookieMask(MoreObjects.firstNonNull(input.getCookieMask().getValue(), OFConstants.DEFAULT_COOKIE_MASK));
        }
        long outGroup = MoreObjects.firstNonNull(input.getOutGroup(), OFConstants.OFPG_ANY);
        mprAggregateRequestBuilder.setOutGroup(outGroup);
    } else {
        mprAggregateRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
        mprAggregateRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
        mprAggregateRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
    }
    // convert and inject match
    final Optional<Object> conversionMatch = convertorExecutor.convert(input.getMatch(), data);
    MatchInjector.inject(conversionMatch, mprAggregateRequestBuilder, data.getVersion());
    FlowCreatorUtil.setWildcardedFlowMatch(version, mprAggregateRequestBuilder);
    // Set request body to main multipart request
    multipartRequestAggregateCaseBuilder.setMultipartRequestAggregate(mprAggregateRequestBuilder.build());
    final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(MultipartType.OFPMPAGGREGATE, xid.getValue(), version);
    mprInput.setMultipartRequestBody(multipartRequestAggregateCaseBuilder.build());
    return mprInput.build();
}
Also used : MultipartRequestInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder) MultipartRequestAggregateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder) MultipartRequestAggregateCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder)

Example 90 with TableId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId in project openflowplugin by opendaylight.

the class OFPluginFlowTest method createTestFlow.

static FlowBuilder createTestFlow() {
    short tableId = 0;
    FlowBuilder flow = new FlowBuilder();
    flow.setMatch(createMatch1().build());
    flow.setInstructions(createDecNwTtlInstructions().build());
    FlowId flowId = new FlowId("127");
    FlowKey key = new FlowKey(flowId);
    if (null == flow.isBarrier()) {
        flow.setBarrier(Boolean.FALSE);
    }
    BigInteger value = BigInteger.TEN;
    flow.setCookie(new FlowCookie(value));
    flow.setCookieMask(new FlowCookie(value));
    flow.setHardTimeout(0);
    flow.setIdleTimeout(0);
    flow.setInstallHw(false);
    flow.setStrict(false);
    flow.setContainerName(null);
    flow.setFlags(new FlowModFlags(false, false, false, false, true));
    flow.setId(flowId);
    flow.setTableId(tableId);
    flow.setKey(key);
    flow.setFlowName("Foo" + "X" + "f1");
    return flow;
}
Also used : FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) FlowCookie(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) FlowModFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags) BigInteger(java.math.BigInteger)

Aggregations

BigInteger (java.math.BigInteger)38 Test (org.junit.Test)32 ArrayList (java.util.ArrayList)26 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)17 ByteBuf (io.netty.buffer.ByteBuf)16 FlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder)16 FlowId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId)15 FlowKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey)15 TableId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId)14 TableId (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId)14 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)13 FlowCookie (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie)12 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)12 InstructionGotoTable (org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable)9 FlowModFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags)7 Optional (com.google.common.base.Optional)6 ExecutionException (java.util.concurrent.ExecutionException)5 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)5 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)5 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)5