summaryrefslogtreecommitdiff
path: root/lib/ofp-msgs.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2014-05-07 15:11:28 -0700
committerBen Pfaff <blp@nicira.com>2014-05-14 10:31:41 -0700
commite28ac5cf361eabee7a224954b99229b379496a8b (patch)
tree95259729f0b6e2dc44832e0bb11ff1cfac966234 /lib/ofp-msgs.c
parentab12d917764c1ae0c036144a053faba8eccf885c (diff)
downloadopenvswitch-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.c25
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)
{