Commit 535e2c6a authored by Chas Williams's avatar Chas Williams Committed by Hideaki Yoshifuji

[ATM]: seq_file for /proc/net/atm (vc) [5/8] (from romieu@fr.zoreil.com)

seq_file support for /proc/net/atm/vc:

Same comments as for pvc and svc.

Extra Chas's suggestion applied since last version:
- atm_vc_xxx renamed to vcc_xxx.
parent 2b6aca2d
...@@ -298,29 +298,27 @@ static const char *vcc_state(struct atm_vcc *vcc) ...@@ -298,29 +298,27 @@ static const char *vcc_state(struct atm_vcc *vcc)
return map[ATM_VF2VS(vcc->flags)]; return map[ATM_VF2VS(vcc->flags)];
} }
static void vcc_info(struct seq_file *seq, struct atm_vcc *vcc)
static void vc_info(struct atm_vcc *vcc,char *buf)
{ {
char *here; seq_printf(seq, "%p ", vcc);
if (!vcc->dev)
here = buf+sprintf(buf,"%p ",vcc); seq_printf(seq, "Unassigned ");
if (!vcc->dev) here += sprintf(here,"Unassigned "); else
else here += sprintf(here,"%3d %3d %5d ",vcc->dev->number,vcc->vpi, seq_printf(seq, "%3d %3d %5d ", vcc->dev->number, vcc->vpi,
vcc->vci); vcc->vci);
switch (vcc->sk->sk_family) { switch (vcc->sk->sk_family) {
case AF_ATMPVC: case AF_ATMPVC:
here += sprintf(here,"PVC"); seq_printf(seq, "PVC");
break; break;
case AF_ATMSVC: case AF_ATMSVC:
here += sprintf(here,"SVC"); seq_printf(seq, "SVC");
break; break;
default: default:
here += sprintf(here, "%3d", vcc->sk->sk_family); seq_printf(seq, "%3d", vcc->sk->sk_family);
} }
here += sprintf(here," %04lx %5d %7d/%7d %7d/%7d\n",vcc->flags, seq_printf(seq, " %04lx %5d %7d/%7d %7d/%7d\n", vcc->flags, vcc->sk->sk_err,
vcc->sk->sk_err, atomic_read(&vcc->sk->sk_wmem_alloc),vcc->sk->sk_sndbuf,
atomic_read(&vcc->sk->sk_wmem_alloc), vcc->sk->sk_sndbuf, atomic_read(&vcc->sk->sk_rmem_alloc),vcc->sk->sk_rcvbuf);
atomic_read(&vcc->sk->sk_rmem_alloc), vcc->sk->sk_rcvbuf);
} }
static void svc_info(struct seq_file *seq, struct atm_vcc *vcc) static void svc_info(struct seq_file *seq, struct atm_vcc *vcc)
...@@ -464,31 +462,39 @@ static struct file_operations pvc_seq_fops = { ...@@ -464,31 +462,39 @@ static struct file_operations pvc_seq_fops = {
.release = vcc_seq_release, .release = vcc_seq_release,
}; };
static int atm_vc_info(loff_t pos,char *buf) static int vcc_seq_show(struct seq_file *seq, void *v)
{
if (v == (void *)1) {
seq_printf(seq, sizeof(void *) == 4 ? "%-8s%s" : "%-16s%s",
"Address ", "Itf VPI VCI Fam Flags Reply "
"Send buffer Recv buffer\n");
} else {
struct vcc_state *state = seq->private;
struct atm_vcc *vcc = atm_sk(state->sk);
vcc_info(seq, vcc);
}
return 0;
}
static struct seq_operations vcc_seq_ops = {
.start = vcc_seq_start,
.next = vcc_seq_next,
.stop = vcc_seq_stop,
.show = vcc_seq_show,
};
static int vcc_seq_open(struct inode *inode, struct file *file)
{ {
struct atm_vcc *vcc; return __vcc_seq_open(inode, file, 0, &vcc_seq_ops);
struct hlist_node *node;
struct sock *s;
int left;
if (!pos)
return sprintf(buf,sizeof(void *) == 4 ? "%-8s%s" : "%-16s%s",
"Address"," Itf VPI VCI Fam Flags Reply Send buffer"
" Recv buffer\n");
left = pos-1;
read_lock(&vcc_sklist_lock);
sk_for_each(s, node, &vcc_sklist) {
vcc = atm_sk(s);
if (!left--) {
vc_info(vcc,buf);
read_unlock(&vcc_sklist_lock);
return strlen(buf);
}
}
read_unlock(&vcc_sklist_lock);
return 0;
} }
static struct file_operations vcc_seq_fops = {
.open = vcc_seq_open,
.read = seq_read,
.llseek = seq_lseek,
.release = vcc_seq_release,
};
static int svc_seq_show(struct seq_file *seq, void *v) static int svc_seq_show(struct seq_file *seq, void *v)
{ {
...@@ -751,7 +757,7 @@ void atm_proc_dev_deregister(struct atm_dev *dev) ...@@ -751,7 +757,7 @@ void atm_proc_dev_deregister(struct atm_dev *dev)
name->owner = THIS_MODULE name->owner = THIS_MODULE
static struct proc_dir_entry *devices = NULL, *pvc = NULL, static struct proc_dir_entry *devices = NULL, *pvc = NULL,
*svc = NULL, *arp = NULL, *lec = NULL, *vc = NULL; *svc = NULL, *arp = NULL, *lec = NULL, *vcc = NULL;
static void atm_proc_cleanup(void) static void atm_proc_cleanup(void)
{ {
...@@ -765,8 +771,8 @@ static void atm_proc_cleanup(void) ...@@ -765,8 +771,8 @@ static void atm_proc_cleanup(void)
remove_proc_entry("arp",atm_proc_root); remove_proc_entry("arp",atm_proc_root);
if (lec) if (lec)
remove_proc_entry("lec",atm_proc_root); remove_proc_entry("lec",atm_proc_root);
if (vc) if (vcc)
remove_proc_entry("vc",atm_proc_root); remove_proc_entry("vcc",atm_proc_root);
remove_proc_entry("net/atm",NULL); remove_proc_entry("net/atm",NULL);
} }
...@@ -778,7 +784,7 @@ int __init atm_proc_init(void) ...@@ -778,7 +784,7 @@ int __init atm_proc_init(void)
CREATE_SEQ_ENTRY(devices); CREATE_SEQ_ENTRY(devices);
CREATE_SEQ_ENTRY(pvc); CREATE_SEQ_ENTRY(pvc);
CREATE_SEQ_ENTRY(svc); CREATE_SEQ_ENTRY(svc);
CREATE_ENTRY(vc); CREATE_SEQ_ENTRY(vcc);
#if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE) #if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE)
CREATE_ENTRY(arp); CREATE_ENTRY(arp);
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment