-/* $OpenBSD: getaddrinfo.c,v 1.18 2000/04/25 13:39:02 itojun Exp $ */
+/* $OpenBSD: getaddrinfo.c,v 1.19 2000/04/26 12:31:44 itojun Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* friends.
*/
+#ifndef INET6
#define INET6
+#endif
#include <sys/types.h>
#include <sys/param.h>
static int get_portmatch __P((const struct addrinfo *, const char *));
static int get_port __P((struct addrinfo *, const char *, int));
static const struct afd *find_afd __P((int));
-#ifdef AI_ADDRCONFIG
+#if 0
static int addrconfig __P((const struct addrinfo *));
#endif
#ifdef INET6
/* external reference: error, and label bad */ \
error = (err); \
goto bad; \
+ /*NOTREACHED*/ \
} while (/*CONSTCOND*/0)
#define MATCH_FAMILY(x, y, w) \
result = NULL;
-#ifdef AI_ADDRCONFIG
+#if 0
/*
* If AI_ADDRCONFIG is specified, check if we are expected to
* return the address family or not.
+ * XXX does not handle PF_UNSPEC case, should filter final result
*/
if ((pai->ai_flags & AI_ADDRCONFIG) != 0 && !addrconfig(pai))
return 0;
struct addrinfo sentinel;
int error;
char pton[PTON_MAX];
- int flags;
*res = NULL;
sentinel.ai_next = NULL;
return 0;
afd = find_afd(pai->ai_family);
- flags = pai->ai_flags;
switch (afd->a_af) {
#if 0 /*X/Open spec*/
for (cur = *res; cur; cur = cur->ai_next) {
if (cur->ai_family != AF_INET6)
continue;
- sin6 = (struct sockaddr_in6 *)cur->ai_addr;
+ sin6 = (struct sockaddr_in6 *)(void *)cur->ai_addr;
if ((scopeid = ip6_str2scopeid(scope, sin6)) == -1) {
free(hostname2);
return(EAI_NONAME); /* XXX: is return OK? */
return NULL;
memcpy(ai, pai, sizeof(struct addrinfo));
- ai->ai_addr = (struct sockaddr *)(ai + 1);
+ ai->ai_addr = (struct sockaddr *)(void *)(ai + 1);
memset(ai->ai_addr, 0, (size_t)afd->a_socklen);
ai->ai_addr->sa_len = afd->a_socklen;
ai->ai_addrlen = afd->a_socklen;
ai->ai_addr->sa_family = ai->ai_family = afd->a_af;
- p = (char *)(ai->ai_addr);
+ p = (char *)(void *)(ai->ai_addr);
memcpy(p + afd->a_off, addr, (size_t)afd->a_addrlen);
return ai;
}
{
/* get_port does not touch first argument. when matchonly == 1. */
+ /* LINTED const cast */
return get_port((struct addrinfo *)ai, servname, 1);
}
if (!matchonly) {
switch (ai->ai_family) {
case AF_INET:
- ((struct sockaddr_in *)ai->ai_addr)->sin_port = port;
+ ((struct sockaddr_in *)(void *)
+ ai->ai_addr)->sin_port = port;
break;
#ifdef INET6
case AF_INET6:
- ((struct sockaddr_in6 *)ai->ai_addr)->sin6_port = port;
+ ((struct sockaddr_in6 *)(void *)
+ ai->ai_addr)->sin6_port = port;
break;
#endif
}
return NULL;
}
-#ifdef AI_ADDRCONFIG
+#if 0
/*
* post-2553: AI_ADDRCONFIG check. if we use getipnodeby* as backend, backend
* will take care of it.
int type, class, buflen, ancount, qdcount;
int haveanswer, had_error;
char tbuf[MAXDNAME];
- const char *tname;
int (*name_ok) __P((const char *));
char hostbuf[8*1024];
memset(&sentinel, 0, sizeof(sentinel));
cur = &sentinel;
- tname = qname;
canonname = NULL;
eom = answer->buf + anslen;
switch (qtype) {
cp += n;
continue;
}
- cur->ai_next = get_ai(&ai, afd, cp);
+ cur->ai_next = get_ai(&ai, afd, (const char *)cp);
if (cur->ai_next == NULL)
had_error++;
while (cur && cur->ai_next)
querybuf buf, buf2;
struct addrinfo sentinel, *cur;
struct res_target q, q2;
- int ancount;
memset(&q, 0, sizeof(q2));
memset(&q2, 0, sizeof(q2));
default:
return NULL;
}
- if ((ancount = res_searchN(name, &q)) < 0)
+ if (res_searchN(name, &q) < 0)
return NULL;
ai = getanswer(&buf, q.n, q.name, q.type, pai);
if (ai) {
const char *addr, *canonname;
char *nextline;
char *cp;
- int more;
addr = canonname = NULL;
-nextline:
- more = 0;
+ memset(&sentinel, 0, sizeof(sentinel));
+ cur = &sentinel;
+nextline:
/* terminate line */
cp = strchr(p, '\n');
if (cp) {