1156066Sharti/*
2156066Sharti * Copyright (c) 2006
3156066Sharti *	Hartmut Brandt.
4156066Sharti *	All rights reserved.
5156066Sharti *
6156066Sharti * Author: Harti Brandt <harti@freebsd.org>
7310903Sngie *
8156066Sharti * Redistribution and use in source and binary forms, with or without
9156066Sharti * modification, are permitted provided that the following conditions
10156066Sharti * are met:
11156066Sharti * 1. Redistributions of source code must retain the above copyright
12156066Sharti *    notice, this list of conditions and the following disclaimer.
13156066Sharti * 2. Redistributions in binary form must reproduce the above copyright
14156066Sharti *    notice, this list of conditions and the following disclaimer in the
15156066Sharti *    documentation and/or other materials provided with the distribution.
16310903Sngie *
17156066Sharti * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18156066Sharti * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19156066Sharti * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20156066Sharti * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
21156066Sharti * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22156066Sharti * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23156066Sharti * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24156066Sharti * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25156066Sharti * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26156066Sharti * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27156066Sharti * SUCH DAMAGE.
28156066Sharti *
29156066Sharti * $Begemot: bsnmp/snmp_mibII/mibII_begemot.c,v 1.1 2006/02/14 09:04:19 brandt_h Exp $
30156066Sharti *
31156066Sharti * Private MIB.
32156066Sharti */
33156066Sharti#include "mibII.h"
34156066Sharti#include "mibII_oid.h"
35156066Sharti
36156066Sharti/*
37156066Sharti * Scalars
38156066Sharti */
39156066Shartiint
40311725Sngieop_begemot_mibII(struct snmp_context *ctx, struct snmp_value *value,
41156066Sharti    u_int sub, u_int idx __unused, enum snmp_op op)
42156066Sharti{
43156066Sharti	switch (op) {
44156066Sharti
45156066Sharti	  case SNMP_OP_GETNEXT:
46156066Sharti		abort();
47156066Sharti
48156066Sharti	  case SNMP_OP_GET:
49156066Sharti		goto get;
50156066Sharti
51156066Sharti	  case SNMP_OP_SET:
52156066Sharti		switch (value->var.subs[sub - 1]) {
53156066Sharti
54156066Sharti		  case LEAF_begemotIfMaxspeed:
55156066Sharti		  case LEAF_begemotIfPoll:
56156066Sharti			return (SNMP_ERR_NOT_WRITEABLE);
57156066Sharti
58156066Sharti		  case LEAF_begemotIfForcePoll:
59156066Sharti			ctx->scratch->int1 = mibif_force_hc_update_interval;
60156066Sharti			mibif_force_hc_update_interval = value->v.uint32;
61156066Sharti			return (SNMP_ERR_NOERROR);
62200063Ssyrinx
63200063Ssyrinx		  case LEAF_begemotIfDataPoll:
64200063Ssyrinx			ctx->scratch->int1 = mibII_poll_ticks;
65200063Ssyrinx			mibII_poll_ticks = value->v.uint32;
66200063Ssyrinx			return (SNMP_ERR_NOERROR);
67156066Sharti		}
68156066Sharti		abort();
69156066Sharti
70156066Sharti	  case SNMP_OP_ROLLBACK:
71156066Sharti		switch (value->var.subs[sub - 1]) {
72156066Sharti
73156066Sharti		  case LEAF_begemotIfForcePoll:
74156066Sharti			mibif_force_hc_update_interval = ctx->scratch->int1;
75156066Sharti			return (SNMP_ERR_NOERROR);
76200063Ssyrinx
77200063Ssyrinx		  case LEAF_begemotIfDataPoll:
78200063Ssyrinx			mibII_poll_ticks = ctx->scratch->int1;
79200063Ssyrinx			return (SNMP_ERR_NOERROR);
80156066Sharti		}
81156066Sharti		abort();
82156066Sharti
83156066Sharti	  case SNMP_OP_COMMIT:
84156066Sharti		switch (value->var.subs[sub - 1]) {
85156066Sharti
86156066Sharti		  case LEAF_begemotIfForcePoll:
87156066Sharti			mibif_force_hc_update_interval = ctx->scratch->int1;
88156066Sharti			mibif_reset_hc_timer();
89156066Sharti			return (SNMP_ERR_NOERROR);
90200063Ssyrinx
91200063Ssyrinx		  case LEAF_begemotIfDataPoll:
92200063Ssyrinx			mibif_restart_mibII_poll_timer();
93200063Ssyrinx			return (SNMP_ERR_NOERROR);
94156066Sharti		}
95156066Sharti		abort();
96156066Sharti	}
97156066Sharti	abort();
98156066Sharti
99156066Sharti  get:
100156066Sharti
101156066Sharti	switch (value->var.subs[sub - 1]) {
102156066Sharti
103156066Sharti	  case LEAF_begemotIfMaxspeed:
104156066Sharti		value->v.counter64 = mibif_maxspeed;
105156066Sharti		return (SNMP_ERR_NOERROR);
106156066Sharti
107156066Sharti	  case LEAF_begemotIfPoll:
108156066Sharti		value->v.uint32 = mibif_hc_update_interval;
109156066Sharti		return (SNMP_ERR_NOERROR);
110156066Sharti
111156066Sharti	  case LEAF_begemotIfForcePoll:
112156066Sharti		value->v.uint32 = mibif_force_hc_update_interval;
113156066Sharti		return (SNMP_ERR_NOERROR);
114200063Ssyrinx
115200063Ssyrinx	  case LEAF_begemotIfDataPoll:
116200063Ssyrinx		value->v.uint32 = mibII_poll_ticks;
117200063Ssyrinx		return (SNMP_ERR_NOERROR);
118156066Sharti	}
119156066Sharti	abort();
120156066Sharti}
121