d0d5edbf936d5d713948ba00f13c283003e1808f
[linux-flexiantxendom0-3.2.10.git] / net / ipv6 / mobile_ip6 / module_mn.c
1 /*
2  *      Mobile IPv6 Mobile Node Module
3  *
4  *      Authors:
5  *      Sami Kivisaari          <skivisaa@cc.hut.fi>
6  *      Antti Tuominen          <ajtuomin@tml.hut.fi>
7  *
8  *      $Id: s.module_mn.c 1.33 03/09/22 16:45:04+03:00 vnuorval@amber.hut.mediapoli.com $
9  *
10  *      This program is free software; you can redistribute it and/or
11  *      modify it under the terms of the GNU General Public License
12  *      as published by the Free Software Foundation; either version
13  *      2 of the License, or (at your option) any later version.
14  */
15
16 #include <linux/config.h>
17 #include <linux/module.h>
18 #include <linux/init.h>
19
20 #ifdef CONFIG_SYSCTL
21 #include <linux/sysctl.h>
22 #endif /* CONFIG_SYSCTL */
23
24 #include <net/mipglue.h>
25 #include <net/ipv6_tunnel.h>
26
27 extern int mipv6_debug;
28 int mipv6_use_auth = 0;
29
30 #if defined(MODULE)
31 // && LINUX_VERSION_CODE > 0
32 MODULE_AUTHOR("MIPL Team");
33 MODULE_DESCRIPTION("Mobile IPv6 Mobile Node");
34 MODULE_LICENSE("GPL");
35 //MODULE_PARM(mipv6_debug, "i");
36 #endif
37
38 #include "config.h"
39
40 #include "mobhdr.h"
41 #include "mn.h"
42 #include "mipv6_icmp.h"
43 #include "prefix.h"
44
45 /* TODO: These will go as soon as we get rid of the last two ioctls */
46 extern int mipv6_ioctl_mn_init(void);
47 extern void mipv6_ioctl_mn_exit(void);
48
49 /**********************************************************************
50  *
51  * MIPv6 Module Init / Cleanup
52  *
53  **********************************************************************/
54
55 #ifdef CONFIG_SYSCTL
56 /* Sysctl table */
57
58 extern int max_rtr_reach_time;
59 extern int eager_cell_switching;
60
61 static int max_reach = 1000;
62 static int min_reach = 1;
63 static int max_one = 1;
64 static int min_zero = 0;
65
66 extern int 
67 mipv6_mdetect_mech_sysctl(ctl_table *, int, struct file *, void *, size_t *);
68
69 extern int 
70 mipv6_router_reach_sysctl(ctl_table *, int, struct file *, void *, size_t *);
71
72
73 ctl_table mipv6_mobility_table[] = {
74         {NET_IPV6_MOBILITY_BU_F_LLADDR, "bu_flag_lladdr",
75          &mip6node_cnf.bu_lladdr, sizeof(int), 0644, NULL,
76          &proc_dointvec_minmax, &sysctl_intvec, 0, &min_zero, &max_one},
77         {NET_IPV6_MOBILITY_BU_F_KEYMGM, "bu_flag_keymgm",
78          &mip6node_cnf.bu_keymgm, sizeof(int), 0644, NULL,
79          &proc_dointvec_minmax, &sysctl_intvec, 0, &min_zero, &max_one},
80         {NET_IPV6_MOBILITY_BU_F_CN_ACK, "bu_flag_cn_ack",
81          &mip6node_cnf.bu_cn_ack, sizeof(int), 0644, NULL,
82          &proc_dointvec_minmax, &sysctl_intvec, 0, &min_zero, &max_one},
83
84         {NET_IPV6_MOBILITY_ROUTER_REACH, "max_router_reachable_time",
85          &max_rtr_reach_time, sizeof(int), 0644, NULL,
86          &proc_dointvec_minmax, &sysctl_intvec, 0, &min_reach, &max_reach},
87
88         {NET_IPV6_MOBILITY_MDETECT_MECHANISM, "eager_cell_switching",
89          &eager_cell_switching, sizeof(int), 0644, NULL,
90          &proc_dointvec_minmax, &sysctl_intvec, 0, &min_zero, &max_one},
91
92         {0}
93 };
94 ctl_table mipv6_table[] = {
95         {NET_IPV6_MOBILITY, "mobility", NULL, 0, 0555, mipv6_mobility_table},
96         {0}
97 };
98
99 static struct ctl_table_header *mipv6_sysctl_header;
100 static struct ctl_table mipv6_net_table[];
101 static struct ctl_table mipv6_root_table[];
102
103 ctl_table mipv6_net_table[] = {
104         {NET_IPV6, "ipv6", NULL, 0, 0555, mipv6_table},
105         {0}
106 };
107
108 ctl_table mipv6_root_table[] = {
109         {CTL_NET, "net", NULL, 0, 0555, mipv6_net_table},
110         {0}
111 };
112 #endif /* CONFIG_SYSCTL */
113
114 /*  Initialize the module  */
115 static int __init mip6_mn_init(void)
116 {
117         int err = 0;
118         extern int mipv6_initialize_pfx_icmpv6(void);
119
120         printk(KERN_INFO "MIPL Mobile IPv6 for Linux Mobile Node %s (%s)\n",
121                MIPLVERSION, MIPV6VERSION);
122         mip6node_cnf.capabilities = CAP_CN | CAP_MN;
123
124 #ifdef CONFIG_IPV6_MOBILITY_DEBUG
125         printk(KERN_INFO "Debug-level: %d\n", mipv6_debug);
126 #endif
127
128 #ifdef CONFIG_SYSCTL
129         mipv6_sysctl_header = register_sysctl_table(mipv6_root_table, 0);
130 #endif
131         if ((err = mipv6_mn_init()) < 0)
132                 goto mn_fail;
133
134         mipv6_mh_mn_init();
135
136         mip6_fn.icmpv6_dhaad_rep_rcv = mipv6_icmpv6_rcv_dhaad_rep;
137         mip6_fn.icmpv6_dhaad_req_rcv = mipv6_icmpv6_no_rcv;
138         mip6_fn.icmpv6_pfxadv_rcv = mipv6_icmpv6_rcv_pfx_adv;
139         mip6_fn.icmpv6_pfxsol_rcv = mipv6_icmpv6_no_rcv;
140         mip6_fn.icmpv6_paramprob_rcv = mipv6_icmpv6_rcv_paramprob;
141
142         mipv6_initialize_pfx_icmpv6();
143
144         if ((err = mipv6_ioctl_mn_init()) < 0)
145                 goto ioctl_fail;
146
147         return 0;
148
149 ioctl_fail:
150         mipv6_shutdown_pfx_icmpv6();
151
152         mip6_fn.icmpv6_dhaad_rep_rcv = NULL;
153         mip6_fn.icmpv6_dhaad_req_rcv = NULL;
154         mip6_fn.icmpv6_pfxadv_rcv = NULL;
155         mip6_fn.icmpv6_pfxsol_rcv = NULL;
156         mip6_fn.icmpv6_paramprob_rcv = NULL;
157
158         mipv6_mh_mn_exit();
159         mipv6_mn_exit();
160 mn_fail:
161 #ifdef CONFIG_SYSCTL
162         unregister_sysctl_table(mipv6_sysctl_header);
163 #endif
164         return err;
165 }
166 module_init(mip6_mn_init);
167
168 #ifdef MODULE
169 /*  Cleanup module  */
170 static void __exit mip6_mn_exit(void)
171 {
172         printk(KERN_INFO "mip6_mn.o exiting.\n");
173         mip6node_cnf.capabilities &= ~(int)CAP_MN;
174
175         mipv6_ioctl_mn_exit();
176         mipv6_shutdown_pfx_icmpv6();
177
178         mip6_fn.icmpv6_dhaad_rep_rcv = NULL;
179         mip6_fn.icmpv6_dhaad_req_rcv = NULL;
180         mip6_fn.icmpv6_pfxadv_rcv = NULL;
181         mip6_fn.icmpv6_pfxsol_rcv = NULL;
182         mip6_fn.icmpv6_paramprob_rcv = NULL;
183
184         mipv6_mn_exit();
185
186 /* common cleanup */
187 #ifdef CONFIG_SYSCTL
188         unregister_sysctl_table(mipv6_sysctl_header);
189 #endif
190 }
191 module_exit(mip6_mn_exit);
192 #endif /* MODULE */