PageRenderTime 52ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/components/ruby-2.1.0/ext/socket/mkconstants.rb

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