libfluid is a library bundle that provides the basic features to implement an OpenFlow controller. It is composed of two separate libraries:
…classes for Creating an OpenFlow server that listens to connections and handles events.
libfluid_base defines a client-server architecture, in which a controller is a server and a switch is a client. It provides a base class upon which you can build your controller (by inheritance): fluid_base::OFServer. You need to implement the callbacks for connection and message events, which will be called automatically.
Connections will be represented by fluid_base::OFConnection objects, which provide the abstraction for the most basic functionalities of an OpenFlow connection.
…classes for easily building and parsing OpenFlow wire format messages.
libfluid_msg (namespace fluid_msg) greatly simplifies message building and parsing in your controller. It provides classes to build OpenFlow messages with marshalling (pack) and unmarshalling (unpack) methods. Packing an object results in an OpenFlow message in the network byte order (wire format), ready to be sent through the OpenFlow connection. For unpacking, the library parses OpenFlow wire format data and sets the object attributes to the loaded values (dealing with byte ordering automatically).
Every message from libfluid_msg inherits from fluid_msg::OFMsg, which contains basic OpenFlow header information, allowing the user to create new OpenFlow messages by extending it. For example, for OpenFlow 1.0, vendor and experimenter messages can be easily implemented inheriting from fluid_msg::of10::Vendor and fluid_msg::of10::Experimenter respectively.