]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/sys-linux.c
small changes suggested by Seth Chaiklin
[ppp.git] / pppd / sys-linux.c
index 1139369f6edad62861c57b5bff98b767c23a7379..43855a932afaff000fc419412e873aca7ce17612 100644 (file)
@@ -866,6 +866,7 @@ void ppp_send_config (int unit,int mtu,u_int32_t asyncmap,int pcomp,int accomp)
     x = get_flags();
     x = pcomp  ? x | SC_COMP_PROT : x & ~SC_COMP_PROT;
     x = accomp ? x | SC_COMP_AC   : x & ~SC_COMP_AC;
+    x = sync_serial ? x | SC_SYNC : x & ~SC_SYNC;
     set_flags(x);
 }
 
@@ -1570,47 +1571,39 @@ ppp_registered(void)
 {
     int local_fd;
     int init_disc = -1;
-    int initfdflags;
+    int mfd = -1;
+    int ret = 0;
 
-    local_fd = open(devnam, O_NONBLOCK | O_RDWR, 0);
-    if (local_fd < 0) {
-       error("Failed to open %s: %m(%d)", devnam, errno);
-       return 0;
-    }
-
-    initfdflags = fcntl(local_fd, F_GETFL);
-    if (initfdflags == -1) {
-       error("Couldn't get device fd flags: %m(%d)", errno);
-       close (local_fd);
-       return 0;
+    if (devnam[0] == 0) {
+       /* running with notty or pty option */
+       char slave[16];
+       if (!get_pty(&mfd, &local_fd, slave, 0))
+           return 0;
+    } else {
+       local_fd = open(devnam, O_NONBLOCK | O_RDWR, 0);
+       if (local_fd < 0) {
+           error("Failed to open %s: %m(%d)", devnam, errno);
+           return 0;
+       }
     }
 
-    initfdflags &= ~O_NONBLOCK;
-    fcntl(local_fd, F_SETFL, initfdflags);
 /*
- * Read the initial line dicipline and try to put the device into the
+ * Read the initial line discipline and try to put the device into the
  * PPP dicipline.
  */
     if (ioctl(local_fd, TIOCGETD, &init_disc) < 0) {
        error("ioctl(TIOCGETD): %m(%d)", errno);
-       close (local_fd);
-       return 0;
-    }
-    
-    if (ioctl(local_fd, TIOCSETD, &ppp_disc) < 0) {
-       error("ioctl(TIOCSETD): %m(%d)", errno);
-       close (local_fd);
-       return 0;
-    }
-    
-    if (ioctl(local_fd, TIOCSETD, &init_disc) < 0) {
-       error("ioctl(TIOCSETD): %m(%d)", errno);
-       close (local_fd);
-       return 0;
-    }
+    } else if (ioctl(local_fd, TIOCSETD, &ppp_disc) < 0) {
+       error("ioctl(TIOCSETD(PPP)): %m(%d)", errno);
+    } else if (ioctl(local_fd, TIOCSETD, &init_disc) < 0) {
+       error("ioctl(TIOCSETD(%d)): %m(%d)", init_disc, errno);
+    } else
+       ret = 1;
     
     close (local_fd);
-    return 1;
+    if (mfd >= 0)
+       close(mfd);
+    return ret;
 }
 
 /********************************************************************
@@ -1660,7 +1653,7 @@ int ppp_available(void)
          "This system lacks kernel support for PPP.  This could be because\n"
          "the PPP kernel module is not loaded, or because the kernel is\n"
          "not configured for PPP.  See the README.linux file in the\n"
-         "ppp-2.3.6 distribution.\n";
+         "ppp-2.3.7 distribution.\n";
 
 /*
  *  This is the PPP device. Validate the version of the driver at this
@@ -2029,10 +2022,10 @@ int sifaddr (int unit, u_int32_t our_adr, u_int32_t his_adr,
     if (ioctl(sock_fd, SIOCSIFADDR, (caddr_t) &ifr) < 0) {
        if (errno != EEXIST) {
            if (! ok_error (errno))
-               error("ioctl(SIOCAIFADDR): %m(%d)", errno);
+               error("ioctl(SIOCSIFADDR): %m(%d)", errno);
        }
         else {
-           warn("ioctl(SIOCAIFADDR): Address already exists");
+           warn("ioctl(SIOCSIFADDR): Address already exists");
        }
         return (0);
     }
@@ -2300,10 +2293,10 @@ int sipxfaddr (int unit, unsigned long int network, unsigned char * node )
            result = 0;
            if (errno != EEXIST) {
                if (! ok_error (errno))
-                   dbglog("ioctl(SIOCAIFADDR, CRTITF): %m (%d)", errno);
+                   dbglog("ioctl(SIOCSIFADDR, CRTITF): %m (%d)", errno);
            }
            else {
-               warn("ioctl(SIOCAIFADDR, CRTITF): Address already exists");
+               warn("ioctl(SIOCSIFADDR, CRTITF): Address already exists");
            }
        }
        close (skfd);
@@ -2346,7 +2339,7 @@ int cipxfaddr (int unit)
  */
        if (ioctl(skfd, SIOCSIFADDR, (caddr_t) &ifr) < 0) {
            if (! ok_error (errno))
-               info("ioctl(SIOCAIFADDR, IPX_DLTITF): %m (%d)", errno);
+               info("ioctl(SIOCSIFADDR, IPX_DLTITF): %m (%d)", errno);
            result = 0;
        }
        close (skfd);