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; }
static int find_match (uint32_t *ip_addr, char *hostname) { uint32_t addr; char **paddr; struct hostent *hp; if (rc_good_ipaddr (hostname) == 0) { if (*ip_addr == ntohl(inet_addr (hostname))) { return 0; } return -1; } if ((hp = rc_gethostbyname(hostname)) == NULL) { return -1; } for (paddr = hp->h_addr_list; *paddr; paddr++) { addr = ** (uint32_t **) paddr; if (ntohl(addr) == *ip_addr) { return 0; } } return -1; }
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; }
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; }