]> git.ozlabs.org Git - ppp.git/commitdiff
minor bugfixes, now 2.4.2b1, add pkts_in/out to pppd_stats,
authorPaul Mackerras <paulus@samba.org>
Fri, 27 Apr 2001 23:16:13 +0000 (23:16 +0000)
committerPaul Mackerras <paulus@samba.org>
Fri, 27 Apr 2001 23:16:13 +0000 (23:16 +0000)
finish transition to netif_set_mtu and tty_send/recv_config

pppd/main.c
pppd/patchlevel.h
pppd/pppd.h
pppd/sys-linux.c
pppd/sys-solaris.c
pppd/sys-sunos4.c

index e0352f02d462726e7ab9e54f75aed64268e58db7..498f856430ce8244b1bc45a084d645a8225f2958 100644 (file)
@@ -17,7 +17,7 @@
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define RCSID  "$Id: main.c,v 1.105 2001/03/12 22:58:59 paulus Exp $"
+#define RCSID  "$Id: main.c,v 1.106 2001/04/27 23:16:13 paulus Exp $"
 
 #include <stdio.h>
 #include <ctype.h>
@@ -1087,9 +1087,6 @@ static struct timeval timenow;            /* Current time */
 
 /*
  * timeout - Schedule a timeout.
- *
- * Note that this timeout takes the number of milliseconds, NOT hz (as in
- * the kernel).
  */
 void
 timeout(func, arg, secs, usecs)
@@ -1098,10 +1095,10 @@ timeout(func, arg, secs, usecs)
     int secs, usecs;
 {
     struct callout *newp, *p, **pp;
-  
+
     MAINDEBUG(("Timeout %p:%p in %d.%03d seconds.", func, arg,
-              time / 1000, time % 1000));
-  
+              secs, usecs/1000));
+
     /*
      * Allocate timeout.
      */
index 5e55d2538cba38e43f20821e874fa91a9eeb7f76..5cdc40d635f4ab28af628bd1add9e4b544cba8cc 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: patchlevel.h,v 1.53 2001/03/25 04:51:54 paulus Exp $ */
+/* $Id: patchlevel.h,v 1.54 2001/04/27 23:16:13 paulus Exp $ */
 
-#define VERSION                "2.4.1"
-#define DATE           "25 March 2001"
+#define VERSION                "2.4.2b1"
+#define DATE           "25 April 2001"
index 38788ce4aa078d633347114d89ca4133d2cd0598..7d27c1c3ab3c1cb54f5bde45b005ca807afdfdaf 100644 (file)
@@ -16,7 +16,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- * $Id: pppd.h,v 1.59 2001/03/12 22:58:59 paulus Exp $
+ * $Id: pppd.h,v 1.60 2001/04/27 23:16:13 paulus Exp $
  */
 
 /*
@@ -147,6 +147,8 @@ struct permitted_ip {
 struct pppd_stats {
     unsigned int       bytes_in;
     unsigned int       bytes_out;
+    unsigned int       pkts_in;
+    unsigned int       pkts_out;
 };
 
 /* Used for storing a sequence of words.  Usually malloced. */
@@ -212,11 +214,15 @@ extern int        unsuccess;      /* # unsuccessful connection attempts */
 extern int     do_callback;    /* set if we want to do callback next */
 extern int     doing_callback; /* set if this is a callback */
 extern char    ppp_devnam[MAXPATHLEN];
+extern int     listen_time;    /* time to listen first (ms) */
 extern struct notifier *pidchange;   /* for notifications of pid changing */
 extern struct notifier *phasechange; /* for notifications of phase changes */
 extern struct notifier *exitnotify;  /* for notification that we're exiting */
 extern struct notifier *sigreceived; /* notification of received signal */
-extern int     listen_time;    /* time to listen first (ms) */
+extern struct notifier *ip_up_notifier; /* IPCP has come up */
+extern struct notifier *ip_down_notifier; /* IPCP has gone down */
+extern struct notifier *auth_up_notifier; /* peer has authenticated */
+extern struct notifier *link_down_notifier; /* link has gone down */
 
 /* Values for do_callback and doing_callback */
 #define CALLBACK_DIALIN                1       /* we are expecting the call back */
index f1b48423ef83c537367820db55cc1ffb96b2a841..189b809cc97d128ed8944fc012f3b6424369c4b0 100644 (file)
@@ -182,7 +182,6 @@ static void decode_version (char *buf, int *version, int *mod, int *patch);
 static int set_kdebugflag(int level);
 static int ppp_registered(void);
 static int make_ppp_unit(void);
-static void restore_loop(void);        /* Transfer ppp unit back to loopback */
 
 extern u_char  inpacket_buf[]; /* borrowed from main.c */
 
@@ -499,8 +498,6 @@ int tty_establish_ppp (int tty_fd)
 
 void tty_disestablish_ppp(int tty_fd)
 {
-    if (demand)
-       restore_loop();
     if (!hungup) {
 /*
  * Flush the tty output buffer so that the TIOCSETD doesn't hang.
@@ -531,10 +528,17 @@ void tty_disestablish_ppp(int tty_fd)
     if (new_style_driver) {
        close(ppp_fd);
        ppp_fd = -1;
-       if (!looped && ifunit >= 0 && ioctl(ppp_dev_fd, PPPIOCDETACH) < 0)
+       if (demand) {
+           set_flags(ppp_dev_fd, get_flags(ppp_dev_fd) | SC_LOOP_TRAFFIC);
+           looped = 1;
+       } else if (ifunit >= 0 && ioctl(ppp_dev_fd, PPPIOCDETACH) < 0)
            error("Couldn't release PPP unit: %m");
        if (!multilink)
            remove_fd(ppp_dev_fd);
+    } else {
+       /* old-style driver */
+       if (demand)
+           set_ppp_fd(slave_fd);
     }
 }
 
@@ -1168,7 +1172,7 @@ int ccp_test (int unit, u_char *opt_ptr, int opt_len, int for_transmit)
 
 void ccp_flags_set (int unit, int isopen, int isup)
 {
-    if (still_ppp()) {
+    if (still_ppp() && ifunit >= 0) {
        int x = get_flags(ppp_dev_fd);
        x = isopen? x | SC_CCP_OPEN : x &~ SC_CCP_OPEN;
        x = isup?   x | SC_CCP_UP   : x &~ SC_CCP_UP;
@@ -1236,6 +1240,8 @@ get_ppp_stats(u, stats)
     }
     stats->bytes_in = req.stats.p.ppp_ibytes;
     stats->bytes_out = req.stats.p.ppp_obytes;
+    stats->pkts_in = req.stats.p.ppp_ipackets;
+    stats->pkts_out = req.stats.p.ppp_opackets;
     return 1;
 }
 
@@ -2554,33 +2560,6 @@ open_ppp_loopback(void)
     return master_fd;
 }
 
-/********************************************************************
- *
- * restore_loop - reattach the ppp unit to the loopback.
- *
- * The kernel ppp driver automatically reattaches the ppp unit to
- * the loopback if the serial port is set to a line discipline other
- * than ppp, or if it detects a modem hangup.  The former will happen
- * in disestablish_ppp if the latter hasn't already happened, so we
- * shouldn't need to do anything.
- *
- * Just to be sure, set the real serial port to the normal discipline.
- */
-
-static void
-restore_loop(void)
-{
-    looped = 1;
-    if (new_style_driver) {
-       set_flags(ppp_dev_fd, get_flags(ppp_dev_fd) | SC_LOOP_TRAFFIC);
-       return;
-    }
-    if (ppp_fd != slave_fd) {
-       (void) ioctl(ppp_fd, TIOCSETD, &tty_disc);
-       set_ppp_fd(slave_fd);
-    }
-}
-
 /********************************************************************
  *
  * sifnpmode - Set the mode for handling packets for a given NP.
index 2cba082652649376134971423e5c06a607ed8df3..ff9c7def8d6071cdb60f75395492c90c3b99943d 100644 (file)
@@ -42,7 +42,7 @@
  * OR MODIFICATIONS.
  */
 
-#define RCSID  "$Id: sys-solaris.c,v 1.4 2001/03/12 22:59:00 paulus Exp $"
+#define RCSID  "$Id: sys-solaris.c,v 1.5 2001/04/27 23:16:13 paulus Exp $"
 
 #include <limits.h>
 #include <stdio.h>
@@ -1520,7 +1520,7 @@ tty_send_config(mtu, asyncmap, pcomp, accomp)
 }
 
 /*
- * ppp_set_xaccm - set the extended transmit ACCM for the interface.
+ * tty_set_xaccm - set the extended transmit ACCM for the interface.
  */
 void
 tty_set_xaccm(accm)
@@ -1537,7 +1537,7 @@ tty_set_xaccm(accm)
 }
 
 /*
- * ppp_recv_config - configure the receive-side characteristics of
+ * tty_recv_config - configure the receive-side characteristics of
  * the ppp interface.
  */
 void
@@ -1629,6 +1629,8 @@ get_ppp_stats(u, stats)
     }
     stats->bytes_in = s.p.ppp_ibytes;
     stats->bytes_out = s.p.ppp_obytes;
+    stats->pkts_in = s.p.ppp_ipackets;
+    stats->pkts_out = s.p.ppp_opackets;
     return 1;
 }
 
@@ -1956,12 +1958,6 @@ sifaddr(u, o, h, m)
        error("Couldn't set remote IP address: %m");
        ret = 0;
     }
-#if 0  /* now done in ppp_send_config */
-    ifr.ifr_metric = link_mtu;
-    if (ioctl(ipfd, SIOCSIFMTU, &ifr) < 0) {
-       error("Couldn't set IP MTU: %m");
-    }
-#endif
 
     remote_addr = h;
     return ret;
index 00f2ec521f5001006c091d7fa96970e84f361b07..9159b4cd7f49a9f2504bfd1aedf54dc9844a10c3 100644 (file)
@@ -25,7 +25,7 @@
  * OR MODIFICATIONS.
  */
 
-#define RCSID  "$Id: sys-sunos4.c,v 1.26 2001/03/12 22:59:00 paulus Exp $"
+#define RCSID  "$Id: sys-sunos4.c,v 1.27 2001/04/27 23:16:13 paulus Exp $"
 
 #include <stdio.h>
 #include <stddef.h>
@@ -735,17 +735,33 @@ get_loop_output()
 }
 
 /*
- * ppp_send_config - configure the transmit characteristics of
- * the ppp interface.
+ * netif_set_mtu - set the MTU on the PPP network interface.
  */
 void
-ppp_send_config(unit, mtu, asyncmap, pcomp, accomp)
+netif_set_mtu(unit, mtu)
     int unit, mtu;
+{
+    struct ifreq ifr;
+
+    memset(&ifr, 0, sizeof(ifr));
+    strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+    ifr.ifr_metric = link_mtu;
+    if (ioctl(sockfd, SIOCSIFMTU, &ifr) < 0) {
+       error("Couldn't set IP MTU: %m");
+    }
+}
+
+/*
+ * tty_send_config - configure the transmit characteristics of
+ * the ppp interface.
+ */
+void
+tty_send_config(mtu, asyncmap, pcomp, accomp)
+    int mtu;
     u_int32_t asyncmap;
     int pcomp, accomp;
 {
     int cf[2];
-    struct ifreq ifr;
 
     link_mtu = mtu;
     if (strioctl(pppfd, PPPIO_MTU, &mtu, sizeof(mtu), 0) < 0) {
@@ -761,21 +777,13 @@ ppp_send_config(unit, mtu, asyncmap, pcomp, accomp)
     if (strioctl(pppfd, PPPIO_CFLAGS, cf, sizeof(cf), sizeof(int)) < 0) {
        error("Couldn't set prot/AC compression: %m");
     }
-
-    /* set mtu for ip as well */
-    memset(&ifr, 0, sizeof(ifr));
-    strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
-    ifr.ifr_metric = link_mtu;
-    if (ioctl(sockfd, SIOCSIFMTU, &ifr) < 0) {
-       error("Couldn't set IP MTU: %m");
-    }
 }
 
 /*
- * ppp_set_xaccm - set the extended transmit ACCM for the interface.
+ * tty_set_xaccm - set the extended transmit ACCM for the interface.
  */
 void
-ppp_set_xaccm(unit, accm)
+tty_set_xaccm(unit, accm)
     int unit;
     ext_accm accm;
 {
@@ -786,12 +794,12 @@ ppp_set_xaccm(unit, accm)
 }
 
 /*
- * ppp_recv_config - configure the receive-side characteristics of
+ * tty_recv_config - configure the receive-side characteristics of
  * the ppp interface.
  */
 void
-ppp_recv_config(unit, mru, asyncmap, pcomp, accomp)
-    int unit, mru;
+tty_recv_config(mru, asyncmap, pcomp, accomp)
+    int mru;
     u_int32_t asyncmap;
     int pcomp, accomp;
 {
@@ -872,6 +880,8 @@ get_ppp_stats(u, stats)
     }
     stats->bytes_in = s.p.ppp_ibytes;
     stats->bytes_out = s.p.ppp_obytes;
+    stats->pkts_in = s.p.ppp_ipackets;
+    stats->pkts_out = s.p.ppp_opackets;
     return 1;
 }