Ruby 2.0.0p247(2013-06-27revision41674)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

Macros | Functions | Variables
option.c File Reference
`#include "rubysocket.h"`
Include dependency graph for option.c:

Go to the source code of this file.

## Macros
#define | IFNAMSIZ (sizeof(unsigned int)*3+1)

## Functions
static VALUE | constant_to_sym (int constant, ID(*intern_const)(int))
static VALUE | optname_to_sym (int level, int optname)
static VALUE | sockopt_initialize (VALUE self, VALUE vfamily, VALUE vlevel, VALUE voptname, VALUE data)
VALUE | rsock_sockopt_new (int family, int level, int optname, VALUE data)
static VALUE | sockopt_family_m (VALUE self)
static int | sockopt_level (VALUE self)
static VALUE | sockopt_level_m (VALUE self)
static int | sockopt_optname (VALUE self)
static VALUE | sockopt_optname_m (VALUE self)
static VALUE | sockopt_data (VALUE self)
static VALUE | sockopt_s_int (VALUE klass, VALUE vfamily, VALUE vlevel, VALUE voptname, VALUE vint)
static VALUE | sockopt_int (VALUE self)
static VALUE | sockopt_s_bool (VALUE klass, VALUE vfamily, VALUE vlevel, VALUE voptname, VALUE vbool)
static VALUE | sockopt_bool (VALUE self)
static VALUE | sockopt_s_linger (VALUE klass, VALUE vonoff, VALUE vsecs)
static VALUE | sockopt_linger (VALUE self)
static int | inspect_int (int level, int optname, VALUE data, VALUE ret)
static int | inspect_errno (int level, int optname, VALUE data, VALUE ret)
static int | inspect_timeval_as_interval (int level, int optname, VALUE data, VALUE ret)
static const char * | inet_ntop (int af, const void *addr, char *numaddr, size_t numaddr_len)
static int | rb_if_indextoname (const char *succ_prefix, const char *fail_prefix, unsigned int ifindex, char *buf, size_t len)
static VALUE | sockopt_inspect (VALUE self)
static VALUE | sockopt_unpack (VALUE self, VALUE template)
void | rsock_init_sockopt (void)

## Variables
VALUE | rb_cSockOpt

## Macro Definition Documentation

#define IFNAMSIZ (sizeof(unsigned int)*3+1)

Referenced by init_constants(), and rb_if_indextoname().

## Function Documentation

static VALUE constant_to_sym | ( | int | constant,
|  | ID(*)(int) | intern_const
| ) |  |
| static

Definition at line 6 of file option.c.

References ID2SYM, INT2NUM, and name.

Referenced by optname_to_sym().

static const char* inet_ntop | ( | int | af,
|  | const void * | addr,
|  | char * | numaddr,
|  | size_t | numaddr_len
| ) |  |
| static

Definition at line 440 of file option.c.

References snprintf.

static int inspect_errno | ( | int | level,
|  | int | optname,
|  | VALUE | data,
|  | VALUE | ret
| ) |  |
| static

Definition at line 311 of file option.c.

References err, i, rb_str_catf(), RSTRING_LEN, RSTRING_PTR, and strerror().

Referenced by sockopt_inspect().

static int inspect_int | ( | int | level,
|  | int | optname,
|  | VALUE | data,
|  | VALUE | ret
| ) |  |
| static

Definition at line 297 of file option.c.

References i, rb_str_catf(), RSTRING_LEN, and RSTRING_PTR.

Referenced by sockopt_inspect().

static int inspect_timeval_as_interval | ( | int | level,
|  | int | optname,
|  | VALUE | data,
|  | VALUE | ret
| ) |  |
| static

Definition at line 385 of file option.c.

References rb_str_catf(), RSTRING_LEN, RSTRING_PTR, timeval::tv_sec, and timeval::tv_usec.

Referenced by sockopt_inspect().

static VALUE optname_to_sym | ( | int | level,
|  | int | optname
| ) |  |
| static

Definition at line 17 of file option.c.

References constant_to_sym(), INT2NUM, IPPROTO_IP, IPPROTO_TCP, IPPROTO_UDP, rsock_intern_ip_optname(), rsock_intern_ipv6_optname(), rsock_intern_so_optname(), rsock_intern_tcp_optname(), and rsock_intern_udp_optname().

Referenced by sockopt_inspect().

static int rb_if_indextoname | ( | const char * | succ_prefix,
|  | const char * | fail_prefix,
|  | unsigned int | ifindex,
|  | char * | buf,
|  | size_t | len
| ) |  |
| static

Definition at line 460 of file option.c.

References IFNAMSIZ, NULL, and snprintf.

void rsock_init_sockopt | ( | void | ) |  |

Definition at line 893 of file option.c.

References rb_cObject, rb_cSocket, rb_cSockOpt, rb_define_class_under(), rb_define_method(), rb_define_singleton_method(), sockopt_bool(), sockopt_data(), sockopt_family_m(), sockopt_initialize(), sockopt_inspect(), sockopt_int(), sockopt_level_m(), sockopt_linger(), sockopt_optname_m(), sockopt_s_bool(), sockopt_s_int(), sockopt_s_linger(), and sockopt_unpack().

Referenced by rsock_init_socket_init().

VALUE rsock_sockopt_new | ( | int | family,
|  | int | level,
|  | int | optname,
|  | VALUE | data
| ) |  |

Definition at line 62 of file option.c.

References INT2NUM, NEWOBJ_OF, rb_cSockOpt, sockopt_initialize(), StringValue, and T_OBJECT.

Referenced by bsock_getsockopt(), sockopt_s_bool(), sockopt_s_int(), and sockopt_s_linger().

static VALUE sockopt_bool | ( | VALUE | self) |  |
| static

Definition at line 223 of file option.c.

References i, Qfalse, Qtrue, rb_eTypeError, rb_raise(), RSTRING_LEN, RSTRING_PTR, sockopt_data(), and StringValue.

Referenced by rsock_init_sockopt().

static VALUE sockopt_data | ( | VALUE | self) |  |
| static

Definition at line 137 of file option.c.

References rb_attr_get(), rb_intern, StringValue, and v.

Referenced by rsock_init_sockopt(), sockopt_bool(), sockopt_inspect(), sockopt_int(), sockopt_linger(), and sockopt_unpack().

static VALUE sockopt_family_m | ( | VALUE | self) |  |
| static

Definition at line 80 of file option.c.

References rb_attr_get(), and rb_intern.

Referenced by rsock_init_sockopt(), and sockopt_inspect().

static VALUE sockopt_initialize | ( | VALUE | self,
|  | VALUE | vfamily,
|  | VALUE | vlevel,
|  | VALUE | voptname,
|  | VALUE | data
| ) |  |
| static

Definition at line 48 of file option.c.

References INT2NUM, level, rb_intern, rb_ivar_set(), rsock_family_arg(), rsock_level_arg(), rsock_optname_arg(), and StringValue.

Referenced by rsock_init_sockopt(), and rsock_sockopt_new().

static VALUE sockopt_inspect | ( | VALUE | self) |  |
| static

Definition at line 667 of file option.c.

References AF_UNSPEC, inspect_errno(), inspect_int(), inspect_timeval_as_interval(), IPPROTO_IP, IPPROTO_TCP, IS_IP_FAMILY, NUM2INT, optname_to_sym(), rb_id2name(), rb_obj_classname(), rb_sprintf(), rb_str_append(), rb_str_cat2(), rb_str_catf(), rb_str_dump(), rsock_intern_family_noprefix(), rsock_intern_iplevel(), rsock_intern_local_optname(), rsock_intern_so_optname(), sockopt_data(), sockopt_family_m(), sockopt_level_m(), sockopt_optname_m(), StringValue, SYM2ID, SYMBOL_P, and v.

Referenced by rsock_init_sockopt().

static VALUE sockopt_int | ( | VALUE | self) |  |
| static

Definition at line 177 of file option.c.

References i, INT2NUM, rb_eTypeError, rb_raise(), RSTRING_LEN, RSTRING_PTR, sockopt_data(), and StringValue.

Referenced by rsock_init_sockopt().

static int sockopt_level | ( | VALUE | self) |  |
| static

Definition at line 86 of file option.c.

References NUM2INT, rb_attr_get(), and rb_intern.

Referenced by sockopt_level_m(), and sockopt_linger().

static VALUE sockopt_level_m | ( | VALUE | self) |  |
| static

Definition at line 101 of file option.c.

References INT2NUM, and sockopt_level().

Referenced by rsock_init_sockopt(), and sockopt_inspect().

static VALUE sockopt_linger | ( | VALUE | self) |  |
| static

Definition at line 273 of file option.c.

References INT2NUM, level, Qfalse, Qtrue, rb_assoc_new(), rb_eTypeError, rb_raise(), RSTRING_LEN, RSTRING_PTR, sockopt_data(), sockopt_level(), and sockopt_optname().

Referenced by rsock_init_sockopt().

static int sockopt_optname | ( | VALUE | self) |  |
| static

Definition at line 107 of file option.c.

References NUM2INT, rb_attr_get(), and rb_intern.

Referenced by sockopt_linger(), and sockopt_optname_m().

static VALUE sockopt_optname_m | ( | VALUE | self) |  |
| static

Definition at line 122 of file option.c.

References INT2NUM, and sockopt_optname().

Referenced by rsock_init_sockopt(), and sockopt_inspect().

static VALUE sockopt_s_bool | ( | VALUE | klass,
|  | VALUE | vfamily,
|  | VALUE | vlevel,
|  | VALUE | voptname,
|  | VALUE | vbool
| ) |  |
| static

Definition at line 204 of file option.c.

References i, level, rb_str_new(), rsock_family_arg(), rsock_level_arg(), rsock_optname_arg(), rsock_sockopt_new(), and RTEST.

Referenced by rsock_init_sockopt().

static VALUE sockopt_s_int | ( | VALUE | klass,
|  | VALUE | vfamily,
|  | VALUE | vlevel,
|  | VALUE | voptname,
|  | VALUE | vint
| ) |  |
| static

Definition at line 156 of file option.c.

References i, level, NUM2INT, rb_str_new(), rsock_family_arg(), rsock_level_arg(), rsock_optname_arg(), and rsock_sockopt_new().

Referenced by rsock_init_sockopt().

static VALUE sockopt_s_linger | ( | VALUE | klass,
|  | VALUE | vonoff,
|  | VALUE | vsecs
| ) |  |
| static

Definition at line 250 of file option.c.

References AF_UNSPEC, NIL_P, NUM2INT, rb_check_to_integer(), rb_str_new(), rsock_sockopt_new(), and RTEST.

Referenced by rsock_init_sockopt().

static VALUE sockopt_unpack | ( | VALUE | self,
|  | VALUE | template
| ) |  |
| static

Definition at line 887 of file option.c.

References rb_funcall(), rb_intern, and sockopt_data().

Referenced by rsock_init_sockopt().

## Variable Documentation

VALUE rb_cSockOpt

Definition at line 3 of file option.c.

Referenced by rsock_init_sockopt(), and rsock_sockopt_new().