| 107 | }; |
| 108 | |
| 109 | static void |
| 110 | sctp_print_address(const char *container, union sctp_sockstore *address, |
| 111 | int port, int num_port) |
| 112 | { |
| 113 | struct servent *sp = 0; |
| 114 | char line[80], *cp; |
| 115 | int width; |
| 116 | size_t alen, plen; |
| 117 | |
| 118 | if (container) |
| 119 | xo_open_container(container); |
| 120 | |
| 121 | switch (address->sa.sa_family) { |
| 122 | #ifdef INET |
| 123 | case AF_INET: |
| 124 | snprintf(line, sizeof(line), "%.*s.", |
| 125 | Wflag ? 39 : 16, inetname(&address->sin.sin_addr)); |
| 126 | break; |
| 127 | #endif |
| 128 | #ifdef INET6 |
| 129 | case AF_INET6: |
| 130 | snprintf(line, sizeof(line), "%.*s.", |
| 131 | Wflag ? 39 : 16, inet6name(&address->sin6.sin6_addr)); |
| 132 | break; |
| 133 | #endif |
| 134 | default: |
| 135 | snprintf(line, sizeof(line), "%.*s.", |
| 136 | Wflag ? 39 : 16, ""); |
| 137 | break; |
| 138 | } |
| 139 | alen = strlen(line); |
| 140 | cp = line + alen; |
| 141 | if (!num_port && port) |
| 142 | sp = getservbyport((int)port, "sctp"); |
| 143 | if (sp || port == 0) |
| 144 | snprintf(cp, sizeof(line) - alen, |
| 145 | "%.15s ", sp ? sp->s_name : "*"); |
| 146 | else |
| 147 | snprintf(cp, sizeof(line) - alen, |
| 148 | "%d ", ntohs((u_short)port)); |
| 149 | width = Wflag ? 45 : 22; |
| 150 | xo_emit("{d:target/%-*.*s} ", width, width, line); |
| 151 | |
| 152 | plen = strlen(cp) - 1; |
| 153 | alen--; |
| 154 | xo_emit("{e:address/%*.*s}{e:port/%*.*s}", alen, alen, line, plen, |
| 155 | plen, cp); |
| 156 | |
| 157 | if (container) |
| 158 | xo_close_container(container); |
| 159 | } |
| 160 | |
| 161 | static int |
| 162 | sctp_skip_xinpcb_ifneed(char *buf, const size_t buflen, size_t *offset) |
no test coverage detected