-
Notifications
You must be signed in to change notification settings - Fork 9
/
net.c
2214 lines (2115 loc) · 47.6 KB
/
net.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (c) 1991, 1992 Paul Kranenburg <[email protected]>
* Copyright (c) 1993 Branko Lankester <[email protected]>
* Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <[email protected]>
* Copyright (c) 1996-2000 Wichert Akkerman <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/un.h>
#if defined(HAVE_SIN6_SCOPE_ID_LINUX)
# define in6_addr in6_addr_libc
# define ipv6_mreq ipv6_mreq_libc
# define sockaddr_in6 sockaddr_in6_libc
#endif
#include <netinet/in.h>
#ifdef HAVE_NETINET_TCP_H
# include <netinet/tcp.h>
#endif
#ifdef HAVE_NETINET_UDP_H
# include <netinet/udp.h>
#endif
#ifdef HAVE_NETINET_SCTP_H
# include <netinet/sctp.h>
#endif
#include <arpa/inet.h>
#include <net/if.h>
#include <asm/types.h>
#if defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC__ + __GLIBC_MINOR__ >= 3)
# include <netipx/ipx.h>
#else
# include <linux/ipx.h>
#endif
#if defined(__GLIBC__) && (((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1)) || defined(HAVE_SIN6_SCOPE_ID_LINUX))
# if defined(HAVE_LINUX_IN6_H)
# if defined(HAVE_SIN6_SCOPE_ID_LINUX)
# undef in6_addr
# undef ipv6_mreq
# undef sockaddr_in6
# define in6_addr in6_addr_kernel
# define ipv6_mreq ipv6_mreq_kernel
# define sockaddr_in6 sockaddr_in6_kernel
# endif
# include <linux/in6.h>
# if defined(HAVE_SIN6_SCOPE_ID_LINUX)
# undef in6_addr
# undef ipv6_mreq
# undef sockaddr_in6
# define in6_addr in6_addr_libc
# define ipv6_mreq ipv6_mreq_libc
# define sockaddr_in6 sockaddr_in6_kernel
# endif
# endif
#endif
#if defined(HAVE_SYS_UIO_H)
# include <sys/uio.h>
#endif
#if defined(HAVE_LINUX_NETLINK_H)
# include <linux/netlink.h>
#endif
#if defined(HAVE_LINUX_IF_PACKET_H)
# include <linux/if_packet.h>
#endif
#if defined(HAVE_LINUX_ICMP_H)
# include <linux/icmp.h>
#endif
#ifndef PF_UNSPEC
# define PF_UNSPEC AF_UNSPEC
#endif
/* Under Linux these are enums so we can't test for them with ifdef. */
#define IPPROTO_EGP IPPROTO_EGP
#define IPPROTO_PUP IPPROTO_PUP
#define IPPROTO_IDP IPPROTO_IDP
#define IPPROTO_IGMP IPPROTO_IGMP
#define IPPROTO_RAW IPPROTO_RAW
#define IPPROTO_MAX IPPROTO_MAX
static const struct xlat domains[] = {
#ifdef PF_AAL5
{ PF_AAL5, "PF_AAL5" },
#endif
#ifdef PF_APPLETALK
{ PF_APPLETALK, "PF_APPLETALK" },
#endif
#ifdef PF_ASH
{ PF_ASH, "PF_ASH" },
#endif
#ifdef PF_ATMPVC
{ PF_ATMPVC, "PF_ATMPVC" },
#endif
#ifdef PF_ATMSVC
{ PF_ATMSVC, "PF_ATMSVC" },
#endif
#ifdef PF_AX25
{ PF_AX25, "PF_AX25" },
#endif
#ifdef PF_BLUETOOTH
{ PF_BLUETOOTH, "PF_BLUETOOTH" },
#endif
#ifdef PF_BRIDGE
{ PF_BRIDGE, "PF_BRIDGE" },
#endif
#ifdef PF_DECnet
{ PF_DECnet, "PF_DECnet" },
#endif
#ifdef PF_DECNET
{ PF_DECNET, "PF_DECNET" },
#endif
#ifdef PF_ECONET
{ PF_ECONET, "PF_ECONET" },
#endif
#ifdef PF_FILE
{ PF_FILE, "PF_FILE" },
#endif
#ifdef PF_IMPLINK
{ PF_IMPLINK, "PF_IMPLINK" },
#endif
#ifdef PF_INET
{ PF_INET, "PF_INET" },
#endif
#ifdef PF_INET6
{ PF_INET6, "PF_INET6" },
#endif
#ifdef PF_IPX
{ PF_IPX, "PF_IPX" },
#endif
#ifdef PF_IRDA
{ PF_IRDA, "PF_IRDA" },
#endif
#ifdef PF_ISO
{ PF_ISO, "PF_ISO" },
#endif
#ifdef PF_KEY
{ PF_KEY, "PF_KEY" },
#endif
#ifdef PF_UNIX
{ PF_UNIX, "PF_UNIX" },
#endif
#ifdef PF_LOCAL
{ PF_LOCAL, "PF_LOCAL" },
#endif
#ifdef PF_NETBEUI
{ PF_NETBEUI, "PF_NETBEUI" },
#endif
#ifdef PF_NETLINK
{ PF_NETLINK, "PF_NETLINK" },
#endif
#ifdef PF_NETROM
{ PF_NETROM, "PF_NETROM" },
#endif
#ifdef PF_PACKET
{ PF_PACKET, "PF_PACKET" },
#endif
#ifdef PF_PPPOX
{ PF_PPPOX, "PF_PPPOX" },
#endif
#ifdef PF_ROSE
{ PF_ROSE, "PF_ROSE" },
#endif
#ifdef PF_ROUTE
{ PF_ROUTE, "PF_ROUTE" },
#endif
#ifdef PF_SECURITY
{ PF_SECURITY, "PF_SECURITY" },
#endif
#ifdef PF_SNA
{ PF_SNA, "PF_SNA" },
#endif
#ifdef PF_UNSPEC
{ PF_UNSPEC, "PF_UNSPEC" },
#endif
#ifdef PF_WANPIPE
{ PF_WANPIPE, "PF_WANPIPE" },
#endif
#ifdef PF_X25
{ PF_X25, "PF_X25" },
#endif
{ 0, NULL },
};
const struct xlat addrfams[] = {
#ifdef AF_APPLETALK
{ AF_APPLETALK, "AF_APPLETALK" },
#endif
#ifdef AF_ASH
{ AF_ASH, "AF_ASH" },
#endif
#ifdef AF_ATMPVC
{ AF_ATMPVC, "AF_ATMPVC" },
#endif
#ifdef AF_ATMSVC
{ AF_ATMSVC, "AF_ATMSVC" },
#endif
#ifdef AF_AX25
{ AF_AX25, "AF_AX25" },
#endif
#ifdef AF_BLUETOOTH
{ AF_BLUETOOTH, "AF_BLUETOOTH" },
#endif
#ifdef AF_BRIDGE
{ AF_BRIDGE, "AF_BRIDGE" },
#endif
#ifdef AF_DECnet
{ AF_DECnet, "AF_DECnet" },
#endif
#ifdef AF_ECONET
{ AF_ECONET, "AF_ECONET" },
#endif
#ifdef AF_FILE
{ AF_FILE, "AF_FILE" },
#endif
#ifdef AF_IMPLINK
{ AF_IMPLINK, "AF_IMPLINK" },
#endif
#ifdef AF_INET
{ AF_INET, "AF_INET" },
#endif
#ifdef AF_INET6
{ AF_INET6, "AF_INET6" },
#endif
#ifdef AF_IPX
{ AF_IPX, "AF_IPX" },
#endif
#ifdef AF_IRDA
{ AF_IRDA, "AF_IRDA" },
#endif
#ifdef AF_ISO
{ AF_ISO, "AF_ISO" },
#endif
#ifdef AF_KEY
{ AF_KEY, "AF_KEY" },
#endif
#ifdef AF_UNIX
{ AF_UNIX, "AF_UNIX" },
#endif
#ifdef AF_LOCAL
{ AF_LOCAL, "AF_LOCAL" },
#endif
#ifdef AF_NETBEUI
{ AF_NETBEUI, "AF_NETBEUI" },
#endif
#ifdef AF_NETLINK
{ AF_NETLINK, "AF_NETLINK" },
#endif
#ifdef AF_NETROM
{ AF_NETROM, "AF_NETROM" },
#endif
#ifdef AF_PACKET
{ AF_PACKET, "AF_PACKET" },
#endif
#ifdef AF_PPPOX
{ AF_PPPOX, "AF_PPPOX" },
#endif
#ifdef AF_ROSE
{ AF_ROSE, "AF_ROSE" },
#endif
#ifdef AF_ROUTE
{ AF_ROUTE, "AF_ROUTE" },
#endif
#ifdef AF_SECURITY
{ AF_SECURITY, "AF_SECURITY" },
#endif
#ifdef AF_SNA
{ AF_SNA, "AF_SNA" },
#endif
#ifdef AF_UNSPEC
{ AF_UNSPEC, "AF_UNSPEC" },
#endif
#ifdef AF_WANPIPE
{ AF_WANPIPE, "AF_WANPIPE" },
#endif
#ifdef AF_X25
{ AF_X25, "AF_X25" },
#endif
{ 0, NULL },
};
static const struct xlat socktypes[] = {
{ SOCK_STREAM, "SOCK_STREAM" },
{ SOCK_DGRAM, "SOCK_DGRAM" },
#ifdef SOCK_RAW
{ SOCK_RAW, "SOCK_RAW" },
#endif
#ifdef SOCK_RDM
{ SOCK_RDM, "SOCK_RDM" },
#endif
#ifdef SOCK_SEQPACKET
{ SOCK_SEQPACKET,"SOCK_SEQPACKET"},
#endif
#ifdef SOCK_DCCP
{ SOCK_DCCP, "SOCK_DCCP" },
#endif
#ifdef SOCK_PACKET
{ SOCK_PACKET, "SOCK_PACKET" },
#endif
{ 0, NULL },
};
static const struct xlat sock_type_flags[] = {
#ifdef SOCK_CLOEXEC
{ SOCK_CLOEXEC, "SOCK_CLOEXEC" },
#endif
#ifdef SOCK_NONBLOCK
{ SOCK_NONBLOCK,"SOCK_NONBLOCK" },
#endif
{ 0, NULL },
};
#ifndef SOCK_TYPE_MASK
# define SOCK_TYPE_MASK 0xf
#endif
static const struct xlat socketlayers[] = {
#if defined(SOL_IP)
{ SOL_IP, "SOL_IP" },
#endif
#if defined(SOL_ICMP)
{ SOL_ICMP, "SOL_ICMP" },
#endif
#if defined(SOL_TCP)
{ SOL_TCP, "SOL_TCP" },
#endif
#if defined(SOL_UDP)
{ SOL_UDP, "SOL_UDP" },
#endif
#if defined(SOL_IPV6)
{ SOL_IPV6, "SOL_IPV6" },
#endif
#if defined(SOL_ICMPV6)
{ SOL_ICMPV6, "SOL_ICMPV6" },
#endif
#if defined(SOL_SCTP)
{ SOL_SCTP, "SOL_SCTP" },
#endif
#if defined(SOL_UDPLITE)
{ SOL_UDPLITE, "SOL_UDPLITE" },
#endif
#if defined(SOL_RAW)
{ SOL_RAW, "SOL_RAW" },
#endif
#if defined(SOL_IPX)
{ SOL_IPX, "SOL_IPX" },
#endif
#if defined(SOL_AX25)
{ SOL_AX25, "SOL_AX25" },
#endif
#if defined(SOL_ATALK)
{ SOL_ATALK, "SOL_ATALK" },
#endif
#if defined(SOL_NETROM)
{ SOL_NETROM, "SOL_NETROM" },
#endif
#if defined(SOL_ROSE)
{ SOL_ROSE, "SOL_ROSE" },
#endif
#if defined(SOL_DECNET)
{ SOL_DECNET, "SOL_DECNET" },
#endif
#if defined(SOL_X25)
{ SOL_X25, "SOL_X25" },
#endif
#if defined(SOL_PACKET)
{ SOL_PACKET, "SOL_PACKET" },
#endif
#if defined(SOL_ATM)
{ SOL_ATM, "SOL_ATM" },
#endif
#if defined(SOL_AAL)
{ SOL_AAL, "SOL_AAL" },
#endif
#if defined(SOL_IRDA)
{ SOL_IRDA, "SOL_IRDA" },
#endif
#if defined(SOL_NETBEUI)
{ SOL_NETBEUI, "SOL_NETBEUI" },
#endif
#if defined(SOL_LLC)
{ SOL_LLC, "SOL_LLC" },
#endif
#if defined(SOL_DCCP)
{ SOL_DCCP, "SOL_DCCP" },
#endif
#if defined(SOL_NETLINK)
{ SOL_NETLINK, "SOL_NETLINK" },
#endif
#if defined(SOL_TIPC)
{ SOL_TIPC, "SOL_TIPC" },
#endif
#if defined(SOL_RXRPC)
{ SOL_RXRPC, "SOL_RXRPC" },
#endif
#if defined(SOL_PPPOL2TP)
{ SOL_PPPOL2TP, "SOL_PPPOL2TP" },
#endif
#if defined(SOL_BLUETOOTH)
{ SOL_BLUETOOTH,"SOL_BLUETOOTH" },
#endif
#if defined(SOL_PNPIPE)
{ SOL_PNPIPE, "SOL_PNPIPE" },
#endif
#if defined(SOL_RDS)
{ SOL_RDS, "SOL_RDS" },
#endif
#if defined(SOL_IUVC)
{ SOL_IUCV, "SOL_IUCV" },
#endif
#if defined(SOL_CAIF)
{ SOL_CAIF, "SOL_CAIF" },
#endif
{ SOL_SOCKET, "SOL_SOCKET" }, /* Never used! */
/* The SOL_* array should remain not NULL-terminated. */
};
/*** WARNING: DANGER WILL ROBINSON: NOTE "socketlayers" array above
falls into "protocols" array below!!!! This is intended!!! ***/
static const struct xlat protocols[] = {
{ IPPROTO_IP, "IPPROTO_IP" },
{ IPPROTO_ICMP, "IPPROTO_ICMP" },
{ IPPROTO_TCP, "IPPROTO_TCP" },
{ IPPROTO_UDP, "IPPROTO_UDP" },
#ifdef IPPROTO_IGMP
{ IPPROTO_IGMP, "IPPROTO_IGMP" },
#endif
#ifdef IPPROTO_GGP
{ IPPROTO_GGP, "IPPROTO_GGP" },
#endif
#ifdef IPPROTO_IPIP
{ IPPROTO_IPIP, "IPPROTO_IPIP" },
#endif
#ifdef IPPROTO_EGP
{ IPPROTO_EGP, "IPPROTO_EGP" },
#endif
#ifdef IPPROTO_PUP
{ IPPROTO_PUP, "IPPROTO_PUP" },
#endif
#ifdef IPPROTO_IDP
{ IPPROTO_IDP, "IPPROTO_IDP" },
#endif
#ifdef IPPROTO_TP
{ IPPROTO_TP, "IPPROTO_TP" },
#endif
#ifdef IPPROTO_DCCP
{ IPPROTO_DCCP, "IPPROTO_DCCP" },
#endif
#ifdef IPPROTO_IPV6
{ IPPROTO_IPV6, "IPPROTO_IPV6" },
#endif
#ifdef IPPROTO_ROUTING
{ IPPROTO_ROUTING, "IPPROTO_ROUTING" },
#endif
#ifdef IPPROTO_FRAGMENT
{ IPPROTO_FRAGMENT, "IPPROTO_FRAGMENT" },
#endif
#ifdef IPPROTO_RSVP
{ IPPROTO_RSVP, "IPPROTO_RSVP" },
#endif
#ifdef IPPROTO_GRE
{ IPPROTO_GRE, "IPPROTO_GRE" },
#endif
#ifdef IPPROTO_ESP
{ IPPROTO_ESP, "IPPROTO_ESP" },
#endif
#ifdef IPPROTO_AH
{ IPPROTO_AH, "IPPROTO_AH" },
#endif
#ifdef IPPROTO_ICMPV6
{ IPPROTO_ICMPV6, "IPPROTO_ICMPV6" },
#endif
#ifdef IPPROTO_NONE
{ IPPROTO_NONE, "IPPROTO_NONE" },
#endif
#ifdef IPPROTO_DSTOPTS
{ IPPROTO_DSTOPTS, "IPPROTO_DSTOPTS" },
#endif
#ifdef IPPROTO_HELLO
{ IPPROTO_HELLO, "IPPROTO_HELLO" },
#endif
#ifdef IPPROTO_ND
{ IPPROTO_ND, "IPPROTO_ND" },
#endif
#ifdef IPPROTO_MTP
{ IPPROTO_MTP, "IPPROTO_MTP" },
#endif
#ifdef IPPROTO_ENCAP
{ IPPROTO_ENCAP, "IPPROTO_ENCAP" },
#endif
#ifdef IPPROTO_PIM
{ IPPROTO_PIM, "IPPROTO_PIM" },
#endif
#ifdef IPPROTO_COMP
{ IPPROTO_COMP, "IPPROTO_COMP" },
#endif
#ifdef IPPROTO_SCTP
{ IPPROTO_SCTP, "IPPROTO_SCTP" },
#endif
#ifdef IPPROTO_UDPLITE
{ IPPROTO_UDPLITE, "IPPROTO_UDPLITE" },
#endif
#ifdef IPPROTO_RAW
{ IPPROTO_RAW, "IPPROTO_RAW" },
#endif
#ifdef IPPROTO_MAX
{ IPPROTO_MAX, "IPPROTO_MAX" },
#endif
{ 0, NULL },
};
static const struct xlat msg_flags[] = {
{ MSG_OOB, "MSG_OOB" },
#ifdef MSG_DONTROUTE
{ MSG_DONTROUTE, "MSG_DONTROUTE" },
#endif
#ifdef MSG_PEEK
{ MSG_PEEK, "MSG_PEEK" },
#endif
#ifdef MSG_CTRUNC
{ MSG_CTRUNC, "MSG_CTRUNC" },
#endif
#ifdef MSG_PROXY
{ MSG_PROXY, "MSG_PROXY" },
#endif
#ifdef MSG_EOR
{ MSG_EOR, "MSG_EOR" },
#endif
#ifdef MSG_WAITALL
{ MSG_WAITALL, "MSG_WAITALL" },
#endif
#ifdef MSG_TRUNC
{ MSG_TRUNC, "MSG_TRUNC" },
#endif
#ifdef MSG_CTRUNC
{ MSG_CTRUNC, "MSG_CTRUNC" },
#endif
#ifdef MSG_ERRQUEUE
{ MSG_ERRQUEUE, "MSG_ERRQUEUE" },
#endif
#ifdef MSG_DONTWAIT
{ MSG_DONTWAIT, "MSG_DONTWAIT" },
#endif
#ifdef MSG_CONFIRM
{ MSG_CONFIRM, "MSG_CONFIRM" },
#endif
#ifdef MSG_PROBE
{ MSG_PROBE, "MSG_PROBE" },
#endif
#ifdef MSG_FIN
{ MSG_FIN, "MSG_FIN" },
#endif
#ifdef MSG_SYN
{ MSG_SYN, "MSG_SYN" },
#endif
#ifdef MSG_RST
{ MSG_RST, "MSG_RST" },
#endif
#ifdef MSG_NOSIGNAL
{ MSG_NOSIGNAL, "MSG_NOSIGNAL" },
#endif
#ifdef MSG_MORE
{ MSG_MORE, "MSG_MORE" },
#endif
#ifdef MSG_WAITFORONE
{ MSG_WAITFORONE, "MSG_WAITFORONE" },
#endif
#ifdef MSG_CMSG_CLOEXEC
{ MSG_CMSG_CLOEXEC, "MSG_CMSG_CLOEXEC" },
#endif
{ 0, NULL },
};
static const struct xlat sockoptions[] = {
#ifdef SO_ACCEPTCONN
{ SO_ACCEPTCONN, "SO_ACCEPTCONN" },
#endif
#ifdef SO_ALLRAW
{ SO_ALLRAW, "SO_ALLRAW" },
#endif
#ifdef SO_ATTACH_FILTER
{ SO_ATTACH_FILTER, "SO_ATTACH_FILTER" },
#endif
#ifdef SO_BINDTODEVICE
{ SO_BINDTODEVICE, "SO_BINDTODEVICE" },
#endif
#ifdef SO_BROADCAST
{ SO_BROADCAST, "SO_BROADCAST" },
#endif
#ifdef SO_BSDCOMPAT
{ SO_BSDCOMPAT, "SO_BSDCOMPAT" },
#endif
#ifdef SO_DEBUG
{ SO_DEBUG, "SO_DEBUG" },
#endif
#ifdef SO_DETACH_FILTER
{ SO_DETACH_FILTER, "SO_DETACH_FILTER" },
#endif
#ifdef SO_DONTROUTE
{ SO_DONTROUTE, "SO_DONTROUTE" },
#endif
#ifdef SO_ERROR
{ SO_ERROR, "SO_ERROR" },
#endif
#ifdef SO_ICS
{ SO_ICS, "SO_ICS" },
#endif
#ifdef SO_IMASOCKET
{ SO_IMASOCKET, "SO_IMASOCKET" },
#endif
#ifdef SO_KEEPALIVE
{ SO_KEEPALIVE, "SO_KEEPALIVE" },
#endif
#ifdef SO_LINGER
{ SO_LINGER, "SO_LINGER" },
#endif
#ifdef SO_LISTENING
{ SO_LISTENING, "SO_LISTENING" },
#endif
#ifdef SO_MGMT
{ SO_MGMT, "SO_MGMT" },
#endif
#ifdef SO_NO_CHECK
{ SO_NO_CHECK, "SO_NO_CHECK" },
#endif
#ifdef SO_OOBINLINE
{ SO_OOBINLINE, "SO_OOBINLINE" },
#endif
#ifdef SO_ORDREL
{ SO_ORDREL, "SO_ORDREL" },
#endif
#ifdef SO_PARALLELSVR
{ SO_PARALLELSVR, "SO_PARALLELSVR" },
#endif
#ifdef SO_PASSCRED
{ SO_PASSCRED, "SO_PASSCRED" },
#endif
#ifdef SO_PEERCRED
{ SO_PEERCRED, "SO_PEERCRED" },
#endif
#ifdef SO_PEERNAME
{ SO_PEERNAME, "SO_PEERNAME" },
#endif
#ifdef SO_PEERSEC
{ SO_PEERSEC, "SO_PEERSEC" },
#endif
#ifdef SO_PRIORITY
{ SO_PRIORITY, "SO_PRIORITY" },
#endif
#ifdef SO_PROTOTYPE
{ SO_PROTOTYPE, "SO_PROTOTYPE" },
#endif
#ifdef SO_RCVBUF
{ SO_RCVBUF, "SO_RCVBUF" },
#endif
#ifdef SO_RCVLOWAT
{ SO_RCVLOWAT, "SO_RCVLOWAT" },
#endif
#ifdef SO_RCVTIMEO
{ SO_RCVTIMEO, "SO_RCVTIMEO" },
#endif
#ifdef SO_RDWR
{ SO_RDWR, "SO_RDWR" },
#endif
#ifdef SO_REUSEADDR
{ SO_REUSEADDR, "SO_REUSEADDR" },
#endif
#ifdef SO_REUSEPORT
{ SO_REUSEPORT, "SO_REUSEPORT" },
#endif
#ifdef SO_SECURITY_AUTHENTICATION
{ SO_SECURITY_AUTHENTICATION,"SO_SECURITY_AUTHENTICATION"},
#endif
#ifdef SO_SECURITY_ENCRYPTION_NETWORK
{ SO_SECURITY_ENCRYPTION_NETWORK,"SO_SECURITY_ENCRYPTION_NETWORK"},
#endif
#ifdef SO_SECURITY_ENCRYPTION_TRANSPORT
{ SO_SECURITY_ENCRYPTION_TRANSPORT,"SO_SECURITY_ENCRYPTION_TRANSPORT"},
#endif
#ifdef SO_SEMA
{ SO_SEMA, "SO_SEMA" },
#endif
#ifdef SO_SNDBUF
{ SO_SNDBUF, "SO_SNDBUF" },
#endif
#ifdef SO_SNDLOWAT
{ SO_SNDLOWAT, "SO_SNDLOWAT" },
#endif
#ifdef SO_SNDTIMEO
{ SO_SNDTIMEO, "SO_SNDTIMEO" },
#endif
#ifdef SO_TIMESTAMP
{ SO_TIMESTAMP, "SO_TIMESTAMP" },
#endif
#ifdef SO_TYPE
{ SO_TYPE, "SO_TYPE" },
#endif
#ifdef SO_USELOOPBACK
{ SO_USELOOPBACK, "SO_USELOOPBACK" },
#endif
{ 0, NULL },
};
#if !defined(SOL_IP) && defined(IPPROTO_IP)
#define SOL_IP IPPROTO_IP
#endif
#ifdef SOL_IP
static const struct xlat sockipoptions[] = {
#ifdef IP_TOS
{ IP_TOS, "IP_TOS" },
#endif
#ifdef IP_TTL
{ IP_TTL, "IP_TTL" },
#endif
#ifdef IP_HDRINCL
{ IP_HDRINCL, "IP_HDRINCL" },
#endif
#ifdef IP_OPTIONS
{ IP_OPTIONS, "IP_OPTIONS" },
#endif
#ifdef IP_ROUTER_ALERT
{ IP_ROUTER_ALERT, "IP_ROUTER_ALERT" },
#endif
#ifdef IP_RECVOPTIONS
{ IP_RECVOPTIONS, "IP_RECVOPTIONS" },
#endif
#ifdef IP_RECVOPTS
{ IP_RECVOPTS, "IP_RECVOPTS" },
#endif
#ifdef IP_RECVRETOPTS
{ IP_RECVRETOPTS, "IP_RECVRETOPTS" },
#endif
#ifdef IP_RECVDSTADDR
{ IP_RECVDSTADDR, "IP_RECVDSTADDR" },
#endif
#ifdef IP_RETOPTS
{ IP_RETOPTS, "IP_RETOPTS" },
#endif
#ifdef IP_PKTINFO
{ IP_PKTINFO, "IP_PKTINFO" },
#endif
#ifdef IP_PKTOPTIONS
{ IP_PKTOPTIONS, "IP_PKTOPTIONS" },
#endif
#ifdef IP_MTU_DISCOVER
{ IP_MTU_DISCOVER, "IP_MTU_DISCOVER" },
#endif
#ifdef IP_RECVERR
{ IP_RECVERR, "IP_RECVERR" },
#endif
#ifdef IP_RECVTTL
{ IP_RECVTTL, "IP_RECVTTL" },
#endif
#ifdef IP_RECVTOS
{ IP_RECVTOS, "IP_RECVTOS" },
#endif
#ifdef IP_MTU
{ IP_MTU, "IP_MTU" },
#endif
#ifdef IP_MULTICAST_IF
{ IP_MULTICAST_IF, "IP_MULTICAST_IF" },
#endif
#ifdef IP_MULTICAST_TTL
{ IP_MULTICAST_TTL, "IP_MULTICAST_TTL" },
#endif
#ifdef IP_MULTICAST_LOOP
{ IP_MULTICAST_LOOP, "IP_MULTICAST_LOOP" },
#endif
#ifdef IP_ADD_MEMBERSHIP
{ IP_ADD_MEMBERSHIP, "IP_ADD_MEMBERSHIP" },
#endif
#ifdef IP_DROP_MEMBERSHIP
{ IP_DROP_MEMBERSHIP, "IP_DROP_MEMBERSHIP" },
#endif
#ifdef IP_BROADCAST_IF
{ IP_BROADCAST_IF, "IP_BROADCAST_IF" },
#endif
#ifdef IP_RECVIFINDEX
{ IP_RECVIFINDEX, "IP_RECVIFINDEX" },
#endif
#ifdef IP_MSFILTER
{ IP_MSFILTER, "IP_MSFILTER" },
#endif
#ifdef MCAST_MSFILTER
{ MCAST_MSFILTER, "MCAST_MSFILTER" },
#endif
#ifdef IP_FREEBIND
{ IP_FREEBIND, "IP_FREEBIND" },
#endif
{ 0, NULL },
};
#endif /* SOL_IP */
#ifdef SOL_IPV6
static const struct xlat sockipv6options[] = {
#ifdef IPV6_ADDRFORM
{ IPV6_ADDRFORM, "IPV6_ADDRFORM" },
#endif
#ifdef MCAST_FILTER
{ MCAST_FILTER, "MCAST_FILTER" },
#endif
#ifdef IPV6_PKTOPTIONS
{ IPV6_PKTOPTIONS, "IPV6_PKTOPTIONS" },
#endif
#ifdef IPV6_MTU
{ IPV6_MTU, "IPV6_MTU" },
#endif
#ifdef IPV6_V6ONLY
{ IPV6_V6ONLY, "IPV6_V6ONLY" },
#endif
#ifdef IPV6_PKTINFO
{ IPV6_PKTINFO, "IPV6_PKTINFO" },
#endif
#ifdef IPV6_HOPLIMIT
{ IPV6_HOPLIMIT, "IPV6_HOPLIMIT" },
#endif
#ifdef IPV6_RTHDR
{ IPV6_RTHDR, "IPV6_RTHDR" },
#endif
#ifdef IPV6_HOPOPTS
{ IPV6_HOPOPTS, "IPV6_HOPOPTS" },
#endif
#ifdef IPV6_DSTOPTS
{ IPV6_DSTOPTS, "IPV6_DSTOPTS" },
#endif
#ifdef IPV6_FLOWINFO
{ IPV6_FLOWINFO, "IPV6_FLOWINFO" },
#endif
#ifdef IPV6_UNICAST_HOPS
{ IPV6_UNICAST_HOPS, "IPV6_UNICAST_HOPS" },
#endif
#ifdef IPV6_MULTICAST_HOPS
{ IPV6_MULTICAST_HOPS, "IPV6_MULTICAST_HOPS" },
#endif
#ifdef IPV6_MULTICAST_LOOP
{ IPV6_MULTICAST_LOOP, "IPV6_MULTICAST_LOOP" },
#endif
#ifdef IPV6_MULTICAST_IF
{ IPV6_MULTICAST_IF, "IPV6_MULTICAST_IF" },
#endif
#ifdef IPV6_MTU_DISCOVER
{ IPV6_MTU_DISCOVER, "IPV6_MTU_DISCOVER" },
#endif
#ifdef IPV6_RECVERR
{ IPV6_RECVERR, "IPV6_RECVERR" },
#endif
#ifdef IPV6_FLOWINFO_SEND
{ IPV6_FLOWINFO_SEND, "IPV6_FLOWINFO_SEND" },
#endif
#ifdef IPV6_ADD_MEMBERSHIP
{ IPV6_ADD_MEMBERSHIP, "IPV6_ADD_MEMBERSHIP" },
#endif
#ifdef IPV6_DROP_MEMBERSHIP
{ IPV6_DROP_MEMBERSHIP, "IPV6_DROP_MEMBERSHIP" },
#endif
#ifdef IPV6_ROUTER_ALERT
{ IPV6_ROUTER_ALERT, "IPV6_ROUTER_ALERT" },
#endif
{ 0, NULL },
};
#endif /* SOL_IPV6 */
#ifdef SOL_IPX
static const struct xlat sockipxoptions[] = {
{ IPX_TYPE, "IPX_TYPE" },
{ 0, NULL },
};
#endif /* SOL_IPX */
#ifdef SOL_RAW
static const struct xlat sockrawoptions[] = {
#if defined(ICMP_FILTER)
{ ICMP_FILTER, "ICMP_FILTER" },
#endif
{ 0, NULL },
};
#endif /* SOL_RAW */
#ifdef SOL_PACKET
static const struct xlat sockpacketoptions[] = {
#ifdef PACKET_ADD_MEMBERSHIP
{ PACKET_ADD_MEMBERSHIP, "PACKET_ADD_MEMBERSHIP" },
#endif
#ifdef PACKET_DROP_MEMBERSHIP
{ PACKET_DROP_MEMBERSHIP, "PACKET_DROP_MEMBERSHIP"},
#endif
#if defined(PACKET_RECV_OUTPUT)
{ PACKET_RECV_OUTPUT, "PACKET_RECV_OUTPUT" },
#endif
#if defined(PACKET_RX_RING)
{ PACKET_RX_RING, "PACKET_RX_RING" },
#endif
#if defined(PACKET_STATISTICS)
{ PACKET_STATISTICS, "PACKET_STATISTICS" },
#endif
#if defined(PACKET_COPY_THRESH)
{ PACKET_COPY_THRESH, "PACKET_COPY_THRESH" },
#endif
#if defined(PACKET_AUXDATA)
{ PACKET_AUXDATA, "PACKET_AUXDATA" },
#endif
#if defined(PACKET_ORIGDEV)
{ PACKET_ORIGDEV, "PACKET_ORIGDEV" },
#endif
#if defined(PACKET_VERSION)
{ PACKET_VERSION, "PACKET_VERSION" },
#endif
#if defined(PACKET_HDRLEN)
{ PACKET_HDRLEN, "PACKET_HDRLEN" },
#endif
#if defined(PACKET_RESERVE)
{ PACKET_RESERVE, "PACKET_RESERVE" },
#endif
#if defined(PACKET_TX_RING)
{ PACKET_TX_RING, "PACKET_TX_RING" },
#endif
#if defined(PACKET_LOSS)
{ PACKET_LOSS, "PACKET_LOSS" },
#endif
{ 0, NULL },
};
#endif /* SOL_PACKET */
#ifdef SOL_SCTP
static const struct xlat socksctpoptions[] = {
#if defined(SCTP_RTOINFO)
{ SCTP_RTOINFO, "SCTP_RTOINFO" },
#endif
#if defined(SCTP_ASSOCINFO)
{ SCTP_ASSOCINFO, "SCTP_ASSOCINFO"},
#endif
#if defined(SCTP_INITMSG)
{ SCTP_INITMSG, "SCTP_INITMSG" },
#endif
#if defined(SCTP_NODELAY)
{ SCTP_NODELAY, "SCTP_NODELAY" },
#endif
#if defined(SCTP_AUTOCLOSE)
{ SCTP_AUTOCLOSE, "SCTP_AUTOCLOSE"},
#endif
#if defined(SCTP_SET_PEER_PRIMARY_ADDR)
{ SCTP_SET_PEER_PRIMARY_ADDR, "SCTP_SET_PEER_PRIMARY_ADDR"},
#endif
#if defined(SCTP_PRIMARY_ADDR)
{ SCTP_PRIMARY_ADDR, "SCTP_PRIMARY_ADDR" },
#endif
#if defined(SCTP_ADAPTATION_LAYER)
{ SCTP_ADAPTATION_LAYER, "SCTP_ADAPTATION_LAYER" },
#endif
#if defined(SCTP_DISABLE_FRAGMENTS)
{ SCTP_DISABLE_FRAGMENTS, "SCTP_DISABLE_FRAGMENTS"},
#endif
#if defined(SCTP_PEER_ADDR_PARAMS)
{ SCTP_PEER_ADDR_PARAMS, "SCTP_PEER_ADDR_PARAMS" },
#endif
#if defined(SCTP_DEFAULT_SEND_PARAM)
{ SCTP_DEFAULT_SEND_PARAM, "SCTP_DEFAULT_SEND_PARAM"},
#endif
#if defined(SCTP_EVENTS)
{ SCTP_EVENTS, "SCTP_EVENTS" },
#endif
#if defined(SCTP_I_WANT_MAPPED_V4_ADDR)
{ SCTP_I_WANT_MAPPED_V4_ADDR, "SCTP_I_WANT_MAPPED_V4_ADDR"},
#endif
#if defined(SCTP_MAXSEG)
{ SCTP_MAXSEG, "SCTP_MAXSEG" },
#endif
#if defined(SCTP_STATUS)
{ SCTP_STATUS, "SCTP_STATUS" },
#endif
#if defined(SCTP_GET_PEER_ADDR_INFO)
{ SCTP_GET_PEER_ADDR_INFO, "SCTP_GET_PEER_ADDR_INFO"},
#endif
#if defined(SCTP_DELAYED_ACK)
{ SCTP_DELAYED_ACK, "SCTP_DELAYED_ACK" },
#endif
#if defined(SCTP_CONTEXT)
{ SCTP_CONTEXT, "SCTP_CONTEXT" },
#endif
#if defined(SCTP_FRAGMENT_INTERLEAVE)
{ SCTP_FRAGMENT_INTERLEAVE, "SCTP_FRAGMENT_INTERLEAVE"},
#endif
#if defined(SCTP_PARTIAL_DELIVERY_POINT)