From: Markus Becker Date: Wed, 14 Mar 2012 15:48:44 +0000 (+0100) Subject: pppd: Notify IPv6 up/down as we do for IPv4 X-Git-Tag: ppp-2.4.7~40 X-Git-Url: http://git.ozlabs.org/?p=ppp.git;a=commitdiff_plain;h=845cda8fa18939cf56e60b073f63a7efa65336fc pppd: Notify IPv6 up/down as we do for IPv4 This adds support for notification of IPv6 up/down, mainly for the sake of NetworkManager. Signed-off-by: Paul Mackerras --- diff --git a/pppd/ipv6cp.c b/pppd/ipv6cp.c index 4a09c9a..4421d99 100644 --- a/pppd/ipv6cp.c +++ b/pppd/ipv6cp.c @@ -179,6 +179,16 @@ int no_ifaceid_neg = 0; /* local vars */ static int ipv6cp_is_up; +/* Hook for a plugin to know when IPv6 protocol has come up */ +void (*ipv6_up_hook) __P((void)) = NULL; + +/* Hook for a plugin to know when IPv6 protocol has come down */ +void (*ipv6_down_hook) __P((void)) = NULL; + +/* Notifiers for when IPCPv6 goes up and down */ +struct notifier *ipv6_up_notifier = NULL; +struct notifier *ipv6_down_notifier = NULL; + /* * Callbacks for fsm code. (CI = Configuration Information) */ @@ -1282,6 +1292,10 @@ ipv6cp_up(f) np_up(f->unit, PPP_IPV6); ipv6cp_is_up = 1; + notify(ipv6_up_notifier, 0); + if (ipv6_up_hook) + ipv6_up_hook(); + /* * Execute the ipv6-up script, like this: * /etc/ppp/ipv6-up interface tty speed local-LL remote-LL @@ -1305,6 +1319,9 @@ ipv6cp_down(f) { IPV6CPDEBUG(("ipv6cp: down")); update_link_stats(f->unit); + notify(ipv6_down_notifier, 0); + if (ipv6_down_hook) + ipv6_down_hook(); if (ipv6cp_is_up) { ipv6cp_is_up = 0; np_down(f->unit, PPP_IPV6); diff --git a/pppd/pppd.h b/pppd/pppd.h index 936cc60..2cd7914 100644 --- a/pppd/pppd.h +++ b/pppd/pppd.h @@ -258,8 +258,10 @@ extern struct notifier *pidchange; /* for notifications of pid changing */ extern struct notifier *phasechange; /* for notifications of phase changes */ extern struct notifier *exitnotify; /* for notification that we're exiting */ extern struct notifier *sigreceived; /* notification of received signal */ -extern struct notifier *ip_up_notifier; /* IPCP has come up */ -extern struct notifier *ip_down_notifier; /* IPCP has gone down */ +extern struct notifier *ip_up_notifier; /* IPCP has come up */ +extern struct notifier *ip_down_notifier; /* IPCP has gone down */ +extern struct notifier *ipv6_up_notifier; /* IPV6CP has come up */ +extern struct notifier *ipv6_down_notifier; /* IPV6CP has gone down */ extern struct notifier *auth_up_notifier; /* peer has authenticated */ extern struct notifier *link_down_notifier; /* link has gone down */ extern struct notifier *fork_notifier; /* we are a new child process */ @@ -727,6 +729,8 @@ extern int (*allowed_address_hook) __P((u_int32_t addr)); extern void (*ip_up_hook) __P((void)); extern void (*ip_down_hook) __P((void)); extern void (*ip_choose_hook) __P((u_int32_t *)); +extern void (*ipv6_up_hook) __P((void)); +extern void (*ipv6_down_hook) __P((void)); extern int (*chap_check_hook) __P((void)); extern int (*chap_passwd_hook) __P((char *user, char *passwd));