43 #define RING_TIMEOUT GNUNET_TIME_UNIT_DAYS 246 if (NULL == line->
port)
281 "Ignoring client's PICKUP message, line is in SHUTDOWN\n");
427 "Received HANGUP for channel %u which is in state %d\n",
504 "Received SUSPEND for channel %u which is in state %d\n",
582 "Received RESUME for channel %u which is in state %d\n",
698 "Cadet audio channel in shutdown; audio data dropped\n");
705 "This channel is suspended locally\n");
713 "Bandwidth insufficient; dropping previous audio data segment\n");
719 "Received %u bytes of AUDIO data from client CID %u\n",
789 "Sending RING message to client. CID is %u\n",
790 (
unsigned int) ch->
cid);
971 "RESUME message received for non-suspended channel, dropping channel.\n");
1046 "Received %u bytes of AUDIO data on suspended channel CID %u; dropping\n",
1047 (
unsigned int) msize,
1052 "Forwarding %u bytes of AUDIO data to client CID %u\n",
1053 (
unsigned int) msize,
1078 "Channel destroyed by CADET in state %d\n",
1168 "Received incoming cadet channel on line %p\n",
1222 if (NULL != line->
port)
1283 if (NULL == line->
port)
1286 _ (
"Could not open line, port %s already in use!\n"),
static void inbound_end(void *cls, const struct GNUNET_CADET_Channel *channel)
Function called whenever an inbound channel is destroyed.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
uint32_t cid
CID, internal caller ID to identify which active call we are talking about.
Client -> Service message to call a phone.
struct Channel * prev
This is a DLL.
static struct GNUNET_CADET_Handle * cadet
Handle for cadet.
ChannelStatus
The possible connection status.
enum ChannelStatus status
Current status of this line.
static struct GNUNET_CADET_Channel * ch
Channel handle.
void GNUNET_CADET_disconnect(struct GNUNET_CADET_Handle *handle)
Disconnect from the cadet service.
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
Cadet message to make a phone ring.
struct GNUNET_MessageHeader * msg
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
uint64_t rel_value_us
The actual value.
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.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
static void handle_client_hangup_message(void *cls, const struct ClientPhoneHangupMessage *msg)
Function to handle a hangup request message from the client.
uint32_t purpose
What does this signature vouch for? This must contain a GNUNET_SIGNATURE_PURPOSE_XXX constant (from g...
#define RING_TIMEOUT
How long is our signature on a call valid? Needs to be long enough for time zone differences and netw...
Opaque handle to the service.
struct GNUNET_IDENTITY_PrivateKey caller_id
Identity of the caller.
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, or when GNUNET_SCHEDULER_shutdown() is being invoked.
static int check_cadet_audio_message(void *cls, const struct CadetAudioMessage *msg)
Function to check an audio message incoming over cadet.
constants for network protocols
static void handle_cadet_resume_message(void *cls, const struct CadetPhoneResumeMessage *msg)
Function to handle a resume message incoming over cadet.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_CALL
Client <- Server message to indicate a ringing phone.
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
static void handle_cadet_pickup_message(void *cls, const struct CadetPhonePickupMessage *message)
Function to handle a pickup message incoming over cadet.
#define GNUNET_SIGNATURE_PURPOSE_CONVERSATION_RING
Signature of a conversation ring.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
A struct Channel represents a cadet channel, which is a P2P connection to another conversation servic...
Information signed in a struct CadetPhoneRingMessage whereby the caller self-identifies to the receiv...
struct GNUNET_PeerIdentity target_peer
Which peer is the call for?
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_AUDIO.
uint32_t cid
CID, internal caller ID to identify which active call we are talking about.
static void handle_client_audio_message(void *cls, const struct ClientAudioMessage *msg)
Function to handle audio data from the client.
static void handle_cadet_audio_message(void *cls, const struct CadetAudioMessage *msg)
Function to handle an audio message incoming over cadet.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_AUDIO
Cadet: audio data.
struct GNUNET_PeerIdentity target
Which peer is hosting the line?
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_SUSPEND
Cadet: phone suspended.
static void channel_audio_sent_notify(void *cls)
Transmission of audio data via cadet channel finished.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
static struct Experiment * e
struct GNUNET_CADET_Port * port
Our open port.
Client -> Service message to register a phone.
Opaque handle to a channel.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static struct GNUNET_PeerIdentity my_identity
Identity of this peer.
struct GNUNET_CADET_Channel * channel
Handle for the channel.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_HANG_UP
Cadet: hang up / refuse call.
uint32_t cid_gen
Generator for channel IDs.
struct Channel * channel_tail
This is a DLL.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO
Client <-> Server message to send audio data.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICK_UP
Client -> Server message to reject/hangup a call.
Client -> Service pick up phone that is ringing.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
We're in shutdown, sending hangup messages before cleaning up.
static void handle_cadet_ring_message(void *cls, const struct CadetPhoneRingMessage *msg)
Function to handle a ring message incoming over cadet.
We are waiting for the phone to be picked up.
struct GNUNET_CADET_Handle * GNUNET_CADET_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the MQ-based cadet service.
#define GNUNET_IDENTITY_sign(priv, ps, sig)
Sign a given block with GNUNET_IDENTITY_PrivateKey.
static void handle_client_register_message(void *cls, const struct ClientPhoneRegisterMessage *msg)
Function to register a phone.
#define GNUNET_IDENTITY_signature_verify(purp, ps, sig, pub)
Verify a given signature with GNUNET_IDENTITY_PublicKey.
static void handle_client_call_message(void *cls, const struct ClientCallMessage *msg)
Function to handle call request from the client.
Handle to a client that is connected to a service.
int8_t suspended_local
GNUNET_YES if the channel was suspended by the local client.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RING
Client <- Server message to indicate a ringing phone.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
static void clean_up_channel(struct Channel *ch)
Channel went down, notify client and free data structure.
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 incomming MQ-based channels.
struct Line * line
Line associated with the channel.
void * cls
Closure for mv and cb.
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...
Client <-> Service hang up phone that may or may not be ringing.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
uint32_t cid
Call ID of the corresponding GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_CALL.
static void handle_client_suspend_message(void *cls, const struct ClientPhoneSuspendMessage *msg)
Function to handle a suspend request message from the client.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICKED_UP
Service -> Client message to notify that phone was picked up.
struct GNUNET_MQ_Envelope * env
Temporary buffer for audio data in the mq.
We just got the connection, but no introduction yet.
struct GNUNET_TIME_AbsoluteNBO expiration_time
When does the signature expire?
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_PICK_UP
Cadet: pick up phone (establish audio channel)
Our phone is ringing, waiting for the client to pick up.
static void handle_cadet_hangup_message(void *cls, const struct CadetPhoneHangupMessage *message)
Function to handle a hangup message incoming over cadet.
static void destroy_line_cadet_channels(struct Channel *ch)
Destroy a channel.
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.
static void * client_connect_cb(void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
A client connected.
uint32_t size
How many bytes does this signature sign? (including this purpose header); in network byte order (!)...
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_RESUME
Cadet: phone resumed.
static struct Channel * find_channel_by_line(struct Line *line, uint32_t cid)
Given a cid, find the corresponding channel given a line.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Message handler for a specific message type.
static void mq_done_finish_caller_shutdown(void *cls)
We are done signalling shutdown to the other peer.
A struct Line connects a local client with cadet channels.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME
Client <-> Server message to resume connection.
static unsigned int size
Size of the "table".
uint32_t cid
CID, internal caller ID number used in the future to identify which active call we are talking about...
struct GNUNET_MQ_Handle * mq
Message queue for client.
Cadet message for phone suspended.
struct GNUNET_HashCode line_port
Phone line / CADET port to register.
struct GNUNET_CRYPTO_EccSignaturePurpose purpose
Purpose for the signature, must be GNUNET_SIGNATURE_PURPOSE_CONVERSATION_RING.
Service <-> Client message for phone was resumed.
Service -> Client: other peer has picked up the phone, we are now talking.
Handle to a message queue.
static void handle_cadet_suspend_message(void *cls, const struct CadetPhoneSuspendMessage *message)
Function to handle a suspend message incoming over cadet.
static void client_disconnect_cb(void *cls, struct GNUNET_SERVICE_Client *client, void *app_ctx)
A client disconnected.
struct GNUNET_HashCode line_port
Port number we are listening on (to verify signatures).
struct GNUNET_SERVICE_Client * client
Handle to the line client.
The identity of the host (wraps the signing key of the peer).
struct GNUNET_HashCode line_port
Which phone line to call at the peer?
void GNUNET_CADET_receive_done(struct GNUNET_CADET_Channel *channel)
Send an ack on the channel to confirm the processing of a message.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_REGISTER
Client -> Server message to register a phone.
uint32_t cid
CID, internal caller ID to identify which active call we are talking about.
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.
struct GNUNET_IDENTITY_Signature signature
Signature over a struct CadetPhoneRingInfoPS
struct GNUNET_IDENTITY_PublicKey caller_id
Who is calling us? (also who is signing).
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_PHONE_RING
Cadet: call initiation.
Service -> Client message for phone is ringing.
Cadet message for phone resumed.
static void do_shutdown(void *cls)
Shutdown nicely.
struct Channel * channel_head
This is a DLL.
#define GNUNET_log(kind,...)
Message Client <-> Service to transmit the audio.
struct GNUNET_IDENTITY_PublicKey caller_id
Who is calling us?
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.
static int check_client_audio_message(void *cls, const struct ClientAudioMessage *msg)
Function to check audio data from the client.
int GNUNET_CRYPTO_get_peer_identity(const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_PeerIdentity *dst)
Retrieve the identity of the host's peer.
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?
static void handle_client_resume_message(void *cls, const struct ClientPhoneResumeMessage *msg)
Function to handle a resume request message from the client.
void GNUNET_CADET_close_port(struct GNUNET_CADET_Port *p)
Close a port opened with GNUNET_CADET_open_port().
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Cadet message for hanging up.
We're in shutdown, sending hangup messages before cleaning up.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND
Client <-> Server message to suspend connection.
static void handle_client_pickup_message(void *cls, const struct ClientPhonePickupMessage *msg)
Function to handle a pickup request message from the client.
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.
struct GNUNET_MQ_Handle * mq
Message queue for control messages.
Service <-> Client message for phone was suspended.
Cadet message for picking up.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
void GNUNET_MQ_send_cancel(struct GNUNET_MQ_Envelope *ev)
Cancel sending the message.
void GNUNET_CADET_channel_destroy(struct GNUNET_CADET_Channel *channel)
Destroy an existing channel.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
struct Channel * next
This is a DLL.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP
Client -> Server message to reject/hangup a call.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
int8_t suspended_remote
GNUNET_YES if the channel was suspended by the other peer.
uint32_t cid
CID, internal caller ID to identify which active call we are talking about.
struct GNUNET_TIME_AbsoluteNBO expiration_time
When does the signature expire?
Cadet message to transmit the audio.
#define GNUNET_free(ptr)
Wrapper around free.
uint32_t cid
Channel identifier we use for this call with the client.
struct GNUNET_MQ_Handle * GNUNET_CADET_get_mq(const struct GNUNET_CADET_Channel *channel)
Obtain the message queue for a connected peer.
struct GNUNET_HashCode line_port
Which port did the call go to?
uint32_t cid
CID, internal caller ID to identify which active call we are sending data to.