| 1284 | }; |
| 1285 | |
| 1286 | void |
| 1287 | inet6print(const char *container, struct in6_addr *in6, int port, |
| 1288 | const char *proto, int numeric) |
| 1289 | { |
| 1290 | struct servent *sp = 0; |
| 1291 | char line[80], *cp; |
| 1292 | int width; |
| 1293 | size_t alen, plen; |
| 1294 | |
| 1295 | if (container) |
| 1296 | xo_open_container(container); |
| 1297 | |
| 1298 | snprintf(line, sizeof(line), "%.*s.", |
| 1299 | Wflag ? 39 : (Aflag && !numeric) ? 12 : 16, |
| 1300 | inet6name(in6)); |
| 1301 | alen = strlen(line); |
| 1302 | cp = line + alen; |
| 1303 | if (!numeric && port) |
| 1304 | GETSERVBYPORT6(port, proto, sp); |
| 1305 | if (sp || port == 0) |
| 1306 | snprintf(cp, sizeof(line) - alen, |
| 1307 | "%.15s", sp ? sp->s_name : "*"); |
| 1308 | else |
| 1309 | snprintf(cp, sizeof(line) - alen, |
| 1310 | "%d", ntohs((u_short)port)); |
| 1311 | width = Wflag ? 45 : Aflag ? 18 : 22; |
| 1312 | |
| 1313 | xo_emit("{d:target/%-*.*s} ", width, width, line); |
| 1314 | |
| 1315 | plen = strlen(cp); |
| 1316 | alen--; |
| 1317 | xo_emit("{e:address/%*.*s}{e:port/%*.*s}", alen, alen, line, plen, |
| 1318 | plen, cp); |
| 1319 | |
| 1320 | if (container) |
| 1321 | xo_close_container(container); |
| 1322 | } |
| 1323 | |
| 1324 | /* |
| 1325 | * Construct an Internet address representation. |
no test coverage detected