2004-01-14 21:24:30 +03:00
|
|
|
/* @file */
|
|
|
|
/*
|
2004-11-22 04:38:40 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University.
|
|
|
|
* All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
|
|
|
|
* All rights reserved.
|
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-01-14 21:24:30 +03:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
#ifndef _OMPI_IF_UTIL_
|
|
|
|
#define _OMPI_IF_UTIL_
|
2004-01-14 21:24:30 +03:00
|
|
|
|
2004-10-22 20:06:05 +04:00
|
|
|
#include "ompi_config.h"
|
2004-10-20 05:03:09 +04:00
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
2004-01-15 20:43:54 +03:00
|
|
|
#include <sys/types.h>
|
2004-10-20 05:03:09 +04:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_SOCKET_H
|
2004-01-15 20:43:54 +03:00
|
|
|
#include <sys/socket.h>
|
2004-10-20 05:03:09 +04:00
|
|
|
#endif
|
2004-10-28 22:13:43 +04:00
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2004-01-15 20:43:54 +03:00
|
|
|
|
2004-01-14 21:24:30 +03:00
|
|
|
/**
|
|
|
|
* Lookup an interface by name and return its primary address.
|
|
|
|
*
|
|
|
|
* @param if_name (IN) Interface name
|
|
|
|
* @param if_addr (OUT) Interface address buffer
|
|
|
|
* @param size (IN) Interface address buffer size
|
|
|
|
*/
|
2004-11-01 17:18:30 +03:00
|
|
|
OMPI_DECLSPEC int ompi_ifnametoaddr(const char* if_name,
|
|
|
|
struct sockaddr* if_addr, int size);
|
2004-01-14 21:24:30 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Lookup an interface by address and return its name.
|
|
|
|
*
|
2004-11-01 17:18:30 +03:00
|
|
|
* @param if_addr (IN) Interface address (hostname or dotted-quad)
|
|
|
|
* @param if_name (OUT) Interface name buffer
|
2004-01-14 21:24:30 +03:00
|
|
|
* @param size (IN) Interface name buffer size
|
|
|
|
*/
|
2004-11-01 17:18:30 +03:00
|
|
|
OMPI_DECLSPEC int ompi_ifaddrtoname(const char* if_addr,
|
|
|
|
char* if_name, int size);
|
2004-01-14 21:24:30 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Lookup an interface by name and return its kernel index.
|
|
|
|
*
|
|
|
|
* @param if_name (IN) Interface name
|
|
|
|
* @return Interface index
|
|
|
|
*/
|
2004-10-22 20:06:05 +04:00
|
|
|
OMPI_DECLSPEC int ompi_ifnametoindex(const char* if_name);
|
2004-01-14 21:24:30 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the number of available interfaces.
|
|
|
|
*/
|
2004-10-22 20:06:05 +04:00
|
|
|
OMPI_DECLSPEC int ompi_ifcount(void);
|
2004-01-14 21:24:30 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the index of the first available interface.
|
|
|
|
*/
|
2004-10-22 20:06:05 +04:00
|
|
|
OMPI_DECLSPEC int ompi_ifbegin(void);
|
2004-01-14 21:24:30 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Lookup the current position in the interface list by
|
|
|
|
* index and return the next available index (if it exists).
|
|
|
|
*
|
|
|
|
* @param if_index Returns the next available index from the
|
|
|
|
* current position.
|
|
|
|
*/
|
2004-10-22 20:06:05 +04:00
|
|
|
OMPI_DECLSPEC int ompi_ifnext(int if_index);
|
2004-01-14 21:24:30 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Lookup an interface by index and return its name.
|
|
|
|
*
|
|
|
|
* @param if_index (IN) Interface index
|
|
|
|
* @param if_name (OUT) Interface name buffer
|
|
|
|
* @param size (IN) Interface name buffer size
|
|
|
|
*/
|
2004-10-22 20:06:05 +04:00
|
|
|
OMPI_DECLSPEC int ompi_ifindextoname(int if_index, char* if_name, int);
|
2004-01-14 21:24:30 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Lookup an interface by index and return its primary address .
|
|
|
|
*
|
|
|
|
* @param if_index (IN) Interface index
|
|
|
|
* @param if_name (OUT) Interface address buffer
|
|
|
|
* @param size (IN) Interface address buffer size
|
|
|
|
*/
|
2004-10-22 20:06:05 +04:00
|
|
|
OMPI_DECLSPEC int ompi_ifindextoaddr(int if_index, struct sockaddr*, int);
|
2004-01-14 21:24:30 +03:00
|
|
|
|
2004-01-26 21:41:37 +03:00
|
|
|
/**
|
|
|
|
* Lookup an interface by index and return its network mask.
|
|
|
|
*
|
|
|
|
* @param if_index (IN) Interface index
|
|
|
|
* @param if_name (OUT) Interface address buffer
|
|
|
|
* @param size (IN) Interface address buffer size
|
|
|
|
*/
|
2004-10-22 20:06:05 +04:00
|
|
|
OMPI_DECLSPEC int ompi_ifindextomask(int if_index, struct sockaddr*, int);
|
2004-10-31 22:01:53 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine if given hostname / IP address is a local address
|
|
|
|
*
|
|
|
|
* @param hostname (IN) Hostname (or stringified IP address)
|
|
|
|
* @return true if \c hostname is local, false otherwise
|
|
|
|
*/
|
|
|
|
OMPI_DECLSPEC bool ompi_ifislocal(char *hostname);
|
|
|
|
|
2004-10-28 22:13:43 +04:00
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
2004-01-26 21:41:37 +03:00
|
|
|
|
2004-01-14 21:24:30 +03:00
|
|
|
#endif
|
|
|
|
|