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)
{
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());
}
/*
- * 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 *);
* 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
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;
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);
}
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]);
}
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]);
}
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]);
}
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]);
}