vmci.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MPL-2.0 */
2 #include "precompiled.hpp"
3 
4 #include "ip.hpp"
5 #include "vmci.hpp"
6 #include "vmci_address.hpp"
7 
8 #if defined ZMQ_HAVE_VMCI
9 
10 #include <cassert>
11 #include <vmci_sockets.h>
12 
13 void zmq::tune_vmci_buffer_size (ctx_t *context_,
14  fd_t sockfd_,
15  uint64_t default_size_,
16  uint64_t min_size_,
17  uint64_t max_size_)
18 {
19  int family = context_->get_vmci_socket_family ();
20  assert (family != -1);
21 
22  if (default_size_ != 0) {
23  int rc = setsockopt (sockfd_, family, SO_VMCI_BUFFER_SIZE,
24  (char *) &default_size_, sizeof default_size_);
25 #if defined ZMQ_HAVE_WINDOWS
26  wsa_assert (rc != SOCKET_ERROR);
27 #else
28  errno_assert (rc == 0);
29 #endif
30  }
31 
32  if (min_size_ != 0) {
33  int rc = setsockopt (sockfd_, family, SO_VMCI_BUFFER_SIZE,
34  (char *) &min_size_, sizeof min_size_);
35 #if defined ZMQ_HAVE_WINDOWS
36  wsa_assert (rc != SOCKET_ERROR);
37 #else
38  errno_assert (rc == 0);
39 #endif
40  }
41 
42  if (max_size_ != 0) {
43  int rc = setsockopt (sockfd_, family, SO_VMCI_BUFFER_SIZE,
44  (char *) &max_size_, sizeof max_size_);
45 #if defined ZMQ_HAVE_WINDOWS
46  wsa_assert (rc != SOCKET_ERROR);
47 #else
48  errno_assert (rc == 0);
49 #endif
50  }
51 }
52 
53 #if defined ZMQ_HAVE_WINDOWS
54 void zmq::tune_vmci_connect_timeout (ctx_t *context_,
55  fd_t sockfd_,
56  DWORD timeout_)
57 #else
58 void zmq::tune_vmci_connect_timeout (ctx_t *context_,
59  fd_t sockfd_,
60  struct timeval timeout_)
61 #endif
62 {
63  int family = context_->get_vmci_socket_family ();
64  assert (family != -1);
65 
66  int rc = setsockopt (sockfd_, family, SO_VMCI_CONNECT_TIMEOUT,
67  (char *) &timeout_, sizeof timeout_);
68 #if defined ZMQ_HAVE_WINDOWS
69  wsa_assert (rc != SOCKET_ERROR);
70 #else
71  errno_assert (rc == 0);
72 #endif
73 }
74 
75 zmq::fd_t zmq::vmci_open_socket (const char *address_,
76  const zmq::options_t &options_,
77  zmq::vmci_address_t *out_vmci_addr_)
78 {
79  // Convert the textual address into address structure.
80  int rc = out_vmci_addr_->resolve (address_);
81  if (rc != 0)
82  return retired_fd;
83 
84  // Create the socket.
85  fd_t s = open_socket (out_vmci_addr_->family (), SOCK_STREAM, 0);
86 
87  if (s == retired_fd) {
88  return retired_fd;
89  }
90 
91  return s;
92 }
93 
94 #endif
context_
MockGeneratorContext context_
Definition: csharp_bootstrap_unittest.cc:125
ip.hpp
zmq::options_t
Definition: options.hpp:34
s
XmlRpcServer s
precompiled.hpp
zmq::fd_t
int fd_t
Definition: zmq.hpp:287
retired_fd
@ retired_fd
Definition: libzmq/tests/testutil.hpp:117
errno_assert
#define errno_assert(x)
Definition: err.hpp:113
zmq::open_socket
fd_t open_socket(int domain_, int type_, int protocol_)
Definition: ip.cpp:73
vmci.hpp
fd_t
zmq_fd_t fd_t
Definition: libzmq/tests/testutil.hpp:98
vmci_address.hpp
options_
DebugStringOptions options_
Definition: src/google/protobuf/descriptor.cc:2410


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:07:01