From: Matthias Wachs Date: Tue, 6 Mar 2012 12:32:16 +0000 (+0000) Subject: - step 1) compiles again X-Git-Tag: initial-import-from-subversion-38251~14402 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=10b2ef580e79924e9117e1654dd9d58b23d618e2;p=oweals%2Fgnunet.git - step 1) compiles again --- diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c index 40f3c477a..7408f7ad7 100644 --- a/src/namestore/gnunet-service-namestore.c +++ b/src/namestore/gnunet-service-namestore.c @@ -219,57 +219,6 @@ void drop_iterator (void *cls, } -/** - * Called whenever a client is disconnected. Frees our - * resources associated with that client. - * - * @param cls closure - * @param client identification of the client - * @param message the stop message - */ -static void handle_stop (void *cls, - struct GNUNET_SERVER_Client * client, - const struct GNUNET_MessageHeader * message) -{ - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "NAMESTORE_RECORD_REMOVE"); - struct DisconnectMessage * msg = (struct DisconnectMessage *) message; - struct GNUNET_NAMESTORE_ZoneIteration * no; - struct GNUNET_NAMESTORE_Client * nc; - int drop; - - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected \n", client); - - nc = client_lookup (client); - if (nc == NULL) - { - GNUNET_break (0); - return; - } - - for (no = nc->op_head; no != NULL; no = no->next) - { - GNUNET_CONTAINER_DLL_remove (nc->op_head, nc->op_tail, no); - GNUNET_free (no); - } - - drop = ntohl(msg->drop); - if (GNUNET_YES == drop) - { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Dropping namestore content\n"); - int stop = GNUNET_NO; - int offset = 0; - while (stop == GNUNET_NO) - { - GSN_database->iterate_records (GSN_database->cls, NULL, NULL, offset, &drop_iterator, &stop); - offset ++; - } - } - - GNUNET_SERVER_client_drop(nc->client); - GNUNET_CONTAINER_DLL_remove (client_head, client_tail, nc); - GNUNET_free (nc); -} - static void handle_lookup_name_it (void *cls, const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, @@ -288,18 +237,16 @@ handle_lookup_name_it (void *cls, char *rd_tmp; char *name_tmp; size_t rd_ser_len; - struct GNUNET_CRYPTO_RsaSignature *signature_tmp; - size_t r_size = 0; - size_t name_len = 0; - if (NULL != name) - name_len = strlen(name) + 1; int copied_elements = 0; int contains_signature = 0; int c; + if (NULL != name) + name_len = strlen(name) + 1; + /* count records to copy */ if (rd_count != 0) { @@ -341,25 +288,24 @@ handle_lookup_name_it (void *cls, char rd_ser[rd_ser_len]; GNUNET_NAMESTORE_records_serialize(copied_elements, rd_selected, rd_ser_len, rd_ser); + if (rd_selected != rd) + GNUNET_free (rd_selected); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found %u records for name `%s' in zone `%s'\n", copied_elements, lnc->name, GNUNET_h2s(lnc->zone)); if ((copied_elements == rd_count) && (signature != NULL)) - contains_signature = GNUNET_YES; - - if (rd_selected != rd) - GNUNET_free (rd_selected); + contains_signature = GNUNET_YES; + else + contains_signature = GNUNET_NO; r_size = sizeof (struct LookupNameResponseMessage) + sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) + name_len + - rd_ser_len + - contains_signature * sizeof (struct GNUNET_CRYPTO_RsaSignature); + rd_ser_len; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message\n", "NAMESTORE_LOOKUP_NAME_RESPONSE"); - lnr_msg = GNUNET_malloc (r_size); - lnr_msg->gns_header.header.type = ntohs (GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE); lnr_msg->gns_header.header.size = ntohs (r_size); lnr_msg->gns_header.r_id = htonl (lnc->request_id); @@ -368,25 +314,19 @@ handle_lookup_name_it (void *cls, lnr_msg->name_len = htons (name_len); lnr_msg->expire = GNUNET_TIME_absolute_hton(expire); lnr_msg->contains_sig = htons (contains_signature); + if (GNUNET_YES == contains_signature) + lnr_msg->signature = *signature; + else + memset (&lnr_msg->signature, '\0', sizeof (lnr_msg->signature)); zone_key_tmp = (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *) &lnr_msg[1]; name_tmp = (char *) &zone_key_tmp[1]; rd_tmp = &name_tmp[name_len]; - signature_tmp = (struct GNUNET_CRYPTO_RsaSignature *) &rd_tmp[rd_ser_len]; - if (zone_key != NULL) - memcpy (zone_key_tmp, zone_key, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); - else - { - struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded dummy; - memset (&dummy, '0', sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); - memcpy (zone_key_tmp, &dummy, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); - } + memcpy (zone_key_tmp, zone_key, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); memcpy (name_tmp, name, name_len); memcpy (rd_tmp, rd_ser, rd_ser_len); - if (GNUNET_YES == contains_signature) - memcpy (signature_tmp, signature, sizeof (struct GNUNET_CRYPTO_RsaSignature)); GNUNET_SERVER_notification_context_unicast (snc, lnc->nc->client, (const struct GNUNET_MessageHeader *) lnr_msg, GNUNET_NO); GNUNET_free (lnr_msg); @@ -444,6 +384,7 @@ static void handle_lookup_name (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looking up all records for name `%s' in zone `%s'\n", name, GNUNET_h2s(&ln_msg->zone)); else GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looking up records with type %u for name `%s' in zone `%s'\n", type, name, GNUNET_h2s(&ln_msg->zone)); + /* do the actual lookup */ lnc.request_id = rid; lnc.nc = nc; @@ -462,13 +403,11 @@ static void handle_record_put (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "NAMESTORE_RECORD_PUT"); struct GNUNET_NAMESTORE_Client *nc; struct GNUNET_TIME_Absolute expire; - struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key; struct GNUNET_CRYPTO_RsaSignature *signature; struct RecordPutResponseMessage rpr_msg; size_t name_len; size_t msg_size; size_t msg_size_exp; - size_t key_len; char * name; char * rd_ser; uint32_t rid = 0; @@ -495,7 +434,6 @@ static void handle_record_put (void *cls, rid = ntohl (rp_msg->gns_header.r_id); msg_size = ntohs (rp_msg->gns_header.header.size); - key_len = ntohs (rp_msg->key_len); name_len = ntohs (rp_msg->name_len); rd_count = ntohs (rp_msg->rd_count); rd_ser_len = ntohs(rp_msg->rd_len); @@ -514,7 +452,7 @@ static void handle_record_put (void *cls, return; } - msg_size_exp = sizeof (struct RecordPutMessage) + key_len + name_len + rd_ser_len; + msg_size_exp = sizeof (struct RecordPutMessage) + name_len + rd_ser_len; if (msg_size != msg_size_exp) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Expected message %u size but message size is %u \n", msg_size_exp, msg_size); @@ -529,8 +467,7 @@ static void handle_record_put (void *cls, return; } - zone_key = (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *) &rp_msg[1]; - name = &((char *)zone_key)[key_len]; + name = (char *) &rp_msg[1]; if (name[name_len -1] != '\0') { @@ -553,13 +490,13 @@ static void handle_record_put (void *cls, GNUNET_HashCode zone_hash; - GNUNET_CRYPTO_hash (zone_key, key_len, &zone_hash); + GNUNET_CRYPTO_hash (&rp_msg->public_key, sizeof (rp_msg->public_key), &zone_hash); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Putting %u record for name `%s' in zone `%s'\n", rd_count, name, GNUNET_h2s(&zone_hash)); /* Database operation */ res = GSN_database->put_records(GSN_database->cls, - zone_key, + &rp_msg->public_key, expire, name, rd_count, rd, @@ -571,9 +508,10 @@ static void handle_record_put (void *cls, /* Send response */ send: GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message\n", "RECORD_PUT_RESPONSE"); - rpr_msg.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT_RESPONSE); - rpr_msg.op_id = rp_msg->gns_header.r_id; - rpr_msg.header.size = htons (sizeof (struct RecordPutResponseMessage)); + rpr_msg.gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT_RESPONSE); + rpr_msg.gns_header.header.size = htons (sizeof (struct RecordPutResponseMessage)); + rpr_msg.gns_header.r_id = rp_msg->gns_header.r_id; + if (GNUNET_OK == res) rpr_msg.op_result = htons (GNUNET_OK); else @@ -965,7 +903,7 @@ static void handle_record_remove (void *cls, name_len = ntohs (rr_msg->name_len); rd_ser_len = ntohs (rr_msg->rd_len); rd_count = ntohs (rr_msg->rd_count); - key_len = ntohs (rr_msg->key_len); + key_len = ntohs (rr_msg->pkey_len); msg_size = ntohs (message->size); if (msg_size > GNUNET_SERVER_MAX_MESSAGE_SIZE) @@ -1137,7 +1075,6 @@ handle_zone_to_name_it (void *cls, ztnr_msg->rd_len = htons (rd_ser_len); ztnr_msg->rd_count = htons (rd_count); ztnr_msg->name_len = htons (name_len); - ztnr_msg->contains_sig = htons (contains_sig); ztnr_msg->expire = GNUNET_TIME_absolute_hton(expire); if (zone_key != NULL) ztnr_msg->zone_key = *zone_key; @@ -1425,8 +1362,6 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, static const struct GNUNET_SERVER_MessageHandler handlers[] = { {&handle_start, NULL, GNUNET_MESSAGE_TYPE_NAMESTORE_START, sizeof (struct StartMessage)}, - {&handle_stop, NULL, - GNUNET_MESSAGE_TYPE_NAMESTORE_DISCONNECT, sizeof (struct DisconnectMessage)}, {&handle_lookup_name, NULL, GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME, 0}, {&handle_record_put, NULL, @@ -1439,10 +1374,10 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME, 0}, {&handle_iteration_start, NULL, GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START, sizeof (struct ZoneIterationStartMessage)}, - {&handle_iteration_stop, NULL, - GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP, sizeof (struct ZoneIterationStopMessage)}, {&handle_iteration_next, NULL, GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT, 0}, + {&handle_iteration_stop, NULL, + GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP, 0}, {NULL, NULL, 0, 0} }; diff --git a/src/namestore/namestore.h b/src/namestore/namestore.h index 17229ab24..5b4c02385 100644 --- a/src/namestore/namestore.h +++ b/src/namestore/namestore.h @@ -47,7 +47,7 @@ #define GNUNET_MESSAGE_TYPE_NAMESTORE_DISCONNECT 449 /** - * Sign name and records + * Create a signature based on name and records * * @param key the private key * @param name the name @@ -57,13 +57,16 @@ * @return the signature */ struct GNUNET_CRYPTO_RsaSignature * -GNUNET_NAMESTORE_create_signature (const struct GNUNET_CRYPTO_RsaPrivateKey *key, const char *name, struct GNUNET_NAMESTORE_RecordData *rd, unsigned int rd_count); +GNUNET_NAMESTORE_create_signature (const struct GNUNET_CRYPTO_RsaPrivateKey *key, + const char *name, + const struct GNUNET_NAMESTORE_RecordData *rd, + unsigned int rd_count); /** * Compares if two records are equal * - * @param a record - * @param b record + * @param a Record a + * @param b Record b * * @return GNUNET_YES or GNUNET_NO */ @@ -71,10 +74,12 @@ int GNUNET_NAMESTORE_records_cmp (const struct GNUNET_NAMESTORE_RecordData *a, const struct GNUNET_NAMESTORE_RecordData *b); + GNUNET_NETWORK_STRUCT_BEGIN /** * A GNS record serialized for network transmission. - * layout is [struct GNUNET_NAMESTORE_NetworkRecord][char[data_size] data] + * + * Layout is [struct GNUNET_NAMESTORE_NetworkRecord][char[data_size] data] */ struct GNUNET_NAMESTORE_NetworkRecord { @@ -114,24 +119,6 @@ struct StartMessage }; -/** - * Connect to namestore service. FIXME: UNNECESSARY. - */ -struct DisconnectMessage -{ - - /** - * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_DISCONNECT - */ - struct GNUNET_MessageHeader header; - - /** - * Drop namestore? - * GNUNET_YES or _NO in NBO - */ - uint32_t drop; -}; - /** * Generic namestore message with op id @@ -152,7 +139,7 @@ struct GNUNET_NAMESTORE_Header /** - * Connect to namestore service + * Lookup a name in the namestore */ struct LookupNameMessage { @@ -179,8 +166,6 @@ struct LookupNameMessage /** * Lookup response - * Memory layout: - * [struct LookupNameResponseMessage][char *name][rc_count * struct GNUNET_NAMESTORE_RecordData] */ struct LookupNameResponseMessage { @@ -189,14 +174,31 @@ struct LookupNameResponseMessage */ struct GNUNET_NAMESTORE_Header gns_header; + /** + * Expiration time + */ struct GNUNET_TIME_AbsoluteNBO expire; + + /** + * Name length + */ uint16_t name_len; + /** + * Bytes of serialized record data + */ uint16_t rd_len; + /** + * Number of records contained + */ uint16_t rd_count; + /** + * Is the signature valid + * GNUNET_YES or GNUNET_NO + */ int16_t contains_sig; /** @@ -205,18 +207,17 @@ struct LookupNameResponseMessage struct GNUNET_CRYPTO_RsaSignature signature; /** - * + * The public key for the name */ struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key; /* 0-terminated name and serialized record data */ + /* rd_len bytes serialized record data */ }; /** * Put a record to the namestore - * Memory layout: - * [struct RecordPutMessage][char *name][rc_count * struct GNUNET_NAMESTORE_RecordData] */ struct RecordPutMessage { @@ -226,17 +227,17 @@ struct RecordPutMessage struct GNUNET_NAMESTORE_Header gns_header; /** - * + * Expiration time */ struct GNUNET_TIME_AbsoluteNBO expire; /** - * name length + * Name length */ uint16_t name_len; /** - * Length of serialized rd data + * Length of serialized record data */ uint16_t rd_len; @@ -251,12 +252,12 @@ struct RecordPutMessage uint16_t reserved; /** - * + * The signature */ struct GNUNET_CRYPTO_RsaSignature signature; /** - * + * The public key */ struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key; @@ -297,12 +298,12 @@ struct RecordCreateMessage struct GNUNET_TIME_AbsoluteNBO expire; /** - * name length + * Name length */ uint16_t name_len; /** - * Record data length + * Length of serialized record data */ uint16_t rd_len; @@ -316,13 +317,16 @@ struct RecordCreateMessage */ uint16_t pkey_len; - /* followed by: name and serialized record data --- PK??? */ + /* followed by: + * GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded private key with length pkey_len + * name with length name_len + * serialized record data with length rd_len + * */ }; /** * Create a record to the namestore response - * Memory layout: */ struct RecordCreateResponseMessage { @@ -335,14 +339,12 @@ struct RecordCreateResponseMessage * name length: GNUNET_NO already exists, GNUNET_YES on success, GNUNET_SYSERR error */ int32_t op_result; - }; /** * Remove a record from the namestore * Memory layout: - * [struct RecordRemoveMessage][char *name][struct GNUNET_NAMESTORE_RecordData] */ struct RecordRemoveMessage { @@ -367,9 +369,15 @@ struct RecordRemoveMessage uint16_t rd_count; /** - * Length of pubkey + * Length of private key */ - uint16_t key_len; + uint16_t pkey_len; + + /* followed by: + * GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded private key with length pkey_len + * name with length name_len + * serialized record data with length rd_len + * */ }; @@ -396,10 +404,13 @@ struct RecordRemoveResponseMessage /** - * Connect to namestore service + * Lookup a name for a zone hash */ struct ZoneToNameMessage { + /** + * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME + */ struct GNUNET_NAMESTORE_Header gns_header; /** @@ -414,28 +425,46 @@ struct ZoneToNameMessage }; /** - * Connect to namestore service + * Respone for zone to name lookup */ struct ZoneToNameResponseMessage { + /** + * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE + */ struct GNUNET_NAMESTORE_Header gns_header; + /** + * Record block expiration + */ struct GNUNET_TIME_AbsoluteNBO expire; + /** + * Length of the name + */ uint16_t name_len; + /** + * Length of serialized record data + */ uint16_t rd_len; + /** + * Number of records contained + */ uint16_t rd_count; /* result in NBO: GNUNET_OK on success, GNUNET_NO if there were no results, GNUNET_SYSERR on error */ int16_t res; /** - * + * Signature */ struct GNUNET_CRYPTO_RsaSignature signature; + /** + * Publik key + */ struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded zone_key; }; @@ -452,12 +481,20 @@ struct ZoneIterationStartMessage */ struct GNUNET_NAMESTORE_Header gns_header; + /** + * Zone hash + */ GNUNET_HashCode zone; + /** + * Which flags must be included + */ uint16_t must_have_flags; + /** + * Which flags must not be included + */ uint16_t must_not_have_flags; - }; @@ -519,7 +556,7 @@ struct ZoneIterationResponseMessage struct GNUNET_CRYPTO_RsaSignature signature; /** - * + * The public key */ struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key; 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, "LOOKUP_NAME_RESPONSE"); struct GNUNET_NAMESTORE_Handle *h = qe->nsh; - struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key; char *name; char * rd_tmp; struct GNUNET_CRYPTO_RsaSignature *signature = NULL; - struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded dummy; struct GNUNET_TIME_Absolute expire; size_t exp_msg_len; size_t msg_len = 0; @@ -277,9 +275,7 @@ handle_lookup_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe, exp_msg_len = sizeof (struct LookupNameResponseMessage) + sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) + - name_len + - rd_len + - contains_sig * sizeof (struct GNUNET_CRYPTO_RsaSignature); + name_len + rd_len; if (msg_len != exp_msg_len) { @@ -288,11 +284,16 @@ handle_lookup_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe, GNUNET_break_op (0); return; } + if (name_len == 0) + { + GNUNET_break_op (0); + return; + } - zone_key = (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *) &msg[1]; - name = (char *) &zone_key[1]; + name = (char *) &msg[1]; rd_tmp = &name[name_len]; + /* deserialize records */ struct GNUNET_NAMESTORE_RecordData rd[rd_count]; GNUNET_NAMESTORE_records_deserialize(rd_len, rd_tmp, rd_count, rd); @@ -300,17 +301,11 @@ handle_lookup_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe, if (contains_sig == GNUNET_NO) signature = NULL; else - signature = (struct GNUNET_CRYPTO_RsaSignature *) &rd_tmp[rd_len]; - if (name_len == 0) - name = NULL; - - memset (&dummy, '0', sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); - if (0 == memcmp (zone_key, &dummy, sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded))) - zone_key = NULL; + signature = &msg->signature; if (qe->proc != NULL) { - qe->proc (qe->proc_cls, zone_key, expire, name, rd_count, (rd_count > 0) ? rd : NULL, signature); + qe->proc (qe->proc_cls, &msg->public_key, expire, name, rd_count, (rd_count > 0) ? rd : NULL, signature); } /* Operation done, remove */ @@ -482,11 +477,9 @@ handle_zone_to_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe, size_t name_len; size_t rd_ser_len; unsigned int rd_count; - int have_signature; char * name_tmp; char * rd_tmp; - struct GNUNET_CRYPTO_RsaSignature* sig_tmp; if (res == GNUNET_SYSERR) { @@ -507,22 +500,16 @@ handle_zone_to_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe, name_len = ntohs (msg->name_len); rd_count = ntohs (msg->rd_count); rd_ser_len = ntohs (msg->rd_len); - have_signature = ntohl (msg->contains_sig); expire = GNUNET_TIME_absolute_ntoh(msg->expire); name_tmp = (char *) &msg[1]; rd_tmp = &name_tmp[name_len]; - if (have_signature == GNUNET_YES) - sig_tmp = (struct GNUNET_CRYPTO_RsaSignature *) &rd_tmp[rd_ser_len]; - else - sig_tmp = NULL; struct GNUNET_NAMESTORE_RecordData rd[rd_count]; GNUNET_NAMESTORE_records_deserialize(rd_ser_len, rd_tmp, rd_count, rd); if (qe->proc != NULL) - qe->proc (qe->proc_cls, &msg->zone_key, expire, name_tmp, rd_count, rd, sig_tmp); - + qe->proc (qe->proc_cls, &msg->zone_key, expire, name_tmp, rd_count, rd, &msg->signature); } else GNUNET_break_op (0); @@ -869,12 +856,6 @@ GNUNET_NAMESTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg) return h; } -struct DisconnectContext -{ - struct GNUNET_NAMESTORE_Handle *h; - int drop; -}; - static void clean_up_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { @@ -917,36 +898,6 @@ clean_up_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) h = NULL; }; -static size_t -transmit_disconnect_to_namestore (void *cls, size_t size, void *buf) -{ - struct DisconnectContext * d_ctx = cls; - struct DisconnectMessage d_msg; - struct GNUNET_NAMESTORE_Handle *h = d_ctx->h; - int res; - - d_msg.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_DISCONNECT); - d_msg.header.size = htons (sizeof (struct DisconnectMessage)); - d_msg.drop = htonl (d_ctx->drop); - - h->th = NULL; - if ((size == 0) || (buf == NULL) || (size < sizeof (struct DisconnectMessage))) - { - GNUNET_break (0); - res = 0; - } - else - { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message to service \n", "NAMESTORE_DISCONNECT"); - memcpy (buf, &d_msg, sizeof (struct DisconnectMessage)); - res = sizeof (struct DisconnectMessage); - } - - GNUNET_SCHEDULER_add_now (&clean_up_task, h); - GNUNET_free (d_ctx); - return res; -} - /** * Disconnect from the namestore service (and free associated * resources). @@ -957,29 +908,8 @@ transmit_disconnect_to_namestore (void *cls, size_t size, void *buf) void GNUNET_NAMESTORE_disconnect (struct GNUNET_NAMESTORE_Handle *h, int drop) { - if (h->th != NULL) - { - GNUNET_CLIENT_notify_transmit_ready_cancel(h->th); - h->th = NULL; - } - if (h->client != NULL) - { - struct DisconnectContext *d_ctx = GNUNET_malloc (sizeof (struct DisconnectContext)); - d_ctx->h = h; - d_ctx->drop = drop; - - h->th = GNUNET_CLIENT_notify_transmit_ready (h->client, sizeof (struct DisconnectMessage), - GNUNET_TIME_UNIT_FOREVER_REL, - GNUNET_NO, &transmit_disconnect_to_namestore, - d_ctx); - } - else - { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Could not send disconnect notification to namestore service, we are not connected!\n"); - if (GNUNET_YES == drop) - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "NAMESTORE will not drop content\n"); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Disconnecting from namestore service\n"); GNUNET_SCHEDULER_add_now (&clean_up_task, h); - } } @@ -1016,7 +946,6 @@ GNUNET_NAMESTORE_record_put (struct GNUNET_NAMESTORE_Handle *h, struct PendingMessage *pe; /* pointer to elements */ - char * zone_key_tmp; char * rd_tmp; char * name_tmp; @@ -1061,22 +990,20 @@ GNUNET_NAMESTORE_record_put (struct GNUNET_NAMESTORE_Handle *h, pe->size = msg_size; pe->is_init = GNUNET_NO; msg = (struct RecordPutMessage *) &pe[1]; - zone_key_tmp = (char *) &msg[1]; - name_tmp = (char *) &zone_key_tmp[pubkey_len]; + name_tmp = (char *) &msg[1]; rd_tmp = &name_tmp[name_len]; msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT); msg->gns_header.header.size = htons (msg_size); msg->gns_header.r_id = htonl (rid); - msg->key_len = htons (pubkey_len); - memcpy (zone_key_tmp, zone_key, pubkey_len); msg->signature = *signature; msg->name_len = htons (name_len); - memcpy (name_tmp, name, name_len); msg->expire = GNUNET_TIME_absolute_hton (expire); msg->rd_len = htons (rd_ser_len); msg->rd_count = htons (rd_count); + msg->public_key = *zone_key; + memcpy (name_tmp, name, name_len); memcpy (rd_tmp, rd_ser, rd_ser_len); 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, msg->name_len = htons (name_len); msg->rd_len = htons (rd_ser_len); msg->rd_count = htons (1); - msg->key_len = htons (key_len); + msg->pkey_len = htons (key_len); memcpy (pkey_tmp, pkey_enc, key_len); memcpy (name_tmp, name, name_len); memcpy (rd_tmp, rd_ser, rd_ser_len); diff --git a/src/namestore/namestore_common.c b/src/namestore/namestore_common.c index c1b5ddc1e..aa4603232 100644 --- a/src/namestore/namestore_common.c +++ b/src/namestore/namestore_common.c @@ -206,7 +206,7 @@ GNUNET_NAMESTORE_records_deserialize (size_t len, struct GNUNET_CRYPTO_RsaSignature * GNUNET_NAMESTORE_create_signature (const struct GNUNET_CRYPTO_RsaPrivateKey *key, const char *name, - struct GNUNET_NAMESTORE_RecordData *rd, + const struct GNUNET_NAMESTORE_RecordData *rd, unsigned int rd_count) { struct GNUNET_CRYPTO_RsaSignature *sig = GNUNET_malloc(sizeof (struct GNUNET_CRYPTO_RsaSignature)); diff --git a/src/namestore/plugin_namestore_sqlite.c b/src/namestore/plugin_namestore_sqlite.c index 429426701..98f89b3da 100644 --- a/src/namestore/plugin_namestore_sqlite.c +++ b/src/namestore/plugin_namestore_sqlite.c @@ -480,7 +480,7 @@ namestore_sqlite_put_records (void *cls, GNUNET_CRYPTO_hash (name, name_len, &nh); memset (&zone_delegation, 0, sizeof (zone_delegation)); for (i=0;i