Module Frenetic_kernel.OpenFlow0x01

exception Unparsable of string

Unparsable msg signals an error in parsing, such as when a bit sequence has been corrupted.

exception Ignored of string

Ignored msg signals the arrival of a valid OpenFlow message that the parser is not yet equipped to handle.

type 'a mask = {
m_value : 'a;
m_mask : 'a option;
}
include sig ... end
val mask_of_sexp : (Ppx_sexp_conv_lib.Sexp.t ‑> 'a) ‑> Ppx_sexp_conv_lib.Sexp.t ‑> 'a mask
val sexp_of_mask : ('a ‑> Ppx_sexp_conv_lib.Sexp.t) ‑> 'a mask ‑> Ppx_sexp_conv_lib.Sexp.t
type switchId = int64
include sig ... end
val switchId_of_sexp : Ppx_sexp_conv_lib.Sexp.t ‑> switchId
val sexp_of_switchId : switchId ‑> Ppx_sexp_conv_lib.Sexp.t
type portId = Packet.int16
include sig ... end
val portId_of_sexp : Ppx_sexp_conv_lib.Sexp.t ‑> portId
val sexp_of_portId : portId ‑> Ppx_sexp_conv_lib.Sexp.t
type queueId = int32
include sig ... end
val queueId_of_sexp : Ppx_sexp_conv_lib.Sexp.t ‑> queueId
val sexp_of_queueId : queueId ‑> Ppx_sexp_conv_lib.Sexp.t
type xid = OpenFlow_Header.xid
type pattern = {
dlSrc : Packet.dlAddr option;
dlDst : Packet.dlAddr option;
dlTyp : Packet.dlTyp option;
dlVlan : Packet.dlVlan option;
dlVlanPcp : Packet.dlVlanPcp option;
nwSrc : Packet.nwAddr mask option;
nwDst : Packet.nwAddr mask option;
nwProto : Packet.nwProto option;
nwTos : Packet.nwTos option;
tpSrc : Packet.tpPort option;
tpDst : Packet.tpPort option;
inPort : portId option;
}
include sig ... end
val pattern_of_sexp : Ppx_sexp_conv_lib.Sexp.t ‑> pattern
val sexp_of_pattern : pattern ‑> Ppx_sexp_conv_lib.Sexp.t
type pseudoPort =
| PhysicalPort of portId
| InPort
| Table
| Normal
| Flood
| AllPorts
| Controller of int
| Local
include sig ... end
val pseudoPort_of_sexp : Ppx_sexp_conv_lib.Sexp.t ‑> pseudoPort
val sexp_of_pseudoPort : pseudoPort ‑> Ppx_sexp_conv_lib.Sexp.t
type action =
| Output of pseudoPort
| SetDlVlan of Packet.dlVlan
| SetDlVlanPcp of Packet.dlVlanPcp
| SetDlSrc of Packet.dlAddr
| SetDlDst of Packet.dlAddr
| SetNwSrc of Packet.nwAddr
| SetNwDst of Packet.nwAddr
| SetNwTos of Packet.nwTos
| SetTpSrc of Packet.tpPort
| SetTpDst of Packet.tpPort
| Enqueue of pseudoPort * queueId
include sig ... end
val action_of_sexp : Ppx_sexp_conv_lib.Sexp.t ‑> action
val sexp_of_action : action ‑> Ppx_sexp_conv_lib.Sexp.t
type timeout =
| Permanent
| ExpiresAfter of Packet.int16
include sig ... end
val timeout_of_sexp : Ppx_sexp_conv_lib.Sexp.t ‑> timeout
val sexp_of_timeout : timeout ‑> Ppx_sexp_conv_lib.Sexp.t
type flowModCommand =
| AddFlow
| ModFlow
| ModStrictFlow
| DeleteFlow
| DeleteStrictFlow
include sig ... end
val flowModCommand_of_sexp : Ppx_sexp_conv_lib.Sexp.t ‑> flowModCommand
val sexp_of_flowModCommand : flowModCommand ‑> Ppx_sexp_conv_lib.Sexp.t
type flowMod = {
command : flowModCommand;
pattern : pattern;
priority : Packet.int16;
actions : action list;
cookie : int64;
idle_timeout : timeout;
hard_timeout : timeout;
notify_when_removed : bool;
apply_to_packet : int32 option;
out_port : pseudoPort option;
check_overlap : bool;
}
include sig ... end
val flowMod_of_sexp : Ppx_sexp_conv_lib.Sexp.t ‑> flowMod
val sexp_of_flowMod : flowMod ‑> Ppx_sexp_conv_lib.Sexp.t
type payload =
| Buffered of int32 * Cstruct.t Core.sexp_opaque
| NotBuffered of Cstruct.t Core.sexp_opaque
include sig ... end
val payload_of_sexp : Ppx_sexp_conv_lib.Sexp.t ‑> payload
val sexp_of_payload : payload ‑> Ppx_sexp_conv_lib.Sexp.t
type packetInReason =
| NoMatch
| ExplicitSend
include sig ... end
val packetInReason_of_sexp : Ppx_sexp_conv_lib.Sexp.t ‑> packetInReason
val sexp_of_packetInReason : packetInReason ‑> Ppx_sexp_conv_lib.Sexp.t
type packetIn = {
input_payload : payload;
total_len : Packet.int16;
port : portId;
reason : packetInReason;
}
include sig ... end
val packetIn_of_sexp : Ppx_sexp_conv_lib.Sexp.t ‑> packetIn
val sexp_of_packetIn : packetIn ‑> Ppx_sexp_conv_lib.Sexp.t
type flowRemovedReason =
| IdleTimeout
| HardTimeout
| Delete
include sig ... end
val flowRemovedReason_of_sexp : Ppx_sexp_conv_lib.Sexp.t ‑> flowRemovedReason
val sexp_of_flowRemovedReason : flowRemovedReason ‑> Ppx_sexp_conv_lib.Sexp.t
type flowRemoved = {
pattern : pattern;
cookie : int64;
priority : Packet.int16;
reason : flowRemovedReason;
duration_sec : int32;
duration_nsec : int32;
idle_timeout : timeout;
packet_count : int64;
byte_count : int64;
}
include sig ... end
val flowRemoved_of_sexp : Ppx_sexp_conv_lib.Sexp.t ‑> flowRemoved
val sexp_of_flowRemoved : flowRemoved ‑> Ppx_sexp_conv_lib.Sexp.t
type packetOut = {
output_payload : payload;
port_id : portId option;
apply_actions : action list;
}
include sig ... end
val packetOut_of_sexp : Ppx_sexp_conv_lib.Sexp.t ‑> packetOut
val sexp_of_packetOut : packetOut ‑> Ppx_sexp_conv_lib.Sexp.t
type statsReq = {
sr_of_match : pattern;
sr_table_id : Packet.int8;
sr_out_port : pseudoPort option;
}
include sig ... end
val statsReq_of_sexp : Ppx_sexp_conv_lib.Sexp.t ‑> statsReq
val sexp_of_statsReq : statsReq ‑> Ppx_sexp_conv_lib.Sexp.t
type request =
| DescriptionRequest
| FlowTableStatsRequest
| IndividualRequest of statsReq
| AggregateRequest of statsReq
| PortRequest of pseudoPort option
include sig ... end
val request_of_sexp : Ppx_sexp_conv_lib.Sexp.t ‑> request
val sexp_of_request : request ‑> Ppx_sexp_conv_lib.Sexp.t
type descriptionStats = {
manufacturer : string;
hardware : string;
software : string;
serial_number : string;
datapath : string;
}
include sig ... end
val descriptionStats_of_sexp : Ppx_sexp_conv_lib.Sexp.t ‑> descriptionStats
val sexp_of_descriptionStats : descriptionStats ‑> Ppx_sexp_conv_lib.Sexp.t
type individualStats = {
table_id : Packet.int8;
of_match : pattern;
duration_sec : int32;
duration_nsec : int32;
priority : Packet.int16;
idle_timeout : Packet.int16;
hard_timeout : Packet.int16;
cookie : int64;
packet_count : int64;
byte_count : int64;
actions : action list;
}
include sig ... end
val individualStats_of_sexp : Ppx_sexp_conv_lib.Sexp.t ‑> individualStats
val sexp_of_individualStats : individualStats ‑> Ppx_sexp_conv_lib.Sexp.t
type aggregateStats = {
total_packet_count : int64;
total_byte_count : int64;
flow_count : int32;
}
include sig ... end
val aggregateStats_of_sexp : Ppx_sexp_conv_lib.Sexp.t ‑> aggregateStats
val sexp_of_aggregateStats : aggregateStats ‑> Ppx_sexp_conv_lib.Sexp.t
type portStats = {
port_no : Packet.int16;
rx_packets : int64;
tx_packets : int64;
rx_bytes : int64;
tx_bytes : int64;
rx_dropped : int64;
tx_dropped : int64;
rx_errors : int64;
tx_errors : int64;
rx_frame_err : int64;
rx_over_err : int64;
rx_crc_err : int64;
collisions : int64;
}
include sig ... end
val portStats_of_sexp : Ppx_sexp_conv_lib.Sexp.t ‑> portStats
val sexp_of_portStats : portStats ‑> Ppx_sexp_conv_lib.Sexp.t
type reply =
| DescriptionRep of descriptionStats
| IndividualFlowRep of individualStats list
| AggregateFlowRep of aggregateStats
| PortRep of portStats list
include sig ... end
val reply_of_sexp : Ppx_sexp_conv_lib.Sexp.t ‑> reply
val sexp_of_reply : reply ‑> Ppx_sexp_conv_lib.Sexp.t
type wildcards = {
in_port : bool;
dl_vlan : bool;
dl_src : bool;
dl_dst : bool;
dl_type : bool;
nw_proto : bool;
tp_src : bool;
tp_dst : bool;
nw_src : int;
nw_dst : int;
dl_vlan_pcp : bool;
nw_tos : bool;
}
include sig ... end
val wildcards_of_sexp : Ppx_sexp_conv_lib.Sexp.t ‑> wildcards
val sexp_of_wildcards : wildcards ‑> Ppx_sexp_conv_lib.Sexp.t
type portConfig = {
down : bool;
no_stp : bool;
no_recv : bool;
no_recv_stp : bool;
no_flood : bool;
no_fwd : bool;
no_packet_in : bool;
}
include sig ... end
val portConfig_of_sexp : Ppx_sexp_conv_lib.Sexp.t ‑> portConfig
val sexp_of_portConfig : portConfig ‑> Ppx_sexp_conv_lib.Sexp.t
type stpState =
| Listen
| Learn
| Forward
| Block
include sig ... end
val stpState_of_sexp : Ppx_sexp_conv_lib.Sexp.t ‑> stpState
val sexp_of_stpState : stpState ‑> Ppx_sexp_conv_lib.Sexp.t
type portState = {
down : bool;
stp_state : stpState;
}
include sig ... end
val portState_of_sexp : Ppx_sexp_conv_lib.Sexp.t ‑> portState
val sexp_of_portState : portState ‑> Ppx_sexp_conv_lib.Sexp.t
type portFeatures = {
f_10MBHD : bool;
f_10MBFD : bool;
f_100MBHD : bool;
f_100MBFD : bool;
f_1GBHD : bool;
f_1GBFD : bool;
f_10GBFD : bool;
copper : bool;
fiber : bool;
autoneg : bool;
pause : bool;
pause_asym : bool;
}
include sig ... end
val portFeatures_of_sexp : Ppx_sexp_conv_lib.Sexp.t ‑> portFeatures
val sexp_of_portFeatures : portFeatures ‑> Ppx_sexp_conv_lib.Sexp.t
type portDescription = {
port_no : portId;
hw_addr : Packet.dlAddr;
name : string;
config : portConfig;
state : portState;
curr : portFeatures;
advertised : portFeatures;
supported : portFeatures;
peer : portFeatures;
}
include sig ... end
val portDescription_of_sexp : Ppx_sexp_conv_lib.Sexp.t ‑> portDescription
val sexp_of_portDescription : portDescription ‑> Ppx_sexp_conv_lib.Sexp.t
module Wildcards : sig ... end
module Match : sig ... end
module PseudoPort : sig ... end
module Timeout : sig ... end
module Action : sig ... end
module FlowMod : sig ... end
module FlowRemoved : sig ... end
module PacketOut : sig ... end
module PortDescription : sig ... end
module PortStatus : sig ... end
module SwitchFeatures : sig ... end

Switch features data structure. See Section 5.3.1 of the OpenFlow 1.0 specification.

module SwitchConfig : sig ... end
module StatsRequest : sig ... end
module StatsReply : sig ... end
module Error : sig ... end

An error message. See Section 5.4.4 of the OpenFlow 1.0 specification.

module Vendor : sig ... end

A VENDOR message. See Section 5.5.4 of the OpenFlow 1.0 specification.

module Message : sig ... end

A subset of the OpenFlow 1.0 messages defined in Section 5.1 of the specification.

Pretty printing

In general, each submodule contains pretty-printing functions for the types defined therein. This section defines pretty printers for top-level types.

val string_of_switchId : switchId ‑> string

string_of_switchId sw pretty-prints sw in hex.

val string_of_portId : portId ‑> string

string_of_portId p pretty-prints p.

val string_of_queueId : queueId ‑> string

string_of_queueId q pretty-prints q.

Parsing exceptions

These exceptions may occur when parsing OpenFlow messages.

Convenient Functions

val parse_payload : payload ‑> Packet.packet
val marshal_payload : int32 option ‑> Packet.packet ‑> payload

marshal_payload buf pkt serializes pkt, where buf is an optional buffer ID.

val match_all : pattern

A pattern that matches all packets. (All fields wildcarded.)

val add_flow : Packet.int16 ‑> pattern ‑> ?⁠idle_to:timeout ‑> ?⁠notify_removed:bool ‑> action list ‑> flowMod

add_flow priority pattern action_sequence creates a FlowMod.t instruction that adds a new flow table entry with the specified priority, pattern, and action_sequence.

The entry is permanent (i.e., does not timeout), its cookie is zero, etc.

val delete_flow_strict : Packet.int16 ‑> pattern ‑> pseudoPort option ‑> flowMod
val delete_all_flows : flowMod

Printing and Debugging

val packetIn_to_string : packetIn ‑> string
val reply_to_string : reply ‑> string