summaryrefslogtreecommitdiff
path: root/pppd
diff options
context:
space:
mode:
authorDavid F. Skoll <dfs@roaringpenguin.com>2002-02-12 20:07:10 +0000
committerDavid F. Skoll <dfs@roaringpenguin.com>2002-02-12 20:07:10 +0000
commitc30d204fe82b18fb9668a05afb587a37f981696c (patch)
tree3f4771e4bd2d4c4491d592e81c918b65b08157e1 /pppd
parent5580a43ba47c96ff41046226a9409c31b5efc8d2 (diff)
downloadppp-c30d204fe82b18fb9668a05afb587a37f981696c.tar.gz
Added new hooks:
snoop_send_hook and snoop_recv_hook allow plugins to watch the flow of frames (typically we're interested in LCP frames). This is useful for implementing L2TP, because the L2TP access concentrator would like to collect some information from LCP and perhaps authentication protocols and forward the information to the LNS.
Diffstat (limited to 'pppd')
-rw-r--r--pppd/main.c5
-rw-r--r--pppd/pppd.h6
-rw-r--r--pppd/sys-linux.c5
-rw-r--r--pppd/sys-solaris.c3
-rw-r--r--pppd/sys-sunos4.c3
-rw-r--r--pppd/sys-svr4.c3
6 files changed, 19 insertions, 6 deletions
diff --git a/pppd/main.c b/pppd/main.c
index 124f640..16231db 100644
--- a/pppd/main.c
+++ b/pppd/main.c
@@ -17,7 +17,7 @@
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define RCSID "$Id: main.c,v 1.111 2002/01/22 16:02:58 dfs Exp $"
+#define RCSID "$Id: main.c,v 1.112 2002/02/12 20:07:09 dfs Exp $"
#include <stdio.h>
#include <ctype.h>
@@ -108,6 +108,8 @@ char db_key[32];
int (*holdoff_hook) __P((void)) = NULL;
int (*new_phase_hook) __P((int)) = NULL;
+void (*snoop_recv_hook) __P((unsigned char *p, int len)) = NULL;
+void (*snoop_send_hook) __P((unsigned char *p, int len)) = NULL;
static int conn_running; /* we have a [dis]connector running */
static int devfd; /* fd of underlying device */
@@ -968,6 +970,7 @@ get_input()
}
dump_packet("rcvd", p, len);
+ if (snoop_recv_hook) snoop_recv_hook(p, len);
p += 2; /* Skip address and control */
GETSHORT(protocol, p);
diff --git a/pppd/pppd.h b/pppd/pppd.h
index 9e9f87b..5d287d6 100644
--- a/pppd/pppd.h
+++ b/pppd/pppd.h
@@ -16,7 +16,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: pppd.h,v 1.64 2002/01/22 16:02:58 dfs Exp $
+ * $Id: pppd.h,v 1.65 2002/02/12 20:07:09 dfs Exp $
*/
/*
@@ -628,6 +628,10 @@ extern void (*ip_choose_hook) __P((u_int32_t *));
extern int (*chap_check_hook) __P((void));
extern int (*chap_passwd_hook) __P((char *user, char *passwd));
+/* Let a plugin snoop sent and received packets. Useful for L2TP */
+extern void (*snoop_recv_hook) __P((unsigned char *p, int len));
+extern void (*snoop_send_hook) __P((unsigned char *p, int len));
+
/*
* Inline versions of get/put char/short/long.
* Pointer is advanced; we assume that both arguments
diff --git a/pppd/sys-linux.c b/pppd/sys-linux.c
index f391dac..76fda67 100644
--- a/pppd/sys-linux.c
+++ b/pppd/sys-linux.c
@@ -127,7 +127,7 @@ static int master_fd = -1;
#ifdef INET6
static int sock6_fd = -1;
#endif /* INET6 */
-static int ppp_dev_fd = -1; /* fd for /dev/ppp (new style driver) */
+int ppp_dev_fd = -1; /* fd for /dev/ppp (new style driver) */
static int chindex; /* channel index (new style driver) */
static fd_set in_fds; /* set of fds that wait_input waits for */
@@ -946,6 +946,7 @@ void output (int unit, unsigned char *p, int len)
int proto;
dump_packet("sent", p, len);
+ if (snoop_send_hook) snoop_send_hook(p, len);
if (len < PPP_HDRLEN)
return;
@@ -1512,6 +1513,8 @@ int sifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway)
SET_SA_FAMILY (rt.rt_dst, AF_INET);
SET_SA_FAMILY (rt.rt_gateway, AF_INET);
+ rt.rt_dev = ifname;
+
if (kernel_version > KVERSION(2,1,0)) {
SET_SA_FAMILY (rt.rt_genmask, AF_INET);
SIN_ADDR(rt.rt_genmask) = 0L;
diff --git a/pppd/sys-solaris.c b/pppd/sys-solaris.c
index fed68f5..dc2fe2b 100644
--- a/pppd/sys-solaris.c
+++ b/pppd/sys-solaris.c
@@ -42,7 +42,7 @@
* OR MODIFICATIONS.
*/
-#define RCSID "$Id: sys-solaris.c,v 1.6 2001/05/23 03:39:13 paulus Exp $"
+#define RCSID "$Id: sys-solaris.c,v 1.7 2002/02/12 20:07:09 dfs Exp $"
#include <limits.h>
#include <stdio.h>
@@ -1293,6 +1293,7 @@ output(unit, p, len)
struct pollfd pfd;
dump_packet("sent", p, len);
+ if (snoop_send_hook) snoop_send_hook(p, len);
data.len = len;
data.buf = (caddr_t) p;
diff --git a/pppd/sys-sunos4.c b/pppd/sys-sunos4.c
index 75e2120..89eebf9 100644
--- a/pppd/sys-sunos4.c
+++ b/pppd/sys-sunos4.c
@@ -25,7 +25,7 @@
* OR MODIFICATIONS.
*/
-#define RCSID "$Id: sys-sunos4.c,v 1.28 2001/05/23 03:39:13 paulus Exp $"
+#define RCSID "$Id: sys-sunos4.c,v 1.29 2002/02/12 20:07:09 dfs Exp $"
#include <stdio.h>
#include <stddef.h>
@@ -575,6 +575,7 @@ output(unit, p, len)
struct pollfd pfd;
dump_packet("sent", p, len);
+ if (snoop_send_hook) snoop_send_hook(p, len);
data.len = len;
data.buf = (caddr_t) p;
diff --git a/pppd/sys-svr4.c b/pppd/sys-svr4.c
index c9969bd..b731e8f 100644
--- a/pppd/sys-svr4.c
+++ b/pppd/sys-svr4.c
@@ -42,7 +42,7 @@
* OR MODIFICATIONS.
*/
-#define RCSID "$Id: sys-svr4.c,v 1.43 2001/05/23 03:39:14 paulus Exp $"
+#define RCSID "$Id: sys-svr4.c,v 1.44 2002/02/12 20:07:10 dfs Exp $"
#include <limits.h>
#include <stdio.h>
@@ -1298,6 +1298,7 @@ output(unit, p, len)
struct pollfd pfd;
dump_packet("sent", p, len);
+ if (snoop_send_hook) snoop_send_hook(p, len);
data.len = len;
data.buf = (caddr_t) p;