- error = 0;
- if (odp->transmit) {
- if (ppp->sc_xc_state != NULL)
- (*ppp->sc_xcomp->comp_free)(ppp->sc_xc_state);
-
- ppp->sc_xcomp = *cp;
- ppp->sc_xc_state = (*cp)->comp_alloc(ccp_option, nb);
-
- if (ppp->sc_xc_state == NULL) {
- if (ppp->flags & SC_DEBUG)
- printk("ppp%ld: comp_alloc failed\n",
- ppp2dev (ppp)->base_addr);
- error = -ENOBUFS;
- }
- ppp->flags &= ~SC_COMP_RUN;
- } else {
- if (ppp->sc_rc_state != NULL)
- (*ppp->sc_rcomp->decomp_free)(ppp->sc_rc_state);
- ppp->sc_rcomp = *cp;
- ppp->sc_rc_state = (*cp)->decomp_alloc(ccp_option, nb);
- if (ppp->sc_rc_state == NULL) {
- if (ppp->flags & SC_DEBUG)
- printk("ppp%ld: decomp_alloc failed\n",
- ppp2dev (ppp)->base_addr);
- error = ENOBUFS;
- }
- ppp->flags &= ~SC_DECOMP_RUN;
- }
- return (error);
- }
-
- if (ppp->flags & SC_DEBUG)
- printk (KERN_DEBUG "ppp%ld: no compressor for [%x %x %x], %x\n",
- ppp2dev (ppp)->base_addr, ccp_option[0], ccp_option[1],
- ccp_option[2], nb);
- return (-EINVAL); /* no handler found */
-}
-#endif /* PPP_COMPRESS */
-
-/*
- * Process the IOCTL event for the tty device.
- */
-
-static int
-ppp_tty_ioctl (struct tty_struct *tty, struct file *file, unsigned int param2,
- unsigned long param3)
-{
- struct ppp *ppp = tty2ppp (tty);
- register int temp_i = 0;
- int error;
-/*
- * Verify the status of the PPP device.
- */
- if (!ppp || ppp->magic != PPP_MAGIC) {
- if (ppp->flags & SC_DEBUG)
- printk (KERN_ERR
- "ppp_tty_ioctl: can't find PPP block from tty!\n");
- return -EBADF;
- }
- CHECK_PPP (-ENXIO);
-/*
- * The user must have an euid of root to do these requests.
- */
- if (!suser ())
- return -EPERM;
-/*
- * Set the MRU value
- */
- switch (param2) {
- case PPPIOCSMRU:
- error = verify_area (VERIFY_READ, (void *) param3,
- sizeof (temp_i));
- if (error == 0) {
- temp_i = (int) get_fs_long (param3);
- if (ppp->flags & SC_DEBUG)
- printk (KERN_INFO
- "ppp_tty_ioctl: set mru to %x\n", temp_i);
-
- if (ppp->mru != temp_i)
- ppp_changedmtu (ppp, ppp2dev (ppp)->mtu, temp_i);
- }
- break;
-/*
- * Fetch the flags
- */
- case PPPIOCGFLAGS:
- error = verify_area (VERIFY_WRITE, (void *) param3,
- sizeof (temp_i));
- if (error == 0) {
- temp_i = (ppp->flags & SC_MASK);
-#ifndef CHECK_CHARACTERS /* Don't generate errors if we don't check chars. */
- temp_i |= SC_RCV_B7_1 | SC_RCV_B7_0 |
- SC_RCV_ODDP | SC_RCV_EVNP;
-#endif
- put_fs_long ((long) temp_i, param3);
- if (ppp->flags & SC_DEBUG)
- printk (KERN_DEBUG
- "ppp_tty_ioctl: get flags: addr %lx flags "
- "%x\n", param3, temp_i);
- }
- break;
-/*
- * Set the flags for the various options
- */
- case PPPIOCSFLAGS:
- error = verify_area (VERIFY_READ, (void *) param3,
- sizeof (temp_i));
- if (error == 0) {
- temp_i = (int) get_fs_long (param3) & SC_MASK;
- temp_i |= (ppp->flags & ~SC_MASK);
-#ifdef PPP_COMPRESS
- if ((ppp->flags & SC_CCP_OPEN) &&
- (temp_i & SC_CCP_OPEN) == 0)
- ppp_ccp_closed (ppp);
-#else
- temp_i &= ~SC_CCP_OPEN;
-#endif
- if ((ppp->flags | temp_i) & SC_DEBUG)
- printk (KERN_INFO
- "ppp_tty_ioctl: set flags to %x\n", temp_i);
- ppp->flags = temp_i;
- }
- break;
-/*
- * Set the compression mode
- */
-#ifdef PPP_COMPRESS
- case PPPIOCSCOMPRESS:
- error = ppp_set_compression (ppp,
- (struct ppp_option_data *) param3);
- break;
-#endif
-/*
- * Retrieve the transmit async map
- */
- case PPPIOCGASYNCMAP:
- error = verify_area (VERIFY_WRITE, (void *) param3,
- sizeof (temp_i));
- if (error == 0) {
- put_fs_long (ppp->xmit_async_map[0], param3);
- if (ppp->flags & SC_DEBUG)
- printk (KERN_INFO
- "ppp_tty_ioctl: get asyncmap: addr "
- "%lx asyncmap %lx\n",
- param3, ppp->xmit_async_map[0]);
- }
- break;
-/*
- * Set the transmit async map
- */
- case PPPIOCSASYNCMAP:
- error = verify_area (VERIFY_READ, (void *) param3,
- sizeof (temp_i));
- if (error == 0) {
- ppp->xmit_async_map[0] = get_fs_long (param3);
- if (ppp->flags & SC_DEBUG)
- printk (KERN_INFO
- "ppp_tty_ioctl: set xmit asyncmap %lx\n",
- ppp->xmit_async_map[0]);
- }
- break;
-/*
- * Set the receive async map
- */
- case PPPIOCSRASYNCMAP:
- error = verify_area (VERIFY_READ, (void *) param3,
- sizeof (temp_i));
- if (error == 0) {
- ppp->recv_async_map = get_fs_long (param3);
- if (ppp->flags & SC_DEBUG)
- printk (KERN_INFO
- "ppp_tty_ioctl: set rcv asyncmap %lx\n",
- ppp->recv_async_map);
- }
- break;
-/*
- * Obtain the unit number for this device.
- */
- case PPPIOCGUNIT:
- error = verify_area (VERIFY_WRITE, (void *) param3,
- sizeof (temp_i));
- if (error == 0) {
- put_fs_long (ppp2dev (ppp)->base_addr, param3);
- if (ppp->flags & SC_DEBUG)
- printk (KERN_INFO
- "ppp_tty_ioctl: get unit: %ld",
- ppp2dev (ppp)->base_addr);