From 3db0825fdc964032a7c6ee17ccb7dedbbcfb208b Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 27 Jan 2019 01:07:58 +0100 Subject: [PATCH] more work on #5385 --- src/cadet/Makefile.am | 1 + src/cadet/cadet_api_get_channel.c | 16 ++++++------ src/cadet/cadet_api_get_peer.c | 2 +- src/cadet/cadet_api_list_peers.c | 5 +++- src/include/gnunet_cadet_service.h | 40 +++++++++++++++++++----------- 5 files changed, 40 insertions(+), 24 deletions(-) diff --git a/src/cadet/Makefile.am b/src/cadet/Makefile.am index 62eaad38c..57a716f29 100644 --- a/src/cadet/Makefile.am +++ b/src/cadet/Makefile.am @@ -35,6 +35,7 @@ lib_LTLIBRARIES = \ libgnunetcadet_la_SOURCES = \ cadet_api.c \ cadet_api_get_peer.c \ + cadet_api_get_tunnel.c \ cadet_api_list_peers.c \ cadet_api_helper.c libgnunetcadet_la_LIBADD = \ diff --git a/src/cadet/cadet_api_get_channel.c b/src/cadet/cadet_api_get_channel.c index d41337522..1249777c2 100644 --- a/src/cadet/cadet_api_get_channel.c +++ b/src/cadet/cadet_api_get_channel.c @@ -121,17 +121,20 @@ reconnect (void *cls) { struct GNUNET_CADET_ChannelMonitor *cm = cls; struct GNUNET_MQ_MessageHandler *handlers[] = { - FIXME - } + FIXME, + GNUNET_MQ_handler_end () + }; struct GNUNET_MessageHeader *msg; struct GNUNET_MQ_Envelope *env; - + + cm->reconnect_task = NULL; cm->mq = GNUNET_CLIENT_connect (cm->cfg, "cadet", handlers, &error_handler, cm); - + if (NULL == cm->mq) + return; env = GNUNET_MQ_msg (msg, type); GNUNET_MQ_send (cm->mq, @@ -142,13 +145,12 @@ reconnect (void *cls) /** * Request information about a specific channel of the running cadet peer. * - * WARNING: unstable API, likely to change in the future! - * - * @param h Handle to the cadet peer. + * @param cfg configuration to use * @param peer ID of the other end of the channel. * @param channel_number Channel number. * @param callback Function to call with the requested data. * @param callback_cls Closure for @c callback. + * @return NULL on error */ struct GNUNET_CADET_ChannelMonitor * GNUNET_CADET_get_channel (const struct GNUNET_CONFIGURATION_Handle *cfg, diff --git a/src/cadet/cadet_api_get_peer.c b/src/cadet/cadet_api_get_peer.c index e86c1567c..bfac8d583 100644 --- a/src/cadet/cadet_api_get_peer.c +++ b/src/cadet/cadet_api_get_peer.c @@ -227,7 +227,7 @@ reconnect (void *cls) * Request information about a peer known to the running cadet peer. * The callback will be called for the tunnel once. * - * @param h Handle to the cadet peer. + * @param cfg configuration to use * @param id Peer whose tunnel to examine. * @param callback Function to call with the requested data. * @param callback_cls Closure for @c callback. diff --git a/src/cadet/cadet_api_list_peers.c b/src/cadet/cadet_api_list_peers.c index d53bcf65d..cc6948a36 100644 --- a/src/cadet/cadet_api_list_peers.c +++ b/src/cadet/cadet_api_list_peers.c @@ -177,11 +177,14 @@ reconnect (void *cls) struct GNUNET_MessageHeader *msg; struct GNUNET_MQ_Envelope *env; + pl->reconnect_task = NULL; pl->mq = GNUNET_CLIENT_connect (pl->cfg, "cadet", handlers, &error_handler, pl); + if (NULL == pl->mq) + return; env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS); GNUNET_MQ_send (pl->mq, @@ -194,7 +197,7 @@ reconnect (void *cls) * The callback will be called for every peer known to the service. * Only one info request (of any kind) can be active at once. * - * @param h Handle to the cadet peer. + * @param cfg configuration to use * @param callback Function to call with the requested data. * @param callback_cls Closure for @c callback. * @return NULL on error diff --git a/src/include/gnunet_cadet_service.h b/src/include/gnunet_cadet_service.h index 2ac98e621..3ff8cf59c 100644 --- a/src/include/gnunet_cadet_service.h +++ b/src/include/gnunet_cadet_service.h @@ -389,15 +389,16 @@ typedef void uint32_t /* ugh */ public_channel_number); +/** + * Operation handle. + */ struct GNUNET_CADET_ChannelMonitor; /** * Request information about a specific channel of the running cadet peer. * - * WARNING: unstable API, likely to change in the future! - * - * @param h Handle to the cadet peer. + * @param cfg configuration to use * @param peer ID of the other end of the channel. * @param channel_number Channel number. * @param callback Function to call with the requested data. @@ -442,6 +443,9 @@ typedef void unsigned int best_path); +/** + * Operation handle. + */ struct GNUNET_CADET_PeersLister; @@ -450,7 +454,7 @@ struct GNUNET_CADET_PeersLister; * The callback will be called for every peer known to the service. * Only one info request (of any kind) can be active at once. * - * @param h Handle to the cadet peer. + * @param cfg configuration to use * @param callback Function to call with the requested data. * @param callback_cls Closure for @c callback. * @return NULL on error @@ -500,12 +504,13 @@ typedef void */ struct GNUNET_CADET_GetPeer; + /** * Request information about a peer known to the running cadet peer. * The callback will be called for the tunnel once. * Only one info request (of any kind) can be active at once. * - * @param h Handle to the cadet peer. + * @param cfg configuration to use * @param id Peer whose tunnel to examine. * @param callback Function to call with the requested data. * @param callback_cls Closure for @c callback. @@ -550,6 +555,9 @@ typedef void uint16_t cstate); +/** + * Operation handle. + */ struct GNUNET_CADET_ListTunnels; @@ -558,12 +566,9 @@ struct GNUNET_CADET_ListTunnels; * The callback will be called for every tunnel of the service. * Only one info request (of any kind) can be active at once. * - * WARNING: unstable API, likely to change in the future! - * - * @param h Handle to the cadet peer. + * @param cfg configuration to use * @param callback Function to call with the requested data. * @param callback_cls Closure for @c callback. - * * @return #GNUNET_OK / #GNUNET_SYSERR */ struct GNUNET_CADET_ListTunnels * @@ -575,8 +580,7 @@ GNUNET_CADET_list_tunnels (const struct GNUNET_CONFIGURATION_Handle *cfg, /** * Cancel a monitor request. The monitor callback will not be called. * - * @param h Cadet handle. - * + * @param lt operation handle * @return Closure given to #GNUNET_CADET_list_tunnels(), if any. */ void * @@ -608,6 +612,9 @@ typedef void unsigned int cstate); +/** + * Operation handle. + */ struct GNUNET_CADET_GetTunnel; @@ -616,13 +623,10 @@ struct GNUNET_CADET_GetTunnel; * The callback will be called for the tunnel once. * Only one info request (of any kind) can be active at once. * - * WARNING: unstable API, likely to change in the future! - * - * @param h Handle to the cadet peer. + * @param cfg configuration to use * @param id Peer whose tunnel to examine. * @param callback Function to call with the requested data. * @param callback_cls Closure for @c callback. - * * @return #GNUNET_OK / #GNUNET_SYSERR */ struct GNUNET_CADET_GetTunnel * @@ -632,6 +636,12 @@ GNUNET_CADET_get_tunnel (const struct GNUNET_CONFIGURATION_Handle *cfg, void *callback_cls); +/** + * Cancel a monitor request. The monitor callback will not be called. + * + * @param lt operation handle + * @return Closure given to #GNUNET_CADET_get_tunnel(), if any. + */ void * GNUNET_CADET_get_tunnel_cancel (struct GNUNET_CADET_GetTunnel *gt); -- 2.25.1