File: /usr/src/linux/net/irda/irsysctl.c

1     /*********************************************************************
2      *                
3      * Filename:      irsysctl.c
4      * Version:       1.0
5      * Description:   Sysctl interface for IrDA
6      * Status:        Experimental.
7      * Author:        Dag Brattli <dagb@cs.uit.no>
8      * Created at:    Sun May 24 22:12:06 1998
9      * Modified at:   Fri Jun  4 02:50:15 1999
10      * Modified by:   Dag Brattli <dagb@cs.uit.no>
11      * 
12      *     Copyright (c) 1997, 1999 Dag Brattli, All Rights Reserved.
13      *      
14      *     This program is free software; you can redistribute it and/or 
15      *     modify it under the terms of the GNU General Public License as 
16      *     published by the Free Software Foundation; either version 2 of 
17      *     the License, or (at your option) any later version.
18      *  
19      *     Neither Dag Brattli nor University of Tromsų admit liability nor
20      *     provide warranty for any of this software. This material is 
21      *     provided "AS-IS" and at no charge.
22      *     
23      ********************************************************************/
24     
25     #include <linux/config.h>
26     #include <linux/mm.h>
27     #include <linux/ctype.h>
28     #include <linux/sysctl.h>
29     #include <asm/segment.h>
30     
31     #include <net/irda/irda.h>
32     #include <net/irda/irias_object.h>
33     
34     #define NET_IRDA 412 /* Random number */
35     enum { DISCOVERY=1, DEVNAME, DEBUG, SLOTS, DISCOVERY_TIMEOUT, 
36            SLOT_TIMEOUT, MAX_BAUD_RATE, MAX_INACTIVE_TIME, LAP_KEEPALIVE_TIME, };
37     
38     extern int  sysctl_discovery;
39     extern int  sysctl_discovery_slots;
40     extern int  sysctl_discovery_timeout;
41     extern int  sysctl_slot_timeout;
42     extern int  sysctl_fast_poll_increase;
43     int         sysctl_compression = 0;
44     extern char sysctl_devname[];
45     extern int  sysctl_max_baud_rate;
46     extern int  sysctl_max_inactive_time;
47     extern int  sysctl_lap_keepalive_time;
48     
49     #ifdef CONFIG_IRDA_DEBUG
50     extern unsigned int irda_debug;
51     #endif
52     
53     static int do_devname(ctl_table *table, int write, struct file *filp,
54     		      void *buffer, size_t *lenp)
55     {
56     	int ret;
57     
58     	ret = proc_dostring(table, write, filp, buffer, lenp);
59     	if (ret == 0 && write) {
60     		struct ias_value *val;
61     
62     		val = irias_new_string_value(sysctl_devname);
63     		if (val)
64     			irias_object_change_attribute("Device", "DeviceName", val);
65     	}
66     	return ret;
67     }
68     
69     /* One file */
70     static ctl_table irda_table[] = {
71     	{ DISCOVERY, "discovery", &sysctl_discovery,
72     	  sizeof(int), 0644, NULL, &proc_dointvec },
73     	{ DEVNAME, "devname", sysctl_devname,
74     	  65, 0644, NULL, &do_devname, &sysctl_string},
75     #ifdef CONFIG_IRDA_DEBUG
76             { DEBUG, "debug", &irda_debug,
77     	  sizeof(int), 0644, NULL, &proc_dointvec },
78     #endif
79     #ifdef CONFIG_IRDA_FAST_RR
80             { SLOTS, "fast_poll_increase", &sysctl_fast_poll_increase,
81     	  sizeof(int), 0644, NULL, &proc_dointvec },
82     #endif
83     	{ SLOTS, "discovery_slots", &sysctl_discovery_slots,
84     	  sizeof(int), 0644, NULL, &proc_dointvec },
85     	{ DISCOVERY_TIMEOUT, "discovery_timeout", &sysctl_discovery_timeout,
86     	  sizeof(int), 0644, NULL, &proc_dointvec },
87     	{ SLOT_TIMEOUT, "slot_timeout", &sysctl_slot_timeout,
88     	  sizeof(int), 0644, NULL, &proc_dointvec },
89     	{ MAX_BAUD_RATE, "max_baud_rate", &sysctl_max_baud_rate,
90     	  sizeof(int), 0644, NULL, &proc_dointvec },
91     	{ MAX_INACTIVE_TIME, "max_inactive_time", &sysctl_max_inactive_time,
92     	  sizeof(int), 0644, NULL, &proc_dointvec },
93     	{ LAP_KEEPALIVE_TIME, "lap_keepalive_time", &sysctl_lap_keepalive_time,
94     	  sizeof(int), 0644, NULL, &proc_dointvec },
95     	{ 0 }
96     };
97     
98     /* One directory */
99     static ctl_table irda_net_table[] = {
100     	{ NET_IRDA, "irda", NULL, 0, 0555, irda_table },
101     	{ 0 }
102     };
103     
104     /* The parent directory */
105     static ctl_table irda_root_table[] = {
106     	{ CTL_NET, "net", NULL, 0, 0555, irda_net_table },
107     	{ 0 }
108     };
109     
110     static struct ctl_table_header *irda_table_header;
111     
112     /*
113      * Function irda_sysctl_register (void)
114      *
115      *    Register our sysctl interface
116      *
117      */
118     int irda_sysctl_register(void)
119     {
120     	irda_table_header = register_sysctl_table(irda_root_table, 0);
121     	if (!irda_table_header)
122     		return -ENOMEM;
123     
124     	return 0;
125     }
126     
127     /*
128      * Function irda_sysctl_unregister (void)
129      *
130      *    Unregister our sysctl interface
131      *
132      */
133     void irda_sysctl_unregister(void) 
134     {
135     	unregister_sysctl_table(irda_table_header);
136     }
137     
138     
139     
140