BadVPN – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 /**
2 * @file
3 * Management Information Base II (RFC1213) ICMP objects and functions.
4 */
5  
6 /*
7 * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands.
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without modification,
11 * are permitted provided that the following conditions are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright notice,
14 * this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 * 3. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
22 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
24 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
26 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
30 * OF SUCH DAMAGE.
31 *
32 * Author: Dirk Ziegelmeier <dziegel@gmx.de>
33 * Christiaan Simons <christiaan.simons@axon.tv>
34 */
35  
36 #include "lwip/snmp.h"
37 #include "lwip/apps/snmp.h"
38 #include "lwip/apps/snmp_core.h"
39 #include "lwip/apps/snmp_mib2.h"
40 #include "lwip/apps/snmp_table.h"
41 #include "lwip/apps/snmp_scalar.h"
42 #include "lwip/icmp.h"
43 #include "lwip/stats.h"
44  
45 #if LWIP_SNMP && SNMP_LWIP_MIB2 && LWIP_ICMP
46  
47 #if SNMP_USE_NETCONN
48 #define SYNC_NODE_NAME(node_name) node_name ## _synced
49 #define CREATE_LWIP_SYNC_NODE(oid, node_name) \
50 static const struct snmp_threadsync_node node_name ## _synced = SNMP_CREATE_THREAD_SYNC_NODE(oid, &node_name.node, &snmp_mib2_lwip_locks);
51 #else
52 #define SYNC_NODE_NAME(node_name) node_name
53 #define CREATE_LWIP_SYNC_NODE(oid, node_name)
54 #endif
55  
56 /* --- icmp .1.3.6.1.2.1.5 ----------------------------------------------------- */
57  
58 static s16_t
59 icmp_get_value(const struct snmp_scalar_array_node_def *node, void *value)
60 {
61 u32_t *uint_ptr = (u32_t *)value;
62  
63 switch (node->oid) {
64 case 1: /* icmpInMsgs */
65 *uint_ptr = STATS_GET(mib2.icmpinmsgs);
66 return sizeof(*uint_ptr);
67 case 2: /* icmpInErrors */
68 *uint_ptr = STATS_GET(mib2.icmpinerrors);
69 return sizeof(*uint_ptr);
70 case 3: /* icmpInDestUnreachs */
71 *uint_ptr = STATS_GET(mib2.icmpindestunreachs);
72 return sizeof(*uint_ptr);
73 case 4: /* icmpInTimeExcds */
74 *uint_ptr = STATS_GET(mib2.icmpintimeexcds);
75 return sizeof(*uint_ptr);
76 case 5: /* icmpInParmProbs */
77 *uint_ptr = STATS_GET(mib2.icmpinparmprobs);
78 return sizeof(*uint_ptr);
79 case 6: /* icmpInSrcQuenchs */
80 *uint_ptr = STATS_GET(mib2.icmpinsrcquenchs);
81 return sizeof(*uint_ptr);
82 case 7: /* icmpInRedirects */
83 *uint_ptr = STATS_GET(mib2.icmpinredirects);
84 return sizeof(*uint_ptr);
85 case 8: /* icmpInEchos */
86 *uint_ptr = STATS_GET(mib2.icmpinechos);
87 return sizeof(*uint_ptr);
88 case 9: /* icmpInEchoReps */
89 *uint_ptr = STATS_GET(mib2.icmpinechoreps);
90 return sizeof(*uint_ptr);
91 case 10: /* icmpInTimestamps */
92 *uint_ptr = STATS_GET(mib2.icmpintimestamps);
93 return sizeof(*uint_ptr);
94 case 11: /* icmpInTimestampReps */
95 *uint_ptr = STATS_GET(mib2.icmpintimestampreps);
96 return sizeof(*uint_ptr);
97 case 12: /* icmpInAddrMasks */
98 *uint_ptr = STATS_GET(mib2.icmpinaddrmasks);
99 return sizeof(*uint_ptr);
100 case 13: /* icmpInAddrMaskReps */
101 *uint_ptr = STATS_GET(mib2.icmpinaddrmaskreps);
102 return sizeof(*uint_ptr);
103 case 14: /* icmpOutMsgs */
104 *uint_ptr = STATS_GET(mib2.icmpoutmsgs);
105 return sizeof(*uint_ptr);
106 case 15: /* icmpOutErrors */
107 *uint_ptr = STATS_GET(mib2.icmpouterrors);
108 return sizeof(*uint_ptr);
109 case 16: /* icmpOutDestUnreachs */
110 *uint_ptr = STATS_GET(mib2.icmpoutdestunreachs);
111 return sizeof(*uint_ptr);
112 case 17: /* icmpOutTimeExcds */
113 *uint_ptr = STATS_GET(mib2.icmpouttimeexcds);
114 return sizeof(*uint_ptr);
115 case 18: /* icmpOutParmProbs: not supported -> always 0 */
116 *uint_ptr = 0;
117 return sizeof(*uint_ptr);
118 case 19: /* icmpOutSrcQuenchs: not supported -> always 0 */
119 *uint_ptr = 0;
120 return sizeof(*uint_ptr);
121 case 20: /* icmpOutRedirects: not supported -> always 0 */
122 *uint_ptr = 0;
123 return sizeof(*uint_ptr);
124 case 21: /* icmpOutEchos */
125 *uint_ptr = STATS_GET(mib2.icmpoutechos);
126 return sizeof(*uint_ptr);
127 case 22: /* icmpOutEchoReps */
128 *uint_ptr = STATS_GET(mib2.icmpoutechoreps);
129 return sizeof(*uint_ptr);
130 case 23: /* icmpOutTimestamps: not supported -> always 0 */
131 *uint_ptr = 0;
132 return sizeof(*uint_ptr);
133 case 24: /* icmpOutTimestampReps: not supported -> always 0 */
134 *uint_ptr = 0;
135 return sizeof(*uint_ptr);
136 case 25: /* icmpOutAddrMasks: not supported -> always 0 */
137 *uint_ptr = 0;
138 return sizeof(*uint_ptr);
139 case 26: /* icmpOutAddrMaskReps: not supported -> always 0 */
140 *uint_ptr = 0;
141 return sizeof(*uint_ptr);
142 default:
143 LWIP_DEBUGF(SNMP_MIB_DEBUG, ("icmp_get_value(): unknown id: %"S32_F"\n", node->oid));
144 break;
145 }
146  
147 return 0;
148 }
149  
150  
151 static const struct snmp_scalar_array_node_def icmp_nodes[] = {
152 { 1, SNMP_ASN1_TYPE_COUNTER, SNMP_NODE_INSTANCE_READ_ONLY},
153 { 2, SNMP_ASN1_TYPE_COUNTER, SNMP_NODE_INSTANCE_READ_ONLY},
154 { 3, SNMP_ASN1_TYPE_COUNTER, SNMP_NODE_INSTANCE_READ_ONLY},
155 { 4, SNMP_ASN1_TYPE_COUNTER, SNMP_NODE_INSTANCE_READ_ONLY},
156 { 5, SNMP_ASN1_TYPE_COUNTER, SNMP_NODE_INSTANCE_READ_ONLY},
157 { 6, SNMP_ASN1_TYPE_COUNTER, SNMP_NODE_INSTANCE_READ_ONLY},
158 { 7, SNMP_ASN1_TYPE_COUNTER, SNMP_NODE_INSTANCE_READ_ONLY},
159 { 8, SNMP_ASN1_TYPE_COUNTER, SNMP_NODE_INSTANCE_READ_ONLY},
160 { 9, SNMP_ASN1_TYPE_COUNTER, SNMP_NODE_INSTANCE_READ_ONLY},
161 {10, SNMP_ASN1_TYPE_COUNTER, SNMP_NODE_INSTANCE_READ_ONLY},
162 {11, SNMP_ASN1_TYPE_COUNTER, SNMP_NODE_INSTANCE_READ_ONLY},
163 {12, SNMP_ASN1_TYPE_COUNTER, SNMP_NODE_INSTANCE_READ_ONLY},
164 {13, SNMP_ASN1_TYPE_COUNTER, SNMP_NODE_INSTANCE_READ_ONLY},
165 {14, SNMP_ASN1_TYPE_COUNTER, SNMP_NODE_INSTANCE_READ_ONLY},
166 {15, SNMP_ASN1_TYPE_COUNTER, SNMP_NODE_INSTANCE_READ_ONLY},
167 {16, SNMP_ASN1_TYPE_COUNTER, SNMP_NODE_INSTANCE_READ_ONLY},
168 {17, SNMP_ASN1_TYPE_COUNTER, SNMP_NODE_INSTANCE_READ_ONLY},
169 {18, SNMP_ASN1_TYPE_COUNTER, SNMP_NODE_INSTANCE_READ_ONLY},
170 {19, SNMP_ASN1_TYPE_COUNTER, SNMP_NODE_INSTANCE_READ_ONLY},
171 {20, SNMP_ASN1_TYPE_COUNTER, SNMP_NODE_INSTANCE_READ_ONLY},
172 {21, SNMP_ASN1_TYPE_COUNTER, SNMP_NODE_INSTANCE_READ_ONLY},
173 {22, SNMP_ASN1_TYPE_COUNTER, SNMP_NODE_INSTANCE_READ_ONLY},
174 {23, SNMP_ASN1_TYPE_COUNTER, SNMP_NODE_INSTANCE_READ_ONLY},
175 {24, SNMP_ASN1_TYPE_COUNTER, SNMP_NODE_INSTANCE_READ_ONLY},
176 {25, SNMP_ASN1_TYPE_COUNTER, SNMP_NODE_INSTANCE_READ_ONLY},
177 {26, SNMP_ASN1_TYPE_COUNTER, SNMP_NODE_INSTANCE_READ_ONLY}
178 };
179  
180 const struct snmp_scalar_array_node snmp_mib2_icmp_root = SNMP_SCALAR_CREATE_ARRAY_NODE(5, icmp_nodes, icmp_get_value, NULL, NULL);
181  
182 #endif /* LWIP_SNMP && SNMP_LWIP_MIB2 && LWIP_ICMP */