module Nettle.OpenFlow.Action (
Action (..)
, ActionType (..)
, PseudoPort (..)
, MaxLenToSendController
#if OPENFLOW_VERSION==1
, VendorID
, QueueID
#endif
, ActionSequence(..)
, sendOnPort, sendOnInPort, flood, drop, allPhysicalPorts, processNormally, sendToController, processWithTable
, setVlanVID, setVlanPriority, stripVlanHeader, setEthSrcAddr, setEthDstAddr
, setIPSrcAddr, setIPDstAddr
#if OPENFLOW_VERSION==152 || OPENFLOW_VERSION==1
, setIPToS
#endif
, setTransportSrcPort
, setTransportDstPort
#if OPENFLOW_VERSION==1
, enqueue
, vendorAction
#endif
) where
import Prelude hiding (drop)
import Nettle.OpenFlow.Port
import Nettle.Ethernet.EthernetAddress
import Nettle.Ethernet.EthernetFrame
import Nettle.IPv4.IPAddress
import Nettle.IPv4.IPPacket
import Data.Word
data ActionType = OutputToPortType
| SetVlanVIDType
| SetVlanPriorityType
| StripVlanHeaderType
| SetEthSrcAddrType
| SetEthDstAddrType
| SetIPSrcAddrType
| SetIPDstAddrType
#if OPENFLOW_VERSION==152 || OPENFLOW_VERSION==1
| SetIPTypeOfServiceType
#endif
| SetTransportSrcPortType
| SetTransportDstPortType
#if OPENFLOW_VERSION==1
| EnqueueType
#endif
| VendorActionType
deriving (Show,Read,Eq,Ord,Enum)
data Action
= SendOutPort PseudoPort
| SetVlanVID VLANID
| SetVlanPriority VLANPriority
| StripVlanHeader
| SetEthSrcAddr EthernetAddress
| SetEthDstAddr EthernetAddress
| SetIPSrcAddr IPAddress
| SetIPDstAddr IPAddress
#if OPENFLOW_VERSION==152 || OPENFLOW_VERSION==1
| SetIPToS IPTypeOfService
#endif
| SetTransportSrcPort TransportPort
| SetTransportDstPort TransportPort
#if OPENFLOW_VERSION==1
| Enqueue {
enqueuePort :: PortID,
queueID :: QueueID
}
| VendorAction VendorID [Word8]
#endif
deriving (Show,Eq)
data PseudoPort = PhysicalPort PortID
| InPort
| Flood
| AllPhysicalPorts
| ToController MaxLenToSendController
| NormalSwitching
| WithTable
deriving (Show,Read, Eq)
type MaxLenToSendController = Word16
#if OPENFLOW_VERSION==1
type VendorID = Word32
type QueueID = Word32
#endif
type ActionSequence = [Action]
send :: PseudoPort -> ActionSequence
send p = [SendOutPort p]
sendOnPort :: PortID -> ActionSequence
sendOnPort p = [SendOutPort $ PhysicalPort p]
sendOnInPort, flood, drop, allPhysicalPorts, processNormally :: ActionSequence
sendOnInPort = send InPort
flood = send Flood
drop = []
allPhysicalPorts = send AllPhysicalPorts
processNormally = send NormalSwitching
processWithTable = send WithTable
sendToController :: MaxLenToSendController -> ActionSequence
sendToController maxlen = send (ToController maxlen)
setVlanVID :: VLANID -> ActionSequence
setVlanVID vlanid = [SetVlanVID vlanid]
setVlanPriority :: VLANPriority -> ActionSequence
setVlanPriority x = [SetVlanPriority x]
stripVlanHeader :: ActionSequence
stripVlanHeader = [StripVlanHeader]
setEthSrcAddr :: EthernetAddress -> ActionSequence
setEthSrcAddr addr = [SetEthSrcAddr addr]
setEthDstAddr :: EthernetAddress -> ActionSequence
setEthDstAddr addr = [SetEthDstAddr addr]
setIPSrcAddr :: IPAddress -> ActionSequence
setIPSrcAddr addr = [SetIPSrcAddr addr]
setIPDstAddr :: IPAddress -> ActionSequence
setIPDstAddr addr = [SetIPDstAddr addr]
#if OPENFLOW_VERSION==152 || OPENFLOW_VERSION==1
setIPToS :: IPTypeOfService -> ActionSequence
setIPToS tos = [SetIPToS tos]
#endif
setTransportSrcPort :: TransportPort -> ActionSequence
setTransportSrcPort port = [SetTransportSrcPort port]
setTransportDstPort :: TransportPort -> ActionSequence
setTransportDstPort port = [SetTransportDstPort port]
#if OPENFLOW_VERSION==1
enqueue :: PortID -> QueueID -> ActionSequence
enqueue portid queueid = [Enqueue portid queueid]
vendorAction :: VendorID -> [Word8] -> ActionSequence
vendorAction vid bytes = [VendorAction vid bytes]
#endif