1require 'optparse' 2require 'erb' 3 4opt = OptionParser.new 5 6opt.def_option('-h', 'help') { 7 puts opt 8 exit 0 9} 10 11opt_o = nil 12opt.def_option('-o FILE', 'specify output file') {|filename| 13 opt_o = filename 14} 15 16opt_H = nil 17opt.def_option('-H FILE', 'specify output header file') {|filename| 18 opt_H = filename 19} 20 21C_ESC = { 22 "\\" => "\\\\", 23 '"' => '\"', 24 "\n" => '\n', 25} 26 270x00.upto(0x1f) {|ch| C_ESC[[ch].pack("C")] ||= "\\%03o" % ch } 280x7f.upto(0xff) {|ch| C_ESC[[ch].pack("C")] = "\\%03o" % ch } 29C_ESC_PAT = Regexp.union(*C_ESC.keys) 30 31def c_str(str) 32 '"' + str.gsub(C_ESC_PAT) {|s| C_ESC[s]} + '"' 33end 34 35opt.parse! 36 37 38 39h = {} 40COMMENTS = Hash.new { |h, name| h[name] = name } 41 42DATA.each_line {|s| 43 name, default_value, comment = s.chomp.split(/\s+/, 3) 44 next unless name && name[0] != ?# 45 46 default_value = nil if default_value == 'nil' 47 48 if h.has_key? name 49 warn "#{$.}: warning: duplicate name: #{name}" 50 next 51 end 52 h[name] = default_value 53 COMMENTS[name] = comment 54} 55DEFS = h.to_a 56 57def each_const 58 DEFS.each {|name, default_value| 59 if name =~ /\AINADDR_/ 60 make_value = "UINT2NUM" 61 else 62 make_value = "INT2NUM" 63 end 64 guard = nil 65 if /\A(AF_INET6|PF_INET6|IPV6_.*)\z/ =~ name 66 # IPv6 is not supported although AF_INET6 is defined on bcc32/mingw 67 guard = "defined(INET6)" 68 end 69 yield guard, make_value, name, default_value 70 } 71end 72 73def each_name(pat) 74 DEFS.each {|name, default_value| 75 next if pat !~ name 76 yield name 77 } 78end 79 80ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_const_decls") 81% each_const {|guard, make_value, name, default_value| 82#if !defined(<%=name%>) 83# if defined(HAVE_CONST_<%=name.upcase%>) 84# define <%=name%> <%=name%> 85%if default_value 86# else 87# define <%=name%> <%=default_value%> 88%end 89# endif 90#endif 91% } 92EOS 93 94ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_const_defs_in_guard(make_value, name, default_value)") 95#if defined(<%=name%>) 96 /* <%= COMMENTS[name] %> */ 97 rb_define_const(rb_cSocket, <%=c_str name%>, <%=make_value%>(<%=name%>)); 98 /* <%= COMMENTS[name] %> */ 99 rb_define_const(rb_mSockConst, <%=c_str name%>, <%=make_value%>(<%=name%>)); 100#endif 101EOS 102 103ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_const_defs") 104% each_const {|guard, make_value, name, default_value| 105% if guard 106#if <%=guard%> 107<%= gen_const_defs_in_guard(make_value, name, default_value).chomp %> 108#endif 109% else 110<%= gen_const_defs_in_guard(make_value, name, default_value).chomp %> 111% end 112% } 113EOS 114 115def reverse_each_name(pat) 116 DEFS.reverse_each {|name, default_value| 117 next if pat !~ name 118 yield name 119 } 120end 121 122def each_names_with_len(pat, prefix_optional=nil) 123 h = {} 124 DEFS.each {|name, default_value| 125 next if pat !~ name 126 (h[name.length] ||= []) << [name, name] 127 } 128 if prefix_optional 129 if Regexp === prefix_optional 130 prefix_pat = prefix_optional 131 else 132 prefix_pat = /\A#{Regexp.escape prefix_optional}/ 133 end 134 DEFS.each {|const, default_value| 135 next if pat !~ const 136 next if prefix_pat !~ const 137 name = $' 138 (h[name.length] ||= []) << [name, const] 139 } 140 end 141 hh = {} 142 h.each {|len, pairs| 143 pairs.each {|name, const| 144 raise "name crash: #{name}" if hh[name] 145 hh[name] = true 146 } 147 } 148 h.keys.sort.each {|len| 149 yield h[len], len 150 } 151end 152 153ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_name_to_int_decl(funcname, pat, prefix_optional, guard=nil)") 154%if guard 155#ifdef <%=guard%> 156int <%=funcname%>(const char *str, long len, int *valp); 157#endif 158%else 159int <%=funcname%>(const char *str, long len, int *valp); 160%end 161EOS 162 163ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_name_to_int_func_in_guard(funcname, pat, prefix_optional, guard=nil)") 164int 165<%=funcname%>(const char *str, long len, int *valp) 166{ 167 switch (len) { 168% each_names_with_len(pat, prefix_optional) {|pairs, len| 169 case <%=len%>: 170% pairs.each {|name, const| 171#ifdef <%=const%> 172 if (memcmp(str, <%=c_str name%>, <%=len%>) == 0) { *valp = <%=const%>; return 0; } 173#endif 174% } 175 return -1; 176 177% } 178 default: 179 return -1; 180 } 181} 182EOS 183 184ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_name_to_int_func(funcname, pat, prefix_optional, guard=nil)") 185%if guard 186#ifdef <%=guard%> 187<%=gen_name_to_int_func_in_guard(funcname, pat, prefix_optional, guard)%> 188#endif 189%else 190<%=gen_name_to_int_func_in_guard(funcname, pat, prefix_optional, guard)%> 191%end 192EOS 193 194NAME_TO_INT_DEFS = [] 195def def_name_to_int(funcname, pat, prefix_optional, guard=nil) 196 decl = gen_name_to_int_decl(funcname, pat, prefix_optional, guard) 197 func = gen_name_to_int_func(funcname, pat, prefix_optional, guard) 198 NAME_TO_INT_DEFS << [decl, func] 199end 200 201def reverse_each_name_with_prefix_optional(pat, prefix_pat) 202 reverse_each_name(pat) {|n| 203 yield n, n 204 } 205 if prefix_pat 206 reverse_each_name(pat) {|n| 207 next if prefix_pat !~ n 208 yield n, $' 209 } 210 end 211end 212 213ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_int_to_name_hash(hash_var, pat, prefix_pat)") 214 <%=hash_var%> = st_init_numtable(); 215% reverse_each_name_with_prefix_optional(pat, prefix_pat) {|n,s| 216#ifdef <%=n%> 217 st_insert(<%=hash_var%>, (st_data_t)<%=n%>, (st_data_t)rb_intern2(<%=c_str s%>, <%=s.length%>)); 218#endif 219% } 220EOS 221 222ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_int_to_name_func(func_name, hash_var)") 223ID 224<%=func_name%>(int val) 225{ 226 st_data_t name; 227 if (st_lookup(<%=hash_var%>, (st_data_t)val, &name)) 228 return (ID)name; 229 return 0; 230} 231EOS 232 233ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_int_to_name_decl(func_name, hash_var)") 234ID <%=func_name%>(int val); 235EOS 236 237INTERN_DEFS = [] 238def def_intern(func_name, pat, prefix_optional=nil) 239 prefix_pat = nil 240 if prefix_optional 241 if Regexp === prefix_optional 242 prefix_pat = prefix_optional 243 else 244 prefix_pat = /\A#{Regexp.escape prefix_optional}/ 245 end 246 end 247 hash_var = "#{func_name}_hash" 248 vardef = "static st_table *#{hash_var};" 249 gen_hash = gen_int_to_name_hash(hash_var, pat, prefix_pat) 250 decl = gen_int_to_name_decl(func_name, hash_var) 251 func = gen_int_to_name_func(func_name, hash_var) 252 INTERN_DEFS << [vardef, gen_hash, decl, func] 253end 254 255def_name_to_int("rsock_family_to_int", /\A(AF_|PF_)/, "AF_") 256def_name_to_int("rsock_socktype_to_int", /\ASOCK_/, "SOCK_") 257def_name_to_int("rsock_ipproto_to_int", /\AIPPROTO_/, "IPPROTO_") 258def_name_to_int("rsock_unknown_level_to_int", /\ASOL_SOCKET\z/, "SOL_") 259def_name_to_int("rsock_ip_level_to_int", /\A(SOL_SOCKET\z|IPPROTO_)/, /\A(SOL_|IPPROTO_)/) 260def_name_to_int("rsock_so_optname_to_int", /\ASO_/, "SO_") 261def_name_to_int("rsock_ip_optname_to_int", /\AIP_/, "IP_") 262def_name_to_int("rsock_ipv6_optname_to_int", /\AIPV6_/, "IPV6_", "IPPROTO_IPV6") 263def_name_to_int("rsock_tcp_optname_to_int", /\ATCP_/, "TCP_") 264def_name_to_int("rsock_udp_optname_to_int", /\AUDP_/, "UDP_") 265def_name_to_int("rsock_shutdown_how_to_int", /\ASHUT_/, "SHUT_") 266def_name_to_int("rsock_scm_optname_to_int", /\ASCM_/, "SCM_") 267 268def_intern('rsock_intern_family', /\AAF_/) 269def_intern('rsock_intern_family_noprefix', /\AAF_/, "AF_") 270def_intern('rsock_intern_protocol_family', /\APF_/) 271def_intern('rsock_intern_socktype', /\ASOCK_/) 272def_intern('rsock_intern_ipproto', /\AIPPROTO_/) 273def_intern('rsock_intern_iplevel', /\A(SOL_SOCKET\z|IPPROTO_)/, /\A(SOL_|IPPROTO_)/) 274def_intern('rsock_intern_so_optname', /\ASO_/, "SO_") 275def_intern('rsock_intern_ip_optname', /\AIP_/, "IP_") 276def_intern('rsock_intern_ipv6_optname', /\AIPV6_/, "IPV6_") 277def_intern('rsock_intern_tcp_optname', /\ATCP_/, "TCP_") 278def_intern('rsock_intern_udp_optname', /\AUDP_/, "UDP_") 279def_intern('rsock_intern_scm_optname', /\ASCM_/, "SCM_") 280def_intern('rsock_intern_local_optname', /\ALOCAL_/, "LOCAL_") 281 282result = ERB.new(<<'EOS', nil, '%').result(binding) 283/* autogenerated file */ 284 285<%= INTERN_DEFS.map {|vardef, gen_hash, decl, func| vardef }.join("\n") %> 286 287static void 288init_constants(void) 289{ 290 /* 291 * Document-module: Socket::Constants 292 * 293 * Socket::Constants provides socket-related constants. All possible 294 * socket constants are listed in the documentation but they may not all 295 * be present on your platform. 296 * 297 * If the underlying platform doesn't define a constant the corresponding 298 * Ruby constant is not defined. 299 * 300 */ 301 rb_mSockConst = rb_define_module_under(rb_cSocket, "Constants"); 302 303<%= gen_const_defs %> 304<%= INTERN_DEFS.map {|vardef, gen_hash, decl, func| gen_hash }.join("\n") %> 305} 306 307<%= NAME_TO_INT_DEFS.map {|decl, func| func }.join("\n") %> 308 309<%= INTERN_DEFS.map {|vardef, gen_hash, decl, func| func }.join("\n") %> 310 311EOS 312 313header_result = ERB.new(<<'EOS', nil, '%').result(binding) 314/* autogenerated file */ 315<%= gen_const_decls %> 316<%= NAME_TO_INT_DEFS.map {|decl, func| decl }.join("\n") %> 317<%= INTERN_DEFS.map {|vardef, gen_hash, decl, func| decl }.join("\n") %> 318EOS 319 320if opt_H 321 File.open(opt_H, 'w') {|f| 322 f << header_result 323 } 324else 325 result = header_result + result 326end 327 328if opt_o 329 File.open(opt_o, 'w') {|f| 330 f << result 331 } 332else 333 $stdout << result 334end 335 336__END__ 337 338SOCK_STREAM nil A stream socket provides a sequenced, reliable two-way connection for a byte stream 339SOCK_DGRAM nil A datagram socket provides connectionless, unreliable messaging 340SOCK_RAW nil A raw socket provides low-level access for direct access or implementing network protocols 341SOCK_RDM nil A reliable datagram socket provides reliable delivery of messages 342SOCK_SEQPACKET nil A sequential packet socket provides sequenced, reliable two-way connection for datagrams 343SOCK_PACKET nil Device-level packet access 344 345AF_UNSPEC nil Unspecified protocol, any supported address family 346PF_UNSPEC nil Unspecified protocol, any supported address family 347AF_INET nil IPv4 protocol 348PF_INET nil IPv4 protocol 349AF_INET6 nil IPv6 protocol 350PF_INET6 nil IPv6 protocol 351AF_UNIX nil UNIX sockets 352PF_UNIX nil UNIX sockets 353AF_AX25 nil AX.25 protocol 354PF_AX25 nil AX.25 protocol 355AF_IPX nil IPX protocol 356PF_IPX nil IPX protocol 357AF_APPLETALK nil AppleTalk protocol 358PF_APPLETALK nil AppleTalk protocol 359AF_LOCAL nil Host-internal protocols 360PF_LOCAL nil Host-internal protocols 361AF_IMPLINK nil ARPANET IMP protocol 362PF_IMPLINK nil ARPANET IMP protocol 363AF_PUP nil PARC Universal Packet protocol 364PF_PUP nil PARC Universal Packet protocol 365AF_CHAOS nil MIT CHAOS protocols 366PF_CHAOS nil MIT CHAOS protocols 367AF_NS nil XEROX NS protocols 368PF_NS nil XEROX NS protocols 369AF_ISO nil ISO Open Systems Interconnection protocols 370PF_ISO nil ISO Open Systems Interconnection protocols 371AF_OSI nil ISO Open Systems Interconnection protocols 372PF_OSI nil ISO Open Systems Interconnection protocols 373AF_ECMA nil European Computer Manufacturers protocols 374PF_ECMA nil European Computer Manufacturers protocols 375AF_DATAKIT nil Datakit protocol 376PF_DATAKIT nil Datakit protocol 377AF_CCITT nil CCITT (now ITU-T) protocols 378PF_CCITT nil CCITT (now ITU-T) protocols 379AF_SNA nil IBM SNA protocol 380PF_SNA nil IBM SNA protocol 381AF_DEC nil DECnet protocol 382PF_DEC nil DECnet protocol 383AF_DLI nil DEC Direct Data Link Interface protocol 384PF_DLI nil DEC Direct Data Link Interface protocol 385AF_LAT nil Local Area Transport protocol 386PF_LAT nil Local Area Transport protocol 387AF_HYLINK nil NSC Hyperchannel protocol 388PF_HYLINK nil NSC Hyperchannel protocol 389AF_ROUTE nil Internal routing protocol 390PF_ROUTE nil Internal routing protocol 391AF_LINK nil Link layer interface 392PF_LINK nil Link layer interface 393AF_COIP nil Connection-oriented IP 394PF_COIP nil Connection-oriented IP 395AF_CNT nil Computer Network Technology 396PF_CNT nil Computer Network Technology 397AF_SIP nil Simple Internet Protocol 398PF_SIP nil Simple Internet Protocol 399AF_NDRV nil Network driver raw access 400PF_NDRV nil Network driver raw access 401AF_ISDN nil Integrated Services Digital Network 402PF_ISDN nil Integrated Services Digital Network 403AF_NATM nil Native ATM access 404PF_NATM nil Native ATM access 405AF_SYSTEM 406PF_SYSTEM 407AF_NETBIOS nil NetBIOS 408PF_NETBIOS nil NetBIOS 409AF_PPP nil Point-to-Point Protocol 410PF_PPP nil Point-to-Point Protocol 411AF_ATM nil Asynchronous Transfer Mode 412PF_ATM nil Asynchronous Transfer Mode 413AF_NETGRAPH nil Netgraph sockets 414PF_NETGRAPH nil Netgraph sockets 415AF_MAX nil Maximum address family for this platform 416PF_MAX nil Maximum address family for this platform 417AF_PACKET nil Direct link-layer access 418PF_PACKET nil Direct link-layer access 419 420AF_E164 nil CCITT (ITU-T) E.164 recommendation 421PF_XTP nil eXpress Transfer Protocol 422PF_RTIP 423PF_PIP 424PF_KEY 425 426MSG_OOB nil Process out-of-band data 427MSG_PEEK nil Peek at incoming message 428MSG_DONTROUTE nil Send without using the routing tables 429MSG_EOR nil Data completes record 430MSG_TRUNC nil Data discarded before delivery 431MSG_CTRUNC nil Control data lost before delivery 432MSG_WAITALL nil Wait for full request or error 433MSG_DONTWAIT nil This message should be non-blocking 434MSG_EOF nil Data completes connection 435MSG_FLUSH nil Start of a hold sequence. Dumps to so_temp 436MSG_HOLD nil Hold fragment in so_temp 437MSG_SEND nil Send the packet in so_temp 438MSG_HAVEMORE nil Data ready to be read 439MSG_RCVMORE nil Data remains in the current packet 440MSG_COMPAT nil End of record 441MSG_PROXY nil Wait for full request 442MSG_FIN 443MSG_SYN 444MSG_CONFIRM nil Confirm path validity 445MSG_RST 446MSG_ERRQUEUE nil Fetch message from error queue 447MSG_NOSIGNAL nil Do not generate SIGPIPE 448MSG_MORE nil Sender will send more 449 450SOL_SOCKET nil Socket-level options 451SOL_IP nil IP socket options 452SOL_IPX nil IPX socket options 453SOL_AX25 nil AX.25 socket options 454SOL_ATALK nil AppleTalk socket options 455SOL_TCP nil TCP socket options 456SOL_UDP nil UDP socket options 457 458IPPROTO_IP 0 Dummy protocol for IP 459IPPROTO_ICMP 1 Control message protocol 460IPPROTO_IGMP nil Group Management Protocol 461IPPROTO_GGP nil Gateway to Gateway Protocol 462IPPROTO_TCP 6 TCP 463IPPROTO_EGP nil Exterior Gateway Protocol 464IPPROTO_PUP nil PARC Universal Packet protocol 465IPPROTO_UDP 17 UDP 466IPPROTO_IDP nil XNS IDP 467IPPROTO_HELLO nil "hello" routing protocol 468IPPROTO_ND nil Sun net disk protocol 469IPPROTO_TP nil ISO transport protocol class 4 470IPPROTO_XTP nil Xpress Transport Protocol 471IPPROTO_EON nil ISO cnlp 472IPPROTO_BIP 473IPPROTO_AH nil IP6 auth header 474IPPROTO_DSTOPTS nil IP6 destination option 475IPPROTO_ESP nil IP6 Encapsulated Security Payload 476IPPROTO_FRAGMENT nil IP6 fragmentation header 477IPPROTO_HOPOPTS nil IP6 hop-by-hop options 478IPPROTO_ICMPV6 nil ICMP6 479IPPROTO_IPV6 nil IP6 header 480IPPROTO_NONE nil IP6 no next header 481IPPROTO_ROUTING nil IP6 routing header 482 483IPPROTO_RAW 255 Raw IP packet 484IPPROTO_MAX nil Maximum IPPROTO constant 485 486# Some port configuration 487IPPORT_RESERVED 1024 Default minimum address for bind or connect 488IPPORT_USERRESERVED 5000 Default maximum address for bind or connect 489 490# Some reserved IP v.4 addresses 491INADDR_ANY 0x00000000 A socket bound to INADDR_ANY receives packets from all interfaces and sends from the default IP address 492INADDR_BROADCAST 0xffffffff The network broadcast address 493INADDR_LOOPBACK 0x7F000001 The loopback address 494INADDR_UNSPEC_GROUP 0xe0000000 The reserved multicast group 495INADDR_ALLHOSTS_GROUP 0xe0000001 Multicast group for all systems on this subset 496INADDR_MAX_LOCAL_GROUP 0xe00000ff The last local network multicast group 497INADDR_NONE 0xffffffff A bitmask for matching no valid IP address 498 499# IP [gs]etsockopt options 500IP_OPTIONS nil IP options to be included in packets 501IP_HDRINCL nil Header is included with data 502IP_TOS nil IP type-of-service 503IP_TTL nil IP time-to-live 504IP_RECVOPTS nil Receive all IP options with datagram 505IP_RECVRETOPTS nil Receive all IP options for response 506IP_RECVDSTADDR nil Receive IP destination address with datagram 507IP_RETOPTS nil IP options to be included in datagrams 508IP_MINTTL nil Minimum TTL allowed for received packets 509IP_DONTFRAG nil Don't fragment packets 510IP_SENDSRCADDR nil Source address for outgoing UDP datagrams 511IP_ONESBCAST nil Force outgoing broadcast datagrams to have the undirected broadcast address 512IP_RECVTTL nil Receive IP TTL with datagrams 513IP_RECVIF nil Receive interface information with datagrams 514IP_RECVSLLA nil Receive link-layer address with datagrams 515IP_PORTRANGE nil Set the port range for sockets with unspecified port numbers 516IP_MULTICAST_IF nil IP multicast interface 517IP_MULTICAST_TTL nil IP multicast TTL 518IP_MULTICAST_LOOP nil IP multicast loopback 519IP_ADD_MEMBERSHIP nil Add a multicast group membership 520IP_DROP_MEMBERSHIP nil Drop a multicast group membership 521IP_DEFAULT_MULTICAST_TTL nil Default multicast TTL 522IP_DEFAULT_MULTICAST_LOOP nil Default multicast loopback 523IP_MAX_MEMBERSHIPS nil Maximum number multicast groups a socket can join 524IP_ROUTER_ALERT nil Notify transit routers to more closely examine the contents of an IP packet 525IP_PKTINFO nil Receive packet information with datagrams 526IP_PKTOPTIONS nil Receive packet options with datagrams 527IP_MTU_DISCOVER nil Path MTU discovery 528IP_RECVERR nil Enable extended reliable error message passing 529IP_RECVTOS nil Receive TOS with incoming packets 530IP_MTU nil The Maximum Transmission Unit of the socket 531IP_FREEBIND nil Allow binding to nonexistent IP addresses 532IP_IPSEC_POLICY nil IPsec security policy 533IP_XFRM_POLICY 534IP_PASSSEC nil Retrieve security context with datagram 535IP_PMTUDISC_DONT nil Never send DF frames 536IP_PMTUDISC_WANT nil Use per-route hints 537IP_PMTUDISC_DO nil Always send DF frames 538IP_UNBLOCK_SOURCE nil Unblock IPv4 multicast packets with a give source address 539IP_BLOCK_SOURCE nil Block IPv4 multicast packets with a give source address 540IP_ADD_SOURCE_MEMBERSHIP nil Add a multicast group membership 541IP_DROP_SOURCE_MEMBERSHIP nil Drop a multicast group membership 542IP_MSFILTER nil Multicast source filtering 543 544MCAST_JOIN_GROUP nil Join a multicast group 545MCAST_BLOCK_SOURCE nil Block multicast packets from this source 546MCAST_UNBLOCK_SOURCE nil Unblock multicast packets from this source 547MCAST_LEAVE_GROUP nil Leave a multicast group 548MCAST_JOIN_SOURCE_GROUP nil Join a multicast source group 549MCAST_LEAVE_SOURCE_GROUP nil Leave a multicast source group 550MCAST_MSFILTER nil Multicast source filtering 551MCAST_EXCLUDE nil Exclusive multicast source filter 552MCAST_INCLUDE nil Inclusive multicast source filter 553 554SO_DEBUG nil Debug info recording 555SO_REUSEADDR nil Allow local address reuse 556SO_REUSEPORT nil Allow local address and port reuse 557SO_TYPE nil Get the socket type 558SO_ERROR nil Get and clear the error status 559SO_DONTROUTE nil Use interface addresses 560SO_BROADCAST nil Permit sending of broadcast messages 561SO_SNDBUF nil Send buffer size 562SO_RCVBUF nil Receive buffer size 563SO_KEEPALIVE nil Keep connections alive 564SO_OOBINLINE nil Leave received out-of-band data in-line 565SO_NO_CHECK nil Disable checksums 566SO_PRIORITY nil The protocol-defined priority for all packets on this socket 567SO_LINGER nil Linger on close if data is present 568SO_PASSCRED nil Receive SCM_CREDENTIALS messages 569SO_PEERCRED nil The credentials of the foreign process connected to this socket 570SO_RCVLOWAT nil Receive low-water mark 571SO_SNDLOWAT nil Send low-water mark 572SO_RCVTIMEO nil Receive timeout 573SO_SNDTIMEO nil Send timeout 574SO_ACCEPTCONN nil Socket has had listen() called on it 575SO_USELOOPBACK nil Bypass hardware when possible 576SO_ACCEPTFILTER nil There is an accept filter 577SO_DONTTRUNC nil Retain unread data 578SO_WANTMORE nil Give a hint when more data is ready 579SO_WANTOOBFLAG nil OOB data is wanted in MSG_FLAG on receive 580SO_NREAD nil Get first packet byte count 581SO_NKE nil Install socket-level Network Kernel Extension 582SO_NOSIGPIPE nil Don't SIGPIPE on EPIPE 583SO_SECURITY_AUTHENTICATION 584SO_SECURITY_ENCRYPTION_TRANSPORT 585SO_SECURITY_ENCRYPTION_NETWORK 586SO_BINDTODEVICE nil Only send packets from the given interface 587SO_ATTACH_FILTER nil Attach an accept filter 588SO_DETACH_FILTER nil Detach an accept filter 589SO_PEERNAME nil Name of the connecting user 590SO_TIMESTAMP nil Receive timestamp with datagrams (timeval) 591SO_TIMESTAMPNS nil Receive nanosecond timestamp with datagrams (timespec) 592SO_BINTIME nil Receive timestamp with datagrams (bintime) 593SO_RECVUCRED nil Receive user credentials with datagram 594SO_MAC_EXEMPT nil Mandatory Access Control exemption for unlabeled peers 595SO_ALLZONES nil Bypass zone boundaries 596 597SOPRI_INTERACTIVE nil Interactive socket priority 598SOPRI_NORMAL nil Normal socket priority 599SOPRI_BACKGROUND nil Background socket priority 600 601IPX_TYPE 602 603TCP_NODELAY nil Don't delay sending to coalesce packets 604TCP_MAXSEG nil Set maximum segment size 605TCP_CORK nil Don't send partial frames 606TCP_DEFER_ACCEPT nil Don't notify a listening socket until data is ready 607TCP_INFO nil Retrieve information about this socket 608TCP_KEEPCNT nil Maximum number of keepalive probes allowed before dropping a connection 609TCP_KEEPIDLE nil Idle time before keepalive probes are sent 610TCP_KEEPINTVL nil Time between keepalive probes 611TCP_LINGER2 nil Lifetime of orphaned FIN_WAIT2 sockets 612TCP_MD5SIG nil Use MD5 digests (RFC2385) 613TCP_NOOPT nil Don't use TCP options 614TCP_NOPUSH nil Don't push the last block of write 615TCP_QUICKACK nil Enable quickack mode 616TCP_SYNCNT nil Number of SYN retransmits before a connection is dropped 617TCP_WINDOW_CLAMP nil Clamp the size of the advertised window 618 619UDP_CORK nil Don't send partial frames 620 621EAI_ADDRFAMILY nil Address family for hostname not supported 622EAI_AGAIN nil Temporary failure in name resolution 623EAI_BADFLAGS nil Invalid flags 624EAI_FAIL nil Non-recoverable failure in name resolution 625EAI_FAMILY nil Address family not supported 626EAI_MEMORY nil Memory allocation failure 627EAI_NODATA nil No address associated with hostname 628EAI_NONAME nil Hostname nor servname, or not known 629EAI_OVERFLOW nil Argument buffer overflow 630EAI_SERVICE nil Servname not supported for socket type 631EAI_SOCKTYPE nil Socket type not supported 632EAI_SYSTEM nil System error returned in errno 633EAI_BADHINTS nil Invalid value for hints 634EAI_PROTOCOL nil Resolved protocol is unknown 635EAI_MAX nil Maximum error code from getaddrinfo 636 637AI_PASSIVE nil Get address to use with bind() 638AI_CANONNAME nil Fill in the canonical name 639AI_NUMERICHOST nil Prevent host name resolution 640AI_NUMERICSERV nil Prevent service name resolution 641AI_MASK nil Valid flag mask for getaddrinfo (not for application use) 642AI_ALL nil Allow all addresses 643AI_V4MAPPED_CFG nil Accept IPv4 mapped addresses if the kernel supports it 644AI_ADDRCONFIG nil Accept only if any address is assigned 645AI_V4MAPPED nil Accept IPv4-mapped IPv6 addresses 646AI_DEFAULT nil Default flags for getaddrinfo 647 648NI_MAXHOST nil Maximum length of a hostname 649NI_MAXSERV nil Maximum length of a service name 650NI_NOFQDN nil An FQDN is not required for local hosts, return only the local part 651NI_NUMERICHOST nil Return a numeric address 652NI_NAMEREQD nil A name is required 653NI_NUMERICSERV nil Return the service name as a digit string 654NI_DGRAM nil The service specified is a datagram service (looks up UDP ports) 655 656SHUT_RD 0 Shut down the reading side of the socket 657SHUT_WR 1 Shut down the writing side of the socket 658SHUT_RDWR 2 Shut down the both sides of the socket 659 660IPV6_JOIN_GROUP nil Join a group membership 661IPV6_LEAVE_GROUP nil Leave a group membership 662IPV6_MULTICAST_HOPS nil IP6 multicast hops 663IPV6_MULTICAST_IF nil IP6 multicast interface 664IPV6_MULTICAST_LOOP nil IP6 multicast loopback 665IPV6_UNICAST_HOPS nil IP6 unicast hops 666IPV6_V6ONLY nil Only bind IPv6 with a wildcard bind 667IPV6_CHECKSUM nil Checksum offset for raw sockets 668IPV6_DONTFRAG nil Don't fragment packets 669IPV6_DSTOPTS nil Destination option 670IPV6_HOPLIMIT nil Hop limit 671IPV6_HOPOPTS nil Hop-by-hop option 672IPV6_NEXTHOP nil Next hop address 673IPV6_PATHMTU nil Retrieve current path MTU 674IPV6_PKTINFO nil Receive packet information with datagram 675IPV6_RECVDSTOPTS nil Receive all IP6 options for response 676IPV6_RECVHOPLIMIT nil Receive hop limit with datagram 677IPV6_RECVHOPOPTS nil Receive hop-by-hop options 678IPV6_RECVPKTINFO nil Receive destination IP address and incoming interface 679IPV6_RECVRTHDR nil Receive routing header 680IPV6_RECVTCLASS nil Receive traffic class 681IPV6_RTHDR nil Allows removal of sticky routing headers 682IPV6_RTHDRDSTOPTS nil Allows removal of sticky destination options header 683IPV6_RTHDR_TYPE_0 nil Routing header type 0 684IPV6_RECVPATHMTU nil Receive current path MTU with datagram 685IPV6_TCLASS nil Specify the traffic class 686IPV6_USE_MIN_MTU nil Use the minimum MTU size 687 688INET_ADDRSTRLEN 16 Maximum length of an IPv4 address string 689INET6_ADDRSTRLEN 46 Maximum length of an IPv6 address string 690IFNAMSIZ nil Maximum interface name size 691IF_NAMESIZE nil Maximum interface name size 692 693SOMAXCONN 5 Maximum connection requests that may be queued for a socket 694 695SCM_RIGHTS nil Access rights 696SCM_TIMESTAMP nil Timestamp (timeval) 697SCM_TIMESTAMPNS nil Timespec (timespec) 698SCM_BINTIME nil Timestamp (bintime) 699SCM_CREDENTIALS nil The sender's credentials 700SCM_CREDS nil Process credentials 701SCM_UCRED nil User credentials 702 703LOCAL_PEERCRED nil Retrieve peer credentials 704LOCAL_CREDS nil Pass credentials to receiver 705LOCAL_CONNWAIT nil Connect blocks until accepted 706