Path: blob/main/contrib/bsnmp/snmp_mibII/mibII_ifmib.c
39478 views
/*1* Copyright (c) 2001-20032* Fraunhofer Institute for Open Communication Systems (FhG Fokus).3* All rights reserved.4*5* Author: Harti Brandt <[email protected]>6*7* Redistribution and use in source and binary forms, with or without8* modification, are permitted provided that the following conditions9* are met:10* 1. Redistributions of source code must retain the above copyright11* notice, this list of conditions and the following disclaimer.12* 2. Redistributions in binary form must reproduce the above copyright13* notice, this list of conditions and the following disclaimer in the14* documentation and/or other materials provided with the distribution.15*16* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND17* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE18* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE19* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE20* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL21* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS22* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)23* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT24* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF26* SUCH DAMAGE.27*28* $Begemot: bsnmp/snmp_mibII/mibII_ifmib.c,v 1.9 2004/08/06 08:47:00 brandt Exp $29*30* Interfaces group.31*/32#include "mibII.h"33#include "mibII_oid.h"3435/*36* Scalars37*/38int39op_ifmib(struct snmp_context *ctx __unused, struct snmp_value *value,40u_int sub, u_int idx __unused, enum snmp_op op)41{42switch (op) {4344case SNMP_OP_GETNEXT:45abort();4647case SNMP_OP_GET:48break;4950case SNMP_OP_SET:51return (SNMP_ERR_NOT_WRITEABLE);5253case SNMP_OP_ROLLBACK:54case SNMP_OP_COMMIT:55abort();56}5758switch (value->var.subs[sub - 1]) {5960case LEAF_ifTableLastChange:61if (mib_iftable_last_change > start_tick)62value->v.uint32 = mib_iftable_last_change - start_tick;63else64value->v.uint32 = 0;65break;6667case LEAF_ifStackLastChange:68if (mib_ifstack_last_change > start_tick)69value->v.uint32 = mib_ifstack_last_change - start_tick;70else71value->v.uint32 = 0;72break;73}74return (SNMP_ERR_NOERROR);75}767778