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
c97707f9
Commit
c97707f9
authored
Oct 21, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove prior captive portal leftovers
parent
82c17db5
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
564 deletions
+0
-564
ARP.php
src/opnsense/mvc/app/models/OPNsense/CaptivePortal/ARP.php
+0
-115
DB.php
src/opnsense/mvc/app/models/OPNsense/CaptivePortal/DB.php
+0
-449
No files found.
src/opnsense/mvc/app/models/OPNsense/CaptivePortal/ARP.php
deleted
100644 → 0
View file @
82c17db5
<?php
/**
* Copyright (C) 2015 Deciso B.V.
*
* 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.
*
*/
namespace
OPNsense\CaptivePortal
;
use
\OPNsense\Core
;
/**
* Class ARP provides access to the systems ARP table
* @package OPNsense\CaptivePortal
*/
class
ARP
{
/**
* pointer to shell object
* @var \Core\Shell
*/
private
$shell
;
/**
* construct new ARP table handlers
*/
public
function
__construct
()
{
$this
->
shell
=
new
Core\Shell
();
}
/**
* set static arp entry
* @param $ipaddress|string hosts ipaddress
* @param $mac|string hosts physical address
*/
public
function
setStatic
(
$ipaddress
,
$mac
)
{
// validate input, only set static entries for valid addresses
if
(
preg_match
(
'/^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$/'
,
trim
(
$mac
)))
{
if
(
filter_var
(
$ipaddress
,
FILTER_VALIDATE_IP
,
FILTER_FLAG_IPV4
|
FILTER_FLAG_IPV6
))
{
$this
->
shell
->
exec
(
"/usr/sbin/arp -s "
.
trim
(
$ipaddress
)
.
" "
.
trim
(
$mac
));
}
}
}
/**
* drop static arp entry
* @param $ipaddress|string hosts ipaddress
*/
public
function
dropStatic
(
$ipaddress
)
{
// validate input, drop arp entry
if
(
filter_var
(
$ipaddress
,
FILTER_VALIDATE_IP
,
FILTER_FLAG_IPV4
|
FILTER_FLAG_IPV6
))
{
$this
->
shell
->
exec
(
"/usr/sbin/arp -d "
.
trim
(
$ipaddress
));
}
}
/**
* Return arp table hashed by mac address
*/
public
function
getMACs
()
{
$result
=
array
();
$shell_output
=
array
();
// execute arp shell command and collect (only valid) info into named array
if
(
$this
->
shell
->
exec
(
'arp -an'
,
false
,
$shell_output
)
==
0
)
{
foreach
(
$shell_output
as
$line
)
{
$line_parts
=
explode
(
" "
,
$line
);
if
(
sizeof
(
$line_parts
)
>=
4
)
{
$ipaddress
=
substr
(
$line_parts
[
1
],
1
,
strlen
(
$line_parts
[
1
])
-
2
);
// reformat mac addresses, sometimes arp return segments without trailing zero's
$mac_raw
=
strtolower
(
$line_parts
[
3
]);
$mac
=
""
;
foreach
(
explode
(
":"
,
$mac_raw
)
as
$segment
)
{
if
(
$mac
!=
""
)
{
$mac
.=
":"
;
}
if
(
strlen
(
$segment
)
==
1
)
{
$mac
.=
"0"
.
$segment
;
}
else
{
$mac
.=
$segment
;
}
}
if
(
preg_match
(
'/^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$/'
,
trim
(
$mac
)))
{
$result
[
$mac
]
=
array
(
'ip'
=>
$ipaddress
);
}
}
}
}
return
$result
;
}
}
src/opnsense/mvc/app/models/OPNsense/CaptivePortal/DB.php
deleted
100644 → 0
View file @
82c17db5
This diff is collapsed.
Click to expand it.
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