Fixed bug in ipppd: MPdiscr is now random
added option deldefaultroute
This commit is contained in:
parent
39ee6c034b
commit
96661ced82
|
@ -16,7 +16,7 @@
|
|||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: ipppd.h,v 1.18 1999/11/10 08:01:32 werner Exp $
|
||||
* $Id: ipppd.h,v 1.19 2000/04/29 08:57:23 kai Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -179,6 +179,7 @@ extern char sys_rcsid[];
|
|||
|
||||
extern int maxconnect;
|
||||
extern int usefirstip,useifip,useifmtu;
|
||||
extern int deldefaultroute;/* delete default gw, if it exists */
|
||||
extern int numdev; /* number of handled devices */
|
||||
extern int debug; /* Debug flag */
|
||||
extern int kdebugflag; /* Tell kernel to print debug messages */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
.\" manual page [] for ipppd 2.0
|
||||
.\" $Id: ipppd.man.in,v 1.8 2000/04/13 13:34:04 kai Exp $
|
||||
.\" CHECKIN $Date: 2000/04/13 13:34:04 $
|
||||
.\" $Id: ipppd.man.in,v 1.9 2000/04/29 08:57:23 kai Exp $
|
||||
.\" CHECKIN $Date: 2000/04/29 08:57:23 $
|
||||
.\" SH section heading
|
||||
.\" SS subsection heading
|
||||
.\" LP paragraph
|
||||
|
@ -163,6 +163,11 @@ Disable the \fBdefaultroute\fR option. The system administrator who
|
|||
wishes to prevent users from creating default routes with \fIipppd\fR
|
||||
can do so by placing this option in the /etc/ppp/ioptions file.
|
||||
.TP
|
||||
.B deldefaultroute
|
||||
Replace default route if it already exists. Together with the option
|
||||
\fBdefaultroute\fR, this will replace any existing default route by a new
|
||||
one through this ipppd's interface when it comes up.
|
||||
.TP
|
||||
.B -detach
|
||||
Don't fork to become a background process (otherwise
|
||||
.I ipppd
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
char lcp_rcsid[] = "$Id: lcp.c,v 1.9 1998/09/23 08:10:25 paul Exp $";
|
||||
char lcp_rcsid[] = "$Id: lcp.c,v 1.10 2000/04/29 08:57:23 kai Exp $";
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
|
@ -190,6 +190,7 @@ static void lcp_init(int unit)
|
|||
{
|
||||
*(u_int32_t *) (&our_discr_addr[0]) = magic();
|
||||
*(u_int32_t *) (&our_discr_addr[4]) = magic();
|
||||
|
||||
first_call = 0;
|
||||
}
|
||||
|
||||
|
|
12
ipppd/main.c
12
ipppd/main.c
|
@ -25,7 +25,7 @@
|
|||
* PATCHLEVEL 9
|
||||
*/
|
||||
|
||||
char main_rcsid[] = "$Id: main.c,v 1.16 1999/06/21 13:28:49 hipp Exp $";
|
||||
char main_rcsid[] = "$Id: main.c,v 1.17 2000/04/29 08:57:24 kai Exp $";
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
@ -165,6 +165,11 @@ int main(int argc,char **argv)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize magic number package.
|
||||
*/
|
||||
magic_init();
|
||||
|
||||
for(i=0;i<NUM_PPP;i++) {
|
||||
lns[i].openfails = 0;
|
||||
lns[i].initfdflags = -1;
|
||||
|
@ -246,11 +251,6 @@ int main(int argc,char **argv)
|
|||
syslog(LOG_NOTICE,devstr);
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize magic number package.
|
||||
*/
|
||||
magic_init();
|
||||
|
||||
/*
|
||||
* Detach ourselves from the terminal, if required,
|
||||
* and identify who is running us.
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
char options_rcsid[] = "$Id: options.c,v 1.16 2000/01/10 21:22:56 kai Exp $";
|
||||
char options_rcsid[] = "$Id: options.c,v 1.17 2000/04/29 08:57:24 kai Exp $";
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
@ -114,6 +114,7 @@ int disable_defaultip = 0; /* Don't use hostname for default IP adrs */
|
|||
char *ipparam = NULL; /* Extra parameter for ip up/down scripts */
|
||||
int cryptpap; /* Passwords in pap-secrets are encrypted */
|
||||
int useifip=0; /* try to get IP addresses from interface */
|
||||
int deldefaultroute=0; /* delete default route, if it exists */
|
||||
int usefirstip=0;
|
||||
int useifmtu=0; /* get MTU value from network device */
|
||||
|
||||
|
@ -247,6 +248,7 @@ static int setwinsaddr __P((int,char **));
|
|||
static int setgetwinsaddr __P((int,char **));
|
||||
static int resetipxproto __P((int));
|
||||
static int setuseifip __P((int));
|
||||
static int setdeldefaultroute __P((int));
|
||||
static int setusefirstip __P((int));
|
||||
static int setmp __P((int));
|
||||
static int setpwlog __P((int));
|
||||
|
@ -413,6 +415,7 @@ static struct cmd {
|
|||
{"-ipx", 0, resetipxproto}, /* Disable IPXCP (and IPX) */
|
||||
|
||||
{"useifip",0,setuseifip}, /* call setifip() for IP addrs */
|
||||
{"deldefaultroute",0, setdeldefaultroute}, /* call setdeldefaultroute for defaultroute */
|
||||
{"usefirstip",0,setusefirstip}, /* use first IP from auth file for remote */
|
||||
{"+mp",0,setmp},
|
||||
{"+pwlog",0,setpwlog},
|
||||
|
@ -1316,6 +1319,12 @@ static int setuseifip(int slot)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int setdeldefaultroute(int slot)
|
||||
{
|
||||
deldefaultroute = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int setifmtu(int slot)
|
||||
{
|
||||
useifmtu = 1;
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
char sys_rcsid[] = "$Id: sys-linux.c,v 1.23 1999/10/25 12:17:29 keil Exp $";
|
||||
char sys_rcsid[] = "$Id: sys-linux.c,v 1.24 2000/04/29 08:57:24 kai Exp $";
|
||||
|
||||
#define _LINUX_STRING_H_
|
||||
|
||||
|
@ -35,6 +35,7 @@ char sys_rcsid[] = "$Id: sys-linux.c,v 1.23 1999/10/25 12:17:29 keil Exp $";
|
|||
#include <sys/stat.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <sys/sysmacros.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -92,6 +93,10 @@ static void decode_version (char *buf, int *version,
|
|||
int sockfd; /* socket for doing interface ioctls */
|
||||
|
||||
static char *lock_file;
|
||||
static int kernel_version;
|
||||
|
||||
#define SIN_ADDR(x) (((struct sockaddr_in *) (&(x)))->sin_addr.s_addr)
|
||||
#define KVERSION(j,n,p) ((j)*1000000 + (n)*1000 + (p))
|
||||
|
||||
#define MAX_IFS 4096
|
||||
|
||||
|
@ -857,26 +862,35 @@ static int defaultroute_exists (void)
|
|||
int result = 0;
|
||||
|
||||
if (!open_route_table())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
||||
while (read_route_table(&rt) != 0)
|
||||
{
|
||||
if (kernel_version > KVERSION(2,1,0) && SIN_ADDR(rt.rt_genmask) != 0)
|
||||
continue;
|
||||
|
||||
if ((rt.rt_flags & RTF_UP) == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
|
||||
if (((struct sockaddr_in *) &rt.rt_dst)->sin_addr.s_addr == 0L)
|
||||
{
|
||||
struct in_addr ina;
|
||||
ina.s_addr = ((struct sockaddr_in *) &rt.rt_gateway)->sin_addr.s_addr;
|
||||
syslog (LOG_ERR,
|
||||
"ppp not replacing existing default route to %s[%s]",
|
||||
rt.rt_dev, inet_ntoa (ina) );
|
||||
result = 1;
|
||||
break;
|
||||
if (!deldefaultroute)
|
||||
{
|
||||
syslog (LOG_ERR,
|
||||
"ppp not replacing existing default route to %s[%s]",
|
||||
rt.rt_dev, inet_ntoa (ina) );
|
||||
result = 1;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
SET_SA_FAMILY (rt.rt_dst, AF_INET);
|
||||
SET_SA_FAMILY (rt.rt_gateway, AF_INET);
|
||||
rt.rt_flags = RTF_UP | RTF_GATEWAY;
|
||||
ioctl(sockfd, SIOCDELRT, &rt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue