PageRenderTime 288ms CodeModel.GetById 219ms app.highlight 40ms RepoModel.GetById 20ms app.codeStats 1ms

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