Hopefully word-wrap is disabled :(
this was originally posted to the linux-kernel list by 
Shaw Carruthers <[EMAIL PROTECTED]>

It should apply cleanly to 0.98.1 as well as 0.16.5, I have not checked the new 0.98.2 
code for any differences in ppp.c.

Lourdes

--- diald-0.16.5.orig/ppp.c.orig        Sun Jan 25 21:51:49 1998
+++ diald-0.16.5.orig/ppp.c     Wed Mar 25 08:11:04 1998
@@ -122,6 +122,7 @@
 int ppp_set_addrs()
 {
     ulong laddr = 0, raddr = 0;
+    int sockfd;
 
     /* Try to get the interface number if we don't know it yet. */
     if (link_iface == -1) {
@@ -140,28 +141,40 @@
        SET_SA_FAMILY (ifr.ifr_dstaddr, AF_INET); 
        SET_SA_FAMILY (ifr.ifr_netmask, AF_INET); 
        sprintf(ifr.ifr_name,"ppp%d",link_iface);
+       sockfd = socket(AF_INET, SOCK_DGRAM, 0);
+       if (sockfd < 0)
+                       {
+                               syslog(LOG_ERR, "Couldn't create IP socket in ppp.c: 
+%m");
+                       die(1);
+        }
        if (ioctl(snoopfd, SIOCGIFFLAGS, (caddr_t) &ifr) == -1) {
           syslog(LOG_ERR,"failed to read ppp interface status");
+          close(sockfd);
           return 0;
        }
-       if (!(ifr.ifr_flags & IFF_UP))
-           return 0;   /* interface is not up yet */
+       if (!(ifr.ifr_flags & IFF_UP)) {
+          close(sockfd);
+          return 0;    /* interface is not up yet */
+       }
 
        if (route_wait) {
            /* set the initial rx counter once the link is up */
            if (rx_count == -1) rx_count = ppp_rx_count();
 
            /* check if we got the routing packet yet */
-           if (ppp_rx_count() == rx_count) return 0;
+           if (ppp_rx_count() == rx_count) {
+                   close(sockfd);
+                   return 0;
+           }
        }
 
        /* Ok, the interface is up, grab the addresses. */
-       if (ioctl(snoopfd, SIOCGIFADDR, (caddr_t) &ifr) == -1)
+       if (ioctl(sockfd, SIOCGIFADDR, (caddr_t) &ifr) == -1)
                syslog(LOG_ERR,"failed to get ppp local address: %m");
        else
                    laddr = ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr;
 
-       if (ioctl(snoopfd, SIOCGIFDSTADDR, (caddr_t) &ifr) == -1) 
+       if (ioctl(sockfd, SIOCGIFDSTADDR, (caddr_t) &ifr) == -1) 
           syslog(LOG_ERR,"failed to get ppp remote address: %m");
        else
           raddr = ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr;
@@ -181,7 +194,7 @@
                proxy_config(orig_local_ip,orig_remote_ip);
            }
        }
-
+       close (sockfd);
        if (dynamic_addrs) {
            /* only do the configuration in dynamic mode. */
            struct in_addr addr;
@@ -192,6 +205,7 @@
            local_addr = laddr;
            syslog(LOG_INFO,"New addresses: local %s, remote %s.",
                local_ip,remote_ip);
+       }
            /* have to reset the proxy if we won't be rerouting... */
            if (!do_reroute) {
                /* If we are rerouting, then we have a window without
@@ -199,18 +213,19 @@
                 * clobbers all the routes.
                 */
                proxy_config(local_ip,remote_ip);
-               set_ptp("sl",proxy_iface,remote_ip,1);
-               add_routes("sl",proxy_iface,local_ip,remote_ip,1);
+               set_ptp("sl",proxy_iface,remote_ip,0);
+               add_routes("sl",proxy_iface,local_ip,remote_ip,0);
            }
-       }
 
        /* This is redundant in normal operation, but if we
         * have to restart the link, then this is necessary...
         */
-       set_ptp("ppp",link_iface,remote_ip,0);
+        /* set_ptp("ppp",link_iface,remote_ip,0); */
 
-       if (do_reroute)
+       if (do_reroute){
             add_routes("ppp",link_iface,local_ip,remote_ip,0);
+            del_routes("sl",proxy_iface,orig_local_ip,orig_remote_ip,0);
+       }     
        return 1;
     }
     return 0;


-
To unsubscribe from this list: send the line "unsubscribe linux-diald" in
the body of a message to [EMAIL PROTECTED]

Reply via email to