[ovs-dev] [PATCH] lib: Adapt jsonrpc header file for use in C++.

Yifeng Sun pkusunyifeng at gmail.com
Thu Oct 4 18:34:44 UTC 2018


ovsdb-idl.h and vswitch-idl.h provide the needed APIs that connect to
db.sock
and read information about Ports and Interfaces. But these header files are
quite large and complex, it looks hard to expose.

Or we make the changes to ovsdb-types.h as below so that it can be compiled
by c++ compilers. What do you think?

Thanks,
Yifeng

diff --git a/lib/ovsdb-types.h b/lib/ovsdb-types.h
index 368c41617794..b9eb0928df6b 100644
--- a/lib/ovsdb-types.h
+++ b/lib/ovsdb-types.h
@@ -53,6 +53,27 @@ enum ovsdb_ref_type {
     OVSDB_REF_WEAK              /* Delete reference if target disappears.
*/
 };

+struct ovsdb_integer_constraints {
+    int64_t min;        /* minInteger or INT64_MIN. */
+    int64_t max;        /* maxInteger or INT64_MAX. */
+};
+
+struct ovsdb_real_constraints {
+    double min;         /* minReal or -DBL_MAX. */
+    double max;         /* minReal or DBL_MAX. */
+};
+
+struct ovsdb_string_constraints {
+    unsigned int minLen; /* minLength or 0. */
+    unsigned int maxLen; /* maxLength or UINT_MAX. */
+};
+
+struct ovsdb_uuid_constraints {
+    char *refTableName; /* Name of referenced table, or NULL. */
+    struct ovsdb_table *refTable; /* Referenced table, if available. */
+    enum ovsdb_ref_type refType;  /* Reference type. */
+};
+
 struct ovsdb_base_type {
     enum ovsdb_atomic_type type;

@@ -61,28 +82,11 @@ struct ovsdb_base_type {
     struct ovsdb_datum *enum_;

     union {
-        struct ovsdb_integer_constraints {
-            int64_t min;        /* minInteger or INT64_MIN. */
-            int64_t max;        /* maxInteger or INT64_MAX. */
-        } integer;
-
-        struct ovsdb_real_constraints {
-            double min;         /* minReal or -DBL_MAX. */
-            double max;         /* minReal or DBL_MAX. */
-        } real;
-
+        struct ovsdb_integer_constraints integer;
+        struct ovsdb_real_constraints real;
         /* No constraints for Boolean types. */
-
-        struct ovsdb_string_constraints {
-            unsigned int minLen; /* minLength or 0. */
-            unsigned int maxLen; /* maxLength or UINT_MAX. */
-        } string;
-
-        struct ovsdb_uuid_constraints {
-            char *refTableName; /* Name of referenced table, or NULL. */
-            struct ovsdb_table *refTable; /* Referenced table, if
available. */
-            enum ovsdb_ref_type refType;  /* Reference type. */
-        } uuid;
+        struct ovsdb_string_constraints string;
+        struct ovsdb_uuid_constraints uuid;
     };
 };

On Thu, Oct 4, 2018 at 9:28 AM Ben Pfaff <blp at ovn.org> wrote:

> One point of view is that JSON-RPC is a standard protocol and it's not
> OVS's responsibility to implement it for every third-party program.
>
> Another is that we could expose the additional APIs that are needed.
>
> On Wed, Oct 03, 2018 at 07:01:09PM -0700, Yifeng Sun wrote:
> > We need a proper method for external code to send queries to db.sock.
> > The jsonrpc.h does expose more than what is needed.
> > Do you have any better suggestion?
> >
> > Thanks,
> > Yifeng
> >
> > On Wed, Oct 3, 2018 at 6:26 PM Ben Pfaff <blp at ovn.org> wrote:
> >
> > > On Wed, Oct 03, 2018 at 04:07:22PM -0700, Yifeng Sun wrote:
> > > > This patch exposes jsonrpc.h for inclusion in C++, which will be
> > > > used by NSX.
> > > >
> > > > It added [extern "C"] to the header file and fixed other places
> > > > to accommodate this change.
> > > >
> > > > Signed-off-by: Yifeng Sun <pkusunyifeng at gmail.com>
> > >
> > > Is this useful by itself?  The header file refers to struct stream,
> > > struct pstream, struct reconnect_stats, and struct svec, but these
> > > aren't in public headers.
> > >
>


More information about the dev mailing list