2 * This file implement the Wireless Extensions proc API.
4 * Authors : Jean Tourrilhes - HPL - <jt@hpl.hp.com>
5 * Copyright (c) 1997-2007 Jean Tourrilhes, All Rights Reserved.
7 * (As all part of the Linux kernel, this file is GPL)
11 * The /proc/net/wireless file is a human readable user-space interface
12 * exporting various wireless specific statistics from the wireless devices.
13 * This is the most popular part of the Wireless Extensions ;-)
15 * This interface is a pure clone of /proc/net/dev (in net/core/dev.c).
16 * The content of the file is basically the content of "struct iw_statistics".
19 #include <linux/module.h>
20 #include <linux/proc_fs.h>
21 #include <linux/seq_file.h>
22 #include <linux/wireless.h>
23 #include <linux/netdevice.h>
24 #include <linux/rtnetlink.h>
25 #include <net/iw_handler.h>
29 static void wireless_seq_printf_stats(struct seq_file *seq,
30 struct net_device *dev)
32 /* Get stats from the driver */
33 struct iw_statistics *stats = get_wireless_stats(dev);
34 static struct iw_statistics nullstats = {};
36 /* show device if it's wireless regardless of current stats */
38 #ifdef CONFIG_WIRELESS_EXT
39 if (dev->wireless_handlers)
42 #ifdef CONFIG_CFG80211
43 if (dev->ieee80211_ptr)
49 seq_printf(seq, "%6s: %04x %3d%c %3d%c %3d%c %6d %6d %6d "
51 dev->name, stats->status, stats->qual.qual,
52 stats->qual.updated & IW_QUAL_QUAL_UPDATED
54 ((__s32) stats->qual.level) -
55 ((stats->qual.updated & IW_QUAL_DBM) ? 0x100 : 0),
56 stats->qual.updated & IW_QUAL_LEVEL_UPDATED
58 ((__s32) stats->qual.noise) -
59 ((stats->qual.updated & IW_QUAL_DBM) ? 0x100 : 0),
60 stats->qual.updated & IW_QUAL_NOISE_UPDATED
62 stats->discard.nwid, stats->discard.code,
63 stats->discard.fragment, stats->discard.retries,
64 stats->discard.misc, stats->miss.beacon);
66 if (stats != &nullstats)
67 stats->qual.updated &= ~IW_QUAL_ALL_UPDATED;
71 /* ---------------------------------------------------------------- */
73 * Print info for /proc/net/wireless (print all entries)
75 static int wireless_dev_seq_show(struct seq_file *seq, void *v)
79 if (v == SEQ_START_TOKEN)
80 seq_printf(seq, "Inter-| sta-| Quality | Discarded "
81 "packets | Missed | WE\n"
82 " face | tus | link level noise | nwid "
83 "crypt frag retry misc | beacon | %d\n",
86 wireless_seq_printf_stats(seq, v);
90 static void *wireless_dev_seq_start(struct seq_file *seq, loff_t *pos)
92 struct net *net = seq_file_net(seq);
94 struct net_device *dev;
98 return SEQ_START_TOKEN;
101 for_each_netdev(net, dev)
107 static void *wireless_dev_seq_next(struct seq_file *seq, void *v, loff_t *pos)
109 struct net *net = seq_file_net(seq);
113 return v == SEQ_START_TOKEN ?
114 first_net_device(net) : next_net_device(v);
117 static void wireless_dev_seq_stop(struct seq_file *seq, void *v)
122 static const struct seq_operations wireless_seq_ops = {
123 .start = wireless_dev_seq_start,
124 .next = wireless_dev_seq_next,
125 .stop = wireless_dev_seq_stop,
126 .show = wireless_dev_seq_show,
129 static int seq_open_wireless(struct inode *inode, struct file *file)
131 return seq_open_net(inode, file, &wireless_seq_ops,
132 sizeof(struct seq_net_private));
135 static const struct file_operations wireless_seq_fops = {
136 .owner = THIS_MODULE,
137 .open = seq_open_wireless,
140 .release = seq_release_net,
143 int __net_init wext_proc_init(struct net *net)
145 /* Create /proc/net/wireless entry */
146 if (!proc_create("wireless", S_IRUGO, net->proc_net,
153 void __net_exit wext_proc_exit(struct net *net)
155 remove_proc_entry("wireless", net->proc_net);