2009-01-01 01:08:41 -05:00
|
|
|
require 'optparse'
|
2009-01-01 01:28:34 -05:00
|
|
|
require 'erb'
|
2009-01-01 01:08:41 -05:00
|
|
|
|
|
|
|
opt = OptionParser.new
|
|
|
|
|
|
|
|
opt.def_option('-h', 'help') {
|
|
|
|
puts opt
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
opt_o = nil
|
|
|
|
opt.def_option('-o FILE', 'specify output file') {|filename|
|
|
|
|
opt_o = filename
|
|
|
|
}
|
|
|
|
|
2009-01-17 05:19:03 -05:00
|
|
|
opt_H = nil
|
|
|
|
opt.def_option('-H FILE', 'specify output header file') {|filename|
|
|
|
|
opt_H = filename
|
|
|
|
}
|
|
|
|
|
2009-01-01 01:28:34 -05:00
|
|
|
C_ESC = {
|
|
|
|
"\\" => "\\\\",
|
|
|
|
'"' => '\"',
|
|
|
|
"\n" => '\n',
|
|
|
|
}
|
|
|
|
|
|
|
|
0x00.upto(0x1f) {|ch| C_ESC[[ch].pack("C")] ||= "\\%03o" % ch }
|
|
|
|
0x7f.upto(0xff) {|ch| C_ESC[[ch].pack("C")] = "\\%03o" % ch }
|
|
|
|
C_ESC_PAT = Regexp.union(*C_ESC.keys)
|
|
|
|
|
|
|
|
def c_str(str)
|
2009-01-10 19:53:03 -05:00
|
|
|
'"' + str.gsub(C_ESC_PAT) {|s| C_ESC[s]} + '"'
|
2009-01-01 01:08:41 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
opt.parse!
|
2005-02-28 01:29:52 -05:00
|
|
|
|
2009-01-01 01:28:34 -05:00
|
|
|
|
2005-03-07 23:41:51 -05:00
|
|
|
|
2009-01-01 14:43:49 -05:00
|
|
|
h = {}
|
2009-01-01 02:49:31 -05:00
|
|
|
DATA.each_line {|s|
|
|
|
|
name, default_value = s.scan(/\S+/)
|
|
|
|
next unless name && name[0] != ?#
|
2009-01-17 00:53:05 -05:00
|
|
|
if h.has_key? name
|
|
|
|
warn "#{$.}: warning: duplicate name: #{name}"
|
|
|
|
next
|
|
|
|
end
|
2009-01-01 14:43:49 -05:00
|
|
|
h[name] = default_value
|
2009-01-01 02:49:31 -05:00
|
|
|
}
|
2009-01-01 14:43:49 -05:00
|
|
|
DEFS = h.to_a
|
2009-01-01 02:49:31 -05:00
|
|
|
|
|
|
|
def each_const
|
|
|
|
DEFS.each {|name, default_value|
|
2008-12-30 07:19:40 -05:00
|
|
|
if name =~ /\AINADDR_/
|
2009-02-16 11:55:33 -05:00
|
|
|
make_value = "UINT2NUM"
|
2008-12-30 07:19:40 -05:00
|
|
|
else
|
2009-02-16 11:55:33 -05:00
|
|
|
make_value = "INT2NUM"
|
2008-12-30 07:19:40 -05:00
|
|
|
end
|
2009-01-01 02:04:31 -05:00
|
|
|
guard = nil
|
2009-07-22 06:32:51 -04:00
|
|
|
if /\A(AF_INET6|PF_INET6|IPV6_.*)\z/ =~ name
|
2009-01-01 02:04:31 -05:00
|
|
|
# IPv6 is not supported although AF_INET6 is defined on bcc32/mingw
|
|
|
|
guard = "defined(INET6)"
|
|
|
|
end
|
2009-02-16 11:55:33 -05:00
|
|
|
yield guard, make_value, name, default_value
|
2009-01-01 01:28:34 -05:00
|
|
|
}
|
2005-02-28 01:29:52 -05:00
|
|
|
end
|
|
|
|
|
2009-01-01 02:49:31 -05:00
|
|
|
def each_name(pat)
|
|
|
|
DEFS.each {|name, default_value|
|
|
|
|
next if pat !~ name
|
|
|
|
yield name
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2009-01-19 08:32:31 -05:00
|
|
|
ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_const_decls")
|
2009-02-16 11:55:33 -05:00
|
|
|
% each_const {|guard, make_value, name, default_value|
|
2010-05-11 10:10:34 -04:00
|
|
|
#if !defined(<%=name%>)
|
|
|
|
# if defined(HAVE_CONST_<%=name.upcase%>)
|
|
|
|
# define <%=name%> <%=name%>
|
|
|
|
%if default_value
|
|
|
|
# else
|
|
|
|
# define <%=name%> <%=default_value%>
|
|
|
|
%end
|
|
|
|
# endif
|
2009-01-19 08:32:31 -05:00
|
|
|
#endif
|
|
|
|
% }
|
|
|
|
EOS
|
2009-01-18 19:23:48 -05:00
|
|
|
|
2009-02-16 11:55:33 -05:00
|
|
|
ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_const_defs_in_guard(make_value, name, default_value)")
|
2009-01-10 06:52:06 -05:00
|
|
|
#if defined(<%=name%>)
|
2010-03-21 06:50:52 -04:00
|
|
|
/* <%=name%>: */
|
2009-02-16 11:55:33 -05:00
|
|
|
rb_define_const(rb_cSocket, <%=c_str name%>, <%=make_value%>(<%=name%>));
|
2010-03-21 06:50:52 -04:00
|
|
|
/* <%=name%>: */
|
2009-02-16 11:55:33 -05:00
|
|
|
rb_define_const(rb_mSockConst, <%=c_str name%>, <%=make_value%>(<%=name%>));
|
2009-01-10 06:52:06 -05:00
|
|
|
#endif
|
|
|
|
EOS
|
|
|
|
|
|
|
|
ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_const_defs")
|
2009-02-16 11:55:33 -05:00
|
|
|
% each_const {|guard, make_value, name, default_value|
|
2009-01-10 06:52:06 -05:00
|
|
|
% if guard
|
|
|
|
#if <%=guard%>
|
2009-02-16 11:55:33 -05:00
|
|
|
<%= gen_const_defs_in_guard(make_value, name, default_value).chomp %>
|
2009-01-10 06:52:06 -05:00
|
|
|
#endif
|
|
|
|
% else
|
2009-02-16 11:55:33 -05:00
|
|
|
<%= gen_const_defs_in_guard(make_value, name, default_value).chomp %>
|
2009-01-10 06:52:06 -05:00
|
|
|
% end
|
|
|
|
% }
|
|
|
|
EOS
|
|
|
|
|
2009-01-02 01:01:57 -05:00
|
|
|
def reverse_each_name(pat)
|
|
|
|
DEFS.reverse_each {|name, default_value|
|
|
|
|
next if pat !~ name
|
|
|
|
yield name
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2009-01-02 01:33:24 -05:00
|
|
|
def each_names_with_len(pat, prefix_optional=nil)
|
2009-01-01 03:03:36 -05:00
|
|
|
h = {}
|
|
|
|
DEFS.each {|name, default_value|
|
|
|
|
next if pat !~ name
|
2009-01-02 01:33:24 -05:00
|
|
|
(h[name.length] ||= []) << [name, name]
|
|
|
|
}
|
|
|
|
if prefix_optional
|
|
|
|
if Regexp === prefix_optional
|
|
|
|
prefix_pat = prefix_optional
|
|
|
|
else
|
|
|
|
prefix_pat = /\A#{Regexp.escape prefix_optional}/
|
|
|
|
end
|
|
|
|
DEFS.each {|const, default_value|
|
|
|
|
next if pat !~ const
|
|
|
|
next if prefix_pat !~ const
|
|
|
|
name = $'
|
|
|
|
(h[name.length] ||= []) << [name, const]
|
|
|
|
}
|
|
|
|
end
|
|
|
|
hh = {}
|
|
|
|
h.each {|len, pairs|
|
|
|
|
pairs.each {|name, const|
|
|
|
|
raise "name crash: #{name}" if hh[name]
|
|
|
|
hh[name] = true
|
|
|
|
}
|
2009-01-01 03:03:36 -05:00
|
|
|
}
|
|
|
|
h.keys.sort.each {|len|
|
|
|
|
yield h[len], len
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2009-01-17 05:19:03 -05:00
|
|
|
ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_name_to_int_decl(funcname, pat, prefix_optional, guard=nil)")
|
|
|
|
%if guard
|
|
|
|
#ifdef <%=guard%>
|
2010-04-28 04:14:13 -04:00
|
|
|
int <%=funcname%>(const char *str, long len, int *valp);
|
2009-01-17 05:19:03 -05:00
|
|
|
#endif
|
|
|
|
%else
|
2010-04-28 04:14:13 -04:00
|
|
|
int <%=funcname%>(const char *str, long len, int *valp);
|
2009-01-17 05:19:03 -05:00
|
|
|
%end
|
|
|
|
EOS
|
|
|
|
|
2009-01-10 06:52:06 -05:00
|
|
|
ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_name_to_int_func_in_guard(funcname, pat, prefix_optional, guard=nil)")
|
2009-01-16 23:11:27 -05:00
|
|
|
int
|
2010-04-28 04:14:13 -04:00
|
|
|
<%=funcname%>(const char *str, long len, int *valp)
|
2009-01-08 09:00:34 -05:00
|
|
|
{
|
|
|
|
switch (len) {
|
2009-01-02 01:33:24 -05:00
|
|
|
% each_names_with_len(pat, prefix_optional) {|pairs, len|
|
2009-01-01 03:38:14 -05:00
|
|
|
case <%=len%>:
|
2009-01-02 01:33:24 -05:00
|
|
|
% pairs.each {|name, const|
|
|
|
|
#ifdef <%=const%>
|
2009-01-08 09:00:34 -05:00
|
|
|
if (memcmp(str, <%=c_str name%>, <%=len%>) == 0) { *valp = <%=const%>; return 0; }
|
2009-01-01 03:38:14 -05:00
|
|
|
#endif
|
|
|
|
% }
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
% }
|
|
|
|
default:
|
|
|
|
return -1;
|
|
|
|
}
|
2009-01-08 09:00:34 -05:00
|
|
|
}
|
2009-01-10 06:52:06 -05:00
|
|
|
EOS
|
|
|
|
|
|
|
|
ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_name_to_int_func(funcname, pat, prefix_optional, guard=nil)")
|
2009-01-08 09:00:34 -05:00
|
|
|
%if guard
|
2009-01-10 06:52:06 -05:00
|
|
|
#ifdef <%=guard%>
|
|
|
|
<%=gen_name_to_int_func_in_guard(funcname, pat, prefix_optional, guard)%>
|
2009-01-08 09:00:34 -05:00
|
|
|
#endif
|
2009-01-10 06:52:06 -05:00
|
|
|
%else
|
|
|
|
<%=gen_name_to_int_func_in_guard(funcname, pat, prefix_optional, guard)%>
|
2009-01-08 09:00:34 -05:00
|
|
|
%end
|
2009-01-01 03:38:14 -05:00
|
|
|
EOS
|
|
|
|
|
2009-01-17 05:19:03 -05:00
|
|
|
NAME_TO_INT_DEFS = []
|
|
|
|
def def_name_to_int(funcname, pat, prefix_optional, guard=nil)
|
|
|
|
decl = gen_name_to_int_decl(funcname, pat, prefix_optional, guard)
|
|
|
|
func = gen_name_to_int_func(funcname, pat, prefix_optional, guard)
|
|
|
|
NAME_TO_INT_DEFS << [decl, func]
|
|
|
|
end
|
|
|
|
|
2009-01-02 03:22:36 -05:00
|
|
|
def reverse_each_name_with_prefix_optional(pat, prefix_pat)
|
|
|
|
reverse_each_name(pat) {|n|
|
|
|
|
yield n, n
|
|
|
|
}
|
|
|
|
if prefix_pat
|
|
|
|
reverse_each_name(pat) {|n|
|
|
|
|
next if prefix_pat !~ n
|
|
|
|
yield n, $'
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-01-02 03:02:36 -05:00
|
|
|
ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_int_to_name_hash(hash_var, pat, prefix_pat)")
|
2009-01-02 01:01:57 -05:00
|
|
|
<%=hash_var%> = st_init_numtable();
|
2009-01-02 03:22:36 -05:00
|
|
|
% reverse_each_name_with_prefix_optional(pat, prefix_pat) {|n,s|
|
2009-01-02 00:33:56 -05:00
|
|
|
#ifdef <%=n%>
|
2009-01-11 22:34:48 -05:00
|
|
|
st_insert(<%=hash_var%>, (st_data_t)<%=n%>, (st_data_t)rb_intern2(<%=c_str s%>, <%=s.length%>));
|
2009-01-02 00:33:56 -05:00
|
|
|
#endif
|
|
|
|
% }
|
2009-01-02 01:01:57 -05:00
|
|
|
EOS
|
|
|
|
|
2009-01-02 03:02:36 -05:00
|
|
|
ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_int_to_name_func(func_name, hash_var)")
|
2009-01-16 23:11:27 -05:00
|
|
|
ID
|
2009-01-02 03:02:36 -05:00
|
|
|
<%=func_name%>(int val)
|
|
|
|
{
|
2009-01-02 01:01:57 -05:00
|
|
|
st_data_t name;
|
2009-01-02 03:02:36 -05:00
|
|
|
if (st_lookup(<%=hash_var%>, (st_data_t)val, &name))
|
2009-01-02 03:46:26 -05:00
|
|
|
return (ID)name;
|
|
|
|
return 0;
|
2009-01-02 03:02:36 -05:00
|
|
|
}
|
2009-01-01 05:37:41 -05:00
|
|
|
EOS
|
|
|
|
|
2009-01-17 05:19:03 -05:00
|
|
|
ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_int_to_name_decl(func_name, hash_var)")
|
|
|
|
ID <%=func_name%>(int val);
|
|
|
|
EOS
|
|
|
|
|
2009-01-02 03:46:26 -05:00
|
|
|
INTERN_DEFS = []
|
|
|
|
def def_intern(func_name, pat, prefix_optional=nil)
|
2009-01-02 03:02:36 -05:00
|
|
|
prefix_pat = nil
|
|
|
|
if prefix_optional
|
|
|
|
if Regexp === prefix_optional
|
|
|
|
prefix_pat = prefix_optional
|
|
|
|
else
|
|
|
|
prefix_pat = /\A#{Regexp.escape prefix_optional}/
|
|
|
|
end
|
|
|
|
end
|
|
|
|
hash_var = "#{func_name}_hash"
|
2009-01-17 05:19:03 -05:00
|
|
|
vardef = "static st_table *#{hash_var};"
|
2009-01-02 03:02:36 -05:00
|
|
|
gen_hash = gen_int_to_name_hash(hash_var, pat, prefix_pat)
|
2009-01-17 05:19:03 -05:00
|
|
|
decl = gen_int_to_name_decl(func_name, hash_var)
|
2009-01-02 03:02:36 -05:00
|
|
|
func = gen_int_to_name_func(func_name, hash_var)
|
2009-01-17 05:19:03 -05:00
|
|
|
INTERN_DEFS << [vardef, gen_hash, decl, func]
|
2009-01-02 03:02:36 -05:00
|
|
|
end
|
|
|
|
|
2009-03-01 01:30:41 -05:00
|
|
|
def_name_to_int("rsock_family_to_int", /\A(AF_|PF_)/, "AF_")
|
|
|
|
def_name_to_int("rsock_socktype_to_int", /\ASOCK_/, "SOCK_")
|
|
|
|
def_name_to_int("rsock_ipproto_to_int", /\AIPPROTO_/, "IPPROTO_")
|
|
|
|
def_name_to_int("rsock_unknown_level_to_int", /\ASOL_SOCKET\z/, "SOL_")
|
|
|
|
def_name_to_int("rsock_ip_level_to_int", /\A(SOL_SOCKET\z|IPPROTO_)/, /\A(SOL_|IPPROTO_)/)
|
|
|
|
def_name_to_int("rsock_so_optname_to_int", /\ASO_/, "SO_")
|
|
|
|
def_name_to_int("rsock_ip_optname_to_int", /\AIP_/, "IP_")
|
|
|
|
def_name_to_int("rsock_ipv6_optname_to_int", /\AIPV6_/, "IPV6_", "IPPROTO_IPV6")
|
|
|
|
def_name_to_int("rsock_tcp_optname_to_int", /\ATCP_/, "TCP_")
|
|
|
|
def_name_to_int("rsock_udp_optname_to_int", /\AUDP_/, "UDP_")
|
|
|
|
def_name_to_int("rsock_shutdown_how_to_int", /\ASHUT_/, "SHUT_")
|
|
|
|
def_name_to_int("rsock_scm_optname_to_int", /\ASCM_/, "SCM_")
|
|
|
|
|
|
|
|
def_intern('rsock_intern_family', /\AAF_/)
|
|
|
|
def_intern('rsock_intern_family_noprefix', /\AAF_/, "AF_")
|
|
|
|
def_intern('rsock_intern_protocol_family', /\APF_/)
|
|
|
|
def_intern('rsock_intern_socktype', /\ASOCK_/)
|
|
|
|
def_intern('rsock_intern_ipproto', /\AIPPROTO_/)
|
|
|
|
def_intern('rsock_intern_iplevel', /\A(SOL_SOCKET\z|IPPROTO_)/, /\A(SOL_|IPPROTO_)/)
|
|
|
|
def_intern('rsock_intern_so_optname', /\ASO_/, "SO_")
|
|
|
|
def_intern('rsock_intern_ip_optname', /\AIP_/, "IP_")
|
|
|
|
def_intern('rsock_intern_ipv6_optname', /\AIPV6_/, "IPV6_")
|
|
|
|
def_intern('rsock_intern_tcp_optname', /\ATCP_/, "TCP_")
|
|
|
|
def_intern('rsock_intern_udp_optname', /\AUDP_/, "UDP_")
|
|
|
|
def_intern('rsock_intern_scm_optname', /\ASCM_/, "SCM_")
|
|
|
|
def_intern('rsock_intern_local_optname', /\ALOCAL_/, "LOCAL_")
|
2009-01-02 03:02:36 -05:00
|
|
|
|
2009-01-20 06:06:22 -05:00
|
|
|
result = ERB.new(<<'EOS', nil, '%').result(binding)
|
|
|
|
/* autogenerated file */
|
2009-01-02 01:01:57 -05:00
|
|
|
|
2009-01-17 05:19:03 -05:00
|
|
|
<%= INTERN_DEFS.map {|vardef, gen_hash, decl, func| vardef }.join("\n") %>
|
2009-01-02 01:01:57 -05:00
|
|
|
|
2010-03-21 06:50:52 -04:00
|
|
|
/*
|
2010-03-21 20:48:51 -04:00
|
|
|
* Document-module: ::Socket::Constants
|
|
|
|
*
|
|
|
|
* Socket::Constants provides socket related constants.
|
|
|
|
* Following lists possible constants.
|
|
|
|
* If underlying platform doesn't define a constant,
|
|
|
|
* the corresponding Ruby constant is not defined.
|
|
|
|
*
|
2010-03-21 06:50:52 -04:00
|
|
|
*/
|
2009-01-01 02:09:19 -05:00
|
|
|
static void
|
2009-02-16 11:55:33 -05:00
|
|
|
init_constants(void)
|
2009-01-01 02:09:19 -05:00
|
|
|
{
|
2010-03-21 06:50:52 -04:00
|
|
|
rb_mSockConst = rb_define_module_under(rb_cSocket, "Constants");
|
2009-02-16 11:55:33 -05:00
|
|
|
|
2009-01-10 06:52:06 -05:00
|
|
|
<%= gen_const_defs %>
|
2009-01-17 05:19:03 -05:00
|
|
|
<%= INTERN_DEFS.map {|vardef, gen_hash, decl, func| gen_hash }.join("\n") %>
|
2009-01-01 02:09:19 -05:00
|
|
|
}
|
2009-01-01 02:49:31 -05:00
|
|
|
|
2009-01-17 05:19:03 -05:00
|
|
|
<%= NAME_TO_INT_DEFS.map {|decl, func| func }.join("\n") %>
|
|
|
|
|
|
|
|
<%= INTERN_DEFS.map {|vardef, gen_hash, decl, func| func }.join("\n") %>
|
2009-01-01 12:40:41 -05:00
|
|
|
|
2009-01-17 05:19:03 -05:00
|
|
|
EOS
|
|
|
|
|
|
|
|
header_result = ERB.new(<<'EOS', nil, '%').result(binding)
|
2009-01-20 06:06:22 -05:00
|
|
|
/* autogenerated file */
|
2009-01-19 08:32:31 -05:00
|
|
|
<%= gen_const_decls %>
|
2009-01-17 05:19:03 -05:00
|
|
|
<%= NAME_TO_INT_DEFS.map {|decl, func| decl }.join("\n") %>
|
|
|
|
<%= INTERN_DEFS.map {|vardef, gen_hash, decl, func| decl }.join("\n") %>
|
2009-01-01 01:28:34 -05:00
|
|
|
EOS
|
|
|
|
|
2009-01-17 05:19:03 -05:00
|
|
|
if opt_H
|
|
|
|
File.open(opt_H, 'w') {|f|
|
|
|
|
f << header_result
|
|
|
|
}
|
2009-01-20 06:06:22 -05:00
|
|
|
else
|
|
|
|
result = header_result + result
|
2009-01-17 05:19:03 -05:00
|
|
|
end
|
|
|
|
|
2009-01-01 01:08:41 -05:00
|
|
|
if opt_o
|
|
|
|
File.open(opt_o, 'w') {|f|
|
2009-01-01 01:28:34 -05:00
|
|
|
f << result
|
2009-01-01 01:08:41 -05:00
|
|
|
}
|
|
|
|
else
|
2009-01-01 01:28:34 -05:00
|
|
|
$stdout << result
|
2009-01-01 01:08:41 -05:00
|
|
|
end
|
|
|
|
|
2005-02-28 01:29:52 -05:00
|
|
|
__END__
|
|
|
|
|
|
|
|
SOCK_STREAM
|
|
|
|
SOCK_DGRAM
|
|
|
|
SOCK_RAW
|
|
|
|
SOCK_RDM
|
|
|
|
SOCK_SEQPACKET
|
|
|
|
SOCK_PACKET
|
|
|
|
|
2009-01-02 00:12:14 -05:00
|
|
|
AF_UNSPEC
|
|
|
|
PF_UNSPEC
|
2005-02-28 01:29:52 -05:00
|
|
|
AF_INET
|
|
|
|
PF_INET
|
2009-01-01 02:04:31 -05:00
|
|
|
AF_INET6
|
|
|
|
PF_INET6
|
2005-02-28 01:29:52 -05:00
|
|
|
AF_UNIX
|
|
|
|
PF_UNIX
|
|
|
|
AF_AX25
|
|
|
|
PF_AX25
|
|
|
|
AF_IPX
|
|
|
|
PF_IPX
|
|
|
|
AF_APPLETALK
|
|
|
|
PF_APPLETALK
|
|
|
|
AF_LOCAL
|
|
|
|
PF_LOCAL
|
|
|
|
AF_IMPLINK
|
|
|
|
PF_IMPLINK
|
|
|
|
AF_PUP
|
|
|
|
PF_PUP
|
|
|
|
AF_CHAOS
|
|
|
|
PF_CHAOS
|
|
|
|
AF_NS
|
|
|
|
PF_NS
|
|
|
|
AF_ISO
|
|
|
|
PF_ISO
|
|
|
|
AF_OSI
|
|
|
|
PF_OSI
|
|
|
|
AF_ECMA
|
|
|
|
PF_ECMA
|
|
|
|
AF_DATAKIT
|
|
|
|
PF_DATAKIT
|
|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
|
|
MSG_RCVMORE
|
|
|
|
MSG_COMPAT
|
2009-03-05 22:56:38 -05:00
|
|
|
MSG_PROXY
|
|
|
|
MSG_FIN
|
|
|
|
MSG_SYN
|
|
|
|
MSG_CONFIRM
|
|
|
|
MSG_RST
|
|
|
|
MSG_ERRQUEUE
|
|
|
|
MSG_NOSIGNAL
|
|
|
|
MSG_MORE
|
2005-02-28 01:29:52 -05:00
|
|
|
|
|
|
|
SOL_SOCKET
|
|
|
|
SOL_IP
|
|
|
|
SOL_IPX
|
|
|
|
SOL_AX25
|
|
|
|
SOL_ATALK
|
|
|
|
SOL_TCP
|
|
|
|
SOL_UDP
|
|
|
|
|
|
|
|
IPPROTO_IP 0
|
|
|
|
IPPROTO_ICMP 1
|
|
|
|
IPPROTO_IGMP
|
|
|
|
IPPROTO_GGP
|
|
|
|
IPPROTO_TCP 6
|
|
|
|
IPPROTO_EGP
|
|
|
|
IPPROTO_PUP
|
|
|
|
IPPROTO_UDP 17
|
|
|
|
IPPROTO_IDP
|
|
|
|
IPPROTO_HELLO
|
|
|
|
IPPROTO_ND
|
|
|
|
IPPROTO_TP
|
|
|
|
IPPROTO_XTP
|
|
|
|
IPPROTO_EON
|
|
|
|
IPPROTO_BIP
|
2008-09-15 23:13:14 -04:00
|
|
|
IPPROTO_AH
|
|
|
|
IPPROTO_DSTOPTS
|
|
|
|
IPPROTO_ESP
|
|
|
|
IPPROTO_FRAGMENT
|
|
|
|
IPPROTO_HOPOPTS
|
|
|
|
IPPROTO_ICMPV6
|
|
|
|
IPPROTO_IPV6
|
|
|
|
IPPROTO_NONE
|
|
|
|
IPPROTO_ROUTING
|
|
|
|
|
2005-02-28 01:29:52 -05:00
|
|
|
IPPROTO_RAW 255
|
|
|
|
IPPROTO_MAX
|
|
|
|
|
|
|
|
# Some port configuration
|
|
|
|
IPPORT_RESERVED 1024
|
|
|
|
IPPORT_USERRESERVED 5000
|
|
|
|
|
|
|
|
# Some reserved IP v.4 addresses
|
|
|
|
INADDR_ANY 0x00000000
|
|
|
|
INADDR_BROADCAST 0xffffffff
|
|
|
|
INADDR_LOOPBACK 0x7F000001
|
|
|
|
INADDR_UNSPEC_GROUP 0xe0000000
|
|
|
|
INADDR_ALLHOSTS_GROUP 0xe0000001
|
|
|
|
INADDR_MAX_LOCAL_GROUP 0xe00000ff
|
|
|
|
INADDR_NONE 0xffffffff
|
|
|
|
|
|
|
|
# IP [gs]etsockopt options
|
|
|
|
IP_OPTIONS
|
|
|
|
IP_HDRINCL
|
|
|
|
IP_TOS
|
|
|
|
IP_TTL
|
|
|
|
IP_RECVOPTS
|
|
|
|
IP_RECVRETOPTS
|
|
|
|
IP_RECVDSTADDR
|
|
|
|
IP_RETOPTS
|
2009-01-01 12:40:41 -05:00
|
|
|
IP_MINTTL
|
|
|
|
IP_DONTFRAG
|
|
|
|
IP_SENDSRCADDR
|
|
|
|
IP_ONESBCAST
|
|
|
|
IP_RECVTTL
|
|
|
|
IP_RECVIF
|
2009-02-09 06:00:45 -05:00
|
|
|
IP_RECVSLLA
|
2009-01-01 12:40:41 -05:00
|
|
|
IP_PORTRANGE
|
2005-02-28 01:29:52 -05:00
|
|
|
IP_MULTICAST_IF
|
|
|
|
IP_MULTICAST_TTL
|
|
|
|
IP_MULTICAST_LOOP
|
|
|
|
IP_ADD_MEMBERSHIP
|
|
|
|
IP_DROP_MEMBERSHIP
|
|
|
|
IP_DEFAULT_MULTICAST_TTL
|
|
|
|
IP_DEFAULT_MULTICAST_LOOP
|
|
|
|
IP_MAX_MEMBERSHIPS
|
2009-02-01 21:51:02 -05:00
|
|
|
IP_ROUTER_ALERT
|
|
|
|
IP_PKTINFO
|
|
|
|
IP_PKTOPTIONS
|
|
|
|
IP_MTU_DISCOVER
|
|
|
|
IP_RECVERR
|
|
|
|
IP_RECVTOS
|
|
|
|
IP_MTU
|
|
|
|
IP_FREEBIND
|
|
|
|
IP_IPSEC_POLICY
|
|
|
|
IP_XFRM_POLICY
|
|
|
|
IP_PASSSEC
|
|
|
|
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TICATION
|
|
|
|
SO_SECURITY_ENCRYPTION_TRANSPORT
|
|
|
|
SO_SECURITY_ENCRYPTION_NETWORK
|
|
|
|
SO_BINDTODEVICE
|
|
|
|
SO_ATTACH_FILTER
|
|
|
|
SO_DETACH_FILTER
|
|
|
|
SO_PEERNAME
|
|
|
|
SO_TIMESTAMP
|
2009-02-22 13:20:11 -05:00
|
|
|
SO_TIMESTAMPNS
|
2009-01-17 00:53:05 -05:00
|
|
|
SO_BINTIME
|
2009-02-09 06:00:45 -05:00
|
|
|
SO_RECVUCRED
|
|
|
|
SO_MAC_EXEMPT
|
|
|
|
SO_ALLZONES
|
2005-02-28 01:29:52 -05:00
|
|
|
|
|
|
|
SOPRI_INTERACTIVE
|
|
|
|
SOPRI_NORMAL
|
|
|
|
SOPRI_BACKGROUND
|
|
|
|
|
|
|
|
IPX_TYPE
|
|
|
|
|
|
|
|
TCP_NODELAY
|
|
|
|
TCP_MAXSEG
|
2009-01-01 12:40:41 -05:00
|
|
|
TCP_CORK
|
|
|
|
TCP_DEFER_ACCEPT
|
|
|
|
TCP_INFO
|
|
|
|
TCP_KEEPCNT
|
|
|
|
TCP_KEEPIDLE
|
|
|
|
TCP_KEEPINTVL
|
|
|
|
TCP_LINGER2
|
|
|
|
TCP_MD5SIG
|
|
|
|
TCP_NOOPT
|
|
|
|
TCP_NOPUSH
|
|
|
|
TCP_QUICKACK
|
|
|
|
TCP_SYNCNT
|
|
|
|
TCP_WINDOW_CLAMP
|
|
|
|
|
|
|
|
UDP_CORK
|
2005-02-28 01:29:52 -05:00
|
|
|
|
|
|
|
EAI_ADDRFAMILY
|
|
|
|
EAI_AGAIN
|
|
|
|
EAI_BADFLAGS
|
|
|
|
EAI_FAIL
|
|
|
|
EAI_FAMILY
|
|
|
|
EAI_MEMORY
|
|
|
|
EAI_NODATA
|
|
|
|
EAI_NONAME
|
2008-09-15 23:13:14 -04:00
|
|
|
EAI_OVERFLOW
|
2005-02-28 01:29:52 -05:00
|
|
|
EAI_SERVICE
|
|
|
|
EAI_SOCKTYPE
|
|
|
|
EAI_SYSTEM
|
|
|
|
EAI_BADHINTS
|
|
|
|
EAI_PROTOCOL
|
|
|
|
EAI_MAX
|
2005-02-28 09:18:41 -05:00
|
|
|
|
2005-02-28 01:29:52 -05:00
|
|
|
AI_PASSIVE
|
|
|
|
AI_CANONNAME
|
|
|
|
AI_NUMERICHOST
|
2008-09-15 23:13:14 -04:00
|
|
|
AI_NUMERICSERV
|
2005-02-28 01:29:52 -05:00
|
|
|
AI_MASK
|
|
|
|
AI_ALL
|
|
|
|
AI_V4MAPPED_CFG
|
|
|
|
AI_ADDRCONFIG
|
|
|
|
AI_V4MAPPED
|
|
|
|
AI_DEFAULT
|
2005-02-28 09:18:41 -05:00
|
|
|
|
2005-02-28 01:29:52 -05:00
|
|
|
NI_MAXHOST
|
|
|
|
NI_MAXSERV
|
|
|
|
NI_NOFQDN
|
|
|
|
NI_NUMERICHOST
|
|
|
|
NI_NAMEREQD
|
|
|
|
NI_NUMERICSERV
|
|
|
|
NI_DGRAM
|
2005-02-28 09:18:41 -05:00
|
|
|
|
2005-02-28 01:29:52 -05:00
|
|
|
SHUT_RD 0
|
|
|
|
SHUT_WR 1
|
|
|
|
SHUT_RDWR 2
|
2008-09-06 08:38:59 -04:00
|
|
|
|
|
|
|
IPV6_JOIN_GROUP
|
|
|
|
IPV6_LEAVE_GROUP
|
|
|
|
IPV6_MULTICAST_HOPS
|
|
|
|
IPV6_MULTICAST_IF
|
|
|
|
IPV6_MULTICAST_LOOP
|
|
|
|
IPV6_UNICAST_HOPS
|
|
|
|
IPV6_V6ONLY
|
|
|
|
IPV6_CHECKSUM
|
|
|
|
IPV6_DONTFRAG
|
|
|
|
IPV6_DSTOPTS
|
|
|
|
IPV6_HOPLIMIT
|
|
|
|
IPV6_HOPOPTS
|
|
|
|
IPV6_NEXTHOP
|
|
|
|
IPV6_PATHMTU
|
|
|
|
IPV6_PKTINFO
|
|
|
|
IPV6_RECVDSTOPTS
|
|
|
|
IPV6_RECVHOPLIMIT
|
|
|
|
IPV6_RECVHOPOPTS
|
|
|
|
IPV6_RECVPKTINFO
|
|
|
|
IPV6_RECVRTHDR
|
|
|
|
IPV6_RECVTCLASS
|
|
|
|
IPV6_RTHDR
|
|
|
|
IPV6_RTHDRDSTOPTS
|
|
|
|
IPV6_RTHDR_TYPE_0
|
|
|
|
IPV6_RECVPATHMTU
|
|
|
|
IPV6_TCLASS
|
|
|
|
IPV6_USE_MIN_MTU
|
2008-09-15 23:13:14 -04:00
|
|
|
|
2010-12-26 11:31:01 -05:00
|
|
|
INET_ADDRSTRLEN 16
|
|
|
|
INET6_ADDRSTRLEN 46
|
2009-02-13 09:49:40 -05:00
|
|
|
IFNAMSIZ
|
2010-12-26 11:31:01 -05:00
|
|
|
IF_NAMESIZE
|
2009-01-19 11:16:05 -05:00
|
|
|
|
|
|
|
SOMAXCONN
|
2009-02-01 21:51:02 -05:00
|
|
|
|
|
|
|
SCM_RIGHTS
|
2009-02-08 05:24:51 -05:00
|
|
|
SCM_TIMESTAMP
|
2009-02-22 13:20:11 -05:00
|
|
|
SCM_TIMESTAMPNS
|
2009-02-23 06:32:43 -05:00
|
|
|
SCM_BINTIME
|
2009-02-24 07:08:23 -05:00
|
|
|
SCM_CREDENTIALS
|
|
|
|
SCM_CREDS
|
|
|
|
SCM_UCRED
|
2009-02-08 05:24:51 -05:00
|
|
|
|
|
|
|
LOCAL_PEERCRED
|
|
|
|
LOCAL_CREDS
|
|
|
|
LOCAL_CONNWAIT
|