This source file includes following definitions.
- create_if
- run_single_test
1
2
3
4
5
6
7
8
9
10
11 #ifndef TEST_REACHABLE_SHARED
12 #define TEST_REACHABLE_SHARED 1
13
14 #include <assert.h>
15
16 #include "opal/runtime/opal.h"
17 #include "opal/mca/reachable/reachable.h"
18 #include "opal/util/if.h"
19 #include "opal/util/string_copy.h"
20
21 BEGIN_C_DECLS
22
23
24 opal_if_t* create_if(int af_family, char *address, int mask, int bandwidth)
25 {
26 opal_if_t *interface = OBJ_NEW(opal_if_t);
27 opal_string_copy(interface->if_name, "interface0", IF_NAMESIZE);
28 interface->af_family = af_family;
29 ((struct sockaddr *)&(interface->if_addr))->sa_family = af_family;
30
31 if (AF_INET == af_family){
32 assert(1 == inet_pton(af_family, address, &((struct sockaddr_in *)&(interface->if_addr))->sin_addr));
33 } else if (AF_INET6 == af_family){
34 assert(1 == inet_pton(af_family, address, &((struct sockaddr_in6 *)&(interface->if_addr))->sin6_addr));
35 }
36
37 interface->if_mask = mask;
38 interface->if_bandwidth = bandwidth;
39
40 return interface;
41 }
42
43
44
45
46
47
48
49 int run_single_test(opal_if_t *local_if, opal_if_t *remote_if)
50 {
51
52 opal_list_t *local_list = OBJ_NEW(opal_list_t);
53 opal_list_t *remote_list = OBJ_NEW(opal_list_t);
54
55 opal_list_append(local_list, &(local_if->super));
56 opal_list_append(remote_list, &(remote_if->super));
57
58 opal_reachable_t *results;
59 results = opal_reachable.reachable(local_list, remote_list);
60 OBJ_RELEASE(local_list);
61 OBJ_RELEASE(remote_list);
62 int result = results->weights[0][0];
63
64
65 OBJ_RELEASE(results);
66 return result;
67 }
68
69 END_C_DECLS
70
71 #endif