1 /* autogenerated file */
2 
3 static st_table *rsock_intern_family_hash;
4 static st_table *rsock_intern_family_noprefix_hash;
5 static st_table *rsock_intern_protocol_family_hash;
6 static st_table *rsock_intern_socktype_hash;
7 static st_table *rsock_intern_ipproto_hash;
8 static st_table *rsock_intern_iplevel_hash;
9 static st_table *rsock_intern_so_optname_hash;
10 static st_table *rsock_intern_ip_optname_hash;
11 static st_table *rsock_intern_ipv6_optname_hash;
12 static st_table *rsock_intern_tcp_optname_hash;
13 static st_table *rsock_intern_udp_optname_hash;
14 static st_table *rsock_intern_scm_optname_hash;
15 static st_table *rsock_intern_local_optname_hash;
16 
17 #ifdef HAVE_LONG_LONG
18 #define INTEGER2NUM(n) \
19     (FIXNUM_MAX < (n) ? ULL2NUM(n) : \
20      FIXNUM_MIN > (LONG_LONG)(n) ? LL2NUM(n) : \
21      LONG2FIX(n))
22 #else
23 #define INTEGER2NUM(n) \
24     (FIXNUM_MAX < (n) ? ULONG2NUM(n) : \
25      FIXNUM_MIN > (long)(n) ? LONG2NUM(n) : \
26      LONG2FIX(n))
27 #endif
28 
29 static void
init_constants(void)30 init_constants(void)
31 {
32     /*
33      * Document-module: Socket::Constants
34      *
35      * Socket::Constants provides socket-related constants.  All possible
36      * socket constants are listed in the documentation but they may not all
37      * be present on your platform.
38      *
39      * If the underlying platform doesn't define a constant the corresponding
40      * Ruby constant is not defined.
41      *
42      */
43     rb_mSockConst = rb_define_module_under(rb_cSocket, "Constants");
44 
45 #if defined(SOCK_STREAM)
46     /* A stream socket provides a sequenced, reliable two-way connection for a byte stream */
47     rb_define_const(rb_cSocket, "SOCK_STREAM", INTEGER2NUM(SOCK_STREAM));
48     /* A stream socket provides a sequenced, reliable two-way connection for a byte stream */
49     rb_define_const(rb_mSockConst, "SOCK_STREAM", INTEGER2NUM(SOCK_STREAM));
50 #endif
51 #if defined(SOCK_DGRAM)
52     /* A datagram socket provides connectionless, unreliable messaging */
53     rb_define_const(rb_cSocket, "SOCK_DGRAM", INTEGER2NUM(SOCK_DGRAM));
54     /* A datagram socket provides connectionless, unreliable messaging */
55     rb_define_const(rb_mSockConst, "SOCK_DGRAM", INTEGER2NUM(SOCK_DGRAM));
56 #endif
57 #if defined(SOCK_RAW)
58     /* A raw socket provides low-level access for direct access or implementing network protocols */
59     rb_define_const(rb_cSocket, "SOCK_RAW", INTEGER2NUM(SOCK_RAW));
60     /* A raw socket provides low-level access for direct access or implementing network protocols */
61     rb_define_const(rb_mSockConst, "SOCK_RAW", INTEGER2NUM(SOCK_RAW));
62 #endif
63 #if defined(SOCK_RDM)
64     /* A reliable datagram socket provides reliable delivery of messages */
65     rb_define_const(rb_cSocket, "SOCK_RDM", INTEGER2NUM(SOCK_RDM));
66     /* A reliable datagram socket provides reliable delivery of messages */
67     rb_define_const(rb_mSockConst, "SOCK_RDM", INTEGER2NUM(SOCK_RDM));
68 #endif
69 #if defined(SOCK_SEQPACKET)
70     /* A sequential packet socket provides sequenced, reliable two-way connection for datagrams */
71     rb_define_const(rb_cSocket, "SOCK_SEQPACKET", INTEGER2NUM(SOCK_SEQPACKET));
72     /* A sequential packet socket provides sequenced, reliable two-way connection for datagrams */
73     rb_define_const(rb_mSockConst, "SOCK_SEQPACKET", INTEGER2NUM(SOCK_SEQPACKET));
74 #endif
75 #if defined(SOCK_PACKET)
76     /* Device-level packet access */
77     rb_define_const(rb_cSocket, "SOCK_PACKET", INTEGER2NUM(SOCK_PACKET));
78     /* Device-level packet access */
79     rb_define_const(rb_mSockConst, "SOCK_PACKET", INTEGER2NUM(SOCK_PACKET));
80 #endif
81 #if defined(AF_UNSPEC)
82     /* Unspecified protocol, any supported address family */
83     rb_define_const(rb_cSocket, "AF_UNSPEC", INTEGER2NUM(AF_UNSPEC));
84     /* Unspecified protocol, any supported address family */
85     rb_define_const(rb_mSockConst, "AF_UNSPEC", INTEGER2NUM(AF_UNSPEC));
86 #endif
87 #if defined(PF_UNSPEC)
88     /* Unspecified protocol, any supported address family */
89     rb_define_const(rb_cSocket, "PF_UNSPEC", INTEGER2NUM(PF_UNSPEC));
90     /* Unspecified protocol, any supported address family */
91     rb_define_const(rb_mSockConst, "PF_UNSPEC", INTEGER2NUM(PF_UNSPEC));
92 #endif
93 #if defined(AF_INET)
94     /* IPv4 protocol */
95     rb_define_const(rb_cSocket, "AF_INET", INTEGER2NUM(AF_INET));
96     /* IPv4 protocol */
97     rb_define_const(rb_mSockConst, "AF_INET", INTEGER2NUM(AF_INET));
98 #endif
99 #if defined(PF_INET)
100     /* IPv4 protocol */
101     rb_define_const(rb_cSocket, "PF_INET", INTEGER2NUM(PF_INET));
102     /* IPv4 protocol */
103     rb_define_const(rb_mSockConst, "PF_INET", INTEGER2NUM(PF_INET));
104 #endif
105 #if defined(INET6)
106 #if defined(AF_INET6)
107     /* IPv6 protocol */
108     rb_define_const(rb_cSocket, "AF_INET6", INTEGER2NUM(AF_INET6));
109     /* IPv6 protocol */
110     rb_define_const(rb_mSockConst, "AF_INET6", INTEGER2NUM(AF_INET6));
111 #endif
112 #endif
113 #if defined(INET6)
114 #if defined(PF_INET6)
115     /* IPv6 protocol */
116     rb_define_const(rb_cSocket, "PF_INET6", INTEGER2NUM(PF_INET6));
117     /* IPv6 protocol */
118     rb_define_const(rb_mSockConst, "PF_INET6", INTEGER2NUM(PF_INET6));
119 #endif
120 #endif
121 #if defined(AF_UNIX)
122     /* UNIX sockets */
123     rb_define_const(rb_cSocket, "AF_UNIX", INTEGER2NUM(AF_UNIX));
124     /* UNIX sockets */
125     rb_define_const(rb_mSockConst, "AF_UNIX", INTEGER2NUM(AF_UNIX));
126 #endif
127 #if defined(PF_UNIX)
128     /* UNIX sockets */
129     rb_define_const(rb_cSocket, "PF_UNIX", INTEGER2NUM(PF_UNIX));
130     /* UNIX sockets */
131     rb_define_const(rb_mSockConst, "PF_UNIX", INTEGER2NUM(PF_UNIX));
132 #endif
133 #if defined(AF_AX25)
134     /* AX.25 protocol */
135     rb_define_const(rb_cSocket, "AF_AX25", INTEGER2NUM(AF_AX25));
136     /* AX.25 protocol */
137     rb_define_const(rb_mSockConst, "AF_AX25", INTEGER2NUM(AF_AX25));
138 #endif
139 #if defined(PF_AX25)
140     /* AX.25 protocol */
141     rb_define_const(rb_cSocket, "PF_AX25", INTEGER2NUM(PF_AX25));
142     /* AX.25 protocol */
143     rb_define_const(rb_mSockConst, "PF_AX25", INTEGER2NUM(PF_AX25));
144 #endif
145 #if defined(AF_IPX)
146     /* IPX protocol */
147     rb_define_const(rb_cSocket, "AF_IPX", INTEGER2NUM(AF_IPX));
148     /* IPX protocol */
149     rb_define_const(rb_mSockConst, "AF_IPX", INTEGER2NUM(AF_IPX));
150 #endif
151 #if defined(PF_IPX)
152     /* IPX protocol */
153     rb_define_const(rb_cSocket, "PF_IPX", INTEGER2NUM(PF_IPX));
154     /* IPX protocol */
155     rb_define_const(rb_mSockConst, "PF_IPX", INTEGER2NUM(PF_IPX));
156 #endif
157 #if defined(AF_APPLETALK)
158     /* AppleTalk protocol */
159     rb_define_const(rb_cSocket, "AF_APPLETALK", INTEGER2NUM(AF_APPLETALK));
160     /* AppleTalk protocol */
161     rb_define_const(rb_mSockConst, "AF_APPLETALK", INTEGER2NUM(AF_APPLETALK));
162 #endif
163 #if defined(PF_APPLETALK)
164     /* AppleTalk protocol */
165     rb_define_const(rb_cSocket, "PF_APPLETALK", INTEGER2NUM(PF_APPLETALK));
166     /* AppleTalk protocol */
167     rb_define_const(rb_mSockConst, "PF_APPLETALK", INTEGER2NUM(PF_APPLETALK));
168 #endif
169 #if defined(AF_LOCAL)
170     /* Host-internal protocols */
171     rb_define_const(rb_cSocket, "AF_LOCAL", INTEGER2NUM(AF_LOCAL));
172     /* Host-internal protocols */
173     rb_define_const(rb_mSockConst, "AF_LOCAL", INTEGER2NUM(AF_LOCAL));
174 #endif
175 #if defined(PF_LOCAL)
176     /* Host-internal protocols */
177     rb_define_const(rb_cSocket, "PF_LOCAL", INTEGER2NUM(PF_LOCAL));
178     /* Host-internal protocols */
179     rb_define_const(rb_mSockConst, "PF_LOCAL", INTEGER2NUM(PF_LOCAL));
180 #endif
181 #if defined(AF_IMPLINK)
182     /* ARPANET IMP protocol */
183     rb_define_const(rb_cSocket, "AF_IMPLINK", INTEGER2NUM(AF_IMPLINK));
184     /* ARPANET IMP protocol */
185     rb_define_const(rb_mSockConst, "AF_IMPLINK", INTEGER2NUM(AF_IMPLINK));
186 #endif
187 #if defined(PF_IMPLINK)
188     /* ARPANET IMP protocol */
189     rb_define_const(rb_cSocket, "PF_IMPLINK", INTEGER2NUM(PF_IMPLINK));
190     /* ARPANET IMP protocol */
191     rb_define_const(rb_mSockConst, "PF_IMPLINK", INTEGER2NUM(PF_IMPLINK));
192 #endif
193 #if defined(AF_PUP)
194     /* PARC Universal Packet protocol */
195     rb_define_const(rb_cSocket, "AF_PUP", INTEGER2NUM(AF_PUP));
196     /* PARC Universal Packet protocol */
197     rb_define_const(rb_mSockConst, "AF_PUP", INTEGER2NUM(AF_PUP));
198 #endif
199 #if defined(PF_PUP)
200     /* PARC Universal Packet protocol */
201     rb_define_const(rb_cSocket, "PF_PUP", INTEGER2NUM(PF_PUP));
202     /* PARC Universal Packet protocol */
203     rb_define_const(rb_mSockConst, "PF_PUP", INTEGER2NUM(PF_PUP));
204 #endif
205 #if defined(AF_CHAOS)
206     /* MIT CHAOS protocols */
207     rb_define_const(rb_cSocket, "AF_CHAOS", INTEGER2NUM(AF_CHAOS));
208     /* MIT CHAOS protocols */
209     rb_define_const(rb_mSockConst, "AF_CHAOS", INTEGER2NUM(AF_CHAOS));
210 #endif
211 #if defined(PF_CHAOS)
212     /* MIT CHAOS protocols */
213     rb_define_const(rb_cSocket, "PF_CHAOS", INTEGER2NUM(PF_CHAOS));
214     /* MIT CHAOS protocols */
215     rb_define_const(rb_mSockConst, "PF_CHAOS", INTEGER2NUM(PF_CHAOS));
216 #endif
217 #if defined(AF_NS)
218     /* XEROX NS protocols */
219     rb_define_const(rb_cSocket, "AF_NS", INTEGER2NUM(AF_NS));
220     /* XEROX NS protocols */
221     rb_define_const(rb_mSockConst, "AF_NS", INTEGER2NUM(AF_NS));
222 #endif
223 #if defined(PF_NS)
224     /* XEROX NS protocols */
225     rb_define_const(rb_cSocket, "PF_NS", INTEGER2NUM(PF_NS));
226     /* XEROX NS protocols */
227     rb_define_const(rb_mSockConst, "PF_NS", INTEGER2NUM(PF_NS));
228 #endif
229 #if defined(AF_ISO)
230     /* ISO Open Systems Interconnection protocols */
231     rb_define_const(rb_cSocket, "AF_ISO", INTEGER2NUM(AF_ISO));
232     /* ISO Open Systems Interconnection protocols */
233     rb_define_const(rb_mSockConst, "AF_ISO", INTEGER2NUM(AF_ISO));
234 #endif
235 #if defined(PF_ISO)
236     /* ISO Open Systems Interconnection protocols */
237     rb_define_const(rb_cSocket, "PF_ISO", INTEGER2NUM(PF_ISO));
238     /* ISO Open Systems Interconnection protocols */
239     rb_define_const(rb_mSockConst, "PF_ISO", INTEGER2NUM(PF_ISO));
240 #endif
241 #if defined(AF_OSI)
242     /* ISO Open Systems Interconnection protocols */
243     rb_define_const(rb_cSocket, "AF_OSI", INTEGER2NUM(AF_OSI));
244     /* ISO Open Systems Interconnection protocols */
245     rb_define_const(rb_mSockConst, "AF_OSI", INTEGER2NUM(AF_OSI));
246 #endif
247 #if defined(PF_OSI)
248     /* ISO Open Systems Interconnection protocols */
249     rb_define_const(rb_cSocket, "PF_OSI", INTEGER2NUM(PF_OSI));
250     /* ISO Open Systems Interconnection protocols */
251     rb_define_const(rb_mSockConst, "PF_OSI", INTEGER2NUM(PF_OSI));
252 #endif
253 #if defined(AF_ECMA)
254     /* European Computer Manufacturers protocols */
255     rb_define_const(rb_cSocket, "AF_ECMA", INTEGER2NUM(AF_ECMA));
256     /* European Computer Manufacturers protocols */
257     rb_define_const(rb_mSockConst, "AF_ECMA", INTEGER2NUM(AF_ECMA));
258 #endif
259 #if defined(PF_ECMA)
260     /* European Computer Manufacturers protocols */
261     rb_define_const(rb_cSocket, "PF_ECMA", INTEGER2NUM(PF_ECMA));
262     /* European Computer Manufacturers protocols */
263     rb_define_const(rb_mSockConst, "PF_ECMA", INTEGER2NUM(PF_ECMA));
264 #endif
265 #if defined(AF_DATAKIT)
266     /* Datakit protocol */
267     rb_define_const(rb_cSocket, "AF_DATAKIT", INTEGER2NUM(AF_DATAKIT));
268     /* Datakit protocol */
269     rb_define_const(rb_mSockConst, "AF_DATAKIT", INTEGER2NUM(AF_DATAKIT));
270 #endif
271 #if defined(PF_DATAKIT)
272     /* Datakit protocol */
273     rb_define_const(rb_cSocket, "PF_DATAKIT", INTEGER2NUM(PF_DATAKIT));
274     /* Datakit protocol */
275     rb_define_const(rb_mSockConst, "PF_DATAKIT", INTEGER2NUM(PF_DATAKIT));
276 #endif
277 #if defined(AF_CCITT)
278     /* CCITT (now ITU-T) protocols */
279     rb_define_const(rb_cSocket, "AF_CCITT", INTEGER2NUM(AF_CCITT));
280     /* CCITT (now ITU-T) protocols */
281     rb_define_const(rb_mSockConst, "AF_CCITT", INTEGER2NUM(AF_CCITT));
282 #endif
283 #if defined(PF_CCITT)
284     /* CCITT (now ITU-T) protocols */
285     rb_define_const(rb_cSocket, "PF_CCITT", INTEGER2NUM(PF_CCITT));
286     /* CCITT (now ITU-T) protocols */
287     rb_define_const(rb_mSockConst, "PF_CCITT", INTEGER2NUM(PF_CCITT));
288 #endif
289 #if defined(AF_SNA)
290     /* IBM SNA protocol */
291     rb_define_const(rb_cSocket, "AF_SNA", INTEGER2NUM(AF_SNA));
292     /* IBM SNA protocol */
293     rb_define_const(rb_mSockConst, "AF_SNA", INTEGER2NUM(AF_SNA));
294 #endif
295 #if defined(PF_SNA)
296     /* IBM SNA protocol */
297     rb_define_const(rb_cSocket, "PF_SNA", INTEGER2NUM(PF_SNA));
298     /* IBM SNA protocol */
299     rb_define_const(rb_mSockConst, "PF_SNA", INTEGER2NUM(PF_SNA));
300 #endif
301 #if defined(AF_DEC)
302     /* DECnet protocol */
303     rb_define_const(rb_cSocket, "AF_DEC", INTEGER2NUM(AF_DEC));
304     /* DECnet protocol */
305     rb_define_const(rb_mSockConst, "AF_DEC", INTEGER2NUM(AF_DEC));
306 #endif
307 #if defined(PF_DEC)
308     /* DECnet protocol */
309     rb_define_const(rb_cSocket, "PF_DEC", INTEGER2NUM(PF_DEC));
310     /* DECnet protocol */
311     rb_define_const(rb_mSockConst, "PF_DEC", INTEGER2NUM(PF_DEC));
312 #endif
313 #if defined(AF_DLI)
314     /* DEC Direct Data Link Interface protocol */
315     rb_define_const(rb_cSocket, "AF_DLI", INTEGER2NUM(AF_DLI));
316     /* DEC Direct Data Link Interface protocol */
317     rb_define_const(rb_mSockConst, "AF_DLI", INTEGER2NUM(AF_DLI));
318 #endif
319 #if defined(PF_DLI)
320     /* DEC Direct Data Link Interface protocol */
321     rb_define_const(rb_cSocket, "PF_DLI", INTEGER2NUM(PF_DLI));
322     /* DEC Direct Data Link Interface protocol */
323     rb_define_const(rb_mSockConst, "PF_DLI", INTEGER2NUM(PF_DLI));
324 #endif
325 #if defined(AF_LAT)
326     /* Local Area Transport protocol */
327     rb_define_const(rb_cSocket, "AF_LAT", INTEGER2NUM(AF_LAT));
328     /* Local Area Transport protocol */
329     rb_define_const(rb_mSockConst, "AF_LAT", INTEGER2NUM(AF_LAT));
330 #endif
331 #if defined(PF_LAT)
332     /* Local Area Transport protocol */
333     rb_define_const(rb_cSocket, "PF_LAT", INTEGER2NUM(PF_LAT));
334     /* Local Area Transport protocol */
335     rb_define_const(rb_mSockConst, "PF_LAT", INTEGER2NUM(PF_LAT));
336 #endif
337 #if defined(AF_HYLINK)
338     /* NSC Hyperchannel protocol */
339     rb_define_const(rb_cSocket, "AF_HYLINK", INTEGER2NUM(AF_HYLINK));
340     /* NSC Hyperchannel protocol */
341     rb_define_const(rb_mSockConst, "AF_HYLINK", INTEGER2NUM(AF_HYLINK));
342 #endif
343 #if defined(PF_HYLINK)
344     /* NSC Hyperchannel protocol */
345     rb_define_const(rb_cSocket, "PF_HYLINK", INTEGER2NUM(PF_HYLINK));
346     /* NSC Hyperchannel protocol */
347     rb_define_const(rb_mSockConst, "PF_HYLINK", INTEGER2NUM(PF_HYLINK));
348 #endif
349 #if defined(AF_ROUTE)
350     /* Internal routing protocol */
351     rb_define_const(rb_cSocket, "AF_ROUTE", INTEGER2NUM(AF_ROUTE));
352     /* Internal routing protocol */
353     rb_define_const(rb_mSockConst, "AF_ROUTE", INTEGER2NUM(AF_ROUTE));
354 #endif
355 #if defined(PF_ROUTE)
356     /* Internal routing protocol */
357     rb_define_const(rb_cSocket, "PF_ROUTE", INTEGER2NUM(PF_ROUTE));
358     /* Internal routing protocol */
359     rb_define_const(rb_mSockConst, "PF_ROUTE", INTEGER2NUM(PF_ROUTE));
360 #endif
361 #if defined(AF_LINK)
362     /* Link layer interface */
363     rb_define_const(rb_cSocket, "AF_LINK", INTEGER2NUM(AF_LINK));
364     /* Link layer interface */
365     rb_define_const(rb_mSockConst, "AF_LINK", INTEGER2NUM(AF_LINK));
366 #endif
367 #if defined(PF_LINK)
368     /* Link layer interface */
369     rb_define_const(rb_cSocket, "PF_LINK", INTEGER2NUM(PF_LINK));
370     /* Link layer interface */
371     rb_define_const(rb_mSockConst, "PF_LINK", INTEGER2NUM(PF_LINK));
372 #endif
373 #if defined(AF_COIP)
374     /* Connection-oriented IP */
375     rb_define_const(rb_cSocket, "AF_COIP", INTEGER2NUM(AF_COIP));
376     /* Connection-oriented IP */
377     rb_define_const(rb_mSockConst, "AF_COIP", INTEGER2NUM(AF_COIP));
378 #endif
379 #if defined(PF_COIP)
380     /* Connection-oriented IP */
381     rb_define_const(rb_cSocket, "PF_COIP", INTEGER2NUM(PF_COIP));
382     /* Connection-oriented IP */
383     rb_define_const(rb_mSockConst, "PF_COIP", INTEGER2NUM(PF_COIP));
384 #endif
385 #if defined(AF_CNT)
386     /* Computer Network Technology */
387     rb_define_const(rb_cSocket, "AF_CNT", INTEGER2NUM(AF_CNT));
388     /* Computer Network Technology */
389     rb_define_const(rb_mSockConst, "AF_CNT", INTEGER2NUM(AF_CNT));
390 #endif
391 #if defined(PF_CNT)
392     /* Computer Network Technology */
393     rb_define_const(rb_cSocket, "PF_CNT", INTEGER2NUM(PF_CNT));
394     /* Computer Network Technology */
395     rb_define_const(rb_mSockConst, "PF_CNT", INTEGER2NUM(PF_CNT));
396 #endif
397 #if defined(AF_SIP)
398     /* Simple Internet Protocol */
399     rb_define_const(rb_cSocket, "AF_SIP", INTEGER2NUM(AF_SIP));
400     /* Simple Internet Protocol */
401     rb_define_const(rb_mSockConst, "AF_SIP", INTEGER2NUM(AF_SIP));
402 #endif
403 #if defined(PF_SIP)
404     /* Simple Internet Protocol */
405     rb_define_const(rb_cSocket, "PF_SIP", INTEGER2NUM(PF_SIP));
406     /* Simple Internet Protocol */
407     rb_define_const(rb_mSockConst, "PF_SIP", INTEGER2NUM(PF_SIP));
408 #endif
409 #if defined(AF_NDRV)
410     /* Network driver raw access */
411     rb_define_const(rb_cSocket, "AF_NDRV", INTEGER2NUM(AF_NDRV));
412     /* Network driver raw access */
413     rb_define_const(rb_mSockConst, "AF_NDRV", INTEGER2NUM(AF_NDRV));
414 #endif
415 #if defined(PF_NDRV)
416     /* Network driver raw access */
417     rb_define_const(rb_cSocket, "PF_NDRV", INTEGER2NUM(PF_NDRV));
418     /* Network driver raw access */
419     rb_define_const(rb_mSockConst, "PF_NDRV", INTEGER2NUM(PF_NDRV));
420 #endif
421 #if defined(AF_ISDN)
422     /* Integrated Services Digital Network */
423     rb_define_const(rb_cSocket, "AF_ISDN", INTEGER2NUM(AF_ISDN));
424     /* Integrated Services Digital Network */
425     rb_define_const(rb_mSockConst, "AF_ISDN", INTEGER2NUM(AF_ISDN));
426 #endif
427 #if defined(PF_ISDN)
428     /* Integrated Services Digital Network */
429     rb_define_const(rb_cSocket, "PF_ISDN", INTEGER2NUM(PF_ISDN));
430     /* Integrated Services Digital Network */
431     rb_define_const(rb_mSockConst, "PF_ISDN", INTEGER2NUM(PF_ISDN));
432 #endif
433 #if defined(AF_NATM)
434     /* Native ATM access */
435     rb_define_const(rb_cSocket, "AF_NATM", INTEGER2NUM(AF_NATM));
436     /* Native ATM access */
437     rb_define_const(rb_mSockConst, "AF_NATM", INTEGER2NUM(AF_NATM));
438 #endif
439 #if defined(PF_NATM)
440     /* Native ATM access */
441     rb_define_const(rb_cSocket, "PF_NATM", INTEGER2NUM(PF_NATM));
442     /* Native ATM access */
443     rb_define_const(rb_mSockConst, "PF_NATM", INTEGER2NUM(PF_NATM));
444 #endif
445 #if defined(AF_SYSTEM)
446     /*  */
447     rb_define_const(rb_cSocket, "AF_SYSTEM", INTEGER2NUM(AF_SYSTEM));
448     /*  */
449     rb_define_const(rb_mSockConst, "AF_SYSTEM", INTEGER2NUM(AF_SYSTEM));
450 #endif
451 #if defined(PF_SYSTEM)
452     /*  */
453     rb_define_const(rb_cSocket, "PF_SYSTEM", INTEGER2NUM(PF_SYSTEM));
454     /*  */
455     rb_define_const(rb_mSockConst, "PF_SYSTEM", INTEGER2NUM(PF_SYSTEM));
456 #endif
457 #if defined(AF_NETBIOS)
458     /* NetBIOS */
459     rb_define_const(rb_cSocket, "AF_NETBIOS", INTEGER2NUM(AF_NETBIOS));
460     /* NetBIOS */
461     rb_define_const(rb_mSockConst, "AF_NETBIOS", INTEGER2NUM(AF_NETBIOS));
462 #endif
463 #if defined(PF_NETBIOS)
464     /* NetBIOS */
465     rb_define_const(rb_cSocket, "PF_NETBIOS", INTEGER2NUM(PF_NETBIOS));
466     /* NetBIOS */
467     rb_define_const(rb_mSockConst, "PF_NETBIOS", INTEGER2NUM(PF_NETBIOS));
468 #endif
469 #if defined(AF_PPP)
470     /* Point-to-Point Protocol */
471     rb_define_const(rb_cSocket, "AF_PPP", INTEGER2NUM(AF_PPP));
472     /* Point-to-Point Protocol */
473     rb_define_const(rb_mSockConst, "AF_PPP", INTEGER2NUM(AF_PPP));
474 #endif
475 #if defined(PF_PPP)
476     /* Point-to-Point Protocol */
477     rb_define_const(rb_cSocket, "PF_PPP", INTEGER2NUM(PF_PPP));
478     /* Point-to-Point Protocol */
479     rb_define_const(rb_mSockConst, "PF_PPP", INTEGER2NUM(PF_PPP));
480 #endif
481 #if defined(AF_ATM)
482     /* Asynchronous Transfer Mode */
483     rb_define_const(rb_cSocket, "AF_ATM", INTEGER2NUM(AF_ATM));
484     /* Asynchronous Transfer Mode */
485     rb_define_const(rb_mSockConst, "AF_ATM", INTEGER2NUM(AF_ATM));
486 #endif
487 #if defined(PF_ATM)
488     /* Asynchronous Transfer Mode */
489     rb_define_const(rb_cSocket, "PF_ATM", INTEGER2NUM(PF_ATM));
490     /* Asynchronous Transfer Mode */
491     rb_define_const(rb_mSockConst, "PF_ATM", INTEGER2NUM(PF_ATM));
492 #endif
493 #if defined(AF_NETGRAPH)
494     /* Netgraph sockets */
495     rb_define_const(rb_cSocket, "AF_NETGRAPH", INTEGER2NUM(AF_NETGRAPH));
496     /* Netgraph sockets */
497     rb_define_const(rb_mSockConst, "AF_NETGRAPH", INTEGER2NUM(AF_NETGRAPH));
498 #endif
499 #if defined(PF_NETGRAPH)
500     /* Netgraph sockets */
501     rb_define_const(rb_cSocket, "PF_NETGRAPH", INTEGER2NUM(PF_NETGRAPH));
502     /* Netgraph sockets */
503     rb_define_const(rb_mSockConst, "PF_NETGRAPH", INTEGER2NUM(PF_NETGRAPH));
504 #endif
505 #if defined(AF_MAX)
506     /* Maximum address family for this platform */
507     rb_define_const(rb_cSocket, "AF_MAX", INTEGER2NUM(AF_MAX));
508     /* Maximum address family for this platform */
509     rb_define_const(rb_mSockConst, "AF_MAX", INTEGER2NUM(AF_MAX));
510 #endif
511 #if defined(PF_MAX)
512     /* Maximum address family for this platform */
513     rb_define_const(rb_cSocket, "PF_MAX", INTEGER2NUM(PF_MAX));
514     /* Maximum address family for this platform */
515     rb_define_const(rb_mSockConst, "PF_MAX", INTEGER2NUM(PF_MAX));
516 #endif
517 #if defined(AF_PACKET)
518     /* Direct link-layer access */
519     rb_define_const(rb_cSocket, "AF_PACKET", INTEGER2NUM(AF_PACKET));
520     /* Direct link-layer access */
521     rb_define_const(rb_mSockConst, "AF_PACKET", INTEGER2NUM(AF_PACKET));
522 #endif
523 #if defined(PF_PACKET)
524     /* Direct link-layer access */
525     rb_define_const(rb_cSocket, "PF_PACKET", INTEGER2NUM(PF_PACKET));
526     /* Direct link-layer access */
527     rb_define_const(rb_mSockConst, "PF_PACKET", INTEGER2NUM(PF_PACKET));
528 #endif
529 #if defined(AF_E164)
530     /* CCITT (ITU-T) E.164 recommendation */
531     rb_define_const(rb_cSocket, "AF_E164", INTEGER2NUM(AF_E164));
532     /* CCITT (ITU-T) E.164 recommendation */
533     rb_define_const(rb_mSockConst, "AF_E164", INTEGER2NUM(AF_E164));
534 #endif
535 #if defined(PF_XTP)
536     /* eXpress Transfer Protocol */
537     rb_define_const(rb_cSocket, "PF_XTP", INTEGER2NUM(PF_XTP));
538     /* eXpress Transfer Protocol */
539     rb_define_const(rb_mSockConst, "PF_XTP", INTEGER2NUM(PF_XTP));
540 #endif
541 #if defined(PF_RTIP)
542     /*  */
543     rb_define_const(rb_cSocket, "PF_RTIP", INTEGER2NUM(PF_RTIP));
544     /*  */
545     rb_define_const(rb_mSockConst, "PF_RTIP", INTEGER2NUM(PF_RTIP));
546 #endif
547 #if defined(PF_PIP)
548     /*  */
549     rb_define_const(rb_cSocket, "PF_PIP", INTEGER2NUM(PF_PIP));
550     /*  */
551     rb_define_const(rb_mSockConst, "PF_PIP", INTEGER2NUM(PF_PIP));
552 #endif
553 #if defined(PF_KEY)
554     /*  */
555     rb_define_const(rb_cSocket, "PF_KEY", INTEGER2NUM(PF_KEY));
556     /*  */
557     rb_define_const(rb_mSockConst, "PF_KEY", INTEGER2NUM(PF_KEY));
558 #endif
559 #if defined(MSG_OOB)
560     /* Process out-of-band data */
561     rb_define_const(rb_cSocket, "MSG_OOB", INTEGER2NUM(MSG_OOB));
562     /* Process out-of-band data */
563     rb_define_const(rb_mSockConst, "MSG_OOB", INTEGER2NUM(MSG_OOB));
564 #endif
565 #if defined(MSG_PEEK)
566     /* Peek at incoming message */
567     rb_define_const(rb_cSocket, "MSG_PEEK", INTEGER2NUM(MSG_PEEK));
568     /* Peek at incoming message */
569     rb_define_const(rb_mSockConst, "MSG_PEEK", INTEGER2NUM(MSG_PEEK));
570 #endif
571 #if defined(MSG_DONTROUTE)
572     /* Send without using the routing tables */
573     rb_define_const(rb_cSocket, "MSG_DONTROUTE", INTEGER2NUM(MSG_DONTROUTE));
574     /* Send without using the routing tables */
575     rb_define_const(rb_mSockConst, "MSG_DONTROUTE", INTEGER2NUM(MSG_DONTROUTE));
576 #endif
577 #if defined(MSG_EOR)
578     /* Data completes record */
579     rb_define_const(rb_cSocket, "MSG_EOR", INTEGER2NUM(MSG_EOR));
580     /* Data completes record */
581     rb_define_const(rb_mSockConst, "MSG_EOR", INTEGER2NUM(MSG_EOR));
582 #endif
583 #if defined(MSG_TRUNC)
584     /* Data discarded before delivery */
585     rb_define_const(rb_cSocket, "MSG_TRUNC", INTEGER2NUM(MSG_TRUNC));
586     /* Data discarded before delivery */
587     rb_define_const(rb_mSockConst, "MSG_TRUNC", INTEGER2NUM(MSG_TRUNC));
588 #endif
589 #if defined(MSG_CTRUNC)
590     /* Control data lost before delivery */
591     rb_define_const(rb_cSocket, "MSG_CTRUNC", INTEGER2NUM(MSG_CTRUNC));
592     /* Control data lost before delivery */
593     rb_define_const(rb_mSockConst, "MSG_CTRUNC", INTEGER2NUM(MSG_CTRUNC));
594 #endif
595 #if defined(MSG_WAITALL)
596     /* Wait for full request or error */
597     rb_define_const(rb_cSocket, "MSG_WAITALL", INTEGER2NUM(MSG_WAITALL));
598     /* Wait for full request or error */
599     rb_define_const(rb_mSockConst, "MSG_WAITALL", INTEGER2NUM(MSG_WAITALL));
600 #endif
601 #if defined(MSG_DONTWAIT)
602     /* This message should be non-blocking */
603     rb_define_const(rb_cSocket, "MSG_DONTWAIT", INTEGER2NUM(MSG_DONTWAIT));
604     /* This message should be non-blocking */
605     rb_define_const(rb_mSockConst, "MSG_DONTWAIT", INTEGER2NUM(MSG_DONTWAIT));
606 #endif
607 #if defined(MSG_EOF)
608     /* Data completes connection */
609     rb_define_const(rb_cSocket, "MSG_EOF", INTEGER2NUM(MSG_EOF));
610     /* Data completes connection */
611     rb_define_const(rb_mSockConst, "MSG_EOF", INTEGER2NUM(MSG_EOF));
612 #endif
613 #if defined(MSG_FLUSH)
614     /* Start of a hold sequence.  Dumps to so_temp */
615     rb_define_const(rb_cSocket, "MSG_FLUSH", INTEGER2NUM(MSG_FLUSH));
616     /* Start of a hold sequence.  Dumps to so_temp */
617     rb_define_const(rb_mSockConst, "MSG_FLUSH", INTEGER2NUM(MSG_FLUSH));
618 #endif
619 #if defined(MSG_HOLD)
620     /* Hold fragment in so_temp */
621     rb_define_const(rb_cSocket, "MSG_HOLD", INTEGER2NUM(MSG_HOLD));
622     /* Hold fragment in so_temp */
623     rb_define_const(rb_mSockConst, "MSG_HOLD", INTEGER2NUM(MSG_HOLD));
624 #endif
625 #if defined(MSG_SEND)
626     /* Send the packet in so_temp */
627     rb_define_const(rb_cSocket, "MSG_SEND", INTEGER2NUM(MSG_SEND));
628     /* Send the packet in so_temp */
629     rb_define_const(rb_mSockConst, "MSG_SEND", INTEGER2NUM(MSG_SEND));
630 #endif
631 #if defined(MSG_HAVEMORE)
632     /* Data ready to be read */
633     rb_define_const(rb_cSocket, "MSG_HAVEMORE", INTEGER2NUM(MSG_HAVEMORE));
634     /* Data ready to be read */
635     rb_define_const(rb_mSockConst, "MSG_HAVEMORE", INTEGER2NUM(MSG_HAVEMORE));
636 #endif
637 #if defined(MSG_RCVMORE)
638     /* Data remains in the current packet */
639     rb_define_const(rb_cSocket, "MSG_RCVMORE", INTEGER2NUM(MSG_RCVMORE));
640     /* Data remains in the current packet */
641     rb_define_const(rb_mSockConst, "MSG_RCVMORE", INTEGER2NUM(MSG_RCVMORE));
642 #endif
643 #if defined(MSG_COMPAT)
644     /* End of record */
645     rb_define_const(rb_cSocket, "MSG_COMPAT", INTEGER2NUM(MSG_COMPAT));
646     /* End of record */
647     rb_define_const(rb_mSockConst, "MSG_COMPAT", INTEGER2NUM(MSG_COMPAT));
648 #endif
649 #if defined(MSG_PROXY)
650     /* Wait for full request */
651     rb_define_const(rb_cSocket, "MSG_PROXY", INTEGER2NUM(MSG_PROXY));
652     /* Wait for full request */
653     rb_define_const(rb_mSockConst, "MSG_PROXY", INTEGER2NUM(MSG_PROXY));
654 #endif
655 #if defined(MSG_FIN)
656     /*  */
657     rb_define_const(rb_cSocket, "MSG_FIN", INTEGER2NUM(MSG_FIN));
658     /*  */
659     rb_define_const(rb_mSockConst, "MSG_FIN", INTEGER2NUM(MSG_FIN));
660 #endif
661 #if defined(MSG_SYN)
662     /*  */
663     rb_define_const(rb_cSocket, "MSG_SYN", INTEGER2NUM(MSG_SYN));
664     /*  */
665     rb_define_const(rb_mSockConst, "MSG_SYN", INTEGER2NUM(MSG_SYN));
666 #endif
667 #if defined(MSG_CONFIRM)
668     /* Confirm path validity */
669     rb_define_const(rb_cSocket, "MSG_CONFIRM", INTEGER2NUM(MSG_CONFIRM));
670     /* Confirm path validity */
671     rb_define_const(rb_mSockConst, "MSG_CONFIRM", INTEGER2NUM(MSG_CONFIRM));
672 #endif
673 #if defined(MSG_RST)
674     /*  */
675     rb_define_const(rb_cSocket, "MSG_RST", INTEGER2NUM(MSG_RST));
676     /*  */
677     rb_define_const(rb_mSockConst, "MSG_RST", INTEGER2NUM(MSG_RST));
678 #endif
679 #if defined(MSG_ERRQUEUE)
680     /* Fetch message from error queue */
681     rb_define_const(rb_cSocket, "MSG_ERRQUEUE", INTEGER2NUM(MSG_ERRQUEUE));
682     /* Fetch message from error queue */
683     rb_define_const(rb_mSockConst, "MSG_ERRQUEUE", INTEGER2NUM(MSG_ERRQUEUE));
684 #endif
685 #if defined(MSG_NOSIGNAL)
686     /* Do not generate SIGPIPE */
687     rb_define_const(rb_cSocket, "MSG_NOSIGNAL", INTEGER2NUM(MSG_NOSIGNAL));
688     /* Do not generate SIGPIPE */
689     rb_define_const(rb_mSockConst, "MSG_NOSIGNAL", INTEGER2NUM(MSG_NOSIGNAL));
690 #endif
691 #if defined(MSG_MORE)
692     /* Sender will send more */
693     rb_define_const(rb_cSocket, "MSG_MORE", INTEGER2NUM(MSG_MORE));
694     /* Sender will send more */
695     rb_define_const(rb_mSockConst, "MSG_MORE", INTEGER2NUM(MSG_MORE));
696 #endif
697 #if defined(MSG_FASTOPEN)
698     /* Reduce step of the handshake process */
699     rb_define_const(rb_cSocket, "MSG_FASTOPEN", INTEGER2NUM(MSG_FASTOPEN));
700     /* Reduce step of the handshake process */
701     rb_define_const(rb_mSockConst, "MSG_FASTOPEN", INTEGER2NUM(MSG_FASTOPEN));
702 #endif
703 #if defined(SOL_SOCKET)
704     /* Socket-level options */
705     rb_define_const(rb_cSocket, "SOL_SOCKET", INTEGER2NUM(SOL_SOCKET));
706     /* Socket-level options */
707     rb_define_const(rb_mSockConst, "SOL_SOCKET", INTEGER2NUM(SOL_SOCKET));
708 #endif
709 #if defined(SOL_IP)
710     /* IP socket options */
711     rb_define_const(rb_cSocket, "SOL_IP", INTEGER2NUM(SOL_IP));
712     /* IP socket options */
713     rb_define_const(rb_mSockConst, "SOL_IP", INTEGER2NUM(SOL_IP));
714 #endif
715 #if defined(SOL_IPX)
716     /* IPX socket options */
717     rb_define_const(rb_cSocket, "SOL_IPX", INTEGER2NUM(SOL_IPX));
718     /* IPX socket options */
719     rb_define_const(rb_mSockConst, "SOL_IPX", INTEGER2NUM(SOL_IPX));
720 #endif
721 #if defined(SOL_AX25)
722     /* AX.25 socket options */
723     rb_define_const(rb_cSocket, "SOL_AX25", INTEGER2NUM(SOL_AX25));
724     /* AX.25 socket options */
725     rb_define_const(rb_mSockConst, "SOL_AX25", INTEGER2NUM(SOL_AX25));
726 #endif
727 #if defined(SOL_ATALK)
728     /* AppleTalk socket options */
729     rb_define_const(rb_cSocket, "SOL_ATALK", INTEGER2NUM(SOL_ATALK));
730     /* AppleTalk socket options */
731     rb_define_const(rb_mSockConst, "SOL_ATALK", INTEGER2NUM(SOL_ATALK));
732 #endif
733 #if defined(SOL_TCP)
734     /* TCP socket options */
735     rb_define_const(rb_cSocket, "SOL_TCP", INTEGER2NUM(SOL_TCP));
736     /* TCP socket options */
737     rb_define_const(rb_mSockConst, "SOL_TCP", INTEGER2NUM(SOL_TCP));
738 #endif
739 #if defined(SOL_UDP)
740     /* UDP socket options */
741     rb_define_const(rb_cSocket, "SOL_UDP", INTEGER2NUM(SOL_UDP));
742     /* UDP socket options */
743     rb_define_const(rb_mSockConst, "SOL_UDP", INTEGER2NUM(SOL_UDP));
744 #endif
745 #if defined(IPPROTO_IP)
746     /* Dummy protocol for IP */
747     rb_define_const(rb_cSocket, "IPPROTO_IP", INTEGER2NUM(IPPROTO_IP));
748     /* Dummy protocol for IP */
749     rb_define_const(rb_mSockConst, "IPPROTO_IP", INTEGER2NUM(IPPROTO_IP));
750 #endif
751 #if defined(IPPROTO_ICMP)
752     /* Control message protocol */
753     rb_define_const(rb_cSocket, "IPPROTO_ICMP", INTEGER2NUM(IPPROTO_ICMP));
754     /* Control message protocol */
755     rb_define_const(rb_mSockConst, "IPPROTO_ICMP", INTEGER2NUM(IPPROTO_ICMP));
756 #endif
757 #if defined(IPPROTO_IGMP)
758     /* Group Management Protocol */
759     rb_define_const(rb_cSocket, "IPPROTO_IGMP", INTEGER2NUM(IPPROTO_IGMP));
760     /* Group Management Protocol */
761     rb_define_const(rb_mSockConst, "IPPROTO_IGMP", INTEGER2NUM(IPPROTO_IGMP));
762 #endif
763 #if defined(IPPROTO_GGP)
764     /* Gateway to Gateway Protocol */
765     rb_define_const(rb_cSocket, "IPPROTO_GGP", INTEGER2NUM(IPPROTO_GGP));
766     /* Gateway to Gateway Protocol */
767     rb_define_const(rb_mSockConst, "IPPROTO_GGP", INTEGER2NUM(IPPROTO_GGP));
768 #endif
769 #if defined(IPPROTO_TCP)
770     /* TCP */
771     rb_define_const(rb_cSocket, "IPPROTO_TCP", INTEGER2NUM(IPPROTO_TCP));
772     /* TCP */
773     rb_define_const(rb_mSockConst, "IPPROTO_TCP", INTEGER2NUM(IPPROTO_TCP));
774 #endif
775 #if defined(IPPROTO_EGP)
776     /* Exterior Gateway Protocol */
777     rb_define_const(rb_cSocket, "IPPROTO_EGP", INTEGER2NUM(IPPROTO_EGP));
778     /* Exterior Gateway Protocol */
779     rb_define_const(rb_mSockConst, "IPPROTO_EGP", INTEGER2NUM(IPPROTO_EGP));
780 #endif
781 #if defined(IPPROTO_PUP)
782     /* PARC Universal Packet protocol */
783     rb_define_const(rb_cSocket, "IPPROTO_PUP", INTEGER2NUM(IPPROTO_PUP));
784     /* PARC Universal Packet protocol */
785     rb_define_const(rb_mSockConst, "IPPROTO_PUP", INTEGER2NUM(IPPROTO_PUP));
786 #endif
787 #if defined(IPPROTO_UDP)
788     /* UDP */
789     rb_define_const(rb_cSocket, "IPPROTO_UDP", INTEGER2NUM(IPPROTO_UDP));
790     /* UDP */
791     rb_define_const(rb_mSockConst, "IPPROTO_UDP", INTEGER2NUM(IPPROTO_UDP));
792 #endif
793 #if defined(IPPROTO_IDP)
794     /* XNS IDP */
795     rb_define_const(rb_cSocket, "IPPROTO_IDP", INTEGER2NUM(IPPROTO_IDP));
796     /* XNS IDP */
797     rb_define_const(rb_mSockConst, "IPPROTO_IDP", INTEGER2NUM(IPPROTO_IDP));
798 #endif
799 #if defined(IPPROTO_HELLO)
800     /* "hello" routing protocol */
801     rb_define_const(rb_cSocket, "IPPROTO_HELLO", INTEGER2NUM(IPPROTO_HELLO));
802     /* "hello" routing protocol */
803     rb_define_const(rb_mSockConst, "IPPROTO_HELLO", INTEGER2NUM(IPPROTO_HELLO));
804 #endif
805 #if defined(IPPROTO_ND)
806     /* Sun net disk protocol */
807     rb_define_const(rb_cSocket, "IPPROTO_ND", INTEGER2NUM(IPPROTO_ND));
808     /* Sun net disk protocol */
809     rb_define_const(rb_mSockConst, "IPPROTO_ND", INTEGER2NUM(IPPROTO_ND));
810 #endif
811 #if defined(IPPROTO_TP)
812     /* ISO transport protocol class 4 */
813     rb_define_const(rb_cSocket, "IPPROTO_TP", INTEGER2NUM(IPPROTO_TP));
814     /* ISO transport protocol class 4 */
815     rb_define_const(rb_mSockConst, "IPPROTO_TP", INTEGER2NUM(IPPROTO_TP));
816 #endif
817 #if defined(IPPROTO_XTP)
818     /* Xpress Transport Protocol */
819     rb_define_const(rb_cSocket, "IPPROTO_XTP", INTEGER2NUM(IPPROTO_XTP));
820     /* Xpress Transport Protocol */
821     rb_define_const(rb_mSockConst, "IPPROTO_XTP", INTEGER2NUM(IPPROTO_XTP));
822 #endif
823 #if defined(IPPROTO_EON)
824     /* ISO cnlp */
825     rb_define_const(rb_cSocket, "IPPROTO_EON", INTEGER2NUM(IPPROTO_EON));
826     /* ISO cnlp */
827     rb_define_const(rb_mSockConst, "IPPROTO_EON", INTEGER2NUM(IPPROTO_EON));
828 #endif
829 #if defined(IPPROTO_BIP)
830     /*  */
831     rb_define_const(rb_cSocket, "IPPROTO_BIP", INTEGER2NUM(IPPROTO_BIP));
832     /*  */
833     rb_define_const(rb_mSockConst, "IPPROTO_BIP", INTEGER2NUM(IPPROTO_BIP));
834 #endif
835 #if defined(IPPROTO_AH)
836     /* IP6 auth header */
837     rb_define_const(rb_cSocket, "IPPROTO_AH", INTEGER2NUM(IPPROTO_AH));
838     /* IP6 auth header */
839     rb_define_const(rb_mSockConst, "IPPROTO_AH", INTEGER2NUM(IPPROTO_AH));
840 #endif
841 #if defined(IPPROTO_DSTOPTS)
842     /* IP6 destination option */
843     rb_define_const(rb_cSocket, "IPPROTO_DSTOPTS", INTEGER2NUM(IPPROTO_DSTOPTS));
844     /* IP6 destination option */
845     rb_define_const(rb_mSockConst, "IPPROTO_DSTOPTS", INTEGER2NUM(IPPROTO_DSTOPTS));
846 #endif
847 #if defined(IPPROTO_ESP)
848     /* IP6 Encapsulated Security Payload */
849     rb_define_const(rb_cSocket, "IPPROTO_ESP", INTEGER2NUM(IPPROTO_ESP));
850     /* IP6 Encapsulated Security Payload */
851     rb_define_const(rb_mSockConst, "IPPROTO_ESP", INTEGER2NUM(IPPROTO_ESP));
852 #endif
853 #if defined(IPPROTO_FRAGMENT)
854     /* IP6 fragmentation header */
855     rb_define_const(rb_cSocket, "IPPROTO_FRAGMENT", INTEGER2NUM(IPPROTO_FRAGMENT));
856     /* IP6 fragmentation header */
857     rb_define_const(rb_mSockConst, "IPPROTO_FRAGMENT", INTEGER2NUM(IPPROTO_FRAGMENT));
858 #endif
859 #if defined(IPPROTO_HOPOPTS)
860     /* IP6 hop-by-hop options */
861     rb_define_const(rb_cSocket, "IPPROTO_HOPOPTS", INTEGER2NUM(IPPROTO_HOPOPTS));
862     /* IP6 hop-by-hop options */
863     rb_define_const(rb_mSockConst, "IPPROTO_HOPOPTS", INTEGER2NUM(IPPROTO_HOPOPTS));
864 #endif
865 #if defined(IPPROTO_ICMPV6)
866     /* ICMP6 */
867     rb_define_const(rb_cSocket, "IPPROTO_ICMPV6", INTEGER2NUM(IPPROTO_ICMPV6));
868     /* ICMP6 */
869     rb_define_const(rb_mSockConst, "IPPROTO_ICMPV6", INTEGER2NUM(IPPROTO_ICMPV6));
870 #endif
871 #if defined(IPPROTO_IPV6)
872     /* IP6 header */
873     rb_define_const(rb_cSocket, "IPPROTO_IPV6", INTEGER2NUM(IPPROTO_IPV6));
874     /* IP6 header */
875     rb_define_const(rb_mSockConst, "IPPROTO_IPV6", INTEGER2NUM(IPPROTO_IPV6));
876 #endif
877 #if defined(IPPROTO_NONE)
878     /* IP6 no next header */
879     rb_define_const(rb_cSocket, "IPPROTO_NONE", INTEGER2NUM(IPPROTO_NONE));
880     /* IP6 no next header */
881     rb_define_const(rb_mSockConst, "IPPROTO_NONE", INTEGER2NUM(IPPROTO_NONE));
882 #endif
883 #if defined(IPPROTO_ROUTING)
884     /* IP6 routing header */
885     rb_define_const(rb_cSocket, "IPPROTO_ROUTING", INTEGER2NUM(IPPROTO_ROUTING));
886     /* IP6 routing header */
887     rb_define_const(rb_mSockConst, "IPPROTO_ROUTING", INTEGER2NUM(IPPROTO_ROUTING));
888 #endif
889 #if defined(IPPROTO_RAW)
890     /* Raw IP packet */
891     rb_define_const(rb_cSocket, "IPPROTO_RAW", INTEGER2NUM(IPPROTO_RAW));
892     /* Raw IP packet */
893     rb_define_const(rb_mSockConst, "IPPROTO_RAW", INTEGER2NUM(IPPROTO_RAW));
894 #endif
895 #if defined(IPPROTO_MAX)
896     /* Maximum IPPROTO constant */
897     rb_define_const(rb_cSocket, "IPPROTO_MAX", INTEGER2NUM(IPPROTO_MAX));
898     /* Maximum IPPROTO constant */
899     rb_define_const(rb_mSockConst, "IPPROTO_MAX", INTEGER2NUM(IPPROTO_MAX));
900 #endif
901 #if defined(IPPORT_RESERVED)
902     /* Default minimum address for bind or connect */
903     rb_define_const(rb_cSocket, "IPPORT_RESERVED", INTEGER2NUM(IPPORT_RESERVED));
904     /* Default minimum address for bind or connect */
905     rb_define_const(rb_mSockConst, "IPPORT_RESERVED", INTEGER2NUM(IPPORT_RESERVED));
906 #endif
907 #if defined(IPPORT_USERRESERVED)
908     /* Default maximum address for bind or connect */
909     rb_define_const(rb_cSocket, "IPPORT_USERRESERVED", INTEGER2NUM(IPPORT_USERRESERVED));
910     /* Default maximum address for bind or connect */
911     rb_define_const(rb_mSockConst, "IPPORT_USERRESERVED", INTEGER2NUM(IPPORT_USERRESERVED));
912 #endif
913 #if defined(INADDR_ANY)
914     /* A socket bound to INADDR_ANY receives packets from all interfaces and sends from the default IP address */
915     rb_define_const(rb_cSocket, "INADDR_ANY", INTEGER2NUM(INADDR_ANY));
916     /* A socket bound to INADDR_ANY receives packets from all interfaces and sends from the default IP address */
917     rb_define_const(rb_mSockConst, "INADDR_ANY", INTEGER2NUM(INADDR_ANY));
918 #endif
919 #if defined(INADDR_BROADCAST)
920     /* The network broadcast address */
921     rb_define_const(rb_cSocket, "INADDR_BROADCAST", INTEGER2NUM(INADDR_BROADCAST));
922     /* The network broadcast address */
923     rb_define_const(rb_mSockConst, "INADDR_BROADCAST", INTEGER2NUM(INADDR_BROADCAST));
924 #endif
925 #if defined(INADDR_LOOPBACK)
926     /* The loopback address */
927     rb_define_const(rb_cSocket, "INADDR_LOOPBACK", INTEGER2NUM(INADDR_LOOPBACK));
928     /* The loopback address */
929     rb_define_const(rb_mSockConst, "INADDR_LOOPBACK", INTEGER2NUM(INADDR_LOOPBACK));
930 #endif
931 #if defined(INADDR_UNSPEC_GROUP)
932     /* The reserved multicast group */
933     rb_define_const(rb_cSocket, "INADDR_UNSPEC_GROUP", INTEGER2NUM(INADDR_UNSPEC_GROUP));
934     /* The reserved multicast group */
935     rb_define_const(rb_mSockConst, "INADDR_UNSPEC_GROUP", INTEGER2NUM(INADDR_UNSPEC_GROUP));
936 #endif
937 #if defined(INADDR_ALLHOSTS_GROUP)
938     /* Multicast group for all systems on this subset */
939     rb_define_const(rb_cSocket, "INADDR_ALLHOSTS_GROUP", INTEGER2NUM(INADDR_ALLHOSTS_GROUP));
940     /* Multicast group for all systems on this subset */
941     rb_define_const(rb_mSockConst, "INADDR_ALLHOSTS_GROUP", INTEGER2NUM(INADDR_ALLHOSTS_GROUP));
942 #endif
943 #if defined(INADDR_MAX_LOCAL_GROUP)
944     /* The last local network multicast group */
945     rb_define_const(rb_cSocket, "INADDR_MAX_LOCAL_GROUP", INTEGER2NUM(INADDR_MAX_LOCAL_GROUP));
946     /* The last local network multicast group */
947     rb_define_const(rb_mSockConst, "INADDR_MAX_LOCAL_GROUP", INTEGER2NUM(INADDR_MAX_LOCAL_GROUP));
948 #endif
949 #if defined(INADDR_NONE)
950     /* A bitmask for matching no valid IP address */
951     rb_define_const(rb_cSocket, "INADDR_NONE", INTEGER2NUM(INADDR_NONE));
952     /* A bitmask for matching no valid IP address */
953     rb_define_const(rb_mSockConst, "INADDR_NONE", INTEGER2NUM(INADDR_NONE));
954 #endif
955 #if defined(IP_OPTIONS)
956     /* IP options to be included in packets */
957     rb_define_const(rb_cSocket, "IP_OPTIONS", INTEGER2NUM(IP_OPTIONS));
958     /* IP options to be included in packets */
959     rb_define_const(rb_mSockConst, "IP_OPTIONS", INTEGER2NUM(IP_OPTIONS));
960 #endif
961 #if defined(IP_HDRINCL)
962     /* Header is included with data */
963     rb_define_const(rb_cSocket, "IP_HDRINCL", INTEGER2NUM(IP_HDRINCL));
964     /* Header is included with data */
965     rb_define_const(rb_mSockConst, "IP_HDRINCL", INTEGER2NUM(IP_HDRINCL));
966 #endif
967 #if defined(IP_TOS)
968     /* IP type-of-service */
969     rb_define_const(rb_cSocket, "IP_TOS", INTEGER2NUM(IP_TOS));
970     /* IP type-of-service */
971     rb_define_const(rb_mSockConst, "IP_TOS", INTEGER2NUM(IP_TOS));
972 #endif
973 #if defined(IP_TTL)
974     /* IP time-to-live */
975     rb_define_const(rb_cSocket, "IP_TTL", INTEGER2NUM(IP_TTL));
976     /* IP time-to-live */
977     rb_define_const(rb_mSockConst, "IP_TTL", INTEGER2NUM(IP_TTL));
978 #endif
979 #if defined(IP_RECVOPTS)
980     /* Receive all IP options with datagram */
981     rb_define_const(rb_cSocket, "IP_RECVOPTS", INTEGER2NUM(IP_RECVOPTS));
982     /* Receive all IP options with datagram */
983     rb_define_const(rb_mSockConst, "IP_RECVOPTS", INTEGER2NUM(IP_RECVOPTS));
984 #endif
985 #if defined(IP_RECVRETOPTS)
986     /* Receive all IP options for response */
987     rb_define_const(rb_cSocket, "IP_RECVRETOPTS", INTEGER2NUM(IP_RECVRETOPTS));
988     /* Receive all IP options for response */
989     rb_define_const(rb_mSockConst, "IP_RECVRETOPTS", INTEGER2NUM(IP_RECVRETOPTS));
990 #endif
991 #if defined(IP_RECVDSTADDR)
992     /* Receive IP destination address with datagram */
993     rb_define_const(rb_cSocket, "IP_RECVDSTADDR", INTEGER2NUM(IP_RECVDSTADDR));
994     /* Receive IP destination address with datagram */
995     rb_define_const(rb_mSockConst, "IP_RECVDSTADDR", INTEGER2NUM(IP_RECVDSTADDR));
996 #endif
997 #if defined(IP_RETOPTS)
998     /* IP options to be included in datagrams */
999     rb_define_const(rb_cSocket, "IP_RETOPTS", INTEGER2NUM(IP_RETOPTS));
1000     /* IP options to be included in datagrams */
1001     rb_define_const(rb_mSockConst, "IP_RETOPTS", INTEGER2NUM(IP_RETOPTS));
1002 #endif
1003 #if defined(IP_MINTTL)
1004     /* Minimum TTL allowed for received packets */
1005     rb_define_const(rb_cSocket, "IP_MINTTL", INTEGER2NUM(IP_MINTTL));
1006     /* Minimum TTL allowed for received packets */
1007     rb_define_const(rb_mSockConst, "IP_MINTTL", INTEGER2NUM(IP_MINTTL));
1008 #endif
1009 #if defined(IP_DONTFRAG)
1010     /* Don't fragment packets */
1011     rb_define_const(rb_cSocket, "IP_DONTFRAG", INTEGER2NUM(IP_DONTFRAG));
1012     /* Don't fragment packets */
1013     rb_define_const(rb_mSockConst, "IP_DONTFRAG", INTEGER2NUM(IP_DONTFRAG));
1014 #endif
1015 #if defined(IP_SENDSRCADDR)
1016     /* Source address for outgoing UDP datagrams */
1017     rb_define_const(rb_cSocket, "IP_SENDSRCADDR", INTEGER2NUM(IP_SENDSRCADDR));
1018     /* Source address for outgoing UDP datagrams */
1019     rb_define_const(rb_mSockConst, "IP_SENDSRCADDR", INTEGER2NUM(IP_SENDSRCADDR));
1020 #endif
1021 #if defined(IP_ONESBCAST)
1022     /* Force outgoing broadcast datagrams to have the undirected broadcast address */
1023     rb_define_const(rb_cSocket, "IP_ONESBCAST", INTEGER2NUM(IP_ONESBCAST));
1024     /* Force outgoing broadcast datagrams to have the undirected broadcast address */
1025     rb_define_const(rb_mSockConst, "IP_ONESBCAST", INTEGER2NUM(IP_ONESBCAST));
1026 #endif
1027 #if defined(IP_RECVTTL)
1028     /* Receive IP TTL with datagrams */
1029     rb_define_const(rb_cSocket, "IP_RECVTTL", INTEGER2NUM(IP_RECVTTL));
1030     /* Receive IP TTL with datagrams */
1031     rb_define_const(rb_mSockConst, "IP_RECVTTL", INTEGER2NUM(IP_RECVTTL));
1032 #endif
1033 #if defined(IP_RECVIF)
1034     /* Receive interface information with datagrams */
1035     rb_define_const(rb_cSocket, "IP_RECVIF", INTEGER2NUM(IP_RECVIF));
1036     /* Receive interface information with datagrams */
1037     rb_define_const(rb_mSockConst, "IP_RECVIF", INTEGER2NUM(IP_RECVIF));
1038 #endif
1039 #if defined(IP_RECVSLLA)
1040     /* Receive link-layer address with datagrams */
1041     rb_define_const(rb_cSocket, "IP_RECVSLLA", INTEGER2NUM(IP_RECVSLLA));
1042     /* Receive link-layer address with datagrams */
1043     rb_define_const(rb_mSockConst, "IP_RECVSLLA", INTEGER2NUM(IP_RECVSLLA));
1044 #endif
1045 #if defined(IP_PORTRANGE)
1046     /* Set the port range for sockets with unspecified port numbers */
1047     rb_define_const(rb_cSocket, "IP_PORTRANGE", INTEGER2NUM(IP_PORTRANGE));
1048     /* Set the port range for sockets with unspecified port numbers */
1049     rb_define_const(rb_mSockConst, "IP_PORTRANGE", INTEGER2NUM(IP_PORTRANGE));
1050 #endif
1051 #if defined(IP_MULTICAST_IF)
1052     /* IP multicast interface */
1053     rb_define_const(rb_cSocket, "IP_MULTICAST_IF", INTEGER2NUM(IP_MULTICAST_IF));
1054     /* IP multicast interface */
1055     rb_define_const(rb_mSockConst, "IP_MULTICAST_IF", INTEGER2NUM(IP_MULTICAST_IF));
1056 #endif
1057 #if defined(IP_MULTICAST_TTL)
1058     /* IP multicast TTL */
1059     rb_define_const(rb_cSocket, "IP_MULTICAST_TTL", INTEGER2NUM(IP_MULTICAST_TTL));
1060     /* IP multicast TTL */
1061     rb_define_const(rb_mSockConst, "IP_MULTICAST_TTL", INTEGER2NUM(IP_MULTICAST_TTL));
1062 #endif
1063 #if defined(IP_MULTICAST_LOOP)
1064     /* IP multicast loopback */
1065     rb_define_const(rb_cSocket, "IP_MULTICAST_LOOP", INTEGER2NUM(IP_MULTICAST_LOOP));
1066     /* IP multicast loopback */
1067     rb_define_const(rb_mSockConst, "IP_MULTICAST_LOOP", INTEGER2NUM(IP_MULTICAST_LOOP));
1068 #endif
1069 #if defined(IP_ADD_MEMBERSHIP)
1070     /* Add a multicast group membership */
1071     rb_define_const(rb_cSocket, "IP_ADD_MEMBERSHIP", INTEGER2NUM(IP_ADD_MEMBERSHIP));
1072     /* Add a multicast group membership */
1073     rb_define_const(rb_mSockConst, "IP_ADD_MEMBERSHIP", INTEGER2NUM(IP_ADD_MEMBERSHIP));
1074 #endif
1075 #if defined(IP_DROP_MEMBERSHIP)
1076     /* Drop a multicast group membership */
1077     rb_define_const(rb_cSocket, "IP_DROP_MEMBERSHIP", INTEGER2NUM(IP_DROP_MEMBERSHIP));
1078     /* Drop a multicast group membership */
1079     rb_define_const(rb_mSockConst, "IP_DROP_MEMBERSHIP", INTEGER2NUM(IP_DROP_MEMBERSHIP));
1080 #endif
1081 #if defined(IP_DEFAULT_MULTICAST_TTL)
1082     /* Default multicast TTL */
1083     rb_define_const(rb_cSocket, "IP_DEFAULT_MULTICAST_TTL", INTEGER2NUM(IP_DEFAULT_MULTICAST_TTL));
1084     /* Default multicast TTL */
1085     rb_define_const(rb_mSockConst, "IP_DEFAULT_MULTICAST_TTL", INTEGER2NUM(IP_DEFAULT_MULTICAST_TTL));
1086 #endif
1087 #if defined(IP_DEFAULT_MULTICAST_LOOP)
1088     /* Default multicast loopback */
1089     rb_define_const(rb_cSocket, "IP_DEFAULT_MULTICAST_LOOP", INTEGER2NUM(IP_DEFAULT_MULTICAST_LOOP));
1090     /* Default multicast loopback */
1091     rb_define_const(rb_mSockConst, "IP_DEFAULT_MULTICAST_LOOP", INTEGER2NUM(IP_DEFAULT_MULTICAST_LOOP));
1092 #endif
1093 #if defined(IP_MAX_MEMBERSHIPS)
1094     /* Maximum number multicast groups a socket can join */
1095     rb_define_const(rb_cSocket, "IP_MAX_MEMBERSHIPS", INTEGER2NUM(IP_MAX_MEMBERSHIPS));
1096     /* Maximum number multicast groups a socket can join */
1097     rb_define_const(rb_mSockConst, "IP_MAX_MEMBERSHIPS", INTEGER2NUM(IP_MAX_MEMBERSHIPS));
1098 #endif
1099 #if defined(IP_ROUTER_ALERT)
1100     /* Notify transit routers to more closely examine the contents of an IP packet */
1101     rb_define_const(rb_cSocket, "IP_ROUTER_ALERT", INTEGER2NUM(IP_ROUTER_ALERT));
1102     /* Notify transit routers to more closely examine the contents of an IP packet */
1103     rb_define_const(rb_mSockConst, "IP_ROUTER_ALERT", INTEGER2NUM(IP_ROUTER_ALERT));
1104 #endif
1105 #if defined(IP_PKTINFO)
1106     /* Receive packet information with datagrams */
1107     rb_define_const(rb_cSocket, "IP_PKTINFO", INTEGER2NUM(IP_PKTINFO));
1108     /* Receive packet information with datagrams */
1109     rb_define_const(rb_mSockConst, "IP_PKTINFO", INTEGER2NUM(IP_PKTINFO));
1110 #endif
1111 #if defined(IP_PKTOPTIONS)
1112     /* Receive packet options with datagrams */
1113     rb_define_const(rb_cSocket, "IP_PKTOPTIONS", INTEGER2NUM(IP_PKTOPTIONS));
1114     /* Receive packet options with datagrams */
1115     rb_define_const(rb_mSockConst, "IP_PKTOPTIONS", INTEGER2NUM(IP_PKTOPTIONS));
1116 #endif
1117 #if defined(IP_MTU_DISCOVER)
1118     /* Path MTU discovery */
1119     rb_define_const(rb_cSocket, "IP_MTU_DISCOVER", INTEGER2NUM(IP_MTU_DISCOVER));
1120     /* Path MTU discovery */
1121     rb_define_const(rb_mSockConst, "IP_MTU_DISCOVER", INTEGER2NUM(IP_MTU_DISCOVER));
1122 #endif
1123 #if defined(IP_RECVERR)
1124     /* Enable extended reliable error message passing */
1125     rb_define_const(rb_cSocket, "IP_RECVERR", INTEGER2NUM(IP_RECVERR));
1126     /* Enable extended reliable error message passing */
1127     rb_define_const(rb_mSockConst, "IP_RECVERR", INTEGER2NUM(IP_RECVERR));
1128 #endif
1129 #if defined(IP_RECVTOS)
1130     /* Receive TOS with incoming packets */
1131     rb_define_const(rb_cSocket, "IP_RECVTOS", INTEGER2NUM(IP_RECVTOS));
1132     /* Receive TOS with incoming packets */
1133     rb_define_const(rb_mSockConst, "IP_RECVTOS", INTEGER2NUM(IP_RECVTOS));
1134 #endif
1135 #if defined(IP_MTU)
1136     /* The Maximum Transmission Unit of the socket */
1137     rb_define_const(rb_cSocket, "IP_MTU", INTEGER2NUM(IP_MTU));
1138     /* The Maximum Transmission Unit of the socket */
1139     rb_define_const(rb_mSockConst, "IP_MTU", INTEGER2NUM(IP_MTU));
1140 #endif
1141 #if defined(IP_FREEBIND)
1142     /* Allow binding to nonexistent IP addresses */
1143     rb_define_const(rb_cSocket, "IP_FREEBIND", INTEGER2NUM(IP_FREEBIND));
1144     /* Allow binding to nonexistent IP addresses */
1145     rb_define_const(rb_mSockConst, "IP_FREEBIND", INTEGER2NUM(IP_FREEBIND));
1146 #endif
1147 #if defined(IP_IPSEC_POLICY)
1148     /* IPsec security policy */
1149     rb_define_const(rb_cSocket, "IP_IPSEC_POLICY", INTEGER2NUM(IP_IPSEC_POLICY));
1150     /* IPsec security policy */
1151     rb_define_const(rb_mSockConst, "IP_IPSEC_POLICY", INTEGER2NUM(IP_IPSEC_POLICY));
1152 #endif
1153 #if defined(IP_XFRM_POLICY)
1154     /*  */
1155     rb_define_const(rb_cSocket, "IP_XFRM_POLICY", INTEGER2NUM(IP_XFRM_POLICY));
1156     /*  */
1157     rb_define_const(rb_mSockConst, "IP_XFRM_POLICY", INTEGER2NUM(IP_XFRM_POLICY));
1158 #endif
1159 #if defined(IP_PASSSEC)
1160     /* Retrieve security context with datagram */
1161     rb_define_const(rb_cSocket, "IP_PASSSEC", INTEGER2NUM(IP_PASSSEC));
1162     /* Retrieve security context with datagram */
1163     rb_define_const(rb_mSockConst, "IP_PASSSEC", INTEGER2NUM(IP_PASSSEC));
1164 #endif
1165 #if defined(IP_TRANSPARENT)
1166     /* Transparent proxy */
1167     rb_define_const(rb_cSocket, "IP_TRANSPARENT", INTEGER2NUM(IP_TRANSPARENT));
1168     /* Transparent proxy */
1169     rb_define_const(rb_mSockConst, "IP_TRANSPARENT", INTEGER2NUM(IP_TRANSPARENT));
1170 #endif
1171 #if defined(IP_PMTUDISC_DONT)
1172     /* Never send DF frames */
1173     rb_define_const(rb_cSocket, "IP_PMTUDISC_DONT", INTEGER2NUM(IP_PMTUDISC_DONT));
1174     /* Never send DF frames */
1175     rb_define_const(rb_mSockConst, "IP_PMTUDISC_DONT", INTEGER2NUM(IP_PMTUDISC_DONT));
1176 #endif
1177 #if defined(IP_PMTUDISC_WANT)
1178     /* Use per-route hints */
1179     rb_define_const(rb_cSocket, "IP_PMTUDISC_WANT", INTEGER2NUM(IP_PMTUDISC_WANT));
1180     /* Use per-route hints */
1181     rb_define_const(rb_mSockConst, "IP_PMTUDISC_WANT", INTEGER2NUM(IP_PMTUDISC_WANT));
1182 #endif
1183 #if defined(IP_PMTUDISC_DO)
1184     /* Always send DF frames */
1185     rb_define_const(rb_cSocket, "IP_PMTUDISC_DO", INTEGER2NUM(IP_PMTUDISC_DO));
1186     /* Always send DF frames */
1187     rb_define_const(rb_mSockConst, "IP_PMTUDISC_DO", INTEGER2NUM(IP_PMTUDISC_DO));
1188 #endif
1189 #if defined(IP_UNBLOCK_SOURCE)
1190     /* Unblock IPv4 multicast packets with a give source address */
1191     rb_define_const(rb_cSocket, "IP_UNBLOCK_SOURCE", INTEGER2NUM(IP_UNBLOCK_SOURCE));
1192     /* Unblock IPv4 multicast packets with a give source address */
1193     rb_define_const(rb_mSockConst, "IP_UNBLOCK_SOURCE", INTEGER2NUM(IP_UNBLOCK_SOURCE));
1194 #endif
1195 #if defined(IP_BLOCK_SOURCE)
1196     /* Block IPv4 multicast packets with a give source address */
1197     rb_define_const(rb_cSocket, "IP_BLOCK_SOURCE", INTEGER2NUM(IP_BLOCK_SOURCE));
1198     /* Block IPv4 multicast packets with a give source address */
1199     rb_define_const(rb_mSockConst, "IP_BLOCK_SOURCE", INTEGER2NUM(IP_BLOCK_SOURCE));
1200 #endif
1201 #if defined(IP_ADD_SOURCE_MEMBERSHIP)
1202     /* Add a multicast group membership */
1203     rb_define_const(rb_cSocket, "IP_ADD_SOURCE_MEMBERSHIP", INTEGER2NUM(IP_ADD_SOURCE_MEMBERSHIP));
1204     /* Add a multicast group membership */
1205     rb_define_const(rb_mSockConst, "IP_ADD_SOURCE_MEMBERSHIP", INTEGER2NUM(IP_ADD_SOURCE_MEMBERSHIP));
1206 #endif
1207 #if defined(IP_DROP_SOURCE_MEMBERSHIP)
1208     /* Drop a multicast group membership */
1209     rb_define_const(rb_cSocket, "IP_DROP_SOURCE_MEMBERSHIP", INTEGER2NUM(IP_DROP_SOURCE_MEMBERSHIP));
1210     /* Drop a multicast group membership */
1211     rb_define_const(rb_mSockConst, "IP_DROP_SOURCE_MEMBERSHIP", INTEGER2NUM(IP_DROP_SOURCE_MEMBERSHIP));
1212 #endif
1213 #if defined(IP_MSFILTER)
1214     /* Multicast source filtering */
1215     rb_define_const(rb_cSocket, "IP_MSFILTER", INTEGER2NUM(IP_MSFILTER));
1216     /* Multicast source filtering */
1217     rb_define_const(rb_mSockConst, "IP_MSFILTER", INTEGER2NUM(IP_MSFILTER));
1218 #endif
1219 #if defined(MCAST_JOIN_GROUP)
1220     /* Join a multicast group */
1221     rb_define_const(rb_cSocket, "MCAST_JOIN_GROUP", INTEGER2NUM(MCAST_JOIN_GROUP));
1222     /* Join a multicast group */
1223     rb_define_const(rb_mSockConst, "MCAST_JOIN_GROUP", INTEGER2NUM(MCAST_JOIN_GROUP));
1224 #endif
1225 #if defined(MCAST_BLOCK_SOURCE)
1226     /* Block multicast packets from this source */
1227     rb_define_const(rb_cSocket, "MCAST_BLOCK_SOURCE", INTEGER2NUM(MCAST_BLOCK_SOURCE));
1228     /* Block multicast packets from this source */
1229     rb_define_const(rb_mSockConst, "MCAST_BLOCK_SOURCE", INTEGER2NUM(MCAST_BLOCK_SOURCE));
1230 #endif
1231 #if defined(MCAST_UNBLOCK_SOURCE)
1232     /* Unblock multicast packets from this source */
1233     rb_define_const(rb_cSocket, "MCAST_UNBLOCK_SOURCE", INTEGER2NUM(MCAST_UNBLOCK_SOURCE));
1234     /* Unblock multicast packets from this source */
1235     rb_define_const(rb_mSockConst, "MCAST_UNBLOCK_SOURCE", INTEGER2NUM(MCAST_UNBLOCK_SOURCE));
1236 #endif
1237 #if defined(MCAST_LEAVE_GROUP)
1238     /* Leave a multicast group */
1239     rb_define_const(rb_cSocket, "MCAST_LEAVE_GROUP", INTEGER2NUM(MCAST_LEAVE_GROUP));
1240     /* Leave a multicast group */
1241     rb_define_const(rb_mSockConst, "MCAST_LEAVE_GROUP", INTEGER2NUM(MCAST_LEAVE_GROUP));
1242 #endif
1243 #if defined(MCAST_JOIN_SOURCE_GROUP)
1244     /* Join a multicast source group */
1245     rb_define_const(rb_cSocket, "MCAST_JOIN_SOURCE_GROUP", INTEGER2NUM(MCAST_JOIN_SOURCE_GROUP));
1246     /* Join a multicast source group */
1247     rb_define_const(rb_mSockConst, "MCAST_JOIN_SOURCE_GROUP", INTEGER2NUM(MCAST_JOIN_SOURCE_GROUP));
1248 #endif
1249 #if defined(MCAST_LEAVE_SOURCE_GROUP)
1250     /* Leave a multicast source group */
1251     rb_define_const(rb_cSocket, "MCAST_LEAVE_SOURCE_GROUP", INTEGER2NUM(MCAST_LEAVE_SOURCE_GROUP));
1252     /* Leave a multicast source group */
1253     rb_define_const(rb_mSockConst, "MCAST_LEAVE_SOURCE_GROUP", INTEGER2NUM(MCAST_LEAVE_SOURCE_GROUP));
1254 #endif
1255 #if defined(MCAST_MSFILTER)
1256     /* Multicast source filtering */
1257     rb_define_const(rb_cSocket, "MCAST_MSFILTER", INTEGER2NUM(MCAST_MSFILTER));
1258     /* Multicast source filtering */
1259     rb_define_const(rb_mSockConst, "MCAST_MSFILTER", INTEGER2NUM(MCAST_MSFILTER));
1260 #endif
1261 #if defined(MCAST_EXCLUDE)
1262     /* Exclusive multicast source filter */
1263     rb_define_const(rb_cSocket, "MCAST_EXCLUDE", INTEGER2NUM(MCAST_EXCLUDE));
1264     /* Exclusive multicast source filter */
1265     rb_define_const(rb_mSockConst, "MCAST_EXCLUDE", INTEGER2NUM(MCAST_EXCLUDE));
1266 #endif
1267 #if defined(MCAST_INCLUDE)
1268     /* Inclusive multicast source filter */
1269     rb_define_const(rb_cSocket, "MCAST_INCLUDE", INTEGER2NUM(MCAST_INCLUDE));
1270     /* Inclusive multicast source filter */
1271     rb_define_const(rb_mSockConst, "MCAST_INCLUDE", INTEGER2NUM(MCAST_INCLUDE));
1272 #endif
1273 #if defined(SO_DEBUG)
1274     /* Debug info recording */
1275     rb_define_const(rb_cSocket, "SO_DEBUG", INTEGER2NUM(SO_DEBUG));
1276     /* Debug info recording */
1277     rb_define_const(rb_mSockConst, "SO_DEBUG", INTEGER2NUM(SO_DEBUG));
1278 #endif
1279 #if defined(SO_REUSEADDR)
1280     /* Allow local address reuse */
1281     rb_define_const(rb_cSocket, "SO_REUSEADDR", INTEGER2NUM(SO_REUSEADDR));
1282     /* Allow local address reuse */
1283     rb_define_const(rb_mSockConst, "SO_REUSEADDR", INTEGER2NUM(SO_REUSEADDR));
1284 #endif
1285 #if defined(SO_REUSEPORT)
1286     /* Allow local address and port reuse */
1287     rb_define_const(rb_cSocket, "SO_REUSEPORT", INTEGER2NUM(SO_REUSEPORT));
1288     /* Allow local address and port reuse */
1289     rb_define_const(rb_mSockConst, "SO_REUSEPORT", INTEGER2NUM(SO_REUSEPORT));
1290 #endif
1291 #if defined(SO_TYPE)
1292     /* Get the socket type */
1293     rb_define_const(rb_cSocket, "SO_TYPE", INTEGER2NUM(SO_TYPE));
1294     /* Get the socket type */
1295     rb_define_const(rb_mSockConst, "SO_TYPE", INTEGER2NUM(SO_TYPE));
1296 #endif
1297 #if defined(SO_ERROR)
1298     /* Get and clear the error status */
1299     rb_define_const(rb_cSocket, "SO_ERROR", INTEGER2NUM(SO_ERROR));
1300     /* Get and clear the error status */
1301     rb_define_const(rb_mSockConst, "SO_ERROR", INTEGER2NUM(SO_ERROR));
1302 #endif
1303 #if defined(SO_DONTROUTE)
1304     /* Use interface addresses */
1305     rb_define_const(rb_cSocket, "SO_DONTROUTE", INTEGER2NUM(SO_DONTROUTE));
1306     /* Use interface addresses */
1307     rb_define_const(rb_mSockConst, "SO_DONTROUTE", INTEGER2NUM(SO_DONTROUTE));
1308 #endif
1309 #if defined(SO_BROADCAST)
1310     /* Permit sending of broadcast messages */
1311     rb_define_const(rb_cSocket, "SO_BROADCAST", INTEGER2NUM(SO_BROADCAST));
1312     /* Permit sending of broadcast messages */
1313     rb_define_const(rb_mSockConst, "SO_BROADCAST", INTEGER2NUM(SO_BROADCAST));
1314 #endif
1315 #if defined(SO_SNDBUF)
1316     /* Send buffer size */
1317     rb_define_const(rb_cSocket, "SO_SNDBUF", INTEGER2NUM(SO_SNDBUF));
1318     /* Send buffer size */
1319     rb_define_const(rb_mSockConst, "SO_SNDBUF", INTEGER2NUM(SO_SNDBUF));
1320 #endif
1321 #if defined(SO_RCVBUF)
1322     /* Receive buffer size */
1323     rb_define_const(rb_cSocket, "SO_RCVBUF", INTEGER2NUM(SO_RCVBUF));
1324     /* Receive buffer size */
1325     rb_define_const(rb_mSockConst, "SO_RCVBUF", INTEGER2NUM(SO_RCVBUF));
1326 #endif
1327 #if defined(SO_SNDBUFFORCE)
1328     /* Send buffer size without wmem_max limit (Linux 2.6.14) */
1329     rb_define_const(rb_cSocket, "SO_SNDBUFFORCE", INTEGER2NUM(SO_SNDBUFFORCE));
1330     /* Send buffer size without wmem_max limit (Linux 2.6.14) */
1331     rb_define_const(rb_mSockConst, "SO_SNDBUFFORCE", INTEGER2NUM(SO_SNDBUFFORCE));
1332 #endif
1333 #if defined(SO_RCVBUFFORCE)
1334     /* Receive buffer size without rmem_max limit (Linux 2.6.14) */
1335     rb_define_const(rb_cSocket, "SO_RCVBUFFORCE", INTEGER2NUM(SO_RCVBUFFORCE));
1336     /* Receive buffer size without rmem_max limit (Linux 2.6.14) */
1337     rb_define_const(rb_mSockConst, "SO_RCVBUFFORCE", INTEGER2NUM(SO_RCVBUFFORCE));
1338 #endif
1339 #if defined(SO_KEEPALIVE)
1340     /* Keep connections alive */
1341     rb_define_const(rb_cSocket, "SO_KEEPALIVE", INTEGER2NUM(SO_KEEPALIVE));
1342     /* Keep connections alive */
1343     rb_define_const(rb_mSockConst, "SO_KEEPALIVE", INTEGER2NUM(SO_KEEPALIVE));
1344 #endif
1345 #if defined(SO_OOBINLINE)
1346     /* Leave received out-of-band data in-line */
1347     rb_define_const(rb_cSocket, "SO_OOBINLINE", INTEGER2NUM(SO_OOBINLINE));
1348     /* Leave received out-of-band data in-line */
1349     rb_define_const(rb_mSockConst, "SO_OOBINLINE", INTEGER2NUM(SO_OOBINLINE));
1350 #endif
1351 #if defined(SO_NO_CHECK)
1352     /* Disable checksums */
1353     rb_define_const(rb_cSocket, "SO_NO_CHECK", INTEGER2NUM(SO_NO_CHECK));
1354     /* Disable checksums */
1355     rb_define_const(rb_mSockConst, "SO_NO_CHECK", INTEGER2NUM(SO_NO_CHECK));
1356 #endif
1357 #if defined(SO_PRIORITY)
1358     /* The protocol-defined priority for all packets on this socket */
1359     rb_define_const(rb_cSocket, "SO_PRIORITY", INTEGER2NUM(SO_PRIORITY));
1360     /* The protocol-defined priority for all packets on this socket */
1361     rb_define_const(rb_mSockConst, "SO_PRIORITY", INTEGER2NUM(SO_PRIORITY));
1362 #endif
1363 #if defined(SO_LINGER)
1364     /* Linger on close if data is present */
1365     rb_define_const(rb_cSocket, "SO_LINGER", INTEGER2NUM(SO_LINGER));
1366     /* Linger on close if data is present */
1367     rb_define_const(rb_mSockConst, "SO_LINGER", INTEGER2NUM(SO_LINGER));
1368 #endif
1369 #if defined(SO_PASSCRED)
1370     /* Receive SCM_CREDENTIALS messages */
1371     rb_define_const(rb_cSocket, "SO_PASSCRED", INTEGER2NUM(SO_PASSCRED));
1372     /* Receive SCM_CREDENTIALS messages */
1373     rb_define_const(rb_mSockConst, "SO_PASSCRED", INTEGER2NUM(SO_PASSCRED));
1374 #endif
1375 #if defined(SO_PEERCRED)
1376     /* The credentials of the foreign process connected to this socket */
1377     rb_define_const(rb_cSocket, "SO_PEERCRED", INTEGER2NUM(SO_PEERCRED));
1378     /* The credentials of the foreign process connected to this socket */
1379     rb_define_const(rb_mSockConst, "SO_PEERCRED", INTEGER2NUM(SO_PEERCRED));
1380 #endif
1381 #if defined(SO_RCVLOWAT)
1382     /* Receive low-water mark */
1383     rb_define_const(rb_cSocket, "SO_RCVLOWAT", INTEGER2NUM(SO_RCVLOWAT));
1384     /* Receive low-water mark */
1385     rb_define_const(rb_mSockConst, "SO_RCVLOWAT", INTEGER2NUM(SO_RCVLOWAT));
1386 #endif
1387 #if defined(SO_SNDLOWAT)
1388     /* Send low-water mark */
1389     rb_define_const(rb_cSocket, "SO_SNDLOWAT", INTEGER2NUM(SO_SNDLOWAT));
1390     /* Send low-water mark */
1391     rb_define_const(rb_mSockConst, "SO_SNDLOWAT", INTEGER2NUM(SO_SNDLOWAT));
1392 #endif
1393 #if defined(SO_RCVTIMEO)
1394     /* Receive timeout */
1395     rb_define_const(rb_cSocket, "SO_RCVTIMEO", INTEGER2NUM(SO_RCVTIMEO));
1396     /* Receive timeout */
1397     rb_define_const(rb_mSockConst, "SO_RCVTIMEO", INTEGER2NUM(SO_RCVTIMEO));
1398 #endif
1399 #if defined(SO_SNDTIMEO)
1400     /* Send timeout */
1401     rb_define_const(rb_cSocket, "SO_SNDTIMEO", INTEGER2NUM(SO_SNDTIMEO));
1402     /* Send timeout */
1403     rb_define_const(rb_mSockConst, "SO_SNDTIMEO", INTEGER2NUM(SO_SNDTIMEO));
1404 #endif
1405 #if defined(SO_ACCEPTCONN)
1406     /* Socket has had listen() called on it */
1407     rb_define_const(rb_cSocket, "SO_ACCEPTCONN", INTEGER2NUM(SO_ACCEPTCONN));
1408     /* Socket has had listen() called on it */
1409     rb_define_const(rb_mSockConst, "SO_ACCEPTCONN", INTEGER2NUM(SO_ACCEPTCONN));
1410 #endif
1411 #if defined(SO_USELOOPBACK)
1412     /* Bypass hardware when possible */
1413     rb_define_const(rb_cSocket, "SO_USELOOPBACK", INTEGER2NUM(SO_USELOOPBACK));
1414     /* Bypass hardware when possible */
1415     rb_define_const(rb_mSockConst, "SO_USELOOPBACK", INTEGER2NUM(SO_USELOOPBACK));
1416 #endif
1417 #if defined(SO_ACCEPTFILTER)
1418     /* There is an accept filter */
1419     rb_define_const(rb_cSocket, "SO_ACCEPTFILTER", INTEGER2NUM(SO_ACCEPTFILTER));
1420     /* There is an accept filter */
1421     rb_define_const(rb_mSockConst, "SO_ACCEPTFILTER", INTEGER2NUM(SO_ACCEPTFILTER));
1422 #endif
1423 #if defined(SO_DONTTRUNC)
1424     /* Retain unread data */
1425     rb_define_const(rb_cSocket, "SO_DONTTRUNC", INTEGER2NUM(SO_DONTTRUNC));
1426     /* Retain unread data */
1427     rb_define_const(rb_mSockConst, "SO_DONTTRUNC", INTEGER2NUM(SO_DONTTRUNC));
1428 #endif
1429 #if defined(SO_WANTMORE)
1430     /* Give a hint when more data is ready */
1431     rb_define_const(rb_cSocket, "SO_WANTMORE", INTEGER2NUM(SO_WANTMORE));
1432     /* Give a hint when more data is ready */
1433     rb_define_const(rb_mSockConst, "SO_WANTMORE", INTEGER2NUM(SO_WANTMORE));
1434 #endif
1435 #if defined(SO_WANTOOBFLAG)
1436     /* OOB data is wanted in MSG_FLAG on receive */
1437     rb_define_const(rb_cSocket, "SO_WANTOOBFLAG", INTEGER2NUM(SO_WANTOOBFLAG));
1438     /* OOB data is wanted in MSG_FLAG on receive */
1439     rb_define_const(rb_mSockConst, "SO_WANTOOBFLAG", INTEGER2NUM(SO_WANTOOBFLAG));
1440 #endif
1441 #if defined(SO_NREAD)
1442     /* Get first packet byte count */
1443     rb_define_const(rb_cSocket, "SO_NREAD", INTEGER2NUM(SO_NREAD));
1444     /* Get first packet byte count */
1445     rb_define_const(rb_mSockConst, "SO_NREAD", INTEGER2NUM(SO_NREAD));
1446 #endif
1447 #if defined(SO_NKE)
1448     /* Install socket-level Network Kernel Extension */
1449     rb_define_const(rb_cSocket, "SO_NKE", INTEGER2NUM(SO_NKE));
1450     /* Install socket-level Network Kernel Extension */
1451     rb_define_const(rb_mSockConst, "SO_NKE", INTEGER2NUM(SO_NKE));
1452 #endif
1453 #if defined(SO_NOSIGPIPE)
1454     /* Don't SIGPIPE on EPIPE */
1455     rb_define_const(rb_cSocket, "SO_NOSIGPIPE", INTEGER2NUM(SO_NOSIGPIPE));
1456     /* Don't SIGPIPE on EPIPE */
1457     rb_define_const(rb_mSockConst, "SO_NOSIGPIPE", INTEGER2NUM(SO_NOSIGPIPE));
1458 #endif
1459 #if defined(SO_SECURITY_AUTHENTICATION)
1460     /*  */
1461     rb_define_const(rb_cSocket, "SO_SECURITY_AUTHENTICATION", INTEGER2NUM(SO_SECURITY_AUTHENTICATION));
1462     /*  */
1463     rb_define_const(rb_mSockConst, "SO_SECURITY_AUTHENTICATION", INTEGER2NUM(SO_SECURITY_AUTHENTICATION));
1464 #endif
1465 #if defined(SO_SECURITY_ENCRYPTION_TRANSPORT)
1466     /*  */
1467     rb_define_const(rb_cSocket, "SO_SECURITY_ENCRYPTION_TRANSPORT", INTEGER2NUM(SO_SECURITY_ENCRYPTION_TRANSPORT));
1468     /*  */
1469     rb_define_const(rb_mSockConst, "SO_SECURITY_ENCRYPTION_TRANSPORT", INTEGER2NUM(SO_SECURITY_ENCRYPTION_TRANSPORT));
1470 #endif
1471 #if defined(SO_SECURITY_ENCRYPTION_NETWORK)
1472     /*  */
1473     rb_define_const(rb_cSocket, "SO_SECURITY_ENCRYPTION_NETWORK", INTEGER2NUM(SO_SECURITY_ENCRYPTION_NETWORK));
1474     /*  */
1475     rb_define_const(rb_mSockConst, "SO_SECURITY_ENCRYPTION_NETWORK", INTEGER2NUM(SO_SECURITY_ENCRYPTION_NETWORK));
1476 #endif
1477 #if defined(SO_BINDTODEVICE)
1478     /* Only send packets from the given interface */
1479     rb_define_const(rb_cSocket, "SO_BINDTODEVICE", INTEGER2NUM(SO_BINDTODEVICE));
1480     /* Only send packets from the given interface */
1481     rb_define_const(rb_mSockConst, "SO_BINDTODEVICE", INTEGER2NUM(SO_BINDTODEVICE));
1482 #endif
1483 #if defined(SO_ATTACH_FILTER)
1484     /* Attach an accept filter */
1485     rb_define_const(rb_cSocket, "SO_ATTACH_FILTER", INTEGER2NUM(SO_ATTACH_FILTER));
1486     /* Attach an accept filter */
1487     rb_define_const(rb_mSockConst, "SO_ATTACH_FILTER", INTEGER2NUM(SO_ATTACH_FILTER));
1488 #endif
1489 #if defined(SO_DETACH_FILTER)
1490     /* Detach an accept filter */
1491     rb_define_const(rb_cSocket, "SO_DETACH_FILTER", INTEGER2NUM(SO_DETACH_FILTER));
1492     /* Detach an accept filter */
1493     rb_define_const(rb_mSockConst, "SO_DETACH_FILTER", INTEGER2NUM(SO_DETACH_FILTER));
1494 #endif
1495 #if defined(SO_GET_FILTER)
1496     /* Obtain filter set by SO_ATTACH_FILTER (Linux 3.8) */
1497     rb_define_const(rb_cSocket, "SO_GET_FILTER", INTEGER2NUM(SO_GET_FILTER));
1498     /* Obtain filter set by SO_ATTACH_FILTER (Linux 3.8) */
1499     rb_define_const(rb_mSockConst, "SO_GET_FILTER", INTEGER2NUM(SO_GET_FILTER));
1500 #endif
1501 #if defined(SO_PEERNAME)
1502     /* Name of the connecting user */
1503     rb_define_const(rb_cSocket, "SO_PEERNAME", INTEGER2NUM(SO_PEERNAME));
1504     /* Name of the connecting user */
1505     rb_define_const(rb_mSockConst, "SO_PEERNAME", INTEGER2NUM(SO_PEERNAME));
1506 #endif
1507 #if defined(SO_TIMESTAMP)
1508     /* Receive timestamp with datagrams (timeval) */
1509     rb_define_const(rb_cSocket, "SO_TIMESTAMP", INTEGER2NUM(SO_TIMESTAMP));
1510     /* Receive timestamp with datagrams (timeval) */
1511     rb_define_const(rb_mSockConst, "SO_TIMESTAMP", INTEGER2NUM(SO_TIMESTAMP));
1512 #endif
1513 #if defined(SO_TIMESTAMPNS)
1514     /* Receive nanosecond timestamp with datagrams (timespec) */
1515     rb_define_const(rb_cSocket, "SO_TIMESTAMPNS", INTEGER2NUM(SO_TIMESTAMPNS));
1516     /* Receive nanosecond timestamp with datagrams (timespec) */
1517     rb_define_const(rb_mSockConst, "SO_TIMESTAMPNS", INTEGER2NUM(SO_TIMESTAMPNS));
1518 #endif
1519 #if defined(SO_BINTIME)
1520     /* Receive timestamp with datagrams (bintime) */
1521     rb_define_const(rb_cSocket, "SO_BINTIME", INTEGER2NUM(SO_BINTIME));
1522     /* Receive timestamp with datagrams (bintime) */
1523     rb_define_const(rb_mSockConst, "SO_BINTIME", INTEGER2NUM(SO_BINTIME));
1524 #endif
1525 #if defined(SO_RECVUCRED)
1526     /* Receive user credentials with datagram */
1527     rb_define_const(rb_cSocket, "SO_RECVUCRED", INTEGER2NUM(SO_RECVUCRED));
1528     /* Receive user credentials with datagram */
1529     rb_define_const(rb_mSockConst, "SO_RECVUCRED", INTEGER2NUM(SO_RECVUCRED));
1530 #endif
1531 #if defined(SO_MAC_EXEMPT)
1532     /* Mandatory Access Control exemption for unlabeled peers */
1533     rb_define_const(rb_cSocket, "SO_MAC_EXEMPT", INTEGER2NUM(SO_MAC_EXEMPT));
1534     /* Mandatory Access Control exemption for unlabeled peers */
1535     rb_define_const(rb_mSockConst, "SO_MAC_EXEMPT", INTEGER2NUM(SO_MAC_EXEMPT));
1536 #endif
1537 #if defined(SO_ALLZONES)
1538     /* Bypass zone boundaries */
1539     rb_define_const(rb_cSocket, "SO_ALLZONES", INTEGER2NUM(SO_ALLZONES));
1540     /* Bypass zone boundaries */
1541     rb_define_const(rb_mSockConst, "SO_ALLZONES", INTEGER2NUM(SO_ALLZONES));
1542 #endif
1543 #if defined(SO_PEERSEC)
1544     /* Obtain the security credentials (Linux 2.6.2) */
1545     rb_define_const(rb_cSocket, "SO_PEERSEC", INTEGER2NUM(SO_PEERSEC));
1546     /* Obtain the security credentials (Linux 2.6.2) */
1547     rb_define_const(rb_mSockConst, "SO_PEERSEC", INTEGER2NUM(SO_PEERSEC));
1548 #endif
1549 #if defined(SO_PASSSEC)
1550     /* Toggle security context passing (Linux 2.6.18) */
1551     rb_define_const(rb_cSocket, "SO_PASSSEC", INTEGER2NUM(SO_PASSSEC));
1552     /* Toggle security context passing (Linux 2.6.18) */
1553     rb_define_const(rb_mSockConst, "SO_PASSSEC", INTEGER2NUM(SO_PASSSEC));
1554 #endif
1555 #if defined(SO_MARK)
1556     /* Set the mark for mark-based routing (Linux 2.6.25) */
1557     rb_define_const(rb_cSocket, "SO_MARK", INTEGER2NUM(SO_MARK));
1558     /* Set the mark for mark-based routing (Linux 2.6.25) */
1559     rb_define_const(rb_mSockConst, "SO_MARK", INTEGER2NUM(SO_MARK));
1560 #endif
1561 #if defined(SO_TIMESTAMPING)
1562     /* Time stamping of incoming and outgoing packets (Linux 2.6.30) */
1563     rb_define_const(rb_cSocket, "SO_TIMESTAMPING", INTEGER2NUM(SO_TIMESTAMPING));
1564     /* Time stamping of incoming and outgoing packets (Linux 2.6.30) */
1565     rb_define_const(rb_mSockConst, "SO_TIMESTAMPING", INTEGER2NUM(SO_TIMESTAMPING));
1566 #endif
1567 #if defined(SO_PROTOCOL)
1568     /* Protocol given for socket() (Linux 2.6.32) */
1569     rb_define_const(rb_cSocket, "SO_PROTOCOL", INTEGER2NUM(SO_PROTOCOL));
1570     /* Protocol given for socket() (Linux 2.6.32) */
1571     rb_define_const(rb_mSockConst, "SO_PROTOCOL", INTEGER2NUM(SO_PROTOCOL));
1572 #endif
1573 #if defined(SO_DOMAIN)
1574     /* Domain given for socket() (Linux 2.6.32) */
1575     rb_define_const(rb_cSocket, "SO_DOMAIN", INTEGER2NUM(SO_DOMAIN));
1576     /* Domain given for socket() (Linux 2.6.32) */
1577     rb_define_const(rb_mSockConst, "SO_DOMAIN", INTEGER2NUM(SO_DOMAIN));
1578 #endif
1579 #if defined(SO_RXQ_OVFL)
1580     /* Toggle cmsg for number of packets dropped (Linux 2.6.33) */
1581     rb_define_const(rb_cSocket, "SO_RXQ_OVFL", INTEGER2NUM(SO_RXQ_OVFL));
1582     /* Toggle cmsg for number of packets dropped (Linux 2.6.33) */
1583     rb_define_const(rb_mSockConst, "SO_RXQ_OVFL", INTEGER2NUM(SO_RXQ_OVFL));
1584 #endif
1585 #if defined(SO_WIFI_STATUS)
1586     /* Toggle cmsg for wifi status (Linux 3.3) */
1587     rb_define_const(rb_cSocket, "SO_WIFI_STATUS", INTEGER2NUM(SO_WIFI_STATUS));
1588     /* Toggle cmsg for wifi status (Linux 3.3) */
1589     rb_define_const(rb_mSockConst, "SO_WIFI_STATUS", INTEGER2NUM(SO_WIFI_STATUS));
1590 #endif
1591 #if defined(SO_PEEK_OFF)
1592     /* Set the peek offset (Linux 3.4) */
1593     rb_define_const(rb_cSocket, "SO_PEEK_OFF", INTEGER2NUM(SO_PEEK_OFF));
1594     /* Set the peek offset (Linux 3.4) */
1595     rb_define_const(rb_mSockConst, "SO_PEEK_OFF", INTEGER2NUM(SO_PEEK_OFF));
1596 #endif
1597 #if defined(SO_NOFCS)
1598     /* Set netns of a socket (Linux 3.4) */
1599     rb_define_const(rb_cSocket, "SO_NOFCS", INTEGER2NUM(SO_NOFCS));
1600     /* Set netns of a socket (Linux 3.4) */
1601     rb_define_const(rb_mSockConst, "SO_NOFCS", INTEGER2NUM(SO_NOFCS));
1602 #endif
1603 #if defined(SO_LOCK_FILTER)
1604     /* Lock the filter attached to a socket (Linux 3.9) */
1605     rb_define_const(rb_cSocket, "SO_LOCK_FILTER", INTEGER2NUM(SO_LOCK_FILTER));
1606     /* Lock the filter attached to a socket (Linux 3.9) */
1607     rb_define_const(rb_mSockConst, "SO_LOCK_FILTER", INTEGER2NUM(SO_LOCK_FILTER));
1608 #endif
1609 #if defined(SO_SELECT_ERR_QUEUE)
1610     /* Make select() detect socket error queue with errorfds (Linux 3.10) */
1611     rb_define_const(rb_cSocket, "SO_SELECT_ERR_QUEUE", INTEGER2NUM(SO_SELECT_ERR_QUEUE));
1612     /* Make select() detect socket error queue with errorfds (Linux 3.10) */
1613     rb_define_const(rb_mSockConst, "SO_SELECT_ERR_QUEUE", INTEGER2NUM(SO_SELECT_ERR_QUEUE));
1614 #endif
1615 #if defined(SO_BUSY_POLL)
1616     /* Set the threshold in microseconds for low latency polling (Linux 3.11) */
1617     rb_define_const(rb_cSocket, "SO_BUSY_POLL", INTEGER2NUM(SO_BUSY_POLL));
1618     /* Set the threshold in microseconds for low latency polling (Linux 3.11) */
1619     rb_define_const(rb_mSockConst, "SO_BUSY_POLL", INTEGER2NUM(SO_BUSY_POLL));
1620 #endif
1621 #if defined(SO_MAX_PACING_RATE)
1622     /* Cap the rate computed by transport layer. [bytes per second] (Linux 3.13) */
1623     rb_define_const(rb_cSocket, "SO_MAX_PACING_RATE", INTEGER2NUM(SO_MAX_PACING_RATE));
1624     /* Cap the rate computed by transport layer. [bytes per second] (Linux 3.13) */
1625     rb_define_const(rb_mSockConst, "SO_MAX_PACING_RATE", INTEGER2NUM(SO_MAX_PACING_RATE));
1626 #endif
1627 #if defined(SO_BPF_EXTENSIONS)
1628     /* Query supported BPF extensions (Linux 3.14) */
1629     rb_define_const(rb_cSocket, "SO_BPF_EXTENSIONS", INTEGER2NUM(SO_BPF_EXTENSIONS));
1630     /* Query supported BPF extensions (Linux 3.14) */
1631     rb_define_const(rb_mSockConst, "SO_BPF_EXTENSIONS", INTEGER2NUM(SO_BPF_EXTENSIONS));
1632 #endif
1633 #if defined(SOPRI_INTERACTIVE)
1634     /* Interactive socket priority */
1635     rb_define_const(rb_cSocket, "SOPRI_INTERACTIVE", INTEGER2NUM(SOPRI_INTERACTIVE));
1636     /* Interactive socket priority */
1637     rb_define_const(rb_mSockConst, "SOPRI_INTERACTIVE", INTEGER2NUM(SOPRI_INTERACTIVE));
1638 #endif
1639 #if defined(SOPRI_NORMAL)
1640     /* Normal socket priority */
1641     rb_define_const(rb_cSocket, "SOPRI_NORMAL", INTEGER2NUM(SOPRI_NORMAL));
1642     /* Normal socket priority */
1643     rb_define_const(rb_mSockConst, "SOPRI_NORMAL", INTEGER2NUM(SOPRI_NORMAL));
1644 #endif
1645 #if defined(SOPRI_BACKGROUND)
1646     /* Background socket priority */
1647     rb_define_const(rb_cSocket, "SOPRI_BACKGROUND", INTEGER2NUM(SOPRI_BACKGROUND));
1648     /* Background socket priority */
1649     rb_define_const(rb_mSockConst, "SOPRI_BACKGROUND", INTEGER2NUM(SOPRI_BACKGROUND));
1650 #endif
1651 #if defined(IPX_TYPE)
1652     /*  */
1653     rb_define_const(rb_cSocket, "IPX_TYPE", INTEGER2NUM(IPX_TYPE));
1654     /*  */
1655     rb_define_const(rb_mSockConst, "IPX_TYPE", INTEGER2NUM(IPX_TYPE));
1656 #endif
1657 #if defined(TCP_NODELAY)
1658     /* Don't delay sending to coalesce packets */
1659     rb_define_const(rb_cSocket, "TCP_NODELAY", INTEGER2NUM(TCP_NODELAY));
1660     /* Don't delay sending to coalesce packets */
1661     rb_define_const(rb_mSockConst, "TCP_NODELAY", INTEGER2NUM(TCP_NODELAY));
1662 #endif
1663 #if defined(TCP_MAXSEG)
1664     /* Set maximum segment size */
1665     rb_define_const(rb_cSocket, "TCP_MAXSEG", INTEGER2NUM(TCP_MAXSEG));
1666     /* Set maximum segment size */
1667     rb_define_const(rb_mSockConst, "TCP_MAXSEG", INTEGER2NUM(TCP_MAXSEG));
1668 #endif
1669 #if defined(TCP_CORK)
1670     /* Don't send partial frames (Linux 2.2, glibc 2.2) */
1671     rb_define_const(rb_cSocket, "TCP_CORK", INTEGER2NUM(TCP_CORK));
1672     /* Don't send partial frames (Linux 2.2, glibc 2.2) */
1673     rb_define_const(rb_mSockConst, "TCP_CORK", INTEGER2NUM(TCP_CORK));
1674 #endif
1675 #if defined(TCP_DEFER_ACCEPT)
1676     /* Don't notify a listening socket until data is ready (Linux 2.4, glibc 2.2) */
1677     rb_define_const(rb_cSocket, "TCP_DEFER_ACCEPT", INTEGER2NUM(TCP_DEFER_ACCEPT));
1678     /* Don't notify a listening socket until data is ready (Linux 2.4, glibc 2.2) */
1679     rb_define_const(rb_mSockConst, "TCP_DEFER_ACCEPT", INTEGER2NUM(TCP_DEFER_ACCEPT));
1680 #endif
1681 #if defined(TCP_INFO)
1682     /* Retrieve information about this socket (Linux 2.4, glibc 2.2) */
1683     rb_define_const(rb_cSocket, "TCP_INFO", INTEGER2NUM(TCP_INFO));
1684     /* Retrieve information about this socket (Linux 2.4, glibc 2.2) */
1685     rb_define_const(rb_mSockConst, "TCP_INFO", INTEGER2NUM(TCP_INFO));
1686 #endif
1687 #if defined(TCP_KEEPCNT)
1688     /* Maximum number of keepalive probes allowed before dropping a connection (Linux 2.4, glibc 2.2) */
1689     rb_define_const(rb_cSocket, "TCP_KEEPCNT", INTEGER2NUM(TCP_KEEPCNT));
1690     /* Maximum number of keepalive probes allowed before dropping a connection (Linux 2.4, glibc 2.2) */
1691     rb_define_const(rb_mSockConst, "TCP_KEEPCNT", INTEGER2NUM(TCP_KEEPCNT));
1692 #endif
1693 #if defined(TCP_KEEPIDLE)
1694     /* Idle time before keepalive probes are sent (Linux 2.4, glibc 2.2) */
1695     rb_define_const(rb_cSocket, "TCP_KEEPIDLE", INTEGER2NUM(TCP_KEEPIDLE));
1696     /* Idle time before keepalive probes are sent (Linux 2.4, glibc 2.2) */
1697     rb_define_const(rb_mSockConst, "TCP_KEEPIDLE", INTEGER2NUM(TCP_KEEPIDLE));
1698 #endif
1699 #if defined(TCP_KEEPINTVL)
1700     /* Time between keepalive probes (Linux 2.4, glibc 2.2) */
1701     rb_define_const(rb_cSocket, "TCP_KEEPINTVL", INTEGER2NUM(TCP_KEEPINTVL));
1702     /* Time between keepalive probes (Linux 2.4, glibc 2.2) */
1703     rb_define_const(rb_mSockConst, "TCP_KEEPINTVL", INTEGER2NUM(TCP_KEEPINTVL));
1704 #endif
1705 #if defined(TCP_LINGER2)
1706     /* Lifetime of orphaned FIN_WAIT2 sockets (Linux 2.4, glibc 2.2) */
1707     rb_define_const(rb_cSocket, "TCP_LINGER2", INTEGER2NUM(TCP_LINGER2));
1708     /* Lifetime of orphaned FIN_WAIT2 sockets (Linux 2.4, glibc 2.2) */
1709     rb_define_const(rb_mSockConst, "TCP_LINGER2", INTEGER2NUM(TCP_LINGER2));
1710 #endif
1711 #if defined(TCP_MD5SIG)
1712     /* Use MD5 digests (RFC2385, Linux 2.6.20, glibc 2.7) */
1713     rb_define_const(rb_cSocket, "TCP_MD5SIG", INTEGER2NUM(TCP_MD5SIG));
1714     /* Use MD5 digests (RFC2385, Linux 2.6.20, glibc 2.7) */
1715     rb_define_const(rb_mSockConst, "TCP_MD5SIG", INTEGER2NUM(TCP_MD5SIG));
1716 #endif
1717 #if defined(TCP_NOOPT)
1718     /* Don't use TCP options */
1719     rb_define_const(rb_cSocket, "TCP_NOOPT", INTEGER2NUM(TCP_NOOPT));
1720     /* Don't use TCP options */
1721     rb_define_const(rb_mSockConst, "TCP_NOOPT", INTEGER2NUM(TCP_NOOPT));
1722 #endif
1723 #if defined(TCP_NOPUSH)
1724     /* Don't push the last block of write */
1725     rb_define_const(rb_cSocket, "TCP_NOPUSH", INTEGER2NUM(TCP_NOPUSH));
1726     /* Don't push the last block of write */
1727     rb_define_const(rb_mSockConst, "TCP_NOPUSH", INTEGER2NUM(TCP_NOPUSH));
1728 #endif
1729 #if defined(TCP_QUICKACK)
1730     /* Enable quickack mode (Linux 2.4.4, glibc 2.3) */
1731     rb_define_const(rb_cSocket, "TCP_QUICKACK", INTEGER2NUM(TCP_QUICKACK));
1732     /* Enable quickack mode (Linux 2.4.4, glibc 2.3) */
1733     rb_define_const(rb_mSockConst, "TCP_QUICKACK", INTEGER2NUM(TCP_QUICKACK));
1734 #endif
1735 #if defined(TCP_SYNCNT)
1736     /* Number of SYN retransmits before a connection is dropped (Linux 2.4, glibc 2.2) */
1737     rb_define_const(rb_cSocket, "TCP_SYNCNT", INTEGER2NUM(TCP_SYNCNT));
1738     /* Number of SYN retransmits before a connection is dropped (Linux 2.4, glibc 2.2) */
1739     rb_define_const(rb_mSockConst, "TCP_SYNCNT", INTEGER2NUM(TCP_SYNCNT));
1740 #endif
1741 #if defined(TCP_WINDOW_CLAMP)
1742     /* Clamp the size of the advertised window (Linux 2.4, glibc 2.2) */
1743     rb_define_const(rb_cSocket, "TCP_WINDOW_CLAMP", INTEGER2NUM(TCP_WINDOW_CLAMP));
1744     /* Clamp the size of the advertised window (Linux 2.4, glibc 2.2) */
1745     rb_define_const(rb_mSockConst, "TCP_WINDOW_CLAMP", INTEGER2NUM(TCP_WINDOW_CLAMP));
1746 #endif
1747 #if defined(TCP_FASTOPEN)
1748     /* Reduce step of the handshake process (Linux 3.7, glibc 2.18) */
1749     rb_define_const(rb_cSocket, "TCP_FASTOPEN", INTEGER2NUM(TCP_FASTOPEN));
1750     /* Reduce step of the handshake process (Linux 3.7, glibc 2.18) */
1751     rb_define_const(rb_mSockConst, "TCP_FASTOPEN", INTEGER2NUM(TCP_FASTOPEN));
1752 #endif
1753 #if defined(TCP_CONGESTION)
1754     /* TCP congestion control algorithm (Linux 2.6.13, glibc 2.6) */
1755     rb_define_const(rb_cSocket, "TCP_CONGESTION", INTEGER2NUM(TCP_CONGESTION));
1756     /* TCP congestion control algorithm (Linux 2.6.13, glibc 2.6) */
1757     rb_define_const(rb_mSockConst, "TCP_CONGESTION", INTEGER2NUM(TCP_CONGESTION));
1758 #endif
1759 #if defined(TCP_COOKIE_TRANSACTIONS)
1760     /* TCP Cookie Transactions (Linux 2.6.33, glibc 2.18) */
1761     rb_define_const(rb_cSocket, "TCP_COOKIE_TRANSACTIONS", INTEGER2NUM(TCP_COOKIE_TRANSACTIONS));
1762     /* TCP Cookie Transactions (Linux 2.6.33, glibc 2.18) */
1763     rb_define_const(rb_mSockConst, "TCP_COOKIE_TRANSACTIONS", INTEGER2NUM(TCP_COOKIE_TRANSACTIONS));
1764 #endif
1765 #if defined(TCP_QUEUE_SEQ)
1766     /* Sequence of a queue for repair mode (Linux 3.5, glibc 2.18) */
1767     rb_define_const(rb_cSocket, "TCP_QUEUE_SEQ", INTEGER2NUM(TCP_QUEUE_SEQ));
1768     /* Sequence of a queue for repair mode (Linux 3.5, glibc 2.18) */
1769     rb_define_const(rb_mSockConst, "TCP_QUEUE_SEQ", INTEGER2NUM(TCP_QUEUE_SEQ));
1770 #endif
1771 #if defined(TCP_REPAIR)
1772     /* Repair mode (Linux 3.5, glibc 2.18) */
1773     rb_define_const(rb_cSocket, "TCP_REPAIR", INTEGER2NUM(TCP_REPAIR));
1774     /* Repair mode (Linux 3.5, glibc 2.18) */
1775     rb_define_const(rb_mSockConst, "TCP_REPAIR", INTEGER2NUM(TCP_REPAIR));
1776 #endif
1777 #if defined(TCP_REPAIR_OPTIONS)
1778     /* Options for repair mode (Linux 3.5, glibc 2.18) */
1779     rb_define_const(rb_cSocket, "TCP_REPAIR_OPTIONS", INTEGER2NUM(TCP_REPAIR_OPTIONS));
1780     /* Options for repair mode (Linux 3.5, glibc 2.18) */
1781     rb_define_const(rb_mSockConst, "TCP_REPAIR_OPTIONS", INTEGER2NUM(TCP_REPAIR_OPTIONS));
1782 #endif
1783 #if defined(TCP_REPAIR_QUEUE)
1784     /* Queue for repair mode (Linux 3.5, glibc 2.18) */
1785     rb_define_const(rb_cSocket, "TCP_REPAIR_QUEUE", INTEGER2NUM(TCP_REPAIR_QUEUE));
1786     /* Queue for repair mode (Linux 3.5, glibc 2.18) */
1787     rb_define_const(rb_mSockConst, "TCP_REPAIR_QUEUE", INTEGER2NUM(TCP_REPAIR_QUEUE));
1788 #endif
1789 #if defined(TCP_THIN_DUPACK)
1790     /* Duplicated acknowledgments handling for thin-streams (Linux 2.6.34, glibc 2.18) */
1791     rb_define_const(rb_cSocket, "TCP_THIN_DUPACK", INTEGER2NUM(TCP_THIN_DUPACK));
1792     /* Duplicated acknowledgments handling for thin-streams (Linux 2.6.34, glibc 2.18) */
1793     rb_define_const(rb_mSockConst, "TCP_THIN_DUPACK", INTEGER2NUM(TCP_THIN_DUPACK));
1794 #endif
1795 #if defined(TCP_THIN_LINEAR_TIMEOUTS)
1796     /* Linear timeouts for thin-streams (Linux 2.6.34, glibc 2.18) */
1797     rb_define_const(rb_cSocket, "TCP_THIN_LINEAR_TIMEOUTS", INTEGER2NUM(TCP_THIN_LINEAR_TIMEOUTS));
1798     /* Linear timeouts for thin-streams (Linux 2.6.34, glibc 2.18) */
1799     rb_define_const(rb_mSockConst, "TCP_THIN_LINEAR_TIMEOUTS", INTEGER2NUM(TCP_THIN_LINEAR_TIMEOUTS));
1800 #endif
1801 #if defined(TCP_TIMESTAMP)
1802     /* TCP timestamp (Linux 3.9, glibc 2.18) */
1803     rb_define_const(rb_cSocket, "TCP_TIMESTAMP", INTEGER2NUM(TCP_TIMESTAMP));
1804     /* TCP timestamp (Linux 3.9, glibc 2.18) */
1805     rb_define_const(rb_mSockConst, "TCP_TIMESTAMP", INTEGER2NUM(TCP_TIMESTAMP));
1806 #endif
1807 #if defined(TCP_USER_TIMEOUT)
1808     /* Max timeout before a TCP connection is aborted (Linux 2.6.37, glibc 2.18) */
1809     rb_define_const(rb_cSocket, "TCP_USER_TIMEOUT", INTEGER2NUM(TCP_USER_TIMEOUT));
1810     /* Max timeout before a TCP connection is aborted (Linux 2.6.37, glibc 2.18) */
1811     rb_define_const(rb_mSockConst, "TCP_USER_TIMEOUT", INTEGER2NUM(TCP_USER_TIMEOUT));
1812 #endif
1813 #if defined(UDP_CORK)
1814     /* Don't send partial frames (Linux 2.5.44, glibc 2.11) */
1815     rb_define_const(rb_cSocket, "UDP_CORK", INTEGER2NUM(UDP_CORK));
1816     /* Don't send partial frames (Linux 2.5.44, glibc 2.11) */
1817     rb_define_const(rb_mSockConst, "UDP_CORK", INTEGER2NUM(UDP_CORK));
1818 #endif
1819 #if defined(EAI_ADDRFAMILY)
1820     /* Address family for hostname not supported */
1821     rb_define_const(rb_cSocket, "EAI_ADDRFAMILY", INTEGER2NUM(EAI_ADDRFAMILY));
1822     /* Address family for hostname not supported */
1823     rb_define_const(rb_mSockConst, "EAI_ADDRFAMILY", INTEGER2NUM(EAI_ADDRFAMILY));
1824 #endif
1825 #if defined(EAI_AGAIN)
1826     /* Temporary failure in name resolution */
1827     rb_define_const(rb_cSocket, "EAI_AGAIN", INTEGER2NUM(EAI_AGAIN));
1828     /* Temporary failure in name resolution */
1829     rb_define_const(rb_mSockConst, "EAI_AGAIN", INTEGER2NUM(EAI_AGAIN));
1830 #endif
1831 #if defined(EAI_BADFLAGS)
1832     /* Invalid flags */
1833     rb_define_const(rb_cSocket, "EAI_BADFLAGS", INTEGER2NUM(EAI_BADFLAGS));
1834     /* Invalid flags */
1835     rb_define_const(rb_mSockConst, "EAI_BADFLAGS", INTEGER2NUM(EAI_BADFLAGS));
1836 #endif
1837 #if defined(EAI_FAIL)
1838     /* Non-recoverable failure in name resolution */
1839     rb_define_const(rb_cSocket, "EAI_FAIL", INTEGER2NUM(EAI_FAIL));
1840     /* Non-recoverable failure in name resolution */
1841     rb_define_const(rb_mSockConst, "EAI_FAIL", INTEGER2NUM(EAI_FAIL));
1842 #endif
1843 #if defined(EAI_FAMILY)
1844     /* Address family not supported */
1845     rb_define_const(rb_cSocket, "EAI_FAMILY", INTEGER2NUM(EAI_FAMILY));
1846     /* Address family not supported */
1847     rb_define_const(rb_mSockConst, "EAI_FAMILY", INTEGER2NUM(EAI_FAMILY));
1848 #endif
1849 #if defined(EAI_MEMORY)
1850     /* Memory allocation failure */
1851     rb_define_const(rb_cSocket, "EAI_MEMORY", INTEGER2NUM(EAI_MEMORY));
1852     /* Memory allocation failure */
1853     rb_define_const(rb_mSockConst, "EAI_MEMORY", INTEGER2NUM(EAI_MEMORY));
1854 #endif
1855 #if defined(EAI_NODATA)
1856     /* No address associated with hostname */
1857     rb_define_const(rb_cSocket, "EAI_NODATA", INTEGER2NUM(EAI_NODATA));
1858     /* No address associated with hostname */
1859     rb_define_const(rb_mSockConst, "EAI_NODATA", INTEGER2NUM(EAI_NODATA));
1860 #endif
1861 #if defined(EAI_NONAME)
1862     /* Hostname nor servname, or not known */
1863     rb_define_const(rb_cSocket, "EAI_NONAME", INTEGER2NUM(EAI_NONAME));
1864     /* Hostname nor servname, or not known */
1865     rb_define_const(rb_mSockConst, "EAI_NONAME", INTEGER2NUM(EAI_NONAME));
1866 #endif
1867 #if defined(EAI_OVERFLOW)
1868     /* Argument buffer overflow */
1869     rb_define_const(rb_cSocket, "EAI_OVERFLOW", INTEGER2NUM(EAI_OVERFLOW));
1870     /* Argument buffer overflow */
1871     rb_define_const(rb_mSockConst, "EAI_OVERFLOW", INTEGER2NUM(EAI_OVERFLOW));
1872 #endif
1873 #if defined(EAI_SERVICE)
1874     /* Servname not supported for socket type */
1875     rb_define_const(rb_cSocket, "EAI_SERVICE", INTEGER2NUM(EAI_SERVICE));
1876     /* Servname not supported for socket type */
1877     rb_define_const(rb_mSockConst, "EAI_SERVICE", INTEGER2NUM(EAI_SERVICE));
1878 #endif
1879 #if defined(EAI_SOCKTYPE)
1880     /* Socket type not supported */
1881     rb_define_const(rb_cSocket, "EAI_SOCKTYPE", INTEGER2NUM(EAI_SOCKTYPE));
1882     /* Socket type not supported */
1883     rb_define_const(rb_mSockConst, "EAI_SOCKTYPE", INTEGER2NUM(EAI_SOCKTYPE));
1884 #endif
1885 #if defined(EAI_SYSTEM)
1886     /* System error returned in errno */
1887     rb_define_const(rb_cSocket, "EAI_SYSTEM", INTEGER2NUM(EAI_SYSTEM));
1888     /* System error returned in errno */
1889     rb_define_const(rb_mSockConst, "EAI_SYSTEM", INTEGER2NUM(EAI_SYSTEM));
1890 #endif
1891 #if defined(EAI_BADHINTS)
1892     /* Invalid value for hints */
1893     rb_define_const(rb_cSocket, "EAI_BADHINTS", INTEGER2NUM(EAI_BADHINTS));
1894     /* Invalid value for hints */
1895     rb_define_const(rb_mSockConst, "EAI_BADHINTS", INTEGER2NUM(EAI_BADHINTS));
1896 #endif
1897 #if defined(EAI_PROTOCOL)
1898     /* Resolved protocol is unknown */
1899     rb_define_const(rb_cSocket, "EAI_PROTOCOL", INTEGER2NUM(EAI_PROTOCOL));
1900     /* Resolved protocol is unknown */
1901     rb_define_const(rb_mSockConst, "EAI_PROTOCOL", INTEGER2NUM(EAI_PROTOCOL));
1902 #endif
1903 #if defined(EAI_MAX)
1904     /* Maximum error code from getaddrinfo */
1905     rb_define_const(rb_cSocket, "EAI_MAX", INTEGER2NUM(EAI_MAX));
1906     /* Maximum error code from getaddrinfo */
1907     rb_define_const(rb_mSockConst, "EAI_MAX", INTEGER2NUM(EAI_MAX));
1908 #endif
1909 #if defined(AI_PASSIVE)
1910     /* Get address to use with bind() */
1911     rb_define_const(rb_cSocket, "AI_PASSIVE", INTEGER2NUM(AI_PASSIVE));
1912     /* Get address to use with bind() */
1913     rb_define_const(rb_mSockConst, "AI_PASSIVE", INTEGER2NUM(AI_PASSIVE));
1914 #endif
1915 #if defined(AI_CANONNAME)
1916     /* Fill in the canonical name */
1917     rb_define_const(rb_cSocket, "AI_CANONNAME", INTEGER2NUM(AI_CANONNAME));
1918     /* Fill in the canonical name */
1919     rb_define_const(rb_mSockConst, "AI_CANONNAME", INTEGER2NUM(AI_CANONNAME));
1920 #endif
1921 #if defined(AI_NUMERICHOST)
1922     /* Prevent host name resolution */
1923     rb_define_const(rb_cSocket, "AI_NUMERICHOST", INTEGER2NUM(AI_NUMERICHOST));
1924     /* Prevent host name resolution */
1925     rb_define_const(rb_mSockConst, "AI_NUMERICHOST", INTEGER2NUM(AI_NUMERICHOST));
1926 #endif
1927 #if defined(AI_NUMERICSERV)
1928     /* Prevent service name resolution */
1929     rb_define_const(rb_cSocket, "AI_NUMERICSERV", INTEGER2NUM(AI_NUMERICSERV));
1930     /* Prevent service name resolution */
1931     rb_define_const(rb_mSockConst, "AI_NUMERICSERV", INTEGER2NUM(AI_NUMERICSERV));
1932 #endif
1933 #if defined(AI_MASK)
1934     /* Valid flag mask for getaddrinfo (not for application use) */
1935     rb_define_const(rb_cSocket, "AI_MASK", INTEGER2NUM(AI_MASK));
1936     /* Valid flag mask for getaddrinfo (not for application use) */
1937     rb_define_const(rb_mSockConst, "AI_MASK", INTEGER2NUM(AI_MASK));
1938 #endif
1939 #if defined(AI_ALL)
1940     /* Allow all addresses */
1941     rb_define_const(rb_cSocket, "AI_ALL", INTEGER2NUM(AI_ALL));
1942     /* Allow all addresses */
1943     rb_define_const(rb_mSockConst, "AI_ALL", INTEGER2NUM(AI_ALL));
1944 #endif
1945 #if defined(AI_V4MAPPED_CFG)
1946     /* Accept IPv4 mapped addresses if the kernel supports it */
1947     rb_define_const(rb_cSocket, "AI_V4MAPPED_CFG", INTEGER2NUM(AI_V4MAPPED_CFG));
1948     /* Accept IPv4 mapped addresses if the kernel supports it */
1949     rb_define_const(rb_mSockConst, "AI_V4MAPPED_CFG", INTEGER2NUM(AI_V4MAPPED_CFG));
1950 #endif
1951 #if defined(AI_ADDRCONFIG)
1952     /* Accept only if any address is assigned */
1953     rb_define_const(rb_cSocket, "AI_ADDRCONFIG", INTEGER2NUM(AI_ADDRCONFIG));
1954     /* Accept only if any address is assigned */
1955     rb_define_const(rb_mSockConst, "AI_ADDRCONFIG", INTEGER2NUM(AI_ADDRCONFIG));
1956 #endif
1957 #if defined(AI_V4MAPPED)
1958     /* Accept IPv4-mapped IPv6 addresses */
1959     rb_define_const(rb_cSocket, "AI_V4MAPPED", INTEGER2NUM(AI_V4MAPPED));
1960     /* Accept IPv4-mapped IPv6 addresses */
1961     rb_define_const(rb_mSockConst, "AI_V4MAPPED", INTEGER2NUM(AI_V4MAPPED));
1962 #endif
1963 #if defined(AI_DEFAULT)
1964     /* Default flags for getaddrinfo */
1965     rb_define_const(rb_cSocket, "AI_DEFAULT", INTEGER2NUM(AI_DEFAULT));
1966     /* Default flags for getaddrinfo */
1967     rb_define_const(rb_mSockConst, "AI_DEFAULT", INTEGER2NUM(AI_DEFAULT));
1968 #endif
1969 #if defined(NI_MAXHOST)
1970     /* Maximum length of a hostname */
1971     rb_define_const(rb_cSocket, "NI_MAXHOST", INTEGER2NUM(NI_MAXHOST));
1972     /* Maximum length of a hostname */
1973     rb_define_const(rb_mSockConst, "NI_MAXHOST", INTEGER2NUM(NI_MAXHOST));
1974 #endif
1975 #if defined(NI_MAXSERV)
1976     /* Maximum length of a service name */
1977     rb_define_const(rb_cSocket, "NI_MAXSERV", INTEGER2NUM(NI_MAXSERV));
1978     /* Maximum length of a service name */
1979     rb_define_const(rb_mSockConst, "NI_MAXSERV", INTEGER2NUM(NI_MAXSERV));
1980 #endif
1981 #if defined(NI_NOFQDN)
1982     /* An FQDN is not required for local hosts, return only the local part */
1983     rb_define_const(rb_cSocket, "NI_NOFQDN", INTEGER2NUM(NI_NOFQDN));
1984     /* An FQDN is not required for local hosts, return only the local part */
1985     rb_define_const(rb_mSockConst, "NI_NOFQDN", INTEGER2NUM(NI_NOFQDN));
1986 #endif
1987 #if defined(NI_NUMERICHOST)
1988     /* Return a numeric address */
1989     rb_define_const(rb_cSocket, "NI_NUMERICHOST", INTEGER2NUM(NI_NUMERICHOST));
1990     /* Return a numeric address */
1991     rb_define_const(rb_mSockConst, "NI_NUMERICHOST", INTEGER2NUM(NI_NUMERICHOST));
1992 #endif
1993 #if defined(NI_NAMEREQD)
1994     /* A name is required */
1995     rb_define_const(rb_cSocket, "NI_NAMEREQD", INTEGER2NUM(NI_NAMEREQD));
1996     /* A name is required */
1997     rb_define_const(rb_mSockConst, "NI_NAMEREQD", INTEGER2NUM(NI_NAMEREQD));
1998 #endif
1999 #if defined(NI_NUMERICSERV)
2000     /* Return the service name as a digit string */
2001     rb_define_const(rb_cSocket, "NI_NUMERICSERV", INTEGER2NUM(NI_NUMERICSERV));
2002     /* Return the service name as a digit string */
2003     rb_define_const(rb_mSockConst, "NI_NUMERICSERV", INTEGER2NUM(NI_NUMERICSERV));
2004 #endif
2005 #if defined(NI_DGRAM)
2006     /* The service specified is a datagram service (looks up UDP ports) */
2007     rb_define_const(rb_cSocket, "NI_DGRAM", INTEGER2NUM(NI_DGRAM));
2008     /* The service specified is a datagram service (looks up UDP ports) */
2009     rb_define_const(rb_mSockConst, "NI_DGRAM", INTEGER2NUM(NI_DGRAM));
2010 #endif
2011 #if defined(SHUT_RD)
2012     /* Shut down the reading side of the socket */
2013     rb_define_const(rb_cSocket, "SHUT_RD", INTEGER2NUM(SHUT_RD));
2014     /* Shut down the reading side of the socket */
2015     rb_define_const(rb_mSockConst, "SHUT_RD", INTEGER2NUM(SHUT_RD));
2016 #endif
2017 #if defined(SHUT_WR)
2018     /* Shut down the writing side of the socket */
2019     rb_define_const(rb_cSocket, "SHUT_WR", INTEGER2NUM(SHUT_WR));
2020     /* Shut down the writing side of the socket */
2021     rb_define_const(rb_mSockConst, "SHUT_WR", INTEGER2NUM(SHUT_WR));
2022 #endif
2023 #if defined(SHUT_RDWR)
2024     /* Shut down the both sides of the socket */
2025     rb_define_const(rb_cSocket, "SHUT_RDWR", INTEGER2NUM(SHUT_RDWR));
2026     /* Shut down the both sides of the socket */
2027     rb_define_const(rb_mSockConst, "SHUT_RDWR", INTEGER2NUM(SHUT_RDWR));
2028 #endif
2029 #if defined(INET6)
2030 #if defined(IPV6_JOIN_GROUP)
2031     /* Join a group membership */
2032     rb_define_const(rb_cSocket, "IPV6_JOIN_GROUP", INTEGER2NUM(IPV6_JOIN_GROUP));
2033     /* Join a group membership */
2034     rb_define_const(rb_mSockConst, "IPV6_JOIN_GROUP", INTEGER2NUM(IPV6_JOIN_GROUP));
2035 #endif
2036 #endif
2037 #if defined(INET6)
2038 #if defined(IPV6_LEAVE_GROUP)
2039     /* Leave a group membership */
2040     rb_define_const(rb_cSocket, "IPV6_LEAVE_GROUP", INTEGER2NUM(IPV6_LEAVE_GROUP));
2041     /* Leave a group membership */
2042     rb_define_const(rb_mSockConst, "IPV6_LEAVE_GROUP", INTEGER2NUM(IPV6_LEAVE_GROUP));
2043 #endif
2044 #endif
2045 #if defined(INET6)
2046 #if defined(IPV6_MULTICAST_HOPS)
2047     /* IP6 multicast hops */
2048     rb_define_const(rb_cSocket, "IPV6_MULTICAST_HOPS", INTEGER2NUM(IPV6_MULTICAST_HOPS));
2049     /* IP6 multicast hops */
2050     rb_define_const(rb_mSockConst, "IPV6_MULTICAST_HOPS", INTEGER2NUM(IPV6_MULTICAST_HOPS));
2051 #endif
2052 #endif
2053 #if defined(INET6)
2054 #if defined(IPV6_MULTICAST_IF)
2055     /* IP6 multicast interface */
2056     rb_define_const(rb_cSocket, "IPV6_MULTICAST_IF", INTEGER2NUM(IPV6_MULTICAST_IF));
2057     /* IP6 multicast interface */
2058     rb_define_const(rb_mSockConst, "IPV6_MULTICAST_IF", INTEGER2NUM(IPV6_MULTICAST_IF));
2059 #endif
2060 #endif
2061 #if defined(INET6)
2062 #if defined(IPV6_MULTICAST_LOOP)
2063     /* IP6 multicast loopback */
2064     rb_define_const(rb_cSocket, "IPV6_MULTICAST_LOOP", INTEGER2NUM(IPV6_MULTICAST_LOOP));
2065     /* IP6 multicast loopback */
2066     rb_define_const(rb_mSockConst, "IPV6_MULTICAST_LOOP", INTEGER2NUM(IPV6_MULTICAST_LOOP));
2067 #endif
2068 #endif
2069 #if defined(INET6)
2070 #if defined(IPV6_UNICAST_HOPS)
2071     /* IP6 unicast hops */
2072     rb_define_const(rb_cSocket, "IPV6_UNICAST_HOPS", INTEGER2NUM(IPV6_UNICAST_HOPS));
2073     /* IP6 unicast hops */
2074     rb_define_const(rb_mSockConst, "IPV6_UNICAST_HOPS", INTEGER2NUM(IPV6_UNICAST_HOPS));
2075 #endif
2076 #endif
2077 #if defined(INET6)
2078 #if defined(IPV6_V6ONLY)
2079     /* Only bind IPv6 with a wildcard bind */
2080     rb_define_const(rb_cSocket, "IPV6_V6ONLY", INTEGER2NUM(IPV6_V6ONLY));
2081     /* Only bind IPv6 with a wildcard bind */
2082     rb_define_const(rb_mSockConst, "IPV6_V6ONLY", INTEGER2NUM(IPV6_V6ONLY));
2083 #endif
2084 #endif
2085 #if defined(INET6)
2086 #if defined(IPV6_CHECKSUM)
2087     /* Checksum offset for raw sockets */
2088     rb_define_const(rb_cSocket, "IPV6_CHECKSUM", INTEGER2NUM(IPV6_CHECKSUM));
2089     /* Checksum offset for raw sockets */
2090     rb_define_const(rb_mSockConst, "IPV6_CHECKSUM", INTEGER2NUM(IPV6_CHECKSUM));
2091 #endif
2092 #endif
2093 #if defined(INET6)
2094 #if defined(IPV6_DONTFRAG)
2095     /* Don't fragment packets */
2096     rb_define_const(rb_cSocket, "IPV6_DONTFRAG", INTEGER2NUM(IPV6_DONTFRAG));
2097     /* Don't fragment packets */
2098     rb_define_const(rb_mSockConst, "IPV6_DONTFRAG", INTEGER2NUM(IPV6_DONTFRAG));
2099 #endif
2100 #endif
2101 #if defined(INET6)
2102 #if defined(IPV6_DSTOPTS)
2103     /* Destination option */
2104     rb_define_const(rb_cSocket, "IPV6_DSTOPTS", INTEGER2NUM(IPV6_DSTOPTS));
2105     /* Destination option */
2106     rb_define_const(rb_mSockConst, "IPV6_DSTOPTS", INTEGER2NUM(IPV6_DSTOPTS));
2107 #endif
2108 #endif
2109 #if defined(INET6)
2110 #if defined(IPV6_HOPLIMIT)
2111     /* Hop limit */
2112     rb_define_const(rb_cSocket, "IPV6_HOPLIMIT", INTEGER2NUM(IPV6_HOPLIMIT));
2113     /* Hop limit */
2114     rb_define_const(rb_mSockConst, "IPV6_HOPLIMIT", INTEGER2NUM(IPV6_HOPLIMIT));
2115 #endif
2116 #endif
2117 #if defined(INET6)
2118 #if defined(IPV6_HOPOPTS)
2119     /* Hop-by-hop option */
2120     rb_define_const(rb_cSocket, "IPV6_HOPOPTS", INTEGER2NUM(IPV6_HOPOPTS));
2121     /* Hop-by-hop option */
2122     rb_define_const(rb_mSockConst, "IPV6_HOPOPTS", INTEGER2NUM(IPV6_HOPOPTS));
2123 #endif
2124 #endif
2125 #if defined(INET6)
2126 #if defined(IPV6_NEXTHOP)
2127     /* Next hop address */
2128     rb_define_const(rb_cSocket, "IPV6_NEXTHOP", INTEGER2NUM(IPV6_NEXTHOP));
2129     /* Next hop address */
2130     rb_define_const(rb_mSockConst, "IPV6_NEXTHOP", INTEGER2NUM(IPV6_NEXTHOP));
2131 #endif
2132 #endif
2133 #if defined(INET6)
2134 #if defined(IPV6_PATHMTU)
2135     /* Retrieve current path MTU */
2136     rb_define_const(rb_cSocket, "IPV6_PATHMTU", INTEGER2NUM(IPV6_PATHMTU));
2137     /* Retrieve current path MTU */
2138     rb_define_const(rb_mSockConst, "IPV6_PATHMTU", INTEGER2NUM(IPV6_PATHMTU));
2139 #endif
2140 #endif
2141 #if defined(INET6)
2142 #if defined(IPV6_PKTINFO)
2143     /* Receive packet information with datagram */
2144     rb_define_const(rb_cSocket, "IPV6_PKTINFO", INTEGER2NUM(IPV6_PKTINFO));
2145     /* Receive packet information with datagram */
2146     rb_define_const(rb_mSockConst, "IPV6_PKTINFO", INTEGER2NUM(IPV6_PKTINFO));
2147 #endif
2148 #endif
2149 #if defined(INET6)
2150 #if defined(IPV6_RECVDSTOPTS)
2151     /* Receive all IP6 options for response */
2152     rb_define_const(rb_cSocket, "IPV6_RECVDSTOPTS", INTEGER2NUM(IPV6_RECVDSTOPTS));
2153     /* Receive all IP6 options for response */
2154     rb_define_const(rb_mSockConst, "IPV6_RECVDSTOPTS", INTEGER2NUM(IPV6_RECVDSTOPTS));
2155 #endif
2156 #endif
2157 #if defined(INET6)
2158 #if defined(IPV6_RECVHOPLIMIT)
2159     /* Receive hop limit with datagram */
2160     rb_define_const(rb_cSocket, "IPV6_RECVHOPLIMIT", INTEGER2NUM(IPV6_RECVHOPLIMIT));
2161     /* Receive hop limit with datagram */
2162     rb_define_const(rb_mSockConst, "IPV6_RECVHOPLIMIT", INTEGER2NUM(IPV6_RECVHOPLIMIT));
2163 #endif
2164 #endif
2165 #if defined(INET6)
2166 #if defined(IPV6_RECVHOPOPTS)
2167     /* Receive hop-by-hop options */
2168     rb_define_const(rb_cSocket, "IPV6_RECVHOPOPTS", INTEGER2NUM(IPV6_RECVHOPOPTS));
2169     /* Receive hop-by-hop options */
2170     rb_define_const(rb_mSockConst, "IPV6_RECVHOPOPTS", INTEGER2NUM(IPV6_RECVHOPOPTS));
2171 #endif
2172 #endif
2173 #if defined(INET6)
2174 #if defined(IPV6_RECVPKTINFO)
2175     /* Receive destination IP address and incoming interface */
2176     rb_define_const(rb_cSocket, "IPV6_RECVPKTINFO", INTEGER2NUM(IPV6_RECVPKTINFO));
2177     /* Receive destination IP address and incoming interface */
2178     rb_define_const(rb_mSockConst, "IPV6_RECVPKTINFO", INTEGER2NUM(IPV6_RECVPKTINFO));
2179 #endif
2180 #endif
2181 #if defined(INET6)
2182 #if defined(IPV6_RECVRTHDR)
2183     /* Receive routing header */
2184     rb_define_const(rb_cSocket, "IPV6_RECVRTHDR", INTEGER2NUM(IPV6_RECVRTHDR));
2185     /* Receive routing header */
2186     rb_define_const(rb_mSockConst, "IPV6_RECVRTHDR", INTEGER2NUM(IPV6_RECVRTHDR));
2187 #endif
2188 #endif
2189 #if defined(INET6)
2190 #if defined(IPV6_RECVTCLASS)
2191     /* Receive traffic class */
2192     rb_define_const(rb_cSocket, "IPV6_RECVTCLASS", INTEGER2NUM(IPV6_RECVTCLASS));
2193     /* Receive traffic class */
2194     rb_define_const(rb_mSockConst, "IPV6_RECVTCLASS", INTEGER2NUM(IPV6_RECVTCLASS));
2195 #endif
2196 #endif
2197 #if defined(INET6)
2198 #if defined(IPV6_RTHDR)
2199     /* Allows removal of sticky routing headers */
2200     rb_define_const(rb_cSocket, "IPV6_RTHDR", INTEGER2NUM(IPV6_RTHDR));
2201     /* Allows removal of sticky routing headers */
2202     rb_define_const(rb_mSockConst, "IPV6_RTHDR", INTEGER2NUM(IPV6_RTHDR));
2203 #endif
2204 #endif
2205 #if defined(INET6)
2206 #if defined(IPV6_RTHDRDSTOPTS)
2207     /* Allows removal of sticky destination options header */
2208     rb_define_const(rb_cSocket, "IPV6_RTHDRDSTOPTS", INTEGER2NUM(IPV6_RTHDRDSTOPTS));
2209     /* Allows removal of sticky destination options header */
2210     rb_define_const(rb_mSockConst, "IPV6_RTHDRDSTOPTS", INTEGER2NUM(IPV6_RTHDRDSTOPTS));
2211 #endif
2212 #endif
2213 #if defined(INET6)
2214 #if defined(IPV6_RTHDR_TYPE_0)
2215     /* Routing header type 0 */
2216     rb_define_const(rb_cSocket, "IPV6_RTHDR_TYPE_0", INTEGER2NUM(IPV6_RTHDR_TYPE_0));
2217     /* Routing header type 0 */
2218     rb_define_const(rb_mSockConst, "IPV6_RTHDR_TYPE_0", INTEGER2NUM(IPV6_RTHDR_TYPE_0));
2219 #endif
2220 #endif
2221 #if defined(INET6)
2222 #if defined(IPV6_RECVPATHMTU)
2223     /* Receive current path MTU with datagram */
2224     rb_define_const(rb_cSocket, "IPV6_RECVPATHMTU", INTEGER2NUM(IPV6_RECVPATHMTU));
2225     /* Receive current path MTU with datagram */
2226     rb_define_const(rb_mSockConst, "IPV6_RECVPATHMTU", INTEGER2NUM(IPV6_RECVPATHMTU));
2227 #endif
2228 #endif
2229 #if defined(INET6)
2230 #if defined(IPV6_TCLASS)
2231     /* Specify the traffic class */
2232     rb_define_const(rb_cSocket, "IPV6_TCLASS", INTEGER2NUM(IPV6_TCLASS));
2233     /* Specify the traffic class */
2234     rb_define_const(rb_mSockConst, "IPV6_TCLASS", INTEGER2NUM(IPV6_TCLASS));
2235 #endif
2236 #endif
2237 #if defined(INET6)
2238 #if defined(IPV6_USE_MIN_MTU)
2239     /* Use the minimum MTU size */
2240     rb_define_const(rb_cSocket, "IPV6_USE_MIN_MTU", INTEGER2NUM(IPV6_USE_MIN_MTU));
2241     /* Use the minimum MTU size */
2242     rb_define_const(rb_mSockConst, "IPV6_USE_MIN_MTU", INTEGER2NUM(IPV6_USE_MIN_MTU));
2243 #endif
2244 #endif
2245 #if defined(INET_ADDRSTRLEN)
2246     /* Maximum length of an IPv4 address string */
2247     rb_define_const(rb_cSocket, "INET_ADDRSTRLEN", INTEGER2NUM(INET_ADDRSTRLEN));
2248     /* Maximum length of an IPv4 address string */
2249     rb_define_const(rb_mSockConst, "INET_ADDRSTRLEN", INTEGER2NUM(INET_ADDRSTRLEN));
2250 #endif
2251 #if defined(INET6_ADDRSTRLEN)
2252     /* Maximum length of an IPv6 address string */
2253     rb_define_const(rb_cSocket, "INET6_ADDRSTRLEN", INTEGER2NUM(INET6_ADDRSTRLEN));
2254     /* Maximum length of an IPv6 address string */
2255     rb_define_const(rb_mSockConst, "INET6_ADDRSTRLEN", INTEGER2NUM(INET6_ADDRSTRLEN));
2256 #endif
2257 #if defined(IFNAMSIZ)
2258     /* Maximum interface name size */
2259     rb_define_const(rb_cSocket, "IFNAMSIZ", INTEGER2NUM(IFNAMSIZ));
2260     /* Maximum interface name size */
2261     rb_define_const(rb_mSockConst, "IFNAMSIZ", INTEGER2NUM(IFNAMSIZ));
2262 #endif
2263 #if defined(IF_NAMESIZE)
2264     /* Maximum interface name size */
2265     rb_define_const(rb_cSocket, "IF_NAMESIZE", INTEGER2NUM(IF_NAMESIZE));
2266     /* Maximum interface name size */
2267     rb_define_const(rb_mSockConst, "IF_NAMESIZE", INTEGER2NUM(IF_NAMESIZE));
2268 #endif
2269 #if defined(SOMAXCONN)
2270     /* Maximum connection requests that may be queued for a socket */
2271     rb_define_const(rb_cSocket, "SOMAXCONN", INTEGER2NUM(SOMAXCONN));
2272     /* Maximum connection requests that may be queued for a socket */
2273     rb_define_const(rb_mSockConst, "SOMAXCONN", INTEGER2NUM(SOMAXCONN));
2274 #endif
2275 #if defined(SCM_RIGHTS)
2276     /* Access rights */
2277     rb_define_const(rb_cSocket, "SCM_RIGHTS", INTEGER2NUM(SCM_RIGHTS));
2278     /* Access rights */
2279     rb_define_const(rb_mSockConst, "SCM_RIGHTS", INTEGER2NUM(SCM_RIGHTS));
2280 #endif
2281 #if defined(SCM_TIMESTAMP)
2282     /* Timestamp (timeval) */
2283     rb_define_const(rb_cSocket, "SCM_TIMESTAMP", INTEGER2NUM(SCM_TIMESTAMP));
2284     /* Timestamp (timeval) */
2285     rb_define_const(rb_mSockConst, "SCM_TIMESTAMP", INTEGER2NUM(SCM_TIMESTAMP));
2286 #endif
2287 #if defined(SCM_TIMESTAMPNS)
2288     /* Timespec (timespec) */
2289     rb_define_const(rb_cSocket, "SCM_TIMESTAMPNS", INTEGER2NUM(SCM_TIMESTAMPNS));
2290     /* Timespec (timespec) */
2291     rb_define_const(rb_mSockConst, "SCM_TIMESTAMPNS", INTEGER2NUM(SCM_TIMESTAMPNS));
2292 #endif
2293 #if defined(SCM_TIMESTAMPING)
2294     /* Timestamp (timespec list) (Linux 2.6.30) */
2295     rb_define_const(rb_cSocket, "SCM_TIMESTAMPING", INTEGER2NUM(SCM_TIMESTAMPING));
2296     /* Timestamp (timespec list) (Linux 2.6.30) */
2297     rb_define_const(rb_mSockConst, "SCM_TIMESTAMPING", INTEGER2NUM(SCM_TIMESTAMPING));
2298 #endif
2299 #if defined(SCM_BINTIME)
2300     /* Timestamp (bintime) */
2301     rb_define_const(rb_cSocket, "SCM_BINTIME", INTEGER2NUM(SCM_BINTIME));
2302     /* Timestamp (bintime) */
2303     rb_define_const(rb_mSockConst, "SCM_BINTIME", INTEGER2NUM(SCM_BINTIME));
2304 #endif
2305 #if defined(SCM_CREDENTIALS)
2306     /* The sender's credentials */
2307     rb_define_const(rb_cSocket, "SCM_CREDENTIALS", INTEGER2NUM(SCM_CREDENTIALS));
2308     /* The sender's credentials */
2309     rb_define_const(rb_mSockConst, "SCM_CREDENTIALS", INTEGER2NUM(SCM_CREDENTIALS));
2310 #endif
2311 #if defined(SCM_CREDS)
2312     /* Process credentials */
2313     rb_define_const(rb_cSocket, "SCM_CREDS", INTEGER2NUM(SCM_CREDS));
2314     /* Process credentials */
2315     rb_define_const(rb_mSockConst, "SCM_CREDS", INTEGER2NUM(SCM_CREDS));
2316 #endif
2317 #if defined(SCM_UCRED)
2318     /* User credentials */
2319     rb_define_const(rb_cSocket, "SCM_UCRED", INTEGER2NUM(SCM_UCRED));
2320     /* User credentials */
2321     rb_define_const(rb_mSockConst, "SCM_UCRED", INTEGER2NUM(SCM_UCRED));
2322 #endif
2323 #if defined(SCM_WIFI_STATUS)
2324     /* Wifi status (Linux 3.3) */
2325     rb_define_const(rb_cSocket, "SCM_WIFI_STATUS", INTEGER2NUM(SCM_WIFI_STATUS));
2326     /* Wifi status (Linux 3.3) */
2327     rb_define_const(rb_mSockConst, "SCM_WIFI_STATUS", INTEGER2NUM(SCM_WIFI_STATUS));
2328 #endif
2329 #if defined(LOCAL_PEERCRED)
2330     /* Retrieve peer credentials */
2331     rb_define_const(rb_cSocket, "LOCAL_PEERCRED", INTEGER2NUM(LOCAL_PEERCRED));
2332     /* Retrieve peer credentials */
2333     rb_define_const(rb_mSockConst, "LOCAL_PEERCRED", INTEGER2NUM(LOCAL_PEERCRED));
2334 #endif
2335 #if defined(LOCAL_CREDS)
2336     /* Pass credentials to receiver */
2337     rb_define_const(rb_cSocket, "LOCAL_CREDS", INTEGER2NUM(LOCAL_CREDS));
2338     /* Pass credentials to receiver */
2339     rb_define_const(rb_mSockConst, "LOCAL_CREDS", INTEGER2NUM(LOCAL_CREDS));
2340 #endif
2341 #if defined(LOCAL_CONNWAIT)
2342     /* Connect blocks until accepted */
2343     rb_define_const(rb_cSocket, "LOCAL_CONNWAIT", INTEGER2NUM(LOCAL_CONNWAIT));
2344     /* Connect blocks until accepted */
2345     rb_define_const(rb_mSockConst, "LOCAL_CONNWAIT", INTEGER2NUM(LOCAL_CONNWAIT));
2346 #endif
2347 #if defined(IFF_802_1Q_VLAN)
2348     /* 802.1Q VLAN device */
2349     rb_define_const(rb_cSocket, "IFF_802_1Q_VLAN", INTEGER2NUM(IFF_802_1Q_VLAN));
2350     /* 802.1Q VLAN device */
2351     rb_define_const(rb_mSockConst, "IFF_802_1Q_VLAN", INTEGER2NUM(IFF_802_1Q_VLAN));
2352 #endif
2353 #if defined(IFF_ALLMULTI)
2354     /* receive all multicast packets */
2355     rb_define_const(rb_cSocket, "IFF_ALLMULTI", INTEGER2NUM(IFF_ALLMULTI));
2356     /* receive all multicast packets */
2357     rb_define_const(rb_mSockConst, "IFF_ALLMULTI", INTEGER2NUM(IFF_ALLMULTI));
2358 #endif
2359 #if defined(IFF_ALTPHYS)
2360     /* use alternate physical connection */
2361     rb_define_const(rb_cSocket, "IFF_ALTPHYS", INTEGER2NUM(IFF_ALTPHYS));
2362     /* use alternate physical connection */
2363     rb_define_const(rb_mSockConst, "IFF_ALTPHYS", INTEGER2NUM(IFF_ALTPHYS));
2364 #endif
2365 #if defined(IFF_AUTOMEDIA)
2366     /* auto media select active */
2367     rb_define_const(rb_cSocket, "IFF_AUTOMEDIA", INTEGER2NUM(IFF_AUTOMEDIA));
2368     /* auto media select active */
2369     rb_define_const(rb_mSockConst, "IFF_AUTOMEDIA", INTEGER2NUM(IFF_AUTOMEDIA));
2370 #endif
2371 #if defined(IFF_BONDING)
2372     /* bonding master or slave */
2373     rb_define_const(rb_cSocket, "IFF_BONDING", INTEGER2NUM(IFF_BONDING));
2374     /* bonding master or slave */
2375     rb_define_const(rb_mSockConst, "IFF_BONDING", INTEGER2NUM(IFF_BONDING));
2376 #endif
2377 #if defined(IFF_BRIDGE_PORT)
2378     /* device used as bridge port */
2379     rb_define_const(rb_cSocket, "IFF_BRIDGE_PORT", INTEGER2NUM(IFF_BRIDGE_PORT));
2380     /* device used as bridge port */
2381     rb_define_const(rb_mSockConst, "IFF_BRIDGE_PORT", INTEGER2NUM(IFF_BRIDGE_PORT));
2382 #endif
2383 #if defined(IFF_BROADCAST)
2384     /* broadcast address valid */
2385     rb_define_const(rb_cSocket, "IFF_BROADCAST", INTEGER2NUM(IFF_BROADCAST));
2386     /* broadcast address valid */
2387     rb_define_const(rb_mSockConst, "IFF_BROADCAST", INTEGER2NUM(IFF_BROADCAST));
2388 #endif
2389 #if defined(IFF_CANTCONFIG)
2390     /* unconfigurable using ioctl(2) */
2391     rb_define_const(rb_cSocket, "IFF_CANTCONFIG", INTEGER2NUM(IFF_CANTCONFIG));
2392     /* unconfigurable using ioctl(2) */
2393     rb_define_const(rb_mSockConst, "IFF_CANTCONFIG", INTEGER2NUM(IFF_CANTCONFIG));
2394 #endif
2395 #if defined(IFF_DEBUG)
2396     /* turn on debugging */
2397     rb_define_const(rb_cSocket, "IFF_DEBUG", INTEGER2NUM(IFF_DEBUG));
2398     /* turn on debugging */
2399     rb_define_const(rb_mSockConst, "IFF_DEBUG", INTEGER2NUM(IFF_DEBUG));
2400 #endif
2401 #if defined(IFF_DISABLE_NETPOLL)
2402     /* disable netpoll at run-time */
2403     rb_define_const(rb_cSocket, "IFF_DISABLE_NETPOLL", INTEGER2NUM(IFF_DISABLE_NETPOLL));
2404     /* disable netpoll at run-time */
2405     rb_define_const(rb_mSockConst, "IFF_DISABLE_NETPOLL", INTEGER2NUM(IFF_DISABLE_NETPOLL));
2406 #endif
2407 #if defined(IFF_DONT_BRIDGE)
2408     /* disallow bridging this ether dev */
2409     rb_define_const(rb_cSocket, "IFF_DONT_BRIDGE", INTEGER2NUM(IFF_DONT_BRIDGE));
2410     /* disallow bridging this ether dev */
2411     rb_define_const(rb_mSockConst, "IFF_DONT_BRIDGE", INTEGER2NUM(IFF_DONT_BRIDGE));
2412 #endif
2413 #if defined(IFF_DORMANT)
2414     /* driver signals dormant */
2415     rb_define_const(rb_cSocket, "IFF_DORMANT", INTEGER2NUM(IFF_DORMANT));
2416     /* driver signals dormant */
2417     rb_define_const(rb_mSockConst, "IFF_DORMANT", INTEGER2NUM(IFF_DORMANT));
2418 #endif
2419 #if defined(IFF_DRV_OACTIVE)
2420     /* tx hardware queue is full */
2421     rb_define_const(rb_cSocket, "IFF_DRV_OACTIVE", INTEGER2NUM(IFF_DRV_OACTIVE));
2422     /* tx hardware queue is full */
2423     rb_define_const(rb_mSockConst, "IFF_DRV_OACTIVE", INTEGER2NUM(IFF_DRV_OACTIVE));
2424 #endif
2425 #if defined(IFF_DRV_RUNNING)
2426     /* resources allocated */
2427     rb_define_const(rb_cSocket, "IFF_DRV_RUNNING", INTEGER2NUM(IFF_DRV_RUNNING));
2428     /* resources allocated */
2429     rb_define_const(rb_mSockConst, "IFF_DRV_RUNNING", INTEGER2NUM(IFF_DRV_RUNNING));
2430 #endif
2431 #if defined(IFF_DYING)
2432     /* interface is winding down */
2433     rb_define_const(rb_cSocket, "IFF_DYING", INTEGER2NUM(IFF_DYING));
2434     /* interface is winding down */
2435     rb_define_const(rb_mSockConst, "IFF_DYING", INTEGER2NUM(IFF_DYING));
2436 #endif
2437 #if defined(IFF_DYNAMIC)
2438     /* dialup device with changing addresses */
2439     rb_define_const(rb_cSocket, "IFF_DYNAMIC", INTEGER2NUM(IFF_DYNAMIC));
2440     /* dialup device with changing addresses */
2441     rb_define_const(rb_mSockConst, "IFF_DYNAMIC", INTEGER2NUM(IFF_DYNAMIC));
2442 #endif
2443 #if defined(IFF_EBRIDGE)
2444     /* ethernet bridging device */
2445     rb_define_const(rb_cSocket, "IFF_EBRIDGE", INTEGER2NUM(IFF_EBRIDGE));
2446     /* ethernet bridging device */
2447     rb_define_const(rb_mSockConst, "IFF_EBRIDGE", INTEGER2NUM(IFF_EBRIDGE));
2448 #endif
2449 #if defined(IFF_ECHO)
2450     /* echo sent packets */
2451     rb_define_const(rb_cSocket, "IFF_ECHO", INTEGER2NUM(IFF_ECHO));
2452     /* echo sent packets */
2453     rb_define_const(rb_mSockConst, "IFF_ECHO", INTEGER2NUM(IFF_ECHO));
2454 #endif
2455 #if defined(IFF_ISATAP)
2456     /* ISATAP interface (RFC4214) */
2457     rb_define_const(rb_cSocket, "IFF_ISATAP", INTEGER2NUM(IFF_ISATAP));
2458     /* ISATAP interface (RFC4214) */
2459     rb_define_const(rb_mSockConst, "IFF_ISATAP", INTEGER2NUM(IFF_ISATAP));
2460 #endif
2461 #if defined(IFF_LINK0)
2462     /* per link layer defined bit 0 */
2463     rb_define_const(rb_cSocket, "IFF_LINK0", INTEGER2NUM(IFF_LINK0));
2464     /* per link layer defined bit 0 */
2465     rb_define_const(rb_mSockConst, "IFF_LINK0", INTEGER2NUM(IFF_LINK0));
2466 #endif
2467 #if defined(IFF_LINK1)
2468     /* per link layer defined bit 1 */
2469     rb_define_const(rb_cSocket, "IFF_LINK1", INTEGER2NUM(IFF_LINK1));
2470     /* per link layer defined bit 1 */
2471     rb_define_const(rb_mSockConst, "IFF_LINK1", INTEGER2NUM(IFF_LINK1));
2472 #endif
2473 #if defined(IFF_LINK2)
2474     /* per link layer defined bit 2 */
2475     rb_define_const(rb_cSocket, "IFF_LINK2", INTEGER2NUM(IFF_LINK2));
2476     /* per link layer defined bit 2 */
2477     rb_define_const(rb_mSockConst, "IFF_LINK2", INTEGER2NUM(IFF_LINK2));
2478 #endif
2479 #if defined(IFF_LIVE_ADDR_CHANGE)
2480     /* hardware address change when it's running */
2481     rb_define_const(rb_cSocket, "IFF_LIVE_ADDR_CHANGE", INTEGER2NUM(IFF_LIVE_ADDR_CHANGE));
2482     /* hardware address change when it's running */
2483     rb_define_const(rb_mSockConst, "IFF_LIVE_ADDR_CHANGE", INTEGER2NUM(IFF_LIVE_ADDR_CHANGE));
2484 #endif
2485 #if defined(IFF_LOOPBACK)
2486     /* loopback net */
2487     rb_define_const(rb_cSocket, "IFF_LOOPBACK", INTEGER2NUM(IFF_LOOPBACK));
2488     /* loopback net */
2489     rb_define_const(rb_mSockConst, "IFF_LOOPBACK", INTEGER2NUM(IFF_LOOPBACK));
2490 #endif
2491 #if defined(IFF_LOWER_UP)
2492     /* driver signals L1 up */
2493     rb_define_const(rb_cSocket, "IFF_LOWER_UP", INTEGER2NUM(IFF_LOWER_UP));
2494     /* driver signals L1 up */
2495     rb_define_const(rb_mSockConst, "IFF_LOWER_UP", INTEGER2NUM(IFF_LOWER_UP));
2496 #endif
2497 #if defined(IFF_MACVLAN_PORT)
2498     /* device used as macvlan port */
2499     rb_define_const(rb_cSocket, "IFF_MACVLAN_PORT", INTEGER2NUM(IFF_MACVLAN_PORT));
2500     /* device used as macvlan port */
2501     rb_define_const(rb_mSockConst, "IFF_MACVLAN_PORT", INTEGER2NUM(IFF_MACVLAN_PORT));
2502 #endif
2503 #if defined(IFF_MASTER)
2504     /* master of a load balancer */
2505     rb_define_const(rb_cSocket, "IFF_MASTER", INTEGER2NUM(IFF_MASTER));
2506     /* master of a load balancer */
2507     rb_define_const(rb_mSockConst, "IFF_MASTER", INTEGER2NUM(IFF_MASTER));
2508 #endif
2509 #if defined(IFF_MASTER_8023AD)
2510     /* bonding master, 802.3ad. */
2511     rb_define_const(rb_cSocket, "IFF_MASTER_8023AD", INTEGER2NUM(IFF_MASTER_8023AD));
2512     /* bonding master, 802.3ad. */
2513     rb_define_const(rb_mSockConst, "IFF_MASTER_8023AD", INTEGER2NUM(IFF_MASTER_8023AD));
2514 #endif
2515 #if defined(IFF_MASTER_ALB)
2516     /* bonding master, balance-alb. */
2517     rb_define_const(rb_cSocket, "IFF_MASTER_ALB", INTEGER2NUM(IFF_MASTER_ALB));
2518     /* bonding master, balance-alb. */
2519     rb_define_const(rb_mSockConst, "IFF_MASTER_ALB", INTEGER2NUM(IFF_MASTER_ALB));
2520 #endif
2521 #if defined(IFF_MASTER_ARPMON)
2522     /* bonding master, ARP mon in use */
2523     rb_define_const(rb_cSocket, "IFF_MASTER_ARPMON", INTEGER2NUM(IFF_MASTER_ARPMON));
2524     /* bonding master, ARP mon in use */
2525     rb_define_const(rb_mSockConst, "IFF_MASTER_ARPMON", INTEGER2NUM(IFF_MASTER_ARPMON));
2526 #endif
2527 #if defined(IFF_MONITOR)
2528     /* user-requested monitor mode */
2529     rb_define_const(rb_cSocket, "IFF_MONITOR", INTEGER2NUM(IFF_MONITOR));
2530     /* user-requested monitor mode */
2531     rb_define_const(rb_mSockConst, "IFF_MONITOR", INTEGER2NUM(IFF_MONITOR));
2532 #endif
2533 #if defined(IFF_MULTICAST)
2534     /* supports multicast */
2535     rb_define_const(rb_cSocket, "IFF_MULTICAST", INTEGER2NUM(IFF_MULTICAST));
2536     /* supports multicast */
2537     rb_define_const(rb_mSockConst, "IFF_MULTICAST", INTEGER2NUM(IFF_MULTICAST));
2538 #endif
2539 #if defined(IFF_NOARP)
2540     /* no address resolution protocol */
2541     rb_define_const(rb_cSocket, "IFF_NOARP", INTEGER2NUM(IFF_NOARP));
2542     /* no address resolution protocol */
2543     rb_define_const(rb_mSockConst, "IFF_NOARP", INTEGER2NUM(IFF_NOARP));
2544 #endif
2545 #if defined(IFF_NOTRAILERS)
2546     /* avoid use of trailers */
2547     rb_define_const(rb_cSocket, "IFF_NOTRAILERS", INTEGER2NUM(IFF_NOTRAILERS));
2548     /* avoid use of trailers */
2549     rb_define_const(rb_mSockConst, "IFF_NOTRAILERS", INTEGER2NUM(IFF_NOTRAILERS));
2550 #endif
2551 #if defined(IFF_OACTIVE)
2552     /* transmission in progress */
2553     rb_define_const(rb_cSocket, "IFF_OACTIVE", INTEGER2NUM(IFF_OACTIVE));
2554     /* transmission in progress */
2555     rb_define_const(rb_mSockConst, "IFF_OACTIVE", INTEGER2NUM(IFF_OACTIVE));
2556 #endif
2557 #if defined(IFF_OVS_DATAPATH)
2558     /* device used as Open vSwitch datapath port */
2559     rb_define_const(rb_cSocket, "IFF_OVS_DATAPATH", INTEGER2NUM(IFF_OVS_DATAPATH));
2560     /* device used as Open vSwitch datapath port */
2561     rb_define_const(rb_mSockConst, "IFF_OVS_DATAPATH", INTEGER2NUM(IFF_OVS_DATAPATH));
2562 #endif
2563 #if defined(IFF_POINTOPOINT)
2564     /* point-to-point link */
2565     rb_define_const(rb_cSocket, "IFF_POINTOPOINT", INTEGER2NUM(IFF_POINTOPOINT));
2566     /* point-to-point link */
2567     rb_define_const(rb_mSockConst, "IFF_POINTOPOINT", INTEGER2NUM(IFF_POINTOPOINT));
2568 #endif
2569 #if defined(IFF_PORTSEL)
2570     /* can set media type */
2571     rb_define_const(rb_cSocket, "IFF_PORTSEL", INTEGER2NUM(IFF_PORTSEL));
2572     /* can set media type */
2573     rb_define_const(rb_mSockConst, "IFF_PORTSEL", INTEGER2NUM(IFF_PORTSEL));
2574 #endif
2575 #if defined(IFF_PPROMISC)
2576     /* user-requested promisc mode */
2577     rb_define_const(rb_cSocket, "IFF_PPROMISC", INTEGER2NUM(IFF_PPROMISC));
2578     /* user-requested promisc mode */
2579     rb_define_const(rb_mSockConst, "IFF_PPROMISC", INTEGER2NUM(IFF_PPROMISC));
2580 #endif
2581 #if defined(IFF_PROMISC)
2582     /* receive all packets */
2583     rb_define_const(rb_cSocket, "IFF_PROMISC", INTEGER2NUM(IFF_PROMISC));
2584     /* receive all packets */
2585     rb_define_const(rb_mSockConst, "IFF_PROMISC", INTEGER2NUM(IFF_PROMISC));
2586 #endif
2587 #if defined(IFF_RENAMING)
2588     /* interface is being renamed */
2589     rb_define_const(rb_cSocket, "IFF_RENAMING", INTEGER2NUM(IFF_RENAMING));
2590     /* interface is being renamed */
2591     rb_define_const(rb_mSockConst, "IFF_RENAMING", INTEGER2NUM(IFF_RENAMING));
2592 #endif
2593 #if defined(IFF_ROUTE)
2594     /* routing entry installed */
2595     rb_define_const(rb_cSocket, "IFF_ROUTE", INTEGER2NUM(IFF_ROUTE));
2596     /* routing entry installed */
2597     rb_define_const(rb_mSockConst, "IFF_ROUTE", INTEGER2NUM(IFF_ROUTE));
2598 #endif
2599 #if defined(IFF_RUNNING)
2600     /* resources allocated */
2601     rb_define_const(rb_cSocket, "IFF_RUNNING", INTEGER2NUM(IFF_RUNNING));
2602     /* resources allocated */
2603     rb_define_const(rb_mSockConst, "IFF_RUNNING", INTEGER2NUM(IFF_RUNNING));
2604 #endif
2605 #if defined(IFF_SIMPLEX)
2606     /* can't hear own transmissions */
2607     rb_define_const(rb_cSocket, "IFF_SIMPLEX", INTEGER2NUM(IFF_SIMPLEX));
2608     /* can't hear own transmissions */
2609     rb_define_const(rb_mSockConst, "IFF_SIMPLEX", INTEGER2NUM(IFF_SIMPLEX));
2610 #endif
2611 #if defined(IFF_SLAVE)
2612     /* slave of a load balancer */
2613     rb_define_const(rb_cSocket, "IFF_SLAVE", INTEGER2NUM(IFF_SLAVE));
2614     /* slave of a load balancer */
2615     rb_define_const(rb_mSockConst, "IFF_SLAVE", INTEGER2NUM(IFF_SLAVE));
2616 #endif
2617 #if defined(IFF_SLAVE_INACTIVE)
2618     /* bonding slave not the curr. active */
2619     rb_define_const(rb_cSocket, "IFF_SLAVE_INACTIVE", INTEGER2NUM(IFF_SLAVE_INACTIVE));
2620     /* bonding slave not the curr. active */
2621     rb_define_const(rb_mSockConst, "IFF_SLAVE_INACTIVE", INTEGER2NUM(IFF_SLAVE_INACTIVE));
2622 #endif
2623 #if defined(IFF_SLAVE_NEEDARP)
2624     /* need ARPs for validation */
2625     rb_define_const(rb_cSocket, "IFF_SLAVE_NEEDARP", INTEGER2NUM(IFF_SLAVE_NEEDARP));
2626     /* need ARPs for validation */
2627     rb_define_const(rb_mSockConst, "IFF_SLAVE_NEEDARP", INTEGER2NUM(IFF_SLAVE_NEEDARP));
2628 #endif
2629 #if defined(IFF_SMART)
2630     /* interface manages own routes */
2631     rb_define_const(rb_cSocket, "IFF_SMART", INTEGER2NUM(IFF_SMART));
2632     /* interface manages own routes */
2633     rb_define_const(rb_mSockConst, "IFF_SMART", INTEGER2NUM(IFF_SMART));
2634 #endif
2635 #if defined(IFF_STATICARP)
2636     /* static ARP */
2637     rb_define_const(rb_cSocket, "IFF_STATICARP", INTEGER2NUM(IFF_STATICARP));
2638     /* static ARP */
2639     rb_define_const(rb_mSockConst, "IFF_STATICARP", INTEGER2NUM(IFF_STATICARP));
2640 #endif
2641 #if defined(IFF_SUPP_NOFCS)
2642     /* sending custom FCS */
2643     rb_define_const(rb_cSocket, "IFF_SUPP_NOFCS", INTEGER2NUM(IFF_SUPP_NOFCS));
2644     /* sending custom FCS */
2645     rb_define_const(rb_mSockConst, "IFF_SUPP_NOFCS", INTEGER2NUM(IFF_SUPP_NOFCS));
2646 #endif
2647 #if defined(IFF_TEAM_PORT)
2648     /* used as team port */
2649     rb_define_const(rb_cSocket, "IFF_TEAM_PORT", INTEGER2NUM(IFF_TEAM_PORT));
2650     /* used as team port */
2651     rb_define_const(rb_mSockConst, "IFF_TEAM_PORT", INTEGER2NUM(IFF_TEAM_PORT));
2652 #endif
2653 #if defined(IFF_TX_SKB_SHARING)
2654     /* sharing skbs on transmit */
2655     rb_define_const(rb_cSocket, "IFF_TX_SKB_SHARING", INTEGER2NUM(IFF_TX_SKB_SHARING));
2656     /* sharing skbs on transmit */
2657     rb_define_const(rb_mSockConst, "IFF_TX_SKB_SHARING", INTEGER2NUM(IFF_TX_SKB_SHARING));
2658 #endif
2659 #if defined(IFF_UNICAST_FLT)
2660     /* unicast filtering */
2661     rb_define_const(rb_cSocket, "IFF_UNICAST_FLT", INTEGER2NUM(IFF_UNICAST_FLT));
2662     /* unicast filtering */
2663     rb_define_const(rb_mSockConst, "IFF_UNICAST_FLT", INTEGER2NUM(IFF_UNICAST_FLT));
2664 #endif
2665 #if defined(IFF_UP)
2666     /* interface is up */
2667     rb_define_const(rb_cSocket, "IFF_UP", INTEGER2NUM(IFF_UP));
2668     /* interface is up */
2669     rb_define_const(rb_mSockConst, "IFF_UP", INTEGER2NUM(IFF_UP));
2670 #endif
2671 #if defined(IFF_WAN_HDLC)
2672     /* WAN HDLC device */
2673     rb_define_const(rb_cSocket, "IFF_WAN_HDLC", INTEGER2NUM(IFF_WAN_HDLC));
2674     /* WAN HDLC device */
2675     rb_define_const(rb_mSockConst, "IFF_WAN_HDLC", INTEGER2NUM(IFF_WAN_HDLC));
2676 #endif
2677 #if defined(IFF_XMIT_DST_RELEASE)
2678     /* dev_hard_start_xmit() is allowed to release skb->dst */
2679     rb_define_const(rb_cSocket, "IFF_XMIT_DST_RELEASE", INTEGER2NUM(IFF_XMIT_DST_RELEASE));
2680     /* dev_hard_start_xmit() is allowed to release skb->dst */
2681     rb_define_const(rb_mSockConst, "IFF_XMIT_DST_RELEASE", INTEGER2NUM(IFF_XMIT_DST_RELEASE));
2682 #endif
2683 #if defined(IFF_VOLATILE)
2684     /* volatile flags */
2685     rb_define_const(rb_cSocket, "IFF_VOLATILE", INTEGER2NUM(IFF_VOLATILE));
2686     /* volatile flags */
2687     rb_define_const(rb_mSockConst, "IFF_VOLATILE", INTEGER2NUM(IFF_VOLATILE));
2688 #endif
2689 #if defined(IFF_CANTCHANGE)
2690     /* flags not changeable */
2691     rb_define_const(rb_cSocket, "IFF_CANTCHANGE", INTEGER2NUM(IFF_CANTCHANGE));
2692     /* flags not changeable */
2693     rb_define_const(rb_mSockConst, "IFF_CANTCHANGE", INTEGER2NUM(IFF_CANTCHANGE));
2694 #endif
2695 
2696     rsock_intern_family_hash = st_init_numtable();
2697 #ifdef AF_E164
2698     st_insert(rsock_intern_family_hash, (st_data_t)AF_E164, (st_data_t)rb_intern2("AF_E164", 7));
2699 #endif
2700 #ifdef AF_PACKET
2701     st_insert(rsock_intern_family_hash, (st_data_t)AF_PACKET, (st_data_t)rb_intern2("AF_PACKET", 9));
2702 #endif
2703 #ifdef AF_MAX
2704     st_insert(rsock_intern_family_hash, (st_data_t)AF_MAX, (st_data_t)rb_intern2("AF_MAX", 6));
2705 #endif
2706 #ifdef AF_NETGRAPH
2707     st_insert(rsock_intern_family_hash, (st_data_t)AF_NETGRAPH, (st_data_t)rb_intern2("AF_NETGRAPH", 11));
2708 #endif
2709 #ifdef AF_ATM
2710     st_insert(rsock_intern_family_hash, (st_data_t)AF_ATM, (st_data_t)rb_intern2("AF_ATM", 6));
2711 #endif
2712 #ifdef AF_PPP
2713     st_insert(rsock_intern_family_hash, (st_data_t)AF_PPP, (st_data_t)rb_intern2("AF_PPP", 6));
2714 #endif
2715 #ifdef AF_NETBIOS
2716     st_insert(rsock_intern_family_hash, (st_data_t)AF_NETBIOS, (st_data_t)rb_intern2("AF_NETBIOS", 10));
2717 #endif
2718 #ifdef AF_SYSTEM
2719     st_insert(rsock_intern_family_hash, (st_data_t)AF_SYSTEM, (st_data_t)rb_intern2("AF_SYSTEM", 9));
2720 #endif
2721 #ifdef AF_NATM
2722     st_insert(rsock_intern_family_hash, (st_data_t)AF_NATM, (st_data_t)rb_intern2("AF_NATM", 7));
2723 #endif
2724 #ifdef AF_ISDN
2725     st_insert(rsock_intern_family_hash, (st_data_t)AF_ISDN, (st_data_t)rb_intern2("AF_ISDN", 7));
2726 #endif
2727 #ifdef AF_NDRV
2728     st_insert(rsock_intern_family_hash, (st_data_t)AF_NDRV, (st_data_t)rb_intern2("AF_NDRV", 7));
2729 #endif
2730 #ifdef AF_SIP
2731     st_insert(rsock_intern_family_hash, (st_data_t)AF_SIP, (st_data_t)rb_intern2("AF_SIP", 6));
2732 #endif
2733 #ifdef AF_CNT
2734     st_insert(rsock_intern_family_hash, (st_data_t)AF_CNT, (st_data_t)rb_intern2("AF_CNT", 6));
2735 #endif
2736 #ifdef AF_COIP
2737     st_insert(rsock_intern_family_hash, (st_data_t)AF_COIP, (st_data_t)rb_intern2("AF_COIP", 7));
2738 #endif
2739 #ifdef AF_LINK
2740     st_insert(rsock_intern_family_hash, (st_data_t)AF_LINK, (st_data_t)rb_intern2("AF_LINK", 7));
2741 #endif
2742 #ifdef AF_ROUTE
2743     st_insert(rsock_intern_family_hash, (st_data_t)AF_ROUTE, (st_data_t)rb_intern2("AF_ROUTE", 8));
2744 #endif
2745 #ifdef AF_HYLINK
2746     st_insert(rsock_intern_family_hash, (st_data_t)AF_HYLINK, (st_data_t)rb_intern2("AF_HYLINK", 9));
2747 #endif
2748 #ifdef AF_LAT
2749     st_insert(rsock_intern_family_hash, (st_data_t)AF_LAT, (st_data_t)rb_intern2("AF_LAT", 6));
2750 #endif
2751 #ifdef AF_DLI
2752     st_insert(rsock_intern_family_hash, (st_data_t)AF_DLI, (st_data_t)rb_intern2("AF_DLI", 6));
2753 #endif
2754 #ifdef AF_DEC
2755     st_insert(rsock_intern_family_hash, (st_data_t)AF_DEC, (st_data_t)rb_intern2("AF_DEC", 6));
2756 #endif
2757 #ifdef AF_SNA
2758     st_insert(rsock_intern_family_hash, (st_data_t)AF_SNA, (st_data_t)rb_intern2("AF_SNA", 6));
2759 #endif
2760 #ifdef AF_CCITT
2761     st_insert(rsock_intern_family_hash, (st_data_t)AF_CCITT, (st_data_t)rb_intern2("AF_CCITT", 8));
2762 #endif
2763 #ifdef AF_DATAKIT
2764     st_insert(rsock_intern_family_hash, (st_data_t)AF_DATAKIT, (st_data_t)rb_intern2("AF_DATAKIT", 10));
2765 #endif
2766 #ifdef AF_ECMA
2767     st_insert(rsock_intern_family_hash, (st_data_t)AF_ECMA, (st_data_t)rb_intern2("AF_ECMA", 7));
2768 #endif
2769 #ifdef AF_OSI
2770     st_insert(rsock_intern_family_hash, (st_data_t)AF_OSI, (st_data_t)rb_intern2("AF_OSI", 6));
2771 #endif
2772 #ifdef AF_ISO
2773     st_insert(rsock_intern_family_hash, (st_data_t)AF_ISO, (st_data_t)rb_intern2("AF_ISO", 6));
2774 #endif
2775 #ifdef AF_NS
2776     st_insert(rsock_intern_family_hash, (st_data_t)AF_NS, (st_data_t)rb_intern2("AF_NS", 5));
2777 #endif
2778 #ifdef AF_CHAOS
2779     st_insert(rsock_intern_family_hash, (st_data_t)AF_CHAOS, (st_data_t)rb_intern2("AF_CHAOS", 8));
2780 #endif
2781 #ifdef AF_PUP
2782     st_insert(rsock_intern_family_hash, (st_data_t)AF_PUP, (st_data_t)rb_intern2("AF_PUP", 6));
2783 #endif
2784 #ifdef AF_IMPLINK
2785     st_insert(rsock_intern_family_hash, (st_data_t)AF_IMPLINK, (st_data_t)rb_intern2("AF_IMPLINK", 10));
2786 #endif
2787 #ifdef AF_LOCAL
2788     st_insert(rsock_intern_family_hash, (st_data_t)AF_LOCAL, (st_data_t)rb_intern2("AF_LOCAL", 8));
2789 #endif
2790 #ifdef AF_APPLETALK
2791     st_insert(rsock_intern_family_hash, (st_data_t)AF_APPLETALK, (st_data_t)rb_intern2("AF_APPLETALK", 12));
2792 #endif
2793 #ifdef AF_IPX
2794     st_insert(rsock_intern_family_hash, (st_data_t)AF_IPX, (st_data_t)rb_intern2("AF_IPX", 6));
2795 #endif
2796 #ifdef AF_AX25
2797     st_insert(rsock_intern_family_hash, (st_data_t)AF_AX25, (st_data_t)rb_intern2("AF_AX25", 7));
2798 #endif
2799 #ifdef AF_UNIX
2800     st_insert(rsock_intern_family_hash, (st_data_t)AF_UNIX, (st_data_t)rb_intern2("AF_UNIX", 7));
2801 #endif
2802 #ifdef AF_INET6
2803     st_insert(rsock_intern_family_hash, (st_data_t)AF_INET6, (st_data_t)rb_intern2("AF_INET6", 8));
2804 #endif
2805 #ifdef AF_INET
2806     st_insert(rsock_intern_family_hash, (st_data_t)AF_INET, (st_data_t)rb_intern2("AF_INET", 7));
2807 #endif
2808 #ifdef AF_UNSPEC
2809     st_insert(rsock_intern_family_hash, (st_data_t)AF_UNSPEC, (st_data_t)rb_intern2("AF_UNSPEC", 9));
2810 #endif
2811 
2812     rsock_intern_family_noprefix_hash = st_init_numtable();
2813 #ifdef AF_E164
2814     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_E164, (st_data_t)rb_intern2("AF_E164", 7));
2815 #endif
2816 #ifdef AF_PACKET
2817     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_PACKET, (st_data_t)rb_intern2("AF_PACKET", 9));
2818 #endif
2819 #ifdef AF_MAX
2820     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_MAX, (st_data_t)rb_intern2("AF_MAX", 6));
2821 #endif
2822 #ifdef AF_NETGRAPH
2823     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_NETGRAPH, (st_data_t)rb_intern2("AF_NETGRAPH", 11));
2824 #endif
2825 #ifdef AF_ATM
2826     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_ATM, (st_data_t)rb_intern2("AF_ATM", 6));
2827 #endif
2828 #ifdef AF_PPP
2829     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_PPP, (st_data_t)rb_intern2("AF_PPP", 6));
2830 #endif
2831 #ifdef AF_NETBIOS
2832     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_NETBIOS, (st_data_t)rb_intern2("AF_NETBIOS", 10));
2833 #endif
2834 #ifdef AF_SYSTEM
2835     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_SYSTEM, (st_data_t)rb_intern2("AF_SYSTEM", 9));
2836 #endif
2837 #ifdef AF_NATM
2838     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_NATM, (st_data_t)rb_intern2("AF_NATM", 7));
2839 #endif
2840 #ifdef AF_ISDN
2841     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_ISDN, (st_data_t)rb_intern2("AF_ISDN", 7));
2842 #endif
2843 #ifdef AF_NDRV
2844     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_NDRV, (st_data_t)rb_intern2("AF_NDRV", 7));
2845 #endif
2846 #ifdef AF_SIP
2847     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_SIP, (st_data_t)rb_intern2("AF_SIP", 6));
2848 #endif
2849 #ifdef AF_CNT
2850     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_CNT, (st_data_t)rb_intern2("AF_CNT", 6));
2851 #endif
2852 #ifdef AF_COIP
2853     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_COIP, (st_data_t)rb_intern2("AF_COIP", 7));
2854 #endif
2855 #ifdef AF_LINK
2856     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_LINK, (st_data_t)rb_intern2("AF_LINK", 7));
2857 #endif
2858 #ifdef AF_ROUTE
2859     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_ROUTE, (st_data_t)rb_intern2("AF_ROUTE", 8));
2860 #endif
2861 #ifdef AF_HYLINK
2862     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_HYLINK, (st_data_t)rb_intern2("AF_HYLINK", 9));
2863 #endif
2864 #ifdef AF_LAT
2865     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_LAT, (st_data_t)rb_intern2("AF_LAT", 6));
2866 #endif
2867 #ifdef AF_DLI
2868     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_DLI, (st_data_t)rb_intern2("AF_DLI", 6));
2869 #endif
2870 #ifdef AF_DEC
2871     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_DEC, (st_data_t)rb_intern2("AF_DEC", 6));
2872 #endif
2873 #ifdef AF_SNA
2874     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_SNA, (st_data_t)rb_intern2("AF_SNA", 6));
2875 #endif
2876 #ifdef AF_CCITT
2877     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_CCITT, (st_data_t)rb_intern2("AF_CCITT", 8));
2878 #endif
2879 #ifdef AF_DATAKIT
2880     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_DATAKIT, (st_data_t)rb_intern2("AF_DATAKIT", 10));
2881 #endif
2882 #ifdef AF_ECMA
2883     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_ECMA, (st_data_t)rb_intern2("AF_ECMA", 7));
2884 #endif
2885 #ifdef AF_OSI
2886     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_OSI, (st_data_t)rb_intern2("AF_OSI", 6));
2887 #endif
2888 #ifdef AF_ISO
2889     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_ISO, (st_data_t)rb_intern2("AF_ISO", 6));
2890 #endif
2891 #ifdef AF_NS
2892     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_NS, (st_data_t)rb_intern2("AF_NS", 5));
2893 #endif
2894 #ifdef AF_CHAOS
2895     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_CHAOS, (st_data_t)rb_intern2("AF_CHAOS", 8));
2896 #endif
2897 #ifdef AF_PUP
2898     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_PUP, (st_data_t)rb_intern2("AF_PUP", 6));
2899 #endif
2900 #ifdef AF_IMPLINK
2901     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_IMPLINK, (st_data_t)rb_intern2("AF_IMPLINK", 10));
2902 #endif
2903 #ifdef AF_LOCAL
2904     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_LOCAL, (st_data_t)rb_intern2("AF_LOCAL", 8));
2905 #endif
2906 #ifdef AF_APPLETALK
2907     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_APPLETALK, (st_data_t)rb_intern2("AF_APPLETALK", 12));
2908 #endif
2909 #ifdef AF_IPX
2910     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_IPX, (st_data_t)rb_intern2("AF_IPX", 6));
2911 #endif
2912 #ifdef AF_AX25
2913     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_AX25, (st_data_t)rb_intern2("AF_AX25", 7));
2914 #endif
2915 #ifdef AF_UNIX
2916     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_UNIX, (st_data_t)rb_intern2("AF_UNIX", 7));
2917 #endif
2918 #ifdef AF_INET6
2919     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_INET6, (st_data_t)rb_intern2("AF_INET6", 8));
2920 #endif
2921 #ifdef AF_INET
2922     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_INET, (st_data_t)rb_intern2("AF_INET", 7));
2923 #endif
2924 #ifdef AF_UNSPEC
2925     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_UNSPEC, (st_data_t)rb_intern2("AF_UNSPEC", 9));
2926 #endif
2927 #ifdef AF_E164
2928     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_E164, (st_data_t)rb_intern2("E164", 4));
2929 #endif
2930 #ifdef AF_PACKET
2931     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_PACKET, (st_data_t)rb_intern2("PACKET", 6));
2932 #endif
2933 #ifdef AF_MAX
2934     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_MAX, (st_data_t)rb_intern2("MAX", 3));
2935 #endif
2936 #ifdef AF_NETGRAPH
2937     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_NETGRAPH, (st_data_t)rb_intern2("NETGRAPH", 8));
2938 #endif
2939 #ifdef AF_ATM
2940     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_ATM, (st_data_t)rb_intern2("ATM", 3));
2941 #endif
2942 #ifdef AF_PPP
2943     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_PPP, (st_data_t)rb_intern2("PPP", 3));
2944 #endif
2945 #ifdef AF_NETBIOS
2946     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_NETBIOS, (st_data_t)rb_intern2("NETBIOS", 7));
2947 #endif
2948 #ifdef AF_SYSTEM
2949     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_SYSTEM, (st_data_t)rb_intern2("SYSTEM", 6));
2950 #endif
2951 #ifdef AF_NATM
2952     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_NATM, (st_data_t)rb_intern2("NATM", 4));
2953 #endif
2954 #ifdef AF_ISDN
2955     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_ISDN, (st_data_t)rb_intern2("ISDN", 4));
2956 #endif
2957 #ifdef AF_NDRV
2958     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_NDRV, (st_data_t)rb_intern2("NDRV", 4));
2959 #endif
2960 #ifdef AF_SIP
2961     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_SIP, (st_data_t)rb_intern2("SIP", 3));
2962 #endif
2963 #ifdef AF_CNT
2964     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_CNT, (st_data_t)rb_intern2("CNT", 3));
2965 #endif
2966 #ifdef AF_COIP
2967     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_COIP, (st_data_t)rb_intern2("COIP", 4));
2968 #endif
2969 #ifdef AF_LINK
2970     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_LINK, (st_data_t)rb_intern2("LINK", 4));
2971 #endif
2972 #ifdef AF_ROUTE
2973     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_ROUTE, (st_data_t)rb_intern2("ROUTE", 5));
2974 #endif
2975 #ifdef AF_HYLINK
2976     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_HYLINK, (st_data_t)rb_intern2("HYLINK", 6));
2977 #endif
2978 #ifdef AF_LAT
2979     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_LAT, (st_data_t)rb_intern2("LAT", 3));
2980 #endif
2981 #ifdef AF_DLI
2982     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_DLI, (st_data_t)rb_intern2("DLI", 3));
2983 #endif
2984 #ifdef AF_DEC
2985     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_DEC, (st_data_t)rb_intern2("DEC", 3));
2986 #endif
2987 #ifdef AF_SNA
2988     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_SNA, (st_data_t)rb_intern2("SNA", 3));
2989 #endif
2990 #ifdef AF_CCITT
2991     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_CCITT, (st_data_t)rb_intern2("CCITT", 5));
2992 #endif
2993 #ifdef AF_DATAKIT
2994     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_DATAKIT, (st_data_t)rb_intern2("DATAKIT", 7));
2995 #endif
2996 #ifdef AF_ECMA
2997     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_ECMA, (st_data_t)rb_intern2("ECMA", 4));
2998 #endif
2999 #ifdef AF_OSI
3000     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_OSI, (st_data_t)rb_intern2("OSI", 3));
3001 #endif
3002 #ifdef AF_ISO
3003     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_ISO, (st_data_t)rb_intern2("ISO", 3));
3004 #endif
3005 #ifdef AF_NS
3006     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_NS, (st_data_t)rb_intern2("NS", 2));
3007 #endif
3008 #ifdef AF_CHAOS
3009     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_CHAOS, (st_data_t)rb_intern2("CHAOS", 5));
3010 #endif
3011 #ifdef AF_PUP
3012     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_PUP, (st_data_t)rb_intern2("PUP", 3));
3013 #endif
3014 #ifdef AF_IMPLINK
3015     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_IMPLINK, (st_data_t)rb_intern2("IMPLINK", 7));
3016 #endif
3017 #ifdef AF_LOCAL
3018     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_LOCAL, (st_data_t)rb_intern2("LOCAL", 5));
3019 #endif
3020 #ifdef AF_APPLETALK
3021     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_APPLETALK, (st_data_t)rb_intern2("APPLETALK", 9));
3022 #endif
3023 #ifdef AF_IPX
3024     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_IPX, (st_data_t)rb_intern2("IPX", 3));
3025 #endif
3026 #ifdef AF_AX25
3027     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_AX25, (st_data_t)rb_intern2("AX25", 4));
3028 #endif
3029 #ifdef AF_UNIX
3030     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_UNIX, (st_data_t)rb_intern2("UNIX", 4));
3031 #endif
3032 #ifdef AF_INET6
3033     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_INET6, (st_data_t)rb_intern2("INET6", 5));
3034 #endif
3035 #ifdef AF_INET
3036     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_INET, (st_data_t)rb_intern2("INET", 4));
3037 #endif
3038 #ifdef AF_UNSPEC
3039     st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_UNSPEC, (st_data_t)rb_intern2("UNSPEC", 6));
3040 #endif
3041 
3042     rsock_intern_protocol_family_hash = st_init_numtable();
3043 #ifdef PF_KEY
3044     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_KEY, (st_data_t)rb_intern2("PF_KEY", 6));
3045 #endif
3046 #ifdef PF_PIP
3047     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_PIP, (st_data_t)rb_intern2("PF_PIP", 6));
3048 #endif
3049 #ifdef PF_RTIP
3050     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_RTIP, (st_data_t)rb_intern2("PF_RTIP", 7));
3051 #endif
3052 #ifdef PF_XTP
3053     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_XTP, (st_data_t)rb_intern2("PF_XTP", 6));
3054 #endif
3055 #ifdef PF_PACKET
3056     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_PACKET, (st_data_t)rb_intern2("PF_PACKET", 9));
3057 #endif
3058 #ifdef PF_MAX
3059     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_MAX, (st_data_t)rb_intern2("PF_MAX", 6));
3060 #endif
3061 #ifdef PF_NETGRAPH
3062     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_NETGRAPH, (st_data_t)rb_intern2("PF_NETGRAPH", 11));
3063 #endif
3064 #ifdef PF_ATM
3065     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_ATM, (st_data_t)rb_intern2("PF_ATM", 6));
3066 #endif
3067 #ifdef PF_PPP
3068     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_PPP, (st_data_t)rb_intern2("PF_PPP", 6));
3069 #endif
3070 #ifdef PF_NETBIOS
3071     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_NETBIOS, (st_data_t)rb_intern2("PF_NETBIOS", 10));
3072 #endif
3073 #ifdef PF_SYSTEM
3074     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_SYSTEM, (st_data_t)rb_intern2("PF_SYSTEM", 9));
3075 #endif
3076 #ifdef PF_NATM
3077     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_NATM, (st_data_t)rb_intern2("PF_NATM", 7));
3078 #endif
3079 #ifdef PF_ISDN
3080     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_ISDN, (st_data_t)rb_intern2("PF_ISDN", 7));
3081 #endif
3082 #ifdef PF_NDRV
3083     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_NDRV, (st_data_t)rb_intern2("PF_NDRV", 7));
3084 #endif
3085 #ifdef PF_SIP
3086     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_SIP, (st_data_t)rb_intern2("PF_SIP", 6));
3087 #endif
3088 #ifdef PF_CNT
3089     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_CNT, (st_data_t)rb_intern2("PF_CNT", 6));
3090 #endif
3091 #ifdef PF_COIP
3092     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_COIP, (st_data_t)rb_intern2("PF_COIP", 7));
3093 #endif
3094 #ifdef PF_LINK
3095     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_LINK, (st_data_t)rb_intern2("PF_LINK", 7));
3096 #endif
3097 #ifdef PF_ROUTE
3098     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_ROUTE, (st_data_t)rb_intern2("PF_ROUTE", 8));
3099 #endif
3100 #ifdef PF_HYLINK
3101     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_HYLINK, (st_data_t)rb_intern2("PF_HYLINK", 9));
3102 #endif
3103 #ifdef PF_LAT
3104     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_LAT, (st_data_t)rb_intern2("PF_LAT", 6));
3105 #endif
3106 #ifdef PF_DLI
3107     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_DLI, (st_data_t)rb_intern2("PF_DLI", 6));
3108 #endif
3109 #ifdef PF_DEC
3110     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_DEC, (st_data_t)rb_intern2("PF_DEC", 6));
3111 #endif
3112 #ifdef PF_SNA
3113     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_SNA, (st_data_t)rb_intern2("PF_SNA", 6));
3114 #endif
3115 #ifdef PF_CCITT
3116     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_CCITT, (st_data_t)rb_intern2("PF_CCITT", 8));
3117 #endif
3118 #ifdef PF_DATAKIT
3119     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_DATAKIT, (st_data_t)rb_intern2("PF_DATAKIT", 10));
3120 #endif
3121 #ifdef PF_ECMA
3122     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_ECMA, (st_data_t)rb_intern2("PF_ECMA", 7));
3123 #endif
3124 #ifdef PF_OSI
3125     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_OSI, (st_data_t)rb_intern2("PF_OSI", 6));
3126 #endif
3127 #ifdef PF_ISO
3128     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_ISO, (st_data_t)rb_intern2("PF_ISO", 6));
3129 #endif
3130 #ifdef PF_NS
3131     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_NS, (st_data_t)rb_intern2("PF_NS", 5));
3132 #endif
3133 #ifdef PF_CHAOS
3134     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_CHAOS, (st_data_t)rb_intern2("PF_CHAOS", 8));
3135 #endif
3136 #ifdef PF_PUP
3137     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_PUP, (st_data_t)rb_intern2("PF_PUP", 6));
3138 #endif
3139 #ifdef PF_IMPLINK
3140     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_IMPLINK, (st_data_t)rb_intern2("PF_IMPLINK", 10));
3141 #endif
3142 #ifdef PF_LOCAL
3143     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_LOCAL, (st_data_t)rb_intern2("PF_LOCAL", 8));
3144 #endif
3145 #ifdef PF_APPLETALK
3146     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_APPLETALK, (st_data_t)rb_intern2("PF_APPLETALK", 12));
3147 #endif
3148 #ifdef PF_IPX
3149     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_IPX, (st_data_t)rb_intern2("PF_IPX", 6));
3150 #endif
3151 #ifdef PF_AX25
3152     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_AX25, (st_data_t)rb_intern2("PF_AX25", 7));
3153 #endif
3154 #ifdef PF_UNIX
3155     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_UNIX, (st_data_t)rb_intern2("PF_UNIX", 7));
3156 #endif
3157 #ifdef PF_INET6
3158     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_INET6, (st_data_t)rb_intern2("PF_INET6", 8));
3159 #endif
3160 #ifdef PF_INET
3161     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_INET, (st_data_t)rb_intern2("PF_INET", 7));
3162 #endif
3163 #ifdef PF_UNSPEC
3164     st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_UNSPEC, (st_data_t)rb_intern2("PF_UNSPEC", 9));
3165 #endif
3166 
3167     rsock_intern_socktype_hash = st_init_numtable();
3168 #ifdef SOCK_PACKET
3169     st_insert(rsock_intern_socktype_hash, (st_data_t)SOCK_PACKET, (st_data_t)rb_intern2("SOCK_PACKET", 11));
3170 #endif
3171 #ifdef SOCK_SEQPACKET
3172     st_insert(rsock_intern_socktype_hash, (st_data_t)SOCK_SEQPACKET, (st_data_t)rb_intern2("SOCK_SEQPACKET", 14));
3173 #endif
3174 #ifdef SOCK_RDM
3175     st_insert(rsock_intern_socktype_hash, (st_data_t)SOCK_RDM, (st_data_t)rb_intern2("SOCK_RDM", 8));
3176 #endif
3177 #ifdef SOCK_RAW
3178     st_insert(rsock_intern_socktype_hash, (st_data_t)SOCK_RAW, (st_data_t)rb_intern2("SOCK_RAW", 8));
3179 #endif
3180 #ifdef SOCK_DGRAM
3181     st_insert(rsock_intern_socktype_hash, (st_data_t)SOCK_DGRAM, (st_data_t)rb_intern2("SOCK_DGRAM", 10));
3182 #endif
3183 #ifdef SOCK_STREAM
3184     st_insert(rsock_intern_socktype_hash, (st_data_t)SOCK_STREAM, (st_data_t)rb_intern2("SOCK_STREAM", 11));
3185 #endif
3186 
3187     rsock_intern_ipproto_hash = st_init_numtable();
3188 #ifdef IPPROTO_MAX
3189     st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_MAX, (st_data_t)rb_intern2("IPPROTO_MAX", 11));
3190 #endif
3191 #ifdef IPPROTO_RAW
3192     st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_RAW, (st_data_t)rb_intern2("IPPROTO_RAW", 11));
3193 #endif
3194 #ifdef IPPROTO_ROUTING
3195     st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_ROUTING, (st_data_t)rb_intern2("IPPROTO_ROUTING", 15));
3196 #endif
3197 #ifdef IPPROTO_NONE
3198     st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_NONE, (st_data_t)rb_intern2("IPPROTO_NONE", 12));
3199 #endif
3200 #ifdef IPPROTO_IPV6
3201     st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_IPV6, (st_data_t)rb_intern2("IPPROTO_IPV6", 12));
3202 #endif
3203 #ifdef IPPROTO_ICMPV6
3204     st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_ICMPV6, (st_data_t)rb_intern2("IPPROTO_ICMPV6", 14));
3205 #endif
3206 #ifdef IPPROTO_HOPOPTS
3207     st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_HOPOPTS, (st_data_t)rb_intern2("IPPROTO_HOPOPTS", 15));
3208 #endif
3209 #ifdef IPPROTO_FRAGMENT
3210     st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_FRAGMENT, (st_data_t)rb_intern2("IPPROTO_FRAGMENT", 16));
3211 #endif
3212 #ifdef IPPROTO_ESP
3213     st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_ESP, (st_data_t)rb_intern2("IPPROTO_ESP", 11));
3214 #endif
3215 #ifdef IPPROTO_DSTOPTS
3216     st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_DSTOPTS, (st_data_t)rb_intern2("IPPROTO_DSTOPTS", 15));
3217 #endif
3218 #ifdef IPPROTO_AH
3219     st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_AH, (st_data_t)rb_intern2("IPPROTO_AH", 10));
3220 #endif
3221 #ifdef IPPROTO_BIP
3222     st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_BIP, (st_data_t)rb_intern2("IPPROTO_BIP", 11));
3223 #endif
3224 #ifdef IPPROTO_EON
3225     st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_EON, (st_data_t)rb_intern2("IPPROTO_EON", 11));
3226 #endif
3227 #ifdef IPPROTO_XTP
3228     st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_XTP, (st_data_t)rb_intern2("IPPROTO_XTP", 11));
3229 #endif
3230 #ifdef IPPROTO_TP
3231     st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_TP, (st_data_t)rb_intern2("IPPROTO_TP", 10));
3232 #endif
3233 #ifdef IPPROTO_ND
3234     st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_ND, (st_data_t)rb_intern2("IPPROTO_ND", 10));
3235 #endif
3236 #ifdef IPPROTO_HELLO
3237     st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_HELLO, (st_data_t)rb_intern2("IPPROTO_HELLO", 13));
3238 #endif
3239 #ifdef IPPROTO_IDP
3240     st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_IDP, (st_data_t)rb_intern2("IPPROTO_IDP", 11));
3241 #endif
3242 #ifdef IPPROTO_UDP
3243     st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_UDP, (st_data_t)rb_intern2("IPPROTO_UDP", 11));
3244 #endif
3245 #ifdef IPPROTO_PUP
3246     st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_PUP, (st_data_t)rb_intern2("IPPROTO_PUP", 11));
3247 #endif
3248 #ifdef IPPROTO_EGP
3249     st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_EGP, (st_data_t)rb_intern2("IPPROTO_EGP", 11));
3250 #endif
3251 #ifdef IPPROTO_TCP
3252     st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_TCP, (st_data_t)rb_intern2("IPPROTO_TCP", 11));
3253 #endif
3254 #ifdef IPPROTO_GGP
3255     st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_GGP, (st_data_t)rb_intern2("IPPROTO_GGP", 11));
3256 #endif
3257 #ifdef IPPROTO_IGMP
3258     st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_IGMP, (st_data_t)rb_intern2("IPPROTO_IGMP", 12));
3259 #endif
3260 #ifdef IPPROTO_ICMP
3261     st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_ICMP, (st_data_t)rb_intern2("IPPROTO_ICMP", 12));
3262 #endif
3263 #ifdef IPPROTO_IP
3264     st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_IP, (st_data_t)rb_intern2("IPPROTO_IP", 10));
3265 #endif
3266 
3267     rsock_intern_iplevel_hash = st_init_numtable();
3268 #ifdef IPPROTO_MAX
3269     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_MAX, (st_data_t)rb_intern2("IPPROTO_MAX", 11));
3270 #endif
3271 #ifdef IPPROTO_RAW
3272     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_RAW, (st_data_t)rb_intern2("IPPROTO_RAW", 11));
3273 #endif
3274 #ifdef IPPROTO_ROUTING
3275     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_ROUTING, (st_data_t)rb_intern2("IPPROTO_ROUTING", 15));
3276 #endif
3277 #ifdef IPPROTO_NONE
3278     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_NONE, (st_data_t)rb_intern2("IPPROTO_NONE", 12));
3279 #endif
3280 #ifdef IPPROTO_IPV6
3281     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_IPV6, (st_data_t)rb_intern2("IPPROTO_IPV6", 12));
3282 #endif
3283 #ifdef IPPROTO_ICMPV6
3284     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_ICMPV6, (st_data_t)rb_intern2("IPPROTO_ICMPV6", 14));
3285 #endif
3286 #ifdef IPPROTO_HOPOPTS
3287     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_HOPOPTS, (st_data_t)rb_intern2("IPPROTO_HOPOPTS", 15));
3288 #endif
3289 #ifdef IPPROTO_FRAGMENT
3290     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_FRAGMENT, (st_data_t)rb_intern2("IPPROTO_FRAGMENT", 16));
3291 #endif
3292 #ifdef IPPROTO_ESP
3293     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_ESP, (st_data_t)rb_intern2("IPPROTO_ESP", 11));
3294 #endif
3295 #ifdef IPPROTO_DSTOPTS
3296     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_DSTOPTS, (st_data_t)rb_intern2("IPPROTO_DSTOPTS", 15));
3297 #endif
3298 #ifdef IPPROTO_AH
3299     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_AH, (st_data_t)rb_intern2("IPPROTO_AH", 10));
3300 #endif
3301 #ifdef IPPROTO_BIP
3302     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_BIP, (st_data_t)rb_intern2("IPPROTO_BIP", 11));
3303 #endif
3304 #ifdef IPPROTO_EON
3305     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_EON, (st_data_t)rb_intern2("IPPROTO_EON", 11));
3306 #endif
3307 #ifdef IPPROTO_XTP
3308     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_XTP, (st_data_t)rb_intern2("IPPROTO_XTP", 11));
3309 #endif
3310 #ifdef IPPROTO_TP
3311     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_TP, (st_data_t)rb_intern2("IPPROTO_TP", 10));
3312 #endif
3313 #ifdef IPPROTO_ND
3314     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_ND, (st_data_t)rb_intern2("IPPROTO_ND", 10));
3315 #endif
3316 #ifdef IPPROTO_HELLO
3317     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_HELLO, (st_data_t)rb_intern2("IPPROTO_HELLO", 13));
3318 #endif
3319 #ifdef IPPROTO_IDP
3320     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_IDP, (st_data_t)rb_intern2("IPPROTO_IDP", 11));
3321 #endif
3322 #ifdef IPPROTO_UDP
3323     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_UDP, (st_data_t)rb_intern2("IPPROTO_UDP", 11));
3324 #endif
3325 #ifdef IPPROTO_PUP
3326     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_PUP, (st_data_t)rb_intern2("IPPROTO_PUP", 11));
3327 #endif
3328 #ifdef IPPROTO_EGP
3329     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_EGP, (st_data_t)rb_intern2("IPPROTO_EGP", 11));
3330 #endif
3331 #ifdef IPPROTO_TCP
3332     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_TCP, (st_data_t)rb_intern2("IPPROTO_TCP", 11));
3333 #endif
3334 #ifdef IPPROTO_GGP
3335     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_GGP, (st_data_t)rb_intern2("IPPROTO_GGP", 11));
3336 #endif
3337 #ifdef IPPROTO_IGMP
3338     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_IGMP, (st_data_t)rb_intern2("IPPROTO_IGMP", 12));
3339 #endif
3340 #ifdef IPPROTO_ICMP
3341     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_ICMP, (st_data_t)rb_intern2("IPPROTO_ICMP", 12));
3342 #endif
3343 #ifdef IPPROTO_IP
3344     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_IP, (st_data_t)rb_intern2("IPPROTO_IP", 10));
3345 #endif
3346 #ifdef SOL_SOCKET
3347     st_insert(rsock_intern_iplevel_hash, (st_data_t)SOL_SOCKET, (st_data_t)rb_intern2("SOL_SOCKET", 10));
3348 #endif
3349 #ifdef IPPROTO_MAX
3350     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_MAX, (st_data_t)rb_intern2("MAX", 3));
3351 #endif
3352 #ifdef IPPROTO_RAW
3353     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_RAW, (st_data_t)rb_intern2("RAW", 3));
3354 #endif
3355 #ifdef IPPROTO_ROUTING
3356     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_ROUTING, (st_data_t)rb_intern2("ROUTING", 7));
3357 #endif
3358 #ifdef IPPROTO_NONE
3359     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_NONE, (st_data_t)rb_intern2("NONE", 4));
3360 #endif
3361 #ifdef IPPROTO_IPV6
3362     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_IPV6, (st_data_t)rb_intern2("IPV6", 4));
3363 #endif
3364 #ifdef IPPROTO_ICMPV6
3365     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_ICMPV6, (st_data_t)rb_intern2("ICMPV6", 6));
3366 #endif
3367 #ifdef IPPROTO_HOPOPTS
3368     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_HOPOPTS, (st_data_t)rb_intern2("HOPOPTS", 7));
3369 #endif
3370 #ifdef IPPROTO_FRAGMENT
3371     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_FRAGMENT, (st_data_t)rb_intern2("FRAGMENT", 8));
3372 #endif
3373 #ifdef IPPROTO_ESP
3374     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_ESP, (st_data_t)rb_intern2("ESP", 3));
3375 #endif
3376 #ifdef IPPROTO_DSTOPTS
3377     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_DSTOPTS, (st_data_t)rb_intern2("DSTOPTS", 7));
3378 #endif
3379 #ifdef IPPROTO_AH
3380     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_AH, (st_data_t)rb_intern2("AH", 2));
3381 #endif
3382 #ifdef IPPROTO_BIP
3383     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_BIP, (st_data_t)rb_intern2("BIP", 3));
3384 #endif
3385 #ifdef IPPROTO_EON
3386     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_EON, (st_data_t)rb_intern2("EON", 3));
3387 #endif
3388 #ifdef IPPROTO_XTP
3389     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_XTP, (st_data_t)rb_intern2("XTP", 3));
3390 #endif
3391 #ifdef IPPROTO_TP
3392     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_TP, (st_data_t)rb_intern2("TP", 2));
3393 #endif
3394 #ifdef IPPROTO_ND
3395     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_ND, (st_data_t)rb_intern2("ND", 2));
3396 #endif
3397 #ifdef IPPROTO_HELLO
3398     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_HELLO, (st_data_t)rb_intern2("HELLO", 5));
3399 #endif
3400 #ifdef IPPROTO_IDP
3401     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_IDP, (st_data_t)rb_intern2("IDP", 3));
3402 #endif
3403 #ifdef IPPROTO_UDP
3404     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_UDP, (st_data_t)rb_intern2("UDP", 3));
3405 #endif
3406 #ifdef IPPROTO_PUP
3407     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_PUP, (st_data_t)rb_intern2("PUP", 3));
3408 #endif
3409 #ifdef IPPROTO_EGP
3410     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_EGP, (st_data_t)rb_intern2("EGP", 3));
3411 #endif
3412 #ifdef IPPROTO_TCP
3413     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_TCP, (st_data_t)rb_intern2("TCP", 3));
3414 #endif
3415 #ifdef IPPROTO_GGP
3416     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_GGP, (st_data_t)rb_intern2("GGP", 3));
3417 #endif
3418 #ifdef IPPROTO_IGMP
3419     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_IGMP, (st_data_t)rb_intern2("IGMP", 4));
3420 #endif
3421 #ifdef IPPROTO_ICMP
3422     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_ICMP, (st_data_t)rb_intern2("ICMP", 4));
3423 #endif
3424 #ifdef IPPROTO_IP
3425     st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_IP, (st_data_t)rb_intern2("IP", 2));
3426 #endif
3427 #ifdef SOL_SOCKET
3428     st_insert(rsock_intern_iplevel_hash, (st_data_t)SOL_SOCKET, (st_data_t)rb_intern2("SOCKET", 6));
3429 #endif
3430 
3431     rsock_intern_so_optname_hash = st_init_numtable();
3432 #ifdef SO_BPF_EXTENSIONS
3433     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_BPF_EXTENSIONS, (st_data_t)rb_intern2("SO_BPF_EXTENSIONS", 17));
3434 #endif
3435 #ifdef SO_MAX_PACING_RATE
3436     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_MAX_PACING_RATE, (st_data_t)rb_intern2("SO_MAX_PACING_RATE", 18));
3437 #endif
3438 #ifdef SO_BUSY_POLL
3439     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_BUSY_POLL, (st_data_t)rb_intern2("SO_BUSY_POLL", 12));
3440 #endif
3441 #ifdef SO_SELECT_ERR_QUEUE
3442     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_SELECT_ERR_QUEUE, (st_data_t)rb_intern2("SO_SELECT_ERR_QUEUE", 19));
3443 #endif
3444 #ifdef SO_LOCK_FILTER
3445     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_LOCK_FILTER, (st_data_t)rb_intern2("SO_LOCK_FILTER", 14));
3446 #endif
3447 #ifdef SO_NOFCS
3448     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_NOFCS, (st_data_t)rb_intern2("SO_NOFCS", 8));
3449 #endif
3450 #ifdef SO_PEEK_OFF
3451     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_PEEK_OFF, (st_data_t)rb_intern2("SO_PEEK_OFF", 11));
3452 #endif
3453 #ifdef SO_WIFI_STATUS
3454     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_WIFI_STATUS, (st_data_t)rb_intern2("SO_WIFI_STATUS", 14));
3455 #endif
3456 #ifdef SO_RXQ_OVFL
3457     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_RXQ_OVFL, (st_data_t)rb_intern2("SO_RXQ_OVFL", 11));
3458 #endif
3459 #ifdef SO_DOMAIN
3460     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_DOMAIN, (st_data_t)rb_intern2("SO_DOMAIN", 9));
3461 #endif
3462 #ifdef SO_PROTOCOL
3463     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_PROTOCOL, (st_data_t)rb_intern2("SO_PROTOCOL", 11));
3464 #endif
3465 #ifdef SO_TIMESTAMPING
3466     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_TIMESTAMPING, (st_data_t)rb_intern2("SO_TIMESTAMPING", 15));
3467 #endif
3468 #ifdef SO_MARK
3469     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_MARK, (st_data_t)rb_intern2("SO_MARK", 7));
3470 #endif
3471 #ifdef SO_PASSSEC
3472     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_PASSSEC, (st_data_t)rb_intern2("SO_PASSSEC", 10));
3473 #endif
3474 #ifdef SO_PEERSEC
3475     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_PEERSEC, (st_data_t)rb_intern2("SO_PEERSEC", 10));
3476 #endif
3477 #ifdef SO_ALLZONES
3478     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_ALLZONES, (st_data_t)rb_intern2("SO_ALLZONES", 11));
3479 #endif
3480 #ifdef SO_MAC_EXEMPT
3481     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_MAC_EXEMPT, (st_data_t)rb_intern2("SO_MAC_EXEMPT", 13));
3482 #endif
3483 #ifdef SO_RECVUCRED
3484     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_RECVUCRED, (st_data_t)rb_intern2("SO_RECVUCRED", 12));
3485 #endif
3486 #ifdef SO_BINTIME
3487     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_BINTIME, (st_data_t)rb_intern2("SO_BINTIME", 10));
3488 #endif
3489 #ifdef SO_TIMESTAMPNS
3490     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_TIMESTAMPNS, (st_data_t)rb_intern2("SO_TIMESTAMPNS", 14));
3491 #endif
3492 #ifdef SO_TIMESTAMP
3493     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_TIMESTAMP, (st_data_t)rb_intern2("SO_TIMESTAMP", 12));
3494 #endif
3495 #ifdef SO_PEERNAME
3496     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_PEERNAME, (st_data_t)rb_intern2("SO_PEERNAME", 11));
3497 #endif
3498 #ifdef SO_GET_FILTER
3499     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_GET_FILTER, (st_data_t)rb_intern2("SO_GET_FILTER", 13));
3500 #endif
3501 #ifdef SO_DETACH_FILTER
3502     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_DETACH_FILTER, (st_data_t)rb_intern2("SO_DETACH_FILTER", 16));
3503 #endif
3504 #ifdef SO_ATTACH_FILTER
3505     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_ATTACH_FILTER, (st_data_t)rb_intern2("SO_ATTACH_FILTER", 16));
3506 #endif
3507 #ifdef SO_BINDTODEVICE
3508     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_BINDTODEVICE, (st_data_t)rb_intern2("SO_BINDTODEVICE", 15));
3509 #endif
3510 #ifdef SO_SECURITY_ENCRYPTION_NETWORK
3511     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_SECURITY_ENCRYPTION_NETWORK, (st_data_t)rb_intern2("SO_SECURITY_ENCRYPTION_NETWORK", 30));
3512 #endif
3513 #ifdef SO_SECURITY_ENCRYPTION_TRANSPORT
3514     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_SECURITY_ENCRYPTION_TRANSPORT, (st_data_t)rb_intern2("SO_SECURITY_ENCRYPTION_TRANSPORT", 32));
3515 #endif
3516 #ifdef SO_SECURITY_AUTHENTICATION
3517     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_SECURITY_AUTHENTICATION, (st_data_t)rb_intern2("SO_SECURITY_AUTHENTICATION", 26));
3518 #endif
3519 #ifdef SO_NOSIGPIPE
3520     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_NOSIGPIPE, (st_data_t)rb_intern2("SO_NOSIGPIPE", 12));
3521 #endif
3522 #ifdef SO_NKE
3523     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_NKE, (st_data_t)rb_intern2("SO_NKE", 6));
3524 #endif
3525 #ifdef SO_NREAD
3526     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_NREAD, (st_data_t)rb_intern2("SO_NREAD", 8));
3527 #endif
3528 #ifdef SO_WANTOOBFLAG
3529     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_WANTOOBFLAG, (st_data_t)rb_intern2("SO_WANTOOBFLAG", 14));
3530 #endif
3531 #ifdef SO_WANTMORE
3532     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_WANTMORE, (st_data_t)rb_intern2("SO_WANTMORE", 11));
3533 #endif
3534 #ifdef SO_DONTTRUNC
3535     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_DONTTRUNC, (st_data_t)rb_intern2("SO_DONTTRUNC", 12));
3536 #endif
3537 #ifdef SO_ACCEPTFILTER
3538     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_ACCEPTFILTER, (st_data_t)rb_intern2("SO_ACCEPTFILTER", 15));
3539 #endif
3540 #ifdef SO_USELOOPBACK
3541     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_USELOOPBACK, (st_data_t)rb_intern2("SO_USELOOPBACK", 14));
3542 #endif
3543 #ifdef SO_ACCEPTCONN
3544     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_ACCEPTCONN, (st_data_t)rb_intern2("SO_ACCEPTCONN", 13));
3545 #endif
3546 #ifdef SO_SNDTIMEO
3547     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_SNDTIMEO, (st_data_t)rb_intern2("SO_SNDTIMEO", 11));
3548 #endif
3549 #ifdef SO_RCVTIMEO
3550     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_RCVTIMEO, (st_data_t)rb_intern2("SO_RCVTIMEO", 11));
3551 #endif
3552 #ifdef SO_SNDLOWAT
3553     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_SNDLOWAT, (st_data_t)rb_intern2("SO_SNDLOWAT", 11));
3554 #endif
3555 #ifdef SO_RCVLOWAT
3556     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_RCVLOWAT, (st_data_t)rb_intern2("SO_RCVLOWAT", 11));
3557 #endif
3558 #ifdef SO_PEERCRED
3559     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_PEERCRED, (st_data_t)rb_intern2("SO_PEERCRED", 11));
3560 #endif
3561 #ifdef SO_PASSCRED
3562     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_PASSCRED, (st_data_t)rb_intern2("SO_PASSCRED", 11));
3563 #endif
3564 #ifdef SO_LINGER
3565     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_LINGER, (st_data_t)rb_intern2("SO_LINGER", 9));
3566 #endif
3567 #ifdef SO_PRIORITY
3568     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_PRIORITY, (st_data_t)rb_intern2("SO_PRIORITY", 11));
3569 #endif
3570 #ifdef SO_NO_CHECK
3571     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_NO_CHECK, (st_data_t)rb_intern2("SO_NO_CHECK", 11));
3572 #endif
3573 #ifdef SO_OOBINLINE
3574     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_OOBINLINE, (st_data_t)rb_intern2("SO_OOBINLINE", 12));
3575 #endif
3576 #ifdef SO_KEEPALIVE
3577     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_KEEPALIVE, (st_data_t)rb_intern2("SO_KEEPALIVE", 12));
3578 #endif
3579 #ifdef SO_RCVBUFFORCE
3580     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_RCVBUFFORCE, (st_data_t)rb_intern2("SO_RCVBUFFORCE", 14));
3581 #endif
3582 #ifdef SO_SNDBUFFORCE
3583     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_SNDBUFFORCE, (st_data_t)rb_intern2("SO_SNDBUFFORCE", 14));
3584 #endif
3585 #ifdef SO_RCVBUF
3586     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_RCVBUF, (st_data_t)rb_intern2("SO_RCVBUF", 9));
3587 #endif
3588 #ifdef SO_SNDBUF
3589     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_SNDBUF, (st_data_t)rb_intern2("SO_SNDBUF", 9));
3590 #endif
3591 #ifdef SO_BROADCAST
3592     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_BROADCAST, (st_data_t)rb_intern2("SO_BROADCAST", 12));
3593 #endif
3594 #ifdef SO_DONTROUTE
3595     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_DONTROUTE, (st_data_t)rb_intern2("SO_DONTROUTE", 12));
3596 #endif
3597 #ifdef SO_ERROR
3598     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_ERROR, (st_data_t)rb_intern2("SO_ERROR", 8));
3599 #endif
3600 #ifdef SO_TYPE
3601     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_TYPE, (st_data_t)rb_intern2("SO_TYPE", 7));
3602 #endif
3603 #ifdef SO_REUSEPORT
3604     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_REUSEPORT, (st_data_t)rb_intern2("SO_REUSEPORT", 12));
3605 #endif
3606 #ifdef SO_REUSEADDR
3607     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_REUSEADDR, (st_data_t)rb_intern2("SO_REUSEADDR", 12));
3608 #endif
3609 #ifdef SO_DEBUG
3610     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_DEBUG, (st_data_t)rb_intern2("SO_DEBUG", 8));
3611 #endif
3612 #ifdef SO_BPF_EXTENSIONS
3613     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_BPF_EXTENSIONS, (st_data_t)rb_intern2("BPF_EXTENSIONS", 14));
3614 #endif
3615 #ifdef SO_MAX_PACING_RATE
3616     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_MAX_PACING_RATE, (st_data_t)rb_intern2("MAX_PACING_RATE", 15));
3617 #endif
3618 #ifdef SO_BUSY_POLL
3619     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_BUSY_POLL, (st_data_t)rb_intern2("BUSY_POLL", 9));
3620 #endif
3621 #ifdef SO_SELECT_ERR_QUEUE
3622     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_SELECT_ERR_QUEUE, (st_data_t)rb_intern2("SELECT_ERR_QUEUE", 16));
3623 #endif
3624 #ifdef SO_LOCK_FILTER
3625     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_LOCK_FILTER, (st_data_t)rb_intern2("LOCK_FILTER", 11));
3626 #endif
3627 #ifdef SO_NOFCS
3628     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_NOFCS, (st_data_t)rb_intern2("NOFCS", 5));
3629 #endif
3630 #ifdef SO_PEEK_OFF
3631     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_PEEK_OFF, (st_data_t)rb_intern2("PEEK_OFF", 8));
3632 #endif
3633 #ifdef SO_WIFI_STATUS
3634     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_WIFI_STATUS, (st_data_t)rb_intern2("WIFI_STATUS", 11));
3635 #endif
3636 #ifdef SO_RXQ_OVFL
3637     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_RXQ_OVFL, (st_data_t)rb_intern2("RXQ_OVFL", 8));
3638 #endif
3639 #ifdef SO_DOMAIN
3640     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_DOMAIN, (st_data_t)rb_intern2("DOMAIN", 6));
3641 #endif
3642 #ifdef SO_PROTOCOL
3643     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_PROTOCOL, (st_data_t)rb_intern2("PROTOCOL", 8));
3644 #endif
3645 #ifdef SO_TIMESTAMPING
3646     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_TIMESTAMPING, (st_data_t)rb_intern2("TIMESTAMPING", 12));
3647 #endif
3648 #ifdef SO_MARK
3649     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_MARK, (st_data_t)rb_intern2("MARK", 4));
3650 #endif
3651 #ifdef SO_PASSSEC
3652     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_PASSSEC, (st_data_t)rb_intern2("PASSSEC", 7));
3653 #endif
3654 #ifdef SO_PEERSEC
3655     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_PEERSEC, (st_data_t)rb_intern2("PEERSEC", 7));
3656 #endif
3657 #ifdef SO_ALLZONES
3658     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_ALLZONES, (st_data_t)rb_intern2("ALLZONES", 8));
3659 #endif
3660 #ifdef SO_MAC_EXEMPT
3661     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_MAC_EXEMPT, (st_data_t)rb_intern2("MAC_EXEMPT", 10));
3662 #endif
3663 #ifdef SO_RECVUCRED
3664     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_RECVUCRED, (st_data_t)rb_intern2("RECVUCRED", 9));
3665 #endif
3666 #ifdef SO_BINTIME
3667     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_BINTIME, (st_data_t)rb_intern2("BINTIME", 7));
3668 #endif
3669 #ifdef SO_TIMESTAMPNS
3670     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_TIMESTAMPNS, (st_data_t)rb_intern2("TIMESTAMPNS", 11));
3671 #endif
3672 #ifdef SO_TIMESTAMP
3673     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_TIMESTAMP, (st_data_t)rb_intern2("TIMESTAMP", 9));
3674 #endif
3675 #ifdef SO_PEERNAME
3676     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_PEERNAME, (st_data_t)rb_intern2("PEERNAME", 8));
3677 #endif
3678 #ifdef SO_GET_FILTER
3679     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_GET_FILTER, (st_data_t)rb_intern2("GET_FILTER", 10));
3680 #endif
3681 #ifdef SO_DETACH_FILTER
3682     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_DETACH_FILTER, (st_data_t)rb_intern2("DETACH_FILTER", 13));
3683 #endif
3684 #ifdef SO_ATTACH_FILTER
3685     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_ATTACH_FILTER, (st_data_t)rb_intern2("ATTACH_FILTER", 13));
3686 #endif
3687 #ifdef SO_BINDTODEVICE
3688     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_BINDTODEVICE, (st_data_t)rb_intern2("BINDTODEVICE", 12));
3689 #endif
3690 #ifdef SO_SECURITY_ENCRYPTION_NETWORK
3691     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_SECURITY_ENCRYPTION_NETWORK, (st_data_t)rb_intern2("SECURITY_ENCRYPTION_NETWORK", 27));
3692 #endif
3693 #ifdef SO_SECURITY_ENCRYPTION_TRANSPORT
3694     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_SECURITY_ENCRYPTION_TRANSPORT, (st_data_t)rb_intern2("SECURITY_ENCRYPTION_TRANSPORT", 29));
3695 #endif
3696 #ifdef SO_SECURITY_AUTHENTICATION
3697     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_SECURITY_AUTHENTICATION, (st_data_t)rb_intern2("SECURITY_AUTHENTICATION", 23));
3698 #endif
3699 #ifdef SO_NOSIGPIPE
3700     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_NOSIGPIPE, (st_data_t)rb_intern2("NOSIGPIPE", 9));
3701 #endif
3702 #ifdef SO_NKE
3703     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_NKE, (st_data_t)rb_intern2("NKE", 3));
3704 #endif
3705 #ifdef SO_NREAD
3706     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_NREAD, (st_data_t)rb_intern2("NREAD", 5));
3707 #endif
3708 #ifdef SO_WANTOOBFLAG
3709     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_WANTOOBFLAG, (st_data_t)rb_intern2("WANTOOBFLAG", 11));
3710 #endif
3711 #ifdef SO_WANTMORE
3712     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_WANTMORE, (st_data_t)rb_intern2("WANTMORE", 8));
3713 #endif
3714 #ifdef SO_DONTTRUNC
3715     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_DONTTRUNC, (st_data_t)rb_intern2("DONTTRUNC", 9));
3716 #endif
3717 #ifdef SO_ACCEPTFILTER
3718     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_ACCEPTFILTER, (st_data_t)rb_intern2("ACCEPTFILTER", 12));
3719 #endif
3720 #ifdef SO_USELOOPBACK
3721     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_USELOOPBACK, (st_data_t)rb_intern2("USELOOPBACK", 11));
3722 #endif
3723 #ifdef SO_ACCEPTCONN
3724     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_ACCEPTCONN, (st_data_t)rb_intern2("ACCEPTCONN", 10));
3725 #endif
3726 #ifdef SO_SNDTIMEO
3727     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_SNDTIMEO, (st_data_t)rb_intern2("SNDTIMEO", 8));
3728 #endif
3729 #ifdef SO_RCVTIMEO
3730     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_RCVTIMEO, (st_data_t)rb_intern2("RCVTIMEO", 8));
3731 #endif
3732 #ifdef SO_SNDLOWAT
3733     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_SNDLOWAT, (st_data_t)rb_intern2("SNDLOWAT", 8));
3734 #endif
3735 #ifdef SO_RCVLOWAT
3736     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_RCVLOWAT, (st_data_t)rb_intern2("RCVLOWAT", 8));
3737 #endif
3738 #ifdef SO_PEERCRED
3739     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_PEERCRED, (st_data_t)rb_intern2("PEERCRED", 8));
3740 #endif
3741 #ifdef SO_PASSCRED
3742     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_PASSCRED, (st_data_t)rb_intern2("PASSCRED", 8));
3743 #endif
3744 #ifdef SO_LINGER
3745     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_LINGER, (st_data_t)rb_intern2("LINGER", 6));
3746 #endif
3747 #ifdef SO_PRIORITY
3748     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_PRIORITY, (st_data_t)rb_intern2("PRIORITY", 8));
3749 #endif
3750 #ifdef SO_NO_CHECK
3751     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_NO_CHECK, (st_data_t)rb_intern2("NO_CHECK", 8));
3752 #endif
3753 #ifdef SO_OOBINLINE
3754     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_OOBINLINE, (st_data_t)rb_intern2("OOBINLINE", 9));
3755 #endif
3756 #ifdef SO_KEEPALIVE
3757     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_KEEPALIVE, (st_data_t)rb_intern2("KEEPALIVE", 9));
3758 #endif
3759 #ifdef SO_RCVBUFFORCE
3760     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_RCVBUFFORCE, (st_data_t)rb_intern2("RCVBUFFORCE", 11));
3761 #endif
3762 #ifdef SO_SNDBUFFORCE
3763     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_SNDBUFFORCE, (st_data_t)rb_intern2("SNDBUFFORCE", 11));
3764 #endif
3765 #ifdef SO_RCVBUF
3766     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_RCVBUF, (st_data_t)rb_intern2("RCVBUF", 6));
3767 #endif
3768 #ifdef SO_SNDBUF
3769     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_SNDBUF, (st_data_t)rb_intern2("SNDBUF", 6));
3770 #endif
3771 #ifdef SO_BROADCAST
3772     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_BROADCAST, (st_data_t)rb_intern2("BROADCAST", 9));
3773 #endif
3774 #ifdef SO_DONTROUTE
3775     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_DONTROUTE, (st_data_t)rb_intern2("DONTROUTE", 9));
3776 #endif
3777 #ifdef SO_ERROR
3778     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_ERROR, (st_data_t)rb_intern2("ERROR", 5));
3779 #endif
3780 #ifdef SO_TYPE
3781     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_TYPE, (st_data_t)rb_intern2("TYPE", 4));
3782 #endif
3783 #ifdef SO_REUSEPORT
3784     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_REUSEPORT, (st_data_t)rb_intern2("REUSEPORT", 9));
3785 #endif
3786 #ifdef SO_REUSEADDR
3787     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_REUSEADDR, (st_data_t)rb_intern2("REUSEADDR", 9));
3788 #endif
3789 #ifdef SO_DEBUG
3790     st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_DEBUG, (st_data_t)rb_intern2("DEBUG", 5));
3791 #endif
3792 
3793     rsock_intern_ip_optname_hash = st_init_numtable();
3794 #ifdef IP_MSFILTER
3795     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_MSFILTER, (st_data_t)rb_intern2("IP_MSFILTER", 11));
3796 #endif
3797 #ifdef IP_DROP_SOURCE_MEMBERSHIP
3798     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_DROP_SOURCE_MEMBERSHIP, (st_data_t)rb_intern2("IP_DROP_SOURCE_MEMBERSHIP", 25));
3799 #endif
3800 #ifdef IP_ADD_SOURCE_MEMBERSHIP
3801     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_ADD_SOURCE_MEMBERSHIP, (st_data_t)rb_intern2("IP_ADD_SOURCE_MEMBERSHIP", 24));
3802 #endif
3803 #ifdef IP_BLOCK_SOURCE
3804     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_BLOCK_SOURCE, (st_data_t)rb_intern2("IP_BLOCK_SOURCE", 15));
3805 #endif
3806 #ifdef IP_UNBLOCK_SOURCE
3807     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_UNBLOCK_SOURCE, (st_data_t)rb_intern2("IP_UNBLOCK_SOURCE", 17));
3808 #endif
3809 #ifdef IP_PMTUDISC_DO
3810     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_PMTUDISC_DO, (st_data_t)rb_intern2("IP_PMTUDISC_DO", 14));
3811 #endif
3812 #ifdef IP_PMTUDISC_WANT
3813     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_PMTUDISC_WANT, (st_data_t)rb_intern2("IP_PMTUDISC_WANT", 16));
3814 #endif
3815 #ifdef IP_PMTUDISC_DONT
3816     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_PMTUDISC_DONT, (st_data_t)rb_intern2("IP_PMTUDISC_DONT", 16));
3817 #endif
3818 #ifdef IP_TRANSPARENT
3819     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_TRANSPARENT, (st_data_t)rb_intern2("IP_TRANSPARENT", 14));
3820 #endif
3821 #ifdef IP_PASSSEC
3822     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_PASSSEC, (st_data_t)rb_intern2("IP_PASSSEC", 10));
3823 #endif
3824 #ifdef IP_XFRM_POLICY
3825     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_XFRM_POLICY, (st_data_t)rb_intern2("IP_XFRM_POLICY", 14));
3826 #endif
3827 #ifdef IP_IPSEC_POLICY
3828     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_IPSEC_POLICY, (st_data_t)rb_intern2("IP_IPSEC_POLICY", 15));
3829 #endif
3830 #ifdef IP_FREEBIND
3831     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_FREEBIND, (st_data_t)rb_intern2("IP_FREEBIND", 11));
3832 #endif
3833 #ifdef IP_MTU
3834     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_MTU, (st_data_t)rb_intern2("IP_MTU", 6));
3835 #endif
3836 #ifdef IP_RECVTOS
3837     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_RECVTOS, (st_data_t)rb_intern2("IP_RECVTOS", 10));
3838 #endif
3839 #ifdef IP_RECVERR
3840     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_RECVERR, (st_data_t)rb_intern2("IP_RECVERR", 10));
3841 #endif
3842 #ifdef IP_MTU_DISCOVER
3843     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_MTU_DISCOVER, (st_data_t)rb_intern2("IP_MTU_DISCOVER", 15));
3844 #endif
3845 #ifdef IP_PKTOPTIONS
3846     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_PKTOPTIONS, (st_data_t)rb_intern2("IP_PKTOPTIONS", 13));
3847 #endif
3848 #ifdef IP_PKTINFO
3849     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_PKTINFO, (st_data_t)rb_intern2("IP_PKTINFO", 10));
3850 #endif
3851 #ifdef IP_ROUTER_ALERT
3852     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_ROUTER_ALERT, (st_data_t)rb_intern2("IP_ROUTER_ALERT", 15));
3853 #endif
3854 #ifdef IP_MAX_MEMBERSHIPS
3855     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_MAX_MEMBERSHIPS, (st_data_t)rb_intern2("IP_MAX_MEMBERSHIPS", 18));
3856 #endif
3857 #ifdef IP_DEFAULT_MULTICAST_LOOP
3858     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_DEFAULT_MULTICAST_LOOP, (st_data_t)rb_intern2("IP_DEFAULT_MULTICAST_LOOP", 25));
3859 #endif
3860 #ifdef IP_DEFAULT_MULTICAST_TTL
3861     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_DEFAULT_MULTICAST_TTL, (st_data_t)rb_intern2("IP_DEFAULT_MULTICAST_TTL", 24));
3862 #endif
3863 #ifdef IP_DROP_MEMBERSHIP
3864     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_DROP_MEMBERSHIP, (st_data_t)rb_intern2("IP_DROP_MEMBERSHIP", 18));
3865 #endif
3866 #ifdef IP_ADD_MEMBERSHIP
3867     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_ADD_MEMBERSHIP, (st_data_t)rb_intern2("IP_ADD_MEMBERSHIP", 17));
3868 #endif
3869 #ifdef IP_MULTICAST_LOOP
3870     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_MULTICAST_LOOP, (st_data_t)rb_intern2("IP_MULTICAST_LOOP", 17));
3871 #endif
3872 #ifdef IP_MULTICAST_TTL
3873     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_MULTICAST_TTL, (st_data_t)rb_intern2("IP_MULTICAST_TTL", 16));
3874 #endif
3875 #ifdef IP_MULTICAST_IF
3876     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_MULTICAST_IF, (st_data_t)rb_intern2("IP_MULTICAST_IF", 15));
3877 #endif
3878 #ifdef IP_PORTRANGE
3879     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_PORTRANGE, (st_data_t)rb_intern2("IP_PORTRANGE", 12));
3880 #endif
3881 #ifdef IP_RECVSLLA
3882     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_RECVSLLA, (st_data_t)rb_intern2("IP_RECVSLLA", 11));
3883 #endif
3884 #ifdef IP_RECVIF
3885     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_RECVIF, (st_data_t)rb_intern2("IP_RECVIF", 9));
3886 #endif
3887 #ifdef IP_RECVTTL
3888     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_RECVTTL, (st_data_t)rb_intern2("IP_RECVTTL", 10));
3889 #endif
3890 #ifdef IP_ONESBCAST
3891     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_ONESBCAST, (st_data_t)rb_intern2("IP_ONESBCAST", 12));
3892 #endif
3893 #ifdef IP_SENDSRCADDR
3894     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_SENDSRCADDR, (st_data_t)rb_intern2("IP_SENDSRCADDR", 14));
3895 #endif
3896 #ifdef IP_DONTFRAG
3897     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_DONTFRAG, (st_data_t)rb_intern2("IP_DONTFRAG", 11));
3898 #endif
3899 #ifdef IP_MINTTL
3900     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_MINTTL, (st_data_t)rb_intern2("IP_MINTTL", 9));
3901 #endif
3902 #ifdef IP_RETOPTS
3903     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_RETOPTS, (st_data_t)rb_intern2("IP_RETOPTS", 10));
3904 #endif
3905 #ifdef IP_RECVDSTADDR
3906     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_RECVDSTADDR, (st_data_t)rb_intern2("IP_RECVDSTADDR", 14));
3907 #endif
3908 #ifdef IP_RECVRETOPTS
3909     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_RECVRETOPTS, (st_data_t)rb_intern2("IP_RECVRETOPTS", 14));
3910 #endif
3911 #ifdef IP_RECVOPTS
3912     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_RECVOPTS, (st_data_t)rb_intern2("IP_RECVOPTS", 11));
3913 #endif
3914 #ifdef IP_TTL
3915     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_TTL, (st_data_t)rb_intern2("IP_TTL", 6));
3916 #endif
3917 #ifdef IP_TOS
3918     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_TOS, (st_data_t)rb_intern2("IP_TOS", 6));
3919 #endif
3920 #ifdef IP_HDRINCL
3921     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_HDRINCL, (st_data_t)rb_intern2("IP_HDRINCL", 10));
3922 #endif
3923 #ifdef IP_OPTIONS
3924     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_OPTIONS, (st_data_t)rb_intern2("IP_OPTIONS", 10));
3925 #endif
3926 #ifdef IP_MSFILTER
3927     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_MSFILTER, (st_data_t)rb_intern2("MSFILTER", 8));
3928 #endif
3929 #ifdef IP_DROP_SOURCE_MEMBERSHIP
3930     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_DROP_SOURCE_MEMBERSHIP, (st_data_t)rb_intern2("DROP_SOURCE_MEMBERSHIP", 22));
3931 #endif
3932 #ifdef IP_ADD_SOURCE_MEMBERSHIP
3933     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_ADD_SOURCE_MEMBERSHIP, (st_data_t)rb_intern2("ADD_SOURCE_MEMBERSHIP", 21));
3934 #endif
3935 #ifdef IP_BLOCK_SOURCE
3936     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_BLOCK_SOURCE, (st_data_t)rb_intern2("BLOCK_SOURCE", 12));
3937 #endif
3938 #ifdef IP_UNBLOCK_SOURCE
3939     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_UNBLOCK_SOURCE, (st_data_t)rb_intern2("UNBLOCK_SOURCE", 14));
3940 #endif
3941 #ifdef IP_PMTUDISC_DO
3942     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_PMTUDISC_DO, (st_data_t)rb_intern2("PMTUDISC_DO", 11));
3943 #endif
3944 #ifdef IP_PMTUDISC_WANT
3945     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_PMTUDISC_WANT, (st_data_t)rb_intern2("PMTUDISC_WANT", 13));
3946 #endif
3947 #ifdef IP_PMTUDISC_DONT
3948     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_PMTUDISC_DONT, (st_data_t)rb_intern2("PMTUDISC_DONT", 13));
3949 #endif
3950 #ifdef IP_TRANSPARENT
3951     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_TRANSPARENT, (st_data_t)rb_intern2("TRANSPARENT", 11));
3952 #endif
3953 #ifdef IP_PASSSEC
3954     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_PASSSEC, (st_data_t)rb_intern2("PASSSEC", 7));
3955 #endif
3956 #ifdef IP_XFRM_POLICY
3957     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_XFRM_POLICY, (st_data_t)rb_intern2("XFRM_POLICY", 11));
3958 #endif
3959 #ifdef IP_IPSEC_POLICY
3960     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_IPSEC_POLICY, (st_data_t)rb_intern2("IPSEC_POLICY", 12));
3961 #endif
3962 #ifdef IP_FREEBIND
3963     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_FREEBIND, (st_data_t)rb_intern2("FREEBIND", 8));
3964 #endif
3965 #ifdef IP_MTU
3966     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_MTU, (st_data_t)rb_intern2("MTU", 3));
3967 #endif
3968 #ifdef IP_RECVTOS
3969     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_RECVTOS, (st_data_t)rb_intern2("RECVTOS", 7));
3970 #endif
3971 #ifdef IP_RECVERR
3972     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_RECVERR, (st_data_t)rb_intern2("RECVERR", 7));
3973 #endif
3974 #ifdef IP_MTU_DISCOVER
3975     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_MTU_DISCOVER, (st_data_t)rb_intern2("MTU_DISCOVER", 12));
3976 #endif
3977 #ifdef IP_PKTOPTIONS
3978     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_PKTOPTIONS, (st_data_t)rb_intern2("PKTOPTIONS", 10));
3979 #endif
3980 #ifdef IP_PKTINFO
3981     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_PKTINFO, (st_data_t)rb_intern2("PKTINFO", 7));
3982 #endif
3983 #ifdef IP_ROUTER_ALERT
3984     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_ROUTER_ALERT, (st_data_t)rb_intern2("ROUTER_ALERT", 12));
3985 #endif
3986 #ifdef IP_MAX_MEMBERSHIPS
3987     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_MAX_MEMBERSHIPS, (st_data_t)rb_intern2("MAX_MEMBERSHIPS", 15));
3988 #endif
3989 #ifdef IP_DEFAULT_MULTICAST_LOOP
3990     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_DEFAULT_MULTICAST_LOOP, (st_data_t)rb_intern2("DEFAULT_MULTICAST_LOOP", 22));
3991 #endif
3992 #ifdef IP_DEFAULT_MULTICAST_TTL
3993     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_DEFAULT_MULTICAST_TTL, (st_data_t)rb_intern2("DEFAULT_MULTICAST_TTL", 21));
3994 #endif
3995 #ifdef IP_DROP_MEMBERSHIP
3996     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_DROP_MEMBERSHIP, (st_data_t)rb_intern2("DROP_MEMBERSHIP", 15));
3997 #endif
3998 #ifdef IP_ADD_MEMBERSHIP
3999     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_ADD_MEMBERSHIP, (st_data_t)rb_intern2("ADD_MEMBERSHIP", 14));
4000 #endif
4001 #ifdef IP_MULTICAST_LOOP
4002     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_MULTICAST_LOOP, (st_data_t)rb_intern2("MULTICAST_LOOP", 14));
4003 #endif
4004 #ifdef IP_MULTICAST_TTL
4005     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_MULTICAST_TTL, (st_data_t)rb_intern2("MULTICAST_TTL", 13));
4006 #endif
4007 #ifdef IP_MULTICAST_IF
4008     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_MULTICAST_IF, (st_data_t)rb_intern2("MULTICAST_IF", 12));
4009 #endif
4010 #ifdef IP_PORTRANGE
4011     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_PORTRANGE, (st_data_t)rb_intern2("PORTRANGE", 9));
4012 #endif
4013 #ifdef IP_RECVSLLA
4014     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_RECVSLLA, (st_data_t)rb_intern2("RECVSLLA", 8));
4015 #endif
4016 #ifdef IP_RECVIF
4017     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_RECVIF, (st_data_t)rb_intern2("RECVIF", 6));
4018 #endif
4019 #ifdef IP_RECVTTL
4020     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_RECVTTL, (st_data_t)rb_intern2("RECVTTL", 7));
4021 #endif
4022 #ifdef IP_ONESBCAST
4023     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_ONESBCAST, (st_data_t)rb_intern2("ONESBCAST", 9));
4024 #endif
4025 #ifdef IP_SENDSRCADDR
4026     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_SENDSRCADDR, (st_data_t)rb_intern2("SENDSRCADDR", 11));
4027 #endif
4028 #ifdef IP_DONTFRAG
4029     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_DONTFRAG, (st_data_t)rb_intern2("DONTFRAG", 8));
4030 #endif
4031 #ifdef IP_MINTTL
4032     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_MINTTL, (st_data_t)rb_intern2("MINTTL", 6));
4033 #endif
4034 #ifdef IP_RETOPTS
4035     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_RETOPTS, (st_data_t)rb_intern2("RETOPTS", 7));
4036 #endif
4037 #ifdef IP_RECVDSTADDR
4038     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_RECVDSTADDR, (st_data_t)rb_intern2("RECVDSTADDR", 11));
4039 #endif
4040 #ifdef IP_RECVRETOPTS
4041     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_RECVRETOPTS, (st_data_t)rb_intern2("RECVRETOPTS", 11));
4042 #endif
4043 #ifdef IP_RECVOPTS
4044     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_RECVOPTS, (st_data_t)rb_intern2("RECVOPTS", 8));
4045 #endif
4046 #ifdef IP_TTL
4047     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_TTL, (st_data_t)rb_intern2("TTL", 3));
4048 #endif
4049 #ifdef IP_TOS
4050     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_TOS, (st_data_t)rb_intern2("TOS", 3));
4051 #endif
4052 #ifdef IP_HDRINCL
4053     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_HDRINCL, (st_data_t)rb_intern2("HDRINCL", 7));
4054 #endif
4055 #ifdef IP_OPTIONS
4056     st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_OPTIONS, (st_data_t)rb_intern2("OPTIONS", 7));
4057 #endif
4058 
4059     rsock_intern_ipv6_optname_hash = st_init_numtable();
4060 #ifdef IPV6_USE_MIN_MTU
4061     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_USE_MIN_MTU, (st_data_t)rb_intern2("IPV6_USE_MIN_MTU", 16));
4062 #endif
4063 #ifdef IPV6_TCLASS
4064     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_TCLASS, (st_data_t)rb_intern2("IPV6_TCLASS", 11));
4065 #endif
4066 #ifdef IPV6_RECVPATHMTU
4067     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RECVPATHMTU, (st_data_t)rb_intern2("IPV6_RECVPATHMTU", 16));
4068 #endif
4069 #ifdef IPV6_RTHDR_TYPE_0
4070     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RTHDR_TYPE_0, (st_data_t)rb_intern2("IPV6_RTHDR_TYPE_0", 17));
4071 #endif
4072 #ifdef IPV6_RTHDRDSTOPTS
4073     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RTHDRDSTOPTS, (st_data_t)rb_intern2("IPV6_RTHDRDSTOPTS", 17));
4074 #endif
4075 #ifdef IPV6_RTHDR
4076     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RTHDR, (st_data_t)rb_intern2("IPV6_RTHDR", 10));
4077 #endif
4078 #ifdef IPV6_RECVTCLASS
4079     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RECVTCLASS, (st_data_t)rb_intern2("IPV6_RECVTCLASS", 15));
4080 #endif
4081 #ifdef IPV6_RECVRTHDR
4082     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RECVRTHDR, (st_data_t)rb_intern2("IPV6_RECVRTHDR", 14));
4083 #endif
4084 #ifdef IPV6_RECVPKTINFO
4085     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RECVPKTINFO, (st_data_t)rb_intern2("IPV6_RECVPKTINFO", 16));
4086 #endif
4087 #ifdef IPV6_RECVHOPOPTS
4088     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RECVHOPOPTS, (st_data_t)rb_intern2("IPV6_RECVHOPOPTS", 16));
4089 #endif
4090 #ifdef IPV6_RECVHOPLIMIT
4091     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RECVHOPLIMIT, (st_data_t)rb_intern2("IPV6_RECVHOPLIMIT", 17));
4092 #endif
4093 #ifdef IPV6_RECVDSTOPTS
4094     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RECVDSTOPTS, (st_data_t)rb_intern2("IPV6_RECVDSTOPTS", 16));
4095 #endif
4096 #ifdef IPV6_PKTINFO
4097     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_PKTINFO, (st_data_t)rb_intern2("IPV6_PKTINFO", 12));
4098 #endif
4099 #ifdef IPV6_PATHMTU
4100     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_PATHMTU, (st_data_t)rb_intern2("IPV6_PATHMTU", 12));
4101 #endif
4102 #ifdef IPV6_NEXTHOP
4103     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_NEXTHOP, (st_data_t)rb_intern2("IPV6_NEXTHOP", 12));
4104 #endif
4105 #ifdef IPV6_HOPOPTS
4106     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_HOPOPTS, (st_data_t)rb_intern2("IPV6_HOPOPTS", 12));
4107 #endif
4108 #ifdef IPV6_HOPLIMIT
4109     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_HOPLIMIT, (st_data_t)rb_intern2("IPV6_HOPLIMIT", 13));
4110 #endif
4111 #ifdef IPV6_DSTOPTS
4112     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_DSTOPTS, (st_data_t)rb_intern2("IPV6_DSTOPTS", 12));
4113 #endif
4114 #ifdef IPV6_DONTFRAG
4115     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_DONTFRAG, (st_data_t)rb_intern2("IPV6_DONTFRAG", 13));
4116 #endif
4117 #ifdef IPV6_CHECKSUM
4118     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_CHECKSUM, (st_data_t)rb_intern2("IPV6_CHECKSUM", 13));
4119 #endif
4120 #ifdef IPV6_V6ONLY
4121     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_V6ONLY, (st_data_t)rb_intern2("IPV6_V6ONLY", 11));
4122 #endif
4123 #ifdef IPV6_UNICAST_HOPS
4124     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_UNICAST_HOPS, (st_data_t)rb_intern2("IPV6_UNICAST_HOPS", 17));
4125 #endif
4126 #ifdef IPV6_MULTICAST_LOOP
4127     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_MULTICAST_LOOP, (st_data_t)rb_intern2("IPV6_MULTICAST_LOOP", 19));
4128 #endif
4129 #ifdef IPV6_MULTICAST_IF
4130     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_MULTICAST_IF, (st_data_t)rb_intern2("IPV6_MULTICAST_IF", 17));
4131 #endif
4132 #ifdef IPV6_MULTICAST_HOPS
4133     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_MULTICAST_HOPS, (st_data_t)rb_intern2("IPV6_MULTICAST_HOPS", 19));
4134 #endif
4135 #ifdef IPV6_LEAVE_GROUP
4136     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_LEAVE_GROUP, (st_data_t)rb_intern2("IPV6_LEAVE_GROUP", 16));
4137 #endif
4138 #ifdef IPV6_JOIN_GROUP
4139     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_JOIN_GROUP, (st_data_t)rb_intern2("IPV6_JOIN_GROUP", 15));
4140 #endif
4141 #ifdef IPV6_USE_MIN_MTU
4142     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_USE_MIN_MTU, (st_data_t)rb_intern2("USE_MIN_MTU", 11));
4143 #endif
4144 #ifdef IPV6_TCLASS
4145     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_TCLASS, (st_data_t)rb_intern2("TCLASS", 6));
4146 #endif
4147 #ifdef IPV6_RECVPATHMTU
4148     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RECVPATHMTU, (st_data_t)rb_intern2("RECVPATHMTU", 11));
4149 #endif
4150 #ifdef IPV6_RTHDR_TYPE_0
4151     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RTHDR_TYPE_0, (st_data_t)rb_intern2("RTHDR_TYPE_0", 12));
4152 #endif
4153 #ifdef IPV6_RTHDRDSTOPTS
4154     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RTHDRDSTOPTS, (st_data_t)rb_intern2("RTHDRDSTOPTS", 12));
4155 #endif
4156 #ifdef IPV6_RTHDR
4157     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RTHDR, (st_data_t)rb_intern2("RTHDR", 5));
4158 #endif
4159 #ifdef IPV6_RECVTCLASS
4160     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RECVTCLASS, (st_data_t)rb_intern2("RECVTCLASS", 10));
4161 #endif
4162 #ifdef IPV6_RECVRTHDR
4163     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RECVRTHDR, (st_data_t)rb_intern2("RECVRTHDR", 9));
4164 #endif
4165 #ifdef IPV6_RECVPKTINFO
4166     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RECVPKTINFO, (st_data_t)rb_intern2("RECVPKTINFO", 11));
4167 #endif
4168 #ifdef IPV6_RECVHOPOPTS
4169     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RECVHOPOPTS, (st_data_t)rb_intern2("RECVHOPOPTS", 11));
4170 #endif
4171 #ifdef IPV6_RECVHOPLIMIT
4172     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RECVHOPLIMIT, (st_data_t)rb_intern2("RECVHOPLIMIT", 12));
4173 #endif
4174 #ifdef IPV6_RECVDSTOPTS
4175     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RECVDSTOPTS, (st_data_t)rb_intern2("RECVDSTOPTS", 11));
4176 #endif
4177 #ifdef IPV6_PKTINFO
4178     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_PKTINFO, (st_data_t)rb_intern2("PKTINFO", 7));
4179 #endif
4180 #ifdef IPV6_PATHMTU
4181     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_PATHMTU, (st_data_t)rb_intern2("PATHMTU", 7));
4182 #endif
4183 #ifdef IPV6_NEXTHOP
4184     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_NEXTHOP, (st_data_t)rb_intern2("NEXTHOP", 7));
4185 #endif
4186 #ifdef IPV6_HOPOPTS
4187     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_HOPOPTS, (st_data_t)rb_intern2("HOPOPTS", 7));
4188 #endif
4189 #ifdef IPV6_HOPLIMIT
4190     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_HOPLIMIT, (st_data_t)rb_intern2("HOPLIMIT", 8));
4191 #endif
4192 #ifdef IPV6_DSTOPTS
4193     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_DSTOPTS, (st_data_t)rb_intern2("DSTOPTS", 7));
4194 #endif
4195 #ifdef IPV6_DONTFRAG
4196     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_DONTFRAG, (st_data_t)rb_intern2("DONTFRAG", 8));
4197 #endif
4198 #ifdef IPV6_CHECKSUM
4199     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_CHECKSUM, (st_data_t)rb_intern2("CHECKSUM", 8));
4200 #endif
4201 #ifdef IPV6_V6ONLY
4202     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_V6ONLY, (st_data_t)rb_intern2("V6ONLY", 6));
4203 #endif
4204 #ifdef IPV6_UNICAST_HOPS
4205     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_UNICAST_HOPS, (st_data_t)rb_intern2("UNICAST_HOPS", 12));
4206 #endif
4207 #ifdef IPV6_MULTICAST_LOOP
4208     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_MULTICAST_LOOP, (st_data_t)rb_intern2("MULTICAST_LOOP", 14));
4209 #endif
4210 #ifdef IPV6_MULTICAST_IF
4211     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_MULTICAST_IF, (st_data_t)rb_intern2("MULTICAST_IF", 12));
4212 #endif
4213 #ifdef IPV6_MULTICAST_HOPS
4214     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_MULTICAST_HOPS, (st_data_t)rb_intern2("MULTICAST_HOPS", 14));
4215 #endif
4216 #ifdef IPV6_LEAVE_GROUP
4217     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_LEAVE_GROUP, (st_data_t)rb_intern2("LEAVE_GROUP", 11));
4218 #endif
4219 #ifdef IPV6_JOIN_GROUP
4220     st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_JOIN_GROUP, (st_data_t)rb_intern2("JOIN_GROUP", 10));
4221 #endif
4222 
4223     rsock_intern_tcp_optname_hash = st_init_numtable();
4224 #ifdef TCP_USER_TIMEOUT
4225     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_USER_TIMEOUT, (st_data_t)rb_intern2("TCP_USER_TIMEOUT", 16));
4226 #endif
4227 #ifdef TCP_TIMESTAMP
4228     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_TIMESTAMP, (st_data_t)rb_intern2("TCP_TIMESTAMP", 13));
4229 #endif
4230 #ifdef TCP_THIN_LINEAR_TIMEOUTS
4231     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_THIN_LINEAR_TIMEOUTS, (st_data_t)rb_intern2("TCP_THIN_LINEAR_TIMEOUTS", 24));
4232 #endif
4233 #ifdef TCP_THIN_DUPACK
4234     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_THIN_DUPACK, (st_data_t)rb_intern2("TCP_THIN_DUPACK", 15));
4235 #endif
4236 #ifdef TCP_REPAIR_QUEUE
4237     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_REPAIR_QUEUE, (st_data_t)rb_intern2("TCP_REPAIR_QUEUE", 16));
4238 #endif
4239 #ifdef TCP_REPAIR_OPTIONS
4240     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_REPAIR_OPTIONS, (st_data_t)rb_intern2("TCP_REPAIR_OPTIONS", 18));
4241 #endif
4242 #ifdef TCP_REPAIR
4243     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_REPAIR, (st_data_t)rb_intern2("TCP_REPAIR", 10));
4244 #endif
4245 #ifdef TCP_QUEUE_SEQ
4246     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_QUEUE_SEQ, (st_data_t)rb_intern2("TCP_QUEUE_SEQ", 13));
4247 #endif
4248 #ifdef TCP_COOKIE_TRANSACTIONS
4249     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_COOKIE_TRANSACTIONS, (st_data_t)rb_intern2("TCP_COOKIE_TRANSACTIONS", 23));
4250 #endif
4251 #ifdef TCP_CONGESTION
4252     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_CONGESTION, (st_data_t)rb_intern2("TCP_CONGESTION", 14));
4253 #endif
4254 #ifdef TCP_FASTOPEN
4255     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_FASTOPEN, (st_data_t)rb_intern2("TCP_FASTOPEN", 12));
4256 #endif
4257 #ifdef TCP_WINDOW_CLAMP
4258     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_WINDOW_CLAMP, (st_data_t)rb_intern2("TCP_WINDOW_CLAMP", 16));
4259 #endif
4260 #ifdef TCP_SYNCNT
4261     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_SYNCNT, (st_data_t)rb_intern2("TCP_SYNCNT", 10));
4262 #endif
4263 #ifdef TCP_QUICKACK
4264     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_QUICKACK, (st_data_t)rb_intern2("TCP_QUICKACK", 12));
4265 #endif
4266 #ifdef TCP_NOPUSH
4267     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_NOPUSH, (st_data_t)rb_intern2("TCP_NOPUSH", 10));
4268 #endif
4269 #ifdef TCP_NOOPT
4270     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_NOOPT, (st_data_t)rb_intern2("TCP_NOOPT", 9));
4271 #endif
4272 #ifdef TCP_MD5SIG
4273     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_MD5SIG, (st_data_t)rb_intern2("TCP_MD5SIG", 10));
4274 #endif
4275 #ifdef TCP_LINGER2
4276     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_LINGER2, (st_data_t)rb_intern2("TCP_LINGER2", 11));
4277 #endif
4278 #ifdef TCP_KEEPINTVL
4279     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_KEEPINTVL, (st_data_t)rb_intern2("TCP_KEEPINTVL", 13));
4280 #endif
4281 #ifdef TCP_KEEPIDLE
4282     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_KEEPIDLE, (st_data_t)rb_intern2("TCP_KEEPIDLE", 12));
4283 #endif
4284 #ifdef TCP_KEEPCNT
4285     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_KEEPCNT, (st_data_t)rb_intern2("TCP_KEEPCNT", 11));
4286 #endif
4287 #ifdef TCP_INFO
4288     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_INFO, (st_data_t)rb_intern2("TCP_INFO", 8));
4289 #endif
4290 #ifdef TCP_DEFER_ACCEPT
4291     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_DEFER_ACCEPT, (st_data_t)rb_intern2("TCP_DEFER_ACCEPT", 16));
4292 #endif
4293 #ifdef TCP_CORK
4294     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_CORK, (st_data_t)rb_intern2("TCP_CORK", 8));
4295 #endif
4296 #ifdef TCP_MAXSEG
4297     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_MAXSEG, (st_data_t)rb_intern2("TCP_MAXSEG", 10));
4298 #endif
4299 #ifdef TCP_NODELAY
4300     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_NODELAY, (st_data_t)rb_intern2("TCP_NODELAY", 11));
4301 #endif
4302 #ifdef TCP_USER_TIMEOUT
4303     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_USER_TIMEOUT, (st_data_t)rb_intern2("USER_TIMEOUT", 12));
4304 #endif
4305 #ifdef TCP_TIMESTAMP
4306     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_TIMESTAMP, (st_data_t)rb_intern2("TIMESTAMP", 9));
4307 #endif
4308 #ifdef TCP_THIN_LINEAR_TIMEOUTS
4309     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_THIN_LINEAR_TIMEOUTS, (st_data_t)rb_intern2("THIN_LINEAR_TIMEOUTS", 20));
4310 #endif
4311 #ifdef TCP_THIN_DUPACK
4312     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_THIN_DUPACK, (st_data_t)rb_intern2("THIN_DUPACK", 11));
4313 #endif
4314 #ifdef TCP_REPAIR_QUEUE
4315     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_REPAIR_QUEUE, (st_data_t)rb_intern2("REPAIR_QUEUE", 12));
4316 #endif
4317 #ifdef TCP_REPAIR_OPTIONS
4318     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_REPAIR_OPTIONS, (st_data_t)rb_intern2("REPAIR_OPTIONS", 14));
4319 #endif
4320 #ifdef TCP_REPAIR
4321     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_REPAIR, (st_data_t)rb_intern2("REPAIR", 6));
4322 #endif
4323 #ifdef TCP_QUEUE_SEQ
4324     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_QUEUE_SEQ, (st_data_t)rb_intern2("QUEUE_SEQ", 9));
4325 #endif
4326 #ifdef TCP_COOKIE_TRANSACTIONS
4327     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_COOKIE_TRANSACTIONS, (st_data_t)rb_intern2("COOKIE_TRANSACTIONS", 19));
4328 #endif
4329 #ifdef TCP_CONGESTION
4330     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_CONGESTION, (st_data_t)rb_intern2("CONGESTION", 10));
4331 #endif
4332 #ifdef TCP_FASTOPEN
4333     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_FASTOPEN, (st_data_t)rb_intern2("FASTOPEN", 8));
4334 #endif
4335 #ifdef TCP_WINDOW_CLAMP
4336     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_WINDOW_CLAMP, (st_data_t)rb_intern2("WINDOW_CLAMP", 12));
4337 #endif
4338 #ifdef TCP_SYNCNT
4339     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_SYNCNT, (st_data_t)rb_intern2("SYNCNT", 6));
4340 #endif
4341 #ifdef TCP_QUICKACK
4342     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_QUICKACK, (st_data_t)rb_intern2("QUICKACK", 8));
4343 #endif
4344 #ifdef TCP_NOPUSH
4345     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_NOPUSH, (st_data_t)rb_intern2("NOPUSH", 6));
4346 #endif
4347 #ifdef TCP_NOOPT
4348     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_NOOPT, (st_data_t)rb_intern2("NOOPT", 5));
4349 #endif
4350 #ifdef TCP_MD5SIG
4351     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_MD5SIG, (st_data_t)rb_intern2("MD5SIG", 6));
4352 #endif
4353 #ifdef TCP_LINGER2
4354     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_LINGER2, (st_data_t)rb_intern2("LINGER2", 7));
4355 #endif
4356 #ifdef TCP_KEEPINTVL
4357     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_KEEPINTVL, (st_data_t)rb_intern2("KEEPINTVL", 9));
4358 #endif
4359 #ifdef TCP_KEEPIDLE
4360     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_KEEPIDLE, (st_data_t)rb_intern2("KEEPIDLE", 8));
4361 #endif
4362 #ifdef TCP_KEEPCNT
4363     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_KEEPCNT, (st_data_t)rb_intern2("KEEPCNT", 7));
4364 #endif
4365 #ifdef TCP_INFO
4366     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_INFO, (st_data_t)rb_intern2("INFO", 4));
4367 #endif
4368 #ifdef TCP_DEFER_ACCEPT
4369     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_DEFER_ACCEPT, (st_data_t)rb_intern2("DEFER_ACCEPT", 12));
4370 #endif
4371 #ifdef TCP_CORK
4372     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_CORK, (st_data_t)rb_intern2("CORK", 4));
4373 #endif
4374 #ifdef TCP_MAXSEG
4375     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_MAXSEG, (st_data_t)rb_intern2("MAXSEG", 6));
4376 #endif
4377 #ifdef TCP_NODELAY
4378     st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_NODELAY, (st_data_t)rb_intern2("NODELAY", 7));
4379 #endif
4380 
4381     rsock_intern_udp_optname_hash = st_init_numtable();
4382 #ifdef UDP_CORK
4383     st_insert(rsock_intern_udp_optname_hash, (st_data_t)UDP_CORK, (st_data_t)rb_intern2("UDP_CORK", 8));
4384 #endif
4385 #ifdef UDP_CORK
4386     st_insert(rsock_intern_udp_optname_hash, (st_data_t)UDP_CORK, (st_data_t)rb_intern2("CORK", 4));
4387 #endif
4388 
4389     rsock_intern_scm_optname_hash = st_init_numtable();
4390 #ifdef SCM_WIFI_STATUS
4391     st_insert(rsock_intern_scm_optname_hash, (st_data_t)SCM_WIFI_STATUS, (st_data_t)rb_intern2("SCM_WIFI_STATUS", 15));
4392 #endif
4393 #ifdef SCM_UCRED
4394     st_insert(rsock_intern_scm_optname_hash, (st_data_t)SCM_UCRED, (st_data_t)rb_intern2("SCM_UCRED", 9));
4395 #endif
4396 #ifdef SCM_CREDS
4397     st_insert(rsock_intern_scm_optname_hash, (st_data_t)SCM_CREDS, (st_data_t)rb_intern2("SCM_CREDS", 9));
4398 #endif
4399 #ifdef SCM_CREDENTIALS
4400     st_insert(rsock_intern_scm_optname_hash, (st_data_t)SCM_CREDENTIALS, (st_data_t)rb_intern2("SCM_CREDENTIALS", 15));
4401 #endif
4402 #ifdef SCM_BINTIME
4403     st_insert(rsock_intern_scm_optname_hash, (st_data_t)SCM_BINTIME, (st_data_t)rb_intern2("SCM_BINTIME", 11));
4404 #endif
4405 #ifdef SCM_TIMESTAMPING
4406     st_insert(rsock_intern_scm_optname_hash, (st_data_t)SCM_TIMESTAMPING, (st_data_t)rb_intern2("SCM_TIMESTAMPING", 16));
4407 #endif
4408 #ifdef SCM_TIMESTAMPNS
4409     st_insert(rsock_intern_scm_optname_hash, (st_data_t)SCM_TIMESTAMPNS, (st_data_t)rb_intern2("SCM_TIMESTAMPNS", 15));
4410 #endif
4411 #ifdef SCM_TIMESTAMP
4412     st_insert(rsock_intern_scm_optname_hash, (st_data_t)SCM_TIMESTAMP, (st_data_t)rb_intern2("SCM_TIMESTAMP", 13));
4413 #endif
4414 #ifdef SCM_RIGHTS
4415     st_insert(rsock_intern_scm_optname_hash, (st_data_t)SCM_RIGHTS, (st_data_t)rb_intern2("SCM_RIGHTS", 10));
4416 #endif
4417 #ifdef SCM_WIFI_STATUS
4418     st_insert(rsock_intern_scm_optname_hash, (st_data_t)SCM_WIFI_STATUS, (st_data_t)rb_intern2("WIFI_STATUS", 11));
4419 #endif
4420 #ifdef SCM_UCRED
4421     st_insert(rsock_intern_scm_optname_hash, (st_data_t)SCM_UCRED, (st_data_t)rb_intern2("UCRED", 5));
4422 #endif
4423 #ifdef SCM_CREDS
4424     st_insert(rsock_intern_scm_optname_hash, (st_data_t)SCM_CREDS, (st_data_t)rb_intern2("CREDS", 5));
4425 #endif
4426 #ifdef SCM_CREDENTIALS
4427     st_insert(rsock_intern_scm_optname_hash, (st_data_t)SCM_CREDENTIALS, (st_data_t)rb_intern2("CREDENTIALS", 11));
4428 #endif
4429 #ifdef SCM_BINTIME
4430     st_insert(rsock_intern_scm_optname_hash, (st_data_t)SCM_BINTIME, (st_data_t)rb_intern2("BINTIME", 7));
4431 #endif
4432 #ifdef SCM_TIMESTAMPING
4433     st_insert(rsock_intern_scm_optname_hash, (st_data_t)SCM_TIMESTAMPING, (st_data_t)rb_intern2("TIMESTAMPING", 12));
4434 #endif
4435 #ifdef SCM_TIMESTAMPNS
4436     st_insert(rsock_intern_scm_optname_hash, (st_data_t)SCM_TIMESTAMPNS, (st_data_t)rb_intern2("TIMESTAMPNS", 11));
4437 #endif
4438 #ifdef SCM_TIMESTAMP
4439     st_insert(rsock_intern_scm_optname_hash, (st_data_t)SCM_TIMESTAMP, (st_data_t)rb_intern2("TIMESTAMP", 9));
4440 #endif
4441 #ifdef SCM_RIGHTS
4442     st_insert(rsock_intern_scm_optname_hash, (st_data_t)SCM_RIGHTS, (st_data_t)rb_intern2("RIGHTS", 6));
4443 #endif
4444 
4445     rsock_intern_local_optname_hash = st_init_numtable();
4446 #ifdef LOCAL_CONNWAIT
4447     st_insert(rsock_intern_local_optname_hash, (st_data_t)LOCAL_CONNWAIT, (st_data_t)rb_intern2("LOCAL_CONNWAIT", 14));
4448 #endif
4449 #ifdef LOCAL_CREDS
4450     st_insert(rsock_intern_local_optname_hash, (st_data_t)LOCAL_CREDS, (st_data_t)rb_intern2("LOCAL_CREDS", 11));
4451 #endif
4452 #ifdef LOCAL_PEERCRED
4453     st_insert(rsock_intern_local_optname_hash, (st_data_t)LOCAL_PEERCRED, (st_data_t)rb_intern2("LOCAL_PEERCRED", 14));
4454 #endif
4455 #ifdef LOCAL_CONNWAIT
4456     st_insert(rsock_intern_local_optname_hash, (st_data_t)LOCAL_CONNWAIT, (st_data_t)rb_intern2("CONNWAIT", 8));
4457 #endif
4458 #ifdef LOCAL_CREDS
4459     st_insert(rsock_intern_local_optname_hash, (st_data_t)LOCAL_CREDS, (st_data_t)rb_intern2("CREDS", 5));
4460 #endif
4461 #ifdef LOCAL_PEERCRED
4462     st_insert(rsock_intern_local_optname_hash, (st_data_t)LOCAL_PEERCRED, (st_data_t)rb_intern2("PEERCRED", 8));
4463 #endif
4464 
4465 }
4466 
4467 int
rsock_family_to_int(const char * str,long len,int * valp)4468 rsock_family_to_int(const char *str, long len, int *valp)
4469 {
4470     switch (len) {
4471       case 2:
4472 #ifdef AF_NS
4473         if (memcmp(str, "NS", 2) == 0) { *valp = AF_NS; return 0; }
4474 #endif
4475         return -1;
4476 
4477       case 3:
4478 #ifdef AF_IPX
4479         if (memcmp(str, "IPX", 3) == 0) { *valp = AF_IPX; return 0; }
4480 #endif
4481 #ifdef AF_PUP
4482         if (memcmp(str, "PUP", 3) == 0) { *valp = AF_PUP; return 0; }
4483 #endif
4484 #ifdef AF_ISO
4485         if (memcmp(str, "ISO", 3) == 0) { *valp = AF_ISO; return 0; }
4486 #endif
4487 #ifdef AF_OSI
4488         if (memcmp(str, "OSI", 3) == 0) { *valp = AF_OSI; return 0; }
4489 #endif
4490 #ifdef AF_SNA
4491         if (memcmp(str, "SNA", 3) == 0) { *valp = AF_SNA; return 0; }
4492 #endif
4493 #ifdef AF_DEC
4494         if (memcmp(str, "DEC", 3) == 0) { *valp = AF_DEC; return 0; }
4495 #endif
4496 #ifdef AF_DLI
4497         if (memcmp(str, "DLI", 3) == 0) { *valp = AF_DLI; return 0; }
4498 #endif
4499 #ifdef AF_LAT
4500         if (memcmp(str, "LAT", 3) == 0) { *valp = AF_LAT; return 0; }
4501 #endif
4502 #ifdef AF_CNT
4503         if (memcmp(str, "CNT", 3) == 0) { *valp = AF_CNT; return 0; }
4504 #endif
4505 #ifdef AF_SIP
4506         if (memcmp(str, "SIP", 3) == 0) { *valp = AF_SIP; return 0; }
4507 #endif
4508 #ifdef AF_PPP
4509         if (memcmp(str, "PPP", 3) == 0) { *valp = AF_PPP; return 0; }
4510 #endif
4511 #ifdef AF_ATM
4512         if (memcmp(str, "ATM", 3) == 0) { *valp = AF_ATM; return 0; }
4513 #endif
4514 #ifdef AF_MAX
4515         if (memcmp(str, "MAX", 3) == 0) { *valp = AF_MAX; return 0; }
4516 #endif
4517         return -1;
4518 
4519       case 4:
4520 #ifdef AF_INET
4521         if (memcmp(str, "INET", 4) == 0) { *valp = AF_INET; return 0; }
4522 #endif
4523 #ifdef AF_UNIX
4524         if (memcmp(str, "UNIX", 4) == 0) { *valp = AF_UNIX; return 0; }
4525 #endif
4526 #ifdef AF_AX25
4527         if (memcmp(str, "AX25", 4) == 0) { *valp = AF_AX25; return 0; }
4528 #endif
4529 #ifdef AF_ECMA
4530         if (memcmp(str, "ECMA", 4) == 0) { *valp = AF_ECMA; return 0; }
4531 #endif
4532 #ifdef AF_LINK
4533         if (memcmp(str, "LINK", 4) == 0) { *valp = AF_LINK; return 0; }
4534 #endif
4535 #ifdef AF_COIP
4536         if (memcmp(str, "COIP", 4) == 0) { *valp = AF_COIP; return 0; }
4537 #endif
4538 #ifdef AF_NDRV
4539         if (memcmp(str, "NDRV", 4) == 0) { *valp = AF_NDRV; return 0; }
4540 #endif
4541 #ifdef AF_ISDN
4542         if (memcmp(str, "ISDN", 4) == 0) { *valp = AF_ISDN; return 0; }
4543 #endif
4544 #ifdef AF_NATM
4545         if (memcmp(str, "NATM", 4) == 0) { *valp = AF_NATM; return 0; }
4546 #endif
4547 #ifdef AF_E164
4548         if (memcmp(str, "E164", 4) == 0) { *valp = AF_E164; return 0; }
4549 #endif
4550         return -1;
4551 
4552       case 5:
4553 #ifdef AF_NS
4554         if (memcmp(str, "AF_NS", 5) == 0) { *valp = AF_NS; return 0; }
4555 #endif
4556 #ifdef PF_NS
4557         if (memcmp(str, "PF_NS", 5) == 0) { *valp = PF_NS; return 0; }
4558 #endif
4559 #ifdef AF_INET6
4560         if (memcmp(str, "INET6", 5) == 0) { *valp = AF_INET6; return 0; }
4561 #endif
4562 #ifdef AF_LOCAL
4563         if (memcmp(str, "LOCAL", 5) == 0) { *valp = AF_LOCAL; return 0; }
4564 #endif
4565 #ifdef AF_CHAOS
4566         if (memcmp(str, "CHAOS", 5) == 0) { *valp = AF_CHAOS; return 0; }
4567 #endif
4568 #ifdef AF_CCITT
4569         if (memcmp(str, "CCITT", 5) == 0) { *valp = AF_CCITT; return 0; }
4570 #endif
4571 #ifdef AF_ROUTE
4572         if (memcmp(str, "ROUTE", 5) == 0) { *valp = AF_ROUTE; return 0; }
4573 #endif
4574         return -1;
4575 
4576       case 6:
4577 #ifdef AF_IPX
4578         if (memcmp(str, "AF_IPX", 6) == 0) { *valp = AF_IPX; return 0; }
4579 #endif
4580 #ifdef PF_IPX
4581         if (memcmp(str, "PF_IPX", 6) == 0) { *valp = PF_IPX; return 0; }
4582 #endif
4583 #ifdef AF_PUP
4584         if (memcmp(str, "AF_PUP", 6) == 0) { *valp = AF_PUP; return 0; }
4585 #endif
4586 #ifdef PF_PUP
4587         if (memcmp(str, "PF_PUP", 6) == 0) { *valp = PF_PUP; return 0; }
4588 #endif
4589 #ifdef AF_ISO
4590         if (memcmp(str, "AF_ISO", 6) == 0) { *valp = AF_ISO; return 0; }
4591 #endif
4592 #ifdef PF_ISO
4593         if (memcmp(str, "PF_ISO", 6) == 0) { *valp = PF_ISO; return 0; }
4594 #endif
4595 #ifdef AF_OSI
4596         if (memcmp(str, "AF_OSI", 6) == 0) { *valp = AF_OSI; return 0; }
4597 #endif
4598 #ifdef PF_OSI
4599         if (memcmp(str, "PF_OSI", 6) == 0) { *valp = PF_OSI; return 0; }
4600 #endif
4601 #ifdef AF_SNA
4602         if (memcmp(str, "AF_SNA", 6) == 0) { *valp = AF_SNA; return 0; }
4603 #endif
4604 #ifdef PF_SNA
4605         if (memcmp(str, "PF_SNA", 6) == 0) { *valp = PF_SNA; return 0; }
4606 #endif
4607 #ifdef AF_DEC
4608         if (memcmp(str, "AF_DEC", 6) == 0) { *valp = AF_DEC; return 0; }
4609 #endif
4610 #ifdef PF_DEC
4611         if (memcmp(str, "PF_DEC", 6) == 0) { *valp = PF_DEC; return 0; }
4612 #endif
4613 #ifdef AF_DLI
4614         if (memcmp(str, "AF_DLI", 6) == 0) { *valp = AF_DLI; return 0; }
4615 #endif
4616 #ifdef PF_DLI
4617         if (memcmp(str, "PF_DLI", 6) == 0) { *valp = PF_DLI; return 0; }
4618 #endif
4619 #ifdef AF_LAT
4620         if (memcmp(str, "AF_LAT", 6) == 0) { *valp = AF_LAT; return 0; }
4621 #endif
4622 #ifdef PF_LAT
4623         if (memcmp(str, "PF_LAT", 6) == 0) { *valp = PF_LAT; return 0; }
4624 #endif
4625 #ifdef AF_CNT
4626         if (memcmp(str, "AF_CNT", 6) == 0) { *valp = AF_CNT; return 0; }
4627 #endif
4628 #ifdef PF_CNT
4629         if (memcmp(str, "PF_CNT", 6) == 0) { *valp = PF_CNT; return 0; }
4630 #endif
4631 #ifdef AF_SIP
4632         if (memcmp(str, "AF_SIP", 6) == 0) { *valp = AF_SIP; return 0; }
4633 #endif
4634 #ifdef PF_SIP
4635         if (memcmp(str, "PF_SIP", 6) == 0) { *valp = PF_SIP; return 0; }
4636 #endif
4637 #ifdef AF_PPP
4638         if (memcmp(str, "AF_PPP", 6) == 0) { *valp = AF_PPP; return 0; }
4639 #endif
4640 #ifdef PF_PPP
4641         if (memcmp(str, "PF_PPP", 6) == 0) { *valp = PF_PPP; return 0; }
4642 #endif
4643 #ifdef AF_ATM
4644         if (memcmp(str, "AF_ATM", 6) == 0) { *valp = AF_ATM; return 0; }
4645 #endif
4646 #ifdef PF_ATM
4647         if (memcmp(str, "PF_ATM", 6) == 0) { *valp = PF_ATM; return 0; }
4648 #endif
4649 #ifdef AF_MAX
4650         if (memcmp(str, "AF_MAX", 6) == 0) { *valp = AF_MAX; return 0; }
4651 #endif
4652 #ifdef PF_MAX
4653         if (memcmp(str, "PF_MAX", 6) == 0) { *valp = PF_MAX; return 0; }
4654 #endif
4655 #ifdef PF_XTP
4656         if (memcmp(str, "PF_XTP", 6) == 0) { *valp = PF_XTP; return 0; }
4657 #endif
4658 #ifdef PF_PIP
4659         if (memcmp(str, "PF_PIP", 6) == 0) { *valp = PF_PIP; return 0; }
4660 #endif
4661 #ifdef PF_KEY
4662         if (memcmp(str, "PF_KEY", 6) == 0) { *valp = PF_KEY; return 0; }
4663 #endif
4664 #ifdef AF_UNSPEC
4665         if (memcmp(str, "UNSPEC", 6) == 0) { *valp = AF_UNSPEC; return 0; }
4666 #endif
4667 #ifdef AF_HYLINK
4668         if (memcmp(str, "HYLINK", 6) == 0) { *valp = AF_HYLINK; return 0; }
4669 #endif
4670 #ifdef AF_SYSTEM
4671         if (memcmp(str, "SYSTEM", 6) == 0) { *valp = AF_SYSTEM; return 0; }
4672 #endif
4673 #ifdef AF_PACKET
4674         if (memcmp(str, "PACKET", 6) == 0) { *valp = AF_PACKET; return 0; }
4675 #endif
4676         return -1;
4677 
4678       case 7:
4679 #ifdef AF_INET
4680         if (memcmp(str, "AF_INET", 7) == 0) { *valp = AF_INET; return 0; }
4681 #endif
4682 #ifdef PF_INET
4683         if (memcmp(str, "PF_INET", 7) == 0) { *valp = PF_INET; return 0; }
4684 #endif
4685 #ifdef AF_UNIX
4686         if (memcmp(str, "AF_UNIX", 7) == 0) { *valp = AF_UNIX; return 0; }
4687 #endif
4688 #ifdef PF_UNIX
4689         if (memcmp(str, "PF_UNIX", 7) == 0) { *valp = PF_UNIX; return 0; }
4690 #endif
4691 #ifdef AF_AX25
4692         if (memcmp(str, "AF_AX25", 7) == 0) { *valp = AF_AX25; return 0; }
4693 #endif
4694 #ifdef PF_AX25
4695         if (memcmp(str, "PF_AX25", 7) == 0) { *valp = PF_AX25; return 0; }
4696 #endif
4697 #ifdef AF_ECMA
4698         if (memcmp(str, "AF_ECMA", 7) == 0) { *valp = AF_ECMA; return 0; }
4699 #endif
4700 #ifdef PF_ECMA
4701         if (memcmp(str, "PF_ECMA", 7) == 0) { *valp = PF_ECMA; return 0; }
4702 #endif
4703 #ifdef AF_LINK
4704         if (memcmp(str, "AF_LINK", 7) == 0) { *valp = AF_LINK; return 0; }
4705 #endif
4706 #ifdef PF_LINK
4707         if (memcmp(str, "PF_LINK", 7) == 0) { *valp = PF_LINK; return 0; }
4708 #endif
4709 #ifdef AF_COIP
4710         if (memcmp(str, "AF_COIP", 7) == 0) { *valp = AF_COIP; return 0; }
4711 #endif
4712 #ifdef PF_COIP
4713         if (memcmp(str, "PF_COIP", 7) == 0) { *valp = PF_COIP; return 0; }
4714 #endif
4715 #ifdef AF_NDRV
4716         if (memcmp(str, "AF_NDRV", 7) == 0) { *valp = AF_NDRV; return 0; }
4717 #endif
4718 #ifdef PF_NDRV
4719         if (memcmp(str, "PF_NDRV", 7) == 0) { *valp = PF_NDRV; return 0; }
4720 #endif
4721 #ifdef AF_ISDN
4722         if (memcmp(str, "AF_ISDN", 7) == 0) { *valp = AF_ISDN; return 0; }
4723 #endif
4724 #ifdef PF_ISDN
4725         if (memcmp(str, "PF_ISDN", 7) == 0) { *valp = PF_ISDN; return 0; }
4726 #endif
4727 #ifdef AF_NATM
4728         if (memcmp(str, "AF_NATM", 7) == 0) { *valp = AF_NATM; return 0; }
4729 #endif
4730 #ifdef PF_NATM
4731         if (memcmp(str, "PF_NATM", 7) == 0) { *valp = PF_NATM; return 0; }
4732 #endif
4733 #ifdef AF_E164
4734         if (memcmp(str, "AF_E164", 7) == 0) { *valp = AF_E164; return 0; }
4735 #endif
4736 #ifdef PF_RTIP
4737         if (memcmp(str, "PF_RTIP", 7) == 0) { *valp = PF_RTIP; return 0; }
4738 #endif
4739 #ifdef AF_IMPLINK
4740         if (memcmp(str, "IMPLINK", 7) == 0) { *valp = AF_IMPLINK; return 0; }
4741 #endif
4742 #ifdef AF_DATAKIT
4743         if (memcmp(str, "DATAKIT", 7) == 0) { *valp = AF_DATAKIT; return 0; }
4744 #endif
4745 #ifdef AF_NETBIOS
4746         if (memcmp(str, "NETBIOS", 7) == 0) { *valp = AF_NETBIOS; return 0; }
4747 #endif
4748         return -1;
4749 
4750       case 8:
4751 #ifdef AF_INET6
4752         if (memcmp(str, "AF_INET6", 8) == 0) { *valp = AF_INET6; return 0; }
4753 #endif
4754 #ifdef PF_INET6
4755         if (memcmp(str, "PF_INET6", 8) == 0) { *valp = PF_INET6; return 0; }
4756 #endif
4757 #ifdef AF_LOCAL
4758         if (memcmp(str, "AF_LOCAL", 8) == 0) { *valp = AF_LOCAL; return 0; }
4759 #endif
4760 #ifdef PF_LOCAL
4761         if (memcmp(str, "PF_LOCAL", 8) == 0) { *valp = PF_LOCAL; return 0; }
4762 #endif
4763 #ifdef AF_CHAOS
4764         if (memcmp(str, "AF_CHAOS", 8) == 0) { *valp = AF_CHAOS; return 0; }
4765 #endif
4766 #ifdef PF_CHAOS
4767         if (memcmp(str, "PF_CHAOS", 8) == 0) { *valp = PF_CHAOS; return 0; }
4768 #endif
4769 #ifdef AF_CCITT
4770         if (memcmp(str, "AF_CCITT", 8) == 0) { *valp = AF_CCITT; return 0; }
4771 #endif
4772 #ifdef PF_CCITT
4773         if (memcmp(str, "PF_CCITT", 8) == 0) { *valp = PF_CCITT; return 0; }
4774 #endif
4775 #ifdef AF_ROUTE
4776         if (memcmp(str, "AF_ROUTE", 8) == 0) { *valp = AF_ROUTE; return 0; }
4777 #endif
4778 #ifdef PF_ROUTE
4779         if (memcmp(str, "PF_ROUTE", 8) == 0) { *valp = PF_ROUTE; return 0; }
4780 #endif
4781 #ifdef AF_NETGRAPH
4782         if (memcmp(str, "NETGRAPH", 8) == 0) { *valp = AF_NETGRAPH; return 0; }
4783 #endif
4784         return -1;
4785 
4786       case 9:
4787 #ifdef AF_UNSPEC
4788         if (memcmp(str, "AF_UNSPEC", 9) == 0) { *valp = AF_UNSPEC; return 0; }
4789 #endif
4790 #ifdef PF_UNSPEC
4791         if (memcmp(str, "PF_UNSPEC", 9) == 0) { *valp = PF_UNSPEC; return 0; }
4792 #endif
4793 #ifdef AF_HYLINK
4794         if (memcmp(str, "AF_HYLINK", 9) == 0) { *valp = AF_HYLINK; return 0; }
4795 #endif
4796 #ifdef PF_HYLINK
4797         if (memcmp(str, "PF_HYLINK", 9) == 0) { *valp = PF_HYLINK; return 0; }
4798 #endif
4799 #ifdef AF_SYSTEM
4800         if (memcmp(str, "AF_SYSTEM", 9) == 0) { *valp = AF_SYSTEM; return 0; }
4801 #endif
4802 #ifdef PF_SYSTEM
4803         if (memcmp(str, "PF_SYSTEM", 9) == 0) { *valp = PF_SYSTEM; return 0; }
4804 #endif
4805 #ifdef AF_PACKET
4806         if (memcmp(str, "AF_PACKET", 9) == 0) { *valp = AF_PACKET; return 0; }
4807 #endif
4808 #ifdef PF_PACKET
4809         if (memcmp(str, "PF_PACKET", 9) == 0) { *valp = PF_PACKET; return 0; }
4810 #endif
4811 #ifdef AF_APPLETALK
4812         if (memcmp(str, "APPLETALK", 9) == 0) { *valp = AF_APPLETALK; return 0; }
4813 #endif
4814         return -1;
4815 
4816       case 10:
4817 #ifdef AF_IMPLINK
4818         if (memcmp(str, "AF_IMPLINK", 10) == 0) { *valp = AF_IMPLINK; return 0; }
4819 #endif
4820 #ifdef PF_IMPLINK
4821         if (memcmp(str, "PF_IMPLINK", 10) == 0) { *valp = PF_IMPLINK; return 0; }
4822 #endif
4823 #ifdef AF_DATAKIT
4824         if (memcmp(str, "AF_DATAKIT", 10) == 0) { *valp = AF_DATAKIT; return 0; }
4825 #endif
4826 #ifdef PF_DATAKIT
4827         if (memcmp(str, "PF_DATAKIT", 10) == 0) { *valp = PF_DATAKIT; return 0; }
4828 #endif
4829 #ifdef AF_NETBIOS
4830         if (memcmp(str, "AF_NETBIOS", 10) == 0) { *valp = AF_NETBIOS; return 0; }
4831 #endif
4832 #ifdef PF_NETBIOS
4833         if (memcmp(str, "PF_NETBIOS", 10) == 0) { *valp = PF_NETBIOS; return 0; }
4834 #endif
4835         return -1;
4836 
4837       case 11:
4838 #ifdef AF_NETGRAPH
4839         if (memcmp(str, "AF_NETGRAPH", 11) == 0) { *valp = AF_NETGRAPH; return 0; }
4840 #endif
4841 #ifdef PF_NETGRAPH
4842         if (memcmp(str, "PF_NETGRAPH", 11) == 0) { *valp = PF_NETGRAPH; return 0; }
4843 #endif
4844         return -1;
4845 
4846       case 12:
4847 #ifdef AF_APPLETALK
4848         if (memcmp(str, "AF_APPLETALK", 12) == 0) { *valp = AF_APPLETALK; return 0; }
4849 #endif
4850 #ifdef PF_APPLETALK
4851         if (memcmp(str, "PF_APPLETALK", 12) == 0) { *valp = PF_APPLETALK; return 0; }
4852 #endif
4853         return -1;
4854 
4855       default:
4856         return -1;
4857     }
4858 }
4859 
4860 
4861 int
rsock_socktype_to_int(const char * str,long len,int * valp)4862 rsock_socktype_to_int(const char *str, long len, int *valp)
4863 {
4864     switch (len) {
4865       case 3:
4866 #ifdef SOCK_RAW
4867         if (memcmp(str, "RAW", 3) == 0) { *valp = SOCK_RAW; return 0; }
4868 #endif
4869 #ifdef SOCK_RDM
4870         if (memcmp(str, "RDM", 3) == 0) { *valp = SOCK_RDM; return 0; }
4871 #endif
4872         return -1;
4873 
4874       case 5:
4875 #ifdef SOCK_DGRAM
4876         if (memcmp(str, "DGRAM", 5) == 0) { *valp = SOCK_DGRAM; return 0; }
4877 #endif
4878         return -1;
4879 
4880       case 6:
4881 #ifdef SOCK_STREAM
4882         if (memcmp(str, "STREAM", 6) == 0) { *valp = SOCK_STREAM; return 0; }
4883 #endif
4884 #ifdef SOCK_PACKET
4885         if (memcmp(str, "PACKET", 6) == 0) { *valp = SOCK_PACKET; return 0; }
4886 #endif
4887         return -1;
4888 
4889       case 8:
4890 #ifdef SOCK_RAW
4891         if (memcmp(str, "SOCK_RAW", 8) == 0) { *valp = SOCK_RAW; return 0; }
4892 #endif
4893 #ifdef SOCK_RDM
4894         if (memcmp(str, "SOCK_RDM", 8) == 0) { *valp = SOCK_RDM; return 0; }
4895 #endif
4896         return -1;
4897 
4898       case 9:
4899 #ifdef SOCK_SEQPACKET
4900         if (memcmp(str, "SEQPACKET", 9) == 0) { *valp = SOCK_SEQPACKET; return 0; }
4901 #endif
4902         return -1;
4903 
4904       case 10:
4905 #ifdef SOCK_DGRAM
4906         if (memcmp(str, "SOCK_DGRAM", 10) == 0) { *valp = SOCK_DGRAM; return 0; }
4907 #endif
4908         return -1;
4909 
4910       case 11:
4911 #ifdef SOCK_STREAM
4912         if (memcmp(str, "SOCK_STREAM", 11) == 0) { *valp = SOCK_STREAM; return 0; }
4913 #endif
4914 #ifdef SOCK_PACKET
4915         if (memcmp(str, "SOCK_PACKET", 11) == 0) { *valp = SOCK_PACKET; return 0; }
4916 #endif
4917         return -1;
4918 
4919       case 14:
4920 #ifdef SOCK_SEQPACKET
4921         if (memcmp(str, "SOCK_SEQPACKET", 14) == 0) { *valp = SOCK_SEQPACKET; return 0; }
4922 #endif
4923         return -1;
4924 
4925       default:
4926         return -1;
4927     }
4928 }
4929 
4930 
4931 int
rsock_ipproto_to_int(const char * str,long len,int * valp)4932 rsock_ipproto_to_int(const char *str, long len, int *valp)
4933 {
4934     switch (len) {
4935       case 2:
4936 #ifdef IPPROTO_IP
4937         if (memcmp(str, "IP", 2) == 0) { *valp = IPPROTO_IP; return 0; }
4938 #endif
4939 #ifdef IPPROTO_ND
4940         if (memcmp(str, "ND", 2) == 0) { *valp = IPPROTO_ND; return 0; }
4941 #endif
4942 #ifdef IPPROTO_TP
4943         if (memcmp(str, "TP", 2) == 0) { *valp = IPPROTO_TP; return 0; }
4944 #endif
4945 #ifdef IPPROTO_AH
4946         if (memcmp(str, "AH", 2) == 0) { *valp = IPPROTO_AH; return 0; }
4947 #endif
4948         return -1;
4949 
4950       case 3:
4951 #ifdef IPPROTO_GGP
4952         if (memcmp(str, "GGP", 3) == 0) { *valp = IPPROTO_GGP; return 0; }
4953 #endif
4954 #ifdef IPPROTO_TCP
4955         if (memcmp(str, "TCP", 3) == 0) { *valp = IPPROTO_TCP; return 0; }
4956 #endif
4957 #ifdef IPPROTO_EGP
4958         if (memcmp(str, "EGP", 3) == 0) { *valp = IPPROTO_EGP; return 0; }
4959 #endif
4960 #ifdef IPPROTO_PUP
4961         if (memcmp(str, "PUP", 3) == 0) { *valp = IPPROTO_PUP; return 0; }
4962 #endif
4963 #ifdef IPPROTO_UDP
4964         if (memcmp(str, "UDP", 3) == 0) { *valp = IPPROTO_UDP; return 0; }
4965 #endif
4966 #ifdef IPPROTO_IDP
4967         if (memcmp(str, "IDP", 3) == 0) { *valp = IPPROTO_IDP; return 0; }
4968 #endif
4969 #ifdef IPPROTO_XTP
4970         if (memcmp(str, "XTP", 3) == 0) { *valp = IPPROTO_XTP; return 0; }
4971 #endif
4972 #ifdef IPPROTO_EON
4973         if (memcmp(str, "EON", 3) == 0) { *valp = IPPROTO_EON; return 0; }
4974 #endif
4975 #ifdef IPPROTO_BIP
4976         if (memcmp(str, "BIP", 3) == 0) { *valp = IPPROTO_BIP; return 0; }
4977 #endif
4978 #ifdef IPPROTO_ESP
4979         if (memcmp(str, "ESP", 3) == 0) { *valp = IPPROTO_ESP; return 0; }
4980 #endif
4981 #ifdef IPPROTO_RAW
4982         if (memcmp(str, "RAW", 3) == 0) { *valp = IPPROTO_RAW; return 0; }
4983 #endif
4984 #ifdef IPPROTO_MAX
4985         if (memcmp(str, "MAX", 3) == 0) { *valp = IPPROTO_MAX; return 0; }
4986 #endif
4987         return -1;
4988 
4989       case 4:
4990 #ifdef IPPROTO_ICMP
4991         if (memcmp(str, "ICMP", 4) == 0) { *valp = IPPROTO_ICMP; return 0; }
4992 #endif
4993 #ifdef IPPROTO_IGMP
4994         if (memcmp(str, "IGMP", 4) == 0) { *valp = IPPROTO_IGMP; return 0; }
4995 #endif
4996 #ifdef IPPROTO_IPV6
4997         if (memcmp(str, "IPV6", 4) == 0) { *valp = IPPROTO_IPV6; return 0; }
4998 #endif
4999 #ifdef IPPROTO_NONE
5000         if (memcmp(str, "NONE", 4) == 0) { *valp = IPPROTO_NONE; return 0; }
5001 #endif
5002         return -1;
5003 
5004       case 5:
5005 #ifdef IPPROTO_HELLO
5006         if (memcmp(str, "HELLO", 5) == 0) { *valp = IPPROTO_HELLO; return 0; }
5007 #endif
5008         return -1;
5009 
5010       case 6:
5011 #ifdef IPPROTO_ICMPV6
5012         if (memcmp(str, "ICMPV6", 6) == 0) { *valp = IPPROTO_ICMPV6; return 0; }
5013 #endif
5014         return -1;
5015 
5016       case 7:
5017 #ifdef IPPROTO_DSTOPTS
5018         if (memcmp(str, "DSTOPTS", 7) == 0) { *valp = IPPROTO_DSTOPTS; return 0; }
5019 #endif
5020 #ifdef IPPROTO_HOPOPTS
5021         if (memcmp(str, "HOPOPTS", 7) == 0) { *valp = IPPROTO_HOPOPTS; return 0; }
5022 #endif
5023 #ifdef IPPROTO_ROUTING
5024         if (memcmp(str, "ROUTING", 7) == 0) { *valp = IPPROTO_ROUTING; return 0; }
5025 #endif
5026         return -1;
5027 
5028       case 8:
5029 #ifdef IPPROTO_FRAGMENT
5030         if (memcmp(str, "FRAGMENT", 8) == 0) { *valp = IPPROTO_FRAGMENT; return 0; }
5031 #endif
5032         return -1;
5033 
5034       case 10:
5035 #ifdef IPPROTO_IP
5036         if (memcmp(str, "IPPROTO_IP", 10) == 0) { *valp = IPPROTO_IP; return 0; }
5037 #endif
5038 #ifdef IPPROTO_ND
5039         if (memcmp(str, "IPPROTO_ND", 10) == 0) { *valp = IPPROTO_ND; return 0; }
5040 #endif
5041 #ifdef IPPROTO_TP
5042         if (memcmp(str, "IPPROTO_TP", 10) == 0) { *valp = IPPROTO_TP; return 0; }
5043 #endif
5044 #ifdef IPPROTO_AH
5045         if (memcmp(str, "IPPROTO_AH", 10) == 0) { *valp = IPPROTO_AH; return 0; }
5046 #endif
5047         return -1;
5048 
5049       case 11:
5050 #ifdef IPPROTO_GGP
5051         if (memcmp(str, "IPPROTO_GGP", 11) == 0) { *valp = IPPROTO_GGP; return 0; }
5052 #endif
5053 #ifdef IPPROTO_TCP
5054         if (memcmp(str, "IPPROTO_TCP", 11) == 0) { *valp = IPPROTO_TCP; return 0; }
5055 #endif
5056 #ifdef IPPROTO_EGP
5057         if (memcmp(str, "IPPROTO_EGP", 11) == 0) { *valp = IPPROTO_EGP; return 0; }
5058 #endif
5059 #ifdef IPPROTO_PUP
5060         if (memcmp(str, "IPPROTO_PUP", 11) == 0) { *valp = IPPROTO_PUP; return 0; }
5061 #endif
5062 #ifdef IPPROTO_UDP
5063         if (memcmp(str, "IPPROTO_UDP", 11) == 0) { *valp = IPPROTO_UDP; return 0; }
5064 #endif
5065 #ifdef IPPROTO_IDP
5066         if (memcmp(str, "IPPROTO_IDP", 11) == 0) { *valp = IPPROTO_IDP; return 0; }
5067 #endif
5068 #ifdef IPPROTO_XTP
5069         if (memcmp(str, "IPPROTO_XTP", 11) == 0) { *valp = IPPROTO_XTP; return 0; }
5070 #endif
5071 #ifdef IPPROTO_EON
5072         if (memcmp(str, "IPPROTO_EON", 11) == 0) { *valp = IPPROTO_EON; return 0; }
5073 #endif
5074 #ifdef IPPROTO_BIP
5075         if (memcmp(str, "IPPROTO_BIP", 11) == 0) { *valp = IPPROTO_BIP; return 0; }
5076 #endif
5077 #ifdef IPPROTO_ESP
5078         if (memcmp(str, "IPPROTO_ESP", 11) == 0) { *valp = IPPROTO_ESP; return 0; }
5079 #endif
5080 #ifdef IPPROTO_RAW
5081         if (memcmp(str, "IPPROTO_RAW", 11) == 0) { *valp = IPPROTO_RAW; return 0; }
5082 #endif
5083 #ifdef IPPROTO_MAX
5084         if (memcmp(str, "IPPROTO_MAX", 11) == 0) { *valp = IPPROTO_MAX; return 0; }
5085 #endif
5086         return -1;
5087 
5088       case 12:
5089 #ifdef IPPROTO_ICMP
5090         if (memcmp(str, "IPPROTO_ICMP", 12) == 0) { *valp = IPPROTO_ICMP; return 0; }
5091 #endif
5092 #ifdef IPPROTO_IGMP
5093         if (memcmp(str, "IPPROTO_IGMP", 12) == 0) { *valp = IPPROTO_IGMP; return 0; }
5094 #endif
5095 #ifdef IPPROTO_IPV6
5096         if (memcmp(str, "IPPROTO_IPV6", 12) == 0) { *valp = IPPROTO_IPV6; return 0; }
5097 #endif
5098 #ifdef IPPROTO_NONE
5099         if (memcmp(str, "IPPROTO_NONE", 12) == 0) { *valp = IPPROTO_NONE; return 0; }
5100 #endif
5101         return -1;
5102 
5103       case 13:
5104 #ifdef IPPROTO_HELLO
5105         if (memcmp(str, "IPPROTO_HELLO", 13) == 0) { *valp = IPPROTO_HELLO; return 0; }
5106 #endif
5107         return -1;
5108 
5109       case 14:
5110 #ifdef IPPROTO_ICMPV6
5111         if (memcmp(str, "IPPROTO_ICMPV6", 14) == 0) { *valp = IPPROTO_ICMPV6; return 0; }
5112 #endif
5113         return -1;
5114 
5115       case 15:
5116 #ifdef IPPROTO_DSTOPTS
5117         if (memcmp(str, "IPPROTO_DSTOPTS", 15) == 0) { *valp = IPPROTO_DSTOPTS; return 0; }
5118 #endif
5119 #ifdef IPPROTO_HOPOPTS
5120         if (memcmp(str, "IPPROTO_HOPOPTS", 15) == 0) { *valp = IPPROTO_HOPOPTS; return 0; }
5121 #endif
5122 #ifdef IPPROTO_ROUTING
5123         if (memcmp(str, "IPPROTO_ROUTING", 15) == 0) { *valp = IPPROTO_ROUTING; return 0; }
5124 #endif
5125         return -1;
5126 
5127       case 16:
5128 #ifdef IPPROTO_FRAGMENT
5129         if (memcmp(str, "IPPROTO_FRAGMENT", 16) == 0) { *valp = IPPROTO_FRAGMENT; return 0; }
5130 #endif
5131         return -1;
5132 
5133       default:
5134         return -1;
5135     }
5136 }
5137 
5138 
5139 int
rsock_unknown_level_to_int(const char * str,long len,int * valp)5140 rsock_unknown_level_to_int(const char *str, long len, int *valp)
5141 {
5142     switch (len) {
5143       case 6:
5144 #ifdef SOL_SOCKET
5145         if (memcmp(str, "SOCKET", 6) == 0) { *valp = SOL_SOCKET; return 0; }
5146 #endif
5147         return -1;
5148 
5149       case 10:
5150 #ifdef SOL_SOCKET
5151         if (memcmp(str, "SOL_SOCKET", 10) == 0) { *valp = SOL_SOCKET; return 0; }
5152 #endif
5153         return -1;
5154 
5155       default:
5156         return -1;
5157     }
5158 }
5159 
5160 
5161 int
rsock_ip_level_to_int(const char * str,long len,int * valp)5162 rsock_ip_level_to_int(const char *str, long len, int *valp)
5163 {
5164     switch (len) {
5165       case 2:
5166 #ifdef IPPROTO_IP
5167         if (memcmp(str, "IP", 2) == 0) { *valp = IPPROTO_IP; return 0; }
5168 #endif
5169 #ifdef IPPROTO_ND
5170         if (memcmp(str, "ND", 2) == 0) { *valp = IPPROTO_ND; return 0; }
5171 #endif
5172 #ifdef IPPROTO_TP
5173         if (memcmp(str, "TP", 2) == 0) { *valp = IPPROTO_TP; return 0; }
5174 #endif
5175 #ifdef IPPROTO_AH
5176         if (memcmp(str, "AH", 2) == 0) { *valp = IPPROTO_AH; return 0; }
5177 #endif
5178         return -1;
5179 
5180       case 3:
5181 #ifdef IPPROTO_GGP
5182         if (memcmp(str, "GGP", 3) == 0) { *valp = IPPROTO_GGP; return 0; }
5183 #endif
5184 #ifdef IPPROTO_TCP
5185         if (memcmp(str, "TCP", 3) == 0) { *valp = IPPROTO_TCP; return 0; }
5186 #endif
5187 #ifdef IPPROTO_EGP
5188         if (memcmp(str, "EGP", 3) == 0) { *valp = IPPROTO_EGP; return 0; }
5189 #endif
5190 #ifdef IPPROTO_PUP
5191         if (memcmp(str, "PUP", 3) == 0) { *valp = IPPROTO_PUP; return 0; }
5192 #endif
5193 #ifdef IPPROTO_UDP
5194         if (memcmp(str, "UDP", 3) == 0) { *valp = IPPROTO_UDP; return 0; }
5195 #endif
5196 #ifdef IPPROTO_IDP
5197         if (memcmp(str, "IDP", 3) == 0) { *valp = IPPROTO_IDP; return 0; }
5198 #endif
5199 #ifdef IPPROTO_XTP
5200         if (memcmp(str, "XTP", 3) == 0) { *valp = IPPROTO_XTP; return 0; }
5201 #endif
5202 #ifdef IPPROTO_EON
5203         if (memcmp(str, "EON", 3) == 0) { *valp = IPPROTO_EON; return 0; }
5204 #endif
5205 #ifdef IPPROTO_BIP
5206         if (memcmp(str, "BIP", 3) == 0) { *valp = IPPROTO_BIP; return 0; }
5207 #endif
5208 #ifdef IPPROTO_ESP
5209         if (memcmp(str, "ESP", 3) == 0) { *valp = IPPROTO_ESP; return 0; }
5210 #endif
5211 #ifdef IPPROTO_RAW
5212         if (memcmp(str, "RAW", 3) == 0) { *valp = IPPROTO_RAW; return 0; }
5213 #endif
5214 #ifdef IPPROTO_MAX
5215         if (memcmp(str, "MAX", 3) == 0) { *valp = IPPROTO_MAX; return 0; }
5216 #endif
5217         return -1;
5218 
5219       case 4:
5220 #ifdef IPPROTO_ICMP
5221         if (memcmp(str, "ICMP", 4) == 0) { *valp = IPPROTO_ICMP; return 0; }
5222 #endif
5223 #ifdef IPPROTO_IGMP
5224         if (memcmp(str, "IGMP", 4) == 0) { *valp = IPPROTO_IGMP; return 0; }
5225 #endif
5226 #ifdef IPPROTO_IPV6
5227         if (memcmp(str, "IPV6", 4) == 0) { *valp = IPPROTO_IPV6; return 0; }
5228 #endif
5229 #ifdef IPPROTO_NONE
5230         if (memcmp(str, "NONE", 4) == 0) { *valp = IPPROTO_NONE; return 0; }
5231 #endif
5232         return -1;
5233 
5234       case 5:
5235 #ifdef IPPROTO_HELLO
5236         if (memcmp(str, "HELLO", 5) == 0) { *valp = IPPROTO_HELLO; return 0; }
5237 #endif
5238         return -1;
5239 
5240       case 6:
5241 #ifdef SOL_SOCKET
5242         if (memcmp(str, "SOCKET", 6) == 0) { *valp = SOL_SOCKET; return 0; }
5243 #endif
5244 #ifdef IPPROTO_ICMPV6
5245         if (memcmp(str, "ICMPV6", 6) == 0) { *valp = IPPROTO_ICMPV6; return 0; }
5246 #endif
5247         return -1;
5248 
5249       case 7:
5250 #ifdef IPPROTO_DSTOPTS
5251         if (memcmp(str, "DSTOPTS", 7) == 0) { *valp = IPPROTO_DSTOPTS; return 0; }
5252 #endif
5253 #ifdef IPPROTO_HOPOPTS
5254         if (memcmp(str, "HOPOPTS", 7) == 0) { *valp = IPPROTO_HOPOPTS; return 0; }
5255 #endif
5256 #ifdef IPPROTO_ROUTING
5257         if (memcmp(str, "ROUTING", 7) == 0) { *valp = IPPROTO_ROUTING; return 0; }
5258 #endif
5259         return -1;
5260 
5261       case 8:
5262 #ifdef IPPROTO_FRAGMENT
5263         if (memcmp(str, "FRAGMENT", 8) == 0) { *valp = IPPROTO_FRAGMENT; return 0; }
5264 #endif
5265         return -1;
5266 
5267       case 10:
5268 #ifdef SOL_SOCKET
5269         if (memcmp(str, "SOL_SOCKET", 10) == 0) { *valp = SOL_SOCKET; return 0; }
5270 #endif
5271 #ifdef IPPROTO_IP
5272         if (memcmp(str, "IPPROTO_IP", 10) == 0) { *valp = IPPROTO_IP; return 0; }
5273 #endif
5274 #ifdef IPPROTO_ND
5275         if (memcmp(str, "IPPROTO_ND", 10) == 0) { *valp = IPPROTO_ND; return 0; }
5276 #endif
5277 #ifdef IPPROTO_TP
5278         if (memcmp(str, "IPPROTO_TP", 10) == 0) { *valp = IPPROTO_TP; return 0; }
5279 #endif
5280 #ifdef IPPROTO_AH
5281         if (memcmp(str, "IPPROTO_AH", 10) == 0) { *valp = IPPROTO_AH; return 0; }
5282 #endif
5283         return -1;
5284 
5285       case 11:
5286 #ifdef IPPROTO_GGP
5287         if (memcmp(str, "IPPROTO_GGP", 11) == 0) { *valp = IPPROTO_GGP; return 0; }
5288 #endif
5289 #ifdef IPPROTO_TCP
5290         if (memcmp(str, "IPPROTO_TCP", 11) == 0) { *valp = IPPROTO_TCP; return 0; }
5291 #endif
5292 #ifdef IPPROTO_EGP
5293         if (memcmp(str, "IPPROTO_EGP", 11) == 0) { *valp = IPPROTO_EGP; return 0; }
5294 #endif
5295 #ifdef IPPROTO_PUP
5296         if (memcmp(str, "IPPROTO_PUP", 11) == 0) { *valp = IPPROTO_PUP; return 0; }
5297 #endif
5298 #ifdef IPPROTO_UDP
5299         if (memcmp(str, "IPPROTO_UDP", 11) == 0) { *valp = IPPROTO_UDP; return 0; }
5300 #endif
5301 #ifdef IPPROTO_IDP
5302         if (memcmp(str, "IPPROTO_IDP", 11) == 0) { *valp = IPPROTO_IDP; return 0; }
5303 #endif
5304 #ifdef IPPROTO_XTP
5305         if (memcmp(str, "IPPROTO_XTP", 11) == 0) { *valp = IPPROTO_XTP; return 0; }
5306 #endif
5307 #ifdef IPPROTO_EON
5308         if (memcmp(str, "IPPROTO_EON", 11) == 0) { *valp = IPPROTO_EON; return 0; }
5309 #endif
5310 #ifdef IPPROTO_BIP
5311         if (memcmp(str, "IPPROTO_BIP", 11) == 0) { *valp = IPPROTO_BIP; return 0; }
5312 #endif
5313 #ifdef IPPROTO_ESP
5314         if (memcmp(str, "IPPROTO_ESP", 11) == 0) { *valp = IPPROTO_ESP; return 0; }
5315 #endif
5316 #ifdef IPPROTO_RAW
5317         if (memcmp(str, "IPPROTO_RAW", 11) == 0) { *valp = IPPROTO_RAW; return 0; }
5318 #endif
5319 #ifdef IPPROTO_MAX
5320         if (memcmp(str, "IPPROTO_MAX", 11) == 0) { *valp = IPPROTO_MAX; return 0; }
5321 #endif
5322         return -1;
5323 
5324       case 12:
5325 #ifdef IPPROTO_ICMP
5326         if (memcmp(str, "IPPROTO_ICMP", 12) == 0) { *valp = IPPROTO_ICMP; return 0; }
5327 #endif
5328 #ifdef IPPROTO_IGMP
5329         if (memcmp(str, "IPPROTO_IGMP", 12) == 0) { *valp = IPPROTO_IGMP; return 0; }
5330 #endif
5331 #ifdef IPPROTO_IPV6
5332         if (memcmp(str, "IPPROTO_IPV6", 12) == 0) { *valp = IPPROTO_IPV6; return 0; }
5333 #endif
5334 #ifdef IPPROTO_NONE
5335         if (memcmp(str, "IPPROTO_NONE", 12) == 0) { *valp = IPPROTO_NONE; return 0; }
5336 #endif
5337         return -1;
5338 
5339       case 13:
5340 #ifdef IPPROTO_HELLO
5341         if (memcmp(str, "IPPROTO_HELLO", 13) == 0) { *valp = IPPROTO_HELLO; return 0; }
5342 #endif
5343         return -1;
5344 
5345       case 14:
5346 #ifdef IPPROTO_ICMPV6
5347         if (memcmp(str, "IPPROTO_ICMPV6", 14) == 0) { *valp = IPPROTO_ICMPV6; return 0; }
5348 #endif
5349         return -1;
5350 
5351       case 15:
5352 #ifdef IPPROTO_DSTOPTS
5353         if (memcmp(str, "IPPROTO_DSTOPTS", 15) == 0) { *valp = IPPROTO_DSTOPTS; return 0; }
5354 #endif
5355 #ifdef IPPROTO_HOPOPTS
5356         if (memcmp(str, "IPPROTO_HOPOPTS", 15) == 0) { *valp = IPPROTO_HOPOPTS; return 0; }
5357 #endif
5358 #ifdef IPPROTO_ROUTING
5359         if (memcmp(str, "IPPROTO_ROUTING", 15) == 0) { *valp = IPPROTO_ROUTING; return 0; }
5360 #endif
5361         return -1;
5362 
5363       case 16:
5364 #ifdef IPPROTO_FRAGMENT
5365         if (memcmp(str, "IPPROTO_FRAGMENT", 16) == 0) { *valp = IPPROTO_FRAGMENT; return 0; }
5366 #endif
5367         return -1;
5368 
5369       default:
5370         return -1;
5371     }
5372 }
5373 
5374 
5375 int
rsock_so_optname_to_int(const char * str,long len,int * valp)5376 rsock_so_optname_to_int(const char *str, long len, int *valp)
5377 {
5378     switch (len) {
5379       case 3:
5380 #ifdef SO_NKE
5381         if (memcmp(str, "NKE", 3) == 0) { *valp = SO_NKE; return 0; }
5382 #endif
5383         return -1;
5384 
5385       case 4:
5386 #ifdef SO_TYPE
5387         if (memcmp(str, "TYPE", 4) == 0) { *valp = SO_TYPE; return 0; }
5388 #endif
5389 #ifdef SO_MARK
5390         if (memcmp(str, "MARK", 4) == 0) { *valp = SO_MARK; return 0; }
5391 #endif
5392         return -1;
5393 
5394       case 5:
5395 #ifdef SO_DEBUG
5396         if (memcmp(str, "DEBUG", 5) == 0) { *valp = SO_DEBUG; return 0; }
5397 #endif
5398 #ifdef SO_ERROR
5399         if (memcmp(str, "ERROR", 5) == 0) { *valp = SO_ERROR; return 0; }
5400 #endif
5401 #ifdef SO_NREAD
5402         if (memcmp(str, "NREAD", 5) == 0) { *valp = SO_NREAD; return 0; }
5403 #endif
5404 #ifdef SO_NOFCS
5405         if (memcmp(str, "NOFCS", 5) == 0) { *valp = SO_NOFCS; return 0; }
5406 #endif
5407         return -1;
5408 
5409       case 6:
5410 #ifdef SO_NKE
5411         if (memcmp(str, "SO_NKE", 6) == 0) { *valp = SO_NKE; return 0; }
5412 #endif
5413 #ifdef SO_SNDBUF
5414         if (memcmp(str, "SNDBUF", 6) == 0) { *valp = SO_SNDBUF; return 0; }
5415 #endif
5416 #ifdef SO_RCVBUF
5417         if (memcmp(str, "RCVBUF", 6) == 0) { *valp = SO_RCVBUF; return 0; }
5418 #endif
5419 #ifdef SO_LINGER
5420         if (memcmp(str, "LINGER", 6) == 0) { *valp = SO_LINGER; return 0; }
5421 #endif
5422 #ifdef SO_DOMAIN
5423         if (memcmp(str, "DOMAIN", 6) == 0) { *valp = SO_DOMAIN; return 0; }
5424 #endif
5425         return -1;
5426 
5427       case 7:
5428 #ifdef SO_TYPE
5429         if (memcmp(str, "SO_TYPE", 7) == 0) { *valp = SO_TYPE; return 0; }
5430 #endif
5431 #ifdef SO_MARK
5432         if (memcmp(str, "SO_MARK", 7) == 0) { *valp = SO_MARK; return 0; }
5433 #endif
5434 #ifdef SO_BINTIME
5435         if (memcmp(str, "BINTIME", 7) == 0) { *valp = SO_BINTIME; return 0; }
5436 #endif
5437 #ifdef SO_PEERSEC
5438         if (memcmp(str, "PEERSEC", 7) == 0) { *valp = SO_PEERSEC; return 0; }
5439 #endif
5440 #ifdef SO_PASSSEC
5441         if (memcmp(str, "PASSSEC", 7) == 0) { *valp = SO_PASSSEC; return 0; }
5442 #endif
5443         return -1;
5444 
5445       case 8:
5446 #ifdef SO_DEBUG
5447         if (memcmp(str, "SO_DEBUG", 8) == 0) { *valp = SO_DEBUG; return 0; }
5448 #endif
5449 #ifdef SO_ERROR
5450         if (memcmp(str, "SO_ERROR", 8) == 0) { *valp = SO_ERROR; return 0; }
5451 #endif
5452 #ifdef SO_NREAD
5453         if (memcmp(str, "SO_NREAD", 8) == 0) { *valp = SO_NREAD; return 0; }
5454 #endif
5455 #ifdef SO_NOFCS
5456         if (memcmp(str, "SO_NOFCS", 8) == 0) { *valp = SO_NOFCS; return 0; }
5457 #endif
5458 #ifdef SO_NO_CHECK
5459         if (memcmp(str, "NO_CHECK", 8) == 0) { *valp = SO_NO_CHECK; return 0; }
5460 #endif
5461 #ifdef SO_PRIORITY
5462         if (memcmp(str, "PRIORITY", 8) == 0) { *valp = SO_PRIORITY; return 0; }
5463 #endif
5464 #ifdef SO_PASSCRED
5465         if (memcmp(str, "PASSCRED", 8) == 0) { *valp = SO_PASSCRED; return 0; }
5466 #endif
5467 #ifdef SO_PEERCRED
5468         if (memcmp(str, "PEERCRED", 8) == 0) { *valp = SO_PEERCRED; return 0; }
5469 #endif
5470 #ifdef SO_RCVLOWAT
5471         if (memcmp(str, "RCVLOWAT", 8) == 0) { *valp = SO_RCVLOWAT; return 0; }
5472 #endif
5473 #ifdef SO_SNDLOWAT
5474         if (memcmp(str, "SNDLOWAT", 8) == 0) { *valp = SO_SNDLOWAT; return 0; }
5475 #endif
5476 #ifdef SO_RCVTIMEO
5477         if (memcmp(str, "RCVTIMEO", 8) == 0) { *valp = SO_RCVTIMEO; return 0; }
5478 #endif
5479 #ifdef SO_SNDTIMEO
5480         if (memcmp(str, "SNDTIMEO", 8) == 0) { *valp = SO_SNDTIMEO; return 0; }
5481 #endif
5482 #ifdef SO_WANTMORE
5483         if (memcmp(str, "WANTMORE", 8) == 0) { *valp = SO_WANTMORE; return 0; }
5484 #endif
5485 #ifdef SO_PEERNAME
5486         if (memcmp(str, "PEERNAME", 8) == 0) { *valp = SO_PEERNAME; return 0; }
5487 #endif
5488 #ifdef SO_ALLZONES
5489         if (memcmp(str, "ALLZONES", 8) == 0) { *valp = SO_ALLZONES; return 0; }
5490 #endif
5491 #ifdef SO_PROTOCOL
5492         if (memcmp(str, "PROTOCOL", 8) == 0) { *valp = SO_PROTOCOL; return 0; }
5493 #endif
5494 #ifdef SO_RXQ_OVFL
5495         if (memcmp(str, "RXQ_OVFL", 8) == 0) { *valp = SO_RXQ_OVFL; return 0; }
5496 #endif
5497 #ifdef SO_PEEK_OFF
5498         if (memcmp(str, "PEEK_OFF", 8) == 0) { *valp = SO_PEEK_OFF; return 0; }
5499 #endif
5500         return -1;
5501 
5502       case 9:
5503 #ifdef SO_SNDBUF
5504         if (memcmp(str, "SO_SNDBUF", 9) == 0) { *valp = SO_SNDBUF; return 0; }
5505 #endif
5506 #ifdef SO_RCVBUF
5507         if (memcmp(str, "SO_RCVBUF", 9) == 0) { *valp = SO_RCVBUF; return 0; }
5508 #endif
5509 #ifdef SO_LINGER
5510         if (memcmp(str, "SO_LINGER", 9) == 0) { *valp = SO_LINGER; return 0; }
5511 #endif
5512 #ifdef SO_DOMAIN
5513         if (memcmp(str, "SO_DOMAIN", 9) == 0) { *valp = SO_DOMAIN; return 0; }
5514 #endif
5515 #ifdef SO_REUSEADDR
5516         if (memcmp(str, "REUSEADDR", 9) == 0) { *valp = SO_REUSEADDR; return 0; }
5517 #endif
5518 #ifdef SO_REUSEPORT
5519         if (memcmp(str, "REUSEPORT", 9) == 0) { *valp = SO_REUSEPORT; return 0; }
5520 #endif
5521 #ifdef SO_DONTROUTE
5522         if (memcmp(str, "DONTROUTE", 9) == 0) { *valp = SO_DONTROUTE; return 0; }
5523 #endif
5524 #ifdef SO_BROADCAST
5525         if (memcmp(str, "BROADCAST", 9) == 0) { *valp = SO_BROADCAST; return 0; }
5526 #endif
5527 #ifdef SO_KEEPALIVE
5528         if (memcmp(str, "KEEPALIVE", 9) == 0) { *valp = SO_KEEPALIVE; return 0; }
5529 #endif
5530 #ifdef SO_OOBINLINE
5531         if (memcmp(str, "OOBINLINE", 9) == 0) { *valp = SO_OOBINLINE; return 0; }
5532 #endif
5533 #ifdef SO_DONTTRUNC
5534         if (memcmp(str, "DONTTRUNC", 9) == 0) { *valp = SO_DONTTRUNC; return 0; }
5535 #endif
5536 #ifdef SO_NOSIGPIPE
5537         if (memcmp(str, "NOSIGPIPE", 9) == 0) { *valp = SO_NOSIGPIPE; return 0; }
5538 #endif
5539 #ifdef SO_TIMESTAMP
5540         if (memcmp(str, "TIMESTAMP", 9) == 0) { *valp = SO_TIMESTAMP; return 0; }
5541 #endif
5542 #ifdef SO_RECVUCRED
5543         if (memcmp(str, "RECVUCRED", 9) == 0) { *valp = SO_RECVUCRED; return 0; }
5544 #endif
5545 #ifdef SO_BUSY_POLL
5546         if (memcmp(str, "BUSY_POLL", 9) == 0) { *valp = SO_BUSY_POLL; return 0; }
5547 #endif
5548         return -1;
5549 
5550       case 10:
5551 #ifdef SO_BINTIME
5552         if (memcmp(str, "SO_BINTIME", 10) == 0) { *valp = SO_BINTIME; return 0; }
5553 #endif
5554 #ifdef SO_PEERSEC
5555         if (memcmp(str, "SO_PEERSEC", 10) == 0) { *valp = SO_PEERSEC; return 0; }
5556 #endif
5557 #ifdef SO_PASSSEC
5558         if (memcmp(str, "SO_PASSSEC", 10) == 0) { *valp = SO_PASSSEC; return 0; }
5559 #endif
5560 #ifdef SO_ACCEPTCONN
5561         if (memcmp(str, "ACCEPTCONN", 10) == 0) { *valp = SO_ACCEPTCONN; return 0; }
5562 #endif
5563 #ifdef SO_GET_FILTER
5564         if (memcmp(str, "GET_FILTER", 10) == 0) { *valp = SO_GET_FILTER; return 0; }
5565 #endif
5566 #ifdef SO_MAC_EXEMPT
5567         if (memcmp(str, "MAC_EXEMPT", 10) == 0) { *valp = SO_MAC_EXEMPT; return 0; }
5568 #endif
5569         return -1;
5570 
5571       case 11:
5572 #ifdef SO_NO_CHECK
5573         if (memcmp(str, "SO_NO_CHECK", 11) == 0) { *valp = SO_NO_CHECK; return 0; }
5574 #endif
5575 #ifdef SO_PRIORITY
5576         if (memcmp(str, "SO_PRIORITY", 11) == 0) { *valp = SO_PRIORITY; return 0; }
5577 #endif
5578 #ifdef SO_PASSCRED
5579         if (memcmp(str, "SO_PASSCRED", 11) == 0) { *valp = SO_PASSCRED; return 0; }
5580 #endif
5581 #ifdef SO_PEERCRED
5582         if (memcmp(str, "SO_PEERCRED", 11) == 0) { *valp = SO_PEERCRED; return 0; }
5583 #endif
5584 #ifdef SO_RCVLOWAT
5585         if (memcmp(str, "SO_RCVLOWAT", 11) == 0) { *valp = SO_RCVLOWAT; return 0; }
5586 #endif
5587 #ifdef SO_SNDLOWAT
5588         if (memcmp(str, "SO_SNDLOWAT", 11) == 0) { *valp = SO_SNDLOWAT; return 0; }
5589 #endif
5590 #ifdef SO_RCVTIMEO
5591         if (memcmp(str, "SO_RCVTIMEO", 11) == 0) { *valp = SO_RCVTIMEO; return 0; }
5592 #endif
5593 #ifdef SO_SNDTIMEO
5594         if (memcmp(str, "SO_SNDTIMEO", 11) == 0) { *valp = SO_SNDTIMEO; return 0; }
5595 #endif
5596 #ifdef SO_WANTMORE
5597         if (memcmp(str, "SO_WANTMORE", 11) == 0) { *valp = SO_WANTMORE; return 0; }
5598 #endif
5599 #ifdef SO_PEERNAME
5600         if (memcmp(str, "SO_PEERNAME", 11) == 0) { *valp = SO_PEERNAME; return 0; }
5601 #endif
5602 #ifdef SO_ALLZONES
5603         if (memcmp(str, "SO_ALLZONES", 11) == 0) { *valp = SO_ALLZONES; return 0; }
5604 #endif
5605 #ifdef SO_PROTOCOL
5606         if (memcmp(str, "SO_PROTOCOL", 11) == 0) { *valp = SO_PROTOCOL; return 0; }
5607 #endif
5608 #ifdef SO_RXQ_OVFL
5609         if (memcmp(str, "SO_RXQ_OVFL", 11) == 0) { *valp = SO_RXQ_OVFL; return 0; }
5610 #endif
5611 #ifdef SO_PEEK_OFF
5612         if (memcmp(str, "SO_PEEK_OFF", 11) == 0) { *valp = SO_PEEK_OFF; return 0; }
5613 #endif
5614 #ifdef SO_SNDBUFFORCE
5615         if (memcmp(str, "SNDBUFFORCE", 11) == 0) { *valp = SO_SNDBUFFORCE; return 0; }
5616 #endif
5617 #ifdef SO_RCVBUFFORCE
5618         if (memcmp(str, "RCVBUFFORCE", 11) == 0) { *valp = SO_RCVBUFFORCE; return 0; }
5619 #endif
5620 #ifdef SO_USELOOPBACK
5621         if (memcmp(str, "USELOOPBACK", 11) == 0) { *valp = SO_USELOOPBACK; return 0; }
5622 #endif
5623 #ifdef SO_WANTOOBFLAG
5624         if (memcmp(str, "WANTOOBFLAG", 11) == 0) { *valp = SO_WANTOOBFLAG; return 0; }
5625 #endif
5626 #ifdef SO_TIMESTAMPNS
5627         if (memcmp(str, "TIMESTAMPNS", 11) == 0) { *valp = SO_TIMESTAMPNS; return 0; }
5628 #endif
5629 #ifdef SO_WIFI_STATUS
5630         if (memcmp(str, "WIFI_STATUS", 11) == 0) { *valp = SO_WIFI_STATUS; return 0; }
5631 #endif
5632 #ifdef SO_LOCK_FILTER
5633         if (memcmp(str, "LOCK_FILTER", 11) == 0) { *valp = SO_LOCK_FILTER; return 0; }
5634 #endif
5635         return -1;
5636 
5637       case 12:
5638 #ifdef SO_REUSEADDR
5639         if (memcmp(str, "SO_REUSEADDR", 12) == 0) { *valp = SO_REUSEADDR; return 0; }
5640 #endif
5641 #ifdef SO_REUSEPORT
5642         if (memcmp(str, "SO_REUSEPORT", 12) == 0) { *valp = SO_REUSEPORT; return 0; }
5643 #endif
5644 #ifdef SO_DONTROUTE
5645         if (memcmp(str, "SO_DONTROUTE", 12) == 0) { *valp = SO_DONTROUTE; return 0; }
5646 #endif
5647 #ifdef SO_BROADCAST
5648         if (memcmp(str, "SO_BROADCAST", 12) == 0) { *valp = SO_BROADCAST; return 0; }
5649 #endif
5650 #ifdef SO_KEEPALIVE
5651         if (memcmp(str, "SO_KEEPALIVE", 12) == 0) { *valp = SO_KEEPALIVE; return 0; }
5652 #endif
5653 #ifdef SO_OOBINLINE
5654         if (memcmp(str, "SO_OOBINLINE", 12) == 0) { *valp = SO_OOBINLINE; return 0; }
5655 #endif
5656 #ifdef SO_DONTTRUNC
5657         if (memcmp(str, "SO_DONTTRUNC", 12) == 0) { *valp = SO_DONTTRUNC; return 0; }
5658 #endif
5659 #ifdef SO_NOSIGPIPE
5660         if (memcmp(str, "SO_NOSIGPIPE", 12) == 0) { *valp = SO_NOSIGPIPE; return 0; }
5661 #endif
5662 #ifdef SO_TIMESTAMP
5663         if (memcmp(str, "SO_TIMESTAMP", 12) == 0) { *valp = SO_TIMESTAMP; return 0; }
5664 #endif
5665 #ifdef SO_RECVUCRED
5666         if (memcmp(str, "SO_RECVUCRED", 12) == 0) { *valp = SO_RECVUCRED; return 0; }
5667 #endif
5668 #ifdef SO_BUSY_POLL
5669         if (memcmp(str, "SO_BUSY_POLL", 12) == 0) { *valp = SO_BUSY_POLL; return 0; }
5670 #endif
5671 #ifdef SO_ACCEPTFILTER
5672         if (memcmp(str, "ACCEPTFILTER", 12) == 0) { *valp = SO_ACCEPTFILTER; return 0; }
5673 #endif
5674 #ifdef SO_BINDTODEVICE
5675         if (memcmp(str, "BINDTODEVICE", 12) == 0) { *valp = SO_BINDTODEVICE; return 0; }
5676 #endif
5677 #ifdef SO_TIMESTAMPING
5678         if (memcmp(str, "TIMESTAMPING", 12) == 0) { *valp = SO_TIMESTAMPING; return 0; }
5679 #endif
5680         return -1;
5681 
5682       case 13:
5683 #ifdef SO_ACCEPTCONN
5684         if (memcmp(str, "SO_ACCEPTCONN", 13) == 0) { *valp = SO_ACCEPTCONN; return 0; }
5685 #endif
5686 #ifdef SO_GET_FILTER
5687         if (memcmp(str, "SO_GET_FILTER", 13) == 0) { *valp = SO_GET_FILTER; return 0; }
5688 #endif
5689 #ifdef SO_MAC_EXEMPT
5690         if (memcmp(str, "SO_MAC_EXEMPT", 13) == 0) { *valp = SO_MAC_EXEMPT; return 0; }
5691 #endif
5692 #ifdef SO_ATTACH_FILTER
5693         if (memcmp(str, "ATTACH_FILTER", 13) == 0) { *valp = SO_ATTACH_FILTER; return 0; }
5694 #endif
5695 #ifdef SO_DETACH_FILTER
5696         if (memcmp(str, "DETACH_FILTER", 13) == 0) { *valp = SO_DETACH_FILTER; return 0; }
5697 #endif
5698         return -1;
5699 
5700       case 14:
5701 #ifdef SO_SNDBUFFORCE
5702         if (memcmp(str, "SO_SNDBUFFORCE", 14) == 0) { *valp = SO_SNDBUFFORCE; return 0; }
5703 #endif
5704 #ifdef SO_RCVBUFFORCE
5705         if (memcmp(str, "SO_RCVBUFFORCE", 14) == 0) { *valp = SO_RCVBUFFORCE; return 0; }
5706 #endif
5707 #ifdef SO_USELOOPBACK
5708         if (memcmp(str, "SO_USELOOPBACK", 14) == 0) { *valp = SO_USELOOPBACK; return 0; }
5709 #endif
5710 #ifdef SO_WANTOOBFLAG
5711         if (memcmp(str, "SO_WANTOOBFLAG", 14) == 0) { *valp = SO_WANTOOBFLAG; return 0; }
5712 #endif
5713 #ifdef SO_TIMESTAMPNS
5714         if (memcmp(str, "SO_TIMESTAMPNS", 14) == 0) { *valp = SO_TIMESTAMPNS; return 0; }
5715 #endif
5716 #ifdef SO_WIFI_STATUS
5717         if (memcmp(str, "SO_WIFI_STATUS", 14) == 0) { *valp = SO_WIFI_STATUS; return 0; }
5718 #endif
5719 #ifdef SO_LOCK_FILTER
5720         if (memcmp(str, "SO_LOCK_FILTER", 14) == 0) { *valp = SO_LOCK_FILTER; return 0; }
5721 #endif
5722 #ifdef SO_BPF_EXTENSIONS
5723         if (memcmp(str, "BPF_EXTENSIONS", 14) == 0) { *valp = SO_BPF_EXTENSIONS; return 0; }
5724 #endif
5725         return -1;
5726 
5727       case 15:
5728 #ifdef SO_ACCEPTFILTER
5729         if (memcmp(str, "SO_ACCEPTFILTER", 15) == 0) { *valp = SO_ACCEPTFILTER; return 0; }
5730 #endif
5731 #ifdef SO_BINDTODEVICE
5732         if (memcmp(str, "SO_BINDTODEVICE", 15) == 0) { *valp = SO_BINDTODEVICE; return 0; }
5733 #endif
5734 #ifdef SO_TIMESTAMPING
5735         if (memcmp(str, "SO_TIMESTAMPING", 15) == 0) { *valp = SO_TIMESTAMPING; return 0; }
5736 #endif
5737 #ifdef SO_MAX_PACING_RATE
5738         if (memcmp(str, "MAX_PACING_RATE", 15) == 0) { *valp = SO_MAX_PACING_RATE; return 0; }
5739 #endif
5740         return -1;
5741 
5742       case 16:
5743 #ifdef SO_ATTACH_FILTER
5744         if (memcmp(str, "SO_ATTACH_FILTER", 16) == 0) { *valp = SO_ATTACH_FILTER; return 0; }
5745 #endif
5746 #ifdef SO_DETACH_FILTER
5747         if (memcmp(str, "SO_DETACH_FILTER", 16) == 0) { *valp = SO_DETACH_FILTER; return 0; }
5748 #endif
5749 #ifdef SO_SELECT_ERR_QUEUE
5750         if (memcmp(str, "SELECT_ERR_QUEUE", 16) == 0) { *valp = SO_SELECT_ERR_QUEUE; return 0; }
5751 #endif
5752         return -1;
5753 
5754       case 17:
5755 #ifdef SO_BPF_EXTENSIONS
5756         if (memcmp(str, "SO_BPF_EXTENSIONS", 17) == 0) { *valp = SO_BPF_EXTENSIONS; return 0; }
5757 #endif
5758         return -1;
5759 
5760       case 18:
5761 #ifdef SO_MAX_PACING_RATE
5762         if (memcmp(str, "SO_MAX_PACING_RATE", 18) == 0) { *valp = SO_MAX_PACING_RATE; return 0; }
5763 #endif
5764         return -1;
5765 
5766       case 19:
5767 #ifdef SO_SELECT_ERR_QUEUE
5768         if (memcmp(str, "SO_SELECT_ERR_QUEUE", 19) == 0) { *valp = SO_SELECT_ERR_QUEUE; return 0; }
5769 #endif
5770         return -1;
5771 
5772       case 23:
5773 #ifdef SO_SECURITY_AUTHENTICATION
5774         if (memcmp(str, "SECURITY_AUTHENTICATION", 23) == 0) { *valp = SO_SECURITY_AUTHENTICATION; return 0; }
5775 #endif
5776         return -1;
5777 
5778       case 26:
5779 #ifdef SO_SECURITY_AUTHENTICATION
5780         if (memcmp(str, "SO_SECURITY_AUTHENTICATION", 26) == 0) { *valp = SO_SECURITY_AUTHENTICATION; return 0; }
5781 #endif
5782         return -1;
5783 
5784       case 27:
5785 #ifdef SO_SECURITY_ENCRYPTION_NETWORK
5786         if (memcmp(str, "SECURITY_ENCRYPTION_NETWORK", 27) == 0) { *valp = SO_SECURITY_ENCRYPTION_NETWORK; return 0; }
5787 #endif
5788         return -1;
5789 
5790       case 29:
5791 #ifdef SO_SECURITY_ENCRYPTION_TRANSPORT
5792         if (memcmp(str, "SECURITY_ENCRYPTION_TRANSPORT", 29) == 0) { *valp = SO_SECURITY_ENCRYPTION_TRANSPORT; return 0; }
5793 #endif
5794         return -1;
5795 
5796       case 30:
5797 #ifdef SO_SECURITY_ENCRYPTION_NETWORK
5798         if (memcmp(str, "SO_SECURITY_ENCRYPTION_NETWORK", 30) == 0) { *valp = SO_SECURITY_ENCRYPTION_NETWORK; return 0; }
5799 #endif
5800         return -1;
5801 
5802       case 32:
5803 #ifdef SO_SECURITY_ENCRYPTION_TRANSPORT
5804         if (memcmp(str, "SO_SECURITY_ENCRYPTION_TRANSPORT", 32) == 0) { *valp = SO_SECURITY_ENCRYPTION_TRANSPORT; return 0; }
5805 #endif
5806         return -1;
5807 
5808       default:
5809         return -1;
5810     }
5811 }
5812 
5813 
5814 int
rsock_ip_optname_to_int(const char * str,long len,int * valp)5815 rsock_ip_optname_to_int(const char *str, long len, int *valp)
5816 {
5817     switch (len) {
5818       case 3:
5819 #ifdef IP_TOS
5820         if (memcmp(str, "TOS", 3) == 0) { *valp = IP_TOS; return 0; }
5821 #endif
5822 #ifdef IP_TTL
5823         if (memcmp(str, "TTL", 3) == 0) { *valp = IP_TTL; return 0; }
5824 #endif
5825 #ifdef IP_MTU
5826         if (memcmp(str, "MTU", 3) == 0) { *valp = IP_MTU; return 0; }
5827 #endif
5828         return -1;
5829 
5830       case 6:
5831 #ifdef IP_TOS
5832         if (memcmp(str, "IP_TOS", 6) == 0) { *valp = IP_TOS; return 0; }
5833 #endif
5834 #ifdef IP_TTL
5835         if (memcmp(str, "IP_TTL", 6) == 0) { *valp = IP_TTL; return 0; }
5836 #endif
5837 #ifdef IP_MTU
5838         if (memcmp(str, "IP_MTU", 6) == 0) { *valp = IP_MTU; return 0; }
5839 #endif
5840 #ifdef IP_MINTTL
5841         if (memcmp(str, "MINTTL", 6) == 0) { *valp = IP_MINTTL; return 0; }
5842 #endif
5843 #ifdef IP_RECVIF
5844         if (memcmp(str, "RECVIF", 6) == 0) { *valp = IP_RECVIF; return 0; }
5845 #endif
5846         return -1;
5847 
5848       case 7:
5849 #ifdef IP_OPTIONS
5850         if (memcmp(str, "OPTIONS", 7) == 0) { *valp = IP_OPTIONS; return 0; }
5851 #endif
5852 #ifdef IP_HDRINCL
5853         if (memcmp(str, "HDRINCL", 7) == 0) { *valp = IP_HDRINCL; return 0; }
5854 #endif
5855 #ifdef IP_RETOPTS
5856         if (memcmp(str, "RETOPTS", 7) == 0) { *valp = IP_RETOPTS; return 0; }
5857 #endif
5858 #ifdef IP_RECVTTL
5859         if (memcmp(str, "RECVTTL", 7) == 0) { *valp = IP_RECVTTL; return 0; }
5860 #endif
5861 #ifdef IP_PKTINFO
5862         if (memcmp(str, "PKTINFO", 7) == 0) { *valp = IP_PKTINFO; return 0; }
5863 #endif
5864 #ifdef IP_RECVERR
5865         if (memcmp(str, "RECVERR", 7) == 0) { *valp = IP_RECVERR; return 0; }
5866 #endif
5867 #ifdef IP_RECVTOS
5868         if (memcmp(str, "RECVTOS", 7) == 0) { *valp = IP_RECVTOS; return 0; }
5869 #endif
5870 #ifdef IP_PASSSEC
5871         if (memcmp(str, "PASSSEC", 7) == 0) { *valp = IP_PASSSEC; return 0; }
5872 #endif
5873         return -1;
5874 
5875       case 8:
5876 #ifdef IP_RECVOPTS
5877         if (memcmp(str, "RECVOPTS", 8) == 0) { *valp = IP_RECVOPTS; return 0; }
5878 #endif
5879 #ifdef IP_DONTFRAG
5880         if (memcmp(str, "DONTFRAG", 8) == 0) { *valp = IP_DONTFRAG; return 0; }
5881 #endif
5882 #ifdef IP_RECVSLLA
5883         if (memcmp(str, "RECVSLLA", 8) == 0) { *valp = IP_RECVSLLA; return 0; }
5884 #endif
5885 #ifdef IP_FREEBIND
5886         if (memcmp(str, "FREEBIND", 8) == 0) { *valp = IP_FREEBIND; return 0; }
5887 #endif
5888 #ifdef IP_MSFILTER
5889         if (memcmp(str, "MSFILTER", 8) == 0) { *valp = IP_MSFILTER; return 0; }
5890 #endif
5891         return -1;
5892 
5893       case 9:
5894 #ifdef IP_MINTTL
5895         if (memcmp(str, "IP_MINTTL", 9) == 0) { *valp = IP_MINTTL; return 0; }
5896 #endif
5897 #ifdef IP_RECVIF
5898         if (memcmp(str, "IP_RECVIF", 9) == 0) { *valp = IP_RECVIF; return 0; }
5899 #endif
5900 #ifdef IP_ONESBCAST
5901         if (memcmp(str, "ONESBCAST", 9) == 0) { *valp = IP_ONESBCAST; return 0; }
5902 #endif
5903 #ifdef IP_PORTRANGE
5904         if (memcmp(str, "PORTRANGE", 9) == 0) { *valp = IP_PORTRANGE; return 0; }
5905 #endif
5906         return -1;
5907 
5908       case 10:
5909 #ifdef IP_OPTIONS
5910         if (memcmp(str, "IP_OPTIONS", 10) == 0) { *valp = IP_OPTIONS; return 0; }
5911 #endif
5912 #ifdef IP_HDRINCL
5913         if (memcmp(str, "IP_HDRINCL", 10) == 0) { *valp = IP_HDRINCL; return 0; }
5914 #endif
5915 #ifdef IP_RETOPTS
5916         if (memcmp(str, "IP_RETOPTS", 10) == 0) { *valp = IP_RETOPTS; return 0; }
5917 #endif
5918 #ifdef IP_RECVTTL
5919         if (memcmp(str, "IP_RECVTTL", 10) == 0) { *valp = IP_RECVTTL; return 0; }
5920 #endif
5921 #ifdef IP_PKTINFO
5922         if (memcmp(str, "IP_PKTINFO", 10) == 0) { *valp = IP_PKTINFO; return 0; }
5923 #endif
5924 #ifdef IP_RECVERR
5925         if (memcmp(str, "IP_RECVERR", 10) == 0) { *valp = IP_RECVERR; return 0; }
5926 #endif
5927 #ifdef IP_RECVTOS
5928         if (memcmp(str, "IP_RECVTOS", 10) == 0) { *valp = IP_RECVTOS; return 0; }
5929 #endif
5930 #ifdef IP_PASSSEC
5931         if (memcmp(str, "IP_PASSSEC", 10) == 0) { *valp = IP_PASSSEC; return 0; }
5932 #endif
5933 #ifdef IP_PKTOPTIONS
5934         if (memcmp(str, "PKTOPTIONS", 10) == 0) { *valp = IP_PKTOPTIONS; return 0; }
5935 #endif
5936         return -1;
5937 
5938       case 11:
5939 #ifdef IP_RECVOPTS
5940         if (memcmp(str, "IP_RECVOPTS", 11) == 0) { *valp = IP_RECVOPTS; return 0; }
5941 #endif
5942 #ifdef IP_DONTFRAG
5943         if (memcmp(str, "IP_DONTFRAG", 11) == 0) { *valp = IP_DONTFRAG; return 0; }
5944 #endif
5945 #ifdef IP_RECVSLLA
5946         if (memcmp(str, "IP_RECVSLLA", 11) == 0) { *valp = IP_RECVSLLA; return 0; }
5947 #endif
5948 #ifdef IP_FREEBIND
5949         if (memcmp(str, "IP_FREEBIND", 11) == 0) { *valp = IP_FREEBIND; return 0; }
5950 #endif
5951 #ifdef IP_MSFILTER
5952         if (memcmp(str, "IP_MSFILTER", 11) == 0) { *valp = IP_MSFILTER; return 0; }
5953 #endif
5954 #ifdef IP_RECVRETOPTS
5955         if (memcmp(str, "RECVRETOPTS", 11) == 0) { *valp = IP_RECVRETOPTS; return 0; }
5956 #endif
5957 #ifdef IP_RECVDSTADDR
5958         if (memcmp(str, "RECVDSTADDR", 11) == 0) { *valp = IP_RECVDSTADDR; return 0; }
5959 #endif
5960 #ifdef IP_SENDSRCADDR
5961         if (memcmp(str, "SENDSRCADDR", 11) == 0) { *valp = IP_SENDSRCADDR; return 0; }
5962 #endif
5963 #ifdef IP_XFRM_POLICY
5964         if (memcmp(str, "XFRM_POLICY", 11) == 0) { *valp = IP_XFRM_POLICY; return 0; }
5965 #endif
5966 #ifdef IP_TRANSPARENT
5967         if (memcmp(str, "TRANSPARENT", 11) == 0) { *valp = IP_TRANSPARENT; return 0; }
5968 #endif
5969 #ifdef IP_PMTUDISC_DO
5970         if (memcmp(str, "PMTUDISC_DO", 11) == 0) { *valp = IP_PMTUDISC_DO; return 0; }
5971 #endif
5972         return -1;
5973 
5974       case 12:
5975 #ifdef IP_ONESBCAST
5976         if (memcmp(str, "IP_ONESBCAST", 12) == 0) { *valp = IP_ONESBCAST; return 0; }
5977 #endif
5978 #ifdef IP_PORTRANGE
5979         if (memcmp(str, "IP_PORTRANGE", 12) == 0) { *valp = IP_PORTRANGE; return 0; }
5980 #endif
5981 #ifdef IP_MULTICAST_IF
5982         if (memcmp(str, "MULTICAST_IF", 12) == 0) { *valp = IP_MULTICAST_IF; return 0; }
5983 #endif
5984 #ifdef IP_ROUTER_ALERT
5985         if (memcmp(str, "ROUTER_ALERT", 12) == 0) { *valp = IP_ROUTER_ALERT; return 0; }
5986 #endif
5987 #ifdef IP_MTU_DISCOVER
5988         if (memcmp(str, "MTU_DISCOVER", 12) == 0) { *valp = IP_MTU_DISCOVER; return 0; }
5989 #endif
5990 #ifdef IP_IPSEC_POLICY
5991         if (memcmp(str, "IPSEC_POLICY", 12) == 0) { *valp = IP_IPSEC_POLICY; return 0; }
5992 #endif
5993 #ifdef IP_BLOCK_SOURCE
5994         if (memcmp(str, "BLOCK_SOURCE", 12) == 0) { *valp = IP_BLOCK_SOURCE; return 0; }
5995 #endif
5996         return -1;
5997 
5998       case 13:
5999 #ifdef IP_PKTOPTIONS
6000         if (memcmp(str, "IP_PKTOPTIONS", 13) == 0) { *valp = IP_PKTOPTIONS; return 0; }
6001 #endif
6002 #ifdef IP_MULTICAST_TTL
6003         if (memcmp(str, "MULTICAST_TTL", 13) == 0) { *valp = IP_MULTICAST_TTL; return 0; }
6004 #endif
6005 #ifdef IP_PMTUDISC_DONT
6006         if (memcmp(str, "PMTUDISC_DONT", 13) == 0) { *valp = IP_PMTUDISC_DONT; return 0; }
6007 #endif
6008 #ifdef IP_PMTUDISC_WANT
6009         if (memcmp(str, "PMTUDISC_WANT", 13) == 0) { *valp = IP_PMTUDISC_WANT; return 0; }
6010 #endif
6011         return -1;
6012 
6013       case 14:
6014 #ifdef IP_RECVRETOPTS
6015         if (memcmp(str, "IP_RECVRETOPTS", 14) == 0) { *valp = IP_RECVRETOPTS; return 0; }
6016 #endif
6017 #ifdef IP_RECVDSTADDR
6018         if (memcmp(str, "IP_RECVDSTADDR", 14) == 0) { *valp = IP_RECVDSTADDR; return 0; }
6019 #endif
6020 #ifdef IP_SENDSRCADDR
6021         if (memcmp(str, "IP_SENDSRCADDR", 14) == 0) { *valp = IP_SENDSRCADDR; return 0; }
6022 #endif
6023 #ifdef IP_XFRM_POLICY
6024         if (memcmp(str, "IP_XFRM_POLICY", 14) == 0) { *valp = IP_XFRM_POLICY; return 0; }
6025 #endif
6026 #ifdef IP_TRANSPARENT
6027         if (memcmp(str, "IP_TRANSPARENT", 14) == 0) { *valp = IP_TRANSPARENT; return 0; }
6028 #endif
6029 #ifdef IP_PMTUDISC_DO
6030         if (memcmp(str, "IP_PMTUDISC_DO", 14) == 0) { *valp = IP_PMTUDISC_DO; return 0; }
6031 #endif
6032 #ifdef IP_MULTICAST_LOOP
6033         if (memcmp(str, "MULTICAST_LOOP", 14) == 0) { *valp = IP_MULTICAST_LOOP; return 0; }
6034 #endif
6035 #ifdef IP_ADD_MEMBERSHIP
6036         if (memcmp(str, "ADD_MEMBERSHIP", 14) == 0) { *valp = IP_ADD_MEMBERSHIP; return 0; }
6037 #endif
6038 #ifdef IP_UNBLOCK_SOURCE
6039         if (memcmp(str, "UNBLOCK_SOURCE", 14) == 0) { *valp = IP_UNBLOCK_SOURCE; return 0; }
6040 #endif
6041         return -1;
6042 
6043       case 15:
6044 #ifdef IP_MULTICAST_IF
6045         if (memcmp(str, "IP_MULTICAST_IF", 15) == 0) { *valp = IP_MULTICAST_IF; return 0; }
6046 #endif
6047 #ifdef IP_ROUTER_ALERT
6048         if (memcmp(str, "IP_ROUTER_ALERT", 15) == 0) { *valp = IP_ROUTER_ALERT; return 0; }
6049 #endif
6050 #ifdef IP_MTU_DISCOVER
6051         if (memcmp(str, "IP_MTU_DISCOVER", 15) == 0) { *valp = IP_MTU_DISCOVER; return 0; }
6052 #endif
6053 #ifdef IP_IPSEC_POLICY
6054         if (memcmp(str, "IP_IPSEC_POLICY", 15) == 0) { *valp = IP_IPSEC_POLICY; return 0; }
6055 #endif
6056 #ifdef IP_BLOCK_SOURCE
6057         if (memcmp(str, "IP_BLOCK_SOURCE", 15) == 0) { *valp = IP_BLOCK_SOURCE; return 0; }
6058 #endif
6059 #ifdef IP_DROP_MEMBERSHIP
6060         if (memcmp(str, "DROP_MEMBERSHIP", 15) == 0) { *valp = IP_DROP_MEMBERSHIP; return 0; }
6061 #endif
6062 #ifdef IP_MAX_MEMBERSHIPS
6063         if (memcmp(str, "MAX_MEMBERSHIPS", 15) == 0) { *valp = IP_MAX_MEMBERSHIPS; return 0; }
6064 #endif
6065         return -1;
6066 
6067       case 16:
6068 #ifdef IP_MULTICAST_TTL
6069         if (memcmp(str, "IP_MULTICAST_TTL", 16) == 0) { *valp = IP_MULTICAST_TTL; return 0; }
6070 #endif
6071 #ifdef IP_PMTUDISC_DONT
6072         if (memcmp(str, "IP_PMTUDISC_DONT", 16) == 0) { *valp = IP_PMTUDISC_DONT; return 0; }
6073 #endif
6074 #ifdef IP_PMTUDISC_WANT
6075         if (memcmp(str, "IP_PMTUDISC_WANT", 16) == 0) { *valp = IP_PMTUDISC_WANT; return 0; }
6076 #endif
6077         return -1;
6078 
6079       case 17:
6080 #ifdef IP_MULTICAST_LOOP
6081         if (memcmp(str, "IP_MULTICAST_LOOP", 17) == 0) { *valp = IP_MULTICAST_LOOP; return 0; }
6082 #endif
6083 #ifdef IP_ADD_MEMBERSHIP
6084         if (memcmp(str, "IP_ADD_MEMBERSHIP", 17) == 0) { *valp = IP_ADD_MEMBERSHIP; return 0; }
6085 #endif
6086 #ifdef IP_UNBLOCK_SOURCE
6087         if (memcmp(str, "IP_UNBLOCK_SOURCE", 17) == 0) { *valp = IP_UNBLOCK_SOURCE; return 0; }
6088 #endif
6089         return -1;
6090 
6091       case 18:
6092 #ifdef IP_DROP_MEMBERSHIP
6093         if (memcmp(str, "IP_DROP_MEMBERSHIP", 18) == 0) { *valp = IP_DROP_MEMBERSHIP; return 0; }
6094 #endif
6095 #ifdef IP_MAX_MEMBERSHIPS
6096         if (memcmp(str, "IP_MAX_MEMBERSHIPS", 18) == 0) { *valp = IP_MAX_MEMBERSHIPS; return 0; }
6097 #endif
6098         return -1;
6099 
6100       case 21:
6101 #ifdef IP_DEFAULT_MULTICAST_TTL
6102         if (memcmp(str, "DEFAULT_MULTICAST_TTL", 21) == 0) { *valp = IP_DEFAULT_MULTICAST_TTL; return 0; }
6103 #endif
6104 #ifdef IP_ADD_SOURCE_MEMBERSHIP
6105         if (memcmp(str, "ADD_SOURCE_MEMBERSHIP", 21) == 0) { *valp = IP_ADD_SOURCE_MEMBERSHIP; return 0; }
6106 #endif
6107         return -1;
6108 
6109       case 22:
6110 #ifdef IP_DEFAULT_MULTICAST_LOOP
6111         if (memcmp(str, "DEFAULT_MULTICAST_LOOP", 22) == 0) { *valp = IP_DEFAULT_MULTICAST_LOOP; return 0; }
6112 #endif
6113 #ifdef IP_DROP_SOURCE_MEMBERSHIP
6114         if (memcmp(str, "DROP_SOURCE_MEMBERSHIP", 22) == 0) { *valp = IP_DROP_SOURCE_MEMBERSHIP; return 0; }
6115 #endif
6116         return -1;
6117 
6118       case 24:
6119 #ifdef IP_DEFAULT_MULTICAST_TTL
6120         if (memcmp(str, "IP_DEFAULT_MULTICAST_TTL", 24) == 0) { *valp = IP_DEFAULT_MULTICAST_TTL; return 0; }
6121 #endif
6122 #ifdef IP_ADD_SOURCE_MEMBERSHIP
6123         if (memcmp(str, "IP_ADD_SOURCE_MEMBERSHIP", 24) == 0) { *valp = IP_ADD_SOURCE_MEMBERSHIP; return 0; }
6124 #endif
6125         return -1;
6126 
6127       case 25:
6128 #ifdef IP_DEFAULT_MULTICAST_LOOP
6129         if (memcmp(str, "IP_DEFAULT_MULTICAST_LOOP", 25) == 0) { *valp = IP_DEFAULT_MULTICAST_LOOP; return 0; }
6130 #endif
6131 #ifdef IP_DROP_SOURCE_MEMBERSHIP
6132         if (memcmp(str, "IP_DROP_SOURCE_MEMBERSHIP", 25) == 0) { *valp = IP_DROP_SOURCE_MEMBERSHIP; return 0; }
6133 #endif
6134         return -1;
6135 
6136       default:
6137         return -1;
6138     }
6139 }
6140 
6141 
6142 #ifdef IPPROTO_IPV6
6143 int
rsock_ipv6_optname_to_int(const char * str,long len,int * valp)6144 rsock_ipv6_optname_to_int(const char *str, long len, int *valp)
6145 {
6146     switch (len) {
6147       case 5:
6148 #ifdef IPV6_RTHDR
6149         if (memcmp(str, "RTHDR", 5) == 0) { *valp = IPV6_RTHDR; return 0; }
6150 #endif
6151         return -1;
6152 
6153       case 6:
6154 #ifdef IPV6_V6ONLY
6155         if (memcmp(str, "V6ONLY", 6) == 0) { *valp = IPV6_V6ONLY; return 0; }
6156 #endif
6157 #ifdef IPV6_TCLASS
6158         if (memcmp(str, "TCLASS", 6) == 0) { *valp = IPV6_TCLASS; return 0; }
6159 #endif
6160         return -1;
6161 
6162       case 7:
6163 #ifdef IPV6_DSTOPTS
6164         if (memcmp(str, "DSTOPTS", 7) == 0) { *valp = IPV6_DSTOPTS; return 0; }
6165 #endif
6166 #ifdef IPV6_HOPOPTS
6167         if (memcmp(str, "HOPOPTS", 7) == 0) { *valp = IPV6_HOPOPTS; return 0; }
6168 #endif
6169 #ifdef IPV6_NEXTHOP
6170         if (memcmp(str, "NEXTHOP", 7) == 0) { *valp = IPV6_NEXTHOP; return 0; }
6171 #endif
6172 #ifdef IPV6_PATHMTU
6173         if (memcmp(str, "PATHMTU", 7) == 0) { *valp = IPV6_PATHMTU; return 0; }
6174 #endif
6175 #ifdef IPV6_PKTINFO
6176         if (memcmp(str, "PKTINFO", 7) == 0) { *valp = IPV6_PKTINFO; return 0; }
6177 #endif
6178         return -1;
6179 
6180       case 8:
6181 #ifdef IPV6_CHECKSUM
6182         if (memcmp(str, "CHECKSUM", 8) == 0) { *valp = IPV6_CHECKSUM; return 0; }
6183 #endif
6184 #ifdef IPV6_DONTFRAG
6185         if (memcmp(str, "DONTFRAG", 8) == 0) { *valp = IPV6_DONTFRAG; return 0; }
6186 #endif
6187 #ifdef IPV6_HOPLIMIT
6188         if (memcmp(str, "HOPLIMIT", 8) == 0) { *valp = IPV6_HOPLIMIT; return 0; }
6189 #endif
6190         return -1;
6191 
6192       case 9:
6193 #ifdef IPV6_RECVRTHDR
6194         if (memcmp(str, "RECVRTHDR", 9) == 0) { *valp = IPV6_RECVRTHDR; return 0; }
6195 #endif
6196         return -1;
6197 
6198       case 10:
6199 #ifdef IPV6_RTHDR
6200         if (memcmp(str, "IPV6_RTHDR", 10) == 0) { *valp = IPV6_RTHDR; return 0; }
6201 #endif
6202 #ifdef IPV6_JOIN_GROUP
6203         if (memcmp(str, "JOIN_GROUP", 10) == 0) { *valp = IPV6_JOIN_GROUP; return 0; }
6204 #endif
6205 #ifdef IPV6_RECVTCLASS
6206         if (memcmp(str, "RECVTCLASS", 10) == 0) { *valp = IPV6_RECVTCLASS; return 0; }
6207 #endif
6208         return -1;
6209 
6210       case 11:
6211 #ifdef IPV6_V6ONLY
6212         if (memcmp(str, "IPV6_V6ONLY", 11) == 0) { *valp = IPV6_V6ONLY; return 0; }
6213 #endif
6214 #ifdef IPV6_TCLASS
6215         if (memcmp(str, "IPV6_TCLASS", 11) == 0) { *valp = IPV6_TCLASS; return 0; }
6216 #endif
6217 #ifdef IPV6_LEAVE_GROUP
6218         if (memcmp(str, "LEAVE_GROUP", 11) == 0) { *valp = IPV6_LEAVE_GROUP; return 0; }
6219 #endif
6220 #ifdef IPV6_RECVDSTOPTS
6221         if (memcmp(str, "RECVDSTOPTS", 11) == 0) { *valp = IPV6_RECVDSTOPTS; return 0; }
6222 #endif
6223 #ifdef IPV6_RECVHOPOPTS
6224         if (memcmp(str, "RECVHOPOPTS", 11) == 0) { *valp = IPV6_RECVHOPOPTS; return 0; }
6225 #endif
6226 #ifdef IPV6_RECVPKTINFO
6227         if (memcmp(str, "RECVPKTINFO", 11) == 0) { *valp = IPV6_RECVPKTINFO; return 0; }
6228 #endif
6229 #ifdef IPV6_RECVPATHMTU
6230         if (memcmp(str, "RECVPATHMTU", 11) == 0) { *valp = IPV6_RECVPATHMTU; return 0; }
6231 #endif
6232 #ifdef IPV6_USE_MIN_MTU
6233         if (memcmp(str, "USE_MIN_MTU", 11) == 0) { *valp = IPV6_USE_MIN_MTU; return 0; }
6234 #endif
6235         return -1;
6236 
6237       case 12:
6238 #ifdef IPV6_DSTOPTS
6239         if (memcmp(str, "IPV6_DSTOPTS", 12) == 0) { *valp = IPV6_DSTOPTS; return 0; }
6240 #endif
6241 #ifdef IPV6_HOPOPTS
6242         if (memcmp(str, "IPV6_HOPOPTS", 12) == 0) { *valp = IPV6_HOPOPTS; return 0; }
6243 #endif
6244 #ifdef IPV6_NEXTHOP
6245         if (memcmp(str, "IPV6_NEXTHOP", 12) == 0) { *valp = IPV6_NEXTHOP; return 0; }
6246 #endif
6247 #ifdef IPV6_PATHMTU
6248         if (memcmp(str, "IPV6_PATHMTU", 12) == 0) { *valp = IPV6_PATHMTU; return 0; }
6249 #endif
6250 #ifdef IPV6_PKTINFO
6251         if (memcmp(str, "IPV6_PKTINFO", 12) == 0) { *valp = IPV6_PKTINFO; return 0; }
6252 #endif
6253 #ifdef IPV6_MULTICAST_IF
6254         if (memcmp(str, "MULTICAST_IF", 12) == 0) { *valp = IPV6_MULTICAST_IF; return 0; }
6255 #endif
6256 #ifdef IPV6_UNICAST_HOPS
6257         if (memcmp(str, "UNICAST_HOPS", 12) == 0) { *valp = IPV6_UNICAST_HOPS; return 0; }
6258 #endif
6259 #ifdef IPV6_RECVHOPLIMIT
6260         if (memcmp(str, "RECVHOPLIMIT", 12) == 0) { *valp = IPV6_RECVHOPLIMIT; return 0; }
6261 #endif
6262 #ifdef IPV6_RTHDRDSTOPTS
6263         if (memcmp(str, "RTHDRDSTOPTS", 12) == 0) { *valp = IPV6_RTHDRDSTOPTS; return 0; }
6264 #endif
6265 #ifdef IPV6_RTHDR_TYPE_0
6266         if (memcmp(str, "RTHDR_TYPE_0", 12) == 0) { *valp = IPV6_RTHDR_TYPE_0; return 0; }
6267 #endif
6268         return -1;
6269 
6270       case 13:
6271 #ifdef IPV6_CHECKSUM
6272         if (memcmp(str, "IPV6_CHECKSUM", 13) == 0) { *valp = IPV6_CHECKSUM; return 0; }
6273 #endif
6274 #ifdef IPV6_DONTFRAG
6275         if (memcmp(str, "IPV6_DONTFRAG", 13) == 0) { *valp = IPV6_DONTFRAG; return 0; }
6276 #endif
6277 #ifdef IPV6_HOPLIMIT
6278         if (memcmp(str, "IPV6_HOPLIMIT", 13) == 0) { *valp = IPV6_HOPLIMIT; return 0; }
6279 #endif
6280         return -1;
6281 
6282       case 14:
6283 #ifdef IPV6_RECVRTHDR
6284         if (memcmp(str, "IPV6_RECVRTHDR", 14) == 0) { *valp = IPV6_RECVRTHDR; return 0; }
6285 #endif
6286 #ifdef IPV6_MULTICAST_HOPS
6287         if (memcmp(str, "MULTICAST_HOPS", 14) == 0) { *valp = IPV6_MULTICAST_HOPS; return 0; }
6288 #endif
6289 #ifdef IPV6_MULTICAST_LOOP
6290         if (memcmp(str, "MULTICAST_LOOP", 14) == 0) { *valp = IPV6_MULTICAST_LOOP; return 0; }
6291 #endif
6292         return -1;
6293 
6294       case 15:
6295 #ifdef IPV6_JOIN_GROUP
6296         if (memcmp(str, "IPV6_JOIN_GROUP", 15) == 0) { *valp = IPV6_JOIN_GROUP; return 0; }
6297 #endif
6298 #ifdef IPV6_RECVTCLASS
6299         if (memcmp(str, "IPV6_RECVTCLASS", 15) == 0) { *valp = IPV6_RECVTCLASS; return 0; }
6300 #endif
6301         return -1;
6302 
6303       case 16:
6304 #ifdef IPV6_LEAVE_GROUP
6305         if (memcmp(str, "IPV6_LEAVE_GROUP", 16) == 0) { *valp = IPV6_LEAVE_GROUP; return 0; }
6306 #endif
6307 #ifdef IPV6_RECVDSTOPTS
6308         if (memcmp(str, "IPV6_RECVDSTOPTS", 16) == 0) { *valp = IPV6_RECVDSTOPTS; return 0; }
6309 #endif
6310 #ifdef IPV6_RECVHOPOPTS
6311         if (memcmp(str, "IPV6_RECVHOPOPTS", 16) == 0) { *valp = IPV6_RECVHOPOPTS; return 0; }
6312 #endif
6313 #ifdef IPV6_RECVPKTINFO
6314         if (memcmp(str, "IPV6_RECVPKTINFO", 16) == 0) { *valp = IPV6_RECVPKTINFO; return 0; }
6315 #endif
6316 #ifdef IPV6_RECVPATHMTU
6317         if (memcmp(str, "IPV6_RECVPATHMTU", 16) == 0) { *valp = IPV6_RECVPATHMTU; return 0; }
6318 #endif
6319 #ifdef IPV6_USE_MIN_MTU
6320         if (memcmp(str, "IPV6_USE_MIN_MTU", 16) == 0) { *valp = IPV6_USE_MIN_MTU; return 0; }
6321 #endif
6322         return -1;
6323 
6324       case 17:
6325 #ifdef IPV6_MULTICAST_IF
6326         if (memcmp(str, "IPV6_MULTICAST_IF", 17) == 0) { *valp = IPV6_MULTICAST_IF; return 0; }
6327 #endif
6328 #ifdef IPV6_UNICAST_HOPS
6329         if (memcmp(str, "IPV6_UNICAST_HOPS", 17) == 0) { *valp = IPV6_UNICAST_HOPS; return 0; }
6330 #endif
6331 #ifdef IPV6_RECVHOPLIMIT
6332         if (memcmp(str, "IPV6_RECVHOPLIMIT", 17) == 0) { *valp = IPV6_RECVHOPLIMIT; return 0; }
6333 #endif
6334 #ifdef IPV6_RTHDRDSTOPTS
6335         if (memcmp(str, "IPV6_RTHDRDSTOPTS", 17) == 0) { *valp = IPV6_RTHDRDSTOPTS; return 0; }
6336 #endif
6337 #ifdef IPV6_RTHDR_TYPE_0
6338         if (memcmp(str, "IPV6_RTHDR_TYPE_0", 17) == 0) { *valp = IPV6_RTHDR_TYPE_0; return 0; }
6339 #endif
6340         return -1;
6341 
6342       case 19:
6343 #ifdef IPV6_MULTICAST_HOPS
6344         if (memcmp(str, "IPV6_MULTICAST_HOPS", 19) == 0) { *valp = IPV6_MULTICAST_HOPS; return 0; }
6345 #endif
6346 #ifdef IPV6_MULTICAST_LOOP
6347         if (memcmp(str, "IPV6_MULTICAST_LOOP", 19) == 0) { *valp = IPV6_MULTICAST_LOOP; return 0; }
6348 #endif
6349         return -1;
6350 
6351       default:
6352         return -1;
6353     }
6354 }
6355 
6356 #endif
6357 
6358 int
rsock_tcp_optname_to_int(const char * str,long len,int * valp)6359 rsock_tcp_optname_to_int(const char *str, long len, int *valp)
6360 {
6361     switch (len) {
6362       case 4:
6363 #ifdef TCP_CORK
6364         if (memcmp(str, "CORK", 4) == 0) { *valp = TCP_CORK; return 0; }
6365 #endif
6366 #ifdef TCP_INFO
6367         if (memcmp(str, "INFO", 4) == 0) { *valp = TCP_INFO; return 0; }
6368 #endif
6369         return -1;
6370 
6371       case 5:
6372 #ifdef TCP_NOOPT
6373         if (memcmp(str, "NOOPT", 5) == 0) { *valp = TCP_NOOPT; return 0; }
6374 #endif
6375         return -1;
6376 
6377       case 6:
6378 #ifdef TCP_MAXSEG
6379         if (memcmp(str, "MAXSEG", 6) == 0) { *valp = TCP_MAXSEG; return 0; }
6380 #endif
6381 #ifdef TCP_MD5SIG
6382         if (memcmp(str, "MD5SIG", 6) == 0) { *valp = TCP_MD5SIG; return 0; }
6383 #endif
6384 #ifdef TCP_NOPUSH
6385         if (memcmp(str, "NOPUSH", 6) == 0) { *valp = TCP_NOPUSH; return 0; }
6386 #endif
6387 #ifdef TCP_SYNCNT
6388         if (memcmp(str, "SYNCNT", 6) == 0) { *valp = TCP_SYNCNT; return 0; }
6389 #endif
6390 #ifdef TCP_REPAIR
6391         if (memcmp(str, "REPAIR", 6) == 0) { *valp = TCP_REPAIR; return 0; }
6392 #endif
6393         return -1;
6394 
6395       case 7:
6396 #ifdef TCP_NODELAY
6397         if (memcmp(str, "NODELAY", 7) == 0) { *valp = TCP_NODELAY; return 0; }
6398 #endif
6399 #ifdef TCP_KEEPCNT
6400         if (memcmp(str, "KEEPCNT", 7) == 0) { *valp = TCP_KEEPCNT; return 0; }
6401 #endif
6402 #ifdef TCP_LINGER2
6403         if (memcmp(str, "LINGER2", 7) == 0) { *valp = TCP_LINGER2; return 0; }
6404 #endif
6405         return -1;
6406 
6407       case 8:
6408 #ifdef TCP_CORK
6409         if (memcmp(str, "TCP_CORK", 8) == 0) { *valp = TCP_CORK; return 0; }
6410 #endif
6411 #ifdef TCP_INFO
6412         if (memcmp(str, "TCP_INFO", 8) == 0) { *valp = TCP_INFO; return 0; }
6413 #endif
6414 #ifdef TCP_KEEPIDLE
6415         if (memcmp(str, "KEEPIDLE", 8) == 0) { *valp = TCP_KEEPIDLE; return 0; }
6416 #endif
6417 #ifdef TCP_QUICKACK
6418         if (memcmp(str, "QUICKACK", 8) == 0) { *valp = TCP_QUICKACK; return 0; }
6419 #endif
6420 #ifdef TCP_FASTOPEN
6421         if (memcmp(str, "FASTOPEN", 8) == 0) { *valp = TCP_FASTOPEN; return 0; }
6422 #endif
6423         return -1;
6424 
6425       case 9:
6426 #ifdef TCP_NOOPT
6427         if (memcmp(str, "TCP_NOOPT", 9) == 0) { *valp = TCP_NOOPT; return 0; }
6428 #endif
6429 #ifdef TCP_KEEPINTVL
6430         if (memcmp(str, "KEEPINTVL", 9) == 0) { *valp = TCP_KEEPINTVL; return 0; }
6431 #endif
6432 #ifdef TCP_QUEUE_SEQ
6433         if (memcmp(str, "QUEUE_SEQ", 9) == 0) { *valp = TCP_QUEUE_SEQ; return 0; }
6434 #endif
6435 #ifdef TCP_TIMESTAMP
6436         if (memcmp(str, "TIMESTAMP", 9) == 0) { *valp = TCP_TIMESTAMP; return 0; }
6437 #endif
6438         return -1;
6439 
6440       case 10:
6441 #ifdef TCP_MAXSEG
6442         if (memcmp(str, "TCP_MAXSEG", 10) == 0) { *valp = TCP_MAXSEG; return 0; }
6443 #endif
6444 #ifdef TCP_MD5SIG
6445         if (memcmp(str, "TCP_MD5SIG", 10) == 0) { *valp = TCP_MD5SIG; return 0; }
6446 #endif
6447 #ifdef TCP_NOPUSH
6448         if (memcmp(str, "TCP_NOPUSH", 10) == 0) { *valp = TCP_NOPUSH; return 0; }
6449 #endif
6450 #ifdef TCP_SYNCNT
6451         if (memcmp(str, "TCP_SYNCNT", 10) == 0) { *valp = TCP_SYNCNT; return 0; }
6452 #endif
6453 #ifdef TCP_REPAIR
6454         if (memcmp(str, "TCP_REPAIR", 10) == 0) { *valp = TCP_REPAIR; return 0; }
6455 #endif
6456 #ifdef TCP_CONGESTION
6457         if (memcmp(str, "CONGESTION", 10) == 0) { *valp = TCP_CONGESTION; return 0; }
6458 #endif
6459         return -1;
6460 
6461       case 11:
6462 #ifdef TCP_NODELAY
6463         if (memcmp(str, "TCP_NODELAY", 11) == 0) { *valp = TCP_NODELAY; return 0; }
6464 #endif
6465 #ifdef TCP_KEEPCNT
6466         if (memcmp(str, "TCP_KEEPCNT", 11) == 0) { *valp = TCP_KEEPCNT; return 0; }
6467 #endif
6468 #ifdef TCP_LINGER2
6469         if (memcmp(str, "TCP_LINGER2", 11) == 0) { *valp = TCP_LINGER2; return 0; }
6470 #endif
6471 #ifdef TCP_THIN_DUPACK
6472         if (memcmp(str, "THIN_DUPACK", 11) == 0) { *valp = TCP_THIN_DUPACK; return 0; }
6473 #endif
6474         return -1;
6475 
6476       case 12:
6477 #ifdef TCP_KEEPIDLE
6478         if (memcmp(str, "TCP_KEEPIDLE", 12) == 0) { *valp = TCP_KEEPIDLE; return 0; }
6479 #endif
6480 #ifdef TCP_QUICKACK
6481         if (memcmp(str, "TCP_QUICKACK", 12) == 0) { *valp = TCP_QUICKACK; return 0; }
6482 #endif
6483 #ifdef TCP_FASTOPEN
6484         if (memcmp(str, "TCP_FASTOPEN", 12) == 0) { *valp = TCP_FASTOPEN; return 0; }
6485 #endif
6486 #ifdef TCP_DEFER_ACCEPT
6487         if (memcmp(str, "DEFER_ACCEPT", 12) == 0) { *valp = TCP_DEFER_ACCEPT; return 0; }
6488 #endif
6489 #ifdef TCP_WINDOW_CLAMP
6490         if (memcmp(str, "WINDOW_CLAMP", 12) == 0) { *valp = TCP_WINDOW_CLAMP; return 0; }
6491 #endif
6492 #ifdef TCP_REPAIR_QUEUE
6493         if (memcmp(str, "REPAIR_QUEUE", 12) == 0) { *valp = TCP_REPAIR_QUEUE; return 0; }
6494 #endif
6495 #ifdef TCP_USER_TIMEOUT
6496         if (memcmp(str, "USER_TIMEOUT", 12) == 0) { *valp = TCP_USER_TIMEOUT; return 0; }
6497 #endif
6498         return -1;
6499 
6500       case 13:
6501 #ifdef TCP_KEEPINTVL
6502         if (memcmp(str, "TCP_KEEPINTVL", 13) == 0) { *valp = TCP_KEEPINTVL; return 0; }
6503 #endif
6504 #ifdef TCP_QUEUE_SEQ
6505         if (memcmp(str, "TCP_QUEUE_SEQ", 13) == 0) { *valp = TCP_QUEUE_SEQ; return 0; }
6506 #endif
6507 #ifdef TCP_TIMESTAMP
6508         if (memcmp(str, "TCP_TIMESTAMP", 13) == 0) { *valp = TCP_TIMESTAMP; return 0; }
6509 #endif
6510         return -1;
6511 
6512       case 14:
6513 #ifdef TCP_CONGESTION
6514         if (memcmp(str, "TCP_CONGESTION", 14) == 0) { *valp = TCP_CONGESTION; return 0; }
6515 #endif
6516 #ifdef TCP_REPAIR_OPTIONS
6517         if (memcmp(str, "REPAIR_OPTIONS", 14) == 0) { *valp = TCP_REPAIR_OPTIONS; return 0; }
6518 #endif
6519         return -1;
6520 
6521       case 15:
6522 #ifdef TCP_THIN_DUPACK
6523         if (memcmp(str, "TCP_THIN_DUPACK", 15) == 0) { *valp = TCP_THIN_DUPACK; return 0; }
6524 #endif
6525         return -1;
6526 
6527       case 16:
6528 #ifdef TCP_DEFER_ACCEPT
6529         if (memcmp(str, "TCP_DEFER_ACCEPT", 16) == 0) { *valp = TCP_DEFER_ACCEPT; return 0; }
6530 #endif
6531 #ifdef TCP_WINDOW_CLAMP
6532         if (memcmp(str, "TCP_WINDOW_CLAMP", 16) == 0) { *valp = TCP_WINDOW_CLAMP; return 0; }
6533 #endif
6534 #ifdef TCP_REPAIR_QUEUE
6535         if (memcmp(str, "TCP_REPAIR_QUEUE", 16) == 0) { *valp = TCP_REPAIR_QUEUE; return 0; }
6536 #endif
6537 #ifdef TCP_USER_TIMEOUT
6538         if (memcmp(str, "TCP_USER_TIMEOUT", 16) == 0) { *valp = TCP_USER_TIMEOUT; return 0; }
6539 #endif
6540         return -1;
6541 
6542       case 18:
6543 #ifdef TCP_REPAIR_OPTIONS
6544         if (memcmp(str, "TCP_REPAIR_OPTIONS", 18) == 0) { *valp = TCP_REPAIR_OPTIONS; return 0; }
6545 #endif
6546         return -1;
6547 
6548       case 19:
6549 #ifdef TCP_COOKIE_TRANSACTIONS
6550         if (memcmp(str, "COOKIE_TRANSACTIONS", 19) == 0) { *valp = TCP_COOKIE_TRANSACTIONS; return 0; }
6551 #endif
6552         return -1;
6553 
6554       case 20:
6555 #ifdef TCP_THIN_LINEAR_TIMEOUTS
6556         if (memcmp(str, "THIN_LINEAR_TIMEOUTS", 20) == 0) { *valp = TCP_THIN_LINEAR_TIMEOUTS; return 0; }
6557 #endif
6558         return -1;
6559 
6560       case 23:
6561 #ifdef TCP_COOKIE_TRANSACTIONS
6562         if (memcmp(str, "TCP_COOKIE_TRANSACTIONS", 23) == 0) { *valp = TCP_COOKIE_TRANSACTIONS; return 0; }
6563 #endif
6564         return -1;
6565 
6566       case 24:
6567 #ifdef TCP_THIN_LINEAR_TIMEOUTS
6568         if (memcmp(str, "TCP_THIN_LINEAR_TIMEOUTS", 24) == 0) { *valp = TCP_THIN_LINEAR_TIMEOUTS; return 0; }
6569 #endif
6570         return -1;
6571 
6572       default:
6573         return -1;
6574     }
6575 }
6576 
6577 
6578 int
rsock_udp_optname_to_int(const char * str,long len,int * valp)6579 rsock_udp_optname_to_int(const char *str, long len, int *valp)
6580 {
6581     switch (len) {
6582       case 4:
6583 #ifdef UDP_CORK
6584         if (memcmp(str, "CORK", 4) == 0) { *valp = UDP_CORK; return 0; }
6585 #endif
6586         return -1;
6587 
6588       case 8:
6589 #ifdef UDP_CORK
6590         if (memcmp(str, "UDP_CORK", 8) == 0) { *valp = UDP_CORK; return 0; }
6591 #endif
6592         return -1;
6593 
6594       default:
6595         return -1;
6596     }
6597 }
6598 
6599 
6600 int
rsock_shutdown_how_to_int(const char * str,long len,int * valp)6601 rsock_shutdown_how_to_int(const char *str, long len, int *valp)
6602 {
6603     switch (len) {
6604       case 2:
6605 #ifdef SHUT_RD
6606         if (memcmp(str, "RD", 2) == 0) { *valp = SHUT_RD; return 0; }
6607 #endif
6608 #ifdef SHUT_WR
6609         if (memcmp(str, "WR", 2) == 0) { *valp = SHUT_WR; return 0; }
6610 #endif
6611         return -1;
6612 
6613       case 4:
6614 #ifdef SHUT_RDWR
6615         if (memcmp(str, "RDWR", 4) == 0) { *valp = SHUT_RDWR; return 0; }
6616 #endif
6617         return -1;
6618 
6619       case 7:
6620 #ifdef SHUT_RD
6621         if (memcmp(str, "SHUT_RD", 7) == 0) { *valp = SHUT_RD; return 0; }
6622 #endif
6623 #ifdef SHUT_WR
6624         if (memcmp(str, "SHUT_WR", 7) == 0) { *valp = SHUT_WR; return 0; }
6625 #endif
6626         return -1;
6627 
6628       case 9:
6629 #ifdef SHUT_RDWR
6630         if (memcmp(str, "SHUT_RDWR", 9) == 0) { *valp = SHUT_RDWR; return 0; }
6631 #endif
6632         return -1;
6633 
6634       default:
6635         return -1;
6636     }
6637 }
6638 
6639 
6640 int
rsock_scm_optname_to_int(const char * str,long len,int * valp)6641 rsock_scm_optname_to_int(const char *str, long len, int *valp)
6642 {
6643     switch (len) {
6644       case 5:
6645 #ifdef SCM_CREDS
6646         if (memcmp(str, "CREDS", 5) == 0) { *valp = SCM_CREDS; return 0; }
6647 #endif
6648 #ifdef SCM_UCRED
6649         if (memcmp(str, "UCRED", 5) == 0) { *valp = SCM_UCRED; return 0; }
6650 #endif
6651         return -1;
6652 
6653       case 6:
6654 #ifdef SCM_RIGHTS
6655         if (memcmp(str, "RIGHTS", 6) == 0) { *valp = SCM_RIGHTS; return 0; }
6656 #endif
6657         return -1;
6658 
6659       case 7:
6660 #ifdef SCM_BINTIME
6661         if (memcmp(str, "BINTIME", 7) == 0) { *valp = SCM_BINTIME; return 0; }
6662 #endif
6663         return -1;
6664 
6665       case 9:
6666 #ifdef SCM_CREDS
6667         if (memcmp(str, "SCM_CREDS", 9) == 0) { *valp = SCM_CREDS; return 0; }
6668 #endif
6669 #ifdef SCM_UCRED
6670         if (memcmp(str, "SCM_UCRED", 9) == 0) { *valp = SCM_UCRED; return 0; }
6671 #endif
6672 #ifdef SCM_TIMESTAMP
6673         if (memcmp(str, "TIMESTAMP", 9) == 0) { *valp = SCM_TIMESTAMP; return 0; }
6674 #endif
6675         return -1;
6676 
6677       case 10:
6678 #ifdef SCM_RIGHTS
6679         if (memcmp(str, "SCM_RIGHTS", 10) == 0) { *valp = SCM_RIGHTS; return 0; }
6680 #endif
6681         return -1;
6682 
6683       case 11:
6684 #ifdef SCM_BINTIME
6685         if (memcmp(str, "SCM_BINTIME", 11) == 0) { *valp = SCM_BINTIME; return 0; }
6686 #endif
6687 #ifdef SCM_TIMESTAMPNS
6688         if (memcmp(str, "TIMESTAMPNS", 11) == 0) { *valp = SCM_TIMESTAMPNS; return 0; }
6689 #endif
6690 #ifdef SCM_CREDENTIALS
6691         if (memcmp(str, "CREDENTIALS", 11) == 0) { *valp = SCM_CREDENTIALS; return 0; }
6692 #endif
6693 #ifdef SCM_WIFI_STATUS
6694         if (memcmp(str, "WIFI_STATUS", 11) == 0) { *valp = SCM_WIFI_STATUS; return 0; }
6695 #endif
6696         return -1;
6697 
6698       case 12:
6699 #ifdef SCM_TIMESTAMPING
6700         if (memcmp(str, "TIMESTAMPING", 12) == 0) { *valp = SCM_TIMESTAMPING; return 0; }
6701 #endif
6702         return -1;
6703 
6704       case 13:
6705 #ifdef SCM_TIMESTAMP
6706         if (memcmp(str, "SCM_TIMESTAMP", 13) == 0) { *valp = SCM_TIMESTAMP; return 0; }
6707 #endif
6708         return -1;
6709 
6710       case 15:
6711 #ifdef SCM_TIMESTAMPNS
6712         if (memcmp(str, "SCM_TIMESTAMPNS", 15) == 0) { *valp = SCM_TIMESTAMPNS; return 0; }
6713 #endif
6714 #ifdef SCM_CREDENTIALS
6715         if (memcmp(str, "SCM_CREDENTIALS", 15) == 0) { *valp = SCM_CREDENTIALS; return 0; }
6716 #endif
6717 #ifdef SCM_WIFI_STATUS
6718         if (memcmp(str, "SCM_WIFI_STATUS", 15) == 0) { *valp = SCM_WIFI_STATUS; return 0; }
6719 #endif
6720         return -1;
6721 
6722       case 16:
6723 #ifdef SCM_TIMESTAMPING
6724         if (memcmp(str, "SCM_TIMESTAMPING", 16) == 0) { *valp = SCM_TIMESTAMPING; return 0; }
6725 #endif
6726         return -1;
6727 
6728       default:
6729         return -1;
6730     }
6731 }
6732 
6733 
6734 
6735 ID
rsock_intern_family(int val)6736 rsock_intern_family(int val)
6737 {
6738     st_data_t name;
6739     if (st_lookup(rsock_intern_family_hash, (st_data_t)val, &name))
6740         return (ID)name;
6741     return 0;
6742 }
6743 
6744 ID
rsock_intern_family_noprefix(int val)6745 rsock_intern_family_noprefix(int val)
6746 {
6747     st_data_t name;
6748     if (st_lookup(rsock_intern_family_noprefix_hash, (st_data_t)val, &name))
6749         return (ID)name;
6750     return 0;
6751 }
6752 
6753 ID
rsock_intern_protocol_family(int val)6754 rsock_intern_protocol_family(int val)
6755 {
6756     st_data_t name;
6757     if (st_lookup(rsock_intern_protocol_family_hash, (st_data_t)val, &name))
6758         return (ID)name;
6759     return 0;
6760 }
6761 
6762 ID
rsock_intern_socktype(int val)6763 rsock_intern_socktype(int val)
6764 {
6765     st_data_t name;
6766     if (st_lookup(rsock_intern_socktype_hash, (st_data_t)val, &name))
6767         return (ID)name;
6768     return 0;
6769 }
6770 
6771 ID
rsock_intern_ipproto(int val)6772 rsock_intern_ipproto(int val)
6773 {
6774     st_data_t name;
6775     if (st_lookup(rsock_intern_ipproto_hash, (st_data_t)val, &name))
6776         return (ID)name;
6777     return 0;
6778 }
6779 
6780 ID
rsock_intern_iplevel(int val)6781 rsock_intern_iplevel(int val)
6782 {
6783     st_data_t name;
6784     if (st_lookup(rsock_intern_iplevel_hash, (st_data_t)val, &name))
6785         return (ID)name;
6786     return 0;
6787 }
6788 
6789 ID
rsock_intern_so_optname(int val)6790 rsock_intern_so_optname(int val)
6791 {
6792     st_data_t name;
6793     if (st_lookup(rsock_intern_so_optname_hash, (st_data_t)val, &name))
6794         return (ID)name;
6795     return 0;
6796 }
6797 
6798 ID
rsock_intern_ip_optname(int val)6799 rsock_intern_ip_optname(int val)
6800 {
6801     st_data_t name;
6802     if (st_lookup(rsock_intern_ip_optname_hash, (st_data_t)val, &name))
6803         return (ID)name;
6804     return 0;
6805 }
6806 
6807 ID
rsock_intern_ipv6_optname(int val)6808 rsock_intern_ipv6_optname(int val)
6809 {
6810     st_data_t name;
6811     if (st_lookup(rsock_intern_ipv6_optname_hash, (st_data_t)val, &name))
6812         return (ID)name;
6813     return 0;
6814 }
6815 
6816 ID
rsock_intern_tcp_optname(int val)6817 rsock_intern_tcp_optname(int val)
6818 {
6819     st_data_t name;
6820     if (st_lookup(rsock_intern_tcp_optname_hash, (st_data_t)val, &name))
6821         return (ID)name;
6822     return 0;
6823 }
6824 
6825 ID
rsock_intern_udp_optname(int val)6826 rsock_intern_udp_optname(int val)
6827 {
6828     st_data_t name;
6829     if (st_lookup(rsock_intern_udp_optname_hash, (st_data_t)val, &name))
6830         return (ID)name;
6831     return 0;
6832 }
6833 
6834 ID
rsock_intern_scm_optname(int val)6835 rsock_intern_scm_optname(int val)
6836 {
6837     st_data_t name;
6838     if (st_lookup(rsock_intern_scm_optname_hash, (st_data_t)val, &name))
6839         return (ID)name;
6840     return 0;
6841 }
6842 
6843 ID
rsock_intern_local_optname(int val)6844 rsock_intern_local_optname(int val)
6845 {
6846     st_data_t name;
6847     if (st_lookup(rsock_intern_local_optname_hash, (st_data_t)val, &name))
6848         return (ID)name;
6849     return 0;
6850 }
6851 
6852 
6853