blob: b5ec383849f0df47a748e7d5c11b7484b5d490bf [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>
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00005 * Copyright (c) 1996-2000 Wichert Akkerman <wichert@cistron.nl>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00006 * 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>
Wichert Akkermanf1850652001-02-16 20:29:03 +000038
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
43#endif
44
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000045#include <netinet/in.h>
Wichert Akkerman8c7122c2001-02-16 19:59:55 +000046#ifdef HAVE_NETINET_TCP_H
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +000047#include <netinet/tcp.h>
48#endif
Wichert Akkerman8c7122c2001-02-16 19:59:55 +000049#ifdef HAVE_NETINET_UDP_H
50#include <netinet/udp.h>
51#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000052#include <arpa/inet.h>
Wichert Akkermanf1850652001-02-16 20:29:03 +000053#include <net/if.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000054#if defined(LINUX)
55#include <asm/types.h>
56#if defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC__ + __GLIBC_MINOR__ >= 3)
57# include <netipx/ipx.h>
58#else
59# include <linux/ipx.h>
60#endif
61#endif /* LINUX */
62
Wichert Akkermanf1850652001-02-16 20:29:03 +000063#if defined (__GLIBC__) && (((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1)) || defined(HAVE_SIN6_SCOPE_ID_LINUX))
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +000064#if defined(HAVE_LINUX_IN6_H)
Wichert Akkermanf1850652001-02-16 20:29:03 +000065#if defined(HAVE_SIN6_SCOPE_ID_LINUX)
66#undef in6_addr
67#undef ipv6_mreq
68#undef sockaddr_in6
69#define in6_addr in6_addr_kernel
70#define ipv6_mreq ipv6_mreq_kernel
71#define sockaddr_in6 sockaddr_in6_kernel
72#endif
Wichert Akkerman505e1761999-11-01 19:39:08 +000073#include <linux/in6.h>
Wichert Akkermanf1850652001-02-16 20:29:03 +000074#if defined(HAVE_SIN6_SCOPE_ID_LINUX)
75#undef in6_addr
76#undef ipv6_mreq
77#undef sockaddr_in6
78#define in6_addr in6_addr_libc
79#define ipv6_mreq ipv6_mreq_libc
80#define sockaddr_in6 sockaddr_in6_kernel
81#endif
Wichert Akkerman505e1761999-11-01 19:39:08 +000082#endif
Wichert Akkerman2f473da1999-11-01 19:53:31 +000083#endif
Wichert Akkerman505e1761999-11-01 19:39:08 +000084
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +000085#if defined(HAVE_SYS_UIO_H)
86#include <sys/uio.h>
87#endif
88
89#if defined(HAVE_LINUX_NETLINK_H)
90#include <linux/netlink.h>
91#endif
92
93#if defined(HAVE_LINUX_IF_PACKET_H)
94#include <linux/if_packet.h>
95#endif
96
Wichert Akkerman7987cdf2000-07-05 16:05:39 +000097#if defined(HAVE_LINUX_ICMP_H)
98#include <linux/icmp.h>
99#endif
100
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000101#ifndef PF_UNSPEC
102#define PF_UNSPEC AF_UNSPEC
103#endif
104
Wichert Akkerman16a03d22000-08-10 02:14:04 +0000105#if UNIXWARE >= 7
106#define HAVE_SENDMSG 1 /* HACK - *FIXME* */
107#endif
108
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000109#ifdef LINUX
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
117#endif
118
119static struct xlat domains[] = {
120 { PF_UNSPEC, "PF_UNSPEC" },
121 { PF_UNIX, "PF_UNIX" },
122 { PF_INET, "PF_INET" },
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000123#ifdef PF_NETLINK
124 { PF_NETLINK, "PF_NETLINK" },
125#endif
126#ifdef PF_PACKET
127 { PF_PACKET, "PF_PACKET" },
128#endif
129#ifdef PF_INET6
130 { PF_INET6, "PF_INET6" },
131#endif
132#ifdef PF_ATMSVC
133 { PF_ATMSVC, "PF_INET6" },
134#endif
135#ifdef PF_INET6
136 { PF_INET6, "PF_INET6" },
137#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000138#ifdef PF_LOCAL
139 { PF_LOCAL, "PS_LOCAL" },
140#endif
141#ifdef PF_ISO
142 { PF_ISO, "PF_ISO" },
143#endif
144#ifdef PF_AX25
145 { PF_AX25, "PF_AX25" },
146#endif
147#ifdef PF_IPX
148 { PF_IPX, "PF_IPX" },
149#endif
150#ifdef PF_APPLETALK
151 { PF_APPLETALK, "PF_APPLETALK" },
152#endif
153#ifdef PF_NETROM
154 { PF_NETROM, "PF_NETROM" },
155#endif
156#ifdef PF_BRIDGE
157 { PF_BRIDGE, "PF_BRIDGE" },
158#endif
159#ifdef PF_AAL5
160 { PF_AAL5, "PF_AAL5" },
161#endif
162#ifdef PF_X25
163 { PF_X25, "PF_X25" },
164#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000165#ifdef PF_ROSE
166 { PF_ROSE, "PF_ROSE" },
167#endif
168#ifdef PF_DECNET
169 { PF_DECNET, "PF_DECNET" },
170#endif
171#ifdef PF_NETBEUI
172 { PF_NETBEUI, "PF_NETBEUI" },
173#endif
174#ifdef PF_IMPLINK
175 { PF_IMPLINK, "PF_IMPLINK" },
176#endif
177 { 0, NULL },
178};
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000179static struct xlat addrfams[] = {
180 { AF_UNSPEC, "AF_UNSPEC" },
181 { AF_UNIX, "AF_UNIX" },
182 { AF_INET, "AF_INET" },
Wichert Akkermane4aafd41999-11-26 09:54:08 +0000183#ifdef AF_INET6
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000184 { AF_INET6, "AF_INET6" },
Wichert Akkermane4aafd41999-11-26 09:54:08 +0000185#endif
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000186 { AF_DECnet, "AF_DECnet" },
187#ifdef PF_ATMSVC
188 { AF_ATMSVC, "AF_ATMSVC" },
189#endif
Wichert Akkermane4aafd41999-11-26 09:54:08 +0000190#ifdef AF_PACKET
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000191 { AF_PACKET, "AF_PACKET" },
Wichert Akkermane4aafd41999-11-26 09:54:08 +0000192#endif
193#ifdef AF_NETLINK
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000194 { AF_NETLINK, "AF_NETLINK" },
Wichert Akkermane4aafd41999-11-26 09:54:08 +0000195#endif
196#ifdef AF_ISO
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000197 { AF_ISO, "AF_ISO" },
198#endif
Wichert Akkermane4aafd41999-11-26 09:54:08 +0000199#ifdef AF_IMPLINK
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000200 { AF_IMPLINK, "AF_IMPLINK" },
201#endif
202 { 0, NULL },
203};
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000204static struct xlat socktypes[] = {
205 { SOCK_STREAM, "SOCK_STREAM" },
206 { SOCK_DGRAM, "SOCK_DGRAM" },
207#ifdef SOCK_RAW
208 { SOCK_RAW, "SOCK_RAW" },
209#endif
210#ifdef SOCK_SEQPACKET
211 { SOCK_SEQPACKET,"SOCK_SEQPACKET"},
212#endif
213#ifdef SOCK_RDM
214 { SOCK_RDM, "SOCK_RDM" },
215#endif
216#ifdef SOCK_PACKET
217 { SOCK_PACKET, "SOCK_PACKET" },
218#endif
219 { 0, NULL },
220};
Wichert Akkermanefdecac2000-11-26 03:59:21 +0000221static struct xlat socketlayers[] = {
John Hughes1e4cb342001-03-06 09:25:46 +0000222#if defined(SOL_IP)
Wichert Akkermanefdecac2000-11-26 03:59:21 +0000223 { SOL_IP, "SOL_IP" },
John Hughes1e4cb342001-03-06 09:25:46 +0000224#endif
Wichert Akkermanefdecac2000-11-26 03:59:21 +0000225#if defined(SOL_ICMP)
226 { SOL_ICMP, "SOL_ICMP" },
227#endif
John Hughes1e4cb342001-03-06 09:25:46 +0000228#if defined(SOL_TCP)
Wichert Akkermanefdecac2000-11-26 03:59:21 +0000229 { SOL_TCP, "SOL_TCP" },
John Hughes1e4cb342001-03-06 09:25:46 +0000230#endif
231#if defined(SOL_UDP)
Wichert Akkermanefdecac2000-11-26 03:59:21 +0000232 { SOL_UDP, "SOL_UDP" },
John Hughes1e4cb342001-03-06 09:25:46 +0000233#endif
Wichert Akkermanefdecac2000-11-26 03:59:21 +0000234#if defined(SOL_IPV6)
235 { SOL_IPV6, "SOL_IPV6" },
236#endif
237#if defined(SOL_ICMPV6)
238 { SOL_ICMPV6, "SOL_ICMPV6" },
239#endif
240#if defined(SOL_RAW)
241 { SOL_RAW, "SOL_RAW" },
242#endif
243#if defined(SOL_IPX)
244 { SOL_IPX, "SOL_IPX" },
245#endif
246#if defined(SOL_IPX)
247 { SOL_IPX, "SOL_IPX" },
248#endif
249#if defined(SOL_AX25)
250 { SOL_AX25, "SOL_AX25" },
251#endif
252#if defined(SOL_ATALK)
253 { SOL_ATALK, "SOL_ATALK" },
254#endif
255#if defined(SOL_NETROM)
256 { SOL_NETROM, "SOL_NETROM" },
257#endif
258#if defined(SOL_ROSE)
259 { SOL_ROSE, "SOL_ROSE" },
260#endif
261#if defined(SOL_DECNET)
262 { SOL_DECNET, "SOL_DECNET" },
263#endif
264#if defined(SOL_X25)
265 { SOL_X25, "SOL_X25" },
266#endif
267#if defined(SOL_PACKET)
268 { SOL_PACKET, "SOL_PACKET" },
269#endif
270#if defined(SOL_ATM)
271 { SOL_ATM, "SOL_ATM" },
272#endif
273#if defined(SOL_AAL)
274 { SOL_AAL, "SOL_AAL" },
275#endif
276#if defined(SOL_IRDA)
277 { SOL_IRDA, "SOL_IRDA" },
278#endif
John Hughes61563572001-03-27 16:47:36 +0000279 { SOL_SOCKET, "SOL_SOCKET" }, /* Never used! */
Wichert Akkermanefdecac2000-11-26 03:59:21 +0000280};
John Hughes93f7fcc2002-05-22 15:46:49 +0000281/*** WARNING: DANGER WILL ROBINSON: NOTE "socketlayers" array above
282 falls into "protocols" array below!!!! This is intended!!! ***/
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000283static struct xlat protocols[] = {
284 { IPPROTO_IP, "IPPROTO_IP" },
285 { IPPROTO_ICMP, "IPPROTO_ICMP" },
286 { IPPROTO_TCP, "IPPROTO_TCP" },
287 { IPPROTO_UDP, "IPPROTO_UDP" },
288#ifdef IPPROTO_GGP
289 { IPPROTO_GGP, "IPPROTO_GGP" },
290#endif
291#ifdef IPPROTO_EGP
292 { IPPROTO_EGP, "IPPROTO_EGP" },
293#endif
294#ifdef IPPROTO_PUP
295 { IPPROTO_PUP, "IPPROTO_PUP" },
296#endif
297#ifdef IPPROTO_IDP
298 { IPPROTO_IDP, "IPPROTO_IDP" },
299#endif
300#ifdef IPPROTO_IPV6
301 { IPPROTO_IPV6, "IPPROTO_IPV6" },
302#endif
303#ifdef IPPROTO_ICMPV6
304 { IPPROTO_ICMPV6,"IPPROTO_ICMPV6"},
305#endif
306#ifdef IPPROTO_IGMP
307 { IPPROTO_IGMP, "IPPROTO_IGMP" },
308#endif
309#ifdef IPPROTO_HELLO
310 { IPPROTO_HELLO,"IPPROTO_HELLO" },
311#endif
312#ifdef IPPROTO_ND
313 { IPPROTO_ND, "IPPROTO_ND" },
314#endif
315#ifdef IPPROTO_RAW
316 { IPPROTO_RAW, "IPPROTO_RAW" },
317#endif
318#ifdef IPPROTO_MAX
319 { IPPROTO_MAX, "IPPROTO_MAX" },
320#endif
321#ifdef IPPROTO_IPIP
322 { IPPROTO_IPIP, "IPPROTO_IPIP" },
323#endif
324 { 0, NULL },
325};
326static struct xlat msg_flags[] = {
327 { MSG_OOB, "MSG_OOB" },
328#ifdef MSG_DONTROUTE
329 { MSG_DONTROUTE,"MSG_DONTROUTE" },
330#endif
331#ifdef MSG_PEEK
332 { MSG_PEEK, "MSG_PEEK" },
333#endif
334#ifdef MSG_CTRUNC
335 { MSG_CTRUNC, "MSG_CTRUNC" },
336#endif
337#ifdef MSG_PROXY
338 { MSG_PROXY, "MSG_PROXY" },
339#endif
340#ifdef MSG_EOR
341 { MSG_EOR, "MSG_EOR" },
342#endif
343#ifdef MSG_WAITALL
344 { MSG_WAITALL, "MSG_WAITALL" },
345#endif
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000346#ifdef MSG_TRUNC
347 { MSG_TRUNC, "MSG_TRUNC" },
348#endif
349#ifdef MSG_CTRUNC
350 { MSG_CTRUNC, "MSG_CTRUNC" },
351#endif
352#ifdef MSG_ERRQUEUE
353 { MSG_ERRQUEUE, "MSG_ERRQUEUE" },
354#endif
355#ifdef MSG_DONTWAIT
356 { MSG_DONTWAIT, "MSG_DONTWAIT" },
357#endif
358#ifdef MSG_CONFIRM
359 { MSG_CONFIRM, "MSG_CONFIRM" },
360#endif
361#ifdef MSG_PROBE
362 { MSG_PROBE, "MSG_PROBE" },
363#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000364 { 0, NULL },
365};
366
367static struct xlat sockoptions[] = {
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000368#ifdef SO_PEERCRED
369 { SO_PEERCRED, "SO_PEERCRED" },
370#endif
371#ifdef SO_PASSCRED
372 { SO_PASSCRED, "SO_PASSCRED" },
373#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000374#ifdef SO_DEBUG
375 { SO_DEBUG, "SO_DEBUG" },
376#endif
377#ifdef SO_REUSEADDR
378 { SO_REUSEADDR, "SO_REUSEADDR" },
379#endif
380#ifdef SO_KEEPALIVE
381 { SO_KEEPALIVE, "SO_KEEPALIVE" },
382#endif
383#ifdef SO_DONTROUTE
384 { SO_DONTROUTE, "SO_DONTROUTE" },
385#endif
386#ifdef SO_BROADCAST
387 { SO_BROADCAST, "SO_BROADCAST" },
388#endif
389#ifdef SO_LINGER
390 { SO_LINGER, "SO_LINGER" },
391#endif
392#ifdef SO_OOBINLINE
393 { SO_OOBINLINE, "SO_OOBINLINE" },
394#endif
395#ifdef SO_TYPE
396 { SO_TYPE, "SO_TYPE" },
397#endif
398#ifdef SO_ERROR
399 { SO_ERROR, "SO_ERROR" },
400#endif
401#ifdef SO_SNDBUF
402 { SO_SNDBUF, "SO_SNDBUF" },
403#endif
404#ifdef SO_RCVBUF
405 { SO_RCVBUF, "SO_RCVBUF" },
406#endif
407#ifdef SO_NO_CHECK
408 { SO_NO_CHECK, "SO_NO_CHECK" },
409#endif
410#ifdef SO_PRIORITY
411 { SO_PRIORITY, "SO_PRIORITY" },
412#endif
413#ifdef SO_ACCEPTCONN
414 { SO_ACCEPTCONN,"SO_ACCEPTCONN" },
415#endif
416#ifdef SO_USELOOPBACK
417 { SO_USELOOPBACK,"SO_USELOOPBACK"},
418#endif
419#ifdef SO_SNDLOWAT
420 { SO_SNDLOWAT, "SO_SNDLOWAT" },
421#endif
422#ifdef SO_RCVLOWAT
423 { SO_RCVLOWAT, "SO_RCVLOWAT" },
424#endif
425#ifdef SO_SNDTIMEO
426 { SO_SNDTIMEO, "SO_SNDTIMEO" },
427#endif
428#ifdef SO_RCVTIMEO
429 { SO_RCVTIMEO, "SO_RCVTIMEO" },
430#endif
431#ifdef SO_BSDCOMPAT
432 { SO_BSDCOMPAT, "SO_BSDCOMPAT" },
433#endif
434#ifdef SO_REUSEPORT
435 { SO_REUSEPORT, "SO_REUSEPORT" },
436#endif
John Hughes38ae88d2002-05-23 11:48:58 +0000437#ifdef SO_ORDREL
438 { SO_ORDREL, "SO_ORDREL" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000439#endif
John Hughes38ae88d2002-05-23 11:48:58 +0000440#ifdef SO_IMASOCKET
441 { SO_IMASOCKET, "SO_IMASOCKET" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000442#endif
John Hughes38ae88d2002-05-23 11:48:58 +0000443#ifdef SO_MGMT
444 { SO_MGMT, "SO_MGMT" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000445#endif
John Hughes38ae88d2002-05-23 11:48:58 +0000446#ifdef SO_LISTENING
447 { SO_LISTENING, "SO_LISTENING" },
448#endif
449#ifdef SO_RDWR
450 { SO_RDWR, "SO_RDWR" },
451#endif
452#ifdef SO_SEMA
453 { SO_SEMA, "SO_SEMA" },
454#endif
455#ifdef SO_PARALLELSVR
456 { SO_PARALLELSVR,"SO_PARALLELSVR"},
457#endif
458#ifdef SO_PROTOTYPE
459 { SO_PROTOTYPE, "SO_PROTOTYPE" },
460#endif
461#ifdef SO_ALLRAW
462 { SO_ALLRAW, "SO_ALLRAW" },
463#endif
464#ifdef SO_ICS
465 { SO_ICS, "SO_ICS" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000466#endif
467 { 0, NULL },
468};
469
John Hughes93f7fcc2002-05-22 15:46:49 +0000470#if !defined (SOL_IP) && defined (IPPROTO_IP)
471#define SOL_IP IPPROTO_IP
472#endif
473
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000474#ifdef SOL_IP
475static struct xlat sockipoptions[] = {
John Hughes93f7fcc2002-05-22 15:46:49 +0000476#ifdef IP_TOS
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000477 { IP_TOS, "IP_TOS" },
John Hughes93f7fcc2002-05-22 15:46:49 +0000478#endif
479#ifdef IP_TTL
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000480 { IP_TTL, "IP_TTL" },
John Hughes93f7fcc2002-05-22 15:46:49 +0000481#endif
482#ifdef IP_HDRINCL
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000483 { IP_HDRINCL, "IP_HDRINCL" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000484#endif
John Hughes93f7fcc2002-05-22 15:46:49 +0000485#ifdef IP_OPTIONS
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000486 { IP_OPTIONS, "IP_OPTIONS" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000487#endif
John Hughes93f7fcc2002-05-22 15:46:49 +0000488#ifdef IP_ROUTER_ALERT
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000489 { IP_ROUTER_ALERT, "IP_ROUTER_ALERT" },
John Hughes93f7fcc2002-05-22 15:46:49 +0000490#endif
491#ifdef IP_RECVOPTIONS
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000492 { IP_RECVOPTIONS, "IP_RECVOPTIONS" },
493#endif
John Hughes93f7fcc2002-05-22 15:46:49 +0000494#ifdef IP_RECVOPTS
495 { IP_RECVOPTS, "IP_RECVOPTS" },
496#endif
497#ifdef IP_RECVRETOPTS
498 { IP_RECVRETOPTS, "IP_RECVRETOPTS" },
499#endif
500#ifdef IP_RECVDSTADDR
501 { IP_RECVDSTADDR, "IP_RECVDSTADDR" },
502#endif
503#ifdef IP_RETOPTS
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000504 { IP_RETOPTS, "IP_RETOPTS" },
John Hughes93f7fcc2002-05-22 15:46:49 +0000505#endif
506#ifdef IP_PKTINFO
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000507 { IP_PKTINFO, "IP_PKTINFO" },
John Hughes93f7fcc2002-05-22 15:46:49 +0000508#endif
509#ifdef IP_PKTOPTIONS
510 { IP_PKTOPTIONS, "IP_PKTOPTIONS" },
511#endif
512#ifdef IP_MTU_DISCOVER
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000513 { IP_MTU_DISCOVER, "IP_MTU_DISCOVER" },
John Hughes93f7fcc2002-05-22 15:46:49 +0000514#endif
515#ifdef IP_RECVERR
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000516 { IP_RECVERR, "IP_RECVERR" },
John Hughes93f7fcc2002-05-22 15:46:49 +0000517#endif
518#ifdef IP_RECVTTL
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000519 { IP_RECVTTL, "IP_RECRECVTTL" },
John Hughes93f7fcc2002-05-22 15:46:49 +0000520#endif
521#ifdef IP_RECVTOS
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000522 { IP_RECVTOS, "IP_RECRECVTOS" },
John Hughes93f7fcc2002-05-22 15:46:49 +0000523#endif
524#ifdef IP_MTU
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000525 { IP_MTU, "IP_MTU" },
526#endif
John Hughes93f7fcc2002-05-22 15:46:49 +0000527#ifdef IP_MULTICAST_IF
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000528 { IP_MULTICAST_IF, "IP_MULTICAST_IF" },
John Hughes93f7fcc2002-05-22 15:46:49 +0000529#endif
530#ifdef IP_MULTICAST_TTL
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000531 { IP_MULTICAST_TTL, "IP_MULTICAST_TTL" },
John Hughes93f7fcc2002-05-22 15:46:49 +0000532#endif
533#ifdef IP_MULTICAST_LOOP
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000534 { IP_MULTICAST_LOOP, "IP_MULTICAST_LOOP" },
John Hughes93f7fcc2002-05-22 15:46:49 +0000535#endif
536#ifdef IP_ADD_MEMBERSHIP
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000537 { IP_ADD_MEMBERSHIP, "IP_ADD_MEMBERSHIP" },
John Hughes93f7fcc2002-05-22 15:46:49 +0000538#endif
539#ifdef IP_DROP_MEMBERSHIP
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000540 { IP_DROP_MEMBERSHIP, "IP_DROP_MEMBERSHIP" },
John Hughes93f7fcc2002-05-22 15:46:49 +0000541#endif
542#ifdef IP_BROADCAST_IF
543 { IP_BROADCAST_IF, "IP_BROADCAST_IF" },
544#endif
545#ifdef IP_RECVIFINDEX
546 { IP_RECVIFINDEX, "IP_RECVIFINDEX" },
547#endif
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000548 { 0, NULL },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000549};
550#endif /* SOL_IP */
551
552#ifdef SOL_IPX
553static struct xlat sockipxoptions[] = {
554 { IPX_TYPE, "IPX_TYPE" },
555 { 0, NULL },
556};
557#endif /* SOL_IPX */
558
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000559#ifdef SOL_RAW
560static struct xlat sockrawoptions[] = {
561#if defined(ICMP_FILTER)
562 { ICMP_FILTER, "ICMP_FILTER" },
563#endif
564 { 0, NULL },
565};
566#endif /* SOL_RAW */
567
568#ifdef SOL_PACKET
569static struct xlat sockpacketoptions[] = {
570 { PACKET_ADD_MEMBERSHIP, "PACKET_ADD_MEMBERSHIP" },
571 { PACKET_DROP_MEMBERSHIP, "PACKET_DROP_MEMBERSHIP"},
572#if defined(PACKET_RECV_OUTPUT)
573 { PACKET_RECV_OUTPUT, "PACKET_RECV_OUTPUT" },
574#endif
575#if defined(PACKET_RX_RING)
576 { PACKET_RX_RING, "PACKET_RX_RING" },
577#endif
578#if defined(PACKET_STATISTICS)
579 { PACKET_STATISTICS, "PACKET_STATISTICS" },
580#endif
581 { 0, NULL },
582};
583#endif /* SOL_PACKET */
584
John Hughes93f7fcc2002-05-22 15:46:49 +0000585#if !defined (SOL_TCP) && defined (IPPROTO_TCP)
586#define SOL_TCP IPPROTO_TCP
587#endif
588
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000589#ifdef SOL_TCP
590static struct xlat socktcpoptions[] = {
Wichert Akkerman8b8ff7c2001-12-27 22:27:30 +0000591 { TCP_NODELAY, "TCP_NODELAY" },
592 { TCP_MAXSEG, "TCP_MAXSEG" },
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000593#if defined(TCP_CORK)
Wichert Akkerman8b8ff7c2001-12-27 22:27:30 +0000594 { TCP_CORK, "TCP_CORK" },
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000595#endif
Wichert Akkerman8b8ff7c2001-12-27 22:27:30 +0000596#if defined(TCP_KEEPIDLE)
597 { TCP_KEEPIDLE, "TCP_KEEPIDLE" },
598#endif
599#if defined(TCP_KEEPINTVL)
600 { TCP_KEEPINTVL, "TCP_KEEPINTVL" },
601#endif
602#if defined(TCP_KEEPCNT)
603 { TCP_KEEPCNT, "TCP_KEEPCNT" },
604#endif
John Hughes38ae88d2002-05-23 11:48:58 +0000605#if defined(TCP_NKEEP)
606 { TCP_NKEEP, "TCP_NKEEP" },
607#endif
Wichert Akkerman8b8ff7c2001-12-27 22:27:30 +0000608#if defined(TCP_SYNCNT)
609 { TCP_SYNCNT, "TCP_SYNCNT" },
610#endif
611#if defined(TCP_LINGER2)
612 { TCP_LINGER2, "TCP_LINGER2" },
613#endif
614#if defined(TCP_DEFER_ACCEPT)
615 { TCP_DEFER_ACCEPT, "TCP_DEFER_ACCEPT" },
616#endif
617#if defined(TCP_WINDOW_CLAMP)
618 { TCP_WINDOW_CLAMP, "TCP_WINDOW_CLAMP" },
619#endif
620#if defined(TCP_INFO)
621 { TCP_INFO, "TCP_INFO" },
622#endif
623#if defined(TCP_QUICKACK)
624 { TCP_QUICKACK, "TCP_QUICKACK" },
625#endif
626 { 0, NULL },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000627};
628#endif /* SOL_TCP */
629
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000630#ifdef SOL_RAW
631static struct xlat icmpfilterflags[] = {
632#if defined(ICMP_ECHOREPLY)
633 { (1<<ICMP_ECHOREPLY), "ICMP_ECHOREPLY" },
634#endif
635#if defined(ICMP_DEST_UNREACH)
636 { (1<<ICMP_DEST_UNREACH), "ICMP_DEST_UNREACH" },
637#endif
638#if defined(ICMP_SOURCE_QUENCH)
639 { (1<<ICMP_SOURCE_QUENCH), "ICMP_SOURCE_QUENCH" },
640#endif
641#if defined(ICMP_REDIRECT)
642 { (1<<ICMP_REDIRECT), "ICMP_REDIRECT" },
643#endif
644#if defined(ICMP_ECHO)
645 { (1<<ICMP_ECHO), "ICMP_ECHO" },
646#endif
647#if defined(ICMP_TIME_EXCEEDED)
648 { (1<<ICMP_TIME_EXCEEDED), "ICMP_TIME_EXCEEDED" },
649#endif
650#if defined(ICMP_PARAMETERPROB)
651 { (1<<ICMP_PARAMETERPROB), "ICMP_PARAMETERPROB" },
652#endif
653#if defined(ICMP_TIMESTAMP)
654 { (1<<ICMP_TIMESTAMP), "ICMP_TIMESTAMP" },
655#endif
656#if defined(ICMP_TIMESTAMPREPLY)
657 { (1<<ICMP_TIMESTAMPREPLY), "ICMP_TIMESTAMPREPLY" },
658#endif
659#if defined(ICMP_INFO_REQUEST)
660 { (1<<ICMP_INFO_REQUEST), "ICMP_INFO_REQUEST" },
661#endif
662#if defined(ICMP_INFO_REPLY)
663 { (1<<ICMP_INFO_REPLY), "ICMP_INFO_REPLY" },
664#endif
665#if defined(ICMP_ADDRESS)
666 { (1<<ICMP_ADDRESS), "ICMP_ADDRESS" },
667#endif
668#if defined(ICMP_ADDRESSREPLY)
669 { (1<<ICMP_ADDRESSREPLY), "ICMP_ADDRESSREPLY" },
670#endif
671 { 0, NULL },
672};
673#endif /* SOL_RAW */
674
Wichert Akkermanb0c598f2002-04-01 12:48:06 +0000675#if defined(AF_PACKET) /* from e.g. linux/if_packet.h */
676static struct xlat af_packet_types[] = {
677#if defined(PACKET_HOST)
678 { PACKET_HOST, "PACKET_HOST" },
679#endif
680#if defined(PACKET_BROADCAST)
681 { PACKET_BROADCAST, "PACKET_BROADCAST" },
682#endif
683#if defined(PACKET_MULTICAST)
684 { PACKET_MULTICAST, "PACKET_MULTICAST" },
685#endif
686#if defined(PACKET_OTHERHOST)
687 { PACKET_OTHERHOST, "PACKET_OTHERHOST" },
688#endif
689#if defined(PACKET_OUTGOING)
690 { PACKET_OUTGOING, "PACKET_OUTGOING" },
691#endif
692#if defined(PACKET_LOOPBACK)
693 { PACKET_LOOPBACK, "PACKET_LOOPBACK" },
694#endif
695#if defined(PACKET_FASTROUTE)
696 { PACKET_FASTROUTE, "PACKET_FASTROUTE" },
697#endif
698 { 0, NULL },
699};
700#endif /* defined(AF_PACKET) */
701
Wichert Akkerman16a03d22000-08-10 02:14:04 +0000702
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000703void
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000704printsock(tcp, addr, addrlen)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000705struct tcb *tcp;
706long addr;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000707int addrlen;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000708{
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000709 union {
710 char pad[128];
711 struct sockaddr sa;
712 struct sockaddr_in sin;
713 struct sockaddr_un sau;
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000714#ifdef HAVE_INET_NTOP
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000715 struct sockaddr_in6 sa6;
716#endif
717#if defined(LINUX) && defined(AF_IPX)
718 struct sockaddr_ipx sipx;
719#endif
720#ifdef AF_PACKET
721 struct sockaddr_ll ll;
722#endif
723#ifdef AF_NETLINK
724 struct sockaddr_nl nl;
725#endif
726 } addrbuf;
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000727 char string_addr[100];
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000728
729 if (addr == 0) {
730 tprintf("NULL");
731 return;
732 }
733 if (!verbose(tcp)) {
734 tprintf("%#lx", addr);
735 return;
736 }
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000737 if ((addrlen<2) || (addrlen>sizeof(addrbuf)))
738 addrlen=sizeof(addrbuf);
739
740 if (umoven(tcp, addr, addrlen, (char*)&addrbuf) < 0) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000741 tprintf("{...}");
742 return;
743 }
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000744
John Hughes1fcb1d62001-09-18 15:56:53 +0000745 tprintf("{sa_family=");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000746 printxval(addrfams, addrbuf.sa.sa_family, "AF_???");
747 tprintf(", ");
748
749 switch (addrbuf.sa.sa_family) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000750 case AF_UNIX:
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000751 if (addrlen==2) {
752 tprintf("<nil>");
753 } else if (addrbuf.sau.sun_path[0]) {
Wichert Akkermanfa306182001-02-21 16:42:26 +0000754 tprintf("path=\"%-.*s\"", addrlen-2, addrbuf.sau.sun_path);
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000755 } else {
Wichert Akkermanfa306182001-02-21 16:42:26 +0000756 tprintf("path=@%-.*s", addrlen-3, addrbuf.sau.sun_path+1);
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000757 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000758 break;
759 case AF_INET:
John Hughes1fcb1d62001-09-18 15:56:53 +0000760 tprintf("sin_port=htons(%u), sin_addr=inet_addr(\"%s\")",
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000761 ntohs(addrbuf.sin.sin_port), inet_ntoa(addrbuf.sin.sin_addr));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000762 break;
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000763#ifdef HAVE_INET_NTOP
764 case AF_INET6:
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000765 inet_ntop(AF_INET6, &addrbuf.sa6.sin6_addr, string_addr, sizeof(string_addr));
Wichert Akkermanf1850652001-02-16 20:29:03 +0000766 tprintf("sin6_port=htons(%u), inet_pton(AF_INET6, \"%s\", &sin6_addr), sin6_flowinfo=%u",
767 ntohs(addrbuf.sa6.sin6_port), string_addr,
768 addrbuf.sa6.sin6_flowinfo);
Roland McGrath6d2b3492002-12-30 00:51:30 +0000769#ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID
Wichert Akkermanf1850652001-02-16 20:29:03 +0000770 {
771#if defined(HAVE_IF_INDEXTONAME) && defined(IN6_IS_ADDR_LINKLOCAL) && defined(IN6_IS_ADDR_MC_LINKLOCAL)
772 int numericscope = 0;
773 if (IN6_IS_ADDR_LINKLOCAL (&addrbuf.sa6.sin6_addr)
774 || IN6_IS_ADDR_MC_LINKLOCAL (&addrbuf.sa6.sin6_addr)) {
775 char scopebuf[IFNAMSIZ + 1];
Roland McGrath6d2b3492002-12-30 00:51:30 +0000776
Wichert Akkermanf1850652001-02-16 20:29:03 +0000777 if (if_indextoname (addrbuf.sa6.sin6_scope_id, scopebuf) == NULL)
778 numericscope++;
779 else
780 tprintf(", sin6_scope_id=if_nametoindex(\"%s\")", scopebuf);
781 } else
782 numericscope++;
Roland McGrath6d2b3492002-12-30 00:51:30 +0000783
Wichert Akkermanf1850652001-02-16 20:29:03 +0000784 if (numericscope)
785#endif
786 tprintf(", sin6_scope_id=%u", addrbuf.sa6.sin6_scope_id);
787 }
788#endif
789 break;
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000790#endif
Wichert Akkermandbb440e1999-05-11 15:06:44 +0000791#if defined(AF_IPX) && defined(linux)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000792 case AF_IPX:
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000793 {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000794 int i;
John Hughes1fcb1d62001-09-18 15:56:53 +0000795 tprintf("sipx_port=htons(%u), ",
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000796 ntohs(addrbuf.sipx.sipx_port));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000797 /* Yes, I know, this does not look too
798 * strace-ish, but otherwise the IPX
799 * addresses just look monstrous...
800 * Anyways, feel free if you don't like
Roland McGrath6d2b3492002-12-30 00:51:30 +0000801 * this way.. :)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000802 */
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000803 tprintf("%08lx:", (unsigned long)ntohl(addrbuf.sipx.sipx_network));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000804 for (i = 0; i<IPX_NODE_LEN; i++)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000805 tprintf("%02x", addrbuf.sipx.sipx_node[i]);
806 tprintf("/[%02x]", addrbuf.sipx.sipx_type);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000807 }
808 break;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000809#endif /* AF_IPX && linux */
810#ifdef AF_PACKET
811 case AF_PACKET:
812 {
813 int i;
Wichert Akkermanb0c598f2002-04-01 12:48:06 +0000814 tprintf("proto=%#04x, if%d, pkttype=",
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000815 ntohs(addrbuf.ll.sll_protocol),
Wichert Akkermanb0c598f2002-04-01 12:48:06 +0000816 addrbuf.ll.sll_ifindex);
817 printxval(af_packet_types, addrbuf.ll.sll_pkttype, "?");
818 tprintf(", addr(%d)={%d, ",
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000819 addrbuf.ll.sll_halen,
820 addrbuf.ll.sll_hatype);
Roland McGrath6d2b3492002-12-30 00:51:30 +0000821 for (i=0; i<addrbuf.ll.sll_halen; i++)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000822 tprintf("%02x", addrbuf.ll.sll_addr[i]);
823 }
824 break;
825
826#endif /* AF_APACKET */
827#ifdef AF_NETLINLK
828 case AF_NETLINK:
829 tprintf("pid=%d, groups=%08x", addrbuf.nl.nl_pid, addrbuf.nl.nl_groups);
830 break;
831#endif /* AF_NETLINK */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000832 /* AF_AX25 AF_APPLETALK AF_NETROM AF_BRIDGE AF_AAL5
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000833 AF_X25 AF_ROSE etc. still need to be done */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000834
835 default:
John Hughes1fcb1d62001-09-18 15:56:53 +0000836 tprintf("sa_data=");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000837 printstr(tcp, (long) &((struct sockaddr *) addr)->sa_data,
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000838 sizeof addrbuf.sa.sa_data);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000839 break;
840 }
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000841 tprintf("}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000842}
843
844#if HAVE_SENDMSG
845
846static void
847printmsghdr(tcp, addr)
848struct tcb *tcp;
849long addr;
850{
851 struct msghdr msg;
852
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000853 if (umove(tcp, addr, &msg) < 0) {
854 tprintf("%#lx", addr);
855 return;
856 }
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000857 tprintf("{msg_name(%d)=", msg.msg_namelen);
858 printsock(tcp, (long)msg.msg_name, msg.msg_namelen);
859
860 tprintf(", msg_iov(%lu)=", (unsigned long)msg.msg_iovlen);
John Hughes1d08dcf2001-07-10 13:48:44 +0000861 tprint_iov(tcp, msg.msg_iovlen, (long) msg.msg_iov);
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000862
Roland McGrath6d2b3492002-12-30 00:51:30 +0000863#ifdef HAVE_STRUCT_MSGHDR_MSG_CONTROL
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000864 tprintf(", msg_controllen=%lu", (unsigned long)msg.msg_controllen);
Roland McGrath6d2b3492002-12-30 00:51:30 +0000865 if (msg.msg_controllen)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000866 tprintf(", msg_control=%#lx, ", (unsigned long) msg.msg_control);
867 tprintf(", msg_flags=");
868 if (printflags(msg_flags, msg.msg_flags)==0)
869 tprintf("0");
Roland McGrath6d2b3492002-12-30 00:51:30 +0000870#else /* !HAVE_STRUCT_MSGHDR_MSG_CONTROL */
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000871 tprintf("msg_accrights=%#lx, msg_accrightslen=%u",
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000872 (unsigned long) msg.msg_accrights, msg.msg_accrightslen);
Roland McGrath6d2b3492002-12-30 00:51:30 +0000873#endif /* !HAVE_STRUCT_MSGHDR_MSG_CONTROL */
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000874 tprintf("}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000875}
876
877#endif /* HAVE_SENDMSG */
878
879int
880sys_socket(tcp)
881struct tcb *tcp;
882{
883 if (entering(tcp)) {
884 printxval(domains, tcp->u_arg[0], "PF_???");
885 tprintf(", ");
886 printxval(socktypes, tcp->u_arg[1], "SOCK_???");
887 tprintf(", ");
888 switch (tcp->u_arg[0]) {
889 case PF_INET:
Roland McGrath8758e542003-06-23 23:39:59 +0000890#ifdef PF_INET6
891 case PF_INET6:
892#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000893 printxval(protocols, tcp->u_arg[2], "IPPROTO_???");
894 break;
895#ifdef PF_IPX
896 case PF_IPX:
897 /* BTW: I don't believe this.. */
898 tprintf("[");
899 printxval(domains, tcp->u_arg[2], "PF_???");
900 tprintf("]");
901 break;
902#endif /* PF_IPX */
903 default:
904 tprintf("%lu", tcp->u_arg[2]);
905 break;
906 }
907 }
908 return 0;
909}
910
911int
John Hughesbdf48f52001-03-06 15:08:09 +0000912sys_so_socket(tcp)
913struct tcb *tcp;
914{
915 if (entering(tcp)) {
916 /* not sure really what these args are... but this
917 * is how truss prints it
918 */
919 tprintf("%ld, %ld, %ld, ",
920 tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]);
921 printpath(tcp, tcp->u_arg[3]);
922 tprintf(", %ld", tcp->u_arg[4]);
923 }
924 return 0;
925}
926
927int
928sys_so_socketpair(tcp)
929struct tcb *tcp;
930{
931 if (entering(tcp)) {
932 /* not sure what this arg is */
933 tprintf("0x%lx", tcp->u_arg[0]);
934 }
935 return 0;
936}
937
938int
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000939sys_bind(tcp)
940struct tcb *tcp;
941{
942 if (entering(tcp)) {
943 tprintf("%ld, ", tcp->u_arg[0]);
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000944 printsock(tcp, tcp->u_arg[1], tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000945 tprintf(", %lu", tcp->u_arg[2]);
946 }
947 return 0;
948}
949
950int
951sys_connect(tcp)
952struct tcb *tcp;
953{
954 return sys_bind(tcp);
955}
956
957int
958sys_listen(tcp)
959struct tcb *tcp;
960{
961 if (entering(tcp)) {
962 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
963 }
964 return 0;
965}
966
967int
968sys_accept(tcp)
969struct tcb *tcp;
970{
971 if (entering(tcp)) {
972 tprintf("%ld, ", tcp->u_arg[0]);
973 } else if (!tcp->u_arg[2])
974 tprintf("%#lx, NULL", tcp->u_arg[1]);
975 else {
976 if (tcp->u_arg[1] == 0 || syserror(tcp)) {
977 tprintf("%#lx", tcp->u_arg[1]);
978 } else {
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000979 printsock(tcp, tcp->u_arg[1], tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000980 }
981 tprintf(", ");
982 printnum(tcp, tcp->u_arg[2], "%lu");
983 }
984 return 0;
985}
986
987int
988sys_send(tcp)
989struct tcb *tcp;
990{
991 if (entering(tcp)) {
992 tprintf("%ld, ", tcp->u_arg[0]);
993 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
994 tprintf(", %lu, ", tcp->u_arg[2]);
995 /* flags */
996 if (printflags(msg_flags, tcp->u_arg[3]) == 0)
997 tprintf("0");
998 }
999 return 0;
1000}
1001
1002int
1003sys_sendto(tcp)
1004struct tcb *tcp;
1005{
1006 if (entering(tcp)) {
1007 tprintf("%ld, ", tcp->u_arg[0]);
1008 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
1009 tprintf(", %lu, ", tcp->u_arg[2]);
1010 /* flags */
1011 if (printflags(msg_flags, tcp->u_arg[3]) == 0)
1012 tprintf("0");
1013 /* to address */
1014 tprintf(", ");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001015 printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001016 /* to length */
1017 tprintf(", %lu", tcp->u_arg[5]);
1018 }
1019 return 0;
1020}
1021
1022#ifdef HAVE_SENDMSG
1023
1024int
1025sys_sendmsg(tcp)
1026struct tcb *tcp;
1027{
1028 if (entering(tcp)) {
1029 tprintf("%ld, ", tcp->u_arg[0]);
1030 printmsghdr(tcp, tcp->u_arg[1]);
1031 /* flags */
1032 tprintf(", ");
1033 if (printflags(msg_flags, tcp->u_arg[2]) == 0)
1034 tprintf("0");
1035 }
1036 return 0;
1037}
1038
1039#endif /* HAVE_SENDMSG */
1040
1041int
1042sys_recv(tcp)
1043struct tcb *tcp;
1044{
1045 if (entering(tcp)) {
1046 tprintf("%ld, ", tcp->u_arg[0]);
1047 } else {
1048 if (syserror(tcp))
1049 tprintf("%#lx", tcp->u_arg[1]);
1050 else
1051 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
1052
1053 tprintf(", %lu, ", tcp->u_arg[2]);
1054 if (printflags(msg_flags, tcp->u_arg[3]) == 0)
1055 tprintf("0");
1056 }
1057 return 0;
1058}
1059
1060int
1061sys_recvfrom(tcp)
1062struct tcb *tcp;
1063{
1064 int fromlen;
1065
1066 if (entering(tcp)) {
1067 tprintf("%ld, ", tcp->u_arg[0]);
1068 } else {
1069 if (syserror(tcp)) {
1070 tprintf("%#lx, %lu, %lu, %#lx, %#lx",
1071 tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3],
1072 tcp->u_arg[4], tcp->u_arg[5]);
1073 return 0;
1074 }
1075 /* buf */
1076 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
1077 /* len */
1078 tprintf(", %lu, ", tcp->u_arg[2]);
1079 /* flags */
1080 if (printflags(msg_flags, tcp->u_arg[3]) == 0)
1081 tprintf("0");
1082 /* from address, len */
1083 if (!tcp->u_arg[4] || !tcp->u_arg[5]) {
1084 if (tcp->u_arg[4] == 0)
1085 tprintf(", NULL");
1086 else
1087 tprintf(", %#lx", tcp->u_arg[4]);
1088 if (tcp->u_arg[5] == 0)
1089 tprintf(", NULL");
1090 else
1091 tprintf(", %#lx", tcp->u_arg[5]);
1092 return 0;
1093 }
1094 if (umove(tcp, tcp->u_arg[5], &fromlen) < 0) {
1095 tprintf(", {...}, [?]");
1096 return 0;
1097 }
1098 tprintf(", ");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001099 printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001100 /* from length */
1101 tprintf(", [%u]", fromlen);
1102 }
1103 return 0;
1104}
1105
1106#ifdef HAVE_SENDMSG
1107
1108int
1109sys_recvmsg(tcp)
1110struct tcb *tcp;
1111{
1112 if (entering(tcp)) {
1113 tprintf("%ld, ", tcp->u_arg[0]);
1114 } else {
1115 if (syserror(tcp) || !verbose(tcp))
1116 tprintf("%#lx", tcp->u_arg[1]);
1117 else
1118 printmsghdr(tcp, tcp->u_arg[1]);
1119 /* flags */
1120 tprintf(", ");
1121 if (printflags(msg_flags, tcp->u_arg[2]) == 0)
1122 tprintf("0");
1123 }
1124 return 0;
1125}
1126
1127#endif /* HAVE_SENDMSG */
1128
1129int
1130sys_shutdown(tcp)
1131struct tcb *tcp;
1132{
1133 if (entering(tcp)) {
1134 tprintf("%ld, %ld", tcp->u_arg[0], tcp->u_arg[1]);
1135 switch (tcp->u_arg[1]) {
1136 case 0:
1137 tprintf("%s", " /* receive */");
1138 break;
1139 case 1:
1140 tprintf("%s", " /* send */");
1141 break;
1142 case 2:
1143 tprintf("%s", " /* send and receive */");
1144 break;
1145 }
1146 }
1147 return 0;
1148}
1149
1150int
1151sys_getsockname(tcp)
1152struct tcb *tcp;
1153{
1154 return sys_accept(tcp);
1155}
1156
1157int
1158sys_getpeername(tcp)
1159struct tcb *tcp;
1160{
1161 return sys_accept(tcp);
1162}
1163
1164int
1165sys_pipe(tcp)
1166struct tcb *tcp;
1167{
1168
Roland McGrath6b1d43e2003-03-31 01:05:01 +00001169#if defined(LINUX) && !defined(SPARC) && !defined(SH)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001170 int fds[2];
1171
1172 if (exiting(tcp)) {
1173 if (syserror(tcp)) {
1174 tprintf("%#lx", tcp->u_arg[0]);
1175 return 0;
1176 }
1177 if (umoven(tcp, tcp->u_arg[0], sizeof fds, (char *) fds) < 0)
1178 tprintf("[...]");
1179 else
1180 tprintf("[%u, %u]", fds[0], fds[1]);
1181 }
Roland McGrath6b1d43e2003-03-31 01:05:01 +00001182#elif defined(SPARC) || defined(SH) || defined(SVR4) || defined(FREEBSD)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001183 if (exiting(tcp))
1184 tprintf("[%lu, %lu]", tcp->u_rval, getrval2(tcp));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001185#endif
1186 return 0;
1187}
1188
1189int
1190sys_socketpair(tcp)
1191struct tcb *tcp;
1192{
1193#ifdef LINUX
1194 int fds[2];
1195#endif
1196
1197 if (entering(tcp)) {
1198 printxval(domains, tcp->u_arg[0], "PF_???");
1199 tprintf(", ");
1200 printxval(socktypes, tcp->u_arg[1], "SOCK_???");
1201 tprintf(", ");
1202 switch (tcp->u_arg[0]) {
1203 case PF_INET:
1204 printxval(protocols, tcp->u_arg[2], "IPPROTO_???");
1205 break;
1206#ifdef PF_IPX
1207 case PF_IPX:
1208 /* BTW: I don't believe this.. */
1209 tprintf("[");
1210 printxval(domains, tcp->u_arg[2], "PF_???");
1211 tprintf("]");
1212 break;
1213#endif /* PF_IPX */
Roland McGrath6d2b3492002-12-30 00:51:30 +00001214 default:
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001215 tprintf("%lu", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001216 break;
1217 }
1218 } else {
1219 if (syserror(tcp)) {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001220 tprintf(", %#lx", tcp->u_arg[3]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001221 return 0;
1222 }
1223#ifdef LINUX
1224 if (umoven(tcp, tcp->u_arg[3], sizeof fds, (char *) fds) < 0)
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001225 tprintf(", [...]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001226 else
1227 tprintf(", [%u, %u]", fds[0], fds[1]);
1228#endif /* LINUX */
Wichert Akkerman2e4ffe52000-09-03 23:57:48 +00001229#if defined(SUNOS4) || defined(SVR4) || defined(FREEBSD)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001230 tprintf(", [%lu, %lu]", tcp->u_rval, getrval2(tcp));
Wichert Akkerman2e4ffe52000-09-03 23:57:48 +00001231#endif /* SUNOS4 || SVR4 || FREEBSD */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001232 }
1233 return 0;
1234}
1235
1236int
1237sys_getsockopt(tcp)
1238struct tcb *tcp;
1239{
1240 if (entering(tcp)) {
1241 tprintf("%ld, ", tcp->u_arg[0]);
John Hughes93f7fcc2002-05-22 15:46:49 +00001242 printxval(socketlayers, tcp->u_arg[1], "SOL_???");
1243 tprintf (", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001244 switch (tcp->u_arg[1]) {
1245 case SOL_SOCKET:
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001246 printxval(sockoptions, tcp->u_arg[2], "SO_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001247 break;
1248#ifdef SOL_IP
1249 case SOL_IP:
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001250 printxval(sockipoptions, tcp->u_arg[2], "IP_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001251 break;
1252#endif
1253#ifdef SOL_IPX
1254 case SOL_IPX:
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001255 printxval(sockipxoptions, tcp->u_arg[2], "IPX_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001256 break;
1257#endif
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001258#ifdef SOL_PACKET
1259 case SOL_PACKET:
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001260 printxval(sockpacketoptions, tcp->u_arg[2], "PACKET_???");
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001261 break;
1262#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001263#ifdef SOL_TCP
1264 case SOL_TCP:
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001265 printxval(socktcpoptions, tcp->u_arg[2], "TCP_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001266 break;
1267#endif
1268
1269 /* SOL_AX25 SOL_ROSE SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25
1270 * etc. still need work */
Roland McGrath6d2b3492002-12-30 00:51:30 +00001271 default:
John Hughes93f7fcc2002-05-22 15:46:49 +00001272 tprintf("%lu", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001273 break;
1274 }
1275 } else {
John Hughes93f7fcc2002-05-22 15:46:49 +00001276 long len;
1277 if (syserror(tcp) || umove (tcp, tcp->u_arg[4], &len) < 0) {
1278 tprintf(", %#lx, %#lx",
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001279 tcp->u_arg[3], tcp->u_arg[4]);
1280 return 0;
1281 }
John Hughes93f7fcc2002-05-22 15:46:49 +00001282
1283 switch (tcp->u_arg[1]) {
1284 case SOL_SOCKET:
1285 switch (tcp->u_arg[2]) {
1286#ifdef SO_LINGER
1287 case SO_LINGER:
1288 if (len == sizeof (struct linger)) {
1289 struct linger linger;
1290 if (umove (tcp,
1291 tcp->u_arg[3],
1292 &linger) < 0)
1293 break;
1294 tprintf(", {onoff=%d, linger=%d}, "
1295 "[%ld]",
1296 linger.l_onoff,
1297 linger.l_linger,
1298 len);
1299 return 0;
1300 }
1301 break;
1302#endif
1303 }
1304 break;
1305 }
1306
1307 tprintf (", ");
1308 if (len == sizeof (int)) {
1309 printnum(tcp, tcp->u_arg[3], "%ld");
1310 }
1311 else {
1312 printstr (tcp, tcp->u_arg[3], len);
1313 }
1314 tprintf(", [%ld]", len);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001315 }
1316 return 0;
1317}
1318
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001319#if defined(ICMP_FILTER)
1320static void printicmpfilter(tcp, addr)
1321struct tcb *tcp;
1322long addr;
1323{
1324 struct icmp_filter filter;
1325
1326 if (!addr) {
1327 tprintf("NULL");
1328 return;
1329 }
1330 if (syserror(tcp) || !verbose(tcp)) {
1331 tprintf("%#lx", addr);
1332 return;
1333 }
1334 if (umove(tcp, addr, &filter) < 0) {
1335 tprintf("{...}");
1336 return;
1337 }
1338
1339 tprintf("~(");
1340 if (printflags(icmpfilterflags, ~filter.data) == 0)
1341 tprintf("0");
1342 tprintf(")");
1343}
1344#endif /* ICMP_FILTER */
1345
John Hughes38ae88d2002-05-23 11:48:58 +00001346static int
1347printsockopt (tcp, level, name, addr, len)
1348struct tcb *tcp;
1349int level;
1350int name;
1351long addr;
1352int len;
1353{
1354 printxval(socketlayers, level, "SOL_??");
1355 tprintf (", ");
1356 switch (level) {
1357 case SOL_SOCKET:
1358 printxval(sockoptions, name, "SO_???");
1359 switch (name) {
1360#if defined(SO_LINGER)
1361 case SO_LINGER:
1362 if (len == sizeof (struct linger)) {
1363 struct linger linger;
1364 if (umove (tcp, addr, &linger) < 0)
1365 break;
1366 tprintf(", {onoff=%d, linger=%d}",
1367 linger.l_onoff,
1368 linger.l_linger);
1369 return 0;
1370 }
1371 break;
1372#endif
1373 }
1374 break;
1375#ifdef SOL_IP
1376 case SOL_IP:
1377 printxval(sockipoptions, name, "IP_???");
1378 break;
1379#endif
1380#ifdef SOL_IPX
1381 case SOL_IPX:
1382 printxval(sockipxoptions, name, "IPX_???");
1383 break;
1384#endif
1385#ifdef SOL_PACKET
1386 case SOL_PACKET:
1387 printxval(sockpacketoptions, name, "PACKET_???");
1388 /* TODO: decode packate_mreq for PACKET_*_MEMBERSHIP */
1389 break;
1390#endif
1391#ifdef SOL_TCP
1392 case SOL_TCP:
1393 printxval(socktcpoptions, name, "TCP_???");
1394 break;
1395#endif
1396#ifdef SOL_RAW
1397 case SOL_RAW:
1398 printxval(sockrawoptions, name, "RAW_???");
1399 switch (name) {
1400#if defined(ICMP_FILTER)
1401 case ICMP_FILTER:
1402 tprintf(", ");
1403 printicmpfilter(tcp, addr);
1404 return 0;
1405#endif
1406 }
1407 break;
1408#endif
1409
Roland McGrath6d2b3492002-12-30 00:51:30 +00001410 /* SOL_AX25 SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25
John Hughes38ae88d2002-05-23 11:48:58 +00001411 * etc. still need work */
1412
1413 default:
1414 tprintf("%u", name);
1415 }
1416
1417 /* default arg printing */
1418
1419 tprintf (", ");
Roland McGrath6d2b3492002-12-30 00:51:30 +00001420
John Hughes38ae88d2002-05-23 11:48:58 +00001421 if (len == sizeof (int)) {
1422 printnum(tcp, addr, "%ld");
1423 }
1424 else {
1425 printstr (tcp, addr, len);
1426 }
1427 return 0;
1428}
1429
1430
Roland McGrathc3ca0d82003-01-14 07:53:38 +00001431#ifdef HAVE_STRUCT_OPTHDR
John Hughes38ae88d2002-05-23 11:48:58 +00001432
1433void
1434print_sock_optmgmt (tcp, addr, len)
1435struct tcb *tcp;
1436long addr;
1437int len;
1438{
1439 int c = 0;
1440 struct opthdr hdr;
1441
John Hughes2c4e3a82002-05-24 10:19:44 +00001442 while (len >= (int) sizeof hdr) {
John Hughes38ae88d2002-05-23 11:48:58 +00001443 if (umove(tcp, addr, &hdr) < 0) break;
1444 if (c++) {
1445 tprintf (", ");
1446 }
1447 else if (len > hdr.len + sizeof hdr) {
1448 tprintf ("[");
1449 }
1450 tprintf ("{");
1451 addr += sizeof hdr;
1452 len -= sizeof hdr;
1453 printsockopt (tcp, hdr.level, hdr.name, addr, hdr.len);
John Hughes2c4e3a82002-05-24 10:19:44 +00001454 if (hdr.len > 0) {
1455 addr += hdr.len;
1456 len -= hdr.len;
1457 }
John Hughes38ae88d2002-05-23 11:48:58 +00001458 tprintf ("}");
1459 }
1460 if (len > 0) {
1461 if (c++) tprintf (", ");
1462 printstr (tcp, addr, len);
1463 }
1464 if (c > 1) tprintf ("]");
1465}
1466
1467#endif
1468
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001469int
1470sys_setsockopt(tcp)
1471struct tcb *tcp;
1472{
1473 if (entering(tcp)) {
1474 tprintf("%ld, ", tcp->u_arg[0]);
John Hughes38ae88d2002-05-23 11:48:58 +00001475 printsockopt (tcp, tcp->u_arg[1], tcp->u_arg[2],
1476 tcp->u_arg[3], tcp->u_arg[4]);
John Hughes93f7fcc2002-05-22 15:46:49 +00001477 tprintf(", %lu", tcp->u_arg[4]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001478 }
1479 return 0;
1480}
Wichert Akkerman16a03d22000-08-10 02:14:04 +00001481
1482#if UNIXWARE >= 7
1483
1484static struct xlat sock_version[] = {
1485 { __NETLIB_UW211_SVR4, "UW211_SVR4" },
1486 { __NETLIB_UW211_XPG4, "UW211_XPG4" },
1487 { __NETLIB_GEMINI_SVR4, "GEMINI_SVR4" },
1488 { __NETLIB_GEMINI_XPG4, "GEMINI_XPG4" },
1489 { __NETLIB_FP1_SVR4, "FP1_SVR4" },
1490 { __NETLIB_FP1_XPG4, "FP1_XPG4" },
1491 { 0, NULL },
1492};
1493
1494
1495int
1496netlib_call(tcp, func)
1497struct tcb *tcp;
1498int (*func) ();
1499{
1500 if (entering(tcp)) {
1501 int i;
1502 printxval (sock_version, tcp->u_arg[0], "__NETLIB_???");
1503 tprintf(", ");
1504 --tcp->u_nargs;
1505 for (i = 0; i < tcp->u_nargs; i++)
1506 tcp->u_arg[i] = tcp->u_arg[i + 1];
1507 return func (tcp);
Roland McGrath6d2b3492002-12-30 00:51:30 +00001508
Wichert Akkerman16a03d22000-08-10 02:14:04 +00001509 }
1510
1511 return func (tcp);
1512}
1513
1514int
1515sys_xsocket(tcp)
1516struct tcb *tcp;
1517{
1518 return netlib_call (tcp, sys_socket);
1519}
1520
1521int
1522sys_xsocketpair(tcp)
1523struct tcb *tcp;
1524{
1525 return netlib_call (tcp, sys_socketpair);
1526}
1527
1528int
1529sys_xbind(tcp)
1530struct tcb *tcp;
1531{
1532 return netlib_call (tcp, sys_bind);
1533}
1534
1535int
1536sys_xconnect(tcp)
1537struct tcb *tcp;
1538{
1539 return netlib_call (tcp, sys_connect);
1540}
1541
1542int
1543sys_xlisten(tcp)
1544struct tcb *tcp;
1545{
1546 return netlib_call (tcp, sys_listen);
1547}
1548
1549int
1550sys_xaccept(tcp)
1551struct tcb *tcp;
1552{
1553 return netlib_call (tcp, sys_accept);
1554}
1555
1556int
1557sys_xsendmsg(tcp)
1558struct tcb *tcp;
1559{
1560 return netlib_call (tcp, sys_sendmsg);
1561}
1562
1563int
1564sys_xrecvmsg(tcp)
1565struct tcb *tcp;
1566{
1567 return netlib_call (tcp, sys_recvmsg);
1568}
1569
1570int
1571sys_xgetsockaddr(tcp)
1572struct tcb *tcp;
1573{
1574 if (entering(tcp)) {
1575 printxval (sock_version, tcp->u_arg[0], "__NETLIB_???");
1576 tprintf(", ");
1577 if (tcp->u_arg[1] == 0) {
1578 tprintf ("LOCALNAME, ");
1579 }
1580 else if (tcp->u_arg[1] == 1) {
1581 tprintf ("REMOTENAME, ");
1582 }
1583 else {
1584 tprintf ("%ld, ", tcp->u_arg [1]);
1585 }
1586 tprintf ("%ld, ", tcp->u_arg [2]);
Roland McGrath6d2b3492002-12-30 00:51:30 +00001587 }
Wichert Akkerman16a03d22000-08-10 02:14:04 +00001588 else {
1589 if (tcp->u_arg[3] == 0 || syserror(tcp)) {
1590 tprintf("%#lx", tcp->u_arg[3]);
1591 } else {
1592 printsock(tcp, tcp->u_arg[3], tcp->u_arg[4]);
1593 }
1594 tprintf(", ");
1595 printnum(tcp, tcp->u_arg[4], "%lu");
1596 }
1597
1598 return 0;
1599
1600}
1601
1602#if 0
1603
1604int
1605sys_xsetsockaddr(tcp)
1606struct tcb *tcp;
1607{
1608 return netlib_call (tcp, sys_setsockaddr);
1609}
1610
1611#endif
1612
1613int
1614sys_xgetsockopt(tcp)
1615struct tcb *tcp;
1616{
1617 return netlib_call (tcp, sys_getsockopt);
1618}
1619
1620int
1621sys_xsetsockopt(tcp)
1622struct tcb *tcp;
1623{
1624 return netlib_call (tcp, sys_setsockopt);
1625}
1626
1627int
1628sys_xshutdown(tcp)
1629struct tcb *tcp;
1630{
1631 return netlib_call (tcp, sys_shutdown);
1632}
1633
1634#endif