Finished task #13731: fix usage of "snmp_inc_*"

This commit is contained in:
goldsimon 2015-09-30 15:54:43 +02:00
parent 7b5ef3ae58
commit 389831218e
4 changed files with 58 additions and 40 deletions

View File

@ -103,8 +103,10 @@ icmp_input(struct pbuf *p, struct netif *inp)
case ICMP_ER:
/* This is OK, echo reply might have been parsed by a raw PCB
(as obviously, an echo request has been sent, too). */
break;
MIB2_STATS_INC(mib2.icmpinechoreps);
break;
case ICMP_ECHO:
MIB2_STATS_INC(mib2.icmpinechos);
src = ip4_current_dest_addr();
/* multicast destination address? */
if (ip_addr_ismulticast(ip_current_dest_addr())) {
@ -235,6 +237,25 @@ icmp_input(struct pbuf *p, struct netif *inp)
}
break;
default:
if (type == ICMP_DUR) {
MIB2_STATS_INC(mib2.icmpindestunreachs);
} else if(type == ICMP_TE) {
MIB2_STATS_INC(mib2.icmpindestunreachs);
} else if(type == ICMP_PP) {
MIB2_STATS_INC(mib2.icmpinparmprobs);
} else if(type == ICMP_SQ) {
MIB2_STATS_INC(mib2.icmpinsrcquenchs);
} else if(type == ICMP_RD) {
MIB2_STATS_INC(mib2.icmpinredirects);
} else if(type == ICMP_TS) {
MIB2_STATS_INC(mib2.icmpintimestamps);
} else if(type == ICMP_TSR) {
MIB2_STATS_INC(mib2.icmpintimestampreps);
} else if(type == ICMP_AM) {
MIB2_STATS_INC(mib2.icmpinaddrmasks);
} else if(type == ICMP_AMR) {
MIB2_STATS_INC(mib2.icmpinaddrmaskreps);
}
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ICMP type %"S16_F" code %"S16_F" not supported.\n",
(s16_t)type, (s16_t)code));
ICMP_STATS_INC(icmp.proterr);
@ -268,6 +289,7 @@ icmperr:
void
icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t)
{
MIB2_STATS_INC(mib2.icmpoutdestunreachs);
icmp_send_response(p, ICMP_DUR, t);
}
@ -282,6 +304,7 @@ icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t)
void
icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t)
{
MIB2_STATS_INC(mib2.icmpouttimeexcds);
icmp_send_response(p, ICMP_TE, t);
}
@ -305,11 +328,15 @@ icmp_send_response(struct pbuf *p, u8_t type, u8_t code)
ip4_addr_t iphdr_src;
struct netif *netif;
/* increase number of messages attempted to send */
MIB2_STATS_INC(mib2.icmpoutmsgs);
/* ICMP header + IP header + 8 bytes of data */
q = pbuf_alloc(PBUF_IP, sizeof(struct icmp_echo_hdr) + IP_HLEN + ICMP_DEST_UNREACH_DATASIZE,
PBUF_RAM);
if (q == NULL) {
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_time_exceeded: failed to allocate pbuf for ICMP packet.\n"));
MIB2_STATS_INC(mib2.icmpouterrors);
return;
}
LWIP_ASSERT("check that first pbuf can hold icmp message",
@ -342,10 +369,6 @@ icmp_send_response(struct pbuf *p, u8_t type, u8_t code)
}
#endif
ICMP_STATS_INC(icmp.xmit);
/* increase number of messages attempted to send */
MIB2_STATS_INC(mib2.icmpoutmsgs);
/* increase number of destination unreachable messages attempted to send */
MIB2_STATS_INC(mib2.icmpouttimeexcds);
ip4_addr_copy(iphdr_src, iphdr->src);
ip4_output_if(q, NULL, &iphdr_src, ICMP_TTL, 0, IP_PROTO_ICMP, netif);
}

View File

@ -3173,14 +3173,14 @@ icmp_get_value(struct obj_def *od, u16_t len, void *value)
case 17: /* icmpOutTimeExcds */
*uint_ptr = STATS_GET(mib2.icmpouttimeexcds);
break;
case 18: /* icmpOutParmProbs */
*uint_ptr = STATS_GET(mib2.icmpoutparmprobs);
case 18: /* icmpOutParmProbs: not supported -> always 0 */
*uint_ptr = 0;
break;
case 19: /* icmpOutSrcQuenchs */
*uint_ptr = STATS_GET(mib2.icmpoutsrcquenchs);
case 19: /* icmpOutSrcQuenchs: not supported -> always 0 */
*uint_ptr = 0;
break;
case 20: /* icmpOutRedirects */
*uint_ptr = STATS_GET(mib2.icmpoutredirects);
case 20: /* icmpOutRedirects: not supported -> always 0 */
*uint_ptr = 0;
break;
case 21: /* icmpOutEchos */
*uint_ptr = STATS_GET(mib2.icmpoutechos);
@ -3188,17 +3188,17 @@ icmp_get_value(struct obj_def *od, u16_t len, void *value)
case 22: /* icmpOutEchoReps */
*uint_ptr = STATS_GET(mib2.icmpoutechoreps);
break;
case 23: /* icmpOutTimestamps */
*uint_ptr = STATS_GET(mib2.icmpouttimestamps);
case 23: /* icmpOutTimestamps: not supported -> always 0 */
*uint_ptr = 0;
break;
case 24: /* icmpOutTimestampReps */
*uint_ptr = STATS_GET(mib2.icmpouttimestampreps);
case 24: /* icmpOutTimestampReps: not supported -> always 0 */
*uint_ptr = 0;
break;
case 25: /* icmpOutAddrMasks */
*uint_ptr = STATS_GET(mib2.icmpoutaddrmasks);
case 25: /* icmpOutAddrMasks: not supported -> always 0 */
*uint_ptr = 0;
break;
case 26: /* icmpOutAddrMaskReps */
*uint_ptr = STATS_GET(mib2.icmpoutaddrmaskreps);
case 26: /* icmpOutAddrMaskReps: not supported -> always 0 */
*uint_ptr = 0;
break;
default:
LWIP_DEBUGF(SNMP_MIB_DEBUG,("icmp_get_value(): unknown id: %d\n", id));

View File

@ -56,6 +56,8 @@ extern "C" {
#define ICMP_TSR 14 /* timestamp reply */
#define ICMP_IRQ 15 /* information request */
#define ICMP_IR 16 /* information reply */
#define ICMP_AM 17 /* address mask request */
#define ICMP_AMR 18 /* address mask reply */
enum icmp_dur_type {
ICMP_DUR_NET = 0, /* net unreachable */

View File

@ -149,30 +149,23 @@ struct stats_mib2 {
/* ICMP */
u32_t icmpinmsgs;
u32_t icmpinerrors;
u32_t icmpindestunreachs; /* @todo: never incremented */
u32_t icmpintimeexcds; /* @todo: never incremented */
u32_t icmpinparmprobs; /* @todo: never incremented */
u32_t icmpinsrcquenchs; /* @todo: never incremented */
u32_t icmpinredirects; /* @todo: never incremented */
u32_t icmpinechos; /* @todo: never incremented */
u32_t icmpinechoreps; /* @todo: never incremented */
u32_t icmpintimestamps; /* @todo: never incremented */
u32_t icmpintimestampreps; /* @todo: never incremented */
u32_t icmpinaddrmasks; /* @todo: never incremented */
u32_t icmpinaddrmaskreps; /* @todo: never incremented */
u32_t icmpindestunreachs;
u32_t icmpintimeexcds;
u32_t icmpinparmprobs;
u32_t icmpinsrcquenchs;
u32_t icmpinredirects;
u32_t icmpinechos;
u32_t icmpinechoreps;
u32_t icmpintimestamps;
u32_t icmpintimestampreps;
u32_t icmpinaddrmasks;
u32_t icmpinaddrmaskreps;
u32_t icmpoutmsgs;
u32_t icmpouterrors; /* @todo: never incremented */
u32_t icmpoutdestunreachs; /* @todo: never incremented */
u32_t icmpouterrors;
u32_t icmpoutdestunreachs;
u32_t icmpouttimeexcds;
u32_t icmpoutparmprobs; /* @todo: never incremented */
u32_t icmpoutsrcquenchs; /* @todo: never incremented */
u32_t icmpoutredirects; /* @todo: never incremented */
u32_t icmpoutechos; /* @todo: never incremented */
u32_t icmpoutechos; /* can be incremented by user application ('ping') */
u32_t icmpoutechoreps;
u32_t icmpouttimestamps; /* @todo: never incremented */
u32_t icmpouttimestampreps; /* @todo: never incremented */
u32_t icmpoutaddrmasks; /* @todo: never incremented */
u32_t icmpoutaddrmaskreps; /* @todo: never incremented */
};
struct stats_mib2_netif_ctrs {