]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/ipcp.c
add ip_{up,down}_hook
[ppp.git] / pppd / ipcp.c
index d273f50d5534bf670e18beff9599c4f7066dc152..b5749ac68363846dfd4fb3347c77536ad05bc9c4 100644 (file)
@@ -17,7 +17,7 @@
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define RCSID  "$Id: ipcp.c,v 1.51 1999/11/15 01:51:51 paulus Exp $"
+#define RCSID  "$Id: ipcp.c,v 1.52 1999/12/23 01:25:33 paulus Exp $"
 
 /*
  * TODO:
@@ -47,6 +47,12 @@ ipcp_options ipcp_hisoptions[NUM_PPP];       /* Options that we ack'd */
 
 bool   disable_defaultip = 0;  /* Don't use hostname for default IP adrs */
 
+/* Hook for a plugin to know when IP protocol has come up */
+void (*ip_up_hook) __P((void)) = NULL;
+
+/* Hook for a plugin to know when IP protocol has come down */
+void (*ip_down_hook) __P((void)) = NULL;
+
 /* local vars */
 static int default_route_set[NUM_PPP]; /* Have set up a default route */
 static int proxy_arp_set[NUM_PPP];     /* Have created proxy arp entry */
@@ -1507,6 +1513,9 @@ ipcp_up(f)
     np_up(f->unit, PPP_IP);
     ipcp_is_up = 1;
 
+    if (ip_up_hook)
+       ip_up_hook();
+
     /*
      * Execute the ip-up script, like this:
      * /etc/ppp/ip-up interface tty speed local-IP remote-IP
@@ -1532,6 +1541,8 @@ ipcp_down(f)
     /* XXX a bit IPv4-centric here, we only need to get the stats
      * before the interface is marked down. */
     update_link_stats(f->unit);
+    if (ip_down_hook)
+       ip_down_hook();
     if (ipcp_is_up) {
        ipcp_is_up = 0;
        np_down(f->unit, PPP_IP);