270 key_len = ntohl (ring->
key_len);
343 "Received HANG_UP message for unknown caller ID %u\n",
344 (
unsigned int) hang->
cid);
349 "Received HANG_UP message, terminating call with `%s'\n",
351 switch (caller->
state)
402 switch (caller->
state)
447 switch (caller->
state)
513 switch (caller->
state)
549 "Connection to conversation service lost, trying to reconnect\n"));
738 void *event_handler_cls,
777 switch (caller->
state)
847 suspend->
cid = caller->
cid;
879 resume->
cid = caller->
cid;
struct GNUNET_MQ_MessageHandlers handlers[]
constants for network protocols
CallerState
Possible states of a caller.
@ CS_CALLEE_SUSPENDED
We suspended the conversation.
@ CS_BOTH_SUSPENDED
Both sides suspended the conversation.
@ CS_ACTIVE
The phone is in an active conversation.
@ CS_CALLER_SUSPENDED
Caller suspended the conversation.
@ CS_RINGING
The phone is ringing (user knows about incoming call).
static enum GNUNET_GenericReturnValue check_phone_ring(void *cls, const struct ClientPhoneRingMessage *ring)
We received a struct ClientPhoneRingMessage
static void clean_up_callers(struct GNUNET_CONVERSATION_Phone *phone)
Clean up all callers of the given phone.
static void handle_phone_ring(void *cls, const struct ClientPhoneRingMessage *ring)
We received a struct ClientPhoneRingMessage
static struct GNUNET_CONVERSATION_Caller * find_caller(struct GNUNET_CONVERSATION_Phone *phone, uint32_t cid)
Find the record of the caller matching the cid.
static void handle_phone_hangup(void *cls, const struct ClientPhoneHangupMessage *hang)
We received a struct ClientPhoneHangupMessage.
static int check_phone_audio(void *cls, const struct ClientAudioMessage *am)
We received a struct ClientAudioMessage, check it is well-formed.
static void handle_phone_resume(void *cls, const struct ClientPhoneResumeMessage *resume)
We received a struct ClientPhoneResumeMessage.
static void reconnect_phone(struct GNUNET_CONVERSATION_Phone *phone)
The phone got disconnected, reconnect to the service.
static void handle_phone_suspend(void *cls, const struct ClientPhoneSuspendMessage *suspend)
We received a struct ClientPhoneSuspendMessage.
static void phone_error_handler(void *cls, enum GNUNET_MQ_Error error)
We encountered an error talking with the conversation service.
static void transmit_phone_audio(void *cls, size_t data_size, const void *data)
Process recorded audio data.
static void handle_phone_audio(void *cls, const struct ClientAudioMessage *am)
We received a struct ClientAudioMessage
PhoneState
Possible states of a phone.
@ PS_REGISTER
We still need to register the phone.
@ PS_READY
We are waiting for calls.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static struct GNUNET_SPEAKER_Handle * speaker
Handle to the speaker.
static struct GNUNET_MICROPHONE_Handle * mic
Our microphone.
static char * line
Desired phone line (string to be converted to a hash).
static struct GNUNET_CONVERSATION_Phone * phone
Phone handle.
static char * data
The data to insert into the dht.
static struct GNUNET_GNSRECORD_Data rd[50]
The record data under a single label.
static size_t data_size
Number of bytes in data.
API to the conversation service.
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
void GNUNET_CONVERSATION_phone_get_record(struct GNUNET_CONVERSATION_Phone *phone, struct GNUNET_GNSRECORD_Data *rd)
Fill in a namestore record with the contact information for this phone.
struct GNUNET_CONVERSATION_Phone * GNUNET_CONVERSATION_phone_create(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_IDENTITY_Ego *ego, GNUNET_CONVERSATION_PhoneEventHandler event_handler, void *event_handler_cls)
Create a new phone.
void(* GNUNET_CONVERSATION_CallerEventHandler)(void *cls, enum GNUNET_CONVERSATION_CallerEventCode code)
Function called with an event emitted by a caller.
void GNUNET_CONVERSATION_caller_suspend(struct GNUNET_CONVERSATION_Caller *caller)
Pause conversation of an active call.
void(* GNUNET_CONVERSATION_PhoneEventHandler)(void *cls, enum GNUNET_CONVERSATION_PhoneEventCode code, struct GNUNET_CONVERSATION_Caller *caller, const struct GNUNET_CRYPTO_PublicKey *caller_id)
Function called with an event emitted by a phone.
void GNUNET_CONVERSATION_phone_destroy(struct GNUNET_CONVERSATION_Phone *phone)
Destroys a phone.
void GNUNET_CONVERSATION_caller_resume(struct GNUNET_CONVERSATION_Caller *caller, struct GNUNET_SPEAKER_Handle *speaker, struct GNUNET_MICROPHONE_Handle *mic)
Resume suspended conversation of a phone.
void GNUNET_CONVERSATION_caller_hang_up(struct GNUNET_CONVERSATION_Caller *caller)
Hang up up a (possibly ringing) phone.
void GNUNET_CONVERSATION_caller_pick_up(struct GNUNET_CONVERSATION_Caller *caller, GNUNET_CONVERSATION_CallerEventHandler event_handler, void *event_handler_cls, struct GNUNET_SPEAKER_Handle *speaker, struct GNUNET_MICROPHONE_Handle *mic)
Picks up a (ringing) phone.
@ GNUNET_CONVERSATION_EC_CALLER_RESUME
We are the callee and the caller resumed the call.
@ GNUNET_CONVERSATION_EC_CALLER_SUSPEND
We are the callee and the caller suspended the call.
@ GNUNET_CONVERSATION_EC_PHONE_HUNG_UP
The conversation was terminated by the caller.
@ GNUNET_CONVERSATION_EC_PHONE_RING
We are the callee and the phone is ringing.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_get_peer_identity(const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_PeerIdentity *dst)
Retrieve the identity of the host's peer.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
const char * GNUNET_GNSRECORD_pkey_to_zkey(const struct GNUNET_CRYPTO_PublicKey *pkey)
Convert public key to the respective absolute domain name in the ".zkey" pTLD.
@ GNUNET_GNSRECORD_RF_NONE
Entry for no flags / cleared flags.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
const struct GNUNET_CRYPTO_PrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
#define GNUNET_log(kind,...)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_read_public_key_from_buffer(const void *buffer, size_t len, struct GNUNET_CRYPTO_PublicKey *key, size_t *read)
Reads a GNUNET_CRYPTO_PublicKey from a compact buffer.
GNUNET_GenericReturnValue
Named constants for return values.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
GNUNET_MQ_Error
Error codes for the queue.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
void GNUNET_NAMESTORE_disconnect(struct GNUNET_NAMESTORE_Handle *h)
Disconnect from the namestore service (and free associated resources).
struct GNUNET_NAMESTORE_Handle * GNUNET_NAMESTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the namestore service.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME
Client <-> Server message to resume connection.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_REGISTER
Client -> Server message to register a phone.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICK_UP
Client -> Server message to reject/hangup a call.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND
Client <-> Server message to suspend connection.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP
Client -> Server message to reject/hangup a call.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO
Client <-> Server message to send audio data.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RING
Client <- Server message to indicate a ringing phone.
#define GNUNET_GNSRECORD_TYPE_PHONE
Endpoint for conversation.
Message Client <-> Service to transmit the audio.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO.
uint32_t cid
CID, internal caller ID to identify which active call we are sending data to.
Client <-> Service hang up phone that may or may not be ringing.
uint32_t cid
CID, internal caller ID to identify which active call we are talking about.
Client -> Service pick up phone that is ringing.
uint32_t cid
CID, internal caller ID to identify which active call we are talking about.
Client -> Service message to register a phone.
struct GNUNET_HashCode line_port
Phone line / CADET port to register.
Service <-> Client message for phone was resumed.
uint32_t cid
CID, internal caller ID to identify which active call we are talking about.
Service -> Client message for phone is ringing.
uint32_t cid
CID, internal caller ID number used in the future to identify which active call we are talking about.
uint32_t key_len
The identity key length.
Service <-> Client message for phone was suspended.
uint32_t cid
CID, internal caller ID to identify which active call we are talking about.
A caller is the handle we have for an incoming call.
uint32_t cid
Internal handle to identify the caller with the service.
struct GNUNET_CONVERSATION_Caller * next
We keep all callers in a DLL.
struct GNUNET_MICROPHONE_Handle * mic
Microphone, or NULL if none is attached.
void * event_handler_cls
Closure for event_handler.
struct GNUNET_SPEAKER_Handle * speaker
Speaker, or NULL if none is attached.
struct GNUNET_CONVERSATION_Phone * phone
Our phone.
enum CallerState state
State machine for the phone.
struct GNUNET_CRYPTO_PublicKey caller_id
Identity of the person calling us.
struct GNUNET_CONVERSATION_Caller * prev
We keep all callers in a DLL.
GNUNET_CONVERSATION_CallerEventHandler event_handler
Function to call for phone events.
A phone record specifies which peer is hosting a given user and may also specify the phone line that ...
struct GNUNET_HashCode line_port
Phone line (CADET port) to connect to.
struct GNUNET_PeerIdentity peer
Identity of the peer hosting the phone service.
uint32_t reserved
Reserved.
uint32_t version
Version of the phone record, for now always one.
A phone is a device that can ring to signal an incoming call and that you can pick up to answer the c...
GNUNET_CONVERSATION_PhoneEventHandler event_handler
Function to call for phone events.
struct GNUNET_CRYPTO_PrivateKey my_zone
My GNS zone.
struct GNUNET_MQ_Handle * mq
Handle for transmitting to the CONVERSATION service.
struct GNUNET_CONVERSATION_Caller * caller_tail
We keep all callers in a DLL.
struct GNUNET_NAMESTORE_Handle * ns
Connection to NAMESTORE (for reverse lookup).
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
struct GNUNET_CONVERSATION_Caller * caller_head
We keep all callers in a DLL.
struct GNUNET_CONVERSATION_PhoneRecord my_record
This phone's record.
enum PhoneState state
State machine for the phone.
void * event_handler_cls
Closure for event_handler.
A private key for an identity as per LSD0001.
An identity key as per LSD0001.
uint32_t record_type
Type of the GNS/DNS record.
const void * data
Binary value stored in the DNS record.
size_t data_size
Number of bytes in data.
enum GNUNET_GNSRECORD_Flags flags
Flags for the record.
uint64_t expiration_time
Expiration time for the DNS record.
A microphone is a device that can capture or otherwise produce audio data.
void * cls
Closure for the callbacks.
GNUNET_MICROPHONE_DisableCallback disable_microphone
Turn the microphone off.
GNUNET_MICROPHONE_EnableCallback enable_microphone
Turn on the microphone.
Handle to a message queue.
Message handler for a specific message type.
Connection to the NAMESTORE service.
A speaker is a device that can play or record audio data.
void * cls
Closure for the callbacks.
GNUNET_SPEAKER_PlayCallback play
Play audio.
GNUNET_SPEAKER_EnableCallback enable_speaker
Turn on the speaker.
GNUNET_SPEAKER_DisableCallback disable_speaker
Turn the speaker off.