diff options
author | Ben Pfaff <blp@nicira.com> | 2014-05-07 15:11:28 -0700 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2014-05-14 10:31:41 -0700 |
commit | e28ac5cf361eabee7a224954b99229b379496a8b (patch) | |
tree | 95259729f0b6e2dc44832e0bb11ff1cfac966234 /lib/ofp-msgs.c | |
parent | ab12d917764c1ae0c036144a053faba8eccf885c (diff) | |
download | openvswitch-e28ac5cf361eabee7a224954b99229b379496a8b.tar.gz |
ofp-msgs: New functions ofpmp_version() and ofpmp_decode_raw().
Each of these allows code in ofp-util.c to be simplified.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'lib/ofp-msgs.c')
-rw-r--r-- | lib/ofp-msgs.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/ofp-msgs.c b/lib/ofp-msgs.c index b67e47a7c..e54918efc 100644 --- a/lib/ofp-msgs.c +++ b/lib/ofp-msgs.c @@ -935,6 +935,31 @@ ofpmp_postappend(struct list *replies, size_t start_ofs) } } +/* Returns the OpenFlow version of the replies being constructed in 'replies', + * which should have been initialized by ofpmp_init(). */ +enum ofp_version +ofpmp_version(struct list *replies) +{ + struct ofpbuf *msg = ofpbuf_from_list(list_back(replies)); + const struct ofp_header *oh = ofpbuf_data(msg); + + return oh->version; +} + +/* Determines the OFPRAW_* type of the OpenFlow messages in 'replies', which + * should have been initialized by ofpmp_init(). */ +enum ofpraw +ofpmp_decode_raw(struct list *replies) +{ + struct ofpbuf *msg = ofpbuf_from_list(list_back(replies)); + enum ofperr error; + enum ofpraw raw; + + error = ofpraw_decode_partial(&raw, ofpbuf_data(msg), ofpbuf_size(msg)); + ovs_assert(!error); + return raw; +} + static ovs_be16 * ofpmp_flags__(const struct ofp_header *oh) { |