Ruby 2.7.0p0(2019-12-25revision647ee6f091eafcce70ffb75ddf7e121e192ab217)

Data Structures | Macros | Functions
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 | str_equal(ptr, len, name)
#define | addrinfo_free RUBY_TYPED_DEFAULT_FREE
#define | IS_ADDRINFO(obj) rb_typeddata_is_kind_of((obj), &addrinfo_type)

## Functions
int | rb_getaddrinfo (const char *node, const char *service, const struct addrinfo *hints, struct rb_addrinfo **res)
void | rb_freeaddrinfo (struct rb_addrinfo *ai)
int | rb_getnameinfo (const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags)
VALUE | rsock_make_ipaddr (struct sockaddr *addr, socklen_t addrlen)
struct rb_addrinfo * | rsock_getaddrinfo (VALUE host, VALUE port, struct addrinfo *hints, int socktype_hack)
int | rsock_fd_family (int fd)
struct rb_addrinfo * | rsock_addrinfo (VALUE host, VALUE port, int family, int socktype, int flags)
VALUE | rsock_ipaddr (struct sockaddr *sockaddr, socklen_t sockaddrlen, int norevlookup)
VALUE | rsock_freeaddrinfo (VALUE arg)
VALUE | rsock_make_hostent (VALUE host, struct rb_addrinfo *addr, VALUE(*ipaddr)(struct sockaddr *, socklen_t))
VALUE | rsock_addrinfo_new (struct sockaddr *addr, socklen_t len, int family, int socktype, int protocol, VALUE canonname, VALUE inspectname)
VALUE | rsock_inspect_sockaddr (struct sockaddr *sockaddr_arg, socklen_t socklen, VALUE ret)
VALUE | rsock_addrinfo_inspect_sockaddr (VALUE self)
VALUE | rsock_sockaddr_string_value (volatile VALUE *v)
VALUE | rsock_sockaddr_string_value_with_addrinfo (volatile VALUE *v, VALUE *rai_ret)
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)

## Macro Definition Documentation

## ◆ addrinfo_free

#define addrinfo_free RUBY_TYPED_DEFAULT_FREE

Definition at line 845 of file raddrinfo.c.

## ◆ IS_ADDRINFO

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

Definition at line 864 of file raddrinfo.c.

## ◆ str_equal

#define str_equal | ( |  | ptr,
|  |  | len,
|  |  | name
| ) |  |

Value:
((ptr)[0] == name[0] && \
rb_strlen_lit(name) == (len) && memcmp(ptr, name, len) == 0)

Definition at line 503 of file raddrinfo.c.

## Function Documentation

## ◆ rb_check_sockaddr_string_type()

VALUE rb_check_sockaddr_string_type | ( | VALUE | val | ) |

Definition at line 2628 of file raddrinfo.c.

References IS_ADDRINFO.

## ◆ rb_freeaddrinfo()

void rb_freeaddrinfo | ( | struct rb_addrinfo * | ai | ) |

Definition at line 396 of file raddrinfo.c.

References rb_addrinfo::ai, addrinfo::ai_addr, addrinfo::ai_next, freeaddrinfo(), and xfree.

Referenced by rsock_freeaddrinfo().

## ◆ rb_getaddrinfo()

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

Definition at line 309 of file raddrinfo.c.

## ◆ rb_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 437 of file raddrinfo.c.

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

Referenced by rsock_ipaddr().

## ◆ rsock_addrinfo()

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

Definition at line 653 of file raddrinfo.c.

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

## ◆ rsock_addrinfo_inspect_sockaddr()

VALUE rsock_addrinfo_inspect_sockaddr | ( | VALUE | self | ) |

Definition at line 1641 of file raddrinfo.c.

Referenced by rsock_syserr_fail_raddrinfo().

## ◆ rsock_addrinfo_new()

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

Definition at line 910 of file raddrinfo.c.

Referenced by rsock_syserr_fail_sockaddr().

## ◆ rsock_fd_family()

int rsock_fd_family | ( | int | fd | ) |

Definition at line 640 of file raddrinfo.c.

References AF_UNSPEC, and offsetof.

## ◆ rsock_fd_socket_addrinfo()

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

Definition at line 2636 of file raddrinfo.c.

Referenced by rsock_io_socket_addrinfo().

## ◆ rsock_freeaddrinfo()

VALUE rsock_freeaddrinfo | ( | VALUE | arg | ) |

Definition at line 808 of file raddrinfo.c.

References arg, Qnil, and rb_freeaddrinfo().

## ◆ rsock_getaddrinfo()

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

Definition at line 576 of file raddrinfo.c.

References error, NI_MAXHOST, NI_MAXSERV, and NULL.

Referenced by rsock_addrinfo().

## ◆ rsock_init_addrinfo()

void rsock_init_addrinfo | ( | void |  | ) |

Definition at line 2681 of file raddrinfo.c.

Referenced by rsock_init_socket_init().

## ◆ rsock_inspect_sockaddr()

VALUE rsock_inspect_sockaddr | ( | struct sockaddr * | sockaddr_arg,
|  | socklen_t | socklen,
|  | VALUE | ret
| ) |  |

Definition at line 1266 of file raddrinfo.c.

References union_sockaddr::addr, AF_UNSPEC, buf, error, getnameinfo(), i, IFNAMSIZ, int, ISPRINT, ISSPACE, len, NI_NUMERICHOST, NI_NUMERICSERV, NULL, offsetof, rb_id2name(), rb_str_cat(), rb_str_cat2, rb_str_catf(), rsock_intern_family(), and rsock_raise_socket_error().

## ◆ rsock_io_socket_addrinfo()

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

Definition at line 2655 of file raddrinfo.c.

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

## ◆ rsock_ipaddr()

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

Definition at line 665 of file raddrinfo.c.

References atoi(), error, id, INT2FIX, NI_NUMERICHOST, NI_NUMERICSERV, NULL, Qnil, rb_ary_new3, rb_getnameinfo(), rb_id2str, rb_str_dup(), rb_str_new2, rsock_intern_family(), rsock_raise_socket_error(), and sprintf().

## ◆ rsock_make_hostent()

VALUE rsock_make_hostent | ( | VALUE | host,
|  | struct rb_addrinfo * | addr,
|  | VALUE(*)(struct sockaddr *, socklen_t) | ipaddr
| ) |  |

Definition at line 816 of file raddrinfo.c.

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

## ◆ rsock_make_ipaddr()

VALUE rsock_make_ipaddr | ( | struct sockaddr * | addr,
|  | socklen_t | addrlen
| ) |  |

Definition at line 470 of file raddrinfo.c.

## ◆ rsock_sockaddr_string_value()

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

Definition at line 2597 of file raddrinfo.c.

References IS_ADDRINFO, and v.

Referenced by rsock_sockaddr_string_value_ptr().

## ◆ rsock_sockaddr_string_value_ptr()

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

Definition at line 2621 of file raddrinfo.c.

References rsock_sockaddr_string_value(), RSTRING_PTR, and v.

## ◆ rsock_sockaddr_string_value_with_addrinfo()

VALUE rsock_sockaddr_string_value_with_addrinfo | ( | volatile VALUE * | v,
|  | VALUE * | rai_ret
| ) |  |

Definition at line 2608 of file raddrinfo.c.

References IS_ADDRINFO, Qnil, and v.

ptr
struct RIMemo * ptr
Definition: debug.c:74
memcmp
int memcmp(const void *s1, const void *s2, size_t len)
Definition: memcmp.c:7
len
uint8_t len
Definition: escape.c:17
rb_strlen_lit
#define rb_strlen_lit(str)
Definition: intern.h:913
name
const char * name
Definition: nkf.c:208