Changeset View
Changeset View
Standalone View
Standalone View
sbin/ifconfig/ifgroup.c
Show First 20 Lines • Show All 108 Lines • ▼ Show 20 Lines | getifgroups(int s) | ||||
free(ifgr.ifgr_groups); | free(ifgr.ifgr_groups); | ||||
} | } | ||||
static void | static void | ||||
printgroup(const char *groupname) | printgroup(const char *groupname) | ||||
{ | { | ||||
struct ifgroupreq ifgr; | struct ifgroupreq ifgr; | ||||
struct ifg_req *ifg; | struct ifg_req *ifg; | ||||
int len; | unsigned int len; | ||||
int s; | int s; | ||||
s = socket(AF_LOCAL, SOCK_DGRAM, 0); | s = socket(AF_LOCAL, SOCK_DGRAM, 0); | ||||
if (s == -1) | if (s == -1) | ||||
err(1, "socket(AF_LOCAL,SOCK_DGRAM)"); | err(1, "socket(AF_LOCAL,SOCK_DGRAM)"); | ||||
bzero(&ifgr, sizeof(ifgr)); | bzero(&ifgr, sizeof(ifgr)); | ||||
strlcpy(ifgr.ifgr_name, groupname, sizeof(ifgr.ifgr_name)); | strlcpy(ifgr.ifgr_name, groupname, sizeof(ifgr.ifgr_name)); | ||||
if (ioctl(s, SIOCGIFGMEMB, (caddr_t)&ifgr) == -1) { | if (ioctl(s, SIOCGIFGMEMB, (caddr_t)&ifgr) == -1) { | ||||
Show All 19 Lines | printgroup(const char *groupname) | ||||
exit(exit_code); | exit(exit_code); | ||||
} | } | ||||
static struct cmd group_cmds[] = { | static struct cmd group_cmds[] = { | ||||
DEF_CMD_ARG("group", setifgroup), | DEF_CMD_ARG("group", setifgroup), | ||||
DEF_CMD_ARG("-group", unsetifgroup), | DEF_CMD_ARG("-group", unsetifgroup), | ||||
}; | }; | ||||
static struct afswtch af_group = { | static struct afswtch af_group = { | ||||
.af_name = "af_group", | .af_name = "af_group", | ||||
.af_af = AF_UNSPEC, | .af_af = AF_UNSPEC, | ||||
.af_other_status = getifgroups, | .af_other_status = getifgroups, | ||||
}; | }; | ||||
static struct option group_gopt = { "g:", "[-g groupname]", printgroup }; | |||||
static struct option group_gopt = { | |||||
.opt = "g:", | |||||
.opt_usage = "[-g groupname]", | |||||
.cb = printgroup, | |||||
}; | |||||
static __constructor void | static __constructor void | ||||
group_ctor(void) | group_ctor(void) | ||||
{ | { | ||||
int i; | for (size_t i = 0; i < nitems(group_cmds); i++) | ||||
for (i = 0; i < nitems(group_cmds); i++) | |||||
cmd_register(&group_cmds[i]); | cmd_register(&group_cmds[i]); | ||||
af_register(&af_group); | af_register(&af_group); | ||||
opt_register(&group_gopt); | opt_register(&group_gopt); | ||||
} | } |