use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstAction in project openflowplugin by opendaylight.
the class SetTpDstActionSerializer method buildAction.
@Override
protected SetFieldCase buildAction(Action input) {
final SetTpDstAction setTpDstAction = SetTpDstActionCase.class.cast(input).getSetTpDstAction();
final PortNumber port = setTpDstAction.getPort();
final SetFieldBuilder builder = new SetFieldBuilder();
Optional.ofNullable(IPProtocols.fromProtocolNum(setTpDstAction.getIpProtocol())).ifPresent(proto -> {
switch(proto) {
case ICMP:
{
builder.setIcmpv4Match(new Icmpv4MatchBuilder().setIcmpv4Code((short) (0xFF & port.getValue())).build());
break;
}
case ICMPV6:
{
builder.setIcmpv6Match(new Icmpv6MatchBuilder().setIcmpv6Code((short) (0xFF & port.getValue())).build());
break;
}
case TCP:
{
builder.setLayer4Match(new TcpMatchBuilder().setTcpDestinationPort(port).build());
break;
}
case UDP:
{
builder.setLayer4Match(new UdpMatchBuilder().setUdpDestinationPort(port).build());
break;
}
default:
}
});
return new SetFieldCaseBuilder().setSetField(builder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstAction in project openflowplugin by opendaylight.
the class SalToOfSetTpDstActionV10Case method process.
@Nonnull
@Override
public Optional<Action> process(@Nonnull final SetTpDstActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
SetTpDstAction settpdstaction = source.getSetTpDstAction();
SetTpDstCaseBuilder setTpDstCaseBuilder = new SetTpDstCaseBuilder();
SetTpDstActionBuilder setTpDstActionBuilder = new SetTpDstActionBuilder();
setTpDstActionBuilder.setPort(new PortNumber(settpdstaction.getPort().getValue().longValue()));
setTpDstCaseBuilder.setSetTpDstAction(setTpDstActionBuilder.build());
return Optional.of(new ActionBuilder().setActionChoice(setTpDstCaseBuilder.build()).build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstAction 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());
}
Aggregations