leaf experimenter {\r
type uint32;\r
}\r
+ leaf data {\r
+ type binary;\r
+ }\r
}\r
// OF1.0 structures\r
augment "/ofaction:actions-container/ofaction:action" {\r
private static final byte PADDING_IN_SET_MPLS_TTL_ACTIONS_HEADER = 3;
private static final byte PADDING_IN_PUSH_VLAN_ACTIONS_HEADER = 2;
private static final byte PADDING_IN_NW_TTL_ACTIONS_HEADER = 3;
+ private static final byte EXPERIMENTER_ACTION_HEADER_LENGTH = 8;
/**
* Creates list of actions (OpenFlow v1.3)
actions.add(createPopPbbAction(input, actionBuilder));
break;
case 0xFFFF:
- actions.add(createExperimenterAction(input, actionBuilder));
+ actions.add(createExperimenterAction(input, actionBuilder, currentActionLength));
break;
default:
break;
return actionBuilder.build();
}
- private static Action createExperimenterAction(ByteBuf in, ActionBuilder actionBuilder) {
+ private static Action createExperimenterAction(ByteBuf in, ActionBuilder actionBuilder, int actionLength) {
actionBuilder.setType(Experimenter.class);
ExperimenterActionBuilder experimenter = new ExperimenterActionBuilder();
experimenter.setExperimenter(in.readUnsignedInt());
+ int dataLength = actionLength - EXPERIMENTER_ACTION_HEADER_LENGTH;
+ if (dataLength > 0) {
+ byte[] data = new byte[dataLength];
+ in.readBytes(data);
+ experimenter.setData(data);
+ }
actionBuilder.addAugmentation(ExperimenterAction.class, experimenter.build());
return actionBuilder.build();
}
private static final byte SET_QUEUE_LENGTH = 8;
private static final byte GROUP_LENGTH = 8;
private static final byte SET_NW_TTL_LENGTH = 8;
- private static final byte EXPERIMENTER_LENGTH = 8;
+ private static final byte EXPERIMENTER_ACTION_HEADER_LENGTH = 8;
private static final byte ACTION_HEADER_LENGTH = 8;
private static final byte LENGTH_OF_ETHERTYPE_ACTION = 8;
private static final byte LENGTH_OF_OTHER_ACTIONS = 8;
private static void encodeExperimenterAction(Action action, ByteBuf outBuffer) {
outBuffer.writeShort(EXPERIMENTER_CODE);
- outBuffer.writeShort(EXPERIMENTER_LENGTH);
ExperimenterAction experimenter = action.getAugmentation(ExperimenterAction.class);
- outBuffer.writeInt(experimenter.getExperimenter().intValue());
+ if (experimenter.getData() != null) {
+ outBuffer.writeShort(EXPERIMENTER_ACTION_HEADER_LENGTH + experimenter.getData().length);
+ outBuffer.writeInt(experimenter.getExperimenter().intValue());
+ outBuffer.writeBytes(experimenter.getData());
+ } else {
+ outBuffer.writeShort(EXPERIMENTER_ACTION_HEADER_LENGTH);
+ outBuffer.writeInt(experimenter.getExperimenter().intValue());
+ }
}
private static void encodeRestOfActionHeader(ByteBuf outBuffer) {
import org.junit.Assert;\r
import org.junit.Test;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction;\r
+ "00 18 00 08 00 00 00 00 "\r
+ "00 19 00 10 80 00 02 04 00 00 00 0B 00 00 00 00 "\r
+ "00 1A 00 08 00 0A 00 00 "\r
- + "00 1B 00 08 00 00 00 00");\r
+ + "00 1B 00 08 00 00 00 00 "\r
+ + "FF FF 00 10 00 00 00 08 00 01 02 03 04 05 06 07");\r
\r
message.skipBytes(4); // skip XID\r
LOGGER.info("bytes: " + message.readableBytes());\r
actions.get(14).getAugmentation(EthertypeAction.class).getEthertype().getValue().intValue());\r
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight."\r
+ "openflow.common.action.rev130731.PopPbb", actions.get(15).getType().getName());\r
+ Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight."\r
+ + "openflow.common.action.rev130731.Experimenter", actions.get(16).getType().getName());\r
+ Assert.assertEquals("Wrong experimenter", 8, actions.get(16).getAugmentation(ExperimenterAction.class)\r
+ .getExperimenter().intValue());\r
+ Assert.assertArrayEquals("Wrong data", new byte[]{0, 1, 2, 3, 4, 5, 6, 7}, actions.get(16)\r
+ .getAugmentation(ExperimenterAction.class).getData());\r
Assert.assertTrue("Unread data in message", message.readableBytes() == 0);\r
}\r
\r
actionBuilder.setType(Experimenter.class);\r
ExperimenterActionBuilder experimenter = new ExperimenterActionBuilder();\r
experimenter.setExperimenter(4L);\r
+ experimenter.setData(new byte[]{0, 1, 2, 3, 4, 5, 6, 7});\r
actionBuilder.addAugmentation(ExperimenterAction.class, experimenter.build());\r
actions.add(actionBuilder.build());\r
\r
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());\r
out.skipBytes(4);\r
Assert.assertEquals("Wrong action type", 65535, out.readUnsignedShort());\r
- Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());\r
- Assert.assertEquals("Wrong action experimenter", 4, out.readUnsignedInt());\r
+ Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort());\r
+ Assert.assertEquals("Wrong experimenter", 4, out.readUnsignedInt());\r
+ byte[] data = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];\r
+ out.readBytes(data);\r
+ Assert.assertArrayEquals("Wrong data", new byte[]{0, 1, 2, 3, 4, 5, 6, 7}, data);\r
+ Assert.assertTrue("Unread data", out.readableBytes() == 0);\r
}\r
\r
}\r