use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder in project openflowplugin by opendaylight.
the class SalToOfSetNwTosActionCase method process.
@Nonnull
@Override
public Optional<Action> process(@Nonnull final SetNwTosActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
SetNwTosAction setnwtosaction = source.getSetNwTosAction();
SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
List<MatchEntry> entries = new ArrayList<>();
entries.add(MatchConvertorUtil.toOfIpDscp(new Dscp(ActionUtil.tosToDscp(setnwtosaction.getTos().shortValue()))));
setFieldBuilder.setMatchEntry(entries);
setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
return Optional.of(new ActionBuilder().setActionChoice(setFieldCaseBuilder.build()).build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder in project openflowplugin by opendaylight.
the class SalToOfSetTpDstActionCase method process.
@Nonnull
@Override
public Optional<Action> process(@Nonnull final SetTpDstActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
IPProtocols protocol = null;
if (data.getIpProtocol() != null) {
protocol = IPProtocols.fromProtocolNum(data.getIpProtocol());
}
SetTpDstAction settpdstaction = source.getSetTpDstAction();
MatchEntryBuilder matchBuilder = new MatchEntryBuilder();
matchBuilder.setOxmClass(OpenflowBasicClass.class);
matchBuilder.setHasMask(false);
int port = settpdstaction.getPort().getValue();
int code = 0xff & port;
if (protocol != null) {
switch(protocol) {
case ICMP:
matchBuilder.setOxmMatchField(Icmpv4Code.class);
Icmpv4CodeCaseBuilder icmpv4CodeCaseBuilder = new Icmpv4CodeCaseBuilder();
Icmpv4CodeBuilder icmpv4CodeBuilder = new Icmpv4CodeBuilder();
icmpv4CodeBuilder.setIcmpv4Code((short) code);
icmpv4CodeCaseBuilder.setIcmpv4Code(icmpv4CodeBuilder.build());
matchBuilder.setMatchEntryValue(icmpv4CodeCaseBuilder.build());
break;
case ICMPV6:
matchBuilder.setOxmMatchField(Icmpv6Code.class);
Icmpv6CodeCaseBuilder icmpv6CodeCaseBuilder = new Icmpv6CodeCaseBuilder();
Icmpv6CodeBuilder icmpv6CodeBuilder = new Icmpv6CodeBuilder();
icmpv6CodeBuilder.setIcmpv6Code((short) code);
icmpv6CodeCaseBuilder.setIcmpv6Code(icmpv6CodeBuilder.build());
matchBuilder.setMatchEntryValue(icmpv6CodeCaseBuilder.build());
break;
case TCP:
matchBuilder.setOxmMatchField(TcpDst.class);
TcpDstCaseBuilder tcpDstCaseBuilder = new TcpDstCaseBuilder();
TcpDstBuilder tcpDstBuilder = new TcpDstBuilder();
tcpDstBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(port));
tcpDstCaseBuilder.setTcpDst(tcpDstBuilder.build());
matchBuilder.setMatchEntryValue(tcpDstCaseBuilder.build());
break;
case UDP:
matchBuilder.setOxmMatchField(UdpDst.class);
UdpDstCaseBuilder udpDstCaseBuilder = new UdpDstCaseBuilder();
UdpDstBuilder udpDstBuilder = new UdpDstBuilder();
udpDstBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(port));
udpDstCaseBuilder.setUdpDst(udpDstBuilder.build());
matchBuilder.setMatchEntryValue(udpDstCaseBuilder.build());
break;
default:
LOG.warn("Unknown protocol with combination of SetSourcePort: {}", protocol);
break;
}
} else {
LOG.warn("Missing protocol with combination of SetSourcePort");
}
List<MatchEntry> entries = new ArrayList<>();
entries.add(matchBuilder.build());
SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
setFieldBuilder.setMatchEntry(entries);
SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
return Optional.of(new ActionBuilder().setActionChoice(setFieldCaseBuilder.build()).build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder in project openflowplugin by opendaylight.
the class SalToOfSetTpSrcActionCase method process.
@Nonnull
@Override
public Optional<Action> process(@Nonnull final SetTpSrcActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
IPProtocols protocol = null;
if (data.getIpProtocol() != null) {
protocol = IPProtocols.fromProtocolNum(data.getIpProtocol());
}
SetTpSrcAction settpsrcaction = source.getSetTpSrcAction();
MatchEntryBuilder matchBuilder = new MatchEntryBuilder();
matchBuilder.setOxmClass(OpenflowBasicClass.class);
matchBuilder.setHasMask(false);
int port = settpsrcaction.getPort().getValue();
int type = 0xff & port;
if (protocol != null) {
switch(protocol) {
case ICMP:
matchBuilder.setOxmMatchField(Icmpv4Type.class);
Icmpv4TypeCaseBuilder icmpv4TypeCaseBuilder = new Icmpv4TypeCaseBuilder();
Icmpv4TypeBuilder icmpv4TypeBuilder = new Icmpv4TypeBuilder();
icmpv4TypeBuilder.setIcmpv4Type((short) type);
icmpv4TypeCaseBuilder.setIcmpv4Type(icmpv4TypeBuilder.build());
matchBuilder.setMatchEntryValue(icmpv4TypeCaseBuilder.build());
break;
case ICMPV6:
matchBuilder.setOxmMatchField(Icmpv6Type.class);
Icmpv6TypeCaseBuilder icmpv6TypeCaseBuilder = new Icmpv6TypeCaseBuilder();
Icmpv6TypeBuilder icmpv6TypeBuilder = new Icmpv6TypeBuilder();
icmpv6TypeBuilder.setIcmpv6Type((short) type);
icmpv6TypeCaseBuilder.setIcmpv6Type(icmpv6TypeBuilder.build());
matchBuilder.setMatchEntryValue(icmpv6TypeCaseBuilder.build());
break;
case TCP:
matchBuilder.setOxmMatchField(TcpSrc.class);
TcpSrcCaseBuilder tcpSrcCaseBuilder = new TcpSrcCaseBuilder();
TcpSrcBuilder tcpSrcBuilder = new TcpSrcBuilder();
tcpSrcBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(port));
tcpSrcCaseBuilder.setTcpSrc(tcpSrcBuilder.build());
matchBuilder.setMatchEntryValue(tcpSrcCaseBuilder.build());
break;
case UDP:
matchBuilder.setOxmMatchField(UdpSrc.class);
UdpSrcCaseBuilder udpSrcCaseBuilder = new UdpSrcCaseBuilder();
UdpSrcBuilder udpSrcBuilder = new UdpSrcBuilder();
udpSrcBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(port));
udpSrcCaseBuilder.setUdpSrc(udpSrcBuilder.build());
matchBuilder.setMatchEntryValue(udpSrcCaseBuilder.build());
break;
default:
LOG.warn("Unknown protocol with combination of SetSourcePort: {}", protocol);
break;
}
} else {
LOG.warn("Null protocol with combination of SetSourcePort");
}
List<MatchEntry> entries = new ArrayList<>();
entries.add(matchBuilder.build());
SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
setFieldBuilder.setMatchEntry(entries);
SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
return Optional.of(new ActionBuilder().setActionChoice(setFieldCaseBuilder.build()).build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder in project openflowplugin by opendaylight.
the class SalToOfStripVlanActionCase method process.
@Nonnull
@Override
public Optional<Action> process(@Nonnull final StripVlanActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
MatchEntryBuilder matchBuilder = new MatchEntryBuilder();
matchBuilder.setOxmClass(OpenflowBasicClass.class);
matchBuilder.setOxmMatchField(VlanVid.class);
matchBuilder.setHasMask(false);
VlanVidCaseBuilder vlanVidCaseBuilder = new VlanVidCaseBuilder();
VlanVidBuilder vlanVidBuilder = new VlanVidBuilder();
vlanVidBuilder.setCfiBit(true);
vlanVidBuilder.setVlanVid(0x0000);
vlanVidCaseBuilder.setVlanVid(vlanVidBuilder.build());
matchBuilder.setMatchEntryValue(vlanVidCaseBuilder.build());
matchBuilder.setHasMask(false);
List<MatchEntry> entries = new ArrayList<>();
entries.add(matchBuilder.build());
SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
setFieldBuilder.setMatchEntry(entries);
SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
return Optional.of(new ActionBuilder().setActionChoice(setFieldCaseBuilder.build()).build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder in project openflowplugin by opendaylight.
the class SetFieldExtensionTest method testGetExtension.
@Test
public void testGetExtension() {
GroupingLooseResolver<GeneralExtensionListGrouping> eqGroup = new GroupingLooseResolver<>(GeneralExtensionListGrouping.class);
eqGroup.add(GeneralAugMatchRpcAddFlowWriteActionsSetField.class);
eqGroup.add(GeneralAugMatchNodesNodeTableFlowWriteActionsSetField.class);
SetFieldBuilder sb1 = new SetFieldBuilder();
ExtensionList extension1 = new ExtensionListBuilder().setExtensionKey(ZVendorExt1.class).build();
GeneralAugMatchRpcAddFlowWriteActionsSetField odlxxx1 = new GeneralAugMatchRpcAddFlowWriteActionsSetFieldBuilder().setExtensionList(Collections.singletonList(extension1)).build();
SetField setField1 = sb1.addAugmentation(GeneralAugMatchRpcAddFlowWriteActionsSetField.class, odlxxx1).build();
SetFieldBuilder sb2 = new SetFieldBuilder();
ExtensionList extension2 = new ExtensionListBuilder().setExtensionKey(ZVendorExt2.class).build();
GeneralAugMatchNodesNodeTableFlowWriteActionsSetField odlxxx2 = new GeneralAugMatchNodesNodeTableFlowWriteActionsSetFieldBuilder().setExtensionList(Collections.singletonList(extension2)).build();
SetField setField2 = sb2.addAugmentation(GeneralAugMatchNodesNodeTableFlowWriteActionsSetField.class, odlxxx2).build();
Assert.assertEquals(ZVendorExt1.class, eqGroup.getExtension(setField1).get().getExtensionList().get(0).getExtensionKey());
Assert.assertEquals(ZVendorExt2.class, eqGroup.getExtension(setField2).get().getExtensionList().get(0).getExtensionKey());
}
Aggregations