]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/ipcp.c
1) Created a subdirectory called 'solaris'. Currently it contains a replica
[ppp.git] / pppd / ipcp.c
index d273f50d5534bf670e18beff9599c4f7066dc152..484c00c4b988c9a49f58b6912d9cd55e12a2fd4d 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.54 2000/04/15 01:27:11 masputra 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 */
@@ -109,7 +115,7 @@ static option_t ipcp_option_list[] = {
     { "-vjccomp", o_bool, &ipcp_wantoptions[0].cflag,
       "Disable VJ connection-ID compression", OPT_A2COPY,
       &ipcp_allowoptions[0].cflag },
-    { "vj-max-slots", 1, setvjslots,
+    { "vj-max-slots", 1, (void *)setvjslots,
       "Set maximum VJ header slots" },
     { "ipcp-accept-local", o_bool, &ipcp_wantoptions[0].accept_local,
       "Accept peer's address for us", 1 },
@@ -119,9 +125,9 @@ static option_t ipcp_option_list[] = {
       "Set ip script parameter" },
     { "noipdefault", o_bool, &disable_defaultip,
       "Don't use name for default IP adrs", 1 },
-    { "ms-dns", 1, setdnsaddr,
+    { "ms-dns", 1, (void *)setdnsaddr,
       "DNS address for the peer's use" },
-    { "ms-wins", 1, setwinsaddr,
+    { "ms-wins", 1, (void *)setwinsaddr,
       "Nameserver for SMB over TCP/IP for peer" },
     { "ipcp-restart", o_int, &ipcp_fsm[0].timeouttime,
       "Set timeout for IPCP" },
@@ -1383,15 +1389,15 @@ ipcp_up(f)
        ipcp_close(f->unit, "Could not determine local IP address");
        return;
     }
-    script_setenv("IPLOCAL", ip_ntoa(go->ouraddr));
-    script_setenv("IPREMOTE", ip_ntoa(ho->hisaddr));
+    script_setenv("IPLOCAL", ip_ntoa(go->ouraddr), 0);
+    script_setenv("IPREMOTE", ip_ntoa(ho->hisaddr), 1);
 
     if (usepeerdns && (go->dnsaddr[0] || go->dnsaddr[1])) {
-       script_setenv("USEPEERDNS", "1");
+       script_setenv("USEPEERDNS", "1", 0);
        if (go->dnsaddr[0])
-           script_setenv("DNS1", ip_ntoa(go->dnsaddr[0]));
+           script_setenv("DNS1", ip_ntoa(go->dnsaddr[0]), 0);
        if (go->dnsaddr[1])
-           script_setenv("DNS2", ip_ntoa(go->dnsaddr[1]));
+           script_setenv("DNS2", ip_ntoa(go->dnsaddr[1]), 0);
        create_resolv(go->dnsaddr[0], go->dnsaddr[1]);
     }
 
@@ -1417,13 +1423,13 @@ ipcp_up(f)
            ipcp_clear_addrs(f->unit, wo->ouraddr, wo->hisaddr);
            if (go->ouraddr != wo->ouraddr) {
                warn("Local IP address changed to %I", go->ouraddr);
-               script_setenv("OLDIPLOCAL", ip_ntoa(wo->ouraddr));
+               script_setenv("OLDIPLOCAL", ip_ntoa(wo->ouraddr), 0);
                wo->ouraddr = go->ouraddr;
            } else
                script_unsetenv("OLDIPLOCAL");
            if (ho->hisaddr != wo->hisaddr) {
                warn("Remote IP address changed to %I", ho->hisaddr);
-               script_setenv("OLDIPREMOTE", ip_ntoa(wo->hisaddr));
+               script_setenv("OLDIPREMOTE", ip_ntoa(wo->hisaddr), 0);
                wo->hisaddr = ho->hisaddr;
            } else
                script_unsetenv("OLDIPREMOTE");
@@ -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);
@@ -1782,7 +1793,7 @@ ipcp_printpkt(p, plen, printer, arg)
     case TERMREQ:
        if (len > 0 && *p >= ' ' && *p < 0x7f) {
            printer(arg, " ");
-           print_string(p, len, printer, arg);
+           print_string((char *)p, len, printer, arg);
            p += len;
            len = 0;
        }