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 struct ctl_path ax25_path
[] = {
35 { .procname
= "net", .ctl_name
= CTL_NET
, },
36 { .procname
= "ax25", .ctl_name
= NET_AX25
, },
39 static const ctl_table ax25_param_table
[] = {
41 .ctl_name
= NET_AX25_IP_DEFAULT_MODE
,
42 .procname
= "ip_default_mode",
43 .maxlen
= sizeof(int),
45 .proc_handler
= &proc_dointvec_minmax
,
46 .strategy
= &sysctl_intvec
,
47 .extra1
= &min_ipdefmode
,
48 .extra2
= &max_ipdefmode
51 .ctl_name
= NET_AX25_DEFAULT_MODE
,
52 .procname
= "ax25_default_mode",
53 .maxlen
= sizeof(int),
55 .proc_handler
= &proc_dointvec_minmax
,
56 .strategy
= &sysctl_intvec
,
57 .extra1
= &min_axdefmode
,
58 .extra2
= &max_axdefmode
61 .ctl_name
= NET_AX25_BACKOFF_TYPE
,
62 .procname
= "backoff_type",
63 .maxlen
= sizeof(int),
65 .proc_handler
= &proc_dointvec_minmax
,
66 .strategy
= &sysctl_intvec
,
67 .extra1
= &min_backoff
,
68 .extra2
= &max_backoff
71 .ctl_name
= NET_AX25_CONNECT_MODE
,
72 .procname
= "connect_mode",
73 .maxlen
= sizeof(int),
75 .proc_handler
= &proc_dointvec_minmax
,
76 .strategy
= &sysctl_intvec
,
77 .extra1
= &min_conmode
,
78 .extra2
= &max_conmode
81 .ctl_name
= NET_AX25_STANDARD_WINDOW
,
82 .procname
= "standard_window_size",
83 .maxlen
= sizeof(int),
85 .proc_handler
= &proc_dointvec_minmax
,
86 .strategy
= &sysctl_intvec
,
87 .extra1
= &min_window
,
91 .ctl_name
= NET_AX25_EXTENDED_WINDOW
,
92 .procname
= "extended_window_size",
93 .maxlen
= sizeof(int),
95 .proc_handler
= &proc_dointvec_minmax
,
96 .strategy
= &sysctl_intvec
,
97 .extra1
= &min_ewindow
,
98 .extra2
= &max_ewindow
101 .ctl_name
= NET_AX25_T1_TIMEOUT
,
102 .procname
= "t1_timeout",
103 .maxlen
= sizeof(int),
105 .proc_handler
= &proc_dointvec_minmax
,
106 .strategy
= &sysctl_intvec
,
111 .ctl_name
= NET_AX25_T2_TIMEOUT
,
112 .procname
= "t2_timeout",
113 .maxlen
= sizeof(int),
115 .proc_handler
= &proc_dointvec_minmax
,
116 .strategy
= &sysctl_intvec
,
121 .ctl_name
= NET_AX25_T3_TIMEOUT
,
122 .procname
= "t3_timeout",
123 .maxlen
= sizeof(int),
125 .proc_handler
= &proc_dointvec_minmax
,
126 .strategy
= &sysctl_intvec
,
131 .ctl_name
= NET_AX25_IDLE_TIMEOUT
,
132 .procname
= "idle_timeout",
133 .maxlen
= sizeof(int),
135 .proc_handler
= &proc_dointvec_minmax
,
136 .strategy
= &sysctl_intvec
,
141 .ctl_name
= NET_AX25_N2
,
142 .procname
= "maximum_retry_count",
143 .maxlen
= sizeof(int),
145 .proc_handler
= &proc_dointvec_minmax
,
146 .strategy
= &sysctl_intvec
,
151 .ctl_name
= NET_AX25_PACLEN
,
152 .procname
= "maximum_packet_length",
153 .maxlen
= sizeof(int),
155 .proc_handler
= &proc_dointvec_minmax
,
156 .strategy
= &sysctl_intvec
,
157 .extra1
= &min_paclen
,
158 .extra2
= &max_paclen
161 .ctl_name
= NET_AX25_PROTOCOL
,
162 .procname
= "protocol",
163 .maxlen
= sizeof(int),
165 .proc_handler
= &proc_dointvec_minmax
,
166 .strategy
= &sysctl_intvec
,
167 .extra1
= &min_proto
,
171 .ctl_name
= NET_AX25_DAMA_SLAVE_TIMEOUT
,
172 .procname
= "dama_slave_timeout",
173 .maxlen
= sizeof(int),
175 .proc_handler
= &proc_dointvec_minmax
,
176 .strategy
= &sysctl_intvec
,
177 .extra1
= &min_ds_timeout
,
178 .extra2
= &max_ds_timeout
180 { .ctl_name
= 0 } /* that's all, folks! */
183 void ax25_register_sysctl(void)
188 spin_lock_bh(&ax25_dev_lock
);
189 for (ax25_table_size
= sizeof(ctl_table
), ax25_dev
= ax25_dev_list
; ax25_dev
!= NULL
; ax25_dev
= ax25_dev
->next
)
190 ax25_table_size
+= sizeof(ctl_table
);
192 if ((ax25_table
= kzalloc(ax25_table_size
, GFP_ATOMIC
)) == NULL
) {
193 spin_unlock_bh(&ax25_dev_lock
);
197 for (n
= 0, ax25_dev
= ax25_dev_list
; ax25_dev
!= NULL
; ax25_dev
= ax25_dev
->next
) {
198 struct ctl_table
*child
= kmemdup(ax25_param_table
,
199 sizeof(ax25_param_table
),
203 kfree(ax25_table
[n
].child
);
205 spin_unlock_bh(&ax25_dev_lock
);
208 ax25_table
[n
].child
= ax25_dev
->systable
= child
;
209 ax25_table
[n
].ctl_name
= n
+ 1;
210 ax25_table
[n
].procname
= ax25_dev
->dev
->name
;
211 ax25_table
[n
].mode
= 0555;
213 #ifndef CONFIG_AX25_DAMA_SLAVE
215 * We do not wish to have a representation of this parameter
216 * in /proc/sys/ when configured *not* to include the
217 * AX.25 DAMA slave code, do we?
220 child
[AX25_VALUES_DS_TIMEOUT
].procname
= NULL
;
223 child
[AX25_MAX_VALUES
].ctl_name
= 0; /* just in case... */
225 for (k
= 0; k
< AX25_MAX_VALUES
; k
++)
226 child
[k
].data
= &ax25_dev
->values
[k
];
230 spin_unlock_bh(&ax25_dev_lock
);
232 ax25_table_header
= register_sysctl_paths(ax25_path
, ax25_table
);
235 void ax25_unregister_sysctl(void)
238 unregister_sysctl_table(ax25_table_header
);
240 for (p
= ax25_table
; p
->ctl_name
; p
++)