static void (*old_snoop_recv_hook)(unsigned char *p, int len) = NULL;
static void (*old_snoop_send_hook)(unsigned char *p, int len) = NULL;
-static void (*old_ip_up_hook)(void) = NULL;
-static void (*old_ip_down_hook)(void) = NULL;
/* Hook provided to allow other plugins to handle ACCM changes */
void (*pppol2tp_send_accm_hook)(int tunnel_id, int session_id,
* Interface up/down events
*****************************************************************************/
-static void pppol2tp_ip_up_hook(void)
+static void pppol2tp_ip_up(void *opaque, int arg)
{
- if (old_ip_up_hook != NULL)
- (*old_ip_up_hook)();
-
+ /* may get called twice (for IPv4 and IPv6) but the hook handles that well */
if (pppol2tp_ip_updown_hook != NULL) {
(*pppol2tp_ip_updown_hook)(pppol2tp_tunnel_id,
pppol2tp_session_id, 1);
}
}
-static void pppol2tp_ip_down_hook(void)
+static void pppol2tp_ip_down(void *opaque, int arg)
{
- if (old_ip_down_hook != NULL)
- (*old_ip_down_hook)();
-
+ /* may get called twice (for IPv4 and IPv6) but the hook handles that well */
if (pppol2tp_ip_updown_hook != NULL) {
(*pppol2tp_ip_updown_hook)(pppol2tp_tunnel_id,
pppol2tp_session_id, 0);
snoop_recv_hook = pppol2tp_lcp_snoop_recv;
snoop_send_hook = pppol2tp_lcp_snoop_send;
}
-
- /* Hook up ip up/down hooks to send indicator to openl2tpd
- * that the link is up
- */
- old_ip_up_hook = ip_up_hook;
- ip_up_hook = pppol2tp_ip_up_hook;
- old_ip_down_hook = ip_down_hook;
- ip_down_hook = pppol2tp_ip_down_hook;
}
/* Called just before pppd exits.
fatal("No PPPoL2TP support on this OS");
#endif
add_options(pppol2tp_options);
+
+ /* Hook up ip up/down notifiers to send indicator to openl2tpd
+ * that the link is up
+ */
+ add_notifier(&ip_up_notifier, pppol2tp_ip_up, NULL);
+ add_notifier(&ip_down_notifier, pppol2tp_ip_down, NULL);
+ add_notifier(&ipv6_up_notifier, pppol2tp_ip_up, NULL);
+ add_notifier(&ipv6_down_notifier, pppol2tp_ip_down, NULL);
}
struct channel pppol2tp_channel = {