aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-13 21:08:21 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-13 21:08:21 +0000
commite1d767d557cb8241f69e50b9e8d55e5a08e0adcb (patch)
tree38a3d43e23b88e4ba9159561d7af95fe4c697f8d
parent7a377062f397a3cf1ee5ddb1e79bba55e3a25bff (diff)
downloadgnunet-e1d767d557cb8241f69e50b9e8d55e5a08e0adcb.tar.gz
gnunet-e1d767d557cb8241f69e50b9e8d55e5a08e0adcb.zip
stuff
-rw-r--r--src/transport/gnunet-service-transport-new.c70
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c22
-rw-r--r--src/transport/gnunet-service-transport_neighbours.h13
3 files changed, 89 insertions, 16 deletions
diff --git a/src/transport/gnunet-service-transport-new.c b/src/transport/gnunet-service-transport-new.c
index 759cfe542..f34450319 100644
--- a/src/transport/gnunet-service-transport-new.c
+++ b/src/transport/gnunet-service-transport-new.c
@@ -36,6 +36,7 @@
36#include "gnunet-service-transport_neighbours.h" 36#include "gnunet-service-transport_neighbours.h"
37#include "gnunet-service-transport_plugins.h" 37#include "gnunet-service-transport_plugins.h"
38#include "gnunet-service-transport_validation.h" 38#include "gnunet-service-transport_validation.h"
39#include "transport.h"
39 40
40/* globals */ 41/* globals */
41 42
@@ -101,11 +102,12 @@ process_hello_update (void *cls,
101 * This function should also be called with "NULL" for the 102 * This function should also be called with "NULL" for the
102 * message to signal that the other peer disconnected. 103 * message to signal that the other peer disconnected.
103 * 104 *
104 * @param cls closure 105 * @param cls closure, const char* with the name of the plugin we received the message from
105 * @param peer (claimed) identity of the other peer 106 * @param peer (claimed) identity of the other peer
106 * @param message the message, NULL if we only care about 107 * @param message the message, NULL if we only care about
107 * learning about the delay until we should receive again -- FIXME! 108 * learning about the delay until we should receive again -- FIXME!
108 * @param distance in overlay hops; use 1 unless DV (or 0 if message == NULL) 109 * @param ats performance information
110 * @param ats_count number of records in ats
109 * @param session identifier used for this session (NULL for plugins 111 * @param session identifier used for this session (NULL for plugins
110 * that do not offer bi-directional communication to the sender 112 * that do not offer bi-directional communication to the sender
111 * using the same "connection") 113 * using the same "connection")
@@ -120,20 +122,29 @@ process_hello_update (void *cls,
120 */ 122 */
121static struct GNUNET_TIME_Relative 123static struct GNUNET_TIME_Relative
122plugin_env_receive_callback (void *cls, 124plugin_env_receive_callback (void *cls,
123 const struct 125 const struct GNUNET_PeerIdentity *peer,
124 GNUNET_PeerIdentity * 126 const struct GNUNET_MessageHeader *message,
125 peer, 127 const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count,
126 const struct
127 GNUNET_MessageHeader *
128 message,
129 const struct GNUNET_TRANSPORT_ATS_Information *ats,
130 uint32_t ats_count,
131 struct Session *session, 128 struct Session *session,
132 const char *sender_address, 129 const char *sender_address,
133 uint16_t sender_address_len) 130 uint16_t sender_address_len)
134{ 131{
135 GNUNET_break (0); // FIXME 132 const char *plugin_name = cls;
136 return GNUNET_TIME_UNIT_ZERO; 133
134 if (NULL != message)
135 GST_clients_broadcast (message, GNUNET_YES);
136 GNUNET_ATS_address_update (GST_ats,
137 peer,
138 GNUNET_TIME_absolute_get (), /* valid at least until right now... */
139 plugin_name,
140 session,
141 sender_address,
142 sender_address_len,
143 ats, ats_count);
144 return GST_neighbours_calculate_receive_delay (peer,
145 (message == NULL)
146 ? 0
147 : ntohs (message->size));
137} 148}
138 149
139 150
@@ -181,7 +192,8 @@ plugin_env_session_end (void *cls,
181 const struct GNUNET_PeerIdentity *peer, 192 const struct GNUNET_PeerIdentity *peer,
182 struct Session *session) 193 struct Session *session)
183{ 194{
184 GNUNET_break (0); // FIXME 195 GST_neighbours_session_terminated (peer,
196 session);
185} 197}
186 198
187 199
@@ -209,7 +221,14 @@ ats_request_address_change (void *cls,
209 size_t plugin_addr_len, 221 size_t plugin_addr_len,
210 struct GNUNET_BANDWIDTH_Value32NBO bandwidth) 222 struct GNUNET_BANDWIDTH_Value32NBO bandwidth)
211{ 223{
212 GNUNET_break (0); // FIXME 224 GST_neighbours_switch_to_address (peer,
225 plugin_name,
226 plugin_addr,
227 plugin_addr_len,
228 session,
229 NULL, 0);
230 GST_neighbours_set_incoming_quota (peer,
231 bandwidth);
213} 232}
214 233
215 234
@@ -228,7 +247,19 @@ neighbours_connect_notification (void *cls,
228 const struct GNUNET_TRANSPORT_ATS_Information *ats, 247 const struct GNUNET_TRANSPORT_ATS_Information *ats,
229 uint32_t ats_count) 248 uint32_t ats_count)
230{ 249{
231 GNUNET_break (0); // FIXME 250 char buf[sizeof(struct ConnectInfoMessage) + ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information)];
251 struct ConnectInfoMessage *connect_msg = (struct ConnectInfoMessage*) buf;
252 struct GNUNET_TRANSPORT_ATS_Information *atsm = &connect_msg->ats;
253
254 connect_msg->header.size = htons (sizeof (buf));
255 connect_msg->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT);
256 connect_msg->ats_count = htonl (ats_count);
257 connect_msg->id = *peer;
258 memcpy (&connect_msg->ats, ats, ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information));
259 atsm[ats_count].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR);
260 atsm[ats_count].value = htonl (0);
261 GST_clients_broadcast (&connect_msg->header,
262 GNUNET_NO);
232} 263}
233 264
234 265
@@ -243,7 +274,14 @@ static void
243neighbours_disconnect_notification (void *cls, 274neighbours_disconnect_notification (void *cls,
244 const struct GNUNET_PeerIdentity *peer) 275 const struct GNUNET_PeerIdentity *peer)
245{ 276{
246 GNUNET_break (0); // FIXME 277 struct DisconnectInfoMessage disconnect_msg;
278
279 disconnect_msg.header.size = htons (sizeof (struct DisconnectInfoMessage));
280 disconnect_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT);
281 disconnect_msg.reserved = htonl (0);
282 disconnect_msg.peer = *peer;
283 GST_clients_broadcast (&disconnect_msg.header,
284 GNUNET_NO);
247} 285}
248 286
249 287
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c
index f262c2b87..9ae9712a9 100644
--- a/src/transport/gnunet-service-transport_neighbours.c
+++ b/src/transport/gnunet-service-transport_neighbours.c
@@ -514,13 +514,35 @@ GST_neighbours_stop ()
514 514
515 515
516/** 516/**
517 * A session was terminated. Take note.
518 *
519 * @param peer identity of the peer where the session died
520 * @param session session that is gone
521 */
522void
523GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
524 struct Session *session)
525{
526 struct NeighbourMapEntry *n;
527
528 n = lookup_neighbour (peer);
529 if (NULL == n)
530 return;
531 if (session == n->session)
532 n->session = NULL;
533}
534
535
536/**
517 * For an existing neighbour record, set the active connection to 537 * For an existing neighbour record, set the active connection to
518 * the given address. 538 * the given address.
519 * 539 *
540 * @param peer identity of the peer to switch the address for
520 * @param plugin_name name of transport that delivered the PONG 541 * @param plugin_name name of transport that delivered the PONG
521 * @param address address of the other peer, NULL if other peer 542 * @param address address of the other peer, NULL if other peer
522 * connected to us 543 * connected to us
523 * @param address_len number of bytes in address 544 * @param address_len number of bytes in address
545 * @param session session to use (or NULL)
524 * @param ats performance data 546 * @param ats performance data
525 * @param ats_count number of entries in ats (excluding 0-termination) 547 * @param ats_count number of entries in ats (excluding 0-termination)
526 */ 548 */
diff --git a/src/transport/gnunet-service-transport_neighbours.h b/src/transport/gnunet-service-transport_neighbours.h
index 281060913..d9b2fd6b4 100644
--- a/src/transport/gnunet-service-transport_neighbours.h
+++ b/src/transport/gnunet-service-transport_neighbours.h
@@ -164,13 +164,26 @@ GST_neighbours_iterate (GST_NeighbourIterator cb,
164 164
165 165
166/** 166/**
167 * A session was terminated. Take note.
168 *
169 * @param peer identity of the peer where the session died
170 * @param session session that is gone
171 */
172void
173GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
174 struct Session *session);
175
176
177/**
167 * For an existing neighbour record, set the active connection to 178 * For an existing neighbour record, set the active connection to
168 * use the given address. 179 * use the given address.
169 * 180 *
181 * @param peer identity of the peer to switch the address for
170 * @param plugin_name name of transport that delivered the PONG 182 * @param plugin_name name of transport that delivered the PONG
171 * @param address address of the other peer, NULL if other peer 183 * @param address address of the other peer, NULL if other peer
172 * connected to us 184 * connected to us
173 * @param address_len number of bytes in address 185 * @param address_len number of bytes in address
186 * @param session session to use (or NULL)
174 * @param ats performance data 187 * @param ats performance data
175 * @param ats_count number of entries in ats (excluding 0-termination) 188 * @param ats_count number of entries in ats (excluding 0-termination)
176 */ 189 */