net.c revision 1fcb1d64ed13836334d100af9412f220efa1bbfa
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 struct xlat domains[] = { 120 { PF_UNSPEC, "PF_UNSPEC" }, 121 { PF_UNIX, "PF_UNIX" }, 122 { PF_INET, "PF_INET" }, 123#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 138#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 165#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}; 179static struct xlat addrfams[] = { 180 { AF_UNSPEC, "AF_UNSPEC" }, 181 { AF_UNIX, "AF_UNIX" }, 182 { AF_INET, "AF_INET" }, 183#ifdef AF_INET6 184 { AF_INET6, "AF_INET6" }, 185#endif 186 { AF_DECnet, "AF_DECnet" }, 187#ifdef PF_ATMSVC 188 { AF_ATMSVC, "AF_ATMSVC" }, 189#endif 190#ifdef AF_PACKET 191 { AF_PACKET, "AF_PACKET" }, 192#endif 193#ifdef AF_NETLINK 194 { AF_NETLINK, "AF_NETLINK" }, 195#endif 196#ifdef AF_ISO 197 { AF_ISO, "AF_ISO" }, 198#endif 199#ifdef AF_IMPLINK 200 { AF_IMPLINK, "AF_IMPLINK" }, 201#endif 202 { 0, NULL }, 203}; 204static 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}; 221static struct xlat socketlayers[] = { 222#if defined(SOL_IP) 223 { SOL_IP, "SOL_IP" }, 224#endif 225#if defined(SOL_ICMP) 226 { SOL_ICMP, "SOL_ICMP" }, 227#endif 228#if defined(SOL_TCP) 229 { SOL_TCP, "SOL_TCP" }, 230#endif 231#if defined(SOL_UDP) 232 { SOL_UDP, "SOL_UDP" }, 233#endif 234#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 279 { SOL_SOCKET, "SOL_SOCKET" }, /* Never used! */ 280}; 281static struct xlat protocols[] = { 282 { IPPROTO_IP, "IPPROTO_IP" }, 283 { IPPROTO_ICMP, "IPPROTO_ICMP" }, 284 { IPPROTO_TCP, "IPPROTO_TCP" }, 285 { IPPROTO_UDP, "IPPROTO_UDP" }, 286#ifdef IPPROTO_GGP 287 { IPPROTO_GGP, "IPPROTO_GGP" }, 288#endif 289#ifdef IPPROTO_EGP 290 { IPPROTO_EGP, "IPPROTO_EGP" }, 291#endif 292#ifdef IPPROTO_PUP 293 { IPPROTO_PUP, "IPPROTO_PUP" }, 294#endif 295#ifdef IPPROTO_IDP 296 { IPPROTO_IDP, "IPPROTO_IDP" }, 297#endif 298#ifdef IPPROTO_IPV6 299 { IPPROTO_IPV6, "IPPROTO_IPV6" }, 300#endif 301#ifdef IPPROTO_ICMPV6 302 { IPPROTO_ICMPV6,"IPPROTO_ICMPV6"}, 303#endif 304#ifdef IPPROTO_IGMP 305 { IPPROTO_IGMP, "IPPROTO_IGMP" }, 306#endif 307#ifdef IPPROTO_HELLO 308 { IPPROTO_HELLO,"IPPROTO_HELLO" }, 309#endif 310#ifdef IPPROTO_ND 311 { IPPROTO_ND, "IPPROTO_ND" }, 312#endif 313#ifdef IPPROTO_RAW 314 { IPPROTO_RAW, "IPPROTO_RAW" }, 315#endif 316#ifdef IPPROTO_MAX 317 { IPPROTO_MAX, "IPPROTO_MAX" }, 318#endif 319#ifdef IPPROTO_IPIP 320 { IPPROTO_IPIP, "IPPROTO_IPIP" }, 321#endif 322 { 0, NULL }, 323}; 324static struct xlat msg_flags[] = { 325 { MSG_OOB, "MSG_OOB" }, 326#ifdef MSG_DONTROUTE 327 { MSG_DONTROUTE,"MSG_DONTROUTE" }, 328#endif 329#ifdef MSG_PEEK 330 { MSG_PEEK, "MSG_PEEK" }, 331#endif 332#ifdef MSG_CTRUNC 333 { MSG_CTRUNC, "MSG_CTRUNC" }, 334#endif 335#ifdef MSG_PROXY 336 { MSG_PROXY, "MSG_PROXY" }, 337#endif 338#ifdef MSG_EOR 339 { MSG_EOR, "MSG_EOR" }, 340#endif 341#ifdef MSG_WAITALL 342 { MSG_WAITALL, "MSG_WAITALL" }, 343#endif 344#ifdef MSG_TRUNC 345 { MSG_TRUNC, "MSG_TRUNC" }, 346#endif 347#ifdef MSG_CTRUNC 348 { MSG_CTRUNC, "MSG_CTRUNC" }, 349#endif 350#ifdef MSG_ERRQUEUE 351 { MSG_ERRQUEUE, "MSG_ERRQUEUE" }, 352#endif 353#ifdef MSG_DONTWAIT 354 { MSG_DONTWAIT, "MSG_DONTWAIT" }, 355#endif 356#ifdef MSG_CONFIRM 357 { MSG_CONFIRM, "MSG_CONFIRM" }, 358#endif 359#ifdef MSG_PROBE 360 { MSG_PROBE, "MSG_PROBE" }, 361#endif 362 { 0, NULL }, 363}; 364 365static struct xlat sockoptions[] = { 366#ifdef SO_PEERCRED 367 { SO_PEERCRED, "SO_PEERCRED" }, 368#endif 369#ifdef SO_PASSCRED 370 { SO_PASSCRED, "SO_PASSCRED" }, 371#endif 372#ifdef SO_DEBUG 373 { SO_DEBUG, "SO_DEBUG" }, 374#endif 375#ifdef SO_REUSEADDR 376 { SO_REUSEADDR, "SO_REUSEADDR" }, 377#endif 378#ifdef SO_KEEPALIVE 379 { SO_KEEPALIVE, "SO_KEEPALIVE" }, 380#endif 381#ifdef SO_DONTROUTE 382 { SO_DONTROUTE, "SO_DONTROUTE" }, 383#endif 384#ifdef SO_BROADCAST 385 { SO_BROADCAST, "SO_BROADCAST" }, 386#endif 387#ifdef SO_LINGER 388 { SO_LINGER, "SO_LINGER" }, 389#endif 390#ifdef SO_OOBINLINE 391 { SO_OOBINLINE, "SO_OOBINLINE" }, 392#endif 393#ifdef SO_TYPE 394 { SO_TYPE, "SO_TYPE" }, 395#endif 396#ifdef SO_ERROR 397 { SO_ERROR, "SO_ERROR" }, 398#endif 399#ifdef SO_SNDBUF 400 { SO_SNDBUF, "SO_SNDBUF" }, 401#endif 402#ifdef SO_RCVBUF 403 { SO_RCVBUF, "SO_RCVBUF" }, 404#endif 405#ifdef SO_NO_CHECK 406 { SO_NO_CHECK, "SO_NO_CHECK" }, 407#endif 408#ifdef SO_PRIORITY 409 { SO_PRIORITY, "SO_PRIORITY" }, 410#endif 411#ifdef SO_ACCEPTCONN 412 { SO_ACCEPTCONN,"SO_ACCEPTCONN" }, 413#endif 414#ifdef SO_USELOOPBACK 415 { SO_USELOOPBACK,"SO_USELOOPBACK"}, 416#endif 417#ifdef SO_SNDLOWAT 418 { SO_SNDLOWAT, "SO_SNDLOWAT" }, 419#endif 420#ifdef SO_RCVLOWAT 421 { SO_RCVLOWAT, "SO_RCVLOWAT" }, 422#endif 423#ifdef SO_SNDTIMEO 424 { SO_SNDTIMEO, "SO_SNDTIMEO" }, 425#endif 426#ifdef SO_RCVTIMEO 427 { SO_RCVTIMEO, "SO_RCVTIMEO" }, 428#endif 429#ifdef SO_BSDCOMPAT 430 { SO_BSDCOMPAT, "SO_BSDCOMPAT" }, 431#endif 432#ifdef SO_REUSEPORT 433 { SO_REUSEPORT, "SO_REUSEPORT" }, 434#endif 435#ifdef SO_RCVLOWAT 436 { SO_RCVLOWAT, "SO_RCVLOWAT" }, 437#endif 438#ifdef SO_SNDLOWAT 439 { SO_SNDLOWAT, "SO_SNDLOWAT" }, 440#endif 441#ifdef SO_RCVTIMEO 442 { SO_RCVTIMEO, "SO_RCVTIMEO" }, 443#endif 444#ifdef SO_SNDTIMEO 445 { SO_SNDTIMEO, "SO_SNDTIMEO" }, 446#endif 447 { 0, NULL }, 448}; 449 450#ifdef SOL_IP 451static struct xlat sockipoptions[] = { 452 { IP_TOS, "IP_TOS" }, 453 { IP_TTL, "IP_TTL" }, 454#if defined(IP_HDRINCL) 455 { IP_HDRINCL, "IP_HDRINCL" }, 456#endif 457#if defined(IP_OPTIONS) 458 { IP_OPTIONS, "IP_OPTIONS" }, 459#endif 460 { IP_ROUTER_ALERT, "IP_ROUTER_ALERT" }, 461#if defined(IP_RECVOPTIONS) 462 { IP_RECVOPTIONS, "IP_RECVOPTIONS" }, 463#endif 464 { IP_RETOPTS, "IP_RETOPTS" }, 465 { IP_PKTINFO, "IP_PKTINFO" }, 466 { IP_PKTOPTIONS, "IP_PKTOPTIONS" }, 467 { IP_MTU_DISCOVER, "IP_MTU_DISCOVER" }, 468 { IP_MTU_DISCOVER, "IP_MTU_DISCOVER" }, 469 { IP_RECVERR, "IP_RECVERR" }, 470 { IP_RECVTTL, "IP_RECRECVTTL" }, 471 { IP_RECVTOS, "IP_RECRECVTOS" }, 472#if defined(IP_MTU) 473 { IP_MTU, "IP_MTU" }, 474#endif 475 { IP_MULTICAST_IF, "IP_MULTICAST_IF" }, 476 { IP_MULTICAST_TTL, "IP_MULTICAST_TTL" }, 477 { IP_MULTICAST_LOOP, "IP_MULTICAST_LOOP" }, 478 { IP_ADD_MEMBERSHIP, "IP_ADD_MEMBERSHIP" }, 479 { IP_DROP_MEMBERSHIP, "IP_DROP_MEMBERSHIP" }, 480 { 0, NULL }, 481}; 482#endif /* SOL_IP */ 483 484#ifdef SOL_IPX 485static struct xlat sockipxoptions[] = { 486 { IPX_TYPE, "IPX_TYPE" }, 487 { 0, NULL }, 488}; 489#endif /* SOL_IPX */ 490 491#ifdef SOL_RAW 492static struct xlat sockrawoptions[] = { 493#if defined(ICMP_FILTER) 494 { ICMP_FILTER, "ICMP_FILTER" }, 495#endif 496 { 0, NULL }, 497}; 498#endif /* SOL_RAW */ 499 500#ifdef SOL_PACKET 501static struct xlat sockpacketoptions[] = { 502 { PACKET_ADD_MEMBERSHIP, "PACKET_ADD_MEMBERSHIP" }, 503 { PACKET_DROP_MEMBERSHIP, "PACKET_DROP_MEMBERSHIP"}, 504#if defined(PACKET_RECV_OUTPUT) 505 { PACKET_RECV_OUTPUT, "PACKET_RECV_OUTPUT" }, 506#endif 507#if defined(PACKET_RX_RING) 508 { PACKET_RX_RING, "PACKET_RX_RING" }, 509#endif 510#if defined(PACKET_STATISTICS) 511 { PACKET_STATISTICS, "PACKET_STATISTICS" }, 512#endif 513 { 0, NULL }, 514}; 515#endif /* SOL_PACKET */ 516 517#ifdef SOL_TCP 518static struct xlat socktcpoptions[] = { 519 { TCP_NODELAY, "TCP_NODELAY" }, 520 { TCP_MAXSEG, "TCP_MAXSEG" }, 521#if defined(TCP_CORK) 522 { TCP_CORK, "TCP_CORK" }, 523#endif 524 { 0, NULL }, 525}; 526#endif /* SOL_TCP */ 527 528#ifdef SOL_RAW 529static struct xlat icmpfilterflags[] = { 530#if defined(ICMP_ECHOREPLY) 531 { (1<<ICMP_ECHOREPLY), "ICMP_ECHOREPLY" }, 532#endif 533#if defined(ICMP_DEST_UNREACH) 534 { (1<<ICMP_DEST_UNREACH), "ICMP_DEST_UNREACH" }, 535#endif 536#if defined(ICMP_SOURCE_QUENCH) 537 { (1<<ICMP_SOURCE_QUENCH), "ICMP_SOURCE_QUENCH" }, 538#endif 539#if defined(ICMP_REDIRECT) 540 { (1<<ICMP_REDIRECT), "ICMP_REDIRECT" }, 541#endif 542#if defined(ICMP_ECHO) 543 { (1<<ICMP_ECHO), "ICMP_ECHO" }, 544#endif 545#if defined(ICMP_TIME_EXCEEDED) 546 { (1<<ICMP_TIME_EXCEEDED), "ICMP_TIME_EXCEEDED" }, 547#endif 548#if defined(ICMP_PARAMETERPROB) 549 { (1<<ICMP_PARAMETERPROB), "ICMP_PARAMETERPROB" }, 550#endif 551#if defined(ICMP_TIMESTAMP) 552 { (1<<ICMP_TIMESTAMP), "ICMP_TIMESTAMP" }, 553#endif 554#if defined(ICMP_TIMESTAMPREPLY) 555 { (1<<ICMP_TIMESTAMPREPLY), "ICMP_TIMESTAMPREPLY" }, 556#endif 557#if defined(ICMP_INFO_REQUEST) 558 { (1<<ICMP_INFO_REQUEST), "ICMP_INFO_REQUEST" }, 559#endif 560#if defined(ICMP_INFO_REPLY) 561 { (1<<ICMP_INFO_REPLY), "ICMP_INFO_REPLY" }, 562#endif 563#if defined(ICMP_ADDRESS) 564 { (1<<ICMP_ADDRESS), "ICMP_ADDRESS" }, 565#endif 566#if defined(ICMP_ADDRESSREPLY) 567 { (1<<ICMP_ADDRESSREPLY), "ICMP_ADDRESSREPLY" }, 568#endif 569 { 0, NULL }, 570}; 571#endif /* SOL_RAW */ 572 573 574void 575printsock(tcp, addr, addrlen) 576struct tcb *tcp; 577long addr; 578int addrlen; 579{ 580 union { 581 char pad[128]; 582 struct sockaddr sa; 583 struct sockaddr_in sin; 584 struct sockaddr_un sau; 585#ifdef HAVE_INET_NTOP 586 struct sockaddr_in6 sa6; 587#endif 588#if defined(LINUX) && defined(AF_IPX) 589 struct sockaddr_ipx sipx; 590#endif 591#ifdef AF_PACKET 592 struct sockaddr_ll ll; 593#endif 594#ifdef AF_NETLINK 595 struct sockaddr_nl nl; 596#endif 597 } addrbuf; 598 char string_addr[100]; 599 600 if (addr == 0) { 601 tprintf("NULL"); 602 return; 603 } 604 if (!verbose(tcp)) { 605 tprintf("%#lx", addr); 606 return; 607 } 608 if ((addrlen<2) || (addrlen>sizeof(addrbuf))) 609 addrlen=sizeof(addrbuf); 610 611 if (umoven(tcp, addr, addrlen, (char*)&addrbuf) < 0) { 612 tprintf("{...}"); 613 return; 614 } 615 616 tprintf("{sa_family="); 617 printxval(addrfams, addrbuf.sa.sa_family, "AF_???"); 618 tprintf(", "); 619 620 switch (addrbuf.sa.sa_family) { 621 case AF_UNIX: 622 if (addrlen==2) { 623 tprintf("<nil>"); 624 } else if (addrbuf.sau.sun_path[0]) { 625 tprintf("path=\"%-.*s\"", addrlen-2, addrbuf.sau.sun_path); 626 } else { 627 tprintf("path=@%-.*s", addrlen-3, addrbuf.sau.sun_path+1); 628 } 629 break; 630 case AF_INET: 631 tprintf("sin_port=htons(%u), sin_addr=inet_addr(\"%s\")", 632 ntohs(addrbuf.sin.sin_port), inet_ntoa(addrbuf.sin.sin_addr)); 633 break; 634#ifdef HAVE_INET_NTOP 635 case AF_INET6: 636 inet_ntop(AF_INET6, &addrbuf.sa6.sin6_addr, string_addr, sizeof(string_addr)); 637 tprintf("sin6_port=htons(%u), inet_pton(AF_INET6, \"%s\", &sin6_addr), sin6_flowinfo=%u", 638 ntohs(addrbuf.sa6.sin6_port), string_addr, 639 addrbuf.sa6.sin6_flowinfo); 640#ifdef HAVE_SIN6_SCOPE_ID 641 { 642#if defined(HAVE_IF_INDEXTONAME) && defined(IN6_IS_ADDR_LINKLOCAL) && defined(IN6_IS_ADDR_MC_LINKLOCAL) 643 int numericscope = 0; 644 if (IN6_IS_ADDR_LINKLOCAL (&addrbuf.sa6.sin6_addr) 645 || IN6_IS_ADDR_MC_LINKLOCAL (&addrbuf.sa6.sin6_addr)) { 646 char scopebuf[IFNAMSIZ + 1]; 647 648 if (if_indextoname (addrbuf.sa6.sin6_scope_id, scopebuf) == NULL) 649 numericscope++; 650 else 651 tprintf(", sin6_scope_id=if_nametoindex(\"%s\")", scopebuf); 652 } else 653 numericscope++; 654 655 if (numericscope) 656#endif 657 tprintf(", sin6_scope_id=%u", addrbuf.sa6.sin6_scope_id); 658 } 659#endif 660 break; 661#endif 662#if defined(AF_IPX) && defined(linux) 663 case AF_IPX: 664 { 665 int i; 666 tprintf("sipx_port=htons(%u), ", 667 ntohs(addrbuf.sipx.sipx_port)); 668 /* Yes, I know, this does not look too 669 * strace-ish, but otherwise the IPX 670 * addresses just look monstrous... 671 * Anyways, feel free if you don't like 672 * this way.. :) 673 */ 674 tprintf("%08lx:", (unsigned long)ntohl(addrbuf.sipx.sipx_network)); 675 for (i = 0; i<IPX_NODE_LEN; i++) 676 tprintf("%02x", addrbuf.sipx.sipx_node[i]); 677 tprintf("/[%02x]", addrbuf.sipx.sipx_type); 678 } 679 break; 680#endif /* AF_IPX && linux */ 681#ifdef AF_PACKET 682 case AF_PACKET: 683 { 684 int i; 685 tprintf("proto=%#04x, if%d, pkttype=%d, addr(%d)={%d, ", 686 ntohs(addrbuf.ll.sll_protocol), 687 addrbuf.ll.sll_ifindex, 688 addrbuf.ll.sll_pkttype, 689 addrbuf.ll.sll_halen, 690 addrbuf.ll.sll_hatype); 691 for (i=0; i<addrbuf.ll.sll_addr[i]; i++) 692 tprintf("%02x", addrbuf.ll.sll_addr[i]); 693 } 694 break; 695 696#endif /* AF_APACKET */ 697#ifdef AF_NETLINLK 698 case AF_NETLINK: 699 tprintf("pid=%d, groups=%08x", addrbuf.nl.nl_pid, addrbuf.nl.nl_groups); 700 break; 701#endif /* AF_NETLINK */ 702 /* AF_AX25 AF_APPLETALK AF_NETROM AF_BRIDGE AF_AAL5 703 AF_X25 AF_ROSE etc. still need to be done */ 704 705 default: 706 tprintf("sa_data="); 707 printstr(tcp, (long) &((struct sockaddr *) addr)->sa_data, 708 sizeof addrbuf.sa.sa_data); 709 break; 710 } 711 tprintf("}"); 712} 713 714#if HAVE_SENDMSG 715 716static void 717printmsghdr(tcp, addr) 718struct tcb *tcp; 719long addr; 720{ 721 struct msghdr msg; 722 723 if (umove(tcp, addr, &msg) < 0) { 724 tprintf("%#lx", addr); 725 return; 726 } 727 tprintf("{msg_name(%d)=", msg.msg_namelen); 728 printsock(tcp, (long)msg.msg_name, msg.msg_namelen); 729 730 tprintf(", msg_iov(%lu)=", (unsigned long)msg.msg_iovlen); 731 tprint_iov(tcp, msg.msg_iovlen, (long) msg.msg_iov); 732 733#ifdef HAVE_MSG_CONTROL 734 tprintf(", msg_controllen=%lu", (unsigned long)msg.msg_controllen); 735 if (msg.msg_controllen) 736 tprintf(", msg_control=%#lx, ", (unsigned long) msg.msg_control); 737 tprintf(", msg_flags="); 738 if (printflags(msg_flags, msg.msg_flags)==0) 739 tprintf("0"); 740#else /* !HAVE_MSG_CONTROL */ 741 tprintf("msg_accrights=%#lx, msg_accrightslen=%u", 742 (unsigned long) msg.msg_accrights, msg.msg_accrightslen); 743#endif /* !HAVE_MSG_CONTROL */ 744 tprintf("}"); 745} 746 747#endif /* HAVE_SENDMSG */ 748 749int 750sys_socket(tcp) 751struct tcb *tcp; 752{ 753 if (entering(tcp)) { 754 printxval(domains, tcp->u_arg[0], "PF_???"); 755 tprintf(", "); 756 printxval(socktypes, tcp->u_arg[1], "SOCK_???"); 757 tprintf(", "); 758 switch (tcp->u_arg[0]) { 759 case PF_INET: 760 printxval(protocols, tcp->u_arg[2], "IPPROTO_???"); 761 break; 762#ifdef PF_IPX 763 case PF_IPX: 764 /* BTW: I don't believe this.. */ 765 tprintf("["); 766 printxval(domains, tcp->u_arg[2], "PF_???"); 767 tprintf("]"); 768 break; 769#endif /* PF_IPX */ 770 default: 771 tprintf("%lu", tcp->u_arg[2]); 772 break; 773 } 774 } 775 return 0; 776} 777 778int 779sys_so_socket(tcp) 780struct tcb *tcp; 781{ 782 if (entering(tcp)) { 783 /* not sure really what these args are... but this 784 * is how truss prints it 785 */ 786 tprintf("%ld, %ld, %ld, ", 787 tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]); 788 printpath(tcp, tcp->u_arg[3]); 789 tprintf(", %ld", tcp->u_arg[4]); 790 } 791 return 0; 792} 793 794int 795sys_so_socketpair(tcp) 796struct tcb *tcp; 797{ 798 if (entering(tcp)) { 799 /* not sure what this arg is */ 800 tprintf("0x%lx", tcp->u_arg[0]); 801 } 802 return 0; 803} 804 805int 806sys_bind(tcp) 807struct tcb *tcp; 808{ 809 if (entering(tcp)) { 810 tprintf("%ld, ", tcp->u_arg[0]); 811 printsock(tcp, tcp->u_arg[1], tcp->u_arg[2]); 812 tprintf(", %lu", tcp->u_arg[2]); 813 } 814 return 0; 815} 816 817int 818sys_connect(tcp) 819struct tcb *tcp; 820{ 821 return sys_bind(tcp); 822} 823 824int 825sys_listen(tcp) 826struct tcb *tcp; 827{ 828 if (entering(tcp)) { 829 tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]); 830 } 831 return 0; 832} 833 834int 835sys_accept(tcp) 836struct tcb *tcp; 837{ 838 if (entering(tcp)) { 839 tprintf("%ld, ", tcp->u_arg[0]); 840 } else if (!tcp->u_arg[2]) 841 tprintf("%#lx, NULL", tcp->u_arg[1]); 842 else { 843 if (tcp->u_arg[1] == 0 || syserror(tcp)) { 844 tprintf("%#lx", tcp->u_arg[1]); 845 } else { 846 printsock(tcp, tcp->u_arg[1], tcp->u_arg[2]); 847 } 848 tprintf(", "); 849 printnum(tcp, tcp->u_arg[2], "%lu"); 850 } 851 return 0; 852} 853 854int 855sys_send(tcp) 856struct tcb *tcp; 857{ 858 if (entering(tcp)) { 859 tprintf("%ld, ", tcp->u_arg[0]); 860 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); 861 tprintf(", %lu, ", tcp->u_arg[2]); 862 /* flags */ 863 if (printflags(msg_flags, tcp->u_arg[3]) == 0) 864 tprintf("0"); 865 } 866 return 0; 867} 868 869int 870sys_sendto(tcp) 871struct tcb *tcp; 872{ 873 if (entering(tcp)) { 874 tprintf("%ld, ", tcp->u_arg[0]); 875 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); 876 tprintf(", %lu, ", tcp->u_arg[2]); 877 /* flags */ 878 if (printflags(msg_flags, tcp->u_arg[3]) == 0) 879 tprintf("0"); 880 /* to address */ 881 tprintf(", "); 882 printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]); 883 /* to length */ 884 tprintf(", %lu", tcp->u_arg[5]); 885 } 886 return 0; 887} 888 889#ifdef HAVE_SENDMSG 890 891int 892sys_sendmsg(tcp) 893struct tcb *tcp; 894{ 895 if (entering(tcp)) { 896 tprintf("%ld, ", tcp->u_arg[0]); 897 printmsghdr(tcp, tcp->u_arg[1]); 898 /* flags */ 899 tprintf(", "); 900 if (printflags(msg_flags, tcp->u_arg[2]) == 0) 901 tprintf("0"); 902 } 903 return 0; 904} 905 906#endif /* HAVE_SENDMSG */ 907 908int 909sys_recv(tcp) 910struct tcb *tcp; 911{ 912 if (entering(tcp)) { 913 tprintf("%ld, ", tcp->u_arg[0]); 914 } else { 915 if (syserror(tcp)) 916 tprintf("%#lx", tcp->u_arg[1]); 917 else 918 printstr(tcp, tcp->u_arg[1], tcp->u_rval); 919 920 tprintf(", %lu, ", tcp->u_arg[2]); 921 if (printflags(msg_flags, tcp->u_arg[3]) == 0) 922 tprintf("0"); 923 } 924 return 0; 925} 926 927int 928sys_recvfrom(tcp) 929struct tcb *tcp; 930{ 931 int fromlen; 932 933 if (entering(tcp)) { 934 tprintf("%ld, ", tcp->u_arg[0]); 935 } else { 936 if (syserror(tcp)) { 937 tprintf("%#lx, %lu, %lu, %#lx, %#lx", 938 tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3], 939 tcp->u_arg[4], tcp->u_arg[5]); 940 return 0; 941 } 942 /* buf */ 943 printstr(tcp, tcp->u_arg[1], tcp->u_rval); 944 /* len */ 945 tprintf(", %lu, ", tcp->u_arg[2]); 946 /* flags */ 947 if (printflags(msg_flags, tcp->u_arg[3]) == 0) 948 tprintf("0"); 949 /* from address, len */ 950 if (!tcp->u_arg[4] || !tcp->u_arg[5]) { 951 if (tcp->u_arg[4] == 0) 952 tprintf(", NULL"); 953 else 954 tprintf(", %#lx", tcp->u_arg[4]); 955 if (tcp->u_arg[5] == 0) 956 tprintf(", NULL"); 957 else 958 tprintf(", %#lx", tcp->u_arg[5]); 959 return 0; 960 } 961 if (umove(tcp, tcp->u_arg[5], &fromlen) < 0) { 962 tprintf(", {...}, [?]"); 963 return 0; 964 } 965 tprintf(", "); 966 printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]); 967 /* from length */ 968 tprintf(", [%u]", fromlen); 969 } 970 return 0; 971} 972 973#ifdef HAVE_SENDMSG 974 975int 976sys_recvmsg(tcp) 977struct tcb *tcp; 978{ 979 if (entering(tcp)) { 980 tprintf("%ld, ", tcp->u_arg[0]); 981 } else { 982 if (syserror(tcp) || !verbose(tcp)) 983 tprintf("%#lx", tcp->u_arg[1]); 984 else 985 printmsghdr(tcp, tcp->u_arg[1]); 986 /* flags */ 987 tprintf(", "); 988 if (printflags(msg_flags, tcp->u_arg[2]) == 0) 989 tprintf("0"); 990 } 991 return 0; 992} 993 994#endif /* HAVE_SENDMSG */ 995 996int 997sys_shutdown(tcp) 998struct tcb *tcp; 999{ 1000 if (entering(tcp)) { 1001 tprintf("%ld, %ld", tcp->u_arg[0], tcp->u_arg[1]); 1002 switch (tcp->u_arg[1]) { 1003 case 0: 1004 tprintf("%s", " /* receive */"); 1005 break; 1006 case 1: 1007 tprintf("%s", " /* send */"); 1008 break; 1009 case 2: 1010 tprintf("%s", " /* send and receive */"); 1011 break; 1012 } 1013 } 1014 return 0; 1015} 1016 1017int 1018sys_getsockname(tcp) 1019struct tcb *tcp; 1020{ 1021 return sys_accept(tcp); 1022} 1023 1024int 1025sys_getpeername(tcp) 1026struct tcb *tcp; 1027{ 1028 return sys_accept(tcp); 1029} 1030 1031int 1032sys_pipe(tcp) 1033struct tcb *tcp; 1034{ 1035 1036#if defined(LINUX) && !defined(SPARC) 1037 int fds[2]; 1038 1039 if (exiting(tcp)) { 1040 if (syserror(tcp)) { 1041 tprintf("%#lx", tcp->u_arg[0]); 1042 return 0; 1043 } 1044 if (umoven(tcp, tcp->u_arg[0], sizeof fds, (char *) fds) < 0) 1045 tprintf("[...]"); 1046 else 1047 tprintf("[%u, %u]", fds[0], fds[1]); 1048 } 1049#elif defined(SPARC) || defined(SVR4) || defined(FREEBSD) 1050 if (exiting(tcp)) 1051 tprintf("[%lu, %lu]", tcp->u_rval, getrval2(tcp)); 1052#endif 1053 return 0; 1054} 1055 1056int 1057sys_socketpair(tcp) 1058struct tcb *tcp; 1059{ 1060#ifdef LINUX 1061 int fds[2]; 1062#endif 1063 1064 if (entering(tcp)) { 1065 printxval(domains, tcp->u_arg[0], "PF_???"); 1066 tprintf(", "); 1067 printxval(socktypes, tcp->u_arg[1], "SOCK_???"); 1068 tprintf(", "); 1069 switch (tcp->u_arg[0]) { 1070 case PF_INET: 1071 printxval(protocols, tcp->u_arg[2], "IPPROTO_???"); 1072 break; 1073#ifdef PF_IPX 1074 case PF_IPX: 1075 /* BTW: I don't believe this.. */ 1076 tprintf("["); 1077 printxval(domains, tcp->u_arg[2], "PF_???"); 1078 tprintf("]"); 1079 break; 1080#endif /* PF_IPX */ 1081 default: 1082 tprintf("%lu", tcp->u_arg[2]); 1083 break; 1084 } 1085 } else { 1086 if (syserror(tcp)) { 1087 tprintf(", %#lx", tcp->u_arg[3]); 1088 return 0; 1089 } 1090#ifdef LINUX 1091 if (umoven(tcp, tcp->u_arg[3], sizeof fds, (char *) fds) < 0) 1092 tprintf(", [...]"); 1093 else 1094 tprintf(", [%u, %u]", fds[0], fds[1]); 1095#endif /* LINUX */ 1096#if defined(SUNOS4) || defined(SVR4) || defined(FREEBSD) 1097 tprintf(", [%lu, %lu]", tcp->u_rval, getrval2(tcp)); 1098#endif /* SUNOS4 || SVR4 || FREEBSD */ 1099 } 1100 return 0; 1101} 1102 1103int 1104sys_getsockopt(tcp) 1105struct tcb *tcp; 1106{ 1107 if (entering(tcp)) { 1108 tprintf("%ld, ", tcp->u_arg[0]); 1109 switch (tcp->u_arg[1]) { 1110 case SOL_SOCKET: 1111 tprintf("SOL_SOCKET, "); 1112 printxval(sockoptions, tcp->u_arg[2], "SO_???"); 1113 tprintf(", "); 1114 break; 1115#ifdef SOL_IP 1116 case SOL_IP: 1117 tprintf("SOL_IP, "); 1118 printxval(sockipoptions, tcp->u_arg[2], "IP_???"); 1119 tprintf(", "); 1120 break; 1121#endif 1122#ifdef SOL_IPX 1123 case SOL_IPX: 1124 tprintf("SOL_IPX, "); 1125 printxval(sockipxoptions, tcp->u_arg[2], "IPX_???"); 1126 tprintf(", "); 1127 break; 1128#endif 1129#ifdef SOL_PACKET 1130 case SOL_PACKET: 1131 tprintf("SOL_PACKET, "); 1132 printxval(sockpacketoptions, tcp->u_arg[2], "PACKET_???"); 1133 tprintf(", "); 1134 break; 1135#endif 1136#ifdef SOL_TCP 1137 case SOL_TCP: 1138 tprintf("SOL_TCP, "); 1139 printxval(socktcpoptions, tcp->u_arg[2], "TCP_???"); 1140 tprintf(", "); 1141 break; 1142#endif 1143 1144 /* SOL_AX25 SOL_ROSE SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25 1145 * etc. still need work */ 1146 default: 1147 /* XXX - should know socket family here */ 1148 printxval(socketlayers, tcp->u_arg[1], "SOL_???"); 1149 tprintf(", %lu, ", tcp->u_arg[2]); 1150 break; 1151 } 1152 } else { 1153 if (syserror(tcp)) { 1154 tprintf("%#lx, %#lx", 1155 tcp->u_arg[3], tcp->u_arg[4]); 1156 return 0; 1157 } 1158 printnum(tcp, tcp->u_arg[3], "%ld"); 1159 tprintf(", "); 1160 printnum(tcp, tcp->u_arg[4], "%ld"); 1161 } 1162 return 0; 1163} 1164 1165#if defined(ICMP_FILTER) 1166static void printicmpfilter(tcp, addr) 1167struct tcb *tcp; 1168long addr; 1169{ 1170 struct icmp_filter filter; 1171 1172 if (!addr) { 1173 tprintf("NULL"); 1174 return; 1175 } 1176 if (syserror(tcp) || !verbose(tcp)) { 1177 tprintf("%#lx", addr); 1178 return; 1179 } 1180 if (umove(tcp, addr, &filter) < 0) { 1181 tprintf("{...}"); 1182 return; 1183 } 1184 1185 tprintf("~("); 1186 if (printflags(icmpfilterflags, ~filter.data) == 0) 1187 tprintf("0"); 1188 tprintf(")"); 1189} 1190#endif /* ICMP_FILTER */ 1191 1192int 1193sys_setsockopt(tcp) 1194struct tcb *tcp; 1195{ 1196 if (entering(tcp)) { 1197 tprintf("%ld, ", tcp->u_arg[0]); 1198 switch (tcp->u_arg[1]) { 1199 case SOL_SOCKET: 1200 tprintf("SOL_SOCKET, "); 1201 printxval(sockoptions, tcp->u_arg[2], "SO_???"); 1202 tprintf(", "); 1203 printnum(tcp, tcp->u_arg[3], "%ld"); 1204 tprintf(", %lu", tcp->u_arg[4]); 1205 break; 1206#ifdef SOL_IP 1207 case SOL_IP: 1208 tprintf("SOL_IP, "); 1209 printxval(sockipoptions, tcp->u_arg[2], "IP_???"); 1210 tprintf(", "); 1211 printnum(tcp, tcp->u_arg[3], "%ld"); 1212 tprintf(", %lu", tcp->u_arg[4]); 1213 break; 1214#endif 1215#ifdef SOL_IPX 1216 case SOL_IPX: 1217 tprintf("SOL_IPX, "); 1218 printxval(sockipxoptions, tcp->u_arg[2], "IPX_???"); 1219 tprintf(", "); 1220 printnum(tcp, tcp->u_arg[3], "%ld"); 1221 tprintf(", %lu", tcp->u_arg[4]); 1222 break; 1223#endif 1224#ifdef SOL_PACKET 1225 case SOL_PACKET: 1226 tprintf("SOL_PACKET, "); 1227 printxval(sockpacketoptions, tcp->u_arg[2], "PACKET_???"); 1228 tprintf(", "); 1229 /* TODO: decode packate_mreq for PACKET_*_MEMBERSHIP */ 1230 printnum(tcp, tcp->u_arg[3], "%ld"); 1231 tprintf(", %lu", tcp->u_arg[4]); 1232 break; 1233#endif 1234#ifdef SOL_TCP 1235 case SOL_TCP: 1236 tprintf("SOL_TCP, "); 1237 printxval(socktcpoptions, tcp->u_arg[2], "TCP_???"); 1238 tprintf(", "); 1239 printnum(tcp, tcp->u_arg[3], "%ld"); 1240 tprintf(", %lu", tcp->u_arg[4]); 1241 break; 1242#endif 1243#ifdef SOL_RAW 1244 case SOL_RAW: 1245 tprintf("SOL_RAW, "); 1246 printxval(sockrawoptions, tcp->u_arg[2], "RAW_???"); 1247 tprintf(", "); 1248 switch (tcp->u_arg[2]) { 1249#if defined(ICMP_FILTER) 1250 case ICMP_FILTER: 1251 printicmpfilter(tcp, tcp->u_arg[3]); 1252 break; 1253#endif 1254 default: 1255 printnum(tcp, tcp->u_arg[3], "%ld"); 1256 break; 1257 } 1258 tprintf(", %lu", tcp->u_arg[4]); 1259 break; 1260#endif 1261 1262 /* SOL_AX25 SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25 1263 * etc. still need work */ 1264 default: 1265 /* XXX - should know socket family here */ 1266 printxval(socketlayers, tcp->u_arg[1], "IPPROTO_???"); 1267 tprintf(", %lu, ", tcp->u_arg[2]); 1268 printnum(tcp, tcp->u_arg[3], "%ld"); 1269 tprintf(", %lu", tcp->u_arg[4]); 1270 break; 1271 } 1272 } 1273 return 0; 1274} 1275 1276#if UNIXWARE >= 7 1277 1278static struct xlat sock_version[] = { 1279 { __NETLIB_UW211_SVR4, "UW211_SVR4" }, 1280 { __NETLIB_UW211_XPG4, "UW211_XPG4" }, 1281 { __NETLIB_GEMINI_SVR4, "GEMINI_SVR4" }, 1282 { __NETLIB_GEMINI_XPG4, "GEMINI_XPG4" }, 1283 { __NETLIB_FP1_SVR4, "FP1_SVR4" }, 1284 { __NETLIB_FP1_XPG4, "FP1_XPG4" }, 1285 { 0, NULL }, 1286}; 1287 1288 1289int 1290netlib_call(tcp, func) 1291struct tcb *tcp; 1292int (*func) (); 1293{ 1294 if (entering(tcp)) { 1295 int i; 1296 printxval (sock_version, tcp->u_arg[0], "__NETLIB_???"); 1297 tprintf(", "); 1298 --tcp->u_nargs; 1299 for (i = 0; i < tcp->u_nargs; i++) 1300 tcp->u_arg[i] = tcp->u_arg[i + 1]; 1301 return func (tcp); 1302 1303 } 1304 1305 return func (tcp); 1306} 1307 1308int 1309sys_xsocket(tcp) 1310struct tcb *tcp; 1311{ 1312 return netlib_call (tcp, sys_socket); 1313} 1314 1315int 1316sys_xsocketpair(tcp) 1317struct tcb *tcp; 1318{ 1319 return netlib_call (tcp, sys_socketpair); 1320} 1321 1322int 1323sys_xbind(tcp) 1324struct tcb *tcp; 1325{ 1326 return netlib_call (tcp, sys_bind); 1327} 1328 1329int 1330sys_xconnect(tcp) 1331struct tcb *tcp; 1332{ 1333 return netlib_call (tcp, sys_connect); 1334} 1335 1336int 1337sys_xlisten(tcp) 1338struct tcb *tcp; 1339{ 1340 return netlib_call (tcp, sys_listen); 1341} 1342 1343int 1344sys_xaccept(tcp) 1345struct tcb *tcp; 1346{ 1347 return netlib_call (tcp, sys_accept); 1348} 1349 1350int 1351sys_xsendmsg(tcp) 1352struct tcb *tcp; 1353{ 1354 return netlib_call (tcp, sys_sendmsg); 1355} 1356 1357int 1358sys_xrecvmsg(tcp) 1359struct tcb *tcp; 1360{ 1361 return netlib_call (tcp, sys_recvmsg); 1362} 1363 1364int 1365sys_xgetsockaddr(tcp) 1366struct tcb *tcp; 1367{ 1368 if (entering(tcp)) { 1369 printxval (sock_version, tcp->u_arg[0], "__NETLIB_???"); 1370 tprintf(", "); 1371 if (tcp->u_arg[1] == 0) { 1372 tprintf ("LOCALNAME, "); 1373 } 1374 else if (tcp->u_arg[1] == 1) { 1375 tprintf ("REMOTENAME, "); 1376 } 1377 else { 1378 tprintf ("%ld, ", tcp->u_arg [1]); 1379 } 1380 tprintf ("%ld, ", tcp->u_arg [2]); 1381 } 1382 else { 1383 if (tcp->u_arg[3] == 0 || syserror(tcp)) { 1384 tprintf("%#lx", tcp->u_arg[3]); 1385 } else { 1386 printsock(tcp, tcp->u_arg[3], tcp->u_arg[4]); 1387 } 1388 tprintf(", "); 1389 printnum(tcp, tcp->u_arg[4], "%lu"); 1390 } 1391 1392 return 0; 1393 1394} 1395 1396#if 0 1397 1398int 1399sys_xsetsockaddr(tcp) 1400struct tcb *tcp; 1401{ 1402 return netlib_call (tcp, sys_setsockaddr); 1403} 1404 1405#endif 1406 1407int 1408sys_xgetsockopt(tcp) 1409struct tcb *tcp; 1410{ 1411 return netlib_call (tcp, sys_getsockopt); 1412} 1413 1414int 1415sys_xsetsockopt(tcp) 1416struct tcb *tcp; 1417{ 1418 return netlib_call (tcp, sys_setsockopt); 1419} 1420 1421int 1422sys_xshutdown(tcp) 1423struct tcb *tcp; 1424{ 1425 return netlib_call (tcp, sys_shutdown); 1426} 1427 1428#endif 1429