| 487 | |
| 488 | |
| 489 | char * |
| 490 | routename(struct sockaddr *sa, int flags) |
| 491 | { |
| 492 | static char line[NI_MAXHOST]; |
| 493 | int error, f; |
| 494 | |
| 495 | f = (flags) ? NI_NUMERICHOST : 0; |
| 496 | error = getnameinfo(sa, sa->sa_len, line, sizeof(line), |
| 497 | NULL, 0, f); |
| 498 | if (error) { |
| 499 | const void *src; |
| 500 | switch (sa->sa_family) { |
| 501 | #ifdef INET |
| 502 | case AF_INET: |
| 503 | src = &satosin(sa)->sin_addr; |
| 504 | inet_ntop(sa->sa_family, src, line, sizeof(line) - 1); |
| 505 | break; |
| 506 | #endif /* INET */ |
| 507 | #ifdef INET6 |
| 508 | case AF_INET6: |
| 509 | src = &satosin6(sa)->sin6_addr; |
| 510 | inet_ntop(AF_INET6_LINUX, src, line, sizeof(line) - 1); |
| 511 | break; |
| 512 | #endif /* INET6 */ |
| 513 | default: |
| 514 | return(line); |
| 515 | } |
| 516 | return (line); |
| 517 | } |
| 518 | trimdomain(line, strlen(line)); |
| 519 | |
| 520 | return (line); |
| 521 | } |
| 522 | |
| 523 | #define NSHIFT(m) ( \ |
| 524 | (m) == IN_CLASSA_NET ? IN_CLASSA_NSHIFT : \ |
no test coverage detected