From b4a24a5e08e9137195135c131973645605e115f9 Mon Sep 17 00:00:00 2001
From: Maxime Bizon <mbizon@freebox.fr>
Date: Thu, 16 Jan 2020 01:05:15 +0100
Subject: [PATCH 11/18] pppd: add mppe state change notifier

---
 pppd/ccp.c  | 8 ++++++++
 pppd/pppd.h | 1 +
 2 files changed, 9 insertions(+)

diff --git a/pppd/ccp.c b/pppd/ccp.c
index 61947d9..b522d31 100644
--- a/pppd/ccp.c
+++ b/pppd/ccp.c
@@ -160,6 +160,8 @@ static option_t ccp_option_list[] = {
     { NULL }
 };
 
+struct notifier *mppe_state_notifier = NULL;
+
 /*
  * Protocol entry points from main code.
  */
@@ -1445,6 +1447,11 @@ ccp_up(f)
 	notice("%s transmit compression enabled", method_name(ho, NULL));
 #ifdef MPPE
     if (go->mppe) {
+	int arg = (1 << 0);
+
+	if ((go->mppe & MPPE_OPT_128))
+		arg |= (1 << 1);
+	notify(mppe_state_notifier, arg);
 	BZERO(mppe_recv_key, MPPE_MAX_KEY_LEN);
 	BZERO(mppe_send_key, MPPE_MAX_KEY_LEN);
 	continue_networks(f->unit);		/* Bring up IP et al */
@@ -1468,6 +1475,7 @@ ccp_down(f)
 	ccp_gotoptions[f->unit].mppe = 0;
 	if (lcp_fsm[f->unit].state == OPENED) {
 	    /* If LCP is not already going down, make sure it does. */
+	    notify(mppe_state_notifier, 0);
 	    error("MPPE disabled");
 	    lcp_close(f->unit, "MPPE disabled");
 	}
diff --git a/pppd/pppd.h b/pppd/pppd.h
index 6baa724..e15032c 100644
--- a/pppd/pppd.h
+++ b/pppd/pppd.h
@@ -279,6 +279,7 @@ extern struct notifier *auth_with_peer_notifier; /* we have authenticated  */
 extern struct notifier *link_down_notifier; /* link has gone down */
 extern struct notifier *fork_notifier;	/* we are a new child process */
 extern struct notifier *first_lcp_notifier; /* first LCP packet received */
+extern struct notifier *mppe_state_notifier; /* mppe state changed */
 
 /* Values for do_callback and doing_callback */
 #define CALLBACK_DIALIN		1	/* we are expecting the call back */
-- 
2.17.1

