5 #define pack_var(v) rb_str_new((const char *)&(v), sizeof(v)) 8 #define XCAT(x,y) CAT(x,y) 10 #if defined(__linux__) || \ 12 defined(__FreeBSD__) || \ 13 defined(__DragonFly__) || \ 14 defined(__APPLE__) || \ 17 # define TYPE_IP_MULTICAST_LOOP int 18 # define TYPE_IP_MULTICAST_TTL int 25 # define TYPE_IP_MULTICAST_LOOP byte 26 # define TYPE_IP_MULTICAST_TTL byte 27 # define USE_INSPECT_BYTE 1 30 #define check_size(len, size) \ 33 rb_raise(rb_eTypeError, "size differ. expected as "#size"=%d but %ld", \ 34 (int)size, (long)(len))) 37 sockopt_pack_byte(
VALUE value)
44 sockopt_pack_int(
VALUE value)
51 constant_to_sym(
int constant,
ID (*intern_const)(
int))
53 ID name = intern_const(constant);
62 optname_to_sym(
int level,
int optname)
125 sockopt_family_m(
VALUE self)
131 sockopt_level(
VALUE self)
146 sockopt_level_m(
VALUE self)
148 return INT2NUM(sockopt_level(
self));
152 sockopt_optname(
VALUE self)
167 sockopt_optname_m(
VALUE self)
169 return INT2NUM(sockopt_optname(
self));
183 sockopt_data(
VALUE self)
218 sockopt_byte(
VALUE self)
220 VALUE data = sockopt_data(
self);
258 sockopt_int(
VALUE self)
261 VALUE data = sockopt_data(
self);
290 int i =
RTEST(vbool) ? 1 : 0;
304 sockopt_bool(
VALUE self)
308 VALUE data = sockopt_data(
self);
338 memset(&l, 0,
sizeof(l));
342 l.l_onoff =
RTEST(vonoff) ? 1 : 0;
357 sockopt_linger(
VALUE self)
359 int level = sockopt_level(
self);
360 int optname = sockopt_optname(
self);
361 VALUE data = sockopt_data(
self);
365 if (level != SOL_SOCKET || optname != SO_LINGER)
368 memcpy((
char*)&l,
RSTRING_PTR(data),
sizeof(
struct linger));
370 case 0: vonoff =
Qfalse;
break;
371 case 1: vonoff =
Qtrue;
break;
372 default: vonoff =
INT2NUM(l.l_onoff);
break;
394 sockopt_s_ipv4_multicast_loop(
VALUE klass,
VALUE value)
397 #if defined(IPPROTO_IP) && defined(IP_MULTICAST_LOOP) 401 # error IPPROTO_IP or IP_MULTICAST_LOOP is not implemented 415 sockopt_ipv4_multicast_loop(
VALUE self)
417 int family =
NUM2INT(sockopt_family_m(
self));
418 int level = sockopt_level(
self);
419 int optname = sockopt_optname(
self);
421 #if defined(IPPROTO_IP) && defined(IP_MULTICAST_LOOP) 422 if (family == AF_INET && level ==
IPPROTO_IP && optname == IP_MULTICAST_LOOP) {
430 #define inspect_ipv4_multicast_loop(a,b,c,d) \ 431 XCAT(inspect_,TYPE_IP_MULTICAST_LOOP)(a,b,c,d) 446 sockopt_s_ipv4_multicast_ttl(
VALUE klass,
VALUE value)
448 #if defined(IPPROTO_IP) && defined(IP_MULTICAST_TTL) 452 # error IPPROTO_IP or IP_MULTICAST_TTL is not implemented 466 sockopt_ipv4_multicast_ttl(
VALUE self)
468 int family =
NUM2INT(sockopt_family_m(
self));
469 int level = sockopt_level(
self);
470 int optname = sockopt_optname(
self);
472 #if defined(IPPROTO_IP) && defined(IP_MULTICAST_TTL) 473 if (family == AF_INET && level ==
IPPROTO_IP && optname == IP_MULTICAST_TTL) {
481 #define inspect_ipv4_multicast_ttl(a,b,c,d) \ 482 XCAT(inspect_,TYPE_IP_MULTICAST_TTL)(a,b,c,d) 498 #ifdef USE_INSPECT_BYTE 528 #if defined(IPV6_MULTICAST_LOOP) 534 memcpy((
char*)&i,
RSTRING_PTR(data),
sizeof(
unsigned int));
544 #if defined(SOL_SOCKET) && defined(SO_LINGER) 554 default:
rb_str_catf(ret,
" on(%d)", s.l_onoff);
break;
565 #if defined(SOL_SOCKET) && defined(SO_TYPE) 587 inspect_timeval_as_interval(
int level,
int optname,
VALUE data,
VALUE ret)
592 rb_str_catf(ret,
" %ld.%06ldsec", (
long)s.tv_sec, (
long)s.tv_usec);
649 #if !defined HAVE_INET_NTOP && ! defined _WIN32 651 inet_ntop(
int af,
const void *addr,
char *numaddr,
size_t numaddr_len)
653 #ifdef HAVE_INET_NTOA 655 memcpy(&in.s_addr, addr,
sizeof(in.s_addr));
656 snprintf(numaddr, numaddr_len,
"%s", inet_ntoa(in));
658 unsigned long x = ntohl(*(
unsigned long*)addr);
659 snprintf(numaddr, numaddr_len,
"%d.%d.%d.%d",
660 (
int) (x>>24) & 0xff, (
int) (x>>16) & 0xff,
661 (
int) (x>> 8) & 0xff, (
int) (x>> 0) & 0xff);
669 rb_if_indextoname(
const char *succ_prefix,
const char *fail_prefix,
unsigned int ifindex,
char *
buf,
size_t len)
671 #if defined(HAVE_IF_INDEXTONAME) 673 if (if_indextoname(ifindex, ifbuf) ==
NULL)
674 return snprintf(
buf, len,
"%s%u", fail_prefix, ifindex);
676 return snprintf(
buf, len,
"%s%s", succ_prefix, ifbuf);
679 # define IFNAMSIZ (sizeof(unsigned int)*3+1) 681 return snprintf(
buf, len,
"%s%u", fail_prefix, ifindex);
685 #if defined(IPPROTO_IP) && defined(HAVE_TYPE_STRUCT_IP_MREQ) 709 #if defined(IPPROTO_IP) && defined(HAVE_TYPE_STRUCT_IP_MREQN) 713 if (
RSTRING_LEN(data) ==
sizeof(
struct ip_mreqn)) {
725 rb_if_indextoname(
" ",
" ifindex:", s.imr_ifindex, ifbuf,
sizeof(ifbuf));
735 #if defined(IPPROTO_IP) && defined(HAVE_TYPE_STRUCT_IP_MREQ) 737 inspect_ipv4_add_drop_membership(
int level,
int optname,
VALUE data,
VALUE ret)
740 return inspect_ipv4_mreq(
level, optname, data, ret);
741 # if defined(HAVE_TYPE_STRUCT_IP_MREQN) 742 else if (
RSTRING_LEN(data) ==
sizeof(
struct ip_mreqn))
743 return inspect_ipv4_mreqn(
level, optname, data, ret);
750 #if defined(IPPROTO_IP) && defined(IP_MULTICAST_IF) && defined(HAVE_TYPE_STRUCT_IP_MREQN) 752 inspect_ipv4_multicast_if(
int level,
int optname,
VALUE data,
VALUE ret)
764 else if (
RSTRING_LEN(data) ==
sizeof(
struct ip_mreqn)) {
765 return inspect_ipv4_mreqn(
level, optname, data, ret);
773 #if defined(IPV6_MULTICAST_IF) 775 inspect_ipv6_multicast_if(
int level,
int optname,
VALUE data,
VALUE ret)
779 unsigned int ifindex;
780 memcpy((
char*)&ifindex,
RSTRING_PTR(data),
sizeof(
unsigned int));
781 rb_if_indextoname(
" ",
" ", ifindex, ifbuf,
sizeof(ifbuf));
791 #if defined(IPPROTO_IPV6) && defined(HAVE_TYPE_STRUCT_IPV6_MREQ) 795 if (
RSTRING_LEN(data) ==
sizeof(
struct ipv6_mreq)) {
803 rb_if_indextoname(
" ",
" interface:", s.ipv6mr_interface, ifbuf,
sizeof(ifbuf));
813 #if defined(IPPROTO_TCP) && defined(TCP_INFO) && defined(HAVE_TYPE_STRUCT_TCP_INFO) 816 # ifndef HAVE_CONST_TCP_ESTABLISHED 817 # define TCP_ESTABLISHED TCPS_ESTABLISHED 819 # ifndef HAVE_CONST_TCP_SYN_SENT 820 # define TCP_SYN_SENT TCPS_SYN_SENT 822 # ifndef HAVE_CONST_TCP_SYN_RECV 823 # define TCP_SYN_RECV TCPS_SYN_RECEIVED 825 # ifndef HAVE_CONST_TCP_FIN_WAIT1 826 # define TCP_FIN_WAIT1 TCPS_FIN_WAIT_1 828 # ifndef HAVE_CONST_TCP_FIN_WAIT2 829 # define TCP_FIN_WAIT2 TCPS_FIN_WAIT_2 831 # ifndef HAVE_CONST_TCP_TIME_WAIT 832 # define TCP_TIME_WAIT TCPS_TIME_WAIT 834 # ifndef HAVE_CONST_TCP_CLOSE 835 # define TCP_CLOSE TCPS_CLOSED 837 # ifndef HAVE_CONST_TCP_CLOSE_WAIT 838 # define TCP_CLOSE_WAIT TCPS_CLOSE_WAIT 840 # ifndef HAVE_CONST_TCP_LAST_ACK 841 # define TCP_LAST_ACK TCPS_LAST_ACK 843 # ifndef HAVE_CONST_TCP_LISTEN 844 # define TCP_LISTEN TCPS_LISTEN 846 # ifndef HAVE_CONST_TCP_CLOSING 847 # define TCP_CLOSING TCPS_CLOSING 851 #if defined(HAVE_CONST_TCP_ESTABLISHED) && !defined(TCP_ESTABLISHED) 852 # define TCP_ESTABLISHED TCP_ESTABLISHED 854 #if defined(HAVE_CONST_TCP_SYN_SENT) && !defined(TCP_SYN_SENT) 855 # define TCP_SYN_SENT TCP_SYN_SENT 857 #if defined(HAVE_CONST_TCP_SYN_RECV) && !defined(TCP_SYN_RECV) 858 # define TCP_SYN_RECV TCP_SYN_RECV 860 #if defined(HAVE_CONST_TCP_FIN_WAIT1) && !defined(TCP_FIN_WAIT1) 861 # define TCP_FIN_WAIT1 TCP_FIN_WAIT1 863 #if defined(HAVE_CONST_TCP_FIN_WAIT2) && !defined(TCP_FIN_WAIT2) 864 # define TCP_FIN_WAIT2 TCP_FIN_WAIT2 866 #if defined(HAVE_CONST_TCP_TIME_WAIT) && !defined(TCP_TIME_WAIT) 867 # define TCP_TIME_WAIT TCP_TIME_WAIT 869 #if defined(HAVE_CONST_TCP_CLOSE) && !defined(TCP_CLOSE) 870 # define TCP_CLOSE TCP_CLOSE 872 #if defined(HAVE_CONST_TCP_CLOSE_WAIT) && !defined(TCP_CLOSE_WAIT) 873 # define TCP_CLOSE_WAIT TCP_CLOSE_WAIT 875 #if defined(HAVE_CONST_TCP_LAST_ACK) && !defined(TCP_LAST_ACK) 876 # define TCP_LAST_ACK TCP_LAST_ACK 878 #if defined(HAVE_CONST_TCP_LISTEN) && !defined(TCP_LISTEN) 879 # define TCP_LISTEN TCP_LISTEN 881 #if defined(HAVE_CONST_TCP_CLOSING) && !defined(TCP_CLOSING) 882 # define TCP_CLOSING TCP_CLOSING 891 #define INSPECT_TCPI_OPTION(optval, name) \ 892 if (options & (optval)) { \ 893 options &= ~(uint8_t)(optval); \ 894 rb_str_catf(ret, "%c%s", sep, name); \ 897 #ifdef TCPI_OPT_TIMESTAMPS 898 INSPECT_TCPI_OPTION(TCPI_OPT_TIMESTAMPS,
"TIMESTAMPS");
901 INSPECT_TCPI_OPTION(TCPI_OPT_SACK,
"SACK");
903 #ifdef TCPI_OPT_WSCALE 904 INSPECT_TCPI_OPTION(TCPI_OPT_WSCALE,
"WSCALE");
907 INSPECT_TCPI_OPTION(TCPI_OPT_ECN,
"ECN");
909 #ifdef TCPI_OPT_ECN_SEEN 910 INSPECT_TCPI_OPTION(TCPI_OPT_ECN_SEEN,
"ECN_SEEN");
912 #ifdef TCPI_OPT_SYN_DATA 913 INSPECT_TCPI_OPTION(TCPI_OPT_SYN_DATA,
"SYN_DATA");
916 INSPECT_TCPI_OPTION(TCPI_OPT_TOE,
"TOE");
918 #undef INSPECT_TCPI_OPTION 920 if (options || sep ==
'=') {
928 rb_str_catf(ret,
"%s%u.%06us", prefix, t / 1000000, t % 1000000);
931 #if !defined __FreeBSD__ && ( \ 932 defined HAVE_STRUCT_TCP_INFO_TCPI_LAST_DATA_SENT || \ 933 defined HAVE_STRUCT_TCP_INFO_TCPI_LAST_DATA_RECV || \ 934 defined HAVE_STRUCT_TCP_INFO_TCPI_LAST_ACK_SENT || \ 935 defined HAVE_STRUCT_TCP_INFO_TCPI_LAST_ACK_RECV || \ 940 rb_str_catf(ret,
"%s%u.%03us", prefix, t / 1000, t % 1000);
945 # define inspect_tcpi_rto(ret, t) inspect_tcpi_usec(ret, " rto=", t) 946 # define inspect_tcpi_last_data_recv(ret, t) inspect_tcpi_usec(ret, " last_data_recv=", t) 947 # define inspect_tcpi_rtt(ret, t) inspect_tcpi_usec(ret, " rtt=", t) 948 # define inspect_tcpi_rttvar(ret, t) inspect_tcpi_usec(ret, " rttvar=", t) 950 # define inspect_tcpi_rto(ret, t) inspect_tcpi_usec(ret, " rto=", t) 951 # define inspect_tcpi_ato(ret, t) inspect_tcpi_usec(ret, " ato=", t) 952 # define inspect_tcpi_last_data_sent(ret, t) inspect_tcpi_msec(ret, " last_data_sent=", t) 953 # define inspect_tcpi_last_data_recv(ret, t) inspect_tcpi_msec(ret, " last_data_recv=", t) 954 # define inspect_tcpi_last_ack_sent(ret, t) inspect_tcpi_msec(ret, " last_ack_sent=", t) 955 # define inspect_tcpi_last_ack_recv(ret, t) inspect_tcpi_msec(ret, " last_ack_recv=", t) 956 # define inspect_tcpi_rtt(ret, t) inspect_tcpi_usec(ret, " rtt=", t) 957 # define inspect_tcpi_rttvar(ret, t) inspect_tcpi_usec(ret, " rttvar=", t) 958 # define inspect_tcpi_rcv_rtt(ret, t) inspect_tcpi_usec(ret, " rcv_rtt=", t) 965 if (
sizeof(
struct tcp_info) <= actual_size) {
968 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_STATE 969 switch (s.tcpi_state) {
970 # ifdef TCP_ESTABLISHED 971 case TCP_ESTABLISHED:
rb_str_cat_cstr(ret,
" state=ESTABLISHED");
break;
979 # ifdef TCP_FIN_WAIT1 982 # ifdef TCP_FIN_WAIT2 985 # ifdef TCP_TIME_WAIT 991 # ifdef TCP_CLOSE_WAIT 1003 default:
rb_str_catf(ret,
" state=%u", s.tcpi_state);
break;
1006 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_CA_STATE 1007 switch (s.tcpi_ca_state) {
1009 case TCP_CA_Disorder:
rb_str_cat_cstr(ret,
" ca_state=Disorder");
break;
1011 case TCP_CA_Recovery:
rb_str_cat_cstr(ret,
" ca_state=Recovery");
break;
1013 default:
rb_str_catf(ret,
" ca_state=%u", s.tcpi_ca_state);
break;
1016 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_RETRANSMITS 1017 rb_str_catf(ret,
" retransmits=%u", s.tcpi_retransmits);
1019 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_PROBES 1022 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_BACKOFF 1025 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_OPTIONS 1026 inspect_tcpi_options(ret, s.tcpi_options);
1028 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_SND_WSCALE 1029 rb_str_catf(ret,
" snd_wscale=%u", s.tcpi_snd_wscale);
1031 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_RCV_WSCALE 1032 rb_str_catf(ret,
" rcv_wscale=%u", s.tcpi_rcv_wscale);
1034 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_RTO 1035 inspect_tcpi_rto(ret, s.tcpi_rto);
1037 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_ATO 1038 inspect_tcpi_ato(ret, s.tcpi_ato);
1040 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_SND_MSS 1043 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_RCV_MSS 1046 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_UNACKED 1049 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_SACKED 1052 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_LOST 1055 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_RETRANS 1058 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_FACKETS 1061 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_LAST_DATA_SENT 1062 inspect_tcpi_last_data_sent(ret, s.tcpi_last_data_sent);
1064 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_LAST_ACK_SENT 1065 inspect_tcpi_last_ack_sent(ret, s.tcpi_last_ack_sent);
1067 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_LAST_DATA_RECV 1068 inspect_tcpi_last_data_recv(ret, s.tcpi_last_data_recv);
1070 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_LAST_ACK_RECV 1071 inspect_tcpi_last_ack_recv(ret, s.tcpi_last_ack_recv);
1073 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_PMTU 1076 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_RCV_SSTHRESH 1077 rb_str_catf(ret,
" rcv_ssthresh=%u", s.tcpi_rcv_ssthresh);
1079 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_RTT 1080 inspect_tcpi_rtt(ret, s.tcpi_rtt);
1082 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_RTTVAR 1083 inspect_tcpi_rttvar(ret, s.tcpi_rttvar);
1085 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_SND_SSTHRESH 1086 rb_str_catf(ret,
" snd_ssthresh=%u", s.tcpi_snd_ssthresh);
1088 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_SND_CWND 1089 rb_str_catf(ret,
" snd_cwnd=%u", s.tcpi_snd_cwnd);
1091 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_ADVMSS 1094 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_REORDERING 1095 rb_str_catf(ret,
" reordering=%u", s.tcpi_reordering);
1097 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_RCV_RTT 1098 inspect_tcpi_rcv_rtt(ret, s.tcpi_rcv_rtt);
1100 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_RCV_SPACE 1101 rb_str_catf(ret,
" rcv_space=%u", s.tcpi_rcv_space);
1103 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_TOTAL_RETRANS 1104 rb_str_catf(ret,
" total_retrans=%u", s.tcpi_total_retrans);
1106 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_SND_WND 1109 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_SND_BWND 1110 rb_str_catf(ret,
" snd_bwnd=%u", s.tcpi_snd_bwnd);
1112 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_SND_NXT 1115 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_RCV_NXT 1118 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_TOE_TID 1121 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_SND_REXMITPACK 1122 rb_str_catf(ret,
" snd_rexmitpack=%u", s.tcpi_snd_rexmitpack);
1124 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_RCV_OOOPACK 1125 rb_str_catf(ret,
" rcv_ooopack=%u", s.tcpi_rcv_ooopack);
1127 #ifdef HAVE_STRUCT_TCP_INFO_TCPI_SND_ZEROWIN 1128 rb_str_catf(ret,
" snd_zerowin=%u", s.tcpi_snd_zerowin);
1130 if (
sizeof(
struct tcp_info) < actual_size)
1131 rb_str_catf(ret,
" (%u bytes too long)", (
unsigned)(actual_size -
sizeof(
struct tcp_info)));
1140 #if defined(SOL_SOCKET) && defined(SO_PEERCRED) 1141 #if defined(__OpenBSD__) 1142 #define RUBY_SOCK_PEERCRED struct sockpeercred 1144 #define RUBY_SOCK_PEERCRED struct ucred 1149 if (
RSTRING_LEN(data) ==
sizeof(RUBY_SOCK_PEERCRED)) {
1150 RUBY_SOCK_PEERCRED cred;
1151 memcpy(&cred,
RSTRING_PTR(data),
sizeof(RUBY_SOCK_PEERCRED));
1153 (
unsigned)cred.pid, (
unsigned)cred.uid, (
unsigned)cred.gid);
1163 #if defined(LOCAL_PEERCRED) 1169 memcpy(&cred,
RSTRING_PTR(data),
sizeof(
struct xucred));
1170 if (cred.cr_version != XUCRED_VERSION)
1174 if (cred.cr_ngroups) {
1176 const char *sep =
" groups=";
1177 for (i = 0; i < cred.cr_ngroups; i++) {
1203 sockopt_inspect(
VALUE self)
1205 int family =
NUM2INT(sockopt_family_m(
self));
1207 int optname =
NUM2INT(sockopt_optname_m(
self));
1208 VALUE data = sockopt_data(
self);
1210 ID family_id, level_id, optname_id;
1223 if (level == SOL_SOCKET) {
1232 #ifdef HAVE_SYS_UN_H 1233 else if (family == AF_UNIX) {
1250 v = optname_to_sym(level, optname);
1263 if (level == SOL_SOCKET)
1270 # if defined(SO_DEBUG) 1271 case SO_DEBUG: inspected = inspect_int(level, optname, data, ret);
break;
1273 # if defined(SO_ERROR) 1274 case SO_ERROR: inspected = inspect_errno(level, optname, data, ret);
break;
1276 # if defined(SO_TYPE) 1277 case SO_TYPE: inspected = inspect_socktype(level, optname, data, ret);
break;
1279 # if defined(SO_ACCEPTCONN) 1280 case SO_ACCEPTCONN: inspected = inspect_int(level, optname, data, ret);
break;
1282 # if defined(SO_BROADCAST) 1283 case SO_BROADCAST: inspected = inspect_int(level, optname, data, ret);
break;
1285 # if defined(SO_REUSEADDR) 1286 case SO_REUSEADDR: inspected = inspect_int(level, optname, data, ret);
break;
1288 # if defined(SO_KEEPALIVE) 1289 case SO_KEEPALIVE: inspected = inspect_int(level, optname, data, ret);
break;
1291 # if defined(SO_OOBINLINE) 1292 case SO_OOBINLINE: inspected = inspect_int(level, optname, data, ret);
break;
1294 # if defined(SO_SNDBUF) 1295 case SO_SNDBUF: inspected = inspect_int(level, optname, data, ret);
break;
1297 # if defined(SO_RCVBUF) 1298 case SO_RCVBUF: inspected = inspect_int(level, optname, data, ret);
break;
1300 # if defined(SO_DONTROUTE) 1301 case SO_DONTROUTE: inspected = inspect_int(level, optname, data, ret);
break;
1303 # if defined(SO_RCVLOWAT) 1304 case SO_RCVLOWAT: inspected = inspect_int(level, optname, data, ret);
break;
1306 # if defined(SO_SNDLOWAT) 1307 case SO_SNDLOWAT: inspected = inspect_int(level, optname, data, ret);
break;
1309 # if defined(SO_LINGER) 1310 case SO_LINGER: inspected = inspect_linger(level, optname, data, ret);
break;
1312 # if defined(SO_RCVTIMEO) 1313 case SO_RCVTIMEO: inspected = inspect_timeval_as_interval(level, optname, data, ret);
break;
1315 # if defined(SO_SNDTIMEO) 1316 case SO_SNDTIMEO: inspected = inspect_timeval_as_interval(level, optname, data, ret);
break;
1318 # if defined(SO_PEERCRED) 1319 case SO_PEERCRED: inspected = inspect_peercred(level, optname, data, ret);
break;
1331 # if defined(IPPROTO_IP) 1334 # if defined(IP_MULTICAST_IF) && defined(HAVE_TYPE_STRUCT_IP_MREQN) 1335 case IP_MULTICAST_IF: inspected = inspect_ipv4_multicast_if(level, optname, data, ret);
break;
1337 # if defined(IP_ADD_MEMBERSHIP) 1338 case IP_ADD_MEMBERSHIP: inspected = inspect_ipv4_add_drop_membership(level, optname, data, ret);
break;
1340 # if defined(IP_DROP_MEMBERSHIP) 1341 case IP_DROP_MEMBERSHIP: inspected = inspect_ipv4_add_drop_membership(level, optname, data, ret);
break;
1343 # if defined(IP_MULTICAST_LOOP) 1346 # if defined(IP_MULTICAST_TTL) 1353 # if defined(IPPROTO_IPV6) 1356 # if defined(IPV6_MULTICAST_HOPS) 1357 case IPV6_MULTICAST_HOPS: inspected = inspect_int(level, optname, data, ret);
break;
1359 # if defined(IPV6_MULTICAST_IF) 1360 case IPV6_MULTICAST_IF: inspected = inspect_ipv6_multicast_if(level, optname, data, ret);
break;
1362 # if defined(IPV6_MULTICAST_LOOP) 1363 case IPV6_MULTICAST_LOOP: inspected = inspect_uint(level, optname, data, ret);
break;
1365 # if defined(IPV6_JOIN_GROUP) 1366 case IPV6_JOIN_GROUP: inspected = inspect_ipv6_mreq(level, optname, data, ret);
break;
1368 # if defined(IPV6_LEAVE_GROUP) 1369 case IPV6_LEAVE_GROUP: inspected = inspect_ipv6_mreq(level, optname, data, ret);
break;
1371 # if defined(IPV6_UNICAST_HOPS) 1372 case IPV6_UNICAST_HOPS: inspected = inspect_int(level, optname, data, ret);
break;
1374 # if defined(IPV6_V6ONLY) 1375 case IPV6_V6ONLY: inspected = inspect_int(level, optname, data, ret);
break;
1381 # if defined(IPPROTO_TCP) 1384 # if defined(TCP_NODELAY) 1385 case TCP_NODELAY: inspected = inspect_int(level, optname, data, ret);
break;
1387 # if defined(TCP_INFO) && defined(HAVE_TYPE_STRUCT_TCP_INFO) 1388 case TCP_INFO: inspected = inspect_tcp_info(level, optname, data, ret);
break;
1396 #ifdef HAVE_SYS_UN_H 1401 # if defined(LOCAL_PEERCRED) 1402 case LOCAL_PEERCRED: inspected = inspect_local_peercred(level, optname, data, ret);
break;
ID rsock_intern_family_noprefix(int val)
void rb_define_singleton_method(VALUE obj, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a singleton method for obj.
void rb_raise(VALUE exc, const char *fmt,...)
#define check_size(len, size)
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
ID rsock_intern_so_optname(int val)
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
Defines a class under the namespace of outer.
const char * inet_ntop(int af, const void *addr, char *numaddr, size_t numaddr_len)
const char * rb_obj_classname(VALUE)
#define NEWOBJ_OF(obj, type, klass, flags)
int rsock_family_arg(VALUE domain)
VALUE rsock_sockopt_new(int family, int level, int optname, VALUE data)
RUBY_EXTERN VALUE rb_cObject
VALUE rb_str_cat2(VALUE, const char *)
VALUE rb_check_to_integer(VALUE, const char *)
Tries to convert val into Integer.
int rsock_level_arg(int family, VALUE level)
#define inspect_ipv4_multicast_loop(a, b, c, d)
ID rsock_intern_iplevel(int val)
VALUE rb_sprintf(const char *format,...)
VALUE rb_ivar_set(VALUE, ID, VALUE)
unsigned char buf[MIME_BUF_SIZE]
VALUE rb_assoc_new(VALUE car, VALUE cdr)
ID rsock_intern_tcp_optname(int val)
ID rsock_intern_local_optname(int val)
const char * rb_id2name(ID)
ID rsock_intern_socktype(int val)
#define TYPE_IP_MULTICAST_LOOP
register unsigned int len
VALUE rb_str_catf(VALUE str, const char *format,...)
RUBY_EXTERN char * strerror(int)
ID rsock_intern_udp_optname(int val)
VALUE rb_str_cat_cstr(VALUE, const char *)
int rsock_optname_arg(int family, int level, VALUE optname)
void rsock_init_sockopt(void)
#define inspect_ipv4_multicast_ttl(a, b, c, d)
ID rsock_intern_ipv6_optname(int val)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
VALUE rb_str_append(VALUE, VALUE)
#define TYPE_IP_MULTICAST_TTL
VALUE rb_to_int(VALUE)
Converts val into Integer.
VALUE rb_attr_get(VALUE, ID)
ID rsock_intern_ip_optname(int val)