diff options
author | pst <pst@FreeBSD.org> | 1994-09-22 19:31:29 +0000 |
---|---|---|
committer | pst <pst@FreeBSD.org> | 1994-09-22 19:31:29 +0000 |
commit | dc4fe996accf9ff5f0e1c9fa6e0f4b0f45316852 (patch) | |
tree | adf66d37e15c60b728647cff59fdd7c4861bac8f /lib/libc | |
parent | 5f25a8f3038a7f38e1d8ebf2befeb9cbb2ee6c29 (diff) | |
download | FreeBSD-src-dc4fe996accf9ff5f0e1c9fa6e0f4b0f45316852.zip FreeBSD-src-dc4fe996accf9ff5f0e1c9fa6e0f4b0f45316852.tar.gz |
Make iso_addr's output conform to modern conventions for NSAP
representation. Original code by pst but ported in as part of
enhancements to BIND 4.9.2 and returned to Vixie.
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/net/iso_addr.c | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/lib/libc/net/iso_addr.c b/lib/libc/net/iso_addr.c index 9ca92f3..41dc531 100644 --- a/lib/libc/net/iso_addr.c +++ b/lib/libc/net/iso_addr.c @@ -90,30 +90,28 @@ iso_addr(addr) out_addr.isoa_len = cp - out_addr.isoa_genaddr; return (&out_addr); } + static char hexlist[] = "0123456789abcdef"; char * iso_ntoa(isoa) const struct iso_addr *isoa; { - static char obuf[64]; - register char *out = obuf; - register int i; - register u_char *in = (u_char *)isoa->isoa_genaddr; - u_char *inlim = in + isoa->isoa_len; + static char tmpbuf[sizeof(isoa->isoa_genaddr)*3]; + const u_char *binary; + char *cp; + int i; + + binary = isoa->isoa_genaddr; + cp = tmpbuf; + + for (i = 0; i < isoa->isoa_len; i++) { + *cp++ = hexlist[*binary >> 4]; + *cp++ = hexlist[*binary++ & 0xf]; - out[1] = 0; - while (in < inlim) { - i = *in++; - *out++ = '.'; - if (i > 0xf) { - out[1] = hexlist[i & 0xf]; - i >>= 4; - out[0] = hexlist[i]; - out += 2; - } else - *out++ = hexlist[i]; + if ((((i % 2) == 0) && ((i + 1) < isoa->isoa_len))) + *cp++ = '.'; } - *out = 0; - return(obuf + 1); + *cp = '\0'; + return tmpbuf; } |