]> granicus.if.org Git - strace/blob - net.c
add clone
[strace] / net.c
1 /*
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>
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
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.
18  *
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.
29  *
30  *      $Id$
31  */
32
33 #include "defs.h"
34
35 #include <sys/stat.h>
36 #include <sys/socket.h>
37 #include <sys/un.h>
38 #include <netinet/in.h>
39 #ifdef FREEBSD
40 #include <netinet/tcp.h>
41 #endif
42 #include <arpa/inet.h>
43 #if defined(LINUX)
44 #include <asm/types.h>
45 #if defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC__ + __GLIBC_MINOR__ >= 3)
46 #  include <netipx/ipx.h>
47 #else
48 #  include <linux/ipx.h>
49 #endif
50 #endif /* LINUX */
51
52 #if defined (__GLIBC__) && ((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1))
53 #if defined(HAVE_LINUX_IN6_H)
54 #include <linux/in6.h>
55 #endif
56 #endif
57
58 #if defined(HAVE_SYS_UIO_H)
59 #include <sys/uio.h>
60 #endif
61
62 #if defined(HAVE_LINUX_NETLINK_H)
63 #include <linux/netlink.h>
64 #endif
65
66 #if defined(HAVE_LINUX_IF_PACKET_H)
67 #include <linux/if_packet.h>
68 #endif
69
70 #if defined(HAVE_LINUX_ICMP_H)
71 #include <linux/icmp.h>
72 #endif
73
74 #ifndef PF_UNSPEC
75 #define PF_UNSPEC AF_UNSPEC
76 #endif
77
78 #if UNIXWARE >= 7
79 #define HAVE_SENDMSG            1               /* HACK - *FIXME* */
80 #endif
81
82 #ifdef LINUX
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
90 #endif
91
92 static struct xlat domains[] = {
93         { PF_UNSPEC,    "PF_UNSPEC"     },
94         { PF_UNIX,      "PF_UNIX"       },
95         { PF_INET,      "PF_INET"       },
96 #ifdef PF_NETLINK
97         { PF_NETLINK,   "PF_NETLINK"    },
98 #endif
99 #ifdef PF_PACKET
100         { PF_PACKET,    "PF_PACKET"     },
101 #endif
102 #ifdef PF_INET6
103         { PF_INET6,     "PF_INET6"      },
104 #endif
105 #ifdef PF_ATMSVC
106         { PF_ATMSVC,    "PF_INET6"      },
107 #endif
108 #ifdef PF_INET6
109         { PF_INET6,     "PF_INET6"      },
110 #endif
111 #ifdef PF_LOCAL
112         { PF_LOCAL,     "PS_LOCAL"      },
113 #endif
114 #ifdef PF_ISO
115         { PF_ISO,       "PF_ISO"        },
116 #endif
117 #ifdef PF_AX25
118         { PF_AX25,      "PF_AX25"       },
119 #endif
120 #ifdef PF_IPX
121         { PF_IPX,       "PF_IPX"        },
122 #endif
123 #ifdef PF_APPLETALK
124         { PF_APPLETALK, "PF_APPLETALK"  },
125 #endif
126 #ifdef PF_NETROM
127         { PF_NETROM,    "PF_NETROM"     },
128 #endif
129 #ifdef PF_BRIDGE
130         { PF_BRIDGE,    "PF_BRIDGE"     },
131 #endif
132 #ifdef PF_AAL5
133         { PF_AAL5,      "PF_AAL5"       },
134 #endif
135 #ifdef PF_X25
136         { PF_X25,       "PF_X25"        },
137 #endif
138 #ifdef PF_ROSE
139         { PF_ROSE,      "PF_ROSE"       },
140 #endif
141 #ifdef PF_DECNET
142         { PF_DECNET,    "PF_DECNET"     },
143 #endif
144 #ifdef PF_NETBEUI
145         { PF_NETBEUI,   "PF_NETBEUI"    },
146 #endif
147 #ifdef PF_IMPLINK
148         { PF_IMPLINK,   "PF_IMPLINK"    },
149 #endif
150         { 0,            NULL            },
151 };
152 static struct xlat addrfams[] = {
153         { AF_UNSPEC,    "AF_UNSPEC"     },
154         { AF_UNIX,      "AF_UNIX"       },
155         { AF_INET,      "AF_INET"       },
156 #ifdef AF_INET6
157         { AF_INET6,     "AF_INET6"      },
158 #endif
159         { AF_DECnet,    "AF_DECnet"     },
160 #ifdef PF_ATMSVC
161         { AF_ATMSVC,    "AF_ATMSVC"     },
162 #endif
163 #ifdef AF_PACKET
164         { AF_PACKET,    "AF_PACKET"     },
165 #endif
166 #ifdef AF_NETLINK
167         { AF_NETLINK,   "AF_NETLINK"    },
168 #endif
169 #ifdef AF_ISO
170         { AF_ISO,       "AF_ISO"        },
171 #endif
172 #ifdef AF_IMPLINK
173         { AF_IMPLINK,   "AF_IMPLINK"    },
174 #endif
175         { 0,            NULL            },
176 };
177 static struct xlat socktypes[] = {
178         { SOCK_STREAM,  "SOCK_STREAM"   },
179         { SOCK_DGRAM,   "SOCK_DGRAM"    },
180 #ifdef SOCK_RAW
181         { SOCK_RAW,     "SOCK_RAW"      },
182 #endif
183 #ifdef SOCK_SEQPACKET
184         { SOCK_SEQPACKET,"SOCK_SEQPACKET"},
185 #endif
186 #ifdef SOCK_RDM
187         { SOCK_RDM,     "SOCK_RDM"      },
188 #endif
189 #ifdef SOCK_PACKET
190         { SOCK_PACKET,  "SOCK_PACKET"   },
191 #endif
192         { 0,            NULL            },
193 };
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"   },
199 #ifdef IPPROTO_GGP
200         { IPPROTO_GGP,  "IPPROTO_GGP"   },
201 #endif
202 #ifdef IPPROTO_EGP
203         { IPPROTO_EGP,  "IPPROTO_EGP"   },
204 #endif
205 #ifdef IPPROTO_PUP
206         { IPPROTO_PUP,  "IPPROTO_PUP"   },
207 #endif
208 #ifdef IPPROTO_IDP
209         { IPPROTO_IDP,  "IPPROTO_IDP"   },
210 #endif
211 #ifdef IPPROTO_IPV6
212         { IPPROTO_IPV6, "IPPROTO_IPV6"  },
213 #endif
214 #ifdef IPPROTO_ICMPV6
215         { IPPROTO_ICMPV6,"IPPROTO_ICMPV6"},
216 #endif
217 #ifdef IPPROTO_IGMP
218         { IPPROTO_IGMP, "IPPROTO_IGMP"  },
219 #endif
220 #ifdef IPPROTO_HELLO
221         { IPPROTO_HELLO,"IPPROTO_HELLO" },
222 #endif
223 #ifdef IPPROTO_ND
224         { IPPROTO_ND,   "IPPROTO_ND"    },
225 #endif
226 #ifdef IPPROTO_RAW
227         { IPPROTO_RAW,  "IPPROTO_RAW"   },
228 #endif
229 #ifdef IPPROTO_MAX
230         { IPPROTO_MAX,  "IPPROTO_MAX"   },
231 #endif
232 #ifdef IPPROTO_IPIP
233         { IPPROTO_IPIP, "IPPROTO_IPIP"  },
234 #endif
235         { 0,            NULL            },
236 };
237 static struct xlat msg_flags[] = {
238         { MSG_OOB,      "MSG_OOB"       },
239 #ifdef MSG_DONTROUTE
240         { MSG_DONTROUTE,"MSG_DONTROUTE" },
241 #endif
242 #ifdef MSG_PEEK
243         { MSG_PEEK,     "MSG_PEEK"      },
244 #endif
245 #ifdef MSG_CTRUNC
246         { MSG_CTRUNC,   "MSG_CTRUNC"    },
247 #endif
248 #ifdef MSG_PROXY
249         { MSG_PROXY,    "MSG_PROXY"     },
250 #endif
251 #ifdef MSG_EOR
252         { MSG_EOR,      "MSG_EOR"       },
253 #endif
254 #ifdef MSG_WAITALL
255         { MSG_WAITALL,  "MSG_WAITALL"   },
256 #endif
257 #ifdef MSG_TRUNC
258         { MSG_TRUNC,    "MSG_TRUNC"     },
259 #endif
260 #ifdef MSG_CTRUNC
261         { MSG_CTRUNC,   "MSG_CTRUNC"    },
262 #endif
263 #ifdef MSG_ERRQUEUE
264         { MSG_ERRQUEUE, "MSG_ERRQUEUE"  },
265 #endif
266 #ifdef MSG_DONTWAIT
267         { MSG_DONTWAIT, "MSG_DONTWAIT"  },
268 #endif
269 #ifdef MSG_CONFIRM
270         { MSG_CONFIRM,  "MSG_CONFIRM"   },
271 #endif
272 #ifdef MSG_PROBE
273         { MSG_PROBE,    "MSG_PROBE"     },
274 #endif
275         { 0,            NULL            },
276 };
277
278 static struct xlat sockoptions[] = {
279 #ifdef SO_PEERCRED
280         { SO_PEERCRED,  "SO_PEERCRED"   },
281 #endif
282 #ifdef SO_PASSCRED
283         { SO_PASSCRED,  "SO_PASSCRED"   },
284 #endif
285 #ifdef SO_DEBUG
286         { SO_DEBUG,     "SO_DEBUG"      },
287 #endif
288 #ifdef SO_REUSEADDR
289         { SO_REUSEADDR, "SO_REUSEADDR"  },
290 #endif
291 #ifdef SO_KEEPALIVE
292         { SO_KEEPALIVE, "SO_KEEPALIVE"  },
293 #endif
294 #ifdef SO_DONTROUTE
295         { SO_DONTROUTE, "SO_DONTROUTE"  },
296 #endif
297 #ifdef SO_BROADCAST
298         { SO_BROADCAST, "SO_BROADCAST"  },
299 #endif
300 #ifdef SO_LINGER
301         { SO_LINGER,    "SO_LINGER"     },
302 #endif
303 #ifdef SO_OOBINLINE
304         { SO_OOBINLINE, "SO_OOBINLINE"  },
305 #endif
306 #ifdef SO_TYPE
307         { SO_TYPE,      "SO_TYPE"       },
308 #endif
309 #ifdef SO_ERROR
310         { SO_ERROR,     "SO_ERROR"      },
311 #endif
312 #ifdef SO_SNDBUF
313         { SO_SNDBUF,    "SO_SNDBUF"     },
314 #endif
315 #ifdef SO_RCVBUF
316         { SO_RCVBUF,    "SO_RCVBUF"     },
317 #endif
318 #ifdef SO_NO_CHECK
319         { SO_NO_CHECK,  "SO_NO_CHECK"   },
320 #endif
321 #ifdef SO_PRIORITY
322         { SO_PRIORITY,  "SO_PRIORITY"   },
323 #endif
324 #ifdef SO_ACCEPTCONN
325         { SO_ACCEPTCONN,"SO_ACCEPTCONN" },
326 #endif
327 #ifdef SO_USELOOPBACK
328         { SO_USELOOPBACK,"SO_USELOOPBACK"},
329 #endif
330 #ifdef SO_SNDLOWAT
331         { SO_SNDLOWAT,  "SO_SNDLOWAT"   },
332 #endif
333 #ifdef SO_RCVLOWAT
334         { SO_RCVLOWAT,  "SO_RCVLOWAT"   },
335 #endif
336 #ifdef SO_SNDTIMEO
337         { SO_SNDTIMEO,  "SO_SNDTIMEO"   },
338 #endif
339 #ifdef SO_RCVTIMEO
340         { SO_RCVTIMEO,  "SO_RCVTIMEO"   },
341 #endif
342 #ifdef SO_BSDCOMPAT
343         { SO_BSDCOMPAT, "SO_BSDCOMPAT"  },
344 #endif
345 #ifdef SO_REUSEPORT
346         { SO_REUSEPORT, "SO_REUSEPORT"  },
347 #endif
348 #ifdef SO_RCVLOWAT
349         { SO_RCVLOWAT, "SO_RCVLOWAT"    },
350 #endif
351 #ifdef SO_SNDLOWAT
352         { SO_SNDLOWAT, "SO_SNDLOWAT"    },
353 #endif
354 #ifdef SO_RCVTIMEO
355         { SO_RCVTIMEO, "SO_RCVTIMEO"    },
356 #endif
357 #ifdef SO_SNDTIMEO
358         { SO_SNDTIMEO, "SO_SNDTIMEO"    },
359 #endif
360         { 0,            NULL            },
361 };
362
363 #ifdef SOL_IP
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"            },
369 #endif
370 #if defined(IP_OPTIONS)
371         { IP_OPTIONS,           "IP_OPTIONS"            },
372 #endif
373         { IP_ROUTER_ALERT,      "IP_ROUTER_ALERT"       },
374 #if defined(IP_RECVOPTIONS)
375         { IP_RECVOPTIONS,       "IP_RECVOPTIONS"        },
376 #endif
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"         },
385 #if defined(IP_MTU)
386         { IP_MTU,               "IP_MTU"                },
387 #endif
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"    },
393         { 0,                    NULL                    },
394 };
395 #endif /* SOL_IP */
396
397 #ifdef SOL_IPX
398 static struct xlat sockipxoptions[] = {
399         { IPX_TYPE,     "IPX_TYPE"      },
400         { 0,            NULL            },
401 };
402 #endif /* SOL_IPX */
403
404 #ifdef SOL_RAW
405 static struct xlat sockrawoptions[] = {
406 #if defined(ICMP_FILTER)
407         { ICMP_FILTER,          "ICMP_FILTER"   },
408 #endif
409         { 0,                    NULL            },
410 };
411 #endif /* SOL_RAW */
412
413 #ifdef SOL_PACKET
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"    },
419 #endif
420 #if defined(PACKET_RX_RING)
421         { PACKET_RX_RING,               "PACKET_RX_RING"        },
422 #endif
423 #if defined(PACKET_STATISTICS)
424         { PACKET_STATISTICS,            "PACKET_STATISTICS"     },
425 #endif
426         { 0,                            NULL                    },
427 };
428 #endif /* SOL_PACKET */
429
430 #ifdef SOL_TCP
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"      },
436 #endif
437         { 0,            NULL            },
438 };
439 #endif /* SOL_TCP */
440
441 #ifdef SOL_RAW
442 static struct xlat icmpfilterflags[] = {
443 #if defined(ICMP_ECHOREPLY)
444         { (1<<ICMP_ECHOREPLY),          "ICMP_ECHOREPLY"        },
445 #endif
446 #if defined(ICMP_DEST_UNREACH)
447         { (1<<ICMP_DEST_UNREACH),       "ICMP_DEST_UNREACH"     },
448 #endif
449 #if defined(ICMP_SOURCE_QUENCH)
450         { (1<<ICMP_SOURCE_QUENCH),      "ICMP_SOURCE_QUENCH"    },
451 #endif
452 #if defined(ICMP_REDIRECT)
453         { (1<<ICMP_REDIRECT),           "ICMP_REDIRECT"         },
454 #endif
455 #if defined(ICMP_ECHO)
456         { (1<<ICMP_ECHO),               "ICMP_ECHO"             },
457 #endif
458 #if defined(ICMP_TIME_EXCEEDED)
459         { (1<<ICMP_TIME_EXCEEDED),      "ICMP_TIME_EXCEEDED"    },
460 #endif
461 #if defined(ICMP_PARAMETERPROB)
462         { (1<<ICMP_PARAMETERPROB),      "ICMP_PARAMETERPROB"    },
463 #endif
464 #if defined(ICMP_TIMESTAMP)
465         { (1<<ICMP_TIMESTAMP),          "ICMP_TIMESTAMP"        },
466 #endif
467 #if defined(ICMP_TIMESTAMPREPLY)
468         { (1<<ICMP_TIMESTAMPREPLY),     "ICMP_TIMESTAMPREPLY"   },
469 #endif
470 #if defined(ICMP_INFO_REQUEST)
471         { (1<<ICMP_INFO_REQUEST),       "ICMP_INFO_REQUEST"     },
472 #endif
473 #if defined(ICMP_INFO_REPLY)
474         { (1<<ICMP_INFO_REPLY),         "ICMP_INFO_REPLY"       },
475 #endif
476 #if defined(ICMP_ADDRESS)
477         { (1<<ICMP_ADDRESS),            "ICMP_ADDRESS"          },
478 #endif
479 #if defined(ICMP_ADDRESSREPLY)
480         { (1<<ICMP_ADDRESSREPLY),       "ICMP_ADDRESSREPLY"     },
481 #endif
482         { 0,                            NULL                    },
483 };
484 #endif /* SOL_RAW */
485
486
487 void
488 printsock(tcp, addr, addrlen)
489 struct tcb *tcp;
490 long addr;
491 int addrlen;
492 {
493         union {
494                 char pad[128];
495                 struct sockaddr sa;
496                 struct sockaddr_in sin;
497                 struct sockaddr_un sau;
498 #ifdef HAVE_INET_NTOP
499                 struct sockaddr_in6 sa6;
500 #endif
501 #if defined(LINUX) && defined(AF_IPX)
502                 struct sockaddr_ipx sipx;
503 #endif
504 #ifdef AF_PACKET
505                 struct sockaddr_ll ll;
506 #endif
507 #ifdef AF_NETLINK
508                 struct sockaddr_nl nl;
509 #endif
510         } addrbuf;
511         char string_addr[100];
512
513         if (addr == 0) {
514                 tprintf("NULL");
515                 return;
516         }
517         if (!verbose(tcp)) {
518                 tprintf("%#lx", addr);
519                 return;
520         }
521         if ((addrlen<2) || (addrlen>sizeof(addrbuf)))
522                 addrlen=sizeof(addrbuf);
523
524         if (umoven(tcp, addr, addrlen, (char*)&addrbuf) < 0) {
525                 tprintf("{...}");
526                 return;
527         }
528
529         tprintf("{sin_family=");
530         printxval(addrfams, addrbuf.sa.sa_family, "AF_???");
531         tprintf(", ");
532
533         switch (addrbuf.sa.sa_family) {
534         case AF_UNIX:
535                 if (addrlen==2) {
536                         tprintf("<nil>");
537                 } else if (addrbuf.sau.sun_path[0]) {
538                         tprintf("path=\"%*.*s\"", addrlen-2, addrlen-2, addrbuf.sau.sun_path);
539                 } else {
540                         tprintf("path=@%*.*s", addrlen-3, addrlen-3, addrbuf.sau.sun_path+1);
541                 }
542                 break;
543         case AF_INET:
544                 tprintf("sin_port=htons(%u), sin_addr=inet_addr(\"%s\")}",
545                         ntohs(addrbuf.sin.sin_port), inet_ntoa(addrbuf.sin.sin_addr));
546                 break;
547 #ifdef HAVE_INET_NTOP
548         case AF_INET6:
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));
552                 break;  
553 #endif
554 #if defined(AF_IPX) && defined(linux)
555         case AF_IPX:
556                 {
557                         int i;
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
564                          * this way.. :) 
565                          */
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);
570                 }
571                 break;
572 #endif /* AF_IPX && linux */
573 #ifdef AF_PACKET
574         case AF_PACKET:
575                 {
576                         int i;
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]);
585                 }
586                 break;
587
588 #endif /* AF_APACKET */
589 #ifdef AF_NETLINLK
590         case AF_NETLINK:
591                 tprintf("pid=%d, groups=%08x", addrbuf.nl.nl_pid, addrbuf.nl.nl_groups);
592                 break;
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 */
596
597         default:
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);
601                 break;
602         }
603         tprintf("}");
604 }
605
606 #if HAVE_SENDMSG
607
608 static void
609 printiovec(tcp, iovec, len)
610 struct tcb *tcp;
611 struct iovec *iovec;
612 long   len;
613 {
614         struct iovec *iov;
615         int i;
616
617         iov = (struct iovec *) malloc(len * sizeof *iov);
618         if (iov == NULL) {
619                 fprintf(stderr, "No memory");
620                 return;
621         }
622         if (umoven(tcp, (long)iovec,
623                                 len * sizeof *iov, (char *) iov) < 0) {
624                 tprintf("%#lx", (unsigned long)iovec);
625         } else {
626                 tprintf("[");
627                 for (i = 0; i < len; i++) {
628                         if (i)
629                                 tprintf(", ");
630                         tprintf("{");
631                         printstr(tcp, (long) iov[i].iov_base,
632                                         iov[i].iov_len);
633                         tprintf(", %lu}", (unsigned long)iov[i].iov_len);
634                 }
635                 tprintf("]");
636         }
637         free((char *) iov);
638 }
639
640 static void
641 printmsghdr(tcp, addr)
642 struct tcb *tcp;
643 long addr;
644 {
645         struct msghdr msg;
646
647         if (umove(tcp, addr, &msg) < 0) {
648                 tprintf("%#lx", addr);
649                 return;
650         }
651         tprintf("{msg_name(%d)=", msg.msg_namelen);
652         printsock(tcp, (long)msg.msg_name, msg.msg_namelen);
653
654         tprintf(", msg_iov(%lu)=", (unsigned long)msg.msg_iovlen);
655         printiovec(tcp, msg.msg_iov, msg.msg_iovlen);
656
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)
663                 tprintf("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 */
668         tprintf("}");
669 }
670
671 #endif /* HAVE_SENDMSG */
672
673 int
674 sys_socket(tcp)
675 struct tcb *tcp;
676 {
677         if (entering(tcp)) {
678                 printxval(domains, tcp->u_arg[0], "PF_???");
679                 tprintf(", ");
680                 printxval(socktypes, tcp->u_arg[1], "SOCK_???");
681                 tprintf(", ");
682                 switch (tcp->u_arg[0]) {
683                 case PF_INET:
684                         printxval(protocols, tcp->u_arg[2], "IPPROTO_???");
685                         break;
686 #ifdef PF_IPX
687                 case PF_IPX:
688                         /* BTW: I don't believe this.. */
689                         tprintf("[");
690                         printxval(domains, tcp->u_arg[2], "PF_???");
691                         tprintf("]");
692                         break;
693 #endif /* PF_IPX */
694                 default:
695                         tprintf("%lu", tcp->u_arg[2]);
696                         break;
697                 }
698         }
699         return 0;
700 }
701
702 int
703 sys_bind(tcp)
704 struct tcb *tcp;
705 {
706         if (entering(tcp)) {
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]);
710         }
711         return 0;
712 }
713
714 int
715 sys_connect(tcp)
716 struct tcb *tcp;
717 {
718         return sys_bind(tcp);
719 }
720
721 int
722 sys_listen(tcp)
723 struct tcb *tcp;
724 {
725         if (entering(tcp)) {
726                 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
727         }
728         return 0;
729 }
730
731 int
732 sys_accept(tcp)
733 struct tcb *tcp;
734 {
735         if (entering(tcp)) {
736                 tprintf("%ld, ", tcp->u_arg[0]);
737         } else if (!tcp->u_arg[2])
738                 tprintf("%#lx, NULL", tcp->u_arg[1]);
739         else {
740                 if (tcp->u_arg[1] == 0 || syserror(tcp)) {
741                         tprintf("%#lx", tcp->u_arg[1]);
742                 } else {
743                         printsock(tcp, tcp->u_arg[1], tcp->u_arg[2]);
744                 }
745                 tprintf(", ");
746                 printnum(tcp, tcp->u_arg[2], "%lu");
747         }
748         return 0;
749 }
750
751 int
752 sys_send(tcp)
753 struct tcb *tcp;
754 {
755         if (entering(tcp)) {
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]);
759                 /* flags */
760                 if (printflags(msg_flags, tcp->u_arg[3]) == 0)
761                         tprintf("0");
762         }
763         return 0;
764 }
765
766 int
767 sys_sendto(tcp)
768 struct tcb *tcp;
769 {
770         if (entering(tcp)) {
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]);
774                 /* flags */
775                 if (printflags(msg_flags, tcp->u_arg[3]) == 0)
776                         tprintf("0");
777                 /* to address */
778                 tprintf(", ");
779                 printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]);
780                 /* to length */
781                 tprintf(", %lu", tcp->u_arg[5]);
782         }
783         return 0;
784 }
785
786 #ifdef HAVE_SENDMSG
787
788 int
789 sys_sendmsg(tcp)
790 struct tcb *tcp;
791 {
792         if (entering(tcp)) {
793                 tprintf("%ld, ", tcp->u_arg[0]);
794                 printmsghdr(tcp, tcp->u_arg[1]);
795                 /* flags */
796                 tprintf(", ");
797                 if (printflags(msg_flags, tcp->u_arg[2]) == 0)
798                         tprintf("0");
799         }
800         return 0;
801 }
802
803 #endif /* HAVE_SENDMSG */
804
805 int
806 sys_recv(tcp)
807 struct tcb *tcp;
808 {
809         if (entering(tcp)) {
810                 tprintf("%ld, ", tcp->u_arg[0]);
811         } else {
812                 if (syserror(tcp))
813                         tprintf("%#lx", tcp->u_arg[1]);
814                 else
815                         printstr(tcp, tcp->u_arg[1], tcp->u_rval);
816
817                 tprintf(", %lu, ", tcp->u_arg[2]);
818                 if (printflags(msg_flags, tcp->u_arg[3]) == 0)
819                         tprintf("0");
820         }
821         return 0;
822 }
823
824 int
825 sys_recvfrom(tcp)
826 struct tcb *tcp;
827 {
828         int fromlen;
829
830         if (entering(tcp)) {
831                 tprintf("%ld, ", tcp->u_arg[0]);
832         } else {
833                 if (syserror(tcp)) {
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]);
837                         return 0;
838                 }
839                 /* buf */
840                 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
841                 /* len */
842                 tprintf(", %lu, ", tcp->u_arg[2]);
843                 /* flags */
844                 if (printflags(msg_flags, tcp->u_arg[3]) == 0)
845                         tprintf("0");
846                 /* from address, len */
847                 if (!tcp->u_arg[4] || !tcp->u_arg[5]) {
848                         if (tcp->u_arg[4] == 0)
849                                 tprintf(", NULL");
850                         else
851                                 tprintf(", %#lx", tcp->u_arg[4]);
852                         if (tcp->u_arg[5] == 0)
853                                 tprintf(", NULL");
854                         else
855                                 tprintf(", %#lx", tcp->u_arg[5]);
856                         return 0;
857                 }
858                 if (umove(tcp, tcp->u_arg[5], &fromlen) < 0) {
859                         tprintf(", {...}, [?]");
860                         return 0;
861                 }
862                 tprintf(", ");
863                 printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]);
864                 /* from length */
865                 tprintf(", [%u]", fromlen);
866         }
867         return 0;
868 }
869
870 #ifdef HAVE_SENDMSG
871
872 int
873 sys_recvmsg(tcp)
874 struct tcb *tcp;
875 {
876         if (entering(tcp)) {
877                 tprintf("%ld, ", tcp->u_arg[0]);
878         } else {
879                 if (syserror(tcp) || !verbose(tcp))
880                         tprintf("%#lx", tcp->u_arg[1]);
881                 else
882                         printmsghdr(tcp, tcp->u_arg[1]);
883                 /* flags */
884                 tprintf(", ");
885                 if (printflags(msg_flags, tcp->u_arg[2]) == 0)
886                         tprintf("0");
887         }
888         return 0;
889 }
890
891 #endif /* HAVE_SENDMSG */
892
893 int
894 sys_shutdown(tcp)
895 struct tcb *tcp;
896 {
897         if (entering(tcp)) {
898                 tprintf("%ld, %ld", tcp->u_arg[0], tcp->u_arg[1]);
899                 switch (tcp->u_arg[1]) {
900                 case 0:
901                         tprintf("%s", " /* receive */");
902                         break;
903                 case 1:
904                         tprintf("%s", " /* send */");
905                         break;
906                 case 2:
907                         tprintf("%s", " /* send and receive */");
908                         break;
909                 }
910         }
911         return 0;
912 }
913
914 int
915 sys_getsockname(tcp)
916 struct tcb *tcp;
917 {
918         return sys_accept(tcp);
919 }
920
921 int
922 sys_getpeername(tcp)
923 struct tcb *tcp;
924 {
925         return sys_accept(tcp);
926 }
927
928 int
929 sys_pipe(tcp)
930 struct tcb *tcp;
931 {
932
933 #if defined(LINUX) && !defined(SPARC)
934         int fds[2];
935
936         if (exiting(tcp)) {
937                 if (syserror(tcp)) {
938                         tprintf("%#lx", tcp->u_arg[0]);
939                         return 0;
940                 }
941                 if (umoven(tcp, tcp->u_arg[0], sizeof fds, (char *) fds) < 0)
942                         tprintf("[...]");
943                 else
944                         tprintf("[%u, %u]", fds[0], fds[1]);
945         }
946 #elif defined(SPARC) || defined(SVR4)
947         if (exiting(tcp))
948                 tprintf("[%lu, %lu]", tcp->u_rval, getrval2(tcp));
949 #endif
950         return 0;
951 }
952
953 int
954 sys_socketpair(tcp)
955 struct tcb *tcp;
956 {
957 #ifdef LINUX
958         int fds[2];
959 #endif
960
961         if (entering(tcp)) {
962                 printxval(domains, tcp->u_arg[0], "PF_???");
963                 tprintf(", ");
964                 printxval(socktypes, tcp->u_arg[1], "SOCK_???");
965                 tprintf(", ");
966                 switch (tcp->u_arg[0]) {
967                 case PF_INET:
968                         printxval(protocols, tcp->u_arg[2], "IPPROTO_???");
969                         break;
970 #ifdef PF_IPX
971                 case PF_IPX:
972                         /* BTW: I don't believe this.. */
973                         tprintf("[");
974                         printxval(domains, tcp->u_arg[2], "PF_???");
975                         tprintf("]");
976                         break;
977 #endif /* PF_IPX */
978                 default:        
979                         tprintf("%lu", tcp->u_arg[2]);
980                         break;
981                 }
982         } else {
983                 if (syserror(tcp)) {
984                         tprintf(", %#lx", tcp->u_arg[3]);
985                         return 0;
986                 }
987 #ifdef LINUX
988                 if (umoven(tcp, tcp->u_arg[3], sizeof fds, (char *) fds) < 0)
989                         tprintf(", [...]");
990                 else
991                         tprintf(", [%u, %u]", fds[0], fds[1]);
992 #endif /* LINUX */
993 #ifdef SUNOS4
994                 tprintf(", [%lu, %lu]", tcp->u_rval, getrval2(tcp));
995 #endif /* SUNOS4 */
996 #ifdef SVR4
997                 tprintf(", [%lu, %lu]", tcp->u_rval, getrval2(tcp));
998 #endif /* SVR4 */
999         }
1000         return 0;
1001 }
1002
1003 int
1004 sys_getsockopt(tcp)
1005 struct tcb *tcp;
1006 {
1007         if (entering(tcp)) {
1008                 tprintf("%ld, ", tcp->u_arg[0]);
1009                 switch (tcp->u_arg[1]) {
1010                 case SOL_SOCKET:
1011                         tprintf("SOL_SOCKET, ");
1012                         printxval(sockoptions, tcp->u_arg[2], "SO_???");
1013                         tprintf(", ");
1014                         break;
1015 #ifdef SOL_IP
1016                 case SOL_IP:
1017                         tprintf("SOL_IP, ");
1018                         printxval(sockipoptions, tcp->u_arg[2], "IP_???");
1019                         tprintf(", ");
1020                         break;
1021 #endif
1022 #ifdef SOL_IPX
1023                 case SOL_IPX:
1024                         tprintf("SOL_IPX, ");
1025                         printxval(sockipxoptions, tcp->u_arg[2], "IPX_???");
1026                         tprintf(", ");
1027                         break;
1028 #endif
1029 #ifdef SOL_PACKET
1030                 case SOL_PACKET:
1031                         tprintf("SOL_PACKET, ");
1032                         printxval(sockpacketoptions, tcp->u_arg[2], "PACKET_???");
1033                         tprintf(", ");
1034                         break;
1035 #endif
1036 #ifdef SOL_TCP
1037                 case SOL_TCP:
1038                         tprintf("SOL_TCP, ");
1039                         printxval(socktcpoptions, tcp->u_arg[2], "TCP_???");
1040                         tprintf(", ");
1041                         break;
1042 #endif
1043
1044                 /* SOL_AX25 SOL_ROSE SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25
1045                  * etc. still need work */
1046                 default: 
1047                         /* XXX - should know socket family here */
1048                         printxval(protocols, tcp->u_arg[1], "IPPROTO_???");
1049                         tprintf(", %lu, ", tcp->u_arg[2]);
1050                         break;
1051                 }
1052         } else {
1053                 if (syserror(tcp)) {
1054                         tprintf("%#lx, %#lx",
1055                                 tcp->u_arg[3], tcp->u_arg[4]);
1056                         return 0;
1057                 }
1058                 printnum(tcp, tcp->u_arg[3], "%ld");
1059                 tprintf(", ");
1060                 printnum(tcp, tcp->u_arg[4], "%ld");
1061         }
1062         return 0;
1063 }
1064
1065 #if defined(ICMP_FILTER)
1066 static void printicmpfilter(tcp, addr)
1067 struct tcb *tcp;
1068 long addr;
1069 {
1070         struct icmp_filter      filter;
1071
1072         if (!addr) {
1073                 tprintf("NULL");
1074                 return;
1075         }
1076         if (syserror(tcp) || !verbose(tcp)) {
1077                 tprintf("%#lx", addr);
1078                 return;
1079         }
1080         if (umove(tcp, addr, &filter) < 0) {
1081                 tprintf("{...}");
1082                 return;
1083         }
1084
1085         tprintf("~(");
1086         if (printflags(icmpfilterflags, ~filter.data) == 0)
1087                 tprintf("0");
1088         tprintf(")");
1089 }
1090 #endif /* ICMP_FILTER */
1091
1092 int
1093 sys_setsockopt(tcp)
1094 struct tcb *tcp;
1095 {
1096         if (entering(tcp)) {
1097                 tprintf("%ld, ", tcp->u_arg[0]);
1098                 switch (tcp->u_arg[1]) {
1099                 case SOL_SOCKET:
1100                         tprintf("SOL_SOCKET, ");
1101                         printxval(sockoptions, tcp->u_arg[2], "SO_???");
1102                         tprintf(", ");
1103                         printnum(tcp, tcp->u_arg[3], "%ld");
1104                         tprintf(", %lu", tcp->u_arg[4]);
1105                         break;
1106 #ifdef SOL_IP
1107                 case SOL_IP:
1108                         tprintf("SOL_IP, ");
1109                         printxval(sockipoptions, tcp->u_arg[2], "IP_???");
1110                         tprintf(", ");
1111                         printnum(tcp, tcp->u_arg[3], "%ld");
1112                         tprintf(", %lu", tcp->u_arg[4]);
1113                         break;
1114 #endif
1115 #ifdef SOL_IPX
1116                 case SOL_IPX:
1117                         tprintf("SOL_IPX, ");
1118                         printxval(sockipxoptions, tcp->u_arg[2], "IPX_???");
1119                         tprintf(", ");
1120                         printnum(tcp, tcp->u_arg[3], "%ld");
1121                         tprintf(", %lu", tcp->u_arg[4]);
1122                         break;
1123 #endif
1124 #ifdef SOL_PACKET
1125                 case SOL_PACKET:
1126                         tprintf("SOL_PACKET, ");
1127                         printxval(sockpacketoptions, tcp->u_arg[2], "PACKET_???");
1128                         tprintf(", ");
1129                         /* TODO: decode packate_mreq for PACKET_*_MEMBERSHIP */
1130                         printnum(tcp, tcp->u_arg[3], "%ld");
1131                         tprintf(", %lu", tcp->u_arg[4]);
1132                         break;
1133 #endif
1134 #ifdef SOL_TCP
1135                 case SOL_TCP:
1136                         tprintf("SOL_TCP, ");
1137                         printxval(socktcpoptions, tcp->u_arg[2], "TCP_???");
1138                         tprintf(", ");
1139                         printnum(tcp, tcp->u_arg[3], "%ld");
1140                         tprintf(", %lu", tcp->u_arg[4]);
1141                         break;
1142 #endif
1143 #ifdef SOL_RAW
1144                 case SOL_RAW:
1145                         tprintf("SOL_RAW, ");
1146                         printxval(sockrawoptions, tcp->u_arg[2], "RAW_???");
1147                         tprintf(", ");
1148                         switch (tcp->u_arg[2]) {
1149 #if defined(ICMP_FILTER)
1150                                 case ICMP_FILTER:
1151                                         printicmpfilter(tcp, tcp->u_arg[3]);
1152                                         break;
1153 #endif
1154                                 default:
1155                                         printnum(tcp, tcp->u_arg[3], "%ld");
1156                                         break;
1157                         }
1158                         tprintf(", %lu", tcp->u_arg[4]);
1159                         break;
1160 #endif
1161
1162                 /* SOL_AX25 SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25 
1163                  * etc. still need work  */
1164                 default:
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]);
1170                         break;
1171                 }
1172         }
1173         return 0;
1174 }
1175
1176 #if UNIXWARE >= 7
1177
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" },
1185         { 0,            NULL            },
1186 };
1187
1188
1189 int
1190 netlib_call(tcp, func)
1191 struct tcb *tcp;
1192 int (*func) ();
1193 {
1194         if (entering(tcp)) {
1195                 int i;
1196                 printxval (sock_version, tcp->u_arg[0], "__NETLIB_???");
1197                 tprintf(", ");
1198                 --tcp->u_nargs;
1199                 for (i = 0; i < tcp->u_nargs; i++)
1200                         tcp->u_arg[i] = tcp->u_arg[i + 1];
1201                 return func (tcp);
1202                 
1203         }
1204
1205         return func (tcp);
1206 }
1207
1208 int
1209 sys_xsocket(tcp)
1210 struct tcb *tcp;
1211 {
1212         return netlib_call (tcp, sys_socket);
1213 }
1214
1215 int
1216 sys_xsocketpair(tcp)
1217 struct tcb *tcp;
1218 {
1219         return netlib_call (tcp, sys_socketpair);
1220 }
1221
1222 int
1223 sys_xbind(tcp)
1224 struct tcb *tcp;
1225 {
1226         return netlib_call (tcp, sys_bind);
1227 }
1228
1229 int
1230 sys_xconnect(tcp)
1231 struct tcb *tcp;
1232 {
1233         return netlib_call (tcp, sys_connect);
1234 }
1235
1236 int
1237 sys_xlisten(tcp)
1238 struct tcb *tcp;
1239 {
1240         return netlib_call (tcp, sys_listen);
1241 }
1242
1243 int
1244 sys_xaccept(tcp)
1245 struct tcb *tcp;
1246 {
1247         return netlib_call (tcp, sys_accept);
1248 }
1249
1250 int
1251 sys_xsendmsg(tcp)
1252 struct tcb *tcp;
1253 {
1254         return netlib_call (tcp, sys_sendmsg);
1255 }
1256
1257 int
1258 sys_xrecvmsg(tcp)
1259 struct tcb *tcp;
1260 {
1261         return netlib_call (tcp, sys_recvmsg);
1262 }
1263
1264 int
1265 sys_xgetsockaddr(tcp)
1266 struct tcb *tcp;
1267 {
1268         if (entering(tcp)) {
1269                 printxval (sock_version, tcp->u_arg[0], "__NETLIB_???");
1270                 tprintf(", ");
1271                 if (tcp->u_arg[1] == 0) {
1272                         tprintf ("LOCALNAME, ");
1273                 }
1274                 else if (tcp->u_arg[1] == 1) {
1275                         tprintf ("REMOTENAME, ");
1276                 }
1277                 else {
1278                         tprintf ("%ld, ", tcp->u_arg [1]);
1279                 }
1280                 tprintf ("%ld, ", tcp->u_arg [2]);
1281         } 
1282         else {
1283                 if (tcp->u_arg[3] == 0 || syserror(tcp)) {
1284                         tprintf("%#lx", tcp->u_arg[3]);
1285                 } else {
1286                         printsock(tcp, tcp->u_arg[3], tcp->u_arg[4]);
1287                 }
1288                 tprintf(", ");
1289                 printnum(tcp, tcp->u_arg[4], "%lu");
1290         }
1291
1292         return 0;
1293
1294 }
1295
1296 #if 0
1297
1298 int
1299 sys_xsetsockaddr(tcp)
1300 struct tcb *tcp;
1301 {
1302         return netlib_call (tcp, sys_setsockaddr);
1303 }
1304
1305 #endif
1306
1307 int
1308 sys_xgetsockopt(tcp)
1309 struct tcb *tcp;
1310 {
1311         return netlib_call (tcp, sys_getsockopt);
1312 }
1313
1314 int
1315 sys_xsetsockopt(tcp)
1316 struct tcb *tcp;
1317 {
1318         return netlib_call (tcp, sys_setsockopt);
1319 }
1320
1321 int
1322 sys_xshutdown(tcp)
1323 struct tcb *tcp;
1324 {
1325         return netlib_call (tcp, sys_shutdown);
1326 }
1327
1328 #endif