summaryrefslogtreecommitdiff
path: root/ext/socket/mkconstants.rb
diff options
context:
space:
mode:
Diffstat (limited to 'ext/socket/mkconstants.rb')
-rw-r--r--ext/socket/mkconstants.rb86
1 files changed, 63 insertions, 23 deletions
diff --git a/ext/socket/mkconstants.rb b/ext/socket/mkconstants.rb
index 620a5f60ff..4271e40cd8 100644
--- a/ext/socket/mkconstants.rb
+++ b/ext/socket/mkconstants.rb
@@ -51,7 +51,10 @@ DATA.each_line {|s|
next
end
h[name] = default_value
- COMMENTS[name] = comment
+ if comment
+ # Stop unintentional references
+ COMMENTS[name] = comment.gsub(/\b(Data|Kernel|Process|Set|Socket|Time)\b/, '\\\\\\&')
+ end
}
DEFS = h.to_a
@@ -73,15 +76,11 @@ def each_name(pat)
}
end
-erb_new = lambda do |src, safe, trim|
- if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+
- ERB.new(src, trim_mode: trim)
- else
- ERB.new(src, safe, trim)
- end
+erb_new = lambda do |src, trim|
+ ERB.new(src, trim_mode: trim)
end
-erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_const_decls")
+erb_new.call(<<'EOS', '%').def_method(Object, "gen_const_decls")
% each_const {|guard, name, default_value|
#if !defined(<%=name%>)
# if defined(HAVE_CONST_<%=name.upcase%>)
@@ -95,7 +94,7 @@ erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_const_decls")
% }
EOS
-erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_const_defs_in_guard(name, default_value)")
+erb_new.call(<<'EOS', '%').def_method(Object, "gen_const_defs_in_guard(name, default_value)")
#if defined(<%=name%>)
/* <%= COMMENTS[name] %> */
rb_define_const(rb_cSocket, <%=c_str name%>, INTEGER2NUM(<%=name%>));
@@ -104,7 +103,7 @@ erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_const_defs_in_guard(name
#endif
EOS
-erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_const_defs")
+erb_new.call(<<'EOS', '%').def_method(Object, "gen_const_defs")
% each_const {|guard, name, default_value|
% if guard
#if <%=guard%>
@@ -154,7 +153,7 @@ def each_names_with_len(pat, prefix_optional=nil)
}
end
-erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_name_to_int_decl(funcname, pat, prefix_optional, guard=nil)")
+erb_new.call(<<'EOS', '%').def_method(Object, "gen_name_to_int_decl(funcname, pat, prefix_optional, guard=nil)")
%if guard
#ifdef <%=guard%>
int <%=funcname%>(const char *str, long len, int *valp);
@@ -164,7 +163,7 @@ int <%=funcname%>(const char *str, long len, int *valp);
%end
EOS
-erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_name_to_int_func_in_guard(funcname, pat, prefix_optional, guard=nil)")
+erb_new.call(<<'EOS', '%').def_method(Object, "gen_name_to_int_func_in_guard(funcname, pat, prefix_optional, guard=nil)")
int
<%=funcname%>(const char *str, long len, int *valp)
{
@@ -186,7 +185,7 @@ int
}
EOS
-erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_name_to_int_func(funcname, pat, prefix_optional, guard=nil)")
+erb_new.call(<<'EOS', '%').def_method(Object, "gen_name_to_int_func(funcname, pat, prefix_optional, guard=nil)")
%if guard
#ifdef <%=guard%>
<%=gen_name_to_int_func_in_guard(funcname, pat, prefix_optional, guard)%>
@@ -215,7 +214,7 @@ def reverse_each_name_with_prefix_optional(pat, prefix_pat)
end
end
-erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_int_to_name_hash(hash_var, pat, prefix_pat)")
+erb_new.call(<<'EOS', '%').def_method(Object, "gen_int_to_name_hash(hash_var, pat, prefix_pat)")
<%=hash_var%> = st_init_numtable();
% reverse_each_name_with_prefix_optional(pat, prefix_pat) {|n,s|
#ifdef <%=n%>
@@ -224,7 +223,7 @@ erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_int_to_name_hash(hash_va
% }
EOS
-erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_int_to_name_func(func_name, hash_var)")
+erb_new.call(<<'EOS', '%').def_method(Object, "gen_int_to_name_func(func_name, hash_var)")
ID
<%=func_name%>(int val)
{
@@ -235,7 +234,7 @@ ID
}
EOS
-erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_int_to_name_decl(func_name, hash_var)")
+erb_new.call(<<'EOS', '%').def_method(Object, "gen_int_to_name_decl(func_name, hash_var)")
ID <%=func_name%>(int val);
EOS
@@ -284,7 +283,7 @@ def_intern('rsock_intern_udp_optname', /\AUDP_/, "UDP_")
def_intern('rsock_intern_scm_optname', /\ASCM_/, "SCM_")
def_intern('rsock_intern_local_optname', /\ALOCAL_/, "LOCAL_")
-result = erb_new.call(<<'EOS', nil, '%').result(binding)
+result = erb_new.call(<<'EOS', '%').result(binding)
/* autogenerated file */
<%= INTERN_DEFS.map {|vardef, gen_hash, decl, func| vardef }.join("\n") %>
@@ -327,7 +326,7 @@ init_constants(void)
EOS
-header_result = erb_new.call(<<'EOS', nil, '%').result(binding)
+header_result = erb_new.call(<<'EOS', '%').result(binding)
/* autogenerated file */
<%= gen_const_decls %>
<%= NAME_TO_INT_DEFS.map {|decl, func| decl }.join("\n") %>
@@ -358,6 +357,8 @@ SOCK_RAW nil A raw socket provides low-level access for direct access or impleme
SOCK_RDM nil A reliable datagram socket provides reliable delivery of messages
SOCK_SEQPACKET nil A sequential packet socket provides sequenced, reliable two-way connection for datagrams
SOCK_PACKET nil Device-level packet access
+SOCK_NONBLOCK nil Set the O_NONBLOCK file status flag on the open file description (see open(2)) referred to by the new file descriptor.
+SOCK_CLOEXEC nil Set the close-on-exec (FD_CLOEXEC) flag on the new file descriptor.
AF_UNSPEC nil Unspecified protocol, any supported address family
PF_UNSPEC nil Unspecified protocol, any supported address family
@@ -397,6 +398,8 @@ AF_SNA nil IBM SNA protocol
PF_SNA nil IBM SNA protocol
AF_DEC nil DECnet protocol
PF_DEC nil DECnet protocol
+AF_DECnet nil DECnet protocol
+PF_DECnet nil DECnet protocol
AF_DLI nil DEC Direct Data Link Interface protocol
PF_DLI nil DEC Direct Data Link Interface protocol
AF_LAT nil Local Area Transport protocol
@@ -419,8 +422,8 @@ AF_ISDN nil Integrated Services Digital Network
PF_ISDN nil Integrated Services Digital Network
AF_NATM nil Native ATM access
PF_NATM nil Native ATM access
-AF_SYSTEM
-PF_SYSTEM
+AF_SYSTEM nil Kernel event messages
+PF_SYSTEM nil Kernel event messages
AF_NETBIOS nil NetBIOS
PF_NETBIOS nil NetBIOS
AF_PPP nil Point-to-Point Protocol
@@ -436,9 +439,36 @@ PF_PACKET nil Direct link-layer access
AF_E164 nil CCITT (ITU-T) E.164 recommendation
PF_XTP nil eXpress Transfer Protocol
-PF_RTIP
-PF_PIP
-PF_KEY
+PF_RTIP nil Help Identify RTIP packets
+PF_PIP nil Help Identify PIP packets
+AF_KEY nil Key management protocol, originally developed for usage with IPsec
+PF_KEY nil Key management protocol, originally developed for usage with IPsec
+AF_NETLINK nil Kernel user interface device
+PF_NETLINK nil Kernel user interface device
+AF_RDS nil Reliable Datagram Sockets (RDS) protocol
+PF_RDS nil Reliable Datagram Sockets (RDS) protocol
+AF_PPPOX nil Generic PPP transport layer, for setting up L2 tunnels (L2TP and PPPoE)
+PF_PPPOX nil Generic PPP transport layer, for setting up L2 tunnels (L2TP and PPPoE)
+AF_LLC nil Logical link control (IEEE 802.2 LLC) protocol
+PF_LLC nil Logical link control (IEEE 802.2 LLC) protocol
+AF_IB nil InfiniBand native addressing
+PF_IB nil InfiniBand native addressing
+AF_MPLS nil Multiprotocol Label Switching
+PF_MPLS nil Multiprotocol Label Switching
+AF_CAN nil Controller Area Network automotive bus protocol
+PF_CAN nil Controller Area Network automotive bus protocol
+AF_TIPC nil TIPC, "cluster domain sockets" protocol
+PF_TIPC nil TIPC, "cluster domain sockets" protocol
+AF_BLUETOOTH nil Bluetooth low-level socket protocol
+PF_BLUETOOTH nil Bluetooth low-level socket protocol
+AF_ALG nil Interface to kernel crypto API
+PF_ALG nil Interface to kernel crypto API
+AF_VSOCK nil VSOCK (originally "VMWare VSockets") protocol for hypervisor-guest communication
+PF_VSOCK nil VSOCK (originally "VMWare VSockets") protocol for hypervisor-guest communication
+AF_KCM nil KCM (kernel connection multiplexor) interface
+PF_KCM nil KCM (kernel connection multiplexor) interface
+AF_XDP nil XDP (express data path) interface
+PF_XDP nil XDP (express data path) interface
MSG_OOB nil Process out-of-band data
MSG_PEEK nil Peek at incoming message
@@ -595,6 +625,7 @@ SO_SNDTIMEO nil Send timeout
SO_ACCEPTCONN nil Socket has had listen() called on it
SO_USELOOPBACK nil Bypass hardware when possible
SO_ACCEPTFILTER nil There is an accept filter
+SO_USER_COOKIE nil Setting an identifier for ipfw purpose mainly
SO_DONTTRUNC nil Retain unread data
SO_WANTMORE nil Give a hint when more data is ready
SO_WANTOOBFLAG nil OOB data is wanted in MSG_FLAG on receive
@@ -630,6 +661,11 @@ SO_SELECT_ERR_QUEUE nil Make select() detect socket error queue with err
SO_BUSY_POLL nil Set the threshold in microseconds for low latency polling (Linux 3.11)
SO_MAX_PACING_RATE nil Cap the rate computed by transport layer. [bytes per second] (Linux 3.13)
SO_BPF_EXTENSIONS nil Query supported BPF extensions (Linux 3.14)
+SO_SETFIB nil Set the associated routing table for the socket (FreeBSD)
+SO_RTABLE nil Set the routing table for this socket (OpenBSD)
+SO_INCOMING_CPU nil Receive the cpu attached to the socket (Linux 3.19)
+SO_INCOMING_NAPI_ID nil Receive the napi ID attached to a RX queue (Linux 4.12)
+SO_CONNECT_TIME nil Returns the number of seconds a socket has been connected. This option is only valid for connection-oriented protocols (Windows)
SOPRI_INTERACTIVE nil Interactive socket priority
SOPRI_NORMAL nil Normal socket priority
@@ -639,9 +675,11 @@ IPX_TYPE
TCP_NODELAY nil Don't delay sending to coalesce packets
TCP_MAXSEG nil Set maximum segment size
+TCP_CONNECTION_INFO nil Retrieve information about this socket (macOS)
TCP_CORK nil Don't send partial frames (Linux 2.2, glibc 2.2)
TCP_DEFER_ACCEPT nil Don't notify a listening socket until data is ready (Linux 2.4, glibc 2.2)
TCP_INFO nil Retrieve information about this socket (Linux 2.4, glibc 2.2)
+TCP_KEEPALIVE nil Idle time before keepalive probes are sent (macOS)
TCP_KEEPCNT nil Maximum number of keepalive probes allowed before dropping a connection (Linux 2.4, glibc 2.2)
TCP_KEEPIDLE nil Idle time before keepalive probes are sent (Linux 2.4, glibc 2.2)
TCP_KEEPINTVL nil Time between keepalive probes (Linux 2.4, glibc 2.2)
@@ -707,6 +745,7 @@ SHUT_RDWR 2 Shut down the both sides of the socket
IPV6_JOIN_GROUP nil Join a group membership
IPV6_LEAVE_GROUP nil Leave a group membership
+IPV6_MTU_DISCOVER nil Path MTU discovery
IPV6_MULTICAST_HOPS nil IP6 multicast hops
IPV6_MULTICAST_IF nil IP6 multicast interface
IPV6_MULTICAST_LOOP nil IP6 multicast loopback
@@ -721,6 +760,7 @@ IPV6_NEXTHOP nil Next hop address
IPV6_PATHMTU nil Retrieve current path MTU
IPV6_PKTINFO nil Receive packet information with datagram
IPV6_RECVDSTOPTS nil Receive all IP6 options for response
+IPV6_RECVERR nil Enable extended reliable error message passing
IPV6_RECVHOPLIMIT nil Receive hop limit with datagram
IPV6_RECVHOPOPTS nil Receive hop-by-hop options
IPV6_RECVPKTINFO nil Receive destination IP address and incoming interface