raddrinfo.c File Reference
`#include "rubysocket.h"`

Go to the source code of this file.

## Data Structures

struct | getaddrinfo_arg
struct | getnameinfo_arg
struct | hostent_arg
struct | rb_addrinfo_t

## Macros

#define | addrinfo_free RUBY_TYPED_DEFAULT_FREE
#define | IS_ADDRINFO(obj) rb_typeddata_is_kind_of((obj), &addrinfo_type)

## Functions

static int | str_is_number (const char *)
static VALUE | nogvl_getaddrinfo (void *arg)
int | rb_getaddrinfo (const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res)
static VALUE | nogvl_getnameinfo (void *arg)
int | rb_getnameinfo (const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags)
static void | make_ipaddr0 (struct sockaddr *addr, char *buf, size_t len)
VALUE | rsock_make_ipaddr (struct sockaddr *addr)
static void | make_inetaddr (unsigned int host, char *buf, size_t len)
static char * | host_str (VALUE host, char *hbuf, size_t len, int *flags_ptr)
static char * | port_str (VALUE port, char *pbuf, size_t len, int *flags_ptr)
struct addrinfo * | rsock_getaddrinfo (VALUE host, VALUE port, struct addrinfo *hints, int socktype_hack)
struct addrinfo * | rsock_addrinfo (VALUE host, VALUE port, int socktype, int flags)
VALUE | rsock_ipaddr (struct sockaddr *sockaddr, int norevlookup)
static VALUE | make_hostent_internal (struct hostent_arg *arg)
VALUE | rsock_freeaddrinfo (struct addrinfo *addr)
VALUE | rsock_make_hostent (VALUE host, struct addrinfo *addr, VALUE(*ipaddr)(struct sockaddr *, size_t))
static void | addrinfo_mark (void *ptr)
static size_t | addrinfo_memsize (const void *ptr)
static VALUE | addrinfo_s_allocate (VALUE klass)
static rb_addrinfo_t * | check_addrinfo (VALUE self)
static rb_addrinfo_t * | get_addrinfo (VALUE self)
static rb_addrinfo_t * | alloc_addrinfo ()
static void | init_addrinfo (rb_addrinfo_t *rai, struct sockaddr *sa, socklen_t len, int pfamily, int socktype, int protocol, VALUE canonname, VALUE inspectname)
VALUE | rsock_addrinfo_new (struct sockaddr *addr, socklen_t len, int family, int socktype, int protocol, VALUE canonname, VALUE inspectname)
static struct addrinfo * | call_getaddrinfo (VALUE node, VALUE service, VALUE family, VALUE socktype, VALUE protocol, VALUE flags, int socktype_hack)
static VALUE | make_inspectname (VALUE node, VALUE service, struct addrinfo *res)
static void | init_addrinfo_getaddrinfo (rb_addrinfo_t *rai, VALUE node, VALUE service, VALUE family, VALUE socktype, VALUE protocol, VALUE flags, VALUE inspectnode, VALUE inspectservice)
static VALUE | addrinfo_firstonly_new (VALUE node, VALUE service, VALUE family, VALUE socktype, VALUE protocol, VALUE flags)
static VALUE | addrinfo_list_new (VALUE node, VALUE service, VALUE family, VALUE socktype, VALUE protocol, VALUE flags)
static VALUE | addrinfo_initialize (int argc, VALUE *argv, VALUE self)
static int | get_afamily (struct sockaddr *addr, socklen_t len)
static int | ai_get_afamily (rb_addrinfo_t *rai)
static VALUE | inspect_sockaddr (VALUE addrinfo, VALUE ret)
static VALUE | addrinfo_inspect (VALUE self)
static VALUE | addrinfo_inspect_sockaddr (VALUE self)
static VALUE | addrinfo_mdump (VALUE self)
static VALUE | addrinfo_mload (VALUE self, VALUE ary)
static VALUE | addrinfo_afamily (VALUE self)
static VALUE | addrinfo_pfamily (VALUE self)
static VALUE | addrinfo_socktype (VALUE self)
static VALUE | addrinfo_protocol (VALUE self)
static VALUE | addrinfo_to_sockaddr (VALUE self)
static VALUE | addrinfo_canonname (VALUE self)
static VALUE | addrinfo_ip_p (VALUE self)
static VALUE | addrinfo_ipv4_p (VALUE self)
static VALUE | addrinfo_ipv6_p (VALUE self)
static VALUE | addrinfo_unix_p (VALUE self)
static VALUE | addrinfo_getnameinfo (int argc, VALUE *argv, VALUE self)
static VALUE | addrinfo_ip_unpack (VALUE self)
static VALUE | addrinfo_ip_address (VALUE self)
static VALUE | addrinfo_ip_port (VALUE self)
static int | extract_in_addr (VALUE self, uint32_t *addrp)
static VALUE | addrinfo_ipv4_private_p (VALUE self)
static VALUE | addrinfo_ipv4_loopback_p (VALUE self)
static VALUE | addrinfo_ipv4_multicast_p (VALUE self)
static VALUE | addrinfo_s_getaddrinfo (int argc, VALUE *argv, VALUE self)
static VALUE | addrinfo_s_ip (VALUE self, VALUE host)
static VALUE | addrinfo_s_tcp (VALUE self, VALUE host, VALUE port)
static VALUE | addrinfo_s_udp (VALUE self, VALUE host, VALUE port)
VALUE | rsock_sockaddr_string_value (volatile VALUE *v)
char * | rsock_sockaddr_string_value_ptr (volatile VALUE *v)
VALUE | rb_check_sockaddr_string_type (VALUE val)
VALUE | rsock_fd_socket_addrinfo (int fd, struct sockaddr *addr, socklen_t len)
VALUE | rsock_io_socket_addrinfo (VALUE io, struct sockaddr *addr, socklen_t len)
void | rsock_init_addrinfo (void)

## Variables

static const rb_data_type_t | addrinfo_type

## Macro Definition Documentation

#define addrinfo_free RUBY_TYPED_DEFAULT_FREE

Definition at line 529 of file raddrinfo.c.

#define IS_ADDRINFO | ( |  | obj | ) | rb_typeddata_is_kind_of((obj), &addrinfo_type)

Definition at line 548 of file raddrinfo.c.

Referenced by rb_check_sockaddr_string_type(), and rsock_sockaddr_string_value().

## Function Documentation

static VALUE addrinfo_afamily | ( | VALUE | self | ) |

static

Definition at line 1349 of file raddrinfo.c.

References ai_get_afamily(), get_addrinfo(), and INT2NUM().

Referenced by rsock_init_addrinfo().

static VALUE addrinfo_canonname | ( | VALUE | self | ) |

static

Definition at line 1440 of file raddrinfo.c.

References rb_addrinfo_t::canonname, and get_addrinfo().

Referenced by rsock_init_addrinfo().

static VALUE addrinfo_firstonly_new | ( | VALUE | node,
|  | VALUE | service,
|  | VALUE | family,
|  | VALUE | socktype,
|  | VALUE | protocol,
|  | VALUE | flags
| ) |  |

static

Definition at line 704 of file raddrinfo.c.

References addrinfo::ai_addr, addrinfo::ai_addrlen, addrinfo::ai_canonname, addrinfo::ai_family, addrinfo::ai_protocol, addrinfo::ai_socktype, call_getaddrinfo(), freeaddrinfo(), make_inspectname(), OBJ_FREEZE, Qnil, rb_tainted_str_new_cstr(), and rsock_addrinfo_new().

Referenced by addrinfo_s_ip(), addrinfo_s_tcp(), and addrinfo_s_udp().

static VALUE addrinfo_getnameinfo | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |

static

Definition at line 1547 of file raddrinfo.c.

References rb_addrinfo_t::addr, get_addrinfo(), getnameinfo(), NI_DGRAM, NIL_P, NUM2INT, rb_assoc_new(), rb_scan_args(), rb_str_new2(), rsock_raise_socket_error(), rb_addrinfo_t::sockaddr_len, and rb_addrinfo_t::socktype.

Referenced by addrinfo_ip_address(), addrinfo_ip_unpack(), and rsock_init_addrinfo().

static VALUE addrinfo_initialize | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |

static

Definition at line 830 of file raddrinfo.c.

References AI_NUMERICHOST, AI_NUMERICSERV, alloc_addrinfo(), check_addrinfo(), DATA_PTR, init_addrinfo(), init_addrinfo_getaddrinfo(), INT2NUM(), NIL_P, NUM2INT, PF_UNSPEC, Qnil, rb_ary_entry(), rb_check_array_type(), rb_eSocket, rb_eTypeError, rb_raise(), rb_scan_args(), rsock_family_arg(), rsock_socktype_arg(), RSTRING_LEN, RSTRING_LENINT, RSTRING_PTR, StringValue, and StringValueCStr.

Referenced by rsock_init_addrinfo().

static VALUE addrinfo_inspect | ( | VALUE | self | ) |

static

Definition at line 1068 of file raddrinfo.c.

References ai_get_afamily(), rb_addrinfo_t::canonname, get_addrinfo(), inspect_sockaddr(), rb_addrinfo_t::inspectname, name, NIL_P, PF_INET, rb_addrinfo_t::pfamily, rb_addrinfo_t::protocol, rb_id2name(), rb_obj_classname(), rb_sprintf(), rb_str_buf_cat2(), rb_str_cat2(), rb_str_catf(), rb_addrinfo_t::socktype, and StringValueCStr.

Referenced by rsock_init_addrinfo().

static VALUE addrinfo_inspect_sockaddr | ( | VALUE | self | ) |

static

Definition at line 1148 of file raddrinfo.c.

References inspect_sockaddr(), and rb_str_new().

Referenced by rsock_init_addrinfo().

static VALUE addrinfo_ip_address | ( | VALUE | self | ) |

static

Definition at line 1608 of file raddrinfo.c.

References addrinfo_getnameinfo(), ai_get_afamily(), get_addrinfo(), INT2NUM(), IS_IP_FAMILY, NI_NUMERICHOST, NI_NUMERICSERV, rb_ary_entry(), rb_eSocket, and rb_raise().

Referenced by rsock_init_addrinfo().

static VALUE addrinfo_ip_p | ( | VALUE | self | ) |

static

Definition at line 1459 of file raddrinfo.c.

References ai_get_afamily(), get_addrinfo(), IS_IP_FAMILY, Qfalse, and Qtrue.

Referenced by rsock_init_addrinfo().

static VALUE addrinfo_ip_port | ( | VALUE | self | ) |

static

Definition at line 1633 of file raddrinfo.c.

References rb_addrinfo_t::addr, ai_get_afamily(), get_addrinfo(), INT2NUM(), IS_IP_FAMILY, rb_eSocket, rb_raise(), and rb_addrinfo_t::sockaddr_len.

Referenced by rsock_init_addrinfo().

static VALUE addrinfo_ip_unpack | ( | VALUE | self | ) |

static

Definition at line 1581 of file raddrinfo.c.

References addrinfo_getnameinfo(), ai_get_afamily(), get_addrinfo(), INT2NUM(), IS_IP_FAMILY, NI_NUMERICHOST, NI_NUMERICSERV, rb_ary_entry(), rb_ary_store(), rb_eSocket, rb_raise(), and StringValueCStr.

Referenced by rsock_init_addrinfo().

static VALUE addrinfo_ipv4_loopback_p | ( | VALUE | self | ) |

static

Definition at line 1701 of file raddrinfo.c.

References extract_in_addr(), Qfalse, and Qtrue.

Referenced by rsock_init_addrinfo().

static VALUE addrinfo_ipv4_multicast_p | ( | VALUE | self | ) |

static

Definition at line 1715 of file raddrinfo.c.

References extract_in_addr(), Qfalse, and Qtrue.

Referenced by rsock_init_addrinfo().

static VALUE addrinfo_ipv4_p | ( | VALUE | self | ) |

static

Definition at line 1479 of file raddrinfo.c.

References ai_get_afamily(), get_addrinfo(), Qfalse, and Qtrue.

Referenced by rsock_init_addrinfo().

static VALUE addrinfo_ipv4_private_p | ( | VALUE | self | ) |

static

Definition at line 1685 of file raddrinfo.c.

References extract_in_addr(), Qfalse, and Qtrue.

Referenced by rsock_init_addrinfo().

static VALUE addrinfo_ipv6_p | ( | VALUE | self | ) |

static

Definition at line 1498 of file raddrinfo.c.

References ai_get_afamily(), get_addrinfo(), Qfalse, and Qtrue.

Referenced by rsock_init_addrinfo().

static VALUE addrinfo_list_new | ( | VALUE | node,
|  | VALUE | service,
|  | VALUE | family,
|  | VALUE | socktype,
|  | VALUE | protocol,
|  | VALUE | flags
| ) |  |

static

Definition at line 729 of file raddrinfo.c.

References addrinfo::ai_addr, addrinfo::ai_addrlen, addrinfo::ai_canonname, addrinfo::ai_family, addrinfo::ai_next, addrinfo::ai_protocol, addrinfo::ai_socktype, call_getaddrinfo(), freeaddrinfo(), make_inspectname(), OBJ_FREEZE, Qnil, rb_ary_new(), rb_ary_push(), rb_tainted_str_new_cstr(), and rsock_addrinfo_new().

Referenced by addrinfo_s_getaddrinfo().

static void addrinfo_mark | ( | void * | ptr | ) |

static

Definition at line 520 of file raddrinfo.c.

References rb_addrinfo_t::canonname, rb_addrinfo_t::inspectname, and rb_gc_mark().

static VALUE addrinfo_mdump | ( | VALUE | self | ) |

static

Definition at line 1155 of file raddrinfo.c.

References rb_addrinfo_t::addr, ai_get_afamily(), rb_addrinfo_t::canonname, get_addrinfo(), getnameinfo(), id, rb_addrinfo_t::inspectname, INT2FIX, IS_IP_FAMILY, NI_MAXHOST, NI_MAXSERV, NI_NUMERICHOST, NI_NUMERICSERV, rb_addrinfo_t::pfamily, rb_addrinfo_t::protocol, rb_ary_new3(), rb_assoc_new(), rb_eSocket, rb_id2str(), rb_raise(), rb_str_new(), rb_str_new_cstr(), rsock_raise_socket_error(), rb_addrinfo_t::sockaddr_len, and rb_addrinfo_t::socktype.

Referenced by rsock_init_addrinfo().

static size_t addrinfo_memsize | ( | const void * | ptr | ) |

static

Definition at line 532 of file raddrinfo.c.

static VALUE addrinfo_mload | ( | VALUE | self,
|  | VALUE | ary
| ) |  |

static

Definition at line 1232 of file raddrinfo.c.

References addrinfo::ai_addr, addrinfo::ai_addrlen, AI_NUMERICHOST, AI_NUMERICSERV, alloc_addrinfo(), call_getaddrinfo(), check_addrinfo(), DATA_PTR, init_addrinfo(), INT2FIX, INT2NUM(), IS_IP_FAMILY, len, NIL_P, Qnil, rb_ary_entry(), rb_convert_type(), rb_eSocket, rb_eTypeError, rb_raise(), RSTRING_LEN, RSTRING_PTR, StringValue, T_ARRAY, and v.

Referenced by rsock_init_addrinfo().

static VALUE addrinfo_pfamily | ( | VALUE | self | ) |

static

Definition at line 1365 of file raddrinfo.c.

References get_addrinfo(), INT2NUM(), and rb_addrinfo_t::pfamily.

Referenced by rsock_init_addrinfo().

static VALUE addrinfo_protocol | ( | VALUE | self | ) |

static

Definition at line 1397 of file raddrinfo.c.

References get_addrinfo(), INT2NUM(), and rb_addrinfo_t::protocol.

Referenced by rsock_init_addrinfo().

static VALUE addrinfo_s_allocate | ( | VALUE | klass | ) |

static

Definition at line 543 of file raddrinfo.c.

References TypedData_Wrap_Struct.

Referenced by rsock_addrinfo_new(), and rsock_init_addrinfo().

static VALUE addrinfo_s_getaddrinfo | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |

static

Definition at line 1983 of file raddrinfo.c.

References addrinfo_list_new(), and rb_scan_args().

Referenced by rsock_init_addrinfo().

static VALUE addrinfo_s_ip | ( | VALUE | self,
|  | VALUE | host
| ) |  |

static

Definition at line 2003 of file raddrinfo.c.

References addrinfo_firstonly_new(), get_addrinfo(), INT2FIX, INT2NUM(), PF_UNSPEC, rb_addrinfo_t::protocol, Qnil, and rb_addrinfo_t::socktype.

Referenced by rsock_init_addrinfo().

static VALUE addrinfo_s_tcp | ( | VALUE | self,
|  | VALUE | host,
|  | VALUE | port
| ) |  |

static

Definition at line 2024 of file raddrinfo.c.

References addrinfo_firstonly_new(), INT2FIX, INT2NUM(), and PF_UNSPEC.

Referenced by rsock_init_addrinfo().

static VALUE addrinfo_s_udp | ( | VALUE | self,
|  | VALUE | host,
|  | VALUE | port
| ) |  |

static

Definition at line 2039 of file raddrinfo.c.

References addrinfo_firstonly_new(), INT2FIX, INT2NUM(), and PF_UNSPEC.

Referenced by rsock_init_addrinfo().

static VALUE addrinfo_socktype | ( | VALUE | self | ) |

static

Definition at line 1381 of file raddrinfo.c.

References get_addrinfo(), INT2NUM(), and rb_addrinfo_t::socktype.

Referenced by rsock_init_addrinfo().

static VALUE addrinfo_to_sockaddr | ( | VALUE | self | ) |

static

Definition at line 1415 of file raddrinfo.c.

References rb_addrinfo_t::addr, get_addrinfo(), OBJ_INFECT, rb_str_new(), and rb_addrinfo_t::sockaddr_len.

Referenced by rb_check_sockaddr_string_type(), rsock_init_addrinfo(), and rsock_sockaddr_string_value().

static VALUE addrinfo_unix_p | ( | VALUE | self | ) |

static

Definition at line 1521 of file raddrinfo.c.

References ai_get_afamily(), get_addrinfo(), Qfalse, and Qtrue.

Referenced by rsock_init_addrinfo().

static int ai_get_afamily | ( | rb_addrinfo_t * | rai | ) |

static

Definition at line 919 of file raddrinfo.c.

References rb_addrinfo_t::addr, get_afamily(), and rb_addrinfo_t::sockaddr_len.

Referenced by addrinfo_afamily(), addrinfo_inspect(), addrinfo_ip_address(), addrinfo_ip_p(), addrinfo_ip_port(), addrinfo_ip_unpack(), addrinfo_ipv4_p(), addrinfo_ipv6_p(), addrinfo_mdump(), addrinfo_unix_p(), and extract_in_addr().

static rb_addrinfo_t* alloc_addrinfo | ( |  | ) |

static

Definition at line 568 of file raddrinfo.c.

References ALLOC, rb_addrinfo_t::canonname, rb_addrinfo_t::inspectname, and Qnil.

Referenced by addrinfo_initialize(), addrinfo_mload(), and rsock_addrinfo_new().

static struct addrinfo* call_getaddrinfo | ( | VALUE | node,
|  | VALUE | service,
|  | VALUE | family,
|  | VALUE | socktype,
|  | VALUE | protocol,
|  | VALUE | flags,
|  | int | socktype_hack
| ) |  |

static read

Definition at line 609 of file raddrinfo.c.

References addrinfo::ai_family, addrinfo::ai_flags, addrinfo::ai_protocol, addrinfo::ai_socktype, MEMZERO, NIL_P, NULL, NUM2INT, PF_UNSPEC, rb_eSocket, rb_raise(), rsock_family_arg(), rsock_getaddrinfo(), and rsock_socktype_arg().

Referenced by addrinfo_firstonly_new(), addrinfo_list_new(), addrinfo_mload(), and init_addrinfo_getaddrinfo().

static rb_addrinfo_t* check_addrinfo | ( | VALUE | self | ) |

inline static

Definition at line 550 of file raddrinfo.c.

References rb_check_typeddata().

Referenced by addrinfo_initialize(), addrinfo_mload(), and get_addrinfo().

static int extract_in_addr | ( | VALUE | self,
|  | uint32_t * | addrp
| ) |  |

static

Definition at line 1671 of file raddrinfo.c.

References rb_addrinfo_t::addr, ai_get_afamily(), and get_addrinfo().

Referenced by addrinfo_ipv4_loopback_p(), addrinfo_ipv4_multicast_p(), and addrinfo_ipv4_private_p().

static rb_addrinfo_t* get_addrinfo | ( | VALUE | self | ) |

static

Definition at line 556 of file raddrinfo.c.

References check_addrinfo(), rb_eTypeError, and rb_raise().

Referenced by addrinfo_afamily(), addrinfo_canonname(), addrinfo_getnameinfo(), addrinfo_inspect(), addrinfo_ip_address(), addrinfo_ip_p(), addrinfo_ip_port(), addrinfo_ip_unpack(), addrinfo_ipv4_p(), addrinfo_ipv6_p(), addrinfo_mdump(), addrinfo_pfamily(), addrinfo_protocol(), addrinfo_s_ip(), addrinfo_socktype(), addrinfo_to_sockaddr(), addrinfo_unix_p(), extract_in_addr(), and inspect_sockaddr().

static int get_afamily | ( | struct sockaddr * | addr,
|  | socklen_t | len
| ) |  |

static

Definition at line 910 of file raddrinfo.c.

References AF_UNSPEC.

Referenced by ai_get_afamily(), and rsock_fd_socket_addrinfo().

static char* host_str | ( | VALUE | host,
|  | char * | hbuf,
|  | size_t | len,
|  | int * | flags_ptr
| ) |  |

static

Definition at line 279 of file raddrinfo.c.

References AI_NUMERICHOST, make_inetaddr(), name, NIL_P, NULL, NUM2UINT, PRIuSIZE, rb_cInteger, rb_eArgError, rb_obj_is_kind_of(), rb_raise(), RSTRING_PTR, SafeStringValue, and strlen().

Referenced by make_hostent_internal(), and rsock_getaddrinfo().

static void init_addrinfo | ( | rb_addrinfo_t * | rai,
|  | struct sockaddr * | sa,
|  | socklen_t | len,
|  | int | pfamily,
|  | int | socktype,
|  | int | protocol,
|  | VALUE | canonname,
|  | VALUE | inspectname
| ) |  |

static

Definition at line 578 of file raddrinfo.c.

References rb_addrinfo_t::addr, rb_addrinfo_t::canonname, rb_addrinfo_t::inspectname, len, rb_addrinfo_t::pfamily, rb_addrinfo_t::protocol, rb_eArgError, rb_raise(), rb_addrinfo_t::sockaddr_len, and rb_addrinfo_t::socktype.

Referenced by addrinfo_initialize(), addrinfo_mload(), init_addrinfo_getaddrinfo(), and rsock_addrinfo_new().

static void init_addrinfo_getaddrinfo | ( | rb_addrinfo_t * | rai,
|  | VALUE | node,
|  | VALUE | service,
|  | VALUE | family,
|  | VALUE | socktype,
|  | VALUE | protocol,
|  | VALUE | flags,
|  | VALUE | inspectnode,
|  | VALUE | inspectservice
| ) |  |

static

Definition at line 637 of file raddrinfo.c.

References addrinfo::ai_addr, addrinfo::ai_addrlen, addrinfo::ai_canonname, call_getaddrinfo(), freeaddrinfo(), init_addrinfo(), make_inspectname(), NUM2INT, OBJ_FREEZE, Qnil, rb_str_equal(), and rb_tainted_str_new_cstr().

Referenced by addrinfo_initialize().

static VALUE inspect_sockaddr | ( | VALUE | addrinfo,
|  | VALUE | ret
| ) |  |

static

Definition at line 925 of file raddrinfo.c.

References rb_addrinfo_t::addr, get_addrinfo(), getnameinfo(), ISPRINT, ISSPACE, NI_NUMERICHOST, NI_NUMERICSERV, NULL, p, rb_id2name(), rb_str_cat2(), rb_str_catf(), rsock_raise_socket_error(), rb_addrinfo_t::sockaddr_len, and sockaddr_storage::ss_family.

Referenced by addrinfo_inspect(), and addrinfo_inspect_sockaddr().

static VALUE make_hostent_internal | ( | struct hostent_arg * | arg | ) |

static

Definition at line 448 of file raddrinfo.c.

References hostent_arg::addr, addrinfo::ai_canonname, addrinfo::ai_family, addrinfo::ai_next, hostent_arg::host, host_str(), INT2NUM(), hostent_arg::ipaddr, names, NI_MAXHOST, NULL, rb_ary_new(), rb_ary_new2(), rb_ary_push(), and rb_str_new2().

Referenced by rsock_make_hostent().

static void make_inetaddr | ( | unsigned int | host,
|  | char * | buf,
|  | size_t | len
| ) |  |

static

Definition at line 252 of file raddrinfo.c.

References make_ipaddr0(), MEMZERO, and SET_SIN_LEN.

Referenced by host_str().

static VALUE make_inspectname | ( | VALUE | node,
|  | VALUE | service,
|  | struct addrinfo * | res
| ) |  |

static

Definition at line 659 of file raddrinfo.c.

References addrinfo::ai_addr, addrinfo::ai_addrlen, FIX2INT, NI_MAXHOST, NI_MAXSERV, NI_NUMERICHOST, NI_NUMERICSERV, NIL_P, OBJ_FREEZE, OBJ_INFECT, Qnil, rb_getnameinfo(), rb_sprintf(), rb_str_catf(), rb_str_dup(), RSTRING_PTR, StringValueCStr, T_FIXNUM, T_STRING, and TYPE.

Referenced by addrinfo_firstonly_new(), addrinfo_list_new(), and init_addrinfo_getaddrinfo().

static void make_ipaddr0 | ( | struct sockaddr * | addr,
|  | char * | buf,
|  | size_t | len
| ) |  |

static

Definition at line 232 of file raddrinfo.c.

References NI_NUMERICHOST, NULL, rb_getnameinfo(), rsock_raise_socket_error(), and SA_LEN.

Referenced by make_inetaddr(), and rsock_make_ipaddr().

static VALUE nogvl_getaddrinfo | ( | void * | arg | ) |

static

Definition at line 158 of file raddrinfo.c.

References arg, getaddrinfo(), getaddrinfo_arg::hints, getaddrinfo_arg::node, getaddrinfo_arg::res, and getaddrinfo_arg::service.

Referenced by rb_getaddrinfo().

static VALUE nogvl_getnameinfo | ( | void * | arg | ) |

static

Definition at line 199 of file raddrinfo.c.

References arg, getnameinfo_arg::flags, getnameinfo(), getnameinfo_arg::host, getnameinfo_arg::hostlen, getnameinfo_arg::sa, getnameinfo_arg::salen, getnameinfo_arg::serv, and getnameinfo_arg::servlen.

Referenced by rb_getnameinfo().

static char* port_str | ( | VALUE | port,
|  | char * | pbuf,
|  | size_t | len,
|  | int * | flags_ptr
| ) |  |

static

Definition at line 316 of file raddrinfo.c.

References AI_NUMERICSERV, FIX2LONG, FIXNUM_P, NIL_P, PRIuSIZE, rb_eArgError, rb_raise(), RSTRING_PTR, SafeStringValue, snprintf, and strlen().

Referenced by rsock_getaddrinfo().

VALUE rb_check_sockaddr_string_type | ( | VALUE | val | ) |

Definition at line 2101 of file raddrinfo.c.

References addrinfo_to_sockaddr(), IS_ADDRINFO, and rb_check_string_type().

Referenced by sock_s_getnameinfo().

int rb_getaddrinfo | ( | const char * | node,
|  | const char * | service,
|  | const struct addrinfo * | hints,
|  | struct addrinfo ** | res
| ) |  |

Definition at line 167 of file raddrinfo.c.

References BLOCKING_REGION, getaddrinfo(), getaddrinfo_arg::hints, MEMZERO, getaddrinfo_arg::node, nogvl_getaddrinfo(), getaddrinfo_arg::res, and getaddrinfo_arg::service.

Referenced by rsock_getaddrinfo(), and sock_s_getnameinfo().

int rb_getnameinfo | ( | const struct sockaddr * | sa,
|  | socklen_t | salen,
|  | char * | host,
|  | size_t | hostlen,
|  | char * | serv,
|  | size_t | servlen,
|  | int | flags
| ) |  |

Definition at line 210 of file raddrinfo.c.

References BLOCKING_REGION, getnameinfo_arg::flags, getnameinfo(), getnameinfo_arg::host, getnameinfo_arg::hostlen, nogvl_getnameinfo(), getnameinfo_arg::sa, getnameinfo_arg::salen, getnameinfo_arg::serv, and getnameinfo_arg::servlen.

Referenced by make_inspectname(), make_ipaddr0(), rsock_ipaddr(), and sock_s_getnameinfo().

struct addrinfo* rsock_addrinfo | ( | VALUE | host,
|  | VALUE | port,
|  | int | socktype,
|  | int | flags
| ) |  |

read

Definition at line 371 of file raddrinfo.c.

References AF_UNSPEC, addrinfo::ai_family, addrinfo::ai_flags, addrinfo::ai_socktype, MEMZERO, and rsock_getaddrinfo().

Referenced by init_inetsock_internal(), ip_s_getaddress(), sock_s_gethostbyname(), sock_s_pack_sockaddr_in(), tcp_s_gethostbyname(), udp_bind(), udp_connect(), and udp_send().

VALUE rsock_addrinfo_new | ( | struct sockaddr * | addr,
|  | socklen_t | len,
|  | int | family,
|  | int | socktype,
|  | int | protocol,
|  | VALUE | canonname,
|  | VALUE | inspectname
| ) |  |

Definition at line 595 of file raddrinfo.c.

References addrinfo_s_allocate(), alloc_addrinfo(), DATA_PTR, init_addrinfo(), and rb_cAddrinfo.

Referenced by addrinfo_firstonly_new(), addrinfo_list_new(), and rsock_fd_socket_addrinfo().

VALUE rsock_fd_socket_addrinfo | ( | int | fd,
|  | struct sockaddr * | addr,
|  | socklen_t | len
| ) |  |

Definition at line 2109 of file raddrinfo.c.

References get_afamily(), Qnil, rb_sys_fail(), and rsock_addrinfo_new().

Referenced by bsock_local_address(), bsock_remote_address(), and rsock_io_socket_addrinfo().

VALUE rsock_freeaddrinfo | ( | struct addrinfo * | addr | ) |

Definition at line 491 of file raddrinfo.c.

References freeaddrinfo(), and Qnil.

Referenced by rsock_make_hostent(), and udp_connect().

struct addrinfo* rsock_getaddrinfo | ( | VALUE | host,
|  | VALUE | port,
|  | struct addrinfo * | hints,
|  | int | socktype_hack
| ) |  |

read

Definition at line 343 of file raddrinfo.c.

References addrinfo::ai_flags, addrinfo::ai_socktype, host_str(), NI_MAXHOST, NI_MAXSERV, NULL, port_str(), rb_eSocket, rb_getaddrinfo(), rb_raise(), rsock_raise_socket_error(), str_is_number(), and strlen().

Referenced by call_getaddrinfo(), rsock_addrinfo(), and sock_s_getaddrinfo().

void rsock_init_addrinfo | ( | void |  | ) |

Definition at line 2152 of file raddrinfo.c.

References addrinfo_afamily(), addrinfo_canonname(), addrinfo_getnameinfo(), addrinfo_initialize(), addrinfo_inspect(), addrinfo_inspect_sockaddr(), addrinfo_ip_address(), addrinfo_ip_p(), addrinfo_ip_port(), addrinfo_ip_unpack(), addrinfo_ipv4_loopback_p(), addrinfo_ipv4_multicast_p(), addrinfo_ipv4_p(), addrinfo_ipv4_private_p(), addrinfo_ipv6_p(), addrinfo_mdump(), addrinfo_mload(), addrinfo_pfamily(), addrinfo_protocol(), addrinfo_s_allocate(), addrinfo_s_getaddrinfo(), addrinfo_s_ip(), addrinfo_s_tcp(), addrinfo_s_udp(), addrinfo_socktype(), addrinfo_to_sockaddr(), addrinfo_unix_p(), rb_cAddrinfo, rb_cData, rb_define_alloc_func(), rb_define_class(), rb_define_method(), and rb_define_singleton_method().

Referenced by rsock_init_socket_init().

VALUE rsock_io_socket_addrinfo | ( | VALUE | io,
|  | struct sockaddr * | addr,
|  | socklen_t | len
| ) |  |

Definition at line 2128 of file raddrinfo.c.

References rb_io_t::fd, FIX2INT, GetOpenFile, NUM2INT, rb_eTypeError, rb_raise(), rsock_fd_socket_addrinfo(), T_BIGNUM, T_FILE, T_FIXNUM, and TYPE.

Referenced by rsock_s_recvfrom(), rsock_s_recvfrom_nonblock(), sock_accept(), sock_accept_nonblock(), and sock_sysaccept().

VALUE rsock_ipaddr | ( | struct sockaddr * | sockaddr,
|  | int | norevlookup
| ) |  |

Definition at line 383 of file raddrinfo.c.

References id, INT2FIX, NI_NUMERICHOST, NI_NUMERICSERV, NULL, Qnil, rb_ary_new3(), rb_getnameinfo(), rb_id2str(), rb_str_dup(), rb_str_new2(), rsock_raise_socket_error(), and SA_LEN.

Referenced by ip_addr(), ip_peeraddr(), make_addrinfo(), rsock_s_recvfrom(), and rsock_s_recvfrom_nonblock().

VALUE rsock_make_hostent | ( | VALUE | host,
|  | struct addrinfo * | addr,
|  | VALUE(*)(struct sockaddr *, size_t) | ipaddr
| ) |  |

Definition at line 498 of file raddrinfo.c.

References hostent_arg::addr, hostent_arg::host, hostent_arg::ipaddr, make_hostent_internal(), rb_ensure(), and rsock_freeaddrinfo().

Referenced by sock_s_gethostbyname(), and tcp_s_gethostbyname().

VALUE rsock_make_ipaddr | ( | struct sockaddr * | addr | ) |

Definition at line 243 of file raddrinfo.c.

References make_ipaddr0(), and rb_str_new2().

Referenced by ip_s_getaddress(), sock_s_unpack_sockaddr_in(), and tcp_sockaddr().

VALUE rsock_sockaddr_string_value | ( | volatile VALUE * | v | ) |

Definition at line 2083 of file raddrinfo.c.

References addrinfo_to_sockaddr(), IS_ADDRINFO, StringValue, and v.

Referenced by rsock_sockaddr_string_value_ptr().

char* rsock_sockaddr_string_value_ptr | ( | volatile VALUE * | v | ) |

Definition at line 2094 of file raddrinfo.c.

References rsock_sockaddr_string_value(), and RSTRING_PTR.

static int str_is_number | ( | const char * | p | ) |

static

Definition at line 264 of file raddrinfo.c.

References NULL, and STRTOUL.

Referenced by rsock_getaddrinfo().

## Variable Documentation

const rb_data_type_t addrinfo_type

static

Initial value:
= {
"socket/addrinfo",
{addrinfo_mark, addrinfo_free, addrinfo_memsize,},
}

Definition at line 537 of file raddrinfo.c.