Info/Layer7/Kemp.pm untested

filter: Statementstmt 0.0% 0 / 63 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 25 MC/DCmcdc 0.0% 0 / 15 Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 8 totaltotal 0.0% 0 / 139 CC 9 SCAR 23.6
CC
9
Cov
0%
_vip_addresses
30.0
serial
6.0
ip_table
6.0
CRAP 10.6
1 # SNMP::Info::Layer7::Kemp
2 #
3 # Copyright (c) 2026 df-an and the SNMP::Info Developers
4 # All rights reserved.
5 #
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions are met:
8 #
9 # * Redistributions of source code must retain the above copyright notice,
10 # this list of conditions and the following disclaimer.
11 # * Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
14 # * Neither the name of the University of California, Santa Cruz nor the
15 # names of its contributors may be used to endorse or promote products
16 # derived from this software without specific prior written permission.
17 #
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22 # LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 # POSSIBILITY OF SUCH DAMAGE.
29  
30 package SNMP::Info::Layer7::Kemp;
31  
32 use strict;
33 use warnings;
34 use Exporter;
35 use SNMP::Info::Layer7;
36  
37 our @ISA = qw/SNMP::Info::Layer7 Exporter/;
38 our @EXPORT_OK = qw//;
39 our ($VERSION, %GLOBALS, %MIBS, %FUNCS, %MUNGE);
40  
41 $VERSION = '3.985003';
42  
43 %MIBS = (
44 %SNMP::Info::Layer7::MIBS,
45 'B100-MIB' => 'patchVersion',
46 'SNMP-FRAMEWORK-MIB' => 'snmpEngineID',
47 );
48  
49 %GLOBALS = (
50 %SNMP::Info::Layer7::GLOBALS,
51 'os_ver' => 'B100-MIB::patchVersion',
52 'kemp_engine_id' => 'SNMP-FRAMEWORK-MIB::snmpEngineID',
53 );
54  
55 %FUNCS = (
56 %SNMP::Info::Layer7::FUNCS,
57 'kemp_vs_ip' => 'B100-MIB::vSIp',
58 'kemp_vs_addrtype' => 'B100-MIB::vSAddrtype',
59 );
60  
61 %MUNGE = (
62 %SNMP::Info::Layer7::MUNGE,
63 'kemp_vs_ip' => \&SNMP::Info::munge_inetaddress,
64 );
65  
66 sub vendor { return 'kemp'; }
67 sub model { return 'LoadMaster'; }
68 sub os { return 'LMOS'; }
69  
70 sub serial {
71 my $kemp = shift;
72 my $raw = $kemp->kemp_engine_id();
73 return unless defined $raw and length $raw;
74  
75 return 'SNMP-ENGINEID-' . uc(unpack('H*', $raw));
76 }
77  
78 # The legacy ip_* methods enumerate IPv4 only. Service indices are not
79 # ifIndex values, and the vendor MIB supplies neither interfaces nor masks.
80 sub _vip_addresses {
81 my $kemp = shift;
82 my $ips = $kemp->kemp_vs_ip() || {};
83 my $types = $kemp->kemp_vs_addrtype() || {};
84 my %vips;
85 foreach my $iid (keys %$ips) {
86 my $type = $types->{$iid};
87 next unless defined $type and ($type eq 'ipv4' or $type eq '1');
88 my $ip = $ips->{$iid};
89 next unless defined $ip and $ip =~ /^(\d{1,3}\.){3}\d{1,3}$/;
90 next if grep { $_ > 255 } split /\./, $ip;
91 next if $ip eq '0.0.0.0' or $ip eq '255.255.255.255';
92 $vips{$ip} = 1;
93 }
94 return \%vips;
95 }
96  
97 sub ip_table {
98 my $kemp = shift;
99 my %ips = %{ $kemp->SUPER::ip_table() || {} };
100 foreach my $ip (keys %{ $kemp->_vip_addresses() }) {
101 $ips{$ip} = $ip unless exists $ips{$ip};
102 }
103 return \%ips;
104 }
105  
106 sub ip_index {
107 my $kemp = shift;
108 my %indices = %{ $kemp->SUPER::ip_index() || {} };
109 foreach my $ip (keys %{ $kemp->_vip_addresses() }) {
110 $indices{$ip} = 0 unless exists $indices{$ip};
111 }
112 return \%indices;
113 }
114  
115 sub ip_netmask {
116 my $kemp = shift;
117 my %masks = %{ $kemp->SUPER::ip_netmask() || {} };
118 foreach my $ip (keys %{ $kemp->_vip_addresses() }) {
119 $masks{$ip} = '255.255.255.255' unless exists $masks{$ip};
120 }
121 return \%masks;
122 }
123  
124 1;
125 __END__