summaryrefslogtreecommitdiff
path: root/src/namestore/namestore_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-06-19 21:14:47 +0000
committerChristian Grothoff <christian@grothoff.org>2012-06-19 21:14:47 +0000
commitbc6e260a1452b0de53e5568e668228ec068e2680 (patch)
treec2cdfdefc3b52781ed8c8e96030e53fe3391c602 /src/namestore/namestore_api.c
parent313d7741e03f767652a61265d1bfc8e2186ef98a (diff)
downloadgnunet-bc6e260a1452b0de53e5568e668228ec068e2680.tar.gz
gnunet-bc6e260a1452b0de53e5568e668228ec068e2680.zip
-starting a bit with namestore_api cleanup
Diffstat (limited to 'src/namestore/namestore_api.c')
-rw-r--r--src/namestore/namestore_api.c169
1 files changed, 133 insertions, 36 deletions
diff --git a/src/namestore/namestore_api.c b/src/namestore/namestore_api.c
index e216ad767..83dc4dd33 100644
--- a/src/namestore/namestore_api.c
+++ b/src/namestore/namestore_api.c
@@ -54,17 +54,41 @@ struct GNUNET_NAMESTORE_QueueEntry
54 */ 54 */
55 struct GNUNET_NAMESTORE_QueueEntry *prev; 55 struct GNUNET_NAMESTORE_QueueEntry *prev;
56 56
57 /**
58 * Main handle to access the namestore.
59 */
57 struct GNUNET_NAMESTORE_Handle *nsh; 60 struct GNUNET_NAMESTORE_Handle *nsh;
58 61
59 uint32_t op_id; 62 /**
60 63 *
64 */
61 GNUNET_NAMESTORE_ContinuationWithStatus cont; 65 GNUNET_NAMESTORE_ContinuationWithStatus cont;
66
67 /**
68 * Closure for 'cont'.
69 */
62 void *cont_cls; 70 void *cont_cls;
63 71
72 /**
73 * Function to call with the records we get back; or NULL.
74 */
64 GNUNET_NAMESTORE_RecordProcessor proc; 75 GNUNET_NAMESTORE_RecordProcessor proc;
76
77 /**
78 * Closure for 'proc'.
79 */
65 void *proc_cls; 80 void *proc_cls;
66 81
67 char *data; /*stub data pointer*/ 82 /**
83 * stub data pointer (???)
84 */
85 char *data;
86
87 /**
88 *
89 */
90 uint32_t op_id;
91
68}; 92};
69 93
70 94
@@ -84,15 +108,46 @@ struct GNUNET_NAMESTORE_ZoneIterator
84 */ 108 */
85 struct GNUNET_NAMESTORE_ZoneIterator *prev; 109 struct GNUNET_NAMESTORE_ZoneIterator *prev;
86 110
87 uint32_t op_id; 111 /**
88 112 * Main handle to access the namestore.
113 */
89 struct GNUNET_NAMESTORE_Handle *h; 114 struct GNUNET_NAMESTORE_Handle *h;
115
116 /**
117 *
118 */
90 GNUNET_NAMESTORE_RecordProcessor proc; 119 GNUNET_NAMESTORE_RecordProcessor proc;
120
121 /**
122 * Closure for 'proc'.
123 */
91 void* proc_cls; 124 void* proc_cls;
125
126 /**
127 *
128 */
92 struct GNUNET_CRYPTO_ShortHashCode zone; 129 struct GNUNET_CRYPTO_ShortHashCode zone;
130
131 /**
132 *
133 */
93 uint32_t no_flags; 134 uint32_t no_flags;
135
136 /**
137 *
138 */
94 uint32_t flags; 139 uint32_t flags;
140
141 /**
142 *
143 */
144 uint32_t op_id;
145
146 /**
147 *
148 */
95 int has_zone; 149 int has_zone;
150
96}; 151};
97 152
98 153
@@ -147,38 +202,56 @@ struct GNUNET_NAMESTORE_Handle
147 struct GNUNET_CLIENT_TransmitHandle *th; 202 struct GNUNET_CLIENT_TransmitHandle *th;
148 203
149 /** 204 /**
150 * Reconnect task 205 * Head of linked list of pending messages to send to the service
151 */ 206 */
152 GNUNET_SCHEDULER_TaskIdentifier reconnect_task; 207 struct PendingMessage * pending_head;
153 208
154 /** 209 /**
155 * Pending messages to send to the service 210 * Tail of linked list of pending messages to send to the service
156 */ 211 */
157
158 struct PendingMessage * pending_head;
159 struct PendingMessage * pending_tail; 212 struct PendingMessage * pending_tail;
160 213
161 /** 214 /**
162 * Should we reconnect to service due to some serious error? 215 * Head of pending namestore queue entries
163 */ 216 */
164 int reconnect; 217 struct GNUNET_NAMESTORE_QueueEntry * op_head;
165
166 218
167 /** 219 /**
168 * Pending namestore queue entries 220 * Tail of pending namestore queue entries
169 */ 221 */
170 struct GNUNET_NAMESTORE_QueueEntry * op_head;
171 struct GNUNET_NAMESTORE_QueueEntry * op_tail; 222 struct GNUNET_NAMESTORE_QueueEntry * op_tail;
172 223
173 uint32_t op_id;
174
175 /** 224 /**
176 * Pending namestore zone iterator entries 225 * Head of pending namestore zone iterator entries
177 */ 226 */
178 struct GNUNET_NAMESTORE_ZoneIterator * z_head; 227 struct GNUNET_NAMESTORE_ZoneIterator * z_head;
228
229 /**
230 * Tail of pending namestore zone iterator entries
231 */
179 struct GNUNET_NAMESTORE_ZoneIterator * z_tail; 232 struct GNUNET_NAMESTORE_ZoneIterator * z_tail;
233
234 /**
235 * Reconnect task
236 */
237 GNUNET_SCHEDULER_TaskIdentifier reconnect_task;
238
239 /**
240 * Should we reconnect to service due to some serious error?
241 */
242 int reconnect;
243
244 /**
245 * ???
246 */
247 uint32_t op_id;
248
180}; 249};
181 250
251
252/**
253 * ???
254 */
182struct GNUNET_NAMESTORE_SimpleRecord 255struct GNUNET_NAMESTORE_SimpleRecord
183{ 256{
184 /** 257 /**
@@ -191,13 +264,41 @@ struct GNUNET_NAMESTORE_SimpleRecord
191 */ 264 */
192 struct GNUNET_NAMESTORE_SimpleRecord *prev; 265 struct GNUNET_NAMESTORE_SimpleRecord *prev;
193 266
267 /**
268 * ???
269 */
194 const char *name; 270 const char *name;
271
272 /**
273 * ???
274 */
195 const struct GNUNET_CRYPTO_ShortHashCode *zone; 275 const struct GNUNET_CRYPTO_ShortHashCode *zone;
196 uint32_t record_type; 276
277 /**
278 * ???
279 */
280 const void *data;
281
282 /**
283 * ???
284 */
197 struct GNUNET_TIME_Absolute expiration; 285 struct GNUNET_TIME_Absolute expiration;
198 enum GNUNET_NAMESTORE_RecordFlags flags; 286
287 /**
288 * ???
289 */
199 size_t data_size; 290 size_t data_size;
200 const void *data; 291
292 /**
293 * ???
294 */
295 enum GNUNET_NAMESTORE_RecordFlags flags;
296
297 /**
298 * ???
299 */
300 uint32_t record_type;
301
201}; 302};
202 303
203 304
@@ -210,23 +311,15 @@ struct GNUNET_NAMESTORE_SimpleRecord
210static void 311static void
211force_reconnect (struct GNUNET_NAMESTORE_Handle *h); 312force_reconnect (struct GNUNET_NAMESTORE_Handle *h);
212 313
314
213static void 315static void
214handle_lookup_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe, 316handle_lookup_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
215 struct LookupNameResponseMessage * msg, 317 struct LookupNameResponseMessage * msg,
216 size_t size) 318 size_t size)
217{ 319{
218 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n",
219 "LOOKUP_NAME_RESPONSE");
220
221 struct GNUNET_NAMESTORE_Handle *h = qe->nsh; 320 struct GNUNET_NAMESTORE_Handle *h = qe->nsh;
222
223 /* Operation done, remove */
224 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe);
225
226
227 char *name; 321 char *name;
228 char * rd_tmp; 322 char * rd_tmp;
229
230 struct GNUNET_CRYPTO_RsaSignature *signature = NULL; 323 struct GNUNET_CRYPTO_RsaSignature *signature = NULL;
231 struct GNUNET_TIME_Absolute expire; 324 struct GNUNET_TIME_Absolute expire;
232 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *public_key_tmp; 325 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *public_key_tmp;
@@ -237,6 +330,10 @@ handle_lookup_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
237 int contains_sig = GNUNET_NO; 330 int contains_sig = GNUNET_NO;
238 int rd_count = 0; 331 int rd_count = 0;
239 332
333 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n",
334 "LOOKUP_NAME_RESPONSE");
335 /* Operation done, remove */
336 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe);
240 rd_len = ntohs (msg->rd_len); 337 rd_len = ntohs (msg->rd_len);
241 rd_count = ntohs (msg->rd_count); 338 rd_count = ntohs (msg->rd_count);
242 msg_len = ntohs (msg->gns_header.header.size); 339 msg_len = ntohs (msg->gns_header.header.size);
@@ -437,6 +534,7 @@ handle_record_remove_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
437 GNUNET_free (qe); 534 GNUNET_free (qe);
438} 535}
439 536
537
440static void 538static void
441handle_zone_to_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe, 539handle_zone_to_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
442 struct ZoneToNameResponseMessage* msg, 540 struct ZoneToNameResponseMessage* msg,
@@ -559,6 +657,7 @@ manage_record_operations (struct GNUNET_NAMESTORE_QueueEntry *qe,
559 } 657 }
560} 658}
561 659
660
562static void 661static void
563handle_zone_iteration_response (struct GNUNET_NAMESTORE_ZoneIterator *ze, 662handle_zone_iteration_response (struct GNUNET_NAMESTORE_ZoneIterator *ze,
564 struct ZoneIterationResponseMessage *msg, 663 struct ZoneIterationResponseMessage *msg,
@@ -653,6 +752,7 @@ manage_zone_operations (struct GNUNET_NAMESTORE_ZoneIterator *ze,
653 } 752 }
654} 753}
655 754
755
656/** 756/**
657 * Type of a function to call when we receive a message 757 * Type of a function to call when we receive a message
658 * from the service. 758 * from the service.
@@ -870,6 +970,7 @@ force_reconnect (struct GNUNET_NAMESTORE_Handle *h)
870 h); 970 h);
871} 971}
872 972
973
873static uint32_t 974static uint32_t
874get_op_id (struct GNUNET_NAMESTORE_Handle *h) 975get_op_id (struct GNUNET_NAMESTORE_Handle *h)
875{ 976{
@@ -878,6 +979,7 @@ get_op_id (struct GNUNET_NAMESTORE_Handle *h)
878 return op_id; 979 return op_id;
879} 980}
880 981
982
881/** 983/**
882 * Initialize the connection with the NAMESTORE service. 984 * Initialize the connection with the NAMESTORE service.
883 * 985 *
@@ -896,6 +998,7 @@ GNUNET_NAMESTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
896 return h; 998 return h;
897} 999}
898 1000
1001
899static void 1002static void
900clean_up_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 1003clean_up_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
901{ 1004{
@@ -1477,8 +1580,6 @@ GNUNET_NAMESTORE_zone_iteration_start (struct GNUNET_NAMESTORE_Handle *h,
1477 uint32_t rid = 0; 1580 uint32_t rid = 0;
1478 1581
1479 GNUNET_assert (NULL != h); 1582 GNUNET_assert (NULL != h);
1480
1481
1482 rid = get_op_id(h); 1583 rid = get_op_id(h);
1483 it = GNUNET_malloc (sizeof (struct GNUNET_NAMESTORE_ZoneIterator)); 1584 it = GNUNET_malloc (sizeof (struct GNUNET_NAMESTORE_ZoneIterator));
1484 it->h = h; 1585 it->h = h;
@@ -1523,8 +1624,6 @@ GNUNET_NAMESTORE_zone_iteration_start (struct GNUNET_NAMESTORE_Handle *h,
1523 msg->must_have_flags = ntohs (must_have_flags); 1624 msg->must_have_flags = ntohs (must_have_flags);
1524 msg->must_not_have_flags = ntohs (must_not_have_flags); 1625 msg->must_not_have_flags = ntohs (must_not_have_flags);
1525 1626
1526
1527
1528 /* transmit message */ 1627 /* transmit message */
1529 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe); 1628 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1530 do_transmit(h); 1629 do_transmit(h);
@@ -1637,10 +1736,8 @@ GNUNET_NAMESTORE_cancel (struct GNUNET_NAMESTORE_QueueEntry *qe)
1637 struct GNUNET_NAMESTORE_Handle *h = qe->nsh; 1736 struct GNUNET_NAMESTORE_Handle *h = qe->nsh;
1638 1737
1639 GNUNET_assert (qe != NULL); 1738 GNUNET_assert (qe != NULL);
1640
1641 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe); 1739 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe);
1642 GNUNET_free(qe); 1740 GNUNET_free(qe);
1643
1644} 1741}
1645 1742
1646/* end of namestore_api.c */ 1743/* end of namestore_api.c */