diff options
Diffstat (limited to 'src/conversation/gnunet-service-conversation.c')
-rw-r--r-- | src/conversation/gnunet-service-conversation.c | 1349 |
1 files changed, 676 insertions, 673 deletions
diff --git a/src/conversation/gnunet-service-conversation.c b/src/conversation/gnunet-service-conversation.c index e5e225623..12b943217 100644 --- a/src/conversation/gnunet-service-conversation.c +++ b/src/conversation/gnunet-service-conversation.c | |||
@@ -52,7 +52,8 @@ struct Line; | |||
52 | /** | 52 | /** |
53 | * The possible connection status | 53 | * The possible connection status |
54 | */ | 54 | */ |
55 | enum ChannelStatus { | 55 | enum ChannelStatus |
56 | { | ||
56 | /** | 57 | /** |
57 | * We just got the connection, but no introduction yet. | 58 | * We just got the connection, but no introduction yet. |
58 | */ | 59 | */ |
@@ -96,7 +97,8 @@ enum ChannelStatus { | |||
96 | * be attached the the same `struct Line`, which represents a local | 97 | * be attached the the same `struct Line`, which represents a local |
97 | * client. We keep them in a linked list. | 98 | * client. We keep them in a linked list. |
98 | */ | 99 | */ |
99 | struct Channel { | 100 | struct Channel |
101 | { | ||
100 | /** | 102 | /** |
101 | * This is a DLL. | 103 | * This is a DLL. |
102 | */ | 104 | */ |
@@ -152,7 +154,8 @@ struct Channel { | |||
152 | /** | 154 | /** |
153 | * A `struct Line` connects a local client with cadet channels. | 155 | * A `struct Line` connects a local client with cadet channels. |
154 | */ | 156 | */ |
155 | struct Line { | 157 | struct Line |
158 | { | ||
156 | /** | 159 | /** |
157 | * This is a DLL. | 160 | * This is a DLL. |
158 | */ | 161 | */ |
@@ -216,7 +219,7 @@ static struct GNUNET_PeerIdentity my_identity; | |||
216 | * @return NULL for not found | 219 | * @return NULL for not found |
217 | */ | 220 | */ |
218 | static struct Channel * | 221 | static struct Channel * |
219 | find_channel_by_line(struct Line *line, uint32_t cid) | 222 | find_channel_by_line (struct Line *line, uint32_t cid) |
220 | { | 223 | { |
221 | for (struct Channel *ch = line->channel_head; NULL != ch; ch = ch->next) | 224 | for (struct Channel *ch = line->channel_head; NULL != ch; ch = ch->next) |
222 | if (cid == ch->cid) | 225 | if (cid == ch->cid) |
@@ -232,8 +235,8 @@ find_channel_by_line(struct Line *line, uint32_t cid) | |||
232 | * @param msg the message from the client | 235 | * @param msg the message from the client |
233 | */ | 236 | */ |
234 | static void | 237 | static void |
235 | handle_client_pickup_message(void *cls, | 238 | handle_client_pickup_message (void *cls, |
236 | const struct ClientPhonePickupMessage *msg) | 239 | const struct ClientPhonePickupMessage *msg) |
237 | { | 240 | { |
238 | struct Line *line = cls; | 241 | struct Line *line = cls; |
239 | struct CadetPhonePickupMessage *mppm; | 242 | struct CadetPhonePickupMessage *mppm; |
@@ -241,56 +244,56 @@ handle_client_pickup_message(void *cls, | |||
241 | struct Channel *ch; | 244 | struct Channel *ch; |
242 | 245 | ||
243 | if (NULL == line->port) | 246 | if (NULL == line->port) |
244 | { | 247 | { |
245 | /* we never opened the port, bad client! */ | 248 | /* we never opened the port, bad client! */ |
246 | GNUNET_break_op(0); | 249 | GNUNET_break_op (0); |
247 | GNUNET_SERVICE_client_drop(line->client); | 250 | GNUNET_SERVICE_client_drop (line->client); |
248 | return; | 251 | return; |
249 | } | 252 | } |
250 | for (ch = line->channel_head; NULL != ch; ch = ch->next) | 253 | for (ch = line->channel_head; NULL != ch; ch = ch->next) |
251 | if (msg->cid == ch->cid) | 254 | if (msg->cid == ch->cid) |
252 | break; | 255 | break; |
253 | if (NULL == ch) | 256 | if (NULL == ch) |
254 | { | 257 | { |
255 | /* could have been destroyed asynchronously, ignore message */ | 258 | /* could have been destroyed asynchronously, ignore message */ |
256 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Channel %u not found\n", msg->cid); | 259 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Channel %u not found\n", msg->cid); |
257 | GNUNET_SERVICE_client_continue(line->client); | 260 | GNUNET_SERVICE_client_continue (line->client); |
258 | return; | 261 | return; |
259 | } | 262 | } |
260 | switch (ch->status) | 263 | switch (ch->status) |
261 | { | 264 | { |
262 | case CS_CALLEE_INIT: | 265 | case CS_CALLEE_INIT: |
263 | GNUNET_break(0); | 266 | GNUNET_break (0); |
264 | GNUNET_SERVICE_client_drop(line->client); | 267 | GNUNET_SERVICE_client_drop (line->client); |
265 | return; | 268 | return; |
266 | 269 | ||
267 | case CS_CALLEE_RINGING: | 270 | case CS_CALLEE_RINGING: |
268 | ch->status = CS_CALLEE_CONNECTED; | 271 | ch->status = CS_CALLEE_CONNECTED; |
269 | break; | 272 | break; |
270 | 273 | ||
271 | case CS_CALLEE_CONNECTED: | 274 | case CS_CALLEE_CONNECTED: |
272 | GNUNET_break(0); | 275 | GNUNET_break (0); |
273 | GNUNET_SERVICE_client_drop(line->client); | 276 | GNUNET_SERVICE_client_drop (line->client); |
274 | return; | 277 | return; |
275 | 278 | ||
276 | case CS_CALLEE_SHUTDOWN: | 279 | case CS_CALLEE_SHUTDOWN: |
277 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 280 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
278 | "Ignoring client's PICKUP message, line is in SHUTDOWN\n"); | 281 | "Ignoring client's PICKUP message, line is in SHUTDOWN\n"); |
279 | break; | 282 | break; |
280 | 283 | ||
281 | case CS_CALLER_CALLING: | 284 | case CS_CALLER_CALLING: |
282 | case CS_CALLER_CONNECTED: | 285 | case CS_CALLER_CONNECTED: |
283 | case CS_CALLER_SHUTDOWN: | 286 | case CS_CALLER_SHUTDOWN: |
284 | GNUNET_break(0); | 287 | GNUNET_break (0); |
285 | GNUNET_SERVICE_client_drop(line->client); | 288 | GNUNET_SERVICE_client_drop (line->client); |
286 | return; | 289 | return; |
287 | } | 290 | } |
288 | GNUNET_break(CS_CALLEE_CONNECTED == ch->status); | 291 | GNUNET_break (CS_CALLEE_CONNECTED == ch->status); |
289 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending PICK_UP message to cadet\n"); | 292 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending PICK_UP message to cadet\n"); |
290 | env = | 293 | env = |
291 | GNUNET_MQ_msg(mppm, GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_PICK_UP); | 294 | GNUNET_MQ_msg (mppm, GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_PICK_UP); |
292 | GNUNET_MQ_send(ch->mq, env); | 295 | GNUNET_MQ_send (ch->mq, env); |
293 | GNUNET_SERVICE_client_continue(line->client); | 296 | GNUNET_SERVICE_client_continue (line->client); |
294 | } | 297 | } |
295 | 298 | ||
296 | 299 | ||
@@ -301,35 +304,35 @@ handle_client_pickup_message(void *cls, | |||
301 | * @param ch channel that went down | 304 | * @param ch channel that went down |
302 | */ | 305 | */ |
303 | static void | 306 | static void |
304 | clean_up_channel(struct Channel *ch) | 307 | clean_up_channel (struct Channel *ch) |
305 | { | 308 | { |
306 | struct Line *line = ch->line; | 309 | struct Line *line = ch->line; |
307 | struct GNUNET_MQ_Envelope *env; | 310 | struct GNUNET_MQ_Envelope *env; |
308 | struct ClientPhoneHangupMessage *hup; | 311 | struct ClientPhoneHangupMessage *hup; |
309 | 312 | ||
310 | switch (ch->status) | 313 | switch (ch->status) |
314 | { | ||
315 | case CS_CALLEE_INIT: | ||
316 | case CS_CALLEE_SHUTDOWN: | ||
317 | case CS_CALLER_SHUTDOWN: | ||
318 | break; | ||
319 | |||
320 | case CS_CALLEE_RINGING: | ||
321 | case CS_CALLEE_CONNECTED: | ||
322 | case CS_CALLER_CALLING: | ||
323 | case CS_CALLER_CONNECTED: | ||
324 | if (NULL != line) | ||
311 | { | 325 | { |
312 | case CS_CALLEE_INIT: | 326 | env = |
313 | case CS_CALLEE_SHUTDOWN: | 327 | GNUNET_MQ_msg (hup, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP); |
314 | case CS_CALLER_SHUTDOWN: | 328 | hup->cid = ch->cid; |
315 | break; | 329 | GNUNET_MQ_send (line->mq, env); |
316 | |||
317 | case CS_CALLEE_RINGING: | ||
318 | case CS_CALLEE_CONNECTED: | ||
319 | case CS_CALLER_CALLING: | ||
320 | case CS_CALLER_CONNECTED: | ||
321 | if (NULL != line) | ||
322 | { | ||
323 | env = | ||
324 | GNUNET_MQ_msg(hup, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP); | ||
325 | hup->cid = ch->cid; | ||
326 | GNUNET_MQ_send(line->mq, env); | ||
327 | } | ||
328 | break; | ||
329 | } | 330 | } |
331 | break; | ||
332 | } | ||
330 | if (NULL != line) | 333 | if (NULL != line) |
331 | GNUNET_CONTAINER_DLL_remove(line->channel_head, line->channel_tail, ch); | 334 | GNUNET_CONTAINER_DLL_remove (line->channel_head, line->channel_tail, ch); |
332 | GNUNET_free(ch); | 335 | GNUNET_free (ch); |
333 | } | 336 | } |
334 | 337 | ||
335 | 338 | ||
@@ -339,15 +342,15 @@ clean_up_channel(struct Channel *ch) | |||
339 | * @param ch channel to destroy. | 342 | * @param ch channel to destroy. |
340 | */ | 343 | */ |
341 | static void | 344 | static void |
342 | destroy_line_cadet_channels(struct Channel *ch) | 345 | destroy_line_cadet_channels (struct Channel *ch) |
343 | { | 346 | { |
344 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Destroying cadet channels\n"); | 347 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Destroying cadet channels\n"); |
345 | if (NULL != ch->channel) | 348 | if (NULL != ch->channel) |
346 | { | 349 | { |
347 | GNUNET_CADET_channel_destroy(ch->channel); | 350 | GNUNET_CADET_channel_destroy (ch->channel); |
348 | ch->channel = NULL; | 351 | ch->channel = NULL; |
349 | } | 352 | } |
350 | clean_up_channel(ch); | 353 | clean_up_channel (ch); |
351 | } | 354 | } |
352 | 355 | ||
353 | 356 | ||
@@ -358,40 +361,40 @@ destroy_line_cadet_channels(struct Channel *ch) | |||
358 | * @param cls the `struct Channel` to reset/terminate | 361 | * @param cls the `struct Channel` to reset/terminate |
359 | */ | 362 | */ |
360 | static void | 363 | static void |
361 | mq_done_finish_caller_shutdown(void *cls) | 364 | mq_done_finish_caller_shutdown (void *cls) |
362 | { | 365 | { |
363 | struct Channel *ch = cls; | 366 | struct Channel *ch = cls; |
364 | 367 | ||
365 | switch (ch->status) | 368 | switch (ch->status) |
366 | { | 369 | { |
367 | case CS_CALLEE_INIT: | 370 | case CS_CALLEE_INIT: |
368 | GNUNET_break(0); | 371 | GNUNET_break (0); |
369 | break; | 372 | break; |
370 | 373 | ||
371 | case CS_CALLEE_RINGING: | 374 | case CS_CALLEE_RINGING: |
372 | GNUNET_break(0); | 375 | GNUNET_break (0); |
373 | break; | 376 | break; |
374 | 377 | ||
375 | case CS_CALLEE_CONNECTED: | 378 | case CS_CALLEE_CONNECTED: |
376 | GNUNET_break(0); | 379 | GNUNET_break (0); |
377 | break; | 380 | break; |
378 | 381 | ||
379 | case CS_CALLEE_SHUTDOWN: | 382 | case CS_CALLEE_SHUTDOWN: |
380 | destroy_line_cadet_channels(ch); | 383 | destroy_line_cadet_channels (ch); |
381 | break; | 384 | break; |
382 | 385 | ||
383 | case CS_CALLER_CALLING: | 386 | case CS_CALLER_CALLING: |
384 | GNUNET_break(0); | 387 | GNUNET_break (0); |
385 | break; | 388 | break; |
386 | 389 | ||
387 | case CS_CALLER_CONNECTED: | 390 | case CS_CALLER_CONNECTED: |
388 | GNUNET_break(0); | 391 | GNUNET_break (0); |
389 | break; | 392 | break; |
390 | 393 | ||
391 | case CS_CALLER_SHUTDOWN: | 394 | case CS_CALLER_SHUTDOWN: |
392 | destroy_line_cadet_channels(ch); | 395 | destroy_line_cadet_channels (ch); |
393 | break; | 396 | break; |
394 | } | 397 | } |
395 | } | 398 | } |
396 | 399 | ||
397 | 400 | ||
@@ -402,8 +405,8 @@ mq_done_finish_caller_shutdown(void *cls) | |||
402 | * @param msg the message from the client | 405 | * @param msg the message from the client |
403 | */ | 406 | */ |
404 | static void | 407 | static void |
405 | handle_client_hangup_message(void *cls, | 408 | handle_client_hangup_message (void *cls, |
406 | const struct ClientPhoneHangupMessage *msg) | 409 | const struct ClientPhoneHangupMessage *msg) |
407 | { | 410 | { |
408 | struct Line *line = cls; | 411 | struct Line *line = cls; |
409 | struct GNUNET_MQ_Envelope *e; | 412 | struct GNUNET_MQ_Envelope *e; |
@@ -414,55 +417,55 @@ handle_client_hangup_message(void *cls, | |||
414 | if (msg->cid == ch->cid) | 417 | if (msg->cid == ch->cid) |
415 | break; | 418 | break; |
416 | if (NULL == ch) | 419 | if (NULL == ch) |
417 | { | 420 | { |
418 | /* could have been destroyed asynchronously, ignore message */ | 421 | /* could have been destroyed asynchronously, ignore message */ |
419 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Channel %u not found\n", msg->cid); | 422 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Channel %u not found\n", msg->cid); |
420 | GNUNET_SERVICE_client_continue(line->client); | 423 | GNUNET_SERVICE_client_continue (line->client); |
421 | return; | 424 | return; |
422 | } | 425 | } |
423 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 426 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
424 | "Received HANGUP for channel %u which is in state %d\n", | 427 | "Received HANGUP for channel %u which is in state %d\n", |
425 | msg->cid, | 428 | msg->cid, |
426 | ch->status); | 429 | ch->status); |
427 | switch (ch->status) | 430 | switch (ch->status) |
428 | { | 431 | { |
429 | case CS_CALLEE_INIT: | 432 | case CS_CALLEE_INIT: |
430 | GNUNET_break(0); | 433 | GNUNET_break (0); |
431 | GNUNET_SERVICE_client_drop(line->client); | 434 | GNUNET_SERVICE_client_drop (line->client); |
432 | return; | 435 | return; |
433 | 436 | ||
434 | case CS_CALLEE_RINGING: | 437 | case CS_CALLEE_RINGING: |
435 | ch->status = CS_CALLEE_SHUTDOWN; | 438 | ch->status = CS_CALLEE_SHUTDOWN; |
436 | break; | 439 | break; |
437 | 440 | ||
438 | case CS_CALLEE_CONNECTED: | 441 | case CS_CALLEE_CONNECTED: |
439 | ch->status = CS_CALLEE_SHUTDOWN; | 442 | ch->status = CS_CALLEE_SHUTDOWN; |
440 | break; | 443 | break; |
441 | 444 | ||
442 | case CS_CALLEE_SHUTDOWN: | 445 | case CS_CALLEE_SHUTDOWN: |
443 | /* maybe the other peer closed asynchronously... */ | 446 | /* maybe the other peer closed asynchronously... */ |
444 | GNUNET_SERVICE_client_continue(line->client); | 447 | GNUNET_SERVICE_client_continue (line->client); |
445 | return; | 448 | return; |
446 | 449 | ||
447 | case CS_CALLER_CALLING: | 450 | case CS_CALLER_CALLING: |
448 | ch->status = CS_CALLER_SHUTDOWN; | 451 | ch->status = CS_CALLER_SHUTDOWN; |
449 | break; | 452 | break; |
450 | 453 | ||
451 | case CS_CALLER_CONNECTED: | 454 | case CS_CALLER_CONNECTED: |
452 | ch->status = CS_CALLER_SHUTDOWN; | 455 | ch->status = CS_CALLER_SHUTDOWN; |
453 | break; | 456 | break; |
454 | 457 | ||
455 | case CS_CALLER_SHUTDOWN: | 458 | case CS_CALLER_SHUTDOWN: |
456 | /* maybe the other peer closed asynchronously... */ | 459 | /* maybe the other peer closed asynchronously... */ |
457 | GNUNET_SERVICE_client_continue(line->client); | 460 | GNUNET_SERVICE_client_continue (line->client); |
458 | return; | 461 | return; |
459 | } | 462 | } |
460 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending HANG_UP message via cadet\n"); | 463 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending HANG_UP message via cadet\n"); |
461 | e = | 464 | e = |
462 | GNUNET_MQ_msg(mhum, GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_HANG_UP); | 465 | GNUNET_MQ_msg (mhum, GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_HANG_UP); |
463 | GNUNET_MQ_notify_sent(e, &mq_done_finish_caller_shutdown, ch); | 466 | GNUNET_MQ_notify_sent (e, &mq_done_finish_caller_shutdown, ch); |
464 | GNUNET_MQ_send(ch->mq, e); | 467 | GNUNET_MQ_send (ch->mq, e); |
465 | GNUNET_SERVICE_client_continue(line->client); | 468 | GNUNET_SERVICE_client_continue (line->client); |
466 | } | 469 | } |
467 | 470 | ||
468 | 471 | ||
@@ -473,8 +476,8 @@ handle_client_hangup_message(void *cls, | |||
473 | * @param msg the message from the client | 476 | * @param msg the message from the client |
474 | */ | 477 | */ |
475 | static void | 478 | static void |
476 | handle_client_suspend_message(void *cls, | 479 | handle_client_suspend_message (void *cls, |
477 | const struct ClientPhoneSuspendMessage *msg) | 480 | const struct ClientPhoneSuspendMessage *msg) |
478 | { | 481 | { |
479 | struct Line *line = cls; | 482 | struct Line *line = cls; |
480 | struct GNUNET_MQ_Envelope *e; | 483 | struct GNUNET_MQ_Envelope *e; |
@@ -485,62 +488,62 @@ handle_client_suspend_message(void *cls, | |||
485 | if (msg->cid == ch->cid) | 488 | if (msg->cid == ch->cid) |
486 | break; | 489 | break; |
487 | if (NULL == ch) | 490 | if (NULL == ch) |
488 | { | 491 | { |
489 | /* could have been destroyed asynchronously, ignore message */ | 492 | /* could have been destroyed asynchronously, ignore message */ |
490 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Channel %u not found\n", msg->cid); | 493 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Channel %u not found\n", msg->cid); |
491 | GNUNET_SERVICE_client_continue(line->client); | 494 | GNUNET_SERVICE_client_continue (line->client); |
492 | return; | 495 | return; |
493 | } | 496 | } |
494 | if (GNUNET_YES == ch->suspended_local) | 497 | if (GNUNET_YES == ch->suspended_local) |
495 | { | 498 | { |
496 | GNUNET_break(0); | 499 | GNUNET_break (0); |
497 | GNUNET_SERVICE_client_drop(line->client); | 500 | GNUNET_SERVICE_client_drop (line->client); |
498 | return; | 501 | return; |
499 | } | 502 | } |
500 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 503 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
501 | "Received SUSPEND for channel %u which is in state %d\n", | 504 | "Received SUSPEND for channel %u which is in state %d\n", |
502 | msg->cid, | 505 | msg->cid, |
503 | ch->status); | 506 | ch->status); |
504 | switch (ch->status) | 507 | switch (ch->status) |
505 | { | 508 | { |
506 | case CS_CALLEE_INIT: | 509 | case CS_CALLEE_INIT: |
507 | GNUNET_break(0); | 510 | GNUNET_break (0); |
508 | GNUNET_SERVICE_client_drop(line->client); | 511 | GNUNET_SERVICE_client_drop (line->client); |
509 | return; | 512 | return; |
510 | 513 | ||
511 | case CS_CALLEE_RINGING: | 514 | case CS_CALLEE_RINGING: |
512 | GNUNET_break(0); | 515 | GNUNET_break (0); |
513 | GNUNET_SERVICE_client_drop(line->client); | 516 | GNUNET_SERVICE_client_drop (line->client); |
514 | return; | 517 | return; |
515 | 518 | ||
516 | case CS_CALLEE_CONNECTED: | 519 | case CS_CALLEE_CONNECTED: |
517 | ch->suspended_local = GNUNET_YES; | 520 | ch->suspended_local = GNUNET_YES; |
518 | break; | 521 | break; |
519 | 522 | ||
520 | case CS_CALLEE_SHUTDOWN: | 523 | case CS_CALLEE_SHUTDOWN: |
521 | /* maybe the other peer closed asynchronously... */ | 524 | /* maybe the other peer closed asynchronously... */ |
522 | GNUNET_SERVICE_client_continue(line->client); | 525 | GNUNET_SERVICE_client_continue (line->client); |
523 | return; | 526 | return; |
524 | 527 | ||
525 | case CS_CALLER_CALLING: | 528 | case CS_CALLER_CALLING: |
526 | GNUNET_break(0); | 529 | GNUNET_break (0); |
527 | GNUNET_SERVICE_client_drop(line->client); | 530 | GNUNET_SERVICE_client_drop (line->client); |
528 | return; | 531 | return; |
529 | 532 | ||
530 | case CS_CALLER_CONNECTED: | 533 | case CS_CALLER_CONNECTED: |
531 | ch->suspended_local = GNUNET_YES; | 534 | ch->suspended_local = GNUNET_YES; |
532 | break; | 535 | break; |
533 | 536 | ||
534 | case CS_CALLER_SHUTDOWN: | 537 | case CS_CALLER_SHUTDOWN: |
535 | /* maybe the other peer closed asynchronously... */ | 538 | /* maybe the other peer closed asynchronously... */ |
536 | GNUNET_SERVICE_client_continue(line->client); | 539 | GNUNET_SERVICE_client_continue (line->client); |
537 | return; | 540 | return; |
538 | } | 541 | } |
539 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending SUSPEND message via cadet\n"); | 542 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUSPEND message via cadet\n"); |
540 | e = | 543 | e = |
541 | GNUNET_MQ_msg(mhum, GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_SUSPEND); | 544 | GNUNET_MQ_msg (mhum, GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_SUSPEND); |
542 | GNUNET_MQ_send(ch->mq, e); | 545 | GNUNET_MQ_send (ch->mq, e); |
543 | GNUNET_SERVICE_client_continue(line->client); | 546 | GNUNET_SERVICE_client_continue (line->client); |
544 | } | 547 | } |
545 | 548 | ||
546 | 549 | ||
@@ -551,8 +554,8 @@ handle_client_suspend_message(void *cls, | |||
551 | * @param msg the message from the client | 554 | * @param msg the message from the client |
552 | */ | 555 | */ |
553 | static void | 556 | static void |
554 | handle_client_resume_message(void *cls, | 557 | handle_client_resume_message (void *cls, |
555 | const struct ClientPhoneResumeMessage *msg) | 558 | const struct ClientPhoneResumeMessage *msg) |
556 | { | 559 | { |
557 | struct Line *line = cls; | 560 | struct Line *line = cls; |
558 | struct GNUNET_MQ_Envelope *e; | 561 | struct GNUNET_MQ_Envelope *e; |
@@ -563,61 +566,61 @@ handle_client_resume_message(void *cls, | |||
563 | if (msg->cid == ch->cid) | 566 | if (msg->cid == ch->cid) |
564 | break; | 567 | break; |
565 | if (NULL == ch) | 568 | if (NULL == ch) |
566 | { | 569 | { |
567 | /* could have been destroyed asynchronously, ignore message */ | 570 | /* could have been destroyed asynchronously, ignore message */ |
568 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Channel %u not found\n", msg->cid); | 571 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Channel %u not found\n", msg->cid); |
569 | GNUNET_SERVICE_client_continue(line->client); | 572 | GNUNET_SERVICE_client_continue (line->client); |
570 | return; | 573 | return; |
571 | } | 574 | } |
572 | if (GNUNET_YES != ch->suspended_local) | 575 | if (GNUNET_YES != ch->suspended_local) |
573 | { | 576 | { |
574 | GNUNET_break(0); | 577 | GNUNET_break (0); |
575 | GNUNET_SERVICE_client_drop(line->client); | 578 | GNUNET_SERVICE_client_drop (line->client); |
576 | return; | 579 | return; |
577 | } | 580 | } |
578 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 581 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
579 | "Received RESUME for channel %u which is in state %d\n", | 582 | "Received RESUME for channel %u which is in state %d\n", |
580 | msg->cid, | 583 | msg->cid, |
581 | ch->status); | 584 | ch->status); |
582 | switch (ch->status) | 585 | switch (ch->status) |
583 | { | 586 | { |
584 | case CS_CALLEE_INIT: | 587 | case CS_CALLEE_INIT: |
585 | GNUNET_break(0); | 588 | GNUNET_break (0); |
586 | GNUNET_SERVICE_client_drop(line->client); | 589 | GNUNET_SERVICE_client_drop (line->client); |
587 | return; | 590 | return; |
588 | 591 | ||
589 | case CS_CALLEE_RINGING: | 592 | case CS_CALLEE_RINGING: |
590 | GNUNET_break(0); | 593 | GNUNET_break (0); |
591 | GNUNET_SERVICE_client_drop(line->client); | 594 | GNUNET_SERVICE_client_drop (line->client); |
592 | return; | 595 | return; |
593 | 596 | ||
594 | case CS_CALLEE_CONNECTED: | 597 | case CS_CALLEE_CONNECTED: |
595 | ch->suspended_local = GNUNET_NO; | 598 | ch->suspended_local = GNUNET_NO; |
596 | break; | 599 | break; |
597 | 600 | ||
598 | case CS_CALLEE_SHUTDOWN: | 601 | case CS_CALLEE_SHUTDOWN: |
599 | /* maybe the other peer closed asynchronously... */ | 602 | /* maybe the other peer closed asynchronously... */ |
600 | GNUNET_SERVICE_client_continue(line->client); | 603 | GNUNET_SERVICE_client_continue (line->client); |
601 | return; | 604 | return; |
602 | 605 | ||
603 | case CS_CALLER_CALLING: | 606 | case CS_CALLER_CALLING: |
604 | GNUNET_break(0); | 607 | GNUNET_break (0); |
605 | GNUNET_SERVICE_client_drop(line->client); | 608 | GNUNET_SERVICE_client_drop (line->client); |
606 | return; | 609 | return; |
607 | 610 | ||
608 | case CS_CALLER_CONNECTED: | 611 | case CS_CALLER_CONNECTED: |
609 | ch->suspended_local = GNUNET_NO; | 612 | ch->suspended_local = GNUNET_NO; |
610 | break; | 613 | break; |
611 | 614 | ||
612 | case CS_CALLER_SHUTDOWN: | 615 | case CS_CALLER_SHUTDOWN: |
613 | /* maybe the other peer closed asynchronously... */ | 616 | /* maybe the other peer closed asynchronously... */ |
614 | GNUNET_SERVICE_client_drop(line->client); | 617 | GNUNET_SERVICE_client_drop (line->client); |
615 | return; | 618 | return; |
616 | } | 619 | } |
617 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending RESUME message via cadet\n"); | 620 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending RESUME message via cadet\n"); |
618 | e = GNUNET_MQ_msg(mhum, GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_RESUME); | 621 | e = GNUNET_MQ_msg (mhum, GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_RESUME); |
619 | GNUNET_MQ_send(ch->mq, e); | 622 | GNUNET_MQ_send (ch->mq, e); |
620 | GNUNET_SERVICE_client_continue(line->client); | 623 | GNUNET_SERVICE_client_continue (line->client); |
621 | } | 624 | } |
622 | 625 | ||
623 | 626 | ||
@@ -627,7 +630,7 @@ handle_client_resume_message(void *cls, | |||
627 | * @param cls the `struct Channel` we are transmitting for | 630 | * @param cls the `struct Channel` we are transmitting for |
628 | */ | 631 | */ |
629 | static void | 632 | static void |
630 | channel_audio_sent_notify(void *cls) | 633 | channel_audio_sent_notify (void *cls) |
631 | { | 634 | { |
632 | struct Channel *ch = cls; | 635 | struct Channel *ch = cls; |
633 | 636 | ||
@@ -643,10 +646,10 @@ channel_audio_sent_notify(void *cls) | |||
643 | * @return #GNUNET_OK (any data is ok) | 646 | * @return #GNUNET_OK (any data is ok) |
644 | */ | 647 | */ |
645 | static int | 648 | static int |
646 | check_client_audio_message(void *cls, const struct ClientAudioMessage *msg) | 649 | check_client_audio_message (void *cls, const struct ClientAudioMessage *msg) |
647 | { | 650 | { |
648 | (void)cls; | 651 | (void) cls; |
649 | (void)msg; | 652 | (void) msg; |
650 | return GNUNET_OK; | 653 | return GNUNET_OK; |
651 | } | 654 | } |
652 | 655 | ||
@@ -658,72 +661,72 @@ check_client_audio_message(void *cls, const struct ClientAudioMessage *msg) | |||
658 | * @param msg the message from the client | 661 | * @param msg the message from the client |
659 | */ | 662 | */ |
660 | static void | 663 | static void |
661 | handle_client_audio_message(void *cls, const struct ClientAudioMessage *msg) | 664 | handle_client_audio_message (void *cls, const struct ClientAudioMessage *msg) |
662 | { | 665 | { |
663 | struct Line *line = cls; | 666 | struct Line *line = cls; |
664 | struct CadetAudioMessage *mam; | 667 | struct CadetAudioMessage *mam; |
665 | struct Channel *ch; | 668 | struct Channel *ch; |
666 | size_t size; | 669 | size_t size; |
667 | 670 | ||
668 | size = ntohs(msg->header.size) - sizeof(struct ClientAudioMessage); | 671 | size = ntohs (msg->header.size) - sizeof(struct ClientAudioMessage); |
669 | ch = find_channel_by_line(line, msg->cid); | 672 | ch = find_channel_by_line (line, msg->cid); |
670 | if (NULL == ch) | 673 | if (NULL == ch) |
671 | { | 674 | { |
672 | /* could have been destroyed asynchronously, ignore message */ | 675 | /* could have been destroyed asynchronously, ignore message */ |
673 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Channel %u not found\n", msg->cid); | 676 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Channel %u not found\n", msg->cid); |
674 | GNUNET_SERVICE_client_continue(line->client); | 677 | GNUNET_SERVICE_client_continue (line->client); |
675 | return; | 678 | return; |
676 | } | 679 | } |
677 | 680 | ||
678 | switch (ch->status) | 681 | switch (ch->status) |
679 | { | 682 | { |
680 | case CS_CALLEE_INIT: | 683 | case CS_CALLEE_INIT: |
681 | case CS_CALLEE_RINGING: | 684 | case CS_CALLEE_RINGING: |
682 | case CS_CALLER_CALLING: | 685 | case CS_CALLER_CALLING: |
683 | GNUNET_break(0); | 686 | GNUNET_break (0); |
684 | GNUNET_SERVICE_client_drop(line->client); | 687 | GNUNET_SERVICE_client_drop (line->client); |
685 | return; | 688 | return; |
686 | 689 | ||
687 | case CS_CALLEE_CONNECTED: | 690 | case CS_CALLEE_CONNECTED: |
688 | case CS_CALLER_CONNECTED: | 691 | case CS_CALLER_CONNECTED: |
689 | /* common case, handled below */ | 692 | /* common case, handled below */ |
690 | break; | 693 | break; |
691 | 694 | ||
692 | case CS_CALLEE_SHUTDOWN: | 695 | case CS_CALLEE_SHUTDOWN: |
693 | case CS_CALLER_SHUTDOWN: | 696 | case CS_CALLER_SHUTDOWN: |
694 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, | 697 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, |
695 | "Cadet audio channel in shutdown; audio data dropped\n"); | 698 | "Cadet audio channel in shutdown; audio data dropped\n"); |
696 | GNUNET_SERVICE_client_continue(line->client); | 699 | GNUNET_SERVICE_client_continue (line->client); |
697 | return; | 700 | return; |
698 | } | 701 | } |
699 | if (GNUNET_YES == ch->suspended_local) | 702 | if (GNUNET_YES == ch->suspended_local) |
700 | { | 703 | { |
701 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | 704 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
702 | "This channel is suspended locally\n"); | 705 | "This channel is suspended locally\n"); |
703 | GNUNET_SERVICE_client_drop(line->client); | 706 | GNUNET_SERVICE_client_drop (line->client); |
704 | return; | 707 | return; |
705 | } | 708 | } |
706 | if (NULL != ch->env) | 709 | if (NULL != ch->env) |
707 | { | 710 | { |
708 | /* NOTE: we may want to not do this and instead combine the data */ | 711 | /* NOTE: we may want to not do this and instead combine the data */ |
709 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 712 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
710 | "Bandwidth insufficient; dropping previous audio data segment\n"); | 713 | "Bandwidth insufficient; dropping previous audio data segment\n"); |
711 | GNUNET_MQ_send_cancel(ch->env); | 714 | GNUNET_MQ_send_cancel (ch->env); |
712 | ch->env = NULL; | 715 | ch->env = NULL; |
713 | } | 716 | } |
714 | 717 | ||
715 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 718 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
716 | "Received %u bytes of AUDIO data from client CID %u\n", | 719 | "Received %u bytes of AUDIO data from client CID %u\n", |
717 | (unsigned int)size, | 720 | (unsigned int) size, |
718 | msg->cid); | 721 | msg->cid); |
719 | ch->env = GNUNET_MQ_msg_extra(mam, | 722 | ch->env = GNUNET_MQ_msg_extra (mam, |
720 | size, | 723 | size, |
721 | GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_AUDIO); | 724 | GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_AUDIO); |
722 | GNUNET_memcpy(&mam[1], &msg[1], size); | 725 | GNUNET_memcpy (&mam[1], &msg[1], size); |
723 | /* FIXME: set options for unreliable transmission */ | 726 | /* FIXME: set options for unreliable transmission */ |
724 | GNUNET_MQ_notify_sent(ch->env, &channel_audio_sent_notify, ch); | 727 | GNUNET_MQ_notify_sent (ch->env, &channel_audio_sent_notify, ch); |
725 | GNUNET_MQ_send(ch->mq, ch->env); | 728 | GNUNET_MQ_send (ch->mq, ch->env); |
726 | GNUNET_SERVICE_client_continue(line->client); | 729 | GNUNET_SERVICE_client_continue (line->client); |
727 | } | 730 | } |
728 | 731 | ||
729 | 732 | ||
@@ -734,7 +737,7 @@ handle_client_audio_message(void *cls, const struct ClientAudioMessage *msg) | |||
734 | * @param msg the incoming message | 737 | * @param msg the incoming message |
735 | */ | 738 | */ |
736 | static void | 739 | static void |
737 | handle_cadet_ring_message(void *cls, const struct CadetPhoneRingMessage *msg) | 740 | handle_cadet_ring_message (void *cls, const struct CadetPhoneRingMessage *msg) |
738 | { | 741 | { |
739 | struct Channel *ch = cls; | 742 | struct Channel *ch = cls; |
740 | struct Line *line = ch->line; | 743 | struct Line *line = ch->line; |
@@ -742,49 +745,49 @@ handle_cadet_ring_message(void *cls, const struct CadetPhoneRingMessage *msg) | |||
742 | struct ClientPhoneRingMessage *cring; | 745 | struct ClientPhoneRingMessage *cring; |
743 | struct CadetPhoneRingInfoPS rs; | 746 | struct CadetPhoneRingInfoPS rs; |
744 | 747 | ||
745 | rs.purpose.purpose = htonl(GNUNET_SIGNATURE_PURPOSE_CONVERSATION_RING); | 748 | rs.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CONVERSATION_RING); |
746 | rs.purpose.size = htonl(sizeof(struct CadetPhoneRingInfoPS)); | 749 | rs.purpose.size = htonl (sizeof(struct CadetPhoneRingInfoPS)); |
747 | rs.line_port = line->line_port; | 750 | rs.line_port = line->line_port; |
748 | rs.target_peer = my_identity; | 751 | rs.target_peer = my_identity; |
749 | rs.expiration_time = msg->expiration_time; | 752 | rs.expiration_time = msg->expiration_time; |
750 | 753 | ||
751 | if (GNUNET_OK != | 754 | if (GNUNET_OK != |
752 | GNUNET_CRYPTO_ecdsa_verify(GNUNET_SIGNATURE_PURPOSE_CONVERSATION_RING, | 755 | GNUNET_CRYPTO_ecdsa_verify (GNUNET_SIGNATURE_PURPOSE_CONVERSATION_RING, |
753 | &rs.purpose, | 756 | &rs.purpose, |
754 | &msg->signature, | 757 | &msg->signature, |
755 | &msg->caller_id)) | 758 | &msg->caller_id)) |
756 | { | 759 | { |
757 | GNUNET_break_op(0); | 760 | GNUNET_break_op (0); |
758 | destroy_line_cadet_channels(ch); | 761 | destroy_line_cadet_channels (ch); |
759 | return; | 762 | return; |
760 | } | 763 | } |
761 | if (0 == GNUNET_TIME_absolute_get_remaining( | 764 | if (0 == GNUNET_TIME_absolute_get_remaining ( |
762 | GNUNET_TIME_absolute_ntoh(msg->expiration_time)) | 765 | GNUNET_TIME_absolute_ntoh (msg->expiration_time)) |
763 | .rel_value_us) | 766 | .rel_value_us) |
764 | { | 767 | { |
765 | /* ancient call, replay? */ | 768 | /* ancient call, replay? */ |
766 | GNUNET_break_op(0); | 769 | GNUNET_break_op (0); |
767 | /* Note that our reliance on time here is awkward; better would be | 770 | /* Note that our reliance on time here is awkward; better would be |
768 | to use a more complex challenge-response protocol against | 771 | to use a more complex challenge-response protocol against |
769 | replay attacks. Left for future work ;-). */ | 772 | replay attacks. Left for future work ;-). */ |
770 | destroy_line_cadet_channels(ch); | 773 | destroy_line_cadet_channels (ch); |
771 | return; | 774 | return; |
772 | } | 775 | } |
773 | if (CS_CALLEE_INIT != ch->status) | 776 | if (CS_CALLEE_INIT != ch->status) |
774 | { | 777 | { |
775 | GNUNET_break_op(0); | 778 | GNUNET_break_op (0); |
776 | destroy_line_cadet_channels(ch); | 779 | destroy_line_cadet_channels (ch); |
777 | return; | 780 | return; |
778 | } | 781 | } |
779 | GNUNET_CADET_receive_done(ch->channel); | 782 | GNUNET_CADET_receive_done (ch->channel); |
780 | ch->status = CS_CALLEE_RINGING; | 783 | ch->status = CS_CALLEE_RINGING; |
781 | env = GNUNET_MQ_msg(cring, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RING); | 784 | env = GNUNET_MQ_msg (cring, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RING); |
782 | cring->cid = ch->cid; | 785 | cring->cid = ch->cid; |
783 | cring->caller_id = msg->caller_id; | 786 | cring->caller_id = msg->caller_id; |
784 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 787 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
785 | "Sending RING message to client. CID is %u\n", | 788 | "Sending RING message to client. CID is %u\n", |
786 | (unsigned int)ch->cid); | 789 | (unsigned int) ch->cid); |
787 | GNUNET_MQ_send(line->mq, env); | 790 | GNUNET_MQ_send (line->mq, env); |
788 | } | 791 | } |
789 | 792 | ||
790 | 793 | ||
@@ -795,8 +798,8 @@ handle_cadet_ring_message(void *cls, const struct CadetPhoneRingMessage *msg) | |||
795 | * @param message the incoming message | 798 | * @param message the incoming message |
796 | */ | 799 | */ |
797 | static void | 800 | static void |
798 | handle_cadet_hangup_message(void *cls, | 801 | handle_cadet_hangup_message (void *cls, |
799 | const struct CadetPhoneHangupMessage *message) | 802 | const struct CadetPhoneHangupMessage *message) |
800 | { | 803 | { |
801 | struct Channel *ch = cls; | 804 | struct Channel *ch = cls; |
802 | struct Line *line = ch->line; | 805 | struct Line *line = ch->line; |
@@ -805,35 +808,35 @@ handle_cadet_hangup_message(void *cls, | |||
805 | enum ChannelStatus status; | 808 | enum ChannelStatus status; |
806 | uint32_t cid; | 809 | uint32_t cid; |
807 | 810 | ||
808 | (void)message; | 811 | (void) message; |
809 | GNUNET_CADET_receive_done(ch->channel); | 812 | GNUNET_CADET_receive_done (ch->channel); |
810 | cid = ch->cid; | 813 | cid = ch->cid; |
811 | status = ch->status; | 814 | status = ch->status; |
812 | destroy_line_cadet_channels(ch); | 815 | destroy_line_cadet_channels (ch); |
813 | switch (status) | 816 | switch (status) |
814 | { | 817 | { |
815 | case CS_CALLEE_INIT: | 818 | case CS_CALLEE_INIT: |
816 | GNUNET_break_op(0); | 819 | GNUNET_break_op (0); |
817 | return; | 820 | return; |
818 | 821 | ||
819 | case CS_CALLEE_RINGING: | 822 | case CS_CALLEE_RINGING: |
820 | case CS_CALLEE_CONNECTED: | 823 | case CS_CALLEE_CONNECTED: |
821 | break; | 824 | break; |
822 | 825 | ||
823 | case CS_CALLEE_SHUTDOWN: | 826 | case CS_CALLEE_SHUTDOWN: |
824 | return; | 827 | return; |
825 | 828 | ||
826 | case CS_CALLER_CALLING: | 829 | case CS_CALLER_CALLING: |
827 | case CS_CALLER_CONNECTED: | 830 | case CS_CALLER_CONNECTED: |
828 | break; | 831 | break; |
829 | 832 | ||
830 | case CS_CALLER_SHUTDOWN: | 833 | case CS_CALLER_SHUTDOWN: |
831 | return; | 834 | return; |
832 | } | 835 | } |
833 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending HANG UP message to client\n"); | 836 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending HANG UP message to client\n"); |
834 | env = GNUNET_MQ_msg(hup, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP); | 837 | env = GNUNET_MQ_msg (hup, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP); |
835 | hup->cid = cid; | 838 | hup->cid = cid; |
836 | GNUNET_MQ_send(line->mq, env); | 839 | GNUNET_MQ_send (line->mq, env); |
837 | } | 840 | } |
838 | 841 | ||
839 | 842 | ||
@@ -844,48 +847,48 @@ handle_cadet_hangup_message(void *cls, | |||
844 | * @param message the incoming message | 847 | * @param message the incoming message |
845 | */ | 848 | */ |
846 | static void | 849 | static void |
847 | handle_cadet_pickup_message(void *cls, | 850 | handle_cadet_pickup_message (void *cls, |
848 | const struct CadetPhonePickupMessage *message) | 851 | const struct CadetPhonePickupMessage *message) |
849 | { | 852 | { |
850 | struct Channel *ch = cls; | 853 | struct Channel *ch = cls; |
851 | struct Line *line = ch->line; | 854 | struct Line *line = ch->line; |
852 | struct GNUNET_MQ_Envelope *env; | 855 | struct GNUNET_MQ_Envelope *env; |
853 | struct ClientPhonePickedupMessage *pick; | 856 | struct ClientPhonePickedupMessage *pick; |
854 | 857 | ||
855 | (void)message; | 858 | (void) message; |
856 | GNUNET_CADET_receive_done(ch->channel); | 859 | GNUNET_CADET_receive_done (ch->channel); |
857 | switch (ch->status) | 860 | switch (ch->status) |
858 | { | 861 | { |
859 | case CS_CALLEE_INIT: | 862 | case CS_CALLEE_INIT: |
860 | case CS_CALLEE_RINGING: | 863 | case CS_CALLEE_RINGING: |
861 | case CS_CALLEE_CONNECTED: | 864 | case CS_CALLEE_CONNECTED: |
862 | GNUNET_break_op(0); | 865 | GNUNET_break_op (0); |
863 | destroy_line_cadet_channels(ch); | 866 | destroy_line_cadet_channels (ch); |
864 | return; | 867 | return; |
865 | 868 | ||
866 | case CS_CALLEE_SHUTDOWN: | 869 | case CS_CALLEE_SHUTDOWN: |
867 | GNUNET_break_op(0); | 870 | GNUNET_break_op (0); |
868 | destroy_line_cadet_channels(ch); | 871 | destroy_line_cadet_channels (ch); |
869 | return; | 872 | return; |
870 | 873 | ||
871 | case CS_CALLER_CALLING: | 874 | case CS_CALLER_CALLING: |
872 | ch->status = CS_CALLER_CONNECTED; | 875 | ch->status = CS_CALLER_CONNECTED; |
873 | break; | 876 | break; |
874 | 877 | ||
875 | case CS_CALLER_CONNECTED: | 878 | case CS_CALLER_CONNECTED: |
876 | GNUNET_break_op(0); | 879 | GNUNET_break_op (0); |
877 | return; | 880 | return; |
878 | 881 | ||
879 | case CS_CALLER_SHUTDOWN: | 882 | case CS_CALLER_SHUTDOWN: |
880 | GNUNET_break_op(0); | 883 | GNUNET_break_op (0); |
881 | mq_done_finish_caller_shutdown(ch); | 884 | mq_done_finish_caller_shutdown (ch); |
882 | return; | 885 | return; |
883 | } | 886 | } |
884 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending PICKED UP message to client\n"); | 887 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending PICKED UP message to client\n"); |
885 | env = | 888 | env = |
886 | GNUNET_MQ_msg(pick, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICKED_UP); | 889 | GNUNET_MQ_msg (pick, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICKED_UP); |
887 | pick->cid = ch->cid; | 890 | pick->cid = ch->cid; |
888 | GNUNET_MQ_send(line->mq, env); | 891 | GNUNET_MQ_send (line->mq, env); |
889 | } | 892 | } |
890 | 893 | ||
891 | 894 | ||
@@ -896,49 +899,49 @@ handle_cadet_pickup_message(void *cls, | |||
896 | * @param message the incoming message | 899 | * @param message the incoming message |
897 | */ | 900 | */ |
898 | static void | 901 | static void |
899 | handle_cadet_suspend_message(void *cls, | 902 | handle_cadet_suspend_message (void *cls, |
900 | const struct CadetPhoneSuspendMessage *message) | 903 | const struct CadetPhoneSuspendMessage *message) |
901 | { | 904 | { |
902 | struct Channel *ch = cls; | 905 | struct Channel *ch = cls; |
903 | struct Line *line = ch->line; | 906 | struct Line *line = ch->line; |
904 | struct GNUNET_MQ_Envelope *env; | 907 | struct GNUNET_MQ_Envelope *env; |
905 | struct ClientPhoneSuspendMessage *suspend; | 908 | struct ClientPhoneSuspendMessage *suspend; |
906 | 909 | ||
907 | (void)message; | 910 | (void) message; |
908 | GNUNET_CADET_receive_done(ch->channel); | 911 | GNUNET_CADET_receive_done (ch->channel); |
909 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Suspending channel CID: %u\n", ch->cid); | 912 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suspending channel CID: %u\n", ch->cid); |
910 | switch (ch->status) | 913 | switch (ch->status) |
911 | { | 914 | { |
912 | case CS_CALLEE_INIT: | 915 | case CS_CALLEE_INIT: |
913 | GNUNET_break_op(0); | 916 | GNUNET_break_op (0); |
914 | break; | 917 | break; |
915 | 918 | ||
916 | case CS_CALLEE_RINGING: | 919 | case CS_CALLEE_RINGING: |
917 | GNUNET_break_op(0); | 920 | GNUNET_break_op (0); |
918 | break; | 921 | break; |
919 | 922 | ||
920 | case CS_CALLEE_CONNECTED: | 923 | case CS_CALLEE_CONNECTED: |
921 | ch->suspended_remote = GNUNET_YES; | 924 | ch->suspended_remote = GNUNET_YES; |
922 | break; | 925 | break; |
923 | 926 | ||
924 | case CS_CALLEE_SHUTDOWN: | 927 | case CS_CALLEE_SHUTDOWN: |
925 | return; | 928 | return; |
926 | 929 | ||
927 | case CS_CALLER_CALLING: | 930 | case CS_CALLER_CALLING: |
928 | GNUNET_break_op(0); | 931 | GNUNET_break_op (0); |
929 | break; | 932 | break; |
930 | 933 | ||
931 | case CS_CALLER_CONNECTED: | 934 | case CS_CALLER_CONNECTED: |
932 | ch->suspended_remote = GNUNET_YES; | 935 | ch->suspended_remote = GNUNET_YES; |
933 | break; | 936 | break; |
934 | 937 | ||
935 | case CS_CALLER_SHUTDOWN: | 938 | case CS_CALLER_SHUTDOWN: |
936 | return; | 939 | return; |
937 | } | 940 | } |
938 | env = | 941 | env = |
939 | GNUNET_MQ_msg(suspend, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND); | 942 | GNUNET_MQ_msg (suspend, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND); |
940 | suspend->cid = ch->cid; | 943 | suspend->cid = ch->cid; |
941 | GNUNET_MQ_send(line->mq, env); | 944 | GNUNET_MQ_send (line->mq, env); |
942 | } | 945 | } |
943 | 946 | ||
944 | 947 | ||
@@ -949,57 +952,57 @@ handle_cadet_suspend_message(void *cls, | |||
949 | * @param msg the incoming message | 952 | * @param msg the incoming message |
950 | */ | 953 | */ |
951 | static void | 954 | static void |
952 | handle_cadet_resume_message(void *cls, | 955 | handle_cadet_resume_message (void *cls, |
953 | const struct CadetPhoneResumeMessage *msg) | 956 | const struct CadetPhoneResumeMessage *msg) |
954 | { | 957 | { |
955 | struct Channel *ch = cls; | 958 | struct Channel *ch = cls; |
956 | struct Line *line; | 959 | struct Line *line; |
957 | struct GNUNET_MQ_Envelope *env; | 960 | struct GNUNET_MQ_Envelope *env; |
958 | struct ClientPhoneResumeMessage *resume; | 961 | struct ClientPhoneResumeMessage *resume; |
959 | 962 | ||
960 | (void)msg; | 963 | (void) msg; |
961 | line = ch->line; | 964 | line = ch->line; |
962 | GNUNET_CADET_receive_done(ch->channel); | 965 | GNUNET_CADET_receive_done (ch->channel); |
963 | if (GNUNET_YES != ch->suspended_remote) | 966 | if (GNUNET_YES != ch->suspended_remote) |
964 | { | 967 | { |
965 | GNUNET_log( | 968 | GNUNET_log ( |
966 | GNUNET_ERROR_TYPE_DEBUG, | 969 | GNUNET_ERROR_TYPE_DEBUG, |
967 | "RESUME message received for non-suspended channel, dropping channel.\n"); | 970 | "RESUME message received for non-suspended channel, dropping channel.\n"); |
968 | destroy_line_cadet_channels(ch); | 971 | destroy_line_cadet_channels (ch); |
969 | return; | 972 | return; |
970 | } | 973 | } |
971 | switch (ch->status) | 974 | switch (ch->status) |
972 | { | 975 | { |
973 | case CS_CALLEE_INIT: | 976 | case CS_CALLEE_INIT: |
974 | GNUNET_break(0); | 977 | GNUNET_break (0); |
975 | break; | 978 | break; |
976 | 979 | ||
977 | case CS_CALLEE_RINGING: | 980 | case CS_CALLEE_RINGING: |
978 | GNUNET_break(0); | 981 | GNUNET_break (0); |
979 | break; | 982 | break; |
980 | 983 | ||
981 | case CS_CALLEE_CONNECTED: | 984 | case CS_CALLEE_CONNECTED: |
982 | ch->suspended_remote = GNUNET_NO; | 985 | ch->suspended_remote = GNUNET_NO; |
983 | break; | 986 | break; |
984 | 987 | ||
985 | case CS_CALLEE_SHUTDOWN: | 988 | case CS_CALLEE_SHUTDOWN: |
986 | return; | 989 | return; |
987 | 990 | ||
988 | case CS_CALLER_CALLING: | 991 | case CS_CALLER_CALLING: |
989 | GNUNET_break(0); | 992 | GNUNET_break (0); |
990 | break; | 993 | break; |
991 | 994 | ||
992 | case CS_CALLER_CONNECTED: | 995 | case CS_CALLER_CONNECTED: |
993 | ch->suspended_remote = GNUNET_NO; | 996 | ch->suspended_remote = GNUNET_NO; |
994 | break; | 997 | break; |
995 | 998 | ||
996 | case CS_CALLER_SHUTDOWN: | 999 | case CS_CALLER_SHUTDOWN: |
997 | return; | 1000 | return; |
998 | } | 1001 | } |
999 | env = | 1002 | env = |
1000 | GNUNET_MQ_msg(resume, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME); | 1003 | GNUNET_MQ_msg (resume, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME); |
1001 | resume->cid = ch->cid; | 1004 | resume->cid = ch->cid; |
1002 | GNUNET_MQ_send(line->mq, env); | 1005 | GNUNET_MQ_send (line->mq, env); |
1003 | } | 1006 | } |
1004 | 1007 | ||
1005 | 1008 | ||
@@ -1011,10 +1014,10 @@ handle_cadet_resume_message(void *cls, | |||
1011 | * @return #GNUNET_OK (always) | 1014 | * @return #GNUNET_OK (always) |
1012 | */ | 1015 | */ |
1013 | static int | 1016 | static int |
1014 | check_cadet_audio_message(void *cls, const struct CadetAudioMessage *msg) | 1017 | check_cadet_audio_message (void *cls, const struct CadetAudioMessage *msg) |
1015 | { | 1018 | { |
1016 | (void)cls; | 1019 | (void) cls; |
1017 | (void)msg; | 1020 | (void) msg; |
1018 | return GNUNET_OK; /* any payload is fine */ | 1021 | return GNUNET_OK; /* any payload is fine */ |
1019 | } | 1022 | } |
1020 | 1023 | ||
@@ -1026,33 +1029,33 @@ check_cadet_audio_message(void *cls, const struct CadetAudioMessage *msg) | |||
1026 | * @param msg the incoming message | 1029 | * @param msg the incoming message |
1027 | */ | 1030 | */ |
1028 | static void | 1031 | static void |
1029 | handle_cadet_audio_message(void *cls, const struct CadetAudioMessage *msg) | 1032 | handle_cadet_audio_message (void *cls, const struct CadetAudioMessage *msg) |
1030 | { | 1033 | { |
1031 | struct Channel *ch = cls; | 1034 | struct Channel *ch = cls; |
1032 | size_t msize = ntohs(msg->header.size) - sizeof(struct CadetAudioMessage); | 1035 | size_t msize = ntohs (msg->header.size) - sizeof(struct CadetAudioMessage); |
1033 | struct GNUNET_MQ_Envelope *env; | 1036 | struct GNUNET_MQ_Envelope *env; |
1034 | struct ClientAudioMessage *cam; | 1037 | struct ClientAudioMessage *cam; |
1035 | 1038 | ||
1036 | GNUNET_CADET_receive_done(ch->channel); | 1039 | GNUNET_CADET_receive_done (ch->channel); |
1037 | if ((GNUNET_YES == ch->suspended_local) || | 1040 | if ((GNUNET_YES == ch->suspended_local) || |
1038 | (GNUNET_YES == ch->suspended_remote)) | 1041 | (GNUNET_YES == ch->suspended_remote)) |
1039 | { | 1042 | { |
1040 | GNUNET_log( | 1043 | GNUNET_log ( |
1041 | GNUNET_ERROR_TYPE_DEBUG, | 1044 | GNUNET_ERROR_TYPE_DEBUG, |
1042 | "Received %u bytes of AUDIO data on suspended channel CID %u; dropping\n", | 1045 | "Received %u bytes of AUDIO data on suspended channel CID %u; dropping\n", |
1043 | (unsigned int)msize, | 1046 | (unsigned int) msize, |
1044 | ch->cid); | 1047 | ch->cid); |
1045 | return; | 1048 | return; |
1046 | } | 1049 | } |
1047 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1050 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1048 | "Forwarding %u bytes of AUDIO data to client CID %u\n", | 1051 | "Forwarding %u bytes of AUDIO data to client CID %u\n", |
1049 | (unsigned int)msize, | 1052 | (unsigned int) msize, |
1050 | ch->cid); | 1053 | ch->cid); |
1051 | env = | 1054 | env = |
1052 | GNUNET_MQ_msg_extra(cam, msize, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO); | 1055 | GNUNET_MQ_msg_extra (cam, msize, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO); |
1053 | cam->cid = ch->cid; | 1056 | cam->cid = ch->cid; |
1054 | GNUNET_memcpy(&cam[1], &msg[1], msize); | 1057 | GNUNET_memcpy (&cam[1], &msg[1], msize); |
1055 | GNUNET_MQ_send(ch->line->mq, env); | 1058 | GNUNET_MQ_send (ch->line->mq, env); |
1056 | } | 1059 | } |
1057 | 1060 | ||
1058 | 1061 | ||
@@ -1064,16 +1067,16 @@ handle_cadet_audio_message(void *cls, const struct CadetAudioMessage *msg) | |||
1064 | * @param channel connection to the other end (henceforth invalid) | 1067 | * @param channel connection to the other end (henceforth invalid) |
1065 | */ | 1068 | */ |
1066 | static void | 1069 | static void |
1067 | inbound_end(void *cls, const struct GNUNET_CADET_Channel *channel) | 1070 | inbound_end (void *cls, const struct GNUNET_CADET_Channel *channel) |
1068 | { | 1071 | { |
1069 | struct Channel *ch = cls; | 1072 | struct Channel *ch = cls; |
1070 | 1073 | ||
1071 | GNUNET_assert(channel == ch->channel); | 1074 | GNUNET_assert (channel == ch->channel); |
1072 | ch->channel = NULL; | 1075 | ch->channel = NULL; |
1073 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1076 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1074 | "Channel destroyed by CADET in state %d\n", | 1077 | "Channel destroyed by CADET in state %d\n", |
1075 | ch->status); | 1078 | ch->status); |
1076 | clean_up_channel(ch); | 1079 | clean_up_channel (ch); |
1077 | } | 1080 | } |
1078 | 1081 | ||
1079 | 1082 | ||
@@ -1084,63 +1087,63 @@ inbound_end(void *cls, const struct GNUNET_CADET_Channel *channel) | |||
1084 | * @param msg the message from the client | 1087 | * @param msg the message from the client |
1085 | */ | 1088 | */ |
1086 | static void | 1089 | static void |
1087 | handle_client_call_message(void *cls, const struct ClientCallMessage *msg) | 1090 | handle_client_call_message (void *cls, const struct ClientCallMessage *msg) |
1088 | { | 1091 | { |
1089 | struct Line *line = cls; | 1092 | struct Line *line = cls; |
1090 | struct Channel *ch = GNUNET_new(struct Channel); | 1093 | struct Channel *ch = GNUNET_new (struct Channel); |
1091 | struct GNUNET_MQ_MessageHandler cadet_handlers[] = | 1094 | struct GNUNET_MQ_MessageHandler cadet_handlers[] = |
1092 | { GNUNET_MQ_hd_fixed_size(cadet_hangup_message, | 1095 | { GNUNET_MQ_hd_fixed_size (cadet_hangup_message, |
1093 | GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_HANG_UP, | 1096 | GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_HANG_UP, |
1094 | struct CadetPhoneHangupMessage, | 1097 | struct CadetPhoneHangupMessage, |
1095 | ch), | 1098 | ch), |
1096 | GNUNET_MQ_hd_fixed_size(cadet_pickup_message, | 1099 | GNUNET_MQ_hd_fixed_size (cadet_pickup_message, |
1097 | GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_PICK_UP, | 1100 | GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_PICK_UP, |
1098 | struct CadetPhonePickupMessage, | 1101 | struct CadetPhonePickupMessage, |
1099 | ch), | 1102 | ch), |
1100 | GNUNET_MQ_hd_fixed_size(cadet_suspend_message, | 1103 | GNUNET_MQ_hd_fixed_size (cadet_suspend_message, |
1101 | GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_SUSPEND, | 1104 | GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_SUSPEND, |
1102 | struct CadetPhoneSuspendMessage, | 1105 | struct CadetPhoneSuspendMessage, |
1103 | ch), | 1106 | ch), |
1104 | GNUNET_MQ_hd_fixed_size(cadet_resume_message, | 1107 | GNUNET_MQ_hd_fixed_size (cadet_resume_message, |
1105 | GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_RESUME, | 1108 | GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_RESUME, |
1106 | struct CadetPhoneResumeMessage, | 1109 | struct CadetPhoneResumeMessage, |
1107 | ch), | 1110 | ch), |
1108 | GNUNET_MQ_hd_var_size(cadet_audio_message, | 1111 | GNUNET_MQ_hd_var_size (cadet_audio_message, |
1109 | GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_AUDIO, | 1112 | GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_AUDIO, |
1110 | struct CadetAudioMessage, | 1113 | struct CadetAudioMessage, |
1111 | ch), | 1114 | ch), |
1112 | GNUNET_MQ_handler_end() }; | 1115 | GNUNET_MQ_handler_end () }; |
1113 | struct GNUNET_MQ_Envelope *e; | 1116 | struct GNUNET_MQ_Envelope *e; |
1114 | struct CadetPhoneRingMessage *ring; | 1117 | struct CadetPhoneRingMessage *ring; |
1115 | struct CadetPhoneRingInfoPS rs; | 1118 | struct CadetPhoneRingInfoPS rs; |
1116 | 1119 | ||
1117 | line->line_port = msg->line_port; | 1120 | line->line_port = msg->line_port; |
1118 | rs.purpose.purpose = htonl(GNUNET_SIGNATURE_PURPOSE_CONVERSATION_RING); | 1121 | rs.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CONVERSATION_RING); |
1119 | rs.purpose.size = htonl(sizeof(struct CadetPhoneRingInfoPS)); | 1122 | rs.purpose.size = htonl (sizeof(struct CadetPhoneRingInfoPS)); |
1120 | rs.line_port = line->line_port; | 1123 | rs.line_port = line->line_port; |
1121 | rs.target_peer = msg->target; | 1124 | rs.target_peer = msg->target; |
1122 | rs.expiration_time = | 1125 | rs.expiration_time = |
1123 | GNUNET_TIME_absolute_hton(GNUNET_TIME_relative_to_absolute(RING_TIMEOUT)); | 1126 | GNUNET_TIME_absolute_hton (GNUNET_TIME_relative_to_absolute (RING_TIMEOUT)); |
1124 | ch->line = line; | 1127 | ch->line = line; |
1125 | GNUNET_CONTAINER_DLL_insert(line->channel_head, line->channel_tail, ch); | 1128 | GNUNET_CONTAINER_DLL_insert (line->channel_head, line->channel_tail, ch); |
1126 | ch->status = CS_CALLER_CALLING; | 1129 | ch->status = CS_CALLER_CALLING; |
1127 | ch->channel = GNUNET_CADET_channel_create(cadet, | 1130 | ch->channel = GNUNET_CADET_channel_create (cadet, |
1128 | ch, | 1131 | ch, |
1129 | &msg->target, | 1132 | &msg->target, |
1130 | &msg->line_port, | 1133 | &msg->line_port, |
1131 | NULL, | 1134 | NULL, |
1132 | &inbound_end, | 1135 | &inbound_end, |
1133 | cadet_handlers); | 1136 | cadet_handlers); |
1134 | ch->mq = GNUNET_CADET_get_mq(ch->channel); | 1137 | ch->mq = GNUNET_CADET_get_mq (ch->channel); |
1135 | e = GNUNET_MQ_msg(ring, GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_RING); | 1138 | e = GNUNET_MQ_msg (ring, GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_RING); |
1136 | GNUNET_CRYPTO_ecdsa_key_get_public(&msg->caller_id, &ring->caller_id); | 1139 | GNUNET_CRYPTO_ecdsa_key_get_public (&msg->caller_id, &ring->caller_id); |
1137 | ring->expiration_time = rs.expiration_time; | 1140 | ring->expiration_time = rs.expiration_time; |
1138 | GNUNET_assert(GNUNET_OK == GNUNET_CRYPTO_ecdsa_sign(&msg->caller_id, | 1141 | GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_ecdsa_sign (&msg->caller_id, |
1139 | &rs.purpose, | 1142 | &rs.purpose, |
1140 | &ring->signature)); | 1143 | &ring->signature)); |
1141 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending RING message via CADET\n"); | 1144 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending RING message via CADET\n"); |
1142 | GNUNET_MQ_send(ch->mq, e); | 1145 | GNUNET_MQ_send (ch->mq, e); |
1143 | GNUNET_SERVICE_client_continue(line->client); | 1146 | GNUNET_SERVICE_client_continue (line->client); |
1144 | } | 1147 | } |
1145 | 1148 | ||
1146 | 1149 | ||
@@ -1154,24 +1157,24 @@ handle_client_call_message(void *cls, const struct ClientCallMessage *msg) | |||
1154 | * @return initial channel context for the channel | 1157 | * @return initial channel context for the channel |
1155 | */ | 1158 | */ |
1156 | static void * | 1159 | static void * |
1157 | inbound_channel(void *cls, | 1160 | inbound_channel (void *cls, |
1158 | struct GNUNET_CADET_Channel *channel, | 1161 | struct GNUNET_CADET_Channel *channel, |
1159 | const struct GNUNET_PeerIdentity *initiator) | 1162 | const struct GNUNET_PeerIdentity *initiator) |
1160 | { | 1163 | { |
1161 | struct Line *line = cls; | 1164 | struct Line *line = cls; |
1162 | struct Channel *ch; | 1165 | struct Channel *ch; |
1163 | 1166 | ||
1164 | (void)initiator; | 1167 | (void) initiator; |
1165 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1168 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1166 | "Received incoming cadet channel on line %p\n", | 1169 | "Received incoming cadet channel on line %p\n", |
1167 | line); | 1170 | line); |
1168 | ch = GNUNET_new(struct Channel); | 1171 | ch = GNUNET_new (struct Channel); |
1169 | ch->status = CS_CALLEE_INIT; | 1172 | ch->status = CS_CALLEE_INIT; |
1170 | ch->line = line; | 1173 | ch->line = line; |
1171 | ch->channel = channel; | 1174 | ch->channel = channel; |
1172 | ch->mq = GNUNET_CADET_get_mq(ch->channel); | 1175 | ch->mq = GNUNET_CADET_get_mq (ch->channel); |
1173 | ch->cid = line->cid_gen++; | 1176 | ch->cid = line->cid_gen++; |
1174 | GNUNET_CONTAINER_DLL_insert(line->channel_head, line->channel_tail, ch); | 1177 | GNUNET_CONTAINER_DLL_insert (line->channel_head, line->channel_tail, ch); |
1175 | return ch; | 1178 | return ch; |
1176 | } | 1179 | } |
1177 | 1180 | ||
@@ -1185,14 +1188,14 @@ inbound_channel(void *cls, | |||
1185 | * @return the `struct Line` for the client | 1188 | * @return the `struct Line` for the client |
1186 | */ | 1189 | */ |
1187 | static void * | 1190 | static void * |
1188 | client_connect_cb(void *cls, | 1191 | client_connect_cb (void *cls, |
1189 | struct GNUNET_SERVICE_Client *client, | 1192 | struct GNUNET_SERVICE_Client *client, |
1190 | struct GNUNET_MQ_Handle *mq) | 1193 | struct GNUNET_MQ_Handle *mq) |
1191 | { | 1194 | { |
1192 | struct Line *line; | 1195 | struct Line *line; |
1193 | 1196 | ||
1194 | (void)cls; | 1197 | (void) cls; |
1195 | line = GNUNET_new(struct Line); | 1198 | line = GNUNET_new (struct Line); |
1196 | line->client = client; | 1199 | line->client = client; |
1197 | line->mq = mq; | 1200 | line->mq = mq; |
1198 | return line; | 1201 | return line; |
@@ -1207,28 +1210,28 @@ client_connect_cb(void *cls, | |||
1207 | * @param app_ctx our `struct Line *` for @a client | 1210 | * @param app_ctx our `struct Line *` for @a client |
1208 | */ | 1211 | */ |
1209 | static void | 1212 | static void |
1210 | client_disconnect_cb(void *cls, | 1213 | client_disconnect_cb (void *cls, |
1211 | struct GNUNET_SERVICE_Client *client, | 1214 | struct GNUNET_SERVICE_Client *client, |
1212 | void *app_ctx) | 1215 | void *app_ctx) |
1213 | { | 1216 | { |
1214 | struct Line *line = app_ctx; | 1217 | struct Line *line = app_ctx; |
1215 | struct Channel *chn; | 1218 | struct Channel *chn; |
1216 | 1219 | ||
1217 | (void)cls; | 1220 | (void) cls; |
1218 | (void)client; | 1221 | (void) client; |
1219 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Client disconnected, closing line\n"); | 1222 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client disconnected, closing line\n"); |
1220 | if (NULL != line->port) | 1223 | if (NULL != line->port) |
1221 | { | 1224 | { |
1222 | GNUNET_CADET_close_port(line->port); | 1225 | GNUNET_CADET_close_port (line->port); |
1223 | line->port = NULL; | 1226 | line->port = NULL; |
1224 | } | 1227 | } |
1225 | for (struct Channel *ch = line->channel_head; NULL != ch; ch = chn) | 1228 | for (struct Channel *ch = line->channel_head; NULL != ch; ch = chn) |
1226 | { | 1229 | { |
1227 | chn = ch->next; | 1230 | chn = ch->next; |
1228 | ch->line = NULL; | 1231 | ch->line = NULL; |
1229 | destroy_line_cadet_channels(ch); | 1232 | destroy_line_cadet_channels (ch); |
1230 | } | 1233 | } |
1231 | GNUNET_free(line); | 1234 | GNUNET_free (line); |
1232 | } | 1235 | } |
1233 | 1236 | ||
1234 | 1237 | ||
@@ -1239,54 +1242,54 @@ client_disconnect_cb(void *cls, | |||
1239 | * @param msg the message from the client | 1242 | * @param msg the message from the client |
1240 | */ | 1243 | */ |
1241 | static void | 1244 | static void |
1242 | handle_client_register_message(void *cls, | 1245 | handle_client_register_message (void *cls, |
1243 | const struct ClientPhoneRegisterMessage *msg) | 1246 | const struct ClientPhoneRegisterMessage *msg) |
1244 | { | 1247 | { |
1245 | struct Line *line = cls; | 1248 | struct Line *line = cls; |
1246 | struct GNUNET_MQ_MessageHandler cadet_handlers[] = | 1249 | struct GNUNET_MQ_MessageHandler cadet_handlers[] = |
1247 | { GNUNET_MQ_hd_fixed_size(cadet_ring_message, | 1250 | { GNUNET_MQ_hd_fixed_size (cadet_ring_message, |
1248 | GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_RING, | 1251 | GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_RING, |
1249 | struct CadetPhoneRingMessage, | 1252 | struct CadetPhoneRingMessage, |
1250 | NULL), | 1253 | NULL), |
1251 | GNUNET_MQ_hd_fixed_size(cadet_hangup_message, | 1254 | GNUNET_MQ_hd_fixed_size (cadet_hangup_message, |
1252 | GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_HANG_UP, | 1255 | GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_HANG_UP, |
1253 | struct CadetPhoneHangupMessage, | 1256 | struct CadetPhoneHangupMessage, |
1254 | NULL), | 1257 | NULL), |
1255 | GNUNET_MQ_hd_fixed_size(cadet_pickup_message, | 1258 | GNUNET_MQ_hd_fixed_size (cadet_pickup_message, |
1256 | GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_PICK_UP, | 1259 | GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_PICK_UP, |
1257 | struct CadetPhonePickupMessage, | 1260 | struct CadetPhonePickupMessage, |
1258 | NULL), | 1261 | NULL), |
1259 | GNUNET_MQ_hd_fixed_size(cadet_suspend_message, | 1262 | GNUNET_MQ_hd_fixed_size (cadet_suspend_message, |
1260 | GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_SUSPEND, | 1263 | GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_SUSPEND, |
1261 | struct CadetPhoneSuspendMessage, | 1264 | struct CadetPhoneSuspendMessage, |
1262 | NULL), | 1265 | NULL), |
1263 | GNUNET_MQ_hd_fixed_size(cadet_resume_message, | 1266 | GNUNET_MQ_hd_fixed_size (cadet_resume_message, |
1264 | GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_RESUME, | 1267 | GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_RESUME, |
1265 | struct CadetPhoneResumeMessage, | 1268 | struct CadetPhoneResumeMessage, |
1266 | NULL), | 1269 | NULL), |
1267 | GNUNET_MQ_hd_var_size(cadet_audio_message, | 1270 | GNUNET_MQ_hd_var_size (cadet_audio_message, |
1268 | GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_AUDIO, | 1271 | GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_AUDIO, |
1269 | struct CadetAudioMessage, | 1272 | struct CadetAudioMessage, |
1270 | NULL), | 1273 | NULL), |
1271 | GNUNET_MQ_handler_end() }; | 1274 | GNUNET_MQ_handler_end () }; |
1272 | 1275 | ||
1273 | line->line_port = msg->line_port; | 1276 | line->line_port = msg->line_port; |
1274 | line->port = GNUNET_CADET_open_port(cadet, | 1277 | line->port = GNUNET_CADET_open_port (cadet, |
1275 | &msg->line_port, | 1278 | &msg->line_port, |
1276 | &inbound_channel, | 1279 | &inbound_channel, |
1277 | line, | 1280 | line, |
1278 | NULL, | 1281 | NULL, |
1279 | &inbound_end, | 1282 | &inbound_end, |
1280 | cadet_handlers); | 1283 | cadet_handlers); |
1281 | if (NULL == line->port) | 1284 | if (NULL == line->port) |
1282 | { | 1285 | { |
1283 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | 1286 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1284 | _("Could not open line, port %s already in use!\n"), | 1287 | _ ("Could not open line, port %s already in use!\n"), |
1285 | GNUNET_h2s(&msg->line_port)); | 1288 | GNUNET_h2s (&msg->line_port)); |
1286 | GNUNET_SERVICE_client_drop(line->client); | 1289 | GNUNET_SERVICE_client_drop (line->client); |
1287 | return; | 1290 | return; |
1288 | } | 1291 | } |
1289 | GNUNET_SERVICE_client_continue(line->client); | 1292 | GNUNET_SERVICE_client_continue (line->client); |
1290 | } | 1293 | } |
1291 | 1294 | ||
1292 | 1295 | ||
@@ -1296,14 +1299,14 @@ handle_client_register_message(void *cls, | |||
1296 | * @param cls closure, NULL | 1299 | * @param cls closure, NULL |
1297 | */ | 1300 | */ |
1298 | static void | 1301 | static void |
1299 | do_shutdown(void *cls) | 1302 | do_shutdown (void *cls) |
1300 | { | 1303 | { |
1301 | (void)cls; | 1304 | (void) cls; |
1302 | if (NULL != cadet) | 1305 | if (NULL != cadet) |
1303 | { | 1306 | { |
1304 | GNUNET_CADET_disconnect(cadet); | 1307 | GNUNET_CADET_disconnect (cadet); |
1305 | cadet = NULL; | 1308 | cadet = NULL; |
1306 | } | 1309 | } |
1307 | } | 1310 | } |
1308 | 1311 | ||
1309 | 1312 | ||
@@ -1315,65 +1318,65 @@ do_shutdown(void *cls) | |||
1315 | * @param service service handle | 1318 | * @param service service handle |
1316 | */ | 1319 | */ |
1317 | static void | 1320 | static void |
1318 | run(void *cls, | 1321 | run (void *cls, |
1319 | const struct GNUNET_CONFIGURATION_Handle *c, | 1322 | const struct GNUNET_CONFIGURATION_Handle *c, |
1320 | struct GNUNET_SERVICE_Handle *service) | 1323 | struct GNUNET_SERVICE_Handle *service) |
1321 | { | 1324 | { |
1322 | (void)cls; | 1325 | (void) cls; |
1323 | (void)service; | 1326 | (void) service; |
1324 | cfg = c; | 1327 | cfg = c; |
1325 | GNUNET_assert(GNUNET_OK == | 1328 | GNUNET_assert (GNUNET_OK == |
1326 | GNUNET_CRYPTO_get_peer_identity(cfg, &my_identity)); | 1329 | GNUNET_CRYPTO_get_peer_identity (cfg, &my_identity)); |
1327 | cadet = GNUNET_CADET_connect(cfg); | 1330 | cadet = GNUNET_CADET_connect (cfg); |
1328 | if (NULL == cadet) | 1331 | if (NULL == cadet) |
1329 | { | 1332 | { |
1330 | GNUNET_break(0); | 1333 | GNUNET_break (0); |
1331 | GNUNET_SCHEDULER_shutdown(); | 1334 | GNUNET_SCHEDULER_shutdown (); |
1332 | return; | 1335 | return; |
1333 | } | 1336 | } |
1334 | GNUNET_SCHEDULER_add_shutdown(&do_shutdown, NULL); | 1337 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); |
1335 | } | 1338 | } |
1336 | 1339 | ||
1337 | 1340 | ||
1338 | /** | 1341 | /** |
1339 | * Define "main" method using service macro. | 1342 | * Define "main" method using service macro. |
1340 | */ | 1343 | */ |
1341 | GNUNET_SERVICE_MAIN( | 1344 | GNUNET_SERVICE_MAIN ( |
1342 | "conversation", | 1345 | "conversation", |
1343 | GNUNET_SERVICE_OPTION_NONE, | 1346 | GNUNET_SERVICE_OPTION_NONE, |
1344 | &run, | 1347 | &run, |
1345 | &client_connect_cb, | 1348 | &client_connect_cb, |
1346 | &client_disconnect_cb, | 1349 | &client_disconnect_cb, |
1347 | NULL, | 1350 | NULL, |
1348 | GNUNET_MQ_hd_fixed_size(client_register_message, | 1351 | GNUNET_MQ_hd_fixed_size (client_register_message, |
1349 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_REGISTER, | 1352 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_REGISTER, |
1350 | struct ClientPhoneRegisterMessage, | 1353 | struct ClientPhoneRegisterMessage, |
1351 | NULL), | 1354 | NULL), |
1352 | GNUNET_MQ_hd_fixed_size(client_pickup_message, | 1355 | GNUNET_MQ_hd_fixed_size (client_pickup_message, |
1353 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICK_UP, | 1356 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICK_UP, |
1354 | struct ClientPhonePickupMessage, | 1357 | struct ClientPhonePickupMessage, |
1355 | NULL), | 1358 | NULL), |
1356 | GNUNET_MQ_hd_fixed_size(client_suspend_message, | 1359 | GNUNET_MQ_hd_fixed_size (client_suspend_message, |
1357 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND, | 1360 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND, |
1358 | struct ClientPhoneSuspendMessage, | 1361 | struct ClientPhoneSuspendMessage, |
1359 | NULL), | 1362 | NULL), |
1360 | GNUNET_MQ_hd_fixed_size(client_resume_message, | 1363 | GNUNET_MQ_hd_fixed_size (client_resume_message, |
1361 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME, | 1364 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME, |
1362 | struct ClientPhoneResumeMessage, | 1365 | struct ClientPhoneResumeMessage, |
1363 | NULL), | 1366 | NULL), |
1364 | GNUNET_MQ_hd_fixed_size(client_hangup_message, | 1367 | GNUNET_MQ_hd_fixed_size (client_hangup_message, |
1365 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP, | 1368 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP, |
1366 | struct ClientPhoneHangupMessage, | 1369 | struct ClientPhoneHangupMessage, |
1367 | NULL), | 1370 | NULL), |
1368 | GNUNET_MQ_hd_fixed_size(client_call_message, | 1371 | GNUNET_MQ_hd_fixed_size (client_call_message, |
1369 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_CALL, | 1372 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_CALL, |
1370 | struct ClientCallMessage, | 1373 | struct ClientCallMessage, |
1371 | NULL), | 1374 | NULL), |
1372 | GNUNET_MQ_hd_var_size(client_audio_message, | 1375 | GNUNET_MQ_hd_var_size (client_audio_message, |
1373 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO, | 1376 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO, |
1374 | struct ClientAudioMessage, | 1377 | struct ClientAudioMessage, |
1375 | NULL), | 1378 | NULL), |
1376 | GNUNET_MQ_handler_end()); | 1379 | GNUNET_MQ_handler_end ()); |
1377 | 1380 | ||
1378 | 1381 | ||
1379 | /* end of gnunet-service-conversation.c */ | 1382 | /* end of gnunet-service-conversation.c */ |