diff --git a/proto/snmp/bgp_mib.c b/proto/snmp/bgp_mib.c index 4f2d5ef8..8d4d337a 100644 --- a/proto/snmp/bgp_mib.c +++ b/proto/snmp/bgp_mib.c @@ -281,7 +281,7 @@ snmp_bgp_state(struct oid *oid) */ u8 state = BGP_INTERNAL_NO_VALUE; - + u8 candidate; switch (oid->n_subid) { @@ -320,9 +320,9 @@ snmp_bgp_state(struct oid *oid) /* u8 candidate; */ switch (oid->ids[2]) { - + case SNMP_BGP_VERSION: - state = BGP_INTERNAL_VERSION; + state = BGP_INTERNAL_VERSION; break; case SNMP_BGP_LOCAL_AS: state = BGP_INTERNAL_LOCAL_AS; @@ -342,9 +342,9 @@ snmp_bgp_state(struct oid *oid) } else /* oid->ids[2] > SNMP_BGP_PEER_TABLE */ - state = BGP_INTERNAL_END; + state = BGP_INTERNAL_END; } - state = (state == BGP_INTERNAL_NO_VALUE) ? + state = (state == BGP_INTERNAL_NO_VALUE) ? candidate : state; /* fall through */ @@ -361,7 +361,7 @@ snmp_bgp_state(struct oid *oid) static inline int is_dynamic(u8 state) { - return (state >= BGP_INTERNAL_IDENTIFIER && + return (state >= BGP_INTERNAL_IDENTIFIER && state <= BGP_INTERNAL_IN_UPDATE_ELAPSED_TIME); } @@ -397,7 +397,7 @@ snmp_bgp_get_valid(u8 state) * SNMP_BGP_FSM_ESTABLISHED_TIME SNMP_BGP_IN_UPDATE_ELAPSED_TIME */ if (state == 1 || state == 4 || state == 5 || - state == 21 || state == 29) + state == 21 || state == 29) return 0; else return state; @@ -511,7 +511,7 @@ update_bgp_oid(struct oid *oid, u8 state) oid->ids[4] = update; \ break; - SNMP_UPDATE_CASE(BGP_INTERNAL_STATE, SNMP_BGP_STATE) + SNMP_UPDATE_CASE(BGP_INTERNAL_STATE, SNMP_BGP_STATE) SNMP_UPDATE_CASE(BGP_INTERNAL_ADMIN_STATUS, SNMP_BGP_ADMIN_STATUS) @@ -859,6 +859,7 @@ UNUSED, uint contid UNUSED, int byte_ord UNUSED, u8 state) BGP_DATA(vb, AGENTX_OCTET_STRING, pkt); break; + // TODO finish me here case BGP_INTERNAL_FSM_TRANSITIONS: break; case BGP_INTERNAL_FSM_ESTABLISHED_TIME: @@ -903,6 +904,7 @@ bgp_fill_static(struct snmp_proto *p, struct agentx_varbind *vb, byte *pkt, uint UNUSED, uint contid UNUSED, int byte_ord UNUSED, u8 state) { snmp_log("snmp bgp_fill_static ()\n"); + byte *temp = pkt; struct oid *oid = &vb->name; @@ -937,7 +939,8 @@ UNUSED, uint contid UNUSED, int byte_ord UNUSED, u8 state) vb->type = AGENTX_NO_SUCH_OBJECT; } - snmp_log("snmp ended with non empty pkt\n"); + snmp_log("snmp ended with non empty pkt %u starting from %p to %p\n", pkt - +temp, temp, pkt); return pkt; } diff --git a/proto/snmp/bgp_mib.h b/proto/snmp/bgp_mib.h index 7cce9722..44c8a541 100644 --- a/proto/snmp/bgp_mib.h +++ b/proto/snmp/bgp_mib.h @@ -69,24 +69,24 @@ enum BGP_INTERNAL_STATES { BGP_INTERNAL_IDENTIFIER, BGP_INTERNAL_STATE, BGP_INTERNAL_ADMIN_STATUS, - BGP_INTERNAL_NEGOTIATED_VERSION, + BGP_INTERNAL_NEGOTIATED_VERSION, BGP_INTERNAL_LOCAL_ADDR, - BGP_INTERNAL_LOCAL_PORT, + BGP_INTERNAL_LOCAL_PORT, BGP_INTERNAL_REMOTE_ADDR, - BGP_INTERNAL_REMOTE_PORT, + BGP_INTERNAL_REMOTE_PORT, BGP_INTERNAL_REMOTE_AS, BGP_INTERNAL_RX_UPDATES, BGP_INTERNAL_TX_UPDATES, BGP_INTERNAL_RX_MESSAGES, BGP_INTERNAL_TX_MESSAGES, - BGP_INTERNAL_LAST_ERROR, + BGP_INTERNAL_LAST_ERROR, BGP_INTERNAL_FSM_TRANSITIONS, BGP_INTERNAL_FSM_ESTABLISHED_TIME, BGP_INTERNAL_RETRY_INTERVAL, BGP_INTERNAL_HOLD_TIME, BGP_INTERNAL_KEEPALIVE, BGP_INTERNAL_HOLD_TIME_CONFIGURED, - BGP_INTERNAL_KEEPALIVE_CONFIGURED, + BGP_INTERNAL_KEEPALIVE_CONFIGURED, BGP_INTERNAL_ORIGINATION_INTERVAL, BGP_INTERNAL_MIN_ROUTE_ADVERTISEMENT, BGP_INTERNAL_IN_UPDATE_ELAPSED_TIME, diff --git a/proto/snmp/snmp.c b/proto/snmp/snmp.c index 8525d572..e5d1b66d 100644 --- a/proto/snmp/snmp.c +++ b/proto/snmp/snmp.c @@ -48,6 +48,7 @@ snmp_init(struct proto_config *CF) p->remote_ip = cf->remote_ip; p->local_port = cf->local_port; p->remote_port = cf->remote_port; + p->local_as = cf->local_as; snmp_log("chaning proto_snmp state to INIT"); p->state = SNMP_INIT; diff --git a/proto/snmp/snmp_utils.c b/proto/snmp/snmp_utils.c index 9b044f05..9d349cd0 100644 --- a/proto/snmp/snmp_utils.c +++ b/proto/snmp/snmp_utils.c @@ -66,8 +66,7 @@ snmp_str_size(const char *str) uint snmp_oid_size(struct oid *o) { - //return 4 + o->n_subid * 4; - return 4 + (o->n_subid << 2); + return 4 + (o->n_subid * 4); } /** @@ -192,10 +191,10 @@ snmp_put_oid(byte *buf, struct oid *oid) for (uint i = 0; i < oid->n_subid; i++) *(((u32 *) buf) + i) = oid->ids[i]; #else - put_u32s(buf, oid->ids, oid->n_subid << 2); + put_u32s(buf, oid->ids, oid->n_subid * 4); #endif - return buf + (oid->n_subid << 2); + return buf + oid->n_subid * 4; } /** @@ -235,7 +234,7 @@ void snmp_oid_dump(struct oid *oid) { log(L_WARN "is eqaul to NULL"); log(L_WARN "OID DUMP END ===="); - log(L_WARN); + log(L_WARN "."); return; } @@ -243,7 +242,7 @@ void snmp_oid_dump(struct oid *oid) { log(L_WARN "is empty"); log(L_WARN "OID DUMP END ===="); - log(L_WARN); + log(L_WARN "."); return; } @@ -380,7 +379,7 @@ void snmp_dump_packet(byte *pkt, uint size) { snmp_log("dump"); - for (int i = 0; i < size; i += 4) + for (uint i = 0; i < size; i += 4) snmp_log("pkt [%d] 0x%02x%02x%02x%02x", i, pkt[i],pkt[i+1],pkt[i+2],pkt[i+3]); snmp_log("end dump"); }