1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
diff -urpN a/agent/mibgroup/mibII/icmp.c b/agent/mibgroup/mibII/icmp.c
--- a/agent/mibgroup/mibII/icmp.c
+++ b/agent/mibgroup/mibII/icmp.c
@@ -106,10 +106,20 @@ struct icmp_msg_stats_table_entry {
int flags;
};
+#ifdef linux
+/* Linux keeps track of all possible message types */
+#define ICMP_MSG_STATS_IPV4_COUNT 256
+#else
#define ICMP_MSG_STATS_IPV4_COUNT 11
+#endif
#ifdef NETSNMP_ENABLE_IPV6
+#ifdef linux
+/* Linux keeps track of all possible message types */
+#define ICMP_MSG_STATS_IPV6_COUNT 256
+#else
#define ICMP_MSG_STATS_IPV6_COUNT 14
+#endif
#else
#define ICMP_MSG_STATS_IPV6_COUNT 0
#endif /* NETSNMP_ENABLE_IPV6 */
@@ -177,7 +187,7 @@ icmp_msg_stats_load(netsnmp_cache *cache
inc = 0;
linux_read_icmp_msg_stat(&v4icmp, &v4icmpmsg, &flag);
if (flag) {
- while (254 != k) {
+ while (255 >= k) {
if (v4icmpmsg.vals[k].InType) {
icmp_msg_stats_table[i].ipVer = 1;
icmp_msg_stats_table[i].icmpMsgStatsType = k;
@@ -1050,6 +1060,12 @@ icmp_stats_table_handler(netsnmp_mib_han
continue;
table_info = netsnmp_extract_table_info(request);
subid = table_info->colnum;
+ DEBUGMSGTL(( "mibII/icmpStatsTable", "oid: " ));
+ DEBUGMSGOID(( "mibII/icmpStatsTable", request->requestvb->name,
+ request->requestvb->name_length ));
+ DEBUGMSG(( "mibII/icmpStatsTable", " In %d InErr %d Out %d OutErr %d\n",
+ entry->icmpStatsInMsgs, entry->icmpStatsInErrors,
+ entry->icmpStatsOutMsgs, entry->icmpStatsOutErrors ));
switch (subid) {
case ICMP_STAT_INMSG:
@@ -1117,6 +1133,11 @@ icmp_msg_stats_table_handler(netsnmp_mib
continue;
table_info = netsnmp_extract_table_info(request);
subid = table_info->colnum;
+ DEBUGMSGTL(( "mibII/icmpMsgStatsTable", "oid: " ));
+ DEBUGMSGOID(( "mibII/icmpMsgStatsTable", request->requestvb->name,
+ request->requestvb->name_length ));
+ DEBUGMSG(( "mibII/icmpMsgStatsTable", " In %d Out %d Flags 0x%x\n",
+ entry->icmpMsgStatsInPkts, entry->icmpMsgStatsOutPkts, entry->flags ));
switch (subid) {
case ICMP_MSG_STAT_IN_PKTS:
diff -urpN a/agent/mibgroup/mibII/kernel_linux.c b/agent/mibgroup/mibII/kernel_linux.c
--- a/agent/mibgroup/mibII/kernel_linux.c
+++ b/agent/mibgroup/mibII/kernel_linux.c
@@ -81,9 +81,9 @@ decode_icmp_msg(char *line, char *data,
index = strtol(token, &delim, 0);
if (ERANGE == errno) {
continue;
- } else if (index > LONG_MAX) {
+ } else if (index > 255) {
continue;
- } else if (index < LONG_MIN) {
+ } else if (index < 0) {
continue;
}
if (NULL == (token = strtok_r(dataptr, " ", &saveptr1)))
@@ -94,9 +94,9 @@ decode_icmp_msg(char *line, char *data,
index = strtol(token, &delim, 0);
if (ERANGE == errno) {
continue;
- } else if (index > LONG_MAX) {
+ } else if (index > 255) {
continue;
- } else if (index < LONG_MIN) {
+ } else if (index < 0) {
continue;
}
if(NULL == (token = strtok_r(dataptr, " ", &saveptr1)))
@@ -426,14 +426,21 @@ linux_read_icmp6_parse(struct icmp6_mib
vals = name;
if (NULL != icmp6msgstat) {
+ int type;
if (0 == strncmp(name, "Icmp6OutType", 12)) {
strsep(&vals, "e");
- icmp6msgstat->vals[atoi(vals)].OutType = stats;
+ type = atoi(vals);
+ if ( type < 0 || type > 255 )
+ continue;
+ icmp6msgstat->vals[type].OutType = stats;
*support = 1;
continue;
} else if (0 == strncmp(name, "Icmp6InType", 11)) {
strsep(&vals, "e");
- icmp6msgstat->vals[atoi(vals)].InType = stats;
+ type = atoi(vals);
+ if ( type < 0 || type > 255 )
+ continue;
+ icmp6msgstat->vals[type].OutType = stats;
*support = 1;
continue;
}
diff -urpN a/agent/mibgroup/mibII/kernel_linux.h b/agent/mibgroup/mibII/kernel_linux.h
--- a/agent/mibgroup/mibII/kernel_linux.h
+++ b/agent/mibgroup/mibII/kernel_linux.h
@@ -121,11 +121,11 @@ struct icmp_msg_mib {
/* Lets use wrapper structures for future expansion */
struct icmp4_msg_mib {
- struct icmp_msg_mib vals[255];
+ struct icmp_msg_mib vals[256];
};
struct icmp6_msg_mib {
- struct icmp_msg_mib vals[255];
+ struct icmp_msg_mib vals[256];
};
struct udp_mib {
|