/*
- * 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.
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
case OFP12_VERSION:
case OFP13_VERSION:
case OFP14_VERSION:
+ case OFP15_VERSION:
return type == OFPT11_STATS_REQUEST;
}
case OFP12_VERSION:
case OFP13_VERSION:
case OFP14_VERSION:
+ case OFP15_VERSION:
return type == OFPT11_STATS_REPLY;
}
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
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;
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)
}
}
+/* 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)
{
case OFP12_VERSION:
case OFP13_VERSION:
case OFP14_VERSION:
+ case OFP15_VERSION:
return &((struct ofp11_stats_msg *) oh)->flags;
default:
OVS_NOT_REACHED();