-/* $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.
*/
#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>
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;
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))
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 */
-/* $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.
*/
#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>
{
struct hostent *hp;
char *colon;
+ struct in_addr ina;
u_int32_t local, remote;
ipcp_options *wo = &ipcp_wantoptions[0];
*/
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;
* 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;
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;
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);
}
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);