Add a function to return the aliases (based on IP addrs) for the current node
This commit was SVN r27618.
Этот коммит содержится в:
родитель
657225ff61
Коммит
a52071a17d
@ -659,6 +659,41 @@ int opal_ifmatches(int idx, char **nets)
|
||||
return OPAL_ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
void opal_ifgetaliases(char ***aliases)
|
||||
{
|
||||
opal_if_t* intf;
|
||||
char ipv4[INET_ADDRSTRLEN];
|
||||
struct sockaddr_in *addr;
|
||||
#if OPAL_ENABLE_IPV6
|
||||
char ipv6[INET6_ADDRSTRLEN];
|
||||
struct sockaddr_in6 *addr6;
|
||||
#endif
|
||||
|
||||
if (OPAL_SUCCESS != opal_if_base_open()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (intf = (opal_if_t*)opal_list_get_first(&opal_if_list);
|
||||
intf != (opal_if_t*)opal_list_get_end(&opal_if_list);
|
||||
intf = (opal_if_t*)opal_list_get_next(intf)) {
|
||||
addr = (struct sockaddr_in*) &intf->if_addr;
|
||||
/* ignore purely loopback interfaces */
|
||||
if ((intf->if_flags & IFF_LOOPBACK) != 0) {
|
||||
continue;
|
||||
}
|
||||
if (addr->sin_family == AF_INET) {
|
||||
inet_ntop(AF_INET, &(addr->sin_addr.s_addr), ipv4, INET_ADDRSTRLEN);
|
||||
opal_argv_append_nosize(aliases, ipv4);
|
||||
}
|
||||
#if OPAL_ENABLE_IPV6
|
||||
else {
|
||||
addr6 = (struct sockaddr_in6*) &intf->if_addr;
|
||||
inet_ntop(AF_INET6, &(addr6->sin6_addr), ipv6, INET6_ADDRSTRLEN);
|
||||
opal_argv_append_nosize(aliases, ipv6);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#else /* HAVE_STRUCT_SOCKADDR_IN */
|
||||
|
||||
@ -756,5 +791,9 @@ int opal_ifmatches(int idx, char **nets)
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
void opal_ifgetaliases(char ***aliases)
|
||||
{
|
||||
}
|
||||
|
||||
#endif /* HAVE_STRUCT_SOCKADDR_IN */
|
||||
|
||||
|
@ -193,6 +193,11 @@ OPAL_DECLSPEC bool opal_ifisloopback(int if_index);
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_ifmatches(int idx, char **nets);
|
||||
|
||||
/*
|
||||
* Provide a list of strings that contain all known aliases for this node
|
||||
*/
|
||||
OPAL_DECLSPEC void opal_ifgetaliases(char ***aliases);
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
#endif
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user