45 #define LOG_MODULE "SNMP [ber]" 46 #define LOG_LEVEL LOG_LEVEL_SNMP 68 uint32_t original_out_len;
70 original_out_len = *out_len;
73 *out-- = (uint8_t)(number & 0xFF);
86 uint32_t original_out_len;
88 original_out_len = *out_len;
91 *out-- = (uint8_t)(number & 0xFF);
107 for(i = 0; i < length; ++i) {
109 *out-- = (uint8_t)*str--;
149 uint8_t i, len, type;
153 if(type != BER_DATA_TYPE_INTEGER) {
171 *num = (uint32_t)(*buf++ & 0xFF);
173 for(i = 1; i < len; ++i) {
175 *num |= (uint8_t)(*buf++ & 0xFF);
185 uint8_t i, len, type;
189 if(type != expected_type) {
207 *num = (uint32_t)(*buf++ & 0xFF);
209 for(i = 1; i < len; ++i) {
211 *num |= (uint8_t)(*buf++ & 0xFF);
221 uint8_t type, i, length_bytes;
225 if(type != BER_DATA_TYPE_OCTET_STRING) {
233 if((*buf & 0x80) == 0) {
234 *length = (uint32_t)*buf++;
238 length_bytes = (uint8_t)(*buf++ & 0x7F);
240 if(length_bytes > 4) {
248 *length = (uint32_t)*buf++;
250 for(i = 1; i < length_bytes; ++i) {
257 *str = (
const char *)buf;
258 *buff_len -= *length;
260 return buf + *length;
unsigned char * snmp_ber_encode_string_len(unsigned char *out, uint32_t *out_len, const char *str, uint32_t length)
Encodes a string.
An implementation of the Simple Network Management Protocol (RFC 3411-3418)
unsigned char * snmp_ber_decode_type(unsigned char *buff, uint32_t *buff_len, uint8_t *type)
Decodes a type.
An implementation of the Simple Network Management Protocol (RFC 3411-3418)
unsigned char * snmp_ber_encode_null(unsigned char *out, uint32_t *out_len, uint8_t type)
Encodes a null.
unsigned char * snmp_ber_decode_null(unsigned char *buf, uint32_t *buff_len)
Decodes a null.
unsigned char * snmp_ber_encode_length(unsigned char *out, uint32_t *out_len, uint8_t length)
Encodes the length.
unsigned char * snmp_ber_decode_length(unsigned char *buff, uint32_t *buff_len, uint8_t *length)
Decodes a length.
unsigned char * snmp_ber_encode_integer(unsigned char *out, uint32_t *out_len, uint32_t number)
Encodes an integer.
unsigned char * snmp_ber_decode_unsigned_integer(unsigned char *buf, uint32_t *buff_len, uint8_t expected_type, uint32_t *num)
Decodes an unsigned number.
unsigned char * snmp_ber_encode_unsigned_integer(unsigned char *out, uint32_t *out_len, uint8_t type, uint32_t number)
Encodes an unsigned integer.
unsigned char * snmp_ber_decode_integer(unsigned char *buf, uint32_t *buff_len, uint32_t *num)
Decodes an integer.
unsigned char * snmp_ber_decode_string_len_buffer(unsigned char *buf, uint32_t *buff_len, const char **str, uint32_t *length)
Decodes a string.
unsigned char * snmp_ber_encode_type(unsigned char *out, uint32_t *out_len, uint8_t type)
Encodes a type.