OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [uclinux/] [uClinux-2.0.x/] [net/] [ipv4/] [ipip.c] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
/*
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
 *              Alan Cox        :       More fixes for 1.3.21, and firewall fix. Maybe this will work soon 8).
13
 *              Kai Schulte     :       Fixed #defines for IP_FIREWALL->FIREWALL
14
 *
15
 *      This program is free software; you can redistribute it and/or
16
 *      modify it under the terms of the GNU General Public License
17
 *      as published by the Free Software Foundation; either version
18
 *      2 of the License, or (at your option) any later version.
19
 *
20
 */
21
 
22
#include <linux/module.h>
23
 
24
#include <linux/types.h>
25
#include <linux/sched.h>
26
#include <linux/kernel.h>
27
#include <linux/skbuff.h>
28
#include <linux/netdevice.h>
29
#include <linux/in.h>
30
#include <linux/tcp.h>
31
#include <linux/udp.h>
32
#include <linux/firewall.h>
33
 
34
#include <net/datalink.h>
35
#include <net/sock.h>
36
#include <net/ip.h>
37
#include <net/icmp.h>
38
#include <net/protocol.h>
39
#include <net/ipip.h>
40
 
41
/*
42
 *      The IPIP protocol driver.
43
 *
44
 *      On entry here
45
 *              skb->data is the original IP header
46
 *              skb->ip_hdr points to the initial IP header.
47
 *              skb->h.raw points at the new header.
48
 */
49
 
50
int ipip_rcv(struct sk_buff *skb, struct device *dev, struct options *opt,
51
                __u32 daddr, unsigned short len, __u32 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
        /*
60
         *      Discard the original IP header
61
         */
62
 
63
        skb->mac.raw = skb->data;
64
        skb_pull(skb, ((struct iphdr *)skb->data)->ihl<<2);
65
 
66
        /*
67
         *      Adjust pointers
68
         */
69
 
70
        skb->h.iph=(struct iphdr *)skb->data;
71
        skb->ip_hdr=(struct iphdr *)skb->data;
72
        memset(skb->proto_priv, 0, sizeof(struct options));
73
 
74
        /*
75
         *      If you want to add LZ compressed IP or things like that here,
76
         *      and in drivers/net/tunnel.c are the places to add.
77
         */
78
 
79
        skb->protocol = htons(ETH_P_IP);
80
        skb->ip_summed = 0;
81
        netif_rx(skb);
82
        MOD_DEC_USE_COUNT;
83
        return(0);
84
}
85
 
86
#ifdef MODULE
87
 
88
static struct inet_protocol ipip_protocol = {
89
  ipip_rcv,             /* IPIP handler          */
90
#if 0
91
  NULL,                 /* Will be UDP fraglist handler */
92
#endif
93
  NULL,                 /* TUNNEL error control    */
94
  0,                    /* next                 */
95
  IPPROTO_IPIP,         /* protocol ID          */
96
  0,                    /* copy                 */
97
  NULL,                 /* data                 */
98
  "IPIP"                /* name                 */
99
};
100
 
101
 
102
/*
103
 *      And now the modules code and kernel interface.
104
 */
105
 
106
int init_module( void)
107
{
108
        inet_add_protocol(&ipip_protocol);
109
        return 0;
110
}
111
 
112
void cleanup_module( void)
113
{
114
        if ( inet_del_protocol(&ipip_protocol) < 0 )
115
                printk(KERN_INFO "ipip close: can't remove protocol\n");
116
}
117
 
118
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.