use of org.projectfloodlight.openflow.types.U8 in project onos by opennetworkinglab.
the class OfdpaExtensionSelectorInterpreter method mapOxm.
@Override
public ExtensionSelector mapOxm(OFOxm<?> oxm) {
VlanId vlanId;
if (oxm.getMatchField().equals(MatchField.VLAN_VID)) {
if (oxm.isMasked()) {
OFVlanVidMatch vid = ((OFOxmVlanVidMasked) oxm).getValue();
OFVlanVidMatch mask = ((OFOxmVlanVidMasked) oxm).getMask();
if (vid.equals(OFVlanVidMatch.ofRawVid((short) 0))) {
vlanId = VlanId.NONE;
} else if (vid.equals(OFVlanVidMatch.PRESENT) && mask.equals(OFVlanVidMatch.PRESENT)) {
vlanId = VlanId.ANY;
} else {
vlanId = VlanId.vlanId(vid.getVlan());
}
} else {
OFVlanVidMatch vid = ((OFOxmVlanVid) oxm).getValue();
if (!vid.isPresentBitSet()) {
vlanId = VlanId.NONE;
} else {
vlanId = VlanId.vlanId(vid.getVlan());
}
}
return new OfdpaMatchVlanVid(vlanId);
} else if (oxm.getMatchField().equals(MatchField.OFDPA_ACTSET_OUTPUT)) {
U32 portNumberU32 = ((OFOxmOfdpaActsetOutput) oxm).getValue();
PortNumber portNumber = PortNumber.portNumber(portNumberU32.getValue());
return new OfdpaMatchActsetOutput(portNumber);
} else if (oxm.getMatchField().equals(MatchField.OFDPA_ALLOW_VLAN_TRANSLATION)) {
U8 value = ((OFOxmOfdpaAllowVlanTranslation) oxm).getValue();
return new OfdpaMatchAllowVlanTranslation(value.getValue());
}
throw new UnsupportedOperationException("Unexpected OXM: " + oxm.toString());
}
use of org.projectfloodlight.openflow.types.U8 in project onos by opennetworkinglab.
the class Ofdpa3ExtensionSelectorInterpreter method mapOxm.
@Override
public ExtensionSelector mapOxm(OFOxm<?> oxm) {
if (oxm.getMatchField().equals(MatchField.OFDPA_OVID)) {
VlanId vlanId;
if (oxm.isMasked()) {
throw new UnsupportedOperationException("Unexpected OXM: " + oxm.toString());
} else {
OFOxmOfdpaOvid ovid = ((OFOxmOfdpaOvid) oxm);
short mask = (short) 0x0FFF;
short oVid = (short) (mask & ovid.getValue().getRaw());
vlanId = VlanId.vlanId(oVid);
}
return new Ofdpa3MatchOvid(vlanId);
} else if (oxm.getMatchField().equals(MatchField.OFDPA_MPLS_L2_PORT)) {
Integer mplsL2Port;
/*
* Supported but not used for now.
*/
if (oxm.isMasked()) {
throw new UnsupportedOperationException("Unexpected OXM: " + oxm.toString());
} else {
OFOxmOfdpaMplsL2Port mplsl2port = ((OFOxmOfdpaMplsL2Port) oxm);
mplsL2Port = mplsl2port.getValue().getRaw();
/*
* 0x0000XXXX UNI Interface.
* 0x0002XXXX NNI Interface
*/
if ((mplsL2Port >= 0 && mplsL2Port <= 0x0000FFFF) || (mplsL2Port >= 0x00020000 && mplsL2Port <= 0x0002FFFF)) {
return new Ofdpa3MatchMplsL2Port(mplsL2Port);
}
throw new UnsupportedOperationException("Unexpected OXM: " + oxm.toString());
}
} else if (oxm.getMatchField().equals(MatchField.OFDPA_ACTSET_OUTPUT)) {
U32 portNumberU32 = ((OFOxmOfdpaActsetOutput) oxm).getValue();
PortNumber portNumber = PortNumber.portNumber(portNumberU32.getValue());
return new OfdpaMatchActsetOutput(portNumber);
} else if (oxm.getMatchField().equals(MatchField.OFDPA_ALLOW_VLAN_TRANSLATION)) {
U8 value = ((OFOxmOfdpaAllowVlanTranslation) oxm).getValue();
return new OfdpaMatchAllowVlanTranslation(value.getValue());
}
throw new UnsupportedOperationException("Unexpected OXM: " + oxm.toString());
}
use of org.projectfloodlight.openflow.types.U8 in project onos by opennetworkinglab.
the class FlowEntryBuilder method buildSelector.
// CHECKSTYLE IGNORE MethodLength FOR NEXT 1 LINES
private TrafficSelector buildSelector() {
MacAddress mac;
Ip4Prefix ip4Prefix;
Ip6Address ip6Address;
Ip6Prefix ip6Prefix;
Ip4Address ip;
ExtensionSelectorInterpreter selectorInterpreter;
if (driverHandler.hasBehaviour(ExtensionSelectorInterpreter.class)) {
selectorInterpreter = driverHandler.behaviour(ExtensionSelectorInterpreter.class);
} else {
selectorInterpreter = null;
}
TrafficSelector.Builder builder = DefaultTrafficSelector.builder();
for (MatchField<?> field : match.getMatchFields()) {
switch(field.id) {
case IN_PORT:
builder.matchInPort(PortNumber.portNumber(match.get(MatchField.IN_PORT).getPortNumber()));
break;
case IN_PHY_PORT:
builder.matchInPhyPort(PortNumber.portNumber(match.get(MatchField.IN_PHY_PORT).getPortNumber()));
break;
case METADATA:
long metadata = match.get(MatchField.METADATA).getValue().getValue();
builder.matchMetadata(metadata);
break;
case ETH_DST:
if (match.isPartiallyMasked(MatchField.ETH_DST)) {
Masked<org.projectfloodlight.openflow.types.MacAddress> maskedMac = match.getMasked(MatchField.ETH_DST);
builder.matchEthDstMasked(MacAddress.valueOf(maskedMac.getValue().getLong()), MacAddress.valueOf(maskedMac.getMask().getLong()));
} else {
mac = MacAddress.valueOf(match.get(MatchField.ETH_DST).getLong());
builder.matchEthDst(mac);
}
break;
case ETH_SRC:
if (match.isPartiallyMasked(MatchField.ETH_SRC)) {
Masked<org.projectfloodlight.openflow.types.MacAddress> maskedMac = match.getMasked(MatchField.ETH_SRC);
builder.matchEthSrcMasked(MacAddress.valueOf(maskedMac.getValue().getLong()), MacAddress.valueOf(maskedMac.getMask().getLong()));
} else {
mac = MacAddress.valueOf(match.get(MatchField.ETH_SRC).getLong());
builder.matchEthSrc(mac);
}
break;
case ETH_TYPE:
int ethType = match.get(MatchField.ETH_TYPE).getValue();
builder.matchEthType((short) ethType);
break;
case VLAN_VID:
if (selectorInterpreter != null && selectorInterpreter.supported(ExtensionSelectorTypes.OFDPA_MATCH_VLAN_VID.type())) {
if (isOF13OrLater(match)) {
OFOxm oxm = ((OFMatchV3) match).getOxmList().get(MatchField.VLAN_VID);
builder.extension(selectorInterpreter.mapOxm(oxm), deviceId);
} else {
break;
}
} else {
VlanId vlanId = null;
if (match.isPartiallyMasked(MatchField.VLAN_VID)) {
Masked<OFVlanVidMatch> masked = match.getMasked(MatchField.VLAN_VID);
if (masked.getValue().equals(OFVlanVidMatch.PRESENT) && masked.getMask().equals(OFVlanVidMatch.PRESENT)) {
vlanId = VlanId.ANY;
}
} else {
if (!match.get(MatchField.VLAN_VID).isPresentBitSet()) {
vlanId = VlanId.NONE;
} else {
vlanId = VlanId.vlanId(match.get(MatchField.VLAN_VID).getVlan());
}
}
if (vlanId != null) {
builder.matchVlanId(vlanId);
}
}
break;
case VLAN_PCP:
byte vlanPcp = match.get(MatchField.VLAN_PCP).getValue();
builder.matchVlanPcp(vlanPcp);
break;
case IP_DSCP:
byte ipDscp = match.get(MatchField.IP_DSCP).getDscpValue();
builder.matchIPDscp(ipDscp);
break;
case IP_ECN:
byte ipEcn = match.get(MatchField.IP_ECN).getEcnValue();
builder.matchIPEcn(ipEcn);
break;
case IP_PROTO:
short proto = match.get(MatchField.IP_PROTO).getIpProtocolNumber();
builder.matchIPProtocol((byte) proto);
break;
case IPV4_SRC:
if (match.isPartiallyMasked(MatchField.IPV4_SRC)) {
Masked<IPv4Address> maskedIp = match.getMasked(MatchField.IPV4_SRC);
ip4Prefix = Ip4Prefix.valueOf(maskedIp.getValue().getInt(), maskedIp.getMask().asCidrMaskLength());
} else {
ip4Prefix = Ip4Prefix.valueOf(match.get(MatchField.IPV4_SRC).getInt(), Ip4Prefix.MAX_MASK_LENGTH);
}
builder.matchIPSrc(ip4Prefix);
break;
case IPV4_DST:
if (match.isPartiallyMasked(MatchField.IPV4_DST)) {
Masked<IPv4Address> maskedIp = match.getMasked(MatchField.IPV4_DST);
ip4Prefix = Ip4Prefix.valueOf(maskedIp.getValue().getInt(), maskedIp.getMask().asCidrMaskLength());
} else {
ip4Prefix = Ip4Prefix.valueOf(match.get(MatchField.IPV4_DST).getInt(), Ip4Prefix.MAX_MASK_LENGTH);
}
builder.matchIPDst(ip4Prefix);
break;
case TCP_SRC:
if (match.isPartiallyMasked(MatchField.TCP_SRC)) {
Masked<org.projectfloodlight.openflow.types.TransportPort> maskedPort = match.getMasked(MatchField.TCP_SRC);
builder.matchTcpSrcMasked(TpPort.tpPort(maskedPort.getValue().getPort()), TpPort.tpPort(maskedPort.getMask().getPort()));
} else {
builder.matchTcpSrc(TpPort.tpPort(match.get(MatchField.TCP_SRC).getPort()));
}
break;
case TCP_DST:
if (match.isPartiallyMasked(MatchField.TCP_DST)) {
Masked<org.projectfloodlight.openflow.types.TransportPort> maskedPort = match.getMasked(MatchField.TCP_DST);
builder.matchTcpDstMasked(TpPort.tpPort(maskedPort.getValue().getPort()), TpPort.tpPort(maskedPort.getMask().getPort()));
} else {
builder.matchTcpDst(TpPort.tpPort(match.get(MatchField.TCP_DST).getPort()));
}
break;
case UDP_SRC:
if (match.isPartiallyMasked(MatchField.UDP_SRC)) {
Masked<org.projectfloodlight.openflow.types.TransportPort> maskedPort = match.getMasked(MatchField.UDP_SRC);
builder.matchUdpSrcMasked(TpPort.tpPort(maskedPort.getValue().getPort()), TpPort.tpPort(maskedPort.getMask().getPort()));
} else {
builder.matchUdpSrc(TpPort.tpPort(match.get(MatchField.UDP_SRC).getPort()));
}
break;
case UDP_DST:
if (match.isPartiallyMasked(MatchField.UDP_DST)) {
Masked<org.projectfloodlight.openflow.types.TransportPort> maskedPort = match.getMasked(MatchField.UDP_DST);
builder.matchUdpDstMasked(TpPort.tpPort(maskedPort.getValue().getPort()), TpPort.tpPort(maskedPort.getMask().getPort()));
} else {
builder.matchUdpDst(TpPort.tpPort(match.get(MatchField.UDP_DST).getPort()));
}
break;
case MPLS_LABEL:
builder.matchMplsLabel(MplsLabel.mplsLabel((int) match.get(MatchField.MPLS_LABEL).getValue()));
break;
case MPLS_BOS:
builder.matchMplsBos(match.get(MatchField.MPLS_BOS).getValue());
break;
case SCTP_SRC:
if (match.isPartiallyMasked(MatchField.SCTP_SRC)) {
Masked<org.projectfloodlight.openflow.types.TransportPort> maskedPort = match.getMasked(MatchField.SCTP_SRC);
builder.matchSctpSrcMasked(TpPort.tpPort(maskedPort.getValue().getPort()), TpPort.tpPort(maskedPort.getMask().getPort()));
} else {
builder.matchSctpSrc(TpPort.tpPort(match.get(MatchField.SCTP_SRC).getPort()));
}
break;
case SCTP_DST:
if (match.isPartiallyMasked(MatchField.SCTP_DST)) {
Masked<org.projectfloodlight.openflow.types.TransportPort> maskedPort = match.getMasked(MatchField.SCTP_DST);
builder.matchSctpDstMasked(TpPort.tpPort(maskedPort.getValue().getPort()), TpPort.tpPort(maskedPort.getMask().getPort()));
} else {
builder.matchSctpDst(TpPort.tpPort(match.get(MatchField.SCTP_DST).getPort()));
}
break;
case ICMPV4_TYPE:
byte icmpType = (byte) match.get(MatchField.ICMPV4_TYPE).getType();
builder.matchIcmpType(icmpType);
break;
case ICMPV4_CODE:
byte icmpCode = (byte) match.get(MatchField.ICMPV4_CODE).getCode();
builder.matchIcmpCode(icmpCode);
break;
case IPV6_SRC:
if (match.isPartiallyMasked(MatchField.IPV6_SRC)) {
Masked<IPv6Address> maskedIp = match.getMasked(MatchField.IPV6_SRC);
ip6Prefix = Ip6Prefix.valueOf(maskedIp.getValue().getBytes(), maskedIp.getMask().asCidrMaskLength());
} else {
ip6Prefix = Ip6Prefix.valueOf(match.get(MatchField.IPV6_SRC).getBytes(), Ip6Prefix.MAX_MASK_LENGTH);
}
builder.matchIPv6Src(ip6Prefix);
break;
case IPV6_DST:
if (match.isPartiallyMasked(MatchField.IPV6_DST)) {
Masked<IPv6Address> maskedIp = match.getMasked(MatchField.IPV6_DST);
ip6Prefix = Ip6Prefix.valueOf(maskedIp.getValue().getBytes(), maskedIp.getMask().asCidrMaskLength());
} else {
ip6Prefix = Ip6Prefix.valueOf(match.get(MatchField.IPV6_DST).getBytes(), Ip6Prefix.MAX_MASK_LENGTH);
}
builder.matchIPv6Dst(ip6Prefix);
break;
case IPV6_FLABEL:
int flowLabel = match.get(MatchField.IPV6_FLABEL).getIPv6FlowLabelValue();
builder.matchIPv6FlowLabel(flowLabel);
break;
case ICMPV6_TYPE:
byte icmpv6type = (byte) match.get(MatchField.ICMPV6_TYPE).getValue();
builder.matchIcmpv6Type(icmpv6type);
break;
case ICMPV6_CODE:
byte icmpv6code = (byte) match.get(MatchField.ICMPV6_CODE).getValue();
builder.matchIcmpv6Code(icmpv6code);
break;
case IPV6_ND_TARGET:
ip6Address = Ip6Address.valueOf(match.get(MatchField.IPV6_ND_TARGET).getBytes());
builder.matchIPv6NDTargetAddress(ip6Address);
break;
case IPV6_ND_SLL:
mac = MacAddress.valueOf(match.get(MatchField.IPV6_ND_SLL).getLong());
builder.matchIPv6NDSourceLinkLayerAddress(mac);
break;
case IPV6_ND_TLL:
mac = MacAddress.valueOf(match.get(MatchField.IPV6_ND_TLL).getLong());
builder.matchIPv6NDTargetLinkLayerAddress(mac);
break;
case IPV6_EXTHDR:
builder.matchIPv6ExthdrFlags((short) match.get(MatchField.IPV6_EXTHDR).getValue());
break;
case OCH_SIGID:
CircuitSignalID sigId = match.get(MatchField.OCH_SIGID);
builder.add(matchLambda(Lambda.ochSignal(lookupGridType(sigId.getGridType()), lookupChannelSpacing(sigId.getChannelSpacing()), sigId.getChannelNumber(), sigId.getSpectralWidth())));
break;
case OCH_SIGTYPE:
U8 sigType = match.get(MatchField.OCH_SIGTYPE);
builder.add(matchOchSignalType(lookupOchSignalType((byte) sigType.getValue())));
break;
case EXP_OCH_SIG_ID:
try {
CircuitSignalID expSigId = match.get(MatchField.EXP_OCH_SIG_ID);
builder.add(matchLambda(Lambda.ochSignal(lookupGridType(expSigId.getGridType()), lookupChannelSpacing(expSigId.getChannelSpacing()), expSigId.getChannelNumber(), expSigId.getSpectralWidth())));
} catch (NoMappingFoundException e) {
log.warn(e.getMessage());
break;
}
break;
case EXP_OCH_SIGTYPE:
try {
U8 expOchSigType = match.get(MatchField.EXP_OCH_SIGTYPE);
builder.add(matchOchSignalType(lookupOchSignalType((byte) expOchSigType.getValue())));
} catch (NoMappingFoundException e) {
log.warn(e.getMessage());
break;
}
break;
case EXP_ODU_SIG_ID:
OduSignalId oduSignalId = OduSignalId.oduSignalId(match.get(MatchField.EXP_ODU_SIG_ID).getTpn(), match.get(MatchField.EXP_ODU_SIG_ID).getTslen(), match.get(MatchField.EXP_ODU_SIG_ID).getTsmap());
builder.add(matchOduSignalId(oduSignalId));
break;
case EXP_ODU_SIGTYPE:
try {
U8 oduSigType = match.get(MatchField.EXP_ODU_SIGTYPE);
builder.add(matchOduSignalType(lookupOduSignalType((byte) oduSigType.getValue())));
} catch (NoMappingFoundException e) {
log.warn(e.getMessage());
break;
}
break;
case TUNNEL_ID:
long tunnelId = match.get(MatchField.TUNNEL_ID).getValue();
builder.matchTunnelId(tunnelId);
break;
case ARP_OP:
int arpOp = match.get(MatchField.ARP_OP).getOpcode();
builder.matchArpOp(arpOp);
break;
case ARP_SHA:
mac = MacAddress.valueOf(match.get(MatchField.ARP_SHA).getLong());
builder.matchArpSha(mac);
break;
case ARP_SPA:
ip = Ip4Address.valueOf(match.get(MatchField.ARP_SPA).getInt());
builder.matchArpSpa(ip);
break;
case ARP_THA:
mac = MacAddress.valueOf(match.get(MatchField.ARP_THA).getLong());
builder.matchArpTha(mac);
break;
case ARP_TPA:
ip = Ip4Address.valueOf(match.get(MatchField.ARP_TPA).getInt());
builder.matchArpTpa(ip);
break;
case NSP:
if (selectorInterpreter != null) {
try {
OFOxm oxm = ((OFMatchV3) match).getOxmList().get(MatchField.NSP);
builder.extension(selectorInterpreter.mapOxm(oxm), deviceId);
} catch (UnsupportedOperationException e) {
log.debug(e.getMessage());
}
}
break;
case NSI:
if (selectorInterpreter != null) {
try {
OFOxm oxm = ((OFMatchV3) match).getOxmList().get(MatchField.NSI);
builder.extension(selectorInterpreter.mapOxm(oxm), deviceId);
} catch (UnsupportedOperationException e) {
log.debug(e.getMessage());
}
}
break;
case ENCAP_ETH_TYPE:
if (selectorInterpreter != null) {
try {
OFOxm oxm = ((OFMatchV3) match).getOxmList().get(MatchField.ENCAP_ETH_TYPE);
builder.extension(selectorInterpreter.mapOxm(oxm), deviceId);
} catch (UnsupportedOperationException e) {
log.debug(e.getMessage());
}
}
break;
case CONNTRACK_STATE:
if (selectorInterpreter != null && selectorInterpreter.supported(ExtensionSelectorTypes.NICIRA_MATCH_CONNTRACK_STATE.type())) {
try {
OFOxm oxm = ((OFMatchV3) match).getOxmList().get(MatchField.CONNTRACK_STATE);
builder.extension(selectorInterpreter.mapOxm(oxm), deviceId);
} catch (UnsupportedOperationException e) {
log.debug(e.getMessage());
}
}
break;
case CONNTRACK_ZONE:
if (selectorInterpreter != null && selectorInterpreter.supported(ExtensionSelectorTypes.NICIRA_MATCH_CONNTRACK_ZONE.type())) {
try {
OFOxm oxm = ((OFMatchV3) match).getOxmList().get(MatchField.CONNTRACK_ZONE);
builder.extension(selectorInterpreter.mapOxm(oxm), deviceId);
} catch (UnsupportedOperationException e) {
log.debug(e.getMessage());
}
}
break;
case CONNTRACK_MARK:
if (selectorInterpreter != null && selectorInterpreter.supported(ExtensionSelectorTypes.NICIRA_MATCH_CONNTRACK_MARK.type())) {
try {
OFOxm oxm = ((OFMatchV3) match).getOxmList().get(MatchField.CONNTRACK_MARK);
builder.extension(selectorInterpreter.mapOxm(oxm), deviceId);
} catch (UnsupportedOperationException e) {
log.debug(e.getMessage());
}
}
break;
case OFDPA_OVID:
if (selectorInterpreter != null && selectorInterpreter.supported(ExtensionSelectorTypes.OFDPA_MATCH_OVID.type())) {
if (isOF13OrLater(match)) {
OFOxm oxm = ((OFMatchV3) match).getOxmList().get(MatchField.OFDPA_OVID);
builder.extension(selectorInterpreter.mapOxm(oxm), deviceId);
} else {
break;
}
}
break;
case OFDPA_MPLS_L2_PORT:
if (selectorInterpreter != null && selectorInterpreter.supported(ExtensionSelectorTypes.OFDPA_MATCH_MPLS_L2_PORT.type())) {
if (isOF13OrLater(match)) {
OFOxm oxm = ((OFMatchV3) match).getOxmList().get(MatchField.OFDPA_MPLS_L2_PORT);
builder.extension(selectorInterpreter.mapOxm(oxm), deviceId);
} else {
break;
}
}
break;
case OFDPA_ALLOW_VLAN_TRANSLATION:
if (selectorInterpreter != null && selectorInterpreter.supported(ExtensionSelectorTypes.OFDPA_MATCH_ALLOW_VLAN_TRANSLATION.type())) {
if (isOF13OrLater(match)) {
OFOxm oxm = ((OFMatchV3) match).getOxmList().get(MatchField.OFDPA_ALLOW_VLAN_TRANSLATION);
builder.extension(selectorInterpreter.mapOxm(oxm), deviceId);
} else {
break;
}
}
break;
case OFDPA_ACTSET_OUTPUT:
if (selectorInterpreter != null && selectorInterpreter.supported(ExtensionSelectorTypes.OFDPA_MATCH_ACTSET_OUTPUT.type())) {
if (isOF13OrLater(match)) {
OFOxm oxm = ((OFMatchV3) match).getOxmList().get(MatchField.OFDPA_ACTSET_OUTPUT);
builder.extension(selectorInterpreter.mapOxm(oxm), deviceId);
} else {
break;
}
}
break;
case MPLS_TC:
default:
log.warn("Match type {} not yet implemented.", field.id);
}
}
return builder.build();
}
use of org.projectfloodlight.openflow.types.U8 in project onos by opennetworkinglab.
the class NiciraExtensionTreatmentInterpreter method mapInstruction.
@Override
public OFAction mapInstruction(OFFactory factory, ExtensionTreatment extensionTreatment) {
ExtensionTreatmentType type = extensionTreatment.type();
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_TUNNEL_DST.type())) {
NiciraSetTunnelDst tunnelDst = (NiciraSetTunnelDst) extensionTreatment;
return factory.actions().setField(factory.oxms().tunnelIpv4Dst(IPv4Address.of(tunnelDst.tunnelDst().toInt())));
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_RESUBMIT.type())) {
NiciraResubmit resubmit = (NiciraResubmit) extensionTreatment;
return factory.actions().niciraResubmit((int) resubmit.inPort().toLong(), resubmit.table());
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_RESUBMIT_TABLE.type())) {
NiciraResubmitTable resubmitTable = (NiciraResubmitTable) extensionTreatment;
return factory.actions().niciraResubmitTable((int) resubmitTable.inPort().toLong(), resubmitTable.table());
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_SPI.type())) {
NiciraSetNshSpi niciraNshSpi = (NiciraSetNshSpi) extensionTreatment;
return factory.actions().setField(factory.oxms().nsp(U32.of(niciraNshSpi.nshSpi().servicePathId())));
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_SI.type())) {
NiciraSetNshSi niciraNshSi = (NiciraSetNshSi) extensionTreatment;
return factory.actions().setField(factory.oxms().nsi(U8.of(niciraNshSi.nshSi().serviceIndex())));
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_CH1.type())) {
NiciraSetNshContextHeader niciraNshch = (NiciraSetNshContextHeader) extensionTreatment;
return factory.actions().setField(factory.oxms().nshC1(U32.of(niciraNshch.nshCh().nshContextHeader())));
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_CH2.type())) {
NiciraSetNshContextHeader niciraNshch = (NiciraSetNshContextHeader) extensionTreatment;
return factory.actions().setField(factory.oxms().nshC2(U32.of(niciraNshch.nshCh().nshContextHeader())));
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_CH3.type())) {
NiciraSetNshContextHeader niciraNshch = (NiciraSetNshContextHeader) extensionTreatment;
return factory.actions().setField(factory.oxms().nshC3(U32.of(niciraNshch.nshCh().nshContextHeader())));
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_CH4.type())) {
NiciraSetNshContextHeader niciraNshch = (NiciraSetNshContextHeader) extensionTreatment;
return factory.actions().setField(factory.oxms().nshC4(U32.of(niciraNshch.nshCh().nshContextHeader())));
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_NSH_MDTYPE.type())) {
NiciraNshMdType niciraNshMdType = (NiciraNshMdType) extensionTreatment;
return factory.actions().setField(factory.oxms().nshMdtype(U8.of(niciraNshMdType.nshMdType())));
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_NSH_NP.type())) {
NiciraNshNp niciraNshNp = (NiciraNshNp) extensionTreatment;
return factory.actions().setField(factory.oxms().nshNp(U8.of(niciraNshNp.nshNp())));
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_ENCAP_ETH_SRC.type())) {
NiciraEncapEthSrc niciraEncapEthSrc = (NiciraEncapEthSrc) extensionTreatment;
return factory.actions().setField(factory.oxms().encapEthSrc(MacAddress.of(niciraEncapEthSrc.encapEthSrc().toBytes())));
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_ENCAP_ETH_DST.type())) {
NiciraEncapEthDst niciraEncapEthDst = (NiciraEncapEthDst) extensionTreatment;
return factory.actions().setField(factory.oxms().encapEthDst(MacAddress.of(niciraEncapEthDst.encapEthDst().toBytes())));
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_ENCAP_ETH_TYPE.type())) {
NiciraEncapEthType niciraEncapEthType = (NiciraEncapEthType) extensionTreatment;
return factory.actions().setField(factory.oxms().encapEthType(U16.of(niciraEncapEthType.encapEthType())));
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_PUSH_NSH.type())) {
return factory.actions().niciraPushNsh();
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_POP_NSH.type())) {
return factory.actions().niciraPopNsh();
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_TUN_GPE_NP.type())) {
NiciraTunGpeNp niciraTunGpeNp = (NiciraTunGpeNp) extensionTreatment;
return factory.actions().setField(factory.oxms().tunGpeNp(U8.of(niciraTunGpeNp.tunGpeNp())));
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_MOV_ARP_SHA_TO_THA.type()) || type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_MOV_ARP_SPA_TO_TPA.type()) || type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_MOV_ETH_SRC_TO_DST.type()) || type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_MOV_IP_SRC_TO_DST.type()) || type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_MOV_NSH_C1_TO_C1.type()) || type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_MOV_NSH_C2_TO_C2.type()) || type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_MOV_NSH_C3_TO_C3.type()) || type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_MOV_NSH_C4_TO_C4.type()) || type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_MOV_TUN_IPV4_DST_TO_TUN_IPV4_DST.type()) || type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_MOV_TUN_ID_TO_TUN_ID.type()) || type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_MOV_NSH_C2_TO_TUN_ID.type())) {
MoveExtensionTreatment mov = (MoveExtensionTreatment) extensionTreatment;
OFActionNiciraMove.Builder action = factory.actions().buildNiciraMove();
action.setDstOfs(mov.dstOffset());
action.setSrcOfs(mov.srcOffset());
action.setNBits(mov.nBits());
action.setSrc(mov.src());
action.setDst(mov.dst());
return action.build();
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_LOAD.type())) {
NiciraLoad load = (NiciraLoad) extensionTreatment;
OFActionNiciraLoad.Builder action = factory.actions().buildNiciraLoad();
action.setOfsNbits(load.ofsNbits());
action.setDst(load.dst());
action.setValue(U64.of(load.value()));
return action.build();
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_CT.type())) {
NiciraCt niciraCt = (NiciraCt) extensionTreatment;
OFActionNiciraCt.Builder ctAction = factory.actions().buildNiciraCt();
ctAction.setFlags(niciraCt.niciraCtFlags());
ctAction.setZoneSrc(niciraCt.niciraCtZoneSrc());
ctAction.setZone(niciraCt.niciraCtZone());
ctAction.setRecircTable(niciraCt.niciraCtRecircTable());
ctAction.setAlg(niciraCt.niciraCtAlg());
List<OFAction> actions = Lists.newArrayList();
for (ExtensionTreatment nestedTreatment : niciraCt.niciraCtNestActions()) {
if (nestedTreatment instanceof NiciraNat) {
NiciraNat niciraNat = (NiciraNat) nestedTreatment;
OFActionNiciraNat.Builder action = factory.actions().buildNiciraNat();
action.setFlags(niciraNat.niciraNatFlags());
int presetFlags = niciraNat.niciraNatPresentFlags();
action.setRangePresent(presetFlags);
List<IPv4Address> ipv4RangeList = Lists.newArrayList();
List<IPv6Address> ipv6RangeList = Lists.newArrayList();
List<U16> portRangeList = Lists.newArrayList();
List<U8> padList = Lists.newArrayList();
if ((presetFlags & NAT_RANGE_IPV4_MIN) != 0) {
ipv4RangeList.add(IPv4Address.of(niciraNat.niciraNatIpAddressMin().getIp4Address().toString()));
}
if ((presetFlags & NAT_RANGE_IPV4_MAX) != 0) {
ipv4RangeList.add(IPv4Address.of(niciraNat.niciraNatIpAddressMax().getIp4Address().toString()));
}
if ((presetFlags & NAT_RANGE_IPV6_MIN) != 0) {
ipv6RangeList.add(IPv6Address.of(niciraNat.niciraNatIpAddressMin().getIp6Address().toString()));
}
if ((presetFlags & NAT_RANGE_IPV6_MAX) != 0) {
ipv6RangeList.add(IPv6Address.of(niciraNat.niciraNatIpAddressMax().getIp6Address().toString()));
}
if ((presetFlags & NAT_RANGE_PROTO_MIN) != 0) {
portRangeList.add(U16.of(niciraNat.niciraNatPortMin()));
}
if ((presetFlags & NAT_RANGE_PROTO_MAX) != 0) {
portRangeList.add(U16.of(niciraNat.niciraNatPortMax()));
}
for (; (ipv6RangeList.size() * 16 + ipv4RangeList.size() * 4 + portRangeList.size() * 2 + padList.size()) % 8 != 0; ) {
padList.add(U8.ofRaw((byte) 0));
}
action.setIpv4Range(ipv4RangeList);
action.setIpv6Range(ipv6RangeList);
action.setPortRange(portRangeList);
action.setPad(padList);
// nat action must be nested in ct action
actions.add(action.build());
} else if (nestedTreatment instanceof NiciraLoad) {
NiciraLoad niciraLoad = (NiciraLoad) nestedTreatment;
OFActionNiciraLoad.Builder action = factory.actions().buildNiciraLoad();
action.setDst(niciraLoad.dst());
action.setOfsNbits(niciraLoad.ofsNbits());
action.setValue(U64.of(niciraLoad.value()));
actions.add(action.build());
}
}
ctAction.setActions(actions);
return ctAction.build();
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_CT_CLEAR.type())) {
return factory.actions().niciraCtClear();
}
return null;
}
Aggregations