diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-10-11 09:43:04 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-10-11 09:43:04 +0000 |
commit | d9d94d0e53d26af75ec8241383d166544ebd79f3 (patch) | |
tree | 9080b73624389403a198257fe0547bb4634e64d2 /src/util/test_connection_addressing.c | |
parent | 2d792ee2e9cc0c993b8907e2c8edb0c2b8465343 (diff) | |
download | gnunet-d9d94d0e53d26af75ec8241383d166544ebd79f3.tar.gz gnunet-d9d94d0e53d26af75ec8241383d166544ebd79f3.zip |
converting to GNUNET_LOG_from*
Diffstat (limited to 'src/util/test_connection_addressing.c')
-rw-r--r-- | src/util/test_connection_addressing.c | 69 |
1 files changed, 35 insertions, 34 deletions
diff --git a/src/util/test_connection_addressing.c b/src/util/test_connection_addressing.c index 018cf61fb..c413c18c8 100644 --- a/src/util/test_connection_addressing.c +++ b/src/util/test_connection_addressing.c | |||
@@ -66,15 +66,16 @@ open_listen_socket () | |||
66 | GNUNET_assert (desc != 0); | 66 | GNUNET_assert (desc != 0); |
67 | if (GNUNET_NETWORK_socket_setsockopt | 67 | if (GNUNET_NETWORK_socket_setsockopt |
68 | (desc, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) != GNUNET_OK) | 68 | (desc, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) != GNUNET_OK) |
69 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "setsockopt"); | 69 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
70 | "setsockopt"); | ||
70 | if (GNUNET_OK != | 71 | if (GNUNET_OK != |
71 | GNUNET_NETWORK_socket_bind (desc, (const struct sockaddr *) &sa, | 72 | GNUNET_NETWORK_socket_bind (desc, (const struct sockaddr *) &sa, |
72 | sizeof (sa))) | 73 | sizeof (sa))) |
73 | { | 74 | { |
74 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 75 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
75 | "bind"); | 76 | "bind"); |
76 | GNUNET_assert (0); | 77 | GNUNET_assert (0); |
77 | } | 78 | } |
78 | GNUNET_NETWORK_socket_listen (desc, 5); | 79 | GNUNET_NETWORK_socket_listen (desc, 5); |
79 | return desc; | 80 | return desc; |
80 | } | 81 | } |
@@ -82,25 +83,25 @@ open_listen_socket () | |||
82 | 83 | ||
83 | static void | 84 | static void |
84 | receive_check (void *cls, const void *buf, size_t available, | 85 | receive_check (void *cls, const void *buf, size_t available, |
85 | const struct sockaddr *addr, socklen_t addrlen, int errCode) | 86 | const struct sockaddr *addr, socklen_t addrlen, int errCode) |
86 | { | 87 | { |
87 | int *ok = cls; | 88 | int *ok = cls; |
88 | 89 | ||
89 | GNUNET_assert (buf != NULL); /* no timeout */ | 90 | GNUNET_assert (buf != NULL); /* no timeout */ |
90 | if (0 == memcmp (&"Hello World"[sofar], buf, available)) | 91 | if (0 == memcmp (&"Hello World"[sofar], buf, available)) |
91 | sofar += available; | 92 | sofar += available; |
92 | if (sofar < 12) | 93 | if (sofar < 12) |
93 | { | 94 | { |
94 | GNUNET_CONNECTION_receive (asock, 1024, | 95 | GNUNET_CONNECTION_receive (asock, 1024, |
95 | GNUNET_TIME_relative_multiply | 96 | GNUNET_TIME_relative_multiply |
96 | (GNUNET_TIME_UNIT_SECONDS, 5), &receive_check, | 97 | (GNUNET_TIME_UNIT_SECONDS, 5), |
97 | cls); | 98 | &receive_check, cls); |
98 | } | 99 | } |
99 | else | 100 | else |
100 | { | 101 | { |
101 | *ok = 0; | 102 | *ok = 0; |
102 | GNUNET_CONNECTION_destroy (asock, GNUNET_YES); | 103 | GNUNET_CONNECTION_destroy (asock, GNUNET_YES); |
103 | } | 104 | } |
104 | } | 105 | } |
105 | 106 | ||
106 | 107 | ||
@@ -116,7 +117,7 @@ run_accept (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
116 | GNUNET_assert (asock != NULL); | 117 | GNUNET_assert (asock != NULL); |
117 | GNUNET_assert (GNUNET_YES == GNUNET_CONNECTION_check (asock)); | 118 | GNUNET_assert (GNUNET_YES == GNUNET_CONNECTION_check (asock)); |
118 | GNUNET_assert (GNUNET_OK == | 119 | GNUNET_assert (GNUNET_OK == |
119 | GNUNET_CONNECTION_get_address (asock, &addr, &alen)); | 120 | GNUNET_CONNECTION_get_address (asock, &addr, &alen)); |
120 | GNUNET_assert (alen == sizeof (struct sockaddr_in)); | 121 | GNUNET_assert (alen == sizeof (struct sockaddr_in)); |
121 | v4 = addr; | 122 | v4 = addr; |
122 | memset (&expect, 0, sizeof (expect)); | 123 | memset (&expect, 0, sizeof (expect)); |
@@ -130,9 +131,9 @@ run_accept (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
130 | GNUNET_free (addr); | 131 | GNUNET_free (addr); |
131 | GNUNET_CONNECTION_destroy (lsock, GNUNET_YES); | 132 | GNUNET_CONNECTION_destroy (lsock, GNUNET_YES); |
132 | GNUNET_CONNECTION_receive (asock, 1024, | 133 | GNUNET_CONNECTION_receive (asock, 1024, |
133 | GNUNET_TIME_relative_multiply | 134 | GNUNET_TIME_relative_multiply |
134 | (GNUNET_TIME_UNIT_SECONDS, 5), &receive_check, | 135 | (GNUNET_TIME_UNIT_SECONDS, 5), &receive_check, |
135 | cls); | 136 | cls); |
136 | } | 137 | } |
137 | 138 | ||
138 | static size_t | 139 | static size_t |
@@ -159,17 +160,17 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
159 | v4.sin_port = htons (PORT); | 160 | v4.sin_port = htons (PORT); |
160 | v4.sin_addr.s_addr = htonl (INADDR_LOOPBACK); | 161 | v4.sin_addr.s_addr = htonl (INADDR_LOOPBACK); |
161 | csock = | 162 | csock = |
162 | GNUNET_CONNECTION_create_from_sockaddr (AF_INET, | 163 | GNUNET_CONNECTION_create_from_sockaddr (AF_INET, |
163 | (const struct sockaddr *) &v4, | 164 | (const struct sockaddr *) &v4, |
164 | sizeof (v4)); | 165 | sizeof (v4)); |
165 | GNUNET_assert (csock != NULL); | 166 | GNUNET_assert (csock != NULL); |
166 | GNUNET_assert (NULL != | 167 | GNUNET_assert (NULL != |
167 | GNUNET_CONNECTION_notify_transmit_ready (csock, 12, | 168 | GNUNET_CONNECTION_notify_transmit_ready (csock, 12, |
168 | GNUNET_TIME_UNIT_SECONDS, | 169 | GNUNET_TIME_UNIT_SECONDS, |
169 | &make_hello, NULL)); | 170 | &make_hello, NULL)); |
170 | GNUNET_CONNECTION_destroy (csock, GNUNET_YES); | 171 | GNUNET_CONNECTION_destroy (csock, GNUNET_YES); |
171 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, ls, &run_accept, | 172 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, ls, |
172 | cls); | 173 | &run_accept, cls); |
173 | } | 174 | } |
174 | 175 | ||
175 | 176 | ||
@@ -196,11 +197,11 @@ main (int argc, char *argv[]) | |||
196 | 197 | ||
197 | GNUNET_log_setup ("test_connection_addressing", | 198 | GNUNET_log_setup ("test_connection_addressing", |
198 | #if VERBOSE | 199 | #if VERBOSE |
199 | "DEBUG", | 200 | "DEBUG", |
200 | #else | 201 | #else |
201 | "WARNING", | 202 | "WARNING", |
202 | #endif | 203 | #endif |
203 | NULL); | 204 | NULL); |
204 | ret += check (); | 205 | ret += check (); |
205 | return ret; | 206 | return ret; |
206 | } | 207 | } |