aboutsummaryrefslogtreecommitdiff
path: root/src/cadet/cadet_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cadet/cadet_api.c')
-rw-r--r--src/cadet/cadet_api.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/cadet/cadet_api.c b/src/cadet/cadet_api.c
index 68bd4c290..3a75266b7 100644
--- a/src/cadet/cadet_api.c
+++ b/src/cadet/cadet_api.c
@@ -995,6 +995,32 @@ GNUNET_CADET_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
995 995
996 996
997/** 997/**
998 * Function to return link to AGPL source upon request.
999 *
1000 * @param cls closure with the identification of the client
1001 * @param msg AGPL request
1002 */
1003static void
1004return_agpl (void *cls, const struct GNUNET_MessageHeader *msg)
1005{
1006 struct GNUNET_SERVICE_Client *client = cls;
1007 struct GNUNET_MQ_Handle *mq;
1008 struct GNUNET_MQ_Envelope *env;
1009 struct GNUNET_MessageHeader *res;
1010 size_t slen;
1011 const struct GNUNET_OS_ProjectData *pd = GNUNET_OS_project_data_get ();
1012
1013 (void) msg;
1014 slen = strlen (pd->agpl_url) + 1;
1015 env = GNUNET_MQ_msg_extra (res, GNUNET_MESSAGE_TYPE_RESPONSE_AGPL, slen);
1016 memcpy (&res[1], GNUNET_AGPL_URL, slen);
1017 mq = GNUNET_SERVICE_client_get_mq (client);
1018 GNUNET_MQ_send (mq, env);
1019 GNUNET_SERVICE_client_continue (client);
1020}
1021
1022
1023/**
998 * Open a port to receive incomming MQ-based channels. 1024 * Open a port to receive incomming MQ-based channels.
999 * 1025 *
1000 * @param h CADET handle. 1026 * @param h CADET handle.
@@ -1016,6 +1042,7 @@ GNUNET_CADET_open_port (struct GNUNET_CADET_Handle *h,
1016 const struct GNUNET_MQ_MessageHandler *handlers) 1042 const struct GNUNET_MQ_MessageHandler *handlers)
1017{ 1043{
1018 struct GNUNET_CADET_Port *p; 1044 struct GNUNET_CADET_Port *p;
1045 const struct GNUNET_OS_ProjectData *pd = GNUNET_OS_project_data_get ();
1019 1046
1020 GNUNET_assert (NULL != connects); 1047 GNUNET_assert (NULL != connects);
1021 GNUNET_assert (NULL != disconnects); 1048 GNUNET_assert (NULL != disconnects);
@@ -1039,7 +1066,9 @@ GNUNET_CADET_open_port (struct GNUNET_CADET_Handle *h,
1039 p->cls = connects_cls; 1066 p->cls = connects_cls;
1040 p->window_changes = window_changes; 1067 p->window_changes = window_changes;
1041 p->disconnects = disconnects; 1068 p->disconnects = disconnects;
1042 p->handlers = GNUNET_MQ_copy_handlers (handlers); 1069 p->handlers = (NULL == pd->agpl_url)
1070 ? GNUNET_MQ_copy_handlers (handlers)
1071 : GNUNET_MQ_copy_handlers2 (handlers, &return_agpl, NULL);
1043 1072
1044 GNUNET_assert (GNUNET_OK == open_port_cb (h, &p->id, p)); 1073 GNUNET_assert (GNUNET_OK == open_port_cb (h, &p->id, p));
1045 return p; 1074 return p;