Skip to content

Commit

Permalink
Updated configuration processing to deal with hosts that don't suppor…
Browse files Browse the repository at this point in the history
…t IPv6
  • Loading branch information
massie committed Jun 10, 2004
1 parent 8f9a594 commit f440479
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
8 changes: 7 additions & 1 deletion monitor-core/gmetad/conf.c
Expand Up @@ -83,7 +83,11 @@ static DOTCONF_CB(cb_trusted_hosts)
le = (llist_entry *)malloc(sizeof(llist_entry));

info = host_serv( cmd->data.list[i], NULL, AF_UNSPEC, SOCK_STREAM);
if(!info || (info->ai_family != AF_INET && info->ai_family != AF_INET6))
if(!info || (info->ai_family != AF_INET
#ifdef AF_INET6
&& info->ai_family != AF_INET6
#endif
))
{
err_msg("Warning: %s is not being added as a trusted host",
cmd->data.list[i]);
Expand All @@ -98,7 +102,9 @@ static DOTCONF_CB(cb_trusted_hosts)
}
else
{
#ifdef AF_INET6
addr = &(((struct sockaddr_in6 *)info->ai_addr )->sin6_addr);
#endif
}

inet_ntop(info->ai_family, addr, le->val, INET6_ADDRSTRLEN);
Expand Down
12 changes: 9 additions & 3 deletions monitor-core/gmond/conf.c
Expand Up @@ -395,25 +395,31 @@ static DOTCONF_CB(cb_trusted_hosts)
{
le = (llist_entry *)malloc(sizeof(llist_entry));
info = host_serv( cmd->data.list[i], NULL, AF_UNSPEC, SOCK_STREAM);
if(!info || (info->ai_family != AF_INET && info->ai_family != AF_INET6))
if(!info || (info->ai_family != AF_INET
#ifdef AF_INET6
&& info->ai_family != AF_INET6
#endif
))
{
err_msg("Warning: %s is not being added as a trusted host",
cmd->data.list[i]);
continue;
}

le->val = (char*) malloc(INET6_ADDRSTRLEN + 1);
le->val = (char*) malloc(64 + 1);

if( info->ai_family == AF_INET )
{
addr = &(((struct sockaddr_in *) info->ai_addr )->sin_addr);
}
else
{
#ifdef AF_INET6
addr = &(((struct sockaddr_in6 *)info->ai_addr )->sin6_addr);
#endif
}

inet_ntop(info->ai_family, addr, le->val, INET6_ADDRSTRLEN);
inet_ntop(info->ai_family, addr, le->val, 64);

/* printf("Adding trusted host %s (IP %s)\n", cmd->data.list[i], le->val); */
llist_add(&(c->trusted_hosts), le);
Expand Down

0 comments on commit f440479

Please sign in to comment.