* Dynamic PPP devices by Jim Freeman <jfree@caldera.com>.
* ppp_tty_receive ``noisy-raise-bug'' fixed by Ove Ewerlid <ewerlid@syscon.uu.se>
*
- * ==FILEVERSION 970227==
+ * ==FILEVERSION 970522==
*
* NOTE TO MAINTAINERS:
* If you modify this file at all, please set the number above to the
#define PPP_MAX_DEV 256
#endif
-/* $Id: ppp.c,v 1.11 1997/04/30 05:42:36 paulus Exp $
+/* $Id: ppp.c,v 1.12 1997/05/22 06:45:12 paulus Exp $
* Added dynamic allocation of channels to eliminate
* compiled-in limits on the number of channels.
*
#include <linux/ioport.h>
#endif
+#if LINUX_VERSION_CODE >= VERSION(2,1,23)
+#include <linux/poll.h>
+#endif
+
#include <linux/in.h>
#include <linux/malloc.h>
#include <linux/tty.h>
#endif
+#if LINUX_VERSION_CODE < VERSION(2,1,37)
+#define test_and_set_bit(nr, addr) set_bit(nr, addr)
+#endif
+
static int ppp_register_compressor (struct compressor *cp);
static void ppp_unregister_compressor (struct compressor *cp);
static int flag_time = OPTIMIZE_FLAG_TIME;
static int max_dev = PPP_MAX_DEV;
+#if LINUX_VERSION_CODE >= VERSION(2,1,19)
+MODULE_PARM(flag_time, "i");
+MODULE_PARM(max_dev, "i");
+#endif
+
/*
* The "main" procedure to the ppp device
*/
unsigned int);
static int ppp_tty_ioctl (struct tty_struct *, struct file *, unsigned int,
unsigned long);
+#if LINUX_VERSION_CODE < VERSION(2,1,23)
static int ppp_tty_select (struct tty_struct *tty, struct inode *inode,
struct file *filp, int sel_type, select_table * wait);
+#else
+static unsigned int ppp_tty_poll (struct tty_struct *tty, struct file *filp, poll_table * wait);
+#endif
static int ppp_tty_open (struct tty_struct *);
static void ppp_tty_close (struct tty_struct *);
static int ppp_tty_room (struct tty_struct *tty);
ppp_ldisc.read = ppp_tty_read;
ppp_ldisc.write = ppp_tty_write;
ppp_ldisc.ioctl = ppp_tty_ioctl;
+#if LINUX_VERSION_CODE < VERSION(2,1,23)
ppp_ldisc.select = ppp_tty_select;
+#else
+ ppp_ldisc.poll = ppp_tty_poll;
+#endif
ppp_ldisc.receive_room = ppp_tty_room;
ppp_ldisc.receive_buf = ppp_tty_receive;
ppp_ldisc.write_wakeup = ppp_tty_wakeup;
static int
ppp_init_dev (struct device *dev)
{
- int indx;
-
#if LINUX_VERSION_CODE < VERSION(2,1,15)
dev->hard_header = ppp_dev_header;
dev->rebuild_header = ppp_dev_rebuild;
dev->tx_queue_len = 10;
dev->type = ARPHRD_PPP;
- for (indx = 0; indx < DEV_NUMBUFFS; indx++)
- skb_queue_head_init (&dev->buffs[indx]);
+#if LINUX_VERSION_CODE < VERSION(2,1,20)
+ {
+ int indx;
+
+ for (indx = 0; indx < DEV_NUMBUFFS; indx++)
+ skb_queue_head_init (&dev->buffs[indx]);
+ }
+#else
+ dev_init_buffers(dev);
+#endif
/* New-style flags */
- dev->flags = IFF_POINTOPOINT;
+ dev->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
dev->family = AF_INET;
dev->pa_addr = 0;
dev->pa_brdaddr = 0;
static void
ppp_ccp_closed (struct ppp *ppp)
{
+ ppp->flags &= ~(SC_CCP_OPEN | SC_CCP_UP | SC_COMP_RUN | SC_DECOMP_RUN);
if (ppp->sc_xc_state) {
(*ppp->sc_xcomp->comp_free) (ppp->sc_xc_state);
ppp->sc_xc_state = NULL;
ppp_ccp_closed (ppp);
- /* Ensure that the pppd process is not hanging on select() */
+ /* Ensure that the pppd process is not hanging on select()/poll() */
wake_up_interruptible (&ppp->read_wait);
wake_up_interruptible (&ppp->write_wait);
if (dev && dev->flags & IFF_UP) {
dev_close (dev); /* close the device properly */
- dev->flags = 0; /* prevent recursion */
+ dev->flags &= ~IFF_UP; /* prevent recursion */
}
ppp_free_buf (ppp->rbuf);
* The total length includes the protocol data.
* Lock the user information buffer.
*/
- if (set_bit (0, &ppp->ubuf->locked)) {
+ if (test_and_set_bit (0, &ppp->ubuf->locked)) {
if (ppp->flags & SC_DEBUG)
printk (KERN_DEBUG
"ppp_us_queue: can't get lock\n");
|| tty != ppp->tty)
return 0;
- if (set_bit (0, &ppp->ubuf->locked) != 0) {
+ if (test_and_set_bit (0, &ppp->ubuf->locked) != 0) {
if (ppp->flags & SC_DEBUG)
printk (KERN_DEBUG
"ppp_tty_read: sleeping(ubuf)\n");
/*
* TTY callback.
*
- * Process the select() statement for the PPP device.
+ * Process the select() (or poll()) statement for the PPP device.
*/
+#if LINUX_VERSION_CODE < VERSION(2,1,23)
static int
ppp_tty_select (struct tty_struct *tty, struct inode *inode,
struct file *filp, int sel_type, select_table * wait)
*/
switch (sel_type) {
case SEL_IN:
- if (set_bit (0, &ppp->ubuf->locked) == 0) {
+ if (test_and_set_bit (0, &ppp->ubuf->locked) == 0) {
/* Test for the presence of data in the queue */
if (ppp->ubuf->head != ppp->ubuf->tail) {
clear_bit (0, &ppp->ubuf->locked);
return result;
}
+#else /* 2.1.23 or later */
+
+static unsigned int
+ppp_tty_poll (struct tty_struct *tty, struct file *filp, poll_table * wait)
+{
+ struct ppp *ppp = tty2ppp (tty);
+ unsigned int mask = 0;
+
+ if (ppp && ppp->magic == PPP_MAGIC && tty == ppp->tty) {
+ CHECK_PPP (0);
+
+ poll_wait(&ppp->read_wait, wait);
+ poll_wait(&ppp->write_wait, wait);
+
+ /* Must lock the user buffer area while checking. */
+ if(test_and_set_bit(0, &ppp->ubuf->locked) == 0) {
+ if(ppp->ubuf->head != ppp->ubuf->tail)
+ mask |= POLLIN | POLLRDNORM;
+ clear_bit(0, &ppp->ubuf->locked);
+ }
+ if(tty->flags & (1 << TTY_OTHER_CLOSED))
+ mask |= POLLHUP;
+ if(tty_hung_up_p(filp))
+ mask |= POLLHUP;
+ if(ppp->tbuf->locked == 0)
+ mask |= POLLOUT | POLLWRNORM;
+ }
+ return mask;
+}
+
+#endif
+
/*************************************************************
* NETWORK OUTPUT
* This routine accepts requests from the network layer
struct ppp *ppp = dev2ppp (dev);
/* reset POINTOPOINT every time, since dev_close zaps it! */
- dev->flags |= IFF_POINTOPOINT;
+ dev->flags |= IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
if (ppp2tty (ppp) == NULL) {
if (ppp->flags & SC_DEBUG)
while (ctl) {
ppp = ctl2ppp (ctl);
- if (!set_bit(0, &ppp->inuse))
+ if (!test_and_set_bit(0, &ppp->inuse))
return (ppp);
ctl = ctl->next;
if (++if_num == max_dev)
/*
- * ==FILEVERSION 970428==
+ * ==FILEVERSION 970522==
*
* ppp_deflate.c - interface the zlib procedures for Deflate compression
* and decompression (as used by gzip) to the PPP code.
*/
#include <linux/module.h>
-
+#include <linux/version.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/types.h>
#include <linux/ioport.h>
#include <linux/in.h>
#include <linux/malloc.h>
+
+#undef VERSION
+/* a nice define to generate linux version numbers */
+#define VERSION(major,minor,patch) (((((major)<<8)+(minor))<<8)+(patch))
+
+#if LINUX_VERSION_CODE >= VERSION(2,1,4)
#include <linux/vmalloc.h>
+#endif
+
#include <linux/errno.h>
#include <linux/sched.h> /* to get the struct task_struct */
#include <linux/string.h> /* used in new tty drivers */
memset (state, 0, sizeof (struct ppp_deflate_state));
state->strm.next_in = NULL;
state->strm.zalloc = zalloc;
- state->strm.zalloc_init = zalloc;
+ state->strm.zalloc_init = zalloc_init;
state->strm.zfree = zfree;
state->w_size = w_size;
state->w_size = w_size;
state->strm.next_out = NULL;
state->strm.zalloc = zalloc;
+ state->strm.zalloc_init = zalloc_init;
state->strm.zfree = zfree;
if (inflateInit2(&state->strm, -w_size) != Z_OK) {