Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
1f01cc36
Commit
1f01cc36
authored
Nov 24, 2002
by
Arnaldo Carvalho de Melo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
o wireless: convert /proc/net/wireless to seq_file
parent
5d0d0e11
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
72 deletions
+85
-72
net/core/dev.c
net/core/dev.c
+16
-6
net/core/wireless.c
net/core/wireless.c
+69
-66
No files found.
net/core/dev.c
View file @
1f01cc36
...
@@ -1737,18 +1737,18 @@ static __inline__ struct net_device *dev_get_idx(struct seq_file *seq,
...
@@ -1737,18 +1737,18 @@ static __inline__ struct net_device *dev_get_idx(struct seq_file *seq,
return
i
==
pos
?
dev
:
NULL
;
return
i
==
pos
?
dev
:
NULL
;
}
}
static
void
*
dev_seq_start
(
struct
seq_file
*
seq
,
loff_t
*
pos
)
void
*
dev_seq_start
(
struct
seq_file
*
seq
,
loff_t
*
pos
)
{
{
read_lock
(
&
dev_base_lock
);
read_lock
(
&
dev_base_lock
);
return
*
pos
?
dev_get_idx
(
seq
,
*
pos
)
:
(
void
*
)
1
;
return
*
pos
?
dev_get_idx
(
seq
,
*
pos
)
:
(
void
*
)
1
;
}
}
static
void
*
dev_seq_next
(
struct
seq_file
*
seq
,
void
*
v
,
loff_t
*
pos
)
void
*
dev_seq_next
(
struct
seq_file
*
seq
,
void
*
v
,
loff_t
*
pos
)
{
{
return
v
==
(
void
*
)
1
?
dev_base
:
((
struct
net_device
*
)
v
)
->
next
;
return
v
==
(
void
*
)
1
?
dev_base
:
((
struct
net_device
*
)
v
)
->
next
;
}
}
static
void
dev_seq_stop
(
struct
seq_file
*
seq
,
void
*
v
)
void
dev_seq_stop
(
struct
seq_file
*
seq
,
void
*
v
)
{
{
read_unlock
(
&
dev_base_lock
);
read_unlock
(
&
dev_base_lock
);
}
}
...
@@ -1856,6 +1856,14 @@ static struct file_operations dev_seq_fops = {
...
@@ -1856,6 +1856,14 @@ static struct file_operations dev_seq_fops = {
.
release
=
seq_release
,
.
release
=
seq_release
,
};
};
#ifdef WIRELESS_EXT
extern
int
wireless_proc_init
(
void
);
extern
int
wireless_proc_exit
(
void
);
#else
#define wireless_proc_init() 0
#define wireless_proc_exit()
#endif
static
int
__init
dev_proc_init
(
void
)
static
int
__init
dev_proc_init
(
void
)
{
{
struct
proc_dir_entry
*
p
;
struct
proc_dir_entry
*
p
;
...
@@ -1865,13 +1873,15 @@ static int __init dev_proc_init(void)
...
@@ -1865,13 +1873,15 @@ static int __init dev_proc_init(void)
if
(
!
p
)
if
(
!
p
)
goto
out
;
goto
out
;
p
->
proc_fops
=
&
dev_seq_fops
;
p
->
proc_fops
=
&
dev_seq_fops
;
if
(
wireless_proc_init
())
goto
out_dev
;
create_proc_read_entry
(
"net/softnet_stat"
,
0
,
0
,
dev_proc_stats
,
NULL
);
create_proc_read_entry
(
"net/softnet_stat"
,
0
,
0
,
dev_proc_stats
,
NULL
);
#ifdef WIRELESS_EXT
proc_net_create
(
"wireless"
,
0
,
dev_get_wireless_info
);
#endif
rc
=
0
;
rc
=
0
;
out:
out:
return
rc
;
return
rc
;
out_dev:
remove_proc_entry
(
"dev"
,
proc_net
);
goto
out
;
}
}
#else
#else
#define dev_proc_init() 0
#define dev_proc_init() 0
...
...
net/core/wireless.c
View file @
1f01cc36
...
@@ -47,15 +47,18 @@
...
@@ -47,15 +47,18 @@
/***************************** INCLUDES *****************************/
/***************************** INCLUDES *****************************/
#include <asm/uaccess.h>
/* copy_to_user() */
#include <linux/config.h>
/* Not needed ??? */
#include <linux/config.h>
/* Not needed ??? */
#include <linux/types.h>
/* off_t */
#include <linux/types.h>
/* off_t */
#include <linux/netdevice.h>
/* struct ifreq, dev_get_by_name() */
#include <linux/netdevice.h>
/* struct ifreq, dev_get_by_name() */
#include <linux/proc_fs.h>
#include <linux/rtnetlink.h>
/* rtnetlink stuff */
#include <linux/rtnetlink.h>
/* rtnetlink stuff */
#include <linux/seq_file.h>
#include <linux/wireless.h>
/* Pretty obvious */
#include <linux/wireless.h>
/* Pretty obvious */
#include <net/iw_handler.h>
/* New driver API */
#include <net/iw_handler.h>
/* New driver API */
#include <asm/uaccess.h>
/* copy_to_user() */
/**************************** CONSTANTS ****************************/
/**************************** CONSTANTS ****************************/
/* Enough lenience, let's make sure things are proper... */
/* Enough lenience, let's make sure things are proper... */
...
@@ -330,83 +333,83 @@ static inline int get_priv_size(__u16 args)
...
@@ -330,83 +333,83 @@ static inline int get_priv_size(__u16 args)
/*
/*
* Print one entry (line) of /proc/net/wireless
* Print one entry (line) of /proc/net/wireless
*/
*/
static
inline
int
sprintf_wireless_stats
(
char
*
buffer
,
struct
net_device
*
dev
)
static
__inline__
void
wireless_seq_printf_stats
(
struct
seq_file
*
seq
,
struct
net_device
*
dev
)
{
{
/* Get stats from the driver */
/* Get stats from the driver */
struct
iw_statistics
*
stats
;
struct
iw_statistics
*
stats
=
get_wireless_stats
(
dev
);
int
size
;
if
(
stats
)
{
stats
=
get_wireless_stats
(
dev
);
seq_printf
(
seq
,
"%6s: %04x %3d%c %3d%c %3d%c %6d %6d %6d "
if
(
stats
!=
(
struct
iw_statistics
*
)
NULL
)
{
"%6d %6d %6d
\n
"
,
size
=
sprintf
(
buffer
,
dev
->
name
,
stats
->
status
,
stats
->
qual
.
qual
,
"%6s: %04x %3d%c %3d%c %3d%c %6d %6d %6d %6d %6d %6d
\n
"
,
stats
->
qual
.
updated
&
1
?
'.'
:
' '
,
dev
->
name
,
((
__u8
)
stats
->
qual
.
level
),
stats
->
status
,
stats
->
qual
.
updated
&
2
?
'.'
:
' '
,
stats
->
qual
.
qual
,
((
__u8
)
stats
->
qual
.
noise
),
stats
->
qual
.
updated
&
1
?
'.'
:
' '
,
stats
->
qual
.
updated
&
4
?
'.'
:
' '
,
((
__u8
)
stats
->
qual
.
level
),
stats
->
discard
.
nwid
,
stats
->
discard
.
code
,
stats
->
qual
.
updated
&
2
?
'.'
:
' '
,
stats
->
discard
.
fragment
,
stats
->
discard
.
retries
,
((
__u8
)
stats
->
qual
.
noise
),
stats
->
discard
.
misc
,
stats
->
miss
.
beacon
);
stats
->
qual
.
updated
&
4
?
'.'
:
' '
,
stats
->
discard
.
nwid
,
stats
->
discard
.
code
,
stats
->
discard
.
fragment
,
stats
->
discard
.
retries
,
stats
->
discard
.
misc
,
stats
->
miss
.
beacon
);
stats
->
qual
.
updated
=
0
;
stats
->
qual
.
updated
=
0
;
}
}
else
size
=
0
;
return
size
;
}
}
/* ---------------------------------------------------------------- */
/* ---------------------------------------------------------------- */
/*
/*
* Print info for /proc/net/wireless (print all entries)
* Print info for /proc/net/wireless (print all entries)
*/
*/
int
dev_get_wireless_info
(
char
*
buffer
,
char
**
start
,
off_t
offset
,
static
int
wireless_seq_show
(
struct
seq_file
*
seq
,
void
*
v
)
int
length
)
{
{
int
len
=
0
;
if
(
v
==
(
void
*
)
1
)
off_t
begin
=
0
;
seq_printf
(
seq
,
"Inter-| sta-| Quality | Discarded "
off_t
pos
=
0
;
"packets | Missed
\n
"
int
size
;
" face | tus | link level noise | nwid "
"crypt frag retry misc | beacon
\n
"
);
struct
net_device
*
dev
;
else
wireless_seq_printf_stats
(
seq
,
v
);
size
=
sprintf
(
buffer
,
return
0
;
"Inter-| sta-| Quality | Discarded packets | Missed
\n
"
}
" face | tus | link level noise | nwid crypt frag retry misc | beacon
\n
"
);
extern
void
*
dev_seq_start
(
struct
seq_file
*
seq
,
loff_t
*
pos
);
extern
void
*
dev_seq_next
(
struct
seq_file
*
seq
,
void
*
v
,
loff_t
*
pos
);
pos
+=
size
;
extern
void
dev_seq_stop
(
struct
seq_file
*
seq
,
void
*
v
);
len
+=
size
;
static
struct
seq_operations
wireless_seq_ops
=
{
read_lock
(
&
dev_base_lock
);
.
start
=
dev_seq_start
,
for
(
dev
=
dev_base
;
dev
!=
NULL
;
dev
=
dev
->
next
)
{
.
next
=
dev_seq_next
,
size
=
sprintf_wireless_stats
(
buffer
+
len
,
dev
);
.
stop
=
dev_seq_stop
,
len
+=
size
;
.
show
=
wireless_seq_show
,
pos
=
begin
+
len
;
};
if
(
pos
<
offset
)
{
len
=
0
;
begin
=
pos
;
}
if
(
pos
>
offset
+
length
)
break
;
}
read_unlock
(
&
dev_base_lock
);
*
start
=
buffer
+
(
offset
-
begin
);
/* Start of wanted data */
static
int
wireless_seq_open
(
struct
inode
*
inode
,
struct
file
*
file
)
len
-=
(
offset
-
begin
);
/* Start slop */
{
if
(
len
>
length
)
return
seq_open
(
file
,
&
wireless_seq_ops
);
len
=
length
;
/* Ending slop */
}
if
(
len
<
0
)
len
=
0
;
return
len
;
static
struct
file_operations
wireless_seq_fops
=
{
.
open
=
wireless_seq_open
,
.
read
=
seq_read
,
.
llseek
=
seq_lseek
,
.
release
=
seq_release
,
};
int
__init
wireless_proc_init
(
void
)
{
struct
proc_dir_entry
*
p
;
int
rc
=
0
;
p
=
create_proc_entry
(
"wireless"
,
S_IRUGO
,
proc_net
);
if
(
p
)
p
->
proc_fops
=
&
wireless_seq_fops
;
else
rc
=
-
ENOMEM
;
return
rc
;
}
void
__init
wireless_proc_exit
(
void
)
{
remove_proc_entry
(
"wireless"
,
proc_net
);
}
}
#endif
/* CONFIG_PROC_FS */
#endif
/* CONFIG_PROC_FS */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment