aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ats/gnunet-service-ats.c2
-rw-r--r--src/ats/gnunet-service-ats_addresses.c120
-rw-r--r--src/ats/gnunet-service-ats_addresses.h48
-rw-r--r--src/ats/gnunet-service-ats_addresses_mlp.c3
-rw-r--r--src/ats/gnunet-service-ats_addresses_mlp.h3
-rw-r--r--src/ats/gnunet-service-ats_addresses_simplistic.c9
-rw-r--r--src/ats/gnunet-service-ats_addresses_simplistic.h3
-rw-r--r--src/ats/gnunet-service-ats_performance.c20
-rw-r--r--src/ats/gnunet-service-ats_performance.h3
-rw-r--r--src/ats/gnunet-service-ats_scheduling.c30
-rw-r--r--src/sysmon/Makefile.am8
-rw-r--r--src/sysmon/gnunet-service-sysmon.c (renamed from src/sysmon/gnunet-daemon-sysmon.c)55
-rw-r--r--src/sysmon/sysmon.conf.in2
13 files changed, 189 insertions, 117 deletions
diff --git a/src/ats/gnunet-service-ats.c b/src/ats/gnunet-service-ats.c
index e994b1da8..3218769a6 100644
--- a/src/ats/gnunet-service-ats.c
+++ b/src/ats/gnunet-service-ats.c
@@ -167,8 +167,8 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
167 GSA_server = server; 167 GSA_server = server;
168 GSA_stats = GNUNET_STATISTICS_create ("ats", cfg); 168 GSA_stats = GNUNET_STATISTICS_create ("ats", cfg);
169 GAS_reservations_init (); 169 GAS_reservations_init ();
170 GAS_performance_init (server);
171 GSA_addresses = GAS_addresses_init (cfg, GSA_stats); 170 GSA_addresses = GAS_addresses_init (cfg, GSA_stats);
171 GAS_performance_init (server, GSA_addresses);
172 GAS_scheduling_init (server, GSA_addresses); 172 GAS_scheduling_init (server, GSA_addresses);
173 173
174 GNUNET_SERVER_disconnect_notify (server, &client_disconnect_handler, NULL); 174 GNUNET_SERVER_disconnect_notify (server, &client_disconnect_handler, NULL);
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c
index ef45144fa..e36e9372f 100644
--- a/src/ats/gnunet-service-ats_addresses.c
+++ b/src/ats/gnunet-service-ats_addresses.c
@@ -86,13 +86,23 @@ enum ATS_Mode
86}; 86};
87 87
88/** 88/**
89 * Handle for ATS address component 89 * Pending Address suggestion requests
90 */ 90 */
91struct GAS_Addresses_Suggestion_Requests 91struct GAS_Addresses_Suggestion_Requests
92{ 92{
93 /**
94 * Next in DLL
95 */
93 struct GAS_Addresses_Suggestion_Requests *next; 96 struct GAS_Addresses_Suggestion_Requests *next;
97
98 /**
99 * Previous in DLL
100 */
94 struct GAS_Addresses_Suggestion_Requests *prev; 101 struct GAS_Addresses_Suggestion_Requests *prev;
95 102
103 /**
104 * Peer ID
105 */
96 struct GNUNET_PeerIdentity id; 106 struct GNUNET_PeerIdentity id;
97}; 107};
98 108
@@ -102,6 +112,11 @@ struct GAS_Addresses_Suggestion_Requests
102struct GAS_Addresses_Handle 112struct GAS_Addresses_Handle
103{ 113{
104 /** 114 /**
115 *
116 */
117 struct GNUNET_STATISTICS_Handle *stat;
118
119 /**
105 * A multihashmap to store all addresses 120 * A multihashmap to store all addresses
106 */ 121 */
107 struct GNUNET_CONTAINER_MultiHashMap *addresses; 122 struct GNUNET_CONTAINER_MultiHashMap *addresses;
@@ -180,12 +195,6 @@ struct GAS_Addresses_Handle
180}; 195};
181 196
182 197
183/**
184 * Temporary handle
185 */
186struct GAS_Addresses_Handle *handle;
187
188
189static unsigned int 198static unsigned int
190assemble_ats_information (const struct ATS_Address *aa, struct GNUNET_ATS_Information **dest) 199assemble_ats_information (const struct ATS_Address *aa, struct GNUNET_ATS_Information **dest)
191{ 200{
@@ -315,7 +324,7 @@ create_address (const struct GNUNET_PeerIdentity *peer,
315 * @return GNUNET_YES if bandwidth allocations should be recalcualted 324 * @return GNUNET_YES if bandwidth allocations should be recalcualted
316 */ 325 */
317static int 326static int
318destroy_address (struct ATS_Address *addr) 327destroy_address (struct GAS_Addresses_Handle *handle, struct ATS_Address *addr)
319{ 328{
320 int ret; 329 int ret;
321 330
@@ -416,8 +425,9 @@ compare_address_it (void *cls, const struct GNUNET_HashCode * key, void *value)
416 * @return existing address record, NULL for none 425 * @return existing address record, NULL for none
417 */ 426 */
418struct ATS_Address * 427struct ATS_Address *
419find_equivalent_address (const struct GNUNET_PeerIdentity *peer, 428find_equivalent_address (struct GAS_Addresses_Handle *handle,
420 const struct ATS_Address *addr) 429 const struct GNUNET_PeerIdentity *peer,
430 const struct ATS_Address *addr)
421{ 431{
422 struct CompareAddressContext cac; 432 struct CompareAddressContext cac;
423 433
@@ -434,7 +444,8 @@ find_equivalent_address (const struct GNUNET_PeerIdentity *peer,
434 444
435 445
436static struct ATS_Address * 446static struct ATS_Address *
437lookup_address (const struct GNUNET_PeerIdentity *peer, 447lookup_address (struct GAS_Addresses_Handle *handle,
448 const struct GNUNET_PeerIdentity *peer,
438 const char *plugin_name, 449 const char *plugin_name,
439 const void *plugin_addr, 450 const void *plugin_addr,
440 size_t plugin_addr_len, 451 size_t plugin_addr_len,
@@ -451,7 +462,7 @@ lookup_address (const struct GNUNET_PeerIdentity *peer,
451 session_id); 462 session_id);
452 463
453 /* Get existing address or address with session == 0 */ 464 /* Get existing address or address with session == 0 */
454 ea = find_equivalent_address (peer, aa); 465 ea = find_equivalent_address (handle, peer, aa);
455 free_address (aa); 466 free_address (aa);
456 if (ea == NULL) 467 if (ea == NULL)
457 { 468 {
@@ -466,11 +477,12 @@ lookup_address (const struct GNUNET_PeerIdentity *peer,
466 477
467 478
468void 479void
469GAS_addresses_add (const struct GNUNET_PeerIdentity *peer, 480GAS_addresses_add (struct GAS_Addresses_Handle *handle,
470 const char *plugin_name, const void *plugin_addr, 481 const struct GNUNET_PeerIdentity *peer,
471 size_t plugin_addr_len, uint32_t session_id, 482 const char *plugin_name, const void *plugin_addr,
472 const struct GNUNET_ATS_Information *atsi, 483 size_t plugin_addr_len, uint32_t session_id,
473 uint32_t atsi_count) 484 const struct GNUNET_ATS_Information *atsi,
485 uint32_t atsi_count)
474{ 486{
475 struct ATS_Address *aa; 487 struct ATS_Address *aa;
476 struct ATS_Address *ea; 488 struct ATS_Address *ea;
@@ -496,7 +508,7 @@ GAS_addresses_add (const struct GNUNET_PeerIdentity *peer,
496 } 508 }
497 509
498 /* Get existing address or address with session == 0 */ 510 /* Get existing address or address with session == 0 */
499 ea = find_equivalent_address (peer, aa); 511 ea = find_equivalent_address (handle, peer, aa);
500 if (ea == NULL) 512 if (ea == NULL)
501 { 513 {
502 /* We have a new address */ 514 /* We have a new address */
@@ -508,6 +520,9 @@ GAS_addresses_add (const struct GNUNET_PeerIdentity *peer,
508 GNUNET_i2s (peer), session_id, aa); 520 GNUNET_i2s (peer), session_id, aa);
509 /* Tell solver about new address */ 521 /* Tell solver about new address */
510 handle->s_add (handle->solver, handle->addresses, aa); 522 handle->s_add (handle->solver, handle->addresses, aa);
523
524
525
511 return; 526 return;
512 } 527 }
513 GNUNET_free (aa->plugin); 528 GNUNET_free (aa->plugin);
@@ -540,7 +555,8 @@ GAS_addresses_add (const struct GNUNET_PeerIdentity *peer,
540 555
541 556
542void 557void
543GAS_addresses_update (const struct GNUNET_PeerIdentity *peer, 558GAS_addresses_update (struct GAS_Addresses_Handle *handle,
559 const struct GNUNET_PeerIdentity *peer,
544 const char *plugin_name, const void *plugin_addr, 560 const char *plugin_name, const void *plugin_addr,
545 size_t plugin_addr_len, uint32_t session_id, 561 size_t plugin_addr_len, uint32_t session_id,
546 const struct GNUNET_ATS_Information *atsi, 562 const struct GNUNET_ATS_Information *atsi,
@@ -555,7 +571,7 @@ GAS_addresses_update (const struct GNUNET_PeerIdentity *peer,
555 GNUNET_assert (NULL != handle->addresses); 571 GNUNET_assert (NULL != handle->addresses);
556 572
557 /* Get existing address */ 573 /* Get existing address */
558 aa = lookup_address (peer, plugin_name, plugin_addr, plugin_addr_len, 574 aa = lookup_address (handle, peer, plugin_name, plugin_addr, plugin_addr_len,
559 session_id, atsi, atsi_count); 575 session_id, atsi, atsi_count);
560 if (aa == NULL) 576 if (aa == NULL)
561 { 577 {
@@ -637,7 +653,7 @@ destroy_by_session_id (void *cls, const struct GNUNET_HashCode * key, void *valu
637 653
638 /* Notify solver about deletion */ 654 /* Notify solver about deletion */
639 handle->s_del (handle->solver, handle->addresses, aa, GNUNET_NO); 655 handle->s_del (handle->solver, handle->addresses, aa, GNUNET_NO);
640 destroy_address (aa); 656 destroy_address (handle, aa);
641 dc->result = GNUNET_NO; 657 dc->result = GNUNET_NO;
642 return GNUNET_OK; /* Continue iteration */ 658 return GNUNET_OK; /* Continue iteration */
643 } 659 }
@@ -667,7 +683,7 @@ destroy_by_session_id (void *cls, const struct GNUNET_HashCode * key, void *valu
667 683
668 /* Notify solver about deletion */ 684 /* Notify solver about deletion */
669 handle->s_del (handle->solver, handle->addresses, aa, GNUNET_NO); 685 handle->s_del (handle->solver, handle->addresses, aa, GNUNET_NO);
670 destroy_address (aa); 686 destroy_address (handle, aa);
671 dc->result = GNUNET_NO; 687 dc->result = GNUNET_NO;
672 return GNUNET_OK; /* Continue iteration */ 688 return GNUNET_OK; /* Continue iteration */
673 } 689 }
@@ -687,7 +703,8 @@ destroy_by_session_id (void *cls, const struct GNUNET_HashCode * key, void *valu
687} 703}
688 704
689void 705void
690GAS_addresses_destroy (const struct GNUNET_PeerIdentity *peer, 706GAS_addresses_destroy (struct GAS_Addresses_Handle *handle,
707 const struct GNUNET_PeerIdentity *peer,
691 const char *plugin_name, const void *plugin_addr, 708 const char *plugin_name, const void *plugin_addr,
692 size_t plugin_addr_len, uint32_t session_id) 709 size_t plugin_addr_len, uint32_t session_id)
693{ 710{
@@ -698,7 +715,7 @@ GAS_addresses_destroy (const struct GNUNET_PeerIdentity *peer,
698 return; 715 return;
699 716
700 /* Get existing address */ 717 /* Get existing address */
701 ea = lookup_address (peer, plugin_name, plugin_addr, plugin_addr_len, 718 ea = lookup_address (handle, peer, plugin_name, plugin_addr, plugin_addr_len,
702 session_id, NULL, 0); 719 session_id, NULL, 0);
703 720
704 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 721 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -724,11 +741,12 @@ GAS_addresses_destroy (const struct GNUNET_PeerIdentity *peer,
724 741
725 742
726int 743int
727GAS_addresses_in_use (const struct GNUNET_PeerIdentity *peer, 744GAS_addresses_in_use (struct GAS_Addresses_Handle *handle,
745 const struct GNUNET_PeerIdentity *peer,
728 const char *plugin_name, const void *plugin_addr, 746 const char *plugin_name, const void *plugin_addr,
729 size_t plugin_addr_len, uint32_t session_id, int in_use) 747 size_t plugin_addr_len, uint32_t session_id, int in_use)
730{ 748{
731 struct ATS_Address *old; 749 struct ATS_Address *ea;
732 750
733 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 751 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
734 "Received `%s' for peer `%s'\n", 752 "Received `%s' for peer `%s'\n",
@@ -738,8 +756,10 @@ GAS_addresses_in_use (const struct GNUNET_PeerIdentity *peer,
738 if (GNUNET_NO == handle->running) 756 if (GNUNET_NO == handle->running)
739 return GNUNET_SYSERR; 757 return GNUNET_SYSERR;
740 758
741 old = lookup_address (peer, plugin_name, plugin_addr, plugin_addr_len, session_id, NULL, 0); 759 ea = lookup_address (handle, peer, plugin_name,
742 if (NULL == old) 760 plugin_addr, plugin_addr_len,
761 session_id, NULL, 0);
762 if (NULL == ea)
743 { 763 {
744 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 764 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
745 "Trying to set unknown address `%s', %s %u %s \n", 765 "Trying to set unknown address `%s', %s %u %s \n",
@@ -749,20 +769,20 @@ GAS_addresses_in_use (const struct GNUNET_PeerIdentity *peer,
749 GNUNET_break (0); 769 GNUNET_break (0);
750 return GNUNET_SYSERR; 770 return GNUNET_SYSERR;
751 } 771 }
752 if (old->used == in_use) 772 if (ea->used == in_use)
753 { 773 {
754 GNUNET_break (0); 774 GNUNET_break (0);
755 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 775 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
756 "Address in use called multiple times for peer `%s': %s -> %s \n", 776 "Address in use called multiple times for peer `%s': %s -> %s \n",
757 GNUNET_i2s (peer), 777 GNUNET_i2s (peer),
758 (GNUNET_NO == old->used) ? "NO" : "YES", 778 (GNUNET_NO == ea->used) ? "NO" : "YES",
759 (GNUNET_NO == in_use) ? "NO" : "YES"); 779 (GNUNET_NO == in_use) ? "NO" : "YES");
760 return GNUNET_SYSERR; 780 return GNUNET_SYSERR;
761 } 781 }
762 old->used = in_use; 782 ea->used = in_use;
763 783
764 /* Tell solver about update */ 784 /* Tell solver about update */
765 handle->s_update (handle->solver, handle->addresses, old); 785 handle->s_update (handle->solver, handle->addresses, ea);
766 786
767 return GNUNET_OK; 787 return GNUNET_OK;
768} 788}
@@ -774,7 +794,8 @@ GAS_addresses_in_use (const struct GNUNET_PeerIdentity *peer,
774 * @param peer the respective peer 794 * @param peer the respective peer
775 */ 795 */
776void 796void
777GAS_addresses_request_address_cancel (const struct GNUNET_PeerIdentity *peer) 797GAS_addresses_request_address_cancel (struct GAS_Addresses_Handle *handle,
798 const struct GNUNET_PeerIdentity *peer)
778{ 799{
779 struct GAS_Addresses_Suggestion_Requests *cur = handle->r_head; 800 struct GAS_Addresses_Suggestion_Requests *cur = handle->r_head;
780 801
@@ -794,7 +815,7 @@ GAS_addresses_request_address_cancel (const struct GNUNET_PeerIdentity *peer)
794 "No address requests pending for peer `%s', cannot remove!\n", GNUNET_i2s (peer)); 815 "No address requests pending for peer `%s', cannot remove!\n", GNUNET_i2s (peer));
795 return; 816 return;
796 } 817 }
797 GAS_addresses_handle_backoff_reset (peer); 818 GAS_addresses_handle_backoff_reset (handle, peer);
798 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 819 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
799 "Removed request pending for peer `%s\n", GNUNET_i2s (peer)); 820 "Removed request pending for peer `%s\n", GNUNET_i2s (peer));
800 GNUNET_CONTAINER_DLL_remove (handle->r_head, handle->r_tail, cur); 821 GNUNET_CONTAINER_DLL_remove (handle->r_head, handle->r_tail, cur);
@@ -808,7 +829,8 @@ GAS_addresses_request_address_cancel (const struct GNUNET_PeerIdentity *peer)
808 * @param peer the respective peer 829 * @param peer the respective peer
809 */ 830 */
810void 831void
811GAS_addresses_request_address (const struct GNUNET_PeerIdentity *peer) 832GAS_addresses_request_address (struct GAS_Addresses_Handle *handle,
833 const struct GNUNET_PeerIdentity *peer)
812{ 834{
813 struct GAS_Addresses_Suggestion_Requests *cur = handle->r_head; 835 struct GAS_Addresses_Suggestion_Requests *cur = handle->r_head;
814 struct ATS_Address *aa; 836 struct ATS_Address *aa;
@@ -883,7 +905,8 @@ reset_address_it (void *cls, const struct GNUNET_HashCode * key, void *value)
883 905
884 906
885void 907void
886GAS_addresses_handle_backoff_reset (const struct GNUNET_PeerIdentity *peer) 908GAS_addresses_handle_backoff_reset (struct GAS_Addresses_Handle *handle,
909 const struct GNUNET_PeerIdentity *peer)
887{ 910{
888 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 911 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
889 "Received `%s' for peer `%s'\n", 912 "Received `%s' for peer `%s'\n",
@@ -898,7 +921,8 @@ GAS_addresses_handle_backoff_reset (const struct GNUNET_PeerIdentity *peer)
898 921
899 922
900void 923void
901GAS_addresses_change_preference (const struct GNUNET_PeerIdentity *peer, 924GAS_addresses_change_preference (struct GAS_Addresses_Handle *handle,
925 const struct GNUNET_PeerIdentity *peer,
902 enum GNUNET_ATS_PreferenceKind kind, 926 enum GNUNET_ATS_PreferenceKind kind,
903 float score) 927 float score)
904{ 928{
@@ -997,9 +1021,14 @@ load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned long long *
997 1021
998 1022
999static void 1023static void
1000bandwidth_changed_cb (struct ATS_Address *address) 1024bandwidth_changed_cb (void *cls, struct ATS_Address *address)
1001{ 1025{
1026 struct GAS_Addresses_Handle *handle = cls;
1002 struct GAS_Addresses_Suggestion_Requests *cur; 1027 struct GAS_Addresses_Suggestion_Requests *cur;
1028
1029 GNUNET_assert (handle != NULL);
1030 GNUNET_assert (address != NULL);
1031
1003 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Bandwidth assignment changed for peer %s \n", GNUNET_i2s(&address->peer)); 1032 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Bandwidth assignment changed for peer %s \n", GNUNET_i2s(&address->peer));
1004 struct GNUNET_ATS_Information *ats; 1033 struct GNUNET_ATS_Information *ats;
1005 unsigned int ats_count; 1034 unsigned int ats_count;
@@ -1052,9 +1081,9 @@ GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
1052 int c; 1081 int c;
1053 1082
1054 ah = GNUNET_malloc (sizeof (struct GAS_Addresses_Handle)); 1083 ah = GNUNET_malloc (sizeof (struct GAS_Addresses_Handle));
1055 handle = ah; 1084 ah->running = GNUNET_NO;
1056 handle->running = GNUNET_NO;
1057 1085
1086 ah->stat = (struct GNUNET_STATISTICS_Handle *) stats;
1058 /* Initialize the addresses database */ 1087 /* Initialize the addresses database */
1059 ah->addresses = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO); 1088 ah->addresses = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO);
1060 GNUNET_assert (NULL != ah->addresses); 1089 GNUNET_assert (NULL != ah->addresses);
@@ -1134,7 +1163,7 @@ GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
1134 1163
1135 quota_count = load_quotas(cfg, quotas_in, quotas_out, GNUNET_ATS_NetworkTypeCount); 1164 quota_count = load_quotas(cfg, quotas_in, quotas_out, GNUNET_ATS_NetworkTypeCount);
1136 1165
1137 ah->solver = ah->s_init (cfg, stats, quotas, quotas_in, quotas_out, quota_count, &bandwidth_changed_cb); 1166 ah->solver = ah->s_init (cfg, stats, quotas, quotas_in, quotas_out, quota_count, &bandwidth_changed_cb, ah);
1138 if (NULL == ah->solver) 1167 if (NULL == ah->solver)
1139 { 1168 {
1140 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to initialize solver!\n"); 1169 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to initialize solver!\n");
@@ -1162,7 +1191,7 @@ free_address_it (void *cls, const struct GNUNET_HashCode * key, void *value)
1162 struct GAS_Addresses_Handle *handle = cls; 1191 struct GAS_Addresses_Handle *handle = cls;
1163 struct ATS_Address *aa = value; 1192 struct ATS_Address *aa = value;
1164 handle->s_del (handle->solver, handle->addresses, aa, GNUNET_NO); 1193 handle->s_del (handle->solver, handle->addresses, aa, GNUNET_NO);
1165 destroy_address (aa); 1194 destroy_address (handle, aa);
1166 return GNUNET_OK; 1195 return GNUNET_OK;
1167} 1196}
1168 1197
@@ -1241,7 +1270,7 @@ peer_it (void *cls,
1241 * @param p_it_cls the closure for the iterator 1270 * @param p_it_cls the closure for the iterator
1242 */ 1271 */
1243void 1272void
1244GAS_addresses_iterate_peers (GNUNET_ATS_Peer_Iterator p_it, void *p_it_cls) 1273GAS_addresses_iterate_peers (struct GAS_Addresses_Handle *handle, GNUNET_ATS_Peer_Iterator p_it, void *p_it_cls)
1245{ 1274{
1246 struct PeerIteratorContext ip_ctx; 1275 struct PeerIteratorContext ip_ctx;
1247 unsigned int size; 1276 unsigned int size;
@@ -1305,7 +1334,10 @@ peerinfo_it (void *cls,
1305 * @param pi_it_cls the closure for the iterator 1334 * @param pi_it_cls the closure for the iterator
1306 */ 1335 */
1307void 1336void
1308GAS_addresses_get_peer_info (const struct GNUNET_PeerIdentity *peer, GNUNET_ATS_PeerInfo_Iterator pi_it, void *pi_it_cls) 1337GAS_addresses_get_peer_info (struct GAS_Addresses_Handle *handle,
1338 const struct GNUNET_PeerIdentity *peer,
1339 GNUNET_ATS_PeerInfo_Iterator pi_it,
1340 void *pi_it_cls)
1309{ 1341{
1310 struct PeerInfoIteratorContext pi_ctx; 1342 struct PeerInfoIteratorContext pi_ctx;
1311 struct GNUNET_BANDWIDTH_Value32NBO zero_bw; 1343 struct GNUNET_BANDWIDTH_Value32NBO zero_bw;
diff --git a/src/ats/gnunet-service-ats_addresses.h b/src/ats/gnunet-service-ats_addresses.h
index 31b747300..b5c665992 100644
--- a/src/ats/gnunet-service-ats_addresses.h
+++ b/src/ats/gnunet-service-ats_addresses.h
@@ -34,6 +34,8 @@
34 34
35#define ATS_BLOCKING_DELTA GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100) 35#define ATS_BLOCKING_DELTA GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100)
36 36
37struct GAS_Addresses_Handle;
38
37/** 39/**
38 * Address with additional information 40 * Address with additional information
39 */ 41 */
@@ -143,7 +145,7 @@ struct ATS_Address
143 */ 145 */
144 146
145typedef void 147typedef void
146 (*GAS_bandwidth_changed_cb) (struct ATS_Address *address); 148 (*GAS_bandwidth_changed_cb) (void *cls, struct ATS_Address *address);
147 149
148/** 150/**
149 * Init the simplistic problem solving component 151 * Init the simplistic problem solving component
@@ -174,7 +176,8 @@ typedef void *
174 unsigned long long *out_quota, 176 unsigned long long *out_quota,
175 unsigned long long *in_quota, 177 unsigned long long *in_quota,
176 int dest_length, 178 int dest_length,
177 GAS_bandwidth_changed_cb bw_changed_cb); 179 GAS_bandwidth_changed_cb bw_changed_cb,
180 void *bw_changed_cb_cls);
178 181
179 182
180typedef void 183typedef void
@@ -236,18 +239,21 @@ void
236GAS_addresses_done (struct GAS_Addresses_Handle *handle); 239GAS_addresses_done (struct GAS_Addresses_Handle *handle);
237 240
238void 241void
239GAS_addresses_handle_backoff_reset (const struct GNUNET_PeerIdentity *peer); 242GAS_addresses_handle_backoff_reset (struct GAS_Addresses_Handle *handle,
243 const struct GNUNET_PeerIdentity *peer);
240 244
241/** 245/**
242 * This address is now used or not used anymore 246 * This address is now used or not used anymore
243 */ 247 */
244int 248int
245GAS_addresses_in_use (const struct GNUNET_PeerIdentity *peer, 249GAS_addresses_in_use (struct GAS_Addresses_Handle *handle,
250 const struct GNUNET_PeerIdentity *peer,
246 const char *plugin_name, const void *plugin_addr, 251 const char *plugin_name, const void *plugin_addr,
247 size_t plugin_addr_len, uint32_t session_id, int in_use); 252 size_t plugin_addr_len, uint32_t session_id, int in_use);
248 253
249void 254void
250GAS_addresses_update (const struct GNUNET_PeerIdentity *peer, 255GAS_addresses_update (struct GAS_Addresses_Handle *handle,
256 const struct GNUNET_PeerIdentity *peer,
251 const char *plugin_name, const void *plugin_addr, 257 const char *plugin_name, const void *plugin_addr,
252 size_t plugin_addr_len, uint32_t session_id, 258 size_t plugin_addr_len, uint32_t session_id,
253 const struct GNUNET_ATS_Information *atsi, 259 const struct GNUNET_ATS_Information *atsi,
@@ -255,7 +261,8 @@ GAS_addresses_update (const struct GNUNET_PeerIdentity *peer,
255 261
256 262
257void 263void
258GAS_addresses_destroy (const struct GNUNET_PeerIdentity *peer, 264GAS_addresses_destroy (struct GAS_Addresses_Handle *handle,
265 const struct GNUNET_PeerIdentity *peer,
259 const char *plugin_name, const void *plugin_addr, 266 const char *plugin_name, const void *plugin_addr,
260 size_t plugin_addr_len, uint32_t session_id); 267 size_t plugin_addr_len, uint32_t session_id);
261 268
@@ -270,22 +277,26 @@ GAS_addresses_destroy_all (struct GAS_Addresses_Handle *handle);
270 * @param peer the respective peer 277 * @param peer the respective peer
271 */ 278 */
272void 279void
273GAS_addresses_request_address_cancel (const struct GNUNET_PeerIdentity *peer); 280GAS_addresses_request_address_cancel (struct GAS_Addresses_Handle *handle,
281 const struct GNUNET_PeerIdentity *peer);
274 282
275void 283void
276GAS_addresses_request_address (const struct GNUNET_PeerIdentity *peer); 284GAS_addresses_request_address (struct GAS_Addresses_Handle *handle,
285 const struct GNUNET_PeerIdentity *peer);
277 286
278void 287void
279GAS_addresses_change_preference (const struct GNUNET_PeerIdentity *peer, 288GAS_addresses_change_preference (struct GAS_Addresses_Handle *handle,
289 const struct GNUNET_PeerIdentity *peer,
280 enum GNUNET_ATS_PreferenceKind kind, 290 enum GNUNET_ATS_PreferenceKind kind,
281 float score); 291 float score);
282 292
283void 293void
284GAS_addresses_add (const struct GNUNET_PeerIdentity *peer, 294GAS_addresses_add (struct GAS_Addresses_Handle *handle,
285 const char *plugin_name, const void *plugin_addr, 295 const struct GNUNET_PeerIdentity *peer,
286 size_t plugin_addr_len, uint32_t session_id, 296 const char *plugin_name, const void *plugin_addr,
287 const struct GNUNET_ATS_Information *atsi, 297 size_t plugin_addr_len, uint32_t session_id,
288 uint32_t atsi_count); 298 const struct GNUNET_ATS_Information *atsi,
299 uint32_t atsi_count);
289 300
290 301
291typedef void (*GNUNET_ATS_Peer_Iterator) (void *p_it_cls, 302typedef void (*GNUNET_ATS_Peer_Iterator) (void *p_it_cls,
@@ -298,7 +309,9 @@ typedef void (*GNUNET_ATS_Peer_Iterator) (void *p_it_cls,
298 * @param p_it_cls the closure for the iterator 309 * @param p_it_cls the closure for the iterator
299 */ 310 */
300void 311void
301GAS_addresses_iterate_peers (GNUNET_ATS_Peer_Iterator p_it, void *p_it_cls); 312GAS_addresses_iterate_peers (struct GAS_Addresses_Handle *handle,
313 GNUNET_ATS_Peer_Iterator p_it,
314 void *p_it_cls);
302 315
303typedef void (*GNUNET_ATS_PeerInfo_Iterator) (void *p_it_cls, 316typedef void (*GNUNET_ATS_PeerInfo_Iterator) (void *p_it_cls,
304 const struct GNUNET_PeerIdentity *id, 317 const struct GNUNET_PeerIdentity *id,
@@ -319,7 +332,10 @@ typedef void (*GNUNET_ATS_PeerInfo_Iterator) (void *p_it_cls,
319 * @param pi_it_cls the closure for the iterator 332 * @param pi_it_cls the closure for the iterator
320 */ 333 */
321void 334void
322GAS_addresses_get_peer_info (const struct GNUNET_PeerIdentity *peer, GNUNET_ATS_PeerInfo_Iterator pi_it, void *pi_it_cls); 335GAS_addresses_get_peer_info (struct GAS_Addresses_Handle *handle,
336 const struct GNUNET_PeerIdentity *peer,
337 GNUNET_ATS_PeerInfo_Iterator pi_it,
338 void *pi_it_cls);
323 339
324#endif 340#endif
325 341
diff --git a/src/ats/gnunet-service-ats_addresses_mlp.c b/src/ats/gnunet-service-ats_addresses_mlp.c
index fe212e78e..4dbf02cd7 100644
--- a/src/ats/gnunet-service-ats_addresses_mlp.c
+++ b/src/ats/gnunet-service-ats_addresses_mlp.c
@@ -1082,7 +1082,8 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
1082 unsigned long long *out_dest, 1082 unsigned long long *out_dest,
1083 unsigned long long *in_dest, 1083 unsigned long long *in_dest,
1084 int dest_length, 1084 int dest_length,
1085 GAS_bandwidth_changed_cb bw_changed_cb) 1085 GAS_bandwidth_changed_cb bw_changed_cb,
1086 void *bw_changed_cb_cls)
1086{ 1087{
1087 struct GAS_MLP_Handle * mlp = GNUNET_malloc (sizeof (struct GAS_MLP_Handle)); 1088 struct GAS_MLP_Handle * mlp = GNUNET_malloc (sizeof (struct GAS_MLP_Handle));
1088 1089
diff --git a/src/ats/gnunet-service-ats_addresses_mlp.h b/src/ats/gnunet-service-ats_addresses_mlp.h
index ea7f87af6..49996ba51 100644
--- a/src/ats/gnunet-service-ats_addresses_mlp.h
+++ b/src/ats/gnunet-service-ats_addresses_mlp.h
@@ -326,7 +326,8 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
326 unsigned long long *out_dest, 326 unsigned long long *out_dest,
327 unsigned long long *in_dest, 327 unsigned long long *in_dest,
328 int dest_length, 328 int dest_length,
329 GAS_bandwidth_changed_cb bw_changed_cb); 329 GAS_bandwidth_changed_cb bw_changed_cb,
330 void *bw_changed_cb_cls);
330 331
331 332
332/** 333/**
diff --git a/src/ats/gnunet-service-ats_addresses_simplistic.c b/src/ats/gnunet-service-ats_addresses_simplistic.c
index 84e8911d1..37491dd7f 100644
--- a/src/ats/gnunet-service-ats_addresses_simplistic.c
+++ b/src/ats/gnunet-service-ats_addresses_simplistic.c
@@ -68,6 +68,7 @@ struct GAS_SIMPLISTIC_Handle
68 68
69 unsigned int networks; 69 unsigned int networks;
70 GAS_bandwidth_changed_cb bw_changed; 70 GAS_bandwidth_changed_cb bw_changed;
71 void *bw_changed_cls;
71}; 72};
72 73
73struct Network 74struct Network
@@ -144,7 +145,8 @@ GAS_simplistic_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
144 unsigned long long *out_quota, 145 unsigned long long *out_quota,
145 unsigned long long *in_quota, 146 unsigned long long *in_quota,
146 int dest_length, 147 int dest_length,
147 GAS_bandwidth_changed_cb bw_changed_cb) 148 GAS_bandwidth_changed_cb bw_changed_cb,
149 void *bw_changed_cb_cls)
148{ 150{
149 int c; 151 int c;
150 struct GAS_SIMPLISTIC_Handle *s = GNUNET_malloc (sizeof (struct GAS_SIMPLISTIC_Handle)); 152 struct GAS_SIMPLISTIC_Handle *s = GNUNET_malloc (sizeof (struct GAS_SIMPLISTIC_Handle));
@@ -152,6 +154,7 @@ GAS_simplistic_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
152 char * net_str[GNUNET_ATS_NetworkTypeCount] = {"UNSPECIFIED", "LOOPBACK", "LAN", "WAN", "WLAN"}; 154 char * net_str[GNUNET_ATS_NetworkTypeCount] = {"UNSPECIFIED", "LOOPBACK", "LAN", "WAN", "WLAN"};
153 155
154 s->bw_changed = bw_changed_cb; 156 s->bw_changed = bw_changed_cb;
157 s->bw_changed_cls = bw_changed_cb_cls;
155 s->networks = dest_length; 158 s->networks = dest_length;
156 s->network_entries = GNUNET_malloc (dest_length * sizeof (struct Network)); 159 s->network_entries = GNUNET_malloc (dest_length * sizeof (struct Network));
157 s->active_addresses = 0; 160 s->active_addresses = 0;
@@ -277,7 +280,7 @@ update_quota_per_network (struct GAS_SIMPLISTIC_Handle *s,
277 cur->addr->assigned_bw_out.value__ = htonl (quota_out); 280 cur->addr->assigned_bw_out.value__ = htonl (quota_out);
278 /* Notify on change */ 281 /* Notify on change */
279 if ((GNUNET_YES == cur->addr->active) && (cur->addr != address_except)) 282 if ((GNUNET_YES == cur->addr->active) && (cur->addr != address_except))
280 s->bw_changed (cur->addr); 283 s->bw_changed (s->bw_changed_cls, cur->addr);
281 } 284 }
282 cur = cur->next; 285 cur = cur->next;
283 } 286 }
@@ -606,7 +609,7 @@ GAS_simplistic_get_preferred_address (void *solver,
606 prev->active = GNUNET_NO; /* No active any longer */ 609 prev->active = GNUNET_NO; /* No active any longer */
607 prev->assigned_bw_in = GNUNET_BANDWIDTH_value_init (0); /* no bw assigned */ 610 prev->assigned_bw_in = GNUNET_BANDWIDTH_value_init (0); /* no bw assigned */
608 prev->assigned_bw_out = GNUNET_BANDWIDTH_value_init (0); /* no bw assigned */ 611 prev->assigned_bw_out = GNUNET_BANDWIDTH_value_init (0); /* no bw assigned */
609 s->bw_changed (prev); /* notify about bw change, REQUIRED? */ 612 s->bw_changed (s->bw_changed_cls, prev); /* notify about bw change, REQUIRED? */
610 if (net_prev->active_addresses < 1) 613 if (net_prev->active_addresses < 1)
611 GNUNET_break (0); 614 GNUNET_break (0);
612 else 615 else
diff --git a/src/ats/gnunet-service-ats_addresses_simplistic.h b/src/ats/gnunet-service-ats_addresses_simplistic.h
index 773772583..3fd36cf32 100644
--- a/src/ats/gnunet-service-ats_addresses_simplistic.h
+++ b/src/ats/gnunet-service-ats_addresses_simplistic.h
@@ -59,7 +59,8 @@ GAS_simplistic_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
59 unsigned long long *out_quota, 59 unsigned long long *out_quota,
60 unsigned long long *in_quota, 60 unsigned long long *in_quota,
61 int dest_length, 61 int dest_length,
62 GAS_bandwidth_changed_cb bw_changed_cb); 62 GAS_bandwidth_changed_cb bw_changed_cb,
63 void *bw_changed_cb_cls);
63 64
64/** 65/**
65 * Shutdown the simplistic problem solving component 66 * Shutdown the simplistic problem solving component
diff --git a/src/ats/gnunet-service-ats_performance.c b/src/ats/gnunet-service-ats_performance.c
index c762ebc33..ef6e5572a 100644
--- a/src/ats/gnunet-service-ats_performance.c
+++ b/src/ats/gnunet-service-ats_performance.c
@@ -77,6 +77,10 @@ struct AddressIteration
77 unsigned int msg_type; 77 unsigned int msg_type;
78}; 78};
79 79
80/**
81 * Address handle
82 */
83static struct GAS_Addresses_Handle *GSA_addresses;
80 84
81/** 85/**
82 * Head of linked list of all clients to this service. 86 * Head of linked list of all clients to this service.
@@ -288,7 +292,7 @@ peer_it (void *cls,
288 if (NULL != id) 292 if (NULL != id)
289 { 293 {
290 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for peer `%s'\n", GNUNET_i2s (id)); 294 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for peer `%s'\n", GNUNET_i2s (id));
291 GAS_addresses_get_peer_info (id, &peerinfo_it, pc); 295 GAS_addresses_get_peer_info (GSA_addresses, id, &peerinfo_it, pc);
292 } 296 }
293} 297}
294 298
@@ -313,7 +317,7 @@ GAS_performance_add_client (struct GNUNET_SERVER_Client *client,
313 GNUNET_CONTAINER_DLL_insert (pc_head, pc_tail, pc); 317 GNUNET_CONTAINER_DLL_insert (pc_head, pc_tail, pc);
314 318
315 /* Send information about clients */ 319 /* Send information about clients */
316 GAS_addresses_iterate_peers (&peer_it, pc); 320 GAS_addresses_iterate_peers (GSA_addresses, &peer_it, pc);
317} 321}
318 322
319static void transmit_req_addr (struct AddressIteration *ai, 323static void transmit_req_addr (struct AddressIteration *ai,
@@ -442,7 +446,7 @@ req_addr_peer_it (void *cls,
442 if (NULL != id) 446 if (NULL != id)
443 { 447 {
444 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for peer `%s'\n", GNUNET_i2s (id)); 448 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for peer `%s'\n", GNUNET_i2s (id));
445 GAS_addresses_get_peer_info (id, &req_addr_peerinfo_it, ai); 449 GAS_addresses_get_peer_info (GSA_addresses, id, &req_addr_peerinfo_it, ai);
446 } 450 }
447 else 451 else
448 { 452 {
@@ -485,13 +489,13 @@ GAS_handle_request_address_list (void *cls, struct GNUNET_SERVER_Client *client,
485 if (0 == memcmp (&alrm->peer, &allzeros, sizeof (struct GNUNET_PeerIdentity))) 489 if (0 == memcmp (&alrm->peer, &allzeros, sizeof (struct GNUNET_PeerIdentity)))
486 { 490 {
487 /* Return addresses for all peers */ 491 /* Return addresses for all peers */
488 GAS_addresses_iterate_peers (&req_addr_peer_it, &ai); 492 GAS_addresses_iterate_peers (GSA_addresses, &req_addr_peer_it, &ai);
489 transmit_req_addr (&ai, NULL, NULL, NULL, 0, GNUNET_NO, NULL, 0, bandwidth_zero, bandwidth_zero); 493 transmit_req_addr (&ai, NULL, NULL, NULL, 0, GNUNET_NO, NULL, 0, bandwidth_zero, bandwidth_zero);
490 } 494 }
491 else 495 else
492 { 496 {
493 /* Return addresses for a specific peer */ 497 /* Return addresses for a specific peer */
494 GAS_addresses_get_peer_info (&alrm->peer, &req_addr_peerinfo_it, &ai); 498 GAS_addresses_get_peer_info (GSA_addresses, &alrm->peer, &req_addr_peerinfo_it, &ai);
495 transmit_req_addr (&ai, NULL, NULL, NULL, 0, GNUNET_NO, NULL, 0, bandwidth_zero, bandwidth_zero); 499 transmit_req_addr (&ai, NULL, NULL, NULL, 0, GNUNET_NO, NULL, 0, bandwidth_zero, bandwidth_zero);
496 } 500 }
497 GNUNET_SERVER_receive_done (client, GNUNET_OK); 501 GNUNET_SERVER_receive_done (client, GNUNET_OK);
@@ -582,7 +586,7 @@ GAS_handle_preference_change (void *cls, struct GNUNET_SERVER_Client *client,
582 1, GNUNET_NO); 586 1, GNUNET_NO);
583 pi = (const struct PreferenceInformation *) &msg[1]; 587 pi = (const struct PreferenceInformation *) &msg[1];
584 for (i = 0; i < nump; i++) 588 for (i = 0; i < nump; i++)
585 GAS_addresses_change_preference (&msg->peer, 589 GAS_addresses_change_preference (GSA_addresses, &msg->peer,
586 (enum GNUNET_ATS_PreferenceKind) 590 (enum GNUNET_ATS_PreferenceKind)
587 ntohl (pi[i].preference_kind), 591 ntohl (pi[i].preference_kind),
588 pi[i].preference_value); 592 pi[i].preference_value);
@@ -596,8 +600,10 @@ GAS_handle_preference_change (void *cls, struct GNUNET_SERVER_Client *client,
596 * @param server handle to our server 600 * @param server handle to our server
597 */ 601 */
598void 602void
599GAS_performance_init (struct GNUNET_SERVER_Handle *server) 603GAS_performance_init (struct GNUNET_SERVER_Handle *server,
604 struct GAS_Addresses_Handle *addresses)
600{ 605{
606 GSA_addresses = addresses;
601 nc = GNUNET_SERVER_notification_context_create (server, 128); 607 nc = GNUNET_SERVER_notification_context_create (server, 128);
602} 608}
603 609
diff --git a/src/ats/gnunet-service-ats_performance.h b/src/ats/gnunet-service-ats_performance.h
index f237c71ac..0ef481d48 100644
--- a/src/ats/gnunet-service-ats_performance.h
+++ b/src/ats/gnunet-service-ats_performance.h
@@ -120,7 +120,8 @@ GAS_handle_preference_change (void *cls, struct GNUNET_SERVER_Client *client,
120 * @param server handle to our server 120 * @param server handle to our server
121 */ 121 */
122void 122void
123GAS_performance_init (struct GNUNET_SERVER_Handle *server); 123GAS_performance_init (struct GNUNET_SERVER_Handle *server,
124 struct GAS_Addresses_Handle *GSA_addresses);
124 125
125 126
126/** 127/**
diff --git a/src/ats/gnunet-service-ats_scheduling.c b/src/ats/gnunet-service-ats_scheduling.c
index 4526e1286..70009b310 100644
--- a/src/ats/gnunet-service-ats_scheduling.c
+++ b/src/ats/gnunet-service-ats_scheduling.c
@@ -171,10 +171,8 @@ GAS_handle_request_address (void *cls, struct GNUNET_SERVER_Client *client,
171 171
172 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", 172 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n",
173 "REQUEST_ADDRESS"); 173 "REQUEST_ADDRESS");
174 GNUNET_STATISTICS_update (GSA_stats, "# address requests received", 1,
175 GNUNET_NO);
176 GNUNET_break (0 == ntohl (msg->reserved)); 174 GNUNET_break (0 == ntohl (msg->reserved));
177 GAS_addresses_request_address (&msg->peer); 175 GAS_addresses_request_address (address_handle, &msg->peer);
178 GNUNET_SERVER_receive_done (client, GNUNET_OK); 176 GNUNET_SERVER_receive_done (client, GNUNET_OK);
179} 177}
180 178
@@ -198,7 +196,7 @@ GAS_handle_request_address_cancel (void *cls,
198 "REQUEST_ADDRESS_CANCEL"); 196 "REQUEST_ADDRESS_CANCEL");
199 GNUNET_break (0 == ntohl (msg->reserved)); 197 GNUNET_break (0 == ntohl (msg->reserved));
200 198
201 GAS_addresses_request_address_cancel (&msg->peer); 199 GAS_addresses_request_address_cancel (address_handle, &msg->peer);
202 200
203 GNUNET_SERVER_receive_done (client, GNUNET_OK); 201 GNUNET_SERVER_receive_done (client, GNUNET_OK);
204} 202}
@@ -220,10 +218,8 @@ GAS_handle_reset_backoff (void *cls,
220 218
221 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", 219 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n",
222 "RESET_BACKOFF"); 220 "RESET_BACKOFF");
223 GNUNET_STATISTICS_update (GSA_stats, "# backoff reset requests received", 1,
224 GNUNET_NO);
225 GNUNET_break (0 == ntohl (msg->reserved)); 221 GNUNET_break (0 == ntohl (msg->reserved));
226 GAS_addresses_handle_backoff_reset (&msg->peer); 222 GAS_addresses_handle_backoff_reset (address_handle, &msg->peer);
227 GNUNET_SERVER_receive_done (client, GNUNET_OK); 223 GNUNET_SERVER_receive_done (client, GNUNET_OK);
228} 224}
229 225
@@ -280,7 +276,7 @@ GAS_handle_address_add (void *cls, struct GNUNET_SERVER_Client *client,
280 } 276 }
281 GNUNET_STATISTICS_update (GSA_stats, "# address updates received", 1, 277 GNUNET_STATISTICS_update (GSA_stats, "# address updates received", 1,
282 GNUNET_NO); 278 GNUNET_NO);
283 GAS_addresses_add (&m->peer, plugin_name, address, address_length, 279 GAS_addresses_add (address_handle, &m->peer, plugin_name, address, address_length,
284 ntohl (m->session_id), atsi, ats_count); 280 ntohl (m->session_id), atsi, ats_count);
285 GNUNET_SERVER_receive_done (client, GNUNET_OK); 281 GNUNET_SERVER_receive_done (client, GNUNET_OK);
286} 282}
@@ -339,7 +335,7 @@ GAS_handle_address_update (void *cls, struct GNUNET_SERVER_Client *client,
339 } 335 }
340 GNUNET_STATISTICS_update (GSA_stats, "# address updates received", 1, 336 GNUNET_STATISTICS_update (GSA_stats, "# address updates received", 1,
341 GNUNET_NO); 337 GNUNET_NO);
342 GAS_addresses_update (&m->peer, plugin_name, address, address_length, 338 GAS_addresses_update (address_handle, &m->peer, plugin_name, address, address_length,
343 ntohl (m->session_id), atsi, ats_count); 339 ntohl (m->session_id), atsi, ats_count);
344 GNUNET_SERVER_receive_done (client, GNUNET_OK); 340 GNUNET_SERVER_receive_done (client, GNUNET_OK);
345} 341}
@@ -395,12 +391,13 @@ GAS_handle_address_in_use (void *cls, struct GNUNET_SERVER_Client *client,
395 } 391 }
396 392
397 in_use = ntohs (m->in_use); 393 in_use = ntohs (m->in_use);
398 res = GAS_addresses_in_use (&m->peer, 394 res = GAS_addresses_in_use (address_handle,
399 plugin_name, 395 &m->peer,
400 address, 396 plugin_name,
401 address_length, 397 address,
402 ntohl (m->session_id), 398 address_length,
403 in_use); 399 ntohl (m->session_id),
400 in_use);
404 401
405 if (res == GNUNET_OK) 402 if (res == GNUNET_OK)
406 GNUNET_SERVER_receive_done (client, GNUNET_OK); 403 GNUNET_SERVER_receive_done (client, GNUNET_OK);
@@ -465,7 +462,8 @@ GAS_handle_address_destroyed (void *cls, struct GNUNET_SERVER_Client *client,
465 return; 462 return;
466 } 463 }
467 GNUNET_STATISTICS_update (GSA_stats, "# addresses destroyed", 1, GNUNET_NO); 464 GNUNET_STATISTICS_update (GSA_stats, "# addresses destroyed", 1, GNUNET_NO);
468 GAS_addresses_destroy (&m->peer, plugin_name, address, address_length, 465 GAS_addresses_destroy (address_handle, &m->peer, plugin_name,
466 address, address_length,
469 ntohl (m->session_id)); 467 ntohl (m->session_id));
470 if (0 != ntohl (m->session_id)) 468 if (0 != ntohl (m->session_id))
471 { 469 {
diff --git a/src/sysmon/Makefile.am b/src/sysmon/Makefile.am
index dd9c24691..0e87a627f 100644
--- a/src/sysmon/Makefile.am
+++ b/src/sysmon/Makefile.am
@@ -16,16 +16,16 @@ if USE_COVERAGE
16endif 16endif
17 17
18libexec_PROGRAMS = \ 18libexec_PROGRAMS = \
19 gnunet_daemon_sysmon 19 gnunet_service_sysmon
20 20
21check_PROGRAMS = \ 21check_PROGRAMS = \
22 test_glibtop \ 22 test_glibtop \
23 test_glibtop_process \ 23 test_glibtop_process \
24 test_glibtop_network 24 test_glibtop_network
25 25
26gnunet_daemon_sysmon_SOURCES = \ 26gnunet_service_sysmon_SOURCES = \
27 gnunet-daemon-sysmon.c 27 gnunet-service-sysmon.c
28gnunet_daemon_sysmon_LDADD = \ 28gnunet_service_sysmon_LDADD = \
29 $(top_builddir)/src/util/libgnunetutil.la \ 29 $(top_builddir)/src/util/libgnunetutil.la \
30 $(top_builddir)/src/statistics/libgnunetstatistics.la \ 30 $(top_builddir)/src/statistics/libgnunetstatistics.la \
31 $(GN_LIBINTL) 31 $(GN_LIBINTL)
diff --git a/src/sysmon/gnunet-daemon-sysmon.c b/src/sysmon/gnunet-service-sysmon.c
index 3fb0fdd5a..32b4ccbed 100644
--- a/src/sysmon/gnunet-daemon-sysmon.c
+++ b/src/sysmon/gnunet-service-sysmon.c
@@ -19,8 +19,8 @@
19*/ 19*/
20 20
21/** 21/**
22 * @file sysmon/gnunet-daemon-sysmon.c 22 * @file sysmon/gnunet-service-sysmon.c
23 * @brief system monitoring daemon 23 * @brief system monitoring service
24 * @author Matthias Wachs 24 * @author Matthias Wachs
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
@@ -508,18 +508,40 @@ run_properties (void)
508 return GNUNET_OK; 508 return GNUNET_OK;
509} 509}
510 510
511
512/**
513 * Task run during shutdown.
514 *
515 * @param cls unused
516 * @param tc unused
517 */
518static void
519cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
520{
521 /* FIXME: do clean up here */
522}
523
524
511/** 525/**
512 * Main function that will be run by the scheduler. 526 * Process template requests.
513 * 527 *
514 * @param cls closure 528 * @param cls closure
515 * @param args remaining command-line arguments 529 * @param server the initialized server
516 * @param cfgfile name of the configuration file used (for saving, can be NULL!) 530 * @param cfg configuration to use
517 * @param cfg configuration
518 */ 531 */
519static void 532static void
520run (void *cls, char *const *args, const char *cfgfile, 533run (void *cls, struct GNUNET_SERVER_Handle *server,
521 const struct GNUNET_CONFIGURATION_Handle *mycfg) 534 const struct GNUNET_CONFIGURATION_Handle *mycfg)
522{ 535{
536 static const struct GNUNET_SERVER_MessageHandler handlers[] = {
537 /* FIXME: add handlers here! */
538 {NULL, NULL, 0, 0}
539 };
540 /* FIXME: do setup here */
541 GNUNET_SERVER_add_handlers (server, handlers);
542 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup_task,
543 NULL);
544
523 struct GNUNET_CONFIGURATION_Handle *properties; 545 struct GNUNET_CONFIGURATION_Handle *properties;
524 char *file; 546 char *file;
525 547
@@ -590,7 +612,7 @@ run (void *cls, char *const *args, const char *cfgfile,
590 612
591 613
592/** 614/**
593 * The main function. 615 * The main function for the template service.
594 * 616 *
595 * @param argc number of arguments from the command line 617 * @param argc number of arguments from the command line
596 * @param argv command line arguments 618 * @param argv command line arguments
@@ -599,18 +621,9 @@ run (void *cls, char *const *args, const char *cfgfile,
599int 621int
600main (int argc, char *const *argv) 622main (int argc, char *const *argv)
601{ 623{
602 static const struct GNUNET_GETOPT_CommandLineOption options[] = { 624 return (GNUNET_OK ==
603 GNUNET_GETOPT_OPTION_END 625 GNUNET_SERVICE_run (argc, argv, "sysmon",
604 }; 626 GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1;
605 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
606 return 2;
607
608 ret = (GNUNET_OK ==
609 GNUNET_PROGRAM_run (argc, argv, "gnunet-daemon-sysmon",
610 gettext_noop ("GNUnet system monitoring and information daemon"), options, &run,
611 NULL)) ? ret : 1;
612 GNUNET_free ((void*) argv);
613 return ret;
614} 627}
615 628
616/* end of gnunet-daemon-sysmon.c */ 629/* end of gnunet-service-sysmon.c */
diff --git a/src/sysmon/sysmon.conf.in b/src/sysmon/sysmon.conf.in
index b5c4c7355..238f4e2ae 100644
--- a/src/sysmon/sysmon.conf.in
+++ b/src/sysmon/sysmon.conf.in
@@ -5,4 +5,4 @@ HOSTNAME = localhost
5HOME = $SERVICEHOME 5HOME = $SERVICEHOME
6BINARY = gnunet-daemon-sysmon 6BINARY = gnunet-daemon-sysmon
7CFGFILE = sysmon-properties.conf 7CFGFILE = sysmon-properties.conf
8UNIXPATH = /tmp/gnunet-daemon-sysmon.sock 8UNIXPATH = /tmp/gnunet-service-sysmon.sock