aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-05-06 11:53:15 +0000
committerChristian Grothoff <christian@grothoff.org>2012-05-06 11:53:15 +0000
commit5b4628337a35dac0fd34e51042b21db70dd39dee (patch)
tree74c8411a8dde0e4bb2549c5ee0a86f97aa2c9925 /src/transport
parent9fac6b6eefdc9144053f736fd388cb2199a97046 (diff)
downloadgnunet-5b4628337a35dac0fd34e51042b21db70dd39dee.tar.gz
gnunet-5b4628337a35dac0fd34e51042b21db70dd39dee.zip
-fixing #2302
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-service-transport_clients.c4
-rw-r--r--src/transport/gnunet-transport.c3
-rw-r--r--src/transport/plugin_transport_http.c6
-rw-r--r--src/transport/plugin_transport_tcp.c8
-rw-r--r--src/transport/plugin_transport_udp.c6
-rw-r--r--src/transport/plugin_transport_unix.c61
-rw-r--r--src/transport/transport_api_address_to_string.c3
7 files changed, 44 insertions, 47 deletions
diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c
index cadb4d6c6..98844f830 100644
--- a/src/transport/gnunet-service-transport_clients.c
+++ b/src/transport/gnunet-service-transport_clients.c
@@ -775,10 +775,6 @@ clients_handle_address_to_string (void *cls,
775 return; 775 return;
776 } 776 }
777 GNUNET_SERVER_disable_receive_done_warning (client); 777 GNUNET_SERVER_disable_receive_done_warning (client);
778 if ((NULL == address) || (0 == address_len))
779 {
780 GNUNET_break_op (0);
781 }
782 papi->address_pretty_printer (papi->cls, plugin_name, address, address_len, 778 papi->address_pretty_printer (papi->cls, plugin_name, address, address_len,
783 numeric, rtimeout, &transmit_address_to_client, 779 numeric, rtimeout, &transmit_address_to_client,
784 tc); 780 tc);
diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c
index 6ef273c45..ee23189a8 100644
--- a/src/transport/gnunet-transport.c
+++ b/src/transport/gnunet-transport.c
@@ -454,7 +454,8 @@ struct ResolutionContext
454 int printed; 454 int printed;
455}; 455};
456 456
457void 457
458static void
458process_string (void *cls, const char *address) 459process_string (void *cls, const char *address)
459{ 460{
460 struct ResolutionContext *rc = cls; 461 struct ResolutionContext *rc = cls;
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c
index 4f9279495..de616173e 100644
--- a/src/transport/plugin_transport_http.c
+++ b/src/transport/plugin_transport_http.c
@@ -212,6 +212,12 @@ http_plugin_address_pretty_printer (void *cls, const char *type,
212 sbs = sizeof (struct sockaddr_in); 212 sbs = sizeof (struct sockaddr_in);
213 port = ntohs (a4->u4_port); 213 port = ntohs (a4->u4_port);
214 } 214 }
215 else if (0 == addrlen)
216 {
217 asc (asc_cls, "<inbound connection>");
218 asc (asc_cls, NULL);
219 return;
220 }
215 else 221 else
216 { 222 {
217 /* invalid address */ 223 /* invalid address */
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c
index ec4bbfc5e..0c1b8a056 100644
--- a/src/transport/plugin_transport_tcp.c
+++ b/src/transport/plugin_transport_tcp.c
@@ -1507,11 +1507,15 @@ tcp_plugin_address_pretty_printer (void *cls, const char *type,
1507 sb = &a4; 1507 sb = &a4;
1508 sbs = sizeof (a4); 1508 sbs = sizeof (a4);
1509 } 1509 }
1510 else if (0 == addrlen)
1511 {
1512 asc (asc_cls, "<inbound connection>");
1513 asc (asc_cls, NULL);
1514 return;
1515 }
1510 else 1516 else
1511 { 1517 {
1512 /* invalid address */ 1518 /* invalid address */
1513 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "tcp",
1514 "Invalid address to string request: plugin `%s', address length: %u bytes\n");
1515 GNUNET_break_op (0); 1519 GNUNET_break_op (0);
1516 asc (asc_cls, NULL); 1520 asc (asc_cls, NULL);
1517 return; 1521 return;
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c
index 9e28f00d4..ec6e52236 100644
--- a/src/transport/plugin_transport_udp.c
+++ b/src/transport/plugin_transport_udp.c
@@ -514,6 +514,12 @@ udp_plugin_address_pretty_printer (void *cls, const char *type,
514 sb = &a4; 514 sb = &a4;
515 sbs = sizeof (a4); 515 sbs = sizeof (a4);
516 } 516 }
517 else if (0 == addrlen)
518 {
519 asc (asc_cls, "<inbound connection>");
520 asc (asc_cls, NULL);
521 return;
522 }
517 else 523 else
518 { 524 {
519 /* invalid address */ 525 /* invalid address */
diff --git a/src/transport/plugin_transport_unix.c b/src/transport/plugin_transport_unix.c
index 1f39f1d40..a858b9a2d 100644
--- a/src/transport/plugin_transport_unix.c
+++ b/src/transport/plugin_transport_unix.c
@@ -185,12 +185,7 @@ struct Plugin
185 */ 185 */
186 struct GNUNET_TRANSPORT_PluginEnvironment *env; 186 struct GNUNET_TRANSPORT_PluginEnvironment *env;
187 187
188 /* 188 /**
189 * Session of peers with whom we are currently connected
190 */
191 struct PeerSession *sessions;
192
193 /*
194 * Sessions 189 * Sessions
195 */ 190 */
196 struct GNUNET_CONTAINER_MultiHashMap *session_map; 191 struct GNUNET_CONTAINER_MultiHashMap *session_map;
@@ -243,9 +238,11 @@ struct Plugin
243 unsigned int bytes_in_queue; 238 unsigned int bytes_in_queue;
244}; 239};
245 240
241
246static void 242static void
247unix_plugin_select (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); 243unix_plugin_select (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
248 244
245
249static void 246static void
250reschedule_select (struct Plugin * plugin) 247reschedule_select (struct Plugin * plugin)
251{ 248{
@@ -320,6 +317,7 @@ get_session_delete_it (void *cls, const GNUNET_HashCode * key, void *value)
320 return GNUNET_YES; 317 return GNUNET_YES;
321} 318}
322 319
320
323/** 321/**
324 * Disconnect from a remote node. Clean up session if we have one for this peer 322 * Disconnect from a remote node. Clean up session if we have one for this peer
325 * 323 *
@@ -327,7 +325,7 @@ get_session_delete_it (void *cls, const GNUNET_HashCode * key, void *value)
327 * @param target the peeridentity of the peer to disconnect 325 * @param target the peeridentity of the peer to disconnect
328 * @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed 326 * @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed
329 */ 327 */
330void 328static void
331unix_disconnect (void *cls, const struct GNUNET_PeerIdentity *target) 329unix_disconnect (void *cls, const struct GNUNET_PeerIdentity *target)
332{ 330{
333 struct Plugin *plugin = cls; 331 struct Plugin *plugin = cls;
@@ -379,23 +377,6 @@ unix_transport_server_stop (void *cls)
379} 377}
380 378
381 379
382struct PeerSession *
383find_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *peer)
384{
385 struct PeerSession *pos;
386
387 pos = plugin->sessions;
388 while (pos != NULL)
389 {
390 if (memcmp (&pos->target, peer, sizeof (struct GNUNET_PeerIdentity)) == 0)
391 return pos;
392 pos = pos->next;
393 }
394
395 return pos;
396}
397
398
399/** 380/**
400 * Actually send out the message, assume we've got the address and 381 * Actually send out the message, assume we've got the address and
401 * send_handle squared away! 382 * send_handle squared away!
@@ -563,6 +544,7 @@ struct gsi_ctx
563 struct Session *res; 544 struct Session *res;
564}; 545};
565 546
547
566static int 548static int
567get_session_it (void *cls, const GNUNET_HashCode * key, void *value) 549get_session_it (void *cls, const GNUNET_HashCode * key, void *value)
568{ 550{
@@ -824,6 +806,7 @@ unix_plugin_select_read (struct Plugin * plugin)
824 } 806 }
825} 807}
826 808
809
827static void 810static void
828unix_plugin_select_write (struct Plugin * plugin) 811unix_plugin_select_write (struct Plugin * plugin)
829{ 812{
@@ -891,14 +874,14 @@ unix_plugin_select_write (struct Plugin * plugin)
891 874
892} 875}
893 876
894/* 877
895 * @param cls the plugin handle 878/**
896 * @param tc the scheduling context (for rescheduling this function again)
897 *
898 * We have been notified that our writeset has something to read. We don't 879 * We have been notified that our writeset has something to read. We don't
899 * know which socket needs to be read, so we have to check each one 880 * know which socket needs to be read, so we have to check each one
900 * Then reschedule this function to be called again once more is available. 881 * Then reschedule this function to be called again once more is available.
901 * 882 *
883 * @param cls the plugin handle
884 * @param tc the scheduling context (for rescheduling this function again)
902 */ 885 */
903static void 886static void
904unix_plugin_select (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 887unix_plugin_select (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
@@ -929,12 +912,13 @@ unix_plugin_select (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
929 reschedule_select (plugin); 912 reschedule_select (plugin);
930} 913}
931 914
915
932/** 916/**
933 * Create a slew of UNIX sockets. If possible, use IPv6 and IPv4. 917 * Create a slew of UNIX sockets. If possible, use IPv6 and IPv4.
934 * 918 *
935 * @param cls closure for server start, should be a struct Plugin * 919 * @param cls closure for server start, should be a struct Plugin *
936 * @return number of sockets created or GNUNET_SYSERR on error 920 * @return number of sockets created or GNUNET_SYSERR on error
937*/ 921 */
938static int 922static int
939unix_transport_server_start (void *cls) 923unix_transport_server_start (void *cls)
940{ 924{
@@ -1041,16 +1025,19 @@ unix_plugin_address_pretty_printer (void *cls, const char *type,
1041 GNUNET_TRANSPORT_AddressStringCallback asc, 1025 GNUNET_TRANSPORT_AddressStringCallback asc,
1042 void *asc_cls) 1026 void *asc_cls)
1043{ 1027{
1044 if ((addr != NULL) && (addrlen > 0)) 1028 if ((NULL != addr) && (addrlen > 0))
1029 {
1045 asc (asc_cls, (const char *) addr); 1030 asc (asc_cls, (const char *) addr);
1031 }
1046 else 1032 else
1047 { 1033 {
1048 GNUNET_break (0); 1034 GNUNET_break (0);
1049 asc (asc_cls, "Invalid UNIX address"); 1035 asc (asc_cls, "<invalid UNIX address>");
1050 } 1036 }
1051 1037 asc (asc_cls, NULL);
1052} 1038}
1053 1039
1040
1054/** 1041/**
1055 * Function called to convert a string address to 1042 * Function called to convert a string address to
1056 * a binary address. 1043 * a binary address.
@@ -1063,11 +1050,11 @@ unix_plugin_address_pretty_printer (void *cls, const char *type,
1063 * @param added length of created address 1050 * @param added length of created address
1064 * @return GNUNET_OK on success, GNUNET_SYSERR on failure 1051 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
1065 */ 1052 */
1066int 1053static int
1067unix_string_to_address (void *cls, const char *addr, uint16_t addrlen, 1054unix_string_to_address (void *cls, const char *addr, uint16_t addrlen,
1068 void **buf, size_t *added) 1055 void **buf, size_t *added)
1069{ 1056{
1070 if ((NULL == addr) || (addrlen == 0)) 1057 if ((NULL == addr) || (0 == addrlen))
1071 { 1058 {
1072 GNUNET_break (0); 1059 GNUNET_break (0);
1073 return GNUNET_SYSERR; 1060 return GNUNET_SYSERR;
@@ -1091,8 +1078,6 @@ unix_string_to_address (void *cls, const char *addr, uint16_t addrlen,
1091} 1078}
1092 1079
1093 1080
1094
1095
1096/** 1081/**
1097 * Function called for a quick conversion of the binary address to 1082 * Function called for a quick conversion of the binary address to
1098 * a numeric address. Note that the caller must not free the 1083 * a numeric address. Note that the caller must not free the
@@ -1109,10 +1094,10 @@ unix_address_to_string (void *cls, const void *addr, size_t addrlen)
1109{ 1094{
1110 if ((addr != NULL) && (addrlen > 0)) 1095 if ((addr != NULL) && (addrlen > 0))
1111 return (const char *) addr; 1096 return (const char *) addr;
1112 else 1097 return NULL;
1113 return NULL;
1114} 1098}
1115 1099
1100
1116/** 1101/**
1117 * Notify transport service about address 1102 * Notify transport service about address
1118 * 1103 *
diff --git a/src/transport/transport_api_address_to_string.c b/src/transport/transport_api_address_to_string.c
index 237c0b657..152e573cd 100644
--- a/src/transport/transport_api_address_to_string.c
+++ b/src/transport/transport_api_address_to_string.c
@@ -141,9 +141,8 @@ GNUNET_TRANSPORT_address_to_string (const struct GNUNET_CONFIGURATION_Handle
141 GNUNET_break (0); 141 GNUNET_break (0);
142 return NULL; 142 return NULL;
143 } 143 }
144
145 client = GNUNET_CLIENT_connect ("transport", cfg); 144 client = GNUNET_CLIENT_connect ("transport", cfg);
146 if (client == NULL) 145 if (NULL == client)
147 return NULL; 146 return NULL;
148 msg = GNUNET_malloc (len); 147 msg = GNUNET_malloc (len);
149 msg->header.size = htons (len); 148 msg->header.size = htons (len);