diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-10-24 13:22:24 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-10-24 13:22:24 +0000 |
commit | a546b122ba433c81bb746b501f9398e9cfd8ad23 (patch) | |
tree | e7d19d6744114aee756e5f3e590ac21a4f3f18a4 /src/ats | |
parent | 45d504e2a7cdf5a9fe0482574dfa45f6f364cb38 (diff) | |
download | gnunet-a546b122ba433c81bb746b501f9398e9cfd8ad23.tar.gz gnunet-a546b122ba433c81bb746b501f9398e9cfd8ad23.zip |
basics
Diffstat (limited to 'src/ats')
-rw-r--r-- | src/ats/gnunet-ats.c | 62 |
1 files changed, 28 insertions, 34 deletions
diff --git a/src/ats/gnunet-ats.c b/src/ats/gnunet-ats.c index a6af3abcb..16dff5de3 100644 --- a/src/ats/gnunet-ats.c +++ b/src/ats/gnunet-ats.c | |||
@@ -32,9 +32,31 @@ | |||
32 | */ | 32 | */ |
33 | static int ret; | 33 | static int ret; |
34 | 34 | ||
35 | static char * peer_str; | 35 | static struct GNUNET_ATS_PerformanceHandle *ph; |
36 | 36 | ||
37 | static int all_peers; | 37 | GNUNET_SCHEDULER_Task end_task; |
38 | |||
39 | void testservice_task (void *cls, | ||
40 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
41 | { | ||
42 | struct GNUNET_CONFIGURATION_Handle *cfg = cls; | ||
43 | |||
44 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) | ||
45 | { | ||
46 | FPRINTF (stderr, _("Service `%s' is not running\n"), "ats"); | ||
47 | return; | ||
48 | } | ||
49 | |||
50 | ph = GNUNET_ATS_performance_init (cfg, NULL, NULL); | ||
51 | if (NULL == ph) | ||
52 | fprintf (stderr, "Cannot connect to ATS service, exiting...\n"); | ||
53 | |||
54 | /* FIXME do work here*/ | ||
55 | fprintf (stderr, "NOT IMPLEMENTED\n"); | ||
56 | |||
57 | GNUNET_ATS_performance_done (ph); | ||
58 | ret = 0; | ||
59 | } | ||
38 | 60 | ||
39 | /** | 61 | /** |
40 | * Main function that will be run by the scheduler. | 62 | * Main function that will be run by the scheduler. |
@@ -48,32 +70,10 @@ static void | |||
48 | run (void *cls, char *const *args, const char *cfgfile, | 70 | run (void *cls, char *const *args, const char *cfgfile, |
49 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 71 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
50 | { | 72 | { |
51 | if (GNUNET_YES == all_peers) | 73 | GNUNET_CLIENT_service_test ("ats", cfg, |
52 | { | 74 | GNUNET_TIME_UNIT_SECONDS, |
53 | /* list information for all peers */ | 75 | &testservice_task, |
54 | printf ("To be implemented!\n"); | 76 | (void *) cfg); |
55 | |||
56 | /* TODO: get all peers */ | ||
57 | |||
58 | /* TODO: get addresses for each peer */ | ||
59 | } | ||
60 | else if (NULL != peer_str) | ||
61 | { | ||
62 | /* list information for a specific peer */ | ||
63 | printf ("To be implemented!\n"); | ||
64 | struct GNUNET_PeerIdentity id; | ||
65 | if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string2(peer_str, strlen (peer_str), &id.hashPubKey)) | ||
66 | { | ||
67 | printf ("`%s' is not a valid peer identity\n", peer_str); | ||
68 | GNUNET_free (peer_str); | ||
69 | return; | ||
70 | } | ||
71 | |||
72 | printf ("Peer `%s':\n", GNUNET_i2s_full (&id)); | ||
73 | |||
74 | /* TODO: get addresses for each peer */ | ||
75 | GNUNET_free (peer_str); | ||
76 | } | ||
77 | } | 77 | } |
78 | 78 | ||
79 | 79 | ||
@@ -89,12 +89,6 @@ main (int argc, char *const *argv) | |||
89 | { | 89 | { |
90 | int res; | 90 | int res; |
91 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 91 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { |
92 | {'P', "peer", "PEER", | ||
93 | gettext_noop ("list information for the given peer"), | ||
94 | 1, &GNUNET_GETOPT_set_string, &peer_str}, | ||
95 | {'A', "all", NULL, | ||
96 | gettext_noop ("list information for all peers"), | ||
97 | 0, &GNUNET_GETOPT_set_one, &all_peers}, | ||
98 | GNUNET_GETOPT_OPTION_END | 92 | GNUNET_GETOPT_OPTION_END |
99 | }; | 93 | }; |
100 | 94 | ||