| line | stmt | bran | cond | sub | pod | time | code | 
| 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 |  |  | 1 |  | 17 | use 5.006; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 45 |  | 
| 31 | 1 |  |  | 1 |  | 5 | use strict; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 28 |  | 
| 32 | 1 |  |  | 1 |  | 5 | use warnings; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 25 |  | 
| 33 |  |  |  |  |  |  |  | 
| 34 | 1 |  |  | 1 |  | 5 | use Carp; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 339 |  | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | #our $VERSION = '0.01'; | 
| 37 |  |  |  |  |  |  |  | 
| 38 |  |  |  |  |  |  | our $AUTOLOAD; | 
| 39 |  |  |  |  |  |  |  | 
| 40 |  |  |  |  |  |  | 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 |  |  |  |  |  |  | { | 
| 55 | 0 |  |  | 0 | 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 |  |  |  |  |  |  | { | 
| 86 | 0 |  |  | 0 |  |  | my $self = shift; | 
| 87 |  |  |  |  |  |  |  | 
| 88 | 0 | 0 |  |  |  |  | return if $AUTOLOAD =~ /DESTROY$/; | 
| 89 |  |  |  |  |  |  |  | 
| 90 | 0 |  |  |  |  |  | my ($name) = $AUTOLOAD =~ /::([^:]+)$/; | 
| 91 |  |  |  |  |  |  | #print "Called $name\n"; | 
| 92 |  |  |  |  |  |  |  | 
| 93 | 0 | 0 |  |  |  |  | if (!exists $oids{$name}) { | 
| 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 | 0 |  |  |  |  | if ($response) { | 
| 104 | 0 |  |  |  |  |  | return $response->{$oid}; | 
| 105 |  |  |  |  |  |  | } else { | 
| 106 | 0 |  |  |  |  |  | return undef; | 
| 107 |  |  |  |  |  |  | } | 
| 108 |  |  |  |  |  |  | } | 
| 109 |  |  |  |  |  |  |  | 
| 110 |  |  |  |  |  |  | 1; | 
| 111 |  |  |  |  |  |  |  | 
| 112 |  |  |  |  |  |  | __END__ |