1
1

Move mca_btl_tcp_addr_isipv4public to opal_addr_isipv4public

This commit was SVN r14512.
Этот коммит содержится в:
Adrian Knoth 2007-04-25 18:06:06 +00:00
родитель 80d984441f
Коммит d1ce39de4f
5 изменённых файлов: 55 добавлений и 44 удалений

Просмотреть файл

@ -224,7 +224,7 @@ int mca_btl_tcp_proc_insert(
mca_btl_tcp_proc_tosocks (endpoint_addr, &endpoint_addr_ss);
/* The best we could get is IPv4 public. So let's check */
if (true == mca_oob_tcp_addr_isipv4public (&endpoint_addr_ss)) {
if (true == opal_addr_isipv4public (&endpoint_addr_ss)) {
btl_endpoint->endpoint_addr = endpoint_addr;
btl_endpoint->endpoint_addr->addr_inuse++;
return OMPI_SUCCESS;
@ -280,7 +280,7 @@ int mca_btl_tcp_proc_insert(
* Let's talk about IPv4 _private_, so isipv4public must
* return false
*/
if (false == mca_oob_tcp_addr_isipv4public (&local_ss)) {
if (false == opal_addr_isipv4public (&local_ss)) {
if (opal_samenetwork(&local_ss, &endpoint_addr_ss, netmask)) {
btl_endpoint->endpoint_addr = endpoint_addr;
btl_endpoint->endpoint_addr->addr_inuse++;

Просмотреть файл

@ -1375,6 +1375,44 @@ opal_ifislocal(char *hostname)
return false;
}
/**
* Returns true if the given address is a public IPv4 address.
*/
bool opal_addr_isipv4public (struct sockaddr_storage *addr)
{
switch (addr->ss_family) {
#if OPAL_WANT_IPV6
case AF_INET6:
return false;
#endif
case AF_INET:
{
struct sockaddr_in *inaddr = (struct sockaddr_in*) addr;
/* RFC1918 defines
- 10.0.0./8
- 172.16.0.0/12
- 192.168.0.0/16
RFC3330 also mentiones
- 169.254.0.0/16 for DHCP onlink iff there's no DHCP server
*/
if ((htonl(0x0a000000) == (inaddr->sin_addr.s_addr & opal_prefix2netmask(8))) ||
(htonl(0xac100000) == (inaddr->sin_addr.s_addr & opal_prefix2netmask(12))) ||
(htonl(0xc0a80000) == (inaddr->sin_addr.s_addr & opal_prefix2netmask(16))) ||
(htonl(0xa9fe0000) == (inaddr->sin_addr.s_addr & opal_prefix2netmask(16)))) {
return false;
}
}
return true;
default:
opal_output (0,
"unhandled sa_family %d passed to mca_oob_tcp_addr_isipv4public\n",
addr->ss_family);
}
return false;
}
#else /* HAVE_STRUCT_SOCKADDR_IN */
/* if we don't have struct sockaddr_in, we don't have traditional
@ -1480,4 +1518,9 @@ opal_iffinalize(void)
return OPAL_SUCCESS;
}
bool
opal_addr_isipv4public (struct sockaddr_storage *addr)
{
return false;
}
#endif /* HAVE_STRUCT_SOCKADDR_IN */

Просмотреть файл

@ -209,6 +209,14 @@ OPAL_DECLSPEC char* opal_sockaddr2str(struct sockaddr_in6 *addr1);
*/
OPAL_DECLSPEC int opal_iffinalize(void);
/**
* Is the given address a public IPv4 address?
*
* @param addr address as struct sockaddr_storage
* @return true, if \c addr is IPv4 public, false otherwise
*/
OPAL_DECLSPEC bool opal_addr_isipv4public(struct sockaddr_storage *addr);
#if defined(c_plusplus) || defined(__cplusplus)
}
#endif

Просмотреть файл

@ -276,11 +276,11 @@ int mca_oob_tcp_addr_get_next(mca_oob_tcp_addr_t* addr, struct sockaddr_storage*
- when IPv4private + IPv6, use IPv6 (this should
be changed when there is something like a CellID)
*/
if (true == mca_oob_tcp_addr_isipv4public (&inaddr)) {
if (true == opal_addr_isipv4public (&inaddr)) {
i_have |= MCA_OOB_TCP_ADDR_IPV4public;
}
if (true == mca_oob_tcp_addr_isipv4public ((struct sockaddr_storage*)&addr->addr_inet[i])) {
if (true == opal_addr_isipv4public ((struct sockaddr_storage*)&addr->addr_inet[i])) {
addr->addr_matched |= MCA_OOB_TCP_ADDR_IPV4public;
}
@ -365,38 +365,3 @@ int mca_oob_tcp_addr_insert(mca_oob_tcp_addr_t* addr, const struct sockaddr_in*
addr->addr_count++;
return ORTE_SUCCESS;
}
bool mca_oob_tcp_addr_isipv4public (struct sockaddr_storage *addr)
{
switch (addr->ss_family) {
#if OPAL_WANT_IPV6
case AF_INET6:
return false;
#endif
case AF_INET:
{
struct sockaddr_in *inaddr = (struct sockaddr_in*) addr;
/* RFC1918 defines
- 10.0.0./8
- 172.16.0.0/12
- 192.168.0.0/16
RFC3330 also mentiones
- 169.254.0.0/16 for DHCP onlink iff there's no DHCP server
*/
if ((htonl(0x0a000000) == (inaddr->sin_addr.s_addr & opal_prefix2netmask(8))) ||
(htonl(0xac100000) == (inaddr->sin_addr.s_addr & opal_prefix2netmask(12))) ||
(htonl(0xc0a80000) == (inaddr->sin_addr.s_addr & opal_prefix2netmask(16))) ||
(htonl(0xa9fe0000) == (inaddr->sin_addr.s_addr & opal_prefix2netmask(16)))) {
return false;
}
}
return true;
default:
opal_output (0,
"unhandled sa_family %d passed to mca_oob_tcp_addr_isipv4public\n",
addr->ss_family);
}
return false;
}

Просмотреть файл

@ -96,11 +96,6 @@ int mca_oob_tcp_addr_insert(mca_oob_tcp_addr_t*, const struct sockaddr_in*);
int mca_oob_tcp_addr_get_next(mca_oob_tcp_addr_t*, struct sockaddr_storage*);
/**
* Returns true if the given address is a public IPv4 address.
*/
bool mca_oob_tcp_addr_isipv4public(struct sockaddr_storage*);
#if defined(c_plusplus) || defined(__cplusplus)
}