diff options
author | shin <shin@FreeBSD.org> | 2000-02-10 02:59:50 +0000 |
---|---|---|
committer | shin <shin@FreeBSD.org> | 2000-02-10 02:59:50 +0000 |
commit | bf70ca5c10ab771d51b44fdada006c5ec5515f04 (patch) | |
tree | dfda42e673026bffc09df760606ced9dab4a35e1 /lib | |
parent | 71b17017a34cc8a1346d155debf51f6b57522d11 (diff) | |
download | FreeBSD-src-bf70ca5c10ab771d51b44fdada006c5ec5515f04.zip FreeBSD-src-bf70ca5c10ab771d51b44fdada006c5ec5515f04.tar.gz |
Let getaddrinfo() and related functions supports traditional IPv4 format
(shortend format, etc)
Current KAME getaddrinfo() supports only d.d.d.d format IPv4
addr. But traditionally inet_aton() and etc support other formats.
(shortend format and octal/deciaml/hex format)
Aboud this,
-As far as the discussion on freebsd-current, many people
think traditional format should also be supported by getaddrinfo().
-X/Open spec requires getaddrinfo() also support those
traditional IPv4 format.
-RFC2553 say nothing about it.
-As the result of confirmation in ietf/ipng list, there is
no clear concensus yet, and the reply was, "RFC2553 update
and X/Open spec will be in sync"
So takeing these conditions into account, I think
getaddrinfo() should also support traditional IPv4 format.
Specified by: Marc Schneiders <marc@oldserver.demon.nl>
Approved by: jkh
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/net/getaddrinfo.c | 4 | ||||
-rw-r--r-- | lib/libc/net/name6.c | 10 |
2 files changed, 10 insertions, 4 deletions
diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c index 125ea69..8b6d6b7 100644 --- a/lib/libc/net/getaddrinfo.c +++ b/lib/libc/net/getaddrinfo.c @@ -635,7 +635,9 @@ explore_numeric(pai, hostname, servname, res) return 0; flags = pai->ai_flags; - if (inet_pton(afd->a_af, hostname, pton) == 1) { + if ((afd->a_af == AF_INET + ? inet_aton(hostname, (struct in_addr *)pton) + : inet_pton(afd->a_af, hostname, pton)) == 1) { if (pai->ai_family == afd->a_af || pai->ai_family == PF_UNSPEC /*?*/) { GET_AI(cur->ai_next, afd, pton); diff --git a/lib/libc/net/name6.c b/lib/libc/net/name6.c index 3f39d03..31bc261 100644 --- a/lib/libc/net/name6.c +++ b/lib/libc/net/name6.c @@ -296,7 +296,7 @@ getipnodebyname(const char *name, int af, int flags, int *errp) return _hpaddr(af, name, &addrbuf, errp); } #endif - if (inet_pton(AF_INET, name, &addrbuf) == 1) { + if (inet_aton(name, (struct in_addr *)&addrbuf) == 1) { if (af != AF_INET) { if (MAPADDRENABLED(flags)) { MAPADDR(&addrbuf, &addrbuf.in_addr); @@ -759,7 +759,9 @@ _files_ghbyname(const char *name, int af, int *errp) } if (!match) continue; - if (inet_pton(af, addrstr, &addrbuf) != 1) { + if ((af == AF_INET + ? inet_aton(addrstr, (struct in_addr *)&addrbuf) + : inet_pton(af, addrstr, &addrbuf)) != 1) { *errp = NO_DATA; /* name found */ continue; } @@ -796,7 +798,9 @@ _files_ghbyaddr(const void *addr, int addrlen, int af, int *errp) while (fgets(buf, sizeof(buf), fp)) { line = buf; if ((p = _hgetword(&line)) == NULL - || inet_pton(af, p, &addrbuf) != 1 + || (af == AF_INET + ? inet_aton(p, (struct in_addr *)&addrbuf) + : inet_pton(af, p, &addrbuf)) != 1 || memcmp(addr, &addrbuf, addrlen) != 0 || (p = _hgetword(&line)) == NULL) continue; |