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 $ |
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> --- 631 unchanged lines hidden (view full) --- 669 670 return (ret); 671} 672 673int 674op_dot1d_stp(struct snmp_context *ctx, struct snmp_value *value, 675 uint sub, uint iidx __unused, enum snmp_op op) 676{ |
677 int ret; |
678 struct bridge_if *bif; 679 680 if ((bif = bridge_get_default()) == NULL) 681 return (SNMP_ERR_NOSUCHNAME); 682 683 if (time(NULL) - bif->entry_age > bridge_get_data_maxage() && 684 bridge_update_bif(bif) <= 0) /* It was just deleted. */ 685 return (SNMP_ERR_NOSUCHNAME); --- 53 unchanged lines hidden (view full) --- 739 740 case LEAF_dot1dStpBridgeHelloTime: 741 value->v.integer = bif->bridge_hello_time; 742 break; 743 744 case LEAF_dot1dStpBridgeForwardDelay: 745 value->v.integer = bif->bridge_fwd_delay; 746 break; |
747 case LEAF_dot1dStpVersion: 748 value->v.integer = bif->stp_version; 749 break; 750 case LEAF_dot1dStpTxHoldCount: 751 value->v.integer = bif->tx_hold_count; |
752 } 753 754 return (SNMP_ERR_NOERROR); 755 756 case SNMP_OP_GETNEXT: 757 abort(); 758 759 case SNMP_OP_SET: 760 switch (value->var.subs[sub - 1]) { 761 case LEAF_dot1dStpPriority: 762 ctx->scratch->int1 = bif->priority; |
763 ret = bridge_set_priority(bif, value->v.integer); |
764 break; 765 766 case LEAF_dot1dStpBridgeMaxAge: 767 ctx->scratch->int1 = bif->bridge_max_age; |
768 ret = bridge_set_maxage(bif, value->v.integer); |
769 break; 770 771 case LEAF_dot1dStpBridgeHelloTime: 772 ctx->scratch->int1 = bif->bridge_hello_time; |
773 ret = bridge_set_hello_time(bif, value->v.integer); |
774 break; 775 776 case LEAF_dot1dStpBridgeForwardDelay: 777 ctx->scratch->int1 = bif->bridge_fwd_delay; |
778 ret = bridge_set_forward_delay(bif, value->v.integer); |
779 break; 780 |
781 case LEAF_dot1dStpVersion: 782 ctx->scratch->int1 = bif->stp_version; 783 ret = bridge_set_stp_version(bif, value->v.integer); 784 break; 785 786 case LEAF_dot1dStpTxHoldCount: 787 ctx->scratch->int1 = bif->tx_hold_count; 788 ret = bridge_set_tx_hold_count(bif, value->v.integer); 789 break; 790 |
791 case LEAF_dot1dStpProtocolSpecification: 792 case LEAF_dot1dStpTimeSinceTopologyChange: 793 case LEAF_dot1dStpTopChanges: 794 case LEAF_dot1dStpDesignatedRoot: 795 case LEAF_dot1dStpRootCost: 796 case LEAF_dot1dStpRootPort: 797 case LEAF_dot1dStpMaxAge: 798 case LEAF_dot1dStpHelloTime: 799 case LEAF_dot1dStpHoldTime: 800 case LEAF_dot1dStpForwardDelay: 801 return (SNMP_ERR_NOT_WRITEABLE); |
802 default: 803 return (SNMP_ERR_NOSUCHNAME); |
804 } 805 |
806 if (ret == -2) 807 return (SNMP_ERR_WRONG_VALUE); 808 else if (ret < 0) 809 return (SNMP_ERR_GENERR); |
810 return (SNMP_ERR_NOERROR); 811 812 case SNMP_OP_ROLLBACK: 813 switch (value->var.subs[sub - 1]) { 814 case LEAF_dot1dStpPriority: |
815 bridge_set_priority(bif, ctx->scratch->int1); |
816 break; 817 case LEAF_dot1dStpBridgeMaxAge: |
818 bridge_set_maxage(bif, ctx->scratch->int1); |
819 break; 820 case LEAF_dot1dStpBridgeHelloTime: |
821 bridge_set_hello_time(bif, ctx->scratch->int1); |
822 break; 823 case LEAF_dot1dStpBridgeForwardDelay: |
824 bridge_set_forward_delay(bif, ctx->scratch->int1); |
825 break; |
826 case LEAF_dot1dStpVersion: 827 bridge_set_stp_version(bif, ctx->scratch->int1); 828 break; 829 case LEAF_dot1dStpTxHoldCount: 830 bridge_set_tx_hold_count(bif, ctx->scratch->int1); 831 break; |
832 } 833 return (SNMP_ERR_NOERROR); 834 835 case SNMP_OP_COMMIT: 836 return (SNMP_ERR_NOERROR); 837 } 838 839 return (SNMP_ERR_NOERROR); --- 32 unchanged lines hidden (view full) --- 872 ctx->scratch->int1 = bif->age_time; 873 if (bridge_set_aging_time(bif, value->v.integer) < 0) 874 return (SNMP_ERR_GENERR); 875 } 876 return (SNMP_ERR_NOERROR); 877 878 case SNMP_OP_ROLLBACK: 879 if (value->var.subs[sub - 1] == LEAF_dot1dTpAgingTime) |
880 bridge_set_aging_time(bif, ctx->scratch->int1); |
881 return (SNMP_ERR_NOERROR); 882 883 case SNMP_OP_COMMIT: 884 return (SNMP_ERR_NOERROR); 885 } 886 887 return (SNMP_ERR_NOERROR); 888} --- 310 unchanged lines hidden (view full) --- 1199 ret = bridge_set_hello_time(bif, val->v.integer); 1200 break; 1201 1202 case LEAF_begemotBridgeStpBridgeForwardDelay: 1203 ctx->scratch->int1 = bif->bridge_fwd_delay; 1204 ret = bridge_set_forward_delay(bif, val->v.integer); 1205 break; 1206 |
1207 case LEAF_begemotBridgeStpVersion: 1208 ctx->scratch->int1 = bif->stp_version; 1209 ret = bridge_set_stp_version(bif, val->v.integer); 1210 break; 1211 1212 case LEAF_begemotBridgeStpTxHoldCount: 1213 ctx->scratch->int1 = bif->tx_hold_count; 1214 ret = bridge_set_tx_hold_count(bif, val->v.integer); 1215 break; 1216 |
1217 case LEAF_begemotBridgeStpProtocolSpecification: 1218 case LEAF_begemotBridgeStpTimeSinceTopologyChange: 1219 case LEAF_begemotBridgeStpTopChanges: 1220 case LEAF_begemotBridgeStpDesignatedRoot: 1221 case LEAF_begemotBridgeStpRootCost: 1222 case LEAF_begemotBridgeStpRootPort: 1223 case LEAF_begemotBridgeStpMaxAge: 1224 case LEAF_begemotBridgeStpHelloTime: --- 23 unchanged lines hidden (view full) --- 1248 1249 case LEAF_begemotBridgeStpBridgeHelloTime: 1250 bridge_set_hello_time(bif, ctx->scratch->int1); 1251 break; 1252 1253 case LEAF_begemotBridgeStpBridgeForwardDelay: 1254 bridge_set_forward_delay(bif, ctx->scratch->int1); 1255 break; |
1256 1257 case LEAF_begemotBridgeStpVersion: 1258 bridge_set_stp_version(bif, ctx->scratch->int1); 1259 break; 1260 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); 1269 } 1270 1271 switch (val->var.subs[sub - 1]) { --- 48 unchanged lines hidden (view full) --- 1320 1321 case LEAF_begemotBridgeStpBridgeHelloTime: 1322 val->v.integer = bif->bridge_hello_time; 1323 break; 1324 1325 case LEAF_begemotBridgeStpBridgeForwardDelay: 1326 val->v.integer = bif->bridge_fwd_delay; 1327 break; |
1328 1329 case LEAF_begemotBridgeStpVersion: 1330 val->v.integer = bif->stp_version; 1331 break; 1332 1333 case LEAF_begemotBridgeStpTxHoldCount: 1334 val->v.integer = bif->tx_hold_count; 1335 break; |
1336 } 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) --- 75 unchanged lines hidden --- |