use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.ArpThaCaseValueBuilder in project openflowplugin by opendaylight.
the class ArpThaConvertor method convert.
@Override
public MatchEntry convert(Extension extension) {
Optional<NxmNxArpThaGrouping> matchGrouping = MatchUtil.ARP_THA_RESOLVER.getExtension(extension);
if (!matchGrouping.isPresent()) {
throw new CodecPreconditionException(extension);
}
MacAddress macAddress = matchGrouping.get().getNxmNxArpTha().getMacAddress();
ArpThaCaseValueBuilder arpThaCaseValueBuilder = new ArpThaCaseValueBuilder();
arpThaCaseValueBuilder.setArpThaValues(new ArpThaValuesBuilder().setMacAddress(macAddress).build());
return MatchUtil.createDefaultMatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxArpTha.class, Nxm1Class.class, arpThaCaseValueBuilder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.ArpThaCaseValueBuilder in project openflowplugin by opendaylight.
the class ArpThaCodecTest method createMatchEntry.
private MatchEntry createMatchEntry() {
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
final ArpThaCaseValueBuilder caseBuilder = new ArpThaCaseValueBuilder();
final ArpThaValuesBuilder valuesBuilder = new ArpThaValuesBuilder();
matchEntryBuilder.setOxmClass(Nxm1Class.class);
matchEntryBuilder.setOxmMatchField(NxmNxArpTha.class);
matchEntryBuilder.setHasMask(false);
byte[] address = new byte[VALUE_LENGTH];
valuesBuilder.setMacAddress(new MacAddress(ByteBufUtils.macAddressToString(address)));
caseBuilder.setArpThaValues(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.ArpThaCaseValueBuilder in project openflowplugin by opendaylight.
the class ArpThaCodec method deserialize.
@Override
public MatchEntry deserialize(ByteBuf message) {
MatchEntryBuilder matchEntryBuilder = deserializeHeaderToBuilder(message);
byte[] address = new byte[VALUE_LENGTH];
message.readBytes(address);
ArpThaCaseValueBuilder caseBuilder = new ArpThaCaseValueBuilder();
caseBuilder.setArpThaValues(new ArpThaValuesBuilder().setMacAddress(new MacAddress(ByteBufUtils.macAddressToString(address))).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.ArpThaCaseValueBuilder in project openflowplugin by opendaylight.
the class ArpThaConvertorTest method testConvertFromOFJava.
@Test
public void testConvertFromOFJava() throws Exception {
final ArpThaValuesBuilder arpThaValuesBuilder = new ArpThaValuesBuilder().setMacAddress(MAC_ADDRESS);
final ArpThaCaseValueBuilder arpThaCaseValueBuilder = new ArpThaCaseValueBuilder().setArpThaValues(arpThaValuesBuilder.build());
final ArpThaCaseValue arpThaCaseValue = arpThaCaseValueBuilder.build();
when(matchEntry.getMatchEntryValue()).thenReturn(arpThaCaseValue);
final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment = arpThaConvertor.convert(matchEntry, MatchPath.PACKET_RECEIVED_MATCH);
Assert.assertEquals(arpThaCaseValue.getArpThaValues().getMacAddress(), ((NxAugMatchNotifPacketIn) extensionAugment.getAugmentationObject()).getNxmNxArpTha().getMacAddress());
Assert.assertEquals(extensionAugment.getKey(), NxmNxArpThaKey.class);
final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment1 = arpThaConvertor.convert(matchEntry, MatchPath.SWITCH_FLOW_REMOVED_MATCH);
Assert.assertEquals(arpThaCaseValue.getArpThaValues().getMacAddress(), ((NxAugMatchNotifSwitchFlowRemoved) extensionAugment1.getAugmentationObject()).getNxmNxArpTha().getMacAddress());
Assert.assertEquals(extensionAugment.getKey(), NxmNxArpThaKey.class);
final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment2 = arpThaConvertor.convert(matchEntry, MatchPath.FLOWS_STATISTICS_UPDATE_MATCH);
Assert.assertEquals(arpThaCaseValue.getArpThaValues().getMacAddress(), ((NxAugMatchNodesNodeTableFlow) extensionAugment2.getAugmentationObject()).getNxmNxArpTha().getMacAddress());
Assert.assertEquals(extensionAugment.getKey(), NxmNxArpThaKey.class);
final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment3 = arpThaConvertor.convert(matchEntry, MatchPath.FLOWS_STATISTICS_RPC_MATCH);
Assert.assertEquals(arpThaCaseValue.getArpThaValues().getMacAddress(), ((NxAugMatchRpcGetFlowStats) extensionAugment3.getAugmentationObject()).getNxmNxArpTha().getMacAddress());
Assert.assertEquals(extensionAugment.getKey(), NxmNxArpThaKey.class);
}
Aggregations