use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.TcpSrcCaseValueBuilder in project openflowplugin by opendaylight.
the class TcpSrcCodecTest method createMatchEntry.
private MatchEntry createMatchEntry() {
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
final TcpSrcCaseValueBuilder caseBuilder = new TcpSrcCaseValueBuilder();
final TcpSrcValuesBuilder valuesBuilder = new TcpSrcValuesBuilder();
matchEntryBuilder.setOxmClass(Nxm0Class.class);
matchEntryBuilder.setOxmMatchField(NxmOfTcpSrc.class);
matchEntryBuilder.setHasMask(true);
valuesBuilder.setPort(new PortNumber(1));
valuesBuilder.setMask(0xffff);
caseBuilder.setTcpSrcValues(valuesBuilder.build());
matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
return matchEntryBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.TcpSrcCaseValueBuilder in project openflowplugin by opendaylight.
the class TcpSrcConvertor method convert.
@Override
public MatchEntry convert(Extension extension) {
Optional<NxmOfTcpSrcGrouping> matchGrouping = MatchUtil.TCP_SRC_RESOLVER.getExtension(extension);
if (!matchGrouping.isPresent()) {
throw new CodecPreconditionException(extension);
}
TcpSrcCaseValueBuilder tcpSrcCaseValueBuilder = new TcpSrcCaseValueBuilder();
TcpSrcValuesBuilder tcpSrcValuesBuilder = new TcpSrcValuesBuilder();
tcpSrcValuesBuilder.setPort(matchGrouping.get().getNxmOfTcpSrc().getPort());
tcpSrcValuesBuilder.setMask(matchGrouping.get().getNxmOfTcpSrc().getMask());
tcpSrcCaseValueBuilder.setTcpSrcValues(tcpSrcValuesBuilder.build());
MatchEntryBuilder ofMatch = MatchUtil.createDefaultMatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmOfTcpSrc.class, Nxm0Class.class, tcpSrcCaseValueBuilder.build());
ofMatch.setHasMask(true);
return ofMatch.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.TcpSrcCaseValueBuilder in project openflowplugin by opendaylight.
the class TcpSrcCodec method deserialize.
@Override
public MatchEntry deserialize(ByteBuf message) {
MatchEntryBuilder matchEntryBuilder = deserializeHeaderToBuilder(message);
matchEntryBuilder.setHasMask(true);
int portNo = message.readUnsignedShort();
int mask = message.readUnsignedShort();
TcpSrcCaseValueBuilder caseBuilder = new TcpSrcCaseValueBuilder();
TcpSrcValuesBuilder tcpSrcValuesBuilder = new TcpSrcValuesBuilder();
tcpSrcValuesBuilder.setPort(new PortNumber(portNo));
tcpSrcValuesBuilder.setMask(mask);
caseBuilder.setTcpSrcValues(tcpSrcValuesBuilder.build());
matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
return matchEntryBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.TcpSrcCaseValueBuilder in project openflowplugin by opendaylight.
the class TcpSrcConvertorTest method testConvert1.
@Test
public void testConvert1() throws Exception {
final TcpSrcValuesBuilder tcpSrcValuesBuilder = new TcpSrcValuesBuilder().setMask(2).setPort(DEFAULT_PORT);
final TcpSrcCaseValueBuilder tcpSrcCaseValueBuilder = new TcpSrcCaseValueBuilder().setTcpSrcValues(tcpSrcValuesBuilder.build());
final TcpSrcCaseValue tcpSrcCaseValue = tcpSrcCaseValueBuilder.build();
when(matchEntry.getMatchEntryValue()).thenReturn(tcpSrcCaseValue);
final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment = tcpSrcConvertor.convert(matchEntry, MatchPath.PACKET_RECEIVED_MATCH);
Assert.assertEquals(2, ((NxAugMatchNotifPacketIn) extensionAugment.getAugmentationObject()).getNxmOfTcpSrc().getMask().intValue());
Assert.assertEquals(DEFAULT_PORT, ((NxAugMatchNotifPacketIn) extensionAugment.getAugmentationObject()).getNxmOfTcpSrc().getPort());
Assert.assertEquals(extensionAugment.getKey(), NxmOfTcpSrcKey.class);
final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment1 = tcpSrcConvertor.convert(matchEntry, MatchPath.SWITCH_FLOW_REMOVED_MATCH);
Assert.assertEquals(2, ((NxAugMatchNotifSwitchFlowRemoved) extensionAugment1.getAugmentationObject()).getNxmOfTcpSrc().getMask().intValue());
Assert.assertEquals(DEFAULT_PORT, ((NxAugMatchNotifSwitchFlowRemoved) extensionAugment1.getAugmentationObject()).getNxmOfTcpSrc().getPort());
Assert.assertEquals(extensionAugment.getKey(), NxmOfTcpSrcKey.class);
final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment2 = tcpSrcConvertor.convert(matchEntry, MatchPath.FLOWS_STATISTICS_UPDATE_MATCH);
Assert.assertEquals(2, ((NxAugMatchNodesNodeTableFlow) extensionAugment2.getAugmentationObject()).getNxmOfTcpSrc().getMask().intValue());
Assert.assertEquals(DEFAULT_PORT, ((NxAugMatchNodesNodeTableFlow) extensionAugment2.getAugmentationObject()).getNxmOfTcpSrc().getPort());
Assert.assertEquals(extensionAugment.getKey(), NxmOfTcpSrcKey.class);
final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment3 = tcpSrcConvertor.convert(matchEntry, MatchPath.FLOWS_STATISTICS_RPC_MATCH);
Assert.assertEquals(2, ((NxAugMatchRpcGetFlowStats) extensionAugment3.getAugmentationObject()).getNxmOfTcpSrc().getMask().intValue());
Assert.assertEquals(DEFAULT_PORT, ((NxAugMatchRpcGetFlowStats) extensionAugment3.getAugmentationObject()).getNxmOfTcpSrc().getPort());
Assert.assertEquals(extensionAugment.getKey(), NxmOfTcpSrcKey.class);
}
Aggregations