diff options
author | Nathan S. Evans <evans@in.tum.de> | 2011-07-08 17:10:45 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2011-07-08 17:10:45 +0000 |
commit | 5058b5b92455e26dd740b5c0344f78e95cd0fc2e (patch) | |
tree | 0077531e5ff8c9c9348b301a10618b0328bef90e /src/nse/nse.h | |
parent | a6627549cdea39c0c5eb75966598e4ee7c31cad1 (diff) | |
download | gnunet-5058b5b92455e26dd740b5c0344f78e95cd0fc2e.tar.gz gnunet-5058b5b92455e26dd740b5c0344f78e95cd0fc2e.zip |
initial nse commit
Diffstat (limited to 'src/nse/nse.h')
-rw-r--r-- | src/nse/nse.h | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/src/nse/nse.h b/src/nse/nse.h new file mode 100644 index 000000000..ee9832dc6 --- /dev/null +++ b/src/nse/nse.h | |||
@@ -0,0 +1,119 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2001-2011 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 | /** | ||
22 | * @author Nathan Evans | ||
23 | * @file nse/nse.h | ||
24 | * | ||
25 | * @brief Common type definitions for the network size estimation | ||
26 | * service and API. | ||
27 | */ | ||
28 | #ifndef NSE_H | ||
29 | #define NSE_H | ||
30 | |||
31 | #include "gnunet_common.h" | ||
32 | |||
33 | #define DEBUG_NSE GNUNET_YES | ||
34 | |||
35 | #define SIGNED_TIMESTAMP_SIZE sizeof(struct GNUNET_TIME_Absolute) | ||
36 | |||
37 | /** FIXME: define NSE message types here. */ | ||
38 | |||
39 | struct GNUNET_Signed_Timestamp | ||
40 | { | ||
41 | char data[SIGNED_TIMESTAMP_SIZE]; | ||
42 | }; | ||
43 | |||
44 | /** | ||
45 | * Network size estimate sent from the service | ||
46 | * to clients. Contains the current size estimate | ||
47 | * (or 0 if none has been calculated) and the | ||
48 | * standard deviation of known estimates. | ||
49 | * | ||
50 | */ | ||
51 | struct GNUNET_NSE_ClientMessage | ||
52 | { | ||
53 | /** | ||
54 | * Type: GNUNET_MESSAGE_TYPE_NSE_UPDATE | ||
55 | */ | ||
56 | struct GNUNET_MessageHeader header; | ||
57 | |||
58 | /* | ||
59 | * The current estimated network size. | ||
60 | */ | ||
61 | double size_estimate; | ||
62 | |||
63 | /** | ||
64 | * The standard deviation (rounded down | ||
65 | * to the nearest integer) of size | ||
66 | * estimations. | ||
67 | */ | ||
68 | double std_deviation; | ||
69 | }; | ||
70 | |||
71 | /** | ||
72 | * Network size estimate reply; sent when "this" | ||
73 | * peer's timer has run out before receiving a | ||
74 | * valid reply from another peer. | ||
75 | * | ||
76 | * FIXME: Is this the right way to do this? | ||
77 | * I think we need to include both the public | ||
78 | * key and the timestamp signed by the private | ||
79 | * key. This way a recipient | ||
80 | * can verify that the peer at least generated | ||
81 | * the public/private key pair, and that the | ||
82 | * timestamp matches what the current peer | ||
83 | * believes it should be. The receiving peer | ||
84 | * would then check whether the XOR of the peer | ||
85 | * identity and the timestamp is within a | ||
86 | * reasonable range of the current time | ||
87 | * (+/- N seconds). If a closer message which | ||
88 | * also verifies hasn't been received (or this | ||
89 | * message is a duplicate), the peer | ||
90 | * calculates the size estimate and forwards | ||
91 | * the request to all other peers. | ||
92 | * | ||
93 | * Hmm... Is it enought to *just* send the peer | ||
94 | * identity? Obviously this is smaller, but it | ||
95 | * doesn't allow us to verify that the | ||
96 | * public/private key pair were generated, right? | ||
97 | */ | ||
98 | struct GNUNET_NSE_ReplyMessage | ||
99 | { | ||
100 | /** | ||
101 | * Type: GNUNET_MESSAGE_TYPE_NSE_REPLY | ||
102 | */ | ||
103 | struct GNUNET_MessageHeader header; | ||
104 | |||
105 | /** | ||
106 | * The current timestamp value (which all | ||
107 | * peers should agree on) signed by the | ||
108 | * private key of the initiating peer. | ||
109 | */ | ||
110 | struct GNUNET_Signed_Timestamp timestamp; | ||
111 | |||
112 | /** | ||
113 | * Public key of the originator, signed timestamp | ||
114 | * is decrypted by this. | ||
115 | */ | ||
116 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey; | ||
117 | }; | ||
118 | |||
119 | #endif | ||