]> git.ozlabs.org Git - ppp.git/commitdiff
Added new hooks:
authorDavid F. Skoll <dfs@roaringpenguin.com>
Tue, 12 Feb 2002 20:07:10 +0000 (20:07 +0000)
committerDavid F. Skoll <dfs@roaringpenguin.com>
Tue, 12 Feb 2002 20:07:10 +0000 (20:07 +0000)
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.

PLUGINS
pppd/main.c
pppd/pppd.h
pppd/sys-linux.c
pppd/sys-solaris.c
pppd/sys-sunos4.c
pppd/sys-svr4.c

diff --git a/PLUGINS b/PLUGINS
index 206f8fc4e7e66a4c9ed12ef6538bac9c20053561..e3e6718cb0669ee9e92c1f37c001d3007456cb24 100644 (file)
--- a/PLUGINS
+++ b/PLUGINS
@@ -211,6 +211,13 @@ address.  If the hook returns 1, the address is accepted.  If it returns
 in the normal away against the appropriate options and secrets files.
 
 
+void (*snoop_recv_hook)(unsigned char *p, int len)
+void (*snoop_send_hook)(unsigned char *p, int len)
+
+These hooks are called whenever pppd receives or sends a packet.  The
+packet is in p; its length is len.  This allows plugins to "snoop in"
+on the pppd conversation.  The hooks may prove useful in implmenting
+L2TP.
 
 A plugin registers itself with a notifier by declaring a procedure of
 the form:
@@ -258,4 +265,4 @@ Here is a list of the currently-implemented notifiers in pppd.
 
 
 
-## $Id: PLUGINS,v 1.4 2002/01/22 16:02:55 dfs Exp $ ##
+## $Id: PLUGINS,v 1.5 2002/02/12 20:07:09 dfs Exp $ ##
index 124f6404e6dcac22d312e4a0001c52c73677573a..16231db75ead75a846022061d3a9a4d4c2395306 100644 (file)
@@ -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);
index 9e9f87b340fbbb0153355a44162d084723026c5f..5d287d6b4649d4a1cd46c40a0bddb65d217c0d2a 100644 (file)
@@ -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
index f391dac082ad1993042c853ec604514e497baf4c..76fda67b3f9e94f5f59145b0e4d6eaff966a6c28 100644 (file)
@@ -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;
index fed68f50f8213b167583fe7ff8e013df2093361a..dc2fe2bc20aab2c6ea72ea63a0194b941afbf7c7 100644 (file)
@@ -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;
index 75e2120fc39ae1a3ae9c8ea0ee8891ae22141fae..89eebf9071f045743b638559e02be9c18baa652f 100644 (file)
@@ -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;
index c9969bde5ae32a0c443eddbfbdefea55df75e15c..b731e8f627e8ab6352b1d437658a494a93ba0d7c 100644 (file)
@@ -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;