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 #include <arpa/inet.h>
55 #include <asm/types.h>
56 #if defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC__ + __GLIBC_MINOR__ >= 3)
57 # include <netipx/ipx.h>
59 # include <linux/ipx.h>
63 #if defined (__GLIBC__) && (((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1)) || defined(HAVE_SIN6_SCOPE_ID_LINUX))
64 #if defined(HAVE_LINUX_IN6_H)
65 #if defined(HAVE_SIN6_SCOPE_ID_LINUX)
69 #define in6_addr in6_addr_kernel
70 #define ipv6_mreq ipv6_mreq_kernel
71 #define sockaddr_in6 sockaddr_in6_kernel
73 #include <linux/in6.h>
74 #if defined(HAVE_SIN6_SCOPE_ID_LINUX)
78 #define in6_addr in6_addr_libc
79 #define ipv6_mreq ipv6_mreq_libc
80 #define sockaddr_in6 sockaddr_in6_kernel
85 #if defined(HAVE_SYS_UIO_H)
89 #if defined(HAVE_LINUX_NETLINK_H)
90 #include <linux/netlink.h>
93 #if defined(HAVE_LINUX_IF_PACKET_H)
94 #include <linux/if_packet.h>
97 #if defined(HAVE_LINUX_ICMP_H)
98 #include <linux/icmp.h>
102 #define PF_UNSPEC AF_UNSPEC
106 #define HAVE_SENDMSG 1 /* HACK - *FIXME* */
110 /* Under Linux these are enums so we can't test for them with ifdef. */
111 #define IPPROTO_EGP IPPROTO_EGP
112 #define IPPROTO_PUP IPPROTO_PUP
113 #define IPPROTO_IDP IPPROTO_IDP
114 #define IPPROTO_IGMP IPPROTO_IGMP
115 #define IPPROTO_RAW IPPROTO_RAW
116 #define IPPROTO_MAX IPPROTO_MAX
119 static const struct xlat domains[] = {
121 { PF_AAL5, "PF_AAL5" },
124 { PF_APPLETALK, "PF_APPLETALK" },
127 { PF_ASH, "PF_ASH" },
130 { PF_ATMPVC, "PF_ATMPVC" },
133 { PF_ATMSVC, "PF_ATMSVC" },
136 { PF_AX25, "PF_AX25" },
139 { PF_BLUETOOTH, "PF_BLUETOOTH" },
142 { PF_BRIDGE, "PF_BRIDGE" },
145 { PF_DECnet, "PF_DECnet" },
148 { PF_DECNET, "PF_DECNET" },
151 { PF_ECONET, "PF_ECONET" },
154 { PF_FILE, "PF_FILE" },
157 { PF_IMPLINK, "PF_IMPLINK" },
160 { PF_INET, "PF_INET" },
163 { PF_INET6, "PF_INET6" },
166 { PF_IPX, "PF_IPX" },
169 { PF_IRDA, "PF_IRDA" },
172 { PF_ISO, "PF_ISO" },
175 { PF_KEY, "PF_KEY" },
178 { PF_UNIX, "PF_UNIX" },
181 { PF_LOCAL, "PF_LOCAL" },
184 { PF_NETBEUI, "PF_NETBEUI" },
187 { PF_NETLINK, "PF_NETLINK" },
190 { PF_NETROM, "PF_NETROM" },
193 { PF_PACKET, "PF_PACKET" },
196 { PF_PPPOX, "PF_PPPOX" },
199 { PF_ROSE, "PF_ROSE" },
202 { PF_ROUTE, "PF_ROUTE" },
205 { PF_SECURITY, "PF_SECURITY" },
208 { PF_SNA, "PF_SNA" },
211 { PF_UNSPEC, "PF_UNSPEC" },
214 { PF_WANPIPE, "PF_WANPIPE" },
217 { PF_X25, "PF_X25" },
221 const struct xlat addrfams[] = {
223 { AF_APPLETALK, "AF_APPLETALK" },
226 { AF_ASH, "AF_ASH" },
229 { AF_ATMPVC, "AF_ATMPVC" },
232 { AF_ATMSVC, "AF_ATMSVC" },
235 { AF_AX25, "AF_AX25" },
238 { AF_BLUETOOTH, "AF_BLUETOOTH" },
241 { AF_BRIDGE, "AF_BRIDGE" },
244 { AF_DECnet, "AF_DECnet" },
247 { AF_ECONET, "AF_ECONET" },
250 { AF_FILE, "AF_FILE" },
253 { AF_IMPLINK, "AF_IMPLINK" },
256 { AF_INET, "AF_INET" },
259 { AF_INET6, "AF_INET6" },
262 { AF_IPX, "AF_IPX" },
265 { AF_IRDA, "AF_IRDA" },
268 { AF_ISO, "AF_ISO" },
271 { AF_KEY, "AF_KEY" },
274 { AF_UNIX, "AF_UNIX" },
277 { AF_LOCAL, "AF_LOCAL" },
280 { AF_NETBEUI, "AF_NETBEUI" },
283 { AF_NETLINK, "AF_NETLINK" },
286 { AF_NETROM, "AF_NETROM" },
289 { AF_PACKET, "AF_PACKET" },
292 { AF_PPPOX, "AF_PPPOX" },
295 { AF_ROSE, "AF_ROSE" },
298 { AF_ROUTE, "AF_ROUTE" },
301 { AF_SECURITY, "AF_SECURITY" },
304 { AF_SNA, "AF_SNA" },
307 { AF_UNSPEC, "AF_UNSPEC" },
310 { AF_WANPIPE, "AF_WANPIPE" },
313 { AF_X25, "AF_X25" },
317 static const struct xlat socktypes[] = {
318 { SOCK_STREAM, "SOCK_STREAM" },
319 { SOCK_DGRAM, "SOCK_DGRAM" },
321 { SOCK_RAW, "SOCK_RAW" },
324 { SOCK_RDM, "SOCK_RDM" },
326 #ifdef SOCK_SEQPACKET
327 { SOCK_SEQPACKET,"SOCK_SEQPACKET"},
330 { SOCK_DCCP, "SOCK_DCCP" },
333 { SOCK_PACKET, "SOCK_PACKET" },
337 const struct xlat sock_type_flags[] = {
339 { SOCK_CLOEXEC, "SOCK_CLOEXEC" },
342 { SOCK_NONBLOCK,"SOCK_NONBLOCK" },
346 #ifndef SOCK_TYPE_MASK
347 # define SOCK_TYPE_MASK 0xf
349 static const struct xlat socketlayers[] = {
351 { SOL_IP, "SOL_IP" },
353 #if defined(SOL_ICMP)
354 { SOL_ICMP, "SOL_ICMP" },
357 { SOL_TCP, "SOL_TCP" },
360 { SOL_UDP, "SOL_UDP" },
362 #if defined(SOL_IPV6)
363 { SOL_IPV6, "SOL_IPV6" },
365 #if defined(SOL_ICMPV6)
366 { SOL_ICMPV6, "SOL_ICMPV6" },
369 { SOL_RAW, "SOL_RAW" },
372 { SOL_IPX, "SOL_IPX" },
375 { SOL_IPX, "SOL_IPX" },
377 #if defined(SOL_AX25)
378 { SOL_AX25, "SOL_AX25" },
380 #if defined(SOL_ATALK)
381 { SOL_ATALK, "SOL_ATALK" },
383 #if defined(SOL_NETROM)
384 { SOL_NETROM, "SOL_NETROM" },
386 #if defined(SOL_ROSE)
387 { SOL_ROSE, "SOL_ROSE" },
389 #if defined(SOL_DECNET)
390 { SOL_DECNET, "SOL_DECNET" },
393 { SOL_X25, "SOL_X25" },
395 #if defined(SOL_PACKET)
396 { SOL_PACKET, "SOL_PACKET" },
399 { SOL_ATM, "SOL_ATM" },
402 { SOL_AAL, "SOL_AAL" },
404 #if defined(SOL_IRDA)
405 { SOL_IRDA, "SOL_IRDA" },
407 { SOL_SOCKET, "SOL_SOCKET" }, /* Never used! */
409 /*** WARNING: DANGER WILL ROBINSON: NOTE "socketlayers" array above
410 falls into "protocols" array below!!!! This is intended!!! ***/
411 static const struct xlat protocols[] = {
412 { IPPROTO_IP, "IPPROTO_IP" },
413 { IPPROTO_ICMP, "IPPROTO_ICMP" },
414 { IPPROTO_TCP, "IPPROTO_TCP" },
415 { IPPROTO_UDP, "IPPROTO_UDP" },
417 { IPPROTO_GGP, "IPPROTO_GGP" },
420 { IPPROTO_EGP, "IPPROTO_EGP" },
423 { IPPROTO_PUP, "IPPROTO_PUP" },
426 { IPPROTO_IDP, "IPPROTO_IDP" },
429 { IPPROTO_IPV6, "IPPROTO_IPV6" },
431 #ifdef IPPROTO_ICMPV6
432 { IPPROTO_ICMPV6,"IPPROTO_ICMPV6"},
435 { IPPROTO_IGMP, "IPPROTO_IGMP" },
438 { IPPROTO_HELLO,"IPPROTO_HELLO" },
441 { IPPROTO_ND, "IPPROTO_ND" },
444 { IPPROTO_RAW, "IPPROTO_RAW" },
447 { IPPROTO_MAX, "IPPROTO_MAX" },
450 { IPPROTO_IPIP, "IPPROTO_IPIP" },
452 #ifdef IPPROTO_UDPLITE
453 { IPPROTO_UDPLITE, "IPPROTO_UDPLITE" },
456 { IPPROTO_SCTP, "IPPROTO_SCTP" },
459 { IPPROTO_GRE, "IPPROTO_GRE" },
463 static const struct xlat msg_flags[] = {
464 { MSG_OOB, "MSG_OOB" },
466 { MSG_DONTROUTE, "MSG_DONTROUTE" },
469 { MSG_PEEK, "MSG_PEEK" },
472 { MSG_CTRUNC, "MSG_CTRUNC" },
475 { MSG_PROXY, "MSG_PROXY" },
478 { MSG_EOR, "MSG_EOR" },
481 { MSG_WAITALL, "MSG_WAITALL" },
484 { MSG_TRUNC, "MSG_TRUNC" },
487 { MSG_CTRUNC, "MSG_CTRUNC" },
490 { MSG_ERRQUEUE, "MSG_ERRQUEUE" },
493 { MSG_DONTWAIT, "MSG_DONTWAIT" },
496 { MSG_CONFIRM, "MSG_CONFIRM" },
499 { MSG_PROBE, "MSG_PROBE" },
502 { MSG_FIN, "MSG_FIN" },
505 { MSG_SYN, "MSG_SYN" },
508 { MSG_RST, "MSG_RST" },
511 { MSG_NOSIGNAL, "MSG_NOSIGNAL" },
514 { MSG_MORE, "MSG_MORE" },
516 #ifdef MSG_CMSG_CLOEXEC
517 { MSG_CMSG_CLOEXEC, "MSG_CMSG_CLOEXEC" },
522 static const struct xlat sockoptions[] = {
524 { SO_ACCEPTCONN, "SO_ACCEPTCONN" },
527 { SO_ALLRAW, "SO_ALLRAW" },
529 #ifdef SO_ATTACH_FILTER
530 { SO_ATTACH_FILTER, "SO_ATTACH_FILTER" },
532 #ifdef SO_BINDTODEVICE
533 { SO_BINDTODEVICE, "SO_BINDTODEVICE" },
536 { SO_BROADCAST, "SO_BROADCAST" },
539 { SO_BSDCOMPAT, "SO_BSDCOMPAT" },
542 { SO_DEBUG, "SO_DEBUG" },
544 #ifdef SO_DETACH_FILTER
545 { SO_DETACH_FILTER, "SO_DETACH_FILTER" },
548 { SO_DONTROUTE, "SO_DONTROUTE" },
551 { SO_ERROR, "SO_ERROR" },
554 { SO_ICS, "SO_ICS" },
557 { SO_IMASOCKET, "SO_IMASOCKET" },
560 { SO_KEEPALIVE, "SO_KEEPALIVE" },
563 { SO_LINGER, "SO_LINGER" },
566 { SO_LISTENING, "SO_LISTENING" },
569 { SO_MGMT, "SO_MGMT" },
572 { SO_NO_CHECK, "SO_NO_CHECK" },
575 { SO_OOBINLINE, "SO_OOBINLINE" },
578 { SO_ORDREL, "SO_ORDREL" },
580 #ifdef SO_PARALLELSVR
581 { SO_PARALLELSVR, "SO_PARALLELSVR" },
584 { SO_PASSCRED, "SO_PASSCRED" },
587 { SO_PEERCRED, "SO_PEERCRED" },
590 { SO_PEERNAME, "SO_PEERNAME" },
593 { SO_PEERSEC, "SO_PEERSEC" },
596 { SO_PRIORITY, "SO_PRIORITY" },
599 { SO_PROTOTYPE, "SO_PROTOTYPE" },
602 { SO_RCVBUF, "SO_RCVBUF" },
605 { SO_RCVLOWAT, "SO_RCVLOWAT" },
608 { SO_RCVTIMEO, "SO_RCVTIMEO" },
611 { SO_RDWR, "SO_RDWR" },
614 { SO_REUSEADDR, "SO_REUSEADDR" },
617 { SO_REUSEPORT, "SO_REUSEPORT" },
619 #ifdef SO_SECURITY_AUTHENTICATION
620 { SO_SECURITY_AUTHENTICATION,"SO_SECURITY_AUTHENTICATION"},
622 #ifdef SO_SECURITY_ENCRYPTION_NETWORK
623 { SO_SECURITY_ENCRYPTION_NETWORK,"SO_SECURITY_ENCRYPTION_NETWORK"},
625 #ifdef SO_SECURITY_ENCRYPTION_TRANSPORT
626 { SO_SECURITY_ENCRYPTION_TRANSPORT,"SO_SECURITY_ENCRYPTION_TRANSPORT"},
629 { SO_SEMA, "SO_SEMA" },
632 { SO_SNDBUF, "SO_SNDBUF" },
635 { SO_SNDLOWAT, "SO_SNDLOWAT" },
638 { SO_SNDTIMEO, "SO_SNDTIMEO" },
641 { SO_TIMESTAMP, "SO_TIMESTAMP" },
644 { SO_TYPE, "SO_TYPE" },
646 #ifdef SO_USELOOPBACK
647 { SO_USELOOPBACK, "SO_USELOOPBACK" },
652 #if !defined (SOL_IP) && defined (IPPROTO_IP)
653 #define SOL_IP IPPROTO_IP
657 static const struct xlat sockipoptions[] = {
659 { IP_TOS, "IP_TOS" },
662 { IP_TTL, "IP_TTL" },
665 { IP_HDRINCL, "IP_HDRINCL" },
668 { IP_OPTIONS, "IP_OPTIONS" },
670 #ifdef IP_ROUTER_ALERT
671 { IP_ROUTER_ALERT, "IP_ROUTER_ALERT" },
673 #ifdef IP_RECVOPTIONS
674 { IP_RECVOPTIONS, "IP_RECVOPTIONS" },
677 { IP_RECVOPTS, "IP_RECVOPTS" },
679 #ifdef IP_RECVRETOPTS
680 { IP_RECVRETOPTS, "IP_RECVRETOPTS" },
682 #ifdef IP_RECVDSTADDR
683 { IP_RECVDSTADDR, "IP_RECVDSTADDR" },
686 { IP_RETOPTS, "IP_RETOPTS" },
689 { IP_PKTINFO, "IP_PKTINFO" },
692 { IP_PKTOPTIONS, "IP_PKTOPTIONS" },
694 #ifdef IP_MTU_DISCOVER
695 { IP_MTU_DISCOVER, "IP_MTU_DISCOVER" },
698 { IP_RECVERR, "IP_RECVERR" },
701 { IP_RECVTTL, "IP_RECVTTL" },
704 { IP_RECVTOS, "IP_RECVTOS" },
707 { IP_MTU, "IP_MTU" },
709 #ifdef IP_MULTICAST_IF
710 { IP_MULTICAST_IF, "IP_MULTICAST_IF" },
712 #ifdef IP_MULTICAST_TTL
713 { IP_MULTICAST_TTL, "IP_MULTICAST_TTL" },
715 #ifdef IP_MULTICAST_LOOP
716 { IP_MULTICAST_LOOP, "IP_MULTICAST_LOOP" },
718 #ifdef IP_ADD_MEMBERSHIP
719 { IP_ADD_MEMBERSHIP, "IP_ADD_MEMBERSHIP" },
721 #ifdef IP_DROP_MEMBERSHIP
722 { IP_DROP_MEMBERSHIP, "IP_DROP_MEMBERSHIP" },
724 #ifdef IP_BROADCAST_IF
725 { IP_BROADCAST_IF, "IP_BROADCAST_IF" },
727 #ifdef IP_RECVIFINDEX
728 { IP_RECVIFINDEX, "IP_RECVIFINDEX" },
731 { IP_MSFILTER, "IP_MSFILTER" },
733 #ifdef MCAST_MSFILTER
734 { MCAST_MSFILTER, "MCAST_MSFILTER" },
737 { IP_FREEBIND, "IP_FREEBIND" },
744 static const struct xlat sockipv6options[] = {
746 { IPV6_ADDRFORM, "IPV6_ADDRFORM" },
749 { MCAST_FILTER, "MCAST_FILTER" },
751 #ifdef IPV6_PKTOPTIONS
752 { IPV6_PKTOPTIONS, "IPV6_PKTOPTIONS" },
755 { IPV6_MTU, "IPV6_MTU" },
758 { IPV6_V6ONLY, "IPV6_V6ONLY" },
761 { IPV6_PKTINFO, "IPV6_PKTINFO" },
764 { IPV6_HOPLIMIT, "IPV6_HOPLIMIT" },
767 { IPV6_RTHDR, "IPV6_RTHDR" },
770 { IPV6_HOPOPTS, "IPV6_HOPOPTS" },
773 { IPV6_DSTOPTS, "IPV6_DSTOPTS" },
776 { IPV6_FLOWINFO, "IPV6_FLOWINFO" },
778 #ifdef IPV6_UNICAST_HOPS
779 { IPV6_UNICAST_HOPS, "IPV6_UNICAST_HOPS" },
781 #ifdef IPV6_MULTICAST_HOPS
782 { IPV6_MULTICAST_HOPS, "IPV6_MULTICAST_HOPS" },
784 #ifdef IPV6_MULTICAST_LOOP
785 { IPV6_MULTICAST_LOOP, "IPV6_MULTICAST_LOOP" },
787 #ifdef IPV6_MULTICAST_IF
788 { IPV6_MULTICAST_IF, "IPV6_MULTICAST_IF" },
790 #ifdef IPV6_MTU_DISCOVER
791 { IPV6_MTU_DISCOVER, "IPV6_MTU_DISCOVER" },
794 { IPV6_RECVERR, "IPV6_RECVERR" },
796 #ifdef IPV6_FLOWINFO_SEND
797 { IPV6_FLOWINFO_SEND, "IPV6_FLOWINFO_SEND" },
799 #ifdef IPV6_ADD_MEMBERSHIP
800 { IPV6_ADD_MEMBERSHIP, "IPV6_ADD_MEMBERSHIP" },
802 #ifdef IPV6_DROP_MEMBERSHIP
803 { IPV6_DROP_MEMBERSHIP, "IPV6_DROP_MEMBERSHIP" },
805 #ifdef IPV6_ROUTER_ALERT
806 { IPV6_ROUTER_ALERT, "IPV6_ROUTER_ALERT" },
810 #endif /* SOL_IPV6 */
813 static const struct xlat sockipxoptions[] = {
814 { IPX_TYPE, "IPX_TYPE" },
820 static const struct xlat sockrawoptions[] = {
821 #if defined(ICMP_FILTER)
822 { ICMP_FILTER, "ICMP_FILTER" },
829 static const struct xlat sockpacketoptions[] = {
830 #ifdef PACKET_ADD_MEMBERSHIP
831 { PACKET_ADD_MEMBERSHIP, "PACKET_ADD_MEMBERSHIP" },
833 #ifdef PACKET_DROP_MEMBERSHIP
834 { PACKET_DROP_MEMBERSHIP, "PACKET_DROP_MEMBERSHIP"},
836 #if defined(PACKET_RECV_OUTPUT)
837 { PACKET_RECV_OUTPUT, "PACKET_RECV_OUTPUT" },
839 #if defined(PACKET_RX_RING)
840 { PACKET_RX_RING, "PACKET_RX_RING" },
842 #if defined(PACKET_STATISTICS)
843 { PACKET_STATISTICS, "PACKET_STATISTICS" },
845 #if defined(PACKET_COPY_THRESH)
846 { PACKET_COPY_THRESH, "PACKET_COPY_THRESH" },
848 #if defined(PACKET_AUXDATA)
849 { PACKET_AUXDATA, "PACKET_AUXDATA" },
851 #if defined(PACKET_ORIGDEV)
852 { PACKET_ORIGDEV, "PACKET_ORIGDEV" },
854 #if defined(PACKET_VERSION)
855 { PACKET_VERSION, "PACKET_VERSION" },
857 #if defined(PACKET_HDRLEN)
858 { PACKET_HDRLEN, "PACKET_HDRLEN" },
860 #if defined(PACKET_RESERVE)
861 { PACKET_RESERVE, "PACKET_RESERVE" },
863 #if defined(PACKET_TX_RING)
864 { PACKET_TX_RING, "PACKET_TX_RING" },
866 #if defined(PACKET_LOSS)
867 { PACKET_LOSS, "PACKET_LOSS" },
871 #endif /* SOL_PACKET */
873 #if !defined (SOL_TCP) && defined (IPPROTO_TCP)
874 #define SOL_TCP IPPROTO_TCP
878 static const struct xlat socktcpoptions[] = {
879 { TCP_NODELAY, "TCP_NODELAY" },
880 { TCP_MAXSEG, "TCP_MAXSEG" },
881 #if defined(TCP_CORK)
882 { TCP_CORK, "TCP_CORK" },
884 #if defined(TCP_KEEPIDLE)
885 { TCP_KEEPIDLE, "TCP_KEEPIDLE" },
887 #if defined(TCP_KEEPINTVL)
888 { TCP_KEEPINTVL, "TCP_KEEPINTVL" },
890 #if defined(TCP_KEEPCNT)
891 { TCP_KEEPCNT, "TCP_KEEPCNT" },
893 #if defined(TCP_NKEEP)
894 { TCP_NKEEP, "TCP_NKEEP" },
896 #if defined(TCP_SYNCNT)
897 { TCP_SYNCNT, "TCP_SYNCNT" },
899 #if defined(TCP_LINGER2)
900 { TCP_LINGER2, "TCP_LINGER2" },
902 #if defined(TCP_DEFER_ACCEPT)
903 { TCP_DEFER_ACCEPT, "TCP_DEFER_ACCEPT" },
905 #if defined(TCP_WINDOW_CLAMP)
906 { TCP_WINDOW_CLAMP, "TCP_WINDOW_CLAMP" },
908 #if defined(TCP_INFO)
909 { TCP_INFO, "TCP_INFO" },
911 #if defined(TCP_QUICKACK)
912 { TCP_QUICKACK, "TCP_QUICKACK" },
919 static const struct xlat icmpfilterflags[] = {
920 #if defined(ICMP_ECHOREPLY)
921 { (1<<ICMP_ECHOREPLY), "ICMP_ECHOREPLY" },
923 #if defined(ICMP_DEST_UNREACH)
924 { (1<<ICMP_DEST_UNREACH), "ICMP_DEST_UNREACH" },
926 #if defined(ICMP_SOURCE_QUENCH)
927 { (1<<ICMP_SOURCE_QUENCH), "ICMP_SOURCE_QUENCH" },
929 #if defined(ICMP_REDIRECT)
930 { (1<<ICMP_REDIRECT), "ICMP_REDIRECT" },
932 #if defined(ICMP_ECHO)
933 { (1<<ICMP_ECHO), "ICMP_ECHO" },
935 #if defined(ICMP_TIME_EXCEEDED)
936 { (1<<ICMP_TIME_EXCEEDED), "ICMP_TIME_EXCEEDED" },
938 #if defined(ICMP_PARAMETERPROB)
939 { (1<<ICMP_PARAMETERPROB), "ICMP_PARAMETERPROB" },
941 #if defined(ICMP_TIMESTAMP)
942 { (1<<ICMP_TIMESTAMP), "ICMP_TIMESTAMP" },
944 #if defined(ICMP_TIMESTAMPREPLY)
945 { (1<<ICMP_TIMESTAMPREPLY), "ICMP_TIMESTAMPREPLY" },
947 #if defined(ICMP_INFO_REQUEST)
948 { (1<<ICMP_INFO_REQUEST), "ICMP_INFO_REQUEST" },
950 #if defined(ICMP_INFO_REPLY)
951 { (1<<ICMP_INFO_REPLY), "ICMP_INFO_REPLY" },
953 #if defined(ICMP_ADDRESS)
954 { (1<<ICMP_ADDRESS), "ICMP_ADDRESS" },
956 #if defined(ICMP_ADDRESSREPLY)
957 { (1<<ICMP_ADDRESSREPLY), "ICMP_ADDRESSREPLY" },
963 #if defined(AF_PACKET) /* from e.g. linux/if_packet.h */
964 static const struct xlat af_packet_types[] = {
965 #if defined(PACKET_HOST)
966 { PACKET_HOST, "PACKET_HOST" },
968 #if defined(PACKET_BROADCAST)
969 { PACKET_BROADCAST, "PACKET_BROADCAST" },
971 #if defined(PACKET_MULTICAST)
972 { PACKET_MULTICAST, "PACKET_MULTICAST" },
974 #if defined(PACKET_OTHERHOST)
975 { PACKET_OTHERHOST, "PACKET_OTHERHOST" },
977 #if defined(PACKET_OUTGOING)
978 { PACKET_OUTGOING, "PACKET_OUTGOING" },
980 #if defined(PACKET_LOOPBACK)
981 { PACKET_LOOPBACK, "PACKET_LOOPBACK" },
983 #if defined(PACKET_FASTROUTE)
984 { PACKET_FASTROUTE, "PACKET_FASTROUTE" },
988 #endif /* defined(AF_PACKET) */
992 printsock(struct tcb *tcp, long addr, int addrlen)
997 struct sockaddr_in sin;
998 struct sockaddr_un sau;
999 #ifdef HAVE_INET_NTOP
1000 struct sockaddr_in6 sa6;
1002 #if defined(LINUX) && defined(AF_IPX)
1003 struct sockaddr_ipx sipx;
1006 struct sockaddr_ll ll;
1009 struct sockaddr_nl nl;
1012 char string_addr[100];
1018 if (!verbose(tcp)) {
1019 tprintf("%#lx", addr);
1023 if (addrlen < 2 || addrlen > sizeof(addrbuf))
1024 addrlen = sizeof(addrbuf);
1026 memset(&addrbuf, 0, sizeof(addrbuf));
1027 if (umoven(tcp, addr, addrlen, addrbuf.pad) < 0) {
1031 addrbuf.pad[sizeof(addrbuf.pad) - 1] = '\0';
1033 tprintf("{sa_family=");
1034 printxval(addrfams, addrbuf.sa.sa_family, "AF_???");
1037 switch (addrbuf.sa.sa_family) {
1041 } else if (addrbuf.sau.sun_path[0]) {
1043 printpathn(tcp, addr + 2, strlen(addrbuf.sau.sun_path));
1046 printpathn(tcp, addr + 3, strlen(addrbuf.sau.sun_path + 1));
1050 tprintf("sin_port=htons(%u), sin_addr=inet_addr(\"%s\")",
1051 ntohs(addrbuf.sin.sin_port), inet_ntoa(addrbuf.sin.sin_addr));
1053 #ifdef HAVE_INET_NTOP
1055 inet_ntop(AF_INET6, &addrbuf.sa6.sin6_addr, string_addr, sizeof(string_addr));
1056 tprintf("sin6_port=htons(%u), inet_pton(AF_INET6, \"%s\", &sin6_addr), sin6_flowinfo=%u",
1057 ntohs(addrbuf.sa6.sin6_port), string_addr,
1058 addrbuf.sa6.sin6_flowinfo);
1059 #ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID
1061 #if defined(HAVE_IF_INDEXTONAME) && defined(IN6_IS_ADDR_LINKLOCAL) && defined(IN6_IS_ADDR_MC_LINKLOCAL)
1062 int numericscope = 0;
1063 if (IN6_IS_ADDR_LINKLOCAL (&addrbuf.sa6.sin6_addr)
1064 || IN6_IS_ADDR_MC_LINKLOCAL (&addrbuf.sa6.sin6_addr)) {
1065 char scopebuf[IFNAMSIZ + 1];
1067 if (if_indextoname (addrbuf.sa6.sin6_scope_id, scopebuf) == NULL)
1070 tprintf(", sin6_scope_id=if_nametoindex(\"%s\")", scopebuf);
1076 tprintf(", sin6_scope_id=%u", addrbuf.sa6.sin6_scope_id);
1081 #if defined(AF_IPX) && defined(linux)
1085 tprintf("sipx_port=htons(%u), ",
1086 ntohs(addrbuf.sipx.sipx_port));
1087 /* Yes, I know, this does not look too
1088 * strace-ish, but otherwise the IPX
1089 * addresses just look monstrous...
1090 * Anyways, feel free if you don't like
1093 tprintf("%08lx:", (unsigned long)ntohl(addrbuf.sipx.sipx_network));
1094 for (i = 0; i<IPX_NODE_LEN; i++)
1095 tprintf("%02x", addrbuf.sipx.sipx_node[i]);
1096 tprintf("/[%02x]", addrbuf.sipx.sipx_type);
1099 #endif /* AF_IPX && linux */
1104 tprintf("proto=%#04x, if%d, pkttype=",
1105 ntohs(addrbuf.ll.sll_protocol),
1106 addrbuf.ll.sll_ifindex);
1107 printxval(af_packet_types, addrbuf.ll.sll_pkttype, "?");
1108 tprintf(", addr(%d)={%d, ",
1109 addrbuf.ll.sll_halen,
1110 addrbuf.ll.sll_hatype);
1111 for (i=0; i<addrbuf.ll.sll_halen; i++)
1112 tprintf("%02x", addrbuf.ll.sll_addr[i]);
1116 #endif /* AF_APACKET */
1119 tprintf("pid=%d, groups=%08x", addrbuf.nl.nl_pid, addrbuf.nl.nl_groups);
1121 #endif /* AF_NETLINK */
1122 /* AF_AX25 AF_APPLETALK AF_NETROM AF_BRIDGE AF_AAL5
1123 AF_X25 AF_ROSE etc. still need to be done */
1126 tprintf("sa_data=");
1127 printstr(tcp, (long) &((struct sockaddr *) addr)->sa_data,
1128 sizeof addrbuf.sa.sa_data);
1135 static const struct xlat scmvals[] = {
1137 { SCM_RIGHTS, "SCM_RIGHTS" },
1139 #ifdef SCM_CREDENTIALS
1140 { SCM_CREDENTIALS, "SCM_CREDENTIALS" },
1146 printcmsghdr(struct tcb *tcp, unsigned long addr, unsigned long len)
1148 struct cmsghdr *cmsg = len < sizeof(struct cmsghdr) ?
1150 if (cmsg == NULL || umoven(tcp, addr, len, (char *) cmsg) < 0) {
1151 tprintf(", msg_control=%#lx", addr);
1156 tprintf(", {cmsg_len=%u, cmsg_level=", (unsigned) cmsg->cmsg_len);
1157 printxval(socketlayers, cmsg->cmsg_level, "SOL_???");
1158 tprintf(", cmsg_type=");
1160 if (cmsg->cmsg_level == SOL_SOCKET) {
1161 unsigned long cmsg_len;
1163 printxval(scmvals, cmsg->cmsg_type, "SCM_???");
1164 cmsg_len = (len < cmsg->cmsg_len) ? len : cmsg->cmsg_len;
1166 if (cmsg->cmsg_type == SCM_RIGHTS
1167 && CMSG_LEN(sizeof(int)) <= cmsg_len) {
1168 int *fds = (int *) CMSG_DATA (cmsg);
1172 while ((char *) fds < ((char *) cmsg + cmsg_len)) {
1175 tprintf("%d", *fds++);
1182 if (cmsg->cmsg_type == SCM_CREDENTIALS
1183 && CMSG_LEN(sizeof(struct ucred)) <= cmsg_len) {
1184 struct ucred *uc = (struct ucred *) CMSG_DATA (cmsg);
1186 tprintf("{pid=%ld, uid=%ld, gid=%ld}}",
1187 (long)uc->pid, (long)uc->uid, (long)uc->gid);
1197 do_msghdr(struct tcb *tcp, struct msghdr *msg)
1199 tprintf("{msg_name(%d)=", msg->msg_namelen);
1200 printsock(tcp, (long)msg->msg_name, msg->msg_namelen);
1202 tprintf(", msg_iov(%lu)=", (unsigned long)msg->msg_iovlen);
1203 tprint_iov(tcp, (unsigned long)msg->msg_iovlen,
1204 (unsigned long)msg->msg_iov);
1206 #ifdef HAVE_STRUCT_MSGHDR_MSG_CONTROL
1207 tprintf(", msg_controllen=%lu", (unsigned long)msg->msg_controllen);
1208 if (msg->msg_controllen)
1209 printcmsghdr(tcp, (unsigned long) msg->msg_control,
1210 msg->msg_controllen);
1211 tprintf(", msg_flags=");
1212 printflags(msg_flags, msg->msg_flags, "MSG_???");
1213 #else /* !HAVE_STRUCT_MSGHDR_MSG_CONTROL */
1214 tprintf("msg_accrights=%#lx, msg_accrightslen=%u",
1215 (unsigned long) msg->msg_accrights, msg->msg_accrightslen);
1216 #endif /* !HAVE_STRUCT_MSGHDR_MSG_CONTROL */
1221 printmsghdr(tcp, addr)
1227 if (umove(tcp, addr, &msg) < 0) {
1228 tprintf("%#lx", addr);
1231 do_msghdr(tcp, &msg);
1236 printmmsghdr(struct tcb *tcp, long addr)
1239 struct msghdr msg_hdr;
1243 if (umove(tcp, addr, &mmsg) < 0) {
1244 tprintf("%#lx", addr);
1248 do_msghdr(tcp, &mmsg.msg_hdr);
1249 tprintf(", %u}", mmsg.msg_len);
1253 #endif /* HAVE_SENDMSG */
1256 * low bits of the socket type define real socket type,
1257 * other bits are socket type flags.
1260 tprint_sock_type(struct tcb *tcp, int flags)
1262 const char *str = xlookup(socktypes, flags & SOCK_TYPE_MASK);
1267 flags &= ~SOCK_TYPE_MASK;
1272 printflags(sock_type_flags, flags, "SOCK_???");
1276 sys_socket(struct tcb *tcp)
1278 if (entering(tcp)) {
1279 printxval(domains, tcp->u_arg[0], "PF_???");
1281 tprint_sock_type(tcp, tcp->u_arg[1]);
1283 switch (tcp->u_arg[0]) {
1288 printxval(protocols, tcp->u_arg[2], "IPPROTO_???");
1292 /* BTW: I don't believe this.. */
1294 printxval(domains, tcp->u_arg[2], "PF_???");
1299 tprintf("%lu", tcp->u_arg[2]);
1311 if (entering(tcp)) {
1312 /* not sure really what these args are... but this
1313 * is how truss prints it
1315 tprintf("%ld, %ld, %ld, ",
1316 tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]);
1317 printpath(tcp, tcp->u_arg[3]);
1318 tprintf(", %ld", tcp->u_arg[4]);
1324 sys_so_socketpair(tcp)
1327 if (entering(tcp)) {
1328 /* not sure what this arg is */
1329 tprintf("0x%lx", tcp->u_arg[0]);
1339 if (entering(tcp)) {
1340 tprintf("%ld, ", tcp->u_arg[0]);
1341 printsock(tcp, tcp->u_arg[1], tcp->u_arg[2]);
1342 tprintf(", %lu", tcp->u_arg[2]);
1351 return sys_bind(tcp);
1358 if (entering(tcp)) {
1359 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
1365 do_accept(struct tcb *tcp, int flags_arg)
1367 if (entering(tcp)) {
1368 tprintf("%ld, ", tcp->u_arg[0]);
1372 tprintf("%#lx, NULL", tcp->u_arg[1]);
1375 if (tcp->u_arg[1] == 0 || syserror(tcp)
1376 || umove (tcp, tcp->u_arg[2], &len) < 0) {
1377 tprintf("%#lx", tcp->u_arg[1]);
1379 printsock(tcp, tcp->u_arg[1], len);
1382 printnum_int(tcp, tcp->u_arg[2], "%u");
1384 if (flags_arg >= 0) {
1386 printflags(sock_type_flags, tcp->u_arg[flags_arg],
1393 sys_accept(struct tcb *tcp)
1395 return do_accept(tcp, -1);
1400 sys_accept4(struct tcb *tcp)
1402 return do_accept(tcp, 3);
1410 if (entering(tcp)) {
1411 tprintf("%ld, ", tcp->u_arg[0]);
1412 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
1413 tprintf(", %lu, ", tcp->u_arg[2]);
1415 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
1424 if (entering(tcp)) {
1425 tprintf("%ld, ", tcp->u_arg[0]);
1426 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
1427 tprintf(", %lu, ", tcp->u_arg[2]);
1429 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
1432 printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]);
1434 tprintf(", %lu", tcp->u_arg[5]);
1445 if (entering(tcp)) {
1446 tprintf("%ld, ", tcp->u_arg[0]);
1447 printmsghdr(tcp, tcp->u_arg[1]);
1450 printflags(msg_flags, tcp->u_arg[2], "MSG_???");
1455 #endif /* HAVE_SENDMSG */
1461 if (entering(tcp)) {
1462 tprintf("%ld, ", tcp->u_arg[0]);
1465 tprintf("%#lx", tcp->u_arg[1]);
1467 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
1469 tprintf(", %lu, ", tcp->u_arg[2]);
1470 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
1481 if (entering(tcp)) {
1482 tprintf("%ld, ", tcp->u_arg[0]);
1484 if (syserror(tcp)) {
1485 tprintf("%#lx, %lu, %lu, %#lx, %#lx",
1486 tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3],
1487 tcp->u_arg[4], tcp->u_arg[5]);
1491 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
1493 tprintf(", %lu, ", tcp->u_arg[2]);
1495 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
1496 /* from address, len */
1497 if (!tcp->u_arg[4] || !tcp->u_arg[5]) {
1498 if (tcp->u_arg[4] == 0)
1501 tprintf(", %#lx", tcp->u_arg[4]);
1502 if (tcp->u_arg[5] == 0)
1505 tprintf(", %#lx", tcp->u_arg[5]);
1508 if (umove(tcp, tcp->u_arg[5], &fromlen) < 0) {
1509 tprintf(", {...}, [?]");
1513 printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]);
1515 tprintf(", [%u]", fromlen);
1526 if (entering(tcp)) {
1527 tprintf("%ld, ", tcp->u_arg[0]);
1529 if (syserror(tcp) || !verbose(tcp))
1530 tprintf("%#lx", tcp->u_arg[1]);
1532 printmsghdr(tcp, tcp->u_arg[1]);
1535 printflags(msg_flags, tcp->u_arg[2], "MSG_???");
1542 sys_recvmmsg(struct tcb *tcp)
1544 static char str[128];
1545 if (entering(tcp)) {
1547 tprintf("%ld, ", tcp->u_arg[0]);
1549 sprint_timespec(str, tcp, tcp->u_arg[4]);
1550 tcp->auxstr = strdup(str);
1552 tprintf("%#lx, %ld, ", tcp->u_arg[1], tcp->u_arg[2]);
1553 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
1555 print_timespec(tcp, tcp->u_arg[4]);
1561 tprintf("%#lx", tcp->u_arg[1]);
1563 printmmsghdr(tcp, tcp->u_arg[1]);
1564 tprintf(", %ld, ", tcp->u_arg[2]);
1566 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
1567 /* timeout on entrance */
1568 tprintf(", %s", tcp->auxstr ? tcp->auxstr : "{...}");
1569 free((void *) tcp->auxstr);
1574 if (tcp->u_rval == 0) {
1575 tcp->auxstr = "Timeout";
1580 /* timeout on exit */
1581 strcpy(str, "left ");
1582 sprint_timespec(str + strlen(str), tcp, tcp->u_arg[4]);
1589 #endif /* HAVE_SENDMSG */
1595 if (entering(tcp)) {
1596 tprintf("%ld, %ld", tcp->u_arg[0], tcp->u_arg[1]);
1597 switch (tcp->u_arg[1]) {
1599 tprintf("%s", " /* receive */");
1602 tprintf("%s", " /* send */");
1605 tprintf("%s", " /* send and receive */");
1613 sys_getsockname(tcp)
1616 return sys_accept(tcp);
1620 sys_getpeername(tcp)
1623 return sys_accept(tcp);
1627 do_pipe(struct tcb *tcp, int flags_arg)
1630 if (syserror(tcp)) {
1631 tprintf("%#lx", tcp->u_arg[0]);
1633 #if defined(LINUX) && !defined(SPARC) && !defined(SPARC64) && !defined(SH) && !defined(IA64)
1636 if (umoven(tcp, tcp->u_arg[0], sizeof fds, (char *) fds) < 0)
1639 tprintf("[%u, %u]", fds[0], fds[1]);
1640 #elif defined(SPARC) || defined(SPARC64) || defined(SH) || defined(SVR4) || defined(FREEBSD) || defined(IA64)
1641 tprintf("[%lu, %lu]", tcp->u_rval, getrval2(tcp));
1643 tprintf("%#lx", tcp->u_arg[0]);
1646 if (flags_arg >= 0) {
1648 printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???");
1655 sys_pipe(struct tcb *tcp)
1657 return do_pipe(tcp, -1);
1662 sys_pipe2(struct tcb *tcp)
1664 return do_pipe(tcp, 1);
1669 sys_socketpair(struct tcb *tcp)
1675 if (entering(tcp)) {
1676 printxval(domains, tcp->u_arg[0], "PF_???");
1678 tprint_sock_type(tcp, tcp->u_arg[1]);
1680 switch (tcp->u_arg[0]) {
1682 printxval(protocols, tcp->u_arg[2], "IPPROTO_???");
1686 /* BTW: I don't believe this.. */
1688 printxval(domains, tcp->u_arg[2], "PF_???");
1693 tprintf("%lu", tcp->u_arg[2]);
1697 if (syserror(tcp)) {
1698 tprintf(", %#lx", tcp->u_arg[3]);
1702 if (umoven(tcp, tcp->u_arg[3], sizeof fds, (char *) fds) < 0)
1705 tprintf(", [%u, %u]", fds[0], fds[1]);
1707 #if defined(SUNOS4) || defined(SVR4) || defined(FREEBSD)
1708 tprintf(", [%lu, %lu]", tcp->u_rval, getrval2(tcp));
1709 #endif /* SUNOS4 || SVR4 || FREEBSD */
1715 sys_getsockopt(struct tcb *tcp)
1717 if (entering(tcp)) {
1718 tprintf("%ld, ", tcp->u_arg[0]);
1719 printxval(socketlayers, tcp->u_arg[1], "SOL_???");
1721 switch (tcp->u_arg[1]) {
1723 printxval(sockoptions, tcp->u_arg[2], "SO_???");
1727 printxval(sockipoptions, tcp->u_arg[2], "IP_???");
1732 printxval(sockipv6options, tcp->u_arg[2], "IPV6_???");
1737 printxval(sockipxoptions, tcp->u_arg[2], "IPX_???");
1742 printxval(sockpacketoptions, tcp->u_arg[2], "PACKET_???");
1747 printxval(socktcpoptions, tcp->u_arg[2], "TCP_???");
1751 /* SOL_AX25 SOL_ROSE SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25
1752 * etc. still need work */
1754 tprintf("%lu", tcp->u_arg[2]);
1760 if (syserror(tcp) || umove (tcp, tcp->u_arg[4], &len) < 0) {
1761 tprintf("%#lx, %#lx",
1762 tcp->u_arg[3], tcp->u_arg[4]);
1766 switch (tcp->u_arg[1]) {
1768 switch (tcp->u_arg[2]) {
1771 if (len == sizeof (struct linger)) {
1772 struct linger linger;
1777 tprintf("{onoff=%d, linger=%d}, "
1788 if (len == sizeof (struct ucred)) {
1794 tprintf("{pid=%ld, uid=%ld, gid=%ld}, "
1807 switch (tcp->u_arg[2]) {
1808 #ifdef PACKET_STATISTICS
1809 case PACKET_STATISTICS:
1810 if (len == sizeof(struct tpacket_stats)) {
1811 struct tpacket_stats stats;
1816 tprintf("{packets=%u, drops=%u}, "
1829 if (len == sizeof (int)) {
1830 printnum_int(tcp, tcp->u_arg[3], "%d");
1833 printstr (tcp, tcp->u_arg[3], len);
1835 tprintf(", [%d]", len);
1840 #if defined(ICMP_FILTER)
1841 static void printicmpfilter(tcp, addr)
1845 struct icmp_filter filter;
1851 if (syserror(tcp) || !verbose(tcp)) {
1852 tprintf("%#lx", addr);
1855 if (umove(tcp, addr, &filter) < 0) {
1861 printflags(icmpfilterflags, ~filter.data, "ICMP_???");
1864 #endif /* ICMP_FILTER */
1867 printsockopt (tcp, level, name, addr, len)
1874 printxval(socketlayers, level, "SOL_??");
1878 printxval(sockoptions, name, "SO_???");
1880 #if defined(SO_LINGER)
1882 if (len == sizeof (struct linger)) {
1883 struct linger linger;
1884 if (umove (tcp, addr, &linger) < 0)
1886 tprintf(", {onoff=%d, linger=%d}",
1897 printxval(sockipoptions, name, "IP_???");
1902 printxval(sockipv6options, name, "IPV6_???");
1907 printxval(sockipxoptions, name, "IPX_???");
1912 printxval(sockpacketoptions, name, "PACKET_???");
1913 /* TODO: decode packate_mreq for PACKET_*_MEMBERSHIP */
1915 #ifdef PACKET_RX_RING
1916 case PACKET_RX_RING:
1918 #ifdef PACKET_TX_RING
1919 case PACKET_TX_RING:
1921 #if defined(PACKET_RX_RING) || defined(PACKET_TX_RING)
1922 if (len == sizeof(struct tpacket_req)) {
1923 struct tpacket_req req;
1924 if (umove(tcp, addr, &req) < 0)
1926 tprintf(", {block_size=%u, block_nr=%u, frame_size=%u, frame_nr=%u}",
1934 #endif /* PACKET_RX_RING || PACKET_TX_RING */
1940 printxval(socktcpoptions, name, "TCP_???");
1945 printxval(sockrawoptions, name, "RAW_???");
1947 #if defined(ICMP_FILTER)
1950 printicmpfilter(tcp, addr);
1957 /* SOL_AX25 SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25
1958 * etc. still need work */
1961 tprintf("%u", name);
1964 /* default arg printing */
1968 if (len == sizeof (int)) {
1969 printnum_int (tcp, addr, "%d");
1972 printstr (tcp, addr, len);
1978 #ifdef HAVE_STRUCT_OPTHDR
1981 print_sock_optmgmt (tcp, addr, len)
1989 while (len >= (int) sizeof hdr) {
1990 if (umove(tcp, addr, &hdr) < 0) break;
1994 else if (len > hdr.len + sizeof hdr) {
2000 printsockopt (tcp, hdr.level, hdr.name, addr, hdr.len);
2008 if (c++) tprintf (", ");
2009 printstr (tcp, addr, len);
2011 if (c > 1) tprintf ("]");
2020 if (entering(tcp)) {
2021 tprintf("%ld, ", tcp->u_arg[0]);
2022 printsockopt (tcp, tcp->u_arg[1], tcp->u_arg[2],
2023 tcp->u_arg[3], tcp->u_arg[4]);
2024 tprintf(", %lu", tcp->u_arg[4]);
2031 static const struct xlat sock_version[] = {
2032 { __NETLIB_UW211_SVR4, "UW211_SVR4" },
2033 { __NETLIB_UW211_XPG4, "UW211_XPG4" },
2034 { __NETLIB_GEMINI_SVR4, "GEMINI_SVR4" },
2035 { __NETLIB_GEMINI_XPG4, "GEMINI_XPG4" },
2036 { __NETLIB_FP1_SVR4, "FP1_SVR4" },
2037 { __NETLIB_FP1_XPG4, "FP1_XPG4" },
2043 netlib_call(tcp, func)
2047 if (entering(tcp)) {
2049 printxval (sock_version, tcp->u_arg[0], "__NETLIB_???");
2052 for (i = 0; i < tcp->u_nargs; i++)
2053 tcp->u_arg[i] = tcp->u_arg[i + 1];
2065 return netlib_call (tcp, sys_socket);
2069 sys_xsocketpair(tcp)
2072 return netlib_call (tcp, sys_socketpair);
2079 return netlib_call (tcp, sys_bind);
2086 return netlib_call (tcp, sys_connect);
2093 return netlib_call (tcp, sys_listen);
2100 return netlib_call (tcp, sys_accept);
2107 return netlib_call (tcp, sys_sendmsg);
2114 return netlib_call (tcp, sys_recvmsg);
2118 sys_xgetsockaddr(tcp)
2121 if (entering(tcp)) {
2122 printxval (sock_version, tcp->u_arg[0], "__NETLIB_???");
2124 if (tcp->u_arg[1] == 0) {
2125 tprintf ("LOCALNAME, ");
2127 else if (tcp->u_arg[1] == 1) {
2128 tprintf ("REMOTENAME, ");
2131 tprintf ("%ld, ", tcp->u_arg [1]);
2133 tprintf ("%ld, ", tcp->u_arg [2]);
2136 if (tcp->u_arg[3] == 0 || syserror(tcp)) {
2137 tprintf("%#lx", tcp->u_arg[3]);
2139 printsock(tcp, tcp->u_arg[3], tcp->u_arg[4]);
2142 printnum(tcp, tcp->u_arg[4], "%lu");
2150 sys_xgetsockopt(tcp)
2153 return netlib_call (tcp, sys_getsockopt);
2157 sys_xsetsockopt(tcp)
2160 return netlib_call (tcp, sys_setsockopt);
2167 return netlib_call (tcp, sys_shutdown);
2170 #endif /* UNIXWARE */