Quite some ago, there was a discussion around [ovs-dev] Creating a libopenvswitch-dev package, back in 2016. Since then libraries have been updated for C++ inclusion, plus other improvements.
From somewhere, I don't have the reference, maybe my own blog, but since I have this in a note on my desktop, I'll include it here:
- Build a string formatted as the “ovs-ofctl” command would do, for example “table=1,cookie=0xdeadbeef,in_port=1,actions=resubmit(,2)”
- Pass this to parser_ofp_flow_mod_str(). The parser will magically parse the string in to a rich struct.
- Pass the struct to ofputil_encode_flow_mod(). This returns a struct with a serialized OpenFlow message buffer.
- Send this buffer on the wire either via a socket you manage yourself or let OpenVswitch do it for you.