#define OFP_ASSERT BOOST_STATIC_ASSERT
#endif /* __cplusplus */
- #ifndef SWIG
- #define OFP_PACKED __attribute__((packed))
- #else
- #define OFP_PACKED /* SWIG doesn't understand __attribute. */
- #endif
-
+/* Version number:
+ * Non-experimental versions released: 0x01
+ * Experimental versions released: 0x81 -- 0x99
+ */
/* The most significant bit being set in the version field indicates an
- * experimental OpenFlow version.
+ * experimental OpenFlow version.
*/
-#define OFP_VERSION 0x97
+#define OFP_VERSION 0x01
#define OFP_MAX_TABLE_NAME_LEN 32
#define OFP_MAX_PORT_NAME_LEN 16
#define STRFTIME_FORMAT(FMT) __attribute__((__format__(__strftime__, FMT, 0)))
#define MALLOC_LIKE __attribute__((__malloc__))
#define ALWAYS_INLINE __attribute__((always_inline))
- #define likely(x) __builtin_expect((x),1)
- #define unlikely(x) __builtin_expect((x),0)
+#define WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
+ #else
+ #define NO_RETURN
+ #define OVS_UNUSED
+ #define PRINTF_FORMAT(FMT, ARG1)
+ #define STRFTIME_FORMAT(FMT)
+ #define MALLOC_LIKE
+ #define ALWAYS_INLINE
++#define WARN_UNUSED_RESULT
+ #endif
#endif /* compiler.h */
COVERAGE_INC(vconn_open);
check_vconn_classes();
- *vconnp = NULL;
- prefix_len = strcspn(name, ":");
- if (prefix_len == strlen(name)) {
- return EAFNOSUPPORT;
+ /* Look up the class. */
+ error = vconn_lookup_class(name, &class);
+ if (!class) {
+ goto error;
}
- for (i = 0; i < ARRAY_SIZE(vconn_classes); i++) {
- struct vconn_class *class = vconn_classes[i];
- if (strlen(class->name) == prefix_len
- && !memcmp(class->name, name, prefix_len)) {
- struct vconn *vconn;
- char *suffix_copy = xstrdup(name + prefix_len + 1);
- int retval = class->open(name, suffix_copy, &vconn);
- free(suffix_copy);
- if (!retval) {
- assert(vconn->state != VCS_CONNECTING
- || vconn->class->connect);
- vconn->min_version = min_version;
- *vconnp = vconn;
- }
- return retval;
- }
+
+ /* Call class's "open" function. */
+ suffix_copy = xstrdup(strchr(name, ':') + 1);
+ error = class->open(name, suffix_copy, &vconn);
+ free(suffix_copy);
+ if (error) {
+ goto error;
}
- return EAFNOSUPPORT;
+
+ /* Success. */
+ assert(vconn->state != VCS_CONNECTING || vconn->class->connect);
+ vconn->min_version = min_version;
+ *vconnp = vconn;
+ return 0;
+
+ error:
+ *vconnp = NULL;
+ return error;
}
+/* Allows 'vconn' to perform maintenance activities, such as flushing output
+ * buffers. */
+void
+vconn_run(struct vconn *vconn)
+{
+ if (vconn->class->run) {
+ (vconn->class->run)(vconn);
+ }
+}
+
+/* Arranges for the poll loop to wake up when 'vconn' needs to perform
+ * maintenance activities. */
+void
+vconn_run_wait(struct vconn *vconn)
+{
+ if (vconn->class->run_wait) {
+ (vconn->class->run_wait)(vconn);
+ }
+}
+
int
vconn_open_block(const char *name, int min_version, struct vconn **vconnp)
{