2 * Copyright (c) 2005-2006.
6 * Author: Hartmut Brandt <harti@freebsd.org>
8 * Redistribution of this software and documentation and use in source and
9 * binary forms, with or without modification, are permitted provided that
10 * the following conditions are met:
12 * 1. Redistributions of source code or documentation must retain the above
13 * copyright notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #include "hostres_snmp.h"
36 #include "hostres_oid.h"
37 #include "hostres_tree.h"
40 op_begemot(struct snmp_context *ctx, struct snmp_value *value,
41 u_int sub, u_int iidx __unused, enum snmp_op op)
47 switch (value->var.subs[sub - 1]) {
49 case LEAF_begemotHrStorageUpdate:
50 value->v.uint32 = storage_tbl_refresh;
51 return (SNMP_ERR_NOERROR);
53 case LEAF_begemotHrFSUpdate:
54 value->v.uint32 = fs_tbl_refresh;
55 return (SNMP_ERR_NOERROR);
57 case LEAF_begemotHrDiskStorageUpdate:
58 value->v.uint32 = disk_storage_tbl_refresh;
59 return (SNMP_ERR_NOERROR);
61 case LEAF_begemotHrNetworkUpdate:
62 value->v.uint32 = network_tbl_refresh;
63 return (SNMP_ERR_NOERROR);
65 case LEAF_begemotHrSWInstalledUpdate:
66 value->v.uint32 = swins_tbl_refresh;
67 return (SNMP_ERR_NOERROR);
69 case LEAF_begemotHrSWRunUpdate:
70 value->v.uint32 = swrun_tbl_refresh;
71 return (SNMP_ERR_NOERROR);
73 case LEAF_begemotHrPkgDir:
74 return (string_get(value, pkg_dir, -1));
82 switch (value->var.subs[sub - 1]) {
84 case LEAF_begemotHrStorageUpdate:
85 ctx->scratch->int1 = storage_tbl_refresh;
86 storage_tbl_refresh = value->v.uint32;
87 return (SNMP_ERR_NOERROR);
89 case LEAF_begemotHrFSUpdate:
90 ctx->scratch->int1 = fs_tbl_refresh;
91 fs_tbl_refresh = value->v.uint32;
92 return (SNMP_ERR_NOERROR);
94 case LEAF_begemotHrDiskStorageUpdate:
95 ctx->scratch->int1 = disk_storage_tbl_refresh;
96 disk_storage_tbl_refresh = value->v.uint32;
97 return (SNMP_ERR_NOERROR);
99 case LEAF_begemotHrNetworkUpdate:
100 ctx->scratch->int1 = network_tbl_refresh;
101 network_tbl_refresh = value->v.uint32;
102 return (SNMP_ERR_NOERROR);
104 case LEAF_begemotHrSWInstalledUpdate:
105 ctx->scratch->int1 = swins_tbl_refresh;
106 swins_tbl_refresh = value->v.uint32;
107 return (SNMP_ERR_NOERROR);
109 case LEAF_begemotHrSWRunUpdate:
110 ctx->scratch->int1 = swrun_tbl_refresh;
111 swrun_tbl_refresh = value->v.uint32;
112 return (SNMP_ERR_NOERROR);
114 case LEAF_begemotHrPkgDir:
115 return (string_save(value, ctx, -1, &pkg_dir));
120 switch (value->var.subs[sub - 1]) {
122 case LEAF_begemotHrStorageUpdate:
123 case LEAF_begemotHrFSUpdate:
124 case LEAF_begemotHrDiskStorageUpdate:
125 case LEAF_begemotHrNetworkUpdate:
126 case LEAF_begemotHrSWInstalledUpdate:
127 case LEAF_begemotHrSWRunUpdate:
128 return (SNMP_ERR_NOERROR);
130 case LEAF_begemotHrPkgDir:
132 return (SNMP_ERR_NOERROR);
136 case SNMP_OP_ROLLBACK:
137 switch (value->var.subs[sub - 1]) {
139 case LEAF_begemotHrStorageUpdate:
140 storage_tbl_refresh = ctx->scratch->int1;
141 return (SNMP_ERR_NOERROR);
143 case LEAF_begemotHrFSUpdate:
144 fs_tbl_refresh = ctx->scratch->int1;
145 return (SNMP_ERR_NOERROR);
147 case LEAF_begemotHrDiskStorageUpdate:
148 disk_storage_tbl_refresh = ctx->scratch->int1;
149 return (SNMP_ERR_NOERROR);
151 case LEAF_begemotHrNetworkUpdate:
152 network_tbl_refresh = ctx->scratch->int1;
153 return (SNMP_ERR_NOERROR);
155 case LEAF_begemotHrSWInstalledUpdate:
156 swins_tbl_refresh = ctx->scratch->int1;
157 return (SNMP_ERR_NOERROR);
159 case LEAF_begemotHrSWRunUpdate:
160 swrun_tbl_refresh = ctx->scratch->int1;
161 return (SNMP_ERR_NOERROR);
163 case LEAF_begemotHrPkgDir:
164 string_rollback(ctx, &pkg_dir);
165 return (SNMP_ERR_NOERROR);