1 |
27 |
unneback |
//==========================================================================
|
2 |
|
|
//
|
3 |
|
|
// snmp/snmpagent/current/src/mibgroup/mibII/dot3.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/dot3.h"
|
104 |
|
|
#include "mibgroup/mibII/ifr_helper.h"
|
105 |
|
|
|
106 |
|
|
#include <net/if_types.h>
|
107 |
|
|
#include <net/if.h>
|
108 |
|
|
#ifdef CYGPKG_NET_FREEBSD_STACK
|
109 |
|
|
#include <net/if_var.h>
|
110 |
|
|
#endif
|
111 |
|
|
|
112 |
|
|
// Get info about the device
|
113 |
|
|
#include <pkgconf/system.h>
|
114 |
|
|
|
115 |
|
|
// These two two acquire all the statistics.
|
116 |
|
|
#include <cyg/io/eth/eth_drv_stats.h>
|
117 |
|
|
#include <sys/sockio.h>
|
118 |
|
|
|
119 |
|
|
/*
|
120 |
|
|
* dot3_variables_oid:
|
121 |
|
|
* this is the top level oid that we want to register under. This
|
122 |
|
|
* is essentially a prefix, with the suffix appearing in the
|
123 |
|
|
* variable below.
|
124 |
|
|
*/
|
125 |
|
|
|
126 |
|
|
oid dot3_variables_oid[] = { 1,3,6,1,2,1,10,7 };
|
127 |
|
|
|
128 |
|
|
|
129 |
|
|
extern struct ifnet_head ifnet;
|
130 |
|
|
|
131 |
|
|
|
132 |
|
|
/*
|
133 |
|
|
* variable4 dot3_variables:
|
134 |
|
|
* this variable defines function callbacks and type return information
|
135 |
|
|
* for the dot3 mib section
|
136 |
|
|
*/
|
137 |
|
|
struct variable4 dot3_variables[] = {
|
138 |
|
|
/* magic number , variable type , ro/rw , callback fn , L, oidsuffix */
|
139 |
|
|
#define DOT3STATSINDEX 3
|
140 |
|
|
{ DOT3STATSINDEX , ASN_INTEGER , RONLY , var_dot3StatsTable, 3, { 2,1,1 } },
|
141 |
|
|
#define DOT3STATSALIGNMENTERRORS 4
|
142 |
|
|
{ DOT3STATSALIGNMENTERRORS, ASN_COUNTER , RONLY , var_dot3StatsTable, 3, { 2,1,2 } },
|
143 |
|
|
#define DOT3STATSFCSERRORS 5
|
144 |
|
|
{ DOT3STATSFCSERRORS , ASN_COUNTER , RONLY , var_dot3StatsTable, 3, { 2,1,3 } },
|
145 |
|
|
#define DOT3STATSSINGLECOLLISIONFRAMES 6
|
146 |
|
|
{ DOT3STATSSINGLECOLLISIONFRAMES, ASN_COUNTER , RONLY , var_dot3StatsTable, 3, { 2,1,4 } },
|
147 |
|
|
#define DOT3STATSMULTIPLECOLLISIONFRAMES 7
|
148 |
|
|
{ DOT3STATSMULTIPLECOLLISIONFRAMES, ASN_COUNTER , RONLY , var_dot3StatsTable, 3, { 2,1,5 } },
|
149 |
|
|
#define DOT3STATSSQETESTERRORS 8
|
150 |
|
|
{ DOT3STATSSQETESTERRORS, ASN_COUNTER , RONLY , var_dot3StatsTable, 3, { 2,1,6 } },
|
151 |
|
|
#define DOT3STATSDEFERREDTRANSMISSIONS 9
|
152 |
|
|
{ DOT3STATSDEFERREDTRANSMISSIONS, ASN_COUNTER , RONLY , var_dot3StatsTable, 3, { 2,1,7 } },
|
153 |
|
|
#define DOT3STATSLATECOLLISIONS 10
|
154 |
|
|
{ DOT3STATSLATECOLLISIONS, ASN_COUNTER , RONLY , var_dot3StatsTable, 3, { 2,1,8 } },
|
155 |
|
|
#define DOT3STATSEXCESSIVECOLLISIONS 11
|
156 |
|
|
{ DOT3STATSEXCESSIVECOLLISIONS, ASN_COUNTER , RONLY , var_dot3StatsTable, 3, { 2,1,9 } },
|
157 |
|
|
#define DOT3STATSINTERNALMACTRANSMITERRORS 12
|
158 |
|
|
{ DOT3STATSINTERNALMACTRANSMITERRORS, ASN_COUNTER , RONLY , var_dot3StatsTable, 3, { 2,1,10 } },
|
159 |
|
|
#define DOT3STATSCARRIERSENSEERRORS 13
|
160 |
|
|
{ DOT3STATSCARRIERSENSEERRORS, ASN_COUNTER , RONLY , var_dot3StatsTable, 3, { 2,1,11 } },
|
161 |
|
|
#define DOT3STATSFRAMETOOLONGS 14
|
162 |
|
|
{ DOT3STATSFRAMETOOLONGS, ASN_COUNTER , RONLY , var_dot3StatsTable, 3, { 2,1,13 } },
|
163 |
|
|
#define DOT3STATSINTERNALMACRECEIVEERRORS 15
|
164 |
|
|
{ DOT3STATSINTERNALMACRECEIVEERRORS, ASN_COUNTER , RONLY , var_dot3StatsTable, 3, { 2,1,16 } },
|
165 |
|
|
#define DOT3STATSETHERCHIPSET 16
|
166 |
|
|
{ DOT3STATSETHERCHIPSET, ASN_OBJECT_ID , RONLY , var_dot3StatsTable, 3, { 2,1,17 } },
|
167 |
|
|
#define DOT3STATSSYMBOLERRORS 17
|
168 |
|
|
{ DOT3STATSSYMBOLERRORS, ASN_COUNTER , RONLY , var_dot3StatsTable, 3, { 2,1,18 } },
|
169 |
|
|
#define DOT3STATSDUPLEXSTATUS 18
|
170 |
|
|
{ DOT3STATSDUPLEXSTATUS, ASN_INTEGER , RONLY , var_dot3StatsTable, 3, { 2,1,19 } },
|
171 |
|
|
|
172 |
|
|
// We do not have this histogram available:
|
173 |
|
|
//#define DOT3COLLFREQUENCIES 22
|
174 |
|
|
// { DOT3COLLFREQUENCIES , ASN_COUNTER , RONLY , var_dot3CollTable, 3, { 5,1,3 } },
|
175 |
|
|
|
176 |
|
|
//UNSUPPORTED: currently we do not get these statistics out
|
177 |
|
|
//#define DOT3CONTROLFUNCTIONSSUPPORTED 25
|
178 |
|
|
// { DOT3CONTROLFUNCTIONSSUPPORTED, ASN_BIT_STR , RONLY , var_dot3ControlTable, 3, { 9,1,1 } },
|
179 |
|
|
//#define DOT3CONTROLINUNKNOWNOPCODES 26
|
180 |
|
|
// { DOT3CONTROLINUNKNOWNOPCODES, ASN_COUNTER , RONLY , var_dot3ControlTable, 3, { 9,1,2 } },
|
181 |
|
|
|
182 |
|
|
|
183 |
|
|
//UNSUPPORTED: currently we do not get these statistics out
|
184 |
|
|
//#define DOT3PAUSEADMINMODE 29
|
185 |
|
|
// { DOT3PAUSEADMINMODE , ASN_INTEGER , RWRITE, var_dot3PauseTable, 3, { 10,1,1 } },
|
186 |
|
|
//#define DOT3PAUSEOPERMODE 30
|
187 |
|
|
// { DOT3PAUSEOPERMODE , ASN_INTEGER , RONLY , var_dot3PauseTable, 3, { 10,1,2 } },
|
188 |
|
|
//#define DOT3INPAUSEFRAMES 31
|
189 |
|
|
// { DOT3INPAUSEFRAMES , ASN_COUNTER , RONLY , var_dot3PauseTable, 3, { 10,1,3 } },
|
190 |
|
|
//#define DOT3OUTPAUSEFRAMES 32
|
191 |
|
|
// { DOT3OUTPAUSEFRAMES , ASN_COUNTER , RONLY , var_dot3PauseTable, 3, { 10,1,4 } },
|
192 |
|
|
|
193 |
|
|
};
|
194 |
|
|
/* (L = length of the oidsuffix) */
|
195 |
|
|
|
196 |
|
|
|
197 |
|
|
/*
|
198 |
|
|
* init_dot3():
|
199 |
|
|
* Initialization routine. This is called when the agent starts up.
|
200 |
|
|
* At a minimum, registration of your variables should take place here.
|
201 |
|
|
*/
|
202 |
|
|
void init_dot3(void)
|
203 |
|
|
{
|
204 |
|
|
/* register ourselves with the agent to handle our mib tree */
|
205 |
|
|
REGISTER_MIB("dot3", dot3_variables, variable4,
|
206 |
|
|
dot3_variables_oid);
|
207 |
|
|
|
208 |
|
|
/* place any other initialization junk you need here */
|
209 |
|
|
}
|
210 |
|
|
|
211 |
|
|
|
212 |
|
|
/*
|
213 |
|
|
* var_dot3StatsTable():
|
214 |
|
|
* Handle this table separately from the scalar value case.
|
215 |
|
|
* The workings of this are basically the same as for var_dot3StatsTable above.
|
216 |
|
|
*/
|
217 |
|
|
unsigned char *
|
218 |
|
|
var_dot3StatsTable(struct variable *vp,
|
219 |
|
|
oid *name,
|
220 |
|
|
size_t *length,
|
221 |
|
|
int exact,
|
222 |
|
|
size_t *var_len,
|
223 |
|
|
WriteMethod **write_method)
|
224 |
|
|
{
|
225 |
|
|
static long long_ret;
|
226 |
|
|
static oid nullobjid[] = { 0,0 };
|
227 |
|
|
static oid etherobjid[ SNMP_CHIPSET_LEN ];
|
228 |
|
|
|
229 |
|
|
register struct ifnet *ifp;
|
230 |
|
|
int interface_count = 0;
|
231 |
|
|
int supports_dot3 = 0, i;
|
232 |
|
|
struct ether_drv_stats x;
|
233 |
|
|
|
234 |
|
|
interface_count = cyg_snmp_num_interfaces();
|
235 |
|
|
|
236 |
|
|
if ( header_simple_table( vp,name,length,exact,var_len,write_method,
|
237 |
|
|
interface_count)
|
238 |
|
|
== MATCH_FAILED )
|
239 |
|
|
return NULL;
|
240 |
|
|
|
241 |
|
|
ifp = cyg_snmp_get_if(name[ (*length)-1 ]);
|
242 |
|
|
|
243 |
|
|
if ( ! ifp )
|
244 |
|
|
return NULL;
|
245 |
|
|
|
246 |
|
|
/* If its an ethernet call the IOCTL and see if the device supports
|
247 |
|
|
dot3. If it does it will return all the values needed */
|
248 |
|
|
if ( IFT_ETHER == ifp->if_type ) {
|
249 |
|
|
bzero( &x, sizeof( x ) );
|
250 |
|
|
if ( NULL != ifp->if_ioctl ) {
|
251 |
|
|
if (!(*ifp->if_ioctl)(ifp, SIOCGIFSTATSUD, (caddr_t)&x)) {
|
252 |
|
|
supports_dot3 = x.supports_dot3;
|
253 |
|
|
}
|
254 |
|
|
}
|
255 |
|
|
}
|
256 |
|
|
|
257 |
|
|
if ( (IFT_LOOP == ifp->if_type ) ||
|
258 |
|
|
(IFT_PROPVIRTUAL == ifp->if_type ) ||
|
259 |
|
|
(!supports_dot3)) {
|
260 |
|
|
switch(vp->magic) {
|
261 |
|
|
case DOT3STATSINDEX:
|
262 |
|
|
long_ret = name[(*length)-1];
|
263 |
|
|
return (unsigned char *) &long_ret;
|
264 |
|
|
|
265 |
|
|
case DOT3STATSETHERCHIPSET:
|
266 |
|
|
*var_len = sizeof(nullobjid);
|
267 |
|
|
return (unsigned char *) nullobjid;
|
268 |
|
|
|
269 |
|
|
case DOT3STATSDUPLEXSTATUS:
|
270 |
|
|
long_ret = 1;
|
271 |
|
|
return (unsigned char *) &long_ret;
|
272 |
|
|
|
273 |
|
|
default:
|
274 |
|
|
long_ret = 0; // a dummy value for most of them
|
275 |
|
|
return (unsigned char *) &long_ret;
|
276 |
|
|
}
|
277 |
|
|
}
|
278 |
|
|
|
279 |
|
|
/* If we got here, the device does support dot3 */
|
280 |
|
|
switch(vp->magic) {
|
281 |
|
|
case DOT3STATSINDEX:
|
282 |
|
|
long_ret = name[(*length)-1];
|
283 |
|
|
return (unsigned char *) &long_ret;
|
284 |
|
|
|
285 |
|
|
case DOT3STATSALIGNMENTERRORS:
|
286 |
|
|
long_ret = x.rx_align_errors;
|
287 |
|
|
return (unsigned char *) &long_ret;
|
288 |
|
|
|
289 |
|
|
case DOT3STATSFCSERRORS:
|
290 |
|
|
long_ret = x.rx_crc_errors;
|
291 |
|
|
return (unsigned char *) &long_ret;
|
292 |
|
|
|
293 |
|
|
case DOT3STATSSINGLECOLLISIONFRAMES:
|
294 |
|
|
long_ret = x.tx_single_collisions;
|
295 |
|
|
return (unsigned char *) &long_ret;
|
296 |
|
|
|
297 |
|
|
case DOT3STATSMULTIPLECOLLISIONFRAMES:
|
298 |
|
|
long_ret = x.tx_mult_collisions;
|
299 |
|
|
return (unsigned char *) &long_ret;
|
300 |
|
|
|
301 |
|
|
case DOT3STATSSQETESTERRORS:
|
302 |
|
|
long_ret = x.tx_sqetesterrors;
|
303 |
|
|
return (unsigned char *) &long_ret;
|
304 |
|
|
|
305 |
|
|
case DOT3STATSDEFERREDTRANSMISSIONS:
|
306 |
|
|
long_ret = x.tx_deferred;
|
307 |
|
|
return (unsigned char *) &long_ret;
|
308 |
|
|
|
309 |
|
|
case DOT3STATSLATECOLLISIONS:
|
310 |
|
|
long_ret = x.tx_late_collisions;
|
311 |
|
|
return (unsigned char *) &long_ret;
|
312 |
|
|
|
313 |
|
|
case DOT3STATSEXCESSIVECOLLISIONS:
|
314 |
|
|
long_ret = x.tx_max_collisions;
|
315 |
|
|
return (unsigned char *) &long_ret;
|
316 |
|
|
|
317 |
|
|
case DOT3STATSINTERNALMACTRANSMITERRORS:
|
318 |
|
|
long_ret = x.tx_underrun;
|
319 |
|
|
return (unsigned char *) &long_ret;
|
320 |
|
|
|
321 |
|
|
case DOT3STATSCARRIERSENSEERRORS:
|
322 |
|
|
long_ret = x.tx_carrier_loss;
|
323 |
|
|
return (unsigned char *) &long_ret;
|
324 |
|
|
|
325 |
|
|
case DOT3STATSFRAMETOOLONGS:
|
326 |
|
|
long_ret = x.rx_too_long_frames;
|
327 |
|
|
return (unsigned char *) &long_ret;
|
328 |
|
|
|
329 |
|
|
case DOT3STATSINTERNALMACRECEIVEERRORS:
|
330 |
|
|
long_ret = x.rx_overrun_errors +
|
331 |
|
|
x.rx_resource_errors;
|
332 |
|
|
return (unsigned char *) &long_ret;
|
333 |
|
|
|
334 |
|
|
case DOT3STATSSYMBOLERRORS:
|
335 |
|
|
long_ret = x.rx_symbol_errors;
|
336 |
|
|
return (unsigned char *) &long_ret;
|
337 |
|
|
|
338 |
|
|
case DOT3STATSETHERCHIPSET:
|
339 |
|
|
i = 0;
|
340 |
|
|
while ( i < sizeof(etherobjid) ) {
|
341 |
|
|
if ( 0 == (etherobjid[i] = x.snmp_chipset[i]) )
|
342 |
|
|
break;
|
343 |
|
|
i++;
|
344 |
|
|
}
|
345 |
|
|
*var_len = i;
|
346 |
|
|
return (unsigned char *) etherobjid;
|
347 |
|
|
|
348 |
|
|
case DOT3STATSDUPLEXSTATUS:
|
349 |
|
|
long_ret = x.duplex;
|
350 |
|
|
if ( 1 > long_ret || 3 < long_ret )
|
351 |
|
|
long_ret = 1;
|
352 |
|
|
return (unsigned char *) &long_ret;
|
353 |
|
|
|
354 |
|
|
default:
|
355 |
|
|
ERROR_MSG("");
|
356 |
|
|
return NULL;
|
357 |
|
|
}
|
358 |
|
|
}
|
359 |
|
|
|
360 |
|
|
|
361 |
|
|
#if 0 // UNSUPPORTED: we do not have the information for these tables.
|
362 |
|
|
/*
|
363 |
|
|
* var_dot3ControlTable():
|
364 |
|
|
* Handle this table separately from the scalar value case.
|
365 |
|
|
* The workings of this are basically the same as for var_dot3ControlTable above.
|
366 |
|
|
*/
|
367 |
|
|
unsigned char *
|
368 |
|
|
var_dot3ControlTable(struct variable *vp,
|
369 |
|
|
oid *name,
|
370 |
|
|
size_t *length,
|
371 |
|
|
int exact,
|
372 |
|
|
size_t *var_len,
|
373 |
|
|
WriteMethod **write_method)
|
374 |
|
|
{
|
375 |
|
|
/* variables we may use later */
|
376 |
|
|
static long long_ret;
|
377 |
|
|
static unsigned char string[SPRINT_MAX_LEN];
|
378 |
|
|
static oid objid[MAX_OID_LEN];
|
379 |
|
|
static struct counter64 c64;
|
380 |
|
|
if (header_simple_table(vp,name,length,exact,var_len,write_method, TABLE_SIZE)
|
381 |
|
|
== MATCH_FAILED )
|
382 |
|
|
return NULL;
|
383 |
|
|
|
384 |
|
|
switch(vp->magic) {
|
385 |
|
|
case DOT3CONTROLFUNCTIONSSUPPORTED:
|
386 |
|
|
long_ret = 1;
|
387 |
|
|
return &long_ret;
|
388 |
|
|
|
389 |
|
|
case DOT3CONTROLINUNKNOWNOPCODES:
|
390 |
|
|
long_ret = 0;
|
391 |
|
|
return (unsigned char *) &long_ret;
|
392 |
|
|
|
393 |
|
|
default:
|
394 |
|
|
ERROR_MSG("");
|
395 |
|
|
}
|
396 |
|
|
return NULL;
|
397 |
|
|
}
|
398 |
|
|
|
399 |
|
|
/*
|
400 |
|
|
* var_dot3PauseTable():
|
401 |
|
|
* Handle this table separately from the scalar value case.
|
402 |
|
|
* The workings of this are basically the same as for var_dot3PauseTable above.
|
403 |
|
|
*/
|
404 |
|
|
unsigned char *
|
405 |
|
|
var_dot3PauseTable(struct variable *vp,
|
406 |
|
|
oid *name,
|
407 |
|
|
size_t *length,
|
408 |
|
|
int exact,
|
409 |
|
|
size_t *var_len,
|
410 |
|
|
WriteMethod **write_method)
|
411 |
|
|
{
|
412 |
|
|
/* variables we may use later */
|
413 |
|
|
static long long_ret;
|
414 |
|
|
static unsigned char string[SPRINT_MAX_LEN];
|
415 |
|
|
static oid objid[MAX_OID_LEN];
|
416 |
|
|
static struct counter64 c64;
|
417 |
|
|
|
418 |
|
|
if (header_simple_table(vp,name,length,exact,var_len,write_method, TABLE_SIZE)
|
419 |
|
|
== MATCH_FAILED )
|
420 |
|
|
return NULL;
|
421 |
|
|
|
422 |
|
|
switch(vp->magic) {
|
423 |
|
|
case DOT3PAUSEADMINMODE:
|
424 |
|
|
*write_method = write_dot3PauseAdminMode;
|
425 |
|
|
long_ret = 0;
|
426 |
|
|
return (unsigned char *) &long_ret;
|
427 |
|
|
|
428 |
|
|
case DOT3PAUSEOPERMODE:
|
429 |
|
|
long_ret = 0;
|
430 |
|
|
return (unsigned char *) &long_ret;
|
431 |
|
|
|
432 |
|
|
case DOT3INPAUSEFRAMES:
|
433 |
|
|
long_ret = 0;
|
434 |
|
|
return (unsigned char *) &long_ret;
|
435 |
|
|
|
436 |
|
|
case DOT3OUTPAUSEFRAMES:
|
437 |
|
|
long_ret = 0;
|
438 |
|
|
return (unsigned char *) &long_ret;
|
439 |
|
|
|
440 |
|
|
default:
|
441 |
|
|
ERROR_MSG("");
|
442 |
|
|
}
|
443 |
|
|
return NULL;
|
444 |
|
|
}
|
445 |
|
|
|
446 |
|
|
|
447 |
|
|
int
|
448 |
|
|
write_dot3PauseAdminMode(int action,
|
449 |
|
|
u_char *var_val,
|
450 |
|
|
u_char var_val_type,
|
451 |
|
|
size_t var_val_len,
|
452 |
|
|
u_char *statP,
|
453 |
|
|
oid *name,
|
454 |
|
|
size_t name_len)
|
455 |
|
|
{
|
456 |
|
|
static long *long_ret;
|
457 |
|
|
int size;
|
458 |
|
|
|
459 |
|
|
switch ( action ) {
|
460 |
|
|
case RESERVE1:
|
461 |
|
|
if (var_val_type != ASN_INTEGER){
|
462 |
|
|
fprintf(stderr, "write to dot3PauseAdminMode not ASN_INTEGER\n");
|
463 |
|
|
return SNMP_ERR_WRONGTYPE;
|
464 |
|
|
}
|
465 |
|
|
if (var_val_len > sizeof(long_ret)){
|
466 |
|
|
fprintf(stderr,"write to dot3PauseAdminMode: bad length\n");
|
467 |
|
|
return SNMP_ERR_WRONGLENGTH;
|
468 |
|
|
}
|
469 |
|
|
break;
|
470 |
|
|
|
471 |
|
|
case RESERVE2:
|
472 |
|
|
size = var_val_len;
|
473 |
|
|
long_ret = (long *) var_val;
|
474 |
|
|
break;
|
475 |
|
|
|
476 |
|
|
case FREE:
|
477 |
|
|
/* Release any resources that have been allocated */
|
478 |
|
|
break;
|
479 |
|
|
|
480 |
|
|
case ACTION:
|
481 |
|
|
/* The variable has been stored in long_ret for
|
482 |
|
|
you to use, and you have just been asked to do something with
|
483 |
|
|
it. Note that anything done here must be reversable in the UNDO case */
|
484 |
|
|
break;
|
485 |
|
|
|
486 |
|
|
case UNDO:
|
487 |
|
|
/* Back out any changes made in the ACTION case */
|
488 |
|
|
break;
|
489 |
|
|
|
490 |
|
|
case COMMIT:
|
491 |
|
|
/* Things are working well, so it's now safe to make the change
|
492 |
|
|
permanently. Make sure that anything done here can't fail! */
|
493 |
|
|
break;
|
494 |
|
|
}
|
495 |
|
|
return SNMP_ERR_NOERROR;
|
496 |
|
|
}
|
497 |
|
|
#endif // UNSUPPORTED
|
498 |
|
|
|
499 |
|
|
// EOF dot3.c
|