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/transport/transport_api_hello_get.c | |
parent | a0fce305c565c0937d917a92712f15e9c5736260 (diff) | |
download | gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.tar.gz gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.zip |
uncrustify as demanded.
Diffstat (limited to 'src/transport/transport_api_hello_get.c')
-rw-r--r-- | src/transport/transport_api_hello_get.c | 142 |
1 files changed, 70 insertions, 72 deletions
diff --git a/src/transport/transport_api_hello_get.c b/src/transport/transport_api_hello_get.c index a4d55b430..0f53148af 100644 --- a/src/transport/transport_api_hello_get.c +++ b/src/transport/transport_api_hello_get.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 | * @file transport/transport_api_hello_get.c | 22 | * @file transport/transport_api_hello_get.c |
@@ -36,9 +36,7 @@ | |||
36 | /** | 36 | /** |
37 | * Functions to call with this peer's HELLO. | 37 | * Functions to call with this peer's HELLO. |
38 | */ | 38 | */ |
39 | struct GNUNET_TRANSPORT_HelloGetHandle | 39 | struct GNUNET_TRANSPORT_HelloGetHandle { |
40 | { | ||
41 | |||
42 | /** | 40 | /** |
43 | * Our configuration. | 41 | * Our configuration. |
44 | */ | 42 | */ |
@@ -89,22 +87,22 @@ struct GNUNET_TRANSPORT_HelloGetHandle | |||
89 | * @return #GNUNET_OK if message is well-formed | 87 | * @return #GNUNET_OK if message is well-formed |
90 | */ | 88 | */ |
91 | static int | 89 | static int |
92 | check_hello (void *cls, | 90 | check_hello(void *cls, |
93 | const struct GNUNET_MessageHeader *msg) | 91 | const struct GNUNET_MessageHeader *msg) |
94 | { | 92 | { |
95 | struct GNUNET_PeerIdentity me; | 93 | struct GNUNET_PeerIdentity me; |
96 | 94 | ||
97 | if (GNUNET_OK != | 95 | if (GNUNET_OK != |
98 | GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) msg, | 96 | GNUNET_HELLO_get_id((const struct GNUNET_HELLO_Message *)msg, |
99 | &me)) | 97 | &me)) |
100 | { | 98 | { |
101 | GNUNET_break (0); | 99 | GNUNET_break(0); |
102 | return GNUNET_SYSERR; | 100 | return GNUNET_SYSERR; |
103 | } | 101 | } |
104 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 102 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
105 | "Receiving (my own) HELLO message (%u bytes), I am `%s'.\n", | 103 | "Receiving (my own) HELLO message (%u bytes), I am `%s'.\n", |
106 | (unsigned int) ntohs (msg->size), | 104 | (unsigned int)ntohs(msg->size), |
107 | GNUNET_i2s (&me)); | 105 | GNUNET_i2s(&me)); |
108 | return GNUNET_OK; | 106 | return GNUNET_OK; |
109 | } | 107 | } |
110 | 108 | ||
@@ -116,13 +114,13 @@ check_hello (void *cls, | |||
116 | * @param msg message received | 114 | * @param msg message received |
117 | */ | 115 | */ |
118 | static void | 116 | static void |
119 | handle_hello (void *cls, | 117 | handle_hello(void *cls, |
120 | const struct GNUNET_MessageHeader *msg) | 118 | const struct GNUNET_MessageHeader *msg) |
121 | { | 119 | { |
122 | struct GNUNET_TRANSPORT_HelloGetHandle *ghh = cls; | 120 | struct GNUNET_TRANSPORT_HelloGetHandle *ghh = cls; |
123 | 121 | ||
124 | ghh->rec (ghh->rec_cls, | 122 | ghh->rec(ghh->rec_cls, |
125 | msg); | 123 | msg); |
126 | } | 124 | } |
127 | 125 | ||
128 | 126 | ||
@@ -133,7 +131,7 @@ handle_hello (void *cls, | |||
133 | * @param ghh transport service to reconnect | 131 | * @param ghh transport service to reconnect |
134 | */ | 132 | */ |
135 | static void | 133 | static void |
136 | schedule_reconnect (struct GNUNET_TRANSPORT_HelloGetHandle *ghh); | 134 | schedule_reconnect(struct GNUNET_TRANSPORT_HelloGetHandle *ghh); |
137 | 135 | ||
138 | 136 | ||
139 | /** | 137 | /** |
@@ -146,16 +144,16 @@ schedule_reconnect (struct GNUNET_TRANSPORT_HelloGetHandle *ghh); | |||
146 | * @param error error code | 144 | * @param error error code |
147 | */ | 145 | */ |
148 | static void | 146 | static void |
149 | mq_error_handler (void *cls, | 147 | mq_error_handler(void *cls, |
150 | enum GNUNET_MQ_Error error) | 148 | enum GNUNET_MQ_Error error) |
151 | { | 149 | { |
152 | struct GNUNET_TRANSPORT_HelloGetHandle *ghh = cls; | 150 | struct GNUNET_TRANSPORT_HelloGetHandle *ghh = cls; |
153 | 151 | ||
154 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 152 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
155 | "Error receiving from transport service, disconnecting temporarily.\n"); | 153 | "Error receiving from transport service, disconnecting temporarily.\n"); |
156 | GNUNET_MQ_destroy (ghh->mq); | 154 | GNUNET_MQ_destroy(ghh->mq); |
157 | ghh->mq = NULL; | 155 | ghh->mq = NULL; |
158 | schedule_reconnect (ghh); | 156 | schedule_reconnect(ghh); |
159 | } | 157 | } |
160 | 158 | ||
161 | 159 | ||
@@ -165,35 +163,35 @@ mq_error_handler (void *cls, | |||
165 | * @param cls the handle to the transport service | 163 | * @param cls the handle to the transport service |
166 | */ | 164 | */ |
167 | static void | 165 | static void |
168 | reconnect (void *cls) | 166 | reconnect(void *cls) |
169 | { | 167 | { |
170 | struct GNUNET_TRANSPORT_HelloGetHandle *ghh = cls; | 168 | struct GNUNET_TRANSPORT_HelloGetHandle *ghh = cls; |
171 | struct GNUNET_MQ_MessageHandler handlers[] = { | 169 | struct GNUNET_MQ_MessageHandler handlers[] = { |
172 | GNUNET_MQ_hd_var_size (hello, | 170 | GNUNET_MQ_hd_var_size(hello, |
173 | GNUNET_MESSAGE_TYPE_HELLO, | 171 | GNUNET_MESSAGE_TYPE_HELLO, |
174 | struct GNUNET_MessageHeader, | 172 | struct GNUNET_MessageHeader, |
175 | ghh), | 173 | ghh), |
176 | GNUNET_MQ_handler_end () | 174 | GNUNET_MQ_handler_end() |
177 | }; | 175 | }; |
178 | struct GNUNET_MQ_Envelope *env; | 176 | struct GNUNET_MQ_Envelope *env; |
179 | struct StartMessage *s; | 177 | struct StartMessage *s; |
180 | 178 | ||
181 | ghh->reconnect_task = NULL; | 179 | ghh->reconnect_task = NULL; |
182 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 180 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
183 | "Connecting to transport service.\n"); | 181 | "Connecting to transport service.\n"); |
184 | GNUNET_assert (NULL == ghh->mq); | 182 | GNUNET_assert(NULL == ghh->mq); |
185 | ghh->mq = GNUNET_CLIENT_connect (ghh->cfg, | 183 | ghh->mq = GNUNET_CLIENT_connect(ghh->cfg, |
186 | "transport", | 184 | "transport", |
187 | handlers, | 185 | handlers, |
188 | &mq_error_handler, | 186 | &mq_error_handler, |
189 | ghh); | 187 | ghh); |
190 | if (NULL == ghh->mq) | 188 | if (NULL == ghh->mq) |
191 | return; | 189 | return; |
192 | env = GNUNET_MQ_msg (s, | 190 | env = GNUNET_MQ_msg(s, |
193 | GNUNET_MESSAGE_TYPE_TRANSPORT_START); | 191 | GNUNET_MESSAGE_TYPE_TRANSPORT_START); |
194 | s->options = htonl (0); | 192 | s->options = htonl(0); |
195 | GNUNET_MQ_send (ghh->mq, | 193 | GNUNET_MQ_send(ghh->mq, |
196 | env); | 194 | env); |
197 | } | 195 | } |
198 | 196 | ||
199 | 197 | ||
@@ -204,13 +202,13 @@ reconnect (void *cls) | |||
204 | * @param ghh transport service to reconnect | 202 | * @param ghh transport service to reconnect |
205 | */ | 203 | */ |
206 | static void | 204 | static void |
207 | schedule_reconnect (struct GNUNET_TRANSPORT_HelloGetHandle *ghh) | 205 | schedule_reconnect(struct GNUNET_TRANSPORT_HelloGetHandle *ghh) |
208 | { | 206 | { |
209 | ghh->reconnect_task = | 207 | ghh->reconnect_task = |
210 | GNUNET_SCHEDULER_add_delayed (ghh->reconnect_delay, | 208 | GNUNET_SCHEDULER_add_delayed(ghh->reconnect_delay, |
211 | &reconnect, | 209 | &reconnect, |
212 | ghh); | 210 | ghh); |
213 | ghh->reconnect_delay = GNUNET_TIME_STD_BACKOFF (ghh->reconnect_delay); | 211 | ghh->reconnect_delay = GNUNET_TIME_STD_BACKOFF(ghh->reconnect_delay); |
214 | } | 212 | } |
215 | 213 | ||
216 | 214 | ||
@@ -228,24 +226,24 @@ schedule_reconnect (struct GNUNET_TRANSPORT_HelloGetHandle *ghh) | |||
228 | * @return handle to cancel the operation | 226 | * @return handle to cancel the operation |
229 | */ | 227 | */ |
230 | struct GNUNET_TRANSPORT_HelloGetHandle * | 228 | struct GNUNET_TRANSPORT_HelloGetHandle * |
231 | GNUNET_TRANSPORT_hello_get (const struct GNUNET_CONFIGURATION_Handle *cfg, | 229 | GNUNET_TRANSPORT_hello_get(const struct GNUNET_CONFIGURATION_Handle *cfg, |
232 | enum GNUNET_TRANSPORT_AddressClass ac, | 230 | enum GNUNET_TRANSPORT_AddressClass ac, |
233 | GNUNET_TRANSPORT_HelloUpdateCallback rec, | 231 | GNUNET_TRANSPORT_HelloUpdateCallback rec, |
234 | void *rec_cls) | 232 | void *rec_cls) |
235 | { | 233 | { |
236 | struct GNUNET_TRANSPORT_HelloGetHandle *ghh; | 234 | struct GNUNET_TRANSPORT_HelloGetHandle *ghh; |
237 | 235 | ||
238 | ghh = GNUNET_new (struct GNUNET_TRANSPORT_HelloGetHandle); | 236 | ghh = GNUNET_new(struct GNUNET_TRANSPORT_HelloGetHandle); |
239 | ghh->rec = rec; | 237 | ghh->rec = rec; |
240 | ghh->rec_cls = rec_cls; | 238 | ghh->rec_cls = rec_cls; |
241 | ghh->cfg = cfg; | 239 | ghh->cfg = cfg; |
242 | ghh->ac = ac; | 240 | ghh->ac = ac; |
243 | reconnect (ghh); | 241 | reconnect(ghh); |
244 | if (NULL == ghh->mq) | 242 | if (NULL == ghh->mq) |
245 | { | 243 | { |
246 | GNUNET_free (ghh); | 244 | GNUNET_free(ghh); |
247 | return NULL; | 245 | return NULL; |
248 | } | 246 | } |
249 | return ghh; | 247 | return ghh; |
250 | } | 248 | } |
251 | 249 | ||
@@ -256,19 +254,19 @@ GNUNET_TRANSPORT_hello_get (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
256 | * @param ghh handle to cancel | 254 | * @param ghh handle to cancel |
257 | */ | 255 | */ |
258 | void | 256 | void |
259 | GNUNET_TRANSPORT_hello_get_cancel (struct GNUNET_TRANSPORT_HelloGetHandle *ghh) | 257 | GNUNET_TRANSPORT_hello_get_cancel(struct GNUNET_TRANSPORT_HelloGetHandle *ghh) |
260 | { | 258 | { |
261 | if (NULL != ghh->reconnect_task) | 259 | if (NULL != ghh->reconnect_task) |
262 | { | 260 | { |
263 | GNUNET_SCHEDULER_cancel (ghh->reconnect_task); | 261 | GNUNET_SCHEDULER_cancel(ghh->reconnect_task); |
264 | ghh->reconnect_task = NULL; | 262 | ghh->reconnect_task = NULL; |
265 | } | 263 | } |
266 | if (NULL != ghh->mq) | 264 | if (NULL != ghh->mq) |
267 | { | 265 | { |
268 | GNUNET_MQ_destroy (ghh->mq); | 266 | GNUNET_MQ_destroy(ghh->mq); |
269 | ghh->mq = NULL; | 267 | ghh->mq = NULL; |
270 | } | 268 | } |
271 | GNUNET_free (ghh); | 269 | GNUNET_free(ghh); |
272 | } | 270 | } |
273 | 271 | ||
274 | 272 | ||