Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/pppd/pppd PR/20066: John F. Woods: Add plugin lcp h...



details:   https://anonhg.NetBSD.org/src/rev/c7bc6b5bf352
branches:  trunk
changeset: 566600:c7bc6b5bf352
user:      christos <christos%NetBSD.org@localhost>
date:      Thu May 13 17:31:57 2004 +0000

description:
PR/20066: John F. Woods: Add plugin lcp hooks.

diffstat:

 usr.sbin/pppd/pppd/lcp.c  |  23 +++++++++++++++++++++--
 usr.sbin/pppd/pppd/pppd.h |   6 +++++-
 2 files changed, 26 insertions(+), 3 deletions(-)

diffs (94 lines):

diff -r f16c7697f577 -r c7bc6b5bf352 usr.sbin/pppd/pppd/lcp.c
--- a/usr.sbin/pppd/pppd/lcp.c  Thu May 13 17:02:32 2004 +0000
+++ b/usr.sbin/pppd/pppd/lcp.c  Thu May 13 17:31:57 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lcp.c,v 1.25 2003/04/01 15:12:12 christos Exp $        */
+/*     $NetBSD: lcp.c,v 1.26 2004/05/13 17:31:57 christos Exp $        */
 
 /*
  * lcp.c - PPP Link Control Protocol.
@@ -47,7 +47,7 @@
 #if 0
 #define RCSID  "Id: lcp.c,v 1.57 2001/03/08 05:11:14 paulus Exp "
 #else
-__RCSID("$NetBSD: lcp.c,v 1.25 2003/04/01 15:12:12 christos Exp $");
+__RCSID("$NetBSD: lcp.c,v 1.26 2004/05/13 17:31:57 christos Exp $");
 #endif
 #endif
 
@@ -204,6 +204,18 @@
 lcp_options lcp_allowoptions[NUM_PPP]; /* Options we allow peer to request */
 lcp_options lcp_hisoptions[NUM_PPP];   /* Options that we ack'd */
 
+/* Hook for LCP up */
+void (*lcp_up_hook) __P((void)) = NULL;
+
+/* Hook for LCP down */
+void (*lcp_down_hook) __P((void)) = NULL;
+
+/* Hook for sending an LCP echo request, argument is pending count */
+void (*lcp_echo_hook) __P((int)) = NULL;
+
+/* Hook for receiving an LCP echo reply, argument is whether it's ours */
+void (*lcp_echoreply_hook) __P((int)) = NULL;
+
 static int lcp_echos_pending = 0;      /* Number of outstanding echo msgs */
 static int lcp_echo_number   = 0;      /* ID number of next echo frame */
 static int lcp_echo_timer_running = 0;  /* set if a timer is running */
@@ -1836,6 +1848,8 @@
     if (ho->neg_mru)
        peer_mru[f->unit] = ho->mru;
 
+    if (lcp_up_hook) (*lcp_up_hook)();
+
     lcp_echo_lowerup(f->unit);  /* Enable echo messages */
 
     link_established(f->unit);
@@ -1857,6 +1871,8 @@
 
     link_down(f->unit);
 
+    if (lcp_down_hook) (*lcp_down_hook)();
+
     ppp_send_config(f->unit, PPP_MRU, 0xffffffff, 0, 0);
     ppp_recv_config(f->unit, PPP_MRU,
                    (go->neg_asyncmap? go->asyncmap: 0xffffffff),
@@ -2181,8 +2197,10 @@
     if (lcp_gotoptions[f->unit].neg_magicnumber
        && magic == lcp_gotoptions[f->unit].magicnumber) {
        warn("appear to have received our own echo-reply!");
+       if (lcp_echoreply_hook) (*lcp_echoreply_hook)(1);
        return;
     }
+    if (lcp_echoreply_hook) (*lcp_echoreply_hook)(0);
 
     /* Reset the number of outstanding echo frames */
     lcp_echos_pending = 0;
@@ -2215,6 +2233,7 @@
     /*
      * Make and send the echo request frame.
      */
+    if (lcp_echo_hook) (*lcp_echo_hook)(lcp_echos_pending);
     lcp_magic = lcp_gotoptions[f->unit].magicnumber;
     pktp = pkt;
     PUTLONG(lcp_magic, pktp);
diff -r f16c7697f577 -r c7bc6b5bf352 usr.sbin/pppd/pppd/pppd.h
--- a/usr.sbin/pppd/pppd/pppd.h Thu May 13 17:02:32 2004 +0000
+++ b/usr.sbin/pppd/pppd/pppd.h Thu May 13 17:31:57 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pppd.h,v 1.25 2003/07/13 14:02:23 itojun Exp $ */
+/*     $NetBSD: pppd.h,v 1.26 2004/05/13 17:31:57 christos Exp $       */
 
 /*
  * pppd.h - PPP daemon global declarations.
@@ -636,6 +636,10 @@
 extern void (*ip_up_hook) __P((void));
 extern void (*ip_down_hook) __P((void));
 extern void (*ip_choose_hook) __P((u_int32_t *));
+void (*lcp_up_hook) __P((void));
+void (*lcp_down_hook) __P((void));
+void (*lcp_echo_hook) __P((int));
+void (*lcp_echoreply_hook) __P((int));
 
 /*
  * Inline versions of get/put char/short/long.



Home | Main Index | Thread Index | Old Index