Deleted Added
full compact
bridge_if.c (164410) bridge_if.c (164997)
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 164410 2006-11-19 15:42:48Z syrinx $
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{
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;
677 struct bridge_if *bif;
678
679 if ((bif = bridge_get_default()) == NULL)
680 return (SNMP_ERR_NOSUCHNAME);
681
682 if (time(NULL) - bif->entry_age > bridge_get_data_maxage() &&
683 bridge_update_bif(bif) <= 0) /* It was just deleted. */
684 return (SNMP_ERR_NOSUCHNAME);

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

738
739 case LEAF_dot1dStpBridgeHelloTime:
740 value->v.integer = bif->bridge_hello_time;
741 break;
742
743 case LEAF_dot1dStpBridgeForwardDelay:
744 value->v.integer = bif->bridge_fwd_delay;
745 break;
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;
746 }
747
748 return (SNMP_ERR_NOERROR);
749
750 case SNMP_OP_GETNEXT:
751 abort();
752
753 case SNMP_OP_SET:
754 switch (value->var.subs[sub - 1]) {
755 case LEAF_dot1dStpPriority:
756 ctx->scratch->int1 = bif->priority;
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;
757 if (bridge_set_priority(bif, value->v.integer) < 0)
758 return (SNMP_ERR_GENERR);
763 ret = bridge_set_priority(bif, value->v.integer);
759 break;
760
761 case LEAF_dot1dStpBridgeMaxAge:
762 ctx->scratch->int1 = bif->bridge_max_age;
764 break;
765
766 case LEAF_dot1dStpBridgeMaxAge:
767 ctx->scratch->int1 = bif->bridge_max_age;
763 if (bridge_set_maxage(bif, value->v.integer) < 0)
764 return (SNMP_ERR_GENERR);
768 ret = bridge_set_maxage(bif, value->v.integer);
765 break;
766
767 case LEAF_dot1dStpBridgeHelloTime:
768 ctx->scratch->int1 = bif->bridge_hello_time;
769 break;
770
771 case LEAF_dot1dStpBridgeHelloTime:
772 ctx->scratch->int1 = bif->bridge_hello_time;
769 if (bridge_set_hello_time(bif, value->v.integer) < 0)
770 return (SNMP_ERR_GENERR);
773 ret = bridge_set_hello_time(bif, value->v.integer);
771 break;
772
773 case LEAF_dot1dStpBridgeForwardDelay:
774 ctx->scratch->int1 = bif->bridge_fwd_delay;
774 break;
775
776 case LEAF_dot1dStpBridgeForwardDelay:
777 ctx->scratch->int1 = bif->bridge_fwd_delay;
775 if (bridge_set_forward_delay(bif, value->v.integer) < 0)
776 return (SNMP_ERR_GENERR);
778 ret = bridge_set_forward_delay(bif, value->v.integer);
777 break;
778
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
779 case LEAF_dot1dStpProtocolSpecification:
780 case LEAF_dot1dStpTimeSinceTopologyChange:
781 case LEAF_dot1dStpTopChanges:
782 case LEAF_dot1dStpDesignatedRoot:
783 case LEAF_dot1dStpRootCost:
784 case LEAF_dot1dStpRootPort:
785 case LEAF_dot1dStpMaxAge:
786 case LEAF_dot1dStpHelloTime:
787 case LEAF_dot1dStpHoldTime:
788 case LEAF_dot1dStpForwardDelay:
789 return (SNMP_ERR_NOT_WRITEABLE);
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);
790 }
791
804 }
805
806 if (ret == -2)
807 return (SNMP_ERR_WRONG_VALUE);
808 else if (ret < 0)
809 return (SNMP_ERR_GENERR);
792 return (SNMP_ERR_NOERROR);
793
794 case SNMP_OP_ROLLBACK:
795 switch (value->var.subs[sub - 1]) {
796 case LEAF_dot1dStpPriority:
810 return (SNMP_ERR_NOERROR);
811
812 case SNMP_OP_ROLLBACK:
813 switch (value->var.subs[sub - 1]) {
814 case LEAF_dot1dStpPriority:
797 (void) bridge_set_priority(bif, ctx->scratch->int1);
815 bridge_set_priority(bif, ctx->scratch->int1);
798 break;
799 case LEAF_dot1dStpBridgeMaxAge:
816 break;
817 case LEAF_dot1dStpBridgeMaxAge:
800 (void) bridge_set_maxage(bif, ctx->scratch->int1);
818 bridge_set_maxage(bif, ctx->scratch->int1);
801 break;
802 case LEAF_dot1dStpBridgeHelloTime:
819 break;
820 case LEAF_dot1dStpBridgeHelloTime:
803 (void) bridge_set_hello_time(bif, ctx->scratch->int1);
821 bridge_set_hello_time(bif, ctx->scratch->int1);
804 break;
805 case LEAF_dot1dStpBridgeForwardDelay:
822 break;
823 case LEAF_dot1dStpBridgeForwardDelay:
806 (void) bridge_set_forward_delay(bif,
807 ctx->scratch->int1);
824 bridge_set_forward_delay(bif, ctx->scratch->int1);
808 break;
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;
809 }
810 return (SNMP_ERR_NOERROR);
811
812 case SNMP_OP_COMMIT:
813 return (SNMP_ERR_NOERROR);
814 }
815
816 return (SNMP_ERR_NOERROR);

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

849 ctx->scratch->int1 = bif->age_time;
850 if (bridge_set_aging_time(bif, value->v.integer) < 0)
851 return (SNMP_ERR_GENERR);
852 }
853 return (SNMP_ERR_NOERROR);
854
855 case SNMP_OP_ROLLBACK:
856 if (value->var.subs[sub - 1] == LEAF_dot1dTpAgingTime)
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)
857 (void) bridge_set_aging_time(bif, ctx->scratch->int1);
880 bridge_set_aging_time(bif, ctx->scratch->int1);
858 return (SNMP_ERR_NOERROR);
859
860 case SNMP_OP_COMMIT:
861 return (SNMP_ERR_NOERROR);
862 }
863
864 return (SNMP_ERR_NOERROR);
865}

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

1176 ret = bridge_set_hello_time(bif, val->v.integer);
1177 break;
1178
1179 case LEAF_begemotBridgeStpBridgeForwardDelay:
1180 ctx->scratch->int1 = bif->bridge_fwd_delay;
1181 ret = bridge_set_forward_delay(bif, val->v.integer);
1182 break;
1183
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
1184 case LEAF_begemotBridgeStpProtocolSpecification:
1185 case LEAF_begemotBridgeStpTimeSinceTopologyChange:
1186 case LEAF_begemotBridgeStpTopChanges:
1187 case LEAF_begemotBridgeStpDesignatedRoot:
1188 case LEAF_begemotBridgeStpRootCost:
1189 case LEAF_begemotBridgeStpRootPort:
1190 case LEAF_begemotBridgeStpMaxAge:
1191 case LEAF_begemotBridgeStpHelloTime:

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

1215
1216 case LEAF_begemotBridgeStpBridgeHelloTime:
1217 bridge_set_hello_time(bif, ctx->scratch->int1);
1218 break;
1219
1220 case LEAF_begemotBridgeStpBridgeForwardDelay:
1221 bridge_set_forward_delay(bif, ctx->scratch->int1);
1222 break;
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;
1223 }
1224 return (SNMP_ERR_NOERROR);
1225
1226 case SNMP_OP_COMMIT:
1227 return (SNMP_ERR_NOERROR);
1228 }
1229
1230 switch (val->var.subs[sub - 1]) {

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

1279
1280 case LEAF_begemotBridgeStpBridgeHelloTime:
1281 val->v.integer = bif->bridge_hello_time;
1282 break;
1283
1284 case LEAF_begemotBridgeStpBridgeForwardDelay:
1285 val->v.integer = bif->bridge_fwd_delay;
1286 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;
1287 }
1288
1289 return (ret);
1290}
1291
1292int
1293op_begemot_tp(struct snmp_context *ctx, struct snmp_value *val,
1294 uint sub, uint iidx __unused, enum snmp_op op)

--- 75 unchanged lines hidden ---
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 ---