OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [net/] [snmp/] [agent/] [v2_0/] [src/] [mibgroup/] [mibII/] [icmp.c] - Blame information for rev 27

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
//==========================================================================
2
//
3
//      snmp/snmpagent/current/src/mibgroup/mibII/icmp.c
4
//
5
//
6
//==========================================================================
7
//####ECOSGPLCOPYRIGHTBEGIN####
8
// -------------------------------------------
9
// This file is part of eCos, the Embedded Configurable Operating System.
10
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
11
//
12
// eCos is free software; you can redistribute it and/or modify it under
13
// the terms of the GNU General Public License as published by the Free
14
// Software Foundation; either version 2 or (at your option) any later version.
15
//
16
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
17
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
18
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19
// for more details.
20
//
21
// You should have received a copy of the GNU General Public License along
22
// with eCos; if not, write to the Free Software Foundation, Inc.,
23
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
24
//
25
// As a special exception, if other files instantiate templates or use macros
26
// or inline functions from this file, or you compile this file and link it
27
// with other works to produce a work based on this file, this file does not
28
// by itself cause the resulting work to be covered by the GNU General Public
29
// License. However the source code for this file must still be made available
30
// in accordance with section (3) of the GNU General Public License.
31
//
32
// This exception does not invalidate any other reasons why a work based on
33
// this file might be covered by the GNU General Public License.
34
//
35
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
36
// at http://sources.redhat.com/ecos/ecos-license/
37
// -------------------------------------------
38
//####ECOSGPLCOPYRIGHTEND####
39
//####UCDSNMPCOPYRIGHTBEGIN####
40
//
41
// -------------------------------------------
42
//
43
// Portions of this software may have been derived from the UCD-SNMP
44
// project,  <http://ucd-snmp.ucdavis.edu/>  from the University of
45
// California at Davis, which was originally based on the Carnegie Mellon
46
// University SNMP implementation.  Portions of this software are therefore
47
// covered by the appropriate copyright disclaimers included herein.
48
//
49
// The release used was version 4.1.2 of May 2000.  "ucd-snmp-4.1.2"
50
// -------------------------------------------
51
//
52
//####UCDSNMPCOPYRIGHTEND####
53
//==========================================================================
54
//#####DESCRIPTIONBEGIN####
55
//
56
// Author(s):    hmt
57
// Contributors: hmt
58
// Date:         2000-05-30
59
// Purpose:      Port of UCD-SNMP distribution to eCos.
60
// Description:  
61
//              
62
//
63
//####DESCRIPTIONEND####
64
//
65
//==========================================================================
66
/********************************************************************
67
       Copyright 1989, 1991, 1992 by Carnegie Mellon University
68
 
69
                          Derivative Work -
70
Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
71
 
72
                         All Rights Reserved
73
 
74
Permission to use, copy, modify and distribute this software and its
75
documentation for any purpose and without fee is hereby granted,
76
provided that the above copyright notice appears in all copies and
77
that both that copyright notice and this permission notice appear in
78
supporting documentation, and that the name of CMU and The Regents of
79
the University of California not be used in advertising or publicity
80
pertaining to distribution of the software without specific written
81
permission.
82
 
83
CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
84
WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
85
WARRANTIES OF MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL CMU OR
86
THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
87
INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
88
FROM THE LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
89
CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
90
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
91
*********************************************************************/
92
/* This file was generated by mib2c and is intended for use as a mib module
93
   for the ucd-snmp snmpd agent. */
94
 
95
 
96
/* This should always be included first before anything else */
97
#include <config.h>
98
 
99
 
100
/* minimal include directives */
101
#include "mibincl.h"
102
#include "mibgroup/util_funcs.h"
103
#include "mibgroup/mibII/icmp.h"
104
 
105
 
106
#define _KERNEL
107
#include <netinet/ip_icmp.h>
108
#include <netinet/icmp_var.h>
109
 
110
/*
111
 * icmp_variables_oid:
112
 *   this is the top level oid that we want to register under.  This
113
 *   is essentially a prefix, with the suffix appearing in the
114
 *   variable below.
115
 */
116
 
117
 
118
oid icmp_variables_oid[] = { 1,3,6,1,2,1,5 };
119
 
120
 
121
/*
122
 * variable2 icmp_variables:
123
 *   this variable defines function callbacks and type return information
124
 *   for the icmp mib section
125
 */
126
 
127
 
128
struct variable2 icmp_variables[] = {
129
/*  magic number        , variable type , ro/rw , callback fn  , L, oidsuffix */
130
#define   ICMPINMSGS            1
131
  { ICMPINMSGS          , ASN_COUNTER   , RONLY , var_icmp, 1, { 1 } },
132
#define   ICMPINERRORS          2
133
  { ICMPINERRORS        , ASN_COUNTER   , RONLY , var_icmp, 1, { 2 } },
134
#define   ICMPINDESTUNREACHS    3
135
  { ICMPINDESTUNREACHS  , ASN_COUNTER   , RONLY , var_icmp, 1, { 3 } },
136
#define   ICMPINTIMEEXCDS       4
137
  { ICMPINTIMEEXCDS     , ASN_COUNTER   , RONLY , var_icmp, 1, { 4 } },
138
#define   ICMPINPARMPROBS       5
139
  { ICMPINPARMPROBS     , ASN_COUNTER   , RONLY , var_icmp, 1, { 5 } },
140
#define   ICMPINSRCQUENCHS      6
141
  { ICMPINSRCQUENCHS    , ASN_COUNTER   , RONLY , var_icmp, 1, { 6 } },
142
#define   ICMPINREDIRECTS       7
143
  { ICMPINREDIRECTS     , ASN_COUNTER   , RONLY , var_icmp, 1, { 7 } },
144
#define   ICMPINECHOS           8
145
  { ICMPINECHOS         , ASN_COUNTER   , RONLY , var_icmp, 1, { 8 } },
146
#define   ICMPINECHOREPS        9
147
  { ICMPINECHOREPS      , ASN_COUNTER   , RONLY , var_icmp, 1, { 9 } },
148
#define   ICMPINTIMESTAMPS      10
149
  { ICMPINTIMESTAMPS    , ASN_COUNTER   , RONLY , var_icmp, 1, { 10 } },
150
#define   ICMPINTIMESTAMPREPS   11
151
  { ICMPINTIMESTAMPREPS , ASN_COUNTER   , RONLY , var_icmp, 1, { 11 } },
152
#define   ICMPINADDRMASKS       12
153
  { ICMPINADDRMASKS     , ASN_COUNTER   , RONLY , var_icmp, 1, { 12 } },
154
#define   ICMPINADDRMASKREPS    13
155
  { ICMPINADDRMASKREPS  , ASN_COUNTER   , RONLY , var_icmp, 1, { 13 } },
156
#define   ICMPOUTMSGS           14
157
  { ICMPOUTMSGS         , ASN_COUNTER   , RONLY , var_icmp, 1, { 14 } },
158
#define   ICMPOUTERRORS         15
159
  { ICMPOUTERRORS       , ASN_COUNTER   , RONLY , var_icmp, 1, { 15 } },
160
#define   ICMPOUTDESTUNREACHS   16
161
  { ICMPOUTDESTUNREACHS , ASN_COUNTER   , RONLY , var_icmp, 1, { 16 } },
162
#define   ICMPOUTTIMEEXCDS      17
163
  { ICMPOUTTIMEEXCDS    , ASN_COUNTER   , RONLY , var_icmp, 1, { 17 } },
164
#define   ICMPOUTPARMPROBS      18
165
  { ICMPOUTPARMPROBS    , ASN_COUNTER   , RONLY , var_icmp, 1, { 18 } },
166
#define   ICMPOUTSRCQUENCHS     19
167
  { ICMPOUTSRCQUENCHS   , ASN_COUNTER   , RONLY , var_icmp, 1, { 19 } },
168
#define   ICMPOUTREDIRECTS      20
169
  { ICMPOUTREDIRECTS    , ASN_COUNTER   , RONLY , var_icmp, 1, { 20 } },
170
#define   ICMPOUTECHOS          21
171
  { ICMPOUTECHOS        , ASN_COUNTER   , RONLY , var_icmp, 1, { 21 } },
172
#define   ICMPOUTECHOREPS       22
173
  { ICMPOUTECHOREPS     , ASN_COUNTER   , RONLY , var_icmp, 1, { 22 } },
174
#define   ICMPOUTTIMESTAMPS     23
175
  { ICMPOUTTIMESTAMPS   , ASN_COUNTER   , RONLY , var_icmp, 1, { 23 } },
176
#define   ICMPOUTTIMESTAMPREPS  24
177
  { ICMPOUTTIMESTAMPREPS, ASN_COUNTER   , RONLY , var_icmp, 1, { 24 } },
178
#define   ICMPOUTADDRMASKS      25
179
  { ICMPOUTADDRMASKS    , ASN_COUNTER   , RONLY , var_icmp, 1, { 25 } },
180
#define   ICMPOUTADDRMASKREPS   26
181
  { ICMPOUTADDRMASKREPS , ASN_COUNTER   , RONLY , var_icmp, 1, { 26 } },
182
 
183
};
184
/*    (L = length of the oidsuffix) */
185
 
186
 
187
/*
188
 * init_icmp():
189
 *   Initialization routine.  This is called when the agent starts up.
190
 *   At a minimum, registration of your variables should take place here.
191
 */
192
void init_icmp(void) {
193
 
194
 
195
  /* register ourselves with the agent to handle our mib tree */
196
  REGISTER_MIB("icmp", icmp_variables, variable2,
197
               icmp_variables_oid);
198
 
199
 
200
  /* place any other initialization junk you need here */
201
}
202
 
203
 
204
/*
205
 * var_icmp():
206
 *   This function is called every time the agent gets a request for
207
 *   a scalar variable that might be found within your mib section
208
 *   registered above.  It is up to you to do the right thing and
209
 *   return the correct value.
210
 *     You should also correct the value of "var_len" if necessary.
211
 *
212
 *   Please see the documentation for more information about writing
213
 *   module extensions, and check out the examples in the examples
214
 *   and mibII directories.
215
 */
216
unsigned char *
217
var_icmp(struct variable *vp,
218
                oid     *name,
219
                size_t  *length,
220
                int     exact,
221
                size_t  *var_len,
222
                WriteMethod **write_method)
223
{
224
    /* variables we may use later */
225
    static long long_ret;
226
    int i;
227
 
228
    if (header_generic(vp,name,length,exact,var_len,write_method)
229
        == MATCH_FAILED )
230
        return NULL;
231
 
232
    switch (vp->magic){
233
    case ICMPINMSGS:
234
        long_ret = icmpstat.icps_badcode + icmpstat.icps_tooshort +
235
            icmpstat.icps_checksum + icmpstat.icps_badlen;
236
        for (i=0; i <= ICMP_MAXTYPE; i++)
237
            long_ret += icmpstat.icps_inhist[i];
238
        return (u_char *)&long_ret;
239
    case ICMPINERRORS:
240
        long_ret = icmpstat.icps_badcode + icmpstat.icps_tooshort +
241
            icmpstat.icps_checksum + icmpstat.icps_badlen;
242
        return (u_char *)&long_ret;
243
    case ICMPINDESTUNREACHS:
244
        long_ret = icmpstat.icps_inhist[ICMP_UNREACH];
245
        return (u_char *) &long_ret;
246
    case ICMPINTIMEEXCDS:
247
        long_ret = icmpstat.icps_inhist[ICMP_TIMXCEED];
248
        return (u_char *) &long_ret;
249
    case ICMPINPARMPROBS:
250
        long_ret = icmpstat.icps_inhist[ICMP_PARAMPROB];
251
        return (u_char *) &long_ret;
252
    case ICMPINSRCQUENCHS:
253
        long_ret = icmpstat.icps_inhist[ICMP_SOURCEQUENCH];
254
        return (u_char *) &long_ret;
255
    case ICMPINREDIRECTS:
256
        long_ret = icmpstat.icps_inhist[ICMP_REDIRECT];
257
        return (u_char *) &long_ret;
258
    case ICMPINECHOS:
259
        long_ret = icmpstat.icps_inhist[ICMP_ECHO];
260
        return (u_char *) &long_ret;
261
    case ICMPINECHOREPS:
262
        long_ret = icmpstat.icps_inhist[ICMP_ECHOREPLY];
263
        return (u_char *) &long_ret;
264
    case ICMPINTIMESTAMPS:
265
        long_ret = icmpstat.icps_inhist[ICMP_TSTAMP];
266
        return (u_char *) &long_ret;
267
    case ICMPINTIMESTAMPREPS:
268
        long_ret = icmpstat.icps_inhist[ICMP_TSTAMPREPLY];
269
        return (u_char *) &long_ret;
270
    case ICMPINADDRMASKS:
271
        long_ret = icmpstat.icps_inhist[ICMP_MASKREQ];
272
        return (u_char *) &long_ret;
273
    case ICMPINADDRMASKREPS:
274
        long_ret = icmpstat.icps_inhist[ICMP_MASKREPLY];
275
        return (u_char *) &long_ret;
276
    case ICMPOUTMSGS:
277
        long_ret = icmpstat.icps_oldshort + icmpstat.icps_oldicmp;
278
        for (i=0; i <= ICMP_MAXTYPE; i++)
279
            long_ret += icmpstat.icps_outhist[i];
280
        return (u_char *)&long_ret;
281
    case ICMPOUTERRORS:
282
        long_ret = icmpstat.icps_oldshort + icmpstat.icps_oldicmp;
283
        return (u_char *)&long_ret;
284
    case ICMPOUTDESTUNREACHS:
285
        long_ret = icmpstat.icps_outhist[ICMP_UNREACH];
286
        return (u_char *) &long_ret;
287
    case ICMPOUTTIMEEXCDS:
288
        long_ret = icmpstat.icps_outhist[ICMP_TIMXCEED];
289
        return (u_char *) &long_ret;
290
    case ICMPOUTPARMPROBS:
291
        long_ret = icmpstat.icps_outhist[ICMP_PARAMPROB];
292
        return (u_char *) &long_ret;
293
    case ICMPOUTSRCQUENCHS:
294
        long_ret = icmpstat.icps_outhist[ICMP_SOURCEQUENCH];
295
        return (u_char *) &long_ret;
296
    case ICMPOUTREDIRECTS:
297
        long_ret = icmpstat.icps_outhist[ICMP_REDIRECT];
298
        return (u_char *) &long_ret;
299
    case ICMPOUTECHOS:
300
        long_ret = icmpstat.icps_outhist[ICMP_ECHO];
301
        return (u_char *) &long_ret;
302
    case ICMPOUTECHOREPS:
303
        long_ret = icmpstat.icps_outhist[ICMP_ECHOREPLY];
304
        return (u_char *) &long_ret;
305
    case ICMPOUTTIMESTAMPS:
306
        long_ret = icmpstat.icps_outhist[ICMP_TSTAMP];
307
        return (u_char *) &long_ret;
308
    case ICMPOUTTIMESTAMPREPS:
309
        long_ret = icmpstat.icps_outhist[ICMP_TSTAMPREPLY];
310
        return (u_char *) &long_ret;
311
    case ICMPOUTADDRMASKS:
312
        long_ret = icmpstat.icps_outhist[ICMP_MASKREQ];
313
        return (u_char *) &long_ret;
314
    case ICMPOUTADDRMASKREPS:
315
        long_ret = icmpstat.icps_outhist[ICMP_MASKREPLY];
316
        return (u_char *) &long_ret;
317
    default:
318
        DEBUGMSGTL(("snmpd", "unknown sub-id %d in var_icmp\n", vp->magic));
319
    }
320
 
321
    return NULL;
322
}
323
 
324
// EOF icmp.c

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.