mibII_ifmib.c revision 133211
1255570Strasz/*
2330449Seadler * Copyright (c) 2001-2003
3330449Seadler *	Fraunhofer Institute for Open Communication Systems (FhG Fokus).
4255570Strasz *	All rights reserved.
5255570Strasz *
6255570Strasz * Author: Harti Brandt <harti@freebsd.org>
7255570Strasz *
8255570Strasz * Redistribution and use in source and binary forms, with or without
9255570Strasz * modification, are permitted provided that the following conditions
10255570Strasz * are met:
11255570Strasz * 1. Redistributions of source code must retain the above copyright
12255570Strasz *    notice, this list of conditions and the following disclaimer.
13255570Strasz * 2. Redistributions in binary form must reproduce the above copyright
14255570Strasz *    notice, this list of conditions and the following disclaimer in the
15255570Strasz *    documentation and/or other materials provided with the distribution.
16255570Strasz *
17255570Strasz * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18255570Strasz * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19255570Strasz * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20255570Strasz * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
21255570Strasz * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22255570Strasz * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23255570Strasz * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24255570Strasz * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25255570Strasz * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26255570Strasz * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27255570Strasz * SUCH DAMAGE.
28255570Strasz *
29255570Strasz * $Begemot: bsnmp/snmp_mibII/mibII_ifmib.c,v 1.9 2004/08/06 08:47:00 brandt Exp $
30255570Strasz *
31255570Strasz * Interfaces group.
32255570Strasz */
33255570Strasz#include "mibII.h"
34255570Strasz#include "mibII_oid.h"
35255570Strasz
36255570Strasz/*
37255570Strasz * Scalars
38255570Strasz */
39255570Straszint
40255570Straszop_ifmib(struct snmp_context *ctx __unused, struct snmp_value *value,
41255570Strasz    u_int sub, u_int idx __unused, enum snmp_op op)
42255570Strasz{
43255570Strasz	switch (op) {
44255570Strasz
45255570Strasz	  case SNMP_OP_GETNEXT:
46255570Strasz		abort();
47255570Strasz
48255570Strasz	  case SNMP_OP_GET:
49255570Strasz		break;
50255570Strasz
51255570Strasz	  case SNMP_OP_SET:
52255570Strasz		return (SNMP_ERR_NOT_WRITEABLE);
53255570Strasz
54255570Strasz	  case SNMP_OP_ROLLBACK:
55255570Strasz	  case SNMP_OP_COMMIT:
56255570Strasz		abort();
57255570Strasz	}
58255570Strasz
59255570Strasz	switch (value->var.subs[sub - 1]) {
60255570Strasz
61255570Strasz	  case LEAF_ifTableLastChange:
62301033Strasz		if (mib_iftable_last_change > start_tick)
63301033Strasz			value->v.uint32 = mib_iftable_last_change - start_tick;
64301033Strasz		else
65301033Strasz			value->v.uint32 = 0;
66255570Strasz		break;
67255570Strasz
68255570Strasz	  case LEAF_ifStackLastChange:
69255570Strasz		if (mib_ifstack_last_change > start_tick)
70255570Strasz			value->v.uint32 = mib_ifstack_last_change - start_tick;
71255570Strasz		else
72255570Strasz			value->v.uint32 = 0;
73255570Strasz		break;
74255570Strasz	}
75255570Strasz	return (SNMP_ERR_NOERROR);
76255570Strasz}
77255570Strasz