-/* $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.
};
#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
struct hostent *hp;
u_short port;
int family, i;
- char *addr;
+ const char *addr;
u_int32_t v4a;
int h_error;
char numserv[512];
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) {
/*
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;
#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))
* implemented here - see RFC2553 p30
*/
if (flags & NI_NOFQDN) {
+ char *p;
p = strchr(hp->h_name, '.');
if (p)
*p = '\0';
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];
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)
/* 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) {