Path: blob/main/contrib/bsnmp/snmp_mibII/mibII_begemot.c
39478 views
/*1* Copyright (c) 20062* Hartmut Brandt.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_begemot.c,v 1.1 2006/02/14 09:04:19 brandt_h Exp $29*30* Private MIB.31*/32#include "mibII.h"33#include "mibII_oid.h"3435/*36* Scalars37*/38int39op_begemot_mibII(struct snmp_context *ctx, 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:48goto get;4950case SNMP_OP_SET:51switch (value->var.subs[sub - 1]) {5253case LEAF_begemotIfMaxspeed:54case LEAF_begemotIfPoll:55return (SNMP_ERR_NOT_WRITEABLE);5657case LEAF_begemotIfForcePoll:58ctx->scratch->int1 = mibif_force_hc_update_interval;59mibif_force_hc_update_interval = value->v.uint32;60return (SNMP_ERR_NOERROR);6162case LEAF_begemotIfDataPoll:63ctx->scratch->int1 = mibII_poll_ticks;64mibII_poll_ticks = value->v.uint32;65return (SNMP_ERR_NOERROR);66}67abort();6869case SNMP_OP_ROLLBACK:70switch (value->var.subs[sub - 1]) {7172case LEAF_begemotIfForcePoll:73mibif_force_hc_update_interval = ctx->scratch->int1;74return (SNMP_ERR_NOERROR);7576case LEAF_begemotIfDataPoll:77mibII_poll_ticks = ctx->scratch->int1;78return (SNMP_ERR_NOERROR);79}80abort();8182case SNMP_OP_COMMIT:83switch (value->var.subs[sub - 1]) {8485case LEAF_begemotIfForcePoll:86mibif_force_hc_update_interval = ctx->scratch->int1;87mibif_reset_hc_timer();88return (SNMP_ERR_NOERROR);8990case LEAF_begemotIfDataPoll:91mibif_restart_mibII_poll_timer();92return (SNMP_ERR_NOERROR);93}94abort();95}96abort();9798get:99100switch (value->var.subs[sub - 1]) {101102case LEAF_begemotIfMaxspeed:103value->v.counter64 = mibif_maxspeed;104return (SNMP_ERR_NOERROR);105106case LEAF_begemotIfPoll:107value->v.uint32 = mibif_hc_update_interval;108return (SNMP_ERR_NOERROR);109110case LEAF_begemotIfForcePoll:111value->v.uint32 = mibif_force_hc_update_interval;112return (SNMP_ERR_NOERROR);113114case LEAF_begemotIfDataPoll:115value->v.uint32 = mibII_poll_ticks;116return (SNMP_ERR_NOERROR);117}118abort();119}120121122