Reviewed by: julian
Submitted by: archie@whistle.com This patch allows true interface routing to be controlled from the command line.. you can now do: route add default -interface ppp0 even if you have no clue what the address at the other end is.. this is part of a set of changes that allow true "unnumbered links" such as netcom run between their sites.. In practice you should assign the address from one of your ethernet interfaces to the local side of the P2P link so that IP doesn't say that the packet comes from 255.255.255.255, but there is no need whatsoever to assign an address of any kind to the remote end of the link.. useful for frame relay links etc also.
This commit is contained in:
parent
4d2556d0ad
commit
6ab541b861
@ -3,7 +3,7 @@
|
||||
PROG= route
|
||||
MAN8= route.8
|
||||
SRCS= route.c keywords.h # ccitt_addr.h
|
||||
CFLAGS+=-I.
|
||||
CFLAGS+=-I. -Wall
|
||||
CLEANFILES+=keywords.h
|
||||
BINOWN= root
|
||||
BINMODE=4555
|
||||
|
@ -177,6 +177,8 @@ no intermediary system to act as a gateway, the
|
||||
modifier should be specified;
|
||||
the gateway given is the address of this host on the common network,
|
||||
indicating the interface to be used for transmission.
|
||||
If the interface point to point, the name of the interface
|
||||
itself may be given instead.
|
||||
.Pp
|
||||
The optional modifiers
|
||||
.Fl xns ,
|
||||
|
@ -43,7 +43,7 @@ static const char copyright[] =
|
||||
static char sccsid[] = "@(#)route.c 8.3 (Berkeley) 3/19/94";
|
||||
*/
|
||||
static const char rcsid[] =
|
||||
"$Id: route.c,v 1.10 1996/07/23 01:18:47 julian Exp $";
|
||||
"$Id: route.c,v 1.11 1996/07/23 22:00:14 julian Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -827,6 +827,48 @@ getaddr(which, s, hpp)
|
||||
break;
|
||||
case RTA_GATEWAY:
|
||||
su = &so_gate;
|
||||
if (iflag) {
|
||||
#define MAX_IFACES 400
|
||||
int sock;
|
||||
struct ifreq iflist[MAX_IFACES];
|
||||
struct ifconf ifconf;
|
||||
struct ifreq *ifr, *ifr_end;
|
||||
struct sockaddr_dl *dl, *sdl = NULL;
|
||||
|
||||
/* Get socket */
|
||||
if ((sock = socket(PF_INET, SOCK_DGRAM, 0)) < 0)
|
||||
err(1, "socket");
|
||||
|
||||
/* Get interface list */
|
||||
ifconf.ifc_req = iflist;
|
||||
ifconf.ifc_len = sizeof(iflist);
|
||||
if (ioctl(sock, SIOCGIFCONF, &ifconf) < 0)
|
||||
err(1, "ioctl(SIOCGIFCONF)");
|
||||
close(sock);
|
||||
|
||||
/* Look for this interface in the list */
|
||||
for (ifr = ifconf.ifc_req,
|
||||
ifr_end = (struct ifreq *)
|
||||
(ifconf.ifc_buf + ifconf.ifc_len);
|
||||
ifr < ifr_end;
|
||||
ifr = (struct ifreq *) ((char *) &ifr->ifr_addr
|
||||
+ ifr->ifr_addr.sa_len)) {
|
||||
dl = (struct sockaddr_dl *)&ifr->ifr_addr;
|
||||
if (ifr->ifr_addr.sa_family == AF_LINK
|
||||
&& (ifr->ifr_flags & IFF_POINTOPOINT)
|
||||
&& !strncmp(s, dl->sdl_data, dl->sdl_nlen)
|
||||
&& s[dl->sdl_nlen] == 0) {
|
||||
sdl = dl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* If we found it, then use it */
|
||||
if (sdl) {
|
||||
su->sdl = *sdl;
|
||||
return(1);
|
||||
}
|
||||
}
|
||||
su->sa.sa_family = af;
|
||||
break;
|
||||
case RTA_NETMASK:
|
||||
|
Loading…
Reference in New Issue
Block a user