Deleted Added
full compact
bridge_if.c (164997) bridge_if.c (165046)
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 *
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 164997 2006-12-07 22:36:17Z syrinx $
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;
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 = NULL;
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));
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
1130 case SNMP_OP_COMMIT:
1131 return (bridge_commit_if_status(val, sub));
1131 case SNMP_OP_COMMIT:
1132 return (bridge_commit_if_status(val, sub));
1133
1134 default:
1135 abort();
1132 }
1133
1134 ret = SNMP_ERR_NOERROR;
1135 switch (val->var.subs[sub - 1]) {
1136 case LEAF_begemotBridgeBaseName:
1137 ret = string_get(val, bif->bif_name, -1);
1138 break;
1139

--- 16 unchanged lines hidden (view full) ---

1156
1157 return (ret);
1158}
1159
1160int
1161op_begemot_stp(struct snmp_context *ctx, struct snmp_value *val,
1162 uint sub, uint iidx __unused, enum snmp_op op)
1163{
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{
1164 int ret = SNMP_ERR_NOERROR; /* Make the compiler happy. */
1165 struct bridge_if *bif = NULL;
1168 int ret;
1169 struct bridge_if *bif;
1166
1167 if (time(NULL) - bridge_list_age > bridge_get_data_maxage())
1168 bridge_update_all_ifs();
1169
1170 switch (op) {
1171 case SNMP_OP_GET:
1172 if ((bif = bridge_if_index_get(&val->var, sub)) == NULL)
1173 return (SNMP_ERR_NOSUCHNAME);

--- 46 unchanged lines hidden (view full) ---

1220 case LEAF_begemotBridgeStpDesignatedRoot:
1221 case LEAF_begemotBridgeStpRootCost:
1222 case LEAF_begemotBridgeStpRootPort:
1223 case LEAF_begemotBridgeStpMaxAge:
1224 case LEAF_begemotBridgeStpHelloTime:
1225 case LEAF_begemotBridgeStpHoldTime:
1226 case LEAF_begemotBridgeStpForwardDelay:
1227 return (SNMP_ERR_NOT_WRITEABLE);
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);
1228 }
1229
1230 if (ret == 0)
1231 return (SNMP_ERR_NOERROR);
1232 else if (ret == -2)
1233 return (SNMP_ERR_WRONG_VALUE);
1234 return (SNMP_ERR_GENERR);
1235

--- 25 unchanged lines hidden (view full) ---

1261 case LEAF_begemotBridgeStpTxHoldCount:
1262 bridge_set_tx_hold_count(bif, ctx->scratch->int1);
1263 break;
1264 }
1265 return (SNMP_ERR_NOERROR);
1266
1267 case SNMP_OP_COMMIT:
1268 return (SNMP_ERR_NOERROR);
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();
1269 }
1270
1279 }
1280
1281 ret = SNMP_ERR_NOERROR;
1282
1271 switch (val->var.subs[sub - 1]) {
1272 case LEAF_begemotBridgeStpProtocolSpecification:
1273 val->v.integer = bif->prot_spec;
1274 break;
1275
1276 case LEAF_begemotBridgeStpPriority:
1277 val->v.integer = bif->priority;
1278 break;

--- 58 unchanged lines hidden (view full) ---

1337
1338 return (ret);
1339}
1340
1341int
1342op_begemot_tp(struct snmp_context *ctx, struct snmp_value *val,
1343 uint sub, uint iidx __unused, enum snmp_op op)
1344{
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{
1345 struct bridge_if *bif = NULL;
1357 struct bridge_if *bif;
1346
1347 if (time(NULL) - bridge_list_age > bridge_get_data_maxage())
1348 bridge_update_all_ifs();
1349
1350 switch (op) {
1351 case SNMP_OP_GET:
1352 if ((bif = bridge_if_index_get(&val->var, sub)) == NULL)
1353 return (SNMP_ERR_NOSUCHNAME);

--- 39 unchanged lines hidden (view full) ---

1393 case LEAF_begemotBridgeTpMaxAddresses:
1394 bridge_set_max_cache(bif, ctx->scratch->int1);
1395 break;
1396 }
1397 return (SNMP_ERR_NOERROR);
1398
1399 case SNMP_OP_COMMIT:
1400 return (SNMP_ERR_NOERROR);
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();
1401 }
1402
1403 switch (val->var.subs[sub - 1]) {
1404 case LEAF_begemotBridgeTpLearnedEntryDiscards:
1405 val->v.uint32 = bif->lrnt_drops;
1406 break;
1407
1408 case LEAF_begemotBridgeTpAgingTime:
1409 val->v.integer = bif->age_time;
1410 break;
1411
1412 case LEAF_begemotBridgeTpMaxAddresses:
1413 val->v.integer = bif->max_addrs;
1414 break;
1415 }
1416
1417 return (SNMP_ERR_NOERROR);
1418}
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}