conversation implementation More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_gnsrecord_lib.h"
#include "gnunet_conversation_service.h"
Go to the source code of this file.
Data Structures | |
struct | CallList |
List of incoming calls. More... | |
struct | VoipCommand |
Structure which defines a command. More... | |
Macros | |
#define | MAX_MESSAGE_LENGTH 1024 |
Maximum length allowed for the command line input. More... | |
#define | XSTRINGIFY(x) STRINGIFY (x) |
#define | STRINGIFY(x) (#x) |
Typedefs | |
typedef void(* | ActionFunction) (const char *arguments) |
Function declareation for executing a action. More... | |
Enumerations | |
enum | PhoneState { PS_REGISTER = 0 , PS_READY , PS_LOOKUP_EGO , PS_LISTEN , PS_ACCEPTED , PS_ERROR } |
Possible states of the phone. More... | |
enum | CallState { CS_LOOKUP = 0 , CS_RINGING , CS_ACTIVE , CS_SHUTDOWN , CS_SUSPENDED_CALLER , CS_SUSPENDED_CALLEE , CS_SUSPENDED_BOTH , CS_RESOLVING , CS_RINGING , CS_CONNECTED , CS_SUSPENDED } |
States for current outgoing call. More... | |
Functions | |
static void | phone_event_handler (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. More... | |
static void | caller_event_handler (void *cls, enum GNUNET_CONVERSATION_CallerEventCode code) |
Function called with an event emitted by a caller. More... | |
static void | start_phone () |
Start our phone. More... | |
static void | call_event_handler (void *cls, enum GNUNET_CONVERSATION_CallEventCode code) |
Function called with an event emitted by a call. More... | |
static void | do_help (const char *args) |
Action function to print help for the command shell. More... | |
static void | do_quit (const char *args) |
Terminate the client. More... | |
static void | do_unknown (const char *msg) |
Handler for unknown command. More... | |
static void | do_call (const char *arg) |
Initiating a new call. More... | |
static void | do_accept (const char *args) |
Accepting an incoming call. More... | |
static void | do_address (const char *args) |
Print address information for this phone. More... | |
static void | do_status (const char *args) |
Accepting an incoming call. More... | |
static void | do_suspend (const char *args) |
Suspending a call. More... | |
static void | do_resume (const char *args) |
Resuming a call. More... | |
static void | do_reject (const char *args) |
Rejecting a call. More... | |
static void | do_stop_task (void *cls) |
Task run during shutdown. More... | |
static void | handle_command_string (char *message, size_t str_len) |
Handle user command. More... | |
static void | handle_command (void *cls) |
Task to handle commands from the terminal. More... | |
static void | identity_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, const char *name) |
Function called by identity service with information about egos. More... | |
static void | run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) |
Main function that will be run by the scheduler. More... | |
int | main (int argc, char *const *argv) |
The main function to conversation. More... | |
Variables | |
static struct GNUNET_CONVERSATION_Phone * | phone |
Phone handle. More... | |
static struct GNUNET_CONVERSATION_Call * | call |
Call handle (for active outgoing call). More... | |
static struct CallList * | cl_active |
Caller handle (for active incoming call). More... | |
static struct CallList * | cl_head |
Head of calls waiting to be accepted. More... | |
static struct CallList * | cl_tail |
Tail of calls waiting to be accepted. More... | |
static char * | line |
Desired phone line (string to be converted to a hash). More... | |
static struct GNUNET_SCHEDULER_Task * | handle_cmd_task |
Task which handles the commands. More... | |
static struct GNUNET_SPEAKER_Handle * | speaker |
Our speaker. More... | |
static struct GNUNET_MICROPHONE_Handle * | mic |
Our microphone. More... | |
static struct GNUNET_CONFIGURATION_Handle * | cfg |
Our configuration. More... | |
static struct GNUNET_IDENTITY_Ego * | my_caller_id |
Our ego. More... | |
static struct GNUNET_IDENTITY_Handle * | id |
Handle to identity service. More... | |
static char * | ego_name |
Name of our ego. More... | |
static struct GNUNET_CRYPTO_PublicKey | peer_key |
Public key of active conversation partner (if any). More... | |
static char * | peer_name |
Name of active conversation partner (if any). More... | |
static struct GNUNET_DISK_FileHandle * | stdin_fh |
File handle for stdin. More... | |
static enum PhoneState | phone_state |
Our phone's current state. More... | |
static enum CallState | call_state |
Our call's current state. More... | |
static unsigned int | caller_num_gen |
Counts the number of incoming calls we have had so far. More... | |
static char * | address |
GNS address for this phone. More... | |
static int | verbose |
Be verbose. More... | |
static struct VoipCommand | commands [] |
List of supported commands. More... | |
conversation implementation
Definition in file gnunet-conversation.c.
#define MAX_MESSAGE_LENGTH 1024 |
Maximum length allowed for the command line input.
Definition at line 34 of file gnunet-conversation.c.
#define XSTRINGIFY | ( | x | ) | STRINGIFY (x) |
Definition at line 36 of file gnunet-conversation.c.
#define STRINGIFY | ( | x | ) | (#x) |
Definition at line 38 of file gnunet-conversation.c.
typedef void(* ActionFunction) (const char *arguments) |
Function declareation for executing a action.
arguments | arguments given to the function |
Definition at line 444 of file gnunet-conversation.c.
enum PhoneState |
Possible states of the phone.
Definition at line 43 of file gnunet-conversation.c.
enum CallState |
States for current outgoing call.
Definition at line 70 of file gnunet-conversation.c.
|
static |
Function called with an event emitted by a phone.
cls | closure |
code | type of the event |
caller | handle for the caller |
caller_id | public key of the caller (in GNS) |
Definition at line 242 of file gnunet-conversation.c.
References _, CallList::caller, CallList::caller_id, CallList::caller_num, caller_num_gen, cl_active, cl_head, cl_tail, GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_DLL_remove, GNUNET_CONVERSATION_EC_PHONE_HUNG_UP, GNUNET_CONVERSATION_EC_PHONE_RING, GNUNET_free, GNUNET_GNSRECORD_pkey_to_zkey(), GNUNET_new, CallList::next, phone_state, and PS_LISTEN.
Referenced by start_phone().
|
static |
Function called with an event emitted by a caller.
cls | closure with the struct CallList of the caller |
code | type of the event issued by the caller |
Definition at line 309 of file gnunet-conversation.c.
References _, CallList::caller_id, GNUNET_CONVERSATION_EC_CALLER_RESUME, GNUNET_CONVERSATION_EC_CALLER_SUSPEND, and GNUNET_GNSRECORD_pkey_to_zkey().
Referenced by do_accept().
|
static |
Start our phone.
Definition at line 334 of file gnunet-conversation.c.
References _, address, cfg, GNUNET_GNSRECORD_Data::data, GNUNET_GNSRECORD_Data::data_size, ego_name, GNUNET_assert, GNUNET_CONVERSATION_phone_create(), GNUNET_CONVERSATION_phone_get_record(), GNUNET_free, GNUNET_GNSRECORD_value_to_string(), my_caller_id, phone, phone_event_handler(), phone_state, PS_ERROR, PS_LISTEN, PS_LOOKUP_EGO, rd, and GNUNET_GNSRECORD_Data::record_type.
Referenced by identity_cb().
|
static |
Function called with an event emitted by a call.
cls | closure, NULL |
code | type of the event on the call |
Definition at line 380 of file gnunet-conversation.c.
References _, call, call_state, CS_CONNECTED, CS_RESOLVING, CS_RINGING, GNUNET_break, GNUNET_CONVERSATION_EC_CALL_ERROR, GNUNET_CONVERSATION_EC_CALL_GNS_FAIL, GNUNET_CONVERSATION_EC_CALL_HUNG_UP, GNUNET_CONVERSATION_EC_CALL_PICKED_UP, GNUNET_CONVERSATION_EC_CALL_RESUMED, GNUNET_CONVERSATION_EC_CALL_RINGING, GNUNET_CONVERSATION_EC_CALL_SUSPENDED, GNUNET_free, and peer_name.
Referenced by do_call().
|
static |
Action function to print help for the command shell.
args | arguments given to the command |
Definition at line 974 of file gnunet-conversation.c.
References VoipCommand::Action, consensus-simulation::args, VoipCommand::command, commands, do_help(), gettext, and VoipCommand::helptext.
Referenced by do_call(), and do_help().
|
static |
Terminate the client.
args | arguments given to the command |
Definition at line 484 of file gnunet-conversation.c.
References consensus-simulation::args, and GNUNET_SCHEDULER_shutdown().
|
static |
|
static |
Initiating a new call.
arg | arguments given to the command |
Definition at line 509 of file gnunet-conversation.c.
References _, find_typedefs::arg, call, call_event_handler(), call_state, cfg, CS_RESOLVING, do_help(), ego_name, GNUNET_assert, GNUNET_CONVERSATION_call_start(), GNUNET_GNSRECORD_pkey_to_zkey(), GNUNET_strdup, mic, my_caller_id, peer_key, peer_name, phone_state, PS_ACCEPTED, PS_ERROR, PS_LISTEN, PS_LOOKUP_EGO, and speaker.
|
static |
Accepting an incoming call.
args | arguments given to the command |
Definition at line 569 of file gnunet-conversation.c.
References _, consensus-simulation::args, call, call_state, CallList::caller, caller_event_handler(), CallList::caller_id, CallList::caller_num, cl_active, cl_head, cl_tail, CS_SUSPENDED, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_CONVERSATION_caller_pick_up(), GNUNET_GNSRECORD_pkey_to_zkey(), GNUNET_snprintf(), mic, CallList::next, peer_key, phone_state, PS_ACCEPTED, PS_ERROR, PS_LISTEN, PS_LOOKUP_EGO, and speaker.
|
static |
Print address information for this phone.
args | arguments given to the command |
Definition at line 642 of file gnunet-conversation.c.
References _, address, and consensus-simulation::args.
|
static |
Accepting an incoming call.
args | arguments given to the command |
Definition at line 660 of file gnunet-conversation.c.
References _, consensus-simulation::args, call, call_state, CallList::caller_id, CallList::caller_num, cl_active, cl_head, cl_tail, CS_CONNECTED, CS_RESOLVING, CS_RINGING, CS_SUSPENDED, ego_name, GNUNET_GNSRECORD_pkey_to_zkey(), line, CallList::next, peer_key, peer_name, phone_state, PS_ACCEPTED, PS_ERROR, PS_LISTEN, and PS_LOOKUP_EGO.
|
static |
Suspending a call.
args | arguments given to the command |
Definition at line 747 of file gnunet-conversation.c.
References _, consensus-simulation::args, call, call_state, CallList::caller, cl_active, CS_CONNECTED, CS_RESOLVING, CS_RINGING, CS_SUSPENDED, GNUNET_assert, GNUNET_CONVERSATION_call_suspend(), GNUNET_CONVERSATION_caller_suspend(), phone_state, PS_ACCEPTED, PS_ERROR, PS_LISTEN, and PS_LOOKUP_EGO.
|
static |
Resuming a call.
args | arguments given to the command |
Definition at line 795 of file gnunet-conversation.c.
References _, consensus-simulation::args, call, call_state, CallList::caller, CallList::caller_num, cl_active, cl_head, CS_CONNECTED, CS_RESOLVING, CS_RINGING, CS_SUSPENDED, GNUNET_assert, GNUNET_CONVERSATION_call_resume(), GNUNET_CONVERSATION_caller_resume(), GNUNET_GNSRECORD_pkey_to_zkey(), GNUNET_snprintf(), mic, CallList::next, peer_key, phone_state, PS_ACCEPTED, PS_ERROR, PS_LISTEN, PS_LOOKUP_EGO, and speaker.
|
static |
Rejecting a call.
args | arguments given to the command |
Definition at line 872 of file gnunet-conversation.c.
References _, consensus-simulation::args, call, CallList::caller, CallList::caller_num, cl_active, cl_head, cl_tail, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_CONVERSATION_call_stop(), GNUNET_CONVERSATION_caller_hang_up(), GNUNET_free, GNUNET_snprintf(), CallList::next, phone_state, PS_ACCEPTED, PS_ERROR, PS_LISTEN, and PS_LOOKUP_EGO.
|
static |
Task run during shutdown.
cls | NULL |
Definition at line 1007 of file gnunet-conversation.c.
References call, ego_name, GNUNET_CONVERSATION_call_stop(), GNUNET_CONVERSATION_phone_destroy(), GNUNET_free, GNUNET_IDENTITY_disconnect(), GNUNET_MICROPHONE_destroy(), GNUNET_SCHEDULER_cancel(), GNUNET_SPEAKER_destroy(), handle_cmd_task, mic, peer_name, phone, phone_state, PS_ERROR, and speaker.
Referenced by run().
|
static |
Handle user command.
message | command the user typed in |
str_len | number of bytes to process in message |
Definition at line 1049 of file gnunet-conversation.c.
References VoipCommand::Action, VoipCommand::command, and commands.
Referenced by handle_command().
|
static |
Task to handle commands from the terminal.
cls | NULL |
Definition at line 1083 of file gnunet-conversation.c.
References GNUNET_SCHEDULER_add_read_file(), GNUNET_TIME_UNIT_FOREVER_REL, handle_cmd_task, handle_command(), handle_command_string(), MAX_MESSAGE_LENGTH, and stdin_fh.
Referenced by handle_command(), and run().
|
static |
Function called by identity service with information about egos.
cls | NULL |
ego | ego handle |
ctx | unused |
name | name of the ego |
Definition at line 1110 of file gnunet-conversation.c.
References _, cfg, ctx, ego_name, GNUNET_CONFIGURATION_set_value_string(), GNUNET_free, GNUNET_strdup, line, my_caller_id, name, start_phone(), and verbose.
Referenced by run().
|
static |
Main function that will be run by the scheduler.
cls | closure |
args | remaining command-line arguments |
cfgfile | name of the configuration file used (for saving, can be NULL!) |
c | configuration |
Definition at line 1151 of file gnunet-conversation.c.
References _, consensus-simulation::args, cfg, do_stop_task(), ego_name, GNUNET_CONFIGURATION_dup(), GNUNET_IDENTITY_connect(), GNUNET_MICROPHONE_create_from_hardware(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_add_with_priority(), GNUNET_SCHEDULER_PRIORITY_UI, GNUNET_SPEAKER_create_from_hardware(), handle_cmd_task, handle_command(), identity_cb(), mic, and speaker.
Referenced by main().
int main | ( | int | argc, |
char *const * | argv | ||
) |
The main function to conversation.
argc | number of arguments from the command line |
argv | command line arguments |
Definition at line 1184 of file gnunet-conversation.c.
References cfg, ego_name, gettext_noop, GNUNET_CONFIGURATION_destroy(), GNUNET_DISK_get_handle_from_int_fd(), GNUNET_ERROR_TYPE_WARNING, GNUNET_GETOPT_OPTION_END, GNUNET_GETOPT_option_string(), GNUNET_log_strerror, GNUNET_OK, GNUNET_OS_project_data_gnunet(), GNUNET_PROGRAM_run(), line, options, ret, run(), and stdin_fh.
|
static |
Phone handle.
Definition at line 129 of file gnunet-conversation.c.
Referenced by clean_up_callers(), do_stop_task(), find_caller(), GNUNET_CONVERSATION_caller_hang_up(), GNUNET_CONVERSATION_caller_pick_up(), GNUNET_CONVERSATION_caller_resume(), GNUNET_CONVERSATION_caller_suspend(), GNUNET_CONVERSATION_phone_create(), GNUNET_CONVERSATION_phone_destroy(), GNUNET_CONVERSATION_phone_get_record(), handle_phone_audio(), handle_phone_hangup(), handle_phone_resume(), handle_phone_ring(), handle_phone_suspend(), phone_error_handler(), reconnect_phone(), start_phone(), and transmit_phone_audio().
|
static |
Call handle (for active outgoing call).
Definition at line 134 of file gnunet-conversation.c.
Referenced by call_error_handler(), call_event_handler(), do_accept(), do_call(), do_reject(), do_resume(), do_status(), do_stop_task(), do_suspend(), fail_call(), GNUNET_CONVERSATION_call_resume(), GNUNET_CONVERSATION_call_start(), GNUNET_CONVERSATION_call_stop(), GNUNET_CONVERSATION_call_suspend(), handle_call_audio(), handle_call_hangup(), handle_call_picked_up(), handle_call_resume(), handle_call_suspend(), handle_gns_response(), iterate_local_members(), iterate_room_members(), and transmit_call_audio().
|
static |
Caller handle (for active incoming call).
This call handler is NOT in the cl_head / cl_tail list.
Definition at line 140 of file gnunet-conversation.c.
Referenced by do_accept(), do_reject(), do_resume(), do_status(), do_suspend(), and phone_event_handler().
|
static |
Head of calls waiting to be accepted.
Definition at line 145 of file gnunet-conversation.c.
Referenced by do_accept(), do_reject(), do_resume(), do_status(), and phone_event_handler().
|
static |
Tail of calls waiting to be accepted.
Definition at line 150 of file gnunet-conversation.c.
Referenced by do_accept(), do_reject(), do_status(), and phone_event_handler().
|
static |
Desired phone line (string to be converted to a hash).
Definition at line 155 of file gnunet-conversation.c.
Referenced by block_create2(), clean_up_channel(), client_connect_cb(), client_disconnect_cb(), database_setup(), do_status(), extract_dns_server(), extract_hosts(), extract_search_domain(), find_channel_by_line(), gns_resolve_name(), GNUNET_CONFIGURATION_deserialize(), GNUNET_CONVERSATION_phone_create(), GNUNET_get_log_call_status(), GNUNET_hex2b(), GNUNET_REGEX_ipv4policy2regex(), GNUNET_REGEX_ipv6policy2regex(), handle_cadet_hangup_message(), handle_cadet_pickup_message(), handle_cadet_resume_message(), handle_cadet_ring_message(), handle_cadet_suspend_message(), handle_client_audio_message(), handle_client_call_message(), handle_client_hangup_message(), handle_client_pickup_message(), handle_client_register_message(), handle_client_resume_message(), handle_client_suspend_message(), handle_collect_result(), identity_cb(), inbound_channel(), main(), parse_recordline(), parsehex(), process_map_output(), process_refresh_output(), process_unmap_output(), read_from_log(), store_and_free_entries(), trim(), try_ifconfig(), and try_ip().
|
static |
Task which handles the commands.
Definition at line 160 of file gnunet-conversation.c.
Referenced by do_stop_task(), handle_command(), and run().
|
static |
Our speaker.
Definition at line 165 of file gnunet-conversation.c.
Referenced by do_accept(), do_call(), do_resume(), do_stop_task(), and run().
|
static |
Our microphone.
Definition at line 170 of file gnunet-conversation.c.
Referenced by destroy(), disable(), do_accept(), do_call(), do_resume(), do_stop_task(), enable(), GNUNET_CONVERSATION_call_resume(), GNUNET_CONVERSATION_call_start(), GNUNET_CONVERSATION_caller_pick_up(), GNUNET_CONVERSATION_caller_resume(), GNUNET_MICROPHONE_create_from_hardware(), process_record_messages(), and run().
|
static |
Our configuration.
Definition at line 175 of file gnunet-conversation.c.
Referenced by do_call(), identity_cb(), main(), run(), and start_phone().
|
static |
Our ego.
Definition at line 180 of file gnunet-conversation.c.
Referenced by do_call(), identity_cb(), and start_phone().
|
static |
Handle to identity service.
Definition at line 185 of file gnunet-conversation.c.
|
static |
Name of our ego.
Definition at line 190 of file gnunet-conversation.c.
Referenced by do_call(), do_status(), do_stop_task(), identity_cb(), main(), run(), and start_phone().
|
static |
Public key of active conversation partner (if any).
Definition at line 195 of file gnunet-conversation.c.
Referenced by do_accept(), do_call(), do_resume(), and do_status().
|
static |
Name of active conversation partner (if any).
Definition at line 200 of file gnunet-conversation.c.
Referenced by call_event_handler(), do_call(), do_status(), and do_stop_task().
|
static |
File handle for stdin.
Definition at line 205 of file gnunet-conversation.c.
Referenced by handle_command(), and main().
|
static |
Our phone's current state.
Definition at line 210 of file gnunet-conversation.c.
Referenced by do_accept(), do_call(), do_reject(), do_resume(), do_status(), do_stop_task(), do_suspend(), phone_event_handler(), and start_phone().
|
static |
Our call's current state.
Definition at line 215 of file gnunet-conversation.c.
Referenced by call_event_handler(), do_accept(), do_call(), do_resume(), do_status(), and do_suspend().
|
static |
Counts the number of incoming calls we have had so far.
Definition at line 220 of file gnunet-conversation.c.
Referenced by phone_event_handler().
|
static |
GNS address for this phone.
Definition at line 225 of file gnunet-conversation.c.
Referenced by address_cb(), allocation_cb(), check_address(), connect_peers_run(), create_address_entry(), create_channel_to_destination(), create_receiver(), do_address(), find_queue(), GDS_u_try_connect(), get_address_without_port(), get_destination_key_from_ip(), GNUNET_get_udp_socket(), GNUNET_HELLO_address_to_prefix(), GNUNET_HELLO_builder_add_address(), GNUNET_HELLO_builder_del_address(), GNUNET_HELLO_sign_address(), GNUNET_NETWORK_socket_accept(), GNUNET_NETWORK_socket_bind(), GNUNET_NETWORK_socket_connect(), GNUNET_TRANSPORT_communicator_address_add(), GNUNET_TRANSPORT_communicator_mq_add(), GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue(), gnunet_try_connect(), handle_add_address(), hello_for_client_cb(), hello_for_incoming_cb(), ip_try_connect(), main(), make_up_icmpv4_payload(), make_up_icmpv6_payload(), mq_init(), notify_monitor(), notify_monitors(), parser_add_address(), process_peer_iteration_cb(), process_peer_monitoring_cb(), process_peer_string(), read_send(), resolve_peer_address(), set_address4(), set_address6(), setup_sender(), sock_read(), sockaddr_to_udpaddr_string(), start_address_validation(), start_phone(), suggest_to_connect(), u_address_add(), udp_socket_notify(), and vpn_allocation_callback().
|
static |
|
static |
List of supported commands.
Definition at line 935 of file gnunet-conversation.c.
Referenced by do_help(), GNUNET_TESTING_main(), GNUNET_TESTING_make_plugin(), GNUNET_TESTING_run(), handle_command_string(), handle_helper_init(), main(), setup_is(), and start_testcase().