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)
10 #include <linux/sysctl.h>
11 #include <linux/spinlock.h>
14 static int min_ipdefmode[1], max_ipdefmode[] = {1};
15 static int min_axdefmode[1], max_axdefmode[] = {1};
16 static int min_backoff[1], max_backoff[] = {2};
17 static int min_conmode[1], max_conmode[] = {2};
18 static int min_window[] = {1}, max_window[] = {7};
19 static int min_ewindow[] = {1}, max_ewindow[] = {63};
20 static int min_t1[] = {1}, max_t1[] = {30000};
21 static int min_t2[] = {1}, max_t2[] = {20000};
22 static int min_t3[1], max_t3[] = {3600000};
23 static int min_idle[1], max_idle[] = {65535000};
24 static int min_n2[] = {1}, max_n2[] = {31};
25 static int min_paclen[] = {1}, max_paclen[] = {512};
26 static int min_proto[1], max_proto[] = { AX25_PROTO_MAX };
27 #ifdef CONFIG_AX25_DAMA_SLAVE
28 static int min_ds_timeout[1], max_ds_timeout[] = {65535000};
31 static struct ctl_table_header *ax25_table_header;
33 static ctl_table *ax25_table;
34 static int ax25_table_size;
36 static struct ctl_path ax25_path[] = {
37 { .procname = "net", .ctl_name = CTL_NET, },
38 { .procname = "ax25", .ctl_name = NET_AX25, },
42 static const ctl_table ax25_param_table[] = {
44 .ctl_name = NET_AX25_IP_DEFAULT_MODE,
45 .procname = "ip_default_mode",
46 .maxlen = sizeof(int),
48 .proc_handler = proc_dointvec_minmax,
49 .strategy = sysctl_intvec,
50 .extra1 = &min_ipdefmode,
51 .extra2 = &max_ipdefmode
54 .ctl_name = NET_AX25_DEFAULT_MODE,
55 .procname = "ax25_default_mode",
56 .maxlen = sizeof(int),
58 .proc_handler = proc_dointvec_minmax,
59 .strategy = sysctl_intvec,
60 .extra1 = &min_axdefmode,
61 .extra2 = &max_axdefmode
64 .ctl_name = NET_AX25_BACKOFF_TYPE,
65 .procname = "backoff_type",
66 .maxlen = sizeof(int),
68 .proc_handler = proc_dointvec_minmax,
69 .strategy = sysctl_intvec,
70 .extra1 = &min_backoff,
71 .extra2 = &max_backoff
74 .ctl_name = NET_AX25_CONNECT_MODE,
75 .procname = "connect_mode",
76 .maxlen = sizeof(int),
78 .proc_handler = proc_dointvec_minmax,
79 .strategy = sysctl_intvec,
80 .extra1 = &min_conmode,
81 .extra2 = &max_conmode
84 .ctl_name = NET_AX25_STANDARD_WINDOW,
85 .procname = "standard_window_size",
86 .maxlen = sizeof(int),
88 .proc_handler = proc_dointvec_minmax,
89 .strategy = sysctl_intvec,
90 .extra1 = &min_window,
94 .ctl_name = NET_AX25_EXTENDED_WINDOW,
95 .procname = "extended_window_size",
96 .maxlen = sizeof(int),
98 .proc_handler = proc_dointvec_minmax,
99 .strategy = sysctl_intvec,
100 .extra1 = &min_ewindow,
101 .extra2 = &max_ewindow
104 .ctl_name = NET_AX25_T1_TIMEOUT,
105 .procname = "t1_timeout",
106 .maxlen = sizeof(int),
108 .proc_handler = proc_dointvec_minmax,
109 .strategy = sysctl_intvec,
114 .ctl_name = NET_AX25_T2_TIMEOUT,
115 .procname = "t2_timeout",
116 .maxlen = sizeof(int),
118 .proc_handler = proc_dointvec_minmax,
119 .strategy = sysctl_intvec,
124 .ctl_name = NET_AX25_T3_TIMEOUT,
125 .procname = "t3_timeout",
126 .maxlen = sizeof(int),
128 .proc_handler = proc_dointvec_minmax,
129 .strategy = sysctl_intvec,
134 .ctl_name = NET_AX25_IDLE_TIMEOUT,
135 .procname = "idle_timeout",
136 .maxlen = sizeof(int),
138 .proc_handler = proc_dointvec_minmax,
139 .strategy = sysctl_intvec,
144 .ctl_name = NET_AX25_N2,
145 .procname = "maximum_retry_count",
146 .maxlen = sizeof(int),
148 .proc_handler = proc_dointvec_minmax,
149 .strategy = sysctl_intvec,
154 .ctl_name = NET_AX25_PACLEN,
155 .procname = "maximum_packet_length",
156 .maxlen = sizeof(int),
158 .proc_handler = proc_dointvec_minmax,
159 .strategy = sysctl_intvec,
160 .extra1 = &min_paclen,
161 .extra2 = &max_paclen
164 .ctl_name = NET_AX25_PROTOCOL,
165 .procname = "protocol",
166 .maxlen = sizeof(int),
168 .proc_handler = proc_dointvec_minmax,
169 .strategy = sysctl_intvec,
170 .extra1 = &min_proto,
173 #ifdef CONFIG_AX25_DAMA_SLAVE
175 .ctl_name = NET_AX25_DAMA_SLAVE_TIMEOUT,
176 .procname = "dama_slave_timeout",
177 .maxlen = sizeof(int),
179 .proc_handler = proc_dointvec_minmax,
180 .strategy = sysctl_intvec,
181 .extra1 = &min_ds_timeout,
182 .extra2 = &max_ds_timeout
186 { .ctl_name = 0 } /* that's all, folks! */
189 void ax25_register_sysctl(void)
194 spin_lock_bh(&ax25_dev_lock);
195 for (ax25_table_size = sizeof(ctl_table), ax25_dev = ax25_dev_list; ax25_dev != NULL; ax25_dev = ax25_dev->next)
196 ax25_table_size += sizeof(ctl_table);
198 if ((ax25_table = kzalloc(ax25_table_size, GFP_ATOMIC)) == NULL) {
199 spin_unlock_bh(&ax25_dev_lock);
203 for (n = 0, ax25_dev = ax25_dev_list; ax25_dev != NULL; ax25_dev = ax25_dev->next) {
204 struct ctl_table *child = kmemdup(ax25_param_table,
205 sizeof(ax25_param_table),
209 kfree(ax25_table[n].child);
211 spin_unlock_bh(&ax25_dev_lock);
214 ax25_table[n].child = ax25_dev->systable = child;
215 ax25_table[n].ctl_name = n + 1;
216 ax25_table[n].procname = ax25_dev->dev->name;
217 ax25_table[n].mode = 0555;
219 child[AX25_MAX_VALUES].ctl_name = 0; /* just in case... */
221 for (k = 0; k < AX25_MAX_VALUES; k++)
222 child[k].data = &ax25_dev->values[k];
226 spin_unlock_bh(&ax25_dev_lock);
228 ax25_table_header = register_sysctl_paths(ax25_path, ax25_table);
231 void ax25_unregister_sysctl(void)
234 unregister_sysctl_table(ax25_table_header);
236 for (p = ax25_table; p->ctl_name; p++)