47 #define LOG_MODULE "SNMP [engine]" 48 #define LOG_LEVEL LOG_LEVEL_SNMP 57 for(i = 0; i < varbinds_length; i++) {
66 header->error_index_max_repetitions.
error_index = i + 1;
69 (&varbinds[i])->value_type = SNMP_DATA_TYPE_NO_SUCH_INSTANCE;
73 header->error_index_max_repetitions.
error_index = 0;
76 resource->
handler(&varbinds[i], resource->
oid);
89 for(i = 0; i < varbinds_length; i++) {
98 header->error_index_max_repetitions.
error_index = i + 1;
101 (&varbinds[i])->value_type = SNMP_DATA_TYPE_END_OF_MIB_VIEW;
105 header->error_index_max_repetitions.
error_index = 0;
108 resource->
handler(&varbinds[i], resource->
oid);
119 uint32_t i, j, original_varbinds_length;
127 original_varbinds_length = *varbinds_length;
128 for(i = 0; i < original_varbinds_length; i++) {
132 *varbinds_length = 0;
133 for(i = 0; i < original_varbinds_length; i++) {
146 header->error_index_max_repetitions.
error_index = i + 1;
149 (&varbinds[i])->value_type = SNMP_DATA_TYPE_END_OF_MIB_VIEW;
153 header->error_index_max_repetitions.
error_index = 0;
157 resource->
handler(&varbinds[*varbinds_length], resource->
oid);
158 (*varbinds_length)++;
163 for(i = 0; i < header->error_index_max_repetitions.
max_repetitions; i++) {
165 for(j = header->error_status_non_repeaters.
non_repeaters; j < original_varbinds_length; j++) {
174 header->error_index_max_repetitions.
error_index = *varbinds_length + 1;
178 (&varbinds[*varbinds_length])->value_type = SNMP_DATA_TYPE_END_OF_MIB_VIEW;
180 (*varbinds_length)++;
185 header->error_index_max_repetitions.
error_index = 0;
189 resource->
handler(&varbinds[*varbinds_length], resource->
oid);
190 (*varbinds_length)++;
205 snmp_engine(
unsigned char *buff, uint32_t buff_len,
unsigned char *out, uint32_t *out_len)
209 static uint32_t varbind_length;
218 LOG_ERR(
"Request with invalid community\n");
227 case SNMP_DATA_TYPE_PDU_GET_REQUEST:
228 if(snmp_engine_get(&header, varbinds, varbind_length) == -1) {
233 case SNMP_DATA_TYPE_PDU_GET_NEXT_REQUEST:
234 if(snmp_engine_get_next(&header, varbinds, varbind_length) == -1) {
239 case SNMP_DATA_TYPE_PDU_GET_BULK:
240 if(snmp_engine_get_bulk(&header, varbinds, &varbind_length) == -1) {
246 LOG_ERR(
"Invalid request type");
250 header.
pdu_type = SNMP_DATA_TYPE_PDU_GET_RESPONSE;
#define SNMP_STATUS_NO_SUCH_NAME
SNMP No Such Name error code.
snmp_mib_resource_handler_t handler
The function handler that is called for this resource.
void snmp_oid_copy(uint32_t *dst, uint32_t *src)
Copies a Oid.
An implementation of the Simple Network Management Protocol (RFC 3411-3418)
#define SNMP_COMMUNITY
Default SNMP Community.
snmp_mib_resource_t * snmp_mib_find_next(uint32_t *oid)
Finds the next MIB Resource after this OID.
#define SNMP_VERSION_1
SNMP Version 1 code.
#define SNMP_MSG_OID_MAX_LEN
Default maximum number of IDs in one OID.
An implementation of the Simple Network Management Protocol (RFC 3411-3418)
#define SNMP_VERSION_2C
SNMP Version 2c code.
snmp_mib_resource_t * snmp_mib_find(uint32_t *oid)
Finds the MIB Resource for this OID.
unsigned char * snmp_message_encode(unsigned char *out, uint32_t *out_len, snmp_header_t *header, snmp_varbind_t *varbinds, uint32_t varbind_num)
Encodes a SNMP message.
uint32_t * oid
A array that represents the OID.
#define SNMP_MAX_NR_VALUES
Default maximum number of OIDs in one response.
unsigned char * snmp_engine(unsigned char *buff, uint32_t buff_len, unsigned char *out, uint32_t *out_len)
Process the SNMP packet and prepares the response.
An implementation of the Simple Network Management Protocol (RFC 3411-3418)
uint8_t * snmp_message_decode(uint8_t *buf, uint32_t buf_len, snmp_header_t *header, snmp_varbind_t *varbinds, uint32_t *varbind_num)
An implementation of the Simple Network Management Protocol (RFC 3411-3418)