use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.statement.Actions in project openflowplugin by opendaylight.
the class OF10FlowModInputMessageFactory method deserialize.
@Override
// FB doesn't recognize Objects.requireNonNull
@SuppressFBWarnings("UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR")
public FlowModInput deserialize(ByteBuf rawMessage) {
Objects.requireNonNull(registry);
FlowModInputBuilder builder = new FlowModInputBuilder();
builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
OFDeserializer<MatchV10> matchDeserializer = registry.getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, EncodeConstants.EMPTY_VALUE, MatchV10.class));
builder.setMatchV10(matchDeserializer.deserialize(rawMessage));
byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
rawMessage.readBytes(cookie);
builder.setCookie(new BigInteger(1, cookie));
builder.setCommand(FlowModCommand.forValue(rawMessage.readUnsignedShort()));
builder.setIdleTimeout(rawMessage.readUnsignedShort());
builder.setHardTimeout(rawMessage.readUnsignedShort());
builder.setPriority(rawMessage.readUnsignedShort());
builder.setBufferId(rawMessage.readUnsignedInt());
builder.setOutPort(new PortNumber((long) rawMessage.readUnsignedShort()));
builder.setFlagsV10(createFlowModFlagsFromBitmap(rawMessage.readUnsignedShort()));
CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF10_VERSION_ID);
List<Action> actions = ListDeserializer.deserializeList(EncodeConstants.OF10_VERSION_ID, rawMessage.readableBytes(), rawMessage, keyMaker, registry);
builder.setAction(actions);
return builder.build();
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.statement.Actions in project openflowplugin by opendaylight.
the class PacketOutInputMessageFactory method deserialize.
@Override
public PacketOutInput deserialize(ByteBuf rawMessage) {
PacketOutInputBuilder builder = new PacketOutInputBuilder();
builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
builder.setBufferId(rawMessage.readUnsignedInt());
builder.setInPort(new PortNumber(rawMessage.readUnsignedInt()));
int actionsLen = rawMessage.readShort();
rawMessage.skipBytes(PADDING);
CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID);
List<Action> actions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, actionsLen, rawMessage, keyMaker, registry);
builder.setAction(actions);
byte[] data = new byte[rawMessage.readableBytes()];
rawMessage.readBytes(data);
builder.setData(data);
return builder.build();
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.statement.Actions in project openflowplugin by opendaylight.
the class GroupMessageDeserializer method deserialize.
@Override
public GroupMessage deserialize(ByteBuf message) {
final GroupMessageBuilder builder = new GroupMessageBuilder().setVersion((short) EncodeConstants.OF13_VERSION_ID).setXid(message.readUnsignedInt()).setCommand(GroupModCommand.forValue(message.readUnsignedShort()));
builder.setGroupType(GroupTypes.forValue(message.readUnsignedByte()));
message.skipBytes(PADDING);
builder.setGroupId(new GroupId(message.readUnsignedInt()));
final List<Bucket> buckets = new ArrayList<>();
while (message.readableBytes() > 0) {
final int length = message.readUnsignedShort();
final BucketBuilder bucket = new BucketBuilder().setWeight(message.readUnsignedShort()).setWatchPort(message.readUnsignedInt()).setWatchGroup(message.readUnsignedInt());
message.skipBytes(PADDING_IN_BUCKETS_HEADER);
if (message.readableBytes() > 0) {
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actions = new ArrayList<>();
final int startIndex = message.readerIndex();
final int bucketLength = length - BUCKETS_HEADER_LENGTH;
int offset = 0;
while (message.readerIndex() - startIndex < bucketLength) {
actions.add(new ActionBuilder().setKey(new ActionKey(offset)).setOrder(offset).setAction(ActionUtil.readAction(EncodeConstants.OF13_VERSION_ID, message, registry, ActionPath.GROUP_DESC_STATS_UPDATED_BUCKET_ACTION)).build());
offset++;
}
bucket.setAction(actions);
}
buckets.add(bucket.build());
}
buckets.sort(COMPARATOR);
return builder.setBuckets(new BucketsBuilder().setBucket(buckets).build()).build();
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.statement.Actions in project openflowplugin by opendaylight.
the class GroupUtil method extractGroupActionsSupportBitmap.
/*
* Method returns the bitmap of actions supported by each group.
*
* @param actionsSupported - list of supported actions
* @return
*/
public static List<Long> extractGroupActionsSupportBitmap(final List<ActionType> actionsSupported) {
List<Long> supportActionByGroups = new ArrayList<>();
for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType supportedActions : actionsSupported) {
long supportActionBitmap = 0;
supportActionBitmap |= supportedActions.isOFPATOUTPUT() ? 1 : 0;
supportActionBitmap |= supportedActions.isOFPATCOPYTTLOUT() ? 1 << 11 : 0;
supportActionBitmap |= supportedActions.isOFPATCOPYTTLIN() ? 1 << 12 : 0;
supportActionBitmap |= supportedActions.isOFPATSETMPLSTTL() ? 1 << 15 : 0;
supportActionBitmap |= supportedActions.isOFPATDECMPLSTTL() ? 1 << 16 : 0;
supportActionBitmap |= supportedActions.isOFPATPUSHVLAN() ? 1 << 17 : 0;
supportActionBitmap |= supportedActions.isOFPATPOPVLAN() ? 1 << 18 : 0;
supportActionBitmap |= supportedActions.isOFPATPUSHMPLS() ? 1 << 19 : 0;
supportActionBitmap |= supportedActions.isOFPATPOPMPLS() ? 1 << 20 : 0;
supportActionBitmap |= supportedActions.isOFPATSETQUEUE() ? 1 << 21 : 0;
supportActionBitmap |= supportedActions.isOFPATGROUP() ? 1 << 22 : 0;
supportActionBitmap |= supportedActions.isOFPATSETNWTTL() ? 1 << 23 : 0;
supportActionBitmap |= supportedActions.isOFPATDECNWTTL() ? 1 << 24 : 0;
supportActionBitmap |= supportedActions.isOFPATSETFIELD() ? 1 << 25 : 0;
supportActionBitmap |= supportedActions.isOFPATPUSHPBB() ? 1 << 26 : 0;
supportActionBitmap |= supportedActions.isOFPATPOPPBB() ? 1 << 27 : 0;
supportActionByGroups.add(supportActionBitmap);
}
return supportActionByGroups;
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.statement.Actions in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactoryTest method testMultipartReplyGroupDescBody01.
/**
* Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
* Test covers bodies of actions Output, Copy TTL Out, Copy TTL In.
*/
@Test
public void testMultipartReplyGroupDescBody01() {
ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 " + // len
"00 38 " + // type
"01 " + // pad
"00 " + // groupId
"00 00 00 08 " + // bucketLen
"00 30 " + // bucketWeight
"00 06 " + // bucketWatchPort
"00 00 00 05 " + // bucketWatchGroup
"00 00 00 04 " + // bucketPad
"00 00 00 00 " + // outputType
"00 00 " + // outputLen
"00 10 " + // outputPort
"00 00 10 FF " + // outputMaxLen
"FF FF " + // outputPad
"00 00 00 00 00 00 " + // copyTTLOutType
"00 0B " + // copyTTLOutLen
"00 08 " + // copyTTLOutPad
"00 00 00 00 " + // copyTTLIntType
"00 0C " + // copyTTLIntLen
"00 08 " + // copyTTLInPad
"00 00 00 00");
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyGroupDescCase messageCase = (MultipartReplyGroupDescCase) builtByFactory.getMultipartReplyBody();
MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc();
Assert.assertEquals("Wrong type", 1, message.getGroupDesc().get(0).getType().getIntValue());
Assert.assertEquals("Wrong groupId", 8, message.getGroupDesc().get(0).getGroupId().getValue().intValue());
Assert.assertEquals("Wrong bucketWeight", 6, message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue());
Assert.assertEquals("Wrong bucketWatchPort", 5, message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().getValue().intValue());
Assert.assertEquals("Wrong bucketWatchGroup", 4, message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue());
Assert.assertTrue("Wrong outputType", message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0).getActionChoice() instanceof OutputActionCase);
Assert.assertEquals("Wrong outputPort", 4351, ((OutputActionCase) message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0).getActionChoice()).getOutputAction().getPort().getValue().intValue());
Assert.assertEquals("Wrong outputMaxLen", 65535, ((OutputActionCase) message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0).getActionChoice()).getOutputAction().getMaxLength().intValue());
Assert.assertTrue("Wrong copyTtlOutType", message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1).getActionChoice() instanceof CopyTtlOutCase);
Assert.assertTrue("Wrong copyTtlInType", message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2).getActionChoice() instanceof CopyTtlInCase);
}
Aggregations