1/*-
2 * Copyright (c) 2006 Shteryana Shopova <syrinx@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
--- 12 unchanged lines hidden (view full) ---
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * Bridge MIB implementation for SNMPd.
27 * Bridge interface objects.
28 *
29 * $FreeBSD: head/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_if.c 165046 2006-12-09 20:58:26Z syrinx $
30 */
31
32#include <sys/queue.h>
33#include <sys/socket.h>
34#include <sys/time.h>
35#include <sys/types.h>
36
37#include <net/ethernet.h>
--- 1053 unchanged lines hidden (view full) ---
1091 return (SNMP_ERR_NOERROR);
1092}
1093
1094int
1095op_begemot_base_bridge(struct snmp_context *ctx, struct snmp_value *val,
1096 uint sub, uint iidx __unused, enum snmp_op op)
1097{
1098 int ret;
1099 struct bridge_if *bif;
1100
1101 if (time(NULL) - bridge_list_age > bridge_get_data_maxage())
1102 bridge_update_all_ifs();
1103
1104 switch (op) {
1105 case SNMP_OP_GET:
1106 if ((bif = bridge_if_index_get(&val->var, sub)) == NULL)
1107 return (SNMP_ERR_NOSUCHNAME);
--- 14 unchanged lines hidden (view full) ---
1122 case LEAF_begemotBridgeBaseNumPorts:
1123 case LEAF_begemotBridgeBaseType:
1124 return (SNMP_ERR_NOT_WRITEABLE);
1125 }
1126 abort();
1127
1128 case SNMP_OP_ROLLBACK:
1129 return (bridge_rollback_if_status(ctx, val, sub));
1130
1131 case SNMP_OP_COMMIT:
1132 return (bridge_commit_if_status(val, sub));
1133
1134 default:
1135 abort();
1136 }
1137
1138 ret = SNMP_ERR_NOERROR;
1139 switch (val->var.subs[sub - 1]) {
1140 case LEAF_begemotBridgeBaseName:
1141 ret = string_get(val, bif->bif_name, -1);
1142 break;
1143
--- 16 unchanged lines hidden (view full) ---
1160
1161 return (ret);
1162}
1163
1164int
1165op_begemot_stp(struct snmp_context *ctx, struct snmp_value *val,
1166 uint sub, uint iidx __unused, enum snmp_op op)
1167{
1168 int ret;
1169 struct bridge_if *bif;
1170
1171 if (time(NULL) - bridge_list_age > bridge_get_data_maxage())
1172 bridge_update_all_ifs();
1173
1174 switch (op) {
1175 case SNMP_OP_GET:
1176 if ((bif = bridge_if_index_get(&val->var, sub)) == NULL)
1177 return (SNMP_ERR_NOSUCHNAME);
--- 46 unchanged lines hidden (view full) ---
1224 case LEAF_begemotBridgeStpDesignatedRoot:
1225 case LEAF_begemotBridgeStpRootCost:
1226 case LEAF_begemotBridgeStpRootPort:
1227 case LEAF_begemotBridgeStpMaxAge:
1228 case LEAF_begemotBridgeStpHelloTime:
1229 case LEAF_begemotBridgeStpHoldTime:
1230 case LEAF_begemotBridgeStpForwardDelay:
1231 return (SNMP_ERR_NOT_WRITEABLE);
1232
1233 default:
1234 return (SNMP_ERR_NOSUCHNAME);
1235 }
1236
1237 if (ret == 0)
1238 return (SNMP_ERR_NOERROR);
1239 else if (ret == -2)
1240 return (SNMP_ERR_WRONG_VALUE);
1241 return (SNMP_ERR_GENERR);
1242
--- 25 unchanged lines hidden (view full) ---
1268 case LEAF_begemotBridgeStpTxHoldCount:
1269 bridge_set_tx_hold_count(bif, ctx->scratch->int1);
1270 break;
1271 }
1272 return (SNMP_ERR_NOERROR);
1273
1274 case SNMP_OP_COMMIT:
1275 return (SNMP_ERR_NOERROR);
1276
1277 default:
1278 abort();
1279 }
1280
1281 ret = SNMP_ERR_NOERROR;
1282
1283 switch (val->var.subs[sub - 1]) {
1284 case LEAF_begemotBridgeStpProtocolSpecification:
1285 val->v.integer = bif->prot_spec;
1286 break;
1287
1288 case LEAF_begemotBridgeStpPriority:
1289 val->v.integer = bif->priority;
1290 break;
--- 58 unchanged lines hidden (view full) ---
1349
1350 return (ret);
1351}
1352
1353int
1354op_begemot_tp(struct snmp_context *ctx, struct snmp_value *val,
1355 uint sub, uint iidx __unused, enum snmp_op op)
1356{
1357 struct bridge_if *bif;
1358
1359 if (time(NULL) - bridge_list_age > bridge_get_data_maxage())
1360 bridge_update_all_ifs();
1361
1362 switch (op) {
1363 case SNMP_OP_GET:
1364 if ((bif = bridge_if_index_get(&val->var, sub)) == NULL)
1365 return (SNMP_ERR_NOSUCHNAME);
--- 39 unchanged lines hidden (view full) ---
1405 case LEAF_begemotBridgeTpMaxAddresses:
1406 bridge_set_max_cache(bif, ctx->scratch->int1);
1407 break;
1408 }
1409 return (SNMP_ERR_NOERROR);
1410
1411 case SNMP_OP_COMMIT:
1412 return (SNMP_ERR_NOERROR);
1413
1414 default:
1415 abort();
1416 }
1417
1418 switch (val->var.subs[sub - 1]) {
1419 case LEAF_begemotBridgeTpLearnedEntryDiscards:
1420 val->v.uint32 = bif->lrnt_drops;
1421 break;
1422
1423 case LEAF_begemotBridgeTpAgingTime:
1424 val->v.integer = bif->age_time;
1425 break;
1426
1427 case LEAF_begemotBridgeTpMaxAddresses:
1428 val->v.integer = bif->max_addrs;
1429 break;
1430 }
1431
1432 return (SNMP_ERR_NOERROR);
1433}
2 * Copyright (c) 2006 Shteryana Shopova <syrinx@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
--- 12 unchanged lines hidden (view full) ---
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * Bridge MIB implementation for SNMPd.
27 * Bridge interface objects.
28 *
29 * $FreeBSD: head/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_if.c 165046 2006-12-09 20:58:26Z syrinx $
30 */
31
32#include <sys/queue.h>
33#include <sys/socket.h>
34#include <sys/time.h>
35#include <sys/types.h>
36
37#include <net/ethernet.h>
--- 1053 unchanged lines hidden (view full) ---
1091 return (SNMP_ERR_NOERROR);
1092}
1093
1094int
1095op_begemot_base_bridge(struct snmp_context *ctx, struct snmp_value *val,
1096 uint sub, uint iidx __unused, enum snmp_op op)
1097{
1098 int ret;
1099 struct bridge_if *bif;
1100
1101 if (time(NULL) - bridge_list_age > bridge_get_data_maxage())
1102 bridge_update_all_ifs();
1103
1104 switch (op) {
1105 case SNMP_OP_GET:
1106 if ((bif = bridge_if_index_get(&val->var, sub)) == NULL)
1107 return (SNMP_ERR_NOSUCHNAME);
--- 14 unchanged lines hidden (view full) ---
1122 case LEAF_begemotBridgeBaseNumPorts:
1123 case LEAF_begemotBridgeBaseType:
1124 return (SNMP_ERR_NOT_WRITEABLE);
1125 }
1126 abort();
1127
1128 case SNMP_OP_ROLLBACK:
1129 return (bridge_rollback_if_status(ctx, val, sub));
1130
1131 case SNMP_OP_COMMIT:
1132 return (bridge_commit_if_status(val, sub));
1133
1134 default:
1135 abort();
1136 }
1137
1138 ret = SNMP_ERR_NOERROR;
1139 switch (val->var.subs[sub - 1]) {
1140 case LEAF_begemotBridgeBaseName:
1141 ret = string_get(val, bif->bif_name, -1);
1142 break;
1143
--- 16 unchanged lines hidden (view full) ---
1160
1161 return (ret);
1162}
1163
1164int
1165op_begemot_stp(struct snmp_context *ctx, struct snmp_value *val,
1166 uint sub, uint iidx __unused, enum snmp_op op)
1167{
1168 int ret;
1169 struct bridge_if *bif;
1170
1171 if (time(NULL) - bridge_list_age > bridge_get_data_maxage())
1172 bridge_update_all_ifs();
1173
1174 switch (op) {
1175 case SNMP_OP_GET:
1176 if ((bif = bridge_if_index_get(&val->var, sub)) == NULL)
1177 return (SNMP_ERR_NOSUCHNAME);
--- 46 unchanged lines hidden (view full) ---
1224 case LEAF_begemotBridgeStpDesignatedRoot:
1225 case LEAF_begemotBridgeStpRootCost:
1226 case LEAF_begemotBridgeStpRootPort:
1227 case LEAF_begemotBridgeStpMaxAge:
1228 case LEAF_begemotBridgeStpHelloTime:
1229 case LEAF_begemotBridgeStpHoldTime:
1230 case LEAF_begemotBridgeStpForwardDelay:
1231 return (SNMP_ERR_NOT_WRITEABLE);
1232
1233 default:
1234 return (SNMP_ERR_NOSUCHNAME);
1235 }
1236
1237 if (ret == 0)
1238 return (SNMP_ERR_NOERROR);
1239 else if (ret == -2)
1240 return (SNMP_ERR_WRONG_VALUE);
1241 return (SNMP_ERR_GENERR);
1242
--- 25 unchanged lines hidden (view full) ---
1268 case LEAF_begemotBridgeStpTxHoldCount:
1269 bridge_set_tx_hold_count(bif, ctx->scratch->int1);
1270 break;
1271 }
1272 return (SNMP_ERR_NOERROR);
1273
1274 case SNMP_OP_COMMIT:
1275 return (SNMP_ERR_NOERROR);
1276
1277 default:
1278 abort();
1279 }
1280
1281 ret = SNMP_ERR_NOERROR;
1282
1283 switch (val->var.subs[sub - 1]) {
1284 case LEAF_begemotBridgeStpProtocolSpecification:
1285 val->v.integer = bif->prot_spec;
1286 break;
1287
1288 case LEAF_begemotBridgeStpPriority:
1289 val->v.integer = bif->priority;
1290 break;
--- 58 unchanged lines hidden (view full) ---
1349
1350 return (ret);
1351}
1352
1353int
1354op_begemot_tp(struct snmp_context *ctx, struct snmp_value *val,
1355 uint sub, uint iidx __unused, enum snmp_op op)
1356{
1357 struct bridge_if *bif;
1358
1359 if (time(NULL) - bridge_list_age > bridge_get_data_maxage())
1360 bridge_update_all_ifs();
1361
1362 switch (op) {
1363 case SNMP_OP_GET:
1364 if ((bif = bridge_if_index_get(&val->var, sub)) == NULL)
1365 return (SNMP_ERR_NOSUCHNAME);
--- 39 unchanged lines hidden (view full) ---
1405 case LEAF_begemotBridgeTpMaxAddresses:
1406 bridge_set_max_cache(bif, ctx->scratch->int1);
1407 break;
1408 }
1409 return (SNMP_ERR_NOERROR);
1410
1411 case SNMP_OP_COMMIT:
1412 return (SNMP_ERR_NOERROR);
1413
1414 default:
1415 abort();
1416 }
1417
1418 switch (val->var.subs[sub - 1]) {
1419 case LEAF_begemotBridgeTpLearnedEntryDiscards:
1420 val->v.uint32 = bif->lrnt_drops;
1421 break;
1422
1423 case LEAF_begemotBridgeTpAgingTime:
1424 val->v.integer = bif->age_time;
1425 break;
1426
1427 case LEAF_begemotBridgeTpMaxAddresses:
1428 val->v.integer = bif->max_addrs;
1429 break;
1430 }
1431
1432 return (SNMP_ERR_NOERROR);
1433}