MCPcopy Create free account
hub / github.com/F-Stack/f-stack / setifflags

Function setifflags

tools/ifconfig/ifconfig.c:1303–1321  ·  view source on GitHub ↗

* Note: doing an SIOCIGIFFLAGS scribbles on the union portion * of the ifreq structure, which may confuse other parts of ifconfig. * Make a private copy so we can avoid that. */

Source from the content-addressed store, hash-verified

1301 * Make a private copy so we can avoid that.
1302 */
1303static void
1304setifflags(const char *vname, int value, int s, const struct afswtch *afp)
1305{
1306 struct ifreq my_ifr;
1307 int flags;
1308
1309 flags = getifflags(name, s);
1310 if (value < 0) {
1311 value = -value;
1312 flags &= ~value;
1313 } else
1314 flags |= value;
1315 memset(&my_ifr, 0, sizeof(my_ifr));
1316 (void) strlcpy(my_ifr.ifr_name, name, sizeof(my_ifr.ifr_name));
1317 my_ifr.ifr_flags = flags & 0xffff;
1318 my_ifr.ifr_flagshigh = flags >> 16;
1319 if (ioctl(s, SIOCSIFFLAGS, (caddr_t)&my_ifr) < 0)
1320 Perror(vname);
1321}
1322
1323void
1324setifcap(const char *vname, int value, int s, const struct afswtch *afp)

Callers

nothing calls this directly

Calls 5

getifflagsFunction · 0.85
memsetFunction · 0.85
PerrorFunction · 0.85
strlcpyFunction · 0.50
ioctlFunction · 0.50

Tested by

no test coverage detected