2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * Copyright (C) 1996 Mike Shaver (shaver@zeroknowledge.com)
9 #include <linux/config.h>
11 #include <linux/sysctl.h>
12 #include <linux/spinlock.h>
15 static int min_ipdefmode[1], max_ipdefmode[] = {1};
16 static int min_axdefmode[1], max_axdefmode[] = {1};
17 static int min_backoff[1], max_backoff[] = {2};
18 static int min_conmode[1], max_conmode[] = {2};
19 static int min_window[] = {1}, max_window[] = {7};
20 static int min_ewindow[] = {1}, max_ewindow[] = {63};
21 static int min_t1[] = {1}, max_t1[] = {30 * HZ};
22 static int min_t2[] = {1}, max_t2[] = {20 * HZ};
23 static int min_t3[1], max_t3[] = {3600 * HZ};
24 static int min_idle[1], max_idle[] = {65535 * HZ};
25 static int min_n2[] = {1}, max_n2[] = {31};
26 static int min_paclen[] = {1}, max_paclen[] = {512};
27 static int min_proto[1], max_proto[] = { AX25_PROTO_MAX };
28 static int min_ds_timeout[1], max_ds_timeout[] = {65535 * HZ};
30 static struct ctl_table_header *ax25_table_header;
32 static ctl_table *ax25_table;
33 static int ax25_table_size;
35 static ctl_table ax25_dir_table[] = {
44 static ctl_table ax25_root_table[] = {
49 .child = ax25_dir_table
54 static const ctl_table ax25_param_table[] = {
56 .ctl_name = NET_AX25_IP_DEFAULT_MODE,
57 .procname = "ip_default_mode",
58 .maxlen = sizeof(int),
60 .proc_handler = &proc_dointvec_minmax,
61 .strategy = &sysctl_intvec,
62 .extra1 = &min_ipdefmode,
63 .extra2 = &max_ipdefmode
66 .ctl_name = NET_AX25_DEFAULT_MODE,
67 .procname = "ax25_default_mode",
68 .maxlen = sizeof(int),
70 .proc_handler = &proc_dointvec_minmax,
71 .strategy = &sysctl_intvec,
72 .extra1 = &min_axdefmode,
73 .extra2 = &max_axdefmode
76 .ctl_name = NET_AX25_BACKOFF_TYPE,
77 .procname = "backoff_type",
78 .maxlen = sizeof(int),
80 .proc_handler = &proc_dointvec_minmax,
81 .strategy = &sysctl_intvec,
82 .extra1 = &min_backoff,
83 .extra2 = &max_backoff
86 .ctl_name = NET_AX25_CONNECT_MODE,
87 .procname = "connect_mode",
88 .maxlen = sizeof(int),
90 .proc_handler = &proc_dointvec_minmax,
91 .strategy = &sysctl_intvec,
92 .extra1 = &min_conmode,
93 .extra2 = &max_conmode
96 .ctl_name = NET_AX25_STANDARD_WINDOW,
97 .procname = "standard_window_size",
98 .maxlen = sizeof(int),
100 .proc_handler = &proc_dointvec_minmax,
101 .strategy = &sysctl_intvec,
102 .extra1 = &min_window,
103 .extra2 = &max_window
106 .ctl_name = NET_AX25_EXTENDED_WINDOW,
107 .procname = "extended_window_size",
108 .maxlen = sizeof(int),
110 .proc_handler = &proc_dointvec_minmax,
111 .strategy = &sysctl_intvec,
112 .extra1 = &min_ewindow,
113 .extra2 = &max_ewindow
116 .ctl_name = NET_AX25_T1_TIMEOUT,
117 .procname = "t1_timeout",
118 .maxlen = sizeof(int),
120 .proc_handler = &proc_dointvec_minmax,
121 .strategy = &sysctl_intvec,
126 .ctl_name = NET_AX25_T2_TIMEOUT,
127 .procname = "t2_timeout",
128 .maxlen = sizeof(int),
130 .proc_handler = &proc_dointvec_minmax,
131 .strategy = &sysctl_intvec,
136 .ctl_name = NET_AX25_T3_TIMEOUT,
137 .procname = "t3_timeout",
138 .maxlen = sizeof(int),
140 .proc_handler = &proc_dointvec_minmax,
141 .strategy = &sysctl_intvec,
146 .ctl_name = NET_AX25_IDLE_TIMEOUT,
147 .procname = "idle_timeout",
148 .maxlen = sizeof(int),
150 .proc_handler = &proc_dointvec_minmax,
151 .strategy = &sysctl_intvec,
156 .ctl_name = NET_AX25_N2,
157 .procname = "maximum_retry_count",
158 .maxlen = sizeof(int),
160 .proc_handler = &proc_dointvec_minmax,
161 .strategy = &sysctl_intvec,
166 .ctl_name = NET_AX25_PACLEN,
167 .procname = "maximum_packet_length",
168 .maxlen = sizeof(int),
170 .proc_handler = &proc_dointvec_minmax,
171 .strategy = &sysctl_intvec,
172 .extra1 = &min_paclen,
173 .extra2 = &max_paclen
176 .ctl_name = NET_AX25_PROTOCOL,
177 .procname = "protocol",
178 .maxlen = sizeof(int),
180 .proc_handler = &proc_dointvec_minmax,
181 .strategy = &sysctl_intvec,
182 .extra1 = &min_proto,
186 .ctl_name = NET_AX25_DAMA_SLAVE_TIMEOUT,
187 .procname = "dama_slave_timeout",
188 .maxlen = sizeof(int),
190 .proc_handler = &proc_dointvec_minmax,
191 .strategy = &sysctl_intvec,
192 .extra1 = &min_ds_timeout,
193 .extra2 = &max_ds_timeout
195 { .ctl_name = 0 } /* that's all, folks! */
198 void ax25_register_sysctl(void)
203 spin_lock_bh(&ax25_dev_lock);
204 for (ax25_table_size = sizeof(ctl_table), ax25_dev = ax25_dev_list; ax25_dev != NULL; ax25_dev = ax25_dev->next)
205 ax25_table_size += sizeof(ctl_table);
207 if ((ax25_table = kmalloc(ax25_table_size, GFP_ATOMIC)) == NULL) {
208 spin_unlock_bh(&ax25_dev_lock);
212 memset(ax25_table, 0x00, ax25_table_size);
214 for (n = 0, ax25_dev = ax25_dev_list; ax25_dev != NULL; ax25_dev = ax25_dev->next) {
215 ctl_table *child = kmalloc(sizeof(ax25_param_table), GFP_ATOMIC);
218 kfree(ax25_table[n].child);
220 spin_unlock_bh(&ax25_dev_lock);
223 memcpy(child, ax25_param_table, sizeof(ax25_param_table));
224 ax25_table[n].child = ax25_dev->systable = child;
225 ax25_table[n].ctl_name = n + 1;
226 ax25_table[n].procname = ax25_dev->dev->name;
227 ax25_table[n].mode = 0555;
229 #ifndef CONFIG_AX25_DAMA_SLAVE
231 * We do not wish to have a representation of this parameter
232 * in /proc/sys/ when configured *not* to include the
233 * AX.25 DAMA slave code, do we?
236 child[AX25_VALUES_DS_TIMEOUT].procname = NULL;
239 child[AX25_MAX_VALUES].ctl_name = 0; /* just in case... */
241 for (k = 0; k < AX25_MAX_VALUES; k++)
242 child[k].data = &ax25_dev->values[k];
246 spin_unlock_bh(&ax25_dev_lock);
248 ax25_dir_table[0].child = ax25_table;
250 ax25_table_header = register_sysctl_table(ax25_root_table, 1);
253 void ax25_unregister_sysctl(void)
256 unregister_sysctl_table(ax25_table_header);
258 ax25_dir_table[0].child = NULL;
259 for (p = ax25_table; p->ctl_name; p++)