root/net/ipv4/ipip.c

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

DEFINITIONS

This source file includes following definitions.
  1. ipip_rcv
  2. init_module
  3. cleanup_module

   1 /*
   2  *      Linux NET3:     IP/IP protocol decoder. 
   3  *
   4  *      Authors:
   5  *              Sam Lantinga (slouken@cs.ucdavis.edu)  02/01/95
   6  *
   7  *      Fixes:
   8  *              Alan Cox        :       Merged and made usable non modular (its so tiny its silly as
   9  *                                      a module taking up 2 pages).
  10  *              Alan Cox        :       Fixed bug with 1.3.18 and IPIP not working (now needs to set skb->h.iph)
  11  *                                      to keep ip_forward happy.
  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  */
  19  
  20 #include <linux/types.h>
  21 #include <linux/kernel.h>
  22 #include <linux/skbuff.h>
  23 #include <linux/netdevice.h>
  24 #include <linux/in.h>
  25 #include <net/datalink.h>
  26 #include <net/sock.h>
  27 #include <net/ip.h>
  28 #include <net/protocol.h>
  29 #include <net/ipip.h>
  30 
  31 /*
  32  * NB. we must include the kernel idenfication string in to install the module.
  33  */
  34  
  35 #if ( defined(CONFIG_NET_IPIP) && defined(CONFIG_IP_FORWARD)) || defined(MODULE)
  36 #ifdef MODULE
  37 #include <linux/module.h>
  38 #include <linux/version.h>
  39 
  40 static char kernel_version[] = UTS_RELEASE;
  41 
  42 #else
  43 #define MOD_INC_USE_COUNT
  44 #define MOD_DEC_USE_COUNT
  45 #endif 
  46 
  47 
  48 /*
  49  *      The driver.
  50  */
  51 
  52 int ipip_rcv(struct sk_buff *skb, struct device *dev, struct options *opt, 
     /* [previous][next][first][last][top][bottom][index][help] */
  53                 unsigned long daddr, unsigned short len, unsigned long saddr,
  54                                    int redo, struct inet_protocol *protocol)
  55 {
  56         /* Don't unlink in the middle of a turnaround */
  57         MOD_INC_USE_COUNT;
  58 #ifdef TUNNEL_DEBUG
  59         printk("ipip_rcv: got a packet!\n");
  60 #endif
  61         skb->h.iph=skb->data;   /* Correct IP header pointer on to new header */
  62         if(ip_forward(skb, dev, 0, daddr, 0))
  63                 kfree_skb(skb, FREE_READ);
  64         MOD_DEC_USE_COUNT;
  65         return(0);
  66 }
  67 
  68 #ifdef MODULE
  69 static struct inet_protocol ipip_protocol = {
  70   ipip_rcv,             /* IPIP handler          */
  71   NULL,                 /* Will be UDP fraglist handler */
  72   NULL,                 /* TUNNEL error control    */
  73   0,                    /* next                 */
  74   IPPROTO_IPIP,         /* protocol ID          */
  75   0,                    /* copy                 */
  76   NULL,                 /* data                 */
  77   "IPIP"                /* name                 */
  78 };
  79 
  80 
  81 /*
  82  *      And now the modules code and kernel interface.
  83  */
  84 
  85 int init_module( void) 
     /* [previous][next][first][last][top][bottom][index][help] */
  86 {
  87         inet_add_protocol(&ipip_protocol);
  88         return 0;
  89 }
  90 
  91 void cleanup_module( void) 
     /* [previous][next][first][last][top][bottom][index][help] */
  92 {
  93         if ( inet_del_protocol(&ipip_protocol) < 0 )
  94                 printk("ipip close: can't remove protocol\n");
  95 }
  96 
  97 #endif
  98 #endif

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