|
|
1.1 root 1: /* icmp.c - MIB realization of the ICMP group */
2:
3: #ifndef lint
4: static char *rcsid = "$Header: /f/osi/snmp/RCS/icmp.c,v 7.1 90/02/17 10:38:06 mrose Exp $";
5: #endif
6:
7: /*
8: * $Header: /f/osi/snmp/RCS/icmp.c,v 7.1 90/02/17 10:38:06 mrose Exp $
9: *
10: * Contributed by NYSERNet Inc. This work was partially supported by the
11: * U.S. Defense Advanced Research Projects Agency and the Rome Air Development
12: * Center of the U.S. Air Force Systems Command under contract number
13: * F30602-88-C-0016.
14: *
15: *
16: * $Log: icmp.c,v $
17: * Revision 7.1 90/02/17 10:38:06 mrose
18: * smux
19: *
20: * Revision 7.0 89/11/23 22:23:02 mrose
21: * Release 6.0
22: *
23: */
24:
25: /*
26: * NOTICE
27: *
28: * Acquisition, use, and distribution of this module and related
29: * materials are subject to the restrictions of a license agreement.
30: * Consult the Preface in the User's Manual for the full terms of
31: * this agreement.
32: *
33: */
34:
35:
36: #include <stdio.h>
37: #include "mib.h"
38:
39: #include "internet.h"
40: #ifdef BSD44
41: #include <machine/machparam.h>
42: #endif
43: #include <netinet/in_systm.h>
44: #include <netinet/ip.h>
45: #include <netinet/ip_icmp.h>
46: #include <netinet/icmp_var.h>
47:
48: /* */
49:
50: static struct icmpstat icmpstat;
51:
52: /* */
53:
54: #define icmpInMsgs 0
55: #define icmpInErrors 1
56: #define icmpInDestUnreachs 2
57: #define icmpInTimeExcds 3
58: #define icmpInParmProbs 4
59: #define icmpInSrcQuenchs 5
60: #define icmpInRedirects 6
61: #define icmpInEchos 7
62: #define icmpInEchoReps 8
63: #define icmpInTimestamps 9
64: #define icmpInTimestampReps 10
65: #define icmpInAddrMasks 11
66: #define icmpInAddrMaskReps 12
67: #define icmpOutMsgs 13
68: #define icmpOutErrors 14
69: #define icmpOutDestUnreachs 15
70: #define icmpOutTimeExcds 16
71: #define icmpOutParmProbs 17
72: #define icmpOutSrcQuenchs 18
73: #define icmpOutRedirects 19
74: #define icmpOutEchos 20
75: #define icmpOutEchoReps 21
76: #define icmpOutTimestamps 22
77: #define icmpOutTimestampReps 23
78: #define icmpOutAddrMasks 24
79: #define icmpOutAddrMaskReps 25
80:
81:
82: static int o_icmp (oi, v, offset)
83: OI oi;
84: register struct type_SNMP_VarBind *v;
85: int offset;
86: {
87: int ifvar;
88: register struct icmpstat *icps = &icmpstat;
89: register OID oid = oi -> oi_name;
90: register OT ot = oi -> oi_type;
91: static int lastq = -1;
92:
93: ifvar = (int) ot -> ot_info;
94: switch (offset) {
95: case type_SNMP_PDUs_get__request:
96: if (oid -> oid_nelem != ot -> ot_name -> oid_nelem + 1
97: || oid -> oid_elements[oid -> oid_nelem - 1] != 0)
98: return int_SNMP_error__status_noSuchName;
99: break;
100:
101: case type_SNMP_PDUs_get__next__request:
102: if (oid -> oid_nelem == ot -> ot_name -> oid_nelem) {
103: OID new;
104:
105: if ((new = oid_extend (oid, 1)) == NULLOID)
106: return int_SNMP_error__status_genErr;
107: new -> oid_elements[new -> oid_nelem - 1] = 0;
108:
109: if (v -> name)
110: free_SNMP_ObjectName (v -> name);
111: v -> name = new;
112: }
113: else
114: return NOTOK;
115: break;
116:
117: default:
118: return int_SNMP_error__status_genErr;
119: }
120:
121: if (quantum != lastq) {
122: lastq = quantum;
123:
124: if (getkmem (nl + N_ICMPSTAT, (caddr_t) icps, sizeof *icps) == NOTOK)
125: return int_SNMP_error__status_genErr;
126: }
127:
128: switch (ifvar) {
129: case icmpInMsgs:
130: return o_integer (oi, v, icps -> icps_checksum
131: + icps -> icps_badlen
132: + icps -> icps_inhist[ICMP_ECHOREPLY]
133: + icps -> icps_inhist[ICMP_UNREACH]
134: + icps -> icps_inhist[ICMP_SOURCEQUENCH]
135: + icps -> icps_inhist[ICMP_REDIRECT]
136: + icps -> icps_inhist[ICMP_ECHO]
137: + icps -> icps_inhist[ICMP_TIMXCEED]
138: + icps -> icps_inhist[ICMP_PARAMPROB]
139: + icps -> icps_inhist[ICMP_TSTAMP]
140: + icps -> icps_inhist[ICMP_TSTAMPREPLY]
141: + icps -> icps_inhist[ICMP_MASKREQ]
142: + icps -> icps_inhist[ICMP_MASKREPLY]);
143:
144: case icmpInErrors:
145: return o_integer (oi, v, icps -> icps_badcode
146: + icps -> icps_checksum
147: + icps -> icps_badlen);
148:
149: case icmpInDestUnreachs:
150: return o_integer (oi, v, icps -> icps_inhist[ICMP_UNREACH]);
151:
152: case icmpInTimeExcds:
153: return o_integer (oi, v, icps -> icps_inhist[ICMP_TIMXCEED]);
154:
155: case icmpInParmProbs:
156: return o_integer (oi, v, icps -> icps_inhist[ICMP_PARAMPROB]);
157:
158: case icmpInSrcQuenchs:
159: return o_integer (oi, v, icps -> icps_inhist[ICMP_SOURCEQUENCH]);
160:
161: case icmpInRedirects:
162: return o_integer (oi, v, icps -> icps_inhist[ICMP_REDIRECT]);
163:
164: case icmpInEchos:
165: return o_integer (oi, v, icps -> icps_inhist[ICMP_ECHO]);
166:
167: case icmpInEchoReps:
168: return o_integer (oi, v, icps -> icps_inhist[ICMP_ECHOREPLY]);
169:
170: case icmpInTimestamps:
171: return o_integer (oi, v, icps -> icps_inhist[ICMP_TSTAMP]);
172:
173: case icmpInTimestampReps:
174: return o_integer (oi, v, icps -> icps_inhist[ICMP_TSTAMPREPLY]);
175:
176: case icmpInAddrMasks:
177: return o_integer (oi, v, icps -> icps_inhist[ICMP_MASKREQ]);
178:
179: case icmpInAddrMaskReps:
180: return o_integer (oi, v, icps -> icps_inhist[ICMP_MASKREPLY]);
181:
182: case icmpOutMsgs:
183: return o_integer (oi, v, icps -> icps_error + icps -> icps_reflect);
184:
185: case icmpOutErrors:
186: return o_integer (oi, v, icps -> icps_error);
187:
188: case icmpOutDestUnreachs:
189: return o_integer (oi, v, icps -> icps_outhist[ICMP_UNREACH]);
190:
191: case icmpOutTimeExcds:
192: return o_integer (oi, v, icps -> icps_outhist[ICMP_TIMXCEED]);
193:
194: case icmpOutParmProbs:
195: return o_integer (oi, v, icps -> icps_outhist[ICMP_PARAMPROB]);
196:
197: case icmpOutSrcQuenchs:
198: return o_integer (oi, v, icps -> icps_outhist[ICMP_SOURCEQUENCH]);
199:
200: case icmpOutRedirects:
201: return o_integer (oi, v, icps -> icps_outhist[ICMP_REDIRECT]);
202:
203: case icmpOutEchos:
204: return o_integer (oi, v, icps -> icps_outhist[ICMP_ECHO]);
205:
206: case icmpOutEchoReps:
207: return o_integer (oi, v, icps -> icps_outhist[ICMP_ECHOREPLY]);
208:
209: case icmpOutTimestamps:
210: return o_integer (oi, v, icps -> icps_outhist[ICMP_TSTAMP]);
211:
212: case icmpOutTimestampReps:
213: return o_integer (oi, v, icps -> icps_outhist[ICMP_TSTAMPREPLY]);
214:
215: case icmpOutAddrMasks:
216: return o_integer (oi, v, icps -> icps_outhist[ICMP_MASKREQ]);
217:
218: case icmpOutAddrMaskReps:
219: return o_integer (oi, v, icps -> icps_outhist[ICMP_MASKREPLY]);
220:
221: default:
222: return int_SNMP_error__status_noSuchName;
223: }
224: }
225:
226: /* */
227:
228: init_icmp () {
229: register OT ot;
230:
231: if (ot = text2obj ("icmpInMsgs"))
232: ot -> ot_getfnx = o_icmp,
233: ot -> ot_info = (caddr_t) icmpInMsgs;
234: if (ot = text2obj ("icmpInErrors"))
235: ot -> ot_getfnx = o_icmp,
236: ot -> ot_info = (caddr_t) icmpInErrors;
237: if (ot = text2obj ("icmpInDestUnreachs"))
238: ot -> ot_getfnx = o_icmp,
239: ot -> ot_info = (caddr_t) icmpInDestUnreachs;
240: if (ot = text2obj ("icmpInTimeExcds"))
241: ot -> ot_getfnx = o_icmp,
242: ot -> ot_info = (caddr_t) icmpInTimeExcds;
243: if (ot = text2obj ("icmpInParmProbs"))
244: ot -> ot_getfnx = o_icmp,
245: ot -> ot_info = (caddr_t) icmpInParmProbs;
246: if (ot = text2obj ("icmpInSrcQuenchs"))
247: ot -> ot_getfnx = o_icmp,
248: ot -> ot_info = (caddr_t) icmpInSrcQuenchs;
249: if (ot = text2obj ("icmpInRedirects"))
250: ot -> ot_getfnx = o_icmp,
251: ot -> ot_info = (caddr_t) icmpInRedirects;
252: if (ot = text2obj ("icmpInEchos"))
253: ot -> ot_getfnx = o_icmp,
254: ot -> ot_info = (caddr_t) icmpInEchos;
255: if (ot = text2obj ("icmpInEchoReps"))
256: ot -> ot_getfnx = o_icmp,
257: ot -> ot_info = (caddr_t) icmpInEchoReps;
258: if (ot = text2obj ("icmpInTimestamps"))
259: ot -> ot_getfnx = o_icmp,
260: ot -> ot_info = (caddr_t) icmpInTimestamps;
261: if (ot = text2obj ("icmpInTimestampReps"))
262: ot -> ot_getfnx = o_icmp,
263: ot -> ot_info = (caddr_t) icmpInTimestampReps;
264: if (ot = text2obj ("icmpInAddrMasks"))
265: ot -> ot_getfnx = o_icmp,
266: ot -> ot_info = (caddr_t) icmpInAddrMasks;
267: if (ot = text2obj ("icmpInAddrMaskReps"))
268: ot -> ot_getfnx = o_icmp,
269: ot -> ot_info = (caddr_t) icmpInAddrMaskReps;
270: if (ot = text2obj ("icmpOutMsgs"))
271: ot -> ot_getfnx = o_icmp,
272: ot -> ot_info = (caddr_t) icmpOutMsgs;
273: if (ot = text2obj ("icmpOutErrors"))
274: ot -> ot_getfnx = o_icmp,
275: ot -> ot_info = (caddr_t) icmpOutErrors;
276: if (ot = text2obj ("icmpOutDestUnreachs"))
277: ot -> ot_getfnx = o_icmp,
278: ot -> ot_info = (caddr_t) icmpOutDestUnreachs;
279: if (ot = text2obj ("icmpOutTimeExcds"))
280: ot -> ot_getfnx = o_icmp,
281: ot -> ot_info = (caddr_t) icmpOutTimeExcds;
282: if (ot = text2obj ("icmpOutParmProbs"))
283: ot -> ot_getfnx = o_icmp,
284: ot -> ot_info = (caddr_t) icmpOutParmProbs;
285: if (ot = text2obj ("icmpOutSrcQuenchs"))
286: ot -> ot_getfnx = o_icmp,
287: ot -> ot_info = (caddr_t) icmpOutSrcQuenchs;
288: if (ot = text2obj ("icmpOutRedirects"))
289: ot -> ot_getfnx = o_icmp,
290: ot -> ot_info = (caddr_t) icmpOutRedirects;
291: if (ot = text2obj ("icmpOutEchos"))
292: ot -> ot_getfnx = o_icmp,
293: ot -> ot_info = (caddr_t) icmpOutEchos;
294: if (ot = text2obj ("icmpOutEchoReps"))
295: ot -> ot_getfnx = o_icmp,
296: ot -> ot_info = (caddr_t) icmpOutEchoReps;
297: if (ot = text2obj ("icmpOutTimestamps"))
298: ot -> ot_getfnx = o_icmp,
299: ot -> ot_info = (caddr_t) icmpOutTimestamps;
300: if (ot = text2obj ("icmpOutTimestampReps"))
301: ot -> ot_getfnx = o_icmp,
302: ot -> ot_info = (caddr_t) icmpOutTimestampReps;
303: if (ot = text2obj ("icmpOutAddrMasks"))
304: ot -> ot_getfnx = o_icmp,
305: ot -> ot_info = (caddr_t) icmpOutAddrMasks;
306: if (ot = text2obj ("icmpOutAddrMaskReps"))
307: ot -> ot_getfnx = o_icmp,
308: ot -> ot_info = (caddr_t) icmpOutAddrMaskReps;
309: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.