aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-09-29 14:44:24 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-09-29 14:44:24 +0000
commit8377aa60c8714fcec4967e1652c4628032b55bf6 (patch)
tree89968302123369aedbcab440d57b4889d6091ce6 /src/transport
parent46dfa72665e1fcd10c1e98957de6a732f5991c13 (diff)
downloadgnunet-8377aa60c8714fcec4967e1652c4628032b55bf6.tar.gz
gnunet-8377aa60c8714fcec4967e1652c4628032b55bf6.zip
fixing list-connections to show correct peer id
extending neighbour-iterate to return plugin, addr and addresslen
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-service-transport.c8
-rw-r--r--src/transport/gnunet-service-transport_blacklist.c8
-rw-r--r--src/transport/gnunet-service-transport_clients.c34
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c2
-rw-r--r--src/transport/gnunet-service-transport_neighbours.h8
-rw-r--r--src/transport/transport_api_address_iterate.c16
6 files changed, 56 insertions, 20 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index 92f78fec5..3693bcf2e 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -83,11 +83,17 @@ struct GNUNET_ATS_Handle *GST_ats;
83 * @param target a connected neighbour 83 * @param target a connected neighbour
84 * @param ats performance information (unused) 84 * @param ats performance information (unused)
85 * @param ats_count number of records in ats (unused) 85 * @param ats_count number of records in ats (unused)
86 * @param transport plugin
87 * @param addr address
88 * @param addrlen address length
86 */ 89 */
87static void 90static void
88transmit_our_hello (void *cls, const struct GNUNET_PeerIdentity *target, 91transmit_our_hello (void *cls, const struct GNUNET_PeerIdentity *target,
89 const struct GNUNET_TRANSPORT_ATS_Information *ats, 92 const struct GNUNET_TRANSPORT_ATS_Information *ats,
90 uint32_t ats_count) 93 uint32_t ats_count,
94 const char * transport,
95 const void * addr,
96 size_t addrlen)
91{ 97{
92 const struct GNUNET_MessageHeader *hello = cls; 98 const struct GNUNET_MessageHeader *hello = cls;
93 99
diff --git a/src/transport/gnunet-service-transport_blacklist.c b/src/transport/gnunet-service-transport_blacklist.c
index a73aa17c1..cb79787ce 100644
--- a/src/transport/gnunet-service-transport_blacklist.c
+++ b/src/transport/gnunet-service-transport_blacklist.c
@@ -550,11 +550,17 @@ struct TestConnectionContext
550 * @param neighbour neighbour's identity 550 * @param neighbour neighbour's identity
551 * @param ats performance data 551 * @param ats performance data
552 * @param ats_count number of entries in ats (excluding 0-termination) 552 * @param ats_count number of entries in ats (excluding 0-termination)
553 * @param transport plugin
554 * @param addr address
555 * @param addrlen address length
553 */ 556 */
554static void 557static void
555test_connection_ok (void *cls, const struct GNUNET_PeerIdentity *neighbour, 558test_connection_ok (void *cls, const struct GNUNET_PeerIdentity *neighbour,
556 const struct GNUNET_TRANSPORT_ATS_Information *ats, 559 const struct GNUNET_TRANSPORT_ATS_Information *ats,
557 uint32_t ats_count) 560 uint32_t ats_count,
561 const char * transport,
562 const void * addr,
563 size_t addrlen)
558{ 564{
559 struct TestConnectionContext *tcc = cls; 565 struct TestConnectionContext *tcc = cls;
560 struct GST_BlacklistCheck *bc; 566 struct GST_BlacklistCheck *bc;
diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c
index 9936c1137..650efc8dd 100644
--- a/src/transport/gnunet-service-transport_clients.c
+++ b/src/transport/gnunet-service-transport_clients.c
@@ -317,12 +317,18 @@ client_disconnect_notification (void *cls, struct GNUNET_SERVER_Client *client)
317 * @param peer identity of the neighbour 317 * @param peer identity of the neighbour
318 * @param ats performance data 318 * @param ats performance data
319 * @param ats_count number of entries in ats (excluding 0-termination) 319 * @param ats_count number of entries in ats (excluding 0-termination)
320 * @param transport plugin
321 * @param addr address
322 * @param addrlen address length
320 */ 323 */
321static void 324static void
322notify_client_about_neighbour (void *cls, 325notify_client_about_neighbour (void *cls,
323 const struct GNUNET_PeerIdentity *peer, 326 const struct GNUNET_PeerIdentity *peer,
324 const struct GNUNET_TRANSPORT_ATS_Information 327 const struct GNUNET_TRANSPORT_ATS_Information
325 *ats, uint32_t ats_count) 328 *ats, uint32_t ats_count,
329 const char * transport,
330 const void * addr,
331 size_t addrlen)
326{ 332{
327 struct TransportClient *tc = cls; 333 struct TransportClient *tc = cls;
328 struct ConnectInfoMessage *cim; 334 struct ConnectInfoMessage *cim;
@@ -803,24 +809,32 @@ clients_handle_peer_address_lookup (void *cls,
803 * @param neighbour identity of the neighbour 809 * @param neighbour identity of the neighbour
804 * @param ats performance data 810 * @param ats performance data
805 * @param ats_count number of entries in ats (excluding 0-termination) 811 * @param ats_count number of entries in ats (excluding 0-termination)
812 * @param transport plugin
813 * @param addr address
814 * @param addrlen address length
806 */ 815 */
807static void 816static void
808output_addresses (void *cls, const struct GNUNET_PeerIdentity *peer, 817output_addresses (void *cls, const struct GNUNET_PeerIdentity *peer,
809 const struct GNUNET_TRANSPORT_ATS_Information *ats, 818 const struct GNUNET_TRANSPORT_ATS_Information *ats,
810 uint32_t ats_count) 819 uint32_t ats_count,
820 const char * transport,
821 const void * addr,
822 size_t addrlen)
811{ 823{
812 struct GNUNET_SERVER_TransmitContext *tc = cls; 824 struct GNUNET_SERVER_TransmitContext *tc = cls;
813 struct AddressIterateResponseMessage msg; 825 struct AddressIterateResponseMessage * msg;
814 size_t size; 826 size_t size;
815 827
816 size = 828 size =
817 sizeof (struct AddressIterateResponseMessage) - 829 (sizeof (struct AddressIterateResponseMessage) + strlen(transport) + 1);
818 sizeof (struct GNUNET_MessageHeader); 830 msg = GNUNET_malloc (size);
819 memcpy (&msg.peer, peer, sizeof (struct GNUNET_PeerIdentity)); 831 memcpy (&msg->peer, peer, sizeof (struct GNUNET_PeerIdentity));
820 msg.addrlen = ntohs (0); 832 memcpy (&msg[0], transport, strlen(transport)+1);
821 msg.pluginlen = ntohs (0); 833 msg->addrlen = ntohs (addrlen);
822 834 msg->pluginlen = ntohs (strlen(transport)+1);
823 transmit_binary_to_client (tc, &msg, size); 835
836 transmit_binary_to_client (tc, msg, size);
837 GNUNET_free(msg);
824} 838}
825 839
826 840
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c
index 09e24565b..26bf3771c 100644
--- a/src/transport/gnunet-service-transport_neighbours.c
+++ b/src/transport/gnunet-service-transport_neighbours.c
@@ -1064,7 +1064,7 @@ neighbours_iterate (void *cls, const GNUNET_HashCode * key, void *value)
1064 return GNUNET_OK; 1064 return GNUNET_OK;
1065 1065
1066 GNUNET_assert (n->ats_count > 0); 1066 GNUNET_assert (n->ats_count > 0);
1067 ic->cb (ic->cb_cls, &n->id, n->ats, n->ats_count); 1067 ic->cb (ic->cb_cls, &n->id, n->ats, n->ats_count, n->plugin_name, n->addr, n->addrlen);
1068 return GNUNET_OK; 1068 return GNUNET_OK;
1069} 1069}
1070 1070
diff --git a/src/transport/gnunet-service-transport_neighbours.h b/src/transport/gnunet-service-transport_neighbours.h
index 86939f91a..88e24b73a 100644
--- a/src/transport/gnunet-service-transport_neighbours.h
+++ b/src/transport/gnunet-service-transport_neighbours.h
@@ -152,13 +152,19 @@ GST_neighbours_force_disconnect (const struct GNUNET_PeerIdentity *target);
152 * @param neighbour identity of the neighbour 152 * @param neighbour identity of the neighbour
153 * @param ats performance data 153 * @param ats performance data
154 * @param ats_count number of entries in ats (including 0-termination) 154 * @param ats_count number of entries in ats (including 0-termination)
155 * @param transport plugin
156 * @param addr address
157 * @param addrlen address length
155 */ 158 */
156typedef void (*GST_NeighbourIterator) (void *cls, 159typedef void (*GST_NeighbourIterator) (void *cls,
157 const struct GNUNET_PeerIdentity * 160 const struct GNUNET_PeerIdentity *
158 neighbour, 161 neighbour,
159 const struct 162 const struct
160 GNUNET_TRANSPORT_ATS_Information * ats, 163 GNUNET_TRANSPORT_ATS_Information * ats,
161 uint32_t ats_count); 164 uint32_t ats_count,
165 const char * transport,
166 const void * addr,
167 size_t addrlen);
162 168
163 169
164/** 170/**
diff --git a/src/transport/transport_api_address_iterate.c b/src/transport/transport_api_address_iterate.c
index da333798f..a5b4251c5 100644
--- a/src/transport/transport_api_address_iterate.c
+++ b/src/transport/transport_api_address_iterate.c
@@ -80,7 +80,10 @@ peer_address_response_processor (void *cls,
80 struct AddressLookupCtx *alucb = cls; 80 struct AddressLookupCtx *alucb = cls;
81 struct AddressIterateResponseMessage *address; 81 struct AddressIterateResponseMessage *address;
82 uint16_t size; 82 uint16_t size;
83 83 char * transport;
84 size_t transport_len;
85 //void * addr;
86 size_t addrlen;
84 87
85 if (msg == NULL) 88 if (msg == NULL)
86 { 89 {
@@ -103,7 +106,7 @@ peer_address_response_processor (void *cls,
103 GNUNET_free (alucb); 106 GNUNET_free (alucb);
104 return; 107 return;
105 } 108 }
106 if (size != sizeof (struct AddressIterateResponseMessage)) 109 if (size < sizeof (struct AddressIterateResponseMessage))
107 { 110 {
108 /* invalid reply */ 111 /* invalid reply */
109 GNUNET_break (0); 112 GNUNET_break (0);
@@ -113,15 +116,16 @@ peer_address_response_processor (void *cls,
113 return; 116 return;
114 } 117 }
115 118
116 address = (struct AddressIterateResponseMessage *) msg; 119 address = (struct AddressIterateResponseMessage *) &msg[1];
117 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "PEER: %s\n",
118 GNUNET_i2s (&address->peer));
119 120
121 transport = (char *) &address[0];
122 transport_len = ntohs(address->pluginlen);
123 addrlen = ntohs(address->addrlen);
120 124
121 /* expect more replies */ 125 /* expect more replies */
122 GNUNET_CLIENT_receive (alucb->client, &peer_address_response_processor, alucb, 126 GNUNET_CLIENT_receive (alucb->client, &peer_address_response_processor, alucb,
123 GNUNET_TIME_absolute_get_remaining (alucb->timeout)); 127 GNUNET_TIME_absolute_get_remaining (alucb->timeout));
124 alucb->cb (alucb->cb_cls, &address->peer, NULL, NULL, 0); 128 alucb->cb (alucb->cb_cls, &address->peer, transport, NULL, addrlen);
125} 129}
126 130
127 131