Server IP : 85.214.239.14 / Your IP : 3.142.36.215 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/3/cwd/proc/3/cwd/usr/share/perl5/Net/SNMP/Transport/IPv4/ |
Upload File : |
# -*- mode: perl -*- # ============================================================================ package Net::SNMP::Transport::IPv4::UDP; # $Id: UDP.pm,v 4.0 2009/09/09 15:05:33 dtown Rel $ # Object that handles the UDP/IPv4 Transport Domain for the SNMP Engine. # Copyright (c) 2001-2009 David M. Town <dtown@cpan.org> # All rights reserved. # This program is free software; you may redistribute it and/or modify it # under the same terms as the Perl 5 programming language system itself. # ============================================================================ use strict; use Net::SNMP::Transport qw( DOMAIN_UDPIPV4 ); use IO::Socket qw( SOCK_DGRAM ); ## Version of the Net::SNMP::Transport::IPv4::UDP module our $VERSION = v4.0.0; ## Handle importing/exporting of symbols use base qw( Net::SNMP::Transport::IPv4 Net::SNMP::Transport ); sub import { return Net::SNMP::Transport->export_to_level(1, @_); } ## RFC 3411 - snmpEngineMaxMessageSize::=INTEGER (484..2147483647) sub MSG_SIZE_DEFAULT_UDP4 { 1472 } # Ethernet(1500) - IPv4(20) - UDP(8) # [public methods] ----------------------------------------------------------- sub new { return shift->SUPER::_new(@_); } sub send { my $this = shift; $this->_error_clear(); if (length($_[0]) > $this->{_max_msg_size}) { return $this->_error( 'The message size %d exceeds the maxMsgSize %d', length($_[0]), $this->{_max_msg_size} ); } my $bytes = $this->{_socket}->send($_[0], 0, $this->{_dest_name}); return defined($bytes) ? $bytes : $this->_perror('Send failure'); } sub recv { my $this = shift; $this->_error_clear(); my $name = $this->{_socket}->recv($_[0], $this->_shared_max_size(), 0); return defined($name) ? $name : $this->_perror('Receive failure'); } sub domain { return DOMAIN_UDPIPV4; # transportDomainUdpIpv4 } sub type { return 'UDP/IPv4'; # udpIpv4(1) } sub agent_addr { my ($this) = @_; $this->_error_clear(); my $name = $this->{_socket}->sockname() || $this->{_sock_name}; if ($this->{_socket}->connect($this->{_dest_name})) { $name = $this->{_socket}->sockname() || $this->{_sock_name}; if (!$this->{_socket}->connect((pack('x') x length $name))) { $this->_perror('Failed to disconnect'); } } return $this->_address($name); } # [private methods] ---------------------------------------------------------- sub _protocol_name { return 'udp'; } sub _protocol_type { return SOCK_DGRAM; } sub _msg_size_default { return MSG_SIZE_DEFAULT_UDP4; } sub _tdomain { return DOMAIN_UDPIPV4; } # ============================================================================ 1; # [end Net::SNMP::Transport::IPv4::UDP]