mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 17:51:53 +00:00
tmp: minor changes
This commit is contained in:
parent
29da25c2d0
commit
908aa67e1c
@ -281,7 +281,7 @@ snmp_bgp_state(struct oid *oid)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
u8 state = BGP_INTERNAL_NO_VALUE;
|
u8 state = BGP_INTERNAL_NO_VALUE;
|
||||||
|
|
||||||
u8 candidate;
|
u8 candidate;
|
||||||
switch (oid->n_subid)
|
switch (oid->n_subid)
|
||||||
{
|
{
|
||||||
@ -320,9 +320,9 @@ snmp_bgp_state(struct oid *oid)
|
|||||||
/* u8 candidate; */
|
/* u8 candidate; */
|
||||||
switch (oid->ids[2])
|
switch (oid->ids[2])
|
||||||
{
|
{
|
||||||
|
|
||||||
case SNMP_BGP_VERSION:
|
case SNMP_BGP_VERSION:
|
||||||
state = BGP_INTERNAL_VERSION;
|
state = BGP_INTERNAL_VERSION;
|
||||||
break;
|
break;
|
||||||
case SNMP_BGP_LOCAL_AS:
|
case SNMP_BGP_LOCAL_AS:
|
||||||
state = BGP_INTERNAL_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 */
|
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;
|
candidate : state;
|
||||||
|
|
||||||
/* fall through */
|
/* fall through */
|
||||||
@ -361,7 +361,7 @@ snmp_bgp_state(struct oid *oid)
|
|||||||
static inline int
|
static inline int
|
||||||
is_dynamic(u8 state)
|
is_dynamic(u8 state)
|
||||||
{
|
{
|
||||||
return (state >= BGP_INTERNAL_IDENTIFIER &&
|
return (state >= BGP_INTERNAL_IDENTIFIER &&
|
||||||
state <= BGP_INTERNAL_IN_UPDATE_ELAPSED_TIME);
|
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
|
* SNMP_BGP_FSM_ESTABLISHED_TIME SNMP_BGP_IN_UPDATE_ELAPSED_TIME
|
||||||
*/
|
*/
|
||||||
if (state == 1 || state == 4 || state == 5 ||
|
if (state == 1 || state == 4 || state == 5 ||
|
||||||
state == 21 || state == 29)
|
state == 21 || state == 29)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return state;
|
return state;
|
||||||
@ -511,7 +511,7 @@ update_bgp_oid(struct oid *oid, u8 state)
|
|||||||
oid->ids[4] = update; \
|
oid->ids[4] = update; \
|
||||||
break;
|
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)
|
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);
|
BGP_DATA(vb, AGENTX_OCTET_STRING, pkt);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// TODO finish me here
|
||||||
case BGP_INTERNAL_FSM_TRANSITIONS:
|
case BGP_INTERNAL_FSM_TRANSITIONS:
|
||||||
break;
|
break;
|
||||||
case BGP_INTERNAL_FSM_ESTABLISHED_TIME:
|
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)
|
UNUSED, uint contid UNUSED, int byte_ord UNUSED, u8 state)
|
||||||
{
|
{
|
||||||
snmp_log("snmp bgp_fill_static ()\n");
|
snmp_log("snmp bgp_fill_static ()\n");
|
||||||
|
byte *temp = pkt;
|
||||||
|
|
||||||
struct oid *oid = &vb->name;
|
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;
|
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;
|
return pkt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,24 +69,24 @@ enum BGP_INTERNAL_STATES {
|
|||||||
BGP_INTERNAL_IDENTIFIER,
|
BGP_INTERNAL_IDENTIFIER,
|
||||||
BGP_INTERNAL_STATE,
|
BGP_INTERNAL_STATE,
|
||||||
BGP_INTERNAL_ADMIN_STATUS,
|
BGP_INTERNAL_ADMIN_STATUS,
|
||||||
BGP_INTERNAL_NEGOTIATED_VERSION,
|
BGP_INTERNAL_NEGOTIATED_VERSION,
|
||||||
BGP_INTERNAL_LOCAL_ADDR,
|
BGP_INTERNAL_LOCAL_ADDR,
|
||||||
BGP_INTERNAL_LOCAL_PORT,
|
BGP_INTERNAL_LOCAL_PORT,
|
||||||
BGP_INTERNAL_REMOTE_ADDR,
|
BGP_INTERNAL_REMOTE_ADDR,
|
||||||
BGP_INTERNAL_REMOTE_PORT,
|
BGP_INTERNAL_REMOTE_PORT,
|
||||||
BGP_INTERNAL_REMOTE_AS,
|
BGP_INTERNAL_REMOTE_AS,
|
||||||
BGP_INTERNAL_RX_UPDATES,
|
BGP_INTERNAL_RX_UPDATES,
|
||||||
BGP_INTERNAL_TX_UPDATES,
|
BGP_INTERNAL_TX_UPDATES,
|
||||||
BGP_INTERNAL_RX_MESSAGES,
|
BGP_INTERNAL_RX_MESSAGES,
|
||||||
BGP_INTERNAL_TX_MESSAGES,
|
BGP_INTERNAL_TX_MESSAGES,
|
||||||
BGP_INTERNAL_LAST_ERROR,
|
BGP_INTERNAL_LAST_ERROR,
|
||||||
BGP_INTERNAL_FSM_TRANSITIONS,
|
BGP_INTERNAL_FSM_TRANSITIONS,
|
||||||
BGP_INTERNAL_FSM_ESTABLISHED_TIME,
|
BGP_INTERNAL_FSM_ESTABLISHED_TIME,
|
||||||
BGP_INTERNAL_RETRY_INTERVAL,
|
BGP_INTERNAL_RETRY_INTERVAL,
|
||||||
BGP_INTERNAL_HOLD_TIME,
|
BGP_INTERNAL_HOLD_TIME,
|
||||||
BGP_INTERNAL_KEEPALIVE,
|
BGP_INTERNAL_KEEPALIVE,
|
||||||
BGP_INTERNAL_HOLD_TIME_CONFIGURED,
|
BGP_INTERNAL_HOLD_TIME_CONFIGURED,
|
||||||
BGP_INTERNAL_KEEPALIVE_CONFIGURED,
|
BGP_INTERNAL_KEEPALIVE_CONFIGURED,
|
||||||
BGP_INTERNAL_ORIGINATION_INTERVAL,
|
BGP_INTERNAL_ORIGINATION_INTERVAL,
|
||||||
BGP_INTERNAL_MIN_ROUTE_ADVERTISEMENT,
|
BGP_INTERNAL_MIN_ROUTE_ADVERTISEMENT,
|
||||||
BGP_INTERNAL_IN_UPDATE_ELAPSED_TIME,
|
BGP_INTERNAL_IN_UPDATE_ELAPSED_TIME,
|
||||||
|
@ -48,6 +48,7 @@ snmp_init(struct proto_config *CF)
|
|||||||
p->remote_ip = cf->remote_ip;
|
p->remote_ip = cf->remote_ip;
|
||||||
p->local_port = cf->local_port;
|
p->local_port = cf->local_port;
|
||||||
p->remote_port = cf->remote_port;
|
p->remote_port = cf->remote_port;
|
||||||
|
p->local_as = cf->local_as;
|
||||||
snmp_log("chaning proto_snmp state to INIT");
|
snmp_log("chaning proto_snmp state to INIT");
|
||||||
p->state = SNMP_INIT;
|
p->state = SNMP_INIT;
|
||||||
|
|
||||||
|
@ -66,8 +66,7 @@ snmp_str_size(const char *str)
|
|||||||
uint
|
uint
|
||||||
snmp_oid_size(struct oid *o)
|
snmp_oid_size(struct oid *o)
|
||||||
{
|
{
|
||||||
//return 4 + o->n_subid * 4;
|
return 4 + (o->n_subid * 4);
|
||||||
return 4 + (o->n_subid << 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -192,10 +191,10 @@ snmp_put_oid(byte *buf, struct oid *oid)
|
|||||||
for (uint i = 0; i < oid->n_subid; i++)
|
for (uint i = 0; i < oid->n_subid; i++)
|
||||||
*(((u32 *) buf) + i) = oid->ids[i];
|
*(((u32 *) buf) + i) = oid->ids[i];
|
||||||
#else
|
#else
|
||||||
put_u32s(buf, oid->ids, oid->n_subid << 2);
|
put_u32s(buf, oid->ids, oid->n_subid * 4);
|
||||||
#endif
|
#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 "is eqaul to NULL");
|
||||||
log(L_WARN "OID DUMP END ====");
|
log(L_WARN "OID DUMP END ====");
|
||||||
log(L_WARN);
|
log(L_WARN ".");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,7 +242,7 @@ void snmp_oid_dump(struct oid *oid)
|
|||||||
{
|
{
|
||||||
log(L_WARN "is empty");
|
log(L_WARN "is empty");
|
||||||
log(L_WARN "OID DUMP END ====");
|
log(L_WARN "OID DUMP END ====");
|
||||||
log(L_WARN);
|
log(L_WARN ".");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,7 +379,7 @@ void
|
|||||||
snmp_dump_packet(byte *pkt, uint size)
|
snmp_dump_packet(byte *pkt, uint size)
|
||||||
{
|
{
|
||||||
snmp_log("dump");
|
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("pkt [%d] 0x%02x%02x%02x%02x", i, pkt[i],pkt[i+1],pkt[i+2],pkt[i+3]);
|
||||||
snmp_log("end dump");
|
snmp_log("end dump");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user