Open vSwitch flow rule handling
Overview
// typedefs typedef struct ovs_flow_rule ovs_flow_rule; // structs struct ovs_flow_rule; // global functions te_errno ovs_flow_rule_parse(const char* rule_str, ovs_flow_rule* rule); void ovs_flow_rule_fini(ovs_flow_rule* rule); te_errno ovs_flow_rule_to_string(ovs_flow_rule* rule, char** rule_str); te_errno ovs_flow_rule_to_ofctl(ovs_flow_rule* rule, char** rule_str); te_errno ovs_flow_rule_str_get_field(const char* rule, const char* field, const char** value, size_t* value_len);
Detailed Documentation
Typedefs
typedef struct ovs_flow_rule ovs_flow_rule
Open vSwitch flow rule descriptor structure
Global Functions
te_errno ovs_flow_rule_parse(const char* rule_str, ovs_flow_rule* rule)
Parse the given string into an Open vSwitch flow rule.
Parameters:
rule_str |
Flow rule string representation. |
rule |
Flow rule descriptor structure. |
Returns:
Status code.
void ovs_flow_rule_fini(ovs_flow_rule* rule)
Free the additional memory used by the flow rule descriptor structure.
Parameters:
rule |
Flow rule descriptor structure. |
Returns:
Nothing.
te_errno ovs_flow_rule_to_string(ovs_flow_rule* rule, char** rule_str)
Format the flow rule including all metadata. The function allocates a memory buffer for the resulting string, it is the user’s responsibility to free it.
Parameters:
rule |
Flow rule descriptor structure. |
rule_str |
Where to store the resulting string. |
Returns:
Status code.
te_errno ovs_flow_rule_to_ofctl(ovs_flow_rule* rule, char** rule_str)
Format the flow rule according to Open vSwitch’s ovs-ofctl expectations. The function allocates a memory buffer for the resulting string, it is the user’s responsibility to free it.
Parameters:
rule |
Flow rule descriptor structure. |
rule_str |
Where to store the resulting string. |
Returns:
Status code.
te_errno ovs_flow_rule_str_get_field(const char* rule, const char* field, const char** value, size_t* value_len)
Given a string representation of some flow rule, extract the value of the field with user-provided name. The function does not allocate anything, the value pointer is guaranteed to be within the same string buffer or NULL. If present, the mask will be included in the result.
Parameters:
rule |
Flow rule in string form. |
field |
Field whose value needs to be extracted. |
value |
Value start address. |
value_len |
Length of the value. |
Returns:
Status code.