Ruby  2.5.0dev(2017-10-22revision60238)
rubysocket.h
Go to the documentation of this file.
1 #ifndef RUBY_SOCKET_H
2 #define RUBY_SOCKET_H 1
3 
4 #include "ruby/ruby.h"
5 #include "ruby/io.h"
6 #include "ruby/thread.h"
7 #include "ruby/util.h"
8 #include "internal.h"
9 #include <stdio.h>
10 #include <sys/types.h>
11 #include <sys/stat.h>
12 
13 #ifdef HAVE_UNISTD_H
14 # include <unistd.h>
15 #endif
16 
17 #ifdef HAVE_SYS_UIO_H
18 # include <sys/uio.h>
19 #endif
20 
21 #ifdef HAVE_XTI_H
22 # include <xti.h>
23 #endif
24 
25 #ifdef _WIN32
26 # if defined(_MSC_VER)
27 # undef HAVE_TYPE_STRUCT_SOCKADDR_DL
28 # endif
29 #else
30 # include <sys/socket.h>
31 # include <netinet/in.h>
32 # ifdef HAVE_NETINET_IN_SYSTM_H
33 # include <netinet/in_systm.h>
34 # endif
35 # ifdef HAVE_NETINET_TCP_H
36 # include <netinet/tcp.h>
37 # endif
38 # ifdef HAVE_NETINET_TCP_FSM_H
39 # include <netinet/tcp_fsm.h>
40 # endif
41 # ifdef HAVE_NETINET_UDP_H
42 # include <netinet/udp.h>
43 # endif
44 # ifdef HAVE_ARPA_INET_H
45 # include <arpa/inet.h>
46 # endif
47 # include <netdb.h>
48 #endif
49 
50 #ifdef HAVE_NETPACKET_PACKET_H
51 # include <netpacket/packet.h>
52 #endif
53 #ifdef HAVE_NET_ETHERNET_H
54 # include <net/ethernet.h>
55 #endif
56 
57 #include <errno.h>
58 
59 #ifdef HAVE_SYS_UN_H
60 # include <sys/un.h>
61 #endif
62 
63 #if defined(HAVE_FCNTL)
64 # ifdef HAVE_SYS_SELECT_H
65 # include <sys/select.h>
66 # endif
67 # ifdef HAVE_SYS_TYPES_H
68 # include <sys/types.h>
69 # endif
70 # ifdef HAVE_SYS_TIME_H
71 # include <sys/time.h>
72 # endif
73 # ifdef HAVE_FCNTL_H
74 # include <fcntl.h>
75 # endif
76 #endif
77 
78 #ifdef HAVE_IFADDRS_H
79 # ifdef __HAIKU__
80 # define _BSD_SOURCE
81 # endif
82 # include <ifaddrs.h>
83 #endif
84 #ifdef HAVE_SYS_IOCTL_H
85 # include <sys/ioctl.h>
86 #endif
87 #ifdef HAVE_SYS_SOCKIO_H
88 # include <sys/sockio.h>
89 #endif
90 #ifdef HAVE_NET_IF_H
91 # include <net/if.h>
92 #endif
93 
94 #ifdef HAVE_SYS_PARAM_H
95 # include <sys/param.h>
96 #endif
97 #ifdef HAVE_SYS_UCRED_H
98 # include <sys/ucred.h>
99 #endif
100 #ifdef HAVE_UCRED_H
101 # include <ucred.h>
102 #endif
103 #ifdef HAVE_NET_IF_DL_H
104 # include <net/if_dl.h>
105 #endif
106 
107 #ifndef HAVE_TYPE_SOCKLEN_T
108 typedef int socklen_t;
109 #endif
110 
111 #ifdef NEED_IF_INDEXTONAME_DECL
112 char *if_indextoname(unsigned int, char *);
113 #endif
114 #ifdef NEED_IF_NAMETOINDEX_DECL
115 unsigned int if_nametoindex(const char *);
116 #endif
117 
118 #define SOCKLEN_MAX \
119  (0 < (socklen_t)-1 ? \
120  ~(socklen_t)0 : \
121  (((((socklen_t)1) << (sizeof(socklen_t) * CHAR_BIT - 2)) - 1) * 2 + 1))
122 
123 #ifndef RSTRING_SOCKLEN
124 # define RSTRING_SOCKLEN (socklen_t)RSTRING_LENINT
125 #endif
126 
127 #ifndef EWOULDBLOCK
128 # define EWOULDBLOCK EAGAIN
129 #endif
130 
131 /*
132  * workaround for NetBSD, OpenBSD and etc.
133  * The problem is since 4.4BSD-Lite.
134  * FreeBSD fix the problem at FreeBSD 2.2.0.
135  * NetBSD fix the problem at NetBSD 3.0 by kern/29624.
136  * OpenBSD fix the problem at OpenBSD 3.8.
137  */
138 #define pseudo_AF_FTIP pseudo_AF_RTIP
139 
140 #ifndef HAVE_GETADDRINFO
141 # include "addrinfo.h"
142 #endif
143 
144 #include "sockport.h"
145 
146 #ifndef NI_MAXHOST
147 # define NI_MAXHOST 1025
148 #endif
149 #ifndef NI_MAXSERV
150 # define NI_MAXSERV 32
151 #endif
152 
153 #ifdef AF_INET6
154 # define IS_IP_FAMILY(af) ((af) == AF_INET || (af) == AF_INET6)
155 #else
156 # define IS_IP_FAMILY(af) ((af) == AF_INET)
157 #endif
158 
159 #ifndef IN6_IS_ADDR_UNIQUE_LOCAL
160 # define IN6_IS_ADDR_UNIQUE_LOCAL(a) (((a)->s6_addr[0] == 0xfc) || ((a)->s6_addr[0] == 0xfd))
161 #endif
162 
163 #ifndef HAVE_TYPE_STRUCT_SOCKADDR_STORAGE
164 /*
165  * RFC 2553: protocol-independent placeholder for socket addresses
166  */
167 # define _SS_MAXSIZE 128
168 # define _SS_ALIGNSIZE (sizeof(double))
169 # define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(unsigned char) * 2)
170 # define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(unsigned char) * 2 - \
171  _SS_PAD1SIZE - _SS_ALIGNSIZE)
172 
174 # ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
175  unsigned char ss_len; /* address length */
176  unsigned char ss_family; /* address family */
177 # else
178  unsigned short ss_family;
179 # endif
181  double __ss_align; /* force desired structure storage alignment */
183 };
184 #endif
185 
186 typedef union {
187  struct sockaddr addr;
188  struct sockaddr_in in;
189 #ifdef AF_INET6
190  struct sockaddr_in6 in6;
191 #endif
192 #ifdef HAVE_TYPE_STRUCT_SOCKADDR_UN
193  struct sockaddr_un un;
194 #endif
195 #ifdef HAVE_TYPE_STRUCT_SOCKADDR_DL
196  struct sockaddr_dl dl; /* AF_LINK */
197 #endif
198  struct sockaddr_storage storage;
199  char place_holder[2048]; /* sockaddr_storage is not enough for Unix domain sockets on SunOS and Darwin. */
201 
202 #ifdef __APPLE__
203 /*
204  * CMSG_ macros are broken on 64bit darwin, because __DARWIN_ALIGN
205  * aligns up to __darwin_size_t which is 64bit, but CMSG_DATA is
206  * 32bit-aligned.
207  */
208 # undef __DARWIN_ALIGNBYTES
209 # define __DARWIN_ALIGNBYTES (sizeof(unsigned int) - 1)
210 #endif
211 
212 #if defined(_AIX)
213 # ifndef CMSG_SPACE
214 # define CMSG_SPACE(len) (_CMSG_ALIGN(sizeof(struct cmsghdr)) + _CMSG_ALIGN(len))
215 # endif
216 # ifndef CMSG_LEN
217 # define CMSG_LEN(len) (_CMSG_ALIGN(sizeof(struct cmsghdr)) + (len))
218 # endif
219 #endif
220 
221 #define INET_CLIENT 0
222 #define INET_SERVER 1
223 #define INET_SOCKS 2
224 
225 extern int rsock_do_not_reverse_lookup;
226 extern int rsock_cmsg_cloexec_state;
227 #define FMODE_NOREVLOOKUP 0x100
228 
229 /* common socket families only */
230 #define FMODE_UNIX 0x00200000
231 #define FMODE_INET 0x00400000
232 #define FMODE_INET6 0x00800000
233 #define FMODE_SOCK (FMODE_UNIX|FMODE_INET|FMODE_INET6)
234 
235 extern VALUE rb_cBasicSocket;
236 extern VALUE rb_cIPSocket;
237 extern VALUE rb_cTCPSocket;
238 extern VALUE rb_cTCPServer;
239 extern VALUE rb_cUDPSocket;
240 #ifdef HAVE_SYS_UN_H
241 extern VALUE rb_cUNIXSocket;
242 extern VALUE rb_cUNIXServer;
243 #endif
244 extern VALUE rb_cSocket;
245 extern VALUE rb_cAddrinfo;
246 extern VALUE rb_cSockOpt;
247 
248 extern VALUE rb_eSocket;
249 
250 #ifdef SOCKS
251 extern VALUE rb_cSOCKSSocket;
252 # ifdef SOCKS5
253 # include <socks.h>
254 # else
255 void SOCKSinit();
256 int Rconnect();
257 # endif
258 #endif
259 
260 #include "constdefs.h"
261 
262 #define BLOCKING_REGION_FD(func, arg) (long)rb_thread_io_blocking_region((func), (arg), (arg)->fd)
263 
264 #define SockAddrStringValue(v) rsock_sockaddr_string_value(&(v))
265 #define SockAddrStringValuePtr(v) rsock_sockaddr_string_value_ptr(&(v))
266 #define SockAddrStringValueWithAddrinfo(v, rai_ret) rsock_sockaddr_string_value_with_addrinfo(&(v), &(rai_ret))
268 char *rsock_sockaddr_string_value_ptr(volatile VALUE *);
270 
272 
273 NORETURN(void rsock_raise_socket_error(const char *, int));
274 
275 int rsock_family_arg(VALUE domain);
276 int rsock_socktype_arg(VALUE type);
277 int rsock_level_arg(int family, VALUE level);
278 int rsock_optname_arg(int family, int level, VALUE optname);
279 int rsock_cmsg_type_arg(int family, int level, VALUE type);
281 
282 int rsock_getfamily(rb_io_t *fptr);
283 
284 struct rb_addrinfo {
285  struct addrinfo *ai;
287 };
288 int rb_getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct rb_addrinfo **res);
289 void rb_freeaddrinfo(struct rb_addrinfo *ai);
291 int rb_getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags);
292 int rsock_fd_family(int fd);
293 struct rb_addrinfo *rsock_addrinfo(VALUE host, VALUE port, int family, int socktype, int flags);
294 struct rb_addrinfo *rsock_getaddrinfo(VALUE host, VALUE port, struct addrinfo *hints, int socktype_hack);
295 VALUE rsock_fd_socket_addrinfo(int fd, struct sockaddr *addr, socklen_t len);
296 VALUE rsock_io_socket_addrinfo(VALUE io, struct sockaddr *addr, socklen_t len);
297 
298 VALUE rsock_addrinfo_new(struct sockaddr *addr, socklen_t len, int family, int socktype, int protocol, VALUE canonname, VALUE inspectname);
300 
301 VALUE rsock_make_ipaddr(struct sockaddr *addr, socklen_t addrlen);
302 VALUE rsock_ipaddr(struct sockaddr *sockaddr, socklen_t sockaddrlen, int norevlookup);
303 VALUE rsock_make_hostent(VALUE host, struct rb_addrinfo *addr, VALUE (*ipaddr)(struct sockaddr *, socklen_t));
304 VALUE rsock_inspect_sockaddr(struct sockaddr *addr, socklen_t socklen, VALUE ret);
305 socklen_t rsock_sockaddr_len(struct sockaddr *addr);
306 VALUE rsock_sockaddr_obj(struct sockaddr *addr, socklen_t len);
307 
308 int rsock_revlookup_flag(VALUE revlookup, int *norevlookup);
309 
310 #ifdef HAVE_SYS_UN_H
311 VALUE rsock_unixpath_str(struct sockaddr_un *sockaddr, socklen_t len);
312 VALUE rsock_unixaddr(struct sockaddr_un *sockaddr, socklen_t len);
313 socklen_t rsock_unix_sockaddr_len(VALUE path);
314 #endif
315 
316 int rsock_socket(int domain, int type, int proto);
317 int rsock_detect_cloexec(int fd);
318 VALUE rsock_init_sock(VALUE sock, int fd);
320 VALUE rsock_init_inetsock(VALUE sock, VALUE remote_host, VALUE remote_serv, VALUE local_host, VALUE local_serv, int type);
321 VALUE rsock_init_unixsock(VALUE sock, VALUE path, int server);
322 
324  int fd, flags;
326  struct sockaddr *to;
328 };
329 
330 VALUE rsock_sendto_blocking(void *data);
331 VALUE rsock_send_blocking(void *data);
333 
335  RECV_RECV, /* BasicSocket#recv(no from) */
336  RECV_IP, /* IPSocket#recvfrom */
337  RECV_UNIX, /* UNIXSocket#recvfrom */
338  RECV_SOCKET /* Socket#recvfrom */
339 };
340 
342  VALUE ex, enum sock_recv_type from);
343 VALUE rsock_s_recvfrom(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from);
344 
345 int rsock_connect(int fd, const struct sockaddr *sockaddr, int len, int socks);
346 
347 VALUE rsock_s_accept(VALUE klass, int fd, struct sockaddr *sockaddr, socklen_t *len);
349  struct sockaddr *sockaddr, socklen_t *len);
351 
352 VALUE rsock_sockopt_new(int family, int level, int optname, VALUE data);
353 
354 #if defined(HAVE_SENDMSG)
355 VALUE rsock_bsock_sendmsg(VALUE sock, VALUE data, VALUE flags,
356  VALUE dest_sockaddr, VALUE controls);
358  VALUE dest_sockaddr, VALUE controls, VALUE ex);
359 #else
360 #define rsock_bsock_sendmsg rb_f_notimplement
361 #define rsock_bsock_sendmsg_nonblock rb_f_notimplement
362 #endif
363 
364 #if defined(HAVE_RECVMSG)
365 VALUE rsock_bsock_recvmsg(VALUE sock, VALUE dlen, VALUE clen, VALUE flags,
366  VALUE scm_rights);
368  VALUE flags, VALUE scm_rights, VALUE ex);
369 ssize_t rsock_recvmsg(int socket, struct msghdr *message, int flags);
370 #else
371 #define rsock_bsock_recvmsg rb_f_notimplement
372 #define rsock_bsock_recvmsg_nonblock rb_f_notimplement
373 #endif
374 
375 #ifdef HAVE_STRUCT_MSGHDR_MSG_CONTROL
376 void rsock_discard_cmsg_resource(struct msghdr *mh, int msg_peek_p);
377 #endif
378 
379 void rsock_init_basicsocket(void);
380 void rsock_init_ipsocket(void);
381 void rsock_init_tcpsocket(void);
382 void rsock_init_tcpserver(void);
383 void rsock_init_sockssocket(void);
384 void rsock_init_udpsocket(void);
385 void rsock_init_unixsocket(void);
386 void rsock_init_unixserver(void);
387 void rsock_init_socket_constants(void);
388 void rsock_init_ancdata(void);
389 void rsock_init_addrinfo(void);
390 void rsock_init_sockopt(void);
391 void rsock_init_sockifaddr(void);
392 void rsock_init_socket_init(void);
393 
394 NORETURN(void rsock_syserr_fail_host_port(int err, const char *, VALUE, VALUE));
395 NORETURN(void rsock_syserr_fail_path(int err, const char *, VALUE));
396 NORETURN(void rsock_syserr_fail_sockaddr(int err, const char *mesg, struct sockaddr *addr, socklen_t len));
397 NORETURN(void rsock_syserr_fail_raddrinfo(int err, const char *mesg, VALUE rai));
398 NORETURN(void rsock_syserr_fail_raddrinfo_or_sockaddr(int err, const char *mesg, VALUE addr, VALUE rai));
399 
400 NORETURN(void rsock_sys_fail_host_port(const char *, VALUE, VALUE));
401 NORETURN(void rsock_sys_fail_path(const char *, VALUE));
402 NORETURN(void rsock_sys_fail_sockaddr(const char *, struct sockaddr *addr, socklen_t len));
403 NORETURN(void rsock_sys_fail_raddrinfo(const char *, VALUE rai));
404 NORETURN(void rsock_sys_fail_raddrinfo_or_sockaddr(const char *, VALUE addr, VALUE rai));
405 
406 /*
407  * It is safe on Linux to attempt using a socket without waiting on it in
408  * all cases. For some syscalls (e.g. accept/accept4), blocking on the
409  * syscall instead of relying on select/poll allows the kernel to use
410  * "wake-one" behavior and avoid the thundering herd problem.
411  * This is likely safe on all other *nix-like systems, so this whitelist
412  * can be expanded by interested parties.
413  */
414 #if defined(__linux__)
415 static inline int rsock_maybe_fd_writable(int fd) { return 1; }
416 static inline void rsock_maybe_wait_fd(int fd) { }
417 # ifdef MSG_DONTWAIT
418 # define MSG_DONTWAIT_RELIABLE 1
419 # endif
420 #else /* some systems (mswin/mingw) need these. ref: r36946 */
421 # define rsock_maybe_fd_writable(fd) rb_thread_fd_writable((fd))
422 # define rsock_maybe_wait_fd(fd) rb_thread_wait_fd((fd))
423 #endif
424 
425 /*
426  * some OSes may support MSG_DONTWAIT inconsistently depending on socket
427  * type, we only expect Linux to support it consistently for all socket types.
428  */
429 #ifndef MSG_DONTWAIT_RELIABLE
430 # define MSG_DONTWAIT_RELIABLE 0
431 #endif
432 
433 #if !defined HAVE_INET_NTOP && ! defined _WIN32
434 const char *inet_ntop(int, const void *, char *, size_t);
435 #elif defined __MINGW32__
436 # define inet_ntop(f,a,n,l) rb_w32_inet_ntop(f,a,n,l)
437 #elif defined _MSC_VER && RUBY_MSVCRT_VERSION < 90
438 const char *WSAAPI inet_ntop(int, const void *, char *, size_t);
439 #endif
440 
441 #endif
int rsock_optname_arg(int family, int level, VALUE optname)
Definition: constants.c:69
VALUE rsock_init_unixsock(VALUE sock, VALUE path, int server)
void rsock_syserr_fail_raddrinfo_or_sockaddr(int err, const char *mesg, VALUE addr, VALUE rai)
Definition: socket.c:94
VALUE rsock_init_inetsock(VALUE sock, VALUE remote_host, VALUE remote_serv, VALUE local_host, VALUE local_serv, int type)
Definition: ipsocket.c:152
VALUE rsock_addrinfo_inspect_sockaddr(VALUE rai)
Definition: raddrinfo.c:1517
void rsock_init_sockifaddr(void)
Definition: ifaddr.c:460
int rsock_fd_family(int fd)
Definition: raddrinfo.c:534
VALUE rsock_ipaddr(struct sockaddr *sockaddr, socklen_t sockaddrlen, int norevlookup)
Definition: raddrinfo.c:559
socklen_t tolen
Definition: rubysocket.h:327
int rsock_shutdown_how_arg(VALUE how)
Definition: constants.c:131
const char * inet_ntop(int, const void *, char *, size_t)
Definition: option.c:651
void rsock_init_basicsocket(void)
Definition: basicsocket.c:692
VALUE rsock_sockaddr_obj(struct sockaddr *addr, socklen_t len)
int rsock_do_not_reverse_lookup
Definition: init.c:31
int rsock_level_arg(int family, VALUE level)
Definition: constants.c:57
VALUE rsock_sock_listen(VALUE sock, VALUE log)
Definition: socket.c:644
VALUE rsock_bsock_send(int argc, VALUE *argv, VALUE sock)
Definition: basicsocket.c:528
Definition: io.h:62
Definition: win32.h:206
VALUE rb_cSockOpt
Definition: option.c:3
VALUE rsock_send_blocking(void *data)
Definition: init.c:91
VALUE rsock_io_socket_addrinfo(VALUE io, struct sockaddr *addr, socklen_t len)
Definition: raddrinfo.c:2534
void rsock_init_unixsocket(void)
Definition: unixsocket.c:529
#define rsock_maybe_fd_writable(fd)
Definition: rubysocket.h:421
void rsock_init_socket_init(void)
Definition: init.c:662
void rsock_init_tcpserver(void)
Definition: tcpserver.c:106
struct sockaddr * to
Definition: rubysocket.h:326
sock_recv_type
Definition: rubysocket.h:334
#define rsock_bsock_sendmsg
Definition: rubysocket.h:360
char __ss_pad2[_SS_PAD2SIZE]
Definition: rubysocket.h:182
VALUE rb_cTCPServer
Definition: init.c:16
VALUE rb_cUDPSocket
Definition: init.c:17
VALUE rb_cIPSocket
Definition: init.c:14
int rsock_cmsg_cloexec_state
Definition: ancdata.c:5
void rsock_syserr_fail_raddrinfo(int err, const char *mesg, VALUE rai)
Definition: socket.c:77
VALUE rsock_make_ipaddr(struct sockaddr *addr, socklen_t addrlen)
Definition: raddrinfo.c:396
int socklen_t
Definition: rubysocket.h:108
socklen_t rsock_sockaddr_len(struct sockaddr *addr)
void rsock_init_socket_constants(void)
Definition: constants.c:141
void rsock_syserr_fail_host_port(int err, const char *mesg, VALUE host, VALUE port)
Definition: socket.c:24
VALUE rsock_sockaddr_string_value(volatile VALUE *)
Definition: raddrinfo.c:2476
VALUE rsock_make_hostent(VALUE host, struct rb_addrinfo *addr, VALUE(*ipaddr)(struct sockaddr *, socklen_t))
Definition: raddrinfo.c:704
VALUE rsock_sock_s_socketpair(int argc, VALUE *argv, VALUE klass)
void rsock_init_tcpsocket(void)
Definition: tcpsocket.c:68
#define level
#define rsock_bsock_sendmsg_nonblock
Definition: rubysocket.h:361
VALUE rsock_addrinfo_new(struct sockaddr *addr, socklen_t len, int family, int socktype, int protocol, VALUE canonname, VALUE inspectname)
Definition: raddrinfo.c:798
void rsock_init_sockssocket(void)
Definition: sockssocket.c:52
void rsock_syserr_fail_path(int err, const char *mesg, VALUE path)
Definition: socket.c:41
void rsock_init_sockopt(void)
Definition: option.c:1438
#define _SS_PAD2SIZE
Definition: rubysocket.h:170
VALUE rsock_sockaddr_string_value_with_addrinfo(volatile VALUE *v, VALUE *ai_ret)
Definition: raddrinfo.c:2487
int argc
Definition: ruby.c:187
int rsock_detect_cloexec(int fd)
Definition: init.c:284
VALUE rb_eSocket
Definition: init.c:25
#define rsock_bsock_recvmsg_nonblock
Definition: rubysocket.h:372
int err
Definition: win32.c:135
VALUE rsock_s_recvfrom(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from)
Definition: init.c:146
unsigned short ss_family
Definition: rubysocket.h:178
VALUE rb_check_sockaddr_string_type(VALUE)
Definition: raddrinfo.c:2507
VALUE rsock_sockopt_new(int family, int level, int optname, VALUE data)
Definition: option.c:107
NORETURN(void rsock_raise_socket_error(const char *, int))
int socklen_t
Definition: getaddrinfo.c:83
void rsock_syserr_fail_sockaddr(int err, const char *mesg, struct sockaddr *addr, socklen_t len)
Definition: socket.c:61
VALUE rb_cSocket
Definition: init.c:22
VALUE rsock_init_sock(VALUE sock, int fd)
Definition: init.c:60
VALUE rsock_s_accept_nonblock(VALUE klass, VALUE ex, rb_io_t *fptr, struct sockaddr *sockaddr, socklen_t *len)
Definition: init.c:553
void rsock_init_udpsocket(void)
Definition: udpsocket.c:227
void rsock_sys_fail_sockaddr(const char *mesg, struct sockaddr *addr, socklen_t len)
Definition: socket.c:55
void rsock_sys_fail_host_port(const char *mesg, VALUE host, VALUE port)
Definition: socket.c:18
unsigned long VALUE
Definition: ruby.h:85
void rsock_init_ipsocket(void)
Definition: ipsocket.c:364
int rsock_socket(int domain, int type, int proto)
Definition: init.c:357
int rsock_revlookup_flag(VALUE revlookup, int *norevlookup)
Definition: ipsocket.c:172
int rsock_connect(int fd, const struct sockaddr *sockaddr, int len, int socks)
Definition: init.c:454
struct rb_addrinfo * rsock_getaddrinfo(VALUE host, VALUE port, struct addrinfo *hints, int socktype_hack)
Definition: raddrinfo.c:506
VALUE rsock_freeaddrinfo(VALUE arg)
Definition: raddrinfo.c:696
register unsigned int len
Definition: zonetab.h:51
int rsock_getfamily(rb_io_t *fptr)
Definition: init.c:630
void rsock_sys_fail_raddrinfo(const char *mesg, VALUE rai)
Definition: socket.c:71
int rb_getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags)
Definition: raddrinfo.c:363
int rsock_socktype_arg(VALUE type)
Definition: constants.c:50
void rsock_sys_fail_raddrinfo_or_sockaddr(const char *mesg, VALUE addr, VALUE rai)
Definition: socket.c:88
#define proto(p)
Definition: sdbm.h:60
VALUE rb_cBasicSocket
Definition: init.c:13
void rsock_raise_socket_error(const char *reason, int error)
Definition: init.c:35
#define rsock_maybe_wait_fd(fd)
Definition: rubysocket.h:422
struct addrinfo * ai
Definition: rubysocket.h:285
void rsock_init_ancdata(void)
Definition: ancdata.c:1695
VALUE rsock_s_recvfrom_nonblock(VALUE sock, VALUE len, VALUE flg, VALUE str, VALUE ex, enum sock_recv_type from)
Definition: init.c:209
char __ss_pad1[_SS_PAD1SIZE]
Definition: rubysocket.h:180
VALUE rsock_inspect_sockaddr(struct sockaddr *addr, socklen_t socklen, VALUE ret)
Definition: raddrinfo.c:1141
#define _SS_PAD1SIZE
Definition: rubysocket.h:169
VALUE rsock_s_accept(VALUE klass, int fd, struct sockaddr *sockaddr, socklen_t *len)
Definition: init.c:595
void rsock_init_unixserver(void)
Definition: unixserver.c:109
int rsock_family_arg(VALUE domain)
Definition: constants.c:43
void rsock_sys_fail_path(const char *mesg, VALUE path)
Definition: socket.c:35
char * rsock_sockaddr_string_value_ptr(volatile VALUE *)
Definition: raddrinfo.c:2500
#define rsock_bsock_recvmsg
Definition: rubysocket.h:371
struct rb_addrinfo * rsock_addrinfo(VALUE host, VALUE port, int family, int socktype, int flags)
Definition: raddrinfo.c:547
VALUE rb_cAddrinfo
Definition: init.c:23
int rb_getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct rb_addrinfo **res)
Definition: raddrinfo.c:288
void rsock_init_addrinfo(void)
Definition: raddrinfo.c:2560
int allocated_by_malloc
Definition: rubysocket.h:286
VALUE rsock_sendto_blocking(void *data)
Definition: init.c:82
void rb_freeaddrinfo(struct rb_addrinfo *ai)
Definition: raddrinfo.c:322
int rsock_cmsg_type_arg(int family, int level, VALUE type)
Definition: constants.c:100
char ** argv
Definition: ruby.c:188
VALUE rsock_fd_socket_addrinfo(int fd, struct sockaddr *addr, socklen_t len)
Definition: raddrinfo.c:2515
VALUE rb_cTCPSocket
Definition: init.c:15