Search in sources :

Example 61 with TableId

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

the class FlowTableStatNotificationSupplierImpl method createNotification.

@Override
public FlowTableStatisticsUpdate createNotification(final FlowTableStatistics flowTableStatistics, final InstanceIdentifier<FlowTableStatistics> path) {
    Preconditions.checkArgument(flowTableStatistics != null);
    Preconditions.checkArgument(path != null);
    final FlowTableAndStatisticsMapBuilder ftsmBuilder = new FlowTableAndStatisticsMapBuilder(flowTableStatistics);
    ftsmBuilder.setKey(new FlowTableAndStatisticsMapKey(new TableId(path.firstKeyOf(Table.class, TableKey.class).getId())));
    final FlowTableStatisticsUpdateBuilder builder = new FlowTableStatisticsUpdateBuilder();
    builder.setId(getNodeId(path));
    builder.setMoreReplies(Boolean.FALSE);
    // NOTE : fix if it needs, but we have to ask DataStore for the NodeConnector list
    builder.setNodeConnector(Collections.<NodeConnector>emptyList());
    builder.setFlowTableAndStatisticsMap(Collections.singletonList(ftsmBuilder.build()));
    return builder.build();
}
Also used : TableId(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId) FlowTableAndStatisticsMapKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMapKey) FlowTableStatisticsUpdateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsUpdateBuilder) FlowTableAndStatisticsMapBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMapBuilder)

Example 62 with TableId

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

the class FlowRemovedMessageFactory method deserialize.

@Override
// FB doesn't recognize Objects.requireNonNull
@SuppressFBWarnings("UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR")
public FlowRemovedMessage deserialize(ByteBuf rawMessage) {
    Objects.requireNonNull(registry);
    FlowRemovedMessageBuilder builder = new FlowRemovedMessageBuilder();
    builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
    builder.setXid(rawMessage.readUnsignedInt());
    byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    rawMessage.readBytes(cookie);
    builder.setCookie(new BigInteger(1, cookie));
    builder.setPriority(rawMessage.readUnsignedShort());
    builder.setReason(FlowRemovedReason.forValue(rawMessage.readUnsignedByte()));
    builder.setTableId(new TableId((long) rawMessage.readUnsignedByte()));
    builder.setDurationSec(rawMessage.readUnsignedInt());
    builder.setDurationNsec(rawMessage.readUnsignedInt());
    builder.setIdleTimeout(rawMessage.readUnsignedShort());
    builder.setHardTimeout(rawMessage.readUnsignedShort());
    byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    rawMessage.readBytes(packetCount);
    builder.setPacketCount(new BigInteger(1, packetCount));
    byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    rawMessage.readBytes(byteCount);
    builder.setByteCount(new BigInteger(1, byteCount));
    OFDeserializer<Match> matchDeserializer = registry.getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Match.class));
    builder.setMatch(matchDeserializer.deserialize(rawMessage));
    return builder.build();
}
Also used : TableId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId) MessageCodeKey(org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey) BigInteger(java.math.BigInteger) FlowRemovedMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 63 with TableId

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

the class TableModInputMessageFactory method deserialize.

@Override
public TableModInput deserialize(ByteBuf rawMessage) {
    TableModInputBuilder builder = new TableModInputBuilder();
    builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
    builder.setXid(rawMessage.readUnsignedInt());
    builder.setTableId(new TableId((long) rawMessage.readUnsignedByte()));
    rawMessage.skipBytes(PADDING_IN_TABLE_MOD_MESSAGE);
    builder.setConfig(createTableConfig(rawMessage.readUnsignedInt()));
    return builder.build();
}
Also used : TableId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId) TableModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInputBuilder)

Example 64 with TableId

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

the class MultipartReplyMessageFactoryTest method testTableSerialize.

@Test
public void testTableSerialize() throws Exception {
    MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setFlags(new MultipartRequestFlags(true));
    builder.setType(MultipartType.forValue(3));
    MultipartReplyTableCaseBuilder tableCase = new MultipartReplyTableCaseBuilder();
    MultipartReplyTableBuilder table = new MultipartReplyTableBuilder();
    table.setTableStats(createTableStats());
    tableCase.setMultipartReplyTable(table.build());
    builder.setMultipartReplyBody(tableCase.build());
    MultipartReplyMessage message = builder.build();
    ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, serializedBuffer);
    BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 40);
    Assert.assertEquals("Wrong type", MultipartType.OFPMPTABLE.getIntValue(), serializedBuffer.readShort());
    Assert.assertEquals("Wrong flags", message.getFlags(), createMultipartRequestFlags(serializedBuffer.readShort()));
    serializedBuffer.skipBytes(PADDING);
    MultipartReplyTableCase body = (MultipartReplyTableCase) message.getMultipartReplyBody();
    MultipartReplyTable messageOutput = body.getMultipartReplyTable();
    TableStats tableStats = messageOutput.getTableStats().get(0);
    Assert.assertEquals("Wrong tableId", tableStats.getTableId().shortValue(), serializedBuffer.readUnsignedByte());
    serializedBuffer.skipBytes(3);
    Assert.assertEquals("Wrong active count", tableStats.getActiveCount().longValue(), serializedBuffer.readInt());
    Assert.assertEquals("Wrong lookup count", tableStats.getLookupCount().longValue(), serializedBuffer.readLong());
    Assert.assertEquals("Wrong matched count", tableStats.getMatchedCount().longValue(), serializedBuffer.readLong());
}
Also used : MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) MultipartReplyTableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTableBuilder) MultipartReplyTableCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCase) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) MultipartReplyTable(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTable) ByteBuf(io.netty.buffer.ByteBuf) TableStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStats) MultipartReplyTableCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCaseBuilder) Test(org.junit.Test)

Example 65 with TableId

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

the class PacketInMessageFactoryTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    PacketInMessageBuilder builder = new PacketInMessageBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setBufferId(256L);
    builder.setTotalLen(10);
    builder.setReason(PacketInReason.forValue(0));
    builder.setTableId(new TableId(1L));
    byte[] cookie = new byte[] { (byte) 0xFF, 0x01, 0x04, 0x01, 0x06, 0x00, 0x07, 0x01 };
    builder.setCookie(new BigInteger(1, cookie));
    MatchBuilder matchBuilder = new MatchBuilder();
    matchBuilder.setType(OxmMatchType.class);
    final List<MatchEntry> entries = new ArrayList<>();
    MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
    entriesBuilder.setOxmClass(OpenflowBasicClass.class);
    entriesBuilder.setOxmMatchField(InPhyPort.class);
    entriesBuilder.setHasMask(false);
    InPhyPortCaseBuilder inPhyPortCaseBuilder = new InPhyPortCaseBuilder();
    InPhyPortBuilder inPhyPortBuilder = new InPhyPortBuilder();
    inPhyPortBuilder.setPortNumber(new PortNumber(42L));
    inPhyPortCaseBuilder.setInPhyPort(inPhyPortBuilder.build());
    entriesBuilder.setMatchEntryValue(inPhyPortCaseBuilder.build());
    entries.add(entriesBuilder.build());
    entriesBuilder.setOxmClass(OpenflowBasicClass.class);
    entriesBuilder.setOxmMatchField(IpEcn.class);
    entriesBuilder.setHasMask(false);
    IpEcnCaseBuilder ipEcnCaseBuilder = new IpEcnCaseBuilder();
    IpEcnBuilder ipEcnBuilder = new IpEcnBuilder();
    ipEcnBuilder.setEcn((short) 4);
    ipEcnCaseBuilder.setIpEcn(ipEcnBuilder.build());
    entriesBuilder.setMatchEntryValue(ipEcnCaseBuilder.build());
    entries.add(entriesBuilder.build());
    matchBuilder.setMatchEntry(entries);
    builder.setMatch(matchBuilder.build());
    byte[] data = ByteBufUtils.hexStringToBytes("00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14");
    builder.setData(data);
    PacketInMessage message = builder.build();
    ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, serializedBuffer);
    BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 66);
    Assert.assertEquals("Wrong BufferId", message.getBufferId().longValue(), serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong actions length", message.getTotalLen().intValue(), serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong reason", message.getReason().getIntValue(), serializedBuffer.readUnsignedByte());
    Assert.assertEquals("Wrong tableId", message.getTableId().getValue().intValue(), serializedBuffer.readUnsignedByte());
    cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    serializedBuffer.readBytes(cookie);
    Assert.assertEquals("Wrong cookie", message.getCookie(), new BigInteger(1, cookie));
    Assert.assertEquals("Wrong match type", 1, serializedBuffer.readUnsignedShort());
    serializedBuffer.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
    Assert.assertEquals("Wrong oxm class", 0x8000, serializedBuffer.readUnsignedShort());
    short fieldAndMask = serializedBuffer.readUnsignedByte();
    Assert.assertEquals("Wrong oxm hasMask", 0, fieldAndMask & 1);
    Assert.assertEquals("Wrong oxm field", 1, fieldAndMask >> 1);
    serializedBuffer.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
    Assert.assertEquals("Wrong oxm value", 42, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong oxm class", 0x8000, serializedBuffer.readUnsignedShort());
    fieldAndMask = serializedBuffer.readUnsignedByte();
    Assert.assertEquals("Wrong oxm hasMask", 0, fieldAndMask & 1);
    Assert.assertEquals("Wrong oxm field", 9, fieldAndMask >> 1);
    serializedBuffer.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
    Assert.assertEquals("Wrong oxm value", 4, serializedBuffer.readUnsignedByte());
    serializedBuffer.skipBytes(7);
    serializedBuffer.skipBytes(PADDING);
    byte[] readData = new byte[serializedBuffer.readableBytes()];
    serializedBuffer.readBytes(readData);
    Assert.assertArrayEquals("Wrong data", message.getData(), readData);
}
Also used : TableId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId) MatchEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry) IpEcnBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.ecn._case.IpEcnBuilder) ArrayList(java.util.ArrayList) PacketInMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage) ByteBuf(io.netty.buffer.ByteBuf) InPhyPortBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.in.phy.port._case.InPhyPortBuilder) PacketInMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder) MatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder) InPhyPortCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPhyPortCaseBuilder) BigInteger(java.math.BigInteger) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber) IpEcnCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpEcnCaseBuilder) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder) Test(org.junit.Test)

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