gtpc2m8l | C/C++ Language Support User's Guide |
This function encodes Simple Network Management Protocol (SNMP) variables using a subset of the basic encoding rules (BER). Use this function when passing variables from the UMIB user exit and when encoding a variable binding list for the tpf_itrpc C/C++ function or the ITRPC macro. For information about BER encoding, see ISO 8825 Part 1: Basic Encoding Rules. Go to http://www.iso.ch/ to view ISO 8825.
Format
#include <c$snmp.h> int tpf_snmp_BER_encode(struct snmp_struct *snmp_structure_ptr);
Normal Return
A value of 0. The following field in snmp_struct was updated:
Error Return
A value of -1. An unsupported type or length was passed. No elements in snmp_struct were updated.
Programming Considerations
This function is implemented in dynamic link library (DLL) CNMP. You must use the definition side-deck for DLL CNMP to link-edit an application that uses this function.
Examples
The following example encodes a 7-byte object identifier pointed to by oid_ptr in BER format.
#include <c$snmp.h> #include <stdlib.h> #include <string.h> extern "C" int QZZ8() { struct snmp_struct snmp_structure_ptr; char buffer_ptr[100]; char *oid_ptr; int rc,length=0; oid_ptr = (char *)malloc(24); memcpy(oid_ptr, "\x2B\x06\x01\x02\x01\x04\x01", 7); snmp_structure_ptr.snmp_input_type = ISNMP_TYPE_OBJECTID; snmp_structure_ptr.snmp_input_length = 7; snmp_structure_ptr.snmp_input_value = oid_ptr; snmp_structure_ptr.snmp_output_value = buffer_ptr; rc = tpf_snmp_BER_encode(&snmp_structure_ptr); if (rc == -1) return(-1); length += snmp_structure_ptr.snmp_output_length; return (0); }
Related Information