GNUnet  0.10.x
Functions
Client library

Generic client-side communication with services. More...

Functions

struct GNUNET_MQ_HandleGNUNET_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. More...
 

Detailed Description

Generic client-side communication with services.

See also
Documentation

Function Documentation

◆ GNUNET_CLIENT_connect()

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.

If handlers are specfied, receive messages from the connection.

Parameters
connectionthe client connection
handlershandlers for receiving messages, can be NULL
error_handlererror handler
error_handler_clsclosure for the error_handler
Returns
the message queue, NULL on error

If handlers are specfied, receive messages from the connection.

Parameters
cfgour configuration
service_namename of the service to connect to
handlershandlers for receiving messages, can be NULL
error_handlererror handler
error_handler_clsclosure for the error_handler
Returns
the message queue, NULL on error

Definition at line 900 of file client.c.

References _, cfg, ClientState::cfg, connection_client_cancel_impl(), connection_client_destroy_impl(), connection_client_send_impl(), AddressProbe::cstate, GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_have_value(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_MQ_queue_for_callbacks(), GNUNET_MST_create(), GNUNET_new, GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_strdup, GNUNET_YES, ClientState::hostname, LOG, ClientState::mq, ClientState::mst, ClientState::port, recv_message(), ClientState::retry_task, ClientState::service_name, start_connect(), and test_service_configuration().

Referenced by addr_cb(), announce_reconnect(), connect_task(), create_internal(), create_loc_uri(), do_connect(), do_peer_connect(), do_plugin_connect(), do_reconnect(), GNUNET_CONSENSUS_create(), GNUNET_CONVERSATION_call_start(), GNUNET_DATASTORE_disconnect(), GNUNET_FS_get_indexed_files(), GNUNET_IDENTITY_ego_lookup(), GNUNET_IDENTITY_ego_lookup_by_suffix(), GNUNET_NAT_AUTO_autoconfig_start(), GNUNET_REVOCATION_query(), GNUNET_REVOCATION_revoke(), GNUNET_SCALARPRODUCT_accept_computation(), GNUNET_SCALARPRODUCT_start_computation(), GNUNET_SECRETSHARING_create_session(), GNUNET_SECRETSHARING_decrypt(), GNUNET_TESTBED_barrier_wait(), GNUNET_TESTBED_controller_connect(), GNUNET_TESTBED_LOGGER_connect(), GNUNET_TRANSPORT_address_to_string(), GNUNET_TRANSPORT_offer_hello(), hash_for_index_cb(), listen_connect(), reconnect(), reconnect_arm(), reconnect_arm_monitor(), reconnect_phone(), reconnect_task(), search_reconnect(), test_nat_punched(), try_connect(), try_reconnect(), and unindex_finish().

905 {
906  struct ClientState *cstate;
907 
908  if (GNUNET_OK !=
910  cfg))
911  return NULL;
912  cstate = GNUNET_new(struct ClientState);
914  cstate->cfg = cfg;
916  cstate);
918  cstate);
919  if (GNUNET_YES ==
921  service_name,
922  "PORT"))
923  {
924  if (!((GNUNET_OK !=
926  service_name,
927  "PORT",
928  &cstate->port)) ||
929  (cstate->port > 65535) ||
930  (GNUNET_OK !=
932  service_name,
933  "HOSTNAME",
934  &cstate->hostname))) &&
935  (0 == strlen(cstate->hostname)))
936  {
937  GNUNET_free(cstate->hostname);
938  cstate->hostname = NULL;
940  _("Need a non-empty hostname for service `%s'.\n"),
941  service_name);
942  }
943  }
947  cstate,
948  handlers,
950  error_handler_cls);
951  return cstate->mq;
952 }
static void error_handler(void *cls, enum GNUNET_MQ_Error error)
We encountered an error handling the MQ to the ATS service.
State we keep per client.
int GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
struct GNUNET_MQ_Handle * mq
MQ to talk to client.
#define LOG(kind,...)
Definition: client.c:36
static void connection_client_cancel_impl(struct GNUNET_MQ_Handle *mq, void *impl_state)
Cancel the currently sent message.
Definition: client.c:871
static void connection_client_destroy_impl(struct GNUNET_MQ_Handle *mq, void *impl_state)
Implement the destruction of a message queue.
Definition: client.c:373
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: client.c:113
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
char * service_name
Name of the service we interact with.
Definition: client.c:130
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
struct GNUNET_MQ_Handle * GNUNET_MQ_queue_for_callbacks(GNUNET_MQ_SendImpl send, GNUNET_MQ_DestroyImpl destroy, GNUNET_MQ_CancelImpl cancel, void *impl_state, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *cls)
Create a message queue for the specified handlers.
Definition: mq.c:550
static int recv_message(void *cls, const struct GNUNET_MessageHeader *msg)
We have received a full message, pass to the MQ dispatcher.
Definition: client.c:322
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1264
int GNUNET_CONFIGURATION_have_value(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Test if we have a value for a particular option.
static void start_connect(void *cls)
Try to connect to the service.
Definition: client.c:783
static char * service_name
Option -s: service name (hash to get service descriptor)
Definition: gnunet-vpn.c:51
struct GNUNET_MessageStreamTokenizer * GNUNET_MST_create(GNUNET_MessageTokenizerCallback cb, void *cb_cls)
Create a message stream tokenizer.
Definition: mst.c:84
int 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.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
struct GNUNET_MessageStreamTokenizer * mst
Tokenizer for inbound messages.
Definition: client.c:160
static int test_service_configuration(const char *service_name, const struct GNUNET_CONFIGURATION_Handle *cfg)
Test whether the configuration has proper values for connection (UNIXPATH || (PORT && HOSTNAME))...
Definition: client.c:723
unsigned long long port
TCP port (0 for disabled).
Definition: client.c:181
char * hostname
Hostname, if any.
Definition: client.c:135
struct GNUNET_SCHEDULER_Task * retry_task
Task for trying to connect to the service.
Definition: client.c:145
#define GNUNET_YES
Definition: gnunet_common.h:77
static void connection_client_send_impl(struct GNUNET_MQ_Handle *mq, const struct GNUNET_MessageHeader *msg, void *impl_state)
Implements the transmission functionality of a message queue.
Definition: client.c:837
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function: