OpenMPI 0.1.1

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

if.h
1 /*
2 * Copyright (c) 2010 Cisco Systems, Inc. All rights reserved.
3 * $COPYRIGHT$
4 *
5 * Additional copyrights may follow
6 *
7 * $HEADER$
8 */
9
10 #ifndef OPAL_MCA_IF_IF_H
11 #define OPAL_MCA_IF_IF_H
12
13 #include "opal_config.h"
14
15 #include <string.h>
16 #ifdef HAVE_UNISTD_H
17 #include <unistd.h>
18 #endif
19 #include <errno.h>
20 #ifdef HAVE_SYS_TYPES_H
21 #include <sys/types.h>
22 #endif
23 #ifdef HAVE_SYS_SOCKET_H
24 #include <sys/socket.h>
25 #endif
26 #ifdef HAVE_SYS_SOCKIO_H
27 #include <sys/sockio.h>
28 #endif
29 #ifdef HAVE_SYS_IOCTL_H
30 #include <sys/ioctl.h>
31 #endif
32 #ifdef HAVE_NETINET_IN_H
33 #include <netinet/in.h>
34 #endif
35 #ifdef HAVE_ARPA_INET_H
36 #include <arpa/inet.h>
37 #endif
38 #ifdef HAVE_NET_IF_H
39 #if defined(__APPLE__) && defined(_LP64)
40 /* Apple engineering suggested using options align=power as a
41 workaround for a bug in OS X 10.4 (Tiger) that prevented ioctl(...,
42 SIOCGIFCONF, ...) from working properly in 64 bit mode on Power PC.
43 It turns out that the underlying issue is the size of struct
44 ifconf, which the kernel expects to be 12 and natural 64 bit
45 alignment would make 16. The same bug appears in 64 bit mode on
46 Intel macs, but align=power is a no-op there, so instead, use the
47 pack pragma to instruct the compiler to pack on 4 byte words, which
48 has the same effect as align=power for our needs and works on both
49 Intel and Power PC Macs. */
50 #pragma pack(push,4)
51 #endif
52 #include <net/if.h>
53 #if defined(__APPLE__) && defined(_LP64)
54 #pragma pack(pop)
55 #endif
56 #endif
57 #ifdef HAVE_NETDB_H
58 #include <netdb.h>
59 #endif
60 #ifdef HAVE_IFADDRS_H
61 #include <ifaddrs.h>
62 #endif
63
64 #include "opal/util/if.h"
65 #include "opal/mca/mca.h"
66 #include "opal/mca/base/base.h"
67
68 BEGIN_C_DECLS
69
70 /*
71 * Define INADDR_NONE if we don't have it. Solaris is the only system
72 * where I have found that it does not exist, and the man page for
73 * inet_addr() says that it returns -1 upon failure. On Linux and
74 * other systems with INADDR_NONE, it's just a #define to -1 anyway.
75 * So just #define it to -1 here if it doesn't already exist.
76 */
77
78 #if !defined(INADDR_NONE)
79 #define INADDR_NONE -1
80 #endif
81
82 #define DEFAULT_NUMBER_INTERFACES 10
83 #define MAX_IFCONF_SIZE 10 * 1024 * 1024
84
85
86 typedef struct opal_if_t {
87 opal_list_item_t super;
88 char if_name[IF_NAMESIZE];
89 int if_index;
90 uint16_t if_kernel_index;
91 #ifndef __WINDOWS__
92 int if_flags;
93 #else
94 u_long if_flags;
95 #endif
96 int if_speed;
97 struct sockaddr_storage if_addr;
98 uint32_t if_mask;
99 #ifdef __WINDOWS__
100 struct sockaddr_in if_bcast;
101 #endif
102 uint32_t if_bandwidth;
103 } opal_if_t;
104 OPAL_DECLSPEC OBJ_CLASS_DECLARATION(opal_if_t);
105
106
107 /* "global" list of available interfaces */
108 OPAL_DECLSPEC extern opal_list_t opal_if_list;
109
110 /* global flags */
111 OPAL_DECLSPEC extern bool opal_if_do_not_resolve;
112 OPAL_DECLSPEC extern bool opal_if_retain_loopback;
113
114 /**
115 * Structure for if components.
116 */
117 struct opal_if_base_component_2_0_0_t {
118 /** MCA base component */
119 mca_base_component_t component;
120 /** MCA base data */
121 mca_base_component_data_t component_data;
122 };
123 /**
124 * Convenience typedef
125 */
126 typedef struct opal_if_base_component_2_0_0_t opal_if_base_component_t;
127
128 /*
129 * Macro for use in components that are of type if
130 */
131 #define OPAL_IF_BASE_VERSION_2_0_0 \
132 MCA_BASE_VERSION_2_0_0, \
133 "if", 2, 0, 0
134
135 END_C_DECLS
136
137 #endif /* OPAL_MCA_IF_IF_H */
mca_base_component_2_0_0_t
Common type for all MCA components.
Definition: mca.h:250
opal_if_base_component_2_0_0_t::component_data
mca_base_component_data_t component_data
MCA base data.
Definition: if.h:121
opal_if_base_component_2_0_0_t
Structure for if components.
Definition: if.h:117
opal_if_base_component_2_0_0_t::component
mca_base_component_t component
MCA base component.
Definition: if.h:119
mca.h
Top-level interface for all MCA components.
opal_list_item_t
Definition: opal_list.h:98
opal_if_t
Definition: if.h:86
sockaddr_storage
Definition: util-internal.h:214
mca_base_component_data_2_0_0_t
Meta data for MCA v2.0.0 components.
Definition: mca.h:309
opal_list_t
Definition: opal_list.h:147
OBJ_CLASS_DECLARATION
#define OBJ_CLASS_DECLARATION(NAME)
Declaration for class descriptor.
Definition: opal_object.h:236