45 #define LOG_MODULE "SNMP [oid]" 46 #define LOG_LEVEL LOG_LEVEL_SNMP 55 while(oid1[i] != ((uint32_t)-1) &&
56 oid2[i] != ((uint32_t)-1)) {
57 if(oid1[i] != oid2[i]) {
58 if(oid1[i] < oid2[i]) {
66 if(oid1[i] == ((uint32_t)-1) &&
67 oid2[i] != ((uint32_t)-1)) {
71 if(oid1[i] != ((uint32_t)-1) &&
72 oid2[i] == ((uint32_t)-1)) {
82 uint32_t original_out_len;
83 uint32_t *oid_start =
oid;
86 original_out_len = *out_len;
87 while(*oid != ((uint32_t)-1)) {
92 while(oid != oid_start) {
95 *out-- = (uint8_t)(num & 0x7F);
100 *out-- = (uint8_t)((num & 0x7F) | 0x80);
106 num = *(out + 1) + 40 * *oid;
110 *out-- = (uint8_t)(num & 0x7F);
115 *out-- = (uint8_t)((num & 0x7F) | 0x80);
129 uint8_t *buf_end, type;
140 if(type != SNMP_DATA_TYPE_OBJECT) {
152 first = div(*buf++, 40);
153 *oid++ = (uint32_t)first.quot;
154 *oid++ = (uint32_t)first.rem;
156 while(buf != buf_end) {
164 *oid = (uint32_t)(*buf & 0x7F);
165 for(i = 0; i < 4; i++) {
167 if((*buf++ & 0x80) == 0) {
172 *oid |= (*buf & 0x7F);
178 *oid++ = ((uint32_t)-1);
179 *oid_len = (uint32_t)(oid - start);
190 while(src[i] != ((uint32_t)-1)) {
200 #if LOG_LEVEL == LOG_LEVEL_DBG 208 while(oid[i] != ((uint32_t)-1)) {
209 LOG_DBG_(
"%lu", (
unsigned long)oid[i]);
211 if(oid[i] != ((uint32_t)-1)) {
void snmp_oid_copy(uint32_t *dst, uint32_t *src)
Copies a Oid.
An implementation of the Simple Network Management Protocol (RFC 3411-3418)
uint8_t * snmp_oid_decode_oid(uint8_t *buf, uint32_t *buff_len, uint32_t *oid, uint32_t *oid_len)
Decodes a Oid.
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)
int snmp_oid_cmp_oid(uint32_t *oid1, uint32_t *oid2)
Compares to oids.
static void start(void)
Start measurement.
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.
uint32_t * oid
A array that represents the OID.
unsigned char * snmp_oid_encode_oid(unsigned char *out, uint32_t *out_len, uint32_t *oid)
Encodes a Oid.
unsigned char * snmp_ber_encode_type(unsigned char *out, uint32_t *out_len, uint8_t type)
Encodes a type.
void snmp_oid_print(uint32_t *oid)
Prints a oid.