GNUnet  0.11.x
Data Structures | Macros | Enumerations | Functions | Variables
gnunet-service-conversation.c File Reference

conversation service implementation More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_protocols.h"
#include "gnunet_applications.h"
#include "gnunet_constants.h"
#include "gnunet_signatures.h"
#include "gnunet_cadet_service.h"
#include "gnunet_conversation_service.h"
#include "conversation.h"
Include dependency graph for gnunet-service-conversation.c:

Go to the source code of this file.

Data Structures

struct  Channel
 A struct Channel represents a cadet channel, which is a P2P connection to another conversation service. More...
 
struct  Line
 A struct Line connects a local client with cadet channels. More...
 

Macros

#define RING_TIMEOUT   GNUNET_TIME_UNIT_DAYS
 How long is our signature on a call valid? Needs to be long enough for time zone differences and network latency to not matter. More...
 

Enumerations

enum  ChannelStatus {
  CS_CALLEE_INIT , CS_CALLEE_RINGING , CS_CALLEE_CONNECTED , CS_CALLEE_SHUTDOWN ,
  CS_CALLER_CALLING , CS_CALLER_CONNECTED , CS_CALLER_SHUTDOWN
}
 The possible connection status. More...
 

Functions

static struct Channelfind_channel_by_line (struct Line *line, uint32_t cid)
 Given a cid, find the corresponding channel given a line. More...
 
static void handle_client_pickup_message (void *cls, const struct ClientPhonePickupMessage *msg)
 Function to handle a pickup request message from the client. More...
 
static void clean_up_channel (struct Channel *ch)
 Channel went down, notify client and free data structure. More...
 
static void destroy_line_cadet_channels (struct Channel *ch)
 Destroy a channel. More...
 
static void mq_done_finish_caller_shutdown (void *cls)
 We are done signalling shutdown to the other peer. More...
 
static void handle_client_hangup_message (void *cls, const struct ClientPhoneHangupMessage *msg)
 Function to handle a hangup request message from the client. More...
 
static void handle_client_suspend_message (void *cls, const struct ClientPhoneSuspendMessage *msg)
 Function to handle a suspend request message from the client. More...
 
static void handle_client_resume_message (void *cls, const struct ClientPhoneResumeMessage *msg)
 Function to handle a resume request message from the client. More...
 
static void channel_audio_sent_notify (void *cls)
 Transmission of audio data via cadet channel finished. More...
 
static int check_client_audio_message (void *cls, const struct ClientAudioMessage *msg)
 Function to check audio data from the client. More...
 
static void handle_client_audio_message (void *cls, const struct ClientAudioMessage *msg)
 Function to handle audio data from the client. More...
 
static void handle_cadet_ring_message (void *cls, const struct CadetPhoneRingMessage *msg)
 Function to handle a ring message incoming over cadet. More...
 
static void handle_cadet_hangup_message (void *cls, const struct CadetPhoneHangupMessage *message)
 Function to handle a hangup message incoming over cadet. More...
 
static void handle_cadet_pickup_message (void *cls, const struct CadetPhonePickupMessage *message)
 Function to handle a pickup message incoming over cadet. More...
 
static void handle_cadet_suspend_message (void *cls, const struct CadetPhoneSuspendMessage *message)
 Function to handle a suspend message incoming over cadet. More...
 
static void handle_cadet_resume_message (void *cls, const struct CadetPhoneResumeMessage *msg)
 Function to handle a resume message incoming over cadet. More...
 
static int check_cadet_audio_message (void *cls, const struct CadetAudioMessage *msg)
 Function to check an audio message incoming over cadet. More...
 
static void handle_cadet_audio_message (void *cls, const struct CadetAudioMessage *msg)
 Function to handle an audio message incoming over cadet. More...
 
static void inbound_end (void *cls, const struct GNUNET_CADET_Channel *channel)
 Function called whenever an inbound channel is destroyed. More...
 
static void handle_client_call_message (void *cls, const struct ClientCallMessage *msg)
 Function to handle call request from the client. More...
 
static void * inbound_channel (void *cls, struct GNUNET_CADET_Channel *channel, const struct GNUNET_PeerIdentity *initiator)
 Method called whenever another peer has added us to a channel the other peer initiated. More...
 
static void * client_connect_cb (void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
 A client connected. More...
 
static void client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *client, void *app_ctx)
 A client disconnected. More...
 
static void handle_client_register_message (void *cls, const struct ClientPhoneRegisterMessage *msg)
 Function to register a phone. More...
 
static void do_shutdown (void *cls)
 Shutdown nicely. More...
 
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *service)
 Main function that will be run by the scheduler. More...
 
 GNUNET_SERVICE_MAIN ("conversation", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_fixed_size(client_register_message, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_REGISTER, struct ClientPhoneRegisterMessage, NULL), GNUNET_MQ_hd_fixed_size(client_pickup_message, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICK_UP, struct ClientPhonePickupMessage, NULL), GNUNET_MQ_hd_fixed_size(client_suspend_message, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND, struct ClientPhoneSuspendMessage, NULL), GNUNET_MQ_hd_fixed_size(client_resume_message, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME, struct ClientPhoneResumeMessage, NULL), GNUNET_MQ_hd_fixed_size(client_hangup_message, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP, struct ClientPhoneHangupMessage, NULL), GNUNET_MQ_hd_fixed_size(client_call_message, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_CALL, struct ClientCallMessage, NULL), GNUNET_MQ_hd_var_size(client_audio_message, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO, struct ClientAudioMessage, NULL), GNUNET_MQ_handler_end())
 Define "main" method using service macro. More...
 

Variables

static const struct GNUNET_CONFIGURATION_Handlecfg
 Our configuration. More...
 
static struct GNUNET_CADET_Handlecadet
 Handle for cadet. More...
 
static struct GNUNET_PeerIdentity my_identity
 Identity of this peer. More...
 

Detailed Description

conversation service implementation

Author
Simon Dieterle
Andreas Fuchs
Christian Grothoff

Definition in file gnunet-service-conversation.c.

Macro Definition Documentation

◆ RING_TIMEOUT

#define RING_TIMEOUT   GNUNET_TIME_UNIT_DAYS

How long is our signature on a call valid? Needs to be long enough for time zone differences and network latency to not matter.

No strong need for it to be short, but we simply like all signatures to eventually expire.

Definition at line 43 of file gnunet-service-conversation.c.

Enumeration Type Documentation

◆ ChannelStatus

The possible connection status.

Enumerator
CS_CALLEE_INIT 

We just got the connection, but no introduction yet.

CS_CALLEE_RINGING 

Our phone is ringing, waiting for the client to pick up.

CS_CALLEE_CONNECTED 

We are talking!

CS_CALLEE_SHUTDOWN 

We're in shutdown, sending hangup messages before cleaning up.

CS_CALLER_CALLING 

We are waiting for the phone to be picked up.

CS_CALLER_CONNECTED 

We are talking!

CS_CALLER_SHUTDOWN 

We're in shutdown, sending hangup messages before cleaning up.

Definition at line 55 of file gnunet-service-conversation.c.

56 {
61 
66 
71 
76 
81 
86 
91 };
@ CS_CALLEE_RINGING
Our phone is ringing, waiting for the client to pick up.
@ CS_CALLEE_SHUTDOWN
We're in shutdown, sending hangup messages before cleaning up.
@ CS_CALLEE_INIT
We just got the connection, but no introduction yet.
@ CS_CALLER_CONNECTED
We are talking!
@ CS_CALLEE_CONNECTED
We are talking!
@ CS_CALLER_SHUTDOWN
We're in shutdown, sending hangup messages before cleaning up.
@ CS_CALLER_CALLING
We are waiting for the phone to be picked up.

Function Documentation

◆ find_channel_by_line()

static struct Channel* find_channel_by_line ( struct Line line,
uint32_t  cid 
)
static

Given a cid, find the corresponding channel given a line.

Parameters
linea line to search
cidwhat to search for
Returns
NULL for not found

Definition at line 222 of file gnunet-service-conversation.c.

223 {
224  for (struct Channel *ch = line->channel_head; NULL != ch; ch = ch->next)
225  if (cid == ch->cid)
226  return ch;
227  return NULL;
228 }
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
static char * line
Desired phone line (string to be converted to a hash).
A struct Channel represents a cadet channel, which is a P2P connection to another conversation servic...

References ch, Channel::cid, and line.

Referenced by handle_client_audio_message().

Here is the caller graph for this function:

◆ handle_client_pickup_message()

static void handle_client_pickup_message ( void *  cls,
const struct ClientPhonePickupMessage msg 
)
static

Function to handle a pickup request message from the client.

Parameters
clsthe struct Line of the client from which the message is
msgthe message from the client

Definition at line 238 of file gnunet-service-conversation.c.

240 {
241  struct Line *line = cls;
242  struct CadetPhonePickupMessage *mppm;
243  struct GNUNET_MQ_Envelope *env;
244  struct Channel *ch;
245 
246  if (NULL == line->port)
247  {
248  /* we never opened the port, bad client! */
249  GNUNET_break_op (0);
251  return;
252  }
253  for (ch = line->channel_head; NULL != ch; ch = ch->next)
254  if (msg->cid == ch->cid)
255  break;
256  if (NULL == ch)
257  {
258  /* could have been destroyed asynchronously, ignore message */
259  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Channel %u not found\n", msg->cid);
261  return;
262  }
263  switch (ch->status)
264  {
265  case CS_CALLEE_INIT:
266  GNUNET_break (0);
268  return;
269 
270  case CS_CALLEE_RINGING:
271  ch->status = CS_CALLEE_CONNECTED;
272  break;
273 
274  case CS_CALLEE_CONNECTED:
275  GNUNET_break (0);
277  return;
278 
279  case CS_CALLEE_SHUTDOWN:
281  "Ignoring client's PICKUP message, line is in SHUTDOWN\n");
282  break;
283 
284  case CS_CALLER_CALLING:
285  case CS_CALLER_CONNECTED:
286  case CS_CALLER_SHUTDOWN:
287  GNUNET_break (0);
289  return;
290  }
291  GNUNET_break (CS_CALLEE_CONNECTED == ch->status);
292  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending PICK_UP message to cadet\n");
293  env =
295  GNUNET_MQ_send (ch->mq, env);
297 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_log(kind,...)
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_DEBUG
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:355
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_PICK_UP
Cadet: pick up phone (establish audio channel)
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2325
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2244
Cadet message for picking up.
Definition: conversation.h:336
struct GNUNET_MQ_Handle * mq
Message Queue for the channel (which we are implementing).
Definition: cadet.h:143
A struct Line connects a local client with cadet channels.

References ch, CS_CALLEE_CONNECTED, CS_CALLEE_INIT, CS_CALLEE_RINGING, CS_CALLEE_SHUTDOWN, CS_CALLER_CALLING, CS_CALLER_CONNECTED, CS_CALLER_SHUTDOWN, env, GNUNET_break, GNUNET_break_op, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_PICK_UP, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), line, GNUNET_CADET_Channel::mq, and msg.

Here is the call graph for this function:

◆ clean_up_channel()

static void clean_up_channel ( struct Channel ch)
static

Channel went down, notify client and free data structure.

Parameters
chchannel that went down

Definition at line 307 of file gnunet-service-conversation.c.

308 {
309  struct Line *line = ch->line;
310  struct GNUNET_MQ_Envelope *env;
311  struct ClientPhoneHangupMessage *hup;
312 
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)
325  {
326  env =
328  hup->cid = ch->cid;
329  GNUNET_MQ_send (line->mq, env);
330  }
331  break;
332  }
333  if (NULL != line)
334  GNUNET_CONTAINER_DLL_remove (line->channel_head, line->channel_tail, ch);
335  GNUNET_free (ch);
336 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP
Client -> Server message to reject/hangup a call.
Client <-> Service hang up phone that may or may not be ringing.
Definition: conversation.h:173
uint32_t cid
CID, internal caller ID to identify which active call we are talking about.
Definition: conversation.h:183

References ch, ClientPhoneHangupMessage::cid, CS_CALLEE_CONNECTED, CS_CALLEE_INIT, CS_CALLEE_RINGING, CS_CALLEE_SHUTDOWN, CS_CALLER_CALLING, CS_CALLER_CONNECTED, CS_CALLER_SHUTDOWN, env, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP, GNUNET_MQ_msg, GNUNET_MQ_send(), and line.

Referenced by destroy_line_cadet_channels(), and inbound_end().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ destroy_line_cadet_channels()

static void destroy_line_cadet_channels ( struct Channel ch)
static

Destroy a channel.

Parameters
chchannel to destroy.

Definition at line 345 of file gnunet-service-conversation.c.

346 {
347  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Destroying cadet channels\n");
348  if (NULL != ch->channel)
349  {
350  GNUNET_CADET_channel_destroy (ch->channel);
351  ch->channel = NULL;
352  }
354 }
static void clean_up_channel(struct Channel *ch)
Channel went down, notify client and free data structure.
void GNUNET_CADET_channel_destroy(struct GNUNET_CADET_Channel *channel)
Destroy an existing channel.
Definition: cadet_api.c:837

References ch, clean_up_channel(), GNUNET_CADET_channel_destroy(), GNUNET_ERROR_TYPE_DEBUG, and GNUNET_log.

Referenced by client_disconnect_cb(), handle_cadet_hangup_message(), handle_cadet_pickup_message(), handle_cadet_resume_message(), handle_cadet_ring_message(), and mq_done_finish_caller_shutdown().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mq_done_finish_caller_shutdown()

static void mq_done_finish_caller_shutdown ( void *  cls)
static

We are done signalling shutdown to the other peer.

Close down the channel.

Parameters
clsthe struct Channel to reset/terminate

Definition at line 364 of file gnunet-service-conversation.c.

365 {
366  struct Channel *ch = cls;
367 
368  switch (ch->status)
369  {
370  case CS_CALLEE_INIT:
371  GNUNET_break (0);
372  break;
373 
374  case CS_CALLEE_RINGING:
375  GNUNET_break (0);
376  break;
377 
378  case CS_CALLEE_CONNECTED:
379  GNUNET_break (0);
380  break;
381 
382  case CS_CALLEE_SHUTDOWN:
384  break;
385 
386  case CS_CALLER_CALLING:
387  GNUNET_break (0);
388  break;
389 
390  case CS_CALLER_CONNECTED:
391  GNUNET_break (0);
392  break;
393 
394  case CS_CALLER_SHUTDOWN:
396  break;
397  }
398 }
static void destroy_line_cadet_channels(struct Channel *ch)
Destroy a channel.

References ch, CS_CALLEE_CONNECTED, CS_CALLEE_INIT, CS_CALLEE_RINGING, CS_CALLEE_SHUTDOWN, CS_CALLER_CALLING, CS_CALLER_CONNECTED, CS_CALLER_SHUTDOWN, destroy_line_cadet_channels(), and GNUNET_break.

Referenced by handle_cadet_pickup_message(), and handle_client_hangup_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_client_hangup_message()

static void handle_client_hangup_message ( void *  cls,
const struct ClientPhoneHangupMessage msg 
)
static

Function to handle a hangup request message from the client.

Parameters
clsthe struct Line the hangup is for
msgthe message from the client

Definition at line 408 of file gnunet-service-conversation.c.

410 {
411  struct Line *line = cls;
412  struct GNUNET_MQ_Envelope *e;
413  struct CadetPhoneHangupMessage *mhum;
414  struct Channel *ch;
415 
416  for (ch = line->channel_head; NULL != ch; ch = ch->next)
417  if (msg->cid == ch->cid)
418  break;
419  if (NULL == ch)
420  {
421  /* could have been destroyed asynchronously, ignore message */
422  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Channel %u not found\n", msg->cid);
424  return;
425  }
427  "Received HANGUP for channel %u which is in state %d\n",
428  msg->cid,
429  ch->status);
430  switch (ch->status)
431  {
432  case CS_CALLEE_INIT:
433  GNUNET_break (0);
435  return;
436 
437  case CS_CALLEE_RINGING:
438  ch->status = CS_CALLEE_SHUTDOWN;
439  break;
440 
441  case CS_CALLEE_CONNECTED:
442  ch->status = CS_CALLEE_SHUTDOWN;
443  break;
444 
445  case CS_CALLEE_SHUTDOWN:
446  /* maybe the other peer closed asynchronously... */
448  return;
449 
450  case CS_CALLER_CALLING:
451  ch->status = CS_CALLER_SHUTDOWN;
452  break;
453 
454  case CS_CALLER_CONNECTED:
455  ch->status = CS_CALLER_SHUTDOWN;
456  break;
457 
458  case CS_CALLER_SHUTDOWN:
459  /* maybe the other peer closed asynchronously... */
461  return;
462  }
463  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending HANG_UP message via cadet\n");
464  e =
467  GNUNET_MQ_send (ch->mq, e);
469 }
static struct Experiment * e
static void mq_done_finish_caller_shutdown(void *cls)
We are done signalling shutdown to the other peer.
void GNUNET_MQ_notify_sent(struct GNUNET_MQ_Envelope *ev, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
Call a callback once the envelope has been sent, that is, sending it can not be canceled anymore.
Definition: mq.c:787
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_HANG_UP
Cadet: hang up / refuse call.
Cadet message for hanging up.
Definition: conversation.h:324

References ch, CS_CALLEE_CONNECTED, CS_CALLEE_INIT, CS_CALLEE_RINGING, CS_CALLEE_SHUTDOWN, CS_CALLER_CALLING, CS_CALLER_CONNECTED, CS_CALLER_SHUTDOWN, e, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_HANG_UP, GNUNET_MQ_msg, GNUNET_MQ_notify_sent(), GNUNET_MQ_send(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), line, GNUNET_CADET_Channel::mq, mq_done_finish_caller_shutdown(), and msg.

Here is the call graph for this function:

◆ handle_client_suspend_message()

static void handle_client_suspend_message ( void *  cls,
const struct ClientPhoneSuspendMessage msg 
)
static

Function to handle a suspend request message from the client.

Parameters
clsthe struct Line the message is about
msgthe message from the client

Definition at line 479 of file gnunet-service-conversation.c.

481 {
482  struct Line *line = cls;
483  struct GNUNET_MQ_Envelope *e;
484  struct CadetPhoneSuspendMessage *mhum;
485  struct Channel *ch;
486 
487  for (ch = line->channel_head; NULL != ch; ch = ch->next)
488  if (msg->cid == ch->cid)
489  break;
490  if (NULL == ch)
491  {
492  /* could have been destroyed asynchronously, ignore message */
493  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Channel %u not found\n", msg->cid);
495  return;
496  }
497  if (GNUNET_YES == ch->suspended_local)
498  {
499  GNUNET_break (0);
501  return;
502  }
504  "Received SUSPEND for channel %u which is in state %d\n",
505  msg->cid,
506  ch->status);
507  switch (ch->status)
508  {
509  case CS_CALLEE_INIT:
510  GNUNET_break (0);
512  return;
513 
514  case CS_CALLEE_RINGING:
515  GNUNET_break (0);
517  return;
518 
519  case CS_CALLEE_CONNECTED:
520  ch->suspended_local = GNUNET_YES;
521  break;
522 
523  case CS_CALLEE_SHUTDOWN:
524  /* maybe the other peer closed asynchronously... */
526  return;
527 
528  case CS_CALLER_CALLING:
529  GNUNET_break (0);
531  return;
532 
533  case CS_CALLER_CONNECTED:
534  ch->suspended_local = GNUNET_YES;
535  break;
536 
537  case CS_CALLER_SHUTDOWN:
538  /* maybe the other peer closed asynchronously... */
540  return;
541  }
542  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUSPEND message via cadet\n");
543  e =
545  GNUNET_MQ_send (ch->mq, e);
547 }
@ GNUNET_YES
Definition: gnunet_common.h:97
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_SUSPEND
Cadet: phone suspended.
Cadet message for phone suspended.
Definition: conversation.h:348

References ch, CS_CALLEE_CONNECTED, CS_CALLEE_INIT, CS_CALLEE_RINGING, CS_CALLEE_SHUTDOWN, CS_CALLER_CALLING, CS_CALLER_CONNECTED, CS_CALLER_SHUTDOWN, e, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_SUSPEND, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_YES, line, GNUNET_CADET_Channel::mq, and msg.

Here is the call graph for this function:

◆ handle_client_resume_message()

static void handle_client_resume_message ( void *  cls,
const struct ClientPhoneResumeMessage msg 
)
static

Function to handle a resume request message from the client.

Parameters
clsthe struct Line the message is about
msgthe message from the client

Definition at line 557 of file gnunet-service-conversation.c.

559 {
560  struct Line *line = cls;
561  struct GNUNET_MQ_Envelope *e;
562  struct CadetPhoneResumeMessage *mhum;
563  struct Channel *ch;
564 
565  for (ch = line->channel_head; NULL != ch; ch = ch->next)
566  if (msg->cid == ch->cid)
567  break;
568  if (NULL == ch)
569  {
570  /* could have been destroyed asynchronously, ignore message */
571  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Channel %u not found\n", msg->cid);
573  return;
574  }
575  if (GNUNET_YES != ch->suspended_local)
576  {
577  GNUNET_break (0);
579  return;
580  }
582  "Received RESUME for channel %u which is in state %d\n",
583  msg->cid,
584  ch->status);
585  switch (ch->status)
586  {
587  case CS_CALLEE_INIT:
588  GNUNET_break (0);
590  return;
591 
592  case CS_CALLEE_RINGING:
593  GNUNET_break (0);
595  return;
596 
597  case CS_CALLEE_CONNECTED:
598  ch->suspended_local = GNUNET_NO;
599  break;
600 
601  case CS_CALLEE_SHUTDOWN:
602  /* maybe the other peer closed asynchronously... */
604  return;
605 
606  case CS_CALLER_CALLING:
607  GNUNET_break (0);
609  return;
610 
611  case CS_CALLER_CONNECTED:
612  ch->suspended_local = GNUNET_NO;
613  break;
614 
615  case CS_CALLER_SHUTDOWN:
616  /* maybe the other peer closed asynchronously... */
618  return;
619  }
620  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending RESUME message via cadet\n");
622  GNUNET_MQ_send (ch->mq, e);
624 }
@ GNUNET_NO
Definition: gnunet_common.h:94
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_RESUME
Cadet: phone resumed.
Cadet message for phone resumed.
Definition: conversation.h:360

References ch, CS_CALLEE_CONNECTED, CS_CALLEE_INIT, CS_CALLEE_RINGING, CS_CALLEE_SHUTDOWN, CS_CALLER_CALLING, CS_CALLER_CONNECTED, CS_CALLER_SHUTDOWN, e, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_RESUME, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_NO, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_YES, line, GNUNET_CADET_Channel::mq, and msg.

Here is the call graph for this function:

◆ channel_audio_sent_notify()

static void channel_audio_sent_notify ( void *  cls)
static

Transmission of audio data via cadet channel finished.

Parameters
clsthe struct Channel we are transmitting for

Definition at line 633 of file gnunet-service-conversation.c.

634 {
635  struct Channel *ch = cls;
636 
637  ch->env = NULL;
638 }

References ch.

Referenced by handle_client_audio_message().

Here is the caller graph for this function:

◆ check_client_audio_message()

static int check_client_audio_message ( void *  cls,
const struct ClientAudioMessage msg 
)
static

Function to check audio data from the client.

Parameters
clsthe struct Line the message is about
msgthe message from the client
Returns
GNUNET_OK (any data is ok)

Definition at line 649 of file gnunet-service-conversation.c.

650 {
651  (void) cls;
652  (void) msg;
653  return GNUNET_OK;
654 }
@ GNUNET_OK
Definition: gnunet_common.h:95

References GNUNET_OK, and msg.

◆ handle_client_audio_message()

static void handle_client_audio_message ( void *  cls,
const struct ClientAudioMessage msg 
)
static

Function to handle audio data from the client.

Parameters
clsthe struct Line the message is about
msgthe message from the client

Definition at line 664 of file gnunet-service-conversation.c.

665 {
666  struct Line *line = cls;
667  struct CadetAudioMessage *mam;
668  struct Channel *ch;
669  size_t size;
670 
671  size = ntohs (msg->header.size) - sizeof(struct ClientAudioMessage);
672  ch = find_channel_by_line (line, msg->cid);
673  if (NULL == ch)
674  {
675  /* could have been destroyed asynchronously, ignore message */
676  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Channel %u not found\n", msg->cid);
678  return;
679  }
680 
681  switch (ch->status)
682  {
683  case CS_CALLEE_INIT:
684  case CS_CALLEE_RINGING:
685  case CS_CALLER_CALLING:
686  GNUNET_break (0);
688  return;
689 
690  case CS_CALLEE_CONNECTED:
691  case CS_CALLER_CONNECTED:
692  /* common case, handled below */
693  break;
694 
695  case CS_CALLEE_SHUTDOWN:
696  case CS_CALLER_SHUTDOWN:
698  "Cadet audio channel in shutdown; audio data dropped\n");
700  return;
701  }
702  if (GNUNET_YES == ch->suspended_local)
703  {
705  "This channel is suspended locally\n");
707  return;
708  }
709  if (NULL != ch->env)
710  {
711  /* NOTE: we may want to not do this and instead combine the data */
713  "Bandwidth insufficient; dropping previous audio data segment\n");
714  GNUNET_MQ_send_cancel (ch->env);
715  ch->env = NULL;
716  }
717 
719  "Received %u bytes of AUDIO data from client CID %u\n",
720  (unsigned int) size,
721  msg->cid);
722  ch->env = GNUNET_MQ_msg_extra (mam,
723  size,
725  GNUNET_memcpy (&mam[1], &msg[1], size);
726  /* FIXME: set options for unreliable transmission */
728  GNUNET_MQ_send (ch->mq, ch->env);
730 }
static struct Channel * find_channel_by_line(struct Line *line, uint32_t cid)
Given a cid, find the corresponding channel given a line.
static void channel_audio_sent_notify(void *cls)
Transmission of audio data via cadet channel finished.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_BULK
void GNUNET_MQ_send_cancel(struct GNUNET_MQ_Envelope *ev)
Cancel sending the message.
Definition: mq.c:929
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
Definition: gnunet_mq_lib.h:52
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_AUDIO
Cadet: audio data.
static unsigned int size
Size of the "table".
Definition: peer.c:67
Cadet message to transmit the audio.
Definition: conversation.h:372
Message Client <-> Service to transmit the audio.
Definition: conversation.h:191
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.

References ch, channel_audio_sent_notify(), CS_CALLEE_CONNECTED, CS_CALLEE_INIT, CS_CALLEE_RINGING, CS_CALLEE_SHUTDOWN, CS_CALLER_CALLING, CS_CALLER_CONNECTED, CS_CALLER_SHUTDOWN, find_channel_by_line(), GNUNET_break, GNUNET_ERROR_TYPE_BULK, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_AUDIO, GNUNET_MQ_msg_extra, GNUNET_MQ_notify_sent(), GNUNET_MQ_send(), GNUNET_MQ_send_cancel(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_YES, line, GNUNET_CADET_Channel::mq, msg, GNUNET_MessageHeader::size, and size.

Here is the call graph for this function:

◆ handle_cadet_ring_message()

static void handle_cadet_ring_message ( void *  cls,
const struct CadetPhoneRingMessage msg 
)
static

Function to handle a ring message incoming over cadet.

Parameters
clsclosure, NULL
msgthe incoming message

Definition at line 740 of file gnunet-service-conversation.c.

741 {
742  struct Channel *ch = cls;
743  struct Line *line = ch->line;
744  struct GNUNET_MQ_Envelope *env;
745  struct ClientPhoneRingMessage *cring;
746  struct CadetPhoneRingInfoPS rs;
747 
749  rs.purpose.size = htonl (sizeof(struct CadetPhoneRingInfoPS));
750  rs.line_port = line->line_port;
751  rs.target_peer = my_identity;
752  rs.expiration_time = msg->expiration_time;
753 
754  if (GNUNET_OK !=
757  &rs,
758  &msg->signature,
759  &msg->caller_id))
760  {
761  GNUNET_break_op (0);
763  return;
764  }
766  GNUNET_TIME_absolute_ntoh (msg->expiration_time))
767  .rel_value_us)
768  {
769  /* ancient call, replay? */
770  GNUNET_break_op (0);
771  /* Note that our reliance on time here is awkward; better would be
772  to use a more complex challenge-response protocol against
773  replay attacks. Left for future work ;-). */
775  return;
776  }
777  if (CS_CALLEE_INIT != ch->status)
778  {
779  GNUNET_break_op (0);
781  return;
782  }
783  GNUNET_CADET_receive_done (ch->channel);
784  ch->status = CS_CALLEE_RINGING;
786  cring->cid = ch->cid;
787  cring->caller_id = msg->caller_id;
789  "Sending RING message to client. CID is %u\n",
790  (unsigned int) ch->cid);
791  GNUNET_MQ_send (line->mq, env);
792 }
static struct GNUNET_PeerIdentity my_identity
Identity of this peer.
void GNUNET_CADET_receive_done(struct GNUNET_CADET_Channel *channel)
Send an ack on the channel to confirm the processing of a message.
Definition: cadet_api.c:888
#define GNUNET_IDENTITY_signature_verify(purp, ps, sig, pub)
Verify a given signature with GNUNET_IDENTITY_PublicKey.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RING
Client <- Server message to indicate a ringing phone.
#define GNUNET_SIGNATURE_PURPOSE_CONVERSATION_RING
Signature of a conversation ring.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining(struct GNUNET_TIME_Absolute future)
Given a timestamp in the future, how much time remains until then?
Definition: time.c:232
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:542
Information signed in a struct CadetPhoneRingMessage whereby the caller self-identifies to the receiv...
Definition: conversation.h:263
struct GNUNET_CRYPTO_EccSignaturePurpose purpose
Purpose for the signature, must be GNUNET_SIGNATURE_PURPOSE_CONVERSATION_RING.
Definition: conversation.h:268
Service -> Client message for phone is ringing.
Definition: conversation.h:95
struct GNUNET_IDENTITY_PublicKey caller_id
Who is calling us?
Definition: conversation.h:110
uint32_t cid
CID, internal caller ID number used in the future to identify which active call we are talking about.
Definition: conversation.h:105
uint32_t purpose
What does this signature vouch for? This must contain a GNUNET_SIGNATURE_PURPOSE_XXX constant (from g...
uint64_t rel_value_us
The actual value.

References ClientPhoneRingMessage::caller_id, ch, ClientPhoneRingMessage::cid, CS_CALLEE_INIT, CS_CALLEE_RINGING, destroy_line_cadet_channels(), env, CadetPhoneRingInfoPS::expiration_time, GNUNET_break_op, GNUNET_CADET_receive_done(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_IDENTITY_signature_verify, GNUNET_log, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RING, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_OK, GNUNET_SIGNATURE_PURPOSE_CONVERSATION_RING, GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_absolute_ntoh(), line, CadetPhoneRingInfoPS::line_port, msg, my_identity, CadetPhoneRingInfoPS::purpose, GNUNET_CRYPTO_EccSignaturePurpose::purpose, GNUNET_TIME_Relative::rel_value_us, GNUNET_CRYPTO_EccSignaturePurpose::size, and CadetPhoneRingInfoPS::target_peer.

Here is the call graph for this function:

◆ handle_cadet_hangup_message()

static void handle_cadet_hangup_message ( void *  cls,
const struct CadetPhoneHangupMessage message 
)
static

Function to handle a hangup message incoming over cadet.

Parameters
clsclosure, our struct Channel *
messagethe incoming message

Definition at line 802 of file gnunet-service-conversation.c.

804 {
805  struct Channel *ch = cls;
806  struct Line *line = ch->line;
807  struct GNUNET_MQ_Envelope *env;
808  struct ClientPhoneHangupMessage *hup;
809  enum ChannelStatus status;
810  uint32_t cid;
811 
812  (void) message;
813  GNUNET_CADET_receive_done (ch->channel);
814  cid = ch->cid;
815  status = ch->status;
817  switch (status)
818  {
819  case CS_CALLEE_INIT:
820  GNUNET_break_op (0);
821  return;
822 
823  case CS_CALLEE_RINGING:
824  case CS_CALLEE_CONNECTED:
825  break;
826 
827  case CS_CALLEE_SHUTDOWN:
828  return;
829 
830  case CS_CALLER_CALLING:
831  case CS_CALLER_CONNECTED:
832  break;
833 
834  case CS_CALLER_SHUTDOWN:
835  return;
836  }
837  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending HANG UP message to client\n");
839  hup->cid = cid;
840  GNUNET_MQ_send (line->mq, env);
841 }
uint16_t status
See PRISM_STATUS_*-constants.
ChannelStatus
The possible connection status.

References ch, ClientPhoneHangupMessage::cid, CS_CALLEE_CONNECTED, CS_CALLEE_INIT, CS_CALLEE_RINGING, CS_CALLEE_SHUTDOWN, CS_CALLER_CALLING, CS_CALLER_CONNECTED, CS_CALLER_SHUTDOWN, destroy_line_cadet_channels(), env, GNUNET_break_op, GNUNET_CADET_receive_done(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP, GNUNET_MQ_msg, GNUNET_MQ_send(), line, and status.

Here is the call graph for this function:

◆ handle_cadet_pickup_message()

static void handle_cadet_pickup_message ( void *  cls,
const struct CadetPhonePickupMessage message 
)
static

Function to handle a pickup message incoming over cadet.

Parameters
clsclosure, our struct Channel *
messagethe incoming message

Definition at line 851 of file gnunet-service-conversation.c.

853 {
854  struct Channel *ch = cls;
855  struct Line *line = ch->line;
856  struct GNUNET_MQ_Envelope *env;
857  struct ClientPhonePickedupMessage *pick;
858 
859  (void) message;
860  GNUNET_CADET_receive_done (ch->channel);
861  switch (ch->status)
862  {
863  case CS_CALLEE_INIT:
864  case CS_CALLEE_RINGING:
865  case CS_CALLEE_CONNECTED:
866  GNUNET_break_op (0);
868  return;
869 
870  case CS_CALLEE_SHUTDOWN:
871  GNUNET_break_op (0);
873  return;
874 
875  case CS_CALLER_CALLING:
876  ch->status = CS_CALLER_CONNECTED;
877  break;
878 
879  case CS_CALLER_CONNECTED:
880  GNUNET_break_op (0);
881  return;
882 
883  case CS_CALLER_SHUTDOWN:
884  GNUNET_break_op (0);
886  return;
887  }
888  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending PICKED UP message to client\n");
889  env =
891  pick->cid = ch->cid;
892  GNUNET_MQ_send (line->mq, env);
893 }
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICKED_UP
Service -> Client message to notify that phone was picked up.
Service -> Client: other peer has picked up the phone, we are now talking.
Definition: conversation.h:244
uint32_t cid
Call ID of the corresponding GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_CALL.
Definition: conversation.h:254

References ch, ClientPhonePickedupMessage::cid, CS_CALLEE_CONNECTED, CS_CALLEE_INIT, CS_CALLEE_RINGING, CS_CALLEE_SHUTDOWN, CS_CALLER_CALLING, CS_CALLER_CONNECTED, CS_CALLER_SHUTDOWN, destroy_line_cadet_channels(), env, GNUNET_break_op, GNUNET_CADET_receive_done(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICKED_UP, GNUNET_MQ_msg, GNUNET_MQ_send(), line, and mq_done_finish_caller_shutdown().

Here is the call graph for this function:

◆ handle_cadet_suspend_message()

static void handle_cadet_suspend_message ( void *  cls,
const struct CadetPhoneSuspendMessage message 
)
static

Function to handle a suspend message incoming over cadet.

Parameters
clsclosure, our struct Channel *
messagethe incoming message

Definition at line 903 of file gnunet-service-conversation.c.

905 {
906  struct Channel *ch = cls;
907  struct Line *line = ch->line;
908  struct GNUNET_MQ_Envelope *env;
909  struct ClientPhoneSuspendMessage *suspend;
910 
911  (void) message;
912  GNUNET_CADET_receive_done (ch->channel);
913  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suspending channel CID: %u\n", ch->cid);
914  switch (ch->status)
915  {
916  case CS_CALLEE_INIT:
917  GNUNET_break_op (0);
918  break;
919 
920  case CS_CALLEE_RINGING:
921  GNUNET_break_op (0);
922  break;
923 
924  case CS_CALLEE_CONNECTED:
925  ch->suspended_remote = GNUNET_YES;
926  break;
927 
928  case CS_CALLEE_SHUTDOWN:
929  return;
930 
931  case CS_CALLER_CALLING:
932  GNUNET_break_op (0);
933  break;
934 
935  case CS_CALLER_CONNECTED:
936  ch->suspended_remote = GNUNET_YES;
937  break;
938 
939  case CS_CALLER_SHUTDOWN:
940  return;
941  }
942  env =
944  suspend->cid = ch->cid;
945  GNUNET_MQ_send (line->mq, env);
946 }
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND
Client <-> Server message to suspend connection.
Service <-> Client message for phone was suspended.
Definition: conversation.h:118
uint32_t cid
CID, internal caller ID to identify which active call we are talking about.
Definition: conversation.h:128

References ch, ClientPhoneSuspendMessage::cid, CS_CALLEE_CONNECTED, CS_CALLEE_INIT, CS_CALLEE_RINGING, CS_CALLEE_SHUTDOWN, CS_CALLER_CALLING, CS_CALLER_CONNECTED, CS_CALLER_SHUTDOWN, env, GNUNET_break_op, GNUNET_CADET_receive_done(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_YES, and line.

Here is the call graph for this function:

◆ handle_cadet_resume_message()

static void handle_cadet_resume_message ( void *  cls,
const struct CadetPhoneResumeMessage msg 
)
static

Function to handle a resume message incoming over cadet.

Parameters
clsclosure, our struct Channel *
msgthe incoming message

Definition at line 956 of file gnunet-service-conversation.c.

958 {
959  struct Channel *ch = cls;
960  struct Line *line;
961  struct GNUNET_MQ_Envelope *env;
962  struct ClientPhoneResumeMessage *resume;
963 
964  (void) msg;
965  line = ch->line;
966  GNUNET_CADET_receive_done (ch->channel);
967  if (GNUNET_YES != ch->suspended_remote)
968  {
969  GNUNET_log (
971  "RESUME message received for non-suspended channel, dropping channel.\n");
973  return;
974  }
975  switch (ch->status)
976  {
977  case CS_CALLEE_INIT:
978  GNUNET_break (0);
979  break;
980 
981  case CS_CALLEE_RINGING:
982  GNUNET_break (0);
983  break;
984 
985  case CS_CALLEE_CONNECTED:
986  ch->suspended_remote = GNUNET_NO;
987  break;
988 
989  case CS_CALLEE_SHUTDOWN:
990  return;
991 
992  case CS_CALLER_CALLING:
993  GNUNET_break (0);
994  break;
995 
996  case CS_CALLER_CONNECTED:
997  ch->suspended_remote = GNUNET_NO;
998  break;
999 
1000  case CS_CALLER_SHUTDOWN:
1001  return;
1002  }
1003  env =
1005  resume->cid = ch->cid;
1006  GNUNET_MQ_send (line->mq, env);
1007 }
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME
Client <-> Server message to resume connection.
Service <-> Client message for phone was resumed.
Definition: conversation.h:136
uint32_t cid
CID, internal caller ID to identify which active call we are talking about.
Definition: conversation.h:146

References ch, ClientPhoneResumeMessage::cid, CS_CALLEE_CONNECTED, CS_CALLEE_INIT, CS_CALLEE_RINGING, CS_CALLEE_SHUTDOWN, CS_CALLER_CALLING, CS_CALLER_CONNECTED, CS_CALLER_SHUTDOWN, destroy_line_cadet_channels(), env, GNUNET_break, GNUNET_CADET_receive_done(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_NO, GNUNET_YES, line, and msg.

Here is the call graph for this function:

◆ check_cadet_audio_message()

static int check_cadet_audio_message ( void *  cls,
const struct CadetAudioMessage msg 
)
static

Function to check an audio message incoming over cadet.

Parameters
clsclosure, our struct Channel *
msgthe incoming message
Returns
GNUNET_OK (always)

Definition at line 1018 of file gnunet-service-conversation.c.

1019 {
1020  (void) cls;
1021  (void) msg;
1022  return GNUNET_OK; /* any payload is fine */
1023 }

References GNUNET_OK, and msg.

◆ handle_cadet_audio_message()

static void handle_cadet_audio_message ( void *  cls,
const struct CadetAudioMessage msg 
)
static

Function to handle an audio message incoming over cadet.

Parameters
clsclosure, our struct Channel *
msgthe incoming message

Definition at line 1033 of file gnunet-service-conversation.c.

1034 {
1035  struct Channel *ch = cls;
1036  size_t msize = ntohs (msg->header.size) - sizeof(struct CadetAudioMessage);
1037  struct GNUNET_MQ_Envelope *env;
1038  struct ClientAudioMessage *cam;
1039 
1040  GNUNET_CADET_receive_done (ch->channel);
1041  if ((GNUNET_YES == ch->suspended_local) ||
1042  (GNUNET_YES == ch->suspended_remote))
1043  {
1044  GNUNET_log (
1046  "Received %u bytes of AUDIO data on suspended channel CID %u; dropping\n",
1047  (unsigned int) msize,
1048  ch->cid);
1049  return;
1050  }
1052  "Forwarding %u bytes of AUDIO data to client CID %u\n",
1053  (unsigned int) msize,
1054  ch->cid);
1055  env =
1057  cam->cid = ch->cid;
1058  GNUNET_memcpy (&cam[1], &msg[1], msize);
1059  GNUNET_MQ_send (ch->line->mq, env);
1060 }
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO
Client <-> Server message to send audio data.
uint32_t cid
CID, internal caller ID to identify which active call we are sending data to.
Definition: conversation.h:201

References ch, ClientAudioMessage::cid, env, GNUNET_CADET_receive_done(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_YES, GNUNET_CADET_Channel::mq, msg, and GNUNET_MessageHeader::size.

Here is the call graph for this function:

◆ inbound_end()

static void inbound_end ( void *  cls,
const struct GNUNET_CADET_Channel channel 
)
static

Function called whenever an inbound channel is destroyed.

Should clean up any associated state.

Parameters
clsclosure (set from GNUNET_CADET_connect)
channelconnection to the other end (henceforth invalid)

Definition at line 1071 of file gnunet-service-conversation.c.

1072 {
1073  struct Channel *ch = cls;
1074 
1075  GNUNET_assert (channel == ch->channel);
1076  ch->channel = NULL;
1078  "Channel destroyed by CADET in state %d\n",
1079  ch->status);
1080  clean_up_channel (ch);
1081 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_CADET_Channel * channel
Handle for the channel.

References ch, Channel::channel, clean_up_channel(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, and GNUNET_log.

Referenced by handle_client_call_message(), and handle_client_register_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_client_call_message()

static void handle_client_call_message ( void *  cls,
const struct ClientCallMessage msg 
)
static

Function to handle call request from the client.

Parameters
clsthe struct Line the message is about
msgthe message from the client

Definition at line 1091 of file gnunet-service-conversation.c.

1092 {
1093  struct Line *line = cls;
1094  struct Channel *ch = GNUNET_new (struct Channel);
1095  struct GNUNET_MQ_MessageHandler cadet_handlers[] =
1096  { GNUNET_MQ_hd_fixed_size (cadet_hangup_message,
1098  struct CadetPhoneHangupMessage,
1099  ch),
1100  GNUNET_MQ_hd_fixed_size (cadet_pickup_message,
1102  struct CadetPhonePickupMessage,
1103  ch),
1104  GNUNET_MQ_hd_fixed_size (cadet_suspend_message,
1106  struct CadetPhoneSuspendMessage,
1107  ch),
1108  GNUNET_MQ_hd_fixed_size (cadet_resume_message,
1110  struct CadetPhoneResumeMessage,
1111  ch),
1112  GNUNET_MQ_hd_var_size (cadet_audio_message,
1114  struct CadetAudioMessage,
1115  ch),
1116  GNUNET_MQ_handler_end () };
1117  struct GNUNET_MQ_Envelope *e;
1118  struct CadetPhoneRingMessage *ring;
1119  struct CadetPhoneRingInfoPS rs;
1120 
1121  line->line_port = msg->line_port;
1122  rs.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CONVERSATION_RING);
1123  rs.purpose.size = htonl (sizeof(struct CadetPhoneRingInfoPS));
1124  rs.line_port = line->line_port;
1125  rs.target_peer = msg->target;
1126  rs.expiration_time =
1128  ch->line = line;
1129  GNUNET_CONTAINER_DLL_insert (line->channel_head, line->channel_tail, ch);
1130  ch->status = CS_CALLER_CALLING;
1131  ch->channel = GNUNET_CADET_channel_create (cadet,
1132  ch,
1133  &msg->target,
1134  &msg->line_port,
1135  NULL,
1136  &inbound_end,
1137  cadet_handlers);
1138  ch->mq = GNUNET_CADET_get_mq (ch->channel);
1140  GNUNET_IDENTITY_key_get_public (&msg->caller_id, &ring->caller_id);
1141  ring->expiration_time = rs.expiration_time;
1142  GNUNET_IDENTITY_sign (&msg->caller_id, &rs, &ring->signature);
1143  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending RING message via CADET\n");
1144  GNUNET_MQ_send (ch->mq, e);
1146 }
static void inbound_end(void *cls, const struct GNUNET_CADET_Channel *channel)
Function called whenever an inbound channel is destroyed.
#define RING_TIMEOUT
How long is our signature on a call valid? Needs to be long enough for time zone differences and netw...
static struct GNUNET_CADET_Handle * cadet
Handle for cadet.
struct GNUNET_CADET_Channel * GNUNET_CADET_channel_create(struct GNUNET_CADET_Handle *h, void *channel_cls, const struct GNUNET_PeerIdentity *destination, const struct GNUNET_HashCode *port, GNUNET_CADET_WindowSizeEventHandler window_changes, GNUNET_CADET_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers)
Create a new channel towards a remote peer.
Definition: cadet_api.c:1031
struct GNUNET_MQ_Handle * GNUNET_CADET_get_mq(const struct GNUNET_CADET_Channel *channel)
Obtain the message queue for a connected peer.
Definition: cadet_api.c:1082
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
enum GNUNET_GenericReturnValue GNUNET_IDENTITY_key_get_public(const struct GNUNET_IDENTITY_PrivateKey *privkey, struct GNUNET_IDENTITY_PublicKey *key)
Retrieves the public key representation of a private key.
Definition: identity_api.c:175
#define GNUNET_IDENTITY_sign(priv, ps, sig)
Sign a given block with GNUNET_IDENTITY_PrivateKey.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_RING
Cadet: call initiation.
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
Definition: time.c:181
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:464
Cadet message to make a phone ring.
Definition: conversation.h:292
struct GNUNET_IDENTITY_Signature signature
Signature over a struct CadetPhoneRingInfoPS
Definition: conversation.h:316
struct GNUNET_TIME_AbsoluteNBO expiration_time
When does the signature expire?
Definition: conversation.h:311
struct GNUNET_IDENTITY_PublicKey caller_id
Who is calling us? (also who is signing).
Definition: conversation.h:306
Message handler for a specific message type.

References cadet, CadetPhoneRingMessage::caller_id, ch, CS_CALLER_CALLING, e, CadetPhoneRingInfoPS::expiration_time, CadetPhoneRingMessage::expiration_time, GNUNET_CADET_channel_create(), GNUNET_CADET_get_mq(), GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_IDENTITY_key_get_public(), GNUNET_IDENTITY_sign, GNUNET_log, GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_AUDIO, GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_HANG_UP, GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_PICK_UP, GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_RESUME, GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_RING, GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_SUSPEND, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_new, GNUNET_SERVICE_client_continue(), GNUNET_SIGNATURE_PURPOSE_CONVERSATION_RING, GNUNET_TIME_absolute_hton(), GNUNET_TIME_relative_to_absolute(), inbound_end(), line, CadetPhoneRingInfoPS::line_port, GNUNET_CADET_Channel::mq, msg, CadetPhoneRingInfoPS::purpose, GNUNET_CRYPTO_EccSignaturePurpose::purpose, RING_TIMEOUT, CadetPhoneRingMessage::signature, GNUNET_CRYPTO_EccSignaturePurpose::size, and CadetPhoneRingInfoPS::target_peer.

Here is the call graph for this function:

◆ inbound_channel()

static void* inbound_channel ( void *  cls,
struct GNUNET_CADET_Channel channel,
const struct GNUNET_PeerIdentity initiator 
)
static

Method called whenever another peer has added us to a channel the other peer initiated.

Parameters
clsthe struct Line receiving a connection
channelnew handle to the channel
initiatorpeer that started the channel
Returns
initial channel context for the channel

Definition at line 1159 of file gnunet-service-conversation.c.

1162 {
1163  struct Line *line = cls;
1164  struct Channel *ch;
1165 
1166  (void) initiator;
1168  "Received incoming cadet channel on line %p\n",
1169  line);
1170  ch = GNUNET_new (struct Channel);
1171  ch->status = CS_CALLEE_INIT;
1172  ch->line = line;
1173  ch->channel = channel;
1174  ch->mq = GNUNET_CADET_get_mq (ch->channel);
1175  ch->cid = line->cid_gen++;
1176  GNUNET_CONTAINER_DLL_insert (line->channel_head, line->channel_tail, ch);
1177  return ch;
1178 }

References ch, Channel::channel, CS_CALLEE_INIT, GNUNET_CADET_get_mq(), GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, line, and GNUNET_CADET_Channel::mq.

Referenced by handle_client_register_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ client_connect_cb()

static void* client_connect_cb ( void *  cls,
struct GNUNET_SERVICE_Client client,
struct GNUNET_MQ_Handle mq 
)
static

A client connected.

Initialize the struct Line data structure.

Parameters
clsclosure, NULL
clientidentification of the client
mqmessage queue for client
Returns
the struct Line for the client

Definition at line 1190 of file gnunet-service-conversation.c.

1193 {
1194  struct Line *line;
1195 
1196  (void) cls;
1197  line = GNUNET_new (struct Line);
1198  line->client = client;
1199  line->mq = mq;
1200  return line;
1201 }
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
struct GNUNET_SERVICE_Client * client
Handle to the line client.

References Line::client, GNUNET_new, line, and mq.

◆ client_disconnect_cb()

static void client_disconnect_cb ( void *  cls,
struct GNUNET_SERVICE_Client client,
void *  app_ctx 
)
static

A client disconnected.

Remove all of its data structure entries.

Parameters
clsclosure, NULL
clientidentification of the client
app_ctxour struct Line * for client

Definition at line 1212 of file gnunet-service-conversation.c.

1215 {
1216  struct Line *line = app_ctx;
1217  struct Channel *chn;
1218 
1219  (void) cls;
1220  (void) client;
1221  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client disconnected, closing line\n");
1222  if (NULL != line->port)
1223  {
1224  GNUNET_CADET_close_port (line->port);
1225  line->port = NULL;
1226  }
1227  for (struct Channel *ch = line->channel_head; NULL != ch; ch = chn)
1228  {
1229  chn = ch->next;
1230  ch->line = NULL;
1232  }
1233  GNUNET_free (line);
1234 }
void GNUNET_CADET_close_port(struct GNUNET_CADET_Port *p)
Close a port opened with GNUNET_CADET_open_port().
Definition: cadet_api.c:808

References ch, destroy_line_cadet_channels(), GNUNET_CADET_close_port(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, and line.

Here is the call graph for this function:

◆ handle_client_register_message()

static void handle_client_register_message ( void *  cls,
const struct ClientPhoneRegisterMessage msg 
)
static

Function to register a phone.

Parameters
clsthe struct Line of the client from which the message is
msgthe message from the client

Definition at line 1244 of file gnunet-service-conversation.c.

1246 {
1247  struct Line *line = cls;
1248  struct GNUNET_MQ_MessageHandler cadet_handlers[] =
1249  { GNUNET_MQ_hd_fixed_size (cadet_ring_message,
1251  struct CadetPhoneRingMessage,
1252  NULL),
1253  GNUNET_MQ_hd_fixed_size (cadet_hangup_message,
1255  struct CadetPhoneHangupMessage,
1256  NULL),
1257  GNUNET_MQ_hd_fixed_size (cadet_pickup_message,
1259  struct CadetPhonePickupMessage,
1260  NULL),
1261  GNUNET_MQ_hd_fixed_size (cadet_suspend_message,
1263  struct CadetPhoneSuspendMessage,
1264  NULL),
1265  GNUNET_MQ_hd_fixed_size (cadet_resume_message,
1267  struct CadetPhoneResumeMessage,
1268  NULL),
1269  GNUNET_MQ_hd_var_size (cadet_audio_message,
1271  struct CadetAudioMessage,
1272  NULL),
1273  GNUNET_MQ_handler_end () };
1274 
1275  line->line_port = msg->line_port;
1277  &msg->line_port,
1278  &inbound_channel,
1279  line,
1280  NULL,
1281  &inbound_end,
1282  cadet_handlers);
1283  if (NULL == line->port)
1284  {
1286  _ ("Could not open line, port %s already in use!\n"),
1287  GNUNET_h2s (&msg->line_port));
1288  GNUNET_SERVICE_client_drop (line->client);
1289  return;
1290  }
1292 }
static void * inbound_channel(void *cls, struct GNUNET_CADET_Channel *channel, const struct GNUNET_PeerIdentity *initiator)
Method called whenever another peer has added us to a channel the other peer initiated.
struct GNUNET_CADET_Port * GNUNET_CADET_open_port(struct GNUNET_CADET_Handle *h, const struct GNUNET_HashCode *port, GNUNET_CADET_ConnectEventHandler connects, void *connects_cls, GNUNET_CADET_WindowSizeEventHandler window_changes, GNUNET_CADET_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers)
Open a port to receive incoming MQ-based channels.
Definition: cadet_api.c:970
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
#define _(String)
GNU gettext support macro.
Definition: platform.h:177

References _, cadet, GNUNET_CADET_open_port(), GNUNET_ERROR_TYPE_WARNING, GNUNET_h2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_AUDIO, GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_HANG_UP, GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_PICK_UP, GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_RESUME, GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_RING, GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_SUSPEND, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), inbound_channel(), inbound_end(), line, and msg.

Here is the call graph for this function:

◆ do_shutdown()

static void do_shutdown ( void *  cls)
static

Shutdown nicely.

Parameters
clsclosure, NULL

Definition at line 1301 of file gnunet-service-conversation.c.

1302 {
1303  (void) cls;
1304  if (NULL != cadet)
1305  {
1307  cadet = NULL;
1308  }
1309 }
void GNUNET_CADET_disconnect(struct GNUNET_CADET_Handle *handle)
Disconnect from the cadet service.
Definition: cadet_api.c:775

References cadet, GNUNET_MQ_MessageHandler::cls, and GNUNET_CADET_disconnect().

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

static void run ( void *  cls,
const struct GNUNET_CONFIGURATION_Handle c,
struct GNUNET_SERVICE_Handle service 
)
static

Main function that will be run by the scheduler.

Parameters
clsclosure
cconfiguration
serviceservice handle

Definition at line 1320 of file gnunet-service-conversation.c.

1323 {
1324  (void) cls;
1325  (void) service;
1326  cfg = c;
1330  if (NULL == cadet)
1331  {
1332  GNUNET_break (0);
1334  return;
1335  }
1337 }
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static void do_shutdown(void *cls)
Shutdown nicely.
struct GNUNET_CADET_Handle * GNUNET_CADET_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the MQ-based cadet service.
Definition: cadet_api.c:910
int GNUNET_CRYPTO_get_peer_identity(const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_PeerIdentity *dst)
Retrieve the identity of the host's peer.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:531
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
Definition: scheduler.c:1331

References cadet, cfg, GNUNET_MQ_MessageHandler::cls, do_shutdown(), GNUNET_assert, GNUNET_break, GNUNET_CADET_connect(), GNUNET_CRYPTO_get_peer_identity(), GNUNET_OK, GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), my_identity, and service.

Here is the call graph for this function:

◆ GNUNET_SERVICE_MAIN()

Define "main" method using service macro.

Variable Documentation

◆ cfg

const struct GNUNET_CONFIGURATION_Handle* cfg
static

Our configuration.

Definition at line 200 of file gnunet-service-conversation.c.

Referenced by run().

◆ cadet

struct GNUNET_CADET_Handle* cadet
static

◆ my_identity

struct GNUNET_PeerIdentity my_identity
static