This is a string that will be visible in the module table. It should give some hint about the function of this module.
This function is called upon loading the module. The module pointer should be stored by the module because it is needed in other calls and the argument vector will contain the arguments to this module from the daemons command line. This function should return 0 if everything is ok or an UNIX error code (see errno 3 ). Once the function returns 0, the fini function is called when the module is unloaded.
The module is unloaded. This gives the module a chance to free resources that are not automatically freed. Be sure to free all memory, because daemons tend to run very long. This function pointer may be NULL if it is not needed.
If this function pointer is not NULL, the function pointed to by it is called whenever the daemon is going to wait for an event. Try to avoid using this feature.
Whenever the daemon receives a SIGUSR1 it dumps it internal state via syslog(3). If the dump field is not NULL it is called by the daemon to dump the state of the module.
Whenever the daemon receives a SIGHUP signal it re-reads its configuration file. If the config field is not NULL it is called after reading the configuration file to give the module a chance to adapt to the new configuration.
If not NULL this function is called after successful loading and initializing the module to start its actual operation.
If the daemon receives a PDU and that PDU has a community string whos community was registered by this module and proxy is not NULL than this function is called to handle the PDU.
This is a pointer to the node array for the MIB tree implemented by this module.
This is the number of nodes in tree.
If this pointer is not NULL it is called whenever another module was loaded or unloaded. It gets a pointer to that module and a flag that is 0 for unloading and 1 for loading.
When everything is ok, the daemon merges the modules MIB tree into its current global tree, calls the modules init function. If this function returns an error, the modules MIB tree is removed from the global one and the module is unloaded. If initialisation is successful, the modules start function is called. After it returns the loaded functions of all modules (including the loaded one) are called.
When the module is unloaded, its MIB tree is removed from the global one, the communities, request id ranges, running timers and selected file descriptors are released, the fini function is called, the module file is unloaded and the loaded functions of all other modules are called.
The PDU could not be decoded, has a wrong version or an unknown community string.
A SET PDU had a value field in a binding with a wrong length field in an ASN.1 header.
A SET PDU had a value field in a binding with a value that is out of range for the given ASN.1 type.
A SET PDU had a value field in a binding with wrong ASN.1 encoding.
The buffer appears to contain a valid begin of a PDU, but is too short. For streaming transports this means that the caller must save what he already has and trying to obtain more input and reissue this input to the function. For datagram transports this means that part of the datagram was lost and the input should be ignored.
The function snmp_input_finish does the other half of processing: if snmp_input_start did not return OK, tries to construct an error response. If the start was OK, it calls the correct function from bsnmpagent to execute the request and depending on the outcome constructs a response or error response PDU or ignores the request PDU. It returns either SNMPD_INPUT_OK or SNMPD_INPUT_FAILED. In the first case a response PDU was constructed and should be sent.
The function snmp_output takes a PDU and encodes it.
The function snmp_send_port takes a PDU, encodes it and sends it through the given port (identified by the transport and the index in the port table) to the given address.
The function snmp_send_trap sends a trap to all trap destinations. The arguments are the oid identifying the trap and a NULL-terminated list of .Vt struct snmp_value pointers that are to be inserted into the trap binding list.
should be called for SNMP_OP_SET. value and ctx are the resp. arguments to the node callback. valp is a pointer to the pointer that holds the current value and req_size should be -1 if any size of the string is acceptable or a number larger or equal zero if the string must have a specific size. The function saves the old value in the scratch area (note, that any initial value must have been allocated by malloc 3 ), allocates a new string, copies over the new value, NUL-terminates it and sets the new current value.
simply frees the saved old value in the scratch area.
frees the new value, and puts back the old one.
is used for GET or GETNEXT. If len is -1, the length is computed via strlen(3) from the current string value. If the current value is NULL, a OCTET STRING of zero length is returned.
must be called if either rollback or commit fails to free the saved old value.
The following functions are used to process scalars of type IP-address:
Saves the current value in the scratch area and sets the new value from valp.
Restores the old IP address from the scratch area.
Retrieves the IP current address.
The following functions handle OID-typed variables:
Saves the current value in the scratch area by allocating a .Vt struct asn_oid with malloc(3) and sets the new value from oid.
Frees the old value in the scratch area.
Restores the old OID from the scratch area and frees the old OID.
Decodes the index part of the OID. The parameter oid must be a pointer to the var field of the value argument of the node callback. The sub argument must be the index of the start of the index in the OID (this is the sub argument to the node callback). code is the index expression (parameter idx to the node callback). These parameters are followed by parameters depending on the syntax of the index elements as follows:
.Vt int32_t * expected as argument.
.Vt u_int64_t * expected as argument. Note, that this syntax is illegal for indexes.
A .Vt u_char ** and a .Vt size_t * expected as arguments. A buffer is allocated to hold the decoded string.
A .Vt struct asn_oid * is expected as argument.
A .Vt u_int8_t * expected as argument that points to a buffer of at least four byte.
COUNTER, GAUGE, TIMETICKS
A .Vt u_int32_t expected.
No argument expected.
compares the current variable with an OID. oid1 and sub come from the node callback arguments value->var and sub resp. oid2 is the OID to compare to. The function returns -1, 0, +1 when the variable is lesser, equal, higher to the given OID. oid2 must contain only the index part of the table column.
is equivalent to index_compare except that it takes an additional parameter off that causes it to ignore the first off components of both indexes.
appends OID src beginning at position sub to dst.
appends OID src beginning at position off to dst beginning at position sub + off.