FreeBSD/contrib/ntp/lib/isc/win32/interfaceiter.c
/*
 * Get information about the current interface to iter->current.
 * If successful, return ISC_R_SUCCESS.
 * If the interface has an unsupported address family, or if
 * some operation on it fails, return ISC_R_IGNORE to make
 * the higher-level iterator code ignore it.
 */
Get information about the current interface to iter->current.
If successful, return ISC_R_SUCCESS.
If the interface has an unsupported address family, or if
some operation on it fails, return ISC_R_IGNORE to make
the higher-level iterator code ignore it.
Get information about the current interface to iter - > current . If successful return ISC_R_SUCCESS . If the interface has an unsupported address family or if some operation on it fails return ISC_R_IGNORE to make the higher - level iterator code ignore it .
static isc_result_t
internal_current(isc_interfaceiter_t *iter) {
	BOOL ifNamed = FALSE;
	unsigned long flags;
	REQUIRE(VALID_IFITER(iter));
	REQUIRE(iter->numIF >= 0);
	memset(&iter->current, 0, sizeof(iter->current));
	iter->current.af = AF_INET;
	isc_netaddr_fromsockaddr(&iter->current.address,
	    (isc_sockaddr_t *)&(iter->IFData.iiAddress));
	iter->current.flags = 0;
	flags = iter->IFData.iiFlags;
	if ((flags & IFF_UP) != 0)
		iter->current.flags |= INTERFACE_F_UP;
	if ((flags & IFF_BROADCAST) != 0)
		iter->current.flags |= INTERFACE_F_BROADCAST;
	if ((flags & IFF_MULTICAST) != 0)
		iter->current.flags |= INTERFACE_F_MULTICAST;
	if ((flags & IFF_POINTTOPOINT) != 0) {
		iter->current.flags |= INTERFACE_F_POINTTOPOINT;
		snprintf(iter->current.name, sizeof(iter->current.name),
			 "PPP %d", iter->numIF);
		ifNamed = TRUE;
	}
	if ((flags & IFF_LOOPBACK) != 0) {
		iter->current.flags |= INTERFACE_F_LOOPBACK;
		snprintf(iter->current.name, sizeof(iter->current.name),
			"v4loop %d", iter->numIF);
		ifNamed = TRUE;
	}
	if ((iter->current.flags & INTERFACE_F_POINTTOPOINT) != 0)
		isc_netaddr_fromsockaddr(&iter->current.dstaddress,
		    (isc_sockaddr_t *)&(iter->IFData.iiBroadcastAddress));
	isc_netaddr_fromsockaddr(&iter->current.netmask,
	    (isc_sockaddr_t *)&(iter->IFData.iiNetmask));
	if ((iter->current.flags & INTERFACE_F_BROADCAST) != 0)
		get_broadcastaddr(&iter->current.broadcast,
				  &iter->current.address,
				  &iter->current.netmask);
	if (ifNamed == FALSE)
		snprintf(iter->current.name, sizeof(iter->current.name),
			"IPv4 %d", iter->numIF);
	return (ISC_R_SUCCESS);
}
static isc_result_t internal_current ( isc_interfaceiter_t * iter ) { BOOL ifNamed = FALSE ; unsigned long flags ; REQUIRE ( VALID_IFITER ( iter ) ) ; REQUIRE ( iter -> numIF >= 0 ) ; memset ( & iter -> current , 0 , sizeof ( iter -> current ) ) ; iter -> current . af = AF_INET ; isc_netaddr_fromsockaddr ( & iter -> current . address , ( isc_sockaddr_t * ) & ( iter -> IFData . iiAddress ) ) ; iter -> current . flags = 0 ; flags = iter -> IFData . iiFlags ; if ( ( flags & IFF_UP ) != 0 ) iter -> current . flags |= INTERFACE_F_UP ; if ( ( flags & IFF_BROADCAST ) != 0 ) iter -> current . flags |= INTERFACE_F_BROADCAST ; if ( ( flags & IFF_MULTICAST ) != 0 ) iter -> current . flags |= INTERFACE_F_MULTICAST ; if ( ( flags & IFF_POINTTOPOINT ) != 0 ) { iter -> current . flags |= INTERFACE_F_POINTTOPOINT ; snprintf ( iter -> current . name , sizeof ( iter -> current . name ) , " " , iter -> numIF ) ; ifNamed = TRUE ; } if ( ( flags & IFF_LOOPBACK ) != 0 ) { iter -> current . flags |= INTERFACE_F_LOOPBACK ; snprintf ( iter -> current . name , sizeof ( iter -> current . name ) , " " , iter -> numIF ) ; ifNamed = TRUE ; } if ( ( iter -> current . flags & INTERFACE_F_POINTTOPOINT ) != 0 ) isc_netaddr_fromsockaddr ( & iter -> current . dstaddress , ( isc_sockaddr_t * ) & ( iter -> IFData . iiBroadcastAddress ) ) ; isc_netaddr_fromsockaddr ( & iter -> current . netmask , ( isc_sockaddr_t * ) & ( iter -> IFData . iiNetmask ) ) ; if ( ( iter -> current . flags & INTERFACE_F_BROADCAST ) != 0 ) get_broadcastaddr ( & iter -> current . broadcast , & iter -> current . address , & iter -> current . netmask ) ; if ( ifNamed == FALSE ) snprintf ( iter -> current . name , sizeof ( iter -> current . name ) , " " , iter -> numIF ) ; return ( ISC_R_SUCCESS ) ; }
Get information about the current interface to iter->current.
Get information about the current interface to iter - > current .
/*
	 * Get interface flags.
	 */ /*
	 * If the interface is point-to-point, get the destination address.
	 */ /*
	 * Get the network mask.
	 */ /*
	 * If the interface is broadcast, get the broadcast address,
	 * based on the unicast address and network mask.
	 */