diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/net/getnameinfo.c | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/lib/libc/net/getnameinfo.c b/lib/libc/net/getnameinfo.c index 33e628c6238..673ead74ba9 100644 --- a/lib/libc/net/getnameinfo.c +++ b/lib/libc/net/getnameinfo.c @@ -1,4 +1,5 @@ -/* $OpenBSD: getnameinfo.c,v 1.13 2000/04/26 14:46:47 itojun Exp $ */ +/* $OpenBSD: getnameinfo.c,v 1.14 2000/04/26 16:08:12 itojun Exp $ */ +/* $KAME: getnameinfo.c,v 1.38 2000/04/26 15:58:50 itojun Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -85,9 +86,9 @@ struct sockinet { }; #ifdef INET6 -static int ip6_parsenumeric __P((const struct sockaddr *, char *, char *, - int, int)); -static int ip6_sa2str __P((struct sockaddr_in6 *, char *, size_t, int)); +static int ip6_parsenumeric __P((const struct sockaddr *, const char *, char *, + size_t, int)); +static int ip6_sa2str __P((const struct sockaddr_in6 *, char *, size_t, int)); #endif #define ENI_NOSOCKET 0 @@ -113,7 +114,7 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags) struct hostent *hp; u_short port; int family, i; - char *addr; + const char *addr; u_int32_t v4a; int h_error; char numserv[512]; @@ -137,8 +138,9 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags) if (salen != afd->a_socklen) return ENI_SALEN; - port = ((struct sockinet *)sa)->si_port; /* network byte order */ - addr = (char *)sa + afd->a_off; + /* network byte order */ + port = ((const struct sockinet *)sa)->si_port; + addr = (const char *)sa + afd->a_off; if (serv == NULL || servlen == 0) { /* @@ -169,7 +171,7 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags) switch (sa->sa_family) { case AF_INET: v4a = (u_int32_t) - ntohl(((struct sockaddr_in *)sa)->sin_addr.s_addr); + ntohl(((const struct sockaddr_in *)sa)->sin_addr.s_addr); if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a)) flags |= NI_NUMERICHOST; v4a >>= IN_CLASSA_NSHIFT; @@ -179,8 +181,8 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags) #ifdef INET6 case AF_INET6: { - struct sockaddr_in6 *sin6; - sin6 = (struct sockaddr_in6 *)sa; + const struct sockaddr_in6 *sin6; + sin6 = (const struct sockaddr_in6 *)sa; switch (sin6->sin6_addr.s6_addr[0]) { case 0x00: if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) @@ -249,6 +251,7 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags) * implemented here - see RFC2553 p30 */ if (flags & NI_NOFQDN) { + char *p; p = strchr(hp->h_name, '.'); if (p) *p = '\0'; @@ -289,8 +292,10 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags) static int ip6_parsenumeric(sa, addr, host, hostlen, flags) const struct sockaddr *sa; - char *addr, *host; - int flags, hostlen; + const char *addr; + char *host; + size_t hostlen; + int flags; { int numaddrlen; char numaddr[512]; @@ -305,14 +310,14 @@ ip6_parsenumeric(sa, addr, host, hostlen, flags) strcpy(host, numaddr); #ifdef NI_WITHSCOPEID - if (((struct sockaddr_in6 *)sa)->sin6_scope_id) { + if (((const struct sockaddr_in6 *)sa)->sin6_scope_id) { if (flags & NI_WITHSCOPEID) { char scopebuf[MAXHOSTNAMELEN]; int scopelen; /* ip6_sa2str never fails */ - scopelen = ip6_sa2str((struct sockaddr_in6 *)sa, + scopelen = ip6_sa2str((const struct sockaddr_in6 *)sa, scopebuf, sizeof(scopebuf), 0); if (scopelen + 1 + numaddrlen + 1 > hostlen) @@ -334,13 +339,13 @@ ip6_parsenumeric(sa, addr, host, hostlen, flags) /* ARGSUSED */ static int ip6_sa2str(sa6, buf, bufsiz, flags) - struct sockaddr_in6 *sa6; + const struct sockaddr_in6 *sa6; char *buf; size_t bufsiz; int flags; { unsigned int ifindex = (unsigned int)sa6->sin6_scope_id; - struct in6_addr *a6 = &sa6->sin6_addr; + const struct in6_addr *a6 = &sa6->sin6_addr; #ifdef notyet if (flags & NI_NUMERICSCOPE) { |