- int answer, len;
- __u8 *data;
- struct ppp *ppp = dev2ppp (dev);
- struct tty_struct *tty = ppp2tty (ppp);
-/*
- * just a little sanity check.
- */
- if (skb == NULL) {
- if (ppp->flags & SC_DEBUG)
- printk (KERN_WARNING "ppp_dev_xmit: null packet!\n");
- return 0;
- }
-/*
- * Avoid timing problem should tty hangup while data is queued to be sent
- */
- if (!ppp->inuse) {
- dev_kfree_skb (skb, FREE_WRITE);
- return 0;
- }
-/*
- * Validate the tty interface
- */
- if (tty == NULL) {
- if (ppp->flags & SC_DEBUG)
- printk (KERN_ERR
- "ppp_dev_xmit: %s not connected to a TTY!\n",
- dev->name);
- dev_kfree_skb (skb, FREE_WRITE);
- return 0;
- }
-/*
- * Fetch the pointer to the data
- */
- len = skb->len;
- data = skb_data(skb);
-
- if (data == (__u8 *) 0) {
- if (ppp->flags & SC_DEBUG)
- printk (KERN_CRIT "ppp_dev_xmit: %s Null skb data\n",
- dev->name);
- dev_kfree_skb (skb, FREE_WRITE);
- return 0;
- }
-/*
- * Detect a change in the transfer size
- */
- if (ppp->mtu != ppp2dev (ppp)->mtu) {
- ppp_changedmtu (ppp,
- ppp2dev (ppp)->mtu,
- ppp->mru);
- }
-/*
- * Acquire the lock on the transmission buffer. If the buffer was busy then
- * mark the device as busy.
- * We also require that ppp->tbuf be unlocked, in order to serialize
- * calls to ppp_dev_xmit_frame (which does compression) and the output
- * of frames w.r.t. tty writes from pppd.
- */
- CHECK_BUF_MAGIC(ppp->wbuf);
- if (ppp->tbuf->locked || lock_buffer (ppp->wbuf) != 0) {
- dev->tbusy = 1;
- if (ppp->flags & SC_DEBUG)
- printk(KERN_DEBUG "dev_xmit blocked, t=%d w=%d\n",
- ppp->tbuf->locked, ppp->wbuf->locked);
- return 1;
- }
-/*
- * Look at the protocol in the skb to determine the difference between
- * an IP frame and an IPX frame.
- */
- switch (ntohs (skb->protocol)) {
- case ETH_P_IPX:
- answer = ppp_dev_xmit_other (dev, ppp, data, len, PPP_IPX);
- break;
-
- case ETH_P_IP:
- answer = ppp_dev_xmit_ip (ppp, ppp->wbuf, data, len);
- break;
-
- default: /* All others have no support at this time. */
- dev_kfree_skb (skb, FREE_WRITE);
- return 0;
- }
-/*
- * This is the end of the transmission. Release the buffer if it was sent.
- */
- if (answer == 0) {
- /* packet queued OK */
- dev_kfree_skb (skb, FREE_WRITE);
- ppp->ddinfo.xmit_idle = jiffies;
- } else {
- ppp->wbuf->locked = 0;
- if (answer < 0) {
- /* packet should be dropped */
- dev_kfree_skb (skb, FREE_WRITE);
- answer = 0;
- } else {
- /* packet should be queued for later */
- dev->tbusy = 1;
- }
- }
- return answer;