From: Oliver Kurth Date: Fri, 15 Sep 2017 18:23:50 +0000 (-0700) Subject: VSOCK: Add getsockopt to determine stream socket disconnect cause X-Git-Tag: stable-10.2.0~106 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=407459a2ceee1d845a5055a856b5947ca00836f4;p=thirdparty%2Fopen-vm-tools.git VSOCK: Add getsockopt to determine stream socket disconnect cause 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. --- diff --git a/open-vm-tools/lib/include/vmci_sockets.h b/open-vm-tools/lib/include/vmci_sockets.h index b4d300c5a..29e80780d 100644 --- a/open-vm-tools/lib/include/vmci_sockets.h +++ b/open-vm-tools/lib/include/vmci_sockets.h @@ -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. *