aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-05-05 14:02:24 +0200
committerChristian Grothoff <christian@grothoff.org>2019-05-05 14:02:24 +0200
commite94c5914935ca0842ca762d343cb167c68b8a79a (patch)
tree4719d48bbcd9be334854d0ed88ba76f5b259b296 /src/transport
parentb84057d7593651e16a161de9f2ec51f93c98589d (diff)
downloadgnunet-e94c5914935ca0842ca762d343cb167c68b8a79a.tar.gz
gnunet-e94c5914935ca0842ca762d343cb167c68b8a79a.zip
use new PriorityPreferences consistently, note on deprecation
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-service-tng.c14
-rw-r--r--src/transport/transport_api2_address.c52
-rw-r--r--src/transport/transport_api2_application.c11
3 files changed, 34 insertions, 43 deletions
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c
index 443c7f245..ab9159963 100644
--- a/src/transport/gnunet-service-tng.c
+++ b/src/transport/gnunet-service-tng.c
@@ -1757,8 +1757,10 @@ struct PeerRequest
1757 1757
1758 /** 1758 /**
1759 * What kind of performance preference does this @e tc have? 1759 * What kind of performance preference does this @e tc have?
1760 *
1761 * TODO: use this!
1760 */ 1762 */
1761 enum GNUNET_MQ_PreferenceKind pk; 1763 enum GNUNET_MQ_PriorityPreferences pk;
1762 1764
1763 /** 1765 /**
1764 * How much bandwidth would this @e tc like to see? 1766 * How much bandwidth would this @e tc like to see?
@@ -1953,6 +1955,12 @@ struct PendingMessage
1953 enum PendingMessageType pmt; 1955 enum PendingMessageType pmt;
1954 1956
1955 /** 1957 /**
1958 * Preferences for this message.
1959 * TODO: actually use this!
1960 */
1961 enum GNUNET_MQ_PriorityPreferences prefs;
1962
1963 /**
1956 * Size of the original message. 1964 * Size of the original message.
1957 */ 1965 */
1958 uint16_t bytes_msg; 1966 uint16_t bytes_msg;
@@ -3736,7 +3744,6 @@ handle_client_send (void *cls, const struct OutboundMessage *obm)
3736 obmm = (const struct GNUNET_MessageHeader *) &obm[1]; 3744 obmm = (const struct GNUNET_MessageHeader *) &obm[1];
3737 bytes_msg = ntohs (obmm->size); 3745 bytes_msg = ntohs (obmm->size);
3738 pp = (enum GNUNET_MQ_PriorityPreferences) ntohl (obm->priority); 3746 pp = (enum GNUNET_MQ_PriorityPreferences) ntohl (obm->priority);
3739 /* FIXME: actually make use of pp */ (void) pp;
3740 vl = GNUNET_CONTAINER_multipeermap_get (links, &obm->peer); 3747 vl = GNUNET_CONTAINER_multipeermap_get (links, &obm->peer);
3741 if (NULL == vl) 3748 if (NULL == vl)
3742 { 3749 {
@@ -3790,6 +3797,7 @@ handle_client_send (void *cls, const struct OutboundMessage *obm)
3790 3797
3791 was_empty = (NULL == target->pending_msg_head); 3798 was_empty = (NULL == target->pending_msg_head);
3792 pm = GNUNET_malloc (sizeof (struct PendingMessage) + payload_size); 3799 pm = GNUNET_malloc (sizeof (struct PendingMessage) + payload_size);
3800 pm->prefs = pp;
3793 pm->client = tc; 3801 pm->client = tc;
3794 pm->target = target; 3802 pm->target = target;
3795 pm->bytes_msg = payload_size; 3803 pm->bytes_msg = payload_size;
@@ -8559,7 +8567,7 @@ handle_suggest (void *cls, const struct ExpressPreferenceMessage *msg)
8559 pr->tc = tc; 8567 pr->tc = tc;
8560 pr->pid = msg->peer; 8568 pr->pid = msg->peer;
8561 pr->bw = msg->bw; 8569 pr->bw = msg->bw;
8562 pr->pk = (enum GNUNET_MQ_PreferenceKind) ntohl (msg->pk); 8570 pr->pk = (enum GNUNET_MQ_PriorityPreferences) ntohl (msg->pk);
8563 if (GNUNET_YES != GNUNET_CONTAINER_multipeermap_put ( 8571 if (GNUNET_YES != GNUNET_CONTAINER_multipeermap_put (
8564 tc->details.application.requests, 8572 tc->details.application.requests,
8565 &pr->pid, 8573 &pr->pid,
diff --git a/src/transport/transport_api2_address.c b/src/transport/transport_api2_address.c
index 1ff599efb..d2cab27d5 100644
--- a/src/transport/transport_api2_address.c
+++ b/src/transport/transport_api2_address.c
@@ -31,7 +31,8 @@
31#include "gnunet_ats_transport_service.h" 31#include "gnunet_ats_transport_service.h"
32#include "transport.h" 32#include "transport.h"
33 33
34#define LOG(kind,...) GNUNET_log_from (kind, "transport-api-address",__VA_ARGS__) 34#define LOG(kind, ...) \
35 GNUNET_log_from (kind, "transport-api-address", __VA_ARGS__)
35 36
36 37
37/** 38/**
@@ -60,7 +61,6 @@ struct GNUNET_TRANSPORT_AddressHandle
60 * Delay until we try to reconnect. 61 * Delay until we try to reconnect.
61 */ 62 */
62 struct GNUNET_TIME_Relative reconnect_delay; 63 struct GNUNET_TIME_Relative reconnect_delay;
63
64}; 64};
65 65
66 66
@@ -84,8 +84,7 @@ disconnect_and_schedule_reconnect (struct GNUNET_TRANSPORT_AddressHandle *h);
84 * @param error error code 84 * @param error error code
85 */ 85 */
86static void 86static void
87mq_error_handler (void *cls, 87mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
88 enum GNUNET_MQ_Error error)
89{ 88{
90 struct GNUNET_TRANSPORT_AddressHandle *h = cls; 89 struct GNUNET_TRANSPORT_AddressHandle *h = cls;
91 90
@@ -104,19 +103,13 @@ static void
104reconnect (void *cls) 103reconnect (void *cls)
105{ 104{
106 struct GNUNET_TRANSPORT_AddressHandle *h = cls; 105 struct GNUNET_TRANSPORT_AddressHandle *h = cls;
107 struct GNUNET_MQ_MessageHandler handlers[] = { 106 struct GNUNET_MQ_MessageHandler handlers[] = {GNUNET_MQ_handler_end ()};
108 GNUNET_MQ_handler_end ()
109 };
110 107
111 h->reconnect_task = NULL; 108 h->reconnect_task = NULL;
112 LOG (GNUNET_ERROR_TYPE_DEBUG, 109 LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to transport service.\n");
113 "Connecting to transport service.\n");
114 GNUNET_assert (NULL == h->mq); 110 GNUNET_assert (NULL == h->mq);
115 h->mq = GNUNET_CLIENT_connect (h->cfg, 111 h->mq =
116 "transport", 112 GNUNET_CLIENT_connect (h->cfg, "transport", handlers, &mq_error_handler, h);
117 handlers,
118 &mq_error_handler,
119 h);
120} 113}
121 114
122 115
@@ -149,12 +142,9 @@ disconnect_and_schedule_reconnect (struct GNUNET_TRANSPORT_AddressHandle *h)
149 disconnect (h); 142 disconnect (h);
150 LOG (GNUNET_ERROR_TYPE_DEBUG, 143 LOG (GNUNET_ERROR_TYPE_DEBUG,
151 "Scheduling task to reconnect to transport service in %s.\n", 144 "Scheduling task to reconnect to transport service in %s.\n",
152 GNUNET_STRINGS_relative_time_to_string (h->reconnect_delay, 145 GNUNET_STRINGS_relative_time_to_string (h->reconnect_delay, GNUNET_YES));
153 GNUNET_YES));
154 h->reconnect_task = 146 h->reconnect_task =
155 GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, 147 GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h);
156 &reconnect,
157 h);
158 h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay); 148 h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay);
159} 149}
160 150
@@ -173,8 +163,7 @@ GNUNET_TRANSPORT_address_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
173 h = GNUNET_new (struct GNUNET_TRANSPORT_AddressHandle); 163 h = GNUNET_new (struct GNUNET_TRANSPORT_AddressHandle);
174 h->cfg = cfg; 164 h->cfg = cfg;
175 h->reconnect_delay = GNUNET_TIME_UNIT_ZERO; 165 h->reconnect_delay = GNUNET_TIME_UNIT_ZERO;
176 LOG (GNUNET_ERROR_TYPE_DEBUG, 166 LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to transport service\n");
177 "Connecting to transport service\n");
178 reconnect (h); 167 reconnect (h);
179 if (NULL == h->mq) 168 if (NULL == h->mq)
180 { 169 {
@@ -191,10 +180,10 @@ GNUNET_TRANSPORT_address_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
191 * @param handle handle to the service as returned from #GNUNET_TRANSPORT_address_connect() 180 * @param handle handle to the service as returned from #GNUNET_TRANSPORT_address_connect()
192 */ 181 */
193void 182void
194GNUNET_TRANSPORT_address_disconnect (struct GNUNET_TRANSPORT_AddressHandle *handle) 183GNUNET_TRANSPORT_address_disconnect (
184 struct GNUNET_TRANSPORT_AddressHandle *handle)
195{ 185{
196 LOG (GNUNET_ERROR_TYPE_DEBUG, 186 LOG (GNUNET_ERROR_TYPE_DEBUG, "Transport disconnect called!\n");
197 "Transport disconnect called!\n");
198 /* this disconnects all neighbours... */ 187 /* this disconnects all neighbours... */
199 disconnect (handle); 188 disconnect (handle);
200 /* and now we stop trying to connect again... */ 189 /* and now we stop trying to connect again... */
@@ -233,17 +222,14 @@ GNUNET_TRANSPORT_address_try (struct GNUNET_TRANSPORT_AddressHandle *ch,
233 struct GNUNET_MQ_Envelope *env; 222 struct GNUNET_MQ_Envelope *env;
234 struct GNUNET_TRANSPORT_AddressToVerify *hdr; 223 struct GNUNET_TRANSPORT_AddressToVerify *hdr;
235 224
236 env = GNUNET_MQ_msg_extra (hdr, 225 env =
237 raw_size, 226 GNUNET_MQ_msg_extra (hdr,
238 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_CONSIDER_VERIFY); 227 raw_size,
228 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_CONSIDER_VERIFY);
239 hdr->peer = *pid; 229 hdr->peer = *pid;
240 memcpy (&hdr[1], 230 memcpy (&hdr[1], raw, raw_size);
241 raw, 231 GNUNET_MQ_send (ch->mq, env);
242 raw_size);
243 GNUNET_MQ_send (ch->mq,
244 env);
245} 232}
246 233
247 234
248
249/* end of transport_api2_address.c */ 235/* end of transport_api2_address.c */
diff --git a/src/transport/transport_api2_application.c b/src/transport/transport_api2_application.c
index 49f0f36c7..7d790d738 100644
--- a/src/transport/transport_api2_application.c
+++ b/src/transport/transport_api2_application.c
@@ -51,7 +51,7 @@ struct GNUNET_TRANSPORT_ApplicationSuggestHandle
51 /** 51 /**
52 * What preference is being expressed? 52 * What preference is being expressed?
53 */ 53 */
54 enum GNUNET_MQ_PreferenceKind pk; 54 enum GNUNET_MQ_PriorityPreferences pk;
55 55
56 /** 56 /**
57 * How much bandwidth does the client expect? 57 * How much bandwidth does the client expect?
@@ -277,15 +277,12 @@ GNUNET_TRANSPORT_application_done (
277 277
278 278
279/** 279/**
280 * We would like to receive address suggestions for a peer. TRANSPORT will 280 * An application would like TRANSPORT to connect to a peer.
281 * respond with a call to the continuation immediately containing an address or
282 * no address if none is available. TRANSPORT can suggest more addresses until we call
283 * #GNUNET_TRANSPORT_application_suggest_cancel().
284 * 281 *
285 * @param ch handle 282 * @param ch handle
286 * @param peer identity of the peer we need an address for 283 * @param peer identity of the peer we need an address for
287 * @param pk what kind of application will the application require (can be 284 * @param pk what kind of application will the application require (can be
288 * #GNUNET_MQ_PREFERENCE_NONE, we will still try to connect) 285 * #GNUNET_MQ_PRIO_BACKGROUND, we will still try to connect)
289 * @param bw desired bandwith, can be zero (we will still try to connect) 286 * @param bw desired bandwith, can be zero (we will still try to connect)
290 * @return suggest handle, NULL if a request is already pending 287 * @return suggest handle, NULL if a request is already pending
291 */ 288 */
@@ -293,7 +290,7 @@ struct GNUNET_TRANSPORT_ApplicationSuggestHandle *
293GNUNET_TRANSPORT_application_suggest ( 290GNUNET_TRANSPORT_application_suggest (
294 struct GNUNET_TRANSPORT_ApplicationHandle *ch, 291 struct GNUNET_TRANSPORT_ApplicationHandle *ch,
295 const struct GNUNET_PeerIdentity *peer, 292 const struct GNUNET_PeerIdentity *peer,
296 enum GNUNET_MQ_PreferenceKind pk, 293 enum GNUNET_MQ_PriorityPreferences pk,
297 struct GNUNET_BANDWIDTH_Value32NBO bw) 294 struct GNUNET_BANDWIDTH_Value32NBO bw)
298{ 295{
299 struct GNUNET_TRANSPORT_ApplicationSuggestHandle *s; 296 struct GNUNET_TRANSPORT_ApplicationSuggestHandle *s;