@Override public OFOxm<?> mapSelector(OFFactory factory, ExtensionSelector extensionSelector) { ExtensionSelectorType type = extensionSelector.type(); if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.OFDPA_MATCH_VLAN_VID.type())) { VlanId vlanId = ((OfdpaMatchVlanVid) extensionSelector).vlanId(); // Special VLAN 0x0000/0x1FFF required by OFDPA if (vlanId.equals(VlanId.NONE)) { OFVlanVidMatch vid = OFVlanVidMatch.ofRawVid((short) 0x0000); OFVlanVidMatch mask = OFVlanVidMatch.ofRawVid((short) 0x1FFF); return factory.oxms().vlanVidMasked(vid, mask); // Normal case } else if (vlanId.equals(VlanId.ANY)) { return factory.oxms().vlanVidMasked(OFVlanVidMatch.PRESENT, OFVlanVidMatch.PRESENT); } else { return factory.oxms().vlanVid(OFVlanVidMatch.ofVlanVid(VlanVid.ofVlan(vlanId.toShort()))); } } throw new UnsupportedOperationException( "Unexpected ExtensionSelector: " + extensionSelector.toString()); }
@Override public OFAction mapInstruction(OFFactory factory, ExtensionTreatment extensionTreatment) { ExtensionTreatmentType type = extensionTreatment.type(); if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_SET_VLAN_ID.type())) { VlanId vlanId = ((OfdpaSetVlanVid) extensionTreatment).vlanId(); // NOTE: OFDPA requires isPresent bit set to zero. OFVlanVidMatch match = OFVlanVidMatch.ofRawVid(vlanId.toShort()); return factory.actions().setField(factory.oxms().vlanVid(match)); } throw new UnsupportedOperationException( "Unexpected ExtensionTreatment: " + extensionTreatment.toString()); }
private OFAction buildL4Modification(Instruction i) { L4ModificationInstruction l4m = (L4ModificationInstruction) i; ModTransportPortInstruction tp; OFOxm<?> oxm = null; switch (l4m.subtype()) { case TCP_SRC: tp = (ModTransportPortInstruction) l4m; oxm = factory().oxms().tcpSrc(TransportPort.of(tp.port().toInt())); break; case TCP_DST: tp = (ModTransportPortInstruction) l4m; oxm = factory().oxms().tcpDst(TransportPort.of(tp.port().toInt())); break; case UDP_SRC: tp = (ModTransportPortInstruction) l4m; oxm = factory().oxms().udpSrc(TransportPort.of(tp.port().toInt())); break; case UDP_DST: tp = (ModTransportPortInstruction) l4m; oxm = factory().oxms().udpDst(TransportPort.of(tp.port().toInt())); break; default: log.warn("Unimplemented action type {}.", l4m.subtype()); break; } if (oxm != null) { return factory().actions().buildSetField().setField(oxm).build(); } return null; }
ip = (L3ModificationInstruction.ModIPInstruction) i; ip4 = ip.ip().getIp4Address(); oxm = factory.oxms().ipv4Src(IPv4Address.of(ip4.toInt())); break; case IPV4_DST: ip = (L3ModificationInstruction.ModIPInstruction) i; ip4 = ip.ip().getIp4Address(); oxm = factory.oxms().ipv4Dst(IPv4Address.of(ip4.toInt())); break; case IPV6_SRC: ip = (L3ModificationInstruction.ModIPInstruction) i; ip6 = ip.ip().getIp6Address(); oxm = factory.oxms().ipv6Src(IPv6Address.of(ip6.toOctets())); break; case IPV6_DST: ip = (L3ModificationInstruction.ModIPInstruction) i; ip6 = ip.ip().getIp6Address(); oxm = factory.oxms().ipv6Dst(IPv6Address.of(ip6.toOctets())); break; case IPV6_FLABEL: (L3ModificationInstruction.ModIPv6FlowLabelInstruction) i; int flowLabel = flowLabelInstruction.flowLabel(); oxm = factory.oxms().ipv6Flabel(IPv6FlowLabel.of(flowLabel)); break; case DEC_TTL:
case ETH_DST: eth = (L2ModificationInstruction.ModEtherInstruction) l2m; oxm = factory.oxms().ethDst(MacAddress.of(eth.mac().toLong())); break; case ETH_SRC: eth = (L2ModificationInstruction.ModEtherInstruction) l2m; oxm = factory.oxms().ethSrc(MacAddress.of(eth.mac().toLong())); break; case VLAN_ID: L2ModificationInstruction.ModVlanIdInstruction vlanId = (L2ModificationInstruction.ModVlanIdInstruction) l2m; oxm = factory.oxms().vlanVid(OFVlanVidMatch.ofVlan(vlanId.vlanId().toShort())); break; case VLAN_PCP: L2ModificationInstruction.ModVlanPcpInstruction vlanPcp = (L2ModificationInstruction.ModVlanPcpInstruction) l2m; oxm = factory.oxms().vlanPcp(VlanPcp.of(vlanPcp.vlanPcp())); break; case VLAN_POP: L2ModificationInstruction.ModMplsLabelInstruction mplsLabel = (L2ModificationInstruction.ModMplsLabelInstruction) l2m; oxm = factory.oxms().mplsLabel(U32.of(mplsLabel.label().toInt())); break; case MPLS_BOS: L2ModificationInstruction.ModMplsBosInstruction mplsBos = (L2ModificationInstruction.ModMplsBosInstruction) l2m; oxm = factory.oxms() .mplsBos(mplsBos.mplsBos() ? OFBooleanValue.TRUE
private OFAction buildL1Modification(Instruction i) { L1ModificationInstruction l1m = (L1ModificationInstruction) i; OFOxm<?> oxm = null; switch (l1m.subtype()) { case ODU_SIGID: ModOduSignalIdInstruction modOduSignalIdInstruction = (ModOduSignalIdInstruction) l1m; OduSignalId oduSignalId = modOduSignalIdInstruction.oduSignalId(); OduSignalID oduSignalID = new OduSignalID((short) oduSignalId.tributaryPortNumber(), (short) oduSignalId.tributarySlotLength(), oduSignalId.tributarySlotBitmap()); oxm = factory().oxms().expOduSigId(oduSignalID); break; default: log.warn("Unimplemented action type {}.", l1m.subtype()); break; } if (oxm != null) { return factory().actions().buildSetField().setField(oxm).build(); } return null; }
private OFAction buildModOchSignalInstruction(ModOchSignalInstruction instruction) { OchSignal signal = instruction.lambda(); byte gridType = OpenFlowValueMapper.lookupGridType(signal.gridType()); byte channelSpacing = OpenFlowValueMapper.lookupChannelSpacing(signal.channelSpacing()); return factory().actions().circuit(factory().oxms().expOchSigId( new CircuitSignalID(gridType, channelSpacing, (short) signal.spacingMultiplier(), (short) signal.slotGranularity()) )); }
@Override public OFOxm<?> mapSelector(OFFactory factory, ExtensionSelector extensionSelector) { ExtensionSelectorType type = extensionSelector.type(); if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SPI.type())) { NiciraMatchNshSpi niciraNshSpi = (NiciraMatchNshSpi) extensionSelector; return factory.oxms().nsp(U32.of(niciraNshSpi.nshSpi().servicePathId())); } if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SI.type())) { NiciraMatchNshSi niciraNshSi = (NiciraMatchNshSi) extensionSelector; return factory.oxms().nsi(U8.of(niciraNshSi.nshSi().serviceIndex())); } if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_ENCAP_ETH_TYPE.type())) { NiciraMatchEncapEthType niciraEncapEthType = (NiciraMatchEncapEthType) extensionSelector; return factory.oxms().encapEthType(U16.of(niciraEncapEthType.encapEthType())); } if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH1.type())) { // TODO } if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH2.type())) { // TODO } if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH3.type())) { // TODO } if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH4.type())) { // TODO } return null; }
ip = (ModIPInstruction) i; ip4 = ip.ip().getIp4Address(); oxm = factory().oxms().ipv4Src(IPv4Address.of(ip4.toInt())); break; case IPV4_DST: ip = (ModIPInstruction) i; ip4 = ip.ip().getIp4Address(); oxm = factory().oxms().ipv4Dst(IPv4Address.of(ip4.toInt())); break; case IPV6_SRC: ip = (ModIPInstruction) i; ip6 = ip.ip().getIp6Address(); oxm = factory().oxms().ipv6Src(IPv6Address.of(ip6.toOctets())); break; case IPV6_DST: ip = (ModIPInstruction) i; ip6 = ip.ip().getIp6Address(); oxm = factory().oxms().ipv6Dst(IPv6Address.of(ip6.toOctets())); break; case IPV6_FLABEL: (ModIPv6FlowLabelInstruction) i; int flowLabel = flowLabelInstruction.flowLabel(); oxm = factory().oxms().ipv6Flabel(IPv6FlowLabel.of(flowLabel)); break; case ARP_SPA: ModArpIPInstruction aip = (ModArpIPInstruction) i; ip4 = aip.ip().getIp4Address(); oxm = factory().oxms().arpSpa(IPv4Address.of(ip4.toInt()));
private OFAction buildL0Modification(Instruction i) { L0ModificationInstruction l0m = (L0ModificationInstruction) i; OFOxm<?> oxm = null; switch (l0m.subtype()) { case OCH: try { ModOchSignalInstruction modOchSignalInstruction = (ModOchSignalInstruction) l0m; OchSignal signal = modOchSignalInstruction.lambda(); byte gridType = OpenFlowValueMapper.lookupGridType(signal.gridType()); byte channelSpacing = OpenFlowValueMapper.lookupChannelSpacing(signal.channelSpacing()); oxm = factory().oxms().expOchSigId( new CircuitSignalID(gridType, channelSpacing, (short) signal.spacingMultiplier(), (short) signal.slotGranularity())); } catch (NoMappingFoundException e) { log.warn(e.getMessage()); break; } break; default: log.warn("Unimplemented action type {}.", l0m.subtype()); break; } if (oxm != null) { return factory().actions().buildSetField().setField(oxm).build(); } return null; }
case ETH_DST: eth = (ModEtherInstruction) l2m; oxm = factory().oxms().ethDst(MacAddress.of(eth.mac().toLong())); break; case ETH_SRC: eth = (ModEtherInstruction) l2m; oxm = factory().oxms().ethSrc(MacAddress.of(eth.mac().toLong())); break; case VLAN_ID: ModVlanIdInstruction vlanId = (ModVlanIdInstruction) l2m; oxm = factory().oxms().vlanVid(OFVlanVidMatch.ofVlan(vlanId.vlanId().toShort())); break; case VLAN_PCP: ModVlanPcpInstruction vlanPcp = (ModVlanPcpInstruction) l2m; oxm = factory().oxms().vlanPcp(VlanPcp.of(vlanPcp.vlanPcp())); break; case MPLS_PUSH: ModMplsLabelInstruction mplsLabel = (ModMplsLabelInstruction) l2m; oxm = factory().oxms().mplsLabel(U32.of(mplsLabel.label().toInt())); break; case MPLS_BOS: ModMplsBosInstruction mplsBos = (ModMplsBosInstruction) l2m; oxm = factory().oxms() .mplsBos(mplsBos.mplsBos() ? OFBooleanValue.TRUE : OFBooleanValue.FALSE); case TUNNEL_ID:
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()))); return factory.actions().setField(factory.oxms().nsp(U32.of(niciraNshSpi.nshSpi().servicePathId()))); return factory.actions().setField(factory.oxms().nsi(U8.of(niciraNshSi.nshSi().serviceIndex()))); return factory.actions().setField(factory.oxms().nshC1(U32.of(niciraNshch.nshCh().nshContextHeader()))); return factory.actions().setField(factory.oxms().nshC2(U32.of(niciraNshch.nshCh().nshContextHeader()))); return factory.actions().setField(factory.oxms().nshC3(U32.of(niciraNshch.nshCh().nshContextHeader()))); return factory.actions().setField(factory.oxms().nshC4(U32.of(niciraNshch.nshCh().nshContextHeader()))); return factory.actions().setField(factory.oxms().nshMdtype(U8.of(niciraNshMdType.nshMdType()))); return factory.actions().setField(factory.oxms().nshNp(U8.of(niciraNshNp.nshNp()))); return factory.actions().setField(factory.oxms().encapEthSrc(MacAddress.of(niciraEncapEthSrc.encapEthSrc() .toBytes()))); return factory.actions().setField(factory.oxms().encapEthDst(MacAddress.of(niciraEncapEthDst.encapEthDst() .toBytes()))); return factory.actions().setField(factory.oxms().encapEthType(U16.of(niciraEncapEthType.encapEthType())));