| 1 | package Net::SNMP::HostInfo::UdpEntry; | ||||||||||
| 2 | |||||||||||
| 3 | =head1 NAME | ||||||||||
| 4 | |||||||||||
| 5 | Net::SNMP::HostInfo::UdpEntry - An entry in the udpTable of a MIB-II host | ||||||||||
| 6 | |||||||||||
| 7 | =head1 SYNOPSIS | ||||||||||
| 8 | |||||||||||
| 9 | use Net::SNMP::HostInfo; | ||||||||||
| 10 | |||||||||||
| 11 | $host = shift || 'localhost'; | ||||||||||
| 12 | $hostinfo = Net::SNMP::HostInfo->new(Hostname => $host); | ||||||||||
| 13 | |||||||||||
| 14 | print "\nUdp Listeners Table:\n"; | ||||||||||
| 15 | printf "%-15s %-5s\n", | ||||||||||
| 16 | qw/LocalAddress Port/; | ||||||||||
| 17 | for $entry ($hostinfo->udpTable) { | ||||||||||
| 18 | printf "%-15s %-5s\n", | ||||||||||
| 19 | $entry->udpLocalAddress, | ||||||||||
| 20 | $entry->udpLocalPort; | ||||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | =head1 DESCRIPTION | ||||||||||
| 24 | |||||||||||
| 25 | "Information about a particular current UDP | ||||||||||
| 26 | listener." | ||||||||||
| 27 | |||||||||||
| 28 | =cut | ||||||||||
| 29 | |||||||||||
| 30 | 1 | ▶ | use 5.006; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 31 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 32 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 33 | |||||||||||
| 34 | 1 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 35 | |||||||||||
| 36 | #our $VERSION = '0.01'; | ||||||||||
| 37 | |||||||||||
| 38 | 1 | our $AUTOLOAD; | |||||||||
| 39 | |||||||||||
| 40 | 1 | my %oids = ( | |||||||||
| 41 | udpLocalAddress => '1.3.6.1.2.1.7.5.1.1', | ||||||||||
| 42 | udpLocalPort => '1.3.6.1.2.1.7.5.1.2', | ||||||||||
| 43 | ); | ||||||||||
| 44 | |||||||||||
| 45 | # Preloaded methods go here. | ||||||||||
| 46 | |||||||||||
| 47 | =head1 METHODS | ||||||||||
| 48 | |||||||||||
| 49 | =over | ||||||||||
| 50 | |||||||||||
| 51 | =cut | ||||||||||
| 52 | |||||||||||
| 53 | sub new | ||||||||||
| 54 | 0 | ▶ | { | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 55 | 0 | my $class = shift; | |||||||||
| 56 | |||||||||||
| 57 | 0 | my %args = @_; | |||||||||
| 58 | |||||||||||
| 59 | 0 | my $self = {}; | |||||||||
| 60 | |||||||||||
| 61 | 0 | $self->{_session} = $args{Session}; | |||||||||
| 62 | 0 | $self->{_decode} = $args{Decode}; | |||||||||
| 63 | 0 | $self->{_index} = $args{Index}; | |||||||||
| 64 | |||||||||||
| 65 | 0 | bless $self, $class; | |||||||||
| 66 | 0 | return $self; | |||||||||
| 67 | } | ||||||||||
| 68 | |||||||||||
| 69 | =item udpLocalAddress | ||||||||||
| 70 | |||||||||||
| 71 | "The local IP address for this UDP listener. In | ||||||||||
| 72 | the case of a UDP listener which is willing to | ||||||||||
| 73 | accept datagrams for any IP interface associated | ||||||||||
| 74 | with the node, the value 0.0.0.0 is used." | ||||||||||
| 75 | |||||||||||
| 76 | =item udpLocalPort | ||||||||||
| 77 | |||||||||||
| 78 | "The local port number for this UDP listener." | ||||||||||
| 79 | |||||||||||
| 80 | =back | ||||||||||
| 81 | |||||||||||
| 82 | =cut | ||||||||||
| 83 | |||||||||||
| 84 | sub AUTOLOAD | ||||||||||
| 85 | 0 | ▶ | { | ||||||||
|
Subroutine
AUTOLOAD: not called CC=4 SCAR=30.0
| |||||||||||
| 86 | 0 | my $self = shift; | |||||||||
| 87 | |||||||||||
| 88 | 0 | ▶ | return if $AUTOLOAD =~ /DESTROY$/; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 89 | |||||||||||
| 90 | 0 | my ($name) = $AUTOLOAD =~ /::([^:]+)$/; | |||||||||
| 91 | #print "Called $name\n"; | ||||||||||
| 92 | |||||||||||
| 93 | 0 | ▶ | if (!exists $oids{$name}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 94 | 0 | croak "Can't locate object method '$name'"; | |||||||||
| 95 | } | ||||||||||
| 96 | |||||||||||
| 97 | 0 | my $oid = $oids{$name} . '.' . $self->{_index}; | |||||||||
| 98 | |||||||||||
| 99 | #print "Trying $oid\n"; | ||||||||||
| 100 | |||||||||||
| 101 | 0 | my $response = $self->{_session}->get_request($oid); | |||||||||
| 102 | |||||||||||
| 103 | 0 | ▶ | if ($response) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 104 | 0 | return $response->{$oid}; | |||||||||
| 105 | } else { | ||||||||||
| 106 | 0 | return undef; | |||||||||
| 107 | } | ||||||||||
| 108 | } | ||||||||||
| 109 | |||||||||||
| 110 | 1 | 1; | |||||||||
| 111 | |||||||||||
| 112 | __END__ | ||||||||||