Radius/Constants.pm

filter: Statementstmt 75.8% 22 / 29 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod 100% 1 / 1 totaltotal 64.4% 29 / 45 CC 5 SCAR 26.5
CC
5
Cov
59%
accepting_packet_type
30.0
BEGIN
1.0
BEGIN
1.0
CRAP 14.2
« Radius/Encode.pm ↑ Summary Radius/Decode.pm »
1 package Data::Radius::Constants;
2 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 4 our %RFC_TYPES;
6  
7 4 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 %RFC_TYPES = (
9 # RADIUS Codes
10 ACCESS_REQUEST => 1,
11 ACCESS_ACCEPT => 2,
12 ACCESS_REJECT => 3,
13 ACCOUNTING_REQUEST => 4,
14 ACCOUNTING_RESPONSE => 5,
15 ACCOUNTING_STATUS => 6,
16 ACCESS_CHALLENGE => 11,
17 # unused - not exported
18 STATUS_SERVER => 12,
19 STATUS_CLIENT => 13,
20 # rfc3576
21 DISCONNECT_REQUEST => 40,
22 DISCONNECT_ACCEPT => 41,
23 DISCONNECT_REJECT => 42,
24 COA_REQUEST => 43,
25 COA_ACCEPT => 44,
26 COA_REJECT => 45,
27 );
28 }
29 4 ▶use constant \%RFC_TYPES;
Subroutine BEGIN: called CC=1 SCAR=0.0
30  
31 4 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33 4 our @EXPORT_OK = (
34 keys (%RFC_TYPES),
35 qw(
36 %RFC_TYPES
37 %RADIUS_PACKET_TYPES
38 accepting_packet_type
39 )
40 );
41 4 our %EXPORT_TAGS = ( all => [ @EXPORT_OK ] );
42  
43 4 ▶use Const::Fast;
Subroutine BEGIN: called CC=1 SCAR=0.0
44  
45 # include all canonical type names and some aliases
46 4 const our %RADIUS_PACKET_TYPES => (
47 %RFC_TYPES,
48 # and aliases
49 'COA' => COA_REQUEST,
50 'DM' => DISCONNECT_REQUEST,
51 'POD' => DISCONNECT_REQUEST,
52 'ACCT' => ACCOUNTING_REQUEST,
53 'AUTH' => ACCESS_REQUEST,
54 );
55  
56 4 const my %accepting_types => (
57 &ACCESS_REQUEST => {
58 &ACCESS_ACCEPT => 1,
59 &ACCESS_REJECT => 0,
60 &ACCESS_CHALLENGE => undef, # this requires explicit handling
61 },
62 &ACCOUNTING_REQUEST => {
63 &ACCOUNTING_RESPONSE => 1,
64 },
65 &ACCOUNTING_STATUS => {
66 &ACCOUNTING_RESPONSE => 1,
67 },
68 &DISCONNECT_REQUEST => {
69 &DISCONNECT_ACCEPT => 1,
70 &DISCONNECT_REJECT => 0,
71 },
72 &COA_REQUEST => {
73 &COA_ACCEPT => 1,
74 &COA_REJECT => 0,
75 },
76 );
77  
78 0 ▶sub accepting_packet_type {
Subroutine accepting_packet_type: not called CC=5 SCAR=34.0
Pod documented
79 0 my ($req_type, $response_type) = @_;
80 $req_type = $RADIUS_PACKET_TYPES{$req_type}
81 0 ▶ if exists $RADIUS_PACKET_TYPES{$req_type};
Branch: 1 branch
BranchTrueFalseTotal
if exists $Data::Radius::Constants::RADIUS_PACKET_TYPES{$req_type} 0 0 0
82 0 ▶ return undef unless exists $accepting_types{$req_type};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $accepting_types{$req_type} 0 0 0
83 0 my $atr = $accepting_types{$req_type};
84 $response_type = $RADIUS_PACKET_TYPES{$response_type}
85 0 ▶ if exists $RADIUS_PACKET_TYPES{$response_type};
Branch: 1 branch
BranchTrueFalseTotal
if exists $Data::Radius::Constants::RADIUS_PACKET_TYPES{$response_type} 0 0 0
86 0 ▶ return undef unless exists $atr->{$response_type};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $atr->{$response_type} 0 0 0
87 0 return $atr->{$response_type};
88 }
89  
90 4 1;
91  
92 __END__
« Radius/Encode.pm ↑ Summary Radius/Decode.pm »