unixctl: New JSON RPC back-end.
[sliver-openvswitch.git] / utilities / ovs-ofctl.c
index bf7a2c1..fd0829e 100644 (file)
@@ -254,7 +254,7 @@ ofctl_exit(struct unixctl_conn *conn, int argc OVS_UNUSED,
 {
     bool *exiting = exiting_;
     *exiting = true;
-    unixctl_command_reply(conn, 200, "");
+    unixctl_command_reply(conn, NULL);
 }
 
 static void run(int retval, const char *message, ...)
@@ -910,7 +910,12 @@ ofctl_send(struct unixctl_conn *conn, int argc,
             ds_put_cstr(&reply, "sent\n");
         }
     }
-    unixctl_command_reply(conn, ok ? 200 : 501, ds_cstr(&reply));
+
+    if (ok) {
+        unixctl_command_reply(conn, ds_cstr(&reply));
+    } else {
+        unixctl_command_reply_error(conn, ds_cstr(&reply));
+    }
     ds_destroy(&reply);
 }
 
@@ -928,7 +933,7 @@ ofctl_barrier(struct unixctl_conn *conn, int argc OVS_UNUSED,
     int error;
 
     if (aux->conn) {
-        unixctl_command_reply(conn, 501, "already waiting for barrier reply");
+        unixctl_command_reply_error(conn, "already waiting for barrier reply");
         return;
     }
 
@@ -939,7 +944,7 @@ ofctl_barrier(struct unixctl_conn *conn, int argc OVS_UNUSED,
     error = vconn_send_block(aux->vconn, msg);
     if (error) {
         ofpbuf_delete(msg);
-        unixctl_command_reply(conn, 501, strerror(error));
+        unixctl_command_reply_error(conn, strerror(error));
     } else {
         aux->conn = conn;
     }
@@ -953,14 +958,14 @@ ofctl_set_output_file(struct unixctl_conn *conn, int argc OVS_UNUSED,
 
     fd = open(argv[1], O_CREAT | O_TRUNC | O_WRONLY, 0666);
     if (fd < 0) {
-        unixctl_command_reply(conn, 501, strerror(errno));
+        unixctl_command_reply_error(conn, strerror(errno));
         return;
     }
 
     fflush(stderr);
     dup2(fd, STDERR_FILENO);
     close(fd);
-    unixctl_command_reply(conn, 200, "");
+    unixctl_command_reply(conn, NULL);
 }
 
 static void
@@ -1013,7 +1018,7 @@ monitor_vconn(struct vconn *vconn)
             ofpbuf_delete(b);
 
             if (barrier_aux.conn && msg_type == OFPT_BARRIER_REPLY) {
-                unixctl_command_reply(barrier_aux.conn, 200, "");
+                unixctl_command_reply(barrier_aux.conn, NULL);
                 barrier_aux.conn = NULL;
             }
         }