aboutsummaryrefslogtreecommitdiff
path: root/src/nse/nse_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-09-15 14:27:01 +0000
committerChristian Grothoff <christian@grothoff.org>2013-09-15 14:27:01 +0000
commitf8ef504cc5e9c2788cacddad202fec3f390f1980 (patch)
tree9eb6a2809dab0d0a9ff71129178d22cf3dadfea9 /src/nse/nse_api.c
parenteed7f472501226b6d6c4f32d3c88d14123f74236 (diff)
downloadgnunet-f8ef504cc5e9c2788cacddad202fec3f390f1980.tar.gz
gnunet-f8ef504cc5e9c2788cacddad202fec3f390f1980.zip
-minor NSE cleanup
Diffstat (limited to 'src/nse/nse_api.c')
-rw-r--r--src/nse/nse_api.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/nse/nse_api.c b/src/nse/nse_api.c
index 211071c0d..3542b5f8a 100644
--- a/src/nse/nse_api.c
+++ b/src/nse/nse_api.c
@@ -35,7 +35,7 @@
35#define LOG(kind,...) GNUNET_log_from (kind, "nse-api",__VA_ARGS__) 35#define LOG(kind,...) GNUNET_log_from (kind, "nse-api",__VA_ARGS__)
36 36
37/** 37/**
38 * Handle for the service. 38 * Handle for talking with the NSE service.
39 */ 39 */
40struct GNUNET_NSE_Handle 40struct GNUNET_NSE_Handle
41{ 41{
@@ -70,7 +70,7 @@ struct GNUNET_NSE_Handle
70 GNUNET_NSE_Callback recv_cb; 70 GNUNET_NSE_Callback recv_cb;
71 71
72 /** 72 /**
73 * Closure to pass to callback. 73 * Closure to pass to @e recv_cb callback.
74 */ 74 */
75 void *recv_cb_cls; 75 void *recv_cb_cls;
76 76
@@ -100,13 +100,14 @@ message_handler (void *cls, const struct GNUNET_MessageHeader *msg)
100 struct GNUNET_NSE_Handle *h = cls; 100 struct GNUNET_NSE_Handle *h = cls;
101 const struct GNUNET_NSE_ClientMessage *client_msg; 101 const struct GNUNET_NSE_ClientMessage *client_msg;
102 102
103 if (msg == NULL) 103 if (NULL == msg)
104 { 104 {
105 /* Error, timeout, death */ 105 /* Error, timeout, death */
106 GNUNET_CLIENT_disconnect (h->client); 106 GNUNET_CLIENT_disconnect (h->client);
107 h->client = NULL; 107 h->client = NULL;
108 h->reconnect_task = 108 h->reconnect_task =
109 GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h); 109 GNUNET_SCHEDULER_add_delayed (h->reconnect_delay,
110 &reconnect, h);
110 return; 111 return;
111 } 112 }
112 if ((ntohs (msg->size) != sizeof (struct GNUNET_NSE_ClientMessage)) || 113 if ((ntohs (msg->size) != sizeof (struct GNUNET_NSE_ClientMessage)) ||
@@ -124,7 +125,6 @@ message_handler (void *cls, const struct GNUNET_MessageHeader *msg)
124} 125}
125 126
126 127
127
128/** 128/**
129 * Reschedule a connect attempt to the service. 129 * Reschedule a connect attempt to the service.
130 * 130 *
@@ -159,10 +159,10 @@ reschedule_connect (struct GNUNET_NSE_Handle *h)
159/** 159/**
160 * Transmit START message to service. 160 * Transmit START message to service.
161 * 161 *
162 * @param cls unused 162 * @param cls the `struct GNUNET_NSE_Handle *`
163 * @param size number of bytes available in buf 163 * @param size number of bytes available in @a buf
164 * @param buf where to copy the message 164 * @param buf where to copy the message
165 * @return number of bytes copied to buf 165 * @return number of bytes copied to @a buf
166 */ 166 */
167static size_t 167static size_t
168send_start (void *cls, size_t size, void *buf) 168send_start (void *cls, size_t size, void *buf)
@@ -175,11 +175,14 @@ send_start (void *cls, size_t size, void *buf)
175 { 175 {
176 /* Connect error... */ 176 /* Connect error... */
177 LOG (GNUNET_ERROR_TYPE_DEBUG, 177 LOG (GNUNET_ERROR_TYPE_DEBUG,
178 "Error while trying to transmit `%s' request.\n", "START"); 178 "Error while trying to transmit `%s' request.\n",
179 "START");
179 reschedule_connect (h); 180 reschedule_connect (h);
180 return 0; 181 return 0;
181 } 182 }
182 LOG (GNUNET_ERROR_TYPE_DEBUG, "Transmitting `%s' request.\n", "START"); 183 LOG (GNUNET_ERROR_TYPE_DEBUG,
184 "Transmitting `%s' request.\n",
185 "START");
183 GNUNET_assert (size >= sizeof (struct GNUNET_MessageHeader)); 186 GNUNET_assert (size >= sizeof (struct GNUNET_MessageHeader));
184 187
185 msg = (struct GNUNET_MessageHeader *) buf; 188 msg = (struct GNUNET_MessageHeader *) buf;
@@ -194,11 +197,12 @@ send_start (void *cls, size_t size, void *buf)
194/** 197/**
195 * Try again to connect to network size estimation service. 198 * Try again to connect to network size estimation service.
196 * 199 *
197 * @param cls the handle to the transport service 200 * @param cls the `struct GNUNET_NSE_Handle *`
198 * @param tc scheduler context 201 * @param tc scheduler context
199 */ 202 */
200static void 203static void
201reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 204reconnect (void *cls,
205 const struct GNUNET_SCHEDULER_TaskContext *tc)
202{ 206{
203 struct GNUNET_NSE_Handle *h = cls; 207 struct GNUNET_NSE_Handle *h = cls;
204 208
@@ -223,8 +227,7 @@ reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
223 * 227 *
224 * @param cfg the configuration to use 228 * @param cfg the configuration to use
225 * @param func funtion to call with network size estimate 229 * @param func funtion to call with network size estimate
226 * @param func_cls closure to pass for network size estimate callback 230 * @param func_cls closure to pass to @a func
227 *
228 * @return handle to use 231 * @return handle to use
229 */ 232 */
230struct GNUNET_NSE_Handle * 233struct GNUNET_NSE_Handle *
@@ -234,7 +237,7 @@ GNUNET_NSE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
234 struct GNUNET_NSE_Handle *ret; 237 struct GNUNET_NSE_Handle *ret;
235 238
236 GNUNET_assert (func != NULL); 239 GNUNET_assert (func != NULL);
237 ret = GNUNET_malloc (sizeof (struct GNUNET_NSE_Handle)); 240 ret = GNUNET_new (struct GNUNET_NSE_Handle);
238 ret->cfg = cfg; 241 ret->cfg = cfg;
239 ret->recv_cb = func; 242 ret->recv_cb = func;
240 ret->recv_cb_cls = func_cls; 243 ret->recv_cb_cls = func_cls;