Deal with HISADDR/MYADDR in filter rules.

Mostly submitted by: kfurge@worldnet.att.net

Allow MYADDR in add/delete commands to facilitate
dynamic additions of a loopback route to MYADDR.
This commit is contained in:
brian 1997-06-28 01:34:03 +00:00
parent 4cd0616eed
commit 512e26e794
2 changed files with 21 additions and 15 deletions

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: command.c,v 1.62 1997/06/25 02:04:35 brian Exp $
* $Id: command.c,v 1.63 1997/06/25 19:29:59 brian Exp $
*
*/
#include <sys/types.h>
@ -258,17 +258,13 @@ char **argv;
TtyOldMode();
if(argc > 0) {
/* substitute pseudo args */
for (i=1; i<argc; i++) {
if (strcasecmp(argv[i], "HISADDR") == 0) {
for (i=1; i<argc; i++)
if (strcasecmp(argv[i], "HISADDR") == 0)
argv[i] = strdup(inet_ntoa(IpcpInfo.his_ipaddr));
}
if (strcasecmp(argv[i], "INTERFACE") == 0) {
else if (strcasecmp(argv[i], "INTERFACE") == 0)
argv[i] = strdup(IfDevName);
}
if (strcasecmp(argv[i], "MYADDR") == 0) {
else if (strcasecmp(argv[i], "MYADDR") == 0)
argv[i] = strdup(inet_ntoa(IpcpInfo.want_ipaddr));
}
}
(void)execvp(argv[0], argv);
}
else
@ -1311,7 +1307,10 @@ char **argv;
struct in_addr dest, gateway, netmask;
if (argc == 3) {
dest = GetIpAddr(argv[0]);
if (strcasecmp(argv[0], "MYADDR") == 0)
dest = IpcpInfo.want_ipaddr;
else
dest = GetIpAddr(argv[0]);
netmask = GetIpAddr(argv[1]);
if (strcasecmp(argv[2], "HISADDR") == 0)
gateway = IpcpInfo.his_ipaddr;
@ -1335,7 +1334,10 @@ char **argv;
if (argc == 1 && strcasecmp(argv[0], "all") == 0)
DeleteIfRoutes(0);
else if (argc > 0 && argc < 4) {
dest = GetIpAddr(argv[0]);
if (strcasecmp(argv[0], "MYADDR") == 0)
dest = IpcpInfo.want_ipaddr;
else
dest = GetIpAddr(argv[0]);
netmask.s_addr = INADDR_ANY;
if (argc > 1) {
if (strcasecmp(argv[1], "HISADDR") == 0)

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: filter.c,v 1.9 1997/05/10 01:22:08 brian Exp $
* $Id: filter.c,v 1.10 1997/06/09 03:27:19 brian Exp $
*
* TODO: Shoud send ICMP error message when we discard packets.
*/
@ -37,6 +37,7 @@
#include "filter.h"
#include "loadalias.h"
#include "vars.h"
#include "ipcp.h"
static struct filterent filterdata;
@ -60,7 +61,6 @@ struct in_addr *paddr;
struct in_addr *pmask;
int *pwidth;
{
u_long addr;
int bits;
char *cp, *wp;
@ -72,8 +72,12 @@ int *pwidth;
pmask->s_addr = 0xffffffff; /* Assume 255.255.255.255 as default */
cp = index(*argv, '/');
if (cp) *cp++ = '\0';
addr = inet_addr(*argv);
paddr->s_addr = addr;
if (strcasecmp(*argv, "HISADDR") == 0)
*paddr = IpcpInfo.his_ipaddr;
else if (strcasecmp(*argv, "MYADDR") == 0)
*paddr = IpcpInfo.want_ipaddr;
else
paddr->s_addr = inet_addr(*argv);
if (cp && *cp) {
bits = strtol(cp, &wp, 0);
if (cp == wp || bits < 0 || bits > 32) {