root/drivers/net/slip.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. sl_alloc
  2. sl_free
  3. sl_changedmtu
  4. sl_lock
  5. sl_unlock
  6. sl_bump
  7. sl_encaps
  8. slip_write_wakeup
  9. sl_xmit
  10. sl_header
  11. sl_rebuild_header
  12. sl_open
  13. sl_close
  14. slip_receive_room
  15. slip_receive_buf
  16. slip_open
  17. slip_close
  18. sl_get_stats
  19. slip_esc
  20. slip_unesc
  21. slip_esc6
  22. slip_unesc6
  23. sl_set_mac_address
  24. sl_set_dev_mac_address
  25. slip_ioctl
  26. sl_open_dev
  27. slip_init_ctrl_dev
  28. slip_init
  29. init_module
  30. cleanup_module

   1 /*
   2  * slip.c       This module implements the SLIP protocol for kernel-based
   3  *              devices like TTY.  It interfaces between a raw TTY, and the
   4  *              kernel's INET protocol layers.
   5  *
   6  * Version:     @(#)slip.c      0.8.3   12/24/94
   7  *
   8  * Authors:     Laurence Culhane, <loz@holmes.demon.co.uk>
   9  *              Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
  10  *
  11  * Fixes:
  12  *              Alan Cox        :       Sanity checks and avoid tx overruns.
  13  *                                      Has a new sl->mtu field.
  14  *              Alan Cox        :       Found cause of overrun. ifconfig sl0 mtu upwards.
  15  *                                      Driver now spots this and grows/shrinks its buffers(hack!).
  16  *                                      Memory leak if you run out of memory setting up a slip driver fixed.
  17  *              Matt Dillon     :       Printable slip (borrowed from NET2E)
  18  *      Pauline Middelink       :       Slip driver fixes.
  19  *              Alan Cox        :       Honours the old SL_COMPRESSED flag
  20  *              Alan Cox        :       KISS AX.25 and AXUI IP support
  21  *              Michael Riepe   :       Automatic CSLIP recognition added
  22  *              Charles Hedrick :       CSLIP header length problem fix.
  23  *              Alan Cox        :       Corrected non-IP cases of the above.
  24  *              Alan Cox        :       Now uses hardware type as per FvK.
  25  *              Alan Cox        :       Default to 192.168.0.0 (RFC 1597)
  26  *              A.N.Kuznetsov   :       dev_tint() recursion fix.
  27  *      Dmitry Gorodchanin      :       SLIP memory leaks
  28  *      Dmitry Gorodchanin      :       Code cleanup. Reduce tty driver
  29  *                                      buffering from 4096 to 256 bytes.
  30  *                                      Improving SLIP response time.
  31  *                                      CONFIG_SLIP_MODE_SLIP6.
  32  *                                      ifconfig sl? up & down now works correctly.
  33  *                                      Modularization.
  34  *              Alan Cox        :       Oops - fix AX.25 buffer lengths
  35  *      Dmitry Gorodchanin      :       Even more cleanups. Preserve CSLIP
  36  *                                      statistics. Include CSLIP code only
  37  *                                      if it really needed.
  38  *              Alan Cox        :       Free slhc buffers in the right place.
  39  *              Alan Cox        :       Allow for digipeated IP over AX.25
  40  *              Matti Aarnio    :       Dynamic SLIP devices, with ideas taken
  41  *                                      from Jim Freeman's <jfree@caldera.com>
  42  *                                      dynamic PPP devices.  We do NOT kfree()
  43  *                                      device entries, just reg./unreg. them
  44  *                                      as they are needed.  We kfree() them
  45  *                                      at module cleanup.
  46  *                                      With MODULE-loading ``insmod'', user can
  47  *                                      issue parameter:   slip_maxdev=1024
  48  *                                      (Or how much he/she wants.. Default is 256)
  49  *
  50  */
  51 
  52 #define SL_CHECK_TRANSMIT
  53 #include <linux/config.h>
  54 #include <linux/module.h>
  55 
  56 /* Undef this, if you don't need 6bit encapsulation code in the driver */
  57 #define CONFIG_SLIP_MODE_SLIP6
  58 
  59 #include <asm/system.h>
  60 #include <asm/segment.h>
  61 #include <asm/bitops.h>
  62 #include <linux/string.h>
  63 #include <linux/mm.h>
  64 #include <linux/interrupt.h>
  65 #include <linux/in.h>
  66 #include <linux/tty.h>
  67 #include <linux/errno.h>
  68 #include <linux/netdevice.h>
  69 #ifdef CONFIG_AX25
  70 #include <linux/timer.h>
  71 #include <net/ax25.h>
  72 #endif
  73 #include <linux/etherdevice.h>
  74 #include <linux/skbuff.h>
  75 #include <linux/if_arp.h>
  76 #include "slip.h"
  77 #ifdef CONFIG_INET
  78 #include <linux/ip.h>
  79 #include <linux/tcp.h>
  80 #include "slhc.h"
  81 #endif
  82 
  83 #ifdef MODULE
  84 #define SLIP_VERSION    "0.8.3-NET3.019-NEWTTY-MODULAR"
  85 #else
  86 #define SLIP_VERSION    "0.8.3-NET3.019-NEWTTY"
  87 #endif
  88 
  89 
  90 typedef struct slip_ctrl {
  91         char            if_name[8];     /* "sl0\0" .. "sl99999\0"       */
  92         struct slip     ctrl;           /* SLIP things                  */
  93         struct device   dev;            /* the device                   */
  94 } slip_ctrl_t;
  95 static slip_ctrl_t      **slip_ctrls = NULL;
  96 int slip_maxdev = SL_NRUNIT;            /* Can be overridden with insmod! */
  97 
  98 static struct tty_ldisc sl_ldisc;
  99 
 100 static int slip_esc(unsigned char *p, unsigned char *d, int len);
 101 static void slip_unesc(struct slip *sl, unsigned char c);
 102 #ifdef CONFIG_SLIP_MODE_SLIP6
 103 static int slip_esc6(unsigned char *p, unsigned char *d, int len);
 104 static void slip_unesc6(struct slip *sl, unsigned char c);
 105 #endif
 106 
 107 
 108 /* Find a free SLIP channel, and link in this `tty' line. */
 109 static inline struct slip *
 110 sl_alloc(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 111 {
 112         slip_ctrl_t *slp;
 113         int i;
 114 
 115         if (slip_ctrls == NULL) return NULL;    /* Master array missing ! */
 116 
 117         for (i = 0; i < slip_maxdev; i++) {
 118           slp = slip_ctrls[i];
 119           /* Not allocated ? */
 120           if (slp == NULL)
 121             break;
 122           /* Not in use ? */
 123           if (!set_bit(SLF_INUSE, &slp->ctrl.flags))
 124             break;
 125         }
 126         /* SLP is set.. */
 127 
 128         /* Sorry, too many, all slots in use */
 129         if (i >= slip_maxdev) return NULL;
 130 
 131         /* If no channels are available, allocate one */
 132         if (!slp &&
 133             (slip_ctrls[i] = (slip_ctrl_t *)kmalloc(sizeof(slip_ctrl_t),
 134                                                     GFP_KERNEL)) != NULL) {
 135           slp = slip_ctrls[i];
 136           memset(slp, 0, sizeof(slip_ctrl_t));
 137 
 138           /* Initialize channel control data */
 139           set_bit(SLF_INUSE, &slp->ctrl.flags);
 140           slp->ctrl.tty         = NULL;
 141           sprintf(slp->if_name, "sl%d", i);
 142           slp->dev.name         = slp->if_name;
 143           slp->dev.base_addr    = i;
 144           slp->dev.priv         = (void*)&(slp->ctrl);
 145           slp->dev.next         = NULL;
 146           slp->dev.init         = slip_init;
 147 /* printk(KERN_INFO "slip: kmalloc()ed SLIP control node for line %s\n",
 148    slp->if_name); */
 149         }
 150         if (slp != NULL) {
 151 
 152           /* register device so that it can be ifconfig'ed       */
 153           /* slip_init() will be called as a side-effect         */
 154           /* SIDE-EFFECT WARNING: slip_init() CLEARS slp->ctrl ! */
 155 
 156           if (register_netdev(&(slp->dev)) == 0) {
 157             /* (Re-)Set the INUSE bit.   Very Important! */
 158             set_bit(SLF_INUSE, &slp->ctrl.flags);
 159             slp->ctrl.dev = &(slp->dev);
 160             slp->dev.priv = (void*)&(slp->ctrl);
 161 
 162 /* printk(KERN_INFO "slip: linked in netdev %s for active use\n",
 163    slp->if_name); */
 164 
 165             return (&(slp->ctrl));
 166 
 167           } else {
 168             clear_bit(SLF_INUSE,&(slp->ctrl.flags));
 169             printk("sl_alloc() - register_netdev() failure.\n");
 170           }
 171         }
 172 
 173         return NULL;
 174 }
 175 
 176 
 177 /* Free a SLIP channel. */
 178 static inline void
 179 sl_free(struct slip *sl)
     /* [previous][next][first][last][top][bottom][index][help] */
 180 {
 181         /* Free all SLIP frame buffers. */
 182         if (sl->rbuff)  {
 183                 kfree(sl->rbuff);
 184         }
 185         sl->rbuff = NULL;
 186         if (sl->xbuff)  {
 187                 kfree(sl->xbuff);
 188         }
 189         sl->xbuff = NULL;
 190 #ifdef SL_INCLUDE_CSLIP
 191         /* Save CSLIP statistics */
 192         if (sl->slcomp)  {
 193                 sl->rx_compressed += sl->slcomp->sls_i_compressed;
 194                 sl->rx_dropped    += sl->slcomp->sls_i_tossed;
 195                 sl->tx_compressed += sl->slcomp->sls_o_compressed;
 196                 sl->tx_misses     += sl->slcomp->sls_o_misses;
 197         }
 198         if (sl->cbuff)  {
 199                 kfree(sl->cbuff);
 200         }
 201         sl->cbuff = NULL;
 202         if(sl->slcomp)
 203                 slhc_free(sl->slcomp);
 204         sl->slcomp = NULL;
 205 #endif
 206 
 207         if (!clear_bit(SLF_INUSE, &sl->flags)) {
 208                 printk("%s: sl_free for already free unit.\n", sl->dev->name);
 209         }
 210 }
 211 
 212 /* MTU has been changed by the IP layer. Unfortunately we are not told
 213    about this, but we spot it ourselves and fix things up. We could be
 214    in an upcall from the tty driver, or in an ip packet queue. */
 215 
 216 static void sl_changedmtu(struct slip *sl)
     /* [previous][next][first][last][top][bottom][index][help] */
 217 {
 218         struct device *dev = sl->dev;
 219         unsigned char *xbuff, *rbuff, *oxbuff, *orbuff;
 220 #ifdef SL_INCLUDE_CSLIP
 221         unsigned char *cbuff, *ocbuff;
 222 #endif
 223         int len;
 224         unsigned long flags;
 225 
 226         len = dev->mtu * 2;
 227 /*
 228  * allow for arrival of larger UDP packets, even if we say not to
 229  * also fixes a bug in which SunOS sends 512-byte packets even with
 230  * an MSS of 128
 231  */
 232         if (len < 576 * 2)  {
 233                 len = 576 * 2;
 234         }
 235 
 236         xbuff = (unsigned char *) kmalloc (len + 4, GFP_ATOMIC);
 237         rbuff = (unsigned char *) kmalloc (len + 4, GFP_ATOMIC);
 238 #ifdef SL_INCLUDE_CSLIP
 239         cbuff = (unsigned char *) kmalloc (len + 4, GFP_ATOMIC);
 240 #endif
 241 
 242 #ifdef SL_INCLUDE_CSLIP
 243         if (xbuff == NULL || rbuff == NULL || cbuff == NULL)  {
 244 #else
 245         if (xbuff == NULL || rbuff == NULL)  {
 246 #endif
 247                 printk("%s: unable to grow slip buffers, MTU change cancelled.\n",
 248                        sl->dev->name);
 249                 dev->mtu = sl->mtu;
 250                 if (xbuff != NULL)  {
 251                         kfree(xbuff);
 252                 }
 253                 if (rbuff != NULL)  {
 254                         kfree(rbuff);
 255                 }
 256 #ifdef SL_INCLUDE_CSLIP
 257                 if (cbuff != NULL)  {
 258                         kfree(cbuff);
 259                 }
 260 #endif
 261                 return;
 262         }
 263 
 264         save_flags(flags); cli();
 265 
 266         oxbuff    = sl->xbuff;
 267         sl->xbuff = xbuff;
 268         orbuff    = sl->rbuff;
 269         sl->rbuff = rbuff;
 270 #ifdef SL_INCLUDE_CSLIP
 271         ocbuff    = sl->cbuff;
 272         sl->cbuff = cbuff;
 273 #endif
 274         if (sl->xleft)  {
 275                 if (sl->xleft <= len)  {
 276                         memcpy(sl->xbuff, sl->xhead, sl->xleft);
 277                 } else  {
 278                         sl->xleft = 0;
 279                         sl->tx_dropped++;
 280                 }
 281         }
 282         sl->xhead = sl->xbuff;
 283 
 284         if (sl->rcount)  {
 285                 if (sl->rcount <= len) {
 286                         memcpy(sl->rbuff, orbuff, sl->rcount);
 287                 } else  {
 288                         sl->rcount = 0;
 289                         sl->rx_over_errors++;
 290                         set_bit(SLF_ERROR, &sl->flags);
 291                 }
 292         }
 293 #ifdef CONFIG_AX25
 294         sl->mtu      = dev->mtu + 73;
 295 #else
 296         sl->mtu      = dev->mtu;
 297 #endif
 298         sl->buffsize = len;
 299 
 300         restore_flags(flags);
 301 
 302         if (oxbuff != NULL)   {
 303                 kfree(oxbuff);
 304         }
 305         if (orbuff != NULL)    {
 306                 kfree(orbuff);
 307         }
 308 #ifdef SL_INCLUDE_CSLIP
 309         if (ocbuff != NULL)  {
 310                 kfree(ocbuff);
 311         }
 312 #endif
 313 }
 314 
 315 
 316 /* Set the "sending" flag.  This must be atomic, hence the ASM. */
 317 static inline void
 318 sl_lock(struct slip *sl)
     /* [previous][next][first][last][top][bottom][index][help] */
 319 {
 320         if (set_bit(0, (void *) &sl->dev->tbusy))  {
 321                 printk("%s: trying to lock already locked device!\n", sl->dev->name);
 322         }
 323 }
 324 
 325 
 326 /* Clear the "sending" flag.  This must be atomic, hence the ASM. */
 327 static inline void
 328 sl_unlock(struct slip *sl)
     /* [previous][next][first][last][top][bottom][index][help] */
 329 {
 330         if (!clear_bit(0, (void *)&sl->dev->tbusy))  {
 331                 printk("%s: trying to unlock already unlocked device!\n", sl->dev->name);
 332         }
 333 }
 334 
 335 /* Send one completely decapsulated IP datagram to the IP layer. */
 336 static void
 337 sl_bump(struct slip *sl)
     /* [previous][next][first][last][top][bottom][index][help] */
 338 {
 339         struct sk_buff *skb;
 340         int count;
 341 
 342         count = sl->rcount;
 343 #ifdef SL_INCLUDE_CSLIP
 344         if (sl->mode & (SL_MODE_ADAPTIVE | SL_MODE_CSLIP)) {
 345                 unsigned char c;
 346                 if ((c = sl->rbuff[0]) & SL_TYPE_COMPRESSED_TCP) {
 347                         /* ignore compressed packets when CSLIP is off */
 348                         if (!(sl->mode & SL_MODE_CSLIP)) {
 349                                 printk("%s: compressed packet ignored\n", sl->dev->name);
 350                                 return;
 351                         }
 352                         /* make sure we've reserved enough space for uncompress to use */
 353                         if (count + 80 > sl->buffsize) {
 354                                 sl->rx_over_errors++;
 355                                 return;
 356                         }
 357                         count = slhc_uncompress(sl->slcomp, sl->rbuff, count);
 358                         if (count <= 0) {
 359                                 return;
 360                         }
 361                 } else if (c >= SL_TYPE_UNCOMPRESSED_TCP) {
 362                         if (!(sl->mode & SL_MODE_CSLIP)) {
 363                                 /* turn on header compression */
 364                                 sl->mode |= SL_MODE_CSLIP;
 365                                 sl->mode &= ~SL_MODE_ADAPTIVE;
 366                                 printk("%s: header compression turned on\n", sl->dev->name);
 367                         }
 368                         sl->rbuff[0] &= 0x4f;
 369                         if (slhc_remember(sl->slcomp, sl->rbuff, count) <= 0) {
 370                                 return;
 371                         }
 372                 }
 373         }
 374 #endif  /* SL_INCLUDE_CSLIP */
 375 
 376         skb = dev_alloc_skb(count);
 377         if (skb == NULL)  {
 378                 printk("%s: memory squeeze, dropping packet.\n", sl->dev->name);
 379                 sl->rx_dropped++;
 380                 return;
 381         }
 382         skb->dev = sl->dev;
 383         memcpy(skb_put(skb,count), sl->rbuff, count);
 384         skb->mac.raw=skb->data;
 385         if(sl->mode & SL_MODE_AX25)
 386                 skb->protocol=htons(ETH_P_AX25);
 387         else
 388                 skb->protocol=htons(ETH_P_IP);
 389         netif_rx(skb);
 390         sl->rx_packets++;
 391 }
 392 
 393 /* Encapsulate one IP datagram and stuff into a TTY queue. */
 394 static void
 395 sl_encaps(struct slip *sl, unsigned char *icp, int len)
     /* [previous][next][first][last][top][bottom][index][help] */
 396 {
 397         unsigned char *p;
 398         int actual, count;
 399 
 400 
 401 #ifdef CONFIG_AX25
 402         if (sl->mtu != sl->dev->mtu + 73) {     /* Someone has been ifconfigging */
 403 #else
 404         if (sl->mtu != sl->dev->mtu) {  /* Someone has been ifconfigging */
 405 #endif
 406                 sl_changedmtu(sl);
 407         }
 408 
 409         if (len > sl->mtu) {            /* Sigh, shouldn't occur BUT ... */
 410                 len = sl->mtu;
 411                 printk ("%s: truncating oversized transmit packet!\n", sl->dev->name);
 412                 sl->tx_dropped++;
 413                 sl_unlock(sl);
 414                 return;
 415         }
 416 
 417         p = icp;
 418 #ifdef SL_INCLUDE_CSLIP
 419         if (sl->mode & SL_MODE_CSLIP)  {
 420                 len = slhc_compress(sl->slcomp, p, len, sl->cbuff, &p, 1);
 421         }
 422 #endif
 423 #ifdef CONFIG_SLIP_MODE_SLIP6
 424         if(sl->mode & SL_MODE_SLIP6)
 425                 count = slip_esc6(p, (unsigned char *) sl->xbuff, len);
 426         else
 427 #endif
 428                 count = slip_esc(p, (unsigned char *) sl->xbuff, len);
 429 
 430         /* Order of next two lines is *very* important.
 431          * When we are sending a little amount of data,
 432          * the transfer may be completed inside driver.write()
 433          * routine, because it's running with interrupts enabled.
 434          * In this case we *never* got WRITE_WAKEUP event,
 435          * if we did not request it before write operation.
 436          *       14 Oct 1994  Dmitry Gorodchanin.
 437          */
 438         sl->tty->flags |= (1 << TTY_DO_WRITE_WAKEUP);
 439         actual = sl->tty->driver.write(sl->tty, 0, sl->xbuff, count);
 440 #ifdef SL_CHECK_TRANSMIT
 441         sl->dev->trans_start = jiffies;
 442 #endif
 443         sl->xleft = count - actual;
 444         sl->xhead = sl->xbuff + actual;
 445 }
 446 
 447 /*
 448  * Called by the driver when there's room for more data.  If we have
 449  * more packets to send, we send them here.
 450  */
 451 static void slip_write_wakeup(struct tty_struct *tty)
     /* [previous][next][first][last][top][bottom][index][help] */
 452 {
 453         int actual;
 454         struct slip *sl = (struct slip *) tty->disc_data;
 455 
 456         /* First make sure we're connected. */
 457         if (!sl || sl->magic != SLIP_MAGIC || !sl->dev->start) {
 458                 return;
 459         }
 460 
 461         if (sl->xleft <= 0)  {
 462                 /* Now serial buffer is almost free & we can start
 463                  * transmission of another packet */
 464                 sl->tx_packets++;
 465                 tty->flags &= ~(1 << TTY_DO_WRITE_WAKEUP);
 466                 sl_unlock(sl);
 467                 mark_bh(NET_BH);
 468                 return;
 469         }
 470 
 471         actual = tty->driver.write(tty, 0, sl->xhead, sl->xleft);
 472         sl->xleft -= actual;
 473         sl->xhead += actual;
 474 }
 475 
 476 /* Encapsulate an IP datagram and kick it into a TTY queue. */
 477 static int
 478 sl_xmit(struct sk_buff *skb, struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 479 {
 480         struct slip *sl = (struct slip*)(dev->priv);
 481 
 482         if (!dev->start)  {
 483                 printk("%s: xmit call when iface is down\n", dev->name);
 484                 return 1;
 485         }
 486         /*
 487          * If we are busy already- too bad.  We ought to be able
 488          * to queue things at this point, to allow for a little
 489          * frame buffer.  Oh well...
 490          * -----------------------------------------------------
 491          * I hate queues in SLIP driver. May be it's efficient,
 492          * but for me latency is more important. ;)
 493          * So, no queues !
 494          *        14 Oct 1994  Dmitry Gorodchanin.
 495          */
 496         if (dev->tbusy) {
 497                 /* May be we must check transmitter timeout here ?
 498                  *      14 Oct 1994 Dmitry Gorodchanin.
 499                  */
 500 #ifdef SL_CHECK_TRANSMIT
 501                 if (jiffies - dev->trans_start  < 20 * HZ)  {
 502                         /* 20 sec timeout not reached */
 503                         return 1;
 504                 }
 505                 printk("%s: transmit timed out, %s?\n", dev->name,
 506                        (sl->tty->driver.chars_in_buffer(sl->tty) || sl->xleft) ?
 507                        "bad line quality" : "driver error");
 508                 sl->xleft = 0;
 509                 sl->tty->flags &= ~(1 << TTY_DO_WRITE_WAKEUP);
 510                 sl_unlock(sl);
 511 #else
 512                 return 1;
 513 #endif
 514         }
 515 
 516         /* We were not busy, so we are now... :-) */
 517         if (skb != NULL) {
 518                 sl_lock(sl);
 519                 sl_encaps(sl, skb->data, skb->len);
 520                 dev_kfree_skb(skb, FREE_WRITE);
 521         }
 522         return 0;
 523 }
 524 
 525 
 526 /* Return the frame type ID.  This is normally IP but maybe be AX.25. */
 527 
 528 /* Fill in the MAC-level header. Not used by SLIP. */
 529 static int
 530 sl_header(struct sk_buff *skb, struct device *dev, unsigned short type,
     /* [previous][next][first][last][top][bottom][index][help] */
 531           void *daddr, void *saddr, unsigned len)
 532 {
 533 #ifdef CONFIG_AX25
 534 #ifdef CONFIG_INET
 535         struct slip *sl = (struct slip*)(dev->priv);
 536 
 537         if (sl->mode & SL_MODE_AX25 && type != htons(ETH_P_AX25))  {
 538                 return ax25_encapsulate(skb, dev, type, daddr, saddr, len);
 539         }
 540 #endif
 541 #endif
 542         return 0;
 543 }
 544 
 545 
 546 /* Rebuild the MAC-level header.  Not used by SLIP. */
 547 static int
 548 sl_rebuild_header(void *buff, struct device *dev, unsigned long raddr,
     /* [previous][next][first][last][top][bottom][index][help] */
 549                   struct sk_buff *skb)
 550 {
 551 #ifdef CONFIG_AX25
 552 #ifdef CONFIG_INET
 553         struct slip *sl = (struct slip*)(dev->priv);
 554 
 555         if (sl->mode & SL_MODE_AX25) {
 556                 return ax25_rebuild_header(buff, dev, raddr, skb);
 557         }
 558 #endif
 559 #endif
 560         return 0;
 561 }
 562 
 563 
 564 /* Open the low-level part of the SLIP channel. Easy! */
 565 static int
 566 sl_open(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 567 {
 568         struct slip *sl = (struct slip*)(dev->priv);
 569         unsigned long len;
 570 
 571         if (sl->tty == NULL) {
 572                 return -ENODEV;
 573         }
 574 
 575         /*
 576          * Allocate the SLIP frame buffers:
 577          *
 578          * rbuff        Receive buffer.
 579          * xbuff        Transmit buffer.
 580          * cbuff        Temporary compression buffer.
 581          */
 582         len = dev->mtu * 2;
 583         /*
 584          * allow for arrival of larger UDP packets, even if we say not to
 585          * also fixes a bug in which SunOS sends 512-byte packets even with
 586          * an MSS of 128
 587          */
 588         if (len < 576 * 2)  {
 589                 len = 576 * 2;
 590         }
 591         sl->rbuff = (unsigned char *) kmalloc(len + 4, GFP_KERNEL);
 592         if (sl->rbuff == NULL)   {
 593                 goto norbuff;
 594         }
 595         sl->xbuff = (unsigned char *) kmalloc(len + 4, GFP_KERNEL);
 596         if (sl->xbuff == NULL)   {
 597                 goto noxbuff;
 598         }
 599 #ifdef SL_INCLUDE_CSLIP
 600         sl->cbuff = (unsigned char *) kmalloc(len + 4, GFP_KERNEL);
 601         if (sl->cbuff == NULL)   {
 602                 goto nocbuff;
 603         }
 604         sl->slcomp = slhc_init(16, 16);
 605         if (sl->slcomp == NULL)  {
 606                 goto noslcomp;
 607         }
 608 #endif
 609 
 610 #ifdef CONFIG_AX25
 611         sl->mtu      = dev->mtu + 73;
 612 #else
 613         sl->mtu      = dev->mtu;
 614 #endif
 615         sl->buffsize = len;
 616         sl->rcount   = 0;
 617         sl->xleft    = 0;
 618 #ifdef CONFIG_SLIP_MODE_SLIP6
 619         sl->xdata    = 0;
 620         sl->xbits    = 0;
 621 #endif
 622         sl->flags   &= (1 << SLF_INUSE);      /* Clear ESCAPE & ERROR flags */
 623 
 624         /* Needed because address '0' is special */
 625         if (dev->pa_addr == 0)  {
 626                 dev->pa_addr=ntohl(0xC0A80001);
 627         }
 628         dev->tbusy  = 0;
 629 /*      dev->flags |= IFF_UP; */
 630         dev->start  = 1;
 631 
 632         return 0;
 633 
 634         /* Cleanup */
 635 #ifdef SL_INCLUDE_CSLIP
 636 noslcomp:
 637         kfree(sl->cbuff);
 638 nocbuff:
 639 #endif
 640         kfree(sl->xbuff);
 641 noxbuff:
 642         kfree(sl->rbuff);
 643 norbuff:
 644         return -ENOMEM;
 645 }
 646 
 647 
 648 /* Close the low-level part of the SLIP channel. Easy! */
 649 static int
 650 sl_close(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 651 {
 652         struct slip *sl = (struct slip*)(dev->priv);
 653 
 654         if (sl->tty == NULL) {
 655                 return -EBUSY;
 656         }
 657         sl->tty->flags &= ~(1 << TTY_DO_WRITE_WAKEUP);
 658         dev->tbusy = 1;
 659         dev->start = 0;
 660         
 661 /*      dev->flags &= ~IFF_UP; */
 662 
 663         return 0;
 664 }
 665 
 666 static int
 667 slip_receive_room(struct tty_struct *tty)
     /* [previous][next][first][last][top][bottom][index][help] */
 668 {
 669         return 65536;  /* We can handle an infinite amount of data. :-) */
 670 }
 671 
 672 /*
 673  * Handle the 'receiver data ready' interrupt.
 674  * This function is called by the 'tty_io' module in the kernel when
 675  * a block of SLIP data has been received, which can now be decapsulated
 676  * and sent on to some IP layer for further processing.
 677  */
 678 static void
 679 slip_receive_buf(struct tty_struct *tty, const unsigned char *cp, char *fp, int count)
     /* [previous][next][first][last][top][bottom][index][help] */
 680 {
 681         struct slip *sl = (struct slip *) tty->disc_data;
 682 
 683         if (!sl || sl->magic != SLIP_MAGIC || !sl->dev->start)
 684                 return;
 685 
 686         /*
 687          * Argh! mtu change time! - costs us the packet part received
 688          * at the change
 689          */
 690 #ifdef CONFIG_AX25
 691         if (sl->mtu != sl->dev->mtu + 73)  {
 692 #else
 693         if (sl->mtu != sl->dev->mtu)  {
 694 #endif
 695                 sl_changedmtu(sl);
 696         }
 697 
 698         /* Read the characters out of the buffer */
 699         while (count--) {
 700                 if (fp && *fp++) {
 701                         if (!set_bit(SLF_ERROR, &sl->flags))  {
 702                                 sl->rx_errors++;
 703                         }
 704                         cp++;
 705                         continue;
 706                 }
 707 #ifdef CONFIG_SLIP_MODE_SLIP6
 708                 if (sl->mode & SL_MODE_SLIP6)
 709                         slip_unesc6(sl, *cp++);
 710                 else
 711 #endif
 712                         slip_unesc(sl, *cp++);
 713         }
 714 }
 715 
 716 /*
 717  * Open the high-level part of the SLIP channel.
 718  * This function is called by the TTY module when the
 719  * SLIP line discipline is called for.  Because we are
 720  * sure the tty line exists, we only have to link it to
 721  * a free SLIP channel...
 722  */
 723 static int
 724 slip_open(struct tty_struct *tty)
     /* [previous][next][first][last][top][bottom][index][help] */
 725 {
 726         struct slip *sl = (struct slip *) tty->disc_data;
 727         int err;
 728 
 729         /* First make sure we're not already connected. */
 730         if (sl && sl->magic == SLIP_MAGIC) {
 731                 return -EEXIST;
 732         }
 733 
 734         /* OK.  Find a free SLIP channel to use. */
 735         if ((sl = sl_alloc()) == NULL) {
 736                 return -ENFILE;
 737         }
 738 
 739         sl->tty = tty;
 740         tty->disc_data = sl;
 741         if (tty->driver.flush_buffer)  {
 742                 tty->driver.flush_buffer(tty);
 743         }
 744         if (tty->ldisc.flush_buffer)  {
 745                 tty->ldisc.flush_buffer(tty);
 746         }
 747 
 748         /* Restore default settings */
 749         sl->mode      = SL_MODE_DEFAULT;
 750         sl->dev->type = ARPHRD_SLIP + sl->mode;
 751 #ifdef CONFIG_AX25      
 752         if (sl->dev->type == 260) {             /* KISS */
 753                 sl->dev->type = ARPHRD_AX25;
 754         }
 755 #endif  
 756         /* Perform the low-level SLIP initialization. */
 757         if ((err = sl_open(sl->dev)))  {
 758                 return err;
 759         }
 760         
 761         MOD_INC_USE_COUNT;
 762 
 763         /* Done.  We have linked the TTY line to a channel. */
 764         return sl->dev->base_addr;
 765 }
 766 
 767 
 768 /*
 769  * Close down a SLIP channel.
 770  * This means flushing out any pending queues, and then restoring the
 771  * TTY line discipline to what it was before it got hooked to SLIP
 772  * (which usually is TTY again).
 773  */
 774 static void
 775 slip_close(struct tty_struct *tty)
     /* [previous][next][first][last][top][bottom][index][help] */
 776 {
 777         struct slip *sl = (struct slip *) tty->disc_data;
 778 
 779         /* First make sure we're connected. */
 780         if (!sl || sl->magic != SLIP_MAGIC) {
 781                 return;
 782         }
 783 
 784         (void) dev_close(sl->dev);
 785         
 786         tty->disc_data = 0;
 787         sl->tty = NULL;
 788         sl_free(sl);
 789         unregister_netdev(sl->dev);
 790         MOD_DEC_USE_COUNT;
 791 }
 792 
 793 
 794 static struct enet_statistics *
 795 sl_get_stats(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 796 {
 797         static struct enet_statistics stats;
 798         struct slip *sl = (struct slip*)(dev->priv);
 799 #ifdef SL_INCLUDE_CSLIP
 800         struct slcompress *comp;
 801 #endif
 802 
 803         memset(&stats, 0, sizeof(struct enet_statistics));
 804 
 805         stats.rx_packets     = sl->rx_packets;
 806         stats.tx_packets     = sl->tx_packets;
 807         stats.rx_dropped     = sl->rx_dropped;
 808         stats.tx_dropped     = sl->tx_dropped;
 809         stats.tx_errors      = sl->tx_errors;
 810         stats.rx_errors      = sl->rx_errors;
 811         stats.rx_over_errors = sl->rx_over_errors;
 812 #ifdef SL_INCLUDE_CSLIP
 813         stats.rx_fifo_errors = sl->rx_compressed;
 814         stats.tx_fifo_errors = sl->tx_compressed;
 815         stats.collisions     = sl->tx_misses;
 816         comp = sl->slcomp;
 817         if (comp) {
 818                 stats.rx_fifo_errors += comp->sls_i_compressed;
 819                 stats.rx_dropped     += comp->sls_i_tossed;
 820                 stats.tx_fifo_errors += comp->sls_o_compressed;
 821                 stats.collisions     += comp->sls_o_misses;
 822         }
 823 #endif /* CONFIG_INET */
 824         return (&stats);
 825 }
 826 
 827 
 828  /************************************************************************
 829   *                     STANDARD SLIP ENCAPSULATION                      *
 830   ************************************************************************/
 831 
 832 int
 833 slip_esc(unsigned char *s, unsigned char *d, int len)
     /* [previous][next][first][last][top][bottom][index][help] */
 834 {
 835         unsigned char *ptr = d;
 836         unsigned char c;
 837 
 838         /*
 839          * Send an initial END character to flush out any
 840          * data that may have accumulated in the receiver
 841          * due to line noise.
 842          */
 843 
 844         *ptr++ = END;
 845 
 846         /*
 847          * For each byte in the packet, send the appropriate
 848          * character sequence, according to the SLIP protocol.
 849          */
 850 
 851         while (len-- > 0) {
 852                 switch(c = *s++) {
 853                  case END:
 854                         *ptr++ = ESC;
 855                         *ptr++ = ESC_END;
 856                         break;
 857                  case ESC:
 858                         *ptr++ = ESC;
 859                         *ptr++ = ESC_ESC;
 860                         break;
 861                  default:
 862                         *ptr++ = c;
 863                         break;
 864                 }
 865         }
 866         *ptr++ = END;
 867         return (ptr - d);
 868 }
 869 
 870 static void
 871 slip_unesc(struct slip *sl, unsigned char s)
     /* [previous][next][first][last][top][bottom][index][help] */
 872 {
 873 
 874         switch(s) {
 875          case END:
 876                 if (!clear_bit(SLF_ERROR, &sl->flags) && (sl->rcount > 2))  {
 877                         sl_bump(sl);
 878                 }
 879                 clear_bit(SLF_ESCAPE, &sl->flags);
 880                 sl->rcount = 0;
 881                 return;
 882 
 883          case ESC:
 884                 set_bit(SLF_ESCAPE, &sl->flags);
 885                 return;
 886          case ESC_ESC:
 887                 if (clear_bit(SLF_ESCAPE, &sl->flags))  {
 888                         s = ESC;
 889                 }
 890                 break;
 891          case ESC_END:
 892                 if (clear_bit(SLF_ESCAPE, &sl->flags))  {
 893                         s = END;
 894                 }
 895                 break;
 896         }
 897         if (!test_bit(SLF_ERROR, &sl->flags))  {
 898                 if (sl->rcount < sl->buffsize)  {
 899                         sl->rbuff[sl->rcount++] = s;
 900                         return;
 901                 }
 902                 sl->rx_over_errors++;
 903                 set_bit(SLF_ERROR, &sl->flags);
 904         }
 905 }
 906 
 907 
 908 #ifdef CONFIG_SLIP_MODE_SLIP6
 909 /************************************************************************
 910  *                       6 BIT SLIP ENCAPSULATION                       *
 911  ************************************************************************/
 912 
 913 int
 914 slip_esc6(unsigned char *s, unsigned char *d, int len)
     /* [previous][next][first][last][top][bottom][index][help] */
 915 {
 916         unsigned char *ptr = d;
 917         unsigned char c;
 918         int i;
 919         unsigned short v = 0;
 920         short bits = 0;
 921 
 922         /*
 923          * Send an initial END character to flush out any
 924          * data that may have accumulated in the receiver
 925          * due to line noise.
 926          */
 927 
 928         *ptr++ = 0x70;
 929 
 930         /*
 931          * Encode the packet into printable ascii characters
 932          */
 933 
 934         for (i = 0; i < len; ++i) {
 935                 v = (v << 8) | s[i];
 936                 bits += 8;
 937                 while (bits >= 6) {
 938                         bits -= 6;
 939                         c = 0x30 + ((v >> bits) & 0x3F);
 940                         *ptr++ = c;
 941                 }
 942         }
 943         if (bits) {
 944                 c = 0x30 + ((v << (6 - bits)) & 0x3F);
 945                 *ptr++ = c;
 946         }
 947         *ptr++ = 0x70;
 948         return ptr - d;
 949 }
 950 
 951 void
 952 slip_unesc6(struct slip *sl, unsigned char s)
     /* [previous][next][first][last][top][bottom][index][help] */
 953 {
 954         unsigned char c;
 955 
 956         if (s == 0x70) {
 957                 if (!clear_bit(SLF_ERROR, &sl->flags) && (sl->rcount > 2))  {
 958                         sl_bump(sl);
 959                 }
 960                 sl->rcount = 0;
 961                 sl->xbits = 0;
 962                 sl->xdata = 0;
 963         } else if (s >= 0x30 && s < 0x70) {
 964                 sl->xdata = (sl->xdata << 6) | ((s - 0x30) & 0x3F);
 965                 sl->xbits += 6;
 966                 if (sl->xbits >= 8) {
 967                         sl->xbits -= 8;
 968                         c = (unsigned char)(sl->xdata >> sl->xbits);
 969                         if (!test_bit(SLF_ERROR, &sl->flags))  {
 970                                 if (sl->rcount < sl->buffsize)  {
 971                                         sl->rbuff[sl->rcount++] = c;
 972                                         return;
 973                                 }
 974                                 sl->rx_over_errors++;
 975                                 set_bit(SLF_ERROR, &sl->flags);
 976                         }
 977                 }
 978         }
 979 }
 980 #endif /* CONFIG_SLIP_MODE_SLIP6 */
 981 
 982 #ifdef CONFIG_AX25
 983 int
 984 sl_set_mac_address(struct device *dev, void *addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 985 {
 986         int err;
 987 
 988         err = verify_area(VERIFY_READ, addr, AX25_ADDR_LEN);
 989         if (err)  {
 990                 return err;
 991         }
 992 
 993         memcpy_fromfs(dev->dev_addr, addr, AX25_ADDR_LEN);      /* addr is an AX.25 shifted ASCII mac address */
 994 
 995         return 0;
 996 }
 997 
 998 static int
 999 sl_set_dev_mac_address(struct device *dev, void *addr)
     /* [previous][next][first][last][top][bottom][index][help] */
1000 {
1001         memcpy(dev->dev_addr, addr, AX25_ADDR_LEN);
1002         return 0;
1003 }
1004 #endif /* CONFIG_AX25 */
1005 
1006 
1007 /* Perform I/O control on an active SLIP channel. */
1008 static int
1009 slip_ioctl(struct tty_struct *tty, void *file, int cmd, void *arg)
     /* [previous][next][first][last][top][bottom][index][help] */
1010 {
1011         struct slip *sl = (struct slip *) tty->disc_data;
1012         int err;
1013         unsigned int tmp;
1014 
1015         /* First make sure we're connected. */
1016         if (!sl || sl->magic != SLIP_MAGIC) {
1017                 return -EINVAL;
1018         }
1019 
1020         switch(cmd) {
1021          case SIOCGIFNAME:
1022                 err = verify_area(VERIFY_WRITE, arg, strlen(sl->dev->name) + 1);
1023                 if (err)  {
1024                         return -err;
1025                 }
1026                 memcpy_tofs(arg, sl->dev->name, strlen(sl->dev->name) + 1);
1027                 return 0;
1028 
1029         case SIOCGIFENCAP:
1030                 err = verify_area(VERIFY_WRITE, arg, sizeof(int));
1031                 if (err)  {
1032                         return -err;
1033                 }
1034                 put_user(sl->mode, (int *)arg);
1035                 return 0;
1036 
1037         case SIOCSIFENCAP:
1038                 err = verify_area(VERIFY_READ, arg, sizeof(int));
1039                 if (err)  {
1040                         return -err;
1041                 }
1042                 tmp = get_user((int *)arg);
1043 #ifndef SL_INCLUDE_CSLIP
1044                 if (tmp & (SL_MODE_CSLIP|SL_MODE_ADAPTIVE))  {
1045                         return -EINVAL;
1046                 }
1047 #else
1048                 if ((tmp & (SL_MODE_ADAPTIVE | SL_MODE_CSLIP)) ==
1049                     (SL_MODE_ADAPTIVE | SL_MODE_CSLIP))  {
1050                         /* return -EINVAL; */
1051                         tmp &= ~SL_MODE_ADAPTIVE;
1052                 }
1053 #endif
1054 #ifndef CONFIG_SLIP_MODE_SLIP6
1055                 if (tmp & SL_MODE_SLIP6)  {
1056                         return -EINVAL;
1057                 }
1058 #endif
1059 #ifndef CONFIG_AX25
1060                 if (tmp & SL_MODE_AX25) {
1061                         return -EINVAL;
1062                 }
1063 #else
1064                 if (tmp & SL_MODE_AX25) {
1065                         sl->dev->addr_len=AX25_ADDR_LEN;          /* sizeof an AX.25 addr */
1066                         sl->dev->hard_header_len=AX25_KISS_HEADER_LEN + AX25_MAX_HEADER_LEN + 3;
1067                 } else  {
1068                         sl->dev->addr_len=0;    /* No mac addr in slip mode */
1069                         sl->dev->hard_header_len=0;
1070                 }
1071 #endif
1072                 sl->mode = tmp;
1073                 sl->dev->type = ARPHRD_SLIP+sl->mode;
1074 #ifdef CONFIG_AX25              
1075                 if (sl->dev->type == 260)  {
1076                         sl->dev->type = ARPHRD_AX25;
1077                 }
1078 #endif          
1079                 return 0;
1080 
1081          case SIOCSIFHWADDR:
1082 #ifdef CONFIG_AX25
1083                 return sl_set_mac_address(sl->dev, arg);
1084 #else
1085                 return -EINVAL;
1086 #endif
1087 
1088         /* Allow stty to read, but not set, the serial port */
1089         case TCGETS:
1090         case TCGETA:
1091                 return n_tty_ioctl(tty, (struct file *) file, cmd, (unsigned long) arg);
1092 
1093         default:
1094                 return -ENOIOCTLCMD;
1095         }
1096 }
1097 
1098 static int sl_open_dev(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
1099 {
1100         struct slip *sl = (struct slip*)(dev->priv);
1101         if(sl->tty==NULL)
1102                 return -ENODEV;
1103         return 0;
1104 }
1105 
1106 /* Initialize SLIP control device -- register SLIP line discipline */
1107 #ifdef MODULE
1108 static int slip_init_ctrl_dev(void)
     /* [previous][next][first][last][top][bottom][index][help] */
1109 #else   /* !MODULE */
1110 int
1111 slip_init_ctrl_dev(struct device *dummy)
1112 #endif  /* !MODULE */
1113 {
1114         int status;
1115 
1116         if (slip_maxdev < 4) slip_maxdev = 4; /* Sanity */
1117 
1118         printk("SLIP: version %s (dynamic channels, max=%d)"
1119 #ifdef CONFIG_SLIP_MODE_SLIP6
1120                " (6 bit encapsulation enabled)"
1121 #endif
1122                "\n",
1123                SLIP_VERSION, slip_maxdev );
1124 #if defined(SL_INCLUDE_CSLIP) && !defined(MODULE)
1125         printk("CSLIP: code copyright 1989 Regents of the University of California\n");
1126 #endif
1127 #ifdef CONFIG_AX25
1128         printk("AX25: KISS encapsulation enabled\n");
1129 #endif
1130 
1131         slip_ctrls = (slip_ctrl_t **) kmalloc(sizeof(void*)*slip_maxdev, GFP_KERNEL);
1132         if (slip_ctrls == NULL) {
1133           printk("SLIP: Can't allocate slip_ctrls[] array!  Uaargh! (-> No SLIP available)\n");
1134           return -ENOMEM;
1135         }
1136         
1137         /* Clear the pointer array, we allocate devices when we need them */
1138         memset(slip_ctrls, 0, sizeof(void*)*slip_maxdev); /* Pointers */
1139 
1140         /* Fill in our line protocol discipline, and register it */
1141         memset(&sl_ldisc, 0, sizeof(sl_ldisc));
1142         sl_ldisc.magic  = TTY_LDISC_MAGIC;
1143         sl_ldisc.flags  = 0;
1144         sl_ldisc.open   = slip_open;
1145         sl_ldisc.close  = slip_close;
1146         sl_ldisc.read   = NULL;
1147         sl_ldisc.write  = NULL;
1148         sl_ldisc.ioctl  = (int (*)(struct tty_struct *, struct file *,
1149                                    unsigned int, unsigned long)) slip_ioctl;
1150         sl_ldisc.select = NULL;
1151         sl_ldisc.receive_buf = slip_receive_buf;
1152         sl_ldisc.receive_room = slip_receive_room;
1153         sl_ldisc.write_wakeup = slip_write_wakeup;
1154         if ((status = tty_register_ldisc(N_SLIP, &sl_ldisc)) != 0)  {
1155           printk("SLIP: can't register line discipline (err = %d)\n", status);
1156         }
1157 
1158 
1159 #ifdef MODULE
1160         return status;
1161 #else
1162         /* Return "not found", so that dev_init() will unlink
1163          * the placeholder device entry for us.
1164          */
1165         return ENODEV;
1166 #endif
1167       }
1168 
1169 
1170 /* Initialize the SLIP driver.  Called by DDI. */
1171 int
1172 slip_init(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
1173 {
1174         struct slip *sl = (struct slip*)(dev->priv);
1175         int i;
1176 #ifdef CONFIG_AX25
1177         static char ax25_bcast[AX25_ADDR_LEN] =
1178                 {'Q'<<1,'S'<<1,'T'<<1,' '<<1,' '<<1,' '<<1,'0'<<1};
1179         static char ax25_test[AX25_ADDR_LEN] =
1180                 {'L'<<1,'I'<<1,'N'<<1,'U'<<1,'X'<<1,' '<<1,'1'<<1};
1181 #endif
1182 
1183         if (sl == NULL)         /* Allocation failed ?? */
1184           return -ENODEV;
1185 
1186         /* Set up the "SLIP Control Block". (And clear statistics) */
1187         
1188         memset(sl, 0, sizeof (struct slip));
1189         sl->magic  = SLIP_MAGIC;
1190         sl->dev    = dev;
1191         
1192         /* Finish setting up the DEVICE info. */
1193         dev->mtu                = SL_MTU;
1194         dev->hard_start_xmit    = sl_xmit;
1195         dev->open               = sl_open_dev;
1196         dev->stop               = sl_close;
1197         dev->hard_header        = sl_header;
1198         dev->get_stats          = sl_get_stats;
1199 #ifdef HAVE_SET_MAC_ADDR
1200 #ifdef CONFIG_AX25
1201         dev->set_mac_address    = sl_set_dev_mac_address;
1202 #endif
1203 #endif
1204         dev->hard_header_len    = 0;
1205         dev->addr_len           = 0;
1206         dev->type               = ARPHRD_SLIP + SL_MODE_DEFAULT;
1207 #ifdef CONFIG_AX25
1208         if (sl->dev->type == 260) {
1209                 sl->dev->type = ARPHRD_AX25;
1210         }
1211         memcpy(dev->broadcast, ax25_bcast, AX25_ADDR_LEN);      /* Only activated in AX.25 mode */
1212         memcpy(dev->dev_addr, ax25_test, AX25_ADDR_LEN);        /*    ""      ""       ""    "" */
1213 #endif
1214         dev->rebuild_header     = sl_rebuild_header;
1215 
1216         for (i = 0; i < DEV_NUMBUFFS; i++)  {
1217                 skb_queue_head_init(&dev->buffs[i]);
1218         }
1219 
1220         /* New-style flags. */
1221         dev->flags              = 0;
1222         dev->family             = AF_INET;
1223         dev->pa_addr            = 0;
1224         dev->pa_brdaddr         = 0;
1225         dev->pa_mask            = 0;
1226         dev->pa_alen            = 4;
1227 
1228         return 0;
1229 }
1230 #ifdef MODULE
1231 
1232 int
1233 init_module(void)
     /* [previous][next][first][last][top][bottom][index][help] */
1234 {
1235         return slip_init_ctrl_dev();
1236 }
1237 
1238 void
1239 cleanup_module(void)
     /* [previous][next][first][last][top][bottom][index][help] */
1240 {
1241         int i;
1242 
1243         if (slip_ctrls != NULL) {
1244           for (i = 0; i < slip_maxdev; i++)  {
1245             if (slip_ctrls[i] != NULL) {
1246               unregister_netdev(&(slip_ctrls[i]->dev));
1247               kfree(slip_ctrls[i]);
1248             }
1249           }
1250           kfree(slip_ctrls);
1251           slip_ctrls = NULL;
1252         }
1253         if ((i = tty_register_ldisc(N_SLIP, NULL)))  {
1254           printk("SLIP: can't unregister line discipline (err = %d)\n", i);
1255         }
1256 }
1257 #endif /* MODULE */

/* [previous][next][first][last][top][bottom][index][help] */