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

Function getifflags

tools/ifconfig/ifconfig.c:1273–1296  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1271}
1272
1273static int
1274getifflags(const char *ifname, int us)
1275{
1276 struct ifreq my_ifr;
1277 int s;
1278
1279 memset(&my_ifr, 0, sizeof(my_ifr));
1280 (void) strlcpy(my_ifr.ifr_name, ifname, sizeof(my_ifr.ifr_name));
1281 if (us < 0) {
1282 if ((s = socket(AF_LOCAL, SOCK_DGRAM, 0)) < 0)
1283 err(1, "socket(family AF_LOCAL,SOCK_DGRAM");
1284 } else
1285 s = us;
1286 if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&my_ifr) < 0) {
1287 Perror("ioctl (SIOCGIFFLAGS)");
1288#ifdef FSTACK
1289 ff_ipc_exit();
1290#endif
1291 exit(1);
1292 }
1293 if (us < 0)
1294 close(s);
1295 return ((my_ifr.ifr_flags & 0xffff) | (my_ifr.ifr_flagshigh << 16));
1296}
1297
1298/*
1299 * Note: doing an SIOCIGIFFLAGS scribbles on the union portion

Callers 2

mainFunction · 0.85
setifflagsFunction · 0.85

Calls 7

memsetFunction · 0.85
PerrorFunction · 0.85
ff_ipc_exitFunction · 0.85
strlcpyFunction · 0.50
socketClass · 0.50
ioctlFunction · 0.50
closeFunction · 0.50

Tested by

no test coverage detected