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>
38 #include <netinet/in.h>
40 #include <netinet/tcp.h>
42 #include <arpa/inet.h>
44 #include <asm/types.h>
45 #if defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC__ + __GLIBC_MINOR__ >= 3)
46 # include <netipx/ipx.h>
48 # include <linux/ipx.h>
52 #if defined (__GLIBC__) && ((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1))
53 #if defined(HAVE_LINUX_IN6_H)
54 #include <linux/in6.h>
58 #if defined(HAVE_SYS_UIO_H)
62 #if defined(HAVE_LINUX_NETLINK_H)
63 #include <linux/netlink.h>
66 #if defined(HAVE_LINUX_IF_PACKET_H)
67 #include <linux/if_packet.h>
70 #if defined(HAVE_LINUX_ICMP_H)
71 #include <linux/icmp.h>
75 #define PF_UNSPEC AF_UNSPEC
79 #define HAVE_SENDMSG 1 /* HACK - *FIXME* */
83 /* Under Linux these are enums so we can't test for them with ifdef. */
84 #define IPPROTO_EGP IPPROTO_EGP
85 #define IPPROTO_PUP IPPROTO_PUP
86 #define IPPROTO_IDP IPPROTO_IDP
87 #define IPPROTO_IGMP IPPROTO_IGMP
88 #define IPPROTO_RAW IPPROTO_RAW
89 #define IPPROTO_MAX IPPROTO_MAX
92 static struct xlat domains[] = {
93 { PF_UNSPEC, "PF_UNSPEC" },
94 { PF_UNIX, "PF_UNIX" },
95 { PF_INET, "PF_INET" },
97 { PF_NETLINK, "PF_NETLINK" },
100 { PF_PACKET, "PF_PACKET" },
103 { PF_INET6, "PF_INET6" },
106 { PF_ATMSVC, "PF_INET6" },
109 { PF_INET6, "PF_INET6" },
112 { PF_LOCAL, "PS_LOCAL" },
115 { PF_ISO, "PF_ISO" },
118 { PF_AX25, "PF_AX25" },
121 { PF_IPX, "PF_IPX" },
124 { PF_APPLETALK, "PF_APPLETALK" },
127 { PF_NETROM, "PF_NETROM" },
130 { PF_BRIDGE, "PF_BRIDGE" },
133 { PF_AAL5, "PF_AAL5" },
136 { PF_X25, "PF_X25" },
139 { PF_ROSE, "PF_ROSE" },
142 { PF_DECNET, "PF_DECNET" },
145 { PF_NETBEUI, "PF_NETBEUI" },
148 { PF_IMPLINK, "PF_IMPLINK" },
152 static struct xlat addrfams[] = {
153 { AF_UNSPEC, "AF_UNSPEC" },
154 { AF_UNIX, "AF_UNIX" },
155 { AF_INET, "AF_INET" },
157 { AF_INET6, "AF_INET6" },
159 { AF_DECnet, "AF_DECnet" },
161 { AF_ATMSVC, "AF_ATMSVC" },
164 { AF_PACKET, "AF_PACKET" },
167 { AF_NETLINK, "AF_NETLINK" },
170 { AF_ISO, "AF_ISO" },
173 { AF_IMPLINK, "AF_IMPLINK" },
177 static struct xlat socktypes[] = {
178 { SOCK_STREAM, "SOCK_STREAM" },
179 { SOCK_DGRAM, "SOCK_DGRAM" },
181 { SOCK_RAW, "SOCK_RAW" },
183 #ifdef SOCK_SEQPACKET
184 { SOCK_SEQPACKET,"SOCK_SEQPACKET"},
187 { SOCK_RDM, "SOCK_RDM" },
190 { SOCK_PACKET, "SOCK_PACKET" },
194 static struct xlat protocols[] = {
195 { IPPROTO_IP, "IPPROTO_IP" },
196 { IPPROTO_ICMP, "IPPROTO_ICMP" },
197 { IPPROTO_TCP, "IPPROTO_TCP" },
198 { IPPROTO_UDP, "IPPROTO_UDP" },
200 { IPPROTO_GGP, "IPPROTO_GGP" },
203 { IPPROTO_EGP, "IPPROTO_EGP" },
206 { IPPROTO_PUP, "IPPROTO_PUP" },
209 { IPPROTO_IDP, "IPPROTO_IDP" },
212 { IPPROTO_IPV6, "IPPROTO_IPV6" },
214 #ifdef IPPROTO_ICMPV6
215 { IPPROTO_ICMPV6,"IPPROTO_ICMPV6"},
218 { IPPROTO_IGMP, "IPPROTO_IGMP" },
221 { IPPROTO_HELLO,"IPPROTO_HELLO" },
224 { IPPROTO_ND, "IPPROTO_ND" },
227 { IPPROTO_RAW, "IPPROTO_RAW" },
230 { IPPROTO_MAX, "IPPROTO_MAX" },
233 { IPPROTO_IPIP, "IPPROTO_IPIP" },
237 static struct xlat msg_flags[] = {
238 { MSG_OOB, "MSG_OOB" },
240 { MSG_DONTROUTE,"MSG_DONTROUTE" },
243 { MSG_PEEK, "MSG_PEEK" },
246 { MSG_CTRUNC, "MSG_CTRUNC" },
249 { MSG_PROXY, "MSG_PROXY" },
252 { MSG_EOR, "MSG_EOR" },
255 { MSG_WAITALL, "MSG_WAITALL" },
258 { MSG_TRUNC, "MSG_TRUNC" },
261 { MSG_CTRUNC, "MSG_CTRUNC" },
264 { MSG_ERRQUEUE, "MSG_ERRQUEUE" },
267 { MSG_DONTWAIT, "MSG_DONTWAIT" },
270 { MSG_CONFIRM, "MSG_CONFIRM" },
273 { MSG_PROBE, "MSG_PROBE" },
278 static struct xlat sockoptions[] = {
280 { SO_PEERCRED, "SO_PEERCRED" },
283 { SO_PASSCRED, "SO_PASSCRED" },
286 { SO_DEBUG, "SO_DEBUG" },
289 { SO_REUSEADDR, "SO_REUSEADDR" },
292 { SO_KEEPALIVE, "SO_KEEPALIVE" },
295 { SO_DONTROUTE, "SO_DONTROUTE" },
298 { SO_BROADCAST, "SO_BROADCAST" },
301 { SO_LINGER, "SO_LINGER" },
304 { SO_OOBINLINE, "SO_OOBINLINE" },
307 { SO_TYPE, "SO_TYPE" },
310 { SO_ERROR, "SO_ERROR" },
313 { SO_SNDBUF, "SO_SNDBUF" },
316 { SO_RCVBUF, "SO_RCVBUF" },
319 { SO_NO_CHECK, "SO_NO_CHECK" },
322 { SO_PRIORITY, "SO_PRIORITY" },
325 { SO_ACCEPTCONN,"SO_ACCEPTCONN" },
327 #ifdef SO_USELOOPBACK
328 { SO_USELOOPBACK,"SO_USELOOPBACK"},
331 { SO_SNDLOWAT, "SO_SNDLOWAT" },
334 { SO_RCVLOWAT, "SO_RCVLOWAT" },
337 { SO_SNDTIMEO, "SO_SNDTIMEO" },
340 { SO_RCVTIMEO, "SO_RCVTIMEO" },
343 { SO_BSDCOMPAT, "SO_BSDCOMPAT" },
346 { SO_REUSEPORT, "SO_REUSEPORT" },
349 { SO_RCVLOWAT, "SO_RCVLOWAT" },
352 { SO_SNDLOWAT, "SO_SNDLOWAT" },
355 { SO_RCVTIMEO, "SO_RCVTIMEO" },
358 { SO_SNDTIMEO, "SO_SNDTIMEO" },
364 static struct xlat sockipoptions[] = {
365 { IP_TOS, "IP_TOS" },
366 { IP_TTL, "IP_TTL" },
367 #if defined(IP_HDRINCL)
368 { IP_HDRINCL, "IP_HDRINCL" },
370 #if defined(IP_OPTIONS)
371 { IP_OPTIONS, "IP_OPTIONS" },
373 { IP_ROUTER_ALERT, "IP_ROUTER_ALERT" },
374 #if defined(IP_RECVOPTIONS)
375 { IP_RECVOPTIONS, "IP_RECVOPTIONS" },
377 { IP_RETOPTS, "IP_RETOPTS" },
378 { IP_PKTINFO, "IP_PKTINFO" },
379 { IP_PKTOPTIONS, "IP_PKTOPTIONS" },
380 { IP_MTU_DISCOVER, "IP_MTU_DISCOVER" },
381 { IP_MTU_DISCOVER, "IP_MTU_DISCOVER" },
382 { IP_RECVERR, "IP_RECVERR" },
383 { IP_RECVTTL, "IP_RECRECVTTL" },
384 { IP_RECVTOS, "IP_RECRECVTOS" },
386 { IP_MTU, "IP_MTU" },
388 { IP_MULTICAST_IF, "IP_MULTICAST_IF" },
389 { IP_MULTICAST_TTL, "IP_MULTICAST_TTL" },
390 { IP_MULTICAST_LOOP, "IP_MULTICAST_LOOP" },
391 { IP_ADD_MEMBERSHIP, "IP_ADD_MEMBERSHIP" },
392 { IP_DROP_MEMBERSHIP, "IP_DROP_MEMBERSHIP" },
398 static struct xlat sockipxoptions[] = {
399 { IPX_TYPE, "IPX_TYPE" },
405 static struct xlat sockrawoptions[] = {
406 #if defined(ICMP_FILTER)
407 { ICMP_FILTER, "ICMP_FILTER" },
414 static struct xlat sockpacketoptions[] = {
415 { PACKET_ADD_MEMBERSHIP, "PACKET_ADD_MEMBERSHIP" },
416 { PACKET_DROP_MEMBERSHIP, "PACKET_DROP_MEMBERSHIP"},
417 #if defined(PACKET_RECV_OUTPUT)
418 { PACKET_RECV_OUTPUT, "PACKET_RECV_OUTPUT" },
420 #if defined(PACKET_RX_RING)
421 { PACKET_RX_RING, "PACKET_RX_RING" },
423 #if defined(PACKET_STATISTICS)
424 { PACKET_STATISTICS, "PACKET_STATISTICS" },
428 #endif /* SOL_PACKET */
431 static struct xlat socktcpoptions[] = {
432 { TCP_NODELAY, "TCP_NODELAY" },
433 { TCP_MAXSEG, "TCP_MAXSEG" },
434 #if defined(TCP_CORK)
435 { TCP_CORK, "TCP_CORK" },
442 static struct xlat icmpfilterflags[] = {
443 #if defined(ICMP_ECHOREPLY)
444 { (1<<ICMP_ECHOREPLY), "ICMP_ECHOREPLY" },
446 #if defined(ICMP_DEST_UNREACH)
447 { (1<<ICMP_DEST_UNREACH), "ICMP_DEST_UNREACH" },
449 #if defined(ICMP_SOURCE_QUENCH)
450 { (1<<ICMP_SOURCE_QUENCH), "ICMP_SOURCE_QUENCH" },
452 #if defined(ICMP_REDIRECT)
453 { (1<<ICMP_REDIRECT), "ICMP_REDIRECT" },
455 #if defined(ICMP_ECHO)
456 { (1<<ICMP_ECHO), "ICMP_ECHO" },
458 #if defined(ICMP_TIME_EXCEEDED)
459 { (1<<ICMP_TIME_EXCEEDED), "ICMP_TIME_EXCEEDED" },
461 #if defined(ICMP_PARAMETERPROB)
462 { (1<<ICMP_PARAMETERPROB), "ICMP_PARAMETERPROB" },
464 #if defined(ICMP_TIMESTAMP)
465 { (1<<ICMP_TIMESTAMP), "ICMP_TIMESTAMP" },
467 #if defined(ICMP_TIMESTAMPREPLY)
468 { (1<<ICMP_TIMESTAMPREPLY), "ICMP_TIMESTAMPREPLY" },
470 #if defined(ICMP_INFO_REQUEST)
471 { (1<<ICMP_INFO_REQUEST), "ICMP_INFO_REQUEST" },
473 #if defined(ICMP_INFO_REPLY)
474 { (1<<ICMP_INFO_REPLY), "ICMP_INFO_REPLY" },
476 #if defined(ICMP_ADDRESS)
477 { (1<<ICMP_ADDRESS), "ICMP_ADDRESS" },
479 #if defined(ICMP_ADDRESSREPLY)
480 { (1<<ICMP_ADDRESSREPLY), "ICMP_ADDRESSREPLY" },
488 printsock(tcp, addr, addrlen)
496 struct sockaddr_in sin;
497 struct sockaddr_un sau;
498 #ifdef HAVE_INET_NTOP
499 struct sockaddr_in6 sa6;
501 #if defined(LINUX) && defined(AF_IPX)
502 struct sockaddr_ipx sipx;
505 struct sockaddr_ll ll;
508 struct sockaddr_nl nl;
511 char string_addr[100];
518 tprintf("%#lx", addr);
521 if ((addrlen<2) || (addrlen>sizeof(addrbuf)))
522 addrlen=sizeof(addrbuf);
524 if (umoven(tcp, addr, addrlen, (char*)&addrbuf) < 0) {
529 tprintf("{sin_family=");
530 printxval(addrfams, addrbuf.sa.sa_family, "AF_???");
533 switch (addrbuf.sa.sa_family) {
537 } else if (addrbuf.sau.sun_path[0]) {
538 tprintf("path=\"%*.*s\"", addrlen-2, addrlen-2, addrbuf.sau.sun_path);
540 tprintf("path=@%*.*s", addrlen-3, addrlen-3, addrbuf.sau.sun_path+1);
544 tprintf("sin_port=htons(%u), sin_addr=inet_addr(\"%s\")}",
545 ntohs(addrbuf.sin.sin_port), inet_ntoa(addrbuf.sin.sin_addr));
547 #ifdef HAVE_INET_NTOP
549 inet_ntop(AF_INET6, &addrbuf.sa6.sin6_addr, string_addr, sizeof(string_addr));
550 tprintf("sin6_port=htons(%u), inet_pton(AF_INET6, \"%s\", &sin6_addr), sin6_flowinfo=htonl(%u)}",
551 ntohs(addrbuf.sa6.sin6_port), string_addr, ntohl(addrbuf.sa6.sin6_flowinfo));
554 #if defined(AF_IPX) && defined(linux)
558 tprintf("{sipx_port=htons(%u), ",
559 ntohs(addrbuf.sipx.sipx_port));
560 /* Yes, I know, this does not look too
561 * strace-ish, but otherwise the IPX
562 * addresses just look monstrous...
563 * Anyways, feel free if you don't like
566 tprintf("%08lx:", (unsigned long)ntohl(addrbuf.sipx.sipx_network));
567 for (i = 0; i<IPX_NODE_LEN; i++)
568 tprintf("%02x", addrbuf.sipx.sipx_node[i]);
569 tprintf("/[%02x]", addrbuf.sipx.sipx_type);
572 #endif /* AF_IPX && linux */
577 tprintf("proto=%#04x, if%d, pkttype=%d, addr(%d)={%d, ",
578 ntohs(addrbuf.ll.sll_protocol),
579 addrbuf.ll.sll_ifindex,
580 addrbuf.ll.sll_pkttype,
581 addrbuf.ll.sll_halen,
582 addrbuf.ll.sll_hatype);
583 for (i=0; i<addrbuf.ll.sll_addr[i]; i++)
584 tprintf("%02x", addrbuf.ll.sll_addr[i]);
588 #endif /* AF_APACKET */
591 tprintf("pid=%d, groups=%08x", addrbuf.nl.nl_pid, addrbuf.nl.nl_groups);
593 #endif /* AF_NETLINK */
594 /* AF_AX25 AF_APPLETALK AF_NETROM AF_BRIDGE AF_AAL5
595 AF_X25 AF_ROSE etc. still need to be done */
598 tprintf("{sa_family=%u, sa_data=", addrbuf.sa.sa_family);
599 printstr(tcp, (long) &((struct sockaddr *) addr)->sa_data,
600 sizeof addrbuf.sa.sa_data);
609 printiovec(tcp, iovec, len)
617 iov = (struct iovec *) malloc(len * sizeof *iov);
619 fprintf(stderr, "No memory");
622 if (umoven(tcp, (long)iovec,
623 len * sizeof *iov, (char *) iov) < 0) {
624 tprintf("%#lx", (unsigned long)iovec);
627 for (i = 0; i < len; i++) {
631 printstr(tcp, (long) iov[i].iov_base,
633 tprintf(", %lu}", (unsigned long)iov[i].iov_len);
641 printmsghdr(tcp, addr)
647 if (umove(tcp, addr, &msg) < 0) {
648 tprintf("%#lx", addr);
651 tprintf("{msg_name(%d)=", msg.msg_namelen);
652 printsock(tcp, (long)msg.msg_name, msg.msg_namelen);
654 tprintf(", msg_iov(%lu)=", (unsigned long)msg.msg_iovlen);
655 printiovec(tcp, msg.msg_iov, msg.msg_iovlen);
657 #ifdef HAVE_MSG_CONTROL
658 tprintf(", msg_controllen=%lu", (unsigned long)msg.msg_controllen);
659 if (msg.msg_controllen)
660 tprintf(", msg_control=%#lx, ", (unsigned long) msg.msg_control);
661 tprintf(", msg_flags=");
662 if (printflags(msg_flags, msg.msg_flags)==0)
664 #else /* !HAVE_MSG_CONTROL */
665 tprintf("msg_accrights=%#lx, msg_accrightslen=%u",
666 (unsigned long) msg.msg_accrights, msg.msg_accrightslen);
667 #endif /* !HAVE_MSG_CONTROL */
671 #endif /* HAVE_SENDMSG */
678 printxval(domains, tcp->u_arg[0], "PF_???");
680 printxval(socktypes, tcp->u_arg[1], "SOCK_???");
682 switch (tcp->u_arg[0]) {
684 printxval(protocols, tcp->u_arg[2], "IPPROTO_???");
688 /* BTW: I don't believe this.. */
690 printxval(domains, tcp->u_arg[2], "PF_???");
695 tprintf("%lu", tcp->u_arg[2]);
707 tprintf("%ld, ", tcp->u_arg[0]);
708 printsock(tcp, tcp->u_arg[1], tcp->u_arg[2]);
709 tprintf(", %lu", tcp->u_arg[2]);
718 return sys_bind(tcp);
726 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
736 tprintf("%ld, ", tcp->u_arg[0]);
737 } else if (!tcp->u_arg[2])
738 tprintf("%#lx, NULL", tcp->u_arg[1]);
740 if (tcp->u_arg[1] == 0 || syserror(tcp)) {
741 tprintf("%#lx", tcp->u_arg[1]);
743 printsock(tcp, tcp->u_arg[1], tcp->u_arg[2]);
746 printnum(tcp, tcp->u_arg[2], "%lu");
756 tprintf("%ld, ", tcp->u_arg[0]);
757 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
758 tprintf(", %lu, ", tcp->u_arg[2]);
760 if (printflags(msg_flags, tcp->u_arg[3]) == 0)
771 tprintf("%ld, ", tcp->u_arg[0]);
772 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
773 tprintf(", %lu, ", tcp->u_arg[2]);
775 if (printflags(msg_flags, tcp->u_arg[3]) == 0)
779 printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]);
781 tprintf(", %lu", tcp->u_arg[5]);
793 tprintf("%ld, ", tcp->u_arg[0]);
794 printmsghdr(tcp, tcp->u_arg[1]);
797 if (printflags(msg_flags, tcp->u_arg[2]) == 0)
803 #endif /* HAVE_SENDMSG */
810 tprintf("%ld, ", tcp->u_arg[0]);
813 tprintf("%#lx", tcp->u_arg[1]);
815 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
817 tprintf(", %lu, ", tcp->u_arg[2]);
818 if (printflags(msg_flags, tcp->u_arg[3]) == 0)
831 tprintf("%ld, ", tcp->u_arg[0]);
834 tprintf("%#lx, %lu, %lu, %#lx, %#lx",
835 tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3],
836 tcp->u_arg[4], tcp->u_arg[5]);
840 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
842 tprintf(", %lu, ", tcp->u_arg[2]);
844 if (printflags(msg_flags, tcp->u_arg[3]) == 0)
846 /* from address, len */
847 if (!tcp->u_arg[4] || !tcp->u_arg[5]) {
848 if (tcp->u_arg[4] == 0)
851 tprintf(", %#lx", tcp->u_arg[4]);
852 if (tcp->u_arg[5] == 0)
855 tprintf(", %#lx", tcp->u_arg[5]);
858 if (umove(tcp, tcp->u_arg[5], &fromlen) < 0) {
859 tprintf(", {...}, [?]");
863 printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]);
865 tprintf(", [%u]", fromlen);
877 tprintf("%ld, ", tcp->u_arg[0]);
879 if (syserror(tcp) || !verbose(tcp))
880 tprintf("%#lx", tcp->u_arg[1]);
882 printmsghdr(tcp, tcp->u_arg[1]);
885 if (printflags(msg_flags, tcp->u_arg[2]) == 0)
891 #endif /* HAVE_SENDMSG */
898 tprintf("%ld, %ld", tcp->u_arg[0], tcp->u_arg[1]);
899 switch (tcp->u_arg[1]) {
901 tprintf("%s", " /* receive */");
904 tprintf("%s", " /* send */");
907 tprintf("%s", " /* send and receive */");
918 return sys_accept(tcp);
925 return sys_accept(tcp);
933 #if defined(LINUX) && !defined(SPARC)
938 tprintf("%#lx", tcp->u_arg[0]);
941 if (umoven(tcp, tcp->u_arg[0], sizeof fds, (char *) fds) < 0)
944 tprintf("[%u, %u]", fds[0], fds[1]);
946 #elif defined(SPARC) || defined(SVR4)
948 tprintf("[%lu, %lu]", tcp->u_rval, getrval2(tcp));
962 printxval(domains, tcp->u_arg[0], "PF_???");
964 printxval(socktypes, tcp->u_arg[1], "SOCK_???");
966 switch (tcp->u_arg[0]) {
968 printxval(protocols, tcp->u_arg[2], "IPPROTO_???");
972 /* BTW: I don't believe this.. */
974 printxval(domains, tcp->u_arg[2], "PF_???");
979 tprintf("%lu", tcp->u_arg[2]);
984 tprintf(", %#lx", tcp->u_arg[3]);
988 if (umoven(tcp, tcp->u_arg[3], sizeof fds, (char *) fds) < 0)
991 tprintf(", [%u, %u]", fds[0], fds[1]);
994 tprintf(", [%lu, %lu]", tcp->u_rval, getrval2(tcp));
997 tprintf(", [%lu, %lu]", tcp->u_rval, getrval2(tcp));
1007 if (entering(tcp)) {
1008 tprintf("%ld, ", tcp->u_arg[0]);
1009 switch (tcp->u_arg[1]) {
1011 tprintf("SOL_SOCKET, ");
1012 printxval(sockoptions, tcp->u_arg[2], "SO_???");
1017 tprintf("SOL_IP, ");
1018 printxval(sockipoptions, tcp->u_arg[2], "IP_???");
1024 tprintf("SOL_IPX, ");
1025 printxval(sockipxoptions, tcp->u_arg[2], "IPX_???");
1031 tprintf("SOL_PACKET, ");
1032 printxval(sockpacketoptions, tcp->u_arg[2], "PACKET_???");
1038 tprintf("SOL_TCP, ");
1039 printxval(socktcpoptions, tcp->u_arg[2], "TCP_???");
1044 /* SOL_AX25 SOL_ROSE SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25
1045 * etc. still need work */
1047 /* XXX - should know socket family here */
1048 printxval(protocols, tcp->u_arg[1], "IPPROTO_???");
1049 tprintf(", %lu, ", tcp->u_arg[2]);
1053 if (syserror(tcp)) {
1054 tprintf("%#lx, %#lx",
1055 tcp->u_arg[3], tcp->u_arg[4]);
1058 printnum(tcp, tcp->u_arg[3], "%ld");
1060 printnum(tcp, tcp->u_arg[4], "%ld");
1065 #if defined(ICMP_FILTER)
1066 static void printicmpfilter(tcp, addr)
1070 struct icmp_filter filter;
1076 if (syserror(tcp) || !verbose(tcp)) {
1077 tprintf("%#lx", addr);
1080 if (umove(tcp, addr, &filter) < 0) {
1086 if (printflags(icmpfilterflags, ~filter.data) == 0)
1090 #endif /* ICMP_FILTER */
1096 if (entering(tcp)) {
1097 tprintf("%ld, ", tcp->u_arg[0]);
1098 switch (tcp->u_arg[1]) {
1100 tprintf("SOL_SOCKET, ");
1101 printxval(sockoptions, tcp->u_arg[2], "SO_???");
1103 printnum(tcp, tcp->u_arg[3], "%ld");
1104 tprintf(", %lu", tcp->u_arg[4]);
1108 tprintf("SOL_IP, ");
1109 printxval(sockipoptions, tcp->u_arg[2], "IP_???");
1111 printnum(tcp, tcp->u_arg[3], "%ld");
1112 tprintf(", %lu", tcp->u_arg[4]);
1117 tprintf("SOL_IPX, ");
1118 printxval(sockipxoptions, tcp->u_arg[2], "IPX_???");
1120 printnum(tcp, tcp->u_arg[3], "%ld");
1121 tprintf(", %lu", tcp->u_arg[4]);
1126 tprintf("SOL_PACKET, ");
1127 printxval(sockpacketoptions, tcp->u_arg[2], "PACKET_???");
1129 /* TODO: decode packate_mreq for PACKET_*_MEMBERSHIP */
1130 printnum(tcp, tcp->u_arg[3], "%ld");
1131 tprintf(", %lu", tcp->u_arg[4]);
1136 tprintf("SOL_TCP, ");
1137 printxval(socktcpoptions, tcp->u_arg[2], "TCP_???");
1139 printnum(tcp, tcp->u_arg[3], "%ld");
1140 tprintf(", %lu", tcp->u_arg[4]);
1145 tprintf("SOL_RAW, ");
1146 printxval(sockrawoptions, tcp->u_arg[2], "RAW_???");
1148 switch (tcp->u_arg[2]) {
1149 #if defined(ICMP_FILTER)
1151 printicmpfilter(tcp, tcp->u_arg[3]);
1155 printnum(tcp, tcp->u_arg[3], "%ld");
1158 tprintf(", %lu", tcp->u_arg[4]);
1162 /* SOL_AX25 SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25
1163 * etc. still need work */
1165 /* XXX - should know socket family here */
1166 printxval(protocols, tcp->u_arg[1], "IPPROTO_???");
1167 tprintf("%lu, ", tcp->u_arg[2]);
1168 printnum(tcp, tcp->u_arg[3], "%ld");
1169 tprintf(", %lu", tcp->u_arg[4]);
1178 static struct xlat sock_version[] = {
1179 { __NETLIB_UW211_SVR4, "UW211_SVR4" },
1180 { __NETLIB_UW211_XPG4, "UW211_XPG4" },
1181 { __NETLIB_GEMINI_SVR4, "GEMINI_SVR4" },
1182 { __NETLIB_GEMINI_XPG4, "GEMINI_XPG4" },
1183 { __NETLIB_FP1_SVR4, "FP1_SVR4" },
1184 { __NETLIB_FP1_XPG4, "FP1_XPG4" },
1190 netlib_call(tcp, func)
1194 if (entering(tcp)) {
1196 printxval (sock_version, tcp->u_arg[0], "__NETLIB_???");
1199 for (i = 0; i < tcp->u_nargs; i++)
1200 tcp->u_arg[i] = tcp->u_arg[i + 1];
1212 return netlib_call (tcp, sys_socket);
1216 sys_xsocketpair(tcp)
1219 return netlib_call (tcp, sys_socketpair);
1226 return netlib_call (tcp, sys_bind);
1233 return netlib_call (tcp, sys_connect);
1240 return netlib_call (tcp, sys_listen);
1247 return netlib_call (tcp, sys_accept);
1254 return netlib_call (tcp, sys_sendmsg);
1261 return netlib_call (tcp, sys_recvmsg);
1265 sys_xgetsockaddr(tcp)
1268 if (entering(tcp)) {
1269 printxval (sock_version, tcp->u_arg[0], "__NETLIB_???");
1271 if (tcp->u_arg[1] == 0) {
1272 tprintf ("LOCALNAME, ");
1274 else if (tcp->u_arg[1] == 1) {
1275 tprintf ("REMOTENAME, ");
1278 tprintf ("%ld, ", tcp->u_arg [1]);
1280 tprintf ("%ld, ", tcp->u_arg [2]);
1283 if (tcp->u_arg[3] == 0 || syserror(tcp)) {
1284 tprintf("%#lx", tcp->u_arg[3]);
1286 printsock(tcp, tcp->u_arg[3], tcp->u_arg[4]);
1289 printnum(tcp, tcp->u_arg[4], "%lu");
1299 sys_xsetsockaddr(tcp)
1302 return netlib_call (tcp, sys_setsockaddr);
1308 sys_xgetsockopt(tcp)
1311 return netlib_call (tcp, sys_getsockopt);
1315 sys_xsetsockopt(tcp)
1318 return netlib_call (tcp, sys_setsockopt);
1325 return netlib_call (tcp, sys_shutdown);