aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/gnunet_mq_lib.h4
-rw-r--r--src/include/gnunet_transport_address_service.h15
-rw-r--r--src/include/gnunet_transport_application_service.h28
-rw-r--r--src/include/gnunet_transport_hello_service.h29
-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
7 files changed, 90 insertions, 63 deletions
diff --git a/src/include/gnunet_mq_lib.h b/src/include/gnunet_mq_lib.h
index 4fe5c8df9..81100d7d8 100644
--- a/src/include/gnunet_mq_lib.h
+++ b/src/include/gnunet_mq_lib.h
@@ -1043,6 +1043,8 @@ GNUNET_MQ_impl_current (struct GNUNET_MQ_Handle *mq);
1043 1043
1044/** 1044/**
1045 * Enum defining all known preference categories. 1045 * Enum defining all known preference categories.
1046 *
1047 * @deprecated will be replaced by `enum GNUNET_MQ_PriorityPreference`
1046 */ 1048 */
1047enum GNUNET_MQ_PreferenceKind 1049enum GNUNET_MQ_PreferenceKind
1048{ 1050{
@@ -1083,6 +1085,8 @@ enum GNUNET_MQ_PreferenceKind
1083 * 1085 *
1084 * @param type the preference type 1086 * @param type the preference type
1085 * @return a string or NULL if invalid 1087 * @return a string or NULL if invalid
1088 *
1089 * @deprecated will be replaced by `enum GNUNET_MQ_PriorityPreference`
1086 */ 1090 */
1087const char * 1091const char *
1088GNUNET_MQ_preference_to_string (enum GNUNET_MQ_PreferenceKind type); 1092GNUNET_MQ_preference_to_string (enum GNUNET_MQ_PreferenceKind type);
diff --git a/src/include/gnunet_transport_address_service.h b/src/include/gnunet_transport_address_service.h
index 9f0717d00..b33a11411 100644
--- a/src/include/gnunet_transport_address_service.h
+++ b/src/include/gnunet_transport_address_service.h
@@ -21,6 +21,9 @@
21/** 21/**
22 * @author Christian Grothoff 22 * @author Christian Grothoff
23 * 23 *
24 * @deprecated NOTE: we may want to drop this API and
25 * only keep the gnunet_transport_application_service.h in the future!
26 *
24 * @file 27 * @file
25 * Provide addresses to transport for validation 28 * Provide addresses to transport for validation
26 * 29 *
@@ -36,9 +39,8 @@
36#define GNUNET_TRANSPORT_ADDRESS_SERVICE_H 39#define GNUNET_TRANSPORT_ADDRESS_SERVICE_H
37 40
38#ifdef __cplusplus 41#ifdef __cplusplus
39extern "C" 42extern "C" {
40{ 43#if 0 /* keep Emacsens' auto-indent happy */
41#if 0 /* keep Emacsens' auto-indent happy */
42} 44}
43#endif 45#endif
44#endif 46#endif
@@ -65,7 +67,8 @@ struct GNUNET_TRANSPORT_AddressHandle;
65 * @return NULL on error 67 * @return NULL on error
66 */ 68 */
67struct GNUNET_TRANSPORT_AddressHandle * 69struct GNUNET_TRANSPORT_AddressHandle *
68GNUNET_TRANSPORT_address_connect (const struct GNUNET_CONFIGURATION_Handle *cfg); 70GNUNET_TRANSPORT_address_connect (
71 const struct GNUNET_CONFIGURATION_Handle *cfg);
69 72
70 73
71/** 74/**
@@ -101,7 +104,7 @@ GNUNET_TRANSPORT_address_try (struct GNUNET_TRANSPORT_AddressHandle *ch,
101 const size_t raw_size); 104 const size_t raw_size);
102 105
103 106
104#if 0 /* keep Emacsens' auto-indent happy */ 107#if 0 /* keep Emacsens' auto-indent happy */
105{ 108{
106#endif 109#endif
107#ifdef __cplusplus 110#ifdef __cplusplus
@@ -111,6 +114,6 @@ GNUNET_TRANSPORT_address_try (struct GNUNET_TRANSPORT_AddressHandle *ch,
111/* ifndef GNUNET_TRANSPORT_ADDRESS_SERVICE_H */ 114/* ifndef GNUNET_TRANSPORT_ADDRESS_SERVICE_H */
112#endif 115#endif
113 116
114/** @} */ /* end of group */ 117/** @} */ /* end of group */
115 118
116/* end of gnunet_transport_address_service.h */ 119/* end of gnunet_transport_address_service.h */
diff --git a/src/include/gnunet_transport_application_service.h b/src/include/gnunet_transport_application_service.h
index 8c63a8234..c12bd7441 100644
--- a/src/include/gnunet_transport_application_service.h
+++ b/src/include/gnunet_transport_application_service.h
@@ -65,6 +65,34 @@ GNUNET_TRANSPORT_application_done (
65 65
66 66
67/** 67/**
68 * An application would like TRANSPORT to connect to a peer.
69 *
70 * @param ch handle
71 * @param peer identity of the peer we need an address for
72 * @param pk what kind of application will the application require (can be
73 * #GNUNET_MQ_PRIO_BACKGROUND, we will still try to connect)
74 * @param bw desired bandwith, can be zero (we will still try to connect)
75 * @return suggest handle, NULL if a request is already pending
76 */
77struct GNUNET_TRANSPORT_ApplicationSuggestHandle *
78GNUNET_TRANSPORT_application_suggest (
79 struct GNUNET_TRANSPORT_ApplicationHandle *ch,
80 const struct GNUNET_PeerIdentity *peer,
81 enum GNUNET_MQ_PriorityPreferences pk,
82 struct GNUNET_BANDWIDTH_Value32NBO bw);
83
84
85/**
86 * We no longer care about being connected to a peer.
87 *
88 * @param sh handle to stop
89 */
90void
91GNUNET_TRANSPORT_application_suggest_cancel (
92 struct GNUNET_TRANSPORT_ApplicationSuggestHandle *sh);
93
94
95/**
68 * An application (or a communicator) has received a HELLO (or other address 96 * An application (or a communicator) has received a HELLO (or other address
69 * data of another peer) and wants TRANSPORT to validate that the address is 97 * data of another peer) and wants TRANSPORT to validate that the address is
70 * correct. The result is NOT returned, in fact TRANSPORT may do nothing 98 * correct. The result is NOT returned, in fact TRANSPORT may do nothing
diff --git a/src/include/gnunet_transport_hello_service.h b/src/include/gnunet_transport_hello_service.h
index 58a1e9979..fe863c058 100644
--- a/src/include/gnunet_transport_hello_service.h
+++ b/src/include/gnunet_transport_hello_service.h
@@ -24,6 +24,8 @@
24 * @file 24 * @file
25 * obtain information about our current address 25 * obtain information about our current address
26 * 26 *
27 * @deprecated, in TNG applications should query PEERSTORE directly!
28 *
27 * @defgroup transport Transport service 29 * @defgroup transport Transport service
28 * address information 30 * address information
29 * 31 *
@@ -35,9 +37,8 @@
35#define GNUNET_TRANSPORT_HELLO_SERVICE_H 37#define GNUNET_TRANSPORT_HELLO_SERVICE_H
36 38
37#ifdef __cplusplus 39#ifdef __cplusplus
38extern "C" 40extern "C" {
39{ 41#if 0 /* keep Emacsens' auto-indent happy */
40#if 0 /* keep Emacsens' auto-indent happy */
41} 42}
42#endif 43#endif
43#endif 44#endif
@@ -118,9 +119,9 @@ enum GNUNET_TRANSPORT_AddressClass
118 * @param cls closure 119 * @param cls closure
119 * @param hello our updated HELLO 120 * @param hello our updated HELLO
120 */ 121 */
121typedef void 122typedef void (*GNUNET_TRANSPORT_HelloUpdateCallback) (
122(*GNUNET_TRANSPORT_HelloUpdateCallback) (void *cls, 123 void *cls,
123 const struct GNUNET_MessageHeader *hello); 124 const struct GNUNET_MessageHeader *hello);
124 125
125 126
126/** 127/**
@@ -164,12 +165,12 @@ GNUNET_TRANSPORT_hello_get_cancel (struct GNUNET_TRANSPORT_HelloGetHandle *ghh);
164 * @param nt network type of the address 165 * @param nt network type of the address
165 * @param expiration when does this address expire? 166 * @param expiration when does this address expire?
166 */ 167 */
167typedef void 168typedef void (*GNUNET_TRANSPORT_AddressCallback) (
168(*GNUNET_TRANSPORT_AddressCallback) (void *cls, 169 void *cls,
169 const struct GNUNET_PeerIdentity *peer, 170 const struct GNUNET_PeerIdentity *peer,
170 const char *address, 171 const char *address,
171 enum GNUNET_NetworkType nt, 172 enum GNUNET_NetworkType nt,
172 struct GNUNET_TIME_Absolute expiration); 173 struct GNUNET_TIME_Absolute expiration);
173 174
174 175
175/** 176/**
@@ -187,7 +188,7 @@ GNUNET_TRANSPORT_hello_parse (const struct GNUNET_MessageHeader *hello,
187 void *cb_cls); 188 void *cb_cls);
188 189
189 190
190#if 0 /* keep Emacsens' auto-indent happy */ 191#if 0 /* keep Emacsens' auto-indent happy */
191{ 192{
192#endif 193#endif
193#ifdef __cplusplus 194#ifdef __cplusplus
@@ -197,6 +198,6 @@ GNUNET_TRANSPORT_hello_parse (const struct GNUNET_MessageHeader *hello,
197/* ifndef GNUNET_TRANSPORT_HELLO_SERVICE_H */ 198/* ifndef GNUNET_TRANSPORT_HELLO_SERVICE_H */
198#endif 199#endif
199 200
200/** @} */ /* end of group */ 201/** @} */ /* end of group */
201 202
202/* end of gnunet_transport_hello_service.h */ 203/* end of gnunet_transport_hello_service.h */
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;