45#define LOG_MODULE "SNMP [message]"
46#define LOG_LEVEL LOG_LEVEL_SNMP
51 uint32_t last_out_len;
59 last_out_len = snmp_packet->
used;
61 switch(varbinds[i].value_type) {
64 LOG_DBG(
"Could not encode integer type\n");
70 LOG_DBG(
"Could not encode timeticks type\n");
76 LOG_DBG(
"Could not encode octet string type\n");
82 LOG_DBG(
"Could not encode oid type\n");
90 LOG_DBG(
"Could not encode null type\n");
95 LOG_DBG(
"Could not encode invlid type\n");
100 LOG_DBG(
"Could not encode oid\n");
105 LOG_DBG(
"Could not encode length\n");
110 LOG_DBG(
"Could not encode type\n");
116 LOG_DBG(
"Could not encode length\n");
120 LOG_DBG(
"Could not encode type\n");
127 LOG_DBG(
"Could not encode max repetition\n");
132 LOG_DBG(
"Could not encode non repeaters\n");
138 LOG_DBG(
"Could not encode error index\n");
143 LOG_DBG(
"Could not encode error status\n");
150 LOG_DBG(
"Could not encode request id\n");
155 LOG_DBG(
"Could not encode length\n");
160 LOG_DBG(
"Could not encode pdu type\n");
165 LOG_DBG(
"Could not encode community\n");
170 LOG_DBG(
"Could not encode version\n");
175 LOG_DBG(
"Could not encode length\n");
180 LOG_DBG(
"Could not encode type\n");
191 uint8_t type, len, i;
194 LOG_DBG(
"Could not decode type\n");
199 LOG_DBG(
"Invalid type\n");
204 LOG_DBG(
"Could not decode length\n");
209 LOG_DBG(
"Could not decode version\n");
218 LOG_DBG(
"Invalid version\n");
223 LOG_DBG(
"Could not decode community\n");
228 LOG_DBG(
"Could not decode pdu type\n");
240 LOG_DBG(
"Invalid version\n");
245 LOG_DBG(
"Could not decode length\n");
250 LOG_DBG(
"Could not decode request id\n");
257 LOG_DBG(
"Could not decode non repeaters\n");
262 LOG_DBG(
"Could not decode max repetition\n");
268 LOG_DBG(
"Could not decode error status\n");
273 LOG_DBG(
"Could not decode error index\n");
280 LOG_DBG(
"Could not decode type\n");
285 LOG_DBG(
"Invalid type\n");
290 LOG_DBG(
"Could not decode length\n");
294 for(i = 0; snmp_packet->
used > 0; ++i) {
296 LOG_DBG(
"OID's overflow\n");
301 LOG_DBG(
"Could not decode type\n");
306 LOG_DBG(
"Invalid (%X) type\n", type);
311 LOG_DBG(
"Could not decode length\n");
316 LOG_DBG(
"Could not decode oid\n");
322 switch(varbinds[i].value_type) {
325 LOG_DBG(
"Could not decode integer type\n");
331 LOG_DBG(
"Could not decode timeticks type\n");
337 LOG_DBG(
"Could not decode octed string type\n");
343 LOG_DBG(
"Could not decode null type\n");
348 LOG_DBG(
"Invalid varbind type\n");
#define BER_DATA_TYPE_NO_SUCH_INSTANCE
No Such Instance.
#define BER_DATA_TYPE_INTEGER
Integer.
int snmp_ber_encode_string_len(snmp_packet_t *snmp_packet, const char *str, uint32_t length)
Encodes a string.
int snmp_ber_encode_timeticks(snmp_packet_t *snmp_packet, uint32_t timeticks)
Encodes a timeticks.
#define BER_DATA_TYPE_PDU_GET_BULK
PDU Get Bulk.
#define BER_DATA_TYPE_OBJECT_IDENTIFIER
Object Identifier.
#define BER_DATA_TYPE_PDU_GET_RESPONSE
PDU Get Reponse.
#define BER_DATA_TYPE_NULL
Null.
int snmp_ber_encode_integer(snmp_packet_t *snmp_packet, uint32_t number)
Encodes an integer.
int snmp_ber_decode_null(snmp_packet_t *snmp_packet)
Decodes a null.
#define BER_DATA_TYPE_TIMETICKS
TimeTicks.
int snmp_ber_decode_type(snmp_packet_t *snmp_packet, uint8_t *type)
Decodes a type.
int snmp_ber_encode_null(snmp_packet_t *snmp_packet, uint8_t type)
Encodes a null.
int snmp_ber_encode_oid(snmp_packet_t *snmp_packet, snmp_oid_t *oid)
Encodes a Oid.
int snmp_ber_decode_oid(snmp_packet_t *snmp_packet, snmp_oid_t *oid)
Decodes an OID.
#define BER_DATA_TYPE_PDU_GET_NEXT_REQUEST
PDU Get Next Request.
int snmp_ber_decode_length(snmp_packet_t *snmp_packet, uint8_t *length)
Decodes a length.
int snmp_ber_decode_integer(snmp_packet_t *snmp_packet, uint32_t *num)
Decodes an integer.
int snmp_ber_encode_type(snmp_packet_t *snmp_packet, uint8_t type)
Encodes a type.
#define BER_DATA_TYPE_PDU_SET_REQUEST
PDU Set Request.
#define BER_DATA_TYPE_PDU_GET_REQUEST
PDU Get Request.
int snmp_ber_encode_length(snmp_packet_t *snmp_packet, uint16_t length)
Encodes the length.
#define BER_DATA_TYPE_EOC
End-of-Content.
#define BER_DATA_TYPE_OCTET_STRING
Octet String.
int snmp_ber_decode_string_len_buffer(snmp_packet_t *snmp_packet, const char **str, uint32_t *length)
Decodes a string.
#define BER_DATA_TYPE_END_OF_MIB_VIEW
End of MIB View.
int snmp_ber_decode_timeticks(snmp_packet_t *snmp_packet, uint32_t *timeticks)
Decodes a timeticks.
#define BER_DATA_TYPE_SEQUENCE
Sequence.
#define SNMP_MAX_NR_VALUES
Default maximum number of OIDs in one response.
#define SNMP_VERSION_2C
SNMP Version 2c code.
#define SNMP_VERSION_1
SNMP Version 1 code.
int snmp_message_decode(snmp_packet_t *snmp_packet, snmp_header_t *header, snmp_varbind_t *varbinds)
int snmp_message_encode(snmp_packet_t *snmp_packet, snmp_header_t *header, snmp_varbind_t *varbinds)
Encodes a SNMP message.
SNMP Implementation of the BER encoding.
SNMP Implementation of the messages.
uint8_t * in
The pointer used for the incoming packet.
uint8_t * out
The pointer used for the outgoing packet.
uint16_t used
The number of bytes used.
uint8_t value_type
The type in this varbind.
union snmp_varbind_s::@41 value
A union to represent the value in this varbind.
const char * string
A pointer to the string value from this varbind.
uint32_t integer
The integer value.