use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.action.container.action.choice.ExperimenterIdCaseBuilder in project openflowplugin by opendaylight.
the class OnfOxmTcpFlagsDeserializer method deserialize.
@Override
public MatchEntry deserialize(ByteBuf input) {
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder(deserializeHeader(input));
ExperimenterIdCaseBuilder expCaseBuilder = createExperimenterIdCase(matchEntryBuilder, input);
addTcpFlagsAugmentation(input, expCaseBuilder, matchEntryBuilder.isHasMask());
matchEntryBuilder.setMatchEntryValue(expCaseBuilder.build());
return matchEntryBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.action.container.action.choice.ExperimenterIdCaseBuilder in project openflowplugin by opendaylight.
the class OF13MatchSerializerTest method testSerializeExperimenterMatchEntry.
/**
* Test serialize experimenter match entry - with no experimenter
* match entry serializer registered.
*/
@Test(expected = IllegalStateException.class)
public void testSerializeExperimenterMatchEntry() {
final List<MatchEntry> entries = new ArrayList<>();
MatchEntryBuilder builder = new MatchEntryBuilder();
builder.setOxmClass(ExperimenterClass.class);
builder.setOxmMatchField(OxmMatchFieldClass.class);
builder.setHasMask(true);
ExperimenterIdCaseBuilder caseBuilder = new ExperimenterIdCaseBuilder();
ExperimenterBuilder expBuilder = new ExperimenterBuilder();
expBuilder.setExperimenter(new ExperimenterId(42L));
caseBuilder.setExperimenter(expBuilder.build());
builder.setMatchEntryValue(caseBuilder.build());
entries.add(builder.build());
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
((OF13MatchSerializer) matchSerializer).serializeMatchEntries(entries, out);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.action.container.action.choice.ExperimenterIdCaseBuilder in project openflowplugin by opendaylight.
the class OF13SetFieldActionSerializerTest method test.
/**
* Test identify ExperimenterClass serializer.
*/
@Test
public void test() {
OF13SetFieldActionSerializer ser = new OF13SetFieldActionSerializer();
ser.injectSerializerRegistry(registry);
final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder actionBuilder = new ActionBuilder();
long experimenterId = 12L;
ExperimenterIdCaseBuilder expCaseBuilder = new ExperimenterIdCaseBuilder();
ExperimenterBuilder expBuilder = new ExperimenterBuilder();
expBuilder.setExperimenter(new ExperimenterId(experimenterId));
expCaseBuilder.setExperimenter(expBuilder.build());
MatchEntryBuilder meb = new MatchEntryBuilder();
meb.setOxmClass(ExperimenterClass.class);
meb.setOxmMatchField(OxmMatchFieldClass.class);
meb.setMatchEntryValue(expCaseBuilder.build());
List<MatchEntry> matchEntry = new ArrayList<>();
MatchEntry me = meb.build();
matchEntry.add(me);
SetFieldCaseBuilder caseBuilder = new SetFieldCaseBuilder();
SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
setFieldBuilder.setMatchEntry(matchEntry);
caseBuilder.setSetFieldAction(setFieldBuilder.build());
actionBuilder.setActionChoice(caseBuilder.build());
MatchEntrySerializerKey<?, ?> key = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, ExperimenterClass.class, OxmMatchFieldClass.class);
key.setExperimenterId(experimenterId);
registry.registerSerializer(key, serializerMock);
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
ser.serialize(actionBuilder.build(), out);
Mockito.verify(serializerMock, Mockito.times(1)).serialize((MatchEntry) Mockito.anyObject(), (ByteBuf) Mockito.anyObject());
int lenght = out.readableBytes();
Assert.assertEquals("Wrong - bad field code", ActionConstants.SET_FIELD_CODE, out.readUnsignedShort());
Assert.assertEquals("Wrong - bad lenght", lenght, out.readUnsignedShort());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.action.container.action.choice.ExperimenterIdCaseBuilder in project openflowplugin by opendaylight.
the class ActionExtensionHelperTest method testProcessAlienAction.
@Test
public void testProcessAlienAction() {
ActionBuilder actionBuilder = new ActionBuilder();
ExperimenterIdCaseBuilder experimenterIdCaseBuilder = new ExperimenterIdCaseBuilder();
ExperimenterBuilder experimenterBuilder = new ExperimenterBuilder();
experimenterBuilder.setExperimenter(new ExperimenterId(42L));
experimenterIdCaseBuilder.setExperimenter(experimenterBuilder.build());
actionBuilder.setActionChoice(experimenterIdCaseBuilder.build());
Action action = ActionExtensionHelper.processAlienAction(actionBuilder.build(), OpenflowVersion.OF13, ActionPath.FLOWS_STATISTICS_UPDATE_APPLY_ACTIONS);
assertNotNull(action);
assertEquals(MockAction.class, action.getImplementedInterface());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.action.container.action.choice.ExperimenterIdCaseBuilder in project openflowplugin by opendaylight.
the class OnfOxmTcpFlagsDeserializer method addTcpFlagsAugmentation.
private static void addTcpFlagsAugmentation(ByteBuf input, ExperimenterIdCaseBuilder expCaseBuilder, boolean hasMask) {
TcpFlagsContainerBuilder flagsContainerBuilder = new TcpFlagsContainerBuilder();
TcpFlagsBuilder flagsBuilder = new TcpFlagsBuilder();
flagsBuilder.setFlags(input.readUnsignedShort());
if (hasMask) {
byte[] mask = new byte[EncodeConstants.SIZE_OF_SHORT_IN_BYTES];
input.readBytes(mask);
flagsBuilder.setMask(mask);
}
flagsContainerBuilder.setTcpFlags(flagsBuilder.build());
expCaseBuilder.addAugmentation(TcpFlagsContainer.class, flagsContainerBuilder.build());
}
Aggregations