diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-06-23 22:31:43 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-06-23 22:31:43 +0000 |
commit | e4b5a6b681d196cb233bf15a91060e3585933aa1 (patch) | |
tree | 882df975f2295b6a0ab6ad6a5a26b52b72d6d48d /src | |
parent | 4029c07550295659b391220324f348f4b1a86381 (diff) | |
download | gnunet-e4b5a6b681d196cb233bf15a91060e3585933aa1.tar.gz gnunet-e4b5a6b681d196cb233bf15a91060e3585933aa1.zip |
-LRN: Check session target:
It changes the Session object layout to make peer identity its first
field, always, for all sessions. Code in find_session() can use this
to check that the session belongs to the right peer.
test_ats_api_add_address always triggers this due to the way it fakes
a pointer to session object.
Diffstat (limited to 'src')
-rw-r--r-- | src/ats/ats_api_scheduling.c | 16 | ||||
-rw-r--r-- | src/transport/plugin_transport_http.h | 9 | ||||
-rw-r--r-- | src/transport/plugin_transport_tcp.c | 11 | ||||
-rw-r--r-- | src/transport/plugin_transport_template.c | 11 | ||||
-rw-r--r-- | src/transport/plugin_transport_unix.c | 3 | ||||
-rw-r--r-- | src/transport/plugin_transport_wlan.c | 11 |
6 files changed, 37 insertions, 24 deletions
diff --git a/src/ats/ats_api_scheduling.c b/src/ats/ats_api_scheduling.c index 88a6423b4..2e97d2ee2 100644 --- a/src/ats/ats_api_scheduling.c +++ b/src/ats/ats_api_scheduling.c | |||
@@ -346,6 +346,22 @@ find_session (struct GNUNET_ATS_SchedulingHandle *sh, uint32_t session_id, | |||
346 | sh->reconnect = GNUNET_YES; | 346 | sh->reconnect = GNUNET_YES; |
347 | return NULL; | 347 | return NULL; |
348 | } | 348 | } |
349 | /* This check exploits the fact that first field of a session object | ||
350 | * is peer identity. | ||
351 | */ | ||
352 | if (0 != | ||
353 | memcmp (peer, sh->session_array[session_id].session, | ||
354 | sizeof (struct GNUNET_PeerIdentity))) | ||
355 | { | ||
356 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "ats-scheduling-api", | ||
357 | "Session %p belongs to peer `%s'\n", | ||
358 | sh->session_array[session_id].session, GNUNET_i2s_full ((struct GNUNET_PeerIdentity *)sh->session_array[session_id].session)); | ||
359 | /* | ||
360 | GNUNET_break (0); | ||
361 | sh->reconnect = GNUNET_YES; | ||
362 | return NULL; | ||
363 | */ | ||
364 | } | ||
349 | return sh->session_array[session_id].session; | 365 | return sh->session_array[session_id].session; |
350 | } | 366 | } |
351 | 367 | ||
diff --git a/src/transport/plugin_transport_http.h b/src/transport/plugin_transport_http.h index 986d7d797..dc0f8bb01 100644 --- a/src/transport/plugin_transport_http.h +++ b/src/transport/plugin_transport_http.h | |||
@@ -339,6 +339,10 @@ struct ServerConnection | |||
339 | */ | 339 | */ |
340 | struct Session | 340 | struct Session |
341 | { | 341 | { |
342 | /** | ||
343 | * To whom are we talking to | ||
344 | */ | ||
345 | struct GNUNET_PeerIdentity target; | ||
342 | 346 | ||
343 | /** | 347 | /** |
344 | * Stored in a linked list. | 348 | * Stored in a linked list. |
@@ -371,11 +375,6 @@ struct Session | |||
371 | uint32_t ats_address_network_type; | 375 | uint32_t ats_address_network_type; |
372 | 376 | ||
373 | /** | 377 | /** |
374 | * To whom are we talking to | ||
375 | */ | ||
376 | struct GNUNET_PeerIdentity target; | ||
377 | |||
378 | /** | ||
379 | * next pointer for double linked list | 378 | * next pointer for double linked list |
380 | */ | 379 | */ |
381 | struct HTTP_Message *msg_head; | 380 | struct HTTP_Message *msg_head; |
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index a42621569..007e87f93 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c | |||
@@ -223,6 +223,11 @@ struct PendingMessage | |||
223 | */ | 223 | */ |
224 | struct Session | 224 | struct Session |
225 | { | 225 | { |
226 | /** | ||
227 | * To whom are we talking to (set to our identity | ||
228 | * if we are still waiting for the welcome message) | ||
229 | */ | ||
230 | struct GNUNET_PeerIdentity target; | ||
226 | 231 | ||
227 | /** | 232 | /** |
228 | * API requirement. | 233 | * API requirement. |
@@ -262,12 +267,6 @@ struct Session | |||
262 | struct GNUNET_SERVER_TransmitHandle *transmit_handle; | 267 | struct GNUNET_SERVER_TransmitHandle *transmit_handle; |
263 | 268 | ||
264 | /** | 269 | /** |
265 | * To whom are we talking to (set to our identity | ||
266 | * if we are still waiting for the welcome message) | ||
267 | */ | ||
268 | struct GNUNET_PeerIdentity target; | ||
269 | |||
270 | /** | ||
271 | * ID of task used to delay receiving more to throttle sender. | 270 | * ID of task used to delay receiving more to throttle sender. |
272 | */ | 271 | */ |
273 | GNUNET_SCHEDULER_TaskIdentifier receive_delay_task; | 272 | GNUNET_SCHEDULER_TaskIdentifier receive_delay_task; |
diff --git a/src/transport/plugin_transport_template.c b/src/transport/plugin_transport_template.c index d3072627e..10ce0da48 100644 --- a/src/transport/plugin_transport_template.c +++ b/src/transport/plugin_transport_template.c | |||
@@ -54,6 +54,11 @@ struct Plugin; | |||
54 | */ | 54 | */ |
55 | struct Session | 55 | struct Session |
56 | { | 56 | { |
57 | /** | ||
58 | * To whom are we talking to (set to our identity | ||
59 | * if we are still waiting for the welcome message) | ||
60 | */ | ||
61 | struct GNUNET_PeerIdentity sender; | ||
57 | 62 | ||
58 | /** | 63 | /** |
59 | * Stored in a linked list. | 64 | * Stored in a linked list. |
@@ -83,12 +88,6 @@ struct Session | |||
83 | void *transmit_cont_cls; | 88 | void *transmit_cont_cls; |
84 | 89 | ||
85 | /** | 90 | /** |
86 | * To whom are we talking to (set to our identity | ||
87 | * if we are still waiting for the welcome message) | ||
88 | */ | ||
89 | struct GNUNET_PeerIdentity sender; | ||
90 | |||
91 | /** | ||
92 | * At what time did we reset last_received last? | 91 | * At what time did we reset last_received last? |
93 | */ | 92 | */ |
94 | struct GNUNET_TIME_Absolute last_quota_update; | 93 | struct GNUNET_TIME_Absolute last_quota_update; |
diff --git a/src/transport/plugin_transport_unix.c b/src/transport/plugin_transport_unix.c index 289fea0b6..b7e10b720 100644 --- a/src/transport/plugin_transport_unix.c +++ b/src/transport/plugin_transport_unix.c | |||
@@ -82,9 +82,10 @@ struct UNIXMessage | |||
82 | 82 | ||
83 | struct Session | 83 | struct Session |
84 | { | 84 | { |
85 | struct GNUNET_PeerIdentity target; | ||
86 | |||
85 | void *addr; | 87 | void *addr; |
86 | size_t addrlen; | 88 | size_t addrlen; |
87 | struct GNUNET_PeerIdentity target; | ||
88 | 89 | ||
89 | /** | 90 | /** |
90 | * Session timeout task | 91 | * Session timeout task |
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c index aed4b2286..c2565a4a8 100644 --- a/src/transport/plugin_transport_wlan.c +++ b/src/transport/plugin_transport_wlan.c | |||
@@ -152,6 +152,11 @@ struct PendingMessage | |||
152 | */ | 152 | */ |
153 | struct Session | 153 | struct Session |
154 | { | 154 | { |
155 | /** | ||
156 | * To whom are we talking to (set to our identity | ||
157 | * if we are still waiting for the welcome message) | ||
158 | */ | ||
159 | struct GNUNET_PeerIdentity target; | ||
155 | 160 | ||
156 | /** | 161 | /** |
157 | * API requirement (must be first). | 162 | * API requirement (must be first). |
@@ -186,12 +191,6 @@ struct Session | |||
186 | struct PendingMessage *pending_message_tail; | 191 | struct PendingMessage *pending_message_tail; |
187 | 192 | ||
188 | /** | 193 | /** |
189 | * To whom are we talking to (set to our identity | ||
190 | * if we are still waiting for the welcome message) | ||
191 | */ | ||
192 | struct GNUNET_PeerIdentity target; | ||
193 | |||
194 | /** | ||
195 | * When should this session time out? | 194 | * When should this session time out? |
196 | */ | 195 | */ |
197 | struct GNUNET_TIME_Absolute timeout; | 196 | struct GNUNET_TIME_Absolute timeout; |