diff options
Diffstat (limited to 'src/messenger/gnunet-service-messenger.c')
-rw-r--r-- | src/messenger/gnunet-service-messenger.c | 247 |
1 files changed, 152 insertions, 95 deletions
diff --git a/src/messenger/gnunet-service-messenger.c b/src/messenger/gnunet-service-messenger.c index 506ab7443..974bdbd37 100644 --- a/src/messenger/gnunet-service-messenger.c +++ b/src/messenger/gnunet-service-messenger.c | |||
@@ -42,7 +42,7 @@ static int | |||
42 | check_create (void *cls, | 42 | check_create (void *cls, |
43 | const struct GNUNET_MESSENGER_CreateMessage *msg) | 43 | const struct GNUNET_MESSENGER_CreateMessage *msg) |
44 | { | 44 | { |
45 | GNUNET_MQ_check_zero_termination(msg); | 45 | GNUNET_MQ_check_zero_termination (msg); |
46 | return GNUNET_OK; | 46 | return GNUNET_OK; |
47 | } | 47 | } |
48 | 48 | ||
@@ -54,7 +54,7 @@ handle_create (void *cls, | |||
54 | 54 | ||
55 | const char *name = ((const char*) msg) + sizeof(*msg); | 55 | const char *name = ((const char*) msg) + sizeof(*msg); |
56 | 56 | ||
57 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Handle created with name: %s\n", name); | 57 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Handle created with name: %s\n", name); |
58 | 58 | ||
59 | setup_srv_handle_name (msg_client->handle, strlen (name) > 0 ? name : NULL); | 59 | setup_srv_handle_name (msg_client->handle, strlen (name) > 0 ? name : NULL); |
60 | 60 | ||
@@ -85,7 +85,7 @@ static int | |||
85 | check_set_name (void *cls, | 85 | check_set_name (void *cls, |
86 | const struct GNUNET_MESSENGER_NameMessage *msg) | 86 | const struct GNUNET_MESSENGER_NameMessage *msg) |
87 | { | 87 | { |
88 | GNUNET_MQ_check_zero_termination(msg); | 88 | GNUNET_MQ_check_zero_termination (msg); |
89 | return GNUNET_OK; | 89 | return GNUNET_OK; |
90 | } | 90 | } |
91 | 91 | ||
@@ -97,7 +97,7 @@ handle_set_name (void *cls, | |||
97 | 97 | ||
98 | const char *name = ((const char*) msg) + sizeof(*msg); | 98 | const char *name = ((const char*) msg) + sizeof(*msg); |
99 | 99 | ||
100 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Handles name is now: %s\n", name); | 100 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Handles name is now: %s\n", name); |
101 | 101 | ||
102 | set_srv_handle_name (msg_client->handle, name); | 102 | set_srv_handle_name (msg_client->handle, name); |
103 | 103 | ||
@@ -110,23 +110,27 @@ handle_room_open (void *cls, | |||
110 | { | 110 | { |
111 | struct GNUNET_MESSENGER_Client *msg_client = cls; | 111 | struct GNUNET_MESSENGER_Client *msg_client = cls; |
112 | 112 | ||
113 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Opening room: %s\n", GNUNET_h2s (&(msg->key))); | 113 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Opening room: %s\n", GNUNET_h2s ( |
114 | &(msg->key))); | ||
114 | 115 | ||
115 | if (GNUNET_YES == open_srv_handle_room (msg_client->handle, &(msg->key))) | 116 | if (GNUNET_YES == open_srv_handle_room (msg_client->handle, &(msg->key))) |
116 | { | 117 | { |
117 | const struct GNUNET_ShortHashCode *member_id = get_srv_handle_member_id (msg_client->handle, &(msg->key)); | 118 | const struct GNUNET_ShortHashCode *member_id = get_srv_handle_member_id ( |
119 | msg_client->handle, &(msg->key)); | ||
118 | 120 | ||
119 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Opening room with member id: %s\n", GNUNET_sh2s (member_id)); | 121 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Opening room with member id: %s\n", |
122 | GNUNET_sh2s (member_id)); | ||
120 | 123 | ||
121 | struct GNUNET_MESSENGER_RoomMessage *response; | 124 | struct GNUNET_MESSENGER_RoomMessage *response; |
122 | struct GNUNET_MQ_Envelope *env; | 125 | struct GNUNET_MQ_Envelope *env; |
123 | 126 | ||
124 | env = GNUNET_MQ_msg(response, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN); | 127 | env = GNUNET_MQ_msg (response, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN); |
125 | GNUNET_memcpy(&(response->key), &(msg->key), sizeof(msg->key)); | 128 | GNUNET_memcpy (&(response->key), &(msg->key), sizeof(msg->key)); |
126 | GNUNET_MQ_send (msg_client->handle->mq, env); | 129 | GNUNET_MQ_send (msg_client->handle->mq, env); |
127 | } | 130 | } |
128 | else | 131 | else |
129 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Opening room failed: %s\n", GNUNET_h2s (&(msg->key))); | 132 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Opening room failed: %s\n", |
133 | GNUNET_h2s (&(msg->key))); | ||
130 | 134 | ||
131 | GNUNET_SERVICE_client_continue (msg_client->client); | 135 | GNUNET_SERVICE_client_continue (msg_client->client); |
132 | } | 136 | } |
@@ -137,25 +141,30 @@ handle_room_entry (void *cls, | |||
137 | { | 141 | { |
138 | struct GNUNET_MESSENGER_Client *msg_client = cls; | 142 | struct GNUNET_MESSENGER_Client *msg_client = cls; |
139 | 143 | ||
140 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Entering room: %s, %s\n", GNUNET_h2s (&(msg->key)), GNUNET_i2s (&(msg->door))); | 144 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Entering room: %s, %s\n", GNUNET_h2s ( |
145 | &(msg->key)), GNUNET_i2s (&(msg->door))); | ||
141 | 146 | ||
142 | if (GNUNET_YES == entry_srv_handle_room (msg_client->handle, &(msg->door), &(msg->key))) | 147 | if (GNUNET_YES == entry_srv_handle_room (msg_client->handle, &(msg->door), |
148 | &(msg->key))) | ||
143 | { | 149 | { |
144 | const struct GNUNET_ShortHashCode *member_id = get_srv_handle_member_id (msg_client->handle, &(msg->key)); | 150 | const struct GNUNET_ShortHashCode *member_id = get_srv_handle_member_id ( |
151 | msg_client->handle, &(msg->key)); | ||
145 | 152 | ||
146 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Entering room with member id: %s\n", GNUNET_sh2s (member_id)); | 153 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Entering room with member id: %s\n", |
154 | GNUNET_sh2s (member_id)); | ||
147 | 155 | ||
148 | struct GNUNET_MESSENGER_RoomMessage *response; | 156 | struct GNUNET_MESSENGER_RoomMessage *response; |
149 | struct GNUNET_MQ_Envelope *env; | 157 | struct GNUNET_MQ_Envelope *env; |
150 | 158 | ||
151 | env = GNUNET_MQ_msg(response, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_ENTRY); | 159 | env = GNUNET_MQ_msg (response, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_ENTRY); |
152 | GNUNET_memcpy(&(response->door), &(msg->door), sizeof(msg->door)); | 160 | GNUNET_memcpy (&(response->door), &(msg->door), sizeof(msg->door)); |
153 | GNUNET_memcpy(&(response->key), &(msg->key), sizeof(msg->key)); | 161 | GNUNET_memcpy (&(response->key), &(msg->key), sizeof(msg->key)); |
154 | GNUNET_MQ_send (msg_client->handle->mq, env); | 162 | GNUNET_MQ_send (msg_client->handle->mq, env); |
155 | } | 163 | } |
156 | else | 164 | else |
157 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Entrance into room failed: %s, %s\n", GNUNET_h2s (&(msg->key)), | 165 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Entrance into room failed: %s, %s\n", |
158 | GNUNET_i2s (&(msg->door))); | 166 | GNUNET_h2s (&(msg->key)), |
167 | GNUNET_i2s (&(msg->door))); | ||
159 | 168 | ||
160 | GNUNET_SERVICE_client_continue (msg_client->client); | 169 | GNUNET_SERVICE_client_continue (msg_client->client); |
161 | } | 170 | } |
@@ -166,21 +175,24 @@ handle_room_close (void *cls, | |||
166 | { | 175 | { |
167 | struct GNUNET_MESSENGER_Client *msg_client = cls; | 176 | struct GNUNET_MESSENGER_Client *msg_client = cls; |
168 | 177 | ||
169 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Closing room: %s\n", GNUNET_h2s (&(msg->key))); | 178 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Closing room: %s\n", GNUNET_h2s ( |
179 | &(msg->key))); | ||
170 | 180 | ||
171 | if (GNUNET_YES == close_srv_handle_room (msg_client->handle, &(msg->key))) | 181 | if (GNUNET_YES == close_srv_handle_room (msg_client->handle, &(msg->key))) |
172 | { | 182 | { |
173 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Closing room succeeded: %s\n", GNUNET_h2s (&(msg->key))); | 183 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Closing room succeeded: %s\n", |
184 | GNUNET_h2s (&(msg->key))); | ||
174 | 185 | ||
175 | struct GNUNET_MESSENGER_RoomMessage *response; | 186 | struct GNUNET_MESSENGER_RoomMessage *response; |
176 | struct GNUNET_MQ_Envelope *env; | 187 | struct GNUNET_MQ_Envelope *env; |
177 | 188 | ||
178 | env = GNUNET_MQ_msg(response, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_CLOSE); | 189 | env = GNUNET_MQ_msg (response, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_CLOSE); |
179 | GNUNET_memcpy(&(response->key), &(msg->key), sizeof(msg->key)); | 190 | GNUNET_memcpy (&(response->key), &(msg->key), sizeof(msg->key)); |
180 | GNUNET_MQ_send (msg_client->handle->mq, env); | 191 | GNUNET_MQ_send (msg_client->handle->mq, env); |
181 | } | 192 | } |
182 | else | 193 | else |
183 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Closing room failed: %s\n", GNUNET_h2s (&(msg->key))); | 194 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Closing room failed: %s\n", |
195 | GNUNET_h2s (&(msg->key))); | ||
184 | 196 | ||
185 | GNUNET_SERVICE_client_continue (msg_client->client); | 197 | GNUNET_SERVICE_client_continue (msg_client->client); |
186 | } | 198 | } |
@@ -195,39 +207,42 @@ check_send_message (void *cls, | |||
195 | return GNUNET_NO; | 207 | return GNUNET_NO; |
196 | 208 | ||
197 | const enum GNUNET_MESSENGER_MessageFlags flags = ( | 209 | const enum GNUNET_MESSENGER_MessageFlags flags = ( |
198 | (enum GNUNET_MESSENGER_MessageFlags) (msg->flags) | 210 | (enum GNUNET_MESSENGER_MessageFlags) (msg->flags) |
199 | ); | 211 | ); |
200 | 212 | ||
201 | const uint16_t length = full_length - sizeof(*msg); | 213 | const uint16_t length = full_length - sizeof(*msg); |
202 | const char *buffer = ((const char*) msg) + sizeof(*msg); | 214 | const char *buffer = ((const char*) msg) + sizeof(*msg); |
203 | 215 | ||
204 | ssize_t key_length = 0; | 216 | size_t key_length = 0; |
205 | 217 | ||
206 | if (!(flags & GNUNET_MESSENGER_FLAG_PRIVATE)) | 218 | if (! (flags & GNUNET_MESSENGER_FLAG_PRIVATE)) |
207 | goto check_for_message; | 219 | goto check_for_message; |
208 | 220 | ||
209 | struct GNUNET_IDENTITY_PublicKey public_key; | 221 | struct GNUNET_IDENTITY_PublicKey public_key; |
210 | 222 | ||
211 | key_length = GNUNET_IDENTITY_read_key_from_buffer(&public_key, buffer, length); | 223 | if (GNUNET_SYSERR == |
212 | 224 | GNUNET_IDENTITY_read_public_key_from_buffer (buffer, length, | |
213 | check_for_message: | 225 | &public_key, |
214 | if (key_length < 0) | 226 | &key_length)) |
215 | return GNUNET_NO; | 227 | return GNUNET_NO; |
216 | 228 | ||
229 | check_for_message: | ||
230 | |||
217 | const uint16_t msg_length = length - key_length; | 231 | const uint16_t msg_length = length - key_length; |
218 | const char* msg_buffer = buffer + key_length; | 232 | const char*msg_buffer = buffer + key_length; |
219 | 233 | ||
220 | struct GNUNET_MESSENGER_Message message; | 234 | struct GNUNET_MESSENGER_Message message; |
221 | 235 | ||
222 | if (length < get_message_kind_size(GNUNET_MESSENGER_KIND_UNKNOWN, GNUNET_NO)) | 236 | if (length < get_message_kind_size (GNUNET_MESSENGER_KIND_UNKNOWN, GNUNET_NO)) |
223 | return GNUNET_NO; | 237 | return GNUNET_NO; |
224 | 238 | ||
225 | if (GNUNET_YES != decode_message (&message, msg_length, msg_buffer, GNUNET_NO, NULL)) | 239 | if (GNUNET_YES != decode_message (&message, msg_length, msg_buffer, GNUNET_NO, |
240 | NULL)) | ||
226 | return GNUNET_NO; | 241 | return GNUNET_NO; |
227 | 242 | ||
228 | const int allowed = filter_message_sending(&message); | 243 | const int allowed = filter_message_sending (&message); |
229 | 244 | ||
230 | cleanup_message(&message); | 245 | cleanup_message (&message); |
231 | return GNUNET_YES == allowed? GNUNET_OK : GNUNET_NO; | 246 | return GNUNET_YES == allowed? GNUNET_OK : GNUNET_NO; |
232 | } | 247 | } |
233 | 248 | ||
@@ -238,45 +253,47 @@ handle_send_message (void *cls, | |||
238 | struct GNUNET_MESSENGER_Client *msg_client = cls; | 253 | struct GNUNET_MESSENGER_Client *msg_client = cls; |
239 | 254 | ||
240 | const enum GNUNET_MESSENGER_MessageFlags flags = ( | 255 | const enum GNUNET_MESSENGER_MessageFlags flags = ( |
241 | (enum GNUNET_MESSENGER_MessageFlags) (msg->flags) | 256 | (enum GNUNET_MESSENGER_MessageFlags) (msg->flags) |
242 | ); | 257 | ); |
243 | 258 | ||
244 | const struct GNUNET_HashCode *key = &(msg->key); | 259 | const struct GNUNET_HashCode *key = &(msg->key); |
245 | const char *buffer = ((const char*) msg) + sizeof(*msg); | 260 | const char *buffer = ((const char*) msg) + sizeof(*msg); |
246 | 261 | ||
247 | const uint16_t length = ntohs (msg->header.size) - sizeof(*msg); | 262 | const uint16_t length = ntohs (msg->header.size) - sizeof(*msg); |
248 | ssize_t key_length = 0; | 263 | size_t key_length = 0; |
249 | 264 | ||
250 | struct GNUNET_IDENTITY_PublicKey public_key; | 265 | struct GNUNET_IDENTITY_PublicKey public_key; |
251 | 266 | ||
252 | if (flags & GNUNET_MESSENGER_FLAG_PRIVATE) | 267 | if (flags & GNUNET_MESSENGER_FLAG_PRIVATE) |
253 | key_length = GNUNET_IDENTITY_read_key_from_buffer( | 268 | GNUNET_IDENTITY_read_public_key_from_buffer ( |
254 | &public_key, buffer, length | 269 | buffer, length, &public_key, &key_length); |
255 | ); | ||
256 | 270 | ||
257 | const uint16_t msg_length = length - key_length; | 271 | const uint16_t msg_length = length - key_length; |
258 | const char* msg_buffer = buffer + key_length; | 272 | const char*msg_buffer = buffer + key_length; |
259 | 273 | ||
260 | struct GNUNET_MESSENGER_Message message; | 274 | struct GNUNET_MESSENGER_Message message; |
261 | decode_message (&message, msg_length, msg_buffer, GNUNET_NO, NULL); | 275 | decode_message (&message, msg_length, msg_buffer, GNUNET_NO, NULL); |
262 | 276 | ||
263 | if ((flags & GNUNET_MESSENGER_FLAG_PRIVATE) && | 277 | if ((flags & GNUNET_MESSENGER_FLAG_PRIVATE) && |
264 | (GNUNET_YES != encrypt_message(&message, &public_key))) | 278 | (GNUNET_YES != encrypt_message (&message, &public_key))) |
265 | { | 279 | { |
266 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Encrypting message failed: Message got dropped!\n"); | 280 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
281 | "Encrypting message failed: Message got dropped!\n"); | ||
267 | 282 | ||
268 | goto end_handling; | 283 | goto end_handling; |
269 | } | 284 | } |
270 | 285 | ||
271 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending message: %s to %s\n", | 286 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending message: %s to %s\n", |
272 | GNUNET_MESSENGER_name_of_kind (message.header.kind), GNUNET_h2s (key)); | 287 | GNUNET_MESSENGER_name_of_kind (message.header.kind), GNUNET_h2s ( |
288 | key)); | ||
273 | 289 | ||
274 | if (GNUNET_YES != send_srv_handle_message (msg_client->handle, key, &message)) | 290 | if (GNUNET_YES != send_srv_handle_message (msg_client->handle, key, &message)) |
275 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Sending message failed: %s to %s\n", | 291 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Sending message failed: %s to %s\n", |
276 | GNUNET_MESSENGER_name_of_kind (message.header.kind), GNUNET_h2s (key)); | 292 | GNUNET_MESSENGER_name_of_kind (message.header.kind), |
293 | GNUNET_h2s (key)); | ||
277 | 294 | ||
278 | end_handling: | 295 | end_handling: |
279 | cleanup_message(&message); | 296 | cleanup_message (&message); |
280 | 297 | ||
281 | GNUNET_SERVICE_client_continue (msg_client->client); | 298 | GNUNET_SERVICE_client_continue (msg_client->client); |
282 | } | 299 | } |
@@ -289,26 +306,30 @@ callback_found_message (void *cls, | |||
289 | { | 306 | { |
290 | struct GNUNET_MESSENGER_Client *msg_client = cls; | 307 | struct GNUNET_MESSENGER_Client *msg_client = cls; |
291 | 308 | ||
292 | if (!message) | 309 | if (! message) |
293 | { | 310 | { |
294 | send_srv_room_message(room, msg_client->handle, create_message_request(hash)); | 311 | send_srv_room_message (room, msg_client->handle, create_message_request ( |
312 | hash)); | ||
295 | return; | 313 | return; |
296 | } | 314 | } |
297 | 315 | ||
298 | struct GNUNET_MESSENGER_MemberStore *store = get_srv_room_member_store(room); | 316 | struct GNUNET_MESSENGER_MemberStore *store = get_srv_room_member_store (room); |
299 | 317 | ||
300 | struct GNUNET_MESSENGER_Member *member = get_store_member_of(store, message); | 318 | struct GNUNET_MESSENGER_Member *member = get_store_member_of (store, message); |
301 | 319 | ||
302 | if (!member) | 320 | if (! member) |
303 | { | 321 | { |
304 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Sender of message (%s) unknown!\n", GNUNET_h2s (hash)); | 322 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Sender of message (%s) unknown!\n", |
323 | GNUNET_h2s (hash)); | ||
305 | return; | 324 | return; |
306 | } | 325 | } |
307 | 326 | ||
308 | struct GNUNET_MESSENGER_MemberSession *session = get_member_session_of(member, message, hash); | 327 | struct GNUNET_MESSENGER_MemberSession *session = get_member_session_of ( |
328 | member, message, hash); | ||
309 | 329 | ||
310 | if (session) | 330 | if (session) |
311 | notify_srv_handle_message (msg_client->handle, room, session, message, hash); | 331 | notify_srv_handle_message (msg_client->handle, room, session, message, |
332 | hash); | ||
312 | } | 333 | } |
313 | 334 | ||
314 | static void | 335 | static void |
@@ -317,39 +338,55 @@ handle_get_message (void *cls, | |||
317 | { | 338 | { |
318 | struct GNUNET_MESSENGER_Client *msg_client = cls; | 339 | struct GNUNET_MESSENGER_Client *msg_client = cls; |
319 | 340 | ||
320 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Requesting message from room: %s\n", GNUNET_h2s (&(msg->key))); | 341 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Requesting message from room: %s\n", |
342 | GNUNET_h2s (&(msg->key))); | ||
321 | 343 | ||
322 | struct GNUNET_MESSENGER_SrvRoom *room = get_service_room (messenger, &(msg->key)); | 344 | struct GNUNET_MESSENGER_SrvRoom *room = get_service_room (messenger, |
345 | &(msg->key)); | ||
323 | 346 | ||
324 | if (!room) | 347 | if (! room) |
325 | { | 348 | { |
326 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Room not found: %s\n", GNUNET_h2s (&(msg->key))); | 349 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Room not found: %s\n", GNUNET_h2s ( |
350 | &(msg->key))); | ||
327 | goto end_handling; | 351 | goto end_handling; |
328 | } | 352 | } |
329 | 353 | ||
330 | struct GNUNET_MESSENGER_MemberStore *member_store = get_srv_room_member_store(room); | 354 | struct GNUNET_MESSENGER_MemberStore *member_store = |
355 | get_srv_room_member_store (room); | ||
331 | 356 | ||
332 | struct GNUNET_MESSENGER_Member *member = get_store_member(member_store, get_srv_handle_member_id( | 357 | struct GNUNET_MESSENGER_Member *member = get_store_member (member_store, |
333 | msg_client->handle, &(msg->key) | 358 | get_srv_handle_member_id ( |
334 | )); | 359 | msg_client-> |
360 | handle, | ||
361 | &(msg->key) | ||
362 | )); | ||
335 | 363 | ||
336 | if (!member) | 364 | if (! member) |
337 | { | 365 | { |
338 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Member not valid to request a message!\n"); | 366 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
367 | "Member not valid to request a message!\n"); | ||
339 | goto end_handling; | 368 | goto end_handling; |
340 | } | 369 | } |
341 | 370 | ||
342 | struct GNUNET_MESSENGER_MemberSession *session = get_member_session(member, &(get_srv_handle_ego(msg_client->handle)->pub)); | 371 | struct GNUNET_MESSENGER_MemberSession *session = get_member_session (member, |
372 | &( | ||
373 | get_srv_handle_ego ( | ||
374 | msg_client | ||
375 | -> | ||
376 | handle) | ||
377 | ->pub)); | ||
343 | 378 | ||
344 | if (!session) | 379 | if (! session) |
345 | { | 380 | { |
346 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Session not valid to request a message!\n"); | 381 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
382 | "Session not valid to request a message!\n"); | ||
347 | goto end_handling; | 383 | goto end_handling; |
348 | } | 384 | } |
349 | 385 | ||
350 | request_srv_room_message (room, &(msg->hash), session, callback_found_message, msg_client); | 386 | request_srv_room_message (room, &(msg->hash), session, callback_found_message, |
387 | msg_client); | ||
351 | 388 | ||
352 | end_handling: | 389 | end_handling: |
353 | GNUNET_SERVICE_client_continue (msg_client->client); | 390 | GNUNET_SERVICE_client_continue (msg_client->client); |
354 | } | 391 | } |
355 | 392 | ||
@@ -358,7 +395,8 @@ callback_client_connect (void *cls, | |||
358 | struct GNUNET_SERVICE_Client *client, | 395 | struct GNUNET_SERVICE_Client *client, |
359 | struct GNUNET_MQ_Handle *mq) | 396 | struct GNUNET_MQ_Handle *mq) |
360 | { | 397 | { |
361 | struct GNUNET_MESSENGER_Client *msg_client = GNUNET_new(struct GNUNET_MESSENGER_Client); | 398 | struct GNUNET_MESSENGER_Client *msg_client = GNUNET_new (struct |
399 | GNUNET_MESSENGER_Client); | ||
362 | 400 | ||
363 | msg_client->client = client; | 401 | msg_client->client = client; |
364 | msg_client->handle = add_service_handle (messenger, mq); | 402 | msg_client->handle = add_service_handle (messenger, mq); |
@@ -375,7 +413,7 @@ callback_client_disconnect (void *cls, | |||
375 | 413 | ||
376 | remove_service_handle (messenger, msg_client->handle); | 414 | remove_service_handle (messenger, msg_client->handle); |
377 | 415 | ||
378 | GNUNET_free(msg_client); | 416 | GNUNET_free (msg_client); |
379 | } | 417 | } |
380 | 418 | ||
381 | /** | 419 | /** |
@@ -392,27 +430,46 @@ run (void *cls, | |||
392 | { | 430 | { |
393 | messenger = create_service (config, service); | 431 | messenger = create_service (config, service); |
394 | 432 | ||
395 | if (!messenger) | 433 | if (! messenger) |
396 | GNUNET_SCHEDULER_shutdown (); | 434 | GNUNET_SCHEDULER_shutdown (); |
397 | } | 435 | } |
398 | 436 | ||
399 | /** | 437 | /** |
400 | * Define "main" method using service macro. | 438 | * Define "main" method using service macro. |
401 | */ | 439 | */ |
402 | GNUNET_SERVICE_MAIN( | 440 | GNUNET_SERVICE_MAIN ( |
403 | GNUNET_MESSENGER_SERVICE_NAME, | 441 | GNUNET_MESSENGER_SERVICE_NAME, |
404 | GNUNET_SERVICE_OPTION_NONE, | 442 | GNUNET_SERVICE_OPTION_NONE, |
405 | &run, | 443 | &run, |
406 | &callback_client_connect, | 444 | &callback_client_connect, |
407 | &callback_client_disconnect, | 445 | &callback_client_disconnect, |
408 | NULL, | 446 | NULL, |
409 | GNUNET_MQ_hd_var_size( create, GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_CREATE, struct GNUNET_MESSENGER_CreateMessage, NULL ), | 447 | GNUNET_MQ_hd_var_size (create, |
410 | GNUNET_MQ_hd_fixed_size( update, GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_UPDATE, struct GNUNET_MESSENGER_UpdateMessage, NULL ), | 448 | GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_CREATE, struct |
411 | GNUNET_MQ_hd_fixed_size( destroy, GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_DESTROY, struct GNUNET_MESSENGER_DestroyMessage, NULL ), | 449 | GNUNET_MESSENGER_CreateMessage, NULL), |
412 | GNUNET_MQ_hd_var_size( set_name, GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_SET_NAME, struct GNUNET_MESSENGER_NameMessage, NULL ), | 450 | GNUNET_MQ_hd_fixed_size (update, |
413 | GNUNET_MQ_hd_fixed_size( room_open, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN, struct GNUNET_MESSENGER_RoomMessage, NULL ), | 451 | GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_UPDATE, |
414 | GNUNET_MQ_hd_fixed_size( room_entry, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_ENTRY, struct GNUNET_MESSENGER_RoomMessage, NULL ), | 452 | struct |
415 | GNUNET_MQ_hd_fixed_size( room_close, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_CLOSE, struct GNUNET_MESSENGER_RoomMessage, NULL ), | 453 | GNUNET_MESSENGER_UpdateMessage, NULL), |
416 | GNUNET_MQ_hd_var_size( send_message, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_SEND_MESSAGE, struct GNUNET_MESSENGER_SendMessage, NULL ), | 454 | GNUNET_MQ_hd_fixed_size (destroy, |
417 | GNUNET_MQ_hd_fixed_size( get_message, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_GET_MESSAGE, struct GNUNET_MESSENGER_GetMessage, NULL ), | 455 | GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_DESTROY, |
418 | GNUNET_MQ_handler_end()); | 456 | struct |
457 | GNUNET_MESSENGER_DestroyMessage, NULL), | ||
458 | GNUNET_MQ_hd_var_size (set_name, | ||
459 | GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_SET_NAME, | ||
460 | struct | ||
461 | GNUNET_MESSENGER_NameMessage, NULL), | ||
462 | GNUNET_MQ_hd_fixed_size (room_open, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN, | ||
463 | struct GNUNET_MESSENGER_RoomMessage, NULL), | ||
464 | GNUNET_MQ_hd_fixed_size (room_entry, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_ENTRY, | ||
465 | struct GNUNET_MESSENGER_RoomMessage, NULL), | ||
466 | GNUNET_MQ_hd_fixed_size (room_close, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_CLOSE, | ||
467 | struct GNUNET_MESSENGER_RoomMessage, NULL), | ||
468 | GNUNET_MQ_hd_var_size (send_message, | ||
469 | GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_SEND_MESSAGE, struct | ||
470 | GNUNET_MESSENGER_SendMessage, NULL), | ||
471 | GNUNET_MQ_hd_fixed_size (get_message, | ||
472 | GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_GET_MESSAGE, | ||
473 | struct | ||
474 | GNUNET_MESSENGER_GetMessage, NULL), | ||
475 | GNUNET_MQ_handler_end ()); | ||