xref: /freebsd/contrib/bsnmp/snmp_mibII/mibII_begemot.c (revision 748b5b1ebd1b2c58c21a90cdc5abdd462eeb22b3)
1748b5b1eSHartmut Brandt /*
2748b5b1eSHartmut Brandt  * Copyright (c) 2006
3748b5b1eSHartmut Brandt  *	Hartmut Brandt.
4748b5b1eSHartmut Brandt  *	All rights reserved.
5748b5b1eSHartmut Brandt  *
6748b5b1eSHartmut Brandt  * Author: Harti Brandt <harti@freebsd.org>
7748b5b1eSHartmut Brandt  *
8748b5b1eSHartmut Brandt  * Redistribution and use in source and binary forms, with or without
9748b5b1eSHartmut Brandt  * modification, are permitted provided that the following conditions
10748b5b1eSHartmut Brandt  * are met:
11748b5b1eSHartmut Brandt  * 1. Redistributions of source code must retain the above copyright
12748b5b1eSHartmut Brandt  *    notice, this list of conditions and the following disclaimer.
13748b5b1eSHartmut Brandt  * 2. Redistributions in binary form must reproduce the above copyright
14748b5b1eSHartmut Brandt  *    notice, this list of conditions and the following disclaimer in the
15748b5b1eSHartmut Brandt  *    documentation and/or other materials provided with the distribution.
16748b5b1eSHartmut Brandt  *
17748b5b1eSHartmut Brandt  * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18748b5b1eSHartmut Brandt  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19748b5b1eSHartmut Brandt  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20748b5b1eSHartmut Brandt  * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
21748b5b1eSHartmut Brandt  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22748b5b1eSHartmut Brandt  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23748b5b1eSHartmut Brandt  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24748b5b1eSHartmut Brandt  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25748b5b1eSHartmut Brandt  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26748b5b1eSHartmut Brandt  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27748b5b1eSHartmut Brandt  * SUCH DAMAGE.
28748b5b1eSHartmut Brandt  *
29748b5b1eSHartmut Brandt  * $Begemot: bsnmp/snmp_mibII/mibII_begemot.c,v 1.1 2006/02/14 09:04:19 brandt_h Exp $
30748b5b1eSHartmut Brandt  *
31748b5b1eSHartmut Brandt  * Private MIB.
32748b5b1eSHartmut Brandt  */
33748b5b1eSHartmut Brandt #include "mibII.h"
34748b5b1eSHartmut Brandt #include "mibII_oid.h"
35748b5b1eSHartmut Brandt 
36748b5b1eSHartmut Brandt /*
37748b5b1eSHartmut Brandt  * Scalars
38748b5b1eSHartmut Brandt  */
39748b5b1eSHartmut Brandt int
40748b5b1eSHartmut Brandt op_begemot_mibII(struct snmp_context *ctx __unused, struct snmp_value *value,
41748b5b1eSHartmut Brandt     u_int sub, u_int idx __unused, enum snmp_op op)
42748b5b1eSHartmut Brandt {
43748b5b1eSHartmut Brandt 	switch (op) {
44748b5b1eSHartmut Brandt 
45748b5b1eSHartmut Brandt 	  case SNMP_OP_GETNEXT:
46748b5b1eSHartmut Brandt 		abort();
47748b5b1eSHartmut Brandt 
48748b5b1eSHartmut Brandt 	  case SNMP_OP_GET:
49748b5b1eSHartmut Brandt 		goto get;
50748b5b1eSHartmut Brandt 
51748b5b1eSHartmut Brandt 	  case SNMP_OP_SET:
52748b5b1eSHartmut Brandt 		switch (value->var.subs[sub - 1]) {
53748b5b1eSHartmut Brandt 
54748b5b1eSHartmut Brandt 		  case LEAF_begemotIfMaxspeed:
55748b5b1eSHartmut Brandt 		  case LEAF_begemotIfPoll:
56748b5b1eSHartmut Brandt 			return (SNMP_ERR_NOT_WRITEABLE);
57748b5b1eSHartmut Brandt 
58748b5b1eSHartmut Brandt 		  case LEAF_begemotIfForcePoll:
59748b5b1eSHartmut Brandt 			ctx->scratch->int1 = mibif_force_hc_update_interval;
60748b5b1eSHartmut Brandt 			mibif_force_hc_update_interval = value->v.uint32;
61748b5b1eSHartmut Brandt 			return (SNMP_ERR_NOERROR);
62748b5b1eSHartmut Brandt 		}
63748b5b1eSHartmut Brandt 		abort();
64748b5b1eSHartmut Brandt 
65748b5b1eSHartmut Brandt 	  case SNMP_OP_ROLLBACK:
66748b5b1eSHartmut Brandt 		switch (value->var.subs[sub - 1]) {
67748b5b1eSHartmut Brandt 
68748b5b1eSHartmut Brandt 		  case LEAF_begemotIfForcePoll:
69748b5b1eSHartmut Brandt 			mibif_force_hc_update_interval = ctx->scratch->int1;
70748b5b1eSHartmut Brandt 			return (SNMP_ERR_NOERROR);
71748b5b1eSHartmut Brandt 		}
72748b5b1eSHartmut Brandt 		abort();
73748b5b1eSHartmut Brandt 
74748b5b1eSHartmut Brandt 	  case SNMP_OP_COMMIT:
75748b5b1eSHartmut Brandt 		switch (value->var.subs[sub - 1]) {
76748b5b1eSHartmut Brandt 
77748b5b1eSHartmut Brandt 		  case LEAF_begemotIfForcePoll:
78748b5b1eSHartmut Brandt 			mibif_force_hc_update_interval = ctx->scratch->int1;
79748b5b1eSHartmut Brandt 			mibif_reset_hc_timer();
80748b5b1eSHartmut Brandt 			return (SNMP_ERR_NOERROR);
81748b5b1eSHartmut Brandt 		}
82748b5b1eSHartmut Brandt 		abort();
83748b5b1eSHartmut Brandt 	}
84748b5b1eSHartmut Brandt 	abort();
85748b5b1eSHartmut Brandt 
86748b5b1eSHartmut Brandt   get:
87748b5b1eSHartmut Brandt 
88748b5b1eSHartmut Brandt 	switch (value->var.subs[sub - 1]) {
89748b5b1eSHartmut Brandt 
90748b5b1eSHartmut Brandt 	  case LEAF_begemotIfMaxspeed:
91748b5b1eSHartmut Brandt 		value->v.counter64 = mibif_maxspeed;
92748b5b1eSHartmut Brandt 		return (SNMP_ERR_NOERROR);
93748b5b1eSHartmut Brandt 
94748b5b1eSHartmut Brandt 	  case LEAF_begemotIfPoll:
95748b5b1eSHartmut Brandt 		value->v.uint32 = mibif_hc_update_interval;
96748b5b1eSHartmut Brandt 		return (SNMP_ERR_NOERROR);
97748b5b1eSHartmut Brandt 
98748b5b1eSHartmut Brandt 	  case LEAF_begemotIfForcePoll:
99748b5b1eSHartmut Brandt 		value->v.uint32 = mibif_force_hc_update_interval;
100748b5b1eSHartmut Brandt 		return (SNMP_ERR_NOERROR);
101748b5b1eSHartmut Brandt 	}
102748b5b1eSHartmut Brandt 	abort();
103748b5b1eSHartmut Brandt }
104