+/* OFPUTIL_VENDOR_* definitions. */
+enum ofputil_vendor_codes {
+#define OFPUTIL_VENDOR(NAME, VENDOR_ID) NAME,
+ OFPUTIL_VENDORS
+ OFPUTIL_N_VENDORS
+#undef OFPUTIL_VENDOR
+};
+\f
+/* Error codes.
+ *
+ * We embed system errno values and OpenFlow standard and vendor extension
+ * error codes into a single 31-bit space using the following encoding.
+ * (Bit 31 is unused and assumed 0 to avoid negative "int" values.)
+ *
+ * 30 0
+ * +------------------------------------------------------+
+ * | 0 | success
+ * +------------------------------------------------------+
+ *
+ * 30 29 0
+ * +--+---------------------------------------------------+
+ * | 0| errno value | errno value
+ * +--+---------------------------------------------------+
+ *
+ * 30 29 26 25 16 15 0
+ * +--+-------+----------------+--------------------------+
+ * | 1| 0 | type | code | standard OpenFlow
+ * +--+-------+----------------+--------------------------+ error
+ *
+ * 30 29 26 25 16 15 0
+ * +--+-------+----------------+--------------------------+ Nicira
+ * | 1| vendor| type | code | NXET_VENDOR
+ * +--+-------+----------------+--------------------------+ error extension
+ *
+ * C and POSIX say that errno values are positive. We assume that they are
+ * less than 2**29. They are actually less than 65536 on at least Linux,
+ * FreeBSD, OpenBSD, and Windows.
+ *
+ * The 'vendor' field holds one of the OFPUTIL_VENDOR_* codes defined above.
+ * It must be nonzero.
+ *
+ * Negative values are not defined.
+ */
+
+/* Currently 4 bits are allocated to the "vendor" field. Make sure that all
+ * the vendor codes can fit. */
+BUILD_ASSERT_DECL(OFPUTIL_N_VENDORS <= 16);
+
+/* These are macro versions of the functions defined below. The macro versions
+ * are intended for use in contexts where function calls are not allowed,
+ * e.g. static initializers and case labels. */
+#define OFP_MKERR(TYPE, CODE) ((1 << 30) | ((TYPE) << 16) | (CODE))
+#define OFP_MKERR_VENDOR(VENDOR, TYPE, CODE) \
+ ((1 << 30) | ((VENDOR) << 26) | ((TYPE) << 16) | (CODE))
+#define OFP_MKERR_NICIRA(TYPE, CODE) \
+ OFP_MKERR_VENDOR(OFPUTIL_VENDOR_NICIRA, TYPE, CODE)
+
+/* Returns the standard OpenFlow error with the specified 'type' and 'code' as
+ * an integer. */