Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Use hash variable as constant

by kcott (Archbishop)
on Jun 27, 2014 at 15:50 UTC ( [id://1091489]=note: print w/replies, xml ) Need Help??


in reply to Use hash variable as constant

G'day Virus2500,

Welcome to the monastery.

"... which i want to get "translated" by Net::SNMP."

You may find some of these (from Net::SNMP's documentation) useful:

"However afaik Net::SNMP translates the bareword INTEGER into an integer value... right?"

You can find the answer to this by tracking back through the code. Doing so will likely increase your understanding of the module and how it works.

From source code for Net::SNMP v6.0.1:

use Net::SNMP::PDU qw( :ALL !DEBUG_INFO );

From source code for Net::SNMP::PDU v6.0.1:

use base qw( Net::SNMP::Message ); sub import { return Net::SNMP::Message->export_to_level(1, @_); }

[See Exporter - Exporting Without Using Exporter's import Method for export_to_level() doco.]

From source code for Net::SNMP::Message v6.0.1:

our %EXPORT_TAGS = ( ... types => [ qw( INTEGER INTEGER32 OCTET_STRING ... ... ); Exporter::export_ok_tags( qw( ... types ... ) ); $EXPORT_TAGS{ALL} = [ @EXPORT_OK ]; ## ASN.1 Basic Encoding Rules type definitions sub INTEGER { 0x02 } # INTEGER sub INTEGER32 { 0x02 } # Integer32 - SNMPv2c sub OCTET_STRING { 0x04 } # OCTET STRING ...

I'll leave you to explore further ...

[While reviewing this source code, also look at sub prepare { ... }), which contains the source of your error message (i.e. $_[0]->_error('The ASN.1 type "%s" is unknown', $_[1])).]

"ERROR: The ASN.1 type "OCTET_STRING" is unknown"

Net::SNMP exports the symbol OCTET_STRING by default. The same is true for INTEGER. From source code for Net::SNMP v6.0.1:

use base qw( Exporter ); our @EXPORT = qw( INTEGER INTEGER32 OCTET_STRING ... );

Below this, are other ways to import them:

our %EXPORT_TAGS = ( asn1 => [ qw( INTEGER INTEGER32 OCTET_STRING ... ... Exporter::export_ok_tags( qw( asn1 debug generictrap snmp translate ) +); $EXPORT_TAGS{ALL} = [ @EXPORT_OK ];

[See also: Net::SNMP - EXPORTS]

Check how you are loading Net::SNMP; compare that with Net::SNMP - EXAMPLES.

[See also: use; Exporter]

-- Ken

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1091489]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-20 14:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found