1/* 2 * ptti.c -- BSD style print_tcptpi() function for lsof library 3 */ 4 5 6/* 7 * Copyright 1997 Purdue Research Foundation, West Lafayette, Indiana 8 * 47907. All rights reserved. 9 * 10 * Written by Victor A. Abell 11 * 12 * This software is not subject to any license of the American Telephone 13 * and Telegraph Company or the Regents of the University of California. 14 * 15 * Permission is granted to anyone to use this software for any purpose on 16 * any computer system, and to alter it and redistribute it freely, subject 17 * to the following restrictions: 18 * 19 * 1. Neither the authors nor Purdue University are responsible for any 20 * consequences of the use of this software. 21 * 22 * 2. The origin of this software must not be misrepresented, either by 23 * explicit claim or by omission. Credit to the authors and Purdue 24 * University must appear in documentation and sources. 25 * 26 * 3. Altered versions must be plainly marked as such, and must not be 27 * misrepresented as being the original software. 28 * 29 * 4. This notice may not be removed or altered. 30 */ 31 32 33#include "../machine.h" 34 35#if defined(USE_LIB_PRINT_TCPTPI) 36 37# if !defined(lint) 38static char copyright[] = 39"@(#) Copyright 1997 Purdue Research Foundation.\nAll rights reserved.\n"; 40static char *rcsid = "$Id: ptti.c,v 1.6 2008/10/21 16:13:23 abe Exp $"; 41# endif /* !defined(lint) */ 42 43#define TCPSTATES /* activate tcpstates[] */ 44#include "../lsof.h" 45 46 47/* 48 * build_IPstates() -- build the TCP and UDP state tables 49 * 50 * Note: this module does not support a UDP state table. 51 */ 52 53void 54build_IPstates() 55{ 56 57/* 58 * Set the TcpNstates global variable. 59 */ 60 TcpNstates = TCP_NSTATES; 61 TcpSt = (char **)&tcpstates; 62} 63 64 65/* 66 * print_tcptpi() - print TCP/TPI info 67 */ 68 69void 70print_tcptpi(nl) 71 int nl; /* 1 == '\n' required */ 72{ 73 int ps = 0; 74 int s; 75 76 if ((Ftcptpi & TCPTPI_STATE) && Lf->lts.type == 0) { 77 if (Ffield) 78 (void) printf("%cST=", LSOF_FID_TCPTPI); 79 else 80 putchar('('); 81 if (!TcpNstates) 82 (void) build_IPstates(); 83 if ((s = Lf->lts.state.i) < 0 || s >= TcpNstates) 84 (void) printf("UNKNOWN_TCP_STATE_%d", s); 85 else 86 (void) fputs(TcpSt[s], stdout); 87 ps++; 88 if (Ffield) 89 putchar(Terminator); 90 } 91 92#if defined(HASTCPTPIQ) 93 if (Ftcptpi & TCPTPI_QUEUES) { 94 if (Lf->lts.rqs) { 95 if (Ffield) 96 putchar(LSOF_FID_TCPTPI); 97 else { 98 if (ps) 99 putchar(' '); 100 else 101 putchar('('); 102 } 103 (void) printf("QR=%lu", Lf->lts.rq); 104 if (Ffield) 105 putchar(Terminator); 106 ps++; 107 } 108 if (Lf->lts.sqs) { 109 if (Ffield) 110 putchar(LSOF_FID_TCPTPI); 111 else { 112 if (ps) 113 putchar(' '); 114 else 115 putchar('('); 116 } 117 (void) printf("QS=%lu", Lf->lts.sq); 118 if (Ffield) 119 putchar(Terminator); 120 ps++; 121 } 122 } 123#endif /* defined(HASTCPTPIQ) */ 124 125#if defined(HASSOOPT) 126 if (Ftcptpi & TCPTPI_FLAGS) { 127 int opt; 128 129 if ((opt = Lf->lts.opt) 130 || Lf->lts.pqlens || Lf->lts.qlens || Lf->lts.qlims 131 || Lf->lts.rbszs || Lf->lts.sbsz 132 ) { 133 char sep = ' '; 134 135 if (Ffield) 136 sep = LSOF_FID_TCPTPI; 137 else if (!ps) 138 sep = '('; 139 (void) printf("%cSO", sep); 140 ps++; 141 sep = '='; 142 143# if defined(SO_ACCEPTCONN) 144 if (opt & SO_ACCEPTCONN) { 145 (void) printf("%cACCEPTCONN", sep); 146 opt &= ~SO_ACCEPTCONN; 147 sep = ','; 148 } 149# endif /* defined(SO_ACCEPTCONN) */ 150 151# if defined(SO_ACCEPTFILTER) 152 if (opt & SO_ACCEPTFILTER) { 153 (void) printf("%cACCEPTFILTER", sep); 154 opt &= ~SO_ACCEPTFILTER; 155 sep = ','; 156 } 157# endif /* defined(SO_ACCEPTFILTER) */ 158 159# if defined(SO_AUDIT) 160 if (opt & SO_AUDIT) { 161 (void) printf("%cAUDIT", sep); 162 opt &= ~SO_AUDIT; 163 sep = ','; 164 } 165# endif /* defined(SO_AUDIT) */ 166 167# if defined(SO_BINDANY) 168 if (opt & SO_BINDANY) { 169 (void) printf("%cBINDANY", sep); 170 opt &= ~SO_BINDANY; 171 sep = ','; 172 } 173# endif /* defined(SO_BINDANY) */ 174 175# if defined(SO_BINTIME) 176 if (opt & SO_BINTIME) { 177 (void) printf("%cBINTIME", sep); 178 opt &= ~SO_BINTIME; 179 sep = ','; 180 } 181# endif /* defined(SO_BINTIME) */ 182 183# if defined(SO_BROADCAST) 184 if (opt & SO_BROADCAST) { 185 (void) printf("%cBROADCAST", sep); 186 opt &= ~SO_BROADCAST; 187 sep = ','; 188 } 189# endif /* defined(SO_BROADCAST) */ 190 191# if defined(SO_CKSUMRECV) 192 if (opt & SO_CKSUMRECV) { 193 (void) printf("%cCKSUMRECV", sep); 194 opt &= ~SO_CKSUMRECV; 195 sep = ','; 196 } 197# endif /* defined(SO_CKSUMRECV) */ 198 199# if defined(SO_CLUA_IN_NOALIAS) 200 if (opt & SO_CLUA_IN_NOALIAS) { 201 (void) printf("%cCLUA_IN_NOALIAS", sep); 202 opt &= ~SO_CLUA_IN_NOALIAS; 203 sep = ','; 204 } 205# endif /* defined(SO_CLUA_IN_NOALIAS) */ 206 207# if defined(SO_CLUA_IN_NOLOCAL) 208 if (opt & SO_CLUA_IN_NOLOCAL) { 209 (void) printf("%cCLUA_IN_NOLOCAL", sep); 210 opt &= ~SO_CLUA_IN_NOLOCAL; 211 sep = ','; 212 } 213# endif /* defined(SO_CLUA_IN_NOLOCAL) */ 214 215# if defined(SO_DEBUG) 216 if (opt & SO_DEBUG) { 217 (void) printf("%cDEBUG", sep); 218 opt &= ~ SO_DEBUG; 219 sep = ','; 220 } 221# endif /* defined(SO_DEBUG) */ 222 223# if defined(SO_DGRAM_ERRIND) 224 if (opt & SO_DGRAM_ERRIND) { 225 (void) printf("%cDGRAM_ERRIND", sep); 226 opt &= ~SO_DGRAM_ERRIND; 227 sep = ','; 228 } 229# endif /* defined(SO_DGRAM_ERRIND) */ 230 231# if defined(SO_DONTROUTE) 232 if (opt & SO_DONTROUTE) { 233 (void) printf("%cDONTROUTE", sep); 234 opt &= ~SO_DONTROUTE; 235 sep = ','; 236 } 237# endif /* defined(SO_DONTROUTE) */ 238 239# if defined(SO_DONTTRUNC) 240 if (opt & SO_DONTTRUNC) { 241 (void) printf("%cDONTTRUNC", sep); 242 opt &= ~SO_DONTTRUNC; 243 sep = ','; 244 } 245# endif /* defined(SO_DONTTRUNC) */ 246 247# if defined(SO_EXPANDED_RIGHTS) 248 if (opt & SO_EXPANDED_RIGHTS) { 249 (void) printf("%cEXPANDED_RIGHTS", sep); 250 opt &= ~SO_EXPANDED_RIGHTS; 251 sep = ','; 252 } 253# endif /* defined(SO_EXPANDED_RIGHTS) */ 254 255# if defined(SO_KEEPALIVE) 256 if (opt & SO_KEEPALIVE) { 257 (void) printf("%cKEEPALIVE", sep); 258 if (Lf->lts.kai) 259 (void) printf("=%d", Lf->lts.kai); 260 opt &= ~SO_KEEPALIVE; 261 sep = ','; 262 } 263# endif /* defined(SO_KEEPALIVE) */ 264 265# if defined(SO_KERNACCEPT) 266 if (opt & SO_KERNACCEPT) { 267 (void) printf("%cKERNACCEPT", sep); 268 opt &= ~SO_KERNACCEPT; 269 sep = ','; 270 } 271# endif /* defined(SO_KERNACCEPT) */ 272 273# if defined(SO_IMASOCKET) 274 if (opt & SO_IMASOCKET) { 275 (void) printf("%cIMASOCKET", sep); 276 opt &= ~SO_IMASOCKET; 277 sep = ','; 278 } 279# endif /* defined(SO_IMASOCKET) */ 280 281# if defined(SO_LINGER) 282 if (opt & SO_LINGER) { 283 (void) printf("%cLINGER", sep); 284 if (Lf->lts.ltm) 285 (void) printf("=%d", Lf->lts.ltm); 286 opt &= ~SO_LINGER; 287 sep = ','; 288 } 289# endif /* defined(SO_LINGER) */ 290 291# if defined(SO_LISTENING) 292 if (opt & SO_LISTENING) { 293 (void) printf("%cLISTENING", sep); 294 opt &= ~SO_LISTENING; 295 sep = ','; 296 } 297# endif /* defined(SO_LISTENING) */ 298 299# if defined(SO_MGMT) 300 if (opt & SO_MGMT) { 301 (void) printf("%cMGMT", sep); 302 opt &= ~SO_MGMT; 303 sep = ','; 304 } 305# endif /* defined(SO_MGMT) */ 306 307# if defined(SO_PAIRABLE) 308 if (opt & SO_PAIRABLE) { 309 (void) printf("%cPAIRABLE", sep); 310 opt &= ~SO_PAIRABLE; 311 sep = ','; 312 } 313# endif /* defined(SO_PAIRABLE) */ 314 315# if defined(SO_RESVPORT) 316 if (opt & SO_RESVPORT) { 317 (void) printf("%cRESVPORT", sep); 318 opt &= ~SO_RESVPORT; 319 sep = ','; 320 } 321# endif /* defined(SO_RESVPORT) */ 322 323# if defined(SO_NOREUSEADDR) 324 if (opt & SO_NOREUSEADDR) { 325 (void) printf("%cNOREUSEADDR", sep); 326 opt &= ~SO_NOREUSEADDR; 327 sep = ','; 328 } 329# endif /* defined(SO_NOREUSEADDR) */ 330 331# if defined(SO_NOSIGPIPE) 332 if (opt & SO_NOSIGPIPE) { 333 (void) printf("%cNOSIGPIPE", sep); 334 opt &= ~SO_NOSIGPIPE; 335 sep = ','; 336 } 337# endif /* defined(SO_NOSIGPIPE) */ 338 339# if defined(SO_OOBINLINE) 340 if (opt & SO_OOBINLINE) { 341 (void) printf("%cOOBINLINE", sep); 342 opt &= ~SO_OOBINLINE; 343 sep = ','; 344 } 345# endif /* defined(SO_OOBINLINE) */ 346 347# if defined(SO_ORDREL) 348 if (opt & SO_ORDREL) { 349 (void) printf("%cORDREL", sep); 350 opt &= ~SO_ORDREL; 351 sep = ','; 352 } 353# endif /* defined(SO_ORDREL) */ 354 355 if (Lf->lts.pqlens) { 356 (void) printf("%cPQLEN=%u", sep, Lf->lts.pqlen); 357 sep = ','; 358 } 359 if (Lf->lts.qlens) { 360 (void) printf("%cQLEN=%u", sep, Lf->lts.qlen); 361 sep = ','; 362 } 363 if (Lf->lts.qlims) { 364 (void) printf("%cQLIM=%u", sep, Lf->lts.qlim); 365 sep = ','; 366 } 367 if (Lf->lts.rbszs) { 368 (void) printf("%cRCVBUF=%lu", sep, Lf->lts.rbsz); 369 sep = ','; 370 } 371 372# if defined(SO_REUSEADDR) 373 if (opt & SO_REUSEADDR) { 374 (void) printf("%cREUSEADDR", sep); 375 opt &= ~SO_REUSEADDR; 376 sep = ','; 377 } 378# endif /* defined(SO_REUSEADDR) */ 379 380# if defined(SO_REUSEALIASPORT) 381 if (opt & SO_REUSEALIASPORT) { 382 (void) printf("%cREUSEALIASPORT", sep); 383 opt &= ~SO_REUSEALIASPORT; 384 sep = ','; 385 } 386# endif /* defined(SO_REUSEALIASPORT) */ 387 388# if defined(SO_REUSEPORT) 389 if (opt & SO_REUSEPORT) { 390 (void) printf("%cREUSEPORT", sep); 391 opt &= ~SO_REUSEPORT; 392 sep = ','; 393 } 394# endif /* defined(SO_REUSEPORT) */ 395 396# if defined(SO_REUSERAD) 397 if (opt & SO_REUSERAD) { 398 (void) printf("%cREUSERAD", sep); 399 opt &= ~SO_REUSERAD; 400 sep = ','; 401 } 402# endif /* defined(SO_REUSERAD) */ 403 404# if defined(SO_SECURITY_REQUEST) 405 if (opt & SO_SECURITY_REQUEST) { 406 (void) printf("%cSECURITY_REQUEST", sep); 407 opt &= ~SO_SECURITY_REQUEST; 408 sep = ','; 409 } 410# endif /* defined(SO_SECURITY_REQUEST) */ 411 412 if (Lf->lts.sbszs) { 413 (void) printf("%cSNDBUF=%lu", sep, Lf->lts.sbsz); 414 sep = ','; 415 } 416 417# if defined(SO_TIMESTAMP) 418 if (opt & SO_TIMESTAMP) { 419 (void) printf("%cTIMESTAMP", sep); 420 opt &= ~SO_TIMESTAMP; 421 sep = ','; 422 } 423# endif /* defined(SO_TIMESTAMP) */ 424 425# if defined(SO_UMC) 426 if (opt & SO_UMC) { 427 (void) printf("%cUMC", sep); 428 opt &= ~SO_UMC; 429 sep = ','; 430 } 431# endif /* defined(SO_UMC) */ 432 433# if defined(SO_USE_IFBUFS) 434 if (opt & SO_USE_IFBUFS) { 435 (void) printf("%cUSE_IFBUFS", sep); 436 opt &= ~SO_USE_IFBUFS; 437 sep = ','; 438 } 439# endif /* defined(SO_USE_IFBUFS) */ 440 441# if defined(SO_USELOOPBACK) 442 if (opt & SO_USELOOPBACK) { 443 (void) printf("%cUSELOOPBACK", sep); 444 opt &= ~SO_USELOOPBACK; 445 sep = ','; 446 } 447# endif /* defined(SO_USELOOPBACK) */ 448 449# if defined(SO_WANTMORE) 450 if (opt & SO_WANTMORE) { 451 (void) printf("%cWANTMORE", sep); 452 opt &= ~SO_WANTMORE; 453 sep = ','; 454 } 455# endif /* defined(SO_WANTMORE) */ 456 457# if defined(SO_WANTOOBFLAG) 458 if (opt & SO_WANTOOBFLAG) { 459 (void) printf("%cWANTOOBFLAG", sep); 460 opt &= ~SO_WANTOOBFLAG; 461 sep = ','; 462 } 463# endif /* defined(SO_WANTOOBFLAG) */ 464 465 if (opt) 466 (void) printf("%cUNKNOWN=%#x", sep, opt); 467 if (Ffield) 468 putchar(Terminator); 469 } 470 } 471#endif /* defined(HASSOOPT) */ 472 473#if defined(HASSOSTATE) 474 if (Ftcptpi & TCPTPI_FLAGS) { 475 unsigned int ss; 476 477 if ((ss = Lf->lts.ss)) { 478 char sep = ' '; 479 480 if (Ffield) 481 sep = LSOF_FID_TCPTPI; 482 else if (!ps) 483 sep = '('; 484 (void) printf("%cSS", sep); 485 ps++; 486 sep = '='; 487 488# if defined(SS_ASYNC) 489 if (ss & SS_ASYNC) { 490 (void) printf("%cASYNC", sep); 491 ss &= ~SS_ASYNC; 492 sep = ','; 493 } 494# endif /* defined(SS_ASYNC) */ 495 496# if defined(SS_BOUND) 497 if (ss & SS_BOUND) { 498 (void) printf("%cBOUND", sep); 499 ss &= ~SS_BOUND; 500 sep = ','; 501 } 502# endif /* defined(SS_BOUND) */ 503 504# if defined(HASSBSTATE) 505# if defined(SBS_CANTRCVMORE) 506 if (Lf->lts.sbs_rcv & SBS_CANTRCVMORE) { 507 (void) printf("%cCANTRCVMORE", sep); 508 Lf->lts.sbs_rcv &= ~SBS_CANTRCVMORE; 509 sep = ','; 510 } 511# endif /* defined(SBS_CANTRCVMORE) */ 512 513# if defined(SBS_CANTSENDMORE) 514 if (Lf->lts.sbs_snd & SBS_CANTSENDMORE) { 515 (void) printf("%cCANTSENDMORE", sep); 516 Lf->lts.sbs_snd &= ~SBS_CANTSENDMORE; 517 sep = ','; 518 } 519# endif /* defined(SS_CANTSENDMORE) */ 520# else /* !defined(HASSBSTATE) */ 521 522# if defined(SS_CANTRCVMORE) 523 if (ss & SS_CANTRCVMORE) { 524 (void) printf("%cCANTRCVMORE", sep); 525 ss &= ~SS_CANTRCVMORE; 526 sep = ','; 527 } 528# endif /* defined(SS_CANTRCVMORE) */ 529 530# if defined(SS_CANTSENDMORE) 531 if (ss & SS_CANTSENDMORE) { 532 (void) printf("%cCANTSENDMORE", sep); 533 ss &= ~SS_CANTSENDMORE; 534 sep = ','; 535 } 536# endif /* defined(SS_CANTSENDMORE) */ 537# endif /* defined(HASSBSTATE) */ 538 539# if defined(SS_COMP) 540 if (ss & SS_COMP) { 541 (void) printf("%cCOMP", sep); 542 ss &= ~SS_COMP; 543 sep = ','; 544 } 545# endif /* defined(SS_COMP) */ 546 547# if defined(SS_CONNECTOUT) 548 if (ss & SS_CONNECTOUT) { 549 (void) printf("%cCONNECTOUT", sep); 550 ss &= ~SS_CONNECTOUT; 551 sep = ','; 552 } 553# endif /* defined(SS_CONNECTOUT) */ 554 555# if defined(SS_HIPRI) 556 if (ss & SS_HIPRI) { 557 (void) printf("%cHIPRI", sep); 558 ss &= ~SS_HIPRI; 559 sep = ','; 560 } 561# endif /* defined(SS_HIPRI) */ 562 563# if defined(SS_IGNERR) 564 if (ss & SS_IGNERR) { 565 (void) printf("%cIGNERR", sep); 566 ss &= ~SS_IGNERR; 567 sep = ','; 568 } 569# endif /* defined(SS_IGNERR) */ 570 571# if defined(SS_INCOMP) 572 if (ss & SS_INCOMP) { 573 (void) printf("%cINCOMP", sep); 574 ss &= ~SS_INCOMP; 575 sep = ','; 576 } 577# endif /* defined(SS_INCOMP) */ 578 579# if defined(SS_IOCWAIT) 580 if (ss & SS_IOCWAIT) { 581 (void) printf("%cIOCWAIT", sep); 582 ss &= ~SS_IOCWAIT; 583 sep = ','; 584 } 585# endif /* defined(SS_IOCWAIT) */ 586 587# if defined(SS_ISCONFIRMING) 588 if (ss & SS_ISCONFIRMING) { 589 (void) printf("%cISCONFIRMING", sep); 590 ss &= ~SS_ISCONFIRMING; 591 sep = ','; 592 } 593# endif /* defined(SS_ISCONFIRMING) */ 594 595# if defined(SS_ISCONNECTED) 596 if (ss & SS_ISCONNECTED) { 597 (void) printf("%cISCONNECTED", sep); 598 ss &= ~SS_ISCONNECTED; 599 sep = ','; 600 } 601# endif /* defined(SS_ISCONNECTED) */ 602 603# if defined(SS_ISCONNECTING) 604 if (ss & SS_ISCONNECTING) { 605 (void) printf("%cISCONNECTING", sep); 606 ss &= ~SS_ISCONNECTING; 607 sep = ','; 608 } 609# endif /* defined(SS_ISCONNECTING) */ 610 611# if defined(SS_ISDISCONNECTING) 612 if (ss & SS_ISDISCONNECTING) { 613 (void) printf("%cISDISCONNECTING", sep); 614 ss &= ~SS_ISDISCONNECTING; 615 sep = ','; 616 } 617# endif /* defined(SS_ISDISCONNECTING) */ 618 619# if defined(SS_MORETOSEND) 620 if (ss & SS_MORETOSEND) { 621 (void) printf("%cMORETOSEND", sep); 622 ss &= ~SS_MORETOSEND; 623 sep = ','; 624 } 625# endif /* defined(SS_MORETOSEND) */ 626 627# if defined(SS_NBIO) 628 if (ss & SS_NBIO) { 629 (void) printf("%cNBIO", sep); 630 ss &= ~SS_NBIO; 631 sep = ','; 632 } 633# endif /* defined(SS_NBIO) */ 634 635# if defined(SS_NOCONN) 636 if (ss & SS_NOCONN) { 637 (void) printf("%cNOCONN", sep); 638 ss &= ~SS_NOCONN; 639 sep = ','; 640 } 641# endif /* defined(SS_NOCONN) */ 642 643# if defined(SS_NODELETE) 644 if (ss & SS_NODELETE) { 645 (void) printf("%cNODELETE", sep); 646 ss &= ~SS_NODELETE; 647 sep = ','; 648 } 649# endif /* defined(SS_NODELETE) */ 650 651# if defined(SS_NOFDREF) 652 if (ss & SS_NOFDREF) { 653 (void) printf("%cNOFDREF", sep); 654 ss &= ~SS_NOFDREF; 655 sep = ','; 656 } 657# endif /* defined(SS_NOFDREF) */ 658 659# if defined(SS_NOGHOST) 660 if (ss & SS_NOGHOST) { 661 (void) printf("%cNOGHOST", sep); 662 ss &= ~SS_NOGHOST; 663 sep = ','; 664 } 665# endif /* defined(SS_NOGHOST) */ 666 667# if defined(SS_NOINPUT) 668 if (ss & SS_NOINPUT) { 669 (void) printf("%cNOINPUT", sep); 670 ss &= ~SS_NOINPUT; 671 sep = ','; 672 } 673# endif /* defined(SS_NOINPUT) */ 674 675# if defined(SS_PRIV) 676 if (ss & SS_PRIV) { 677 (void) printf("%cPRIV", sep); 678 ss &= ~SS_PRIV; 679 sep = ','; 680 } 681# endif /* defined(SS_PRIV) */ 682 683# if defined(SS_QUEUE) 684 if (ss & SS_QUEUE) { 685 (void) printf("%cQUEUE", sep); 686 ss &= ~SS_QUEUE; 687 sep = ','; 688 } 689# endif /* defined(SS_QUEUE) */ 690 691# if defined(HASSBSTATE) 692# if defined(SBS_RCVATMARK) 693 if (Lf->lts.sbs_rcv & SBS_RCVATMARK) { 694 (void) printf("%cRCVATMARK", sep); 695 Lf->lts.sbs_rcv &= ~SBS_RCVATMARK; 696 sep = ','; 697 } 698# endif /* defined(SBS_RCVATMARK) */ 699 700# else /* !defined(HASSBSTATE) */ 701# if defined(SS_RCVATMARK) 702 if (ss & SS_RCVATMARK) { 703 (void) printf("%cRCVATMARK", sep); 704 ss &= ~SS_RCVATMARK; 705 sep = ','; 706 } 707# endif /* defined(SS_RCVATMARK) */ 708# endif /* defined(HASSBSTATE) */ 709 710# if defined(SS_READWAIT) 711 if (ss & SS_READWAIT) { 712 (void) printf("%cREADWAIT", sep); 713 ss &= ~SS_READWAIT; 714 sep = ','; 715 } 716# endif /* defined(SS_READWAIT) */ 717 718# if defined(SS_SETRCV) 719 if (ss & SS_SETRCV) { 720 (void) printf("%cSETRCV", sep); 721 ss &= ~SS_SETRCV; 722 sep = ','; 723 } 724# endif /* defined(SS_SETRCV) */ 725 726# if defined(SS_SETSND) 727 if (ss & SS_SETSND) { 728 (void) printf("%cSETSND", sep); 729 ss &= ~SS_SETSND; 730 sep = ','; 731 } 732# endif /* defined(SS_SETSND) */ 733 734# if defined(SS_SIGREAD) 735 if (ss & SS_SIGREAD) { 736 (void) printf("%cSIGREAD", sep); 737 ss &= ~SS_SIGREAD; 738 sep = ','; 739 } 740# endif /* defined(SS_SIGREAD) */ 741 742# if defined(SS_SIGWRITE) 743 if (ss & SS_SIGWRITE) { 744 (void) printf("%cSIGWRITE", sep); 745 ss &= ~SS_SIGWRITE; 746 sep = ','; 747 } 748# endif /* defined(SS_SIGWRITE) */ 749 750# if defined(SS_SPLICED) 751 if (ss & SS_SPLICED) { 752 (void) printf("%cSPLICED", sep); 753 ss &= ~SS_SPLICED; 754 sep = ','; 755 } 756# endif /* defined(SS_SPLICED) */ 757 758# if defined(SS_WRITEWAIT) 759 if (ss & SS_WRITEWAIT) { 760 (void) printf("%cWRITEWAIT", sep); 761 ss &= ~SS_WRITEWAIT; 762 sep = ','; 763 } 764# endif /* defined(SS_WRITEWAIT) */ 765 766# if defined(SS_ZOMBIE) 767 if (ss & SS_ZOMBIE) { 768 (void) printf("%cZOMBIE", sep); 769 ss &= ~SS_ZOMBIE; 770 sep = ','; 771 } 772# endif /* defined(SS_ZOMBIE) */ 773 774 if (ss) 775 (void) printf("%cUNKNOWN=%#x", sep, ss); 776 if (Ffield) 777 putchar(Terminator); 778 } 779 } 780#endif /* defined(HASSOSTATE) */ 781 782#if defined(HASTCPOPT) 783 if (Ftcptpi & TCPTPI_FLAGS) { 784 int topt; 785 786 if ((topt = Lf->lts.topt) || Lf->lts.msss) { 787 char sep = ' '; 788 789 if (Ffield) 790 sep = LSOF_FID_TCPTPI; 791 else if (!ps) 792 sep = '('; 793 (void) printf("%cTF", sep); 794 ps++; 795 sep = '='; 796 797# if defined(TF_ACKNOW) 798 if (topt & TF_ACKNOW) { 799 (void) printf("%cACKNOW", sep); 800 topt &= ~TF_ACKNOW; 801 sep = ','; 802 } 803# endif /* defined(TF_ACKNOW) */ 804 805# if defined(TF_CANT_TXSACK) 806 if (topt & TF_CANT_TXSACK) { 807 (void) printf("%cCANT_TXSACK", sep); 808 topt &= ~TF_CANT_TXSACK; 809 sep = ','; 810 } 811# endif /* defined(TF_CANT_TXSACK) */ 812 813# if defined(TF_DEAD) 814 if (topt & TF_DEAD) { 815 (void) printf("%cDEAD", sep); 816 topt &= ~TF_DEAD; 817 sep = ','; 818 } 819# endif /* defined(TF_DEAD) */ 820 821# if defined(TF_DELACK) 822 if (topt & TF_DELACK) { 823 (void) printf("%cDELACK", sep); 824 topt &= ~TF_DELACK; 825 sep = ','; 826 } 827# endif /* defined(TF_DELACK) */ 828 829# if defined(TF_DELAY_ACK) 830 if (topt & TF_DELAY_ACK) { 831 (void) printf("%cDELAY_ACK", sep); 832 topt &= ~TF_DELAY_ACK; 833 sep = ','; 834 } 835# endif /* defined(TF_DELAY_ACK) */ 836 837# if defined(TF_DISABLE_ECN) 838 if (topt & TF_DISABLE_ECN) { 839 (void) printf("%cDISABLE_ECN", sep); 840 topt &= ~TF_DISABLE_ECN; 841 sep = ','; 842 } 843# endif /* defined(TF_DISABLE_ECN) */ 844 845# if defined(TF_ECN) 846 if (topt & TF_ECN) { 847 (void) printf("%cECN", sep); 848 topt &= ~TF_ECN; 849 sep = ','; 850 } 851# endif /* defined(TF_ECN) */ 852 853# if defined(TF_ECN_PERMIT) 854 if (topt & TF_ECN_PERMIT) { 855 (void) printf("%cECN_PERMIT", sep); 856 topt &= ~TF_ECN_PERMIT; 857 sep = ','; 858 } 859# endif /* defined(TF_ECN_PERMIT) */ 860 861# if defined(TF_FASTRECOVERY) 862 if (topt & TF_FASTRECOVERY) { 863 (void) printf("%cFASTRECOVERY", sep); 864 topt &= ~TF_FASTRECOVERY; 865 sep = ','; 866 } 867# endif /* defined(TF_FASTRECOVERY) */ 868 869# if defined(TF_FASTRXMT_PHASE) 870 if (topt & TF_FASTRXMT_PHASE) { 871 (void) printf("%cFASTRXMT_PHASE", sep); 872 topt &= ~TF_FASTRXMT_PHASE; 873 sep = ','; 874 } 875# endif /* defined(TF_FASTRXMT_PHASE) */ 876 877# if defined(TF_HAVEACKED) 878 if (topt & TF_HAVEACKED) { 879 (void) printf("%cHAVEACKED", sep); 880 topt &= ~TF_HAVEACKED; 881 sep = ','; 882 } 883# endif /* defined(TF_HAVEACKED) */ 884 885# if defined(TF_HAVECLOSED) 886 if (topt & TF_HAVECLOSED) { 887 (void) printf("%cHAVECLOSED", sep); 888 topt &= ~TF_HAVECLOSED; 889 sep = ','; 890 } 891# endif /* defined(TF_HAVECLOSED) */ 892 893# if defined(TF_IGNR_RXSACK) 894 if (topt & TF_IGNR_RXSACK) { 895 (void) printf("%cIGNR_RXSACK", sep); 896 topt &= ~TF_IGNR_RXSACK; 897 sep = ','; 898 } 899# endif /* defined(TF_IGNR_RXSACK) */ 900 901# if defined(TF_IOLOCK) 902 if (topt & TF_IOLOCK) { 903 (void) printf("%cIOLOCK", sep); 904 topt &= ~TF_IOLOCK; 905 sep = ','; 906 } 907# endif /* defined(TF_IOLOCK) */ 908 909# if defined(TF_LARGESEND) 910 if (topt & TF_LARGESEND) { 911 (void) printf("%cLARGESEND", sep); 912 topt &= ~TF_LARGESEND; 913 sep = ','; 914 } 915# endif /* defined(TF_LARGESEND) */ 916 917# if defined(TF_LASTIDLE) 918 if (topt & TF_LASTIDLE) { 919 (void) printf("%cLASTIDLE", sep); 920 topt &= ~TF_LASTIDLE; 921 sep = ','; 922 } 923# endif /* defined(TF_LASTIDLE) */ 924 925# if defined(TF_LQ_OVERFLOW) 926 if (topt & TF_LQ_OVERFLOW) { 927 (void) printf("%cLQ_OVERFLOW", sep); 928 topt &= ~TF_LQ_OVERFLOW; 929 sep = ','; 930 } 931# endif /* defined(TF_LQ_OVERFLOW) */ 932 933 if (Lf->lts.msss) { 934 (void) printf("%cMSS=%lu", sep, Lf->lts.mss); 935 sep = ','; 936 } 937 938# if defined(TF_MORETOCOME) 939 if (topt & TF_MORETOCOME) { 940 (void) printf("%cMORETOCOME", sep); 941 topt &= ~TF_MORETOCOME; 942 sep = ','; 943 } 944# endif /* defined(TF_MORETOCOME) */ 945 946# if defined(TF_NEEDACK) 947 if (topt & TF_NEEDACK) { 948 (void) printf("%cNEEDACK", sep); 949 topt &= ~TF_NEEDACK; 950 sep = ','; 951 } 952# endif /* defined(TF_NEEDACK) */ 953 954# if defined(TF_NEEDCLOSE) 955 if (topt & TF_NEEDCLOSE) { 956 (void) printf("%cNEEDCLOSE", sep); 957 topt &= ~TF_NEEDCLOSE; 958 sep = ','; 959 } 960# endif /* defined(TF_NEEDCLOSE) */ 961 962# if defined(TF_NEEDFIN) 963 if (topt & TF_NEEDFIN) { 964 (void) printf("%cNEEDFIN", sep); 965 topt &= ~TF_NEEDFIN; 966 sep = ','; 967 } 968# endif /* defined(TF_NEEDFIN) */ 969 970# if defined(TF_NEEDIN) 971 if (topt & TF_NEEDIN) { 972 (void) printf("%cNEEDIN", sep); 973 topt &= ~TF_NEEDIN; 974 sep = ','; 975 } 976# endif /* defined(TF_NEEDIN) */ 977 978# if defined(TF_NEEDOUT) 979 if (topt & TF_NEEDOUT) { 980 (void) printf("%cNEEDOUT", sep); 981 topt &= ~TF_NEEDOUT; 982 sep = ','; 983 } 984# endif /* defined(TF_NEEDOUT) */ 985 986# if defined(TF_NEEDSYN) 987 if (topt & TF_NEEDSYN) { 988 (void) printf("%cNEEDSYN", sep); 989 topt &= ~TF_NEEDSYN; 990 sep = ','; 991 } 992# endif /* defined(TF_NEEDSYN) */ 993 994# if defined(TF_NEEDTIMER) 995 if (topt & TF_NEEDTIMER) { 996 (void) printf("%cNEEDTIMER", sep); 997 topt &= ~TF_NEEDTIMER; 998 sep = ','; 999 } 1000# endif /* defined(TF_NEEDTIMER) */ 1001 1002# if defined(TF_NEWRENO_RXMT) 1003 if (topt & TF_NEWRENO_RXMT) { 1004 (void) printf("%cNEWRENO_RXMT", sep); 1005 topt &= ~TF_NEWRENO_RXMT; 1006 sep = ','; 1007 } 1008# endif /* defined(TF_NEWRENO_RXMT) */ 1009 1010# if defined(TF_NODELACK) 1011 if (topt & TF_NODELACK) { 1012 (void) printf("%cNODELACK", sep); 1013 topt &= ~TF_NODELACK; 1014 sep = ','; 1015 } 1016# endif /* defined(TF_NODELACK) */ 1017 1018# if defined(TF_NODELAY) 1019 if (topt & TF_NODELAY) { 1020 (void) printf("%cNODELAY", sep); 1021 topt &= ~TF_NODELAY; 1022 sep = ','; 1023 } 1024# endif /* defined(TF_NODELAY) */ 1025 1026# if defined(TF_NOOPT) 1027 if (topt & TF_NOOPT) { 1028 (void) printf("%cNOOPT", sep); 1029 topt &= ~TF_NOOPT; 1030 sep = ','; 1031 } 1032# endif /* defined(TF_NOOPT) */ 1033 1034# if defined(TF_NOPUSH) 1035 if (topt & TF_NOPUSH) { 1036 (void) printf("%cNOPUSH", sep); 1037 topt &= ~TF_NOPUSH; 1038 sep = ','; 1039 } 1040# endif /* defined(TF_NOPUSH) */ 1041 1042# if defined(TF_NO_PMTU) 1043 if (topt & TF_NO_PMTU) { 1044 (void) printf("%cNO_PMTU", sep); 1045 topt &= ~TF_NO_PMTU; 1046 sep = ','; 1047 } 1048# endif /* defined(TF_NO_PMTU) */ 1049 1050# if defined(TF_RAW) 1051 if (topt & TF_RAW) { 1052 (void) printf("%cRAW", sep); 1053 topt &= ~TF_RAW; 1054 sep = ','; 1055 } 1056# endif /* defined(TF_RAW) */ 1057 1058# if defined(TF_RCVD_CC) 1059 if (topt & TF_RCVD_CC) { 1060 (void) printf("%cRCVD_CC", sep); 1061 topt &= ~TF_RCVD_CC; 1062 sep = ','; 1063 } 1064# endif /* defined(TF_RCVD_CC) */ 1065 1066# if defined(TF_RCVD_SCALE) 1067 if (topt & TF_RCVD_SCALE) { 1068 (void) printf("%cRCVD_SCALE", sep); 1069 topt &= ~TF_RCVD_SCALE; 1070 sep = ','; 1071 } 1072# endif /* defined(TF_RCVD_SCALE) */ 1073 1074# if defined(TF_RCVD_CE) 1075 if (topt & TF_RCVD_CE) { 1076 (void) printf("%cRCVD_CE", sep); 1077 topt &= ~TF_RCVD_CE; 1078 sep = ','; 1079 } 1080# endif /* defined(TF_RCVD_CE) */ 1081 1082# if defined(TF_RCVD_TS) 1083 if (topt & TF_RCVD_TS) { 1084 (void) printf("%cRCVD_TS", sep); 1085 topt &= ~TF_RCVD_TS; 1086 sep = ','; 1087 } 1088# endif /* defined(TF_RCVD_TS) */ 1089 1090# if defined(TF_RCVD_TSTMP) 1091 if (topt & TF_RCVD_TSTMP) { 1092 (void) printf("%cRCVD_TSTMP", sep); 1093 topt &= ~TF_RCVD_TSTMP; 1094 sep = ','; 1095 } 1096# endif /* defined(TF_RCVD_TSTMP) */ 1097 1098# if defined(TF_RCVD_WS) 1099 if (topt & TF_RCVD_WS) { 1100 (void) printf("%cRCVD_WS", sep); 1101 topt &= ~TF_RCVD_WS; 1102 sep = ','; 1103 } 1104# endif /* defined(TF_RCVD_WS) */ 1105 1106# if defined(TF_REASSEMBLING) 1107 if (topt & TF_REASSEMBLING) { 1108 (void) printf("%cREASSEMBLING", sep); 1109 topt &= ~TF_REASSEMBLING; 1110 sep = ','; 1111 } 1112# endif /* defined(TF_REASSEMBLING) */ 1113 1114# if defined(TF_REQ_CC) 1115 if (topt & TF_REQ_CC) { 1116 (void) printf("%cREQ_CC", sep); 1117 topt &= ~TF_REQ_CC; 1118 sep = ','; 1119 } 1120# endif /* defined(TF_REQ_CC) */ 1121 1122# if defined(TF_REQ_SCALE) 1123 if (topt & TF_REQ_SCALE) { 1124 (void) printf("%cREQ_SCALE", sep); 1125 topt &= ~TF_REQ_SCALE; 1126 sep = ','; 1127 } 1128# endif /* defined(TF_REQ_SCALE) */ 1129 1130# if defined(TF_REQ_TSTMP) 1131 if (topt & TF_REQ_TSTMP) { 1132 (void) printf("%cREQ_TSTMP", sep); 1133 topt &= ~TF_REQ_TSTMP; 1134 sep = ','; 1135 } 1136# endif /* defined(TF_REQ_TSTMP) */ 1137 1138# if defined(TF_RFC1323) 1139 if (topt & TF_RFC1323) { 1140 (void) printf("%cRFC1323", sep); 1141 topt &= ~TF_RFC1323; 1142 sep = ','; 1143 } 1144# endif /* defined(TF_RFC1323) */ 1145 1146# if defined(TF_RXWIN0SENT) 1147 if (topt & TF_RXWIN0SENT) { 1148 (void) printf("%cRXWIN0SENT", sep); 1149 topt &= ~TF_RXWIN0SENT; 1150 sep = ','; 1151 } 1152# endif /* defined(TF_RXWIN0SENT) */ 1153 1154# if defined(TF_SACK_GENERATE) 1155 if (topt & TF_SACK_GENERATE) { 1156 (void) printf("%cSACK_GENERATE", sep); 1157 topt &= ~TF_SACK_GENERATE; 1158 sep = ','; 1159 } 1160# endif /* defined(TF_SACK_GENERATE) */ 1161 1162# if defined(TF_SACK_PERMIT) 1163 if (topt & TF_SACK_PERMIT) { 1164 (void) printf("%cSACK_PERMIT", sep); 1165 topt &= ~TF_SACK_PERMIT; 1166 sep = ','; 1167 } 1168# endif /* defined(TF_SACK_PERMIT) */ 1169 1170# if defined(TF_SACK_PROCESS) 1171 if (topt & TF_SACK_PROCESS) { 1172 (void) printf("%cSACK_PROCESS", sep); 1173 topt &= ~TF_SACK_PROCESS; 1174 sep = ','; 1175 } 1176# endif /* defined(TF_SACK_PROCESS) */ 1177 1178# if defined(TF_SEND) 1179 if (topt & TF_SEND) { 1180 (void) printf("%cSEND", sep); 1181 topt &= ~TF_SEND; 1182 sep = ','; 1183 } 1184# endif /* defined(TF_SEND) */ 1185 1186# if defined(TF_SEND_AND_DISCONNECT) 1187 if (topt & TF_SEND_AND_DISCONNECT) { 1188 (void) printf("%cSEND_AND_DISCONNECT", sep); 1189 topt &= ~TF_SEND_AND_DISCONNECT; 1190 sep = ','; 1191 } 1192# endif /* defined(TF_SEND_AND_DISCONNECT) */ 1193 1194# if defined(TF_SENDCCNEW) 1195 if (topt & TF_SENDCCNEW) { 1196 (void) printf("%cSENDCCNEW", sep); 1197 topt &= ~TF_SENDCCNEW; 1198 sep = ','; 1199 } 1200# endif /* defined(TF_SENDCCNEW) */ 1201 1202# if defined(TF_SEND_CWR) 1203 if (topt & TF_SEND_CWR) { 1204 (void) printf("%cSEND_CWR", sep); 1205 topt &= ~TF_SEND_CWR; 1206 sep = ','; 1207 } 1208# endif /* defined(TF_SEND_CWR) */ 1209 1210# if defined(TF_SEND_ECHO) 1211 if (topt & TF_SEND_ECHO) { 1212 (void) printf("%cSEND_ECHO", sep); 1213 topt &= ~TF_SEND_ECHO; 1214 sep = ','; 1215 } 1216# endif /* defined(TF_SEND_ECHO) */ 1217 1218# if defined(TF_SEND_TSTMP) 1219 if (topt & TF_SEND_TSTMP) { 1220 (void) printf("%cSEND_TSTMP", sep); 1221 topt &= ~TF_SEND_TSTMP; 1222 sep = ','; 1223 } 1224# endif /* defined(TF_SEND_TSTMP) */ 1225 1226# if defined(TF_SENTFIN) 1227 if (topt & TF_SENTFIN) { 1228 (void) printf("%cSENTFIN", sep); 1229 topt &= ~TF_SENTFIN; 1230 sep = ','; 1231 } 1232# endif /* defined(TF_SENTFIN) */ 1233 1234# if defined(TF_SENT_TS) 1235 if (topt & TF_SENT_TS) { 1236 (void) printf("%cSENT_TS", sep); 1237 topt &= ~TF_SENT_TS; 1238 sep = ','; 1239 } 1240# endif /* defined(TF_SENT_TS) */ 1241 1242# if defined(TF_SENT_WS) 1243 if (topt & TF_SENT_WS) { 1244 (void) printf("%cSENT_WS", sep); 1245 topt &= ~TF_SENT_WS; 1246 sep = ','; 1247 } 1248# endif /* defined(TF_SENT_WS) */ 1249 1250# if defined(TF_SIGNATURE) 1251 if (topt & TF_SIGNATURE) { 1252 (void) printf("%cSIGNATURE", sep); 1253 topt &= ~TF_SIGNATURE; 1254 sep = ','; 1255 } 1256# endif /* defined(TF_SIGNATURE) */ 1257 1258# if defined(TF_SLOWLINK) 1259 if (topt & TF_SLOWLINK) { 1260 (void) printf("%cSLOWLINK", sep); 1261 topt &= ~TF_SLOWLINK; 1262 sep = ','; 1263 } 1264# endif /* defined(TF_SLOWLINK) */ 1265 1266# if defined(TF_STDURG) 1267 if (topt & TF_STDURG) { 1268 (void) printf("%cSTDURG", sep); 1269 topt &= ~TF_STDURG; 1270 sep = ','; 1271 } 1272# endif /* defined(TF_STDURG) */ 1273 1274# if defined(TF_SYN_REXMT) 1275 if (topt & TF_SYN_REXMT) { 1276 (void) printf("%cSYN_REXMT", sep); 1277 topt &= ~TF_SYN_REXMT; 1278 sep = ','; 1279 } 1280# endif /* defined(TF_SYN_REXMT) */ 1281 1282# if defined(TF_UIOMOVED) 1283 if (topt & TF_UIOMOVED) { 1284 (void) printf("%cUIOMOVED", sep); 1285 topt &= ~TF_UIOMOVED; 1286 sep = ','; 1287 } 1288# endif /* defined(TF_UIOMOVED) */ 1289 1290# if defined(TF_USE_SCALE) 1291 if (topt & TF_USE_SCALE) { 1292 (void) printf("%cUSE_SCALE", sep); 1293 topt &= ~TF_USE_SCALE; 1294 sep = ','; 1295 } 1296# endif /* defined(TF_USE_SCALE) */ 1297 1298# if defined(TF_WASIDLE) 1299 if (topt & TF_WASIDLE) { 1300 (void) printf("%cWASIDLE", sep); 1301 topt &= ~TF_WASIDLE; 1302 sep = ','; 1303 } 1304# endif /* defined(TF_WASIDLE) */ 1305 1306# if defined(TF_WASFRECOVERY) 1307 if (topt & TF_WASFRECOVERY) { 1308 (void) printf("%cWASFRECOVERY", sep); 1309 topt &= ~TF_WASFRECOVERY; 1310 sep = ','; 1311 } 1312# endif /* defined(TF_WASFRECOVERY) */ 1313 1314# if defined(TF_WILL_SACK) 1315 if (topt & TF_WILL_SACK) { 1316 (void) printf("%cWILL_SACK", sep); 1317 topt &= ~TF_WILL_SACK; 1318 sep = ','; 1319 } 1320# endif /* defined(TF_WILL_SACK) */ 1321 1322 if (topt) 1323 (void) printf("%cUNKNOWN=%#x", sep, topt); 1324 if (Ffield) 1325 putchar(Terminator); 1326 } 1327 } 1328#endif /* defined(HASTCPOPT) */ 1329 1330#if defined(HASTCPTPIW) 1331 if (Ftcptpi & TCPTPI_WINDOWS) { 1332 if (Lf->lts.rws) { 1333 if (Ffield) 1334 putchar(LSOF_FID_TCPTPI); 1335 else { 1336 if (ps) 1337 putchar(' '); 1338 else 1339 putchar('('); 1340 } 1341 (void) printf("WR=%lu", Lf->lts.rw); 1342 if (Ffield) 1343 putchar(Terminator); 1344 ps++; 1345 } 1346 if (Lf->lts.wws) { 1347 if (Ffield) 1348 putchar(LSOF_FID_TCPTPI); 1349 else { 1350 if (ps) 1351 putchar(' '); 1352 else 1353 putchar('('); 1354 } 1355 (void) printf("WW=%lu", Lf->lts.ww); 1356 if (Ffield) 1357 putchar(Terminator); 1358 ps++; 1359 } 1360 } 1361#endif /* defined(HASTCPTPIW) */ 1362 1363 if (ps && !Ffield) 1364 putchar(')'); 1365 if (nl) 1366 putchar('\n'); 1367} 1368#else /* !defined(USE_LIB_PRINT_TCPTPI) */ 1369char ptti_d1[] = "d"; char *ptti_d2 = ptti_d1; 1370#endif /* defined(USE_LIB_PRINT_TCPTPI) */ 1371