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/cadet/cadet_api_get_channel.c | |
parent | a0fce305c565c0937d917a92712f15e9c5736260 (diff) | |
download | gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.tar.gz gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.zip |
uncrustify as demanded.
Diffstat (limited to 'src/cadet/cadet_api_get_channel.c')
-rw-r--r-- | src/cadet/cadet_api_get_channel.c | 139 |
1 files changed, 68 insertions, 71 deletions
diff --git a/src/cadet/cadet_api_get_channel.c b/src/cadet/cadet_api_get_channel.c index 81f0691f1..5479f4238 100644 --- a/src/cadet/cadet_api_get_channel.c +++ b/src/cadet/cadet_api_get_channel.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 | * @file cadet/cadet_api_get_channel.c | 21 | * @file cadet/cadet_api_get_channel.c |
22 | * @brief cadet api: client implementation of cadet service | 22 | * @brief cadet api: client implementation of cadet service |
@@ -34,9 +34,7 @@ | |||
34 | /** | 34 | /** |
35 | * Operation handle. | 35 | * Operation handle. |
36 | */ | 36 | */ |
37 | struct GNUNET_CADET_ChannelMonitor | 37 | struct GNUNET_CADET_ChannelMonitor { |
38 | { | ||
39 | |||
40 | /** | 38 | /** |
41 | * Channel callback. | 39 | * Channel callback. |
42 | */ | 40 | */ |
@@ -56,7 +54,7 @@ struct GNUNET_CADET_ChannelMonitor | |||
56 | * Message queue to talk to CADET service. | 54 | * Message queue to talk to CADET service. |
57 | */ | 55 | */ |
58 | struct GNUNET_MQ_Handle *mq; | 56 | struct GNUNET_MQ_Handle *mq; |
59 | 57 | ||
60 | /** | 58 | /** |
61 | * Task to reconnect. | 59 | * Task to reconnect. |
62 | */ | 60 | */ |
@@ -71,7 +69,6 @@ struct GNUNET_CADET_ChannelMonitor | |||
71 | * Peer we want information about. | 69 | * Peer we want information about. |
72 | */ | 70 | */ |
73 | struct GNUNET_PeerIdentity peer; | 71 | struct GNUNET_PeerIdentity peer; |
74 | |||
75 | }; | 72 | }; |
76 | 73 | ||
77 | 74 | ||
@@ -84,11 +81,11 @@ struct GNUNET_CADET_ChannelMonitor | |||
84 | * #GNUNET_SYSERR otherwise | 81 | * #GNUNET_SYSERR otherwise |
85 | */ | 82 | */ |
86 | static int | 83 | static int |
87 | check_channel_info (void *cls, | 84 | check_channel_info(void *cls, |
88 | const struct GNUNET_CADET_ChannelInfoMessage *message) | 85 | const struct GNUNET_CADET_ChannelInfoMessage *message) |
89 | { | 86 | { |
90 | (void) cls; | 87 | (void)cls; |
91 | 88 | ||
92 | return GNUNET_OK; | 89 | return GNUNET_OK; |
93 | } | 90 | } |
94 | 91 | ||
@@ -96,39 +93,39 @@ check_channel_info (void *cls, | |||
96 | /** | 93 | /** |
97 | * Process a local peer info reply, pass info to the user. | 94 | * Process a local peer info reply, pass info to the user. |
98 | * | 95 | * |
99 | * @param cls Closure | 96 | * @param cls Closure |
100 | * @param message Message itself. | 97 | * @param message Message itself. |
101 | */ | 98 | */ |
102 | static void | 99 | static void |
103 | handle_channel_info (void *cls, | 100 | handle_channel_info(void *cls, |
104 | const struct GNUNET_CADET_ChannelInfoMessage *message) | 101 | const struct GNUNET_CADET_ChannelInfoMessage *message) |
105 | { | 102 | { |
106 | struct GNUNET_CADET_ChannelMonitor *cm = cls; | 103 | struct GNUNET_CADET_ChannelMonitor *cm = cls; |
107 | struct GNUNET_CADET_ChannelInternals ci; | 104 | struct GNUNET_CADET_ChannelInternals ci; |
108 | 105 | ||
109 | ci.root = message->root; | 106 | ci.root = message->root; |
110 | ci.dest = message->dest; | 107 | ci.dest = message->dest; |
111 | cm->channel_cb (cm->channel_cb_cls, | 108 | cm->channel_cb(cm->channel_cb_cls, |
112 | &ci); | 109 | &ci); |
113 | GNUNET_CADET_get_channel_cancel (cm); | 110 | GNUNET_CADET_get_channel_cancel(cm); |
114 | } | 111 | } |
115 | 112 | ||
116 | 113 | ||
117 | /** | 114 | /** |
118 | * Process a local peer info reply, pass info to the user. | 115 | * Process a local peer info reply, pass info to the user. |
119 | * | 116 | * |
120 | * @param cls Closure | 117 | * @param cls Closure |
121 | * @param message Message itself. | 118 | * @param message Message itself. |
122 | */ | 119 | */ |
123 | static void | 120 | static void |
124 | handle_channel_info_end (void *cls, | 121 | handle_channel_info_end(void *cls, |
125 | const struct GNUNET_MessageHeader *message) | 122 | const struct GNUNET_MessageHeader *message) |
126 | { | 123 | { |
127 | struct GNUNET_CADET_ChannelMonitor *cm = cls; | 124 | struct GNUNET_CADET_ChannelMonitor *cm = cls; |
128 | 125 | ||
129 | cm->channel_cb (cm->channel_cb_cls, | 126 | cm->channel_cb(cm->channel_cb_cls, |
130 | NULL); | 127 | NULL); |
131 | GNUNET_CADET_get_channel_cancel (cm); | 128 | GNUNET_CADET_get_channel_cancel(cm); |
132 | } | 129 | } |
133 | 130 | ||
134 | 131 | ||
@@ -138,7 +135,7 @@ handle_channel_info_end (void *cls, | |||
138 | * @param cls a `struct GNUNET_CADET_ChannelMonitor` operation | 135 | * @param cls a `struct GNUNET_CADET_ChannelMonitor` operation |
139 | */ | 136 | */ |
140 | static void | 137 | static void |
141 | reconnect (void *cls); | 138 | reconnect(void *cls); |
142 | 139 | ||
143 | 140 | ||
144 | /** | 141 | /** |
@@ -148,18 +145,18 @@ reconnect (void *cls); | |||
148 | * @param error error code from MQ | 145 | * @param error error code from MQ |
149 | */ | 146 | */ |
150 | static void | 147 | static void |
151 | error_handler (void *cls, | 148 | error_handler(void *cls, |
152 | enum GNUNET_MQ_Error error) | 149 | enum GNUNET_MQ_Error error) |
153 | { | 150 | { |
154 | struct GNUNET_CADET_ChannelMonitor *cm = cls; | 151 | struct GNUNET_CADET_ChannelMonitor *cm = cls; |
155 | 152 | ||
156 | GNUNET_MQ_destroy (cm->mq); | 153 | GNUNET_MQ_destroy(cm->mq); |
157 | cm->mq = NULL; | 154 | cm->mq = NULL; |
158 | cm->backoff = GNUNET_TIME_randomized_backoff (cm->backoff, | 155 | cm->backoff = GNUNET_TIME_randomized_backoff(cm->backoff, |
159 | GNUNET_TIME_UNIT_MINUTES); | 156 | GNUNET_TIME_UNIT_MINUTES); |
160 | cm->reconnect_task = GNUNET_SCHEDULER_add_delayed (cm->backoff, | 157 | cm->reconnect_task = GNUNET_SCHEDULER_add_delayed(cm->backoff, |
161 | &reconnect, | 158 | &reconnect, |
162 | cm); | 159 | cm); |
163 | } | 160 | } |
164 | 161 | ||
165 | 162 | ||
@@ -169,36 +166,36 @@ error_handler (void *cls, | |||
169 | * @param cls a `struct GNUNET_CADET_ChannelMonitor` operation | 166 | * @param cls a `struct GNUNET_CADET_ChannelMonitor` operation |
170 | */ | 167 | */ |
171 | static void | 168 | static void |
172 | reconnect (void *cls) | 169 | reconnect(void *cls) |
173 | { | 170 | { |
174 | struct GNUNET_CADET_ChannelMonitor *cm = cls; | 171 | struct GNUNET_CADET_ChannelMonitor *cm = cls; |
175 | struct GNUNET_MQ_MessageHandler handlers[] = { | 172 | struct GNUNET_MQ_MessageHandler handlers[] = { |
176 | GNUNET_MQ_hd_fixed_size (channel_info_end, | 173 | GNUNET_MQ_hd_fixed_size(channel_info_end, |
177 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_CHANNEL_END, | 174 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_CHANNEL_END, |
178 | struct GNUNET_MessageHeader, | 175 | struct GNUNET_MessageHeader, |
179 | cm), | 176 | cm), |
180 | GNUNET_MQ_hd_var_size (channel_info, | 177 | GNUNET_MQ_hd_var_size(channel_info, |
181 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_CHANNEL, | 178 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_CHANNEL, |
182 | struct GNUNET_CADET_ChannelInfoMessage, | 179 | struct GNUNET_CADET_ChannelInfoMessage, |
183 | cm), | 180 | cm), |
184 | GNUNET_MQ_handler_end () | 181 | GNUNET_MQ_handler_end() |
185 | }; | 182 | }; |
186 | struct GNUNET_CADET_RequestChannelInfoMessage *msg; | 183 | struct GNUNET_CADET_RequestChannelInfoMessage *msg; |
187 | struct GNUNET_MQ_Envelope *env; | 184 | struct GNUNET_MQ_Envelope *env; |
188 | 185 | ||
189 | cm->reconnect_task = NULL; | 186 | cm->reconnect_task = NULL; |
190 | cm->mq = GNUNET_CLIENT_connect (cm->cfg, | 187 | cm->mq = GNUNET_CLIENT_connect(cm->cfg, |
191 | "cadet", | 188 | "cadet", |
192 | handlers, | 189 | handlers, |
193 | &error_handler, | 190 | &error_handler, |
194 | cm); | 191 | cm); |
195 | if (NULL == cm->mq) | 192 | if (NULL == cm->mq) |
196 | return; | 193 | return; |
197 | env = GNUNET_MQ_msg (msg, | 194 | env = GNUNET_MQ_msg(msg, |
198 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_CHANNEL); | 195 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_CHANNEL); |
199 | msg->target = cm->peer; | 196 | msg->target = cm->peer; |
200 | GNUNET_MQ_send (cm->mq, | 197 | GNUNET_MQ_send(cm->mq, |
201 | env); | 198 | env); |
202 | } | 199 | } |
203 | 200 | ||
204 | 201 | ||
@@ -212,29 +209,29 @@ reconnect (void *cls) | |||
212 | * @return NULL on error | 209 | * @return NULL on error |
213 | */ | 210 | */ |
214 | struct GNUNET_CADET_ChannelMonitor * | 211 | struct GNUNET_CADET_ChannelMonitor * |
215 | GNUNET_CADET_get_channel (const struct GNUNET_CONFIGURATION_Handle *cfg, | 212 | GNUNET_CADET_get_channel(const struct GNUNET_CONFIGURATION_Handle *cfg, |
216 | struct GNUNET_PeerIdentity *peer, | 213 | struct GNUNET_PeerIdentity *peer, |
217 | GNUNET_CADET_ChannelCB callback, | 214 | GNUNET_CADET_ChannelCB callback, |
218 | void *callback_cls) | 215 | void *callback_cls) |
219 | { | 216 | { |
220 | struct GNUNET_CADET_ChannelMonitor *cm; | 217 | struct GNUNET_CADET_ChannelMonitor *cm; |
221 | 218 | ||
222 | if (NULL == callback) | 219 | if (NULL == callback) |
223 | { | 220 | { |
224 | GNUNET_break (0); | 221 | GNUNET_break(0); |
225 | return NULL; | 222 | return NULL; |
226 | } | 223 | } |
227 | cm = GNUNET_new (struct GNUNET_CADET_ChannelMonitor); | 224 | cm = GNUNET_new(struct GNUNET_CADET_ChannelMonitor); |
228 | cm->channel_cb = callback; | 225 | cm->channel_cb = callback; |
229 | cm->channel_cb_cls = callback_cls; | 226 | cm->channel_cb_cls = callback_cls; |
230 | cm->cfg = cfg; | 227 | cm->cfg = cfg; |
231 | cm->peer = *peer; | 228 | cm->peer = *peer; |
232 | reconnect (cm); | 229 | reconnect(cm); |
233 | if (NULL == cm->mq) | 230 | if (NULL == cm->mq) |
234 | { | 231 | { |
235 | GNUNET_free (cm); | 232 | GNUNET_free(cm); |
236 | return NULL; | 233 | return NULL; |
237 | } | 234 | } |
238 | return cm; | 235 | return cm; |
239 | } | 236 | } |
240 | 237 | ||
@@ -246,15 +243,15 @@ GNUNET_CADET_get_channel (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
246 | * @return Closure that was given to #GNUNET_CADET_get_channel(). | 243 | * @return Closure that was given to #GNUNET_CADET_get_channel(). |
247 | */ | 244 | */ |
248 | void * | 245 | void * |
249 | GNUNET_CADET_get_channel_cancel (struct GNUNET_CADET_ChannelMonitor *cm) | 246 | GNUNET_CADET_get_channel_cancel(struct GNUNET_CADET_ChannelMonitor *cm) |
250 | { | 247 | { |
251 | void *ret = cm->channel_cb_cls; | 248 | void *ret = cm->channel_cb_cls; |
252 | 249 | ||
253 | if (NULL != cm->mq) | 250 | if (NULL != cm->mq) |
254 | GNUNET_MQ_destroy (cm->mq); | 251 | GNUNET_MQ_destroy(cm->mq); |
255 | if (NULL != cm->reconnect_task) | 252 | if (NULL != cm->reconnect_task) |
256 | GNUNET_SCHEDULER_cancel (cm->reconnect_task); | 253 | GNUNET_SCHEDULER_cancel(cm->reconnect_task); |
257 | GNUNET_free (cm); | 254 | GNUNET_free(cm); |
258 | return ret; | 255 | return ret; |
259 | } | 256 | } |
260 | 257 | ||