mibII_ifmib.c revision 122394
1145554Sdarrenr/* 2145554Sdarrenr * Copyright (c) 2001-2003 3145554Sdarrenr * Fraunhofer Institute for Open Communication Systems (FhG Fokus). 4255332Scy * All rights reserved. 5145554Sdarrenr * 6145554Sdarrenr * Author: Harti Brandt <harti@freebsd.org> 7255332Scy * 8255332Scy * Redistribution of this software and documentation and use in source and 9145554Sdarrenr * binary forms, with or without modification, are permitted provided that 10145554Sdarrenr * the following conditions are met: 11145554Sdarrenr * 12255332Scy * 1. Redistributions of source code or documentation must retain the above 13145554Sdarrenr * copyright notice, this list of conditions and the following disclaimer. 14145554Sdarrenr * 2. Redistributions in binary form must reproduce the above copyright 15255332Scy * notice, this list of conditions and the following disclaimer in the 16145554Sdarrenr * documentation and/or other materials provided with the distribution. 17255332Scy * 3. Neither the name of the Institute nor the names of its contributors 18145554Sdarrenr * may be used to endorse or promote products derived from this software 19255332Scy * without specific prior written permission. 20145554Sdarrenr * 21145554Sdarrenr * THIS SOFTWARE AND DOCUMENTATION IS PROVIDED BY FRAUNHOFER FOKUS 22145554Sdarrenr * AND ITS CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 23145554Sdarrenr * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 24255332Scy * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 25255332Scy * FRAUNHOFER FOKUS OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26255332Scy * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27145554Sdarrenr * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 28145554Sdarrenr * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29145554Sdarrenr * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30145554Sdarrenr * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31145554Sdarrenr * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32145554Sdarrenr * 33145554Sdarrenr * $Begemot: bsnmp/snmp_mibII/mibII_ifmib.c,v 1.7 2003/01/28 13:44:35 hbb Exp $ 34145554Sdarrenr * 35145554Sdarrenr * Interfaces group. 36145554Sdarrenr */ 37145554Sdarrenr#include "mibII.h" 38145554Sdarrenr#include "mibII_oid.h" 39145554Sdarrenr 40145554Sdarrenr/* 41145554Sdarrenr * Scalars 42145554Sdarrenr */ 43145554Sdarrenrint 44145554Sdarrenrop_ifmib(struct snmp_context *ctx __unused, struct snmp_value *value, 45145554Sdarrenr u_int sub, u_int idx __unused, enum snmp_op op) 46145554Sdarrenr{ 47145554Sdarrenr switch (op) { 48255332Scy 49255332Scy case SNMP_OP_GETNEXT: 50255332Scy abort(); 51145554Sdarrenr 52145554Sdarrenr case SNMP_OP_GET: 53145554Sdarrenr break; 54145554Sdarrenr 55145554Sdarrenr case SNMP_OP_SET: 56255332Scy return (SNMP_ERR_NOT_WRITEABLE); 57255332Scy 58255332Scy case SNMP_OP_ROLLBACK: 59145554Sdarrenr case SNMP_OP_COMMIT: 60145554Sdarrenr abort(); 61145554Sdarrenr } 62145554Sdarrenr 63145554Sdarrenr switch (value->var.subs[sub - 1]) { 64145554Sdarrenr 65145554Sdarrenr case LEAF_ifTableLastChange: 66145554Sdarrenr if (mib_iftable_last_change > start_tick) 67255332Scy value->v.uint32 = mib_iftable_last_change - start_tick; 68255332Scy else 69255332Scy value->v.uint32 = 0; 70255332Scy break; 71255332Scy 72255332Scy case LEAF_ifStackLastChange: 73255332Scy if (mib_ifstack_last_change > start_tick) 74145554Sdarrenr value->v.uint32 = mib_ifstack_last_change - start_tick; 75170268Sdarrenr else 76145554Sdarrenr value->v.uint32 = 0; 77170268Sdarrenr break; 78145554Sdarrenr } 79145554Sdarrenr return (SNMP_ERR_NOERROR); 80145554Sdarrenr} 81145554Sdarrenr