OpenMPI
0.1.1
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
net.h
1
/*
2
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
3
* University Research and Technology
4
* Corporation. All rights reserved.
5
* Copyright (c) 2004-2005 The University of Tennessee and The University
6
* of Tennessee Research Foundation. All rights
7
* reserved.
8
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9
* University of Stuttgart. All rights reserved.
10
* Copyright (c) 2004-2005 The Regents of the University of California.
11
* All rights reserved.
12
* Copyright (c) 2007 Los Alamos National Security, LLC. All rights
13
* reserved.
14
* $COPYRIGHT$
15
*
16
* Additional copyrights may follow
17
*
18
* $HEADER$
19
*/
20
21
/* @file */
22
23
#ifndef OPAL_UTIL_NET_H
24
#define OPAL_UTIL_NET_H
25
26
#include "opal_config.h"
27
28
#ifdef HAVE_SYS_TYPES_H
29
#include <sys/types.h>
30
#endif
31
#ifdef HAVE_SYS_SOCKET_H
32
#include <sys/socket.h>
33
#endif
34
#ifdef HAVE_NETINET_IN_H
35
#include <netinet/in.h>
36
#endif
37
38
BEGIN_C_DECLS
39
40
/**
41
* Intiailize the network helper subsystem
42
*
43
* Initialize the network helper subsystem. Should be called exactly
44
* once for any process that will use any function in the network
45
* helper subsystem.
46
*
47
* @retval OPAL_SUCCESS Success
48
* @retval OPAL_ERR_TEMP_OUT_OF_RESOURCE Not enough memory for static
49
* buffer creation
50
*/
51
OPAL_DECLSPEC
int
opal_net_init(
void
);
52
53
54
/**
55
* Finalize the network helper subsystem
56
*
57
* Finalize the network helper subsystem. Should be called exactly
58
* once for any process that will use any function in the network
59
* helper subsystem.
60
*
61
* @retval OPAL_SUCCESS Success
62
*/
63
OPAL_DECLSPEC
int
opal_net_finalize(
void
);
64
65
66
/**
67
* Calculate netmask in network byte order from CIDR notation
68
*
69
* @param prefixlen (IN) CIDR prefixlen
70
* @return netmask in network byte order
71
*/
72
OPAL_DECLSPEC uint32_t opal_net_prefix2netmask(uint32_t prefixlen);
73
74
75
/**
76
* Determine if given IP address is in the localhost range
77
*
78
* Determine if the given IP address is in the localhost range
79
* (127.0.0.0/8), meaning that it can't be used to connect to machines
80
* outside the current host.
81
*
82
* @param addr struct sockaddr_in of IP address
83
* @return true if \c addr is a localhost address,
84
* false otherwise.
85
*/
86
OPAL_DECLSPEC
bool
opal_net_islocalhost(
const
struct
sockaddr *addr);
87
88
89
/**
90
* Are we on the same network?
91
*
92
* For IPv6, we only need to check for /64, there are no other
93
* local netmasks.
94
*
95
* @param addr1 struct sockaddr of address
96
* @param addr2 struct sockaddr of address
97
* @param prefixlen netmask (either CIDR oder IPv6 prefixlen)
98
* @return true if \c addr1 and \c addr2 are on the
99
* same net, false otherwise.
100
*/
101
OPAL_DECLSPEC
bool
opal_net_samenetwork(
const
struct
sockaddr *addr1,
102
const
struct
sockaddr *addr2,
103
uint32_t prefixlen);
104
105
106
/**
107
* Is the given address a public IPv4 address? Returns false for IPv6
108
* address.
109
*
110
* @param addr address as struct sockaddr
111
* @return true, if \c addr is IPv4 public, false otherwise
112
*/
113
OPAL_DECLSPEC
bool
opal_net_addr_isipv4public(
const
struct
sockaddr *addr);
114
115
116
/**
117
* Get string version of address
118
*
119
* Return the un-resolved address in a string format. The string will
120
* be returned in a per-thread static buffer and should not be freed
121
* by the user.
122
*
123
* @param addr struct sockaddr of address
124
* @return literal representation of \c addr
125
*/
126
OPAL_DECLSPEC
char
* opal_net_get_hostname(
const
struct
sockaddr *addr);
127
128
129
/**
130
* Get port number from struct sockaddr
131
*
132
* Return the port number (as an integr) from either a struct
133
* sockaddr_in or a struct sockaddr_in6.
134
*
135
* @param addr struct sockaddr containing address
136
* @return port number from \addr
137
*/
138
OPAL_DECLSPEC
int
opal_net_get_port(
const
struct
sockaddr *addr);
139
140
END_C_DECLS
141
142
#endif
/* OPAL_UTIL_NET_H */
opal
util
net.h
Generated on Wed Dec 24 2014 12:05:29 for OpenMPI by
1.8.8