diff options
author | ng0 <ng0@n0.is> | 2019-09-08 12:33:09 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2019-09-08 12:33:09 +0000 |
commit | d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb (patch) | |
tree | 9efd18ea7d425652085ed0bd5e8e45604bc5f6b9 /src/nat/test_nat_mini.c | |
parent | a0fce305c565c0937d917a92712f15e9c5736260 (diff) | |
download | gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.tar.gz gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.zip |
uncrustify as demanded.
Diffstat (limited to 'src/nat/test_nat_mini.c')
-rw-r--r-- | src/nat/test_nat_mini.c | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/src/nat/test_nat_mini.c b/src/nat/test_nat_mini.c index 8a7ff16f4..09231d8ec 100644 --- a/src/nat/test_nat_mini.c +++ b/src/nat/test_nat_mini.c | |||
@@ -11,12 +11,12 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * Testcase for port redirection and public IP address retrieval. | 22 | * Testcase for port redirection and public IP address retrieval. |
@@ -35,31 +35,31 @@ | |||
35 | #include "gnunet_nat_lib.h" | 35 | #include "gnunet_nat_lib.h" |
36 | 36 | ||
37 | /* Time to wait before stopping NAT, in seconds */ | 37 | /* Time to wait before stopping NAT, in seconds */ |
38 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) | 38 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5) |
39 | 39 | ||
40 | /** | 40 | /** |
41 | * Function called on each address that the NAT service | 41 | * Function called on each address that the NAT service |
42 | * believes to be valid for the transport. | 42 | * believes to be valid for the transport. |
43 | */ | 43 | */ |
44 | static void | 44 | static void |
45 | addr_callback (void *cls, int add_remove, | 45 | addr_callback(void *cls, int add_remove, |
46 | const struct sockaddr *addr, | 46 | const struct sockaddr *addr, |
47 | socklen_t addrlen, | 47 | socklen_t addrlen, |
48 | enum GNUNET_NAT_StatusCode ret) | 48 | enum GNUNET_NAT_StatusCode ret) |
49 | { | 49 | { |
50 | if (GNUNET_NAT_ERROR_SUCCESS == ret) | 50 | if (GNUNET_NAT_ERROR_SUCCESS == ret) |
51 | { | 51 | { |
52 | fprintf (stderr, | 52 | fprintf(stderr, |
53 | "Address changed: %s `%s' (%u bytes)\n", | 53 | "Address changed: %s `%s' (%u bytes)\n", |
54 | add_remove == GNUNET_YES | 54 | add_remove == GNUNET_YES |
55 | ? "added" : "removed", | 55 | ? "added" : "removed", |
56 | GNUNET_a2s (addr, | 56 | GNUNET_a2s(addr, |
57 | addrlen), | 57 | addrlen), |
58 | (unsigned int) addrlen); | 58 | (unsigned int)addrlen); |
59 | } | 59 | } |
60 | else | 60 | else |
61 | ; | 61 | ; |
62 | //TODO: proper error handling! | 62 | //TODO: proper error handling! |
63 | } | 63 | } |
64 | 64 | ||
65 | 65 | ||
@@ -67,12 +67,12 @@ addr_callback (void *cls, int add_remove, | |||
67 | * Function that terminates the test. | 67 | * Function that terminates the test. |
68 | */ | 68 | */ |
69 | static void | 69 | static void |
70 | stop (void *cls) | 70 | stop(void *cls) |
71 | { | 71 | { |
72 | struct GNUNET_NAT_MiniHandle *mini = cls; | 72 | struct GNUNET_NAT_MiniHandle *mini = cls; |
73 | 73 | ||
74 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stopping NAT and quitting...\n"); | 74 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Stopping NAT and quitting...\n"); |
75 | GNUNET_NAT_mini_map_stop (mini); | 75 | GNUNET_NAT_mini_map_stop(mini); |
76 | } | 76 | } |
77 | 77 | ||
78 | #define PORT 10000 | 78 | #define PORT 10000 |
@@ -81,27 +81,27 @@ stop (void *cls) | |||
81 | * Main function run with scheduler. | 81 | * Main function run with scheduler. |
82 | */ | 82 | */ |
83 | static void | 83 | static void |
84 | run (void *cls, char *const *args, const char *cfgfile, | 84 | run(void *cls, char *const *args, const char *cfgfile, |
85 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 85 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
86 | { | 86 | { |
87 | struct GNUNET_NAT_MiniHandle *mini; | 87 | struct GNUNET_NAT_MiniHandle *mini; |
88 | 88 | ||
89 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 89 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
90 | "Requesting NAT redirection for port %u...\n", | 90 | "Requesting NAT redirection for port %u...\n", |
91 | PORT); | 91 | PORT); |
92 | mini = GNUNET_NAT_mini_map_start (PORT, GNUNET_YES /* tcp */ , | 92 | mini = GNUNET_NAT_mini_map_start(PORT, GNUNET_YES /* tcp */, |
93 | &addr_callback, NULL); | 93 | &addr_callback, NULL); |
94 | if (NULL == mini) | 94 | if (NULL == mini) |
95 | { | 95 | { |
96 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Could not start UPnP interaction\n"); | 96 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Could not start UPnP interaction\n"); |
97 | return; | 97 | return; |
98 | } | 98 | } |
99 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &stop, mini); | 99 | GNUNET_SCHEDULER_add_delayed(TIMEOUT, &stop, mini); |
100 | } | 100 | } |
101 | 101 | ||
102 | 102 | ||
103 | int | 103 | int |
104 | main (int argc, char *const argv[]) | 104 | main(int argc, char *const argv[]) |
105 | { | 105 | { |
106 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 106 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
107 | GNUNET_GETOPT_OPTION_END | 107 | GNUNET_GETOPT_OPTION_END |
@@ -116,16 +116,16 @@ main (int argc, char *const argv[]) | |||
116 | NULL | 116 | NULL |
117 | }; | 117 | }; |
118 | 118 | ||
119 | GNUNET_log_setup ("test-nat-mini", | 119 | GNUNET_log_setup("test-nat-mini", |
120 | "WARNING", | 120 | "WARNING", |
121 | NULL); | 121 | NULL); |
122 | 122 | ||
123 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 123 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
124 | "UPnP test for NAT library, timeout set to %s\n", | 124 | "UPnP test for NAT library, timeout set to %s\n", |
125 | GNUNET_STRINGS_relative_time_to_string (TIMEOUT, | 125 | GNUNET_STRINGS_relative_time_to_string(TIMEOUT, |
126 | GNUNET_YES)); | 126 | GNUNET_YES)); |
127 | GNUNET_PROGRAM_run (5, argv_prog, "test-nat-mini", "nohelp", options, &run, | 127 | GNUNET_PROGRAM_run(5, argv_prog, "test-nat-mini", "nohelp", options, &run, |
128 | NULL); | 128 | NULL); |
129 | return 0; | 129 | return 0; |
130 | } | 130 | } |
131 | 131 | ||