From: Ben Pfaff Date: Thu, 11 Sep 2008 18:46:57 +0000 (-0700) Subject: Make "struct vconn" opaque. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9fe9a47916b38646a30bbceb60c7a2b7caba1112;p=openvswitch Make "struct vconn" opaque. --- diff --git a/include/vconn-provider.h b/include/vconn-provider.h index 57778e7b..8bb8368a 100644 --- a/include/vconn-provider.h +++ b/include/vconn-provider.h @@ -37,9 +37,12 @@ /* Provider interface, which provide a virtual connection to an OpenFlow * device. */ +#include #include "vconn.h" -/* Virtual connection to an OpenFlow device. */ +/* Virtual connection to an OpenFlow device. + * + * This structure should be treated as opaque by vconn implementations. */ struct vconn { struct vconn_class *class; int connect_status; @@ -49,6 +52,11 @@ struct vconn { void vconn_init(struct vconn *, struct vconn_class *, int connect_status, uint32_t ip, const char *name); +static inline void vconn_assert_class(const struct vconn *vconn, + const struct vconn_class *class) +{ + assert(vconn->class == class); +} struct vconn_class { /* Prefix for connection names, e.g. "nl", "tcp". */ diff --git a/lib/vconn-netlink.c b/lib/vconn-netlink.c index 4f609bb3..29212369 100644 --- a/lib/vconn-netlink.c +++ b/lib/vconn-netlink.c @@ -65,7 +65,7 @@ struct netlink_vconn static struct netlink_vconn * netlink_vconn_cast(struct vconn *vconn) { - assert(vconn->class == &netlink_vconn_class); + vconn_assert_class(vconn, &netlink_vconn_class); return CONTAINER_OF(vconn, struct netlink_vconn, vconn); } diff --git a/lib/vconn-ssl.c b/lib/vconn-ssl.c index d553834f..d899e091 100644 --- a/lib/vconn-ssl.c +++ b/lib/vconn-ssl.c @@ -251,7 +251,7 @@ error: static struct ssl_vconn * ssl_vconn_cast(struct vconn *vconn) { - assert(vconn->class == &ssl_vconn_class); + vconn_assert_class(vconn, &ssl_vconn_class); return CONTAINER_OF(vconn, struct ssl_vconn, vconn); } @@ -672,7 +672,7 @@ struct pssl_vconn static struct pssl_vconn * pssl_vconn_cast(struct vconn *vconn) { - assert(vconn->class == &pssl_vconn_class); + vconn_assert_class(vconn, &pssl_vconn_class); return CONTAINER_OF(vconn, struct pssl_vconn, vconn); } diff --git a/lib/vconn-stream.c b/lib/vconn-stream.c index 444778a9..f58cc2c0 100644 --- a/lib/vconn-stream.c +++ b/lib/vconn-stream.c @@ -85,7 +85,7 @@ new_stream_vconn(const char *name, int fd, int connect_status, static struct stream_vconn * stream_vconn_cast(struct vconn *vconn) { - assert(vconn->class == &stream_vconn_class); + vconn_assert_class(vconn, &stream_vconn_class); return CONTAINER_OF(vconn, struct stream_vconn, vconn); } @@ -269,7 +269,7 @@ static struct vconn_class pstream_vconn_class; static struct pstream_vconn * pstream_vconn_cast(struct vconn *vconn) { - assert(vconn->class == &pstream_vconn_class); + vconn_assert_class(vconn, &pstream_vconn_class); return CONTAINER_OF(vconn, struct pstream_vconn, vconn); }