aboutsummaryrefslogtreecommitdiff
path: root/src/namestore
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-09-29 16:31:29 +0000
committerChristian Grothoff <christian@grothoff.org>2013-09-29 16:31:29 +0000
commit191782c428e1c9cc4216f139fbbb96a5614db4d2 (patch)
tree8bc75f482e31ff5d0727481b7b26c7715a56fe4b /src/namestore
parent3195b01c1be562d1896becdd5f12281796cf28c0 (diff)
downloadgnunet-191782c428e1c9cc4216f139fbbb96a5614db4d2.tar.gz
gnunet-191782c428e1c9cc4216f139fbbb96a5614db4d2.zip
-minor stylistic cleanup, doxygen
Diffstat (limited to 'src/namestore')
-rw-r--r--src/namestore/namestore_api.c98
1 files changed, 65 insertions, 33 deletions
diff --git a/src/namestore/namestore_api.c b/src/namestore/namestore_api.c
index f24e090ed..3875e3cbf 100644
--- a/src/namestore/namestore_api.c
+++ b/src/namestore/namestore_api.c
@@ -78,7 +78,7 @@ struct GNUNET_NAMESTORE_QueueEntry
78 GNUNET_NAMESTORE_RecordMonitor proc; 78 GNUNET_NAMESTORE_RecordMonitor proc;
79 79
80 /** 80 /**
81 * Closure for 'proc'. 81 * Closure for @e proc.
82 */ 82 */
83 void *proc_cls; 83 void *proc_cls;
84 84
@@ -88,7 +88,7 @@ struct GNUNET_NAMESTORE_QueueEntry
88 GNUNET_NAMESTORE_BlockProcessor block_proc; 88 GNUNET_NAMESTORE_BlockProcessor block_proc;
89 89
90 /** 90 /**
91 * Closure for 'block_proc'. 91 * Closure for @e block_proc.
92 */ 92 */
93 void *block_proc_cls; 93 void *block_proc_cls;
94 94
@@ -127,7 +127,7 @@ struct GNUNET_NAMESTORE_ZoneIterator
127 GNUNET_NAMESTORE_RecordMonitor proc; 127 GNUNET_NAMESTORE_RecordMonitor proc;
128 128
129 /** 129 /**
130 * Closure for 'proc'. 130 * Closure for @e proc.
131 */ 131 */
132 void* proc_cls; 132 void* proc_cls;
133 133
@@ -193,32 +193,32 @@ struct GNUNET_NAMESTORE_Handle
193 /** 193 /**
194 * Head of linked list of pending messages to send to the service 194 * Head of linked list of pending messages to send to the service
195 */ 195 */
196 struct PendingMessage * pending_head; 196 struct PendingMessage *pending_head;
197 197
198 /** 198 /**
199 * Tail of linked list of pending messages to send to the service 199 * Tail of linked list of pending messages to send to the service
200 */ 200 */
201 struct PendingMessage * pending_tail; 201 struct PendingMessage *pending_tail;
202 202
203 /** 203 /**
204 * Head of pending namestore queue entries 204 * Head of pending namestore queue entries
205 */ 205 */
206 struct GNUNET_NAMESTORE_QueueEntry * op_head; 206 struct GNUNET_NAMESTORE_QueueEntry *op_head;
207 207
208 /** 208 /**
209 * Tail of pending namestore queue entries 209 * Tail of pending namestore queue entries
210 */ 210 */
211 struct GNUNET_NAMESTORE_QueueEntry * op_tail; 211 struct GNUNET_NAMESTORE_QueueEntry *op_tail;
212 212
213 /** 213 /**
214 * Head of pending namestore zone iterator entries 214 * Head of pending namestore zone iterator entries
215 */ 215 */
216 struct GNUNET_NAMESTORE_ZoneIterator * z_head; 216 struct GNUNET_NAMESTORE_ZoneIterator *z_head;
217 217
218 /** 218 /**
219 * Tail of pending namestore zone iterator entries 219 * Tail of pending namestore zone iterator entries
220 */ 220 */
221 struct GNUNET_NAMESTORE_ZoneIterator * z_tail; 221 struct GNUNET_NAMESTORE_ZoneIterator *z_tail;
222 222
223 /** 223 /**
224 * Reconnect task 224 * Reconnect task
@@ -253,7 +253,8 @@ force_reconnect (struct GNUNET_NAMESTORE_Handle *h);
253 253
254 254
255/** 255/**
256 * Handle an incoming message of type #GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_BLOCK_RESPONSE. 256 * Handle an incoming message of type
257 * #GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_BLOCK_RESPONSE.
257 * 258 *
258 * @param qe the respective entry in the message queue 259 * @param qe the respective entry in the message queue
259 * @param msg the message we received 260 * @param msg the message we received
@@ -266,7 +267,8 @@ handle_lookup_block_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
266 size_t size) 267 size_t size)
267{ 268{
268 struct GNUNET_NAMESTORE_Block *block; 269 struct GNUNET_NAMESTORE_Block *block;
269 char buf[size + sizeof (struct GNUNET_NAMESTORE_Block) - sizeof (struct LookupBlockResponseMessage)]; 270 char buf[size + sizeof (struct GNUNET_NAMESTORE_Block)
271 - sizeof (struct LookupBlockResponseMessage)];
270 272
271 LOG (GNUNET_ERROR_TYPE_DEBUG, 273 LOG (GNUNET_ERROR_TYPE_DEBUG,
272 "Received `%s'\n", 274 "Received `%s'\n",
@@ -305,7 +307,8 @@ handle_lookup_block_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
305 307
306 308
307/** 309/**
308 * Handle an incoming message of type #GNUNET_MESSAGE_TYPE_NAMESTORE_BLOCK_CACHE_RESPONSE 310 * Handle an incoming message of type
311 * #GNUNET_MESSAGE_TYPE_NAMESTORE_BLOCK_CACHE_RESPONSE
309 * 312 *
310 * @param qe the respective entry in the message queue 313 * @param qe the respective entry in the message queue
311 * @param msg the message we received 314 * @param msg the message we received
@@ -319,18 +322,24 @@ handle_block_cache_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
319{ 322{
320 int res; 323 int res;
321 324
322 LOG (GNUNET_ERROR_TYPE_DEBUG, "Received `%s'\n", 325 LOG (GNUNET_ERROR_TYPE_DEBUG,
326 "Received `%s'\n",
323 "BLOCK_CACHE_RESPONSE"); 327 "BLOCK_CACHE_RESPONSE");
324 res = ntohl (msg->op_result); 328 res = ntohl (msg->op_result);
325 /* TODO: add actual error message from namestore to response... */ 329 /* TODO: add actual error message from namestore to response... */
326 if (NULL != qe->cont) 330 if (NULL != qe->cont)
327 qe->cont (qe->cont_cls, res, (GNUNET_OK == res) ? NULL : _("Namestore failed to cache block")); 331 qe->cont (qe->cont_cls,
332 res,
333 (GNUNET_OK == res) ?
334 NULL
335 : _("Namestore failed to cache block"));
328 return GNUNET_OK; 336 return GNUNET_OK;
329} 337}
330 338
331 339
332/** 340/**
333 * Handle an incoming message of type #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE 341 * Handle an incoming message of type
342 * #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE
334 * 343 *
335 * @param qe the respective entry in the message queue 344 * @param qe the respective entry in the message queue
336 * @param msg the message we received 345 * @param msg the message we received
@@ -361,7 +370,8 @@ handle_record_store_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
361 370
362 371
363/** 372/**
364 * Handle an incoming message of type #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT 373 * Handle an incoming message of type
374 * #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT
365 * 375 *
366 * @param qe the respective entry in the message queue 376 * @param qe the respective entry in the message queue
367 * @param msg the message we received 377 * @param msg the message we received
@@ -425,7 +435,8 @@ handle_record_result (struct GNUNET_NAMESTORE_QueueEntry *qe,
425 435
426 436
427/** 437/**
428 * Handle an incoming message of type #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE. 438 * Handle an incoming message of type
439 * #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE.
429 * 440 *
430 * @param qe the respective entry in the message queue 441 * @param qe the respective entry in the message queue
431 * @param msg the message we received 442 * @param msg the message we received
@@ -599,10 +610,12 @@ handle_zone_iteration_response (struct GNUNET_NAMESTORE_ZoneIterator *ze,
599 return GNUNET_SYSERR; 610 return GNUNET_SYSERR;
600 } 611 }
601 if ( (0 == name_len) && 612 if ( (0 == name_len) &&
602 (0 == (memcmp (&msg->private_key, &priv_dummy, sizeof (priv_dummy)))) ) 613 (0 == (memcmp (&msg->private_key,
614 &priv_dummy,
615 sizeof (priv_dummy)))) )
603 { 616 {
604 LOG (GNUNET_ERROR_TYPE_DEBUG, 617 LOG (GNUNET_ERROR_TYPE_DEBUG,
605 "Zone iteration is completed!\n"); 618 "Zone iteration completed!\n");
606 if (NULL != ze->proc) 619 if (NULL != ze->proc)
607 ze->proc (ze->proc_cls, NULL, NULL, 0, NULL); 620 ze->proc (ze->proc_cls, NULL, NULL, 0, NULL);
608 return GNUNET_NO; 621 return GNUNET_NO;
@@ -617,13 +630,19 @@ handle_zone_iteration_response (struct GNUNET_NAMESTORE_ZoneIterator *ze,
617 { 630 {
618 struct GNUNET_NAMESTORE_RecordData rd[rd_count]; 631 struct GNUNET_NAMESTORE_RecordData rd[rd_count];
619 632
620 if (GNUNET_OK != GNUNET_NAMESTORE_records_deserialize (rd_len, rd_ser_tmp, rd_count, rd)) 633 if (GNUNET_OK != GNUNET_NAMESTORE_records_deserialize (rd_len,
634 rd_ser_tmp,
635 rd_count,
636 rd))
621 { 637 {
622 GNUNET_break (0); 638 GNUNET_break (0);
623 return GNUNET_SYSERR; 639 return GNUNET_SYSERR;
624 } 640 }
625 if (NULL != ze->proc) 641 if (NULL != ze->proc)
626 ze->proc (ze->proc_cls, &msg->private_key, name_tmp, rd_count, rd); 642 ze->proc (ze->proc_cls,
643 &msg->private_key,
644 name_tmp,
645 rd_count, rd);
627 return GNUNET_YES; 646 return GNUNET_YES;
628 } 647 }
629} 648}
@@ -653,7 +672,9 @@ manage_zone_operations (struct GNUNET_NAMESTORE_ZoneIterator *ze,
653 GNUNET_break (0); 672 GNUNET_break (0);
654 return GNUNET_SYSERR; 673 return GNUNET_SYSERR;
655 } 674 }
656 return handle_zone_iteration_response (ze, (const struct RecordResultMessage *) msg, size); 675 return handle_zone_iteration_response (ze,
676 (const struct RecordResultMessage *) msg,
677 size);
657 default: 678 default:
658 GNUNET_break (0); 679 GNUNET_break (0);
659 return GNUNET_SYSERR; 680 return GNUNET_SYSERR;
@@ -691,7 +712,8 @@ process_namestore_message (void *cls,
691 if (size < sizeof (struct GNUNET_NAMESTORE_Header)) 712 if (size < sizeof (struct GNUNET_NAMESTORE_Header))
692 { 713 {
693 GNUNET_break_op (0); 714 GNUNET_break_op (0);
694 GNUNET_CLIENT_receive (h->client, &process_namestore_message, h, 715 GNUNET_CLIENT_receive (h->client,
716 &process_namestore_message, h,
695 GNUNET_TIME_UNIT_FOREVER_REL); 717 GNUNET_TIME_UNIT_FOREVER_REL);
696 return; 718 return;
697 } 719 }
@@ -772,10 +794,12 @@ do_transmit (struct GNUNET_NAMESTORE_Handle *h);
772 * @param cls the `struct GNUNET_NAMESTORE_Handle` 794 * @param cls the `struct GNUNET_NAMESTORE_Handle`
773 * @param size number of bytes we can transmit 795 * @param size number of bytes we can transmit
774 * @param buf where to copy the messages 796 * @param buf where to copy the messages
775 * @return number of bytes copied into buf 797 * @return number of bytes copied into @a buf
776 */ 798 */
777static size_t 799static size_t
778transmit_message_to_namestore (void *cls, size_t size, void *buf) 800transmit_message_to_namestore (void *cls,
801 size_t size,
802 void *buf)
779{ 803{
780 struct GNUNET_NAMESTORE_Handle *h = cls; 804 struct GNUNET_NAMESTORE_Handle *h = cls;
781 struct PendingMessage *p; 805 struct PendingMessage *p;
@@ -790,12 +814,15 @@ transmit_message_to_namestore (void *cls, size_t size, void *buf)
790 } 814 }
791 ret = 0; 815 ret = 0;
792 cbuf = buf; 816 cbuf = buf;
793 while ((NULL != (p = h->pending_head)) && (p->size <= size)) 817 while ( (NULL != (p = h->pending_head)) &&
818 (p->size <= size) )
794 { 819 {
795 memcpy (&cbuf[ret], &p[1], p->size); 820 memcpy (&cbuf[ret], &p[1], p->size);
796 ret += p->size; 821 ret += p->size;
797 size -= p->size; 822 size -= p->size;
798 GNUNET_CONTAINER_DLL_remove (h->pending_head, h->pending_tail, p); 823 GNUNET_CONTAINER_DLL_remove (h->pending_head,
824 h->pending_tail,
825 p);
799 if (GNUNET_NO == h->is_receiving) 826 if (GNUNET_NO == h->is_receiving)
800 { 827 {
801 h->is_receiving = GNUNET_YES; 828 h->is_receiving = GNUNET_YES;
@@ -856,7 +883,8 @@ reconnect (struct GNUNET_NAMESTORE_Handle *h)
856 * @param tc scheduler context 883 * @param tc scheduler context
857 */ 884 */
858static void 885static void
859reconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 886reconnect_task (void *cls,
887 const struct GNUNET_SCHEDULER_TaskContext *tc)
860{ 888{
861 struct GNUNET_NAMESTORE_Handle *h = cls; 889 struct GNUNET_NAMESTORE_Handle *h = cls;
862 890
@@ -1086,8 +1114,10 @@ GNUNET_NAMESTORE_records_store (struct GNUNET_NAMESTORE_Handle *h,
1086 name_tmp = (char *) &msg[1]; 1114 name_tmp = (char *) &msg[1];
1087 memcpy (name_tmp, label, name_len); 1115 memcpy (name_tmp, label, name_len);
1088 rd_ser = &name_tmp[name_len]; 1116 rd_ser = &name_tmp[name_len];
1089 GNUNET_break (rd_ser_len == GNUNET_NAMESTORE_records_serialize (rd_count, rd, rd_ser_len, rd_ser)); 1117 GNUNET_break (rd_ser_len ==
1090 1118 GNUNET_NAMESTORE_records_serialize (rd_count, rd,
1119 rd_ser_len,
1120 rd_ser));
1091 LOG (GNUNET_ERROR_TYPE_DEBUG, 1121 LOG (GNUNET_ERROR_TYPE_DEBUG,
1092 "Sending `%s' message for name `%s' with size %u and %u records\n", 1122 "Sending `%s' message for name `%s' with size %u and %u records\n",
1093 "NAMESTORE_RECORD_STORE", label, msg_size, 1123 "NAMESTORE_RECORD_STORE", label, msg_size,
@@ -1156,7 +1186,7 @@ GNUNET_NAMESTORE_lookup_block (struct GNUNET_NAMESTORE_Handle *h,
1156 * @param value_zone public key of the target zone (value), never NULL 1186 * @param value_zone public key of the target zone (value), never NULL
1157 * @param proc function to call on the matching records, or with 1187 * @param proc function to call on the matching records, or with
1158 * NULL (rd_count == 0) if there are no matching records 1188 * NULL (rd_count == 0) if there are no matching records
1159 * @param proc_cls closure for proc 1189 * @param proc_cls closure for @a proc
1160 * @return a handle that can be used to 1190 * @return a handle that can be used to
1161 * cancel 1191 * cancel
1162 */ 1192 */
@@ -1277,7 +1307,9 @@ GNUNET_NAMESTORE_zone_iterator_next (struct GNUNET_NAMESTORE_ZoneIterator *it)
1277 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT); 1307 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT);
1278 msg->gns_header.header.size = htons (msg_size); 1308 msg->gns_header.header.size = htons (msg_size);
1279 msg->gns_header.r_id = htonl (it->op_id); 1309 msg->gns_header.r_id = htonl (it->op_id);
1280 LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message\n", "ZONE_ITERATION_NEXT"); 1310 LOG (GNUNET_ERROR_TYPE_DEBUG,
1311 "Sending `%s' message\n",
1312 "ZONE_ITERATION_NEXT");
1281 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe); 1313 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1282 do_transmit(h); 1314 do_transmit(h);
1283} 1315}
@@ -1329,7 +1361,7 @@ GNUNET_NAMESTORE_cancel (struct GNUNET_NAMESTORE_QueueEntry *qe)
1329 struct GNUNET_NAMESTORE_Handle *h = qe->nsh; 1361 struct GNUNET_NAMESTORE_Handle *h = qe->nsh;
1330 1362
1331 GNUNET_assert (NULL != qe); 1363 GNUNET_assert (NULL != qe);
1332 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe); 1364 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, qe);
1333 GNUNET_free(qe); 1365 GNUNET_free(qe);
1334} 1366}
1335 1367