blob: fc5bb9ee69a3c974b8345f36270b944d343cae3d [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
437#ifdef SO_RCVLOWAT
438 { SO_RCVLOWAT, "SO_RCVLOWAT" },
439#endif
440#ifdef SO_SNDLOWAT
441 { SO_SNDLOWAT, "SO_SNDLOWAT" },
442#endif
443#ifdef SO_RCVTIMEO
444 { SO_RCVTIMEO, "SO_RCVTIMEO" },
445#endif
446#ifdef SO_SNDTIMEO
447 { SO_SNDTIMEO, "SO_SNDTIMEO" },
448#endif
449 { 0, NULL },
450};
451
John Hughes93f7fcc2002-05-22 15:46:49 +0000452#if !defined (SOL_IP) && defined (IPPROTO_IP)
453#define SOL_IP IPPROTO_IP
454#endif
455
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000456#ifdef SOL_IP
457static struct xlat sockipoptions[] = {
John Hughes93f7fcc2002-05-22 15:46:49 +0000458#ifdef IP_TOS
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000459 { IP_TOS, "IP_TOS" },
John Hughes93f7fcc2002-05-22 15:46:49 +0000460#endif
461#ifdef IP_TTL
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000462 { IP_TTL, "IP_TTL" },
John Hughes93f7fcc2002-05-22 15:46:49 +0000463#endif
464#ifdef IP_HDRINCL
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000465 { IP_HDRINCL, "IP_HDRINCL" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000466#endif
John Hughes93f7fcc2002-05-22 15:46:49 +0000467#ifdef IP_OPTIONS
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000468 { IP_OPTIONS, "IP_OPTIONS" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000469#endif
John Hughes93f7fcc2002-05-22 15:46:49 +0000470#ifdef IP_ROUTER_ALERT
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000471 { IP_ROUTER_ALERT, "IP_ROUTER_ALERT" },
John Hughes93f7fcc2002-05-22 15:46:49 +0000472#endif
473#ifdef IP_RECVOPTIONS
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000474 { IP_RECVOPTIONS, "IP_RECVOPTIONS" },
475#endif
John Hughes93f7fcc2002-05-22 15:46:49 +0000476#ifdef IP_RECVOPTS
477 { IP_RECVOPTS, "IP_RECVOPTS" },
478#endif
479#ifdef IP_RECVRETOPTS
480 { IP_RECVRETOPTS, "IP_RECVRETOPTS" },
481#endif
482#ifdef IP_RECVDSTADDR
483 { IP_RECVDSTADDR, "IP_RECVDSTADDR" },
484#endif
485#ifdef IP_RETOPTS
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000486 { IP_RETOPTS, "IP_RETOPTS" },
John Hughes93f7fcc2002-05-22 15:46:49 +0000487#endif
488#ifdef IP_PKTINFO
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000489 { IP_PKTINFO, "IP_PKTINFO" },
John Hughes93f7fcc2002-05-22 15:46:49 +0000490#endif
491#ifdef IP_PKTOPTIONS
492 { IP_PKTOPTIONS, "IP_PKTOPTIONS" },
493#endif
494#ifdef IP_MTU_DISCOVER
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000495 { IP_MTU_DISCOVER, "IP_MTU_DISCOVER" },
John Hughes93f7fcc2002-05-22 15:46:49 +0000496#endif
497#ifdef IP_RECVERR
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000498 { IP_RECVERR, "IP_RECVERR" },
John Hughes93f7fcc2002-05-22 15:46:49 +0000499#endif
500#ifdef IP_RECVTTL
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000501 { IP_RECVTTL, "IP_RECRECVTTL" },
John Hughes93f7fcc2002-05-22 15:46:49 +0000502#endif
503#ifdef IP_RECVTOS
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000504 { IP_RECVTOS, "IP_RECRECVTOS" },
John Hughes93f7fcc2002-05-22 15:46:49 +0000505#endif
506#ifdef IP_MTU
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000507 { IP_MTU, "IP_MTU" },
508#endif
John Hughes93f7fcc2002-05-22 15:46:49 +0000509#ifdef IP_MULTICAST_IF
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000510 { IP_MULTICAST_IF, "IP_MULTICAST_IF" },
John Hughes93f7fcc2002-05-22 15:46:49 +0000511#endif
512#ifdef IP_MULTICAST_TTL
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000513 { IP_MULTICAST_TTL, "IP_MULTICAST_TTL" },
John Hughes93f7fcc2002-05-22 15:46:49 +0000514#endif
515#ifdef IP_MULTICAST_LOOP
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000516 { IP_MULTICAST_LOOP, "IP_MULTICAST_LOOP" },
John Hughes93f7fcc2002-05-22 15:46:49 +0000517#endif
518#ifdef IP_ADD_MEMBERSHIP
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000519 { IP_ADD_MEMBERSHIP, "IP_ADD_MEMBERSHIP" },
John Hughes93f7fcc2002-05-22 15:46:49 +0000520#endif
521#ifdef IP_DROP_MEMBERSHIP
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000522 { IP_DROP_MEMBERSHIP, "IP_DROP_MEMBERSHIP" },
John Hughes93f7fcc2002-05-22 15:46:49 +0000523#endif
524#ifdef IP_BROADCAST_IF
525 { IP_BROADCAST_IF, "IP_BROADCAST_IF" },
526#endif
527#ifdef IP_RECVIFINDEX
528 { IP_RECVIFINDEX, "IP_RECVIFINDEX" },
529#endif
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000530 { 0, NULL },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000531};
532#endif /* SOL_IP */
533
534#ifdef SOL_IPX
535static struct xlat sockipxoptions[] = {
536 { IPX_TYPE, "IPX_TYPE" },
537 { 0, NULL },
538};
539#endif /* SOL_IPX */
540
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000541#ifdef SOL_RAW
542static struct xlat sockrawoptions[] = {
543#if defined(ICMP_FILTER)
544 { ICMP_FILTER, "ICMP_FILTER" },
545#endif
546 { 0, NULL },
547};
548#endif /* SOL_RAW */
549
550#ifdef SOL_PACKET
551static struct xlat sockpacketoptions[] = {
552 { PACKET_ADD_MEMBERSHIP, "PACKET_ADD_MEMBERSHIP" },
553 { PACKET_DROP_MEMBERSHIP, "PACKET_DROP_MEMBERSHIP"},
554#if defined(PACKET_RECV_OUTPUT)
555 { PACKET_RECV_OUTPUT, "PACKET_RECV_OUTPUT" },
556#endif
557#if defined(PACKET_RX_RING)
558 { PACKET_RX_RING, "PACKET_RX_RING" },
559#endif
560#if defined(PACKET_STATISTICS)
561 { PACKET_STATISTICS, "PACKET_STATISTICS" },
562#endif
563 { 0, NULL },
564};
565#endif /* SOL_PACKET */
566
John Hughes93f7fcc2002-05-22 15:46:49 +0000567#if !defined (SOL_TCP) && defined (IPPROTO_TCP)
568#define SOL_TCP IPPROTO_TCP
569#endif
570
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000571#ifdef SOL_TCP
572static struct xlat socktcpoptions[] = {
Wichert Akkerman8b8ff7c2001-12-27 22:27:30 +0000573 { TCP_NODELAY, "TCP_NODELAY" },
574 { TCP_MAXSEG, "TCP_MAXSEG" },
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000575#if defined(TCP_CORK)
Wichert Akkerman8b8ff7c2001-12-27 22:27:30 +0000576 { TCP_CORK, "TCP_CORK" },
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000577#endif
Wichert Akkerman8b8ff7c2001-12-27 22:27:30 +0000578#if defined(TCP_KEEPIDLE)
579 { TCP_KEEPIDLE, "TCP_KEEPIDLE" },
580#endif
581#if defined(TCP_KEEPINTVL)
582 { TCP_KEEPINTVL, "TCP_KEEPINTVL" },
583#endif
584#if defined(TCP_KEEPCNT)
585 { TCP_KEEPCNT, "TCP_KEEPCNT" },
586#endif
587#if defined(TCP_SYNCNT)
588 { TCP_SYNCNT, "TCP_SYNCNT" },
589#endif
590#if defined(TCP_LINGER2)
591 { TCP_LINGER2, "TCP_LINGER2" },
592#endif
593#if defined(TCP_DEFER_ACCEPT)
594 { TCP_DEFER_ACCEPT, "TCP_DEFER_ACCEPT" },
595#endif
596#if defined(TCP_WINDOW_CLAMP)
597 { TCP_WINDOW_CLAMP, "TCP_WINDOW_CLAMP" },
598#endif
599#if defined(TCP_INFO)
600 { TCP_INFO, "TCP_INFO" },
601#endif
602#if defined(TCP_QUICKACK)
603 { TCP_QUICKACK, "TCP_QUICKACK" },
604#endif
605 { 0, NULL },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000606};
607#endif /* SOL_TCP */
608
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000609#ifdef SOL_RAW
610static struct xlat icmpfilterflags[] = {
611#if defined(ICMP_ECHOREPLY)
612 { (1<<ICMP_ECHOREPLY), "ICMP_ECHOREPLY" },
613#endif
614#if defined(ICMP_DEST_UNREACH)
615 { (1<<ICMP_DEST_UNREACH), "ICMP_DEST_UNREACH" },
616#endif
617#if defined(ICMP_SOURCE_QUENCH)
618 { (1<<ICMP_SOURCE_QUENCH), "ICMP_SOURCE_QUENCH" },
619#endif
620#if defined(ICMP_REDIRECT)
621 { (1<<ICMP_REDIRECT), "ICMP_REDIRECT" },
622#endif
623#if defined(ICMP_ECHO)
624 { (1<<ICMP_ECHO), "ICMP_ECHO" },
625#endif
626#if defined(ICMP_TIME_EXCEEDED)
627 { (1<<ICMP_TIME_EXCEEDED), "ICMP_TIME_EXCEEDED" },
628#endif
629#if defined(ICMP_PARAMETERPROB)
630 { (1<<ICMP_PARAMETERPROB), "ICMP_PARAMETERPROB" },
631#endif
632#if defined(ICMP_TIMESTAMP)
633 { (1<<ICMP_TIMESTAMP), "ICMP_TIMESTAMP" },
634#endif
635#if defined(ICMP_TIMESTAMPREPLY)
636 { (1<<ICMP_TIMESTAMPREPLY), "ICMP_TIMESTAMPREPLY" },
637#endif
638#if defined(ICMP_INFO_REQUEST)
639 { (1<<ICMP_INFO_REQUEST), "ICMP_INFO_REQUEST" },
640#endif
641#if defined(ICMP_INFO_REPLY)
642 { (1<<ICMP_INFO_REPLY), "ICMP_INFO_REPLY" },
643#endif
644#if defined(ICMP_ADDRESS)
645 { (1<<ICMP_ADDRESS), "ICMP_ADDRESS" },
646#endif
647#if defined(ICMP_ADDRESSREPLY)
648 { (1<<ICMP_ADDRESSREPLY), "ICMP_ADDRESSREPLY" },
649#endif
650 { 0, NULL },
651};
652#endif /* SOL_RAW */
653
Wichert Akkermanb0c598f2002-04-01 12:48:06 +0000654#if defined(AF_PACKET) /* from e.g. linux/if_packet.h */
655static struct xlat af_packet_types[] = {
656#if defined(PACKET_HOST)
657 { PACKET_HOST, "PACKET_HOST" },
658#endif
659#if defined(PACKET_BROADCAST)
660 { PACKET_BROADCAST, "PACKET_BROADCAST" },
661#endif
662#if defined(PACKET_MULTICAST)
663 { PACKET_MULTICAST, "PACKET_MULTICAST" },
664#endif
665#if defined(PACKET_OTHERHOST)
666 { PACKET_OTHERHOST, "PACKET_OTHERHOST" },
667#endif
668#if defined(PACKET_OUTGOING)
669 { PACKET_OUTGOING, "PACKET_OUTGOING" },
670#endif
671#if defined(PACKET_LOOPBACK)
672 { PACKET_LOOPBACK, "PACKET_LOOPBACK" },
673#endif
674#if defined(PACKET_FASTROUTE)
675 { PACKET_FASTROUTE, "PACKET_FASTROUTE" },
676#endif
677 { 0, NULL },
678};
679#endif /* defined(AF_PACKET) */
680
Wichert Akkerman16a03d22000-08-10 02:14:04 +0000681
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000682void
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000683printsock(tcp, addr, addrlen)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000684struct tcb *tcp;
685long addr;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000686int addrlen;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000687{
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000688 union {
689 char pad[128];
690 struct sockaddr sa;
691 struct sockaddr_in sin;
692 struct sockaddr_un sau;
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000693#ifdef HAVE_INET_NTOP
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000694 struct sockaddr_in6 sa6;
695#endif
696#if defined(LINUX) && defined(AF_IPX)
697 struct sockaddr_ipx sipx;
698#endif
699#ifdef AF_PACKET
700 struct sockaddr_ll ll;
701#endif
702#ifdef AF_NETLINK
703 struct sockaddr_nl nl;
704#endif
705 } addrbuf;
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000706 char string_addr[100];
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000707
708 if (addr == 0) {
709 tprintf("NULL");
710 return;
711 }
712 if (!verbose(tcp)) {
713 tprintf("%#lx", addr);
714 return;
715 }
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000716 if ((addrlen<2) || (addrlen>sizeof(addrbuf)))
717 addrlen=sizeof(addrbuf);
718
719 if (umoven(tcp, addr, addrlen, (char*)&addrbuf) < 0) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000720 tprintf("{...}");
721 return;
722 }
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000723
John Hughes1fcb1d62001-09-18 15:56:53 +0000724 tprintf("{sa_family=");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000725 printxval(addrfams, addrbuf.sa.sa_family, "AF_???");
726 tprintf(", ");
727
728 switch (addrbuf.sa.sa_family) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000729 case AF_UNIX:
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000730 if (addrlen==2) {
731 tprintf("<nil>");
732 } else if (addrbuf.sau.sun_path[0]) {
Wichert Akkermanfa306182001-02-21 16:42:26 +0000733 tprintf("path=\"%-.*s\"", addrlen-2, addrbuf.sau.sun_path);
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000734 } else {
Wichert Akkermanfa306182001-02-21 16:42:26 +0000735 tprintf("path=@%-.*s", addrlen-3, addrbuf.sau.sun_path+1);
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000736 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000737 break;
738 case AF_INET:
John Hughes1fcb1d62001-09-18 15:56:53 +0000739 tprintf("sin_port=htons(%u), sin_addr=inet_addr(\"%s\")",
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000740 ntohs(addrbuf.sin.sin_port), inet_ntoa(addrbuf.sin.sin_addr));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000741 break;
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000742#ifdef HAVE_INET_NTOP
743 case AF_INET6:
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000744 inet_ntop(AF_INET6, &addrbuf.sa6.sin6_addr, string_addr, sizeof(string_addr));
Wichert Akkermanf1850652001-02-16 20:29:03 +0000745 tprintf("sin6_port=htons(%u), inet_pton(AF_INET6, \"%s\", &sin6_addr), sin6_flowinfo=%u",
746 ntohs(addrbuf.sa6.sin6_port), string_addr,
747 addrbuf.sa6.sin6_flowinfo);
748#ifdef HAVE_SIN6_SCOPE_ID
749 {
750#if defined(HAVE_IF_INDEXTONAME) && defined(IN6_IS_ADDR_LINKLOCAL) && defined(IN6_IS_ADDR_MC_LINKLOCAL)
751 int numericscope = 0;
752 if (IN6_IS_ADDR_LINKLOCAL (&addrbuf.sa6.sin6_addr)
753 || IN6_IS_ADDR_MC_LINKLOCAL (&addrbuf.sa6.sin6_addr)) {
754 char scopebuf[IFNAMSIZ + 1];
755
756 if (if_indextoname (addrbuf.sa6.sin6_scope_id, scopebuf) == NULL)
757 numericscope++;
758 else
759 tprintf(", sin6_scope_id=if_nametoindex(\"%s\")", scopebuf);
760 } else
761 numericscope++;
762
763 if (numericscope)
764#endif
765 tprintf(", sin6_scope_id=%u", addrbuf.sa6.sin6_scope_id);
766 }
767#endif
768 break;
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000769#endif
Wichert Akkermandbb440e1999-05-11 15:06:44 +0000770#if defined(AF_IPX) && defined(linux)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000771 case AF_IPX:
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000772 {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000773 int i;
John Hughes1fcb1d62001-09-18 15:56:53 +0000774 tprintf("sipx_port=htons(%u), ",
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000775 ntohs(addrbuf.sipx.sipx_port));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000776 /* Yes, I know, this does not look too
777 * strace-ish, but otherwise the IPX
778 * addresses just look monstrous...
779 * Anyways, feel free if you don't like
780 * this way.. :)
781 */
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000782 tprintf("%08lx:", (unsigned long)ntohl(addrbuf.sipx.sipx_network));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000783 for (i = 0; i<IPX_NODE_LEN; i++)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000784 tprintf("%02x", addrbuf.sipx.sipx_node[i]);
785 tprintf("/[%02x]", addrbuf.sipx.sipx_type);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000786 }
787 break;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000788#endif /* AF_IPX && linux */
789#ifdef AF_PACKET
790 case AF_PACKET:
791 {
792 int i;
Wichert Akkermanb0c598f2002-04-01 12:48:06 +0000793 tprintf("proto=%#04x, if%d, pkttype=",
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000794 ntohs(addrbuf.ll.sll_protocol),
Wichert Akkermanb0c598f2002-04-01 12:48:06 +0000795 addrbuf.ll.sll_ifindex);
796 printxval(af_packet_types, addrbuf.ll.sll_pkttype, "?");
797 tprintf(", addr(%d)={%d, ",
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000798 addrbuf.ll.sll_halen,
799 addrbuf.ll.sll_hatype);
Wichert Akkermanb0c598f2002-04-01 12:48:06 +0000800 for (i=0; i<addrbuf.ll.sll_halen; i++)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000801 tprintf("%02x", addrbuf.ll.sll_addr[i]);
802 }
803 break;
804
805#endif /* AF_APACKET */
806#ifdef AF_NETLINLK
807 case AF_NETLINK:
808 tprintf("pid=%d, groups=%08x", addrbuf.nl.nl_pid, addrbuf.nl.nl_groups);
809 break;
810#endif /* AF_NETLINK */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000811 /* AF_AX25 AF_APPLETALK AF_NETROM AF_BRIDGE AF_AAL5
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000812 AF_X25 AF_ROSE etc. still need to be done */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000813
814 default:
John Hughes1fcb1d62001-09-18 15:56:53 +0000815 tprintf("sa_data=");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000816 printstr(tcp, (long) &((struct sockaddr *) addr)->sa_data,
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000817 sizeof addrbuf.sa.sa_data);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000818 break;
819 }
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000820 tprintf("}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000821}
822
823#if HAVE_SENDMSG
824
825static void
826printmsghdr(tcp, addr)
827struct tcb *tcp;
828long addr;
829{
830 struct msghdr msg;
831
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000832 if (umove(tcp, addr, &msg) < 0) {
833 tprintf("%#lx", addr);
834 return;
835 }
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000836 tprintf("{msg_name(%d)=", msg.msg_namelen);
837 printsock(tcp, (long)msg.msg_name, msg.msg_namelen);
838
839 tprintf(", msg_iov(%lu)=", (unsigned long)msg.msg_iovlen);
John Hughes1d08dcf2001-07-10 13:48:44 +0000840 tprint_iov(tcp, msg.msg_iovlen, (long) msg.msg_iov);
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000841
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000842#ifdef HAVE_MSG_CONTROL
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000843 tprintf(", msg_controllen=%lu", (unsigned long)msg.msg_controllen);
844 if (msg.msg_controllen)
845 tprintf(", msg_control=%#lx, ", (unsigned long) msg.msg_control);
846 tprintf(", msg_flags=");
847 if (printflags(msg_flags, msg.msg_flags)==0)
848 tprintf("0");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000849#else /* !HAVE_MSG_CONTROL */
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000850 tprintf("msg_accrights=%#lx, msg_accrightslen=%u",
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000851 (unsigned long) msg.msg_accrights, msg.msg_accrightslen);
852#endif /* !HAVE_MSG_CONTROL */
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000853 tprintf("}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000854}
855
856#endif /* HAVE_SENDMSG */
857
858int
859sys_socket(tcp)
860struct tcb *tcp;
861{
862 if (entering(tcp)) {
863 printxval(domains, tcp->u_arg[0], "PF_???");
864 tprintf(", ");
865 printxval(socktypes, tcp->u_arg[1], "SOCK_???");
866 tprintf(", ");
867 switch (tcp->u_arg[0]) {
868 case PF_INET:
869 printxval(protocols, tcp->u_arg[2], "IPPROTO_???");
870 break;
871#ifdef PF_IPX
872 case PF_IPX:
873 /* BTW: I don't believe this.. */
874 tprintf("[");
875 printxval(domains, tcp->u_arg[2], "PF_???");
876 tprintf("]");
877 break;
878#endif /* PF_IPX */
879 default:
880 tprintf("%lu", tcp->u_arg[2]);
881 break;
882 }
883 }
884 return 0;
885}
886
887int
John Hughesbdf48f52001-03-06 15:08:09 +0000888sys_so_socket(tcp)
889struct tcb *tcp;
890{
891 if (entering(tcp)) {
892 /* not sure really what these args are... but this
893 * is how truss prints it
894 */
895 tprintf("%ld, %ld, %ld, ",
896 tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]);
897 printpath(tcp, tcp->u_arg[3]);
898 tprintf(", %ld", tcp->u_arg[4]);
899 }
900 return 0;
901}
902
903int
904sys_so_socketpair(tcp)
905struct tcb *tcp;
906{
907 if (entering(tcp)) {
908 /* not sure what this arg is */
909 tprintf("0x%lx", tcp->u_arg[0]);
910 }
911 return 0;
912}
913
914int
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000915sys_bind(tcp)
916struct tcb *tcp;
917{
918 if (entering(tcp)) {
919 tprintf("%ld, ", tcp->u_arg[0]);
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000920 printsock(tcp, tcp->u_arg[1], tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000921 tprintf(", %lu", tcp->u_arg[2]);
922 }
923 return 0;
924}
925
926int
927sys_connect(tcp)
928struct tcb *tcp;
929{
930 return sys_bind(tcp);
931}
932
933int
934sys_listen(tcp)
935struct tcb *tcp;
936{
937 if (entering(tcp)) {
938 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
939 }
940 return 0;
941}
942
943int
944sys_accept(tcp)
945struct tcb *tcp;
946{
947 if (entering(tcp)) {
948 tprintf("%ld, ", tcp->u_arg[0]);
949 } else if (!tcp->u_arg[2])
950 tprintf("%#lx, NULL", tcp->u_arg[1]);
951 else {
952 if (tcp->u_arg[1] == 0 || syserror(tcp)) {
953 tprintf("%#lx", tcp->u_arg[1]);
954 } else {
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000955 printsock(tcp, tcp->u_arg[1], tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000956 }
957 tprintf(", ");
958 printnum(tcp, tcp->u_arg[2], "%lu");
959 }
960 return 0;
961}
962
963int
964sys_send(tcp)
965struct tcb *tcp;
966{
967 if (entering(tcp)) {
968 tprintf("%ld, ", tcp->u_arg[0]);
969 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
970 tprintf(", %lu, ", tcp->u_arg[2]);
971 /* flags */
972 if (printflags(msg_flags, tcp->u_arg[3]) == 0)
973 tprintf("0");
974 }
975 return 0;
976}
977
978int
979sys_sendto(tcp)
980struct tcb *tcp;
981{
982 if (entering(tcp)) {
983 tprintf("%ld, ", tcp->u_arg[0]);
984 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
985 tprintf(", %lu, ", tcp->u_arg[2]);
986 /* flags */
987 if (printflags(msg_flags, tcp->u_arg[3]) == 0)
988 tprintf("0");
989 /* to address */
990 tprintf(", ");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000991 printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000992 /* to length */
993 tprintf(", %lu", tcp->u_arg[5]);
994 }
995 return 0;
996}
997
998#ifdef HAVE_SENDMSG
999
1000int
1001sys_sendmsg(tcp)
1002struct tcb *tcp;
1003{
1004 if (entering(tcp)) {
1005 tprintf("%ld, ", tcp->u_arg[0]);
1006 printmsghdr(tcp, tcp->u_arg[1]);
1007 /* flags */
1008 tprintf(", ");
1009 if (printflags(msg_flags, tcp->u_arg[2]) == 0)
1010 tprintf("0");
1011 }
1012 return 0;
1013}
1014
1015#endif /* HAVE_SENDMSG */
1016
1017int
1018sys_recv(tcp)
1019struct tcb *tcp;
1020{
1021 if (entering(tcp)) {
1022 tprintf("%ld, ", tcp->u_arg[0]);
1023 } else {
1024 if (syserror(tcp))
1025 tprintf("%#lx", tcp->u_arg[1]);
1026 else
1027 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
1028
1029 tprintf(", %lu, ", tcp->u_arg[2]);
1030 if (printflags(msg_flags, tcp->u_arg[3]) == 0)
1031 tprintf("0");
1032 }
1033 return 0;
1034}
1035
1036int
1037sys_recvfrom(tcp)
1038struct tcb *tcp;
1039{
1040 int fromlen;
1041
1042 if (entering(tcp)) {
1043 tprintf("%ld, ", tcp->u_arg[0]);
1044 } else {
1045 if (syserror(tcp)) {
1046 tprintf("%#lx, %lu, %lu, %#lx, %#lx",
1047 tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3],
1048 tcp->u_arg[4], tcp->u_arg[5]);
1049 return 0;
1050 }
1051 /* buf */
1052 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
1053 /* len */
1054 tprintf(", %lu, ", tcp->u_arg[2]);
1055 /* flags */
1056 if (printflags(msg_flags, tcp->u_arg[3]) == 0)
1057 tprintf("0");
1058 /* from address, len */
1059 if (!tcp->u_arg[4] || !tcp->u_arg[5]) {
1060 if (tcp->u_arg[4] == 0)
1061 tprintf(", NULL");
1062 else
1063 tprintf(", %#lx", tcp->u_arg[4]);
1064 if (tcp->u_arg[5] == 0)
1065 tprintf(", NULL");
1066 else
1067 tprintf(", %#lx", tcp->u_arg[5]);
1068 return 0;
1069 }
1070 if (umove(tcp, tcp->u_arg[5], &fromlen) < 0) {
1071 tprintf(", {...}, [?]");
1072 return 0;
1073 }
1074 tprintf(", ");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001075 printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001076 /* from length */
1077 tprintf(", [%u]", fromlen);
1078 }
1079 return 0;
1080}
1081
1082#ifdef HAVE_SENDMSG
1083
1084int
1085sys_recvmsg(tcp)
1086struct tcb *tcp;
1087{
1088 if (entering(tcp)) {
1089 tprintf("%ld, ", tcp->u_arg[0]);
1090 } else {
1091 if (syserror(tcp) || !verbose(tcp))
1092 tprintf("%#lx", tcp->u_arg[1]);
1093 else
1094 printmsghdr(tcp, tcp->u_arg[1]);
1095 /* flags */
1096 tprintf(", ");
1097 if (printflags(msg_flags, tcp->u_arg[2]) == 0)
1098 tprintf("0");
1099 }
1100 return 0;
1101}
1102
1103#endif /* HAVE_SENDMSG */
1104
1105int
1106sys_shutdown(tcp)
1107struct tcb *tcp;
1108{
1109 if (entering(tcp)) {
1110 tprintf("%ld, %ld", tcp->u_arg[0], tcp->u_arg[1]);
1111 switch (tcp->u_arg[1]) {
1112 case 0:
1113 tprintf("%s", " /* receive */");
1114 break;
1115 case 1:
1116 tprintf("%s", " /* send */");
1117 break;
1118 case 2:
1119 tprintf("%s", " /* send and receive */");
1120 break;
1121 }
1122 }
1123 return 0;
1124}
1125
1126int
1127sys_getsockname(tcp)
1128struct tcb *tcp;
1129{
1130 return sys_accept(tcp);
1131}
1132
1133int
1134sys_getpeername(tcp)
1135struct tcb *tcp;
1136{
1137 return sys_accept(tcp);
1138}
1139
1140int
1141sys_pipe(tcp)
1142struct tcb *tcp;
1143{
1144
1145#if defined(LINUX) && !defined(SPARC)
1146 int fds[2];
1147
1148 if (exiting(tcp)) {
1149 if (syserror(tcp)) {
1150 tprintf("%#lx", tcp->u_arg[0]);
1151 return 0;
1152 }
1153 if (umoven(tcp, tcp->u_arg[0], sizeof fds, (char *) fds) < 0)
1154 tprintf("[...]");
1155 else
1156 tprintf("[%u, %u]", fds[0], fds[1]);
1157 }
Wichert Akkerman2e4ffe52000-09-03 23:57:48 +00001158#elif defined(SPARC) || defined(SVR4) || defined(FREEBSD)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001159 if (exiting(tcp))
1160 tprintf("[%lu, %lu]", tcp->u_rval, getrval2(tcp));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001161#endif
1162 return 0;
1163}
1164
1165int
1166sys_socketpair(tcp)
1167struct tcb *tcp;
1168{
1169#ifdef LINUX
1170 int fds[2];
1171#endif
1172
1173 if (entering(tcp)) {
1174 printxval(domains, tcp->u_arg[0], "PF_???");
1175 tprintf(", ");
1176 printxval(socktypes, tcp->u_arg[1], "SOCK_???");
1177 tprintf(", ");
1178 switch (tcp->u_arg[0]) {
1179 case PF_INET:
1180 printxval(protocols, tcp->u_arg[2], "IPPROTO_???");
1181 break;
1182#ifdef PF_IPX
1183 case PF_IPX:
1184 /* BTW: I don't believe this.. */
1185 tprintf("[");
1186 printxval(domains, tcp->u_arg[2], "PF_???");
1187 tprintf("]");
1188 break;
1189#endif /* PF_IPX */
1190 default:
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001191 tprintf("%lu", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001192 break;
1193 }
1194 } else {
1195 if (syserror(tcp)) {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001196 tprintf(", %#lx", tcp->u_arg[3]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001197 return 0;
1198 }
1199#ifdef LINUX
1200 if (umoven(tcp, tcp->u_arg[3], sizeof fds, (char *) fds) < 0)
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001201 tprintf(", [...]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001202 else
1203 tprintf(", [%u, %u]", fds[0], fds[1]);
1204#endif /* LINUX */
Wichert Akkerman2e4ffe52000-09-03 23:57:48 +00001205#if defined(SUNOS4) || defined(SVR4) || defined(FREEBSD)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001206 tprintf(", [%lu, %lu]", tcp->u_rval, getrval2(tcp));
Wichert Akkerman2e4ffe52000-09-03 23:57:48 +00001207#endif /* SUNOS4 || SVR4 || FREEBSD */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001208 }
1209 return 0;
1210}
1211
1212int
1213sys_getsockopt(tcp)
1214struct tcb *tcp;
1215{
1216 if (entering(tcp)) {
1217 tprintf("%ld, ", tcp->u_arg[0]);
John Hughes93f7fcc2002-05-22 15:46:49 +00001218 printxval(socketlayers, tcp->u_arg[1], "SOL_???");
1219 tprintf (", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001220 switch (tcp->u_arg[1]) {
1221 case SOL_SOCKET:
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001222 printxval(sockoptions, tcp->u_arg[2], "SO_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001223 break;
1224#ifdef SOL_IP
1225 case SOL_IP:
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001226 printxval(sockipoptions, tcp->u_arg[2], "IP_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001227 break;
1228#endif
1229#ifdef SOL_IPX
1230 case SOL_IPX:
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001231 printxval(sockipxoptions, tcp->u_arg[2], "IPX_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001232 break;
1233#endif
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001234#ifdef SOL_PACKET
1235 case SOL_PACKET:
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001236 printxval(sockpacketoptions, tcp->u_arg[2], "PACKET_???");
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001237 break;
1238#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001239#ifdef SOL_TCP
1240 case SOL_TCP:
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001241 printxval(socktcpoptions, tcp->u_arg[2], "TCP_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001242 break;
1243#endif
1244
1245 /* SOL_AX25 SOL_ROSE SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25
1246 * etc. still need work */
1247 default:
John Hughes93f7fcc2002-05-22 15:46:49 +00001248 tprintf("%lu", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001249 break;
1250 }
1251 } else {
John Hughes93f7fcc2002-05-22 15:46:49 +00001252 long len;
1253 if (syserror(tcp) || umove (tcp, tcp->u_arg[4], &len) < 0) {
1254 tprintf(", %#lx, %#lx",
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001255 tcp->u_arg[3], tcp->u_arg[4]);
1256 return 0;
1257 }
John Hughes93f7fcc2002-05-22 15:46:49 +00001258
1259 switch (tcp->u_arg[1]) {
1260 case SOL_SOCKET:
1261 switch (tcp->u_arg[2]) {
1262#ifdef SO_LINGER
1263 case SO_LINGER:
1264 if (len == sizeof (struct linger)) {
1265 struct linger linger;
1266 if (umove (tcp,
1267 tcp->u_arg[3],
1268 &linger) < 0)
1269 break;
1270 tprintf(", {onoff=%d, linger=%d}, "
1271 "[%ld]",
1272 linger.l_onoff,
1273 linger.l_linger,
1274 len);
1275 return 0;
1276 }
1277 break;
1278#endif
1279 }
1280 break;
1281 }
1282
1283 tprintf (", ");
1284 if (len == sizeof (int)) {
1285 printnum(tcp, tcp->u_arg[3], "%ld");
1286 }
1287 else {
1288 printstr (tcp, tcp->u_arg[3], len);
1289 }
1290 tprintf(", [%ld]", len);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001291 }
1292 return 0;
1293}
1294
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001295#if defined(ICMP_FILTER)
1296static void printicmpfilter(tcp, addr)
1297struct tcb *tcp;
1298long addr;
1299{
1300 struct icmp_filter filter;
1301
1302 if (!addr) {
1303 tprintf("NULL");
1304 return;
1305 }
1306 if (syserror(tcp) || !verbose(tcp)) {
1307 tprintf("%#lx", addr);
1308 return;
1309 }
1310 if (umove(tcp, addr, &filter) < 0) {
1311 tprintf("{...}");
1312 return;
1313 }
1314
1315 tprintf("~(");
1316 if (printflags(icmpfilterflags, ~filter.data) == 0)
1317 tprintf("0");
1318 tprintf(")");
1319}
1320#endif /* ICMP_FILTER */
1321
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001322int
1323sys_setsockopt(tcp)
1324struct tcb *tcp;
1325{
1326 if (entering(tcp)) {
1327 tprintf("%ld, ", tcp->u_arg[0]);
John Hughes93f7fcc2002-05-22 15:46:49 +00001328 printxval(socketlayers, tcp->u_arg[1], "IPPROTO_???");
1329 tprintf (", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001330 switch (tcp->u_arg[1]) {
1331 case SOL_SOCKET:
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001332 printxval(sockoptions, tcp->u_arg[2], "SO_???");
John Hughes93f7fcc2002-05-22 15:46:49 +00001333 switch (tcp->u_arg[2]) {
1334#if defined(SO_LINGER)
1335 case SO_LINGER:
1336 if (tcp->u_arg[4] == sizeof (struct linger)) {
1337 struct linger linger;
1338 if (umove (tcp,
1339 tcp->u_arg[3],
1340 &linger) < 0)
1341 break;
1342 tprintf(", {onoff=%d, linger=%d}, %lu",
1343 linger.l_onoff,
1344 linger.l_linger,
1345 tcp->u_arg[4]);
1346 return 0;
1347 }
1348 break;
1349#endif
1350 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001351 break;
1352#ifdef SOL_IP
1353 case SOL_IP:
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001354 printxval(sockipoptions, tcp->u_arg[2], "IP_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001355 break;
1356#endif
1357#ifdef SOL_IPX
1358 case SOL_IPX:
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001359 printxval(sockipxoptions, tcp->u_arg[2], "IPX_???");
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001360 break;
1361#endif
1362#ifdef SOL_PACKET
1363 case SOL_PACKET:
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001364 printxval(sockpacketoptions, tcp->u_arg[2], "PACKET_???");
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001365 /* TODO: decode packate_mreq for PACKET_*_MEMBERSHIP */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001366 break;
1367#endif
1368#ifdef SOL_TCP
1369 case SOL_TCP:
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001370 printxval(socktcpoptions, tcp->u_arg[2], "TCP_???");
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001371 break;
1372#endif
1373#ifdef SOL_RAW
1374 case SOL_RAW:
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001375 printxval(sockrawoptions, tcp->u_arg[2], "RAW_???");
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001376 switch (tcp->u_arg[2]) {
1377#if defined(ICMP_FILTER)
John Hughes93f7fcc2002-05-22 15:46:49 +00001378 case ICMP_FILTER:
1379 tprintf(", ");
1380 printicmpfilter(tcp, tcp->u_arg[3]);
1381 tprintf(", %lu", tcp->u_arg[4]);
1382 return 0;
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001383#endif
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001384 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001385 break;
1386#endif
1387
1388 /* SOL_AX25 SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25
1389 * etc. still need work */
John Hughes93f7fcc2002-05-22 15:46:49 +00001390
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001391 default:
John Hughes93f7fcc2002-05-22 15:46:49 +00001392 tprintf("%lu", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001393 }
John Hughes93f7fcc2002-05-22 15:46:49 +00001394
1395 /* default arg printing */
1396
1397 tprintf (", ");
1398
1399 if (tcp->u_arg[4] == sizeof (int)) {
1400 printnum(tcp, tcp->u_arg[3], "%ld");
1401 }
1402 else {
1403 printstr (tcp, tcp->u_arg[3], tcp->u_arg[4]);
1404 }
1405
1406 tprintf(", %lu", tcp->u_arg[4]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001407 }
1408 return 0;
1409}
Wichert Akkerman16a03d22000-08-10 02:14:04 +00001410
1411#if UNIXWARE >= 7
1412
1413static struct xlat sock_version[] = {
1414 { __NETLIB_UW211_SVR4, "UW211_SVR4" },
1415 { __NETLIB_UW211_XPG4, "UW211_XPG4" },
1416 { __NETLIB_GEMINI_SVR4, "GEMINI_SVR4" },
1417 { __NETLIB_GEMINI_XPG4, "GEMINI_XPG4" },
1418 { __NETLIB_FP1_SVR4, "FP1_SVR4" },
1419 { __NETLIB_FP1_XPG4, "FP1_XPG4" },
1420 { 0, NULL },
1421};
1422
1423
1424int
1425netlib_call(tcp, func)
1426struct tcb *tcp;
1427int (*func) ();
1428{
1429 if (entering(tcp)) {
1430 int i;
1431 printxval (sock_version, tcp->u_arg[0], "__NETLIB_???");
1432 tprintf(", ");
1433 --tcp->u_nargs;
1434 for (i = 0; i < tcp->u_nargs; i++)
1435 tcp->u_arg[i] = tcp->u_arg[i + 1];
1436 return func (tcp);
1437
1438 }
1439
1440 return func (tcp);
1441}
1442
1443int
1444sys_xsocket(tcp)
1445struct tcb *tcp;
1446{
1447 return netlib_call (tcp, sys_socket);
1448}
1449
1450int
1451sys_xsocketpair(tcp)
1452struct tcb *tcp;
1453{
1454 return netlib_call (tcp, sys_socketpair);
1455}
1456
1457int
1458sys_xbind(tcp)
1459struct tcb *tcp;
1460{
1461 return netlib_call (tcp, sys_bind);
1462}
1463
1464int
1465sys_xconnect(tcp)
1466struct tcb *tcp;
1467{
1468 return netlib_call (tcp, sys_connect);
1469}
1470
1471int
1472sys_xlisten(tcp)
1473struct tcb *tcp;
1474{
1475 return netlib_call (tcp, sys_listen);
1476}
1477
1478int
1479sys_xaccept(tcp)
1480struct tcb *tcp;
1481{
1482 return netlib_call (tcp, sys_accept);
1483}
1484
1485int
1486sys_xsendmsg(tcp)
1487struct tcb *tcp;
1488{
1489 return netlib_call (tcp, sys_sendmsg);
1490}
1491
1492int
1493sys_xrecvmsg(tcp)
1494struct tcb *tcp;
1495{
1496 return netlib_call (tcp, sys_recvmsg);
1497}
1498
1499int
1500sys_xgetsockaddr(tcp)
1501struct tcb *tcp;
1502{
1503 if (entering(tcp)) {
1504 printxval (sock_version, tcp->u_arg[0], "__NETLIB_???");
1505 tprintf(", ");
1506 if (tcp->u_arg[1] == 0) {
1507 tprintf ("LOCALNAME, ");
1508 }
1509 else if (tcp->u_arg[1] == 1) {
1510 tprintf ("REMOTENAME, ");
1511 }
1512 else {
1513 tprintf ("%ld, ", tcp->u_arg [1]);
1514 }
1515 tprintf ("%ld, ", tcp->u_arg [2]);
1516 }
1517 else {
1518 if (tcp->u_arg[3] == 0 || syserror(tcp)) {
1519 tprintf("%#lx", tcp->u_arg[3]);
1520 } else {
1521 printsock(tcp, tcp->u_arg[3], tcp->u_arg[4]);
1522 }
1523 tprintf(", ");
1524 printnum(tcp, tcp->u_arg[4], "%lu");
1525 }
1526
1527 return 0;
1528
1529}
1530
1531#if 0
1532
1533int
1534sys_xsetsockaddr(tcp)
1535struct tcb *tcp;
1536{
1537 return netlib_call (tcp, sys_setsockaddr);
1538}
1539
1540#endif
1541
1542int
1543sys_xgetsockopt(tcp)
1544struct tcb *tcp;
1545{
1546 return netlib_call (tcp, sys_getsockopt);
1547}
1548
1549int
1550sys_xsetsockopt(tcp)
1551struct tcb *tcp;
1552{
1553 return netlib_call (tcp, sys_setsockopt);
1554}
1555
1556int
1557sys_xshutdown(tcp)
1558struct tcb *tcp;
1559{
1560 return netlib_call (tcp, sys_shutdown);
1561}
1562
1563#endif