Crossport lib/process.[ch] from master branch.
[sliver-openvswitch.git] / lib / vconn-unix.c
index cff7d2e..b1a7d8a 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include "buffer.h"
-#include "socket-util.h"
-#include "util.h"
-#include "openflow.h"
-#include "ofp-print.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"
 
@@ -82,8 +81,13 @@ unix_open(const char *name, char *suffix, struct vconn **vconnp)
 }
 
 struct vconn_class unix_vconn_class = {
-    .name = "unix",
-    .open = unix_open,
+    "unix",                     /* name */
+    unix_open,                  /* open */
+    NULL,                       /* close */
+    NULL,                       /* connect */
+    NULL,                       /* recv */
+    NULL,                       /* send */
+    NULL,                       /* wait */
 };
 \f
 /* Passive UNIX socket. */
@@ -110,12 +114,11 @@ punix_accept(int fd, const struct sockaddr *sa, size_t sa_len,
              struct vconn **vconnp)
 {
     const struct sockaddr_un *sun = (const struct sockaddr_un *) sa;
+    int name_len = get_unix_name_len(sa_len);
     char name[128];
 
-    if (sa_len >= offsetof(struct sockaddr_un, sun_path)) {
-        snprintf(name, sizeof name, "unix:%.*s",
-                (int) (sa_len - offsetof(struct sockaddr_un, sun_path)),
-                sun->sun_path);
+    if (name_len > 0) {
+        snprintf(name, sizeof name, "unix:%.*s", name_len, sun->sun_path);
     } else {
         strcpy(name, "unix");
     }