datapath-windows: Make VPORT ovs number values smaller than MAXUINT16
[cascardo/ovs.git] / lib / ofp-msgs.c
index b67e47a..904aba6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013 Nicira, Inc.
+ * Copyright (c) 2012, 2013, 2014 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -110,11 +110,9 @@ static enum ofperr ofpraw_from_ofphdrs(enum ofpraw *, const struct ofphdrs *);
 static ovs_be32
 alloc_xid(void)
 {
-    static atomic_uint32_t next_xid = ATOMIC_VAR_INIT(1);
-    uint32_t xid;
+    static atomic_count next_xid = ATOMIC_COUNT_INIT(1);
 
-    atomic_add(&next_xid, 1, &xid);
-    return htonl(xid);
+    return htonl(atomic_count_inc(&next_xid));
 }
 \f
 static uint32_t
@@ -269,6 +267,7 @@ ofp_is_stat_request(enum ofp_version version, uint8_t type)
     case OFP12_VERSION:
     case OFP13_VERSION:
     case OFP14_VERSION:
+    case OFP15_VERSION:
         return type == OFPT11_STATS_REQUEST;
     }
 
@@ -285,6 +284,7 @@ ofp_is_stat_reply(enum ofp_version version, uint8_t type)
     case OFP12_VERSION:
     case OFP13_VERSION:
     case OFP14_VERSION:
+    case OFP15_VERSION:
         return type == OFPT11_STATS_REPLY;
     }
 
@@ -325,6 +325,7 @@ ofphdrs_len(const struct ofphdrs *hdrs)
     case OFP12_VERSION:
     case OFP13_VERSION:
     case OFP14_VERSION:
+    case OFP15_VERSION:
         if (hdrs->type == OFPT11_STATS_REQUEST ||
             hdrs->type == OFPT11_STATS_REPLY) {
             return (hdrs->stat == OFPST_VENDOR
@@ -758,6 +759,7 @@ ofpraw_stats_request_to_reply(enum ofpraw raw, uint8_t version)
     case OFP12_VERSION:
     case OFP13_VERSION:
     case OFP14_VERSION:
+    case OFP15_VERSION:
         ovs_assert(hdrs.type == OFPT11_STATS_REQUEST);
         hdrs.type = OFPT11_STATS_REPLY;
         break;
@@ -832,7 +834,7 @@ ofpmsg_update_length(struct ofpbuf *buf)
     oh->length = htons(ofpbuf_size(buf));
 }
 
-/* Returns just past the Openflow header (including the stats headers, vendor
+/* Returns just past the OpenFlow header (including the stats headers, vendor
  * header, and any subtype header) in 'oh'. */
 const void *
 ofpmsg_body(const struct ofp_header *oh)
@@ -935,6 +937,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)
 {
@@ -945,6 +972,7 @@ ofpmp_flags__(const struct ofp_header *oh)
     case OFP12_VERSION:
     case OFP13_VERSION:
     case OFP14_VERSION:
+    case OFP15_VERSION:
         return &((struct ofp11_stats_msg *) oh)->flags;
     default:
         OVS_NOT_REACHED();