]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
VSOCK: Add getsockopt to determine stream socket disconnect cause
authorOliver Kurth <okurth@vmware.com>
Fri, 15 Sep 2017 18:23:50 +0000 (11:23 -0700)
committerOliver Kurth <okurth@vmware.com>
Fri, 15 Sep 2017 18:23:50 +0000 (11:23 -0700)
This is the vSocket part of adding support for getting the
disconnect cause of a vSocket stream socket. This adds a
getsockopt option to determine stream socket disconnect cause
as registered by the underlying VMCI queue pair.

open-vm-tools/lib/include/vmci_sockets.h

index b4d300c5a9a11d524259fbfd80080f741d4e0999..29e80780db24136167f43479222fbde8d8220830 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2007-2016 VMware, Inc. All rights reserved.
+ * Copyright (C) 2007-2017 VMware, Inc. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published
@@ -249,6 +249,36 @@ extern "C" {
 
 #define SO_VMCI_NONBLOCK_TXRX               7
 
+/**
+ * \brief Option name for STREAM socket connection disconect cause
+ *
+ * Use as the option name in \c getsockopt(3) to get the cause of the
+ * peer disconnect for a stream socket.
+ *
+ * \note Only available for ESX (VMkernel/userworld) endpoints.
+ *
+ * An example is given below.
+ *
+ * \code
+ * int vmciFd;
+ * int af = VMCISock_GetAFValueFd(&vmciFd);
+ * int32 cause;
+ * socklen_t len = sizeof cause;
+ * int fd = socket(af, SOCK_DGRAM, 0);
+ * ...
+ * if (recv(fd, buf, buflen, 0) == 0) {
+ *    getsockopt(fd, af, SO_VMCI_DISCONNECT_CAUSE, &cause, &len);
+ * }
+ * close(fd);
+ * VMCISock_ReleaseAFValueFd(vmciFd);
+ * \endcode
+ */
+
+#define SO_VMCI_DISCONNECT_CAUSE            8
+
+#define VMCI_SOCKETS_DISCONNECT_REGULAR     0
+#define VMCI_SOCKETS_DISCONNECT_VMOTION     1
+
 /**
  * \brief The vSocket equivalent of INADDR_ANY.
  *