MCPcopy Create free account
hub / github.com/F-Stack/f-stack / domask

Function domask

tools/netstat/route.c:529–555  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

527 0)
528
529static void
530domask(char *dst, size_t buflen, u_long mask)
531{
532 int b, i;
533
534 if (mask == 0) {
535 *dst = '\0';
536 return;
537 }
538 i = 0;
539 for (b = 0; b < 32; b++)
540 if (mask & (1 << b)) {
541 int bb;
542
543 i = b;
544 for (bb = b+1; bb < 32; bb++)
545 if (!(mask & (1 << bb))) {
546 i = -1; /* noncontig */
547 break;
548 }
549 break;
550 }
551 if (i == -1)
552 snprintf(dst, buflen, "&0x%lx", mask);
553 else
554 snprintf(dst, buflen, "/%d", 32-i);
555}
556
557/*
558 * Return the name of the network whose address is given.

Callers 1

netname4Function · 0.85

Calls 1

snprintfFunction · 0.85

Tested by

no test coverage detected