Interpret the address argument as network-type address for `destination'

argument only.  Before that, the `route add default gateway' first tried
the `gateway' as network address and passed its name to getnetbyname(3),
which in the BIND resolution case does the T_PTR lookup on that name.
This commit is contained in:
Ruslan Ermilov 2000-09-29 10:50:11 +00:00
parent ecfe112d3e
commit 4eed20b85f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=66449

View File

@ -810,7 +810,7 @@ getaddr(which, s, hpp)
struct hostent *hp;
struct netent *np;
u_long val;
char *q,qs;
char *q;
int afamily; /* local copy of af so we can change it */
if (af == 0) {
@ -976,31 +976,30 @@ getaddr(which, s, hpp)
q = strchr(s,'/');
if (q && which == RTA_DST) {
qs = *q;
*q = '\0';
if (((val = inet_addr(s)) != INADDR_NONE)) {
if ((val = inet_addr(s)) != INADDR_NONE) {
inet_makenetandmask(
htonl(val), &su->sin, strtoul(q+1, 0, 0));
ntohl(val), &su->sin, strtoul(q+1, 0, 0));
return (0);
}
*q =qs;
*q = '/';
}
if (((val = inet_addr(s)) != INADDR_NONE) &&
(which != RTA_DST || forcenet == 0)) {
if ((which != RTA_DST || forcenet == 0) &&
(val = inet_addr(s)) != INADDR_NONE) {
su->sin.sin_addr.s_addr = val;
if (inet_lnaof(su->sin.sin_addr) != INADDR_ANY)
if (which != RTA_DST ||
inet_lnaof(su->sin.sin_addr) != INADDR_ANY)
return (1);
else {
val = ntohl(val);
goto netdone;
}
}
if ((val = inet_network(s)) != INADDR_NONE ||
(forcehost == 0 && (np = getnetbyname(s)) != NULL &&
(val = np->n_net) != 0)) {
if (which == RTA_DST && forcehost == 0 &&
((val = inet_network(s)) != INADDR_NONE ||
((np = getnetbyname(s)) != NULL && (val = np->n_net) != 0))) {
netdone:
if (which == RTA_DST)
inet_makenetandmask(val, &su->sin, 0);
inet_makenetandmask(val, &su->sin, 0);
return (0);
}
hp = gethostbyname(s);