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
Expand all
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
This diff is collapsed.
Click to expand it.
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