Merge "master" into "next".
[sliver-openvswitch.git] / lib / stream-unix.c
similarity index 74%
rename from lib/vconn-unix.c
rename to lib/stream-unix.c
index d2b5a0f..33f566b 100644 (file)
@@ -15,7 +15,7 @@
  */
 
 #include <config.h>
-#include "vconn.h"
+#include "stream.h"
 #include <assert.h>
 #include <errno.h>
 #include <inttypes.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include "ofpbuf.h"
-#include "openflow/openflow.h"
 #include "packets.h"
 #include "poll-loop.h"
 #include "socket-util.h"
 #include "util.h"
-#include "vconn-provider.h"
-#include "vconn-stream.h"
+#include "stream-provider.h"
+#include "stream-fd.h"
 
 #include "vlog.h"
-#define THIS_MODULE VLM_vconn_unix
+#define THIS_MODULE VLM_stream_unix
 
 /* Active UNIX socket. */
 
 static int n_unix_sockets;
 
 static int
-unix_open(const char *name, char *suffix, struct vconn **vconnp)
+unix_open(const char *name, char *suffix, struct stream **streamp)
 {
     const char *connect_path = suffix;
     char *bind_path;
     int fd;
 
-    bind_path = xasprintf("/tmp/vconn-unix.%ld.%d",
+    bind_path = xasprintf("/tmp/stream-unix.%ld.%d",
                           (long int) getpid(), n_unix_sockets++);
     fd = make_unix_socket(SOCK_STREAM, true, false, bind_path, connect_path);
     if (fd < 0) {
@@ -60,27 +58,30 @@ unix_open(const char *name, char *suffix, struct vconn **vconnp)
         return -fd;
     }
 
-    return new_stream_vconn(name, fd, check_connection_completion(fd),
-                            bind_path, vconnp);
+    return new_fd_stream(name, fd, check_connection_completion(fd),
+                         bind_path, streamp);
 }
 
-struct vconn_class unix_vconn_class = {
+struct stream_class unix_stream_class = {
     "unix",                     /* name */
     unix_open,                  /* open */
     NULL,                       /* close */
     NULL,                       /* connect */
     NULL,                       /* recv */
     NULL,                       /* send */
+    NULL,                       /* run */
+    NULL,                       /* run_wait */
     NULL,                       /* wait */
 };
 \f
 /* Passive UNIX socket. */
 
 static int punix_accept(int fd, const struct sockaddr *sa, size_t sa_len,
-                        struct vconn **vconnp);
+                        struct stream **streamp);
 
 static int
-punix_open(const char *name OVS_UNUSED, char *suffix, struct pvconn **pvconnp)
+punix_open(const char *name OVS_UNUSED, char *suffix,
+           struct pstream **pstreamp)
 {
     int fd, error;
 
@@ -90,12 +91,6 @@ punix_open(const char *name OVS_UNUSED, char *suffix, struct pvconn **pvconnp)
         return errno;
     }
 
-    error = set_nonblocking(fd);
-    if (error) {
-        close(fd);
-        return error;
-    }
-
     if (listen(fd, 10) < 0) {
         error = errno;
         VLOG_ERR("%s: listen: %s", name, strerror(error));
@@ -103,13 +98,13 @@ punix_open(const char *name OVS_UNUSED, char *suffix, struct pvconn **pvconnp)
         return error;
     }
 
-    return new_pstream_pvconn("punix", fd, punix_accept,
-                              xstrdup(suffix), pvconnp);
+    return new_fd_pstream("punix", fd, punix_accept,
+                          xstrdup(suffix), pstreamp);
 }
 
 static int
 punix_accept(int fd, const struct sockaddr *sa, size_t sa_len,
-             struct vconn **vconnp)
+             struct stream **streamp)
 {
     const struct sockaddr_un *sun = (const struct sockaddr_un *) sa;
     int name_len = get_unix_name_len(sa_len);
@@ -120,10 +115,10 @@ punix_accept(int fd, const struct sockaddr *sa, size_t sa_len,
     } else {
         strcpy(name, "unix");
     }
-    return new_stream_vconn(name, fd, 0, NULL, vconnp);
+    return new_fd_stream(name, fd, 0, NULL, streamp);
 }
 
-struct pvconn_class punix_pvconn_class = {
+struct pstream_class punix_pstream_class = {
     "punix",
     punix_open,
     NULL,