make restore_loop part of disestablish_ppp
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define RCSID "$Id: main.c,v 1.104 2001/03/09 00:55:14 paulus Exp $"
+#define RCSID "$Id: main.c,v 1.105 2001/03/12 22:58:59 paulus Exp $"
#include <stdio.h>
#include <ctype.h>
#include <stdio.h>
#include <ctype.h>
/* set up the serial device as a ppp interface */
tdb_writelock(pppdb);
/* set up the serial device as a ppp interface */
tdb_writelock(pppdb);
- fd_ppp = establish_ppp(devfd);
+ fd_ppp = the_channel->establish_ppp(devfd);
if (fd_ppp < 0) {
tdb_writeunlock(pppdb);
status = EXIT_FATAL_ERROR;
if (fd_ppp < 0) {
tdb_writeunlock(pppdb);
status = EXIT_FATAL_ERROR;
if (link_stats_valid) {
int t = (link_connect_time + 5) / 6; /* 1/10ths of minutes */
info("Connect time %d.%d minutes.", t/10, t%10);
if (link_stats_valid) {
int t = (link_connect_time + 5) / 6; /* 1/10ths of minutes */
info("Connect time %d.%d minutes.", t/10, t%10);
- info("Sent %d bytes, received %d bytes.",
+ info("Sent %u bytes, received %u bytes.",
link_stats.bytes_out, link_stats.bytes_in);
}
link_stats.bytes_out, link_stats.bytes_in);
}
*/
remove_fd(fd_ppp);
clean_check();
*/
remove_fd(fd_ppp);
clean_check();
- if (demand)
- restore_loop();
- disestablish_ppp(devfd); /* XXX */
+ the_channel->disestablish_ppp(devfd);
fd_ppp = -1;
if (!hungup)
lcp_lowerdown(0);
fd_ppp = -1;
if (!hungup)
lcp_lowerdown(0);
sys_cleanup();
if (fd_ppp >= 0)
sys_cleanup();
if (fd_ppp >= 0)
- disestablish_ppp(devfd);
+ the_channel->disestablish_ppp(devfd);
if (the_channel->cleanup)
(*the_channel->cleanup)();
if (the_channel->cleanup)
(*the_channel->cleanup)();
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: pppd.h,v 1.58 2001/03/08 05:11:16 paulus Exp $
+ * $Id: pppd.h,v 1.59 2001/03/12 22:58:59 paulus Exp $
void (*check_options) __P((void));
/* get the channel ready to do PPP, return a file descriptor */
int (*connect) __P((void));
void (*check_options) __P((void));
/* get the channel ready to do PPP, return a file descriptor */
int (*connect) __P((void));
- /* we're finished doing PPP on the channel */
+ /* we're finished with the channel */
void (*disconnect) __P((void));
void (*disconnect) __P((void));
+ /* put the channel into PPP `mode' */
+ int (*establish_ppp) __P((int));
+ /* take the channel out of PPP `mode', restore loopback if demand */
+ void (*disestablish_ppp) __P((int));
/* set the transmit-side PPP parameters of the channel */
void (*send_config) __P((int, u_int32_t, int, int));
/* set the receive-side PPP parameters of the channel */
/* set the transmit-side PPP parameters of the channel */
void (*send_config) __P((int, u_int32_t, int, int));
/* set the receive-side PPP parameters of the channel */
int ppp_available __P((void)); /* Test whether ppp kernel support exists */
int get_pty __P((int *, int *, char *, int)); /* Get pty master/slave */
int open_ppp_loopback __P((void)); /* Open loopback for demand-dialling */
int ppp_available __P((void)); /* Test whether ppp kernel support exists */
int get_pty __P((int *, int *, char *, int)); /* Get pty master/slave */
int open_ppp_loopback __P((void)); /* Open loopback for demand-dialling */
-int establish_ppp __P((int)); /* Turn serial port into a ppp interface */
-void restore_loop __P((void)); /* Transfer ppp unit back to loopback */
-void disestablish_ppp __P((int)); /* Restore port to normal operation */
+int tty_establish_ppp __P((int)); /* Turn serial port into a ppp interface */
+void tty_disestablish_ppp __P((int)); /* Restore port to normal operation */
void make_new_bundle __P((int, int, int, int)); /* Create new bundle */
int bundle_attach __P((int)); /* Attach link to existing bundle */
void cfg_bundle __P((int, int, int, int)); /* Configure existing bundle */
void make_new_bundle __P((int, int, int, int)); /* Create new bundle */
int bundle_attach __P((int)); /* Attach link to existing bundle */
void cfg_bundle __P((int, int, int, int)); /* Configure existing bundle */
static int set_kdebugflag(int level);
static int ppp_registered(void);
static int make_ppp_unit(void);
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 */
extern u_char inpacket_buf[]; /* borrowed from main.c */
/********************************************************************
*
/********************************************************************
*
- * establish_ppp - Turn the serial port into a ppp interface.
+ * tty_establish_ppp - Turn the serial port into a ppp interface.
-int establish_ppp (int tty_fd)
+int tty_establish_ppp (int tty_fd)
/********************************************************************
*
/********************************************************************
*
- * disestablish_ppp - Restore the serial port to normal operation.
+ * tty_disestablish_ppp - Restore the serial port to normal operation,
+ * and reconnect the ppp unit to the loopback if in demand mode.
* This shouldn't call die() because it's called from die().
*/
* This shouldn't call die() because it's called from die().
*/
-void disestablish_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.
if (!hungup) {
/*
* Flush the tty output buffer so that the TIOCSETD doesn't hang.
nr = read(ppp_fd, buf, len);
if (nr < 0 && errno != EWOULDBLOCK && errno != EIO && errno != EINTR)
error("read: %m");
nr = read(ppp_fd, buf, len);
if (nr < 0 && errno != EWOULDBLOCK && errno != EIO && errno != EINTR)
error("read: %m");
+ if (nr < 0 && errno == ENXIO)
+ return 0;
}
if (nr < 0 && new_style_driver && ifunit >= 0) {
/* N.B. we read ppp_fd first since LCP packets come in there. */
nr = read(ppp_dev_fd, buf, len);
if (nr < 0 && errno != EWOULDBLOCK && errno != EIO && errno != EINTR)
error("read /dev/ppp: %m");
}
if (nr < 0 && new_style_driver && ifunit >= 0) {
/* N.B. we read ppp_fd first since LCP packets come in there. */
nr = read(ppp_dev_fd, buf, len);
if (nr < 0 && errno != EWOULDBLOCK && errno != EIO && errno != EINTR)
error("read /dev/ppp: %m");
+ if (nr < 0 && errno == ENXIO)
+ return 0;
}
return (new_style_driver && nr > 0)? nr+2: nr;
}
}
return (new_style_driver && nr > 0)? nr+2: nr;
}
ifr.ifr_mtu = mtu;
if (ifunit >= 0 && ioctl(sock_fd, SIOCSIFMTU, (caddr_t) &ifr) < 0)
ifr.ifr_mtu = mtu;
if (ifunit >= 0 && ioctl(sock_fd, SIOCSIFMTU, (caddr_t) &ifr) < 0)
- fatal("ioctl(SIOCSIFMTU): %m(%d)", errno);
+ fatal("ioctl(SIOCSIFMTU): %m");
}
/********************************************************************
}
/********************************************************************
* Just to be sure, set the real serial port to the normal discipline.
*/
* Just to be sure, set the real serial port to the normal discipline.
*/
restore_loop(void)
{
looped = 1;
restore_loop(void)
{
looped = 1;
-#define RCSID "$Id: sys-solaris.c,v 1.3 2001/03/08 05:14:26 paulus Exp $"
+#define RCSID "$Id: sys-solaris.c,v 1.4 2001/03/12 22:59:00 paulus Exp $"
#include <limits.h>
#include <stdio.h>
#include <limits.h>
#include <stdio.h>
- * establish_ppp - Turn the serial port into a ppp interface.
+ * tty_establish_ppp - Turn the serial port into a ppp interface.
- * restore_loop - reattach the ppp unit to the loopback.
- * This doesn't need to do anything because disestablish_ppp does it.
- */
-void
-restore_loop()
-{
-}
-
-/*
- * disestablish_ppp - Restore the serial port to normal operation.
+ * tty_disestablish_ppp - Restore the serial port to normal operation.
* It attempts to reconstruct the stream with the previously popped
* modules. This shouldn't call die() because it's called from die().
*/
void
* It attempts to reconstruct the stream with the previously popped
* modules. This shouldn't call die() because it's called from die().
*/
void
+tty_disestablish_ppp(fd)
-#define RCSID "$Id: sys-sunos4.c,v 1.25 1999/12/23 01:38:19 paulus Exp $"
+#define RCSID "$Id: sys-sunos4.c,v 1.26 2001/03/12 22:59:00 paulus Exp $"
#include <stdio.h>
#include <stddef.h>
#include <stdio.h>
#include <stddef.h>
- * establish_ppp - Turn the serial port into a ppp interface.
+ * tty_establish_ppp - Turn the serial port into a ppp interface.
-/*
- * restore_loop - reattach the ppp unit to the loopback.
- * This doesn't need to do anything because disestablish_ppp does it.
- */
-void
-restore_loop()
-{
-}
-
/*
* disestablish_ppp - Restore the serial port to normal operation.
* It attempts to reconstruct the stream with the previously popped
* modules. This shouldn't call die() because it's called from die().
*/
void
/*
* disestablish_ppp - Restore the serial port to normal operation.
* It attempts to reconstruct the stream with the previously popped
* modules. This shouldn't call die() because it's called from die().
*/
void
+tty_disestablish_ppp(fd)
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define RCSID "$Id: tty.c,v 1.5 2001/03/08 05:11:16 paulus Exp $"
+#define RCSID "$Id: tty.c,v 1.6 2001/03/12 22:59:01 paulus Exp $"
#include <stdio.h>
#include <ctype.h>
#include <stdio.h>
#include <ctype.h>
&tty_check_options,
&connect_tty,
&disconnect_tty,
&tty_check_options,
&connect_tty,
&disconnect_tty,
+ &tty_establish_ppp,
+ &tty_disestablish_ppp,
&tty_do_send_config,
&tty_recv_config,
&cleanup_tty,
&tty_do_send_config,
&tty_recv_config,
&cleanup_tty,