コード例 #1
0
static int
rc_is_myname(char *hostname)
{
	struct in6_addr 	addr;
	struct in6_addr 	**paddr;
	struct 	hostent *hp;
	int	res;

	//rc_log(LOG_NOTICE,"rc_is_myname(%s)", hostname);
	if (rc_good_ipaddr(hostname) == 0) {
		if (rc_get_ipaddr(hostname, &addr) == 0) {
			//rc_log(LOG_NOTICE,"rc_is_myname(%s) return false", hostname);
			return -1;
		}
		return rc_ipaddr_local(&addr);
	}
	if ((hp = rc_gethostbyname(hostname)) == NULL)
		return -1;
	for (paddr = (struct in6_addr**)hp->h_addr_list; *paddr; paddr++) {
		addr = **(struct in6_addr **)paddr;
		res = rc_ipaddr_local(&addr);
		if (res == 0 || res == -1) {
			//rc_log(LOG_NOTICE,"rc_is_myname(%s) return %d", hostname, res);
			return res;
		}
	}
	//rc_log(LOG_NOTICE,"rc_is_myname(%s) return 1", hostname);
	return 1;
}
コード例 #2
0
ファイル: config.c プロジェクト: benegon/freeradius-client
static int
rc_is_myname(char *hostname)
{
	uint32_t 	addr;
	char 	**paddr;
	struct 	hostent *hp;
	int	res;

	if (rc_good_ipaddr(hostname) == 0)
		return rc_ipaddr_local(ntohl(inet_addr(hostname)));

	if ((hp = rc_gethostbyname(hostname)) == NULL)
		return -1;
	for (paddr = hp->h_addr_list; *paddr; paddr++) {
		addr = **(uint32_t **)paddr;
		res = rc_ipaddr_local(ntohl(addr));
		if (res == 0 || res == -1)
			return res;
	}
	return 1;
}
コード例 #3
0
/** Checks if provided name refers to ourselves
 *
 * @param info an addrinfo of the host to check
 * @return 0 if yes, 1 if no and -1 on failure.
 */
static int rc_is_myname(const struct addrinfo *info)
{
	const struct addrinfo *p;
	int	res;

	p = info;
	while(p != NULL) {
		res = rc_ipaddr_local(p->ai_addr);
		if (res == 0 || res == -1) {
 			return res;
		}
		p = p->ai_next;
 	}
 	return 1;
}