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 struct xlat domains[] = {
120 { PF_UNSPEC, "PF_UNSPEC" },
121 { PF_UNIX, "PF_UNIX" },
122 { PF_INET, "PF_INET" },
124 { PF_NETLINK, "PF_NETLINK" },
127 { PF_PACKET, "PF_PACKET" },
130 { PF_INET6, "PF_INET6" },
133 { PF_ATMSVC, "PF_INET6" },
136 { PF_INET6, "PF_INET6" },
139 { PF_LOCAL, "PS_LOCAL" },
142 { PF_ISO, "PF_ISO" },
145 { PF_AX25, "PF_AX25" },
148 { PF_IPX, "PF_IPX" },
151 { PF_APPLETALK, "PF_APPLETALK" },
154 { PF_NETROM, "PF_NETROM" },
157 { PF_BRIDGE, "PF_BRIDGE" },
160 { PF_AAL5, "PF_AAL5" },
163 { PF_X25, "PF_X25" },
166 { PF_ROSE, "PF_ROSE" },
169 { PF_DECNET, "PF_DECNET" },
172 { PF_NETBEUI, "PF_NETBEUI" },
175 { PF_IMPLINK, "PF_IMPLINK" },
179 static struct xlat addrfams[] = {
180 { AF_UNSPEC, "AF_UNSPEC" },
181 { AF_UNIX, "AF_UNIX" },
182 { AF_INET, "AF_INET" },
184 { AF_INET6, "AF_INET6" },
186 { AF_DECnet, "AF_DECnet" },
188 { AF_ATMSVC, "AF_ATMSVC" },
191 { AF_PACKET, "AF_PACKET" },
194 { AF_NETLINK, "AF_NETLINK" },
197 { AF_ISO, "AF_ISO" },
200 { AF_IMPLINK, "AF_IMPLINK" },
204 static struct xlat socktypes[] = {
205 { SOCK_STREAM, "SOCK_STREAM" },
206 { SOCK_DGRAM, "SOCK_DGRAM" },
208 { SOCK_RAW, "SOCK_RAW" },
210 #ifdef SOCK_SEQPACKET
211 { SOCK_SEQPACKET,"SOCK_SEQPACKET"},
214 { SOCK_RDM, "SOCK_RDM" },
217 { SOCK_PACKET, "SOCK_PACKET" },
221 static struct xlat socketlayers[] = {
223 { SOL_IP, "SOL_IP" },
225 #if defined(SOL_ICMP)
226 { SOL_ICMP, "SOL_ICMP" },
229 { SOL_TCP, "SOL_TCP" },
232 { SOL_UDP, "SOL_UDP" },
234 #if defined(SOL_IPV6)
235 { SOL_IPV6, "SOL_IPV6" },
237 #if defined(SOL_ICMPV6)
238 { SOL_ICMPV6, "SOL_ICMPV6" },
241 { SOL_RAW, "SOL_RAW" },
244 { SOL_IPX, "SOL_IPX" },
247 { SOL_IPX, "SOL_IPX" },
249 #if defined(SOL_AX25)
250 { SOL_AX25, "SOL_AX25" },
252 #if defined(SOL_ATALK)
253 { SOL_ATALK, "SOL_ATALK" },
255 #if defined(SOL_NETROM)
256 { SOL_NETROM, "SOL_NETROM" },
258 #if defined(SOL_ROSE)
259 { SOL_ROSE, "SOL_ROSE" },
261 #if defined(SOL_DECNET)
262 { SOL_DECNET, "SOL_DECNET" },
265 { SOL_X25, "SOL_X25" },
267 #if defined(SOL_PACKET)
268 { SOL_PACKET, "SOL_PACKET" },
271 { SOL_ATM, "SOL_ATM" },
274 { SOL_AAL, "SOL_AAL" },
276 #if defined(SOL_IRDA)
277 { SOL_IRDA, "SOL_IRDA" },
279 { SOL_SOCKET, "SOL_SOCKET" }, /* Never used! */
281 static struct xlat protocols[] = {
282 { IPPROTO_IP, "IPPROTO_IP" },
283 { IPPROTO_ICMP, "IPPROTO_ICMP" },
284 { IPPROTO_TCP, "IPPROTO_TCP" },
285 { IPPROTO_UDP, "IPPROTO_UDP" },
287 { IPPROTO_GGP, "IPPROTO_GGP" },
290 { IPPROTO_EGP, "IPPROTO_EGP" },
293 { IPPROTO_PUP, "IPPROTO_PUP" },
296 { IPPROTO_IDP, "IPPROTO_IDP" },
299 { IPPROTO_IPV6, "IPPROTO_IPV6" },
301 #ifdef IPPROTO_ICMPV6
302 { IPPROTO_ICMPV6,"IPPROTO_ICMPV6"},
305 { IPPROTO_IGMP, "IPPROTO_IGMP" },
308 { IPPROTO_HELLO,"IPPROTO_HELLO" },
311 { IPPROTO_ND, "IPPROTO_ND" },
314 { IPPROTO_RAW, "IPPROTO_RAW" },
317 { IPPROTO_MAX, "IPPROTO_MAX" },
320 { IPPROTO_IPIP, "IPPROTO_IPIP" },
324 static struct xlat msg_flags[] = {
325 { MSG_OOB, "MSG_OOB" },
327 { MSG_DONTROUTE,"MSG_DONTROUTE" },
330 { MSG_PEEK, "MSG_PEEK" },
333 { MSG_CTRUNC, "MSG_CTRUNC" },
336 { MSG_PROXY, "MSG_PROXY" },
339 { MSG_EOR, "MSG_EOR" },
342 { MSG_WAITALL, "MSG_WAITALL" },
345 { MSG_TRUNC, "MSG_TRUNC" },
348 { MSG_CTRUNC, "MSG_CTRUNC" },
351 { MSG_ERRQUEUE, "MSG_ERRQUEUE" },
354 { MSG_DONTWAIT, "MSG_DONTWAIT" },
357 { MSG_CONFIRM, "MSG_CONFIRM" },
360 { MSG_PROBE, "MSG_PROBE" },
365 static struct xlat sockoptions[] = {
367 { SO_PEERCRED, "SO_PEERCRED" },
370 { SO_PASSCRED, "SO_PASSCRED" },
373 { SO_DEBUG, "SO_DEBUG" },
376 { SO_REUSEADDR, "SO_REUSEADDR" },
379 { SO_KEEPALIVE, "SO_KEEPALIVE" },
382 { SO_DONTROUTE, "SO_DONTROUTE" },
385 { SO_BROADCAST, "SO_BROADCAST" },
388 { SO_LINGER, "SO_LINGER" },
391 { SO_OOBINLINE, "SO_OOBINLINE" },
394 { SO_TYPE, "SO_TYPE" },
397 { SO_ERROR, "SO_ERROR" },
400 { SO_SNDBUF, "SO_SNDBUF" },
403 { SO_RCVBUF, "SO_RCVBUF" },
406 { SO_NO_CHECK, "SO_NO_CHECK" },
409 { SO_PRIORITY, "SO_PRIORITY" },
412 { SO_ACCEPTCONN,"SO_ACCEPTCONN" },
414 #ifdef SO_USELOOPBACK
415 { SO_USELOOPBACK,"SO_USELOOPBACK"},
418 { SO_SNDLOWAT, "SO_SNDLOWAT" },
421 { SO_RCVLOWAT, "SO_RCVLOWAT" },
424 { SO_SNDTIMEO, "SO_SNDTIMEO" },
427 { SO_RCVTIMEO, "SO_RCVTIMEO" },
430 { SO_BSDCOMPAT, "SO_BSDCOMPAT" },
433 { SO_REUSEPORT, "SO_REUSEPORT" },
436 { SO_RCVLOWAT, "SO_RCVLOWAT" },
439 { SO_SNDLOWAT, "SO_SNDLOWAT" },
442 { SO_RCVTIMEO, "SO_RCVTIMEO" },
445 { SO_SNDTIMEO, "SO_SNDTIMEO" },
451 static struct xlat sockipoptions[] = {
452 { IP_TOS, "IP_TOS" },
453 { IP_TTL, "IP_TTL" },
454 #if defined(IP_HDRINCL)
455 { IP_HDRINCL, "IP_HDRINCL" },
457 #if defined(IP_OPTIONS)
458 { IP_OPTIONS, "IP_OPTIONS" },
460 { IP_ROUTER_ALERT, "IP_ROUTER_ALERT" },
461 #if defined(IP_RECVOPTIONS)
462 { IP_RECVOPTIONS, "IP_RECVOPTIONS" },
464 { IP_RETOPTS, "IP_RETOPTS" },
465 { IP_PKTINFO, "IP_PKTINFO" },
466 { IP_PKTOPTIONS, "IP_PKTOPTIONS" },
467 { IP_MTU_DISCOVER, "IP_MTU_DISCOVER" },
468 { IP_MTU_DISCOVER, "IP_MTU_DISCOVER" },
469 { IP_RECVERR, "IP_RECVERR" },
470 { IP_RECVTTL, "IP_RECRECVTTL" },
471 { IP_RECVTOS, "IP_RECRECVTOS" },
473 { IP_MTU, "IP_MTU" },
475 { IP_MULTICAST_IF, "IP_MULTICAST_IF" },
476 { IP_MULTICAST_TTL, "IP_MULTICAST_TTL" },
477 { IP_MULTICAST_LOOP, "IP_MULTICAST_LOOP" },
478 { IP_ADD_MEMBERSHIP, "IP_ADD_MEMBERSHIP" },
479 { IP_DROP_MEMBERSHIP, "IP_DROP_MEMBERSHIP" },
485 static struct xlat sockipxoptions[] = {
486 { IPX_TYPE, "IPX_TYPE" },
492 static struct xlat sockrawoptions[] = {
493 #if defined(ICMP_FILTER)
494 { ICMP_FILTER, "ICMP_FILTER" },
501 static struct xlat sockpacketoptions[] = {
502 { PACKET_ADD_MEMBERSHIP, "PACKET_ADD_MEMBERSHIP" },
503 { PACKET_DROP_MEMBERSHIP, "PACKET_DROP_MEMBERSHIP"},
504 #if defined(PACKET_RECV_OUTPUT)
505 { PACKET_RECV_OUTPUT, "PACKET_RECV_OUTPUT" },
507 #if defined(PACKET_RX_RING)
508 { PACKET_RX_RING, "PACKET_RX_RING" },
510 #if defined(PACKET_STATISTICS)
511 { PACKET_STATISTICS, "PACKET_STATISTICS" },
515 #endif /* SOL_PACKET */
518 static struct xlat socktcpoptions[] = {
519 { TCP_NODELAY, "TCP_NODELAY" },
520 { TCP_MAXSEG, "TCP_MAXSEG" },
521 #if defined(TCP_CORK)
522 { TCP_CORK, "TCP_CORK" },
529 static struct xlat icmpfilterflags[] = {
530 #if defined(ICMP_ECHOREPLY)
531 { (1<<ICMP_ECHOREPLY), "ICMP_ECHOREPLY" },
533 #if defined(ICMP_DEST_UNREACH)
534 { (1<<ICMP_DEST_UNREACH), "ICMP_DEST_UNREACH" },
536 #if defined(ICMP_SOURCE_QUENCH)
537 { (1<<ICMP_SOURCE_QUENCH), "ICMP_SOURCE_QUENCH" },
539 #if defined(ICMP_REDIRECT)
540 { (1<<ICMP_REDIRECT), "ICMP_REDIRECT" },
542 #if defined(ICMP_ECHO)
543 { (1<<ICMP_ECHO), "ICMP_ECHO" },
545 #if defined(ICMP_TIME_EXCEEDED)
546 { (1<<ICMP_TIME_EXCEEDED), "ICMP_TIME_EXCEEDED" },
548 #if defined(ICMP_PARAMETERPROB)
549 { (1<<ICMP_PARAMETERPROB), "ICMP_PARAMETERPROB" },
551 #if defined(ICMP_TIMESTAMP)
552 { (1<<ICMP_TIMESTAMP), "ICMP_TIMESTAMP" },
554 #if defined(ICMP_TIMESTAMPREPLY)
555 { (1<<ICMP_TIMESTAMPREPLY), "ICMP_TIMESTAMPREPLY" },
557 #if defined(ICMP_INFO_REQUEST)
558 { (1<<ICMP_INFO_REQUEST), "ICMP_INFO_REQUEST" },
560 #if defined(ICMP_INFO_REPLY)
561 { (1<<ICMP_INFO_REPLY), "ICMP_INFO_REPLY" },
563 #if defined(ICMP_ADDRESS)
564 { (1<<ICMP_ADDRESS), "ICMP_ADDRESS" },
566 #if defined(ICMP_ADDRESSREPLY)
567 { (1<<ICMP_ADDRESSREPLY), "ICMP_ADDRESSREPLY" },
575 printsock(tcp, addr, addrlen)
583 struct sockaddr_in sin;
584 struct sockaddr_un sau;
585 #ifdef HAVE_INET_NTOP
586 struct sockaddr_in6 sa6;
588 #if defined(LINUX) && defined(AF_IPX)
589 struct sockaddr_ipx sipx;
592 struct sockaddr_ll ll;
595 struct sockaddr_nl nl;
598 char string_addr[100];
605 tprintf("%#lx", addr);
608 if ((addrlen<2) || (addrlen>sizeof(addrbuf)))
609 addrlen=sizeof(addrbuf);
611 if (umoven(tcp, addr, addrlen, (char*)&addrbuf) < 0) {
616 tprintf("{sin_family=");
617 printxval(addrfams, addrbuf.sa.sa_family, "AF_???");
620 switch (addrbuf.sa.sa_family) {
624 } else if (addrbuf.sau.sun_path[0]) {
625 tprintf("path=\"%-.*s\"", addrlen-2, addrbuf.sau.sun_path);
627 tprintf("path=@%-.*s", addrlen-3, addrbuf.sau.sun_path+1);
631 tprintf("sin_port=htons(%u), sin_addr=inet_addr(\"%s\")}",
632 ntohs(addrbuf.sin.sin_port), inet_ntoa(addrbuf.sin.sin_addr));
634 #ifdef HAVE_INET_NTOP
636 inet_ntop(AF_INET6, &addrbuf.sa6.sin6_addr, string_addr, sizeof(string_addr));
637 tprintf("sin6_port=htons(%u), inet_pton(AF_INET6, \"%s\", &sin6_addr), sin6_flowinfo=%u",
638 ntohs(addrbuf.sa6.sin6_port), string_addr,
639 addrbuf.sa6.sin6_flowinfo);
640 #ifdef HAVE_SIN6_SCOPE_ID
642 #if defined(HAVE_IF_INDEXTONAME) && defined(IN6_IS_ADDR_LINKLOCAL) && defined(IN6_IS_ADDR_MC_LINKLOCAL)
643 int numericscope = 0;
644 if (IN6_IS_ADDR_LINKLOCAL (&addrbuf.sa6.sin6_addr)
645 || IN6_IS_ADDR_MC_LINKLOCAL (&addrbuf.sa6.sin6_addr)) {
646 char scopebuf[IFNAMSIZ + 1];
648 if (if_indextoname (addrbuf.sa6.sin6_scope_id, scopebuf) == NULL)
651 tprintf(", sin6_scope_id=if_nametoindex(\"%s\")", scopebuf);
657 tprintf(", sin6_scope_id=%u", addrbuf.sa6.sin6_scope_id);
662 #if defined(AF_IPX) && defined(linux)
666 tprintf("{sipx_port=htons(%u), ",
667 ntohs(addrbuf.sipx.sipx_port));
668 /* Yes, I know, this does not look too
669 * strace-ish, but otherwise the IPX
670 * addresses just look monstrous...
671 * Anyways, feel free if you don't like
674 tprintf("%08lx:", (unsigned long)ntohl(addrbuf.sipx.sipx_network));
675 for (i = 0; i<IPX_NODE_LEN; i++)
676 tprintf("%02x", addrbuf.sipx.sipx_node[i]);
677 tprintf("/[%02x]", addrbuf.sipx.sipx_type);
680 #endif /* AF_IPX && linux */
685 tprintf("proto=%#04x, if%d, pkttype=%d, addr(%d)={%d, ",
686 ntohs(addrbuf.ll.sll_protocol),
687 addrbuf.ll.sll_ifindex,
688 addrbuf.ll.sll_pkttype,
689 addrbuf.ll.sll_halen,
690 addrbuf.ll.sll_hatype);
691 for (i=0; i<addrbuf.ll.sll_addr[i]; i++)
692 tprintf("%02x", addrbuf.ll.sll_addr[i]);
696 #endif /* AF_APACKET */
699 tprintf("pid=%d, groups=%08x", addrbuf.nl.nl_pid, addrbuf.nl.nl_groups);
701 #endif /* AF_NETLINK */
702 /* AF_AX25 AF_APPLETALK AF_NETROM AF_BRIDGE AF_AAL5
703 AF_X25 AF_ROSE etc. still need to be done */
706 tprintf("{sa_family=%u, sa_data=", addrbuf.sa.sa_family);
707 printstr(tcp, (long) &((struct sockaddr *) addr)->sa_data,
708 sizeof addrbuf.sa.sa_data);
717 printiovec(tcp, iovec, len)
725 iov = (struct iovec *) malloc(len * sizeof *iov);
727 fprintf(stderr, "No memory");
730 if (umoven(tcp, (long)iovec,
731 len * sizeof *iov, (char *) iov) < 0) {
732 tprintf("%#lx", (unsigned long)iovec);
735 for (i = 0; i < len; i++) {
739 printstr(tcp, (long) iov[i].iov_base,
741 tprintf(", %lu}", (unsigned long)iov[i].iov_len);
749 printmsghdr(tcp, addr)
755 if (umove(tcp, addr, &msg) < 0) {
756 tprintf("%#lx", addr);
759 tprintf("{msg_name(%d)=", msg.msg_namelen);
760 printsock(tcp, (long)msg.msg_name, msg.msg_namelen);
762 tprintf(", msg_iov(%lu)=", (unsigned long)msg.msg_iovlen);
763 printiovec(tcp, msg.msg_iov, msg.msg_iovlen);
765 #ifdef HAVE_MSG_CONTROL
766 tprintf(", msg_controllen=%lu", (unsigned long)msg.msg_controllen);
767 if (msg.msg_controllen)
768 tprintf(", msg_control=%#lx, ", (unsigned long) msg.msg_control);
769 tprintf(", msg_flags=");
770 if (printflags(msg_flags, msg.msg_flags)==0)
772 #else /* !HAVE_MSG_CONTROL */
773 tprintf("msg_accrights=%#lx, msg_accrightslen=%u",
774 (unsigned long) msg.msg_accrights, msg.msg_accrightslen);
775 #endif /* !HAVE_MSG_CONTROL */
779 #endif /* HAVE_SENDMSG */
786 printxval(domains, tcp->u_arg[0], "PF_???");
788 printxval(socktypes, tcp->u_arg[1], "SOCK_???");
790 switch (tcp->u_arg[0]) {
792 printxval(protocols, tcp->u_arg[2], "IPPROTO_???");
796 /* BTW: I don't believe this.. */
798 printxval(domains, tcp->u_arg[2], "PF_???");
803 tprintf("%lu", tcp->u_arg[2]);
815 /* not sure really what these args are... but this
816 * is how truss prints it
818 tprintf("%ld, %ld, %ld, ",
819 tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]);
820 printpath(tcp, tcp->u_arg[3]);
821 tprintf(", %ld", tcp->u_arg[4]);
827 sys_so_socketpair(tcp)
831 /* not sure what this arg is */
832 tprintf("0x%lx", tcp->u_arg[0]);
842 tprintf("%ld, ", tcp->u_arg[0]);
843 printsock(tcp, tcp->u_arg[1], tcp->u_arg[2]);
844 tprintf(", %lu", tcp->u_arg[2]);
853 return sys_bind(tcp);
861 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
871 tprintf("%ld, ", tcp->u_arg[0]);
872 } else if (!tcp->u_arg[2])
873 tprintf("%#lx, NULL", tcp->u_arg[1]);
875 if (tcp->u_arg[1] == 0 || syserror(tcp)) {
876 tprintf("%#lx", tcp->u_arg[1]);
878 printsock(tcp, tcp->u_arg[1], tcp->u_arg[2]);
881 printnum(tcp, tcp->u_arg[2], "%lu");
891 tprintf("%ld, ", tcp->u_arg[0]);
892 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
893 tprintf(", %lu, ", tcp->u_arg[2]);
895 if (printflags(msg_flags, tcp->u_arg[3]) == 0)
906 tprintf("%ld, ", tcp->u_arg[0]);
907 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
908 tprintf(", %lu, ", tcp->u_arg[2]);
910 if (printflags(msg_flags, tcp->u_arg[3]) == 0)
914 printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]);
916 tprintf(", %lu", tcp->u_arg[5]);
928 tprintf("%ld, ", tcp->u_arg[0]);
929 printmsghdr(tcp, tcp->u_arg[1]);
932 if (printflags(msg_flags, tcp->u_arg[2]) == 0)
938 #endif /* HAVE_SENDMSG */
945 tprintf("%ld, ", tcp->u_arg[0]);
948 tprintf("%#lx", tcp->u_arg[1]);
950 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
952 tprintf(", %lu, ", tcp->u_arg[2]);
953 if (printflags(msg_flags, tcp->u_arg[3]) == 0)
966 tprintf("%ld, ", tcp->u_arg[0]);
969 tprintf("%#lx, %lu, %lu, %#lx, %#lx",
970 tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3],
971 tcp->u_arg[4], tcp->u_arg[5]);
975 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
977 tprintf(", %lu, ", tcp->u_arg[2]);
979 if (printflags(msg_flags, tcp->u_arg[3]) == 0)
981 /* from address, len */
982 if (!tcp->u_arg[4] || !tcp->u_arg[5]) {
983 if (tcp->u_arg[4] == 0)
986 tprintf(", %#lx", tcp->u_arg[4]);
987 if (tcp->u_arg[5] == 0)
990 tprintf(", %#lx", tcp->u_arg[5]);
993 if (umove(tcp, tcp->u_arg[5], &fromlen) < 0) {
994 tprintf(", {...}, [?]");
998 printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]);
1000 tprintf(", [%u]", fromlen);
1011 if (entering(tcp)) {
1012 tprintf("%ld, ", tcp->u_arg[0]);
1014 if (syserror(tcp) || !verbose(tcp))
1015 tprintf("%#lx", tcp->u_arg[1]);
1017 printmsghdr(tcp, tcp->u_arg[1]);
1020 if (printflags(msg_flags, tcp->u_arg[2]) == 0)
1026 #endif /* HAVE_SENDMSG */
1032 if (entering(tcp)) {
1033 tprintf("%ld, %ld", tcp->u_arg[0], tcp->u_arg[1]);
1034 switch (tcp->u_arg[1]) {
1036 tprintf("%s", " /* receive */");
1039 tprintf("%s", " /* send */");
1042 tprintf("%s", " /* send and receive */");
1050 sys_getsockname(tcp)
1053 return sys_accept(tcp);
1057 sys_getpeername(tcp)
1060 return sys_accept(tcp);
1068 #if defined(LINUX) && !defined(SPARC)
1072 if (syserror(tcp)) {
1073 tprintf("%#lx", tcp->u_arg[0]);
1076 if (umoven(tcp, tcp->u_arg[0], sizeof fds, (char *) fds) < 0)
1079 tprintf("[%u, %u]", fds[0], fds[1]);
1081 #elif defined(SPARC) || defined(SVR4) || defined(FREEBSD)
1083 tprintf("[%lu, %lu]", tcp->u_rval, getrval2(tcp));
1096 if (entering(tcp)) {
1097 printxval(domains, tcp->u_arg[0], "PF_???");
1099 printxval(socktypes, tcp->u_arg[1], "SOCK_???");
1101 switch (tcp->u_arg[0]) {
1103 printxval(protocols, tcp->u_arg[2], "IPPROTO_???");
1107 /* BTW: I don't believe this.. */
1109 printxval(domains, tcp->u_arg[2], "PF_???");
1114 tprintf("%lu", tcp->u_arg[2]);
1118 if (syserror(tcp)) {
1119 tprintf(", %#lx", tcp->u_arg[3]);
1123 if (umoven(tcp, tcp->u_arg[3], sizeof fds, (char *) fds) < 0)
1126 tprintf(", [%u, %u]", fds[0], fds[1]);
1128 #if defined(SUNOS4) || defined(SVR4) || defined(FREEBSD)
1129 tprintf(", [%lu, %lu]", tcp->u_rval, getrval2(tcp));
1130 #endif /* SUNOS4 || SVR4 || FREEBSD */
1139 if (entering(tcp)) {
1140 tprintf("%ld, ", tcp->u_arg[0]);
1141 switch (tcp->u_arg[1]) {
1143 tprintf("SOL_SOCKET, ");
1144 printxval(sockoptions, tcp->u_arg[2], "SO_???");
1149 tprintf("SOL_IP, ");
1150 printxval(sockipoptions, tcp->u_arg[2], "IP_???");
1156 tprintf("SOL_IPX, ");
1157 printxval(sockipxoptions, tcp->u_arg[2], "IPX_???");
1163 tprintf("SOL_PACKET, ");
1164 printxval(sockpacketoptions, tcp->u_arg[2], "PACKET_???");
1170 tprintf("SOL_TCP, ");
1171 printxval(socktcpoptions, tcp->u_arg[2], "TCP_???");
1176 /* SOL_AX25 SOL_ROSE SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25
1177 * etc. still need work */
1179 /* XXX - should know socket family here */
1180 printxval(socketlayers, tcp->u_arg[1], "SOL_???");
1181 tprintf(", %lu, ", tcp->u_arg[2]);
1185 if (syserror(tcp)) {
1186 tprintf("%#lx, %#lx",
1187 tcp->u_arg[3], tcp->u_arg[4]);
1190 printnum(tcp, tcp->u_arg[3], "%ld");
1192 printnum(tcp, tcp->u_arg[4], "%ld");
1197 #if defined(ICMP_FILTER)
1198 static void printicmpfilter(tcp, addr)
1202 struct icmp_filter filter;
1208 if (syserror(tcp) || !verbose(tcp)) {
1209 tprintf("%#lx", addr);
1212 if (umove(tcp, addr, &filter) < 0) {
1218 if (printflags(icmpfilterflags, ~filter.data) == 0)
1222 #endif /* ICMP_FILTER */
1228 if (entering(tcp)) {
1229 tprintf("%ld, ", tcp->u_arg[0]);
1230 switch (tcp->u_arg[1]) {
1232 tprintf("SOL_SOCKET, ");
1233 printxval(sockoptions, tcp->u_arg[2], "SO_???");
1235 printnum(tcp, tcp->u_arg[3], "%ld");
1236 tprintf(", %lu", tcp->u_arg[4]);
1240 tprintf("SOL_IP, ");
1241 printxval(sockipoptions, tcp->u_arg[2], "IP_???");
1243 printnum(tcp, tcp->u_arg[3], "%ld");
1244 tprintf(", %lu", tcp->u_arg[4]);
1249 tprintf("SOL_IPX, ");
1250 printxval(sockipxoptions, tcp->u_arg[2], "IPX_???");
1252 printnum(tcp, tcp->u_arg[3], "%ld");
1253 tprintf(", %lu", tcp->u_arg[4]);
1258 tprintf("SOL_PACKET, ");
1259 printxval(sockpacketoptions, tcp->u_arg[2], "PACKET_???");
1261 /* TODO: decode packate_mreq for PACKET_*_MEMBERSHIP */
1262 printnum(tcp, tcp->u_arg[3], "%ld");
1263 tprintf(", %lu", tcp->u_arg[4]);
1268 tprintf("SOL_TCP, ");
1269 printxval(socktcpoptions, tcp->u_arg[2], "TCP_???");
1271 printnum(tcp, tcp->u_arg[3], "%ld");
1272 tprintf(", %lu", tcp->u_arg[4]);
1277 tprintf("SOL_RAW, ");
1278 printxval(sockrawoptions, tcp->u_arg[2], "RAW_???");
1280 switch (tcp->u_arg[2]) {
1281 #if defined(ICMP_FILTER)
1283 printicmpfilter(tcp, tcp->u_arg[3]);
1287 printnum(tcp, tcp->u_arg[3], "%ld");
1290 tprintf(", %lu", tcp->u_arg[4]);
1294 /* SOL_AX25 SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25
1295 * etc. still need work */
1297 /* XXX - should know socket family here */
1298 printxval(socketlayers, tcp->u_arg[1], "IPPROTO_???");
1299 tprintf(", %lu, ", tcp->u_arg[2]);
1300 printnum(tcp, tcp->u_arg[3], "%ld");
1301 tprintf(", %lu", tcp->u_arg[4]);
1310 static struct xlat sock_version[] = {
1311 { __NETLIB_UW211_SVR4, "UW211_SVR4" },
1312 { __NETLIB_UW211_XPG4, "UW211_XPG4" },
1313 { __NETLIB_GEMINI_SVR4, "GEMINI_SVR4" },
1314 { __NETLIB_GEMINI_XPG4, "GEMINI_XPG4" },
1315 { __NETLIB_FP1_SVR4, "FP1_SVR4" },
1316 { __NETLIB_FP1_XPG4, "FP1_XPG4" },
1322 netlib_call(tcp, func)
1326 if (entering(tcp)) {
1328 printxval (sock_version, tcp->u_arg[0], "__NETLIB_???");
1331 for (i = 0; i < tcp->u_nargs; i++)
1332 tcp->u_arg[i] = tcp->u_arg[i + 1];
1344 return netlib_call (tcp, sys_socket);
1348 sys_xsocketpair(tcp)
1351 return netlib_call (tcp, sys_socketpair);
1358 return netlib_call (tcp, sys_bind);
1365 return netlib_call (tcp, sys_connect);
1372 return netlib_call (tcp, sys_listen);
1379 return netlib_call (tcp, sys_accept);
1386 return netlib_call (tcp, sys_sendmsg);
1393 return netlib_call (tcp, sys_recvmsg);
1397 sys_xgetsockaddr(tcp)
1400 if (entering(tcp)) {
1401 printxval (sock_version, tcp->u_arg[0], "__NETLIB_???");
1403 if (tcp->u_arg[1] == 0) {
1404 tprintf ("LOCALNAME, ");
1406 else if (tcp->u_arg[1] == 1) {
1407 tprintf ("REMOTENAME, ");
1410 tprintf ("%ld, ", tcp->u_arg [1]);
1412 tprintf ("%ld, ", tcp->u_arg [2]);
1415 if (tcp->u_arg[3] == 0 || syserror(tcp)) {
1416 tprintf("%#lx", tcp->u_arg[3]);
1418 printsock(tcp, tcp->u_arg[3], tcp->u_arg[4]);
1421 printnum(tcp, tcp->u_arg[4], "%lu");
1431 sys_xsetsockaddr(tcp)
1434 return netlib_call (tcp, sys_setsockaddr);
1440 sys_xgetsockopt(tcp)
1443 return netlib_call (tcp, sys_getsockopt);
1447 sys_xsetsockopt(tcp)
1450 return netlib_call (tcp, sys_setsockopt);
1457 return netlib_call (tcp, sys_shutdown);