ten minute timeout
[oweals/gnunet.git] / src / include / gnunet_nse_service.h
1 /*
2       This file is part of GNUnet
3       (C) 2009, 2010 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 2, 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 #ifndef GNUNET_NSE_SERVICE_H_
22 #define GNUNET_NSE_SERVICE_H_
23
24 /**
25  * @file include/gnunet_nse_service.h
26  * @brief API to retrieve the current network size estimate,
27  *        also to register for notifications whenever a new
28  *        network size estimate is calculated.
29  *
30  * @author Nathan Evans
31  */
32
33 #ifdef __cplusplus
34 extern "C"
35 {
36 #if 0                           /* keep Emacsens' auto-indent happy */
37 }
38 #endif
39 #endif
40
41 #include "gnunet_common.h"
42 #include "gnunet_configuration_lib.h"
43 #include "gnunet_scheduler_lib.h"
44
45 /**
46  * Version of the network size estimation API.
47  */
48 #define GNUNET_NSE_VERSION 0x00000000
49
50 /**
51  * Interval for sending network size estimation flood requests.
52  * Number is in milliseconds.
53  * This needs to be a factor of the number milliseconds in
54  * a day, as the base time used is midnight each day offset
55  * by this amount.
56  *
57  * There are 86400000 milliseconds in a day.
58  */
59 #if 0
60 #define GNUNET_NSE_INTERVAL 60000 /* Every minute */
61 #define GNUNET_NSE_INTERVAL 180000 /* Every three minutes */
62 #define GNUNET_NSE_INTERVAL 360000 /* Every six minutes */
63 #define GNUNET_NSE_INTERVAL 600000 /* Every ten minutes */
64 #define GNUNET_NSE_INTERVAL 1200000 /* Every twenty minutes */
65 #endif
66 #define GNUNET_NSE_INTERVAL 360000 /* Every ten minutes */
67 /**
68  * How much clock skew (in milliseconds) will we allow
69  * for received messages.  We check our current time
70  * with the timestamp received as part of the message
71  * and if the difference is greater than this tolerance
72  * we will discard the message as invalid.
73  *
74  * There are 86400000 milliseconds in a day.
75  */
76 #define GNUNET_NSE_DRIFT_TOLERANCE 600000 /* Ten minutes. */
77
78 /**
79  * Number of bits
80  */
81 #define GNUNET_NSE_BITS
82
83 /**
84  * Handle for the network size estimation service.
85  */
86 struct GNUNET_NSE_Handle;
87
88
89 /**
90  * Callback to call when network size estimate is updated.
91  *
92  * @param cls closure
93  * @param estimate the value of the current network size estimate
94  * @param std_dev standard deviation (rounded down to nearest integer)
95  *                of the size estimation values seen
96  *
97  */
98 typedef void
99 (*GNUNET_NSE_Callback) (void *cls, double estimate, double std_dev);
100
101 /**
102  * Connect to the network size estimation service.
103  *
104  * @param cfg the configuration to use
105  * @param func funtion to call with network size estimate
106  * @param func_cls closure to pass for network size estimate callback
107  *
108  * @return handle to use
109  */
110 struct GNUNET_NSE_Handle *
111 GNUNET_NSE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
112                     GNUNET_NSE_Callback func, void *func_cls);
113
114
115 /**
116  * Disconnect from network size estimation service
117  *
118  * @param h handle to destroy
119  *
120  */
121 void
122 GNUNET_NSE_disconnect (struct GNUNET_NSE_Handle *h);
123
124
125 #if 0                           /* keep Emacsens' auto-indent happy */
126 {
127 #endif
128 #ifdef __cplusplus
129 }
130 #endif
131
132 #endif /* GNUNET_NSE_SERVICE_H_ */