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  *
  11  *      This program is free software; you can redistribute it and/or
  12  *      modify it under the terms of the GNU General Public License
  13  *      as published by the Free Software Foundation; either version
  14  *      2 of the License, or (at your option) any later version.
  15  *
  16  */
  17  
  18 #include <linux/types.h>
  19 #include <linux/kernel.h>
  20 #include <linux/skbuff.h>
  21 #include <linux/netdevice.h>
  22 #include <linux/in.h>
  23 #include <net/datalink.h>
  24 #include <net/sock.h>
  25 #include <net/ip.h>
  26 #include <net/protocol.h>
  27 #include <net/ipip.h>
  28 
  29 /*
  30  * NB. we must include the kernel idenfication string in to install the module.
  31  */
  32  
  33 #if ( defined(CONFIG_NET_IPIP) && defined(CONFIG_IP_FORWARD)) || defined(MODULE)
  34 #ifdef MODULE
  35 #include <linux/module.h>
  36 #include <linux/version.h>
  37 
  38 static char kernel_version[] = UTS_RELEASE;
  39 
  40 #else
  41 #define MOD_INC_USE_COUNT
  42 #define MOD_DEC_USE_COUNT
  43 #endif 
  44 
  45 
  46 /*
  47  *      The driver.
  48  */
  49 
  50 int ipip_rcv(struct sk_buff *skb, struct device *dev, struct options *opt, 
     /* [previous][next][first][last][top][bottom][index][help] */
  51                 unsigned long daddr, unsigned short len, unsigned long saddr,
  52                                    int redo, struct inet_protocol *protocol)
  53 {
  54         /* Don't unlink in the middle of a turnaround */
  55         MOD_INC_USE_COUNT;
  56 #ifdef TUNNEL_DEBUG
  57         printk("ipip_rcv: got a packet!\n");
  58 #endif
  59         if(ip_forward(skb, dev, 0, daddr, 0))
  60                 kfree_skb(skb, FREE_READ);
  61         MOD_DEC_USE_COUNT;
  62         return(0);
  63 }
  64 
  65 #ifdef MODULE
  66 static struct inet_protocol ipip_protocol = {
  67   ipip_rcv,             /* IPIP handler          */
  68   NULL,                 /* Will be UDP fraglist handler */
  69   NULL,                 /* TUNNEL error control    */
  70   0,                    /* next                 */
  71   IPPROTO_IPIP,         /* protocol ID          */
  72   0,                    /* copy                 */
  73   NULL,                 /* data                 */
  74   "IPIP"                /* name                 */
  75 };
  76 
  77 
  78 /*
  79  *      And now the modules code and kernel interface.
  80  */
  81 
  82 int init_module( void) 
     /* [previous][next][first][last][top][bottom][index][help] */
  83 {
  84         inet_add_protocol(&ipip_protocol);
  85         return 0;
  86 }
  87 
  88 void cleanup_module( void) 
     /* [previous][next][first][last][top][bottom][index][help] */
  89 {
  90         if ( inet_del_protocol(&ipip_protocol) < 0 )
  91                 printk("ipip close: can't remove protocol\n");
  92 }
  93 
  94 #endif
  95 #endif

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