1 |
27 |
unneback |
//==========================================================================
|
2 |
|
|
//
|
3 |
|
|
// snmp/snmpagent/current/src/mibgroup/mibII/interfaces.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, Andrew Lunn
|
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 |
|
|
#include <pkgconf/system.h>
|
96 |
|
|
|
97 |
|
|
#include <sys/param.h>
|
98 |
|
|
#include <sys/socket.h>
|
99 |
|
|
#include <sys/time.h>
|
100 |
|
|
#include <net/if.h>
|
101 |
|
|
#ifdef CYGPKG_NET_FREEBSD_STACK
|
102 |
|
|
#include <net/if_var.h>
|
103 |
|
|
#endif
|
104 |
|
|
#include <netinet/in.h>
|
105 |
|
|
#include <netinet/if_ether.h>
|
106 |
|
|
#include <net/if_arp.h>
|
107 |
|
|
// These two to acquire all the statistics.
|
108 |
|
|
|
109 |
|
|
#include <cyg/io/eth/eth_drv_stats.h>
|
110 |
|
|
#include <sys/sockio.h>
|
111 |
|
|
|
112 |
|
|
/* This should always be included first before anything else */
|
113 |
|
|
#include <config.h>
|
114 |
|
|
|
115 |
|
|
|
116 |
|
|
/* minimal include directives */
|
117 |
|
|
#include "mibincl.h"
|
118 |
|
|
#include "mibgroup/util_funcs.h"
|
119 |
|
|
#include "mibgroup/mibII/interfaces.h"
|
120 |
|
|
#include "mibgroup/mibII/ifr_helper.h"
|
121 |
|
|
#include <net/if_types.h>
|
122 |
|
|
|
123 |
|
|
/*
|
124 |
|
|
* interfaces_variables_oid:
|
125 |
|
|
* this is the top level oid that we want to register under. This
|
126 |
|
|
* is essentially a prefix, with the suffix appearing in the
|
127 |
|
|
* variable below.
|
128 |
|
|
*/
|
129 |
|
|
oid interfaces_variables_oid[] = { 1,3,6,1,2,1,2 };
|
130 |
|
|
|
131 |
|
|
|
132 |
|
|
/*
|
133 |
|
|
* variable4 interfaces_variables:
|
134 |
|
|
* this variable defines function callbacks and type return information
|
135 |
|
|
* for the interfaces mib section
|
136 |
|
|
*/
|
137 |
|
|
|
138 |
|
|
|
139 |
|
|
struct variable4 interfaces_variables[] = {
|
140 |
|
|
/* magic number , variable type , ro/rw , callback fn , L, oidsuffix */
|
141 |
|
|
#define IFNUMBER 1
|
142 |
|
|
{ IFNUMBER , ASN_INTEGER , RONLY , var_interfaces, 1, { 1 } },
|
143 |
|
|
#define IFINDEX 4
|
144 |
|
|
{ IFINDEX , ASN_INTEGER , RONLY , var_ifTable, 3, { 2,1,1 } },
|
145 |
|
|
#define IFDESCR 5
|
146 |
|
|
{ IFDESCR , ASN_OCTET_STR , RONLY , var_ifTable, 3, { 2,1,2 } },
|
147 |
|
|
#define IFTYPE 6
|
148 |
|
|
{ IFTYPE , ASN_INTEGER , RONLY , var_ifTable, 3, { 2,1,3 } },
|
149 |
|
|
#define IFMTU 7
|
150 |
|
|
{ IFMTU , ASN_INTEGER , RONLY , var_ifTable, 3, { 2,1,4 } },
|
151 |
|
|
#define IFSPEED 8
|
152 |
|
|
{ IFSPEED , ASN_GAUGE , RONLY , var_ifTable, 3, { 2,1,5 } },
|
153 |
|
|
#define IFPHYSADDRESS 9
|
154 |
|
|
{ IFPHYSADDRESS , ASN_OCTET_STR , RONLY , var_ifTable, 3, { 2,1,6 } },
|
155 |
|
|
#define IFADMINSTATUS 10
|
156 |
|
|
{ IFADMINSTATUS , ASN_INTEGER , RWRITE, var_ifTable, 3, { 2,1,7 } },
|
157 |
|
|
#define IFOPERSTATUS 11
|
158 |
|
|
{ IFOPERSTATUS , ASN_INTEGER , RONLY , var_ifTable, 3, { 2,1,8 } },
|
159 |
|
|
#define IFLASTCHANGE 12
|
160 |
|
|
{ IFLASTCHANGE , ASN_TIMETICKS , RONLY , var_ifTable, 3, { 2,1,9 } },
|
161 |
|
|
#define IFINOCTETS 13
|
162 |
|
|
{ IFINOCTETS , ASN_COUNTER , RONLY , var_ifTable, 3, { 2,1,10 } },
|
163 |
|
|
#define IFINUCASTPKTS 14
|
164 |
|
|
{ IFINUCASTPKTS , ASN_COUNTER , RONLY , var_ifTable, 3, { 2,1,11 } },
|
165 |
|
|
#define IFINNUCASTPKTS 15
|
166 |
|
|
{ IFINNUCASTPKTS , ASN_COUNTER , RONLY , var_ifTable, 3, { 2,1,12 } },
|
167 |
|
|
#define IFINDISCARDS 16
|
168 |
|
|
{ IFINDISCARDS , ASN_COUNTER , RONLY , var_ifTable, 3, { 2,1,13 } },
|
169 |
|
|
#define IFINERRORS 17
|
170 |
|
|
{ IFINERRORS , ASN_COUNTER , RONLY , var_ifTable, 3, { 2,1,14 } },
|
171 |
|
|
#define IFINUNKNOWNPROTOS 18
|
172 |
|
|
{ IFINUNKNOWNPROTOS , ASN_COUNTER , RONLY , var_ifTable, 3, { 2,1,15 } },
|
173 |
|
|
#define IFOUTOCTETS 19
|
174 |
|
|
{ IFOUTOCTETS , ASN_COUNTER , RONLY , var_ifTable, 3, { 2,1,16 } },
|
175 |
|
|
#define IFOUTUCASTPKTS 20
|
176 |
|
|
{ IFOUTUCASTPKTS , ASN_COUNTER , RONLY , var_ifTable, 3, { 2,1,17 } },
|
177 |
|
|
#define IFOUTNUCASTPKTS 21
|
178 |
|
|
{ IFOUTNUCASTPKTS , ASN_COUNTER , RONLY , var_ifTable, 3, { 2,1,18 } },
|
179 |
|
|
#define IFOUTDISCARDS 22
|
180 |
|
|
{ IFOUTDISCARDS , ASN_COUNTER , RONLY , var_ifTable, 3, { 2,1,19 } },
|
181 |
|
|
#define IFOUTERRORS 23
|
182 |
|
|
{ IFOUTERRORS , ASN_COUNTER , RONLY , var_ifTable, 3, { 2,1,20 } },
|
183 |
|
|
#define IFOUTQLEN 24
|
184 |
|
|
{ IFOUTQLEN , ASN_GAUGE , RONLY , var_ifTable, 3, { 2,1,21 } },
|
185 |
|
|
#define IFSPECIFIC 25
|
186 |
|
|
{ IFSPECIFIC , ASN_OBJECT_ID , RONLY , var_ifTable, 3, { 2,1,22 } },
|
187 |
|
|
|
188 |
|
|
};
|
189 |
|
|
/* (L = length of the oidsuffix) */
|
190 |
|
|
|
191 |
|
|
|
192 |
|
|
/*
|
193 |
|
|
* init_interfaces():
|
194 |
|
|
* Initialization routine. This is called when the agent starts up.
|
195 |
|
|
* At a minimum, registration of your variables should take place here.
|
196 |
|
|
*/
|
197 |
|
|
void init_interfaces(void) {
|
198 |
|
|
|
199 |
|
|
|
200 |
|
|
/* register ourselves with the agent to handle our mib tree */
|
201 |
|
|
REGISTER_MIB("interfaces", interfaces_variables, variable4,
|
202 |
|
|
interfaces_variables_oid);
|
203 |
|
|
|
204 |
|
|
|
205 |
|
|
/* place any other initialization junk you need here */
|
206 |
|
|
}
|
207 |
|
|
|
208 |
|
|
/*
|
209 |
|
|
* var_interfaces():
|
210 |
|
|
* This function is called every time the agent gets a request for
|
211 |
|
|
* a scalar variable that might be found within your mib section
|
212 |
|
|
* registered above. It is up to you to do the right thing and
|
213 |
|
|
* return the correct value.
|
214 |
|
|
* You should also correct the value of "var_len" if necessary.
|
215 |
|
|
*
|
216 |
|
|
* Please see the documentation for more information about writing
|
217 |
|
|
* module extensions, and check out the examples in the examples
|
218 |
|
|
* and mibII directories.
|
219 |
|
|
*/
|
220 |
|
|
unsigned char *
|
221 |
|
|
var_interfaces(struct variable *vp,
|
222 |
|
|
oid *name,
|
223 |
|
|
size_t *length,
|
224 |
|
|
int exact,
|
225 |
|
|
size_t *var_len,
|
226 |
|
|
WriteMethod **write_method)
|
227 |
|
|
{
|
228 |
|
|
|
229 |
|
|
|
230 |
|
|
static long long_ret;
|
231 |
|
|
|
232 |
|
|
if ( MATCH_FAILED ==
|
233 |
|
|
header_generic(vp,name,length,exact,var_len,write_method) )
|
234 |
|
|
return NULL;
|
235 |
|
|
|
236 |
|
|
/*
|
237 |
|
|
* this is where we do the value assignments for the mib results.
|
238 |
|
|
*/
|
239 |
|
|
switch(vp->magic) {
|
240 |
|
|
case IFNUMBER: {
|
241 |
|
|
long_ret = cyg_snmp_num_interfaces();
|
242 |
|
|
return (unsigned char *) &long_ret;
|
243 |
|
|
}
|
244 |
|
|
default:
|
245 |
|
|
ERROR_MSG("");
|
246 |
|
|
}
|
247 |
|
|
return NULL;
|
248 |
|
|
}
|
249 |
|
|
|
250 |
|
|
|
251 |
|
|
/*
|
252 |
|
|
* var_ifTable():
|
253 |
|
|
* Handle this table separately from the scalar value case.
|
254 |
|
|
* The workings of this are basically the same as for var_interfaces above.
|
255 |
|
|
*/
|
256 |
|
|
unsigned char *
|
257 |
|
|
var_ifTable(struct variable *vp,
|
258 |
|
|
oid *name,
|
259 |
|
|
size_t *length,
|
260 |
|
|
int exact,
|
261 |
|
|
size_t *var_len,
|
262 |
|
|
WriteMethod **write_method)
|
263 |
|
|
{
|
264 |
|
|
|
265 |
|
|
|
266 |
|
|
/* variables we may use later */
|
267 |
|
|
static long long_ret;
|
268 |
|
|
static unsigned char string[SPRINT_MAX_LEN];
|
269 |
|
|
static oid objid[MAX_OID_LEN];
|
270 |
|
|
struct ifnet *ifp;
|
271 |
|
|
int if_num;
|
272 |
|
|
|
273 |
|
|
int interface_count = cyg_snmp_num_interfaces();
|
274 |
|
|
|
275 |
|
|
/*
|
276 |
|
|
* This assumes that the table is a 'simple' table.
|
277 |
|
|
* See the implementation documentation for the meaning of this.
|
278 |
|
|
* You will need to provide the correct value for the TABLE_SIZE parameter
|
279 |
|
|
*
|
280 |
|
|
* If this table does not meet the requirements for a simple table,
|
281 |
|
|
* you will need to provide the replacement code yourself.
|
282 |
|
|
* Mib2c is not smart enough to write this for you.
|
283 |
|
|
* Again, see the implementation documentation for what is required.
|
284 |
|
|
*/
|
285 |
|
|
if ( header_simple_table( vp,name,length,exact,var_len,write_method,
|
286 |
|
|
interface_count)
|
287 |
|
|
== MATCH_FAILED )
|
288 |
|
|
return NULL;
|
289 |
|
|
|
290 |
|
|
if_num = name[ (*length)-1 ];
|
291 |
|
|
|
292 |
|
|
ifp = cyg_snmp_get_if(if_num);
|
293 |
|
|
if (!ifp)
|
294 |
|
|
return NULL;
|
295 |
|
|
|
296 |
|
|
// This is to assist customers with their own special interfaces; if they
|
297 |
|
|
// define IFT_CUSTOMER_SPECIAL to whatever their own device is, then its
|
298 |
|
|
// ioctl() will be called to handle these enquiries.
|
299 |
|
|
#ifdef IFT_CUSTOMER_SPECIAL
|
300 |
|
|
if ( (ifp->if_type == IFT_CUSTOMER_SPECIAL) && (NULL != ifp->if_ioctl) )
|
301 |
|
|
{
|
302 |
|
|
if( (vp->magic == IFDESCR) || (vp->magic == IFPHYSADDRESS) )
|
303 |
|
|
{
|
304 |
|
|
(*ifp->if_ioctl)(ifp, vp->magic, (caddr_t)string);
|
305 |
|
|
*var_len = strlen(string);
|
306 |
|
|
return (unsigned char *) string;
|
307 |
|
|
}
|
308 |
|
|
else
|
309 |
|
|
{
|
310 |
|
|
(*ifp->if_ioctl)(ifp, vp->magic, (caddr_t)&long_ret);
|
311 |
|
|
return (unsigned char *) &long_ret;
|
312 |
|
|
}
|
313 |
|
|
}
|
314 |
|
|
#endif // IFT_CUSTOMER_SPECIAL
|
315 |
|
|
|
316 |
|
|
if ( IFT_ETHER == ifp->if_type &&
|
317 |
|
|
((IFDESCR == vp->magic) ||
|
318 |
|
|
(IFSPEED == vp->magic) ||
|
319 |
|
|
(IFOUTDISCARDS == vp->magic) ||
|
320 |
|
|
(IFOUTQLEN == vp->magic) )
|
321 |
|
|
) {
|
322 |
|
|
// then acquire up to date information and deal with the relevent
|
323 |
|
|
// keys (only):
|
324 |
|
|
int i = -1;
|
325 |
|
|
struct ether_drv_stats x;
|
326 |
|
|
bzero( &x, sizeof( x ) );
|
327 |
|
|
|
328 |
|
|
// Call the ioctl to get all the info.
|
329 |
|
|
// (We KNOW it's an ether dev here, it should have an ioctl())
|
330 |
|
|
if ( NULL != ifp->if_ioctl )
|
331 |
|
|
i = (*ifp->if_ioctl)(ifp, SIOCGIFSTATSUD, (caddr_t)&x);
|
332 |
|
|
|
333 |
|
|
switch(vp->magic) {
|
334 |
|
|
case IFDESCR:
|
335 |
|
|
if ( i || 0 == x.description[0] )
|
336 |
|
|
strcpy( string, "<Ethernet, details not available>" );
|
337 |
|
|
else
|
338 |
|
|
strcpy( string, x.description );
|
339 |
|
|
*var_len = strlen(string);
|
340 |
|
|
return (unsigned char *) string;
|
341 |
|
|
|
342 |
|
|
case IFSPEED:
|
343 |
|
|
long_ret = x.speed;
|
344 |
|
|
return (unsigned char *) &long_ret;
|
345 |
|
|
|
346 |
|
|
case IFOUTDISCARDS:
|
347 |
|
|
long_ret = x.tx_dropped;
|
348 |
|
|
return (unsigned char *) &long_ret;
|
349 |
|
|
|
350 |
|
|
case IFOUTQLEN:
|
351 |
|
|
long_ret = x.tx_queue_len;
|
352 |
|
|
return (unsigned char *) &long_ret;
|
353 |
|
|
|
354 |
|
|
default:
|
355 |
|
|
CYG_FAIL( "Bad magic; shouldn't be in here" );
|
356 |
|
|
break;
|
357 |
|
|
}
|
358 |
|
|
}
|
359 |
|
|
|
360 |
|
|
switch(vp->magic) {
|
361 |
|
|
|
362 |
|
|
case IFINDEX:
|
363 |
|
|
long_ret = name[(*length)-1];
|
364 |
|
|
return (unsigned char *) &long_ret;
|
365 |
|
|
|
366 |
|
|
case IFDESCR:
|
367 |
|
|
switch ( ifp->if_type ) {
|
368 |
|
|
case IFT_LOOP:
|
369 |
|
|
strcpy( string, "(Loopback device)" );
|
370 |
|
|
break;
|
371 |
|
|
case IFT_PROPVIRTUAL:
|
372 |
|
|
strcpy( string, "(Proprietary Virtual/Internal)" );
|
373 |
|
|
break;
|
374 |
|
|
default:
|
375 |
|
|
strcpy( string, "Some shy network adaptor" );
|
376 |
|
|
break;
|
377 |
|
|
}
|
378 |
|
|
*var_len = strlen(string);
|
379 |
|
|
return (unsigned char *) string;
|
380 |
|
|
|
381 |
|
|
case IFTYPE:
|
382 |
|
|
long_ret = ifp->if_type;
|
383 |
|
|
return (unsigned char *) &long_ret;
|
384 |
|
|
|
385 |
|
|
case IFMTU:
|
386 |
|
|
long_ret = ifp->if_mtu;
|
387 |
|
|
return (unsigned char *) &long_ret;
|
388 |
|
|
|
389 |
|
|
case IFSPEED:
|
390 |
|
|
if ( IFT_LOOP == ifp->if_type )
|
391 |
|
|
long_ret = 0;
|
392 |
|
|
else
|
393 |
|
|
long_ret = ifp->if_baudrate;
|
394 |
|
|
return (unsigned char *) &long_ret;
|
395 |
|
|
|
396 |
|
|
case IFPHYSADDRESS: {
|
397 |
|
|
if ( IFT_ETHER == ifp->if_type ) {
|
398 |
|
|
struct arpcom *ac = (struct arpcom *)ifp;
|
399 |
|
|
bcopy(&ac->ac_enaddr, string, ETHER_ADDR_LEN);
|
400 |
|
|
}
|
401 |
|
|
else {
|
402 |
|
|
bzero( string, ETHER_ADDR_LEN );
|
403 |
|
|
}
|
404 |
|
|
*var_len = ETHER_ADDR_LEN;
|
405 |
|
|
return (unsigned char *) string;
|
406 |
|
|
}
|
407 |
|
|
case IFADMINSTATUS:
|
408 |
|
|
//NOTSUPPORTED: *write_method = write_ifAdminStatus;
|
409 |
|
|
long_ret = (ifp->if_flags & IFF_RUNNING) ? 1 : 2;
|
410 |
|
|
return (unsigned char *) &long_ret;
|
411 |
|
|
|
412 |
|
|
case IFOPERSTATUS:
|
413 |
|
|
long_ret = (ifp->if_flags & IFF_UP) ? 1 : 2;
|
414 |
|
|
return (unsigned char *) &long_ret;
|
415 |
|
|
|
416 |
|
|
case IFLASTCHANGE:
|
417 |
|
|
long_ret = 0; //FIXME: ifp->if_lastchange;
|
418 |
|
|
return (unsigned char *) &long_ret;
|
419 |
|
|
|
420 |
|
|
case IFINOCTETS:
|
421 |
|
|
long_ret = ifp->if_ibytes;
|
422 |
|
|
return (unsigned char *) &long_ret;
|
423 |
|
|
|
424 |
|
|
case IFINUCASTPKTS:
|
425 |
|
|
long_ret = ifp->if_ipackets - ifp->if_imcasts;
|
426 |
|
|
return (unsigned char *) &long_ret;
|
427 |
|
|
|
428 |
|
|
case IFINNUCASTPKTS:
|
429 |
|
|
long_ret = ifp->if_imcasts;
|
430 |
|
|
return (unsigned char *) &long_ret;
|
431 |
|
|
|
432 |
|
|
case IFINDISCARDS:
|
433 |
|
|
long_ret = ifp->if_iqdrops;
|
434 |
|
|
return (unsigned char *) &long_ret;
|
435 |
|
|
|
436 |
|
|
case IFINERRORS:
|
437 |
|
|
long_ret = ifp->if_ierrors;
|
438 |
|
|
return (unsigned char *) &long_ret;
|
439 |
|
|
|
440 |
|
|
case IFINUNKNOWNPROTOS:
|
441 |
|
|
long_ret = ifp->if_noproto;
|
442 |
|
|
return (unsigned char *) &long_ret;
|
443 |
|
|
|
444 |
|
|
case IFOUTOCTETS:
|
445 |
|
|
long_ret = ifp->if_obytes;
|
446 |
|
|
return (unsigned char *) &long_ret;
|
447 |
|
|
|
448 |
|
|
case IFOUTUCASTPKTS:
|
449 |
|
|
long_ret = ifp->if_opackets - ifp->if_omcasts;
|
450 |
|
|
return (unsigned char *) &long_ret;
|
451 |
|
|
|
452 |
|
|
case IFOUTNUCASTPKTS:
|
453 |
|
|
long_ret = ifp->if_omcasts;
|
454 |
|
|
return (unsigned char *) &long_ret;
|
455 |
|
|
|
456 |
|
|
case IFOUTDISCARDS:
|
457 |
|
|
long_ret = 0; // ETHER case dealt with above
|
458 |
|
|
return (unsigned char *) &long_ret;
|
459 |
|
|
|
460 |
|
|
case IFOUTERRORS:
|
461 |
|
|
long_ret = ifp->if_oerrors;
|
462 |
|
|
return (unsigned char *) &long_ret;
|
463 |
|
|
|
464 |
|
|
case IFOUTQLEN:
|
465 |
|
|
long_ret = 0; // ETHER case dealt with above
|
466 |
|
|
return (unsigned char *) &long_ret;
|
467 |
|
|
|
468 |
|
|
case IFSPECIFIC:
|
469 |
|
|
objid[0] = 0;
|
470 |
|
|
objid[1] = 0;
|
471 |
|
|
*var_len = 2*sizeof(oid);
|
472 |
|
|
return (unsigned char *) objid;
|
473 |
|
|
|
474 |
|
|
default:
|
475 |
|
|
ERROR_MSG("");
|
476 |
|
|
}
|
477 |
|
|
return NULL;
|
478 |
|
|
}
|
479 |
|
|
|
480 |
|
|
|
481 |
|
|
|
482 |
|
|
//NOTSUPPORTED:
|
483 |
|
|
#if 0
|
484 |
|
|
int
|
485 |
|
|
write_ifAdminStatus(int action,
|
486 |
|
|
u_char *var_val,
|
487 |
|
|
u_char var_val_type,
|
488 |
|
|
size_t var_val_len,
|
489 |
|
|
u_char *statP,
|
490 |
|
|
oid *name,
|
491 |
|
|
size_t name_len)
|
492 |
|
|
{
|
493 |
|
|
static long *long_ret;
|
494 |
|
|
int size;
|
495 |
|
|
|
496 |
|
|
|
497 |
|
|
switch ( action ) {
|
498 |
|
|
case RESERVE1:
|
499 |
|
|
if (var_val_type != ASN_INTEGER){
|
500 |
|
|
fprintf(stderr, "write to ifAdminStatus not ASN_INTEGER\n");
|
501 |
|
|
return SNMP_ERR_WRONGTYPE;
|
502 |
|
|
}
|
503 |
|
|
if (var_val_len > sizeof(long_ret)){
|
504 |
|
|
fprintf(stderr,"write to ifAdminStatus: bad length\n");
|
505 |
|
|
return SNMP_ERR_WRONGLENGTH;
|
506 |
|
|
}
|
507 |
|
|
break;
|
508 |
|
|
|
509 |
|
|
|
510 |
|
|
case RESERVE2:
|
511 |
|
|
size = var_val_len;
|
512 |
|
|
long_ret = (long *) var_val;
|
513 |
|
|
|
514 |
|
|
|
515 |
|
|
break;
|
516 |
|
|
|
517 |
|
|
|
518 |
|
|
case FREE:
|
519 |
|
|
/* Release any resources that have been allocated */
|
520 |
|
|
break;
|
521 |
|
|
|
522 |
|
|
|
523 |
|
|
case ACTION:
|
524 |
|
|
/* The variable has been stored in long_ret for you to use,
|
525 |
|
|
and you have just been asked to do something with it. Note
|
526 |
|
|
that anything done here must be reversable in the UNDO case */
|
527 |
|
|
break;
|
528 |
|
|
|
529 |
|
|
|
530 |
|
|
case UNDO:
|
531 |
|
|
/* Back out any changes made in the ACTION case */
|
532 |
|
|
break;
|
533 |
|
|
|
534 |
|
|
|
535 |
|
|
case COMMIT:
|
536 |
|
|
/* Things are working well, so it's now safe to make the change
|
537 |
|
|
permanently. Make sure that anything done here can't fail! */
|
538 |
|
|
break;
|
539 |
|
|
}
|
540 |
|
|
return SNMP_ERR_NOERROR;
|
541 |
|
|
}
|
542 |
|
|
|
543 |
|
|
#endif
|
544 |
|
|
|
545 |
|
|
// EOF interfaces.c
|