* Print out protocol statistics or control blocks (per sflag). * If the interface was not specifically requested, and the symbol * is not in the namelist, ignore this one. */
| 708 | * is not in the namelist, ignore this one. |
| 709 | */ |
| 710 | static void |
| 711 | printproto(struct protox *tp, const char *name, bool *first) |
| 712 | { |
| 713 | void (*pr)(u_long, const char *, int, int); |
| 714 | u_long off; |
| 715 | bool doingdblocks = false; |
| 716 | |
| 717 | if (sflag) { |
| 718 | if (iflag) { |
| 719 | if (tp->pr_istats) |
| 720 | intpr(tp->pr_istats, af); |
| 721 | else if (pflag) |
| 722 | xo_message("%s: no per-interface stats routine", |
| 723 | tp->pr_name); |
| 724 | return; |
| 725 | } else { |
| 726 | pr = tp->pr_stats; |
| 727 | if (!pr) { |
| 728 | if (pflag) |
| 729 | xo_message("%s: no stats routine", |
| 730 | tp->pr_name); |
| 731 | return; |
| 732 | } |
| 733 | if (tp->pr_usesysctl && live) |
| 734 | off = 0; |
| 735 | else if (tp->pr_sindex < 0) { |
| 736 | if (pflag) |
| 737 | xo_message("%s: stats routine doesn't " |
| 738 | "work on cores", tp->pr_name); |
| 739 | return; |
| 740 | } else |
| 741 | off = nl[tp->pr_sindex].n_value; |
| 742 | } |
| 743 | } else { |
| 744 | doingdblocks = true; |
| 745 | pr = tp->pr_cblocks; |
| 746 | if (!pr) { |
| 747 | if (pflag) |
| 748 | xo_message("%s: no PCB routine", tp->pr_name); |
| 749 | return; |
| 750 | } |
| 751 | if (tp->pr_usesysctl && live) |
| 752 | off = 0; |
| 753 | else if (tp->pr_index < 0) { |
| 754 | if (pflag) |
| 755 | xo_message("%s: PCB routine doesn't work on " |
| 756 | "cores", tp->pr_name); |
| 757 | return; |
| 758 | } else |
| 759 | off = nl[tp->pr_index].n_value; |
| 760 | } |
| 761 | if (pr != NULL && (off || (live && tp->pr_usesysctl) || |
| 762 | af != AF_UNSPEC)) { |
| 763 | if (doingdblocks && *first) { |
| 764 | xo_open_list("socket"); |
| 765 | *first = false; |
| 766 | } |
| 767 |
no test coverage detected