use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.TcpDstCaseValueBuilder in project openflowplugin by opendaylight.
the class TcpDstConvertorTest method testConvert1.
@Test
public void testConvert1() throws Exception {
final TcpDstValuesBuilder tcpDstValuesBuilder = new TcpDstValuesBuilder().setMask(2).setPort(DEFAULT_PORT);
final TcpDstCaseValueBuilder tcpDstCaseValueBuilder = new TcpDstCaseValueBuilder().setTcpDstValues(tcpDstValuesBuilder.build());
final TcpDstCaseValue tcpDstCaseValue = tcpDstCaseValueBuilder.build();
when(matchEntry.getMatchEntryValue()).thenReturn(tcpDstCaseValue);
final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment = tcpDstConvertor.convert(matchEntry, MatchPath.PACKET_RECEIVED_MATCH);
Assert.assertEquals(2, ((NxAugMatchNotifPacketIn) extensionAugment.getAugmentationObject()).getNxmOfTcpDst().getMask().intValue());
Assert.assertEquals(DEFAULT_PORT, ((NxAugMatchNotifPacketIn) extensionAugment.getAugmentationObject()).getNxmOfTcpDst().getPort());
Assert.assertEquals(extensionAugment.getKey(), NxmOfTcpDstKey.class);
final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment1 = tcpDstConvertor.convert(matchEntry, MatchPath.SWITCH_FLOW_REMOVED_MATCH);
Assert.assertEquals(2, ((NxAugMatchNotifSwitchFlowRemoved) extensionAugment1.getAugmentationObject()).getNxmOfTcpDst().getMask().intValue());
Assert.assertEquals(DEFAULT_PORT, ((NxAugMatchNotifSwitchFlowRemoved) extensionAugment1.getAugmentationObject()).getNxmOfTcpDst().getPort());
Assert.assertEquals(extensionAugment.getKey(), NxmOfTcpDstKey.class);
final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment2 = tcpDstConvertor.convert(matchEntry, MatchPath.FLOWS_STATISTICS_UPDATE_MATCH);
Assert.assertEquals(2, ((NxAugMatchNodesNodeTableFlow) extensionAugment2.getAugmentationObject()).getNxmOfTcpDst().getMask().intValue());
Assert.assertEquals(DEFAULT_PORT, ((NxAugMatchNodesNodeTableFlow) extensionAugment2.getAugmentationObject()).getNxmOfTcpDst().getPort());
Assert.assertEquals(extensionAugment.getKey(), NxmOfTcpDstKey.class);
final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment3 = tcpDstConvertor.convert(matchEntry, MatchPath.FLOWS_STATISTICS_RPC_MATCH);
Assert.assertEquals(2, ((NxAugMatchRpcGetFlowStats) extensionAugment3.getAugmentationObject()).getNxmOfTcpDst().getMask().intValue());
Assert.assertEquals(DEFAULT_PORT, ((NxAugMatchRpcGetFlowStats) extensionAugment3.getAugmentationObject()).getNxmOfTcpDst().getPort());
Assert.assertEquals(extensionAugment.getKey(), NxmOfTcpDstKey.class);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.TcpDstCaseValueBuilder in project openflowplugin by opendaylight.
the class TcpDstConvertor method convert.
@Override
public MatchEntry convert(Extension extension) {
Optional<NxmOfTcpDstGrouping> matchGrouping = MatchUtil.TCP_DST_RESOLVER.getExtension(extension);
if (!matchGrouping.isPresent()) {
throw new CodecPreconditionException(extension);
}
TcpDstCaseValueBuilder tcpDstCaseValueBuilder = new TcpDstCaseValueBuilder();
TcpDstValuesBuilder tcpDstValuesBuilder = new TcpDstValuesBuilder();
tcpDstValuesBuilder.setPort(matchGrouping.get().getNxmOfTcpDst().getPort());
tcpDstValuesBuilder.setMask(matchGrouping.get().getNxmOfTcpDst().getMask());
tcpDstCaseValueBuilder.setTcpDstValues(tcpDstValuesBuilder.build());
MatchEntryBuilder ofMatch = MatchUtil.createDefaultMatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmOfTcpDst.class, Nxm0Class.class, tcpDstCaseValueBuilder.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.TcpDstCaseValueBuilder in project openflowplugin by opendaylight.
the class TcpDstCodecTest method createMatchEntry.
private MatchEntry createMatchEntry() {
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
final TcpDstCaseValueBuilder caseBuilder = new TcpDstCaseValueBuilder();
final TcpDstValuesBuilder valuesBuilder = new TcpDstValuesBuilder();
matchEntryBuilder.setOxmClass(Nxm0Class.class);
matchEntryBuilder.setOxmMatchField(NxmOfTcpDst.class);
matchEntryBuilder.setHasMask(true);
valuesBuilder.setPort(new PortNumber(1));
valuesBuilder.setMask(0xffff);
caseBuilder.setTcpDstValues(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.TcpDstCaseValueBuilder in project openflowplugin by opendaylight.
the class TcpDstCodec method deserialize.
@Override
public MatchEntry deserialize(ByteBuf message) {
MatchEntryBuilder matchEntryBuilder = deserializeHeaderToBuilder(message);
matchEntryBuilder.setHasMask(true);
int portNo = message.readUnsignedShort();
int mask = message.readUnsignedShort();
TcpDstCaseValueBuilder caseBuilder = new TcpDstCaseValueBuilder();
TcpDstValuesBuilder tcpDstValuesBuilder = new TcpDstValuesBuilder();
tcpDstValuesBuilder.setPort(new PortNumber(portNo));
tcpDstValuesBuilder.setMask(mask);
caseBuilder.setTcpDstValues(tcpDstValuesBuilder.build());
matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
return matchEntryBuilder.build();
}
Aggregations