MCPcopy Index your code
hub / github.com/F-Stack/f-stack / inetname

Function inetname

tools/netstat/inet.c:1468–1510  ·  view source on GitHub ↗

* Construct an Internet address representation. * If numeric_addr has been supplied, give * numeric value, otherwise try for symbolic name. */

Source from the content-addressed store, hash-verified

1466 * numeric value, otherwise try for symbolic name.
1467 */
1468char *
1469inetname(struct in_addr *inp)
1470{
1471 char *cp;
1472 static char line[MAXHOSTNAMELEN];
1473#ifndef FSTACK
1474 struct hostent *hp;
1475 struct netent *np;
1476#endif
1477
1478 cp = 0;
1479#ifndef FSTACK
1480 if (!numeric_addr && inp->s_addr != INADDR_ANY) {
1481 int net = inet_netof(*inp);
1482 int lna = inet_lnaof(*inp);
1483
1484 if (lna == INADDR_ANY) {
1485 np = getnetbyaddr(net, AF_INET);
1486 if (np)
1487 cp = np->n_name;
1488 }
1489 if (cp == NULL) {
1490 hp = gethostbyaddr((char *)inp, sizeof (*inp), AF_INET);
1491 if (hp) {
1492 cp = hp->h_name;
1493 trimdomain(cp, strlen(cp));
1494 }
1495 }
1496 }
1497#endif
1498 if (inp->s_addr == INADDR_ANY)
1499 strcpy(line, "*");
1500 else if (cp) {
1501 strlcpy(line, cp, sizeof(line));
1502 } else {
1503 inp->s_addr = ntohl(inp->s_addr);
1504#define C(x) ((u_int)((x) & 0xff))
1505 snprintf(line, sizeof(line), "%u.%u.%u.%u",
1506 C(inp->s_addr >> 24), C(inp->s_addr >> 16),
1507 C(inp->s_addr >> 8), C(inp->s_addr));
1508 }
1509 return (line);
1510}
1511#endif

Callers 2

inetprintFunction · 0.85
sctp_print_addressFunction · 0.85

Calls 3

trimdomainFunction · 0.85
snprintfFunction · 0.85
strlcpyFunction · 0.50

Tested by

no test coverage detected