diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-03-06 12:32:16 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-03-06 12:32:16 +0000 |
commit | 10b2ef580e79924e9117e1654dd9d58b23d618e2 (patch) | |
tree | 3fd102121a0171764118cddae2796bee74da80c3 /src/namestore/namestore_api.c | |
parent | b45ab93426129c5b4460067a6fac06abf536b461 (diff) | |
download | gnunet-10b2ef580e79924e9117e1654dd9d58b23d618e2.tar.gz gnunet-10b2ef580e79924e9117e1654dd9d58b23d618e2.zip |
- step 1) compiles again
Diffstat (limited to 'src/namestore/namestore_api.c')
-rw-r--r-- | src/namestore/namestore_api.c | 105 |
1 files changed, 16 insertions, 89 deletions
diff --git a/src/namestore/namestore_api.c b/src/namestore/namestore_api.c index 9634b6d4d..f885c2b7c 100644 --- a/src/namestore/namestore_api.c +++ b/src/namestore/namestore_api.c | |||
@@ -254,12 +254,10 @@ handle_lookup_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe, | |||
254 | "LOOKUP_NAME_RESPONSE"); | 254 | "LOOKUP_NAME_RESPONSE"); |
255 | 255 | ||
256 | struct GNUNET_NAMESTORE_Handle *h = qe->nsh; | 256 | struct GNUNET_NAMESTORE_Handle *h = qe->nsh; |
257 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key; | ||
258 | char *name; | 257 | char *name; |
259 | char * rd_tmp; | 258 | char * rd_tmp; |
260 | 259 | ||
261 | struct GNUNET_CRYPTO_RsaSignature *signature = NULL; | 260 | struct GNUNET_CRYPTO_RsaSignature *signature = NULL; |
262 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded dummy; | ||
263 | struct GNUNET_TIME_Absolute expire; | 261 | struct GNUNET_TIME_Absolute expire; |
264 | size_t exp_msg_len; | 262 | size_t exp_msg_len; |
265 | size_t msg_len = 0; | 263 | size_t msg_len = 0; |
@@ -277,9 +275,7 @@ handle_lookup_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe, | |||
277 | 275 | ||
278 | exp_msg_len = sizeof (struct LookupNameResponseMessage) + | 276 | exp_msg_len = sizeof (struct LookupNameResponseMessage) + |
279 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) + | 277 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) + |
280 | name_len + | 278 | name_len + rd_len; |
281 | rd_len + | ||
282 | contains_sig * sizeof (struct GNUNET_CRYPTO_RsaSignature); | ||
283 | 279 | ||
284 | if (msg_len != exp_msg_len) | 280 | if (msg_len != exp_msg_len) |
285 | { | 281 | { |
@@ -288,11 +284,16 @@ handle_lookup_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe, | |||
288 | GNUNET_break_op (0); | 284 | GNUNET_break_op (0); |
289 | return; | 285 | return; |
290 | } | 286 | } |
287 | if (name_len == 0) | ||
288 | { | ||
289 | GNUNET_break_op (0); | ||
290 | return; | ||
291 | } | ||
291 | 292 | ||
292 | zone_key = (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *) &msg[1]; | 293 | name = (char *) &msg[1]; |
293 | name = (char *) &zone_key[1]; | ||
294 | rd_tmp = &name[name_len]; | 294 | rd_tmp = &name[name_len]; |
295 | 295 | ||
296 | /* deserialize records */ | ||
296 | struct GNUNET_NAMESTORE_RecordData rd[rd_count]; | 297 | struct GNUNET_NAMESTORE_RecordData rd[rd_count]; |
297 | GNUNET_NAMESTORE_records_deserialize(rd_len, rd_tmp, rd_count, rd); | 298 | GNUNET_NAMESTORE_records_deserialize(rd_len, rd_tmp, rd_count, rd); |
298 | 299 | ||
@@ -300,17 +301,11 @@ handle_lookup_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe, | |||
300 | if (contains_sig == GNUNET_NO) | 301 | if (contains_sig == GNUNET_NO) |
301 | signature = NULL; | 302 | signature = NULL; |
302 | else | 303 | else |
303 | signature = (struct GNUNET_CRYPTO_RsaSignature *) &rd_tmp[rd_len]; | 304 | signature = &msg->signature; |
304 | if (name_len == 0) | ||
305 | name = NULL; | ||
306 | |||
307 | memset (&dummy, '0', sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); | ||
308 | if (0 == memcmp (zone_key, &dummy, sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded))) | ||
309 | zone_key = NULL; | ||
310 | 305 | ||
311 | if (qe->proc != NULL) | 306 | if (qe->proc != NULL) |
312 | { | 307 | { |
313 | qe->proc (qe->proc_cls, zone_key, expire, name, rd_count, (rd_count > 0) ? rd : NULL, signature); | 308 | qe->proc (qe->proc_cls, &msg->public_key, expire, name, rd_count, (rd_count > 0) ? rd : NULL, signature); |
314 | } | 309 | } |
315 | 310 | ||
316 | /* Operation done, remove */ | 311 | /* Operation done, remove */ |
@@ -482,11 +477,9 @@ handle_zone_to_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe, | |||
482 | size_t name_len; | 477 | size_t name_len; |
483 | size_t rd_ser_len; | 478 | size_t rd_ser_len; |
484 | unsigned int rd_count; | 479 | unsigned int rd_count; |
485 | int have_signature; | ||
486 | 480 | ||
487 | char * name_tmp; | 481 | char * name_tmp; |
488 | char * rd_tmp; | 482 | char * rd_tmp; |
489 | struct GNUNET_CRYPTO_RsaSignature* sig_tmp; | ||
490 | 483 | ||
491 | if (res == GNUNET_SYSERR) | 484 | if (res == GNUNET_SYSERR) |
492 | { | 485 | { |
@@ -507,22 +500,16 @@ handle_zone_to_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe, | |||
507 | name_len = ntohs (msg->name_len); | 500 | name_len = ntohs (msg->name_len); |
508 | rd_count = ntohs (msg->rd_count); | 501 | rd_count = ntohs (msg->rd_count); |
509 | rd_ser_len = ntohs (msg->rd_len); | 502 | rd_ser_len = ntohs (msg->rd_len); |
510 | have_signature = ntohl (msg->contains_sig); | ||
511 | expire = GNUNET_TIME_absolute_ntoh(msg->expire); | 503 | expire = GNUNET_TIME_absolute_ntoh(msg->expire); |
512 | 504 | ||
513 | name_tmp = (char *) &msg[1]; | 505 | name_tmp = (char *) &msg[1]; |
514 | rd_tmp = &name_tmp[name_len]; | 506 | rd_tmp = &name_tmp[name_len]; |
515 | if (have_signature == GNUNET_YES) | ||
516 | sig_tmp = (struct GNUNET_CRYPTO_RsaSignature *) &rd_tmp[rd_ser_len]; | ||
517 | else | ||
518 | sig_tmp = NULL; | ||
519 | 507 | ||
520 | struct GNUNET_NAMESTORE_RecordData rd[rd_count]; | 508 | struct GNUNET_NAMESTORE_RecordData rd[rd_count]; |
521 | GNUNET_NAMESTORE_records_deserialize(rd_ser_len, rd_tmp, rd_count, rd); | 509 | GNUNET_NAMESTORE_records_deserialize(rd_ser_len, rd_tmp, rd_count, rd); |
522 | 510 | ||
523 | if (qe->proc != NULL) | 511 | if (qe->proc != NULL) |
524 | qe->proc (qe->proc_cls, &msg->zone_key, expire, name_tmp, rd_count, rd, sig_tmp); | 512 | qe->proc (qe->proc_cls, &msg->zone_key, expire, name_tmp, rd_count, rd, &msg->signature); |
525 | |||
526 | } | 513 | } |
527 | else | 514 | else |
528 | GNUNET_break_op (0); | 515 | GNUNET_break_op (0); |
@@ -869,12 +856,6 @@ GNUNET_NAMESTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
869 | return h; | 856 | return h; |
870 | } | 857 | } |
871 | 858 | ||
872 | struct DisconnectContext | ||
873 | { | ||
874 | struct GNUNET_NAMESTORE_Handle *h; | ||
875 | int drop; | ||
876 | }; | ||
877 | |||
878 | static void | 859 | static void |
879 | clean_up_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 860 | clean_up_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
880 | { | 861 | { |
@@ -917,36 +898,6 @@ clean_up_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
917 | h = NULL; | 898 | h = NULL; |
918 | }; | 899 | }; |
919 | 900 | ||
920 | static size_t | ||
921 | transmit_disconnect_to_namestore (void *cls, size_t size, void *buf) | ||
922 | { | ||
923 | struct DisconnectContext * d_ctx = cls; | ||
924 | struct DisconnectMessage d_msg; | ||
925 | struct GNUNET_NAMESTORE_Handle *h = d_ctx->h; | ||
926 | int res; | ||
927 | |||
928 | d_msg.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_DISCONNECT); | ||
929 | d_msg.header.size = htons (sizeof (struct DisconnectMessage)); | ||
930 | d_msg.drop = htonl (d_ctx->drop); | ||
931 | |||
932 | h->th = NULL; | ||
933 | if ((size == 0) || (buf == NULL) || (size < sizeof (struct DisconnectMessage))) | ||
934 | { | ||
935 | GNUNET_break (0); | ||
936 | res = 0; | ||
937 | } | ||
938 | else | ||
939 | { | ||
940 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message to service \n", "NAMESTORE_DISCONNECT"); | ||
941 | memcpy (buf, &d_msg, sizeof (struct DisconnectMessage)); | ||
942 | res = sizeof (struct DisconnectMessage); | ||
943 | } | ||
944 | |||
945 | GNUNET_SCHEDULER_add_now (&clean_up_task, h); | ||
946 | GNUNET_free (d_ctx); | ||
947 | return res; | ||
948 | } | ||
949 | |||
950 | /** | 901 | /** |
951 | * Disconnect from the namestore service (and free associated | 902 | * Disconnect from the namestore service (and free associated |
952 | * resources). | 903 | * resources). |
@@ -957,29 +908,8 @@ transmit_disconnect_to_namestore (void *cls, size_t size, void *buf) | |||
957 | void | 908 | void |
958 | GNUNET_NAMESTORE_disconnect (struct GNUNET_NAMESTORE_Handle *h, int drop) | 909 | GNUNET_NAMESTORE_disconnect (struct GNUNET_NAMESTORE_Handle *h, int drop) |
959 | { | 910 | { |
960 | if (h->th != NULL) | 911 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Disconnecting from namestore service\n"); |
961 | { | ||
962 | GNUNET_CLIENT_notify_transmit_ready_cancel(h->th); | ||
963 | h->th = NULL; | ||
964 | } | ||
965 | if (h->client != NULL) | ||
966 | { | ||
967 | struct DisconnectContext *d_ctx = GNUNET_malloc (sizeof (struct DisconnectContext)); | ||
968 | d_ctx->h = h; | ||
969 | d_ctx->drop = drop; | ||
970 | |||
971 | h->th = GNUNET_CLIENT_notify_transmit_ready (h->client, sizeof (struct DisconnectMessage), | ||
972 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
973 | GNUNET_NO, &transmit_disconnect_to_namestore, | ||
974 | d_ctx); | ||
975 | } | ||
976 | else | ||
977 | { | ||
978 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Could not send disconnect notification to namestore service, we are not connected!\n"); | ||
979 | if (GNUNET_YES == drop) | ||
980 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "NAMESTORE will not drop content\n"); | ||
981 | GNUNET_SCHEDULER_add_now (&clean_up_task, h); | 912 | GNUNET_SCHEDULER_add_now (&clean_up_task, h); |
982 | } | ||
983 | } | 913 | } |
984 | 914 | ||
985 | 915 | ||
@@ -1016,7 +946,6 @@ GNUNET_NAMESTORE_record_put (struct GNUNET_NAMESTORE_Handle *h, | |||
1016 | struct PendingMessage *pe; | 946 | struct PendingMessage *pe; |
1017 | 947 | ||
1018 | /* pointer to elements */ | 948 | /* pointer to elements */ |
1019 | char * zone_key_tmp; | ||
1020 | char * rd_tmp; | 949 | char * rd_tmp; |
1021 | char * name_tmp; | 950 | char * name_tmp; |
1022 | 951 | ||
@@ -1061,22 +990,20 @@ GNUNET_NAMESTORE_record_put (struct GNUNET_NAMESTORE_Handle *h, | |||
1061 | pe->size = msg_size; | 990 | pe->size = msg_size; |
1062 | pe->is_init = GNUNET_NO; | 991 | pe->is_init = GNUNET_NO; |
1063 | msg = (struct RecordPutMessage *) &pe[1]; | 992 | msg = (struct RecordPutMessage *) &pe[1]; |
1064 | zone_key_tmp = (char *) &msg[1]; | 993 | name_tmp = (char *) &msg[1]; |
1065 | name_tmp = (char *) &zone_key_tmp[pubkey_len]; | ||
1066 | rd_tmp = &name_tmp[name_len]; | 994 | rd_tmp = &name_tmp[name_len]; |
1067 | 995 | ||
1068 | msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT); | 996 | msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT); |
1069 | msg->gns_header.header.size = htons (msg_size); | 997 | msg->gns_header.header.size = htons (msg_size); |
1070 | msg->gns_header.r_id = htonl (rid); | 998 | msg->gns_header.r_id = htonl (rid); |
1071 | msg->key_len = htons (pubkey_len); | ||
1072 | memcpy (zone_key_tmp, zone_key, pubkey_len); | ||
1073 | msg->signature = *signature; | 999 | msg->signature = *signature; |
1074 | msg->name_len = htons (name_len); | 1000 | msg->name_len = htons (name_len); |
1075 | memcpy (name_tmp, name, name_len); | ||
1076 | msg->expire = GNUNET_TIME_absolute_hton (expire); | 1001 | msg->expire = GNUNET_TIME_absolute_hton (expire); |
1077 | msg->rd_len = htons (rd_ser_len); | 1002 | msg->rd_len = htons (rd_ser_len); |
1078 | msg->rd_count = htons (rd_count); | 1003 | msg->rd_count = htons (rd_count); |
1079 | 1004 | ||
1005 | msg->public_key = *zone_key; | ||
1006 | memcpy (name_tmp, name, name_len); | ||
1080 | memcpy (rd_tmp, rd_ser, rd_ser_len); | 1007 | memcpy (rd_tmp, rd_ser, rd_ser_len); |
1081 | 1008 | ||
1082 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for name `%s' with size %u\n", "NAMESTORE_RECORD_PUT", name, msg_size); | 1009 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for name `%s' with size %u\n", "NAMESTORE_RECORD_PUT", name, msg_size); |
@@ -1306,7 +1233,7 @@ GNUNET_NAMESTORE_record_remove (struct GNUNET_NAMESTORE_Handle *h, | |||
1306 | msg->name_len = htons (name_len); | 1233 | msg->name_len = htons (name_len); |
1307 | msg->rd_len = htons (rd_ser_len); | 1234 | msg->rd_len = htons (rd_ser_len); |
1308 | msg->rd_count = htons (1); | 1235 | msg->rd_count = htons (1); |
1309 | msg->key_len = htons (key_len); | 1236 | msg->pkey_len = htons (key_len); |
1310 | memcpy (pkey_tmp, pkey_enc, key_len); | 1237 | memcpy (pkey_tmp, pkey_enc, key_len); |
1311 | memcpy (name_tmp, name, name_len); | 1238 | memcpy (name_tmp, name, name_len); |
1312 | memcpy (rd_tmp, rd_ser, rd_ser_len); | 1239 | memcpy (rd_tmp, rd_ser, rd_ser_len); |