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
247134f7
Commit
247134f7
authored
Dec 28, 2015
by
Ad Schellevis
Committed by
Franco Fichtner
Jan 08, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change some spacing (2 tabs -> 4 spaces)
(cherry picked from commit
08913f70
)
parent
97600872
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
115 additions
and
115 deletions
+115
-115
interfaces.lib.inc
src/etc/inc/interfaces.lib.inc
+115
-115
No files found.
src/etc/inc/interfaces.lib.inc
View file @
247134f7
<?php
/*
Copyright (c) 2015 Franco Fichtner <franco@opnsense.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Copyright (c) 2015 Franco Fichtner <franco@opnsense.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
function
legacy_interface_listget
(
$flag
=
''
)
{
$cmd
=
'/sbin/ifconfig -l'
;
$ifs
=
null
;
if
(
$flag
===
'up'
)
{
$cmd
.=
'u'
;
}
else
if
(
$flag
===
'down'
)
{
$cmd
.=
'd'
;
}
exec
(
$cmd
.
' 2>&1'
,
$out
,
$ret
);
if
(
$ret
)
{
log_error
(
'The command `'
.
$cmd
.
'\' failed to execute'
);
return
(
$ifs
);
}
if
(
isset
(
$out
[
0
]))
{
$ifs
=
explode
(
' '
,
$out
[
0
]);
}
return
(
$ifs
);
$cmd
=
'/sbin/ifconfig -l'
;
$ifs
=
null
;
if
(
$flag
===
'up'
)
{
$cmd
.=
'u'
;
}
else
if
(
$flag
===
'down'
)
{
$cmd
.=
'd'
;
}
exec
(
$cmd
.
' 2>&1'
,
$out
,
$ret
);
if
(
$ret
)
{
log_error
(
'The command `'
.
$cmd
.
'\' failed to execute'
);
return
(
$ifs
);
}
if
(
isset
(
$out
[
0
]))
{
$ifs
=
explode
(
' '
,
$out
[
0
]);
}
return
(
$ifs
);
}
function
legacy_interface_flags
(
$ifs
,
$flag
,
$report_errors
=
true
)
{
/* $flags isn't escaped because it can be an argument list */
$cmd
=
'/sbin/ifconfig '
.
escapeshellarg
(
$ifs
)
.
' '
.
$flag
;
/* $flags isn't escaped because it can be an argument list */
$cmd
=
'/sbin/ifconfig '
.
escapeshellarg
(
$ifs
)
.
' '
.
$flag
;
exec
(
$cmd
.
' 2>&1'
,
$out
,
$ret
);
if
(
!
empty
(
$ret
)
&&
$report_errors
)
{
log_error
(
'The command `'
.
$cmd
.
'\' failed to execute'
);
}
exec
(
$cmd
.
' 2>&1'
,
$out
,
$ret
);
if
(
!
empty
(
$ret
)
&&
$report_errors
)
{
log_error
(
'The command `'
.
$cmd
.
'\' failed to execute'
);
}
}
function
legacy_interface_create
(
$ifs
)
{
$cmd
=
'/sbin/ifconfig '
.
escapeshellarg
(
$ifs
)
.
' create'
;
$new
=
null
;
$cmd
=
'/sbin/ifconfig '
.
escapeshellarg
(
$ifs
)
.
' create'
;
$new
=
null
;
exec
(
$cmd
.
' 2>&1'
,
$out
,
$ret
);
if
(
$ret
)
{
log_error
(
'The command `'
.
$cmd
.
'\' failed to execute'
);
return
(
$new
);
}
exec
(
$cmd
.
' 2>&1'
,
$out
,
$ret
);
if
(
$ret
)
{
log_error
(
'The command `'
.
$cmd
.
'\' failed to execute'
);
return
(
$new
);
}
if
(
isset
(
$out
[
0
]))
{
$new
=
$out
[
0
];
}
if
(
isset
(
$out
[
0
]))
{
$new
=
$out
[
0
];
}
return
(
$new
);
return
(
$new
);
}
function
legacy_interface_destroy
(
$ifs
)
{
$cmd
=
'/sbin/ifconfig '
.
escapeshellarg
(
$ifs
)
.
' destroy'
;
$cmd
=
'/sbin/ifconfig '
.
escapeshellarg
(
$ifs
)
.
' destroy'
;
exec
(
$cmd
.
' 2>&1'
,
$out
,
$ret
);
if
(
$ret
)
{
log_error
(
'The command `'
.
$cmd
.
'\' failed to execute'
);
}
exec
(
$cmd
.
' 2>&1'
,
$out
,
$ret
);
if
(
$ret
)
{
log_error
(
'The command `'
.
$cmd
.
'\' failed to execute'
);
}
}
function
legacy_interface_setaddress
(
$ifs
,
$addr
)
{
$cmd
=
'/sbin/ifconfig '
.
escapeshellarg
(
$ifs
)
.
' alias '
.
escapeshellarg
(
$addr
);
$cmd
=
'/sbin/ifconfig '
.
escapeshellarg
(
$ifs
)
.
' alias '
.
escapeshellarg
(
$addr
);
exec
(
$cmd
.
' 2>&1'
,
$out
,
$ret
);
if
(
$ret
)
{
log_error
(
'The command `'
.
$cmd
.
'\' failed to execute'
);
}
exec
(
$cmd
.
' 2>&1'
,
$out
,
$ret
);
if
(
$ret
)
{
log_error
(
'The command `'
.
$cmd
.
'\' failed to execute'
);
}
}
function
legacy_interface_deladdress
(
$ifs
,
$addr
)
{
$cmd
=
'/sbin/ifconfig '
.
escapeshellarg
(
$ifs
)
.
' -alias '
.
escapeshellarg
(
$addr
);
$cmd
=
'/sbin/ifconfig '
.
escapeshellarg
(
$ifs
)
.
' -alias '
.
escapeshellarg
(
$addr
);
exec
(
$cmd
.
' 2>&1'
,
$out
,
$ret
);
if
(
$ret
)
{
log_error
(
'The command `'
.
$cmd
.
'\' failed to execute'
);
}
exec
(
$cmd
.
' 2>&1'
,
$out
,
$ret
);
if
(
$ret
)
{
log_error
(
'The command `'
.
$cmd
.
'\' failed to execute'
);
}
}
function
legacy_interface_rename
(
$ifs
,
$name
)
{
$cmd
=
'/sbin/ifconfig '
.
escapeshellarg
(
$ifs
)
.
' name '
.
escapeshellarg
(
$name
);
$cmd
=
'/sbin/ifconfig '
.
escapeshellarg
(
$ifs
)
.
' name '
.
escapeshellarg
(
$name
);
exec
(
$cmd
.
' 2>&1'
,
$out
,
$ret
);
if
(
$ret
)
{
log_error
(
'The command `'
.
$cmd
.
'\' failed to execute'
);
}
exec
(
$cmd
.
' 2>&1'
,
$out
,
$ret
);
if
(
$ret
)
{
log_error
(
'The command `'
.
$cmd
.
'\' failed to execute'
);
}
}
function
legacy_interface_mtu
(
$ifs
,
$mtu
)
{
$cmd
=
'/sbin/ifconfig '
.
escapeshellarg
(
$ifs
)
.
' mtu '
.
escapeshellarg
(
$mtu
);
$cmd
=
'/sbin/ifconfig '
.
escapeshellarg
(
$ifs
)
.
' mtu '
.
escapeshellarg
(
$mtu
);
exec
(
$cmd
.
' 2>&1'
,
$out
,
$ret
);
if
(
$ret
)
{
log_error
(
'The command `'
.
$cmd
.
'\' failed to execute'
);
}
exec
(
$cmd
.
' 2>&1'
,
$out
,
$ret
);
if
(
$ret
)
{
log_error
(
'The command `'
.
$cmd
.
'\' failed to execute'
);
}
}
function
legacy_bridge_member
(
$ifs
,
$member
)
{
$cmd
=
'/sbin/ifconfig '
.
escapeshellarg
(
$ifs
)
.
' addm '
.
escapeshellarg
(
$member
);
$cmd
=
'/sbin/ifconfig '
.
escapeshellarg
(
$ifs
)
.
' addm '
.
escapeshellarg
(
$member
);
exec
(
$cmd
.
' 2>&1'
,
$out
,
$ret
);
if
(
$ret
)
{
log_error
(
'The command `'
.
$cmd
.
'\' failed to execute'
);
}
exec
(
$cmd
.
' 2>&1'
,
$out
,
$ret
);
if
(
$ret
)
{
log_error
(
'The command `'
.
$cmd
.
'\' failed to execute'
);
}
}
function
legacy_vlan_tag
(
$ifs
,
$member
,
$tag
)
{
$cmd
=
'/sbin/ifconfig '
.
escapeshellarg
(
$ifs
)
.
' vlandev '
.
escapeshellarg
(
$member
)
.
' vlan '
.
escapeshellarg
(
$tag
);
$cmd
=
'/sbin/ifconfig '
.
escapeshellarg
(
$ifs
)
.
' vlandev '
.
escapeshellarg
(
$member
)
.
' vlan '
.
escapeshellarg
(
$tag
);
exec
(
$cmd
.
' 2>&1'
,
$out
,
$ret
);
if
(
$ret
)
{
log_error
(
'The command `'
.
$cmd
.
'\' failed to execute'
);
}
exec
(
$cmd
.
' 2>&1'
,
$out
,
$ret
);
if
(
$ret
)
{
log_error
(
'The command `'
.
$cmd
.
'\' failed to execute'
);
}
}
function
legacy_interface_stats
(
$ifs
)
{
$cmd
=
'/usr/local/sbin/ifinfo '
.
escapeshellarg
(
$ifs
);
$stats
=
array
();
exec
(
$cmd
.
' 2>&1'
,
$out
,
$ret
);
if
(
$ret
)
{
log_error
(
'The command `'
.
$cmd
.
'\' failed to execute'
);
return
$stats
;
}
if
(
count
(
$out
))
{
/* first one is header */
array_shift
(
$out
);
foreach
(
$out
as
$line
)
{
$stat
=
explode
(
':'
,
$line
);
$stats
[
trim
(
$stat
[
0
])]
=
trim
(
$stat
[
1
]);
}
}
return
$stats
;
$cmd
=
'/usr/local/sbin/ifinfo '
.
escapeshellarg
(
$ifs
);
$stats
=
array
();
exec
(
$cmd
.
' 2>&1'
,
$out
,
$ret
);
if
(
$ret
)
{
log_error
(
'The command `'
.
$cmd
.
'\' failed to execute'
);
return
$stats
;
}
if
(
count
(
$out
))
{
/* first one is header */
array_shift
(
$out
);
foreach
(
$out
as
$line
)
{
$stat
=
explode
(
':'
,
$line
);
$stats
[
trim
(
$stat
[
0
])]
=
trim
(
$stat
[
1
]);
}
}
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