diff options
author | Philipp Tölke <toelke@in.tum.de> | 2010-11-02 21:40:01 +0000 |
---|---|---|
committer | Philipp Tölke <toelke@in.tum.de> | 2010-11-02 21:40:01 +0000 |
commit | 11c2830064ec60af2b84a9b7f885b2f9d31a1b0d (patch) | |
tree | b2a6542452d7ed9b0006f519fea239de4849176c /src/vpn/gnunet-daemon-vpn.c | |
parent | f0d0be799be9acd5fee5e0b1f39ea196a8f253b6 (diff) | |
download | gnunet-11c2830064ec60af2b84a9b7f885b2f9d31a1b0d.tar.gz gnunet-11c2830064ec60af2b84a9b7f885b2f9d31a1b0d.zip |
get rid of the unneeded "closure"-struct
Diffstat (limited to 'src/vpn/gnunet-daemon-vpn.c')
-rw-r--r-- | src/vpn/gnunet-daemon-vpn.c | 204 |
1 files changed, 127 insertions, 77 deletions
diff --git a/src/vpn/gnunet-daemon-vpn.c b/src/vpn/gnunet-daemon-vpn.c index cc2474f32..e84600e4a 100644 --- a/src/vpn/gnunet-daemon-vpn.c +++ b/src/vpn/gnunet-daemon-vpn.c | |||
@@ -43,42 +43,92 @@ | |||
43 | */ | 43 | */ |
44 | static int ret; | 44 | static int ret; |
45 | 45 | ||
46 | struct vpn_cls { | 46 | /** |
47 | struct GNUNET_DISK_PipeHandle* helper_in; // From the helper | 47 | * The scheduler to use throughout the daemon |
48 | struct GNUNET_DISK_PipeHandle* helper_out; // To the helper | 48 | */ |
49 | const struct GNUNET_DISK_FileHandle* fh_from_helper; | 49 | static struct GNUNET_SCHEDULER_Handle *sched; |
50 | const struct GNUNET_DISK_FileHandle* fh_to_helper; | ||
51 | 50 | ||
52 | struct GNUNET_SERVER_MessageStreamTokenizer* mst; | 51 | /** |
52 | * The configuration to use | ||
53 | */ | ||
54 | static const struct GNUNET_CONFIGURATION_Handle *cfg; | ||
53 | 55 | ||
54 | struct GNUNET_SCHEDULER_Handle *sched; | 56 | /** |
57 | * PipeHandle to receive data from the helper | ||
58 | */ | ||
59 | static struct GNUNET_DISK_PipeHandle* helper_in; | ||
55 | 60 | ||
56 | struct GNUNET_CLIENT_Connection *dns_connection; | 61 | /** |
57 | unsigned char restart_hijack; | 62 | * PipeHandle to send data to the helper |
63 | */ | ||
64 | static struct GNUNET_DISK_PipeHandle* helper_out; | ||
58 | 65 | ||
59 | pid_t helper_pid; | 66 | /** |
67 | * FileHandle to receive data from the helper | ||
68 | */ | ||
69 | static const struct GNUNET_DISK_FileHandle* fh_from_helper; | ||
60 | 70 | ||
61 | const struct GNUNET_CONFIGURATION_Handle *cfg; | 71 | /** |
72 | * FileHandle to send data to the helper | ||
73 | */ | ||
74 | static const struct GNUNET_DISK_FileHandle* fh_to_helper; | ||
62 | 75 | ||
63 | struct query_packet_list *head; | 76 | /** |
64 | struct query_packet_list *tail; | 77 | * The Message-Tokenizer that tokenizes the messages comming from the helper |
78 | */ | ||
79 | static struct GNUNET_SERVER_MessageStreamTokenizer* mst; | ||
65 | 80 | ||
66 | struct answer_packet_list *answer_proc_head; | 81 | /** |
67 | struct answer_packet_list *answer_proc_tail; | 82 | * The connection to the service-dns |
68 | }; | 83 | */ |
84 | static struct GNUNET_CLIENT_Connection *dns_connection; | ||
69 | 85 | ||
70 | static struct vpn_cls mycls; | 86 | /** |
87 | * A flag to show that the service-dns has to rehijack the outbound dns-packets | ||
88 | * | ||
89 | * This gets set when the helper restarts as the routing-tables are flushed when | ||
90 | * the interface vanishes. | ||
91 | */ | ||
92 | static unsigned char restart_hijack; | ||
93 | |||
94 | /** | ||
95 | * The process id of the helper | ||
96 | */ | ||
97 | static pid_t helper_pid; | ||
98 | |||
99 | /** | ||
100 | * a list of outgoing dns-query-packets | ||
101 | */ | ||
102 | static struct query_packet_list *head; | ||
103 | |||
104 | /** | ||
105 | * The last element of the list of outgoing dns-query-packets | ||
106 | */ | ||
107 | static struct query_packet_list *tail; | ||
108 | |||
109 | /** | ||
110 | * A list of processed dns-responses. | ||
111 | * | ||
112 | * "processed" means that the packet is complete and can be sent out via udp | ||
113 | * directly | ||
114 | */ | ||
115 | static struct answer_packet_list *answer_proc_head; | ||
116 | |||
117 | /** | ||
118 | * The last element of the list of processed dns-responses. | ||
119 | */ | ||
120 | static struct answer_packet_list *answer_proc_tail; | ||
71 | 121 | ||
72 | size_t send_query(void* cls, size_t size, void* buf); | 122 | size_t send_query(void* cls, size_t size, void* buf); |
73 | 123 | ||
74 | static void cleanup(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tskctx) { | 124 | static void cleanup(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tskctx) { |
75 | GNUNET_assert (0 != (tskctx->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)); | 125 | GNUNET_assert (0 != (tskctx->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)); |
76 | PLIBC_KILL(mycls.helper_pid, SIGTERM); | 126 | PLIBC_KILL(helper_pid, SIGTERM); |
77 | GNUNET_OS_process_wait(mycls.helper_pid); | 127 | GNUNET_OS_process_wait(helper_pid); |
78 | if (mycls.dns_connection != NULL) | 128 | if (dns_connection != NULL) |
79 | { | 129 | { |
80 | GNUNET_CLIENT_disconnect (mycls.dns_connection, GNUNET_NO); | 130 | GNUNET_CLIENT_disconnect (dns_connection, GNUNET_NO); |
81 | mycls.dns_connection = NULL; | 131 | dns_connection = NULL; |
82 | } | 132 | } |
83 | } | 133 | } |
84 | 134 | ||
@@ -90,39 +140,39 @@ static void start_helper_and_schedule(void *cls, | |||
90 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 140 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
91 | return; | 141 | return; |
92 | 142 | ||
93 | mycls.helper_in = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, GNUNET_NO); | 143 | helper_in = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, GNUNET_NO); |
94 | mycls.helper_out = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_NO, GNUNET_YES); | 144 | helper_out = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_NO, GNUNET_YES); |
95 | 145 | ||
96 | if (mycls.helper_in == NULL || mycls.helper_out == NULL) return; | 146 | if (helper_in == NULL || helper_out == NULL) return; |
97 | 147 | ||
98 | mycls.helper_pid = GNUNET_OS_start_process(mycls.helper_in, mycls.helper_out, "gnunet-helper-vpn", "gnunet-helper-vpn", NULL); | 148 | helper_pid = GNUNET_OS_start_process(helper_in, helper_out, "gnunet-helper-vpn", "gnunet-helper-vpn", NULL); |
99 | 149 | ||
100 | mycls.fh_from_helper = GNUNET_DISK_pipe_handle (mycls.helper_out, GNUNET_DISK_PIPE_END_READ); | 150 | fh_from_helper = GNUNET_DISK_pipe_handle (helper_out, GNUNET_DISK_PIPE_END_READ); |
101 | mycls.fh_to_helper = GNUNET_DISK_pipe_handle (mycls.helper_in, GNUNET_DISK_PIPE_END_WRITE); | 151 | fh_to_helper = GNUNET_DISK_pipe_handle (helper_in, GNUNET_DISK_PIPE_END_WRITE); |
102 | 152 | ||
103 | GNUNET_DISK_pipe_close_end(mycls.helper_out, GNUNET_DISK_PIPE_END_WRITE); | 153 | GNUNET_DISK_pipe_close_end(helper_out, GNUNET_DISK_PIPE_END_WRITE); |
104 | GNUNET_DISK_pipe_close_end(mycls.helper_in, GNUNET_DISK_PIPE_END_READ); | 154 | GNUNET_DISK_pipe_close_end(helper_in, GNUNET_DISK_PIPE_END_READ); |
105 | 155 | ||
106 | GNUNET_SCHEDULER_add_read_file (mycls.sched, GNUNET_TIME_UNIT_FOREVER_REL, mycls.fh_from_helper, &helper_read, NULL); | 156 | GNUNET_SCHEDULER_add_read_file (sched, GNUNET_TIME_UNIT_FOREVER_REL, fh_from_helper, &helper_read, NULL); |
107 | } | 157 | } |
108 | 158 | ||
109 | 159 | ||
110 | static void restart_helper(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tskctx) { | 160 | static void restart_helper(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tskctx) { |
111 | // Kill the helper | 161 | // Kill the helper |
112 | PLIBC_KILL(mycls.helper_pid, SIGKILL); | 162 | PLIBC_KILL(helper_pid, SIGKILL); |
113 | GNUNET_OS_process_wait(mycls.helper_pid); | 163 | GNUNET_OS_process_wait(helper_pid); |
114 | 164 | ||
115 | /* Tell the dns-service to rehijack the dns-port | 165 | /* Tell the dns-service to rehijack the dns-port |
116 | * The routing-table gets flushed if an interface disappears. | 166 | * The routing-table gets flushed if an interface disappears. |
117 | */ | 167 | */ |
118 | mycls.restart_hijack = 1; | 168 | restart_hijack = 1; |
119 | GNUNET_CLIENT_notify_transmit_ready(mycls.dns_connection, sizeof(struct GNUNET_MessageHeader), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, &send_query, NULL); | 169 | GNUNET_CLIENT_notify_transmit_ready(dns_connection, sizeof(struct GNUNET_MessageHeader), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, &send_query, NULL); |
120 | 170 | ||
121 | GNUNET_DISK_pipe_close(mycls.helper_in); | 171 | GNUNET_DISK_pipe_close(helper_in); |
122 | GNUNET_DISK_pipe_close(mycls.helper_out); | 172 | GNUNET_DISK_pipe_close(helper_out); |
123 | 173 | ||
124 | // Restart the helper | 174 | // Restart the helper |
125 | GNUNET_SCHEDULER_add_delayed (mycls.sched, GNUNET_TIME_UNIT_SECONDS, start_helper_and_schedule, NULL); | 175 | GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_UNIT_SECONDS, start_helper_and_schedule, NULL); |
126 | 176 | ||
127 | } | 177 | } |
128 | 178 | ||
@@ -132,16 +182,16 @@ static void helper_read(void* cls, const struct GNUNET_SCHEDULER_TaskContext* ts | |||
132 | if (tsdkctx->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) | 182 | if (tsdkctx->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) |
133 | return; | 183 | return; |
134 | 184 | ||
135 | int t = GNUNET_DISK_file_read(mycls.fh_from_helper, &buf, 65535); | 185 | int t = GNUNET_DISK_file_read(fh_from_helper, &buf, 65535); |
136 | if (t<=0) { | 186 | if (t<=0) { |
137 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Read error for header from vpn-helper: %m\n"); | 187 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Read error for header from vpn-helper: %m\n"); |
138 | GNUNET_SCHEDULER_add_now(mycls.sched, restart_helper, cls); | 188 | GNUNET_SCHEDULER_add_now(sched, restart_helper, cls); |
139 | return; | 189 | return; |
140 | } | 190 | } |
141 | 191 | ||
142 | /* FIXME */ GNUNET_SERVER_mst_receive(mycls.mst, NULL, buf, t, 0, 0); | 192 | /* FIXME */ GNUNET_SERVER_mst_receive(mst, NULL, buf, t, 0, 0); |
143 | 193 | ||
144 | GNUNET_SCHEDULER_add_read_file (mycls.sched, GNUNET_TIME_UNIT_FOREVER_REL, mycls.fh_from_helper, &helper_read, NULL); | 194 | GNUNET_SCHEDULER_add_read_file (sched, GNUNET_TIME_UNIT_FOREVER_REL, fh_from_helper, &helper_read, NULL); |
145 | } | 195 | } |
146 | 196 | ||
147 | static uint16_t calculate_ip_checksum(uint16_t* hdr, short len) { | 197 | static uint16_t calculate_ip_checksum(uint16_t* hdr, short len) { |
@@ -159,7 +209,7 @@ static uint16_t calculate_ip_checksum(uint16_t* hdr, short len) { | |||
159 | static void helper_write(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tsdkctx) { | 209 | static void helper_write(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tsdkctx) { |
160 | if (tsdkctx->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) | 210 | if (tsdkctx->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) |
161 | return; | 211 | return; |
162 | struct answer_packet_list* ans = mycls.answer_proc_head; | 212 | struct answer_packet_list* ans = answer_proc_head; |
163 | size_t len = ntohs(ans->pkt.hdr.size); | 213 | size_t len = ntohs(ans->pkt.hdr.size); |
164 | 214 | ||
165 | GNUNET_assert(ans->pkt.subtype == GNUNET_DNS_ANSWER_TYPE_IP); | 215 | GNUNET_assert(ans->pkt.subtype == GNUNET_DNS_ANSWER_TYPE_IP); |
@@ -199,21 +249,21 @@ static void helper_write(void* cls, const struct GNUNET_SCHEDULER_TaskContext* t | |||
199 | 249 | ||
200 | memcpy(&pkt->udp_dns.data, ans->pkt.data, data_len); | 250 | memcpy(&pkt->udp_dns.data, ans->pkt.data, data_len); |
201 | 251 | ||
202 | GNUNET_CONTAINER_DLL_remove (mycls.answer_proc_head, mycls.answer_proc_tail, ans); | 252 | GNUNET_CONTAINER_DLL_remove (answer_proc_head, answer_proc_tail, ans); |
203 | GNUNET_free(ans); | 253 | GNUNET_free(ans); |
204 | 254 | ||
205 | /* FIXME */ GNUNET_DISK_file_write(mycls.fh_to_helper, pkt, pkt_len); | 255 | /* FIXME */ GNUNET_DISK_file_write(fh_to_helper, pkt, pkt_len); |
206 | 256 | ||
207 | if (mycls.answer_proc_head != NULL) | 257 | if (answer_proc_head != NULL) |
208 | GNUNET_SCHEDULER_add_write_file (mycls.sched, GNUNET_TIME_UNIT_FOREVER_REL, mycls.fh_to_helper, &helper_write, NULL); | 258 | GNUNET_SCHEDULER_add_write_file (sched, GNUNET_TIME_UNIT_FOREVER_REL, fh_to_helper, &helper_write, NULL); |
209 | } | 259 | } |
210 | 260 | ||
211 | size_t send_query(void* cls, size_t size, void* buf) | 261 | size_t send_query(void* cls, size_t size, void* buf) |
212 | { | 262 | { |
213 | size_t len; | 263 | size_t len; |
214 | if (mycls.restart_hijack == 1) | 264 | if (restart_hijack == 1) |
215 | { | 265 | { |
216 | mycls.restart_hijack = 0; | 266 | restart_hijack = 0; |
217 | GNUNET_assert(sizeof(struct GNUNET_MessageHeader) >= size); | 267 | GNUNET_assert(sizeof(struct GNUNET_MessageHeader) >= size); |
218 | struct GNUNET_MessageHeader* hdr = buf; | 268 | struct GNUNET_MessageHeader* hdr = buf; |
219 | len = sizeof(struct GNUNET_MessageHeader); | 269 | len = sizeof(struct GNUNET_MessageHeader); |
@@ -222,20 +272,20 @@ size_t send_query(void* cls, size_t size, void* buf) | |||
222 | } | 272 | } |
223 | else | 273 | else |
224 | { | 274 | { |
225 | struct query_packet_list* query = mycls.head; | 275 | struct query_packet_list* query = head; |
226 | len = ntohs(query->pkt.hdr.size); | 276 | len = ntohs(query->pkt.hdr.size); |
227 | 277 | ||
228 | GNUNET_assert(len <= size); | 278 | GNUNET_assert(len <= size); |
229 | 279 | ||
230 | memcpy(buf, &query->pkt.hdr, len); | 280 | memcpy(buf, &query->pkt.hdr, len); |
231 | 281 | ||
232 | GNUNET_CONTAINER_DLL_remove (mycls.head, mycls.tail, query); | 282 | GNUNET_CONTAINER_DLL_remove (head, tail, query); |
233 | 283 | ||
234 | GNUNET_free(query); | 284 | GNUNET_free(query); |
235 | } | 285 | } |
236 | 286 | ||
237 | if (mycls.head != NULL || mycls.restart_hijack == 1) { | 287 | if (head != NULL || restart_hijack == 1) { |
238 | GNUNET_CLIENT_notify_transmit_ready(mycls.dns_connection, ntohs(mycls.head->pkt.hdr.size), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, &send_query, NULL); | 288 | GNUNET_CLIENT_notify_transmit_ready(dns_connection, ntohs(head->pkt.hdr.size), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, &send_query, NULL); |
239 | } | 289 | } |
240 | 290 | ||
241 | return len; | 291 | return len; |
@@ -279,10 +329,10 @@ static void message_token(void *cls, void *client, const struct GNUNET_MessageHe | |||
279 | query->pkt.src_port = udp->udp_hdr.spt; | 329 | query->pkt.src_port = udp->udp_hdr.spt; |
280 | memcpy(query->pkt.data, udp->data, ntohs(udp->udp_hdr.len) - 8); | 330 | memcpy(query->pkt.data, udp->data, ntohs(udp->udp_hdr.len) - 8); |
281 | 331 | ||
282 | GNUNET_CONTAINER_DLL_insert_after(mycls.head, mycls.tail, mycls.tail, query); | 332 | GNUNET_CONTAINER_DLL_insert_after(head, tail, tail, query); |
283 | 333 | ||
284 | if (mycls.dns_connection != NULL) | 334 | if (dns_connection != NULL) |
285 | /* struct GNUNET_CLIENT_TransmitHandle* th = */ GNUNET_CLIENT_notify_transmit_ready(mycls.dns_connection, len, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, &send_query, NULL); | 335 | /* struct GNUNET_CLIENT_TransmitHandle* th = */ GNUNET_CLIENT_notify_transmit_ready(dns_connection, len, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, &send_query, NULL); |
286 | } | 336 | } |
287 | } | 337 | } |
288 | 338 | ||
@@ -297,11 +347,11 @@ reconnect_to_service_dns (void *cls, | |||
297 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 347 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
298 | return; | 348 | return; |
299 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Connecting\n"); | 349 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Connecting\n"); |
300 | GNUNET_assert (mycls.dns_connection == NULL); | 350 | GNUNET_assert (dns_connection == NULL); |
301 | mycls.dns_connection = GNUNET_CLIENT_connect (mycls.sched, "dns", mycls.cfg); | 351 | dns_connection = GNUNET_CLIENT_connect (sched, "dns", cfg); |
302 | GNUNET_CLIENT_receive(mycls.dns_connection, &dns_answer_handler, NULL, GNUNET_TIME_UNIT_FOREVER_REL); | 352 | GNUNET_CLIENT_receive(dns_connection, &dns_answer_handler, NULL, GNUNET_TIME_UNIT_FOREVER_REL); |
303 | if (mycls.head != NULL) | 353 | if (head != NULL) |
304 | /* struct GNUNET_CLIENT_TransmitHandle* th = */ GNUNET_CLIENT_notify_transmit_ready(mycls.dns_connection, ntohs(mycls.head->pkt.hdr.size), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, &send_query, NULL); | 354 | /* struct GNUNET_CLIENT_TransmitHandle* th = */ GNUNET_CLIENT_notify_transmit_ready(dns_connection, ntohs(head->pkt.hdr.size), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, &send_query, NULL); |
305 | } | 355 | } |
306 | 356 | ||
307 | static void | 357 | static void |
@@ -332,9 +382,9 @@ process_answer(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tc) { | |||
332 | 382 | ||
333 | memcpy(&list->pkt, pkt, htons(pkt->hdr.size)); | 383 | memcpy(&list->pkt, pkt, htons(pkt->hdr.size)); |
334 | 384 | ||
335 | GNUNET_CONTAINER_DLL_insert_after(mycls.answer_proc_head, mycls.answer_proc_tail, mycls.answer_proc_tail, list); | 385 | GNUNET_CONTAINER_DLL_insert_after(answer_proc_head, answer_proc_tail, answer_proc_tail, list); |
336 | 386 | ||
337 | GNUNET_SCHEDULER_add_write_file (mycls.sched, GNUNET_TIME_UNIT_FOREVER_REL, mycls.fh_to_helper, &helper_write, NULL); | 387 | GNUNET_SCHEDULER_add_write_file (sched, GNUNET_TIME_UNIT_FOREVER_REL, fh_to_helper, &helper_write, NULL); |
338 | 388 | ||
339 | return; | 389 | return; |
340 | } | 390 | } |
@@ -344,9 +394,9 @@ dns_answer_handler(void* cls, const struct GNUNET_MessageHeader *msg) | |||
344 | { | 394 | { |
345 | if (msg == NULL) | 395 | if (msg == NULL) |
346 | { | 396 | { |
347 | GNUNET_CLIENT_disconnect(mycls.dns_connection, GNUNET_NO); | 397 | GNUNET_CLIENT_disconnect(dns_connection, GNUNET_NO); |
348 | mycls.dns_connection = NULL; | 398 | dns_connection = NULL; |
349 | GNUNET_SCHEDULER_add_delayed (mycls.sched, | 399 | GNUNET_SCHEDULER_add_delayed (sched, |
350 | GNUNET_TIME_UNIT_SECONDS, | 400 | GNUNET_TIME_UNIT_SECONDS, |
351 | &reconnect_to_service_dns, | 401 | &reconnect_to_service_dns, |
352 | NULL); | 402 | NULL); |
@@ -356,9 +406,9 @@ dns_answer_handler(void* cls, const struct GNUNET_MessageHeader *msg) | |||
356 | if (msg->type != htons(GNUNET_MESSAGE_TYPE_LOCAL_RESPONSE_DNS)) | 406 | if (msg->type != htons(GNUNET_MESSAGE_TYPE_LOCAL_RESPONSE_DNS)) |
357 | { | 407 | { |
358 | GNUNET_break (0); | 408 | GNUNET_break (0); |
359 | GNUNET_CLIENT_disconnect(mycls.dns_connection, GNUNET_NO); | 409 | GNUNET_CLIENT_disconnect(dns_connection, GNUNET_NO); |
360 | mycls.dns_connection = NULL; | 410 | dns_connection = NULL; |
361 | GNUNET_SCHEDULER_add_now (mycls.sched, | 411 | GNUNET_SCHEDULER_add_now (sched, |
362 | &reconnect_to_service_dns, | 412 | &reconnect_to_service_dns, |
363 | NULL); | 413 | NULL); |
364 | return; | 414 | return; |
@@ -367,8 +417,8 @@ dns_answer_handler(void* cls, const struct GNUNET_MessageHeader *msg) | |||
367 | 417 | ||
368 | memcpy(pkt, msg, ntohs(msg->size)); | 418 | memcpy(pkt, msg, ntohs(msg->size)); |
369 | 419 | ||
370 | GNUNET_SCHEDULER_add_now(mycls.sched, process_answer, pkt); | 420 | GNUNET_SCHEDULER_add_now(sched, process_answer, pkt); |
371 | GNUNET_CLIENT_receive(mycls.dns_connection, &dns_answer_handler, NULL, GNUNET_TIME_UNIT_FOREVER_REL); | 421 | GNUNET_CLIENT_receive(dns_connection, &dns_answer_handler, NULL, GNUNET_TIME_UNIT_FOREVER_REL); |
372 | } | 422 | } |
373 | 423 | ||
374 | /** | 424 | /** |
@@ -382,15 +432,15 @@ dns_answer_handler(void* cls, const struct GNUNET_MessageHeader *msg) | |||
382 | */ | 432 | */ |
383 | static void | 433 | static void |
384 | run (void *cls, | 434 | run (void *cls, |
385 | struct GNUNET_SCHEDULER_Handle *sched, | 435 | struct GNUNET_SCHEDULER_Handle *sched_, |
386 | char *const *args, | 436 | char *const *args, |
387 | const char *cfgfile, | 437 | const char *cfgfile, |
388 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 438 | const struct GNUNET_CONFIGURATION_Handle *cfg_) |
389 | { | 439 | { |
390 | mycls.sched = sched; | 440 | sched = sched_; |
391 | mycls.mst = GNUNET_SERVER_mst_create(&message_token, NULL); | 441 | mst = GNUNET_SERVER_mst_create(&message_token, NULL); |
392 | mycls.cfg = cfg; | 442 | cfg = cfg_; |
393 | mycls.restart_hijack = 0; | 443 | restart_hijack = 0; |
394 | GNUNET_SCHEDULER_add_now (sched, &reconnect_to_service_dns, NULL); | 444 | GNUNET_SCHEDULER_add_now (sched, &reconnect_to_service_dns, NULL); |
395 | GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_UNIT_FOREVER_REL, &cleanup, cls); | 445 | GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_UNIT_FOREVER_REL, &cleanup, cls); |
396 | GNUNET_SCHEDULER_add_now (sched, start_helper_and_schedule, NULL); | 446 | GNUNET_SCHEDULER_add_now (sched, start_helper_and_schedule, NULL); |