usr.sbin/rtadvd/if.c
int
if_getflags(int ifindex, int oifflags)
{
	struct ifreq ifr;
	int s;

	if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
		syslog(LOG_ERR, "<%s> socket: %s", __func__,
		       strerror(errno));
		return (oifflags & ~IFF_UP);
	}

	if_indextoname(ifindex, ifr.ifr_name);
	if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&ifr) < 0) {
		syslog(LOG_ERR, "<%s> ioctl:SIOCGIFFLAGS: failed for %s",
		       __func__, ifr.ifr_name);
		close(s);
		return (oifflags & ~IFF_UP);
	}
	close(s);
	return (ifr.ifr_flags);
}
/* give interface index and its old flags, then new flags returned */
give interface index and its old flags, then new flags returned
give interface index and its old flags then new flags returned
int
if_getflags(int ifindex, int oifflags)
{
	struct ifreq ifr;
	int s;
	if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
		syslog(LOG_ERR, "<%s> socket: %s", __func__,
		       strerror(errno));
		return (oifflags & ~IFF_UP);
	}
	if_indextoname(ifindex, ifr.ifr_name);
	if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&ifr) < 0) {
		syslog(LOG_ERR, "<%s> ioctl:SIOCGIFFLAGS: failed for %s",
		       __func__, ifr.ifr_name);
		close(s);
		return (oifflags & ~IFF_UP);
	}
	close(s);
	return (ifr.ifr_flags);
}
int if_getflags ( int ifindex , int oifflags ) { struct ifreq ifr ; int s ; if ( ( s = socket ( AF_INET6 , SOCK_DGRAM , 0 ) ) < 0 ) { syslog ( LOG_ERR , " " , __func__ , strerror ( errno ) ) ; return ( oifflags & ~ IFF_UP ) ; } if_indextoname ( ifindex , ifr . ifr_name ) ; if ( ioctl ( s , SIOCGIFFLAGS , ( caddr_t ) & ifr ) < 0 ) { syslog ( LOG_ERR , " " , __func__ , ifr . ifr_name ) ; close ( s ) ; return ( oifflags & ~ IFF_UP ) ; } close ( s ) ; return ( ifr . ifr_flags ) ; }
give interface index and its old flags, then new flags returned
give interface index and its old flags then new flags returned