3e86158156
The PPP Daemon is the userland part of the Point-to-Point Protocol. It works in combination with a dedicated kernel network interface usually named ppp. PPP is a very extensible protocol and pppd supports a large number of options, including compression (through various algorithms), cryptography (Microsoft's MPPE) and authentication (PAP, CHAP, Microsoft CHAP), provided the kernel has the relevant back-ends in some cases.
82 lines
2.6 KiB
Text
82 lines
2.6 KiB
Text
$NetBSD: patch-ar,v 1.1.1.1 2005/01/02 02:51:42 cube Exp $
|
|
|
|
--- pppd/lcp.c.orig 2004-11-13 03:28:15.000000000 +0100
|
|
+++ pppd/lcp.c
|
|
@@ -193,6 +193,18 @@ lcp_options lcp_gotoptions[NUM_PPP]; /*
|
|
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 */
|
|
@@ -1907,6 +1919,8 @@ lcp_up(f)
|
|
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);
|
|
@@ -1928,6 +1942,8 @@ lcp_down(f)
|
|
|
|
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),
|
|
@@ -2260,8 +2276,10 @@ lcp_received_echo_reply (f, id, inp, len
|
|
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;
|
|
@@ -2278,6 +2296,9 @@ LcpSendEchoRequest (f)
|
|
u_int32_t lcp_magic;
|
|
u_char pkt[4], *pktp;
|
|
|
|
+ if (f->state != OPENED)
|
|
+ return;
|
|
+
|
|
/*
|
|
* Detect the failure of the peer at this point.
|
|
*/
|
|
@@ -2291,13 +2312,12 @@ LcpSendEchoRequest (f)
|
|
/*
|
|
* Make and send the echo request frame.
|
|
*/
|
|
- if (f->state == OPENED) {
|
|
- lcp_magic = lcp_gotoptions[f->unit].magicnumber;
|
|
- pktp = pkt;
|
|
- PUTLONG(lcp_magic, pktp);
|
|
- fsm_sdata(f, ECHOREQ, lcp_echo_number++ & 0xFF, pkt, pktp - pkt);
|
|
- ++lcp_echos_pending;
|
|
- }
|
|
+ if (lcp_echo_hook) (*lcp_echo_hook)(lcp_echos_pending);
|
|
+ lcp_magic = lcp_gotoptions[f->unit].magicnumber;
|
|
+ pktp = pkt;
|
|
+ PUTLONG(lcp_magic, pktp);
|
|
+ fsm_sdata(f, ECHOREQ, lcp_echo_number++ & 0xFF, pkt, pktp - pkt);
|
|
+ ++lcp_echos_pending;
|
|
}
|
|
|
|
/*
|