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
8a7ba132
Commit
8a7ba132
authored
Jul 08, 2015
by
Ad Schellevis
Committed by
Franco Fichtner
Jul 20, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(legacy) cleanups related to interfaces.inc (remove unused, move single usage, isset issues)
parent
eb03dc1a
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
214 additions
and
295 deletions
+214
-295
interfaces.inc
src/etc/inc/interfaces.inc
+55
-295
legacy.inc
src/etc/inc/xmlrpc/legacy.inc
+36
-0
carp_status.php
src/www/carp_status.php
+20
-0
interfaces.php
src/www/interfaces.php
+68
-0
wizard.php
src/www/wizard.php
+35
-0
No files found.
src/etc/inc/interfaces.inc
View file @
8a7ba132
...
...
@@ -115,40 +115,6 @@ function does_interface_exist($interface, $flush = true) {
return
false
;
}
/*
* does_vip_exist($vip): return true or false if a vip is
* configured.
*/
function
does_vip_exist
(
$vip
)
{
global
$config
;
if
(
!
$vip
)
return
false
;
switch
(
$vip
[
'mode'
])
{
case
"carp"
:
case
"ipalias"
:
/* XXX: Make proper checks? */
$realif
=
get_real_interface
(
$vip
[
'interface'
]);
if
(
!
does_interface_exist
(
$realif
))
{
return
false
;
}
break
;
case
"proxyarp"
:
/* XXX: Implement this */
default
:
return
false
;
}
$ifacedata
=
pfSense_getall_interface_addresses
(
$realif
);
foreach
(
$ifacedata
as
$vipips
)
{
if
(
$vipips
==
"
{
$vip
[
'subnet'
]
}
/
{
$vip
[
'subnet_bits'
]
}
"
)
return
true
;
}
return
false
;
}
function
interface_netgraph_needed
(
$interface
=
"wan"
)
{
global
$config
;
...
...
@@ -157,10 +123,10 @@ function interface_netgraph_needed($interface = "wan") {
if
(
!
empty
(
$config
[
'pptpd'
])
&&
$config
[
'pptpd'
][
'mode'
]
==
"server"
)
$found
=
true
;
if
(
$found
==
false
&&
!
empty
(
$config
[
'l2tp'
])
&&
if
(
!
$found
&&
!
empty
(
$config
[
'l2tp'
])
&&
$config
[
'l2tp'
][
'mode'
]
==
"server"
)
$found
=
true
;
if
(
$found
==
false
&&
is_array
(
$config
[
'pppoes'
][
'pppoe'
]))
{
if
(
!
$found
&&
isset
(
$config
[
'pppoes'
][
'pppoe'
])
&&
is_array
(
$config
[
'pppoes'
][
'pppoe'
]))
{
foreach
(
$config
[
'pppoes'
][
'pppoe'
]
as
$pppoe
)
{
if
(
$pppoe
[
'mode'
]
!=
"server"
)
continue
;
...
...
@@ -169,7 +135,7 @@ function interface_netgraph_needed($interface = "wan") {
break
;
}
}
if
(
$found
==
false
)
{
if
(
!
$found
)
{
if
(
!
empty
(
$config
[
'interfaces'
][
$interface
]))
{
switch
(
$config
[
'interfaces'
][
$interface
][
'ipaddr'
])
{
case
"ppp"
:
...
...
@@ -184,20 +150,10 @@ function interface_netgraph_needed($interface = "wan") {
}
}
}
if
(
$found
==
false
)
{
if
(
!
$found
)
{
$realif
=
get_real_interface
(
$interface
);
if
(
isset
(
$config
[
'ppps'
][
'ppp'
]))
{
foreach
(
$config
[
'ppps'
][
'ppp'
]
as
$pppid
=>
$ppp
)
{
/* This if block doesn't do anything. It can be deleted.
PPP interfaces are found above in the previous if ($found == false) block.
This block of code is only entered for OPTx interfaces that are configured for PPPoE modem access, so $realif != $ppp['if']
if ($realif == $ppp['if']) {
$found = true;
break;
}
*/
$ports
=
explode
(
','
,
$ppp
[
'ports'
]);
foreach
(
$ports
as
$pid
=>
$port
){
$port
=
get_real_interface
(
$port
);
...
...
@@ -218,7 +174,7 @@ This block of code is only entered for OPTx interfaces that are configured for P
}
}
if
(
$found
==
false
)
{
if
(
!
$found
)
{
$realif
=
get_real_interface
(
$interface
);
pfSense_ngctl_detach
(
"
{
$realif
}
:"
,
$realif
);
}
...
...
@@ -377,7 +333,7 @@ function interface_qinq_configure(&$vlan, $fd = NULL) {
interface_qinq2_configure
(
$qinq
,
$fd
,
$macaddr
);
}
}
if
(
$exec
==
true
)
{
if
(
$exec
)
{
fclose
(
$fd
);
mwexec
(
'/usr/sbin/ngctl -f /tmp/netgraphcmd'
);
}
...
...
@@ -396,7 +352,7 @@ function interfaces_qinq_configure() {
global
$config
;
if
(
file_exists
(
"/var/run/booting"
))
echo
gettext
(
"Configuring QinQ interfaces..."
);
if
(
is
_array
(
$config
[
'qinqs'
][
'qinqentry'
])
&&
count
(
$config
[
'qinqs'
][
'qinqentry'
]))
{
if
(
is
set
(
$config
[
'qinqs'
][
'qinqentry'
])
&&
is_array
(
$config
[
'qinqs'
][
'qinqentry'
]))
{
foreach
(
$config
[
'qinqs'
][
'qinqentry'
]
as
$qinq
)
{
/* XXX: Maybe we should report any errors?! */
interface_qinq_configure
(
$qinq
);
...
...
@@ -547,7 +503,7 @@ function interface_bridge_configure(&$bridge, $checkmember = 0) {
else
if
(
!
empty
(
$mtu
)
&&
$mtu
<
$smallermtu
)
$smallermtu
=
$mtu
;
}
if
(
$foundgif
==
false
&&
$checkmember
==
2
)
{
if
(
!
$foundgif
&&
$checkmember
==
2
)
{
return
;
}
...
...
@@ -745,7 +701,7 @@ function interfaces_lagg_configure($realif = "") {
if
(
file_exists
(
"/var/run/booting"
))
echo
gettext
(
"Configuring LAGG interfaces..."
);
$i
=
0
;
if
(
is
_array
(
$config
[
'laggs'
][
'lagg'
])
&&
count
(
$config
[
'laggs'
][
'lagg'
]))
{
if
(
is
set
(
$config
[
'laggs'
][
'lagg'
])
&&
is_array
(
$config
[
'laggs'
][
'lagg'
]))
{
foreach
(
$config
[
'laggs'
][
'lagg'
]
as
$lagg
)
{
if
(
empty
(
$lagg
[
'laggif'
]))
$lagg
[
'laggif'
]
=
"lagg
{
$i
}
"
;
...
...
@@ -851,7 +807,7 @@ function interface_lagg_configure(&$lagg)
function
interfaces_gre_configure
(
$checkparent
=
0
,
$realif
=
""
)
{
global
$config
;
if
(
is
_array
(
$config
[
'gres'
][
'gre'
])
&&
count
(
$config
[
'gres'
][
'gre'
]))
{
if
(
is
set
(
$config
[
'gres'
][
'gre'
])
&&
is_array
(
$config
[
'gres'
][
'gre'
]))
{
foreach
(
$config
[
'gres'
][
'gre'
]
as
$i
=>
$gre
)
{
if
(
empty
(
$gre
[
'greif'
]))
$gre
[
'greif'
]
=
"gre
{
$i
}
"
;
...
...
@@ -1403,25 +1359,6 @@ function interface_bring_down($interface = "wan", $destroy = false, $ifacecfg =
return
;
}
function
interfaces_carp_set_maintenancemode
(
$carp_maintenancemode
){
global
$config
;
if
(
isset
(
$config
[
"virtualip_carp_maintenancemode"
])
&&
$carp_maintenancemode
==
false
)
{
unset
(
$config
[
"virtualip_carp_maintenancemode"
]);
write_config
(
"Leave CARP maintenance mode"
);
}
else
if
(
!
isset
(
$config
[
"virtualip_carp_maintenancemode"
])
&&
$carp_maintenancemode
==
true
)
{
$config
[
"virtualip_carp_maintenancemode"
]
=
true
;
write_config
(
"Enter CARP maintenance mode"
);
}
$viparr
=
&
$config
[
'virtualip'
][
'vip'
];
foreach
(
$viparr
as
$vip
)
{
if
(
$vip
[
'mode'
]
==
"carp"
)
{
interface_carp_configure
(
$vip
);
}
}
}
function
interfaces_ptpid_used
(
$ptpid
)
{
global
$config
;
...
...
@@ -1447,7 +1384,7 @@ function getMPDCRONSettings($pppif)
global
$config
;
$cron_cmd_file
=
"/var/etc/pppoe_restart_
{
$pppif
}
"
;
if
(
is_array
(
$config
[
'cron'
][
'item'
]))
{
if
(
is
set
(
$config
[
'cron'
][
'item'
])
&&
is
_array
(
$config
[
'cron'
][
'item'
]))
{
foreach
(
$config
[
'cron'
][
'item'
]
as
$i
=>
$item
)
{
if
(
stripos
(
$item
[
'command'
],
$cron_cmd_file
)
!==
false
)
return
array
(
"ID"
=>
$i
,
"ITEM"
=>
$item
);
...
...
@@ -1463,7 +1400,7 @@ function handle_pppoe_reset($post_array) {
$pppif
=
"
{
$post_array
[
'type'
]
}{
$post_array
[
'ptpid'
]
}
"
;
$cron_cmd_file
=
"/var/etc/pppoe_restart_
{
$pppif
}
"
;
if
(
!
is_array
(
$config
[
'cron'
][
'item'
]))
if
(
!
is
set
(
$config
[
'cron'
][
'item'
])
||
!
is
_array
(
$config
[
'cron'
][
'item'
]))
$config
[
'cron'
][
'item'
]
=
array
();
$itemhash
=
getMPDCRONSettings
(
$pppif
);
...
...
@@ -1561,13 +1498,13 @@ function interface_ppps_configure($interface)
symlink
(
'/usr/local/sbin/mpd.script'
,
'/var/etc/mpd.script'
);
}
if
(
is
_array
(
$config
[
'ppps'
][
'ppp'
])
&&
count
(
$config
[
'ppps'
][
'ppp'
]))
{
if
(
is
set
(
$config
[
'ppps'
][
'ppp'
])
&&
is_array
(
$config
[
'ppps'
][
'ppp'
]))
{
foreach
(
$config
[
'ppps'
][
'ppp'
]
as
$pppid
=>
$ppp
)
{
if
(
$ifcfg
[
'if'
]
==
$ppp
[
'if'
])
break
;
}
}
if
(
!
$ppp
||
$ifcfg
[
'if'
]
!=
$ppp
[
'if'
]){
if
(
!
isset
(
$ppp
)
||
$ifcfg
[
'if'
]
!=
$ppp
[
'if'
]){
log_error
(
sprintf
(
gettext
(
"Can't find PPP config for %s in interface_ppps_configure()."
),
$ifcfg
[
'if'
]));
return
0
;
}
...
...
@@ -2013,7 +1950,7 @@ function interfaces_carp_setup()
unset
(
$carp_sync_int
);
/* setup pfsync interface */
if
(
$carp_sync_int
&&
isset
(
$pfsyncenabled
))
{
if
(
!
empty
(
$carp_sync_int
)
&&
isset
(
$pfsyncenabled
))
{
if
(
is_ipaddr
(
$pfsyncpeerip
))
$syncpeer
=
"syncpeer
{
$pfsyncpeerip
}
"
;
else
...
...
@@ -2062,8 +1999,7 @@ function interface_proxyarp_configure($interface = '')
}
$paa
=
array
();
if
(
!
empty
(
$config
[
'virtualip'
])
&&
is_array
(
$config
[
'virtualip'
][
'vip'
]))
{
if
(
isset
(
$config
[
'virtualip'
][
'vip'
])
&&
is_array
(
$config
[
'virtualip'
][
'vip'
]))
{
/* group by interface */
foreach
(
$config
[
'virtualip'
][
'vip'
]
as
$vipent
)
{
if
(
$vipent
[
'mode'
]
===
"proxyarp"
)
{
...
...
@@ -2252,7 +2188,7 @@ function interface_wireless_clone($realif, $wlcfg)
* If it has not been cloned then go ahead and clone it.
*/
$needs_clone
=
false
;
if
(
is_array
(
$wlcfg
[
'wireless'
]))
if
(
is
set
(
$wlcfg
[
'wireless'
])
&&
is
_array
(
$wlcfg
[
'wireless'
]))
$wlcfg_mode
=
$wlcfg
[
'wireless'
][
'mode'
];
else
$wlcfg_mode
=
$wlcfg
[
'mode'
];
...
...
@@ -2287,7 +2223,7 @@ function interface_wireless_clone($realif, $wlcfg)
$needs_clone
=
true
;
}
if
(
$needs_clone
==
true
)
{
if
(
$needs_clone
)
{
/* remove previous instance if it exists */
if
(
does_interface_exist
(
$realif
))
{
legacy_interface_destroy
(
$realif
);
...
...
@@ -2366,7 +2302,7 @@ function interface_sync_wireless_clones(&$ifcfg, $sync_changes = false)
}
// Sync the mode on the clone creation page with the configured mode on the interface
if
(
interface_is_wireless_clone
(
$ifcfg
[
'if'
]
)
&&
isset
(
$config
[
'wireless'
][
'clone'
])
&&
is_array
(
$config
[
'wireless'
][
'clone'
]))
{
if
(
stristr
(
$ifcfg
[
'if'
],
"_wlan"
)
&&
isset
(
$config
[
'wireless'
][
'clone'
])
&&
is_array
(
$config
[
'wireless'
][
'clone'
]))
{
foreach
(
$config
[
'wireless'
][
'clone'
]
as
&
$clone
)
{
if
(
$clone
[
'cloneif'
]
==
$ifcfg
[
'if'
])
{
if
(
$sync_changes
)
{
...
...
@@ -2845,7 +2781,7 @@ function find_dhcp6c_process($interface)
function
interface_vlan_mtu_configured
(
$realhwif
,
$mtu
)
{
global
$config
;
if
(
is
_array
(
$config
[
'vlans
'
])
&&
is_array
(
$config
[
'vlans'
][
'vlan'
]))
{
if
(
is
set
(
$config
[
'vlans'
][
'vlan
'
])
&&
is_array
(
$config
[
'vlans'
][
'vlan'
]))
{
foreach
(
$config
[
'vlans'
][
'vlan'
]
as
$vlan
)
{
if
(
$vlan
[
'if'
]
!=
$realhwif
)
continue
;
...
...
@@ -2990,7 +2926,7 @@ function interface_configure($interface = 'wan', $reloadall = false, $linkupeven
mwexec
(
"/sbin/ifconfig "
.
escapeshellarg
(
$realif
)
.
" inet6 -accept_rtadv"
);
/* wireless configuration? */
if
(
is_array
(
$wancfg
[
'wireless'
]))
if
(
is
set
(
$wancfg
[
'wireless'
])
&&
is
_array
(
$wancfg
[
'wireless'
]))
interface_wireless_configure
(
$realif
,
$wancfg
,
$wancfg
[
'wireless'
]);
$mac
=
get_interface_mac
(
$realhwif
);
...
...
@@ -3000,7 +2936,7 @@ function interface_configure($interface = 'wan', $reloadall = false, $linkupeven
* the interface config again, which attempts to spoof the MAC again,
* which cycles the link again...
*/
if
(
$wancfg
[
'spoofmac'
]
&&
(
$wancfg
[
'spoofmac'
]
!=
$mac
))
{
if
(
isset
(
$wancfg
[
'spoofmac'
])
&&
(
$wancfg
[
'spoofmac'
]
!=
$mac
))
{
mwexec
(
"/sbin/ifconfig "
.
escapeshellarg
(
$realhwif
)
.
" link "
.
escapeshellarg
(
$wancfg
[
'spoofmac'
]));
...
...
@@ -3008,7 +2944,7 @@ function interface_configure($interface = 'wan', $reloadall = false, $linkupeven
* All vlans need to spoof their parent mac address, too. see
* ticket #1514: http://cvstrac.pfsense.com/tktview?tn=1514,33
*/
if
(
is_array
(
$config
[
'vlans'
][
'vlan'
]))
{
if
(
is
set
(
$config
[
'vlans'
][
'vlan'
])
&&
is
_array
(
$config
[
'vlans'
][
'vlan'
]))
{
foreach
(
$config
[
'vlans'
][
'vlan'
]
as
$vlan
)
{
if
(
$vlan
[
'if'
]
==
$realhwif
)
mwexec
(
"/sbin/ifconfig "
.
escapeshellarg
(
$vlan
[
'vlanif'
])
.
...
...
@@ -3032,12 +2968,14 @@ function interface_configure($interface = 'wan', $reloadall = false, $linkupeven
}
/* media */
if
(
$wancfg
[
'media'
]
||
$wancfg
[
'mediaopt'
]
)
{
if
(
isset
(
$wancfg
[
'media'
])
||
isset
(
$wancfg
[
'mediaopt'
])
)
{
$cmd
=
"/sbin/ifconfig "
.
escapeshellarg
(
$realhwif
);
if
(
$wancfg
[
'media'
])
if
(
isset
(
$wancfg
[
'media'
]))
{
$cmd
.=
" media "
.
escapeshellarg
(
$wancfg
[
'media'
]);
if
(
$wancfg
[
'mediaopt'
])
}
if
(
isset
(
$wancfg
[
'mediaopt'
]))
{
$cmd
.=
" mediaopt "
.
escapeshellarg
(
$wancfg
[
'mediaopt'
]);
}
mwexec
(
$cmd
);
}
$options
=
pfSense_get_interface_addresses
(
$realhwif
);
...
...
@@ -3082,6 +3020,7 @@ function interface_configure($interface = 'wan', $reloadall = false, $linkupeven
break
;
}
if
(
isset
(
$wancfg
[
'ipaddrv6'
]))
{
switch
(
$wancfg
[
'ipaddrv6'
])
{
case
'slaac'
:
case
'dhcp6'
:
...
...
@@ -3105,7 +3044,7 @@ function interface_configure($interface = 'wan', $reloadall = false, $linkupeven
}
break
;
}
}
if
(
!
empty
(
$wancfg
[
'mtu'
]))
{
if
(
stristr
(
$realif
,
"_vlan"
))
{
$assignedparent
=
convert_real_interface_to_friendly_interface_name
(
$realhwif
);
...
...
@@ -4273,13 +4212,6 @@ function get_parent_interface($interface, $avoidrecurse = false) {
return
$parents
;
}
function
interface_is_wireless_clone
(
$wlif
)
{
if
(
!
stristr
(
$wlif
,
"_wlan"
))
{
return
false
;
}
else
{
return
true
;
}
}
function
interface_get_wireless_base
(
$wlif
)
{
if
(
!
stristr
(
$wlif
,
"_wlan"
))
{
...
...
@@ -4438,111 +4370,6 @@ function guess_interface_from_ip($ipaddress) {
return
$ret
;
}
/*
* find_ip_interface($ip): return the interface where an ip is defined
* (or if $bits is specified, where an IP within the subnet is defined)
*/
function
find_ip_interface
(
$ip
,
$bits
=
null
)
{
if
(
!
is_ipaddr
(
$ip
))
return
false
;
$isv6ip
=
is_ipaddrv6
(
$ip
);
/* if list */
$ifdescrs
=
get_configured_interface_list
();
foreach
(
$ifdescrs
as
$ifdescr
=>
$ifname
)
{
$ifip
=
(
$isv6ip
)
?
get_interface_ipv6
(
$ifname
)
:
get_interface_ip
(
$ifname
);
if
(
is_null
(
$ifip
))
continue
;
if
(
is_null
(
$bits
))
{
if
(
$ip
==
$ifip
)
{
$int
=
get_real_interface
(
$ifname
);
return
$int
;
}
}
else
{
if
(
ip_in_subnet
(
$ifip
,
$ip
.
"/"
.
$bits
))
{
$int
=
get_real_interface
(
$ifname
);
return
$int
;
}
}
}
return
false
;
}
/*
* find_virtual_ip_alias($ip): return the virtual IP alias where an IP is found
* (or if $bits is specified, where an IP within the subnet is found)
*/
function
find_virtual_ip_alias
(
$ip
,
$bits
=
null
)
{
global
$config
;
if
(
!
isset
(
$config
[
'virtualip'
][
'vip'
]))
{
return
false
;
}
if
(
!
is_ipaddr
(
$ip
))
{
return
false
;
}
$isv6ip
=
is_ipaddrv6
(
$ip
);
foreach
(
$config
[
'virtualip'
][
'vip'
]
as
$vip
)
{
if
(
$vip
[
'mode'
]
===
"ipalias"
)
{
if
(
is_ipaddrv6
(
$vip
[
'subnet'
])
!=
$isv6ip
)
continue
;
if
(
is_null
(
$bits
))
{
if
(
ip_in_subnet
(
$ip
,
$vip
[
'subnet'
]
.
"/"
.
$vip
[
'subnet_bits'
]))
{
return
$vip
;
}
}
else
{
if
((
$isv6ip
&&
check_subnetsv6_overlap
(
$ip
,
$bits
,
$vip
[
'subnet'
],
$vip
[
'subnet_bits'
]))
||
(
!
$isv6ip
&&
check_subnets_overlap
(
$ip
,
$bits
,
$vip
[
'subnet'
],
$vip
[
'subnet_bits'
])))
{
return
$vip
;
}
}
}
}
return
false
;
}
/*
* find_carp_interface($ip): return the carp interface where an ip is defined
*/
function
find_carp_interface
(
$ip
)
{
global
$config
;
if
(
isset
(
$config
[
'virtualip'
][
'vip'
]))
{
foreach
(
$config
[
'virtualip'
][
'vip'
]
as
$vip
)
{
if
(
$vip
[
'mode'
]
==
"carp"
)
{
if
(
is_ipaddrv4
(
$ip
))
{
$carp_ip
=
get_interface_ip
(
$vip
[
'interface'
]);
}
if
(
is_ipaddrv6
(
$ip
))
{
$carp_ip
=
get_interface_ipv6
(
$vip
[
'interface'
]);
}
exec
(
"/sbin/ifconfig"
,
$output
,
$return
);
foreach
(
$output
as
$line
)
{
$elements
=
preg_split
(
"/[ ]+/i"
,
$line
);
if
(
strstr
(
$elements
[
0
],
"vip"
))
$curif
=
str_replace
(
":"
,
""
,
$elements
[
0
]);
if
(
stristr
(
$line
,
$ip
))
{
$if
=
$curif
;
continue
;
}
}
if
(
$if
)
{
return
$if
;
}
}
}
}
}
/****f* interfaces/link_ip_to_carp_interface
...
...
@@ -4721,7 +4548,6 @@ function link_interface_to_gif($interface)
*/
function
find_interface_ip
(
$interface
,
$flush
=
false
)
{
global
$interface_ip_arr_cache
;
global
$interface_sn_arr_cache
;
$interface
=
str_replace
(
"
\n
"
,
""
,
$interface
);
...
...
@@ -4731,8 +4557,9 @@ function find_interface_ip($interface, $flush = false) {
/* Setup IP cache */
if
(
!
isset
(
$interface_ip_arr_cache
[
$interface
])
or
$flush
)
{
$ifinfo
=
pfSense_get_interface_addresses
(
$interface
);
if
(
isset
(
$ifinfo
[
'ipaddr'
]))
{
$interface_ip_arr_cache
[
$interface
]
=
$ifinfo
[
'ipaddr'
];
$interface_sn_arr_cache
[
$interface
]
=
$ifinfo
[
'subnetbits'
];
}
}
return
$interface_ip_arr_cache
[
$interface
];
...
...
@@ -4794,16 +4621,14 @@ function find_interface_ipv6_ll($interface, $flush = false) {
function
find_interface_subnet
(
$interface
,
$flush
=
false
)
{
global
$interface_sn_arr_cache
;
global
$interface_ip_arr_cache
;
$interface
=
str_replace
(
"
\n
"
,
""
,
$interface
);
if
(
does_interface_exist
(
$interface
)
==
false
)
return
;
if
(
!
isset
(
$interface_sn_arr_cache
[
$interface
])
or
$flush
)
{
if
(
!
isset
(
$interface_sn_arr_cache
[
$interface
])
||
$flush
)
{
$ifinfo
=
pfSense_get_interface_addresses
(
$interface
);
if
(
isset
(
$ifinfo
[
'ipaddr'
]))
{
$interface_ip_arr_cache
[
$interface
]
=
$ifinfo
[
'ipaddr'
];
if
(
isset
(
$ifinfo
[
'subnetbits'
]))
{
$interface_sn_arr_cache
[
$interface
]
=
$ifinfo
[
'subnetbits'
];
return
$interface_sn_arr_cache
[
$interface
];
}
...
...
@@ -5047,72 +4872,7 @@ function is_interface_wireless($interface)
return
true
;
}
function
get_wireless_modes
(
$interface
)
{
/* return wireless modes and channels */
$wireless_modes
=
array
();
$cloned_interface
=
get_real_interface
(
$interface
);
if
(
$cloned_interface
&&
is_interface_wireless
(
$cloned_interface
))
{
$chan_list
=
"/sbin/ifconfig
{
$cloned_interface
}
list chan"
;
$stack_list
=
"/usr/bin/awk -F
\"
Channel
\"
'{ gsub(/
\\
*/,
\"
\"
); print
\$
2
\"\\\n\"
\$
3 }'"
;
$format_list
=
"/usr/bin/awk '{print
\$
5
\"
\"
\$
6
\"
,
\"
\$
1}'"
;
$interface_channels
=
""
;
exec
(
"
$chan_list
|
$stack_list
| sort -u |
$format_list
2>&1"
,
$interface_channels
);
$interface_channel_count
=
count
(
$interface_channels
);
$c
=
0
;
while
(
$c
<
$interface_channel_count
)
{
$channel_line
=
explode
(
","
,
$interface_channels
[
"
$c
"
]);
$wireless_mode
=
trim
(
$channel_line
[
0
]);
$wireless_channel
=
trim
(
$channel_line
[
1
]);
if
(
trim
(
$wireless_mode
)
!=
""
)
{
/* if we only have 11g also set 11b channels */
if
(
$wireless_mode
==
"11g"
)
{
if
(
!
isset
(
$wireless_modes
[
"11b"
]))
$wireless_modes
[
"11b"
]
=
array
();
}
else
if
(
$wireless_mode
==
"11g ht"
)
{
if
(
!
isset
(
$wireless_modes
[
"11b"
]))
$wireless_modes
[
"11b"
]
=
array
();
if
(
!
isset
(
$wireless_modes
[
"11g"
]))
$wireless_modes
[
"11g"
]
=
array
();
$wireless_mode
=
"11ng"
;
}
else
if
(
$wireless_mode
==
"11a ht"
)
{
if
(
!
isset
(
$wireless_modes
[
"11a"
]))
$wireless_modes
[
"11a"
]
=
array
();
$wireless_mode
=
"11na"
;
}
$wireless_modes
[
"
$wireless_mode
"
][
"
$c
"
]
=
$wireless_channel
;
}
$c
++
;
}
}
return
(
$wireless_modes
);
}
/* return channel numbers, frequency, max txpower, and max regulation txpower */
function
get_wireless_channel_info
(
$interface
)
{
$wireless_channels
=
array
();
$cloned_interface
=
get_real_interface
(
$interface
);
if
(
$cloned_interface
&&
is_interface_wireless
(
$cloned_interface
))
{
$chan_list
=
"/sbin/ifconfig
{
$cloned_interface
}
list txpower"
;
$stack_list
=
"/usr/bin/awk -F
\"
Channel
\"
'{ gsub(/
\\
*/,
\"
\"
); print
\$
2
\"\\\n\"
\$
3 }'"
;
$format_list
=
"/usr/bin/awk '{print
\$
1
\"
,
\"
\$
3
\"
\"
\$
4
\"
,
\"
\$
5
\"
,
\"
\$
7}'"
;
$interface_channels
=
""
;
exec
(
"
$chan_list
|
$stack_list
| sort -u |
$format_list
2>&1"
,
$interface_channels
);
foreach
(
$interface_channels
as
$channel_line
)
{
$channel_line
=
explode
(
","
,
$channel_line
);
if
(
!
isset
(
$wireless_channels
[
$channel_line
[
0
]]))
$wireless_channels
[
$channel_line
[
0
]]
=
$channel_line
;
}
}
return
(
$wireless_channels
);
}
/****f* interfaces/get_interface_mtu
* NAME
...
...
src/etc/inc/xmlrpc/legacy.inc
View file @
8a7ba132
...
...
@@ -43,6 +43,42 @@ function xmlrpc_publishable_legacy()
return
$publish
;
}
/*
* does_vip_exist($vip): return true or false if a vip is
* configured.
*/
function
does_vip_exist
(
$vip
)
{
global
$config
;
if
(
!
$vip
)
return
false
;
switch
(
$vip
[
'mode'
])
{
case
"carp"
:
case
"ipalias"
:
/* XXX: Make proper checks? */
$realif
=
get_real_interface
(
$vip
[
'interface'
]);
if
(
!
does_interface_exist
(
$realif
))
{
return
false
;
}
break
;
case
"proxyarp"
:
/* XXX: Implement this */
default
:
return
false
;
}
$ifacedata
=
pfSense_getall_interface_addresses
(
$realif
);
foreach
(
$ifacedata
as
$vipips
)
{
if
(
$vipips
==
"
{
$vip
[
'subnet'
]
}
/
{
$vip
[
'subnet_bits'
]
}
"
)
return
true
;
}
return
false
;
}
/**
* @param null $category
* @return mixed
...
...
src/www/carp_status.php
View file @
8a7ba132
...
...
@@ -30,6 +30,26 @@
require_once
(
"guiconfig.inc"
);
require_once
(
"globals.inc"
);
function
interfaces_carp_set_maintenancemode
(
$carp_maintenancemode
){
global
$config
;
if
(
isset
(
$config
[
"virtualip_carp_maintenancemode"
])
&&
$carp_maintenancemode
==
false
)
{
unset
(
$config
[
"virtualip_carp_maintenancemode"
]);
write_config
(
"Leave CARP maintenance mode"
);
}
else
if
(
!
isset
(
$config
[
"virtualip_carp_maintenancemode"
])
&&
$carp_maintenancemode
==
true
)
{
$config
[
"virtualip_carp_maintenancemode"
]
=
true
;
write_config
(
"Enter CARP maintenance mode"
);
}
$viparr
=
&
$config
[
'virtualip'
][
'vip'
];
foreach
(
$viparr
as
$vip
)
{
if
(
$vip
[
'mode'
]
==
"carp"
)
{
interface_carp_configure
(
$vip
);
}
}
}
unset
(
$interface_arr_cache
);
unset
(
$carp_interface_count_cache
);
unset
(
$interface_ip_arr_cache
);
...
...
src/www/interfaces.php
View file @
8a7ba132
...
...
@@ -39,6 +39,74 @@ require_once("rrd.inc");
require_once
(
"vpn.inc"
);
require_once
(
"xmlparse_attr.inc"
);
function
get_wireless_modes
(
$interface
)
{
/* return wireless modes and channels */
$wireless_modes
=
array
();
$cloned_interface
=
get_real_interface
(
$interface
);
if
(
$cloned_interface
&&
is_interface_wireless
(
$cloned_interface
))
{
$chan_list
=
"/sbin/ifconfig
{
$cloned_interface
}
list chan"
;
$stack_list
=
"/usr/bin/awk -F
\"
Channel
\"
'{ gsub(/
\\
*/,
\"
\"
); print
\$
2
\"\\\n\"
\$
3 }'"
;
$format_list
=
"/usr/bin/awk '{print
\$
5
\"
\"
\$
6
\"
,
\"
\$
1}'"
;
$interface_channels
=
""
;
exec
(
"
$chan_list
|
$stack_list
| sort -u |
$format_list
2>&1"
,
$interface_channels
);
$interface_channel_count
=
count
(
$interface_channels
);
$c
=
0
;
while
(
$c
<
$interface_channel_count
)
{
$channel_line
=
explode
(
","
,
$interface_channels
[
"
$c
"
]);
$wireless_mode
=
trim
(
$channel_line
[
0
]);
$wireless_channel
=
trim
(
$channel_line
[
1
]);
if
(
trim
(
$wireless_mode
)
!=
""
)
{
/* if we only have 11g also set 11b channels */
if
(
$wireless_mode
==
"11g"
)
{
if
(
!
isset
(
$wireless_modes
[
"11b"
]))
$wireless_modes
[
"11b"
]
=
array
();
}
else
if
(
$wireless_mode
==
"11g ht"
)
{
if
(
!
isset
(
$wireless_modes
[
"11b"
]))
$wireless_modes
[
"11b"
]
=
array
();
if
(
!
isset
(
$wireless_modes
[
"11g"
]))
$wireless_modes
[
"11g"
]
=
array
();
$wireless_mode
=
"11ng"
;
}
else
if
(
$wireless_mode
==
"11a ht"
)
{
if
(
!
isset
(
$wireless_modes
[
"11a"
]))
$wireless_modes
[
"11a"
]
=
array
();
$wireless_mode
=
"11na"
;
}
$wireless_modes
[
"
$wireless_mode
"
][
"
$c
"
]
=
$wireless_channel
;
}
$c
++
;
}
}
return
(
$wireless_modes
);
}
/* return channel numbers, frequency, max txpower, and max regulation txpower */
function
get_wireless_channel_info
(
$interface
)
{
$wireless_channels
=
array
();
$cloned_interface
=
get_real_interface
(
$interface
);
if
(
$cloned_interface
&&
is_interface_wireless
(
$cloned_interface
))
{
$chan_list
=
"/sbin/ifconfig
{
$cloned_interface
}
list txpower"
;
$stack_list
=
"/usr/bin/awk -F
\"
Channel
\"
'{ gsub(/
\\
*/,
\"
\"
); print
\$
2
\"\\\n\"
\$
3 }'"
;
$format_list
=
"/usr/bin/awk '{print
\$
1
\"
,
\"
\$
3
\"
\"
\$
4
\"
,
\"
\$
5
\"
,
\"
\$
7}'"
;
$interface_channels
=
""
;
exec
(
"
$chan_list
|
$stack_list
| sort -u |
$format_list
2>&1"
,
$interface_channels
);
foreach
(
$interface_channels
as
$channel_line
)
{
$channel_line
=
explode
(
","
,
$channel_line
);
if
(
!
isset
(
$wireless_channels
[
$channel_line
[
0
]]))
$wireless_channels
[
$channel_line
[
0
]]
=
$channel_line
;
}
}
return
(
$wireless_channels
);
}
$referer
=
(
isset
(
$_SERVER
[
'HTTP_REFERER'
])
?
$_SERVER
[
'HTTP_REFERER'
]
:
'/interfaces.php'
);
// Get configured interface list
...
...
src/www/wizard.php
View file @
8a7ba132
...
...
@@ -34,6 +34,41 @@ require_once("functions.inc");
require_once
(
"filter.inc"
);
require_once
(
"rrd.inc"
);
/*
* find_ip_interface($ip): return the interface where an ip is defined
* (or if $bits is specified, where an IP within the subnet is defined)
*/
function
find_ip_interface
(
$ip
,
$bits
=
null
)
{
if
(
!
is_ipaddr
(
$ip
))
return
false
;
$isv6ip
=
is_ipaddrv6
(
$ip
);
/* if list */
$ifdescrs
=
get_configured_interface_list
();
foreach
(
$ifdescrs
as
$ifdescr
=>
$ifname
)
{
$ifip
=
(
$isv6ip
)
?
get_interface_ipv6
(
$ifname
)
:
get_interface_ip
(
$ifname
);
if
(
is_null
(
$ifip
))
continue
;
if
(
is_null
(
$bits
))
{
if
(
$ip
==
$ifip
)
{
$int
=
get_real_interface
(
$ifname
);
return
$int
;
}
}
else
{
if
(
ip_in_subnet
(
$ifip
,
$ip
.
"/"
.
$bits
))
{
$int
=
get_real_interface
(
$ifname
);
return
$int
;
}
}
}
return
false
;
}
global
$g
;
$stepid
=
htmlspecialchars
(
$_GET
[
'stepid'
]);
...
...
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