{ /* registering whole BGP4-MIB subtree */
//snmp_log("snmp_proto %p (%p)", p, p->p.pool);
+
struct snmp_register *registering = snmp_register_create(p, SNMP_BGP4_MIB);
struct oid *oid = mb_alloc(p->p.pool, snmp_oid_sizeof(2));
add_tail(&p->register_queue, ®istering->n);
p->register_to_ack++;
+ /* snmp_register(struct snmp_proto *p, struct oid *oid, uint index, uint len, u8 is_instance) */
snmp_register(p, oid, 0, 1, 0);
}
snmp_log(" local port: %u", config->local_port);
snmp_log(" remote port: %u", config->remote_port);
- // crashes ?
if (conn) {
snmp_log(" state: %u", conn->state);
snmp_log(" remote as: %u", conn->remote_caps->as4_number);
snmp_log(" fsm transitions: %u",
bgp_proto->stats.fsm_established_transitions);
- // not supported yet
- snmp_log(" fsm total time: --");
+ snmp_log(" fsm total time: -- (0)"); // not supported by bird
snmp_log(" retry interval: %u", config->connect_retry_time);
snmp_log(" hold configurated: %u", config->hold_time );
snmp_log(" keep alive config: %u", config->keepalive_time );
- // unknown
- snmp_log(" min AS origin. int.: --");
+ snmp_log(" min AS origin. int.: -- (0)"); // not supported by bird
snmp_log(" min route advertisement: %u", 0 );
snmp_log(" in update elapsed time: %u", 0 );
/* fall through */
case 4:
- if (oid->ids[3] == BGP4_PEER_ENTRY)
+ if (oid->ids[3] == SNMP_BGP_PEER_ENTRY)
state = (state == BGP_INTERNAL_NO_VALUE) ?
BGP_INTERNAL_PEER_ENTRY : state;
else
/* most likely not functioning */
if (o->prefix == 2 && o->n_subid > 0 && o->ids[0] == 1)
{
- if (o->n_subid == 2 && (o->ids[1] == BGP4_MIB_VERSION ||
- o->ids[1] == BGP4_MIB_LOCAL_AS))
+ if (o->n_subid == 2 && (o->ids[1] == SNMP_BGP4_MIB ||
+ o->ids[1] == SNMP_BGP_LOCAL_AS))
return 1;
- else if (o->n_subid > 2 && o->ids[1] == BGP4_PEER_TABLE &&
- o->ids[2] == BGP4_PEER_ENTRY)
+ else if (o->n_subid > 2 && o->ids[1] == SNMP_BGP_PEER_TABLE &&
+ o->ids[2] == SNMP_BGP_PEER_ENTRY)
{
if (o->n_subid == 3)
return 1;
/* We skip the first match as we should not include ip address in oid */
if (match)
{
- snmp_log("continue");
+ snmp_log("continue");
trie_walk_next(&ws, &net);
}
{
case BGP_INTERNAL_IDENTIFIER:
if (bgp_state == BS_OPENCONFIRM || bgp_state == BS_ESTABLISHED)
- pkt = snmp_varbind_ip4(vb, size, ipa_to_ip4(bgp_proto->remote_ip));
+ pkt = snmp_varbind_ip4(vb, size, ip4_from_u32(bgp_proto->remote_id));
else
pkt = snmp_varbind_ip4(vb, size, IP4_NONE);
break;
pkt = snmp_varbind_nstr(vb, size, last_error, 2);
break;
- // TODO finish me here
case BGP_INTERNAL_FSM_TRANSITIONS:
pkt = snmp_varbind_counter32(vb, size,
bgp_stats->fsm_established_transitions);
case BGP_INTERNAL_HOLD_TIME:
// (0, 3..65535)
- pkt = snmp_varbind_int(vb, size, bgp_conn->hold_time);
+ pkt = snmp_varbind_int(vb, size, (bgp_conn) ? bgp_conn->hold_time : 0);
break;
case BGP_INTERNAL_KEEPALIVE:
- pkt = snmp_varbind_int(vb, size, bgp_conn->keepalive_time);
+ if (!bgp_conf->hold_time)
+ pkt = snmp_varbind_int(vb, size, 0);
+ else
+ pkt = snmp_varbind_int(vb, size,
+ (bgp_conn) ? bgp_conn->keepalive_time : 0);
break;
case BGP_INTERNAL_HOLD_TIME_CONFIGURED:
break;
case BGP_INTERNAL_KEEPALIVE_CONFIGURED:
- pkt = snmp_varbind_int(vb, size, bgp_conf->keepalive_time);
+ if (!bgp_conf->keepalive_time)
+ pkt = snmp_varbind_int(vb, size, 0);
+ else
+ pkt = snmp_varbind_int(vb, size,
+ (bgp_conn) ? bgp_conn->keepalive_time : 0);
break;
case BGP_INTERNAL_ORIGINATION_INTERVAL:
break;
case BGP_INTERNAL_IN_UPDATE_ELAPSED_TIME:
- pkt = snmp_varbind_gauge32(vb, size, (current_time()
- - bgp_proto->last_rx_update) TO_S);
+ pkt = snmp_varbind_gauge32(vb, size,
+ (current_time() - bgp_proto->last_rx_update) TO_S
+ );
break;
case BGP_INTERNAL_END:
#include "subagent.h"
/* peers attributes */
-enum BGP4_MIB {
+enum BGP4_MIB_PEER_TABLE {
SNMP_BGP_IDENTIFIER = 1,
SNMP_BGP_STATE = 2,
SNMP_BGP_ADMIN_STATUS = 3, /* in read-only mode */
SNMP_BGP_TX_MESSAGES = 13, /* out total messages */
SNMP_BGP_LAST_ERROR = 14,
SNMP_BGP_FSM_TRANSITIONS = 15, /* FSM established transitions */
- SNMP_BGP_FSM_ESTABLISHED_TIME = 16, /* UNSUPPORTED FSM established time */
+ SNMP_BGP_FSM_ESTABLISHED_TIME = 16,
SNMP_BGP_RETRY_INTERVAL = 17,
SNMP_BGP_HOLD_TIME = 18,
SNMP_BGP_KEEPALIVE = 19,
SNMP_BGP_KEEPALIVE_CONFIGURED = 21,
SNMP_BGP_ORIGINATION_INTERVAL = 22, /* UNSUPPORTED - 0 */
SNMP_BGP_MIN_ROUTE_ADVERTISEMENT = 23, /* UNSUPPORTED - 0 */
- SNMP_BGP_IN_UPDATE_ELAPSED_TIME = 24, /* UNSUPPORTED */
+ SNMP_BGP_IN_UPDATE_ELAPSED_TIME = 24,
} PACKED;
/* version of BGP, here BGP-4 */
#define SNMP_BGP_NEGOTIATED_VER_VALUE 4
#define SNMP_BGP_NEGOTIATED_VER_NO_VALUE 0
-//void snmp_init_bgp_table(void);
-//void snmp_del_bgp_table(void);
-
struct oid;
void snmp_bgp_register(struct snmp_proto *p);
-// - int snmp_bgp_is_supported(struct oid *o);
-//int snmp_bgp_valid_ip4(struct oid *o);
-//u8 snmp_bgp_state(const struct oid *o);
u8 snmp_bgp_get_valid(u8 state);
u8 snmp_bgp_getnext_valid(u8 state);
struct oid *snmp_bgp_search(struct snmp_proto *p, struct oid *o_start, struct oid *o_end, uint contid);
enum snmp_search_res snmp_bgp_search2(struct snmp_proto *p, struct oid **searched, const struct oid *o_end, uint contid);
-//byte * snmp_bgp_fill(struct snmp_proto *p, struct agentx_varbind *vb, byte *buf, uint size, uint contid UNUSED, int byte_ord);
void snmp_bgp_fill(struct snmp_proto *p, struct agentx_varbind *vb, struct snmp_pdu_context *c);
-#define BGP4_MIB_VERSION 1
-#define BGP4_MIB_LOCAL_AS 2
-#define BGP4_PEER_TABLE 3
-#define BGP4_PEER_ENTRY 1
-
#define SNMP_BGP_VERSION 1
#define SNMP_BGP_LOCAL_AS 2
#define SNMP_BGP_PEER_TABLE 3
/* BGP linearized state */
enum BGP_INTERNAL_STATES {
BGP_INTERNAL_INVALID = 0,
- BGP_INTERNAL_BGP = 1,
+ BGP_INTERNAL_START = 1,
+ BGP_INTERNAL_BGP,
BGP_INTERNAL_VERSION,
BGP_INTERNAL_LOCAL_AS,
BGP_INTERNAL_PEER_TABLE,
BGP_INTERNAL_ORIGINATION_INTERVAL,
BGP_INTERNAL_MIN_ROUTE_ADVERTISEMENT,
BGP_INTERNAL_IN_UPDATE_ELAPSED_TIME,
+ BGP_INTERNAL_PEER_TABLE_END,
BGP_INTERNAL_END,
BGP_INTERNAL_NO_VALUE = 255,
} PACKED;
cli_msg(-1006, " name: %s", cf->name);
cli_msg(-1006, "");
- cli_msg(-1006, " rem. identifier: %u", bp->remote_id);
- // learn more !!
+ cli_msg(-1006, " loc. identifier: %I4", bp->local_id);
+ cli_msg(-1006, " rem. identifier: %I4", bp->remote_id);
cli_msg(-1006, " admin status: %s", (p->disabled) ? "stop" :
"start");
- // version ?
cli_msg(-1006, " version: 4");
- cli_msg(-1006, " local ip: %u", bcf->local_ip);
- cli_msg(-1006, " remote ip: %u", bcf->remote_ip);
- cli_msg(-1006, " local port: %u", bcf->local_port);
- cli_msg(-1006, " remote port: %u", bcf->remote_port);
+ cli_msg(-1006, " local ip: %I4", bcf->local_ip);
+ cli_msg(-1006, " remote ip: %I4", bcf->remote_ip);
+ cli_msg(-1006, " local port: %I4", bcf->local_port);
+ cli_msg(-1006, " remote port: %I4", bcf->remote_port);
/*
if (conn) {
cli_msg(-1006, " state: %u", conn->state);
cli_msg(-1006, " fsm transitions: %u",
bp->stats.fsm_established_transitions);
- // not supported yet
- cli_msg(-1006, " fsm total time: --");
+ cli_msg(-1006, " fsm total time: -- (0)");
cli_msg(-1006, " retry interval: %u", bcf->connect_retry_time);
/*
cli_msg(-1006, " hold configurated: %u", bcf->hold_time );
cli_msg(-1006, " keep alive config: %u", bcf->keepalive_time );
- // unknown
- cli_msg(-1006, " min AS origin. int.: --");
+ cli_msg(-1006, " min AS origin. int.: -- (0)");
cli_msg(-1006, " min route advertisement: %u", 0 );
cli_msg(-1006, " in update elapsed time: %u", 0 );
tm_stop(p->ping_timer);
- /* connection established => close the connection */
- if (p->state == SNMP_CONN)
+ /* connection established -> close the connection */
+ if (p->state == SNMP_CONN ||
+ p->state == SNMP_REGISTER)
{
p->state = SNMP_STOP;
/* startup time is reused for connection closing */
p->startup_timer->hook = snmp_stop_timeout;
- // TODO timeout duration ??
+ // TODO timeout option
tm_set(p->startup_timer, 15 S);
snmp_stop_subagent(p);