Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
net-tools
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
net-tools
Commits
47af40ad
Commit
47af40ad
authored
Dec 05, 2002
by
Bernd Eckenfels
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better ioctl fallback handling for interface listing, avoids duplicate
interfaces, thanks for the help from Bruno Hall.
parent
e2bee14f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
12 deletions
+23
-12
lib/interface.c
lib/interface.c
+23
-12
No files found.
lib/interface.c
View file @
47af40ad
...
...
@@ -7,7 +7,7 @@
8/2000 Andi Kleen make the list operations a bit more efficient.
People are crazy enough to use thousands of aliases now.
$Id: interface.c,v 1.2
4 2002/06/14 01:33
:50 ecki Exp $
$Id: interface.c,v 1.2
5 2002/12/05 21:54
:50 ecki Exp $
*/
#include "config.h"
...
...
@@ -87,6 +87,8 @@ int procnetdev_vsn = 1;
int
ife_short
;
int
if_list_all
=
0
;
/* do we have requested the complete proc list, yet? */
static
struct
interface
*
int_list
,
*
int_last
;
static
int
if_readlist_proc
(
char
*
);
...
...
@@ -120,19 +122,22 @@ static struct interface *if_cache_add(char *name)
struct
interface
*
lookup_interface
(
char
*
name
)
{
struct
interface
*
ife
=
NULL
;
if
(
if_readlist_proc
(
name
)
<
0
)
return
NULL
;
ife
=
if_cache_add
(
name
);
return
ife
;
/* if we have read all, use it */
if
(
if_list_all
)
return
if_cache_add
(
name
);
/* otherwise we read a limited list */
if
(
if_readlist_proc
(
name
)
<
0
)
return
NULL
;
return
if_cache_add
(
name
);
}
int
for_all_interfaces
(
int
(
*
doit
)
(
struct
interface
*
,
void
*
),
void
*
cookie
)
{
struct
interface
*
ife
;
if
(
!
int_list
&&
(
if_readlist
()
<
0
))
if
(
!
int_list
_all
&&
(
if_readlist
()
<
0
))
return
-
1
;
for
(
ife
=
int_list
;
ife
;
ife
=
ife
->
next
)
{
int
err
=
doit
(
ife
,
cookie
);
...
...
@@ -150,6 +155,7 @@ int if_cache_free(void)
free
(
ife
);
}
int_last
=
NULL
;
int_list_all
=
0
;
return
0
;
}
...
...
@@ -316,7 +322,7 @@ static int if_readlist_proc(char *target)
if
(
!
fh
)
{
fprintf
(
stderr
,
_
(
"Warning: cannot open %s (%s). Limited output.
\n
"
),
_PATH_PROCNET_DEV
,
strerror
(
errno
));
return
if_readconf
()
;
return
-
2
;
}
fgets
(
buf
,
sizeof
buf
,
fh
);
/* eat line */
fgets
(
buf
,
sizeof
buf
,
fh
);
...
...
@@ -372,11 +378,16 @@ static int if_readlist_proc(char *target)
int
if_readlist
(
void
)
{
/* caller will/should check not to call this too often
* (i.e. only if int_list
!= NULL
* (i.e. only if int_list
_all == 0
*/
int
err
=
if_readlist_proc
(
NULL
);
if
(
!
err
)
err
=
if_readconf
();
if
(
err
)
err
=
if_readconf
();
if
(
!
err
)
if_list_all
=
1
;
return
err
;
}
...
...
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