Deleted Added
full compact
bridge_sys.c (166493) bridge_sys.c (171791)
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 OS specific ioctls.
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 OS specific ioctls.
28 *
29 * $FreeBSD: head/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_sys.c 166493 2007-02-04 13:31:05Z syrinx $
29 * $FreeBSD: head/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_sys.c 171791 2007-08-08 19:27:50Z syrinx $
30 */
31
32#include <sys/ioctl.h>
33#include <sys/param.h>
34#include <sys/module.h>
35#include <sys/linker.h>
36#include <sys/socket.h>
37#include <sys/sysctl.h>

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

424 return (-1);
425 }
426
427 bif->max_addrs = b_param.ifbrp_csize;
428 return (0);
429}
430
431int
30 */
31
32#include <sys/ioctl.h>
33#include <sys/param.h>
34#include <sys/module.h>
35#include <sys/linker.h>
36#include <sys/socket.h>
37#include <sys/sysctl.h>

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

424 return (-1);
425 }
426
427 bif->max_addrs = b_param.ifbrp_csize;
428 return (0);
429}
430
431int
432bridge_set_tx_hold_count(struct bridge_if *bif __unused,
433 int32_t tx_hc __unused)
432bridge_set_tx_hold_count(struct bridge_if *bif, int32_t tx_hc)
434{
435 struct ifdrv ifd;
436 struct ifbrparam b_param;
437
438 if (tx_hc < SNMP_BRIDGE_MIN_TXHC || tx_hc > SNMP_BRIDGE_MAX_TXHC)
439 return (-1);
440
441 strlcpy(ifd.ifd_name, bif->bif_name, IFNAMSIZ);

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

450 return (-1);
451 }
452
453 bif->tx_hold_count = b_param.ifbrp_txhc;
454 return (0);
455}
456
457int
433{
434 struct ifdrv ifd;
435 struct ifbrparam b_param;
436
437 if (tx_hc < SNMP_BRIDGE_MIN_TXHC || tx_hc > SNMP_BRIDGE_MAX_TXHC)
438 return (-1);
439
440 strlcpy(ifd.ifd_name, bif->bif_name, IFNAMSIZ);

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

449 return (-1);
450 }
451
452 bif->tx_hold_count = b_param.ifbrp_txhc;
453 return (0);
454}
455
456int
458bridge_set_stp_version(struct bridge_if *bif __unused,
459 int32_t stp_proto __unused)
457bridge_set_stp_version(struct bridge_if *bif, int32_t stp_proto)
460{
461 struct ifdrv ifd;
462 struct ifbrparam b_param;
463
464 strlcpy(ifd.ifd_name, bif->bif_name, IFNAMSIZ);
465 ifd.ifd_len = sizeof(b_param);
466 ifd.ifd_data = &b_param;
467 b_param.ifbrp_proto = stp_proto;

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

670 bp->enable = dot1dStpPortEnable_disabled;
671
672 /* Begemot Bridge MIB only. */
673 if (k_info->ifbr_ifsflags & IFBIF_SPAN)
674 bp->span_enable = begemotBridgeBaseSpanEnabled_enabled;
675 else
676 bp->span_enable = begemotBridgeBaseSpanEnabled_disabled;
677
458{
459 struct ifdrv ifd;
460 struct ifbrparam b_param;
461
462 strlcpy(ifd.ifd_name, bif->bif_name, IFNAMSIZ);
463 ifd.ifd_len = sizeof(b_param);
464 ifd.ifd_data = &b_param;
465 b_param.ifbrp_proto = stp_proto;

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

668 bp->enable = dot1dStpPortEnable_disabled;
669
670 /* Begemot Bridge MIB only. */
671 if (k_info->ifbr_ifsflags & IFBIF_SPAN)
672 bp->span_enable = begemotBridgeBaseSpanEnabled_enabled;
673 else
674 bp->span_enable = begemotBridgeBaseSpanEnabled_disabled;
675
676 if (k_info->ifbr_ifsflags & IFBIF_PRIVATE)
677 bp->priv_set = TruthValue_true;
678 else
679 bp->priv_set = TruthValue_false;
680
678 if (k_info->ifbr_ifsflags & IFBIF_BSTP_ADMEDGE)
679 bp->admin_edge = TruthValue_true;
680 else
681 bp->admin_edge = TruthValue_false;
682
683 if (k_info->ifbr_ifsflags & IFBIF_BSTP_EDGE)
684 bp->oper_edge = TruthValue_true;
685 else

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

835
836 return (0);
837}
838
839/*
840 * Set the PonitToPoint status of the link administratively.
841 */
842int
681 if (k_info->ifbr_ifsflags & IFBIF_BSTP_ADMEDGE)
682 bp->admin_edge = TruthValue_true;
683 else
684 bp->admin_edge = TruthValue_false;
685
686 if (k_info->ifbr_ifsflags & IFBIF_BSTP_EDGE)
687 bp->oper_edge = TruthValue_true;
688 else

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

838
839 return (0);
840}
841
842/*
843 * Set the PonitToPoint status of the link administratively.
844 */
845int
843bridge_port_set_admin_ptp(const char *bif_name __unused,
844 struct bridge_port *bp __unused, uint32_t admin_ptp __unused)
846bridge_port_set_admin_ptp(const char *bif_name, struct bridge_port *bp,
847 uint32_t admin_ptp)
845{
846 struct ifdrv ifd;
847 struct ifbreq b_req;
848
849 if (bp->admin_ptp == admin_ptp)
850 return (0);
851
852 bzero(&b_req, sizeof(b_req));

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

886 bp->admin_ptp = admin_ptp;
887 return (0);
888}
889
890/*
891 * Set admin edge.
892 */
893int
848{
849 struct ifdrv ifd;
850 struct ifbreq b_req;
851
852 if (bp->admin_ptp == admin_ptp)
853 return (0);
854
855 bzero(&b_req, sizeof(b_req));

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

889 bp->admin_ptp = admin_ptp;
890 return (0);
891}
892
893/*
894 * Set admin edge.
895 */
896int
894bridge_port_set_admin_edge(const char *bif_name __unused,
895 struct bridge_port *bp __unused, uint32_t enable __unused)
897bridge_port_set_admin_edge(const char *bif_name, struct bridge_port *bp,
898 uint32_t enable)
896{
897 struct ifdrv ifd;
898 struct ifbreq b_req;
899
900 if (bp->admin_edge == enable)
901 return (0);
902
903 bzero(&b_req, sizeof(b_req));

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

927 }
928
929 bp->admin_edge = enable;
930
931 return (0);
932}
933
934/*
899{
900 struct ifdrv ifd;
901 struct ifbreq b_req;
902
903 if (bp->admin_edge == enable)
904 return (0);
905
906 bzero(&b_req, sizeof(b_req));

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

930 }
931
932 bp->admin_edge = enable;
933
934 return (0);
935}
936
937/*
938 * Set 'private' flag.
939 */
940int
941bridge_port_set_private(const char *bif_name, struct bridge_port *bp,
942 uint32_t priv_set)
943{
944 struct ifdrv ifd;
945 struct ifbreq b_req;
946
947 if (bp->priv_set == priv_set)
948 return (0);
949
950 bzero(&b_req, sizeof(b_req));
951 strlcpy(ifd.ifd_name, bif_name, sizeof(ifd.ifd_name));
952 ifd.ifd_len = sizeof(b_req);
953 ifd.ifd_data = &b_req;
954 strlcpy(b_req.ifbr_ifsname, bp->p_name, sizeof(b_req.ifbr_ifsname));
955 ifd.ifd_cmd = BRDGGIFFLGS;
956
957 if (ioctl(sock, SIOCGDRVSPEC, &ifd) < 0) {
958 syslog(LOG_ERR, "get member %s param: ioctl(BRDGGIFFLGS) "
959 "failed: %s", bp->p_name, strerror(errno));
960 return (-1);
961 }
962
963 if (priv_set == TruthValue_true)
964 b_req.ifbr_ifsflags |= IFBIF_PRIVATE;
965 else if (priv_set == TruthValue_false)
966 b_req.ifbr_ifsflags &= ~IFBIF_PRIVATE;
967 else
968 return (SNMP_ERR_WRONG_VALUE);
969
970 ifd.ifd_cmd = BRDGSIFFLGS;
971 if (ioctl(sock, SIOCSDRVSPEC, &ifd) < 0) {
972 syslog(LOG_ERR, "set member %s param: ioctl(BRDGSIFFLGS) "
973 "failed: %s", bp->p_name, strerror(errno));
974 return (-1);
975 }
976
977 bp->priv_set = priv_set;
978
979 return (0);
980}
981
982
983/*
935 * Add a bridge member port.
936 */
937int
938bridge_port_addm(struct bridge_port *bp, const char *b_name)
939{
940 struct ifdrv ifd;
941 struct ifbreq b_req;
942

--- 512 unchanged lines hidden ---
984 * Add a bridge member port.
985 */
986int
987bridge_port_addm(struct bridge_port *bp, const char *b_name)
988{
989 struct ifdrv ifd;
990 struct ifbreq b_req;
991

--- 512 unchanged lines hidden ---