Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F102616642
D28965.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D28965.diff
View Options
diff --git a/sbin/ifconfig/ifgroup.c b/sbin/ifconfig/ifgroup.c
--- a/sbin/ifconfig/ifgroup.c
+++ b/sbin/ifconfig/ifgroup.c
@@ -43,6 +43,8 @@
#include <string.h>
#include <unistd.h>
+#include <libifconfig.h>
+
#include "ifconfig.h"
/* ARGSUSED */
@@ -84,33 +86,21 @@
static void
getifgroups(int s)
{
- int len, cnt;
- struct ifgroupreq ifgr;
- struct ifg_req *ifg;
-
- memset(&ifgr, 0, sizeof(ifgr));
- strlcpy(ifgr.ifgr_name, name, IFNAMSIZ);
+ ifconfig_handle_t *lifh;
+ struct ifgroupreq ifgr;
+ size_t cnt;
- if (ioctl(s, SIOCGIFGROUP, (caddr_t)&ifgr) == -1) {
- if (errno == EINVAL || errno == ENOTTY)
- return;
- else
- err(1, "SIOCGIFGROUP");
- }
+ lifh = ifconfig_open();
+ if (lifh == NULL)
+ return;
- len = ifgr.ifgr_len;
- ifgr.ifgr_groups =
- (struct ifg_req *)calloc(len / sizeof(struct ifg_req),
- sizeof(struct ifg_req));
- if (ifgr.ifgr_groups == NULL)
- err(1, "getifgroups");
- if (ioctl(s, SIOCGIFGROUP, (caddr_t)&ifgr) == -1)
- err(1, "SIOCGIFGROUP");
+ if (ifconfig_get_groups(lifh, name, &ifgr) == -1)
+ goto close;
cnt = 0;
- ifg = ifgr.ifgr_groups;
- for (; ifg && len >= sizeof(struct ifg_req); ifg++) {
- len -= sizeof(struct ifg_req);
+ for (size_t i = 0; i < ifgr.ifgr_len / sizeof(struct ifg_req); ++i) {
+ struct ifg_req *ifg = &ifgr.ifgr_groups[i];
+
if (strcmp(ifg->ifgrq_group, "all")) {
if (cnt == 0)
printf("\tgroups:");
@@ -122,6 +112,8 @@
printf("\n");
free(ifgr.ifgr_groups);
+close:
+ ifconfig_close(lifh);
}
static void
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 15, 8:55 PM (19 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14647752
Default Alt Text
D28965.diff (1 KB)
Attached To
Mode
D28965: sbin/ifconfig: Use libifconfig to get groups
Attached
Detach File
Event Timeline
Log In to Comment