root/net/tcp/loopback.c

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

DEFINITIONS

This source file includes following definitions.
  1. loopback_xmit
  2. loopback_init

   1 /* loopback.c contains the loopback device functions. */
   2 /*
   3     Copyright (C) 1992  Ross Biro
   4 
   5     This program is free software; you can redistribute it and/or modify
   6     it under the terms of the GNU General Public License as published by
   7     the Free Software Foundation; either version 2, or (at your option)
   8     any later version.
   9 
  10     This program is distributed in the hope that it will be useful,
  11     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13     GNU General Public License for more details.
  14 
  15     You should have received a copy of the GNU General Public License
  16     along with this program; if not, write to the Free Software
  17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
  18 
  19     The Author may be reached as bir7@leland.stanford.edu or
  20     C/O Department of Mathematics; Stanford University; Stanford, CA 94305
  21 */
  22 /* $Id: loopback.c,v 0.8.4.8 1993/01/23 18:00:11 bir7 Exp $ */
  23 /* $Log: loopback.c,v $
  24  * Revision 0.8.4.8  1993/01/23  18:00:11  bir7
  25  * Fixed problems introduced by merge.
  26  *
  27  * Revision 0.8.4.7  1993/01/22  23:21:38  bir7
  28  * Merged with 99 pl4
  29  *
  30  * Revision 0.8.4.6  1993/01/22  22:58:08  bir7
  31  * Changed so transmitting takes place in bottom half of interrupt routine.
  32  *
  33  * Revision 0.8.4.5  1992/12/12  19:25:04  bir7
  34  * Cleaned up Log messages.
  35  *
  36  * Revision 0.8.4.4  1992/12/05  21:35:53  bir7
  37  * changed dev->init to return an int.
  38  *
  39  * Revision 0.8.4.3  1992/11/18  15:38:03  bir7
  40  * Fixed bug in start_xmit.
  41  *
  42  * Revision 0.8.4.2  1992/11/10  10:38:48  bir7
  43  * Change free_s to kfree_s and accidently changed free_skb to kfree_skb.
  44  *
  45  * Revision 0.8.4.1  1992/11/10  00:17:18  bir7
  46  * version change only.
  47  *
  48  * Revision 0.8.3.2  1992/11/10  00:14:47  bir7
  49  * Changed malloc to kmalloc and added Id and Log
  50  * */
  51 
  52 #include <linux/config.h>
  53 #include <linux/kernel.h>
  54 #include <linux/sched.h>
  55 #include <linux/fs.h>
  56 #include <linux/tty.h>
  57 #include <linux/types.h>
  58 #include <linux/ptrace.h>
  59 #include <linux/string.h>
  60 #include <asm/system.h>
  61 #include <asm/segment.h>
  62 #include <asm/io.h>
  63 #include <errno.h>
  64 #include <linux/fcntl.h>
  65 #include <netinet/in.h>
  66 
  67 #include "dev.h"
  68 #include "eth.h"
  69 #include "timer.h"
  70 #include "ip.h"
  71 #include "tcp.h"
  72 #include "sock.h"
  73 #include "arp.h"
  74 
  75 #ifdef PRINTK
  76 #undef PRINTK
  77 #endif
  78 
  79 #ifdef LOOPBACK_DEBUG
  80 #define PRINTK(x) printk x
  81 #else
  82 #define PRINTK(x) /**/
  83 #endif
  84 
  85 static int
  86 loopback_xmit(struct sk_buff *skb, struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
  87 {
  88   int done;
  89   if (!skb || !dev) return 0;
  90   PRINTK (("loopback_xmit (dev = %X)\n", dev));
  91   cli();
  92   if (dev->tbusy != 0)
  93     {
  94        sti();
  95        return (1);
  96     }
  97   dev->tbusy = 1;
  98   sti();
  99 
 100   done = dev_rint ((unsigned char *)(skb+1), skb->len, 0, dev);
 101 
 102   if (skb->free)
 103     kfree_skb (skb, FREE_WRITE);
 104 
 105   while (done != 1)
 106          {
 107            done = dev_rint (NULL, 0, 0, dev);
 108          }
 109 
 110   dev->tbusy = 0;
 111 
 112   return (0);
 113 }
 114 
 115 int
 116 loopback_init(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 117 {
 118    printk ("Loopback device init\n");
 119   /* initialize the rest of the device structure. */
 120   dev->mtu = 2000; /* mtu */
 121   dev->tbusy = 0;
 122   dev->hard_start_xmit = loopback_xmit;
 123   dev->open = NULL;
 124   dev->hard_header = eth_hard_header;
 125   dev->add_arp = NULL;
 126   dev->hard_header_len = sizeof (struct enet_header);
 127   dev->addr_len = ETHER_ADDR_LEN;
 128   dev->type = ETHER_TYPE;
 129   dev->queue_xmit = dev_queue_xmit;
 130   dev->rebuild_header = eth_rebuild_header;
 131   dev->type_trans = eth_type_trans;
 132   dev->loopback = 1;
 133   return (0);
 134 }

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