Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
awit-frameworks
awit-perl-toolkit
Commits
b725a9da
Commit
b725a9da
authored
Mar 28, 2017
by
Nigel Kukard
Browse files
Merge branch 'netipfix-0.0.x' into 'v0.0.x'
Fixed warning for v0.0.x usage of Socket* modules See merge request
!16
parents
fd19a8ca
8c2944a7
Changes
1
Hide whitespace changes
Inline
Side-by-side
awitpt/netip.pm
View file @
b725a9da
...
...
@@ -29,16 +29,8 @@ package awitpt::netip;
use
strict
;
use
warnings
;
use
Socket
;
BEGIN
{
if
(
defined
&
Socket::
inet_pton
)
{
Socket
->
import
(
qw(inet_pton AF_INET6)
);
}
else
{
require
Socket6
;
Socket6
->
import
(
qw(inet_pton AF_INET6)
);
}
};
use
Socket
qw(inet_aton)
;
use
Socket6
qw(inet_pton AF_INET6)
;
# Our current error message
my
$error
=
"";
...
...
@@ -197,7 +189,7 @@ sub to_network
sub
_cidr2mask_v4
{
my
$self
=
shift
;
return
pack
"
N
",
0xffffffff
<<
(
32
-
$self
->
{'
cidr
'});
return
pack
"
N
",
0xffffffff
<<
(
32
-
$self
->
{'
cidr
'});
}
...
...
@@ -205,27 +197,29 @@ sub _cidr2mask_v4 {
sub
_cidr2mask_v6
{
my
$self
=
shift
;
return
pack
('
B128
',
'
1
'
x
$self
->
{'
cidr
'});
return
pack
('
B128
',
'
1
'
x
$self
->
{'
cidr
'});
}
# Function to match an v4 address
sub
_ipv4_matcher
{
no
locale
;
my
(
$self
,
$test
)
=
@_
;
my
$mask
=
$test
->
_cidr2mask_v4
();
my
$mask
=
$test
->
_cidr2mask_v4
();
return
((
inet_aton
(
$test
->
{'
ip
'})
&
$mask
)
eq
(
inet_aton
(
$self
->
{'
ip
'})
&
$mask
));
return
((
inet_aton
(
$test
->
{'
ip
'})
&
$mask
)
eq
(
inet_aton
(
$self
->
{'
ip
'})
&
$mask
))
?
1
:
0
;
}
# Function to match an v6 address
sub
_ipv6_matcher
{
no
locale
;
my
(
$self
,
$test
)
=
@_
;
my
$mask
=
$test
->
_cidr2mask_v6
();
my
$mask
=
$test
->
_cidr2mask_v6
();
return
((
inet_pton
(
AF_INET6
,
$test
->
{'
ip
'})
&
$mask
)
eq
(
inet_pton
(
AF_INET6
,
$self
->
{'
ip
'})
&
$mask
));
return
((
inet_pton
(
AF_INET6
,
$test
->
{'
ip
'})
&
$mask
)
eq
(
inet_pton
(
AF_INET6
,
$self
->
{'
ip
'})
&
$mask
))
?
1
:
0
;
}
...
...
Write
Preview
Supports
Markdown
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