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
, },
40 static const ctl_table ax25_param_table
[] = {
42 .ctl_name
= NET_AX25_IP_DEFAULT_MODE
,
43 .procname
= "ip_default_mode",
44 .maxlen
= sizeof(int),
46 .proc_handler
= &proc_dointvec_minmax
,
47 .strategy
= &sysctl_intvec
,
48 .extra1
= &min_ipdefmode
,
49 .extra2
= &max_ipdefmode
52 .ctl_name
= NET_AX25_DEFAULT_MODE
,
53 .procname
= "ax25_default_mode",
54 .maxlen
= sizeof(int),
56 .proc_handler
= &proc_dointvec_minmax
,
57 .strategy
= &sysctl_intvec
,
58 .extra1
= &min_axdefmode
,
59 .extra2
= &max_axdefmode
62 .ctl_name
= NET_AX25_BACKOFF_TYPE
,
63 .procname
= "backoff_type",
64 .maxlen
= sizeof(int),
66 .proc_handler
= &proc_dointvec_minmax
,
67 .strategy
= &sysctl_intvec
,
68 .extra1
= &min_backoff
,
69 .extra2
= &max_backoff
72 .ctl_name
= NET_AX25_CONNECT_MODE
,
73 .procname
= "connect_mode",
74 .maxlen
= sizeof(int),
76 .proc_handler
= &proc_dointvec_minmax
,
77 .strategy
= &sysctl_intvec
,
78 .extra1
= &min_conmode
,
79 .extra2
= &max_conmode
82 .ctl_name
= NET_AX25_STANDARD_WINDOW
,
83 .procname
= "standard_window_size",
84 .maxlen
= sizeof(int),
86 .proc_handler
= &proc_dointvec_minmax
,
87 .strategy
= &sysctl_intvec
,
88 .extra1
= &min_window
,
92 .ctl_name
= NET_AX25_EXTENDED_WINDOW
,
93 .procname
= "extended_window_size",
94 .maxlen
= sizeof(int),
96 .proc_handler
= &proc_dointvec_minmax
,
97 .strategy
= &sysctl_intvec
,
98 .extra1
= &min_ewindow
,
99 .extra2
= &max_ewindow
102 .ctl_name
= NET_AX25_T1_TIMEOUT
,
103 .procname
= "t1_timeout",
104 .maxlen
= sizeof(int),
106 .proc_handler
= &proc_dointvec_minmax
,
107 .strategy
= &sysctl_intvec
,
112 .ctl_name
= NET_AX25_T2_TIMEOUT
,
113 .procname
= "t2_timeout",
114 .maxlen
= sizeof(int),
116 .proc_handler
= &proc_dointvec_minmax
,
117 .strategy
= &sysctl_intvec
,
122 .ctl_name
= NET_AX25_T3_TIMEOUT
,
123 .procname
= "t3_timeout",
124 .maxlen
= sizeof(int),
126 .proc_handler
= &proc_dointvec_minmax
,
127 .strategy
= &sysctl_intvec
,
132 .ctl_name
= NET_AX25_IDLE_TIMEOUT
,
133 .procname
= "idle_timeout",
134 .maxlen
= sizeof(int),
136 .proc_handler
= &proc_dointvec_minmax
,
137 .strategy
= &sysctl_intvec
,
142 .ctl_name
= NET_AX25_N2
,
143 .procname
= "maximum_retry_count",
144 .maxlen
= sizeof(int),
146 .proc_handler
= &proc_dointvec_minmax
,
147 .strategy
= &sysctl_intvec
,
152 .ctl_name
= NET_AX25_PACLEN
,
153 .procname
= "maximum_packet_length",
154 .maxlen
= sizeof(int),
156 .proc_handler
= &proc_dointvec_minmax
,
157 .strategy
= &sysctl_intvec
,
158 .extra1
= &min_paclen
,
159 .extra2
= &max_paclen
162 .ctl_name
= NET_AX25_PROTOCOL
,
163 .procname
= "protocol",
164 .maxlen
= sizeof(int),
166 .proc_handler
= &proc_dointvec_minmax
,
167 .strategy
= &sysctl_intvec
,
168 .extra1
= &min_proto
,
171 #ifdef CONFIG_AX25_DAMA_SLAVE
173 .ctl_name
= NET_AX25_DAMA_SLAVE_TIMEOUT
,
174 .procname
= "dama_slave_timeout",
175 .maxlen
= sizeof(int),
177 .proc_handler
= &proc_dointvec_minmax
,
178 .strategy
= &sysctl_intvec
,
179 .extra1
= &min_ds_timeout
,
180 .extra2
= &max_ds_timeout
184 { .ctl_name
= 0 } /* that's all, folks! */
187 void ax25_register_sysctl(void)
192 spin_lock_bh(&ax25_dev_lock
);
193 for (ax25_table_size
= sizeof(ctl_table
), ax25_dev
= ax25_dev_list
; ax25_dev
!= NULL
; ax25_dev
= ax25_dev
->next
)
194 ax25_table_size
+= sizeof(ctl_table
);
196 if ((ax25_table
= kzalloc(ax25_table_size
, GFP_ATOMIC
)) == NULL
) {
197 spin_unlock_bh(&ax25_dev_lock
);
201 for (n
= 0, ax25_dev
= ax25_dev_list
; ax25_dev
!= NULL
; ax25_dev
= ax25_dev
->next
) {
202 struct ctl_table
*child
= kmemdup(ax25_param_table
,
203 sizeof(ax25_param_table
),
207 kfree(ax25_table
[n
].child
);
209 spin_unlock_bh(&ax25_dev_lock
);
212 ax25_table
[n
].child
= ax25_dev
->systable
= child
;
213 ax25_table
[n
].ctl_name
= n
+ 1;
214 ax25_table
[n
].procname
= ax25_dev
->dev
->name
;
215 ax25_table
[n
].mode
= 0555;
217 child
[AX25_MAX_VALUES
].ctl_name
= 0; /* just in case... */
219 for (k
= 0; k
< AX25_MAX_VALUES
; k
++)
220 child
[k
].data
= &ax25_dev
->values
[k
];
224 spin_unlock_bh(&ax25_dev_lock
);
226 ax25_table_header
= register_sysctl_paths(ax25_path
, ax25_table
);
229 void ax25_unregister_sysctl(void)
232 unregister_sysctl_table(ax25_table_header
);
234 for (p
= ax25_table
; p
->ctl_name
; p
++)