net.c revision f535b54bc40373c81b13df0975aef4212dacbbde
1/* 2 * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl> 3 * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl> 4 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com> 5 * Copyright (c) 1996-2000 Wichert Akkerman <wichert@cistron.nl> 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. The name of the author may not be used to endorse or promote products 17 * derived from this software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * 30 * $Id$ 31 */ 32 33#include "defs.h" 34 35#include <sys/stat.h> 36#include <sys/socket.h> 37#include <sys/un.h> 38 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 45#include <netinet/in.h> 46#ifdef HAVE_NETINET_TCP_H 47#include <netinet/tcp.h> 48#endif 49#ifdef HAVE_NETINET_UDP_H 50#include <netinet/udp.h> 51#endif 52#include <arpa/inet.h> 53#include <net/if.h> 54#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 63#if defined (__GLIBC__) && (((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1)) || defined(HAVE_SIN6_SCOPE_ID_LINUX)) 64#if defined(HAVE_LINUX_IN6_H) 65#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 73#include <linux/in6.h> 74#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 82#endif 83#endif 84 85#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 97#if defined(HAVE_LINUX_ICMP_H) 98#include <linux/icmp.h> 99#endif 100 101#ifndef PF_UNSPEC 102#define PF_UNSPEC AF_UNSPEC 103#endif 104 105#if UNIXWARE >= 7 106#define HAVE_SENDMSG 1 /* HACK - *FIXME* */ 107#endif 108 109#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 const struct xlat domains[] = { 120#ifdef PF_AAL5 121 { PF_AAL5, "PF_AAL5" }, 122#endif 123#ifdef PF_APPLETALK 124 { PF_APPLETALK, "PF_APPLETALK" }, 125#endif 126#ifdef PF_ASH 127 { PF_ASH, "PF_ASH" }, 128#endif 129#ifdef PF_ATMPVC 130 { PF_ATMPVC, "PF_ATMPVC" }, 131#endif 132#ifdef PF_ATMSVC 133 { PF_ATMSVC, "PF_ATMSVC" }, 134#endif 135#ifdef PF_AX25 136 { PF_AX25, "PF_AX25" }, 137#endif 138#ifdef PF_BLUETOOTH 139 { PF_BLUETOOTH, "PF_BLUETOOTH" }, 140#endif 141#ifdef PF_BRIDGE 142 { PF_BRIDGE, "PF_BRIDGE" }, 143#endif 144#ifdef PF_DECnet 145 { PF_DECnet, "PF_DECnet" }, 146#endif 147#ifdef PF_DECNET 148 { PF_DECNET, "PF_DECNET" }, 149#endif 150#ifdef PF_ECONET 151 { PF_ECONET, "PF_ECONET" }, 152#endif 153#ifdef PF_FILE 154 { PF_FILE, "PF_FILE" }, 155#endif 156#ifdef PF_IMPLINK 157 { PF_IMPLINK, "PF_IMPLINK" }, 158#endif 159#ifdef PF_INET 160 { PF_INET, "PF_INET" }, 161#endif 162#ifdef PF_INET6 163 { PF_INET6, "PF_INET6" }, 164#endif 165#ifdef PF_IPX 166 { PF_IPX, "PF_IPX" }, 167#endif 168#ifdef PF_IRDA 169 { PF_IRDA, "PF_IRDA" }, 170#endif 171#ifdef PF_ISO 172 { PF_ISO, "PF_ISO" }, 173#endif 174#ifdef PF_KEY 175 { PF_KEY, "PF_KEY" }, 176#endif 177#ifdef PF_UNIX 178 { PF_UNIX, "PF_UNIX" }, 179#endif 180#ifdef PF_LOCAL 181 { PF_LOCAL, "PF_LOCAL" }, 182#endif 183#ifdef PF_NETBEUI 184 { PF_NETBEUI, "PF_NETBEUI" }, 185#endif 186#ifdef PF_NETLINK 187 { PF_NETLINK, "PF_NETLINK" }, 188#endif 189#ifdef PF_NETROM 190 { PF_NETROM, "PF_NETROM" }, 191#endif 192#ifdef PF_PACKET 193 { PF_PACKET, "PF_PACKET" }, 194#endif 195#ifdef PF_PPPOX 196 { PF_PPPOX, "PF_PPPOX" }, 197#endif 198#ifdef PF_ROSE 199 { PF_ROSE, "PF_ROSE" }, 200#endif 201#ifdef PF_ROUTE 202 { PF_ROUTE, "PF_ROUTE" }, 203#endif 204#ifdef PF_SECURITY 205 { PF_SECURITY, "PF_SECURITY" }, 206#endif 207#ifdef PF_SNA 208 { PF_SNA, "PF_SNA" }, 209#endif 210#ifdef PF_UNSPEC 211 { PF_UNSPEC, "PF_UNSPEC" }, 212#endif 213#ifdef PF_WANPIPE 214 { PF_WANPIPE, "PF_WANPIPE" }, 215#endif 216#ifdef PF_X25 217 { PF_X25, "PF_X25" }, 218#endif 219 { 0, NULL }, 220}; 221const struct xlat addrfams[] = { 222#ifdef AF_APPLETALK 223 { AF_APPLETALK, "AF_APPLETALK" }, 224#endif 225#ifdef AF_ASH 226 { AF_ASH, "AF_ASH" }, 227#endif 228#ifdef AF_ATMPVC 229 { AF_ATMPVC, "AF_ATMPVC" }, 230#endif 231#ifdef AF_ATMSVC 232 { AF_ATMSVC, "AF_ATMSVC" }, 233#endif 234#ifdef AF_AX25 235 { AF_AX25, "AF_AX25" }, 236#endif 237#ifdef AF_BLUETOOTH 238 { AF_BLUETOOTH, "AF_BLUETOOTH" }, 239#endif 240#ifdef AF_BRIDGE 241 { AF_BRIDGE, "AF_BRIDGE" }, 242#endif 243#ifdef AF_DECnet 244 { AF_DECnet, "AF_DECnet" }, 245#endif 246#ifdef AF_ECONET 247 { AF_ECONET, "AF_ECONET" }, 248#endif 249#ifdef AF_FILE 250 { AF_FILE, "AF_FILE" }, 251#endif 252#ifdef AF_IMPLINK 253 { AF_IMPLINK, "AF_IMPLINK" }, 254#endif 255#ifdef AF_INET 256 { AF_INET, "AF_INET" }, 257#endif 258#ifdef AF_INET6 259 { AF_INET6, "AF_INET6" }, 260#endif 261#ifdef AF_IPX 262 { AF_IPX, "AF_IPX" }, 263#endif 264#ifdef AF_IRDA 265 { AF_IRDA, "AF_IRDA" }, 266#endif 267#ifdef AF_ISO 268 { AF_ISO, "AF_ISO" }, 269#endif 270#ifdef AF_KEY 271 { AF_KEY, "AF_KEY" }, 272#endif 273#ifdef AF_UNIX 274 { AF_UNIX, "AF_UNIX" }, 275#endif 276#ifdef AF_LOCAL 277 { AF_LOCAL, "AF_LOCAL" }, 278#endif 279#ifdef AF_NETBEUI 280 { AF_NETBEUI, "AF_NETBEUI" }, 281#endif 282#ifdef AF_NETLINK 283 { AF_NETLINK, "AF_NETLINK" }, 284#endif 285#ifdef AF_NETROM 286 { AF_NETROM, "AF_NETROM" }, 287#endif 288#ifdef AF_PACKET 289 { AF_PACKET, "AF_PACKET" }, 290#endif 291#ifdef AF_PPPOX 292 { AF_PPPOX, "AF_PPPOX" }, 293#endif 294#ifdef AF_ROSE 295 { AF_ROSE, "AF_ROSE" }, 296#endif 297#ifdef AF_ROUTE 298 { AF_ROUTE, "AF_ROUTE" }, 299#endif 300#ifdef AF_SECURITY 301 { AF_SECURITY, "AF_SECURITY" }, 302#endif 303#ifdef AF_SNA 304 { AF_SNA, "AF_SNA" }, 305#endif 306#ifdef AF_UNSPEC 307 { AF_UNSPEC, "AF_UNSPEC" }, 308#endif 309#ifdef AF_WANPIPE 310 { AF_WANPIPE, "AF_WANPIPE" }, 311#endif 312#ifdef AF_X25 313 { AF_X25, "AF_X25" }, 314#endif 315 { 0, NULL }, 316}; 317static const struct xlat socktypes[] = { 318 { SOCK_STREAM, "SOCK_STREAM" }, 319 { SOCK_DGRAM, "SOCK_DGRAM" }, 320#ifdef SOCK_RAW 321 { SOCK_RAW, "SOCK_RAW" }, 322#endif 323#ifdef SOCK_RDM 324 { SOCK_RDM, "SOCK_RDM" }, 325#endif 326#ifdef SOCK_SEQPACKET 327 { SOCK_SEQPACKET,"SOCK_SEQPACKET"}, 328#endif 329#ifdef SOCK_DCCP 330 { SOCK_DCCP, "SOCK_DCCP" }, 331#endif 332#ifdef SOCK_PACKET 333 { SOCK_PACKET, "SOCK_PACKET" }, 334#endif 335 { 0, NULL }, 336}; 337const struct xlat sock_type_flags[] = { 338#ifdef SOCK_CLOEXEC 339 { SOCK_CLOEXEC, "SOCK_CLOEXEC" }, 340#endif 341#ifdef SOCK_NONBLOCK 342 { SOCK_NONBLOCK,"SOCK_NONBLOCK" }, 343#endif 344 { 0, NULL }, 345}; 346#ifndef SOCK_TYPE_MASK 347# define SOCK_TYPE_MASK 0xf 348#endif 349static const struct xlat socketlayers[] = { 350#if defined(SOL_IP) 351 { SOL_IP, "SOL_IP" }, 352#endif 353#if defined(SOL_ICMP) 354 { SOL_ICMP, "SOL_ICMP" }, 355#endif 356#if defined(SOL_TCP) 357 { SOL_TCP, "SOL_TCP" }, 358#endif 359#if defined(SOL_UDP) 360 { SOL_UDP, "SOL_UDP" }, 361#endif 362#if defined(SOL_IPV6) 363 { SOL_IPV6, "SOL_IPV6" }, 364#endif 365#if defined(SOL_ICMPV6) 366 { SOL_ICMPV6, "SOL_ICMPV6" }, 367#endif 368#if defined(SOL_RAW) 369 { SOL_RAW, "SOL_RAW" }, 370#endif 371#if defined(SOL_IPX) 372 { SOL_IPX, "SOL_IPX" }, 373#endif 374#if defined(SOL_IPX) 375 { SOL_IPX, "SOL_IPX" }, 376#endif 377#if defined(SOL_AX25) 378 { SOL_AX25, "SOL_AX25" }, 379#endif 380#if defined(SOL_ATALK) 381 { SOL_ATALK, "SOL_ATALK" }, 382#endif 383#if defined(SOL_NETROM) 384 { SOL_NETROM, "SOL_NETROM" }, 385#endif 386#if defined(SOL_ROSE) 387 { SOL_ROSE, "SOL_ROSE" }, 388#endif 389#if defined(SOL_DECNET) 390 { SOL_DECNET, "SOL_DECNET" }, 391#endif 392#if defined(SOL_X25) 393 { SOL_X25, "SOL_X25" }, 394#endif 395#if defined(SOL_PACKET) 396 { SOL_PACKET, "SOL_PACKET" }, 397#endif 398#if defined(SOL_ATM) 399 { SOL_ATM, "SOL_ATM" }, 400#endif 401#if defined(SOL_AAL) 402 { SOL_AAL, "SOL_AAL" }, 403#endif 404#if defined(SOL_IRDA) 405 { SOL_IRDA, "SOL_IRDA" }, 406#endif 407 { SOL_SOCKET, "SOL_SOCKET" }, /* Never used! */ 408}; 409/*** WARNING: DANGER WILL ROBINSON: NOTE "socketlayers" array above 410 falls into "protocols" array below!!!! This is intended!!! ***/ 411static const struct xlat protocols[] = { 412 { IPPROTO_IP, "IPPROTO_IP" }, 413 { IPPROTO_ICMP, "IPPROTO_ICMP" }, 414 { IPPROTO_TCP, "IPPROTO_TCP" }, 415 { IPPROTO_UDP, "IPPROTO_UDP" }, 416#ifdef IPPROTO_GGP 417 { IPPROTO_GGP, "IPPROTO_GGP" }, 418#endif 419#ifdef IPPROTO_EGP 420 { IPPROTO_EGP, "IPPROTO_EGP" }, 421#endif 422#ifdef IPPROTO_PUP 423 { IPPROTO_PUP, "IPPROTO_PUP" }, 424#endif 425#ifdef IPPROTO_IDP 426 { IPPROTO_IDP, "IPPROTO_IDP" }, 427#endif 428#ifdef IPPROTO_IPV6 429 { IPPROTO_IPV6, "IPPROTO_IPV6" }, 430#endif 431#ifdef IPPROTO_ICMPV6 432 { IPPROTO_ICMPV6,"IPPROTO_ICMPV6"}, 433#endif 434#ifdef IPPROTO_IGMP 435 { IPPROTO_IGMP, "IPPROTO_IGMP" }, 436#endif 437#ifdef IPPROTO_HELLO 438 { IPPROTO_HELLO,"IPPROTO_HELLO" }, 439#endif 440#ifdef IPPROTO_ND 441 { IPPROTO_ND, "IPPROTO_ND" }, 442#endif 443#ifdef IPPROTO_RAW 444 { IPPROTO_RAW, "IPPROTO_RAW" }, 445#endif 446#ifdef IPPROTO_MAX 447 { IPPROTO_MAX, "IPPROTO_MAX" }, 448#endif 449#ifdef IPPROTO_IPIP 450 { IPPROTO_IPIP, "IPPROTO_IPIP" }, 451#endif 452 { 0, NULL }, 453}; 454static const struct xlat msg_flags[] = { 455 { MSG_OOB, "MSG_OOB" }, 456#ifdef MSG_DONTROUTE 457 { MSG_DONTROUTE, "MSG_DONTROUTE" }, 458#endif 459#ifdef MSG_PEEK 460 { MSG_PEEK, "MSG_PEEK" }, 461#endif 462#ifdef MSG_CTRUNC 463 { MSG_CTRUNC, "MSG_CTRUNC" }, 464#endif 465#ifdef MSG_PROXY 466 { MSG_PROXY, "MSG_PROXY" }, 467#endif 468#ifdef MSG_EOR 469 { MSG_EOR, "MSG_EOR" }, 470#endif 471#ifdef MSG_WAITALL 472 { MSG_WAITALL, "MSG_WAITALL" }, 473#endif 474#ifdef MSG_TRUNC 475 { MSG_TRUNC, "MSG_TRUNC" }, 476#endif 477#ifdef MSG_CTRUNC 478 { MSG_CTRUNC, "MSG_CTRUNC" }, 479#endif 480#ifdef MSG_ERRQUEUE 481 { MSG_ERRQUEUE, "MSG_ERRQUEUE" }, 482#endif 483#ifdef MSG_DONTWAIT 484 { MSG_DONTWAIT, "MSG_DONTWAIT" }, 485#endif 486#ifdef MSG_CONFIRM 487 { MSG_CONFIRM, "MSG_CONFIRM" }, 488#endif 489#ifdef MSG_PROBE 490 { MSG_PROBE, "MSG_PROBE" }, 491#endif 492#ifdef MSG_FIN 493 { MSG_FIN, "MSG_FIN" }, 494#endif 495#ifdef MSG_SYN 496 { MSG_SYN, "MSG_SYN" }, 497#endif 498#ifdef MSG_RST 499 { MSG_RST, "MSG_RST" }, 500#endif 501#ifdef MSG_NOSIGNAL 502 { MSG_NOSIGNAL, "MSG_NOSIGNAL" }, 503#endif 504#ifdef MSG_MORE 505 { MSG_MORE, "MSG_MORE" }, 506#endif 507#ifdef MSG_CMSG_CLOEXEC 508 { MSG_CMSG_CLOEXEC, "MSG_CMSG_CLOEXEC" }, 509#endif 510 { 0, NULL }, 511}; 512 513static const struct xlat sockoptions[] = { 514#ifdef SO_ACCEPTCONN 515 { SO_ACCEPTCONN, "SO_ACCEPTCONN" }, 516#endif 517#ifdef SO_ALLRAW 518 { SO_ALLRAW, "SO_ALLRAW" }, 519#endif 520#ifdef SO_ATTACH_FILTER 521 { SO_ATTACH_FILTER, "SO_ATTACH_FILTER" }, 522#endif 523#ifdef SO_BINDTODEVICE 524 { SO_BINDTODEVICE, "SO_BINDTODEVICE" }, 525#endif 526#ifdef SO_BROADCAST 527 { SO_BROADCAST, "SO_BROADCAST" }, 528#endif 529#ifdef SO_BSDCOMPAT 530 { SO_BSDCOMPAT, "SO_BSDCOMPAT" }, 531#endif 532#ifdef SO_DEBUG 533 { SO_DEBUG, "SO_DEBUG" }, 534#endif 535#ifdef SO_DETACH_FILTER 536 { SO_DETACH_FILTER, "SO_DETACH_FILTER" }, 537#endif 538#ifdef SO_DONTROUTE 539 { SO_DONTROUTE, "SO_DONTROUTE" }, 540#endif 541#ifdef SO_ERROR 542 { SO_ERROR, "SO_ERROR" }, 543#endif 544#ifdef SO_ICS 545 { SO_ICS, "SO_ICS" }, 546#endif 547#ifdef SO_IMASOCKET 548 { SO_IMASOCKET, "SO_IMASOCKET" }, 549#endif 550#ifdef SO_KEEPALIVE 551 { SO_KEEPALIVE, "SO_KEEPALIVE" }, 552#endif 553#ifdef SO_LINGER 554 { SO_LINGER, "SO_LINGER" }, 555#endif 556#ifdef SO_LISTENING 557 { SO_LISTENING, "SO_LISTENING" }, 558#endif 559#ifdef SO_MGMT 560 { SO_MGMT, "SO_MGMT" }, 561#endif 562#ifdef SO_NO_CHECK 563 { SO_NO_CHECK, "SO_NO_CHECK" }, 564#endif 565#ifdef SO_OOBINLINE 566 { SO_OOBINLINE, "SO_OOBINLINE" }, 567#endif 568#ifdef SO_ORDREL 569 { SO_ORDREL, "SO_ORDREL" }, 570#endif 571#ifdef SO_PARALLELSVR 572 { SO_PARALLELSVR, "SO_PARALLELSVR" }, 573#endif 574#ifdef SO_PASSCRED 575 { SO_PASSCRED, "SO_PASSCRED" }, 576#endif 577#ifdef SO_PEERCRED 578 { SO_PEERCRED, "SO_PEERCRED" }, 579#endif 580#ifdef SO_PEERNAME 581 { SO_PEERNAME, "SO_PEERNAME" }, 582#endif 583#ifdef SO_PEERSEC 584 { SO_PEERSEC, "SO_PEERSEC" }, 585#endif 586#ifdef SO_PRIORITY 587 { SO_PRIORITY, "SO_PRIORITY" }, 588#endif 589#ifdef SO_PROTOTYPE 590 { SO_PROTOTYPE, "SO_PROTOTYPE" }, 591#endif 592#ifdef SO_RCVBUF 593 { SO_RCVBUF, "SO_RCVBUF" }, 594#endif 595#ifdef SO_RCVLOWAT 596 { SO_RCVLOWAT, "SO_RCVLOWAT" }, 597#endif 598#ifdef SO_RCVTIMEO 599 { SO_RCVTIMEO, "SO_RCVTIMEO" }, 600#endif 601#ifdef SO_RDWR 602 { SO_RDWR, "SO_RDWR" }, 603#endif 604#ifdef SO_REUSEADDR 605 { SO_REUSEADDR, "SO_REUSEADDR" }, 606#endif 607#ifdef SO_REUSEPORT 608 { SO_REUSEPORT, "SO_REUSEPORT" }, 609#endif 610#ifdef SO_SECURITY_AUTHENTICATION 611 { SO_SECURITY_AUTHENTICATION,"SO_SECURITY_AUTHENTICATION"}, 612#endif 613#ifdef SO_SECURITY_ENCRYPTION_NETWORK 614 { SO_SECURITY_ENCRYPTION_NETWORK,"SO_SECURITY_ENCRYPTION_NETWORK"}, 615#endif 616#ifdef SO_SECURITY_ENCRYPTION_TRANSPORT 617 { SO_SECURITY_ENCRYPTION_TRANSPORT,"SO_SECURITY_ENCRYPTION_TRANSPORT"}, 618#endif 619#ifdef SO_SEMA 620 { SO_SEMA, "SO_SEMA" }, 621#endif 622#ifdef SO_SNDBUF 623 { SO_SNDBUF, "SO_SNDBUF" }, 624#endif 625#ifdef SO_SNDLOWAT 626 { SO_SNDLOWAT, "SO_SNDLOWAT" }, 627#endif 628#ifdef SO_SNDTIMEO 629 { SO_SNDTIMEO, "SO_SNDTIMEO" }, 630#endif 631#ifdef SO_TIMESTAMP 632 { SO_TIMESTAMP, "SO_TIMESTAMP" }, 633#endif 634#ifdef SO_TYPE 635 { SO_TYPE, "SO_TYPE" }, 636#endif 637#ifdef SO_USELOOPBACK 638 { SO_USELOOPBACK, "SO_USELOOPBACK" }, 639#endif 640 { 0, NULL }, 641}; 642 643#if !defined (SOL_IP) && defined (IPPROTO_IP) 644#define SOL_IP IPPROTO_IP 645#endif 646 647#ifdef SOL_IP 648static const struct xlat sockipoptions[] = { 649#ifdef IP_TOS 650 { IP_TOS, "IP_TOS" }, 651#endif 652#ifdef IP_TTL 653 { IP_TTL, "IP_TTL" }, 654#endif 655#ifdef IP_HDRINCL 656 { IP_HDRINCL, "IP_HDRINCL" }, 657#endif 658#ifdef IP_OPTIONS 659 { IP_OPTIONS, "IP_OPTIONS" }, 660#endif 661#ifdef IP_ROUTER_ALERT 662 { IP_ROUTER_ALERT, "IP_ROUTER_ALERT" }, 663#endif 664#ifdef IP_RECVOPTIONS 665 { IP_RECVOPTIONS, "IP_RECVOPTIONS" }, 666#endif 667#ifdef IP_RECVOPTS 668 { IP_RECVOPTS, "IP_RECVOPTS" }, 669#endif 670#ifdef IP_RECVRETOPTS 671 { IP_RECVRETOPTS, "IP_RECVRETOPTS" }, 672#endif 673#ifdef IP_RECVDSTADDR 674 { IP_RECVDSTADDR, "IP_RECVDSTADDR" }, 675#endif 676#ifdef IP_RETOPTS 677 { IP_RETOPTS, "IP_RETOPTS" }, 678#endif 679#ifdef IP_PKTINFO 680 { IP_PKTINFO, "IP_PKTINFO" }, 681#endif 682#ifdef IP_PKTOPTIONS 683 { IP_PKTOPTIONS, "IP_PKTOPTIONS" }, 684#endif 685#ifdef IP_MTU_DISCOVER 686 { IP_MTU_DISCOVER, "IP_MTU_DISCOVER" }, 687#endif 688#ifdef IP_RECVERR 689 { IP_RECVERR, "IP_RECVERR" }, 690#endif 691#ifdef IP_RECVTTL 692 { IP_RECVTTL, "IP_RECVTTL" }, 693#endif 694#ifdef IP_RECVTOS 695 { IP_RECVTOS, "IP_RECVTOS" }, 696#endif 697#ifdef IP_MTU 698 { IP_MTU, "IP_MTU" }, 699#endif 700#ifdef IP_MULTICAST_IF 701 { IP_MULTICAST_IF, "IP_MULTICAST_IF" }, 702#endif 703#ifdef IP_MULTICAST_TTL 704 { IP_MULTICAST_TTL, "IP_MULTICAST_TTL" }, 705#endif 706#ifdef IP_MULTICAST_LOOP 707 { IP_MULTICAST_LOOP, "IP_MULTICAST_LOOP" }, 708#endif 709#ifdef IP_ADD_MEMBERSHIP 710 { IP_ADD_MEMBERSHIP, "IP_ADD_MEMBERSHIP" }, 711#endif 712#ifdef IP_DROP_MEMBERSHIP 713 { IP_DROP_MEMBERSHIP, "IP_DROP_MEMBERSHIP" }, 714#endif 715#ifdef IP_BROADCAST_IF 716 { IP_BROADCAST_IF, "IP_BROADCAST_IF" }, 717#endif 718#ifdef IP_RECVIFINDEX 719 { IP_RECVIFINDEX, "IP_RECVIFINDEX" }, 720#endif 721#ifdef IP_MSFILTER 722 { IP_MSFILTER, "IP_MSFILTER" }, 723#endif 724#ifdef MCAST_MSFILTER 725 { MCAST_MSFILTER, "MCAST_MSFILTER" }, 726#endif 727#ifdef IP_FREEBIND 728 { IP_FREEBIND, "IP_FREEBIND" }, 729#endif 730 { 0, NULL }, 731}; 732#endif /* SOL_IP */ 733 734#ifdef SOL_IPV6 735static const struct xlat sockipv6options[] = { 736#ifdef IPV6_ADDRFORM 737 { IPV6_ADDRFORM, "IPV6_ADDRFORM" }, 738#endif 739#ifdef MCAST_FILTER 740 { MCAST_FILTER, "MCAST_FILTER" }, 741#endif 742#ifdef IPV6_PKTOPTIONS 743 { IPV6_PKTOPTIONS, "IPV6_PKTOPTIONS" }, 744#endif 745#ifdef IPV6_MTU 746 { IPV6_MTU, "IPV6_MTU" }, 747#endif 748#ifdef IPV6_V6ONLY 749 { IPV6_V6ONLY, "IPV6_V6ONLY" }, 750#endif 751#ifdef IPV6_PKTINFO 752 { IPV6_PKTINFO, "IPV6_PKTINFO" }, 753#endif 754#ifdef IPV6_HOPLIMIT 755 { IPV6_HOPLIMIT, "IPV6_HOPLIMIT" }, 756#endif 757#ifdef IPV6_RTHDR 758 { IPV6_RTHDR, "IPV6_RTHDR" }, 759#endif 760#ifdef IPV6_HOPOPTS 761 { IPV6_HOPOPTS, "IPV6_HOPOPTS" }, 762#endif 763#ifdef IPV6_DSTOPTS 764 { IPV6_DSTOPTS, "IPV6_DSTOPTS" }, 765#endif 766#ifdef IPV6_FLOWINFO 767 { IPV6_FLOWINFO, "IPV6_FLOWINFO" }, 768#endif 769#ifdef IPV6_UNICAST_HOPS 770 { IPV6_UNICAST_HOPS, "IPV6_UNICAST_HOPS" }, 771#endif 772#ifdef IPV6_MULTICAST_HOPS 773 { IPV6_MULTICAST_HOPS, "IPV6_MULTICAST_HOPS" }, 774#endif 775#ifdef IPV6_MULTICAST_LOOP 776 { IPV6_MULTICAST_LOOP, "IPV6_MULTICAST_LOOP" }, 777#endif 778#ifdef IPV6_MULTICAST_IF 779 { IPV6_MULTICAST_IF, "IPV6_MULTICAST_IF" }, 780#endif 781#ifdef IPV6_MTU_DISCOVER 782 { IPV6_MTU_DISCOVER, "IPV6_MTU_DISCOVER" }, 783#endif 784#ifdef IPV6_RECVERR 785 { IPV6_RECVERR, "IPV6_RECVERR" }, 786#endif 787#ifdef IPV6_FLOWINFO_SEND 788 { IPV6_FLOWINFO_SEND, "IPV6_FLOWINFO_SEND" }, 789#endif 790#ifdef IPV6_ADD_MEMBERSHIP 791 { IPV6_ADD_MEMBERSHIP, "IPV6_ADD_MEMBERSHIP" }, 792#endif 793#ifdef IPV6_DROP_MEMBERSHIP 794 { IPV6_DROP_MEMBERSHIP, "IPV6_DROP_MEMBERSHIP" }, 795#endif 796#ifdef IPV6_ROUTER_ALERT 797 { IPV6_ROUTER_ALERT, "IPV6_ROUTER_ALERT" }, 798#endif 799 { 0, NULL }, 800}; 801#endif /* SOL_IPV6 */ 802 803#ifdef SOL_IPX 804static const struct xlat sockipxoptions[] = { 805 { IPX_TYPE, "IPX_TYPE" }, 806 { 0, NULL }, 807}; 808#endif /* SOL_IPX */ 809 810#ifdef SOL_RAW 811static const struct xlat sockrawoptions[] = { 812#if defined(ICMP_FILTER) 813 { ICMP_FILTER, "ICMP_FILTER" }, 814#endif 815 { 0, NULL }, 816}; 817#endif /* SOL_RAW */ 818 819#ifdef SOL_PACKET 820static const struct xlat sockpacketoptions[] = { 821#ifdef PACKET_ADD_MEMBERSHIP 822 { PACKET_ADD_MEMBERSHIP, "PACKET_ADD_MEMBERSHIP" }, 823#endif 824#ifdef PACKET_DROP_MEMBERSHIP 825 { PACKET_DROP_MEMBERSHIP, "PACKET_DROP_MEMBERSHIP"}, 826#endif 827#if defined(PACKET_RECV_OUTPUT) 828 { PACKET_RECV_OUTPUT, "PACKET_RECV_OUTPUT" }, 829#endif 830#if defined(PACKET_RX_RING) 831 { PACKET_RX_RING, "PACKET_RX_RING" }, 832#endif 833#if defined(PACKET_STATISTICS) 834 { PACKET_STATISTICS, "PACKET_STATISTICS" }, 835#endif 836 { 0, NULL }, 837}; 838#endif /* SOL_PACKET */ 839 840#if !defined (SOL_TCP) && defined (IPPROTO_TCP) 841#define SOL_TCP IPPROTO_TCP 842#endif 843 844#ifdef SOL_TCP 845static const struct xlat socktcpoptions[] = { 846 { TCP_NODELAY, "TCP_NODELAY" }, 847 { TCP_MAXSEG, "TCP_MAXSEG" }, 848#if defined(TCP_CORK) 849 { TCP_CORK, "TCP_CORK" }, 850#endif 851#if defined(TCP_KEEPIDLE) 852 { TCP_KEEPIDLE, "TCP_KEEPIDLE" }, 853#endif 854#if defined(TCP_KEEPINTVL) 855 { TCP_KEEPINTVL, "TCP_KEEPINTVL" }, 856#endif 857#if defined(TCP_KEEPCNT) 858 { TCP_KEEPCNT, "TCP_KEEPCNT" }, 859#endif 860#if defined(TCP_NKEEP) 861 { TCP_NKEEP, "TCP_NKEEP" }, 862#endif 863#if defined(TCP_SYNCNT) 864 { TCP_SYNCNT, "TCP_SYNCNT" }, 865#endif 866#if defined(TCP_LINGER2) 867 { TCP_LINGER2, "TCP_LINGER2" }, 868#endif 869#if defined(TCP_DEFER_ACCEPT) 870 { TCP_DEFER_ACCEPT, "TCP_DEFER_ACCEPT" }, 871#endif 872#if defined(TCP_WINDOW_CLAMP) 873 { TCP_WINDOW_CLAMP, "TCP_WINDOW_CLAMP" }, 874#endif 875#if defined(TCP_INFO) 876 { TCP_INFO, "TCP_INFO" }, 877#endif 878#if defined(TCP_QUICKACK) 879 { TCP_QUICKACK, "TCP_QUICKACK" }, 880#endif 881 { 0, NULL }, 882}; 883#endif /* SOL_TCP */ 884 885#ifdef SOL_RAW 886static const struct xlat icmpfilterflags[] = { 887#if defined(ICMP_ECHOREPLY) 888 { (1<<ICMP_ECHOREPLY), "ICMP_ECHOREPLY" }, 889#endif 890#if defined(ICMP_DEST_UNREACH) 891 { (1<<ICMP_DEST_UNREACH), "ICMP_DEST_UNREACH" }, 892#endif 893#if defined(ICMP_SOURCE_QUENCH) 894 { (1<<ICMP_SOURCE_QUENCH), "ICMP_SOURCE_QUENCH" }, 895#endif 896#if defined(ICMP_REDIRECT) 897 { (1<<ICMP_REDIRECT), "ICMP_REDIRECT" }, 898#endif 899#if defined(ICMP_ECHO) 900 { (1<<ICMP_ECHO), "ICMP_ECHO" }, 901#endif 902#if defined(ICMP_TIME_EXCEEDED) 903 { (1<<ICMP_TIME_EXCEEDED), "ICMP_TIME_EXCEEDED" }, 904#endif 905#if defined(ICMP_PARAMETERPROB) 906 { (1<<ICMP_PARAMETERPROB), "ICMP_PARAMETERPROB" }, 907#endif 908#if defined(ICMP_TIMESTAMP) 909 { (1<<ICMP_TIMESTAMP), "ICMP_TIMESTAMP" }, 910#endif 911#if defined(ICMP_TIMESTAMPREPLY) 912 { (1<<ICMP_TIMESTAMPREPLY), "ICMP_TIMESTAMPREPLY" }, 913#endif 914#if defined(ICMP_INFO_REQUEST) 915 { (1<<ICMP_INFO_REQUEST), "ICMP_INFO_REQUEST" }, 916#endif 917#if defined(ICMP_INFO_REPLY) 918 { (1<<ICMP_INFO_REPLY), "ICMP_INFO_REPLY" }, 919#endif 920#if defined(ICMP_ADDRESS) 921 { (1<<ICMP_ADDRESS), "ICMP_ADDRESS" }, 922#endif 923#if defined(ICMP_ADDRESSREPLY) 924 { (1<<ICMP_ADDRESSREPLY), "ICMP_ADDRESSREPLY" }, 925#endif 926 { 0, NULL }, 927}; 928#endif /* SOL_RAW */ 929 930#if defined(AF_PACKET) /* from e.g. linux/if_packet.h */ 931static const struct xlat af_packet_types[] = { 932#if defined(PACKET_HOST) 933 { PACKET_HOST, "PACKET_HOST" }, 934#endif 935#if defined(PACKET_BROADCAST) 936 { PACKET_BROADCAST, "PACKET_BROADCAST" }, 937#endif 938#if defined(PACKET_MULTICAST) 939 { PACKET_MULTICAST, "PACKET_MULTICAST" }, 940#endif 941#if defined(PACKET_OTHERHOST) 942 { PACKET_OTHERHOST, "PACKET_OTHERHOST" }, 943#endif 944#if defined(PACKET_OUTGOING) 945 { PACKET_OUTGOING, "PACKET_OUTGOING" }, 946#endif 947#if defined(PACKET_LOOPBACK) 948 { PACKET_LOOPBACK, "PACKET_LOOPBACK" }, 949#endif 950#if defined(PACKET_FASTROUTE) 951 { PACKET_FASTROUTE, "PACKET_FASTROUTE" }, 952#endif 953 { 0, NULL }, 954}; 955#endif /* defined(AF_PACKET) */ 956 957 958void 959printsock(struct tcb *tcp, long addr, int addrlen) 960{ 961 union { 962 char pad[128]; 963 struct sockaddr sa; 964 struct sockaddr_in sin; 965 struct sockaddr_un sau; 966#ifdef HAVE_INET_NTOP 967 struct sockaddr_in6 sa6; 968#endif 969#if defined(LINUX) && defined(AF_IPX) 970 struct sockaddr_ipx sipx; 971#endif 972#ifdef AF_PACKET 973 struct sockaddr_ll ll; 974#endif 975#ifdef AF_NETLINK 976 struct sockaddr_nl nl; 977#endif 978 } addrbuf; 979 char string_addr[100]; 980 981 if (addr == 0) { 982 tprintf("NULL"); 983 return; 984 } 985 if (!verbose(tcp)) { 986 tprintf("%#lx", addr); 987 return; 988 } 989 990 if (addrlen < 2 || addrlen > sizeof(addrbuf)) 991 addrlen = sizeof(addrbuf); 992 993 memset(&addrbuf, 0, sizeof(addrbuf)); 994 if (umoven(tcp, addr, addrlen, addrbuf.pad) < 0) { 995 tprintf("{...}"); 996 return; 997 } 998 addrbuf.pad[sizeof(addrbuf.pad) - 1] = '\0'; 999 1000 tprintf("{sa_family="); 1001 printxval(addrfams, addrbuf.sa.sa_family, "AF_???"); 1002 tprintf(", "); 1003 1004 switch (addrbuf.sa.sa_family) { 1005 case AF_UNIX: 1006 if (addrlen == 2) { 1007 tprintf("NULL"); 1008 } else if (addrbuf.sau.sun_path[0]) { 1009 tprintf("path="); 1010 printpathn(tcp, addr + 2, strlen(addrbuf.sau.sun_path)); 1011 } else { 1012 tprintf("path=@"); 1013 printpathn(tcp, addr + 3, strlen(addrbuf.sau.sun_path + 1)); 1014 } 1015 break; 1016 case AF_INET: 1017 tprintf("sin_port=htons(%u), sin_addr=inet_addr(\"%s\")", 1018 ntohs(addrbuf.sin.sin_port), inet_ntoa(addrbuf.sin.sin_addr)); 1019 break; 1020#ifdef HAVE_INET_NTOP 1021 case AF_INET6: 1022 inet_ntop(AF_INET6, &addrbuf.sa6.sin6_addr, string_addr, sizeof(string_addr)); 1023 tprintf("sin6_port=htons(%u), inet_pton(AF_INET6, \"%s\", &sin6_addr), sin6_flowinfo=%u", 1024 ntohs(addrbuf.sa6.sin6_port), string_addr, 1025 addrbuf.sa6.sin6_flowinfo); 1026#ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID 1027 { 1028#if defined(HAVE_IF_INDEXTONAME) && defined(IN6_IS_ADDR_LINKLOCAL) && defined(IN6_IS_ADDR_MC_LINKLOCAL) 1029 int numericscope = 0; 1030 if (IN6_IS_ADDR_LINKLOCAL (&addrbuf.sa6.sin6_addr) 1031 || IN6_IS_ADDR_MC_LINKLOCAL (&addrbuf.sa6.sin6_addr)) { 1032 char scopebuf[IFNAMSIZ + 1]; 1033 1034 if (if_indextoname (addrbuf.sa6.sin6_scope_id, scopebuf) == NULL) 1035 numericscope++; 1036 else 1037 tprintf(", sin6_scope_id=if_nametoindex(\"%s\")", scopebuf); 1038 } else 1039 numericscope++; 1040 1041 if (numericscope) 1042#endif 1043 tprintf(", sin6_scope_id=%u", addrbuf.sa6.sin6_scope_id); 1044 } 1045#endif 1046 break; 1047#endif 1048#if defined(AF_IPX) && defined(linux) 1049 case AF_IPX: 1050 { 1051 int i; 1052 tprintf("sipx_port=htons(%u), ", 1053 ntohs(addrbuf.sipx.sipx_port)); 1054 /* Yes, I know, this does not look too 1055 * strace-ish, but otherwise the IPX 1056 * addresses just look monstrous... 1057 * Anyways, feel free if you don't like 1058 * this way.. :) 1059 */ 1060 tprintf("%08lx:", (unsigned long)ntohl(addrbuf.sipx.sipx_network)); 1061 for (i = 0; i<IPX_NODE_LEN; i++) 1062 tprintf("%02x", addrbuf.sipx.sipx_node[i]); 1063 tprintf("/[%02x]", addrbuf.sipx.sipx_type); 1064 } 1065 break; 1066#endif /* AF_IPX && linux */ 1067#ifdef AF_PACKET 1068 case AF_PACKET: 1069 { 1070 int i; 1071 tprintf("proto=%#04x, if%d, pkttype=", 1072 ntohs(addrbuf.ll.sll_protocol), 1073 addrbuf.ll.sll_ifindex); 1074 printxval(af_packet_types, addrbuf.ll.sll_pkttype, "?"); 1075 tprintf(", addr(%d)={%d, ", 1076 addrbuf.ll.sll_halen, 1077 addrbuf.ll.sll_hatype); 1078 for (i=0; i<addrbuf.ll.sll_halen; i++) 1079 tprintf("%02x", addrbuf.ll.sll_addr[i]); 1080 } 1081 break; 1082 1083#endif /* AF_APACKET */ 1084#ifdef AF_NETLINK 1085 case AF_NETLINK: 1086 tprintf("pid=%d, groups=%08x", addrbuf.nl.nl_pid, addrbuf.nl.nl_groups); 1087 break; 1088#endif /* AF_NETLINK */ 1089 /* AF_AX25 AF_APPLETALK AF_NETROM AF_BRIDGE AF_AAL5 1090 AF_X25 AF_ROSE etc. still need to be done */ 1091 1092 default: 1093 tprintf("sa_data="); 1094 printstr(tcp, (long) &((struct sockaddr *) addr)->sa_data, 1095 sizeof addrbuf.sa.sa_data); 1096 break; 1097 } 1098 tprintf("}"); 1099} 1100 1101#if HAVE_SENDMSG 1102static const struct xlat scmvals[] = { 1103#ifdef SCM_RIGHTS 1104 { SCM_RIGHTS, "SCM_RIGHTS" }, 1105#endif 1106#ifdef SCM_CREDENTIALS 1107 { SCM_CREDENTIALS, "SCM_CREDENTIALS" }, 1108#endif 1109 { 0, NULL } 1110}; 1111 1112static void 1113printcmsghdr(tcp, addr, len) 1114struct tcb *tcp; 1115unsigned long addr; 1116unsigned long len; 1117{ 1118 struct cmsghdr *cmsg = len < sizeof(struct cmsghdr) ? 1119 NULL : malloc(len); 1120 if (cmsg == NULL || umoven(tcp, addr, len, (char *) cmsg) < 0) { 1121 tprintf(", msg_control=%#lx", addr); 1122 free(cmsg); 1123 return; 1124 } 1125 1126 tprintf(", {cmsg_len=%zu, cmsg_level=", cmsg->cmsg_len); 1127 printxval(socketlayers, cmsg->cmsg_level, "SOL_???"); 1128 tprintf(", cmsg_type="); 1129 1130 if (cmsg->cmsg_level == SOL_SOCKET) { 1131 unsigned long cmsg_len; 1132 1133 printxval(scmvals, cmsg->cmsg_type, "SCM_???"); 1134 cmsg_len = (len < cmsg->cmsg_len) ? len : cmsg->cmsg_len; 1135 1136 if (cmsg->cmsg_type == SCM_RIGHTS 1137 && CMSG_LEN(sizeof(int)) <= cmsg_len) { 1138 int *fds = (int *) CMSG_DATA (cmsg); 1139 int first = 1; 1140 1141 tprintf(", {"); 1142 while ((char *) fds < ((char *) cmsg + cmsg_len)) { 1143 if (!first) 1144 tprintf(", "); 1145 tprintf("%d", *fds++); 1146 first = 0; 1147 } 1148 tprintf("}}"); 1149 free(cmsg); 1150 return; 1151 } 1152 if (cmsg->cmsg_type == SCM_CREDENTIALS 1153 && CMSG_LEN(sizeof(struct ucred)) <= cmsg_len) { 1154 struct ucred *uc = (struct ucred *) CMSG_DATA (cmsg); 1155 1156 tprintf("{pid=%ld, uid=%ld, gid=%ld}}", 1157 (long)uc->pid, (long)uc->uid, (long)uc->gid); 1158 free(cmsg); 1159 return; 1160 } 1161 } 1162 free(cmsg); 1163 tprintf(", ...}"); 1164} 1165 1166static void 1167printmsghdr(tcp, addr) 1168struct tcb *tcp; 1169long addr; 1170{ 1171 struct msghdr msg; 1172 1173 if (umove(tcp, addr, &msg) < 0) { 1174 tprintf("%#lx", addr); 1175 return; 1176 } 1177 tprintf("{msg_name(%d)=", msg.msg_namelen); 1178 printsock(tcp, (long)msg.msg_name, msg.msg_namelen); 1179 1180 tprintf(", msg_iov(%lu)=", (unsigned long)msg.msg_iovlen); 1181 tprint_iov(tcp, (unsigned long)msg.msg_iovlen, 1182 (unsigned long)msg.msg_iov); 1183 1184#ifdef HAVE_STRUCT_MSGHDR_MSG_CONTROL 1185 tprintf(", msg_controllen=%lu", (unsigned long)msg.msg_controllen); 1186 if (msg.msg_controllen) 1187 printcmsghdr(tcp, (unsigned long) msg.msg_control, 1188 msg.msg_controllen); 1189 tprintf(", msg_flags="); 1190 printflags(msg_flags, msg.msg_flags, "MSG_???"); 1191#else /* !HAVE_STRUCT_MSGHDR_MSG_CONTROL */ 1192 tprintf("msg_accrights=%#lx, msg_accrightslen=%u", 1193 (unsigned long) msg.msg_accrights, msg.msg_accrightslen); 1194#endif /* !HAVE_STRUCT_MSGHDR_MSG_CONTROL */ 1195 tprintf("}"); 1196} 1197 1198#endif /* HAVE_SENDMSG */ 1199 1200/* 1201 * low bits of the socket type define real socket type, 1202 * other bits are socket type flags. 1203 */ 1204static void 1205tprint_sock_type(struct tcb *tcp, int flags) 1206{ 1207 const char *str = xlookup(socktypes, flags & SOCK_TYPE_MASK); 1208 1209 if (str) 1210 { 1211 tprintf("%s", str); 1212 flags &= ~SOCK_TYPE_MASK; 1213 if (!flags) 1214 return; 1215 tprintf("|"); 1216 } 1217 printflags(sock_type_flags, flags, "SOCK_???"); 1218} 1219 1220int 1221sys_socket(struct tcb *tcp) 1222{ 1223 if (entering(tcp)) { 1224 printxval(domains, tcp->u_arg[0], "PF_???"); 1225 tprintf(", "); 1226 tprint_sock_type(tcp, tcp->u_arg[1]); 1227 tprintf(", "); 1228 switch (tcp->u_arg[0]) { 1229 case PF_INET: 1230#ifdef PF_INET6 1231 case PF_INET6: 1232#endif 1233 printxval(protocols, tcp->u_arg[2], "IPPROTO_???"); 1234 break; 1235#ifdef PF_IPX 1236 case PF_IPX: 1237 /* BTW: I don't believe this.. */ 1238 tprintf("["); 1239 printxval(domains, tcp->u_arg[2], "PF_???"); 1240 tprintf("]"); 1241 break; 1242#endif /* PF_IPX */ 1243 default: 1244 tprintf("%lu", tcp->u_arg[2]); 1245 break; 1246 } 1247 } 1248 return 0; 1249} 1250 1251#ifdef SVR4 1252int 1253sys_so_socket(tcp) 1254struct tcb *tcp; 1255{ 1256 if (entering(tcp)) { 1257 /* not sure really what these args are... but this 1258 * is how truss prints it 1259 */ 1260 tprintf("%ld, %ld, %ld, ", 1261 tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]); 1262 printpath(tcp, tcp->u_arg[3]); 1263 tprintf(", %ld", tcp->u_arg[4]); 1264 } 1265 return 0; 1266} 1267 1268int 1269sys_so_socketpair(tcp) 1270struct tcb *tcp; 1271{ 1272 if (entering(tcp)) { 1273 /* not sure what this arg is */ 1274 tprintf("0x%lx", tcp->u_arg[0]); 1275 } 1276 return 0; 1277} 1278#endif /* SVR4 */ 1279 1280int 1281sys_bind(tcp) 1282struct tcb *tcp; 1283{ 1284 if (entering(tcp)) { 1285 tprintf("%ld, ", tcp->u_arg[0]); 1286 printsock(tcp, tcp->u_arg[1], tcp->u_arg[2]); 1287 tprintf(", %lu", tcp->u_arg[2]); 1288 } 1289 return 0; 1290} 1291 1292int 1293sys_connect(tcp) 1294struct tcb *tcp; 1295{ 1296 return sys_bind(tcp); 1297} 1298 1299int 1300sys_listen(tcp) 1301struct tcb *tcp; 1302{ 1303 if (entering(tcp)) { 1304 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]); 1305 } 1306 return 0; 1307} 1308 1309int 1310sys_accept(tcp) 1311struct tcb *tcp; 1312{ 1313 if (entering(tcp)) { 1314 tprintf("%ld, ", tcp->u_arg[0]); 1315 } else if (!tcp->u_arg[2]) 1316 tprintf("%#lx, NULL", tcp->u_arg[1]); 1317 else { 1318 int len; 1319 if (tcp->u_arg[1] == 0 || syserror(tcp) 1320 || umove (tcp, tcp->u_arg[2], &len) < 0) { 1321 tprintf("%#lx", tcp->u_arg[1]); 1322 } else { 1323 printsock(tcp, tcp->u_arg[1], len); 1324 } 1325 tprintf(", "); 1326 printnum_int(tcp, tcp->u_arg[2], "%u"); 1327 } 1328 return 0; 1329} 1330 1331int 1332sys_send(tcp) 1333struct tcb *tcp; 1334{ 1335 if (entering(tcp)) { 1336 tprintf("%ld, ", tcp->u_arg[0]); 1337 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); 1338 tprintf(", %lu, ", tcp->u_arg[2]); 1339 /* flags */ 1340 printflags(msg_flags, tcp->u_arg[3], "MSG_???"); 1341 } 1342 return 0; 1343} 1344 1345int 1346sys_sendto(tcp) 1347struct tcb *tcp; 1348{ 1349 if (entering(tcp)) { 1350 tprintf("%ld, ", tcp->u_arg[0]); 1351 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); 1352 tprintf(", %lu, ", tcp->u_arg[2]); 1353 /* flags */ 1354 printflags(msg_flags, tcp->u_arg[3], "MSG_???"); 1355 /* to address */ 1356 tprintf(", "); 1357 printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]); 1358 /* to length */ 1359 tprintf(", %lu", tcp->u_arg[5]); 1360 } 1361 return 0; 1362} 1363 1364#ifdef HAVE_SENDMSG 1365 1366int 1367sys_sendmsg(tcp) 1368struct tcb *tcp; 1369{ 1370 if (entering(tcp)) { 1371 tprintf("%ld, ", tcp->u_arg[0]); 1372 printmsghdr(tcp, tcp->u_arg[1]); 1373 /* flags */ 1374 tprintf(", "); 1375 printflags(msg_flags, tcp->u_arg[2], "MSG_???"); 1376 } 1377 return 0; 1378} 1379 1380#endif /* HAVE_SENDMSG */ 1381 1382int 1383sys_recv(tcp) 1384struct tcb *tcp; 1385{ 1386 if (entering(tcp)) { 1387 tprintf("%ld, ", tcp->u_arg[0]); 1388 } else { 1389 if (syserror(tcp)) 1390 tprintf("%#lx", tcp->u_arg[1]); 1391 else 1392 printstr(tcp, tcp->u_arg[1], tcp->u_rval); 1393 1394 tprintf(", %lu, ", tcp->u_arg[2]); 1395 printflags(msg_flags, tcp->u_arg[3], "MSG_???"); 1396 } 1397 return 0; 1398} 1399 1400int 1401sys_recvfrom(tcp) 1402struct tcb *tcp; 1403{ 1404 int fromlen; 1405 1406 if (entering(tcp)) { 1407 tprintf("%ld, ", tcp->u_arg[0]); 1408 } else { 1409 if (syserror(tcp)) { 1410 tprintf("%#lx, %lu, %lu, %#lx, %#lx", 1411 tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3], 1412 tcp->u_arg[4], tcp->u_arg[5]); 1413 return 0; 1414 } 1415 /* buf */ 1416 printstr(tcp, tcp->u_arg[1], tcp->u_rval); 1417 /* len */ 1418 tprintf(", %lu, ", tcp->u_arg[2]); 1419 /* flags */ 1420 printflags(msg_flags, tcp->u_arg[3], "MSG_???"); 1421 /* from address, len */ 1422 if (!tcp->u_arg[4] || !tcp->u_arg[5]) { 1423 if (tcp->u_arg[4] == 0) 1424 tprintf(", NULL"); 1425 else 1426 tprintf(", %#lx", tcp->u_arg[4]); 1427 if (tcp->u_arg[5] == 0) 1428 tprintf(", NULL"); 1429 else 1430 tprintf(", %#lx", tcp->u_arg[5]); 1431 return 0; 1432 } 1433 if (umove(tcp, tcp->u_arg[5], &fromlen) < 0) { 1434 tprintf(", {...}, [?]"); 1435 return 0; 1436 } 1437 tprintf(", "); 1438 printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]); 1439 /* from length */ 1440 tprintf(", [%u]", fromlen); 1441 } 1442 return 0; 1443} 1444 1445#ifdef HAVE_SENDMSG 1446 1447int 1448sys_recvmsg(tcp) 1449struct tcb *tcp; 1450{ 1451 if (entering(tcp)) { 1452 tprintf("%ld, ", tcp->u_arg[0]); 1453 } else { 1454 if (syserror(tcp) || !verbose(tcp)) 1455 tprintf("%#lx", tcp->u_arg[1]); 1456 else 1457 printmsghdr(tcp, tcp->u_arg[1]); 1458 /* flags */ 1459 tprintf(", "); 1460 printflags(msg_flags, tcp->u_arg[2], "MSG_???"); 1461 } 1462 return 0; 1463} 1464 1465#endif /* HAVE_SENDMSG */ 1466 1467int 1468sys_shutdown(tcp) 1469struct tcb *tcp; 1470{ 1471 if (entering(tcp)) { 1472 tprintf("%ld, %ld", tcp->u_arg[0], tcp->u_arg[1]); 1473 switch (tcp->u_arg[1]) { 1474 case 0: 1475 tprintf("%s", " /* receive */"); 1476 break; 1477 case 1: 1478 tprintf("%s", " /* send */"); 1479 break; 1480 case 2: 1481 tprintf("%s", " /* send and receive */"); 1482 break; 1483 } 1484 } 1485 return 0; 1486} 1487 1488int 1489sys_getsockname(tcp) 1490struct tcb *tcp; 1491{ 1492 return sys_accept(tcp); 1493} 1494 1495int 1496sys_getpeername(tcp) 1497struct tcb *tcp; 1498{ 1499 return sys_accept(tcp); 1500} 1501 1502static int 1503do_pipe(struct tcb *tcp, int flags_arg) 1504{ 1505 if (exiting(tcp)) { 1506 if (syserror(tcp)) { 1507 tprintf("%#lx", tcp->u_arg[0]); 1508 } else { 1509#if defined(LINUX) && !defined(SPARC) && !defined(SPARC64) && !defined(SH) && !defined(IA64) 1510 int fds[2]; 1511 1512 if (umoven(tcp, tcp->u_arg[0], sizeof fds, (char *) fds) < 0) 1513 tprintf("[...]"); 1514 else 1515 tprintf("[%u, %u]", fds[0], fds[1]); 1516#elif defined(SPARC) || defined(SPARC64) || defined(SH) || defined(SVR4) || defined(FREEBSD) || defined(IA64) 1517 tprintf("[%lu, %lu]", tcp->u_rval, getrval2(tcp)); 1518#else 1519 tprintf("%#lx", tcp->u_arg[0]); 1520#endif 1521 } 1522 if (flags_arg >= 0) { 1523 tprintf(", "); 1524 printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???"); 1525 } 1526 } 1527 return 0; 1528} 1529 1530int 1531sys_pipe(struct tcb *tcp) 1532{ 1533 return do_pipe(tcp, -1); 1534} 1535 1536#ifdef LINUX 1537int 1538sys_pipe2(struct tcb *tcp) 1539{ 1540 return do_pipe(tcp, 1); 1541} 1542#endif 1543 1544int 1545sys_socketpair(struct tcb *tcp) 1546{ 1547#ifdef LINUX 1548 int fds[2]; 1549#endif 1550 1551 if (entering(tcp)) { 1552 printxval(domains, tcp->u_arg[0], "PF_???"); 1553 tprintf(", "); 1554 tprint_sock_type(tcp, tcp->u_arg[1]); 1555 tprintf(", "); 1556 switch (tcp->u_arg[0]) { 1557 case PF_INET: 1558 printxval(protocols, tcp->u_arg[2], "IPPROTO_???"); 1559 break; 1560#ifdef PF_IPX 1561 case PF_IPX: 1562 /* BTW: I don't believe this.. */ 1563 tprintf("["); 1564 printxval(domains, tcp->u_arg[2], "PF_???"); 1565 tprintf("]"); 1566 break; 1567#endif /* PF_IPX */ 1568 default: 1569 tprintf("%lu", tcp->u_arg[2]); 1570 break; 1571 } 1572 } else { 1573 if (syserror(tcp)) { 1574 tprintf(", %#lx", tcp->u_arg[3]); 1575 return 0; 1576 } 1577#ifdef LINUX 1578 if (umoven(tcp, tcp->u_arg[3], sizeof fds, (char *) fds) < 0) 1579 tprintf(", [...]"); 1580 else 1581 tprintf(", [%u, %u]", fds[0], fds[1]); 1582#endif /* LINUX */ 1583#if defined(SUNOS4) || defined(SVR4) || defined(FREEBSD) 1584 tprintf(", [%lu, %lu]", tcp->u_rval, getrval2(tcp)); 1585#endif /* SUNOS4 || SVR4 || FREEBSD */ 1586 } 1587 return 0; 1588} 1589 1590int 1591sys_getsockopt(tcp) 1592struct tcb *tcp; 1593{ 1594 if (entering(tcp)) { 1595 tprintf("%ld, ", tcp->u_arg[0]); 1596 printxval(socketlayers, tcp->u_arg[1], "SOL_???"); 1597 tprintf (", "); 1598 switch (tcp->u_arg[1]) { 1599 case SOL_SOCKET: 1600 printxval(sockoptions, tcp->u_arg[2], "SO_???"); 1601 break; 1602#ifdef SOL_IP 1603 case SOL_IP: 1604 printxval(sockipoptions, tcp->u_arg[2], "IP_???"); 1605 break; 1606#endif 1607#ifdef SOL_IPV6 1608 case SOL_IPV6: 1609 printxval(sockipv6options, tcp->u_arg[2], "IPV6_???"); 1610 break; 1611#endif 1612#ifdef SOL_IPX 1613 case SOL_IPX: 1614 printxval(sockipxoptions, tcp->u_arg[2], "IPX_???"); 1615 break; 1616#endif 1617#ifdef SOL_PACKET 1618 case SOL_PACKET: 1619 printxval(sockpacketoptions, tcp->u_arg[2], "PACKET_???"); 1620 break; 1621#endif 1622#ifdef SOL_TCP 1623 case SOL_TCP: 1624 printxval(socktcpoptions, tcp->u_arg[2], "TCP_???"); 1625 break; 1626#endif 1627 1628 /* SOL_AX25 SOL_ROSE SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25 1629 * etc. still need work */ 1630 default: 1631 tprintf("%lu", tcp->u_arg[2]); 1632 break; 1633 } 1634 } else { 1635 int len; 1636 if (syserror(tcp) || umove (tcp, tcp->u_arg[4], &len) < 0) { 1637 tprintf(", %#lx, %#lx", 1638 tcp->u_arg[3], tcp->u_arg[4]); 1639 return 0; 1640 } 1641 1642 switch (tcp->u_arg[1]) { 1643 case SOL_SOCKET: 1644 switch (tcp->u_arg[2]) { 1645#ifdef SO_LINGER 1646 case SO_LINGER: 1647 if (len == sizeof (struct linger)) { 1648 struct linger linger; 1649 if (umove (tcp, 1650 tcp->u_arg[3], 1651 &linger) < 0) 1652 break; 1653 tprintf(", {onoff=%d, linger=%d}, " 1654 "[%d]", 1655 linger.l_onoff, 1656 linger.l_linger, 1657 len); 1658 return 0; 1659 } 1660 break; 1661#endif 1662 } 1663 break; 1664 } 1665 1666 tprintf (", "); 1667 if (len == sizeof (int)) { 1668 printnum(tcp, tcp->u_arg[3], "%ld"); 1669 } 1670 else { 1671 printstr (tcp, tcp->u_arg[3], len); 1672 } 1673 tprintf(", [%d]", len); 1674 } 1675 return 0; 1676} 1677 1678#if defined(ICMP_FILTER) 1679static void printicmpfilter(tcp, addr) 1680struct tcb *tcp; 1681long addr; 1682{ 1683 struct icmp_filter filter; 1684 1685 if (!addr) { 1686 tprintf("NULL"); 1687 return; 1688 } 1689 if (syserror(tcp) || !verbose(tcp)) { 1690 tprintf("%#lx", addr); 1691 return; 1692 } 1693 if (umove(tcp, addr, &filter) < 0) { 1694 tprintf("{...}"); 1695 return; 1696 } 1697 1698 tprintf("~("); 1699 printflags(icmpfilterflags, ~filter.data, "ICMP_???"); 1700 tprintf(")"); 1701} 1702#endif /* ICMP_FILTER */ 1703 1704static int 1705printsockopt (tcp, level, name, addr, len) 1706struct tcb *tcp; 1707int level; 1708int name; 1709long addr; 1710int len; 1711{ 1712 printxval(socketlayers, level, "SOL_??"); 1713 tprintf (", "); 1714 switch (level) { 1715 case SOL_SOCKET: 1716 printxval(sockoptions, name, "SO_???"); 1717 switch (name) { 1718#if defined(SO_LINGER) 1719 case SO_LINGER: 1720 if (len == sizeof (struct linger)) { 1721 struct linger linger; 1722 if (umove (tcp, addr, &linger) < 0) 1723 break; 1724 tprintf(", {onoff=%d, linger=%d}", 1725 linger.l_onoff, 1726 linger.l_linger); 1727 return 0; 1728 } 1729 break; 1730#endif 1731 } 1732 break; 1733#ifdef SOL_IP 1734 case SOL_IP: 1735 printxval(sockipoptions, name, "IP_???"); 1736 break; 1737#endif 1738#ifdef SOL_IPV6 1739 case SOL_IPV6: 1740 printxval(sockipv6options, name, "IPV6_???"); 1741 break; 1742#endif 1743#ifdef SOL_IPX 1744 case SOL_IPX: 1745 printxval(sockipxoptions, name, "IPX_???"); 1746 break; 1747#endif 1748#ifdef SOL_PACKET 1749 case SOL_PACKET: 1750 printxval(sockpacketoptions, name, "PACKET_???"); 1751 /* TODO: decode packate_mreq for PACKET_*_MEMBERSHIP */ 1752 break; 1753#endif 1754#ifdef SOL_TCP 1755 case SOL_TCP: 1756 printxval(socktcpoptions, name, "TCP_???"); 1757 break; 1758#endif 1759#ifdef SOL_RAW 1760 case SOL_RAW: 1761 printxval(sockrawoptions, name, "RAW_???"); 1762 switch (name) { 1763#if defined(ICMP_FILTER) 1764 case ICMP_FILTER: 1765 tprintf(", "); 1766 printicmpfilter(tcp, addr); 1767 return 0; 1768#endif 1769 } 1770 break; 1771#endif 1772 1773 /* SOL_AX25 SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25 1774 * etc. still need work */ 1775 1776 default: 1777 tprintf("%u", name); 1778 } 1779 1780 /* default arg printing */ 1781 1782 tprintf (", "); 1783 1784 if (len == sizeof (int)) { 1785 printnum_int (tcp, addr, "%d"); 1786 } 1787 else { 1788 printstr (tcp, addr, len); 1789 } 1790 return 0; 1791} 1792 1793 1794#ifdef HAVE_STRUCT_OPTHDR 1795 1796void 1797print_sock_optmgmt (tcp, addr, len) 1798struct tcb *tcp; 1799long addr; 1800int len; 1801{ 1802 int c = 0; 1803 struct opthdr hdr; 1804 1805 while (len >= (int) sizeof hdr) { 1806 if (umove(tcp, addr, &hdr) < 0) break; 1807 if (c++) { 1808 tprintf (", "); 1809 } 1810 else if (len > hdr.len + sizeof hdr) { 1811 tprintf ("["); 1812 } 1813 tprintf ("{"); 1814 addr += sizeof hdr; 1815 len -= sizeof hdr; 1816 printsockopt (tcp, hdr.level, hdr.name, addr, hdr.len); 1817 if (hdr.len > 0) { 1818 addr += hdr.len; 1819 len -= hdr.len; 1820 } 1821 tprintf ("}"); 1822 } 1823 if (len > 0) { 1824 if (c++) tprintf (", "); 1825 printstr (tcp, addr, len); 1826 } 1827 if (c > 1) tprintf ("]"); 1828} 1829 1830#endif 1831 1832int 1833sys_setsockopt(tcp) 1834struct tcb *tcp; 1835{ 1836 if (entering(tcp)) { 1837 tprintf("%ld, ", tcp->u_arg[0]); 1838 printsockopt (tcp, tcp->u_arg[1], tcp->u_arg[2], 1839 tcp->u_arg[3], tcp->u_arg[4]); 1840 tprintf(", %lu", tcp->u_arg[4]); 1841 } 1842 return 0; 1843} 1844 1845#if UNIXWARE >= 7 1846 1847static const struct xlat sock_version[] = { 1848 { __NETLIB_UW211_SVR4, "UW211_SVR4" }, 1849 { __NETLIB_UW211_XPG4, "UW211_XPG4" }, 1850 { __NETLIB_GEMINI_SVR4, "GEMINI_SVR4" }, 1851 { __NETLIB_GEMINI_XPG4, "GEMINI_XPG4" }, 1852 { __NETLIB_FP1_SVR4, "FP1_SVR4" }, 1853 { __NETLIB_FP1_XPG4, "FP1_XPG4" }, 1854 { 0, NULL }, 1855}; 1856 1857 1858int 1859netlib_call(tcp, func) 1860struct tcb *tcp; 1861int (*func) (); 1862{ 1863 if (entering(tcp)) { 1864 int i; 1865 printxval (sock_version, tcp->u_arg[0], "__NETLIB_???"); 1866 tprintf(", "); 1867 --tcp->u_nargs; 1868 for (i = 0; i < tcp->u_nargs; i++) 1869 tcp->u_arg[i] = tcp->u_arg[i + 1]; 1870 return func (tcp); 1871 1872 } 1873 1874 return func (tcp); 1875} 1876 1877int 1878sys_xsocket(tcp) 1879struct tcb *tcp; 1880{ 1881 return netlib_call (tcp, sys_socket); 1882} 1883 1884int 1885sys_xsocketpair(tcp) 1886struct tcb *tcp; 1887{ 1888 return netlib_call (tcp, sys_socketpair); 1889} 1890 1891int 1892sys_xbind(tcp) 1893struct tcb *tcp; 1894{ 1895 return netlib_call (tcp, sys_bind); 1896} 1897 1898int 1899sys_xconnect(tcp) 1900struct tcb *tcp; 1901{ 1902 return netlib_call (tcp, sys_connect); 1903} 1904 1905int 1906sys_xlisten(tcp) 1907struct tcb *tcp; 1908{ 1909 return netlib_call (tcp, sys_listen); 1910} 1911 1912int 1913sys_xaccept(tcp) 1914struct tcb *tcp; 1915{ 1916 return netlib_call (tcp, sys_accept); 1917} 1918 1919int 1920sys_xsendmsg(tcp) 1921struct tcb *tcp; 1922{ 1923 return netlib_call (tcp, sys_sendmsg); 1924} 1925 1926int 1927sys_xrecvmsg(tcp) 1928struct tcb *tcp; 1929{ 1930 return netlib_call (tcp, sys_recvmsg); 1931} 1932 1933int 1934sys_xgetsockaddr(tcp) 1935struct tcb *tcp; 1936{ 1937 if (entering(tcp)) { 1938 printxval (sock_version, tcp->u_arg[0], "__NETLIB_???"); 1939 tprintf(", "); 1940 if (tcp->u_arg[1] == 0) { 1941 tprintf ("LOCALNAME, "); 1942 } 1943 else if (tcp->u_arg[1] == 1) { 1944 tprintf ("REMOTENAME, "); 1945 } 1946 else { 1947 tprintf ("%ld, ", tcp->u_arg [1]); 1948 } 1949 tprintf ("%ld, ", tcp->u_arg [2]); 1950 } 1951 else { 1952 if (tcp->u_arg[3] == 0 || syserror(tcp)) { 1953 tprintf("%#lx", tcp->u_arg[3]); 1954 } else { 1955 printsock(tcp, tcp->u_arg[3], tcp->u_arg[4]); 1956 } 1957 tprintf(", "); 1958 printnum(tcp, tcp->u_arg[4], "%lu"); 1959 } 1960 1961 return 0; 1962 1963} 1964 1965#if 0 1966 1967int 1968sys_xsetsockaddr(tcp) 1969struct tcb *tcp; 1970{ 1971 return netlib_call (tcp, sys_setsockaddr); 1972} 1973 1974#endif 1975 1976int 1977sys_xgetsockopt(tcp) 1978struct tcb *tcp; 1979{ 1980 return netlib_call (tcp, sys_getsockopt); 1981} 1982 1983int 1984sys_xsetsockopt(tcp) 1985struct tcb *tcp; 1986{ 1987 return netlib_call (tcp, sys_setsockopt); 1988} 1989 1990int 1991sys_xshutdown(tcp) 1992struct tcb *tcp; 1993{ 1994 return netlib_call (tcp, sys_shutdown); 1995} 1996 1997#endif 1998