root/net/inet/loopback.c

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

DEFINITIONS

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

   1 /*
   2  * INET         An implementation of the TCP/IP protocol suite for the LINUX
   3  *              operating system.  INET is implemented using the  BSD Socket
   4  *              interface as the means of communication with the user level.
   5  *
   6  *              Pseudo-driver for the loopback interface.
   7  *
   8  * Version:     @(#)loopback.c  1.0.4   05/25/93
   9  *
  10  * Authors:     Ross Biro, <bir7@leland.Stanford.Edu>
  11  *              Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
  12  *
  13  *              This program is free software; you can redistribute it and/or
  14  *              modify it under the terms of the GNU General Public License
  15  *              as published by the Free Software Foundation; either version
  16  *              2 of the License, or (at your option) any later version.
  17  */
  18 #include <asm/system.h>
  19 #include <asm/segment.h>
  20 #include <asm/io.h>
  21 #include <linux/config.h>
  22 #include <linux/kernel.h>
  23 #include <linux/sched.h>
  24 #include <linux/fs.h>
  25 #include <linux/tty.h>
  26 #include <linux/types.h>
  27 #include <linux/ptrace.h>
  28 #include <linux/string.h>
  29 #include <linux/socket.h>
  30 #include <linux/errno.h>
  31 #include <linux/fcntl.h>
  32 #include <linux/in.h>
  33 #include "inet.h"
  34 #include "dev.h"
  35 #include "eth.h"
  36 #include "ip.h"
  37 #include "protocol.h"
  38 #include "tcp.h"
  39 #include "skbuff.h"
  40 #include "sock.h"
  41 #include "arp.h"
  42 
  43 
  44 static int
  45 loopback_xmit(struct sk_buff *skb, struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
  46 {
  47   int done;
  48 
  49   DPRINTF((DBG_LOOPB, "loopback_xmit(dev=%X, skb=%X)\n", dev, skb));
  50   if (skb == NULL || dev == NULL) return(0);
  51 
  52   cli();
  53   if (dev->tbusy != 0) {
  54         sti();
  55         return(1);
  56   }
  57   dev->tbusy = 1;
  58   sti();
  59 
  60   done = dev_rint((unsigned char *)(skb+1), skb->len, 0, dev);
  61   if (skb->free) kfree_skb(skb, FREE_WRITE);
  62 
  63   while (done != 1) {
  64         done = dev_rint(NULL, 0, 0, dev);
  65   }
  66   dev->tbusy = 0;
  67 
  68 #if 1
  69         __asm__("cmpl $0,_intr_count\n\t"
  70                 "jne 1f\n\t"
  71                 "movl _bh_active,%%eax\n\t"
  72                 "testl _bh_mask,%%eax\n\t"
  73                 "je 1f\n\t"
  74                 "incl _intr_count\n\t"
  75                 "call _do_bottom_half\n\t"
  76                 "decl _intr_count\n"
  77                 "1:"
  78                 :
  79                 :
  80                 : "ax", "dx", "cx");
  81 #endif
  82 
  83   return(0);
  84 }
  85 
  86 
  87 /* Initialize the rest of the LOOPBACK device. */
  88 int
  89 loopback_init(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
  90 {
  91   dev->mtu              = 2000;                 /* MTU                  */
  92   dev->tbusy            = 0;
  93   dev->hard_start_xmit  = loopback_xmit;
  94   dev->open             = NULL;
  95 #if 1
  96   dev->hard_header      = eth_header;
  97   dev->add_arp          = NULL;
  98   dev->hard_header_len  = ETH_HLEN;             /* 14                   */
  99   dev->addr_len         = ETH_ALEN;             /* 6                    */
 100   dev->type             = ARPHRD_ETHER;         /* 0x0001               */
 101   dev->type_trans       = eth_type_trans;
 102   dev->rebuild_header   = eth_rebuild_header;
 103 #else
 104   dev->hard_header_length = 0;
 105   dev->add_arp          = NULL;
 106   dev->addr_len         = 0;
 107   dev->type             = 0;                    /* loopback_type (0)    */
 108   dev->hard_header      = NULL;
 109   dev->type_trans       = NULL;
 110   dev->rebuild_header   = NULL;
 111 #endif
 112   dev->queue_xmit       = dev_queue_xmit;
 113 
 114   /* New-style flags. */
 115   dev->flags            = IFF_LOOPBACK;
 116   dev->family           = AF_INET;
 117   dev->pa_addr          = in_aton("127.0.0.1");
 118   dev->pa_brdaddr       = in_aton("127.255.255.255");
 119   dev->pa_mask          = in_aton("255.0.0.0");
 120   dev->pa_alen          = sizeof(unsigned long);
 121 
 122   return(0);
 123 };

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