2
* Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
3
* Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4
* Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
5
* Copyright (c) 1996-2000 Wichert Akkerman <wichert@cistron.nl>
8
* Redistribution and use in source and binary forms, with or without
9
* modification, are permitted provided that the following conditions
11
* 1. Redistributions of source code must retain the above copyright
12
* notice, this list of conditions and the following disclaimer.
13
* 2. Redistributions in binary form must reproduce the above copyright
14
* notice, this list of conditions and the following disclaimer in the
15
* documentation and/or other materials provided with the distribution.
16
* 3. The name of the author may not be used to endorse or promote products
17
* derived from this software without specific prior written permission.
19
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
#include <sys/socket.h>
39
#if defined(HAVE_SIN6_SCOPE_ID_LINUX)
40
#define in6_addr in6_addr_libc
41
#define ipv6_mreq ipv6_mreq_libc
42
#define sockaddr_in6 sockaddr_in6_libc
45
#include <netinet/in.h>
46
#ifdef HAVE_NETINET_TCP_H
47
#include <netinet/tcp.h>
49
#ifdef HAVE_NETINET_UDP_H
50
#include <netinet/udp.h>
52
#ifdef HAVE_NETINET_SCTP_H
53
#include <netinet/sctp.h>
55
#include <arpa/inet.h>
58
#include <asm/types.h>
59
#if defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC__ + __GLIBC_MINOR__ >= 3)
60
# include <netipx/ipx.h>
62
# include <linux/ipx.h>
66
#if defined (__GLIBC__) && (((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1)) || defined(HAVE_SIN6_SCOPE_ID_LINUX))
67
#if defined(HAVE_LINUX_IN6_H)
68
#if defined(HAVE_SIN6_SCOPE_ID_LINUX)
72
#define in6_addr in6_addr_kernel
73
#define ipv6_mreq ipv6_mreq_kernel
74
#define sockaddr_in6 sockaddr_in6_kernel
76
#include <linux/in6.h>
77
#if defined(HAVE_SIN6_SCOPE_ID_LINUX)
81
#define in6_addr in6_addr_libc
82
#define ipv6_mreq ipv6_mreq_libc
83
#define sockaddr_in6 sockaddr_in6_kernel
88
#if defined(HAVE_SYS_UIO_H)
92
#if defined(HAVE_LINUX_NETLINK_H)
93
#include <linux/netlink.h>
96
#if defined(HAVE_LINUX_IF_PACKET_H)
97
#include <linux/if_packet.h>
100
#if defined(HAVE_LINUX_ICMP_H)
101
#include <linux/icmp.h>
105
#define PF_UNSPEC AF_UNSPEC
109
#define HAVE_SENDMSG 1 /* HACK - *FIXME* */
113
/* Under Linux these are enums so we can't test for them with ifdef. */
114
#define IPPROTO_EGP IPPROTO_EGP
115
#define IPPROTO_PUP IPPROTO_PUP
116
#define IPPROTO_IDP IPPROTO_IDP
117
#define IPPROTO_IGMP IPPROTO_IGMP
118
#define IPPROTO_RAW IPPROTO_RAW
119
#define IPPROTO_MAX IPPROTO_MAX
124
extern void CDE_begin_socket_bind_or_connect(struct tcb* tcp);
127
static const struct xlat domains[] = {
129
{ PF_AAL5, "PF_AAL5" },
132
{ PF_APPLETALK, "PF_APPLETALK" },
135
{ PF_ASH, "PF_ASH" },
138
{ PF_ATMPVC, "PF_ATMPVC" },
141
{ PF_ATMSVC, "PF_ATMSVC" },
144
{ PF_AX25, "PF_AX25" },
147
{ PF_BLUETOOTH, "PF_BLUETOOTH" },
150
{ PF_BRIDGE, "PF_BRIDGE" },
153
{ PF_DECnet, "PF_DECnet" },
156
{ PF_DECNET, "PF_DECNET" },
159
{ PF_ECONET, "PF_ECONET" },
162
{ PF_FILE, "PF_FILE" },
165
{ PF_IMPLINK, "PF_IMPLINK" },
168
{ PF_INET, "PF_INET" },
171
{ PF_INET6, "PF_INET6" },
174
{ PF_IPX, "PF_IPX" },
177
{ PF_IRDA, "PF_IRDA" },
180
{ PF_ISO, "PF_ISO" },
183
{ PF_KEY, "PF_KEY" },
186
{ PF_UNIX, "PF_UNIX" },
189
{ PF_LOCAL, "PF_LOCAL" },
192
{ PF_NETBEUI, "PF_NETBEUI" },
195
{ PF_NETLINK, "PF_NETLINK" },
198
{ PF_NETROM, "PF_NETROM" },
201
{ PF_PACKET, "PF_PACKET" },
204
{ PF_PPPOX, "PF_PPPOX" },
207
{ PF_ROSE, "PF_ROSE" },
210
{ PF_ROUTE, "PF_ROUTE" },
213
{ PF_SECURITY, "PF_SECURITY" },
216
{ PF_SNA, "PF_SNA" },
219
{ PF_UNSPEC, "PF_UNSPEC" },
222
{ PF_WANPIPE, "PF_WANPIPE" },
225
{ PF_X25, "PF_X25" },
229
const struct xlat addrfams[] = {
231
{ AF_APPLETALK, "AF_APPLETALK" },
234
{ AF_ASH, "AF_ASH" },
237
{ AF_ATMPVC, "AF_ATMPVC" },
240
{ AF_ATMSVC, "AF_ATMSVC" },
243
{ AF_AX25, "AF_AX25" },
246
{ AF_BLUETOOTH, "AF_BLUETOOTH" },
249
{ AF_BRIDGE, "AF_BRIDGE" },
252
{ AF_DECnet, "AF_DECnet" },
255
{ AF_ECONET, "AF_ECONET" },
258
{ AF_FILE, "AF_FILE" },
261
{ AF_IMPLINK, "AF_IMPLINK" },
264
{ AF_INET, "AF_INET" },
267
{ AF_INET6, "AF_INET6" },
270
{ AF_IPX, "AF_IPX" },
273
{ AF_IRDA, "AF_IRDA" },
276
{ AF_ISO, "AF_ISO" },
279
{ AF_KEY, "AF_KEY" },
282
{ AF_UNIX, "AF_UNIX" },
285
{ AF_LOCAL, "AF_LOCAL" },
288
{ AF_NETBEUI, "AF_NETBEUI" },
291
{ AF_NETLINK, "AF_NETLINK" },
294
{ AF_NETROM, "AF_NETROM" },
297
{ AF_PACKET, "AF_PACKET" },
300
{ AF_PPPOX, "AF_PPPOX" },
303
{ AF_ROSE, "AF_ROSE" },
306
{ AF_ROUTE, "AF_ROUTE" },
309
{ AF_SECURITY, "AF_SECURITY" },
312
{ AF_SNA, "AF_SNA" },
315
{ AF_UNSPEC, "AF_UNSPEC" },
318
{ AF_WANPIPE, "AF_WANPIPE" },
321
{ AF_X25, "AF_X25" },
325
static const struct xlat socktypes[] = {
326
{ SOCK_STREAM, "SOCK_STREAM" },
327
{ SOCK_DGRAM, "SOCK_DGRAM" },
329
{ SOCK_RAW, "SOCK_RAW" },
332
{ SOCK_RDM, "SOCK_RDM" },
334
#ifdef SOCK_SEQPACKET
335
{ SOCK_SEQPACKET,"SOCK_SEQPACKET"},
338
{ SOCK_DCCP, "SOCK_DCCP" },
341
{ SOCK_PACKET, "SOCK_PACKET" },
345
static const struct xlat sock_type_flags[] = {
347
{ SOCK_CLOEXEC, "SOCK_CLOEXEC" },
350
{ SOCK_NONBLOCK,"SOCK_NONBLOCK" },
354
#ifndef SOCK_TYPE_MASK
355
# define SOCK_TYPE_MASK 0xf
357
static const struct xlat socketlayers[] = {
359
{ SOL_IP, "SOL_IP" },
361
#if defined(SOL_ICMP)
362
{ SOL_ICMP, "SOL_ICMP" },
365
{ SOL_TCP, "SOL_TCP" },
368
{ SOL_UDP, "SOL_UDP" },
370
#if defined(SOL_IPV6)
371
{ SOL_IPV6, "SOL_IPV6" },
373
#if defined(SOL_ICMPV6)
374
{ SOL_ICMPV6, "SOL_ICMPV6" },
376
#if defined(SOL_SCTP)
377
{ SOL_SCTP, "SOL_SCTP" },
379
#if defined(SOL_UDPLITE)
380
{ SOL_UDPLITE, "SOL_UDPLITE" },
383
{ SOL_RAW, "SOL_RAW" },
386
{ SOL_IPX, "SOL_IPX" },
388
#if defined(SOL_AX25)
389
{ SOL_AX25, "SOL_AX25" },
391
#if defined(SOL_ATALK)
392
{ SOL_ATALK, "SOL_ATALK" },
394
#if defined(SOL_NETROM)
395
{ SOL_NETROM, "SOL_NETROM" },
397
#if defined(SOL_ROSE)
398
{ SOL_ROSE, "SOL_ROSE" },
400
#if defined(SOL_DECNET)
401
{ SOL_DECNET, "SOL_DECNET" },
404
{ SOL_X25, "SOL_X25" },
406
#if defined(SOL_PACKET)
407
{ SOL_PACKET, "SOL_PACKET" },
410
{ SOL_ATM, "SOL_ATM" },
413
{ SOL_AAL, "SOL_AAL" },
415
#if defined(SOL_IRDA)
416
{ SOL_IRDA, "SOL_IRDA" },
418
#if defined(SOL_NETBEUI)
419
{ SOL_NETBEUI, "SOL_NETBEUI" },
422
{ SOL_LLC, "SOL_LLC" },
424
#if defined(SOL_DCCP)
425
{ SOL_DCCP, "SOL_DCCP" },
427
#if defined(SOL_NETLINK)
428
{ SOL_NETLINK, "SOL_NETLINK" },
430
#if defined(SOL_TIPC)
431
{ SOL_TIPC, "SOL_TIPC" },
433
#if defined(SOL_RXRPC)
434
{ SOL_RXRPC, "SOL_RXRPC" },
436
#if defined(SOL_PPPOL2TP)
437
{ SOL_PPPOL2TP, "SOL_PPPOL2TP" },
439
#if defined(SOL_BLUETOOTH)
440
{ SOL_BLUETOOTH,"SOL_BLUETOOTH" },
442
#if defined(SOL_PNPIPE)
443
{ SOL_PNPIPE, "SOL_PNPIPE" },
446
{ SOL_RDS, "SOL_RDS" },
448
#if defined(SOL_IUVC)
449
{ SOL_IUCV, "SOL_IUCV" },
451
#if defined(SOL_CAIF)
452
{ SOL_CAIF, "SOL_CAIF" },
454
{ SOL_SOCKET, "SOL_SOCKET" }, /* Never used! */
455
/* The SOL_* array should remain not NULL-terminated. */
457
/*** WARNING: DANGER WILL ROBINSON: NOTE "socketlayers" array above
458
falls into "protocols" array below!!!! This is intended!!! ***/
459
static const struct xlat protocols[] = {
460
{ IPPROTO_IP, "IPPROTO_IP" },
461
{ IPPROTO_ICMP, "IPPROTO_ICMP" },
462
{ IPPROTO_TCP, "IPPROTO_TCP" },
463
{ IPPROTO_UDP, "IPPROTO_UDP" },
465
{ IPPROTO_IGMP, "IPPROTO_IGMP" },
468
{ IPPROTO_GGP, "IPPROTO_GGP" },
471
{ IPPROTO_IPIP, "IPPROTO_IPIP" },
474
{ IPPROTO_EGP, "IPPROTO_EGP" },
477
{ IPPROTO_PUP, "IPPROTO_PUP" },
480
{ IPPROTO_IDP, "IPPROTO_IDP" },
483
{ IPPROTO_TP, "IPPROTO_TP" },
486
{ IPPROTO_DCCP, "IPPROTO_DCCP" },
489
{ IPPROTO_IPV6, "IPPROTO_IPV6" },
491
#ifdef IPPROTO_ROUTING
492
{ IPPROTO_ROUTING, "IPPROTO_ROUTING" },
494
#ifdef IPPROTO_FRAGMENT
495
{ IPPROTO_FRAGMENT, "IPPROTO_FRAGMENT" },
498
{ IPPROTO_RSVP, "IPPROTO_RSVP" },
501
{ IPPROTO_GRE, "IPPROTO_GRE" },
504
{ IPPROTO_ESP, "IPPROTO_ESP" },
507
{ IPPROTO_AH, "IPPROTO_AH" },
509
#ifdef IPPROTO_ICMPV6
510
{ IPPROTO_ICMPV6, "IPPROTO_ICMPV6" },
513
{ IPPROTO_NONE, "IPPROTO_NONE" },
515
#ifdef IPPROTO_DSTOPTS
516
{ IPPROTO_DSTOPTS, "IPPROTO_DSTOPTS" },
519
{ IPPROTO_HELLO, "IPPROTO_HELLO" },
522
{ IPPROTO_ND, "IPPROTO_ND" },
525
{ IPPROTO_MTP, "IPPROTO_MTP" },
528
{ IPPROTO_ENCAP, "IPPROTO_ENCAP" },
531
{ IPPROTO_PIM, "IPPROTO_PIM" },
534
{ IPPROTO_COMP, "IPPROTO_COMP" },
537
{ IPPROTO_SCTP, "IPPROTO_SCTP" },
539
#ifdef IPPROTO_UDPLITE
540
{ IPPROTO_UDPLITE, "IPPROTO_UDPLITE" },
543
{ IPPROTO_RAW, "IPPROTO_RAW" },
546
{ IPPROTO_MAX, "IPPROTO_MAX" },
550
static const struct xlat msg_flags[] = {
551
{ MSG_OOB, "MSG_OOB" },
553
{ MSG_DONTROUTE, "MSG_DONTROUTE" },
556
{ MSG_PEEK, "MSG_PEEK" },
559
{ MSG_CTRUNC, "MSG_CTRUNC" },
562
{ MSG_PROXY, "MSG_PROXY" },
565
{ MSG_EOR, "MSG_EOR" },
568
{ MSG_WAITALL, "MSG_WAITALL" },
571
{ MSG_TRUNC, "MSG_TRUNC" },
574
{ MSG_CTRUNC, "MSG_CTRUNC" },
577
{ MSG_ERRQUEUE, "MSG_ERRQUEUE" },
580
{ MSG_DONTWAIT, "MSG_DONTWAIT" },
583
{ MSG_CONFIRM, "MSG_CONFIRM" },
586
{ MSG_PROBE, "MSG_PROBE" },
589
{ MSG_FIN, "MSG_FIN" },
592
{ MSG_SYN, "MSG_SYN" },
595
{ MSG_RST, "MSG_RST" },
598
{ MSG_NOSIGNAL, "MSG_NOSIGNAL" },
601
{ MSG_MORE, "MSG_MORE" },
603
#ifdef MSG_CMSG_CLOEXEC
604
{ MSG_CMSG_CLOEXEC, "MSG_CMSG_CLOEXEC" },
609
static const struct xlat sockoptions[] = {
611
{ SO_ACCEPTCONN, "SO_ACCEPTCONN" },
614
{ SO_ALLRAW, "SO_ALLRAW" },
616
#ifdef SO_ATTACH_FILTER
617
{ SO_ATTACH_FILTER, "SO_ATTACH_FILTER" },
619
#ifdef SO_BINDTODEVICE
620
{ SO_BINDTODEVICE, "SO_BINDTODEVICE" },
623
{ SO_BROADCAST, "SO_BROADCAST" },
626
{ SO_BSDCOMPAT, "SO_BSDCOMPAT" },
629
{ SO_DEBUG, "SO_DEBUG" },
631
#ifdef SO_DETACH_FILTER
632
{ SO_DETACH_FILTER, "SO_DETACH_FILTER" },
635
{ SO_DONTROUTE, "SO_DONTROUTE" },
638
{ SO_ERROR, "SO_ERROR" },
641
{ SO_ICS, "SO_ICS" },
644
{ SO_IMASOCKET, "SO_IMASOCKET" },
647
{ SO_KEEPALIVE, "SO_KEEPALIVE" },
650
{ SO_LINGER, "SO_LINGER" },
653
{ SO_LISTENING, "SO_LISTENING" },
656
{ SO_MGMT, "SO_MGMT" },
659
{ SO_NO_CHECK, "SO_NO_CHECK" },
662
{ SO_OOBINLINE, "SO_OOBINLINE" },
665
{ SO_ORDREL, "SO_ORDREL" },
667
#ifdef SO_PARALLELSVR
668
{ SO_PARALLELSVR, "SO_PARALLELSVR" },
671
{ SO_PASSCRED, "SO_PASSCRED" },
674
{ SO_PEERCRED, "SO_PEERCRED" },
677
{ SO_PEERNAME, "SO_PEERNAME" },
680
{ SO_PEERSEC, "SO_PEERSEC" },
683
{ SO_PRIORITY, "SO_PRIORITY" },
686
{ SO_PROTOTYPE, "SO_PROTOTYPE" },
689
{ SO_RCVBUF, "SO_RCVBUF" },
692
{ SO_RCVLOWAT, "SO_RCVLOWAT" },
695
{ SO_RCVTIMEO, "SO_RCVTIMEO" },
698
{ SO_RDWR, "SO_RDWR" },
701
{ SO_REUSEADDR, "SO_REUSEADDR" },
704
{ SO_REUSEPORT, "SO_REUSEPORT" },
706
#ifdef SO_SECURITY_AUTHENTICATION
707
{ SO_SECURITY_AUTHENTICATION,"SO_SECURITY_AUTHENTICATION"},
709
#ifdef SO_SECURITY_ENCRYPTION_NETWORK
710
{ SO_SECURITY_ENCRYPTION_NETWORK,"SO_SECURITY_ENCRYPTION_NETWORK"},
712
#ifdef SO_SECURITY_ENCRYPTION_TRANSPORT
713
{ SO_SECURITY_ENCRYPTION_TRANSPORT,"SO_SECURITY_ENCRYPTION_TRANSPORT"},
716
{ SO_SEMA, "SO_SEMA" },
719
{ SO_SNDBUF, "SO_SNDBUF" },
722
{ SO_SNDLOWAT, "SO_SNDLOWAT" },
725
{ SO_SNDTIMEO, "SO_SNDTIMEO" },
728
{ SO_TIMESTAMP, "SO_TIMESTAMP" },
731
{ SO_TYPE, "SO_TYPE" },
733
#ifdef SO_USELOOPBACK
734
{ SO_USELOOPBACK, "SO_USELOOPBACK" },
739
#if !defined (SOL_IP) && defined (IPPROTO_IP)
740
#define SOL_IP IPPROTO_IP
744
static const struct xlat sockipoptions[] = {
746
{ IP_TOS, "IP_TOS" },
749
{ IP_TTL, "IP_TTL" },
752
{ IP_HDRINCL, "IP_HDRINCL" },
755
{ IP_OPTIONS, "IP_OPTIONS" },
757
#ifdef IP_ROUTER_ALERT
758
{ IP_ROUTER_ALERT, "IP_ROUTER_ALERT" },
760
#ifdef IP_RECVOPTIONS
761
{ IP_RECVOPTIONS, "IP_RECVOPTIONS" },
764
{ IP_RECVOPTS, "IP_RECVOPTS" },
766
#ifdef IP_RECVRETOPTS
767
{ IP_RECVRETOPTS, "IP_RECVRETOPTS" },
769
#ifdef IP_RECVDSTADDR
770
{ IP_RECVDSTADDR, "IP_RECVDSTADDR" },
773
{ IP_RETOPTS, "IP_RETOPTS" },
776
{ IP_PKTINFO, "IP_PKTINFO" },
779
{ IP_PKTOPTIONS, "IP_PKTOPTIONS" },
781
#ifdef IP_MTU_DISCOVER
782
{ IP_MTU_DISCOVER, "IP_MTU_DISCOVER" },
785
{ IP_RECVERR, "IP_RECVERR" },
788
{ IP_RECVTTL, "IP_RECVTTL" },
791
{ IP_RECVTOS, "IP_RECVTOS" },
794
{ IP_MTU, "IP_MTU" },
796
#ifdef IP_MULTICAST_IF
797
{ IP_MULTICAST_IF, "IP_MULTICAST_IF" },
799
#ifdef IP_MULTICAST_TTL
800
{ IP_MULTICAST_TTL, "IP_MULTICAST_TTL" },
802
#ifdef IP_MULTICAST_LOOP
803
{ IP_MULTICAST_LOOP, "IP_MULTICAST_LOOP" },
805
#ifdef IP_ADD_MEMBERSHIP
806
{ IP_ADD_MEMBERSHIP, "IP_ADD_MEMBERSHIP" },
808
#ifdef IP_DROP_MEMBERSHIP
809
{ IP_DROP_MEMBERSHIP, "IP_DROP_MEMBERSHIP" },
811
#ifdef IP_BROADCAST_IF
812
{ IP_BROADCAST_IF, "IP_BROADCAST_IF" },
814
#ifdef IP_RECVIFINDEX
815
{ IP_RECVIFINDEX, "IP_RECVIFINDEX" },
818
{ IP_MSFILTER, "IP_MSFILTER" },
820
#ifdef MCAST_MSFILTER
821
{ MCAST_MSFILTER, "MCAST_MSFILTER" },
824
{ IP_FREEBIND, "IP_FREEBIND" },
831
static const struct xlat sockipv6options[] = {
833
{ IPV6_ADDRFORM, "IPV6_ADDRFORM" },
836
{ MCAST_FILTER, "MCAST_FILTER" },
838
#ifdef IPV6_PKTOPTIONS
839
{ IPV6_PKTOPTIONS, "IPV6_PKTOPTIONS" },
842
{ IPV6_MTU, "IPV6_MTU" },
845
{ IPV6_V6ONLY, "IPV6_V6ONLY" },
848
{ IPV6_PKTINFO, "IPV6_PKTINFO" },
851
{ IPV6_HOPLIMIT, "IPV6_HOPLIMIT" },
854
{ IPV6_RTHDR, "IPV6_RTHDR" },
857
{ IPV6_HOPOPTS, "IPV6_HOPOPTS" },
860
{ IPV6_DSTOPTS, "IPV6_DSTOPTS" },
863
{ IPV6_FLOWINFO, "IPV6_FLOWINFO" },
865
#ifdef IPV6_UNICAST_HOPS
866
{ IPV6_UNICAST_HOPS, "IPV6_UNICAST_HOPS" },
868
#ifdef IPV6_MULTICAST_HOPS
869
{ IPV6_MULTICAST_HOPS, "IPV6_MULTICAST_HOPS" },
871
#ifdef IPV6_MULTICAST_LOOP
872
{ IPV6_MULTICAST_LOOP, "IPV6_MULTICAST_LOOP" },
874
#ifdef IPV6_MULTICAST_IF
875
{ IPV6_MULTICAST_IF, "IPV6_MULTICAST_IF" },
877
#ifdef IPV6_MTU_DISCOVER
878
{ IPV6_MTU_DISCOVER, "IPV6_MTU_DISCOVER" },
881
{ IPV6_RECVERR, "IPV6_RECVERR" },
883
#ifdef IPV6_FLOWINFO_SEND
884
{ IPV6_FLOWINFO_SEND, "IPV6_FLOWINFO_SEND" },
886
#ifdef IPV6_ADD_MEMBERSHIP
887
{ IPV6_ADD_MEMBERSHIP, "IPV6_ADD_MEMBERSHIP" },
889
#ifdef IPV6_DROP_MEMBERSHIP
890
{ IPV6_DROP_MEMBERSHIP, "IPV6_DROP_MEMBERSHIP" },
892
#ifdef IPV6_ROUTER_ALERT
893
{ IPV6_ROUTER_ALERT, "IPV6_ROUTER_ALERT" },
897
#endif /* SOL_IPV6 */
900
static const struct xlat sockipxoptions[] = {
901
{ IPX_TYPE, "IPX_TYPE" },
907
static const struct xlat sockrawoptions[] = {
908
#if defined(ICMP_FILTER)
909
{ ICMP_FILTER, "ICMP_FILTER" },
916
static const struct xlat sockpacketoptions[] = {
917
#ifdef PACKET_ADD_MEMBERSHIP
918
{ PACKET_ADD_MEMBERSHIP, "PACKET_ADD_MEMBERSHIP" },
920
#ifdef PACKET_DROP_MEMBERSHIP
921
{ PACKET_DROP_MEMBERSHIP, "PACKET_DROP_MEMBERSHIP"},
923
#if defined(PACKET_RECV_OUTPUT)
924
{ PACKET_RECV_OUTPUT, "PACKET_RECV_OUTPUT" },
926
#if defined(PACKET_RX_RING)
927
{ PACKET_RX_RING, "PACKET_RX_RING" },
929
#if defined(PACKET_STATISTICS)
930
{ PACKET_STATISTICS, "PACKET_STATISTICS" },
932
#if defined(PACKET_COPY_THRESH)
933
{ PACKET_COPY_THRESH, "PACKET_COPY_THRESH" },
935
#if defined(PACKET_AUXDATA)
936
{ PACKET_AUXDATA, "PACKET_AUXDATA" },
938
#if defined(PACKET_ORIGDEV)
939
{ PACKET_ORIGDEV, "PACKET_ORIGDEV" },
941
#if defined(PACKET_VERSION)
942
{ PACKET_VERSION, "PACKET_VERSION" },
944
#if defined(PACKET_HDRLEN)
945
{ PACKET_HDRLEN, "PACKET_HDRLEN" },
947
#if defined(PACKET_RESERVE)
948
{ PACKET_RESERVE, "PACKET_RESERVE" },
950
#if defined(PACKET_TX_RING)
951
{ PACKET_TX_RING, "PACKET_TX_RING" },
953
#if defined(PACKET_LOSS)
954
{ PACKET_LOSS, "PACKET_LOSS" },
958
#endif /* SOL_PACKET */
961
static const struct xlat socksctpoptions[] = {
962
#if defined(SCTP_RTOINFO)
963
{ SCTP_RTOINFO, "SCTP_RTOINFO" },
965
#if defined(SCTP_ASSOCINFO)
966
{ SCTP_ASSOCINFO, "SCTP_ASSOCINFO"},
968
#if defined(SCTP_INITMSG)
969
{ SCTP_INITMSG, "SCTP_INITMSG" },
971
#if defined(SCTP_NODELAY)
972
{ SCTP_NODELAY, "SCTP_NODELAY" },
974
#if defined(SCTP_AUTOCLOSE)
975
{ SCTP_AUTOCLOSE, "SCTP_AUTOCLOSE"},
977
#if defined(SCTP_SET_PEER_PRIMARY_ADDR)
978
{ SCTP_SET_PEER_PRIMARY_ADDR, "SCTP_SET_PEER_PRIMARY_ADDR"},
980
#if defined(SCTP_PRIMARY_ADDR)
981
{ SCTP_PRIMARY_ADDR, "SCTP_PRIMARY_ADDR" },
983
#if defined(SCTP_ADAPTATION_LAYER)
984
{ SCTP_ADAPTATION_LAYER, "SCTP_ADAPTATION_LAYER" },
986
#if defined(SCTP_DISABLE_FRAGMENTS)
987
{ SCTP_DISABLE_FRAGMENTS, "SCTP_DISABLE_FRAGMENTS"},
989
#if defined(SCTP_PEER_ADDR_PARAMS)
990
{ SCTP_PEER_ADDR_PARAMS, "SCTP_PEER_ADDR_PARAMS" },
992
#if defined(SCTP_DEFAULT_SEND_PARAM)
993
{ SCTP_DEFAULT_SEND_PARAM, "SCTP_DEFAULT_SEND_PARAM"},
995
#if defined(SCTP_EVENTS)
996
{ SCTP_EVENTS, "SCTP_EVENTS" },
998
#if defined(SCTP_I_WANT_MAPPED_V4_ADDR)
999
{ SCTP_I_WANT_MAPPED_V4_ADDR, "SCTP_I_WANT_MAPPED_V4_ADDR"},
1001
#if defined(SCTP_MAXSEG)
1002
{ SCTP_MAXSEG, "SCTP_MAXSEG" },
1004
#if defined(SCTP_STATUS)
1005
{ SCTP_STATUS, "SCTP_STATUS" },
1007
#if defined(SCTP_GET_PEER_ADDR_INFO)
1008
{ SCTP_GET_PEER_ADDR_INFO, "SCTP_GET_PEER_ADDR_INFO"},
1010
#if defined(SCTP_DELAYED_ACK)
1011
{ SCTP_DELAYED_ACK, "SCTP_DELAYED_ACK" },
1013
#if defined(SCTP_CONTEXT)
1014
{ SCTP_CONTEXT, "SCTP_CONTEXT" },
1016
#if defined(SCTP_FRAGMENT_INTERLEAVE)
1017
{ SCTP_FRAGMENT_INTERLEAVE, "SCTP_FRAGMENT_INTERLEAVE"},
1019
#if defined(SCTP_PARTIAL_DELIVERY_POINT)
1020
{ SCTP_PARTIAL_DELIVERY_POINT, "SCTP_PARTIAL_DELIVERY_POINT"},
1022
#if defined(SCTP_MAX_BURST)
1023
{ SCTP_MAX_BURST, "SCTP_MAX_BURST" },
1025
#if defined(SCTP_AUTH_CHUNK)
1026
{ SCTP_AUTH_CHUNK, "SCTP_AUTH_CHUNK" },
1028
#if defined(SCTP_HMAC_IDENT)
1029
{ SCTP_HMAC_IDENT, "SCTP_HMAC_IDENT" },
1031
#if defined(SCTP_AUTH_KEY)
1032
{ SCTP_AUTH_KEY, "SCTP_AUTH_KEY" },
1034
#if defined(SCTP_AUTH_ACTIVE_KEY)
1035
{ SCTP_AUTH_ACTIVE_KEY, "SCTP_AUTH_ACTIVE_KEY" },
1037
#if defined(SCTP_AUTH_DELETE_KEY)
1038
{ SCTP_AUTH_DELETE_KEY, "SCTP_AUTH_DELETE_KEY" },
1040
#if defined(SCTP_PEER_AUTH_CHUNKS)
1041
{ SCTP_PEER_AUTH_CHUNKS, "SCTP_PEER_AUTH_CHUNKS" },
1043
#if defined(SCTP_LOCAL_AUTH_CHUNKS)
1044
{ SCTP_LOCAL_AUTH_CHUNKS, "SCTP_LOCAL_AUTH_CHUNKS"},
1046
#if defined(SCTP_GET_ASSOC_NUMBER)
1047
{ SCTP_GET_ASSOC_NUMBER, "SCTP_GET_ASSOC_NUMBER" },
1050
/* linux specific things */
1051
#if defined(SCTP_SOCKOPT_BINDX_ADD)
1052
{ SCTP_SOCKOPT_BINDX_ADD, "SCTP_SOCKOPT_BINDX_ADD" },
1054
#if defined(SCTP_SOCKOPT_BINDX_REM)
1055
{ SCTP_SOCKOPT_BINDX_REM, "SCTP_SOCKOPT_BINDX_REM" },
1057
#if defined(SCTP_SOCKOPT_PEELOFF)
1058
{ SCTP_SOCKOPT_PEELOFF, "SCTP_SOCKOPT_PEELOFF" },
1060
#if defined(SCTP_GET_PEER_ADDRS_NUM_OLD)
1061
{ SCTP_GET_PEER_ADDRS_NUM_OLD, "SCTP_GET_PEER_ADDRS_NUM_OLD" },
1063
#if defined(SCTP_GET_PEER_ADDRS_OLD)
1064
{ SCTP_GET_PEER_ADDRS_OLD, "SCTP_GET_PEER_ADDRS_OLD" },
1066
#if defined(SCTP_GET_LOCAL_ADDRS_NUM_OLD)
1067
{ SCTP_GET_LOCAL_ADDRS_NUM_OLD, "SCTP_GET_LOCAL_ADDRS_NUM_OLD" },
1069
#if defined(SCTP_GET_LOCAL_ADDRS_OLD)
1070
{ SCTP_GET_LOCAL_ADDRS_OLD, "SCTP_GET_LOCAL_ADDRS_OLD" },
1072
#if defined(SCTP_SOCKOPT_CONNECTX_OLD)
1073
{ SCTP_SOCKOPT_CONNECTX_OLD, "SCTP_SOCKOPT_CONNECTX_OLD" },
1075
#if defined(SCTP_GET_PEER_ADDRS)
1076
{ SCTP_GET_PEER_ADDRS, "SCTP_GET_PEER_ADDRS" },
1078
#if defined(SCTP_GET_LOCAL_ADDRS)
1079
{ SCTP_GET_LOCAL_ADDRS, "SCTP_GET_LOCAL_ADDRS" },
1086
#if !defined (SOL_TCP) && defined (IPPROTO_TCP)
1087
#define SOL_TCP IPPROTO_TCP
1091
static const struct xlat socktcpoptions[] = {
1092
{ TCP_NODELAY, "TCP_NODELAY" },
1093
{ TCP_MAXSEG, "TCP_MAXSEG" },
1094
#if defined(TCP_CORK)
1095
{ TCP_CORK, "TCP_CORK" },
1097
#if defined(TCP_KEEPIDLE)
1098
{ TCP_KEEPIDLE, "TCP_KEEPIDLE" },
1100
#if defined(TCP_KEEPINTVL)
1101
{ TCP_KEEPINTVL, "TCP_KEEPINTVL" },
1103
#if defined(TCP_KEEPCNT)
1104
{ TCP_KEEPCNT, "TCP_KEEPCNT" },
1106
#if defined(TCP_NKEEP)
1107
{ TCP_NKEEP, "TCP_NKEEP" },
1109
#if defined(TCP_SYNCNT)
1110
{ TCP_SYNCNT, "TCP_SYNCNT" },
1112
#if defined(TCP_LINGER2)
1113
{ TCP_LINGER2, "TCP_LINGER2" },
1115
#if defined(TCP_DEFER_ACCEPT)
1116
{ TCP_DEFER_ACCEPT, "TCP_DEFER_ACCEPT" },
1118
#if defined(TCP_WINDOW_CLAMP)
1119
{ TCP_WINDOW_CLAMP, "TCP_WINDOW_CLAMP" },
1121
#if defined(TCP_INFO)
1122
{ TCP_INFO, "TCP_INFO" },
1124
#if defined(TCP_QUICKACK)
1125
{ TCP_QUICKACK, "TCP_QUICKACK" },
1129
#endif /* SOL_TCP */
1132
static const struct xlat icmpfilterflags[] = {
1133
#if defined(ICMP_ECHOREPLY)
1134
{ (1<<ICMP_ECHOREPLY), "ICMP_ECHOREPLY" },
1136
#if defined(ICMP_DEST_UNREACH)
1137
{ (1<<ICMP_DEST_UNREACH), "ICMP_DEST_UNREACH" },
1139
#if defined(ICMP_SOURCE_QUENCH)
1140
{ (1<<ICMP_SOURCE_QUENCH), "ICMP_SOURCE_QUENCH" },
1142
#if defined(ICMP_REDIRECT)
1143
{ (1<<ICMP_REDIRECT), "ICMP_REDIRECT" },
1145
#if defined(ICMP_ECHO)
1146
{ (1<<ICMP_ECHO), "ICMP_ECHO" },
1148
#if defined(ICMP_TIME_EXCEEDED)
1149
{ (1<<ICMP_TIME_EXCEEDED), "ICMP_TIME_EXCEEDED" },
1151
#if defined(ICMP_PARAMETERPROB)
1152
{ (1<<ICMP_PARAMETERPROB), "ICMP_PARAMETERPROB" },
1154
#if defined(ICMP_TIMESTAMP)
1155
{ (1<<ICMP_TIMESTAMP), "ICMP_TIMESTAMP" },
1157
#if defined(ICMP_TIMESTAMPREPLY)
1158
{ (1<<ICMP_TIMESTAMPREPLY), "ICMP_TIMESTAMPREPLY" },
1160
#if defined(ICMP_INFO_REQUEST)
1161
{ (1<<ICMP_INFO_REQUEST), "ICMP_INFO_REQUEST" },
1163
#if defined(ICMP_INFO_REPLY)
1164
{ (1<<ICMP_INFO_REPLY), "ICMP_INFO_REPLY" },
1166
#if defined(ICMP_ADDRESS)
1167
{ (1<<ICMP_ADDRESS), "ICMP_ADDRESS" },
1169
#if defined(ICMP_ADDRESSREPLY)
1170
{ (1<<ICMP_ADDRESSREPLY), "ICMP_ADDRESSREPLY" },
1174
#endif /* SOL_RAW */
1176
#if defined(AF_PACKET) /* from e.g. linux/if_packet.h */
1177
static const struct xlat af_packet_types[] = {
1178
#if defined(PACKET_HOST)
1179
{ PACKET_HOST, "PACKET_HOST" },
1181
#if defined(PACKET_BROADCAST)
1182
{ PACKET_BROADCAST, "PACKET_BROADCAST" },
1184
#if defined(PACKET_MULTICAST)
1185
{ PACKET_MULTICAST, "PACKET_MULTICAST" },
1187
#if defined(PACKET_OTHERHOST)
1188
{ PACKET_OTHERHOST, "PACKET_OTHERHOST" },
1190
#if defined(PACKET_OUTGOING)
1191
{ PACKET_OUTGOING, "PACKET_OUTGOING" },
1193
#if defined(PACKET_LOOPBACK)
1194
{ PACKET_LOOPBACK, "PACKET_LOOPBACK" },
1196
#if defined(PACKET_FASTROUTE)
1197
{ PACKET_FASTROUTE, "PACKET_FASTROUTE" },
1201
#endif /* defined(AF_PACKET) */
1205
printsock(struct tcb *tcp, long addr, int addrlen)
1210
struct sockaddr_in sin;
1211
struct sockaddr_un sau;
1212
#ifdef HAVE_INET_NTOP
1213
struct sockaddr_in6 sa6;
1215
#if defined(LINUX) && defined(AF_IPX)
1216
struct sockaddr_ipx sipx;
1219
struct sockaddr_ll ll;
1222
struct sockaddr_nl nl;
1225
char string_addr[100];
1231
if (!verbose(tcp)) {
1232
tprintf("%#lx", addr);
1236
if (addrlen < 2 || addrlen > sizeof(addrbuf))
1237
addrlen = sizeof(addrbuf);
1239
memset(&addrbuf, 0, sizeof(addrbuf));
1240
if (umoven(tcp, addr, addrlen, addrbuf.pad) < 0) {
1244
addrbuf.pad[sizeof(addrbuf.pad) - 1] = '\0';
1246
tprintf("{sa_family=");
1247
printxval(addrfams, addrbuf.sa.sa_family, "AF_???");
1250
switch (addrbuf.sa.sa_family) {
1254
} else if (addrbuf.sau.sun_path[0]) {
1256
printpathn(tcp, addr + 2, strlen(addrbuf.sau.sun_path));
1259
printpathn(tcp, addr + 3, strlen(addrbuf.sau.sun_path + 1));
1263
tprintf("sin_port=htons(%u), sin_addr=inet_addr(\"%s\")",
1264
ntohs(addrbuf.sin.sin_port), inet_ntoa(addrbuf.sin.sin_addr));
1266
#ifdef HAVE_INET_NTOP
1268
inet_ntop(AF_INET6, &addrbuf.sa6.sin6_addr, string_addr, sizeof(string_addr));
1269
tprintf("sin6_port=htons(%u), inet_pton(AF_INET6, \"%s\", &sin6_addr), sin6_flowinfo=%u",
1270
ntohs(addrbuf.sa6.sin6_port), string_addr,
1271
addrbuf.sa6.sin6_flowinfo);
1272
#ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID
1274
#if defined(HAVE_IF_INDEXTONAME) && defined(IN6_IS_ADDR_LINKLOCAL) && defined(IN6_IS_ADDR_MC_LINKLOCAL)
1275
int numericscope = 0;
1276
if (IN6_IS_ADDR_LINKLOCAL (&addrbuf.sa6.sin6_addr)
1277
|| IN6_IS_ADDR_MC_LINKLOCAL (&addrbuf.sa6.sin6_addr)) {
1278
char scopebuf[IFNAMSIZ + 1];
1280
if (if_indextoname (addrbuf.sa6.sin6_scope_id, scopebuf) == NULL)
1283
tprintf(", sin6_scope_id=if_nametoindex(\"%s\")", scopebuf);
1289
tprintf(", sin6_scope_id=%u", addrbuf.sa6.sin6_scope_id);
1294
#if defined(AF_IPX) && defined(linux)
1298
tprintf("sipx_port=htons(%u), ",
1299
ntohs(addrbuf.sipx.sipx_port));
1300
/* Yes, I know, this does not look too
1301
* strace-ish, but otherwise the IPX
1302
* addresses just look monstrous...
1303
* Anyways, feel free if you don't like
1306
tprintf("%08lx:", (unsigned long)ntohl(addrbuf.sipx.sipx_network));
1307
for (i = 0; i<IPX_NODE_LEN; i++)
1308
tprintf("%02x", addrbuf.sipx.sipx_node[i]);
1309
tprintf("/[%02x]", addrbuf.sipx.sipx_type);
1312
#endif /* AF_IPX && linux */
1317
tprintf("proto=%#04x, if%d, pkttype=",
1318
ntohs(addrbuf.ll.sll_protocol),
1319
addrbuf.ll.sll_ifindex);
1320
printxval(af_packet_types, addrbuf.ll.sll_pkttype, "?");
1321
tprintf(", addr(%d)={%d, ",
1322
addrbuf.ll.sll_halen,
1323
addrbuf.ll.sll_hatype);
1324
for (i=0; i<addrbuf.ll.sll_halen; i++)
1325
tprintf("%02x", addrbuf.ll.sll_addr[i]);
1329
#endif /* AF_APACKET */
1332
tprintf("pid=%d, groups=%08x", addrbuf.nl.nl_pid, addrbuf.nl.nl_groups);
1334
#endif /* AF_NETLINK */
1335
/* AF_AX25 AF_APPLETALK AF_NETROM AF_BRIDGE AF_AAL5
1336
AF_X25 AF_ROSE etc. still need to be done */
1339
tprintf("sa_data=");
1340
printstr(tcp, (long) &((struct sockaddr *) addr)->sa_data,
1341
sizeof addrbuf.sa.sa_data);
1348
static const struct xlat scmvals[] = {
1350
{ SCM_RIGHTS, "SCM_RIGHTS" },
1352
#ifdef SCM_CREDENTIALS
1353
{ SCM_CREDENTIALS, "SCM_CREDENTIALS" },
1359
printcmsghdr(struct tcb *tcp, unsigned long addr, unsigned long len)
1361
struct cmsghdr *cmsg = len < sizeof(struct cmsghdr) ?
1363
if (cmsg == NULL || umoven(tcp, addr, len, (char *) cmsg) < 0) {
1364
tprintf(", msg_control=%#lx", addr);
1369
tprintf(", {cmsg_len=%u, cmsg_level=", (unsigned) cmsg->cmsg_len);
1370
printxval(socketlayers, cmsg->cmsg_level, "SOL_???");
1371
tprintf(", cmsg_type=");
1373
if (cmsg->cmsg_level == SOL_SOCKET) {
1374
unsigned long cmsg_len;
1376
printxval(scmvals, cmsg->cmsg_type, "SCM_???");
1377
cmsg_len = (len < cmsg->cmsg_len) ? len : cmsg->cmsg_len;
1379
if (cmsg->cmsg_type == SCM_RIGHTS
1380
&& CMSG_LEN(sizeof(int)) <= cmsg_len) {
1381
int *fds = (int *) CMSG_DATA (cmsg);
1385
while ((char *) fds < ((char *) cmsg + cmsg_len)) {
1388
tprintf("%d", *fds++);
1395
if (cmsg->cmsg_type == SCM_CREDENTIALS
1396
&& CMSG_LEN(sizeof(struct ucred)) <= cmsg_len) {
1397
struct ucred *uc = (struct ucred *) CMSG_DATA (cmsg);
1399
tprintf("{pid=%ld, uid=%ld, gid=%ld}}",
1400
(long)uc->pid, (long)uc->uid, (long)uc->gid);
1410
do_msghdr(struct tcb *tcp, struct msghdr *msg)
1412
tprintf("{msg_name(%d)=", msg->msg_namelen);
1413
printsock(tcp, (long)msg->msg_name, msg->msg_namelen);
1415
tprintf(", msg_iov(%lu)=", (unsigned long)msg->msg_iovlen);
1416
tprint_iov(tcp, (unsigned long)msg->msg_iovlen,
1417
(unsigned long)msg->msg_iov);
1419
#ifdef HAVE_STRUCT_MSGHDR_MSG_CONTROL
1420
tprintf(", msg_controllen=%lu", (unsigned long)msg->msg_controllen);
1421
if (msg->msg_controllen)
1422
printcmsghdr(tcp, (unsigned long) msg->msg_control,
1423
msg->msg_controllen);
1424
tprintf(", msg_flags=");
1425
printflags(msg_flags, msg->msg_flags, "MSG_???");
1426
#else /* !HAVE_STRUCT_MSGHDR_MSG_CONTROL */
1427
tprintf("msg_accrights=%#lx, msg_accrightslen=%u",
1428
(unsigned long) msg->msg_accrights, msg->msg_accrightslen);
1429
#endif /* !HAVE_STRUCT_MSGHDR_MSG_CONTROL */
1434
printmsghdr(tcp, addr)
1440
if (umove(tcp, addr, &msg) < 0) {
1441
tprintf("%#lx", addr);
1444
do_msghdr(tcp, &msg);
1449
printmmsghdr(struct tcb *tcp, long addr)
1452
struct msghdr msg_hdr;
1456
if (umove(tcp, addr, &mmsg) < 0) {
1457
tprintf("%#lx", addr);
1461
do_msghdr(tcp, &mmsg.msg_hdr);
1462
tprintf(", %u}", mmsg.msg_len);
1466
#endif /* HAVE_SENDMSG */
1469
* low bits of the socket type define real socket type,
1470
* other bits are socket type flags.
1473
tprint_sock_type(struct tcb *tcp, int flags)
1475
const char *str = xlookup(socktypes, flags & SOCK_TYPE_MASK);
1480
flags &= ~SOCK_TYPE_MASK;
1485
printflags(sock_type_flags, flags, "SOCK_???");
1489
sys_socket(struct tcb *tcp)
1491
if (entering(tcp)) {
1492
printxval(domains, tcp->u_arg[0], "PF_???");
1494
tprint_sock_type(tcp, tcp->u_arg[1]);
1496
switch (tcp->u_arg[0]) {
1501
printxval(protocols, tcp->u_arg[2], "IPPROTO_???");
1505
/* BTW: I don't believe this.. */
1507
printxval(domains, tcp->u_arg[2], "PF_???");
1512
tprintf("%lu", tcp->u_arg[2]);
1524
if (entering(tcp)) {
1525
/* not sure really what these args are... but this
1526
* is how truss prints it
1528
tprintf("%ld, %ld, %ld, ",
1529
tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]);
1530
printpath(tcp, tcp->u_arg[3]);
1531
tprintf(", %ld", tcp->u_arg[4]);
1537
sys_so_socketpair(tcp)
1540
if (entering(tcp)) {
1541
/* not sure what this arg is */
1542
tprintf("0x%lx", tcp->u_arg[0]);
1552
CDE_begin_socket_bind_or_connect(tcp); // pgbovine
1555
if (entering(tcp)) {
1556
tprintf("%ld, ", tcp->u_arg[0]);
1557
printsock(tcp, tcp->u_arg[1], tcp->u_arg[2]);
1558
tprintf(", %lu", tcp->u_arg[2]);
1568
// pgbovine - handle connect in the same way as bind (see above)
1569
return sys_bind(tcp);
1576
if (entering(tcp)) {
1577
tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
1583
do_accept(struct tcb *tcp, int flags_arg)
1585
if (entering(tcp)) {
1586
tprintf("%ld, ", tcp->u_arg[0]);
1590
tprintf("%#lx, NULL", tcp->u_arg[1]);
1593
if (tcp->u_arg[1] == 0 || syserror(tcp)
1594
|| umove (tcp, tcp->u_arg[2], &len) < 0) {
1595
tprintf("%#lx", tcp->u_arg[1]);
1597
printsock(tcp, tcp->u_arg[1], len);
1600
printnum_int(tcp, tcp->u_arg[2], "%u");
1602
if (flags_arg >= 0) {
1604
printflags(sock_type_flags, tcp->u_arg[flags_arg],
1611
sys_accept(struct tcb *tcp)
1613
return do_accept(tcp, -1);
1618
sys_accept4(struct tcb *tcp)
1620
return do_accept(tcp, 3);
1628
if (entering(tcp)) {
1629
tprintf("%ld, ", tcp->u_arg[0]);
1630
printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
1631
tprintf(", %lu, ", tcp->u_arg[2]);
1633
printflags(msg_flags, tcp->u_arg[3], "MSG_???");
1642
if (entering(tcp)) {
1643
tprintf("%ld, ", tcp->u_arg[0]);
1644
printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
1645
tprintf(", %lu, ", tcp->u_arg[2]);
1647
printflags(msg_flags, tcp->u_arg[3], "MSG_???");
1650
printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]);
1652
tprintf(", %lu", tcp->u_arg[5]);
1663
if (entering(tcp)) {
1664
tprintf("%ld, ", tcp->u_arg[0]);
1665
printmsghdr(tcp, tcp->u_arg[1]);
1668
printflags(msg_flags, tcp->u_arg[2], "MSG_???");
1673
#endif /* HAVE_SENDMSG */
1679
if (entering(tcp)) {
1680
tprintf("%ld, ", tcp->u_arg[0]);
1683
tprintf("%#lx", tcp->u_arg[1]);
1685
printstr(tcp, tcp->u_arg[1], tcp->u_rval);
1687
tprintf(", %lu, ", tcp->u_arg[2]);
1688
printflags(msg_flags, tcp->u_arg[3], "MSG_???");
1699
if (entering(tcp)) {
1700
tprintf("%ld, ", tcp->u_arg[0]);
1702
if (syserror(tcp)) {
1703
tprintf("%#lx, %lu, %lu, %#lx, %#lx",
1704
tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3],
1705
tcp->u_arg[4], tcp->u_arg[5]);
1709
printstr(tcp, tcp->u_arg[1], tcp->u_rval);
1711
tprintf(", %lu, ", tcp->u_arg[2]);
1713
printflags(msg_flags, tcp->u_arg[3], "MSG_???");
1714
/* from address, len */
1715
if (!tcp->u_arg[4] || !tcp->u_arg[5]) {
1716
if (tcp->u_arg[4] == 0)
1719
tprintf(", %#lx", tcp->u_arg[4]);
1720
if (tcp->u_arg[5] == 0)
1723
tprintf(", %#lx", tcp->u_arg[5]);
1726
if (umove(tcp, tcp->u_arg[5], &fromlen) < 0) {
1727
tprintf(", {...}, [?]");
1731
printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]);
1733
tprintf(", [%u]", fromlen);
1744
if (entering(tcp)) {
1745
tprintf("%ld, ", tcp->u_arg[0]);
1747
if (syserror(tcp) || !verbose(tcp))
1748
tprintf("%#lx", tcp->u_arg[1]);
1750
printmsghdr(tcp, tcp->u_arg[1]);
1753
printflags(msg_flags, tcp->u_arg[2], "MSG_???");
1760
sys_recvmmsg(struct tcb *tcp)
1762
static char str[128];
1763
if (entering(tcp)) {
1765
tprintf("%ld, ", tcp->u_arg[0]);
1767
sprint_timespec(str, tcp, tcp->u_arg[4]);
1768
tcp->auxstr = strdup(str);
1770
tprintf("%#lx, %ld, ", tcp->u_arg[1], tcp->u_arg[2]);
1771
printflags(msg_flags, tcp->u_arg[3], "MSG_???");
1773
print_timespec(tcp, tcp->u_arg[4]);
1779
tprintf("%#lx", tcp->u_arg[1]);
1781
printmmsghdr(tcp, tcp->u_arg[1]);
1782
tprintf(", %ld, ", tcp->u_arg[2]);
1784
printflags(msg_flags, tcp->u_arg[3], "MSG_???");
1785
/* timeout on entrance */
1786
tprintf(", %s", tcp->auxstr ? tcp->auxstr : "{...}");
1787
free((void *) tcp->auxstr);
1792
if (tcp->u_rval == 0) {
1793
tcp->auxstr = "Timeout";
1798
/* timeout on exit */
1799
strcpy(str, "left ");
1800
sprint_timespec(str + strlen(str), tcp, tcp->u_arg[4]);
1807
#endif /* HAVE_SENDMSG */
1809
static const struct xlat shutdown_modes[] = {
1820
if (entering(tcp)) {
1821
tprintf("%ld, ", tcp->u_arg[0]);
1822
printxval(shutdown_modes, tcp->u_arg[1], "SHUT_???");
1828
sys_getsockname(tcp)
1831
return sys_accept(tcp);
1835
sys_getpeername(tcp)
1838
return sys_accept(tcp);
1842
do_pipe(struct tcb *tcp, int flags_arg)
1845
if (syserror(tcp)) {
1846
tprintf("%#lx", tcp->u_arg[0]);
1848
#if defined(LINUX) && !defined(SPARC) && !defined(SPARC64) && !defined(SH) && !defined(IA64)
1851
if (umoven(tcp, tcp->u_arg[0], sizeof fds, (char *) fds) < 0)
1854
tprintf("[%u, %u]", fds[0], fds[1]);
1855
#elif defined(SPARC) || defined(SPARC64) || defined(SH) || defined(SVR4) || defined(FREEBSD) || defined(IA64)
1856
tprintf("[%lu, %lu]", tcp->u_rval, getrval2(tcp));
1858
tprintf("%#lx", tcp->u_arg[0]);
1861
if (flags_arg >= 0) {
1863
printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???");
1870
sys_pipe(struct tcb *tcp)
1872
return do_pipe(tcp, -1);
1877
sys_pipe2(struct tcb *tcp)
1879
return do_pipe(tcp, 1);
1884
sys_socketpair(struct tcb *tcp)
1890
if (entering(tcp)) {
1891
printxval(domains, tcp->u_arg[0], "PF_???");
1893
tprint_sock_type(tcp, tcp->u_arg[1]);
1895
switch (tcp->u_arg[0]) {
1897
printxval(protocols, tcp->u_arg[2], "IPPROTO_???");
1901
/* BTW: I don't believe this.. */
1903
printxval(domains, tcp->u_arg[2], "PF_???");
1908
tprintf("%lu", tcp->u_arg[2]);
1912
if (syserror(tcp)) {
1913
tprintf(", %#lx", tcp->u_arg[3]);
1917
if (umoven(tcp, tcp->u_arg[3], sizeof fds, (char *) fds) < 0)
1920
tprintf(", [%u, %u]", fds[0], fds[1]);
1922
#if defined(SUNOS4) || defined(SVR4) || defined(FREEBSD)
1923
tprintf(", [%lu, %lu]", tcp->u_rval, getrval2(tcp));
1924
#endif /* SUNOS4 || SVR4 || FREEBSD */
1930
sys_getsockopt(struct tcb *tcp)
1932
if (entering(tcp)) {
1933
tprintf("%ld, ", tcp->u_arg[0]);
1934
printxval(socketlayers, tcp->u_arg[1], "SOL_???");
1936
switch (tcp->u_arg[1]) {
1938
printxval(sockoptions, tcp->u_arg[2], "SO_???");
1942
printxval(sockipoptions, tcp->u_arg[2], "IP_???");
1947
printxval(sockipv6options, tcp->u_arg[2], "IPV6_???");
1952
printxval(sockipxoptions, tcp->u_arg[2], "IPX_???");
1957
printxval(sockpacketoptions, tcp->u_arg[2], "PACKET_???");
1962
printxval(socktcpoptions, tcp->u_arg[2], "TCP_???");
1967
printxval(socksctpoptions, tcp->u_arg[2], "SCTP_???");
1971
/* SOL_AX25 SOL_ROSE SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25
1972
* etc. still need work */
1974
tprintf("%lu", tcp->u_arg[2]);
1980
if (syserror(tcp) || umove (tcp, tcp->u_arg[4], &len) < 0) {
1981
tprintf("%#lx, %#lx",
1982
tcp->u_arg[3], tcp->u_arg[4]);
1986
switch (tcp->u_arg[1]) {
1988
switch (tcp->u_arg[2]) {
1991
if (len == sizeof (struct linger)) {
1992
struct linger linger;
1997
tprintf("{onoff=%d, linger=%d}, "
2008
if (len == sizeof (struct ucred)) {
2014
tprintf("{pid=%ld, uid=%ld, gid=%ld}, "
2027
switch (tcp->u_arg[2]) {
2028
#ifdef PACKET_STATISTICS
2029
case PACKET_STATISTICS:
2030
if (len == sizeof(struct tpacket_stats)) {
2031
struct tpacket_stats stats;
2036
tprintf("{packets=%u, drops=%u}, "
2049
if (len == sizeof (int)) {
2050
printnum_int(tcp, tcp->u_arg[3], "%d");
2053
printstr (tcp, tcp->u_arg[3], len);
2055
tprintf(", [%d]", len);
2060
#if defined(ICMP_FILTER)
2061
static void printicmpfilter(tcp, addr)
2065
struct icmp_filter filter;
2071
if (syserror(tcp) || !verbose(tcp)) {
2072
tprintf("%#lx", addr);
2075
if (umove(tcp, addr, &filter) < 0) {
2081
printflags(icmpfilterflags, ~filter.data, "ICMP_???");
2084
#endif /* ICMP_FILTER */
2087
printsockopt (tcp, level, name, addr, len)
2094
printxval(socketlayers, level, "SOL_??");
2098
printxval(sockoptions, name, "SO_???");
2100
#if defined(SO_LINGER)
2102
if (len == sizeof (struct linger)) {
2103
struct linger linger;
2104
if (umove (tcp, addr, &linger) < 0)
2106
tprintf(", {onoff=%d, linger=%d}",
2117
printxval(sockipoptions, name, "IP_???");
2122
printxval(sockipv6options, name, "IPV6_???");
2127
printxval(sockipxoptions, name, "IPX_???");
2132
printxval(sockpacketoptions, name, "PACKET_???");
2133
/* TODO: decode packate_mreq for PACKET_*_MEMBERSHIP */
2135
#ifdef PACKET_RX_RING
2136
case PACKET_RX_RING:
2138
#ifdef PACKET_TX_RING
2139
case PACKET_TX_RING:
2141
#if defined(PACKET_RX_RING) || defined(PACKET_TX_RING)
2142
if (len == sizeof(struct tpacket_req)) {
2143
struct tpacket_req req;
2144
if (umove(tcp, addr, &req) < 0)
2146
tprintf(", {block_size=%u, block_nr=%u, frame_size=%u, frame_nr=%u}",
2154
#endif /* PACKET_RX_RING || PACKET_TX_RING */
2160
printxval(socktcpoptions, name, "TCP_???");
2165
printxval(socksctpoptions, name, "SCTP_???");
2170
printxval(sockrawoptions, name, "RAW_???");
2172
#if defined(ICMP_FILTER)
2175
printicmpfilter(tcp, addr);
2182
/* SOL_AX25 SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25
2183
* etc. still need work */
2186
tprintf("%u", name);
2189
/* default arg printing */
2193
if (len == sizeof (int)) {
2194
printnum_int (tcp, addr, "%d");
2197
printstr (tcp, addr, len);
2203
#ifdef HAVE_STRUCT_OPTHDR
2206
print_sock_optmgmt (tcp, addr, len)
2214
while (len >= (int) sizeof hdr) {
2215
if (umove(tcp, addr, &hdr) < 0) break;
2219
else if (len > hdr.len + sizeof hdr) {
2225
printsockopt (tcp, hdr.level, hdr.name, addr, hdr.len);
2233
if (c++) tprintf (", ");
2234
printstr (tcp, addr, len);
2236
if (c > 1) tprintf ("]");
2245
if (entering(tcp)) {
2246
tprintf("%ld, ", tcp->u_arg[0]);
2247
printsockopt (tcp, tcp->u_arg[1], tcp->u_arg[2],
2248
tcp->u_arg[3], tcp->u_arg[4]);
2249
tprintf(", %lu", tcp->u_arg[4]);
2256
static const struct xlat sock_version[] = {
2257
{ __NETLIB_UW211_SVR4, "UW211_SVR4" },
2258
{ __NETLIB_UW211_XPG4, "UW211_XPG4" },
2259
{ __NETLIB_GEMINI_SVR4, "GEMINI_SVR4" },
2260
{ __NETLIB_GEMINI_XPG4, "GEMINI_XPG4" },
2261
{ __NETLIB_FP1_SVR4, "FP1_SVR4" },
2262
{ __NETLIB_FP1_XPG4, "FP1_XPG4" },
2268
netlib_call(tcp, func)
2272
if (entering(tcp)) {
2274
printxval (sock_version, tcp->u_arg[0], "__NETLIB_???");
2277
for (i = 0; i < tcp->u_nargs; i++)
2278
tcp->u_arg[i] = tcp->u_arg[i + 1];
2290
return netlib_call (tcp, sys_socket);
2294
sys_xsocketpair(tcp)
2297
return netlib_call (tcp, sys_socketpair);
2304
return netlib_call (tcp, sys_bind);
2311
return netlib_call (tcp, sys_connect);
2318
return netlib_call (tcp, sys_listen);
2325
return netlib_call (tcp, sys_accept);
2332
return netlib_call (tcp, sys_sendmsg);
2339
return netlib_call (tcp, sys_recvmsg);
2343
sys_xgetsockaddr(tcp)
2346
if (entering(tcp)) {
2347
printxval (sock_version, tcp->u_arg[0], "__NETLIB_???");
2349
if (tcp->u_arg[1] == 0) {
2350
tprintf ("LOCALNAME, ");
2352
else if (tcp->u_arg[1] == 1) {
2353
tprintf ("REMOTENAME, ");
2356
tprintf ("%ld, ", tcp->u_arg [1]);
2358
tprintf ("%ld, ", tcp->u_arg [2]);
2361
if (tcp->u_arg[3] == 0 || syserror(tcp)) {
2362
tprintf("%#lx", tcp->u_arg[3]);
2364
printsock(tcp, tcp->u_arg[3], tcp->u_arg[4]);
2367
printnum(tcp, tcp->u_arg[4], "%lu");
2375
sys_xgetsockopt(tcp)
2378
return netlib_call (tcp, sys_getsockopt);
2382
sys_xsetsockopt(tcp)
2385
return netlib_call (tcp, sys_setsockopt);
2392
return netlib_call (tcp, sys_shutdown);
2395
#endif /* UNIXWARE */