libfluid_msg is a library to create, serialize and deserialize OpenFlow 1.0 and OpenFlow 1.3 messages.
libfluid_msg has been tested on Ubuntu 12.04 and Fedora 19. It should run on other flavors of Linux. MacOS, Windows and BSD variations are currently not supported, but they should run with some simple changes (we plan to support them oficially in the future).
Install the dependencies:
Build:
Configure your system to find libraries in /usr/local/lib
:
You can skip this last step by running
./configure --prefix=/usr
in the build.
Install the dependencies:
Build:
Configure your system to find libraries in /usr/local/lib
:
To use OpenFlow 1.0 messages, you will need to include:
And for OpenFlow 1.3:
Link with your code with -lfluid_msg
.
libfluid_msg provides classes for all OpenFlow 1.0 and 1.3 message types along with classes that represent common structures. These classes have two methods to serialize and deserialize OpenFlow messages.
Here's how to pack a Hello message:
The message is serialized into a binary format, ready to be sent through the wire. The user is responsible for the memory management of the generated packed message.
And then unpack another:
The unpack method returns an OpenFlow error message. Most of the error handling is related to the length of the messages, but some messages, like fluid_msg::of13::FlowMod, have other types of error checking. To retrieve the error type and code use the following functions:
Here is an example of how to create a message composed by other OpenFlow elements. To create a fluid_msg::of10::FlowMod message:
The example creates a fluid_msg::of10::FlowMod message with all fields wildcarded and with two actions. Notice that we are passing static and dynamic objects to the fluid_msg::of10::FlowMod class. The class takes ownership of the objects, deleting objects dinamically allocated. So the user should not delete that memory.
To create a fluid_msg::of13::FlowMod, with OXM Fields of13::InPort and of13::EthType; and with and of13::ApplyActions instruction containing the action of13::OutputAction: