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 static int min_ds_timeout
[1], max_ds_timeout
[] = {65535000};
29 static struct ctl_table_header
*ax25_table_header
;
31 static ctl_table
*ax25_table
;
32 static int ax25_table_size
;
34 static ctl_table ax25_dir_table
[] = {
43 static ctl_table ax25_root_table
[] = {
48 .child
= ax25_dir_table
53 static const ctl_table ax25_param_table
[] = {
55 .ctl_name
= NET_AX25_IP_DEFAULT_MODE
,
56 .procname
= "ip_default_mode",
57 .maxlen
= sizeof(int),
59 .proc_handler
= &proc_dointvec_minmax
,
60 .strategy
= &sysctl_intvec
,
61 .extra1
= &min_ipdefmode
,
62 .extra2
= &max_ipdefmode
65 .ctl_name
= NET_AX25_DEFAULT_MODE
,
66 .procname
= "ax25_default_mode",
67 .maxlen
= sizeof(int),
69 .proc_handler
= &proc_dointvec_minmax
,
70 .strategy
= &sysctl_intvec
,
71 .extra1
= &min_axdefmode
,
72 .extra2
= &max_axdefmode
75 .ctl_name
= NET_AX25_BACKOFF_TYPE
,
76 .procname
= "backoff_type",
77 .maxlen
= sizeof(int),
79 .proc_handler
= &proc_dointvec_minmax
,
80 .strategy
= &sysctl_intvec
,
81 .extra1
= &min_backoff
,
82 .extra2
= &max_backoff
85 .ctl_name
= NET_AX25_CONNECT_MODE
,
86 .procname
= "connect_mode",
87 .maxlen
= sizeof(int),
89 .proc_handler
= &proc_dointvec_minmax
,
90 .strategy
= &sysctl_intvec
,
91 .extra1
= &min_conmode
,
92 .extra2
= &max_conmode
95 .ctl_name
= NET_AX25_STANDARD_WINDOW
,
96 .procname
= "standard_window_size",
97 .maxlen
= sizeof(int),
99 .proc_handler
= &proc_dointvec_minmax
,
100 .strategy
= &sysctl_intvec
,
101 .extra1
= &min_window
,
102 .extra2
= &max_window
105 .ctl_name
= NET_AX25_EXTENDED_WINDOW
,
106 .procname
= "extended_window_size",
107 .maxlen
= sizeof(int),
109 .proc_handler
= &proc_dointvec_minmax
,
110 .strategy
= &sysctl_intvec
,
111 .extra1
= &min_ewindow
,
112 .extra2
= &max_ewindow
115 .ctl_name
= NET_AX25_T1_TIMEOUT
,
116 .procname
= "t1_timeout",
117 .maxlen
= sizeof(int),
119 .proc_handler
= &proc_dointvec_minmax
,
120 .strategy
= &sysctl_intvec
,
125 .ctl_name
= NET_AX25_T2_TIMEOUT
,
126 .procname
= "t2_timeout",
127 .maxlen
= sizeof(int),
129 .proc_handler
= &proc_dointvec_minmax
,
130 .strategy
= &sysctl_intvec
,
135 .ctl_name
= NET_AX25_T3_TIMEOUT
,
136 .procname
= "t3_timeout",
137 .maxlen
= sizeof(int),
139 .proc_handler
= &proc_dointvec_minmax
,
140 .strategy
= &sysctl_intvec
,
145 .ctl_name
= NET_AX25_IDLE_TIMEOUT
,
146 .procname
= "idle_timeout",
147 .maxlen
= sizeof(int),
149 .proc_handler
= &proc_dointvec_minmax
,
150 .strategy
= &sysctl_intvec
,
155 .ctl_name
= NET_AX25_N2
,
156 .procname
= "maximum_retry_count",
157 .maxlen
= sizeof(int),
159 .proc_handler
= &proc_dointvec_minmax
,
160 .strategy
= &sysctl_intvec
,
165 .ctl_name
= NET_AX25_PACLEN
,
166 .procname
= "maximum_packet_length",
167 .maxlen
= sizeof(int),
169 .proc_handler
= &proc_dointvec_minmax
,
170 .strategy
= &sysctl_intvec
,
171 .extra1
= &min_paclen
,
172 .extra2
= &max_paclen
175 .ctl_name
= NET_AX25_PROTOCOL
,
176 .procname
= "protocol",
177 .maxlen
= sizeof(int),
179 .proc_handler
= &proc_dointvec_minmax
,
180 .strategy
= &sysctl_intvec
,
181 .extra1
= &min_proto
,
185 .ctl_name
= NET_AX25_DAMA_SLAVE_TIMEOUT
,
186 .procname
= "dama_slave_timeout",
187 .maxlen
= sizeof(int),
189 .proc_handler
= &proc_dointvec_minmax
,
190 .strategy
= &sysctl_intvec
,
191 .extra1
= &min_ds_timeout
,
192 .extra2
= &max_ds_timeout
194 { .ctl_name
= 0 } /* that's all, folks! */
197 void ax25_register_sysctl(void)
202 spin_lock_bh(&ax25_dev_lock
);
203 for (ax25_table_size
= sizeof(ctl_table
), ax25_dev
= ax25_dev_list
; ax25_dev
!= NULL
; ax25_dev
= ax25_dev
->next
)
204 ax25_table_size
+= sizeof(ctl_table
);
206 if ((ax25_table
= kzalloc(ax25_table_size
, GFP_ATOMIC
)) == NULL
) {
207 spin_unlock_bh(&ax25_dev_lock
);
211 for (n
= 0, ax25_dev
= ax25_dev_list
; ax25_dev
!= NULL
; ax25_dev
= ax25_dev
->next
) {
212 ctl_table
*child
= kmalloc(sizeof(ax25_param_table
), GFP_ATOMIC
);
215 kfree(ax25_table
[n
].child
);
217 spin_unlock_bh(&ax25_dev_lock
);
220 memcpy(child
, ax25_param_table
, sizeof(ax25_param_table
));
221 ax25_table
[n
].child
= ax25_dev
->systable
= child
;
222 ax25_table
[n
].ctl_name
= n
+ 1;
223 ax25_table
[n
].procname
= ax25_dev
->dev
->name
;
224 ax25_table
[n
].mode
= 0555;
226 #ifndef CONFIG_AX25_DAMA_SLAVE
228 * We do not wish to have a representation of this parameter
229 * in /proc/sys/ when configured *not* to include the
230 * AX.25 DAMA slave code, do we?
233 child
[AX25_VALUES_DS_TIMEOUT
].procname
= NULL
;
236 child
[AX25_MAX_VALUES
].ctl_name
= 0; /* just in case... */
238 for (k
= 0; k
< AX25_MAX_VALUES
; k
++)
239 child
[k
].data
= &ax25_dev
->values
[k
];
243 spin_unlock_bh(&ax25_dev_lock
);
245 ax25_dir_table
[0].child
= ax25_table
;
247 ax25_table_header
= register_sysctl_table(ax25_root_table
, 1);
250 void ax25_unregister_sysctl(void)
253 unregister_sysctl_table(ax25_table_header
);
255 ax25_dir_table
[0].child
= NULL
;
256 for (p
= ax25_table
; p
->ctl_name
; p
++)