1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #pragma ident "%Z%%M% %I% %E% SMI" 28 29 #include <stdio.h> 30 #include <stdlib.h> 31 #include <unistd.h> 32 #include <fcntl.h> 33 #include <ctype.h> 34 #include <string.h> 35 #include <signal.h> 36 #include <errno.h> 37 #include <dirent.h> 38 #include <limits.h> 39 #include <door.h> 40 #include <sys/types.h> 41 #include <sys/socket.h> 42 #include <sys/stat.h> 43 #include <sys/mman.h> 44 #include <sys/mkdev.h> 45 #include <sys/un.h> 46 #include <netdb.h> 47 #include <libproc.h> 48 #include <netinet/in.h> 49 #include <netinet/udp.h> 50 #include <arpa/inet.h> 51 #include <netdb.h> 52 53 #define copyflock(dst, src) \ 54 (dst).l_type = (src).l_type; \ 55 (dst).l_whence = (src).l_whence; \ 56 (dst).l_start = (src).l_start; \ 57 (dst).l_len = (src).l_len; \ 58 (dst).l_sysid = (src).l_sysid; \ 59 (dst).l_pid = (src).l_pid; 60 61 static char *command; 62 static volatile int interrupt; 63 static int Fflag; 64 static boolean_t nflag = B_FALSE; 65 66 static void intr(int); 67 static void dofcntl(struct ps_prochandle *, int, int, int); 68 static void dosocket(struct ps_prochandle *, int); 69 static void show_files(struct ps_prochandle *); 70 static void show_fileflags(int); 71 static void show_door(struct ps_prochandle *, int); 72 static int getflock(struct ps_prochandle *, int, struct flock *); 73 74 int 75 main(int argc, char **argv) 76 { 77 int retc = 0; 78 int opt; 79 int errflg = 0; 80 struct ps_prochandle *Pr; 81 82 if ((command = strrchr(argv[0], '/')) != NULL) 83 command++; 84 else 85 command = argv[0]; 86 87 /* options */ 88 while ((opt = getopt(argc, argv, "Fn")) != EOF) { 89 switch (opt) { 90 case 'F': /* force grabbing (no O_EXCL) */ 91 Fflag = PGRAB_FORCE; 92 break; 93 case 'n': 94 nflag = B_TRUE; 95 break; 96 default: 97 errflg = 1; 98 break; 99 } 100 } 101 102 argc -= optind; 103 argv += optind; 104 105 if (errflg || argc <= 0) { 106 (void) fprintf(stderr, "usage:\t%s [-F] pid ...\n", 107 command); 108 (void) fprintf(stderr, 109 " (report open files of each process)\n"); 110 (void) fprintf(stderr, 111 " -F: force grabbing of the target process\n"); 112 exit(2); 113 } 114 115 /* catch signals from terminal */ 116 if (sigset(SIGHUP, SIG_IGN) == SIG_DFL) 117 (void) sigset(SIGHUP, intr); 118 if (sigset(SIGINT, SIG_IGN) == SIG_DFL) 119 (void) sigset(SIGINT, intr); 120 if (sigset(SIGQUIT, SIG_IGN) == SIG_DFL) 121 (void) sigset(SIGQUIT, intr); 122 (void) sigset(SIGPIPE, intr); 123 (void) sigset(SIGTERM, intr); 124 125 (void) proc_initstdio(); 126 127 128 while (--argc >= 0 && !interrupt) { 129 char *arg; 130 psinfo_t psinfo; 131 pid_t pid; 132 int gret; 133 134 (void) proc_flushstdio(); 135 136 /* get the specified pid and the psinfo struct */ 137 if ((pid = proc_arg_psinfo(arg = *argv++, PR_ARG_PIDS, 138 &psinfo, &gret)) == -1) { 139 (void) fprintf(stderr, "%s: cannot examine %s: %s\n", 140 command, arg, Pgrab_error(gret)); 141 retc++; 142 } else if ((Pr = Pgrab(pid, Fflag, &gret)) != NULL) { 143 if (Pcreate_agent(Pr) == 0) { 144 proc_unctrl_psinfo(&psinfo); 145 (void) printf("%d:\t%.70s\n", 146 (int)pid, psinfo.pr_psargs); 147 show_files(Pr); 148 Pdestroy_agent(Pr); 149 } else { 150 (void) fprintf(stderr, 151 "%s: cannot control process %d\n", 152 command, (int)pid); 153 retc++; 154 } 155 Prelease(Pr, 0); 156 Pr = NULL; 157 } else { 158 switch (gret) { 159 case G_SYS: 160 case G_SELF: 161 proc_unctrl_psinfo(&psinfo); 162 (void) printf("%d:\t%.70s\n", (int)pid, 163 psinfo.pr_psargs); 164 if (gret == G_SYS) 165 (void) printf(" [system process]\n"); 166 else 167 show_files(NULL); 168 break; 169 default: 170 (void) fprintf(stderr, "%s: %s: %d\n", 171 command, Pgrab_error(gret), (int)pid); 172 retc++; 173 break; 174 } 175 } 176 } 177 178 (void) proc_finistdio(); 179 180 if (interrupt && retc == 0) 181 retc++; 182 return (retc); 183 } 184 185 /* ARGSUSED */ 186 static void 187 intr(int sig) 188 { 189 interrupt = 1; 190 } 191 192 /* ------ begin specific code ------ */ 193 194 static void 195 show_files(struct ps_prochandle *Pr) 196 { 197 DIR *dirp; 198 struct dirent *dentp; 199 char pname[100]; 200 char fname[PATH_MAX]; 201 struct stat64 statb; 202 struct rlimit rlim; 203 pid_t pid; 204 int fd; 205 char *s; 206 int ret; 207 208 if (pr_getrlimit(Pr, RLIMIT_NOFILE, &rlim) == 0) { 209 ulong_t nfd = rlim.rlim_cur; 210 if (nfd == RLIM_INFINITY) 211 (void) printf( 212 " Current rlimit: unlimited file descriptors\n"); 213 else 214 (void) printf( 215 " Current rlimit: %lu file descriptors\n", nfd); 216 } 217 218 /* in case we are doing this to ourself */ 219 pid = (Pr == NULL)? getpid() : Pstatus(Pr)->pr_pid; 220 221 (void) sprintf(pname, "/proc/%d/fd", (int)pid); 222 if ((dirp = opendir(pname)) == NULL) { 223 (void) fprintf(stderr, "%s: cannot open directory %s\n", 224 command, pname); 225 return; 226 } 227 228 /* for each open file --- */ 229 while ((dentp = readdir(dirp)) != NULL && !interrupt) { 230 char unknown[12]; 231 dev_t rdev; 232 233 /* skip '.' and '..' */ 234 if (!isdigit(dentp->d_name[0])) 235 continue; 236 237 fd = atoi(dentp->d_name); 238 if (pr_fstat64(Pr, fd, &statb) == -1) { 239 s = unknown; 240 (void) sprintf(s, "%4d", fd); 241 perror(s); 242 continue; 243 } 244 245 rdev = NODEV; 246 switch (statb.st_mode & S_IFMT) { 247 case S_IFCHR: s = "S_IFCHR"; rdev = statb.st_rdev; break; 248 case S_IFBLK: s = "S_IFBLK"; rdev = statb.st_rdev; break; 249 case S_IFIFO: s = "S_IFIFO"; break; 250 case S_IFDIR: s = "S_IFDIR"; break; 251 case S_IFREG: s = "S_IFREG"; break; 252 case S_IFLNK: s = "S_IFLNK"; break; 253 case S_IFSOCK: s = "S_IFSOCK"; break; 254 case S_IFDOOR: s = "S_IFDOOR"; break; 255 case S_IFPORT: s = "S_IFPORT"; break; 256 default: 257 s = unknown; 258 (void) sprintf(s, "0x%.4x ", 259 (int)statb.st_mode & S_IFMT); 260 break; 261 } 262 263 (void) printf("%4d: %s mode:0%.3o", fd, s, 264 (int)statb.st_mode & ~S_IFMT); 265 266 if (major(statb.st_dev) != (major_t)NODEV && 267 minor(statb.st_dev) != (minor_t)NODEV) 268 (void) printf(" dev:%lu,%lu", 269 (ulong_t)major(statb.st_dev), 270 (ulong_t)minor(statb.st_dev)); 271 else 272 (void) printf(" dev:0x%.8lX", (long)statb.st_dev); 273 274 if ((statb.st_mode & S_IFMT) == S_IFPORT) { 275 (void) printf(" uid:%d gid:%d", 276 (int)statb.st_uid, 277 (int)statb.st_gid); 278 (void) printf(" size:%lld\n", 279 (longlong_t)statb.st_size); 280 continue; 281 } 282 283 (void) printf(" ino:%llu uid:%d gid:%d", 284 (u_longlong_t)statb.st_ino, 285 (int)statb.st_uid, (int)statb.st_gid); 286 287 if (rdev == NODEV) 288 (void) printf(" size:%lld\n", 289 (longlong_t)statb.st_size); 290 else if (major(rdev) != (major_t)NODEV && 291 minor(rdev) != (minor_t)NODEV) 292 (void) printf(" rdev:%lu,%lu\n", 293 (ulong_t)major(rdev), (ulong_t)minor(rdev)); 294 else 295 (void) printf(" rdev:0x%.8lX\n", (long)rdev); 296 297 if (!nflag) { 298 dofcntl(Pr, fd, 299 (statb.st_mode & (S_IFMT|S_ENFMT|S_IXGRP)) 300 == (S_IFREG|S_ENFMT), 301 (statb.st_mode & S_IFMT) == S_IFDOOR); 302 303 if ((statb.st_mode & S_IFMT) == S_IFSOCK) 304 dosocket(Pr, fd); 305 306 (void) sprintf(pname, "/proc/%d/path/%d", (int)pid, fd); 307 308 if ((ret = readlink(pname, fname, PATH_MAX - 1)) > 0) { 309 fname[ret] = '\0'; 310 (void) printf(" %s\n", fname); 311 } 312 } 313 } 314 315 (void) closedir(dirp); 316 } 317 318 319 static int 320 getflock(struct ps_prochandle *Pr, int fd, struct flock *flock_native) 321 { 322 int ret; 323 #ifdef _LP64 324 struct flock64_32 flock_target; 325 326 if (Pstatus(Pr)->pr_dmodel == PR_MODEL_ILP32) { 327 copyflock(flock_target, *flock_native); 328 ret = pr_fcntl(Pr, fd, F_GETLK, &flock_target); 329 copyflock(*flock_native, flock_target); 330 return (ret); 331 } 332 #endif /* _LP64 */ 333 ret = pr_fcntl(Pr, fd, F_GETLK, flock_native); 334 return (ret); 335 } 336 337 /* examine open file with fcntl() */ 338 static void 339 dofcntl(struct ps_prochandle *Pr, int fd, int mandatory, int isdoor) 340 { 341 struct flock flock; 342 int fileflags; 343 int fdflags; 344 345 fileflags = pr_fcntl(Pr, fd, F_GETXFL, 0); 346 fdflags = pr_fcntl(Pr, fd, F_GETFD, 0); 347 348 if (fileflags != -1 || fdflags != -1) { 349 (void) printf(" "); 350 if (fileflags != -1) 351 show_fileflags(fileflags); 352 if (fdflags != -1 && (fdflags & FD_CLOEXEC)) 353 (void) printf(" FD_CLOEXEC"); 354 if (isdoor) 355 show_door(Pr, fd); 356 (void) fputc('\n', stdout); 357 } else if (isdoor) { 358 (void) printf(" "); 359 show_door(Pr, fd); 360 (void) fputc('\n', stdout); 361 } 362 363 flock.l_type = F_WRLCK; 364 flock.l_whence = 0; 365 flock.l_start = 0; 366 flock.l_len = 0; 367 flock.l_sysid = 0; 368 flock.l_pid = 0; 369 if (getflock(Pr, fd, &flock) != -1) { 370 if (flock.l_type != F_UNLCK && (flock.l_sysid || flock.l_pid)) { 371 unsigned long sysid = flock.l_sysid; 372 373 (void) printf(" %s %s lock set by", 374 mandatory ? "mandatory" : "advisory", 375 flock.l_type == F_RDLCK? "read" : "write"); 376 if (sysid) 377 (void) printf(" system 0x%lX", sysid); 378 if (flock.l_pid) 379 (void) printf(" process %d", (int)flock.l_pid); 380 (void) fputc('\n', stdout); 381 } 382 } 383 } 384 385 #ifdef O_PRIV 386 #define ALL_O_FLAGS O_ACCMODE | O_NDELAY | O_NONBLOCK | O_APPEND | \ 387 O_PRIV | O_SYNC | O_DSYNC | O_RSYNC | O_XATTR | \ 388 O_CREAT | O_TRUNC | O_EXCL | O_NOCTTY | O_LARGEFILE 389 #else 390 #define ALL_O_FLAGS O_ACCMODE | O_NDELAY | O_NONBLOCK | O_APPEND | \ 391 O_SYNC | O_DSYNC | O_RSYNC | O_XATTR | \ 392 O_CREAT | O_TRUNC | O_EXCL | O_NOCTTY | O_LARGEFILE 393 #endif 394 395 static void 396 show_fileflags(int flags) 397 { 398 char buffer[136]; 399 char *str = buffer; 400 401 switch (flags & O_ACCMODE) { 402 case O_RDONLY: 403 (void) strcpy(str, "O_RDONLY"); 404 break; 405 case O_WRONLY: 406 (void) strcpy(str, "O_WRONLY"); 407 break; 408 case O_RDWR: 409 (void) strcpy(str, "O_RDWR"); 410 break; 411 default: 412 (void) sprintf(str, "0x%x", flags & O_ACCMODE); 413 break; 414 } 415 416 if (flags & O_NDELAY) 417 (void) strcat(str, "|O_NDELAY"); 418 if (flags & O_NONBLOCK) 419 (void) strcat(str, "|O_NONBLOCK"); 420 if (flags & O_APPEND) 421 (void) strcat(str, "|O_APPEND"); 422 #ifdef O_PRIV 423 if (flags & O_PRIV) 424 (void) strcat(str, "|O_PRIV"); 425 #endif 426 if (flags & O_SYNC) 427 (void) strcat(str, "|O_SYNC"); 428 if (flags & O_DSYNC) 429 (void) strcat(str, "|O_DSYNC"); 430 if (flags & O_RSYNC) 431 (void) strcat(str, "|O_RSYNC"); 432 if (flags & O_CREAT) 433 (void) strcat(str, "|O_CREAT"); 434 if (flags & O_TRUNC) 435 (void) strcat(str, "|O_TRUNC"); 436 if (flags & O_EXCL) 437 (void) strcat(str, "|O_EXCL"); 438 if (flags & O_NOCTTY) 439 (void) strcat(str, "|O_NOCTTY"); 440 if (flags & O_LARGEFILE) 441 (void) strcat(str, "|O_LARGEFILE"); 442 if (flags & O_XATTR) 443 (void) strcat(str, "|O_XATTR"); 444 if (flags & ~(ALL_O_FLAGS)) 445 (void) sprintf(str + strlen(str), "|0x%x", 446 flags & ~(ALL_O_FLAGS)); 447 448 (void) printf("%s", str); 449 } 450 451 /* show door info */ 452 static void 453 show_door(struct ps_prochandle *Pr, int fd) 454 { 455 door_info_t door_info; 456 psinfo_t psinfo; 457 458 if (pr_door_info(Pr, fd, &door_info) != 0) 459 return; 460 461 if (proc_get_psinfo(door_info.di_target, &psinfo) != 0) 462 psinfo.pr_fname[0] = '\0'; 463 464 (void) printf(" door to "); 465 if (psinfo.pr_fname[0] != '\0') 466 (void) printf("%s[%d]", psinfo.pr_fname, 467 (int)door_info.di_target); 468 else 469 (void) printf("pid %d", (int)door_info.di_target); 470 } 471 472 static void 473 show_sockaddr(const char *str, struct sockaddr *sa, socklen_t len) 474 { 475 /* LINTED pointer assignment */ 476 struct sockaddr_in *so_in = (struct sockaddr_in *)sa; 477 /* LINTED pointer assignment */ 478 struct sockaddr_in6 *so_in6 = (struct sockaddr_in6 *)sa; 479 struct sockaddr_un *so_un = (struct sockaddr_un *)sa; 480 char abuf[INET6_ADDRSTRLEN]; 481 const char *p; 482 483 switch (sa->sa_family) { 484 default: 485 return; 486 case AF_INET: 487 (void) printf("\t%s: AF_INET %s port: %u\n", 488 str, 489 inet_ntop(AF_INET, &so_in->sin_addr, abuf, sizeof (abuf)), 490 ntohs(so_in->sin_port)); 491 return; 492 case AF_INET6: 493 (void) printf("\t%s: AF_INET6 %s port: %u\n", 494 str, 495 inet_ntop(AF_INET6, &so_in6->sin6_addr, 496 abuf, sizeof (abuf)), 497 ntohs(so_in->sin_port)); 498 return; 499 case AF_UNIX: 500 if (len >= sizeof (so_un->sun_family)) { 501 /* Null terminate */ 502 len -= sizeof (so_un->sun_family); 503 so_un->sun_path[len] = NULL; 504 (void) printf("\t%s: AF_UNIX %s\n", 505 str, so_un->sun_path); 506 } 507 return; 508 case AF_IMPLINK: p = "AF_IMPLINK"; break; 509 case AF_PUP: p = "AF_PUP"; break; 510 case AF_CHAOS: p = "AF_CHAOS"; break; 511 case AF_NS: p = "AF_NS"; break; 512 case AF_NBS: p = "AF_NBS"; break; 513 case AF_ECMA: p = "AF_ECMA"; break; 514 case AF_DATAKIT: p = "AF_DATAKIT"; break; 515 case AF_CCITT: p = "AF_CCITT"; break; 516 case AF_SNA: p = "AF_SNA"; break; 517 case AF_DECnet: p = "AF_DECnet"; break; 518 case AF_DLI: p = "AF_DLI"; break; 519 case AF_LAT: p = "AF_LAT"; break; 520 case AF_HYLINK: p = "AF_HYLINK"; break; 521 case AF_APPLETALK: p = "AF_APPLETALK"; break; 522 case AF_NIT: p = "AF_NIT"; break; 523 case AF_802: p = "AF_802"; break; 524 case AF_OSI: p = "AF_OSI"; break; 525 case AF_X25: p = "AF_X25"; break; 526 case AF_OSINET: p = "AF_OSINET"; break; 527 case AF_GOSIP: p = "AF_GOSIP"; break; 528 case AF_IPX: p = "AF_IPX"; break; 529 case AF_ROUTE: p = "AF_ROUTE"; break; 530 case AF_LINK: p = "AF_LINK"; break; 531 } 532 533 (void) printf("\t%s: %s\n", str, p); 534 } 535 536 static void 537 show_socktype(uint_t type) 538 { 539 static const char *types[] = { 540 NULL, "DGRAM", "STREAM", NULL, "RAW", "RDM", "SEQPACKET" 541 }; 542 543 if (type < sizeof (types) / sizeof (*types) && types[type] != NULL) 544 (void) printf("\tSOCK_%s\n", types[type]); 545 else 546 (void) printf("\tunknown socket type %u\n", type); 547 } 548 549 #define BUFSIZE 200 550 static void 551 show_sockopts(struct ps_prochandle *Pr, int fd) 552 { 553 int val, vlen; 554 char buf[BUFSIZE]; 555 char buf1[32]; 556 char ipaddr[INET_ADDRSTRLEN]; 557 int i; 558 in_addr_t nexthop_val; 559 struct boolopt { 560 int level; 561 int opt; 562 const char *name; 563 }; 564 static struct boolopt boolopts[] = { 565 { SOL_SOCKET, SO_DEBUG, "SO_DEBUG," }, 566 { SOL_SOCKET, SO_REUSEADDR, "SO_REUSEADDR," }, 567 { SOL_SOCKET, SO_KEEPALIVE, "SO_KEEPALIVE," }, 568 { SOL_SOCKET, SO_DONTROUTE, "SO_DONTROUTE," }, 569 { SOL_SOCKET, SO_BROADCAST, "SO_BROADCAST," }, 570 { SOL_SOCKET, SO_OOBINLINE, "SO_OOBINLINE," }, 571 { SOL_SOCKET, SO_DGRAM_ERRIND, "SO_DGRAM_ERRIND,"}, 572 { SOL_SOCKET, SO_ALLZONES, "SO_ALLZONES," }, 573 { SOL_SOCKET, SO_EXCLBIND, "SO_EXCLBIND," }, 574 { IPPROTO_UDP, UDP_NAT_T_ENDPOINT, "UDP_NAT_T_ENDPOINT," }, 575 }; 576 struct linger l; 577 578 buf[0] = '!'; /* sentinel value, never printed */ 579 buf[1] = '\0'; 580 581 for (i = 0; i < sizeof (boolopts) / sizeof (boolopts[0]); i++) { 582 vlen = sizeof (val); 583 if (pr_getsockopt(Pr, fd, boolopts[i].level, boolopts[i].opt, 584 &val, &vlen) == 0 && val != 0) 585 (void) strlcat(buf, boolopts[i].name, sizeof (buf)); 586 } 587 588 vlen = sizeof (l); 589 if (pr_getsockopt(Pr, fd, SOL_SOCKET, SO_LINGER, &l, &vlen) == 0 && 590 l.l_onoff != 0) { 591 (void) snprintf(buf1, sizeof (buf1), "SO_LINGER(%d),", 592 l.l_linger); 593 (void) strlcat(buf, buf1, sizeof (buf)); 594 } 595 596 vlen = sizeof (val); 597 if (pr_getsockopt(Pr, fd, SOL_SOCKET, SO_SNDBUF, &val, &vlen) == 0) { 598 (void) snprintf(buf1, sizeof (buf1), "SO_SNDBUF(%d),", val); 599 (void) strlcat(buf, buf1, sizeof (buf)); 600 } 601 vlen = sizeof (val); 602 if (pr_getsockopt(Pr, fd, SOL_SOCKET, SO_RCVBUF, &val, &vlen) == 0) { 603 (void) snprintf(buf1, sizeof (buf1), "SO_RCVBUF(%d),", val); 604 (void) strlcat(buf, buf1, sizeof (buf)); 605 } 606 vlen = sizeof (nexthop_val); 607 if (pr_getsockopt(Pr, fd, IPPROTO_IP, IP_NEXTHOP, &nexthop_val, 608 &vlen) == 0) { 609 if (vlen > 0) { 610 (void) inet_ntop(AF_INET, (void *) &nexthop_val, 611 ipaddr, sizeof (ipaddr)); 612 (void) snprintf(buf1, sizeof (buf1), "IP_NEXTHOP(%s),", 613 ipaddr); 614 (void) strlcat(buf, buf1, sizeof (buf)); 615 } 616 } 617 618 buf[strlen(buf) - 1] = '\0'; /* overwrites sentinel if no options */ 619 if (buf[1] != '\0') 620 (void) printf("\t%s\n", buf+1); 621 } 622 623 /* the file is a socket */ 624 static void 625 dosocket(struct ps_prochandle *Pr, int fd) 626 { 627 /* A buffer large enough for PATH_MAX size AF_UNIX address */ 628 long buf[(sizeof (short) + PATH_MAX + sizeof (long) - 1) 629 / sizeof (long)]; 630 struct sockaddr *sa = (struct sockaddr *)buf; 631 socklen_t len; 632 int type, tlen; 633 634 tlen = sizeof (type); 635 if (pr_getsockopt(Pr, fd, SOL_SOCKET, SO_TYPE, &type, &tlen) 636 == 0) 637 show_socktype((uint_t)type); 638 639 show_sockopts(Pr, fd); 640 641 len = sizeof (buf); 642 if (pr_getsockname(Pr, fd, sa, &len) == 0) 643 show_sockaddr("sockname", sa, len); 644 645 len = sizeof (buf); 646 if (pr_getpeername(Pr, fd, sa, &len) == 0) 647 show_sockaddr("peername", sa, len); 648 } 649