1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26#include <linux/mm.h>
27#include <linux/ctype.h>
28#include <linux/sysctl.h>
29#include <linux/init.h>
30
31#include <net/irda/irda.h>
32#include <net/irda/irlmp.h>
33#include <net/irda/timer.h>
34#include <net/irda/irias_object.h>
35
36extern int sysctl_discovery;
37extern int sysctl_discovery_slots;
38extern int sysctl_discovery_timeout;
39extern int sysctl_slot_timeout;
40extern int sysctl_fast_poll_increase;
41extern char sysctl_devname[];
42extern int sysctl_max_baud_rate;
43extern unsigned int sysctl_min_tx_turn_time;
44extern unsigned int sysctl_max_tx_data_size;
45extern unsigned int sysctl_max_tx_window;
46extern int sysctl_max_noreply_time;
47extern int sysctl_warn_noreply_time;
48extern int sysctl_lap_keepalive_time;
49
50extern struct irlmp_cb *irlmp;
51
52
53static int max_discovery_slots = 16;
54static int min_discovery_slots = 1;
55
56
57static int max_slot_timeout = 160;
58static int min_slot_timeout = 20;
59static int max_max_baud_rate = 16000000;
60static int min_max_baud_rate = 2400;
61static int max_min_tx_turn_time = 10000;
62static int min_min_tx_turn_time;
63static int max_max_tx_data_size = 2048;
64static int min_max_tx_data_size = 64;
65static int max_max_tx_window = 7;
66static int min_max_tx_window = 1;
67static int max_max_noreply_time = 40;
68static int min_max_noreply_time = 3;
69static int max_warn_noreply_time = 3;
70static int min_warn_noreply_time = 1;
71static int max_lap_keepalive_time = 10000;
72static int min_lap_keepalive_time = 100;
73
74
75
76static int do_devname(struct ctl_table *table, int write,
77 void __user *buffer, size_t *lenp, loff_t *ppos)
78{
79 int ret;
80
81 ret = proc_dostring(table, write, buffer, lenp, ppos);
82 if (ret == 0 && write) {
83 struct ias_value *val;
84
85 val = irias_new_string_value(sysctl_devname);
86 if (val)
87 irias_object_change_attribute("Device", "DeviceName", val);
88 }
89 return ret;
90}
91
92
93static int do_discovery(struct ctl_table *table, int write,
94 void __user *buffer, size_t *lenp, loff_t *ppos)
95{
96 int ret;
97
98 ret = proc_dointvec(table, write, buffer, lenp, ppos);
99 if (ret)
100 return ret;
101
102 if (irlmp == NULL)
103 return -ENODEV;
104
105 if (sysctl_discovery)
106 irlmp_start_discovery_timer(irlmp, sysctl_discovery_timeout*HZ);
107 else
108 del_timer_sync(&irlmp->discovery_timer);
109
110 return ret;
111}
112
113
114static struct ctl_table irda_table[] = {
115 {
116 .procname = "discovery",
117 .data = &sysctl_discovery,
118 .maxlen = sizeof(int),
119 .mode = 0644,
120 .proc_handler = do_discovery,
121 },
122 {
123 .procname = "devname",
124 .data = sysctl_devname,
125 .maxlen = 65,
126 .mode = 0644,
127 .proc_handler = do_devname,
128 },
129#ifdef CONFIG_IRDA_DEBUG
130 {
131 .procname = "debug",
132 .data = &irda_debug,
133 .maxlen = sizeof(int),
134 .mode = 0644,
135 .proc_handler = proc_dointvec
136 },
137#endif
138#ifdef CONFIG_IRDA_FAST_RR
139 {
140 .procname = "fast_poll_increase",
141 .data = &sysctl_fast_poll_increase,
142 .maxlen = sizeof(int),
143 .mode = 0644,
144 .proc_handler = proc_dointvec
145 },
146#endif
147 {
148 .procname = "discovery_slots",
149 .data = &sysctl_discovery_slots,
150 .maxlen = sizeof(int),
151 .mode = 0644,
152 .proc_handler = proc_dointvec_minmax,
153 .extra1 = &min_discovery_slots,
154 .extra2 = &max_discovery_slots
155 },
156 {
157 .procname = "discovery_timeout",
158 .data = &sysctl_discovery_timeout,
159 .maxlen = sizeof(int),
160 .mode = 0644,
161 .proc_handler = proc_dointvec
162 },
163 {
164 .procname = "slot_timeout",
165 .data = &sysctl_slot_timeout,
166 .maxlen = sizeof(int),
167 .mode = 0644,
168 .proc_handler = proc_dointvec_minmax,
169 .extra1 = &min_slot_timeout,
170 .extra2 = &max_slot_timeout
171 },
172 {
173 .procname = "max_baud_rate",
174 .data = &sysctl_max_baud_rate,
175 .maxlen = sizeof(int),
176 .mode = 0644,
177 .proc_handler = proc_dointvec_minmax,
178 .extra1 = &min_max_baud_rate,
179 .extra2 = &max_max_baud_rate
180 },
181 {
182 .procname = "min_tx_turn_time",
183 .data = &sysctl_min_tx_turn_time,
184 .maxlen = sizeof(int),
185 .mode = 0644,
186 .proc_handler = proc_dointvec_minmax,
187 .extra1 = &min_min_tx_turn_time,
188 .extra2 = &max_min_tx_turn_time
189 },
190 {
191 .procname = "max_tx_data_size",
192 .data = &sysctl_max_tx_data_size,
193 .maxlen = sizeof(int),
194 .mode = 0644,
195 .proc_handler = proc_dointvec_minmax,
196 .extra1 = &min_max_tx_data_size,
197 .extra2 = &max_max_tx_data_size
198 },
199 {
200 .procname = "max_tx_window",
201 .data = &sysctl_max_tx_window,
202 .maxlen = sizeof(int),
203 .mode = 0644,
204 .proc_handler = proc_dointvec_minmax,
205 .extra1 = &min_max_tx_window,
206 .extra2 = &max_max_tx_window
207 },
208 {
209 .procname = "max_noreply_time",
210 .data = &sysctl_max_noreply_time,
211 .maxlen = sizeof(int),
212 .mode = 0644,
213 .proc_handler = proc_dointvec_minmax,
214 .extra1 = &min_max_noreply_time,
215 .extra2 = &max_max_noreply_time
216 },
217 {
218 .procname = "warn_noreply_time",
219 .data = &sysctl_warn_noreply_time,
220 .maxlen = sizeof(int),
221 .mode = 0644,
222 .proc_handler = proc_dointvec_minmax,
223 .extra1 = &min_warn_noreply_time,
224 .extra2 = &max_warn_noreply_time
225 },
226 {
227 .procname = "lap_keepalive_time",
228 .data = &sysctl_lap_keepalive_time,
229 .maxlen = sizeof(int),
230 .mode = 0644,
231 .proc_handler = proc_dointvec_minmax,
232 .extra1 = &min_lap_keepalive_time,
233 .extra2 = &max_lap_keepalive_time
234 },
235 { }
236};
237
238static struct ctl_table_header *irda_table_header;
239
240
241
242
243
244
245
246int __init irda_sysctl_register(void)
247{
248 irda_table_header = register_net_sysctl(&init_net, "net/irda", irda_table);
249 if (!irda_table_header)
250 return -ENOMEM;
251
252 return 0;
253}
254
255
256
257
258
259
260
261void irda_sysctl_unregister(void)
262{
263 unregister_net_sysctl_table(irda_table_header);
264}
265
266
267
268