Main Page | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

asn1.h File Reference

#include "snmp_pp/target.h"

Go to the source code of this file.

Compounds

struct  counter64
struct  snmp_pdu
struct  variable_list

Defines

#define MAXLENGTH_BUFFER   SNMP_MSG_LENGTH
#define MAX_SUBID   0xFFFFFFFF
#define MAX_OID_LEN   128
#define ASN_BOOLEAN   (0x01)
#define ASN_INTEGER   (0x02)
#define ASN_BIT_STR   (0x03)
#define ASN_OCTET_STR   (0x04)
#define ASN_NULL   (0x05)
#define ASN_OBJECT_ID   (0x06)
#define ASN_SEQUENCE   (0x10)
#define ASN_SET   (0x11)
#define ASN_UNIVERSAL   (0x00)
#define ASN_APPLICATION   (0x40)
#define ASN_CONTEXT   (0x80)
#define ASN_PRIVATE   (0xC0)
#define ASN_PRIMITIVE   (0x00)
#define ASN_CONSTRUCTOR   (0x20)
#define ASN_LONG_LEN   (0x80)
#define ASN_EXTENSION_ID   (0x1F)
#define ASN_BIT8   (0x80)
#define IS_CONSTRUCTOR(byte)   ((byte) & ASN_CONSTRUCTOR)
#define IS_EXTENSION_ID(byte)   (((byte) & ASN_EXTENSION_ID) == ASN_EXTENSION_ID)
#define ASN_MAX_NAME_LEN   128
#define SNMP_VERSION_1   0
#define SNMP_VERSION_2C   1
#define SNMP_VERSION_2STERN   2
#define SNMP_VERSION_3   3
#define SMI_IPADDRESS   (ASN_APPLICATION | 0)
#define SMI_COUNTER   (ASN_APPLICATION | 1)
#define SMI_GAUGE   (ASN_APPLICATION | 2)
#define SMI_TIMETICKS   (ASN_APPLICATION | 3)
#define SMI_OPAQUE   (ASN_APPLICATION | 4)
#define SMI_NSAP   (ASN_APPLICATION | 5)
#define SMI_COUNTER64   (ASN_APPLICATION | 6)
#define SMI_UINTEGER   (ASN_APPLICATION | 7)
#define GET_REQ_MSG   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0)
#define GETNEXT_REQ_MSG   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1)
#define GET_RSP_MSG   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2)
#define SET_REQ_MSG   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3)
#define TRP_REQ_MSG   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4)
#define GETBULK_REQ_MSG   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5)
#define INFORM_REQ_MSG   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6)
#define TRP2_REQ_MSG   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x7)
#define REPORT_MSG   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x8)
#define SNMP_NOSUCHOBJECT   (ASN_CONTEXT | ASN_PRIMITIVE | 0x0)
#define SNMP_NOSUCHINSTANCE   (ASN_CONTEXT | ASN_PRIMITIVE | 0x1)
#define SNMP_ENDOFMIBVIEW   (ASN_CONTEXT | ASN_PRIMITIVE | 0x2)
#define SNMP_MSG_LENGTH   MAX_SNMP_PACKET
#define ASNERROR(string)   debugprintf(3, "ASN parse error (%s)\n", string )

Typedefs

typedef unsigned long oid
typedef sockaddr_in ipaddr

Functions

DLLOPT unsigned char * asn_parse_int (unsigned char *data, int *datalength, unsigned char *type, long int *intp, int intsize)
DLLOPT unsigned char * asn_parse_unsigned_int (unsigned char *data, int *datalength, unsigned char *type, unsigned long *intp, int intsize)
DLLOPT unsigned char * asn_build_int (unsigned char *data, int *datalength, const unsigned char type, const long *intp, int intsize)
DLLOPT unsigned char * asn_build_unsigned_int (unsigned char *data, int *datalength, unsigned char type, unsigned long *intp, int intsize)
DLLOPT unsigned char * asn_parse_string (unsigned char *data, int *datalength, unsigned char *type, unsigned char *string, int *strlength)
DLLOPT unsigned char * asn_build_string (unsigned char *data, int *datalength, const unsigned char type, const unsigned char *string, const int strlength)
DLLOPT unsigned char * asn_parse_header (unsigned char *data, int *datalength, unsigned char *type)
DLLOPT unsigned char * asn_build_header (unsigned char *data, int *datalength, unsigned char type, int length)
DLLOPT unsigned char * asn_build_sequence (unsigned char *data, int *datalength, unsigned char type, int length)
DLLOPT unsigned char * asn_parse_length (unsigned char *data, unsigned long *length)
DLLOPT unsigned char * asn_build_length (unsigned char *data, int *datalength, int length)
DLLOPT unsigned char * asn_parse_objid (unsigned char *data, int *datalength, unsigned char *type, oid *objid, int *objidlength)
DLLOPT unsigned char * asn_build_objid (unsigned char *data, int *datalength, unsigned char type, oid *objid, int objidlength)
DLLOPT unsigned char * asn_parse_null (unsigned char *data, int *datalength, unsigned char *type)
DLLOPT unsigned char * asn_build_null (unsigned char *data, int *datalength, unsigned char type)
DLLOPT unsigned char * asn_parse_bitstring (unsigned char *data, int *datalength, unsigned char *type, unsigned char *string, int *strlength)
DLLOPT unsigned char * asn_build_bitstring (unsigned char *data, int *datalength, unsigned char type, unsigned char *string, int strlength)
DLLOPT unsigned char * asn_parse_unsigned_int64 (unsigned char *data, int *datalength, unsigned char *type, struct counter64 *cp, int countersize)
DLLOPT unsigned char * asn_build_unsigned_int64 (unsigned char *data, int *datalength, unsigned char type, struct counter64 *cp, int countersize)
DLLOPT struct snmp_pdusnmp_pdu_create (int command)
DLLOPT void snmp_free_pdu (struct snmp_pdu *pdu)
DLLOPT int snmp_build (struct snmp_pdu *pdu, unsigned char *packet, int *out_length, const long version, const unsigned char *community, const int community_len)
DLLOPT void snmp_add_var (struct snmp_pdu *pdu, oid *name, int name_length, SmiVALUE *smival)
DLLOPT int snmp_parse (struct snmp_pdu *pdu, unsigned char *data, int data_length, unsigned char *community_name, int &community_len, snmp_version &version)
DLLOPT unsigned char * build_vb (struct snmp_pdu *pdu, unsigned char *buf, int *buf_len)
DLLOPT unsigned char * build_data_pdu (struct snmp_pdu *pdu, unsigned char *buf, int *buf_len, unsigned char *vb_buf, int vb_buf_len)
DLLOPT unsigned char * snmp_build_var_op (unsigned char *data, oid *var_name, int *var_name_len, unsigned char var_val_type, int var_val_len, unsigned char *var_val, int *listlength)
DLLOPT unsigned char * snmp_parse_var_op (unsigned char *data, oid *var_name, int *var_name_len, unsigned char *var_val_type, int *var_val_len, unsigned char **var_val, int *listlength)
DLLOPT int snmp_parse_data_pdu (struct snmp_pdu *pdu, unsigned char *&data, int &length)
DLLOPT int snmp_parse_vb (struct snmp_pdu *pdu, unsigned char *&data, int &data_len)
DLLOPT void clear_pdu (struct snmp_pdu *pdu, bool clear_all=false)
DLLOPT unsigned char * asn1_build_header_data (unsigned char *outBuf, int *maxLength, long msgID, long maxMessageSize, unsigned char msgFlags, long securityModel)
 Encode the given values for the HeaderData into the buffer.

DLLOPT unsigned char * asn1_parse_header_data (unsigned char *buf, int *buf_len, long *msg_id, long *msg_max_size, unsigned char *msg_flags, long *msg_security_model)
 Parse the filled HeaderData of a SNMPv3 message and return the encoded values.

DLLOPT unsigned char * asn1_parse_scoped_pdu (unsigned char *scoped_pdu, int *scoped_pdu_len, unsigned char *context_engine_id, int *context_engine_id_len, unsigned char *context_name, int *context_name_len)
 Parse the ScopedPDU and return the encoded values.

DLLOPT unsigned char * asn1_build_scoped_pdu (unsigned char *outBuf, int *max_len, unsigned char *contextEngineID, long contextEngineIDLength, unsigned char *contextName, long contextNameLength, unsigned char *data, long dataLength)
 Encode the given values for the scopedPDU into the buffer.


Define Documentation

#define ASN_APPLICATION   (0x40)
 

Definition at line 76 of file asn1.h.

#define ASN_BIT8   (0x80)
 

Definition at line 92 of file asn1.h.

#define ASN_BIT_STR   (0x03)
 

Definition at line 62 of file asn1.h.

#define ASN_BOOLEAN   (0x01)
 

Definition at line 58 of file asn1.h.

#define ASN_CONSTRUCTOR   (0x20)
 

Definition at line 88 of file asn1.h.

#define ASN_CONTEXT   (0x80)
 

Definition at line 79 of file asn1.h.

#define ASN_EXTENSION_ID   (0x1F)
 

Definition at line 91 of file asn1.h.

#define ASN_INTEGER   (0x02)
 

Definition at line 60 of file asn1.h.

#define ASN_LONG_LEN   (0x80)
 

Definition at line 90 of file asn1.h.

#define ASN_MAX_NAME_LEN   128
 

Definition at line 97 of file asn1.h.

#define ASN_NULL   (0x05)
 

Definition at line 65 of file asn1.h.

#define ASN_OBJECT_ID   (0x06)
 

Definition at line 67 of file asn1.h.

#define ASN_OCTET_STR   (0x04)
 

Definition at line 63 of file asn1.h.

#define ASN_PRIMITIVE   (0x00)
 

Definition at line 85 of file asn1.h.

#define ASN_PRIVATE   (0xC0)
 

Definition at line 82 of file asn1.h.

#define ASN_SEQUENCE   (0x10)
 

Definition at line 69 of file asn1.h.

#define ASN_SET   (0x11)
 

Definition at line 71 of file asn1.h.

#define ASN_UNIVERSAL   (0x00)
 

Definition at line 73 of file asn1.h.

#define ASNERROR string   )     debugprintf(3, "ASN parse error (%s)\n", string )
 

Definition at line 131 of file asn1.h.

#define GET_REQ_MSG   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0)
 

Definition at line 113 of file asn1.h.

#define GET_RSP_MSG   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2)
 

Definition at line 115 of file asn1.h.

#define GETBULK_REQ_MSG   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5)
 

Definition at line 119 of file asn1.h.

#define GETNEXT_REQ_MSG   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1)
 

Definition at line 114 of file asn1.h.

#define INFORM_REQ_MSG   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6)
 

Definition at line 120 of file asn1.h.

#define IS_CONSTRUCTOR byte   )     ((byte) & ASN_CONSTRUCTOR)
 

Definition at line 94 of file asn1.h.

#define IS_EXTENSION_ID byte   )     (((byte) & ASN_EXTENSION_ID) == ASN_EXTENSION_ID)
 

Definition at line 95 of file asn1.h.

#define MAX_OID_LEN   128
 

Definition at line 55 of file asn1.h.

#define MAX_SUBID   0xFFFFFFFF
 

Definition at line 49 of file asn1.h.

#define MAXLENGTH_BUFFER   SNMP_MSG_LENGTH
 

Definition at line 46 of file asn1.h.

#define REPORT_MSG   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x8)
 

Definition at line 122 of file asn1.h.

#define SET_REQ_MSG   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3)
 

Definition at line 116 of file asn1.h.

#define SMI_COUNTER   (ASN_APPLICATION | 1)
 

Definition at line 105 of file asn1.h.

#define SMI_COUNTER64   (ASN_APPLICATION | 6)
 

Definition at line 110 of file asn1.h.

#define SMI_GAUGE   (ASN_APPLICATION | 2)
 

Definition at line 106 of file asn1.h.

#define SMI_IPADDRESS   (ASN_APPLICATION | 0)
 

Definition at line 104 of file asn1.h.

#define SMI_NSAP   (ASN_APPLICATION | 5)
 

Definition at line 109 of file asn1.h.

#define SMI_OPAQUE   (ASN_APPLICATION | 4)
 

Definition at line 108 of file asn1.h.

#define SMI_TIMETICKS   (ASN_APPLICATION | 3)
 

Definition at line 107 of file asn1.h.

#define SMI_UINTEGER   (ASN_APPLICATION | 7)
 

Definition at line 111 of file asn1.h.

#define SNMP_ENDOFMIBVIEW   (ASN_CONTEXT | ASN_PRIMITIVE | 0x2)
 

Definition at line 126 of file asn1.h.

#define SNMP_MSG_LENGTH   MAX_SNMP_PACKET
 

Definition at line 128 of file asn1.h.

Referenced by SnmpMessage::SnmpMessage().

#define SNMP_NOSUCHINSTANCE   (ASN_CONTEXT | ASN_PRIMITIVE | 0x1)
 

Definition at line 125 of file asn1.h.

#define SNMP_NOSUCHOBJECT   (ASN_CONTEXT | ASN_PRIMITIVE | 0x0)
 

Definition at line 124 of file asn1.h.

#define SNMP_VERSION_1   0
 

Definition at line 98 of file asn1.h.

#define SNMP_VERSION_2C   1
 

Definition at line 99 of file asn1.h.

#define SNMP_VERSION_2STERN   2
 

Definition at line 100 of file asn1.h.

#define SNMP_VERSION_3   3
 

Definition at line 101 of file asn1.h.

#define TRP2_REQ_MSG   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x7)
 

Definition at line 121 of file asn1.h.

#define TRP_REQ_MSG   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4)
 

Definition at line 117 of file asn1.h.


Typedef Documentation

typedef struct sockaddr_in ipaddr
 

Definition at line 137 of file asn1.h.

typedef unsigned long oid
 

Definition at line 48 of file asn1.h.

Referenced by Vb::get_oid(), Vb::set_oid(), and Vb::Vb().


Function Documentation

DLLOPT unsigned char* asn1_build_header_data unsigned char *  outBuf,
int *  maxLength,
long  msgID,
long  maxMessageSize,
unsigned char  msgFlags,
long  securityModel
 

Encode the given values for the HeaderData into the buffer.

HeaderData ::= SEQUENCE { msgID INTEGER (0..2147483647), msgMaxSize INTEGER (484..2147483647), msgFlags OCTET STRING (SIZE(1)), msgSecurityModel INTEGER (0..2147483647) }
Parameters:
outBuf - The buffer
maxLength - IN: length of the buffer OUT: free bytes left in the buffer
msgID - The message ID
maxMessageSize - The maximum size of a SNMPv3 message
msgFlags - The message Flags
securityModel - The security model
Returns:
- Pointer to the first free byte in the buffer or NULL if an error occured

DLLOPT unsigned char* asn1_build_scoped_pdu unsigned char *  outBuf,
int *  max_len,
unsigned char *  contextEngineID,
long  contextEngineIDLength,
unsigned char *  contextName,
long  contextNameLength,
unsigned char *  data,
long  dataLength
 

Encode the given values for the scopedPDU into the buffer.

ScopedPDU ::= SEQUENCE { contextEngineID OCTET STRING contextName OCTET STRING data ANY -- PDU }
param outBuf - The buffer param max_len - IN: length of the buffer OUT: free bytes left in the buffer param contextEngineID - The contextEngineID param contextEngineIDLength - The length of the contextEngineID param contextName - The contextName param contextNameLength - The length of the contextName param data - The already encoded data param dataLength - The length of the data

Returns:
- Pointer to the first free byte in the buffer or NULL if an error occured

DLLOPT unsigned char* asn1_parse_header_data unsigned char *  buf,
int *  buf_len,
long *  msg_id,
long *  msg_max_size,
unsigned char *  msg_flags,
long *  msg_security_model
 

Parse the filled HeaderData of a SNMPv3 message and return the encoded values.

HeaderData ::= SEQUENCE { msgID INTEGER (0..2147483647), msgMaxSize INTEGER (484..2147483647), msgFlags OCTET STRING (SIZE(1)), msgSecurityModel INTEGER (0..2147483647) }

Parameters:
buf - The buffer to parse
buf_len - IN: The length of the buffer OUT: The number of bytes after this object int the buffer
msg_id - OUT: The message id
msg_max_size - OUT: THe maximum message size of the sender
msg_flags - OUT: The message flags
msg_security_model - OUT: The security model used to build this message
Returns:
- Returns a pointer to the first byte past the end of the object HeaderData (i.e. the start of the next object). Returns NULL on any error.

DLLOPT unsigned char* asn1_parse_scoped_pdu unsigned char *  scoped_pdu,
int *  scoped_pdu_len,
unsigned char *  context_engine_id,
int *  context_engine_id_len,
unsigned char *  context_name,
int *  context_name_len
 

Parse the ScopedPDU and return the encoded values.

ScopedPDU ::= SEQUENCE { contextEngineID OCTET STRING, contextName OCTET STRING, data ANY -- e.g., PDUs as defined in RFC 1905 }

Parameters:
scoped_pdu - The buffer to parse
scoped_pdu_len - IN: The length of the buffer OUT: The number of bytes after this object int the buffer
context_engine_id - OUT: The parsed contextEngineID
context_engine_id_len - OUT: The length of the contextEngineID
context_name - OUT: The parsed contextName
context_name_len - OUT: The length of the contextName
Returns:
- Pointer to the data object of the scopedPDU or NULL on any error.

DLLOPT unsigned char* asn_build_bitstring unsigned char *  data,
int *  datalength,
unsigned char  type,
unsigned char *  string,
int  strlength
 

DLLOPT unsigned char* asn_build_header unsigned char *  data,
int *  datalength,
unsigned char  type,
int  length
 

DLLOPT unsigned char* asn_build_int unsigned char *  data,
int *  datalength,
const unsigned char  type,
const long *  intp,
int  intsize
 

DLLOPT unsigned char* asn_build_length unsigned char *  data,
int *  datalength,
int  length
 

DLLOPT unsigned char* asn_build_null unsigned char *  data,
int *  datalength,
unsigned char  type
 

DLLOPT unsigned char* asn_build_objid unsigned char *  data,
int *  datalength,
unsigned char  type,
oid objid,
int  objidlength
 

DLLOPT unsigned char* asn_build_sequence unsigned char *  data,
int *  datalength,
unsigned char  type,
int  length
 

DLLOPT unsigned char* asn_build_string unsigned char *  data,
int *  datalength,
const unsigned char  type,
const unsigned char *  string,
const int  strlength
 

DLLOPT unsigned char* asn_build_unsigned_int unsigned char *  data,
int *  datalength,
unsigned char  type,
unsigned long *  intp,
int  intsize
 

DLLOPT unsigned char* asn_build_unsigned_int64 unsigned char *  data,
int *  datalength,
unsigned char  type,
struct counter64 cp,
int  countersize
 

DLLOPT unsigned char* asn_parse_bitstring unsigned char *  data,
int *  datalength,
unsigned char *  type,
unsigned char *  string,
int *  strlength
 

DLLOPT unsigned char* asn_parse_header unsigned char *  data,
int *  datalength,
unsigned char *  type
 

DLLOPT unsigned char* asn_parse_int unsigned char *  data,
int *  datalength,
unsigned char *  type,
long int *  intp,
int  intsize
 

DLLOPT unsigned char* asn_parse_length unsigned char *  data,
unsigned long *  length
 

DLLOPT unsigned char* asn_parse_null unsigned char *  data,
int *  datalength,
unsigned char *  type
 

DLLOPT unsigned char* asn_parse_objid unsigned char *  data,
int *  datalength,
unsigned char *  type,
oid objid,
int *  objidlength
 

DLLOPT unsigned char* asn_parse_string unsigned char *  data,
int *  datalength,
unsigned char *  type,
unsigned char *  string,
int *  strlength
 

DLLOPT unsigned char* asn_parse_unsigned_int unsigned char *  data,
int *  datalength,
unsigned char *  type,
unsigned long *  intp,
int  intsize
 

DLLOPT unsigned char* asn_parse_unsigned_int64 unsigned char *  data,
int *  datalength,
unsigned char *  type,
struct counter64 cp,
int  countersize
 

DLLOPT unsigned char* build_data_pdu struct snmp_pdu pdu,
unsigned char *  buf,
int *  buf_len,
unsigned char *  vb_buf,
int  vb_buf_len
 

DLLOPT unsigned char* build_vb struct snmp_pdu pdu,
unsigned char *  buf,
int *  buf_len
 

DLLOPT void clear_pdu struct snmp_pdu pdu,
bool  clear_all = false
 

DLLOPT void snmp_add_var struct snmp_pdu pdu,
oid name,
int  name_length,
SmiVALUE smival
 

DLLOPT int snmp_build struct snmp_pdu pdu,
unsigned char *  packet,
int *  out_length,
const long  version,
const unsigned char *  community,
const int  community_len
 

DLLOPT unsigned char* snmp_build_var_op unsigned char *  data,
oid var_name,
int *  var_name_len,
unsigned char  var_val_type,
int  var_val_len,
unsigned char *  var_val,
int *  listlength
 

DLLOPT void snmp_free_pdu struct snmp_pdu pdu  ) 
 

DLLOPT int snmp_parse struct snmp_pdu pdu,
unsigned char *  data,
int  data_length,
unsigned char *  community_name,
int &  community_len,
snmp_version version
 

DLLOPT int snmp_parse_data_pdu struct snmp_pdu pdu,
unsigned char *&  data,
int &  length
 

DLLOPT unsigned char* snmp_parse_var_op unsigned char *  data,
oid var_name,
int *  var_name_len,
unsigned char *  var_val_type,
int *  var_val_len,
unsigned char **  var_val,
int *  listlength
 

DLLOPT int snmp_parse_vb struct snmp_pdu pdu,
unsigned char *&  data,
int &  data_len
 

DLLOPT struct snmp_pdu* snmp_pdu_create int  command  ) 
 


Generated on Tue Jan 4 22:42:14 2005 for SNMP++ by doxygen 1.3.2