blob: e2319646f6da87d51d1041a79cadb9fe6cbfdb67 [file] [log] [blame]
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001/*
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 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 * $Id$
30 */
31
32#include "defs.h"
33
34#include <sys/stat.h>
35#include <sys/socket.h>
36#include <sys/un.h>
37#include <netinet/in.h>
38#include <arpa/inet.h>
39#if defined(LINUX)
40#include <asm/types.h>
41#if defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC__ + __GLIBC_MINOR__ >= 3)
42# include <netipx/ipx.h>
43#else
44# include <linux/ipx.h>
45#endif
46#endif /* LINUX */
47
48#ifndef PF_UNSPEC
49#define PF_UNSPEC AF_UNSPEC
50#endif
51
52#ifdef LINUX
53/* Under Linux these are enums so we can't test for them with ifdef. */
54#define IPPROTO_EGP IPPROTO_EGP
55#define IPPROTO_PUP IPPROTO_PUP
56#define IPPROTO_IDP IPPROTO_IDP
57#define IPPROTO_IGMP IPPROTO_IGMP
58#define IPPROTO_RAW IPPROTO_RAW
59#define IPPROTO_MAX IPPROTO_MAX
60#endif
61
62static struct xlat domains[] = {
63 { PF_UNSPEC, "PF_UNSPEC" },
64 { PF_UNIX, "PF_UNIX" },
65 { PF_INET, "PF_INET" },
66#ifdef PF_LOCAL
67 { PF_LOCAL, "PS_LOCAL" },
68#endif
69#ifdef PF_ISO
70 { PF_ISO, "PF_ISO" },
71#endif
72#ifdef PF_AX25
73 { PF_AX25, "PF_AX25" },
74#endif
75#ifdef PF_IPX
76 { PF_IPX, "PF_IPX" },
77#endif
78#ifdef PF_APPLETALK
79 { PF_APPLETALK, "PF_APPLETALK" },
80#endif
81#ifdef PF_NETROM
82 { PF_NETROM, "PF_NETROM" },
83#endif
84#ifdef PF_BRIDGE
85 { PF_BRIDGE, "PF_BRIDGE" },
86#endif
87#ifdef PF_AAL5
88 { PF_AAL5, "PF_AAL5" },
89#endif
90#ifdef PF_X25
91 { PF_X25, "PF_X25" },
92#endif
93#ifdef PF_INET6
94 { PF_INET6, "PF_INET6" },
95#endif
96#ifdef PF_ROSE
97 { PF_ROSE, "PF_ROSE" },
98#endif
99#ifdef PF_DECNET
100 { PF_DECNET, "PF_DECNET" },
101#endif
102#ifdef PF_NETBEUI
103 { PF_NETBEUI, "PF_NETBEUI" },
104#endif
105#ifdef PF_IMPLINK
106 { PF_IMPLINK, "PF_IMPLINK" },
107#endif
108 { 0, NULL },
109};
110static struct xlat socktypes[] = {
111 { SOCK_STREAM, "SOCK_STREAM" },
112 { SOCK_DGRAM, "SOCK_DGRAM" },
113#ifdef SOCK_RAW
114 { SOCK_RAW, "SOCK_RAW" },
115#endif
116#ifdef SOCK_SEQPACKET
117 { SOCK_SEQPACKET,"SOCK_SEQPACKET"},
118#endif
119#ifdef SOCK_RDM
120 { SOCK_RDM, "SOCK_RDM" },
121#endif
122#ifdef SOCK_PACKET
123 { SOCK_PACKET, "SOCK_PACKET" },
124#endif
125 { 0, NULL },
126};
127static struct xlat protocols[] = {
128 { IPPROTO_IP, "IPPROTO_IP" },
129 { IPPROTO_ICMP, "IPPROTO_ICMP" },
130 { IPPROTO_TCP, "IPPROTO_TCP" },
131 { IPPROTO_UDP, "IPPROTO_UDP" },
132#ifdef IPPROTO_GGP
133 { IPPROTO_GGP, "IPPROTO_GGP" },
134#endif
135#ifdef IPPROTO_EGP
136 { IPPROTO_EGP, "IPPROTO_EGP" },
137#endif
138#ifdef IPPROTO_PUP
139 { IPPROTO_PUP, "IPPROTO_PUP" },
140#endif
141#ifdef IPPROTO_IDP
142 { IPPROTO_IDP, "IPPROTO_IDP" },
143#endif
144#ifdef IPPROTO_IPV6
145 { IPPROTO_IPV6, "IPPROTO_IPV6" },
146#endif
147#ifdef IPPROTO_ICMPV6
148 { IPPROTO_ICMPV6,"IPPROTO_ICMPV6"},
149#endif
150#ifdef IPPROTO_IGMP
151 { IPPROTO_IGMP, "IPPROTO_IGMP" },
152#endif
153#ifdef IPPROTO_HELLO
154 { IPPROTO_HELLO,"IPPROTO_HELLO" },
155#endif
156#ifdef IPPROTO_ND
157 { IPPROTO_ND, "IPPROTO_ND" },
158#endif
159#ifdef IPPROTO_RAW
160 { IPPROTO_RAW, "IPPROTO_RAW" },
161#endif
162#ifdef IPPROTO_MAX
163 { IPPROTO_MAX, "IPPROTO_MAX" },
164#endif
165#ifdef IPPROTO_IPIP
166 { IPPROTO_IPIP, "IPPROTO_IPIP" },
167#endif
168 { 0, NULL },
169};
170static struct xlat msg_flags[] = {
171 { MSG_OOB, "MSG_OOB" },
172#ifdef MSG_DONTROUTE
173 { MSG_DONTROUTE,"MSG_DONTROUTE" },
174#endif
175#ifdef MSG_PEEK
176 { MSG_PEEK, "MSG_PEEK" },
177#endif
178#ifdef MSG_CTRUNC
179 { MSG_CTRUNC, "MSG_CTRUNC" },
180#endif
181#ifdef MSG_PROXY
182 { MSG_PROXY, "MSG_PROXY" },
183#endif
184#ifdef MSG_EOR
185 { MSG_EOR, "MSG_EOR" },
186#endif
187#ifdef MSG_WAITALL
188 { MSG_WAITALL, "MSG_WAITALL" },
189#endif
190 { 0, NULL },
191};
192
193static struct xlat sockoptions[] = {
194#ifdef SO_DEBUG
195 { SO_DEBUG, "SO_DEBUG" },
196#endif
197#ifdef SO_REUSEADDR
198 { SO_REUSEADDR, "SO_REUSEADDR" },
199#endif
200#ifdef SO_KEEPALIVE
201 { SO_KEEPALIVE, "SO_KEEPALIVE" },
202#endif
203#ifdef SO_DONTROUTE
204 { SO_DONTROUTE, "SO_DONTROUTE" },
205#endif
206#ifdef SO_BROADCAST
207 { SO_BROADCAST, "SO_BROADCAST" },
208#endif
209#ifdef SO_LINGER
210 { SO_LINGER, "SO_LINGER" },
211#endif
212#ifdef SO_OOBINLINE
213 { SO_OOBINLINE, "SO_OOBINLINE" },
214#endif
215#ifdef SO_TYPE
216 { SO_TYPE, "SO_TYPE" },
217#endif
218#ifdef SO_ERROR
219 { SO_ERROR, "SO_ERROR" },
220#endif
221#ifdef SO_SNDBUF
222 { SO_SNDBUF, "SO_SNDBUF" },
223#endif
224#ifdef SO_RCVBUF
225 { SO_RCVBUF, "SO_RCVBUF" },
226#endif
227#ifdef SO_NO_CHECK
228 { SO_NO_CHECK, "SO_NO_CHECK" },
229#endif
230#ifdef SO_PRIORITY
231 { SO_PRIORITY, "SO_PRIORITY" },
232#endif
233#ifdef SO_ACCEPTCONN
234 { SO_ACCEPTCONN,"SO_ACCEPTCONN" },
235#endif
236#ifdef SO_USELOOPBACK
237 { SO_USELOOPBACK,"SO_USELOOPBACK"},
238#endif
239#ifdef SO_SNDLOWAT
240 { SO_SNDLOWAT, "SO_SNDLOWAT" },
241#endif
242#ifdef SO_RCVLOWAT
243 { SO_RCVLOWAT, "SO_RCVLOWAT" },
244#endif
245#ifdef SO_SNDTIMEO
246 { SO_SNDTIMEO, "SO_SNDTIMEO" },
247#endif
248#ifdef SO_RCVTIMEO
249 { SO_RCVTIMEO, "SO_RCVTIMEO" },
250#endif
251#ifdef SO_BSDCOMPAT
252 { SO_BSDCOMPAT, "SO_BSDCOMPAT" },
253#endif
254#ifdef SO_REUSEPORT
255 { SO_REUSEPORT, "SO_REUSEPORT" },
256#endif
257#ifdef SO_RCVLOWAT
258 { SO_RCVLOWAT, "SO_RCVLOWAT" },
259#endif
260#ifdef SO_SNDLOWAT
261 { SO_SNDLOWAT, "SO_SNDLOWAT" },
262#endif
263#ifdef SO_RCVTIMEO
264 { SO_RCVTIMEO, "SO_RCVTIMEO" },
265#endif
266#ifdef SO_SNDTIMEO
267 { SO_SNDTIMEO, "SO_SNDTIMEO" },
268#endif
269 { 0, NULL },
270};
271
272#ifdef SOL_IP
273static struct xlat sockipoptions[] = {
274 { IP_TOS, "IP_TOS" },
275 { IP_TTL, "IP_TTL" },
276#if defined(IP_HDRINCL)
277 { IP_HDRINCL, "IP_HDRINCL" },
278#endif
279#if defined(IP_OPTIONS)
280 { IP_OPTIONS, "IP_OPTIONS" },
281#endif
282 { IP_MULTICAST_IF, "IP_MULTICAST_IF" },
283 { IP_MULTICAST_TTL, "IP_MULTICAST_TTL" },
284 { IP_MULTICAST_LOOP, "IP_MULTICAST_LOOP" },
285 { IP_ADD_MEMBERSHIP, "IP_ADD_MEMBERSHIP" },
286 { IP_DROP_MEMBERSHIP, "IP_DROP_MEMBERSHIP" },
287 { 0, NULL },
288};
289#endif /* SOL_IP */
290
291#ifdef SOL_IPX
292static struct xlat sockipxoptions[] = {
293 { IPX_TYPE, "IPX_TYPE" },
294 { 0, NULL },
295};
296#endif /* SOL_IPX */
297
298#ifdef SOL_TCP
299static struct xlat socktcpoptions[] = {
300 { TCP_NODELAY, "TCP_NODELAY" },
301 { TCP_MAXSEG, "TCP_MAXSEG" },
302 { 0, NULL },
303};
304#endif /* SOL_TCP */
305
306void
307printsock(tcp, addr)
308struct tcb *tcp;
309long addr;
310{
311 struct sockaddr sa;
312 struct sockaddr_in *sin = (struct sockaddr_in *) &sa;
313 struct sockaddr_un sau;
314#ifdef LINUX
315 struct sockaddr_ipx sipx;
316#endif
317
318 if (addr == 0) {
319 tprintf("NULL");
320 return;
321 }
322 if (!verbose(tcp)) {
323 tprintf("%#lx", addr);
324 return;
325 }
326 if (umove(tcp, addr, &sa) < 0) {
327 tprintf("{...}");
328 return;
329 }
330 switch (sa.sa_family) {
331 case AF_UNIX:
332 if (umove(tcp, addr, &sau) < 0)
333 tprintf("{sun_family=AF_UNIX, ...}");
334 else
335 tprintf("{sun_family=AF_UNIX, sun_path=\"%s\"}",
336 sau.sun_path);
337 break;
338 case AF_INET:
339 tprintf("{sin_family=AF_INET, ");
340 tprintf("sin_port=htons(%u), sin_addr=inet_addr(\"%s\")}",
341 ntohs(sin->sin_port), inet_ntoa(sin->sin_addr));
342 break;
343#ifdef AF_IPX
344 case AF_IPX:
345 if (umove(tcp, addr, &sipx)<0)
346 tprintf("{sipx_family=AF_IPX, ...}");
347 else {
348 int i;
349 tprintf("{sipx_family=AF_IPX, ");
350 tprintf("{sipx_port=htons(%u), ",
351 ntohs(sipx.sipx_port));
352 /* Yes, I know, this does not look too
353 * strace-ish, but otherwise the IPX
354 * addresses just look monstrous...
355 * Anyways, feel free if you don't like
356 * this way.. :)
357 */
Nate Sammons6bfcd321999-04-06 01:39:04 +0000358 tprintf("%08lx:", (unsigned long)ntohl(sipx.sipx_network));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000359 for (i = 0; i<IPX_NODE_LEN; i++)
360 tprintf("%02x", sipx.sipx_node[i]);
361 tprintf("/[%02x]", sipx.sipx_type);
362 tprintf("}");
363 }
364 break;
365#endif /* AF_IPX */
366 /* AF_AX25 AF_APPLETALK AF_NETROM AF_BRIDGE AF_AAL5
367 AF_X25 AF_INET6 AF_ROSE still need to be done */
368
369 default:
370 tprintf("{sa_family=%u, sa_data=", sa.sa_family);
371 printstr(tcp, (long) &((struct sockaddr *) addr)->sa_data,
372 sizeof sa.sa_data);
373 tprintf("}");
374 break;
375 }
376}
377
378#if HAVE_SENDMSG
379
380static void
381printmsghdr(tcp, addr)
382struct tcb *tcp;
383long addr;
384{
385 struct msghdr msg;
386
387 umove(tcp, addr, &msg);
388 tprintf("{msg_name=%s, msg_namelen=%u, msg_iov=%#lx, msg_iovlen=%u, ",
389 (char *) msg.msg_name, msg.msg_namelen,
390 (unsigned long) msg.msg_iov, msg.msg_iovlen);
391#ifdef HAVE_MSG_CONTROL
392 tprintf("msg_control=%#lx, msg_controllen=%u, msg_flags=%#x}",
393 (unsigned long) msg.msg_control, msg.msg_controllen,
394 msg.msg_flags);
395#else /* !HAVE_MSG_CONTROL */
396 tprintf("msg_accrights=%#lx, msg_accrightslen=%u}",
397 (unsigned long) msg.msg_accrights, msg.msg_accrightslen);
398#endif /* !HAVE_MSG_CONTROL */
399}
400
401#endif /* HAVE_SENDMSG */
402
403int
404sys_socket(tcp)
405struct tcb *tcp;
406{
407 if (entering(tcp)) {
408 printxval(domains, tcp->u_arg[0], "PF_???");
409 tprintf(", ");
410 printxval(socktypes, tcp->u_arg[1], "SOCK_???");
411 tprintf(", ");
412 switch (tcp->u_arg[0]) {
413 case PF_INET:
414 printxval(protocols, tcp->u_arg[2], "IPPROTO_???");
415 break;
416#ifdef PF_IPX
417 case PF_IPX:
418 /* BTW: I don't believe this.. */
419 tprintf("[");
420 printxval(domains, tcp->u_arg[2], "PF_???");
421 tprintf("]");
422 break;
423#endif /* PF_IPX */
424 default:
425 tprintf("%lu", tcp->u_arg[2]);
426 break;
427 }
428 }
429 return 0;
430}
431
432int
433sys_bind(tcp)
434struct tcb *tcp;
435{
436 if (entering(tcp)) {
437 tprintf("%ld, ", tcp->u_arg[0]);
438 printsock(tcp, tcp->u_arg[1]);
439 tprintf(", %lu", tcp->u_arg[2]);
440 }
441 return 0;
442}
443
444int
445sys_connect(tcp)
446struct tcb *tcp;
447{
448 return sys_bind(tcp);
449}
450
451int
452sys_listen(tcp)
453struct tcb *tcp;
454{
455 if (entering(tcp)) {
456 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
457 }
458 return 0;
459}
460
461int
462sys_accept(tcp)
463struct tcb *tcp;
464{
465 if (entering(tcp)) {
466 tprintf("%ld, ", tcp->u_arg[0]);
467 } else if (!tcp->u_arg[2])
468 tprintf("%#lx, NULL", tcp->u_arg[1]);
469 else {
470 if (tcp->u_arg[1] == 0 || syserror(tcp)) {
471 tprintf("%#lx", tcp->u_arg[1]);
472 } else {
473 printsock(tcp, tcp->u_arg[1]);
474 }
475 tprintf(", ");
476 printnum(tcp, tcp->u_arg[2], "%lu");
477 }
478 return 0;
479}
480
481int
482sys_send(tcp)
483struct tcb *tcp;
484{
485 if (entering(tcp)) {
486 tprintf("%ld, ", tcp->u_arg[0]);
487 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
488 tprintf(", %lu, ", tcp->u_arg[2]);
489 /* flags */
490 if (printflags(msg_flags, tcp->u_arg[3]) == 0)
491 tprintf("0");
492 }
493 return 0;
494}
495
496int
497sys_sendto(tcp)
498struct tcb *tcp;
499{
500 if (entering(tcp)) {
501 tprintf("%ld, ", tcp->u_arg[0]);
502 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
503 tprintf(", %lu, ", tcp->u_arg[2]);
504 /* flags */
505 if (printflags(msg_flags, tcp->u_arg[3]) == 0)
506 tprintf("0");
507 /* to address */
508 tprintf(", ");
509 printsock(tcp, tcp->u_arg[4]);
510 /* to length */
511 tprintf(", %lu", tcp->u_arg[5]);
512 }
513 return 0;
514}
515
516#ifdef HAVE_SENDMSG
517
518int
519sys_sendmsg(tcp)
520struct tcb *tcp;
521{
522 if (entering(tcp)) {
523 tprintf("%ld, ", tcp->u_arg[0]);
524 printmsghdr(tcp, tcp->u_arg[1]);
525 /* flags */
526 tprintf(", ");
527 if (printflags(msg_flags, tcp->u_arg[2]) == 0)
528 tprintf("0");
529 }
530 return 0;
531}
532
533#endif /* HAVE_SENDMSG */
534
535int
536sys_recv(tcp)
537struct tcb *tcp;
538{
539 if (entering(tcp)) {
540 tprintf("%ld, ", tcp->u_arg[0]);
541 } else {
542 if (syserror(tcp))
543 tprintf("%#lx", tcp->u_arg[1]);
544 else
545 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
546
547 tprintf(", %lu, ", tcp->u_arg[2]);
548 if (printflags(msg_flags, tcp->u_arg[3]) == 0)
549 tprintf("0");
550 }
551 return 0;
552}
553
554int
555sys_recvfrom(tcp)
556struct tcb *tcp;
557{
558 int fromlen;
559
560 if (entering(tcp)) {
561 tprintf("%ld, ", tcp->u_arg[0]);
562 } else {
563 if (syserror(tcp)) {
564 tprintf("%#lx, %lu, %lu, %#lx, %#lx",
565 tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3],
566 tcp->u_arg[4], tcp->u_arg[5]);
567 return 0;
568 }
569 /* buf */
570 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
571 /* len */
572 tprintf(", %lu, ", tcp->u_arg[2]);
573 /* flags */
574 if (printflags(msg_flags, tcp->u_arg[3]) == 0)
575 tprintf("0");
576 /* from address, len */
577 if (!tcp->u_arg[4] || !tcp->u_arg[5]) {
578 if (tcp->u_arg[4] == 0)
579 tprintf(", NULL");
580 else
581 tprintf(", %#lx", tcp->u_arg[4]);
582 if (tcp->u_arg[5] == 0)
583 tprintf(", NULL");
584 else
585 tprintf(", %#lx", tcp->u_arg[5]);
586 return 0;
587 }
588 if (umove(tcp, tcp->u_arg[5], &fromlen) < 0) {
589 tprintf(", {...}, [?]");
590 return 0;
591 }
592 tprintf(", ");
593 printsock(tcp, tcp->u_arg[4]);
594 /* from length */
595 tprintf(", [%u]", fromlen);
596 }
597 return 0;
598}
599
600#ifdef HAVE_SENDMSG
601
602int
603sys_recvmsg(tcp)
604struct tcb *tcp;
605{
606 if (entering(tcp)) {
607 tprintf("%ld, ", tcp->u_arg[0]);
608 } else {
609 if (syserror(tcp) || !verbose(tcp))
610 tprintf("%#lx", tcp->u_arg[1]);
611 else
612 printmsghdr(tcp, tcp->u_arg[1]);
613 /* flags */
614 tprintf(", ");
615 if (printflags(msg_flags, tcp->u_arg[2]) == 0)
616 tprintf("0");
617 }
618 return 0;
619}
620
621#endif /* HAVE_SENDMSG */
622
623int
624sys_shutdown(tcp)
625struct tcb *tcp;
626{
627 if (entering(tcp)) {
628 tprintf("%ld, %ld", tcp->u_arg[0], tcp->u_arg[1]);
629 switch (tcp->u_arg[1]) {
630 case 0:
631 tprintf("%s", " /* receive */");
632 break;
633 case 1:
634 tprintf("%s", " /* send */");
635 break;
636 case 2:
637 tprintf("%s", " /* send and receive */");
638 break;
639 }
640 }
641 return 0;
642}
643
644int
645sys_getsockname(tcp)
646struct tcb *tcp;
647{
648 return sys_accept(tcp);
649}
650
651int
652sys_getpeername(tcp)
653struct tcb *tcp;
654{
655 return sys_accept(tcp);
656}
657
658int
659sys_pipe(tcp)
660struct tcb *tcp;
661{
662
663#if defined(LINUX) && !defined(SPARC)
664 int fds[2];
665
666 if (exiting(tcp)) {
667 if (syserror(tcp)) {
668 tprintf("%#lx", tcp->u_arg[0]);
669 return 0;
670 }
671 if (umoven(tcp, tcp->u_arg[0], sizeof fds, (char *) fds) < 0)
672 tprintf("[...]");
673 else
674 tprintf("[%u, %u]", fds[0], fds[1]);
675 }
Wichert Akkerman5daa0281999-03-15 19:49:42 +0000676#elif defined(SPARC) || defined(SVR4)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000677 if (exiting(tcp))
678 tprintf("[%lu, %lu]", tcp->u_rval, getrval2(tcp));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000679#endif
680 return 0;
681}
682
683int
684sys_socketpair(tcp)
685struct tcb *tcp;
686{
687#ifdef LINUX
688 int fds[2];
689#endif
690
691 if (entering(tcp)) {
692 printxval(domains, tcp->u_arg[0], "PF_???");
693 tprintf(", ");
694 printxval(socktypes, tcp->u_arg[1], "SOCK_???");
695 tprintf(", ");
696 switch (tcp->u_arg[0]) {
697 case PF_INET:
698 printxval(protocols, tcp->u_arg[2], "IPPROTO_???");
699 break;
700#ifdef PF_IPX
701 case PF_IPX:
702 /* BTW: I don't believe this.. */
703 tprintf("[");
704 printxval(domains, tcp->u_arg[2], "PF_???");
705 tprintf("]");
706 break;
707#endif /* PF_IPX */
708 default:
709 tprintf(", %lu", tcp->u_arg[2]);
710 break;
711 }
712 } else {
713 if (syserror(tcp)) {
714 tprintf("%#lx", tcp->u_arg[3]);
715 return 0;
716 }
717#ifdef LINUX
718 if (umoven(tcp, tcp->u_arg[3], sizeof fds, (char *) fds) < 0)
719 tprintf("[...]");
720 else
721 tprintf(", [%u, %u]", fds[0], fds[1]);
722#endif /* LINUX */
723#ifdef SUNOS4
724 tprintf(", [%lu, %lu]", tcp->u_rval, getrval2(tcp));
725#endif /* SUNOS4 */
726#ifdef SVR4
727 tprintf(", [%lu, %lu]", tcp->u_rval, getrval2(tcp));
728#endif /* SVR4 */
729 }
730 return 0;
731}
732
733int
734sys_getsockopt(tcp)
735struct tcb *tcp;
736{
737 if (entering(tcp)) {
738 tprintf("%ld, ", tcp->u_arg[0]);
739 switch (tcp->u_arg[1]) {
740 case SOL_SOCKET:
741 tprintf("SOL_SOCKET, ");
742 printxval(sockoptions, tcp->u_arg[2], "SO_???");
743 tprintf(", ");
744 break;
745#ifdef SOL_IP
746 case SOL_IP:
747 tprintf("SOL_IP, ");
748 printxval(sockipoptions, tcp->u_arg[2], "IP_???");
749 tprintf(", ");
750 break;
751#endif
752#ifdef SOL_IPX
753 case SOL_IPX:
754 tprintf("SOL_IPX, ");
755 printxval(sockipxoptions, tcp->u_arg[2], "IPX_???");
756 tprintf(", ");
757 break;
758#endif
759#ifdef SOL_TCP
760 case SOL_TCP:
761 tprintf("SOL_TCP, ");
762 printxval(socktcpoptions, tcp->u_arg[2], "TCP_???");
763 tprintf(", ");
764 break;
765#endif
766
767 /* SOL_AX25 SOL_ROSE SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25
768 * etc. still need work */
769 default:
770 /* XXX - should know socket family here */
771 printxval(protocols, tcp->u_arg[1], "IPPROTO_???");
772 tprintf("%lu, ", tcp->u_arg[2]);
773 break;
774 }
775 } else {
776 if (syserror(tcp)) {
777 tprintf("%#lx, %#lx",
778 tcp->u_arg[3], tcp->u_arg[4]);
779 return 0;
780 }
781 printnum(tcp, tcp->u_arg[3], "%ld");
782 tprintf(", ");
783 printnum(tcp, tcp->u_arg[4], "%ld");
784 }
785 return 0;
786}
787
788int
789sys_setsockopt(tcp)
790struct tcb *tcp;
791{
792 if (entering(tcp)) {
793 tprintf("%ld, ", tcp->u_arg[0]);
794 switch (tcp->u_arg[1]) {
795 case SOL_SOCKET:
796 tprintf("SOL_SOCKET, ");
797 printxval(sockoptions, tcp->u_arg[2], "SO_???");
798 tprintf(", ");
799 break;
800#ifdef SOL_IP
801 case SOL_IP:
802 tprintf("SOL_IP, ");
803 printxval(sockipoptions, tcp->u_arg[2], "IP_???");
804 tprintf(", ");
805 break;
806#endif
807#ifdef SOL_IPX
808 case SOL_IPX:
809 tprintf("SOL_IPX, ");
810 printxval(sockipxoptions, tcp->u_arg[2], "IPX_???");
811 tprintf(", ");
812 break;
813#endif
814#ifdef SOL_TCP
815 case SOL_TCP:
816 tprintf("SOL_TCP, ");
817 printxval(socktcpoptions, tcp->u_arg[2], "TCP_???");
818 tprintf(", ");
819 break;
820#endif
821
822 /* SOL_AX25 SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25
823 * etc. still need work */
824 default:
825 /* XXX - should know socket family here */
826 printxval(protocols, tcp->u_arg[1], "IPPROTO_???");
827 tprintf("%lu, ", tcp->u_arg[2]);
828 break;
829 }
830 printnum(tcp, tcp->u_arg[3], "%ld");
831 tprintf(", %lu", tcp->u_arg[4]);
832 }
833 return 0;
834}