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 项目: springware/92u10
static int find_match (UINT4 *ip_addr, char *hostname)
{
	UINT4           addr;
	char          **paddr;
	struct hostent *hp;

	if (rc_good_ipaddr (hostname) == 0)
	{
		if (*ip_addr == ntohl(inet_addr (hostname)))
		{
			return (0);
		}
	}
	else
	{
		if ((hp = gethostbyname (hostname)) == (struct hostent *) NULL)
		{
			return (-1);
		}
		for (paddr = hp->h_addr_list; *paddr; paddr++)
		{
			addr = ** (UINT4 **) paddr;
			if (ntohl(addr) == *ip_addr)
			{
				return (0);
			}
		}
	}
	return (-1);
}
示例#3
0
UINT4 rc_get_ipaddr (char *host)
{
	struct hostent *hp;

	if (rc_good_ipaddr (host) == 0)
	{
		return ntohl(inet_addr (host));
	}
	else if ((hp = gethostbyname (host)) == (struct hostent *) NULL)
	{
		error("rc_get_ipaddr: couldn't resolve hostname: %s", host);
		return ((UINT4) 0);
	}
	return ntohl((*(UINT4 *) hp->h_addr));
}
static int find_match (struct in6_addr *ip_addr, char *hostname)
{

	struct in6_addr  addr;
	char           **paddr;
	struct hostent  *hp;

	//rc_log(LOG_NOTICE,"find_match(%x:%x:%x:%x:%x:%x:%x:%x/%s)\n", NIP6ADDR(ip_addr), hostname);
	if (rc_good_ipaddr (hostname) == 0)
	{
		if (rc_get_ipaddr(hostname, &addr) == 0) {
			//rc_log(LOG_NOTICE,"find_match %x:%x:%x:%x:%x:%x:%x:%x/%s Success@1\n", NIP6ADDR(ip_addr), hostname);
			return 0;
		}
		if (IN6_ARE_ADDR_EQUAL(ip_addr, &addr))
		{
			//rc_log(LOG_NOTICE,"find_match %x:%x:%x:%x:%x:%x:%x:%x/%s Success@2\n", NIP6ADDR(ip_addr), hostname);
			return 0;
		}
		//rc_log(LOG_NOTICE,"find_match %x:%x:%x:%x:%x:%x:%x:%x/%s Failed@3\n", NIP6ADDR(ip_addr), hostname);
		return -1;
	}

	if ((hp = rc_gethostbyname(hostname)) == NULL)
	{
		//rc_log(LOG_NOTICE,"find_match %x:%x:%x:%x:%x:%x:%x:%x/%s Failed@4\n", NIP6ADDR(ip_addr), hostname);
		return -1;
	}

	for (paddr = hp->h_addr_list; *paddr; paddr++)
	{
		addr = ** (struct in6_addr **) paddr;

		//rc_log(LOG_NOTICE,"find_match Compare %x:%x:%x:%x:%x:%x:%x:%x/%x:%x:%x:%x:%x:%x:%x:%x\n", NIP6ADDR(ip_addr), NIP6ADDR(&addr));
		if (IN6_ARE_ADDR_EQUAL(ip_addr, &addr))
		{
			//rc_log(LOG_NOTICE,"find_match %x:%x:%x:%x:%x:%x:%x:%x/%s Success@5\n", NIP6ADDR(ip_addr), hostname);
			return 0;
		}
	}
	//rc_log(LOG_NOTICE,"find_match %x:%x:%x:%x:%x:%x:%x:%x/%s Failed@6\n", NIP6ADDR(ip_addr), hostname);
	return -1;
}
示例#5
0
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;
}