gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r13504 - gnunet/src/vpn


From: gnunet
Subject: [GNUnet-SVN] r13504 - gnunet/src/vpn
Date: Tue, 2 Nov 2010 22:40:01 +0100

Author: toelke
Date: 2010-11-02 22:40:01 +0100 (Tue, 02 Nov 2010)
New Revision: 13504

Modified:
   gnunet/src/vpn/gnunet-daemon-vpn.c
   gnunet/src/vpn/gnunet-service-dns.c
Log:
get rid of the unneeded "closure"-struct

Modified: gnunet/src/vpn/gnunet-daemon-vpn.c
===================================================================
--- gnunet/src/vpn/gnunet-daemon-vpn.c  2010-11-02 21:21:52 UTC (rev 13503)
+++ gnunet/src/vpn/gnunet-daemon-vpn.c  2010-11-02 21:40:01 UTC (rev 13504)
@@ -43,42 +43,92 @@
  */
 static int ret;
 
-struct vpn_cls {
-       struct GNUNET_DISK_PipeHandle* helper_in; // From the helper
-       struct GNUNET_DISK_PipeHandle* helper_out; // To the helper
-       const struct GNUNET_DISK_FileHandle* fh_from_helper;
-       const struct GNUNET_DISK_FileHandle* fh_to_helper;
+/**
+ * The scheduler to use throughout the daemon
+ */
+static struct GNUNET_SCHEDULER_Handle *sched;
 
-       struct GNUNET_SERVER_MessageStreamTokenizer* mst;
+/**
+ * The configuration to use
+ */
+static const struct GNUNET_CONFIGURATION_Handle *cfg;
 
-       struct GNUNET_SCHEDULER_Handle *sched;
+/**
+ * PipeHandle to receive data from the helper
+ */
+static struct GNUNET_DISK_PipeHandle* helper_in;
 
-       struct GNUNET_CLIENT_Connection *dns_connection;
-       unsigned char restart_hijack;
+/**
+ * PipeHandle to send data to the helper
+ */
+static struct GNUNET_DISK_PipeHandle* helper_out;
 
-       pid_t helper_pid;
+/**
+ * FileHandle to receive data from the helper
+ */
+static const struct GNUNET_DISK_FileHandle* fh_from_helper;
 
-       const struct GNUNET_CONFIGURATION_Handle *cfg;
+/**
+ * FileHandle to send data to the helper
+ */
+static const struct GNUNET_DISK_FileHandle* fh_to_helper;
 
-       struct query_packet_list *head;
-       struct query_packet_list *tail;
+/**
+ * The Message-Tokenizer that tokenizes the messages comming from the helper
+ */
+static struct GNUNET_SERVER_MessageStreamTokenizer* mst;
 
-       struct answer_packet_list *answer_proc_head;
-       struct answer_packet_list *answer_proc_tail;
-};
+/**
+ * The connection to the service-dns
+ */
+static struct GNUNET_CLIENT_Connection *dns_connection;
 
-static struct vpn_cls mycls;
+/**
+ * A flag to show that the service-dns has to rehijack the outbound dns-packets
+ *
+ * This gets set when the helper restarts as the routing-tables are flushed 
when
+ * the interface vanishes.
+ */
+static unsigned char restart_hijack;
 
+/**
+ * The process id of the helper
+ */
+static pid_t helper_pid;
+
+/**
+ * a list of outgoing dns-query-packets
+ */
+static struct query_packet_list *head;
+
+/**
+ * The last element of the list of outgoing dns-query-packets
+ */
+static struct query_packet_list *tail;
+
+/**
+ * A list of processed dns-responses.
+ *
+ * "processed" means that the packet is complete and can be sent out via udp
+ * directly
+ */
+static struct answer_packet_list *answer_proc_head;
+
+/**
+ * The last element of the list of processed dns-responses.
+ */
+static struct answer_packet_list *answer_proc_tail;
+
 size_t send_query(void* cls, size_t size, void* buf);
 
 static void cleanup(void* cls, const struct GNUNET_SCHEDULER_TaskContext* 
tskctx) {
   GNUNET_assert (0 != (tskctx->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN));
-  PLIBC_KILL(mycls.helper_pid, SIGTERM);
-  GNUNET_OS_process_wait(mycls.helper_pid);
-  if (mycls.dns_connection != NULL)
+  PLIBC_KILL(helper_pid, SIGTERM);
+  GNUNET_OS_process_wait(helper_pid);
+  if (dns_connection != NULL)
     {
-      GNUNET_CLIENT_disconnect (mycls.dns_connection, GNUNET_NO);
-      mycls.dns_connection = NULL;
+      GNUNET_CLIENT_disconnect (dns_connection, GNUNET_NO);
+      dns_connection = NULL;
     }
 }
 
@@ -90,39 +140,39 @@
        if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
          return;
 
-       mycls.helper_in = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, GNUNET_NO);
-       mycls.helper_out = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_NO, GNUNET_YES);
+       helper_in = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, GNUNET_NO);
+       helper_out = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_NO, GNUNET_YES);
 
-       if (mycls.helper_in == NULL || mycls.helper_out == NULL) return;
+       if (helper_in == NULL || helper_out == NULL) return;
 
-       mycls.helper_pid = GNUNET_OS_start_process(mycls.helper_in, 
mycls.helper_out, "gnunet-helper-vpn", "gnunet-helper-vpn", NULL);
+       helper_pid = GNUNET_OS_start_process(helper_in, helper_out, 
"gnunet-helper-vpn", "gnunet-helper-vpn", NULL);
 
-       mycls.fh_from_helper = GNUNET_DISK_pipe_handle (mycls.helper_out, 
GNUNET_DISK_PIPE_END_READ);
-       mycls.fh_to_helper = GNUNET_DISK_pipe_handle (mycls.helper_in, 
GNUNET_DISK_PIPE_END_WRITE);
+       fh_from_helper = GNUNET_DISK_pipe_handle (helper_out, 
GNUNET_DISK_PIPE_END_READ);
+       fh_to_helper = GNUNET_DISK_pipe_handle (helper_in, 
GNUNET_DISK_PIPE_END_WRITE);
 
-       GNUNET_DISK_pipe_close_end(mycls.helper_out, 
GNUNET_DISK_PIPE_END_WRITE);
-       GNUNET_DISK_pipe_close_end(mycls.helper_in, GNUNET_DISK_PIPE_END_READ);
+       GNUNET_DISK_pipe_close_end(helper_out, GNUNET_DISK_PIPE_END_WRITE);
+       GNUNET_DISK_pipe_close_end(helper_in, GNUNET_DISK_PIPE_END_READ);
 
-       GNUNET_SCHEDULER_add_read_file (mycls.sched, 
GNUNET_TIME_UNIT_FOREVER_REL, mycls.fh_from_helper, &helper_read, NULL);
+       GNUNET_SCHEDULER_add_read_file (sched, GNUNET_TIME_UNIT_FOREVER_REL, 
fh_from_helper, &helper_read, NULL);
 }
 
 
 static void restart_helper(void* cls, const struct 
GNUNET_SCHEDULER_TaskContext* tskctx) {
        // Kill the helper
-       PLIBC_KILL(mycls.helper_pid, SIGKILL);
-       GNUNET_OS_process_wait(mycls.helper_pid);
+       PLIBC_KILL(helper_pid, SIGKILL);
+       GNUNET_OS_process_wait(helper_pid);
 
        /* Tell the dns-service to rehijack the dns-port
         * The routing-table gets flushed if an interface disappears.
         */
-       mycls.restart_hijack = 1;
-       GNUNET_CLIENT_notify_transmit_ready(mycls.dns_connection, sizeof(struct 
GNUNET_MessageHeader), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, &send_query, 
NULL);
+       restart_hijack = 1;
+       GNUNET_CLIENT_notify_transmit_ready(dns_connection, sizeof(struct 
GNUNET_MessageHeader), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, &send_query, 
NULL);
 
-       GNUNET_DISK_pipe_close(mycls.helper_in);
-       GNUNET_DISK_pipe_close(mycls.helper_out);
+       GNUNET_DISK_pipe_close(helper_in);
+       GNUNET_DISK_pipe_close(helper_out);
 
        // Restart the helper
-       GNUNET_SCHEDULER_add_delayed (mycls.sched, GNUNET_TIME_UNIT_SECONDS, 
start_helper_and_schedule, NULL);
+       GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_UNIT_SECONDS, 
start_helper_and_schedule, NULL);
 
 }
 
@@ -132,16 +182,16 @@
        if (tsdkctx->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)
                return;
 
-       int t = GNUNET_DISK_file_read(mycls.fh_from_helper, &buf, 65535);
+       int t = GNUNET_DISK_file_read(fh_from_helper, &buf, 65535);
        if (t<=0) {
                GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Read error for header 
from vpn-helper: %m\n");
-               GNUNET_SCHEDULER_add_now(mycls.sched, restart_helper, cls);
+               GNUNET_SCHEDULER_add_now(sched, restart_helper, cls);
                return;
        }
 
-       /* FIXME */ GNUNET_SERVER_mst_receive(mycls.mst, NULL, buf, t, 0, 0);
+       /* FIXME */ GNUNET_SERVER_mst_receive(mst, NULL, buf, t, 0, 0);
 
-       GNUNET_SCHEDULER_add_read_file (mycls.sched, 
GNUNET_TIME_UNIT_FOREVER_REL, mycls.fh_from_helper, &helper_read, NULL);
+       GNUNET_SCHEDULER_add_read_file (sched, GNUNET_TIME_UNIT_FOREVER_REL, 
fh_from_helper, &helper_read, NULL);
 }
 
 static uint16_t calculate_ip_checksum(uint16_t* hdr, short len) {
@@ -159,7 +209,7 @@
 static void helper_write(void* cls, const struct GNUNET_SCHEDULER_TaskContext* 
tsdkctx) {
        if (tsdkctx->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)
                return;
-       struct answer_packet_list* ans = mycls.answer_proc_head;
+       struct answer_packet_list* ans = answer_proc_head;
        size_t len = ntohs(ans->pkt.hdr.size);
 
        GNUNET_assert(ans->pkt.subtype == GNUNET_DNS_ANSWER_TYPE_IP);
@@ -199,21 +249,21 @@
 
        memcpy(&pkt->udp_dns.data, ans->pkt.data, data_len);
        
-       GNUNET_CONTAINER_DLL_remove (mycls.answer_proc_head, 
mycls.answer_proc_tail, ans);
+       GNUNET_CONTAINER_DLL_remove (answer_proc_head, answer_proc_tail, ans);
        GNUNET_free(ans);
 
-       /* FIXME */ GNUNET_DISK_file_write(mycls.fh_to_helper, pkt, pkt_len);
+       /* FIXME */ GNUNET_DISK_file_write(fh_to_helper, pkt, pkt_len);
 
-       if (mycls.answer_proc_head != NULL)
-               GNUNET_SCHEDULER_add_write_file (mycls.sched, 
GNUNET_TIME_UNIT_FOREVER_REL, mycls.fh_to_helper, &helper_write, NULL);
+       if (answer_proc_head != NULL)
+               GNUNET_SCHEDULER_add_write_file (sched, 
GNUNET_TIME_UNIT_FOREVER_REL, fh_to_helper, &helper_write, NULL);
 }
 
 size_t send_query(void* cls, size_t size, void* buf)
 {
   size_t len;
-  if (mycls.restart_hijack == 1)
+  if (restart_hijack == 1)
     {
-      mycls.restart_hijack = 0;
+      restart_hijack = 0;
       GNUNET_assert(sizeof(struct GNUNET_MessageHeader) >= size);
       struct GNUNET_MessageHeader* hdr = buf;
       len = sizeof(struct GNUNET_MessageHeader);
@@ -222,20 +272,20 @@
     }
   else
     {
-       struct query_packet_list* query = mycls.head;
+       struct query_packet_list* query = head;
        len = ntohs(query->pkt.hdr.size);
 
        GNUNET_assert(len <= size);
 
        memcpy(buf, &query->pkt.hdr, len);
 
-       GNUNET_CONTAINER_DLL_remove (mycls.head, mycls.tail, query);
+       GNUNET_CONTAINER_DLL_remove (head, tail, query);
 
        GNUNET_free(query);
     }
 
-       if (mycls.head != NULL || mycls.restart_hijack == 1) {
-               GNUNET_CLIENT_notify_transmit_ready(mycls.dns_connection, 
ntohs(mycls.head->pkt.hdr.size), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, 
&send_query, NULL);
+       if (head != NULL || restart_hijack == 1) {
+               GNUNET_CLIENT_notify_transmit_ready(dns_connection, 
ntohs(head->pkt.hdr.size), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, 
&send_query, NULL);
        }
 
        return len;
@@ -279,10 +329,10 @@
                        query->pkt.src_port = udp->udp_hdr.spt;
                        memcpy(query->pkt.data, udp->data, 
ntohs(udp->udp_hdr.len) - 8);
 
-                       GNUNET_CONTAINER_DLL_insert_after(mycls.head, 
mycls.tail, mycls.tail, query);
+                       GNUNET_CONTAINER_DLL_insert_after(head, tail, tail, 
query);
 
-                       if (mycls.dns_connection != NULL)
-                         /* struct GNUNET_CLIENT_TransmitHandle* th = */ 
GNUNET_CLIENT_notify_transmit_ready(mycls.dns_connection, len, 
GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, &send_query, NULL);
+                       if (dns_connection != NULL)
+                         /* struct GNUNET_CLIENT_TransmitHandle* th = */ 
GNUNET_CLIENT_notify_transmit_ready(dns_connection, len, 
GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, &send_query, NULL);
                }
        }
 
@@ -297,11 +347,11 @@
   if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
     return;
   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Connecting\n");
-  GNUNET_assert (mycls.dns_connection == NULL);
-  mycls.dns_connection = GNUNET_CLIENT_connect (mycls.sched, "dns", 
mycls.cfg); 
-  GNUNET_CLIENT_receive(mycls.dns_connection, &dns_answer_handler, NULL, 
GNUNET_TIME_UNIT_FOREVER_REL);
-  if (mycls.head != NULL)
-    /* 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);
+  GNUNET_assert (dns_connection == NULL);
+  dns_connection = GNUNET_CLIENT_connect (sched, "dns", cfg);
+  GNUNET_CLIENT_receive(dns_connection, &dns_answer_handler, NULL, 
GNUNET_TIME_UNIT_FOREVER_REL);
+  if (head != NULL)
+    /* 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);
 }
 
 static void
@@ -332,9 +382,9 @@
 
        memcpy(&list->pkt, pkt, htons(pkt->hdr.size));
 
-       GNUNET_CONTAINER_DLL_insert_after(mycls.answer_proc_head, 
mycls.answer_proc_tail, mycls.answer_proc_tail, list);
+       GNUNET_CONTAINER_DLL_insert_after(answer_proc_head, answer_proc_tail, 
answer_proc_tail, list);
 
-       GNUNET_SCHEDULER_add_write_file (mycls.sched, 
GNUNET_TIME_UNIT_FOREVER_REL, mycls.fh_to_helper, &helper_write, NULL);
+       GNUNET_SCHEDULER_add_write_file (sched, GNUNET_TIME_UNIT_FOREVER_REL, 
fh_to_helper, &helper_write, NULL);
 
        return;
 }
@@ -344,9 +394,9 @@
 {
   if (msg == NULL)
     {
-      GNUNET_CLIENT_disconnect(mycls.dns_connection, GNUNET_NO);
-      mycls.dns_connection = NULL;
-      GNUNET_SCHEDULER_add_delayed (mycls.sched,
+      GNUNET_CLIENT_disconnect(dns_connection, GNUNET_NO);
+      dns_connection = NULL;
+      GNUNET_SCHEDULER_add_delayed (sched,
                                    GNUNET_TIME_UNIT_SECONDS,
                                    &reconnect_to_service_dns,
                                    NULL);
@@ -356,9 +406,9 @@
   if (msg->type != htons(GNUNET_MESSAGE_TYPE_LOCAL_RESPONSE_DNS)) 
     {
       GNUNET_break (0);
-      GNUNET_CLIENT_disconnect(mycls.dns_connection, GNUNET_NO);
-      mycls.dns_connection = NULL;
-      GNUNET_SCHEDULER_add_now (mycls.sched,
+      GNUNET_CLIENT_disconnect(dns_connection, GNUNET_NO);
+      dns_connection = NULL;
+      GNUNET_SCHEDULER_add_now (sched,
                                &reconnect_to_service_dns,
                                NULL);
       return;
@@ -367,8 +417,8 @@
 
   memcpy(pkt, msg, ntohs(msg->size));
 
-  GNUNET_SCHEDULER_add_now(mycls.sched, process_answer, pkt);
-  GNUNET_CLIENT_receive(mycls.dns_connection, &dns_answer_handler, NULL, 
GNUNET_TIME_UNIT_FOREVER_REL);
+  GNUNET_SCHEDULER_add_now(sched, process_answer, pkt);
+  GNUNET_CLIENT_receive(dns_connection, &dns_answer_handler, NULL, 
GNUNET_TIME_UNIT_FOREVER_REL);
 }
 
 /**
@@ -382,15 +432,15 @@
  */
 static void
 run (void *cls,
-     struct GNUNET_SCHEDULER_Handle *sched,
+     struct GNUNET_SCHEDULER_Handle *sched_,
      char *const *args,
      const char *cfgfile,
-     const struct GNUNET_CONFIGURATION_Handle *cfg) 
+     const struct GNUNET_CONFIGURATION_Handle *cfg_)
 {
-  mycls.sched = sched;
-  mycls.mst = GNUNET_SERVER_mst_create(&message_token, NULL);
-  mycls.cfg = cfg;
-  mycls.restart_hijack = 0;
+  sched = sched_;
+  mst = GNUNET_SERVER_mst_create(&message_token, NULL);
+  cfg = cfg_;
+  restart_hijack = 0;
   GNUNET_SCHEDULER_add_now (sched, &reconnect_to_service_dns, NULL);
   GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_UNIT_FOREVER_REL, &cleanup, 
cls); 
   GNUNET_SCHEDULER_add_now (sched, start_helper_and_schedule, NULL);

Modified: gnunet/src/vpn/gnunet-service-dns.c
===================================================================
--- gnunet/src/vpn/gnunet-service-dns.c 2010-11-02 21:21:52 UTC (rev 13503)
+++ gnunet/src/vpn/gnunet-service-dns.c 2010-11-02 21:40:01 UTC (rev 13504)
@@ -39,21 +39,18 @@
 #include "gnunet_crypto_lib.h"
 #include "gnunet_signatures.h"
 
-struct dns_cls {
-       struct GNUNET_SCHEDULER_Handle *sched;
+static struct GNUNET_SCHEDULER_Handle *sched;
 
-       struct GNUNET_NETWORK_Handle *dnsout;
+static struct GNUNET_NETWORK_Handle *dnsout;
 
-       struct GNUNET_DHT_Handle *dht;
+static struct GNUNET_DHT_Handle *dht;
 
-       unsigned short dnsoutport;
+static unsigned short dnsoutport;
 
-       const struct GNUNET_CONFIGURATION_Handle *cfg;
+static const struct GNUNET_CONFIGURATION_Handle *cfg;
 
-       struct answer_packet_list *head;
-       struct answer_packet_list *tail;
-};
-static struct dns_cls mycls;
+static struct answer_packet_list *head;
+static struct answer_packet_list *tail;
 
 struct dns_query_id_state {
        unsigned valid:1;
@@ -163,7 +160,7 @@
 
   answer->pkt.addroffset = htons((unsigned short)((unsigned 
long)(&drec_data->data)-(unsigned long)(&answer->pkt)));
 
-  GNUNET_CONTAINER_DLL_insert_after(mycls.head, mycls.tail, mycls.tail, 
answer);
+  GNUNET_CONTAINER_DLL_insert_after(head, tail, tail, answer);
 
   GNUNET_SERVER_notify_transmit_ready(query_states[id].client,
                                      len,
@@ -178,8 +175,8 @@
  * This receives a GNUNET_MESSAGE_TYPE_REHIJACK and rehijacks the DNS
  */
 void rehijack(void *cls, struct GNUNET_SERVER_Client *client, const struct 
GNUNET_MessageHeader *message) {
-    unhijack(mycls.dnsoutport);
-    hijack(mycls.dnsoutport);
+    unhijack(dnsoutport);
+    hijack(dnsoutport);
 }
 
 /**
@@ -212,7 +209,7 @@
            struct receive_dht_cls* cls = GNUNET_malloc(sizeof(struct 
receive_dht_cls));
            cls->id = dns->s.id;
 
-           cls->handle = GNUNET_DHT_get_start(mycls.dht,
+           cls->handle = GNUNET_DHT_get_start(dht,
                                 GNUNET_TIME_UNIT_MINUTES,
                                 GNUNET_BLOCK_TYPE_DNS,
                                 &key,
@@ -235,26 +232,26 @@
        dest.sin_port = htons(53);
        dest.sin_addr.s_addr = pkt->orig_to;
 
-       /* int r = */ GNUNET_NETWORK_socket_sendto(mycls.dnsout, dns, 
ntohs(pkt->hdr.size) - sizeof(struct query_packet) + 1, (struct sockaddr*) 
&dest, sizeof dest);
+       /* int r = */ GNUNET_NETWORK_socket_sendto(dnsout, dns, 
ntohs(pkt->hdr.size) - sizeof(struct query_packet) + 1, (struct sockaddr*) 
&dest, sizeof dest);
 
 out:
        GNUNET_SERVER_receive_done(client, GNUNET_OK);
 }
 
 size_t send_answer(void* cls, size_t size, void* buf) {
-       struct answer_packet_list* query = mycls.head;
+       struct answer_packet_list* query = head;
        size_t len = ntohs(query->pkt.hdr.size);
 
        GNUNET_assert(len <= size);
 
        memcpy(buf, &query->pkt.hdr, len);
 
-       GNUNET_CONTAINER_DLL_remove (mycls.head, mycls.tail, query);
+       GNUNET_CONTAINER_DLL_remove (head, tail, query);
 
        GNUNET_free(query);
 
-       if (mycls.head != NULL) {
-               GNUNET_SERVER_notify_transmit_ready(cls, 
ntohs(mycls.head->pkt.hdr.size), GNUNET_TIME_UNIT_FOREVER_REL, &send_answer, 
cls);
+       if (head != NULL) {
+               GNUNET_SERVER_notify_transmit_ready(cls, 
ntohs(head->pkt.hdr.size), GNUNET_TIME_UNIT_FOREVER_REL, &send_answer, cls);
        }
 
        return len;
@@ -272,7 +269,7 @@
        unsigned int addrlen = sizeof addr;
 
        int r;
-       r = GNUNET_NETWORK_socket_recvfrom(mycls.dnsout, buf, 65536, (struct 
sockaddr*)&addr, &addrlen);
+       r = GNUNET_NETWORK_socket_recvfrom(dnsout, buf, 65536, (struct 
sockaddr*)&addr, &addrlen);
 
        /* if (r < 0) TODO */
 
@@ -289,12 +286,12 @@
                answer->pkt.dst_port = query_states[dns->s.id].local_port;
                memcpy(answer->pkt.data, buf, r);
 
-               GNUNET_CONTAINER_DLL_insert_after(mycls.head, mycls.tail, 
mycls.tail, answer);
+               GNUNET_CONTAINER_DLL_insert_after(head, tail, tail, answer);
 
                /* struct GNUNET_CONNECTION_TransmitHandle* th = */ 
GNUNET_SERVER_notify_transmit_ready(query_states[dns->s.id].client, len, 
GNUNET_TIME_UNIT_FOREVER_REL, &send_answer, query_states[dns->s.id].client);
        }
 
-       GNUNET_SCHEDULER_add_read_net(mycls.sched, 
GNUNET_TIME_UNIT_FOREVER_REL, mycls.dnsout, &read_response, NULL);
+       GNUNET_SCHEDULER_add_read_net(sched, GNUNET_TIME_UNIT_FOREVER_REL, 
dnsout, &read_response, NULL);
 }
 
 
@@ -308,8 +305,8 @@
 cleanup_task (void *cls,
              const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
-       unhijack(mycls.dnsoutport);
-       GNUNET_DHT_disconnect(mycls.dht);
+       unhijack(dnsoutport);
+       GNUNET_DHT_disconnect(dht);
 }
 
 static void
@@ -330,7 +327,7 @@
   GNUNET_CRYPTO_hash(name, strlen(name)+1, &data.service_descriptor);
 
   char* keyfile;
-  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename(mycls.cfg, 
"GNUNETD",
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename(cfg, "GNUNETD",
                                                           "HOSTKEY", &keyfile))
     {
       GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "could not read keyfile-value\n");
@@ -359,7 +356,7 @@
 
   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Putting with key %08x\n", *((unsigned 
int*)&data.service_descriptor));
 
-  GNUNET_DHT_put(mycls.dht,
+  GNUNET_DHT_put(dht,
                 &data.service_descriptor,
                 GNUNET_DHT_RO_NONE,
                 GNUNET_BLOCK_TYPE_DNS,
@@ -370,7 +367,7 @@
                 NULL,
                 NULL);
 
-  GNUNET_SCHEDULER_add_delayed (mycls.sched, GNUNET_TIME_UNIT_HOURS, 
publish_name, NULL);
+  GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_UNIT_HOURS, publish_name, 
NULL);
 }
 
 /**
@@ -381,9 +378,9 @@
  */
 static void
 run (void *cls,
-     struct GNUNET_SCHEDULER_Handle *sched,
+     struct GNUNET_SCHEDULER_Handle *sched_,
      struct GNUNET_SERVER_Handle *server,
-     const struct GNUNET_CONFIGURATION_Handle *cfg)
+     const struct GNUNET_CONFIGURATION_Handle *cfg_)
 {
   static const struct GNUNET_SERVER_MessageHandler handlers[] = {
          /* callback, cls, type, size */
@@ -392,7 +389,8 @@
     {NULL, NULL, 0, 0}
   };
 
-  mycls.cfg = cfg;
+  cfg = cfg_;
+  sched = sched_;
 
   {
   int i;
@@ -401,18 +399,17 @@
   }
   }
 
-  mycls.dht = GNUNET_DHT_connect(sched, cfg, 1024);
+  dht = GNUNET_DHT_connect(sched, cfg, 1024);
 
   struct sockaddr_in addr;
 
-  mycls.sched = sched;
-  mycls.dnsout = GNUNET_NETWORK_socket_create (AF_INET, SOCK_DGRAM, 0);
-  if (mycls.dnsout == NULL) 
+  dnsout = GNUNET_NETWORK_socket_create (AF_INET, SOCK_DGRAM, 0);
+  if (dnsout == NULL)
     return;
   memset(&addr, 0, sizeof(struct sockaddr_in));
 
-  int err = GNUNET_NETWORK_socket_bind (mycls.dnsout,
-                                       (struct sockaddr*)&addr, 
+  int err = GNUNET_NETWORK_socket_bind (dnsout,
+                                       (struct sockaddr*)&addr,
                                        sizeof(struct sockaddr_in));
 
   if (err != GNUNET_YES) {
@@ -420,17 +417,17 @@
        return;
   }
   socklen_t addrlen = sizeof(struct sockaddr_in);
-  err = getsockname(GNUNET_NETWORK_get_fd(mycls.dnsout),
-                   (struct sockaddr*) &addr, 
+  err = getsockname(GNUNET_NETWORK_get_fd(dnsout),
+                   (struct sockaddr*) &addr,
                    &addrlen);
 
-  mycls.dnsoutport = htons(addr.sin_port);
+  dnsoutport = htons(addr.sin_port);
 
   hijack(htons(addr.sin_port));
 
-  GNUNET_SCHEDULER_add_now (mycls.sched, publish_name, NULL);
+  GNUNET_SCHEDULER_add_now (sched, publish_name, NULL);
 
-       GNUNET_SCHEDULER_add_read_net(sched, GNUNET_TIME_UNIT_FOREVER_REL, 
mycls.dnsout, &read_response, NULL);
+  GNUNET_SCHEDULER_add_read_net(sched, GNUNET_TIME_UNIT_FOREVER_REL, dnsout, 
&read_response, NULL);
 
   GNUNET_SERVER_add_handlers (server, handlers);
   GNUNET_SCHEDULER_add_delayed (sched,




reply via email to

[Prev in Thread] Current Thread [Next in Thread]