Source
x
/*
* atalk_proc.c - proc support for Appletalk
*
* Copyright(c) Arnaldo Carvalho de Melo <acme@conectiva.com.br>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, version 2.
*/
static __inline__ struct atalk_iface *atalk_get_interface_idx(loff_t pos)
{
struct atalk_iface *i;
for (i = atalk_interfaces; pos && i; i = i->next)
--pos;
return i;
}
static void *atalk_seq_interface_start(struct seq_file *seq, loff_t *pos)
__acquires(atalk_interfaces_lock)
{
loff_t l = *pos;
read_lock_bh(&atalk_interfaces_lock);
return l ? atalk_get_interface_idx(--l) : SEQ_START_TOKEN;
}
static void *atalk_seq_interface_next(struct seq_file *seq, void *v, loff_t *pos)
{
struct atalk_iface *i;
++*pos;
if (v == SEQ_START_TOKEN) {
i = NULL;
if (atalk_interfaces)
i = atalk_interfaces;
goto out;
}
i = v;
i = i->next;
out:
return i;
}
static void atalk_seq_interface_stop(struct seq_file *seq, void *v)
__releases(atalk_interfaces_lock)
{
read_unlock_bh(&atalk_interfaces_lock);
}
static int atalk_seq_interface_show(struct seq_file *seq, void *v)
{
struct atalk_iface *iface;
if (v == SEQ_START_TOKEN) {
seq_puts(seq, "Interface Address Networks "
"Status\n");
goto out;
}
iface = v;
seq_printf(seq, "%-16s %04X:%02X %04X-%04X %d\n",
iface->dev->name, ntohs(iface->address.s_net),
iface->address.s_node, ntohs(iface->nets.nr_firstnet),
ntohs(iface->nets.nr_lastnet), iface->status);
out:
return 0;
}
static __inline__ struct atalk_route *atalk_get_route_idx(loff_t pos)
{
struct atalk_route *r;
for (r = atalk_routes; pos && r; r = r->next)
--pos;
return r;
}
static void *atalk_seq_route_start(struct seq_file *seq, loff_t *pos)
__acquires(atalk_routes_lock)