ovsdb: Use port 6632 as a default port for database connections.
authorBen Pfaff <blp@nicira.com>
Thu, 18 Mar 2010 19:59:34 +0000 (12:59 -0700)
committerBen Pfaff <blp@nicira.com>
Mon, 12 Apr 2010 18:15:15 +0000 (11:15 -0700)
Until now we have required a port number to be specified explicitly for
database connections.  This commit adopts port 6632 as a default.

lib/jsonrpc.c
lib/jsonrpc.h
ovsdb/SPECS
ovsdb/jsonrpc-server.c
ovsdb/ovsdb-client.c
tests/test-jsonrpc.c
tests/test-ovsdb.c

index f0ac27b..72590a2 100644 (file)
@@ -56,6 +56,24 @@ static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 5);
 static void jsonrpc_received(struct jsonrpc *);
 static void jsonrpc_cleanup(struct jsonrpc *);
 
+/* This is just the same as stream_open() except that it uses the default
+ * JSONRPC ports if none is specified. */
+int
+jsonrpc_stream_open(const char *name, struct stream **streamp)
+{
+    return stream_open_with_default_ports(name, JSONRPC_TCP_PORT,
+                                          JSONRPC_SSL_PORT, streamp);
+}
+
+/* This is just the same as pstream_open() except that it uses the default
+ * JSONRPC ports if none is specified. */
+int
+jsonrpc_pstream_open(const char *name, struct pstream **pstreamp)
+{
+    return pstream_open_with_default_ports(name, JSONRPC_TCP_PORT,
+                                           JSONRPC_SSL_PORT, pstreamp);
+}
+
 struct jsonrpc *
 jsonrpc_open(struct stream *stream)
 {
@@ -727,12 +745,12 @@ jsonrpc_session_connect(struct jsonrpc_session *s)
 
     jsonrpc_session_disconnect(s);
     if (!reconnect_is_passive(s->reconnect)) {
-        error = stream_open(name, &s->stream);
+        error = jsonrpc_stream_open(name, &s->stream);
         if (!error) {
             reconnect_connecting(s->reconnect, time_msec());
         }
     } else {
-        error = s->pstream ? 0 : pstream_open(name, &s->pstream);
+        error = s->pstream ? 0 : jsonrpc_pstream_open(name, &s->pstream);
         if (!error) {
             reconnect_listening(s->reconnect, time_msec());
         }
index ae8b9de..154c459 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009 Nicira Networks.
+ * Copyright (c) 2009, 2010 Nicira Networks.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 struct json;
 struct jsonrpc_msg;
+struct pstream;
 struct stream;
 \f
 /* API for a JSON-RPC stream. */
 
+/* Default port numbers.
+ *
+ * There is nothing standard about these port numbers.  They are simply what
+ * we have chosen. */
+#define JSONRPC_TCP_PORT 6632
+#define JSONRPC_SSL_PORT 6632
+
+int jsonrpc_stream_open(const char *name, struct stream **);
+int jsonrpc_pstream_open(const char *name, struct pstream **);
+
 struct jsonrpc *jsonrpc_open(struct stream *);
 void jsonrpc_close(struct jsonrpc *);
 
index c926e21..cbd69de 100644 (file)
@@ -251,6 +251,8 @@ over HTTP, for these reasons:
 
     * The JSON-RPC specification for HTTP transport is incomplete.
 
+We are using TCP port 6632 for the database JSON-RPC connection.
+
 The database wire protocol consists of the following JSON-RPC methods:
 
 list_dbs
index 73c3c1c..84243d5 100644 (file)
@@ -144,7 +144,7 @@ ovsdb_jsonrpc_server_add_remote(struct ovsdb_jsonrpc_server *svr,
     struct pstream *listener;
     int error;
 
-    error = pstream_open(name, &listener);
+    error = jsonrpc_pstream_open(name, &listener);
     if (error && error != EAFNOSUPPORT) {
         VLOG_ERR_RL(&rl, "%s: listen failed: %s", name, strerror(error));
         return;
index a17c5aa..7a8310f 100644 (file)
@@ -224,11 +224,11 @@ open_jsonrpc(const char *server)
     struct stream *stream;
     int error;
 
-    error = stream_open_block(stream_open(server, &stream), &stream);
+    error = stream_open_block(jsonrpc_stream_open(server, &stream), &stream);
     if (error == EAFNOSUPPORT) {
         struct pstream *pstream;
 
-        error = pstream_open(server, &pstream);
+        error = jsonrpc_pstream_open(server, &pstream);
         if (error) {
             ovs_fatal(error, "failed to connect or listen to \"%s\"", server);
         }
index f760b3c..d02a65f 100644 (file)
@@ -185,7 +185,7 @@ do_listen(int argc OVS_UNUSED, char *argv[])
 
     die_if_already_running();
 
-    error = pstream_open(argv[1], &pstream);
+    error = jsonrpc_pstream_open(argv[1], &pstream);
     if (error) {
         ovs_fatal(error, "could not listen on \"%s\"", argv[1]);
     }
@@ -274,7 +274,7 @@ do_request(int argc OVS_UNUSED, char *argv[])
         ovs_fatal(0, "not a valid JSON-RPC request: %s", string);
     }
 
-    error = stream_open_block(stream_open(argv[1], &stream), &stream);
+    error = stream_open_block(jsonrpc_stream_open(argv[1], &stream), &stream);
     if (error) {
         ovs_fatal(error, "could not open \"%s\"", argv[1]);
     }
@@ -313,7 +313,7 @@ do_notify(int argc OVS_UNUSED, char *argv[])
         ovs_fatal(0, "not a JSON RPC-valid notification: %s", string);
     }
 
-    error = stream_open_block(stream_open(argv[1], &stream), &stream);
+    error = stream_open_block(jsonrpc_stream_open(argv[1], &stream), &stream);
     if (error) {
         ovs_fatal(error, "could not open \"%s\"", argv[1]);
     }
index 8cb6c94..41308d5 100644 (file)
@@ -1764,7 +1764,8 @@ do_idl(int argc, char *argv[])
     if (argc > 2) {
         struct stream *stream;
 
-        error = stream_open_block(stream_open(argv[1], &stream), &stream);
+        error = stream_open_block(jsonrpc_stream_open(argv[1], &stream),
+                                  &stream);
         if (error) {
             ovs_fatal(error, "failed to connect to \"%s\"", argv[1]);
         }