Files
@ d6b9b2ac5869
Branch filter:
Location: vmkdrivers/BLD/build/HEADERS/vmkapi-current-all-public-bincomp/vmkernel64/release/sockets/vmkapi_socket.h
d6b9b2ac5869
22.3 KiB
text/x-chdr
ESXi-5.5-U2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 | /***************************************************************************
* Copyright 2007 - 2012 VMware, Inc. All rights reserved.
***************************************************************************/
/*
* @VMKAPIMOD_LICENSE@
*/
/*
***********************************************************************
* Sockets */ /**
* \defgroup Socket Network Socket Interfaces
* @{
*
***********************************************************************
*/
#ifndef _VMKAPI_SOCKET_H_
#define _VMKAPI_SOCKET_H_
/** \cond never */
#ifndef VMK_HEADER_INCLUDED_FROM_VMKAPI_H
#error This vmkapi file should never be included directly but only via vmkapi.h
#endif
/** \endcond never */
/**
* \brief Opaque socket handle.
*/
typedef struct vmk_SocketInt *vmk_Socket;
/**
* \brief Definition for an invalid vmk_Socket.
*/
#define VMK_SOCKET_INVALID ((vmk_Socket)NULL)
/*
* Address families
*/
/** \brief IPv4 */
#define VMK_SOCKET_AF_INET 2
/** \brief IPv6 */
#define VMK_SOCKET_AF_INET6 28
/*
* Socket types
*/
/** \brief Streaming */
#define VMK_SOCKET_SOCK_STREAM 1
/** \brief Datagrams */
#define VMK_SOCKET_SOCK_DGRAM 2
/** \brief Raw datagrams */
#define VMK_SOCKET_SOCK_RAW 3
/*
* Flags for vmk_SocketSendTo() and vmk_SocketRecvFrom()
*/
/** \brief Send/receive of this message should not block */
#define VMK_SOCKET_MSG_DONTWAIT 0x80
/*
* Socket option levels
*/
/** \brief Operate on the socket itself */
#define VMK_SOCKET_SOL_SOCKET 0xffff
/*
* Socket-level socket options
*/
/** \brief Allow local address reuse */
#define VMK_SOCKET_SO_REUSEADDR 0x0004
/** \brief Keep connections alive */
#define VMK_SOCKET_SO_KEEPALIVE 0x0008
/** \brief Just use interface addresses */
#define VMK_SOCKET_SO_DONTROUTE 0x0010
/** \brief Linger on close if data present */
#define VMK_SOCKET_SO_LINGER 0x0080
/** \brief Allow local address and port reuse */
#define VMK_SOCKET_SO_REUSEPORT 0x0200
/** \brief Timestamp received dgram traffic */
#define VMK_SOCKET_SO_TIMESTAMP 0x0400
/** \brief Use non-blocking socket semantics */
#define VMK_SOCKET_SO_NONBLOCKING 0x1015
/** \brief Bind socket to a vmknic
* \note Note that the TCP/IP stack will only transmit the packet if the routing
* decision indicates that it can be sent out of the specified vmknic.
*/
#define VMK_SOCKET_SO_BINDTOVMK 0x1016
/*
* Values for the vmk_SocketShutdown()'s "how" parameter
*/
/** \brief Further receives will be disallowed */
#define VMK_SOCKET_SHUT_RD 0
/** \brief Further sends will be disallowed. */
#define VMK_SOCKET_SHUT_WR 1
/** \brief Further sends and receives will be disallowed. */
#define VMK_SOCKET_SHUT_RDWR 2
/**
* \brief
* Abstract socket network address
*
* A protocol-specific address is used in actual practice.
*/
typedef struct vmk_SocketAddress {
vmk_uint8 sa_len;
vmk_uint8 sa_family;
vmk_uint8 sa_data[254];
} VMK_ATTRIBUTE_PACKED vmk_SocketAddress;
/**
* \brief
* Data structure for setting the VMK_SOCKET_SO_LINGER option
*/
typedef struct vmk_SocketLingerData {
/** \brief Whether linger is enabled or not */
vmk_uint32 enabled;
/** \brief Linger duration (in seconds) */
vmk_uint32 duration;
} VMK_ATTRIBUTE_PACKED vmk_SocketLingerData;
/*
***********************************************************************
* vmk_SocketAddrToString -- */ /**
*
* \ingroup Socket
* \brief Convert an address into a simple string for a particular
* address family.
*
* \nativedriversdisallowed
*
* \note This function will not block.
*
* \param[in] addr Address to translate to a string.
* \param[out] buffer Buffer to place the converted string into.
* \param[in] bufferLength Length of the buffer in bytes.
*
* \retval VMK_OK Success.
* \retval VMK_BAD_PARAM Bad input addr or buffer
* \retval VMK_NOT_SUPPORTED Unknown address family.
*
* \note This call does *not* do any sort of network lookup. It merely
* converts an address into a human-readable format. In most
* cases the converted string is simply a numeric string.
*
***********************************************************************
*/
VMK_ReturnStatus vmk_SocketAddrToString(const vmk_SocketAddress *addr,
char *buffer,
int bufferLength);
/*
***********************************************************************
* vmk_SocketStringToAddr -- */ /**
*
* \ingroup Socket
* \brief Convert an address into a simple string for a particular
* address family.
*
* \nativedriversdisallowed
*
* \note This function will not block.
*
* \param[in] addressFamily Address family that the string address
* will be converted into.
* \param[in] buffer Buffer containing the string to convert.
* \param[in] bufferLength Length of the buffer in bytes.
* \param[in,out] addr Address the string is converted into.
*
* \retval VMK_OK Success.
* \retval VMK_BAD_PARAM Bad input addr or buffer
* \retval VMK_NOT_SUPPORTED Unknown address family.
* \note This call does *not* do any sort of network lookup. It merely
* converts a simple human-readable string into a address. In most
* cases, this is simply a conversion of a numeric string into
* a network address.
*
***********************************************************************
*/
VMK_ReturnStatus vmk_SocketStringToAddr(int addressFamily,
const char *buffer,
int bufferLength,
vmk_SocketAddress *addr);
/*
***********************************************************************
* vmk_SocketCreate -- */ /**
*
* \ingroup Socket
* \brief Create a new unbound socket.
*
* \nativedriversdisallowed
*
* \note This function will not block.
* \note The default behavior is to create a blocking socket. If
* nonblocking behavior is required then the
* VMK_SOCKET_SO_NONBLOCKING socket option must be set.
*
* \param[in] domain Protocol family for this socket.
* \param[in] type Type of communication on this socket
* \param[in] protocol Specific protocol to use from address family
* \param[out] socket Newly created socket
*
* \retval VMK_OK Success.
* \retval VMK_BAD_PARAM Bad input parameter.
* \retval VMK_NO_MODULE_HEAP The module's heap is not set.
* \retval VMK_NO_MEMORY Unable to allocate memory for socket.
* \retval VMK_EPROTONOSUPPORT Maps to BSD error code EPROTONOSUPPORT.
* \retval VMK_BAD_PARAM_TYPE Maps to BSD error code EPROTOTYPE.
* \retval VMK_NO_BUFFERSPACE Maps to BSD error code ENOBUFS.
* \retval VMK_EOPNOTSUPP Maps to BSD error code EOPNOTSUPP.
* \retval VMK_NO_ACCESS Maps to BSD error code EACCESS.
*
* \note For BSD error code definitions see the FreeBSD 7 man page
* socket(2).
*
* \note Specific domain (VMK_SOCKET_AF_*), type (VMK_SOCKET_SOCK_*),
* and protocol (VMK_SOCKET_*PROTO*) values are implementation
* dependent, an application can determine if a specific domain
* and type is supported by trying to create a socket with zero
* protocol value.
*
***********************************************************************
*/
VMK_ReturnStatus vmk_SocketCreate(int domain,
int type,
int protocol,
vmk_Socket *socket);
/*
***********************************************************************
* vmk_SocketBind -- */ /**
*
* \ingroup Socket
* \brief Bind a socket to a network address endpoint.
*
* \nativedriversdisallowed
*
* \note This function will not block.
*
* \param[in] socket Socket to bind to the network address
* \param[in] address Information describing the network address
* that the socket will be bound to.
* \param[in] addressLength Length in bytes of the network address
* information.
*
* \retval VMK_BAD_PARAM Socket was already bound
* \retval VMK_NOT_SUPPORTED Unknown socket type.
* \retval VMK_NO_MODULE_HEAP This module's heap is not set.
* \retval VMK_EOPNOTSUPP Maps to BSD error code EOPNOTSUPP.
* \retval VMK_BAD_PARAM Maps to BSD error code EINVAL.
* \retval VMK_EADDRNOTAVAIL Maps to BSD error code EADDRNOTAVAIL.
* \retval VMK_ADDRFAM_UNSUPP Maps to BSD error code EAFNOSUPPORT.
* \retval VMK_EADDRINUSE Maps to BSD error code EADDRINUSE.
* \retval VMK_NO_ACCESS Maps to BSD error code EACCESS.
*
* \note For BSD error code definitions see the FreeBSD 7 man page
* bind(2).
*
***********************************************************************
*/
VMK_ReturnStatus vmk_SocketBind(vmk_Socket socket,
vmk_SocketAddress *address,
int addressLength);
/*
***********************************************************************
* vmk_SocketConnect -- */ /**
*
* \ingroup Socket
* \brief Connect to a network address
*
* \nativedriversdisallowed
*
* \note This function may block if the socket is blocking socket
* (this is the default behavior). If nonblocking behavior is required
* then the VMK_SOCKET_SO_NONBLOCKING socket option must be set.
*
* \param[in] socket Socket to connect through.
* \param[in] address The network address info for the address
* to connect to.
* \param[in] addressLength The length of the address info.
*
* \retval VMK_NOT_SUPPORTED Unknown socket type.
* \retval VMK_EALREADY Socket already connected.
* \retval VMK_EINPROGRESS Socket is nonblocking and connection
* is still in progress.
* \retval VMK_EOPNOTSUPP Maps to BSD error code EOPNOTSUPP.
* \retval VMK_ALREADY_CONNECTED Maps to BSD error code EISCONN.
* \retval VMK_BAD_PARAM Maps to BSD error code EINVAL.
* \retval VMK_EADDRNOTAVAIL Maps to BSD error code EADDRNOTAVAIL.
* \retval VMK_ADDRFAM_UNSUPP Maps to BSD error code EAFNOSUPPORT.
* \retval VMK_EADDRINUSE Maps to BSD error code EADDRINUSE.
* \retval VMK_NO_ACCESS Maps to BSD error code EACCESS.
*
* \note For BSD error code definitions see the FreeBSD 7 man page
* connect(2).
*
***********************************************************************
*/
VMK_ReturnStatus vmk_SocketConnect(vmk_Socket socket,
vmk_SocketAddress *address,
int addressLength);
/*
***********************************************************************
* vmk_SocketShutdown -- */ /**
*
* \ingroup Socket
* \brief Shutdown part or all of a connection on a socket
*
* \nativedriversdisallowed
*
* \note This function may block if VMK_SOCKET_SO_LINGER has been set
* otherwise it will not block.
*
* \param[in] socket Socket to query.
* \param[in] how Data direction(s) to shutdown on the socket.
*
* \retval VMK_NOT_SUPPORTED Unknown socket type.
* \retval VMK_EOPNOTSUPP Maps to BSD error code EOPNOTSUPP.
* \retval VMK_ECONNRESET Maps to BSD error code ECONNRESET.
* \retval VMK_ENOTCONN Maps to BSD error code ENOTCONN.
*
* \note For BSD error code definitions see the FreeBSD 7 man page
* shutdown(2).
*
***********************************************************************
*/
VMK_ReturnStatus vmk_SocketShutdown(vmk_Socket socket,
int how);
/*
***********************************************************************
* vmk_SocketClose -- */ /**
*
* \ingroup Socket
* \brief Destroy an existing socket.
*
* \nativedriversdisallowed
*
* \note This function may block if VMK_SOCKET_SO_LINGER has been set
* otherwise will not block.
*
* \param[in] socket Socket to close
*
* \retval VMK_OK Success.
* \retval VMK_BAD_PARAM Input socket is invalid.
* \retval VMK_NO_MODULE_HEAP The module's heap is not set.
* \retval VMK_BUSY Socket is already closing.
* \retval VMK_NOT_SUPPORTED Unknown socket type.
*
***********************************************************************
*/
VMK_ReturnStatus vmk_SocketClose(vmk_Socket socket);
/*
***********************************************************************
* vmk_SocketGetSockOpt -- */ /**
*
* \ingroup Socket
* \brief Get the option information from a socket
*
* \nativedriversdisallowed
*
* \note This function will not block.
*
* \param[in] socket Socket to get the option info from.
* \param[in] level Level of communication infrastructure from which
* to get the socket option.
* \param[in] option The option to get the information about.
* \param[out] optval Data that is currently set on the option.
* \param[out] optlen The length of option data.
*
* \retval VMK_OK Success.
* \retval VMK_BAD_PARAM Input socket is invalid.
* \retval VMK_NOT_SUPPORTED Unknown socket type.
* \retval VMK_NOT_SUPPORTED Maps to BSD error code ENOPROTOOPT.
* \retval VMK_EOPNOTSUPP Maps to BSD error code EOPNOTSUPP.
* \retval VMK_BAD_PARAM Maps to BSD error code EINVAL.
*
* \note For BSD error code definitions see the FreeBSD 7 man page
* getsockopt(2).
*
***********************************************************************
*/
VMK_ReturnStatus vmk_SocketGetSockOpt(vmk_Socket socket,
int level,
int option,
void *optval,
int *optlen);
/*
***********************************************************************
* vmk_SocketSetSockOpt -- */ /**
*
* \ingroup Socket
* \brief Set the option information on a socket
*
* \nativedriversdisallowed
*
* \note This function will not block.
*
* \param[in] socket Socket to set the option info on.
* \param[in] level Level of communication infrastructure from which
* to set the socket option.
* \param[in] option The option to set the information about.
* \param[in] optval Data to set on the option.
* \param[in] optlen The length of the option data.
*
* \retval VMK_OK Success.
* \retval VMK_BAD_PARAM Input socket is invalid.
* \retval VMK_NOT_SUPPORTED Unknown socket type.
* \retval VMK_NOT_SUPPORTED Maps to BSD error code ENOPROTOOPT.
* \retval VMK_EOPNOTSUPP Maps to BSD error code EOPNOTSUPP.
* \retval VMK_BAD_PARAM Maps to BSD error code EINVAL.
*
* \note For BSD error code definitions see the FreeBSD 7 man page
* setsockopt(2).
*
***********************************************************************
*/
VMK_ReturnStatus vmk_SocketSetSockOpt(vmk_Socket socket,
int level,
int option,
const void *optval,
int optlen);
/*
***********************************************************************
* vmk_SocketSendTo -- */ /**
*
* \ingroup Socket
* \brief Send data to a network address.
*
* \nativedriversdisallowed
*
* \note This function may block if the VMK_SOCKET_MSG_DONTWAIT flag is
* not set or the socket is a blocking socket.
*
* \param[in] socket Socket to send the data through.
* \param[in] flags Settings for this send transaction.
* \param[in] address Address information describing the
* data's destination.
* \param[in] data Pointer to data buffer to send.
* \param[in] len Length in bytes of the data buffer to send.
* \param[out] bytesSent Number of bytes actually sent.
*
* \retval VMK_OK Success.
* \retval VMK_NOT_SUPPORTED Unknown socket type.
* \retval VMK_BAD_PARAM Unsupported flags setting.
* \retval VMK_EOPNOTSUPP Maps to BSD error code EOPNOTSUPP.
* \retval VMK_ENOTCONN Maps to BSD error code ENOTCONN.
* \retval VMK_EDESTADDRREQ Maps to BSD error code EDESTADDRREQ.
* \retval VMK_MESSAGE_TOO_LONG Maps to BSD error code EMSGSIZE.
* \retval VMK_WOULD_BLOCK Maps to BSD error code EAGAIN.
* \retval VMK_NO_BUFFERSPACE Maps to BSD error code ENOBUFS.
* \retval VMK_EHOSTUNREACH Maps to BSD error code EHOSTUNREACH.
* \retval VMK_ALREADY_CONNECTED Maps to BSD error code EISCONN.
* \retval VMK_ECONNREFUSED Maps to BSD error code ECONNREFUSED.
* \retval VMK_EHOSTDOWN Maps to BSD error code EHOSTDOWN.
* \retval VMK_ENETDOWN Maps to BSD error code ENETDOWN.
* \retval VMK_EADDRNOTAVAIL Maps to BSD error code EADDRNOTAVAIL.
* \retval VMK_BROKEN_PIPE Maps to BSD error code EPIPE.
*
* \note For BSD error code definitions see the FreeBSD 7 man page
* sendto(2).
*
***********************************************************************
*/
VMK_ReturnStatus vmk_SocketSendTo(vmk_Socket socket,
int flags,
vmk_SocketAddress *address,
void *data,
int len,
int *bytesSent);
/*
***********************************************************************
* vmk_SocketRecvFrom -- */ /**
*
* \ingroup Socket
* \brief Receive data from a network address.
*
* \nativedriversdisallowed
*
* \note This function may block if the VMK_SOCKET_MSG_DONTWAIT flag is
* not set or the socket is a blocking socket.
*
* \param[in] socket Socket to receive the data through.
* \param[in] flags Settings for this receive transaction.
* \param[in] address The source address information the
* messages should be received from,
* or NULL if this is not necessary for
* the socket's protocol or settings.
* \param[in,out] addressLength Length in bytes of the address
* information.
* \param[in] data Pointer to data buffer to receive to.
* \param[in] len Length in bytes of the data buffer.
* \param[out] bytesReceived Number of bytes actually received.
*
* \retval VMK_NOT_SUPPORTED Receive on unbound VMKLINK socket is
* not supported.
* \retval VMK_EOPNOTSUPP Maps to BSD error code EOPNOTSUPP.
* \retval VMK_ENOTCONN Maps to BSD error code ENOTCONN.
* \retval VMK_MESSAGE_TOO_LONG Maps to BSD error code EMSGSIZE.
* \retval VMK_WOULD_BLOCK Maps to BSD error code EAGAIN.
* \retval VMK_ECONNRESET Maps to BSD error code ECONNRESET.
* \retval VMK_INVALID_ADDRESS Maps to BSD error code EFAULT.
*
* \note For BSD error code definitions see the FreeBSD 7 man page
* recvfrom(2).
*
***********************************************************************
*/
VMK_ReturnStatus vmk_SocketRecvFrom(vmk_Socket socket,
int flags,
vmk_SocketAddress *address,
int *addressLength,
void *data,
int len,
int *bytesReceived);
/*
***********************************************************************
* vmk_SocketGetSockName -- */ /**
*
* \ingroup Socket
* \brief Get the socket's local endpoint network address information.
*
* \nativedriversdisallowed
*
* \note This function will not block.
*
* \param[in] socket Socket to query.
* \param[out] address The network address info for the socket
* local endpoint.
* \param[in,out] addressLength The length of the address info.
*
* \retval VMK_OK Success.
* \retval VMK_BAD_PARAM Bad input socket or address.
* \retval VMK_NOT_SUPPORTED Unknown socket family.
* \retval VMK_EOPNOTSUPP Maps to BSD error code EOPNOTSUPP.
* \retval VMK_BAD_PARAM Maps to BSD error code EINVAL.
* \retval VMK_NO_MEMORY Maps to BSD error code ENOMEM.
*
* \note For BSD error code definitions see the FreeBSD 7 man page
* getsockname(2).
*
***********************************************************************
*/
VMK_ReturnStatus vmk_SocketGetSockName(vmk_Socket socket,
vmk_SocketAddress *address,
int *addressLength);
/*
***********************************************************************
* vmk_SocketGetPeerName -- */ /**
*
* \ingroup Socket
* \brief Get the socket's far endpoint network address information.
*
* \nativedriversdisallowed
*
* \note This function will not block.
*
* \param[in] socket Socket to query.
* \param[out] address The network address info for the
* socket remote endpoint.
* \param[in,out] addressLength The length of the address info.
*
* \retval VMK_OK Success.
* \retval VMK_BAD_PARAM Bad input socket or address.
* \retval VMK_NOT_SUPPORTED Unknown socket family.
* \retval VMK_EOPNOTSUPP Maps to BSD error code EOPNOTSUPP.
* \retval VMK_NO_MEMORY Maps to BSD error code ENOMEM.
* \retval VMK_ENOTCONN Maps to BSD error code ENOTCONN.
*
* \note For BSD error code definitions see the FreeBSD 7 man page
* getpeername(2).
*
***********************************************************************
*/
VMK_ReturnStatus vmk_SocketGetPeerName(vmk_Socket socket,
vmk_SocketAddress *address,
int *addressLength);
#endif /* _VMKAPI_SOCKET_H_ */
/** @} */
|