use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.tun.ipv4.src.grouping.TunIpv4SrcValuesBuilder in project openflowplugin by opendaylight.
the class TunIPv4SrcConvertorTest method testConvert1.
@Test
public void testConvert1() throws Exception {
final TunIpv4SrcValuesBuilder tunIpv4SrcValuesBuilder = new TunIpv4SrcValuesBuilder().setValue(IpConverter.ipv4AddressToLong(IPV4_ADDRESS));
final TunIpv4SrcCaseValueBuilder tunIpv4SrcCaseValueBuilder = new TunIpv4SrcCaseValueBuilder().setTunIpv4SrcValues(tunIpv4SrcValuesBuilder.build());
final TunIpv4SrcCaseValue tunIpv4SrcCaseValue = tunIpv4SrcCaseValueBuilder.build();
when(matchEntry.getMatchEntryValue()).thenReturn(tunIpv4SrcCaseValue);
final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment = tunIPv4DstConvertor.convert(matchEntry, MatchPath.PACKET_RECEIVED_MATCH);
Assert.assertEquals(IPV4_ADDRESS, ((NxAugMatchNotifPacketIn) extensionAugment.getAugmentationObject()).getNxmNxTunIpv4Src().getIpv4Address());
Assert.assertEquals(extensionAugment.getKey(), NxmNxTunIpv4SrcKey.class);
final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment1 = tunIPv4DstConvertor.convert(matchEntry, MatchPath.SWITCH_FLOW_REMOVED_MATCH);
Assert.assertEquals(IPV4_ADDRESS, ((NxAugMatchNotifSwitchFlowRemoved) extensionAugment1.getAugmentationObject()).getNxmNxTunIpv4Src().getIpv4Address());
Assert.assertEquals(extensionAugment.getKey(), NxmNxTunIpv4SrcKey.class);
final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment2 = tunIPv4DstConvertor.convert(matchEntry, MatchPath.FLOWS_STATISTICS_UPDATE_MATCH);
Assert.assertEquals(IPV4_ADDRESS, ((NxAugMatchNodesNodeTableFlow) extensionAugment2.getAugmentationObject()).getNxmNxTunIpv4Src().getIpv4Address());
Assert.assertEquals(extensionAugment.getKey(), NxmNxTunIpv4SrcKey.class);
final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment3 = tunIPv4DstConvertor.convert(matchEntry, MatchPath.FLOWS_STATISTICS_RPC_MATCH);
Assert.assertEquals(IPV4_ADDRESS, ((NxAugMatchRpcGetFlowStats) extensionAugment3.getAugmentationObject()).getNxmNxTunIpv4Src().getIpv4Address());
Assert.assertEquals(extensionAugment.getKey(), NxmNxTunIpv4SrcKey.class);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.tun.ipv4.src.grouping.TunIpv4SrcValuesBuilder in project openflowplugin by opendaylight.
the class TunIPv4SrcConvertor method convert.
@Override
public MatchEntry convert(Extension extension) {
Optional<NxmNxTunIpv4SrcGrouping> matchGrouping = MatchUtil.TUN_IPV4_SRC_RESOLVER.getExtension(extension);
if (!matchGrouping.isPresent()) {
throw new CodecPreconditionException(extension);
}
Ipv4Address value = matchGrouping.get().getNxmNxTunIpv4Src().getIpv4Address();
TunIpv4SrcCaseValueBuilder tunIpv4SrcCaseValueBuilder = new TunIpv4SrcCaseValueBuilder();
tunIpv4SrcCaseValueBuilder.setTunIpv4SrcValues(new TunIpv4SrcValuesBuilder().setValue(MatchUtil.ipv4ToLong(value)).build());
return MatchUtil.createDefaultMatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxTunIpv4Src.class, Nxm1Class.class, tunIpv4SrcCaseValueBuilder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.tun.ipv4.src.grouping.TunIpv4SrcValuesBuilder in project openflowplugin by opendaylight.
the class TunIpv4SrcCodecTest method createMatchEntry.
private MatchEntry createMatchEntry() {
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
final TunIpv4SrcCaseValueBuilder caseBuilder = new TunIpv4SrcCaseValueBuilder();
final TunIpv4SrcValuesBuilder valuesBuilder = new TunIpv4SrcValuesBuilder();
matchEntryBuilder.setOxmClass(Nxm1Class.class);
matchEntryBuilder.setOxmMatchField(NxmNxTunIpv4Src.class);
matchEntryBuilder.setHasMask(false);
valuesBuilder.setValue((long) 1);
caseBuilder.setTunIpv4SrcValues(valuesBuilder.build());
matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
return matchEntryBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.tun.ipv4.src.grouping.TunIpv4SrcValuesBuilder in project openflowplugin by opendaylight.
the class TunIpv4SrcCodec method deserialize.
@Override
public MatchEntry deserialize(ByteBuf message) {
MatchEntryBuilder matchEntriesBuilder = deserializeHeaderToBuilder(message);
TunIpv4SrcCaseValueBuilder caseBuilder = new TunIpv4SrcCaseValueBuilder();
TunIpv4SrcValuesBuilder valuesBuilder = new TunIpv4SrcValuesBuilder();
valuesBuilder.setValue(message.readUnsignedInt());
caseBuilder.setTunIpv4SrcValues(valuesBuilder.build());
matchEntriesBuilder.setMatchEntryValue(caseBuilder.build());
return matchEntriesBuilder.build();
}
Aggregations