diff options
author | Ben Pfaff <blp@nicira.com> | 2011-08-16 16:30:57 -0700 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2011-09-13 11:46:08 -0700 |
commit | 93996add1ca50e85e4b3938133fcac15b56fbf01 (patch) | |
tree | 98d4783477d32f737b11a884f46e3310fe1dd7de /lib/ofp-util.h | |
parent | 333eba210b39a09a17c036335ed312ae123ba339 (diff) | |
download | openvswitch-93996add1ca50e85e4b3938133fcac15b56fbf01.tar.gz |
ofp-util: Add type-safe functions for serializing actions.
Diffstat (limited to 'lib/ofp-util.h')
-rw-r--r-- | lib/ofp-util.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/ofp-util.h b/lib/ofp-util.h index e70d963d5..a658df113 100644 --- a/lib/ofp-util.h +++ b/lib/ofp-util.h @@ -334,6 +334,30 @@ enum ofputil_action_code ofputil_decode_action_unsafe( int ofputil_action_code_from_name(const char *); +void *ofputil_put_action(enum ofputil_action_code, struct ofpbuf *buf); + +/* For each OpenFlow action <ENUM> that has a corresponding action structure + * struct <STRUCT>, this defines two functions: + * + * void ofputil_init_<ENUM>(struct <STRUCT> *action); + * + * Initializes the parts of 'action' that identify it as having type <ENUM> + * and length 'sizeof *action' and zeros the rest. For actions that have + * variable length, the length used and cleared is that of struct <STRUCT>. + * + * struct <STRUCT> *ofputil_put_<ENUM>(struct ofpbuf *buf); + * + * Appends a new 'action', of length 'sizeof(struct <STRUCT>)', to 'buf', + * initializes it with ofputil_init_<ENUM>(), and returns it. + */ +#define OFPAT_ACTION(ENUM, STRUCT, NAME) \ + void ofputil_init_##ENUM(struct STRUCT *); \ + struct STRUCT *ofputil_put_##ENUM(struct ofpbuf *); +#define NXAST_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) \ + void ofputil_init_##ENUM(struct STRUCT *); \ + struct STRUCT *ofputil_put_##ENUM(struct ofpbuf *); +#include "ofp-util.def" + #define OFP_ACTION_ALIGN 8 /* Alignment of ofp_actions. */ static inline union ofp_action * |