gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r25422 - in gnunet/src: ats sysmon


From: gnunet
Subject: [GNUnet-SVN] r25422 - in gnunet/src: ats sysmon
Date: Wed, 12 Dec 2012 14:28:06 +0100

Author: wachs
Date: 2012-12-12 14:28:06 +0100 (Wed, 12 Dec 2012)
New Revision: 25422

Added:
   gnunet/src/sysmon/gnunet-service-sysmon.c
Removed:
   gnunet/src/sysmon/gnunet-daemon-sysmon.c
Modified:
   gnunet/src/ats/gnunet-service-ats.c
   gnunet/src/ats/gnunet-service-ats_addresses.c
   gnunet/src/ats/gnunet-service-ats_addresses.h
   gnunet/src/ats/gnunet-service-ats_addresses_mlp.c
   gnunet/src/ats/gnunet-service-ats_addresses_mlp.h
   gnunet/src/ats/gnunet-service-ats_addresses_simplistic.c
   gnunet/src/ats/gnunet-service-ats_addresses_simplistic.h
   gnunet/src/ats/gnunet-service-ats_performance.c
   gnunet/src/ats/gnunet-service-ats_performance.h
   gnunet/src/ats/gnunet-service-ats_scheduling.c
   gnunet/src/sysmon/Makefile.am
   gnunet/src/sysmon/sysmon.conf.in
Log:
changes

Modified: gnunet/src/ats/gnunet-service-ats.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats.c 2012-12-12 13:17:51 UTC (rev 25421)
+++ gnunet/src/ats/gnunet-service-ats.c 2012-12-12 13:28:06 UTC (rev 25422)
@@ -167,8 +167,8 @@
   GSA_server = server;
   GSA_stats = GNUNET_STATISTICS_create ("ats", cfg);
   GAS_reservations_init ();
-  GAS_performance_init (server);
   GSA_addresses = GAS_addresses_init (cfg, GSA_stats);
+  GAS_performance_init (server, GSA_addresses);
   GAS_scheduling_init (server, GSA_addresses);
 
   GNUNET_SERVER_disconnect_notify (server, &client_disconnect_handler, NULL);

Modified: gnunet/src/ats/gnunet-service-ats_addresses.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses.c       2012-12-12 13:17:51 UTC 
(rev 25421)
+++ gnunet/src/ats/gnunet-service-ats_addresses.c       2012-12-12 13:28:06 UTC 
(rev 25422)
@@ -86,13 +86,23 @@
 };
 
 /**
- * Handle for ATS address component
+ * Pending Address suggestion requests
  */
 struct GAS_Addresses_Suggestion_Requests
 {
+  /**
+   * Next in DLL
+   */
   struct GAS_Addresses_Suggestion_Requests *next;
+
+  /**
+   * Previous in DLL
+   */
   struct GAS_Addresses_Suggestion_Requests *prev;
 
+  /**
+   * Peer ID
+   */
   struct GNUNET_PeerIdentity id;
 };
 
@@ -102,6 +112,11 @@
 struct GAS_Addresses_Handle
 {
   /**
+   *
+   */
+  struct GNUNET_STATISTICS_Handle *stat;
+
+  /**
    * A multihashmap to store all addresses
    */
   struct GNUNET_CONTAINER_MultiHashMap *addresses;
@@ -180,12 +195,6 @@
 };
 
 
-/**
- * Temporary handle
- */
-struct GAS_Addresses_Handle *handle;
-
-
 static unsigned int
 assemble_ats_information (const struct ATS_Address *aa,  struct 
GNUNET_ATS_Information **dest)
 {
@@ -315,7 +324,7 @@
  * @return GNUNET_YES if bandwidth allocations should be recalcualted
  */
 static int
-destroy_address (struct ATS_Address *addr)
+destroy_address (struct GAS_Addresses_Handle *handle, struct ATS_Address *addr)
 {
   int ret;
 
@@ -416,8 +425,9 @@
  * @return existing address record, NULL for none
  */
 struct ATS_Address *
-find_equivalent_address (const struct GNUNET_PeerIdentity *peer,
-              const struct ATS_Address *addr)
+find_equivalent_address (struct GAS_Addresses_Handle *handle,
+                         const struct GNUNET_PeerIdentity *peer,
+                         const struct ATS_Address *addr)
 {
   struct CompareAddressContext cac;
 
@@ -434,7 +444,8 @@
 
 
 static struct ATS_Address *
-lookup_address (const struct GNUNET_PeerIdentity *peer,
+lookup_address (struct GAS_Addresses_Handle *handle,
+                const struct GNUNET_PeerIdentity *peer,
                 const char *plugin_name,
                 const void *plugin_addr,
                 size_t plugin_addr_len,
@@ -451,7 +462,7 @@
                        session_id);
 
   /* Get existing address or address with session == 0 */
-  ea = find_equivalent_address (peer, aa);
+  ea = find_equivalent_address (handle, peer, aa);
   free_address (aa);
   if (ea == NULL)
   {
@@ -466,11 +477,12 @@
 
 
 void
-GAS_addresses_add (const struct GNUNET_PeerIdentity *peer,
-                      const char *plugin_name, const void *plugin_addr,
-                      size_t plugin_addr_len, uint32_t session_id,
-                      const struct GNUNET_ATS_Information *atsi,
-                      uint32_t atsi_count)
+GAS_addresses_add (struct GAS_Addresses_Handle *handle,
+                   const struct GNUNET_PeerIdentity *peer,
+                   const char *plugin_name, const void *plugin_addr,
+                   size_t plugin_addr_len, uint32_t session_id,
+                   const struct GNUNET_ATS_Information *atsi,
+                   uint32_t atsi_count)
 {
   struct ATS_Address *aa;
   struct ATS_Address *ea;
@@ -496,7 +508,7 @@
   }
 
   /* Get existing address or address with session == 0 */
-  ea = find_equivalent_address (peer, aa);
+  ea = find_equivalent_address (handle, peer, aa);
   if (ea == NULL)
   {
     /* We have a new address */
@@ -508,6 +520,9 @@
                 GNUNET_i2s (peer), session_id, aa);
     /* Tell solver about new address */
     handle->s_add (handle->solver, handle->addresses, aa);
+
+
+
     return;
   }
   GNUNET_free (aa->plugin);
@@ -540,7 +555,8 @@
 
 
 void
-GAS_addresses_update (const struct GNUNET_PeerIdentity *peer,
+GAS_addresses_update (struct GAS_Addresses_Handle *handle,
+                      const struct GNUNET_PeerIdentity *peer,
                       const char *plugin_name, const void *plugin_addr,
                       size_t plugin_addr_len, uint32_t session_id,
                       const struct GNUNET_ATS_Information *atsi,
@@ -555,7 +571,7 @@
   GNUNET_assert (NULL != handle->addresses);
 
   /* Get existing address */
-  aa = lookup_address (peer, plugin_name, plugin_addr, plugin_addr_len,
+  aa = lookup_address (handle, peer, plugin_name, plugin_addr, plugin_addr_len,
                        session_id, atsi, atsi_count);
   if (aa == NULL)
   {
@@ -637,7 +653,7 @@
 
       /* Notify solver about deletion */
       handle->s_del (handle->solver, handle->addresses, aa, GNUNET_NO);
-      destroy_address (aa);
+      destroy_address (handle, aa);
       dc->result = GNUNET_NO;
       return GNUNET_OK; /* Continue iteration */
     }
@@ -667,7 +683,7 @@
 
         /* Notify solver about deletion */
         handle->s_del (handle->solver, handle->addresses, aa, GNUNET_NO);
-        destroy_address (aa);
+        destroy_address (handle, aa);
         dc->result = GNUNET_NO;
         return GNUNET_OK; /* Continue iteration */
     }
@@ -687,7 +703,8 @@
 }
 
 void
-GAS_addresses_destroy (const struct GNUNET_PeerIdentity *peer,
+GAS_addresses_destroy (struct GAS_Addresses_Handle *handle,
+                       const struct GNUNET_PeerIdentity *peer,
                        const char *plugin_name, const void *plugin_addr,
                        size_t plugin_addr_len, uint32_t session_id)
 {
@@ -698,7 +715,7 @@
     return;
 
   /* Get existing address */
-  ea = lookup_address (peer, plugin_name, plugin_addr, plugin_addr_len,
+  ea = lookup_address (handle, peer, plugin_name, plugin_addr, plugin_addr_len,
                        session_id, NULL, 0);
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -724,11 +741,12 @@
 
 
 int
-GAS_addresses_in_use (const struct GNUNET_PeerIdentity *peer,
+GAS_addresses_in_use (struct GAS_Addresses_Handle *handle,
+                      const struct GNUNET_PeerIdentity *peer,
                       const char *plugin_name, const void *plugin_addr,
                       size_t plugin_addr_len, uint32_t session_id, int in_use)
 {
-  struct ATS_Address *old;
+  struct ATS_Address *ea;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Received `%s' for peer `%s'\n",
@@ -738,8 +756,10 @@
   if (GNUNET_NO == handle->running)
     return GNUNET_SYSERR;
 
-  old = lookup_address (peer, plugin_name, plugin_addr, plugin_addr_len, 
session_id, NULL, 0);
-  if (NULL == old)
+  ea = lookup_address (handle, peer, plugin_name,
+                        plugin_addr, plugin_addr_len,
+                        session_id, NULL, 0);
+  if (NULL == ea)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "Trying to set unknown address `%s', %s %u %s \n",
@@ -749,20 +769,20 @@
     GNUNET_break (0);
     return GNUNET_SYSERR;
   }
-  if (old->used == in_use)
+  if (ea->used == in_use)
   {
     GNUNET_break (0);
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "Address in use called multiple times for peer `%s': %s -> %s 
\n",
                 GNUNET_i2s (peer),
-                (GNUNET_NO == old->used) ? "NO" : "YES",
+                (GNUNET_NO == ea->used) ? "NO" : "YES",
                 (GNUNET_NO == in_use) ? "NO" : "YES");
     return GNUNET_SYSERR;
   }
-  old->used = in_use;
+  ea->used = in_use;
 
   /* Tell solver about update */
-  handle->s_update (handle->solver, handle->addresses, old);
+  handle->s_update (handle->solver, handle->addresses, ea);
 
   return GNUNET_OK;
 }
@@ -774,7 +794,8 @@
  * @param peer the respective peer
  */
 void
-GAS_addresses_request_address_cancel (const struct GNUNET_PeerIdentity *peer)
+GAS_addresses_request_address_cancel (struct GAS_Addresses_Handle *handle,
+                                      const struct GNUNET_PeerIdentity *peer)
 {
   struct GAS_Addresses_Suggestion_Requests *cur = handle->r_head;
 
@@ -794,7 +815,7 @@
                   "No address requests pending for peer `%s', cannot 
remove!\n", GNUNET_i2s (peer));
       return;
   }
-  GAS_addresses_handle_backoff_reset (peer);
+  GAS_addresses_handle_backoff_reset (handle, peer);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Removed request pending for peer `%s\n", GNUNET_i2s (peer));
   GNUNET_CONTAINER_DLL_remove (handle->r_head, handle->r_tail, cur);
@@ -808,7 +829,8 @@
  * @param peer the respective peer
  */
 void
-GAS_addresses_request_address (const struct GNUNET_PeerIdentity *peer)
+GAS_addresses_request_address (struct GAS_Addresses_Handle *handle,
+                               const struct GNUNET_PeerIdentity *peer)
 {
   struct GAS_Addresses_Suggestion_Requests *cur = handle->r_head;
   struct ATS_Address *aa;
@@ -883,7 +905,8 @@
 
 
 void
-GAS_addresses_handle_backoff_reset (const struct GNUNET_PeerIdentity *peer)
+GAS_addresses_handle_backoff_reset (struct GAS_Addresses_Handle *handle,
+                                    const struct GNUNET_PeerIdentity *peer)
 {
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Received `%s' for peer `%s'\n",
@@ -898,7 +921,8 @@
 
 
 void
-GAS_addresses_change_preference (const struct GNUNET_PeerIdentity *peer,
+GAS_addresses_change_preference (struct GAS_Addresses_Handle *handle,
+                                 const struct GNUNET_PeerIdentity *peer,
                                  enum GNUNET_ATS_PreferenceKind kind,
                                  float score)
 {
@@ -997,9 +1021,14 @@
 
 
 static void
-bandwidth_changed_cb (struct ATS_Address *address)
+bandwidth_changed_cb (void *cls, struct ATS_Address *address)
 {
+  struct GAS_Addresses_Handle *handle = cls;
   struct GAS_Addresses_Suggestion_Requests *cur;
+
+  GNUNET_assert (handle != NULL);
+  GNUNET_assert (address != NULL);
+
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Bandwidth assignment changed for peer 
%s \n", GNUNET_i2s(&address->peer));
   struct GNUNET_ATS_Information *ats;
   unsigned int ats_count;
@@ -1052,9 +1081,9 @@
   int c;
 
   ah = GNUNET_malloc (sizeof (struct GAS_Addresses_Handle));
-  handle = ah;
-  handle->running = GNUNET_NO;
+  ah->running = GNUNET_NO;
 
+  ah->stat = (struct GNUNET_STATISTICS_Handle *) stats;
   /* Initialize the addresses database */
   ah->addresses = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO);
   GNUNET_assert (NULL != ah->addresses);
@@ -1134,7 +1163,7 @@
 
   quota_count = load_quotas(cfg, quotas_in, quotas_out, 
GNUNET_ATS_NetworkTypeCount);
 
-  ah->solver = ah->s_init (cfg, stats, quotas, quotas_in, quotas_out, 
quota_count, &bandwidth_changed_cb);
+  ah->solver = ah->s_init (cfg, stats, quotas, quotas_in, quotas_out, 
quota_count, &bandwidth_changed_cb, ah);
   if (NULL == ah->solver)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to initialize solver!\n");
@@ -1162,7 +1191,7 @@
   struct GAS_Addresses_Handle *handle = cls;
   struct ATS_Address *aa = value;
   handle->s_del (handle->solver, handle->addresses, aa, GNUNET_NO);
-  destroy_address (aa);
+  destroy_address (handle, aa);
   return GNUNET_OK;
 }
 
@@ -1241,7 +1270,7 @@
  * @param p_it_cls the closure for the iterator
  */
 void
-GAS_addresses_iterate_peers (GNUNET_ATS_Peer_Iterator p_it, void *p_it_cls)
+GAS_addresses_iterate_peers (struct GAS_Addresses_Handle *handle, 
GNUNET_ATS_Peer_Iterator p_it, void *p_it_cls)
 {
   struct PeerIteratorContext ip_ctx;
   unsigned int size;
@@ -1305,7 +1334,10 @@
  * @param pi_it_cls the closure for the iterator
  */
 void
-GAS_addresses_get_peer_info (const struct GNUNET_PeerIdentity *peer, 
GNUNET_ATS_PeerInfo_Iterator pi_it, void *pi_it_cls)
+GAS_addresses_get_peer_info (struct GAS_Addresses_Handle *handle,
+                             const struct GNUNET_PeerIdentity *peer,
+                             GNUNET_ATS_PeerInfo_Iterator pi_it,
+                             void *pi_it_cls)
 {
   struct PeerInfoIteratorContext pi_ctx;
   struct GNUNET_BANDWIDTH_Value32NBO zero_bw;

Modified: gnunet/src/ats/gnunet-service-ats_addresses.h
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses.h       2012-12-12 13:17:51 UTC 
(rev 25421)
+++ gnunet/src/ats/gnunet-service-ats_addresses.h       2012-12-12 13:28:06 UTC 
(rev 25422)
@@ -34,6 +34,8 @@
 
 #define ATS_BLOCKING_DELTA 
GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100)
 
+struct GAS_Addresses_Handle;
+
 /**
  * Address with additional information
  */
@@ -143,7 +145,7 @@
  */
 
 typedef void
- (*GAS_bandwidth_changed_cb) (struct ATS_Address *address);
+ (*GAS_bandwidth_changed_cb) (void *cls, struct ATS_Address *address);
 
 /**
  * Init the simplistic problem solving component
@@ -174,7 +176,8 @@
                      unsigned long long *out_quota,
                      unsigned long long *in_quota,
                      int dest_length,
-                     GAS_bandwidth_changed_cb bw_changed_cb);
+                     GAS_bandwidth_changed_cb bw_changed_cb,
+                     void *bw_changed_cb_cls);
 
 
 typedef void
@@ -236,18 +239,21 @@
 GAS_addresses_done (struct GAS_Addresses_Handle *handle);
 
 void
-GAS_addresses_handle_backoff_reset (const struct GNUNET_PeerIdentity *peer);
+GAS_addresses_handle_backoff_reset (struct GAS_Addresses_Handle *handle,
+                                    const struct GNUNET_PeerIdentity *peer);
 
 /**
  * This address is now used or not used anymore
  */
 int
-GAS_addresses_in_use (const struct GNUNET_PeerIdentity *peer,
+GAS_addresses_in_use (struct GAS_Addresses_Handle *handle,
+                      const struct GNUNET_PeerIdentity *peer,
                       const char *plugin_name, const void *plugin_addr,
                       size_t plugin_addr_len, uint32_t session_id, int in_use);
 
 void
-GAS_addresses_update (const struct GNUNET_PeerIdentity *peer,
+GAS_addresses_update (struct GAS_Addresses_Handle *handle,
+                      const struct GNUNET_PeerIdentity *peer,
                       const char *plugin_name, const void *plugin_addr,
                       size_t plugin_addr_len, uint32_t session_id,
                       const struct GNUNET_ATS_Information *atsi,
@@ -255,7 +261,8 @@
 
 
 void
-GAS_addresses_destroy (const struct GNUNET_PeerIdentity *peer,
+GAS_addresses_destroy (struct GAS_Addresses_Handle *handle,
+                       const struct GNUNET_PeerIdentity *peer,
                        const char *plugin_name, const void *plugin_addr,
                        size_t plugin_addr_len, uint32_t session_id);
 
@@ -270,22 +277,26 @@
  * @param peer the respective peer
  */
 void
-GAS_addresses_request_address_cancel (const struct GNUNET_PeerIdentity *peer);
+GAS_addresses_request_address_cancel (struct GAS_Addresses_Handle *handle,
+                                      const struct GNUNET_PeerIdentity *peer);
 
 void
-GAS_addresses_request_address (const struct GNUNET_PeerIdentity *peer);
+GAS_addresses_request_address (struct GAS_Addresses_Handle *handle,
+                               const struct GNUNET_PeerIdentity *peer);
 
 void
-GAS_addresses_change_preference (const struct GNUNET_PeerIdentity *peer,
+GAS_addresses_change_preference (struct GAS_Addresses_Handle *handle,
+                                 const struct GNUNET_PeerIdentity *peer,
                                  enum GNUNET_ATS_PreferenceKind kind,
                                  float score);
 
 void
-GAS_addresses_add (const struct GNUNET_PeerIdentity *peer,
-                      const char *plugin_name, const void *plugin_addr,
-                      size_t plugin_addr_len, uint32_t session_id,
-                      const struct GNUNET_ATS_Information *atsi,
-                      uint32_t atsi_count);
+GAS_addresses_add (struct GAS_Addresses_Handle *handle,
+                   const struct GNUNET_PeerIdentity *peer,
+                   const char *plugin_name, const void *plugin_addr,
+                   size_t plugin_addr_len, uint32_t session_id,
+                   const struct GNUNET_ATS_Information *atsi,
+                   uint32_t atsi_count);
 
 
 typedef void (*GNUNET_ATS_Peer_Iterator) (void *p_it_cls,
@@ -298,7 +309,9 @@
  * @param p_it_cls the closure for the iterator
  */
 void
-GAS_addresses_iterate_peers (GNUNET_ATS_Peer_Iterator p_it, void *p_it_cls);
+GAS_addresses_iterate_peers (struct GAS_Addresses_Handle *handle,
+                             GNUNET_ATS_Peer_Iterator p_it,
+                             void *p_it_cls);
 
 typedef void (*GNUNET_ATS_PeerInfo_Iterator) (void *p_it_cls,
     const struct GNUNET_PeerIdentity *id,
@@ -319,7 +332,10 @@
  * @param pi_it_cls the closure for the iterator
  */
 void
-GAS_addresses_get_peer_info (const struct GNUNET_PeerIdentity *peer, 
GNUNET_ATS_PeerInfo_Iterator pi_it, void *pi_it_cls);
+GAS_addresses_get_peer_info (struct GAS_Addresses_Handle *handle,
+                             const struct GNUNET_PeerIdentity *peer,
+                             GNUNET_ATS_PeerInfo_Iterator pi_it,
+                             void *pi_it_cls);
 
 #endif
 

Modified: gnunet/src/ats/gnunet-service-ats_addresses_mlp.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses_mlp.c   2012-12-12 13:17:51 UTC 
(rev 25421)
+++ gnunet/src/ats/gnunet-service-ats_addresses_mlp.c   2012-12-12 13:28:06 UTC 
(rev 25422)
@@ -1082,7 +1082,8 @@
               unsigned long long *out_dest,
               unsigned long long *in_dest,
               int dest_length,
-              GAS_bandwidth_changed_cb bw_changed_cb)
+              GAS_bandwidth_changed_cb bw_changed_cb,
+              void *bw_changed_cb_cls)
 {
   struct GAS_MLP_Handle * mlp = GNUNET_malloc (sizeof (struct GAS_MLP_Handle));
 

Modified: gnunet/src/ats/gnunet-service-ats_addresses_mlp.h
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses_mlp.h   2012-12-12 13:17:51 UTC 
(rev 25421)
+++ gnunet/src/ats/gnunet-service-ats_addresses_mlp.h   2012-12-12 13:28:06 UTC 
(rev 25422)
@@ -326,7 +326,8 @@
               unsigned long long *out_dest,
               unsigned long long *in_dest,
               int dest_length,
-              GAS_bandwidth_changed_cb bw_changed_cb);
+              GAS_bandwidth_changed_cb bw_changed_cb,
+              void *bw_changed_cb_cls);
 
 
 /**

Modified: gnunet/src/ats/gnunet-service-ats_addresses_simplistic.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses_simplistic.c    2012-12-12 
13:17:51 UTC (rev 25421)
+++ gnunet/src/ats/gnunet-service-ats_addresses_simplistic.c    2012-12-12 
13:28:06 UTC (rev 25422)
@@ -68,6 +68,7 @@
 
   unsigned int networks;
   GAS_bandwidth_changed_cb bw_changed;
+  void *bw_changed_cls;
 };
 
 struct Network
@@ -144,7 +145,8 @@
                      unsigned long long *out_quota,
                      unsigned long long *in_quota,
                      int dest_length,
-                     GAS_bandwidth_changed_cb bw_changed_cb)
+                     GAS_bandwidth_changed_cb bw_changed_cb,
+                     void *bw_changed_cb_cls)
 {
   int c;
   struct GAS_SIMPLISTIC_Handle *s = GNUNET_malloc (sizeof (struct 
GAS_SIMPLISTIC_Handle));
@@ -152,6 +154,7 @@
   char * net_str[GNUNET_ATS_NetworkTypeCount] = {"UNSPECIFIED", "LOOPBACK", 
"LAN", "WAN", "WLAN"};
 
   s->bw_changed = bw_changed_cb;
+  s->bw_changed_cls = bw_changed_cb_cls;
   s->networks = dest_length;
   s->network_entries = GNUNET_malloc (dest_length * sizeof (struct Network));
   s->active_addresses = 0;
@@ -277,7 +280,7 @@
         cur->addr->assigned_bw_out.value__ = htonl (quota_out);
         /* Notify on change */
         if ((GNUNET_YES == cur->addr->active) && (cur->addr != address_except))
-          s->bw_changed (cur->addr);
+          s->bw_changed (s->bw_changed_cls, cur->addr);
       }
       cur = cur->next;
   }
@@ -606,7 +609,7 @@
       prev->active = GNUNET_NO; /* No active any longer */
       prev->assigned_bw_in = GNUNET_BANDWIDTH_value_init (0); /* no bw 
assigned */
       prev->assigned_bw_out = GNUNET_BANDWIDTH_value_init (0); /* no bw 
assigned */
-      s->bw_changed (prev); /* notify about bw change, REQUIRED? */
+      s->bw_changed (s->bw_changed_cls, prev); /* notify about bw change, 
REQUIRED? */
       if (net_prev->active_addresses < 1)
         GNUNET_break (0);
       else

Modified: gnunet/src/ats/gnunet-service-ats_addresses_simplistic.h
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses_simplistic.h    2012-12-12 
13:17:51 UTC (rev 25421)
+++ gnunet/src/ats/gnunet-service-ats_addresses_simplistic.h    2012-12-12 
13:28:06 UTC (rev 25422)
@@ -59,7 +59,8 @@
                      unsigned long long *out_quota,
                      unsigned long long *in_quota,
                      int dest_length,
-                     GAS_bandwidth_changed_cb bw_changed_cb);
+                     GAS_bandwidth_changed_cb bw_changed_cb,
+                     void *bw_changed_cb_cls);
 
 /**
  * Shutdown the simplistic problem solving component

Modified: gnunet/src/ats/gnunet-service-ats_performance.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_performance.c     2012-12-12 13:17:51 UTC 
(rev 25421)
+++ gnunet/src/ats/gnunet-service-ats_performance.c     2012-12-12 13:28:06 UTC 
(rev 25422)
@@ -77,6 +77,10 @@
   unsigned int msg_type;
 };
 
+/**
+ * Address handle
+ */
+static struct GAS_Addresses_Handle *GSA_addresses;
 
 /**
  * Head of linked list of all clients to this service.
@@ -288,7 +292,7 @@
   if (NULL != id)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for peer `%s'\n", 
GNUNET_i2s (id));
-    GAS_addresses_get_peer_info (id, &peerinfo_it, pc);
+    GAS_addresses_get_peer_info (GSA_addresses, id, &peerinfo_it, pc);
   }
 }
 
@@ -313,7 +317,7 @@
   GNUNET_CONTAINER_DLL_insert (pc_head, pc_tail, pc);
 
   /* Send information about clients */
-  GAS_addresses_iterate_peers (&peer_it, pc);
+  GAS_addresses_iterate_peers (GSA_addresses, &peer_it, pc);
 }
 
 static void transmit_req_addr (struct AddressIteration *ai,
@@ -442,7 +446,7 @@
   if (NULL != id)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for peer `%s'\n", 
GNUNET_i2s (id));
-    GAS_addresses_get_peer_info (id, &req_addr_peerinfo_it, ai);
+    GAS_addresses_get_peer_info (GSA_addresses, id, &req_addr_peerinfo_it, ai);
   }
   else
   {
@@ -485,13 +489,13 @@
   if (0 == memcmp (&alrm->peer, &allzeros, sizeof (struct 
GNUNET_PeerIdentity)))
   {
       /* Return addresses for all peers */
-      GAS_addresses_iterate_peers (&req_addr_peer_it, &ai);
+      GAS_addresses_iterate_peers (GSA_addresses, &req_addr_peer_it, &ai);
       transmit_req_addr (&ai, NULL, NULL, NULL, 0, GNUNET_NO, NULL, 0, 
bandwidth_zero, bandwidth_zero);
   }
   else
   {
       /* Return addresses for a specific peer */
-      GAS_addresses_get_peer_info (&alrm->peer, &req_addr_peerinfo_it, &ai);
+      GAS_addresses_get_peer_info (GSA_addresses, &alrm->peer, 
&req_addr_peerinfo_it, &ai);
       transmit_req_addr (&ai, NULL, NULL, NULL, 0, GNUNET_NO, NULL, 0, 
bandwidth_zero, bandwidth_zero);
   }
   GNUNET_SERVER_receive_done (client, GNUNET_OK);
@@ -582,7 +586,7 @@
                             1, GNUNET_NO);
   pi = (const struct PreferenceInformation *) &msg[1];
   for (i = 0; i < nump; i++)
-    GAS_addresses_change_preference (&msg->peer,
+    GAS_addresses_change_preference (GSA_addresses, &msg->peer,
                                      (enum GNUNET_ATS_PreferenceKind)
                                      ntohl (pi[i].preference_kind),
                                      pi[i].preference_value);
@@ -596,8 +600,10 @@
  * @param server handle to our server
  */
 void
-GAS_performance_init (struct GNUNET_SERVER_Handle *server)
+GAS_performance_init (struct GNUNET_SERVER_Handle *server,
+                      struct GAS_Addresses_Handle *addresses)
 {
+  GSA_addresses = addresses;
   nc = GNUNET_SERVER_notification_context_create (server, 128);
 }
 

Modified: gnunet/src/ats/gnunet-service-ats_performance.h
===================================================================
--- gnunet/src/ats/gnunet-service-ats_performance.h     2012-12-12 13:17:51 UTC 
(rev 25421)
+++ gnunet/src/ats/gnunet-service-ats_performance.h     2012-12-12 13:28:06 UTC 
(rev 25422)
@@ -120,7 +120,8 @@
  * @param server handle to our server
  */
 void
-GAS_performance_init (struct GNUNET_SERVER_Handle *server);
+GAS_performance_init (struct GNUNET_SERVER_Handle *server,
+                      struct GAS_Addresses_Handle *GSA_addresses);
 
 
 /**

Modified: gnunet/src/ats/gnunet-service-ats_scheduling.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_scheduling.c      2012-12-12 13:17:51 UTC 
(rev 25421)
+++ gnunet/src/ats/gnunet-service-ats_scheduling.c      2012-12-12 13:28:06 UTC 
(rev 25422)
@@ -171,10 +171,8 @@
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n",
               "REQUEST_ADDRESS");
-  GNUNET_STATISTICS_update (GSA_stats, "# address requests received", 1,
-                            GNUNET_NO);
   GNUNET_break (0 == ntohl (msg->reserved));
-  GAS_addresses_request_address (&msg->peer);
+  GAS_addresses_request_address (address_handle, &msg->peer);
   GNUNET_SERVER_receive_done (client, GNUNET_OK);
 }
 
@@ -198,7 +196,7 @@
               "REQUEST_ADDRESS_CANCEL");
   GNUNET_break (0 == ntohl (msg->reserved));
 
-  GAS_addresses_request_address_cancel (&msg->peer);
+  GAS_addresses_request_address_cancel (address_handle, &msg->peer);
 
   GNUNET_SERVER_receive_done (client, GNUNET_OK);
 }
@@ -220,10 +218,8 @@
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n",
               "RESET_BACKOFF");
-  GNUNET_STATISTICS_update (GSA_stats, "# backoff reset requests received", 1,
-                            GNUNET_NO);
   GNUNET_break (0 == ntohl (msg->reserved));
-  GAS_addresses_handle_backoff_reset (&msg->peer);
+  GAS_addresses_handle_backoff_reset (address_handle, &msg->peer);
   GNUNET_SERVER_receive_done (client, GNUNET_OK);
 }
 
@@ -280,7 +276,7 @@
   }
   GNUNET_STATISTICS_update (GSA_stats, "# address updates received", 1,
                             GNUNET_NO);
-  GAS_addresses_add (&m->peer, plugin_name, address, address_length,
+  GAS_addresses_add (address_handle, &m->peer, plugin_name, address, 
address_length,
                         ntohl (m->session_id), atsi, ats_count);
   GNUNET_SERVER_receive_done (client, GNUNET_OK);
 }
@@ -339,7 +335,7 @@
   }
   GNUNET_STATISTICS_update (GSA_stats, "# address updates received", 1,
                             GNUNET_NO);
-  GAS_addresses_update (&m->peer, plugin_name, address, address_length,
+  GAS_addresses_update (address_handle, &m->peer, plugin_name, address, 
address_length,
                         ntohl (m->session_id), atsi, ats_count);
   GNUNET_SERVER_receive_done (client, GNUNET_OK);
 }
@@ -395,12 +391,13 @@
   }
 
   in_use = ntohs (m->in_use);
-  res = GAS_addresses_in_use (&m->peer,
-                             plugin_name,
-                             address,
-                             address_length,
-                             ntohl (m->session_id),
-                             in_use);
+  res = GAS_addresses_in_use (address_handle,
+                              &m->peer,
+                              plugin_name,
+                              address,
+                              address_length,
+                              ntohl (m->session_id),
+                              in_use);
 
   if (res == GNUNET_OK)
     GNUNET_SERVER_receive_done (client, GNUNET_OK);
@@ -465,7 +462,8 @@
     return;
   }
   GNUNET_STATISTICS_update (GSA_stats, "# addresses destroyed", 1, GNUNET_NO);
-  GAS_addresses_destroy (&m->peer, plugin_name, address, address_length,
+  GAS_addresses_destroy (address_handle, &m->peer, plugin_name,
+                         address, address_length,
                          ntohl (m->session_id));
   if (0 != ntohl (m->session_id))
   {

Modified: gnunet/src/sysmon/Makefile.am
===================================================================
--- gnunet/src/sysmon/Makefile.am       2012-12-12 13:17:51 UTC (rev 25421)
+++ gnunet/src/sysmon/Makefile.am       2012-12-12 13:28:06 UTC (rev 25422)
@@ -16,16 +16,16 @@
 endif
 
 libexec_PROGRAMS = \
- gnunet_daemon_sysmon
+ gnunet_service_sysmon
 
 check_PROGRAMS = \
  test_glibtop \
  test_glibtop_process \
  test_glibtop_network
  
-gnunet_daemon_sysmon_SOURCES = \
- gnunet-daemon-sysmon.c         
-gnunet_daemon_sysmon_LDADD = \
+gnunet_service_sysmon_SOURCES = \
+ gnunet-service-sysmon.c         
+gnunet_service_sysmon_LDADD = \
   $(top_builddir)/src/util/libgnunetutil.la \
   $(top_builddir)/src/statistics/libgnunetstatistics.la \
   $(GN_LIBINTL)

Deleted: gnunet/src/sysmon/gnunet-daemon-sysmon.c
===================================================================
--- gnunet/src/sysmon/gnunet-daemon-sysmon.c    2012-12-12 13:17:51 UTC (rev 
25421)
+++ gnunet/src/sysmon/gnunet-daemon-sysmon.c    2012-12-12 13:28:06 UTC (rev 
25422)
@@ -1,616 +0,0 @@
-/*
-     This file is part of GNUnet.
-     (C) 2001, 2002, 2004, 2005, 2006, 2007, 2009 Christian Grothoff (and 
other contributing authors)
-
-     GNUnet is free software; you can redistribute it and/or modify
-     it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 3, or (at your
-     option) any later version.
-
-     GNUnet is distributed in the hope that it will be useful, but
-     WITHOUT ANY WARRANTY; without even the implied warranty of
-     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-     General Public License for more details.
-
-     You should have received a copy of the GNU General Public License
-     along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-     Boston, MA 02111-1307, USA.
-*/
-
-/**
- * @file sysmon/gnunet-daemon-sysmon.c
- * @brief system monitoring daemon
- * @author Matthias Wachs
- */
-#include "platform.h"
-#include "gnunet_util_lib.h"
-#include "gnunet_statistics_service.h"
-
-enum operation
-{
-  o_internal,
-  o_command
-};
-
-
-enum type
-{
-  t_static,
-  t_continous
-};
-
-enum value
-{
-  v_numeric,
-  v_string
-};
-
-/**
- * A system property to monitor
- */
-struct SysmonProperty
-{
-  /**
-   * Next element in in the DLL
-   */
-  struct SysmonProperty *next;
-
-  /**
-   * Previous element in in the DLL
-   */
-  struct SysmonProperty *prev;
-
-  /**
-   * Description used for statistics valuesd
-   */
-  char * desc;
-
-  /**
-   * Type
-   */
-  int type;
-
-  /**
-   * Value type
-   */
-  int value_type;
-
-  /**
-   * Execution interval
-   */
-  struct GNUNET_TIME_Relative interval;
-
-  /**
-   * Command
-   */
-  char * cmd;
-
-  /**
-   * Command arguments
-   */
-  char * cmd_args;
-
-  /**
-   * Command execution handle
-   */
-  void * cmd_exec_handle;
-
-  /**
-   * Numerical value
-   */
-  uint64_t num_val;
-
-  /**
-   * String value
-   */
-  char * str_val;
-
-  /**
-   * Task id
-   */
-  GNUNET_SCHEDULER_TaskIdentifier task_id;
-
-  /**
-   * Task handle
-   */
-  GNUNET_SCHEDULER_Task task;
-
-};
-
-/**
- * Final status code.
- */
-static int ret;
-
-/**
- * Configuration handle
- */
-const struct GNUNET_CONFIGURATION_Handle *cfg;
-
-
-/**
- * Statistics handle
- */
-struct GNUNET_STATISTICS_Handle *stats;
-
-/**
- * Shutdown task
- */
-GNUNET_SCHEDULER_TaskIdentifier end_task;
-
-struct SysmonProperty *sp_head;
-struct SysmonProperty *sp_tail;
-
-static void
-shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
-  struct SysmonProperty *sp;
-  struct SysmonProperty *next;
-
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sysdaemon stopping ... \n");
-
-  end_task = GNUNET_SCHEDULER_NO_TASK;
-
-  if (NULL != stats)
-  {
-    GNUNET_STATISTICS_destroy (stats, GNUNET_YES);
-    stats = NULL;
-  }
-
-  next = sp_head;
-  while (NULL != (sp = next))
-  {
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping `%s' \n", sp->desc);
-      GNUNET_CONTAINER_DLL_remove (sp_head, sp_tail, sp);
-      next = sp->next;
-      if (GNUNET_SCHEDULER_NO_TASK != sp->task_id)
-      {
-        GNUNET_SCHEDULER_cancel (sp->task_id);
-        sp->task_id = GNUNET_SCHEDULER_NO_TASK;
-      }
-      GNUNET_free_non_null (sp->cmd);
-      GNUNET_free_non_null (sp->cmd_args);
-      GNUNET_free (sp->desc);
-      GNUNET_free (sp);
-  }
-
-}
-
-static void
-shutdown_now (void)
-{
-  if (GNUNET_SCHEDULER_NO_TASK != end_task)
-    GNUNET_SCHEDULER_cancel (end_task);
-  GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
-}
-
-static void
-to_lower_str (char * str)
-{
-  int c;
-  for (c = 0; c <= strlen (str); c++)
-    str[c] = tolower(str[c]);
-}
-
-static int
-put_property (struct SysmonProperty *sp)
-{
-  if (v_numeric ==sp->value_type)
-  {
-      GNUNET_STATISTICS_set (stats, sp->desc, sp->num_val, GNUNET_NO);
-  }
-  else if (v_string ==sp->value_type)
-  {
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "NOT IMPLEMENTED\n");
-  }
-  else
-  {
-    GNUNET_break (0);
-    return GNUNET_SYSERR;
-  }
-  return GNUNET_OK;
-}
-
-static void
-update_uptime (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
-  struct SysmonProperty *sp = cls;
-  sp->num_val ++;
-  put_property (sp);
-}
-
-static void
-exec_cmd_proc (void *cls, const char *line)
-{
-  struct SysmonProperty *sp = cls;
-  unsigned long long tmp;
-  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Property output: `%s'\n", line);
-  if (NULL == line)
-  {
-      GNUNET_OS_command_stop (sp->cmd_exec_handle);
-      sp->cmd_exec_handle = NULL;
-      return;
-  }
-
-  switch (sp->value_type) {
-    case v_numeric:
-      if (1 != sscanf (line, "%llu", &tmp))
-      {
-        GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Command output was not a 
numerical value: `%s'\n", line);
-        return;
-      }
-      break;
-    case v_string:
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "NOT IMPLEMENTED\n");
-      break;
-    default:
-      break;
-
-  }
-  sp->num_val = tmp;
-
-  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Property output: `%s'\n", line);
-  put_property (sp);
-
-
-}
-
-static void
-exec_cmd (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
-  struct SysmonProperty *sp = cls;
-  GNUNET_assert (NULL != sp->cmd);
-
-  if (NULL != sp->cmd_exec_handle)
-  {
-    GNUNET_OS_command_stop (sp->cmd_exec_handle);
-    sp->cmd_exec_handle = NULL;
-    GNUNET_break (0);
-  }
-  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Property `%s': command `%s' `%s'\n", 
sp->desc, sp->cmd, sp->cmd_args);
-  if (NULL == (sp->cmd_exec_handle = GNUNET_OS_command_run (&exec_cmd_proc, sp,
-      GNUNET_TIME_UNIT_SECONDS,
-      sp->cmd, sp->cmd,
-      sp->cmd_args,
-      NULL)))
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Property `%s': command `%s' 
failed\n", sp->desc, sp->cmd);
-}
-
-static void
-load_property (void *cls,
-               const char *section)
-{
-  struct GNUNET_CONFIGURATION_Handle *properties = cls;
-  struct SysmonProperty *sp;
-  char *tmp;
-
-  if (NULL == strstr (section, "sysmon-"))
-    return;
-
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Loading section `%s'\n", section);
-
-  if (GNUNET_NO == GNUNET_CONFIGURATION_have_value (properties, section, 
"TYPE"))
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Missing value %s in section `%s'\n",
-        "TYPE", section);
-    return;
-  }
-  if (GNUNET_NO == GNUNET_CONFIGURATION_have_value (properties, 
section,"VALUE"))
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Missing value %s in section `%s'\n",
-        "VALUE", section);
-    return;
-  }
-  if (GNUNET_NO == GNUNET_CONFIGURATION_have_value (properties, 
section,"DESCRIPTION"))
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Missing value %s in section `%s'\n",
-        "DESCRIPTION", section);
-    return;
-  }
-  if (GNUNET_NO == GNUNET_CONFIGURATION_have_value (properties, section,"CMD"))
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Missing value %s in section `%s'\n",
-        "CMD", section);
-    return;
-  }
-  sp = GNUNET_malloc (sizeof (struct SysmonProperty));
-
-  /* description */
-  GNUNET_CONFIGURATION_get_value_string (properties, section, "DESCRIPTION", 
&sp->desc);
-
-  /* cmd */
-  GNUNET_CONFIGURATION_get_value_string (properties, section, "CMD", &tmp);
-  char *args = "";
-  if (NULL != strchr (tmp, ' '))
-  {
-      args = strchr (tmp, ' ');
-      if (strlen (args) > 1)
-      {
-          args[0] = '\0';
-          args++;
-      }
-  }
-  sp->cmd = GNUNET_strdup (tmp);
-  sp->cmd_args = GNUNET_strdup (args);
-  GNUNET_free (tmp);
-  sp->task = &exec_cmd;
-
-  /* type */
-  GNUNET_CONFIGURATION_get_value_string (properties, section, "TYPE", &tmp);
-  to_lower_str (tmp);
-  if (0 == strcasecmp(tmp, "static"))
-    sp->type = t_static;
-  else if (0 == strcasecmp(tmp, "continous"))
-    sp->type = t_continous;
-  else
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Invalid value %s for %s in section 
`%s'\n",
-        tmp, "TYPE", section);
-    GNUNET_free (tmp);
-    GNUNET_free (sp);
-    return;
-  }
-  GNUNET_free (tmp);
-
-  /* value */
-  GNUNET_CONFIGURATION_get_value_string (properties, section, "VALUE", &tmp);
-  to_lower_str (tmp);
-  if (0 == strcasecmp(tmp, "numeric"))
-    sp->value_type = v_numeric;
-  else if (0 == strcasecmp(tmp, "string"))
-    sp->value_type = v_string;
-  else
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Invalid value %s for %s in section 
`%s'\n",
-        tmp, "VALUE", section);
-    GNUNET_free (tmp);
-    GNUNET_free (sp);
-    return;
-  }
-  GNUNET_free (tmp);
-
-  /* interval */
-  if (GNUNET_NO == GNUNET_CONFIGURATION_have_value (properties, 
section,"INTERVAL"))
-    sp->interval = GNUNET_TIME_UNIT_MINUTES;
-  else
-  {
-    if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (properties, 
section, "INTERVAL", &sp->interval))
-    {
-        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-            _("Could not parse execution interval for `%s', set to default 60 
sec.\n"), section);
-        sp->interval = GNUNET_TIME_UNIT_MINUTES;
-    }
-  }
-
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Loaded property `%s': %s, %s, interval 
%llu\n",
-      (NULL != sp->desc) ? sp->desc: "<undefined>",
-      (t_continous == sp->type) ? "continious" : "static",
-      (v_numeric == sp->value_type) ? "numeric" : "string",
-      sp->interval.rel_value);
-
-  GNUNET_CONTAINER_DLL_insert (sp_head, sp_tail, sp);
-
-}
-
-static int
-load_default_properties (void)
-{
-  struct SysmonProperty *sp;
-  /* GNUnet version array */
-  unsigned int ver[3];
-
-  /* GNUnet vcs revision */
-  unsigned int revision;
-return GNUNET_OK;
-  /* version */
-#ifdef VERSION
-  if (3 != sscanf (VERSION, "%u.%u.%u", &ver[0], &ver[1], &ver[2]))
-  {
-    ver[0] = 0;
-    ver[1] = 0;
-    ver[2] = 0;
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not parse version string 
`%s'\n", VERSION);
-  }
-#else
-  ver[0] = 0;
-  ver[1] = 0;
-  ver[2] = 0;
-  GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Version string is undefined \n");
-#endif
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Version: %u.%u.%u\n", ver[0], ver[1], 
ver[2]);
-
-  sp = GNUNET_malloc (sizeof (struct SysmonProperty));
-  sp->desc = GNUNET_strdup ("GNUnet version");
-  sp->type = t_static;
-  sp->value_type = v_numeric;
-  sp->num_val = 100 * ver[0] + 10  * ver[1] + ver[2];
-  GNUNET_CONTAINER_DLL_insert (sp_head, sp_tail, sp);
-
-  /* revision */
-#ifdef VCS_VERSION
-  if (1 != sscanf (VCS_VERSION, "svn-%uM", &revision))
-  {
-    revision = 0;
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not parse revision string 
`%s'\n", VCS_VERSION);
-  }
-#else
-  GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "VCS revision string is undefined 
\n");
-  revision = 0;
-#endif
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Revision: %u\n", revision);
-
-  sp = GNUNET_malloc (sizeof (struct SysmonProperty));
-  sp->desc = GNUNET_strdup ("GNUnet vcs revision");
-  sp->type = t_static;
-  sp->value_type = v_numeric;
-  sp->num_val = (uint64_t) revision;
-  GNUNET_CONTAINER_DLL_insert (sp_head, sp_tail, sp);
-
-
-  /* GNUnet startup time  */
-  sp = GNUNET_malloc (sizeof (struct SysmonProperty));
-  sp->desc = GNUNET_strdup ("GNUnet startup time");
-  sp->type = t_static;
-  sp->value_type = v_numeric;
-  sp->num_val = (uint64_t) GNUNET_TIME_absolute_get().abs_value;
-  GNUNET_CONTAINER_DLL_insert (sp_head, sp_tail, sp);
-
-
-  /* GNUnet sysmon daemon uptime */
-  sp = GNUNET_malloc (sizeof (struct SysmonProperty));
-  sp->desc = GNUNET_strdup ("GNUnet uptime");
-  sp->type = t_continous;
-  sp->value_type = v_numeric;
-  sp->num_val = (uint64_t) 0;
-  sp->interval = GNUNET_TIME_UNIT_SECONDS;
-  sp->task_id = GNUNET_SCHEDULER_NO_TASK;
-  sp->task = update_uptime;
-  GNUNET_CONTAINER_DLL_insert (sp_head, sp_tail, sp);
-
-  return GNUNET_OK;
-}
-
-
-static void
-run_property (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
-  struct SysmonProperty *sp = cls;
-  sp->task_id = GNUNET_SCHEDULER_NO_TASK;
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Running continous property `%s' \n", 
sp->desc);
-  sp->task (cls, tc);
-  sp->task_id = GNUNET_SCHEDULER_add_delayed (sp->interval, &run_property, sp);
-}
-
-
-static int
-run_properties (void)
-{
-  struct SysmonProperty *sp;
-
-  for (sp = sp_head; NULL != sp; sp = sp->next)
-  {
-      if (t_static == sp->type)
-      {
-          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Running static property `%s' 
\n", sp->desc);
-          put_property (sp);
-      }
-      else
-      {
-          if (NULL == sp->task)
-          {
-            GNUNET_break (0);
-            continue;
-          }
-          sp->task_id = GNUNET_SCHEDULER_add_now (&run_property, sp);
-      }
-  }
-  return GNUNET_OK;
-}
-
-/**
- * Main function that will be run by the scheduler.
- *
- * @param cls closure
- * @param args remaining command-line arguments
- * @param cfgfile name of the configuration file used (for saving, can be 
NULL!)
- * @param cfg configuration
- */
-static void
-run (void *cls, char *const *args, const char *cfgfile,
-     const struct GNUNET_CONFIGURATION_Handle *mycfg)
-{
-  struct GNUNET_CONFIGURATION_Handle *properties;
-  char *file;
-
-  end_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_FOREVER_REL, 
&shutdown_task, NULL);
-  cfg = mycfg;
-
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sysdaemon starting ... \n");
-
-  if (GNUNET_SYSERR ==GNUNET_CONFIGURATION_get_value_filename (mycfg, 
"sysmon", "CFGFILE", &file))
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Sysmon configuration file not set, 
exit! \n");
-    shutdown_now();
-    ret = 1;
-    return;
-  }
-
-  properties = GNUNET_CONFIGURATION_create();
-  if (NULL == properties)
-  {
-    GNUNET_break (0);
-    shutdown_now();
-    ret = 1;
-    return;
-  }
-  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (properties, file))
-  {
-      GNUNET_break (0);
-      GNUNET_CONFIGURATION_destroy (properties);
-      GNUNET_free (file);
-      ret = 1;
-      shutdown_now();
-      return;
-  }
-  GNUNET_free (file);
-  GNUNET_CONFIGURATION_iterate_sections (properties, &load_property, 
properties);
-
-  GNUNET_CONFIGURATION_destroy (properties);
-
-  /* Creating statistics */
-  stats = GNUNET_STATISTICS_create ("sysmon", mycfg);
-  if (NULL == stats)
-  {
-    GNUNET_break (0);
-    shutdown_now();
-    ret = 1;
-    return;
-  }
-
-  /* load properties */
-  if (GNUNET_SYSERR == load_default_properties ())
-  {
-    GNUNET_break (0);
-    shutdown_now();
-    ret = 1;
-    return;
-  }
-
-  /* run properties */
-  if (GNUNET_SYSERR == run_properties ())
-  {
-    GNUNET_break (0);
-    shutdown_now();
-    ret = 1;
-    return;
-  }
-
-}
-
-
-/**
- * The main function.
- *
- * @param argc number of arguments from the command line
- * @param argv command line arguments
- * @return 0 ok, 1 on error
- */
-int
-main (int argc, char *const *argv)
-{
-  static const struct GNUNET_GETOPT_CommandLineOption options[] = {
-    GNUNET_GETOPT_OPTION_END
-  };
-  if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
-    return 2;
-
-  ret = (GNUNET_OK ==
-        GNUNET_PROGRAM_run (argc, argv, "gnunet-daemon-sysmon",
-                            gettext_noop ("GNUnet system monitoring and 
information daemon"), options, &run,
-                            NULL)) ? ret : 1;
-  GNUNET_free ((void*) argv);
-  return ret;
-}
-
-/* end of gnunet-daemon-sysmon.c */

Copied: gnunet/src/sysmon/gnunet-service-sysmon.c (from rev 25162, 
gnunet/src/sysmon/gnunet-daemon-sysmon.c)
===================================================================
--- gnunet/src/sysmon/gnunet-service-sysmon.c                           (rev 0)
+++ gnunet/src/sysmon/gnunet-service-sysmon.c   2012-12-12 13:28:06 UTC (rev 
25422)
@@ -0,0 +1,629 @@
+/*
+     This file is part of GNUnet.
+     (C) 2001, 2002, 2004, 2005, 2006, 2007, 2009 Christian Grothoff (and 
other contributing authors)
+
+     GNUnet is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 3, or (at your
+     option) any later version.
+
+     GNUnet is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file sysmon/gnunet-service-sysmon.c
+ * @brief system monitoring service
+ * @author Matthias Wachs
+ */
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_statistics_service.h"
+
+enum operation
+{
+  o_internal,
+  o_command
+};
+
+
+enum type
+{
+  t_static,
+  t_continous
+};
+
+enum value
+{
+  v_numeric,
+  v_string
+};
+
+/**
+ * A system property to monitor
+ */
+struct SysmonProperty
+{
+  /**
+   * Next element in in the DLL
+   */
+  struct SysmonProperty *next;
+
+  /**
+   * Previous element in in the DLL
+   */
+  struct SysmonProperty *prev;
+
+  /**
+   * Description used for statistics valuesd
+   */
+  char * desc;
+
+  /**
+   * Type
+   */
+  int type;
+
+  /**
+   * Value type
+   */
+  int value_type;
+
+  /**
+   * Execution interval
+   */
+  struct GNUNET_TIME_Relative interval;
+
+  /**
+   * Command
+   */
+  char * cmd;
+
+  /**
+   * Command arguments
+   */
+  char * cmd_args;
+
+  /**
+   * Command execution handle
+   */
+  void * cmd_exec_handle;
+
+  /**
+   * Numerical value
+   */
+  uint64_t num_val;
+
+  /**
+   * String value
+   */
+  char * str_val;
+
+  /**
+   * Task id
+   */
+  GNUNET_SCHEDULER_TaskIdentifier task_id;
+
+  /**
+   * Task handle
+   */
+  GNUNET_SCHEDULER_Task task;
+
+};
+
+/**
+ * Final status code.
+ */
+static int ret;
+
+/**
+ * Configuration handle
+ */
+const struct GNUNET_CONFIGURATION_Handle *cfg;
+
+
+/**
+ * Statistics handle
+ */
+struct GNUNET_STATISTICS_Handle *stats;
+
+/**
+ * Shutdown task
+ */
+GNUNET_SCHEDULER_TaskIdentifier end_task;
+
+struct SysmonProperty *sp_head;
+struct SysmonProperty *sp_tail;
+
+static void
+shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  struct SysmonProperty *sp;
+  struct SysmonProperty *next;
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sysdaemon stopping ... \n");
+
+  end_task = GNUNET_SCHEDULER_NO_TASK;
+
+  if (NULL != stats)
+  {
+    GNUNET_STATISTICS_destroy (stats, GNUNET_YES);
+    stats = NULL;
+  }
+
+  next = sp_head;
+  while (NULL != (sp = next))
+  {
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping `%s' \n", sp->desc);
+      GNUNET_CONTAINER_DLL_remove (sp_head, sp_tail, sp);
+      next = sp->next;
+      if (GNUNET_SCHEDULER_NO_TASK != sp->task_id)
+      {
+        GNUNET_SCHEDULER_cancel (sp->task_id);
+        sp->task_id = GNUNET_SCHEDULER_NO_TASK;
+      }
+      GNUNET_free_non_null (sp->cmd);
+      GNUNET_free_non_null (sp->cmd_args);
+      GNUNET_free (sp->desc);
+      GNUNET_free (sp);
+  }
+
+}
+
+static void
+shutdown_now (void)
+{
+  if (GNUNET_SCHEDULER_NO_TASK != end_task)
+    GNUNET_SCHEDULER_cancel (end_task);
+  GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
+}
+
+static void
+to_lower_str (char * str)
+{
+  int c;
+  for (c = 0; c <= strlen (str); c++)
+    str[c] = tolower(str[c]);
+}
+
+static int
+put_property (struct SysmonProperty *sp)
+{
+  if (v_numeric ==sp->value_type)
+  {
+      GNUNET_STATISTICS_set (stats, sp->desc, sp->num_val, GNUNET_NO);
+  }
+  else if (v_string ==sp->value_type)
+  {
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "NOT IMPLEMENTED\n");
+  }
+  else
+  {
+    GNUNET_break (0);
+    return GNUNET_SYSERR;
+  }
+  return GNUNET_OK;
+}
+
+static void
+update_uptime (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  struct SysmonProperty *sp = cls;
+  sp->num_val ++;
+  put_property (sp);
+}
+
+static void
+exec_cmd_proc (void *cls, const char *line)
+{
+  struct SysmonProperty *sp = cls;
+  unsigned long long tmp;
+  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Property output: `%s'\n", line);
+  if (NULL == line)
+  {
+      GNUNET_OS_command_stop (sp->cmd_exec_handle);
+      sp->cmd_exec_handle = NULL;
+      return;
+  }
+
+  switch (sp->value_type) {
+    case v_numeric:
+      if (1 != sscanf (line, "%llu", &tmp))
+      {
+        GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Command output was not a 
numerical value: `%s'\n", line);
+        return;
+      }
+      break;
+    case v_string:
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "NOT IMPLEMENTED\n");
+      break;
+    default:
+      break;
+
+  }
+  sp->num_val = tmp;
+
+  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Property output: `%s'\n", line);
+  put_property (sp);
+
+
+}
+
+static void
+exec_cmd (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  struct SysmonProperty *sp = cls;
+  GNUNET_assert (NULL != sp->cmd);
+
+  if (NULL != sp->cmd_exec_handle)
+  {
+    GNUNET_OS_command_stop (sp->cmd_exec_handle);
+    sp->cmd_exec_handle = NULL;
+    GNUNET_break (0);
+  }
+  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Property `%s': command `%s' `%s'\n", 
sp->desc, sp->cmd, sp->cmd_args);
+  if (NULL == (sp->cmd_exec_handle = GNUNET_OS_command_run (&exec_cmd_proc, sp,
+      GNUNET_TIME_UNIT_SECONDS,
+      sp->cmd, sp->cmd,
+      sp->cmd_args,
+      NULL)))
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Property `%s': command `%s' 
failed\n", sp->desc, sp->cmd);
+}
+
+static void
+load_property (void *cls,
+               const char *section)
+{
+  struct GNUNET_CONFIGURATION_Handle *properties = cls;
+  struct SysmonProperty *sp;
+  char *tmp;
+
+  if (NULL == strstr (section, "sysmon-"))
+    return;
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Loading section `%s'\n", section);
+
+  if (GNUNET_NO == GNUNET_CONFIGURATION_have_value (properties, section, 
"TYPE"))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Missing value %s in section `%s'\n",
+        "TYPE", section);
+    return;
+  }
+  if (GNUNET_NO == GNUNET_CONFIGURATION_have_value (properties, 
section,"VALUE"))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Missing value %s in section `%s'\n",
+        "VALUE", section);
+    return;
+  }
+  if (GNUNET_NO == GNUNET_CONFIGURATION_have_value (properties, 
section,"DESCRIPTION"))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Missing value %s in section `%s'\n",
+        "DESCRIPTION", section);
+    return;
+  }
+  if (GNUNET_NO == GNUNET_CONFIGURATION_have_value (properties, section,"CMD"))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Missing value %s in section `%s'\n",
+        "CMD", section);
+    return;
+  }
+  sp = GNUNET_malloc (sizeof (struct SysmonProperty));
+
+  /* description */
+  GNUNET_CONFIGURATION_get_value_string (properties, section, "DESCRIPTION", 
&sp->desc);
+
+  /* cmd */
+  GNUNET_CONFIGURATION_get_value_string (properties, section, "CMD", &tmp);
+  char *args = "";
+  if (NULL != strchr (tmp, ' '))
+  {
+      args = strchr (tmp, ' ');
+      if (strlen (args) > 1)
+      {
+          args[0] = '\0';
+          args++;
+      }
+  }
+  sp->cmd = GNUNET_strdup (tmp);
+  sp->cmd_args = GNUNET_strdup (args);
+  GNUNET_free (tmp);
+  sp->task = &exec_cmd;
+
+  /* type */
+  GNUNET_CONFIGURATION_get_value_string (properties, section, "TYPE", &tmp);
+  to_lower_str (tmp);
+  if (0 == strcasecmp(tmp, "static"))
+    sp->type = t_static;
+  else if (0 == strcasecmp(tmp, "continous"))
+    sp->type = t_continous;
+  else
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Invalid value %s for %s in section 
`%s'\n",
+        tmp, "TYPE", section);
+    GNUNET_free (tmp);
+    GNUNET_free (sp);
+    return;
+  }
+  GNUNET_free (tmp);
+
+  /* value */
+  GNUNET_CONFIGURATION_get_value_string (properties, section, "VALUE", &tmp);
+  to_lower_str (tmp);
+  if (0 == strcasecmp(tmp, "numeric"))
+    sp->value_type = v_numeric;
+  else if (0 == strcasecmp(tmp, "string"))
+    sp->value_type = v_string;
+  else
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Invalid value %s for %s in section 
`%s'\n",
+        tmp, "VALUE", section);
+    GNUNET_free (tmp);
+    GNUNET_free (sp);
+    return;
+  }
+  GNUNET_free (tmp);
+
+  /* interval */
+  if (GNUNET_NO == GNUNET_CONFIGURATION_have_value (properties, 
section,"INTERVAL"))
+    sp->interval = GNUNET_TIME_UNIT_MINUTES;
+  else
+  {
+    if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (properties, 
section, "INTERVAL", &sp->interval))
+    {
+        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+            _("Could not parse execution interval for `%s', set to default 60 
sec.\n"), section);
+        sp->interval = GNUNET_TIME_UNIT_MINUTES;
+    }
+  }
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Loaded property `%s': %s, %s, interval 
%llu\n",
+      (NULL != sp->desc) ? sp->desc: "<undefined>",
+      (t_continous == sp->type) ? "continious" : "static",
+      (v_numeric == sp->value_type) ? "numeric" : "string",
+      sp->interval.rel_value);
+
+  GNUNET_CONTAINER_DLL_insert (sp_head, sp_tail, sp);
+
+}
+
+static int
+load_default_properties (void)
+{
+  struct SysmonProperty *sp;
+  /* GNUnet version array */
+  unsigned int ver[3];
+
+  /* GNUnet vcs revision */
+  unsigned int revision;
+return GNUNET_OK;
+  /* version */
+#ifdef VERSION
+  if (3 != sscanf (VERSION, "%u.%u.%u", &ver[0], &ver[1], &ver[2]))
+  {
+    ver[0] = 0;
+    ver[1] = 0;
+    ver[2] = 0;
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not parse version string 
`%s'\n", VERSION);
+  }
+#else
+  ver[0] = 0;
+  ver[1] = 0;
+  ver[2] = 0;
+  GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Version string is undefined \n");
+#endif
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Version: %u.%u.%u\n", ver[0], ver[1], 
ver[2]);
+
+  sp = GNUNET_malloc (sizeof (struct SysmonProperty));
+  sp->desc = GNUNET_strdup ("GNUnet version");
+  sp->type = t_static;
+  sp->value_type = v_numeric;
+  sp->num_val = 100 * ver[0] + 10  * ver[1] + ver[2];
+  GNUNET_CONTAINER_DLL_insert (sp_head, sp_tail, sp);
+
+  /* revision */
+#ifdef VCS_VERSION
+  if (1 != sscanf (VCS_VERSION, "svn-%uM", &revision))
+  {
+    revision = 0;
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not parse revision string 
`%s'\n", VCS_VERSION);
+  }
+#else
+  GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "VCS revision string is undefined 
\n");
+  revision = 0;
+#endif
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Revision: %u\n", revision);
+
+  sp = GNUNET_malloc (sizeof (struct SysmonProperty));
+  sp->desc = GNUNET_strdup ("GNUnet vcs revision");
+  sp->type = t_static;
+  sp->value_type = v_numeric;
+  sp->num_val = (uint64_t) revision;
+  GNUNET_CONTAINER_DLL_insert (sp_head, sp_tail, sp);
+
+
+  /* GNUnet startup time  */
+  sp = GNUNET_malloc (sizeof (struct SysmonProperty));
+  sp->desc = GNUNET_strdup ("GNUnet startup time");
+  sp->type = t_static;
+  sp->value_type = v_numeric;
+  sp->num_val = (uint64_t) GNUNET_TIME_absolute_get().abs_value;
+  GNUNET_CONTAINER_DLL_insert (sp_head, sp_tail, sp);
+
+
+  /* GNUnet sysmon daemon uptime */
+  sp = GNUNET_malloc (sizeof (struct SysmonProperty));
+  sp->desc = GNUNET_strdup ("GNUnet uptime");
+  sp->type = t_continous;
+  sp->value_type = v_numeric;
+  sp->num_val = (uint64_t) 0;
+  sp->interval = GNUNET_TIME_UNIT_SECONDS;
+  sp->task_id = GNUNET_SCHEDULER_NO_TASK;
+  sp->task = update_uptime;
+  GNUNET_CONTAINER_DLL_insert (sp_head, sp_tail, sp);
+
+  return GNUNET_OK;
+}
+
+
+static void
+run_property (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  struct SysmonProperty *sp = cls;
+  sp->task_id = GNUNET_SCHEDULER_NO_TASK;
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Running continous property `%s' \n", 
sp->desc);
+  sp->task (cls, tc);
+  sp->task_id = GNUNET_SCHEDULER_add_delayed (sp->interval, &run_property, sp);
+}
+
+
+static int
+run_properties (void)
+{
+  struct SysmonProperty *sp;
+
+  for (sp = sp_head; NULL != sp; sp = sp->next)
+  {
+      if (t_static == sp->type)
+      {
+          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Running static property `%s' 
\n", sp->desc);
+          put_property (sp);
+      }
+      else
+      {
+          if (NULL == sp->task)
+          {
+            GNUNET_break (0);
+            continue;
+          }
+          sp->task_id = GNUNET_SCHEDULER_add_now (&run_property, sp);
+      }
+  }
+  return GNUNET_OK;
+}
+
+
+/**
+ * Task run during shutdown.
+ *
+ * @param cls unused
+ * @param tc unused
+ */
+static void
+cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  /* FIXME: do clean up here */
+}
+
+
+/**
+ * Process template requests.
+ *
+ * @param cls closure
+ * @param server the initialized server
+ * @param cfg configuration to use
+ */
+static void
+run (void *cls, struct GNUNET_SERVER_Handle *server,
+     const struct GNUNET_CONFIGURATION_Handle *mycfg)
+{
+  static const struct GNUNET_SERVER_MessageHandler handlers[] = {
+    /* FIXME: add handlers here! */
+    {NULL, NULL, 0, 0}
+  };
+  /* FIXME: do setup here */
+  GNUNET_SERVER_add_handlers (server, handlers);
+  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup_task,
+                                NULL);
+
+  struct GNUNET_CONFIGURATION_Handle *properties;
+  char *file;
+
+  end_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_FOREVER_REL, 
&shutdown_task, NULL);
+  cfg = mycfg;
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sysdaemon starting ... \n");
+
+  if (GNUNET_SYSERR ==GNUNET_CONFIGURATION_get_value_filename (mycfg, 
"sysmon", "CFGFILE", &file))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Sysmon configuration file not set, 
exit! \n");
+    shutdown_now();
+    ret = 1;
+    return;
+  }
+
+  properties = GNUNET_CONFIGURATION_create();
+  if (NULL == properties)
+  {
+    GNUNET_break (0);
+    shutdown_now();
+    ret = 1;
+    return;
+  }
+  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (properties, file))
+  {
+      GNUNET_break (0);
+      GNUNET_CONFIGURATION_destroy (properties);
+      GNUNET_free (file);
+      ret = 1;
+      shutdown_now();
+      return;
+  }
+  GNUNET_free (file);
+  GNUNET_CONFIGURATION_iterate_sections (properties, &load_property, 
properties);
+
+  GNUNET_CONFIGURATION_destroy (properties);
+
+  /* Creating statistics */
+  stats = GNUNET_STATISTICS_create ("sysmon", mycfg);
+  if (NULL == stats)
+  {
+    GNUNET_break (0);
+    shutdown_now();
+    ret = 1;
+    return;
+  }
+
+  /* load properties */
+  if (GNUNET_SYSERR == load_default_properties ())
+  {
+    GNUNET_break (0);
+    shutdown_now();
+    ret = 1;
+    return;
+  }
+
+  /* run properties */
+  if (GNUNET_SYSERR == run_properties ())
+  {
+    GNUNET_break (0);
+    shutdown_now();
+    ret = 1;
+    return;
+  }
+
+}
+
+
+/**
+ * The main function for the template service.
+ *
+ * @param argc number of arguments from the command line
+ * @param argv command line arguments
+ * @return 0 ok, 1 on error
+ */
+int
+main (int argc, char *const *argv)
+{
+  return (GNUNET_OK ==
+          GNUNET_SERVICE_run (argc, argv, "sysmon",
+                              GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1;
+}
+
+/* end of gnunet-service-sysmon.c */

Modified: gnunet/src/sysmon/sysmon.conf.in
===================================================================
--- gnunet/src/sysmon/sysmon.conf.in    2012-12-12 13:17:51 UTC (rev 25421)
+++ gnunet/src/sysmon/sysmon.conf.in    2012-12-12 13:28:06 UTC (rev 25422)
@@ -5,4 +5,4 @@
 HOME = $SERVICEHOME
 BINARY = gnunet-daemon-sysmon
 CFGFILE = sysmon-properties.conf
-UNIXPATH = /tmp/gnunet-daemon-sysmon.sock
+UNIXPATH = /tmp/gnunet-service-sysmon.sock




reply via email to

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