1 |
27 |
unneback |
//==========================================================================
|
2 |
|
|
//
|
3 |
|
|
// snmp/snmpagent/current/src/mibgroup/mibII/ip.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 <sys/param.h>
|
96 |
|
|
#include <sys/param.h>
|
97 |
|
|
#include <sys/socket.h>
|
98 |
|
|
#include <sys/time.h>
|
99 |
|
|
#include <net/if.h>
|
100 |
|
|
#ifdef CYGPKG_NET_FREEBSD_STACK
|
101 |
|
|
#include <net/if_var.h>
|
102 |
|
|
#endif
|
103 |
|
|
#include <netinet/in.h>
|
104 |
|
|
#include <netinet/if_ether.h>
|
105 |
|
|
#include <net/if_arp.h>
|
106 |
|
|
#include <netinet/in_var.h>
|
107 |
|
|
#include <netinet/ip_var.h>
|
108 |
|
|
|
109 |
|
|
/* This should always be included first before anything else */
|
110 |
|
|
#include <config.h>
|
111 |
|
|
|
112 |
|
|
/* minimal include directives */
|
113 |
|
|
#include "mibincl.h"
|
114 |
|
|
#include "mibgroup/util_funcs.h"
|
115 |
|
|
#include "mibgroup/mibII/ip.h"
|
116 |
|
|
|
117 |
|
|
#include <cyg/io/eth/eth_drv.h>
|
118 |
|
|
|
119 |
|
|
extern struct in_ifaddrhead in_ifaddr;
|
120 |
|
|
|
121 |
|
|
/*
|
122 |
|
|
* ip_variables_oid:
|
123 |
|
|
* this is the top level oid that we want to register under. This
|
124 |
|
|
* is essentially a prefix, with the suffix appearing in the
|
125 |
|
|
* variable below.
|
126 |
|
|
*/
|
127 |
|
|
|
128 |
|
|
|
129 |
|
|
oid ip_variables_oid[] = { 1,3,6,1,2,1,4 };
|
130 |
|
|
|
131 |
|
|
/*
|
132 |
|
|
* variable4 ip_variables:
|
133 |
|
|
* this variable defines function callbacks and type return information
|
134 |
|
|
* for the ip mib section
|
135 |
|
|
*/
|
136 |
|
|
|
137 |
|
|
struct variable4 ip_variables[] = {
|
138 |
|
|
/* magic number , variable type , ro/rw , callback fn , L, oidsuffix */
|
139 |
|
|
#define IPFORWARDING 1
|
140 |
|
|
{ IPFORWARDING , ASN_INTEGER , RWRITE, var_ip, 1, { 1 } },
|
141 |
|
|
#define IPDEFAULTTTL 2
|
142 |
|
|
{ IPDEFAULTTTL , ASN_INTEGER , RWRITE, var_ip, 1, { 2 } },
|
143 |
|
|
#define IPINRECEIVES 3
|
144 |
|
|
{ IPINRECEIVES , ASN_COUNTER , RONLY , var_ip, 1, { 3 } },
|
145 |
|
|
#define IPINHDRERRORS 4
|
146 |
|
|
{ IPINHDRERRORS , ASN_COUNTER , RONLY , var_ip, 1, { 4 } },
|
147 |
|
|
#define IPINADDRERRORS 5
|
148 |
|
|
{ IPINADDRERRORS , ASN_COUNTER , RONLY , var_ip, 1, { 5 } },
|
149 |
|
|
#define IPFORWDATAGRAMS 6
|
150 |
|
|
{ IPFORWDATAGRAMS , ASN_COUNTER , RONLY , var_ip, 1, { 6 } },
|
151 |
|
|
#define IPINUNKNOWNPROTOS 7
|
152 |
|
|
{ IPINUNKNOWNPROTOS , ASN_COUNTER , RONLY , var_ip, 1, { 7 } },
|
153 |
|
|
#define IPINDISCARDS 8
|
154 |
|
|
{ IPINDISCARDS , ASN_COUNTER , RONLY , var_ip, 1, { 8 } },
|
155 |
|
|
#define IPINDELIVERS 9
|
156 |
|
|
{ IPINDELIVERS , ASN_COUNTER , RONLY , var_ip, 1, { 9 } },
|
157 |
|
|
#define IPOUTREQUESTS 10
|
158 |
|
|
{ IPOUTREQUESTS , ASN_COUNTER , RONLY , var_ip, 1, { 10 } },
|
159 |
|
|
#define IPOUTDISCARDS 11
|
160 |
|
|
{ IPOUTDISCARDS , ASN_COUNTER , RONLY , var_ip, 1, { 11 } },
|
161 |
|
|
#define IPOUTNOROUTES 12
|
162 |
|
|
{ IPOUTNOROUTES , ASN_COUNTER , RONLY , var_ip, 1, { 12 } },
|
163 |
|
|
#define IPREASMTIMEOUT 13
|
164 |
|
|
{ IPREASMTIMEOUT , ASN_INTEGER , RONLY , var_ip, 1, { 13 } },
|
165 |
|
|
#define IPREASMREQDS 14
|
166 |
|
|
{ IPREASMREQDS , ASN_COUNTER , RONLY , var_ip, 1, { 14 } },
|
167 |
|
|
#define IPREASMOKS 15
|
168 |
|
|
{ IPREASMOKS , ASN_COUNTER , RONLY , var_ip, 1, { 15 } },
|
169 |
|
|
#define IPREASMFAILS 16
|
170 |
|
|
{ IPREASMFAILS , ASN_COUNTER , RONLY , var_ip, 1, { 16 } },
|
171 |
|
|
#define IPFRAGOKS 17
|
172 |
|
|
{ IPFRAGOKS , ASN_COUNTER , RONLY , var_ip, 1, { 17 } },
|
173 |
|
|
#define IPFRAGFAILS 18
|
174 |
|
|
{ IPFRAGFAILS , ASN_COUNTER , RONLY , var_ip, 1, { 18 } },
|
175 |
|
|
#define IPFRAGCREATES 19
|
176 |
|
|
{ IPFRAGCREATES , ASN_COUNTER , RONLY , var_ip, 1, { 19 } },
|
177 |
|
|
|
178 |
|
|
|
179 |
|
|
#define IPADENTADDR 22
|
180 |
|
|
{ IPADENTADDR , ASN_IPADDRESS , RONLY , var_ipAddrTable, 3, { 20,1,1 } },
|
181 |
|
|
#define IPADENTIFINDEX 23
|
182 |
|
|
{ IPADENTIFINDEX , ASN_INTEGER , RONLY , var_ipAddrTable, 3, { 20,1,2 } },
|
183 |
|
|
#define IPADENTNETMASK 24
|
184 |
|
|
{ IPADENTNETMASK , ASN_IPADDRESS , RONLY , var_ipAddrTable, 3, { 20,1,3 } },
|
185 |
|
|
#define IPADENTBCASTADDR 25
|
186 |
|
|
{ IPADENTBCASTADDR , ASN_INTEGER , RONLY , var_ipAddrTable, 3, { 20,1,4 } },
|
187 |
|
|
#define IPADENTREASMMAXSIZE 26
|
188 |
|
|
{ IPADENTREASMMAXSIZE , ASN_INTEGER , RONLY , var_ipAddrTable, 3, { 20,1,5 } },
|
189 |
|
|
|
190 |
|
|
// ROUTE TABLE is OBSOLETE according to my book
|
191 |
|
|
//#define IPROUTEDEST 29
|
192 |
|
|
// { IPROUTEDEST , ASN_IPADDRESS , RWRITE, var_ipRouteTable, 3, { 21,1,1 } },
|
193 |
|
|
//#define IPROUTEIFINDEX 30
|
194 |
|
|
// { IPROUTEIFINDEX , ASN_INTEGER , RWRITE, var_ipRouteTable, 3, { 21,1,2 } },
|
195 |
|
|
//#define IPROUTEMETRIC1 31
|
196 |
|
|
// { IPROUTEMETRIC1 , ASN_INTEGER , RWRITE, var_ipRouteTable, 3, { 21,1,3 } },
|
197 |
|
|
//#define IPROUTEMETRIC2 32
|
198 |
|
|
// { IPROUTEMETRIC2 , ASN_INTEGER , RWRITE, var_ipRouteTable, 3, { 21,1,4 } },
|
199 |
|
|
//#define IPROUTEMETRIC3 33
|
200 |
|
|
// { IPROUTEMETRIC3 , ASN_INTEGER , RWRITE, var_ipRouteTable, 3, { 21,1,5 } },
|
201 |
|
|
//#define IPROUTEMETRIC4 34
|
202 |
|
|
// { IPROUTEMETRIC4 , ASN_INTEGER , RWRITE, var_ipRouteTable, 3, { 21,1,6 } },
|
203 |
|
|
//#define IPROUTENEXTHOP 35
|
204 |
|
|
// { IPROUTENEXTHOP , ASN_IPADDRESS , RWRITE, var_ipRouteTable, 3, { 21,1,7 } },
|
205 |
|
|
//#define IPROUTETYPE 36
|
206 |
|
|
// { IPROUTETYPE , ASN_INTEGER , RWRITE, var_ipRouteTable, 3, { 21,1,8 } },
|
207 |
|
|
//#define IPROUTEPROTO 37
|
208 |
|
|
// { IPROUTEPROTO , ASN_INTEGER , RONLY , var_ipRouteTable, 3, { 21,1,9 } },
|
209 |
|
|
//#define IPROUTEAGE 38
|
210 |
|
|
// { IPROUTEAGE , ASN_INTEGER , RWRITE, var_ipRouteTable, 3, { 21,1,10 } },
|
211 |
|
|
//#define IPROUTEMASK 39
|
212 |
|
|
// { IPROUTEMASK , ASN_IPADDRESS , RWRITE, var_ipRouteTable, 3, { 21,1,11 } },
|
213 |
|
|
//#define IPROUTEMETRIC5 40
|
214 |
|
|
// { IPROUTEMETRIC5 , ASN_INTEGER , RWRITE, var_ipRouteTable, 3, { 21,1,12 } },
|
215 |
|
|
//#define IPROUTEINFO 41
|
216 |
|
|
// { IPROUTEINFO , ASN_OBJECT_ID , RONLY , var_ipRouteTable, 3, { 21,1,13 } },
|
217 |
|
|
|
218 |
|
|
#define IPNETTOMEDIAIFINDEX 44
|
219 |
|
|
{ IPNETTOMEDIAIFINDEX , ASN_INTEGER , RWRITE, var_ipNetToMediaTable, 3, { 22,1,1 } },
|
220 |
|
|
#define IPNETTOMEDIAPHYSADDRESS 45
|
221 |
|
|
{ IPNETTOMEDIAPHYSADDRESS, ASN_OCTET_STR, RWRITE, var_ipNetToMediaTable, 3, { 22,1,2 } },
|
222 |
|
|
#define IPNETTOMEDIANETADDRESS 46
|
223 |
|
|
{ IPNETTOMEDIANETADDRESS, ASN_IPADDRESS , RWRITE, var_ipNetToMediaTable, 3, { 22,1,3 } },
|
224 |
|
|
#define IPNETTOMEDIATYPE 47
|
225 |
|
|
{ IPNETTOMEDIATYPE , ASN_INTEGER , RWRITE, var_ipNetToMediaTable, 3, { 22,1,4 } },
|
226 |
|
|
|
227 |
|
|
#define IPROUTINGDISCARDS 48
|
228 |
|
|
{ IPROUTINGDISCARDS , ASN_COUNTER , RONLY , var_ip, 1, { 23 } },
|
229 |
|
|
|
230 |
|
|
};
|
231 |
|
|
/* (L = length of the oidsuffix) */
|
232 |
|
|
|
233 |
|
|
|
234 |
|
|
/*
|
235 |
|
|
* init_ip():
|
236 |
|
|
* Initialization routine. This is called when the agent starts up.
|
237 |
|
|
* At a minimum, registration of your variables should take place here.
|
238 |
|
|
*/
|
239 |
|
|
void init_ip(void) {
|
240 |
|
|
|
241 |
|
|
|
242 |
|
|
/* register ourselves with the agent to handle our mib tree */
|
243 |
|
|
REGISTER_MIB("ip", ip_variables, variable4,
|
244 |
|
|
ip_variables_oid);
|
245 |
|
|
|
246 |
|
|
|
247 |
|
|
/* place any other initialization junk you need here */
|
248 |
|
|
}
|
249 |
|
|
|
250 |
|
|
|
251 |
|
|
/*
|
252 |
|
|
* var_ip():
|
253 |
|
|
* This function is called every time the agent gets a request for
|
254 |
|
|
* a scalar variable that might be found within your mib section
|
255 |
|
|
* registered above. It is up to you to do the right thing and
|
256 |
|
|
* return the correct value.
|
257 |
|
|
* You should also correct the value of "var_len" if necessary.
|
258 |
|
|
*
|
259 |
|
|
* Please see the documentation for more information about writing
|
260 |
|
|
* module extensions, and check out the examples in the examples
|
261 |
|
|
* and mibII directories.
|
262 |
|
|
*/
|
263 |
|
|
unsigned char *
|
264 |
|
|
var_ip(struct variable *vp,
|
265 |
|
|
oid *name,
|
266 |
|
|
size_t *length,
|
267 |
|
|
int exact,
|
268 |
|
|
size_t *var_len,
|
269 |
|
|
WriteMethod **write_method)
|
270 |
|
|
{
|
271 |
|
|
|
272 |
|
|
|
273 |
|
|
/* variables we may use later */
|
274 |
|
|
static long long_ret;
|
275 |
|
|
|
276 |
|
|
if (header_generic(vp,name,length,exact,var_len,write_method)
|
277 |
|
|
== MATCH_FAILED )
|
278 |
|
|
return NULL;
|
279 |
|
|
|
280 |
|
|
switch(vp->magic) {
|
281 |
|
|
|
282 |
|
|
case IPFORWARDING:
|
283 |
|
|
*write_method = write_ipForwarding;
|
284 |
|
|
long_ret = ipforwarding ? 1 : 2;
|
285 |
|
|
return (unsigned char *) &long_ret;
|
286 |
|
|
|
287 |
|
|
case IPDEFAULTTTL:
|
288 |
|
|
*write_method = write_ipDefaultTTL;
|
289 |
|
|
long_ret = ip_defttl;
|
290 |
|
|
return (unsigned char *) &long_ret;
|
291 |
|
|
|
292 |
|
|
case IPINRECEIVES:
|
293 |
|
|
long_ret = ipstat.ips_total;
|
294 |
|
|
return (unsigned char *) &long_ret;
|
295 |
|
|
|
296 |
|
|
case IPINHDRERRORS:
|
297 |
|
|
long_ret = ipstat.ips_badsum
|
298 |
|
|
+ ipstat.ips_badhlen
|
299 |
|
|
+ ipstat.ips_badlen
|
300 |
|
|
+ ipstat.ips_badoptions
|
301 |
|
|
+ ipstat.ips_badvers
|
302 |
|
|
#ifdef CYGPKG_NET_OPENBSD_STACK
|
303 |
|
|
+ ipstat.ips_badfrags
|
304 |
|
|
#endif
|
305 |
|
|
+ ipstat.ips_toolong
|
306 |
|
|
;
|
307 |
|
|
return (unsigned char *) &long_ret;
|
308 |
|
|
|
309 |
|
|
case IPINADDRERRORS:
|
310 |
|
|
long_ret = ipstat.ips_cantforward;
|
311 |
|
|
return (unsigned char *) &long_ret;
|
312 |
|
|
|
313 |
|
|
case IPFORWDATAGRAMS:
|
314 |
|
|
long_ret = ipstat.ips_forward;
|
315 |
|
|
return (unsigned char *) &long_ret;
|
316 |
|
|
|
317 |
|
|
case IPINUNKNOWNPROTOS:
|
318 |
|
|
long_ret = ipstat.ips_noproto;
|
319 |
|
|
return (unsigned char *) &long_ret;
|
320 |
|
|
|
321 |
|
|
case IPINDISCARDS:
|
322 |
|
|
long_ret = ipstat.ips_total - ipstat.ips_delivered -
|
323 |
|
|
(
|
324 |
|
|
ipstat.ips_badsum
|
325 |
|
|
+ ipstat.ips_badhlen
|
326 |
|
|
+ ipstat.ips_badlen
|
327 |
|
|
+ ipstat.ips_badoptions
|
328 |
|
|
+ ipstat.ips_badvers
|
329 |
|
|
#ifdef CYGPKG_NET_OPENBSD_STACK
|
330 |
|
|
+ ipstat.ips_badfrags
|
331 |
|
|
#endif
|
332 |
|
|
+ ipstat.ips_toolong
|
333 |
|
|
) -
|
334 |
|
|
ipstat.ips_cantforward;
|
335 |
|
|
if ( 0 > long_ret )
|
336 |
|
|
long_ret = 0;
|
337 |
|
|
return (unsigned char *) &long_ret;
|
338 |
|
|
|
339 |
|
|
case IPINDELIVERS:
|
340 |
|
|
long_ret = ipstat.ips_delivered;
|
341 |
|
|
return (unsigned char *) &long_ret;
|
342 |
|
|
|
343 |
|
|
case IPOUTREQUESTS:
|
344 |
|
|
long_ret = ipstat.ips_localout;
|
345 |
|
|
return (unsigned char *) &long_ret;
|
346 |
|
|
|
347 |
|
|
case IPOUTDISCARDS:
|
348 |
|
|
long_ret = ipstat.ips_odropped;
|
349 |
|
|
return (unsigned char *) &long_ret;
|
350 |
|
|
|
351 |
|
|
case IPOUTNOROUTES:
|
352 |
|
|
long_ret = ipstat.ips_noroute;
|
353 |
|
|
return (unsigned char *) &long_ret;
|
354 |
|
|
|
355 |
|
|
case IPREASMTIMEOUT:
|
356 |
|
|
long_ret = 0; //FIXME
|
357 |
|
|
return (unsigned char *) &long_ret;
|
358 |
|
|
|
359 |
|
|
case IPREASMREQDS:
|
360 |
|
|
long_ret = ipstat.ips_fragments;
|
361 |
|
|
return (unsigned char *) &long_ret;
|
362 |
|
|
|
363 |
|
|
case IPREASMOKS:
|
364 |
|
|
long_ret = ipstat.ips_reassembled;
|
365 |
|
|
return (unsigned char *) &long_ret;
|
366 |
|
|
|
367 |
|
|
case IPREASMFAILS:
|
368 |
|
|
long_ret = ipstat.ips_fragments -
|
369 |
|
|
(ipstat.ips_fragdropped + ipstat.ips_fragtimeout);
|
370 |
|
|
return (unsigned char *) &long_ret;
|
371 |
|
|
|
372 |
|
|
case IPFRAGOKS:
|
373 |
|
|
long_ret = ipstat.ips_fragmented;
|
374 |
|
|
return (unsigned char *) &long_ret;
|
375 |
|
|
|
376 |
|
|
case IPFRAGFAILS:
|
377 |
|
|
long_ret = ipstat.ips_cantfrag;
|
378 |
|
|
return (unsigned char *) &long_ret;
|
379 |
|
|
|
380 |
|
|
case IPFRAGCREATES:
|
381 |
|
|
long_ret = ipstat.ips_ofragments;
|
382 |
|
|
return (unsigned char *) &long_ret;
|
383 |
|
|
|
384 |
|
|
case IPROUTINGDISCARDS:
|
385 |
|
|
long_ret = ipstat.ips_noroute;
|
386 |
|
|
return (unsigned char *) &long_ret;
|
387 |
|
|
|
388 |
|
|
default:
|
389 |
|
|
ERROR_MSG("");
|
390 |
|
|
}
|
391 |
|
|
return NULL;
|
392 |
|
|
}
|
393 |
|
|
|
394 |
|
|
|
395 |
|
|
/*
|
396 |
|
|
* var_ipAddrTable():
|
397 |
|
|
* Handle this table separately from the scalar value case.
|
398 |
|
|
* The workings of this are basically the same as for var_ipAddrTable above.
|
399 |
|
|
*/
|
400 |
|
|
unsigned char *
|
401 |
|
|
var_ipAddrTable(struct variable *vp,
|
402 |
|
|
oid *name,
|
403 |
|
|
size_t *length,
|
404 |
|
|
int exact,
|
405 |
|
|
size_t *var_len,
|
406 |
|
|
WriteMethod **write_method)
|
407 |
|
|
{
|
408 |
|
|
/*
|
409 |
|
|
* object identifier is of form:
|
410 |
|
|
* 1.3.6.1.2.1.4.20.1.?.A.B.C.D, where A.B.C.D is IP address.
|
411 |
|
|
* IPADDR starts at offset 10.
|
412 |
|
|
*/
|
413 |
|
|
oid lowest[14];
|
414 |
|
|
oid current[14], *op;
|
415 |
|
|
u_char *cp;
|
416 |
|
|
|
417 |
|
|
static long long_ret;
|
418 |
|
|
static unsigned char string[SPRINT_MAX_LEN];
|
419 |
|
|
|
420 |
|
|
register struct in_ifaddr *ia;
|
421 |
|
|
register struct in_ifaddr *low_ia = NULL;
|
422 |
|
|
|
423 |
|
|
register struct ifnet *ifp;
|
424 |
|
|
int interface_count = 1;
|
425 |
|
|
|
426 |
|
|
/* fill in object part of name for current (less sizeof instance part) */
|
427 |
|
|
memcpy( (char *)current,(char *)vp->name, (int)vp->namelen * sizeof(oid));
|
428 |
|
|
|
429 |
|
|
for (
|
430 |
|
|
#ifdef CYGPKG_NET_OPENBSD_STACK
|
431 |
|
|
ia = in_ifaddr.tqh_first; ia;
|
432 |
|
|
ia = ia->ia_list.tqe_next
|
433 |
|
|
#endif
|
434 |
|
|
#ifdef CYGPKG_NET_FREEBSD_STACK
|
435 |
|
|
ia = in_ifaddrhead.tqh_first; ia;
|
436 |
|
|
ia = ia->ia_link.tqe_next
|
437 |
|
|
#endif
|
438 |
|
|
) {
|
439 |
|
|
cp = (u_char *)&(ia->ia_addr.sin_addr.s_addr);
|
440 |
|
|
|
441 |
|
|
op = current + 10;
|
442 |
|
|
*op++ = *cp++;
|
443 |
|
|
*op++ = *cp++;
|
444 |
|
|
*op++ = *cp++;
|
445 |
|
|
*op++ = *cp++;
|
446 |
|
|
if (exact){
|
447 |
|
|
if (snmp_oid_compare(current, 14, name, *length) == 0) {
|
448 |
|
|
memcpy( (char *)lowest,(char *)current, 14 * sizeof(oid));
|
449 |
|
|
low_ia = ia;
|
450 |
|
|
break; /* no need to search further */
|
451 |
|
|
}
|
452 |
|
|
} else {
|
453 |
|
|
if ((snmp_oid_compare(current, 14, name, *length) > 0) &&
|
454 |
|
|
(!low_ia || (snmp_oid_compare(current, 14, lowest, 14) < 0))) {
|
455 |
|
|
/*
|
456 |
|
|
* if new one is greater than input and closer to input than
|
457 |
|
|
* previous lowest, save this one as the "next" one.
|
458 |
|
|
*/
|
459 |
|
|
memcpy( (char *)lowest,(char *)current, 14 * sizeof(oid));
|
460 |
|
|
low_ia = ia;
|
461 |
|
|
}
|
462 |
|
|
}
|
463 |
|
|
}
|
464 |
|
|
|
465 |
|
|
if ( ! low_ia )
|
466 |
|
|
return NULL;
|
467 |
|
|
|
468 |
|
|
memcpy( (char *)name,(char *)lowest, 14 * sizeof(oid));
|
469 |
|
|
*length = 14;
|
470 |
|
|
*write_method = 0;
|
471 |
|
|
*var_len = sizeof(long_return);
|
472 |
|
|
|
473 |
|
|
/*
|
474 |
|
|
* this is where we do the value assignments for the mib results.
|
475 |
|
|
*/
|
476 |
|
|
switch(vp->magic) {
|
477 |
|
|
|
478 |
|
|
case IPADENTADDR:
|
479 |
|
|
cp = (u_char *)&(low_ia->ia_addr.sin_addr.s_addr);
|
480 |
|
|
string[0] = *cp++;
|
481 |
|
|
string[1] = *cp++;
|
482 |
|
|
string[2] = *cp++;
|
483 |
|
|
string[3] = *cp++;
|
484 |
|
|
*var_len = 4;
|
485 |
|
|
return (unsigned char *) string;
|
486 |
|
|
|
487 |
|
|
case IPADENTIFINDEX:
|
488 |
|
|
ifp = ifnet.tqh_first;
|
489 |
|
|
while (ifp && ifp->if_index != low_ia->ia_ifa.ifa_ifp->if_index) {
|
490 |
|
|
interface_count++;
|
491 |
|
|
ifp = ifp->if_list.tqe_next;
|
492 |
|
|
}
|
493 |
|
|
if (!ifp) {
|
494 |
|
|
return NULL;
|
495 |
|
|
}
|
496 |
|
|
long_ret = interface_count;
|
497 |
|
|
return (unsigned char *) &long_ret;
|
498 |
|
|
|
499 |
|
|
case IPADENTNETMASK:
|
500 |
|
|
cp = (u_char *)&(low_ia->ia_subnetmask);
|
501 |
|
|
string[0] = *cp++;
|
502 |
|
|
string[1] = *cp++;
|
503 |
|
|
string[2] = *cp++;
|
504 |
|
|
string[3] = *cp++;
|
505 |
|
|
*var_len = 4;
|
506 |
|
|
return (unsigned char *) string;
|
507 |
|
|
|
508 |
|
|
case IPADENTBCASTADDR:
|
509 |
|
|
long_ret = 1;
|
510 |
|
|
return (unsigned char *) &long_ret;
|
511 |
|
|
|
512 |
|
|
case IPADENTREASMMAXSIZE:
|
513 |
|
|
long_ret = IP_MAXPACKET;
|
514 |
|
|
return (unsigned char *) &long_ret;
|
515 |
|
|
|
516 |
|
|
default:
|
517 |
|
|
ERROR_MSG("");
|
518 |
|
|
}
|
519 |
|
|
return NULL;
|
520 |
|
|
}
|
521 |
|
|
|
522 |
|
|
|
523 |
|
|
|
524 |
|
|
|
525 |
|
|
/*
|
526 |
|
|
* var_ipNetToMediaTable():
|
527 |
|
|
* Handle this table separately from the scalar value case.
|
528 |
|
|
* The workings of this are basically the same as for var_ip above.
|
529 |
|
|
*/
|
530 |
|
|
|
531 |
|
|
// According to sections 6.1.5 (ip) and 6.1.4 (at) pp.130-138 of the book
|
532 |
|
|
// by William Stallings, this lists *our* interfaces only, not the ARP
|
533 |
|
|
// table. The MIBs are rather ambiguous, as is Mark A. Miller's book also.
|
534 |
|
|
//
|
535 |
|
|
// Specifically, the indexing by interface Id suggests there should only be
|
536 |
|
|
// one entry per interface.
|
537 |
|
|
|
538 |
|
|
unsigned char *
|
539 |
|
|
var_ipNetToMediaTable(struct variable *vp,
|
540 |
|
|
oid *name,
|
541 |
|
|
size_t *length,
|
542 |
|
|
int exact,
|
543 |
|
|
size_t *var_len,
|
544 |
|
|
WriteMethod **write_method)
|
545 |
|
|
{
|
546 |
|
|
static long long_ret;
|
547 |
|
|
static unsigned char string[SPRINT_MAX_LEN];
|
548 |
|
|
/*
|
549 |
|
|
* IP Net to Media table object identifier is of form:
|
550 |
|
|
* 1.3.6.1.2.1.4.22.1.?.interface.A.B.C.D, where A.B.C.D is IP address.
|
551 |
|
|
* Interface is at offset 10,
|
552 |
|
|
* IPADDR starts at offset 11.
|
553 |
|
|
*/
|
554 |
|
|
u_char *cp;
|
555 |
|
|
oid *op;
|
556 |
|
|
oid lowest[16];
|
557 |
|
|
oid current[16];
|
558 |
|
|
|
559 |
|
|
register struct in_ifaddr *ia;
|
560 |
|
|
register struct in_ifaddr *low_ia = NULL;
|
561 |
|
|
|
562 |
|
|
/* fill in object part of name for current (less sizeof instance part) */
|
563 |
|
|
memcpy((char *)current, (char *)vp->name, (int)vp->namelen * sizeof(oid));
|
564 |
|
|
|
565 |
|
|
for (
|
566 |
|
|
#ifdef CYGPKG_NET_OPENBSD_STACK
|
567 |
|
|
ia = in_ifaddr.tqh_first; ia;
|
568 |
|
|
ia = ia->ia_list.tqe_next
|
569 |
|
|
#endif
|
570 |
|
|
#ifdef CYGPKG_NET_FREEBSD_STACK
|
571 |
|
|
ia = in_ifaddrhead.tqh_first; ia;
|
572 |
|
|
ia = ia->ia_link.tqe_next
|
573 |
|
|
#endif
|
574 |
|
|
) {
|
575 |
|
|
// interface number
|
576 |
|
|
current[10] = ia->ia_ifa.ifa_ifp->if_index;
|
577 |
|
|
// IP address
|
578 |
|
|
cp = (u_char *)&(ia->ia_addr.sin_addr.s_addr);
|
579 |
|
|
op = current + 11;
|
580 |
|
|
*op++ = *cp++;
|
581 |
|
|
*op++ = *cp++;
|
582 |
|
|
*op++ = *cp++;
|
583 |
|
|
*op++ = *cp++;
|
584 |
|
|
|
585 |
|
|
if (exact){
|
586 |
|
|
if (snmp_oid_compare(current, 15, name, *length) == 0){
|
587 |
|
|
memcpy( (char *)lowest,(char *)current, 15 * sizeof(oid));
|
588 |
|
|
low_ia = ia;
|
589 |
|
|
break; /* no need to search further */
|
590 |
|
|
}
|
591 |
|
|
} else {
|
592 |
|
|
if ((snmp_oid_compare(current, 15, name, *length) > 0) &&
|
593 |
|
|
((!low_ia) || (snmp_oid_compare(current, 15, lowest, 15) < 0))) {
|
594 |
|
|
/*
|
595 |
|
|
* if new one is greater than input and closer to input than
|
596 |
|
|
* previous lowest, save this one as the "next" one.
|
597 |
|
|
*/
|
598 |
|
|
memcpy( (char *)lowest,(char *)current, 15 * sizeof(oid));
|
599 |
|
|
low_ia = ia;
|
600 |
|
|
}
|
601 |
|
|
}
|
602 |
|
|
}
|
603 |
|
|
if ( ! low_ia )
|
604 |
|
|
return(NULL);
|
605 |
|
|
|
606 |
|
|
memcpy( (char *)name,(char *)lowest, 15 * sizeof(oid));
|
607 |
|
|
*length = 15;
|
608 |
|
|
*write_method = 0;
|
609 |
|
|
*var_len = sizeof(long_return);
|
610 |
|
|
|
611 |
|
|
/*
|
612 |
|
|
* this is where we do the value assignments for the mib results.
|
613 |
|
|
*/
|
614 |
|
|
switch(vp->magic) {
|
615 |
|
|
case IPNETTOMEDIAIFINDEX:
|
616 |
|
|
//NOTSUPPORTED: *write_method = write_ipNetToMediaIfIndex;
|
617 |
|
|
long_ret = low_ia->ia_ifa.ifa_ifp->if_index;
|
618 |
|
|
return (unsigned char *) &long_ret;
|
619 |
|
|
|
620 |
|
|
case IPNETTOMEDIAPHYSADDRESS: {
|
621 |
|
|
struct eth_drv_sc *sc = low_ia->ia_ifa.ifa_ifp->if_softc;
|
622 |
|
|
if (!sc) {
|
623 |
|
|
// No hardware associated with this device.
|
624 |
|
|
return(NULL);
|
625 |
|
|
}
|
626 |
|
|
bcopy(&sc->sc_arpcom.ac_enaddr, string, ETHER_ADDR_LEN);
|
627 |
|
|
*var_len = ETHER_ADDR_LEN;
|
628 |
|
|
//NOTSUPPORTED: *write_method = write_ipNetToMediaPhysAddress;
|
629 |
|
|
return (unsigned char *) string;
|
630 |
|
|
}
|
631 |
|
|
case IPNETTOMEDIANETADDRESS:
|
632 |
|
|
//NOTSUPPORTED: *write_method = write_ipNetToMediaNetAddress;
|
633 |
|
|
cp = (u_char *)&(low_ia->ia_addr.sin_addr.s_addr);
|
634 |
|
|
string[0] = *cp++;
|
635 |
|
|
string[1] = *cp++;
|
636 |
|
|
string[2] = *cp++;
|
637 |
|
|
string[3] = *cp++;
|
638 |
|
|
*var_len = 4;
|
639 |
|
|
return (unsigned char *) string;
|
640 |
|
|
|
641 |
|
|
case IPNETTOMEDIATYPE:
|
642 |
|
|
//NOTSUPPORTED: *write_method = write_ipNetToMediaType;
|
643 |
|
|
long_ret = 4; // Static mapping
|
644 |
|
|
return (unsigned char *) &long_ret;
|
645 |
|
|
|
646 |
|
|
default:
|
647 |
|
|
ERROR_MSG("");
|
648 |
|
|
}
|
649 |
|
|
return NULL;
|
650 |
|
|
}
|
651 |
|
|
|
652 |
|
|
|
653 |
|
|
|
654 |
|
|
|
655 |
|
|
int
|
656 |
|
|
write_ipForwarding(int action,
|
657 |
|
|
u_char *var_val,
|
658 |
|
|
u_char var_val_type,
|
659 |
|
|
size_t var_val_len,
|
660 |
|
|
u_char *statP,
|
661 |
|
|
oid *name,
|
662 |
|
|
size_t name_len)
|
663 |
|
|
{
|
664 |
|
|
static long setval;
|
665 |
|
|
|
666 |
|
|
switch ( action ) {
|
667 |
|
|
case RESERVE1:
|
668 |
|
|
if (var_val_type != ASN_INTEGER){
|
669 |
|
|
fprintf(stderr, "write to ipForwarding not ASN_INTEGER\n");
|
670 |
|
|
return SNMP_ERR_WRONGTYPE;
|
671 |
|
|
}
|
672 |
|
|
if (var_val_len > sizeof(setval)){
|
673 |
|
|
fprintf(stderr,"write to ipForwarding: bad length\n");
|
674 |
|
|
return SNMP_ERR_WRONGLENGTH;
|
675 |
|
|
}
|
676 |
|
|
setval = *(long *)var_val;
|
677 |
|
|
if ( 1 != setval && 2 != setval )
|
678 |
|
|
return SNMP_ERR_WRONGVALUE;
|
679 |
|
|
break;
|
680 |
|
|
|
681 |
|
|
case RESERVE2:
|
682 |
|
|
case FREE:
|
683 |
|
|
case ACTION:
|
684 |
|
|
case UNDO:
|
685 |
|
|
break;
|
686 |
|
|
|
687 |
|
|
case COMMIT:
|
688 |
|
|
ipforwarding = (setval == 1);
|
689 |
|
|
break;
|
690 |
|
|
}
|
691 |
|
|
return SNMP_ERR_NOERROR;
|
692 |
|
|
}
|
693 |
|
|
|
694 |
|
|
|
695 |
|
|
|
696 |
|
|
|
697 |
|
|
int
|
698 |
|
|
write_ipDefaultTTL(int action,
|
699 |
|
|
u_char *var_val,
|
700 |
|
|
u_char var_val_type,
|
701 |
|
|
size_t var_val_len,
|
702 |
|
|
u_char *statP,
|
703 |
|
|
oid *name,
|
704 |
|
|
size_t name_len)
|
705 |
|
|
{
|
706 |
|
|
static long setval;
|
707 |
|
|
|
708 |
|
|
switch ( action ) {
|
709 |
|
|
case RESERVE1:
|
710 |
|
|
if (var_val_type != ASN_INTEGER){
|
711 |
|
|
fprintf(stderr, "write to ipDefaultTTL not ASN_INTEGER\n");
|
712 |
|
|
return SNMP_ERR_WRONGTYPE;
|
713 |
|
|
}
|
714 |
|
|
if (var_val_len > sizeof(setval)){
|
715 |
|
|
fprintf(stderr,"write to ipDefaultTTL: bad length\n");
|
716 |
|
|
return SNMP_ERR_WRONGLENGTH;
|
717 |
|
|
}
|
718 |
|
|
setval = *(long *)var_val;
|
719 |
|
|
break;
|
720 |
|
|
|
721 |
|
|
case RESERVE2:
|
722 |
|
|
case FREE:
|
723 |
|
|
case ACTION:
|
724 |
|
|
case UNDO:
|
725 |
|
|
break;
|
726 |
|
|
|
727 |
|
|
case COMMIT:
|
728 |
|
|
ip_defttl = setval;
|
729 |
|
|
break;
|
730 |
|
|
}
|
731 |
|
|
return SNMP_ERR_NOERROR;
|
732 |
|
|
}
|
733 |
|
|
|
734 |
|
|
|
735 |
|
|
// ---------------------------------------------------------------------------
|
736 |
|
|
// writing these is not supported. The templates from mib2c are retained.
|
737 |
|
|
//
|
738 |
|
|
//NOTSUPPORTED:
|
739 |
|
|
#if 0
|
740 |
|
|
int
|
741 |
|
|
write_ipNetToMediaIfIndex(int action,
|
742 |
|
|
u_char *var_val,
|
743 |
|
|
u_char var_val_type,
|
744 |
|
|
size_t var_val_len,
|
745 |
|
|
u_char *statP,
|
746 |
|
|
oid *name,
|
747 |
|
|
size_t name_len)
|
748 |
|
|
{
|
749 |
|
|
static long *long_ret;
|
750 |
|
|
int size;
|
751 |
|
|
|
752 |
|
|
|
753 |
|
|
switch ( action ) {
|
754 |
|
|
case RESERVE1:
|
755 |
|
|
if (var_val_type != ASN_INTEGER){
|
756 |
|
|
fprintf(stderr, "write to ipNetToMediaIfIndex not ASN_INTEGER\n");
|
757 |
|
|
return SNMP_ERR_WRONGTYPE;
|
758 |
|
|
}
|
759 |
|
|
if (var_val_len > sizeof(long_ret)){
|
760 |
|
|
fprintf(stderr,"write to ipNetToMediaIfIndex: bad length\n");
|
761 |
|
|
return SNMP_ERR_WRONGLENGTH;
|
762 |
|
|
}
|
763 |
|
|
break;
|
764 |
|
|
|
765 |
|
|
|
766 |
|
|
case RESERVE2:
|
767 |
|
|
size = var_val_len;
|
768 |
|
|
long_ret = (long *) var_val;
|
769 |
|
|
|
770 |
|
|
|
771 |
|
|
break;
|
772 |
|
|
|
773 |
|
|
|
774 |
|
|
case FREE:
|
775 |
|
|
/* Release any resources that have been allocated */
|
776 |
|
|
break;
|
777 |
|
|
|
778 |
|
|
|
779 |
|
|
case ACTION:
|
780 |
|
|
/* The variable has been stored in long_ret for
|
781 |
|
|
you to use, and you have just been asked to do something with
|
782 |
|
|
it. Note that anything done here must be reversable in the UNDO case */
|
783 |
|
|
break;
|
784 |
|
|
|
785 |
|
|
|
786 |
|
|
case UNDO:
|
787 |
|
|
/* Back out any changes made in the ACTION case */
|
788 |
|
|
break;
|
789 |
|
|
|
790 |
|
|
|
791 |
|
|
case COMMIT:
|
792 |
|
|
/* Things are working well, so it's now safe to make the change
|
793 |
|
|
permanently. Make sure that anything done here can't fail! */
|
794 |
|
|
break;
|
795 |
|
|
}
|
796 |
|
|
return SNMP_ERR_NOERROR;
|
797 |
|
|
}
|
798 |
|
|
|
799 |
|
|
|
800 |
|
|
|
801 |
|
|
|
802 |
|
|
int
|
803 |
|
|
write_ipNetToMediaPhysAddress(int action,
|
804 |
|
|
u_char *var_val,
|
805 |
|
|
u_char var_val_type,
|
806 |
|
|
size_t var_val_len,
|
807 |
|
|
u_char *statP,
|
808 |
|
|
oid *name,
|
809 |
|
|
size_t name_len)
|
810 |
|
|
{
|
811 |
|
|
static unsigned char string[SPRINT_MAX_LEN];
|
812 |
|
|
int size;
|
813 |
|
|
|
814 |
|
|
|
815 |
|
|
switch ( action ) {
|
816 |
|
|
case RESERVE1:
|
817 |
|
|
if (var_val_type != ASN_OCTET_STR){
|
818 |
|
|
fprintf(stderr, "write to ipNetToMediaPhysAddress not ASN_OCTET_STR\n");
|
819 |
|
|
return SNMP_ERR_WRONGTYPE;
|
820 |
|
|
}
|
821 |
|
|
if (var_val_len > sizeof(string)){
|
822 |
|
|
fprintf(stderr,"write to ipNetToMediaPhysAddress: bad length\n");
|
823 |
|
|
return SNMP_ERR_WRONGLENGTH;
|
824 |
|
|
}
|
825 |
|
|
break;
|
826 |
|
|
|
827 |
|
|
|
828 |
|
|
case RESERVE2:
|
829 |
|
|
size = var_val_len;
|
830 |
|
|
//string = (char *) var_val;
|
831 |
|
|
|
832 |
|
|
|
833 |
|
|
break;
|
834 |
|
|
|
835 |
|
|
|
836 |
|
|
case FREE:
|
837 |
|
|
/* Release any resources that have been allocated */
|
838 |
|
|
break;
|
839 |
|
|
|
840 |
|
|
|
841 |
|
|
case ACTION:
|
842 |
|
|
/* The variable has been stored in string for
|
843 |
|
|
you to use, and you have just been asked to do something with
|
844 |
|
|
it. Note that anything done here must be reversable in the UNDO case */
|
845 |
|
|
break;
|
846 |
|
|
|
847 |
|
|
|
848 |
|
|
case UNDO:
|
849 |
|
|
/* Back out any changes made in the ACTION case */
|
850 |
|
|
break;
|
851 |
|
|
|
852 |
|
|
|
853 |
|
|
case COMMIT:
|
854 |
|
|
/* Things are working well, so it's now safe to make the change
|
855 |
|
|
permanently. Make sure that anything done here can't fail! */
|
856 |
|
|
break;
|
857 |
|
|
}
|
858 |
|
|
return SNMP_ERR_NOERROR;
|
859 |
|
|
}
|
860 |
|
|
|
861 |
|
|
|
862 |
|
|
|
863 |
|
|
|
864 |
|
|
int
|
865 |
|
|
write_ipNetToMediaNetAddress(int action,
|
866 |
|
|
u_char *var_val,
|
867 |
|
|
u_char var_val_type,
|
868 |
|
|
size_t var_val_len,
|
869 |
|
|
u_char *statP,
|
870 |
|
|
oid *name,
|
871 |
|
|
size_t name_len)
|
872 |
|
|
{
|
873 |
|
|
static unsigned char string[SPRINT_MAX_LEN];
|
874 |
|
|
int size;
|
875 |
|
|
|
876 |
|
|
|
877 |
|
|
switch ( action ) {
|
878 |
|
|
case RESERVE1:
|
879 |
|
|
if (var_val_type != ASN_IPADDRESS){
|
880 |
|
|
fprintf(stderr, "write to ipNetToMediaNetAddress not ASN_IPADDRESS\n");
|
881 |
|
|
return SNMP_ERR_WRONGTYPE;
|
882 |
|
|
}
|
883 |
|
|
if (var_val_len > sizeof(string)){
|
884 |
|
|
fprintf(stderr,"write to ipNetToMediaNetAddress: bad length\n");
|
885 |
|
|
return SNMP_ERR_WRONGLENGTH;
|
886 |
|
|
}
|
887 |
|
|
break;
|
888 |
|
|
|
889 |
|
|
|
890 |
|
|
case RESERVE2:
|
891 |
|
|
size = var_val_len;
|
892 |
|
|
//string = (char *) var_val;
|
893 |
|
|
|
894 |
|
|
|
895 |
|
|
break;
|
896 |
|
|
|
897 |
|
|
|
898 |
|
|
case FREE:
|
899 |
|
|
/* Release any resources that have been allocated */
|
900 |
|
|
break;
|
901 |
|
|
|
902 |
|
|
|
903 |
|
|
case ACTION:
|
904 |
|
|
/* The variable has been stored in string for
|
905 |
|
|
you to use, and you have just been asked to do something with
|
906 |
|
|
it. Note that anything done here must be reversable in the UNDO case */
|
907 |
|
|
break;
|
908 |
|
|
|
909 |
|
|
|
910 |
|
|
case UNDO:
|
911 |
|
|
/* Back out any changes made in the ACTION case */
|
912 |
|
|
break;
|
913 |
|
|
|
914 |
|
|
|
915 |
|
|
case COMMIT:
|
916 |
|
|
/* Things are working well, so it's now safe to make the change
|
917 |
|
|
permanently. Make sure that anything done here can't fail! */
|
918 |
|
|
break;
|
919 |
|
|
}
|
920 |
|
|
return SNMP_ERR_NOERROR;
|
921 |
|
|
}
|
922 |
|
|
|
923 |
|
|
|
924 |
|
|
|
925 |
|
|
|
926 |
|
|
int
|
927 |
|
|
write_ipNetToMediaType(int action,
|
928 |
|
|
u_char *var_val,
|
929 |
|
|
u_char var_val_type,
|
930 |
|
|
size_t var_val_len,
|
931 |
|
|
u_char *statP,
|
932 |
|
|
oid *name,
|
933 |
|
|
size_t name_len)
|
934 |
|
|
{
|
935 |
|
|
static long *long_ret;
|
936 |
|
|
int size;
|
937 |
|
|
|
938 |
|
|
|
939 |
|
|
switch ( action ) {
|
940 |
|
|
case RESERVE1:
|
941 |
|
|
if (var_val_type != ASN_INTEGER){
|
942 |
|
|
fprintf(stderr, "write to ipNetToMediaType not ASN_INTEGER\n");
|
943 |
|
|
return SNMP_ERR_WRONGTYPE;
|
944 |
|
|
}
|
945 |
|
|
if (var_val_len > sizeof(long_ret)){
|
946 |
|
|
fprintf(stderr,"write to ipNetToMediaType: bad length\n");
|
947 |
|
|
return SNMP_ERR_WRONGLENGTH;
|
948 |
|
|
}
|
949 |
|
|
break;
|
950 |
|
|
|
951 |
|
|
|
952 |
|
|
case RESERVE2:
|
953 |
|
|
size = var_val_len;
|
954 |
|
|
long_ret = (long *) var_val;
|
955 |
|
|
|
956 |
|
|
|
957 |
|
|
break;
|
958 |
|
|
|
959 |
|
|
|
960 |
|
|
case FREE:
|
961 |
|
|
/* Release any resources that have been allocated */
|
962 |
|
|
break;
|
963 |
|
|
|
964 |
|
|
|
965 |
|
|
case ACTION:
|
966 |
|
|
/* The variable has been stored in long_ret for
|
967 |
|
|
you to use, and you have just been asked to do something with
|
968 |
|
|
it. Note that anything done here must be reversable in the UNDO case */
|
969 |
|
|
break;
|
970 |
|
|
|
971 |
|
|
|
972 |
|
|
case UNDO:
|
973 |
|
|
/* Back out any changes made in the ACTION case */
|
974 |
|
|
break;
|
975 |
|
|
|
976 |
|
|
|
977 |
|
|
case COMMIT:
|
978 |
|
|
/* Things are working well, so it's now safe to make the change
|
979 |
|
|
permanently. Make sure that anything done here can't fail! */
|
980 |
|
|
break;
|
981 |
|
|
}
|
982 |
|
|
return SNMP_ERR_NOERROR;
|
983 |
|
|
}
|
984 |
|
|
|
985 |
|
|
#endif
|
986 |
|
|
// ---------------------------------------------------------------------------
|
987 |
|
|
|
988 |
|
|
// EOF ip.c
|