Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
7c3dadb0
Commit
7c3dadb0
authored
May 09, 2016
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(interfaces.lib.inc) extend legacy_interface_stats to support "fetch all interfaces"
parent
99aa186e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
10 deletions
+20
-10
interfaces.lib.inc
src/etc/inc/interfaces.lib.inc
+20
-10
No files found.
src/etc/inc/interfaces.lib.inc
View file @
7c3dadb0
...
...
@@ -149,9 +149,15 @@ function legacy_vlan_tag($ifs, $member, $tag)
}
}
function
legacy_interface_stats
(
$ifs
)
function
legacy_interface_stats
(
$ifs
=
null
)
{
$cmd
=
'/usr/local/sbin/ifinfo '
.
escapeshellarg
(
$ifs
);
if
(
$ifs
!=
null
)
{
// only request data for selected interface
$cmd
=
'/usr/local/sbin/ifinfo '
.
escapeshellarg
(
$ifs
);
}
else
{
// all interfaces
$cmd
=
'/usr/local/sbin/ifinfo'
;
}
$stats
=
array
();
exec
(
$cmd
.
' 2>&1'
,
$out
,
$ret
);
...
...
@@ -160,17 +166,21 @@ function legacy_interface_stats($ifs)
return
$stats
;
}
if
(
count
(
$out
))
{
/* first one is header */
array_shift
(
$out
);
foreach
(
$out
as
$line
)
{
$current_interface
=
""
;
foreach
(
$out
as
$line
)
{
if
(
strpos
(
$line
,
'Interface'
)
===
0
)
{
$current_interface
=
explode
(
')'
,
explode
(
'('
,
$line
)[
1
])[
0
];
$stats
[
$current_interface
]
=
array
();
}
elseif
(
$current_interface
!=
""
)
{
$stat
=
explode
(
':'
,
$line
);
$stats
[
trim
(
$stat
[
0
])]
=
trim
(
$stat
[
1
]);
$stats
[
$current_interface
][
trim
(
$stat
[
0
])]
=
trim
(
$stat
[
1
]);
}
}
return
$stats
;
if
(
$ifs
!=
null
)
{
return
$stats
[
$current_interface
];
}
else
{
return
$stats
;
}
}
/**
...
...
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