use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.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());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.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());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.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);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.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();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.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;
}
Aggregations