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 "timer.h"
  37 #include "ip.h"
  38 #include "protocol.h"
  39 #include "tcp.h"
  40 #include "skbuff.h"
  41 #include "sock.h"
  42 #include "arp.h"
  43 
  44 
  45 static int
  46 loopback_xmit(struct sk_buff *skb, struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
  47 {
  48   int done;
  49 
  50   DPRINTF((DBG_LOOPB, "loopback_xmit(dev=%X, skb=%X)\n", dev, skb));
  51   if (skb == NULL || dev == NULL) return(0);
  52 
  53   cli();
  54   if (dev->tbusy != 0) {
  55         sti();
  56         return(1);
  57   }
  58   dev->tbusy = 1;
  59   sti();
  60 
  61   done = dev_rint((unsigned char *)(skb+1), skb->len, 0, dev);
  62   if (skb->free) kfree_skb(skb, FREE_WRITE);
  63 
  64   while (done != 1) {
  65         done = dev_rint(NULL, 0, 0, dev);
  66   }
  67   dev->tbusy = 0;
  68 
  69   return(0);
  70 }
  71 
  72 
  73 /* Initialize the rest of the LOOPBACK device. */
  74 int
  75 loopback_init(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
  76 {
  77   dev->mtu              = 2000;                 /* MTU                  */
  78   dev->tbusy            = 0;
  79   dev->hard_start_xmit  = loopback_xmit;
  80   dev->open             = NULL;
  81 #if 1
  82   dev->hard_header      = eth_header;
  83   dev->add_arp          = NULL;
  84   dev->hard_header_len  = ETH_HLEN;             /* 14                   */
  85   dev->addr_len         = ETH_ALEN;             /* 6                    */
  86   dev->type             = ARPHRD_ETHER;         /* 0x0001               */
  87   dev->type_trans       = eth_type_trans;
  88   dev->rebuild_header   = eth_rebuild_header;
  89 #else
  90   dev->hard_header_length = 0;
  91   dev->add_arp          = NULL;
  92   dev->addr_len         = 0;
  93   dev->type             = 0;                    /* loopback_type (0)    */
  94   dev->hard_header      = NULL;
  95   dev->type_trans       = NULL;
  96   dev->rebuild_header   = NULL;
  97 #endif
  98   dev->queue_xmit       = dev_queue_xmit;
  99 
 100   /* New-style flags. */
 101   dev->flags            = IFF_LOOPBACK;
 102   dev->family           = AF_INET;
 103   dev->pa_addr          = in_aton("127.0.0.1");
 104   dev->pa_brdaddr       = in_aton("127.255.255.255");
 105   dev->pa_mask          = in_aton("255.0.0.0");
 106   dev->pa_alen          = sizeof(unsigned long);
 107 
 108   return(0);
 109 };

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