CF_DECLS
CF_KEYWORDS(SNMP, PROTOCOL, BGP, LOCAL, AS, REMOTE, ADDRESS, PORT, DESCRIPTION,
- TIMEOUT, PRIORITY, CONTEXT, DEFAULT, MESSAGE)
+ TIMEOUT, PRIORITY, CONTEXT, DEFAULT, MESSAGE, VERBOSE)
CF_GRAMMAR
SNMP_CFG->bgp_local_as = $3;
}
| SNMP DESCRIPTION text {
- if (strlen($3) > UINT32_MAX) cf_error("Description is too long");
+ if (strlen($3) > UINT16_MAX - 1) cf_error("Description is too long");
SNMP_CFG->description = $3;
}
| PRIORITY expr {
}
*/
| START DELAY TIME expr_us { SNMP_CFG->startup_delay = $4; }
+ | VERBOSE bool { SNMP_CFG->verbose = $2; }
;
snmp_proto_opts:
SNMP_CFG->local_port = 0;
SNMP_CFG->remote_port = 705;
SNMP_CFG->bgp_local_as = 0;
+ SNMP_CFG->verbose = 0;
SNMP_CFG->description = "bird";
SNMP_CFG->timeout = 15;
switch (state)
{
case SNMP_INIT:
- TRACE(D_EVENTS, "TODO");
+ TRACE(D_EVENTS, "starting protocol");
ASSERT(last == SNMP_DOWN);
proto_notify_state(&p->p, PS_START);
/* Fall thru */
case SNMP_LOCKED:
- TRACE(D_EVENTS, "snmp %s: address lock acquired", p->p.name);
+ TRACE(D_EVENTS, "address lock acquired");
ASSERT(last == SNMP_INIT);
sock *s = sk_new(p->pool);
return PS_START;
case SNMP_CONN:
- TRACE(D_EVENTS, "MIBs registered");
+ TRACE(D_EVENTS, "MIBs registered, AgentX session established");
ASSERT(last == SNMP_REGISTER);
proto_notify_state(&p->p, PS_UP);
return PS_UP;
return PS_DOWN;
default:
- die("unknown snmp state transition");
+ die("unknown SNMP state transition");
return PS_DOWN;
}
}
p->bgp_local_id = cf->bgp_local_id;
p->timeout = cf->timeout;
p->startup_delay = cf->startup_delay;
+ p->verbose = cf->verbose;
p->pool = p->p.pool;
p->lp = lp_new(p->pool);
|| old->timeout != new->timeout // TODO distinguish message timemout
//(Open.timeout and timeout for timer)
|| old->priority != new->priority
- || strncmp(old->description, new->description, UINT32_MAX));
+ || strncmp(old->description, new->description, UINT16_MAX - 1));
}
/*
{
/* copy possibly changed values */
p->startup_delay = new->startup_delay;
+ p->verbose = new->verbose;
ASSERT(p->ping_timer);
int active = tm_active(p->ping_timer);
static uint
parse_close_pdu(struct snmp_proto *p, byte * const pkt_start)
{
- TRACE(D_PACKETS, "SNMP received agentx-Close-PDU");
byte *pkt = pkt_start;
struct agentx_close_pdu *pdu = (void *) pkt;
if (pkt_size != sizeof(struct agentx_close_pdu))
{
- TRACE(D_PACKETS, "SNMP malformed agentx-Close-PDU, closing anyway");
+ TRACE(D_PACKETS, "SNMP received agentx-Close-PDU that's malformed, closing anyway");
snmp_simple_response(p, AGENTX_RES_GEN_ERROR, 0);
snmp_reset(p);
return 0;
if (!snmp_test_close_reason(pdu->reason))
{
- TRACE(D_PACKETS, "SNMP invalid close reason %u", pdu->reason);
+ TRACE(D_PACKETS, "SNMP received agentx-Close-PDU with invalid close reason %u", pdu->reason);
snmp_simple_response(p, AGENTX_RES_GEN_ERROR, 0);
snmp_reset(p);
return 0;
}
enum agentx_close_reasons reason = (enum agentx_close_reasons) pdu->reason;
- TRACE(D_PACKETS, "SNMP close reason %u", reason);
+ TRACE(D_PACKETS, "SNMP received agentx-Close-PDU with close reason %u", reason);
snmp_simple_response(p, AGENTX_RES_NO_ERROR, 0);
snmp_reset(p);
return pkt_size + AGENTX_HEADER_SIZE;
if (pkt_size != 0)
{
- TRACE(D_PACKETS, "SNMP received malformed set PDU (size)");
+ TRACE(D_PACKETS, "SNMP received PDU is malformed (size)");
snmp_simple_response(p, AGENTX_RES_PARSE_ERROR, 0);
snmp_reset(p);
return 0;
//mb_free(tr);
c.error = err;
- TRACE(D_PACKETS, "SNMP received set PDU with error %u", c.error);
+ TRACE(D_PACKETS, "SNMP received PDU parsed with error %u", c.error);
response_err_ind(r, c.error, 0);
sk_send(p->sock, AGENTX_HEADER_SIZE);
if (pkt_size != 0)
{
return AGENTX_HEADER_SIZE;
- TRACE(D_PACKETS, "SNMP received malformed agentx-CleanupSet-PDU");
+ TRACE(D_PACKETS, "SNMP received agentx-CleanupSet-PDU is malformed");
snmp_reset(p);
return 0;
}
default:
/* We reset the connection for malformed packet (Unknown packet type) */
- TRACE(D_PACKETS, "SNMP received unknown packet type (%u)", LOAD_U8(h->type));
+ TRACE(D_PACKETS, "SNMP received PDU with unknown type (%u)", LOAD_U8(h->type));
snmp_reset(p);
return 0;
}
switch (r->error)
{
case AGENTX_RES_NO_ERROR:
- TRACE(D_PACKETS, "SNMP received agetnx-Response-PDU");
+ if (p->verbose || LOAD_U32(h->packet_id) != p->ignore_ping_id)
+ TRACE(D_PACKETS, "SNMP received agentx-Response-PDU");
+ if (LOAD_U32(h->packet_id) == p->ignore_ping_id)
+ p->ignore_ping_id = 0;
do_response(p, res);
break;
case AGENTX_RES_REQUEST_DENIED:
case AGENTX_RES_UNKNOWN_REGISTER:
TRACE(D_PACKETS, "SNMP received agentx-Response-PDU with error %u", r->error);
+ if (LOAD_U32(h->packet_id) == p->ignore_ping_id)
+ p->ignore_ping_id = 0;
snmp_register_ack(p, r);
break;
snmp_blank_header(h, AGENTX_PING_PDU);
p->packet_id++;
snmp_session(p, h);
+ if (p->verbose)
+ TRACE(D_PACKETS, "SNMP sending agentx-Ping-PDU");
+ p->ignore_ping_id = p->packet_id;
/* sending only header */
uint s = update_packet_size(h, (byte *) h + AGENTX_HEADER_SIZE);