]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/ipcp.c
add ip_{up,down}_hook
[ppp.git] / pppd / ipcp.c
index a652cbb641b51374129a4d447c99d98a13134ef2..b5749ac68363846dfd4fb3347c77536ad05bc9c4 100644 (file)
@@ -17,7 +17,7 @@
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define RCSID  "$Id: ipcp.c,v 1.50 1999/08/24 05:31:09 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 */
@@ -264,7 +270,7 @@ setdnsaddr(argv)
     struct hostent *hp;
 
     dns = inet_addr(*argv);
-    if (dns == -1) {
+    if (dns == (u_int32_t) -1) {
        if ((hp = gethostbyname(*argv)) == NULL) {
            option_error("invalid address parameter '%s' for ms-dns option",
                         *argv);
@@ -296,7 +302,7 @@ setwinsaddr(argv)
     struct hostent *hp;
 
     wins = inet_addr(*argv);
-    if (wins == -1) {
+    if (wins == (u_int32_t) -1) {
        if ((hp = gethostbyname(*argv)) == NULL) {
            option_error("invalid address parameter '%s' for ms-wins option",
                         *argv);
@@ -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);