summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1999-06-06 20:34:57 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1999-06-06 20:34:57 +0000
commitd81b45ee94910922de18c1de9ec100a0d4a24c36 (patch)
tree80840deaf1c319e8732e6e7d6e04f248f6e77f9a /sbin
parent7af5a9e3fb335e3f63aa1231e6aec5312266fd91 (diff)
use inet_aton() instead of inet_addr()
Diffstat (limited to 'sbin')
-rw-r--r--sbin/ipf/parse.c9
-rw-r--r--sbin/ipnat/ipnat.c30
2 files changed, 21 insertions, 18 deletions
diff --git a/sbin/ipf/parse.c b/sbin/ipf/parse.c
index d819996d5f6..2b39a865c0e 100644
--- a/sbin/ipf/parse.c
+++ b/sbin/ipf/parse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.c,v 1.23 1999/02/05 05:58:42 deraadt Exp $ */
+/* $OpenBSD: parse.c,v 1.24 1999/06/06 20:34:55 deraadt Exp $ */
/*
* Copyright (C) 1993-1998 by Darren Reed.
*
@@ -40,7 +40,7 @@
#if !defined(lint)
static const char sccsid[] ="@(#)parse.c 1.44 6/5/96 (C) 1993-1996 Darren Reed";
-static const char rcsid[] = "@(#)$Id: parse.c,v 1.23 1999/02/05 05:58:42 deraadt Exp $";
+static const char rcsid[] = "@(#)$Id: parse.c,v 1.24 1999/06/06 20:34:55 deraadt Exp $";
#endif
extern struct ipopt_names ionames[], secclass[];
@@ -620,12 +620,13 @@ int *resolved;
{
struct hostent *hp;
struct netent *np;
+ struct in_addr addr;
*resolved = 0;
if (!strcasecmp("any",host))
return 0L;
- if (isdigit(*host))
- return inet_addr(host);
+ if (inet_aton(host, &addr))
+ return addr.s_addr;
if (!strcasecmp("<thishost>", host))
host = thishost;
diff --git a/sbin/ipnat/ipnat.c b/sbin/ipnat/ipnat.c
index ac8ee00fd16..8a1f3af4ee2 100644
--- a/sbin/ipnat/ipnat.c
+++ b/sbin/ipnat/ipnat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ipnat.c,v 1.27 1999/06/03 17:53:11 deraadt Exp $ */
+/* $OpenBSD: ipnat.c,v 1.28 1999/06/06 20:34:56 deraadt Exp $ */
/*
* Copyright (C) 1993-1998 by Darren Reed.
*
@@ -67,7 +67,7 @@ extern char *sys_errlist[];
#if !defined(lint)
static const char sccsid[] ="@(#)ipnat.c 1.9 6/5/96 (C) 1993 Darren Reed";
-static const char rcsid[] = "@(#)$Id: ipnat.c,v 1.27 1999/06/03 17:53:11 deraadt Exp $";
+static const char rcsid[] = "@(#)$Id: ipnat.c,v 1.28 1999/06/06 20:34:56 deraadt Exp $";
#endif
@@ -515,16 +515,17 @@ char *msk;
#if defined(__OpenBSD__)
/*
- * get_if_addr():
+ * if_addr():
* given a string containing an interface name (e.g. "ppp0")
- * return the IP address it represents as an unsigned int
+ * return the IP address it represents
*
* The OpenBSD community considers this feature to be quite useful and
* suggests inclusion into other platforms. The closest alternative is
* to define /etc/networks with suitable values.
*/
-u_32_t if_addr(name)
-char *name;
+int if_addr(name, ap)
+char *name;
+struct in_addr *ap;
{
struct ifconf ifc;
struct ifreq ifreq, *ifr;
@@ -533,7 +534,7 @@ char *name;
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
warn("socket");
- return INADDR_NONE;
+ return 0;
}
while (1) {
@@ -567,14 +568,15 @@ char *name;
close(s);
free(inbuf);
sin = (struct sockaddr_in *)&ifr->ifr_addr;
- return (sin->sin_addr.s_addr);
+ *ap = sin->sin_addr;
+ return (1);
}
}
if_addr_lose:
close(s);
free(inbuf);
- return INADDR_NONE;
+ return 0;
}
#endif
@@ -590,19 +592,19 @@ int *resolved;
struct hostent *hp;
struct netent *np;
#if defined(__OpenBSD__)
- u_32_t addr;
+ struct in_addr addr;
#endif
*resolved = 0;
if (!strcasecmp("any", host))
return 0L;
- if (isdigit(*host))
- return inet_addr(host);
+ if (inet_aton(host, &addr))
+ return (u_32_t)addr.s_addr;
#if defined(__OpenBSD__)
/* attempt a map from interface name to address */
- if ((addr = if_addr(host)) != INADDR_NONE)
- return addr;
+ if (if_addr(host, &addr))
+ return (u_32_t)addr.s_addr;
#endif
if (!(hp = gethostbyname(host))) {
if (!(np = getnetbyname(host))) {