summaryrefslogtreecommitdiff
path: root/usr.sbin/pppd
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>1997-01-02 10:50:21 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>1997-01-02 10:50:21 +0000
commit3c1d9e5d8209b0c8b16d0e1bb5ee52255bdfe9db (patch)
tree0a7df3beb97c8ee5feaecc66f9ff5686390db7f3 /usr.sbin/pppd
parent0555228bc967253747ca2cf16ec3a10143710171 (diff)
inet_addr --> inet_aton
Diffstat (limited to 'usr.sbin/pppd')
-rw-r--r--usr.sbin/pppd/auth.c21
-rw-r--r--usr.sbin/pppd/options.c36
2 files changed, 32 insertions, 25 deletions
diff --git a/usr.sbin/pppd/auth.c b/usr.sbin/pppd/auth.c
index 466828eb213..cb43d74ef9d 100644
--- a/usr.sbin/pppd/auth.c
+++ b/usr.sbin/pppd/auth.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: auth.c,v 1.6 1996/12/23 13:22:37 mickey Exp $ */
+/* $OpenBSD: auth.c,v 1.7 1997/01/02 10:50:18 mickey Exp $ */
/*
* auth.c - PPP authentication and phase control.
@@ -35,7 +35,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: auth.c,v 1.6 1996/12/23 13:22:37 mickey Exp $";
+static char rcsid[] = "$OpenBSD: auth.c,v 1.7 1997/01/02 10:50:18 mickey Exp $";
#endif
#include <stdio.h>
@@ -1082,8 +1082,9 @@ ip_addr_check(addr, addrs)
u_int32_t addr;
struct wordlist *addrs;
{
- u_int32_t a, mask, ah;
- int accept;
+ u_int32_t mask, ah;
+ struct in_addr ina;
+ int accept, r = 1;
char *ptr_word, *ptr_mask;
struct hostent *hp;
struct netent *np;
@@ -1125,17 +1126,17 @@ ip_addr_check(addr, addrs)
hp = gethostbyname(ptr_word);
if (hp != NULL && hp->h_addrtype == AF_INET) {
- a = *(u_int32_t *)hp->h_addr;
+ ina.s_addr = *(u_int32_t *)hp->h_addr;
mask = ~ (u_int32_t) 0; /* are we sure we want this? */
} else {
np = getnetbyname (ptr_word);
if (np != NULL && np->n_addrtype == AF_INET)
- a = htonl (*(u_int32_t *)np->n_net);
+ ina.s_addr = htonl (*(u_int32_t *)np->n_net);
else
- a = inet_addr (ptr_word);
+ r = inet_aton (ptr_word, &ina);
if (ptr_mask == NULL) {
/* calculate appropriate mask for net */
- ah = ntohl(a);
+ ah = ntohl(ina.s_addr);
if (IN_CLASSA(ah))
mask = IN_CLASSA_NET;
else if (IN_CLASSB(ah))
@@ -1148,12 +1149,12 @@ ip_addr_check(addr, addrs)
if (ptr_mask != NULL)
*ptr_mask = '/';
- if (a == -1L)
+ if (r == 0)
syslog (LOG_WARNING,
"unknown host %s in auth. address list",
addrs->word);
else
- if (((addr ^ a) & htonl(mask)) == 0)
+ if (((addr ^ ina.s_addr) & htonl(mask)) == 0)
return accept;
}
return 0; /* not in list => can't have it */
diff --git a/usr.sbin/pppd/options.c b/usr.sbin/pppd/options.c
index 4f5347908b5..44e509fa056 100644
--- a/usr.sbin/pppd/options.c
+++ b/usr.sbin/pppd/options.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: options.c,v 1.6 1996/12/23 13:22:45 mickey Exp $ */
+/* $OpenBSD: options.c,v 1.7 1997/01/02 10:50:20 mickey Exp $ */
/*
* options.c - handles option processing for PPP.
@@ -20,7 +20,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: options.c,v 1.6 1996/12/23 13:22:45 mickey Exp $";
+static char rcsid[] = "$OpenBSD: options.c,v 1.7 1997/01/02 10:50:20 mickey Exp $";
#endif
#include <ctype.h>
@@ -1564,6 +1564,7 @@ setipaddr(arg)
{
struct hostent *hp;
char *colon;
+ struct in_addr ina;
u_int32_t local, remote;
ipcp_options *wo = &ipcp_wantoptions[0];
@@ -1578,14 +1579,19 @@ setipaddr(arg)
*/
if (colon != arg) {
*colon = '\0';
- if ((local = inet_addr(arg)) == -1) {
+ if (inet_aton(arg, &ina) == 0) {
if ((hp = gethostbyname(arg)) == NULL) {
option_error("unknown host: %s", arg);
return -1;
} else {
local = *(u_int32_t *)hp->h_addr;
+ if (our_name[0] == 0) {
+ strncpy(our_name, arg, MAXNAMELEN);
+ our_name[MAXNAMELEN-1] = 0;
}
}
+ } else
+ local = ina.s_addr;
if (bad_ip_adrs(local)) {
option_error("bad local IP address %s", ip_ntoa(local));
return -1;
@@ -1599,7 +1605,7 @@ setipaddr(arg)
* If colon last character, then no remote addr.
*/
if (*++colon != '\0') {
- if ((remote = inet_addr(colon)) == -1) {
+ if (inet_aton(colon, &ina) == 0) {
if ((hp = gethostbyname(colon)) == NULL) {
option_error("unknown host: %s", colon);
return -1;
@@ -1610,7 +1616,8 @@ setipaddr(arg)
remote_name[MAXNAMELEN-1] = 0;
}
}
- }
+ } else
+ remote = ina.s_addr;
if (bad_ip_adrs(remote)) {
option_error("bad remote IP address %s", ip_ntoa(remote));
return -1;
@@ -1663,14 +1670,14 @@ static int
setnetmask(argv)
char **argv;
{
- u_int32_t mask;
+ struct in_addr ina;
- if ((mask = inet_addr(*argv)) == -1 || (netmask & ~mask) != 0) {
+ if (inet_aton(*argv, &ina) == 0 || (netmask & ~ina.s_addr) != 0) {
option_error("invalid netmask value '%s'", *argv);
return 0;
}
- netmask = mask;
+ netmask = ina.s_addr;
return (1);
}
@@ -2124,23 +2131,22 @@ static int
setdnsaddr(argv)
char **argv;
{
- u_int32_t dns;
+ struct in_addr ina;
struct hostent *hp;
- dns = inet_addr(*argv);
- if (dns == -1) {
+ if (inet_aton(*argv, &ina) == 0) {
if ((hp = gethostbyname(*argv)) == NULL) {
option_error("invalid address parameter '%s' for ms-dns option",
*argv);
- return 0;
+ return 0;
}
- dns = *(u_int32_t *)hp->h_addr;
+ ina.s_addr = *(u_int32_t *)hp->h_addr;
}
if (ipcp_allowoptions[0].dnsaddr[0] == 0) {
- ipcp_allowoptions[0].dnsaddr[0] = dns;
+ ipcp_allowoptions[0].dnsaddr[0] = ina.s_addr;
} else {
- ipcp_allowoptions[0].dnsaddr[1] = dns;
+ ipcp_allowoptions[0].dnsaddr[1] = ina.s_addr;
}
return (1);