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/ats | |
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/ats')
-rw-r--r-- | src/ats/ats_api_scheduling.c | 16 |
1 files changed, 16 insertions, 0 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 | ||