diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-07-14 18:20:55 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-07-14 18:20:55 +0000 |
commit | e43155e9ea536991a489e0fe04890e0269869af1 (patch) | |
tree | b6488239217f7c00d7dc109641292b4ba5092ded /src/identity/gnunet-service-identity.c | |
parent | 206b8c58b7e6843ddb4832692b11032d4fe57541 (diff) | |
download | gnunet-e43155e9ea536991a489e0fe04890e0269869af1.tar.gz gnunet-e43155e9ea536991a489e0fe04890e0269869af1.zip |
-skeleton for identity service
Diffstat (limited to 'src/identity/gnunet-service-identity.c')
-rw-r--r-- | src/identity/gnunet-service-identity.c | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/src/identity/gnunet-service-identity.c b/src/identity/gnunet-service-identity.c new file mode 100644 index 000000000..05f9ce134 --- /dev/null +++ b/src/identity/gnunet-service-identity.c | |||
@@ -0,0 +1,97 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2013 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file identity/gnunet-service-identity.c | ||
23 | * @brief network size estimation service | ||
24 | * @author Nathan Evans | ||
25 | * @author Christian Grothoff | ||
26 | * | ||
27 | * The purpose of this service is to estimate the size of the network. | ||
28 | * Given a specified interval, each peer hashes the most recent | ||
29 | * timestamp which is evenly divisible by that interval. This hash is | ||
30 | * compared in distance to the peer identity to choose an offset. The | ||
31 | * closer the peer identity to the hashed timestamp, the earlier the | ||
32 | * peer sends out a "nearest peer" message. The closest peer's | ||
33 | * message should thus be received before any others, which stops | ||
34 | * those peer from sending their messages at a later duration. So | ||
35 | * every peer should receive the same nearest peer message, and from | ||
36 | * this can calculate the expected number of peers in the network. | ||
37 | */ | ||
38 | #include "platform.h" | ||
39 | #include <math.h> | ||
40 | #include "gnunet_util_lib.h" | ||
41 | #include "gnunet_constants.h" | ||
42 | #include "gnunet_protocols.h" | ||
43 | #include "gnunet_signatures.h" | ||
44 | #include "gnunet_statistics_service.h" | ||
45 | #include "gnunet_identity_service.h" | ||
46 | #include "identity.h" | ||
47 | |||
48 | /** | ||
49 | * Handle to our current configuration. | ||
50 | */ | ||
51 | static const struct GNUNET_CONFIGURATION_Handle *cfg; | ||
52 | |||
53 | /** | ||
54 | * Handle to the statistics service. | ||
55 | */ | ||
56 | static struct GNUNET_STATISTICS_Handle *stats; | ||
57 | |||
58 | |||
59 | /** | ||
60 | * Handle network size estimate clients. | ||
61 | * | ||
62 | * @param cls closure | ||
63 | * @param server the initialized server | ||
64 | * @param c configuration to use | ||
65 | */ | ||
66 | static void | ||
67 | run (void *cls, | ||
68 | struct GNUNET_SERVER_Handle *server, | ||
69 | const struct GNUNET_CONFIGURATION_Handle *c) | ||
70 | { | ||
71 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { | ||
72 | // {&handle_start_message, NULL, GNUNET_MESSAGE_TYPE_IDENTITY_START, sizeof (struct GNUNET_MessageHeader)}, | ||
73 | {NULL, NULL, 0, 0} | ||
74 | }; | ||
75 | |||
76 | cfg = c; | ||
77 | stats = GNUNET_STATISTICS_create ("identity", cfg); | ||
78 | } | ||
79 | |||
80 | |||
81 | /** | ||
82 | * The main function for the network size estimation service. | ||
83 | * | ||
84 | * @param argc number of arguments from the command line | ||
85 | * @param argv command line arguments | ||
86 | * @return 0 ok, 1 on error | ||
87 | */ | ||
88 | int | ||
89 | main (int argc, char *const *argv) | ||
90 | { | ||
91 | return (GNUNET_OK == | ||
92 | GNUNET_SERVICE_run (argc, argv, "identity", GNUNET_SERVICE_OPTION_NONE, | ||
93 | &run, NULL)) ? 0 : 1; | ||
94 | } | ||
95 | |||
96 | |||
97 | /* end of gnunet-service-identity.c */ | ||