Net-SNMP

 view release on metacpan or  search on metacpan

lib/Net/SNMP/PDU.pm  view on Meta::CPAN

{
   return $_[0]->{_enterprise};
}

sub agent_addr
{
   return $_[0]->{_agent_addr};
}

sub generic_trap
{
   return $_[0]->{_generic_trap};
}

sub specific_trap
{
   return $_[0]->{_specific_trap};
}

sub time_stamp
{
   return $_[0]->{_time_stamp};
}

sub var_bind_list
{
   my ($this, $vbl, $types) = @_;

   return if defined $this->{_error};

   if (@_ > 1) {

      # The VarBindList HASH is being updated from an external
      # source.  We need to update the VarBind names ARRAY to
      # correspond to the new keys of the HASH.  If the updated
      # information is valid, we will use lexicographical ordering
      # for the ARRAY entries since we do not have a PDU to use
      # to determine the ordering.  The ASN.1 types HASH is also
      # updated here if a cooresponding HASH is passed.  We double
      # check the mapping by populating the hash with the keys of
      # the VarBindList HASH. 

      if (!defined($vbl) || (ref($vbl) ne 'HASH')) {

         $this->{_var_bind_list}  = undef;
         $this->{_var_bind_names} = [];
         $this->{_var_bind_types} = undef;

      } else {

         $this->{_var_bind_list} = $vbl;

         @{$this->{_var_bind_names}} =
            map  { $_->[0] }
               sort { $a->[1] cmp $b->[1] }
                  map
                  {
                     my $oid = $_;
                     $oid =~ s/^\.//;
                     $oid =~ s/ /\.0/g;
                     [$_, pack 'N*', split m/\./, $oid]
                  } keys %{$vbl};

         if (!defined($types) || (ref($types) ne 'HASH')) {
             $types = {};
         }

         for (keys %{$vbl}) {
            $this->{_var_bind_types}->{$_} =
               exists($types->{$_}) ? $types->{$_} : undef;
         }

      }

   }

   return $this->{_var_bind_list};
}

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

   return [] if defined($this->{_error}) || !defined $this->{_var_bind_names};

   return $this->{_var_bind_names};
}

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

   return if defined $this->{_error};

   return $this->{_var_bind_types};
}

sub scoped
{
   return $_[0]->{_scoped};
}

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

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

   return TRUE if (($this->{_version} < SNMP_VERSION_3) || ($this->{_scoped}));

   # contextName::=OCTET STRING
   if (!defined $this->prepare(OCTET_STRING, $this->context_name())) {
      return $this->_error();
   }

   # contextEngineID::=OCTET STRING
   if (!defined $this->prepare(OCTET_STRING, $this->context_engine_id())) {
      return $this->_error();
   }

   # ScopedPDU::=SEQUENCE



( run in 0.535 second using v1.01-cache-2.11-cpan-71847e10f99 )