diff options
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/gnunet-communicator-unix.c | 44 | ||||
-rw-r--r-- | src/transport/gnunet-service-tng.c | 16 | ||||
-rw-r--r-- | src/transport/transport.h | 10 | ||||
-rw-r--r-- | src/transport/transport_api2_communication.c | 105 |
4 files changed, 110 insertions, 65 deletions
diff --git a/src/transport/gnunet-communicator-unix.c b/src/transport/gnunet-communicator-unix.c index a9a75f779..a97560ad4 100644 --- a/src/transport/gnunet-communicator-unix.c +++ b/src/transport/gnunet-communicator-unix.c | |||
@@ -11,7 +11,7 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | */ | 17 | */ |
@@ -31,8 +31,8 @@ | |||
31 | #include "gnunet_transport_communication_service.h" | 31 | #include "gnunet_transport_communication_service.h" |
32 | 32 | ||
33 | /** | 33 | /** |
34 | * How many messages do we keep at most in the queue to the | 34 | * How many messages do we keep at most in the queue to the |
35 | * transport service before we start to drop (default, | 35 | * transport service before we start to drop (default, |
36 | * can be changed via the configuration file). | 36 | * can be changed via the configuration file). |
37 | * Should be _below_ the level of the communicator API, as | 37 | * Should be _below_ the level of the communicator API, as |
38 | * otherwise we may read messages just to have them dropped | 38 | * otherwise we may read messages just to have them dropped |
@@ -113,17 +113,17 @@ struct Queue | |||
113 | * if this queue is in the #queue_head DLL. | 113 | * if this queue is in the #queue_head DLL. |
114 | */ | 114 | */ |
115 | const struct GNUNET_MessageHeader *msg; | 115 | const struct GNUNET_MessageHeader *msg; |
116 | 116 | ||
117 | /** | 117 | /** |
118 | * Message queue we are providing for the #ch. | 118 | * Message queue we are providing for the #ch. |
119 | */ | 119 | */ |
120 | struct GNUNET_MQ_Handle *mq; | 120 | struct GNUNET_MQ_Handle *mq; |
121 | 121 | ||
122 | /** | 122 | /** |
123 | * handle for this queue with the #ch. | 123 | * handle for this queue with the #ch. |
124 | */ | 124 | */ |
125 | struct GNUNET_TRANSPORT_QueueHandle *qh; | 125 | struct GNUNET_TRANSPORT_QueueHandle *qh; |
126 | 126 | ||
127 | /** | 127 | /** |
128 | * Number of bytes we currently have in our write queue. | 128 | * Number of bytes we currently have in our write queue. |
129 | */ | 129 | */ |
@@ -211,14 +211,14 @@ queue_destroy (struct Queue *queue) | |||
211 | struct GNUNET_MQ_Handle *mq; | 211 | struct GNUNET_MQ_Handle *mq; |
212 | 212 | ||
213 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 213 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
214 | "Disconnecting queue for peer `%s'\n", | 214 | "Disconnecting queue for peer `%s'\n", |
215 | GNUNET_i2s (&queue->target)); | 215 | GNUNET_i2s (&queue->target)); |
216 | if (0 != queue->bytes_in_queue) | 216 | if (0 != queue->bytes_in_queue) |
217 | { | 217 | { |
218 | GNUNET_CONTAINER_DLL_remove (queue_head, | 218 | GNUNET_CONTAINER_DLL_remove (queue_head, |
219 | queue_tail, | 219 | queue_tail, |
220 | queue); | 220 | queue); |
221 | queue->bytes_in_queue = 0; | 221 | queue->bytes_in_queue = 0; |
222 | } | 222 | } |
223 | if (NULL != (mq = queue->mq)) | 223 | if (NULL != (mq = queue->mq)) |
224 | { | 224 | { |
@@ -439,7 +439,7 @@ select_write_cb (void *cls) | |||
439 | queue->address_len); | 439 | queue->address_len); |
440 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 440 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
441 | "UNIX transmitted message to %s (%d/%u: %s)\n", | 441 | "UNIX transmitted message to %s (%d/%u: %s)\n", |
442 | GNUNET_i2s (&queue->target), | 442 | GNUNET_i2s (&queue->target), |
443 | (int) sent, | 443 | (int) sent, |
444 | (unsigned int) msg_size, | 444 | (unsigned int) msg_size, |
445 | (sent < 0) ? STRERROR (errno) : "ok"); | 445 | (sent < 0) ? STRERROR (errno) : "ok"); |
@@ -463,7 +463,7 @@ select_write_cb (void *cls) | |||
463 | /* We should retry later... */ | 463 | /* We should retry later... */ |
464 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_DEBUG, | 464 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_DEBUG, |
465 | "send"); | 465 | "send"); |
466 | return; | 466 | return; |
467 | case EMSGSIZE: | 467 | case EMSGSIZE: |
468 | { | 468 | { |
469 | socklen_t size = 0; | 469 | socklen_t size = 0; |
@@ -533,7 +533,7 @@ mq_send (struct GNUNET_MQ_Handle *mq, | |||
533 | 533 | ||
534 | GNUNET_assert (mq == queue->mq); | 534 | GNUNET_assert (mq == queue->mq); |
535 | GNUNET_assert (NULL == queue->msg); | 535 | GNUNET_assert (NULL == queue->msg); |
536 | queue->msg = msg; | 536 | queue->msg = msg; |
537 | GNUNET_CONTAINER_DLL_insert (queue_head, | 537 | GNUNET_CONTAINER_DLL_insert (queue_head, |
538 | queue_tail, | 538 | queue_tail, |
539 | queue); | 539 | queue); |
@@ -664,7 +664,7 @@ setup_queue (const struct GNUNET_PeerIdentity *target, | |||
664 | queue); | 664 | queue); |
665 | { | 665 | { |
666 | char *foreign_addr; | 666 | char *foreign_addr; |
667 | 667 | ||
668 | if ('\0' == un->sun_path[0]) | 668 | if ('\0' == un->sun_path[0]) |
669 | GNUNET_asprintf (&foreign_addr, | 669 | GNUNET_asprintf (&foreign_addr, |
670 | "%s-@%s", | 670 | "%s-@%s", |
@@ -679,8 +679,9 @@ setup_queue (const struct GNUNET_PeerIdentity *target, | |||
679 | = GNUNET_TRANSPORT_communicator_mq_add (ch, | 679 | = GNUNET_TRANSPORT_communicator_mq_add (ch, |
680 | &queue->target, | 680 | &queue->target, |
681 | foreign_addr, | 681 | foreign_addr, |
682 | UNIX_MTU, | 682 | UNIX_MTU, |
683 | GNUNET_ATS_NET_LOOPBACK, | 683 | GNUNET_ATS_NET_LOOPBACK, |
684 | 0 /* distance */, | ||
684 | cs, | 685 | cs, |
685 | queue->mq); | 686 | queue->mq); |
686 | GNUNET_free (foreign_addr); | 687 | GNUNET_free (foreign_addr); |
@@ -798,12 +799,12 @@ select_read_cb (void *cls) | |||
798 | _("Maximum number of UNIX connections exceeded, dropping incoming message\n")); | 799 | _("Maximum number of UNIX connections exceeded, dropping incoming message\n")); |
799 | return; | 800 | return; |
800 | } | 801 | } |
801 | 802 | ||
802 | { | 803 | { |
803 | uint16_t offset = 0; | 804 | uint16_t offset = 0; |
804 | uint16_t tsize = msize - sizeof (struct UNIXMessage); | 805 | uint16_t tsize = msize - sizeof (struct UNIXMessage); |
805 | const char *msgbuf = (const char *) &msg[1]; | 806 | const char *msgbuf = (const char *) &msg[1]; |
806 | 807 | ||
807 | while (offset + sizeof (struct GNUNET_MessageHeader) <= tsize) | 808 | while (offset + sizeof (struct GNUNET_MessageHeader) <= tsize) |
808 | { | 809 | { |
809 | const struct GNUNET_MessageHeader *currhdr; | 810 | const struct GNUNET_MessageHeader *currhdr; |
@@ -870,7 +871,7 @@ mq_init (void *cls, | |||
870 | const char *path; | 871 | const char *path; |
871 | struct sockaddr_un *un; | 872 | struct sockaddr_un *un; |
872 | socklen_t un_len; | 873 | socklen_t un_len; |
873 | 874 | ||
874 | if (0 != strncmp (address, | 875 | if (0 != strncmp (address, |
875 | COMMUNICATOR_ADDRESS_PREFIX "-", | 876 | COMMUNICATOR_ADDRESS_PREFIX "-", |
876 | strlen (COMMUNICATOR_ADDRESS_PREFIX "-"))) | 877 | strlen (COMMUNICATOR_ADDRESS_PREFIX "-"))) |
@@ -902,7 +903,7 @@ mq_init (void *cls, | |||
902 | { | 903 | { |
903 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 904 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
904 | "Failed to setup queue to %s at `%s'\n", | 905 | "Failed to setup queue to %s at `%s'\n", |
905 | GNUNET_i2s (peer), | 906 | GNUNET_i2s (peer), |
906 | path); | 907 | path); |
907 | return GNUNET_NO; | 908 | return GNUNET_NO; |
908 | } | 909 | } |
@@ -981,7 +982,7 @@ do_shutdown (void *cls) | |||
981 | 982 | ||
982 | /** | 983 | /** |
983 | * Setup communicator and launch network interactions. | 984 | * Setup communicator and launch network interactions. |
984 | * | 985 | * |
985 | * @param cls NULL (always) | 986 | * @param cls NULL (always) |
986 | * @param args remaining command-line arguments | 987 | * @param args remaining command-line arguments |
987 | * @param cfgfile name of the configuration file used (for saving, can be NULL!) | 988 | * @param cfgfile name of the configuration file used (for saving, can be NULL!) |
@@ -998,7 +999,7 @@ run (void *cls, | |||
998 | socklen_t un_len; | 999 | socklen_t un_len; |
999 | char *my_addr; | 1000 | char *my_addr; |
1000 | (void) cls; | 1001 | (void) cls; |
1001 | 1002 | ||
1002 | if (GNUNET_OK != | 1003 | if (GNUNET_OK != |
1003 | GNUNET_CONFIGURATION_get_value_filename (cfg, | 1004 | GNUNET_CONFIGURATION_get_value_filename (cfg, |
1004 | COMMUNICATOR_CONFIG_SECTION, | 1005 | COMMUNICATOR_CONFIG_SECTION, |
@@ -1016,7 +1017,7 @@ run (void *cls, | |||
1016 | "MAX_QUEUE_LENGTH", | 1017 | "MAX_QUEUE_LENGTH", |
1017 | &max_queue_length)) | 1018 | &max_queue_length)) |
1018 | max_queue_length = DEFAULT_MAX_QUEUE_LENGTH; | 1019 | max_queue_length = DEFAULT_MAX_QUEUE_LENGTH; |
1019 | 1020 | ||
1020 | un = unix_address_to_sockaddr (unix_socket_path, | 1021 | un = unix_address_to_sockaddr (unix_socket_path, |
1021 | &un_len); | 1022 | &un_len); |
1022 | if (NULL == un) | 1023 | if (NULL == un) |
@@ -1082,6 +1083,7 @@ run (void *cls, | |||
1082 | ch = GNUNET_TRANSPORT_communicator_connect (cfg, | 1083 | ch = GNUNET_TRANSPORT_communicator_connect (cfg, |
1083 | COMMUNICATOR_CONFIG_SECTION, | 1084 | COMMUNICATOR_CONFIG_SECTION, |
1084 | COMMUNICATOR_ADDRESS_PREFIX, | 1085 | COMMUNICATOR_ADDRESS_PREFIX, |
1086 | GNUNET_TRANSPORT_CC_RELIABLE, | ||
1085 | &mq_init, | 1087 | &mq_init, |
1086 | NULL); | 1088 | NULL); |
1087 | if (NULL == ch) | 1089 | if (NULL == ch) |
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c index ca8838380..3e08900bb 100644 --- a/src/transport/gnunet-service-tng.c +++ b/src/transport/gnunet-service-tng.c | |||
@@ -155,6 +155,11 @@ struct Queue | |||
155 | uint32_t mtu; | 155 | uint32_t mtu; |
156 | 156 | ||
157 | /** | 157 | /** |
158 | * Distance to the target of this queue. | ||
159 | */ | ||
160 | uint32_t distance; | ||
161 | |||
162 | /** | ||
158 | * Network type offered by this queue. | 163 | * Network type offered by this queue. |
159 | */ | 164 | */ |
160 | enum GNUNET_ATS_Network_Type nt; | 165 | enum GNUNET_ATS_Network_Type nt; |
@@ -423,6 +428,11 @@ struct TransportClient | |||
423 | */ | 428 | */ |
424 | struct AddressListEntry *addr_tail; | 429 | struct AddressListEntry *addr_tail; |
425 | 430 | ||
431 | /** | ||
432 | * Characteristics of this communicator. | ||
433 | */ | ||
434 | enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc; | ||
435 | |||
426 | } communicator; | 436 | } communicator; |
427 | 437 | ||
428 | } details; | 438 | } details; |
@@ -1106,7 +1116,10 @@ handle_communicator_available (void *cls, | |||
1106 | size = ntohs (cam->header.size) - sizeof (*cam); | 1116 | size = ntohs (cam->header.size) - sizeof (*cam); |
1107 | if (0 == size) | 1117 | if (0 == size) |
1108 | return; /* receive-only communicator */ | 1118 | return; /* receive-only communicator */ |
1109 | tc->details.communicator.address_prefix = GNUNET_strdup ((const char *) &cam[1]); | 1119 | tc->details.communicator.address_prefix |
1120 | = GNUNET_strdup ((const char *) &cam[1]); | ||
1121 | tc->details.communicator.cc | ||
1122 | = (enum GNUNET_TRANSPORT_CommunicatorCharacteristics) ntohl (cam->cc); | ||
1110 | GNUNET_SERVICE_client_continue (tc->client); | 1123 | GNUNET_SERVICE_client_continue (tc->client); |
1111 | } | 1124 | } |
1112 | 1125 | ||
@@ -1413,6 +1426,7 @@ handle_add_queue_message (void *cls, | |||
1413 | queue->rtt = GNUNET_TIME_UNIT_FOREVER_REL; | 1426 | queue->rtt = GNUNET_TIME_UNIT_FOREVER_REL; |
1414 | queue->qid = aqm->qid; | 1427 | queue->qid = aqm->qid; |
1415 | queue->mtu = ntohl (aqm->mtu); | 1428 | queue->mtu = ntohl (aqm->mtu); |
1429 | queue->distance = ntohl (aqm->distance); | ||
1416 | queue->nt = (enum GNUNET_ATS_Network_Type) ntohl (aqm->nt); | 1430 | queue->nt = (enum GNUNET_ATS_Network_Type) ntohl (aqm->nt); |
1417 | queue->cs = (enum GNUNET_TRANSPORT_ConnectionStatus) ntohl (aqm->cs); | 1431 | queue->cs = (enum GNUNET_TRANSPORT_ConnectionStatus) ntohl (aqm->cs); |
1418 | queue->neighbour = neighbour; | 1432 | queue->neighbour = neighbour; |
diff --git a/src/transport/transport.h b/src/transport/transport.h index e8c276342..515c178f4 100644 --- a/src/transport/transport.h +++ b/src/transport/transport.h | |||
@@ -661,6 +661,11 @@ struct GNUNET_TRANSPORT_CommunicatorAvailableMessage | |||
661 | */ | 661 | */ |
662 | struct GNUNET_MessageHeader header; | 662 | struct GNUNET_MessageHeader header; |
663 | 663 | ||
664 | /** | ||
665 | * NBO encoding of `enum GNUNET_TRANSPORT_CommunicatorCharacteristics` | ||
666 | */ | ||
667 | uint32_t cc; | ||
668 | |||
664 | /* Followed by the address prefix of the communicator */ | 669 | /* Followed by the address prefix of the communicator */ |
665 | }; | 670 | }; |
666 | 671 | ||
@@ -810,6 +815,11 @@ struct GNUNET_TRANSPORT_AddQueueMessage | |||
810 | */ | 815 | */ |
811 | uint32_t cs; | 816 | uint32_t cs; |
812 | 817 | ||
818 | /** | ||
819 | * Hops to the target (DV-only), in NBO. | ||
820 | */ | ||
821 | uint32_t distance; | ||
822 | |||
813 | /* followed by UTF-8 encoded, 0-terminated human-readable address */ | 823 | /* followed by UTF-8 encoded, 0-terminated human-readable address */ |
814 | }; | 824 | }; |
815 | 825 | ||
diff --git a/src/transport/transport_api2_communication.c b/src/transport/transport_api2_communication.c index 6704f0cd8..a89802ddd 100644 --- a/src/transport/transport_api2_communication.c +++ b/src/transport/transport_api2_communication.c | |||
@@ -11,7 +11,7 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | */ | 17 | */ |
@@ -29,8 +29,8 @@ | |||
29 | 29 | ||
30 | 30 | ||
31 | /** | 31 | /** |
32 | * How many messages do we keep at most in the queue to the | 32 | * How many messages do we keep at most in the queue to the |
33 | * transport service before we start to drop (default, | 33 | * transport service before we start to drop (default, |
34 | * can be changed via the configuration file). | 34 | * can be changed via the configuration file). |
35 | */ | 35 | */ |
36 | #define DEFAULT_MAX_QUEUE_LENGTH 16 | 36 | #define DEFAULT_MAX_QUEUE_LENGTH 16 |
@@ -60,7 +60,7 @@ struct FlowControl | |||
60 | * Closure for @e cb | 60 | * Closure for @e cb |
61 | */ | 61 | */ |
62 | void *cb_cls; | 62 | void *cb_cls; |
63 | 63 | ||
64 | /** | 64 | /** |
65 | * Which peer is this about? | 65 | * Which peer is this about? |
66 | */ | 66 | */ |
@@ -93,7 +93,7 @@ struct AckPending | |||
93 | * Communicator this entry belongs to. | 93 | * Communicator this entry belongs to. |
94 | */ | 94 | */ |
95 | struct GNUNET_TRANSPORT_CommunicatorHandle *ch; | 95 | struct GNUNET_TRANSPORT_CommunicatorHandle *ch; |
96 | 96 | ||
97 | /** | 97 | /** |
98 | * Which peer is this about? | 98 | * Which peer is this about? |
99 | */ | 99 | */ |
@@ -145,12 +145,12 @@ struct GNUNET_TRANSPORT_CommunicatorHandle | |||
145 | * DLL of queues we offer. | 145 | * DLL of queues we offer. |
146 | */ | 146 | */ |
147 | struct GNUNET_TRANSPORT_QueueHandle *queue_head; | 147 | struct GNUNET_TRANSPORT_QueueHandle *queue_head; |
148 | 148 | ||
149 | /** | 149 | /** |
150 | * DLL of queues we offer. | 150 | * DLL of queues we offer. |
151 | */ | 151 | */ |
152 | struct GNUNET_TRANSPORT_QueueHandle *queue_tail; | 152 | struct GNUNET_TRANSPORT_QueueHandle *queue_tail; |
153 | 153 | ||
154 | /** | 154 | /** |
155 | * Our configuration. | 155 | * Our configuration. |
156 | */ | 156 | */ |
@@ -181,12 +181,12 @@ struct GNUNET_TRANSPORT_CommunicatorHandle | |||
181 | * Queue to talk to the transport service. | 181 | * Queue to talk to the transport service. |
182 | */ | 182 | */ |
183 | struct GNUNET_MQ_Handle *mq; | 183 | struct GNUNET_MQ_Handle *mq; |
184 | 184 | ||
185 | /** | 185 | /** |
186 | * Maximum permissable queue length. | 186 | * Maximum permissable queue length. |
187 | */ | 187 | */ |
188 | unsigned long long max_queue_length; | 188 | unsigned long long max_queue_length; |
189 | 189 | ||
190 | /** | 190 | /** |
191 | * Flow-control identifier generator. | 191 | * Flow-control identifier generator. |
192 | */ | 192 | */ |
@@ -202,7 +202,12 @@ struct GNUNET_TRANSPORT_CommunicatorHandle | |||
202 | * Queue identifier generator. | 202 | * Queue identifier generator. |
203 | */ | 203 | */ |
204 | uint32_t queue_gen; | 204 | uint32_t queue_gen; |
205 | 205 | ||
206 | /** | ||
207 | * Characteristics of the communicator. | ||
208 | */ | ||
209 | enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc; | ||
210 | |||
206 | }; | 211 | }; |
207 | 212 | ||
208 | 213 | ||
@@ -222,21 +227,26 @@ struct GNUNET_TRANSPORT_QueueHandle | |||
222 | * Kept in a DLL. | 227 | * Kept in a DLL. |
223 | */ | 228 | */ |
224 | struct GNUNET_TRANSPORT_QueueHandle *prev; | 229 | struct GNUNET_TRANSPORT_QueueHandle *prev; |
225 | 230 | ||
226 | /** | 231 | /** |
227 | * Handle this queue belongs to. | 232 | * Handle this queue belongs to. |
228 | */ | 233 | */ |
229 | struct GNUNET_TRANSPORT_CommunicatorHandle *ch; | 234 | struct GNUNET_TRANSPORT_CommunicatorHandle *ch; |
230 | 235 | ||
231 | /** | 236 | /** |
232 | * Which peer we can communciate with. | 237 | * Address used by the communication queue. |
233 | */ | 238 | */ |
234 | struct GNUNET_PeerIdentity peer; | 239 | char *address; |
235 | 240 | ||
236 | /** | 241 | /** |
237 | * Address used by the communication queue. | 242 | * The queue itself. |
238 | */ | 243 | */ |
239 | char *address; | 244 | struct GNUNET_MQ_Handle *mq; |
245 | |||
246 | /** | ||
247 | * Which peer we can communciate with. | ||
248 | */ | ||
249 | struct GNUNET_PeerIdentity peer; | ||
240 | 250 | ||
241 | /** | 251 | /** |
242 | * Network type of the communciation queue. | 252 | * Network type of the communciation queue. |
@@ -247,11 +257,11 @@ struct GNUNET_TRANSPORT_QueueHandle | |||
247 | * Communication status of the queue. | 257 | * Communication status of the queue. |
248 | */ | 258 | */ |
249 | enum GNUNET_TRANSPORT_ConnectionStatus cs; | 259 | enum GNUNET_TRANSPORT_ConnectionStatus cs; |
250 | 260 | ||
251 | /** | 261 | /** |
252 | * The queue itself. | 262 | * How many hops is the target away (DV-only) |
253 | */ | 263 | */ |
254 | struct GNUNET_MQ_Handle *mq; | 264 | uint32_t distance; |
255 | 265 | ||
256 | /** | 266 | /** |
257 | * ID for this queue when talking to the transport service. | 267 | * ID for this queue when talking to the transport service. |
@@ -262,7 +272,7 @@ struct GNUNET_TRANSPORT_QueueHandle | |||
262 | * Maximum transmission unit for the queue. | 272 | * Maximum transmission unit for the queue. |
263 | */ | 273 | */ |
264 | uint32_t mtu; | 274 | uint32_t mtu; |
265 | 275 | ||
266 | }; | 276 | }; |
267 | 277 | ||
268 | 278 | ||
@@ -282,7 +292,7 @@ struct GNUNET_TRANSPORT_AddressIdentifier | |||
282 | * Kept in a DLL. | 292 | * Kept in a DLL. |
283 | */ | 293 | */ |
284 | struct GNUNET_TRANSPORT_AddressIdentifier *prev; | 294 | struct GNUNET_TRANSPORT_AddressIdentifier *prev; |
285 | 295 | ||
286 | /** | 296 | /** |
287 | * Transport handle where the address was added. | 297 | * Transport handle where the address was added. |
288 | */ | 298 | */ |
@@ -298,7 +308,7 @@ struct GNUNET_TRANSPORT_AddressIdentifier | |||
298 | * address.) | 308 | * address.) |
299 | */ | 309 | */ |
300 | struct GNUNET_TIME_Relative expiration; | 310 | struct GNUNET_TIME_Relative expiration; |
301 | 311 | ||
302 | /** | 312 | /** |
303 | * Internal UUID for the address used in communication with the | 313 | * Internal UUID for the address used in communication with the |
304 | * transport service. | 314 | * transport service. |
@@ -309,7 +319,7 @@ struct GNUNET_TRANSPORT_AddressIdentifier | |||
309 | * Network type for the address. | 319 | * Network type for the address. |
310 | */ | 320 | */ |
311 | enum GNUNET_ATS_Network_Type nt; | 321 | enum GNUNET_ATS_Network_Type nt; |
312 | 322 | ||
313 | }; | 323 | }; |
314 | 324 | ||
315 | 325 | ||
@@ -333,7 +343,7 @@ send_add_address (struct GNUNET_TRANSPORT_AddressIdentifier *ai) | |||
333 | { | 343 | { |
334 | struct GNUNET_MQ_Envelope *env; | 344 | struct GNUNET_MQ_Envelope *env; |
335 | struct GNUNET_TRANSPORT_AddAddressMessage *aam; | 345 | struct GNUNET_TRANSPORT_AddAddressMessage *aam; |
336 | 346 | ||
337 | if (NULL == ai->ch->mq) | 347 | if (NULL == ai->ch->mq) |
338 | return; | 348 | return; |
339 | env = GNUNET_MQ_msg_extra (aam, | 349 | env = GNUNET_MQ_msg_extra (aam, |
@@ -360,10 +370,10 @@ send_del_address (struct GNUNET_TRANSPORT_AddressIdentifier *ai) | |||
360 | { | 370 | { |
361 | struct GNUNET_MQ_Envelope *env; | 371 | struct GNUNET_MQ_Envelope *env; |
362 | struct GNUNET_TRANSPORT_DelAddressMessage *dam; | 372 | struct GNUNET_TRANSPORT_DelAddressMessage *dam; |
363 | 373 | ||
364 | if (NULL == ai->ch->mq) | 374 | if (NULL == ai->ch->mq) |
365 | return; | 375 | return; |
366 | env = GNUNET_MQ_msg (dam, | 376 | env = GNUNET_MQ_msg (dam, |
367 | GNUNET_MESSAGE_TYPE_TRANSPORT_DEL_ADDRESS); | 377 | GNUNET_MESSAGE_TYPE_TRANSPORT_DEL_ADDRESS); |
368 | dam->aid = htonl (ai->aid); | 378 | dam->aid = htonl (ai->aid); |
369 | GNUNET_MQ_send (ai->ch->mq, | 379 | GNUNET_MQ_send (ai->ch->mq, |
@@ -382,7 +392,7 @@ send_add_queue (struct GNUNET_TRANSPORT_QueueHandle *qh) | |||
382 | { | 392 | { |
383 | struct GNUNET_MQ_Envelope *env; | 393 | struct GNUNET_MQ_Envelope *env; |
384 | struct GNUNET_TRANSPORT_AddQueueMessage *aqm; | 394 | struct GNUNET_TRANSPORT_AddQueueMessage *aqm; |
385 | 395 | ||
386 | if (NULL == qh->ch->mq) | 396 | if (NULL == qh->ch->mq) |
387 | return; | 397 | return; |
388 | env = GNUNET_MQ_msg_extra (aqm, | 398 | env = GNUNET_MQ_msg_extra (aqm, |
@@ -393,6 +403,7 @@ send_add_queue (struct GNUNET_TRANSPORT_QueueHandle *qh) | |||
393 | aqm->nt = htonl ((uint32_t) qh->nt); | 403 | aqm->nt = htonl ((uint32_t) qh->nt); |
394 | aqm->mtu = htonl (qh->mtu); | 404 | aqm->mtu = htonl (qh->mtu); |
395 | aqm->cs = htonl ((uint32_t) qh->cs); | 405 | aqm->cs = htonl ((uint32_t) qh->cs); |
406 | aqm->distance = htonl (qh->distance); | ||
396 | memcpy (&aqm[1], | 407 | memcpy (&aqm[1], |
397 | qh->address, | 408 | qh->address, |
398 | strlen (qh->address) + 1); | 409 | strlen (qh->address) + 1); |
@@ -412,10 +423,10 @@ send_del_queue (struct GNUNET_TRANSPORT_QueueHandle *qh) | |||
412 | { | 423 | { |
413 | struct GNUNET_MQ_Envelope *env; | 424 | struct GNUNET_MQ_Envelope *env; |
414 | struct GNUNET_TRANSPORT_DelQueueMessage *dqm; | 425 | struct GNUNET_TRANSPORT_DelQueueMessage *dqm; |
415 | 426 | ||
416 | if (NULL == qh->ch->mq) | 427 | if (NULL == qh->ch->mq) |
417 | return; | 428 | return; |
418 | env = GNUNET_MQ_msg (dqm, | 429 | env = GNUNET_MQ_msg (dqm, |
419 | GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN); | 430 | GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN); |
420 | dqm->qid = htonl (qh->queue_id); | 431 | dqm->qid = htonl (qh->queue_id); |
421 | dqm->receiver = qh->peer; | 432 | dqm->receiver = qh->peer; |
@@ -437,7 +448,7 @@ disconnect (struct GNUNET_TRANSPORT_CommunicatorHandle *ch) | |||
437 | { | 448 | { |
438 | struct FlowControl *fcn; | 449 | struct FlowControl *fcn; |
439 | struct AckPending *apn; | 450 | struct AckPending *apn; |
440 | 451 | ||
441 | for (struct FlowControl *fc = ch->fc_head; | 452 | for (struct FlowControl *fc = ch->fc_head; |
442 | NULL != fc; | 453 | NULL != fc; |
443 | fc = fcn) | 454 | fc = fcn) |
@@ -497,7 +508,7 @@ handle_incoming_ack (void *cls, | |||
497 | const struct GNUNET_TRANSPORT_IncomingMessageAck *incoming_ack) | 508 | const struct GNUNET_TRANSPORT_IncomingMessageAck *incoming_ack) |
498 | { | 509 | { |
499 | struct GNUNET_TRANSPORT_CommunicatorHandle *ch = cls; | 510 | struct GNUNET_TRANSPORT_CommunicatorHandle *ch = cls; |
500 | 511 | ||
501 | for (struct FlowControl *fc = ch->fc_head; | 512 | for (struct FlowControl *fc = ch->fc_head; |
502 | NULL != fc; | 513 | NULL != fc; |
503 | fc = fc->next) | 514 | fc = fc->next) |
@@ -563,7 +574,7 @@ handle_create_queue (void *cls, | |||
563 | const char *addr = (const char *) &cq[1]; | 574 | const char *addr = (const char *) &cq[1]; |
564 | struct GNUNET_TRANSPORT_CreateQueueResponse *cqr; | 575 | struct GNUNET_TRANSPORT_CreateQueueResponse *cqr; |
565 | struct GNUNET_MQ_Envelope *env; | 576 | struct GNUNET_MQ_Envelope *env; |
566 | 577 | ||
567 | if (GNUNET_OK != | 578 | if (GNUNET_OK != |
568 | ch->mq_init (ch->mq_init_cls, | 579 | ch->mq_init (ch->mq_init_cls, |
569 | &cq->receiver, | 580 | &cq->receiver, |
@@ -573,12 +584,12 @@ handle_create_queue (void *cls, | |||
573 | "Address `%s' invalid for this communicator\n", | 584 | "Address `%s' invalid for this communicator\n", |
574 | addr); | 585 | addr); |
575 | env = GNUNET_MQ_msg (cqr, | 586 | env = GNUNET_MQ_msg (cqr, |
576 | GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_FAIL); | 587 | GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_FAIL); |
577 | } | 588 | } |
578 | else | 589 | else |
579 | { | 590 | { |
580 | env = GNUNET_MQ_msg (cqr, | 591 | env = GNUNET_MQ_msg (cqr, |
581 | GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_OK); | 592 | GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_OK); |
582 | } | 593 | } |
583 | cqr->request_id = cq->request_id; | 594 | cqr->request_id = cq->request_id; |
584 | GNUNET_MQ_send (ch->mq, | 595 | GNUNET_MQ_send (ch->mq, |
@@ -678,12 +689,12 @@ handle_send_msg (void *cls, | |||
678 | struct AckPending *ap; | 689 | struct AckPending *ap; |
679 | struct GNUNET_TRANSPORT_QueueHandle *qh; | 690 | struct GNUNET_TRANSPORT_QueueHandle *qh; |
680 | 691 | ||
681 | for (qh = ch->queue_head;NULL != qh; qh = qh->next) | 692 | for (qh = ch->queue_head;NULL != qh; qh = qh->next) |
682 | if ( (qh->queue_id == smt->qid) && | 693 | if ( (qh->queue_id == smt->qid) && |
683 | (0 == memcmp (&qh->peer, | 694 | (0 == memcmp (&qh->peer, |
684 | &smt->receiver, | 695 | &smt->receiver, |
685 | sizeof (struct GNUNET_PeerIdentity))) ) | 696 | sizeof (struct GNUNET_PeerIdentity))) ) |
686 | break; | 697 | break; |
687 | if (NULL == qh) | 698 | if (NULL == qh) |
688 | { | 699 | { |
689 | /* queue is already gone, tell transport this one failed */ | 700 | /* queue is already gone, tell transport this one failed */ |
@@ -737,7 +748,7 @@ reconnect (struct GNUNET_TRANSPORT_CommunicatorHandle *ch) | |||
737 | }; | 748 | }; |
738 | struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *cam; | 749 | struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *cam; |
739 | struct GNUNET_MQ_Envelope *env; | 750 | struct GNUNET_MQ_Envelope *env; |
740 | 751 | ||
741 | ch->mq = GNUNET_CLIENT_connect (ch->cfg, | 752 | ch->mq = GNUNET_CLIENT_connect (ch->cfg, |
742 | "transport", | 753 | "transport", |
743 | handlers, | 754 | handlers, |
@@ -745,9 +756,10 @@ reconnect (struct GNUNET_TRANSPORT_CommunicatorHandle *ch) | |||
745 | ch); | 756 | ch); |
746 | if (NULL == ch->mq) | 757 | if (NULL == ch->mq) |
747 | return; | 758 | return; |
748 | env = GNUNET_MQ_msg_extra (cam, | 759 | env = GNUNET_MQ_msg_extra (cam, |
749 | strlen (ch->addr_prefix) + 1, | 760 | strlen (ch->addr_prefix) + 1, |
750 | GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR); | 761 | GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR); |
762 | cam->cc = htonl ((uint32_t) ch->cc); | ||
751 | memcpy (&cam[1], | 763 | memcpy (&cam[1], |
752 | ch->addr_prefix, | 764 | ch->addr_prefix, |
753 | strlen (ch->addr_prefix) + 1); | 765 | strlen (ch->addr_prefix) + 1); |
@@ -771,6 +783,7 @@ reconnect (struct GNUNET_TRANSPORT_CommunicatorHandle *ch) | |||
771 | * @param config_section section of the configuration to use for options | 783 | * @param config_section section of the configuration to use for options |
772 | * @param addr_prefix address prefix for addresses supported by this | 784 | * @param addr_prefix address prefix for addresses supported by this |
773 | * communicator, could be NULL for incoming-only communicators | 785 | * communicator, could be NULL for incoming-only communicators |
786 | * @param cc what characteristics does the communicator have? | ||
774 | * @param mtu maximum message size supported by communicator, 0 if | 787 | * @param mtu maximum message size supported by communicator, 0 if |
775 | * sending is not supported, SIZE_MAX for no MTU | 788 | * sending is not supported, SIZE_MAX for no MTU |
776 | * @param mq_init function to call to initialize a message queue given | 789 | * @param mq_init function to call to initialize a message queue given |
@@ -783,17 +796,19 @@ struct GNUNET_TRANSPORT_CommunicatorHandle * | |||
783 | GNUNET_TRANSPORT_communicator_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | 796 | GNUNET_TRANSPORT_communicator_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, |
784 | const char *config_section, | 797 | const char *config_section, |
785 | const char *addr_prefix, | 798 | const char *addr_prefix, |
799 | enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc, | ||
786 | GNUNET_TRANSPORT_CommunicatorMqInit mq_init, | 800 | GNUNET_TRANSPORT_CommunicatorMqInit mq_init, |
787 | void *mq_init_cls) | 801 | void *mq_init_cls) |
788 | { | 802 | { |
789 | struct GNUNET_TRANSPORT_CommunicatorHandle *ch; | 803 | struct GNUNET_TRANSPORT_CommunicatorHandle *ch; |
790 | 804 | ||
791 | ch = GNUNET_new (struct GNUNET_TRANSPORT_CommunicatorHandle); | 805 | ch = GNUNET_new (struct GNUNET_TRANSPORT_CommunicatorHandle); |
792 | ch->cfg = cfg; | 806 | ch->cfg = cfg; |
793 | ch->config_section = config_section; | 807 | ch->config_section = config_section; |
794 | ch->addr_prefix = addr_prefix; | 808 | ch->addr_prefix = addr_prefix; |
795 | ch->mq_init = mq_init; | 809 | ch->mq_init = mq_init; |
796 | ch->mq_init_cls = mq_init_cls; | 810 | ch->mq_init_cls = mq_init_cls; |
811 | ch->cc = cc; | ||
797 | reconnect (ch); | 812 | reconnect (ch); |
798 | if (GNUNET_OK != | 813 | if (GNUNET_OK != |
799 | GNUNET_CONFIGURATION_get_value_number (cfg, | 814 | GNUNET_CONFIGURATION_get_value_number (cfg, |
@@ -858,7 +873,7 @@ GNUNET_TRANSPORT_communicator_receive (struct GNUNET_TRANSPORT_CommunicatorHandl | |||
858 | struct GNUNET_MQ_Envelope *env; | 873 | struct GNUNET_MQ_Envelope *env; |
859 | struct GNUNET_TRANSPORT_IncomingMessage *im; | 874 | struct GNUNET_TRANSPORT_IncomingMessage *im; |
860 | uint16_t msize; | 875 | uint16_t msize; |
861 | 876 | ||
862 | if (NULL == ch->mq) | 877 | if (NULL == ch->mq) |
863 | return GNUNET_SYSERR; | 878 | return GNUNET_SYSERR; |
864 | if ( (NULL == cb) && | 879 | if ( (NULL == cb) && |
@@ -869,7 +884,7 @@ GNUNET_TRANSPORT_communicator_receive (struct GNUNET_TRANSPORT_CommunicatorHandl | |||
869 | ch->max_queue_length); | 884 | ch->max_queue_length); |
870 | return GNUNET_NO; | 885 | return GNUNET_NO; |
871 | } | 886 | } |
872 | 887 | ||
873 | msize = ntohs (msg->size); | 888 | msize = ntohs (msg->size); |
874 | env = GNUNET_MQ_msg_extra (im, | 889 | env = GNUNET_MQ_msg_extra (im, |
875 | msize, | 890 | msize, |
@@ -918,6 +933,8 @@ GNUNET_TRANSPORT_communicator_receive (struct GNUNET_TRANSPORT_CommunicatorHandl | |||
918 | * @param mtu maximum message size supported by queue, 0 if | 933 | * @param mtu maximum message size supported by queue, 0 if |
919 | * sending is not supported, SIZE_MAX for no MTU | 934 | * sending is not supported, SIZE_MAX for no MTU |
920 | * @param nt which network type does the @a address belong to? | 935 | * @param nt which network type does the @a address belong to? |
936 | * @param cc what characteristics does the communicator have? | ||
937 | * @param distance how many hops does this queue use (DV-only)? | ||
921 | * @param cs what is the connection status of the queue? | 938 | * @param cs what is the connection status of the queue? |
922 | * @param mq message queue of the @a peer | 939 | * @param mq message queue of the @a peer |
923 | * @return API handle identifying the new MQ | 940 | * @return API handle identifying the new MQ |
@@ -928,6 +945,7 @@ GNUNET_TRANSPORT_communicator_mq_add (struct GNUNET_TRANSPORT_CommunicatorHandle | |||
928 | const char *address, | 945 | const char *address, |
929 | uint32_t mtu, | 946 | uint32_t mtu, |
930 | enum GNUNET_ATS_Network_Type nt, | 947 | enum GNUNET_ATS_Network_Type nt, |
948 | uint32_t distance, | ||
931 | enum GNUNET_TRANSPORT_ConnectionStatus cs, | 949 | enum GNUNET_TRANSPORT_ConnectionStatus cs, |
932 | struct GNUNET_MQ_Handle *mq) | 950 | struct GNUNET_MQ_Handle *mq) |
933 | { | 951 | { |
@@ -939,6 +957,7 @@ GNUNET_TRANSPORT_communicator_mq_add (struct GNUNET_TRANSPORT_CommunicatorHandle | |||
939 | qh->address = GNUNET_strdup (address); | 957 | qh->address = GNUNET_strdup (address); |
940 | qh->nt = nt; | 958 | qh->nt = nt; |
941 | qh->mtu = mtu; | 959 | qh->mtu = mtu; |
960 | qh->distance = distance; | ||
942 | qh->cs = cs; | 961 | qh->cs = cs; |
943 | qh->mq = mq; | 962 | qh->mq = mq; |
944 | qh->queue_id = ch->queue_gen++; | 963 | qh->queue_id = ch->queue_gen++; |
@@ -960,7 +979,7 @@ void | |||
960 | GNUNET_TRANSPORT_communicator_mq_del (struct GNUNET_TRANSPORT_QueueHandle *qh) | 979 | GNUNET_TRANSPORT_communicator_mq_del (struct GNUNET_TRANSPORT_QueueHandle *qh) |
961 | { | 980 | { |
962 | struct GNUNET_TRANSPORT_CommunicatorHandle *ch = qh->ch; | 981 | struct GNUNET_TRANSPORT_CommunicatorHandle *ch = qh->ch; |
963 | 982 | ||
964 | send_del_queue (qh); | 983 | send_del_queue (qh); |
965 | GNUNET_CONTAINER_DLL_remove (ch->queue_head, | 984 | GNUNET_CONTAINER_DLL_remove (ch->queue_head, |
966 | ch->queue_tail, | 985 | ch->queue_tail, |