aboutsummaryrefslogtreecommitdiff
path: root/src/namestore/namestore_api.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-06-20 10:53:52 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-06-20 10:53:52 +0000
commitace68a1c47140651fe78396be2f07bce725aad49 (patch)
tree4af07dd713c28c17be89ed56828389fb8cc8d46c /src/namestore/namestore_api.c
parent39ee5bd7ed16e4c1308415daf55eb2bdd1584a8a (diff)
downloadgnunet-ace68a1c47140651fe78396be2f07bce725aad49.tar.gz
gnunet-ace68a1c47140651fe78396be2f07bce725aad49.zip
clean up and documentation for namestor API
Diffstat (limited to 'src/namestore/namestore_api.c')
-rw-r--r--src/namestore/namestore_api.c162
1 files changed, 80 insertions, 82 deletions
diff --git a/src/namestore/namestore_api.c b/src/namestore/namestore_api.c
index 83dc4dd33..7b333ca9c 100644
--- a/src/namestore/namestore_api.c
+++ b/src/namestore/namestore_api.c
@@ -60,7 +60,7 @@ struct GNUNET_NAMESTORE_QueueEntry
60 struct GNUNET_NAMESTORE_Handle *nsh; 60 struct GNUNET_NAMESTORE_Handle *nsh;
61 61
62 /** 62 /**
63 * 63 * Continuation to call
64 */ 64 */
65 GNUNET_NAMESTORE_ContinuationWithStatus cont; 65 GNUNET_NAMESTORE_ContinuationWithStatus cont;
66 66
@@ -79,13 +79,9 @@ struct GNUNET_NAMESTORE_QueueEntry
79 */ 79 */
80 void *proc_cls; 80 void *proc_cls;
81 81
82 /**
83 * stub data pointer (???)
84 */
85 char *data;
86 82
87 /** 83 /**
88 * 84 * The operation id this zone iteration operation has
89 */ 85 */
90 uint32_t op_id; 86 uint32_t op_id;
91 87
@@ -93,7 +89,7 @@ struct GNUNET_NAMESTORE_QueueEntry
93 89
94 90
95/** 91/**
96 * Zone iterator 92 * Handle for a zone iterator operation
97 */ 93 */
98struct GNUNET_NAMESTORE_ZoneIterator 94struct GNUNET_NAMESTORE_ZoneIterator
99{ 95{
@@ -114,7 +110,7 @@ struct GNUNET_NAMESTORE_ZoneIterator
114 struct GNUNET_NAMESTORE_Handle *h; 110 struct GNUNET_NAMESTORE_Handle *h;
115 111
116 /** 112 /**
117 * 113 * The continuation to call with the results
118 */ 114 */
119 GNUNET_NAMESTORE_RecordProcessor proc; 115 GNUNET_NAMESTORE_RecordProcessor proc;
120 116
@@ -124,30 +120,23 @@ struct GNUNET_NAMESTORE_ZoneIterator
124 void* proc_cls; 120 void* proc_cls;
125 121
126 /** 122 /**
127 * 123 * If this iterator iterates over a specific zone this value contains the
124 * short hash of the zone
128 */ 125 */
129 struct GNUNET_CRYPTO_ShortHashCode zone; 126 struct GNUNET_CRYPTO_ShortHashCode zone;
130 127
131 /** 128 /**
132 * 129 * The operation id this zone iteration operation has
133 */
134 uint32_t no_flags;
135
136 /**
137 *
138 */
139 uint32_t flags;
140
141 /**
142 *
143 */ 130 */
144 uint32_t op_id; 131 uint32_t op_id;
145 132
146 /** 133 /**
134 * GNUNET_YES if this iterator iterates over a specific zone
135 * GNUNET_NO if this iterator iterates over all zones
147 * 136 *
137 * Zone is stored 'GNUNET_CRYPTO_ShortHashCode zone';
148 */ 138 */
149 int has_zone; 139 int has_zone;
150
151}; 140};
152 141
153 142
@@ -242,67 +231,13 @@ struct GNUNET_NAMESTORE_Handle
242 int reconnect; 231 int reconnect;
243 232
244 /** 233 /**
245 * ??? 234 * The last operation id used for a NAMESTORE operation
246 */
247 uint32_t op_id;
248
249};
250
251
252/**
253 * ???
254 */
255struct GNUNET_NAMESTORE_SimpleRecord
256{
257 /**
258 * DLL
259 */
260 struct GNUNET_NAMESTORE_SimpleRecord *next;
261
262 /**
263 * DLL
264 */
265 struct GNUNET_NAMESTORE_SimpleRecord *prev;
266
267 /**
268 * ???
269 */
270 const char *name;
271
272 /**
273 * ???
274 */
275 const struct GNUNET_CRYPTO_ShortHashCode *zone;
276
277 /**
278 * ???
279 */
280 const void *data;
281
282 /**
283 * ???
284 */
285 struct GNUNET_TIME_Absolute expiration;
286
287 /**
288 * ???
289 */ 235 */
290 size_t data_size; 236 uint32_t last_op_id_used;
291
292 /**
293 * ???
294 */
295 enum GNUNET_NAMESTORE_RecordFlags flags;
296
297 /**
298 * ???
299 */
300 uint32_t record_type;
301 237
302}; 238};
303 239
304 240
305
306/** 241/**
307 * Disconnect from service and then reconnect. 242 * Disconnect from service and then reconnect.
308 * 243 *
@@ -312,6 +247,13 @@ static void
312force_reconnect (struct GNUNET_NAMESTORE_Handle *h); 247force_reconnect (struct GNUNET_NAMESTORE_Handle *h);
313 248
314 249
250/**
251 * Handle an incoming message of type 'GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE'
252 *
253 * @param qe the respective entry in the message queue
254 * @param msg the message we received
255 * @param size the message size
256 */
315static void 257static void
316handle_lookup_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe, 258handle_lookup_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
317 struct LookupNameResponseMessage * msg, 259 struct LookupNameResponseMessage * msg,
@@ -391,6 +333,13 @@ handle_lookup_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
391} 333}
392 334
393 335
336/**
337 * Handle an incoming message of type 'GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT_RESPONSE'
338 *
339 * @param qe the respective entry in the message queue
340 * @param msg the message we received
341 * @param size the message size
342 */
394static void 343static void
395handle_record_put_response (struct GNUNET_NAMESTORE_QueueEntry *qe, 344handle_record_put_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
396 struct RecordPutResponseMessage* msg, 345 struct RecordPutResponseMessage* msg,
@@ -430,6 +379,13 @@ handle_record_put_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
430} 379}
431 380
432 381
382/**
383 * Handle an incoming message of type 'GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE_RESPONSE'
384 *
385 * @param qe the respective entry in the message queue
386 * @param msg the message we received
387 * @param size the message size
388 */
433static void 389static void
434handle_record_create_response (struct GNUNET_NAMESTORE_QueueEntry *qe, 390handle_record_create_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
435 struct RecordCreateResponseMessage* msg, 391 struct RecordCreateResponseMessage* msg,
@@ -470,6 +426,13 @@ handle_record_create_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
470} 426}
471 427
472 428
429/**
430 * Handle an incoming message of type 'GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE_RESPONSE'
431 *
432 * @param qe the respective entry in the message queue
433 * @param msg the message we received
434 * @param size the message size
435 */
473static void 436static void
474handle_record_remove_response (struct GNUNET_NAMESTORE_QueueEntry *qe, 437handle_record_remove_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
475 struct RecordRemoveResponseMessage* msg, 438 struct RecordRemoveResponseMessage* msg,
@@ -535,6 +498,13 @@ handle_record_remove_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
535} 498}
536 499
537 500
501/**
502 * Handle an incoming message of type 'GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE'
503 *
504 * @param qe the respective entry in the message queue
505 * @param msg the message we received
506 * @param size the message size
507 */
538static void 508static void
539handle_zone_to_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe, 509handle_zone_to_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
540 struct ZoneToNameResponseMessage* msg, 510 struct ZoneToNameResponseMessage* msg,
@@ -603,6 +573,14 @@ handle_zone_to_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
603} 573}
604 574
605 575
576/**
577 * Handle incoming messages for record operations
578 *
579 * @param ze the respective zone iteration handle
580 * @param msg the message we received
581 * @param type the message type in HBO
582 * @param size the message size
583 */
606static void 584static void
607manage_record_operations (struct GNUNET_NAMESTORE_QueueEntry *qe, 585manage_record_operations (struct GNUNET_NAMESTORE_QueueEntry *qe,
608 const struct GNUNET_MessageHeader *msg, 586 const struct GNUNET_MessageHeader *msg,
@@ -658,6 +636,13 @@ manage_record_operations (struct GNUNET_NAMESTORE_QueueEntry *qe,
658} 636}
659 637
660 638
639/**
640 * Handle a response from NAMESTORE service for a zone iteration request
641 *
642 * @param ze the respective iterator for this operation
643 * @param msg the message containing the respoonse
644 * @param size the message size
645 */
661static void 646static void
662handle_zone_iteration_response (struct GNUNET_NAMESTORE_ZoneIterator *ze, 647handle_zone_iteration_response (struct GNUNET_NAMESTORE_ZoneIterator *ze,
663 struct ZoneIterationResponseMessage *msg, 648 struct ZoneIterationResponseMessage *msg,
@@ -730,6 +715,14 @@ handle_zone_iteration_response (struct GNUNET_NAMESTORE_ZoneIterator *ze,
730} 715}
731 716
732 717
718/**
719 * Handle incoming messages for zone iterations
720 *
721 * @param ze the respective zone iteration handle
722 * @param msg the message we received
723 * @param type the message type in HBO
724 * @param size the message size
725 */
733static void 726static void
734manage_zone_operations (struct GNUNET_NAMESTORE_ZoneIterator *ze, 727manage_zone_operations (struct GNUNET_NAMESTORE_ZoneIterator *ze,
735 const struct GNUNET_MessageHeader *msg, 728 const struct GNUNET_MessageHeader *msg,
@@ -794,7 +787,7 @@ process_namestore_message (void *cls, const struct GNUNET_MessageHeader *msg)
794 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received message type %i size %i op %u\n", type, size, r_id); 787 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received message type %i size %i op %u\n", type, size, r_id);
795 788
796 /* Find matching operation */ 789 /* Find matching operation */
797 if (r_id > h->op_id) 790 if (r_id > h->last_op_id_used)
798 { 791 {
799 /* No matching pending operation found */ 792 /* No matching pending operation found */
800 GNUNET_break_op (0); 793 GNUNET_break_op (0);
@@ -912,7 +905,7 @@ do_transmit (struct GNUNET_NAMESTORE_Handle *h)
912/** 905/**
913 * Reconnect to namestore service. 906 * Reconnect to namestore service.
914 * 907 *
915 * @param h the handle to the namestore service 908 * @param h the handle to the NAMESTORE service
916 */ 909 */
917static void 910static void
918reconnect (struct GNUNET_NAMESTORE_Handle *h) 911reconnect (struct GNUNET_NAMESTORE_Handle *h)
@@ -971,11 +964,16 @@ force_reconnect (struct GNUNET_NAMESTORE_Handle *h)
971} 964}
972 965
973 966
967/**
968 * Get an unused operation id to distinguish between namestore requests
969 * @param h the namestore handle
970 * @return operation id
971 */
974static uint32_t 972static uint32_t
975get_op_id (struct GNUNET_NAMESTORE_Handle *h) 973get_op_id (struct GNUNET_NAMESTORE_Handle *h)
976{ 974{
977 uint32_t op_id = h->op_id; 975 uint32_t op_id = h->last_op_id_used;
978 h->op_id ++; 976 h->last_op_id_used ++;
979 return op_id; 977 return op_id;
980} 978}
981 979
@@ -994,7 +992,7 @@ GNUNET_NAMESTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
994 h = GNUNET_malloc (sizeof (struct GNUNET_NAMESTORE_Handle)); 992 h = GNUNET_malloc (sizeof (struct GNUNET_NAMESTORE_Handle));
995 h->cfg = cfg; 993 h->cfg = cfg;
996 h->reconnect_task = GNUNET_SCHEDULER_add_now (&reconnect_task, h); 994 h->reconnect_task = GNUNET_SCHEDULER_add_now (&reconnect_task, h);
997 h->op_id = 0; 995 h->last_op_id_used = 0;
998 return h; 996 return h;
999} 997}
1000 998