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.
10 #include <linux/slab.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[] = {30000};
22 static int min_t2[] = {1}, max_t2[] = {20000};
23 static int min_t3[1], max_t3[] = {3600000};
24 static int min_idle[1], max_idle[] = {65535000};
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 #ifdef CONFIG_AX25_DAMA_SLAVE
29 static int min_ds_timeout[1], max_ds_timeout[] = {65535000};
32 static struct ctl_table_header *ax25_table_header;
34 static ctl_table *ax25_table;
35 static int ax25_table_size;
37 static struct ctl_path ax25_path[] = {
38 { .procname = "net", },
39 { .procname = "ax25", },
43 static const ctl_table ax25_param_table[] = {
45 .procname = "ip_default_mode",
46 .maxlen = sizeof(int),
48 .proc_handler = proc_dointvec_minmax,
49 .extra1 = &min_ipdefmode,
50 .extra2 = &max_ipdefmode
53 .procname = "ax25_default_mode",
54 .maxlen = sizeof(int),
56 .proc_handler = proc_dointvec_minmax,
57 .extra1 = &min_axdefmode,
58 .extra2 = &max_axdefmode
61 .procname = "backoff_type",
62 .maxlen = sizeof(int),
64 .proc_handler = proc_dointvec_minmax,
65 .extra1 = &min_backoff,
66 .extra2 = &max_backoff
69 .procname = "connect_mode",
70 .maxlen = sizeof(int),
72 .proc_handler = proc_dointvec_minmax,
73 .extra1 = &min_conmode,
74 .extra2 = &max_conmode
77 .procname = "standard_window_size",
78 .maxlen = sizeof(int),
80 .proc_handler = proc_dointvec_minmax,
81 .extra1 = &min_window,
85 .procname = "extended_window_size",
86 .maxlen = sizeof(int),
88 .proc_handler = proc_dointvec_minmax,
89 .extra1 = &min_ewindow,
90 .extra2 = &max_ewindow
93 .procname = "t1_timeout",
94 .maxlen = sizeof(int),
96 .proc_handler = proc_dointvec_minmax,
101 .procname = "t2_timeout",
102 .maxlen = sizeof(int),
104 .proc_handler = proc_dointvec_minmax,
109 .procname = "t3_timeout",
110 .maxlen = sizeof(int),
112 .proc_handler = proc_dointvec_minmax,
117 .procname = "idle_timeout",
118 .maxlen = sizeof(int),
120 .proc_handler = proc_dointvec_minmax,
125 .procname = "maximum_retry_count",
126 .maxlen = sizeof(int),
128 .proc_handler = proc_dointvec_minmax,
133 .procname = "maximum_packet_length",
134 .maxlen = sizeof(int),
136 .proc_handler = proc_dointvec_minmax,
137 .extra1 = &min_paclen,
138 .extra2 = &max_paclen
141 .procname = "protocol",
142 .maxlen = sizeof(int),
144 .proc_handler = proc_dointvec_minmax,
145 .extra1 = &min_proto,
148 #ifdef CONFIG_AX25_DAMA_SLAVE
150 .procname = "dama_slave_timeout",
151 .maxlen = sizeof(int),
153 .proc_handler = proc_dointvec_minmax,
154 .extra1 = &min_ds_timeout,
155 .extra2 = &max_ds_timeout
159 { } /* that's all, folks! */
162 void ax25_register_sysctl(void)
167 spin_lock_bh(&ax25_dev_lock);
168 for (ax25_table_size = sizeof(ctl_table), ax25_dev = ax25_dev_list; ax25_dev != NULL; ax25_dev = ax25_dev->next)
169 ax25_table_size += sizeof(ctl_table);
171 if ((ax25_table = kzalloc(ax25_table_size, GFP_ATOMIC)) == NULL) {
172 spin_unlock_bh(&ax25_dev_lock);
176 for (n = 0, ax25_dev = ax25_dev_list; ax25_dev != NULL; ax25_dev = ax25_dev->next) {
177 struct ctl_table *child = kmemdup(ax25_param_table,
178 sizeof(ax25_param_table),
182 kfree(ax25_table[n].child);
184 spin_unlock_bh(&ax25_dev_lock);
187 ax25_table[n].child = ax25_dev->systable = child;
188 ax25_table[n].procname = ax25_dev->dev->name;
189 ax25_table[n].mode = 0555;
192 for (k = 0; k < AX25_MAX_VALUES; k++)
193 child[k].data = &ax25_dev->values[k];
197 spin_unlock_bh(&ax25_dev_lock);
199 ax25_table_header = register_sysctl_paths(ax25_path, ax25_table);
202 void ax25_unregister_sysctl(void)
205 unregister_sysctl_table(ax25_table_header);
207 for (p = ax25_table; p->procname; p++)