]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/basic/socket-util.c
tree-wide: "<n>bit" → "<n>-bit"
[thirdparty/systemd.git] / src / basic / socket-util.c
index 9040ff7c53471dcb38d0dcc68ea09315bd86d620..6951c12c9b72f8ceeb477af691bd7579992b4974 100644 (file)
@@ -1179,7 +1179,7 @@ void* cmsg_find_and_copy_data(struct msghdr *mh, int level, int type, void *buf,
         assert(buf_len > 0);
 
         /* This is similar to cmsg_find_data(), but copy the found data to buf. This should be typically used
-         * when reading possibly unaligned data such as timestamp, as time_t is 64bit and size_t is 32bit on
+         * when reading possibly unaligned data such as timestamp, as time_t is 64-bit and size_t is 32-bit on
          * RISCV32. See issue #27241. */
 
         cmsg = cmsg_find(mh, level, type, CMSG_LEN(buf_len));
@@ -1522,13 +1522,20 @@ int socket_address_parse_vsock(SocketAddress *ret_address, const char *s) {
         _cleanup_free_ char *n = NULL;
         char *e, *cid_start;
         unsigned port, cid;
-        int r;
+        int type, r;
 
         assert(ret_address);
         assert(s);
 
-        cid_start = startswith(s, "vsock:");
-        if (!cid_start)
+        if ((cid_start = startswith(s, "vsock:")))
+                type = 0;
+        else if ((cid_start = startswith(s, "vsock-dgram:")))
+                type = SOCK_DGRAM;
+        else if ((cid_start = startswith(s, "vsock-seqpacket:")))
+                type = SOCK_SEQPACKET;
+        else if ((cid_start = startswith(s, "vsock-stream:")))
+                type = SOCK_STREAM;
+        else
                 return -EPROTO;
 
         e = strchr(cid_start, ':');
@@ -1557,6 +1564,7 @@ int socket_address_parse_vsock(SocketAddress *ret_address, const char *s) {
                         .svm_family = AF_VSOCK,
                         .svm_port = port,
                 },
+                .type = type,
                 .size = sizeof(struct sockaddr_vm),
         };