* Stores all members of a group in memory pointed to by igfr */
| 1710 | * Stores all members of a group in memory pointed to by igfr |
| 1711 | */ |
| 1712 | static int |
| 1713 | if_getgroupmembers(struct ifgroupreq *ifgr) |
| 1714 | { |
| 1715 | struct ifg_group *ifg; |
| 1716 | struct ifg_member *ifgm; |
| 1717 | struct ifg_req ifgrq, *ifgp; |
| 1718 | int len, error; |
| 1719 | |
| 1720 | IFNET_RLOCK(); |
| 1721 | CK_STAILQ_FOREACH(ifg, &V_ifg_head, ifg_next) |
| 1722 | if (strcmp(ifg->ifg_group, ifgr->ifgr_name) == 0) |
| 1723 | break; |
| 1724 | if (ifg == NULL) { |
| 1725 | IFNET_RUNLOCK(); |
| 1726 | return (ENOENT); |
| 1727 | } |
| 1728 | |
| 1729 | if (ifgr->ifgr_len == 0) { |
| 1730 | CK_STAILQ_FOREACH(ifgm, &ifg->ifg_members, ifgm_next) |
| 1731 | ifgr->ifgr_len += sizeof(ifgrq); |
| 1732 | IFNET_RUNLOCK(); |
| 1733 | return (0); |
| 1734 | } |
| 1735 | |
| 1736 | len = ifgr->ifgr_len; |
| 1737 | ifgp = ifgr_groups_get(ifgr); |
| 1738 | CK_STAILQ_FOREACH(ifgm, &ifg->ifg_members, ifgm_next) { |
| 1739 | if (len < sizeof(ifgrq)) { |
| 1740 | IFNET_RUNLOCK(); |
| 1741 | return (EINVAL); |
| 1742 | } |
| 1743 | bzero(&ifgrq, sizeof ifgrq); |
| 1744 | strlcpy(ifgrq.ifgrq_member, ifgm->ifgm_ifp->if_xname, |
| 1745 | sizeof(ifgrq.ifgrq_member)); |
| 1746 | if ((error = copyout(&ifgrq, ifgp, sizeof(struct ifg_req)))) { |
| 1747 | IFNET_RUNLOCK(); |
| 1748 | return (error); |
| 1749 | } |
| 1750 | len -= sizeof(ifgrq); |
| 1751 | ifgp++; |
| 1752 | } |
| 1753 | IFNET_RUNLOCK(); |
| 1754 | |
| 1755 | return (0); |
| 1756 | } |
| 1757 | |
| 1758 | /* |
| 1759 | * Return counter values from counter(9)s stored in ifnet. |