aboutsummaryrefslogtreecommitdiffstats
path: root/net/atm/mpoa_proc.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/atm/mpoa_proc.c')
-rw-r--r--net/atm/mpoa_proc.c88
1 files changed, 44 insertions, 44 deletions
diff --git a/net/atm/mpoa_proc.c b/net/atm/mpoa_proc.c
index 3844c85d602f..43315af10309 100644
--- a/net/atm/mpoa_proc.c
+++ b/net/atm/mpoa_proc.c
@@ -2,7 +2,7 @@
2#ifdef CONFIG_PROC_FS 2#ifdef CONFIG_PROC_FS
3#include <linux/errno.h> 3#include <linux/errno.h>
4#include <linux/kernel.h> 4#include <linux/kernel.h>
5#include <linux/string.h> 5#include <linux/string.h>
6#include <linux/mm.h> 6#include <linux/mm.h>
7#include <linux/module.h> 7#include <linux/module.h>
8#include <linux/proc_fs.h> 8#include <linux/proc_fs.h>
@@ -16,7 +16,7 @@
16 16
17/* 17/*
18 * mpoa_proc.c: Implementation MPOA client's proc 18 * mpoa_proc.c: Implementation MPOA client's proc
19 * file system statistics 19 * file system statistics
20 */ 20 */
21 21
22#if 1 22#if 1
@@ -32,7 +32,7 @@ extern struct proc_dir_entry *atm_proc_root; /* from proc.c. */
32 32
33static int proc_mpc_open(struct inode *inode, struct file *file); 33static int proc_mpc_open(struct inode *inode, struct file *file);
34static ssize_t proc_mpc_write(struct file *file, const char __user *buff, 34static ssize_t proc_mpc_write(struct file *file, const char __user *buff,
35 size_t nbytes, loff_t *ppos); 35 size_t nbytes, loff_t *ppos);
36 36
37static int parse_qos(const char *buff); 37static int parse_qos(const char *buff);
38 38
@@ -52,18 +52,18 @@ static struct file_operations mpc_file_operations = {
52 * Returns the state of an ingress cache entry as a string 52 * Returns the state of an ingress cache entry as a string
53 */ 53 */
54static const char *ingress_state_string(int state){ 54static const char *ingress_state_string(int state){
55 switch(state) { 55 switch(state) {
56 case INGRESS_RESOLVING: 56 case INGRESS_RESOLVING:
57 return "resolving "; 57 return "resolving ";
58 break; 58 break;
59 case INGRESS_RESOLVED: 59 case INGRESS_RESOLVED:
60 return "resolved "; 60 return "resolved ";
61 break; 61 break;
62 case INGRESS_INVALID: 62 case INGRESS_INVALID:
63 return "invalid "; 63 return "invalid ";
64 break; 64 break;
65 case INGRESS_REFRESHING: 65 case INGRESS_REFRESHING:
66 return "refreshing "; 66 return "refreshing ";
67 break; 67 break;
68 default: 68 default:
69 return ""; 69 return "";
@@ -74,15 +74,15 @@ static const char *ingress_state_string(int state){
74 * Returns the state of an egress cache entry as a string 74 * Returns the state of an egress cache entry as a string
75 */ 75 */
76static const char *egress_state_string(int state){ 76static const char *egress_state_string(int state){
77 switch(state) { 77 switch(state) {
78 case EGRESS_RESOLVED: 78 case EGRESS_RESOLVED:
79 return "resolved "; 79 return "resolved ";
80 break; 80 break;
81 case EGRESS_PURGE: 81 case EGRESS_PURGE:
82 return "purge "; 82 return "purge ";
83 break; 83 break;
84 case EGRESS_INVALID: 84 case EGRESS_INVALID:
85 return "invalid "; 85 return "invalid ";
86 break; 86 break;
87 default: 87 default:
88 return ""; 88 return "";
@@ -135,7 +135,7 @@ static int mpc_show(struct seq_file *m, void *v)
135 return 0; 135 return 0;
136 } 136 }
137 137
138 seq_printf(m, "\nInterface %d:\n\n", mpc->dev_num); 138 seq_printf(m, "\nInterface %d:\n\n", mpc->dev_num);
139 seq_printf(m, "Ingress Entries:\nIP address State Holding time Packets fwded VPI VCI\n"); 139 seq_printf(m, "Ingress Entries:\nIP address State Holding time Packets fwded VPI VCI\n");
140 do_gettimeofday(&now); 140 do_gettimeofday(&now);
141 141
@@ -163,7 +163,7 @@ static int mpc_show(struct seq_file *m, void *v)
163 egress_state_string(eg_entry->entry_state), 163 egress_state_string(eg_entry->entry_state),
164 (eg_entry->ctrl_info.holding_time-(now.tv_sec-eg_entry->tv.tv_sec)), 164 (eg_entry->ctrl_info.holding_time-(now.tv_sec-eg_entry->tv.tv_sec)),
165 eg_entry->packets_rcvd); 165 eg_entry->packets_rcvd);
166 166
167 /* latest IP address */ 167 /* latest IP address */
168 temp = (unsigned char *)&eg_entry->latest_ip_addr; 168 temp = (unsigned char *)&eg_entry->latest_ip_addr;
169 sprintf(ip_string, "%d.%d.%d.%d", temp[0], temp[1], temp[2], temp[3]); 169 sprintf(ip_string, "%d.%d.%d.%d", temp[0], temp[1], temp[2], temp[3]);
@@ -190,51 +190,51 @@ static int proc_mpc_open(struct inode *inode, struct file *file)
190} 190}
191 191
192static ssize_t proc_mpc_write(struct file *file, const char __user *buff, 192static ssize_t proc_mpc_write(struct file *file, const char __user *buff,
193 size_t nbytes, loff_t *ppos) 193 size_t nbytes, loff_t *ppos)
194{ 194{
195 char *page, *p; 195 char *page, *p;
196 unsigned len; 196 unsigned len;
197 197
198 if (nbytes == 0) 198 if (nbytes == 0)
199 return 0; 199 return 0;
200 200
201 if (nbytes >= PAGE_SIZE) 201 if (nbytes >= PAGE_SIZE)
202 nbytes = PAGE_SIZE-1; 202 nbytes = PAGE_SIZE-1;
203 203
204 page = (char *)__get_free_page(GFP_KERNEL); 204 page = (char *)__get_free_page(GFP_KERNEL);
205 if (!page) 205 if (!page)
206 return -ENOMEM; 206 return -ENOMEM;
207 207
208 for (p = page, len = 0; len < nbytes; p++, len++) { 208 for (p = page, len = 0; len < nbytes; p++, len++) {
209 if (get_user(*p, buff++)) { 209 if (get_user(*p, buff++)) {
210 free_page((unsigned long)page); 210 free_page((unsigned long)page);
211 return -EFAULT; 211 return -EFAULT;
212 } 212 }
213 if (*p == '\0' || *p == '\n') 213 if (*p == '\0' || *p == '\n')
214 break; 214 break;
215 } 215 }
216 216
217 *p = '\0'; 217 *p = '\0';
218 218
219 if (!parse_qos(page)) 219 if (!parse_qos(page))
220 printk("mpoa: proc_mpc_write: could not parse '%s'\n", page); 220 printk("mpoa: proc_mpc_write: could not parse '%s'\n", page);
221
222 free_page((unsigned long)page);
221 223
222 free_page((unsigned long)page); 224 return len;
223
224 return len;
225} 225}
226 226
227static int parse_qos(const char *buff) 227static int parse_qos(const char *buff)
228{ 228{
229 /* possible lines look like this 229 /* possible lines look like this
230 * add 130.230.54.142 tx=max_pcr,max_sdu rx=max_pcr,max_sdu 230 * add 130.230.54.142 tx=max_pcr,max_sdu rx=max_pcr,max_sdu
231 */ 231 */
232 unsigned char ip[4]; 232 unsigned char ip[4];
233 int tx_pcr, tx_sdu, rx_pcr, rx_sdu; 233 int tx_pcr, tx_sdu, rx_pcr, rx_sdu;
234 __be32 ipaddr; 234 __be32 ipaddr;
235 struct atm_qos qos; 235 struct atm_qos qos;
236 236
237 memset(&qos, 0, sizeof(struct atm_qos)); 237 memset(&qos, 0, sizeof(struct atm_qos));
238 238
239 if (sscanf(buff, "del %hhu.%hhu.%hhu.%hhu", 239 if (sscanf(buff, "del %hhu.%hhu.%hhu.%hhu",
240 ip, ip+1, ip+2, ip+3) == 4) { 240 ip, ip+1, ip+2, ip+3) == 4) {
@@ -250,14 +250,14 @@ static int parse_qos(const char *buff)
250 ip, ip+1, ip+2, ip+3, &tx_pcr, &tx_sdu, &rx_pcr, &rx_sdu) != 8) 250 ip, ip+1, ip+2, ip+3, &tx_pcr, &tx_sdu, &rx_pcr, &rx_sdu) != 8)
251 return 0; 251 return 0;
252 252
253 ipaddr = *(__be32 *)ip; 253 ipaddr = *(__be32 *)ip;
254 qos.txtp.traffic_class = ATM_CBR; 254 qos.txtp.traffic_class = ATM_CBR;
255 qos.txtp.max_pcr = tx_pcr; 255 qos.txtp.max_pcr = tx_pcr;
256 qos.txtp.max_sdu = tx_sdu; 256 qos.txtp.max_sdu = tx_sdu;
257 qos.rxtp.traffic_class = ATM_CBR; 257 qos.rxtp.traffic_class = ATM_CBR;
258 qos.rxtp.max_pcr = rx_pcr; 258 qos.rxtp.max_pcr = rx_pcr;
259 qos.rxtp.max_sdu = rx_sdu; 259 qos.rxtp.max_sdu = rx_sdu;
260 qos.aal = ATM_AAL5; 260 qos.aal = ATM_AAL5;
261 dprintk("mpoa: mpoa_proc.c: parse_qos(): setting qos paramameters to tx=%d,%d rx=%d,%d\n", 261 dprintk("mpoa: mpoa_proc.c: parse_qos(): setting qos paramameters to tx=%d,%d rx=%d,%d\n",
262 qos.txtp.max_pcr, 262 qos.txtp.max_pcr,
263 qos.txtp.max_sdu, 263 qos.txtp.max_sdu,
@@ -276,11 +276,11 @@ int mpc_proc_init(void)
276{ 276{
277 struct proc_dir_entry *p; 277 struct proc_dir_entry *p;
278 278
279 p = create_proc_entry(STAT_FILE_NAME, 0, atm_proc_root); 279 p = create_proc_entry(STAT_FILE_NAME, 0, atm_proc_root);
280 if (!p) { 280 if (!p) {
281 printk(KERN_ERR "Unable to initialize /proc/atm/%s\n", STAT_FILE_NAME); 281 printk(KERN_ERR "Unable to initialize /proc/atm/%s\n", STAT_FILE_NAME);
282 return -ENOMEM; 282 return -ENOMEM;
283 } 283 }
284 p->proc_fops = &mpc_file_operations; 284 p->proc_fops = &mpc_file_operations;
285 p->owner = THIS_MODULE; 285 p->owner = THIS_MODULE;
286 return 0; 286 return 0;