diff options
Diffstat (limited to 'src/include')
136 files changed, 7967 insertions, 9480 deletions
diff --git a/src/include/.gitignore b/src/include/.gitignore index 6c12255e5..76ca45ab4 100644 --- a/src/include/.gitignore +++ b/src/include/.gitignore | |||
@@ -1,2 +1,3 @@ | |||
1 | gnu_name_system_record_types.h | 1 | !gnunet_config.h.in |
2 | gnunet_signatures.h | 2 | gnunet_config.h |
3 | gnunet_mysql_compat.h | ||
diff --git a/src/include/Makefile.am b/src/include/Makefile.am index 586645567..8f39faab6 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am | |||
@@ -4,24 +4,22 @@ SUBDIRS = . | |||
4 | gnunetincludedir = $(includedir)/gnunet | 4 | gnunetincludedir = $(includedir)/gnunet |
5 | 5 | ||
6 | EXTRA_DIST = \ | 6 | EXTRA_DIST = \ |
7 | platform.h \ | ||
7 | gauger.h \ | 8 | gauger.h \ |
8 | block_fs.h \ | 9 | block_fs.h \ |
9 | block_dns.h \ | 10 | block_dns.h \ |
10 | block_regex.h | 11 | block_regex.h |
11 | 12 | ||
12 | gnunetinclude_HEADERS = \ | 13 | gnunetinclude_HEADERS = \ |
13 | platform.h gettext.h \ | 14 | gnunet_config.h \ |
15 | gettext.h \ | ||
14 | compat.h \ | 16 | compat.h \ |
15 | gnunet_abd_service.h \ | 17 | gnunet_abd_service.h \ |
16 | gnunet_applications.h \ | 18 | gnunet_applications.h \ |
17 | gnunet_arm_service.h \ | 19 | gnunet_arm_service.h \ |
18 | gnunet_ats_service.h \ | ||
19 | gnunet_ats_application_service.h \ | ||
20 | gnunet_ats_transport_service.h \ | ||
21 | gnunet_ats_plugin.h \ | ||
22 | gnunet_bandwidth_lib.h \ | 20 | gnunet_bandwidth_lib.h \ |
23 | gnunet_bio_lib.h \ | 21 | gnunet_bio_lib.h \ |
24 | gnunet_dht_block_types.h \ | 22 | gnunet_dht_block_types.h \ |
25 | gnunet_block_lib.h \ | 23 | gnunet_block_lib.h \ |
26 | gnunet_block_group_lib.h \ | 24 | gnunet_block_group_lib.h \ |
27 | gnunet_block_plugin.h \ | 25 | gnunet_block_plugin.h \ |
@@ -35,6 +33,7 @@ gnunetinclude_HEADERS = \ | |||
35 | gnunet_container_lib.h \ | 33 | gnunet_container_lib.h \ |
36 | gnunet_conversation_service.h \ | 34 | gnunet_conversation_service.h \ |
37 | gnunet_core_service.h \ | 35 | gnunet_core_service.h \ |
36 | gnunet_core_testing_lib.h \ | ||
38 | gnunet_crypto_lib.h \ | 37 | gnunet_crypto_lib.h \ |
39 | gnunet_curl_lib.h \ | 38 | gnunet_curl_lib.h \ |
40 | gnunet_datacache_lib.h \ | 39 | gnunet_datacache_lib.h \ |
@@ -48,8 +47,7 @@ gnunetinclude_HEADERS = \ | |||
48 | gnunet_dnsparser_lib.h \ | 47 | gnunet_dnsparser_lib.h \ |
49 | gnunet_dnsstub_lib.h \ | 48 | gnunet_dnsstub_lib.h \ |
50 | gnunet_dns_service.h \ | 49 | gnunet_dns_service.h \ |
51 | gnunet_fragmentation_lib.h \ | 50 | gnunet_error_codes.h \ |
52 | gnunet_friends_lib.h \ | ||
53 | gnunet_fs_service.h \ | 51 | gnunet_fs_service.h \ |
54 | gnunet_getopt_lib.h \ | 52 | gnunet_getopt_lib.h \ |
55 | gnunet_gns_service.h \ | 53 | gnunet_gns_service.h \ |
@@ -57,7 +55,8 @@ gnunetinclude_HEADERS = \ | |||
57 | gnunet_gnsrecord_json_lib.h \ | 55 | gnunet_gnsrecord_json_lib.h \ |
58 | gnunet_gnsrecord_plugin.h \ | 56 | gnunet_gnsrecord_plugin.h \ |
59 | gnu_name_system_record_types.h \ | 57 | gnu_name_system_record_types.h \ |
60 | gnunet_hello_lib.h \ | 58 | gnu_name_system_protocols.h \ |
59 | gnu_name_system_service_ports.h \ | ||
61 | gnunet_hello_uri_lib.h \ | 60 | gnunet_hello_uri_lib.h \ |
62 | gnunet_helper_lib.h \ | 61 | gnunet_helper_lib.h \ |
63 | gnunet_identity_service.h \ | 62 | gnunet_identity_service.h \ |
@@ -72,8 +71,6 @@ gnunetinclude_HEADERS = \ | |||
72 | gnunet_microphone_lib.h \ | 71 | gnunet_microphone_lib.h \ |
73 | gnunet_mst_lib.h \ | 72 | gnunet_mst_lib.h \ |
74 | gnunet_mq_lib.h \ | 73 | gnunet_mq_lib.h \ |
75 | gnunet_my_lib.h \ | ||
76 | gnunet_mysql_lib.h \ | ||
77 | gnunet_namecache_plugin.h \ | 74 | gnunet_namecache_plugin.h \ |
78 | gnunet_namecache_service.h \ | 75 | gnunet_namecache_service.h \ |
79 | gnunet_namestore_plugin.h \ | 76 | gnunet_namestore_plugin.h \ |
@@ -87,7 +84,6 @@ gnunetinclude_HEADERS = \ | |||
87 | gnunet_op_lib.h \ | 84 | gnunet_op_lib.h \ |
88 | gnunet_os_lib.h \ | 85 | gnunet_os_lib.h \ |
89 | gnunet_peer_lib.h \ | 86 | gnunet_peer_lib.h \ |
90 | gnunet_peerinfo_service.h \ | ||
91 | gnunet_peerstore_plugin.h \ | 87 | gnunet_peerstore_plugin.h \ |
92 | gnunet_peerstore_service.h \ | 88 | gnunet_peerstore_service.h \ |
93 | gnunet_plugin_lib.h \ | 89 | gnunet_plugin_lib.h \ |
@@ -114,21 +110,18 @@ gnunetinclude_HEADERS = \ | |||
114 | gnunet_sq_lib.h \ | 110 | gnunet_sq_lib.h \ |
115 | gnunet_statistics_service.h \ | 111 | gnunet_statistics_service.h \ |
116 | gnunet_strings_lib.h \ | 112 | gnunet_strings_lib.h \ |
117 | gnunet_testbed_service.h \ | 113 | gnunet_testing_barrier.h \ |
118 | gnunet_testbed_logger_service.h \ | ||
119 | gnunet_testing_lib.h \ | 114 | gnunet_testing_lib.h \ |
120 | gnunet_testing_plugin.h \ | 115 | gnunet_testing_plugin.h \ |
121 | gnunet_testing_ng_lib.h \ | 116 | gnunet_testing_ng_lib.h \ |
117 | gnunet_testing_loop_lib.h \ | ||
122 | gnunet_testing_netjail_lib.h \ | 118 | gnunet_testing_netjail_lib.h \ |
123 | gnunet_time_lib.h \ | 119 | gnunet_time_lib.h \ |
124 | gnunet_transport_service.h \ | ||
125 | gnunet_transport_application_service.h \ | 120 | gnunet_transport_application_service.h \ |
126 | gnunet_transport_communication_service.h \ | 121 | gnunet_transport_communication_service.h \ |
127 | gnunet_transport_core_service.h \ | ||
128 | gnunet_transport_hello_service.h \ | ||
129 | gnunet_transport_manipulation_service.h \ | ||
130 | gnunet_transport_monitor_service.h \ | 122 | gnunet_transport_monitor_service.h \ |
131 | gnunet_transport_plugin.h \ | 123 | gnunet_transport_core_service.h \ |
124 | gnunet_transport_testing_ng_lib.h \ | ||
132 | gnunet_tun_lib.h \ | 125 | gnunet_tun_lib.h \ |
133 | gnunet_uri_lib.h \ | 126 | gnunet_uri_lib.h \ |
134 | gnunet_util_lib.h \ | 127 | gnunet_util_lib.h \ |
diff --git a/src/include/block_dns.h b/src/include/block_dns.h index 2186cb1a1..4ac6d0250 100644 --- a/src/include/block_dns.h +++ b/src/include/block_dns.h | |||
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup vpn_suite | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
@@ -30,6 +33,7 @@ | |||
30 | #ifndef BLOCK_DNS_H | 33 | #ifndef BLOCK_DNS_H |
31 | #define BLOCK_DNS_H | 34 | #define BLOCK_DNS_H |
32 | 35 | ||
36 | |||
33 | #include "gnunet_util_lib.h" | 37 | #include "gnunet_util_lib.h" |
34 | 38 | ||
35 | GNUNET_NETWORK_STRUCT_BEGIN | 39 | GNUNET_NETWORK_STRUCT_BEGIN |
@@ -65,3 +69,5 @@ GNUNET_NETWORK_STRUCT_END | |||
65 | #endif | 69 | #endif |
66 | 70 | ||
67 | /** @} */ /* end of group */ | 71 | /** @} */ /* end of group */ |
72 | |||
73 | /** @} */ /* end of group addition to vpn_suite */ | ||
diff --git a/src/include/block_fs.h b/src/include/block_fs.h index e4caf6e50..b64a83f39 100644 --- a/src/include/block_fs.h +++ b/src/include/block_fs.h | |||
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup fs_l2 | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
@@ -31,6 +34,7 @@ | |||
31 | #ifndef BLOCK_FS_H | 34 | #ifndef BLOCK_FS_H |
32 | #define BLOCK_FS_H | 35 | #define BLOCK_FS_H |
33 | 36 | ||
37 | |||
34 | #include "gnunet_util_lib.h" | 38 | #include "gnunet_util_lib.h" |
35 | #include "gnunet_fs_service.h" | 39 | #include "gnunet_fs_service.h" |
36 | 40 | ||
@@ -98,3 +102,5 @@ GNUNET_NETWORK_STRUCT_END | |||
98 | #endif | 102 | #endif |
99 | 103 | ||
100 | /** @} */ /* end of group */ | 104 | /** @} */ /* end of group */ |
105 | |||
106 | /** @} */ /* end of group addition to fs_l2 */ | ||
diff --git a/src/include/block_regex.h b/src/include/block_regex.h index cc78f2c32..fea19e335 100644 --- a/src/include/block_regex.h +++ b/src/include/block_regex.h | |||
@@ -36,6 +36,7 @@ extern "C" | |||
36 | #endif | 36 | #endif |
37 | #endif | 37 | #endif |
38 | 38 | ||
39 | |||
39 | #include "gnunet_util_lib.h" | 40 | #include "gnunet_util_lib.h" |
40 | #include <stdint.h> | 41 | #include <stdint.h> |
41 | 42 | ||
diff --git a/src/include/gauger.h b/src/include/gauger.h index 716ce9cb1..f811b335c 100644 --- a/src/include/gauger.h +++ b/src/include/gauger.h | |||
@@ -11,6 +11,7 @@ | |||
11 | #ifndef __GAUGER_H__ | 11 | #ifndef __GAUGER_H__ |
12 | #define __GAUGER_H__ | 12 | #define __GAUGER_H__ |
13 | 13 | ||
14 | |||
14 | #include <unistd.h> | 15 | #include <unistd.h> |
15 | #include <stdio.h> | 16 | #include <stdio.h> |
16 | #include <sys/wait.h> | 17 | #include <sys/wait.h> |
diff --git a/src/include/gettext.h b/src/include/gettext.h index 458512657..6e98f197a 100644 --- a/src/include/gettext.h +++ b/src/include/gettext.h | |||
@@ -23,6 +23,7 @@ | |||
23 | #if ENABLE_NLS | 23 | #if ENABLE_NLS |
24 | 24 | ||
25 | /* Get declarations of GNU message catalog functions. */ | 25 | /* Get declarations of GNU message catalog functions. */ |
26 | |||
26 | #include <libintl.h> | 27 | #include <libintl.h> |
27 | 28 | ||
28 | #else | 29 | #else |
diff --git a/src/include/gnu_name_system_protocols.h b/src/include/gnu_name_system_protocols.h new file mode 100644 index 000000000..c10eef468 --- /dev/null +++ b/src/include/gnu_name_system_protocols.h | |||
@@ -0,0 +1,96 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2012-2023 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your 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 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | #ifndef GNUNET_GNS_PROTOCOLS_H | ||
21 | #define GNUNET_GNS_PROTOCOLS_H | ||
22 | |||
23 | /** | ||
24 | * WARNING: | ||
25 | * This header is generated! | ||
26 | * In order to add GNS service ports, you must register | ||
27 | * them in GANA, and then use the header generation script | ||
28 | * to create an update of this file. You may then replace this | ||
29 | * file with the update. | ||
30 | */ | ||
31 | |||
32 | #ifdef __cplusplus | ||
33 | extern "C" { | ||
34 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
35 | } | ||
36 | #endif | ||
37 | #endif | ||
38 | |||
39 | struct GNUNET_GNS_Protocol | ||
40 | { | ||
41 | const char *name; | ||
42 | |||
43 | uint16_t number; | ||
44 | }; | ||
45 | |||
46 | struct GNUNET_GNS_Protocol GNUNET_GNS_Protocols[] = { | ||
47 | /** | ||
48 | * LIGHTest trust policy scheme | ||
49 | */ | ||
50 | { | ||
51 | .name = "trust", | ||
52 | .number = 49152 | ||
53 | }, | ||
54 | |||
55 | { | ||
56 | .name = NULL, | ||
57 | .number = 0 | ||
58 | } | ||
59 | }; | ||
60 | |||
61 | uint16_t | ||
62 | GNUNET_GNS_protocol_name_to_number (const char *name) | ||
63 | { | ||
64 | int i = 0; | ||
65 | while (NULL != GNUNET_GNS_Protocols[i].name) | ||
66 | { | ||
67 | if (0 == strcmp (name, GNUNET_GNS_Protocols[i].name)) | ||
68 | return GNUNET_GNS_Protocols[i].number; | ||
69 | i++; | ||
70 | } | ||
71 | return 0; | ||
72 | } | ||
73 | |||
74 | |||
75 | const char* | ||
76 | GNUNET_GNS_protocol_number_to_name (uint16_t number) | ||
77 | { | ||
78 | int i = 0; | ||
79 | while (NULL != GNUNET_GNS_Protocols[i].name) | ||
80 | { | ||
81 | if (number == GNUNET_GNS_Protocols[i].number) | ||
82 | return GNUNET_GNS_Protocols[i].name; | ||
83 | i++; | ||
84 | } | ||
85 | return NULL; | ||
86 | } | ||
87 | |||
88 | |||
89 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
90 | { | ||
91 | #endif | ||
92 | #ifdef __cplusplus | ||
93 | } | ||
94 | #endif | ||
95 | |||
96 | #endif | ||
diff --git a/src/include/gnu_name_system_record_types.h b/src/include/gnu_name_system_record_types.h new file mode 100644 index 000000000..8a62cac11 --- /dev/null +++ b/src/include/gnu_name_system_record_types.h | |||
@@ -0,0 +1,204 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2012-2022 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your 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 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | #ifndef GNU_NAME_SYSTEM_RECORD_TYPES_H | ||
21 | #define GNU_NAME_SYSTEM_RECORD_TYPES_H | ||
22 | |||
23 | /** | ||
24 | * WARNING: | ||
25 | * This header is generated! | ||
26 | * In order to add GNS record types, you must register | ||
27 | * them in GANA, and then use the header generation script | ||
28 | * to create an update of this file. You may then replace this | ||
29 | * file with the update. | ||
30 | */ | ||
31 | |||
32 | #ifdef __cplusplus | ||
33 | extern "C" { | ||
34 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
35 | } | ||
36 | #endif | ||
37 | #endif | ||
38 | |||
39 | |||
40 | /** | ||
41 | * GNS zone delegation (PKEY) | ||
42 | */ | ||
43 | #define GNUNET_GNSRECORD_TYPE_PKEY 65536 | ||
44 | |||
45 | |||
46 | /** | ||
47 | * GNS zone nickname | ||
48 | */ | ||
49 | #define GNUNET_GNSRECORD_TYPE_NICK 65537 | ||
50 | |||
51 | |||
52 | /** | ||
53 | * GNS legacy hostname | ||
54 | */ | ||
55 | #define GNUNET_GNSRECORD_TYPE_LEHO 65538 | ||
56 | |||
57 | |||
58 | /** | ||
59 | * VPN resolution | ||
60 | */ | ||
61 | #define GNUNET_GNSRECORD_TYPE_VPN 65539 | ||
62 | |||
63 | |||
64 | /** | ||
65 | * Delegation to DNS | ||
66 | */ | ||
67 | #define GNUNET_GNSRECORD_TYPE_GNS2DNS 65540 | ||
68 | |||
69 | |||
70 | /** | ||
71 | * Box record | ||
72 | */ | ||
73 | #define GNUNET_GNSRECORD_TYPE_BOX 65541 | ||
74 | |||
75 | |||
76 | /** | ||
77 | * social place for SecuShare | ||
78 | */ | ||
79 | #define GNUNET_GNSRECORD_TYPE_PLACE 65542 | ||
80 | |||
81 | |||
82 | /** | ||
83 | * Endpoint for conversation | ||
84 | */ | ||
85 | #define GNUNET_GNSRECORD_TYPE_PHONE 65543 | ||
86 | |||
87 | |||
88 | /** | ||
89 | * identity attribute | ||
90 | */ | ||
91 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE 65544 | ||
92 | |||
93 | |||
94 | /** | ||
95 | * local ticket reference | ||
96 | */ | ||
97 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET 65545 | ||
98 | |||
99 | |||
100 | /** | ||
101 | * SBox record | ||
102 | */ | ||
103 | #define GNUNET_GNSRECORD_TYPE_SBOX 65547 | ||
104 | |||
105 | |||
106 | /** | ||
107 | * For ABD policies | ||
108 | */ | ||
109 | #define GNUNET_GNSRECORD_TYPE_DELEGATE 65548 | ||
110 | |||
111 | |||
112 | /** | ||
113 | * For ABD reverse lookups | ||
114 | */ | ||
115 | #define GNUNET_GNSRECORD_TYPE_ATTRIBUTE 65549 | ||
116 | |||
117 | |||
118 | /** | ||
119 | * for reclaim records | ||
120 | */ | ||
121 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF 65550 | ||
122 | |||
123 | |||
124 | /** | ||
125 | * Redirection record | ||
126 | */ | ||
127 | #define GNUNET_GNSRECORD_TYPE_REDIRECT 65551 | ||
128 | |||
129 | |||
130 | /** | ||
131 | * For reclaim OIDC client names. | ||
132 | */ | ||
133 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT 65552 | ||
134 | |||
135 | |||
136 | /** | ||
137 | * Used reclaimID OIDC client redirect URIs. | ||
138 | */ | ||
139 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT 65553 | ||
140 | |||
141 | |||
142 | /** | ||
143 | * Record type for an attribute attestation (e.g. JWT). | ||
144 | */ | ||
145 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL 65554 | ||
146 | |||
147 | |||
148 | /** | ||
149 | * Record type for a presentation of a credential. | ||
150 | */ | ||
151 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION 65555 | ||
152 | |||
153 | |||
154 | /** | ||
155 | * GNS zone delegation (EDKEY) | ||
156 | */ | ||
157 | #define GNUNET_GNSRECORD_TYPE_EDKEY 65556 | ||
158 | |||
159 | |||
160 | /** | ||
161 | * Encoding for Robust Immutable Storage (ERIS) binary read capability | ||
162 | */ | ||
163 | #define GNUNET_GNSRECORD_TYPE_ERIS_READ_CAPABILITY 65557 | ||
164 | |||
165 | |||
166 | /** | ||
167 | * Record type to share an entry of a messenger room | ||
168 | */ | ||
169 | #define GNUNET_GNSRECORD_TYPE_MESSENGER_ROOM_ENTRY 65558 | ||
170 | |||
171 | |||
172 | /** | ||
173 | * Record type to indicate a previously delete record (PRIVATE only) | ||
174 | */ | ||
175 | #define GNUNET_GNSRECORD_TYPE_TOMBSTONE 65559 | ||
176 | |||
177 | |||
178 | /** | ||
179 | * Record type to store details about a messenger room | ||
180 | */ | ||
181 | #define GNUNET_GNSRECORD_TYPE_MESSENGER_ROOM_DETAILS 65560 | ||
182 | |||
183 | |||
184 | /** | ||
185 | * Record type to store DID Documents | ||
186 | */ | ||
187 | #define GNUNET_GNSRECORD_TYPE_DID_DOCUMENT 65561 | ||
188 | |||
189 | |||
190 | /** | ||
191 | * Private metadata for a delegation registration | ||
192 | */ | ||
193 | #define GNUNET_GNSRECORD_TYPE_GNS_REGISTRAR_METADATA 4294901760 | ||
194 | |||
195 | |||
196 | |||
197 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
198 | { | ||
199 | #endif | ||
200 | #ifdef __cplusplus | ||
201 | } | ||
202 | #endif | ||
203 | |||
204 | #endif | ||
diff --git a/src/include/gnu_name_system_service_ports.h b/src/include/gnu_name_system_service_ports.h new file mode 100644 index 000000000..040e598b6 --- /dev/null +++ b/src/include/gnu_name_system_service_ports.h | |||
@@ -0,0 +1,104 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2012-2023 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your 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 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | #ifndef GNUNET_GNS_SERVICE_PORTS_H | ||
21 | #define GNUNET_GNS_SERVICE_PORTS_H | ||
22 | |||
23 | /** | ||
24 | * WARNING: | ||
25 | * This header is generated! | ||
26 | * In order to add GNS service ports, you must register | ||
27 | * them in GANA, and then use the header generation script | ||
28 | * to create an update of this file. You may then replace this | ||
29 | * file with the update. | ||
30 | */ | ||
31 | |||
32 | #ifdef __cplusplus | ||
33 | extern "C" { | ||
34 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
35 | } | ||
36 | #endif | ||
37 | #endif | ||
38 | |||
39 | struct GNUNET_GNS_ServicePort | ||
40 | { | ||
41 | const char *name; | ||
42 | |||
43 | uint16_t port; | ||
44 | }; | ||
45 | |||
46 | struct GNUNET_GNS_ServicePort GNUNET_GNS_ServicePorts[] = { | ||
47 | /** | ||
48 | * Used by Trust Scheme Authorities to publish information about Trust Schemes (LIGHTest) | ||
49 | */ | ||
50 | { | ||
51 | .name = "scheme", | ||
52 | .port = 49152 | ||
53 | }, | ||
54 | |||
55 | /** | ||
56 | * Used Trust Translation Authorities to publish information about Trust Translations (LIGHTest) | ||
57 | */ | ||
58 | { | ||
59 | .name = "translation", | ||
60 | .port = 49153 | ||
61 | }, | ||
62 | |||
63 | { | ||
64 | .name = NULL, | ||
65 | .port = 0 | ||
66 | } | ||
67 | }; | ||
68 | |||
69 | uint16_t | ||
70 | GNUNET_GNS_service_port_name_to_number (const char *name) | ||
71 | { | ||
72 | int i = 0; | ||
73 | while (NULL != GNUNET_GNS_ServicePorts[i].name) | ||
74 | { | ||
75 | if (0 == strcmp (name, GNUNET_GNS_ServicePorts[i].name)) | ||
76 | return GNUNET_GNS_ServicePorts[i].port; | ||
77 | i++; | ||
78 | } | ||
79 | return 0; | ||
80 | } | ||
81 | |||
82 | |||
83 | const char* | ||
84 | GNUNET_GNS_service_port_number_to_name (uint16_t port) | ||
85 | { | ||
86 | int i = 0; | ||
87 | while (NULL != GNUNET_GNS_ServicePorts[i].name) | ||
88 | { | ||
89 | if (port == GNUNET_GNS_ServicePorts[i].port) | ||
90 | return GNUNET_GNS_ServicePorts[i].name; | ||
91 | i++; | ||
92 | } | ||
93 | return NULL; | ||
94 | } | ||
95 | |||
96 | |||
97 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
98 | { | ||
99 | #endif | ||
100 | #ifdef __cplusplus | ||
101 | } | ||
102 | #endif | ||
103 | |||
104 | #endif | ||
diff --git a/src/include/gnunet_abd_service.h b/src/include/gnunet_abd_service.h index 21f668a8d..cb6e77256 100644 --- a/src/include/gnunet_abd_service.h +++ b/src/include/gnunet_abd_service.h | |||
@@ -19,19 +19,23 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup reclaim_suite | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Martin Schanzenbach | 25 | * @author Martin Schanzenbach |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
25 | * API to the Credential service | 28 | * API to the Credential service |
26 | * | 29 | * |
27 | * @defgroup abd Credential service | 30 | * @defgroup abd Credential service |
28 | * Credentials | 31 | * Credential service for Attribute-Based Decryption |
29 | * | 32 | * |
30 | * @{ | 33 | * @{ |
31 | */ | 34 | */ |
32 | #ifndef GNUNET_ABD_SERVICE_H | 35 | #ifndef GNUNET_ABD_SERVICE_H |
33 | #define GNUNET_ABD_SERVICE_H | 36 | #define GNUNET_ABD_SERVICE_H |
34 | 37 | ||
38 | |||
35 | #include "gnunet_util_lib.h" | 39 | #include "gnunet_util_lib.h" |
36 | #include "gnunet_gns_service.h" | 40 | #include "gnunet_gns_service.h" |
37 | #include "gnunet_identity_service.h" | 41 | #include "gnunet_identity_service.h" |
@@ -103,7 +107,7 @@ struct GNUNET_ABD_DelegationRecordSet | |||
103 | /** | 107 | /** |
104 | * Public key of the subject this attribute was delegated to | 108 | * Public key of the subject this attribute was delegated to |
105 | */ | 109 | */ |
106 | struct GNUNET_IDENTITY_PublicKey subject_key; | 110 | struct GNUNET_CRYPTO_PublicKey subject_key; |
107 | 111 | ||
108 | /** | 112 | /** |
109 | * Length of attribute, may be 0 | 113 | * Length of attribute, may be 0 |
@@ -123,7 +127,7 @@ struct GNUNET_ABD_DelegationSet | |||
123 | /** | 127 | /** |
124 | * Public key of the subject this attribute was delegated to | 128 | * Public key of the subject this attribute was delegated to |
125 | */ | 129 | */ |
126 | struct GNUNET_IDENTITY_PublicKey subject_key; | 130 | struct GNUNET_CRYPTO_PublicKey subject_key; |
127 | 131 | ||
128 | uint32_t subject_attribute_len; | 132 | uint32_t subject_attribute_len; |
129 | 133 | ||
@@ -143,12 +147,12 @@ struct GNUNET_ABD_Delegation | |||
143 | /** | 147 | /** |
144 | * The issuer of the delegation | 148 | * The issuer of the delegation |
145 | */ | 149 | */ |
146 | struct GNUNET_IDENTITY_PublicKey issuer_key; | 150 | struct GNUNET_CRYPTO_PublicKey issuer_key; |
147 | 151 | ||
148 | /** | 152 | /** |
149 | * Public key of the subject this attribute was delegated to | 153 | * Public key of the subject this attribute was delegated to |
150 | */ | 154 | */ |
151 | struct GNUNET_IDENTITY_PublicKey subject_key; | 155 | struct GNUNET_CRYPTO_PublicKey subject_key; |
152 | 156 | ||
153 | /** | 157 | /** |
154 | * Length of the attribute | 158 | * Length of the attribute |
@@ -181,17 +185,17 @@ struct GNUNET_ABD_Delegate | |||
181 | /** | 185 | /** |
182 | * The issuer of the credential | 186 | * The issuer of the credential |
183 | */ | 187 | */ |
184 | struct GNUNET_IDENTITY_PublicKey issuer_key; | 188 | struct GNUNET_CRYPTO_PublicKey issuer_key; |
185 | 189 | ||
186 | /** | 190 | /** |
187 | * Public key of the subject this credential was issued to | 191 | * Public key of the subject this credential was issued to |
188 | */ | 192 | */ |
189 | struct GNUNET_IDENTITY_PublicKey subject_key; | 193 | struct GNUNET_CRYPTO_PublicKey subject_key; |
190 | 194 | ||
191 | /** | 195 | /** |
192 | * Signature of this credential | 196 | * Signature of this credential |
193 | */ | 197 | */ |
194 | struct GNUNET_IDENTITY_Signature signature; | 198 | struct GNUNET_CRYPTO_Signature signature; |
195 | 199 | ||
196 | /** | 200 | /** |
197 | * Expiration of this credential | 201 | * Expiration of this credential |
@@ -318,9 +322,9 @@ typedef void (*GNUNET_ABD_RemoveDelegateResultProcessor) (void *cls, | |||
318 | */ | 322 | */ |
319 | struct GNUNET_ABD_Request* | 323 | struct GNUNET_ABD_Request* |
320 | GNUNET_ABD_verify (struct GNUNET_ABD_Handle *handle, | 324 | GNUNET_ABD_verify (struct GNUNET_ABD_Handle *handle, |
321 | const struct GNUNET_IDENTITY_PublicKey *issuer_key, | 325 | const struct GNUNET_CRYPTO_PublicKey *issuer_key, |
322 | const char *issuer_attribute, | 326 | const char *issuer_attribute, |
323 | const struct GNUNET_IDENTITY_PublicKey *subject_key, | 327 | const struct GNUNET_CRYPTO_PublicKey *subject_key, |
324 | uint32_t delegate_count, | 328 | uint32_t delegate_count, |
325 | const struct GNUNET_ABD_Delegate *delegates, | 329 | const struct GNUNET_ABD_Delegate *delegates, |
326 | enum GNUNET_ABD_AlgoDirectionFlags direction, | 330 | enum GNUNET_ABD_AlgoDirectionFlags direction, |
@@ -331,9 +335,9 @@ struct GNUNET_ABD_Request* | |||
331 | 335 | ||
332 | struct GNUNET_ABD_Request* | 336 | struct GNUNET_ABD_Request* |
333 | GNUNET_ABD_collect (struct GNUNET_ABD_Handle *handle, | 337 | GNUNET_ABD_collect (struct GNUNET_ABD_Handle *handle, |
334 | const struct GNUNET_IDENTITY_PublicKey *issuer_key, | 338 | const struct GNUNET_CRYPTO_PublicKey *issuer_key, |
335 | const char *issuer_attribute, | 339 | const char *issuer_attribute, |
336 | const struct GNUNET_IDENTITY_PrivateKey *subject_key, | 340 | const struct GNUNET_CRYPTO_PrivateKey *subject_key, |
337 | enum GNUNET_ABD_AlgoDirectionFlags direction, | 341 | enum GNUNET_ABD_AlgoDirectionFlags direction, |
338 | GNUNET_ABD_CredentialResultProcessor proc, | 342 | GNUNET_ABD_CredentialResultProcessor proc, |
339 | void *proc_cls, | 343 | void *proc_cls, |
@@ -356,7 +360,7 @@ struct GNUNET_ABD_Request * | |||
356 | GNUNET_ABD_add_delegation (struct GNUNET_ABD_Handle *handle, | 360 | GNUNET_ABD_add_delegation (struct GNUNET_ABD_Handle *handle, |
357 | struct GNUNET_IDENTITY_Ego *issuer, | 361 | struct GNUNET_IDENTITY_Ego *issuer, |
358 | const char *attribute, | 362 | const char *attribute, |
359 | struct GNUNET_IDENTITY_PublicKey *subject, | 363 | struct GNUNET_CRYPTO_PublicKey *subject, |
360 | const char *delegated_attribute, | 364 | const char *delegated_attribute, |
361 | GNUNET_ABD_DelegateResultProcessor proc, | 365 | GNUNET_ABD_DelegateResultProcessor proc, |
362 | void *proc_cls); | 366 | void *proc_cls); |
@@ -384,13 +388,13 @@ GNUNET_ABD_remove_delegation (struct GNUNET_ABD_Handle *handle, | |||
384 | * | 388 | * |
385 | * @param issuer the ego that should be used to issue the attribute | 389 | * @param issuer the ego that should be used to issue the attribute |
386 | * @param subject the subject of the attribute | 390 | * @param subject the subject of the attribute |
387 | * @param attribute the name of the attribute | 391 | * @param iss_attr the name of the attribute |
388 | * @param expiration the TTL of the credential | 392 | * @param expiration the TTL of the credential |
389 | * @return handle to the queued request | 393 | * @return handle to the queued request |
390 | */ | 394 | */ |
391 | struct GNUNET_ABD_Delegate* | 395 | struct GNUNET_ABD_Delegate* |
392 | GNUNET_ABD_delegate_issue (const struct GNUNET_IDENTITY_PrivateKey *issuer, | 396 | GNUNET_ABD_delegate_issue (const struct GNUNET_CRYPTO_PrivateKey *issuer, |
393 | struct GNUNET_IDENTITY_PublicKey *subject, | 397 | struct GNUNET_CRYPTO_PublicKey *subject, |
394 | const char *iss_attr, | 398 | const char *iss_attr, |
395 | const char *sub_attr, | 399 | const char *sub_attr, |
396 | struct GNUNET_TIME_Absolute *expiration); | 400 | struct GNUNET_TIME_Absolute *expiration); |
@@ -415,3 +419,5 @@ GNUNET_ABD_request_cancel (struct GNUNET_ABD_Request *lr); | |||
415 | #endif | 419 | #endif |
416 | 420 | ||
417 | /** @} */ /* end of group */ | 421 | /** @} */ /* end of group */ |
422 | |||
423 | /** @} */ /* end of group addition to reclaim_suite */ | ||
diff --git a/src/include/gnunet_applications.h b/src/include/gnunet_applications.h index 1e2ac59f7..489dc7050 100644 --- a/src/include/gnunet_applications.h +++ b/src/include/gnunet_applications.h | |||
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup Backbone | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
@@ -133,4 +136,6 @@ extern "C" | |||
133 | 136 | ||
134 | /** @} */ /* end of group */ | 137 | /** @} */ /* end of group */ |
135 | 138 | ||
139 | /** @} */ /* end of group addition to Backbone */ | ||
140 | |||
136 | /* end of gnunet_applications.h */ | 141 | /* end of gnunet_applications.h */ |
diff --git a/src/include/gnunet_arm_service.h b/src/include/gnunet_arm_service.h index 9615f8c9d..639e723c5 100644 --- a/src/include/gnunet_arm_service.h +++ b/src/include/gnunet_arm_service.h | |||
@@ -43,6 +43,7 @@ extern "C" | |||
43 | #endif | 43 | #endif |
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | |||
46 | #include "gnunet_util_lib.h" | 47 | #include "gnunet_util_lib.h" |
47 | 48 | ||
48 | /** | 49 | /** |
diff --git a/src/include/gnunet_ats_application_service.h b/src/include/gnunet_ats_application_service.h deleted file mode 100644 index a48dba825..000000000 --- a/src/include/gnunet_ats_application_service.h +++ /dev/null | |||
@@ -1,103 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2010-2015, 2018 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your 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 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @file | ||
22 | * Bandwidth allocation API for applications to interact with | ||
23 | * | ||
24 | * @author Christian Grothoff | ||
25 | * @author Matthias Wachs | ||
26 | * | ||
27 | * @defgroup ats ATS service | ||
28 | * Bandwidth allocation | ||
29 | * | ||
30 | * @see [Documentation](https://gnunet.org/ats-subsystem) | ||
31 | * | ||
32 | * @{ | ||
33 | */ | ||
34 | #ifndef GNUNET_ATS_APPLICATION_SERVICE_H | ||
35 | #define GNUNET_ATS_APPLICATION_SERVICE_H | ||
36 | |||
37 | #include "gnunet_constants.h" | ||
38 | #include "gnunet_util_lib.h" | ||
39 | |||
40 | /** | ||
41 | * Handle to the ATS subsystem for making suggestions about | ||
42 | * connections the peer would like to have. | ||
43 | */ | ||
44 | struct GNUNET_ATS_ApplicationHandle; | ||
45 | |||
46 | |||
47 | /** | ||
48 | * Initialize the ATS application client handle. | ||
49 | * | ||
50 | * @param cfg configuration to use | ||
51 | * @return ats application handle, NULL on error | ||
52 | */ | ||
53 | struct GNUNET_ATS_ApplicationHandle * | ||
54 | GNUNET_ATS_application_init (const struct GNUNET_CONFIGURATION_Handle *cfg); | ||
55 | |||
56 | |||
57 | /** | ||
58 | * Shutdown ATS application client. | ||
59 | * | ||
60 | * @param ch handle to destroy | ||
61 | */ | ||
62 | void | ||
63 | GNUNET_ATS_application_done (struct GNUNET_ATS_ApplicationHandle *ch); | ||
64 | |||
65 | |||
66 | /** | ||
67 | * Handle for suggestion requests. | ||
68 | */ | ||
69 | struct GNUNET_ATS_ApplicationSuggestHandle; | ||
70 | |||
71 | |||
72 | /** | ||
73 | * An application would like to communicate with a peer. ATS should | ||
74 | * allocate bandwidth using a suitable address for requiremetns @a pk | ||
75 | * to transport. | ||
76 | * | ||
77 | * @param ch handle | ||
78 | * @param peer identity of the peer we need an address for | ||
79 | * @param pk what kind of application will the application require (can be | ||
80 | * #GNUNET_MQ_PREFERENCE_NONE, we will still try to connect) | ||
81 | * @param bw desired bandwidth, can be zero (we will still try to connect) | ||
82 | * @return suggestion handle, NULL if request is already pending | ||
83 | */ | ||
84 | struct GNUNET_ATS_ApplicationSuggestHandle * | ||
85 | GNUNET_ATS_application_suggest (struct GNUNET_ATS_ApplicationHandle *ch, | ||
86 | const struct GNUNET_PeerIdentity *peer, | ||
87 | enum GNUNET_MQ_PreferenceKind pk, | ||
88 | struct GNUNET_BANDWIDTH_Value32NBO bw); | ||
89 | |||
90 | |||
91 | /** | ||
92 | * We no longer care about communicating with a peer. | ||
93 | * | ||
94 | * @param sh handle | ||
95 | */ | ||
96 | void | ||
97 | GNUNET_ATS_application_suggest_cancel (struct | ||
98 | GNUNET_ATS_ApplicationSuggestHandle *sh); | ||
99 | |||
100 | /** @} */ /* end of group */ | ||
101 | |||
102 | #endif | ||
103 | /* end of file gnunet_ats_application_service.h */ | ||
diff --git a/src/include/gnunet_ats_plugin.h b/src/include/gnunet_ats_plugin.h deleted file mode 100644 index c0662673c..000000000 --- a/src/include/gnunet_ats_plugin.h +++ /dev/null | |||
@@ -1,486 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2009-2015 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your 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 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @author Christian Grothoff | ||
23 | * | ||
24 | * @file | ||
25 | * API for the ATS solvers. | ||
26 | * | ||
27 | * @defgroup ats-plugin ATS service plugin API | ||
28 | * Plugin API for the ATS service. | ||
29 | * | ||
30 | * Specifies the struct that is given to the plugin's entry method and the other | ||
31 | * struct that must be returned. Note that the destructors of ATS plugins will | ||
32 | * be given the value returned by the constructor and is expected to return a | ||
33 | * NULL pointer. | ||
34 | * | ||
35 | * @{ | ||
36 | */ | ||
37 | #ifndef PLUGIN_ATS_H | ||
38 | #define PLUGIN_ATS_H | ||
39 | |||
40 | #include "gnunet_ats_service.h" | ||
41 | #include "gnunet_statistics_service.h" | ||
42 | |||
43 | /** | ||
44 | * Representation of an address the plugin can choose from. | ||
45 | */ | ||
46 | struct ATS_Address; | ||
47 | |||
48 | /** | ||
49 | * Change the preference for a peer | ||
50 | * | ||
51 | * @param handle the solver handle | ||
52 | * @param client the client sending this request | ||
53 | * @param peer the peer id | ||
54 | * @param kind the preference kind to change | ||
55 | * @param score the new preference score | ||
56 | * @param pref_rel the normalized preference value for this kind over all clients | ||
57 | */ | ||
58 | typedef void | ||
59 | (*GAS_solver_address_change_preference) (void *solver, | ||
60 | const struct GNUNET_PeerIdentity *peer, | ||
61 | enum GNUNET_ATS_PreferenceKind kind, | ||
62 | double pref_rel); | ||
63 | |||
64 | |||
65 | /** | ||
66 | * Give feedback about the current assignment | ||
67 | * | ||
68 | * @param handle the solver handle | ||
69 | * @param application the application sending this request | ||
70 | * @param peer the peer id | ||
71 | * @param scope the time interval for this feedback: [now - scope .. now] | ||
72 | * @param kind the preference kind for this feedback | ||
73 | * @param score the feedback score | ||
74 | */ | ||
75 | typedef void | ||
76 | (*GAS_solver_address_feedback_preference) (void *solver, | ||
77 | struct GNUNET_SERVICE_Client * | ||
78 | application, | ||
79 | const struct | ||
80 | GNUNET_PeerIdentity *peer, | ||
81 | const struct GNUNET_TIME_Relative | ||
82 | scope, | ||
83 | enum GNUNET_ATS_PreferenceKind kind, | ||
84 | double score); | ||
85 | |||
86 | /** | ||
87 | * Notify the solver about a bulk operation changing possibly a lot of values | ||
88 | * Solver will not resolve until all bulk operations are marked as done | ||
89 | * | ||
90 | * @param solver the solver | ||
91 | */ | ||
92 | typedef void | ||
93 | (*GAS_solver_bulk_start) (void *solver); | ||
94 | |||
95 | |||
96 | /** | ||
97 | * Mark a bulk operation as done | ||
98 | * Solver will resolve if values have changed | ||
99 | * | ||
100 | * @param solver the solver | ||
101 | */ | ||
102 | typedef void | ||
103 | (*GAS_solver_bulk_stop) (void *solver); | ||
104 | |||
105 | |||
106 | /** | ||
107 | * Add a single address within a network to the solver | ||
108 | * | ||
109 | * @param solver the solver Handle | ||
110 | * @param address the address to add | ||
111 | * @param network network type of this address | ||
112 | */ | ||
113 | typedef void | ||
114 | (*GAS_solver_address_add) (void *solver, | ||
115 | struct ATS_Address *address, | ||
116 | uint32_t network); | ||
117 | |||
118 | |||
119 | /** | ||
120 | * Delete an address or just the session from the solver | ||
121 | * | ||
122 | * @param solver the solver Handle | ||
123 | * @param address the address to delete | ||
124 | */ | ||
125 | typedef void | ||
126 | (*GAS_solver_address_delete) (void *solver, | ||
127 | struct ATS_Address *address); | ||
128 | |||
129 | |||
130 | /** | ||
131 | * Transport properties for this address have changed | ||
132 | * | ||
133 | * @param solver solver handle | ||
134 | * @param address the address | ||
135 | */ | ||
136 | typedef void | ||
137 | (*GAS_solver_address_property_changed) (void *solver, | ||
138 | struct ATS_Address *address); | ||
139 | |||
140 | |||
141 | /** | ||
142 | * Get the preferred address for a peer from solver | ||
143 | * | ||
144 | * @param solver the solver to use | ||
145 | * @param peer the peer | ||
146 | */ | ||
147 | typedef void | ||
148 | (*GAS_solver_get_preferred_address) (void *solver, | ||
149 | const struct GNUNET_PeerIdentity *peer); | ||
150 | |||
151 | |||
152 | /** | ||
153 | * Stop getting the preferred address for a peer from solver | ||
154 | * | ||
155 | * @param solver the solver to use | ||
156 | * @param peer the peer | ||
157 | */ | ||
158 | typedef void | ||
159 | (*GAS_solver_stop_get_preferred_address) (void *solver, | ||
160 | const struct | ||
161 | GNUNET_PeerIdentity *peer); | ||
162 | |||
163 | |||
164 | /** | ||
165 | * Solver functions. | ||
166 | * | ||
167 | * Each solver is required to set up and return an instance | ||
168 | * of this struct during initialization. | ||
169 | */ | ||
170 | struct GNUNET_ATS_SolverFunctions | ||
171 | { | ||
172 | /** | ||
173 | * Closure to pass to all solver functions in this struct. | ||
174 | */ | ||
175 | void *cls; | ||
176 | |||
177 | /** | ||
178 | * Add a new address for a peer to the solver | ||
179 | * | ||
180 | * The address is already contained in the addresses hashmap! | ||
181 | */ | ||
182 | GAS_solver_address_add s_add; | ||
183 | |||
184 | /** | ||
185 | * Update the properties of an address in the solver | ||
186 | */ | ||
187 | GAS_solver_address_property_changed s_address_update_property; | ||
188 | |||
189 | /** | ||
190 | * Tell solver to notify ATS if the address to use changes for a specific | ||
191 | * peer using the bandwidth changed callback | ||
192 | * | ||
193 | * The solver must only notify about changes for peers with pending address | ||
194 | * requests! | ||
195 | */ | ||
196 | GAS_solver_get_preferred_address s_get; | ||
197 | |||
198 | /** | ||
199 | * Tell solver stop notifying ATS about changes for this peers | ||
200 | * | ||
201 | * The solver must only notify about changes for peers with pending address | ||
202 | * requests! | ||
203 | */ | ||
204 | GAS_solver_stop_get_preferred_address s_get_stop; | ||
205 | |||
206 | /** | ||
207 | * Delete an address in the solver | ||
208 | * | ||
209 | * The address is not contained in the address hashmap anymore! | ||
210 | */ | ||
211 | GAS_solver_address_delete s_del; | ||
212 | |||
213 | /** | ||
214 | * Change relative preference for quality in solver | ||
215 | */ | ||
216 | GAS_solver_address_change_preference s_pref; | ||
217 | |||
218 | /** | ||
219 | * Give feedback about the current assignment | ||
220 | */ | ||
221 | GAS_solver_address_feedback_preference s_feedback; | ||
222 | |||
223 | /** | ||
224 | * Start a bulk operation | ||
225 | * | ||
226 | * Used if many values have to be updated at the same time. | ||
227 | * When a bulk operation is pending the solver does not have to resolve | ||
228 | * the problem since more updates will follow anyway | ||
229 | * | ||
230 | * For each call to bulk_start, a call to bulk_stop is required! | ||
231 | */ | ||
232 | GAS_solver_bulk_start s_bulk_start; | ||
233 | |||
234 | /** | ||
235 | * Bulk operation done | ||
236 | * | ||
237 | * If no more bulk operations are pending, the solver can solve the problem | ||
238 | * with the updated values | ||
239 | */ | ||
240 | GAS_solver_bulk_stop s_bulk_stop; | ||
241 | }; | ||
242 | |||
243 | |||
244 | /** | ||
245 | * Operation codes for solver information callback | ||
246 | * | ||
247 | * Order of calls is expected to be: | ||
248 | * #GAS_OP_SOLVE_START | ||
249 | * #GAS_OP_SOLVE_STOP | ||
250 | * #GAS_OP_SOLVE_UPDATE_NOTIFICATION_START | ||
251 | * #GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP | ||
252 | * | ||
253 | */ | ||
254 | enum GAS_Solver_Operation | ||
255 | { | ||
256 | /** | ||
257 | * A solution iteration has been started | ||
258 | */ | ||
259 | GAS_OP_SOLVE_START, | ||
260 | |||
261 | /** | ||
262 | * A solution iteration has been finished | ||
263 | */ | ||
264 | GAS_OP_SOLVE_STOP, | ||
265 | |||
266 | /** | ||
267 | * The setup of the problem as a preparation to solve it was started | ||
268 | */ | ||
269 | GAS_OP_SOLVE_SETUP_START, | ||
270 | |||
271 | /** | ||
272 | * The setup of the problem as a preparation to solve is finished | ||
273 | */ | ||
274 | GAS_OP_SOLVE_SETUP_STOP, | ||
275 | |||
276 | /** | ||
277 | * Solving of the LP problem was started | ||
278 | * MLP solver only | ||
279 | */ | ||
280 | GAS_OP_SOLVE_MLP_LP_START, | ||
281 | |||
282 | /** | ||
283 | * Solving of the LP problem is done | ||
284 | * MLP solver only | ||
285 | */ | ||
286 | GAS_OP_SOLVE_MLP_LP_STOP, | ||
287 | |||
288 | /** | ||
289 | * Solving of the MLP problem was started | ||
290 | * MLP solver only | ||
291 | */ | ||
292 | GAS_OP_SOLVE_MLP_MLP_START, | ||
293 | |||
294 | /** | ||
295 | * Solving of the MLP problem is done | ||
296 | * MLP solver only | ||
297 | */ | ||
298 | GAS_OP_SOLVE_MLP_MLP_STOP, | ||
299 | |||
300 | /** | ||
301 | * After the problem was finished, start notifications about changes | ||
302 | * to addresses | ||
303 | */ | ||
304 | GAS_OP_SOLVE_UPDATE_NOTIFICATION_START, | ||
305 | |||
306 | /** | ||
307 | * After the problem was finished, notifications about changes to addresses | ||
308 | * are done | ||
309 | */ | ||
310 | GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP | ||
311 | }; | ||
312 | |||
313 | |||
314 | /** | ||
315 | * Status of a GAS_Solver_Operation operation | ||
316 | */ | ||
317 | enum GAS_Solver_Status | ||
318 | { | ||
319 | /** | ||
320 | * Success | ||
321 | */ | ||
322 | GAS_STAT_SUCCESS, | ||
323 | |||
324 | /** | ||
325 | * Failure | ||
326 | */ | ||
327 | GAS_STAT_FAIL | ||
328 | }; | ||
329 | |||
330 | |||
331 | /** | ||
332 | * Status of the operation | ||
333 | */ | ||
334 | enum GAS_Solver_Additional_Information | ||
335 | { | ||
336 | /** | ||
337 | * No more specific information | ||
338 | */ | ||
339 | GAS_INFO_NONE, | ||
340 | |||
341 | /** | ||
342 | * A full solution process is performed | ||
343 | * Quite specific to the MLP solver | ||
344 | */ | ||
345 | GAS_INFO_FULL, | ||
346 | |||
347 | /** | ||
348 | * An existing solution was reused | ||
349 | * Quite specific to the MLP solver | ||
350 | */ | ||
351 | GAS_INFO_UPDATED, | ||
352 | |||
353 | /** | ||
354 | * The proportional solver had to recalculate for a single network | ||
355 | */ | ||
356 | GAS_INFO_PROP_SINGLE, | ||
357 | |||
358 | /** | ||
359 | * The proportional solver had to recalculate for all networks | ||
360 | */ | ||
361 | GAS_INFO_PROP_ALL | ||
362 | }; | ||
363 | |||
364 | |||
365 | /** | ||
366 | * Callback to call with additional information | ||
367 | * Used for measurement | ||
368 | * | ||
369 | * @param cls the closure | ||
370 | * @param op the operation | ||
371 | */ | ||
372 | typedef void | ||
373 | (*GAS_solver_information_callback) (void *cls, | ||
374 | enum GAS_Solver_Operation op, | ||
375 | enum GAS_Solver_Status stat, | ||
376 | enum GAS_Solver_Additional_Information); | ||
377 | |||
378 | |||
379 | /** | ||
380 | * Callback to call from solver when bandwidth for address has changed | ||
381 | * | ||
382 | * @param address the with changed bandwidth assigned | ||
383 | */ | ||
384 | typedef void | ||
385 | (*GAS_bandwidth_changed_cb) (void *cls, | ||
386 | struct ATS_Address *address); | ||
387 | |||
388 | |||
389 | /** | ||
390 | * Callback to call from solver to obtain application preference | ||
391 | * values for a peer. | ||
392 | * | ||
393 | * @param cls the cls | ||
394 | * @param id the peer id | ||
395 | * @return carry of double values containing the preferences with | ||
396 | * GNUNET_ATS_PreferenceCount elements | ||
397 | */ | ||
398 | typedef const double * | ||
399 | (*GAS_get_preferences) (void *cls, | ||
400 | const struct GNUNET_PeerIdentity *id); | ||
401 | |||
402 | |||
403 | /** | ||
404 | * Callback to call from solver to obtain application connectivity | ||
405 | * preferences for a peer. | ||
406 | * | ||
407 | * @param cls the cls | ||
408 | * @param id the peer id | ||
409 | * @return 0 if connectivity is not desired, non-null if address | ||
410 | * suggestions are requested | ||
411 | */ | ||
412 | typedef unsigned int | ||
413 | (*GAS_get_connectivity) (void *cls, | ||
414 | const struct GNUNET_PeerIdentity *id); | ||
415 | |||
416 | |||
417 | /** | ||
418 | * The ATS plugin will pass a pointer to a struct | ||
419 | * of this type as to the initialization function | ||
420 | * of the ATS plugins. | ||
421 | */ | ||
422 | struct GNUNET_ATS_PluginEnvironment | ||
423 | { | ||
424 | /** | ||
425 | * Configuration handle to be used by the solver | ||
426 | */ | ||
427 | const struct GNUNET_CONFIGURATION_Handle *cfg; | ||
428 | |||
429 | /** | ||
430 | * Statistics handle to be used by the solver | ||
431 | */ | ||
432 | struct GNUNET_STATISTICS_Handle *stats; | ||
433 | |||
434 | /** | ||
435 | * Closure to pass to all callbacks in this struct. | ||
436 | */ | ||
437 | void *cls; | ||
438 | |||
439 | /** | ||
440 | * Hashmap containing all addresses available | ||
441 | */ | ||
442 | struct GNUNET_CONTAINER_MultiPeerMap *addresses; | ||
443 | |||
444 | /** | ||
445 | * ATS addresses callback to be notified about bandwidth assignment changes | ||
446 | */ | ||
447 | GAS_bandwidth_changed_cb bandwidth_changed_cb; | ||
448 | |||
449 | /** | ||
450 | * ATS addresses function to obtain preference values | ||
451 | */ | ||
452 | GAS_get_preferences get_preferences; | ||
453 | |||
454 | /** | ||
455 | * ATS addresses function to obtain preference values | ||
456 | */ | ||
457 | GAS_get_connectivity get_connectivity; | ||
458 | |||
459 | /** | ||
460 | * Callback for solver to call with status information, | ||
461 | * can be NULL | ||
462 | */ | ||
463 | GAS_solver_information_callback info_cb; | ||
464 | |||
465 | /** | ||
466 | * Number of networks available, size of the @e out_quota | ||
467 | * and @e in_quota arrays. | ||
468 | */ | ||
469 | unsigned int network_count; | ||
470 | |||
471 | /** | ||
472 | * Array of configured outbound quotas | ||
473 | * Order according to networks in network array | ||
474 | */ | ||
475 | unsigned long long out_quota[GNUNET_NT_COUNT]; | ||
476 | |||
477 | /** | ||
478 | * Array of configured inbound quotas | ||
479 | * Order according to networks in network array | ||
480 | */ | ||
481 | unsigned long long in_quota[GNUNET_NT_COUNT]; | ||
482 | }; | ||
483 | |||
484 | #endif | ||
485 | |||
486 | /** @} */ /* end of group */ | ||
diff --git a/src/include/gnunet_ats_service.h b/src/include/gnunet_ats_service.h deleted file mode 100644 index 68ba8e6b2..000000000 --- a/src/include/gnunet_ats_service.h +++ /dev/null | |||
@@ -1,624 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2010-2015 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your 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 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @file | ||
22 | * Automatic transport selection and outbound bandwidth determination | ||
23 | * | ||
24 | * @author Christian Grothoff | ||
25 | * @author Matthias Wachs | ||
26 | * | ||
27 | * @defgroup ats ATS service | ||
28 | * Automatic Transport Selection and outbound bandwidth determination | ||
29 | * | ||
30 | * @see [Documentation](https://gnunet.org/ats-subsystem) | ||
31 | * | ||
32 | * @{ | ||
33 | */ | ||
34 | #ifndef GNUNET_ATS_SERVICE_H | ||
35 | #define GNUNET_ATS_SERVICE_H | ||
36 | |||
37 | #include "gnunet_constants.h" | ||
38 | #include "gnunet_util_lib.h" | ||
39 | #include "gnunet_hello_lib.h" | ||
40 | |||
41 | |||
42 | /** | ||
43 | * Default bandwidth assigned to a network : 64 KB/s | ||
44 | */ | ||
45 | #define GNUNET_ATS_DefaultBandwidth 65536 | ||
46 | |||
47 | /** | ||
48 | * Undefined value for an `enum GNUNET_ATS_Property` | ||
49 | */ | ||
50 | #define GNUNET_ATS_VALUE_UNDEFINED UINT32_MAX | ||
51 | |||
52 | /** | ||
53 | * String representation for GNUNET_ATS_VALUE_UNDEFINED | ||
54 | */ | ||
55 | #define GNUNET_ATS_VALUE_UNDEFINED_STR "undefined" | ||
56 | |||
57 | /** | ||
58 | * Maximum bandwidth assigned to a network : 4095 MB/s | ||
59 | */ | ||
60 | #define GNUNET_ATS_MaxBandwidth UINT32_MAX | ||
61 | |||
62 | /** | ||
63 | * Textual equivalent for GNUNET_ATS_MaxBandwidth | ||
64 | */ | ||
65 | #define GNUNET_ATS_MaxBandwidthString "unlimited" | ||
66 | |||
67 | |||
68 | /** | ||
69 | * ATS performance characteristics for an address. | ||
70 | */ | ||
71 | struct GNUNET_ATS_Properties | ||
72 | { | ||
73 | /** | ||
74 | * Delay. Time between when the time packet is sent and the packet | ||
75 | * arrives. FOREVER if we did not measure yet. | ||
76 | */ | ||
77 | struct GNUNET_TIME_Relative delay; | ||
78 | |||
79 | /** | ||
80 | * Actual traffic on this connection from this peer to the other peer. | ||
81 | * Includes transport overhead. | ||
82 | * | ||
83 | * Unit: [bytes/second] | ||
84 | */ | ||
85 | uint32_t utilization_out; | ||
86 | |||
87 | /** | ||
88 | * Actual traffic on this connection from the other peer to this peer. | ||
89 | * Includes transport overhead. | ||
90 | * | ||
91 | * Unit: [bytes/second] | ||
92 | */ | ||
93 | uint32_t utilization_in; | ||
94 | |||
95 | /** | ||
96 | * Distance on network layer (required for distance-vector routing) | ||
97 | * in hops. Zero for direct connections (e.g. plain TCP/UDP). | ||
98 | */ | ||
99 | unsigned int distance; | ||
100 | |||
101 | /** | ||
102 | * Which network scope does the respective address belong to? | ||
103 | * This property does not change. | ||
104 | */ | ||
105 | enum GNUNET_NetworkType scope; | ||
106 | }; | ||
107 | |||
108 | |||
109 | /** | ||
110 | * ATS performance characteristics for an address in | ||
111 | * network byte order (for IPC). | ||
112 | */ | ||
113 | struct GNUNET_ATS_PropertiesNBO | ||
114 | { | ||
115 | /** | ||
116 | * Actual traffic on this connection from this peer to the other peer. | ||
117 | * Includes transport overhead. | ||
118 | * | ||
119 | * Unit: [bytes/second] | ||
120 | */ | ||
121 | uint32_t utilization_out GNUNET_PACKED; | ||
122 | |||
123 | /** | ||
124 | * Actual traffic on this connection from the other peer to this peer. | ||
125 | * Includes transport overhead. | ||
126 | * | ||
127 | * Unit: [bytes/second] | ||
128 | */ | ||
129 | uint32_t utilization_in GNUNET_PACKED; | ||
130 | |||
131 | /** | ||
132 | * Which network scope does the respective address belong to? | ||
133 | * This property does not change. | ||
134 | */ | ||
135 | uint32_t scope GNUNET_PACKED; | ||
136 | |||
137 | /** | ||
138 | * Distance on network layer (required for distance-vector routing) | ||
139 | * in hops. Zero for direct connections (e.g. plain TCP/UDP). | ||
140 | */ | ||
141 | uint32_t distance GNUNET_PACKED; | ||
142 | |||
143 | /** | ||
144 | * Delay. Time between when the time packet is sent and the packet | ||
145 | * arrives. FOREVER if we did not measure yet. | ||
146 | */ | ||
147 | struct GNUNET_TIME_RelativeNBO delay; | ||
148 | }; | ||
149 | |||
150 | |||
151 | /* ********************* LAN Characterization library ************************ */ | ||
152 | /* Note: these functions do not really communicate with the ATS service */ | ||
153 | |||
154 | |||
155 | /** | ||
156 | * Convert ATS properties from host to network byte order. | ||
157 | * | ||
158 | * @param nbo[OUT] value written | ||
159 | * @param hbo value read | ||
160 | */ | ||
161 | void | ||
162 | GNUNET_ATS_properties_hton (struct GNUNET_ATS_PropertiesNBO *nbo, | ||
163 | const struct GNUNET_ATS_Properties *hbo); | ||
164 | |||
165 | |||
166 | /** | ||
167 | * Convert ATS properties from network to host byte order. | ||
168 | * | ||
169 | * @param hbo[OUT] value written | ||
170 | * @param nbo value read | ||
171 | */ | ||
172 | void | ||
173 | GNUNET_ATS_properties_ntoh (struct GNUNET_ATS_Properties *hbo, | ||
174 | const struct GNUNET_ATS_PropertiesNBO *nbo); | ||
175 | |||
176 | |||
177 | /* ********************Connection Suggestion API ***************************** */ | ||
178 | |||
179 | /** | ||
180 | * Handle to the ATS subsystem for making suggestions about | ||
181 | * connections the peer would like to have. | ||
182 | */ | ||
183 | struct GNUNET_ATS_ConnectivityHandle; | ||
184 | |||
185 | /** | ||
186 | * Handle for address suggestion requests. | ||
187 | */ | ||
188 | struct GNUNET_ATS_ConnectivitySuggestHandle; | ||
189 | |||
190 | |||
191 | /** | ||
192 | * Initialize the ATS connectivity suggestion client handle. | ||
193 | * | ||
194 | * @param cfg configuration to use | ||
195 | * @return ats connectivity handle, NULL on error | ||
196 | */ | ||
197 | struct GNUNET_ATS_ConnectivityHandle * | ||
198 | GNUNET_ATS_connectivity_init (const struct GNUNET_CONFIGURATION_Handle *cfg); | ||
199 | |||
200 | |||
201 | /** | ||
202 | * Shutdown ATS connectivity suggestion client. | ||
203 | * | ||
204 | * @param ch handle to destroy | ||
205 | */ | ||
206 | void | ||
207 | GNUNET_ATS_connectivity_done (struct GNUNET_ATS_ConnectivityHandle *ch); | ||
208 | |||
209 | |||
210 | /** | ||
211 | * We would like to establish a new connection with a peer. ATS | ||
212 | * should suggest a good address to begin with. | ||
213 | * | ||
214 | * @param ch handle | ||
215 | * @param peer identity of the peer we need an address for | ||
216 | * @param strength how urgent is the need for such a suggestion | ||
217 | * @return suggestion handle, NULL if request is already pending | ||
218 | */ | ||
219 | struct GNUNET_ATS_ConnectivitySuggestHandle * | ||
220 | GNUNET_ATS_connectivity_suggest (struct GNUNET_ATS_ConnectivityHandle *ch, | ||
221 | const struct GNUNET_PeerIdentity *peer, | ||
222 | uint32_t strength); | ||
223 | |||
224 | |||
225 | /** | ||
226 | * We no longer care about being connected to a peer. | ||
227 | * | ||
228 | * @param sh handle | ||
229 | */ | ||
230 | void | ||
231 | GNUNET_ATS_connectivity_suggest_cancel (struct | ||
232 | GNUNET_ATS_ConnectivitySuggestHandle *sh); | ||
233 | |||
234 | |||
235 | /* ******************************** Scheduling API ***************************** */ | ||
236 | |||
237 | /** | ||
238 | * Handle to the ATS subsystem for bandwidth/transport scheduling information. | ||
239 | */ | ||
240 | struct GNUNET_ATS_SchedulingHandle; | ||
241 | |||
242 | /** | ||
243 | * Opaque session handle, defined by plugins. Contents not known to ATS. | ||
244 | */ | ||
245 | struct GNUNET_ATS_Session; | ||
246 | |||
247 | |||
248 | /** | ||
249 | * Signature of a function called by ATS with the current bandwidth | ||
250 | * and address preferences as determined by ATS. If our connection | ||
251 | * to ATS dies and thus all suggestions become invalid, this function | ||
252 | * is called ONCE with all arguments (except @a cls) being NULL/0. | ||
253 | * | ||
254 | * @param cls closure | ||
255 | * @param peer for which we suggest an address, NULL if ATS connection died | ||
256 | * @param address suggested address (including peer identity of the peer), | ||
257 | * may be NULL to signal disconnect from peer | ||
258 | * @param session session to use, NULL to establish a new outgoing session | ||
259 | * @param bandwidth_out assigned outbound bandwidth for the connection, | ||
260 | * 0 to signal disconnect | ||
261 | * @param bandwidth_in assigned inbound bandwidth for the connection, | ||
262 | * 0 to signal disconnect | ||
263 | */ | ||
264 | typedef void | ||
265 | (*GNUNET_ATS_AddressSuggestionCallback) (void *cls, | ||
266 | const struct GNUNET_PeerIdentity *peer, | ||
267 | const struct | ||
268 | GNUNET_HELLO_Address *address, | ||
269 | struct GNUNET_ATS_Session *session, | ||
270 | struct GNUNET_BANDWIDTH_Value32NBO | ||
271 | bandwidth_out, | ||
272 | struct GNUNET_BANDWIDTH_Value32NBO | ||
273 | bandwidth_in); | ||
274 | |||
275 | |||
276 | /** | ||
277 | * Initialize the ATS scheduling subsystem. | ||
278 | * | ||
279 | * @param cfg configuration to use | ||
280 | * @param suggest_cb notification to call whenever the suggestation changed | ||
281 | * @param suggest_cb_cls closure for @a suggest_cb | ||
282 | * @return ats context | ||
283 | */ | ||
284 | struct GNUNET_ATS_SchedulingHandle * | ||
285 | GNUNET_ATS_scheduling_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
286 | GNUNET_ATS_AddressSuggestionCallback suggest_cb, | ||
287 | void *suggest_cb_cls); | ||
288 | |||
289 | |||
290 | /** | ||
291 | * Client is done with ATS scheduling, release resources. | ||
292 | * | ||
293 | * @param sh handle to release | ||
294 | */ | ||
295 | void | ||
296 | GNUNET_ATS_scheduling_done (struct GNUNET_ATS_SchedulingHandle *sh); | ||
297 | |||
298 | |||
299 | /** | ||
300 | * Handle used within ATS to track an address. | ||
301 | */ | ||
302 | struct GNUNET_ATS_AddressRecord; | ||
303 | |||
304 | |||
305 | /** | ||
306 | * We have a new address ATS should know. Addresses have to be added with this | ||
307 | * function before they can be: updated, set in use and destroyed | ||
308 | * | ||
309 | * @param sh handle | ||
310 | * @param address the address | ||
311 | * @param session session handle (if available, e.g for incoming connections) | ||
312 | * @param prop performance data for the address | ||
313 | * @return handle to the address representation inside ATS, NULL | ||
314 | * on error (i.e. ATS knows this exact address already, or | ||
315 | * address is invalid) | ||
316 | */ | ||
317 | struct GNUNET_ATS_AddressRecord * | ||
318 | GNUNET_ATS_address_add (struct GNUNET_ATS_SchedulingHandle *sh, | ||
319 | const struct GNUNET_HELLO_Address *address, | ||
320 | struct GNUNET_ATS_Session *session, | ||
321 | const struct GNUNET_ATS_Properties *prop); | ||
322 | |||
323 | |||
324 | /** | ||
325 | * An address was used to initiate a session. | ||
326 | * | ||
327 | * @param ar address record to update information for | ||
328 | * @param session session handle | ||
329 | */ | ||
330 | void | ||
331 | GNUNET_ATS_address_add_session (struct GNUNET_ATS_AddressRecord *ar, | ||
332 | struct GNUNET_ATS_Session *session); | ||
333 | |||
334 | |||
335 | /** | ||
336 | * A @a session was destroyed, disassociate it from the given address | ||
337 | * record. If this was an incoming address, destroys the address as | ||
338 | * well. | ||
339 | * | ||
340 | * @param ar address record to update information for | ||
341 | * @param session session handle | ||
342 | * @return #GNUNET_YES if the @a ar was destroyed because | ||
343 | * it was an incoming address, | ||
344 | * #GNUNET_NO if the @ar was kept because we can | ||
345 | * use it still to establish a new session | ||
346 | */ | ||
347 | int | ||
348 | GNUNET_ATS_address_del_session (struct GNUNET_ATS_AddressRecord *ar, | ||
349 | struct GNUNET_ATS_Session *session); | ||
350 | |||
351 | |||
352 | /** | ||
353 | * We have updated performance statistics for a given address. Note | ||
354 | * that this function can be called for addresses that are currently | ||
355 | * in use as well as addresses that are valid but not actively in use. | ||
356 | * Furthermore, the peer may not even be connected to us right now (@a | ||
357 | * session value of NULL used to signal disconnect, or somehow we | ||
358 | * otherwise got updated on @a ats information). Based on the | ||
359 | * information provided, ATS may update bandwidth assignments and | ||
360 | * suggest to switch addresses. | ||
361 | * | ||
362 | * @param ar address record to update information for | ||
363 | * @param prop performance data for the address | ||
364 | */ | ||
365 | void | ||
366 | GNUNET_ATS_address_update (struct GNUNET_ATS_AddressRecord *ar, | ||
367 | const struct GNUNET_ATS_Properties *prop); | ||
368 | |||
369 | |||
370 | /** | ||
371 | * An address got destroyed, stop using it as a valid address. | ||
372 | * | ||
373 | * @param ar address record to destroy, it's validation has | ||
374 | * expired and ATS may no longer use it | ||
375 | */ | ||
376 | void | ||
377 | GNUNET_ATS_address_destroy (struct GNUNET_ATS_AddressRecord *ar); | ||
378 | |||
379 | |||
380 | /* ******************************** Performance API ***************************** */ | ||
381 | |||
382 | /** | ||
383 | * ATS Handle to obtain and/or modify performance information. | ||
384 | */ | ||
385 | struct GNUNET_ATS_PerformanceHandle; | ||
386 | |||
387 | /** | ||
388 | * Signature of a function that is called with QoS information about an address. | ||
389 | * | ||
390 | * @param cls closure | ||
391 | * @param address the address, NULL if ATS service was disconnected or | ||
392 | * when the iteration is completed in the case of | ||
393 | * #GNUNET_ATS_performance_list_addresses() | ||
394 | * @param address_active #GNUNET_YES if this address is actively used | ||
395 | * to maintain a connection to a peer; | ||
396 | * #GNUNET_NO if the address is not actively used; | ||
397 | * #GNUNET_SYSERR if this address is no longer available for ATS | ||
398 | * @param bandwidth_out assigned outbound bandwidth for the connection | ||
399 | * @param bandwidth_in assigned inbound bandwidth for the connection | ||
400 | * @param prop performance data for the address | ||
401 | */ | ||
402 | typedef void | ||
403 | (*GNUNET_ATS_AddressInformationCallback) (void *cls, | ||
404 | const struct | ||
405 | GNUNET_HELLO_Address *address, | ||
406 | int address_active, | ||
407 | struct GNUNET_BANDWIDTH_Value32NBO | ||
408 | bandwidth_out, | ||
409 | struct GNUNET_BANDWIDTH_Value32NBO | ||
410 | bandwidth_in, | ||
411 | const struct | ||
412 | GNUNET_ATS_Properties *prop); | ||
413 | |||
414 | |||
415 | /** | ||
416 | * Handle for an address listing operation | ||
417 | */ | ||
418 | struct GNUNET_ATS_AddressListHandle; | ||
419 | |||
420 | |||
421 | /** | ||
422 | * Get handle to access performance API of the ATS subsystem. | ||
423 | * | ||
424 | * @param cfg configuration to use | ||
425 | * @param addr_info_cb callback called when performance characteristics for | ||
426 | * an address change | ||
427 | * @param addr_info_cb_cls closure for @a addr_info_cb | ||
428 | * @return ats performance context | ||
429 | */ | ||
430 | struct GNUNET_ATS_PerformanceHandle * | ||
431 | GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
432 | GNUNET_ATS_AddressInformationCallback addr_info_cb, | ||
433 | void *addr_info_cb_cls); | ||
434 | |||
435 | |||
436 | /** | ||
437 | * Get information about addresses known to the ATS subsystem. | ||
438 | * | ||
439 | * @param ph the performance handle to use | ||
440 | * @param peer peer idm can be NULL for all peers | ||
441 | * @param all #GNUNET_YES to get information about all addresses or #GNUNET_NO to | ||
442 | * get only address currently used | ||
443 | * @param infocb callback to call with the addresses, | ||
444 | * will callback with address == NULL when done | ||
445 | * @param infocb_cls closure for @a infocb | ||
446 | * @return handle to abort the operation | ||
447 | */ | ||
448 | struct GNUNET_ATS_AddressListHandle * | ||
449 | GNUNET_ATS_performance_list_addresses (struct GNUNET_ATS_PerformanceHandle *ph, | ||
450 | const struct GNUNET_PeerIdentity *peer, | ||
451 | int all, | ||
452 | GNUNET_ATS_AddressInformationCallback | ||
453 | infocb, | ||
454 | void *infocb_cls); | ||
455 | |||
456 | |||
457 | /** | ||
458 | * Cancel a pending address listing operation | ||
459 | * | ||
460 | * @param alh the `struct GNUNET_ATS_AddressListHandle` handle to cancel | ||
461 | */ | ||
462 | void | ||
463 | GNUNET_ATS_performance_list_addresses_cancel (struct | ||
464 | GNUNET_ATS_AddressListHandle *alh); | ||
465 | |||
466 | |||
467 | /** | ||
468 | * Client is done using the ATS performance subsystem, release resources. | ||
469 | * | ||
470 | * @param ph handle | ||
471 | */ | ||
472 | void | ||
473 | GNUNET_ATS_performance_done (struct GNUNET_ATS_PerformanceHandle *ph); | ||
474 | |||
475 | |||
476 | /** | ||
477 | * Function called with reservation result. | ||
478 | * | ||
479 | * @param cls closure | ||
480 | * @param peer identifies the peer | ||
481 | * @param amount set to the amount that was actually reserved or unreserved; | ||
482 | * either the full requested amount or zero (no partial reservations) | ||
483 | * @param res_delay if the reservation could not be satisfied (amount was 0), how | ||
484 | * long should the client wait until re-trying? | ||
485 | */ | ||
486 | typedef void | ||
487 | (*GNUNET_ATS_ReservationCallback) (void *cls, | ||
488 | const struct GNUNET_PeerIdentity *peer, | ||
489 | int32_t amount, | ||
490 | struct GNUNET_TIME_Relative res_delay); | ||
491 | |||
492 | |||
493 | /** | ||
494 | * Context that can be used to cancel a peer information request. | ||
495 | */ | ||
496 | struct GNUNET_ATS_ReservationContext; | ||
497 | |||
498 | |||
499 | /** | ||
500 | * Reserve inbound bandwidth from the given peer. ATS will look at | ||
501 | * the current amount of traffic we receive from the peer and ensure | ||
502 | * that the peer could add 'amount' of data to its stream. | ||
503 | * | ||
504 | * @param ph performance handle | ||
505 | * @param peer identifies the peer | ||
506 | * @param amount reserve N bytes for receiving, negative | ||
507 | * amounts can be used to undo a (recent) reservation; | ||
508 | * @param rcb function to call with the resulting reservation information | ||
509 | * @param rcb_cls closure for @a rcb | ||
510 | * @return NULL on error | ||
511 | * @deprecated will be replaced soon | ||
512 | */ | ||
513 | struct GNUNET_ATS_ReservationContext * | ||
514 | GNUNET_ATS_reserve_bandwidth (struct GNUNET_ATS_PerformanceHandle *ph, | ||
515 | const struct GNUNET_PeerIdentity *peer, | ||
516 | int32_t amount, | ||
517 | GNUNET_ATS_ReservationCallback rcb, | ||
518 | void *rcb_cls); | ||
519 | |||
520 | |||
521 | /** | ||
522 | * Cancel request for reserving bandwidth. | ||
523 | * | ||
524 | * @param rc context returned by the original GNUNET_ATS_reserve_bandwidth call | ||
525 | */ | ||
526 | void | ||
527 | GNUNET_ATS_reserve_bandwidth_cancel (struct GNUNET_ATS_ReservationContext *rc); | ||
528 | |||
529 | |||
530 | /** | ||
531 | * ATS preference types as array initializer | ||
532 | */ | ||
533 | #define GNUNET_ATS_PreferenceType { GNUNET_ATS_PREFERENCE_BANDWIDTH, \ | ||
534 | GNUNET_ATS_PREFERENCE_LATENCY, \ | ||
535 | GNUNET_ATS_PREFERENCE_END } | ||
536 | |||
537 | /** | ||
538 | * ATS preference types as string array initializer | ||
539 | */ | ||
540 | #define GNUNET_ATS_PreferenceTypeString { "BANDWIDTH", "LATENCY", "END" } | ||
541 | |||
542 | /** | ||
543 | * Enum defining all known preference categories. | ||
544 | */ | ||
545 | enum GNUNET_ATS_PreferenceKind | ||
546 | { | ||
547 | /** | ||
548 | * Change the peer's bandwidth value (value per byte of bandwidth in | ||
549 | * the goal function) to the given amount. The argument is followed | ||
550 | * by a double value giving the desired value (can be negative). | ||
551 | * Preference changes are forgotten if peers disconnect. | ||
552 | */ | ||
553 | GNUNET_ATS_PREFERENCE_BANDWIDTH = 0, | ||
554 | |||
555 | /** | ||
556 | * Change the peer's latency value to the given amount. The | ||
557 | * argument is followed by a double value giving the desired value | ||
558 | * (can be negative). The absolute score in the goal function is | ||
559 | * the inverse of the latency in microseconds (minimum: 1 | ||
560 | * microsecond) multiplied by the latency preferences. | ||
561 | */ | ||
562 | GNUNET_ATS_PREFERENCE_LATENCY = 1, | ||
563 | |||
564 | /** | ||
565 | * End of preference list. | ||
566 | */ | ||
567 | GNUNET_ATS_PREFERENCE_END = 2 | ||
568 | }; | ||
569 | |||
570 | |||
571 | /** | ||
572 | * Convert a GNUNET_ATS_PreferenceType to a string | ||
573 | * | ||
574 | * @param type the preference type | ||
575 | * @return a string or NULL if invalid | ||
576 | */ | ||
577 | const char * | ||
578 | GNUNET_ATS_print_preference_type (enum GNUNET_ATS_PreferenceKind type); | ||
579 | |||
580 | |||
581 | /** | ||
582 | * Change preferences for the given peer. Preference changes are forgotten if peers | ||
583 | * disconnect. | ||
584 | * | ||
585 | * @param ph performance handle @param peer identifies the peer | ||
586 | * @param ... #GNUNET_ATS_PREFERENCE_END-terminated specification of the | ||
587 | * desired changes | ||
588 | */ | ||
589 | void | ||
590 | GNUNET_ATS_performance_change_preference (struct | ||
591 | GNUNET_ATS_PerformanceHandle *ph, | ||
592 | const struct | ||
593 | GNUNET_PeerIdentity *peer, | ||
594 | ...); | ||
595 | |||
596 | |||
597 | /** | ||
598 | * Application feedback on how good preference requirements are fulfilled | ||
599 | * for the preferences included in the given time scope [now - scope .. now] | ||
600 | * | ||
601 | * An application notifies ATS if (and only if) it has feedback information | ||
602 | * for specific properties. This values are valid until the feedback scores are | ||
603 | * updated by the application. | ||
604 | * | ||
605 | * If the application has no feedback for this preference kind the application | ||
606 | * will not explicitly call for this property and will not include it in this | ||
607 | * function call. | ||
608 | * | ||
609 | * @param ph performance handle | ||
610 | * @param scope the time interval this valid for: [now - scope .. now] | ||
611 | * @param peer identifies the peer | ||
612 | * @param ... #GNUNET_ATS_PREFERENCE_END-terminated specification of the desired changes | ||
613 | */ | ||
614 | void | ||
615 | GNUNET_ATS_performance_give_feedback (struct GNUNET_ATS_PerformanceHandle *ph, | ||
616 | const struct GNUNET_PeerIdentity *peer, | ||
617 | const struct GNUNET_TIME_Relative scope, | ||
618 | ...); | ||
619 | |||
620 | #endif | ||
621 | |||
622 | /** @} */ /* end of group */ | ||
623 | |||
624 | /* end of file gnunet-service-transport_ats.h */ | ||
diff --git a/src/include/gnunet_ats_transport_service.h b/src/include/gnunet_ats_transport_service.h deleted file mode 100644 index fd821baef..000000000 --- a/src/include/gnunet_ats_transport_service.h +++ /dev/null | |||
@@ -1,240 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2010-2015, 2018 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your 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 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @file | ||
22 | * Bandwidth allocation API for the transport service | ||
23 | * | ||
24 | * @author Christian Grothoff | ||
25 | * @author Matthias Wachs | ||
26 | * | ||
27 | * @defgroup ats ATS service | ||
28 | * Bandwidth allocation for transport service | ||
29 | * | ||
30 | * @see [Documentation](https://gnunet.org/ats-subsystem) | ||
31 | * | ||
32 | * @{ | ||
33 | */ | ||
34 | #ifndef GNUNET_ATS_TRANSPORT_SERVICE_H | ||
35 | #define GNUNET_ATS_TRANSPORT_SERVICE_H | ||
36 | |||
37 | #include "gnunet_constants.h" | ||
38 | #include "gnunet_util_lib.h" | ||
39 | #include "gnunet_nt_lib.h" | ||
40 | #include "gnunet_transport_communication_service.h" | ||
41 | |||
42 | |||
43 | /** | ||
44 | * ATS performance characteristics for a session. | ||
45 | */ | ||
46 | struct GNUNET_ATS_Properties | ||
47 | { | ||
48 | /** | ||
49 | * Delay. Time between when the time packet is sent and the packet | ||
50 | * arrives. FOREVER if we did not (successfully) measure yet. | ||
51 | */ | ||
52 | struct GNUNET_TIME_Relative delay; | ||
53 | |||
54 | /** | ||
55 | * Confirmed successful payload on this connection from this peer to | ||
56 | * the other peer. | ||
57 | * | ||
58 | * Unit: [bytes/second] | ||
59 | */ | ||
60 | uint32_t goodput_out; | ||
61 | |||
62 | /** | ||
63 | * Confirmed useful payload on this connection to this peer from | ||
64 | * the other peer. | ||
65 | * | ||
66 | * Unit: [bytes/second] | ||
67 | */ | ||
68 | uint32_t goodput_in; | ||
69 | |||
70 | /** | ||
71 | * Actual traffic on this connection from this peer to the other peer. | ||
72 | * Includes transport overhead. | ||
73 | * | ||
74 | * Unit: [bytes/second] | ||
75 | */ | ||
76 | uint32_t utilization_out; | ||
77 | |||
78 | /** | ||
79 | * Actual traffic on this connection from the other peer to this peer. | ||
80 | * Includes transport overhead. | ||
81 | * | ||
82 | * Unit: [bytes/second] | ||
83 | */ | ||
84 | uint32_t utilization_in; | ||
85 | |||
86 | /** | ||
87 | * Distance on network layer (required for distance-vector routing) | ||
88 | * in hops. Zero for direct connections (e.g. plain TCP/UDP). | ||
89 | */ | ||
90 | uint32_t distance; | ||
91 | |||
92 | /** | ||
93 | * MTU of the network layer, UINT32_MAX for no MTU (stream). | ||
94 | * | ||
95 | * Unit: [bytes] | ||
96 | */ | ||
97 | uint32_t mtu; | ||
98 | |||
99 | /** | ||
100 | * Which network scope does the respective address belong to? | ||
101 | */ | ||
102 | enum GNUNET_NetworkType nt; | ||
103 | |||
104 | /** | ||
105 | * What characteristics does this communicator have? | ||
106 | */ | ||
107 | enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc; | ||
108 | }; | ||
109 | |||
110 | |||
111 | /* ******************************** Transport API ***************************** */ | ||
112 | |||
113 | /** | ||
114 | * Handle to the ATS subsystem for bandwidth/transport transport information. | ||
115 | */ | ||
116 | struct GNUNET_ATS_TransportHandle; | ||
117 | |||
118 | /** | ||
119 | * Opaque session handle, to be defined by transport. Contents not known to ATS. | ||
120 | */ | ||
121 | struct GNUNET_ATS_Session; | ||
122 | |||
123 | |||
124 | /** | ||
125 | * Signature of a function called by ATS with the current bandwidth | ||
126 | * allocation to be used as determined by ATS. | ||
127 | * | ||
128 | * @param cls closure | ||
129 | * @param session session this is about | ||
130 | * @param bandwidth_out assigned outbound bandwidth for the connection, | ||
131 | * 0 to signal disconnect | ||
132 | * @param bandwidth_in assigned inbound bandwidth for the connection, | ||
133 | * 0 to signal disconnect | ||
134 | */ | ||
135 | typedef void | ||
136 | (*GNUNET_ATS_AllocationCallback) (void *cls, | ||
137 | struct GNUNET_ATS_Session *session, | ||
138 | struct GNUNET_BANDWIDTH_Value32NBO | ||
139 | bandwidth_out, | ||
140 | struct GNUNET_BANDWIDTH_Value32NBO | ||
141 | bandwidth_in); | ||
142 | |||
143 | |||
144 | /** | ||
145 | * Signature of a function called by ATS suggesting transport to | ||
146 | * try connecting with a particular address. | ||
147 | * | ||
148 | * @param cls closure | ||
149 | * @param pid target peer | ||
150 | * @param address the address to try | ||
151 | */ | ||
152 | typedef void | ||
153 | (*GNUNET_ATS_SuggestionCallback) (void *cls, | ||
154 | const struct GNUNET_PeerIdentity *pid, | ||
155 | const char *address); | ||
156 | |||
157 | |||
158 | /** | ||
159 | * Initialize the ATS transport subsystem. | ||
160 | * | ||
161 | * @param cfg configuration to use | ||
162 | * @param alloc_cb notification to call whenever the allocation changed | ||
163 | * @param alloc_cb_cls closure for @a alloc_cb | ||
164 | * @param suggest_cb notification to call whenever the suggestation is made | ||
165 | * @param suggest_cb_cls closure for @a suggest_cb | ||
166 | * @return ats context | ||
167 | */ | ||
168 | struct GNUNET_ATS_TransportHandle * | ||
169 | GNUNET_ATS_transport_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
170 | GNUNET_ATS_AllocationCallback alloc_cb, | ||
171 | void *alloc_cb_cls, | ||
172 | GNUNET_ATS_SuggestionCallback suggest_cb, | ||
173 | void *suggest_cb_cls); | ||
174 | |||
175 | |||
176 | /** | ||
177 | * Client is done with ATS transport, release resources. | ||
178 | * | ||
179 | * @param ath handle to release | ||
180 | */ | ||
181 | void | ||
182 | GNUNET_ATS_transport_done (struct GNUNET_ATS_TransportHandle *ath); | ||
183 | |||
184 | |||
185 | /** | ||
186 | * Handle used within ATS to track an session. | ||
187 | */ | ||
188 | struct GNUNET_ATS_SessionRecord; | ||
189 | |||
190 | |||
191 | /** | ||
192 | * We have a new session ATS should know. Sessiones have to be added with this | ||
193 | * function before they can be: updated, set in use and destroyed | ||
194 | * | ||
195 | * @param ath handle | ||
196 | * @param pid peer we connected to | ||
197 | * @param address the address (human readable version), | ||
198 | * @param session transport-internal handle for the session/queue, NULL if | ||
199 | * the session is inbound-only | ||
200 | * @param prop performance data for the session | ||
201 | * @return handle to the session representation inside ATS, NULL | ||
202 | * on error (i.e. ATS knows this exact session already, or | ||
203 | * session is invalid) | ||
204 | */ | ||
205 | struct GNUNET_ATS_SessionRecord * | ||
206 | GNUNET_ATS_session_add (struct GNUNET_ATS_TransportHandle *ath, | ||
207 | const struct GNUNET_PeerIdentity *pid, | ||
208 | const char *address, | ||
209 | struct GNUNET_ATS_Session *session, | ||
210 | const struct GNUNET_ATS_Properties *prop); | ||
211 | |||
212 | |||
213 | /** | ||
214 | * We have updated performance statistics for a given session. Based | ||
215 | * on the information provided, ATS may update bandwidth assignments. | ||
216 | * | ||
217 | * @param ar session record to update information for | ||
218 | * @param prop performance data for the session | ||
219 | */ | ||
220 | void | ||
221 | GNUNET_ATS_session_update (struct GNUNET_ATS_SessionRecord *ar, | ||
222 | const struct GNUNET_ATS_Properties *prop); | ||
223 | |||
224 | |||
225 | /** | ||
226 | * A session was destroyed, ATS should now schedule and | ||
227 | * allocate under the assumption that this @a ar is no | ||
228 | * longer in use. | ||
229 | * | ||
230 | * @param ar session record to drop | ||
231 | */ | ||
232 | void | ||
233 | GNUNET_ATS_session_del (struct GNUNET_ATS_SessionRecord *ar); | ||
234 | |||
235 | |||
236 | #endif | ||
237 | |||
238 | /** @} */ /* end of group */ | ||
239 | |||
240 | /* end of file gnunet-service-transport_ats.h */ | ||
diff --git a/src/include/gnunet_bandwidth_lib.h b/src/include/gnunet_bandwidth_lib.h index 9130ff57e..00a7d6c5d 100644 --- a/src/include/gnunet_bandwidth_lib.h +++ b/src/include/gnunet_bandwidth_lib.h | |||
@@ -19,6 +19,10 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup libgnunetutil | ||
23 | * Multi-function utilities library for GNUnet programs | ||
24 | * @{ | ||
25 | * | ||
22 | * @author Christian Grothoff | 26 | * @author Christian Grothoff |
23 | * | 27 | * |
24 | * @file | 28 | * @file |
@@ -29,6 +33,10 @@ | |||
29 | * @{ | 33 | * @{ |
30 | */ | 34 | */ |
31 | 35 | ||
36 | #if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) | ||
37 | #error "Only <gnunet_util_lib.h> can be included directly." | ||
38 | #endif | ||
39 | |||
32 | #ifndef GNUNET_BANDWIDTH_LIB_H | 40 | #ifndef GNUNET_BANDWIDTH_LIB_H |
33 | #define GNUNET_BANDWIDTH_LIB_H | 41 | #define GNUNET_BANDWIDTH_LIB_H |
34 | 42 | ||
@@ -39,7 +47,7 @@ extern "C" { | |||
39 | #endif | 47 | #endif |
40 | #endif | 48 | #endif |
41 | 49 | ||
42 | #include "gnunet_common.h" | 50 | |
43 | #include "gnunet_time_lib.h" | 51 | #include "gnunet_time_lib.h" |
44 | 52 | ||
45 | GNUNET_NETWORK_STRUCT_BEGIN | 53 | GNUNET_NETWORK_STRUCT_BEGIN |
@@ -351,4 +359,6 @@ GNUNET_BANDWIDTH_tracker_update_quota ( | |||
351 | 359 | ||
352 | /** @} */ /* end of group */ | 360 | /** @} */ /* end of group */ |
353 | 361 | ||
362 | /** @} */ /* end of group addition */ | ||
363 | |||
354 | /* end of gnunet_bandwidth_lib.h */ | 364 | /* end of gnunet_bandwidth_lib.h */ |
diff --git a/src/include/gnunet_bio_lib.h b/src/include/gnunet_bio_lib.h index 142f1b088..73550db7e 100644 --- a/src/include/gnunet_bio_lib.h +++ b/src/include/gnunet_bio_lib.h | |||
@@ -19,6 +19,10 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup libgnunetutil | ||
23 | * Multi-function utilities library for GNUnet programs | ||
24 | * @{ | ||
25 | * | ||
22 | * @author Christian Grothoff | 26 | * @author Christian Grothoff |
23 | * | 27 | * |
24 | * @file | 28 | * @file |
@@ -29,9 +33,15 @@ | |||
29 | * @{ | 33 | * @{ |
30 | */ | 34 | */ |
31 | 35 | ||
36 | #include "gnunet_common.h" | ||
37 | #if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) | ||
38 | #error "Only <gnunet_util_lib.h> can be included directly." | ||
39 | #endif | ||
40 | |||
32 | #ifndef GNUNET_BIO_LIB_H | 41 | #ifndef GNUNET_BIO_LIB_H |
33 | #define GNUNET_BIO_LIB_H | 42 | #define GNUNET_BIO_LIB_H |
34 | 43 | ||
44 | |||
35 | #include "gnunet_container_lib.h" | 45 | #include "gnunet_container_lib.h" |
36 | 46 | ||
37 | #ifdef __cplusplus | 47 | #ifdef __cplusplus |
@@ -79,9 +89,18 @@ GNUNET_BIO_read_open_buffer (void *buffer, size_t size); | |||
79 | * @param emsg set to the error message | 89 | * @param emsg set to the error message |
80 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | 90 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
81 | */ | 91 | */ |
82 | int | 92 | enum GNUNET_GenericReturnValue |
83 | GNUNET_BIO_read_close (struct GNUNET_BIO_ReadHandle *h, char **emsg); | 93 | GNUNET_BIO_read_close (struct GNUNET_BIO_ReadHandle *h, char **emsg); |
84 | 94 | ||
95 | /** | ||
96 | * Set read error to handle | ||
97 | * | ||
98 | * @param h the handle | ||
99 | * @param emsg the message | ||
100 | */ | ||
101 | void | ||
102 | GNUNET_BIO_read_set_error (struct GNUNET_BIO_ReadHandle *h, const char* emsg); | ||
103 | |||
85 | 104 | ||
86 | /** | 105 | /** |
87 | * Read some contents into a buffer. | 106 | * Read some contents into a buffer. |
@@ -92,7 +111,7 @@ GNUNET_BIO_read_close (struct GNUNET_BIO_ReadHandle *h, char **emsg); | |||
92 | * @param len the number of bytes to read | 111 | * @param len the number of bytes to read |
93 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure | 112 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure |
94 | */ | 113 | */ |
95 | int | 114 | enum GNUNET_GenericReturnValue |
96 | GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h, | 115 | GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h, |
97 | const char *what, | 116 | const char *what, |
98 | void *result, | 117 | void *result, |
@@ -109,26 +128,13 @@ GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h, | |||
109 | * @param max_length maximum allowed length for the string | 128 | * @param max_length maximum allowed length for the string |
110 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure | 129 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure |
111 | */ | 130 | */ |
112 | int | 131 | enum GNUNET_GenericReturnValue |
113 | GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h, | 132 | GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h, |
114 | const char *what, | 133 | const char *what, |
115 | char **result, | 134 | char **result, |
116 | size_t max_length); | 135 | size_t max_length); |
117 | 136 | ||
118 | 137 | ||
119 | /** | ||
120 | * Read a metadata container. | ||
121 | * | ||
122 | * @param h handle to an open file | ||
123 | * @param what describes what is being read (for error message creation) | ||
124 | * @param result the buffer to store a pointer to the (allocated) metadata | ||
125 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure | ||
126 | */ | ||
127 | int | ||
128 | GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h, | ||
129 | const char *what, | ||
130 | struct GNUNET_CONTAINER_MetaData **result); | ||
131 | |||
132 | 138 | ||
133 | /** | 139 | /** |
134 | * Read a float. | 140 | * Read a float. |
@@ -137,7 +143,7 @@ GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h, | |||
137 | * @param what describes what is being read (for error message creation) | 143 | * @param what describes what is being read (for error message creation) |
138 | * @param f address of float to read | 144 | * @param f address of float to read |
139 | */ | 145 | */ |
140 | int | 146 | enum GNUNET_GenericReturnValue |
141 | GNUNET_BIO_read_float (struct GNUNET_BIO_ReadHandle *h, | 147 | GNUNET_BIO_read_float (struct GNUNET_BIO_ReadHandle *h, |
142 | const char *what, | 148 | const char *what, |
143 | float *f); | 149 | float *f); |
@@ -150,7 +156,7 @@ GNUNET_BIO_read_float (struct GNUNET_BIO_ReadHandle *h, | |||
150 | * @param what describes what is being read (for error message creation) | 156 | * @param what describes what is being read (for error message creation) |
151 | * @param f address of double to read | 157 | * @param f address of double to read |
152 | */ | 158 | */ |
153 | int | 159 | enum GNUNET_GenericReturnValue |
154 | GNUNET_BIO_read_double (struct GNUNET_BIO_ReadHandle *h, | 160 | GNUNET_BIO_read_double (struct GNUNET_BIO_ReadHandle *h, |
155 | const char *what, | 161 | const char *what, |
156 | double *f); | 162 | double *f); |
@@ -164,7 +170,7 @@ GNUNET_BIO_read_double (struct GNUNET_BIO_ReadHandle *h, | |||
164 | * @param i where to store the data | 170 | * @param i where to store the data |
165 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 171 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
166 | */ | 172 | */ |
167 | int | 173 | enum GNUNET_GenericReturnValue |
168 | GNUNET_BIO_read_int32 (struct GNUNET_BIO_ReadHandle *h, | 174 | GNUNET_BIO_read_int32 (struct GNUNET_BIO_ReadHandle *h, |
169 | const char *what, | 175 | const char *what, |
170 | int32_t *i); | 176 | int32_t *i); |
@@ -178,7 +184,7 @@ GNUNET_BIO_read_int32 (struct GNUNET_BIO_ReadHandle *h, | |||
178 | * @param i where to store the data | 184 | * @param i where to store the data |
179 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 185 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
180 | */ | 186 | */ |
181 | int | 187 | enum GNUNET_GenericReturnValue |
182 | GNUNET_BIO_read_int64 (struct GNUNET_BIO_ReadHandle *h, | 188 | GNUNET_BIO_read_int64 (struct GNUNET_BIO_ReadHandle *h, |
183 | const char *what, | 189 | const char *what, |
184 | int64_t *i); | 190 | int64_t *i); |
@@ -219,7 +225,7 @@ GNUNET_BIO_write_open_buffer (void); | |||
219 | * @return #GNUNET_OK upon success. Upon failure #GNUNET_SYSERR is returned | 225 | * @return #GNUNET_OK upon success. Upon failure #GNUNET_SYSERR is returned |
220 | * and the file is closed | 226 | * and the file is closed |
221 | */ | 227 | */ |
222 | int | 228 | enum GNUNET_GenericReturnValue |
223 | GNUNET_BIO_flush (struct GNUNET_BIO_WriteHandle *h); | 229 | GNUNET_BIO_flush (struct GNUNET_BIO_WriteHandle *h); |
224 | 230 | ||
225 | 231 | ||
@@ -235,7 +241,7 @@ GNUNET_BIO_flush (struct GNUNET_BIO_WriteHandle *h); | |||
235 | * @param size where to store the size of @e contents | 241 | * @param size where to store the size of @e contents |
236 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | 242 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
237 | */ | 243 | */ |
238 | int | 244 | enum GNUNET_GenericReturnValue |
239 | GNUNET_BIO_get_buffer_contents (struct GNUNET_BIO_WriteHandle *h, | 245 | GNUNET_BIO_get_buffer_contents (struct GNUNET_BIO_WriteHandle *h, |
240 | char **emsg, | 246 | char **emsg, |
241 | void **contents, | 247 | void **contents, |
@@ -251,7 +257,7 @@ GNUNET_BIO_get_buffer_contents (struct GNUNET_BIO_WriteHandle *h, | |||
251 | * if the handle has an error message, the return value is #GNUNET_SYSERR | 257 | * if the handle has an error message, the return value is #GNUNET_SYSERR |
252 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | 258 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
253 | */ | 259 | */ |
254 | int | 260 | enum GNUNET_GenericReturnValue |
255 | GNUNET_BIO_write_close (struct GNUNET_BIO_WriteHandle *h, char **emsg); | 261 | GNUNET_BIO_write_close (struct GNUNET_BIO_WriteHandle *h, char **emsg); |
256 | 262 | ||
257 | 263 | ||
@@ -264,7 +270,7 @@ GNUNET_BIO_write_close (struct GNUNET_BIO_WriteHandle *h, char **emsg); | |||
264 | * @param n number of bytes to write | 270 | * @param n number of bytes to write |
265 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 271 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
266 | */ | 272 | */ |
267 | int | 273 | enum GNUNET_GenericReturnValue |
268 | GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h, | 274 | GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h, |
269 | const char *what, | 275 | const char *what, |
270 | const void *buffer, | 276 | const void *buffer, |
@@ -279,25 +285,12 @@ GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h, | |||
279 | * @param s string to write (can be NULL) | 285 | * @param s string to write (can be NULL) |
280 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 286 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
281 | */ | 287 | */ |
282 | int | 288 | enum GNUNET_GenericReturnValue |
283 | GNUNET_BIO_write_string (struct GNUNET_BIO_WriteHandle *h, | 289 | GNUNET_BIO_write_string (struct GNUNET_BIO_WriteHandle *h, |
284 | const char *what, | 290 | const char *what, |
285 | const char *s); | 291 | const char *s); |
286 | 292 | ||
287 | 293 | ||
288 | /** | ||
289 | * Write a metadata container. | ||
290 | * | ||
291 | * @param h the IO handle to write to | ||
292 | * @param what what is being written (for error message creation) | ||
293 | * @param m metadata to write | ||
294 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | ||
295 | */ | ||
296 | int | ||
297 | GNUNET_BIO_write_meta_data (struct GNUNET_BIO_WriteHandle *h, | ||
298 | const char *what, | ||
299 | const struct GNUNET_CONTAINER_MetaData *m); | ||
300 | |||
301 | 294 | ||
302 | /** | 295 | /** |
303 | * Write a float. | 296 | * Write a float. |
@@ -306,7 +299,7 @@ GNUNET_BIO_write_meta_data (struct GNUNET_BIO_WriteHandle *h, | |||
306 | * @param what what is being written (for error message creation) | 299 | * @param what what is being written (for error message creation) |
307 | * @param f float to write (must be a variable) | 300 | * @param f float to write (must be a variable) |
308 | */ | 301 | */ |
309 | int | 302 | enum GNUNET_GenericReturnValue |
310 | GNUNET_BIO_write_float (struct GNUNET_BIO_WriteHandle *h, | 303 | GNUNET_BIO_write_float (struct GNUNET_BIO_WriteHandle *h, |
311 | const char *what, | 304 | const char *what, |
312 | float f); | 305 | float f); |
@@ -318,7 +311,7 @@ GNUNET_BIO_write_float (struct GNUNET_BIO_WriteHandle *h, | |||
318 | * @param what what is being written (for error message creation) | 311 | * @param what what is being written (for error message creation) |
319 | * @param f double to write (must be a variable) | 312 | * @param f double to write (must be a variable) |
320 | */ | 313 | */ |
321 | int | 314 | enum GNUNET_GenericReturnValue |
322 | GNUNET_BIO_write_double (struct GNUNET_BIO_WriteHandle *h, | 315 | GNUNET_BIO_write_double (struct GNUNET_BIO_WriteHandle *h, |
323 | const char *what, | 316 | const char *what, |
324 | double f); | 317 | double f); |
@@ -332,7 +325,7 @@ GNUNET_BIO_write_double (struct GNUNET_BIO_WriteHandle *h, | |||
332 | * @param i 32-bit integer to write | 325 | * @param i 32-bit integer to write |
333 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 326 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
334 | */ | 327 | */ |
335 | int | 328 | enum GNUNET_GenericReturnValue |
336 | GNUNET_BIO_write_int32 (struct GNUNET_BIO_WriteHandle *h, | 329 | GNUNET_BIO_write_int32 (struct GNUNET_BIO_WriteHandle *h, |
337 | const char *what, | 330 | const char *what, |
338 | int32_t i); | 331 | int32_t i); |
@@ -346,7 +339,7 @@ GNUNET_BIO_write_int32 (struct GNUNET_BIO_WriteHandle *h, | |||
346 | * @param i 64-bit integer to write | 339 | * @param i 64-bit integer to write |
347 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 340 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
348 | */ | 341 | */ |
349 | int | 342 | enum GNUNET_GenericReturnValue |
350 | GNUNET_BIO_write_int64 (struct GNUNET_BIO_WriteHandle *h, | 343 | GNUNET_BIO_write_int64 (struct GNUNET_BIO_WriteHandle *h, |
351 | const char *what, | 344 | const char *what, |
352 | int64_t i); | 345 | int64_t i); |
@@ -444,17 +437,6 @@ GNUNET_BIO_read_spec_string (const char *what, | |||
444 | size_t max_length); | 437 | size_t max_length); |
445 | 438 | ||
446 | 439 | ||
447 | /** | ||
448 | * Create the specification to read a metadata container. | ||
449 | * | ||
450 | * @param what describes what is being read (for error message creation) | ||
451 | * @param result the buffer to store a pointer to the (allocated) metadata | ||
452 | * @return the read spec | ||
453 | */ | ||
454 | struct GNUNET_BIO_ReadSpec | ||
455 | GNUNET_BIO_read_spec_meta_data (const char *what, | ||
456 | struct GNUNET_CONTAINER_MetaData **result); | ||
457 | |||
458 | 440 | ||
459 | /** | 441 | /** |
460 | * Create the specification to read an (u)int32_t. | 442 | * Create the specification to read an (u)int32_t. |
@@ -508,7 +490,7 @@ GNUNET_BIO_read_spec_double (const char *what, double *f); | |||
508 | * the last element must be #GNUNET_BIO_read_spec_end | 490 | * the last element must be #GNUNET_BIO_read_spec_end |
509 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | 491 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
510 | */ | 492 | */ |
511 | int | 493 | enum GNUNET_GenericReturnValue |
512 | GNUNET_BIO_read_spec_commit (struct GNUNET_BIO_ReadHandle *h, | 494 | GNUNET_BIO_read_spec_commit (struct GNUNET_BIO_ReadHandle *h, |
513 | struct GNUNET_BIO_ReadSpec *rs); | 495 | struct GNUNET_BIO_ReadSpec *rs); |
514 | 496 | ||
@@ -601,18 +583,6 @@ GNUNET_BIO_write_spec_string (const char *what, | |||
601 | 583 | ||
602 | 584 | ||
603 | /** | 585 | /** |
604 | * Create the specification to write a metadata container. | ||
605 | * | ||
606 | * @param what what is being written (for error message creation) | ||
607 | * @param m metadata to write | ||
608 | * @return the write spec | ||
609 | */ | ||
610 | struct GNUNET_BIO_WriteSpec | ||
611 | GNUNET_BIO_write_spec_meta_data (const char *what, | ||
612 | const struct GNUNET_CONTAINER_MetaData *m); | ||
613 | |||
614 | |||
615 | /** | ||
616 | * Create the specification to write an (u)int32_t. | 586 | * Create the specification to write an (u)int32_t. |
617 | * | 587 | * |
618 | * @param what describes what is being written (for error message creation) | 588 | * @param what describes what is being written (for error message creation) |
@@ -666,7 +636,7 @@ GNUNET_BIO_write_spec_double (const char *what, double *f); | |||
666 | * the last element must be #GNUNET_BIO_write_spec_end | 636 | * the last element must be #GNUNET_BIO_write_spec_end |
667 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | 637 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
668 | */ | 638 | */ |
669 | int | 639 | enum GNUNET_GenericReturnValue |
670 | GNUNET_BIO_write_spec_commit (struct GNUNET_BIO_WriteHandle *h, | 640 | GNUNET_BIO_write_spec_commit (struct GNUNET_BIO_WriteHandle *h, |
671 | struct GNUNET_BIO_WriteSpec *ws); | 641 | struct GNUNET_BIO_WriteSpec *ws); |
672 | 642 | ||
@@ -683,4 +653,6 @@ GNUNET_BIO_write_spec_commit (struct GNUNET_BIO_WriteHandle *h, | |||
683 | 653 | ||
684 | /** @} */ /* end of group bio */ | 654 | /** @} */ /* end of group bio */ |
685 | 655 | ||
656 | /** @} */ /* end of group addition */ | ||
657 | |||
686 | /* end of gnunet_bio_lib.h */ | 658 | /* end of gnunet_bio_lib.h */ |
diff --git a/src/include/gnunet_block_group_lib.h b/src/include/gnunet_block_group_lib.h index d242ceefb..b1f59899e 100644 --- a/src/include/gnunet_block_group_lib.h +++ b/src/include/gnunet_block_group_lib.h | |||
@@ -31,6 +31,7 @@ | |||
31 | #ifndef GNUNET_BLOCK_GROUP_LIB_H | 31 | #ifndef GNUNET_BLOCK_GROUP_LIB_H |
32 | #define GNUNET_BLOCK_GROUP_LIB_H | 32 | #define GNUNET_BLOCK_GROUP_LIB_H |
33 | 33 | ||
34 | |||
34 | #include "gnunet_util_lib.h" | 35 | #include "gnunet_util_lib.h" |
35 | #include "gnunet_block_lib.h" | 36 | #include "gnunet_block_lib.h" |
36 | 37 | ||
@@ -90,7 +91,7 @@ GNUNET_BLOCK_GROUP_bf_create (void *cls, | |||
90 | * @param bg block group to use for testing | 91 | * @param bg block group to use for testing |
91 | * @param hc hash of element to evaluate | 92 | * @param hc hash of element to evaluate |
92 | * @return #GNUNET_YES if @a hc is (likely) a duplicate | 93 | * @return #GNUNET_YES if @a hc is (likely) a duplicate |
93 | * #GNUNET_NO if @a hc was definitively not in @bg (but now is) | 94 | * #GNUNET_NO if @a hc was definitively not in @a bg (but now is) |
94 | */ | 95 | */ |
95 | enum GNUNET_GenericReturnValue | 96 | enum GNUNET_GenericReturnValue |
96 | GNUNET_BLOCK_GROUP_bf_test_and_set (struct GNUNET_BLOCK_Group *bg, | 97 | GNUNET_BLOCK_GROUP_bf_test_and_set (struct GNUNET_BLOCK_Group *bg, |
diff --git a/src/include/gnunet_block_lib.h b/src/include/gnunet_block_lib.h index af61dcfb0..fdccbab78 100644 --- a/src/include/gnunet_block_lib.h +++ b/src/include/gnunet_block_lib.h | |||
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup dht_libs DHT and support libraries | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
@@ -31,6 +34,7 @@ | |||
31 | #ifndef GNUNET_BLOCK_LIB_H | 34 | #ifndef GNUNET_BLOCK_LIB_H |
32 | #define GNUNET_BLOCK_LIB_H | 35 | #define GNUNET_BLOCK_LIB_H |
33 | 36 | ||
37 | |||
34 | #include "gnunet_util_lib.h" | 38 | #include "gnunet_util_lib.h" |
35 | #include "gnunet_dht_block_types.h" | 39 | #include "gnunet_dht_block_types.h" |
36 | 40 | ||
@@ -128,7 +132,6 @@ struct GNUNET_BLOCK_Group; | |||
128 | * | 132 | * |
129 | * @param ctx block context in which the block group is created | 133 | * @param ctx block context in which the block group is created |
130 | * @param type type of the block for which we are creating the group | 134 | * @param type type of the block for which we are creating the group |
131 | * @param nonce random value used to seed the group creation | ||
132 | * @param raw_data optional serialized prior state of the group, NULL if unavailable/fresh | 135 | * @param raw_data optional serialized prior state of the group, NULL if unavailable/fresh |
133 | * @param raw_data_size number of bytes in @a raw_data, 0 if unavailable/fresh | 136 | * @param raw_data_size number of bytes in @a raw_data, 0 if unavailable/fresh |
134 | * @param ... type-specific additional data, can be empty | 137 | * @param ... type-specific additional data, can be empty |
@@ -269,7 +272,7 @@ GNUNET_BLOCK_group_set_seen (struct GNUNET_BLOCK_Group *bg, | |||
269 | 272 | ||
270 | /** | 273 | /** |
271 | * Try merging two block groups. Afterwards, @a bg1 should remain | 274 | * Try merging two block groups. Afterwards, @a bg1 should remain |
272 | * valid and contain the rules from both @a bg1 and @bg2, and | 275 | * valid and contain the rules from both @a bg1 and @a bg2, and |
273 | * @a bg2 should be destroyed (as part of this call). The latter | 276 | * @a bg2 should be destroyed (as part of this call). The latter |
274 | * should happen even if merging is not supported. | 277 | * should happen even if merging is not supported. |
275 | * | 278 | * |
@@ -296,4 +299,6 @@ GNUNET_BLOCK_group_merge (struct GNUNET_BLOCK_Group *bg1, | |||
296 | 299 | ||
297 | /** @} */ /* end of group */ | 300 | /** @} */ /* end of group */ |
298 | 301 | ||
302 | /** @} */ /* end of group addition */ | ||
303 | |||
299 | /* end of gnunet_block_lib.h */ | 304 | /* end of gnunet_block_lib.h */ |
diff --git a/src/include/gnunet_block_plugin.h b/src/include/gnunet_block_plugin.h index 6f9e8e9dc..16e93c780 100644 --- a/src/include/gnunet_block_plugin.h +++ b/src/include/gnunet_block_plugin.h | |||
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup dht_libs DHT and support libraries | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
@@ -35,6 +38,7 @@ | |||
35 | #ifndef PLUGIN_BLOCK_H | 38 | #ifndef PLUGIN_BLOCK_H |
36 | #define PLUGIN_BLOCK_H | 39 | #define PLUGIN_BLOCK_H |
37 | 40 | ||
41 | |||
38 | #include "gnunet_util_lib.h" | 42 | #include "gnunet_util_lib.h" |
39 | #include "gnunet_block_lib.h" | 43 | #include "gnunet_block_lib.h" |
40 | 44 | ||
@@ -289,3 +293,5 @@ struct GNUNET_BLOCK_PluginFunctions | |||
289 | #endif | 293 | #endif |
290 | 294 | ||
291 | /** @} */ /* end of group */ | 295 | /** @} */ /* end of group */ |
296 | |||
297 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_buffer_lib.h b/src/include/gnunet_buffer_lib.h index 7239eccfb..e65981206 100644 --- a/src/include/gnunet_buffer_lib.h +++ b/src/include/gnunet_buffer_lib.h | |||
@@ -19,11 +19,19 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup libgnunetutil | ||
23 | * Multi-function utilities library for GNUnet programs | ||
24 | * @{ | ||
25 | * | ||
22 | * Common buffer management functions. | 26 | * Common buffer management functions. |
23 | * | 27 | * |
24 | * @author Florian Dold | 28 | * @author Florian Dold |
25 | */ | 29 | */ |
26 | 30 | ||
31 | #if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) | ||
32 | #error "Only <gnunet_util_lib.h> can be included directly." | ||
33 | #endif | ||
34 | |||
27 | #ifndef GNUNET_BUFFER_LIB_H | 35 | #ifndef GNUNET_BUFFER_LIB_H |
28 | #define GNUNET_BUFFER_LIB_H | 36 | #define GNUNET_BUFFER_LIB_H |
29 | 37 | ||
@@ -203,3 +211,5 @@ GNUNET_buffer_clear (struct GNUNET_Buffer *buf); | |||
203 | 211 | ||
204 | 212 | ||
205 | #endif | 213 | #endif |
214 | |||
215 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_cadet_service.h b/src/include/gnunet_cadet_service.h index f08c1572a..ab53d2bd8 100644 --- a/src/include/gnunet_cadet_service.h +++ b/src/include/gnunet_cadet_service.h | |||
@@ -18,6 +18,9 @@ | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @addtogroup Backbone | ||
22 | * @{ | ||
23 | * | ||
21 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
22 | * @author Bart Polot | 25 | * @author Bart Polot |
23 | * | 26 | * |
@@ -42,8 +45,8 @@ extern "C" { | |||
42 | #endif | 45 | #endif |
43 | #endif | 46 | #endif |
44 | 47 | ||
48 | |||
45 | #include "gnunet_util_lib.h" | 49 | #include "gnunet_util_lib.h" |
46 | #include "gnunet_transport_service.h" | ||
47 | 50 | ||
48 | /** | 51 | /** |
49 | * Version number of GNUnet-cadet API. | 52 | * Version number of GNUnet-cadet API. |
@@ -309,7 +312,9 @@ union GNUNET_CADET_ChannelInfo | |||
309 | * Get information about a channel. | 312 | * Get information about a channel. |
310 | * | 313 | * |
311 | * @param channel Channel handle. | 314 | * @param channel Channel handle. |
315 | * @param option Query (GNUNET_CADET_OPTION_*) | ||
312 | * @param ... dependent on option, currently not used | 316 | * @param ... dependent on option, currently not used |
317 | * | ||
313 | * @return Union with an answer to the query. | 318 | * @return Union with an answer to the query. |
314 | */ | 319 | */ |
315 | const union GNUNET_CADET_ChannelInfo * | 320 | const union GNUNET_CADET_ChannelInfo * |
@@ -627,4 +632,6 @@ GNUNET_CADET_list_tunnels_cancel (struct GNUNET_CADET_ListTunnels *lt); | |||
627 | 632 | ||
628 | /** @} */ /* end of group */ | 633 | /** @} */ /* end of group */ |
629 | 634 | ||
635 | /** @} */ /* end of group addition */ | ||
636 | |||
630 | /* end of gnunet_cadet_service.h */ | 637 | /* end of gnunet_cadet_service.h */ |
diff --git a/src/include/gnunet_child_management_lib.h b/src/include/gnunet_child_management_lib.h index a35b37865..ab0ab93eb 100644 --- a/src/include/gnunet_child_management_lib.h +++ b/src/include/gnunet_child_management_lib.h | |||
@@ -18,7 +18,15 @@ | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #if ! defined (__GNUNET_UTIL_LIB_H_INSIDE__) | ||
22 | #error "Only <gnunet_util_lib.h> can be included directly." | ||
23 | #endif | ||
24 | |||
21 | /** | 25 | /** |
26 | * @addtogroup libgnunetutil | ||
27 | * Multi-function utilities library for GNUnet programs | ||
28 | * @{ | ||
29 | * | ||
22 | * @file include/gnunet_child_management_lib.h | 30 | * @file include/gnunet_child_management_lib.h |
23 | * @brief GNUnet child management api | 31 | * @brief GNUnet child management api |
24 | * @author Christian Grothoff | 32 | * @author Christian Grothoff |
@@ -41,8 +49,7 @@ struct GNUNET_ChildWaitHandle; | |||
41 | * @param cls handle for the callback | 49 | * @param cls handle for the callback |
42 | * @param type type of the process | 50 | * @param type type of the process |
43 | * @param exit_code status code of the process | 51 | * @param exit_code status code of the process |
44 | * | 52 | */ |
45 | */ | ||
46 | typedef void | 53 | typedef void |
47 | (*GNUNET_ChildCompletedCallback)(void *cls, | 54 | (*GNUNET_ChildCompletedCallback)(void *cls, |
48 | enum GNUNET_OS_ProcessStatusType type, | 55 | enum GNUNET_OS_ProcessStatusType type, |
@@ -70,3 +77,5 @@ void | |||
70 | GNUNET_wait_child_cancel (struct GNUNET_ChildWaitHandle *cwh); | 77 | GNUNET_wait_child_cancel (struct GNUNET_ChildWaitHandle *cwh); |
71 | 78 | ||
72 | #endif | 79 | #endif |
80 | |||
81 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_client_lib.h b/src/include/gnunet_client_lib.h index 2ecd38b04..ab4c7d088 100644 --- a/src/include/gnunet_client_lib.h +++ b/src/include/gnunet_client_lib.h | |||
@@ -19,6 +19,13 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup libgnunetutil | ||
23 | * Multi-function utilities library for GNUnet programs | ||
24 | * @{ | ||
25 | * | ||
26 | * @addtogroup networking | ||
27 | * @{ | ||
28 | * | ||
22 | * @author Christian Grothoff | 29 | * @author Christian Grothoff |
23 | * | 30 | * |
24 | * @file | 31 | * @file |
@@ -32,6 +39,10 @@ | |||
32 | * @{ | 39 | * @{ |
33 | */ | 40 | */ |
34 | 41 | ||
42 | #if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) | ||
43 | #error "Only <gnunet_util_lib.h> can be included directly." | ||
44 | #endif | ||
45 | |||
35 | #ifndef GNUNET_CLIENT_LIB_H | 46 | #ifndef GNUNET_CLIENT_LIB_H |
36 | #define GNUNET_CLIENT_LIB_H | 47 | #define GNUNET_CLIENT_LIB_H |
37 | 48 | ||
@@ -43,6 +54,7 @@ extern "C" | |||
43 | #endif | 54 | #endif |
44 | #endif | 55 | #endif |
45 | 56 | ||
57 | |||
46 | #include "gnunet_mq_lib.h" | 58 | #include "gnunet_mq_lib.h" |
47 | 59 | ||
48 | 60 | ||
@@ -67,7 +79,8 @@ GNUNET_CLIENT_test (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
67 | * Create a message queue to connect to a GNUnet service. | 79 | * Create a message queue to connect to a GNUnet service. |
68 | * If handlers are specified, receive messages from the connection. | 80 | * If handlers are specified, receive messages from the connection. |
69 | * | 81 | * |
70 | * @param connection the client connection | 82 | * @param cfg our configuration |
83 | * @param service_name name of the service to connect to | ||
71 | * @param handlers handlers for receiving messages, can be NULL | 84 | * @param handlers handlers for receiving messages, can be NULL |
72 | * @param error_handler error handler | 85 | * @param error_handler error handler |
73 | * @param error_handler_cls closure for the @a error_handler | 86 | * @param error_handler_cls closure for the @a error_handler |
@@ -93,4 +106,8 @@ GNUNET_CLIENT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
93 | 106 | ||
94 | /** @} */ /* end of group client */ | 107 | /** @} */ /* end of group client */ |
95 | 108 | ||
109 | /** @} */ /* end of group addition */ | ||
110 | |||
111 | /** @} */ /* end of group addition */ | ||
112 | |||
96 | /* end of gnunet_client_lib.h */ | 113 | /* end of gnunet_client_lib.h */ |
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h index 9bcd99c7b..9fa3de37d 100644 --- a/src/include/gnunet_common.h +++ b/src/include/gnunet_common.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2006-2021 GNUnet e.V. | 3 | Copyright (C) 2006-2022 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -19,6 +19,10 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup libgnunetutil | ||
23 | * Multi-function utilities library for GNUnet programs | ||
24 | * @{ | ||
25 | * | ||
22 | * @file include/gnunet_common.h | 26 | * @file include/gnunet_common.h |
23 | * @brief commonly used definitions; globals in this file | 27 | * @brief commonly used definitions; globals in this file |
24 | * are exempt from the rule that the module name ("common") | 28 | * are exempt from the rule that the module name ("common") |
@@ -36,28 +40,38 @@ | |||
36 | #ifndef GNUNET_COMMON_H | 40 | #ifndef GNUNET_COMMON_H |
37 | #define GNUNET_COMMON_H | 41 | #define GNUNET_COMMON_H |
38 | 42 | ||
43 | #include "gnunet_config.h" | ||
44 | |||
45 | #include <stdbool.h> | ||
39 | #include <stdlib.h> | 46 | #include <stdlib.h> |
40 | #if HAVE_SYS_SOCKET_H | ||
41 | #include <sys/socket.h> | 47 | #include <sys/socket.h> |
42 | #endif | 48 | #include <sys/un.h> |
43 | #if HAVE_NETINET_IN_H | ||
44 | #include <netinet/in.h> | 49 | #include <netinet/in.h> |
45 | #endif | 50 | #include <arpa/inet.h> |
46 | #ifdef HAVE_STDINT_H | ||
47 | #include <stdint.h> | 51 | #include <stdint.h> |
48 | #endif | ||
49 | #ifdef HAVE_STDARG_H | ||
50 | #include <stdarg.h> | 52 | #include <stdarg.h> |
51 | #endif | ||
52 | #ifdef HAVE_SYS_TYPES_H | ||
53 | #include <sys/types.h> | 53 | #include <sys/types.h> |
54 | #endif | ||
55 | #ifdef HAVE_SYS_SOCKET_H | ||
56 | #include <sys/socket.h> | ||
57 | #endif | ||
58 | 54 | ||
55 | #if defined(__FreeBSD__) | ||
56 | |||
57 | #include <sys/endian.h> | ||
58 | #define bswap_32(x) bswap32(x) | ||
59 | #define bswap_64(x) bswap64(x) | ||
60 | |||
61 | #elif defined(__OpenBSD__) | ||
62 | |||
63 | #define bswap_32(x) swap32(x) | ||
64 | #define bswap_64(x) swap64(x) | ||
65 | |||
66 | #elif defined(__NetBSD__) | ||
59 | 67 | ||
60 | #ifdef HAVE_BYTESWAP_H | 68 | #include <machine/bswap.h> |
69 | #if defined(__BSWAP_RENAME) && !defined(__bswap_32) | ||
70 | #define bswap_32(x) bswap32(x) | ||
71 | #define bswap_64(x) bswap64(x) | ||
72 | #endif | ||
73 | |||
74 | #elif defined(__linux__) || defined(GNU) | ||
61 | #include <byteswap.h> | 75 | #include <byteswap.h> |
62 | #endif | 76 | #endif |
63 | 77 | ||
@@ -132,12 +146,6 @@ enum GNUNET_GenericReturnValue | |||
132 | #endif | 146 | #endif |
133 | 147 | ||
134 | /** | 148 | /** |
135 | * wrap va_arg for enums | ||
136 | */ | ||
137 | #define GNUNET_VA_ARG_ENUM(va, X) ((enum X) va_arg (va, int)) | ||
138 | |||
139 | |||
140 | /** | ||
141 | * @ingroup logging | 149 | * @ingroup logging |
142 | * define #GNUNET_EXTRA_LOGGING if using this header outside the GNUnet source | 150 | * define #GNUNET_EXTRA_LOGGING if using this header outside the GNUnet source |
143 | * tree where gnunet_config.h is unavailable | 151 | * tree where gnunet_config.h is unavailable |
@@ -150,8 +158,7 @@ enum GNUNET_GenericReturnValue | |||
150 | * Endian operations | 158 | * Endian operations |
151 | */ | 159 | */ |
152 | 160 | ||
153 | #if __BYTE_ORDER == __LITTLE_ENDIAN | 161 | #if defined(bswap_16) || defined(bswap_32) || defined(bswap_64) |
154 | #ifdef HAVE_BYTESWAP_H | ||
155 | #define BYTE_SWAP_16(x) bswap_16 (x) | 162 | #define BYTE_SWAP_16(x) bswap_16 (x) |
156 | #define BYTE_SWAP_32(x) bswap_32 (x) | 163 | #define BYTE_SWAP_32(x) bswap_32 (x) |
157 | #define BYTE_SWAP_64(x) bswap_64 (x) | 164 | #define BYTE_SWAP_64(x) bswap_64 (x) |
@@ -170,6 +177,7 @@ enum GNUNET_GenericReturnValue | |||
170 | 56)) | 177 | 56)) |
171 | #endif | 178 | #endif |
172 | 179 | ||
180 | #if __BYTE_ORDER == __LITTLE_ENDIAN | ||
173 | #define GNUNET_htobe16(x) BYTE_SWAP_16 (x) | 181 | #define GNUNET_htobe16(x) BYTE_SWAP_16 (x) |
174 | #define GNUNET_htole16(x) (x) | 182 | #define GNUNET_htole16(x) (x) |
175 | #define GNUNET_be16toh(x) BYTE_SWAP_16 (x) | 183 | #define GNUNET_be16toh(x) BYTE_SWAP_16 (x) |
@@ -667,7 +675,7 @@ GNUNET_log_skip (int n, int check_reset); | |||
667 | * @param logfile change logging to logfile (use NULL to keep stderr) | 675 | * @param logfile change logging to logfile (use NULL to keep stderr) |
668 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if logfile could not be opened | 676 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if logfile could not be opened |
669 | */ | 677 | */ |
670 | int | 678 | enum GNUNET_GenericReturnValue |
671 | GNUNET_log_setup (const char *comp, const char *loglevel, const char *logfile); | 679 | GNUNET_log_setup (const char *comp, const char *loglevel, const char *logfile); |
672 | 680 | ||
673 | 681 | ||
@@ -980,7 +988,7 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind); | |||
980 | } while (0) | 988 | } while (0) |
981 | 989 | ||
982 | 990 | ||
983 | #if HAVE_STATIC_ASSERT | 991 | #ifdef _Static_assert |
984 | /** | 992 | /** |
985 | * Assertion to be checked (if supported by C compiler) at | 993 | * Assertion to be checked (if supported by C compiler) at |
986 | * compile time, otherwise checked at runtime and resulting | 994 | * compile time, otherwise checked at runtime and resulting |
@@ -1506,7 +1514,7 @@ GNUNET_is_zero_ (const void *a, | |||
1506 | * will be updated to reflect the new address. The TYPE of | 1514 | * will be updated to reflect the new address. The TYPE of |
1507 | * arr is important since size is the number of elements and | 1515 | * arr is important since size is the number of elements and |
1508 | * not the size in bytes | 1516 | * not the size in bytes |
1509 | * @param len the number of elements in the existing vector (number | 1517 | * @param len2 the number of elements in the existing vector (number |
1510 | * of elements to copy over), will be updated with the new | 1518 | * of elements to copy over), will be updated with the new |
1511 | * array size | 1519 | * array size |
1512 | 1520 | ||
@@ -1739,7 +1747,7 @@ GNUNET_copy_message (const struct GNUNET_MessageHeader *msg); | |||
1739 | * Set the async scope for the current thread. | 1747 | * Set the async scope for the current thread. |
1740 | * | 1748 | * |
1741 | * @param aid the async scope identifier | 1749 | * @param aid the async scope identifier |
1742 | * @param old_scope[out] location to save the old scope | 1750 | * @param[out] old_scope location to save the old scope |
1743 | */ | 1751 | */ |
1744 | void | 1752 | void |
1745 | GNUNET_async_scope_enter (const struct GNUNET_AsyncScopeId *aid, | 1753 | GNUNET_async_scope_enter (const struct GNUNET_AsyncScopeId *aid, |
@@ -1861,3 +1869,5 @@ enum GNUNET_SCHEDULER_Priority | |||
1861 | #endif | 1869 | #endif |
1862 | 1870 | ||
1863 | #endif /* GNUNET_COMMON_H */ | 1871 | #endif /* GNUNET_COMMON_H */ |
1872 | |||
1873 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_config.h.in b/src/include/gnunet_config.h.in new file mode 100644 index 000000000..5dff759ae --- /dev/null +++ b/src/include/gnunet_config.h.in | |||
@@ -0,0 +1,58 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2022 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your 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 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | #ifndef GNUNET_CONFIG_H | ||
22 | #define GNUNET_CONFIG_H | ||
23 | |||
24 | /** | ||
25 | * @author Martin Schanzenbach | ||
26 | * | ||
27 | * @file | ||
28 | * Convenience header including public (!) information on the | ||
29 | * installed GNUnet configuration. | ||
30 | * | ||
31 | */ | ||
32 | |||
33 | /* The version of GNUnet */ | ||
34 | #define GNUNET_VERSION "@gnunet_version@" | ||
35 | |||
36 | /* Major version */ | ||
37 | #define GNUNET_MAJOR_VERSION @gnunet_major_version@ | ||
38 | |||
39 | /* Micro version */ | ||
40 | #define GNUNET_MINOR_VERSION @gnunet_minor_version@ | ||
41 | |||
42 | /* Mico version */ | ||
43 | #define GNUNET_MICRO_VERSION @gnunet_micro_version@ | ||
44 | |||
45 | /* Set to 1 is this is an experimental build */ | ||
46 | #define GNUNET_EXPERIMENTAL @enable_experimental@ | ||
47 | |||
48 | /* Set to 1 if GnuTLS has DANE support */ | ||
49 | #define GNUNET_CURL_GNUTLS @curl_gnutls@ | ||
50 | |||
51 | /** | ||
52 | * Set to 1 if file-sharing meta data parsing is built with | ||
53 | * libextractor, which means that callers to the API must use also use | ||
54 | * libextractor. | ||
55 | */ | ||
56 | #define GNUNET_FS_EXTRACTOR_ENABLED @extractor@ | ||
57 | |||
58 | #endif | ||
diff --git a/src/include/gnunet_configuration_lib.h b/src/include/gnunet_configuration_lib.h index bc862f54f..3b9be5849 100644 --- a/src/include/gnunet_configuration_lib.h +++ b/src/include/gnunet_configuration_lib.h | |||
@@ -19,6 +19,10 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup libgnunetutil | ||
23 | * Multi-function utilities library for GNUnet programs | ||
24 | * @{ | ||
25 | * | ||
22 | * @author Christian Grothoff | 26 | * @author Christian Grothoff |
23 | * | 27 | * |
24 | * @file | 28 | * @file |
@@ -31,6 +35,7 @@ | |||
31 | #ifndef GNUNET_CONFIGURATION_LIB_H | 35 | #ifndef GNUNET_CONFIGURATION_LIB_H |
32 | #define GNUNET_CONFIGURATION_LIB_H | 36 | #define GNUNET_CONFIGURATION_LIB_H |
33 | 37 | ||
38 | |||
34 | #include "gnunet_time_lib.h" | 39 | #include "gnunet_time_lib.h" |
35 | 40 | ||
36 | #ifdef __cplusplus | 41 | #ifdef __cplusplus |
@@ -170,7 +175,7 @@ GNUNET_CONFIGURATION_serialize_diagnostics ( | |||
170 | * @param mem the memory block of serialized configuration | 175 | * @param mem the memory block of serialized configuration |
171 | * @param size the size of the memory block | 176 | * @param size the size of the memory block |
172 | * @param source_filename source filename, will be used | 177 | * @param source_filename source filename, will be used |
173 | * to resolve relative @INLINE@ statements | 178 | * to resolve relative \@INLINE\@ statements |
174 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 179 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
175 | */ | 180 | */ |
176 | enum GNUNET_GenericReturnValue | 181 | enum GNUNET_GenericReturnValue |
@@ -795,3 +800,5 @@ GNUNET_CONFIGURATION_config_tool_run ( | |||
795 | #endif | 800 | #endif |
796 | 801 | ||
797 | /** @} */ /* end of group configuration */ | 802 | /** @} */ /* end of group configuration */ |
803 | |||
804 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_consensus_service.h b/src/include/gnunet_consensus_service.h index 9387aa095..47a928d9c 100644 --- a/src/include/gnunet_consensus_service.h +++ b/src/include/gnunet_consensus_service.h | |||
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup Sets | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Florian Dold | 25 | * @author Florian Dold |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
@@ -40,6 +43,7 @@ extern "C" | |||
40 | #endif | 43 | #endif |
41 | #endif | 44 | #endif |
42 | 45 | ||
46 | |||
43 | #include "gnunet_common.h" | 47 | #include "gnunet_common.h" |
44 | #include "gnunet_time_lib.h" | 48 | #include "gnunet_time_lib.h" |
45 | #include "gnunet_configuration_lib.h" | 49 | #include "gnunet_configuration_lib.h" |
@@ -78,8 +82,8 @@ struct GNUNET_CONSENSUS_Handle; | |||
78 | * Create a consensus session. The set being reconciled is initially | 82 | * Create a consensus session. The set being reconciled is initially |
79 | * empty. | 83 | * empty. |
80 | * | 84 | * |
81 | * @param cfg | 85 | * @param cfg configuration to use for connecting to the consensus service |
82 | * @param num_peers | 86 | * @param num_peers number of peers in the peers array |
83 | * @param peers array of peers participating in this consensus session | 87 | * @param peers array of peers participating in this consensus session |
84 | * Inclusion of the local peer is optional. | 88 | * Inclusion of the local peer is optional. |
85 | * @param session_id session identifier | 89 | * @param session_id session identifier |
@@ -180,3 +184,5 @@ GNUNET_CONSENSUS_destroy (struct GNUNET_CONSENSUS_Handle *consensus); | |||
180 | #endif | 184 | #endif |
181 | 185 | ||
182 | /** @} */ /* end of group */ | 186 | /** @} */ /* end of group */ |
187 | |||
188 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_container_lib.h b/src/include/gnunet_container_lib.h index ae6c34f2b..8f36f1c61 100644 --- a/src/include/gnunet_container_lib.h +++ b/src/include/gnunet_container_lib.h | |||
@@ -19,35 +19,57 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup libgnunetutil | ||
23 | * Multi-function utilities library for GNUnet programs | ||
24 | * @{ | ||
25 | * | ||
22 | * @author Christian Grothoff | 26 | * @author Christian Grothoff |
23 | * @author Nils Durner | 27 | * @author Nils Durner |
24 | * | 28 | * |
25 | * @file | 29 | * @file |
26 | * Container classes for GNUnet | 30 | * Container classes for GNUnet |
27 | * | 31 | * |
28 | * @defgroup hashmap Container library: MultiHashMap | 32 | * @addtogroup container |
33 | * Common data structures in GNUnet programs | ||
34 | * @{ | ||
35 | * | ||
36 | * @defgroup hashmap MultiHashMap | ||
29 | * Hash map with multiple values per key. | 37 | * Hash map with multiple values per key. |
30 | * | 38 | * |
31 | * @see [Documentation](https://gnunet.org/util_multihashmap) | 39 | * @see [Documentation](https://gnunet.org/util_multihashmap) |
32 | * | 40 | * |
33 | * @defgroup heap Container library: Heap | 41 | * @defgroup heap Heap |
34 | * Min- or max-heap with arbitrary element removal | 42 | * Min- or max-heap with arbitrary element removal |
35 | * | 43 | * |
36 | * @defgroup bloomfilter Container library: Bloom filter | 44 | * @defgroup bloomfilter Bloom filter |
37 | * Probabilistic set tests | 45 | * Probabilistic set tests |
38 | * | 46 | * |
39 | * @defgroup dll Container library: Doubly-linked list | 47 | * @defgroup dll Doubly-linked list |
40 | * | 48 | * |
41 | * @see [Documentation](https://gnunet.org/mdll-api) | 49 | * @see [Documentation](https://gnunet.org/mdll-api) |
42 | * | 50 | * |
43 | * @defgroup metadata Container library: Metadata | 51 | * |
44 | * GNU libextractor key-value pairs | 52 | * @} |
45 | */ | 53 | */ |
46 | 54 | ||
55 | #include "gnunet_common.h" | ||
56 | #if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) | ||
57 | #error "Only <gnunet_util_lib.h> can be included directly." | ||
58 | #endif | ||
59 | |||
47 | #ifndef GNUNET_CONTAINER_LIB_H | 60 | #ifndef GNUNET_CONTAINER_LIB_H |
48 | #define GNUNET_CONTAINER_LIB_H | 61 | #define GNUNET_CONTAINER_LIB_H |
49 | 62 | ||
63 | #ifdef __cplusplus | ||
64 | extern "C" { | ||
65 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
66 | } | ||
67 | #endif | ||
68 | #endif | ||
69 | |||
70 | |||
50 | /* add error and config prototypes */ | 71 | /* add error and config prototypes */ |
72 | |||
51 | #include "gnunet_crypto_lib.h" | 73 | #include "gnunet_crypto_lib.h" |
52 | 74 | ||
53 | 75 | ||
@@ -87,114 +109,6 @@ char * | |||
87 | GNUNET_decompress (const char *input, size_t input_size, size_t output_size); | 109 | GNUNET_decompress (const char *input, size_t input_size, size_t output_size); |
88 | 110 | ||
89 | 111 | ||
90 | #if HAVE_EXTRACTOR_H | ||
91 | |||
92 | #include <extractor.h> | ||
93 | |||
94 | #else | ||
95 | |||
96 | /* definitions from extractor.h we need for the build */ | ||
97 | |||
98 | /** | ||
99 | * Enumeration defining various sources of keywords. See also | ||
100 | * http://dublincore.org/documents/1998/09/dces/ | ||
101 | */ | ||
102 | enum EXTRACTOR_MetaType | ||
103 | { | ||
104 | EXTRACTOR_METATYPE_RESERVED = 0, | ||
105 | EXTRACTOR_METATYPE_MIMETYPE = 1, | ||
106 | EXTRACTOR_METATYPE_FILENAME = 2, | ||
107 | EXTRACTOR_METATYPE_COMMENT = 3, | ||
108 | EXTRACTOR_METATYPE_TITLE = 4, | ||
109 | EXTRACTOR_METATYPE_BOOK_TITLE = 5, | ||
110 | EXTRACTOR_METATYPE_JOURNAL_NAME = 8, | ||
111 | EXTRACTOR_METATYPE_AUTHOR_NAME = 13, | ||
112 | EXTRACTOR_METATYPE_PUBLICATION_DATE = 24, | ||
113 | EXTRACTOR_METATYPE_URL = 29, | ||
114 | EXTRACTOR_METATYPE_URI = 30, | ||
115 | EXTRACTOR_METATYPE_ISRC = 31, | ||
116 | EXTRACTOR_METATYPE_UNKNOWN = 45, | ||
117 | EXTRACTOR_METATYPE_DESCRIPTION = 46, | ||
118 | EXTRACTOR_METATYPE_KEYWORDS = 49, | ||
119 | EXTRACTOR_METATYPE_SUBJECT = 52, | ||
120 | EXTRACTOR_METATYPE_PACKAGE_NAME = 69, | ||
121 | EXTRACTOR_METATYPE_THUMBNAIL = 114, | ||
122 | EXTRACTOR_METATYPE_ALBUM = 129, | ||
123 | EXTRACTOR_METATYPE_ARTIST = 130, | ||
124 | EXTRACTOR_METATYPE_ORIGINAL_TITLE = 162, | ||
125 | EXTRACTOR_METATYPE_GNUNET_FULL_DATA = 174, | ||
126 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME = 180, | ||
127 | }; | ||
128 | |||
129 | /** | ||
130 | * Format in which the extracted meta data is presented. | ||
131 | */ | ||
132 | enum EXTRACTOR_MetaFormat | ||
133 | { | ||
134 | /** | ||
135 | * Format is unknown. | ||
136 | */ | ||
137 | EXTRACTOR_METAFORMAT_UNKNOWN = 0, | ||
138 | |||
139 | /** | ||
140 | * 0-terminated, UTF-8 encoded string. "data_len" | ||
141 | * is strlen(data)+1. | ||
142 | */ | ||
143 | EXTRACTOR_METAFORMAT_UTF8 = 1, | ||
144 | |||
145 | /** | ||
146 | * Some kind of binary format, see given Mime type. | ||
147 | */ | ||
148 | EXTRACTOR_METAFORMAT_BINARY = 2, | ||
149 | |||
150 | /** | ||
151 | * 0-terminated string. The specific encoding is unknown. | ||
152 | * "data_len" is strlen (data)+1. | ||
153 | */ | ||
154 | EXTRACTOR_METAFORMAT_C_STRING = 3 | ||
155 | }; | ||
156 | |||
157 | |||
158 | /** | ||
159 | * Type of a function that libextractor calls for each | ||
160 | * meta data item found. | ||
161 | * | ||
162 | * @param cls closure (user-defined) | ||
163 | * @param plugin_name name of the plugin that produced this value; | ||
164 | * special values can be used (e.g. '<zlib>' for zlib being | ||
165 | * used in the main libextractor library and yielding | ||
166 | * meta data). | ||
167 | * @param type libextractor-type describing the meta data | ||
168 | * @param format basic format information about @a data | ||
169 | * @param data_mime_type mime-type of @a data (not of the original file); | ||
170 | * can be NULL (if mime-type is not known) | ||
171 | * @param data actual meta-data found | ||
172 | * @param data_len number of bytes in @a data | ||
173 | * @return 0 to continue extracting, 1 to abort | ||
174 | */ | ||
175 | typedef int (*EXTRACTOR_MetaDataProcessor) (void *cls, | ||
176 | const char *plugin_name, | ||
177 | enum EXTRACTOR_MetaType type, | ||
178 | enum EXTRACTOR_MetaFormat format, | ||
179 | const char *data_mime_type, | ||
180 | const char *data, | ||
181 | size_t data_len); | ||
182 | |||
183 | #endif | ||
184 | |||
185 | #ifndef EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME | ||
186 | /* hack for LE < 0.6.3 */ | ||
187 | #define EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME 180 | ||
188 | #endif | ||
189 | |||
190 | #ifdef __cplusplus | ||
191 | extern "C" { | ||
192 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
193 | } | ||
194 | #endif | ||
195 | #endif | ||
196 | |||
197 | |||
198 | /* ******************* bloomfilter ***************** */ | 112 | /* ******************* bloomfilter ***************** */ |
199 | 113 | ||
200 | /** | 114 | /** |
@@ -264,7 +178,7 @@ GNUNET_CONTAINER_bloomfilter_init (const char *data, | |||
264 | * @param size the size of the given @a data array | 178 | * @param size the size of the given @a data array |
265 | * @return #GNUNET_SYSERR if the data array of the wrong size | 179 | * @return #GNUNET_SYSERR if the data array of the wrong size |
266 | */ | 180 | */ |
267 | int | 181 | enum GNUNET_GenericReturnValue |
268 | GNUNET_CONTAINER_bloomfilter_get_raw_data ( | 182 | GNUNET_CONTAINER_bloomfilter_get_raw_data ( |
269 | const struct GNUNET_CONTAINER_BloomFilter *bf, | 183 | const struct GNUNET_CONTAINER_BloomFilter *bf, |
270 | char *data, | 184 | char *data, |
@@ -378,7 +292,7 @@ GNUNET_CONTAINER_bloomfilter_clear (struct GNUNET_CONTAINER_BloomFilter *bf); | |||
378 | * @param size size of @a data | 292 | * @param size size of @a data |
379 | * @return #GNUNET_OK on success | 293 | * @return #GNUNET_OK on success |
380 | */ | 294 | */ |
381 | int | 295 | enum GNUNET_GenericReturnValue |
382 | GNUNET_CONTAINER_bloomfilter_or (struct GNUNET_CONTAINER_BloomFilter *bf, | 296 | GNUNET_CONTAINER_bloomfilter_or (struct GNUNET_CONTAINER_BloomFilter *bf, |
383 | const char *data, | 297 | const char *data, |
384 | size_t size); | 298 | size_t size); |
@@ -394,7 +308,7 @@ GNUNET_CONTAINER_bloomfilter_or (struct GNUNET_CONTAINER_BloomFilter *bf, | |||
394 | * @param to_or the bloomfilter to or-in | 308 | * @param to_or the bloomfilter to or-in |
395 | * @return #GNUNET_OK on success | 309 | * @return #GNUNET_OK on success |
396 | */ | 310 | */ |
397 | int | 311 | enum GNUNET_GenericReturnValue |
398 | GNUNET_CONTAINER_bloomfilter_or2 ( | 312 | GNUNET_CONTAINER_bloomfilter_or2 ( |
399 | struct GNUNET_CONTAINER_BloomFilter *bf, | 313 | struct GNUNET_CONTAINER_BloomFilter *bf, |
400 | const struct GNUNET_CONTAINER_BloomFilter *to_or); | 314 | const struct GNUNET_CONTAINER_BloomFilter *to_or); |
@@ -420,285 +334,6 @@ GNUNET_CONTAINER_bloomfilter_resize (struct GNUNET_CONTAINER_BloomFilter *bf, | |||
420 | unsigned int k); | 334 | unsigned int k); |
421 | 335 | ||
422 | 336 | ||
423 | /* ****************** metadata ******************* */ | ||
424 | |||
425 | /** | ||
426 | * @ingroup metadata | ||
427 | * Meta data to associate with a file, directory or namespace. | ||
428 | */ | ||
429 | struct GNUNET_CONTAINER_MetaData; | ||
430 | |||
431 | |||
432 | /** | ||
433 | * @ingroup metadata | ||
434 | * Create a fresh meta data container. | ||
435 | * | ||
436 | * @return empty meta-data container | ||
437 | */ | ||
438 | struct GNUNET_CONTAINER_MetaData * | ||
439 | GNUNET_CONTAINER_meta_data_create (void); | ||
440 | |||
441 | |||
442 | /** | ||
443 | * @ingroup metadata | ||
444 | * Duplicate a MetaData token. | ||
445 | * | ||
446 | * @param md what to duplicate | ||
447 | * @return duplicate meta-data container | ||
448 | */ | ||
449 | struct GNUNET_CONTAINER_MetaData * | ||
450 | GNUNET_CONTAINER_meta_data_duplicate ( | ||
451 | const struct GNUNET_CONTAINER_MetaData *md); | ||
452 | |||
453 | |||
454 | /** | ||
455 | * @ingroup metadata | ||
456 | * Free meta data. | ||
457 | * | ||
458 | * @param md what to free | ||
459 | */ | ||
460 | void | ||
461 | GNUNET_CONTAINER_meta_data_destroy (struct GNUNET_CONTAINER_MetaData *md); | ||
462 | |||
463 | |||
464 | /** | ||
465 | * @ingroup metadata | ||
466 | * Test if two MDs are equal. We consider them equal if | ||
467 | * the meta types, formats and content match (we do not | ||
468 | * include the mime types and plugins names in this | ||
469 | * consideration). | ||
470 | * | ||
471 | * @param md1 first value to check | ||
472 | * @param md2 other value to check | ||
473 | * @return #GNUNET_YES if they are equal | ||
474 | */ | ||
475 | int | ||
476 | GNUNET_CONTAINER_meta_data_test_equal ( | ||
477 | const struct GNUNET_CONTAINER_MetaData *md1, | ||
478 | const struct GNUNET_CONTAINER_MetaData *md2); | ||
479 | |||
480 | |||
481 | /** | ||
482 | * @ingroup metadata | ||
483 | * Extend metadata. | ||
484 | * | ||
485 | * @param md metadata to extend | ||
486 | * @param plugin_name name of the plugin that produced this value; | ||
487 | * special values can be used (e.g. '<zlib>' for zlib being | ||
488 | * used in the main libextractor library and yielding | ||
489 | * meta data). | ||
490 | * @param type libextractor-type describing the meta data | ||
491 | * @param format basic format information about data | ||
492 | * @param data_mime_type mime-type of data (not of the original file); | ||
493 | * can be NULL (if mime-type is not known) | ||
494 | * @param data actual meta-data found | ||
495 | * @param data_size number of bytes in data | ||
496 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if this entry already exists | ||
497 | * data_mime_type and plugin_name are not considered for "exists" checks | ||
498 | */ | ||
499 | int | ||
500 | GNUNET_CONTAINER_meta_data_insert (struct GNUNET_CONTAINER_MetaData *md, | ||
501 | const char *plugin_name, | ||
502 | enum EXTRACTOR_MetaType type, | ||
503 | enum EXTRACTOR_MetaFormat format, | ||
504 | const char *data_mime_type, | ||
505 | const char *data, | ||
506 | size_t data_size); | ||
507 | |||
508 | |||
509 | /** | ||
510 | * @ingroup metadata | ||
511 | * Extend metadata. Merges the meta data from the second argument | ||
512 | * into the first, discarding duplicate key-value pairs. | ||
513 | * | ||
514 | * @param md metadata to extend | ||
515 | * @param in metadata to merge | ||
516 | */ | ||
517 | void | ||
518 | GNUNET_CONTAINER_meta_data_merge (struct GNUNET_CONTAINER_MetaData *md, | ||
519 | const struct GNUNET_CONTAINER_MetaData *in); | ||
520 | |||
521 | |||
522 | /** | ||
523 | * @ingroup metadata | ||
524 | * Remove an item. | ||
525 | * | ||
526 | * @param md metadata to manipulate | ||
527 | * @param type type of the item to remove | ||
528 | * @param data specific value to remove, NULL to remove all | ||
529 | * entries of the given type | ||
530 | * @param data_size number of bytes in data | ||
531 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the item does not exist in md | ||
532 | */ | ||
533 | int | ||
534 | GNUNET_CONTAINER_meta_data_delete (struct GNUNET_CONTAINER_MetaData *md, | ||
535 | enum EXTRACTOR_MetaType type, | ||
536 | const char *data, | ||
537 | size_t data_size); | ||
538 | |||
539 | |||
540 | /** | ||
541 | * @ingroup metadata | ||
542 | * Remove all items in the container. | ||
543 | * | ||
544 | * @param md metadata to manipulate | ||
545 | */ | ||
546 | void | ||
547 | GNUNET_CONTAINER_meta_data_clear (struct GNUNET_CONTAINER_MetaData *md); | ||
548 | |||
549 | |||
550 | /** | ||
551 | * @ingroup metadata | ||
552 | * Add the current time as the publication date | ||
553 | * to the meta-data. | ||
554 | * | ||
555 | * @param md metadata to modify | ||
556 | */ | ||
557 | void | ||
558 | GNUNET_CONTAINER_meta_data_add_publication_date ( | ||
559 | struct GNUNET_CONTAINER_MetaData *md); | ||
560 | |||
561 | |||
562 | /** | ||
563 | * @ingroup metadata | ||
564 | * Iterate over MD entries. | ||
565 | * | ||
566 | * @param md metadata to inspect | ||
567 | * @param iter function to call on each entry, return 0 to continue to iterate | ||
568 | * and 1 to abort iteration in this function (GNU libextractor API!) | ||
569 | * @param iter_cls closure for @a iter | ||
570 | * @return number of entries | ||
571 | */ | ||
572 | int | ||
573 | GNUNET_CONTAINER_meta_data_iterate (const struct GNUNET_CONTAINER_MetaData *md, | ||
574 | EXTRACTOR_MetaDataProcessor iter, | ||
575 | void *iter_cls); | ||
576 | |||
577 | |||
578 | /** | ||
579 | * @ingroup metadata | ||
580 | * Get the first MD entry of the given type. Caller | ||
581 | * is responsible for freeing the return value. | ||
582 | * Also, only meta data items that are strings (0-terminated) | ||
583 | * are returned by this function. | ||
584 | * | ||
585 | * @param md metadata to inspect | ||
586 | * @param type type to look for | ||
587 | * @return NULL if no entry was found | ||
588 | */ | ||
589 | char * | ||
590 | GNUNET_CONTAINER_meta_data_get_by_type ( | ||
591 | const struct GNUNET_CONTAINER_MetaData *md, | ||
592 | enum EXTRACTOR_MetaType type); | ||
593 | |||
594 | |||
595 | /** | ||
596 | * @ingroup metadata | ||
597 | * Get the first matching MD entry of the given types. Caller is | ||
598 | * responsible for freeing the return value. Also, only meta data | ||
599 | * items that are strings (0-terminated) are returned by this | ||
600 | * function. | ||
601 | * | ||
602 | * @param md metadata to inspect | ||
603 | * @param ... -1-terminated list of types | ||
604 | * @return NULL if we do not have any such entry, | ||
605 | * otherwise client is responsible for freeing the value! | ||
606 | */ | ||
607 | char * | ||
608 | GNUNET_CONTAINER_meta_data_get_first_by_types ( | ||
609 | const struct GNUNET_CONTAINER_MetaData *md, | ||
610 | ...); | ||
611 | |||
612 | /** | ||
613 | * @ingroup metadata | ||
614 | * Get a thumbnail from the meta-data (if present). Only matches meta | ||
615 | * data with mime type "image" and binary format. | ||
616 | * | ||
617 | * @param md metadata to inspect | ||
618 | * @param thumb will be set to the thumbnail data. Must be | ||
619 | * freed by the caller! | ||
620 | * @return number of bytes in thumbnail, 0 if not available | ||
621 | */ | ||
622 | size_t | ||
623 | GNUNET_CONTAINER_meta_data_get_thumbnail ( | ||
624 | const struct GNUNET_CONTAINER_MetaData *md, | ||
625 | unsigned char **thumb); | ||
626 | |||
627 | |||
628 | /** | ||
629 | * @ingroup metadata | ||
630 | * Options for metadata serialization. | ||
631 | */ | ||
632 | enum GNUNET_CONTAINER_MetaDataSerializationOptions | ||
633 | { | ||
634 | /** | ||
635 | * @ingroup metadata | ||
636 | * Serialize all of the data. | ||
637 | */ | ||
638 | GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL = 0, | ||
639 | |||
640 | /** | ||
641 | * @ingroup metadata | ||
642 | * If not enough space is available, it is acceptable | ||
643 | * to only serialize some of the metadata. | ||
644 | */ | ||
645 | GNUNET_CONTAINER_META_DATA_SERIALIZE_PART = 1, | ||
646 | |||
647 | /** | ||
648 | * @ingroup metadata | ||
649 | * Speed is of the essence, do not allow compression. | ||
650 | */ | ||
651 | GNUNET_CONTAINER_META_DATA_SERIALIZE_NO_COMPRESS = 2 | ||
652 | }; | ||
653 | |||
654 | |||
655 | /** | ||
656 | * @ingroup metadata | ||
657 | * Serialize meta-data to target. | ||
658 | * | ||
659 | * @param md metadata to serialize | ||
660 | * @param target where to write the serialized metadata; | ||
661 | * *target can be NULL, in which case memory is allocated | ||
662 | * @param max maximum number of bytes available | ||
663 | * @param opt is it ok to just write SOME of the | ||
664 | * meta-data to match the size constraint, | ||
665 | * possibly discarding some data? | ||
666 | * @return number of bytes written on success, | ||
667 | * -1 on error (typically: not enough | ||
668 | * space) | ||
669 | */ | ||
670 | ssize_t | ||
671 | GNUNET_CONTAINER_meta_data_serialize ( | ||
672 | const struct GNUNET_CONTAINER_MetaData *md, | ||
673 | char **target, | ||
674 | size_t max, | ||
675 | enum GNUNET_CONTAINER_MetaDataSerializationOptions opt); | ||
676 | |||
677 | |||
678 | /** | ||
679 | * @ingroup metadata | ||
680 | * Get the size of the full meta-data in serialized form. | ||
681 | * | ||
682 | * @param md metadata to inspect | ||
683 | * @return number of bytes needed for serialization, -1 on error | ||
684 | */ | ||
685 | ssize_t | ||
686 | GNUNET_CONTAINER_meta_data_get_serialized_size ( | ||
687 | const struct GNUNET_CONTAINER_MetaData *md); | ||
688 | |||
689 | |||
690 | /** | ||
691 | * @ingroup metadata | ||
692 | * Deserialize meta-data. Initializes md. | ||
693 | * | ||
694 | * @param input serialized meta-data. | ||
695 | * @param size number of bytes available | ||
696 | * @return MD on success, NULL on error (e.g. | ||
697 | * bad format) | ||
698 | */ | ||
699 | struct GNUNET_CONTAINER_MetaData * | ||
700 | GNUNET_CONTAINER_meta_data_deserialize (const char *input, size_t size); | ||
701 | |||
702 | 337 | ||
703 | /* ******************************* HashMap **************************** */ | 338 | /* ******************************* HashMap **************************** */ |
704 | 339 | ||
@@ -766,7 +401,8 @@ enum GNUNET_CONTAINER_MultiHashMapOption | |||
766 | * iterate, | 401 | * iterate, |
767 | * #GNUNET_NO if not. | 402 | * #GNUNET_NO if not. |
768 | */ | 403 | */ |
769 | typedef int (*GNUNET_CONTAINER_MulitHashMapIteratorCallback) ( | 404 | typedef enum GNUNET_GenericReturnValue |
405 | (*GNUNET_CONTAINER_MultiHashMapIteratorCallback)( | ||
770 | void *cls, | 406 | void *cls, |
771 | const struct GNUNET_HashCode *key, | 407 | const struct GNUNET_HashCode *key, |
772 | void *value); | 408 | void *value); |
@@ -834,7 +470,7 @@ GNUNET_CONTAINER_multihashmap_get ( | |||
834 | * @return #GNUNET_YES on success, #GNUNET_NO if the key-value pair | 470 | * @return #GNUNET_YES on success, #GNUNET_NO if the key-value pair |
835 | * is not in the map | 471 | * is not in the map |
836 | */ | 472 | */ |
837 | int | 473 | enum GNUNET_GenericReturnValue |
838 | GNUNET_CONTAINER_multihashmap_remove (struct GNUNET_CONTAINER_MultiHashMap *map, | 474 | GNUNET_CONTAINER_multihashmap_remove (struct GNUNET_CONTAINER_MultiHashMap *map, |
839 | const struct GNUNET_HashCode *key, | 475 | const struct GNUNET_HashCode *key, |
840 | const void *value); | 476 | const void *value); |
@@ -876,7 +512,7 @@ GNUNET_CONTAINER_multihashmap_clear (struct GNUNET_CONTAINER_MultiHashMap *map); | |||
876 | * @return #GNUNET_YES if such a value exists, | 512 | * @return #GNUNET_YES if such a value exists, |
877 | * #GNUNET_NO if not | 513 | * #GNUNET_NO if not |
878 | */ | 514 | */ |
879 | int | 515 | enum GNUNET_GenericReturnValue |
880 | GNUNET_CONTAINER_multihashmap_contains ( | 516 | GNUNET_CONTAINER_multihashmap_contains ( |
881 | const struct GNUNET_CONTAINER_MultiHashMap *map, | 517 | const struct GNUNET_CONTAINER_MultiHashMap *map, |
882 | const struct GNUNET_HashCode *key); | 518 | const struct GNUNET_HashCode *key); |
@@ -893,7 +529,7 @@ GNUNET_CONTAINER_multihashmap_contains ( | |||
893 | * @return #GNUNET_YES if such a value exists, | 529 | * @return #GNUNET_YES if such a value exists, |
894 | * #GNUNET_NO if not | 530 | * #GNUNET_NO if not |
895 | */ | 531 | */ |
896 | int | 532 | enum GNUNET_GenericReturnValue |
897 | GNUNET_CONTAINER_multihashmap_contains_value ( | 533 | GNUNET_CONTAINER_multihashmap_contains_value ( |
898 | const struct GNUNET_CONTAINER_MultiHashMap *map, | 534 | const struct GNUNET_CONTAINER_MultiHashMap *map, |
899 | const struct GNUNET_HashCode *key, | 535 | const struct GNUNET_HashCode *key, |
@@ -913,7 +549,7 @@ GNUNET_CONTAINER_multihashmap_contains_value ( | |||
913 | * #GNUNET_SYSERR if #GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY was the option and the | 549 | * #GNUNET_SYSERR if #GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY was the option and the |
914 | * value already exists | 550 | * value already exists |
915 | */ | 551 | */ |
916 | int | 552 | enum GNUNET_GenericReturnValue |
917 | GNUNET_CONTAINER_multihashmap_put ( | 553 | GNUNET_CONTAINER_multihashmap_put ( |
918 | struct GNUNET_CONTAINER_MultiHashMap *map, | 554 | struct GNUNET_CONTAINER_MultiHashMap *map, |
919 | const struct GNUNET_HashCode *key, | 555 | const struct GNUNET_HashCode *key, |
@@ -945,7 +581,7 @@ GNUNET_CONTAINER_multihashmap_size ( | |||
945 | int | 581 | int |
946 | GNUNET_CONTAINER_multihashmap_iterate ( | 582 | GNUNET_CONTAINER_multihashmap_iterate ( |
947 | struct GNUNET_CONTAINER_MultiHashMap *map, | 583 | struct GNUNET_CONTAINER_MultiHashMap *map, |
948 | GNUNET_CONTAINER_MulitHashMapIteratorCallback it, | 584 | GNUNET_CONTAINER_MultiHashMapIteratorCallback it, |
949 | void *it_cls); | 585 | void *it_cls); |
950 | 586 | ||
951 | 587 | ||
@@ -982,7 +618,7 @@ GNUNET_CONTAINER_multihashmap_iterator_create ( | |||
982 | * @return #GNUNET_YES we returned an element, | 618 | * @return #GNUNET_YES we returned an element, |
983 | * #GNUNET_NO if we are out of elements | 619 | * #GNUNET_NO if we are out of elements |
984 | */ | 620 | */ |
985 | int | 621 | enum GNUNET_GenericReturnValue |
986 | GNUNET_CONTAINER_multihashmap_iterator_next ( | 622 | GNUNET_CONTAINER_multihashmap_iterator_next ( |
987 | struct GNUNET_CONTAINER_MultiHashMapIterator *iter, | 623 | struct GNUNET_CONTAINER_MultiHashMapIterator *iter, |
988 | struct GNUNET_HashCode *key, | 624 | struct GNUNET_HashCode *key, |
@@ -1011,11 +647,11 @@ GNUNET_CONTAINER_multihashmap_iterator_destroy ( | |||
1011 | * @return the number of key value pairs processed, | 647 | * @return the number of key value pairs processed, |
1012 | * #GNUNET_SYSERR if it aborted iteration | 648 | * #GNUNET_SYSERR if it aborted iteration |
1013 | */ | 649 | */ |
1014 | int | 650 | enum GNUNET_GenericReturnValue |
1015 | GNUNET_CONTAINER_multihashmap_get_multiple ( | 651 | GNUNET_CONTAINER_multihashmap_get_multiple ( |
1016 | struct GNUNET_CONTAINER_MultiHashMap *map, | 652 | struct GNUNET_CONTAINER_MultiHashMap *map, |
1017 | const struct GNUNET_HashCode *key, | 653 | const struct GNUNET_HashCode *key, |
1018 | GNUNET_CONTAINER_MulitHashMapIteratorCallback it, | 654 | GNUNET_CONTAINER_MultiHashMapIteratorCallback it, |
1019 | void *it_cls); | 655 | void *it_cls); |
1020 | 656 | ||
1021 | 657 | ||
@@ -1033,7 +669,7 @@ GNUNET_CONTAINER_multihashmap_get_multiple ( | |||
1033 | unsigned int | 669 | unsigned int |
1034 | GNUNET_CONTAINER_multihashmap_get_random ( | 670 | GNUNET_CONTAINER_multihashmap_get_random ( |
1035 | const struct GNUNET_CONTAINER_MultiHashMap *map, | 671 | const struct GNUNET_CONTAINER_MultiHashMap *map, |
1036 | GNUNET_CONTAINER_MulitHashMapIteratorCallback it, | 672 | GNUNET_CONTAINER_MultiHashMapIteratorCallback it, |
1037 | void *it_cls); | 673 | void *it_cls); |
1038 | 674 | ||
1039 | 675 | ||
@@ -1050,7 +686,8 @@ GNUNET_CONTAINER_multihashmap_get_random ( | |||
1050 | * iterate, | 686 | * iterate, |
1051 | * #GNUNET_NO if not. | 687 | * #GNUNET_NO if not. |
1052 | */ | 688 | */ |
1053 | typedef int (*GNUNET_CONTAINER_PeerMapIterator) ( | 689 | typedef enum GNUNET_GenericReturnValue |
690 | (*GNUNET_CONTAINER_PeerMapIterator)( | ||
1054 | void *cls, | 691 | void *cls, |
1055 | const struct GNUNET_PeerIdentity *key, | 692 | const struct GNUNET_PeerIdentity *key, |
1056 | void *value); | 693 | void *value); |
@@ -1123,7 +760,7 @@ GNUNET_CONTAINER_multipeermap_get ( | |||
1123 | * @return #GNUNET_YES on success, #GNUNET_NO if the key-value pair | 760 | * @return #GNUNET_YES on success, #GNUNET_NO if the key-value pair |
1124 | * is not in the map | 761 | * is not in the map |
1125 | */ | 762 | */ |
1126 | int | 763 | enum GNUNET_GenericReturnValue |
1127 | GNUNET_CONTAINER_multipeermap_remove (struct GNUNET_CONTAINER_MultiPeerMap *map, | 764 | GNUNET_CONTAINER_multipeermap_remove (struct GNUNET_CONTAINER_MultiPeerMap *map, |
1128 | const struct GNUNET_PeerIdentity *key, | 765 | const struct GNUNET_PeerIdentity *key, |
1129 | const void *value); | 766 | const void *value); |
@@ -1153,7 +790,7 @@ GNUNET_CONTAINER_multipeermap_remove_all ( | |||
1153 | * @return #GNUNET_YES if such a value exists, | 790 | * @return #GNUNET_YES if such a value exists, |
1154 | * #GNUNET_NO if not | 791 | * #GNUNET_NO if not |
1155 | */ | 792 | */ |
1156 | int | 793 | enum GNUNET_GenericReturnValue |
1157 | GNUNET_CONTAINER_multipeermap_contains ( | 794 | GNUNET_CONTAINER_multipeermap_contains ( |
1158 | const struct GNUNET_CONTAINER_MultiPeerMap *map, | 795 | const struct GNUNET_CONTAINER_MultiPeerMap *map, |
1159 | const struct GNUNET_PeerIdentity *key); | 796 | const struct GNUNET_PeerIdentity *key); |
@@ -1170,7 +807,7 @@ GNUNET_CONTAINER_multipeermap_contains ( | |||
1170 | * @return #GNUNET_YES if such a value exists, | 807 | * @return #GNUNET_YES if such a value exists, |
1171 | * #GNUNET_NO if not | 808 | * #GNUNET_NO if not |
1172 | */ | 809 | */ |
1173 | int | 810 | enum GNUNET_GenericReturnValue |
1174 | GNUNET_CONTAINER_multipeermap_contains_value ( | 811 | GNUNET_CONTAINER_multipeermap_contains_value ( |
1175 | const struct GNUNET_CONTAINER_MultiPeerMap *map, | 812 | const struct GNUNET_CONTAINER_MultiPeerMap *map, |
1176 | const struct GNUNET_PeerIdentity *key, | 813 | const struct GNUNET_PeerIdentity *key, |
@@ -1250,9 +887,12 @@ GNUNET_CONTAINER_multipeermap_iterator_create ( | |||
1250 | * @ingroup hashmap | 887 | * @ingroup hashmap |
1251 | * Retrieve the next element from the hash map at the iterator's | 888 | * Retrieve the next element from the hash map at the iterator's |
1252 | * position. If there are no elements left, #GNUNET_NO is returned, | 889 | * position. If there are no elements left, #GNUNET_NO is returned, |
1253 | * and @a key and @a value are not modified. This operation is only | 890 | * and @a key and @a value are not modified. |
1254 | * allowed if no elements have been removed from the multihashmap | 891 | * |
1255 | * since the creation of @a iter, and the map has not been destroyed. | 892 | * This operation is only allowed if no elements have been removed |
893 | * from the multihashmap since the creation of @a iter, and the map | ||
894 | * has not been destroyed. | ||
895 | * | ||
1256 | * Adding elements may result in repeating or skipping elements. | 896 | * Adding elements may result in repeating or skipping elements. |
1257 | * | 897 | * |
1258 | * @param iter the iterator to get the next element from | 898 | * @param iter the iterator to get the next element from |
@@ -1261,7 +901,7 @@ GNUNET_CONTAINER_multipeermap_iterator_create ( | |||
1261 | * @return #GNUNET_YES we returned an element, | 901 | * @return #GNUNET_YES we returned an element, |
1262 | * #GNUNET_NO if we are out of elements | 902 | * #GNUNET_NO if we are out of elements |
1263 | */ | 903 | */ |
1264 | int | 904 | enum GNUNET_GenericReturnValue |
1265 | GNUNET_CONTAINER_multipeermap_iterator_next ( | 905 | GNUNET_CONTAINER_multipeermap_iterator_next ( |
1266 | struct GNUNET_CONTAINER_MultiPeerMapIterator *iter, | 906 | struct GNUNET_CONTAINER_MultiPeerMapIterator *iter, |
1267 | struct GNUNET_PeerIdentity *key, | 907 | struct GNUNET_PeerIdentity *key, |
@@ -1329,7 +969,8 @@ GNUNET_CONTAINER_multipeermap_get_random ( | |||
1329 | * iterate, | 969 | * iterate, |
1330 | * #GNUNET_NO if not. | 970 | * #GNUNET_NO if not. |
1331 | */ | 971 | */ |
1332 | typedef int (*GNUNET_CONTAINER_ShortmapIterator) ( | 972 | typedef enum GNUNET_GenericReturnValue |
973 | (*GNUNET_CONTAINER_ShortmapIterator)( | ||
1333 | void *cls, | 974 | void *cls, |
1334 | const struct GNUNET_ShortHashCode *key, | 975 | const struct GNUNET_ShortHashCode *key, |
1335 | void *value); | 976 | void *value); |
@@ -1470,7 +1111,7 @@ GNUNET_CONTAINER_multishortmap_contains_value ( | |||
1470 | * #GNUNET_SYSERR if #GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY was the option and the | 1111 | * #GNUNET_SYSERR if #GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY was the option and the |
1471 | * value already exists | 1112 | * value already exists |
1472 | */ | 1113 | */ |
1473 | int | 1114 | enum GNUNET_GenericReturnValue |
1474 | GNUNET_CONTAINER_multishortmap_put ( | 1115 | GNUNET_CONTAINER_multishortmap_put ( |
1475 | struct GNUNET_CONTAINER_MultiShortmap *map, | 1116 | struct GNUNET_CONTAINER_MultiShortmap *map, |
1476 | const struct GNUNET_ShortHashCode *key, | 1117 | const struct GNUNET_ShortHashCode *key, |
@@ -1543,7 +1184,7 @@ GNUNET_CONTAINER_multishortmap_iterator_create ( | |||
1543 | * @return #GNUNET_YES we returned an element, | 1184 | * @return #GNUNET_YES we returned an element, |
1544 | * #GNUNET_NO if we are out of elements | 1185 | * #GNUNET_NO if we are out of elements |
1545 | */ | 1186 | */ |
1546 | int | 1187 | enum GNUNET_GenericReturnValue |
1547 | GNUNET_CONTAINER_multishortmap_iterator_next ( | 1188 | GNUNET_CONTAINER_multishortmap_iterator_next ( |
1548 | struct GNUNET_CONTAINER_MultiShortmapIterator *iter, | 1189 | struct GNUNET_CONTAINER_MultiShortmapIterator *iter, |
1549 | struct GNUNET_ShortHashCode *key, | 1190 | struct GNUNET_ShortHashCode *key, |
@@ -1612,7 +1253,8 @@ GNUNET_CONTAINER_multishortmap_get_random ( | |||
1612 | * iterate, | 1253 | * iterate, |
1613 | * #GNUNET_NO if not. | 1254 | * #GNUNET_NO if not. |
1614 | */ | 1255 | */ |
1615 | typedef int (*GNUNET_CONTAINER_MultiUuidmapIteratorCallback) ( | 1256 | typedef enum GNUNET_GenericReturnValue |
1257 | (*GNUNET_CONTAINER_MultiUuidmapIteratorCallback)( | ||
1616 | void *cls, | 1258 | void *cls, |
1617 | const struct GNUNET_Uuid *key, | 1259 | const struct GNUNET_Uuid *key, |
1618 | void *value); | 1260 | void *value); |
@@ -1685,7 +1327,7 @@ GNUNET_CONTAINER_multiuuidmap_get ( | |||
1685 | * @return #GNUNET_YES on success, #GNUNET_NO if the key-value pair | 1327 | * @return #GNUNET_YES on success, #GNUNET_NO if the key-value pair |
1686 | * is not in the map | 1328 | * is not in the map |
1687 | */ | 1329 | */ |
1688 | int | 1330 | enum GNUNET_GenericReturnValue |
1689 | GNUNET_CONTAINER_multiuuidmap_remove (struct GNUNET_CONTAINER_MultiUuidmap *map, | 1331 | GNUNET_CONTAINER_multiuuidmap_remove (struct GNUNET_CONTAINER_MultiUuidmap *map, |
1690 | const struct GNUNET_Uuid *key, | 1332 | const struct GNUNET_Uuid *key, |
1691 | const void *value); | 1333 | const void *value); |
@@ -1715,7 +1357,7 @@ GNUNET_CONTAINER_multiuuidmap_remove_all ( | |||
1715 | * @return #GNUNET_YES if such a value exists, | 1357 | * @return #GNUNET_YES if such a value exists, |
1716 | * #GNUNET_NO if not | 1358 | * #GNUNET_NO if not |
1717 | */ | 1359 | */ |
1718 | int | 1360 | enum GNUNET_GenericReturnValue |
1719 | GNUNET_CONTAINER_multiuuidmap_contains ( | 1361 | GNUNET_CONTAINER_multiuuidmap_contains ( |
1720 | const struct GNUNET_CONTAINER_MultiUuidmap *map, | 1362 | const struct GNUNET_CONTAINER_MultiUuidmap *map, |
1721 | const struct GNUNET_Uuid *key); | 1363 | const struct GNUNET_Uuid *key); |
@@ -1732,7 +1374,7 @@ GNUNET_CONTAINER_multiuuidmap_contains ( | |||
1732 | * @return #GNUNET_YES if such a value exists, | 1374 | * @return #GNUNET_YES if such a value exists, |
1733 | * #GNUNET_NO if not | 1375 | * #GNUNET_NO if not |
1734 | */ | 1376 | */ |
1735 | int | 1377 | enum GNUNET_GenericReturnValue |
1736 | GNUNET_CONTAINER_multiuuidmap_contains_value ( | 1378 | GNUNET_CONTAINER_multiuuidmap_contains_value ( |
1737 | const struct GNUNET_CONTAINER_MultiUuidmap *map, | 1379 | const struct GNUNET_CONTAINER_MultiUuidmap *map, |
1738 | const struct GNUNET_Uuid *key, | 1380 | const struct GNUNET_Uuid *key, |
@@ -1752,7 +1394,7 @@ GNUNET_CONTAINER_multiuuidmap_contains_value ( | |||
1752 | * #GNUNET_SYSERR if #GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY was the option and the | 1394 | * #GNUNET_SYSERR if #GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY was the option and the |
1753 | * value already exists | 1395 | * value already exists |
1754 | */ | 1396 | */ |
1755 | int | 1397 | enum GNUNET_GenericReturnValue |
1756 | GNUNET_CONTAINER_multiuuidmap_put ( | 1398 | GNUNET_CONTAINER_multiuuidmap_put ( |
1757 | struct GNUNET_CONTAINER_MultiUuidmap *map, | 1399 | struct GNUNET_CONTAINER_MultiUuidmap *map, |
1758 | const struct GNUNET_Uuid *key, | 1400 | const struct GNUNET_Uuid *key, |
@@ -1782,7 +1424,7 @@ GNUNET_CONTAINER_multiuuidmap_size ( | |||
1782 | * @return the number of key value pairs processed, | 1424 | * @return the number of key value pairs processed, |
1783 | * #GNUNET_SYSERR if it aborted iteration | 1425 | * #GNUNET_SYSERR if it aborted iteration |
1784 | */ | 1426 | */ |
1785 | int | 1427 | enum GNUNET_GenericReturnValue |
1786 | GNUNET_CONTAINER_multiuuidmap_iterate ( | 1428 | GNUNET_CONTAINER_multiuuidmap_iterate ( |
1787 | struct GNUNET_CONTAINER_MultiUuidmap *map, | 1429 | struct GNUNET_CONTAINER_MultiUuidmap *map, |
1788 | GNUNET_CONTAINER_MultiUuidmapIteratorCallback it, | 1430 | GNUNET_CONTAINER_MultiUuidmapIteratorCallback it, |
@@ -1825,7 +1467,7 @@ GNUNET_CONTAINER_multiuuidmap_iterator_create ( | |||
1825 | * @return #GNUNET_YES we returned an element, | 1467 | * @return #GNUNET_YES we returned an element, |
1826 | * #GNUNET_NO if we are out of elements | 1468 | * #GNUNET_NO if we are out of elements |
1827 | */ | 1469 | */ |
1828 | int | 1470 | enum GNUNET_GenericReturnValue |
1829 | GNUNET_CONTAINER_multiuuidmap_iterator_next ( | 1471 | GNUNET_CONTAINER_multiuuidmap_iterator_next ( |
1830 | struct GNUNET_CONTAINER_MultiUuidmapIterator *iter, | 1472 | struct GNUNET_CONTAINER_MultiUuidmapIterator *iter, |
1831 | struct GNUNET_Uuid *key, | 1473 | struct GNUNET_Uuid *key, |
@@ -1908,9 +1550,11 @@ struct GNUNET_CONTAINER_MultiHashMap32Iterator; | |||
1908 | * iterate, | 1550 | * iterate, |
1909 | * #GNUNET_NO if not. | 1551 | * #GNUNET_NO if not. |
1910 | */ | 1552 | */ |
1911 | typedef int (*GNUNET_CONTAINER_MulitHashMapIterator32Callback) (void *cls, | 1553 | typedef enum GNUNET_GenericReturnValue |
1912 | uint32_t key, | 1554 | (*GNUNET_CONTAINER_MultiHashMapIterator32Callback)( |
1913 | void *value); | 1555 | void *cls, |
1556 | uint32_t key, | ||
1557 | void *value); | ||
1914 | 1558 | ||
1915 | 1559 | ||
1916 | /** | 1560 | /** |
@@ -1978,7 +1622,7 @@ GNUNET_CONTAINER_multihashmap32_get ( | |||
1978 | int | 1622 | int |
1979 | GNUNET_CONTAINER_multihashmap32_iterate ( | 1623 | GNUNET_CONTAINER_multihashmap32_iterate ( |
1980 | struct GNUNET_CONTAINER_MultiHashMap32 *map, | 1624 | struct GNUNET_CONTAINER_MultiHashMap32 *map, |
1981 | GNUNET_CONTAINER_MulitHashMapIterator32Callback it, | 1625 | GNUNET_CONTAINER_MultiHashMapIterator32Callback it, |
1982 | void *it_cls); | 1626 | void *it_cls); |
1983 | 1627 | ||
1984 | 1628 | ||
@@ -1994,7 +1638,7 @@ GNUNET_CONTAINER_multihashmap32_iterate ( | |||
1994 | * @return #GNUNET_YES on success, #GNUNET_NO if the key-value pair | 1638 | * @return #GNUNET_YES on success, #GNUNET_NO if the key-value pair |
1995 | * is not in the map | 1639 | * is not in the map |
1996 | */ | 1640 | */ |
1997 | int | 1641 | enum GNUNET_GenericReturnValue |
1998 | GNUNET_CONTAINER_multihashmap32_remove ( | 1642 | GNUNET_CONTAINER_multihashmap32_remove ( |
1999 | struct GNUNET_CONTAINER_MultiHashMap32 *map, | 1643 | struct GNUNET_CONTAINER_MultiHashMap32 *map, |
2000 | uint32_t key, | 1644 | uint32_t key, |
@@ -2026,7 +1670,7 @@ GNUNET_CONTAINER_multihashmap32_remove_all ( | |||
2026 | * @return #GNUNET_YES if such a value exists, | 1670 | * @return #GNUNET_YES if such a value exists, |
2027 | * #GNUNET_NO if not | 1671 | * #GNUNET_NO if not |
2028 | */ | 1672 | */ |
2029 | int | 1673 | enum GNUNET_GenericReturnValue |
2030 | GNUNET_CONTAINER_multihashmap32_contains ( | 1674 | GNUNET_CONTAINER_multihashmap32_contains ( |
2031 | const struct GNUNET_CONTAINER_MultiHashMap32 *map, | 1675 | const struct GNUNET_CONTAINER_MultiHashMap32 *map, |
2032 | uint32_t key); | 1676 | uint32_t key); |
@@ -2043,7 +1687,7 @@ GNUNET_CONTAINER_multihashmap32_contains ( | |||
2043 | * @return #GNUNET_YES if such a value exists, | 1687 | * @return #GNUNET_YES if such a value exists, |
2044 | * #GNUNET_NO if not | 1688 | * #GNUNET_NO if not |
2045 | */ | 1689 | */ |
2046 | int | 1690 | enum GNUNET_GenericReturnValue |
2047 | GNUNET_CONTAINER_multihashmap32_contains_value ( | 1691 | GNUNET_CONTAINER_multihashmap32_contains_value ( |
2048 | const struct GNUNET_CONTAINER_MultiHashMap32 *map, | 1692 | const struct GNUNET_CONTAINER_MultiHashMap32 *map, |
2049 | uint32_t key, | 1693 | uint32_t key, |
@@ -2063,7 +1707,7 @@ GNUNET_CONTAINER_multihashmap32_contains_value ( | |||
2063 | * #GNUNET_SYSERR if #GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY was the option and the | 1707 | * #GNUNET_SYSERR if #GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY was the option and the |
2064 | * value already exists | 1708 | * value already exists |
2065 | */ | 1709 | */ |
2066 | int | 1710 | enum GNUNET_GenericReturnValue |
2067 | GNUNET_CONTAINER_multihashmap32_put ( | 1711 | GNUNET_CONTAINER_multihashmap32_put ( |
2068 | struct GNUNET_CONTAINER_MultiHashMap32 *map, | 1712 | struct GNUNET_CONTAINER_MultiHashMap32 *map, |
2069 | uint32_t key, | 1713 | uint32_t key, |
@@ -2086,7 +1730,7 @@ int | |||
2086 | GNUNET_CONTAINER_multihashmap32_get_multiple ( | 1730 | GNUNET_CONTAINER_multihashmap32_get_multiple ( |
2087 | struct GNUNET_CONTAINER_MultiHashMap32 *map, | 1731 | struct GNUNET_CONTAINER_MultiHashMap32 *map, |
2088 | uint32_t key, | 1732 | uint32_t key, |
2089 | GNUNET_CONTAINER_MulitHashMapIterator32Callback it, | 1733 | GNUNET_CONTAINER_MultiHashMapIterator32Callback it, |
2090 | void *it_cls); | 1734 | void *it_cls); |
2091 | 1735 | ||
2092 | 1736 | ||
@@ -2121,7 +1765,7 @@ GNUNET_CONTAINER_multihashmap32_iterator_create ( | |||
2121 | * @return #GNUNET_YES we returned an element, | 1765 | * @return #GNUNET_YES we returned an element, |
2122 | * #GNUNET_NO if we are out of elements | 1766 | * #GNUNET_NO if we are out of elements |
2123 | */ | 1767 | */ |
2124 | int | 1768 | enum GNUNET_GenericReturnValue |
2125 | GNUNET_CONTAINER_multihashmap32_iterator_next ( | 1769 | GNUNET_CONTAINER_multihashmap32_iterator_next ( |
2126 | struct GNUNET_CONTAINER_MultiHashMap32Iterator *iter, | 1770 | struct GNUNET_CONTAINER_MultiHashMap32Iterator *iter, |
2127 | uint32_t *key, | 1771 | uint32_t *key, |
@@ -2568,7 +2212,7 @@ GNUNET_CONTAINER_heap_peek (const struct GNUNET_CONTAINER_Heap *heap); | |||
2568 | * @return #GNUNET_YES if an element is returned, | 2212 | * @return #GNUNET_YES if an element is returned, |
2569 | * #GNUNET_NO if the heap is empty. | 2213 | * #GNUNET_NO if the heap is empty. |
2570 | */ | 2214 | */ |
2571 | int | 2215 | enum GNUNET_GenericReturnValue |
2572 | GNUNET_CONTAINER_heap_peek2 (const struct GNUNET_CONTAINER_Heap *heap, | 2216 | GNUNET_CONTAINER_heap_peek2 (const struct GNUNET_CONTAINER_Heap *heap, |
2573 | void **element, | 2217 | void **element, |
2574 | GNUNET_CONTAINER_HeapCostType *cost); | 2218 | GNUNET_CONTAINER_HeapCostType *cost); |
@@ -2608,8 +2252,8 @@ GNUNET_CONTAINER_heap_node_get_cost ( | |||
2608 | * @return #GNUNET_YES if we should continue to iterate, | 2252 | * @return #GNUNET_YES if we should continue to iterate, |
2609 | * #GNUNET_NO if not. | 2253 | * #GNUNET_NO if not. |
2610 | */ | 2254 | */ |
2611 | typedef int | 2255 | typedef enum GNUNET_GenericReturnValue |
2612 | (*GNUNET_CONTAINER_HeapIterator) ( | 2256 | (*GNUNET_CONTAINER_HeapIterator)( |
2613 | void *cls, | 2257 | void *cls, |
2614 | struct GNUNET_CONTAINER_HeapNode *node, | 2258 | struct GNUNET_CONTAINER_HeapNode *node, |
2615 | void *element, | 2259 | void *element, |
@@ -2704,4 +2348,7 @@ GNUNET_CONTAINER_heap_update_cost (struct GNUNET_CONTAINER_HeapNode *node, | |||
2704 | 2348 | ||
2705 | /* ifndef GNUNET_CONTAINER_LIB_H */ | 2349 | /* ifndef GNUNET_CONTAINER_LIB_H */ |
2706 | #endif | 2350 | #endif |
2351 | |||
2352 | /** @} */ /* end of group addition */ | ||
2353 | |||
2707 | /* end of gnunet_container_lib.h */ | 2354 | /* end of gnunet_container_lib.h */ |
diff --git a/src/include/gnunet_conversation_service.h b/src/include/gnunet_conversation_service.h index be5a81cfb..7857a49cf 100644 --- a/src/include/gnunet_conversation_service.h +++ b/src/include/gnunet_conversation_service.h | |||
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup conversation_l2 Conversation service and libraries | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Simon Dieterle | 25 | * @author Simon Dieterle |
23 | * @author Andreas Fuchs | 26 | * @author Andreas Fuchs |
24 | * @author Christian Grothoff | 27 | * @author Christian Grothoff |
@@ -58,6 +61,7 @@ extern "C" | |||
58 | #endif | 61 | #endif |
59 | #endif | 62 | #endif |
60 | 63 | ||
64 | |||
61 | #include "gnunet_util_lib.h" | 65 | #include "gnunet_util_lib.h" |
62 | #include "gnunet_identity_service.h" | 66 | #include "gnunet_identity_service.h" |
63 | #include "gnunet_namestore_service.h" | 67 | #include "gnunet_namestore_service.h" |
@@ -147,7 +151,7 @@ typedef void | |||
147 | struct GNUNET_CONVERSATION_Caller * | 151 | struct GNUNET_CONVERSATION_Caller * |
148 | caller, | 152 | caller, |
149 | const struct | 153 | const struct |
150 | GNUNET_IDENTITY_PublicKey *caller_id); | 154 | GNUNET_CRYPTO_PublicKey *caller_id); |
151 | 155 | ||
152 | 156 | ||
153 | /** | 157 | /** |
@@ -438,3 +442,5 @@ GNUNET_CONVERSATION_call_stop (struct GNUNET_CONVERSATION_Call *call); | |||
438 | #endif | 442 | #endif |
439 | 443 | ||
440 | /** @} */ /* end of group */ | 444 | /** @} */ /* end of group */ |
445 | |||
446 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_core_service.h b/src/include/gnunet_core_service.h index 59d9613f8..c3069be81 100644 --- a/src/include/gnunet_core_service.h +++ b/src/include/gnunet_core_service.h | |||
@@ -20,6 +20,9 @@ | |||
20 | /** | 20 | /** |
21 | * @author Christian Grothoff | 21 | * @author Christian Grothoff |
22 | * | 22 | * |
23 | * @addtogroup Backbone | ||
24 | * @{ | ||
25 | * | ||
23 | * @file include/gnunet_core_service.h | 26 | * @file include/gnunet_core_service.h |
24 | * Core service; the main API for encrypted P2P communications | 27 | * Core service; the main API for encrypted P2P communications |
25 | * | 28 | * |
@@ -40,8 +43,8 @@ extern "C" { | |||
40 | #endif | 43 | #endif |
41 | #endif | 44 | #endif |
42 | 45 | ||
46 | |||
43 | #include "gnunet_util_lib.h" | 47 | #include "gnunet_util_lib.h" |
44 | #include "gnunet_transport_service.h" | ||
45 | 48 | ||
46 | /** | 49 | /** |
47 | * Version number of GNUnet-core API. | 50 | * Version number of GNUnet-core API. |
@@ -441,4 +444,6 @@ GNUNET_CORE_mq_create (struct GNUNET_CORE_Handle *h, | |||
441 | 444 | ||
442 | /** @} */ /* end of group core */ | 445 | /** @} */ /* end of group core */ |
443 | 446 | ||
447 | /** @} */ /* end of backbone addition */ | ||
448 | |||
444 | /* end of gnunet_core_service.h */ | 449 | /* end of gnunet_core_service.h */ |
diff --git a/src/include/gnunet_core_testing_lib.h b/src/include/gnunet_core_testing_lib.h new file mode 100644 index 000000000..bf6f416d9 --- /dev/null +++ b/src/include/gnunet_core_testing_lib.h | |||
@@ -0,0 +1,158 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2021-2023 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your 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 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @brief API for cmds working with core sub system provided by libgnunetcoretesting | ||
23 | * @author t3sserakt | ||
24 | */ | ||
25 | #ifndef GNUNET_CORE_TESTING_LIB_H | ||
26 | #define GNUNET_CORE_TESTING_LIB_H | ||
27 | |||
28 | |||
29 | #include "gnunet_util_lib.h" | ||
30 | #include "gnunet_testing_ng_lib.h" | ||
31 | |||
32 | |||
33 | /** | ||
34 | * Struct to store information needed in callbacks. | ||
35 | */ | ||
36 | // FIXME: breaks naming conventions | ||
37 | struct GNUNET_TESTING_ConnectPeersState | ||
38 | { | ||
39 | /** | ||
40 | * Receive callback | ||
41 | */ | ||
42 | struct GNUNET_MQ_MessageHandler *handlers; | ||
43 | |||
44 | /** | ||
45 | * A map with struct GNUNET_MQ_Handle values for each peer this peer | ||
46 | * is connected to. | ||
47 | */ | ||
48 | struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map; | ||
49 | |||
50 | /** | ||
51 | * Handle for transport. | ||
52 | */ | ||
53 | struct GNUNET_TRANSPORT_ApplicationHandle *ah; | ||
54 | |||
55 | /** | ||
56 | * Core handle. | ||
57 | */ | ||
58 | struct GNUNET_TRANSPORT_CoreHandle *th; | ||
59 | |||
60 | /** | ||
61 | * Context for our asynchronous completion. | ||
62 | */ | ||
63 | struct GNUNET_TESTING_AsyncContext ac; | ||
64 | |||
65 | /** | ||
66 | * The testing system of this node. | ||
67 | */ | ||
68 | const struct GNUNET_TESTING_System *tl_system; | ||
69 | |||
70 | // Label of the cmd which started the test system. | ||
71 | const char *create_label; | ||
72 | |||
73 | /** | ||
74 | * Number globally identifying the node. | ||
75 | * | ||
76 | */ | ||
77 | uint32_t num; | ||
78 | |||
79 | /** | ||
80 | * Label of the cmd to start a peer. | ||
81 | * | ||
82 | */ | ||
83 | const char *start_peer_label; | ||
84 | |||
85 | /** | ||
86 | * The topology of the test setup. | ||
87 | */ | ||
88 | struct GNUNET_TESTING_NetjailTopology *topology; | ||
89 | |||
90 | /** | ||
91 | * Connections to other peers. | ||
92 | */ | ||
93 | struct GNUNET_TESTING_NodeConnection *node_connections_head; | ||
94 | |||
95 | struct GNUNET_TESTING_Interpreter *is; | ||
96 | |||
97 | /** | ||
98 | * Number of connections. | ||
99 | */ | ||
100 | unsigned int con_num; | ||
101 | |||
102 | /** | ||
103 | * Number of additional connects this cmd will wait for not triggered by this cmd. | ||
104 | */ | ||
105 | unsigned int additional_connects; | ||
106 | |||
107 | /** | ||
108 | * Number of connections we already have a notification for. | ||
109 | */ | ||
110 | unsigned int con_num_notified; | ||
111 | |||
112 | /** | ||
113 | * Number of additional connects this cmd will wait for not triggered by this cmd we already have a notification for. | ||
114 | */ | ||
115 | unsigned int additional_connects_notified; | ||
116 | |||
117 | /** | ||
118 | * Flag indicating, whether the command is waiting for peers to connect that are configured to connect. | ||
119 | */ | ||
120 | unsigned int wait_for_connect; | ||
121 | }; | ||
122 | |||
123 | |||
124 | /** | ||
125 | * FIXME: document properly! | ||
126 | * Create command | ||
127 | * | ||
128 | * @param label name for command | ||
129 | * @param start_peer_label Label of the cmd to start a peer. | ||
130 | * @param create_label Label of the cmd which started the test system. | ||
131 | * @param num Number globally identifying the node. | ||
132 | * @param topology The topology for the test setup. | ||
133 | * @param additional_connects Number of additional connects this cmd will wait for not triggered by this cmd. | ||
134 | * @return command. | ||
135 | */ | ||
136 | struct GNUNET_TESTING_Command | ||
137 | GNUNET_CORE_cmd_connect_peers ( | ||
138 | const char *label, | ||
139 | const char *start_peer_label, | ||
140 | const char *create_label, | ||
141 | uint32_t num, | ||
142 | struct GNUNET_TESTING_NetjailTopology *topology, | ||
143 | unsigned int additional_connects, | ||
144 | unsigned int wait_for_connect, | ||
145 | struct GNUNET_MQ_MessageHandler *handlers); | ||
146 | |||
147 | |||
148 | /** | ||
149 | * Call #op on all simple traits. | ||
150 | */ | ||
151 | #define GNUNET_CORE_TESTING_SIMPLE_TRAITS(op, prefix) \ | ||
152 | op (prefix, connect_peer_state, const struct GNUNET_TESTING_ConnectPeersState) | ||
153 | |||
154 | GNUNET_CORE_TESTING_SIMPLE_TRAITS (GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT, GNUNET_CORE_TESTING) | ||
155 | |||
156 | |||
157 | |||
158 | #endif | ||
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h index 2737ee0e9..50937324d 100644 --- a/src/include/gnunet_crypto_lib.h +++ b/src/include/gnunet_crypto_lib.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2001-2013 GNUnet e.V. | 3 | Copyright (C) 2001-2023 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -19,6 +19,10 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup libgnunetutil | ||
23 | * Multi-function utilities library for GNUnet programs | ||
24 | * @{ | ||
25 | * | ||
22 | * @file include/gnunet_crypto_lib.h | 26 | * @file include/gnunet_crypto_lib.h |
23 | * @brief cryptographic primitives for GNUnet | 27 | * @brief cryptographic primitives for GNUnet |
24 | * | 28 | * |
@@ -40,6 +44,10 @@ | |||
40 | * @see [Documentation](https://gnunet.org/crypto-api) | 44 | * @see [Documentation](https://gnunet.org/crypto-api) |
41 | */ | 45 | */ |
42 | 46 | ||
47 | #if ! defined (__GNUNET_UTIL_LIB_H_INSIDE__) | ||
48 | #error "Only <gnunet_util_lib.h> can be included directly." | ||
49 | #endif | ||
50 | |||
43 | #ifndef GNUNET_CRYPTO_LIB_H | 51 | #ifndef GNUNET_CRYPTO_LIB_H |
44 | #define GNUNET_CRYPTO_LIB_H | 52 | #define GNUNET_CRYPTO_LIB_H |
45 | 53 | ||
@@ -50,6 +58,7 @@ extern "C" { | |||
50 | #endif | 58 | #endif |
51 | #endif | 59 | #endif |
52 | 60 | ||
61 | |||
53 | #include <stdbool.h> | 62 | #include <stdbool.h> |
54 | #include <sodium.h> | 63 | #include <sodium.h> |
55 | 64 | ||
@@ -58,7 +67,6 @@ extern "C" { | |||
58 | */ | 67 | */ |
59 | struct GNUNET_PeerIdentity; | 68 | struct GNUNET_PeerIdentity; |
60 | 69 | ||
61 | #include "gnunet_common.h" | ||
62 | #include <gcrypt.h> | 70 | #include <gcrypt.h> |
63 | 71 | ||
64 | 72 | ||
@@ -340,6 +348,117 @@ struct GNUNET_CRYPTO_Edx25519Signature | |||
340 | unsigned char s[256 / 8]; | 348 | unsigned char s[256 / 8]; |
341 | }; | 349 | }; |
342 | 350 | ||
351 | /** | ||
352 | * Elligator representative (always for Curve25519) | ||
353 | */ | ||
354 | struct GNUNET_CRYPTO_ElligatorRepresentative | ||
355 | { | ||
356 | /** | ||
357 | * Represents an element of Curve25519 finite field. | ||
358 | * Always smaller than 2 ^ 254 - 10 -> Needs to be serialized into a random-looking byte stream before transmission. | ||
359 | */ | ||
360 | unsigned char r[256 / 8]; | ||
361 | }; | ||
362 | |||
363 | /** | ||
364 | * Key type for the generic public key union | ||
365 | */ | ||
366 | enum GNUNET_CRYPTO_KeyType | ||
367 | { | ||
368 | /** | ||
369 | * The identity type. The value is the same as the | ||
370 | * PKEY record type. | ||
371 | */ | ||
372 | GNUNET_PUBLIC_KEY_TYPE_ECDSA = 65536, | ||
373 | |||
374 | /** | ||
375 | * EDDSA identity. The value is the same as the EDKEY | ||
376 | * record type. | ||
377 | */ | ||
378 | GNUNET_PUBLIC_KEY_TYPE_EDDSA = 65556 | ||
379 | }; | ||
380 | |||
381 | /** | ||
382 | * A private key for an identity as per LSD0001. | ||
383 | * Note that these types are NOT packed and MUST NOT be used in RPC | ||
384 | * messages. Use the respective serialization functions. | ||
385 | */ | ||
386 | struct GNUNET_CRYPTO_PrivateKey | ||
387 | { | ||
388 | /** | ||
389 | * Type of public key. | ||
390 | * Defined by the GNS zone type value. | ||
391 | * In NBO. | ||
392 | */ | ||
393 | uint32_t type; | ||
394 | |||
395 | union | ||
396 | { | ||
397 | /** | ||
398 | * An ECDSA identity key. | ||
399 | */ | ||
400 | struct GNUNET_CRYPTO_EcdsaPrivateKey ecdsa_key; | ||
401 | |||
402 | /** | ||
403 | * AN EdDSA identtiy key | ||
404 | */ | ||
405 | struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_key; | ||
406 | }; | ||
407 | }; | ||
408 | |||
409 | |||
410 | /** | ||
411 | * An identity key as per LSD0001. | ||
412 | */ | ||
413 | struct GNUNET_CRYPTO_PublicKey | ||
414 | { | ||
415 | /** | ||
416 | * Type of public key. | ||
417 | * Defined by the GNS zone type value. | ||
418 | * In NBO. | ||
419 | */ | ||
420 | uint32_t type; | ||
421 | |||
422 | union | ||
423 | { | ||
424 | /** | ||
425 | * An ECDSA identity key. | ||
426 | */ | ||
427 | struct GNUNET_CRYPTO_EcdsaPublicKey ecdsa_key; | ||
428 | |||
429 | /** | ||
430 | * AN EdDSA identtiy key | ||
431 | */ | ||
432 | struct GNUNET_CRYPTO_EddsaPublicKey eddsa_key; | ||
433 | }; | ||
434 | }; | ||
435 | |||
436 | |||
437 | /** | ||
438 | * An identity signature as per LSD0001. | ||
439 | */ | ||
440 | struct GNUNET_CRYPTO_Signature | ||
441 | { | ||
442 | /** | ||
443 | * Type of signature. | ||
444 | * Defined by the GNS zone type value. | ||
445 | * In NBO. | ||
446 | */ | ||
447 | uint32_t type; | ||
448 | |||
449 | union | ||
450 | { | ||
451 | /** | ||
452 | * An ECDSA signature | ||
453 | */ | ||
454 | struct GNUNET_CRYPTO_EcdsaSignature ecdsa_signature; | ||
455 | |||
456 | /** | ||
457 | * AN EdDSA signature | ||
458 | */ | ||
459 | struct GNUNET_CRYPTO_EddsaSignature eddsa_signature; | ||
460 | }; | ||
461 | }; | ||
343 | 462 | ||
344 | /** | 463 | /** |
345 | * @brief type for session keys | 464 | * @brief type for session keys |
@@ -553,17 +672,33 @@ struct GNUNET_CRYPTO_CsSignature | |||
553 | * Schnorr signatures are composed of a scalar s and a curve point | 672 | * Schnorr signatures are composed of a scalar s and a curve point |
554 | */ | 673 | */ |
555 | struct GNUNET_CRYPTO_CsS s_scalar; | 674 | struct GNUNET_CRYPTO_CsS s_scalar; |
675 | |||
676 | /** | ||
677 | * Curve point of the Schnorr signature. | ||
678 | */ | ||
556 | struct GNUNET_CRYPTO_CsRPublic r_point; | 679 | struct GNUNET_CRYPTO_CsRPublic r_point; |
557 | }; | 680 | }; |
558 | 681 | ||
559 | 682 | ||
560 | /** | 683 | /** |
561 | * Nonce | 684 | * Nonce for the session, picked by client, |
685 | * shared with the signer. | ||
686 | */ | ||
687 | struct GNUNET_CRYPTO_CsSessionNonce | ||
688 | { | ||
689 | /*a nonce*/ | ||
690 | unsigned char snonce[256 / 8]; | ||
691 | }; | ||
692 | |||
693 | |||
694 | /** | ||
695 | * Nonce for computing blinding factors. Not | ||
696 | * shared with the signer. | ||
562 | */ | 697 | */ |
563 | struct GNUNET_CRYPTO_CsNonce | 698 | struct GNUNET_CRYPTO_CsBlindingNonce |
564 | { | 699 | { |
565 | /*a nonce*/ | 700 | /*a nonce*/ |
566 | unsigned char nonce[256 / 8]; | 701 | unsigned char bnonce[256 / 8]; |
567 | }; | 702 | }; |
568 | 703 | ||
569 | 704 | ||
@@ -655,7 +790,7 @@ GNUNET_CRYPTO_zero_keys (void *buffer, size_t length); | |||
655 | * Fill block with a random values. | 790 | * Fill block with a random values. |
656 | * | 791 | * |
657 | * @param mode desired quality of the random number | 792 | * @param mode desired quality of the random number |
658 | * @param buffer the buffer to fill | 793 | * @param[out] buffer the buffer to fill |
659 | * @param length buffer length | 794 | * @param length buffer length |
660 | */ | 795 | */ |
661 | void | 796 | void |
@@ -672,7 +807,7 @@ GNUNET_CRYPTO_random_block (enum GNUNET_CRYPTO_Quality mode, | |||
672 | * here is not a completely random number. | 807 | * here is not a completely random number. |
673 | * | 808 | * |
674 | * @param mode desired quality of the random number | 809 | * @param mode desired quality of the random number |
675 | * @param uuid the value to fill | 810 | * @param[out] uuid the value to fill |
676 | */ | 811 | */ |
677 | void | 812 | void |
678 | GNUNET_CRYPTO_random_timeflake (enum GNUNET_CRYPTO_Quality mode, | 813 | GNUNET_CRYPTO_random_timeflake (enum GNUNET_CRYPTO_Quality mode, |
@@ -693,7 +828,7 @@ GNUNET_CRYPTO_random_u32 (enum GNUNET_CRYPTO_Quality mode, uint32_t i); | |||
693 | 828 | ||
694 | /** | 829 | /** |
695 | * @ingroup crypto | 830 | * @ingroup crypto |
696 | * Random on unsigned 64-bit values. | 831 | * Generate a random unsigned 64-bit value. |
697 | * | 832 | * |
698 | * @param mode desired quality of the random number | 833 | * @param mode desired quality of the random number |
699 | * @param max value returned will be in range [0,@a max) (exclusive) | 834 | * @param max value returned will be in range [0,@a max) (exclusive) |
@@ -1427,7 +1562,7 @@ enum GNUNET_GenericReturnValue | |||
1427 | GNUNET_CRYPTO_eddsa_private_key_from_string ( | 1562 | GNUNET_CRYPTO_eddsa_private_key_from_string ( |
1428 | const char *enc, | 1563 | const char *enc, |
1429 | size_t enclen, | 1564 | size_t enclen, |
1430 | struct GNUNET_CRYPTO_EddsaPrivateKey *pub); | 1565 | struct GNUNET_CRYPTO_EddsaPrivateKey *priv); |
1431 | 1566 | ||
1432 | 1567 | ||
1433 | /** | 1568 | /** |
@@ -1554,6 +1689,9 @@ GNUNET_CRYPTO_edx25519_key_create_from_seed ( | |||
1554 | /** | 1689 | /** |
1555 | * @ingroup crypto | 1690 | * @ingroup crypto |
1556 | * Create a new private key. Clear with #GNUNET_CRYPTO_ecdhe_key_clear(). | 1691 | * Create a new private key. Clear with #GNUNET_CRYPTO_ecdhe_key_clear(). |
1692 | * This is X25519 DH (RFC 7748 Section 5) and corresponds to | ||
1693 | * X25519(a,9). | ||
1694 | * See #GNUNET_CRYPTO_ecc_ecdh for the DH function. | ||
1557 | * | 1695 | * |
1558 | * @param[out] pk set to fresh private key; | 1696 | * @param[out] pk set to fresh private key; |
1559 | */ | 1697 | */ |
@@ -1631,12 +1769,49 @@ GNUNET_CRYPTO_eddsa_setup_hostkey (const char *cfg_name); | |||
1631 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the identity | 1769 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the identity |
1632 | * could not be retrieved | 1770 | * could not be retrieved |
1633 | */ | 1771 | */ |
1634 | int | 1772 | enum GNUNET_GenericReturnValue |
1635 | GNUNET_CRYPTO_get_peer_identity (const struct GNUNET_CONFIGURATION_Handle *cfg, | 1773 | GNUNET_CRYPTO_get_peer_identity (const struct GNUNET_CONFIGURATION_Handle *cfg, |
1636 | struct GNUNET_PeerIdentity *dst); | 1774 | struct GNUNET_PeerIdentity *dst); |
1637 | 1775 | ||
1638 | 1776 | ||
1639 | /** | 1777 | /** |
1778 | * @ingroup crypto | ||
1779 | * Sign a given block with a specific purpose using the host's peer identity. | ||
1780 | * | ||
1781 | * @param cfg configuration to use | ||
1782 | * @param purpose what to sign (size, purpose) | ||
1783 | * @param sig where to write the signature | ||
1784 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the identity | ||
1785 | * could not be retrieved | ||
1786 | */ | ||
1787 | enum GNUNET_GenericReturnValue | ||
1788 | GNUNET_CRYPTO_sign_by_peer_identity (const struct | ||
1789 | GNUNET_CONFIGURATION_Handle *cfg, | ||
1790 | const struct | ||
1791 | GNUNET_CRYPTO_EccSignaturePurpose *purpose, | ||
1792 | struct GNUNET_CRYPTO_EddsaSignature *sig); | ||
1793 | |||
1794 | |||
1795 | /** | ||
1796 | * @ingroup crypto | ||
1797 | * Verify a given signature with a peer's identity. | ||
1798 | * | ||
1799 | * @param purpose what is the purpose that the signature should have? | ||
1800 | * @param validate block to validate (size, purpose, data) | ||
1801 | * @param sig signature that is being validated | ||
1802 | * @param identity the peer's identity to verify | ||
1803 | * @return #GNUNET_OK if ok, #GNUNET_SYSERR if invalid | ||
1804 | */ | ||
1805 | enum GNUNET_GenericReturnValue | ||
1806 | GNUNET_CRYPTO_verify_peer_identity (uint32_t purpose, | ||
1807 | const struct | ||
1808 | GNUNET_CRYPTO_EccSignaturePurpose *validate, | ||
1809 | const struct | ||
1810 | GNUNET_CRYPTO_EddsaSignature *sig, | ||
1811 | const struct GNUNET_PeerIdentity *identity); | ||
1812 | |||
1813 | |||
1814 | /** | ||
1640 | * Internal structure used to cache pre-calculated values for DLOG calculation. | 1815 | * Internal structure used to cache pre-calculated values for DLOG calculation. |
1641 | */ | 1816 | */ |
1642 | struct GNUNET_CRYPTO_EccDlogContext; | 1817 | struct GNUNET_CRYPTO_EccDlogContext; |
@@ -1679,7 +1854,7 @@ GNUNET_CRYPTO_ecc_dlog_prepare (unsigned int max, | |||
1679 | * Calculate ECC discrete logarithm for small factors. | 1854 | * Calculate ECC discrete logarithm for small factors. |
1680 | * Opposite of #GNUNET_CRYPTO_ecc_dexp(). | 1855 | * Opposite of #GNUNET_CRYPTO_ecc_dexp(). |
1681 | * | 1856 | * |
1682 | * @param dlc precalculated values, determine range of factors | 1857 | * @param edc precalculated values, determine range of factors |
1683 | * @param input point on the curve to factor | 1858 | * @param input point on the curve to factor |
1684 | * @return INT_MAX if dlog failed, otherwise the factor | 1859 | * @return INT_MAX if dlog failed, otherwise the factor |
1685 | */ | 1860 | */ |
@@ -1802,6 +1977,9 @@ GNUNET_CRYPTO_ecc_scalar_from_int (int64_t val, | |||
1802 | /** | 1977 | /** |
1803 | * @ingroup crypto | 1978 | * @ingroup crypto |
1804 | * Derive key material from a public and a private ECC key. | 1979 | * Derive key material from a public and a private ECC key. |
1980 | * This is X25519 DH (RFC 7748 Section 5) and corresponds to | ||
1981 | * H(X25519(b,X25519(a,9))) where b := priv, pub := X25519(a,9), | ||
1982 | * and a := #GNUNET_CRYPTO_ecdhe_key_create(). | ||
1805 | * | 1983 | * |
1806 | * @param priv private key to use for the ECDH (x) | 1984 | * @param priv private key to use for the ECDH (x) |
1807 | * @param pub public key to use for the ECDH (yG) | 1985 | * @param pub public key to use for the ECDH (yG) |
@@ -1818,6 +1996,10 @@ GNUNET_CRYPTO_ecc_ecdh (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | |||
1818 | * @ingroup crypto | 1996 | * @ingroup crypto |
1819 | * Derive key material from a ECDH public key and a private EdDSA key. | 1997 | * Derive key material from a ECDH public key and a private EdDSA key. |
1820 | * Dual to #GNUNET_CRRYPTO_ecdh_eddsa. | 1998 | * Dual to #GNUNET_CRRYPTO_ecdh_eddsa. |
1999 | * This uses the Ed25519 private seed as X25519 seed. | ||
2000 | * As such, this also is a X25519 DH (see #GNUNET_CRYPTO_ecc_ecdh). | ||
2001 | * NOTE: Whenever you can get away with it, use separate key pairs | ||
2002 | * for signing and encryption (DH)! | ||
1821 | * | 2003 | * |
1822 | * @param priv private key from EdDSA to use for the ECDH (x) | 2004 | * @param priv private key from EdDSA to use for the ECDH (x) |
1823 | * @param pub public key to use for the ECDH (yG) | 2005 | * @param pub public key to use for the ECDH (yG) |
@@ -1829,6 +2011,122 @@ GNUNET_CRYPTO_eddsa_ecdh (const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, | |||
1829 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, | 2011 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, |
1830 | struct GNUNET_HashCode *key_material); | 2012 | struct GNUNET_HashCode *key_material); |
1831 | 2013 | ||
2014 | /** | ||
2015 | * @ingroup crypto | ||
2016 | * Decapsulate a key for a private EdDSA key. | ||
2017 | * Dual to #GNUNET_CRRYPTO_eddsa_kem_encaps. | ||
2018 | * | ||
2019 | * @param priv private key from EdDSA to use for the ECDH (x) | ||
2020 | * @param c the encapsulated key | ||
2021 | * @param key_material where to write the key material H(h(x)yG) | ||
2022 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
2023 | */ | ||
2024 | enum GNUNET_GenericReturnValue | ||
2025 | GNUNET_CRYPTO_eddsa_kem_decaps (const struct | ||
2026 | GNUNET_CRYPTO_EddsaPrivateKey *priv, | ||
2027 | const struct GNUNET_CRYPTO_EcdhePublicKey *c, | ||
2028 | struct GNUNET_HashCode *key_material); | ||
2029 | |||
2030 | /** | ||
2031 | * @ingroup crypto | ||
2032 | * Encapsulate key material for a EdDSA public key. | ||
2033 | * Dual to #GNUNET_CRRYPTO_eddsa_kem_decaps. | ||
2034 | * | ||
2035 | * @param priv private key to use for the ECDH (y) | ||
2036 | * @param c public key from EdDSA to use for the ECDH (X=h(x)G) | ||
2037 | * @param key_material where to write the key material H(yX)=H(h(x)yG) | ||
2038 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
2039 | */ | ||
2040 | enum GNUNET_GenericReturnValue | ||
2041 | GNUNET_CRYPTO_eddsa_kem_encaps (const struct GNUNET_CRYPTO_EddsaPublicKey *pub, | ||
2042 | struct GNUNET_CRYPTO_EcdhePublicKey *c, | ||
2043 | struct GNUNET_HashCode *key_material); | ||
2044 | |||
2045 | /** | ||
2046 | * This is the encapsulated key of our FO-KEM. | ||
2047 | */ | ||
2048 | struct GNUNET_CRYPTO_FoKemC | ||
2049 | { | ||
2050 | /* The output of the FO-OWTF F(x) */ | ||
2051 | struct GNUNET_HashCode y; | ||
2052 | |||
2053 | /* The ephemeral public key from the DH in the KEM */ | ||
2054 | struct GNUNET_CRYPTO_EcdhePublicKey pub; | ||
2055 | }; | ||
2056 | |||
2057 | /** | ||
2058 | * @ingroup crypto | ||
2059 | * Encapsulate key material using a CCA-secure KEM. | ||
2060 | * The KEM is using a OWTF with image oracle constructed from | ||
2061 | * a Fujusaki-Okamoto transformation using ElGamal (DH plus XOR OTP). | ||
2062 | * Dual to #GNUNET_CRRYPTO_eddsa_fo_kem_decaps. | ||
2063 | * | ||
2064 | * @param pub public key to encapsulated for | ||
2065 | * @param[out] c the encapsulation | ||
2066 | * @param[out] key_material the encapsulated key | ||
2067 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
2068 | */ | ||
2069 | enum GNUNET_GenericReturnValue | ||
2070 | GNUNET_CRYPTO_eddsa_fo_kem_encaps ( | ||
2071 | const struct GNUNET_CRYPTO_EddsaPublicKey *pub, | ||
2072 | struct GNUNET_CRYPTO_FoKemC *c, | ||
2073 | struct GNUNET_HashCode *key_material); | ||
2074 | |||
2075 | |||
2076 | /** | ||
2077 | * @ingroup crypto | ||
2078 | * Decapsulate key material using a CCA-secure KEM. | ||
2079 | * The KEM is using a OWTF with image oracle constructed from | ||
2080 | * a Fujusaki-Okamoto transformation using ElGamal (DH plus XOR OTP). | ||
2081 | * Dual to #GNUNET_CRRYPTO_eddsa_fo_kem_encaps. | ||
2082 | * | ||
2083 | * @param priv private key this encapsulation is for | ||
2084 | * @param c the encapsulation | ||
2085 | * @param[out] key_material the encapsulated key | ||
2086 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
2087 | */ | ||
2088 | enum GNUNET_GenericReturnValue | ||
2089 | GNUNET_CRYPTO_eddsa_fo_kem_decaps (const struct | ||
2090 | GNUNET_CRYPTO_EddsaPrivateKey *priv, | ||
2091 | const struct GNUNET_CRYPTO_FoKemC *c, | ||
2092 | struct GNUNET_HashCode *key_material); | ||
2093 | |||
2094 | /** | ||
2095 | * @ingroup crypto | ||
2096 | * Encapsulate key material using a CCA-secure KEM. | ||
2097 | * The KEM is using a OWTF with image oracle constructed from | ||
2098 | * a Fujusaki-Okamoto transformation using ElGamal (DH plus XOR OTP). | ||
2099 | * Dual to #GNUNET_CRRYPTO_eddsa_fo_kem_decaps. | ||
2100 | * | ||
2101 | * @param pub public key to encapsulated for | ||
2102 | * @param[out] c the encapsulation | ||
2103 | * @param[out] key_material the encapsulated key | ||
2104 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
2105 | */ | ||
2106 | enum GNUNET_GenericReturnValue | ||
2107 | GNUNET_CRYPTO_ecdsa_fo_kem_encaps (const struct | ||
2108 | GNUNET_CRYPTO_EcdsaPublicKey *pub, | ||
2109 | struct GNUNET_CRYPTO_FoKemC *c, | ||
2110 | struct GNUNET_HashCode *key_material); | ||
2111 | |||
2112 | |||
2113 | /** | ||
2114 | * @ingroup crypto | ||
2115 | * Decapsulate key material using a CCA-secure KEM. | ||
2116 | * The KEM is using a OWTF with image oracle constructed from | ||
2117 | * a Fujusaki-Okamoto transformation using ElGamal (DH plus XOR OTP). | ||
2118 | * Dual to #GNUNET_CRRYPTO_eddsa_fo_kem_encaps. | ||
2119 | * | ||
2120 | * @param priv private key this encapsulation is for | ||
2121 | * @param c the encapsulation | ||
2122 | * @param[out] key_material the encapsulated key | ||
2123 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
2124 | */ | ||
2125 | enum GNUNET_GenericReturnValue | ||
2126 | GNUNET_CRYPTO_ecdsa_fo_kem_decaps (const struct | ||
2127 | GNUNET_CRYPTO_EcdsaPrivateKey *priv, | ||
2128 | struct GNUNET_CRYPTO_FoKemC *c, | ||
2129 | struct GNUNET_HashCode *key_material); | ||
1832 | 2130 | ||
1833 | /** | 2131 | /** |
1834 | * @ingroup crypto | 2132 | * @ingroup crypto |
@@ -1850,6 +2148,10 @@ GNUNET_CRYPTO_ecdsa_ecdh (const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, | |||
1850 | * @ingroup crypto | 2148 | * @ingroup crypto |
1851 | * Derive key material from a EdDSA public key and a private ECDH key. | 2149 | * Derive key material from a EdDSA public key and a private ECDH key. |
1852 | * Dual to #GNUNET_CRRYPTO_eddsa_ecdh. | 2150 | * Dual to #GNUNET_CRRYPTO_eddsa_ecdh. |
2151 | * This converts the Edwards25519 public key @a pub to a Curve25519 | ||
2152 | * public key before computing a X25519 DH (see #GNUNET_CRYPTO_ecc_ecdh). | ||
2153 | * NOTE: Whenever you can get away with it, use separate key pairs | ||
2154 | * for signing and encryption (DH)! | ||
1853 | * | 2155 | * |
1854 | * @param priv private key to use for the ECDH (y) | 2156 | * @param priv private key to use for the ECDH (y) |
1855 | * @param pub public key from EdDSA to use for the ECDH (X=h(x)G) | 2157 | * @param pub public key from EdDSA to use for the ECDH (X=h(x)G) |
@@ -1861,6 +2163,7 @@ GNUNET_CRYPTO_ecdh_eddsa (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | |||
1861 | const struct GNUNET_CRYPTO_EddsaPublicKey *pub, | 2163 | const struct GNUNET_CRYPTO_EddsaPublicKey *pub, |
1862 | struct GNUNET_HashCode *key_material); | 2164 | struct GNUNET_HashCode *key_material); |
1863 | 2165 | ||
2166 | |||
1864 | /** | 2167 | /** |
1865 | * @ingroup crypto | 2168 | * @ingroup crypto |
1866 | * Derive key material from a EcDSA public key and a private ECDH key. | 2169 | * Derive key material from a EcDSA public key and a private ECDH key. |
@@ -1945,6 +2248,21 @@ GNUNET_CRYPTO_ecdsa_sign_ ( | |||
1945 | const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, | 2248 | const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, |
1946 | struct GNUNET_CRYPTO_EcdsaSignature *sig); | 2249 | struct GNUNET_CRYPTO_EcdsaSignature *sig); |
1947 | 2250 | ||
2251 | /** | ||
2252 | * @brief | ||
2253 | * | ||
2254 | * @param priv | ||
2255 | * @param data | ||
2256 | * @param size | ||
2257 | * @param sig | ||
2258 | * @return enum GNUNET_GenericReturnValue | ||
2259 | */ | ||
2260 | enum GNUNET_GenericReturnValue | ||
2261 | GNUNET_CRYPTO_eddsa_sign_raw ( | ||
2262 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, | ||
2263 | void *data, | ||
2264 | size_t size, | ||
2265 | struct GNUNET_CRYPTO_EddsaSignature *sig); | ||
1948 | 2266 | ||
1949 | /** | 2267 | /** |
1950 | * @ingroup crypto | 2268 | * @ingroup crypto |
@@ -2220,7 +2538,7 @@ GNUNET_CRYPTO_ecdsa_public_key_derive ( | |||
2220 | * @param label label to use for key deriviation | 2538 | * @param label label to use for key deriviation |
2221 | * @param context additional context to use for HKDF of 'h'; | 2539 | * @param context additional context to use for HKDF of 'h'; |
2222 | * typically the name of the subsystem/application | 2540 | * typically the name of the subsystem/application |
2223 | * @param purp the signature purpose | 2541 | * @param purpose the signature purpose |
2224 | * @param sig the resulting signature | 2542 | * @param sig the resulting signature |
2225 | * @return GNUNET_OK on success | 2543 | * @return GNUNET_OK on success |
2226 | */ | 2544 | */ |
@@ -2285,7 +2603,7 @@ GNUNET_CRYPTO_eddsa_public_key_derive ( | |||
2285 | * @param label label to use for key deriviation | 2603 | * @param label label to use for key deriviation |
2286 | * @param context additional context to use for HKDF of 'h'; | 2604 | * @param context additional context to use for HKDF of 'h'; |
2287 | * typically the name of the subsystem/application | 2605 | * typically the name of the subsystem/application |
2288 | * @param purp the signature purpose | 2606 | * @param purpose the signature purpose |
2289 | * @param sig the resulting signature | 2607 | * @param sig the resulting signature |
2290 | * @return GNUNET_OK on success | 2608 | * @return GNUNET_OK on success |
2291 | */ | 2609 | */ |
@@ -2348,6 +2666,97 @@ GNUNET_CRYPTO_edx25519_public_key_derive ( | |||
2348 | 2666 | ||
2349 | 2667 | ||
2350 | /** | 2668 | /** |
2669 | * @ingroup crypto | ||
2670 | * Clears the most significant bit and second most significant bit of the serialized representaive before applying elligator direct map. | ||
2671 | * | ||
2672 | * @param representative serialized elligator representative of an element of Curves25519's finite field | ||
2673 | * @param point destination for the calculated point on the curve | ||
2674 | * @param high_y bool pointed to will be set to 'true' if corresponding y-coordinate is > 2 ^ 254 - 10, otherwise 0. Can be set to NULL if not needed. | ||
2675 | */ | ||
2676 | void | ||
2677 | GNUNET_CRYPTO_ecdhe_elligator_decoding ( | ||
2678 | struct GNUNET_CRYPTO_EcdhePublicKey *point, | ||
2679 | bool *high_y, | ||
2680 | const struct GNUNET_CRYPTO_ElligatorRepresentative *representative); | ||
2681 | |||
2682 | /** | ||
2683 | * @ingroup crypto | ||
2684 | * Encodes a point on Curve25519 to a an element of the underlying finite field. | ||
2685 | * This transformation is deterministic. | ||
2686 | * | ||
2687 | * @param r storage for the calculated representative | ||
2688 | * @param pub a point on the curve | ||
2689 | * @param high_y encodes if y-coordinate is > 2 ^254 - 10, which determines the representative value out of two | ||
2690 | * @return 'true' if the given point can be encoded into a representative. Otherwise 'false' is returned and the content of the representative storage is undefined | ||
2691 | */ | ||
2692 | bool | ||
2693 | GNUNET_CRYPTO_ecdhe_elligator_encoding ( | ||
2694 | struct GNUNET_CRYPTO_ElligatorRepresentative *r, | ||
2695 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, | ||
2696 | bool high_y); | ||
2697 | |||
2698 | |||
2699 | /** | ||
2700 | * @ingroup crypto | ||
2701 | * Generates a valid public key for elligator's inverse map by adding a lower order point to a prime order point. | ||
2702 | * Following Method 1 in description https://elligator.org/key-exchange section Step 2: Generate a “special” public key. | ||
2703 | * | ||
2704 | * @param pub valid public key for elligator inverse map | ||
2705 | * @param pk private key for generating valid public key | ||
2706 | * @return GNUNET_OK on success | ||
2707 | */ | ||
2708 | enum GNUNET_GenericReturnValue | ||
2709 | GNUNET_CRYPTO_ecdhe_elligator_generate_public_key ( | ||
2710 | struct GNUNET_CRYPTO_EcdhePublicKey *pub, | ||
2711 | struct GNUNET_CRYPTO_EcdhePrivateKey *pk); | ||
2712 | |||
2713 | |||
2714 | /** | ||
2715 | * @ingroup crypto | ||
2716 | * Generates a private key for Curve25519 and the elligator representative of the corresponding public key. | ||
2717 | * | ||
2718 | * @param repr representative of the public key | ||
2719 | * @param pk Curve25519 private key | ||
2720 | */ | ||
2721 | void | ||
2722 | GNUNET_CRYPTO_ecdhe_elligator_key_create ( | ||
2723 | struct GNUNET_CRYPTO_ElligatorRepresentative *repr, | ||
2724 | struct GNUNET_CRYPTO_EcdhePrivateKey *pk); | ||
2725 | |||
2726 | /** | ||
2727 | * @ingroup crypto | ||
2728 | * Carries out ecdh encapsulation with given public key and the private key from a freshly created ephemeral key pair. | ||
2729 | * Following the terminology in https://eprint.iacr.org/2021/509.pdf. | ||
2730 | * | ||
2731 | * @param pub given edwards curve public key (X) | ||
2732 | * @param r representative of ephemeral public key A to use for the ECDH (direct_map(r)=A=aG) | ||
2733 | * @param key_material where to write the key material H(aX)=H(x(aG)) | ||
2734 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
2735 | */ | ||
2736 | enum GNUNET_GenericReturnValue | ||
2737 | GNUNET_CRYPTO_eddsa_elligator_kem_encaps ( | ||
2738 | const struct GNUNET_CRYPTO_EddsaPublicKey *pub, | ||
2739 | struct GNUNET_CRYPTO_ElligatorRepresentative *r, | ||
2740 | struct GNUNET_HashCode *key_material); | ||
2741 | |||
2742 | /** | ||
2743 | * @ingroup crypto | ||
2744 | * Carries out ecdh decapsulation with own private key and the representative of the received public key. | ||
2745 | * Following the terminology in https://eprint.iacr.org/2021/509.pdf. | ||
2746 | * | ||
2747 | * @param priv own private key (x) | ||
2748 | * @param r received representative r, from which we can obtain the public key A (direct_map(r)=A=aG) | ||
2749 | * @param key_material where to write the key material H(xA)=H(a(xG)) | ||
2750 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
2751 | */ | ||
2752 | enum GNUNET_GenericReturnValue | ||
2753 | GNUNET_CRYPTO_eddsa_elligator_kem_decaps ( | ||
2754 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, | ||
2755 | const struct GNUNET_CRYPTO_ElligatorRepresentative *r, | ||
2756 | struct GNUNET_HashCode *key_material); | ||
2757 | |||
2758 | |||
2759 | /** | ||
2351 | * Output the given MPI value to the given buffer in network | 2760 | * Output the given MPI value to the given buffer in network |
2352 | * byte order. The MPI @a val may not be negative. | 2761 | * byte order. The MPI @a val may not be negative. |
2353 | * | 2762 | * |
@@ -2413,7 +2822,7 @@ GNUNET_CRYPTO_paillier_encrypt ( | |||
2413 | * @param private_key Private key to use for decryption. | 2822 | * @param private_key Private key to use for decryption. |
2414 | * @param public_key Public key to use for decryption. | 2823 | * @param public_key Public key to use for decryption. |
2415 | * @param ciphertext Ciphertext to decrypt. | 2824 | * @param ciphertext Ciphertext to decrypt. |
2416 | * @param[out] m Decryption of @a ciphertext with @private_key. | 2825 | * @param[out] m Decryption of @a ciphertext with @a private_key. |
2417 | */ | 2826 | */ |
2418 | void | 2827 | void |
2419 | GNUNET_CRYPTO_paillier_decrypt ( | 2828 | GNUNET_CRYPTO_paillier_decrypt ( |
@@ -2424,7 +2833,8 @@ GNUNET_CRYPTO_paillier_decrypt ( | |||
2424 | 2833 | ||
2425 | 2834 | ||
2426 | /** | 2835 | /** |
2427 | * Compute a ciphertext that represents the sum of the plaintext in @a x1 and @a x2 | 2836 | * Compute a ciphertext that represents the sum of the plaintext in @a c1 |
2837 | * and @a c2 | ||
2428 | * | 2838 | * |
2429 | * Note that this operation can only be done a finite number of times | 2839 | * Note that this operation can only be done a finite number of times |
2430 | * before an overflow occurs. | 2840 | * before an overflow occurs. |
@@ -2561,8 +2971,9 @@ GNUNET_CRYPTO_rsa_private_key_get_public ( | |||
2561 | * @param hc where to store the hash code | 2971 | * @param hc where to store the hash code |
2562 | */ | 2972 | */ |
2563 | void | 2973 | void |
2564 | GNUNET_CRYPTO_rsa_public_key_hash (const struct GNUNET_CRYPTO_RsaPublicKey *key, | 2974 | GNUNET_CRYPTO_rsa_public_key_hash ( |
2565 | struct GNUNET_HashCode *hc); | 2975 | const struct GNUNET_CRYPTO_RsaPublicKey *key, |
2976 | struct GNUNET_HashCode *hc); | ||
2566 | 2977 | ||
2567 | 2978 | ||
2568 | /** | 2979 | /** |
@@ -2667,53 +3078,83 @@ GNUNET_CRYPTO_rsa_public_key_cmp (const struct GNUNET_CRYPTO_RsaPublicKey *p1, | |||
2667 | 3078 | ||
2668 | 3079 | ||
2669 | /** | 3080 | /** |
3081 | * @brief RSA Parameters to create blinded signature | ||
3082 | */ | ||
3083 | struct GNUNET_CRYPTO_RsaBlindedMessage | ||
3084 | { | ||
3085 | /** | ||
3086 | * Blinded message to be signed | ||
3087 | * Note: is malloc()'ed! | ||
3088 | */ | ||
3089 | void *blinded_msg; | ||
3090 | |||
3091 | /** | ||
3092 | * Size of the @e blinded_msg to be signed. | ||
3093 | */ | ||
3094 | size_t blinded_msg_size; | ||
3095 | }; | ||
3096 | |||
3097 | |||
3098 | /** | ||
2670 | * Blinds the given message with the given blinding key | 3099 | * Blinds the given message with the given blinding key |
2671 | * | 3100 | * |
2672 | * @param hash hash of the message to sign | 3101 | * @param message the message to sign |
2673 | * @param bkey the blinding key | 3102 | * @param message_size number of bytes in @a message |
3103 | * @param bks the blinding key | ||
2674 | * @param pkey the public key of the signer | 3104 | * @param pkey the public key of the signer |
2675 | * @param[out] buf set to a buffer with the blinded message to be signed | 3105 | * @param[out] bm set to the blinded message |
2676 | * @param[out] buf_size number of bytes stored in @a buf | ||
2677 | * @return #GNUNET_YES if successful, #GNUNET_NO if RSA key is malicious | 3106 | * @return #GNUNET_YES if successful, #GNUNET_NO if RSA key is malicious |
2678 | */ | 3107 | */ |
2679 | int | 3108 | enum GNUNET_GenericReturnValue |
2680 | GNUNET_CRYPTO_rsa_blind (const struct GNUNET_HashCode *hash, | 3109 | GNUNET_CRYPTO_rsa_blind (const void *message, |
3110 | size_t message_size, | ||
2681 | const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks, | 3111 | const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks, |
2682 | struct GNUNET_CRYPTO_RsaPublicKey *pkey, | 3112 | struct GNUNET_CRYPTO_RsaPublicKey *pkey, |
2683 | void **buf, | 3113 | struct GNUNET_CRYPTO_RsaBlindedMessage *bm); |
2684 | size_t *buf_size); | ||
2685 | 3114 | ||
2686 | 3115 | ||
2687 | /** | 3116 | /** |
2688 | * Sign a blinded value, which must be a full domain hash of a message. | 3117 | * Sign a blinded value, which must be a full domain hash of a message. |
2689 | * | 3118 | * |
2690 | * @param key private key to use for the signing | 3119 | * @param key private key to use for the signing |
2691 | * @param msg the (blinded) message to sign | 3120 | * @param bm the (blinded) message to sign |
2692 | * @param msg_len number of bytes in @a msg to sign | ||
2693 | * @return NULL on error, signature on success | 3121 | * @return NULL on error, signature on success |
2694 | */ | 3122 | */ |
2695 | struct GNUNET_CRYPTO_RsaSignature * | 3123 | struct GNUNET_CRYPTO_RsaSignature * |
2696 | GNUNET_CRYPTO_rsa_sign_blinded (const struct GNUNET_CRYPTO_RsaPrivateKey *key, | 3124 | GNUNET_CRYPTO_rsa_sign_blinded (const struct GNUNET_CRYPTO_RsaPrivateKey *key, |
2697 | const void *msg, | 3125 | const struct |
2698 | size_t msg_len); | 3126 | GNUNET_CRYPTO_RsaBlindedMessage *bm); |
2699 | 3127 | ||
2700 | 3128 | ||
2701 | /** | 3129 | /** |
2702 | * Create and sign a full domain hash of a message. | 3130 | * Create and sign a full domain hash of a message. |
2703 | * | 3131 | * |
2704 | * @param key private key to use for the signing | 3132 | * @param key private key to use for the signing |
2705 | * @param hash the hash of the message to sign | 3133 | * @param message the message to sign |
3134 | * @param message_size number of bytes in @a message | ||
2706 | * @return NULL on error, including a malicious RSA key, signature on success | 3135 | * @return NULL on error, including a malicious RSA key, signature on success |
2707 | */ | 3136 | */ |
2708 | struct GNUNET_CRYPTO_RsaSignature * | 3137 | struct GNUNET_CRYPTO_RsaSignature * |
2709 | GNUNET_CRYPTO_rsa_sign_fdh (const struct GNUNET_CRYPTO_RsaPrivateKey *key, | 3138 | GNUNET_CRYPTO_rsa_sign_fdh (const struct GNUNET_CRYPTO_RsaPrivateKey *key, |
2710 | const struct GNUNET_HashCode *hash); | 3139 | const void *message, |
3140 | size_t message_size); | ||
3141 | |||
3142 | |||
3143 | /** | ||
3144 | * Free memory occupied by blinded message. Only frees contents, not | ||
3145 | * @a bm itself. | ||
3146 | * | ||
3147 | * @param[in] bm memory to free | ||
3148 | */ | ||
3149 | void | ||
3150 | GNUNET_CRYPTO_rsa_blinded_message_free ( | ||
3151 | struct GNUNET_CRYPTO_RsaBlindedMessage *bm); | ||
2711 | 3152 | ||
2712 | 3153 | ||
2713 | /** | 3154 | /** |
2714 | * Free memory occupied by signature. | 3155 | * Free memory occupied by signature. |
2715 | * | 3156 | * |
2716 | * @param sig memory to free | 3157 | * @param[in] sig memory to free |
2717 | */ | 3158 | */ |
2718 | void | 3159 | void |
2719 | GNUNET_CRYPTO_rsa_signature_free (struct GNUNET_CRYPTO_RsaSignature *sig); | 3160 | GNUNET_CRYPTO_rsa_signature_free (struct GNUNET_CRYPTO_RsaSignature *sig); |
@@ -2741,8 +3182,9 @@ GNUNET_CRYPTO_rsa_signature_encode ( | |||
2741 | * @return NULL on error | 3182 | * @return NULL on error |
2742 | */ | 3183 | */ |
2743 | struct GNUNET_CRYPTO_RsaSignature * | 3184 | struct GNUNET_CRYPTO_RsaSignature * |
2744 | GNUNET_CRYPTO_rsa_signature_decode (const void *buf, | 3185 | GNUNET_CRYPTO_rsa_signature_decode ( |
2745 | size_t buf_size); | 3186 | const void *buf, |
3187 | size_t buf_size); | ||
2746 | 3188 | ||
2747 | 3189 | ||
2748 | /** | 3190 | /** |
@@ -2752,7 +3194,8 @@ GNUNET_CRYPTO_rsa_signature_decode (const void *buf, | |||
2752 | * @return the duplicate key; NULL upon error | 3194 | * @return the duplicate key; NULL upon error |
2753 | */ | 3195 | */ |
2754 | struct GNUNET_CRYPTO_RsaSignature * | 3196 | struct GNUNET_CRYPTO_RsaSignature * |
2755 | GNUNET_CRYPTO_rsa_signature_dup (const struct GNUNET_CRYPTO_RsaSignature *sig); | 3197 | GNUNET_CRYPTO_rsa_signature_dup ( |
3198 | const struct GNUNET_CRYPTO_RsaSignature *sig); | ||
2756 | 3199 | ||
2757 | 3200 | ||
2758 | /** | 3201 | /** |
@@ -2775,13 +3218,15 @@ GNUNET_CRYPTO_rsa_unblind (const struct GNUNET_CRYPTO_RsaSignature *sig, | |||
2775 | * Verify whether the given hash corresponds to the given signature and the | 3218 | * Verify whether the given hash corresponds to the given signature and the |
2776 | * signature is valid with respect to the given public key. | 3219 | * signature is valid with respect to the given public key. |
2777 | * | 3220 | * |
2778 | * @param hash the message to verify to match the @a sig | 3221 | * @param message the message to sign |
3222 | * @param message_size number of bytes in @a message | ||
2779 | * @param sig signature that is being validated | 3223 | * @param sig signature that is being validated |
2780 | * @param public_key public key of the signer | 3224 | * @param public_key public key of the signer |
2781 | * @returns #GNUNET_YES if ok, #GNUNET_NO if RSA key is malicious, #GNUNET_SYSERR if signature | 3225 | * @returns #GNUNET_YES if ok, #GNUNET_NO if RSA key is malicious, #GNUNET_SYSERR if signature |
2782 | */ | 3226 | */ |
2783 | enum GNUNET_GenericReturnValue | 3227 | enum GNUNET_GenericReturnValue |
2784 | GNUNET_CRYPTO_rsa_verify (const struct GNUNET_HashCode *hash, | 3228 | GNUNET_CRYPTO_rsa_verify (const void *message, |
3229 | size_t message_size, | ||
2785 | const struct GNUNET_CRYPTO_RsaSignature *sig, | 3230 | const struct GNUNET_CRYPTO_RsaSignature *sig, |
2786 | const struct GNUNET_CRYPTO_RsaPublicKey *public_key); | 3231 | const struct GNUNET_CRYPTO_RsaPublicKey *public_key); |
2787 | 3232 | ||
@@ -2821,10 +3266,11 @@ GNUNET_CRYPTO_cs_private_key_get_public ( | |||
2821 | * @param[out] r array containing derived secrets r0 and r1 | 3266 | * @param[out] r array containing derived secrets r0 and r1 |
2822 | */ | 3267 | */ |
2823 | void | 3268 | void |
2824 | GNUNET_CRYPTO_cs_r_derive (const struct GNUNET_CRYPTO_CsNonce *nonce, | 3269 | GNUNET_CRYPTO_cs_r_derive ( |
2825 | const char *seed, | 3270 | const struct GNUNET_CRYPTO_CsSessionNonce *nonce, |
2826 | const struct GNUNET_CRYPTO_CsPrivateKey *lts, | 3271 | const char *seed, |
2827 | struct GNUNET_CRYPTO_CsRSecret r[2]); | 3272 | const struct GNUNET_CRYPTO_CsPrivateKey *lts, |
3273 | struct GNUNET_CRYPTO_CsRSecret r[2]); | ||
2828 | 3274 | ||
2829 | 3275 | ||
2830 | /** | 3276 | /** |
@@ -2834,27 +3280,57 @@ GNUNET_CRYPTO_cs_r_derive (const struct GNUNET_CRYPTO_CsNonce *nonce, | |||
2834 | * @param[out] r_pub where to write the public key | 3280 | * @param[out] r_pub where to write the public key |
2835 | */ | 3281 | */ |
2836 | void | 3282 | void |
2837 | GNUNET_CRYPTO_cs_r_get_public (const struct GNUNET_CRYPTO_CsRSecret *r_priv, | 3283 | GNUNET_CRYPTO_cs_r_get_public ( |
2838 | struct GNUNET_CRYPTO_CsRPublic *r_pub); | 3284 | const struct GNUNET_CRYPTO_CsRSecret *r_priv, |
3285 | struct GNUNET_CRYPTO_CsRPublic *r_pub); | ||
3286 | |||
2839 | 3287 | ||
2840 | /** | 3288 | /** |
2841 | * Derives new random blinding factors. | 3289 | * Derives new random blinding factors. |
2842 | * In original papers blinding factors are generated randomly | 3290 | * In original papers blinding factors are generated randomly |
2843 | * To provide abort-idempotency, blinding factors need to be derived but still need to be UNPREDICTABLE | 3291 | * To provide abort-idempotency, blinding factors need to be derived but still need to be UNPREDICTABLE. |
2844 | * To ensure unpredictability a new nonce has to be used. | 3292 | * To ensure unpredictability a new nonce has to be used. |
2845 | * Uses HKDF internally | 3293 | * Uses HKDF internally. |
2846 | * | 3294 | * |
2847 | * @param blind_seed is the blinding seed to derive blinding factors | 3295 | * @param blind_seed is the blinding seed to derive blinding factors |
2848 | * @param[out] bs array containing the two derived blinding secrets | 3296 | * @param[out] bs array containing the two derived blinding secrets |
2849 | */ | 3297 | */ |
2850 | void | 3298 | void |
2851 | GNUNET_CRYPTO_cs_blinding_secrets_derive ( | 3299 | GNUNET_CRYPTO_cs_blinding_secrets_derive ( |
2852 | const struct GNUNET_CRYPTO_CsNonce *blind_seed, | 3300 | const struct GNUNET_CRYPTO_CsBlindingNonce *blind_seed, |
2853 | struct GNUNET_CRYPTO_CsBlindingSecret bs[2]); | 3301 | struct GNUNET_CRYPTO_CsBlindingSecret bs[2]); |
2854 | 3302 | ||
2855 | 3303 | ||
2856 | /** | 3304 | /** |
2857 | * Calculate two blinded c's | 3305 | * @brief CS Parameters derived from the message |
3306 | * during blinding to create blinded signature | ||
3307 | */ | ||
3308 | struct GNUNET_CRYPTO_CsBlindedMessage | ||
3309 | { | ||
3310 | /** | ||
3311 | * The Clause Schnorr c_0 and c_1 containing the blinded message | ||
3312 | */ | ||
3313 | struct GNUNET_CRYPTO_CsC c[2]; | ||
3314 | |||
3315 | /** | ||
3316 | * Nonce used in initial request. | ||
3317 | */ | ||
3318 | struct GNUNET_CRYPTO_CsSessionNonce nonce; | ||
3319 | |||
3320 | }; | ||
3321 | |||
3322 | |||
3323 | /** | ||
3324 | * Pair of Public R values for Cs denominations | ||
3325 | */ | ||
3326 | struct GNUNET_CRYPTO_CSPublicRPairP | ||
3327 | { | ||
3328 | struct GNUNET_CRYPTO_CsRPublic r_pub[2]; | ||
3329 | }; | ||
3330 | |||
3331 | |||
3332 | /** | ||
3333 | * Calculate two blinded c's. | ||
2858 | * Comment: One would be insecure due to Wagner's algorithm solving ROS | 3334 | * Comment: One would be insecure due to Wagner's algorithm solving ROS |
2859 | * | 3335 | * |
2860 | * @param bs array of the two blinding factor structs each containing alpha and beta | 3336 | * @param bs array of the two blinding factor structs each containing alpha and beta |
@@ -2863,7 +3339,7 @@ GNUNET_CRYPTO_cs_blinding_secrets_derive ( | |||
2863 | * @param msg the message to blind in preparation for signing | 3339 | * @param msg the message to blind in preparation for signing |
2864 | * @param msg_len length of message msg | 3340 | * @param msg_len length of message msg |
2865 | * @param[out] blinded_c array of the two blinded c's | 3341 | * @param[out] blinded_c array of the two blinded c's |
2866 | * @param[out] blinded_r_pub array of the two blinded R | 3342 | * @param[out] r_pub_blind array of the two blinded R |
2867 | */ | 3343 | */ |
2868 | void | 3344 | void |
2869 | GNUNET_CRYPTO_cs_calc_blinded_c ( | 3345 | GNUNET_CRYPTO_cs_calc_blinded_c ( |
@@ -2873,32 +3349,49 @@ GNUNET_CRYPTO_cs_calc_blinded_c ( | |||
2873 | const void *msg, | 3349 | const void *msg, |
2874 | size_t msg_len, | 3350 | size_t msg_len, |
2875 | struct GNUNET_CRYPTO_CsC blinded_c[2], | 3351 | struct GNUNET_CRYPTO_CsC blinded_c[2], |
2876 | struct GNUNET_CRYPTO_CsRPublic blinded_r_pub[2]); | 3352 | struct GNUNET_CRYPTO_CSPublicRPairP *r_pub_blind); |
2877 | 3353 | ||
2878 | 3354 | ||
2879 | /** | 3355 | /** |
2880 | * Sign a blinded c | 3356 | * The Sign Answer for Clause Blind Schnorr signature. |
2881 | * This function derives b from a nonce and a longterm secret | 3357 | * The sign operation returns a parameter @param b and the signature |
2882 | * In original papers b is generated randomly | 3358 | * scalar @param s_scalar. |
3359 | */ | ||
3360 | struct GNUNET_CRYPTO_CsBlindSignature | ||
3361 | { | ||
3362 | /** | ||
3363 | * To make ROS problem harder, the signer chooses an unpredictable b and | ||
3364 | * only calculates signature of c_b | ||
3365 | */ | ||
3366 | unsigned int b; | ||
3367 | |||
3368 | /** | ||
3369 | * The blinded s scalar calculated from c_b | ||
3370 | */ | ||
3371 | struct GNUNET_CRYPTO_CsBlindS s_scalar; | ||
3372 | }; | ||
3373 | |||
3374 | |||
3375 | /** | ||
3376 | * Sign a blinded @a c. | ||
3377 | * This function derives b from a nonce and a longterm secret. | ||
3378 | * In the original papers b is generated randomly. | ||
2883 | * To provide abort-idempotency, b needs to be derived but still need to be UNPREDICTABLE. | 3379 | * To provide abort-idempotency, b needs to be derived but still need to be UNPREDICTABLE. |
2884 | * To ensure unpredictability a new nonce has to be used for every signature | 3380 | * To ensure unpredictability a new nonce has to be used for every signature. |
2885 | * HKDF is used internally for derivation | 3381 | * HKDF is used internally for derivation. |
2886 | * r0 and r1 can be derived prior by using GNUNET_CRYPTO_cs_r_derive | 3382 | * r0 and r1 can be derived prior by using GNUNET_CRYPTO_cs_r_derive. |
2887 | * | 3383 | * |
2888 | * @param priv private key to use for the signing and as LTS in HKDF | 3384 | * @param priv private key to use for the signing and as LTS in HKDF |
2889 | * @param r array of the two secret nonce from the signer | 3385 | * @param r array of the two secret inputs from the signer |
2890 | * @param c array of the two blinded c to sign c_b | 3386 | * @param bm blinded message, including array of the two blinded c to sign c_b and the random nonce |
2891 | * @param nonce is a random nonce | 3387 | * @param[out] cs_blind_sig where to write the blind signature |
2892 | * @param[out] blinded_signature_scalar where to write the signature | ||
2893 | * @return 0 or 1 for b (see Clause Blind Signature Scheme) | ||
2894 | */ | 3388 | */ |
2895 | unsigned int | 3389 | void |
2896 | GNUNET_CRYPTO_cs_sign_derive ( | 3390 | GNUNET_CRYPTO_cs_sign_derive ( |
2897 | const struct GNUNET_CRYPTO_CsPrivateKey *priv, | 3391 | const struct GNUNET_CRYPTO_CsPrivateKey *priv, |
2898 | const struct GNUNET_CRYPTO_CsRSecret r[2], | 3392 | const struct GNUNET_CRYPTO_CsRSecret r[2], |
2899 | const struct GNUNET_CRYPTO_CsC c[2], | 3393 | const struct GNUNET_CRYPTO_CsBlindedMessage *bm, |
2900 | const struct GNUNET_CRYPTO_CsNonce *nonce, | 3394 | struct GNUNET_CRYPTO_CsBlindSignature *cs_blind_sig); |
2901 | struct GNUNET_CRYPTO_CsBlindS *blinded_signature_scalar); | ||
2902 | 3395 | ||
2903 | 3396 | ||
2904 | /** | 3397 | /** |
@@ -2926,12 +3419,1066 @@ GNUNET_CRYPTO_cs_unblind ( | |||
2926 | * @returns #GNUNET_YES on success, #GNUNET_SYSERR if signature invalid | 3419 | * @returns #GNUNET_YES on success, #GNUNET_SYSERR if signature invalid |
2927 | */ | 3420 | */ |
2928 | enum GNUNET_GenericReturnValue | 3421 | enum GNUNET_GenericReturnValue |
2929 | GNUNET_CRYPTO_cs_verify (const struct GNUNET_CRYPTO_CsSignature *sig, | 3422 | GNUNET_CRYPTO_cs_verify ( |
2930 | const struct GNUNET_CRYPTO_CsPublicKey *pub, | 3423 | const struct GNUNET_CRYPTO_CsSignature *sig, |
2931 | const void *msg, | 3424 | const struct GNUNET_CRYPTO_CsPublicKey *pub, |
2932 | size_t msg_len); | 3425 | const void *msg, |
3426 | size_t msg_len); | ||
2933 | 3427 | ||
2934 | 3428 | ||
3429 | /** | ||
3430 | * Types of public keys used for blind signatures. | ||
3431 | */ | ||
3432 | enum GNUNET_CRYPTO_BlindSignatureAlgorithm | ||
3433 | { | ||
3434 | |||
3435 | /** | ||
3436 | * Invalid type of signature. | ||
3437 | */ | ||
3438 | GNUNET_CRYPTO_BSA_INVALID = 0, | ||
3439 | |||
3440 | /** | ||
3441 | * RSA blind signature. | ||
3442 | */ | ||
3443 | GNUNET_CRYPTO_BSA_RSA = 1, | ||
3444 | |||
3445 | /** | ||
3446 | * Clause Blind Schnorr signature. | ||
3447 | */ | ||
3448 | GNUNET_CRYPTO_BSA_CS = 2 | ||
3449 | }; | ||
3450 | |||
3451 | |||
3452 | /** | ||
3453 | * @brief Type of (unblinded) signatures. | ||
3454 | */ | ||
3455 | struct GNUNET_CRYPTO_UnblindedSignature | ||
3456 | { | ||
3457 | |||
3458 | /** | ||
3459 | * Type of the signature. | ||
3460 | */ | ||
3461 | enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher; | ||
3462 | |||
3463 | /** | ||
3464 | * Reference counter. | ||
3465 | */ | ||
3466 | unsigned int rc; | ||
3467 | |||
3468 | /** | ||
3469 | * Details, depending on @e cipher. | ||
3470 | */ | ||
3471 | union | ||
3472 | { | ||
3473 | /** | ||
3474 | * If we use #GNUNET_CRYPTO_BSA_CS in @a cipher. | ||
3475 | */ | ||
3476 | struct GNUNET_CRYPTO_CsSignature cs_signature; | ||
3477 | |||
3478 | /** | ||
3479 | * If we use #GNUNET_CRYPTO_BSA_RSA in @a cipher. | ||
3480 | */ | ||
3481 | struct GNUNET_CRYPTO_RsaSignature *rsa_signature; | ||
3482 | |||
3483 | } details; | ||
3484 | |||
3485 | }; | ||
3486 | |||
3487 | |||
3488 | /** | ||
3489 | * @brief Type for *blinded* signatures. | ||
3490 | * Must be unblinded before it becomes valid. | ||
3491 | */ | ||
3492 | struct GNUNET_CRYPTO_BlindedSignature | ||
3493 | { | ||
3494 | |||
3495 | /** | ||
3496 | * Type of the signature. | ||
3497 | */ | ||
3498 | enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher; | ||
3499 | |||
3500 | /** | ||
3501 | * Reference counter. | ||
3502 | */ | ||
3503 | unsigned int rc; | ||
3504 | |||
3505 | /** | ||
3506 | * Details, depending on @e cipher. | ||
3507 | */ | ||
3508 | union | ||
3509 | { | ||
3510 | /** | ||
3511 | * If we use #GNUNET_CRYPTO_BSA_CS in @a cipher. | ||
3512 | * At this point only the blinded s scalar is used. | ||
3513 | * The final signature consisting of r,s is built after unblinding. | ||
3514 | */ | ||
3515 | struct GNUNET_CRYPTO_CsBlindSignature blinded_cs_answer; | ||
3516 | |||
3517 | /** | ||
3518 | * If we use #GNUNET_CRYPTO_BSA_RSA in @a cipher. | ||
3519 | */ | ||
3520 | struct GNUNET_CRYPTO_RsaSignature *blinded_rsa_signature; | ||
3521 | |||
3522 | } details; | ||
3523 | |||
3524 | }; | ||
3525 | |||
3526 | |||
3527 | /** | ||
3528 | * @brief Type of public signing keys for blind signatures. | ||
3529 | */ | ||
3530 | struct GNUNET_CRYPTO_BlindSignPublicKey | ||
3531 | { | ||
3532 | |||
3533 | /** | ||
3534 | * Type of the public key. | ||
3535 | */ | ||
3536 | enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher; | ||
3537 | |||
3538 | /** | ||
3539 | * Reference counter. | ||
3540 | */ | ||
3541 | unsigned int rc; | ||
3542 | |||
3543 | /** | ||
3544 | * Hash of the public key. | ||
3545 | */ | ||
3546 | struct GNUNET_HashCode pub_key_hash; | ||
3547 | |||
3548 | /** | ||
3549 | * Details, depending on @e cipher. | ||
3550 | */ | ||
3551 | union | ||
3552 | { | ||
3553 | /** | ||
3554 | * If we use #GNUNET_CRYPTO_BSA_CS in @a cipher. | ||
3555 | */ | ||
3556 | struct GNUNET_CRYPTO_CsPublicKey cs_public_key; | ||
3557 | |||
3558 | /** | ||
3559 | * If we use #GNUNET_CRYPTO_BSA_RSA in @a cipher. | ||
3560 | */ | ||
3561 | struct GNUNET_CRYPTO_RsaPublicKey *rsa_public_key; | ||
3562 | |||
3563 | } details; | ||
3564 | }; | ||
3565 | |||
3566 | |||
3567 | /** | ||
3568 | * @brief Type of private signing keys for blind signing. | ||
3569 | */ | ||
3570 | struct GNUNET_CRYPTO_BlindSignPrivateKey | ||
3571 | { | ||
3572 | |||
3573 | /** | ||
3574 | * Type of the public key. | ||
3575 | */ | ||
3576 | enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher; | ||
3577 | |||
3578 | /** | ||
3579 | * Reference counter. | ||
3580 | */ | ||
3581 | unsigned int rc; | ||
3582 | |||
3583 | /** | ||
3584 | * Details, depending on @e cipher. | ||
3585 | */ | ||
3586 | union | ||
3587 | { | ||
3588 | /** | ||
3589 | * If we use #GNUNET_CRYPTO_BSA_CS in @a cipher. | ||
3590 | */ | ||
3591 | struct GNUNET_CRYPTO_CsPrivateKey cs_private_key; | ||
3592 | |||
3593 | /** | ||
3594 | * If we use #GNUNET_CRYPTO_BSA_RSA in @a cipher. | ||
3595 | */ | ||
3596 | struct GNUNET_CRYPTO_RsaPrivateKey *rsa_private_key; | ||
3597 | |||
3598 | } details; | ||
3599 | }; | ||
3600 | |||
3601 | |||
3602 | /** | ||
3603 | * @brief Blinded message ready for blind signing. | ||
3604 | */ | ||
3605 | struct GNUNET_CRYPTO_BlindedMessage | ||
3606 | { | ||
3607 | /** | ||
3608 | * Type of the sign blinded message | ||
3609 | */ | ||
3610 | enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher; | ||
3611 | |||
3612 | /** | ||
3613 | * Reference counter. | ||
3614 | */ | ||
3615 | unsigned int rc; | ||
3616 | |||
3617 | /** | ||
3618 | * Details, depending on @e cipher. | ||
3619 | */ | ||
3620 | union | ||
3621 | { | ||
3622 | /** | ||
3623 | * If we use #GNUNET_CRYPTO_BSA_CS in @a cipher. | ||
3624 | */ | ||
3625 | struct GNUNET_CRYPTO_CsBlindedMessage cs_blinded_message; | ||
3626 | |||
3627 | /** | ||
3628 | * If we use #GNUNET_CRYPTO_BSA_RSA in @a cipher. | ||
3629 | */ | ||
3630 | struct GNUNET_CRYPTO_RsaBlindedMessage rsa_blinded_message; | ||
3631 | |||
3632 | } details; | ||
3633 | }; | ||
3634 | |||
3635 | |||
3636 | /** | ||
3637 | * Secret r for Cs denominations | ||
3638 | */ | ||
3639 | struct GNUNET_CRYPTO_CSPrivateRPairP | ||
3640 | { | ||
3641 | struct GNUNET_CRYPTO_CsRSecret r[2]; | ||
3642 | }; | ||
3643 | |||
3644 | |||
3645 | /** | ||
3646 | * @brief Input needed for blinding a message. | ||
3647 | */ | ||
3648 | struct GNUNET_CRYPTO_BlindingInputValues | ||
3649 | { | ||
3650 | |||
3651 | /** | ||
3652 | * Type of the signature. | ||
3653 | */ | ||
3654 | enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher; | ||
3655 | |||
3656 | /** | ||
3657 | * Reference counter. | ||
3658 | */ | ||
3659 | unsigned int rc; | ||
3660 | |||
3661 | /** | ||
3662 | * Details, depending on @e cipher. | ||
3663 | */ | ||
3664 | union | ||
3665 | { | ||
3666 | /** | ||
3667 | * If we use #GNUNET_CRYPTO_BSA_CS in @a cipher. | ||
3668 | */ | ||
3669 | struct GNUNET_CRYPTO_CSPublicRPairP cs_values; | ||
3670 | |||
3671 | } details; | ||
3672 | |||
3673 | }; | ||
3674 | |||
3675 | |||
3676 | /** | ||
3677 | * Nonce used to deterministiacally derive input values | ||
3678 | * used in multi-round blind signature protocols. | ||
3679 | */ | ||
3680 | union GNUNET_CRYPTO_BlindSessionNonce | ||
3681 | { | ||
3682 | /** | ||
3683 | * Nonce used when signing with CS. | ||
3684 | */ | ||
3685 | struct GNUNET_CRYPTO_CsSessionNonce cs_nonce; | ||
3686 | }; | ||
3687 | |||
3688 | |||
3689 | /** | ||
3690 | * Compute blinding input values for a given @a nonce and | ||
3691 | * @a salt. | ||
3692 | * | ||
3693 | * @param bsign_priv private key to compute input values for | ||
3694 | * @param nonce session nonce to derive input values from | ||
3695 | * @param salt salt to include in derivation logic | ||
3696 | * @return blinding input values | ||
3697 | */ | ||
3698 | struct GNUNET_CRYPTO_BlindingInputValues * | ||
3699 | GNUNET_CRYPTO_get_blinding_input_values ( | ||
3700 | const struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv, | ||
3701 | const union GNUNET_CRYPTO_BlindSessionNonce *nonce, | ||
3702 | const char *salt); | ||
3703 | |||
3704 | |||
3705 | /** | ||
3706 | * Decrement reference counter of a @a bsign_pub, and free it if it reaches zero. | ||
3707 | * | ||
3708 | * @param[in] bsign_pub key to free | ||
3709 | */ | ||
3710 | void | ||
3711 | GNUNET_CRYPTO_blind_sign_pub_decref ( | ||
3712 | struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub); | ||
3713 | |||
3714 | |||
3715 | /** | ||
3716 | * Decrement reference counter of a @a bsign_priv, and free it if it reaches zero. | ||
3717 | * | ||
3718 | * @param[in] bsign_priv key to free | ||
3719 | */ | ||
3720 | void | ||
3721 | GNUNET_CRYPTO_blind_sign_priv_decref ( | ||
3722 | struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv); | ||
3723 | |||
3724 | |||
3725 | /** | ||
3726 | * Decrement reference counter of a @a ub_sig, and free it if it reaches zero. | ||
3727 | * | ||
3728 | * @param[in] ub_sig signature to free | ||
3729 | */ | ||
3730 | void | ||
3731 | GNUNET_CRYPTO_unblinded_sig_decref ( | ||
3732 | struct GNUNET_CRYPTO_UnblindedSignature *ub_sig); | ||
3733 | |||
3734 | |||
3735 | /** | ||
3736 | * Decrement reference counter of a @a blind_sig, and free it if it reaches zero. | ||
3737 | * | ||
3738 | * @param[in] blind_sig signature to free | ||
3739 | */ | ||
3740 | void | ||
3741 | GNUNET_CRYPTO_blinded_sig_decref ( | ||
3742 | struct GNUNET_CRYPTO_BlindedSignature *blind_sig); | ||
3743 | |||
3744 | |||
3745 | /** | ||
3746 | * Decrement reference counter of a @a bm, and free it if it reaches zero. | ||
3747 | * | ||
3748 | * @param[in] bm blinded message to free | ||
3749 | */ | ||
3750 | void | ||
3751 | GNUNET_CRYPTO_blinded_message_decref ( | ||
3752 | struct GNUNET_CRYPTO_BlindedMessage *bm); | ||
3753 | |||
3754 | |||
3755 | /** | ||
3756 | * Increment reference counter of the given @a bm. | ||
3757 | * | ||
3758 | * @param[in,out] bm blinded message to increment reference counter for | ||
3759 | * @return alias of @a bm with RC incremented | ||
3760 | */ | ||
3761 | struct GNUNET_CRYPTO_BlindedMessage * | ||
3762 | GNUNET_CRYPTO_blinded_message_incref ( | ||
3763 | struct GNUNET_CRYPTO_BlindedMessage *bm); | ||
3764 | |||
3765 | |||
3766 | /** | ||
3767 | * Increment reference counter of the given @a bi. | ||
3768 | * | ||
3769 | * @param[in,out] bi blinding input values to increment reference counter for | ||
3770 | * @return alias of @a bi with RC incremented | ||
3771 | */ | ||
3772 | struct GNUNET_CRYPTO_BlindingInputValues * | ||
3773 | GNUNET_CRYPTO_blinding_input_values_incref ( | ||
3774 | struct GNUNET_CRYPTO_BlindingInputValues *bm); | ||
3775 | |||
3776 | |||
3777 | /** | ||
3778 | * Decrement reference counter of the given @a bi, and free it if it reaches | ||
3779 | * zero. | ||
3780 | * | ||
3781 | * @param[in,out] bi blinding input values to decrement reference counter for | ||
3782 | */ | ||
3783 | void | ||
3784 | GNUNET_CRYPTO_blinding_input_values_decref ( | ||
3785 | struct GNUNET_CRYPTO_BlindingInputValues *bm); | ||
3786 | |||
3787 | |||
3788 | /** | ||
3789 | * Increment reference counter of the given @a bsign_pub. | ||
3790 | * | ||
3791 | * @param[in,out] bsign_pub public key to increment reference counter for | ||
3792 | * @return alias of @a bsign_pub with RC incremented | ||
3793 | */ | ||
3794 | struct GNUNET_CRYPTO_BlindSignPublicKey * | ||
3795 | GNUNET_CRYPTO_bsign_pub_incref ( | ||
3796 | struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub); | ||
3797 | |||
3798 | |||
3799 | /** | ||
3800 | * Increment reference counter of the given @a bsign_priv. | ||
3801 | * | ||
3802 | * @param[in,out] bsign_priv private key to increment reference counter for | ||
3803 | * @return alias of @a bsign_priv with RC incremented | ||
3804 | */ | ||
3805 | struct GNUNET_CRYPTO_BlindSignPrivateKey * | ||
3806 | GNUNET_CRYPTO_bsign_priv_incref ( | ||
3807 | struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv); | ||
3808 | |||
3809 | |||
3810 | /** | ||
3811 | * Increment reference counter of the given @a ub_sig. | ||
3812 | * | ||
3813 | * @param[in,out] ub_sig signature to increment reference counter for | ||
3814 | * @return alias of @a ub_sig with RC incremented | ||
3815 | */ | ||
3816 | struct GNUNET_CRYPTO_UnblindedSignature * | ||
3817 | GNUNET_CRYPTO_ub_sig_incref (struct GNUNET_CRYPTO_UnblindedSignature *ub_sig); | ||
3818 | |||
3819 | |||
3820 | /** | ||
3821 | * Increment reference counter of the given @a blind_sig. | ||
3822 | * | ||
3823 | * @param[in,out] blind_sig signature to increment reference counter for | ||
3824 | * @return alias of @a blind_sig with RC incremented | ||
3825 | */ | ||
3826 | struct GNUNET_CRYPTO_BlindedSignature * | ||
3827 | GNUNET_CRYPTO_blind_sig_incref ( | ||
3828 | struct GNUNET_CRYPTO_BlindedSignature *blind_sig); | ||
3829 | |||
3830 | |||
3831 | /** | ||
3832 | * Compare two denomination public keys. | ||
3833 | * | ||
3834 | * @param bp1 first key | ||
3835 | * @param bp2 second key | ||
3836 | * @return 0 if the keys are equal, otherwise -1 or 1 | ||
3837 | */ | ||
3838 | int | ||
3839 | GNUNET_CRYPTO_bsign_pub_cmp ( | ||
3840 | const struct GNUNET_CRYPTO_BlindSignPublicKey *bp1, | ||
3841 | const struct GNUNET_CRYPTO_BlindSignPublicKey *bp2); | ||
3842 | |||
3843 | |||
3844 | /** | ||
3845 | * Compare two denomination signatures. | ||
3846 | * | ||
3847 | * @param sig1 first signature | ||
3848 | * @param sig2 second signature | ||
3849 | * @return 0 if the keys are equal, otherwise -1 or 1 | ||
3850 | */ | ||
3851 | int | ||
3852 | GNUNET_CRYPTO_ub_sig_cmp (const struct GNUNET_CRYPTO_UnblindedSignature *sig1, | ||
3853 | const struct GNUNET_CRYPTO_UnblindedSignature *sig2); | ||
3854 | |||
3855 | |||
3856 | /** | ||
3857 | * Compare two blinded denomination signatures. | ||
3858 | * | ||
3859 | * @param sig1 first signature | ||
3860 | * @param sig2 second signature | ||
3861 | * @return 0 if the keys are equal, otherwise -1 or 1 | ||
3862 | */ | ||
3863 | int | ||
3864 | GNUNET_CRYPTO_blind_sig_cmp ( | ||
3865 | const struct GNUNET_CRYPTO_BlindedSignature *sig1, | ||
3866 | const struct GNUNET_CRYPTO_BlindedSignature *sig2); | ||
3867 | |||
3868 | |||
3869 | /** | ||
3870 | * Compare two blinded messages. | ||
3871 | * | ||
3872 | * @param bp1 first blinded message | ||
3873 | * @param bp2 second blinded message | ||
3874 | * @return 0 if the keys are equal, otherwise -1 or 1 | ||
3875 | */ | ||
3876 | int | ||
3877 | GNUNET_CRYPTO_blinded_message_cmp ( | ||
3878 | const struct GNUNET_CRYPTO_BlindedMessage *bp1, | ||
3879 | const struct GNUNET_CRYPTO_BlindedMessage *bp2); | ||
3880 | |||
3881 | |||
3882 | /** | ||
3883 | * Initialize public-private key pair for blind signatures. | ||
3884 | * | ||
3885 | * For #GNUNET_CRYPTO_BSA_RSA, an additional "unsigned int" | ||
3886 | * argument with the number of bits for 'n' (e.g. 2048) must | ||
3887 | * be passed. | ||
3888 | * | ||
3889 | * @param[out] bsign_priv where to write the private key with RC 1 | ||
3890 | * @param[out] bsign_pub where to write the public key with RC 1 | ||
3891 | * @param cipher which type of cipher to use | ||
3892 | * @param ... RSA key size (eg. 2048/3072/4096) | ||
3893 | * @return #GNUNET_OK on success, #GNUNET_NO if parameterst were invalid | ||
3894 | */ | ||
3895 | enum GNUNET_GenericReturnValue | ||
3896 | GNUNET_CRYPTO_blind_sign_keys_create ( | ||
3897 | struct GNUNET_CRYPTO_BlindSignPrivateKey **bsign_priv, | ||
3898 | struct GNUNET_CRYPTO_BlindSignPublicKey **bsign_pub, | ||
3899 | enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher, | ||
3900 | ...); | ||
3901 | |||
3902 | |||
3903 | /** | ||
3904 | * Initialize public-private key pair for blind signatures. | ||
3905 | * | ||
3906 | * For #GNUNET_CRYPTO_BSA_RSA, an additional "unsigned int" | ||
3907 | * argument with the number of bits for 'n' (e.g. 2048) must | ||
3908 | * be passed. | ||
3909 | * | ||
3910 | * @param[out] bsign_priv where to write the private key with RC 1 | ||
3911 | * @param[out] bsign_pub where to write the public key with RC 1 | ||
3912 | * @param cipher which type of cipher to use | ||
3913 | * @param ap RSA key size (eg. 2048/3072/4096) | ||
3914 | * @return #GNUNET_OK on success, #GNUNET_NO if parameterst were invalid | ||
3915 | */ | ||
3916 | enum GNUNET_GenericReturnValue | ||
3917 | GNUNET_CRYPTO_blind_sign_keys_create_va ( | ||
3918 | struct GNUNET_CRYPTO_BlindSignPrivateKey **bsign_priv, | ||
3919 | struct GNUNET_CRYPTO_BlindSignPublicKey **bsign_pub, | ||
3920 | enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher, | ||
3921 | va_list ap); | ||
3922 | |||
3923 | |||
3924 | /** | ||
3925 | * @brief Type of blinding secrets. Must be exactly 32 bytes (DB). | ||
3926 | */ | ||
3927 | union GNUNET_CRYPTO_BlindingSecretP | ||
3928 | { | ||
3929 | /** | ||
3930 | * Clause Schnorr nonce. | ||
3931 | */ | ||
3932 | struct GNUNET_CRYPTO_CsBlindingNonce nonce; | ||
3933 | |||
3934 | /** | ||
3935 | * Variant for RSA for blind signatures. | ||
3936 | */ | ||
3937 | struct GNUNET_CRYPTO_RsaBlindingKeySecret rsa_bks; | ||
3938 | }; | ||
3939 | |||
3940 | |||
3941 | /** | ||
3942 | * Blind message for blind signing with @a dk using blinding secret @a coin_bks. | ||
3943 | * | ||
3944 | * @param bsign_pub public key to blind for | ||
3945 | * @param bks blinding secret to use | ||
3946 | * @param nonce nonce used to obtain @a alg_values | ||
3947 | * can be NULL if input values are not used for the cipher | ||
3948 | * @param message message to sign | ||
3949 | * @param message_size number of bytes in @a message | ||
3950 | * @param alg_values algorithm specific values to blind the @a message | ||
3951 | * @return blinded message to give to signer, NULL on error | ||
3952 | */ | ||
3953 | struct GNUNET_CRYPTO_BlindedMessage * | ||
3954 | GNUNET_CRYPTO_message_blind_to_sign ( | ||
3955 | const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub, | ||
3956 | const union GNUNET_CRYPTO_BlindingSecretP *bks, | ||
3957 | const union GNUNET_CRYPTO_BlindSessionNonce *nonce, | ||
3958 | const void *message, | ||
3959 | size_t message_size, | ||
3960 | const struct GNUNET_CRYPTO_BlindingInputValues *alg_values); | ||
3961 | |||
3962 | |||
3963 | /** | ||
3964 | * Create blind signature. | ||
3965 | * | ||
3966 | * @param bsign_priv private key to use for signing | ||
3967 | * @param salt salt value to use for the HKDF, | ||
3968 | * can be NULL if input values are not used for the cipher | ||
3969 | * @param blinded_message the already blinded message to sign | ||
3970 | * @return blind signature with RC=1, NULL on failure | ||
3971 | */ | ||
3972 | struct GNUNET_CRYPTO_BlindedSignature * | ||
3973 | GNUNET_CRYPTO_blind_sign ( | ||
3974 | const struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv, | ||
3975 | const char *salt, | ||
3976 | const struct GNUNET_CRYPTO_BlindedMessage *blinded_message); | ||
3977 | |||
3978 | |||
3979 | /** | ||
3980 | * Unblind blind signature. | ||
3981 | * | ||
3982 | * @param blinded_sig the blind signature | ||
3983 | * @param bks blinding secret to use | ||
3984 | * @param message message that was supposedly signed | ||
3985 | * @param message_size number of bytes in @a message | ||
3986 | * @param alg_values algorithm specific values | ||
3987 | * @param bsign_pub public key used for signing | ||
3988 | * @return unblinded signature with RC=1, NULL on error | ||
3989 | */ | ||
3990 | struct GNUNET_CRYPTO_UnblindedSignature * | ||
3991 | GNUNET_CRYPTO_blind_sig_unblind ( | ||
3992 | const struct GNUNET_CRYPTO_BlindedSignature *blinded_sig, | ||
3993 | const union GNUNET_CRYPTO_BlindingSecretP *bks, | ||
3994 | const void *message, | ||
3995 | size_t message_size, | ||
3996 | const struct GNUNET_CRYPTO_BlindingInputValues *alg_values, | ||
3997 | const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub); | ||
3998 | |||
3999 | |||
4000 | /** | ||
4001 | * Verify signature made blindly. | ||
4002 | * | ||
4003 | * @param bsign_pub public key | ||
4004 | * @param ub_sig signature made blindly with the private key | ||
4005 | * @param message message that was supposedly signed | ||
4006 | * @param message_size number of bytes in @a message | ||
4007 | * @return #GNUNET_OK if the signature is valid | ||
4008 | */ | ||
4009 | enum GNUNET_GenericReturnValue | ||
4010 | GNUNET_CRYPTO_blind_sig_verify ( | ||
4011 | const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub, | ||
4012 | const struct GNUNET_CRYPTO_UnblindedSignature *ub_sig, | ||
4013 | const void *message, | ||
4014 | size_t message_size); | ||
4015 | |||
4016 | |||
4017 | /** | ||
4018 | * Get the compacted length of a #GNUNET_CRYPTO_PublicKey. | ||
4019 | * Compacted means that it returns the minimum number of bytes this | ||
4020 | * key is long, as opposed to the union structure inside | ||
4021 | * #GNUNET_CRYPTO_PublicKey. | ||
4022 | * Useful for compact serializations. | ||
4023 | * | ||
4024 | * @param key the key. | ||
4025 | * @return -1 on error, else the compacted length of the key. | ||
4026 | */ | ||
4027 | ssize_t | ||
4028 | GNUNET_CRYPTO_public_key_get_length (const struct | ||
4029 | GNUNET_CRYPTO_PublicKey *key); | ||
4030 | |||
4031 | /** | ||
4032 | * Reads a #GNUNET_CRYPTO_PublicKey from a compact buffer. | ||
4033 | * The buffer has to contain at least the compacted length of | ||
4034 | * a #GNUNET_CRYPTO_PublicKey in bytes. | ||
4035 | * If the buffer is too small, the function returns -1 as error. | ||
4036 | * If the buffer does not contain a valid key, it returns -2 as error. | ||
4037 | * | ||
4038 | * @param buffer the buffer | ||
4039 | * @param len the length of buffer | ||
4040 | * @param key the key | ||
4041 | * @param the amount of bytes read from the buffer | ||
4042 | * @return #GNUNET_SYSERR on error | ||
4043 | */ | ||
4044 | enum GNUNET_GenericReturnValue | ||
4045 | GNUNET_CRYPTO_read_public_key_from_buffer ( | ||
4046 | const void *buffer, | ||
4047 | size_t len, | ||
4048 | struct GNUNET_CRYPTO_PublicKey *key, | ||
4049 | size_t *read); | ||
4050 | |||
4051 | /** | ||
4052 | * Get the compacted length of a #GNUNET_CRYPTO_PrivateKey. | ||
4053 | * Compacted means that it returns the minimum number of bytes this | ||
4054 | * key is long, as opposed to the union structure inside | ||
4055 | * #GNUNET_CRYPTO_PrivateKey. | ||
4056 | * Useful for compact serializations. | ||
4057 | * | ||
4058 | * @param key the key. | ||
4059 | * @return -1 on error, else the compacted length of the key. | ||
4060 | */ | ||
4061 | ssize_t | ||
4062 | GNUNET_CRYPTO_private_key_get_length ( | ||
4063 | const struct GNUNET_CRYPTO_PrivateKey *key); | ||
4064 | |||
4065 | |||
4066 | /** | ||
4067 | * Writes a #GNUNET_CRYPTO_PublicKey to a compact buffer. | ||
4068 | * The buffer requires space for at least the compacted length of | ||
4069 | * a #GNUNET_CRYPTO_PublicKey in bytes. | ||
4070 | * If the buffer is too small, the function returns -1 as error. | ||
4071 | * If the key is not valid, it returns -2 as error. | ||
4072 | * | ||
4073 | * @param key the key | ||
4074 | * @param buffer the buffer | ||
4075 | * @param len the length of buffer | ||
4076 | * @return -1 or -2 on error, else the amount of bytes written to the buffer | ||
4077 | */ | ||
4078 | ssize_t | ||
4079 | GNUNET_CRYPTO_write_public_key_to_buffer (const struct | ||
4080 | GNUNET_CRYPTO_PublicKey *key, | ||
4081 | void*buffer, | ||
4082 | size_t len); | ||
4083 | |||
4084 | |||
4085 | /** | ||
4086 | * Reads a #GNUNET_CRYPTO_PrivateKey from a compact buffer. | ||
4087 | * The buffer has to contain at least the compacted length of | ||
4088 | * a #GNUNET_CRYPTO_PrivateKey in bytes. | ||
4089 | * If the buffer is too small, the function returns GNUNET_SYSERR as error. | ||
4090 | * | ||
4091 | * @param buffer the buffer | ||
4092 | * @param len the length of buffer | ||
4093 | * @param key the key | ||
4094 | * @param the amount of bytes read from the buffer | ||
4095 | * @return #GNUNET_SYSERR on error | ||
4096 | */ | ||
4097 | enum GNUNET_GenericReturnValue | ||
4098 | GNUNET_CRYPTO_read_private_key_from_buffer ( | ||
4099 | const void*buffer, | ||
4100 | size_t len, | ||
4101 | struct GNUNET_CRYPTO_PrivateKey *key, | ||
4102 | size_t *read); | ||
4103 | |||
4104 | |||
4105 | /** | ||
4106 | * Writes a #GNUNET_CRYPTO_PrivateKey to a compact buffer. | ||
4107 | * The buffer requires space for at least the compacted length of | ||
4108 | * a #GNUNET_CRYPTO_PrivateKey in bytes. | ||
4109 | * If the buffer is too small, the function returns -1 as error. | ||
4110 | * If the key is not valid, it returns -2 as error. | ||
4111 | * | ||
4112 | * @param key the key | ||
4113 | * @param buffer the buffer | ||
4114 | * @param len the length of buffer | ||
4115 | * @return -1 or -2 on error, else the amount of bytes written to the buffer | ||
4116 | */ | ||
4117 | ssize_t | ||
4118 | GNUNET_CRYPTO_write_private_key_to_buffer ( | ||
4119 | const struct GNUNET_CRYPTO_PrivateKey *key, | ||
4120 | void*buffer, | ||
4121 | size_t len); | ||
4122 | |||
4123 | |||
4124 | /** | ||
4125 | * Get the compacted length of a #GNUNET_CRYPTO_Signature. | ||
4126 | * Compacted means that it returns the minimum number of bytes this | ||
4127 | * signature is long, as opposed to the union structure inside | ||
4128 | * #GNUNET_CRYPTO_Signature. | ||
4129 | * Useful for compact serializations. | ||
4130 | * | ||
4131 | * @param sig the signature. | ||
4132 | * @return -1 on error, else the compacted length of the signature. | ||
4133 | */ | ||
4134 | ssize_t | ||
4135 | GNUNET_CRYPTO_signature_get_length ( | ||
4136 | const struct GNUNET_CRYPTO_Signature *sig); | ||
4137 | |||
4138 | |||
4139 | /** | ||
4140 | * Get the compacted length of a signature by type. | ||
4141 | * Compacted means that it returns the minimum number of bytes this | ||
4142 | * signature is long, as opposed to the union structure inside | ||
4143 | * #GNUNET_CRYPTO_Signature. | ||
4144 | * Useful for compact serializations. | ||
4145 | * | ||
4146 | * @param sig the signature. | ||
4147 | * @return -1 on error, else the compacted length of the signature. | ||
4148 | */ | ||
4149 | ssize_t | ||
4150 | GNUNET_CRYPTO_signature_get_raw_length_by_type (uint32_t type); | ||
4151 | |||
4152 | |||
4153 | /** | ||
4154 | * Reads a #GNUNET_CRYPTO_Signature from a compact buffer. | ||
4155 | * The buffer has to contain at least the compacted length of | ||
4156 | * a #GNUNET_CRYPTO_Signature in bytes. | ||
4157 | * If the buffer is too small, the function returns -1 as error. | ||
4158 | * If the buffer does not contain a valid key, it returns -2 as error. | ||
4159 | * | ||
4160 | * @param sig the signature | ||
4161 | * @param buffer the buffer | ||
4162 | * @param len the length of buffer | ||
4163 | * @return -1 or -2 on error, else the amount of bytes read from the buffer | ||
4164 | */ | ||
4165 | ssize_t | ||
4166 | GNUNET_CRYPTO_read_signature_from_buffer ( | ||
4167 | struct GNUNET_CRYPTO_Signature *sig, | ||
4168 | const void*buffer, | ||
4169 | size_t len); | ||
4170 | |||
4171 | |||
4172 | /** | ||
4173 | * Writes a #GNUNET_CRYPTO_Signature to a compact buffer. | ||
4174 | * The buffer requires space for at least the compacted length of | ||
4175 | * a #GNUNET_CRYPTO_Signature in bytes. | ||
4176 | * If the buffer is too small, the function returns -1 as error. | ||
4177 | * If the key is not valid, it returns -2 as error. | ||
4178 | * | ||
4179 | * @param sig the signature | ||
4180 | * @param buffer the buffer | ||
4181 | * @param len the length of buffer | ||
4182 | * @return -1 or -2 on error, else the amount of bytes written to the buffer | ||
4183 | */ | ||
4184 | ssize_t | ||
4185 | GNUNET_CRYPTO_write_signature_to_buffer ( | ||
4186 | const struct GNUNET_CRYPTO_Signature *sig, | ||
4187 | void*buffer, | ||
4188 | size_t len); | ||
4189 | |||
4190 | |||
4191 | /** | ||
4192 | * @brief Sign a given block. | ||
4193 | * | ||
4194 | * The @a purpose data is the beginning of the data of which the signature is | ||
4195 | * to be created. The `size` field in @a purpose must correctly indicate the | ||
4196 | * number of bytes of the data structure, including its header. If possible, | ||
4197 | * use #GNUNET_CRYPTO_sign() instead of this function. | ||
4198 | * | ||
4199 | * @param priv private key to use for the signing | ||
4200 | * @param purpose what to sign (size, purpose) | ||
4201 | * @param[out] sig where to write the signature | ||
4202 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
4203 | */ | ||
4204 | enum GNUNET_GenericReturnValue | ||
4205 | GNUNET_CRYPTO_sign_ ( | ||
4206 | const struct GNUNET_CRYPTO_PrivateKey *priv, | ||
4207 | const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, | ||
4208 | struct GNUNET_CRYPTO_Signature *sig); | ||
4209 | |||
4210 | /** | ||
4211 | * @brief Sign a given block. | ||
4212 | * | ||
4213 | * The @a purpose data is the beginning of the data of which the signature is | ||
4214 | * to be created. The `size` field in @a purpose must correctly indicate the | ||
4215 | * number of bytes of the data structure, including its header. | ||
4216 | * The signature payload and length depends on the key type. | ||
4217 | * | ||
4218 | * @param priv private key to use for the signing | ||
4219 | * @param purpose what to sign (size, purpose) | ||
4220 | * @param[out] sig where to write the signature | ||
4221 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
4222 | */ | ||
4223 | enum GNUNET_GenericReturnValue | ||
4224 | GNUNET_CRYPTO_sign_raw_ ( | ||
4225 | const struct GNUNET_CRYPTO_PrivateKey *priv, | ||
4226 | const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, | ||
4227 | unsigned char *sig); | ||
4228 | |||
4229 | |||
4230 | /** | ||
4231 | * @brief Sign a given block with #GNUNET_CRYPTO_PrivateKey. | ||
4232 | * | ||
4233 | * The @a ps data must be a fixed-size struct for which the signature is to be | ||
4234 | * created. The `size` field in @a ps->purpose must correctly indicate the | ||
4235 | * number of bytes of the data structure, including its header. | ||
4236 | * | ||
4237 | * @param priv private key to use for the signing | ||
4238 | * @param ps packed struct with what to sign, MUST begin with a purpose | ||
4239 | * @param[out] sig where to write the signature | ||
4240 | */ | ||
4241 | #define GNUNET_CRYPTO_sign(priv,ps,sig) do { \ | ||
4242 | /* check size is set correctly */ \ | ||
4243 | GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \ | ||
4244 | /* check 'ps' begins with the purpose */ \ | ||
4245 | GNUNET_static_assert (((void*) (ps)) == \ | ||
4246 | ((void*) &(ps)->purpose)); \ | ||
4247 | GNUNET_assert (GNUNET_OK == \ | ||
4248 | GNUNET_CRYPTO_sign_ (priv, \ | ||
4249 | &(ps)->purpose, \ | ||
4250 | sig)); \ | ||
4251 | } while (0) | ||
4252 | |||
4253 | |||
4254 | /** | ||
4255 | * @brief Verify a given signature. | ||
4256 | * | ||
4257 | * The @a validate data is the beginning of the data of which the signature | ||
4258 | * is to be verified. The `size` field in @a validate must correctly indicate | ||
4259 | * the number of bytes of the data structure, including its header. If @a | ||
4260 | * purpose does not match the purpose given in @a validate (the latter must be | ||
4261 | * in big endian), signature verification fails. If possible, | ||
4262 | * use #GNUNET_CRYPTO_signature_verify() instead of this function (only if @a validate | ||
4263 | * is not fixed-size, you must use this function directly). | ||
4264 | * | ||
4265 | * @param purpose what is the purpose that the signature should have? | ||
4266 | * @param validate block to validate (size, purpose, data) | ||
4267 | * @param sig signature that is being validated | ||
4268 | * @param pub public key of the signer | ||
4269 | * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid | ||
4270 | */ | ||
4271 | enum GNUNET_GenericReturnValue | ||
4272 | GNUNET_CRYPTO_signature_verify_ ( | ||
4273 | uint32_t purpose, | ||
4274 | const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, | ||
4275 | const struct GNUNET_CRYPTO_Signature *sig, | ||
4276 | const struct GNUNET_CRYPTO_PublicKey *pub); | ||
4277 | |||
4278 | /** | ||
4279 | * @brief Verify a given signature. | ||
4280 | * | ||
4281 | * The @a validate data is the beginning of the data of which the signature | ||
4282 | * is to be verified. The `size` field in @a validate must correctly indicate | ||
4283 | * the number of bytes of the data structure, including its header. If @a | ||
4284 | * purpose does not match the purpose given in @a validate (the latter must be | ||
4285 | * in big endian), signature verification fails. | ||
4286 | * | ||
4287 | * @param purpose what is the purpose that the signature should have? | ||
4288 | * @param validate block to validate (size, purpose, data) | ||
4289 | * @param sig signature that is being validated | ||
4290 | * @param pub public key of the signer | ||
4291 | * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid | ||
4292 | */ | ||
4293 | enum GNUNET_GenericReturnValue | ||
4294 | GNUNET_CRYPTO_signature_verify_raw_ ( | ||
4295 | uint32_t purpose, | ||
4296 | const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, | ||
4297 | const unsigned char *sig, | ||
4298 | const struct GNUNET_CRYPTO_PublicKey *pub); | ||
4299 | |||
4300 | |||
4301 | /** | ||
4302 | * @brief Verify a given signature with #GNUNET_CRYPTO_PublicKey. | ||
4303 | * | ||
4304 | * The @a ps data must be a fixed-size struct for which the signature is to be | ||
4305 | * created. The `size` field in @a ps->purpose must correctly indicate the | ||
4306 | * number of bytes of the data structure, including its header. | ||
4307 | * | ||
4308 | * @param purp purpose of the signature, must match 'ps->purpose.purpose' | ||
4309 | * (except in host byte order) | ||
4310 | * @param ps packed struct with what to sign, MUST begin with a purpose | ||
4311 | * @param sig where to read the signature from | ||
4312 | * @param pub public key to use for the verifying | ||
4313 | */ | ||
4314 | #define GNUNET_CRYPTO_signature_verify(purp,ps,sig,pub) ({ \ | ||
4315 | /* check size is set correctly */ \ | ||
4316 | GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \ | ||
4317 | /* check 'ps' begins with the purpose */ \ | ||
4318 | GNUNET_static_assert (((void*) (ps)) == \ | ||
4319 | ((void*) &(ps)->purpose)); \ | ||
4320 | GNUNET_CRYPTO_signature_verify_ (purp, \ | ||
4321 | &(ps)->purpose, \ | ||
4322 | sig, \ | ||
4323 | pub); \ | ||
4324 | }) | ||
4325 | |||
4326 | |||
4327 | /** | ||
4328 | * Encrypt a block with #GNUNET_CRYPTO_PublicKey and derives a | ||
4329 | * #GNUNET_CRYPTO_EcdhePublicKey which is required for decryption | ||
4330 | * using ecdh to derive a symmetric key. | ||
4331 | * | ||
4332 | * @param block the block to encrypt | ||
4333 | * @param size the size of the @a block | ||
4334 | * @param pub public key to use for ecdh | ||
4335 | * @param ecc where to write the ecc public key | ||
4336 | * @param result the output parameter in which to store the encrypted result | ||
4337 | * can be the same or overlap with @c block | ||
4338 | * @returns the size of the encrypted block, -1 for errors. | ||
4339 | * Due to the use of CFB and therefore an effective stream cipher, | ||
4340 | * this size should be the same as @c len. | ||
4341 | */ | ||
4342 | ssize_t | ||
4343 | GNUNET_CRYPTO_encrypt_old (const void *block, | ||
4344 | size_t size, | ||
4345 | const struct GNUNET_CRYPTO_PublicKey *pub, | ||
4346 | struct GNUNET_CRYPTO_EcdhePublicKey *ecc, | ||
4347 | void *result); | ||
4348 | |||
4349 | |||
4350 | /** | ||
4351 | * Decrypt a given block with #GNUNET_CRYPTO_PrivateKey and a given | ||
4352 | * #GNUNET_CRYPTO_EcdhePublicKey using ecdh to derive a symmetric key. | ||
4353 | * | ||
4354 | * @param block the data to decrypt, encoded as returned by encrypt | ||
4355 | * @param size the size of the @a block to decrypt | ||
4356 | * @param priv private key to use for ecdh | ||
4357 | * @param ecc the ecc public key | ||
4358 | * @param result address to store the result at | ||
4359 | * can be the same or overlap with @c block | ||
4360 | * @return -1 on failure, size of decrypted block on success. | ||
4361 | * Due to the use of CFB and therefore an effective stream cipher, | ||
4362 | * this size should be the same as @c size. | ||
4363 | */ | ||
4364 | ssize_t | ||
4365 | GNUNET_CRYPTO_decrypt_old ( | ||
4366 | const void *block, | ||
4367 | size_t size, | ||
4368 | const struct GNUNET_CRYPTO_PrivateKey *priv, | ||
4369 | const struct GNUNET_CRYPTO_EcdhePublicKey *ecc, | ||
4370 | void *result); | ||
4371 | |||
4372 | #define GNUNET_CRYPTO_ENCRYPT_OVERHEAD_BYTES (crypto_secretbox_MACBYTES \ | ||
4373 | + sizeof (struct \ | ||
4374 | GNUNET_CRYPTO_FoKemC)) | ||
4375 | |||
4376 | /** | ||
4377 | * Encrypt a block with #GNUNET_CRYPTO_PublicKey and derives a | ||
4378 | * #GNUNET_CRYPTO_EcdhePublicKey which is required for decryption | ||
4379 | * using ecdh to derive a symmetric key. | ||
4380 | * | ||
4381 | * Note that the result buffer for the ciphertext must be the length of | ||
4382 | * the message to encrypt plus #GNUNET_CRYPTO_ENCRYPT_OVERHEAD_BYTES. | ||
4383 | * | ||
4384 | * @param block the block to encrypt | ||
4385 | * @param size the size of the @a block | ||
4386 | * @param pub public key to encrypt for | ||
4387 | * @param result the output parameter in which to store the encrypted result | ||
4388 | * can be the same or overlap with @c block | ||
4389 | * @returns GNUNET_OK on success. | ||
4390 | */ | ||
4391 | enum GNUNET_GenericReturnValue | ||
4392 | GNUNET_CRYPTO_encrypt (const void *block, | ||
4393 | size_t size, | ||
4394 | const struct GNUNET_CRYPTO_PublicKey *pub, | ||
4395 | void *result, | ||
4396 | size_t result_size); | ||
4397 | |||
4398 | |||
4399 | /** | ||
4400 | * Decrypt a given block with #GNUNET_CRYPTO_PrivateKey and a given | ||
4401 | * #GNUNET_CRYPTO_EcdhePublicKey using ecdh to derive a symmetric key. | ||
4402 | * | ||
4403 | * @param block the data to decrypt, encoded as returned by encrypt | ||
4404 | * @param size the size of the @a block to decrypt | ||
4405 | * @param priv private key to use for ecdh | ||
4406 | * @param result address to store the result at | ||
4407 | * can be the same or overlap with @c block | ||
4408 | * @returns GNUNET_OK on success. | ||
4409 | */ | ||
4410 | enum GNUNET_GenericReturnValue | ||
4411 | GNUNET_CRYPTO_decrypt (const void *block, | ||
4412 | size_t size, | ||
4413 | const struct GNUNET_CRYPTO_PrivateKey *priv, | ||
4414 | void *result, | ||
4415 | size_t result_size); | ||
4416 | |||
4417 | |||
4418 | /** | ||
4419 | * Creates a (Base32) string representation of the public key. | ||
4420 | * The resulting string encodes a compacted representation of the key. | ||
4421 | * See also #GNUNET_CRYPTO_key_get_length. | ||
4422 | * | ||
4423 | * @param key the key. | ||
4424 | * @return the string representation of the key, or NULL on error. | ||
4425 | */ | ||
4426 | char * | ||
4427 | GNUNET_CRYPTO_public_key_to_string ( | ||
4428 | const struct GNUNET_CRYPTO_PublicKey *key); | ||
4429 | |||
4430 | |||
4431 | /** | ||
4432 | * Creates a (Base32) string representation of the private key. | ||
4433 | * The resulting string encodes a compacted representation of the key. | ||
4434 | * See also #GNUNET_CRYPTO_key_get_length. | ||
4435 | * | ||
4436 | * @param key the key. | ||
4437 | * @return the string representation of the key, or NULL on error. | ||
4438 | */ | ||
4439 | char * | ||
4440 | GNUNET_CRYPTO_private_key_to_string ( | ||
4441 | const struct GNUNET_CRYPTO_PrivateKey *key); | ||
4442 | |||
4443 | |||
4444 | /** | ||
4445 | * Parses a (Base32) string representation of the public key. | ||
4446 | * See also #GNUNET_CRYPTO_public_key_to_string. | ||
4447 | * | ||
4448 | * @param str the encoded key. | ||
4449 | * @param key where to write the key. | ||
4450 | * @return GNUNET_SYSERR on error. | ||
4451 | */ | ||
4452 | enum GNUNET_GenericReturnValue | ||
4453 | GNUNET_CRYPTO_public_key_from_string (const char*str, | ||
4454 | struct GNUNET_CRYPTO_PublicKey *key); | ||
4455 | |||
4456 | |||
4457 | /** | ||
4458 | * Parses a (Base32) string representation of the private key. | ||
4459 | * See also #GNUNET_CRYPTO_private_key_to_string. | ||
4460 | * | ||
4461 | * @param str the encoded key. | ||
4462 | * @param key where to write the key. | ||
4463 | * @return GNUNET_SYSERR on error. | ||
4464 | */ | ||
4465 | enum GNUNET_GenericReturnValue | ||
4466 | GNUNET_CRYPTO_private_key_from_string (const char*str, | ||
4467 | struct GNUNET_CRYPTO_PrivateKey *key); | ||
4468 | |||
4469 | |||
4470 | /** | ||
4471 | * Retrieves the public key representation of a private key. | ||
4472 | * | ||
4473 | * @param privkey the private key. | ||
4474 | * @param key the public key result. | ||
4475 | * @return GNUNET_SYSERR on error. | ||
4476 | */ | ||
4477 | enum GNUNET_GenericReturnValue | ||
4478 | GNUNET_CRYPTO_key_get_public (const struct | ||
4479 | GNUNET_CRYPTO_PrivateKey *privkey, | ||
4480 | struct GNUNET_CRYPTO_PublicKey *key); | ||
4481 | |||
2935 | #if 0 /* keep Emacsens' auto-indent happy */ | 4482 | #if 0 /* keep Emacsens' auto-indent happy */ |
2936 | { | 4483 | { |
2937 | #endif | 4484 | #endif |
@@ -2942,4 +4489,7 @@ GNUNET_CRYPTO_cs_verify (const struct GNUNET_CRYPTO_CsSignature *sig, | |||
2942 | 4489 | ||
2943 | /* ifndef GNUNET_CRYPTO_LIB_H */ | 4490 | /* ifndef GNUNET_CRYPTO_LIB_H */ |
2944 | #endif | 4491 | #endif |
4492 | |||
4493 | /** @} */ /* end of group addition */ | ||
4494 | |||
2945 | /* end of gnunet_crypto_lib.h */ | 4495 | /* end of gnunet_crypto_lib.h */ |
diff --git a/src/include/gnunet_curl_lib.h b/src/include/gnunet_curl_lib.h index 38acecc48..967170085 100644 --- a/src/include/gnunet_curl_lib.h +++ b/src/include/gnunet_curl_lib.h | |||
@@ -18,6 +18,9 @@ | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @addtogroup lib_extra Additional libraries | ||
22 | * @{ | ||
23 | * | ||
21 | * @file src/include/gnunet_curl_lib.h | 24 | * @file src/include/gnunet_curl_lib.h |
22 | * @brief library to make it easy to download JSON replies over HTTP | 25 | * @brief library to make it easy to download JSON replies over HTTP |
23 | * @author Sree Harsha Totakura <sreeharsha@totakura.in> | 26 | * @author Sree Harsha Totakura <sreeharsha@totakura.in> |
@@ -29,13 +32,8 @@ | |||
29 | */ | 32 | */ |
30 | #ifndef GNUNET_CURL_LIB_H | 33 | #ifndef GNUNET_CURL_LIB_H |
31 | #define GNUNET_CURL_LIB_H | 34 | #define GNUNET_CURL_LIB_H |
32 | #if HAVE_LIBCURL | 35 | |
33 | #include <curl/curl.h> | 36 | #include <curl/curl.h> |
34 | #elif HAVE_LIBGNURL | ||
35 | #include <gnurl/curl.h> | ||
36 | #else | ||
37 | #error "needs curl or gnurl" | ||
38 | #endif | ||
39 | #include "gnunet_util_lib.h" | 37 | #include "gnunet_util_lib.h" |
40 | 38 | ||
41 | 39 | ||
@@ -230,7 +228,7 @@ typedef void | |||
230 | * be executed AND cleaned up | 228 | * be executed AND cleaned up |
231 | * @param jcc callback to invoke upon completion | 229 | * @param jcc callback to invoke upon completion |
232 | * @param jcc_cls closure for @a jcc | 230 | * @param jcc_cls closure for @a jcc |
233 | * @return NULL on error (in this case, @eh is still released!) | 231 | * @return NULL on error (in this case, @a eh is still released!) |
234 | */ | 232 | */ |
235 | struct GNUNET_CURL_Job * | 233 | struct GNUNET_CURL_Job * |
236 | GNUNET_CURL_job_add (struct GNUNET_CURL_Context *ctx, | 234 | GNUNET_CURL_job_add (struct GNUNET_CURL_Context *ctx, |
@@ -252,7 +250,7 @@ GNUNET_CURL_job_add (struct GNUNET_CURL_Context *ctx, | |||
252 | * be executed AND cleaned up | 250 | * be executed AND cleaned up |
253 | * @param jcc callback to invoke upon completion | 251 | * @param jcc callback to invoke upon completion |
254 | * @param jcc_cls closure for @a jcc | 252 | * @param jcc_cls closure for @a jcc |
255 | * @return NULL on error (in this case, @eh is still released!) | 253 | * @return NULL on error (in this case, @a eh is still released!) |
256 | */ | 254 | */ |
257 | struct GNUNET_CURL_Job * | 255 | struct GNUNET_CURL_Job * |
258 | GNUNET_CURL_job_add_with_ct_json (struct GNUNET_CURL_Context *ctx, | 256 | GNUNET_CURL_job_add_with_ct_json (struct GNUNET_CURL_Context *ctx, |
@@ -310,7 +308,7 @@ GNUNET_CURL_set_tlscert (struct GNUNET_CURL_Context *ctx, | |||
310 | * @param job_headers extra headers to add for this request | 308 | * @param job_headers extra headers to add for this request |
311 | * @param jcc callback to invoke upon completion | 309 | * @param jcc callback to invoke upon completion |
312 | * @param jcc_cls closure for @a jcc | 310 | * @param jcc_cls closure for @a jcc |
313 | * @return NULL on error (in this case, @eh is still released!) | 311 | * @return NULL on error (in this case, @a eh is still released!) |
314 | */ | 312 | */ |
315 | struct GNUNET_CURL_Job * | 313 | struct GNUNET_CURL_Job * |
316 | GNUNET_CURL_job_add2 (struct GNUNET_CURL_Context *ctx, | 314 | GNUNET_CURL_job_add2 (struct GNUNET_CURL_Context *ctx, |
@@ -330,10 +328,9 @@ GNUNET_CURL_job_add2 (struct GNUNET_CURL_Context *ctx, | |||
330 | * @param eh curl easy handle for the request, will | 328 | * @param eh curl easy handle for the request, will |
331 | * be executed AND cleaned up | 329 | * be executed AND cleaned up |
332 | * @param job_headers extra headers to add for this request | 330 | * @param job_headers extra headers to add for this request |
333 | * @param max_reply_size largest acceptable response body | ||
334 | * @param jcc callback to invoke upon completion | 331 | * @param jcc callback to invoke upon completion |
335 | * @param jcc_cls closure for @a jcc | 332 | * @param jcc_cls closure for @a jcc |
336 | * @return NULL on error (in this case, @eh is still released!) | 333 | * @return NULL on error (in this case, @a eh is still released!) |
337 | */ | 334 | */ |
338 | struct GNUNET_CURL_Job * | 335 | struct GNUNET_CURL_Job * |
339 | GNUNET_CURL_job_add_raw (struct GNUNET_CURL_Context *ctx, | 336 | GNUNET_CURL_job_add_raw (struct GNUNET_CURL_Context *ctx, |
@@ -436,11 +433,13 @@ GNUNET_CURL_enable_async_scope_header (struct GNUNET_CURL_Context *ctx, | |||
436 | * | 433 | * |
437 | * @returns #GNUNET_YES iff given a valid scope ID | 434 | * @returns #GNUNET_YES iff given a valid scope ID |
438 | */ | 435 | */ |
439 | int | 436 | enum GNUNET_GenericReturnValue |
440 | GNUNET_CURL_is_valid_scope_id (const char *scope_id); | 437 | GNUNET_CURL_is_valid_scope_id (const char *scope_id); |
441 | 438 | ||
442 | 439 | ||
443 | #endif | 440 | #endif |
444 | /** @} */ /* end of group */ | 441 | /** @} */ /* end of group */ |
445 | 442 | ||
443 | /** @} */ /* end of group addition to lib_extra */ | ||
444 | |||
446 | /* end of gnunet_curl_lib.h */ | 445 | /* end of gnunet_curl_lib.h */ |
diff --git a/src/include/gnunet_datacache_lib.h b/src/include/gnunet_datacache_lib.h index b4ef346e2..2c7bf1e8f 100644 --- a/src/include/gnunet_datacache_lib.h +++ b/src/include/gnunet_datacache_lib.h | |||
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup dht_libs DHT and support libraries | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
@@ -37,6 +40,7 @@ | |||
37 | #ifndef GNUNET_DATACACHE_LIB_H | 40 | #ifndef GNUNET_DATACACHE_LIB_H |
38 | #define GNUNET_DATACACHE_LIB_H | 41 | #define GNUNET_DATACACHE_LIB_H |
39 | 42 | ||
43 | |||
40 | #include "gnunet_util_lib.h" | 44 | #include "gnunet_util_lib.h" |
41 | #include "gnunet_block_lib.h" | 45 | #include "gnunet_block_lib.h" |
42 | #include "gnunet_dht_service.h" | 46 | #include "gnunet_dht_service.h" |
@@ -208,3 +212,5 @@ GNUNET_DATACACHE_get_closest (struct GNUNET_DATACACHE_Handle *h, | |||
208 | #endif | 212 | #endif |
209 | 213 | ||
210 | /** @} */ /* end of group */ | 214 | /** @} */ /* end of group */ |
215 | |||
216 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_datacache_plugin.h b/src/include/gnunet_datacache_plugin.h index 7e63d87d9..e144e155e 100644 --- a/src/include/gnunet_datacache_plugin.h +++ b/src/include/gnunet_datacache_plugin.h | |||
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup dht_libs DHT and support libraries | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
@@ -31,6 +34,7 @@ | |||
31 | #ifndef PLUGIN_DATACACHE_H | 34 | #ifndef PLUGIN_DATACACHE_H |
32 | #define PLUGIN_DATACACHE_H | 35 | #define PLUGIN_DATACACHE_H |
33 | 36 | ||
37 | |||
34 | #include "gnunet_datacache_lib.h" | 38 | #include "gnunet_datacache_lib.h" |
35 | 39 | ||
36 | #ifdef __cplusplus | 40 | #ifdef __cplusplus |
@@ -180,3 +184,5 @@ struct GNUNET_DATACACHE_PluginFunctions | |||
180 | #endif | 184 | #endif |
181 | 185 | ||
182 | /** @} */ /* end of group */ | 186 | /** @} */ /* end of group */ |
187 | |||
188 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_datastore_plugin.h b/src/include/gnunet_datastore_plugin.h index 113f6b2f2..c4f31c7ce 100644 --- a/src/include/gnunet_datastore_plugin.h +++ b/src/include/gnunet_datastore_plugin.h | |||
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup fs_l2 File sharing and support services/libraries | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
@@ -31,6 +34,7 @@ | |||
31 | #ifndef PLUGIN_DATASTORE_H | 34 | #ifndef PLUGIN_DATASTORE_H |
32 | #define PLUGIN_DATASTORE_H | 35 | #define PLUGIN_DATASTORE_H |
33 | 36 | ||
37 | |||
34 | #include "gnunet_block_lib.h" | 38 | #include "gnunet_block_lib.h" |
35 | #include "gnunet_configuration_lib.h" | 39 | #include "gnunet_configuration_lib.h" |
36 | #include "gnunet_datastore_service.h" | 40 | #include "gnunet_datastore_service.h" |
@@ -98,17 +102,17 @@ struct GNUNET_DATASTORE_PluginEnvironment | |||
98 | * @return #GNUNET_OK to keep the item | 102 | * @return #GNUNET_OK to keep the item |
99 | * #GNUNET_NO to delete the item | 103 | * #GNUNET_NO to delete the item |
100 | */ | 104 | */ |
101 | typedef int | 105 | typedef enum GNUNET_GenericReturnValue |
102 | (*PluginDatumProcessor) (void *cls, | 106 | (*PluginDatumProcessor)(void *cls, |
103 | const struct GNUNET_HashCode *key, | 107 | const struct GNUNET_HashCode *key, |
104 | uint32_t size, | 108 | uint32_t size, |
105 | const void *data, | 109 | const void *data, |
106 | enum GNUNET_BLOCK_Type type, | 110 | enum GNUNET_BLOCK_Type type, |
107 | uint32_t priority, | 111 | uint32_t priority, |
108 | uint32_t anonymity, | 112 | uint32_t anonymity, |
109 | uint32_t replication, | 113 | uint32_t replication, |
110 | struct GNUNET_TIME_Absolute expiration, | 114 | struct GNUNET_TIME_Absolute expiration, |
111 | uint64_t uid); | 115 | uint64_t uid); |
112 | 116 | ||
113 | 117 | ||
114 | /** | 118 | /** |
@@ -377,3 +381,5 @@ struct GNUNET_DATASTORE_PluginFunctions | |||
377 | #endif | 381 | #endif |
378 | 382 | ||
379 | /** @} */ /* end of group */ | 383 | /** @} */ /* end of group */ |
384 | |||
385 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_datastore_service.h b/src/include/gnunet_datastore_service.h index c99db67bc..153387238 100644 --- a/src/include/gnunet_datastore_service.h +++ b/src/include/gnunet_datastore_service.h | |||
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup fs_l2 File sharing and support services/libraries | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
@@ -39,6 +42,7 @@ | |||
39 | #ifndef GNUNET_DATASTORE_SERVICE_H | 42 | #ifndef GNUNET_DATASTORE_SERVICE_H |
40 | #define GNUNET_DATASTORE_SERVICE_H | 43 | #define GNUNET_DATASTORE_SERVICE_H |
41 | 44 | ||
45 | |||
42 | #include "gnunet_util_lib.h" | 46 | #include "gnunet_util_lib.h" |
43 | #include "gnunet_block_lib.h" | 47 | #include "gnunet_block_lib.h" |
44 | 48 | ||
@@ -361,3 +365,5 @@ GNUNET_DATASTORE_cancel (struct GNUNET_DATASTORE_QueueEntry *qe); | |||
361 | #endif | 365 | #endif |
362 | 366 | ||
363 | /** @} */ /* end of group */ | 367 | /** @} */ /* end of group */ |
368 | |||
369 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_db_lib.h b/src/include/gnunet_db_lib.h index e88e836f6..1ff665c2b 100644 --- a/src/include/gnunet_db_lib.h +++ b/src/include/gnunet_db_lib.h | |||
@@ -25,6 +25,7 @@ | |||
25 | #ifndef GNUNET_DB_LIB_H | 25 | #ifndef GNUNET_DB_LIB_H |
26 | #define GNUNET_DB_LIB_H | 26 | #define GNUNET_DB_LIB_H |
27 | 27 | ||
28 | |||
28 | #include "gnunet_common.h" | 29 | #include "gnunet_common.h" |
29 | 30 | ||
30 | /** | 31 | /** |
diff --git a/src/include/gnunet_dht_block_types.h b/src/include/gnunet_dht_block_types.h index 1829897ca..ab46af410 100644 --- a/src/include/gnunet_dht_block_types.h +++ b/src/include/gnunet_dht_block_types.h | |||
@@ -68,9 +68,9 @@ enum GNUNET_BLOCK_Type | |||
68 | 68 | ||
69 | 69 | ||
70 | /** | 70 | /** |
71 | * Type of a block that contains a HELLO for a peer. | 71 | * Legacy type of a block that contains a HELLO for a peer. |
72 | */ | 72 | */ |
73 | GNUNET_BLOCK_TYPE_DHT_HELLO = 7, | 73 | GNUNET_BLOCK_TYPE_LEGACY_HELLO = 7, |
74 | 74 | ||
75 | 75 | ||
76 | /** | 76 | /** |
@@ -106,7 +106,7 @@ enum GNUNET_BLOCK_Type | |||
106 | /** | 106 | /** |
107 | * Type of a block that contains a DHT-NG HELLO for a peer. | 107 | * Type of a block that contains a DHT-NG HELLO for a peer. |
108 | */ | 108 | */ |
109 | GNUNET_BLOCK_TYPE_DHT_URL_HELLO = 13, | 109 | GNUNET_BLOCK_TYPE_DHT_HELLO = 13, |
110 | 110 | ||
111 | 111 | ||
112 | /** | 112 | /** |
diff --git a/src/include/gnunet_dht_service.h b/src/include/gnunet_dht_service.h index ebc6e2767..a1ea31c25 100644 --- a/src/include/gnunet_dht_service.h +++ b/src/include/gnunet_dht_service.h | |||
@@ -19,6 +19,11 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup Backbone | ||
23 | * @{ | ||
24 | * @addtogroup dht_libs DHT and support libraries | ||
25 | * @{ | ||
26 | * | ||
22 | * @author Christian Grothoff | 27 | * @author Christian Grothoff |
23 | * | 28 | * |
24 | * @file | 29 | * @file |
@@ -35,9 +40,9 @@ | |||
35 | #ifndef GNUNET_DHT_SERVICE_H | 40 | #ifndef GNUNET_DHT_SERVICE_H |
36 | #define GNUNET_DHT_SERVICE_H | 41 | #define GNUNET_DHT_SERVICE_H |
37 | 42 | ||
43 | |||
38 | #include "gnunet_util_lib.h" | 44 | #include "gnunet_util_lib.h" |
39 | #include "gnunet_block_lib.h" | 45 | #include "gnunet_block_lib.h" |
40 | #include "gnunet_hello_lib.h" | ||
41 | 46 | ||
42 | #ifdef __cplusplus | 47 | #ifdef __cplusplus |
43 | extern "C" | 48 | extern "C" |
@@ -138,7 +143,7 @@ struct GNUNET_DHT_HopSignature | |||
138 | /** | 143 | /** |
139 | * Hash over the payload of the block. | 144 | * Hash over the payload of the block. |
140 | */ | 145 | */ |
141 | struct GNUNET_HashCode h_data; | 146 | struct GNUNET_HashCode h_data GNUNET_PACKED; |
142 | 147 | ||
143 | /** | 148 | /** |
144 | * Previous hop the message was received from. All zeros | 149 | * Previous hop the message was received from. All zeros |
@@ -580,3 +585,7 @@ GNUNET_DHT_hello_offer (struct GNUNET_DHT_Handle *dht_handle, | |||
580 | #endif | 585 | #endif |
581 | 586 | ||
582 | /** @} */ /* end of group dht */ | 587 | /** @} */ /* end of group dht */ |
588 | |||
589 | /** @} */ /* end of group addition */ | ||
590 | |||
591 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_dhtu_plugin.h b/src/include/gnunet_dhtu_plugin.h index fa0b5f667..0503dda1c 100644 --- a/src/include/gnunet_dhtu_plugin.h +++ b/src/include/gnunet_dhtu_plugin.h | |||
@@ -27,6 +27,7 @@ | |||
27 | #ifndef PLUGIN_DHTU_H | 27 | #ifndef PLUGIN_DHTU_H |
28 | #define PLUGIN_DHTU_H | 28 | #define PLUGIN_DHTU_H |
29 | 29 | ||
30 | |||
30 | #include "gnunet_util_lib.h" | 31 | #include "gnunet_util_lib.h" |
31 | 32 | ||
32 | 33 | ||
@@ -119,7 +120,7 @@ struct GNUNET_DHTU_PluginEnvironment | |||
119 | * @param cls the closure | 120 | * @param cls the closure |
120 | * @param target handle to the target, | 121 | * @param target handle to the target, |
121 | * pointer will remain valid until @e disconnect_cb is called | 122 | * pointer will remain valid until @e disconnect_cb is called |
122 | * @para pid peer identity, | 123 | * @param pid peer identity, |
123 | * pointer will remain valid until @e disconnect_cb is called | 124 | * pointer will remain valid until @e disconnect_cb is called |
124 | * @param[out] ctx storage space for DHT to use in association with this target | 125 | * @param[out] ctx storage space for DHT to use in association with this target |
125 | */ | 126 | */ |
diff --git a/src/include/gnunet_disk_lib.h b/src/include/gnunet_disk_lib.h index 7dfd9ccf1..2aec55851 100644 --- a/src/include/gnunet_disk_lib.h +++ b/src/include/gnunet_disk_lib.h | |||
@@ -18,6 +18,10 @@ | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @addtogroup libgnunetutil | ||
22 | * Multi-function utilities library for GNUnet programs | ||
23 | * @{ | ||
24 | * | ||
21 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
22 | * | 26 | * |
23 | * @file | 27 | * @file |
@@ -27,6 +31,11 @@ | |||
27 | * Disk IO APIs | 31 | * Disk IO APIs |
28 | * @{ | 32 | * @{ |
29 | */ | 33 | */ |
34 | |||
35 | #if ! defined (__GNUNET_UTIL_LIB_H_INSIDE__) | ||
36 | #error "Only <gnunet_util_lib.h> can be included directly." | ||
37 | #endif | ||
38 | |||
30 | #ifndef GNUNET_DISK_LIB_H | 39 | #ifndef GNUNET_DISK_LIB_H |
31 | #define GNUNET_DISK_LIB_H | 40 | #define GNUNET_DISK_LIB_H |
32 | 41 | ||
@@ -72,6 +81,7 @@ struct GNUNET_DISK_FileHandle | |||
72 | or unsigned long long, this IS platform dependent; | 81 | or unsigned long long, this IS platform dependent; |
73 | but "stdlib.h" should be portable 'enough' to be | 82 | but "stdlib.h" should be portable 'enough' to be |
74 | unconditionally available... */ | 83 | unconditionally available... */ |
84 | |||
75 | #include <stdlib.h> | 85 | #include <stdlib.h> |
76 | #include "gnunet_configuration_lib.h" | 86 | #include "gnunet_configuration_lib.h" |
77 | #include "gnunet_scheduler_lib.h" | 87 | #include "gnunet_scheduler_lib.h" |
@@ -670,7 +680,7 @@ GNUNET_DISK_directory_scan (const char *dir_name, | |||
670 | * Currently, the glob_pattern only supports asterisks in the last | 680 | * Currently, the glob_pattern only supports asterisks in the last |
671 | * path component. | 681 | * path component. |
672 | * | 682 | * |
673 | * @param glob_patterb the glob pattern to search for | 683 | * @param glob_pattern the glob pattern to search for |
674 | * @param callback the method to call for each file | 684 | * @param callback the method to call for each file |
675 | * @param callback_cls closure for @a callback | 685 | * @param callback_cls closure for @a callback |
676 | * @return the number of files found, -1 on error | 686 | * @return the number of files found, -1 on error |
@@ -815,4 +825,6 @@ GNUNET_DISK_file_sync (const struct GNUNET_DISK_FileHandle *h); | |||
815 | 825 | ||
816 | /** @} */ /* end of group */ | 826 | /** @} */ /* end of group */ |
817 | 827 | ||
828 | /** @} */ /* end of group addition */ | ||
829 | |||
818 | /* end of gnunet_disk_lib.h */ | 830 | /* end of gnunet_disk_lib.h */ |
diff --git a/src/include/gnunet_dns_service.h b/src/include/gnunet_dns_service.h index 20f0f13ee..b5741a7e2 100644 --- a/src/include/gnunet_dns_service.h +++ b/src/include/gnunet_dns_service.h | |||
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup vpn_suite VPN services and libraries | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
@@ -33,6 +36,7 @@ | |||
33 | #ifndef GNUNET_DNS_SERVICE_H | 36 | #ifndef GNUNET_DNS_SERVICE_H |
34 | #define GNUNET_DNS_SERVICE_H | 37 | #define GNUNET_DNS_SERVICE_H |
35 | 38 | ||
39 | |||
36 | #include "gnunet_util_lib.h" | 40 | #include "gnunet_util_lib.h" |
37 | 41 | ||
38 | 42 | ||
@@ -191,3 +195,5 @@ GNUNET_DNS_disconnect (struct GNUNET_DNS_Handle *dh); | |||
191 | #endif | 195 | #endif |
192 | 196 | ||
193 | /** @} */ /* end of group */ | 197 | /** @} */ /* end of group */ |
198 | |||
199 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_dnsparser_lib.h b/src/include/gnunet_dnsparser_lib.h index f77073264..9a84f346f 100644 --- a/src/include/gnunet_dnsparser_lib.h +++ b/src/include/gnunet_dnsparser_lib.h | |||
@@ -18,7 +18,15 @@ | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) | ||
22 | #error "Only <gnunet_util_lib.h> can be included directly." | ||
23 | #endif | ||
24 | |||
25 | |||
21 | /** | 26 | /** |
27 | * @addtogroup libgnunetutil | ||
28 | * @{ | ||
29 | * | ||
22 | * @author Philipp Toelke | 30 | * @author Philipp Toelke |
23 | * @author Christian Grothoff | 31 | * @author Christian Grothoff |
24 | * | 32 | * |
@@ -32,8 +40,6 @@ | |||
32 | #ifndef GNUNET_DNSPARSER_LIB_H | 40 | #ifndef GNUNET_DNSPARSER_LIB_H |
33 | #define GNUNET_DNSPARSER_LIB_H | 41 | #define GNUNET_DNSPARSER_LIB_H |
34 | 42 | ||
35 | #include "gnunet_util_lib.h" | ||
36 | |||
37 | /** | 43 | /** |
38 | * Maximum length of a label in DNS. | 44 | * Maximum length of a label in DNS. |
39 | */ | 45 | */ |
@@ -78,6 +84,7 @@ | |||
78 | #define GNUNET_DNSPARSER_TYPE_NSEC3 50 | 84 | #define GNUNET_DNSPARSER_TYPE_NSEC3 50 |
79 | #define GNUNET_DNSPARSER_TYPE_NSEC3PARAM 51 | 85 | #define GNUNET_DNSPARSER_TYPE_NSEC3PARAM 51 |
80 | #define GNUNET_DNSPARSER_TYPE_TLSA 52 | 86 | #define GNUNET_DNSPARSER_TYPE_TLSA 52 |
87 | #define GNUNET_DNSPARSER_TYPE_SMIMEA 53 | ||
81 | #define GNUNET_DNSPARSER_TYPE_HIP 55 | 88 | #define GNUNET_DNSPARSER_TYPE_HIP 55 |
82 | #define GNUNET_DNSPARSER_TYPE_CDS 59 | 89 | #define GNUNET_DNSPARSER_TYPE_CDS 59 |
83 | #define GNUNET_DNSPARSER_TYPE_CDNSKEY 60 | 90 | #define GNUNET_DNSPARSER_TYPE_CDNSKEY 60 |
@@ -172,6 +179,33 @@ struct GNUNET_DNSPARSER_SrvRecord | |||
172 | 179 | ||
173 | 180 | ||
174 | /** | 181 | /** |
182 | * Information from URI records (RFC 7553). | ||
183 | */ | ||
184 | struct GNUNET_DNSPARSER_UriRecord | ||
185 | { | ||
186 | /** | ||
187 | * URI of the target, | ||
188 | * where the URI is as specified in RFC 3986. | ||
189 | */ | ||
190 | char *target; | ||
191 | |||
192 | /** | ||
193 | * Preference for this entry (lower value is higher preference). Clients | ||
194 | * will contact hosts from the lowest-priority group first and fall back | ||
195 | * to higher priorities if the low-priority entries are unavailable. | ||
196 | */ | ||
197 | uint16_t priority; | ||
198 | |||
199 | /** | ||
200 | * Relative weight for records with the same priority. Clients will use | ||
201 | * the hosts of the same (lowest) priority with a probability proportional | ||
202 | * to the weight given. | ||
203 | */ | ||
204 | uint16_t weight; | ||
205 | }; | ||
206 | |||
207 | |||
208 | /** | ||
175 | * DNS CERT types as defined in RFC 4398. | 209 | * DNS CERT types as defined in RFC 4398. |
176 | */ | 210 | */ |
177 | enum GNUNET_DNSPARSER_CertType | 211 | enum GNUNET_DNSPARSER_CertType |
@@ -473,6 +507,11 @@ struct GNUNET_DNSPARSER_Record | |||
473 | struct GNUNET_DNSPARSER_SrvRecord *srv; | 507 | struct GNUNET_DNSPARSER_SrvRecord *srv; |
474 | 508 | ||
475 | /** | 509 | /** |
510 | * URI data for URI records. | ||
511 | */ | ||
512 | struct GNUNET_DNSPARSER_UriRecord *uri; | ||
513 | |||
514 | /** | ||
476 | * Raw data for all other types. | 515 | * Raw data for all other types. |
477 | */ | 516 | */ |
478 | struct GNUNET_DNSPARSER_RawRecord raw; | 517 | struct GNUNET_DNSPARSER_RawRecord raw; |
@@ -737,6 +776,25 @@ GNUNET_DNSPARSER_builder_add_srv (char *dst, | |||
737 | size_t *off, | 776 | size_t *off, |
738 | const struct GNUNET_DNSPARSER_SrvRecord *srv); | 777 | const struct GNUNET_DNSPARSER_SrvRecord *srv); |
739 | 778 | ||
779 | |||
780 | /** | ||
781 | * Add an URI record to the UDP packet at the given location. | ||
782 | * | ||
783 | * @param dst where to write the URI record | ||
784 | * @param dst_len number of bytes in @a dst | ||
785 | * @param off pointer to offset where to write the URI information (increment by bytes used) | ||
786 | * can also change if there was an error | ||
787 | * @param uri URI information to write | ||
788 | * @return #GNUNET_SYSERR if @a uri is invalid | ||
789 | * #GNUNET_NO if @a uri did not fit | ||
790 | * #GNUNET_OK if @a uri was added to @a dst | ||
791 | */ | ||
792 | int | ||
793 | GNUNET_DNSPARSER_builder_add_uri (char *dst, | ||
794 | size_t dst_len, | ||
795 | size_t *off, | ||
796 | const struct GNUNET_DNSPARSER_UriRecord *uri); | ||
797 | |||
740 | /* ***************** low-level parsing API ******************** */ | 798 | /* ***************** low-level parsing API ******************** */ |
741 | 799 | ||
742 | /** | 800 | /** |
@@ -847,6 +905,21 @@ GNUNET_DNSPARSER_parse_srv (const char *udp_payload, | |||
847 | size_t udp_payload_length, | 905 | size_t udp_payload_length, |
848 | size_t *off); | 906 | size_t *off); |
849 | 907 | ||
908 | |||
909 | /** | ||
910 | * Parse a DNS URI record. | ||
911 | * | ||
912 | * @param udp_payload reference to UDP packet | ||
913 | * @param udp_payload_length length of @a udp_payload | ||
914 | * @param off pointer to the offset of the query to parse in the URI record (to be | ||
915 | * incremented by the size of the record), unchanged on error | ||
916 | * @return the parsed URI record, NULL on error | ||
917 | */ | ||
918 | struct GNUNET_DNSPARSER_UriRecord * | ||
919 | GNUNET_DNSPARSER_parse_uri (const char *udp_payload, | ||
920 | size_t udp_payload_length, | ||
921 | size_t *off); | ||
922 | |||
850 | /* ***************** low-level duplication API ******************** */ | 923 | /* ***************** low-level duplication API ******************** */ |
851 | 924 | ||
852 | /** | 925 | /** |
@@ -903,6 +976,16 @@ GNUNET_DNSPARSER_duplicate_srv_record (const struct | |||
903 | GNUNET_DNSPARSER_SrvRecord *r); | 976 | GNUNET_DNSPARSER_SrvRecord *r); |
904 | 977 | ||
905 | 978 | ||
979 | /** | ||
980 | * Duplicate (deep-copy) the given DNS record | ||
981 | * | ||
982 | * @param r the record | ||
983 | * @return the newly allocated record | ||
984 | */ | ||
985 | struct GNUNET_DNSPARSER_UriRecord * | ||
986 | GNUNET_DNSPARSER_duplicate_uri_record (const struct | ||
987 | GNUNET_DNSPARSER_UriRecord *r); | ||
988 | |||
906 | /* ***************** low-level deallocation API ******************** */ | 989 | /* ***************** low-level deallocation API ******************** */ |
907 | 990 | ||
908 | /** | 991 | /** |
@@ -933,6 +1016,15 @@ GNUNET_DNSPARSER_free_srv (struct GNUNET_DNSPARSER_SrvRecord *srv); | |||
933 | 1016 | ||
934 | 1017 | ||
935 | /** | 1018 | /** |
1019 | * Free URI information record. | ||
1020 | * | ||
1021 | * @param uri record to free | ||
1022 | */ | ||
1023 | void | ||
1024 | GNUNET_DNSPARSER_free_uri (struct GNUNET_DNSPARSER_UriRecord *uri); | ||
1025 | |||
1026 | |||
1027 | /** | ||
936 | * Free SOA information record. | 1028 | * Free SOA information record. |
937 | * | 1029 | * |
938 | * @param soa record to free | 1030 | * @param soa record to free |
@@ -978,3 +1070,5 @@ GNUNET_DNSPARSER_hex_to_bin (const char *hex, | |||
978 | #endif | 1070 | #endif |
979 | 1071 | ||
980 | /** @} */ /* end of group */ | 1072 | /** @} */ /* end of group */ |
1073 | |||
1074 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_dnsstub_lib.h b/src/include/gnunet_dnsstub_lib.h index 4e93105bb..fa5151a8c 100644 --- a/src/include/gnunet_dnsstub_lib.h +++ b/src/include/gnunet_dnsstub_lib.h | |||
@@ -18,7 +18,14 @@ | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) | ||
22 | #error "Only <gnunet_util_lib.h> can be included directly." | ||
23 | #endif | ||
24 | |||
21 | /** | 25 | /** |
26 | * @addtogroup libgnunetutil | ||
27 | * @{ | ||
28 | * | ||
22 | * @author Christian Grothoff | 29 | * @author Christian Grothoff |
23 | * | 30 | * |
24 | * @file | 31 | * @file |
@@ -31,6 +38,7 @@ | |||
31 | #ifndef GNUNET_DNSSTUB_LIB_H | 38 | #ifndef GNUNET_DNSSTUB_LIB_H |
32 | #define GNUNET_DNSSTUB_LIB_H | 39 | #define GNUNET_DNSSTUB_LIB_H |
33 | 40 | ||
41 | |||
34 | #include "gnunet_util_lib.h" | 42 | #include "gnunet_util_lib.h" |
35 | 43 | ||
36 | /** | 44 | /** |
@@ -86,7 +94,7 @@ GNUNET_DNSSTUB_add_dns_sa (struct GNUNET_DNSSTUB_Context *ctx, | |||
86 | * Only effective for requests issued after this call. | 94 | * Only effective for requests issued after this call. |
87 | * | 95 | * |
88 | * @param ctx resolver context to modify | 96 | * @param ctx resolver context to modify |
89 | * @param retry_frequ how long to wait between retries | 97 | * @param retry_freq how long to wait between retries |
90 | */ | 98 | */ |
91 | void | 99 | void |
92 | GNUNET_DNSSTUB_set_retry (struct GNUNET_DNSSTUB_Context *ctx, | 100 | GNUNET_DNSSTUB_set_retry (struct GNUNET_DNSSTUB_Context *ctx, |
@@ -147,3 +155,5 @@ GNUNET_DNSSTUB_resolve_cancel (struct GNUNET_DNSSTUB_RequestSocket *rs); | |||
147 | #endif | 155 | #endif |
148 | 156 | ||
149 | /** @} */ /* end of group */ | 157 | /** @} */ /* end of group */ |
158 | |||
159 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_error_codes.h b/src/include/gnunet_error_codes.h new file mode 100644 index 000000000..aa897afe0 --- /dev/null +++ b/src/include/gnunet_error_codes.h | |||
@@ -0,0 +1,242 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2012-2022 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your 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 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @file include/taler_error_codes.h | ||
22 | * @brief GNUnet error codes, generated via https://gana.gnunet.org/ | ||
23 | * | ||
24 | * Do NOT edit this file, it is generated! | ||
25 | */ | ||
26 | #ifndef GNUNET_ERROR_CODES_H | ||
27 | #define GNUNET_ERROR_CODES_H | ||
28 | |||
29 | #ifdef __cplusplus | ||
30 | extern "C" { | ||
31 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
32 | } | ||
33 | #endif | ||
34 | #endif | ||
35 | |||
36 | #include <limits.h> | ||
37 | |||
38 | |||
39 | /** | ||
40 | * Taler error codes. | ||
41 | */ | ||
42 | enum GNUNET_ErrorCode | ||
43 | { | ||
44 | |||
45 | |||
46 | /** | ||
47 | * No error (success). | ||
48 | * Returned with an HTTP status code of #MHD_HTTP_UNINITIALIZED (0). | ||
49 | */ | ||
50 | GNUNET_EC_NONE = 0, | ||
51 | |||
52 | |||
53 | /** | ||
54 | * Unknown and unspecified error. | ||
55 | * Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500). | ||
56 | */ | ||
57 | GNUNET_EC_UNKNOWN = 1, | ||
58 | |||
59 | |||
60 | /** | ||
61 | * Communication with service failed. | ||
62 | * Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500). | ||
63 | */ | ||
64 | GNUNET_EC_SERVICE_COMMUNICATION_FAILED = 101, | ||
65 | |||
66 | |||
67 | /** | ||
68 | * Ego not found. | ||
69 | * Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404). | ||
70 | */ | ||
71 | GNUNET_EC_IDENTITY_NOT_FOUND = 200, | ||
72 | |||
73 | |||
74 | /** | ||
75 | * Identifier already in use for another ego. | ||
76 | * Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409). | ||
77 | */ | ||
78 | GNUNET_EC_IDENTITY_NAME_CONFLICT = 201, | ||
79 | |||
80 | |||
81 | /** | ||
82 | * The given ego is invalid or malformed. | ||
83 | * Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500). | ||
84 | */ | ||
85 | GNUNET_EC_IDENTITY_INVALID = 202, | ||
86 | |||
87 | |||
88 | /** | ||
89 | * Unknown namestore error. | ||
90 | * Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500). | ||
91 | */ | ||
92 | GNUNET_EC_NAMESTORE_UNKNOWN = 5000, | ||
93 | |||
94 | |||
95 | /** | ||
96 | * Zone iteration failed. | ||
97 | * Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500). | ||
98 | */ | ||
99 | GNUNET_EC_NAMESTORE_ITERATION_FAILED = 5001, | ||
100 | |||
101 | |||
102 | /** | ||
103 | * Zone not found. | ||
104 | * Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404). | ||
105 | */ | ||
106 | GNUNET_EC_NAMESTORE_ZONE_NOT_FOUND = 5002, | ||
107 | |||
108 | |||
109 | /** | ||
110 | * Record not found. | ||
111 | * Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404). | ||
112 | */ | ||
113 | GNUNET_EC_NAMESTORE_RECORD_NOT_FOUND = 5003, | ||
114 | |||
115 | |||
116 | /** | ||
117 | * Zone iteration failed. | ||
118 | * Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500). | ||
119 | */ | ||
120 | GNUNET_EC_NAMESTORE_RECORD_DELETE_FAILED = 5004, | ||
121 | |||
122 | |||
123 | /** | ||
124 | * Zone does not contain any records. | ||
125 | * Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404). | ||
126 | */ | ||
127 | GNUNET_EC_NAMESTORE_ZONE_EMPTY = 5005, | ||
128 | |||
129 | |||
130 | /** | ||
131 | * Failed to lookup record. | ||
132 | * Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500). | ||
133 | */ | ||
134 | GNUNET_EC_NAMESTORE_LOOKUP_ERROR = 5006, | ||
135 | |||
136 | |||
137 | /** | ||
138 | * No records given. | ||
139 | * Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400). | ||
140 | */ | ||
141 | GNUNET_EC_NAMESTORE_NO_RECORDS_GIVEN = 5007, | ||
142 | |||
143 | |||
144 | /** | ||
145 | * Record data invalid. | ||
146 | * Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400). | ||
147 | */ | ||
148 | GNUNET_EC_NAMESTORE_RECORD_DATA_INVALID = 5008, | ||
149 | |||
150 | |||
151 | /** | ||
152 | * No label given. | ||
153 | * Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400). | ||
154 | */ | ||
155 | GNUNET_EC_NAMESTORE_NO_LABEL_GIVEN = 5009, | ||
156 | |||
157 | |||
158 | /** | ||
159 | * No results given. | ||
160 | * Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404). | ||
161 | */ | ||
162 | GNUNET_EC_NAMESTORE_NO_RESULTS = 5010, | ||
163 | |||
164 | |||
165 | /** | ||
166 | * Record already exists. | ||
167 | * Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409). | ||
168 | */ | ||
169 | GNUNET_EC_NAMESTORE_RECORD_EXISTS = 5011, | ||
170 | |||
171 | |||
172 | /** | ||
173 | * Record size exceeds maximum limit. | ||
174 | * Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500). | ||
175 | */ | ||
176 | GNUNET_EC_NAMESTORE_RECORD_TOO_BIG = 5012, | ||
177 | |||
178 | |||
179 | /** | ||
180 | * There was an error in the database backend. | ||
181 | * Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500). | ||
182 | */ | ||
183 | GNUNET_EC_NAMESTORE_BACKEND_FAILED = 5013, | ||
184 | |||
185 | |||
186 | /** | ||
187 | * Failed to store the given records. | ||
188 | * Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500). | ||
189 | */ | ||
190 | GNUNET_EC_NAMESTORE_STORE_FAILED = 5014, | ||
191 | |||
192 | |||
193 | /** | ||
194 | * Label invalid or malformed. | ||
195 | * Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400). | ||
196 | */ | ||
197 | GNUNET_EC_NAMESTORE_LABEL_INVALID = 5015, | ||
198 | |||
199 | |||
200 | }; | ||
201 | |||
202 | |||
203 | /** | ||
204 | * Returns a hint for a given error code. | ||
205 | * | ||
206 | * @param ec the error code. | ||
207 | * @return the hint if it could be found, otherwise "<no hint found>" | ||
208 | */ | ||
209 | const char * | ||
210 | GNUNET_ErrorCode_get_hint (enum GNUNET_ErrorCode ec); | ||
211 | |||
212 | |||
213 | /** | ||
214 | * Return HTTP status for a given error code. | ||
215 | * | ||
216 | * @param ec the error code. | ||
217 | * @return the HTTP status code for the given @a ec, UINT_MAX if not found | ||
218 | */ | ||
219 | unsigned int | ||
220 | GNUNET_ErrorCode_get_http_status (enum GNUNET_ErrorCode ec); | ||
221 | |||
222 | |||
223 | /** | ||
224 | * Return HTTP status for a given error code that is guaranteed | ||
225 | * to work (no corner cases). | ||
226 | * | ||
227 | * @param ec the error code. | ||
228 | * @return the HTTP status code for the given @a ec, 500 if | ||
229 | * the @a ec is not found or is a client-side code | ||
230 | */ | ||
231 | unsigned int | ||
232 | GNUNET_ErrorCode_get_http_status_safe (enum GNUNET_ErrorCode ec); | ||
233 | |||
234 | |||
235 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
236 | { | ||
237 | #endif | ||
238 | #ifdef __cplusplus | ||
239 | } | ||
240 | #endif | ||
241 | |||
242 | #endif | ||
diff --git a/src/include/gnunet_fragmentation_lib.h b/src/include/gnunet_fragmentation_lib.h deleted file mode 100644 index c964b5434..000000000 --- a/src/include/gnunet_fragmentation_lib.h +++ /dev/null | |||
@@ -1,230 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2009, 2011, 2015 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your 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 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @author Christian Grothoff | ||
22 | * | ||
23 | * @file | ||
24 | * Library to help fragment messages | ||
25 | * | ||
26 | * @defgroup fragmentation Fragmentation library | ||
27 | * Library to help fragment messages | ||
28 | * @{ | ||
29 | * | ||
30 | * @todo Consider additional flow-control for sending from | ||
31 | * fragmentation based on continuations. | ||
32 | */ | ||
33 | |||
34 | #ifndef GNUNET_FRAGMENTATION_LIB_H | ||
35 | #define GNUNET_FRAGMENTATION_LIB_H | ||
36 | |||
37 | #include "gnunet_util_lib.h" | ||
38 | #include "gnunet_bandwidth_lib.h" | ||
39 | #include "gnunet_statistics_service.h" | ||
40 | |||
41 | #ifdef __cplusplus | ||
42 | extern "C" | ||
43 | { | ||
44 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
45 | } | ||
46 | #endif | ||
47 | #endif | ||
48 | |||
49 | |||
50 | /** | ||
51 | * Fragmentation context. | ||
52 | */ | ||
53 | struct GNUNET_FRAGMENT_Context; | ||
54 | |||
55 | |||
56 | /** | ||
57 | * Function that is called with messages created by the fragmentation | ||
58 | * module. In the case of the 'proc' callback of the | ||
59 | * #GNUNET_FRAGMENT_context_create() function, this function must | ||
60 | * eventually call #GNUNET_FRAGMENT_context_transmission_done(). | ||
61 | * | ||
62 | * @param cls closure | ||
63 | * @param msg the message that was created | ||
64 | */ | ||
65 | typedef void | ||
66 | (*GNUNET_FRAGMENT_MessageProcessor) (void *cls, | ||
67 | const struct GNUNET_MessageHeader *msg); | ||
68 | |||
69 | |||
70 | /** | ||
71 | * Create a fragmentation context for the given message. | ||
72 | * Fragments the message into fragments of size @a mtu or | ||
73 | * less. Calls @a proc on each un-acknowledged fragment, | ||
74 | * using both the expected @a msg_delay between messages and | ||
75 | * acknowledgements and the given @a tracker to guide the | ||
76 | * frequency of calls to @a proc. | ||
77 | * | ||
78 | * @param stats statistics context | ||
79 | * @param mtu the maximum message size for each fragment | ||
80 | * @param tracker bandwidth tracker to use for flow control (can be NULL) | ||
81 | * @param msg_delay initial delay to insert between fragment transmissions | ||
82 | * based on previous messages | ||
83 | * @param ack_delay expected delay between fragment transmission | ||
84 | * and ACK based on previous messages | ||
85 | * @param msg the message to fragment | ||
86 | * @param proc function to call for each fragment to transmit | ||
87 | * @param proc_cls closure for proc | ||
88 | * @return the fragmentation context | ||
89 | */ | ||
90 | struct GNUNET_FRAGMENT_Context * | ||
91 | GNUNET_FRAGMENT_context_create (struct GNUNET_STATISTICS_Handle *stats, | ||
92 | uint16_t mtu, | ||
93 | struct GNUNET_BANDWIDTH_Tracker *tracker, | ||
94 | struct GNUNET_TIME_Relative msg_delay, | ||
95 | struct GNUNET_TIME_Relative ack_delay, | ||
96 | const struct GNUNET_MessageHeader *msg, | ||
97 | GNUNET_FRAGMENT_MessageProcessor proc, | ||
98 | void *proc_cls); | ||
99 | |||
100 | |||
101 | /** | ||
102 | * Continuation to call from the 'proc' function after the fragment | ||
103 | * has been transmitted (and hence the next fragment can now be | ||
104 | * given to proc). | ||
105 | * | ||
106 | * @param fc fragmentation context | ||
107 | */ | ||
108 | void | ||
109 | GNUNET_FRAGMENT_context_transmission_done (struct GNUNET_FRAGMENT_Context *fc); | ||
110 | |||
111 | |||
112 | /** | ||
113 | * Process an acknowledgement message we got from the other | ||
114 | * side (to control re-transmits). | ||
115 | * | ||
116 | * @param fc fragmentation context | ||
117 | * @param msg acknowledgement message we received | ||
118 | * @return #GNUNET_OK if this ack completes the work of the 'fc' | ||
119 | * (all fragments have been received); | ||
120 | * #GNUNET_NO if more messages are pending | ||
121 | * #GNUNET_SYSERR if this ack is not valid for this fc | ||
122 | */ | ||
123 | int | ||
124 | GNUNET_FRAGMENT_process_ack (struct GNUNET_FRAGMENT_Context *fc, | ||
125 | const struct GNUNET_MessageHeader *msg); | ||
126 | |||
127 | |||
128 | /** | ||
129 | * Destroy the given fragmentation context (stop calling 'proc', free | ||
130 | * resources). | ||
131 | * | ||
132 | * @param fc fragmentation context | ||
133 | * @param msg_delay where to store average delay between individual message transmissions the | ||
134 | * last message (OUT only) | ||
135 | * @param ack_delay where to store average delay between transmission and ACK for the | ||
136 | * last message, set to FOREVER if the message was not fully transmitted (OUT only) | ||
137 | */ | ||
138 | void | ||
139 | GNUNET_FRAGMENT_context_destroy (struct GNUNET_FRAGMENT_Context *fc, | ||
140 | struct GNUNET_TIME_Relative *msg_delay, | ||
141 | struct GNUNET_TIME_Relative *ack_delay); | ||
142 | |||
143 | |||
144 | /** | ||
145 | * Convert an ACK message to a printable format suitable for logging. | ||
146 | * | ||
147 | * @param ack message to print | ||
148 | * @return ack in human-readable format | ||
149 | */ | ||
150 | const char * | ||
151 | GNUNET_FRAGMENT_print_ack (const struct GNUNET_MessageHeader *ack); | ||
152 | |||
153 | |||
154 | /** | ||
155 | * Defragmentation context (one per connection). | ||
156 | */ | ||
157 | struct GNUNET_DEFRAGMENT_Context; | ||
158 | |||
159 | |||
160 | /** | ||
161 | * Function that is called with acknowledgement messages created by | ||
162 | * the fragmentation module. Acknowledgements are cumulative, | ||
163 | * so it is OK to only transmit the 'latest' ack message for the same | ||
164 | * message ID. | ||
165 | * | ||
166 | * @param cls closure | ||
167 | * @param id unique message ID (modulo collisions) | ||
168 | * @param msg the message that was created | ||
169 | */ | ||
170 | typedef void | ||
171 | (*GNUNET_DEFRAGMENT_AckProcessor) (void *cls, | ||
172 | uint32_t id, | ||
173 | const struct GNUNET_MessageHeader *msg); | ||
174 | |||
175 | |||
176 | /** | ||
177 | * Create a defragmentation context. | ||
178 | * | ||
179 | * @param stats statistics context | ||
180 | * @param mtu the maximum message size for each fragment | ||
181 | * @param num_msgs how many fragmented messages | ||
182 | * to we defragment at most at the same time? | ||
183 | * @param cls closure for @a proc and @a ackp | ||
184 | * @param proc function to call with defragmented messages | ||
185 | * @param ackp function to call with acknowledgements (to send | ||
186 | * back to the other side) | ||
187 | * @return the defragmentation context | ||
188 | */ | ||
189 | struct GNUNET_DEFRAGMENT_Context * | ||
190 | GNUNET_DEFRAGMENT_context_create (struct GNUNET_STATISTICS_Handle *stats, | ||
191 | uint16_t mtu, | ||
192 | unsigned int num_msgs, | ||
193 | void *cls, | ||
194 | GNUNET_FRAGMENT_MessageProcessor proc, | ||
195 | GNUNET_DEFRAGMENT_AckProcessor ackp); | ||
196 | |||
197 | |||
198 | /** | ||
199 | * Destroy the given defragmentation context. | ||
200 | * | ||
201 | * @param dc defragmentation context | ||
202 | */ | ||
203 | void | ||
204 | GNUNET_DEFRAGMENT_context_destroy (struct GNUNET_DEFRAGMENT_Context *dc); | ||
205 | |||
206 | |||
207 | /** | ||
208 | * We have received a fragment. Process it. | ||
209 | * | ||
210 | * @param dc the context | ||
211 | * @param msg the message that was received | ||
212 | * @return #GNUNET_OK on success, | ||
213 | * #GNUNET_NO if this was a duplicate, | ||
214 | * #GNUNET_SYSERR on error | ||
215 | */ | ||
216 | int | ||
217 | GNUNET_DEFRAGMENT_process_fragment (struct GNUNET_DEFRAGMENT_Context *dc, | ||
218 | const struct GNUNET_MessageHeader *msg); | ||
219 | |||
220 | |||
221 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
222 | { | ||
223 | #endif | ||
224 | #ifdef __cplusplus | ||
225 | } | ||
226 | #endif | ||
227 | |||
228 | #endif | ||
229 | |||
230 | /** @} */ /* end of group */ | ||
diff --git a/src/include/gnunet_friends_lib.h b/src/include/gnunet_friends_lib.h deleted file mode 100644 index d591ea082..000000000 --- a/src/include/gnunet_friends_lib.h +++ /dev/null | |||
@@ -1,118 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2013 Christian Grothoff | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your 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 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @author Christian Grothoff | ||
23 | * | ||
24 | * @file | ||
25 | * Library to read and write the FRIENDS file | ||
26 | * | ||
27 | * @defgroup friends Friends library | ||
28 | * Library to read and write the FRIENDS file | ||
29 | * @{ | ||
30 | */ | ||
31 | #ifndef GNUNET_FRIENDS_LIB_H | ||
32 | #define GNUNET_FRIENDS_LIB_H | ||
33 | |||
34 | #ifdef __cplusplus | ||
35 | extern "C" | ||
36 | { | ||
37 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
38 | } | ||
39 | #endif | ||
40 | #endif | ||
41 | |||
42 | #include "gnunet_util_lib.h" | ||
43 | |||
44 | |||
45 | /** | ||
46 | * Signature of a function called on each friend found. | ||
47 | * | ||
48 | * @param cls closure | ||
49 | * @param friend_id peer identity of the friend | ||
50 | */ | ||
51 | typedef void (*GNUNET_FRIENDS_Callback)(void *cls, | ||
52 | const struct | ||
53 | GNUNET_PeerIdentity *friend_id); | ||
54 | |||
55 | |||
56 | /** | ||
57 | * Parse the FRIENDS file. | ||
58 | * | ||
59 | * @param cfg our configuration | ||
60 | * @param cb function to call on each friend found | ||
61 | * @param cb_cls closure for @a cb | ||
62 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on parsing errors | ||
63 | */ | ||
64 | int | ||
65 | GNUNET_FRIENDS_parse (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
66 | GNUNET_FRIENDS_Callback cb, | ||
67 | void *cb_cls); | ||
68 | |||
69 | |||
70 | /** | ||
71 | * Handle for writing a friends file. | ||
72 | */ | ||
73 | struct GNUNET_FRIENDS_Writer; | ||
74 | |||
75 | |||
76 | /** | ||
77 | * Start writing a fresh FRIENDS file. Will make a backup of the | ||
78 | * old one. | ||
79 | * | ||
80 | * @param cfg configuration to use. | ||
81 | * @return NULL on error | ||
82 | */ | ||
83 | struct GNUNET_FRIENDS_Writer * | ||
84 | GNUNET_FRIENDS_write_start (const struct GNUNET_CONFIGURATION_Handle *cfg); | ||
85 | |||
86 | |||
87 | /** | ||
88 | * Finish writing out the friends file. | ||
89 | * | ||
90 | * @param w write handle | ||
91 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | ||
92 | */ | ||
93 | int | ||
94 | GNUNET_FRIENDS_write_stop (struct GNUNET_FRIENDS_Writer *w); | ||
95 | |||
96 | |||
97 | /** | ||
98 | * Add a friend to the friends file. | ||
99 | * | ||
100 | * @param w write handle | ||
101 | * @param friend_id friend to add | ||
102 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | ||
103 | */ | ||
104 | int | ||
105 | GNUNET_FRIENDS_write (struct GNUNET_FRIENDS_Writer *w, | ||
106 | const struct GNUNET_PeerIdentity *friend_id); | ||
107 | |||
108 | |||
109 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
110 | { | ||
111 | #endif | ||
112 | #ifdef __cplusplus | ||
113 | } | ||
114 | #endif | ||
115 | |||
116 | #endif | ||
117 | |||
118 | /** @} */ /* end of group */ | ||
diff --git a/src/include/gnunet_fs_service.h b/src/include/gnunet_fs_service.h index 96936bad2..a05e07ac5 100644 --- a/src/include/gnunet_fs_service.h +++ b/src/include/gnunet_fs_service.h | |||
@@ -18,6 +18,9 @@ | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @addtogroup fs_l2 File sharing and support services/libraries | ||
22 | * @{ | ||
23 | * | ||
21 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
22 | * | 25 | * |
23 | * @file | 26 | * @file |
@@ -33,6 +36,8 @@ | |||
33 | #ifndef GNUNET_FS_LIB_H | 36 | #ifndef GNUNET_FS_LIB_H |
34 | #define GNUNET_FS_LIB_H | 37 | #define GNUNET_FS_LIB_H |
35 | 38 | ||
39 | |||
40 | #include "gnunet_common.h" | ||
36 | #include "gnunet_util_lib.h" | 41 | #include "gnunet_util_lib.h" |
37 | 42 | ||
38 | #ifdef __cplusplus | 43 | #ifdef __cplusplus |
@@ -66,6 +71,106 @@ extern "C" | |||
66 | */ | 71 | */ |
67 | #define GNUNET_FS_VERSION 0x00090300 | 72 | #define GNUNET_FS_VERSION 0x00090300 |
68 | 73 | ||
74 | #if GNUNET_FS_EXTRACTOR_ENABLED | ||
75 | |||
76 | #include <extractor.h> | ||
77 | |||
78 | #else | ||
79 | |||
80 | /* definitions from extractor.h we need for the build */ | ||
81 | |||
82 | /** | ||
83 | * Enumeration defining various sources of keywords. See also | ||
84 | * http://dublincore.org/documents/1998/09/dces/ | ||
85 | */ | ||
86 | enum EXTRACTOR_MetaType | ||
87 | { | ||
88 | EXTRACTOR_METATYPE_RESERVED = 0, | ||
89 | EXTRACTOR_METATYPE_MIMETYPE = 1, | ||
90 | EXTRACTOR_METATYPE_FILENAME = 2, | ||
91 | EXTRACTOR_METATYPE_COMMENT = 3, | ||
92 | EXTRACTOR_METATYPE_TITLE = 4, | ||
93 | EXTRACTOR_METATYPE_BOOK_TITLE = 5, | ||
94 | EXTRACTOR_METATYPE_JOURNAL_NAME = 8, | ||
95 | EXTRACTOR_METATYPE_AUTHOR_NAME = 13, | ||
96 | EXTRACTOR_METATYPE_PUBLICATION_DATE = 24, | ||
97 | EXTRACTOR_METATYPE_URL = 29, | ||
98 | EXTRACTOR_METATYPE_URI = 30, | ||
99 | EXTRACTOR_METATYPE_ISRC = 31, | ||
100 | EXTRACTOR_METATYPE_UNKNOWN = 45, | ||
101 | EXTRACTOR_METATYPE_DESCRIPTION = 46, | ||
102 | EXTRACTOR_METATYPE_KEYWORDS = 49, | ||
103 | EXTRACTOR_METATYPE_SUBJECT = 52, | ||
104 | EXTRACTOR_METATYPE_PACKAGE_NAME = 69, | ||
105 | EXTRACTOR_METATYPE_THUMBNAIL = 114, | ||
106 | EXTRACTOR_METATYPE_ALBUM = 129, | ||
107 | EXTRACTOR_METATYPE_ARTIST = 130, | ||
108 | EXTRACTOR_METATYPE_ORIGINAL_TITLE = 162, | ||
109 | EXTRACTOR_METATYPE_GNUNET_FULL_DATA = 174, | ||
110 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME = 180, | ||
111 | }; | ||
112 | |||
113 | /** | ||
114 | * Format in which the extracted meta data is presented. | ||
115 | */ | ||
116 | enum EXTRACTOR_MetaFormat | ||
117 | { | ||
118 | /** | ||
119 | * Format is unknown. | ||
120 | */ | ||
121 | EXTRACTOR_METAFORMAT_UNKNOWN = 0, | ||
122 | |||
123 | /** | ||
124 | * 0-terminated, UTF-8 encoded string. "data_len" | ||
125 | * is strlen(data)+1. | ||
126 | */ | ||
127 | EXTRACTOR_METAFORMAT_UTF8 = 1, | ||
128 | |||
129 | /** | ||
130 | * Some kind of binary format, see given Mime type. | ||
131 | */ | ||
132 | EXTRACTOR_METAFORMAT_BINARY = 2, | ||
133 | |||
134 | /** | ||
135 | * 0-terminated string. The specific encoding is unknown. | ||
136 | * "data_len" is strlen (data)+1. | ||
137 | */ | ||
138 | EXTRACTOR_METAFORMAT_C_STRING = 3 | ||
139 | }; | ||
140 | |||
141 | |||
142 | /** | ||
143 | * Type of a function that libextractor calls for each | ||
144 | * meta data item found. | ||
145 | * | ||
146 | * @param cls closure (user-defined) | ||
147 | * @param plugin_name name of the plugin that produced this value; | ||
148 | * special values can be used (e.g. '<zlib>' for zlib being | ||
149 | * used in the main libextractor library and yielding | ||
150 | * meta data). | ||
151 | * @param type libextractor-type describing the meta data | ||
152 | * @param format basic format information about @a data | ||
153 | * @param data_mime_type mime-type of @a data (not of the original file); | ||
154 | * can be NULL (if mime-type is not known) | ||
155 | * @param data actual meta-data found | ||
156 | * @param data_len number of bytes in @a data | ||
157 | * @return 0 to continue extracting, 1 to abort | ||
158 | */ | ||
159 | typedef int (*EXTRACTOR_MetaDataProcessor) (void *cls, | ||
160 | const char *plugin_name, | ||
161 | enum EXTRACTOR_MetaType type, | ||
162 | enum EXTRACTOR_MetaFormat format, | ||
163 | const char *data_mime_type, | ||
164 | const char *data, | ||
165 | size_t data_len); | ||
166 | |||
167 | #endif | ||
168 | |||
169 | #ifndef EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME | ||
170 | /* hack for LE < 0.6.3 */ | ||
171 | #define EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME 180 | ||
172 | #endif | ||
173 | |||
69 | 174 | ||
70 | /* ******************** URI API *********************** */ | 175 | /* ******************** URI API *********************** */ |
71 | 176 | ||
@@ -88,6 +193,12 @@ extern "C" | |||
88 | */ | 193 | */ |
89 | struct GNUNET_FS_Uri; | 194 | struct GNUNET_FS_Uri; |
90 | 195 | ||
196 | /** | ||
197 | * @ingroup metadata | ||
198 | * Meta data to associate with a file, directory or namespace. | ||
199 | */ | ||
200 | struct GNUNET_FS_MetaData; | ||
201 | |||
91 | 202 | ||
92 | /** | 203 | /** |
93 | * Iterator over keywords | 204 | * Iterator over keywords |
@@ -108,7 +219,7 @@ typedef int | |||
108 | * into HashMaps. The key may change between FS implementations. | 219 | * into HashMaps. The key may change between FS implementations. |
109 | * | 220 | * |
110 | * @param uri uri to convert to a unique key | 221 | * @param uri uri to convert to a unique key |
111 | * @param key wherer to store the unique key | 222 | * @param key where to store the unique key |
112 | * @return #GNUNET_OK on success | 223 | * @return #GNUNET_OK on success |
113 | */ | 224 | */ |
114 | int | 225 | int |
@@ -414,6 +525,17 @@ GNUNET_FS_uri_chk_get_file_size (const struct GNUNET_FS_Uri *uri); | |||
414 | 525 | ||
415 | 526 | ||
416 | /** | 527 | /** |
528 | * What is the hash of the original file's content | ||
529 | * that this URI refers to? | ||
530 | * | ||
531 | * @param uri the CHK URI to inspect | ||
532 | * @return hash of the file as specified in the CHK URI | ||
533 | */ | ||
534 | const struct GNUNET_HashCode* | ||
535 | GNUNET_FS_uri_chk_get_file_hash (const struct GNUNET_FS_Uri *uri); | ||
536 | |||
537 | |||
538 | /** | ||
417 | * Is this a location URI? | 539 | * Is this a location URI? |
418 | * | 540 | * |
419 | * @param uri the uri to check | 541 | * @param uri the uri to check |
@@ -432,7 +554,7 @@ GNUNET_FS_uri_test_loc (const struct GNUNET_FS_Uri *uri); | |||
432 | * @return NULL on error, otherwise a KSK URI | 554 | * @return NULL on error, otherwise a KSK URI |
433 | */ | 555 | */ |
434 | struct GNUNET_FS_Uri * | 556 | struct GNUNET_FS_Uri * |
435 | GNUNET_FS_uri_ksk_create_from_meta_data (const struct GNUNET_CONTAINER_MetaData | 557 | GNUNET_FS_uri_ksk_create_from_meta_data (const struct GNUNET_FS_MetaData |
436 | *md); | 558 | *md); |
437 | 559 | ||
438 | 560 | ||
@@ -461,14 +583,14 @@ GNUNET_FS_GETOPT_KEYWORDS (char shortName, | |||
461 | * @param name long name of the option | 583 | * @param name long name of the option |
462 | * @param argumentHelp help text for the option argument | 584 | * @param argumentHelp help text for the option argument |
463 | * @param description long help text for the option | 585 | * @param description long help text for the option |
464 | * @param[out] metadata set to the desired value | 586 | * @param[out] meta metadata set to the desired value |
465 | */ | 587 | */ |
466 | struct GNUNET_GETOPT_CommandLineOption | 588 | struct GNUNET_GETOPT_CommandLineOption |
467 | GNUNET_FS_GETOPT_METADATA (char shortName, | 589 | GNUNET_FS_GETOPT_METADATA (char shortName, |
468 | const char *name, | 590 | const char *name, |
469 | const char *argumentHelp, | 591 | const char *argumentHelp, |
470 | const char *description, | 592 | const char *description, |
471 | struct GNUNET_CONTAINER_MetaData **meta); | 593 | struct GNUNET_FS_MetaData **meta); |
472 | 594 | ||
473 | /** | 595 | /** |
474 | * Command-line option parser function that allows the user to specify | 596 | * Command-line option parser function that allows the user to specify |
@@ -477,7 +599,7 @@ GNUNET_FS_GETOPT_METADATA (char shortName, | |||
477 | * the metadata must be passed as the "scls" argument. | 599 | * the metadata must be passed as the "scls" argument. |
478 | * | 600 | * |
479 | * @param ctx command line processor context | 601 | * @param ctx command line processor context |
480 | * @param scls must be of type `struct GNUNET_CONTAINER_MetaData **` | 602 | * @param scls must be of type `struct GNUNET_FS_MetaData **` |
481 | * @param option name of the option (typically 'k') | 603 | * @param option name of the option (typically 'k') |
482 | * @param value command line argument given | 604 | * @param value command line argument given |
483 | * @return #GNUNET_OK on success | 605 | * @return #GNUNET_OK on success |
@@ -1095,7 +1217,7 @@ struct GNUNET_FS_ProgressInfo | |||
1095 | /** | 1217 | /** |
1096 | * Known metadata for the download. | 1218 | * Known metadata for the download. |
1097 | */ | 1219 | */ |
1098 | const struct GNUNET_CONTAINER_MetaData *meta; | 1220 | const struct GNUNET_FS_MetaData *meta; |
1099 | } start; | 1221 | } start; |
1100 | 1222 | ||
1101 | /** | 1223 | /** |
@@ -1107,7 +1229,7 @@ struct GNUNET_FS_ProgressInfo | |||
1107 | /** | 1229 | /** |
1108 | * Known metadata for the download. | 1230 | * Known metadata for the download. |
1109 | */ | 1231 | */ |
1110 | const struct GNUNET_CONTAINER_MetaData *meta; | 1232 | const struct GNUNET_FS_MetaData *meta; |
1111 | 1233 | ||
1112 | /** | 1234 | /** |
1113 | * Error message, NULL if we have not encountered any error yet. | 1235 | * Error message, NULL if we have not encountered any error yet. |
@@ -1192,7 +1314,7 @@ struct GNUNET_FS_ProgressInfo | |||
1192 | /** | 1314 | /** |
1193 | * Metadata for the search result. | 1315 | * Metadata for the search result. |
1194 | */ | 1316 | */ |
1195 | const struct GNUNET_CONTAINER_MetaData *meta; | 1317 | const struct GNUNET_FS_MetaData *meta; |
1196 | 1318 | ||
1197 | /** | 1319 | /** |
1198 | * URI for the search result. | 1320 | * URI for the search result. |
@@ -1220,7 +1342,7 @@ struct GNUNET_FS_ProgressInfo | |||
1220 | /** | 1342 | /** |
1221 | * Metadata for the search result. | 1343 | * Metadata for the search result. |
1222 | */ | 1344 | */ |
1223 | const struct GNUNET_CONTAINER_MetaData *meta; | 1345 | const struct GNUNET_FS_MetaData *meta; |
1224 | 1346 | ||
1225 | /** | 1347 | /** |
1226 | * URI for the search result. | 1348 | * URI for the search result. |
@@ -1267,7 +1389,7 @@ struct GNUNET_FS_ProgressInfo | |||
1267 | /** | 1389 | /** |
1268 | * Metadata for the search result. | 1390 | * Metadata for the search result. |
1269 | */ | 1391 | */ |
1270 | const struct GNUNET_CONTAINER_MetaData *meta; | 1392 | const struct GNUNET_FS_MetaData *meta; |
1271 | 1393 | ||
1272 | /** | 1394 | /** |
1273 | * URI for the search result. | 1395 | * URI for the search result. |
@@ -1319,7 +1441,7 @@ struct GNUNET_FS_ProgressInfo | |||
1319 | /** | 1441 | /** |
1320 | * Metadata for the search result. | 1442 | * Metadata for the search result. |
1321 | */ | 1443 | */ |
1322 | const struct GNUNET_CONTAINER_MetaData *meta; | 1444 | const struct GNUNET_FS_MetaData *meta; |
1323 | 1445 | ||
1324 | /** | 1446 | /** |
1325 | * URI for the search result. | 1447 | * URI for the search result. |
@@ -1347,7 +1469,7 @@ struct GNUNET_FS_ProgressInfo | |||
1347 | /** | 1469 | /** |
1348 | * Metadata for the search result. | 1470 | * Metadata for the search result. |
1349 | */ | 1471 | */ |
1350 | const struct GNUNET_CONTAINER_MetaData *meta; | 1472 | const struct GNUNET_FS_MetaData *meta; |
1351 | 1473 | ||
1352 | /** | 1474 | /** |
1353 | * URI for the search result. | 1475 | * URI for the search result. |
@@ -1402,7 +1524,7 @@ struct GNUNET_FS_ProgressInfo | |||
1402 | /** | 1524 | /** |
1403 | * Metadata for the namespace. | 1525 | * Metadata for the namespace. |
1404 | */ | 1526 | */ |
1405 | const struct GNUNET_CONTAINER_MetaData *meta; | 1527 | const struct GNUNET_FS_MetaData *meta; |
1406 | 1528 | ||
1407 | /** | 1529 | /** |
1408 | * Public key of the namespace. | 1530 | * Public key of the namespace. |
@@ -1702,7 +1824,7 @@ typedef int | |||
1702 | (*GNUNET_FS_FileInformationProcessor) (void *cls, | 1824 | (*GNUNET_FS_FileInformationProcessor) (void *cls, |
1703 | struct GNUNET_FS_FileInformation *fi, | 1825 | struct GNUNET_FS_FileInformation *fi, |
1704 | uint64_t length, | 1826 | uint64_t length, |
1705 | struct GNUNET_CONTAINER_MetaData *meta, | 1827 | struct GNUNET_FS_MetaData *meta, |
1706 | struct GNUNET_FS_Uri **uri, | 1828 | struct GNUNET_FS_Uri **uri, |
1707 | struct GNUNET_FS_BlockOptions *bo, | 1829 | struct GNUNET_FS_BlockOptions *bo, |
1708 | int *do_index, | 1830 | int *do_index, |
@@ -1729,7 +1851,8 @@ GNUNET_FS_file_information_get_id (struct GNUNET_FS_FileInformation *s); | |||
1729 | * @return "filename" field of the structure (can be NULL) | 1851 | * @return "filename" field of the structure (can be NULL) |
1730 | */ | 1852 | */ |
1731 | const char * | 1853 | const char * |
1732 | GNUNET_FS_file_information_get_filename (const struct GNUNET_FS_FileInformation *s); | 1854 | GNUNET_FS_file_information_get_filename (const struct |
1855 | GNUNET_FS_FileInformation *s); | ||
1733 | 1856 | ||
1734 | 1857 | ||
1735 | /** | 1858 | /** |
@@ -1766,7 +1889,7 @@ GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h, | |||
1766 | const struct | 1889 | const struct |
1767 | GNUNET_FS_Uri *keywords, | 1890 | GNUNET_FS_Uri *keywords, |
1768 | const struct | 1891 | const struct |
1769 | GNUNET_CONTAINER_MetaData *meta, | 1892 | GNUNET_FS_MetaData *meta, |
1770 | int do_index, | 1893 | int do_index, |
1771 | const struct | 1894 | const struct |
1772 | GNUNET_FS_BlockOptions *bo); | 1895 | GNUNET_FS_BlockOptions *bo); |
@@ -1796,7 +1919,7 @@ GNUNET_FS_file_information_create_from_data (struct GNUNET_FS_Handle *h, | |||
1796 | const struct | 1919 | const struct |
1797 | GNUNET_FS_Uri *keywords, | 1920 | GNUNET_FS_Uri *keywords, |
1798 | const struct | 1921 | const struct |
1799 | GNUNET_CONTAINER_MetaData *meta, | 1922 | GNUNET_FS_MetaData *meta, |
1800 | int do_index, | 1923 | int do_index, |
1801 | const struct | 1924 | const struct |
1802 | GNUNET_FS_BlockOptions *bo); | 1925 | GNUNET_FS_BlockOptions *bo); |
@@ -1855,7 +1978,7 @@ GNUNET_FS_file_information_create_from_reader (struct GNUNET_FS_Handle *h, | |||
1855 | const struct GNUNET_FS_Uri | 1978 | const struct GNUNET_FS_Uri |
1856 | *keywords, | 1979 | *keywords, |
1857 | const struct | 1980 | const struct |
1858 | GNUNET_CONTAINER_MetaData *meta, | 1981 | GNUNET_FS_MetaData *meta, |
1859 | int do_index, | 1982 | int do_index, |
1860 | const struct | 1983 | const struct |
1861 | GNUNET_FS_BlockOptions *bo); | 1984 | GNUNET_FS_BlockOptions *bo); |
@@ -1879,7 +2002,7 @@ GNUNET_FS_file_information_create_empty_directory (struct GNUNET_FS_Handle *h, | |||
1879 | const struct GNUNET_FS_Uri | 2002 | const struct GNUNET_FS_Uri |
1880 | *keywords, | 2003 | *keywords, |
1881 | const struct | 2004 | const struct |
1882 | GNUNET_CONTAINER_MetaData | 2005 | GNUNET_FS_MetaData |
1883 | *meta, | 2006 | *meta, |
1884 | const struct | 2007 | const struct |
1885 | GNUNET_FS_BlockOptions *bo, | 2008 | GNUNET_FS_BlockOptions *bo, |
@@ -2038,7 +2161,7 @@ struct GNUNET_FS_PublishKskContext; | |||
2038 | struct GNUNET_FS_PublishKskContext * | 2161 | struct GNUNET_FS_PublishKskContext * |
2039 | GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h, | 2162 | GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h, |
2040 | const struct GNUNET_FS_Uri *ksk_uri, | 2163 | const struct GNUNET_FS_Uri *ksk_uri, |
2041 | const struct GNUNET_CONTAINER_MetaData *meta, | 2164 | const struct GNUNET_FS_MetaData *meta, |
2042 | const struct GNUNET_FS_Uri *uri, | 2165 | const struct GNUNET_FS_Uri *uri, |
2043 | const struct GNUNET_FS_BlockOptions *bo, | 2166 | const struct GNUNET_FS_BlockOptions *bo, |
2044 | enum GNUNET_FS_PublishOptions options, | 2167 | enum GNUNET_FS_PublishOptions options, |
@@ -2080,7 +2203,7 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h, | |||
2080 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns, | 2203 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns, |
2081 | const char *identifier, | 2204 | const char *identifier, |
2082 | const char *update, | 2205 | const char *update, |
2083 | const struct GNUNET_CONTAINER_MetaData *meta, | 2206 | const struct GNUNET_FS_MetaData *meta, |
2084 | const struct GNUNET_FS_Uri *uri, | 2207 | const struct GNUNET_FS_Uri *uri, |
2085 | const struct GNUNET_FS_BlockOptions *bo, | 2208 | const struct GNUNET_FS_BlockOptions *bo, |
2086 | enum GNUNET_FS_PublishOptions options, | 2209 | enum GNUNET_FS_PublishOptions options, |
@@ -2176,7 +2299,7 @@ typedef void (*GNUNET_FS_IdentifierProcessor) (void *cls, | |||
2176 | const struct | 2299 | const struct |
2177 | GNUNET_FS_Uri *last_uri, | 2300 | GNUNET_FS_Uri *last_uri, |
2178 | const struct | 2301 | const struct |
2179 | GNUNET_CONTAINER_MetaData * | 2302 | GNUNET_FS_MetaData * |
2180 | last_meta, | 2303 | last_meta, |
2181 | const char *next_id); | 2304 | const char *next_id); |
2182 | 2305 | ||
@@ -2286,7 +2409,7 @@ GNUNET_FS_search_stop (struct GNUNET_FS_SearchContext *sc); | |||
2286 | struct GNUNET_FS_SearchResult * | 2409 | struct GNUNET_FS_SearchResult * |
2287 | GNUNET_FS_probe (struct GNUNET_FS_Handle *h, | 2410 | GNUNET_FS_probe (struct GNUNET_FS_Handle *h, |
2288 | const struct GNUNET_FS_Uri *uri, | 2411 | const struct GNUNET_FS_Uri *uri, |
2289 | const struct GNUNET_CONTAINER_MetaData *meta, | 2412 | const struct GNUNET_FS_MetaData *meta, |
2290 | void *client_info, | 2413 | void *client_info, |
2291 | uint32_t anonymity); | 2414 | uint32_t anonymity); |
2292 | 2415 | ||
@@ -2374,7 +2497,7 @@ enum GNUNET_FS_DownloadOptions | |||
2374 | struct GNUNET_FS_DownloadContext * | 2497 | struct GNUNET_FS_DownloadContext * |
2375 | GNUNET_FS_download_start (struct GNUNET_FS_Handle *h, | 2498 | GNUNET_FS_download_start (struct GNUNET_FS_Handle *h, |
2376 | const struct GNUNET_FS_Uri *uri, | 2499 | const struct GNUNET_FS_Uri *uri, |
2377 | const struct GNUNET_CONTAINER_MetaData *meta, | 2500 | const struct GNUNET_FS_MetaData *meta, |
2378 | const char *filename, const char *tempname, | 2501 | const char *filename, const char *tempname, |
2379 | uint64_t offset, uint64_t length, uint32_t anonymity, | 2502 | uint64_t offset, uint64_t length, uint32_t anonymity, |
2380 | enum GNUNET_FS_DownloadOptions options, void *cctx, | 2503 | enum GNUNET_FS_DownloadOptions options, void *cctx, |
@@ -2468,7 +2591,7 @@ GNUNET_FS_download_resume (struct GNUNET_FS_DownloadContext *dc); | |||
2468 | * we have no mime-type information (treat as #GNUNET_NO) | 2591 | * we have no mime-type information (treat as #GNUNET_NO) |
2469 | */ | 2592 | */ |
2470 | int | 2593 | int |
2471 | GNUNET_FS_meta_data_test_for_directory (const struct GNUNET_CONTAINER_MetaData | 2594 | GNUNET_FS_meta_data_test_for_directory (const struct GNUNET_FS_MetaData |
2472 | *md); | 2595 | *md); |
2473 | 2596 | ||
2474 | 2597 | ||
@@ -2479,7 +2602,7 @@ GNUNET_FS_meta_data_test_for_directory (const struct GNUNET_CONTAINER_MetaData | |||
2479 | * @param md metadata to add mimetype to | 2602 | * @param md metadata to add mimetype to |
2480 | */ | 2603 | */ |
2481 | void | 2604 | void |
2482 | GNUNET_FS_meta_data_make_directory (struct GNUNET_CONTAINER_MetaData *md); | 2605 | GNUNET_FS_meta_data_make_directory (struct GNUNET_FS_MetaData *md); |
2483 | 2606 | ||
2484 | 2607 | ||
2485 | /** | 2608 | /** |
@@ -2490,7 +2613,7 @@ GNUNET_FS_meta_data_make_directory (struct GNUNET_CONTAINER_MetaData *md); | |||
2490 | */ | 2613 | */ |
2491 | char * | 2614 | char * |
2492 | GNUNET_FS_meta_data_suggest_filename (const struct | 2615 | GNUNET_FS_meta_data_suggest_filename (const struct |
2493 | GNUNET_CONTAINER_MetaData *md); | 2616 | GNUNET_FS_MetaData *md); |
2494 | 2617 | ||
2495 | 2618 | ||
2496 | /** | 2619 | /** |
@@ -2513,7 +2636,7 @@ typedef void (*GNUNET_FS_DirectoryEntryProcessor) (void *cls, | |||
2513 | const struct GNUNET_FS_Uri * | 2636 | const struct GNUNET_FS_Uri * |
2514 | uri, | 2637 | uri, |
2515 | const struct | 2638 | const struct |
2516 | GNUNET_CONTAINER_MetaData * | 2639 | GNUNET_FS_MetaData * |
2517 | meta, size_t length, | 2640 | meta, size_t length, |
2518 | const void *data); | 2641 | const void *data); |
2519 | 2642 | ||
@@ -2556,7 +2679,7 @@ struct GNUNET_FS_DirectoryBuilder; | |||
2556 | * @param mdir metadata for the directory | 2679 | * @param mdir metadata for the directory |
2557 | */ | 2680 | */ |
2558 | struct GNUNET_FS_DirectoryBuilder * | 2681 | struct GNUNET_FS_DirectoryBuilder * |
2559 | GNUNET_FS_directory_builder_create (const struct GNUNET_CONTAINER_MetaData | 2682 | GNUNET_FS_directory_builder_create (const struct GNUNET_FS_MetaData |
2560 | *mdir); | 2683 | *mdir); |
2561 | 2684 | ||
2562 | 2685 | ||
@@ -2573,7 +2696,7 @@ GNUNET_FS_directory_builder_create (const struct GNUNET_CONTAINER_MetaData | |||
2573 | void | 2696 | void |
2574 | GNUNET_FS_directory_builder_add (struct GNUNET_FS_DirectoryBuilder *bld, | 2697 | GNUNET_FS_directory_builder_add (struct GNUNET_FS_DirectoryBuilder *bld, |
2575 | const struct GNUNET_FS_Uri *uri, | 2698 | const struct GNUNET_FS_Uri *uri, |
2576 | const struct GNUNET_CONTAINER_MetaData *md, | 2699 | const struct GNUNET_FS_MetaData *md, |
2577 | const void *data); | 2700 | const void *data); |
2578 | 2701 | ||
2579 | 2702 | ||
@@ -2688,7 +2811,7 @@ struct GNUNET_FS_ShareTreeItem | |||
2688 | /** | 2811 | /** |
2689 | * Metadata for this file or directory | 2812 | * Metadata for this file or directory |
2690 | */ | 2813 | */ |
2691 | struct GNUNET_CONTAINER_MetaData *meta; | 2814 | struct GNUNET_FS_MetaData *meta; |
2692 | 2815 | ||
2693 | /** | 2816 | /** |
2694 | * Keywords for this file or directory (derived from metadata). | 2817 | * Keywords for this file or directory (derived from metadata). |
@@ -2777,6 +2900,336 @@ GNUNET_FS_share_tree_trim (struct GNUNET_FS_ShareTreeItem *toplevel); | |||
2777 | void | 2900 | void |
2778 | GNUNET_FS_share_tree_free (struct GNUNET_FS_ShareTreeItem *toplevel); | 2901 | GNUNET_FS_share_tree_free (struct GNUNET_FS_ShareTreeItem *toplevel); |
2779 | 2902 | ||
2903 | /** | ||
2904 | * Meta data processing | ||
2905 | * @defgroup metadata Metadata | ||
2906 | * GNU libextractor key-value pairs | ||
2907 | */ | ||
2908 | |||
2909 | |||
2910 | /* ****************** metadata ******************* */ | ||
2911 | |||
2912 | |||
2913 | /** | ||
2914 | * @ingroup metadata | ||
2915 | * Create a fresh meta data container. | ||
2916 | * | ||
2917 | * @return empty meta-data container | ||
2918 | */ | ||
2919 | struct GNUNET_FS_MetaData * | ||
2920 | GNUNET_FS_meta_data_create (void); | ||
2921 | |||
2922 | |||
2923 | /** | ||
2924 | * @ingroup metadata | ||
2925 | * Duplicate a MetaData token. | ||
2926 | * | ||
2927 | * @param md what to duplicate | ||
2928 | * @return duplicate meta-data container | ||
2929 | */ | ||
2930 | struct GNUNET_FS_MetaData * | ||
2931 | GNUNET_FS_meta_data_duplicate ( | ||
2932 | const struct GNUNET_FS_MetaData *md); | ||
2933 | |||
2934 | |||
2935 | /** | ||
2936 | * @ingroup metadata | ||
2937 | * Free meta data. | ||
2938 | * | ||
2939 | * @param md what to free | ||
2940 | */ | ||
2941 | void | ||
2942 | GNUNET_FS_meta_data_destroy (struct GNUNET_FS_MetaData *md); | ||
2943 | |||
2944 | |||
2945 | /** | ||
2946 | * @ingroup metadata | ||
2947 | * Test if two MDs are equal. We consider them equal if | ||
2948 | * the meta types, formats and content match (we do not | ||
2949 | * include the mime types and plugins names in this | ||
2950 | * consideration). | ||
2951 | * | ||
2952 | * @param md1 first value to check | ||
2953 | * @param md2 other value to check | ||
2954 | * @return #GNUNET_YES if they are equal | ||
2955 | */ | ||
2956 | int | ||
2957 | GNUNET_FS_meta_data_test_equal ( | ||
2958 | const struct GNUNET_FS_MetaData *md1, | ||
2959 | const struct GNUNET_FS_MetaData *md2); | ||
2960 | |||
2961 | |||
2962 | /** | ||
2963 | * @ingroup metadata | ||
2964 | * Extend metadata. | ||
2965 | * | ||
2966 | * @param md metadata to extend | ||
2967 | * @param plugin_name name of the plugin that produced this value; | ||
2968 | * special values can be used (e.g. '<zlib>' for zlib being | ||
2969 | * used in the main libextractor library and yielding | ||
2970 | * meta data). | ||
2971 | * @param type libextractor-type describing the meta data | ||
2972 | * @param format basic format information about data | ||
2973 | * @param data_mime_type mime-type of data (not of the original file); | ||
2974 | * can be NULL (if mime-type is not known) | ||
2975 | * @param data actual meta-data found | ||
2976 | * @param data_size number of bytes in data | ||
2977 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if this entry already exists | ||
2978 | * data_mime_type and plugin_name are not considered for "exists" checks | ||
2979 | */ | ||
2980 | int | ||
2981 | GNUNET_FS_meta_data_insert (struct GNUNET_FS_MetaData *md, | ||
2982 | const char *plugin_name, | ||
2983 | enum EXTRACTOR_MetaType type, | ||
2984 | enum EXTRACTOR_MetaFormat format, | ||
2985 | const char *data_mime_type, | ||
2986 | const char *data, | ||
2987 | size_t data_size); | ||
2988 | |||
2989 | |||
2990 | /** | ||
2991 | * @ingroup metadata | ||
2992 | * Extend metadata. Merges the meta data from the second argument | ||
2993 | * into the first, discarding duplicate key-value pairs. | ||
2994 | * | ||
2995 | * @param md metadata to extend | ||
2996 | * @param in metadata to merge | ||
2997 | */ | ||
2998 | void | ||
2999 | GNUNET_FS_meta_data_merge (struct GNUNET_FS_MetaData *md, | ||
3000 | const struct GNUNET_FS_MetaData *in); | ||
3001 | |||
3002 | |||
3003 | /** | ||
3004 | * @ingroup metadata | ||
3005 | * Remove an item. | ||
3006 | * | ||
3007 | * @param md metadata to manipulate | ||
3008 | * @param type type of the item to remove | ||
3009 | * @param data specific value to remove, NULL to remove all | ||
3010 | * entries of the given type | ||
3011 | * @param data_size number of bytes in data | ||
3012 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the item does not exist in md | ||
3013 | */ | ||
3014 | int | ||
3015 | GNUNET_FS_meta_data_delete (struct GNUNET_FS_MetaData *md, | ||
3016 | enum EXTRACTOR_MetaType type, | ||
3017 | const char *data, | ||
3018 | size_t data_size); | ||
3019 | |||
3020 | |||
3021 | /** | ||
3022 | * @ingroup metadata | ||
3023 | * Remove all items in the container. | ||
3024 | * | ||
3025 | * @param md metadata to manipulate | ||
3026 | */ | ||
3027 | void | ||
3028 | GNUNET_FS_meta_data_clear (struct GNUNET_FS_MetaData *md); | ||
3029 | |||
3030 | |||
3031 | /** | ||
3032 | * @ingroup metadata | ||
3033 | * Add the current time as the publication date | ||
3034 | * to the meta-data. | ||
3035 | * | ||
3036 | * @param md metadata to modify | ||
3037 | */ | ||
3038 | void | ||
3039 | GNUNET_FS_meta_data_add_publication_date ( | ||
3040 | struct GNUNET_FS_MetaData *md); | ||
3041 | |||
3042 | |||
3043 | /** | ||
3044 | * @ingroup metadata | ||
3045 | * Iterate over MD entries. | ||
3046 | * | ||
3047 | * @param md metadata to inspect | ||
3048 | * @param iter function to call on each entry, return 0 to continue to iterate | ||
3049 | * and 1 to abort iteration in this function (GNU libextractor API!) | ||
3050 | * @param iter_cls closure for @a iter | ||
3051 | * @return number of entries | ||
3052 | */ | ||
3053 | int | ||
3054 | GNUNET_FS_meta_data_iterate (const struct GNUNET_FS_MetaData *md, | ||
3055 | EXTRACTOR_MetaDataProcessor iter, | ||
3056 | void *iter_cls); | ||
3057 | |||
3058 | |||
3059 | /** | ||
3060 | * @ingroup metadata | ||
3061 | * Get the first MD entry of the given type. Caller | ||
3062 | * is responsible for freeing the return value. | ||
3063 | * Also, only meta data items that are strings (0-terminated) | ||
3064 | * are returned by this function. | ||
3065 | * | ||
3066 | * @param md metadata to inspect | ||
3067 | * @param type type to look for | ||
3068 | * @return NULL if no entry was found | ||
3069 | */ | ||
3070 | char * | ||
3071 | GNUNET_FS_meta_data_get_by_type ( | ||
3072 | const struct GNUNET_FS_MetaData *md, | ||
3073 | enum EXTRACTOR_MetaType type); | ||
3074 | |||
3075 | |||
3076 | /** | ||
3077 | * @ingroup metadata | ||
3078 | * Get the first matching MD entry of the given types. Caller is | ||
3079 | * responsible for freeing the return value. Also, only meta data | ||
3080 | * items that are strings (0-terminated) are returned by this | ||
3081 | * function. | ||
3082 | * | ||
3083 | * @param md metadata to inspect | ||
3084 | * @param ... -1-terminated list of types | ||
3085 | * @return NULL if we do not have any such entry, | ||
3086 | * otherwise client is responsible for freeing the value! | ||
3087 | */ | ||
3088 | char * | ||
3089 | GNUNET_FS_meta_data_get_first_by_types ( | ||
3090 | const struct GNUNET_FS_MetaData *md, | ||
3091 | ...); | ||
3092 | |||
3093 | /** | ||
3094 | * @ingroup metadata | ||
3095 | * Get a thumbnail from the meta-data (if present). Only matches meta | ||
3096 | * data with mime type "image" and binary format. | ||
3097 | * | ||
3098 | * @param md metadata to inspect | ||
3099 | * @param thumb will be set to the thumbnail data. Must be | ||
3100 | * freed by the caller! | ||
3101 | * @return number of bytes in thumbnail, 0 if not available | ||
3102 | */ | ||
3103 | size_t | ||
3104 | GNUNET_FS_meta_data_get_thumbnail ( | ||
3105 | const struct GNUNET_FS_MetaData *md, | ||
3106 | unsigned char **thumb); | ||
3107 | |||
3108 | |||
3109 | /** | ||
3110 | * @ingroup metadata | ||
3111 | * Options for metadata serialization. | ||
3112 | */ | ||
3113 | enum GNUNET_FS_MetaDataSerializationOptions | ||
3114 | { | ||
3115 | /** | ||
3116 | * @ingroup metadata | ||
3117 | * Serialize all of the data. | ||
3118 | */ | ||
3119 | GNUNET_FS_META_DATA_SERIALIZE_FULL = 0, | ||
3120 | |||
3121 | /** | ||
3122 | * @ingroup metadata | ||
3123 | * If not enough space is available, it is acceptable | ||
3124 | * to only serialize some of the metadata. | ||
3125 | */ | ||
3126 | GNUNET_FS_META_DATA_SERIALIZE_PART = 1, | ||
3127 | |||
3128 | /** | ||
3129 | * @ingroup metadata | ||
3130 | * Speed is of the essence, do not allow compression. | ||
3131 | */ | ||
3132 | GNUNET_FS_META_DATA_SERIALIZE_NO_COMPRESS = 2 | ||
3133 | }; | ||
3134 | |||
3135 | |||
3136 | /** | ||
3137 | * @ingroup metadata | ||
3138 | * Serialize meta-data to target. | ||
3139 | * | ||
3140 | * @param md metadata to serialize | ||
3141 | * @param target where to write the serialized metadata; | ||
3142 | * *target can be NULL, in which case memory is allocated | ||
3143 | * @param max maximum number of bytes available | ||
3144 | * @param opt is it ok to just write SOME of the | ||
3145 | * meta-data to match the size constraint, | ||
3146 | * possibly discarding some data? | ||
3147 | * @return number of bytes written on success, | ||
3148 | * -1 on error (typically: not enough | ||
3149 | * space) | ||
3150 | */ | ||
3151 | ssize_t | ||
3152 | GNUNET_FS_meta_data_serialize ( | ||
3153 | const struct GNUNET_FS_MetaData *md, | ||
3154 | char **target, | ||
3155 | size_t max, | ||
3156 | enum GNUNET_FS_MetaDataSerializationOptions opt); | ||
3157 | |||
3158 | |||
3159 | /** | ||
3160 | * @ingroup metadata | ||
3161 | * Get the size of the full meta-data in serialized form. | ||
3162 | * | ||
3163 | * @param md metadata to inspect | ||
3164 | * @return number of bytes needed for serialization, -1 on error | ||
3165 | */ | ||
3166 | ssize_t | ||
3167 | GNUNET_FS_meta_data_get_serialized_size ( | ||
3168 | const struct GNUNET_FS_MetaData *md); | ||
3169 | |||
3170 | |||
3171 | /** | ||
3172 | * @ingroup metadata | ||
3173 | * Deserialize meta-data. Initializes md. | ||
3174 | * | ||
3175 | * @param input serialized meta-data. | ||
3176 | * @param size number of bytes available | ||
3177 | * @return MD on success, NULL on error (e.g. | ||
3178 | * bad format) | ||
3179 | */ | ||
3180 | struct GNUNET_FS_MetaData * | ||
3181 | GNUNET_FS_meta_data_deserialize (const char *input, size_t size); | ||
3182 | |||
3183 | /** | ||
3184 | * Write a metadata container. | ||
3185 | * | ||
3186 | * @param h the IO handle to write to | ||
3187 | * @param what what is being written (for error message creation) | ||
3188 | * @param m metadata to write | ||
3189 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | ||
3190 | */ | ||
3191 | enum GNUNET_GenericReturnValue | ||
3192 | GNUNET_FS_write_meta_data (struct GNUNET_BIO_WriteHandle *h, | ||
3193 | const char *what, | ||
3194 | const struct GNUNET_FS_MetaData *m); | ||
3195 | |||
3196 | /** | ||
3197 | * Create the specification to read a metadata container. | ||
3198 | * | ||
3199 | * @param what describes what is being read (for error message creation) | ||
3200 | * @param result the buffer to store a pointer to the (allocated) metadata | ||
3201 | * @return the read spec | ||
3202 | */ | ||
3203 | struct GNUNET_BIO_ReadSpec | ||
3204 | GNUNET_FS_read_spec_meta_data (const char *what, | ||
3205 | struct GNUNET_FS_MetaData **result); | ||
3206 | |||
3207 | |||
3208 | |||
3209 | /** | ||
3210 | * Create the specification to write a metadata container. | ||
3211 | * | ||
3212 | * @param what what is being written (for error message creation) | ||
3213 | * @param m metadata to write | ||
3214 | * @return the write spec | ||
3215 | */ | ||
3216 | struct GNUNET_BIO_WriteSpec | ||
3217 | GNUNET_FS_write_spec_meta_data (const char *what, | ||
3218 | const struct GNUNET_FS_MetaData *m); | ||
3219 | |||
3220 | /** | ||
3221 | * Read a metadata container. | ||
3222 | * | ||
3223 | * @param h handle to an open file | ||
3224 | * @param what describes what is being read (for error message creation) | ||
3225 | * @param result the buffer to store a pointer to the (allocated) metadata | ||
3226 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure | ||
3227 | */ | ||
3228 | enum GNUNET_GenericReturnValue | ||
3229 | GNUNET_FS_read_meta_data (struct GNUNET_BIO_ReadHandle *h, | ||
3230 | const char *what, | ||
3231 | struct GNUNET_FS_MetaData **result); | ||
3232 | |||
2780 | 3233 | ||
2781 | #if 0 /* keep Emacsens' auto-indent happy */ | 3234 | #if 0 /* keep Emacsens' auto-indent happy */ |
2782 | { | 3235 | { |
@@ -2788,3 +3241,5 @@ GNUNET_FS_share_tree_free (struct GNUNET_FS_ShareTreeItem *toplevel); | |||
2788 | #endif | 3241 | #endif |
2789 | 3242 | ||
2790 | /** @} */ /* end of group */ | 3243 | /** @} */ /* end of group */ |
3244 | |||
3245 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_getopt_lib.h b/src/include/gnunet_getopt_lib.h index 259d648dd..390e8c153 100644 --- a/src/include/gnunet_getopt_lib.h +++ b/src/include/gnunet_getopt_lib.h | |||
@@ -19,6 +19,10 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup libgnunetutil | ||
23 | * Multi-function utilities library for GNUnet programs | ||
24 | * @{ | ||
25 | * | ||
22 | * @author Christian Grothoff | 26 | * @author Christian Grothoff |
23 | * | 27 | * |
24 | * @file | 28 | * @file |
@@ -29,6 +33,10 @@ | |||
29 | * @{ | 33 | * @{ |
30 | */ | 34 | */ |
31 | 35 | ||
36 | #if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) | ||
37 | #error "Only <gnunet_util_lib.h> can be included directly." | ||
38 | #endif | ||
39 | |||
32 | #ifndef GNUNET_GETOPT_LIB_H | 40 | #ifndef GNUNET_GETOPT_LIB_H |
33 | #define GNUNET_GETOPT_LIB_H | 41 | #define GNUNET_GETOPT_LIB_H |
34 | 42 | ||
@@ -39,6 +47,7 @@ extern "C" { | |||
39 | #endif | 47 | #endif |
40 | #endif | 48 | #endif |
41 | 49 | ||
50 | |||
42 | #include "gnunet_configuration_lib.h" | 51 | #include "gnunet_configuration_lib.h" |
43 | 52 | ||
44 | /** | 53 | /** |
@@ -400,7 +409,6 @@ GNUNET_GETOPT_option_timestamp (char shortName, | |||
400 | * | 409 | * |
401 | * @param shortName short name of the option | 410 | * @param shortName short name of the option |
402 | * @param name long name of the option | 411 | * @param name long name of the option |
403 | * @param argumentHelp help text for the option argument | ||
404 | * @param description long help text for the option | 412 | * @param description long help text for the option |
405 | * @param[out] val set to 1 if the option is present | 413 | * @param[out] val set to 1 if the option is present |
406 | */ | 414 | */ |
@@ -507,4 +515,6 @@ GNUNET_GETOPT_run (const char *binaryOptions, | |||
507 | 515 | ||
508 | /** @} */ /* end of group getopt */ | 516 | /** @} */ /* end of group getopt */ |
509 | 517 | ||
518 | /** @} */ /* end of group addition */ | ||
519 | |||
510 | /* end of gnunet_getopt_lib.h */ | 520 | /* end of gnunet_getopt_lib.h */ |
diff --git a/src/include/gnunet_gns_service.h b/src/include/gnunet_gns_service.h index 5c06f8045..1f19e58ac 100644 --- a/src/include/gnunet_gns_service.h +++ b/src/include/gnunet_gns_service.h | |||
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup GNS | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Martin Schanzenbach | 25 | * @author Martin Schanzenbach |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
@@ -34,8 +37,8 @@ | |||
34 | #ifndef GNUNET_GNS_SERVICE_H | 37 | #ifndef GNUNET_GNS_SERVICE_H |
35 | #define GNUNET_GNS_SERVICE_H | 38 | #define GNUNET_GNS_SERVICE_H |
36 | 39 | ||
40 | |||
37 | #include "gnunet_util_lib.h" | 41 | #include "gnunet_util_lib.h" |
38 | #include "gnunet_dnsparser_lib.h" | ||
39 | #include "gnunet_identity_service.h" | 42 | #include "gnunet_identity_service.h" |
40 | #include "gnunet_namestore_service.h" | 43 | #include "gnunet_namestore_service.h" |
41 | 44 | ||
@@ -134,7 +137,7 @@ enum GNUNET_GNS_LocalOptions | |||
134 | struct GNUNET_GNS_LookupRequest * | 137 | struct GNUNET_GNS_LookupRequest * |
135 | GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle, | 138 | GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle, |
136 | const char *name, | 139 | const char *name, |
137 | const struct GNUNET_IDENTITY_PublicKey *zone, | 140 | const struct GNUNET_CRYPTO_PublicKey *zone, |
138 | uint32_t type, | 141 | uint32_t type, |
139 | enum GNUNET_GNS_LocalOptions options, | 142 | enum GNUNET_GNS_LocalOptions options, |
140 | GNUNET_GNS_LookupResultProcessor proc, | 143 | GNUNET_GNS_LookupResultProcessor proc, |
@@ -158,7 +161,7 @@ GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle, | |||
158 | struct GNUNET_GNS_LookupRequest * | 161 | struct GNUNET_GNS_LookupRequest * |
159 | GNUNET_GNS_lookup_limited (struct GNUNET_GNS_Handle *handle, | 162 | GNUNET_GNS_lookup_limited (struct GNUNET_GNS_Handle *handle, |
160 | const char *name, | 163 | const char *name, |
161 | const struct GNUNET_IDENTITY_PublicKey *zone, | 164 | const struct GNUNET_CRYPTO_PublicKey *zone, |
162 | uint32_t type, | 165 | uint32_t type, |
163 | enum GNUNET_GNS_LocalOptions options, | 166 | enum GNUNET_GNS_LocalOptions options, |
164 | uint16_t recursion_depth_limit, | 167 | uint16_t recursion_depth_limit, |
@@ -235,3 +238,5 @@ GNUNET_GNS_lookup_with_tld_cancel (struct GNUNET_GNS_LookupWithTldRequest *ltr); | |||
235 | #endif | 238 | #endif |
236 | 239 | ||
237 | /** @} */ /* end of group */ | 240 | /** @} */ /* end of group */ |
241 | |||
242 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_gnsrecord_json_lib.h b/src/include/gnunet_gnsrecord_json_lib.h index 966461705..5bc48034b 100644 --- a/src/include/gnunet_gnsrecord_json_lib.h +++ b/src/include/gnunet_gnsrecord_json_lib.h | |||
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup GNS | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Martin Schanzenbach | 25 | * @author Martin Schanzenbach |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
@@ -34,6 +37,7 @@ | |||
34 | #ifndef GNUNET_GNSRECORD_JSON_LIB_H | 37 | #ifndef GNUNET_GNSRECORD_JSON_LIB_H |
35 | #define GNUNET_GNSRECORD_JSON_LIB_H | 38 | #define GNUNET_GNSRECORD_JSON_LIB_H |
36 | 39 | ||
40 | |||
37 | #include "gnunet_gnsrecord_lib.h" | 41 | #include "gnunet_gnsrecord_lib.h" |
38 | #include "gnunet_json_lib.h" | 42 | #include "gnunet_json_lib.h" |
39 | 43 | ||
@@ -69,5 +73,15 @@ GNUNET_GNSRECORD_JSON_from_gnsrecord (const char*rname, | |||
69 | const struct GNUNET_GNSRECORD_Data *rd, | 73 | const struct GNUNET_GNSRECORD_Data *rd, |
70 | unsigned int rd_count); | 74 | unsigned int rd_count); |
71 | 75 | ||
76 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
77 | { | ||
78 | #endif | ||
79 | #ifdef __cplusplus | ||
80 | } | ||
81 | #endif | ||
72 | 82 | ||
73 | #endif | 83 | #endif |
84 | |||
85 | /** @} */ /* end of group */ | ||
86 | |||
87 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_gnsrecord_lib.h b/src/include/gnunet_gnsrecord_lib.h index 006211aee..b4e45727b 100644 --- a/src/include/gnunet_gnsrecord_lib.h +++ b/src/include/gnunet_gnsrecord_lib.h | |||
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup GNS | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
@@ -34,6 +37,8 @@ | |||
34 | #ifndef GNUNET_GNSRECORD_LIB_H | 37 | #ifndef GNUNET_GNSRECORD_LIB_H |
35 | #define GNUNET_GNSRECORD_LIB_H | 38 | #define GNUNET_GNSRECORD_LIB_H |
36 | 39 | ||
40 | |||
41 | #include "gnunet_common.h" | ||
37 | #include "gnunet_identity_service.h" | 42 | #include "gnunet_identity_service.h" |
38 | 43 | ||
39 | #ifdef __cplusplus | 44 | #ifdef __cplusplus |
@@ -66,59 +71,102 @@ extern "C" { | |||
66 | #include "gnu_name_system_record_types.h" | 71 | #include "gnu_name_system_record_types.h" |
67 | 72 | ||
68 | /** | 73 | /** |
74 | * When comparing flags for record equality for removal, | ||
75 | * which flags should must match (in addition to the type, | ||
76 | * name, expiration value and data of the record)? All flags | ||
77 | * that are not listed here will be ignored for this purpose. | ||
78 | * (for example, we don't expect that users will remember to | ||
79 | * pass the '--private' option when removing a record from | ||
80 | * the namestore, hence we don't require this particular option | ||
81 | * to match upon removal). See also | ||
82 | * #GNUNET_GNSRECORD_records_cmp. | ||
83 | */ | ||
84 | #define GNUNET_GNSRECORD_RF_RCMP_FLAGS (GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION) | ||
85 | |||
86 | |||
87 | /** | ||
69 | * Flags that can be set for a record. | 88 | * Flags that can be set for a record. |
70 | * MUST fit into 16 bit. | 89 | * The numbers in the registry correspond to the bit index as specified in |
90 | * LSD0001 Chapter "Resource Records". | ||
91 | * Each enum member represents the 16-bit integer value of the flags field if | ||
92 | * only that particular flag was set. | ||
93 | * The value can be used to efficiently compare the bitmask setting for the | ||
94 | * record flag in C. | ||
95 | * WARNING: The values are in host byte order! In order to correctly check | ||
96 | * against the flags field a record, the respective fields must | ||
97 | * also be converted to HBO (or the enum value to NBO). | ||
71 | */ | 98 | */ |
72 | enum GNUNET_GNSRECORD_Flags | 99 | enum GNUNET_GNSRECORD_Flags |
73 | { | 100 | { |
74 | /** | 101 | /** |
75 | * No special options. | 102 | * Entry for no flags / cleared flags. |
76 | */ | 103 | */ |
77 | GNUNET_GNSRECORD_RF_NONE = 0, | 104 | GNUNET_GNSRECORD_RF_NONE = 0, |
78 | 105 | ||
106 | |||
79 | /** | 107 | /** |
80 | * This record is critical. If it cannot be processed | 108 | * This record is critical. If it cannot be processed (for example because the record type is unknown) resolution MUST fail |
81 | * (for example because the record type is unknown) | ||
82 | * resolution MUST fail | ||
83 | */ | 109 | */ |
84 | GNUNET_GNSRECORD_RF_CRITICAL = 1, | 110 | GNUNET_GNSRECORD_RF_CRITICAL = 1 << (15 - 15), |
111 | |||
85 | 112 | ||
86 | /** | 113 | /** |
87 | * This record should not be used unless all (other) records with an absolute | 114 | * This record should not be used unless all (other) records in the set with an absolute expiration time have expired. |
88 | * expiration time have expired. | ||
89 | */ | 115 | */ |
90 | GNUNET_GNSRECORD_RF_SHADOW_RECORD = 2, | 116 | GNUNET_GNSRECORD_RF_SHADOW = 1 << (15 - 14), |
117 | |||
91 | 118 | ||
92 | /** | 119 | /** |
93 | * This is a supplemental record. | 120 | * This is a supplemental record. |
94 | */ | 121 | */ |
95 | GNUNET_GNSRECORD_RF_SUPPLEMENTAL = 4, | 122 | GNUNET_GNSRECORD_RF_SUPPLEMENTAL = 1 << (15 - 13), |
96 | 123 | ||
97 | /** | 124 | /** |
98 | * This expiration time of the record is a relative | 125 | * Maintenance records. E.g. TOMBSTONEs |
99 | * time (not an absolute time). | ||
100 | */ | 126 | */ |
101 | GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION = 16384, /* 2^14 */ | 127 | GNUNET_GNSRECORD_RF_MAINTENANCE = 1 << (15 - 2), |
102 | 128 | ||
103 | /** | 129 | /** |
104 | * This is a private record of this peer and it should | 130 | * This expiration time of the record is a relative time (not an absolute time). Used in GNUnet implementation. |
105 | * thus not be handed out to other peers. | ||
106 | */ | 131 | */ |
107 | GNUNET_GNSRECORD_RF_PRIVATE = 32768, /* 2^15 */ | 132 | GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION = 1 << (15 - 1), |
133 | |||
134 | |||
135 | /** | ||
136 | * This is a private record of this peer and it should thus not be published. | ||
137 | */ | ||
138 | GNUNET_GNSRECORD_RF_PRIVATE = 1 << (15 - 0), | ||
139 | |||
140 | }; | ||
108 | 141 | ||
109 | 142 | ||
110 | /** | 143 | /** |
111 | * When comparing flags for record equality for removal, | 144 | * Filter for GNUNET_GNSRECORD_normalize_record_set(). |
112 | * which flags should must match (in addition to the type, | ||
113 | * name, expiration value and data of the record)? All flags | ||
114 | * that are not listed here will be ignored for this purpose. | ||
115 | * (for example, we don't expect that users will remember to | ||
116 | * pass the '--private' option when removing a record from | ||
117 | * the namestore, hence we don't require this particular option | ||
118 | * to match upon removal). See also | ||
119 | * #GNUNET_GNSRECORD_records_cmp. | ||
120 | */ | 145 | */ |
121 | #define GNUNET_GNSRECORD_RF_RCMP_FLAGS (GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION) | 146 | enum GNUNET_GNSRECORD_Filter |
147 | { | ||
148 | /** | ||
149 | * No filter flags set. | ||
150 | * Private and public records are returned, | ||
151 | * maintenance records (TOMBSTONE etc) are not. | ||
152 | */ | ||
153 | GNUNET_GNSRECORD_FILTER_NONE = 0, | ||
154 | |||
155 | /** | ||
156 | * Include maintenance records (TOMBSTONE etc). | ||
157 | */ | ||
158 | GNUNET_GNSRECORD_FILTER_INCLUDE_MAINTENANCE = 1, | ||
159 | |||
160 | /** | ||
161 | * Filter private records | ||
162 | */ | ||
163 | GNUNET_GNSRECORD_FILTER_OMIT_PRIVATE = 2, | ||
164 | |||
165 | /** | ||
166 | * Filter public records. | ||
167 | * FIXME: Not implemented | ||
168 | */ | ||
169 | // GNUNET_NAMESTORE_FILTER_OMIT_PUBLIC = 4, | ||
122 | }; | 170 | }; |
123 | 171 | ||
124 | 172 | ||
@@ -283,6 +331,31 @@ struct GNUNET_GNSRECORD_BoxRecord | |||
283 | /* followed by the 'original' record */ | 331 | /* followed by the 'original' record */ |
284 | }; | 332 | }; |
285 | 333 | ||
334 | |||
335 | /** | ||
336 | * Record type used to box up SMIMEA records. For example, a | ||
337 | * SMIMEA record for "c93f1e400f26708f98cb19d936620da35eec8f72e57 | ||
338 | * f9eec01c1afd6._smimecert.foo.gnu" will be stored under | ||
339 | * "foo.gnu" as a SBOX record with the local-path of the associated | ||
340 | * e-mails hash turnicated to 28 octets encoded as hex and protocol _smimecert | ||
341 | * and record_type "SMIMEA". When a BOX record is received, GNS | ||
342 | * unboxes it if the name contained "hash._PROTO", otherwise GNS | ||
343 | * leaves it untouched. This is done to ensure that SMIMEA | ||
344 | * records do not require a separate network request, thus making SMIMEA | ||
345 | * records inseparable from the "main" A/AAAA/VPN/etc. records. | ||
346 | */ | ||
347 | struct GNUNET_GNSRECORD_SBoxRecord | ||
348 | { | ||
349 | /** | ||
350 | * GNS record type of the boxed record. In NBO. | ||
351 | */ | ||
352 | uint32_t record_type GNUNET_PACKED; | ||
353 | |||
354 | /* followed by the zero terminated hostname prefix */ | ||
355 | /* followed by the 'original' record */ | ||
356 | }; | ||
357 | |||
358 | |||
286 | /** | 359 | /** |
287 | * Record type used internally to keep track of reverse mappings into a | 360 | * Record type used internally to keep track of reverse mappings into a |
288 | * namespace. | 361 | * namespace. |
@@ -295,7 +368,7 @@ struct GNUNET_GNSRECORD_ReverseRecord | |||
295 | /** | 368 | /** |
296 | * The public key of the namespace the is delegating to our namespace | 369 | * The public key of the namespace the is delegating to our namespace |
297 | */ | 370 | */ |
298 | struct GNUNET_IDENTITY_PublicKey pkey; | 371 | struct GNUNET_CRYPTO_PublicKey pkey; |
299 | 372 | ||
300 | /** | 373 | /** |
301 | * The expiration time of the delegation | 374 | * The expiration time of the delegation |
@@ -450,7 +523,7 @@ GNUNET_GNSRECORD_string_normalize (const char *src); | |||
450 | * #GNUNET_GNSRECORD_z2s. | 523 | * #GNUNET_GNSRECORD_z2s. |
451 | */ | 524 | */ |
452 | const char * | 525 | const char * |
453 | GNUNET_GNSRECORD_z2s (const struct GNUNET_IDENTITY_PublicKey *z); | 526 | GNUNET_GNSRECORD_z2s (const struct GNUNET_CRYPTO_PublicKey *z); |
454 | 527 | ||
455 | 528 | ||
456 | /** | 529 | /** |
@@ -464,7 +537,7 @@ GNUNET_GNSRECORD_z2s (const struct GNUNET_IDENTITY_PublicKey *z); | |||
464 | * key in an encoding suitable for DNS labels. | 537 | * key in an encoding suitable for DNS labels. |
465 | */ | 538 | */ |
466 | const char * | 539 | const char * |
467 | GNUNET_GNSRECORD_pkey_to_zkey (const struct GNUNET_IDENTITY_PublicKey *pkey); | 540 | GNUNET_GNSRECORD_pkey_to_zkey (const struct GNUNET_CRYPTO_PublicKey *pkey); |
468 | 541 | ||
469 | 542 | ||
470 | /** | 543 | /** |
@@ -478,7 +551,7 @@ GNUNET_GNSRECORD_pkey_to_zkey (const struct GNUNET_IDENTITY_PublicKey *pkey); | |||
478 | */ | 551 | */ |
479 | int | 552 | int |
480 | GNUNET_GNSRECORD_zkey_to_pkey (const char *zkey, | 553 | GNUNET_GNSRECORD_zkey_to_pkey (const char *zkey, |
481 | struct GNUNET_IDENTITY_PublicKey *pkey); | 554 | struct GNUNET_CRYPTO_PublicKey *pkey); |
482 | 555 | ||
483 | 556 | ||
484 | /** | 557 | /** |
@@ -490,12 +563,13 @@ GNUNET_GNSRECORD_zkey_to_pkey (const char *zkey, | |||
490 | */ | 563 | */ |
491 | void | 564 | void |
492 | GNUNET_GNSRECORD_query_from_private_key ( | 565 | GNUNET_GNSRECORD_query_from_private_key ( |
493 | const struct GNUNET_IDENTITY_PrivateKey *zone, const char *label, | 566 | const struct GNUNET_CRYPTO_PrivateKey *zone, const char *label, |
494 | struct GNUNET_HashCode *query); | 567 | struct GNUNET_HashCode *query); |
495 | 568 | ||
496 | 569 | ||
497 | /** | 570 | /** |
498 | * Calculate the DHT query for a given @a label in a given @a zone. | 571 | * Calculate the DHT query for a given @a label in a given @a zone. |
572 | * FIXME: We may want to plugin-ize this at some point. | ||
499 | * | 573 | * |
500 | * @param pub public key of the zone | 574 | * @param pub public key of the zone |
501 | * @param label label of the record | 575 | * @param label label of the record |
@@ -503,7 +577,7 @@ GNUNET_GNSRECORD_query_from_private_key ( | |||
503 | */ | 577 | */ |
504 | void | 578 | void |
505 | GNUNET_GNSRECORD_query_from_public_key ( | 579 | GNUNET_GNSRECORD_query_from_public_key ( |
506 | const struct GNUNET_IDENTITY_PublicKey *pub, const char *label, | 580 | const struct GNUNET_CRYPTO_PublicKey *pub, const char *label, |
507 | struct GNUNET_HashCode *query); | 581 | struct GNUNET_HashCode *query); |
508 | 582 | ||
509 | 583 | ||
@@ -517,10 +591,23 @@ GNUNET_GNSRECORD_query_from_public_key ( | |||
517 | */ | 591 | */ |
518 | ssize_t | 592 | ssize_t |
519 | GNUNET_GNSRECORD_block_calculate_size (const struct | 593 | GNUNET_GNSRECORD_block_calculate_size (const struct |
520 | GNUNET_IDENTITY_PrivateKey *key, | 594 | GNUNET_CRYPTO_PrivateKey *key, |
521 | const struct GNUNET_GNSRECORD_Data *rd, | 595 | const struct GNUNET_GNSRECORD_Data *rd, |
522 | unsigned int rd_count); | 596 | unsigned int rd_count); |
523 | 597 | ||
598 | /** | ||
599 | * Sign a block create with #GNUNET_GNSRECORD_block_create_unsigned | ||
600 | * | ||
601 | * @param key the private key | ||
602 | * @param label the label of the block | ||
603 | * @param block the unsigned block | ||
604 | * @return GNUNET_OK on success | ||
605 | */ | ||
606 | enum GNUNET_GenericReturnValue | ||
607 | GNUNET_GNSRECORD_block_sign (const struct | ||
608 | GNUNET_CRYPTO_PrivateKey *key, | ||
609 | const char *label, | ||
610 | struct GNUNET_GNSRECORD_Block *block); | ||
524 | 611 | ||
525 | /** | 612 | /** |
526 | * Sign name and records | 613 | * Sign name and records |
@@ -534,7 +621,7 @@ GNUNET_GNSRECORD_block_calculate_size (const struct | |||
534 | * @return GNUNET_OK on success | 621 | * @return GNUNET_OK on success |
535 | */ | 622 | */ |
536 | enum GNUNET_GenericReturnValue | 623 | enum GNUNET_GenericReturnValue |
537 | GNUNET_GNSRECORD_block_create (const struct GNUNET_IDENTITY_PrivateKey *key, | 624 | GNUNET_GNSRECORD_block_create (const struct GNUNET_CRYPTO_PrivateKey *key, |
538 | struct GNUNET_TIME_Absolute expire, | 625 | struct GNUNET_TIME_Absolute expire, |
539 | const char *label, | 626 | const char *label, |
540 | const struct GNUNET_GNSRECORD_Data *rd, | 627 | const struct GNUNET_GNSRECORD_Data *rd, |
@@ -543,6 +630,31 @@ GNUNET_GNSRECORD_block_create (const struct GNUNET_IDENTITY_PrivateKey *key, | |||
543 | 630 | ||
544 | 631 | ||
545 | /** | 632 | /** |
633 | * Create name and records but do not sign! | ||
634 | * Sign later with #GNUNET_GNSRECORD_block_sign(). | ||
635 | * Cache derived public key (also keeps the | ||
636 | * private key in static memory, so do not use this function if | ||
637 | * keeping the private key in the process'es RAM is a major issue). | ||
638 | * | ||
639 | * @param key the private key | ||
640 | * @param expire block expiration | ||
641 | * @param label the name for the records | ||
642 | * @param rd record data | ||
643 | * @param rd_count number of records in @a rd | ||
644 | * @param result the block buffer. Will be allocated. | ||
645 | * @return GNUNET_OK on success. | ||
646 | */ | ||
647 | enum GNUNET_GenericReturnValue | ||
648 | GNUNET_GNSRECORD_block_create_unsigned (const struct | ||
649 | GNUNET_CRYPTO_PrivateKey *key, | ||
650 | struct GNUNET_TIME_Absolute expire, | ||
651 | const char *label, | ||
652 | const struct GNUNET_GNSRECORD_Data *rd, | ||
653 | unsigned int rd_count, | ||
654 | struct GNUNET_GNSRECORD_Block **result); | ||
655 | |||
656 | |||
657 | /** | ||
546 | * Sign name and records, cache derived public key (also keeps the | 658 | * Sign name and records, cache derived public key (also keeps the |
547 | * private key in static memory, so do not use this function if | 659 | * private key in static memory, so do not use this function if |
548 | * keeping the private key in the process'es RAM is a major issue). | 660 | * keeping the private key in the process'es RAM is a major issue). |
@@ -556,7 +668,7 @@ GNUNET_GNSRECORD_block_create (const struct GNUNET_IDENTITY_PrivateKey *key, | |||
556 | * @return GNUNET_OK on success. | 668 | * @return GNUNET_OK on success. |
557 | */ | 669 | */ |
558 | enum GNUNET_GenericReturnValue | 670 | enum GNUNET_GenericReturnValue |
559 | GNUNET_GNSRECORD_block_create2 (const struct GNUNET_IDENTITY_PrivateKey *key, | 671 | GNUNET_GNSRECORD_block_create2 (const struct GNUNET_CRYPTO_PrivateKey *key, |
560 | struct GNUNET_TIME_Absolute expire, | 672 | struct GNUNET_TIME_Absolute expire, |
561 | const char *label, | 673 | const char *label, |
562 | const struct GNUNET_GNSRECORD_Data *rd, | 674 | const struct GNUNET_GNSRECORD_Data *rd, |
@@ -571,7 +683,7 @@ GNUNET_GNSRECORD_block_create2 (const struct GNUNET_IDENTITY_PrivateKey *key, | |||
571 | * @param block block to verify | 683 | * @param block block to verify |
572 | * @return #GNUNET_OK if the signature is valid | 684 | * @return #GNUNET_OK if the signature is valid |
573 | */ | 685 | */ |
574 | int | 686 | enum GNUNET_GenericReturnValue |
575 | GNUNET_GNSRECORD_block_verify (const struct GNUNET_GNSRECORD_Block *block); | 687 | GNUNET_GNSRECORD_block_verify (const struct GNUNET_GNSRECORD_Block *block); |
576 | 688 | ||
577 | 689 | ||
@@ -586,10 +698,10 @@ GNUNET_GNSRECORD_block_verify (const struct GNUNET_GNSRECORD_Block *block); | |||
586 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the block was | 698 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the block was |
587 | * not well-formed | 699 | * not well-formed |
588 | */ | 700 | */ |
589 | int | 701 | enum GNUNET_GenericReturnValue |
590 | GNUNET_GNSRECORD_block_decrypt ( | 702 | GNUNET_GNSRECORD_block_decrypt ( |
591 | const struct GNUNET_GNSRECORD_Block *block, | 703 | const struct GNUNET_GNSRECORD_Block *block, |
592 | const struct GNUNET_IDENTITY_PublicKey *zone_key, const char *label, | 704 | const struct GNUNET_CRYPTO_PublicKey *zone_key, const char *label, |
593 | GNUNET_GNSRECORD_RecordCallback proc, void *proc_cls); | 705 | GNUNET_GNSRECORD_RecordCallback proc, void *proc_cls); |
594 | 706 | ||
595 | 707 | ||
@@ -600,7 +712,7 @@ GNUNET_GNSRECORD_block_decrypt ( | |||
600 | * @param b another record | 712 | * @param b another record |
601 | * @return #GNUNET_YES if the records are equal, or #GNUNET_NO if not. | 713 | * @return #GNUNET_YES if the records are equal, or #GNUNET_NO if not. |
602 | */ | 714 | */ |
603 | int | 715 | enum GNUNET_GenericReturnValue |
604 | GNUNET_GNSRECORD_records_cmp (const struct GNUNET_GNSRECORD_Data *a, | 716 | GNUNET_GNSRECORD_records_cmp (const struct GNUNET_GNSRECORD_Data *a, |
605 | const struct GNUNET_GNSRECORD_Data *b); | 717 | const struct GNUNET_GNSRECORD_Data *b); |
606 | 718 | ||
@@ -669,7 +781,7 @@ enum GNUNET_GenericReturnValue | |||
669 | GNUNET_GNSRECORD_identity_from_data (const char *data, | 781 | GNUNET_GNSRECORD_identity_from_data (const char *data, |
670 | size_t data_size, | 782 | size_t data_size, |
671 | uint32_t type, | 783 | uint32_t type, |
672 | struct GNUNET_IDENTITY_PublicKey *key); | 784 | struct GNUNET_CRYPTO_PublicKey *key); |
673 | 785 | ||
674 | 786 | ||
675 | /** | 787 | /** |
@@ -683,7 +795,7 @@ GNUNET_GNSRECORD_identity_from_data (const char *data, | |||
683 | */ | 795 | */ |
684 | enum GNUNET_GenericReturnValue | 796 | enum GNUNET_GenericReturnValue |
685 | GNUNET_GNSRECORD_data_from_identity (const struct | 797 | GNUNET_GNSRECORD_data_from_identity (const struct |
686 | GNUNET_IDENTITY_PublicKey *key, | 798 | GNUNET_CRYPTO_PublicKey *key, |
687 | char **data, | 799 | char **data, |
688 | size_t *data_size, | 800 | size_t *data_size, |
689 | uint32_t *type); | 801 | uint32_t *type); |
@@ -720,9 +832,9 @@ GNUNET_GNSRECORD_is_critical (uint32_t type); | |||
720 | * @param rd input records | 832 | * @param rd input records |
721 | * @param rd_count size of the @a rd and @a rd_public arrays | 833 | * @param rd_count size of the @a rd and @a rd_public arrays |
722 | * @param rd_public where to write the converted records | 834 | * @param rd_public where to write the converted records |
723 | * @param rd_public_count number of records written to @a rd_public | 835 | * @param rd_count_public number of records written to @a rd_public |
724 | * @param min_expiry the minimum expiration of this set | 836 | * @param min_expiry the minimum expiration of this set |
725 | * @param include_private GNUNET_YES if private records should be included. | 837 | * @param filter the record set filter, see GNUNET_GNSRECORD_Filter. |
726 | * @param emsg the error message if something went wrong | 838 | * @param emsg the error message if something went wrong |
727 | * @return GNUNET_OK if set could be normalized and is consistent | 839 | * @return GNUNET_OK if set could be normalized and is consistent |
728 | */ | 840 | */ |
@@ -733,43 +845,147 @@ GNUNET_GNSRECORD_normalize_record_set (const char *label, | |||
733 | struct GNUNET_GNSRECORD_Data *rd_public, | 845 | struct GNUNET_GNSRECORD_Data *rd_public, |
734 | unsigned int *rd_count_public, | 846 | unsigned int *rd_count_public, |
735 | struct GNUNET_TIME_Absolute *min_expiry, | 847 | struct GNUNET_TIME_Absolute *min_expiry, |
736 | int include_private, | 848 | enum GNUNET_GNSRECORD_Filter filter, |
737 | char **emsg); | 849 | char **emsg); |
738 | 850 | ||
851 | /** | ||
852 | * Check label for invalid characters. | ||
853 | * | ||
854 | * @param label the label to check | ||
855 | * @param emsg an error message (NULL if label is valid). Will be allocated. | ||
856 | * @return GNUNET_OK if label is valid. | ||
857 | */ | ||
858 | enum GNUNET_GenericReturnValue | ||
859 | GNUNET_GNSRECORD_label_check (const char*label, char **emsg); | ||
860 | |||
861 | /** | ||
862 | * Maximum length of a revocation | ||
863 | */ | ||
864 | #define GNUNET_MAX_POW_SIZE sizeof(struct GNUNET_GNSRECORD_PowP) \ | ||
865 | + sizeof(struct GNUNET_CRYPTO_PublicKey) \ | ||
866 | + 1024 // FIXME max sig_len | ||
867 | |||
868 | /** | ||
869 | * The proof-of-work narrowing factor. | ||
870 | * The number of PoWs that are calculates as part of revocation. | ||
871 | */ | ||
872 | #define POW_COUNT 32 | ||
873 | |||
874 | |||
875 | GNUNET_NETWORK_STRUCT_BEGIN | ||
739 | 876 | ||
740 | /** | 877 | /** |
741 | * Convert namestore records from the internal format to that | 878 | * Struct for a proof of work as part of the revocation. |
742 | * suitable for publication (removes private records). | 879 | */ |
880 | struct GNUNET_GNSRECORD_PowP | ||
881 | { | ||
882 | /** | ||
883 | * The timestamp of the revocation | ||
884 | */ | ||
885 | struct GNUNET_TIME_AbsoluteNBO timestamp; | ||
886 | |||
887 | /** | ||
888 | * The TTL of this revocation (purely informational) | ||
889 | */ | ||
890 | struct GNUNET_TIME_RelativeNBO ttl; | ||
891 | |||
892 | /** | ||
893 | * The PoWs | ||
894 | */ | ||
895 | uint64_t pow[POW_COUNT] GNUNET_PACKED; | ||
896 | |||
897 | /** followed by the public key type, the key and a signature **/ | ||
898 | }; | ||
899 | |||
900 | |||
901 | /** | ||
902 | * The signature object we use for the PoW | ||
903 | */ | ||
904 | struct GNUNET_GNSRECORD_SignaturePurposePS | ||
905 | { | ||
906 | /** | ||
907 | * The signature purpose | ||
908 | */ | ||
909 | struct GNUNET_CRYPTO_EccSignaturePurpose purpose; | ||
910 | |||
911 | /** | ||
912 | * The timestamp of the revocation | ||
913 | */ | ||
914 | struct GNUNET_TIME_AbsoluteNBO timestamp; | ||
915 | |||
916 | /** Followed by the zone public key type and key **/ | ||
917 | }; | ||
918 | |||
919 | GNUNET_NETWORK_STRUCT_END | ||
920 | |||
921 | |||
922 | /** | ||
923 | * Handle to a running proof-of-work calculation. | ||
924 | */ | ||
925 | struct GNUNET_GNSRECORD_PowCalculationHandle; | ||
926 | |||
927 | |||
928 | /** | ||
929 | * Check if the given proof-of-work is valid. | ||
743 | * | 930 | * |
744 | * @param label the label under which this set is (supposed to be) published. | 931 | * @param pow proof of work |
745 | * @param rd input records | 932 | * @param matching_bits how many bits must match (configuration) |
746 | * @param rd_count size of the @a rd and @a rd_public arrays | 933 | * @param epoch_duration length of single epoch in configuration |
747 | * @param rd_public where to write the converted records | 934 | * @return #GNUNET_YES if the @a pow is acceptable, #GNUNET_NO if not |
748 | * @param rd_public_count number of records written to @a rd_public | ||
749 | * @param expiry the expiration of the block | ||
750 | * @param emsg the error message if something went wrong | ||
751 | * @return GNUNET_OK if set is consistent and can be exported | ||
752 | */ | 935 | */ |
753 | enum GNUNET_GenericReturnValue | 936 | enum GNUNET_GenericReturnValue |
754 | GNUNET_GNSRECORD_convert_records_for_export (const char *label, | 937 | GNUNET_GNSRECORD_check_pow (const struct GNUNET_GNSRECORD_PowP *pow, |
755 | const struct | 938 | unsigned int matching_bits, |
756 | GNUNET_GNSRECORD_Data *rd, | 939 | struct GNUNET_TIME_Relative epoch_duration); |
757 | unsigned int rd_count, | 940 | |
758 | struct GNUNET_GNSRECORD_Data * | ||
759 | rd_public, | ||
760 | unsigned int *rd_count_public, | ||
761 | struct GNUNET_TIME_Absolute *expiry, | ||
762 | char **emsg); | ||
763 | 941 | ||
764 | /** | 942 | /** |
765 | * Check label for invalid characters. | 943 | * Initializes a fresh PoW computation. |
766 | * | 944 | * |
767 | * @param label the label to check | 945 | * @param key the key to calculate the PoW for. |
768 | * @param emsg an error message (NULL if label is valid). Will be allocated. | 946 | * @param pow the pow object to work with in the calculation. |
769 | * @return GNUNET_OK if label is valid. | 947 | */ |
948 | void | ||
949 | GNUNET_GNSRECORD_pow_init (const struct GNUNET_CRYPTO_PrivateKey *key, | ||
950 | struct GNUNET_GNSRECORD_PowP *pow); | ||
951 | |||
952 | |||
953 | /** | ||
954 | * Starts a proof-of-work calculation given the pow object as well as | ||
955 | * target epochs and difficulty. | ||
956 | * | ||
957 | * @param pow the PoW to based calculations on. | ||
958 | * @param epochs the number of epochs for which the PoW must be valid. | ||
959 | * @param difficulty the base difficulty of the PoW. | ||
960 | * @return a handle for use in PoW rounds | ||
961 | */ | ||
962 | struct GNUNET_GNSRECORD_PowCalculationHandle* | ||
963 | GNUNET_GNSRECORD_pow_start (struct GNUNET_GNSRECORD_PowP *pow, | ||
964 | int epochs, | ||
965 | unsigned int difficulty); | ||
966 | |||
967 | |||
968 | /** | ||
969 | * Calculate a single round in the key revocation PoW. | ||
970 | * | ||
971 | * @param pc handle to the PoW, initially called with NULL. | ||
972 | * @return GNUNET_YES if the @a pow is acceptable, GNUNET_NO if not | ||
770 | */ | 973 | */ |
771 | enum GNUNET_GenericReturnValue | 974 | enum GNUNET_GenericReturnValue |
772 | GNUNET_GNSRECORD_label_check (const char*label, char **emsg); | 975 | GNUNET_GNSRECORD_pow_round (struct GNUNET_GNSRECORD_PowCalculationHandle *pc); |
976 | |||
977 | size_t | ||
978 | GNUNET_GNSRECORD_proof_get_size (const struct GNUNET_GNSRECORD_PowP *pow); | ||
979 | |||
980 | /** | ||
981 | * Stop a PoW calculation | ||
982 | * | ||
983 | * @param pc the calculation to clean up | ||
984 | * @return #GNUNET_YES if pow valid, #GNUNET_NO if pow was set but is not | ||
985 | * valid | ||
986 | */ | ||
987 | void | ||
988 | GNUNET_GNSRECORD_pow_stop (struct GNUNET_GNSRECORD_PowCalculationHandle *pc); | ||
773 | 989 | ||
774 | #if 0 /* keep Emacsens' auto-indent happy */ | 990 | #if 0 /* keep Emacsens' auto-indent happy */ |
775 | { | 991 | { |
@@ -781,3 +997,5 @@ GNUNET_GNSRECORD_label_check (const char*label, char **emsg); | |||
781 | #endif | 997 | #endif |
782 | 998 | ||
783 | /** @} */ /* end of group */ | 999 | /** @} */ /* end of group */ |
1000 | |||
1001 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_gnsrecord_plugin.h b/src/include/gnunet_gnsrecord_plugin.h index 84b7c3c23..f55934b60 100644 --- a/src/include/gnunet_gnsrecord_plugin.h +++ b/src/include/gnunet_gnsrecord_plugin.h | |||
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup GNS | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
@@ -157,6 +160,8 @@ struct GNUNET_GNSRECORD_PluginFunctions | |||
157 | 160 | ||
158 | /** @} */ /* end of group */ | 161 | /** @} */ /* end of group */ |
159 | 162 | ||
163 | /** @} */ /* end of group addition */ | ||
164 | |||
160 | #if 0 /* keep Emacsens' auto-indent happy */ | 165 | #if 0 /* keep Emacsens' auto-indent happy */ |
161 | { | 166 | { |
162 | #endif | 167 | #endif |
diff --git a/src/include/gnunet_hello_lib.h b/src/include/gnunet_hello_lib.h deleted file mode 100644 index 74eca999d..000000000 --- a/src/include/gnunet_hello_lib.h +++ /dev/null | |||
@@ -1,539 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2010, 2011 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your 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 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @author Christian Grothoff | ||
23 | * @file | ||
24 | * Helper library for handling HELLOs | ||
25 | * | ||
26 | * @defgroup hello Hello library | ||
27 | * Helper library for handling HELLOs | ||
28 | * | ||
29 | * @see [Documentation](https://gnunet.org/gnunets-hostlist-subsystem) | ||
30 | * | ||
31 | * @{ | ||
32 | */ | ||
33 | |||
34 | #ifndef GNUNET_HELLO_LIB_H | ||
35 | #define GNUNET_HELLO_LIB_H | ||
36 | |||
37 | #ifdef __cplusplus | ||
38 | extern "C" { | ||
39 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
40 | } | ||
41 | #endif | ||
42 | #endif | ||
43 | |||
44 | #include "gnunet_util_lib.h" | ||
45 | |||
46 | /** | ||
47 | * Prefix that every HELLO URI must start with. | ||
48 | */ | ||
49 | #define GNUNET_HELLO_URI_PREFIX "gnunet://hello/" | ||
50 | |||
51 | /** | ||
52 | * Prefix that every FRIEND HELLO URI must start with. | ||
53 | */ | ||
54 | #define GNUNET_FRIEND_HELLO_URI_PREFIX "gnunet://friend-hello/" | ||
55 | |||
56 | /** | ||
57 | * Separator used in HELLO URI | ||
58 | */ | ||
59 | #define GNUNET_HELLO_URI_SEP '+' | ||
60 | |||
61 | |||
62 | /** | ||
63 | * Additional local information about an address | ||
64 | * | ||
65 | * These information are only valid for the local peer and are not serialized | ||
66 | * when a #GNUNET_HELLO_Message is created | ||
67 | */ | ||
68 | enum GNUNET_HELLO_AddressInfo | ||
69 | { | ||
70 | /** | ||
71 | * No additional information | ||
72 | */ | ||
73 | GNUNET_HELLO_ADDRESS_INFO_NONE = 0, | ||
74 | |||
75 | /** | ||
76 | * This is an inbound address and cannot be used to initiate an outbound | ||
77 | * connection to another peer | ||
78 | */ | ||
79 | GNUNET_HELLO_ADDRESS_INFO_INBOUND = 1 | ||
80 | }; | ||
81 | |||
82 | |||
83 | /** | ||
84 | * An address for communicating with a peer. We frequently | ||
85 | * need this tuple and the components cannot really be | ||
86 | * separated. This is NOT the format that would be used | ||
87 | * on the wire. | ||
88 | */ | ||
89 | struct GNUNET_HELLO_Address | ||
90 | { | ||
91 | /** | ||
92 | * For which peer is this an address? | ||
93 | */ | ||
94 | struct GNUNET_PeerIdentity peer; | ||
95 | |||
96 | /** | ||
97 | * Name of the transport plugin enabling the communication using | ||
98 | * this address. | ||
99 | */ | ||
100 | const char *transport_name; | ||
101 | |||
102 | /** | ||
103 | * Binary representation of the address (plugin-specific). | ||
104 | */ | ||
105 | const void *address; | ||
106 | |||
107 | /** | ||
108 | * Number of bytes in @e address. | ||
109 | */ | ||
110 | size_t address_length; | ||
111 | |||
112 | /** | ||
113 | * Extended information about address | ||
114 | * | ||
115 | * This field contains additional #GNUNET_HELLO_AddressInfo flags e.g. | ||
116 | * to indicate an address is inbound and cannot be used to initiate an | ||
117 | * outbound connection. | ||
118 | * | ||
119 | * These information are only valid for the local peer and are not serialized | ||
120 | * when a #GNUNET_HELLO_Message is created | ||
121 | */ | ||
122 | enum GNUNET_HELLO_AddressInfo local_info; | ||
123 | }; | ||
124 | |||
125 | |||
126 | /** | ||
127 | * Allocate an address struct. | ||
128 | * | ||
129 | * @param peer the peer | ||
130 | * @param transport_name plugin name | ||
131 | * @param address binary address | ||
132 | * @param address_length number of bytes in @a address | ||
133 | * @param local_info additional local information for the address | ||
134 | * @return the address struct | ||
135 | */ | ||
136 | struct GNUNET_HELLO_Address * | ||
137 | GNUNET_HELLO_address_allocate (const struct GNUNET_PeerIdentity *peer, | ||
138 | const char *transport_name, | ||
139 | const void *address, | ||
140 | size_t address_length, | ||
141 | enum GNUNET_HELLO_AddressInfo local_info); | ||
142 | |||
143 | |||
144 | /** | ||
145 | * Copy an address struct. | ||
146 | * | ||
147 | * @param address address to copy | ||
148 | * @return a copy of the address struct | ||
149 | */ | ||
150 | struct GNUNET_HELLO_Address * | ||
151 | GNUNET_HELLO_address_copy (const struct GNUNET_HELLO_Address *address); | ||
152 | |||
153 | |||
154 | /** | ||
155 | * Compare two addresses. Does NOT compare the peer identity, | ||
156 | * that is assumed already to match! | ||
157 | * | ||
158 | * @param a1 first address | ||
159 | * @param a2 second address | ||
160 | * @return 0 if the addresses are equal, -1 if @a a1< @a a2, 1 if @a a1> @a a2. | ||
161 | */ | ||
162 | int | ||
163 | GNUNET_HELLO_address_cmp (const struct GNUNET_HELLO_Address *a1, | ||
164 | const struct GNUNET_HELLO_Address *a2); | ||
165 | |||
166 | |||
167 | /** | ||
168 | * Get the size of an address struct. | ||
169 | * | ||
170 | * @param address address | ||
171 | * @return the size | ||
172 | */ | ||
173 | size_t | ||
174 | GNUNET_HELLO_address_get_size (const struct GNUNET_HELLO_Address *address); | ||
175 | |||
176 | |||
177 | /** | ||
178 | * Check if an address has a local option set | ||
179 | * | ||
180 | * @param address the address to check | ||
181 | * @param option the respective option to check for | ||
182 | * @return #GNUNET_YES or #GNUNET_NO | ||
183 | */ | ||
184 | int | ||
185 | GNUNET_HELLO_address_check_option (const struct GNUNET_HELLO_Address *address, | ||
186 | enum GNUNET_HELLO_AddressInfo option); | ||
187 | |||
188 | |||
189 | /** | ||
190 | * Free an address. | ||
191 | * | ||
192 | * @param addr address to free | ||
193 | */ | ||
194 | #define GNUNET_HELLO_address_free(addr) GNUNET_free (addr) | ||
195 | |||
196 | |||
197 | GNUNET_NETWORK_STRUCT_BEGIN | ||
198 | |||
199 | /** | ||
200 | * A HELLO message is used to exchange information about | ||
201 | * transports with other peers. This struct is always | ||
202 | * followed by the actual network addresses which have | ||
203 | * the format: | ||
204 | * | ||
205 | * 1) transport-name (0-terminated) | ||
206 | * 2) address-length (uint16_t, network byte order; possibly | ||
207 | * unaligned!) | ||
208 | * 3) address expiration (`struct GNUNET_TIME_AbsoluteNBO`); possibly | ||
209 | * unaligned!) | ||
210 | * 4) address (address-length bytes; possibly unaligned!) | ||
211 | */ | ||
212 | struct GNUNET_HELLO_Message | ||
213 | { | ||
214 | /** | ||
215 | * Type will be #GNUNET_MESSAGE_TYPE_HELLO. | ||
216 | */ | ||
217 | struct GNUNET_MessageHeader header; | ||
218 | |||
219 | /** | ||
220 | * Use in F2F mode: Do not gossip this HELLO message | ||
221 | */ | ||
222 | uint32_t friend_only GNUNET_PACKED; | ||
223 | |||
224 | /** | ||
225 | * The public key of the peer. | ||
226 | */ | ||
227 | struct GNUNET_CRYPTO_EddsaPublicKey publicKey; | ||
228 | }; | ||
229 | GNUNET_NETWORK_STRUCT_END | ||
230 | |||
231 | |||
232 | /** | ||
233 | * Return HELLO type | ||
234 | * | ||
235 | * @param h HELLO Message to test | ||
236 | * @return #GNUNET_YES for friend-only or #GNUNET_NO otherwise | ||
237 | */ | ||
238 | int | ||
239 | GNUNET_HELLO_is_friend_only (const struct GNUNET_HELLO_Message *h); | ||
240 | |||
241 | |||
242 | /** | ||
243 | * Copy the given address information into | ||
244 | * the given buffer using the format of HELLOs. | ||
245 | * | ||
246 | * @param address address to add | ||
247 | * @param expiration expiration for the address | ||
248 | * @param target where to copy the address | ||
249 | * @param max maximum number of bytes to copy to @a target | ||
250 | * @return number of bytes copied, 0 if | ||
251 | * the target buffer was not big enough. | ||
252 | */ | ||
253 | size_t | ||
254 | GNUNET_HELLO_add_address (const struct GNUNET_HELLO_Address *address, | ||
255 | struct GNUNET_TIME_Absolute expiration, | ||
256 | char *target, | ||
257 | size_t max); | ||
258 | |||
259 | |||
260 | /** | ||
261 | * Callback function used to fill a buffer of max bytes with a list of | ||
262 | * addresses in the format used by HELLOs. Should use | ||
263 | * #GNUNET_HELLO_add_address() as a helper function. | ||
264 | * | ||
265 | * @param cls closure | ||
266 | * @param max maximum number of bytes that can be written to @a buf | ||
267 | * @param buf where to write the address information | ||
268 | * @return number of bytes written or 0, #GNUNET_SYSERR to signal the | ||
269 | * end of the iteration. | ||
270 | */ | ||
271 | typedef ssize_t | ||
272 | (*GNUNET_HELLO_GenerateAddressListCallback) (void *cls, | ||
273 | size_t max, | ||
274 | void *buf); | ||
275 | |||
276 | |||
277 | /** | ||
278 | * Construct a HELLO message given the public key, | ||
279 | * expiration time and an iterator that spews the | ||
280 | * transport addresses. | ||
281 | * | ||
282 | * If friend only is set to #GNUNET_YES we create a FRIEND_HELLO which | ||
283 | * will not be gossiped to other peers. | ||
284 | * | ||
285 | * @param public_key public key to include in the HELLO | ||
286 | * @param addrgen callback to invoke to get addresses | ||
287 | * @param addrgen_cls closure for @a addrgen | ||
288 | * @param friend_only should the returned HELLO be only visible to friends? | ||
289 | * @return the hello message | ||
290 | */ | ||
291 | struct GNUNET_HELLO_Message * | ||
292 | GNUNET_HELLO_create (const struct GNUNET_CRYPTO_EddsaPublicKey *public_key, | ||
293 | GNUNET_HELLO_GenerateAddressListCallback addrgen, | ||
294 | void *addrgen_cls, | ||
295 | int friend_only); | ||
296 | |||
297 | |||
298 | /** | ||
299 | * Return the size of the given HELLO message. | ||
300 | * | ||
301 | * @param hello to inspect | ||
302 | * @return the size, 0 if HELLO is invalid | ||
303 | */ | ||
304 | uint16_t | ||
305 | GNUNET_HELLO_size (const struct GNUNET_HELLO_Message *hello); | ||
306 | |||
307 | |||
308 | /** | ||
309 | * Construct a HELLO message by merging the | ||
310 | * addresses in two existing HELLOs (which | ||
311 | * must be for the same peer). | ||
312 | * | ||
313 | * @param h1 first HELLO message | ||
314 | * @param h2 the second HELLO message | ||
315 | * @return the combined hello message | ||
316 | */ | ||
317 | struct GNUNET_HELLO_Message * | ||
318 | GNUNET_HELLO_merge (const struct GNUNET_HELLO_Message *h1, | ||
319 | const struct GNUNET_HELLO_Message *h2); | ||
320 | |||
321 | |||
322 | /** | ||
323 | * Test if two HELLO messages contain the same addresses. | ||
324 | * If they only differ in expiration time, the lowest | ||
325 | * expiration time larger than 'now' where they differ | ||
326 | * is returned. | ||
327 | * | ||
328 | * @param h1 first HELLO message | ||
329 | * @param h2 the second HELLO message | ||
330 | * @param now time to use for deciding which addresses have | ||
331 | * expired and should not be considered at all | ||
332 | * @return absolute time forever if the two HELLOs are | ||
333 | * totally identical; smallest timestamp >= now if | ||
334 | * they only differ in timestamps; | ||
335 | * zero if the some addresses with expirations >= now | ||
336 | * do not match at all | ||
337 | */ | ||
338 | struct GNUNET_TIME_Absolute | ||
339 | GNUNET_HELLO_equals (const struct GNUNET_HELLO_Message *h1, | ||
340 | const struct GNUNET_HELLO_Message *h2, | ||
341 | struct GNUNET_TIME_Absolute now); | ||
342 | |||
343 | |||
344 | /** | ||
345 | * Iterator callback to go over all addresses. | ||
346 | * | ||
347 | * @param cls closure | ||
348 | * @param address the address | ||
349 | * @param expiration expiration time | ||
350 | * @return #GNUNET_OK to keep the address, | ||
351 | * #GNUNET_NO to delete it from the HELLO | ||
352 | * #GNUNET_SYSERR to stop iterating (but keep current address) | ||
353 | */ | ||
354 | typedef int (*GNUNET_HELLO_AddressIterator) ( | ||
355 | void *cls, | ||
356 | const struct GNUNET_HELLO_Address *address, | ||
357 | struct GNUNET_TIME_Absolute expiration); | ||
358 | |||
359 | |||
360 | /** | ||
361 | * When does the last address in the given HELLO expire? | ||
362 | * | ||
363 | * @param msg HELLO to inspect | ||
364 | * @return time the last address expires, 0 if there are no addresses in the HELLO | ||
365 | */ | ||
366 | struct GNUNET_TIME_Absolute | ||
367 | GNUNET_HELLO_get_last_expiration (const struct GNUNET_HELLO_Message *msg); | ||
368 | |||
369 | |||
370 | /** | ||
371 | * Iterate over all of the addresses in the HELLO. | ||
372 | * | ||
373 | * @param msg HELLO to iterate over; client does not need to | ||
374 | * have verified that msg is well-formed (beyond starting | ||
375 | * with a GNUNET_MessageHeader of the right type). | ||
376 | * @param return_modified if a modified copy should be returned, | ||
377 | * otherwise NULL will be returned | ||
378 | * @param it iterator to call on each address | ||
379 | * @param it_cls closure for @a it | ||
380 | * @return the modified HELLO or NULL | ||
381 | */ | ||
382 | struct GNUNET_HELLO_Message * | ||
383 | GNUNET_HELLO_iterate_addresses (const struct GNUNET_HELLO_Message *msg, | ||
384 | int return_modified, | ||
385 | GNUNET_HELLO_AddressIterator it, | ||
386 | void *it_cls); | ||
387 | |||
388 | |||
389 | /** | ||
390 | * Iterate over addresses in @a new_hello that are NOT already present | ||
391 | * in @a old_hello. Note that if the address is present in @a old_hello | ||
392 | * but the expiration time in @a new_hello is more recent, the | ||
393 | * iterator is also called. | ||
394 | * | ||
395 | * @param new_hello a HELLO message | ||
396 | * @param old_hello a HELLO message | ||
397 | * @param expiration_limit ignore addresses in old_hello | ||
398 | * that expired before the given time stamp | ||
399 | * @param it iterator to call on each address | ||
400 | * @param it_cls closure for @a it | ||
401 | */ | ||
402 | void | ||
403 | GNUNET_HELLO_iterate_new_addresses ( | ||
404 | const struct GNUNET_HELLO_Message *new_hello, | ||
405 | const struct GNUNET_HELLO_Message *old_hello, | ||
406 | struct GNUNET_TIME_Absolute expiration_limit, | ||
407 | GNUNET_HELLO_AddressIterator it, | ||
408 | void *it_cls); | ||
409 | |||
410 | |||
411 | /** | ||
412 | * Get the peer identity from a HELLO message. | ||
413 | * | ||
414 | * @param hello the hello message | ||
415 | * @param peer where to store the peer's identity | ||
416 | * @return #GNUNET_SYSERR if the HELLO was malformed | ||
417 | */ | ||
418 | int | ||
419 | GNUNET_HELLO_get_id (const struct GNUNET_HELLO_Message *hello, | ||
420 | struct GNUNET_PeerIdentity *peer); | ||
421 | |||
422 | |||
423 | /** | ||
424 | * Get the header from a HELLO message, used so other code | ||
425 | * can correctly send HELLO messages. | ||
426 | * | ||
427 | * @param hello the hello message | ||
428 | * | ||
429 | * @return header or NULL if the HELLO was malformed | ||
430 | */ | ||
431 | struct GNUNET_MessageHeader * | ||
432 | GNUNET_HELLO_get_header (struct GNUNET_HELLO_Message *hello); | ||
433 | |||
434 | |||
435 | /** | ||
436 | * Helper function to load/access transport plugins. | ||
437 | * FIXME: pass closure! | ||
438 | * | ||
439 | * @param name name of the transport plugin to load | ||
440 | * @return NULL if a plugin with name @a name is not known/loadable | ||
441 | */ | ||
442 | typedef struct GNUNET_TRANSPORT_PluginFunctions *( | ||
443 | *GNUNET_HELLO_TransportPluginsFind) (const char *name); | ||
444 | |||
445 | |||
446 | /** | ||
447 | * Compose a hello URI string from a hello message. | ||
448 | * | ||
449 | * @param hello Hello message | ||
450 | * @param plugins_find Function to find transport plugins by name | ||
451 | * @return Hello URI string | ||
452 | */ | ||
453 | char * | ||
454 | GNUNET_HELLO_compose_uri (const struct GNUNET_HELLO_Message *hello, | ||
455 | GNUNET_HELLO_TransportPluginsFind plugins_find); | ||
456 | |||
457 | |||
458 | /** | ||
459 | * Parse a hello URI string to a hello message. | ||
460 | * | ||
461 | * @param uri URI string to parse | ||
462 | * @param pubkey Pointer to struct where public key is parsed | ||
463 | * @param hello Pointer to struct where hello message is parsed | ||
464 | * @param plugins_find Function to find transport plugins by name | ||
465 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the URI was invalid, #GNUNET_NO on other errors | ||
466 | */ | ||
467 | int | ||
468 | GNUNET_HELLO_parse_uri (const char *uri, | ||
469 | struct GNUNET_CRYPTO_EddsaPublicKey *pubkey, | ||
470 | struct GNUNET_HELLO_Message **hello, | ||
471 | GNUNET_HELLO_TransportPluginsFind plugins_find); | ||
472 | |||
473 | |||
474 | /* NG API */ | ||
475 | #include "gnunet_nt_lib.h" | ||
476 | |||
477 | |||
478 | /** | ||
479 | * Build address record by signing raw information with private key. | ||
480 | * | ||
481 | * @param address text address to sign | ||
482 | * @param nt network type of @a address | ||
483 | * @param mono_time when was @a address valid | ||
484 | * @param private_key signing key to use | ||
485 | * @param result[out] where to write address record (allocated) | ||
486 | * @param result_size[out] set to size of @a result | ||
487 | */ | ||
488 | void | ||
489 | GNUNET_HELLO_sign_address ( | ||
490 | const char *address, | ||
491 | enum GNUNET_NetworkType nt, | ||
492 | struct GNUNET_TIME_Absolute mono_time, | ||
493 | const struct GNUNET_CRYPTO_EddsaPrivateKey *private_key, | ||
494 | void **result, | ||
495 | size_t *result_size); | ||
496 | |||
497 | |||
498 | /** | ||
499 | * Check signature and extract address record. | ||
500 | * | ||
501 | * @param raw raw signed address | ||
502 | * @param raw_size size of @a raw | ||
503 | * @param pid public key to use for signature verification | ||
504 | * @param nt[out] set to network type | ||
505 | * @param mono_time[out] when was the address generated | ||
506 | * @return NULL on error, otherwise the address | ||
507 | */ | ||
508 | char * | ||
509 | GNUNET_HELLO_extract_address (const void *raw, | ||
510 | size_t raw_size, | ||
511 | const struct GNUNET_PeerIdentity *pid, | ||
512 | enum GNUNET_NetworkType *nt, | ||
513 | struct GNUNET_TIME_Absolute *mono_time); | ||
514 | |||
515 | |||
516 | /** | ||
517 | * Given an address as a string, extract the prefix that identifies | ||
518 | * the communicator offering transmissions to that address. | ||
519 | * | ||
520 | * @param address a peer's address | ||
521 | * @return NULL if the address is mal-formed, otherwise the prefix | ||
522 | */ | ||
523 | char * | ||
524 | GNUNET_HELLO_address_to_prefix (const char *address); | ||
525 | |||
526 | |||
527 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
528 | { | ||
529 | #endif | ||
530 | #ifdef __cplusplus | ||
531 | } | ||
532 | #endif | ||
533 | |||
534 | /* ifndef GNUNET_HELLO_LIB_H */ | ||
535 | #endif | ||
536 | |||
537 | /** @} */ /* end of group */ | ||
538 | |||
539 | /* end of gnunet_hello_lib.h */ | ||
diff --git a/src/include/gnunet_hello_uri_lib.h b/src/include/gnunet_hello_uri_lib.h index c109a151a..aecda0885 100644 --- a/src/include/gnunet_hello_uri_lib.h +++ b/src/include/gnunet_hello_uri_lib.h | |||
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup Backbone | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
23 | * @file | 26 | * @file |
24 | * Helper library for handling HELLO URIs | 27 | * Helper library for handling HELLO URIs |
@@ -39,6 +42,7 @@ extern "C" { | |||
39 | #endif | 42 | #endif |
40 | #endif | 43 | #endif |
41 | 44 | ||
45 | |||
42 | #include "gnunet_util_lib.h" | 46 | #include "gnunet_util_lib.h" |
43 | 47 | ||
44 | 48 | ||
@@ -66,6 +70,13 @@ GNUNET_HELLO_builder_new (const struct GNUNET_PeerIdentity *pid); | |||
66 | 70 | ||
67 | 71 | ||
68 | /** | 72 | /** |
73 | * Get the PeerIdentity for this builder. | ||
74 | */ | ||
75 | const struct GNUNET_PeerIdentity * | ||
76 | GNUNET_HELLO_builder_get_id (const struct GNUNET_HELLO_Builder *builder); | ||
77 | |||
78 | |||
79 | /** | ||
69 | * Release resources of a @a builder. | 80 | * Release resources of a @a builder. |
70 | * | 81 | * |
71 | * @param[in] builder to free | 82 | * @param[in] builder to free |
@@ -107,6 +118,17 @@ GNUNET_HELLO_builder_from_url (const char *url); | |||
107 | 118 | ||
108 | 119 | ||
109 | /** | 120 | /** |
121 | * Get the expiration time for this HELLO. | ||
122 | * | ||
123 | * @param msg The hello msg. | ||
124 | * @return The expiration time. | ||
125 | */ | ||
126 | struct GNUNET_TIME_Absolute | ||
127 | GNUNET_HELLO_builder_get_expiration_time (const struct | ||
128 | GNUNET_MessageHeader *msg); | ||
129 | |||
130 | |||
131 | /** | ||
110 | * Generate envelope with GNUnet HELLO message (including | 132 | * Generate envelope with GNUnet HELLO message (including |
111 | * peer ID) from a @a builder | 133 | * peer ID) from a @a builder |
112 | * | 134 | * |
@@ -116,7 +138,8 @@ GNUNET_HELLO_builder_from_url (const char *url); | |||
116 | */ | 138 | */ |
117 | struct GNUNET_MQ_Envelope * | 139 | struct GNUNET_MQ_Envelope * |
118 | GNUNET_HELLO_builder_to_env (const struct GNUNET_HELLO_Builder *builder, | 140 | GNUNET_HELLO_builder_to_env (const struct GNUNET_HELLO_Builder *builder, |
119 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv); | 141 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, |
142 | struct GNUNET_TIME_Relative expiration_time); | ||
120 | 143 | ||
121 | 144 | ||
122 | /** | 145 | /** |
@@ -129,7 +152,8 @@ GNUNET_HELLO_builder_to_env (const struct GNUNET_HELLO_Builder *builder, | |||
129 | struct GNUNET_MessageHeader * | 152 | struct GNUNET_MessageHeader * |
130 | GNUNET_HELLO_builder_to_dht_hello_msg ( | 153 | GNUNET_HELLO_builder_to_dht_hello_msg ( |
131 | const struct GNUNET_HELLO_Builder *builder, | 154 | const struct GNUNET_HELLO_Builder *builder, |
132 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv); | 155 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, |
156 | struct GNUNET_TIME_Relative expiration_time); | ||
133 | 157 | ||
134 | 158 | ||
135 | /** | 159 | /** |
@@ -158,7 +182,8 @@ enum GNUNET_GenericReturnValue | |||
158 | GNUNET_HELLO_builder_to_block (const struct GNUNET_HELLO_Builder *builder, | 182 | GNUNET_HELLO_builder_to_block (const struct GNUNET_HELLO_Builder *builder, |
159 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, | 183 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, |
160 | void *block, | 184 | void *block, |
161 | size_t *block_size); | 185 | size_t *block_size, |
186 | struct GNUNET_TIME_Relative expiration_time); | ||
162 | 187 | ||
163 | 188 | ||
164 | /** | 189 | /** |
@@ -195,6 +220,7 @@ GNUNET_HELLO_builder_del_address (struct GNUNET_HELLO_Builder *builder, | |||
195 | */ | 220 | */ |
196 | typedef void | 221 | typedef void |
197 | (*GNUNET_HELLO_UriCallback) (void *cls, | 222 | (*GNUNET_HELLO_UriCallback) (void *cls, |
223 | const struct GNUNET_PeerIdentity* pid, | ||
198 | const char *uri); | 224 | const char *uri); |
199 | 225 | ||
200 | 226 | ||
@@ -202,13 +228,12 @@ typedef void | |||
202 | * Iterate over URIs in a builder. | 228 | * Iterate over URIs in a builder. |
203 | * | 229 | * |
204 | * @param builder builder to iterate over | 230 | * @param builder builder to iterate over |
205 | * @param[out] pid set to the peer the @a builder is for | ||
206 | * @param uc callback invoked for each URI, can be NULL | 231 | * @param uc callback invoked for each URI, can be NULL |
207 | * @param uc_cls closure for @a addrgen | 232 | * @param uc_cls closure for @a addrgen |
233 | * @return pid of the peer the @a builder is for, can be NULL | ||
208 | */ | 234 | */ |
209 | void | 235 | const struct GNUNET_PeerIdentity * |
210 | GNUNET_HELLO_builder_iterate (const struct GNUNET_HELLO_Builder *builder, | 236 | GNUNET_HELLO_builder_iterate (const struct GNUNET_HELLO_Builder *builder, |
211 | struct GNUNET_PeerIdentity *pid, | ||
212 | GNUNET_HELLO_UriCallback uc, | 237 | GNUNET_HELLO_UriCallback uc, |
213 | void *uc_cls); | 238 | void *uc_cls); |
214 | 239 | ||
@@ -233,6 +258,35 @@ GNUNET_HELLO_dht_msg_to_block (const struct GNUNET_MessageHeader *hello, | |||
233 | struct GNUNET_TIME_Absolute *block_expiration); | 258 | struct GNUNET_TIME_Absolute *block_expiration); |
234 | 259 | ||
235 | 260 | ||
261 | /** | ||
262 | * Given an address as a string, extract the prefix that identifies | ||
263 | * the communicator offering transmissions to that address. | ||
264 | * | ||
265 | * @param address a peer's address | ||
266 | * @return NULL if the address is mal-formed, otherwise the prefix | ||
267 | */ | ||
268 | char * | ||
269 | GNUNET_HELLO_address_to_prefix (const char *address); | ||
270 | |||
271 | /** | ||
272 | * Build address record by signing raw information with private key. | ||
273 | * | ||
274 | * @param address text address to sign | ||
275 | * @param nt network type of @a address | ||
276 | * @param mono_time when was @a address valid | ||
277 | * @param private_key signing key to use | ||
278 | * @param[out] result where to write address record (allocated) | ||
279 | * @param[out] result_size set to size of @a result | ||
280 | */ | ||
281 | void | ||
282 | GNUNET_HELLO_sign_address ( | ||
283 | const char *address, | ||
284 | enum GNUNET_NetworkType nt, | ||
285 | struct GNUNET_TIME_Absolute mono_time, | ||
286 | const struct GNUNET_CRYPTO_EddsaPrivateKey *private_key, | ||
287 | void **result, | ||
288 | size_t *result_size); | ||
289 | |||
236 | #if 0 /* keep Emacsens' auto-indent happy */ | 290 | #if 0 /* keep Emacsens' auto-indent happy */ |
237 | { | 291 | { |
238 | #endif | 292 | #endif |
@@ -245,4 +299,6 @@ GNUNET_HELLO_dht_msg_to_block (const struct GNUNET_MessageHeader *hello, | |||
245 | 299 | ||
246 | /** @} */ /* end of group */ | 300 | /** @} */ /* end of group */ |
247 | 301 | ||
302 | /** @} */ /* end of group addition */ | ||
303 | |||
248 | /* end of gnunet_hello_uri_lib.h */ | 304 | /* end of gnunet_hello_uri_lib.h */ |
diff --git a/src/include/gnunet_helper_lib.h b/src/include/gnunet_helper_lib.h index b54120204..c329c4a33 100644 --- a/src/include/gnunet_helper_lib.h +++ b/src/include/gnunet_helper_lib.h | |||
@@ -19,6 +19,10 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup libgnunetutil | ||
23 | * Multi-function utilities library for GNUnet programs | ||
24 | * @{ | ||
25 | * | ||
22 | * @author Philipp Toelke | 26 | * @author Philipp Toelke |
23 | * @author Christian Grothoff | 27 | * @author Christian Grothoff |
24 | * | 28 | * |
@@ -34,10 +38,14 @@ | |||
34 | * @{ | 38 | * @{ |
35 | */ | 39 | */ |
36 | 40 | ||
41 | #if ! defined (__GNUNET_UTIL_LIB_H_INSIDE__) | ||
42 | #error "Only <gnunet_util_lib.h> can be included directly." | ||
43 | #endif | ||
44 | |||
37 | #ifndef GNUNET_HELPER_LIB_H | 45 | #ifndef GNUNET_HELPER_LIB_H |
38 | #define GNUNET_HELPER_LIB_H | 46 | #define GNUNET_HELPER_LIB_H |
39 | 47 | ||
40 | #include "gnunet_scheduler_lib.h" | 48 | |
41 | #include "gnunet_mst_lib.h" | 49 | #include "gnunet_mst_lib.h" |
42 | 50 | ||
43 | 51 | ||
@@ -91,8 +99,9 @@ GNUNET_HELPER_start (int with_control_pipe, | |||
91 | * stdin; #GNUNET_NO to signal termination by sending SIGTERM to helper | 99 | * stdin; #GNUNET_NO to signal termination by sending SIGTERM to helper |
92 | * @return #GNUNET_OK on success; #GNUNET_SYSERR on error | 100 | * @return #GNUNET_OK on success; #GNUNET_SYSERR on error |
93 | */ | 101 | */ |
94 | int | 102 | enum GNUNET_GenericReturnValue |
95 | GNUNET_HELPER_kill (struct GNUNET_HELPER_Handle *h, int soft_kill); | 103 | GNUNET_HELPER_kill (struct GNUNET_HELPER_Handle *h, |
104 | int soft_kill); | ||
96 | 105 | ||
97 | 106 | ||
98 | /** | 107 | /** |
@@ -103,7 +112,7 @@ GNUNET_HELPER_kill (struct GNUNET_HELPER_Handle *h, int soft_kill); | |||
103 | * @param h the helper handle | 112 | * @param h the helper handle |
104 | * @return #GNUNET_OK on success; #GNUNET_SYSERR on error | 113 | * @return #GNUNET_OK on success; #GNUNET_SYSERR on error |
105 | */ | 114 | */ |
106 | int | 115 | enum GNUNET_GenericReturnValue |
107 | GNUNET_HELPER_wait (struct GNUNET_HELPER_Handle *h); | 116 | GNUNET_HELPER_wait (struct GNUNET_HELPER_Handle *h); |
108 | 117 | ||
109 | 118 | ||
@@ -136,8 +145,10 @@ GNUNET_HELPER_stop (struct GNUNET_HELPER_Handle *h, int soft_kill); | |||
136 | * #GNUNET_NO if helper process died | 145 | * #GNUNET_NO if helper process died |
137 | * #GNUNET_SYSERR during GNUNET_HELPER_destroy | 146 | * #GNUNET_SYSERR during GNUNET_HELPER_destroy |
138 | */ | 147 | */ |
139 | typedef void (*GNUNET_HELPER_Continuation)(void *cls, | 148 | typedef void |
140 | int result); | 149 | (*GNUNET_HELPER_Continuation)( |
150 | void *cls, | ||
151 | enum GNUNET_GenericReturnValue result); | ||
141 | 152 | ||
142 | 153 | ||
143 | /** | 154 | /** |
@@ -181,3 +192,5 @@ GNUNET_HELPER_send_cancel (struct GNUNET_HELPER_SendHandle *sh); | |||
181 | /* end of include guard: GNUNET_HELPER_LIB_H */ | 192 | /* end of include guard: GNUNET_HELPER_LIB_H */ |
182 | 193 | ||
183 | /** @} */ /* end of group */ | 194 | /** @} */ /* end of group */ |
195 | |||
196 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_identity_service.h b/src/include/gnunet_identity_service.h index 227c7f486..270f4d26f 100644 --- a/src/include/gnunet_identity_service.h +++ b/src/include/gnunet_identity_service.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2013 GNUnet e.V. | 3 | Copyright (C) 2013--2023 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup egos Ego management | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
@@ -42,6 +45,7 @@ | |||
42 | #ifndef GNUNET_IDENTITY_SERVICE_H | 45 | #ifndef GNUNET_IDENTITY_SERVICE_H |
43 | #define GNUNET_IDENTITY_SERVICE_H | 46 | #define GNUNET_IDENTITY_SERVICE_H |
44 | 47 | ||
48 | #include "gnunet_common.h" | ||
45 | #ifdef __cplusplus | 49 | #ifdef __cplusplus |
46 | extern "C" { | 50 | extern "C" { |
47 | #if 0 /* keep Emacsens' auto-indent happy */ | 51 | #if 0 /* keep Emacsens' auto-indent happy */ |
@@ -49,6 +53,7 @@ extern "C" { | |||
49 | #endif | 53 | #endif |
50 | #endif | 54 | #endif |
51 | 55 | ||
56 | |||
52 | #include "gnunet_util_lib.h" | 57 | #include "gnunet_util_lib.h" |
53 | 58 | ||
54 | 59 | ||
@@ -57,20 +62,6 @@ extern "C" { | |||
57 | */ | 62 | */ |
58 | #define GNUNET_IDENTITY_VERSION 0x00000100 | 63 | #define GNUNET_IDENTITY_VERSION 0x00000100 |
59 | 64 | ||
60 | enum GNUNET_IDENTITY_KeyType | ||
61 | { | ||
62 | /** | ||
63 | * The identity type. The value is the same as the | ||
64 | * PKEY record type. | ||
65 | */ | ||
66 | GNUNET_IDENTITY_TYPE_ECDSA = 65536, | ||
67 | |||
68 | /** | ||
69 | * EDDSA identity. The value is the same as the EDKEY | ||
70 | * record type. | ||
71 | */ | ||
72 | GNUNET_IDENTITY_TYPE_EDDSA = 65556 | ||
73 | }; | ||
74 | 65 | ||
75 | /** | 66 | /** |
76 | * Handle to access the identity service. | 67 | * Handle to access the identity service. |
@@ -82,90 +73,6 @@ struct GNUNET_IDENTITY_Handle; | |||
82 | */ | 73 | */ |
83 | struct GNUNET_IDENTITY_Ego; | 74 | struct GNUNET_IDENTITY_Ego; |
84 | 75 | ||
85 | // FIXME: these types are NOT packed, | ||
86 | // NOT 64-bit aligned, but used in messages!!?? | ||
87 | |||
88 | /** | ||
89 | * A private key for an identity as per LSD0001. | ||
90 | */ | ||
91 | struct GNUNET_IDENTITY_PrivateKey | ||
92 | { | ||
93 | /** | ||
94 | * Type of public key. | ||
95 | * Defined by the GNS zone type value. | ||
96 | * In NBO. | ||
97 | */ | ||
98 | uint32_t type; | ||
99 | |||
100 | union | ||
101 | { | ||
102 | /** | ||
103 | * An ECDSA identity key. | ||
104 | */ | ||
105 | struct GNUNET_CRYPTO_EcdsaPrivateKey ecdsa_key; | ||
106 | |||
107 | /** | ||
108 | * AN EdDSA identtiy key | ||
109 | */ | ||
110 | struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_key; | ||
111 | }; | ||
112 | }; | ||
113 | |||
114 | |||
115 | /** | ||
116 | * An identity key as per LSD0001. | ||
117 | */ | ||
118 | struct GNUNET_IDENTITY_PublicKey | ||
119 | { | ||
120 | /** | ||
121 | * Type of public key. | ||
122 | * Defined by the GNS zone type value. | ||
123 | * In NBO. | ||
124 | */ | ||
125 | uint32_t type; | ||
126 | |||
127 | union | ||
128 | { | ||
129 | /** | ||
130 | * An ECDSA identity key. | ||
131 | */ | ||
132 | struct GNUNET_CRYPTO_EcdsaPublicKey ecdsa_key; | ||
133 | |||
134 | /** | ||
135 | * AN EdDSA identtiy key | ||
136 | */ | ||
137 | struct GNUNET_CRYPTO_EddsaPublicKey eddsa_key; | ||
138 | }; | ||
139 | }; | ||
140 | |||
141 | |||
142 | /** | ||
143 | * An identity signature as per LSD0001. | ||
144 | */ | ||
145 | struct GNUNET_IDENTITY_Signature | ||
146 | { | ||
147 | /** | ||
148 | * Type of signature. | ||
149 | * Defined by the GNS zone type value. | ||
150 | * In NBO. | ||
151 | */ | ||
152 | uint32_t type; | ||
153 | |||
154 | union | ||
155 | { | ||
156 | /** | ||
157 | * An ECDSA signature | ||
158 | */ | ||
159 | struct GNUNET_CRYPTO_EcdsaSignature ecdsa_signature; | ||
160 | |||
161 | /** | ||
162 | * AN EdDSA signature | ||
163 | */ | ||
164 | struct GNUNET_CRYPTO_EddsaSignature eddsa_signature; | ||
165 | }; | ||
166 | }; | ||
167 | |||
168 | |||
169 | /** | 76 | /** |
170 | * Handle for an operation with the identity service. | 77 | * Handle for an operation with the identity service. |
171 | */ | 78 | */ |
@@ -178,7 +85,7 @@ struct GNUNET_IDENTITY_Operation; | |||
178 | * @param ego the ego | 85 | * @param ego the ego |
179 | * @return associated ECC key, valid as long as the ego is valid | 86 | * @return associated ECC key, valid as long as the ego is valid |
180 | */ | 87 | */ |
181 | const struct GNUNET_IDENTITY_PrivateKey * | 88 | const struct GNUNET_CRYPTO_PrivateKey * |
182 | GNUNET_IDENTITY_ego_get_private_key (const struct GNUNET_IDENTITY_Ego *ego); | 89 | GNUNET_IDENTITY_ego_get_private_key (const struct GNUNET_IDENTITY_Ego *ego); |
183 | 90 | ||
184 | 91 | ||
@@ -199,7 +106,17 @@ GNUNET_IDENTITY_ego_get_anonymous (void); | |||
199 | */ | 106 | */ |
200 | void | 107 | void |
201 | GNUNET_IDENTITY_ego_get_public_key (struct GNUNET_IDENTITY_Ego *ego, | 108 | GNUNET_IDENTITY_ego_get_public_key (struct GNUNET_IDENTITY_Ego *ego, |
202 | struct GNUNET_IDENTITY_PublicKey *pk); | 109 | struct GNUNET_CRYPTO_PublicKey *pk); |
110 | |||
111 | |||
112 | /** | ||
113 | * Obtain the name associated with an ego. | ||
114 | * | ||
115 | * @param ego the ego | ||
116 | * @return associated name, valid as long as the ego is valid | ||
117 | */ | ||
118 | const char* | ||
119 | GNUNET_IDENTITY_ego_get_name (const struct GNUNET_IDENTITY_Ego *ego); | ||
203 | 120 | ||
204 | 121 | ||
205 | /** | 122 | /** |
@@ -277,11 +194,11 @@ GNUNET_IDENTITY_get (struct GNUNET_IDENTITY_Handle *id, | |||
277 | * been completed. | 194 | * been completed. |
278 | * | 195 | * |
279 | * @param cls closure | 196 | * @param cls closure |
280 | * @param emsg NULL on success, otherwise an error message | 197 | * @param ec the #GNUNET_ErrorCode |
281 | */ | 198 | */ |
282 | typedef void | 199 | typedef void |
283 | (*GNUNET_IDENTITY_Continuation) (void *cls, | 200 | (*GNUNET_IDENTITY_Continuation) (void *cls, |
284 | const char *emsg); | 201 | enum GNUNET_ErrorCode ec); |
285 | 202 | ||
286 | 203 | ||
287 | /** | 204 | /** |
@@ -317,13 +234,13 @@ GNUNET_IDENTITY_disconnect (struct GNUNET_IDENTITY_Handle *h); | |||
317 | * | 234 | * |
318 | * @param cls closure | 235 | * @param cls closure |
319 | * @param pk private key, NULL on error | 236 | * @param pk private key, NULL on error |
320 | * @param emsg error message, NULL on success | 237 | * @param ec the #GNUNET_ErrorCode |
321 | */ | 238 | */ |
322 | typedef void | 239 | typedef void |
323 | (*GNUNET_IDENTITY_CreateContinuation) ( | 240 | (*GNUNET_IDENTITY_CreateContinuation) ( |
324 | void *cls, | 241 | void *cls, |
325 | const struct GNUNET_IDENTITY_PrivateKey *pk, | 242 | const struct GNUNET_CRYPTO_PrivateKey *pk, |
326 | const char *emsg); | 243 | enum GNUNET_ErrorCode ec); |
327 | 244 | ||
328 | 245 | ||
329 | /** | 246 | /** |
@@ -340,8 +257,8 @@ typedef void | |||
340 | struct GNUNET_IDENTITY_Operation * | 257 | struct GNUNET_IDENTITY_Operation * |
341 | GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *id, | 258 | GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *id, |
342 | const char *name, | 259 | const char *name, |
343 | const struct GNUNET_IDENTITY_PrivateKey *privkey, | 260 | const struct GNUNET_CRYPTO_PrivateKey *privkey, |
344 | enum GNUNET_IDENTITY_KeyType ktype, | 261 | enum GNUNET_CRYPTO_KeyType ktype, |
345 | GNUNET_IDENTITY_CreateContinuation cont, | 262 | GNUNET_IDENTITY_CreateContinuation cont, |
346 | void *cont_cls); | 263 | void *cont_cls); |
347 | 264 | ||
@@ -392,378 +309,6 @@ void | |||
392 | GNUNET_IDENTITY_cancel (struct GNUNET_IDENTITY_Operation *op); | 309 | GNUNET_IDENTITY_cancel (struct GNUNET_IDENTITY_Operation *op); |
393 | 310 | ||
394 | 311 | ||
395 | /** | ||
396 | * Get the compacted length of a #GNUNET_IDENTITY_PublicKey. | ||
397 | * Compacted means that it returns the minimum number of bytes this | ||
398 | * key is long, as opposed to the union structure inside | ||
399 | * #GNUNET_IDENTITY_PublicKey. | ||
400 | * Useful for compact serializations. | ||
401 | * | ||
402 | * @param key the key. | ||
403 | * @return -1 on error, else the compacted length of the key. | ||
404 | */ | ||
405 | ssize_t | ||
406 | GNUNET_IDENTITY_key_get_length (const struct GNUNET_IDENTITY_PublicKey *key); | ||
407 | |||
408 | |||
409 | /** | ||
410 | * Reads a #GNUNET_IDENTITY_PublicKey from a compact buffer. | ||
411 | * The buffer has to contain at least the compacted length of | ||
412 | * a #GNUNET_IDENTITY_PublicKey in bytes. | ||
413 | * If the buffer is too small, the function returns -1 as error. | ||
414 | * If the buffer does not contain a valid key, it returns -2 as error. | ||
415 | * | ||
416 | * @param key the key | ||
417 | * @param buffer the buffer | ||
418 | * @param len the length of buffer | ||
419 | * @return -1 or -2 on error, else the amount of bytes read from the buffer | ||
420 | */ | ||
421 | ssize_t | ||
422 | GNUNET_IDENTITY_read_key_from_buffer (struct GNUNET_IDENTITY_PublicKey *key, | ||
423 | const void*buffer, | ||
424 | size_t len); | ||
425 | |||
426 | |||
427 | /** | ||
428 | * Writes a #GNUNET_IDENTITY_PublicKey to a compact buffer. | ||
429 | * The buffer requires space for at least the compacted length of | ||
430 | * a #GNUNET_IDENTITY_PublicKey in bytes. | ||
431 | * If the buffer is too small, the function returns -1 as error. | ||
432 | * If the key is not valid, it returns -2 as error. | ||
433 | * | ||
434 | * @param key the key | ||
435 | * @param buffer the buffer | ||
436 | * @param len the length of buffer | ||
437 | * @return -1 or -2 on error, else the amount of bytes written to the buffer | ||
438 | */ | ||
439 | ssize_t | ||
440 | GNUNET_IDENTITY_write_key_to_buffer (const struct | ||
441 | GNUNET_IDENTITY_PublicKey *key, | ||
442 | void*buffer, | ||
443 | size_t len); | ||
444 | |||
445 | |||
446 | /** | ||
447 | * Get the compacted length of a #GNUNET_IDENTITY_Signature. | ||
448 | * Compacted means that it returns the minimum number of bytes this | ||
449 | * signature is long, as opposed to the union structure inside | ||
450 | * #GNUNET_IDENTITY_Signature. | ||
451 | * Useful for compact serializations. | ||
452 | * | ||
453 | * @param sig the signature. | ||
454 | * @return -1 on error, else the compacted length of the signature. | ||
455 | */ | ||
456 | ssize_t | ||
457 | GNUNET_IDENTITY_signature_get_length (const struct | ||
458 | GNUNET_IDENTITY_Signature *sig); | ||
459 | |||
460 | |||
461 | /** | ||
462 | * Get the compacted length of a signature by type. | ||
463 | * Compacted means that it returns the minimum number of bytes this | ||
464 | * signature is long, as opposed to the union structure inside | ||
465 | * #GNUNET_IDENTITY_Signature. | ||
466 | * Useful for compact serializations. | ||
467 | * | ||
468 | * @param sig the signature. | ||
469 | * @return -1 on error, else the compacted length of the signature. | ||
470 | */ | ||
471 | ssize_t | ||
472 | GNUNET_IDENTITY_signature_get_raw_length_by_type (const uint32_t type); | ||
473 | |||
474 | |||
475 | |||
476 | /** | ||
477 | * Reads a #GNUNET_IDENTITY_Signature from a compact buffer. | ||
478 | * The buffer has to contain at least the compacted length of | ||
479 | * a #GNUNET_IDENTITY_Signature in bytes. | ||
480 | * If the buffer is too small, the function returns -1 as error. | ||
481 | * If the buffer does not contain a valid key, it returns -2 as error. | ||
482 | * | ||
483 | * @param sig the signature | ||
484 | * @param buffer the buffer | ||
485 | * @param len the length of buffer | ||
486 | * @return -1 or -2 on error, else the amount of bytes read from the buffer | ||
487 | */ | ||
488 | ssize_t | ||
489 | GNUNET_IDENTITY_read_signature_from_buffer (struct | ||
490 | GNUNET_IDENTITY_Signature *sig, | ||
491 | const void*buffer, | ||
492 | size_t len); | ||
493 | |||
494 | |||
495 | /** | ||
496 | * Writes a #GNUNET_IDENTITY_Signature to a compact buffer. | ||
497 | * The buffer requires space for at least the compacted length of | ||
498 | * a #GNUNET_IDENTITY_Signature in bytes. | ||
499 | * If the buffer is too small, the function returns -1 as error. | ||
500 | * If the key is not valid, it returns -2 as error. | ||
501 | * | ||
502 | * @param sig the signature | ||
503 | * @param buffer the buffer | ||
504 | * @param len the length of buffer | ||
505 | * @return -1 or -2 on error, else the amount of bytes written to the buffer | ||
506 | */ | ||
507 | ssize_t | ||
508 | GNUNET_IDENTITY_write_signature_to_buffer (const struct | ||
509 | GNUNET_IDENTITY_Signature *sig, | ||
510 | void*buffer, | ||
511 | size_t len); | ||
512 | |||
513 | |||
514 | /** | ||
515 | * @brief Sign a given block. | ||
516 | * | ||
517 | * The @a purpose data is the beginning of the data of which the signature is | ||
518 | * to be created. The `size` field in @a purpose must correctly indicate the | ||
519 | * number of bytes of the data structure, including its header. If possible, | ||
520 | * use #GNUNET_IDENTITY_sign() instead of this function. | ||
521 | * | ||
522 | * @param priv private key to use for the signing | ||
523 | * @param purpose what to sign (size, purpose) | ||
524 | * @param[out] sig where to write the signature | ||
525 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
526 | */ | ||
527 | enum GNUNET_GenericReturnValue | ||
528 | GNUNET_IDENTITY_sign_ (const struct | ||
529 | GNUNET_IDENTITY_PrivateKey *priv, | ||
530 | const struct | ||
531 | GNUNET_CRYPTO_EccSignaturePurpose *purpose, | ||
532 | struct GNUNET_IDENTITY_Signature *sig); | ||
533 | |||
534 | /** | ||
535 | * @brief Sign a given block. | ||
536 | * | ||
537 | * The @a purpose data is the beginning of the data of which the signature is | ||
538 | * to be created. The `size` field in @a purpose must correctly indicate the | ||
539 | * number of bytes of the data structure, including its header. | ||
540 | * The signature payload and length depends on the key type. | ||
541 | * | ||
542 | * @param priv private key to use for the signing | ||
543 | * @param purpose what to sign (size, purpose) | ||
544 | * @param[out] sig where to write the signature | ||
545 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
546 | */ | ||
547 | enum GNUNET_GenericReturnValue | ||
548 | GNUNET_IDENTITY_sign_raw_ (const struct | ||
549 | GNUNET_IDENTITY_PrivateKey *priv, | ||
550 | const struct | ||
551 | GNUNET_CRYPTO_EccSignaturePurpose *purpose, | ||
552 | unsigned char *sig); | ||
553 | |||
554 | |||
555 | /** | ||
556 | * @brief Sign a given block with #GNUNET_IDENTITY_PrivateKey. | ||
557 | * | ||
558 | * The @a ps data must be a fixed-size struct for which the signature is to be | ||
559 | * created. The `size` field in @a ps->purpose must correctly indicate the | ||
560 | * number of bytes of the data structure, including its header. | ||
561 | * | ||
562 | * @param priv private key to use for the signing | ||
563 | * @param ps packed struct with what to sign, MUST begin with a purpose | ||
564 | * @param[out] sig where to write the signature | ||
565 | */ | ||
566 | #define GNUNET_IDENTITY_sign(priv,ps,sig) do { \ | ||
567 | /* check size is set correctly */ \ | ||
568 | GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \ | ||
569 | /* check 'ps' begins with the purpose */ \ | ||
570 | GNUNET_static_assert (((void*) (ps)) == \ | ||
571 | ((void*) &(ps)->purpose)); \ | ||
572 | GNUNET_assert (GNUNET_OK == \ | ||
573 | GNUNET_IDENTITY_sign_ (priv, \ | ||
574 | &(ps)->purpose, \ | ||
575 | sig)); \ | ||
576 | } while (0) | ||
577 | |||
578 | |||
579 | /** | ||
580 | * @brief Verify a given signature. | ||
581 | * | ||
582 | * The @a validate data is the beginning of the data of which the signature | ||
583 | * is to be verified. The `size` field in @a validate must correctly indicate | ||
584 | * the number of bytes of the data structure, including its header. If @a | ||
585 | * purpose does not match the purpose given in @a validate (the latter must be | ||
586 | * in big endian), signature verification fails. If possible, | ||
587 | * use #GNUNET_IDENTITY_signature_verify() instead of this function (only if @a validate | ||
588 | * is not fixed-size, you must use this function directly). | ||
589 | * | ||
590 | * @param purpose what is the purpose that the signature should have? | ||
591 | * @param validate block to validate (size, purpose, data) | ||
592 | * @param sig signature that is being validated | ||
593 | * @param pub public key of the signer | ||
594 | * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid | ||
595 | */ | ||
596 | enum GNUNET_GenericReturnValue | ||
597 | GNUNET_IDENTITY_signature_verify_ (uint32_t purpose, | ||
598 | const struct | ||
599 | GNUNET_CRYPTO_EccSignaturePurpose *validate, | ||
600 | const struct GNUNET_IDENTITY_Signature *sig, | ||
601 | const struct | ||
602 | GNUNET_IDENTITY_PublicKey *pub); | ||
603 | |||
604 | /** | ||
605 | * @brief Verify a given signature. | ||
606 | * | ||
607 | * The @a validate data is the beginning of the data of which the signature | ||
608 | * is to be verified. The `size` field in @a validate must correctly indicate | ||
609 | * the number of bytes of the data structure, including its header. If @a | ||
610 | * purpose does not match the purpose given in @a validate (the latter must be | ||
611 | * in big endian), signature verification fails. | ||
612 | * | ||
613 | * @param purpose what is the purpose that the signature should have? | ||
614 | * @param validate block to validate (size, purpose, data) | ||
615 | * @param sig signature that is being validated | ||
616 | * @param pub public key of the signer | ||
617 | * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid | ||
618 | */ | ||
619 | enum GNUNET_GenericReturnValue | ||
620 | GNUNET_IDENTITY_signature_verify_raw_ (uint32_t purpose, | ||
621 | const struct | ||
622 | GNUNET_CRYPTO_EccSignaturePurpose * | ||
623 | validate, | ||
624 | const unsigned char *sig, | ||
625 | const struct | ||
626 | GNUNET_IDENTITY_PublicKey *pub); | ||
627 | |||
628 | |||
629 | /** | ||
630 | * @brief Verify a given signature with #GNUNET_IDENTITY_PublicKey. | ||
631 | * | ||
632 | * The @a ps data must be a fixed-size struct for which the signature is to be | ||
633 | * created. The `size` field in @a ps->purpose must correctly indicate the | ||
634 | * number of bytes of the data structure, including its header. | ||
635 | * | ||
636 | * @param purp purpose of the signature, must match 'ps->purpose.purpose' | ||
637 | * (except in host byte order) | ||
638 | * @param ps packed struct with what to sign, MUST begin with a purpose | ||
639 | * @param sig where to read the signature from | ||
640 | * @param pub public key to use for the verifying | ||
641 | */ | ||
642 | #define GNUNET_IDENTITY_signature_verify(purp,ps,sig,pub) ({ \ | ||
643 | /* check size is set correctly */ \ | ||
644 | GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \ | ||
645 | /* check 'ps' begins with the purpose */ \ | ||
646 | GNUNET_static_assert (((void*) (ps)) == \ | ||
647 | ((void*) &(ps)->purpose)); \ | ||
648 | GNUNET_IDENTITY_signature_verify_ (purp, \ | ||
649 | &(ps)->purpose, \ | ||
650 | sig, \ | ||
651 | pub); \ | ||
652 | }) | ||
653 | |||
654 | |||
655 | /** | ||
656 | * Encrypt a block with #GNUNET_IDENTITY_PublicKey and derives a | ||
657 | * #GNUNET_CRYPTO_EcdhePublicKey which is required for decryption | ||
658 | * using ecdh to derive a symmetric key. | ||
659 | * | ||
660 | * @param block the block to encrypt | ||
661 | * @param size the size of the @a block | ||
662 | * @param pub public key to use for ecdh | ||
663 | * @param ecc where to write the ecc public key | ||
664 | * @param result the output parameter in which to store the encrypted result | ||
665 | * can be the same or overlap with @c block | ||
666 | * @returns the size of the encrypted block, -1 for errors. | ||
667 | * Due to the use of CFB and therefore an effective stream cipher, | ||
668 | * this size should be the same as @c len. | ||
669 | */ | ||
670 | ssize_t | ||
671 | GNUNET_IDENTITY_encrypt (const void *block, | ||
672 | size_t size, | ||
673 | const struct GNUNET_IDENTITY_PublicKey *pub, | ||
674 | struct GNUNET_CRYPTO_EcdhePublicKey *ecc, | ||
675 | void *result); | ||
676 | |||
677 | |||
678 | /** | ||
679 | * Decrypt a given block with #GNUNET_IDENTITY_PrivateKey and a given | ||
680 | * #GNUNET_CRYPTO_EcdhePublicKey using ecdh to derive a symmetric key. | ||
681 | * | ||
682 | * @param block the data to decrypt, encoded as returned by encrypt | ||
683 | * @param size the size of the @a block to decrypt | ||
684 | * @param priv private key to use for ecdh | ||
685 | * @param ecc the ecc public key | ||
686 | * @param result address to store the result at | ||
687 | * can be the same or overlap with @c block | ||
688 | * @return -1 on failure, size of decrypted block on success. | ||
689 | * Due to the use of CFB and therefore an effective stream cipher, | ||
690 | * this size should be the same as @c size. | ||
691 | */ | ||
692 | ssize_t | ||
693 | GNUNET_IDENTITY_decrypt (const void *block, | ||
694 | size_t size, | ||
695 | const struct | ||
696 | GNUNET_IDENTITY_PrivateKey *priv, | ||
697 | const struct | ||
698 | GNUNET_CRYPTO_EcdhePublicKey *ecc, | ||
699 | void *result); | ||
700 | |||
701 | |||
702 | /** | ||
703 | * Creates a (Base32) string representation of the public key. | ||
704 | * The resulting string encodes a compacted representation of the key. | ||
705 | * See also #GNUNET_IDENTITY_key_get_length. | ||
706 | * | ||
707 | * @param key the key. | ||
708 | * @return the string representation of the key, or NULL on error. | ||
709 | */ | ||
710 | char * | ||
711 | GNUNET_IDENTITY_public_key_to_string (const struct | ||
712 | GNUNET_IDENTITY_PublicKey *key); | ||
713 | |||
714 | |||
715 | /** | ||
716 | * Creates a (Base32) string representation of the private key. | ||
717 | * The resulting string encodes a compacted representation of the key. | ||
718 | * See also #GNUNET_IDENTITY_key_get_length. | ||
719 | * | ||
720 | * @param key the key. | ||
721 | * @return the string representation of the key, or NULL on error. | ||
722 | */ | ||
723 | char * | ||
724 | GNUNET_IDENTITY_private_key_to_string (const struct | ||
725 | GNUNET_IDENTITY_PrivateKey *key); | ||
726 | |||
727 | |||
728 | /** | ||
729 | * Parses a (Base32) string representation of the public key. | ||
730 | * See also #GNUNET_IDENTITY_public_key_to_string. | ||
731 | * | ||
732 | * @param str the encoded key. | ||
733 | * @param key where to write the key. | ||
734 | * @return GNUNET_SYSERR on error. | ||
735 | */ | ||
736 | enum GNUNET_GenericReturnValue | ||
737 | GNUNET_IDENTITY_public_key_from_string (const char*str, | ||
738 | struct GNUNET_IDENTITY_PublicKey *key); | ||
739 | |||
740 | |||
741 | /** | ||
742 | * Parses a (Base32) string representation of the private key. | ||
743 | * See also #GNUNET_IDENTITY_private_key_to_string. | ||
744 | * | ||
745 | * @param str the encoded key. | ||
746 | * @param key where to write the key. | ||
747 | * @return GNUNET_SYSERR on error. | ||
748 | */ | ||
749 | enum GNUNET_GenericReturnValue | ||
750 | GNUNET_IDENTITY_private_key_from_string (const char*str, | ||
751 | struct GNUNET_IDENTITY_PrivateKey *key); | ||
752 | |||
753 | |||
754 | /** | ||
755 | * Retrieves the public key representation of a private key. | ||
756 | * | ||
757 | * @param privkey the private key. | ||
758 | * @param key the public key result. | ||
759 | * @return GNUNET_SYSERR on error. | ||
760 | */ | ||
761 | enum GNUNET_GenericReturnValue | ||
762 | GNUNET_IDENTITY_key_get_public (const struct | ||
763 | GNUNET_IDENTITY_PrivateKey *privkey, | ||
764 | struct GNUNET_IDENTITY_PublicKey *key); | ||
765 | |||
766 | |||
767 | /* ************* convenience API to lookup an ego ***************** */ | 312 | /* ************* convenience API to lookup an ego ***************** */ |
768 | 313 | ||
769 | /** | 314 | /** |
@@ -816,7 +361,7 @@ GNUNET_IDENTITY_ego_lookup_cancel (struct GNUNET_IDENTITY_EgoLookup *el); | |||
816 | typedef void | 361 | typedef void |
817 | (*GNUNET_IDENTITY_EgoSuffixCallback) ( | 362 | (*GNUNET_IDENTITY_EgoSuffixCallback) ( |
818 | void *cls, | 363 | void *cls, |
819 | const struct GNUNET_IDENTITY_PrivateKey *priv, | 364 | const struct GNUNET_CRYPTO_PrivateKey *priv, |
820 | const char *ego_name); | 365 | const char *ego_name); |
821 | 366 | ||
822 | 367 | ||
@@ -839,11 +384,11 @@ struct GNUNET_IDENTITY_EgoSuffixLookup; | |||
839 | * @return handle to abort the operation | 384 | * @return handle to abort the operation |
840 | */ | 385 | */ |
841 | struct GNUNET_IDENTITY_EgoSuffixLookup * | 386 | struct GNUNET_IDENTITY_EgoSuffixLookup * |
842 | GNUNET_IDENTITY_ego_lookup_by_suffix (const struct | 387 | GNUNET_IDENTITY_ego_lookup_by_suffix ( |
843 | GNUNET_CONFIGURATION_Handle *cfg, | 388 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
844 | const char *suffix, | 389 | const char *suffix, |
845 | GNUNET_IDENTITY_EgoSuffixCallback cb, | 390 | GNUNET_IDENTITY_EgoSuffixCallback cb, |
846 | void *cb_cls); | 391 | void *cb_cls); |
847 | 392 | ||
848 | 393 | ||
849 | /** | 394 | /** |
@@ -868,4 +413,6 @@ GNUNET_IDENTITY_ego_lookup_by_suffix_cancel ( | |||
868 | 413 | ||
869 | /** @} */ /* end of group identity */ | 414 | /** @} */ /* end of group identity */ |
870 | 415 | ||
416 | /** @} */ /* end of group addition */ | ||
417 | |||
871 | /* end of gnunet_identity_service.h */ | 418 | /* end of gnunet_identity_service.h */ |
diff --git a/src/include/gnunet_json_lib.h b/src/include/gnunet_json_lib.h index 2002a0130..0b6b299d1 100644 --- a/src/include/gnunet_json_lib.h +++ b/src/include/gnunet_json_lib.h | |||
@@ -27,6 +27,7 @@ | |||
27 | #ifndef GNUNET_JSON_LIB_H | 27 | #ifndef GNUNET_JSON_LIB_H |
28 | #define GNUNET_JSON_LIB_H | 28 | #define GNUNET_JSON_LIB_H |
29 | 29 | ||
30 | |||
30 | #include "gnunet_util_lib.h" | 31 | #include "gnunet_util_lib.h" |
31 | #include <jansson.h> | 32 | #include <jansson.h> |
32 | #include <microhttpd.h> | 33 | #include <microhttpd.h> |
@@ -129,7 +130,7 @@ struct GNUNET_JSON_Specification | |||
129 | * @param root the JSON node to start the navigation at. | 130 | * @param root the JSON node to start the navigation at. |
130 | * @param spec parse specification array | 131 | * @param spec parse specification array |
131 | * @param[out] error_json_name which JSON field was problematic | 132 | * @param[out] error_json_name which JSON field was problematic |
132 | * @param[out] which index into @a spec did we encounter an error | 133 | * @param[out] error_line which index into @a spec did we encounter an error |
133 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 134 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
134 | */ | 135 | */ |
135 | enum GNUNET_GenericReturnValue | 136 | enum GNUNET_GenericReturnValue |
@@ -141,7 +142,13 @@ GNUNET_JSON_parse (const json_t *root, | |||
141 | 142 | ||
142 | /** | 143 | /** |
143 | * Frees all elements allocated during a #GNUNET_JSON_parse() | 144 | * Frees all elements allocated during a #GNUNET_JSON_parse() |
144 | * operation. | 145 | * operation. Convenience function to be called if cleaning |
146 | * up all heap-allocated data from a #GNUNET_JSON_parse() is | ||
147 | * desired. The function does not have to be called if no data | ||
148 | * was heap-allocated (e.g. only integers, strings and fixed-sized | ||
149 | * data was used), or if the application calls the respective | ||
150 | * code to free the heap (not always #GNUNET_free(), depends | ||
151 | * on the data type!) on the returned heap-allocated data itself. | ||
145 | * | 152 | * |
146 | * @param spec specification of the parse operation | 153 | * @param spec specification of the parse operation |
147 | */ | 154 | */ |
@@ -197,6 +204,29 @@ GNUNET_JSON_spec_fixed (const char *name, | |||
197 | 204 | ||
198 | 205 | ||
199 | /** | 206 | /** |
207 | * Variable size object (in network byte order, encoded using base64 encoding). | ||
208 | * | ||
209 | * @param name name of the JSON field | ||
210 | * @param[out] obj pointer where to write the data, must have @a size bytes | ||
211 | * @param size number of bytes expected in @a obj | ||
212 | */ | ||
213 | struct GNUNET_JSON_Specification | ||
214 | GNUNET_JSON_spec_fixed64 (const char *name, | ||
215 | void *obj, | ||
216 | size_t size); | ||
217 | |||
218 | |||
219 | /** | ||
220 | * Fixed size object (in network byte order, encoded using base64 encoding). | ||
221 | * | ||
222 | * @param name name of the JSON field | ||
223 | * @param obj pointer where to write the data (type of `*obj` will determine size) | ||
224 | */ | ||
225 | #define GNUNET_JSON_spec_fixed64_auto(name, obj) \ | ||
226 | GNUNET_JSON_spec_fixed (name, obj, sizeof(*obj)) | ||
227 | |||
228 | |||
229 | /** | ||
200 | * Variable size object (in network byte order, encoded using | 230 | * Variable size object (in network byte order, encoded using |
201 | * Crockford Base32hex encoding). | 231 | * Crockford Base32hex encoding). |
202 | * | 232 | * |
@@ -222,7 +252,8 @@ GNUNET_JSON_spec_string (const char *name, | |||
222 | 252 | ||
223 | 253 | ||
224 | /** | 254 | /** |
225 | * JSON object. | 255 | * JSON object or array. Reference counter is |
256 | * incremented. | ||
226 | * | 257 | * |
227 | * @param name name of the JSON field | 258 | * @param name name of the JSON field |
228 | * @param[out] jsonp where to store the JSON found under @a name | 259 | * @param[out] jsonp where to store the JSON found under @a name |
@@ -233,6 +264,28 @@ GNUNET_JSON_spec_json (const char *name, | |||
233 | 264 | ||
234 | 265 | ||
235 | /** | 266 | /** |
267 | * JSON object, reference counter not incremented. | ||
268 | * | ||
269 | * @param name name of the JSON field | ||
270 | * @param[out] jsonp where to store the JSON found under @a name | ||
271 | */ | ||
272 | struct GNUNET_JSON_Specification | ||
273 | GNUNET_JSON_spec_object_const (const char *name, | ||
274 | const json_t **jsonp); | ||
275 | |||
276 | |||
277 | /** | ||
278 | * JSON array, reference counter not incremented. | ||
279 | * | ||
280 | * @param name name of the JSON field | ||
281 | * @param[out] jsonp where to store the JSON found under @a name | ||
282 | */ | ||
283 | struct GNUNET_JSON_Specification | ||
284 | GNUNET_JSON_spec_array_const (const char *name, | ||
285 | const json_t **jsonp); | ||
286 | |||
287 | |||
288 | /** | ||
236 | * boolean. | 289 | * boolean. |
237 | * | 290 | * |
238 | * @param name name of the JSON field | 291 | * @param name name of the JSON field |
@@ -244,6 +297,17 @@ GNUNET_JSON_spec_bool (const char *name, | |||
244 | 297 | ||
245 | 298 | ||
246 | /** | 299 | /** |
300 | * double. | ||
301 | * | ||
302 | * @param name name of the JSON field | ||
303 | * @param[out] f where to store the double found under @a name | ||
304 | */ | ||
305 | struct GNUNET_JSON_Specification | ||
306 | GNUNET_JSON_spec_double (const char *name, | ||
307 | double *f); | ||
308 | |||
309 | |||
310 | /** | ||
247 | * 8-bit integer. | 311 | * 8-bit integer. |
248 | * | 312 | * |
249 | * @param name name of the JSON field | 313 | * @param name name of the JSON field |
@@ -315,7 +379,7 @@ GNUNET_JSON_spec_boolean (const char *name, | |||
315 | * Timestamp. | 379 | * Timestamp. |
316 | * | 380 | * |
317 | * @param name name of the JSON field | 381 | * @param name name of the JSON field |
318 | * @param[out] at where to store the absolute time found under @a name | 382 | * @param[out] t at where to store the absolute time found under @a name |
319 | */ | 383 | */ |
320 | struct GNUNET_JSON_Specification | 384 | struct GNUNET_JSON_Specification |
321 | GNUNET_JSON_spec_timestamp (const char *name, | 385 | GNUNET_JSON_spec_timestamp (const char *name, |
@@ -378,7 +442,21 @@ GNUNET_JSON_spec_rsa_signature (const char *name, | |||
378 | * @return json string that encodes @a data | 442 | * @return json string that encodes @a data |
379 | */ | 443 | */ |
380 | json_t * | 444 | json_t * |
381 | GNUNET_JSON_from_data (const void *data, size_t size); | 445 | GNUNET_JSON_from_data (const void *data, |
446 | size_t size); | ||
447 | |||
448 | |||
449 | /** | ||
450 | * Convert binary data to a JSON string with base64 | ||
451 | * encoding. | ||
452 | * | ||
453 | * @param data binary data | ||
454 | * @param size size of @a data in bytes | ||
455 | * @return json string that encodes @a data | ||
456 | */ | ||
457 | json_t * | ||
458 | GNUNET_JSON_from_data64 (const void *data, | ||
459 | size_t size); | ||
382 | 460 | ||
383 | 461 | ||
384 | /** | 462 | /** |
@@ -393,6 +471,17 @@ GNUNET_JSON_from_data (const void *data, size_t size); | |||
393 | 471 | ||
394 | 472 | ||
395 | /** | 473 | /** |
474 | * Convert binary data to a JSON string with base64 | ||
475 | * encoding. | ||
476 | * | ||
477 | * @param ptr binary data, sizeof (*ptr) must yield correct size | ||
478 | * @return json string that encodes @a data | ||
479 | */ | ||
480 | #define GNUNET_JSON_from_data64_auto(ptr) \ | ||
481 | GNUNET_JSON_from_data64 (ptr, sizeof(*ptr)) | ||
482 | |||
483 | |||
484 | /** | ||
396 | * Convert timestamp to a json string. | 485 | * Convert timestamp to a json string. |
397 | * | 486 | * |
398 | * @param stamp the time stamp | 487 | * @param stamp the time stamp |
@@ -632,6 +721,19 @@ GNUNET_JSON_pack_bool (const char *name, | |||
632 | 721 | ||
633 | /** | 722 | /** |
634 | * Generate packer instruction for a JSON field of type | 723 | * Generate packer instruction for a JSON field of type |
724 | * double. | ||
725 | * | ||
726 | * @param name name of the field to add to the object | ||
727 | * @param f double value | ||
728 | * @return json pack specification | ||
729 | */ | ||
730 | struct GNUNET_JSON_PackSpec | ||
731 | GNUNET_JSON_pack_double (const char *name, | ||
732 | double f); | ||
733 | |||
734 | |||
735 | /** | ||
736 | * Generate packer instruction for a JSON field of type | ||
635 | * string. | 737 | * string. |
636 | * | 738 | * |
637 | * @param name name of the field to add to the object | 739 | * @param name name of the field to add to the object |
@@ -755,6 +857,37 @@ GNUNET_JSON_pack_data_varsize (const char *name, | |||
755 | 857 | ||
756 | /** | 858 | /** |
757 | * Generate packer instruction for a JSON field of type | 859 | * Generate packer instruction for a JSON field of type |
860 | * variable size binary blob. | ||
861 | * Use base64-encoding, instead of the more common | ||
862 | * Crockford base32-encoding. | ||
863 | * | ||
864 | * @param name name of the field to add to the object | ||
865 | * @param blob binary data to pack | ||
866 | * @param blob_size number of bytes in @a blob | ||
867 | * @return json pack specification | ||
868 | */ | ||
869 | struct GNUNET_JSON_PackSpec | ||
870 | GNUNET_JSON_pack_data64_varsize (const char *name, | ||
871 | const void *blob, | ||
872 | size_t blob_size); | ||
873 | |||
874 | |||
875 | /** | ||
876 | * Generate packer instruction for a JSON field where the | ||
877 | * size is automatically determined from the argument. | ||
878 | * Use base64-encoding, instead of the more common | ||
879 | * Crockford base32-encoding. | ||
880 | * | ||
881 | * @param name name of the field to add to the object | ||
882 | * @param blob data to pack, must not be an array | ||
883 | * @return json pack specification | ||
884 | */ | ||
885 | #define GNUNET_JSON_pack_data64_auto(name,blob) \ | ||
886 | GNUNET_JSON_pack_data64_varsize (name, blob, sizeof (*blob)) | ||
887 | |||
888 | |||
889 | /** | ||
890 | * Generate packer instruction for a JSON field of type | ||
758 | * timestamp. | 891 | * timestamp. |
759 | * | 892 | * |
760 | * @param name name of the field to add to the object | 893 | * @param name name of the field to add to the object |
@@ -833,6 +966,19 @@ GNUNET_JSON_pack_rsa_signature (const char *name, | |||
833 | const struct GNUNET_CRYPTO_RsaSignature *sig); | 966 | const struct GNUNET_CRYPTO_RsaSignature *sig); |
834 | 967 | ||
835 | 968 | ||
969 | /** | ||
970 | * Generate packer instruction for a JSON field of type | ||
971 | * unblinded signature. | ||
972 | * | ||
973 | * @param name name of the field to add to the object | ||
974 | * @param sig unblinded signature | ||
975 | * @return json pack specification | ||
976 | */ | ||
977 | struct GNUNET_JSON_PackSpec | ||
978 | GNUNET_JSON_pack_unblinded_signature (const char *name, | ||
979 | const struct GNUNET_CRYPTO_UnblindedSignature *sig); | ||
980 | |||
981 | |||
836 | #endif | 982 | #endif |
837 | 983 | ||
838 | /* end of gnunet_json_lib.h */ | 984 | /* end of gnunet_json_lib.h */ |
diff --git a/src/include/gnunet_load_lib.h b/src/include/gnunet_load_lib.h index ef596807a..56cacfbbb 100644 --- a/src/include/gnunet_load_lib.h +++ b/src/include/gnunet_load_lib.h | |||
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup libgnunetutil | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
@@ -40,6 +43,7 @@ extern "C" | |||
40 | #endif | 43 | #endif |
41 | #endif | 44 | #endif |
42 | 45 | ||
46 | |||
43 | #include "gnunet_common.h" | 47 | #include "gnunet_common.h" |
44 | #include "gnunet_time_lib.h" | 48 | #include "gnunet_time_lib.h" |
45 | 49 | ||
@@ -124,4 +128,6 @@ GNUNET_LOAD_update (struct GNUNET_LOAD_Value *load, uint64_t data); | |||
124 | 128 | ||
125 | /** @} */ /* end of group */ | 129 | /** @} */ /* end of group */ |
126 | 130 | ||
131 | /** @} */ /* end of group addition to libgnunetutil */ | ||
132 | |||
127 | /* end of gnunet_load_lib.h */ | 133 | /* end of gnunet_load_lib.h */ |
diff --git a/src/include/gnunet_messenger_service.h b/src/include/gnunet_messenger_service.h index f8bbc7398..1bc68b87b 100644 --- a/src/include/gnunet_messenger_service.h +++ b/src/include/gnunet_messenger_service.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2020--2022 GNUnet e.V. | 3 | Copyright (C) 2020--2024 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -39,21 +39,21 @@ extern "C" { | |||
39 | #endif | 39 | #endif |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | #include "platform.h" | 42 | #include "gnunet_common.h" |
43 | #include "gnunet_configuration_lib.h" | 43 | #include "gnunet_configuration_lib.h" |
44 | #include "gnunet_crypto_lib.h" | ||
45 | #include "gnunet_identity_service.h" | 44 | #include "gnunet_identity_service.h" |
46 | #include "gnunet_mq_lib.h" | 45 | #include "gnunet_reclaim_lib.h" |
47 | #include "gnunet_protocols.h" | 46 | #include "gnunet_reclaim_service.h" |
48 | #include "gnunet_scheduler_lib.h" | 47 | #include "gnunet_scheduler_lib.h" |
49 | #include "gnunet_time_lib.h" | 48 | #include "gnunet_time_lib.h" |
49 | #include "gnunet_util_lib.h" | ||
50 | 50 | ||
51 | /** | 51 | /** |
52 | * Version number of GNUnet Messenger API. | 52 | * Version number of GNUnet Messenger API. |
53 | * | 53 | * |
54 | * Current version of the Messenger: 0.1 | 54 | * Current version of the Messenger: 0.3 |
55 | */ | 55 | */ |
56 | #define GNUNET_MESSENGER_VERSION 0x00000001 | 56 | #define GNUNET_MESSENGER_VERSION 0x00000003 |
57 | 57 | ||
58 | /** | 58 | /** |
59 | * Identifier of GNUnet MESSENGER Service. | 59 | * Identifier of GNUnet MESSENGER Service. |
@@ -96,7 +96,7 @@ struct GNUNET_MESSENGER_RoomEntryRecord | |||
96 | 96 | ||
97 | GNUNET_NETWORK_STRUCT_END | 97 | GNUNET_NETWORK_STRUCT_END |
98 | 98 | ||
99 | GNUNET_NETWORK_STRUCT_BEGIN | 99 | GNUNET_NETWORK_STRUCT_BEGIN |
100 | 100 | ||
101 | /** | 101 | /** |
102 | * A room details record specifies a custom name for a given room and | 102 | * A room details record specifies a custom name for a given room and |
@@ -107,7 +107,7 @@ struct GNUNET_MESSENGER_RoomDetailsRecord | |||
107 | /** | 107 | /** |
108 | * The custom name for the room. | 108 | * The custom name for the room. |
109 | */ | 109 | */ |
110 | char name [256]; | 110 | char name[256]; |
111 | 111 | ||
112 | /** | 112 | /** |
113 | * The flags of the room. | 113 | * The flags of the room. |
@@ -198,6 +198,26 @@ enum GNUNET_MESSENGER_MessageKind | |||
198 | GNUNET_MESSENGER_KIND_DELETE = 15, | 198 | GNUNET_MESSENGER_KIND_DELETE = 15, |
199 | 199 | ||
200 | /** | 200 | /** |
201 | * The connection kind. The message contains a #GNUNET_MESSENGER_MessageConnection body. | ||
202 | */ | ||
203 | GNUNET_MESSENGER_KIND_CONNECTION = 16, | ||
204 | |||
205 | /** | ||
206 | * The ticket kind. The message contains a #GNUNET_MESSENGER_MessageTicket body. | ||
207 | */ | ||
208 | GNUNET_MESSENGER_KIND_TICKET = 17, | ||
209 | |||
210 | /** | ||
211 | * The transcript kind. The message contains a #GNUNET_MESSENGER_MessageTranscript body. | ||
212 | */ | ||
213 | GNUNET_MESSENGER_KIND_TRANSCRIPT = 18, | ||
214 | |||
215 | /** | ||
216 | * The tag kind. The message contains a #GNUNET_MESSENGER_MessageTag body. | ||
217 | */ | ||
218 | GNUNET_MESSENGER_KIND_TAG = 19, | ||
219 | |||
220 | /** | ||
201 | * The unknown kind. The message contains an unknown body. | 221 | * The unknown kind. The message contains an unknown body. |
202 | */ | 222 | */ |
203 | GNUNET_MESSENGER_KIND_UNKNOWN = 0 | 223 | GNUNET_MESSENGER_KIND_UNKNOWN = 0 |
@@ -225,7 +245,7 @@ struct GNUNET_MESSENGER_MessageHeader | |||
225 | /** | 245 | /** |
226 | * The signature of the senders private key. | 246 | * The signature of the senders private key. |
227 | */ | 247 | */ |
228 | struct GNUNET_IDENTITY_Signature signature; | 248 | struct GNUNET_CRYPTO_Signature signature; |
229 | 249 | ||
230 | /** | 250 | /** |
231 | * The timestamp of the message. | 251 | * The timestamp of the message. |
@@ -257,11 +277,6 @@ struct GNUNET_MESSENGER_MessageHeader | |||
257 | struct GNUNET_MESSENGER_MessageInfo | 277 | struct GNUNET_MESSENGER_MessageInfo |
258 | { | 278 | { |
259 | /** | 279 | /** |
260 | * The senders key to verify its signatures. | ||
261 | */ | ||
262 | struct GNUNET_IDENTITY_PublicKey host_key; | ||
263 | |||
264 | /** | ||
265 | * The version of GNUnet Messenger API. | 280 | * The version of GNUnet Messenger API. |
266 | * | 281 | * |
267 | * The sixteen lower bits represent the lower version number while the sixteen higher bits | 282 | * The sixteen lower bits represent the lower version number while the sixteen higher bits |
@@ -282,7 +297,7 @@ struct GNUNET_MESSENGER_MessageJoin | |||
282 | /** | 297 | /** |
283 | * The senders public key to verify its signatures. | 298 | * The senders public key to verify its signatures. |
284 | */ | 299 | */ |
285 | struct GNUNET_IDENTITY_PublicKey key; | 300 | struct GNUNET_CRYPTO_PublicKey key; |
286 | }; | 301 | }; |
287 | 302 | ||
288 | /** | 303 | /** |
@@ -320,7 +335,7 @@ struct GNUNET_MESSENGER_MessageKey | |||
320 | /** | 335 | /** |
321 | * The new public key which replaces the current senders public key. | 336 | * The new public key which replaces the current senders public key. |
322 | */ | 337 | */ |
323 | struct GNUNET_IDENTITY_PublicKey key; | 338 | struct GNUNET_CRYPTO_PublicKey key; |
324 | }; | 339 | }; |
325 | 340 | ||
326 | /** | 341 | /** |
@@ -499,6 +514,87 @@ struct GNUNET_MESSENGER_MessageDelete | |||
499 | }; | 514 | }; |
500 | 515 | ||
501 | /** | 516 | /** |
517 | * A connection message body | ||
518 | * This allows to tell others about connection information about a peer. | ||
519 | * | ||
520 | * Message-body-size: 8 bytes | ||
521 | */ | ||
522 | struct GNUNET_MESSENGER_MessageConnection | ||
523 | { | ||
524 | /** | ||
525 | * The amount of connections of a peer. | ||
526 | */ | ||
527 | uint32_t amount; | ||
528 | |||
529 | /** | ||
530 | * The flags about the connections of a peer. | ||
531 | */ | ||
532 | uint32_t flags; | ||
533 | }; | ||
534 | |||
535 | /** | ||
536 | * A ticket message body | ||
537 | * This allows to exchange ticket identifiers with an audience. | ||
538 | * | ||
539 | * Message-body-size: 32 bytes | ||
540 | */ | ||
541 | struct GNUNET_MESSENGER_MessageTicket | ||
542 | { | ||
543 | /** | ||
544 | * The identifier of a RECLAIM ticket. | ||
545 | */ | ||
546 | struct GNUNET_RECLAIM_Identifier identifier; | ||
547 | }; | ||
548 | |||
549 | /** | ||
550 | * A transcript message body | ||
551 | * This allows reading the content of a sent private message. | ||
552 | * | ||
553 | * Message-body-size: 68+ | ||
554 | */ | ||
555 | struct GNUNET_MESSENGER_MessageTranscript | ||
556 | { | ||
557 | /** | ||
558 | * The hash of the original message. | ||
559 | */ | ||
560 | struct GNUNET_HashCode hash; | ||
561 | |||
562 | /** | ||
563 | * The key from the recipient of the original message. | ||
564 | */ | ||
565 | struct GNUNET_CRYPTO_PublicKey key; | ||
566 | |||
567 | /** | ||
568 | * The length of the transcribed message. | ||
569 | */ | ||
570 | uint16_t length; | ||
571 | |||
572 | /** | ||
573 | * The data of the transcribed message. | ||
574 | */ | ||
575 | char *data; | ||
576 | }; | ||
577 | |||
578 | /** | ||
579 | * A tag message body | ||
580 | * This allows tagging a message with a custom tag. | ||
581 | * | ||
582 | * Message-body-size: 32+ | ||
583 | */ | ||
584 | struct GNUNET_MESSENGER_MessageTag | ||
585 | { | ||
586 | /** | ||
587 | * The hash of the message to tag. | ||
588 | */ | ||
589 | struct GNUNET_HashCode hash; | ||
590 | |||
591 | /** | ||
592 | * The custom tag. | ||
593 | */ | ||
594 | char *tag; | ||
595 | }; | ||
596 | |||
597 | /** | ||
502 | * The unified body of a #GNUNET_MESSENGER_Message. | 598 | * The unified body of a #GNUNET_MESSENGER_Message. |
503 | */ | 599 | */ |
504 | struct GNUNET_MESSENGER_MessageBody | 600 | struct GNUNET_MESSENGER_MessageBody |
@@ -520,6 +616,10 @@ struct GNUNET_MESSENGER_MessageBody | |||
520 | struct GNUNET_MESSENGER_MessageFile file; | 616 | struct GNUNET_MESSENGER_MessageFile file; |
521 | struct GNUNET_MESSENGER_MessagePrivate privacy; | 617 | struct GNUNET_MESSENGER_MessagePrivate privacy; |
522 | struct GNUNET_MESSENGER_MessageDelete deletion; | 618 | struct GNUNET_MESSENGER_MessageDelete deletion; |
619 | struct GNUNET_MESSENGER_MessageConnection connection; | ||
620 | struct GNUNET_MESSENGER_MessageTicket ticket; | ||
621 | struct GNUNET_MESSENGER_MessageTranscript transcript; | ||
622 | struct GNUNET_MESSENGER_MessageTag tag; | ||
523 | }; | 623 | }; |
524 | }; | 624 | }; |
525 | 625 | ||
@@ -540,7 +640,7 @@ struct GNUNET_MESSENGER_Message | |||
540 | }; | 640 | }; |
541 | 641 | ||
542 | /** | 642 | /** |
543 | * Enum for the different supported flags used by message handling | 643 | * Enum for the different supported flags used by message handling. |
544 | * Compatible flags can be OR'ed together. | 644 | * Compatible flags can be OR'ed together. |
545 | */ | 645 | */ |
546 | enum GNUNET_MESSENGER_MessageFlags | 646 | enum GNUNET_MESSENGER_MessageFlags |
@@ -559,18 +659,44 @@ enum GNUNET_MESSENGER_MessageFlags | |||
559 | * The private flag. The flag indicates that the message was privately encrypted. | 659 | * The private flag. The flag indicates that the message was privately encrypted. |
560 | */ | 660 | */ |
561 | GNUNET_MESSENGER_FLAG_PRIVATE = 2, | 661 | GNUNET_MESSENGER_FLAG_PRIVATE = 2, |
662 | |||
663 | /** | ||
664 | * The peer flag. The flag indicates that the message was sent by a peer and not a member. | ||
665 | */ | ||
666 | GNUNET_MESSENGER_FLAG_PEER = 4, | ||
667 | |||
668 | /** | ||
669 | * The recent flag. The flag indicates that the message was recently handled by the service. | ||
670 | */ | ||
671 | GNUNET_MESSENGER_FLAG_RECENT = 8, | ||
672 | |||
673 | /** | ||
674 | * The update flag. The flag indicates that the message was updated by the client. | ||
675 | */ | ||
676 | GNUNET_MESSENGER_FLAG_UPDATE = 16, | ||
677 | |||
678 | /** | ||
679 | * The delete flag. The flag indicates that the message was deleted by the service. | ||
680 | */ | ||
681 | GNUNET_MESSENGER_FLAG_DELETE = 32, | ||
562 | }; | 682 | }; |
563 | 683 | ||
564 | /** | 684 | /** |
565 | * Method called whenever the EGO of a <i>handle</i> changes or if the first connection fails | 685 | * Enum for the different supported flags used to specify connection handling. |
566 | * to load a valid EGO and the anonymous key pair will be used instead. | 686 | * Compatible flags can be OR'ed together. |
567 | * | ||
568 | * @param[in/out] cls Closure from #GNUNET_MESSENGER_connect | ||
569 | * @param[in/out] handle Messenger handle | ||
570 | */ | 687 | */ |
571 | typedef void | 688 | enum GNUNET_MESSENGER_ConnectionFlags |
572 | (*GNUNET_MESSENGER_IdentityCallback) (void *cls, | 689 | { |
573 | struct GNUNET_MESSENGER_Handle *handle); | 690 | /** |
691 | * The none flag. The flag indicates that the connection is not affected by any modifications. | ||
692 | */ | ||
693 | GNUNET_MESSENGER_FLAG_CONNECTION_NONE = 0,/**< GNUNET_MESSENGER_FLAG_CONNECTION_NONE */ | ||
694 | |||
695 | /** | ||
696 | * The auto flag. The flag indicates that a peer will automatically handle routing. | ||
697 | */ | ||
698 | GNUNET_MESSENGER_FLAG_CONNECTION_AUTO = 1,/**< GNUNET_MESSENGER_FLAG_CONNECTION_AUTO */ | ||
699 | }; | ||
574 | 700 | ||
575 | /** | 701 | /** |
576 | * Method called whenever a message is sent or received from a <i>room</i>. | 702 | * Method called whenever a message is sent or received from a <i>room</i>. |
@@ -581,6 +707,7 @@ typedef void | |||
581 | * @param[in/out] cls Closure from #GNUNET_MESSENGER_connect | 707 | * @param[in/out] cls Closure from #GNUNET_MESSENGER_connect |
582 | * @param[in] room Room handle | 708 | * @param[in] room Room handle |
583 | * @param[in] sender Sender of message | 709 | * @param[in] sender Sender of message |
710 | * @param[in] recipient Recipient of message | ||
584 | * @param[in] message Newly received or sent message | 711 | * @param[in] message Newly received or sent message |
585 | * @param[in] hash Hash identifying the message | 712 | * @param[in] hash Hash identifying the message |
586 | * @param[in] flags Flags of the message | 713 | * @param[in] flags Flags of the message |
@@ -588,8 +715,12 @@ typedef void | |||
588 | typedef void | 715 | typedef void |
589 | (*GNUNET_MESSENGER_MessageCallback) (void *cls, | 716 | (*GNUNET_MESSENGER_MessageCallback) (void *cls, |
590 | struct GNUNET_MESSENGER_Room *room, | 717 | struct GNUNET_MESSENGER_Room *room, |
591 | const struct GNUNET_MESSENGER_Contact *sender, | 718 | const struct |
592 | const struct GNUNET_MESSENGER_Message *message, | 719 | GNUNET_MESSENGER_Contact *sender, |
720 | const struct | ||
721 | GNUNET_MESSENGER_Contact *recipient, | ||
722 | const struct | ||
723 | GNUNET_MESSENGER_Message *message, | ||
593 | const struct GNUNET_HashCode *hash, | 724 | const struct GNUNET_HashCode *hash, |
594 | enum GNUNET_MESSENGER_MessageFlags flags); | 725 | enum GNUNET_MESSENGER_MessageFlags flags); |
595 | 726 | ||
@@ -601,49 +732,34 @@ typedef void | |||
601 | * @param[in] room Room handle | 732 | * @param[in] room Room handle |
602 | * @param[in] contact Contact handle | 733 | * @param[in] contact Contact handle |
603 | */ | 734 | */ |
604 | typedef int | 735 | typedef enum GNUNET_GenericReturnValue |
605 | (*GNUNET_MESSENGER_MemberCallback) (void* cls, | 736 | (*GNUNET_MESSENGER_MemberCallback) (void *cls, |
606 | struct GNUNET_MESSENGER_Room *room, | 737 | struct GNUNET_MESSENGER_Room *room, |
607 | const struct GNUNET_MESSENGER_Contact *contact); | 738 | const struct |
739 | GNUNET_MESSENGER_Contact *contact); | ||
608 | 740 | ||
609 | /** | 741 | /** |
610 | * Set up a handle for the messenger related functions and connects to all necessary services. It will look up the ego | 742 | * Set up a handle for the messenger related functions and connects to all necessary services. It will use the |
611 | * key identified by its <i>name</i> and use it for signing all messages from the handle. | 743 | * a custom name in combination of a private key provided for signing all messages from the handle. |
612 | * | 744 | * |
613 | * @param[in] cfg Configuration to use | 745 | * @param[in] cfg Configuration to use |
614 | * @param[in] name Name to look up an ego or NULL to stay anonymous | 746 | * @param[in] name Name or NULL |
615 | * @param[in] identity_callback Function called when the EGO of the handle changes | 747 | * @param[in] key Private key or NULL to stay anonymous |
616 | * @param[in/out] identity_cls Closure for the <i>identity_callback</i> handler | ||
617 | * @param[in] msg_callback Function called when a new message is sent or received | 748 | * @param[in] msg_callback Function called when a new message is sent or received |
618 | * @param[in/out] msg_cls Closure for the <i>msg_callback</i> handler | 749 | * @param[in,out] msg_cls Closure for the <i>msg_callback</i> handler |
619 | * @return Messenger handle to use, NULL on error | 750 | * @return Messenger handle to use, NULL on error |
620 | */ | 751 | */ |
621 | struct GNUNET_MESSENGER_Handle* | 752 | struct GNUNET_MESSENGER_Handle* |
622 | GNUNET_MESSENGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | 753 | GNUNET_MESSENGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, |
623 | const char *name, | 754 | const char *name, |
624 | GNUNET_MESSENGER_IdentityCallback identity_callback, | 755 | const struct GNUNET_CRYPTO_PrivateKey *key, |
625 | void *identity_cls, | ||
626 | GNUNET_MESSENGER_MessageCallback msg_callback, | 756 | GNUNET_MESSENGER_MessageCallback msg_callback, |
627 | void *msg_cls); | 757 | void *msg_cls); |
628 | 758 | ||
629 | /** | 759 | /** |
630 | * Update a handle of the messenger to use a different ego key and replace the old one with a newly generated one. All | ||
631 | * participated rooms get informed about the key renewal. The handle requires a set name for this function to work and | ||
632 | * it needs to be unused by other egos. | ||
633 | * | ||
634 | * Keep in mind that this will fully delete the old ego key (if any is used) even if any other service wants to use it | ||
635 | * as default. | ||
636 | * | ||
637 | * @param[in/out] handle Messenger handle to use | ||
638 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure | ||
639 | */ | ||
640 | int | ||
641 | GNUNET_MESSENGER_update (struct GNUNET_MESSENGER_Handle *handle); | ||
642 | |||
643 | /** | ||
644 | * Disconnect all of the messengers used services and clears up its used memory. | 760 | * Disconnect all of the messengers used services and clears up its used memory. |
645 | * | 761 | * |
646 | * @param[in/out] handle Messenger handle to use | 762 | * @param[in,out] handle Messenger handle to use |
647 | */ | 763 | */ |
648 | void | 764 | void |
649 | GNUNET_MESSENGER_disconnect (struct GNUNET_MESSENGER_Handle *handle); | 765 | GNUNET_MESSENGER_disconnect (struct GNUNET_MESSENGER_Handle *handle); |
@@ -658,15 +774,14 @@ const char* | |||
658 | GNUNET_MESSENGER_get_name (const struct GNUNET_MESSENGER_Handle *handle); | 774 | GNUNET_MESSENGER_get_name (const struct GNUNET_MESSENGER_Handle *handle); |
659 | 775 | ||
660 | /** | 776 | /** |
661 | * Set the name for the messenger. This will rename the currently used ego and move all stored files related to the current | 777 | * Set the name for the messenger handle and sends messages renaming your contact in currently |
662 | * name to its new directory. If anything fails during this process the function returns #GNUNET_NO and the name for | 778 | * open rooms. |
663 | * the messenger won't change as specified. | ||
664 | * | 779 | * |
665 | * @param[in/out] handle Messenger handle to use | 780 | * @param[in,out] handle Messenger handle to use |
666 | * @param[in] name Name for the messenger to change to | 781 | * @param[in] name Name for the messenger to change to |
667 | * @return #GNUNET_YES on success, #GNUNET_NO on failure and #GNUNET_SYSERR if <i>handle</i> is NULL | 782 | * @return #GNUNET_YES on success, #GNUNET_NO on failure and #GNUNET_SYSERR if <i>handle</i> is NULL |
668 | */ | 783 | */ |
669 | int | 784 | enum GNUNET_GenericReturnValue |
670 | GNUNET_MESSENGER_set_name (struct GNUNET_MESSENGER_Handle *handle, | 785 | GNUNET_MESSENGER_set_name (struct GNUNET_MESSENGER_Handle *handle, |
671 | const char *name); | 786 | const char *name); |
672 | 787 | ||
@@ -674,12 +789,25 @@ GNUNET_MESSENGER_set_name (struct GNUNET_MESSENGER_Handle *handle, | |||
674 | * Get the public key used by the messenger or NULL if the anonymous key was used. | 789 | * Get the public key used by the messenger or NULL if the anonymous key was used. |
675 | * | 790 | * |
676 | * @param[in] handle Messenger handle to use | 791 | * @param[in] handle Messenger handle to use |
677 | * @return Used ego's public key or NULL | 792 | * @return Used public key or NULL |
678 | */ | 793 | */ |
679 | const struct GNUNET_IDENTITY_PublicKey* | 794 | const struct GNUNET_CRYPTO_PublicKey* |
680 | GNUNET_MESSENGER_get_key (const struct GNUNET_MESSENGER_Handle *handle); | 795 | GNUNET_MESSENGER_get_key (const struct GNUNET_MESSENGER_Handle *handle); |
681 | 796 | ||
682 | /** | 797 | /** |
798 | * Set the private key used by the messenger or NULL if the anonymous key should be | ||
799 | * used instead. The currently used key will be replaced and the change will get signed | ||
800 | * accordingly to be verified by all contacts. | ||
801 | * | ||
802 | * @param[in,out] handle Messenger handle to use | ||
803 | * @param[in] key Private key to change to or NULL | ||
804 | * @return #GNUNET_YES on success, #GNUNET_NO on failure and #GNUNET_SYSERR if <i>handle</i> is NULL | ||
805 | */ | ||
806 | enum GNUNET_GenericReturnValue | ||
807 | GNUNET_MESSENGER_set_key (struct GNUNET_MESSENGER_Handle *handle, | ||
808 | const struct GNUNET_CRYPTO_PrivateKey *key); | ||
809 | |||
810 | /** | ||
683 | * Open a room to send and receive messages. The room will use the specified <i>key</i> as port for the underlying cadet | 811 | * Open a room to send and receive messages. The room will use the specified <i>key</i> as port for the underlying cadet |
684 | * service. Opening a room results in opening the port for incoming connections as possible <b>door</b>. | 812 | * service. Opening a room results in opening the port for incoming connections as possible <b>door</b>. |
685 | * | 813 | * |
@@ -691,7 +819,7 @@ GNUNET_MESSENGER_get_key (const struct GNUNET_MESSENGER_Handle *handle); | |||
691 | * | 819 | * |
692 | * ( All <b>doors</b> form a ring structured network to shorten the latency sending and receiving messages. ) | 820 | * ( All <b>doors</b> form a ring structured network to shorten the latency sending and receiving messages. ) |
693 | * | 821 | * |
694 | * @param[in/out] handle Messenger handle to use | 822 | * @param[in,out] handle Messenger handle to use |
695 | * @param[in] key Hash identifying the port | 823 | * @param[in] key Hash identifying the port |
696 | * @return Room handle, NULL on error | 824 | * @return Room handle, NULL on error |
697 | */ | 825 | */ |
@@ -712,7 +840,7 @@ GNUNET_MESSENGER_open_room (struct GNUNET_MESSENGER_Handle *handle, | |||
712 | * | 840 | * |
713 | * ( All <b>doors</b> form a ring structured network to shorten the latency sending and receiving messages. ) | 841 | * ( All <b>doors</b> form a ring structured network to shorten the latency sending and receiving messages. ) |
714 | * | 842 | * |
715 | * @param[in/out] handle Messenger handle to use | 843 | * @param[in,out] handle Messenger handle to use |
716 | * @param[in] door Peer identity of an open <b>door</b> | 844 | * @param[in] door Peer identity of an open <b>door</b> |
717 | * @param[in] key Hash identifying the port | 845 | * @param[in] key Hash identifying the port |
718 | * @return Room handle, NULL on error | 846 | * @return Room handle, NULL on error |
@@ -729,7 +857,7 @@ GNUNET_MESSENGER_enter_room (struct GNUNET_MESSENGER_Handle *handle, | |||
729 | * ( After a member closes a <b>door</b>, all members entered through that specific <b>door</b> have to use another one | 857 | * ( After a member closes a <b>door</b>, all members entered through that specific <b>door</b> have to use another one |
730 | * or open the room on their own. ) | 858 | * or open the room on their own. ) |
731 | * | 859 | * |
732 | * @param[in/out] room Room handle | 860 | * @param[in,out] room Room handle |
733 | */ | 861 | */ |
734 | void | 862 | void |
735 | GNUNET_MESSENGER_close_room (struct GNUNET_MESSENGER_Room *room); | 863 | GNUNET_MESSENGER_close_room (struct GNUNET_MESSENGER_Room *room); |
@@ -774,25 +902,51 @@ GNUNET_MESSENGER_get_sender (const struct GNUNET_MESSENGER_Room *room, | |||
774 | const struct GNUNET_HashCode *hash); | 902 | const struct GNUNET_HashCode *hash); |
775 | 903 | ||
776 | /** | 904 | /** |
905 | * Get the contact of a member in a <i>room</i> which has been targeted as recipient of a specific message identified | ||
906 | * with a given <i>hash</i>. | ||
907 | * | ||
908 | * Notice that contacts are independent of rooms but will be removed if all rooms containing these contacts get closed. | ||
909 | * | ||
910 | * @param[in] room Room handle | ||
911 | * @param[in] hash Hash identifying a message | ||
912 | * @return Contact handle, NULL otherwise | ||
913 | */ | ||
914 | const struct GNUNET_MESSENGER_Contact* | ||
915 | GNUNET_MESSENGER_get_recipient (const struct GNUNET_MESSENGER_Room *room, | ||
916 | const struct GNUNET_HashCode *hash); | ||
917 | |||
918 | /** | ||
777 | * Get the name used by the <i>contact</i>. | 919 | * Get the name used by the <i>contact</i>. |
778 | * | 920 | * |
779 | * @param[in] contact Contact handle | 921 | * @param[in] contact Contact handle |
780 | * @return Name of <i>contact</i> or NULL | 922 | * @return Name of <i>contact</i> or NULL |
781 | */ | 923 | */ |
782 | const char* | 924 | const char* |
783 | GNUNET_MESSENGER_contact_get_name (const struct GNUNET_MESSENGER_Contact *contact); | 925 | GNUNET_MESSENGER_contact_get_name (const struct |
926 | GNUNET_MESSENGER_Contact *contact); | ||
784 | 927 | ||
785 | /** | 928 | /** |
786 | * Get the public key used by the <i>contact</i> or NULL if the anonymous key was used. | 929 | * Get the public key used by the <i>contact</i> or NULL if the anonymous key was used. |
787 | * | 930 | * |
788 | * @param[in] contact Contact handle | 931 | * @param[in] contact Contact handle |
789 | * @return Public key of the ego used by <i>contact</i> or NULL | 932 | * @return Public key used by <i>contact</i> or NULL |
790 | */ | 933 | */ |
791 | const struct GNUNET_IDENTITY_PublicKey* | 934 | const struct GNUNET_CRYPTO_PublicKey* |
792 | GNUNET_MESSENGER_contact_get_key (const struct GNUNET_MESSENGER_Contact *contact); | 935 | GNUNET_MESSENGER_contact_get_key (const struct |
936 | GNUNET_MESSENGER_Contact *contact); | ||
793 | 937 | ||
794 | /** | 938 | /** |
795 | * Send a <i>message</i> into a </i>room</i>. If you opened the <i>room</i> all entered members will receive the | 939 | * Get the locally unique id of the <i>contact</i>. |
940 | * | ||
941 | * @param[in] contact Contact handle | ||
942 | * @return Locally unique contact id or zero | ||
943 | */ | ||
944 | size_t | ||
945 | GNUNET_MESSENGER_contact_get_id (const struct | ||
946 | GNUNET_MESSENGER_Contact *contact); | ||
947 | |||
948 | /** | ||
949 | * Send a <i>message</i> into a <i>room</i>. If you opened the <i>room</i> all entered members will receive the | ||
796 | * <i>message</i>. If you entered the <i>room</i> through a <b>door</b> all so entered <b>doors</b> will receive the | 950 | * <i>message</i>. If you entered the <i>room</i> through a <b>door</b> all so entered <b>doors</b> will receive the |
797 | * <i>message</i> as well. All members receiving the <i>message</i> will also propagate this <i>message</i> recursively | 951 | * <i>message</i> as well. All members receiving the <i>message</i> will also propagate this <i>message</i> recursively |
798 | * as long as the <i>message</i> is unknown to them. | 952 | * as long as the <i>message</i> is unknown to them. |
@@ -805,14 +959,30 @@ GNUNET_MESSENGER_contact_get_key (const struct GNUNET_MESSENGER_Contact *contact | |||
805 | * | 959 | * |
806 | * Sending a message to all members in a given room can be done by providing NULL as contact. | 960 | * Sending a message to all members in a given room can be done by providing NULL as contact. |
807 | * | 961 | * |
808 | * @param[in/out] room Room handle | 962 | * @param[in,out] room Room handle |
809 | * @param[in] message New message to send | 963 | * @param[in,out] message New message to send |
810 | * @param[in] contact Contact or NULL | 964 | * @param[in] contact Contact or NULL |
811 | */ | 965 | */ |
812 | void | 966 | void |
813 | GNUNET_MESSENGER_send_message (struct GNUNET_MESSENGER_Room *room, | 967 | GNUNET_MESSENGER_send_message (struct GNUNET_MESSENGER_Room *room, |
814 | const struct GNUNET_MESSENGER_Message *message, | 968 | const struct GNUNET_MESSENGER_Message *message, |
815 | const struct GNUNET_MESSENGER_Contact* contact); | 969 | const struct GNUNET_MESSENGER_Contact *contact); |
970 | |||
971 | /** | ||
972 | * Delete a message identified by its <i>hash</i> from a <i>room</i>. A deletion will be propagated to all members | ||
973 | * of the room as with any other sent message. Notice that a deletion will only request other members of the room | ||
974 | * to delete the selected message. If you are not permitted to delete the message, the deletion will be ignored. | ||
975 | * | ||
976 | * Depending on the implementation other clients may also ignore your deletion request in other circumstances. | ||
977 | * | ||
978 | * @param[in,out] room Room handle | ||
979 | * @param[in] message Message to delete | ||
980 | * @param[in] delay Delay to delete the message | ||
981 | */ | ||
982 | void | ||
983 | GNUNET_MESSENGER_delete_message (struct GNUNET_MESSENGER_Room *room, | ||
984 | const struct GNUNET_HashCode *hash, | ||
985 | const struct GNUNET_TIME_Relative delay); | ||
816 | 986 | ||
817 | /** | 987 | /** |
818 | * Get the message in a <i>room</i> identified by its <i>hash</i>. | 988 | * Get the message in a <i>room</i> identified by its <i>hash</i>. |
@@ -838,7 +1008,23 @@ GNUNET_MESSENGER_get_message (const struct GNUNET_MESSENGER_Room *room, | |||
838 | int | 1008 | int |
839 | GNUNET_MESSENGER_iterate_members (struct GNUNET_MESSENGER_Room *room, | 1009 | GNUNET_MESSENGER_iterate_members (struct GNUNET_MESSENGER_Room *room, |
840 | GNUNET_MESSENGER_MemberCallback callback, | 1010 | GNUNET_MESSENGER_MemberCallback callback, |
841 | void* cls); | 1011 | void *cls); |
1012 | |||
1013 | /** | ||
1014 | * Send a <i>ticket</i> into a <i>room</i>. The ticket will automatically be converted | ||
1015 | * into a message to be sent only to its audience as a private message. | ||
1016 | * | ||
1017 | * A ticket can only be sent with this function if its issuer's public key is the one | ||
1018 | * being used by the messenger. The audience's public key is not allowed to be the | ||
1019 | * anonymous public key. The room needs to contain a member using the audience's public | ||
1020 | * key. | ||
1021 | * | ||
1022 | * @param[in,out] room Room handle | ||
1023 | * @param[in] ticket Ticket to send | ||
1024 | */ | ||
1025 | void | ||
1026 | GNUNET_MESSENGER_send_ticket (struct GNUNET_MESSENGER_Room *room, | ||
1027 | const struct GNUNET_RECLAIM_Ticket *ticket); | ||
842 | 1028 | ||
843 | #if 0 /* keep Emacsens' auto-indent happy */ | 1029 | #if 0 /* keep Emacsens' auto-indent happy */ |
844 | { | 1030 | { |
diff --git a/src/include/gnunet_mhd_compat.h b/src/include/gnunet_mhd_compat.h index 0cfcc6445..7ef297c2f 100644 --- a/src/include/gnunet_mhd_compat.h +++ b/src/include/gnunet_mhd_compat.h | |||
@@ -25,6 +25,7 @@ | |||
25 | * MHD compatibility definitions for warning-less compile of | 25 | * MHD compatibility definitions for warning-less compile of |
26 | * our code against MHD before and after #MHD_VERSION 0x00097002. | 26 | * our code against MHD before and after #MHD_VERSION 0x00097002. |
27 | */ | 27 | */ |
28 | |||
28 | #include <microhttpd.h> | 29 | #include <microhttpd.h> |
29 | 30 | ||
30 | #if MHD_VERSION >= 0x00097002 | 31 | #if MHD_VERSION >= 0x00097002 |
@@ -35,7 +36,7 @@ | |||
35 | 36 | ||
36 | #else | 37 | #else |
37 | 38 | ||
38 | /** | 39 | ** |
39 | * Data type to use for functions return an "MHD result". | 40 | * Data type to use for functions return an "MHD result". |
40 | */ | 41 | */ |
41 | #define MHD_RESULT int | 42 | #define MHD_RESULT int |
diff --git a/src/include/gnunet_microphone_lib.h b/src/include/gnunet_microphone_lib.h index 2b08bcd71..394caed68 100644 --- a/src/include/gnunet_microphone_lib.h +++ b/src/include/gnunet_microphone_lib.h | |||
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup conversation_l2 Conversation service and libraries | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Simon Dieterle | 25 | * @author Simon Dieterle |
23 | * @author Andreas Fuchs | 26 | * @author Andreas Fuchs |
24 | * @author Christian Grothoff | 27 | * @author Christian Grothoff |
@@ -41,6 +44,7 @@ extern "C" | |||
41 | #endif | 44 | #endif |
42 | #endif | 45 | #endif |
43 | 46 | ||
47 | |||
44 | #include "gnunet_util_lib.h" | 48 | #include "gnunet_util_lib.h" |
45 | 49 | ||
46 | /** | 50 | /** |
@@ -141,4 +145,6 @@ GNUNET_MICROPHONE_destroy (struct GNUNET_MICROPHONE_Handle *microphone); | |||
141 | 145 | ||
142 | /** @} */ /* end of group */ | 146 | /** @} */ /* end of group */ |
143 | 147 | ||
148 | /** @} */ /* end of group addition */ | ||
149 | |||
144 | /* end of gnunet_microphone_lib.h */ | 150 | /* end of gnunet_microphone_lib.h */ |
diff --git a/src/include/gnunet_mq_lib.h b/src/include/gnunet_mq_lib.h index a1c5c4957..3eca71f0f 100644 --- a/src/include/gnunet_mq_lib.h +++ b/src/include/gnunet_mq_lib.h | |||
@@ -18,7 +18,17 @@ | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include "gnunet_common.h" | ||
22 | #if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) | ||
23 | #error "Only <gnunet_util_lib.h> can be included directly." | ||
24 | #endif | ||
25 | |||
26 | |||
21 | /** | 27 | /** |
28 | * @addtogroup libgnunetutil | ||
29 | * Multi-function utilities library for GNUnet programs | ||
30 | * @{ | ||
31 | * | ||
22 | * @author Florian Dold | 32 | * @author Florian Dold |
23 | * @author Christian Grothoff | 33 | * @author Christian Grothoff |
24 | * | 34 | * |
@@ -35,6 +45,7 @@ | |||
35 | #ifndef GNUNET_MQ_LIB_H | 45 | #ifndef GNUNET_MQ_LIB_H |
36 | #define GNUNET_MQ_LIB_H | 46 | #define GNUNET_MQ_LIB_H |
37 | 47 | ||
48 | |||
38 | #include "gnunet_scheduler_lib.h" | 49 | #include "gnunet_scheduler_lib.h" |
39 | 50 | ||
40 | /** | 51 | /** |
@@ -386,9 +397,9 @@ typedef void | |||
386 | * FIFO of envelopes independent of MQ itself and wants to | 397 | * FIFO of envelopes independent of MQ itself and wants to |
387 | * re-use the pointers internal to @a env. Use with caution. | 398 | * re-use the pointers internal to @a env. Use with caution. |
388 | * | 399 | * |
389 | * @param[in|out] env_head of envelope DLL | 400 | * @param[in,out] env_head of envelope DLL |
390 | * @param[in|out] env_tail tail of envelope DLL | 401 | * @param[in,out] env_tail tail of envelope DLL |
391 | * @param[in|out] env element to insert at the tail | 402 | * @param[in,out] env element to insert at the tail |
392 | */ | 403 | */ |
393 | void | 404 | void |
394 | GNUNET_MQ_dll_insert_head (struct GNUNET_MQ_Envelope **env_head, | 405 | GNUNET_MQ_dll_insert_head (struct GNUNET_MQ_Envelope **env_head, |
@@ -404,9 +415,9 @@ GNUNET_MQ_dll_insert_head (struct GNUNET_MQ_Envelope **env_head, | |||
404 | * FIFO of envelopes independent of MQ itself and wants to | 415 | * FIFO of envelopes independent of MQ itself and wants to |
405 | * re-use the pointers internal to @a env. Use with caution. | 416 | * re-use the pointers internal to @a env. Use with caution. |
406 | * | 417 | * |
407 | * @param[in|out] env_head of envelope DLL | 418 | * @param[in,out] env_head of envelope DLL |
408 | * @param[in|out] env_tail tail of envelope DLL | 419 | * @param[in,out] env_tail tail of envelope DLL |
409 | * @param[in|out] env element to insert at the tail | 420 | * @param[in,out] env element to insert at the tail |
410 | */ | 421 | */ |
411 | void | 422 | void |
412 | GNUNET_MQ_dll_insert_tail (struct GNUNET_MQ_Envelope **env_head, | 423 | GNUNET_MQ_dll_insert_tail (struct GNUNET_MQ_Envelope **env_head, |
@@ -422,9 +433,9 @@ GNUNET_MQ_dll_insert_tail (struct GNUNET_MQ_Envelope **env_head, | |||
422 | * FIFO of envelopes independent of MQ itself and wants to | 433 | * FIFO of envelopes independent of MQ itself and wants to |
423 | * re-use the pointers internal to @a env. Use with caution. | 434 | * re-use the pointers internal to @a env. Use with caution. |
424 | * | 435 | * |
425 | * @param[in|out] env_head of envelope DLL | 436 | * @param[in,out] env_head of envelope DLL |
426 | * @param[in|out] env_tail tail of envelope DLL | 437 | * @param[in,out] env_tail tail of envelope DLL |
427 | * @param[in|out] env element to remove from the DLL | 438 | * @param[in,out] env element to remove from the DLL |
428 | */ | 439 | */ |
429 | void | 440 | void |
430 | GNUNET_MQ_dll_remove (struct GNUNET_MQ_Envelope **env_head, | 441 | GNUNET_MQ_dll_remove (struct GNUNET_MQ_Envelope **env_head, |
@@ -597,6 +608,7 @@ struct GNUNET_MQ_MessageHandler | |||
597 | * "context"), | 608 | * "context"), |
598 | * GNUNET_MQ_handler_end() | 609 | * GNUNET_MQ_handler_end() |
599 | * }; | 610 | * }; |
611 | * </code> | ||
600 | * | 612 | * |
601 | * @param name unique basename for the functions | 613 | * @param name unique basename for the functions |
602 | * @param code message type constant | 614 | * @param code message type constant |
@@ -680,7 +692,7 @@ struct GNUNET_MQ_MessageHandler | |||
680 | * @return #GNUNET_OK on success, #GNUNET_NO if no handler matched, | 692 | * @return #GNUNET_OK on success, #GNUNET_NO if no handler matched, |
681 | * #GNUNET_SYSERR if message was rejected by check function | 693 | * #GNUNET_SYSERR if message was rejected by check function |
682 | */ | 694 | */ |
683 | int | 695 | enum GNUNET_GenericReturnValue |
684 | GNUNET_MQ_handle_message (const struct GNUNET_MQ_MessageHandler *handlers, | 696 | GNUNET_MQ_handle_message (const struct GNUNET_MQ_MessageHandler *handlers, |
685 | const struct GNUNET_MessageHeader *mh); | 697 | const struct GNUNET_MessageHeader *mh); |
686 | 698 | ||
@@ -983,7 +995,7 @@ GNUNET_MQ_destroy_notify_cancel ( | |||
983 | * Call the message message handler that was registered | 995 | * Call the message message handler that was registered |
984 | * for the type of the given message in the given message queue. | 996 | * for the type of the given message in the given message queue. |
985 | * | 997 | * |
986 | * This function is indented to be used for the implementation | 998 | * This function is intended to be used for the implementation |
987 | * of message queues. | 999 | * of message queues. |
988 | * | 1000 | * |
989 | * @param mq message queue with the handlers | 1001 | * @param mq message queue with the handlers |
@@ -1120,3 +1132,5 @@ GNUNET_MQ_preference_to_string (enum GNUNET_MQ_PreferenceKind type); | |||
1120 | #endif | 1132 | #endif |
1121 | 1133 | ||
1122 | /** @} */ /* end of group mq */ | 1134 | /** @} */ /* end of group mq */ |
1135 | |||
1136 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_mst_lib.h b/src/include/gnunet_mst_lib.h index 9f3431b98..5b848bbd6 100644 --- a/src/include/gnunet_mst_lib.h +++ b/src/include/gnunet_mst_lib.h | |||
@@ -19,6 +19,13 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup libgnunetutil | ||
23 | * Multi-function utilities library for GNUnet programs | ||
24 | * @{ | ||
25 | * | ||
26 | * @addtogroup networking | ||
27 | * @{ | ||
28 | * | ||
22 | * @author Christian Grothoff | 29 | * @author Christian Grothoff |
23 | * | 30 | * |
24 | * @file | 31 | * @file |
@@ -32,6 +39,10 @@ | |||
32 | * @{ | 39 | * @{ |
33 | */ | 40 | */ |
34 | 41 | ||
42 | #if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) | ||
43 | #error "Only <gnunet_util_lib.h> can be included directly." | ||
44 | #endif | ||
45 | |||
35 | #ifndef GNUNET_MST_LIB_H | 46 | #ifndef GNUNET_MST_LIB_H |
36 | #define GNUNET_MST_LIB_H | 47 | #define GNUNET_MST_LIB_H |
37 | 48 | ||
@@ -43,8 +54,6 @@ extern "C" | |||
43 | #endif | 54 | #endif |
44 | #endif | 55 | #endif |
45 | 56 | ||
46 | #include "gnunet_common.h" | ||
47 | |||
48 | 57 | ||
49 | /** | 58 | /** |
50 | * Handle to a message stream tokenizer. | 59 | * Handle to a message stream tokenizer. |
@@ -96,7 +105,7 @@ GNUNET_MST_create (GNUNET_MessageTokenizerCallback cb, | |||
96 | * #GNUNET_NO if one_shot was set and we have another message ready | 105 | * #GNUNET_NO if one_shot was set and we have another message ready |
97 | * #GNUNET_SYSERR if the data stream is corrupt | 106 | * #GNUNET_SYSERR if the data stream is corrupt |
98 | */ | 107 | */ |
99 | int | 108 | enum GNUNET_GenericReturnValue |
100 | GNUNET_MST_from_buffer (struct GNUNET_MessageStreamTokenizer *mst, | 109 | GNUNET_MST_from_buffer (struct GNUNET_MessageStreamTokenizer *mst, |
101 | const char *buf, | 110 | const char *buf, |
102 | size_t size, | 111 | size_t size, |
@@ -118,7 +127,7 @@ GNUNET_MST_from_buffer (struct GNUNET_MessageStreamTokenizer *mst, | |||
118 | * #GNUNET_NO if one_shot was set and we have another message ready | 127 | * #GNUNET_NO if one_shot was set and we have another message ready |
119 | * #GNUNET_SYSERR if the data stream is corrupt | 128 | * #GNUNET_SYSERR if the data stream is corrupt |
120 | */ | 129 | */ |
121 | int | 130 | enum GNUNET_GenericReturnValue |
122 | GNUNET_MST_read (struct GNUNET_MessageStreamTokenizer *mst, | 131 | GNUNET_MST_read (struct GNUNET_MessageStreamTokenizer *mst, |
123 | struct GNUNET_NETWORK_Handle *sock, | 132 | struct GNUNET_NETWORK_Handle *sock, |
124 | int purge, | 133 | int purge, |
@@ -136,7 +145,7 @@ GNUNET_MST_read (struct GNUNET_MessageStreamTokenizer *mst, | |||
136 | * #GNUNET_NO if one_shot was set and we have another message ready | 145 | * #GNUNET_NO if one_shot was set and we have another message ready |
137 | * #GNUNET_SYSERR if the data stream is corrupt | 146 | * #GNUNET_SYSERR if the data stream is corrupt |
138 | */ | 147 | */ |
139 | int | 148 | enum GNUNET_GenericReturnValue |
140 | GNUNET_MST_next (struct GNUNET_MessageStreamTokenizer *mst, | 149 | GNUNET_MST_next (struct GNUNET_MessageStreamTokenizer *mst, |
141 | int one_shot); | 150 | int one_shot); |
142 | 151 | ||
@@ -161,4 +170,8 @@ GNUNET_MST_destroy (struct GNUNET_MessageStreamTokenizer *mst); | |||
161 | 170 | ||
162 | /** @} */ /* end of group server */ | 171 | /** @} */ /* end of group server */ |
163 | 172 | ||
173 | /** @} */ /* end of group addition to networking */ | ||
174 | |||
175 | /** @} */ /* end of group addition to libgnunetutil*/ | ||
176 | |||
164 | /* end of gnunet_mst_lib.h */ | 177 | /* end of gnunet_mst_lib.h */ |
diff --git a/src/include/gnunet_my_lib.h b/src/include/gnunet_my_lib.h deleted file mode 100644 index 0c95d50d0..000000000 --- a/src/include/gnunet_my_lib.h +++ /dev/null | |||
@@ -1,500 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2016 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your 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 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @author Christian Grothoff | ||
22 | * @author Christophe Genevey | ||
23 | * | ||
24 | * @file | ||
25 | * Helper library to access a MySQL database | ||
26 | * | ||
27 | * @defgroup mysql MySQL library | ||
28 | * Helper library to access a MySQL database. | ||
29 | * @{ | ||
30 | */ | ||
31 | #ifndef GNUNET_MY_LIB_H | ||
32 | #define GNUNET_MY_LIB_H | ||
33 | |||
34 | #include "gnunet_util_lib.h" | ||
35 | #include "gnunet_mysql_lib.h" | ||
36 | #include <mysql/mysql.h> | ||
37 | |||
38 | #ifdef __cplusplus | ||
39 | extern "C" | ||
40 | { | ||
41 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
42 | } | ||
43 | #endif | ||
44 | #endif | ||
45 | |||
46 | |||
47 | /** | ||
48 | * Information we pass to #GNUNET_MY_exec_prepared() to | ||
49 | * initialize the arguments of the prepared statement. | ||
50 | */ | ||
51 | struct GNUNET_MY_QueryParam; | ||
52 | |||
53 | |||
54 | /** | ||
55 | * Function called to convert input argument into SQL parameters. | ||
56 | * | ||
57 | * @param cls closure | ||
58 | * @param pq data about the query | ||
59 | * @param qbind array of parameters to initialize | ||
60 | * @return -1 on error | ||
61 | */ | ||
62 | typedef int | ||
63 | (*GNUNET_MY_QueryConverter)(void *cls, | ||
64 | const struct GNUNET_MY_QueryParam *qp, | ||
65 | MYSQL_BIND *qbind); | ||
66 | |||
67 | |||
68 | /** | ||
69 | * Function called to cleanup result data. | ||
70 | * | ||
71 | * @param cls closure | ||
72 | * @param rs spec to clean up | ||
73 | */ | ||
74 | typedef void | ||
75 | (*GNUNET_MY_QueryCleanup)(void *cls, | ||
76 | MYSQL_BIND *qbind); | ||
77 | /** | ||
78 | * Information we pass to #GNUNET_MY_exec_prepared() to | ||
79 | * initialize the arguments of the prepared statement. | ||
80 | */ | ||
81 | |||
82 | |||
83 | struct GNUNET_MY_QueryParam | ||
84 | { | ||
85 | /** | ||
86 | * Function to call for the type conversion. | ||
87 | */ | ||
88 | GNUNET_MY_QueryConverter conv; | ||
89 | |||
90 | /** | ||
91 | * Function to call for cleaning up the query. Can be NULL. | ||
92 | */ | ||
93 | GNUNET_MY_QueryCleanup cleaner; | ||
94 | |||
95 | /** | ||
96 | * Closure for @e conv. | ||
97 | */ | ||
98 | void *conv_cls; | ||
99 | |||
100 | /** | ||
101 | * Number of arguments the @a conv converter expects to initialize. | ||
102 | */ | ||
103 | unsigned int num_params; | ||
104 | |||
105 | /** | ||
106 | * Information to pass to @e conv. | ||
107 | */ | ||
108 | const void *data; | ||
109 | |||
110 | /** | ||
111 | * Information to pass to @e conv. Size of @a data. | ||
112 | */ | ||
113 | unsigned long data_len; | ||
114 | }; | ||
115 | |||
116 | /** | ||
117 | * End of query parameter specification. | ||
118 | * | ||
119 | * @return array last entry for the result specification to use | ||
120 | */ | ||
121 | #define GNUNET_MY_query_param_end { NULL, NULL, NULL, 0, NULL, 0 } | ||
122 | |||
123 | |||
124 | /** | ||
125 | * Generate query parameter for a buffer @a ptr of | ||
126 | * @a ptr_size bytes.FG | ||
127 | * | ||
128 | * @param ptr pointer to the query parameter to pass | ||
129 | * @oaran ptr_size number of bytes in @a ptr | ||
130 | */ | ||
131 | struct GNUNET_MY_QueryParam | ||
132 | GNUNET_MY_query_param_fixed_size (const void *ptr, | ||
133 | size_t ptr_size); | ||
134 | |||
135 | |||
136 | /** | ||
137 | * Run a prepared SELECT statement. | ||
138 | * | ||
139 | * @param mc mysql context | ||
140 | * @param sh handle to SELECT statement | ||
141 | * @param params parameters to the statement | ||
142 | * @return TBD | ||
143 | */ | ||
144 | int | ||
145 | GNUNET_MY_exec_prepared (struct GNUNET_MYSQL_Context *mc, | ||
146 | struct GNUNET_MYSQL_StatementHandle *sh, | ||
147 | struct GNUNET_MY_QueryParam *params); | ||
148 | |||
149 | |||
150 | /** | ||
151 | * Information we pass to #GNUNET_MY_extract_result() to | ||
152 | * initialize the arguments of the prepared statement. | ||
153 | */ | ||
154 | struct GNUNET_MY_ResultParam; | ||
155 | |||
156 | /** | ||
157 | * Information we pass to #GNUNET_MY_extract_result() to | ||
158 | * initialize the arguments of the prepared statement. | ||
159 | */ | ||
160 | struct GNUNET_MY_ResultSpec; | ||
161 | |||
162 | /** | ||
163 | * Function called to convert input argument into SQL parameters. | ||
164 | * | ||
165 | * @param cls closure | ||
166 | * @param[in,out] rs | ||
167 | * @param stmt the mysql statement that is being run | ||
168 | * @param column the column that is being processed | ||
169 | * @param[out] results | ||
170 | * @return -1 on error | ||
171 | */ | ||
172 | typedef int | ||
173 | (*GNUNET_MY_ResultConverter)(void *cls, | ||
174 | struct GNUNET_MY_ResultSpec *rs, | ||
175 | MYSQL_STMT *stmt, | ||
176 | unsigned int column, | ||
177 | MYSQL_BIND *results); | ||
178 | |||
179 | /** | ||
180 | * Function called to cleanup result data. | ||
181 | * | ||
182 | * @param cls closure | ||
183 | * @param rs spec to clean up | ||
184 | */ | ||
185 | typedef void | ||
186 | (*GNUNET_MY_ResultCleanup)(void *cls, | ||
187 | struct GNUNET_MY_ResultSpec *rs); | ||
188 | |||
189 | |||
190 | /** | ||
191 | * Information we pass to #GNUNET_MY_extract_result() to | ||
192 | * initialize the arguments of the prepared statement. | ||
193 | */ | ||
194 | struct GNUNET_MY_ResultSpec | ||
195 | { | ||
196 | /** | ||
197 | * Function to call to initialize the MYSQL_BIND array. | ||
198 | */ | ||
199 | GNUNET_MY_ResultConverter pre_conv; | ||
200 | |||
201 | /** | ||
202 | * Function to call for converting the result. Can be NULL. | ||
203 | */ | ||
204 | GNUNET_MY_ResultConverter post_conv; | ||
205 | |||
206 | /** | ||
207 | * Function to call for cleaning up the result. Can be NULL. | ||
208 | */ | ||
209 | GNUNET_MY_ResultCleanup cleaner; | ||
210 | |||
211 | /** | ||
212 | * Closure for @e conv. | ||
213 | */ | ||
214 | void *conv_cls; | ||
215 | |||
216 | /** | ||
217 | * Destination for the data. | ||
218 | */ | ||
219 | void *dst; | ||
220 | |||
221 | /** | ||
222 | * Allowed size for the data, 0 for variable-size | ||
223 | * (in this case, the type of @e dst is a `void **` | ||
224 | * and we need to allocate a buffer of the right size). | ||
225 | */ | ||
226 | size_t dst_size; | ||
227 | |||
228 | /** | ||
229 | * Where to store actual size of the result. | ||
230 | */ | ||
231 | size_t *result_size; | ||
232 | |||
233 | /** | ||
234 | * How many fields does this result specification occupy | ||
235 | * in the result returned by MySQL. | ||
236 | */ | ||
237 | unsigned int num_fields; | ||
238 | |||
239 | /** | ||
240 | * Location where we temporarily store the output buffer | ||
241 | * length from MySQL. Internal to libgnunetmy. | ||
242 | */ | ||
243 | unsigned long mysql_bind_output_length; | ||
244 | |||
245 | /** | ||
246 | * Memory for MySQL to notify us about NULL values. | ||
247 | */ | ||
248 | MYSQL_BOOL is_null; | ||
249 | }; | ||
250 | |||
251 | |||
252 | /** | ||
253 | * End of result speceter specification. | ||
254 | * | ||
255 | * @return array last entry for the result specification to use | ||
256 | */ | ||
257 | #define GNUNET_MY_result_spec_end { NULL, NULL, NULL, 0, NULL, 0, 0 } | ||
258 | |||
259 | |||
260 | /** | ||
261 | * Obtain fixed size result of @a ptr_size bytes from | ||
262 | * MySQL, store in already allocated buffer at @a ptr. | ||
263 | * | ||
264 | * @spec ptr where to write the result | ||
265 | * @oaran ptr_size number of bytes available at @a ptr | ||
266 | */ | ||
267 | struct GNUNET_MY_ResultSpec | ||
268 | GNUNET_MY_result_spec_fixed_size (void *ptr, | ||
269 | size_t ptr_size); | ||
270 | |||
271 | /** | ||
272 | * Generate query parameter for a string | ||
273 | * | ||
274 | *@param ptr pointer to the string query parameter to pass | ||
275 | */ | ||
276 | struct GNUNET_MY_QueryParam | ||
277 | GNUNET_MY_query_param_string (const char *ptr); | ||
278 | |||
279 | /** | ||
280 | * Generate fixed-size query parameter with size determined | ||
281 | * by variable type. | ||
282 | * | ||
283 | * @param x pointer to the query parameter to pass | ||
284 | */ | ||
285 | #define GNUNET_MY_query_param_auto_from_type( \ | ||
286 | x) GNUNET_MY_query_param_fixed_size ((x), sizeof(*(x))) | ||
287 | |||
288 | /** | ||
289 | * Generate query parameter for an RSA public key. The | ||
290 | * database must contain a BLOB type in the respective position. | ||
291 | * | ||
292 | * @param x the query parameter to pass | ||
293 | * @return array entry for the query parameters to use | ||
294 | */ | ||
295 | struct GNUNET_MY_QueryParam | ||
296 | GNUNET_MY_query_param_rsa_public_key (const struct | ||
297 | GNUNET_CRYPTO_RsaPublicKey *x); | ||
298 | |||
299 | /** | ||
300 | * Generate query parameter for an RSA signature. The | ||
301 | * database must contain a BLOB type in the respective position | ||
302 | * | ||
303 | *@param x the query parameter to pass | ||
304 | *@return array entry for the query parameters to use | ||
305 | */ | ||
306 | struct GNUNET_MY_QueryParam | ||
307 | GNUNET_MY_query_param_rsa_signature (const struct | ||
308 | GNUNET_CRYPTO_RsaSignature *x); | ||
309 | |||
310 | /** | ||
311 | * Generate query parameter for an absolute time value. | ||
312 | * The database must store a 64-bit integer. | ||
313 | * | ||
314 | *@param x pointer to the query parameter to pass | ||
315 | *@return array entry for the query parameters to use | ||
316 | */ | ||
317 | struct GNUNET_MY_QueryParam | ||
318 | GNUNET_MY_query_param_absolute_time (const struct GNUNET_TIME_Absolute *x); | ||
319 | |||
320 | |||
321 | /** | ||
322 | * Generate query parameter for an absolute time value. | ||
323 | * The database must store a 64-bit integer. | ||
324 | * | ||
325 | *@param x pointer to the query parameter to pass | ||
326 | */ | ||
327 | struct GNUNET_MY_QueryParam | ||
328 | GNUNET_MY_query_param_absolute_time_nbo (const struct | ||
329 | GNUNET_TIME_AbsoluteNBO *x); | ||
330 | |||
331 | /** | ||
332 | * Generate query parameter for an uint16_t in host byte order. | ||
333 | * | ||
334 | * @param x pointer to the query parameter to pass | ||
335 | */ | ||
336 | struct GNUNET_MY_QueryParam | ||
337 | GNUNET_MY_query_param_uint16 (const uint16_t *x); | ||
338 | |||
339 | /** | ||
340 | * Generate query parameter for an uint32_t in host byte order | ||
341 | * | ||
342 | *@param x pointer to the query parameter to pass | ||
343 | */ | ||
344 | struct GNUNET_MY_QueryParam | ||
345 | GNUNET_MY_query_param_uint32 (const uint32_t *x); | ||
346 | |||
347 | /** | ||
348 | * Generate query parameter for an uint64_t in host byte order | ||
349 | * | ||
350 | *@param x pointer to the query parameter to pass | ||
351 | */ | ||
352 | struct GNUNET_MY_QueryParam | ||
353 | GNUNET_MY_query_param_uint64 (const uint64_t *x); | ||
354 | |||
355 | /** | ||
356 | * We expect a fixed-size result, with size determined by the type of `* dst` | ||
357 | * | ||
358 | * @spec name name of the field in the table | ||
359 | * @spec dst point to where to store the result, type fits expected result size | ||
360 | * @return array entry for the result specification to use | ||
361 | */ | ||
362 | #define GNUNET_MY_result_spec_auto_from_type( \ | ||
363 | dst) GNUNET_MY_result_spec_fixed_size ((dst), sizeof(*(dst))) | ||
364 | |||
365 | |||
366 | /** | ||
367 | * Variable-size result expected | ||
368 | * | ||
369 | * @param[out] dst where to store the result, allocated | ||
370 | * @param[out] sptr where to store the size of @a dst | ||
371 | * @return array entru for the result specification to use | ||
372 | */ | ||
373 | struct GNUNET_MY_ResultSpec | ||
374 | GNUNET_MY_result_spec_variable_size (void **dst, | ||
375 | size_t *ptr_size); | ||
376 | |||
377 | /** | ||
378 | * RSA public key expected | ||
379 | * | ||
380 | * @param name name of the field in the table | ||
381 | * @param[out] rsa where to store the result | ||
382 | * @return array entry for the result specification to use | ||
383 | */ | ||
384 | struct GNUNET_MY_ResultSpec | ||
385 | GNUNET_MY_result_spec_rsa_public_key (struct GNUNET_CRYPTO_RsaPublicKey **rsa); | ||
386 | |||
387 | |||
388 | /** | ||
389 | * RSA signature expected. | ||
390 | * | ||
391 | * @param[out] sig where to store the result; | ||
392 | * @return array entry for the result specification to use | ||
393 | */ | ||
394 | struct GNUNET_MY_ResultSpec | ||
395 | GNUNET_MY_result_spec_rsa_signature (struct GNUNET_CRYPTO_RsaSignature **sig); | ||
396 | |||
397 | /** | ||
398 | * 0- terminated string exprected. | ||
399 | * | ||
400 | * @param[out] dst where to store the result, allocated | ||
401 | * @return array entry for the result specification to use | ||
402 | */ | ||
403 | struct GNUNET_MY_ResultSpec | ||
404 | GNUNET_MY_result_spec_string (char **dst); | ||
405 | |||
406 | /** | ||
407 | * Absolute time expected | ||
408 | * | ||
409 | * @param name name of the field in the table | ||
410 | * @param[out] at where to store the result | ||
411 | * @return array entry for the result specification to use | ||
412 | */ | ||
413 | struct GNUNET_MY_ResultSpec | ||
414 | GNUNET_MY_result_spec_absolute_time (struct GNUNET_TIME_Absolute *at); | ||
415 | |||
416 | /** | ||
417 | * Absolute time in network byte order expected | ||
418 | * | ||
419 | * @param[out] at where to store the result | ||
420 | * @return array entry for the result specification to use | ||
421 | */ | ||
422 | struct GNUNET_MY_ResultSpec | ||
423 | GNUNET_MY_result_spec_absolute_time_nbo (struct GNUNET_TIME_AbsoluteNBO *at); | ||
424 | |||
425 | /** | ||
426 | * uint16_t expected | ||
427 | * | ||
428 | * @param[out] u16 where to store the result | ||
429 | * @return array entry for the result specification to use | ||
430 | */ | ||
431 | struct GNUNET_MY_ResultSpec | ||
432 | GNUNET_MY_result_spec_uint16 (uint16_t *u16); | ||
433 | |||
434 | /** | ||
435 | * uint32_t expected | ||
436 | * | ||
437 | * @param[out] u32 where to store the result | ||
438 | * @return array entry for the result specification to use | ||
439 | */ | ||
440 | struct GNUNET_MY_ResultSpec | ||
441 | GNUNET_MY_result_spec_uint32 (uint32_t *u32); | ||
442 | |||
443 | /** | ||
444 | * uint64_t expected. | ||
445 | * | ||
446 | * @param[out] u64 where to store the result | ||
447 | * @return array entry for the result specification to use | ||
448 | */ | ||
449 | struct GNUNET_MY_ResultSpec | ||
450 | GNUNET_MY_result_spec_uint64 (uint64_t *u64); | ||
451 | |||
452 | |||
453 | /** | ||
454 | * Extract results from a query result according to the given | ||
455 | * specification. Always fetches the next row. | ||
456 | * | ||
457 | * @param sh statement that returned results | ||
458 | * @param rs specification to extract for | ||
459 | * @return | ||
460 | * #GNUNET_YES if all results could be extracted | ||
461 | * #GNUNET_NO if there is no more data in the result set | ||
462 | * #GNUNET_SYSERR if a result was invalid | ||
463 | */ | ||
464 | int | ||
465 | GNUNET_MY_extract_result (struct GNUNET_MYSQL_StatementHandle *sh, | ||
466 | struct GNUNET_MY_ResultSpec *specs); | ||
467 | |||
468 | |||
469 | /** | ||
470 | * Free all memory that was allocated in @a qp during | ||
471 | * #GNUNET_MY_exect_prepared(). | ||
472 | * | ||
473 | * @param qp query specification to clean up | ||
474 | * @param qbind mysql query | ||
475 | */ | ||
476 | void | ||
477 | GNUNET_MY_cleanup_query (struct GNUNET_MY_QueryParam *qp, | ||
478 | MYSQL_BIND *qbind); | ||
479 | |||
480 | |||
481 | /** | ||
482 | * Free all memory that was allocated in @a rs during | ||
483 | * #GNUNET_MY_extract_result(). | ||
484 | * | ||
485 | * @param rs reult specification to clean up | ||
486 | */ | ||
487 | void | ||
488 | GNUNET_MY_cleanup_result (struct GNUNET_MY_ResultSpec *rs); | ||
489 | |||
490 | |||
491 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
492 | { | ||
493 | #endif | ||
494 | #ifdef __cplusplus | ||
495 | } | ||
496 | #endif | ||
497 | |||
498 | #endif | ||
499 | |||
500 | /** @} */ /* end of group */ | ||
diff --git a/src/include/gnunet_mysql_lib.h b/src/include/gnunet_mysql_lib.h deleted file mode 100644 index 843d3ccb3..000000000 --- a/src/include/gnunet_mysql_lib.h +++ /dev/null | |||
@@ -1,157 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2012 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your 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 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @author Christian Grothoff | ||
22 | * | ||
23 | * @file | ||
24 | * Helper library to access a MySQL database | ||
25 | * | ||
26 | * @defgroup mysql MySQL library | ||
27 | * Helper library to access a MySQL database. | ||
28 | * @{ | ||
29 | */ | ||
30 | #ifndef GNUNET_MYSQL_LIB_H | ||
31 | #define GNUNET_MYSQL_LIB_H | ||
32 | |||
33 | #include "gnunet_util_lib.h" | ||
34 | #include <mysql/mysql.h> | ||
35 | |||
36 | #ifdef __cplusplus | ||
37 | extern "C" | ||
38 | { | ||
39 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
40 | } | ||
41 | #endif | ||
42 | #endif | ||
43 | |||
44 | #ifdef HAVE_MYSQL8 | ||
45 | typedef bool MYSQL_BOOL; | ||
46 | #else | ||
47 | typedef my_bool MYSQL_BOOL; //MySQL < 8 wants this | ||
48 | #endif | ||
49 | |||
50 | |||
51 | /** | ||
52 | * Mysql context. | ||
53 | */ | ||
54 | struct GNUNET_MYSQL_Context; | ||
55 | |||
56 | |||
57 | /** | ||
58 | * Handle for a prepared statement. | ||
59 | */ | ||
60 | struct GNUNET_MYSQL_StatementHandle; | ||
61 | |||
62 | |||
63 | /** | ||
64 | * Type of a callback that will be called for each | ||
65 | * data set returned from MySQL. | ||
66 | * | ||
67 | * @param cls user-defined argument | ||
68 | * @param num_values number of elements in values | ||
69 | * @param values values returned by MySQL | ||
70 | * @return #GNUNET_OK to continue iterating, #GNUNET_SYSERR to abort | ||
71 | */ | ||
72 | typedef int | ||
73 | (*GNUNET_MYSQL_DataProcessor) (void *cls, | ||
74 | unsigned int num_values, | ||
75 | MYSQL_BIND *values); | ||
76 | |||
77 | |||
78 | /** | ||
79 | * Create a mysql context. | ||
80 | * | ||
81 | * @param cfg configuration | ||
82 | * @param section configuration section to use to get MySQL configuration options | ||
83 | * @return the mysql context | ||
84 | */ | ||
85 | struct GNUNET_MYSQL_Context * | ||
86 | GNUNET_MYSQL_context_create (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
87 | const char *section); | ||
88 | |||
89 | |||
90 | /** | ||
91 | * Destroy a mysql context. Also frees all associated prepared statements. | ||
92 | * | ||
93 | * @param mc context to destroy | ||
94 | */ | ||
95 | void | ||
96 | GNUNET_MYSQL_context_destroy (struct GNUNET_MYSQL_Context *mc); | ||
97 | |||
98 | |||
99 | /** | ||
100 | * Close database connection and all prepared statements (we got a DB | ||
101 | * error). The connection will automatically be re-opened and | ||
102 | * statements will be re-prepared if they are needed again later. | ||
103 | * | ||
104 | * @param mc mysql context | ||
105 | */ | ||
106 | void | ||
107 | GNUNET_MYSQL_statements_invalidate (struct GNUNET_MYSQL_Context *mc); | ||
108 | |||
109 | |||
110 | /** | ||
111 | * Get internal handle for a prepared statement. This function should rarely | ||
112 | * be used, and if, with caution! On failures during the interaction with | ||
113 | * the handle, you must call #GNUNET_MYSQL_statements_invalidate()! | ||
114 | * | ||
115 | * @param sh prepared statement to introspect | ||
116 | * @return MySQL statement handle, NULL on error | ||
117 | */ | ||
118 | MYSQL_STMT * | ||
119 | GNUNET_MYSQL_statement_get_stmt (struct GNUNET_MYSQL_StatementHandle *sh); | ||
120 | |||
121 | |||
122 | /** | ||
123 | * Prepare a statement. Prepared statements are automatically discarded | ||
124 | * when the MySQL context is destroyed. | ||
125 | * | ||
126 | * @param mc mysql context | ||
127 | * @param query query text | ||
128 | * @return prepared statement, NULL on error | ||
129 | */ | ||
130 | struct GNUNET_MYSQL_StatementHandle * | ||
131 | GNUNET_MYSQL_statement_prepare (struct GNUNET_MYSQL_Context *mc, | ||
132 | const char *query); | ||
133 | |||
134 | |||
135 | /** | ||
136 | * Run a SQL statement. | ||
137 | * | ||
138 | * @param mc mysql context | ||
139 | * @param sql SQL statement to run | ||
140 | * @return #GNUNET_OK on success | ||
141 | * #GNUNET_SYSERR if there was a problem | ||
142 | */ | ||
143 | int | ||
144 | GNUNET_MYSQL_statement_run (struct GNUNET_MYSQL_Context *mc, | ||
145 | const char *sql); | ||
146 | |||
147 | |||
148 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
149 | { | ||
150 | #endif | ||
151 | #ifdef __cplusplus | ||
152 | } | ||
153 | #endif | ||
154 | |||
155 | #endif | ||
156 | |||
157 | /** @} */ /* end of group */ | ||
diff --git a/src/include/gnunet_namecache_plugin.h b/src/include/gnunet_namecache_plugin.h index 7c218fbeb..a3848bf4e 100644 --- a/src/include/gnunet_namecache_plugin.h +++ b/src/include/gnunet_namecache_plugin.h | |||
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup GNS | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
@@ -34,6 +37,7 @@ | |||
34 | #ifndef GNUNET_NAMECACHE_PLUGIN_H | 37 | #ifndef GNUNET_NAMECACHE_PLUGIN_H |
35 | #define GNUNET_NAMECACHE_PLUGIN_H | 38 | #define GNUNET_NAMECACHE_PLUGIN_H |
36 | 39 | ||
40 | |||
37 | #include "gnunet_util_lib.h" | 41 | #include "gnunet_util_lib.h" |
38 | #include "gnunet_namecache_service.h" | 42 | #include "gnunet_namecache_service.h" |
39 | #include "gnunet_namestore_service.h" | 43 | #include "gnunet_namestore_service.h" |
@@ -106,3 +110,5 @@ struct GNUNET_NAMECACHE_PluginFunctions | |||
106 | #endif | 110 | #endif |
107 | 111 | ||
108 | /** @} */ /* end of group */ | 112 | /** @} */ /* end of group */ |
113 | |||
114 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_namecache_service.h b/src/include/gnunet_namecache_service.h index 07b26aec3..669386c37 100644 --- a/src/include/gnunet_namecache_service.h +++ b/src/include/gnunet_namecache_service.h | |||
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup GNS | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
@@ -38,6 +41,7 @@ | |||
38 | #ifndef GNUNET_NAMECACHE_SERVICE_H | 41 | #ifndef GNUNET_NAMECACHE_SERVICE_H |
39 | #define GNUNET_NAMECACHE_SERVICE_H | 42 | #define GNUNET_NAMECACHE_SERVICE_H |
40 | 43 | ||
44 | |||
41 | #include "gnunet_util_lib.h" | 45 | #include "gnunet_util_lib.h" |
42 | #include "gnunet_block_lib.h" | 46 | #include "gnunet_block_lib.h" |
43 | #include "gnunet_namestore_service.h" | 47 | #include "gnunet_namestore_service.h" |
@@ -173,3 +177,5 @@ GNUNET_NAMECACHE_cancel (struct GNUNET_NAMECACHE_QueueEntry *qe); | |||
173 | #endif | 177 | #endif |
174 | 178 | ||
175 | /** @} */ /* end of group */ | 179 | /** @} */ /* end of group */ |
180 | |||
181 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_namestore_plugin.h b/src/include/gnunet_namestore_plugin.h index 3dca5a853..b7bcc4eb6 100644 --- a/src/include/gnunet_namestore_plugin.h +++ b/src/include/gnunet_namestore_plugin.h | |||
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup GNS | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
@@ -31,6 +34,7 @@ | |||
31 | #ifndef GNUNET_NAMESTORE_PLUGIN_H | 34 | #ifndef GNUNET_NAMESTORE_PLUGIN_H |
32 | #define GNUNET_NAMESTORE_PLUGIN_H | 35 | #define GNUNET_NAMESTORE_PLUGIN_H |
33 | 36 | ||
37 | |||
34 | #include "gnunet_util_lib.h" | 38 | #include "gnunet_util_lib.h" |
35 | #include "gnunet_namestore_service.h" | 39 | #include "gnunet_namestore_service.h" |
36 | 40 | ||
@@ -49,6 +53,7 @@ extern "C" | |||
49 | * @param cls closure | 53 | * @param cls closure |
50 | * @param serial unique serial number of the record, MUST NOT BE ZERO, | 54 | * @param serial unique serial number of the record, MUST NOT BE ZERO, |
51 | * and must be monotonically increasing while iterating | 55 | * and must be monotonically increasing while iterating |
56 | * @param editor_hint content of the editor field when record was read (may be NULL) | ||
52 | * @param zone_key private key of the zone | 57 | * @param zone_key private key of the zone |
53 | * @param label name that is being mapped (at most 255 characters long) | 58 | * @param label name that is being mapped (at most 255 characters long) |
54 | * @param rd_count number of entries in @a rd array | 59 | * @param rd_count number of entries in @a rd array |
@@ -57,8 +62,9 @@ extern "C" | |||
57 | typedef void | 62 | typedef void |
58 | (*GNUNET_NAMESTORE_RecordIterator) (void *cls, | 63 | (*GNUNET_NAMESTORE_RecordIterator) (void *cls, |
59 | uint64_t serial, | 64 | uint64_t serial, |
65 | const char *editor_hint, | ||
60 | const struct | 66 | const struct |
61 | GNUNET_IDENTITY_PrivateKey *private_key, | 67 | GNUNET_CRYPTO_PrivateKey *private_key, |
62 | const char *label, | 68 | const char *label, |
63 | unsigned int rd_count, | 69 | unsigned int rd_count, |
64 | const struct GNUNET_GNSRECORD_Data *rd); | 70 | const struct GNUNET_GNSRECORD_Data *rd); |
@@ -85,12 +91,12 @@ struct GNUNET_NAMESTORE_PluginFunctions | |||
85 | * @param rd array of records with data to store | 91 | * @param rd array of records with data to store |
86 | * @return #GNUNET_OK on success, else #GNUNET_SYSERR | 92 | * @return #GNUNET_OK on success, else #GNUNET_SYSERR |
87 | */ | 93 | */ |
88 | int | 94 | enum GNUNET_GenericReturnValue |
89 | (*store_records) (void *cls, | 95 | (*store_records)(void *cls, |
90 | const struct GNUNET_IDENTITY_PrivateKey *zone, | 96 | const struct GNUNET_CRYPTO_PrivateKey *zone, |
91 | const char *label, | 97 | const char *label, |
92 | unsigned int rd_count, | 98 | unsigned int rd_count, |
93 | const struct GNUNET_GNSRECORD_Data *rd); | 99 | const struct GNUNET_GNSRECORD_Data *rd); |
94 | 100 | ||
95 | /** | 101 | /** |
96 | * Lookup records in the datastore for which we are the authority. | 102 | * Lookup records in the datastore for which we are the authority. |
@@ -102,12 +108,12 @@ struct GNUNET_NAMESTORE_PluginFunctions | |||
102 | * @param iter_cls closure for @a iter | 108 | * @param iter_cls closure for @a iter |
103 | * @return #GNUNET_OK on success, #GNUNET_NO for no results, else #GNUNET_SYSERR | 109 | * @return #GNUNET_OK on success, #GNUNET_NO for no results, else #GNUNET_SYSERR |
104 | */ | 110 | */ |
105 | int | 111 | enum GNUNET_GenericReturnValue |
106 | (*lookup_records) (void *cls, | 112 | (*lookup_records)(void *cls, |
107 | const struct GNUNET_IDENTITY_PrivateKey *zone, | 113 | const struct GNUNET_CRYPTO_PrivateKey *zone, |
108 | const char *label, | 114 | const char *label, |
109 | GNUNET_NAMESTORE_RecordIterator iter, | 115 | GNUNET_NAMESTORE_RecordIterator iter, |
110 | void *iter_cls); | 116 | void *iter_cls); |
111 | 117 | ||
112 | 118 | ||
113 | /** | 119 | /** |
@@ -124,13 +130,13 @@ struct GNUNET_NAMESTORE_PluginFunctions | |||
124 | * @param iter_cls closure for @a iter | 130 | * @param iter_cls closure for @a iter |
125 | * @return #GNUNET_OK on success, #GNUNET_NO if there were no more results, #GNUNET_SYSERR on error | 131 | * @return #GNUNET_OK on success, #GNUNET_NO if there were no more results, #GNUNET_SYSERR on error |
126 | */ | 132 | */ |
127 | int | 133 | enum GNUNET_GenericReturnValue |
128 | (*iterate_records) (void *cls, | 134 | (*iterate_records)(void *cls, |
129 | const struct GNUNET_IDENTITY_PrivateKey *zone, | 135 | const struct GNUNET_CRYPTO_PrivateKey *zone, |
130 | uint64_t serial, | 136 | uint64_t serial, |
131 | uint64_t limit, | 137 | uint64_t limit, |
132 | GNUNET_NAMESTORE_RecordIterator iter, | 138 | GNUNET_NAMESTORE_RecordIterator iter, |
133 | void *iter_cls); | 139 | void *iter_cls); |
134 | 140 | ||
135 | 141 | ||
136 | /** | 142 | /** |
@@ -144,77 +150,77 @@ struct GNUNET_NAMESTORE_PluginFunctions | |||
144 | * @param iter_cls closure for @a iter | 150 | * @param iter_cls closure for @a iter |
145 | * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error | 151 | * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error |
146 | */ | 152 | */ |
147 | int | 153 | enum GNUNET_GenericReturnValue |
148 | (*zone_to_name) (void *cls, | 154 | (*zone_to_name)(void *cls, |
149 | const struct GNUNET_IDENTITY_PrivateKey *zone, | 155 | const struct GNUNET_CRYPTO_PrivateKey *zone, |
150 | const struct GNUNET_IDENTITY_PublicKey *value_zone, | 156 | const struct GNUNET_CRYPTO_PublicKey *value_zone, |
151 | GNUNET_NAMESTORE_RecordIterator iter, | 157 | GNUNET_NAMESTORE_RecordIterator iter, |
152 | void *iter_cls); | 158 | void *iter_cls); |
153 | 159 | ||
154 | /** Transaction-based API draft **/ | 160 | /** Transaction-based API draft **/ |
155 | 161 | ||
156 | /** | 162 | /** |
157 | * Start a transaction in the database | 163 | * Edit records in the namestore. |
164 | * This modifies the editor hint, an advisory lock entry. | ||
165 | * The record iterator will be called with the old editor hint (if any). | ||
158 | * | 166 | * |
159 | * @param cls closure (internal context for the plugin) | 167 | * @param cls closure (internal context for the plugin) |
160 | * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error | 168 | * @param zone private key of the zone |
169 | * @param editor_hint the new value for the advisory lock field | ||
170 | * @param label name of the record in the zone | ||
171 | * @param iter function to call with the result | ||
172 | * @param iter_cls closure for @a iter | ||
173 | * @return #GNUNET_OK on success, #GNUNET_NO for no results, else #GNUNET_SYSERR | ||
161 | */ | 174 | */ |
162 | enum GNUNET_GenericReturnValue | 175 | enum GNUNET_GenericReturnValue |
163 | (*transaction_begin) (void *cls); | 176 | (*edit_records)(void *cls, |
177 | const char *editor_hint, | ||
178 | const struct GNUNET_CRYPTO_PrivateKey *zone, | ||
179 | const char *label, | ||
180 | GNUNET_NAMESTORE_RecordIterator iter, | ||
181 | void *iter_cls); | ||
164 | 182 | ||
165 | /** | 183 | /** |
166 | * Abort a transaction in the database | 184 | * This clears the editor hint, unless it does not match the |
185 | * given editor hint, in which case this is a NOP. | ||
186 | * If a replacement hint is given, it hint is not cleared, but | ||
187 | * set to the replacement. | ||
167 | * | 188 | * |
168 | * @param cls closure (internal context for the plugin) | 189 | * @param cls closure (internal context for the plugin) |
169 | * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error | 190 | * @param zone private key of the zone |
191 | * @param editor_hint the new value for the advisory lock field | ||
192 | * @param editor_hint_replacement an optional value to use instead of a clear | ||
193 | * @param label name of the record in the zone | ||
194 | * @param iter function to call with the result | ||
195 | * @param iter_cls closure for @a iter | ||
196 | * @return #GNUNET_OK on success, #GNUNET_NO for no results, else #GNUNET_SYSERR | ||
170 | */ | 197 | */ |
171 | enum GNUNET_GenericReturnValue | 198 | enum GNUNET_GenericReturnValue |
172 | (*transaction_abort) (void *cls); | 199 | (*clear_editor_hint)(void *cls, |
200 | const char *editor_hint, | ||
201 | const char *editor_hint_replacement, | ||
202 | const struct GNUNET_CRYPTO_PrivateKey *zone, | ||
203 | const char *label); | ||
173 | 204 | ||
174 | /** | 205 | /** |
175 | * Commit a transaction in the database | 206 | * Setup the database. |
176 | * | 207 | * |
177 | * @param cls closure (internal context for the plugin) | 208 | * @param cls closure (internal context for the plugin) |
178 | * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error | 209 | * @return #GNUNET_OK on success, else fails with #GNUNET_SYSERR |
179 | */ | 210 | */ |
180 | enum GNUNET_GenericReturnValue | 211 | enum GNUNET_GenericReturnValue |
181 | (*transaction_commit) (void *cls); | 212 | (*create_tables)(void *cls); |
182 | 213 | ||
183 | /** | ||
184 | * Replace a record in the datastore for which we are the authority. | ||
185 | * Removes any existing record in the same zone with the same name. | ||
186 | * | ||
187 | * @param cls closure (internal context for the plugin) | ||
188 | * @param zone private key of the zone | ||
189 | * @param label name of the record in the zone | ||
190 | * @param rd_count number of entries in @a rd array, 0 to delete all records | ||
191 | * @param rd array of records with data to store | ||
192 | * @return #GNUNET_OK on success, else #GNUNET_SYSERR | ||
193 | */ | ||
194 | int | ||
195 | (*replace_records) (void *cls, | ||
196 | const struct GNUNET_IDENTITY_PrivateKey *zone, | ||
197 | const char *label, | ||
198 | unsigned int rd_count, | ||
199 | const struct GNUNET_GNSRECORD_Data *rd); | ||
200 | 214 | ||
201 | /** | 215 | /** |
202 | * Lookup records in the datastore for which we are the authority. | 216 | * Drop existing tables. |
217 | * DANGEROUS: All existing data in the dabase will be lost! | ||
203 | * | 218 | * |
204 | * @param cls closure (internal context for the plugin) | 219 | * @param cls closure (internal context for the plugin) |
205 | * @param zone private key of the zone | 220 | * @return #GNUNET_OK on success, else fails with #GNUNET_SYSERR |
206 | * @param label name of the record in the zone | ||
207 | * @param iter function to call with the result | ||
208 | * @param iter_cls closure for @a iter | ||
209 | * @return #GNUNET_OK on success, #GNUNET_NO for no results, else #GNUNET_SYSERR | ||
210 | */ | 221 | */ |
211 | int | 222 | enum GNUNET_GenericReturnValue |
212 | (*select_records) (void *cls, | 223 | (*drop_tables)(void *cls); |
213 | const struct GNUNET_IDENTITY_PrivateKey *zone, | ||
214 | const char *label, | ||
215 | GNUNET_NAMESTORE_RecordIterator iter, | ||
216 | void *iter_cls); | ||
217 | |||
218 | }; | 224 | }; |
219 | 225 | ||
220 | 226 | ||
@@ -228,3 +234,5 @@ struct GNUNET_NAMESTORE_PluginFunctions | |||
228 | #endif | 234 | #endif |
229 | 235 | ||
230 | /** @} */ /* end of group */ | 236 | /** @} */ /* end of group */ |
237 | |||
238 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_namestore_service.h b/src/include/gnunet_namestore_service.h index 86572803f..0f9be8b10 100644 --- a/src/include/gnunet_namestore_service.h +++ b/src/include/gnunet_namestore_service.h | |||
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup GNS | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
@@ -38,10 +41,10 @@ | |||
38 | #ifndef GNUNET_NAMESTORE_SERVICE_H | 41 | #ifndef GNUNET_NAMESTORE_SERVICE_H |
39 | #define GNUNET_NAMESTORE_SERVICE_H | 42 | #define GNUNET_NAMESTORE_SERVICE_H |
40 | 43 | ||
44 | |||
45 | #include "gnunet_error_codes.h" | ||
41 | #include "gnunet_util_lib.h" | 46 | #include "gnunet_util_lib.h" |
42 | #include "gnunet_block_lib.h" | ||
43 | #include "gnunet_gnsrecord_lib.h" | 47 | #include "gnunet_gnsrecord_lib.h" |
44 | #include "gnunet_identity_service.h" | ||
45 | 48 | ||
46 | #ifdef __cplusplus | 49 | #ifdef __cplusplus |
47 | extern "C" | 50 | extern "C" |
@@ -67,6 +70,28 @@ struct GNUNET_NAMESTORE_Handle; | |||
67 | */ | 70 | */ |
68 | struct GNUNET_NAMESTORE_ZoneIterator; | 71 | struct GNUNET_NAMESTORE_ZoneIterator; |
69 | 72 | ||
73 | /** | ||
74 | * Transaction control types. | ||
75 | * They roughly correspond to DB transaction controls | ||
76 | */ | ||
77 | enum GNUNET_NAMESTORE_TxControl | ||
78 | { | ||
79 | GNUNET_NAMESTORE_TX_BEGIN = 0, | ||
80 | GNUNET_NAMESTORE_TX_COMMIT = 1, | ||
81 | GNUNET_NAMESTORE_TX_ROLLBACK = 2, | ||
82 | }; | ||
83 | |||
84 | /** | ||
85 | * A struct for record bulk import. | ||
86 | * The fields are arrays pointing to individual GNS records and names. | ||
87 | */ | ||
88 | struct GNUNET_NAMESTORE_RecordInfo | ||
89 | { | ||
90 | const char *a_label; | ||
91 | unsigned int a_rd_count; | ||
92 | struct GNUNET_GNSRECORD_Data *a_rd; | ||
93 | }; | ||
94 | |||
70 | 95 | ||
71 | /** | 96 | /** |
72 | * Connect to the namestore service. | 97 | * Connect to the namestore service. |
@@ -97,12 +122,11 @@ GNUNET_NAMESTORE_disconnect (struct GNUNET_NAMESTORE_Handle *h); | |||
97 | * @param success #GNUNET_SYSERR on failure (including timeout/queue drop/failure to validate) | 122 | * @param success #GNUNET_SYSERR on failure (including timeout/queue drop/failure to validate) |
98 | * #GNUNET_NO if content was already there or not found | 123 | * #GNUNET_NO if content was already there or not found |
99 | * #GNUNET_YES (or other positive value) on success | 124 | * #GNUNET_YES (or other positive value) on success |
100 | * @param emsg NULL on success, otherwise an error message | 125 | * @param ec the #GNUNET_ErrorCode, #GNUNET_EC_NONE on success. |
101 | */ | 126 | */ |
102 | typedef void | 127 | typedef void |
103 | (*GNUNET_NAMESTORE_ContinuationWithStatus) (void *cls, | 128 | (*GNUNET_NAMESTORE_ContinuationWithStatus) (void *cls, |
104 | int32_t success, | 129 | enum GNUNET_ErrorCode ec); |
105 | const char *emsg); | ||
106 | 130 | ||
107 | 131 | ||
108 | /** | 132 | /** |
@@ -116,6 +140,9 @@ typedef void | |||
116 | * keep up with the changes, calling @a cont will be delayed until the | 140 | * keep up with the changes, calling @a cont will be delayed until the |
117 | * monitors do keep up. | 141 | * monitors do keep up. |
118 | * | 142 | * |
143 | * This always overwrites the record set and unsets any advisory | ||
144 | * lock inrrespective of the currently set editor hint/advisory lock value. | ||
145 | * | ||
119 | * @param h handle to the namestore | 146 | * @param h handle to the namestore |
120 | * @param pkey private key of the zone | 147 | * @param pkey private key of the zone |
121 | * @param label name that is being mapped | 148 | * @param label name that is being mapped |
@@ -126,13 +153,50 @@ typedef void | |||
126 | * @return handle to abort the request | 153 | * @return handle to abort the request |
127 | */ | 154 | */ |
128 | struct GNUNET_NAMESTORE_QueueEntry * | 155 | struct GNUNET_NAMESTORE_QueueEntry * |
129 | GNUNET_NAMESTORE_records_store (struct GNUNET_NAMESTORE_Handle *h, | 156 | GNUNET_NAMESTORE_record_set_store (struct GNUNET_NAMESTORE_Handle *h, |
130 | const struct GNUNET_IDENTITY_PrivateKey *pkey, | 157 | const struct GNUNET_CRYPTO_PrivateKey *pkey, |
131 | const char *label, | 158 | const char *label, |
132 | unsigned int rd_count, | 159 | unsigned int rd_count, |
133 | const struct GNUNET_GNSRECORD_Data *rd, | 160 | const struct GNUNET_GNSRECORD_Data *rd, |
134 | GNUNET_NAMESTORE_ContinuationWithStatus cont, | 161 | GNUNET_NAMESTORE_ContinuationWithStatus cont, |
135 | void *cont_cls); | 162 | void *cont_cls); |
163 | |||
164 | /** | ||
165 | * Store one or more record sets in the namestore. If any item is already present, | ||
166 | * it is replaced with the new record. Use an empty array to | ||
167 | * remove all records under the given name. | ||
168 | * | ||
169 | * The continuation is called after the records have been stored in the | ||
170 | * database. They may not yet have been commited. Monitors may be notified | ||
171 | * asynchronously (basically with a buffer when commited). | ||
172 | * However, if any monitor is consistently too slow to | ||
173 | * keep up with the changes, calling @a cont will be delayed until the | ||
174 | * monitors do keep up. | ||
175 | * Uncommited store requests within a transaction (GNUNET_NAMESTORE_transaction_begin) | ||
176 | * cause @a cont to be called immediately before the commit and before | ||
177 | * notification of monitors. | ||
178 | * | ||
179 | * This always overwrites the record set and unsets any advisory | ||
180 | * lock inrrespective of the currently set editor hint/advisory lock value. | ||
181 | * | ||
182 | * @param h handle to the namestore | ||
183 | * @param pkey private key of the zone | ||
184 | * @param rd_set_count the number of record sets | ||
185 | * @param record_info the records to add containing @a rd_set_count records | ||
186 | * @param cont continuation to call when done | ||
187 | * @param rds_sent set to how many record sets could actually be sent | ||
188 | * @param cont_cls closure for @a cont | ||
189 | * @return handle to abort the request | ||
190 | */ | ||
191 | struct GNUNET_NAMESTORE_QueueEntry * | ||
192 | GNUNET_NAMESTORE_records_store ( | ||
193 | struct GNUNET_NAMESTORE_Handle *h, | ||
194 | const struct GNUNET_CRYPTO_PrivateKey *pkey, | ||
195 | unsigned int rd_set_count, | ||
196 | const struct GNUNET_NAMESTORE_RecordInfo *record_info, | ||
197 | unsigned int *rds_sent, | ||
198 | GNUNET_NAMESTORE_ContinuationWithStatus cont, | ||
199 | void *cont_cls); | ||
136 | 200 | ||
137 | /** | 201 | /** |
138 | * Store an item in the namestore. If the item is already present, | 202 | * Store an item in the namestore. If the item is already present, |
@@ -156,16 +220,14 @@ GNUNET_NAMESTORE_records_store (struct GNUNET_NAMESTORE_Handle *h, | |||
156 | * @return handle to abort the request | 220 | * @return handle to abort the request |
157 | */ | 221 | */ |
158 | struct GNUNET_NAMESTORE_QueueEntry * | 222 | struct GNUNET_NAMESTORE_QueueEntry * |
159 | GNUNET_NAMESTORE_records_store_ (struct GNUNET_NAMESTORE_Handle *h, | 223 | GNUNET_NAMESTORE_record_set_store_ (struct GNUNET_NAMESTORE_Handle *h, |
160 | const struct GNUNET_IDENTITY_PrivateKey *pkey, | 224 | const struct GNUNET_CRYPTO_PrivateKey *pkey, |
161 | const char *label, | 225 | const char *label, |
162 | unsigned int rd_count, | 226 | unsigned int rd_count, |
163 | const struct GNUNET_GNSRECORD_Data *rd, | 227 | const struct GNUNET_GNSRECORD_Data *rd, |
164 | int is_zonemaster, | 228 | int is_zonemaster, |
165 | GNUNET_NAMESTORE_ContinuationWithStatus cont, | 229 | GNUNET_NAMESTORE_ContinuationWithStatus cont, |
166 | void *cont_cls); | 230 | void *cont_cls); |
167 | |||
168 | |||
169 | 231 | ||
170 | 232 | ||
171 | /** | 233 | /** |
@@ -180,10 +242,48 @@ GNUNET_NAMESTORE_records_store_ (struct GNUNET_NAMESTORE_Handle *h, | |||
180 | typedef void | 242 | typedef void |
181 | (*GNUNET_NAMESTORE_RecordMonitor) (void *cls, | 243 | (*GNUNET_NAMESTORE_RecordMonitor) (void *cls, |
182 | const struct | 244 | const struct |
183 | GNUNET_IDENTITY_PrivateKey *zone, | 245 | GNUNET_CRYPTO_PrivateKey *zone, |
184 | const char *label, | 246 | const char *label, |
185 | unsigned int rd_count, | 247 | unsigned int rd_count, |
186 | const struct GNUNET_GNSRECORD_Data *rd); | 248 | const struct GNUNET_GNSRECORD_Data *rd); |
249 | /** | ||
250 | * Process a record that was stored in the namestore. | ||
251 | * | ||
252 | * @param cls closure | ||
253 | * @param ec the error code. #GNUNET_EC_NONE on success. | ||
254 | * @param rd_count number of entries in @a rd array, 0 if label was deleted | ||
255 | * @param rd array of records with data to store | ||
256 | * @param editor_hint the advisory lock value that was replaced. NULL of not advisory lock | ||
257 | was set or if lock was equal to provided editor hint. | ||
258 | */ | ||
259 | typedef void | ||
260 | (*GNUNET_NAMESTORE_EditRecordSetBeginCallback) (void *cls, | ||
261 | enum GNUNET_ErrorCode ec, | ||
262 | unsigned int rd_count, | ||
263 | const struct | ||
264 | GNUNET_GNSRECORD_Data *rd, | ||
265 | const char *editor_hint); | ||
266 | |||
267 | /** | ||
268 | * Process a record set that was stored in the namestore. | ||
269 | * The record set expiration value takes existing TOMBSTONE records | ||
270 | * into account even if those are not returned. | ||
271 | * | ||
272 | * @param cls closure | ||
273 | * @param zone private key of the zone | ||
274 | * @param label label of the records | ||
275 | * @param rd_count number of entries in @a rd array, 0 if label was deleted | ||
276 | * @param rd array of records with data to store | ||
277 | * @param expiry the expiration of this record set. | ||
278 | */ | ||
279 | typedef void | ||
280 | (*GNUNET_NAMESTORE_RecordSetMonitor) (void *cls, | ||
281 | const struct | ||
282 | GNUNET_CRYPTO_PrivateKey *zone, | ||
283 | const char *label, | ||
284 | unsigned int rd_count, | ||
285 | const struct GNUNET_GNSRECORD_Data *rd, | ||
286 | struct GNUNET_TIME_Absolute expiry); | ||
187 | 287 | ||
188 | 288 | ||
189 | /** | 289 | /** |
@@ -203,13 +303,39 @@ typedef void | |||
203 | struct GNUNET_NAMESTORE_QueueEntry * | 303 | struct GNUNET_NAMESTORE_QueueEntry * |
204 | GNUNET_NAMESTORE_records_lookup (struct GNUNET_NAMESTORE_Handle *h, | 304 | GNUNET_NAMESTORE_records_lookup (struct GNUNET_NAMESTORE_Handle *h, |
205 | const struct | 305 | const struct |
206 | GNUNET_IDENTITY_PrivateKey *pkey, | 306 | GNUNET_CRYPTO_PrivateKey *pkey, |
207 | const char *label, | 307 | const char *label, |
208 | GNUNET_SCHEDULER_TaskCallback error_cb, | 308 | GNUNET_SCHEDULER_TaskCallback error_cb, |
209 | void *error_cb_cls, | 309 | void *error_cb_cls, |
210 | GNUNET_NAMESTORE_RecordMonitor rm, | 310 | GNUNET_NAMESTORE_RecordMonitor rm, |
211 | void *rm_cls); | 311 | void *rm_cls); |
212 | 312 | ||
313 | /** | ||
314 | * Lookup an item in the namestore with GNSRECORD filter. | ||
315 | * | ||
316 | * @param h handle to the namestore | ||
317 | * @param pkey private key of the zone | ||
318 | * @param label name that is being mapped | ||
319 | * @param error_cb function to call on error (i.e. disconnect) | ||
320 | * the handle is afterwards invalid | ||
321 | * @param error_cb_cls closure for @a error_cb | ||
322 | * @param rm function to call with the result (with 0 records if we don't have that label); | ||
323 | * the handle is afterwards invalid | ||
324 | * @param rm_cls closure for @a rm | ||
325 | * @param filter the record set filter to use | ||
326 | * @return handle to abort the request | ||
327 | */ | ||
328 | struct GNUNET_NAMESTORE_QueueEntry * | ||
329 | GNUNET_NAMESTORE_records_lookup2 (struct GNUNET_NAMESTORE_Handle *h, | ||
330 | const struct | ||
331 | GNUNET_CRYPTO_PrivateKey *pkey, | ||
332 | const char *label, | ||
333 | GNUNET_SCHEDULER_TaskCallback error_cb, | ||
334 | void *error_cb_cls, | ||
335 | GNUNET_NAMESTORE_RecordMonitor rm, | ||
336 | void *rm_cls, | ||
337 | enum GNUNET_GNSRECORD_Filter filter); | ||
338 | |||
213 | 339 | ||
214 | /** | 340 | /** |
215 | * Look for an existing PKEY delegation record for a given public key. | 341 | * Look for an existing PKEY delegation record for a given public key. |
@@ -230,9 +356,9 @@ GNUNET_NAMESTORE_records_lookup (struct GNUNET_NAMESTORE_Handle *h, | |||
230 | */ | 356 | */ |
231 | struct GNUNET_NAMESTORE_QueueEntry * | 357 | struct GNUNET_NAMESTORE_QueueEntry * |
232 | GNUNET_NAMESTORE_zone_to_name (struct GNUNET_NAMESTORE_Handle *h, | 358 | GNUNET_NAMESTORE_zone_to_name (struct GNUNET_NAMESTORE_Handle *h, |
233 | const struct GNUNET_IDENTITY_PrivateKey *zone, | 359 | const struct GNUNET_CRYPTO_PrivateKey *zone, |
234 | const struct | 360 | const struct |
235 | GNUNET_IDENTITY_PublicKey *value_zone, | 361 | GNUNET_CRYPTO_PublicKey *value_zone, |
236 | GNUNET_SCHEDULER_TaskCallback error_cb, | 362 | GNUNET_SCHEDULER_TaskCallback error_cb, |
237 | void *error_cb_cls, | 363 | void *error_cb_cls, |
238 | GNUNET_NAMESTORE_RecordMonitor proc, | 364 | GNUNET_NAMESTORE_RecordMonitor proc, |
@@ -252,6 +378,9 @@ GNUNET_NAMESTORE_cancel (struct GNUNET_NAMESTORE_QueueEntry *qe); | |||
252 | 378 | ||
253 | 379 | ||
254 | /** | 380 | /** |
381 | * @deprecated since 0.16.7 will be replaced in 0.18 | ||
382 | * @see GNUNET_NAMESTORE_zone_iteration_start2() | ||
383 | * | ||
255 | * Starts a new zone iteration (used to periodically PUT all of our | 384 | * Starts a new zone iteration (used to periodically PUT all of our |
256 | * records into our DHT). This MUST lock the `struct GNUNET_NAMESTORE_Handle` | 385 | * records into our DHT). This MUST lock the `struct GNUNET_NAMESTORE_Handle` |
257 | * for any other calls than #GNUNET_NAMESTORE_zone_iterator_next() and | 386 | * for any other calls than #GNUNET_NAMESTORE_zone_iterator_next() and |
@@ -279,7 +408,7 @@ GNUNET_NAMESTORE_cancel (struct GNUNET_NAMESTORE_QueueEntry *qe); | |||
279 | struct GNUNET_NAMESTORE_ZoneIterator * | 408 | struct GNUNET_NAMESTORE_ZoneIterator * |
280 | GNUNET_NAMESTORE_zone_iteration_start (struct GNUNET_NAMESTORE_Handle *h, | 409 | GNUNET_NAMESTORE_zone_iteration_start (struct GNUNET_NAMESTORE_Handle *h, |
281 | const struct | 410 | const struct |
282 | GNUNET_IDENTITY_PrivateKey *zone, | 411 | GNUNET_CRYPTO_PrivateKey *zone, |
283 | GNUNET_SCHEDULER_TaskCallback error_cb, | 412 | GNUNET_SCHEDULER_TaskCallback error_cb, |
284 | void *error_cb_cls, | 413 | void *error_cb_cls, |
285 | GNUNET_NAMESTORE_RecordMonitor proc, | 414 | GNUNET_NAMESTORE_RecordMonitor proc, |
@@ -287,6 +416,44 @@ GNUNET_NAMESTORE_zone_iteration_start (struct GNUNET_NAMESTORE_Handle *h, | |||
287 | GNUNET_SCHEDULER_TaskCallback finish_cb, | 416 | GNUNET_SCHEDULER_TaskCallback finish_cb, |
288 | void *finish_cb_cls); | 417 | void *finish_cb_cls); |
289 | 418 | ||
419 | /** | ||
420 | * Starts a new zone iteration (used to periodically PUT all of our | ||
421 | * records into our DHT). This MUST lock the `struct GNUNET_NAMESTORE_Handle` | ||
422 | * for any other calls than #GNUNET_NAMESTORE_zone_iterator_next() and | ||
423 | * #GNUNET_NAMESTORE_zone_iteration_stop. @a proc will be called once | ||
424 | * immediately, and then again after | ||
425 | * #GNUNET_NAMESTORE_zone_iterator_next() is invoked. | ||
426 | * | ||
427 | * On error (disconnect), @a error_cb will be invoked. | ||
428 | * On normal completion, @a finish_cb proc will be | ||
429 | * invoked. | ||
430 | * | ||
431 | * @param h handle to the namestore | ||
432 | * @param zone zone to access, NULL for all zones | ||
433 | * @param error_cb function to call on error (i.e. disconnect), | ||
434 | * the handle is afterwards invalid | ||
435 | * @param error_cb_cls closure for @a error_cb | ||
436 | * @param proc function to call on each name from the zone; it | ||
437 | * will be called repeatedly with a value (if available) | ||
438 | * @param proc_cls closure for @a proc | ||
439 | * @param finish_cb function to call on completion | ||
440 | * the handle is afterwards invalid | ||
441 | * @param finish_cb_cls closure for @a finish_cb | ||
442 | * @param filter the record set filter to use | ||
443 | * @return an iterator handle to use for iteration | ||
444 | */ | ||
445 | struct GNUNET_NAMESTORE_ZoneIterator * | ||
446 | GNUNET_NAMESTORE_zone_iteration_start2 (struct GNUNET_NAMESTORE_Handle *h, | ||
447 | const struct | ||
448 | GNUNET_CRYPTO_PrivateKey *zone, | ||
449 | GNUNET_SCHEDULER_TaskCallback error_cb, | ||
450 | void *error_cb_cls, | ||
451 | GNUNET_NAMESTORE_RecordSetMonitor proc, | ||
452 | void *proc_cls, | ||
453 | GNUNET_SCHEDULER_TaskCallback finish_cb, | ||
454 | void *finish_cb_cls, | ||
455 | enum GNUNET_GNSRECORD_Filter filter); | ||
456 | |||
290 | 457 | ||
291 | /** | 458 | /** |
292 | * Calls the record processor specified in #GNUNET_NAMESTORE_zone_iteration_start | 459 | * Calls the record processor specified in #GNUNET_NAMESTORE_zone_iteration_start |
@@ -319,6 +486,9 @@ struct GNUNET_NAMESTORE_ZoneMonitor; | |||
319 | 486 | ||
320 | 487 | ||
321 | /** | 488 | /** |
489 | * @deprecated since 0.16.7 will be replaced in 0.18 | ||
490 | * @see GNUNET_NAMESTORE_zone_monitor_start2() | ||
491 | * | ||
322 | * Begin monitoring a zone for changes. Will first call the @a | 492 | * Begin monitoring a zone for changes. Will first call the @a |
323 | * monitor function on all existing records in the selected zone(s) if | 493 | * monitor function on all existing records in the selected zone(s) if |
324 | * @a iterate_first is #GNUNET_YES. In any case, we will then call @a | 494 | * @a iterate_first is #GNUNET_YES. In any case, we will then call @a |
@@ -348,7 +518,7 @@ struct GNUNET_NAMESTORE_ZoneMonitor; | |||
348 | struct GNUNET_NAMESTORE_ZoneMonitor * | 518 | struct GNUNET_NAMESTORE_ZoneMonitor * |
349 | GNUNET_NAMESTORE_zone_monitor_start ( | 519 | GNUNET_NAMESTORE_zone_monitor_start ( |
350 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 520 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
351 | const struct GNUNET_IDENTITY_PrivateKey *zone, | 521 | const struct GNUNET_CRYPTO_PrivateKey *zone, |
352 | int iterate_first, | 522 | int iterate_first, |
353 | GNUNET_SCHEDULER_TaskCallback error_cb, | 523 | GNUNET_SCHEDULER_TaskCallback error_cb, |
354 | void *error_cb_cls, | 524 | void *error_cb_cls, |
@@ -357,6 +527,47 @@ GNUNET_NAMESTORE_zone_monitor_start ( | |||
357 | GNUNET_SCHEDULER_TaskCallback sync_cb, | 527 | GNUNET_SCHEDULER_TaskCallback sync_cb, |
358 | void *sync_cb_cls); | 528 | void *sync_cb_cls); |
359 | 529 | ||
530 | /** | ||
531 | * Begin monitoring a zone for changes. Will first call the @a | ||
532 | * monitor function on all existing records in the selected zone(s) if | ||
533 | * @a iterate_first is #GNUNET_YES. In any case, we will then call @a | ||
534 | * sync_cb, and then afterwards call the @a monitor whenever a record | ||
535 | * changes. If the namestore disconnects, the @a error_cb function is | ||
536 | * called with a disconnect event. Once the connection is | ||
537 | * re-established, the process begins from the start (depending on @a | ||
538 | * iterate_first, we will again first do all existing records, then @a | ||
539 | * sync, then updates). | ||
540 | * | ||
541 | * @param cfg configuration to use to connect to namestore | ||
542 | * @param zone zone to monitor, NULL for all zones | ||
543 | * @param iterate_first #GNUNET_YES to first iterate over all existing records, | ||
544 | * #GNUNET_NO to only return changes that happen from now on | ||
545 | * @param error_cb function to call on error (i.e. disconnect); note that | ||
546 | * unlike the other error callbacks in this API, a call to this | ||
547 | * function does NOT destroy the monitor handle, it merely signals | ||
548 | * that monitoring is down. You need to still explicitly call | ||
549 | * #GNUNET_NAMESTORE_zone_monitor_stop(). | ||
550 | * @param error_cb_cls closure for @a error_cb | ||
551 | * @param monitor function to call on zone changes, with an initial limit of 1 | ||
552 | * @param monitor_cls closure for @a monitor | ||
553 | * @param sync_cb function called when we're in sync with the namestore | ||
554 | * @param sync_cb_cls closure for @a sync_cb | ||
555 | * @param filter the record set filter to use | ||
556 | * @return handle to stop monitoring | ||
557 | */ | ||
558 | struct GNUNET_NAMESTORE_ZoneMonitor * | ||
559 | GNUNET_NAMESTORE_zone_monitor_start2 ( | ||
560 | const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
561 | const struct GNUNET_CRYPTO_PrivateKey *zone, | ||
562 | int iterate_first, | ||
563 | GNUNET_SCHEDULER_TaskCallback error_cb, | ||
564 | void *error_cb_cls, | ||
565 | GNUNET_NAMESTORE_RecordSetMonitor monitor, | ||
566 | void *monitor_cls, | ||
567 | GNUNET_SCHEDULER_TaskCallback sync_cb, | ||
568 | void *sync_cb_cls, | ||
569 | enum GNUNET_GNSRECORD_Filter filter); | ||
570 | |||
360 | 571 | ||
361 | /** | 572 | /** |
362 | * Calls the monitor processor specified in #GNUNET_NAMESTORE_zone_monitor_start | 573 | * Calls the monitor processor specified in #GNUNET_NAMESTORE_zone_monitor_start |
@@ -398,101 +609,62 @@ GNUNET_NAMESTORE_zone_monitor_stop (struct GNUNET_NAMESTORE_ZoneMonitor *zm); | |||
398 | */ | 609 | */ |
399 | 610 | ||
400 | /** | 611 | /** |
401 | * Begin a namestore transaction. | 612 | * This function is used to initiate the editing |
402 | * | 613 | * of a record set under #label. |
403 | * @param h handle to the namestore | 614 | * It will set the editor hint of the record set to #editor_hint. |
404 | * @param error_cb function to call on error (i.e. disconnect or unable to get lock) | 615 | * The editor hint serves as an advisory lock that is used in |
405 | * the handle is afterwards invalid | 616 | * #GNUNET_NAMESTORE_EdtirRecordSetBeginCallback if #editor_hint |
406 | * @param error_cb_cls closure for @a error_cb | 617 | * differs from the currently set advisory lock in the database. |
407 | * @return handle to abort the request | ||
408 | */ | ||
409 | struct GNUNET_NAMESTORE_QueueEntry * | ||
410 | GNUNET_NAMESTORE_transaction_begin (struct GNUNET_NAMESTORE_Handle *h, | ||
411 | GNUNET_SCHEDULER_TaskCallback error_cb, | ||
412 | void *error_cb_cls); | ||
413 | |||
414 | /** | ||
415 | * Begin rollback all actions in a transaction. | ||
416 | * Reverts all actions performed since #GNUNET_NAMESTORE_transaction_begin | ||
417 | * | ||
418 | * @param h handle to the namestore | ||
419 | * @param error_cb function to call on error (i.e. disconnect or unable to get lock) | ||
420 | * the handle is afterwards invalid | ||
421 | * @param error_cb_cls closure for @a error_cb | ||
422 | * @return handle to abort the request | ||
423 | */ | ||
424 | struct GNUNET_NAMESTORE_QueueEntry * | ||
425 | GNUNET_NAMESTORE_transaction_abort (struct GNUNET_NAMESTORE_Handle *h, | ||
426 | GNUNET_SCHEDULER_TaskCallback error_cb, | ||
427 | void *error_cb_cls); | ||
428 | /** | ||
429 | * Commit a namestore transaction. | ||
430 | * Saves all actions performed since #GNUNET_NAMESTORE_transaction_begin | ||
431 | * | ||
432 | * @param h handle to the namestore | ||
433 | * @param error_cb function to call on error (i.e. disconnect or unable to get lock) | ||
434 | * the handle is afterwards invalid | ||
435 | * @param error_cb_cls closure for @a error_cb | ||
436 | * @return handle to abort the request | ||
437 | */ | ||
438 | struct GNUNET_NAMESTORE_QueueEntry * | ||
439 | GNUNET_NAMESTORE_transaction_commit (struct GNUNET_NAMESTORE_Handle *h, | ||
440 | GNUNET_SCHEDULER_TaskCallback error_cb, | ||
441 | void *error_cb_cls); | ||
442 | |||
443 | /** | ||
444 | * Lookup an item in the namestore. | ||
445 | * | 618 | * |
446 | * @param h handle to the namestore | 619 | * @param h handle to the namestore |
447 | * @param pkey private key of the zone | 620 | * @param pkey the private key of the zone to edit |
448 | * @param label name that is being mapped | 621 | * @param label the label of the record set to edit |
449 | * @param error_cb function to call on error (i.e. disconnect) | 622 | * @param editor_hint the editor hint to set as advisory lock |
450 | * the handle is afterwards invalid | 623 | * @param error_cb the error callback |
451 | * @param error_cb_cls closure for @a error_cb | 624 | * @param error_cb_cls closure to #error_cb |
452 | * @param rm function to call with the result (with 0 records if we don't have that label); | 625 | * @param edit_cb the #GNUNET_NAMESTORE_EditRecordSetBeginCallback |
453 | * the handle is afterwards invalid | 626 | * @param edit_cb_cls closure to #edit_cb |
454 | * @param rm_cls closure for @a rm | 627 | * @return handle to the operation |
455 | * @return handle to abort the request | ||
456 | */ | 628 | */ |
457 | struct GNUNET_NAMESTORE_QueueEntry * | 629 | struct GNUNET_NAMESTORE_QueueEntry * |
458 | GNUNET_NAMESTORE_records_select (struct GNUNET_NAMESTORE_Handle *h, | 630 | GNUNET_NAMESTORE_record_set_edit_begin (struct GNUNET_NAMESTORE_Handle *h, |
459 | const struct | 631 | const struct |
460 | GNUNET_IDENTITY_PrivateKey *pkey, | 632 | GNUNET_CRYPTO_PrivateKey *pkey, |
461 | const char *label, | 633 | const char *label, |
462 | GNUNET_SCHEDULER_TaskCallback error_cb, | 634 | const char *editor_hint, |
463 | void *error_cb_cls, | 635 | GNUNET_NAMESTORE_EditRecordSetBeginCallback |
464 | GNUNET_NAMESTORE_RecordMonitor rm, | 636 | edit_cb, |
465 | void *rm_cls); | 637 | void *edit_cb_cls); |
466 | |||
467 | 638 | ||
468 | /** | 639 | /** |
469 | * Creates, deletes or updates an item in the namestore. | 640 | * If the current advisory lock is set to the provided editor hint, |
470 | * If the item is already present, it is replaced with the new record set. | 641 | * this API cancels the editing of a record set and unsets the advisory lock in database. |
471 | * Use an empty array to remove all records under the given name. | 642 | * Optionally, a new editor hint can be provided: For example, |
643 | * the value that was returned in in the callback to | ||
644 | * #GNUNET_NAMESTORE_record_set_edit_begin. | ||
472 | * | 645 | * |
473 | * The continuation is called after the value has been stored in the | 646 | * If provided editor hint does not match the current advisory lock, |
474 | * database. Monitors may be notified asynchronously (basically with | 647 | * this function is not doing anything (NOP). |
475 | * a buffer). However, if any monitor is consistently too slow to | ||
476 | * keep up with the changes, calling @a cont will be delayed until the | ||
477 | * monitors do keep up. | ||
478 | * | 648 | * |
479 | * @param h handle to the namestore | 649 | * @param h handle to the namestore |
480 | * @param pkey private key of the zone | 650 | * @param pkey the private key of the zone to edit |
481 | * @param label name that is being mapped | 651 | * @param label the label of the record set to edit |
482 | * @param rd_count number of records in the 'rd' array | 652 | * @param editor_hint the editor hint to set as advisory lock |
483 | * @param rd array of records with data to store | 653 | * @param editor_hint_replacement the editor hint to set as advisory lock instead of clearing it |
484 | * @param cont continuation to call when done | 654 | * @param finished_cb the callback called when cancelled |
485 | * @param cont_cls closure for @a cont | 655 | * @param finished_cb_cls closure to #finished_cb |
486 | * @return handle to abort the request | 656 | * @return handle to the operation |
487 | */ | 657 | */ |
488 | struct GNUNET_NAMESTORE_QueueEntry * | 658 | struct GNUNET_NAMESTORE_QueueEntry * |
489 | GNUNET_NAMESTORE_records_replace (struct GNUNET_NAMESTORE_Handle *h, | 659 | GNUNET_NAMESTORE_record_set_edit_cancel (struct GNUNET_NAMESTORE_Handle *h, |
490 | const struct GNUNET_IDENTITY_PrivateKey *pkey, | 660 | const struct |
491 | const char *label, | 661 | GNUNET_CRYPTO_PrivateKey *pkey, |
492 | unsigned int rd_count, | 662 | const char *label, |
493 | const struct GNUNET_GNSRECORD_Data *rd, | 663 | const char *editor_hint, |
494 | GNUNET_NAMESTORE_ContinuationWithStatus cont, | 664 | const char *editor_hint_replacement, |
495 | void *cont_cls); | 665 | GNUNET_NAMESTORE_ContinuationWithStatus |
666 | finished_cb, | ||
667 | void *finished_cls); | ||
496 | 668 | ||
497 | #if 0 /* keep Emacsens' auto-indent happy */ | 669 | #if 0 /* keep Emacsens' auto-indent happy */ |
498 | { | 670 | { |
@@ -504,3 +676,5 @@ GNUNET_NAMESTORE_records_replace (struct GNUNET_NAMESTORE_Handle *h, | |||
504 | #endif | 676 | #endif |
505 | 677 | ||
506 | /** @} */ /* end of group */ | 678 | /** @} */ /* end of group */ |
679 | |||
680 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_nat_auto_service.h b/src/include/gnunet_nat_auto_service.h index 78284dc01..1c511cac3 100644 --- a/src/include/gnunet_nat_auto_service.h +++ b/src/include/gnunet_nat_auto_service.h | |||
@@ -26,7 +26,7 @@ | |||
26 | * Service for testing and autoconfiguration of | 26 | * Service for testing and autoconfiguration of |
27 | * NAT traversal functionality | 27 | * NAT traversal functionality |
28 | * | 28 | * |
29 | * @defgroup nat NAT testing library | 29 | * @defgroup nat NAT library |
30 | * | 30 | * |
31 | * @{ | 31 | * @{ |
32 | */ | 32 | */ |
@@ -34,6 +34,7 @@ | |||
34 | #ifndef GNUNET_NAT_AUTO_SERVICE_H | 34 | #ifndef GNUNET_NAT_AUTO_SERVICE_H |
35 | #define GNUNET_NAT_AUTO_SERVICE_H | 35 | #define GNUNET_NAT_AUTO_SERVICE_H |
36 | 36 | ||
37 | |||
37 | #include "gnunet_util_lib.h" | 38 | #include "gnunet_util_lib.h" |
38 | #include "gnunet_nat_service.h" | 39 | #include "gnunet_nat_service.h" |
39 | 40 | ||
diff --git a/src/include/gnunet_nat_service.h b/src/include/gnunet_nat_service.h index e39e2c016..ba9f252a0 100644 --- a/src/include/gnunet_nat_service.h +++ b/src/include/gnunet_nat_service.h | |||
@@ -36,6 +36,7 @@ | |||
36 | #ifndef GNUNET_NAT_SERVICE_H | 36 | #ifndef GNUNET_NAT_SERVICE_H |
37 | #define GNUNET_NAT_SERVICE_H | 37 | #define GNUNET_NAT_SERVICE_H |
38 | 38 | ||
39 | |||
39 | #include "gnunet_util_lib.h" | 40 | #include "gnunet_util_lib.h" |
40 | 41 | ||
41 | 42 | ||
@@ -344,6 +345,19 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
344 | 345 | ||
345 | 346 | ||
346 | /** | 347 | /** |
348 | * Add global address to the list of addresses and notify clients. | ||
349 | * | ||
350 | * @param nh the handle returned by register | ||
351 | * @param addr IP address to add. | ||
352 | * @param address_length number of bytes in @a addr | ||
353 | */ | ||
354 | void | ||
355 | GNUNET_NAT_add_global_address (struct GNUNET_NAT_Handle *nh, | ||
356 | char *addr, | ||
357 | unsigned int address_length); | ||
358 | |||
359 | |||
360 | /** | ||
347 | * Test if the given address is (currently) a plausible IP address for | 361 | * Test if the given address is (currently) a plausible IP address for |
348 | * this peer. Mostly a convenience function so that clients do not | 362 | * this peer. Mostly a convenience function so that clients do not |
349 | * have to explicitly track all IPs that the #GNUNET_NAT_AddressCallback | 363 | * have to explicitly track all IPs that the #GNUNET_NAT_AddressCallback |
@@ -385,6 +399,12 @@ GNUNET_NAT_request_reversal (struct GNUNET_NAT_Handle *nh, | |||
385 | * handle. This frees the handle, after having sent the needed | 399 | * handle. This frees the handle, after having sent the needed |
386 | * commands to close open ports. | 400 | * commands to close open ports. |
387 | * | 401 | * |
402 | * FIXME: No, the implementation of this API does not do anything beyond | ||
403 | * cleaning up the handle. | ||
404 | * This is a problem for applications that use #GNUNET_NAT_AddressCallback | ||
405 | * and use the app_ctx to store objects, because the callback will never be | ||
406 | * called for cleanup on unregister. | ||
407 | * | ||
388 | * @param nh the handle to unregister | 408 | * @param nh the handle to unregister |
389 | */ | 409 | */ |
390 | void | 410 | void |
diff --git a/src/include/gnunet_nc_lib.h b/src/include/gnunet_nc_lib.h index bd22fd6e2..8f4d9a16f 100644 --- a/src/include/gnunet_nc_lib.h +++ b/src/include/gnunet_nc_lib.h | |||
@@ -17,7 +17,17 @@ | |||
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | |||
21 | |||
22 | #if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) | ||
23 | #error "Only <gnunet_util_lib.h> can be included directly." | ||
24 | #endif | ||
25 | |||
20 | /** | 26 | /** |
27 | * @addtogroup libgnunetutil | ||
28 | * Multi-function utilities library for GNUnet programs | ||
29 | * @{ | ||
30 | * | ||
21 | * @author Christian Grothoff | 31 | * @author Christian Grothoff |
22 | * | 32 | * |
23 | * @file | 33 | * @file |
@@ -99,3 +109,7 @@ unsigned int | |||
99 | GNUNET_notification_context_get_size (struct GNUNET_NotificationContext *nc); | 109 | GNUNET_notification_context_get_size (struct GNUNET_NotificationContext *nc); |
100 | 110 | ||
101 | #endif | 111 | #endif |
112 | |||
113 | /** @} */ /* end of group mq */ | ||
114 | |||
115 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_network_lib.h b/src/include/gnunet_network_lib.h index b1cf58711..764b7b29d 100644 --- a/src/include/gnunet_network_lib.h +++ b/src/include/gnunet_network_lib.h | |||
@@ -19,6 +19,13 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup libgnunetutil | ||
23 | * Multi-function utilities library for GNUnet programs | ||
24 | * @{ | ||
25 | * | ||
26 | * @addtogroup networking | ||
27 | * @{ | ||
28 | * | ||
22 | * @author Nils Durner | 29 | * @author Nils Durner |
23 | * @author Tobias Frisch | 30 | * @author Tobias Frisch |
24 | * | 31 | * |
@@ -32,6 +39,7 @@ | |||
32 | #ifndef GNUNET_NETWORK_LIB_H | 39 | #ifndef GNUNET_NETWORK_LIB_H |
33 | #define GNUNET_NETWORK_LIB_H | 40 | #define GNUNET_NETWORK_LIB_H |
34 | 41 | ||
42 | #include "gnunet_common.h" | ||
35 | #ifdef __cplusplus | 43 | #ifdef __cplusplus |
36 | extern "C" | 44 | extern "C" |
37 | { | 45 | { |
@@ -45,6 +53,7 @@ extern "C" | |||
45 | * Include "sys/select.h" because it is required to use | 53 | * Include "sys/select.h" because it is required to use |
46 | * "fd_set" in "struct GNUNET_NETWORK_FDSet"! | 54 | * "fd_set" in "struct GNUNET_NETWORK_FDSet"! |
47 | */ | 55 | */ |
56 | |||
48 | #include <sys/select.h> | 57 | #include <sys/select.h> |
49 | //#endif | 58 | //#endif |
50 | #ifdef HAVE_SYS_SOCKET_H | 59 | #ifdef HAVE_SYS_SOCKET_H |
@@ -149,7 +158,7 @@ GNUNET_NETWORK_socket_box_native (int fd); | |||
149 | * @param doBlock blocking mode | 158 | * @param doBlock blocking mode |
150 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 159 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
151 | */ | 160 | */ |
152 | int | 161 | enum GNUNET_GenericReturnValue |
153 | GNUNET_NETWORK_socket_set_blocking (struct GNUNET_NETWORK_Handle *fd, | 162 | GNUNET_NETWORK_socket_set_blocking (struct GNUNET_NETWORK_Handle *fd, |
154 | int doBlock); | 163 | int doBlock); |
155 | 164 | ||
@@ -588,3 +597,7 @@ GNUNET_NETWORK_test_port_free (int ipproto, | |||
588 | #endif /* GNUNET_NETWORK_LIB_H */ | 597 | #endif /* GNUNET_NETWORK_LIB_H */ |
589 | 598 | ||
590 | /** @} */ /* end of group */ | 599 | /** @} */ /* end of group */ |
600 | |||
601 | /** @} */ /* end of group addition */ | ||
602 | |||
603 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_nse_service.h b/src/include/gnunet_nse_service.h index 0401e0cbc..fe9e1f853 100644 --- a/src/include/gnunet_nse_service.h +++ b/src/include/gnunet_nse_service.h | |||
@@ -22,6 +22,9 @@ | |||
22 | #define GNUNET_NSE_SERVICE_H_ | 22 | #define GNUNET_NSE_SERVICE_H_ |
23 | 23 | ||
24 | /** | 24 | /** |
25 | * @addtogroup Backbone | ||
26 | * @{ | ||
27 | * | ||
25 | * @author Nathan Evans | 28 | * @author Nathan Evans |
26 | * | 29 | * |
27 | * @file | 30 | * @file |
@@ -47,6 +50,7 @@ extern "C" | |||
47 | #endif | 50 | #endif |
48 | #endif | 51 | #endif |
49 | 52 | ||
53 | |||
50 | #include "gnunet_util_lib.h" | 54 | #include "gnunet_util_lib.h" |
51 | 55 | ||
52 | /** | 56 | /** |
@@ -116,4 +120,6 @@ GNUNET_NSE_disconnect (struct GNUNET_NSE_Handle *h); | |||
116 | 120 | ||
117 | /** @} */ /* end of group nse */ | 121 | /** @} */ /* end of group nse */ |
118 | 122 | ||
123 | /** @} */ /* end of group addition */ | ||
124 | |||
119 | #endif /* GNUNET_NSE_SERVICE_H_ */ | 125 | #endif /* GNUNET_NSE_SERVICE_H_ */ |
diff --git a/src/include/gnunet_nt_lib.h b/src/include/gnunet_nt_lib.h index 18419a7b8..014b4fbe0 100644 --- a/src/include/gnunet_nt_lib.h +++ b/src/include/gnunet_nt_lib.h | |||
@@ -17,12 +17,20 @@ | |||
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | |||
21 | #if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) | ||
22 | #error "Only <gnunet_util_lib.h> can be included directly." | ||
23 | #endif | ||
24 | |||
20 | /** | 25 | /** |
26 | * @addtogroup Backbone | ||
27 | * @{ | ||
28 | * | ||
21 | * @file network type characterization | 29 | * @file network type characterization |
22 | * @author Christian Grothoff | 30 | * @author Christian Grothoff |
23 | * @author Matthias Wachs | 31 | * @author Matthias Wachs |
24 | * | 32 | * |
25 | * @defgroup nt network type characterization | 33 | * @defgroup nt Network type characterization |
26 | * | 34 | * |
27 | * @{ | 35 | * @{ |
28 | */ | 36 | */ |
@@ -122,3 +130,5 @@ GNUNET_NT_scanner_done (struct GNUNET_NT_InterfaceScanner *is); | |||
122 | #endif | 130 | #endif |
123 | 131 | ||
124 | /** @} */ /* end of group */ | 132 | /** @} */ /* end of group */ |
133 | |||
134 | /** @} */ /* end of group addition to backbone */ | ||
diff --git a/src/include/gnunet_op_lib.h b/src/include/gnunet_op_lib.h index 77fa7f955..e028fb7fb 100644 --- a/src/include/gnunet_op_lib.h +++ b/src/include/gnunet_op_lib.h | |||
@@ -18,7 +18,15 @@ | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) | ||
22 | #error "Only <gnunet_util_lib.h> can be included directly." | ||
23 | #endif | ||
24 | |||
21 | /** | 25 | /** |
26 | * @addtogroup libgnunetutil | ||
27 | * Multi-function utilities library for GNUnet programs | ||
28 | * @{ | ||
29 | * | ||
22 | * @file | 30 | * @file |
23 | * Asynchronous operations; register callbacks for operations and call them when a response arrives. | 31 | * Asynchronous operations; register callbacks for operations and call them when a response arrives. |
24 | * | 32 | * |
@@ -28,6 +36,7 @@ | |||
28 | #ifndef GNUNET_OP_H | 36 | #ifndef GNUNET_OP_H |
29 | #define GNUNET_OP_H | 37 | #define GNUNET_OP_H |
30 | 38 | ||
39 | |||
31 | #include "gnunet_util_lib.h" | 40 | #include "gnunet_util_lib.h" |
32 | 41 | ||
33 | /** | 42 | /** |
@@ -153,3 +162,5 @@ GNUNET_OP_remove (struct GNUNET_OP_Handle *h, | |||
153 | 162 | ||
154 | 163 | ||
155 | #endif // GNUNET_OP_H | 164 | #endif // GNUNET_OP_H |
165 | |||
166 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_os_lib.h b/src/include/gnunet_os_lib.h index eddf97dab..c1e193720 100644 --- a/src/include/gnunet_os_lib.h +++ b/src/include/gnunet_os_lib.h | |||
@@ -18,7 +18,15 @@ | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #if ! defined (__GNUNET_UTIL_LIB_H_INSIDE__) | ||
22 | #error "Only <gnunet_util_lib.h> can be included directly." | ||
23 | #endif | ||
24 | |||
21 | /** | 25 | /** |
26 | * @addtogroup libgnunetutil | ||
27 | * Multi-function utilities library for GNUnet programs | ||
28 | * @{ | ||
29 | * | ||
22 | * @author Christian Grothoff | 30 | * @author Christian Grothoff |
23 | * @author Krista Bennett | 31 | * @author Krista Bennett |
24 | * @author Gerd Knorr <kraxel@bytesex.org> | 32 | * @author Gerd Knorr <kraxel@bytesex.org> |
@@ -56,10 +64,6 @@ extern "C" | |||
56 | #endif | 64 | #endif |
57 | #endif | 65 | #endif |
58 | 66 | ||
59 | #include "gnunet_common.h" | ||
60 | #include "gnunet_configuration_lib.h" | ||
61 | #include "gnunet_scheduler_lib.h" | ||
62 | |||
63 | 67 | ||
64 | /** | 68 | /** |
65 | * Flags that determine which of the standard streams | 69 | * Flags that determine which of the standard streams |
@@ -379,14 +383,14 @@ GNUNET_OS_get_suid_binary_path (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
379 | * @param addrlen length of the address | 383 | * @param addrlen length of the address |
380 | * @return #GNUNET_OK to continue iteration, #GNUNET_SYSERR to abort | 384 | * @return #GNUNET_OK to continue iteration, #GNUNET_SYSERR to abort |
381 | */ | 385 | */ |
382 | typedef int | 386 | typedef enum GNUNET_GenericReturnValue |
383 | (*GNUNET_OS_NetworkInterfaceProcessor) (void *cls, | 387 | (*GNUNET_OS_NetworkInterfaceProcessor)(void *cls, |
384 | const char *name, | 388 | const char *name, |
385 | int isDefault, | 389 | int isDefault, |
386 | const struct sockaddr *addr, | 390 | const struct sockaddr *addr, |
387 | const struct sockaddr *broadcast_addr, | 391 | const struct sockaddr *broadcast_addr, |
388 | const struct sockaddr *netmask, | 392 | const struct sockaddr *netmask, |
389 | socklen_t addrlen); | 393 | socklen_t addrlen); |
390 | 394 | ||
391 | 395 | ||
392 | /** | 396 | /** |
@@ -608,7 +612,7 @@ GNUNET_OS_command_run (GNUNET_OS_LineProcessor proc, | |||
608 | * @param code return code/signal number | 612 | * @param code return code/signal number |
609 | * @return #GNUNET_OK on success, #GNUNET_NO if the process is still running, #GNUNET_SYSERR otherwise | 613 | * @return #GNUNET_OK on success, #GNUNET_NO if the process is still running, #GNUNET_SYSERR otherwise |
610 | */ | 614 | */ |
611 | int | 615 | enum GNUNET_GenericReturnValue |
612 | GNUNET_OS_process_status (struct GNUNET_OS_Process *proc, | 616 | GNUNET_OS_process_status (struct GNUNET_OS_Process *proc, |
613 | enum GNUNET_OS_ProcessStatusType *type, | 617 | enum GNUNET_OS_ProcessStatusType *type, |
614 | unsigned long *code); | 618 | unsigned long *code); |
@@ -624,7 +628,7 @@ GNUNET_OS_process_status (struct GNUNET_OS_Process *proc, | |||
624 | * @param proc pointer to process structure of the process to wait for | 628 | * @param proc pointer to process structure of the process to wait for |
625 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | 629 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
626 | */ | 630 | */ |
627 | int | 631 | enum GNUNET_GenericReturnValue |
628 | GNUNET_OS_process_wait (struct GNUNET_OS_Process *proc); | 632 | GNUNET_OS_process_wait (struct GNUNET_OS_Process *proc); |
629 | 633 | ||
630 | 634 | ||
@@ -637,7 +641,7 @@ GNUNET_OS_process_wait (struct GNUNET_OS_Process *proc); | |||
637 | * @param code return code/signal number | 641 | * @param code return code/signal number |
638 | * @return #GNUNET_OK on success, #GNUNET_NO if the process is still running, #GNUNET_SYSERR otherwise | 642 | * @return #GNUNET_OK on success, #GNUNET_NO if the process is still running, #GNUNET_SYSERR otherwise |
639 | */ | 643 | */ |
640 | int | 644 | enum GNUNET_GenericReturnValue |
641 | GNUNET_OS_process_wait_status (struct GNUNET_OS_Process *proc, | 645 | GNUNET_OS_process_wait_status (struct GNUNET_OS_Process *proc, |
642 | enum GNUNET_OS_ProcessStatusType *type, | 646 | enum GNUNET_OS_ProcessStatusType *type, |
643 | unsigned long *code); | 647 | unsigned long *code); |
@@ -690,4 +694,6 @@ GNUNET_OS_check_helper_binary (const char *binary, | |||
690 | 694 | ||
691 | /** @} */ /* end of group */ | 695 | /** @} */ /* end of group */ |
692 | 696 | ||
697 | /** @} */ /* end of group addition */ | ||
698 | |||
693 | /* end of gnunet_os_lib.h */ | 699 | /* end of gnunet_os_lib.h */ |
diff --git a/src/include/gnunet_peer_lib.h b/src/include/gnunet_peer_lib.h index f94b883f8..4a67878b9 100644 --- a/src/include/gnunet_peer_lib.h +++ b/src/include/gnunet_peer_lib.h | |||
@@ -18,7 +18,15 @@ | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) | ||
22 | #error "Only <gnunet_util_lib.h> can be included directly." | ||
23 | #endif | ||
24 | |||
21 | /** | 25 | /** |
26 | * @addtogroup libgnunetutil | ||
27 | * Multi-function utilities library for GNUnet programs | ||
28 | * @{ | ||
29 | * | ||
22 | * @author Christian Grothoff | 30 | * @author Christian Grothoff |
23 | * | 31 | * |
24 | * @file | 32 | * @file |
@@ -32,6 +40,7 @@ | |||
32 | #ifndef GNUNET_PEER_LIB_H | 40 | #ifndef GNUNET_PEER_LIB_H |
33 | #define GNUNET_PEER_LIB_H | 41 | #define GNUNET_PEER_LIB_H |
34 | 42 | ||
43 | |||
35 | #include "gnunet_util_lib.h" | 44 | #include "gnunet_util_lib.h" |
36 | 45 | ||
37 | #ifdef __cplusplus | 46 | #ifdef __cplusplus |
@@ -126,4 +135,6 @@ GNUNET_PEER_resolve2 (GNUNET_PEER_Id id); | |||
126 | 135 | ||
127 | /** @} */ /* end of group */ | 136 | /** @} */ /* end of group */ |
128 | 137 | ||
138 | /** @} */ /* end of group addition */ | ||
139 | |||
129 | /* end of gnunet_peer_lib.h */ | 140 | /* end of gnunet_peer_lib.h */ |
diff --git a/src/include/gnunet_peerinfo_service.h b/src/include/gnunet_peerinfo_service.h deleted file mode 100644 index cdea1a95f..000000000 --- a/src/include/gnunet_peerinfo_service.h +++ /dev/null | |||
@@ -1,210 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2009, 2010 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your 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 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @author Christian Grothoff | ||
22 | * | ||
23 | * @file | ||
24 | * Maintain the list of currently known hosts | ||
25 | * | ||
26 | * @defgroup peerinfo Peer Info service | ||
27 | * Maintain the list of currently known hosts. | ||
28 | * | ||
29 | * Holds an in-memory structure of data/hosts. | ||
30 | * | ||
31 | * @see [Documentation](https://gnunet.org/gnunets-peerinfo-subsystem) | ||
32 | * | ||
33 | * @{ | ||
34 | */ | ||
35 | |||
36 | #ifndef GNUNET_PEERINFO_SERVICE_H | ||
37 | #define GNUNET_PEERINFO_SERVICE_H | ||
38 | |||
39 | #include "gnunet_common.h" | ||
40 | #include "gnunet_configuration_lib.h" | ||
41 | #include "gnunet_crypto_lib.h" | ||
42 | #include "gnunet_hello_lib.h" | ||
43 | |||
44 | #ifdef __cplusplus | ||
45 | extern "C" | ||
46 | { | ||
47 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
48 | } | ||
49 | #endif | ||
50 | #endif | ||
51 | |||
52 | |||
53 | /** | ||
54 | * Handle to the peerinfo service. | ||
55 | */ | ||
56 | struct GNUNET_PEERINFO_Handle; | ||
57 | |||
58 | |||
59 | /** | ||
60 | * Connect to the peerinfo service. | ||
61 | * | ||
62 | * @param cfg configuration to use | ||
63 | * @return NULL on error (configuration related, actual connection | ||
64 | * etablishment may happen asynchronously). | ||
65 | */ | ||
66 | struct GNUNET_PEERINFO_Handle * | ||
67 | GNUNET_PEERINFO_connect (const struct GNUNET_CONFIGURATION_Handle *cfg); | ||
68 | |||
69 | |||
70 | /** | ||
71 | * Disconnect from the peerinfo service. Note that all iterators must | ||
72 | * have completed or have been cancelled by the time this function is | ||
73 | * called (otherwise, calling this function is a serious error). | ||
74 | * Furthermore, if #GNUNET_PEERINFO_add_peer() operations are still | ||
75 | * pending, they will be cancelled silently on disconnect. | ||
76 | * | ||
77 | * @param h handle to disconnect | ||
78 | */ | ||
79 | void | ||
80 | GNUNET_PEERINFO_disconnect (struct GNUNET_PEERINFO_Handle *h); | ||
81 | |||
82 | |||
83 | /** | ||
84 | * Add a host to the persistent list. This method operates in | ||
85 | * semi-reliable mode: if the transmission is not completed by | ||
86 | * the time #GNUNET_PEERINFO_disconnect() is called, it will be | ||
87 | * aborted. Furthermore, if a second HELLO is added for the | ||
88 | * same peer before the first one was transmitted, PEERINFO may | ||
89 | * merge the two HELLOs prior to transmission to the service. | ||
90 | * | ||
91 | * @param h handle to the peerinfo service | ||
92 | * @param hello the verified (!) HELLO message | ||
93 | * @param cont continuation to call when done, NULL is allowed | ||
94 | * @param cont_cls closure for @a cont | ||
95 | * @return handle to cancel add operation; all pending | ||
96 | * 'add' operations will be cancelled automatically | ||
97 | * on disconnect, so it is not necessary to keep this | ||
98 | * handle (unless @a cont is non-NULL and at some point | ||
99 | * calling @a cont must be prevented) | ||
100 | */ | ||
101 | struct GNUNET_MQ_Envelope * | ||
102 | GNUNET_PEERINFO_add_peer (struct GNUNET_PEERINFO_Handle *h, | ||
103 | const struct GNUNET_HELLO_Message *hello, | ||
104 | GNUNET_SCHEDULER_TaskCallback cont, | ||
105 | void *cont_cls); | ||
106 | |||
107 | |||
108 | /** | ||
109 | * Type of an iterator over the hosts. Note that each | ||
110 | * host will be called with each available protocol. | ||
111 | * | ||
112 | * @param cls closure | ||
113 | * @param peer id of the peer, NULL for last call | ||
114 | * @param hello hello message for the peer (can be NULL) | ||
115 | * @param error message | ||
116 | */ | ||
117 | typedef void | ||
118 | (*GNUNET_PEERINFO_Processor) (void *cls, | ||
119 | const struct GNUNET_PeerIdentity *peer, | ||
120 | const struct GNUNET_HELLO_Message *hello, | ||
121 | const char *err_msg); | ||
122 | |||
123 | |||
124 | /** | ||
125 | * Handle for cancellation of iteration over peers. | ||
126 | */ | ||
127 | struct GNUNET_PEERINFO_IteratorContext; | ||
128 | |||
129 | |||
130 | /** | ||
131 | * Call a method for each known matching host. The callback method | ||
132 | * will be invoked once for each matching host and then finally once | ||
133 | * with a NULL pointer. After that final invocation, the iterator | ||
134 | * context must no longer be used. | ||
135 | * | ||
136 | * Instead of calling this function with `peer == NULL` it is often | ||
137 | * better to use #GNUNET_PEERINFO_notify(). | ||
138 | * | ||
139 | * @param h handle to the peerinfo service | ||
140 | * @param include_friend_only include HELLO messages for friends only | ||
141 | * @param peer restrict iteration to this peer only (can be NULL) | ||
142 | * @param timeout how long to wait until timing out | ||
143 | * @param callback the method to call for each peer | ||
144 | * @param callback_cls closure for @a callback | ||
145 | * @return iterator context | ||
146 | */ | ||
147 | struct GNUNET_PEERINFO_IteratorContext * | ||
148 | GNUNET_PEERINFO_iterate (struct GNUNET_PEERINFO_Handle *h, | ||
149 | int include_friend_only, | ||
150 | const struct GNUNET_PeerIdentity *peer, | ||
151 | GNUNET_PEERINFO_Processor callback, | ||
152 | void *callback_cls); | ||
153 | |||
154 | |||
155 | /** | ||
156 | * Cancel an iteration over peer information. | ||
157 | * | ||
158 | * @param ic context of the iterator to cancel | ||
159 | */ | ||
160 | void | ||
161 | GNUNET_PEERINFO_iterate_cancel (struct GNUNET_PEERINFO_IteratorContext *ic); | ||
162 | |||
163 | |||
164 | /** | ||
165 | * Handle for notifications about changes to the set of known peers. | ||
166 | */ | ||
167 | struct GNUNET_PEERINFO_NotifyContext; | ||
168 | |||
169 | |||
170 | /** | ||
171 | * Call a method whenever our known information about peers | ||
172 | * changes. Initially calls the given function for all known | ||
173 | * peers and then only signals changes. | ||
174 | * | ||
175 | * If @a include_friend_only is set to #GNUNET_YES peerinfo will include HELLO | ||
176 | * messages which are intended for friend to friend mode and which do not | ||
177 | * have to be gossiped. Otherwise these messages are skipped. | ||
178 | * | ||
179 | * @param cfg configuration to use | ||
180 | * @param include_friend_only include HELLO messages for friends only | ||
181 | * @param callback the method to call for each peer | ||
182 | * @param callback_cls closure for @a callback | ||
183 | * @return NULL on error | ||
184 | */ | ||
185 | struct GNUNET_PEERINFO_NotifyContext * | ||
186 | GNUNET_PEERINFO_notify (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
187 | int include_friend_only, | ||
188 | GNUNET_PEERINFO_Processor callback, | ||
189 | void *callback_cls); | ||
190 | |||
191 | |||
192 | /** | ||
193 | * Stop notifying about changes. | ||
194 | * | ||
195 | * @param nc context to stop notifying | ||
196 | */ | ||
197 | void | ||
198 | GNUNET_PEERINFO_notify_cancel (struct GNUNET_PEERINFO_NotifyContext *nc); | ||
199 | |||
200 | |||
201 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
202 | { | ||
203 | #endif | ||
204 | #ifdef __cplusplus | ||
205 | } | ||
206 | #endif | ||
207 | |||
208 | #endif | ||
209 | |||
210 | /** @} */ /* end of group */ | ||
diff --git a/src/include/gnunet_peerstore_plugin.h b/src/include/gnunet_peerstore_plugin.h index 90190e5b5..6ecb9135a 100644 --- a/src/include/gnunet_peerstore_plugin.h +++ b/src/include/gnunet_peerstore_plugin.h | |||
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup Backbone | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Omar Tarabai | 25 | * @author Omar Tarabai |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
@@ -31,6 +34,7 @@ | |||
31 | #ifndef GNUNET_PEERSTORE_PLUGIN_H | 34 | #ifndef GNUNET_PEERSTORE_PLUGIN_H |
32 | #define GNUNET_PEERSTORE_PLUGIN_H | 35 | #define GNUNET_PEERSTORE_PLUGIN_H |
33 | 36 | ||
37 | |||
34 | #include "gnunet_util_lib.h" | 38 | #include "gnunet_util_lib.h" |
35 | #include "gnunet_peerstore_service.h" | 39 | #include "gnunet_peerstore_service.h" |
36 | 40 | ||
@@ -42,6 +46,19 @@ extern "C" | |||
42 | #endif | 46 | #endif |
43 | #endif | 47 | #endif |
44 | 48 | ||
49 | /** | ||
50 | * Function called by PEERSTORE for each matching record. | ||
51 | * | ||
52 | * @param cls closure | ||
53 | * @param seq sequence in interation | ||
54 | * @param record peerstore record information | ||
55 | * @param emsg error message, or NULL if no errors | ||
56 | */ | ||
57 | typedef void (*GNUNET_PEERSTORE_PluginProcessor) ( | ||
58 | void *cls, | ||
59 | uint64_t seq, | ||
60 | const struct GNUNET_PEERSTORE_Record *record, | ||
61 | const char *emsg); | ||
45 | 62 | ||
46 | /** | 63 | /** |
47 | * @brief struct returned by the initialization function of the plugin | 64 | * @brief struct returned by the initialization function of the plugin |
@@ -89,6 +106,7 @@ struct GNUNET_PEERSTORE_PluginFunctions | |||
89 | * @param sub_system name of sub system | 106 | * @param sub_system name of sub system |
90 | * @param peer Peer identity (can be NULL) | 107 | * @param peer Peer identity (can be NULL) |
91 | * @param key entry key string (can be NULL) | 108 | * @param key entry key string (can be NULL) |
109 | * @param limit max number of results to give | ||
92 | * @param iter function to call asynchronously with the results, terminated | 110 | * @param iter function to call asynchronously with the results, terminated |
93 | * by a NULL result | 111 | * by a NULL result |
94 | * @param iter_cls closure for @a iter | 112 | * @param iter_cls closure for @a iter |
@@ -100,7 +118,9 @@ struct GNUNET_PEERSTORE_PluginFunctions | |||
100 | const char *sub_system, | 118 | const char *sub_system, |
101 | const struct GNUNET_PeerIdentity *peer, | 119 | const struct GNUNET_PeerIdentity *peer, |
102 | const char *key, | 120 | const char *key, |
103 | GNUNET_PEERSTORE_Processor iter, | 121 | uint64_t serial, |
122 | uint64_t limit, | ||
123 | GNUNET_PEERSTORE_PluginProcessor iter, | ||
104 | void *iter_cls); | 124 | void *iter_cls); |
105 | 125 | ||
106 | /** | 126 | /** |
@@ -131,3 +151,5 @@ struct GNUNET_PEERSTORE_PluginFunctions | |||
131 | #endif | 151 | #endif |
132 | 152 | ||
133 | /** @} */ /* end of group */ | 153 | /** @} */ /* end of group */ |
154 | |||
155 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_peerstore_service.h b/src/include/gnunet_peerstore_service.h index 91a8f2e66..3fb9df82a 100644 --- a/src/include/gnunet_peerstore_service.h +++ b/src/include/gnunet_peerstore_service.h | |||
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup Backbone | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Omar Tarabai | 25 | * @author Omar Tarabai |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
@@ -33,6 +36,7 @@ | |||
33 | #ifndef GNUNET_PEERSTORE_SERVICE_H | 36 | #ifndef GNUNET_PEERSTORE_SERVICE_H |
34 | #define GNUNET_PEERSTORE_SERVICE_H | 37 | #define GNUNET_PEERSTORE_SERVICE_H |
35 | 38 | ||
39 | |||
36 | #include "gnunet_util_lib.h" | 40 | #include "gnunet_util_lib.h" |
37 | 41 | ||
38 | #ifdef __cplusplus | 42 | #ifdef __cplusplus |
@@ -42,6 +46,10 @@ extern "C" { | |||
42 | #endif | 46 | #endif |
43 | #endif | 47 | #endif |
44 | 48 | ||
49 | /** | ||
50 | * Key used for storing HELLO in the peerstore | ||
51 | */ | ||
52 | #define GNUNET_PEERSTORE_HELLO_KEY "peerstore-peer-hello-uri" | ||
45 | 53 | ||
46 | /** | 54 | /** |
47 | * Key used for storing addresses in URL format in the peerstore | 55 | * Key used for storing addresses in URL format in the peerstore |
@@ -58,32 +66,32 @@ extern "C" { | |||
58 | * messages. | 66 | * messages. |
59 | */ | 67 | */ |
60 | #define GNUNET_PEERSTORE_TRANSPORT_BACKCHANNEL_MONOTIME \ | 68 | #define GNUNET_PEERSTORE_TRANSPORT_BACKCHANNEL_MONOTIME \ |
61 | "transport-backchannel-monotonic-time" | 69 | "transport-backchannel-monotonic-time" |
62 | 70 | ||
63 | /** | 71 | /** |
64 | * Key used to store sender's monotonic time from DV learn | 72 | * Key used to store sender's monotonic time from DV learn |
65 | * messages. | 73 | * messages. |
66 | */ | 74 | */ |
67 | #define GNUNET_PEERSTORE_TRANSPORT_DVLEARN_MONOTIME \ | 75 | #define GNUNET_PEERSTORE_TRANSPORT_DVLEARN_MONOTIME \ |
68 | "transport-dv-learn-monotonic-time" | 76 | "transport-dv-learn-monotonic-time" |
69 | 77 | ||
70 | /** | 78 | /** |
71 | * Key used to store sender's monotonic time from handshake message. | 79 | * Key used to store sender's monotonic time from handshake message. |
72 | */ | 80 | */ |
73 | #define GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE \ | 81 | #define GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE \ |
74 | "transport-tcp-communicator-handshake" | 82 | "transport-tcp-communicator-handshake" |
75 | 83 | ||
76 | /** | 84 | /** |
77 | * Key used to store sender's monotonic time from handshake ack message. | 85 | * Key used to store sender's monotonic time from handshake ack message. |
78 | */ | 86 | */ |
79 | #define GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE_ACK \ | 87 | #define GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE_ACK \ |
80 | "transport-tcp-communicator-handshake-ack" | 88 | "transport-tcp-communicator-handshake-ack" |
81 | 89 | ||
82 | /** | 90 | /** |
83 | * Key used to store sender's monotonic time from rekey message. | 91 | * Key used to store sender's monotonic time from rekey message. |
84 | */ | 92 | */ |
85 | #define GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_REKEY \ | 93 | #define GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_REKEY \ |
86 | "transport-tcp-communicator-rekey" | 94 | "transport-tcp-communicator-rekey" |
87 | 95 | ||
88 | 96 | ||
89 | /** | 97 | /** |
@@ -100,7 +108,8 @@ enum GNUNET_PEERSTORE_StoreOption | |||
100 | * Delete any previous values for the given key before | 108 | * Delete any previous values for the given key before |
101 | * storing the given value. | 109 | * storing the given value. |
102 | */ | 110 | */ |
103 | GNUNET_PEERSTORE_STOREOPTION_REPLACE = 1 | 111 | GNUNET_PEERSTORE_STOREOPTION_REPLACE = 1, |
112 | |||
104 | }; | 113 | }; |
105 | 114 | ||
106 | /** | 115 | /** |
@@ -114,6 +123,11 @@ struct GNUNET_PEERSTORE_Handle; | |||
114 | struct GNUNET_PEERSTORE_StoreContext; | 123 | struct GNUNET_PEERSTORE_StoreContext; |
115 | 124 | ||
116 | /** | 125 | /** |
126 | * Context for the info handler. | ||
127 | */ | ||
128 | struct GNUNET_PEERSTORE_NotifyContext; | ||
129 | |||
130 | /** | ||
117 | * Single PEERSTORE record | 131 | * Single PEERSTORE record |
118 | */ | 132 | */ |
119 | struct GNUNET_PEERSTORE_Record | 133 | struct GNUNET_PEERSTORE_Record |
@@ -148,11 +162,6 @@ struct GNUNET_PEERSTORE_Record | |||
148 | */ | 162 | */ |
149 | struct GNUNET_TIME_Absolute expiry; | 163 | struct GNUNET_TIME_Absolute expiry; |
150 | 164 | ||
151 | /** | ||
152 | * Client from which this record originated. | ||
153 | * NOTE: This is internal to the service. | ||
154 | */ | ||
155 | struct GNUNET_SERVICE_Client *client; | ||
156 | }; | 165 | }; |
157 | 166 | ||
158 | 167 | ||
@@ -166,9 +175,16 @@ typedef void (*GNUNET_PEERSTORE_Continuation) (void *cls, int success); | |||
166 | 175 | ||
167 | 176 | ||
168 | /** | 177 | /** |
178 | * Context for a add hello uri request. | ||
179 | */ | ||
180 | struct GNUNET_PEERSTORE_StoreHelloContext; | ||
181 | |||
182 | |||
183 | /** | ||
169 | * Function called by PEERSTORE for each matching record. | 184 | * Function called by PEERSTORE for each matching record. |
170 | * | 185 | * |
171 | * @param cls closure | 186 | * @param cls closure |
187 | * @param seq sequence in interation | ||
172 | * @param record peerstore record information | 188 | * @param record peerstore record information |
173 | * @param emsg error message, or NULL if no errors | 189 | * @param emsg error message, or NULL if no errors |
174 | */ | 190 | */ |
@@ -177,6 +193,43 @@ typedef void (*GNUNET_PEERSTORE_Processor) ( | |||
177 | const struct GNUNET_PEERSTORE_Record *record, | 193 | const struct GNUNET_PEERSTORE_Record *record, |
178 | const char *emsg); | 194 | const char *emsg); |
179 | 195 | ||
196 | /** | ||
197 | * Function called by PEERSTORE when notifying a client about a changed hello. | ||
198 | * | ||
199 | * @param cls closure | ||
200 | * @param hello_uri Hello uri. | ||
201 | */ | ||
202 | typedef void (*GNUNET_PEERSTORE_hello_notify_cb) ( | ||
203 | void *cls, | ||
204 | const struct GNUNET_PeerIdentity *peer, | ||
205 | const struct GNUNET_MessageHeader *hello, | ||
206 | const char *err_msg); | ||
207 | |||
208 | /** | ||
209 | * Add hello to peerstore. | ||
210 | * | ||
211 | * @param h handle for peerstore. | ||
212 | * @param msg The hello to add. | ||
213 | * @param cont The continuation function to execute after storing. | ||
214 | * @param cont_cls The continuation function closure. | ||
215 | * @return The context for storing. | ||
216 | */ | ||
217 | struct GNUNET_PEERSTORE_StoreHelloContext * | ||
218 | GNUNET_PEERSTORE_hello_add (struct GNUNET_PEERSTORE_Handle *h, | ||
219 | const struct GNUNET_MessageHeader *msg, | ||
220 | GNUNET_PEERSTORE_Continuation cont, | ||
221 | void *cont_cls); | ||
222 | |||
223 | |||
224 | /** | ||
225 | * Cancel the request to add a hello. | ||
226 | * | ||
227 | * @param huc The context for storing a hello. | ||
228 | */ | ||
229 | void | ||
230 | GNUNET_PEERSTORE_hello_add_cancel (struct | ||
231 | GNUNET_PEERSTORE_StoreHelloContext *huc); | ||
232 | |||
180 | 233 | ||
181 | /** | 234 | /** |
182 | * Connect to the PEERSTORE service. | 235 | * Connect to the PEERSTORE service. |
@@ -188,15 +241,13 @@ GNUNET_PEERSTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg); | |||
188 | 241 | ||
189 | 242 | ||
190 | /** | 243 | /** |
191 | * Disconnect from the PEERSTORE service. Any pending ITERATE and WATCH requests | 244 | * Disconnect from the PEERSTORE service. Any pending ITERATE and WATCH and |
192 | * will be canceled. | 245 | * STORE requests will be canceled. |
193 | * Any pending STORE requests will depend on @e snyc_first flag. | ||
194 | * | 246 | * |
195 | * @param h handle to disconnect | 247 | * @param h handle to disconnect |
196 | * @param sync_first send any pending STORE requests before disconnecting | ||
197 | */ | 248 | */ |
198 | void | 249 | void |
199 | GNUNET_PEERSTORE_disconnect (struct GNUNET_PEERSTORE_Handle *h, int sync_first); | 250 | GNUNET_PEERSTORE_disconnect (struct GNUNET_PEERSTORE_Handle *h); |
200 | 251 | ||
201 | 252 | ||
202 | /** | 253 | /** |
@@ -238,63 +289,130 @@ GNUNET_PEERSTORE_store_cancel (struct GNUNET_PEERSTORE_StoreContext *sc); | |||
238 | 289 | ||
239 | 290 | ||
240 | /** | 291 | /** |
241 | * Iterate over records matching supplied key information | 292 | * Iterate over peerstore entries. |
293 | * The iteration can be filtered to contain only records | ||
294 | * matching @a peer and/or @a key. | ||
295 | * The @a sub_system to match must be provided. | ||
296 | * @a callback will be called with (each) matching record. | ||
297 | * #GNUNET_PEERSTORE_iteration_next() must be invoked | ||
298 | * to continue processing until the end of the iteration is | ||
299 | * reached. | ||
242 | * | 300 | * |
243 | * @param h handle to the PEERSTORE service | 301 | * @param h handle to the PEERSTORE service |
244 | * @param sub_system name of sub system | 302 | * @param sub_system name of sub system |
245 | * @param peer Peer identity (can be NULL) | 303 | * @param peer Peer identity (can be NULL) |
246 | * @param key entry key string (can be NULL) | 304 | * @param key entry key string (can be NULL) |
247 | * @param callback function called with each matching record, all NULL's on end | 305 | * @param callback function called with each matching record. The record will be NULL to indicate end. |
248 | * @param callback_cls closure for @a callback | 306 | * @param callback_cls closure for @a callback |
307 | * @return Handle to iteration request | ||
249 | */ | 308 | */ |
250 | struct GNUNET_PEERSTORE_IterateContext * | 309 | struct GNUNET_PEERSTORE_IterateContext * |
251 | GNUNET_PEERSTORE_iterate (struct GNUNET_PEERSTORE_Handle *h, | 310 | GNUNET_PEERSTORE_iteration_start (struct GNUNET_PEERSTORE_Handle *h, |
252 | const char *sub_system, | 311 | const char *sub_system, |
253 | const struct GNUNET_PeerIdentity *peer, | 312 | const struct GNUNET_PeerIdentity *peer, |
254 | const char *key, | 313 | const char *key, |
255 | GNUNET_PEERSTORE_Processor callback, | 314 | GNUNET_PEERSTORE_Processor callback, |
256 | void *callback_cls); | 315 | void *callback_cls); |
257 | 316 | ||
258 | 317 | ||
259 | /** | 318 | /** |
260 | * Cancel an iterate request | 319 | * Continue an iteration. |
261 | * Please do not call after the iterate request is done | 320 | * Do NOT call after the iterate request is done. |
262 | * | 321 | * |
263 | * @param ic Iterate request context as returned by GNUNET_PEERSTORE_iterate() | 322 | * @param ic Iterate request context as returned by #GNUNET_PEERSTORE_iteration_start() |
323 | * @param limit how many records to return max until #GNUNET_PEERSTORE_iterate_next() needs to be called again. | ||
264 | */ | 324 | */ |
265 | void | 325 | void |
266 | GNUNET_PEERSTORE_iterate_cancel (struct GNUNET_PEERSTORE_IterateContext *ic); | 326 | GNUNET_PEERSTORE_iteration_next (struct GNUNET_PEERSTORE_IterateContext *ic, |
327 | uint64_t limit); | ||
267 | 328 | ||
268 | 329 | ||
269 | /** | 330 | /** |
331 | * Cancel an iteration. | ||
332 | * Do NOT call after the iterate request is done | ||
333 | * | ||
334 | * @param ic Iterate request context as returned by #GNUNET_PEERSTORE_iteration_start() | ||
335 | */ | ||
336 | void | ||
337 | GNUNET_PEERSTORE_iteration_stop (struct GNUNET_PEERSTORE_IterateContext *ic); | ||
338 | |||
339 | /** | ||
270 | * Request watching a given key | 340 | * Request watching a given key |
271 | * User will be notified with any new values added to key. | 341 | * The monitoring can be filtered to contain only records |
342 | * matching @a peer and/or @a key. | ||
343 | * The @a sub_system to match must be provided. | ||
344 | * @a callback will be called with (each) matching new record. | ||
345 | * #GNUNET_PEERSTORE_monitor_next() must be invoked | ||
346 | * to continue processing until @a sync_cb is | ||
347 | * called, indicating that the caller should be up-to-date. | ||
348 | * The caller will be notified with any new values added to key | ||
349 | * through @a callback. | ||
350 | * If @a iterate_first is set to GNUNET_YES, the monitor will first | ||
351 | * iterate over all existing, matching records. In any case, | ||
352 | * after @a sync_cb is called the first time monitoring starts. | ||
272 | * | 353 | * |
273 | * @param h handle to the PEERSTORE service | 354 | * @param h handle to the PEERSTORE service |
355 | * @param iterate_first first iterated of all results if GNUNET_YES | ||
274 | * @param sub_system name of sub system | 356 | * @param sub_system name of sub system |
275 | * @param peer Peer identity | 357 | * @param peer Peer identity |
276 | * @param key entry key string | 358 | * @param key entry key string |
359 | * @param error_cb function to call on error (i.e. disconnect); note that | ||
360 | * unlike the other error callbacks in this API, a call to this | ||
361 | * function does NOT destroy the monitor handle, it merely signals | ||
362 | * that monitoring is down. You need to still explicitly call | ||
363 | * #GNUNET_PEERSTORE_monitor_stop(). | ||
364 | * @param error_cb_cls closure for @a error_cb | ||
365 | * @param sync_cb function called when we're in sync with the peerstore | ||
366 | * @param sync_cb_cls closure for @a sync_cb | ||
277 | * @param callback function called with each new value | 367 | * @param callback function called with each new value |
278 | * @param callback_cls closure for @a callback | 368 | * @param callback_cls closure for @a callback |
279 | * @return Handle to watch request | 369 | * @return Handle to watch request |
280 | */ | 370 | */ |
281 | struct GNUNET_PEERSTORE_WatchContext * | 371 | struct GNUNET_PEERSTORE_Monitor * |
282 | GNUNET_PEERSTORE_watch (struct GNUNET_PEERSTORE_Handle *h, | 372 | GNUNET_PEERSTORE_monitor_start (const struct GNUNET_CONFIGURATION_Handle *cfg, |
283 | const char *sub_system, | 373 | int iterate_first, |
284 | const struct GNUNET_PeerIdentity *peer, | 374 | const char *sub_system, |
285 | const char *key, | 375 | const struct GNUNET_PeerIdentity *peer, |
286 | GNUNET_PEERSTORE_Processor callback, | 376 | const char *key, |
287 | void *callback_cls); | 377 | GNUNET_SCHEDULER_TaskCallback error_cb, |
288 | 378 | void *error_cb_cls, | |
379 | GNUNET_SCHEDULER_TaskCallback sync_cb, | ||
380 | void *sync_cb_cls, | ||
381 | GNUNET_PEERSTORE_Processor callback, | ||
382 | void *callback_cls); | ||
289 | 383 | ||
290 | /** | 384 | /** |
291 | * Cancel a watch request | 385 | * Calls the monitor processor specified in #GNUNET_PEERSTORE_monitor_start |
386 | * for the next record(s). This function is used to allow clients that merely | ||
387 | * monitor the NAMESTORE to still throttle namestore operations, so we can be | ||
388 | * sure that the monitors can keep up. | ||
389 | * | ||
390 | * Note that #GNUNET_PEERSTORE_store() only waits for this | ||
391 | * call if the previous limit set by the client was already reached. | ||
392 | * Thus, by using a @a limit greater than 1, monitors basically enable | ||
393 | * a queue of notifications to be processed asynchronously with some | ||
394 | * delay. Note that even with a limit of 1 the | ||
395 | * #GNUNET_PEERSTORE_store() function will run asynchronously | ||
396 | * and the continuation may be invoked before the monitors completed | ||
397 | * (or even started) processing the notification. Thus, monitors will | ||
398 | * only closely track the current state of the peerstore, but not | ||
399 | * be involved in the transactions. | ||
292 | * | 400 | * |
293 | * @param wc handle to the watch request | 401 | * @param zm the monitor |
402 | * @param limit number of records to return to the iterator in one shot | ||
403 | * (before #GNUNET_PEERSTORE_monitor_next is to be called again) | ||
294 | */ | 404 | */ |
295 | void | 405 | void |
296 | GNUNET_PEERSTORE_watch_cancel (struct GNUNET_PEERSTORE_WatchContext *wc); | 406 | GNUNET_PEERSTORE_monitor_next (struct GNUNET_PEERSTORE_Monitor *zm, |
407 | uint64_t limit); | ||
297 | 408 | ||
409 | /** | ||
410 | * Stop monitoring. | ||
411 | * | ||
412 | * @param zm handle to the monitor activity to stop | ||
413 | */ | ||
414 | void | ||
415 | GNUNET_PEERSTORE_monitor_stop (struct GNUNET_PEERSTORE_Monitor *zm); | ||
298 | 416 | ||
299 | #if 0 /* keep Emacsens' auto-indent happy */ | 417 | #if 0 /* keep Emacsens' auto-indent happy */ |
300 | { | 418 | { |
@@ -306,3 +424,5 @@ GNUNET_PEERSTORE_watch_cancel (struct GNUNET_PEERSTORE_WatchContext *wc); | |||
306 | #endif | 424 | #endif |
307 | 425 | ||
308 | /** @} */ /* end of group */ | 426 | /** @} */ /* end of group */ |
427 | |||
428 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_plugin_lib.h b/src/include/gnunet_plugin_lib.h index d265eb343..2a9cde47f 100644 --- a/src/include/gnunet_plugin_lib.h +++ b/src/include/gnunet_plugin_lib.h | |||
@@ -18,7 +18,15 @@ | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) | ||
22 | #error "Only <gnunet_util_lib.h> can be included directly." | ||
23 | #endif | ||
24 | |||
21 | /** | 25 | /** |
26 | * @addtogroup libgnunetutil | ||
27 | * Multi-function utilities library for GNUnet programs | ||
28 | * @{ | ||
29 | * | ||
22 | * @author Christian Grothoff | 30 | * @author Christian Grothoff |
23 | * | 31 | * |
24 | * @file | 32 | * @file |
@@ -40,9 +48,6 @@ extern "C" | |||
40 | #endif | 48 | #endif |
41 | #endif | 49 | #endif |
42 | 50 | ||
43 | #include "gnunet_common.h" | ||
44 | #include "gnunet_configuration_lib.h" | ||
45 | |||
46 | 51 | ||
47 | /** | 52 | /** |
48 | * Signature of any function exported by a plugin. | 53 | * Signature of any function exported by a plugin. |
@@ -65,7 +70,7 @@ typedef void * | |||
65 | * @param library_name name of the plugin to test if it is installed | 70 | * @param library_name name of the plugin to test if it is installed |
66 | * @return #GNUNET_YES if the plugin exists, #GNUNET_NO if not | 71 | * @return #GNUNET_YES if the plugin exists, #GNUNET_NO if not |
67 | */ | 72 | */ |
68 | int | 73 | enum GNUNET_GenericReturnValue |
69 | GNUNET_PLUGIN_test (const char *library_name); | 74 | GNUNET_PLUGIN_test (const char *library_name); |
70 | 75 | ||
71 | 76 | ||
@@ -169,4 +174,6 @@ GNUNET_PLUGIN_unload (const char *library_name, | |||
169 | 174 | ||
170 | /** @} */ /* end of group */ | 175 | /** @} */ /* end of group */ |
171 | 176 | ||
177 | /** @} */ /* end of group addition */ | ||
178 | |||
172 | /* end of gnunet_plugin_lib.h */ | 179 | /* end of gnunet_plugin_lib.h */ |
diff --git a/src/include/gnunet_pq_lib.h b/src/include/gnunet_pq_lib.h index 2263704aa..7501bee12 100644 --- a/src/include/gnunet_pq_lib.h +++ b/src/include/gnunet_pq_lib.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | Copyright (C) 2016, 2017, 2020, 2021 GNUnet e.V. | 3 | Copyright (C) 2016, 2017, 2020-2022 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -25,9 +25,19 @@ | |||
25 | #ifndef GNUNET_PQ_LIB_H | 25 | #ifndef GNUNET_PQ_LIB_H |
26 | #define GNUNET_PQ_LIB_H | 26 | #define GNUNET_PQ_LIB_H |
27 | 27 | ||
28 | |||
28 | #include <libpq-fe.h> | 29 | #include <libpq-fe.h> |
30 | #include <stdint.h> | ||
31 | #include "gnunet_common.h" | ||
32 | #include "gnunet_time_lib.h" | ||
29 | #include "gnunet_util_lib.h" | 33 | #include "gnunet_util_lib.h" |
30 | #include "gnunet_db_lib.h" | 34 | #include "gnunet_db_lib.h" |
35 | #include "postgres_ext.h" | ||
36 | |||
37 | /** | ||
38 | * Postgres context. | ||
39 | */ | ||
40 | struct GNUNET_PQ_Context; | ||
31 | 41 | ||
32 | /* ************************* pq_query_helper.c functions ************************ */ | 42 | /* ************************* pq_query_helper.c functions ************************ */ |
33 | 43 | ||
@@ -57,6 +67,14 @@ typedef int | |||
57 | void *scratch[], | 67 | void *scratch[], |
58 | unsigned int scratch_length); | 68 | unsigned int scratch_length); |
59 | 69 | ||
70 | /** | ||
71 | * Function called to cleanup the closure of SQL parameters converter. Will be | ||
72 | * called with GNUNET_PQ_query_params_cleanup | ||
73 | * | ||
74 | * @param cls closure | ||
75 | */ | ||
76 | typedef void | ||
77 | (*GNUNET_PQ_QueryConverter_Cleanup)(void *cls); | ||
60 | 78 | ||
61 | /** | 79 | /** |
62 | * @brief Description of a DB query parameter. | 80 | * @brief Description of a DB query parameter. |
@@ -70,10 +88,20 @@ struct GNUNET_PQ_QueryParam | |||
70 | 88 | ||
71 | /** | 89 | /** |
72 | * Closure for @e conv. | 90 | * Closure for @e conv. |
91 | * The function @conv_cls_cleanup can be set to cleanup the closure. | ||
92 | * The cleanup of the closure MUST be triggered manually by a call to | ||
93 | * GNUNET_PQ_query_params_cleanup. | ||
73 | */ | 94 | */ |
74 | void *conv_cls; | 95 | void *conv_cls; |
75 | 96 | ||
76 | /** | 97 | /** |
98 | * Function to cleanup the closure @a conv_cls, may be NULL. | ||
99 | * The cleanup of the closure MUST be triggered manually by a call to | ||
100 | * GNUNET_PQ_query_params_cleanup. | ||
101 | */ | ||
102 | GNUNET_PQ_QueryConverter_Cleanup conv_cls_cleanup; | ||
103 | |||
104 | /** | ||
77 | * Data or NULL. | 105 | * Data or NULL. |
78 | */ | 106 | */ |
79 | const void *data; | 107 | const void *data; |
@@ -90,6 +118,15 @@ struct GNUNET_PQ_QueryParam | |||
90 | 118 | ||
91 | }; | 119 | }; |
92 | 120 | ||
121 | /** | ||
122 | * Must be called to cleanup memory from closures after the query parameters | ||
123 | * have been used as much as needed. | ||
124 | * | ||
125 | * @param params Array of GNUNET_PQ_QueryParam which must terminate with a GNUNET_PQ_query_param_end | ||
126 | */ | ||
127 | void | ||
128 | GNUNET_PQ_cleanup_query_params_closures ( | ||
129 | const struct GNUNET_PQ_QueryParam *params); | ||
93 | 130 | ||
94 | /** | 131 | /** |
95 | * End of query parameter specification. | 132 | * End of query parameter specification. |
@@ -118,7 +155,7 @@ GNUNET_PQ_query_param_null (void); | |||
118 | * @a ptr_size bytes. | 155 | * @a ptr_size bytes. |
119 | * | 156 | * |
120 | * @param ptr pointer to the query parameter to pass | 157 | * @param ptr pointer to the query parameter to pass |
121 | * @oaran ptr_size number of bytes in @a ptr | 158 | * @param ptr_size number of bytes in @a ptr |
122 | * @return query parameter to use | 159 | * @return query parameter to use |
123 | */ | 160 | */ |
124 | struct GNUNET_PQ_QueryParam | 161 | struct GNUNET_PQ_QueryParam |
@@ -145,6 +182,210 @@ GNUNET_PQ_query_param_string (const char *ptr); | |||
145 | struct GNUNET_PQ_QueryParam | 182 | struct GNUNET_PQ_QueryParam |
146 | GNUNET_PQ_query_param_bool (bool b); | 183 | GNUNET_PQ_query_param_bool (bool b); |
147 | 184 | ||
185 | /** | ||
186 | * Returns the oid for a given datatype by name. | ||
187 | * | ||
188 | * @param db The db-connection | ||
189 | * @param name The name of the datatype | ||
190 | * @param[out] oid The OID of the datatype. | ||
191 | * @return GNUNET_OK when the datatype was found, GNUNET_SYSERR otherwise | ||
192 | */ | ||
193 | enum GNUNET_GenericReturnValue | ||
194 | GNUNET_PQ_get_oid_by_name ( | ||
195 | struct GNUNET_PQ_Context *db, | ||
196 | const char *name, | ||
197 | Oid *oid); | ||
198 | |||
199 | |||
200 | /** | ||
201 | * The header for a postgresql array in binary format. note that this a | ||
202 | * simplified special case of the general structure (which contains pointers), | ||
203 | * as we only support one-dimensional arrays. | ||
204 | * | ||
205 | * Note that all values must be in network-byte-order. | ||
206 | */ | ||
207 | struct GNUNET_PQ_ArrayHeader_P | ||
208 | { | ||
209 | uint32_t ndim; /* number of dimensions. we only support ndim = 1 */ | ||
210 | uint32_t has_null; | ||
211 | uint32_t oid; /* oid of the elements */ | ||
212 | uint32_t dim; /* size of the array */ | ||
213 | uint32_t lbound; /* index value of first element in the db (default: 1). */ | ||
214 | } __attribute__((packed)); | ||
215 | |||
216 | |||
217 | /** | ||
218 | * Generate query parameter for an array of bool in host byte order. | ||
219 | * | ||
220 | * @param num Number of elements in @a elements | ||
221 | * @param elements Continuous array of @a num boolean elements | ||
222 | * @param db Database context, needed for database-depending encoding of @a elements | ||
223 | * @return query parameter to use | ||
224 | */ | ||
225 | struct GNUNET_PQ_QueryParam | ||
226 | GNUNET_PQ_query_param_array_bool ( | ||
227 | unsigned int num, | ||
228 | const bool *elements, | ||
229 | struct GNUNET_PQ_Context *db); | ||
230 | |||
231 | /** | ||
232 | * Generate query parameter for an array of uint16_t in host byte order. | ||
233 | * Note that the (unsigend) elements are not checked to wrap over INT2_MAX | ||
234 | * | ||
235 | * @param num Number of elements in @a elements | ||
236 | * @param elements Continuous array of @a num uint16 elements | ||
237 | * @param db Database context, needed for database-depending encoding of @a elements | ||
238 | * @return query parameter to use | ||
239 | */ | ||
240 | struct GNUNET_PQ_QueryParam | ||
241 | GNUNET_PQ_query_param_array_uint16 ( | ||
242 | unsigned int num, | ||
243 | const uint16_t *elements, | ||
244 | struct GNUNET_PQ_Context *db); | ||
245 | |||
246 | /** | ||
247 | * Generate query parameter for an array of uint32_t in host byte order. | ||
248 | * Note that the (unsigend) elements are not checked to wrap over INT4_MAX | ||
249 | * | ||
250 | * @param num Number of elements in @a elements | ||
251 | * @param elements Continuous Array of @a num uint32_t elements | ||
252 | * @param db Database context, needed for database-depending encoding of @a elements | ||
253 | * @return query parameter to use | ||
254 | */ | ||
255 | struct GNUNET_PQ_QueryParam | ||
256 | GNUNET_PQ_query_param_array_uint32 ( | ||
257 | unsigned int num, | ||
258 | const uint32_t *elements, | ||
259 | struct GNUNET_PQ_Context *db); | ||
260 | |||
261 | /** | ||
262 | * Generate query parameter for an array of uint64 in host byte order. | ||
263 | * Note that the (unsigend) elements are not checked to wrap over INT8_MAX | ||
264 | * | ||
265 | * @param num Number of elements in @a elements | ||
266 | * @param elements Continuous array of @a num uint64_t elements | ||
267 | * @param db Database context, needed for database-depending encoding of @a elements | ||
268 | * @return query parameter to use | ||
269 | */ | ||
270 | struct GNUNET_PQ_QueryParam | ||
271 | GNUNET_PQ_query_param_array_uint64 ( | ||
272 | unsigned int num, | ||
273 | const uint64_t *elements, | ||
274 | struct GNUNET_PQ_Context *db); | ||
275 | |||
276 | /** | ||
277 | * Generate query parameter for an array of buffers @a elements, each of | ||
278 | * corresponding size given in @a sizes. | ||
279 | * | ||
280 | * @param num Number of elements in @a elements | ||
281 | * @param elements Continous array of @a num buffers, each of corresponding size given in @a sizes. | ||
282 | * @param sizes Pointer to sizes in bytes of each element in @a elements | ||
283 | * @param db Database context, needed for database-depending encoding of @a elements | ||
284 | * @return query parameter to use | ||
285 | */ | ||
286 | struct GNUNET_PQ_QueryParam | ||
287 | GNUNET_PQ_query_param_array_bytes ( | ||
288 | unsigned int num, | ||
289 | const void *elements, | ||
290 | const size_t *sizes, | ||
291 | struct GNUNET_PQ_Context *db); | ||
292 | |||
293 | /** | ||
294 | * Generate query parameter for an array of buffers @a elements, | ||
295 | * each of the same size @a size. | ||
296 | * | ||
297 | * @param num Number of elements in @a elements | ||
298 | * @param elements Continous array of @a num buffers, each with the same size @a same_size | ||
299 | * @param same_size Size in bytes of each element in @a elements | ||
300 | * @param db Database context, needed for database-depending encoding of @a elements | ||
301 | * @return query parameter to use | ||
302 | */ | ||
303 | struct GNUNET_PQ_QueryParam | ||
304 | GNUNET_PQ_query_param_array_bytes_same_size ( | ||
305 | unsigned int num, | ||
306 | const void *elements, | ||
307 | size_t same_size, | ||
308 | struct GNUNET_PQ_Context *db); | ||
309 | |||
310 | /** | ||
311 | * Generate array of equal-sized query parameter with size determined | ||
312 | * by variable type from a pointer to an continuous array. | ||
313 | * | ||
314 | * @param num Number of elements in @a elements | ||
315 | * @param elements Continuous array of the query parameter to pass. | ||
316 | * @param db Database context, needed for database-depending encoding of @a elements | ||
317 | * @return query parameter to use | ||
318 | */ | ||
319 | #define GNUNET_PQ_query_param_array_auto_from_type(num, elements, db) \ | ||
320 | GNUNET_PQ_query_param_array_bytes_same_size ((num), \ | ||
321 | (elements), \ | ||
322 | sizeof(*(elements)), \ | ||
323 | (db)) | ||
324 | |||
325 | /** | ||
326 | * Generate query parameter for an array of pointers to buffers @a elements, | ||
327 | * each of the same size @a size. | ||
328 | * | ||
329 | * @param num Number of elements in @a elements | ||
330 | * @param elements Array of @a num pointers to buffers, each with the same size @a same_size | ||
331 | * @param same_size Size in bytes of each element in @a elements | ||
332 | * @param db Database context, needed for database-depending encoding of @a elements | ||
333 | * @return query parameter to use | ||
334 | */ | ||
335 | struct GNUNET_PQ_QueryParam | ||
336 | GNUNET_PQ_query_param_array_ptrs_bytes_same_size ( | ||
337 | unsigned int num, | ||
338 | const void *elements[static num], | ||
339 | size_t same_size, | ||
340 | struct GNUNET_PQ_Context *db); | ||
341 | |||
342 | |||
343 | /** | ||
344 | * Generate array of equal-sized query parameter with size determined by | ||
345 | * variable type from a pointer to an array of pointers to objects of the same | ||
346 | * type. | ||
347 | * | ||
348 | * @param num Number of elements in @a elements | ||
349 | * @param elements Continuous array of the query parameter to pass. | ||
350 | * @param db Database context, needed for database-depending encoding of @a elements | ||
351 | * @return query parameter to use | ||
352 | */ | ||
353 | #define GNUNET_PQ_query_param_array_ptrs_auto_from_type(num, elements, db) \ | ||
354 | GNUNET_PQ_query_param_array_ptrs_bytes_same_size ((num), \ | ||
355 | (const void **) (elements), \ | ||
356 | sizeof(*(elements[0])), \ | ||
357 | (db)) | ||
358 | |||
359 | |||
360 | /** | ||
361 | * Generate query parameter for an array of strings (continuous) | ||
362 | * | ||
363 | * @param num Number of elements in @a elements | ||
364 | * @param elements Array of @a num continuous strings (zero-terminated each) | ||
365 | * @param db Database context, needed for database-depending encoding of @a elements | ||
366 | * @return query parameter to use | ||
367 | */ | ||
368 | struct GNUNET_PQ_QueryParam | ||
369 | GNUNET_PQ_query_param_array_string ( | ||
370 | unsigned int num, | ||
371 | const char *elements, | ||
372 | struct GNUNET_PQ_Context *db); | ||
373 | |||
374 | |||
375 | /** | ||
376 | * Generate query parameter for an array of strings (pointers) | ||
377 | * | ||
378 | * @param num Number of elements in @a elements | ||
379 | * @param elements Array of @a num pointer to strings | ||
380 | * @param db Database context, needed for database-depending encoding of @a elements | ||
381 | * @return query parameter to use | ||
382 | */ | ||
383 | struct GNUNET_PQ_QueryParam | ||
384 | GNUNET_PQ_query_param_array_ptrs_string ( | ||
385 | unsigned int num, | ||
386 | const char *elements[static num], | ||
387 | struct GNUNET_PQ_Context *db); | ||
388 | |||
148 | 389 | ||
149 | /** | 390 | /** |
150 | * Generate fixed-size query parameter with size determined | 391 | * Generate fixed-size query parameter with size determined |
@@ -156,6 +397,83 @@ GNUNET_PQ_query_param_bool (bool b); | |||
156 | #define GNUNET_PQ_query_param_auto_from_type(x) \ | 397 | #define GNUNET_PQ_query_param_auto_from_type(x) \ |
157 | GNUNET_PQ_query_param_fixed_size ((x), sizeof(*(x))) | 398 | GNUNET_PQ_query_param_fixed_size ((x), sizeof(*(x))) |
158 | 399 | ||
400 | /** | ||
401 | * Generate query parameter for an array of absolute time stamps (continuous) | ||
402 | * | ||
403 | * @param num Number of elements in @a elements | ||
404 | * @param elements Array of @a num absolute timestamps | ||
405 | * @return query parameter to use | ||
406 | */ | ||
407 | struct GNUNET_PQ_QueryParam | ||
408 | GNUNET_PQ_query_param_array_abs_time ( | ||
409 | unsigned int num, | ||
410 | const struct GNUNET_TIME_Absolute *elements, | ||
411 | struct GNUNET_PQ_Context *db); | ||
412 | |||
413 | /** | ||
414 | * Generate query parameter for an array of absolute time stamps (pointers) | ||
415 | * | ||
416 | * @param num Number of elements in @a elements | ||
417 | * @param elements Array of @a num pointers to absolute timestamps | ||
418 | * @return query parameter to use | ||
419 | */ | ||
420 | struct GNUNET_PQ_QueryParam | ||
421 | GNUNET_PQ_query_param_array_ptrs_abs_time ( | ||
422 | unsigned int num, | ||
423 | const struct GNUNET_TIME_Absolute *elements[], | ||
424 | struct GNUNET_PQ_Context *db); | ||
425 | |||
426 | /** | ||
427 | * Generate query parameter for an array of relative time stamps (continuous) | ||
428 | * | ||
429 | * @param num Number of elements in @a elements | ||
430 | * @param elements Array of @a num relative timestamps | ||
431 | * @return query parameter to use | ||
432 | */ | ||
433 | struct GNUNET_PQ_QueryParam | ||
434 | GNUNET_PQ_query_param_array_rel_time ( | ||
435 | unsigned int num, | ||
436 | const struct GNUNET_TIME_Relative *elements, | ||
437 | struct GNUNET_PQ_Context *db); | ||
438 | |||
439 | /** | ||
440 | * Generate query parameter for an array of relative time stamps (pointers) | ||
441 | * | ||
442 | * @param num Number of elements in @a elements | ||
443 | * @param elements Array of @a num pointers to relative timestamps | ||
444 | * @return query parameter to use | ||
445 | */ | ||
446 | struct GNUNET_PQ_QueryParam | ||
447 | GNUNET_PQ_query_param_array_ptrs_rel_time ( | ||
448 | unsigned int num, | ||
449 | const struct GNUNET_TIME_Relative *elements[], | ||
450 | struct GNUNET_PQ_Context *db); | ||
451 | |||
452 | /** | ||
453 | * Generate query parameter for an array of time stamps (continuous) | ||
454 | * | ||
455 | * @param num Number of elements in @a elements | ||
456 | * @param elements Array of @a num timestamps | ||
457 | * @return query parameter to use | ||
458 | */ | ||
459 | struct GNUNET_PQ_QueryParam | ||
460 | GNUNET_PQ_query_param_array_timestamp ( | ||
461 | unsigned int num, | ||
462 | const struct GNUNET_TIME_Timestamp *elements, | ||
463 | struct GNUNET_PQ_Context *db); | ||
464 | |||
465 | /** | ||
466 | * Generate query parameter for an array of time stamps (pointers) | ||
467 | * | ||
468 | * @param num Number of elements in @a elements | ||
469 | * @param elements Array of @a num pointers to relative timestamps | ||
470 | * @return query parameter to use | ||
471 | */ | ||
472 | struct GNUNET_PQ_QueryParam | ||
473 | GNUNET_PQ_query_param_array_ptrs_timestamp ( | ||
474 | unsigned int num, | ||
475 | const struct GNUNET_TIME_Timestamp *elements[], | ||
476 | struct GNUNET_PQ_Context *db); | ||
159 | 477 | ||
160 | /** | 478 | /** |
161 | * Generate query parameter for an RSA public key. The | 479 | * Generate query parameter for an RSA public key. The |
@@ -235,7 +553,7 @@ GNUNET_PQ_query_param_absolute_time_nbo ( | |||
235 | */ | 553 | */ |
236 | struct GNUNET_PQ_QueryParam | 554 | struct GNUNET_PQ_QueryParam |
237 | GNUNET_PQ_query_param_timestamp_nbo ( | 555 | GNUNET_PQ_query_param_timestamp_nbo ( |
238 | const struct GNUNET_TIME_TimestampNBO *t); | 556 | const struct GNUNET_TIME_TimestampNBO *x); |
239 | 557 | ||
240 | 558 | ||
241 | /** | 559 | /** |
@@ -259,7 +577,7 @@ GNUNET_PQ_query_param_uint32 (const uint32_t *x); | |||
259 | 577 | ||
260 | 578 | ||
261 | /** | 579 | /** |
262 | * Generate query parameter for an uint16_t in host byte order. | 580 | * Generate query parameter for an uint64_t in host byte order. |
263 | * | 581 | * |
264 | * @param x pointer to the query parameter to pass | 582 | * @param x pointer to the query parameter to pass |
265 | * @return query parameter to use | 583 | * @return query parameter to use |
@@ -268,6 +586,37 @@ struct GNUNET_PQ_QueryParam | |||
268 | GNUNET_PQ_query_param_uint64 (const uint64_t *x); | 586 | GNUNET_PQ_query_param_uint64 (const uint64_t *x); |
269 | 587 | ||
270 | 588 | ||
589 | /** | ||
590 | * Generate query parameter for an int64_t in host byte order. | ||
591 | * | ||
592 | * @param x pointer to the query parameter to pass | ||
593 | * @return query parameter to use | ||
594 | */ | ||
595 | struct GNUNET_PQ_QueryParam | ||
596 | GNUNET_PQ_query_param_int64 (const int64_t *x); | ||
597 | |||
598 | /** | ||
599 | * Generate query parameter for a blind sign public key. | ||
600 | * Internally, the various attributes of the public key | ||
601 | * will be serialized into on variable-size BLOB. | ||
602 | * | ||
603 | * @param pub pointer to the query parameter to pass | ||
604 | * | ||
605 | */ | ||
606 | struct GNUNET_PQ_QueryParam | ||
607 | GNUNET_PQ_query_param_blind_sign_pub ( | ||
608 | const struct GNUNET_CRYPTO_BlindSignPublicKey *pub); | ||
609 | |||
610 | /** | ||
611 | * Generate query parameter for a blind sign private key of variable size. | ||
612 | * | ||
613 | * @param priv pointer to the query parameter to pass | ||
614 | * | ||
615 | */ | ||
616 | struct GNUNET_PQ_QueryParam | ||
617 | GNUNET_PQ_query_param_blind_sign_priv ( | ||
618 | const struct GNUNET_CRYPTO_BlindSignPrivateKey *priv); | ||
619 | |||
271 | /* ************************* pq_result_helper.c functions ************************ */ | 620 | /* ************************* pq_result_helper.c functions ************************ */ |
272 | 621 | ||
273 | 622 | ||
@@ -317,8 +666,7 @@ struct GNUNET_PQ_ResultSpec | |||
317 | GNUNET_PQ_ResultConverter conv; | 666 | GNUNET_PQ_ResultConverter conv; |
318 | 667 | ||
319 | /** | 668 | /** |
320 | * Function to clean up result data, NULL if cleanup is | 669 | * Function to clean up result data, NULL if cleanup is not necessary. |
321 | * not necessary. | ||
322 | */ | 670 | */ |
323 | GNUNET_PQ_ResultCleanup cleaner; | 671 | GNUNET_PQ_ResultCleanup cleaner; |
324 | 672 | ||
@@ -333,9 +681,9 @@ struct GNUNET_PQ_ResultSpec | |||
333 | void *dst; | 681 | void *dst; |
334 | 682 | ||
335 | /** | 683 | /** |
336 | * Allowed size for the data, 0 for variable-size | 684 | * Allowed size for the data, 0 for variable-size (in this case, the type of |
337 | * (in this case, the type of @e dst is a `void **` | 685 | * @e dst is a `void **` and we need to allocate a buffer of the right |
338 | * and we need to allocate a buffer of the right size). | 686 | * size). |
339 | */ | 687 | */ |
340 | size_t dst_size; | 688 | size_t dst_size; |
341 | 689 | ||
@@ -355,10 +703,8 @@ struct GNUNET_PQ_ResultSpec | |||
355 | bool is_nullable; | 703 | bool is_nullable; |
356 | 704 | ||
357 | /** | 705 | /** |
358 | * Points to a location where we should store | 706 | * Points to a location where we should store "true" if the result found is |
359 | * "true" if the result found is NULL, and | 707 | * NULL, and otherwise "false". Only used if @e is_nullable is true. |
360 | * otherwise "false". Only used if @e is_nullable | ||
361 | * is true. | ||
362 | */ | 708 | */ |
363 | bool *is_null; | 709 | bool *is_null; |
364 | 710 | ||
@@ -385,8 +731,7 @@ struct GNUNET_PQ_ResultSpec | |||
385 | 731 | ||
386 | 732 | ||
387 | /** | 733 | /** |
388 | * Allow NULL value to be found in the database | 734 | * Allow NULL value to be found in the database for the given value. |
389 | * for the given value. | ||
390 | * | 735 | * |
391 | * @param rs result spec entry to modify | 736 | * @param rs result spec entry to modify |
392 | * @param[out] is_null location set to 'true' if the | 737 | * @param[out] is_null location set to 'true' if the |
@@ -582,13 +927,231 @@ GNUNET_PQ_result_spec_uint64 (const char *name, | |||
582 | uint64_t *u64); | 927 | uint64_t *u64); |
583 | 928 | ||
584 | 929 | ||
585 | /* ************************* pq.c functions ************************ */ | 930 | /** |
931 | * int64_t expected. | ||
932 | * | ||
933 | * @param name name of the field in the table | ||
934 | * @param[out] i64 where to store the result | ||
935 | * @return array entry for the result specification to use | ||
936 | */ | ||
937 | struct GNUNET_PQ_ResultSpec | ||
938 | GNUNET_PQ_result_spec_int64 (const char *name, | ||
939 | int64_t *i64); | ||
940 | |||
586 | 941 | ||
587 | /** | 942 | /** |
588 | * Postgres context. | 943 | * array of bool expected. |
944 | * | ||
945 | * @param db Database context, needed for OID lookup for the correct type | ||
946 | * @param name name of the field in the table | ||
947 | * @param[out] num where to store the number of elements in the array @a bools. | ||
948 | * @param[out] bools pointer to where to store the result, an array of @a num bool's. Allocated by the function, MUST be freed with GNUNET_free. | ||
949 | * @return array entry for the result specification to use | ||
589 | */ | 950 | */ |
590 | struct GNUNET_PQ_Context; | 951 | struct GNUNET_PQ_ResultSpec |
952 | GNUNET_PQ_result_spec_array_bool ( | ||
953 | struct GNUNET_PQ_Context *db, | ||
954 | const char *name, | ||
955 | size_t *num, | ||
956 | bool **bools); | ||
957 | |||
958 | /** | ||
959 | * array of uint16_t expected. | ||
960 | * | ||
961 | * @param db Database context, needed for OID lookup for the correct type | ||
962 | * @param name name of the field in the table | ||
963 | * @param[out] num where to store the number of elements in the array @a u16s. | ||
964 | * @param[out] dst pointer to where to store the an array of @a num uint16_t's. Allocated by the function, MUST be freed with GNUNET_free. | ||
965 | * @return array entry for the result specification to use | ||
966 | */ | ||
967 | struct GNUNET_PQ_ResultSpec | ||
968 | GNUNET_PQ_result_spec_array_uint16 ( | ||
969 | struct GNUNET_PQ_Context *db, | ||
970 | const char *name, | ||
971 | size_t *num, | ||
972 | uint16_t **dst); | ||
973 | |||
974 | /** | ||
975 | * array of uint32_t expected. | ||
976 | * | ||
977 | * @param db Database context, needed for OID lookup for the correct type | ||
978 | * @param name name of the field in the table | ||
979 | * @param[out] num where to store the number of elements in the array @a u32s. | ||
980 | * @param[out] dst pointer to where to store the array of @a num uint32_t's. Allocated by the function, MUST be freed with GNUNET_free. | ||
981 | * @return array entry for the result specification to use | ||
982 | */ | ||
983 | struct GNUNET_PQ_ResultSpec | ||
984 | GNUNET_PQ_result_spec_array_uint32 ( | ||
985 | struct GNUNET_PQ_Context *db, | ||
986 | const char *name, | ||
987 | size_t *num, | ||
988 | uint32_t **dst); | ||
989 | |||
990 | /** | ||
991 | * array of uint64_t expected. | ||
992 | * | ||
993 | * @param db Database context, needed for OID lookup for the correct type | ||
994 | * @param name name of the field in the table | ||
995 | * @param[out] num where to store the number of elements in the array @a u64s. | ||
996 | * @param[out] dst pointer to where to store the array of @a num uint64_t's. Allocated by the function, MUST be freed with GNUNET_free. | ||
997 | * @return array entry for the result specification to use | ||
998 | */ | ||
999 | struct GNUNET_PQ_ResultSpec | ||
1000 | GNUNET_PQ_result_spec_array_uint64 ( | ||
1001 | struct GNUNET_PQ_Context *db, | ||
1002 | const char *name, | ||
1003 | size_t *num, | ||
1004 | uint64_t **dst); | ||
1005 | |||
1006 | |||
1007 | /** | ||
1008 | * array of absolute time expected. | ||
1009 | * | ||
1010 | * @param db Database context, needed for OID lookup for the correct type | ||
1011 | * @param name name of the field in the table | ||
1012 | * @param[out] num where to store the number of elements in the array @a u64s. | ||
1013 | * @param[out] dst pointer to where to store the array of @a num absolute time. Allocated by the function, MUST be freed with GNUNET_free. | ||
1014 | * @return array entry for the result specification to use | ||
1015 | */ | ||
1016 | struct GNUNET_PQ_ResultSpec | ||
1017 | GNUNET_PQ_result_spec_array_abs_time ( | ||
1018 | struct GNUNET_PQ_Context *db, | ||
1019 | const char *name, | ||
1020 | size_t *num, | ||
1021 | struct GNUNET_TIME_Absolute **dst); | ||
1022 | |||
1023 | /** | ||
1024 | * array of relative time expected. | ||
1025 | * | ||
1026 | * @param db Database context, needed for OID lookup for the correct type | ||
1027 | * @param name name of the field in the table | ||
1028 | * @param[out] num where to store the number of elements in the array @a u64s. | ||
1029 | * @param[out] dst pointer to where to store the array of @a num relate time. Allocated by the function, MUST be freed with GNUNET_free. | ||
1030 | * @return array entry for the result specification to use | ||
1031 | */ | ||
1032 | struct GNUNET_PQ_ResultSpec | ||
1033 | GNUNET_PQ_result_spec_array_rel_time ( | ||
1034 | struct GNUNET_PQ_Context *db, | ||
1035 | const char *name, | ||
1036 | size_t *num, | ||
1037 | struct GNUNET_TIME_Relative **dst); | ||
1038 | |||
1039 | /** | ||
1040 | * array of relative time expected. | ||
1041 | * | ||
1042 | * @param db Database context, needed for OID lookup for the correct type | ||
1043 | * @param name name of the field in the table | ||
1044 | * @param[out] num where to store the number of elements in the array @a u64s. | ||
1045 | * @param[out] dst pointer to where to store the array of @a num timestamps. Allocated by the function, MUST be freed with GNUNET_free. | ||
1046 | * @return array entry for the result specification to use | ||
1047 | */ | ||
1048 | |||
1049 | struct GNUNET_PQ_ResultSpec | ||
1050 | GNUNET_PQ_result_spec_array_timestamp ( | ||
1051 | struct GNUNET_PQ_Context *db, | ||
1052 | const char *name, | ||
1053 | size_t *num, | ||
1054 | struct GNUNET_TIME_Timestamp **dst); | ||
1055 | |||
1056 | /** | ||
1057 | * Array of variable-size result expected. | ||
1058 | * | ||
1059 | * @param db Database context, needed for OID lookup for the correct type | ||
1060 | * @param name name of the field in the table | ||
1061 | * @param[out] num where to store the number of elements | ||
1062 | * @param[out] sizes where to store the @a num size's of byte-buffers in @a dst | ||
1063 | * @param[out] dst where to store the continuous array of @a num byte-buffers , allocated | ||
1064 | * @return array entry for the result specification to use | ||
1065 | */ | ||
1066 | struct GNUNET_PQ_ResultSpec | ||
1067 | GNUNET_PQ_result_spec_array_variable_size ( | ||
1068 | struct GNUNET_PQ_Context *db, | ||
1069 | const char *name, | ||
1070 | size_t *num, | ||
1071 | size_t **sizes, | ||
1072 | void **dst); | ||
1073 | |||
1074 | |||
1075 | /** | ||
1076 | * Array of fixed-size result expected. | ||
1077 | * | ||
1078 | * @param db Database context, needed for OID lookup for the correct type | ||
1079 | * @param name name of the field in the table | ||
1080 | * @param size number of bytes expected in each element of @a dst | ||
1081 | * @param[out] num where to store the number of elements | ||
1082 | * @param[out] dst where to store the results, an continuous array of fixed-size elements | ||
1083 | * @return array entry for the result specification to use | ||
1084 | */ | ||
1085 | struct GNUNET_PQ_ResultSpec | ||
1086 | GNUNET_PQ_result_spec_array_fixed_size ( | ||
1087 | struct GNUNET_PQ_Context *db, | ||
1088 | const char *name, | ||
1089 | size_t size, | ||
1090 | size_t *num, | ||
1091 | void **dst); | ||
1092 | |||
1093 | |||
1094 | /** | ||
1095 | * We expect a fixed-size result, with size determined by the type of `* dst` | ||
1096 | * | ||
1097 | * @param db Database context, needed for OID lookup for the correct type | ||
1098 | * @param name name of the field in the table | ||
1099 | * @param num pointer to where to store the number of elements | ||
1100 | * @param dst pointer to where to store the results, type fits expected result size | ||
1101 | * @return array entry for the result specification to use | ||
1102 | */ | ||
1103 | #define GNUNET_PQ_result_spec_auto_array_from_type(db, name, num, dst) \ | ||
1104 | GNUNET_PQ_result_spec_array_fixed_size ( \ | ||
1105 | (db), \ | ||
1106 | (name), \ | ||
1107 | sizeof(*(dst)), \ | ||
1108 | (num), \ | ||
1109 | (void *) &(dst)) | ||
1110 | |||
1111 | |||
1112 | /** | ||
1113 | * Array of 0-terminated strings expected. | ||
1114 | * | ||
1115 | * @param db Database context, needed for OID lookup for the correct type | ||
1116 | * @param name name of the field in the table | ||
1117 | * @param[out] num where to store the number of elements | ||
1118 | * @param[out] dst where to store the allocated continous array of @a num 0-terminated strings | ||
1119 | * @return array entry for the result specification to use | ||
1120 | */ | ||
1121 | struct GNUNET_PQ_ResultSpec | ||
1122 | GNUNET_PQ_result_spec_array_string ( | ||
1123 | struct GNUNET_PQ_Context *db, | ||
1124 | const char *name, | ||
1125 | size_t *num, | ||
1126 | char **dst); | ||
1127 | |||
1128 | |||
1129 | /** | ||
1130 | * Blind sign public key expected. | ||
1131 | * | ||
1132 | * @param name name of the field in the table | ||
1133 | * @param[out] public_key where to store the denomination signature | ||
1134 | * @return array entry for the result specification to use | ||
1135 | */ | ||
1136 | struct GNUNET_PQ_ResultSpec | ||
1137 | GNUNET_PQ_result_spec_blind_sign_pub ( | ||
1138 | const char *name, | ||
1139 | struct GNUNET_CRYPTO_BlindSignPublicKey **public_key); | ||
1140 | |||
1141 | |||
1142 | /** | ||
1143 | * Blind sign private key expected. | ||
1144 | * | ||
1145 | * @param name name of the field in the table | ||
1146 | * @param[out] private_key where to store the denomination signature | ||
1147 | * @return array entry for the result specification to use | ||
1148 | */ | ||
1149 | struct GNUNET_PQ_ResultSpec | ||
1150 | GNUNET_PQ_result_spec_blind_sign_priv ( | ||
1151 | const char *name, | ||
1152 | struct GNUNET_CRYPTO_BlindSignPrivateKey **private_key); | ||
591 | 1153 | ||
1154 | /* ************************* pq.c functions ************************ */ | ||
592 | 1155 | ||
593 | /** | 1156 | /** |
594 | * Execute a prepared statement. | 1157 | * Execute a prepared statement. |
@@ -754,11 +1317,6 @@ struct GNUNET_PQ_PreparedStatement | |||
754 | */ | 1317 | */ |
755 | const char *sql; | 1318 | const char *sql; |
756 | 1319 | ||
757 | /** | ||
758 | * Number of arguments included in @e sql. | ||
759 | */ | ||
760 | unsigned int num_arguments; | ||
761 | |||
762 | }; | 1320 | }; |
763 | 1321 | ||
764 | 1322 | ||
@@ -767,7 +1325,7 @@ struct GNUNET_PQ_PreparedStatement | |||
767 | */ | 1325 | */ |
768 | #define GNUNET_PQ_PREPARED_STATEMENT_END \ | 1326 | #define GNUNET_PQ_PREPARED_STATEMENT_END \ |
769 | { \ | 1327 | { \ |
770 | NULL, NULL, 0 \ | 1328 | NULL, NULL \ |
771 | } | 1329 | } |
772 | 1330 | ||
773 | 1331 | ||
@@ -776,13 +1334,11 @@ struct GNUNET_PQ_PreparedStatement | |||
776 | * | 1334 | * |
777 | * @param name name of the statement | 1335 | * @param name name of the statement |
778 | * @param sql actual SQL statement | 1336 | * @param sql actual SQL statement |
779 | * @param num_args number of arguments in the statement | ||
780 | * @return initialized struct | 1337 | * @return initialized struct |
781 | */ | 1338 | */ |
782 | struct GNUNET_PQ_PreparedStatement | 1339 | struct GNUNET_PQ_PreparedStatement |
783 | GNUNET_PQ_make_prepare (const char *name, | 1340 | GNUNET_PQ_make_prepare (const char *name, |
784 | const char *sql, | 1341 | const char *sql); |
785 | unsigned int num_args); | ||
786 | 1342 | ||
787 | 1343 | ||
788 | /** | 1344 | /** |
@@ -799,6 +1355,22 @@ GNUNET_PQ_prepare_statements (struct GNUNET_PQ_Context *db, | |||
799 | const struct GNUNET_PQ_PreparedStatement *ps); | 1355 | const struct GNUNET_PQ_PreparedStatement *ps); |
800 | 1356 | ||
801 | 1357 | ||
1358 | /** | ||
1359 | * Request creation of prepared statements @a ps from Postgres, but do not | ||
1360 | * automatically re-prepare the statement if we are disconnected from the | ||
1361 | * database. | ||
1362 | * | ||
1363 | * @param db database to prepare the statements for | ||
1364 | * @param ps #GNUNET_PQ_PREPARED_STATEMENT_END-terminated array of prepared | ||
1365 | * statements. | ||
1366 | * @return #GNUNET_OK on success, | ||
1367 | * #GNUNET_SYSERR on error | ||
1368 | */ | ||
1369 | enum GNUNET_GenericReturnValue | ||
1370 | GNUNET_PQ_prepare_once (struct GNUNET_PQ_Context *db, | ||
1371 | const struct GNUNET_PQ_PreparedStatement *ps); | ||
1372 | |||
1373 | |||
802 | /* ******************** pq_exec.c functions ************** */ | 1374 | /* ******************** pq_exec.c functions ************** */ |
803 | 1375 | ||
804 | 1376 | ||
@@ -853,7 +1425,7 @@ GNUNET_PQ_make_try_execute (const char *sql); | |||
853 | /** | 1425 | /** |
854 | * Request execution of an array of statements @a es from Postgres. | 1426 | * Request execution of an array of statements @a es from Postgres. |
855 | * | 1427 | * |
856 | * @param pq database to execute the statements in | 1428 | * @param db database to execute the statements in |
857 | * @param es #GNUNET_PQ_PREPARED_STATEMENT_END-terminated array of prepared | 1429 | * @param es #GNUNET_PQ_PREPARED_STATEMENT_END-terminated array of prepared |
858 | * statements. | 1430 | * statements. |
859 | * @return #GNUNET_OK on success (modulo statements where errors can be ignored) | 1431 | * @return #GNUNET_OK on success (modulo statements where errors can be ignored) |
@@ -895,14 +1467,14 @@ enum GNUNET_PQ_Options | |||
895 | * configuration. Initialize logging via GNUnet's log routines and disable | 1467 | * configuration. Initialize logging via GNUnet's log routines and disable |
896 | * Postgres's logger. Also ensures that the statements in @a load_path and @a | 1468 | * Postgres's logger. Also ensures that the statements in @a load_path and @a |
897 | * es are executed whenever we (re)connect to the database, and that the | 1469 | * es are executed whenever we (re)connect to the database, and that the |
898 | * prepared statements in @a ps are "ready". If statements in @es fail that | 1470 | * prepared statements in @a ps are "ready". If statements in @a es fail that |
899 | * were created with #GNUNET_PQ_make_execute(), then the entire operation | 1471 | * were created with #GNUNET_PQ_make_execute(), then the entire operation |
900 | * fails. | 1472 | * fails. |
901 | * | 1473 | * |
902 | * In @a load_path, a list of "$XXXX.sql" files is expected where $XXXX | 1474 | * In @a load_path, a list of "$XXXX.sql" files is expected where $XXXX |
903 | * must be a sequence of contiguous integer values starting at 0000. | 1475 | * must be a sequence of contiguous integer values starting at 0000. |
904 | * These files are then loaded in sequence using "psql $config_str" before | 1476 | * These files are then loaded in sequence using "psql $config_str" before |
905 | * running statements from @e es. The directory is inspected again on | 1477 | * running statements from @a es. The directory is inspected again on |
906 | * reconnect. | 1478 | * reconnect. |
907 | * | 1479 | * |
908 | * @param config_str configuration to use | 1480 | * @param config_str configuration to use |
@@ -939,7 +1511,7 @@ GNUNET_PQ_exec_sql (struct GNUNET_PQ_Context *db, | |||
939 | * configuration. Initialize logging via GNUnet's log routines and disable | 1511 | * configuration. Initialize logging via GNUnet's log routines and disable |
940 | * Postgres's logger. Also ensures that the statements in @a load_path and @a | 1512 | * Postgres's logger. Also ensures that the statements in @a load_path and @a |
941 | * es are executed whenever we (re)connect to the database, and that the | 1513 | * es are executed whenever we (re)connect to the database, and that the |
942 | * prepared statements in @a ps are "ready". If statements in @es fail that | 1514 | * prepared statements in @a ps are "ready". If statements in @a es fail that |
943 | * were created with #GNUNET_PQ_make_execute(), then the entire operation | 1515 | * were created with #GNUNET_PQ_make_execute(), then the entire operation |
944 | * fails. | 1516 | * fails. |
945 | * | 1517 | * |
@@ -968,10 +1540,10 @@ GNUNET_PQ_connect2 (const char *config_str, | |||
968 | 1540 | ||
969 | 1541 | ||
970 | /** | 1542 | /** |
971 | * Connect to a postgres database using the configuration | 1543 | * Connect to a postgres database using the configuration option "CONFIG" in |
972 | * option "CONFIG" in @a section. Also ensures that the | 1544 | * @a section. Also ensures that the statements in @a es are executed |
973 | * statements in @a es are executed whenever we (re)connect to the | 1545 | * whenever we (re)connect to the database, and that the prepared statements |
974 | * database, and that the prepared statements in @a ps are "ready". | 1546 | * in @a ps are "ready". |
975 | * | 1547 | * |
976 | * The caller does not have to ensure that @a es and @a ps remain allocated | 1548 | * The caller does not have to ensure that @a es and @a ps remain allocated |
977 | * and initialized in memory until #GNUNET_PQ_disconnect() is called, as a copy will be made. | 1549 | * and initialized in memory until #GNUNET_PQ_disconnect() is called, as a copy will be made. |
@@ -999,7 +1571,8 @@ GNUNET_PQ_connect_with_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
999 | * database, and that the prepared statements in @a ps are "ready". | 1571 | * database, and that the prepared statements in @a ps are "ready". |
1000 | * | 1572 | * |
1001 | * The caller does not have to ensure that @a es and @a ps remain allocated | 1573 | * The caller does not have to ensure that @a es and @a ps remain allocated |
1002 | * and initialized in memory until #GNUNET_PQ_disconnect() is called, as a copy will be made. | 1574 | * and initialized in memory until #GNUNET_PQ_disconnect() is called, as a |
1575 | * copy will be made. | ||
1003 | * | 1576 | * |
1004 | * @param cfg configuration | 1577 | * @param cfg configuration |
1005 | * @param section configuration section to use to get Postgres configuration options | 1578 | * @param section configuration section to use to get Postgres configuration options |
@@ -1078,12 +1651,24 @@ GNUNET_PQ_event_listen_cancel (struct GNUNET_DB_EventHandler *eh); | |||
1078 | 1651 | ||
1079 | 1652 | ||
1080 | /** | 1653 | /** |
1654 | * Poll for events right now. Useful if we may have | ||
1655 | * triggered an event for ourselves. Not needed when | ||
1656 | * using GNUNET_PQ_event_notify(), but useful when | ||
1657 | * stored procedures may have triggered events. | ||
1658 | * Does nothing if there are no events. | ||
1659 | * | ||
1660 | * @param[in,out] db database to check for events | ||
1661 | */ | ||
1662 | void | ||
1663 | GNUNET_PQ_event_do_poll (struct GNUNET_PQ_Context *db); | ||
1664 | |||
1665 | |||
1666 | /** | ||
1081 | * Notify all that listen on @a es of an event. | 1667 | * Notify all that listen on @a es of an event. |
1082 | * | 1668 | * |
1083 | * Unlike many other calls, this function is thread-safe | 1669 | * Unlike many other calls, this function is thread-safe and may be called |
1084 | * and may be called from threads that are different | 1670 | * from threads that are different from the one that setup @a db. However, the |
1085 | * from the one that setup @a db. However, the @a cb | 1671 | * @a cb will always be called from the thread that runs |
1086 | * will always be called from the thread that runs | ||
1087 | * #GNUNET_PQ_event_do_poll() or the GNUnet scheduler. | 1672 | * #GNUNET_PQ_event_do_poll() or the GNUnet scheduler. |
1088 | * | 1673 | * |
1089 | * @param db database context to use | 1674 | * @param db database context to use |
@@ -1099,6 +1684,17 @@ GNUNET_PQ_event_notify (struct GNUNET_PQ_Context *db, | |||
1099 | 1684 | ||
1100 | 1685 | ||
1101 | /** | 1686 | /** |
1687 | * Compute the channel that one should notify upon for the given event | ||
1688 | * specification. | ||
1689 | * | ||
1690 | * @param es event specification | ||
1691 | * @return channel to notify upon | ||
1692 | */ | ||
1693 | char * | ||
1694 | GNUNET_PQ_get_event_notify_channel (const struct GNUNET_DB_EventHeaderP *es); | ||
1695 | |||
1696 | |||
1697 | /** | ||
1102 | * Within the @a db context, run all the SQL files | 1698 | * Within the @a db context, run all the SQL files |
1103 | * from the @a load_path from 0000-9999.sql (as long | 1699 | * from the @a load_path from 0000-9999.sql (as long |
1104 | * as the files exist contiguously). | 1700 | * as the files exist contiguously). |
diff --git a/src/include/gnunet_program_lib.h b/src/include/gnunet_program_lib.h index 4167060c0..f06d95422 100644 --- a/src/include/gnunet_program_lib.h +++ b/src/include/gnunet_program_lib.h | |||
@@ -18,7 +18,15 @@ | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #if ! defined (__GNUNET_UTIL_LIB_H_INSIDE__) | ||
22 | #error "Only <gnunet_util_lib.h> can be included directly." | ||
23 | #endif | ||
24 | |||
21 | /** | 25 | /** |
26 | * @addtogroup libgnunetutil | ||
27 | * Multi-function utilities library for GNUnet programs | ||
28 | * @{ | ||
29 | * | ||
22 | * @author Christian Grothoff | 30 | * @author Christian Grothoff |
23 | * | 31 | * |
24 | * @file | 32 | * @file |
@@ -40,6 +48,7 @@ extern "C" | |||
40 | #endif | 48 | #endif |
41 | #endif | 49 | #endif |
42 | 50 | ||
51 | |||
43 | #include "gnunet_configuration_lib.h" | 52 | #include "gnunet_configuration_lib.h" |
44 | #include "gnunet_getopt_lib.h" | 53 | #include "gnunet_getopt_lib.h" |
45 | #include "gnunet_scheduler_lib.h" | 54 | #include "gnunet_scheduler_lib.h" |
@@ -113,6 +122,45 @@ GNUNET_PROGRAM_run (int argc, | |||
113 | GNUNET_PROGRAM_Main task, | 122 | GNUNET_PROGRAM_Main task, |
114 | void *task_cls); | 123 | void *task_cls); |
115 | 124 | ||
125 | enum GNUNET_GenericReturnValue | ||
126 | GNUNET_DAEMON_register (const char *daemon_name, | ||
127 | const char *daemon_desc, | ||
128 | GNUNET_PROGRAM_Main task); | ||
129 | |||
130 | #ifndef HAVE_GNUNET_MONOLITH | ||
131 | #define GNUNET_DAEMON_MAIN(daemon_name, daemon_help, init_cb) \ | ||
132 | int \ | ||
133 | main (int argc, \ | ||
134 | char *const *argv) \ | ||
135 | { \ | ||
136 | int ret; \ | ||
137 | struct GNUNET_GETOPT_CommandLineOption options[] = { \ | ||
138 | GNUNET_GETOPT_OPTION_END \ | ||
139 | }; \ | ||
140 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, \ | ||
141 | &argv)) \ | ||
142 | return 2; \ | ||
143 | ret = GNUNET_PROGRAM_run (argc, \ | ||
144 | argv, \ | ||
145 | daemon_name, \ | ||
146 | daemon_help, \ | ||
147 | options, \ | ||
148 | init_cb, \ | ||
149 | NULL); \ | ||
150 | GNUNET_free_nz ((void*) argv); \ | ||
151 | return ret; \ | ||
152 | } | ||
153 | #else | ||
154 | #define GNUNET_DAEMON_MAIN(daemon_name, daemon_help, init_cb) \ | ||
155 | static int __attribute__ ((constructor)) \ | ||
156 | init (void) \ | ||
157 | { \ | ||
158 | return GNUNET_DAEMON_register (daemon_name, \ | ||
159 | daemon_help, \ | ||
160 | init_cb); \ | ||
161 | } | ||
162 | #endif | ||
163 | |||
116 | 164 | ||
117 | #if 0 /* keep Emacsens' auto-indent happy */ | 165 | #if 0 /* keep Emacsens' auto-indent happy */ |
118 | { | 166 | { |
@@ -126,4 +174,6 @@ GNUNET_PROGRAM_run (int argc, | |||
126 | 174 | ||
127 | /** @} */ /* end of group program */ | 175 | /** @} */ /* end of group program */ |
128 | 176 | ||
177 | /** @} */ /* end of group addition */ | ||
178 | |||
129 | /* end of gnunet_program_lib.h */ | 179 | /* end of gnunet_program_lib.h */ |
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index f2892e125..6ab008d16 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2001--2020 GNUnet e.V. | 3 | Copyright (C) 2001--2024 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -19,6 +19,10 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup libgnunetutil | ||
23 | * Multi-function utilities library for GNUnet programs | ||
24 | * @{ | ||
25 | * | ||
22 | * @author Christian Grothoff | 26 | * @author Christian Grothoff |
23 | * @author Tobias Frisch | 27 | * @author Tobias Frisch |
24 | * | 28 | * |
@@ -1323,7 +1327,7 @@ extern "C" { | |||
1323 | /** | 1327 | /** |
1324 | * Service to client: result of store operation. | 1328 | * Service to client: result of store operation. |
1325 | */ | 1329 | */ |
1326 | #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE 436 | 1330 | #define GNUNET_MESSAGE_TYPE_NAMESTORE_GENERIC_RESPONSE 436 |
1327 | 1331 | ||
1328 | /** | 1332 | /** |
1329 | * Client to service: lookup label | 1333 | * Client to service: lookup label |
@@ -2348,7 +2352,7 @@ extern "C" { | |||
2348 | /** M<->S<->C: PSYC message which contains a header and one or more message | 2352 | /** M<->S<->C: PSYC message which contains a header and one or more message |
2349 | * parts. */ | 2353 | * parts. */ |
2350 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_HEADER \ | 2354 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_HEADER \ |
2351 | 692 // FIXME: start using this where appropriate | 2355 | 692 // FIXME: start using this where appropriate |
2352 | 2356 | ||
2353 | /** Message part: method */ | 2357 | /** Message part: method */ |
2354 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD 693 | 2358 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD 693 |
@@ -2595,14 +2599,14 @@ extern "C" { | |||
2595 | #define GNUNET_MESSAGE_TYPE_PEERSTORE_STORE 820 | 2599 | #define GNUNET_MESSAGE_TYPE_PEERSTORE_STORE 820 |
2596 | 2600 | ||
2597 | /** | 2601 | /** |
2598 | * Iteration request | 2602 | * Iteration request (see also 828, 829) |
2599 | */ | 2603 | */ |
2600 | #define GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE 821 | 2604 | #define GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_START 821 |
2601 | 2605 | ||
2602 | /** | 2606 | /** |
2603 | * Iteration record message | 2607 | * Record result message |
2604 | */ | 2608 | */ |
2605 | #define GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_RECORD 822 | 2609 | #define GNUNET_MESSAGE_TYPE_PEERSTORE_RECORD 822 |
2606 | 2610 | ||
2607 | /** | 2611 | /** |
2608 | * Iteration end message | 2612 | * Iteration end message |
@@ -2610,19 +2614,34 @@ extern "C" { | |||
2610 | #define GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_END 823 | 2614 | #define GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_END 823 |
2611 | 2615 | ||
2612 | /** | 2616 | /** |
2613 | * Watch request | 2617 | * Monitor request |
2618 | */ | ||
2619 | #define GNUNET_MESSAGE_TYPE_PEERSTORE_MONITOR_START 824 | ||
2620 | |||
2621 | /** | ||
2622 | * Monitor sync | ||
2623 | */ | ||
2624 | #define GNUNET_MESSAGE_TYPE_PEERSTORE_MONITOR_SYNC 825 | ||
2625 | |||
2626 | /** | ||
2627 | * Monitor next request | ||
2628 | */ | ||
2629 | #define GNUNET_MESSAGE_TYPE_PEERSTORE_MONITOR_NEXT 826 | ||
2630 | |||
2631 | /** | ||
2632 | * Store result message | ||
2614 | */ | 2633 | */ |
2615 | #define GNUNET_MESSAGE_TYPE_PEERSTORE_WATCH 824 | 2634 | #define GNUNET_MESSAGE_TYPE_PEERSTORE_STORE_RESULT 827 |
2616 | 2635 | ||
2617 | /** | 2636 | /** |
2618 | * Watch response | 2637 | * Iteration request (see also 821, 829) |
2619 | */ | 2638 | */ |
2620 | #define GNUNET_MESSAGE_TYPE_PEERSTORE_WATCH_RECORD 825 | 2639 | #define GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_NEXT 828 |
2621 | 2640 | ||
2622 | /** | 2641 | /** |
2623 | * Watch cancel request | 2642 | * Iteration request (see also 821, 828) |
2624 | */ | 2643 | */ |
2625 | #define GNUNET_MESSAGE_TYPE_PEERSTORE_WATCH_CANCEL 826 | 2644 | #define GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_STOP 829 |
2626 | 2645 | ||
2627 | /******************************************************************************* | 2646 | /******************************************************************************* |
2628 | * SOCIAL message types | 2647 | * SOCIAL message types |
@@ -3197,6 +3216,11 @@ extern "C" { | |||
3197 | #define GNUNET_MESSAGE_TYPE_NAT_ADDRESS_CHANGE 1064 | 3216 | #define GNUNET_MESSAGE_TYPE_NAT_ADDRESS_CHANGE 1064 |
3198 | 3217 | ||
3199 | /** | 3218 | /** |
3219 | * Message to ask NAT service to notify all clients about a new global address. | ||
3220 | */ | ||
3221 | #define GNUNET_MESSAGE_TYPE_NAT_ADD_GLOBAL_ADDRESS 1065 | ||
3222 | |||
3223 | /** | ||
3200 | * Message to ask NAT service to request autoconfiguration. | 3224 | * Message to ask NAT service to request autoconfiguration. |
3201 | */ | 3225 | */ |
3202 | #define GNUNET_MESSAGE_TYPE_NAT_AUTO_REQUEST_CFG 1067 | 3226 | #define GNUNET_MESSAGE_TYPE_NAT_AUTO_REQUEST_CFG 1067 |
@@ -3526,6 +3550,11 @@ extern "C" { | |||
3526 | #define GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_PAD 1461 | 3550 | #define GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_PAD 1461 |
3527 | 3551 | ||
3528 | /** | 3552 | /** |
3553 | * UDP Rekey. | ||
3554 | */ | ||
3555 | #define GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_REKEY 1462 | ||
3556 | |||
3557 | /** | ||
3529 | * Next available: 1500 | 3558 | * Next available: 1500 |
3530 | */ | 3559 | */ |
3531 | #define GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_DELETE 1500 | 3560 | #define GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_DELETE 1500 |
@@ -3545,17 +3574,9 @@ extern "C" { | |||
3545 | 3574 | ||
3546 | #define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_CREATE 1600 | 3575 | #define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_CREATE 1600 |
3547 | 3576 | ||
3548 | #define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_UPDATE 1601 | 3577 | #define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_DESTROY 1601 |
3549 | |||
3550 | #define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_DESTROY 1602 | ||
3551 | |||
3552 | #define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_GET_NAME 1603 | ||
3553 | |||
3554 | #define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_SET_NAME 1604 | ||
3555 | |||
3556 | #define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_GET_KEY 1605 | ||
3557 | 3578 | ||
3558 | #define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_MEMBER_ID 1606 | 3579 | #define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_MEMBER_ID 1602 |
3559 | 3580 | ||
3560 | /************************************ Room *************************************/ | 3581 | /************************************ Room *************************************/ |
3561 | 3582 | ||
@@ -3571,6 +3592,10 @@ extern "C" { | |||
3571 | 3592 | ||
3572 | #define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_GET_MESSAGE 1616 | 3593 | #define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_GET_MESSAGE 1616 |
3573 | 3594 | ||
3595 | #define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_SYNC 1617 | ||
3596 | |||
3597 | #define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_LINK 1618 | ||
3598 | |||
3574 | /*********************************************************************************/ | 3599 | /*********************************************************************************/ |
3575 | 3600 | ||
3576 | /*********************************************************************************/ | 3601 | /*********************************************************************************/ |
@@ -3597,7 +3622,36 @@ extern "C" { | |||
3597 | 3622 | ||
3598 | #define GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED 1706 | 3623 | #define GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED 1706 |
3599 | 3624 | ||
3625 | #define GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_REACHED 1707 | ||
3626 | |||
3627 | #define GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ATTACH 1708 | ||
3628 | |||
3629 | #define GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_CROSSABLE 1709 | ||
3630 | |||
3631 | #define GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ATTACHED 1710 | ||
3632 | |||
3633 | /*********************************************************************************/ | ||
3634 | |||
3600 | /*********************************************************************************/ | 3635 | /*********************************************************************************/ |
3636 | /********************************** NAMESTORE (cont.) **************************/ | ||
3637 | /*********************************************************************************/ | ||
3638 | /* NAMESTORE: message types 1750-1800 | ||
3639 | */ | ||
3640 | |||
3641 | /** | ||
3642 | * Message type for start of record edit with advisory lock | ||
3643 | */ | ||
3644 | #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT 1750 | ||
3645 | |||
3646 | /** | ||
3647 | * Return record set to edit with previous editor hint/advisory lock | ||
3648 | */ | ||
3649 | #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT_RESPONSE 1751 | ||
3650 | |||
3651 | /** | ||
3652 | * Message type for cancellation/reset of editor hint/advisory lock | ||
3653 | */ | ||
3654 | #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT_CANCEL 1752 | ||
3601 | 3655 | ||
3602 | /** | 3656 | /** |
3603 | * Type used to match 'all' message types. | 3657 | * Type used to match 'all' message types. |
@@ -3617,4 +3671,6 @@ extern "C" { | |||
3617 | 3671 | ||
3618 | /** @} */ /* end of group protocols */ | 3672 | /** @} */ /* end of group protocols */ |
3619 | 3673 | ||
3674 | /** @} */ /* end of group addition */ | ||
3675 | |||
3620 | /* end of gnunet_protocols.h */ | 3676 | /* end of gnunet_protocols.h */ |
diff --git a/src/include/gnunet_reclaim_lib.h b/src/include/gnunet_reclaim_lib.h index bbf1c3ad3..e4dec14fa 100644 --- a/src/include/gnunet_reclaim_lib.h +++ b/src/include/gnunet_reclaim_lib.h | |||
@@ -19,12 +19,15 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup reclaim_suite RECLAIM services and libraries | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Martin Schanzenbach | 25 | * @author Martin Schanzenbach |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
25 | * Identity attribute definitions | 28 | * Identity attribute definitions |
26 | * | 29 | * |
27 | * @defgroup reclaim-attribute reclaim attributes | 30 | * @defgroup reclaim-attribute Reclaim attributes |
28 | * @{ | 31 | * @{ |
29 | */ | 32 | */ |
30 | #ifndef GNUNET_RECLAIM_ATTRIBUTE_LIB_H | 33 | #ifndef GNUNET_RECLAIM_ATTRIBUTE_LIB_H |
@@ -37,6 +40,7 @@ extern "C" { | |||
37 | #endif | 40 | #endif |
38 | #endif | 41 | #endif |
39 | 42 | ||
43 | |||
40 | #include "gnunet_util_lib.h" | 44 | #include "gnunet_util_lib.h" |
41 | 45 | ||
42 | enum GNUNET_RECLAIM_AttributeType { | 46 | enum GNUNET_RECLAIM_AttributeType { |
@@ -512,7 +516,7 @@ GNUNET_RECLAIM_attribute_number_to_typename (uint32_t type); | |||
512 | /** | 516 | /** |
513 | * Get required size for serialization buffer | 517 | * Get required size for serialization buffer |
514 | * | 518 | * |
515 | * @param attrs the attribute list to serialize | 519 | * @param credentials the attribute list to serialize |
516 | * @return the required buffer size | 520 | * @return the required buffer size |
517 | */ | 521 | */ |
518 | size_t | 522 | size_t |
@@ -521,9 +525,9 @@ GNUNET_RECLAIM_credential_list_serialize_get_size ( | |||
521 | 525 | ||
522 | 526 | ||
523 | /** | 527 | /** |
524 | * Destroy claim list | 528 | * Destroy credential list |
525 | * | 529 | * |
526 | * @param attrs list to destroy | 530 | * @param credentials list to destroy |
527 | */ | 531 | */ |
528 | void | 532 | void |
529 | GNUNET_RECLAIM_credential_list_destroy ( | 533 | GNUNET_RECLAIM_credential_list_destroy ( |
@@ -548,15 +552,15 @@ GNUNET_RECLAIM_credential_list_add ( | |||
548 | 552 | ||
549 | 553 | ||
550 | /** | 554 | /** |
551 | * Serialize an attribute list | 555 | * Serialize a credential list |
552 | * | 556 | * |
553 | * @param attrs the attribute list to serialize | 557 | * @param credentials the credential list to serialize |
554 | * @param result the serialized attribute | 558 | * @param result the serialized credential |
555 | * @return length of serialized data | 559 | * @return length of serialized data |
556 | */ | 560 | */ |
557 | size_t | 561 | size_t |
558 | GNUNET_RECLAIM_credential_list_serialize ( | 562 | GNUNET_RECLAIM_credential_list_serialize ( |
559 | const struct GNUNET_RECLAIM_CredentialList *attrs, | 563 | const struct GNUNET_RECLAIM_CredentialList *credentials, |
560 | char *result); | 564 | char *result); |
561 | 565 | ||
562 | 566 | ||
@@ -858,4 +862,6 @@ GNUNET_RECLAIM_credential_get_presentation ( | |||
858 | 862 | ||
859 | /** @} */ /* end of group reclaim-attribute */ | 863 | /** @} */ /* end of group reclaim-attribute */ |
860 | 864 | ||
865 | /** @} */ /* end of group addition */ | ||
866 | |||
861 | /* end of gnunet_reclaim_attribute_lib.h */ | 867 | /* end of gnunet_reclaim_attribute_lib.h */ |
diff --git a/src/include/gnunet_reclaim_plugin.h b/src/include/gnunet_reclaim_plugin.h index 11d5d76f7..f8b2084d2 100644 --- a/src/include/gnunet_reclaim_plugin.h +++ b/src/include/gnunet_reclaim_plugin.h | |||
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup reclaim_suite RECLAIM services and libraries | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Martin Schanzenbach | 25 | * @author Martin Schanzenbach |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
@@ -30,6 +33,7 @@ | |||
30 | #ifndef GNUNET_RECLAIM_PLUGIN_H | 33 | #ifndef GNUNET_RECLAIM_PLUGIN_H |
31 | #define GNUNET_RECLAIM_PLUGIN_H | 34 | #define GNUNET_RECLAIM_PLUGIN_H |
32 | 35 | ||
36 | |||
33 | #include "gnunet_util_lib.h" | 37 | #include "gnunet_util_lib.h" |
34 | #include "gnunet_reclaim_lib.h" | 38 | #include "gnunet_reclaim_lib.h" |
35 | 39 | ||
@@ -439,3 +443,5 @@ struct GNUNET_RECLAIM_CredentialPluginFunctions | |||
439 | #endif | 443 | #endif |
440 | 444 | ||
441 | /** @} */ /* end of group */ | 445 | /** @} */ /* end of group */ |
446 | |||
447 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_reclaim_service.h b/src/include/gnunet_reclaim_service.h index 38e1c8735..08f3f60a3 100644 --- a/src/include/gnunet_reclaim_service.h +++ b/src/include/gnunet_reclaim_service.h | |||
@@ -19,13 +19,16 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup reclaim_suite RECLAIM services and libraries | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Martin Schanzenbach | 25 | * @author Martin Schanzenbach |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
25 | * reclaim service; implements identity and personal data sharing | 28 | * reclaim service; implements identity and personal data sharing |
26 | * for GNUnet | 29 | * for GNUnet |
27 | * | 30 | * |
28 | * @defgroup reclaim service | 31 | * @defgroup reclaim Reclaim service |
29 | * @{ | 32 | * @{ |
30 | */ | 33 | */ |
31 | #ifndef GNUNET_RECLAIM_SERVICE_H | 34 | #ifndef GNUNET_RECLAIM_SERVICE_H |
@@ -38,6 +41,7 @@ extern "C" { | |||
38 | #endif | 41 | #endif |
39 | #endif | 42 | #endif |
40 | 43 | ||
44 | |||
41 | #include "gnunet_identity_service.h" | 45 | #include "gnunet_identity_service.h" |
42 | #include "gnunet_reclaim_lib.h" | 46 | #include "gnunet_reclaim_lib.h" |
43 | #include "gnunet_util_lib.h" | 47 | #include "gnunet_util_lib.h" |
@@ -45,7 +49,7 @@ extern "C" { | |||
45 | /** | 49 | /** |
46 | * Version number of the re:claimID API. | 50 | * Version number of the re:claimID API. |
47 | */ | 51 | */ |
48 | #define GNUNET_RECLAIM_VERSION 0x00000001 | 52 | #define GNUNET_RECLAIM_VERSION 0x00000002 |
49 | 53 | ||
50 | /** | 54 | /** |
51 | * Opaque handle to access the service. | 55 | * Opaque handle to access the service. |
@@ -58,6 +62,9 @@ struct GNUNET_RECLAIM_Handle; | |||
58 | */ | 62 | */ |
59 | struct GNUNET_RECLAIM_Operation; | 63 | struct GNUNET_RECLAIM_Operation; |
60 | 64 | ||
65 | #define GNUNET_RECLAIM_TICKET_RP_URI_MAX_LEN 256 | ||
66 | |||
67 | #define GNUNET_RECLAIM_TICKET_RP_URI_URN_PREFIX "urn:gns:" | ||
61 | 68 | ||
62 | /** | 69 | /** |
63 | * The authorization ticket. This ticket is meant to be transferred | 70 | * The authorization ticket. This ticket is meant to be transferred |
@@ -70,17 +77,20 @@ struct GNUNET_RECLAIM_Ticket | |||
70 | /** | 77 | /** |
71 | * The ticket issuer (= the user) | 78 | * The ticket issuer (= the user) |
72 | */ | 79 | */ |
73 | struct GNUNET_IDENTITY_PublicKey identity; | 80 | struct GNUNET_CRYPTO_PublicKey identity; |
74 | 81 | ||
75 | /** | 82 | /** |
76 | * The ticket audience (= relying party) | 83 | * The ticket random identifier |
77 | */ | 84 | */ |
78 | struct GNUNET_IDENTITY_PublicKey audience; | 85 | struct GNUNET_RECLAIM_Identifier rnd; |
86 | |||
79 | 87 | ||
80 | /** | 88 | /** |
81 | * The ticket random identifier | 89 | * Followed by the ticket audience (= relying party) URI. |
90 | * 0-terminated string. | ||
91 | * Example: "urn:gns:000G002B4RF1XPBXDPGZA0PT16BHQCS427YQK4NC84KZMK7TK8C2Z5GMK8" | ||
82 | */ | 92 | */ |
83 | struct GNUNET_RECLAIM_Identifier rnd; | 93 | char rp_uri[GNUNET_RECLAIM_TICKET_RP_URI_MAX_LEN]; |
84 | }; | 94 | }; |
85 | 95 | ||
86 | 96 | ||
@@ -130,7 +140,7 @@ typedef void (*GNUNET_RECLAIM_ContinuationWithStatus) (void *cls, | |||
130 | * @param attr The attribute | 140 | * @param attr The attribute |
131 | */ | 141 | */ |
132 | typedef void (*GNUNET_RECLAIM_AttributeResult) ( | 142 | typedef void (*GNUNET_RECLAIM_AttributeResult) ( |
133 | void *cls, const struct GNUNET_IDENTITY_PublicKey *identity, | 143 | void *cls, const struct GNUNET_CRYPTO_PublicKey *identity, |
134 | const struct GNUNET_RECLAIM_Attribute *attr); | 144 | const struct GNUNET_RECLAIM_Attribute *attr); |
135 | 145 | ||
136 | /** | 146 | /** |
@@ -142,7 +152,7 @@ typedef void (*GNUNET_RECLAIM_AttributeResult) ( | |||
142 | * @param presentation The presentation for the credential (may be NULL) | 152 | * @param presentation The presentation for the credential (may be NULL) |
143 | */ | 153 | */ |
144 | typedef void (*GNUNET_RECLAIM_AttributeTicketResult) ( | 154 | typedef void (*GNUNET_RECLAIM_AttributeTicketResult) ( |
145 | void *cls, const struct GNUNET_IDENTITY_PublicKey *identity, | 155 | void *cls, const struct GNUNET_CRYPTO_PublicKey *identity, |
146 | const struct GNUNET_RECLAIM_Attribute *attr, | 156 | const struct GNUNET_RECLAIM_Attribute *attr, |
147 | const struct GNUNET_RECLAIM_Presentation *presentation); | 157 | const struct GNUNET_RECLAIM_Presentation *presentation); |
148 | 158 | ||
@@ -156,7 +166,7 @@ typedef void (*GNUNET_RECLAIM_AttributeTicketResult) ( | |||
156 | * @param attributes the parsed attributes | 166 | * @param attributes the parsed attributes |
157 | */ | 167 | */ |
158 | typedef void (*GNUNET_RECLAIM_CredentialResult) ( | 168 | typedef void (*GNUNET_RECLAIM_CredentialResult) ( |
159 | void *cls, const struct GNUNET_IDENTITY_PublicKey *identity, | 169 | void *cls, const struct GNUNET_CRYPTO_PublicKey *identity, |
160 | const struct GNUNET_RECLAIM_Credential *credential); | 170 | const struct GNUNET_RECLAIM_Credential *credential); |
161 | 171 | ||
162 | 172 | ||
@@ -185,7 +195,7 @@ GNUNET_RECLAIM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg); | |||
185 | struct GNUNET_RECLAIM_Operation * | 195 | struct GNUNET_RECLAIM_Operation * |
186 | GNUNET_RECLAIM_attribute_store ( | 196 | GNUNET_RECLAIM_attribute_store ( |
187 | struct GNUNET_RECLAIM_Handle *h, | 197 | struct GNUNET_RECLAIM_Handle *h, |
188 | const struct GNUNET_IDENTITY_PrivateKey *pkey, | 198 | const struct GNUNET_CRYPTO_PrivateKey *pkey, |
189 | const struct GNUNET_RECLAIM_Attribute *attr, | 199 | const struct GNUNET_RECLAIM_Attribute *attr, |
190 | const struct GNUNET_TIME_Relative *exp_interval, | 200 | const struct GNUNET_TIME_Relative *exp_interval, |
191 | GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls); | 201 | GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls); |
@@ -197,7 +207,7 @@ GNUNET_RECLAIM_attribute_store ( | |||
197 | * | 207 | * |
198 | * @param h handle to the re:claimID service | 208 | * @param h handle to the re:claimID service |
199 | * @param pkey private key of the identity | 209 | * @param pkey private key of the identity |
200 | * @param attr the credential value | 210 | * @param credential the credential value |
201 | * @param exp_interval the relative expiration interval for the credential | 211 | * @param exp_interval the relative expiration interval for the credential |
202 | * @param cont continuation to call when done | 212 | * @param cont continuation to call when done |
203 | * @param cont_cls closure for @a cont | 213 | * @param cont_cls closure for @a cont |
@@ -206,7 +216,7 @@ GNUNET_RECLAIM_attribute_store ( | |||
206 | struct GNUNET_RECLAIM_Operation * | 216 | struct GNUNET_RECLAIM_Operation * |
207 | GNUNET_RECLAIM_credential_store ( | 217 | GNUNET_RECLAIM_credential_store ( |
208 | struct GNUNET_RECLAIM_Handle *h, | 218 | struct GNUNET_RECLAIM_Handle *h, |
209 | const struct GNUNET_IDENTITY_PrivateKey *pkey, | 219 | const struct GNUNET_CRYPTO_PrivateKey *pkey, |
210 | const struct GNUNET_RECLAIM_Credential *credential, | 220 | const struct GNUNET_RECLAIM_Credential *credential, |
211 | const struct GNUNET_TIME_Relative *exp_interval, | 221 | const struct GNUNET_TIME_Relative *exp_interval, |
212 | GNUNET_RECLAIM_ContinuationWithStatus cont, | 222 | GNUNET_RECLAIM_ContinuationWithStatus cont, |
@@ -227,12 +237,12 @@ GNUNET_RECLAIM_credential_store ( | |||
227 | struct GNUNET_RECLAIM_Operation * | 237 | struct GNUNET_RECLAIM_Operation * |
228 | GNUNET_RECLAIM_attribute_delete ( | 238 | GNUNET_RECLAIM_attribute_delete ( |
229 | struct GNUNET_RECLAIM_Handle *h, | 239 | struct GNUNET_RECLAIM_Handle *h, |
230 | const struct GNUNET_IDENTITY_PrivateKey *pkey, | 240 | const struct GNUNET_CRYPTO_PrivateKey *pkey, |
231 | const struct GNUNET_RECLAIM_Attribute *attr, | 241 | const struct GNUNET_RECLAIM_Attribute *attr, |
232 | GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls); | 242 | GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls); |
233 | 243 | ||
234 | /** | 244 | /** |
235 | * Delete a credential. Tickets used to share use a presentation of this | 245 | * Delete a credential. Tickets used to share a presentation of this |
236 | * credential are updated accordingly. | 246 | * credential are updated accordingly. |
237 | * | 247 | * |
238 | * @param h handle to the re:claimID service | 248 | * @param h handle to the re:claimID service |
@@ -245,7 +255,7 @@ GNUNET_RECLAIM_attribute_delete ( | |||
245 | struct GNUNET_RECLAIM_Operation * | 255 | struct GNUNET_RECLAIM_Operation * |
246 | GNUNET_RECLAIM_credential_delete ( | 256 | GNUNET_RECLAIM_credential_delete ( |
247 | struct GNUNET_RECLAIM_Handle *h, | 257 | struct GNUNET_RECLAIM_Handle *h, |
248 | const struct GNUNET_IDENTITY_PrivateKey *pkey, | 258 | const struct GNUNET_CRYPTO_PrivateKey *pkey, |
249 | const struct GNUNET_RECLAIM_Credential *cred, | 259 | const struct GNUNET_RECLAIM_Credential *cred, |
250 | GNUNET_RECLAIM_ContinuationWithStatus cont, | 260 | GNUNET_RECLAIM_ContinuationWithStatus cont, |
251 | void *cont_cls); | 261 | void *cont_cls); |
@@ -277,7 +287,7 @@ GNUNET_RECLAIM_credential_delete ( | |||
277 | struct GNUNET_RECLAIM_AttributeIterator * | 287 | struct GNUNET_RECLAIM_AttributeIterator * |
278 | GNUNET_RECLAIM_get_attributes_start ( | 288 | GNUNET_RECLAIM_get_attributes_start ( |
279 | struct GNUNET_RECLAIM_Handle *h, | 289 | struct GNUNET_RECLAIM_Handle *h, |
280 | const struct GNUNET_IDENTITY_PrivateKey *identity, | 290 | const struct GNUNET_CRYPTO_PrivateKey *identity, |
281 | GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, | 291 | GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, |
282 | GNUNET_RECLAIM_AttributeResult proc, void *proc_cls, | 292 | GNUNET_RECLAIM_AttributeResult proc, void *proc_cls, |
283 | GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls); | 293 | GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls); |
@@ -333,7 +343,7 @@ GNUNET_RECLAIM_get_attributes_stop ( | |||
333 | struct GNUNET_RECLAIM_CredentialIterator * | 343 | struct GNUNET_RECLAIM_CredentialIterator * |
334 | GNUNET_RECLAIM_get_credentials_start ( | 344 | GNUNET_RECLAIM_get_credentials_start ( |
335 | struct GNUNET_RECLAIM_Handle *h, | 345 | struct GNUNET_RECLAIM_Handle *h, |
336 | const struct GNUNET_IDENTITY_PrivateKey *identity, | 346 | const struct GNUNET_CRYPTO_PrivateKey *identity, |
337 | GNUNET_SCHEDULER_TaskCallback error_cb, | 347 | GNUNET_SCHEDULER_TaskCallback error_cb, |
338 | void *error_cb_cls, | 348 | void *error_cb_cls, |
339 | GNUNET_RECLAIM_CredentialResult proc, | 349 | GNUNET_RECLAIM_CredentialResult proc, |
@@ -346,7 +356,7 @@ GNUNET_RECLAIM_get_credentials_start ( | |||
346 | * Calls the record processor specified in #GNUNET_RECLAIM_get_credentials_start | 356 | * Calls the record processor specified in #GNUNET_RECLAIM_get_credentials_start |
347 | * for the next record. | 357 | * for the next record. |
348 | * | 358 | * |
349 | * @param it the iterator | 359 | * @param ait the iterator |
350 | */ | 360 | */ |
351 | void | 361 | void |
352 | GNUNET_RECLAIM_get_credentials_next ( | 362 | GNUNET_RECLAIM_get_credentials_next ( |
@@ -358,7 +368,7 @@ GNUNET_RECLAIM_get_credentials_next ( | |||
358 | * be called on any iteration that has not yet completed prior to calling | 368 | * be called on any iteration that has not yet completed prior to calling |
359 | * #GNUNET_RECLAIM_disconnect. | 369 | * #GNUNET_RECLAIM_disconnect. |
360 | * | 370 | * |
361 | * @param it the iterator | 371 | * @param ait the iterator |
362 | */ | 372 | */ |
363 | void | 373 | void |
364 | GNUNET_RECLAIM_get_credentials_stop ( | 374 | GNUNET_RECLAIM_get_credentials_stop ( |
@@ -372,7 +382,7 @@ GNUNET_RECLAIM_get_credentials_stop ( | |||
372 | * | 382 | * |
373 | * @param h the identity provider to use | 383 | * @param h the identity provider to use |
374 | * @param iss the issuing identity (= the user) | 384 | * @param iss the issuing identity (= the user) |
375 | * @param rp the subject of the ticket (= the relying party) | 385 | * @param rp the subject of the ticket (= the relying party) see #GNUNET_RECLAIM_Ticket |
376 | * @param attrs the attributes that the relying party is given access to | 386 | * @param attrs the attributes that the relying party is given access to |
377 | * @param cb the callback | 387 | * @param cb the callback |
378 | * @param cb_cls the callback closure | 388 | * @param cb_cls the callback closure |
@@ -381,8 +391,8 @@ GNUNET_RECLAIM_get_credentials_stop ( | |||
381 | struct GNUNET_RECLAIM_Operation * | 391 | struct GNUNET_RECLAIM_Operation * |
382 | GNUNET_RECLAIM_ticket_issue ( | 392 | GNUNET_RECLAIM_ticket_issue ( |
383 | struct GNUNET_RECLAIM_Handle *h, | 393 | struct GNUNET_RECLAIM_Handle *h, |
384 | const struct GNUNET_IDENTITY_PrivateKey *iss, | 394 | const struct GNUNET_CRYPTO_PrivateKey *iss, |
385 | const struct GNUNET_IDENTITY_PublicKey *rp, | 395 | const char *rp, |
386 | const struct GNUNET_RECLAIM_AttributeList *attrs, | 396 | const struct GNUNET_RECLAIM_AttributeList *attrs, |
387 | GNUNET_RECLAIM_IssueTicketCallback cb, void *cb_cls); | 397 | GNUNET_RECLAIM_IssueTicketCallback cb, void *cb_cls); |
388 | 398 | ||
@@ -403,7 +413,7 @@ GNUNET_RECLAIM_ticket_issue ( | |||
403 | struct GNUNET_RECLAIM_Operation * | 413 | struct GNUNET_RECLAIM_Operation * |
404 | GNUNET_RECLAIM_ticket_revoke ( | 414 | GNUNET_RECLAIM_ticket_revoke ( |
405 | struct GNUNET_RECLAIM_Handle *h, | 415 | struct GNUNET_RECLAIM_Handle *h, |
406 | const struct GNUNET_IDENTITY_PrivateKey *identity, | 416 | const struct GNUNET_CRYPTO_PrivateKey *identity, |
407 | const struct GNUNET_RECLAIM_Ticket *ticket, | 417 | const struct GNUNET_RECLAIM_Ticket *ticket, |
408 | GNUNET_RECLAIM_ContinuationWithStatus cb, void *cb_cls); | 418 | GNUNET_RECLAIM_ContinuationWithStatus cb, void *cb_cls); |
409 | 419 | ||
@@ -413,8 +423,6 @@ GNUNET_RECLAIM_ticket_revoke ( | |||
413 | * information from the issuer | 423 | * information from the issuer |
414 | * | 424 | * |
415 | * @param h the identity provider to use | 425 | * @param h the identity provider to use |
416 | * @param identity the identity that is the subject of the issued ticket (the | ||
417 | * relying party) | ||
418 | * @param ticket the issued ticket to consume | 426 | * @param ticket the issued ticket to consume |
419 | * @param cb the callback to call | 427 | * @param cb the callback to call |
420 | * @param cb_cls the callback closure | 428 | * @param cb_cls the callback closure |
@@ -423,7 +431,6 @@ GNUNET_RECLAIM_ticket_revoke ( | |||
423 | struct GNUNET_RECLAIM_Operation * | 431 | struct GNUNET_RECLAIM_Operation * |
424 | GNUNET_RECLAIM_ticket_consume ( | 432 | GNUNET_RECLAIM_ticket_consume ( |
425 | struct GNUNET_RECLAIM_Handle *h, | 433 | struct GNUNET_RECLAIM_Handle *h, |
426 | const struct GNUNET_IDENTITY_PrivateKey *identity, | ||
427 | const struct GNUNET_RECLAIM_Ticket *ticket, | 434 | const struct GNUNET_RECLAIM_Ticket *ticket, |
428 | GNUNET_RECLAIM_AttributeTicketResult cb, void *cb_cls); | 435 | GNUNET_RECLAIM_AttributeTicketResult cb, void *cb_cls); |
429 | 436 | ||
@@ -448,7 +455,7 @@ GNUNET_RECLAIM_ticket_consume ( | |||
448 | struct GNUNET_RECLAIM_TicketIterator * | 455 | struct GNUNET_RECLAIM_TicketIterator * |
449 | GNUNET_RECLAIM_ticket_iteration_start ( | 456 | GNUNET_RECLAIM_ticket_iteration_start ( |
450 | struct GNUNET_RECLAIM_Handle *h, | 457 | struct GNUNET_RECLAIM_Handle *h, |
451 | const struct GNUNET_IDENTITY_PrivateKey *identity, | 458 | const struct GNUNET_CRYPTO_PrivateKey *identity, |
452 | GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, | 459 | GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, |
453 | GNUNET_RECLAIM_TicketCallback proc, void *proc_cls, | 460 | GNUNET_RECLAIM_TicketCallback proc, void *proc_cls, |
454 | GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls); | 461 | GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls); |
@@ -495,6 +502,43 @@ GNUNET_RECLAIM_disconnect (struct GNUNET_RECLAIM_Handle *h); | |||
495 | void | 502 | void |
496 | GNUNET_RECLAIM_cancel (struct GNUNET_RECLAIM_Operation *op); | 503 | GNUNET_RECLAIM_cancel (struct GNUNET_RECLAIM_Operation *op); |
497 | 504 | ||
505 | /** | ||
506 | * Get serialized ticket size | ||
507 | * | ||
508 | * @param tkt the ticket | ||
509 | * @return the buffer length requirement for a serialization | ||
510 | */ | ||
511 | size_t | ||
512 | GNUNET_RECLAIM_ticket_serialize_get_size (const struct GNUNET_RECLAIM_Ticket *tkt); | ||
513 | |||
514 | /** | ||
515 | * Deserializes a ticket | ||
516 | * | ||
517 | * @param buffer the buffer to read from | ||
518 | * @param len the length of the buffer | ||
519 | * @param tkt the ticket to write to (must be allocated) | ||
520 | * @param kb_read how many bytes were read from buffer | ||
521 | * @return GNUNET_SYSERR on error | ||
522 | */ | ||
523 | enum GNUNET_GenericReturnValue | ||
524 | GNUNET_RECLAIM_read_ticket_from_buffer (const void *buffer, | ||
525 | size_t len, | ||
526 | struct GNUNET_RECLAIM_Ticket *tkt, | ||
527 | size_t *tb_read); | ||
528 | |||
529 | /** | ||
530 | * Serializes a ticket | ||
531 | * | ||
532 | * @param tkt the ticket to serialize | ||
533 | * @param buffer the buffer to serialize to (must be allocated with sufficient size | ||
534 | * @param len the length of the buffer | ||
535 | * @return the number of written bytes or < 0 on error | ||
536 | */ | ||
537 | ssize_t | ||
538 | GNUNET_RECLAIM_write_ticket_to_buffer (const struct | ||
539 | GNUNET_RECLAIM_Ticket *tkt, | ||
540 | void *buffer, | ||
541 | size_t len); | ||
498 | 542 | ||
499 | #if 0 /* keep Emacsens' auto-indent happy */ | 543 | #if 0 /* keep Emacsens' auto-indent happy */ |
500 | { | 544 | { |
@@ -509,4 +553,6 @@ GNUNET_RECLAIM_cancel (struct GNUNET_RECLAIM_Operation *op); | |||
509 | 553 | ||
510 | /** @} */ /* end of group reclaim */ | 554 | /** @} */ /* end of group reclaim */ |
511 | 555 | ||
556 | /** @} */ /* end of group addition */ | ||
557 | |||
512 | /* end of gnunet_reclaim_service.h */ | 558 | /* end of gnunet_reclaim_service.h */ |
diff --git a/src/include/gnunet_regex_service.h b/src/include/gnunet_regex_service.h index a875eab90..093bf2d6a 100644 --- a/src/include/gnunet_regex_service.h +++ b/src/include/gnunet_regex_service.h | |||
@@ -18,6 +18,9 @@ | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @addtogroup Backbone | ||
22 | * @{ | ||
23 | * | ||
21 | * @author Maximilian Szengel | 24 | * @author Maximilian Szengel |
22 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
23 | * | 26 | * |
@@ -36,6 +39,7 @@ | |||
36 | #ifndef GNUNET_REGEX_SERVICE_H | 39 | #ifndef GNUNET_REGEX_SERVICE_H |
37 | #define GNUNET_REGEX_SERVICE_H | 40 | #define GNUNET_REGEX_SERVICE_H |
38 | 41 | ||
42 | |||
39 | #include "gnunet_util_lib.h" | 43 | #include "gnunet_util_lib.h" |
40 | 44 | ||
41 | #ifdef __cplusplus | 45 | #ifdef __cplusplus |
@@ -149,3 +153,5 @@ GNUNET_REGEX_search_cancel (struct GNUNET_REGEX_Search *s); | |||
149 | #endif | 153 | #endif |
150 | 154 | ||
151 | /** @} */ /* end of group */ | 155 | /** @} */ /* end of group */ |
156 | |||
157 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_resolver_service.h b/src/include/gnunet_resolver_service.h index 956e4d67e..89fec24f5 100644 --- a/src/include/gnunet_resolver_service.h +++ b/src/include/gnunet_resolver_service.h | |||
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup vpn_suite | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
@@ -40,6 +43,7 @@ extern "C" | |||
40 | #endif | 43 | #endif |
41 | #endif | 44 | #endif |
42 | 45 | ||
46 | |||
43 | #include "gnunet_configuration_lib.h" | 47 | #include "gnunet_configuration_lib.h" |
44 | #include "gnunet_scheduler_lib.h" | 48 | #include "gnunet_scheduler_lib.h" |
45 | #include "gnunet_time_lib.h" | 49 | #include "gnunet_time_lib.h" |
@@ -178,4 +182,6 @@ GNUNET_RESOLVER_request_cancel (struct GNUNET_RESOLVER_RequestHandle *rh); | |||
178 | 182 | ||
179 | /** @} */ /* end of group resolver */ | 183 | /** @} */ /* end of group resolver */ |
180 | 184 | ||
185 | /** @} */ /* end of group addition to vpn_suite */ | ||
186 | |||
181 | /* end of gnunet_resolver_service.h */ | 187 | /* end of gnunet_resolver_service.h */ |
diff --git a/src/include/gnunet_rest_lib.h b/src/include/gnunet_rest_lib.h index 7e74bee76..f70500de5 100644 --- a/src/include/gnunet_rest_lib.h +++ b/src/include/gnunet_rest_lib.h | |||
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup rest_l2 REST service and libraries | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Martin Schanzenbach | 25 | * @author Martin Schanzenbach |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
@@ -31,6 +34,7 @@ | |||
31 | #ifndef GNUNET_REST_LIB_H | 34 | #ifndef GNUNET_REST_LIB_H |
32 | #define GNUNET_REST_LIB_H | 35 | #define GNUNET_REST_LIB_H |
33 | 36 | ||
37 | |||
34 | #include "gnunet_util_lib.h" | 38 | #include "gnunet_util_lib.h" |
35 | #include <microhttpd.h> | 39 | #include <microhttpd.h> |
36 | 40 | ||
@@ -137,3 +141,5 @@ GNUNET_REST_handle_request (struct GNUNET_REST_RequestHandle *conn, | |||
137 | #endif | 141 | #endif |
138 | 142 | ||
139 | /** @} */ /* end of group */ | 143 | /** @} */ /* end of group */ |
144 | |||
145 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_rest_plugin.h b/src/include/gnunet_rest_plugin.h index 96454f66b..3a8af5389 100644 --- a/src/include/gnunet_rest_plugin.h +++ b/src/include/gnunet_rest_plugin.h | |||
@@ -18,6 +18,9 @@ | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @addtogroup rest_l2 REST service and libraries | ||
22 | * @{ | ||
23 | * | ||
21 | * @author Martin Schanzenbach | 24 | * @author Martin Schanzenbach |
22 | * | 25 | * |
23 | * @file | 26 | * @file |
@@ -29,6 +32,7 @@ | |||
29 | #ifndef GNUNET_REST_PLUGIN_H | 32 | #ifndef GNUNET_REST_PLUGIN_H |
30 | #define GNUNET_REST_PLUGIN_H | 33 | #define GNUNET_REST_PLUGIN_H |
31 | 34 | ||
35 | |||
32 | #include "gnunet_util_lib.h" | 36 | #include "gnunet_util_lib.h" |
33 | #include "gnunet_rest_lib.h" | 37 | #include "gnunet_rest_lib.h" |
34 | #include "microhttpd.h" | 38 | #include "microhttpd.h" |
@@ -59,24 +63,13 @@ struct GNUNET_REST_Plugin | |||
59 | * e.g. http://hostname:port/name | 63 | * e.g. http://hostname:port/name |
60 | */ | 64 | */ |
61 | char *name; | 65 | char *name; |
62 | |||
63 | /** | ||
64 | * Function to process a REST call | ||
65 | * | ||
66 | * @param method the HTTP method called | ||
67 | * @param url the relative url accessed | ||
68 | * @param data the REST data (can be NULL) | ||
69 | * @param data_size the length of the data | ||
70 | * @param proc the callback for result | ||
71 | * @param proc_cls closure for callback | ||
72 | * @return GNUNET_YES if the request was processed | ||
73 | */ | ||
74 | enum GNUNET_GenericReturnValue (*process_request)( | ||
75 | struct GNUNET_REST_RequestHandle *handle, | ||
76 | GNUNET_REST_ResultProcessor proc, | ||
77 | void *proc_cls); | ||
78 | }; | 66 | }; |
79 | 67 | ||
68 | typedef enum GNUNET_GenericReturnValue (*GNUNET_REST_ProcessingFunction)( | ||
69 | void *plugin, | ||
70 | struct GNUNET_REST_RequestHandle *handle, | ||
71 | GNUNET_REST_ResultProcessor proc, | ||
72 | void *proc_cls); | ||
80 | 73 | ||
81 | #if 0 /* keep Emacsens' auto-indent happy */ | 74 | #if 0 /* keep Emacsens' auto-indent happy */ |
82 | { | 75 | { |
@@ -88,3 +81,5 @@ struct GNUNET_REST_Plugin | |||
88 | #endif | 81 | #endif |
89 | 82 | ||
90 | /** @} */ /* end of group */ | 83 | /** @} */ /* end of group */ |
84 | |||
85 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_revocation_service.h b/src/include/gnunet_revocation_service.h index 8cff948e2..427be62ac 100644 --- a/src/include/gnunet_revocation_service.h +++ b/src/include/gnunet_revocation_service.h | |||
@@ -21,9 +21,14 @@ | |||
21 | #ifndef GNUNET_REVOCATION_SERVICE_H_ | 21 | #ifndef GNUNET_REVOCATION_SERVICE_H_ |
22 | #define GNUNET_REVOCATION_SERVICE_H_ | 22 | #define GNUNET_REVOCATION_SERVICE_H_ |
23 | 23 | ||
24 | |||
25 | #include "gnunet_gnsrecord_lib.h" | ||
24 | #include "gnunet_identity_service.h" | 26 | #include "gnunet_identity_service.h" |
25 | 27 | ||
26 | /** | 28 | /** |
29 | * @addtogroup egos Ego management | ||
30 | * @{ | ||
31 | * | ||
27 | * @author Christian Grothoff | 32 | * @author Christian Grothoff |
28 | * | 33 | * |
29 | * @file | 34 | * @file |
@@ -52,71 +57,6 @@ extern "C" | |||
52 | */ | 57 | */ |
53 | #define GNUNET_REVOCATION_VERSION 0x00000001 | 58 | #define GNUNET_REVOCATION_VERSION 0x00000001 |
54 | 59 | ||
55 | /** | ||
56 | * Maximum length of a revocation | ||
57 | */ | ||
58 | #define GNUNET_REVOCATION_MAX_PROOF_SIZE sizeof(struct GNUNET_REVOCATION_PowP) +\ | ||
59 | sizeof(struct GNUNET_IDENTITY_PublicKey) +\ | ||
60 | 1024 //FIXME max sig_len | ||
61 | |||
62 | /** | ||
63 | * The proof-of-work narrowing factor. | ||
64 | * The number of PoWs that are calculates as part of revocation. | ||
65 | */ | ||
66 | #define POW_COUNT 32 | ||
67 | |||
68 | |||
69 | GNUNET_NETWORK_STRUCT_BEGIN | ||
70 | |||
71 | /** | ||
72 | * Struct for a proof of work as part of the revocation. | ||
73 | */ | ||
74 | struct GNUNET_REVOCATION_PowP | ||
75 | { | ||
76 | /** | ||
77 | * The timestamp of the revocation | ||
78 | */ | ||
79 | struct GNUNET_TIME_AbsoluteNBO timestamp; | ||
80 | |||
81 | /** | ||
82 | * The TTL of this revocation (purely informational) | ||
83 | */ | ||
84 | struct GNUNET_TIME_RelativeNBO ttl; | ||
85 | |||
86 | /** | ||
87 | * The PoWs | ||
88 | */ | ||
89 | uint64_t pow[POW_COUNT] GNUNET_PACKED; | ||
90 | |||
91 | /** followed by the public key type, the key and a signature **/ | ||
92 | }; | ||
93 | |||
94 | |||
95 | /** | ||
96 | * The signature object we use for the PoW | ||
97 | */ | ||
98 | struct GNUNET_REVOCATION_SignaturePurposePS | ||
99 | { | ||
100 | /** | ||
101 | * The signature purpose | ||
102 | */ | ||
103 | struct GNUNET_CRYPTO_EccSignaturePurpose purpose; | ||
104 | |||
105 | /** | ||
106 | * The timestamp of the revocation | ||
107 | */ | ||
108 | struct GNUNET_TIME_AbsoluteNBO timestamp; | ||
109 | |||
110 | /** Followed by the zone public key type and key **/ | ||
111 | }; | ||
112 | |||
113 | GNUNET_NETWORK_STRUCT_END | ||
114 | |||
115 | |||
116 | /** | ||
117 | * Handle to a running proof-of-work calculation. | ||
118 | */ | ||
119 | struct GNUNET_REVOCATION_PowCalculationHandle; | ||
120 | 60 | ||
121 | /** | 61 | /** |
122 | * Handle for the key revocation query. | 62 | * Handle for the key revocation query. |
@@ -148,7 +88,7 @@ typedef void (*GNUNET_REVOCATION_Callback) (void *cls, | |||
148 | */ | 88 | */ |
149 | struct GNUNET_REVOCATION_Query * | 89 | struct GNUNET_REVOCATION_Query * |
150 | GNUNET_REVOCATION_query (const struct GNUNET_CONFIGURATION_Handle *cfg, | 90 | GNUNET_REVOCATION_query (const struct GNUNET_CONFIGURATION_Handle *cfg, |
151 | const struct GNUNET_IDENTITY_PublicKey *key, | 91 | const struct GNUNET_CRYPTO_PublicKey *key, |
152 | GNUNET_REVOCATION_Callback func, void *func_cls); | 92 | GNUNET_REVOCATION_Callback func, void *func_cls); |
153 | 93 | ||
154 | 94 | ||
@@ -172,7 +112,7 @@ struct GNUNET_REVOCATION_Handle; | |||
172 | * | 112 | * |
173 | * @param cfg the configuration to use | 113 | * @param cfg the configuration to use |
174 | * @param pow proof of work to use (should have been created by | 114 | * @param pow proof of work to use (should have been created by |
175 | * iteratively calling #GNUNET_REVOCATION_pow_round) | 115 | * iteratively calling #GNUNET_CRYPTO_pow_round) |
176 | * @param func function to call with the result of the check | 116 | * @param func function to call with the result of the check |
177 | * (called with `is_valid` being #GNUNET_NO if | 117 | * (called with `is_valid` being #GNUNET_NO if |
178 | * the revocation worked). | 118 | * the revocation worked). |
@@ -181,7 +121,7 @@ struct GNUNET_REVOCATION_Handle; | |||
181 | */ | 121 | */ |
182 | struct GNUNET_REVOCATION_Handle * | 122 | struct GNUNET_REVOCATION_Handle * |
183 | GNUNET_REVOCATION_revoke (const struct GNUNET_CONFIGURATION_Handle *cfg, | 123 | GNUNET_REVOCATION_revoke (const struct GNUNET_CONFIGURATION_Handle *cfg, |
184 | const struct GNUNET_REVOCATION_PowP *pow, | 124 | const struct GNUNET_GNSRECORD_PowP *pow, |
185 | GNUNET_REVOCATION_Callback func, void *func_cls); | 125 | GNUNET_REVOCATION_Callback func, void *func_cls); |
186 | 126 | ||
187 | 127 | ||
@@ -194,68 +134,6 @@ void | |||
194 | GNUNET_REVOCATION_revoke_cancel (struct GNUNET_REVOCATION_Handle *h); | 134 | GNUNET_REVOCATION_revoke_cancel (struct GNUNET_REVOCATION_Handle *h); |
195 | 135 | ||
196 | 136 | ||
197 | /** | ||
198 | * Check if the given proof-of-work is valid. | ||
199 | * | ||
200 | * @param pow proof of work | ||
201 | * @param matching_bits how many bits must match (configuration) | ||
202 | * @param epoch_duration length of single epoch in configuration | ||
203 | * @return #GNUNET_YES if the @a pow is acceptable, #GNUNET_NO if not | ||
204 | */ | ||
205 | enum GNUNET_GenericReturnValue | ||
206 | GNUNET_REVOCATION_check_pow (const struct GNUNET_REVOCATION_PowP *pow, | ||
207 | unsigned int matching_bits, | ||
208 | struct GNUNET_TIME_Relative epoch_duration); | ||
209 | |||
210 | |||
211 | /** | ||
212 | * Initializes a fresh PoW computation. | ||
213 | * | ||
214 | * @param key the key to calculate the PoW for. | ||
215 | * @param pow the pow object to work with in the calculation. | ||
216 | */ | ||
217 | void | ||
218 | GNUNET_REVOCATION_pow_init (const struct GNUNET_IDENTITY_PrivateKey *key, | ||
219 | struct GNUNET_REVOCATION_PowP *pow); | ||
220 | |||
221 | |||
222 | /** | ||
223 | * Starts a proof-of-work calculation given the pow object as well as | ||
224 | * target epochs and difficulty. | ||
225 | * | ||
226 | * @param pow the PoW to based calculations on. | ||
227 | * @param epochs the number of epochs for which the PoW must be valid. | ||
228 | * @param difficulty the base difficulty of the PoW. | ||
229 | * @return a handle for use in PoW rounds | ||
230 | */ | ||
231 | struct GNUNET_REVOCATION_PowCalculationHandle* | ||
232 | GNUNET_REVOCATION_pow_start (struct GNUNET_REVOCATION_PowP *pow, | ||
233 | int epochs, | ||
234 | unsigned int difficulty); | ||
235 | |||
236 | |||
237 | /** | ||
238 | * Calculate a single round in the key revocation PoW. | ||
239 | * | ||
240 | * @param pc handle to the PoW, initially called with NULL. | ||
241 | * @return GNUNET_YES if the @a pow is acceptable, GNUNET_NO if not | ||
242 | */ | ||
243 | enum GNUNET_GenericReturnValue | ||
244 | GNUNET_REVOCATION_pow_round (struct GNUNET_REVOCATION_PowCalculationHandle *pc); | ||
245 | |||
246 | |||
247 | /** | ||
248 | * Stop a PoW calculation | ||
249 | * | ||
250 | * @param pc the calculation to clean up | ||
251 | * @return #GNUNET_YES if pow valid, #GNUNET_NO if pow was set but is not | ||
252 | * valid | ||
253 | */ | ||
254 | void | ||
255 | GNUNET_REVOCATION_pow_stop (struct GNUNET_REVOCATION_PowCalculationHandle *pc); | ||
256 | |||
257 | size_t | ||
258 | GNUNET_REVOCATION_proof_get_size (const struct GNUNET_REVOCATION_PowP *pow); | ||
259 | 137 | ||
260 | 138 | ||
261 | #if 0 /* keep Emacsens' auto-indent happy */ | 139 | #if 0 /* keep Emacsens' auto-indent happy */ |
@@ -268,3 +146,5 @@ GNUNET_REVOCATION_proof_get_size (const struct GNUNET_REVOCATION_PowP *pow); | |||
268 | #endif /* GNUNET_REVOCATION_SERVICE_H_ */ | 146 | #endif /* GNUNET_REVOCATION_SERVICE_H_ */ |
269 | 147 | ||
270 | /** @} */ /* end of group revocation */ | 148 | /** @} */ /* end of group revocation */ |
149 | |||
150 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_rps_service.h b/src/include/gnunet_rps_service.h index a0ed675f7..85c085111 100644 --- a/src/include/gnunet_rps_service.h +++ b/src/include/gnunet_rps_service.h | |||
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup Backbone | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Julius Bünger | 25 | * @author Julius Bünger |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
@@ -262,3 +265,5 @@ GNUNET_RPS_disconnect (struct GNUNET_RPS_Handle *h); | |||
262 | #endif | 265 | #endif |
263 | 266 | ||
264 | /** @} */ /* end of group */ | 267 | /** @} */ /* end of group */ |
268 | |||
269 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_scalarproduct_service.h b/src/include/gnunet_scalarproduct_service.h index 1d775f659..96d12db3f 100644 --- a/src/include/gnunet_scalarproduct_service.h +++ b/src/include/gnunet_scalarproduct_service.h | |||
@@ -31,6 +31,7 @@ | |||
31 | #ifndef GNUNET_SCALARPRODUCT_SERVICE_H | 31 | #ifndef GNUNET_SCALARPRODUCT_SERVICE_H |
32 | #define GNUNET_SCALARPRODUCT_SERVICE_H | 32 | #define GNUNET_SCALARPRODUCT_SERVICE_H |
33 | #define GCRYPT_NO_DEPRECATED | 33 | #define GCRYPT_NO_DEPRECATED |
34 | |||
34 | #include <gcrypt.h> | 35 | #include <gcrypt.h> |
35 | 36 | ||
36 | #ifdef __cplusplus | 37 | #ifdef __cplusplus |
@@ -179,7 +180,7 @@ GNUNET_SCALARPRODUCT_start_computation ( | |||
179 | struct GNUNET_SCALARPRODUCT_ComputationHandle * | 180 | struct GNUNET_SCALARPRODUCT_ComputationHandle * |
180 | GNUNET_SCALARPRODUCT_accept_computation ( | 181 | GNUNET_SCALARPRODUCT_accept_computation ( |
181 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 182 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
182 | const struct GNUNET_HashCode *key, | 183 | const struct GNUNET_HashCode *session_key, |
183 | const struct GNUNET_SCALARPRODUCT_Element *elements, | 184 | const struct GNUNET_SCALARPRODUCT_Element *elements, |
184 | uint32_t element_count, | 185 | uint32_t element_count, |
185 | GNUNET_SCALARPRODUCT_ContinuationWithStatus cont, | 186 | GNUNET_SCALARPRODUCT_ContinuationWithStatus cont, |
diff --git a/src/include/gnunet_scheduler_lib.h b/src/include/gnunet_scheduler_lib.h index 158f1d83b..0118a1535 100644 --- a/src/include/gnunet_scheduler_lib.h +++ b/src/include/gnunet_scheduler_lib.h | |||
@@ -19,6 +19,10 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup libgnunetutil | ||
23 | * Multi-function utilities library for GNUnet programs | ||
24 | * @{ | ||
25 | * | ||
22 | * @author Christian Grothoff | 26 | * @author Christian Grothoff |
23 | * | 27 | * |
24 | * @file | 28 | * @file |
@@ -92,6 +96,7 @@ enum GNUNET_SCHEDULER_Reason | |||
92 | }; | 96 | }; |
93 | 97 | ||
94 | 98 | ||
99 | |||
95 | #include "gnunet_time_lib.h" | 100 | #include "gnunet_time_lib.h" |
96 | #include "gnunet_network_lib.h" | 101 | #include "gnunet_network_lib.h" |
97 | 102 | ||
@@ -929,3 +934,5 @@ GNUNET_SCHEDULER_begin_async_scope (struct GNUNET_AsyncScopeId *aid); | |||
929 | #endif | 934 | #endif |
930 | 935 | ||
931 | /** @} */ /* end of group scheduler */ | 936 | /** @} */ /* end of group scheduler */ |
937 | |||
938 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_secretsharing_service.h b/src/include/gnunet_secretsharing_service.h index c13cf482a..de629b308 100644 --- a/src/include/gnunet_secretsharing_service.h +++ b/src/include/gnunet_secretsharing_service.h | |||
@@ -40,6 +40,7 @@ extern "C" | |||
40 | #endif | 40 | #endif |
41 | #endif | 41 | #endif |
42 | 42 | ||
43 | |||
43 | #include "gnunet_common.h" | 44 | #include "gnunet_common.h" |
44 | #include "gnunet_time_lib.h" | 45 | #include "gnunet_time_lib.h" |
45 | #include "gnunet_configuration_lib.h" | 46 | #include "gnunet_configuration_lib.h" |
diff --git a/src/include/gnunet_service_lib.h b/src/include/gnunet_service_lib.h index ad238a0fa..0ad4fcc3c 100644 --- a/src/include/gnunet_service_lib.h +++ b/src/include/gnunet_service_lib.h | |||
@@ -18,7 +18,19 @@ | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | |||
22 | #if ! defined (__GNUNET_UTIL_LIB_H_INSIDE__) | ||
23 | #error "Only <gnunet_util_lib.h> can be included directly." | ||
24 | #endif | ||
25 | |||
21 | /** | 26 | /** |
27 | * @addtogroup libgnunetutil | ||
28 | * Multi-function utilities library for GNUnet programs | ||
29 | * @{ | ||
30 | * | ||
31 | * @addtogroup networking | ||
32 | * @{ | ||
33 | * | ||
22 | * @author Christian Grothoff | 34 | * @author Christian Grothoff |
23 | * | 35 | * |
24 | * @file | 36 | * @file |
@@ -43,8 +55,8 @@ extern "C" | |||
43 | #endif | 55 | #endif |
44 | #endif | 56 | #endif |
45 | 57 | ||
58 | #include "gnunet_util_lib.h" | ||
46 | #include "gnunet_configuration_lib.h" | 59 | #include "gnunet_configuration_lib.h" |
47 | #include "gnunet_mq_lib.h" | ||
48 | 60 | ||
49 | 61 | ||
50 | /** | 62 | /** |
@@ -191,7 +203,6 @@ GNUNET_SERVICE_start (const char *service_name, | |||
191 | void | 203 | void |
192 | GNUNET_SERVICE_stop (struct GNUNET_SERVICE_Handle *srv); | 204 | GNUNET_SERVICE_stop (struct GNUNET_SERVICE_Handle *srv); |
193 | 205 | ||
194 | |||
195 | /** | 206 | /** |
196 | * Creates the "main" function for a GNUnet service. You | 207 | * Creates the "main" function for a GNUnet service. You |
197 | * should almost always use the #GNUNET_SERVICE_MAIN macro | 208 | * should almost always use the #GNUNET_SERVICE_MAIN macro |
@@ -246,6 +257,56 @@ GNUNET_SERVICE_run_ (int argc, | |||
246 | 257 | ||
247 | 258 | ||
248 | /** | 259 | /** |
260 | * Registers the GNUnet service to be scheduled as part of a monilithic | ||
261 | * libgnunet. | ||
262 | * You should almost always use the #GNUNET_SERVICE_MAIN macro | ||
263 | * instead of calling this function directly. | ||
264 | * | ||
265 | * The function will launch the service with the name @a service_name | ||
266 | * using the @a service_options to configure its shutdown | ||
267 | * behavior. Once the service is ready, the @a init_cb will be called | ||
268 | * for service-specific initialization. @a init_cb will be given the | ||
269 | * service handler which can be used to control the service's | ||
270 | * availability. When clients connect or disconnect, the respective | ||
271 | * @a connect_cb or @a disconnect_cb functions will be called. For | ||
272 | * messages received from the clients, the respective @a handlers will | ||
273 | * be invoked; for the closure of the handlers we use the return value | ||
274 | * from the @a connect_cb invocation of the respective client. | ||
275 | * | ||
276 | * Each handler MUST call #GNUNET_SERVICE_client_continue() after each | ||
277 | * message to receive further messages from this client. If | ||
278 | * #GNUNET_SERVICE_client_continue() is not called within a short | ||
279 | * time, a warning will be logged. If delays are expected, services | ||
280 | * should call #GNUNET_SERVICE_client_disable_continue_warning() to | ||
281 | * disable the warning. | ||
282 | * | ||
283 | * Clients sending invalid messages (based on @a handlers) will be | ||
284 | * dropped. Additionally, clients can be dropped at any time using | ||
285 | * #GNUNET_SERVICE_client_drop(). | ||
286 | * | ||
287 | * @param service_name name of the service to run | ||
288 | * @param options options controlling shutdown of the service | ||
289 | * @param service_init_cb function to call once the service is ready | ||
290 | * @param connect_cb function to call whenever a client connects | ||
291 | * @param disconnect_cb function to call whenever a client disconnects | ||
292 | * @param cls closure argument for @a service_init_cb, @a connect_cb and @a disconnect_cb | ||
293 | * @param handlers NULL-terminated array of message handlers for the service, | ||
294 | * the closure will be set to the value returned by | ||
295 | * the @a connect_cb for the respective connection | ||
296 | * @return 0 on success, non-zero on error | ||
297 | */ | ||
298 | int | ||
299 | GNUNET_SERVICE_register_ ( | ||
300 | const char *service_name, | ||
301 | enum GNUNET_SERVICE_Options options, | ||
302 | GNUNET_SERVICE_InitCallback service_init_cb, | ||
303 | GNUNET_SERVICE_ConnectHandler connect_cb, | ||
304 | GNUNET_SERVICE_DisconnectHandler disconnect_cb, | ||
305 | void *cls, | ||
306 | const struct GNUNET_MQ_MessageHandler *handlers); | ||
307 | |||
308 | |||
309 | /** | ||
249 | * Creates the "main" function for a GNUnet service. You | 310 | * Creates the "main" function for a GNUnet service. You |
250 | * MUST use this macro to define GNUnet services (except | 311 | * MUST use this macro to define GNUnet services (except |
251 | * for ARM, which MUST NOT use the macro). The reason is | 312 | * for ARM, which MUST NOT use the macro). The reason is |
@@ -275,8 +336,8 @@ GNUNET_SERVICE_run_ (int argc, | |||
275 | * #GNUNET_SERVICE_client_drop(). | 336 | * #GNUNET_SERVICE_client_drop(). |
276 | * | 337 | * |
277 | * @param service_name name of the service to run | 338 | * @param service_name name of the service to run |
278 | * @param options options controlling shutdown of the service | 339 | * @param service_options options controlling shutdown of the service |
279 | * @param service_init_cb function to call once the service is ready | 340 | * @param init_cb function to call once the service is ready |
280 | * @param connect_cb function to call whenever a client connects | 341 | * @param connect_cb function to call whenever a client connects |
281 | * @param disconnect_cb function to call whenever a client disconnects | 342 | * @param disconnect_cb function to call whenever a client disconnects |
282 | * @param cls closure argument for @a service_init_cb, @a connect_cb and @a disconnect_cb | 343 | * @param cls closure argument for @a service_init_cb, @a connect_cb and @a disconnect_cb |
@@ -302,26 +363,51 @@ GNUNET_SERVICE_run_ (int argc, | |||
302 | * GNUNET_MQ_handler_end ()); | 363 | * GNUNET_MQ_handler_end ()); |
303 | * </code> | 364 | * </code> |
304 | */ | 365 | */ |
366 | #ifndef HAVE_GNUNET_MONOLITH | ||
367 | #define GNUNET_SERVICE_MAIN(service_name, service_options, init_cb, connect_cb, \ | ||
368 | disconnect_cb, cls, ...) \ | ||
369 | int \ | ||
370 | main (int argc, \ | ||
371 | char *const *argv) \ | ||
372 | { \ | ||
373 | struct GNUNET_MQ_MessageHandler mh[] = { \ | ||
374 | __VA_ARGS__ \ | ||
375 | }; \ | ||
376 | return GNUNET_SERVICE_run_ (argc, \ | ||
377 | argv, \ | ||
378 | service_name, \ | ||
379 | service_options, \ | ||
380 | init_cb, \ | ||
381 | connect_cb, \ | ||
382 | disconnect_cb, \ | ||
383 | cls, \ | ||
384 | mh); \ | ||
385 | } | ||
386 | #else | ||
305 | #define GNUNET_SERVICE_MAIN(service_name, service_options, init_cb, connect_cb, \ | 387 | #define GNUNET_SERVICE_MAIN(service_name, service_options, init_cb, connect_cb, \ |
306 | disconnect_cb, cls, ...) \ | 388 | disconnect_cb, cls, ...) \ |
307 | int \ | 389 | static int __attribute__ ((constructor)) \ |
308 | main (int argc, \ | 390 | init (void) \ |
309 | char *const *argv) \ | 391 | { \ |
310 | { \ | 392 | struct GNUNET_MQ_MessageHandler mh[] = { \ |
311 | struct GNUNET_MQ_MessageHandler mh[] = { \ | 393 | __VA_ARGS__ \ |
312 | __VA_ARGS__ \ | 394 | }; \ |
313 | }; \ | 395 | return GNUNET_SERVICE_register_ (service_name, \ |
314 | return GNUNET_SERVICE_run_ (argc, \ | 396 | service_options, \ |
315 | argv, \ | 397 | init_cb, \ |
316 | service_name, \ | 398 | connect_cb, \ |
317 | service_options, \ | 399 | disconnect_cb, \ |
318 | init_cb, \ | 400 | cls, \ |
319 | connect_cb, \ | 401 | mh); \ |
320 | disconnect_cb, \ | 402 | } |
321 | cls, \ | 403 | #endif |
322 | mh); \ | ||
323 | } | ||
324 | 404 | ||
405 | /** | ||
406 | * Run the mainloop in a monolithic libgnunet. | ||
407 | * Must be called such that services are actually launched. | ||
408 | */ | ||
409 | void | ||
410 | GNUNET_SERVICE_main (int argc, char *const *argv); | ||
325 | 411 | ||
326 | /** | 412 | /** |
327 | * Suspend accepting connections from the listen socket temporarily. | 413 | * Suspend accepting connections from the listen socket temporarily. |
@@ -442,4 +528,8 @@ GNUNET_SERVICE_client_persist (struct GNUNET_SERVICE_Client *c); | |||
442 | 528 | ||
443 | /** @} */ /* end of group service */ | 529 | /** @} */ /* end of group service */ |
444 | 530 | ||
531 | /** @} */ /* end of group addition to networking*/ | ||
532 | |||
533 | /** @} */ /* end of group addition to libgnunetutil */ | ||
534 | |||
445 | /* end of gnunet_service_lib.h */ | 535 | /* end of gnunet_service_lib.h */ |
diff --git a/src/include/gnunet_set_service.h b/src/include/gnunet_set_service.h index 802a979cd..6874c9ec4 100644 --- a/src/include/gnunet_set_service.h +++ b/src/include/gnunet_set_service.h | |||
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup Sets | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Florian Dold | 25 | * @author Florian Dold |
23 | * @author Christian Grothoff | 26 | * @author Christian Grothoff |
24 | * | 27 | * |
@@ -44,6 +47,7 @@ extern "C" | |||
44 | #endif | 47 | #endif |
45 | #endif | 48 | #endif |
46 | 49 | ||
50 | |||
47 | #include "gnunet_common.h" | 51 | #include "gnunet_common.h" |
48 | #include "gnunet_time_lib.h" | 52 | #include "gnunet_time_lib.h" |
49 | #include "gnunet_configuration_lib.h" | 53 | #include "gnunet_configuration_lib.h" |
@@ -365,10 +369,10 @@ GNUNET_SET_add_element (struct GNUNET_SET_Handle *set, | |||
365 | 369 | ||
366 | 370 | ||
367 | /** | 371 | /** |
368 | * Remove an element to the given set. | 372 | * Remove an element to the given set. |
369 | * After the element has been removed (in the sense of the | 373 | * After the element has been removed (in the sense of the request |
370 | * request being transmitted to the set service), cont will be called. | 374 | * being transmitted to the set service), @a cont will be called. |
371 | * Calls to remove_element can be queued | 375 | * Multiple calls to GNUNET_SET_remove_element() can be queued |
372 | * | 376 | * |
373 | * @param set set to remove element from | 377 | * @param set set to remove element from |
374 | * @param element element to remove from the set | 378 | * @param element element to remove from the set |
@@ -556,7 +560,7 @@ GNUNET_SET_element_dup (const struct GNUNET_SET_Element *element); | |||
556 | * Hash a set element. | 560 | * Hash a set element. |
557 | * | 561 | * |
558 | * @param element the element that should be hashed | 562 | * @param element the element that should be hashed |
559 | * @param ret_hash a pointer to where the hash of @a element | 563 | * @param[out] ret_hash a pointer to where the hash of @a element |
560 | * should be stored | 564 | * should be stored |
561 | */ | 565 | */ |
562 | void | 566 | void |
@@ -574,3 +578,5 @@ GNUNET_SET_element_hash (const struct GNUNET_SET_Element *element, | |||
574 | #endif | 578 | #endif |
575 | 579 | ||
576 | /** @} */ /* end of group */ | 580 | /** @} */ /* end of group */ |
581 | |||
582 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_seti_service.h b/src/include/gnunet_seti_service.h index 5cf35e0cd..9125ae825 100644 --- a/src/include/gnunet_seti_service.h +++ b/src/include/gnunet_seti_service.h | |||
@@ -18,6 +18,9 @@ | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @addtogroup Sets | ||
22 | * @{ | ||
23 | * | ||
21 | * @author Florian Dold | 24 | * @author Florian Dold |
22 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
23 | * | 26 | * |
@@ -41,6 +44,7 @@ extern "C" | |||
41 | #endif | 44 | #endif |
42 | #endif | 45 | #endif |
43 | 46 | ||
47 | |||
44 | #include "gnunet_common.h" | 48 | #include "gnunet_common.h" |
45 | #include "gnunet_time_lib.h" | 49 | #include "gnunet_time_lib.h" |
46 | #include "gnunet_configuration_lib.h" | 50 | #include "gnunet_configuration_lib.h" |
@@ -367,3 +371,5 @@ GNUNET_SETI_element_hash (const struct GNUNET_SETI_Element *element, | |||
367 | #endif | 371 | #endif |
368 | 372 | ||
369 | /** @} */ /* end of group */ | 373 | /** @} */ /* end of group */ |
374 | |||
375 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_setu_service.h b/src/include/gnunet_setu_service.h index 1d7e48402..89a50f138 100644 --- a/src/include/gnunet_setu_service.h +++ b/src/include/gnunet_setu_service.h | |||
@@ -18,6 +18,9 @@ | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @addtogroup Sets | ||
22 | * @{ | ||
23 | * | ||
21 | * @author Florian Dold | 24 | * @author Florian Dold |
22 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
23 | * | 26 | * |
@@ -41,6 +44,7 @@ extern "C" | |||
41 | #endif | 44 | #endif |
42 | #endif | 45 | #endif |
43 | 46 | ||
47 | |||
44 | #include "gnunet_common.h" | 48 | #include "gnunet_common.h" |
45 | #include "gnunet_time_lib.h" | 49 | #include "gnunet_time_lib.h" |
46 | #include "gnunet_configuration_lib.h" | 50 | #include "gnunet_configuration_lib.h" |
@@ -288,9 +292,9 @@ GNUNET_SETU_destroy (struct GNUNET_SETU_Handle *set); | |||
288 | 292 | ||
289 | 293 | ||
290 | /** | 294 | /** |
291 | * Prepare a set operation to be evaluated with another peer. The evaluation | 295 | * Prepare a set operation to be evaluated with another peer. |
292 | * will not start until the client provides a local set with | 296 | * The evaluation will not start until the client provides a |
293 | * GNUNET_SETU_commit(). | 297 | * local set with GNUNET_SETU_commit(). |
294 | * | 298 | * |
295 | * @param other_peer peer with the other set | 299 | * @param other_peer peer with the other set |
296 | * @param app_id hash for the application using the set | 300 | * @param app_id hash for the application using the set |
@@ -412,3 +416,5 @@ GNUNET_SETU_element_hash (const struct GNUNET_SETU_Element *element, | |||
412 | #endif | 416 | #endif |
413 | 417 | ||
414 | /** @} */ /* end of group */ | 418 | /** @} */ /* end of group */ |
419 | |||
420 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_signal_lib.h b/src/include/gnunet_signal_lib.h index 5a14a2d9e..02fbbf005 100644 --- a/src/include/gnunet_signal_lib.h +++ b/src/include/gnunet_signal_lib.h | |||
@@ -18,7 +18,15 @@ | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) | ||
22 | #error "Only <gnunet_util_lib.h> can be included directly." | ||
23 | #endif | ||
24 | |||
21 | /** | 25 | /** |
26 | * @addtogroup libgnunetutil | ||
27 | * Multi-function utilities library for GNUnet programs | ||
28 | * @{ | ||
29 | * | ||
22 | * @author Christian Grothoff | 30 | * @author Christian Grothoff |
23 | * | 31 | * |
24 | * @file | 32 | * @file |
@@ -105,4 +113,6 @@ GNUNET_SIGNAL_raise (const int sig); | |||
105 | 113 | ||
106 | /** @} */ /* end of group */ | 114 | /** @} */ /* end of group */ |
107 | 115 | ||
116 | /** @} */ /* end of group addition */ | ||
117 | |||
108 | /* end of gnunet_signal_lib.h */ | 118 | /* end of gnunet_signal_lib.h */ |
diff --git a/src/include/gnunet_signatures.h b/src/include/gnunet_signatures.h new file mode 100644 index 000000000..6ec30bf71 --- /dev/null +++ b/src/include/gnunet_signatures.h | |||
@@ -0,0 +1,254 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2012-2022 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your 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 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | #ifndef GNUNET_SIGNATURES_H | ||
21 | #define GNUNET_SIGNATURES_H | ||
22 | |||
23 | /** | ||
24 | * WARNING: | ||
25 | * This header is generated! | ||
26 | * In order to add a signature purpose, you must register | ||
27 | * them in GANA, and then use the header generation script | ||
28 | * to create an update of this file. You may then replace this | ||
29 | * file with the update. | ||
30 | */ | ||
31 | |||
32 | |||
33 | |||
34 | #ifdef __cplusplus | ||
35 | extern "C" { | ||
36 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
37 | } | ||
38 | #endif | ||
39 | #endif | ||
40 | |||
41 | |||
42 | /** | ||
43 | * Network signature purpose definitions. Note that all values | ||
44 | * must be uint32_t and encoded in network byte order in the structs. | ||
45 | */ | ||
46 | |||
47 | |||
48 | |||
49 | /** | ||
50 | * Test signature, not valid for anything other than writing a test. (Note that the signature verification code will accept this value). (GNUnet) | ||
51 | */ | ||
52 | #define GNUNET_SIGNATURE_PURPOSE_TEST 0 | ||
53 | |||
54 | |||
55 | /** | ||
56 | * Signature for confirming that this peer uses a particular address. (GNUnet-TRANSPORT) | ||
57 | */ | ||
58 | #define GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN 1 | ||
59 | |||
60 | |||
61 | /** | ||
62 | * Signature for confirming that this peer intends to disconnect. (GNUnet-TRANSPORT) | ||
63 | */ | ||
64 | #define GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DISCONNECT 2 | ||
65 | |||
66 | |||
67 | /** | ||
68 | * GNS zone key revocation (GNS) | ||
69 | */ | ||
70 | #define GNUNET_SIGNATURE_PURPOSE_GNS_REVOCATION 3 | ||
71 | |||
72 | |||
73 | /** | ||
74 | * Signature for a namespace/pseudonym advertisement (by the namespace owner). (GNUnet-FS) | ||
75 | */ | ||
76 | #define GNUNET_SIGNATURE_PURPOSE_NAMESPACE_ADVERTISEMENT 4 | ||
77 | |||
78 | |||
79 | /** | ||
80 | * Signature by which a peer affirms that it is providing a certain bit of content for use in LOCation URIs. (GNUnet-FS) | ||
81 | */ | ||
82 | #define GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT 5 | ||
83 | |||
84 | |||
85 | /** | ||
86 | * Signature by which a peer affirms that it forwarded a message in the DHT. (GNUnet-DHT) | ||
87 | */ | ||
88 | #define GNUNET_SIGNATURE_PURPOSE_DHT_HOP 6 | ||
89 | |||
90 | |||
91 | /** | ||
92 | * Signature by which a peer affirms its address. (GNUnet-HELLO) | ||
93 | */ | ||
94 | #define GNUNET_SIGNATURE_PURPOSE_HELLO 7 | ||
95 | |||
96 | |||
97 | /** | ||
98 | * Signature on a GNUNET_DNS_Advertisement. (GNUnet-DNS+Exit) | ||
99 | */ | ||
100 | #define GNUNET_SIGNATURE_PURPOSE_DNS_RECORD 11 | ||
101 | |||
102 | |||
103 | /** | ||
104 | * Signature of a chat message. (GNUnet-MESSENGER) | ||
105 | */ | ||
106 | #define GNUNET_SIGNATURE_PURPOSE_CHAT_MESSAGE 12 | ||
107 | |||
108 | |||
109 | /** | ||
110 | * Signature of confirmation receipt for a chat message. (GNUnet-MESSENGER) | ||
111 | */ | ||
112 | #define GNUNET_SIGNATURE_PURPOSE_CHAT_RECEIPT 13 | ||
113 | |||
114 | |||
115 | /** | ||
116 | * Signature of a network size estimate message. (GNUnet-NSE) | ||
117 | */ | ||
118 | #define GNUNET_SIGNATURE_PURPOSE_NSE_SEND 14 | ||
119 | |||
120 | |||
121 | /** | ||
122 | * GNS record set signature (GNS) | ||
123 | */ | ||
124 | #define GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN 15 | ||
125 | |||
126 | |||
127 | /** | ||
128 | * Purpose is to set a session key. (GNUnet-CORE) | ||
129 | */ | ||
130 | #define GNUNET_SIGNATURE_PURPOSE_SET_ECC_KEY 16 | ||
131 | |||
132 | |||
133 | /** | ||
134 | * UBlock Signature, done using DSS, not ECC (GNUnet-FS) | ||
135 | */ | ||
136 | #define GNUNET_SIGNATURE_PURPOSE_FS_UBLOCK 17 | ||
137 | |||
138 | |||
139 | /** | ||
140 | * Accept state in regex DFA. Peer affirms that it offers the matching service. (GNUnet-REGEX) | ||
141 | */ | ||
142 | #define GNUNET_SIGNATURE_PURPOSE_REGEX_ACCEPT 18 | ||
143 | |||
144 | |||
145 | /** | ||
146 | * Signature of a conversation ring. (GNUnet-CONVERSATION) | ||
147 | */ | ||
148 | #define GNUNET_SIGNATURE_PURPOSE_CONVERSATION_RING 20 | ||
149 | |||
150 | |||
151 | /** | ||
152 | * Signature for the first round of distributed key generation. (GNUnet-SECRETSHARING) | ||
153 | */ | ||
154 | #define GNUNET_SIGNATURE_PURPOSE_SECRETSHARING_DKG1 21 | ||
155 | |||
156 | |||
157 | /** | ||
158 | * Signature for the second round of distributed key generation. (GNUnet-SECRETSHARING) | ||
159 | */ | ||
160 | #define GNUNET_SIGNATURE_PURPOSE_SECRETSHARING_DKG2 22 | ||
161 | |||
162 | |||
163 | /** | ||
164 | * Signature for the cooperative decryption. (GNUnet-SECRETSHARING) | ||
165 | */ | ||
166 | #define GNUNET_SIGNATURE_PURPOSE_SECRETSHARING_DECRYPTION 23 | ||
167 | |||
168 | |||
169 | /** | ||
170 | * Signature for a GNUid Ticket (Reclaim) | ||
171 | */ | ||
172 | #define GNUNET_SIGNATURE_PURPOSE_RECLAIM_CODE_SIGN 27 | ||
173 | |||
174 | |||
175 | /** | ||
176 | * Signature for a GNUnet credential (Reclaim) | ||
177 | */ | ||
178 | #define GNUNET_SIGNATURE_PURPOSE_DELEGATE 28 | ||
179 | |||
180 | |||
181 | /** | ||
182 | * Signature by a peer affirming that this is one of its addresses for the given time period. (GNUnet-TRANSPORT) | ||
183 | */ | ||
184 | #define GNUNET_SIGNATURE_PURPOSE_TRANSPORT_ADDRESS 29 | ||
185 | |||
186 | |||
187 | /** | ||
188 | * Signature by a peer affirming that the given ephemeral key is currently in use by that peer's transport service. (GNUnet-TRANSPORT) | ||
189 | */ | ||
190 | #define GNUNET_SIGNATURE_PURPOSE_TRANSPORT_EPHEMERAL 30 | ||
191 | |||
192 | |||
193 | /** | ||
194 | * Signature used by TCP communicator handshake. (GNUnet-TRANSPORT-TCP) | ||
195 | */ | ||
196 | #define GNUNET_SIGNATURE_PURPOSE_COMMUNICATOR_TCP_HANDSHAKE 31 | ||
197 | |||
198 | |||
199 | /** | ||
200 | * Signature used by TCP communicator rekey. (GNUnet-TRANSPORT-TCP) | ||
201 | */ | ||
202 | #define GNUNET_SIGNATURE_PURPOSE_COMMUNICATOR_TCP_REKEY 32 | ||
203 | |||
204 | |||
205 | /** | ||
206 | * Signature used by UDP communicator handshake. (GNUnet-TRANSPORT-UDP) | ||
207 | */ | ||
208 | #define GNUNET_SIGNATURE_PURPOSE_COMMUNICATOR_UDP_HANDSHAKE 33 | ||
209 | |||
210 | |||
211 | /** | ||
212 | * Signature used by UDP broadcasts. (GNUnet-TRANSPORT-UDP) | ||
213 | */ | ||
214 | #define GNUNET_SIGNATURE_PURPOSE_COMMUNICATOR_UDP_BROADCAST 34 | ||
215 | |||
216 | |||
217 | /** | ||
218 | * Signature by a peer affirming that it received a challenge (and stating how long it expects the address on which the challenge was received to remain valid). (GNUnet-TRANSPORT) | ||
219 | */ | ||
220 | #define GNUNET_SIGNATURE_PURPOSE_TRANSPORT_CHALLENGE 35 | ||
221 | |||
222 | |||
223 | /** | ||
224 | * Signature by a peer affirming that it is on a DV path. (GNUnet-TRANSPORT) | ||
225 | */ | ||
226 | #define GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_HOP 36 | ||
227 | |||
228 | |||
229 | /** | ||
230 | * Signature by a peer affirming that it originated the DV path. (GNUnet-TRANSPORT) | ||
231 | */ | ||
232 | #define GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_INITIATOR 37 | ||
233 | |||
234 | |||
235 | /** | ||
236 | * Signature by a peer that like to create a connection. (GNUnet-CADET) | ||
237 | */ | ||
238 | #define GNUNET_SIGNATURE_PURPOSE_CADET_CONNECTION_INITIATOR 38 | ||
239 | |||
240 | |||
241 | /** | ||
242 | * Signature by a peer sending back the nonce received at initial handshake. (GNUnet-TRANSPORT-TCP) | ||
243 | */ | ||
244 | #define GNUNET_SIGNATURE_PURPOSE_COMMUNICATOR_TCP_HANDSHAKE_ACK 39 | ||
245 | |||
246 | |||
247 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
248 | { | ||
249 | #endif | ||
250 | #ifdef __cplusplus | ||
251 | } | ||
252 | #endif | ||
253 | |||
254 | #endif | ||
diff --git a/src/include/gnunet_socks.h b/src/include/gnunet_socks.h index 1a6ae1119..98a27cd1a 100644 --- a/src/include/gnunet_socks.h +++ b/src/include/gnunet_socks.h | |||
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup libgnunetutil | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Jeffrey Burdges | 25 | * @author Jeffrey Burdges |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
@@ -40,6 +43,7 @@ extern "C" | |||
40 | #endif | 43 | #endif |
41 | #endif | 44 | #endif |
42 | 45 | ||
46 | |||
43 | #include "gnunet_common.h" | 47 | #include "gnunet_common.h" |
44 | 48 | ||
45 | 49 | ||
@@ -81,4 +85,6 @@ GNUNET_SOCKS_do_connect (const char *service_name, | |||
81 | 85 | ||
82 | /** @} */ /* end of group */ | 86 | /** @} */ /* end of group */ |
83 | 87 | ||
88 | /** @} */ /* end of group addition to libgnunetutil */ | ||
89 | |||
84 | /* end of gnunet_socks.h */ | 90 | /* end of gnunet_socks.h */ |
diff --git a/src/include/gnunet_speaker_lib.h b/src/include/gnunet_speaker_lib.h index 71a7c2166..c6bb128dd 100644 --- a/src/include/gnunet_speaker_lib.h +++ b/src/include/gnunet_speaker_lib.h | |||
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup conversation_l2 Conversation service and libraries | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Simon Dieterle | 25 | * @author Simon Dieterle |
23 | * @author Andreas Fuchs | 26 | * @author Andreas Fuchs |
24 | * @author Christian Grothoff | 27 | * @author Christian Grothoff |
@@ -41,6 +44,7 @@ extern "C" | |||
41 | #endif | 44 | #endif |
42 | #endif | 45 | #endif |
43 | 46 | ||
47 | |||
44 | #include "gnunet_util_lib.h" | 48 | #include "gnunet_util_lib.h" |
45 | 49 | ||
46 | /** | 50 | /** |
@@ -142,4 +146,6 @@ GNUNET_SPEAKER_destroy (struct GNUNET_SPEAKER_Handle *speaker); | |||
142 | 146 | ||
143 | /** @} */ /* end of group */ | 147 | /** @} */ /* end of group */ |
144 | 148 | ||
149 | /** @} */ /* end of group addition */ | ||
150 | |||
145 | /* end of gnunet_speaker_lib.h */ | 151 | /* end of gnunet_speaker_lib.h */ |
diff --git a/src/include/gnunet_sq_lib.h b/src/include/gnunet_sq_lib.h index 51713e755..b84e6759a 100644 --- a/src/include/gnunet_sq_lib.h +++ b/src/include/gnunet_sq_lib.h | |||
@@ -25,6 +25,7 @@ | |||
25 | #ifndef GNUNET_SQ_LIB_H | 25 | #ifndef GNUNET_SQ_LIB_H |
26 | #define GNUNET_SQ_LIB_H | 26 | #define GNUNET_SQ_LIB_H |
27 | 27 | ||
28 | |||
28 | #include <sqlite3.h> | 29 | #include <sqlite3.h> |
29 | #include "gnunet_util_lib.h" | 30 | #include "gnunet_util_lib.h" |
30 | 31 | ||
@@ -91,7 +92,7 @@ struct GNUNET_SQ_QueryParam | |||
91 | * @a ptr_size bytes. | 92 | * @a ptr_size bytes. |
92 | * | 93 | * |
93 | * @param ptr pointer to the query parameter to pass | 94 | * @param ptr pointer to the query parameter to pass |
94 | * @oaran ptr_size number of bytes in @a ptr | 95 | * @param ptr_size number of bytes in @a ptr |
95 | */ | 96 | */ |
96 | struct GNUNET_SQ_QueryParam | 97 | struct GNUNET_SQ_QueryParam |
97 | GNUNET_SQ_query_param_fixed_size (const void *ptr, | 98 | GNUNET_SQ_query_param_fixed_size (const void *ptr, |
diff --git a/src/include/gnunet_statistics_service.h b/src/include/gnunet_statistics_service.h index 20e958865..0fe09e69a 100644 --- a/src/include/gnunet_statistics_service.h +++ b/src/include/gnunet_statistics_service.h | |||
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup Backbone | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
@@ -47,6 +50,7 @@ extern "C" | |||
47 | #endif | 50 | #endif |
48 | #endif | 51 | #endif |
49 | 52 | ||
53 | |||
50 | #include "gnunet_util_lib.h" | 54 | #include "gnunet_util_lib.h" |
51 | 55 | ||
52 | /** | 56 | /** |
@@ -227,4 +231,6 @@ GNUNET_STATISTICS_update (struct GNUNET_STATISTICS_Handle *handle, | |||
227 | 231 | ||
228 | /** @} */ /* end of group statistics */ | 232 | /** @} */ /* end of group statistics */ |
229 | 233 | ||
234 | /** @} */ /* end of group addition */ | ||
235 | |||
230 | #endif | 236 | #endif |
diff --git a/src/include/gnunet_strings_lib.h b/src/include/gnunet_strings_lib.h index aa4daf8a3..df70c5e8f 100644 --- a/src/include/gnunet_strings_lib.h +++ b/src/include/gnunet_strings_lib.h | |||
@@ -18,7 +18,15 @@ | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #if ! defined (__GNUNET_UTIL_LIB_H_INSIDE__) | ||
22 | #error "Only <gnunet_util_lib.h> can be included directly." | ||
23 | #endif | ||
24 | |||
21 | /** | 25 | /** |
26 | * @addtogroup libgnunetutil | ||
27 | * Multi-function utilities library for GNUnet programs | ||
28 | * @{ | ||
29 | * | ||
22 | * @author Christian Grothoff | 30 | * @author Christian Grothoff |
23 | * @author Krista Bennett | 31 | * @author Krista Bennett |
24 | * @author Gerd Knorr <kraxel@bytesex.org> | 32 | * @author Gerd Knorr <kraxel@bytesex.org> |
@@ -33,6 +41,10 @@ | |||
33 | * @{ | 41 | * @{ |
34 | */ | 42 | */ |
35 | 43 | ||
44 | #if ! defined (__GNUNET_UTIL_LIB_H_INSIDE__) | ||
45 | #error "Only <gnunet_util_lib.h> can be included directly." | ||
46 | #endif | ||
47 | |||
36 | #ifndef GNUNET_STRINGS_LIB_H | 48 | #ifndef GNUNET_STRINGS_LIB_H |
37 | #define GNUNET_STRINGS_LIB_H | 49 | #define GNUNET_STRINGS_LIB_H |
38 | 50 | ||
@@ -40,6 +52,7 @@ | |||
40 | or unsigned long long, this IS platform dependent; | 52 | or unsigned long long, this IS platform dependent; |
41 | but "stdlib.h" should be portable 'enough' to be | 53 | but "stdlib.h" should be portable 'enough' to be |
42 | unconditionally available... */ | 54 | unconditionally available... */ |
55 | |||
43 | #include <stdlib.h> | 56 | #include <stdlib.h> |
44 | #include <sys/socket.h> | 57 | #include <sys/socket.h> |
45 | #include <netinet/in.h> | 58 | #include <netinet/in.h> |
@@ -397,15 +410,19 @@ GNUNET_STRINGS_base64_encode (const void *in, | |||
397 | /** | 410 | /** |
398 | * url/percent encode (RFC3986). | 411 | * url/percent encode (RFC3986). |
399 | * | 412 | * |
413 | * FIXME: awkward API, @a len is not actually used | ||
414 | * @a out is 0-terminated, should probably be changed | ||
415 | * to only input @a data and directly return @out or NULL. | ||
416 | * | ||
400 | * @param data the data to decode | 417 | * @param data the data to decode |
401 | * @param len the length of the input | 418 | * @param len the length of the input |
402 | * @param output where to write the output (*output should be NULL, | 419 | * @param out where to write the output (*out should be NULL, |
403 | * is allocated) | 420 | * is allocated) |
404 | * @return the size of the output | 421 | * @return the size of the output |
405 | */ | 422 | */ |
406 | size_t | 423 | size_t |
407 | GNUNET_STRINGS_urlencode (const char *data, | 424 | GNUNET_STRINGS_urlencode (size_t len, |
408 | size_t len, | 425 | const char data[static len], |
409 | char **out); | 426 | char **out); |
410 | 427 | ||
411 | 428 | ||
@@ -444,7 +461,7 @@ GNUNET_STRINGS_base64_decode (const char *data, | |||
444 | * | 461 | * |
445 | * @param data the data to decode | 462 | * @param data the data to decode |
446 | * @param len the length of the input | 463 | * @param len the length of the input |
447 | * @param output where to write the output (*output should be NULL, | 464 | * @param out where to write the output (*out should be NULL, |
448 | * is allocated) | 465 | * is allocated) |
449 | * @return the size of the output | 466 | * @return the size of the output |
450 | */ | 467 | */ |
@@ -565,7 +582,7 @@ GNUNET_STRINGS_check_filename (const char *filename, | |||
565 | */ | 582 | */ |
566 | enum GNUNET_GenericReturnValue | 583 | enum GNUNET_GenericReturnValue |
567 | GNUNET_STRINGS_to_address_ipv6 (const char *zt_addr, | 584 | GNUNET_STRINGS_to_address_ipv6 (const char *zt_addr, |
568 | uint16_t addrlen, | 585 | size_t addrlen, |
569 | struct sockaddr_in6 *r_buf); | 586 | struct sockaddr_in6 *r_buf); |
570 | 587 | ||
571 | 588 | ||
@@ -581,7 +598,7 @@ GNUNET_STRINGS_to_address_ipv6 (const char *zt_addr, | |||
581 | */ | 598 | */ |
582 | enum GNUNET_GenericReturnValue | 599 | enum GNUNET_GenericReturnValue |
583 | GNUNET_STRINGS_to_address_ipv4 (const char *zt_addr, | 600 | GNUNET_STRINGS_to_address_ipv4 (const char *zt_addr, |
584 | uint16_t addrlen, | 601 | size_t addrlen, |
585 | struct sockaddr_in *r_buf); | 602 | struct sockaddr_in *r_buf); |
586 | 603 | ||
587 | 604 | ||
@@ -657,6 +674,23 @@ GNUNET_strlcpy (char *dst, | |||
657 | size_t n); | 674 | size_t n); |
658 | 675 | ||
659 | 676 | ||
677 | /** | ||
678 | * Sometimes we use the binary name to determine which specific | ||
679 | * test to run. In those cases, the string after the last "_" | ||
680 | * in 'argv[0]' specifies a string that determines the configuration | ||
681 | * file or plugin to use. | ||
682 | * | ||
683 | * This function returns the respective substring, taking care | ||
684 | * of issues such as binaries ending in '.exe' on W32. | ||
685 | * | ||
686 | * @param argv0 the name of the binary | ||
687 | * @return string between the last '_' and the '.exe' (or the end of the string), | ||
688 | * NULL if argv0 has no '_' | ||
689 | */ | ||
690 | char * | ||
691 | GNUNET_STRINGS_get_suffix_from_binary_name (const char *argv0); | ||
692 | |||
693 | |||
660 | /* ***************** IPv4/IPv6 parsing ****************** */ | 694 | /* ***************** IPv4/IPv6 parsing ****************** */ |
661 | 695 | ||
662 | struct GNUNET_STRINGS_PortPolicy | 696 | struct GNUNET_STRINGS_PortPolicy |
@@ -765,4 +799,6 @@ GNUNET_STRINGS_parse_ipv6_policy (const char *routeListX); | |||
765 | 799 | ||
766 | /** @} */ /* end of group */ | 800 | /** @} */ /* end of group */ |
767 | 801 | ||
802 | /** @} */ /* end of group addition */ | ||
803 | |||
768 | /* end of gnunet_util_string.h */ | 804 | /* end of gnunet_util_string.h */ |
diff --git a/src/include/gnunet_testbed_logger_service.h b/src/include/gnunet_testbed_logger_service.h deleted file mode 100644 index 72b5ab364..000000000 --- a/src/include/gnunet_testbed_logger_service.h +++ /dev/null | |||
@@ -1,133 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2008--2013 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your 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 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @author Sree Harsha Totakura <sreeharsha@totakura.in> | ||
23 | * | ||
24 | * @file | ||
25 | * API for submitting data to the testbed logger service | ||
26 | * | ||
27 | * @defgroup testbed-logger Testbed Logger service | ||
28 | * Submit data to the testbed logger service. | ||
29 | * @{ | ||
30 | */ | ||
31 | |||
32 | #ifndef GNUNET_TESTBED_LOGGER_SERVICE_H | ||
33 | #define GNUNET_TESTBED_LOGGER_SERVICE_H | ||
34 | |||
35 | #ifdef __cplusplus | ||
36 | extern "C" | ||
37 | { | ||
38 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
39 | } | ||
40 | #endif | ||
41 | #endif | ||
42 | |||
43 | #include "gnunet_util_lib.h" | ||
44 | |||
45 | /** | ||
46 | * Opaque handle for the logging service | ||
47 | */ | ||
48 | struct GNUNET_TESTBED_LOGGER_Handle; | ||
49 | |||
50 | |||
51 | /** | ||
52 | * Connect to the testbed logger service | ||
53 | * | ||
54 | * @param cfg configuration to use | ||
55 | * @return the handle which can be used for sending data to the service; NULL | ||
56 | * upon any error | ||
57 | */ | ||
58 | struct GNUNET_TESTBED_LOGGER_Handle * | ||
59 | GNUNET_TESTBED_LOGGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg); | ||
60 | |||
61 | |||
62 | /** | ||
63 | * Disconnect from the logger service. Also cancels any pending send handles. | ||
64 | * | ||
65 | * @param h the logger handle | ||
66 | */ | ||
67 | void | ||
68 | GNUNET_TESTBED_LOGGER_disconnect (struct GNUNET_TESTBED_LOGGER_Handle *h); | ||
69 | |||
70 | |||
71 | /** | ||
72 | * Functions of this type are called to notify a successful transmission of the | ||
73 | * message to the logger service. | ||
74 | * | ||
75 | * @param cls the closure given to GNUNET_TESTBED_LOGGER_send() | ||
76 | * @param size the amount of data sent | ||
77 | */ | ||
78 | typedef void | ||
79 | (*GNUNET_TESTBED_LOGGER_FlushCompletion) (void *cls, | ||
80 | size_t size); | ||
81 | |||
82 | |||
83 | /** | ||
84 | * Send data to be logged to the logger service. The data will be buffered and | ||
85 | * will be sent upon an explicit call to GNUNET_TESTBED_LOGGER_flush() or upon | ||
86 | * exceeding a threshold size. | ||
87 | * | ||
88 | * @param h the logger handle | ||
89 | * @param data the data to send; | ||
90 | * @param size how many bytes of @a data to send | ||
91 | */ | ||
92 | void | ||
93 | GNUNET_TESTBED_LOGGER_write (struct GNUNET_TESTBED_LOGGER_Handle *h, | ||
94 | const void *data, | ||
95 | size_t size); | ||
96 | |||
97 | |||
98 | /** | ||
99 | * Flush the buffered data to the logger service | ||
100 | * | ||
101 | * @param h the logger handle | ||
102 | * @param cb the callback to call after the data is flushed | ||
103 | * @param cb_cls the closure for @a cb | ||
104 | */ | ||
105 | void | ||
106 | GNUNET_TESTBED_LOGGER_flush (struct GNUNET_TESTBED_LOGGER_Handle *h, | ||
107 | GNUNET_TESTBED_LOGGER_FlushCompletion cb, | ||
108 | void *cb_cls); | ||
109 | |||
110 | |||
111 | /** | ||
112 | * Cancel notification upon flush. Should only be used when the flush | ||
113 | * completion callback given to GNUNET_TESTBED_LOGGER_flush() is not already | ||
114 | * called. | ||
115 | * | ||
116 | * @param h the logger handle | ||
117 | */ | ||
118 | void | ||
119 | GNUNET_TESTBED_LOGGER_flush_cancel (struct GNUNET_TESTBED_LOGGER_Handle *h); | ||
120 | |||
121 | |||
122 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
123 | { | ||
124 | #endif | ||
125 | #ifdef __cplusplus | ||
126 | } | ||
127 | #endif | ||
128 | |||
129 | #endif /* GNUNET_TESTBED_LOGGER_SERVICE_H */ | ||
130 | |||
131 | /** @} */ /* end of group */ | ||
132 | |||
133 | /* End of gnunet_testbed_logger_service.h */ | ||
diff --git a/src/include/gnunet_testbed_service.h b/src/include/gnunet_testbed_service.h deleted file mode 100644 index 888c6e391..000000000 --- a/src/include/gnunet_testbed_service.h +++ /dev/null | |||
@@ -1,1729 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2008--2013 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your 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 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @author Christian Grothoff | ||
23 | * | ||
24 | * @file | ||
25 | * API for writing tests and creating large-scale emulation testbeds for GNUnet. | ||
26 | * | ||
27 | * @defgroup testbed Testbed service | ||
28 | * Writing tests and creating large-scale emulation testbeds for GNUnet. | ||
29 | * | ||
30 | * @see [Documentation](https://docs.gnunet.org/handbook/gnunet.html#TESTBED-Subsystem) | ||
31 | * | ||
32 | * @{ | ||
33 | */ | ||
34 | |||
35 | #ifndef GNUNET_TESTBED_SERVICE_H | ||
36 | #define GNUNET_TESTBED_SERVICE_H | ||
37 | |||
38 | #include "gnunet_util_lib.h" | ||
39 | #include "gnunet_testing_lib.h" | ||
40 | |||
41 | #ifdef __cplusplus | ||
42 | extern "C" | ||
43 | { | ||
44 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
45 | } | ||
46 | #endif | ||
47 | #endif | ||
48 | |||
49 | |||
50 | /** | ||
51 | * Opaque handle to a host running experiments managed by the testbed framework. | ||
52 | * The master process must be able to SSH to this host without password (via | ||
53 | * ssh-agent). | ||
54 | */ | ||
55 | struct GNUNET_TESTBED_Host; | ||
56 | |||
57 | /** | ||
58 | * Opaque handle to a peer controlled by the testbed framework. A peer runs | ||
59 | * at a particular host. | ||
60 | */ | ||
61 | struct GNUNET_TESTBED_Peer; | ||
62 | |||
63 | /** | ||
64 | * Opaque handle to an abstract operation to be executed by the testbed framework. | ||
65 | */ | ||
66 | struct GNUNET_TESTBED_Operation; | ||
67 | |||
68 | /** | ||
69 | * Handle to interact with a GNUnet testbed controller. Each | ||
70 | * controller has at least one master handle which is created when the | ||
71 | * controller is created; this master handle interacts with the | ||
72 | * controller process, destroying it destroys the controller (by | ||
73 | * closing stdin of the controller process). Additionally, | ||
74 | * controllers can interact with each other (in a P2P fashion); those | ||
75 | * links are established via TCP/IP on the controller's service port. | ||
76 | */ | ||
77 | struct GNUNET_TESTBED_Controller; | ||
78 | |||
79 | |||
80 | /** | ||
81 | * Create a host to run peers and controllers on. | ||
82 | * | ||
83 | * @param hostname name of the host, use "NULL" for localhost | ||
84 | * @param username username to use for the login; may be NULL | ||
85 | * @param cfg the configuration to use as a template while starting a controller | ||
86 | * on this host. Operation queue sizes specific to a host are also | ||
87 | * read from this configuration handle | ||
88 | * @param port port number to use for ssh; use 0 to let ssh decide | ||
89 | * @return handle to the host, NULL on error | ||
90 | */ | ||
91 | struct GNUNET_TESTBED_Host * | ||
92 | GNUNET_TESTBED_host_create (const char *hostname, | ||
93 | const char *username, | ||
94 | const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
95 | uint16_t port); | ||
96 | |||
97 | |||
98 | /** | ||
99 | * Create a host to run peers and controllers on. This function is used | ||
100 | * if a peer learns about a host via IPC between controllers (and thus | ||
101 | * some higher-level controller has already determined the unique IDs). | ||
102 | * | ||
103 | * @param id global host ID assigned to the host; 0 is | ||
104 | * reserved to always mean 'localhost' | ||
105 | * @param hostname name of the host, use "NULL" for localhost | ||
106 | * @param username username to use for the login; may be NULL | ||
107 | * @param cfg the configuration to use as a template while starting a controller | ||
108 | * on this host. Operation queue sizes specific to a host are also | ||
109 | * read from this configuration handle | ||
110 | * @param port port number to use for ssh; use 0 to let ssh decide | ||
111 | * @return handle to the host, NULL on error | ||
112 | */ | ||
113 | struct GNUNET_TESTBED_Host * | ||
114 | GNUNET_TESTBED_host_create_with_id (uint32_t id, | ||
115 | const char *hostname, | ||
116 | const char *username, | ||
117 | const struct GNUNET_CONFIGURATION_Handle | ||
118 | *cfg, | ||
119 | uint16_t port); | ||
120 | |||
121 | |||
122 | /** | ||
123 | * Load a set of hosts from a configuration file. The hostfile format is | ||
124 | * specified at https://gnunet.org/content/hosts-file-format | ||
125 | * | ||
126 | * @param filename file with the host specification | ||
127 | * @param cfg the configuration to use as a template while starting a controller | ||
128 | * on any of the loaded hosts. Operation queue sizes specific to a host | ||
129 | * are also read from this configuration handle | ||
130 | * @param hosts set to the hosts found in the file; caller must free this if | ||
131 | * number of hosts returned is greater than 0 | ||
132 | * @return number of hosts returned in 'hosts', 0 on error | ||
133 | */ | ||
134 | unsigned int | ||
135 | GNUNET_TESTBED_hosts_load_from_file (const char *filename, | ||
136 | const struct GNUNET_CONFIGURATION_Handle | ||
137 | *cfg, | ||
138 | struct GNUNET_TESTBED_Host ***hosts); | ||
139 | |||
140 | |||
141 | /** | ||
142 | * Destroy a host handle. Must only be called once everything | ||
143 | * running on that host has been stopped. | ||
144 | * | ||
145 | * @param host handle to destroy | ||
146 | */ | ||
147 | void | ||
148 | GNUNET_TESTBED_host_destroy (struct GNUNET_TESTBED_Host *host); | ||
149 | |||
150 | |||
151 | /** | ||
152 | * The handle for whether a host is habitable or not | ||
153 | */ | ||
154 | struct GNUNET_TESTBED_HostHabitableCheckHandle; | ||
155 | |||
156 | |||
157 | /** | ||
158 | * Callbacks of this type are called by GNUNET_TESTBED_is_host_habitable to | ||
159 | * inform whether the given host is habitable or not. The Handle returned by | ||
160 | * GNUNET_TESTBED_is_host_habitable() is invalid after this callback is called | ||
161 | * | ||
162 | * @param cls the closure given to GNUNET_TESTBED_is_host_habitable() | ||
163 | * @param host the host whose status is being reported; will be NULL if the host | ||
164 | * given to GNUNET_TESTBED_is_host_habitable() is NULL | ||
165 | * @param status GNUNET_YES if it is habitable; GNUNET_NO if not | ||
166 | */ | ||
167 | typedef void | ||
168 | (*GNUNET_TESTBED_HostHabitableCallback) (void *cls, | ||
169 | const struct GNUNET_TESTBED_Host *host, | ||
170 | int status); | ||
171 | |||
172 | |||
173 | /** | ||
174 | * Checks whether a host can be used to start testbed service | ||
175 | * | ||
176 | * @param host the host to check | ||
177 | * @param config the configuration handle to lookup the path of the testbed | ||
178 | * helper | ||
179 | * @param cb the callback to call to inform about habitability of the given host | ||
180 | * @param cb_cls the closure for the callback | ||
181 | * @return NULL upon any error or a handle which can be passed to | ||
182 | * GNUNET_TESTBED_is_host_habitable_cancel() | ||
183 | */ | ||
184 | struct GNUNET_TESTBED_HostHabitableCheckHandle * | ||
185 | GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host, | ||
186 | const struct GNUNET_CONFIGURATION_Handle | ||
187 | *config, | ||
188 | GNUNET_TESTBED_HostHabitableCallback cb, | ||
189 | void *cb_cls); | ||
190 | |||
191 | |||
192 | /** | ||
193 | * Function to cancel a request started using GNUNET_TESTBED_is_host_habitable() | ||
194 | * | ||
195 | * @param handle the habitability check handle | ||
196 | */ | ||
197 | void | ||
198 | GNUNET_TESTBED_is_host_habitable_cancel (struct | ||
199 | GNUNET_TESTBED_HostHabitableCheckHandle | ||
200 | *handle); | ||
201 | |||
202 | /** | ||
203 | * Obtain the host's hostname. | ||
204 | * | ||
205 | * @param host handle to the host, NULL means 'localhost' | ||
206 | * @return hostname of the host | ||
207 | */ | ||
208 | const char * | ||
209 | GNUNET_TESTBED_host_get_hostname (const struct GNUNET_TESTBED_Host *host); | ||
210 | |||
211 | |||
212 | /** | ||
213 | * Enumeration with (at most 64) possible event types that | ||
214 | * can be monitored using the testbed framework. | ||
215 | */ | ||
216 | enum GNUNET_TESTBED_EventType | ||
217 | { | ||
218 | /** | ||
219 | * A peer has been started. | ||
220 | */ | ||
221 | GNUNET_TESTBED_ET_PEER_START = 0, | ||
222 | |||
223 | /** | ||
224 | * A peer has been stopped. | ||
225 | */ | ||
226 | GNUNET_TESTBED_ET_PEER_STOP = 1, | ||
227 | |||
228 | /** | ||
229 | * A connection between two peers was established. | ||
230 | */ | ||
231 | GNUNET_TESTBED_ET_CONNECT = 2, | ||
232 | |||
233 | /** | ||
234 | * A connection between two peers was torn down. | ||
235 | */ | ||
236 | GNUNET_TESTBED_ET_DISCONNECT = 3, | ||
237 | |||
238 | /** | ||
239 | * A requested testbed operation has been completed. | ||
240 | */ | ||
241 | GNUNET_TESTBED_ET_OPERATION_FINISHED = 4, | ||
242 | }; | ||
243 | |||
244 | |||
245 | /** | ||
246 | * Types of information that can be requested about a peer. | ||
247 | */ | ||
248 | enum GNUNET_TESTBED_PeerInformationType | ||
249 | { | ||
250 | /** | ||
251 | * Special value (not valid for requesting information) | ||
252 | * that is used in the event struct if a 'generic' pointer | ||
253 | * is returned (for other operations not related to this | ||
254 | * enumeration). | ||
255 | */ | ||
256 | GNUNET_TESTBED_PIT_GENERIC = 0, | ||
257 | |||
258 | /** | ||
259 | * What configuration is the peer using? Returns a 'const struct | ||
260 | * GNUNET_CONFIGURATION_Handle *'. Valid until | ||
261 | * 'GNUNET_TESTNIG_operation_done' is called. However, the | ||
262 | * values may be inaccurate if the peer is reconfigured in | ||
263 | * the meantime. | ||
264 | */ | ||
265 | GNUNET_TESTBED_PIT_CONFIGURATION, | ||
266 | |||
267 | /** | ||
268 | * What is the identity of the peer? Returns a | ||
269 | * 'const struct GNUNET_PeerIdentity *'. Valid until | ||
270 | * 'GNUNET_TESTNIG_operation_done' is called. | ||
271 | */ | ||
272 | GNUNET_TESTBED_PIT_IDENTITY | ||
273 | }; | ||
274 | |||
275 | |||
276 | /** | ||
277 | * Argument to GNUNET_TESTBED_ControllerCallback with details about | ||
278 | * the event. | ||
279 | */ | ||
280 | struct GNUNET_TESTBED_EventInformation | ||
281 | { | ||
282 | /** | ||
283 | * Type of the event. | ||
284 | */ | ||
285 | enum GNUNET_TESTBED_EventType type; | ||
286 | |||
287 | /** | ||
288 | * Handle for the corresponding operation that generated this event | ||
289 | */ | ||
290 | struct GNUNET_TESTBED_Operation *op; | ||
291 | |||
292 | /** | ||
293 | * Closure given while creating the above operation | ||
294 | */ | ||
295 | void *op_cls; | ||
296 | |||
297 | /** | ||
298 | * Details about the event. | ||
299 | */ | ||
300 | union | ||
301 | { | ||
302 | /** | ||
303 | * Details about peer start event. | ||
304 | */ | ||
305 | struct | ||
306 | { | ||
307 | /** | ||
308 | * Handle for the host where the peer | ||
309 | * was started. | ||
310 | */ | ||
311 | struct GNUNET_TESTBED_Host *host; | ||
312 | |||
313 | /** | ||
314 | * Handle for the peer that was started. | ||
315 | */ | ||
316 | struct GNUNET_TESTBED_Peer *peer; | ||
317 | } peer_start; | ||
318 | |||
319 | /** | ||
320 | * Details about peer stop event. | ||
321 | */ | ||
322 | struct | ||
323 | { | ||
324 | /** | ||
325 | * Handle for the peer that was started. | ||
326 | */ | ||
327 | struct GNUNET_TESTBED_Peer *peer; | ||
328 | } peer_stop; | ||
329 | |||
330 | /** | ||
331 | * Details about connect event. | ||
332 | */ | ||
333 | struct | ||
334 | { | ||
335 | /** | ||
336 | * Handle for one of the connected peers. | ||
337 | */ | ||
338 | struct GNUNET_TESTBED_Peer *peer1; | ||
339 | |||
340 | /** | ||
341 | * Handle for one of the connected peers. | ||
342 | */ | ||
343 | struct GNUNET_TESTBED_Peer *peer2; | ||
344 | } peer_connect; | ||
345 | |||
346 | /** | ||
347 | * Details about disconnect event. | ||
348 | */ | ||
349 | struct | ||
350 | { | ||
351 | /** | ||
352 | * Handle for one of the disconnected peers. | ||
353 | */ | ||
354 | struct GNUNET_TESTBED_Peer *peer1; | ||
355 | |||
356 | /** | ||
357 | * Handle for one of the disconnected peers. | ||
358 | */ | ||
359 | struct GNUNET_TESTBED_Peer *peer2; | ||
360 | } peer_disconnect; | ||
361 | |||
362 | /** | ||
363 | * Details about an operation finished event. | ||
364 | */ | ||
365 | struct | ||
366 | { | ||
367 | /** | ||
368 | * Error message for the operation, NULL on success. | ||
369 | */ | ||
370 | const char *emsg; | ||
371 | |||
372 | /** | ||
373 | * No result (NULL pointer) or generic result | ||
374 | * (whatever the GNUNET_TESTBED_ConnectAdapter returned). | ||
375 | */ | ||
376 | void *generic; | ||
377 | } operation_finished; | ||
378 | } details; | ||
379 | }; | ||
380 | |||
381 | |||
382 | /** | ||
383 | * Signature of the event handler function called by the | ||
384 | * respective event controller. | ||
385 | * | ||
386 | * @param cls closure | ||
387 | * @param event information about the event | ||
388 | */ | ||
389 | typedef void | ||
390 | (*GNUNET_TESTBED_ControllerCallback)(void *cls, | ||
391 | const struct | ||
392 | GNUNET_TESTBED_EventInformation *event); | ||
393 | |||
394 | |||
395 | /** | ||
396 | * Opaque Handle for Controller process | ||
397 | */ | ||
398 | struct GNUNET_TESTBED_ControllerProc; | ||
399 | |||
400 | |||
401 | /** | ||
402 | * Callback to signal successful startup of the controller process | ||
403 | * | ||
404 | * @param cls the closure from GNUNET_TESTBED_controller_start() | ||
405 | * @param cfg the configuration with which the controller has been started; | ||
406 | * NULL if status is not #GNUNET_OK | ||
407 | * @param status #GNUNET_OK if the startup is successful; #GNUNET_SYSERR if not, | ||
408 | * GNUNET_TESTBED_controller_stop() shouldn't be called in this case | ||
409 | */ | ||
410 | typedef void | ||
411 | (*GNUNET_TESTBED_ControllerStatusCallback) (void *cls, | ||
412 | const struct | ||
413 | GNUNET_CONFIGURATION_Handle *cfg, | ||
414 | int status); | ||
415 | |||
416 | |||
417 | /** | ||
418 | * Starts a controller process at the given host. The given host's configuration | ||
419 | * is used as a Template configuration to use for the remote controller; the | ||
420 | * remote controller will be started with a slightly modified configuration | ||
421 | * (port numbers, unix domain sockets and service home values are changed as per | ||
422 | * TESTING library on the remote host). The modified configuration replaces the | ||
423 | * host's existing configuration before signalling success through the | ||
424 | * GNUNET_TESTBED_ControllerStatusCallback() | ||
425 | * | ||
426 | * @param trusted_ip the ip address of the controller which will be set as TRUSTED | ||
427 | * HOST(all connections form this ip are permitted by the testbed) when | ||
428 | * starting testbed controller at host. This can either be a single ip | ||
429 | * address or a network address in CIDR notation. | ||
430 | * @param host the host where the controller has to be started. CANNOT be NULL. | ||
431 | * @param cb function called when the controller is successfully started or | ||
432 | * dies unexpectedly; GNUNET_TESTBED_controller_stop shouldn't be | ||
433 | * called if cb is called with GNUNET_SYSERR as status. Will never be | ||
434 | * called in the same task as 'GNUNET_TESTBED_controller_start' | ||
435 | * (synchronous errors will be signalled by returning NULL). This | ||
436 | * parameter cannot be NULL. | ||
437 | * @param cls closure for above callbacks | ||
438 | * @return the controller process handle, NULL on errors | ||
439 | */ | ||
440 | struct GNUNET_TESTBED_ControllerProc * | ||
441 | GNUNET_TESTBED_controller_start (const char *trusted_ip, | ||
442 | struct GNUNET_TESTBED_Host *host, | ||
443 | GNUNET_TESTBED_ControllerStatusCallback cb, | ||
444 | void *cls); | ||
445 | |||
446 | |||
447 | /** | ||
448 | * Stop the controller process (also will terminate all peers and controllers | ||
449 | * dependent on this controller). This function blocks until the testbed has | ||
450 | * been fully terminated (!). The controller status cb from | ||
451 | * GNUNET_TESTBED_controller_start() will not be called. | ||
452 | * | ||
453 | * @param cproc the controller process handle | ||
454 | */ | ||
455 | void | ||
456 | GNUNET_TESTBED_controller_stop (struct GNUNET_TESTBED_ControllerProc *cproc); | ||
457 | |||
458 | |||
459 | /** | ||
460 | * Connect to a controller process. The configuration to use for the connection | ||
461 | * is retrieved from the given host where a controller is started using | ||
462 | * GNUNET_TESTBED_controller_start(). | ||
463 | * | ||
464 | * @param host host to run the controller on; This should be the same host if | ||
465 | * the controller was previously started with | ||
466 | * GNUNET_TESTBED_controller_start() | ||
467 | * @param event_mask bit mask with set of events to call 'cc' for; | ||
468 | * or-ed values of "1LL" shifted by the | ||
469 | * respective 'enum GNUNET_TESTBED_EventType' | ||
470 | * (e.g. "(1LL << GNUNET_TESTBED_ET_CONNECT) | ...") | ||
471 | * @param cc controller callback to invoke on events | ||
472 | * @param cc_cls closure for cc | ||
473 | * @return handle to the controller | ||
474 | */ | ||
475 | struct GNUNET_TESTBED_Controller * | ||
476 | GNUNET_TESTBED_controller_connect (struct GNUNET_TESTBED_Host *host, | ||
477 | uint64_t event_mask, | ||
478 | GNUNET_TESTBED_ControllerCallback cc, | ||
479 | void *cc_cls); | ||
480 | |||
481 | |||
482 | /** | ||
483 | * Stop the given controller (also will terminate all peers and | ||
484 | * controllers dependent on this controller). This function | ||
485 | * blocks until the testbed has been fully terminated (!). | ||
486 | * | ||
487 | * @param c handle to controller to stop | ||
488 | */ | ||
489 | void | ||
490 | GNUNET_TESTBED_controller_disconnect (struct GNUNET_TESTBED_Controller *c); | ||
491 | |||
492 | |||
493 | /** | ||
494 | * Opaque handle for host registration | ||
495 | */ | ||
496 | struct GNUNET_TESTBED_HostRegistrationHandle; | ||
497 | |||
498 | |||
499 | /** | ||
500 | * Callback which will be called to after a host registration succeeded or failed | ||
501 | * | ||
502 | * @param cls the closure | ||
503 | * @param emsg the error message; NULL if host registration is successful | ||
504 | */ | ||
505 | typedef void | ||
506 | (*GNUNET_TESTBED_HostRegistrationCompletion) (void *cls, | ||
507 | const char *emsg); | ||
508 | |||
509 | |||
510 | /** | ||
511 | * Register a host with the controller. This makes the controller aware of the | ||
512 | * host. A host should be registered at the controller before starting a | ||
513 | * sub-controller on that host using GNUNET_TESTBED_controller_link(). | ||
514 | * | ||
515 | * @param controller the controller handle | ||
516 | * @param host the host to register | ||
517 | * @param cc the completion callback to call to inform the status of | ||
518 | * registration. After calling this callback the registration handle | ||
519 | * will be invalid. Cannot be NULL | ||
520 | * @param cc_cls the closure for the cc | ||
521 | * @return handle to the host registration which can be used to cancel the | ||
522 | * registration; NULL if another registration handle is present and | ||
523 | * is not cancelled | ||
524 | */ | ||
525 | struct GNUNET_TESTBED_HostRegistrationHandle * | ||
526 | GNUNET_TESTBED_register_host (struct GNUNET_TESTBED_Controller *controller, | ||
527 | struct GNUNET_TESTBED_Host *host, | ||
528 | GNUNET_TESTBED_HostRegistrationCompletion cc, | ||
529 | void *cc_cls); | ||
530 | |||
531 | |||
532 | /** | ||
533 | * Cancel the pending registration. Note that the registration message will | ||
534 | * already be queued to be sent to the service, cancellation has only the | ||
535 | * effect that the registration completion callback for the registration is | ||
536 | * never called and from our perspective the host is not registered until the | ||
537 | * completion callback is called. | ||
538 | * | ||
539 | * @param handle the registration handle to cancel | ||
540 | */ | ||
541 | void | ||
542 | GNUNET_TESTBED_cancel_registration (struct GNUNET_TESTBED_HostRegistrationHandle | ||
543 | *handle); | ||
544 | |||
545 | |||
546 | /** | ||
547 | * Callback to be called when an operation is completed | ||
548 | * | ||
549 | * @param cls the callback closure from functions generating an operation | ||
550 | * @param op the operation that has been finished | ||
551 | * @param emsg error message in case the operation has failed; will be NULL if | ||
552 | * operation has executed successfully. | ||
553 | */ | ||
554 | typedef void | ||
555 | (*GNUNET_TESTBED_OperationCompletionCallback) (void *cls, | ||
556 | struct GNUNET_TESTBED_Operation * | ||
557 | op, | ||
558 | const char *emsg); | ||
559 | |||
560 | |||
561 | /** | ||
562 | * Create a link from slave controller to delegated controller. Whenever the | ||
563 | * master controller is asked to start a peer at the delegated controller the | ||
564 | * request will be routed towards slave controller (if a route exists). The | ||
565 | * slave controller will then route it to the delegated controller. The | ||
566 | * configuration of the delegated controller is given and is used to either | ||
567 | * create the delegated controller or to connect to an existing controller. Note | ||
568 | * that while starting the delegated controller the configuration will be | ||
569 | * modified to accommodate available free ports. the 'is_subordinate' specifies | ||
570 | * if the given delegated controller should be started and managed by the slave | ||
571 | * controller, or if the delegated controller already has a master and the slave | ||
572 | * controller connects to it as a non master controller. The success or failure | ||
573 | * of this operation will be signalled through the | ||
574 | * GNUNET_TESTBED_ControllerCallback() with an event of type | ||
575 | * #GNUNET_TESTBED_ET_OPERATION_FINISHED | ||
576 | * | ||
577 | * @param op_cls the operation closure for the event which is generated to | ||
578 | * signal success or failure of this operation | ||
579 | * @param master handle to the master controller who creates the association | ||
580 | * @param delegated_host requests to which host should be delegated; cannot be NULL | ||
581 | * @param slave_host which host is used to run the slave controller; use NULL to | ||
582 | * make the master controller connect to the delegated host | ||
583 | * @param is_subordinate #GNUNET_YES if the controller at delegated_host should | ||
584 | * be started by the slave controller; #GNUNET_NO if the slave | ||
585 | * controller has to connect to the already started delegated | ||
586 | * controller via TCP/IP | ||
587 | * @return the operation handle | ||
588 | */ | ||
589 | struct GNUNET_TESTBED_Operation * | ||
590 | GNUNET_TESTBED_controller_link (void *op_cls, | ||
591 | struct GNUNET_TESTBED_Controller *master, | ||
592 | struct GNUNET_TESTBED_Host *delegated_host, | ||
593 | struct GNUNET_TESTBED_Host *slave_host, | ||
594 | int is_subordinate); | ||
595 | |||
596 | |||
597 | /** | ||
598 | * Function to acquire the configuration of a running slave controller. The | ||
599 | * completion of the operation is signalled through the controller_cb from | ||
600 | * GNUNET_TESTBED_controller_connect(). If the operation is successful the | ||
601 | * handle to the configuration is available in the generic pointer of | ||
602 | * operation_finished field of `struct GNUNET_TESTBED_EventInformation`. | ||
603 | * | ||
604 | * @param op_cls the closure for the operation | ||
605 | * @param master the handle to master controller | ||
606 | * @param slave_host the host where the slave controller is running; the handle | ||
607 | * to the slave_host should remain valid until this operation is | ||
608 | * cancelled or marked as finished | ||
609 | * @return the operation handle; NULL if the slave_host is not registered at | ||
610 | * master | ||
611 | */ | ||
612 | struct GNUNET_TESTBED_Operation * | ||
613 | GNUNET_TESTBED_get_slave_config (void *op_cls, | ||
614 | struct GNUNET_TESTBED_Controller *master, | ||
615 | struct GNUNET_TESTBED_Host *slave_host); | ||
616 | |||
617 | |||
618 | /** | ||
619 | * Functions of this signature are called when a peer has been successfully | ||
620 | * created | ||
621 | * | ||
622 | * @param cls the closure from GNUNET_TESTBED_peer_create() | ||
623 | * @param peer the handle for the created peer; NULL on any error during | ||
624 | * creation | ||
625 | * @param emsg NULL if peer is not NULL; else MAY contain the error description | ||
626 | */ | ||
627 | typedef void | ||
628 | (*GNUNET_TESTBED_PeerCreateCallback) (void *cls, | ||
629 | struct GNUNET_TESTBED_Peer *peer, | ||
630 | const char *emsg); | ||
631 | |||
632 | |||
633 | /** | ||
634 | * Create the given peer at the specified host using the given | ||
635 | * controller. If the given controller is not running on the target | ||
636 | * host, it should find or create a controller at the target host and | ||
637 | * delegate creating the peer. Explicit delegation paths can be setup | ||
638 | * using 'GNUNET_TESTBED_controller_link'. If no explicit delegation | ||
639 | * path exists, a direct link with a subordinate controller is setup | ||
640 | * for the first delegated peer to a particular host; the subordinate | ||
641 | * controller is then destroyed once the last peer that was delegated | ||
642 | * to the remote host is stopped. | ||
643 | * | ||
644 | * Creating the peer only creates the handle to manipulate and further | ||
645 | * configure the peer; use #GNUNET_TESTBED_peer_start and | ||
646 | * #GNUNET_TESTBED_peer_stop to actually start/stop the peer's | ||
647 | * processes. | ||
648 | * | ||
649 | * Note that the given configuration will be adjusted by the | ||
650 | * controller to avoid port/path conflicts with other peers. | ||
651 | * The "final" configuration can be obtained using | ||
652 | * #GNUNET_TESTBED_peer_get_information. | ||
653 | * | ||
654 | * @param controller controller process to use | ||
655 | * @param host host to run the peer on; cannot be NULL | ||
656 | * @param cfg Template configuration to use for the peer. Should exist until | ||
657 | * operation is cancelled or GNUNET_TESTBED_operation_done() is called | ||
658 | * @param cb the callback to call when the peer has been created | ||
659 | * @param cls the closure to the above callback | ||
660 | * @return the operation handle | ||
661 | */ | ||
662 | struct GNUNET_TESTBED_Operation * | ||
663 | GNUNET_TESTBED_peer_create (struct GNUNET_TESTBED_Controller *controller, | ||
664 | struct GNUNET_TESTBED_Host *host, | ||
665 | const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
666 | GNUNET_TESTBED_PeerCreateCallback cb, | ||
667 | void *cls); | ||
668 | |||
669 | |||
670 | /** | ||
671 | * Functions of this signature are called when a peer has been successfully | ||
672 | * started or stopped. | ||
673 | * | ||
674 | * @param cls the closure from GNUNET_TESTBED_peer_start/stop() | ||
675 | * @param emsg NULL on success; otherwise an error description | ||
676 | */ | ||
677 | typedef void | ||
678 | (*GNUNET_TESTBED_PeerChurnCallback) (void *cls, | ||
679 | const char *emsg); | ||
680 | |||
681 | |||
682 | /** | ||
683 | * Start the given peer. | ||
684 | * | ||
685 | * @param op_cls the closure for this operation; will be set in the event | ||
686 | * information | ||
687 | * @param peer peer to start | ||
688 | * @param pcc function to call upon completion | ||
689 | * @param pcc_cls closure for 'pcc' | ||
690 | * @return handle to the operation | ||
691 | */ | ||
692 | struct GNUNET_TESTBED_Operation * | ||
693 | GNUNET_TESTBED_peer_start (void *op_cls, | ||
694 | struct GNUNET_TESTBED_Peer *peer, | ||
695 | GNUNET_TESTBED_PeerChurnCallback pcc, | ||
696 | void *pcc_cls); | ||
697 | |||
698 | |||
699 | /** | ||
700 | * Stop the given peer. The handle remains valid (use | ||
701 | * #GNUNET_TESTBED_peer_destroy to fully clean up the | ||
702 | * state of the peer). | ||
703 | * | ||
704 | * @param op_cls the closure for this operation; will be set in the event | ||
705 | * information | ||
706 | * @param peer peer to stop | ||
707 | * @param pcc function to call upon completion | ||
708 | * @param pcc_cls closure for 'pcc' | ||
709 | * @return handle to the operation | ||
710 | */ | ||
711 | struct GNUNET_TESTBED_Operation * | ||
712 | GNUNET_TESTBED_peer_stop (void *op_cls, | ||
713 | struct GNUNET_TESTBED_Peer *peer, | ||
714 | GNUNET_TESTBED_PeerChurnCallback pcc, | ||
715 | void *pcc_cls); | ||
716 | |||
717 | |||
718 | /** | ||
719 | * Data returned from GNUNET_TESTBED_peer_get_information | ||
720 | */ | ||
721 | struct GNUNET_TESTBED_PeerInformation | ||
722 | { | ||
723 | /** | ||
724 | * Peer information type; captures which of the types | ||
725 | * in the 'op_result' is actually in use. | ||
726 | */ | ||
727 | enum GNUNET_TESTBED_PeerInformationType pit; | ||
728 | |||
729 | /** | ||
730 | * The result of the get information operation; Choose according to the pit | ||
731 | */ | ||
732 | union | ||
733 | { | ||
734 | /** | ||
735 | * The configuration of the peer | ||
736 | */ | ||
737 | struct GNUNET_CONFIGURATION_Handle *cfg; | ||
738 | |||
739 | /** | ||
740 | * The identity of the peer | ||
741 | */ | ||
742 | struct GNUNET_PeerIdentity *id; | ||
743 | } result; | ||
744 | }; | ||
745 | |||
746 | |||
747 | /** | ||
748 | * Callback to be called when the requested peer information is available | ||
749 | * The peer information in the callback is valid until the operation 'op' is canceled. | ||
750 | * | ||
751 | * @param cb_cls the closure from GNUNET_TETSBED_peer_get_information() | ||
752 | * @param op the operation this callback corresponds to | ||
753 | * @param pinfo the result; will be NULL if the operation has failed | ||
754 | * @param emsg error message if the operation has failed; will be NULL if the | ||
755 | * operation is successful | ||
756 | */ | ||
757 | typedef void | ||
758 | (*GNUNET_TESTBED_PeerInfoCallback) (void *cb_cls, | ||
759 | struct GNUNET_TESTBED_Operation *op, | ||
760 | const struct | ||
761 | GNUNET_TESTBED_PeerInformation *pinfo, | ||
762 | const char *emsg); | ||
763 | |||
764 | |||
765 | /** | ||
766 | * Request information about a peer. The controller callback will not be called | ||
767 | * with event type #GNUNET_TESTBED_ET_OPERATION_FINISHED when result for this | ||
768 | * operation is available. Instead, the GNUNET_TESTBED_PeerInfoCallback() will | ||
769 | * be called. | ||
770 | * The peer information in the callback is valid until the operation is canceled. | ||
771 | * | ||
772 | * @param peer peer to request information about | ||
773 | * @param pit desired information | ||
774 | * @param cb the convenience callback to be called when results for this | ||
775 | * operation are available | ||
776 | * @param cb_cls the closure for @a cb | ||
777 | * @return handle to the operation | ||
778 | */ | ||
779 | struct GNUNET_TESTBED_Operation * | ||
780 | GNUNET_TESTBED_peer_get_information (struct GNUNET_TESTBED_Peer *peer, | ||
781 | enum GNUNET_TESTBED_PeerInformationType | ||
782 | pit, | ||
783 | GNUNET_TESTBED_PeerInfoCallback cb, | ||
784 | void *cb_cls); | ||
785 | |||
786 | |||
787 | /** | ||
788 | * Change @a peer configuration. Ports and paths cannot be changed this | ||
789 | * way. | ||
790 | * | ||
791 | * @param peer peer to change configuration for | ||
792 | * @param cfg new configuration | ||
793 | * @return handle to the operation | ||
794 | */ | ||
795 | struct GNUNET_TESTBED_Operation * | ||
796 | GNUNET_TESTBED_peer_update_configuration (struct GNUNET_TESTBED_Peer *peer, | ||
797 | const struct | ||
798 | GNUNET_CONFIGURATION_Handle *cfg); | ||
799 | |||
800 | |||
801 | /** | ||
802 | * Destroy the given peer; the peer should have been | ||
803 | * stopped first (if it was started). | ||
804 | * | ||
805 | * @param peer peer to stop | ||
806 | * @return handle to the operation | ||
807 | */ | ||
808 | struct GNUNET_TESTBED_Operation * | ||
809 | GNUNET_TESTBED_peer_destroy (struct GNUNET_TESTBED_Peer *peer); | ||
810 | |||
811 | |||
812 | /** | ||
813 | * Start or stop given service at a peer. This should not be called to | ||
814 | * start/stop the peer's ARM service. Use GNUNET_TESTBED_peer_start(), | ||
815 | * GNUNET_TESTBED_peer_stop() for starting/stopping peer's ARM service. Success | ||
816 | * or failure of the generated operation is signalled through the controller | ||
817 | * event callback and/or operation completion callback. | ||
818 | * | ||
819 | * @param op_cls the closure for the operation | ||
820 | * @param peer the peer whose service is to be started/stopped | ||
821 | * @param service_name the name of the service | ||
822 | * @param cb the operation completion callback | ||
823 | * @param cb_cls the closure for @a cb | ||
824 | * @param start 1 to start the service; 0 to stop the service | ||
825 | * @return an operation handle; NULL upon error (peer not running) | ||
826 | */ | ||
827 | struct GNUNET_TESTBED_Operation * | ||
828 | GNUNET_TESTBED_peer_manage_service (void *op_cls, | ||
829 | struct GNUNET_TESTBED_Peer *peer, | ||
830 | const char *service_name, | ||
831 | GNUNET_TESTBED_OperationCompletionCallback | ||
832 | cb, | ||
833 | void *cb_cls, | ||
834 | unsigned int start); | ||
835 | |||
836 | |||
837 | /** | ||
838 | * Stops and destroys all peers. Is equivalent of calling | ||
839 | * GNUNET_TESTBED_peer_stop() and GNUNET_TESTBED_peer_destroy() on all peers, | ||
840 | * except that the peer stop event and operation finished event corresponding to | ||
841 | * the respective functions are not generated. This function should be called | ||
842 | * when there are no other pending operations. If there are pending operations, | ||
843 | * it will return NULL | ||
844 | * | ||
845 | * @param c the controller to send this message to | ||
846 | * @param op_cls closure for the operation | ||
847 | * @param cb the callback to call when all peers are stopped and destroyed | ||
848 | * @param cb_cls the closure for the callback | ||
849 | * @return operation handle on success; NULL if any pending operations are | ||
850 | * present | ||
851 | */ | ||
852 | struct GNUNET_TESTBED_Operation * | ||
853 | GNUNET_TESTBED_shutdown_peers (struct GNUNET_TESTBED_Controller *c, | ||
854 | void *op_cls, | ||
855 | GNUNET_TESTBED_OperationCompletionCallback cb, | ||
856 | void *cb_cls); | ||
857 | |||
858 | |||
859 | /** | ||
860 | * Options for peer connections. | ||
861 | */ | ||
862 | enum GNUNET_TESTBED_ConnectOption | ||
863 | { | ||
864 | /** | ||
865 | * No option (not valid as an argument). | ||
866 | */ | ||
867 | GNUNET_TESTBED_CO_NONE = 0, | ||
868 | |||
869 | /** | ||
870 | * Allow or disallow a connection between the specified peers. | ||
871 | * Followed by #GNUNET_NO (int) if a connection is disallowed | ||
872 | * or #GNUNET_YES if a connection is allowed. Note that the | ||
873 | * default (all connections allowed or disallowed) is | ||
874 | * specified in the configuration of the controller. | ||
875 | */ | ||
876 | GNUNET_TESTBED_CO_ALLOW = 1, | ||
877 | |||
878 | /** | ||
879 | * FIXME: add (and implement) options to limit connection to | ||
880 | * particular transports, force simulation of particular latencies | ||
881 | * or message loss rates, or set bandwidth limitations. | ||
882 | */ | ||
883 | }; | ||
884 | |||
885 | |||
886 | /** | ||
887 | * Manipulate the P2P underlay topology by configuring a link | ||
888 | * between two peers. | ||
889 | * | ||
890 | * @param op_cls closure argument to give with the operation event | ||
891 | * @param p1 first peer | ||
892 | * @param p2 second peer | ||
893 | * @param co option to change | ||
894 | * @param ap option-specific values | ||
895 | * @return handle to the operation, NULL if configuring the link at this | ||
896 | * time is not allowed | ||
897 | */ | ||
898 | struct GNUNET_TESTBED_Operation * | ||
899 | GNUNET_TESTBED_underlay_configure_link_va (void *op_cls, | ||
900 | struct GNUNET_TESTBED_Peer *p1, | ||
901 | struct GNUNET_TESTBED_Peer *p2, | ||
902 | enum GNUNET_TESTBED_ConnectOption co, | ||
903 | va_list ap); | ||
904 | |||
905 | |||
906 | /** | ||
907 | * Manipulate the P2P underlay topology by configuring a link | ||
908 | * between two peers. | ||
909 | * | ||
910 | * @param op_cls closure argument to give with the operation event | ||
911 | * @param p1 first peer | ||
912 | * @param p2 second peer | ||
913 | * @param co option to change | ||
914 | * @param ... option-specific values | ||
915 | * @return handle to the operation, NULL if configuring the link at this | ||
916 | * time is not allowed | ||
917 | */ | ||
918 | struct GNUNET_TESTBED_Operation * | ||
919 | GNUNET_TESTBED_underlay_configure_link (void *op_cls, | ||
920 | struct GNUNET_TESTBED_Peer *p1, | ||
921 | struct GNUNET_TESTBED_Peer *p2, | ||
922 | enum GNUNET_TESTBED_ConnectOption co, | ||
923 | ...); | ||
924 | |||
925 | |||
926 | /** | ||
927 | * Topologies and topology options supported for testbeds. Options should always | ||
928 | * end with #GNUNET_TESTBED_TOPOLOGY_OPTION_END | ||
929 | */ | ||
930 | enum GNUNET_TESTBED_TopologyOption | ||
931 | { | ||
932 | /** | ||
933 | * A clique (everyone connected to everyone else). No options. If there are N | ||
934 | * peers this topology results in (N * (N -1)) connections. | ||
935 | */ | ||
936 | GNUNET_TESTBED_TOPOLOGY_CLIQUE, | ||
937 | |||
938 | /** | ||
939 | * Small-world network (2d torus plus random links). Followed | ||
940 | * by the number of random links to add (unsigned int). | ||
941 | */ | ||
942 | GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD, | ||
943 | |||
944 | /** | ||
945 | * Small-world network (ring plus random links). Followed | ||
946 | * by the number of random links to add (unsigned int). | ||
947 | */ | ||
948 | GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD_RING, | ||
949 | |||
950 | /** | ||
951 | * Ring topology. No options. | ||
952 | */ | ||
953 | GNUNET_TESTBED_TOPOLOGY_RING, | ||
954 | |||
955 | /** | ||
956 | * Star topology. No options. | ||
957 | */ | ||
958 | GNUNET_TESTBED_TOPOLOGY_STAR, | ||
959 | |||
960 | /** | ||
961 | * 2-d torus. No options. | ||
962 | */ | ||
963 | GNUNET_TESTBED_TOPOLOGY_2D_TORUS, | ||
964 | |||
965 | /** | ||
966 | * Random graph. Followed by the number of random links to be established | ||
967 | * (unsigned int) | ||
968 | */ | ||
969 | GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI, | ||
970 | |||
971 | /** | ||
972 | * Certain percentage of peers are unable to communicate directly | ||
973 | * replicating NAT conditions. Followed by the fraction of | ||
974 | * NAT'ed peers (float). | ||
975 | */ | ||
976 | GNUNET_TESTBED_TOPOLOGY_INTERNAT, | ||
977 | |||
978 | /** | ||
979 | * Scale free topology. It is generated according to the method described in | ||
980 | * "Emergence of Scaling in Random Networks." Science 286, 509-512, 1999. | ||
981 | * | ||
982 | * This options takes two arguments in the following order: an uint16_t to | ||
983 | * determine the maximum number of edges a peer is permitted to have while | ||
984 | * generating scale free topology, a good value for this argument is 70; and | ||
985 | * an uint8_t to determine the number of edges to be established when adding a | ||
986 | * new node to the scale free network, a good value for this argument is 4. | ||
987 | */ | ||
988 | GNUNET_TESTBED_TOPOLOGY_SCALE_FREE, | ||
989 | |||
990 | /** | ||
991 | * Straight line topology. No options. | ||
992 | */ | ||
993 | GNUNET_TESTBED_TOPOLOGY_LINE, | ||
994 | |||
995 | /** | ||
996 | * Read a topology from a given file. Followed by the name of the file (const char *). | ||
997 | */ | ||
998 | GNUNET_TESTBED_TOPOLOGY_FROM_FILE, | ||
999 | |||
1000 | /** | ||
1001 | * All peers are disconnected. No options. | ||
1002 | */ | ||
1003 | GNUNET_TESTBED_TOPOLOGY_NONE, | ||
1004 | |||
1005 | /** | ||
1006 | * The options should always end with this | ||
1007 | */ | ||
1008 | GNUNET_TESTBED_TOPOLOGY_OPTION_END, | ||
1009 | |||
1010 | /* The following are not topologies but influence how the topology has to be | ||
1011 | setup. These options should follow the topology specific options (if | ||
1012 | required by the chosen topology). Note that these should be given before | ||
1013 | GNUNET_TESTBED_TOPOLOGY_OPTION_END */ | ||
1014 | |||
1015 | /** | ||
1016 | * How many times should the failed overlay connect operations be retried | ||
1017 | * before giving up. The default if this option is not specified is to retry | ||
1018 | * 3 times. This option takes and unsigned integer as a parameter. Use this | ||
1019 | * option with parameter 0 to disable retrying of failed overlay connect | ||
1020 | * operations. | ||
1021 | */ | ||
1022 | GNUNET_TESTBED_TOPOLOGY_RETRY_CNT | ||
1023 | }; | ||
1024 | |||
1025 | |||
1026 | /** | ||
1027 | * Configure overall network topology to have a particular shape. | ||
1028 | * | ||
1029 | * @param op_cls closure argument to give with the operation event | ||
1030 | * @param num_peers number of peers in 'peers' | ||
1031 | * @param peers array of 'num_peers' with the peers to configure | ||
1032 | * @param topo desired underlay topology to use | ||
1033 | * @param ap topology-specific options | ||
1034 | * @return handle to the operation, NULL if configuring the topology | ||
1035 | * is not allowed at this time | ||
1036 | */ | ||
1037 | struct GNUNET_TESTBED_Operation * | ||
1038 | GNUNET_TESTBED_underlay_configure_topology_va (void *op_cls, | ||
1039 | unsigned int num_peers, | ||
1040 | struct GNUNET_TESTBED_Peer ** | ||
1041 | peers, | ||
1042 | enum | ||
1043 | GNUNET_TESTBED_TopologyOption | ||
1044 | topo, | ||
1045 | va_list ap); | ||
1046 | |||
1047 | |||
1048 | /** | ||
1049 | * Configure overall network topology to have a particular shape. | ||
1050 | * | ||
1051 | * @param op_cls closure argument to give with the operation event | ||
1052 | * @param num_peers number of peers in 'peers' | ||
1053 | * @param peers array of 'num_peers' with the peers to configure | ||
1054 | * @param topo desired underlay topology to use | ||
1055 | * @param ... topology-specific options | ||
1056 | * @return handle to the operation, NULL if configuring the topology | ||
1057 | * is not allowed at this time | ||
1058 | */ | ||
1059 | struct GNUNET_TESTBED_Operation * | ||
1060 | GNUNET_TESTBED_underlay_configure_topology (void *op_cls, | ||
1061 | unsigned int num_peers, | ||
1062 | struct GNUNET_TESTBED_Peer **peers, | ||
1063 | enum GNUNET_TESTBED_TopologyOption | ||
1064 | topo, | ||
1065 | ...); | ||
1066 | |||
1067 | |||
1068 | /** | ||
1069 | * Both peers must have been started before calling this function. | ||
1070 | * This function then obtains a HELLO from @a p1, gives it to @a p2 | ||
1071 | * and asks @a p2 to connect to @a p1. | ||
1072 | * | ||
1073 | * @param op_cls closure argument to give with the operation event | ||
1074 | * @param cb the callback to call when this operation has finished | ||
1075 | * @param cb_cls the closure for @a cb | ||
1076 | * @param p1 first peer | ||
1077 | * @param p2 second peer | ||
1078 | * @return handle to the operation, NULL if connecting these two | ||
1079 | * peers is fundamentally not possible at this time (peers | ||
1080 | * not running or underlay disallows) | ||
1081 | */ | ||
1082 | struct GNUNET_TESTBED_Operation * | ||
1083 | GNUNET_TESTBED_overlay_connect (void *op_cls, | ||
1084 | GNUNET_TESTBED_OperationCompletionCallback cb, | ||
1085 | void *cb_cls, | ||
1086 | struct GNUNET_TESTBED_Peer *p1, | ||
1087 | struct GNUNET_TESTBED_Peer *p2); | ||
1088 | |||
1089 | |||
1090 | /** | ||
1091 | * Callbacks of this type are called when topology configuration is completed | ||
1092 | * | ||
1093 | * @param cls the operation closure given to | ||
1094 | * GNUNET_TESTBED_overlay_configure_topology_va() and | ||
1095 | * GNUNET_TESTBED_overlay_configure() calls | ||
1096 | * @param nsuccess the number of successful overlay connects | ||
1097 | * @param nfailures the number of overlay connects which failed | ||
1098 | */ | ||
1099 | typedef void (*GNUNET_TESTBED_TopologyCompletionCallback) (void *cls, | ||
1100 | unsigned int | ||
1101 | nsuccess, | ||
1102 | unsigned int | ||
1103 | nfailures); | ||
1104 | |||
1105 | |||
1106 | /** | ||
1107 | * All peers must have been started before calling this function. | ||
1108 | * This function then connects the given peers in the P2P overlay | ||
1109 | * using the given topology. | ||
1110 | * | ||
1111 | * @param op_cls closure argument to give with the peer connect operation events | ||
1112 | * generated through this function | ||
1113 | * @param num_peers number of peers in 'peers' | ||
1114 | * @param peers array of 'num_peers' with the peers to configure | ||
1115 | * @param max_connections the maximums number of overlay connections that will | ||
1116 | * be made to achieve the given topology | ||
1117 | * @param comp_cb the completion callback to call when the topology generation | ||
1118 | * is completed | ||
1119 | * @param comp_cb_cls closure for the @a comp_cb | ||
1120 | * @param topo desired underlay topology to use | ||
1121 | * @param va topology-specific options | ||
1122 | * @return handle to the operation, NULL if connecting these | ||
1123 | * peers is fundamentally not possible at this time (peers | ||
1124 | * not running or underlay disallows) or if num_peers is less than 2 | ||
1125 | */ | ||
1126 | struct GNUNET_TESTBED_Operation * | ||
1127 | GNUNET_TESTBED_overlay_configure_topology_va (void *op_cls, | ||
1128 | unsigned int num_peers, | ||
1129 | struct GNUNET_TESTBED_Peer **peers, | ||
1130 | unsigned int *max_connections, | ||
1131 | GNUNET_TESTBED_TopologyCompletionCallback | ||
1132 | comp_cb, | ||
1133 | void *comp_cb_cls, | ||
1134 | enum GNUNET_TESTBED_TopologyOption | ||
1135 | topo, | ||
1136 | va_list va); | ||
1137 | |||
1138 | |||
1139 | /** | ||
1140 | * All peers must have been started before calling this function. | ||
1141 | * This function then connects the given peers in the P2P overlay | ||
1142 | * using the given topology. | ||
1143 | * | ||
1144 | * @param op_cls closure argument to give with the peer connect operation events | ||
1145 | * generated through this function | ||
1146 | * @param num_peers number of peers in 'peers' | ||
1147 | * @param peers array of 'num_peers' with the peers to configure | ||
1148 | * @param max_connections the maximums number of overlay connections that will | ||
1149 | * be made to achieve the given topology | ||
1150 | * @param comp_cb the completion callback to call when the topology generation | ||
1151 | * is completed | ||
1152 | * @param comp_cb_cls closure for the above completion callback | ||
1153 | * @param topo desired underlay topology to use | ||
1154 | * @param ... topology-specific options | ||
1155 | * @return handle to the operation, NULL if connecting these | ||
1156 | * peers is fundamentally not possible at this time (peers | ||
1157 | * not running or underlay disallows) or if num_peers is less than 2 | ||
1158 | */ | ||
1159 | struct GNUNET_TESTBED_Operation * | ||
1160 | GNUNET_TESTBED_overlay_configure_topology (void *op_cls, | ||
1161 | unsigned int num_peers, | ||
1162 | struct GNUNET_TESTBED_Peer **peers, | ||
1163 | unsigned int *max_connections, | ||
1164 | GNUNET_TESTBED_TopologyCompletionCallback | ||
1165 | comp_cb, | ||
1166 | void *comp_cb_cls, | ||
1167 | enum GNUNET_TESTBED_TopologyOption | ||
1168 | topo, | ||
1169 | ...); | ||
1170 | |||
1171 | |||
1172 | /** | ||
1173 | * Ask the testbed controller to write the current overlay topology to | ||
1174 | * a file. Naturally, the file will only contain a snapshot as the | ||
1175 | * topology may evolve all the time. | ||
1176 | * FIXME: needs continuation!? | ||
1177 | * | ||
1178 | * @param controller overlay controller to inspect | ||
1179 | * @param filename name of the file the topology should | ||
1180 | * be written to. | ||
1181 | */ | ||
1182 | void | ||
1183 | GNUNET_TESTBED_overlay_write_topology_to_file (struct | ||
1184 | GNUNET_TESTBED_Controller * | ||
1185 | controller, | ||
1186 | const char *filename); | ||
1187 | |||
1188 | |||
1189 | /** | ||
1190 | * Adapter function called to establish a connection to | ||
1191 | * a service. | ||
1192 | * | ||
1193 | * @param cls closure | ||
1194 | * @param cfg configuration of the peer to connect to; will be available until | ||
1195 | * GNUNET_TESTBED_operation_done() is called on the operation returned | ||
1196 | * from GNUNET_TESTBED_service_connect() | ||
1197 | * @return service handle to return in 'op_result', NULL on error | ||
1198 | */ | ||
1199 | typedef void * | ||
1200 | (*GNUNET_TESTBED_ConnectAdapter)(void *cls, | ||
1201 | const struct GNUNET_CONFIGURATION_Handle *cfg); | ||
1202 | |||
1203 | |||
1204 | /** | ||
1205 | * Adapter function called to destroy a connection to | ||
1206 | * a service. | ||
1207 | * | ||
1208 | * @param cls closure | ||
1209 | * @param op_result service handle returned from the connect adapter | ||
1210 | */ | ||
1211 | typedef void | ||
1212 | (*GNUNET_TESTBED_DisconnectAdapter)(void *cls, | ||
1213 | void *op_result); | ||
1214 | |||
1215 | |||
1216 | /** | ||
1217 | * Callback to be called when a service connect operation is completed | ||
1218 | * | ||
1219 | * @param cls the callback closure from functions generating an operation | ||
1220 | * @param op the operation that has been finished | ||
1221 | * @param ca_result the service handle returned from GNUNET_TESTBED_ConnectAdapter() | ||
1222 | * @param emsg error message in case the operation has failed; will be NULL if | ||
1223 | * operation has executed successfully. | ||
1224 | */ | ||
1225 | typedef void | ||
1226 | (*GNUNET_TESTBED_ServiceConnectCompletionCallback) (void *cls, | ||
1227 | struct | ||
1228 | GNUNET_TESTBED_Operation *op, | ||
1229 | void *ca_result, | ||
1230 | const char *emsg); | ||
1231 | |||
1232 | |||
1233 | /** | ||
1234 | * Connect to a service offered by the given peer. Will ensure that | ||
1235 | * the request is queued to not overwhelm our ability to create and | ||
1236 | * maintain connections with other systems. The actual service | ||
1237 | * handle is then returned via the 'op_result' member in the event | ||
1238 | * callback. The @a ca callback is used to create the connection | ||
1239 | * when the time is right; the @a da callback will be used to | ||
1240 | * destroy the connection (upon #GNUNET_TESTBED_operation_done). | ||
1241 | * #GNUNET_TESTBED_operation_done can be used to abort this | ||
1242 | * operation until the event callback has been called. | ||
1243 | * | ||
1244 | * @param op_cls closure to pass in operation event // FIXME: didn't we say we'd no longer use the global callback for these? -CG | ||
1245 | * @param peer peer that runs the service | ||
1246 | * @param service_name name of the service to connect to | ||
1247 | * @param cb the callback to call when this operation is ready (that is, | ||
1248 | * right after the connect adapter returns) | ||
1249 | * @param cb_cls closure for @a cb | ||
1250 | * @param ca helper function to establish the connection | ||
1251 | * @param da helper function to close the connection | ||
1252 | * @param cada_cls closure for @a ca and @a da | ||
1253 | * @return handle for the operation | ||
1254 | */ | ||
1255 | struct GNUNET_TESTBED_Operation * | ||
1256 | GNUNET_TESTBED_service_connect (void *op_cls, | ||
1257 | struct GNUNET_TESTBED_Peer *peer, | ||
1258 | const char *service_name, | ||
1259 | GNUNET_TESTBED_ServiceConnectCompletionCallback | ||
1260 | cb, | ||
1261 | void *cb_cls, | ||
1262 | GNUNET_TESTBED_ConnectAdapter ca, | ||
1263 | GNUNET_TESTBED_DisconnectAdapter da, | ||
1264 | void *cada_cls); | ||
1265 | |||
1266 | |||
1267 | /** | ||
1268 | * This function is used to signal that the event information (struct | ||
1269 | * GNUNET_TESTBED_EventInformation) from an operation has been fully processed | ||
1270 | * i.e. if the event callback is ever called for this operation. If the event | ||
1271 | * callback for this operation has not yet been called, calling this function | ||
1272 | * cancels the operation, frees its resources and ensures the no event is | ||
1273 | * generated with respect to this operation. Note that however cancelling an | ||
1274 | * operation does NOT guarantee that the operation will be fully undone (or that | ||
1275 | * nothing ever happened). | ||
1276 | * | ||
1277 | * This function MUST be called for every operation to fully remove the | ||
1278 | * operation from the operation queue. After calling this function, if | ||
1279 | * operation is completed and its event information is of type | ||
1280 | * GNUNET_TESTBED_ET_OPERATION_FINISHED, the 'op_result' becomes invalid (!). | ||
1281 | |||
1282 | * If the operation is generated from GNUNET_TESTBED_service_connect() then | ||
1283 | * calling this function on such as operation calls the disconnect adapter if | ||
1284 | * the connect adapter was ever called. | ||
1285 | * | ||
1286 | * @param operation operation to signal completion or cancellation | ||
1287 | */ | ||
1288 | void | ||
1289 | GNUNET_TESTBED_operation_done (struct GNUNET_TESTBED_Operation *operation); | ||
1290 | |||
1291 | |||
1292 | /** | ||
1293 | * Callback function to process statistic values from all peers. | ||
1294 | * | ||
1295 | * @param cls closure | ||
1296 | * @param peer the peer the statistic belong to | ||
1297 | * @param subsystem name of subsystem that created the statistic | ||
1298 | * @param name the name of the datum | ||
1299 | * @param value the current value | ||
1300 | * @param is_persistent #GNUNET_YES if the value is persistent, #GNUNET_NO if not | ||
1301 | * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration | ||
1302 | */ | ||
1303 | typedef int | ||
1304 | (*GNUNET_TESTBED_StatisticsIterator) (void *cls, | ||
1305 | const struct GNUNET_TESTBED_Peer *peer, | ||
1306 | const char *subsystem, | ||
1307 | const char *name, | ||
1308 | uint64_t value, | ||
1309 | int is_persistent); | ||
1310 | |||
1311 | |||
1312 | /** | ||
1313 | * Convenience method that iterates over all (running) peers | ||
1314 | * and retrieves all statistics from each peer. | ||
1315 | * | ||
1316 | * @param num_peers number of peers to iterate over | ||
1317 | * @param peers array of peers to iterate over | ||
1318 | * @param subsystem limit to the specified subsystem, NULL for all subsystems | ||
1319 | * @param name name of the statistic value, NULL for all values | ||
1320 | * @param proc processing function for each statistic retrieved | ||
1321 | * @param cont continuation to call once call is completed. The completion of this | ||
1322 | * operation is *ONLY* signalled through this callback -- no | ||
1323 | * GNUNET_TESTBED_ET_OPERATION_FINISHED is generated | ||
1324 | * @param cls closure to pass to proc and cont | ||
1325 | * @return operation handle to cancel the operation | ||
1326 | */ | ||
1327 | struct GNUNET_TESTBED_Operation * | ||
1328 | GNUNET_TESTBED_get_statistics (unsigned int num_peers, | ||
1329 | struct GNUNET_TESTBED_Peer **peers, | ||
1330 | const char *subsystem, const char *name, | ||
1331 | GNUNET_TESTBED_StatisticsIterator proc, | ||
1332 | GNUNET_TESTBED_OperationCompletionCallback cont, | ||
1333 | void *cls); | ||
1334 | |||
1335 | |||
1336 | /** | ||
1337 | * Return the index of the peer inside of the total peer array, | ||
1338 | * aka. the peer's "unique ID". | ||
1339 | * | ||
1340 | * @param peer Peer handle. | ||
1341 | * | ||
1342 | * @return The peer's unique ID. | ||
1343 | */ | ||
1344 | uint32_t | ||
1345 | GNUNET_TESTBED_get_index (const struct GNUNET_TESTBED_Peer *peer); | ||
1346 | |||
1347 | |||
1348 | /** | ||
1349 | * Handle for testbed run helper functions | ||
1350 | */ | ||
1351 | struct GNUNET_TESTBED_RunHandle; | ||
1352 | |||
1353 | |||
1354 | /** | ||
1355 | * Signature of a main function for a testcase. | ||
1356 | * | ||
1357 | * @param cls closure | ||
1358 | * @param h the run handle | ||
1359 | * @param num_peers number of peers in 'peers' | ||
1360 | * @param peers handle to peers run in the testbed. NULL upon timeout (see | ||
1361 | * GNUNET_TESTBED_test_run()). | ||
1362 | * @param links_succeeded the number of overlay link connection attempts that | ||
1363 | * succeeded | ||
1364 | * @param links_failed the number of overlay link connection attempts that | ||
1365 | * failed | ||
1366 | * @see GNUNET_TESTBED_test_run() | ||
1367 | */ | ||
1368 | typedef void | ||
1369 | (*GNUNET_TESTBED_TestMaster)(void *cls, | ||
1370 | struct GNUNET_TESTBED_RunHandle *h, | ||
1371 | unsigned int num_peers, | ||
1372 | struct GNUNET_TESTBED_Peer **peers, | ||
1373 | unsigned int links_succeeded, | ||
1374 | unsigned int links_failed); | ||
1375 | |||
1376 | |||
1377 | /** | ||
1378 | * Convenience method for running a testbed with | ||
1379 | * a single call. Underlay and overlay topology | ||
1380 | * are configured using the "UNDERLAY" and "OVERLAY" | ||
1381 | * options in the "[testbed]" section of the configuration\ | ||
1382 | * (with possible options given in "UNDERLAY_XXX" and/or | ||
1383 | * "OVERLAY_XXX"). | ||
1384 | * | ||
1385 | * The test_master callback will be called once the testbed setup is finished or | ||
1386 | * upon a timeout. This timeout is given through the configuration file by | ||
1387 | * setting the option "SETUP_TIMEOUT" in "[TESTBED]" section. | ||
1388 | * | ||
1389 | * The testbed is to be terminated using a call to | ||
1390 | * "GNUNET_SCHEDULER_shutdown". | ||
1391 | * | ||
1392 | * @param host_filename name of the file with the 'hosts', NULL | ||
1393 | * to run everything on 'localhost' | ||
1394 | * @param cfg configuration to use (for testbed, controller and peers) | ||
1395 | * @param num_peers number of peers to start; FIXME: maybe put that ALSO into | ||
1396 | * cfg?; should be greater than 0 | ||
1397 | * @param event_mask bit mask with set of events to call 'cc' for; | ||
1398 | * or-ed values of "1LL" shifted by the | ||
1399 | * respective 'enum GNUNET_TESTBED_EventType' | ||
1400 | * (e.g. "(1LL << GNUNET_TESTBED_ET_CONNECT) || ...") | ||
1401 | * @param cc controller callback to invoke on events; This callback is called | ||
1402 | * for all peer start events even if GNUNET_TESTBED_ET_PEER_START isn't | ||
1403 | * set in the event_mask as this is the only way get access to the | ||
1404 | * handle of each peer | ||
1405 | * @param cc_cls closure for cc | ||
1406 | * @param test_master this callback will be called once the test is ready or | ||
1407 | * upon timeout | ||
1408 | * @param test_master_cls closure for 'test_master'. | ||
1409 | */ | ||
1410 | void | ||
1411 | GNUNET_TESTBED_run (const char *host_filename, | ||
1412 | const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
1413 | unsigned int num_peers, | ||
1414 | uint64_t event_mask, | ||
1415 | GNUNET_TESTBED_ControllerCallback cc, | ||
1416 | void *cc_cls, | ||
1417 | GNUNET_TESTBED_TestMaster test_master, | ||
1418 | void *test_master_cls); | ||
1419 | |||
1420 | |||
1421 | /** | ||
1422 | * Convenience method for running a "simple" test on the local system | ||
1423 | * with a single call from 'main'. Underlay and overlay topology are | ||
1424 | * configured using the "UNDERLAY" and "OVERLAY" options in the | ||
1425 | * "[TESTBED]" section of the configuration (with possible options | ||
1426 | * given in "UNDERLAY_XXX" and/or "OVERLAY_XXX"). | ||
1427 | * | ||
1428 | * The test_master callback will be called once the testbed setup is finished or | ||
1429 | * upon a timeout. This timeout is given through the configuration file by | ||
1430 | * setting the option "SETUP_TIMEOUT" in "[TESTBED]" section. | ||
1431 | * | ||
1432 | * The test is to be terminated using a call to | ||
1433 | * "GNUNET_SCHEDULER_shutdown". If starting the test fails, | ||
1434 | * the program is stopped without 'master' ever being run. | ||
1435 | * | ||
1436 | * NOTE: this function should be called from 'main', NOT from | ||
1437 | * within a GNUNET_SCHEDULER-loop. This function will initialize | ||
1438 | * the scheduler loop, the testbed and then pass control to | ||
1439 | * 'master'. | ||
1440 | * | ||
1441 | * @param testname name of the testcase (to configure logging, etc.) | ||
1442 | * @param cfg_filename configuration filename to use | ||
1443 | * (for testbed, controller and peers) | ||
1444 | * @param num_peers number of peers to start; should be greter than 0 | ||
1445 | * @param event_mask bit mask with set of events to call 'cc' for; | ||
1446 | * or-ed values of "1LL" shifted by the | ||
1447 | * respective 'enum GNUNET_TESTBED_EventType' | ||
1448 | * (e.g. "(1LL << GNUNET_TESTBED_ET_CONNECT) || ...") | ||
1449 | * @param cc controller callback to invoke on events; This callback is called | ||
1450 | * for all peer start events even if #GNUNET_TESTBED_ET_PEER_START isn't | ||
1451 | * set in the event_mask as this is the only way get access to the | ||
1452 | * handle of each peer | ||
1453 | * @param cc_cls closure for @a cc | ||
1454 | * @param test_master this callback will be called once the test is ready or | ||
1455 | * upon timeout | ||
1456 | * @param test_master_cls closure for @a test_master. | ||
1457 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
1458 | */ | ||
1459 | int | ||
1460 | GNUNET_TESTBED_test_run (const char *testname, | ||
1461 | const char *cfg_filename, | ||
1462 | unsigned int num_peers, | ||
1463 | uint64_t event_mask, | ||
1464 | GNUNET_TESTBED_ControllerCallback cc, | ||
1465 | void *cc_cls, | ||
1466 | GNUNET_TESTBED_TestMaster test_master, | ||
1467 | void *test_master_cls); | ||
1468 | |||
1469 | |||
1470 | /** | ||
1471 | * Obtain handle to the master controller from a testbed run. The handle | ||
1472 | * returned should not be disconnected. | ||
1473 | * | ||
1474 | * @param h the testbed run handle | ||
1475 | * @return handle to the master controller | ||
1476 | */ | ||
1477 | struct GNUNET_TESTBED_Controller * | ||
1478 | GNUNET_TESTBED_run_get_controller_handle (struct GNUNET_TESTBED_RunHandle *h); | ||
1479 | |||
1480 | |||
1481 | /** | ||
1482 | * Opaque handle for barrier | ||
1483 | */ | ||
1484 | struct GNUNET_TESTBED_Barrier; | ||
1485 | |||
1486 | |||
1487 | /** | ||
1488 | * Status of a barrier | ||
1489 | */ | ||
1490 | enum GNUNET_TESTBED_BarrierStatus | ||
1491 | { | ||
1492 | /** | ||
1493 | * Barrier initialised successfully | ||
1494 | */ | ||
1495 | GNUNET_TESTBED_BARRIERSTATUS_INITIALISED = 1, | ||
1496 | |||
1497 | /** | ||
1498 | * Barrier is crossed | ||
1499 | */ | ||
1500 | GNUNET_TESTBED_BARRIERSTATUS_CROSSED, | ||
1501 | |||
1502 | /** | ||
1503 | * Error status | ||
1504 | */ | ||
1505 | GNUNET_TESTBED_BARRIERSTATUS_ERROR, | ||
1506 | }; | ||
1507 | |||
1508 | |||
1509 | /** | ||
1510 | * Functions of this type are to be given as callback argument to | ||
1511 | * GNUNET_TESTBED_barrier_init(). The callback will be called when status | ||
1512 | * information is available for the barrier. | ||
1513 | * | ||
1514 | * @param cls the closure given to GNUNET_TESTBED_barrier_init() | ||
1515 | * @param name the name of the barrier | ||
1516 | * @param barrier the barrier handle | ||
1517 | * @param status status of the barrier. The barrier is removed once it has been | ||
1518 | * crossed or an error occurs while processing it. Therefore it is | ||
1519 | * invalid to call GNUNET_TESTBED_barrier_cancel() on a crossed or | ||
1520 | * errored barrier. | ||
1521 | * @param emsg if the status were to be #GNUNET_SYSERR, this parameter has the | ||
1522 | * error message | ||
1523 | */ | ||
1524 | typedef void | ||
1525 | (*GNUNET_TESTBED_barrier_status_cb) (void *cls, | ||
1526 | const char *name, | ||
1527 | struct GNUNET_TESTBED_Barrier *barrier, | ||
1528 | enum GNUNET_TESTBED_BarrierStatus status, | ||
1529 | const char *emsg); | ||
1530 | |||
1531 | |||
1532 | /** | ||
1533 | * Initialise a barrier and call the given callback when the required percentage | ||
1534 | * of peers (quorum) reach the barrier. | ||
1535 | * | ||
1536 | * @param controller the handle to the controller | ||
1537 | * @param name identification name of the barrier | ||
1538 | * @param quorum the percentage of peers that is required to reach the barrier. | ||
1539 | * Peers signal reaching a barrier by calling | ||
1540 | * GNUNET_TESTBED_barrier_reached(). | ||
1541 | * @param cb the callback to call when the barrier is reached or upon error. | ||
1542 | * Cannot be NULL. | ||
1543 | * @param cb_cls closure for @a cb | ||
1544 | * @return barrier handle | ||
1545 | */ | ||
1546 | struct GNUNET_TESTBED_Barrier * | ||
1547 | GNUNET_TESTBED_barrier_init (struct GNUNET_TESTBED_Controller *controller, | ||
1548 | const char *name, | ||
1549 | unsigned int quorum, | ||
1550 | GNUNET_TESTBED_barrier_status_cb cb, | ||
1551 | void *cb_cls); | ||
1552 | |||
1553 | |||
1554 | /** | ||
1555 | * Cancel a barrier. | ||
1556 | * | ||
1557 | * @param barrier the barrier handle | ||
1558 | */ | ||
1559 | void | ||
1560 | GNUNET_TESTBED_barrier_cancel (struct GNUNET_TESTBED_Barrier *barrier); | ||
1561 | |||
1562 | |||
1563 | /** | ||
1564 | * Opaque handle for barrier wait | ||
1565 | */ | ||
1566 | struct GNUNET_TESTBED_BarrierWaitHandle; | ||
1567 | |||
1568 | |||
1569 | /** | ||
1570 | * Functions of this type are to be given as acallback argument to | ||
1571 | * GNUNET_TESTBED_barrier_wait(). The callback will be called when the barrier | ||
1572 | * corresponding given in GNUNET_TESTBED_barrier_wait() is crossed or cancelled. | ||
1573 | * | ||
1574 | * @param cls closure pointer given to GNUNET_TESTBED_barrier_wait() | ||
1575 | * @param name the barrier name | ||
1576 | * @param status #GNUNET_SYSERR in case of error while waiting for the barrier; | ||
1577 | * #GNUNET_OK if the barrier is crossed | ||
1578 | */ | ||
1579 | typedef void | ||
1580 | (*GNUNET_TESTBED_barrier_wait_cb) (void *cls, | ||
1581 | const char *name, | ||
1582 | int status); | ||
1583 | |||
1584 | |||
1585 | /** | ||
1586 | * Wait for a barrier to be crossed. This function should be called by the | ||
1587 | * peers which have been started by the testbed. If the peer is not started by | ||
1588 | * testbed this function may return error | ||
1589 | * | ||
1590 | * @param name the name of the barrier | ||
1591 | * @param cb the barrier wait callback | ||
1592 | * @param cls the closure for the above callback | ||
1593 | * @return barrier wait handle which can be used to cancel the waiting at | ||
1594 | * anytime before the callback is called. NULL upon error. | ||
1595 | */ | ||
1596 | struct GNUNET_TESTBED_BarrierWaitHandle * | ||
1597 | GNUNET_TESTBED_barrier_wait (const char *name, | ||
1598 | GNUNET_TESTBED_barrier_wait_cb cb, | ||
1599 | void *cls); | ||
1600 | |||
1601 | |||
1602 | /** | ||
1603 | * Cancel a barrier wait handle. Should not be called in or after the callback | ||
1604 | * given to GNUNET_TESTBED_barrier_wait() has been called. | ||
1605 | * | ||
1606 | * @param h the barrier wait handle | ||
1607 | */ | ||
1608 | void | ||
1609 | GNUNET_TESTBED_barrier_wait_cancel (struct GNUNET_TESTBED_BarrierWaitHandle *h); | ||
1610 | |||
1611 | |||
1612 | /** | ||
1613 | * Model for configuring underlay links of a peer | ||
1614 | * @ingroup underlay | ||
1615 | */ | ||
1616 | struct GNUNET_TESTBED_UnderlayLinkModel; | ||
1617 | |||
1618 | |||
1619 | /** | ||
1620 | * The type of GNUNET_TESTBED_UnderlayLinkModel | ||
1621 | * @ingroup underlay | ||
1622 | */ | ||
1623 | enum GNUNET_TESTBED_UnderlayLinkModelType | ||
1624 | { | ||
1625 | /** | ||
1626 | * The model is based on white listing of peers to which underlay connections | ||
1627 | * are permitted. Underlay connections to all other peers will not be | ||
1628 | * permitted. | ||
1629 | */ | ||
1630 | GNUNET_TESTBED_UNDERLAYLINKMODELTYPE_BLACKLIST, | ||
1631 | |||
1632 | /** | ||
1633 | * The model is based on black listing of peers to which underlay connections | ||
1634 | * are not permitted. Underlay connections to all other peers will be | ||
1635 | * permitted | ||
1636 | */ | ||
1637 | GNUNET_TESTBED_UNDERLAYLINKMODELTYPE_WHITELIST | ||
1638 | }; | ||
1639 | |||
1640 | |||
1641 | /** | ||
1642 | * Create a GNUNET_TESTBED_UnderlayLinkModel for the given peer. A peer can | ||
1643 | * have ONLY ONE model and it can be either a blacklist or whitelist based one. | ||
1644 | * | ||
1645 | * @ingroup underlay | ||
1646 | * @param peer the peer for which the model has to be created | ||
1647 | * @param type the type of the model | ||
1648 | * @return the model | ||
1649 | */ | ||
1650 | struct GNUNET_TESTBED_UnderlayLinkModel * | ||
1651 | GNUNET_TESTBED_underlaylinkmodel_create (struct GNUNET_TESTBED_Peer *peer, | ||
1652 | enum | ||
1653 | GNUNET_TESTBED_UnderlayLinkModelType | ||
1654 | type); | ||
1655 | |||
1656 | |||
1657 | /** | ||
1658 | * Add a peer to the given model. Underlay connections to the given peer will | ||
1659 | * be permitted if the model is whitelist based; otherwise they will not be | ||
1660 | * permitted. | ||
1661 | * | ||
1662 | * @ingroup underlay | ||
1663 | * @param model the model | ||
1664 | * @param peer the peer to add | ||
1665 | */ | ||
1666 | void | ||
1667 | GNUNET_TESTBED_underlaylinkmodel_add_peer (struct | ||
1668 | GNUNET_TESTBED_UnderlayLinkModel * | ||
1669 | model, | ||
1670 | struct GNUNET_TESTBED_Peer *peer); | ||
1671 | |||
1672 | |||
1673 | /** | ||
1674 | * Set the metrics for a link to the given peer in the underlay model. The link | ||
1675 | * SHOULD be permittable according to the given model. | ||
1676 | * | ||
1677 | * @ingroup underlay | ||
1678 | * @param model the model | ||
1679 | * @param peer the other end peer of the link | ||
1680 | * @param latency latency of the link in microseconds | ||
1681 | * @param loss data loss of the link expressed as a percentage | ||
1682 | * @param bandwidth bandwidth of the link in kilobytes per second [kB/s] | ||
1683 | */ | ||
1684 | void | ||
1685 | GNUNET_TESTBED_underlaylinkmodel_set_link (struct | ||
1686 | GNUNET_TESTBED_UnderlayLinkModel * | ||
1687 | model, | ||
1688 | struct GNUNET_TESTBED_Peer *peer, | ||
1689 | uint32_t latency, | ||
1690 | uint32_t loss, | ||
1691 | uint32_t bandwidth); | ||
1692 | |||
1693 | |||
1694 | /** | ||
1695 | * Commit the model. The model is freed in this function(!). | ||
1696 | * | ||
1697 | * @ingroup underlay | ||
1698 | * @param model the model to commit | ||
1699 | */ | ||
1700 | void | ||
1701 | GNUNET_TESTBED_underlaylinkmodel_commit (struct | ||
1702 | GNUNET_TESTBED_UnderlayLinkModel *model); | ||
1703 | |||
1704 | |||
1705 | /** | ||
1706 | * Free the resources of the model. Use this function only if the model has not | ||
1707 | * be committed and has to be unallocated. The peer can then have another model | ||
1708 | * created. | ||
1709 | * | ||
1710 | * @ingroup underlay | ||
1711 | * @param model the model to unallocate | ||
1712 | */ | ||
1713 | void | ||
1714 | GNUNET_TESTBED_underlaylinkmodel_free (struct | ||
1715 | GNUNET_TESTBED_UnderlayLinkModel *model); | ||
1716 | |||
1717 | |||
1718 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
1719 | { | ||
1720 | #endif | ||
1721 | |||
1722 | |||
1723 | #ifdef __cplusplus | ||
1724 | } | ||
1725 | #endif | ||
1726 | |||
1727 | #endif | ||
1728 | |||
1729 | /** @} */ /* end of group */ | ||
diff --git a/src/include/gnunet_testing_barrier.h b/src/include/gnunet_testing_barrier.h new file mode 100644 index 000000000..b0f4e1c03 --- /dev/null +++ b/src/include/gnunet_testing_barrier.h | |||
@@ -0,0 +1,122 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2022 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your 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 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file include/gnunet_testing_barrier.h | ||
23 | * @brief API to manage barriers. | ||
24 | * @author t3sserakt | ||
25 | */ | ||
26 | |||
27 | #ifndef GNUNET_TESTING_BARRIER_LIB_H | ||
28 | #define GNUNET_TESTING_BARRIER_LIB_H | ||
29 | |||
30 | #include "gnunet_testing_plugin.h" | ||
31 | |||
32 | |||
33 | struct GNUNET_TESTING_Barrier; | ||
34 | |||
35 | |||
36 | #define GNUNET_TESTING_BARRIER_MAX 32 | ||
37 | |||
38 | /** | ||
39 | * An entry for a barrier list | ||
40 | * FIXME: why is this in the public API!??! | ||
41 | */ | ||
42 | struct GNUNET_TESTING_BarrierListEntry | ||
43 | { | ||
44 | /* DLL */ | ||
45 | struct GNUNET_TESTING_BarrierListEntry *next; | ||
46 | |||
47 | /* DLL */ | ||
48 | struct GNUNET_TESTING_BarrierListEntry *prev; | ||
49 | |||
50 | /* The barrier name*/ | ||
51 | char *barrier_name; | ||
52 | |||
53 | /** | ||
54 | * Number of commands attached to the barrier. | ||
55 | */ | ||
56 | unsigned int expected_reaches; | ||
57 | }; | ||
58 | |||
59 | /** | ||
60 | * A list to hold barriers provided by plugins | ||
61 | * FIXME: why is this in the public API!??! | ||
62 | */ | ||
63 | struct GNUNET_TESTING_BarrierList | ||
64 | { | ||
65 | /** List head **/ | ||
66 | struct GNUNET_TESTING_BarrierListEntry *head; | ||
67 | |||
68 | /** List tail **/ | ||
69 | struct GNUNET_TESTING_BarrierListEntry *tail; | ||
70 | }; | ||
71 | |||
72 | |||
73 | /** | ||
74 | * Command to create a barrier. | ||
75 | * | ||
76 | * FIXME: high-level it is baffling how we need both the GNUNET_TESTING_Barrier | ||
77 | * and the Command that creates barriers. Conceptually this seems to be | ||
78 | * very much separate. Can we move _Barrier completely into testing as private? | ||
79 | * | ||
80 | * @param label The label of this command. | ||
81 | * @param percentage_to_be_reached If this percentage of processes reached | ||
82 | * this barrier, all processes waiting at | ||
83 | * this barrier can pass it. Must not be | ||
84 | * used together with number_to_be_reached. | ||
85 | * @param number_to_be_reached If this number of processes reached | ||
86 | * this barrier, all processes waiting at | ||
87 | * this barrier can pass it. Must not be | ||
88 | * used together with percentage_to_be_reached. | ||
89 | */ | ||
90 | struct GNUNET_TESTING_Command | ||
91 | GNUNET_TESTING_cmd_barrier_create ( | ||
92 | const char *label, | ||
93 | double percentage_to_be_reached, | ||
94 | unsigned int number_to_be_reached); | ||
95 | |||
96 | |||
97 | /** | ||
98 | * If this command is executed the the process is signaling the master process | ||
99 | * that it reached a barrier. If this command is synchronous it will block. | ||
100 | * | ||
101 | * FIXME: Now this, as it returns a Command, seems to me like it should be | ||
102 | * part of the public API? | ||
103 | * | ||
104 | * @param label name for command. | ||
105 | * @param barrier_label The name of the barrier we waited for and which was reached. | ||
106 | * @param asynchronous_finish If #GNUNET_YES this command will not block. | ||
107 | * @param node_number The global number of the node the cmd runs on. | ||
108 | * @param running_on_master Is this cmd running on the master loop? | ||
109 | * @param write_message Callback to write messages to the master loop. | ||
110 | * @return command. | ||
111 | */ | ||
112 | struct GNUNET_TESTING_Command | ||
113 | GNUNET_TESTING_cmd_barrier_reached ( | ||
114 | const char *label, | ||
115 | const char *barrier_label, | ||
116 | unsigned int asynchronous_finish, /* FIXME: why not a bool? */ | ||
117 | unsigned int node_number, | ||
118 | unsigned int running_on_master, /* FIXME: why not a bool? */ | ||
119 | GNUNET_TESTING_cmd_helper_write_cb write_message); /* FIXME: no 'cls' closure argument!? */ | ||
120 | |||
121 | #endif | ||
122 | /* end of testing_barrier.h */ | ||
diff --git a/src/include/gnunet_testing_lib.h b/src/include/gnunet_testing_lib.h index 664e20ac3..0d74de8c2 100644 --- a/src/include/gnunet_testing_lib.h +++ b/src/include/gnunet_testing_lib.h | |||
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup Testing | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
@@ -41,6 +44,7 @@ | |||
41 | #ifndef GNUNET_TESTING_LIB_H | 44 | #ifndef GNUNET_TESTING_LIB_H |
42 | #define GNUNET_TESTING_LIB_H | 45 | #define GNUNET_TESTING_LIB_H |
43 | 46 | ||
47 | |||
44 | #include "gnunet_util_lib.h" | 48 | #include "gnunet_util_lib.h" |
45 | #include "gnunet_statistics_service.h" | 49 | #include "gnunet_statistics_service.h" |
46 | #include "gnunet_arm_service.h" | 50 | #include "gnunet_arm_service.h" |
@@ -398,7 +402,7 @@ typedef void | |||
398 | * Starts a peer using the given configuration and then invokes the | 402 | * Starts a peer using the given configuration and then invokes the |
399 | * given callback. This function ALSO initializes the scheduler loop | 403 | * given callback. This function ALSO initializes the scheduler loop |
400 | * and should thus be called directly from "main". The testcase | 404 | * and should thus be called directly from "main". The testcase |
401 | * should self-terminate by invoking 'GNUNET_SCHEDULER_shutdown'. | 405 | * should self-terminate by invoking #GNUNET_SCHEDULER_shutdown(). |
402 | * | 406 | * |
403 | * @param testdir only the directory name without any path. This is used for | 407 | * @param testdir only the directory name without any path. This is used for |
404 | * all service homes; the directory will be created in a temporary | 408 | * all service homes; the directory will be created in a temporary |
@@ -406,7 +410,7 @@ typedef void | |||
406 | * @param cfgfilename name of the configuration file to use; | 410 | * @param cfgfilename name of the configuration file to use; |
407 | * use NULL to only run with defaults | 411 | * use NULL to only run with defaults |
408 | * @param tm main function of the testcase | 412 | * @param tm main function of the testcase |
409 | * @param tm_cls closure for 'tm' | 413 | * @param tm_cls closure for @a tm |
410 | * @return 0 on success, 1 on error | 414 | * @return 0 on success, 1 on error |
411 | */ | 415 | */ |
412 | int | 416 | int |
@@ -422,7 +426,7 @@ GNUNET_TESTING_peer_run (const char *testdir, | |||
422 | * Starts a service using the given configuration and then invokes the | 426 | * Starts a service using the given configuration and then invokes the |
423 | * given callback. This function ALSO initializes the scheduler loop | 427 | * given callback. This function ALSO initializes the scheduler loop |
424 | * and should thus be called directly from "main". The testcase | 428 | * and should thus be called directly from "main". The testcase |
425 | * should self-terminate by invoking 'GNUNET_SCHEDULER_shutdown'. | 429 | * should self-terminate by invoking #GNUNET_SCHEDULER_shutdown(). |
426 | * | 430 | * |
427 | * This function is useful if the testcase is for a single service | 431 | * This function is useful if the testcase is for a single service |
428 | * and if that service doesn't itself depend on other services. | 432 | * and if that service doesn't itself depend on other services. |
@@ -445,23 +449,6 @@ GNUNET_TESTING_service_run (const char *testdir, | |||
445 | void *tm_cls); | 449 | void *tm_cls); |
446 | 450 | ||
447 | 451 | ||
448 | /** | ||
449 | * Sometimes we use the binary name to determine which specific | ||
450 | * test to run. In those cases, the string after the last "_" | ||
451 | * in 'argv[0]' specifies a string that determines the configuration | ||
452 | * file or plugin to use. | ||
453 | * | ||
454 | * This function returns the respective substring, taking care | ||
455 | * of issues such as binaries ending in '.exe' on W32. | ||
456 | * | ||
457 | * @param argv0 the name of the binary | ||
458 | * @return string between the last '_' and the '.exe' (or the end of the string), | ||
459 | * NULL if argv0 has no '_' | ||
460 | */ | ||
461 | char * | ||
462 | GNUNET_TESTING_get_testname_from_underscore (const char *argv0); | ||
463 | |||
464 | |||
465 | #if 0 /* keep Emacsens' auto-indent happy */ | 452 | #if 0 /* keep Emacsens' auto-indent happy */ |
466 | { | 453 | { |
467 | #endif | 454 | #endif |
@@ -472,3 +459,5 @@ GNUNET_TESTING_get_testname_from_underscore (const char *argv0); | |||
472 | #endif | 459 | #endif |
473 | 460 | ||
474 | /** @} */ /* end of group */ | 461 | /** @} */ /* end of group */ |
462 | |||
463 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_testing_loop_lib.h b/src/include/gnunet_testing_loop_lib.h new file mode 100644 index 000000000..7e13edfab --- /dev/null +++ b/src/include/gnunet_testing_loop_lib.h | |||
@@ -0,0 +1,697 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2021, 2023 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your 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 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @brief Central interpreter and command loop for writing an interpreter to test asynchronous systems | ||
23 | * @author Christian Grothoff <christian@grothoff.org> | ||
24 | * @author Marcello Stanisci | ||
25 | * @author t3sserakt | ||
26 | */ | ||
27 | #ifndef GNUNET_TESTING_LOOP_LIB_H | ||
28 | #define GNUNET_TESTING_LOOP_LIB_H | ||
29 | |||
30 | /** | ||
31 | * Maximum length of label in command | ||
32 | */ | ||
33 | #define GNUNET_TESTING_CMD_MAX_LABEL_LENGTH 127 | ||
34 | |||
35 | /* ********************* Helper functions ********************* */ | ||
36 | |||
37 | /** | ||
38 | * Print failing line number and trigger shutdown. Useful | ||
39 | * quite any time after the command "run" method has been called. | ||
40 | */ | ||
41 | #define GNUNET_TESTING_FAIL(is) \ | ||
42 | do \ | ||
43 | { \ | ||
44 | GNUNET_break (0); \ | ||
45 | GNUNET_TESTING_interpreter_fail (is); \ | ||
46 | return; \ | ||
47 | } while (0) | ||
48 | |||
49 | |||
50 | /* ******************* Generic interpreter logic ************ */ | ||
51 | |||
52 | /** | ||
53 | * Global state of the interpreter, used by a command | ||
54 | * to access information about other commands. | ||
55 | */ | ||
56 | struct GNUNET_TESTING_Interpreter; | ||
57 | |||
58 | /** | ||
59 | * State each asynchronous command must have in its closure. | ||
60 | */ | ||
61 | struct GNUNET_TESTING_AsyncContext | ||
62 | { | ||
63 | |||
64 | /** | ||
65 | * Interpreter we are part of. | ||
66 | */ | ||
67 | struct GNUNET_TESTING_Interpreter *is; // FIXME: Why needed? When available? | ||
68 | |||
69 | /** | ||
70 | * Function to call when done. | ||
71 | */ | ||
72 | GNUNET_SCHEDULER_TaskCallback cont; | ||
73 | |||
74 | /** | ||
75 | * Closure for @e cont. | ||
76 | */ | ||
77 | void *cont_cls; | ||
78 | |||
79 | /** | ||
80 | * Indication if the command finished (#GNUNET_OK). | ||
81 | * #GNUNET_NO if it did not finish, | ||
82 | * #GNUNET_SYSERR if it failed. | ||
83 | */ | ||
84 | enum GNUNET_GenericReturnValue finished; | ||
85 | }; | ||
86 | |||
87 | |||
88 | /** | ||
89 | * The asynchronous command of @a ac has failed. | ||
90 | * | ||
91 | * @param ac command-specific context | ||
92 | */ | ||
93 | void | ||
94 | GNUNET_TESTING_async_fail (struct GNUNET_TESTING_AsyncContext *ac); | ||
95 | |||
96 | |||
97 | /** | ||
98 | * The asynchronous command of @a ac has finished. | ||
99 | * | ||
100 | * @param ac command-specific context | ||
101 | */ | ||
102 | void | ||
103 | GNUNET_TESTING_async_finish (struct GNUNET_TESTING_AsyncContext *ac); | ||
104 | |||
105 | |||
106 | /** | ||
107 | * Signature of a function used to start executing a command | ||
108 | * of a test. | ||
109 | * | ||
110 | * @param cls closure | ||
111 | * @param is interpreter running the command | ||
112 | */ | ||
113 | typedef void | ||
114 | (*GNUNET_TESTING_CommandRunRoutine)(void *cls, | ||
115 | struct GNUNET_TESTING_Interpreter *is); | ||
116 | |||
117 | |||
118 | /** | ||
119 | * Signature of a function used to clean up resources allocated | ||
120 | * by a command. | ||
121 | * | ||
122 | * @param cls closure | ||
123 | */ | ||
124 | typedef void | ||
125 | (*GNUNET_TESTING_CommandCleanupRoutine)(void *cls); | ||
126 | |||
127 | |||
128 | /** | ||
129 | * Signature of a function used to extract traits exposed by a | ||
130 | * command. | ||
131 | * | ||
132 | * @param cls closure | ||
133 | * @param[out] ret where to return the trait data | ||
134 | * @param trait name of the trait to return | ||
135 | * @param index index of the trait (for traits that are indexed) | ||
136 | * @return #GNUNET_OK on success | ||
137 | */ | ||
138 | typedef enum GNUNET_GenericReturnValue | ||
139 | (*GNUNET_TESTING_CommandGetTraits) (void *cls, | ||
140 | const void **ret, | ||
141 | const char *trait, | ||
142 | unsigned int index); | ||
143 | |||
144 | /** | ||
145 | * Create a new command | ||
146 | * | ||
147 | * @param cls the closure | ||
148 | * @param label the Label. Maximum length is GNUNET_TESTING_CMD_MAX_LABEL_LENGTH | ||
149 | * @param run the run routing | ||
150 | * @param cleanup the cleanup function | ||
151 | * @param traits the traits function (optional) | ||
152 | * @param the async context | ||
153 | * @return the command the function cannot fail | ||
154 | */ | ||
155 | struct GNUNET_TESTING_Command | ||
156 | GNUNET_TESTING_command_new (void *cls, | ||
157 | const char *label, | ||
158 | GNUNET_TESTING_CommandRunRoutine run, | ||
159 | GNUNET_TESTING_CommandCleanupRoutine cleanup, | ||
160 | GNUNET_TESTING_CommandGetTraits traits, | ||
161 | struct GNUNET_TESTING_AsyncContext *ac); | ||
162 | |||
163 | |||
164 | /** | ||
165 | * Structure with storage space for a label. | ||
166 | */ | ||
167 | struct GNUNET_TESTING_CommandLabel | ||
168 | { | ||
169 | char value[GNUNET_TESTING_CMD_MAX_LABEL_LENGTH + 1]; | ||
170 | }; | ||
171 | |||
172 | |||
173 | /** | ||
174 | * Set @a label to @a value. Asserts that @a value is | ||
175 | * not longer than #GNUNET_TESTING_CMD_MAX_LABEL_LENGTH. | ||
176 | * | ||
177 | * @param[out] label label to initialize | ||
178 | * @param value value to store into @a label | ||
179 | */ | ||
180 | void | ||
181 | GNUNET_TESTING_set_label (struct GNUNET_TESTING_CommandLabel *label, | ||
182 | const char *value); | ||
183 | |||
184 | |||
185 | /** | ||
186 | * A command to be run by the interpreter. | ||
187 | */ | ||
188 | struct GNUNET_TESTING_Command | ||
189 | { | ||
190 | /** | ||
191 | * Closure for all commands with command-specific context information. | ||
192 | */ | ||
193 | void *cls; | ||
194 | |||
195 | /** | ||
196 | * Label for the command. | ||
197 | */ | ||
198 | struct GNUNET_TESTING_CommandLabel label; | ||
199 | |||
200 | /** | ||
201 | * Runs the command. Note that upon return, the interpreter | ||
202 | * will not automatically run the next command, as the command | ||
203 | * may continue asynchronously in other scheduler tasks. Thus, | ||
204 | * the command must ensure to eventually call | ||
205 | * #GNUNET_TESTING_interpreter_next() or | ||
206 | * #GNUNET_TESTING_interpreter_fail(). | ||
207 | * | ||
208 | * If this function creates some asynchronous activity, it should | ||
209 | * initialize @e finish to a function that can be used to wait for | ||
210 | * the asynchronous activity to terminate. | ||
211 | * | ||
212 | * @param cls closure | ||
213 | * @param is interpreter state | ||
214 | */ | ||
215 | GNUNET_TESTING_CommandRunRoutine run; | ||
216 | |||
217 | /** | ||
218 | * Pointer to the asynchronous context in the command's | ||
219 | * closure. Used by the | ||
220 | * #GNUNET_TESTING_async_finish() and | ||
221 | * #GNUNET_TESTING_async_fail() functions. | ||
222 | * | ||
223 | * Must be NULL if a command is synchronous. | ||
224 | */ | ||
225 | struct GNUNET_TESTING_AsyncContext *ac; | ||
226 | |||
227 | /** | ||
228 | * Clean up after the command. Run during forced termination | ||
229 | * (CTRL-C) or test failure or test success. | ||
230 | * | ||
231 | * @param cls closure | ||
232 | */ | ||
233 | GNUNET_TESTING_CommandCleanupRoutine cleanup; | ||
234 | |||
235 | /** | ||
236 | * Extract information from a command that is useful for other | ||
237 | * commands. Can be NULL if a command has no traits. | ||
238 | * | ||
239 | * @param cls closure | ||
240 | * @param[out] ret result (could be anything) | ||
241 | * @param trait name of the trait | ||
242 | * @param index index number of the object to extract. | ||
243 | * @return #GNUNET_OK on success, | ||
244 | * #GNUNET_NO if no trait was found | ||
245 | */ | ||
246 | GNUNET_TESTING_CommandGetTraits traits; | ||
247 | |||
248 | /** | ||
249 | * When did the execution of this command start? | ||
250 | */ | ||
251 | struct GNUNET_TIME_Absolute start_time; | ||
252 | |||
253 | /** | ||
254 | * When did the execution of this command finish? | ||
255 | */ | ||
256 | struct GNUNET_TIME_Absolute finish_time; | ||
257 | |||
258 | /** | ||
259 | * When did we start the last run of this command? Delta to @e finish_time | ||
260 | * gives the latency for the last successful run. Useful in case @e | ||
261 | * num_tries was positive and the command was run multiple times. In that | ||
262 | * case, the @e start_time gives the time when we first tried to run the | ||
263 | * command, so the difference between @e start_time and @e finish_time would | ||
264 | * be the time all of the @e num_tries took, while the delta to @e | ||
265 | * last_req_time is the time the last (successful) execution took. | ||
266 | */ | ||
267 | struct GNUNET_TIME_Absolute last_req_time; | ||
268 | |||
269 | /** | ||
270 | * In case @e asynchronous_finish is true, how long should we wait for this | ||
271 | * command to complete? If @e finish did not complete after this amount of | ||
272 | * time, the interpreter will fail. Should be set generously to ensure | ||
273 | * tests do not fail on slow systems. | ||
274 | */ | ||
275 | struct GNUNET_TIME_Relative default_timeout; | ||
276 | |||
277 | /** | ||
278 | * How often did we try to execute this command? (In case it is a request | ||
279 | * that is repated.) Note that a command must have some built-in retry | ||
280 | * mechanism for this value to be useful. | ||
281 | */ | ||
282 | unsigned int num_tries; | ||
283 | |||
284 | /** | ||
285 | * If "true", the interpreter should not immediately call | ||
286 | * @e finish, even if @e finish is non-NULL. Otherwise, | ||
287 | * #GNUNET_TESTING_cmd_finish() must be used | ||
288 | * to ensure that a command actually completed. | ||
289 | */ | ||
290 | bool asynchronous_finish; | ||
291 | |||
292 | }; | ||
293 | |||
294 | |||
295 | /** | ||
296 | * Lookup command by label. | ||
297 | * Only future commands are looked up. | ||
298 | * | ||
299 | * @param is interpreter to lookup command in | ||
300 | * @param label label of the command to lookup. | ||
301 | * @return the command, if it is found, or NULL. | ||
302 | * @deprecated (still in use in a very odd way) | ||
303 | */ | ||
304 | // FIXME: think harder about whether this is actually needed, likely not. | ||
305 | const struct GNUNET_TESTING_Command * | ||
306 | GNUNET_TESTING_interpreter_lookup_future_command ( | ||
307 | struct GNUNET_TESTING_Interpreter *is, | ||
308 | const char *label); | ||
309 | |||
310 | |||
311 | /** | ||
312 | * Lookup command by label. | ||
313 | * | ||
314 | * @param is interpreter to lookup command in | ||
315 | * @param label label of the command to lookup. | ||
316 | * @return the command, if it is found, or NULL. | ||
317 | */ | ||
318 | const struct GNUNET_TESTING_Command * | ||
319 | GNUNET_TESTING_interpreter_lookup_command ( | ||
320 | struct GNUNET_TESTING_Interpreter *is, | ||
321 | const char *label); | ||
322 | |||
323 | |||
324 | /** | ||
325 | * Lookup command by label. | ||
326 | * All commands, first into the past, then into the future are looked up. | ||
327 | * | ||
328 | * @param is interpreter to lookup command in | ||
329 | * @param label label of the command to lookup. | ||
330 | * @return the command, if it is found, or NULL. | ||
331 | * @deprecated (still in use in a very odd way) | ||
332 | */ | ||
333 | const struct GNUNET_TESTING_Command * | ||
334 | GNUNET_TESTING_interpreter_lookup_command_all ( | ||
335 | struct GNUNET_TESTING_Interpreter *is, | ||
336 | const char *label); | ||
337 | |||
338 | |||
339 | /** | ||
340 | * Current command failed, clean up and fail the test case. | ||
341 | * | ||
342 | * @param is interpreter state. | ||
343 | */ | ||
344 | void | ||
345 | GNUNET_TESTING_interpreter_fail (struct GNUNET_TESTING_Interpreter *is); | ||
346 | |||
347 | |||
348 | /** | ||
349 | * Turn asynchronous command into non-blocking command by setting | ||
350 | * asynchronous_finish to true. Modifies (and then returns) @a cmd simply | ||
351 | * setting the bit. By default, most commands are blocking, and by wrapping | ||
352 | * the command construction in this function a blocking command can be turned | ||
353 | * into an asynchronous command where the interpreter continues after | ||
354 | * initiating the asynchronous action. Does nothing if the command is | ||
355 | * fundamentally synchronous. | ||
356 | * | ||
357 | * @param[in,out] cmd command to make non-blocking | ||
358 | * @return a finish-command. | ||
359 | */ | ||
360 | struct GNUNET_TESTING_Command | ||
361 | GNUNET_TESTING_cmd_make_unblocking (struct GNUNET_TESTING_Command cmd); | ||
362 | |||
363 | |||
364 | /** | ||
365 | * Create (synchronous) command that waits for another command to finish. | ||
366 | * If @a cmd_ref did not finish after @a timeout, this command will fail | ||
367 | * the test case. | ||
368 | * | ||
369 | * @param finish_label label for this command | ||
370 | * @param cmd_ref reference to a previous command which we should | ||
371 | * wait for (call `finish()` on) | ||
372 | * @param timeout how long to wait at most for @a cmd_ref to finish | ||
373 | * @return a finish-command. | ||
374 | */ | ||
375 | const struct GNUNET_TESTING_Command | ||
376 | GNUNET_TESTING_cmd_finish (const char *finish_label, | ||
377 | const char *cmd_ref, | ||
378 | struct GNUNET_TIME_Relative timeout); | ||
379 | |||
380 | |||
381 | /** | ||
382 | * Make the instruction pointer point to @a target_label | ||
383 | * only if @a counter is greater than zero. | ||
384 | * | ||
385 | * @param label command label | ||
386 | * @param target_label label of the new instruction pointer's destination after the jump; | ||
387 | * must be before the current instruction | ||
388 | * @param counter counts how many times the rewinding is to happen. | ||
389 | */ | ||
390 | struct GNUNET_TESTING_Command | ||
391 | GNUNET_TESTING_cmd_rewind_ip (const char *label, | ||
392 | const char *target_label, | ||
393 | unsigned int counter); | ||
394 | |||
395 | |||
396 | /** | ||
397 | * Function called with the final result of the test. | ||
398 | * FIXME: This may want to use a GNUNET_ErrorCode (namespaced, e.g. | ||
399 | * GNUNET_EC_TESTING_*) | ||
400 | * | ||
401 | * @param cls closure | ||
402 | * @param rv #GNUNET_OK if the test passed | ||
403 | */ | ||
404 | typedef void | ||
405 | (*GNUNET_TESTING_ResultCallback)(void *cls, | ||
406 | enum GNUNET_GenericReturnValue rv); | ||
407 | |||
408 | |||
409 | /** | ||
410 | * Run the testsuite. Note, CMDs are copied into | ||
411 | * the interpreter state because they are _usually_ | ||
412 | * defined into the "run" method that returns after | ||
413 | * having scheduled the test interpreter. | ||
414 | * | ||
415 | * @param commands the array of command to execute | ||
416 | * @param timeout how long to wait for each command to execute | ||
417 | * @param rc function to call with the final result | ||
418 | * @param rc_cls closure for @a rc | ||
419 | * @return The interpreter. | ||
420 | */ | ||
421 | struct GNUNET_TESTING_Interpreter * | ||
422 | GNUNET_TESTING_run (const struct GNUNET_TESTING_Command *commands, | ||
423 | struct GNUNET_TIME_Relative timeout, | ||
424 | GNUNET_TESTING_ResultCallback rc, | ||
425 | void *rc_cls); | ||
426 | |||
427 | |||
428 | /** | ||
429 | * Start a GNUnet scheduler event loop and | ||
430 | * run the testsuite. Return 0 upon success. | ||
431 | * Expected to be called directly from main(). | ||
432 | * FIXME: Why is this commands array here not const? | ||
433 | * | ||
434 | * @param commands the list of command to execute | ||
435 | * @param timeout how long to wait for each command to execute | ||
436 | * @return EXIT_SUCCESS on success, EXIT_FAILURE on failure | ||
437 | */ | ||
438 | int | ||
439 | GNUNET_TESTING_main (struct GNUNET_TESTING_Command *commands, | ||
440 | struct GNUNET_TIME_Relative timeout); | ||
441 | |||
442 | |||
443 | |||
444 | /* ************** Fundamental interpreter commands ************ */ | ||
445 | |||
446 | |||
447 | /** | ||
448 | * Create command array terminator. | ||
449 | * | ||
450 | * @return a end-command. | ||
451 | */ | ||
452 | struct GNUNET_TESTING_Command | ||
453 | GNUNET_TESTING_cmd_end (void); | ||
454 | |||
455 | |||
456 | /** | ||
457 | * Create a "batch" command. Such command takes a end_CMD-terminated array of | ||
458 | * CMDs and executed them. Once it hits the end CMD, it passes the control to | ||
459 | * the next top-level CMD, regardless of it being another batch or ordinary | ||
460 | * CMD. | ||
461 | * | ||
462 | * @param label the command label. | ||
463 | * @param batch array of CMDs to execute. | ||
464 | * @return the command. | ||
465 | */ | ||
466 | struct GNUNET_TESTING_Command | ||
467 | GNUNET_TESTING_cmd_batch (const char *label, | ||
468 | struct GNUNET_TESTING_Command *batch); | ||
469 | |||
470 | |||
471 | /** | ||
472 | * Performance counter. | ||
473 | */ | ||
474 | struct GNUNET_TESTING_Timer | ||
475 | { | ||
476 | /** | ||
477 | * For which type of commands. | ||
478 | */ | ||
479 | const char *prefix; | ||
480 | |||
481 | /** | ||
482 | * Total time spend in all commands of this type. | ||
483 | */ | ||
484 | struct GNUNET_TIME_Relative total_duration; | ||
485 | |||
486 | /** | ||
487 | * Total time spend waiting for the *successful* exeuction | ||
488 | * in all commands of this type. | ||
489 | */ | ||
490 | struct GNUNET_TIME_Relative success_latency; | ||
491 | |||
492 | /** | ||
493 | * Number of commands summed up. | ||
494 | */ | ||
495 | unsigned int num_commands; | ||
496 | |||
497 | /** | ||
498 | * Number of retries summed up. | ||
499 | */ | ||
500 | unsigned int num_retries; | ||
501 | }; | ||
502 | |||
503 | /** | ||
504 | * Obtain performance data from the interpreter. | ||
505 | * | ||
506 | * @param[in,out] timers what commands (by label) to obtain runtimes for | ||
507 | * @return the command | ||
508 | */ | ||
509 | struct GNUNET_TESTING_Command | ||
510 | GNUNET_TESTING_cmd_stat (struct GNUNET_TESTING_Timer *timers); | ||
511 | |||
512 | |||
513 | /* *** Generic trait logic for implementing traits ********* */ | ||
514 | |||
515 | /** | ||
516 | * A `struct GNUNET_TESTING_Trait` can be used to exchange data between cmds. | ||
517 | * | ||
518 | * Therefor the cmd which like to provide data to other cmds has to implement | ||
519 | * the trait function, where an array of traits is defined with the help of the | ||
520 | * #GNUNET_TESTING_make_trait_ macro. The data can be retrieved with the help of the | ||
521 | * #GNUNET_TESTING_get_trait_ macro. Traits name and type must be defined to make | ||
522 | * use of the macros. | ||
523 | */ | ||
524 | struct GNUNET_TESTING_Trait | ||
525 | { | ||
526 | /** | ||
527 | * Index number associated with the trait. This gives the | ||
528 | * possibility to have _multiple_ traits on offer under the | ||
529 | * same name. | ||
530 | */ | ||
531 | unsigned int index; | ||
532 | |||
533 | /** | ||
534 | * Trait type, for example "reserve-pub" or "coin-priv". | ||
535 | */ | ||
536 | const char *trait_name; | ||
537 | |||
538 | /** | ||
539 | * Pointer to the piece of data to offer. | ||
540 | */ | ||
541 | const void *ptr; | ||
542 | }; | ||
543 | |||
544 | |||
545 | /** | ||
546 | * "end" of traits array. Because traits are offered into arrays, this type | ||
547 | * of trait is used to mark the end of such arrays; useful when iterating over | ||
548 | * those. | ||
549 | */ | ||
550 | struct GNUNET_TESTING_Trait | ||
551 | GNUNET_TESTING_trait_end (void); | ||
552 | |||
553 | |||
554 | /** | ||
555 | * Obtain value of a trait from a command. | ||
556 | * | ||
557 | * @param traits the array of all the traits. | ||
558 | * @param[out] ret where to store the result. | ||
559 | * @param trait type of the trait to extract. | ||
560 | * @param index index number of the trait to extract. | ||
561 | * @return #GNUNET_OK when the trait is found. | ||
562 | */ | ||
563 | enum GNUNET_GenericReturnValue | ||
564 | GNUNET_TESTING_get_trait (const struct GNUNET_TESTING_Trait *traits, | ||
565 | const void **ret, | ||
566 | const char *trait, | ||
567 | unsigned int index); | ||
568 | |||
569 | |||
570 | |||
571 | /** | ||
572 | * Create headers for a trait with name @a name for | ||
573 | * statically allocated data of type @a type. | ||
574 | * | ||
575 | * @param prefix symbol prefix to use | ||
576 | * @param name name of the trait | ||
577 | * @param type data type for the trait | ||
578 | */ | ||
579 | #define GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT(prefix,name,type) \ | ||
580 | enum GNUNET_GenericReturnValue \ | ||
581 | prefix ## _get_trait_ ## name ( \ | ||
582 | const struct GNUNET_TESTING_Command *cmd, \ | ||
583 | type **ret); \ | ||
584 | struct GNUNET_TESTING_Trait \ | ||
585 | prefix ## _make_trait_ ## name ( \ | ||
586 | type * value); | ||
587 | |||
588 | |||
589 | /** | ||
590 | * Create C implementation for a trait with name @a name for statically | ||
591 | * allocated data of type @a type. | ||
592 | * | ||
593 | * @param prefix symbol prefix to use | ||
594 | * @param name name of the trait | ||
595 | * @param type data type for the trait | ||
596 | */ | ||
597 | #define GNUNET_TESTING_MAKE_IMPL_SIMPLE_TRAIT(prefix,name,type) \ | ||
598 | enum GNUNET_GenericReturnValue \ | ||
599 | prefix ## _get_trait_ ## name ( \ | ||
600 | const struct GNUNET_TESTING_Command *cmd, \ | ||
601 | type * *ret) \ | ||
602 | { \ | ||
603 | if (NULL == cmd->traits) return GNUNET_SYSERR; \ | ||
604 | return cmd->traits (cmd->cls, \ | ||
605 | (const void **) ret, \ | ||
606 | GNUNET_S (name), \ | ||
607 | 0); \ | ||
608 | } \ | ||
609 | struct GNUNET_TESTING_Trait \ | ||
610 | prefix ## _make_trait_ ## name ( \ | ||
611 | type * value) \ | ||
612 | { \ | ||
613 | struct GNUNET_TESTING_Trait ret = { \ | ||
614 | .trait_name = GNUNET_S (name), \ | ||
615 | .ptr = (const void *) value \ | ||
616 | }; \ | ||
617 | return ret; \ | ||
618 | } | ||
619 | |||
620 | |||
621 | /** | ||
622 | * Create headers for a trait with name @a name for | ||
623 | * statically allocated data of type @a type. | ||
624 | * | ||
625 | * @param prefix symbol prefix to use | ||
626 | * @param name name of the trait | ||
627 | * @param type data type for the trait | ||
628 | */ | ||
629 | #define GNUNET_TESTING_MAKE_DECL_INDEXED_TRAIT(prefix,name,type) \ | ||
630 | enum GNUNET_GenericReturnValue \ | ||
631 | prefix ## _get_trait_ ## name ( \ | ||
632 | const struct GNUNET_TESTING_Command *cmd, \ | ||
633 | unsigned int index, \ | ||
634 | type **ret); \ | ||
635 | struct GNUNET_TESTING_Trait \ | ||
636 | prefix ## _make_trait_ ## name ( \ | ||
637 | unsigned int index, \ | ||
638 | type *value); | ||
639 | |||
640 | |||
641 | /** | ||
642 | * Create C implementation for a trait with name @a name for statically | ||
643 | * allocated data of type @a type. | ||
644 | */ | ||
645 | #define GNUNET_TESTING_MAKE_IMPL_INDEXED_TRAIT(prefix,name,type) \ | ||
646 | enum GNUNET_GenericReturnValue \ | ||
647 | prefix ## _get_trait_ ## name ( \ | ||
648 | const struct GNUNET_TESTING_Command *cmd, \ | ||
649 | unsigned int index, \ | ||
650 | type * *ret) \ | ||
651 | { \ | ||
652 | if (NULL == cmd->traits) return GNUNET_SYSERR; \ | ||
653 | return cmd->traits (cmd->cls, \ | ||
654 | (const void **) ret, \ | ||
655 | GNUNET_S (name), \ | ||
656 | index); \ | ||
657 | } \ | ||
658 | struct GNUNET_TESTING_Trait \ | ||
659 | prefix ## _make_trait_ ## name ( \ | ||
660 | unsigned int index, \ | ||
661 | type * value) \ | ||
662 | { \ | ||
663 | struct GNUNET_TESTING_Trait ret = { \ | ||
664 | .index = index, \ | ||
665 | .trait_name = GNUNET_S (name), \ | ||
666 | .ptr = (const void *) value \ | ||
667 | }; \ | ||
668 | return ret; \ | ||
669 | } | ||
670 | |||
671 | |||
672 | /** | ||
673 | * Call #op on all simple traits needed by loop logic. | ||
674 | * | ||
675 | * @param op operation to perform | ||
676 | * @param prefix prefix to pass to @e op | ||
677 | */ | ||
678 | #define GNUNET_TESTING_LOOP_SIMPLE_TRAITS(op,prefix) \ | ||
679 | op (prefix, batch_cmds, struct GNUNET_TESTING_Command *) | ||
680 | |||
681 | |||
682 | GNUNET_TESTING_LOOP_SIMPLE_TRAITS(GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT, GNUNET_TESTING) | ||
683 | |||
684 | |||
685 | /** | ||
686 | * Call #op on all indexed traits needed by loop logic. | ||
687 | * | ||
688 | * @param op operation to perform | ||
689 | * @param prefix prefix to pass to @e op | ||
690 | */ | ||
691 | #define GNUNET_TESTING_LOOP_INDEXED_TRAITS(op,prefix) \ | ||
692 | op (prefix, cmd, const struct GNUNET_TESTING_Command) | ||
693 | |||
694 | GNUNET_TESTING_LOOP_INDEXED_TRAITS (GNUNET_TESTING_MAKE_DECL_INDEXED_TRAIT, GNUNET_TESTING) | ||
695 | |||
696 | |||
697 | #endif | ||
diff --git a/src/include/gnunet_testing_netjail_lib.h b/src/include/gnunet_testing_netjail_lib.h index b65ae6537..843fce0d5 100644 --- a/src/include/gnunet_testing_netjail_lib.h +++ b/src/include/gnunet_testing_netjail_lib.h | |||
@@ -27,9 +27,8 @@ | |||
27 | #ifndef GNUNET_TESTING_NETJAIL_LIB_H | 27 | #ifndef GNUNET_TESTING_NETJAIL_LIB_H |
28 | #define GNUNET_TESTING_NETJAIL_LIB_H | 28 | #define GNUNET_TESTING_NETJAIL_LIB_H |
29 | 29 | ||
30 | #include "gnunet_util_lib.h" | ||
31 | #include "gnunet_testing_plugin.h" | ||
32 | #include "gnunet_testing_ng_lib.h" | 30 | #include "gnunet_testing_ng_lib.h" |
31 | #include "gnunet_testing_plugin.h" | ||
33 | 32 | ||
34 | 33 | ||
35 | /** | 34 | /** |
@@ -52,7 +51,7 @@ struct GNUNET_TESTING_NetjailRouter | |||
52 | /** | 51 | /** |
53 | * Enum for the different types of nodes. | 52 | * Enum for the different types of nodes. |
54 | */ | 53 | */ |
55 | enum GNUNET_TESTING_NODE_TYPE | 54 | enum GNUNET_TESTING_NodeType |
56 | { | 55 | { |
57 | /** | 56 | /** |
58 | * Node in a subnet. | 57 | * Node in a subnet. |
@@ -121,7 +120,7 @@ struct GNUNET_TESTING_NodeConnection | |||
121 | /** | 120 | /** |
122 | * The type of the node this connection points to. | 121 | * The type of the node this connection points to. |
123 | */ | 122 | */ |
124 | enum GNUNET_TESTING_NODE_TYPE node_type; | 123 | enum GNUNET_TESTING_NodeType node_type; |
125 | 124 | ||
126 | /** | 125 | /** |
127 | * The node which establish the connection | 126 | * The node which establish the connection |
@@ -145,6 +144,16 @@ struct GNUNET_TESTING_NodeConnection | |||
145 | struct GNUNET_TESTING_NetjailNode | 144 | struct GNUNET_TESTING_NetjailNode |
146 | { | 145 | { |
147 | /** | 146 | /** |
147 | * Head of the DLL with the connections which shall be established to other nodes. | ||
148 | */ | ||
149 | struct GNUNET_TESTING_NodeConnection *node_connections_head; | ||
150 | |||
151 | /** | ||
152 | * Tail of the DLL with the connections which shall be established to other nodes. | ||
153 | */ | ||
154 | struct GNUNET_TESTING_NodeConnection *node_connections_tail; | ||
155 | |||
156 | /** | ||
148 | * Plugin for the test case to be run on this node. | 157 | * Plugin for the test case to be run on this node. |
149 | */ | 158 | */ |
150 | char *plugin; | 159 | char *plugin; |
@@ -165,14 +174,19 @@ struct GNUNET_TESTING_NetjailNode | |||
165 | unsigned int node_n; | 174 | unsigned int node_n; |
166 | 175 | ||
167 | /** | 176 | /** |
168 | * Head of the DLL with the connections which shall be established to other nodes. | 177 | * The overall number of the node in the whole test system. |
169 | */ | 178 | */ |
170 | struct GNUNET_TESTING_NodeConnection *node_connections_head; | 179 | unsigned int node_number; |
171 | 180 | ||
172 | /** | 181 | /** |
173 | * Tail of the DLL with the connections which shall be established to other nodes. | 182 | * The number of unintentional additional connections this node waits for. This overwrites the global additional_connects value. |
174 | */ | 183 | */ |
175 | struct GNUNET_TESTING_NodeConnection *node_connections_tail; | 184 | unsigned int additional_connects; |
185 | |||
186 | /** | ||
187 | * The number of cmds waiting for a specific barrier. | ||
188 | */ | ||
189 | unsigned int expected_reaches; | ||
176 | }; | 190 | }; |
177 | 191 | ||
178 | 192 | ||
@@ -250,13 +264,37 @@ GNUNET_TESTING_get_topo_from_file (const char *filename); | |||
250 | 264 | ||
251 | 265 | ||
252 | /** | 266 | /** |
267 | * FIXME: this could use a "to_string". | ||
253 | * Parse the topology data. | 268 | * Parse the topology data. |
254 | * | 269 | * |
255 | * @param data The topology data. | 270 | * @param data The topology data. |
256 | * @return The GNUNET_TESTING_NetjailTopology | 271 | * @return The GNUNET_TESTING_NetjailTopology |
257 | */ | 272 | */ |
258 | struct GNUNET_TESTING_NetjailTopology * | 273 | struct GNUNET_TESTING_NetjailTopology * |
259 | GNUNET_TESTING_get_topo_from_string (char *data); | 274 | GNUNET_TESTING_get_topo_from_string (const char *data); |
275 | |||
276 | |||
277 | /** | ||
278 | * Get the number of unintentional additional connections the node waits for. | ||
279 | * | ||
280 | * @param num The specific node we want the additional connects for. | ||
281 | * @return The number of additional connects | ||
282 | */ | ||
283 | unsigned int | ||
284 | GNUNET_TESTING_get_additional_connects (unsigned int num, | ||
285 | struct GNUNET_TESTING_NetjailTopology * | ||
286 | topology); | ||
287 | |||
288 | /** | ||
289 | * Get a node from the topology. | ||
290 | * | ||
291 | * @param num The specific node we want the connections for. | ||
292 | * @param topology The topology we get the connections from. | ||
293 | * @return The connections of the node. | ||
294 | */ | ||
295 | struct GNUNET_TESTING_NetjailNode * | ||
296 | GNUNET_TESTING_get_node (unsigned int num, | ||
297 | struct GNUNET_TESTING_NetjailTopology *topology); | ||
260 | 298 | ||
261 | 299 | ||
262 | /** | 300 | /** |
@@ -267,8 +305,8 @@ GNUNET_TESTING_get_topo_from_string (char *data); | |||
267 | * @return The connections of the node. | 305 | * @return The connections of the node. |
268 | */ | 306 | */ |
269 | struct GNUNET_TESTING_NodeConnection * | 307 | struct GNUNET_TESTING_NodeConnection * |
270 | GNUNET_TESTING_get_connections (unsigned int num, struct | 308 | GNUNET_TESTING_get_connections (unsigned int num, |
271 | GNUNET_TESTING_NetjailTopology *topology); | 309 | const struct GNUNET_TESTING_NetjailTopology *topology); |
272 | 310 | ||
273 | 311 | ||
274 | /** | 312 | /** |
@@ -280,7 +318,7 @@ GNUNET_TESTING_get_connections (unsigned int num, struct | |||
280 | */ | 318 | */ |
281 | char * | 319 | char * |
282 | GNUNET_TESTING_get_address (struct GNUNET_TESTING_NodeConnection *connection, | 320 | GNUNET_TESTING_get_address (struct GNUNET_TESTING_NodeConnection *connection, |
283 | char *prefix); | 321 | const char *prefix); |
284 | 322 | ||
285 | 323 | ||
286 | /** | 324 | /** |
@@ -309,7 +347,7 @@ GNUNET_TESTING_calculate_num (struct | |||
309 | * Struct with information for callbacks. | 347 | * Struct with information for callbacks. |
310 | * | 348 | * |
311 | */ | 349 | */ |
312 | struct BlockState | 350 | struct GNUNET_TESTING_BlockState |
313 | { | 351 | { |
314 | /** | 352 | /** |
315 | * Context for our asynchronous completion. | 353 | * Context for our asynchronous completion. |
@@ -331,7 +369,7 @@ struct BlockState | |||
331 | * Struct to hold information for callbacks. | 369 | * Struct to hold information for callbacks. |
332 | * | 370 | * |
333 | */ | 371 | */ |
334 | struct LocalPreparedState | 372 | struct GNUNET_TESTING_LocalPreparedState |
335 | { | 373 | { |
336 | /** | 374 | /** |
337 | * Context for our asynchronous completion. | 375 | * Context for our asynchronous completion. |
@@ -342,22 +380,35 @@ struct LocalPreparedState | |||
342 | * Callback to write messages to the master loop. | 380 | * Callback to write messages to the master loop. |
343 | * | 381 | * |
344 | */ | 382 | */ |
345 | TESTING_CMD_HELPER_write_cb write_message; | 383 | GNUNET_TESTING_cmd_helper_write_cb write_message; |
346 | }; | 384 | }; |
347 | 385 | ||
348 | 386 | /** | |
387 | * This command destroys the ressources allocated for the test system setup. | ||
388 | * | ||
389 | * @param label Name for command. | ||
390 | * @param create_label Label of the cmd which started the test system. | ||
391 | * @param write_message Callback to write messages to the master loop. | ||
392 | * @return command. | ||
393 | */ | ||
349 | struct GNUNET_TESTING_Command | 394 | struct GNUNET_TESTING_Command |
350 | GNUNET_TESTING_cmd_system_destroy (const char *label, | 395 | GNUNET_TESTING_cmd_system_destroy (const char *label, |
351 | const char *create_label); | 396 | const char *create_label); |
352 | 397 | ||
353 | 398 | /** | |
399 | * This command is setting up a test environment for a peer to start. | ||
400 | * | ||
401 | * @param label Name for command. | ||
402 | * @param testdir Only the directory name without any path. Temporary | ||
403 | * directory used for all service homes. | ||
404 | */ | ||
354 | struct GNUNET_TESTING_Command | 405 | struct GNUNET_TESTING_Command |
355 | GNUNET_TESTING_cmd_system_create (const char *label, | 406 | GNUNET_TESTING_cmd_system_create (const char *label, |
356 | const char *testdir); | 407 | const char *testdir); |
357 | 408 | ||
358 | 409 | ||
359 | /** | 410 | /** |
360 | * Create command. | 411 | * This command executes a shell script to setup the netjail environment. |
361 | * | 412 | * |
362 | * @param label name for command. | 413 | * @param label name for command. |
363 | * @param topology_config Configuration file for the test topology. | 414 | * @param topology_config Configuration file for the test topology. |
@@ -371,7 +422,7 @@ GNUNET_TESTING_cmd_netjail_start (const char *label, | |||
371 | 422 | ||
372 | 423 | ||
373 | /** | 424 | /** |
374 | * Create command. | 425 | * This command executes a shell script to remove the netjail environment. |
375 | * | 426 | * |
376 | * @param label name for command. | 427 | * @param label name for command. |
377 | * @param topology_config Configuration file for the test topology. | 428 | * @param topology_config Configuration file for the test topology. |
@@ -385,7 +436,8 @@ GNUNET_TESTING_cmd_netjail_stop (const char *label, | |||
385 | 436 | ||
386 | 437 | ||
387 | /** | 438 | /** |
388 | * Create command. | 439 | * This command executes a shell script which starts a helper process. |
440 | * This process is running on a netjail node, executing a defined test case. | ||
389 | * | 441 | * |
390 | * @param label Name for the command. | 442 | * @param label Name for the command. |
391 | * @param topology The complete topology information. | 443 | * @param topology The complete topology information. |
@@ -395,7 +447,7 @@ GNUNET_TESTING_cmd_netjail_stop (const char *label, | |||
395 | * @return command. | 447 | * @return command. |
396 | */ | 448 | */ |
397 | struct GNUNET_TESTING_Command | 449 | struct GNUNET_TESTING_Command |
398 | GNUNET_TESTING_cmd_netjail_start_testing_system ( | 450 | GNUNET_TESTING_cmd_netjail_start_cmds_helper ( |
399 | const char *label, | 451 | const char *label, |
400 | struct GNUNET_TESTING_NetjailTopology *topology, | 452 | struct GNUNET_TESTING_NetjailTopology *topology, |
401 | unsigned int *read_file, | 453 | unsigned int *read_file, |
@@ -412,89 +464,67 @@ GNUNET_TESTING_cmd_netjail_start_testing_system ( | |||
412 | * @return command. | 464 | * @return command. |
413 | */ | 465 | */ |
414 | struct GNUNET_TESTING_Command | 466 | struct GNUNET_TESTING_Command |
415 | GNUNET_TESTING_cmd_stop_testing_system ( | 467 | GNUNET_TESTING_cmd_stop_cmds_helper ( |
416 | const char *label, | 468 | const char *label, |
417 | const char *helper_start_label, | 469 | const char *helper_start_label, |
418 | struct GNUNET_TESTING_NetjailTopology *topology); | 470 | struct GNUNET_TESTING_NetjailTopology *topology); |
419 | 471 | ||
420 | 472 | ||
421 | /** | 473 | /** |
422 | * Create a GNUNET_CMDS_LOCAL_FINISHED message. | 474 | * This command is used to block the loop, until the command is finished by other commands, |
475 | * using a trait to get this commands struct GNUNET_TESTING_AsyncContext. | ||
423 | * | 476 | * |
424 | * @param rv The result of the local test as GNUNET_GenericReturnValue. | 477 | * @param label name for command. |
425 | * @return The GNUNET_CMDS_LOCAL_FINISHED message. | 478 | * @return command. |
426 | */ | 479 | */ |
427 | struct GNUNET_MessageHeader * | ||
428 | GNUNET_TESTING_send_local_test_finished_msg (enum GNUNET_GenericReturnValue rv); | ||
429 | |||
430 | |||
431 | struct GNUNET_TESTING_Command | ||
432 | GNUNET_TESTING_cmd_barrier_create ( | ||
433 | const char *label); | ||
434 | |||
435 | |||
436 | struct GNUNET_TESTING_Command | 480 | struct GNUNET_TESTING_Command |
437 | GNUNET_TESTING_cmd_barrier_setup_finished ( | 481 | GNUNET_TESTING_cmd_block_until_external_trigger ( |
438 | const char *label); | 482 | const char *label); |
439 | 483 | ||
440 | |||
441 | // Wait for barrier to be reached by all; | ||
442 | // async version implies reached but does not | ||
443 | // wait on other peers to reach it. | ||
444 | struct GNUNET_TESTING_Command | ||
445 | GNUNET_TESTING_cmd_barrier_reached ( | ||
446 | const char *label, | ||
447 | const char *barrier_label); | ||
448 | |||
449 | |||
450 | struct GNUNET_TESTING_Command | ||
451 | GNUNET_TESTING_cmd_block_until_all_peers_started ( | ||
452 | const char *label, | ||
453 | unsigned int *all_peers_started); | ||
454 | |||
455 | |||
456 | /** | 484 | /** |
457 | * Create command. | 485 | * DEPRECATED |
486 | * This command sends a GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED message to the master loop. | ||
458 | * | 487 | * |
459 | * @param label name for command. | 488 | * @param label name for command. |
460 | * @param all_peers_started Flag which will be set from outside. | 489 | * @param write_message Callback to write messages to the master loop. |
461 | * @param asynchronous_finish If GNUNET_YES this command will not block. | ||
462 | * @return command. | 490 | * @return command. |
463 | */ | 491 | */ |
464 | struct GNUNET_TESTING_Command | 492 | struct GNUNET_TESTING_Command |
465 | GNUNET_TESTING_cmd_block_until_external_trigger ( | ||
466 | const char *label); | ||
467 | |||
468 | |||
469 | struct GNUNET_TESTING_Command | ||
470 | GNUNET_TESTING_cmd_send_peer_ready (const char *label, | 493 | GNUNET_TESTING_cmd_send_peer_ready (const char *label, |
471 | TESTING_CMD_HELPER_write_cb write_message); | 494 | GNUNET_TESTING_cmd_helper_write_cb write_message); |
472 | 495 | ||
473 | 496 | ||
474 | /** | 497 | /** |
475 | * Create command. | 498 | * This command sends a GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TESTS_PREPARED message to the master loop. |
476 | * | 499 | * |
477 | * @param label name for command. | 500 | * @param label name for command. |
478 | * @param write_message Callback to write messages to the master loop. | 501 | * @param write_message Callback to write messages to the master loop. |
479 | * @return command. | 502 | * @return command. |
480 | */ | 503 | */ |
481 | struct GNUNET_TESTING_Command | 504 | struct GNUNET_TESTING_Command |
482 | GNUNET_TESTING_cmd_local_test_finished ( | 505 | GNUNET_TESTING_cmd_local_test_prepared (const char *label, |
483 | const char *label, | 506 | GNUNET_TESTING_cmd_helper_write_cb |
484 | TESTING_CMD_HELPER_write_cb write_message); | 507 | write_message); |
508 | |||
485 | 509 | ||
486 | /** | 510 | /** |
487 | * Create command. | 511 | * Create command. |
488 | * | 512 | * |
489 | * @param label name for command. | 513 | * @param label name for command. |
490 | * @param write_message Callback to write messages to the master loop. | 514 | * @param system_label Label of the cmd to setup a test environment. |
491 | * @param all_local_tests_prepared Flag which will be set from outside. | 515 | * @param no Decimal number representing the last byte of the IP address of this peer. |
516 | * @param node_ip The IP address of this node. | ||
517 | * @param cfgname Configuration file name for this peer. | ||
518 | * @param broadcast Flag indicating, if broadcast should be switched on. | ||
492 | * @return command. | 519 | * @return command. |
493 | */ | 520 | */ |
494 | struct GNUNET_TESTING_Command | 521 | struct GNUNET_TESTING_Command |
495 | GNUNET_TESTING_cmd_local_test_prepared (const char *label, | 522 | GNUNET_TESTING_cmd_start_peer (const char *label, |
496 | TESTING_CMD_HELPER_write_cb | 523 | const char *system_label, |
497 | write_message); | 524 | uint32_t no, |
525 | const char *node_ip, | ||
526 | const char *cfgname, | ||
527 | unsigned int broadcast); | ||
498 | 528 | ||
499 | 529 | ||
500 | /* ***** Netjail trait support ***** */ | 530 | /* ***** Netjail trait support ***** */ |
@@ -503,13 +533,14 @@ GNUNET_TESTING_cmd_local_test_prepared (const char *label, | |||
503 | /** | 533 | /** |
504 | * Call #op on all simple traits. | 534 | * Call #op on all simple traits. |
505 | */ | 535 | */ |
506 | #define GNUNET_TESTING_SIMPLE_NETJAIL_TRAITS(op) \ | 536 | #define GNUNET_TESTING_SIMPLE_NETJAIL_TRAITS(op, prefix) \ |
507 | op (test_system, const struct GNUNET_TESTING_System) \ | 537 | op (prefix, test_system, const struct GNUNET_TESTING_System) \ |
508 | op (async_context, const struct GNUNET_TESTING_AsyncContext) \ | 538 | op (prefix, async_context, struct GNUNET_TESTING_AsyncContext) \ |
509 | op (helper_handles, const struct GNUNET_HELPER_Handle *) \ | 539 | op (prefix, helper_handles, const struct GNUNET_HELPER_Handle *) \ |
510 | op (local_prepared_state, const struct LocalPreparedState) \ | 540 | op (prefix, local_prepared_state, const struct GNUNET_TESTING_LocalPreparedState) \ |
511 | op (block_state, const struct BlockState) | 541 | op (prefix, block_state, struct GNUNET_TESTING_BlockState) |
512 | 542 | ||
513 | GNUNET_TESTING_SIMPLE_NETJAIL_TRAITS (GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT) | 543 | GNUNET_TESTING_SIMPLE_NETJAIL_TRAITS (GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT, GNUNET_TESTING) |
544 | |||
514 | 545 | ||
515 | #endif | 546 | #endif |
diff --git a/src/include/gnunet_testing_ng_lib.h b/src/include/gnunet_testing_ng_lib.h index 1bc66e59d..407f50bb7 100644 --- a/src/include/gnunet_testing_ng_lib.h +++ b/src/include/gnunet_testing_ng_lib.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | Copyright (C) 2021 GNUnet e.V. | 3 | Copyright (C) 2021, 2023 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -19,7 +19,7 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @brief API for writing an interpreter to test GNUnet components | 22 | * @brief Meta-header for next-generation testing logic |
23 | * @author Christian Grothoff <christian@grothoff.org> | 23 | * @author Christian Grothoff <christian@grothoff.org> |
24 | * @author Marcello Stanisci | 24 | * @author Marcello Stanisci |
25 | * @author t3sserakt | 25 | * @author t3sserakt |
@@ -27,409 +27,15 @@ | |||
27 | #ifndef GNUNET_TESTING_NG_LIB_H | 27 | #ifndef GNUNET_TESTING_NG_LIB_H |
28 | #define GNUNET_TESTING_NG_LIB_H | 28 | #define GNUNET_TESTING_NG_LIB_H |
29 | 29 | ||
30 | #include "gnunet_util_lib.h" | ||
31 | #include "gnunet_testing_plugin.h" | ||
32 | #include "gnunet_testing_lib.h" | ||
33 | |||
34 | /** | ||
35 | * Stringify operator. | ||
36 | * | ||
37 | * @param a some expression to stringify. Must NOT be a macro. | ||
38 | * @return same expression as a constant string. | ||
39 | */ | ||
40 | #define GNUNET_S(a) #a | ||
41 | |||
42 | |||
43 | /* ********************* Helper functions ********************* */ | ||
44 | |||
45 | /** | ||
46 | * Print failing line number and trigger shutdown. Useful | ||
47 | * quite any time after the command "run" method has been called. | ||
48 | */ | ||
49 | #define GNUNET_TESTING_FAIL(is) \ | ||
50 | do \ | ||
51 | { \ | ||
52 | GNUNET_break (0); \ | ||
53 | GNUNET_TESTING_interpreter_fail (is); \ | ||
54 | return; \ | ||
55 | } while (0) | ||
56 | |||
57 | |||
58 | /* ******************* Generic interpreter logic ************ */ | ||
59 | |||
60 | /** | ||
61 | * Global state of the interpreter, used by a command | ||
62 | * to access information about other commands. | ||
63 | */ | ||
64 | struct GNUNET_TESTING_Interpreter; | ||
65 | |||
66 | /** | ||
67 | * State each asynchronous command must have in its closure. | ||
68 | */ | ||
69 | struct GNUNET_TESTING_AsyncContext | ||
70 | { | ||
71 | |||
72 | /** | ||
73 | * Interpreter we are part of. | ||
74 | */ | ||
75 | struct GNUNET_TESTING_Interpreter *is; | ||
76 | |||
77 | /** | ||
78 | * Function to call when done. | ||
79 | */ | ||
80 | GNUNET_SCHEDULER_TaskCallback cont; | ||
81 | |||
82 | /** | ||
83 | * Closure for @e cont. | ||
84 | */ | ||
85 | void *cont_cls; | ||
86 | |||
87 | /** | ||
88 | * Indication if the command finished (#GNUNET_OK). | ||
89 | * #GNUNET_NO if it did not finish, | ||
90 | * #GNUNET_SYSERR if it failed. | ||
91 | */ | ||
92 | enum GNUNET_GenericReturnValue finished; | ||
93 | }; | ||
94 | |||
95 | |||
96 | /** | ||
97 | * A command to be run by the interpreter. | ||
98 | */ | ||
99 | struct GNUNET_TESTING_Command | ||
100 | { | ||
101 | |||
102 | /** | ||
103 | * Closure for all commands with command-specific context information. | ||
104 | */ | ||
105 | void *cls; | ||
106 | |||
107 | /** | ||
108 | * Label for the command. | ||
109 | */ | ||
110 | const char *label; | ||
111 | |||
112 | /** | ||
113 | * Runs the command. Note that upon return, the interpreter | ||
114 | * will not automatically run the next command, as the command | ||
115 | * may continue asynchronously in other scheduler tasks. Thus, | ||
116 | * the command must ensure to eventually call | ||
117 | * #GNUNET_TESTING_interpreter_next() or | ||
118 | * #GNUNET_TESTING_interpreter_fail(). | ||
119 | * | ||
120 | * If this function creates some asynchronous activity, it should | ||
121 | * initialize @e finish to a function that can be used to wait for | ||
122 | * the asynchronous activity to terminate. | ||
123 | * | ||
124 | * @param cls closure | ||
125 | * @param is interpreter state | ||
126 | */ | ||
127 | void | ||
128 | (*run)(void *cls, | ||
129 | struct GNUNET_TESTING_Interpreter *is); | ||
130 | |||
131 | /** | ||
132 | * Pointer to the asynchronous context in the command's | ||
133 | * closure. Used by the | ||
134 | * #GNUNET_TESTING_async_finish() and | ||
135 | * #GNUNET_TESTING_async_fail() functions. | ||
136 | * | ||
137 | * Must be NULL if a command is synchronous. | ||
138 | */ | ||
139 | struct GNUNET_TESTING_AsyncContext *ac; | ||
140 | |||
141 | /** | ||
142 | * Clean up after the command. Run during forced termination | ||
143 | * (CTRL-C) or test failure or test success. | ||
144 | * | ||
145 | * @param cls closure | ||
146 | */ | ||
147 | void | ||
148 | (*cleanup)(void *cls); | ||
149 | |||
150 | /** | ||
151 | * Extract information from a command that is useful for other | ||
152 | * commands. Can be NULL if a command has no traits. | ||
153 | * | ||
154 | * @param cls closure | ||
155 | * @param[out] ret result (could be anything) | ||
156 | * @param trait name of the trait | ||
157 | * @param index index number of the object to extract. | ||
158 | * @return #GNUNET_OK on success, | ||
159 | * #GNUNET_NO if no trait was found | ||
160 | */ | ||
161 | enum GNUNET_GenericReturnValue | ||
162 | (*traits)(void *cls, | ||
163 | const void **ret, | ||
164 | const char *trait, | ||
165 | unsigned int index); | ||
166 | |||
167 | /** | ||
168 | * When did the execution of this command start? | ||
169 | */ | ||
170 | struct GNUNET_TIME_Absolute start_time; | ||
171 | |||
172 | /** | ||
173 | * When did the execution of this command finish? | ||
174 | */ | ||
175 | struct GNUNET_TIME_Absolute finish_time; | ||
176 | |||
177 | /** | ||
178 | * When did we start the last run of this command? Delta to @e finish_time | ||
179 | * gives the latency for the last successful run. Useful in case @e | ||
180 | * num_tries was positive and the command was run multiple times. In that | ||
181 | * case, the @e start_time gives the time when we first tried to run the | ||
182 | * command, so the difference between @e start_time and @e finish_time would | ||
183 | * be the time all of the @e num_tries took, while the delta to @e | ||
184 | * last_req_time is the time the last (successful) execution took. | ||
185 | */ | ||
186 | struct GNUNET_TIME_Absolute last_req_time; | ||
187 | |||
188 | /** | ||
189 | * In case @e asynchronous_finish is true, how long should we wait for this | ||
190 | * command to complete? If @e finish did not complete after this amount of | ||
191 | * time, the interpreter will fail. Should be set generously to ensure | ||
192 | * tests do not fail on slow systems. | ||
193 | */ | ||
194 | struct GNUNET_TIME_Relative default_timeout; | ||
195 | |||
196 | /** | ||
197 | * How often did we try to execute this command? (In case it is a request | ||
198 | * that is repated.) Note that a command must have some built-in retry | ||
199 | * mechanism for this value to be useful. | ||
200 | */ | ||
201 | unsigned int num_tries; | ||
202 | |||
203 | /** | ||
204 | * If "true", the interpreter should not immediately call | ||
205 | * @e finish, even if @e finish is non-NULL. Otherwise, | ||
206 | * #GNUNET_TESTING_cmd_finish() must be used | ||
207 | * to ensure that a command actually completed. | ||
208 | */ | ||
209 | bool asynchronous_finish; | ||
210 | |||
211 | }; | ||
212 | |||
213 | |||
214 | /** | ||
215 | * Lookup command by label. | ||
216 | * Only future commands are looked up. | ||
217 | * | ||
218 | * @param is interpreter to lookup command in | ||
219 | * @param label label of the command to lookup. | ||
220 | * @return the command, if it is found, or NULL. | ||
221 | */ | ||
222 | const struct GNUNET_TESTING_Command * | ||
223 | GNUNET_TESTING_interpreter_lookup_future_command ( | ||
224 | struct GNUNET_TESTING_Interpreter *is, | ||
225 | const char *label); | ||
226 | |||
227 | |||
228 | /** | ||
229 | * Lookup command by label. | ||
230 | * | ||
231 | * @param is interpreter to lookup command in | ||
232 | * @param label label of the command to lookup. | ||
233 | * @return the command, if it is found, or NULL. | ||
234 | */ | ||
235 | const struct GNUNET_TESTING_Command * | ||
236 | GNUNET_TESTING_interpreter_lookup_command ( | ||
237 | struct GNUNET_TESTING_Interpreter *is, | ||
238 | const char *label); | ||
239 | |||
240 | |||
241 | /** | ||
242 | * Lookup command by label. | ||
243 | * All commands, first into the past, then into the future are looked up. | ||
244 | * | ||
245 | * @param is interpreter to lookup command in | ||
246 | * @param label label of the command to lookup. | ||
247 | * @return the command, if it is found, or NULL. | ||
248 | */ | ||
249 | const struct GNUNET_TESTING_Command * | ||
250 | GNUNET_TESTING_interpreter_lookup_command_all ( | ||
251 | struct GNUNET_TESTING_Interpreter *is, | ||
252 | const char *label); | ||
253 | |||
254 | |||
255 | /** | ||
256 | * Obtain label of the command being now run. | ||
257 | * | ||
258 | * @param is interpreter state. | ||
259 | * @return the label. | ||
260 | */ | ||
261 | const char * | ||
262 | GNUNET_TESTING_interpreter_get_current_label ( | ||
263 | struct GNUNET_TESTING_Interpreter *is); | ||
264 | |||
265 | |||
266 | /** | ||
267 | * Current command failed, clean up and fail the test case. | ||
268 | * | ||
269 | * @param is interpreter state. | ||
270 | */ | ||
271 | void | ||
272 | GNUNET_TESTING_interpreter_fail (struct GNUNET_TESTING_Interpreter *is); | ||
273 | |||
274 | |||
275 | /** | ||
276 | * The asynchronous command of @a ac has failed. | ||
277 | * | ||
278 | * @param ac command-specific context | ||
279 | */ | ||
280 | void | ||
281 | GNUNET_TESTING_async_fail (struct GNUNET_TESTING_AsyncContext *ac); | ||
282 | |||
283 | |||
284 | /** | ||
285 | * The asynchronous command of @a ac has finished. | ||
286 | * | ||
287 | * @param ac command-specific context | ||
288 | */ | ||
289 | void | ||
290 | GNUNET_TESTING_async_finish (struct GNUNET_TESTING_AsyncContext *ac); | ||
291 | |||
292 | |||
293 | /** | ||
294 | * Create command array terminator. | ||
295 | * | ||
296 | * @return a end-command. | ||
297 | */ | ||
298 | struct GNUNET_TESTING_Command | ||
299 | GNUNET_TESTING_cmd_end (void); | ||
300 | |||
301 | |||
302 | /** | ||
303 | * Turn asynchronous command into non blocking command by setting asynchronous_finish to true. | ||
304 | * | ||
305 | * @param cmd command to make synchronous. | ||
306 | * @return a finish-command. | ||
307 | */ | ||
308 | struct GNUNET_TESTING_Command | ||
309 | GNUNET_TESTING_cmd_make_unblocking (struct GNUNET_TESTING_Command cmd); | ||
310 | |||
311 | |||
312 | /** | ||
313 | * Create (synchronous) command that waits for another command to finish. | ||
314 | * If @a cmd_ref did not finish after @a timeout, this command will fail | ||
315 | * the test case. | ||
316 | * | ||
317 | * @param finish_label label for this command | ||
318 | * @param cmd_ref reference to a previous command which we should | ||
319 | * wait for (call `finish()` on) | ||
320 | * @param timeout how long to wait at most for @a cmd_ref to finish | ||
321 | * @return a finish-command. | ||
322 | */ | ||
323 | const struct GNUNET_TESTING_Command | ||
324 | GNUNET_TESTING_cmd_finish (const char *finish_label, | ||
325 | const char *cmd_ref, | ||
326 | struct GNUNET_TIME_Relative timeout); | ||
327 | |||
328 | 30 | ||
329 | /** | 31 | #include "gnunet_util_lib.h" |
330 | * Make the instruction pointer point to @a target_label | ||
331 | * only if @a counter is greater than zero. | ||
332 | * | ||
333 | * @param label command label | ||
334 | * @param target_label label of the new instruction pointer's destination after the jump; | ||
335 | * must be before the current instruction | ||
336 | * @param counter counts how many times the rewinding is to happen. | ||
337 | */ | ||
338 | struct GNUNET_TESTING_Command | ||
339 | GNUNET_TESTING_cmd_rewind_ip (const char *label, | ||
340 | const char *target_label, | ||
341 | unsigned int counter); | ||
342 | |||
343 | |||
344 | /** | ||
345 | * Function called with the final result of the test. | ||
346 | * | ||
347 | * @param cls closure | ||
348 | * @param rv #GNUNET_OK if the test passed | ||
349 | */ | ||
350 | typedef void | ||
351 | (*GNUNET_TESTING_ResultCallback)(void *cls, | ||
352 | enum GNUNET_GenericReturnValue rv); | ||
353 | |||
354 | |||
355 | /** | ||
356 | * Run the testsuite. Note, CMDs are copied into | ||
357 | * the interpreter state because they are _usually_ | ||
358 | * defined into the "run" method that returns after | ||
359 | * having scheduled the test interpreter. | ||
360 | * | ||
361 | * @param commands the list of command to execute | ||
362 | * @param timeout how long to wait for each command to execute | ||
363 | * @param rc function to call with the final result | ||
364 | * @param rc_cls closure for @a rc | ||
365 | */ | ||
366 | void | ||
367 | GNUNET_TESTING_run (struct GNUNET_TESTING_Command *commands, | ||
368 | struct GNUNET_TIME_Relative timeout, | ||
369 | GNUNET_TESTING_ResultCallback rc, | ||
370 | void *rc_cls); | ||
371 | |||
372 | |||
373 | /** | ||
374 | * Start a GNUnet scheduler event loop and | ||
375 | * run the testsuite. Return 0 upon success. | ||
376 | * Expected to be called directly from main(). | ||
377 | * | ||
378 | * @param commands the list of command to execute | ||
379 | * @param timeout how long to wait for each command to execute | ||
380 | * @return EXIT_SUCCESS on success, EXIT_FAILURE on failure | ||
381 | */ | ||
382 | int | ||
383 | GNUNET_TESTING_main (struct GNUNET_TESTING_Command *commands, | ||
384 | struct GNUNET_TIME_Relative timeout); | ||
385 | |||
386 | |||
387 | /** | ||
388 | * Look for substring in a programs' name. | ||
389 | * | ||
390 | * @param prog program's name to look into | ||
391 | * @param marker chunk to find in @a prog | ||
392 | * // FIXME: this does not belong here! => libgnunetutil, maybe? | ||
393 | * // FIXME: return bool? document return value! | ||
394 | */ | ||
395 | int | ||
396 | GNUNET_TESTING_has_in_name (const char *prog, | ||
397 | const char *marker); | ||
398 | |||
399 | |||
400 | /* ************** Specific interpreter commands ************ */ | ||
401 | |||
402 | |||
403 | /** | ||
404 | * Returns the actual running command. | ||
405 | * | ||
406 | * @param is Global state of the interpreter, used by a command | ||
407 | * to access information about other commands. | ||
408 | * @return The actual running command. | ||
409 | */ | ||
410 | struct GNUNET_TESTING_Command * | ||
411 | GNUNET_TESTING_interpreter_get_current_command ( | ||
412 | struct GNUNET_TESTING_Interpreter *is); | ||
413 | |||
414 | |||
415 | /** | ||
416 | * Check if the command is running. | ||
417 | * | ||
418 | * @param cmd The command to check. | ||
419 | * @return GNUNET_NO if the command is not running, GNUNET_YES if it is running. | ||
420 | */ | ||
421 | enum GNUNET_GenericReturnValue | ||
422 | GNUNET_TESTING_running (const struct GNUNET_TESTING_Command *command); | ||
423 | 32 | ||
33 | /* FIXME: legacy test header, to be removed!! */ | ||
34 | #include "gnunet_testing_lib.h" | ||
424 | 35 | ||
425 | /** | 36 | #include "gnunet_testing_plugin.h" |
426 | * Check if a command is finished. | 37 | #include "gnunet_testing_loop_lib.h" |
427 | * | 38 | #include "gnunet_testing_netjail_lib.h" |
428 | * @param cmd The command to check. | ||
429 | * @return GNUNET_NO if the command is not finished, GNUNET_YES if it is finished. | ||
430 | */ | ||
431 | enum GNUNET_GenericReturnValue | ||
432 | GNUNET_TESTING_finished (struct GNUNET_TESTING_Command *command); | ||
433 | 39 | ||
434 | 40 | ||
435 | /** | 41 | /** |
@@ -437,14 +43,12 @@ GNUNET_TESTING_finished (struct GNUNET_TESTING_Command *command); | |||
437 | * | 43 | * |
438 | * @param label command label. | 44 | * @param label command label. |
439 | * @param process_label label of a command that has a process trait | 45 | * @param process_label label of a command that has a process trait |
440 | * @param process_index index of the process trait at @a process_label // FIXME: enum? needed? | ||
441 | * @param signal signal to send to @a process. | 46 | * @param signal signal to send to @a process. |
442 | * @return the command. | 47 | * @return the command. |
443 | */ | 48 | */ |
444 | struct GNUNET_TESTING_Command | 49 | struct GNUNET_TESTING_Command |
445 | GNUNET_TESTING_cmd_signal (const char *label, | 50 | GNUNET_TESTING_cmd_signal (const char *label, |
446 | const char *process_label, | 51 | const char *process_label, |
447 | unsigned int process_index, | ||
448 | int signal); | 52 | int signal); |
449 | 53 | ||
450 | 54 | ||
@@ -461,244 +65,51 @@ GNUNET_TESTING_cmd_sleep (const char *label, | |||
461 | 65 | ||
462 | 66 | ||
463 | /** | 67 | /** |
464 | * Create a "batch" command. Such command takes a end_CMD-terminated array of | 68 | * Command to execute a script synchronously. |
465 | * CMDs and executed them. Once it hits the end CMD, it passes the control to | ||
466 | * the next top-level CMD, regardless of it being another batch or ordinary | ||
467 | * CMD. | ||
468 | * | ||
469 | * @param label the command label. | ||
470 | * @param batch array of CMDs to execute. | ||
471 | * @return the command. | ||
472 | */ | ||
473 | struct GNUNET_TESTING_Command | ||
474 | GNUNET_TESTING_cmd_batch (const char *label, | ||
475 | struct GNUNET_TESTING_Command *batch); | ||
476 | |||
477 | |||
478 | /** | ||
479 | * Performance counter. | ||
480 | * // FIXME: this might not belong here! | ||
481 | */ | ||
482 | struct GNUNET_TESTING_Timer | ||
483 | { | ||
484 | /** | ||
485 | * For which type of commands. | ||
486 | */ | ||
487 | const char *prefix; | ||
488 | |||
489 | /** | ||
490 | * Total time spend in all commands of this type. | ||
491 | */ | ||
492 | struct GNUNET_TIME_Relative total_duration; | ||
493 | |||
494 | /** | ||
495 | * Total time spend waiting for the *successful* exeuction | ||
496 | * in all commands of this type. | ||
497 | */ | ||
498 | struct GNUNET_TIME_Relative success_latency; | ||
499 | |||
500 | /** | ||
501 | * Number of commands summed up. | ||
502 | */ | ||
503 | unsigned int num_commands; | ||
504 | |||
505 | /** | ||
506 | * Number of retries summed up. | ||
507 | */ | ||
508 | unsigned int num_retries; | ||
509 | }; | ||
510 | |||
511 | |||
512 | /** | ||
513 | * Retrieve the public key from the test system with the unique node id. | ||
514 | * | ||
515 | * @param num The unique node id. | ||
516 | * @param tl_system The test system. | ||
517 | * @return The peer identity wrapping the public key. | ||
518 | */ | ||
519 | struct GNUNET_PeerIdentity * | ||
520 | GNUNET_TESTING_get_pub_key (unsigned int num, | ||
521 | const struct GNUNET_TESTING_System *tl_system); | ||
522 | |||
523 | |||
524 | /** | ||
525 | * Obtain performance data from the interpreter. | ||
526 | * | 69 | * |
527 | * @param timers what commands (by label) to obtain runtimes for | 70 | * FIXME: is this accurate? How is this limited to BASH scripts or even scripts? |
528 | * @return the command | ||
529 | */ | ||
530 | struct GNUNET_TESTING_Command | ||
531 | GNUNET_TESTING_cmd_stat (struct GNUNET_TESTING_Timer *timers); | ||
532 | |||
533 | |||
534 | /* *** Generic trait logic for implementing traits ********* */ | ||
535 | |||
536 | /** | ||
537 | * A trait. | ||
538 | */ | ||
539 | struct GNUNET_TESTING_Trait | ||
540 | { | ||
541 | /** | ||
542 | * Index number associated with the trait. This gives the | ||
543 | * possibility to have _multiple_ traits on offer under the | ||
544 | * same name. | ||
545 | */ | ||
546 | unsigned int index; | ||
547 | |||
548 | /** | ||
549 | * Trait type, for example "reserve-pub" or "coin-priv". | ||
550 | */ | ||
551 | const char *trait_name; | ||
552 | |||
553 | /** | ||
554 | * Pointer to the piece of data to offer. | ||
555 | */ | ||
556 | const void *ptr; | ||
557 | }; | ||
558 | |||
559 | |||
560 | /** | ||
561 | * "end" trait. Because traits are offered into arrays, | ||
562 | * this type of trait is used to mark the end of such arrays; | ||
563 | * useful when iterating over those. | ||
564 | */ | ||
565 | struct GNUNET_TESTING_Trait | ||
566 | GNUNET_TESTING_trait_end (void); | ||
567 | |||
568 | |||
569 | /** | ||
570 | * Extract a trait. | ||
571 | * | 71 | * |
572 | * @param traits the array of all the traits. | 72 | * @param label Label of the command. |
573 | * @param[out] ret where to store the result. | 73 | * @param script The name of the script. |
574 | * @param trait type of the trait to extract. | 74 | * @param script_argv The arguments of the script. |
575 | * @param index index number of the trait to extract. | 75 | */ |
576 | * @return #GNUNET_OK when the trait is found. | 76 | const struct GNUNET_TESTING_Command |
577 | */ | 77 | GNUNET_TESTING_cmd_exec_bash_script (const char *label, |
578 | enum GNUNET_GenericReturnValue | 78 | const char *script, |
579 | GNUNET_TESTING_get_trait (const struct GNUNET_TESTING_Trait *traits, | 79 | char *const script_argv[], |
580 | const void **ret, | 80 | // FIXME: wtf are these two args here for!? |
581 | const char *trait, | 81 | int argc, |
582 | unsigned int index); | 82 | GNUNET_ChildCompletedCallback cb); |
583 | |||
584 | |||
585 | /* ****** Specific traits supported by this component ******* */ | ||
586 | |||
587 | |||
588 | /** | ||
589 | * Create headers for a trait with name @a name for | ||
590 | * statically allocated data of type @a type. | ||
591 | */ | ||
592 | #define GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT(name,type) \ | ||
593 | enum GNUNET_GenericReturnValue \ | ||
594 | GNUNET_TESTING_get_trait_ ## name ( \ | ||
595 | const struct GNUNET_TESTING_Command *cmd, \ | ||
596 | type **ret); \ | ||
597 | struct GNUNET_TESTING_Trait \ | ||
598 | GNUNET_TESTING_make_trait_ ## name ( \ | ||
599 | type * value); | ||
600 | |||
601 | |||
602 | /** | ||
603 | * Create C implementation for a trait with name @a name for statically | ||
604 | * allocated data of type @a type. | ||
605 | */ | ||
606 | #define GNUNET_TESTING_MAKE_IMPL_SIMPLE_TRAIT(name,type) \ | ||
607 | enum GNUNET_GenericReturnValue \ | ||
608 | GNUNET_TESTING_get_trait_ ## name ( \ | ||
609 | const struct GNUNET_TESTING_Command *cmd, \ | ||
610 | type **ret) \ | ||
611 | { \ | ||
612 | if (NULL == cmd->traits) return GNUNET_SYSERR; \ | ||
613 | return cmd->traits (cmd->cls, \ | ||
614 | (const void **) ret, \ | ||
615 | GNUNET_S (name), \ | ||
616 | 0); \ | ||
617 | } \ | ||
618 | struct GNUNET_TESTING_Trait \ | ||
619 | GNUNET_TESTING_make_trait_ ## name ( \ | ||
620 | type * value) \ | ||
621 | { \ | ||
622 | struct GNUNET_TESTING_Trait ret = { \ | ||
623 | .trait_name = GNUNET_S (name), \ | ||
624 | .ptr = (const void *) value \ | ||
625 | }; \ | ||
626 | return ret; \ | ||
627 | } | ||
628 | |||
629 | 83 | ||
630 | /** | ||
631 | * Create headers for a trait with name @a name for | ||
632 | * statically allocated data of type @a type. | ||
633 | */ | ||
634 | #define GNUNET_TESTING_MAKE_DECL_INDEXED_TRAIT(name,type) \ | ||
635 | enum GNUNET_GenericReturnValue \ | ||
636 | GNUNET_TESTING_get_trait_ ## name ( \ | ||
637 | const struct GNUNET_TESTING_Command *cmd, \ | ||
638 | unsigned int index, \ | ||
639 | type **ret); \ | ||
640 | struct GNUNET_TESTING_Trait \ | ||
641 | GNUNET_TESTING_make_trait_ ## name ( \ | ||
642 | unsigned int index, \ | ||
643 | type * value); | ||
644 | 84 | ||
645 | 85 | ||
646 | /** | 86 | /* ****** Specific traits needed by this component ******* */ |
647 | * Create C implementation for a trait with name @a name for statically | ||
648 | * allocated data of type @a type. | ||
649 | */ | ||
650 | #define GNUNET_TESTING_MAKE_IMPL_INDEXED_TRAIT(name,type) \ | ||
651 | enum GNUNET_GenericReturnValue \ | ||
652 | GNUNET_TESTING_get_trait_ ## name ( \ | ||
653 | const struct GNUNET_TESTING_Command *cmd, \ | ||
654 | unsigned int index, \ | ||
655 | type **ret) \ | ||
656 | { \ | ||
657 | if (NULL == cmd->traits) return GNUNET_SYSERR; \ | ||
658 | return cmd->traits (cmd->cls, \ | ||
659 | (const void **) ret, \ | ||
660 | GNUNET_S (name), \ | ||
661 | index); \ | ||
662 | } \ | ||
663 | struct GNUNET_TESTING_Trait \ | ||
664 | GNUNET_TESTING_make_trait_ ## name ( \ | ||
665 | unsigned int index, \ | ||
666 | type * value) \ | ||
667 | { \ | ||
668 | struct GNUNET_TESTING_Trait ret = { \ | ||
669 | .index = index, \ | ||
670 | .trait_name = GNUNET_S (name), \ | ||
671 | .ptr = (const void *) value \ | ||
672 | }; \ | ||
673 | return ret; \ | ||
674 | } | ||
675 | 87 | ||
676 | 88 | ||
677 | /** | 89 | /** |
678 | * Call #op on all simple traits. | 90 | * Call #op on all simple traits. |
679 | */ | 91 | */ |
680 | #define GNUNET_TESTING_SIMPLE_TRAITS(op) \ | 92 | #define GNUNET_TESTING_SIMPLE_TRAITS(op, prefix) \ |
681 | op (batch_cmds, struct GNUNET_TESTING_Command *) \ | 93 | op (prefix, process, struct GNUNET_OS_Process *) |
682 | op (process, struct GNUNET_OS_Process *) | 94 | |
683 | 95 | ||
96 | GNUNET_TESTING_SIMPLE_TRAITS (GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT, GNUNET_TESTING) | ||
684 | 97 | ||
685 | /** | 98 | /** |
686 | * Call #op on all indexed traits. | 99 | * Call #op on all indexed traits. |
687 | */ | 100 | */ |
688 | #define GNUNET_TESTING_INDEXED_TRAITS(op) \ | 101 | #define GNUNET_TESTING_INDEXED_TRAITS(op, prefix) \ |
689 | op (uint32, const uint32_t) \ | 102 | op (prefix, uint32, const uint32_t) \ |
690 | op (uint64, const uint64_t) \ | 103 | op (prefix, uint64, const uint64_t) \ |
691 | op (int64, const int64_t) \ | 104 | op (prefix, int64, const int64_t) \ |
692 | op (uint, const unsigned int) \ | 105 | op (prefix, uint, const unsigned int) \ |
693 | op (string, const char) \ | 106 | op (prefix, string, const char) \ |
694 | op (cmd, const struct GNUNET_TESTING_Command) \ | 107 | op (prefix, uuid, const struct GNUNET_Uuid) \ |
695 | op (uuid, const struct GNUNET_Uuid) \ | 108 | op (prefix, time, const struct GNUNET_TIME_Absolute) \ |
696 | op (time, const struct GNUNET_TIME_Absolute) \ | 109 | op (prefix, absolute_time, const struct GNUNET_TIME_Absolute) \ |
697 | op (absolute_time, const struct GNUNET_TIME_Absolute) \ | 110 | op (prefix, relative_time, const struct GNUNET_TIME_Relative) |
698 | op (relative_time, const struct GNUNET_TIME_Relative) | ||
699 | 111 | ||
700 | GNUNET_TESTING_SIMPLE_TRAITS (GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT) | 112 | GNUNET_TESTING_INDEXED_TRAITS (GNUNET_TESTING_MAKE_DECL_INDEXED_TRAIT, GNUNET_TESTING) |
701 | 113 | ||
702 | GNUNET_TESTING_INDEXED_TRAITS (GNUNET_TESTING_MAKE_DECL_INDEXED_TRAIT) | ||
703 | 114 | ||
704 | #endif | 115 | #endif |
diff --git a/src/include/gnunet_testing_plugin.h b/src/include/gnunet_testing_plugin.h index b59d2cea1..b030bc8a8 100644 --- a/src/include/gnunet_testing_plugin.h +++ b/src/include/gnunet_testing_plugin.h | |||
@@ -28,6 +28,8 @@ | |||
28 | #ifndef GNUNET_TESTING_PLUGIN_H | 28 | #ifndef GNUNET_TESTING_PLUGIN_H |
29 | #define GNUNET_TESTING_PLUGIN_H | 29 | #define GNUNET_TESTING_PLUGIN_H |
30 | 30 | ||
31 | #include "gnunet_common.h" | ||
32 | |||
31 | #ifdef __cplusplus | 33 | #ifdef __cplusplus |
32 | extern "C" | 34 | extern "C" |
33 | { | 35 | { |
@@ -36,41 +38,101 @@ extern "C" | |||
36 | #endif | 38 | #endif |
37 | #endif | 39 | #endif |
38 | 40 | ||
41 | |||
42 | /** | ||
43 | * Callback function to write messages from the helper process running on a netjail node to the master process. | ||
44 | * | ||
45 | * @param message The message to write. | ||
46 | * @param msg_length The length of the message. | ||
47 | */ | ||
39 | typedef void | 48 | typedef void |
40 | (*TESTING_CMD_HELPER_write_cb) (struct GNUNET_MessageHeader *message, size_t | 49 | (*GNUNET_TESTING_cmd_helper_write_cb) (struct GNUNET_MessageHeader *message, |
41 | msg_length); | 50 | size_t msg_length); |
42 | 51 | ||
52 | /** | ||
53 | * Callback function which writes a message from the helper process running on a netjail node to the master process * signaling that the test case running on the netjail node finished. | ||
54 | */ | ||
43 | typedef void | 55 | typedef void |
44 | (*GNUNET_TESTING_PLUGIN_StartTestCase) (TESTING_CMD_HELPER_write_cb | 56 | (*GNUNET_TESTING_cmd_helper_finish_cb) (); |
45 | write_message, char *router_ip, | 57 | |
46 | char *node_ip, | ||
47 | char *n, | ||
48 | char *m, | ||
49 | char *local_m, | ||
50 | char *topology_data, | ||
51 | unsigned int *read_file); | ||
52 | 58 | ||
59 | /** | ||
60 | * Function to be implemented for each test case plugin which starts the test case on a netjail node. | ||
61 | * | ||
62 | * @param write_message Callback function to write messages from the helper process running on a | ||
63 | * netjail node to the master process. | ||
64 | * @param router_ip Global address of the network namespace, if the helper process is for a node in a subnet. | ||
65 | * @param node_ip The IP address of the node. | ||
66 | * @param m The number of the node in a network namespace. | ||
67 | * @param n The number of the network namespace. | ||
68 | * @param local_m The number of nodes in a network namespace. | ||
69 | * @param topology_data A file name for the file containing the topology configuration, or a string containing | ||
70 | * the topology configuration. | ||
71 | * @param read_file If read_file is GNUNET_YES this string is the filename for the topology configuration, | ||
72 | * if read_file is GNUNET_NO the string contains the topology configuration. | ||
73 | * @param finish_cb Callback function which writes a message from the helper process running on a netjail | ||
74 | * node to the master process * signaling that the test case running on the netjail node finished. | ||
75 | * @return Returns The struct GNUNET_TESTING_Interpreter of the command loop running on this netjail node. | ||
76 | */ | ||
77 | typedef struct GNUNET_TESTING_Interpreter * | ||
78 | (*GNUNET_TESTING_PLUGIN_StartTestCase) ( | ||
79 | GNUNET_TESTING_cmd_helper_write_cb write_message, | ||
80 | const char *router_ip, | ||
81 | const char *node_ip, | ||
82 | const char *n, | ||
83 | const char *m, | ||
84 | const char *local_m, | ||
85 | const char *topology_data, | ||
86 | unsigned int *read_file, | ||
87 | GNUNET_TESTING_cmd_helper_finish_cb | ||
88 | finish_cb); | ||
53 | 89 | ||
90 | /** | ||
91 | * DEPRECATED | ||
92 | * The helper process received a message of type | ||
93 | * GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED. This will finish the blocking command | ||
94 | * GNUNET_TESTING_cmd_block_until_external_trigger which was execute right after the command | ||
95 | * GNUNET_TESTING_cmd_send_peer_ready. | ||
96 | */ | ||
54 | typedef void | 97 | typedef void |
55 | (*GNUNET_TESTING_PLUGIN_ALL_PEERS_STARTED) (); | 98 | (*GNUNET_TESTING_PLUGIN_ALL_PEERS_STARTED) (); |
56 | 99 | ||
57 | 100 | /** | |
101 | * DEPRECATED | ||
102 | * The helper process received a message of type | ||
103 | * GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_LOCAL_TESTS_PREPARED. This will finish the blocking command | ||
104 | * GNUNET_TESTING_cmd_local_test_prepared which was execute right after the command | ||
105 | * GNUNET_TRANSPORT_cmd_connect_peers. | ||
106 | * FIXME: do not use ALL CAPS | ||
107 | */ | ||
58 | typedef void | 108 | typedef void |
59 | (*GNUNET_TESTING_PLUGIN_ALL_LOCAL_TESTS_PREPARED) (); | 109 | (*GNUNET_TESTING_PLUGIN_ALL_LOCAL_TESTS_PREPARED) (); |
60 | 110 | ||
61 | 111 | ||
112 | /** | ||
113 | * This function returns a struct GNUNET_TESTING_BarrierList, which is a list of all barriers | ||
114 | * this test case will wait for. | ||
115 | * | ||
116 | * @return A struct GNUNET_TESTING_BarrierList. | ||
117 | * FIXME: do not use ALL CAPS | ||
118 | */ | ||
119 | typedef struct GNUNET_TESTING_BarrierList* | ||
120 | (*GNUNET_TESTING_PLUGIN_GET_WAITING_FOR_BARRIERS) (void); | ||
121 | |||
122 | |||
123 | /** | ||
124 | * The plugin API every test case plugin has to implement. | ||
125 | */ | ||
62 | struct GNUNET_TESTING_PluginFunctions | 126 | struct GNUNET_TESTING_PluginFunctions |
63 | { | 127 | { |
64 | /** | ||
65 | * Closure for all of the callbacks. | ||
66 | */ | ||
67 | void *cls; | ||
68 | 128 | ||
69 | GNUNET_TESTING_PLUGIN_StartTestCase start_testcase; | 129 | GNUNET_TESTING_PLUGIN_StartTestCase start_testcase; |
70 | 130 | ||
71 | GNUNET_TESTING_PLUGIN_ALL_PEERS_STARTED all_peers_started; | 131 | GNUNET_TESTING_PLUGIN_ALL_PEERS_STARTED all_peers_started; |
72 | 132 | ||
73 | GNUNET_TESTING_PLUGIN_ALL_LOCAL_TESTS_PREPARED all_local_tests_prepared; | 133 | GNUNET_TESTING_PLUGIN_ALL_LOCAL_TESTS_PREPARED all_local_tests_prepared; |
134 | |||
135 | GNUNET_TESTING_PLUGIN_GET_WAITING_FOR_BARRIERS get_waiting_for_barriers; | ||
74 | }; | 136 | }; |
75 | 137 | ||
76 | #if 0 /* keep Emacsens' auto-indent happy */ | 138 | #if 0 /* keep Emacsens' auto-indent happy */ |
diff --git a/src/include/gnunet_time_lib.h b/src/include/gnunet_time_lib.h index d59eb984d..88dafc62c 100644 --- a/src/include/gnunet_time_lib.h +++ b/src/include/gnunet_time_lib.h | |||
@@ -19,6 +19,10 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup libgnunetutil | ||
23 | * Multi-function utilities library for GNUnet programs | ||
24 | * @{ | ||
25 | * | ||
22 | * @author Christian Grothoff | 26 | * @author Christian Grothoff |
23 | * | 27 | * |
24 | * @file | 28 | * @file |
@@ -40,6 +44,7 @@ extern "C" | |||
40 | #endif | 44 | #endif |
41 | #endif | 45 | #endif |
42 | 46 | ||
47 | |||
43 | #include "gnunet_common.h" | 48 | #include "gnunet_common.h" |
44 | 49 | ||
45 | /** | 50 | /** |
@@ -238,7 +243,7 @@ GNUNET_TIME_timestamp2s (struct GNUNET_TIME_Timestamp ts); | |||
238 | * Note that the returned value will be overwritten if this function | 243 | * Note that the returned value will be overwritten if this function |
239 | * is called again. | 244 | * is called again. |
240 | * | 245 | * |
241 | * @param t the absolute time to convert | 246 | * @param ts the absolute time to convert |
242 | * @return timestamp in human-readable form in local time | 247 | * @return timestamp in human-readable form in local time |
243 | */ | 248 | */ |
244 | const char * | 249 | const char * |
@@ -614,6 +619,17 @@ GNUNET_TIME_absolute_subtract (struct GNUNET_TIME_Absolute start, | |||
614 | * Multiply relative time by a given factor. | 619 | * Multiply relative time by a given factor. |
615 | * | 620 | * |
616 | * @param rel some duration | 621 | * @param rel some duration |
622 | * @param factor double to multiply with | ||
623 | * @return FOREVER if rel=FOREVER or on overflow; otherwise rel*factor | ||
624 | */ | ||
625 | struct GNUNET_TIME_Relative | ||
626 | GNUNET_TIME_relative_multiply_double (struct GNUNET_TIME_Relative rel, | ||
627 | double factor); | ||
628 | |||
629 | /** | ||
630 | * Multiply relative time by a given factor. | ||
631 | * | ||
632 | * @param rel some duration | ||
617 | * @param factor integer to multiply with | 633 | * @param factor integer to multiply with |
618 | * @return FOREVER if rel=FOREVER or on overflow; otherwise rel*factor | 634 | * @return FOREVER if rel=FOREVER or on overflow; otherwise rel*factor |
619 | */ | 635 | */ |
@@ -910,4 +926,6 @@ GNUNET_TIME_absolute_get_monotonic ( | |||
910 | 926 | ||
911 | /** @} */ /* end of group time */ | 927 | /** @} */ /* end of group time */ |
912 | 928 | ||
929 | /** @} */ /* end of group addition */ | ||
930 | |||
913 | /* end of gnunet_time_lib.h */ | 931 | /* end of gnunet_time_lib.h */ |
diff --git a/src/include/gnunet_transport_application_service.h b/src/include/gnunet_transport_application_service.h index f5d4c4ee0..66512089a 100644 --- a/src/include/gnunet_transport_application_service.h +++ b/src/include/gnunet_transport_application_service.h | |||
@@ -18,23 +18,24 @@ | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @addtogroup Backbone | ||
22 | * @{ | ||
23 | * | ||
21 | * @file | 24 | * @file |
22 | * Bandwidth allocation API for applications to interact with | 25 | * Bandwidth allocation API for applications to interact with |
23 | * | 26 | * |
24 | * @author Christian Grothoff | 27 | * @author Christian Grothoff |
25 | * @author Matthias Wachs | 28 | * @author Matthias Wachs |
26 | * | 29 | * |
27 | * @defgroup TRANSPORT service | 30 | * @defgroup TNG Transport Next Generation service |
28 | * Bandwidth allocation | ||
29 | * | ||
30 | * @{ | 31 | * @{ |
31 | */ | 32 | */ |
32 | #ifndef GNUNET_TRANSPORT_APPLICATION_SERVICE_H | 33 | #ifndef GNUNET_TRANSPORT_APPLICATION_SERVICE_H |
33 | #define GNUNET_TRANSPORT_APPLICATION_SERVICE_H | 34 | #define GNUNET_TRANSPORT_APPLICATION_SERVICE_H |
34 | 35 | ||
36 | |||
35 | #include "gnunet_constants.h" | 37 | #include "gnunet_constants.h" |
36 | #include "gnunet_util_lib.h" | 38 | #include "gnunet_util_lib.h" |
37 | #include "gnunet_nt_lib.h" | ||
38 | #include "gnunet_testing_lib.h" | 39 | #include "gnunet_testing_lib.h" |
39 | #include "gnunet_testing_ng_lib.h" | 40 | #include "gnunet_testing_ng_lib.h" |
40 | 41 | ||
@@ -118,5 +119,7 @@ GNUNET_TRANSPORT_application_validate ( | |||
118 | 119 | ||
119 | /** @} */ /* end of group */ | 120 | /** @} */ /* end of group */ |
120 | 121 | ||
122 | /** @} */ /* end of group addition */ | ||
123 | |||
121 | #endif | 124 | #endif |
122 | /* end of file gnunet_ats_application_service.h */ | 125 | /* end of file gnunet_ats_application_service.h */ |
diff --git a/src/include/gnunet_transport_communication_service.h b/src/include/gnunet_transport_communication_service.h index 81a382fb2..ea947911f 100644 --- a/src/include/gnunet_transport_communication_service.h +++ b/src/include/gnunet_transport_communication_service.h | |||
@@ -19,12 +19,15 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup Backbone | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
25 | * API of the transport service towards the communicator processes. | 28 | * API of the transport service towards the communicator processes. |
26 | * | 29 | * |
27 | * @defgroup transport TRANSPORT service | 30 | * @defgroup TNG Transport Next Generation service |
28 | * Low-level communication with other peers | 31 | * Low-level communication with other peers |
29 | * | 32 | * |
30 | * @see [Documentation](https://gnunet.org/transport-service) | 33 | * @see [Documentation](https://gnunet.org/transport-service) |
@@ -42,8 +45,8 @@ extern "C" { | |||
42 | #endif | 45 | #endif |
43 | #endif | 46 | #endif |
44 | 47 | ||
48 | |||
45 | #include "gnunet_util_lib.h" | 49 | #include "gnunet_util_lib.h" |
46 | #include "gnunet_nt_lib.h" | ||
47 | 50 | ||
48 | /** | 51 | /** |
49 | * Version number of the transport communication API. | 52 | * Version number of the transport communication API. |
@@ -71,7 +74,7 @@ extern "C" { | |||
71 | * @param address where to send the message, human-readable | 74 | * @param address where to send the message, human-readable |
72 | * communicator-specific format, 0-terminated, UTF-8 | 75 | * communicator-specific format, 0-terminated, UTF-8 |
73 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the provided address is | 76 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the provided address is |
74 | * invalid | 77 | * invalid, #GNUNET_NO if this address is already (beging) connected to. |
75 | */ | 78 | */ |
76 | typedef int (*GNUNET_TRANSPORT_CommunicatorMqInit) ( | 79 | typedef int (*GNUNET_TRANSPORT_CommunicatorMqInit) ( |
77 | void *cls, | 80 | void *cls, |
@@ -135,7 +138,8 @@ typedef void (*GNUNET_TRANSPORT_CommunicatorNotify) ( | |||
135 | * Connect to the transport service. | 138 | * Connect to the transport service. |
136 | * | 139 | * |
137 | * @param cfg configuration to use | 140 | * @param cfg configuration to use |
138 | * @param config_section section of the configuration to use for options | 141 | * @param config_section_name section of the configuration to use for |
142 | * options | ||
139 | * @param addr_prefix address prefix for addresses supported by this | 143 | * @param addr_prefix address prefix for addresses supported by this |
140 | * communicator, could be NULL for incoming-only communicators | 144 | * communicator, could be NULL for incoming-only communicators |
141 | * @param cc what characteristics does the communicator have? | 145 | * @param cc what characteristics does the communicator have? |
@@ -280,7 +284,7 @@ GNUNET_TRANSPORT_communicator_mq_add ( | |||
280 | * Notify transport service that an MQ was updated | 284 | * Notify transport service that an MQ was updated |
281 | * | 285 | * |
282 | * @param ch connection to transport service | 286 | * @param ch connection to transport service |
283 | * @param qh the queue to update | 287 | * @param u_qh the queue to update |
284 | * @param q_len number of messages that can be send through this queue | 288 | * @param q_len number of messages that can be send through this queue |
285 | * @param priority queue priority. Queues with highest priority should be | 289 | * @param priority queue priority. Queues with highest priority should be |
286 | * used | 290 | * used |
@@ -383,4 +387,6 @@ GNUNET_TRANSPORT_communicator_notify ( | |||
383 | 387 | ||
384 | /** @} */ /* end of group */ | 388 | /** @} */ /* end of group */ |
385 | 389 | ||
390 | /** @} */ /* end of group addition */ | ||
391 | |||
386 | /* end of gnunet_transport_communicator_service.h */ | 392 | /* end of gnunet_transport_communicator_service.h */ |
diff --git a/src/include/gnunet_transport_core_service.h b/src/include/gnunet_transport_core_service.h index 314eb342f..f7907a12d 100644 --- a/src/include/gnunet_transport_core_service.h +++ b/src/include/gnunet_transport_core_service.h | |||
@@ -18,12 +18,15 @@ | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @addtogroup Backbone | ||
22 | * @{ | ||
23 | * | ||
21 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
22 | * | 25 | * |
23 | * @file | 26 | * @file |
24 | * API of the transport service towards the CORE service (TNG version) | 27 | * API of the transport service towards the CORE service (TNG version) |
25 | * | 28 | * |
26 | * @defgroup transport TRANSPORT service | 29 | * @defgroup TNG Transport Next Generation service |
27 | * Communication with other peers | 30 | * Communication with other peers |
28 | * | 31 | * |
29 | * @see [Documentation](https://gnunet.org/transport-service) | 32 | * @see [Documentation](https://gnunet.org/transport-service) |
@@ -40,6 +43,7 @@ extern "C" { | |||
40 | #endif | 43 | #endif |
41 | #endif | 44 | #endif |
42 | 45 | ||
46 | |||
43 | #include "gnunet_util_lib.h" | 47 | #include "gnunet_util_lib.h" |
44 | 48 | ||
45 | /** | 49 | /** |
@@ -174,4 +178,6 @@ GNUNET_TRANSPORT_core_get_mq (struct GNUNET_TRANSPORT_CoreHandle *handle, | |||
174 | 178 | ||
175 | /** @} */ /* end of group */ | 179 | /** @} */ /* end of group */ |
176 | 180 | ||
181 | /** @} */ /* end of group addition */ | ||
182 | |||
177 | /* end of gnunet_transport_core_service.h */ | 183 | /* end of gnunet_transport_core_service.h */ |
diff --git a/src/include/gnunet_transport_hello_service.h b/src/include/gnunet_transport_hello_service.h deleted file mode 100644 index fecffd527..000000000 --- a/src/include/gnunet_transport_hello_service.h +++ /dev/null | |||
@@ -1,201 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2009-2016 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your 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 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @author Christian Grothoff | ||
23 | * | ||
24 | * @file | ||
25 | * obtain information about our current address | ||
26 | * | ||
27 | * @deprecated, in TNG applications should query PEERSTORE directly! | ||
28 | * | ||
29 | * @defgroup transport Transport service | ||
30 | * address information | ||
31 | * | ||
32 | * @see [Documentation](https://gnunet.org/transport-service) | ||
33 | * | ||
34 | * @{ | ||
35 | */ | ||
36 | #ifndef GNUNET_TRANSPORT_HELLO_SERVICE_H | ||
37 | #define GNUNET_TRANSPORT_HELLO_SERVICE_H | ||
38 | |||
39 | #ifdef __cplusplus | ||
40 | extern "C" { | ||
41 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
42 | } | ||
43 | #endif | ||
44 | #endif | ||
45 | |||
46 | #include "gnunet_util_lib.h" | ||
47 | #include "gnunet_ats_service.h" | ||
48 | |||
49 | /** | ||
50 | * Version number of the transport API. | ||
51 | */ | ||
52 | #define GNUNET_TRANSPORT_HELLO_VERSION 0x00000000 | ||
53 | |||
54 | |||
55 | /** | ||
56 | * Some addresses contain sensitive information or are | ||
57 | * not suitable for global distribution. We use address | ||
58 | * classes to filter addresses by which domain they make | ||
59 | * sense to be used in. These are used in a bitmask. | ||
60 | */ | ||
61 | enum GNUNET_TRANSPORT_AddressClass | ||
62 | { | ||
63 | /** | ||
64 | * No address. | ||
65 | */ | ||
66 | GNUNET_TRANSPORT_AC_NONE = 0, | ||
67 | |||
68 | /** | ||
69 | * Addresses that fall into no other category | ||
70 | * (i.e. incoming which we cannot use elsewhere). | ||
71 | */ | ||
72 | GNUNET_TRANSPORT_AC_OTHER = 1, | ||
73 | |||
74 | /** | ||
75 | * Addresses that are global and are insensitive | ||
76 | * (i.e. IPv4). | ||
77 | */ | ||
78 | GNUNET_TRANSPORT_AC_GLOBAL = 2, | ||
79 | |||
80 | /** | ||
81 | * Addresses that are global and are sensitive | ||
82 | * (i.e. IPv6 with our MAC). | ||
83 | */ | ||
84 | GNUNET_TRANSPORT_AC_GLOBAL_PRIVATE = 4, | ||
85 | |||
86 | /** | ||
87 | * Addresses useful in the local wired network, | ||
88 | * i.e. a MAC. Sensitive, but obvious to people nearby. | ||
89 | * Useful for broadcasts. | ||
90 | */ | ||
91 | GNUNET_TRANSPORT_AC_LAN = 8, | ||
92 | |||
93 | /** | ||
94 | * Addresses useful in the local wireless network, | ||
95 | * i.e. a MAC. Sensitive, but obvious to people nearby. | ||
96 | * Useful for broadcasts. | ||
97 | */ | ||
98 | GNUNET_TRANSPORT_AC_WLAN = 16, | ||
99 | |||
100 | /** | ||
101 | * Addresses useful in the local bluetooth network. Sensitive, but | ||
102 | * obvious to people nearby. Useful for broadcasts. | ||
103 | */ | ||
104 | GNUNET_TRANSPORT_AC_BT = 32, | ||
105 | |||
106 | /** | ||
107 | * Bitmask for "any" address. | ||
108 | */ | ||
109 | GNUNET_TRANSPORT_AC_ANY = 65535 | ||
110 | }; | ||
111 | |||
112 | |||
113 | /** | ||
114 | * Function called whenever there is an update to the | ||
115 | * HELLO of this peer. | ||
116 | * | ||
117 | * @param cls closure | ||
118 | * @param hello our updated HELLO | ||
119 | */ | ||
120 | typedef void (*GNUNET_TRANSPORT_HelloUpdateCallback) ( | ||
121 | void *cls, | ||
122 | const struct GNUNET_MessageHeader *hello); | ||
123 | |||
124 | |||
125 | /** | ||
126 | * Handle to cancel a #GNUNET_TRANSPORT_hello_get() operation. | ||
127 | */ | ||
128 | struct GNUNET_TRANSPORT_HelloGetHandle; | ||
129 | |||
130 | |||
131 | /** | ||
132 | * Obtain updates on changes to the HELLO message for this peer. The callback | ||
133 | * given in this function is never called synchronously. | ||
134 | * | ||
135 | * @param cfg configuration to use | ||
136 | * @param ac which network type should the addresses from the HELLO belong to? | ||
137 | * @param rec function to call with the HELLO | ||
138 | * @param rec_cls closure for @a rec | ||
139 | * @return handle to cancel the operation | ||
140 | */ | ||
141 | struct GNUNET_TRANSPORT_HelloGetHandle * | ||
142 | GNUNET_TRANSPORT_hello_get (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
143 | enum GNUNET_TRANSPORT_AddressClass ac, | ||
144 | GNUNET_TRANSPORT_HelloUpdateCallback rec, | ||
145 | void *rec_cls); | ||
146 | |||
147 | |||
148 | /** | ||
149 | * Stop receiving updates about changes to our HELLO message. | ||
150 | * | ||
151 | * @param ghh handle to cancel | ||
152 | */ | ||
153 | void | ||
154 | GNUNET_TRANSPORT_hello_get_cancel (struct GNUNET_TRANSPORT_HelloGetHandle *ghh); | ||
155 | |||
156 | |||
157 | /** | ||
158 | * Function with addresses found in a HELLO. | ||
159 | * | ||
160 | * @param cls closure | ||
161 | * @param peer identity of the peer | ||
162 | * @param address the address (UTF-8, 0-terminated) | ||
163 | * @param nt network type of the address | ||
164 | * @param expiration when does this address expire? | ||
165 | */ | ||
166 | typedef void (*GNUNET_TRANSPORT_AddressCallback) ( | ||
167 | void *cls, | ||
168 | const struct GNUNET_PeerIdentity *peer, | ||
169 | const char *address, | ||
170 | enum GNUNET_NetworkType nt, | ||
171 | struct GNUNET_TIME_Absolute expiration); | ||
172 | |||
173 | |||
174 | /** | ||
175 | * Parse a HELLO message that we have received into its | ||
176 | * constituent addresses. | ||
177 | * | ||
178 | * @param hello message to parse | ||
179 | * @param cb function to call on each address found | ||
180 | * @param cb_cls closure for @a cb | ||
181 | * @return #GNUNET_OK if hello was well-formed, #GNUNET_SYSERR if not | ||
182 | */ | ||
183 | int | ||
184 | GNUNET_TRANSPORT_hello_parse (const struct GNUNET_MessageHeader *hello, | ||
185 | GNUNET_TRANSPORT_AddressCallback cb, | ||
186 | void *cb_cls); | ||
187 | |||
188 | |||
189 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
190 | { | ||
191 | #endif | ||
192 | #ifdef __cplusplus | ||
193 | } | ||
194 | #endif | ||
195 | |||
196 | /* ifndef GNUNET_TRANSPORT_HELLO_SERVICE_H */ | ||
197 | #endif | ||
198 | |||
199 | /** @} */ /* end of group */ | ||
200 | |||
201 | /* end of gnunet_transport_hello_service.h */ | ||
diff --git a/src/include/gnunet_transport_manipulation_service.h b/src/include/gnunet_transport_manipulation_service.h deleted file mode 100644 index 09fb138f8..000000000 --- a/src/include/gnunet_transport_manipulation_service.h +++ /dev/null | |||
@@ -1,117 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2009-2014, 2016 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your 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 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @author Christian Grothoff | ||
23 | * | ||
24 | * @file | ||
25 | * Low-level P2P IO | ||
26 | * | ||
27 | * @defgroup transport Transport service | ||
28 | * Low-level P2P IO | ||
29 | * | ||
30 | * @see [Documentation](https://gnunet.org/transport-service) | ||
31 | * | ||
32 | * @{ | ||
33 | */ | ||
34 | |||
35 | #ifndef GNUNET_TRANSPORT_MANIPULATION_SERVICE_H | ||
36 | #define GNUNET_TRANSPORT_MANIPULATION_SERVICE_H | ||
37 | |||
38 | |||
39 | #ifdef __cplusplus | ||
40 | extern "C" | ||
41 | { | ||
42 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
43 | } | ||
44 | #endif | ||
45 | #endif | ||
46 | |||
47 | #include "gnunet_util_lib.h" | ||
48 | #include "gnunet_ats_service.h" | ||
49 | |||
50 | /** | ||
51 | * Version number of the transport API. | ||
52 | */ | ||
53 | #define GNUNET_TRANSPORT_MANIPULATION_VERSION 0x00000003 | ||
54 | |||
55 | /** | ||
56 | * Handle for transport manipulation. | ||
57 | */ | ||
58 | struct GNUNET_TRANSPORT_ManipulationHandle; | ||
59 | |||
60 | |||
61 | /** | ||
62 | * Connect to the transport service. Note that the connection may | ||
63 | * complete (or fail) asynchronously. | ||
64 | * | ||
65 | * @param cfg configuration to use | ||
66 | * @return NULL on error | ||
67 | */ | ||
68 | struct GNUNET_TRANSPORT_ManipulationHandle * | ||
69 | GNUNET_TRANSPORT_manipulation_connect (const struct | ||
70 | GNUNET_CONFIGURATION_Handle *cfg); | ||
71 | |||
72 | |||
73 | /** | ||
74 | * Disconnect from the transport service. | ||
75 | * | ||
76 | * @param handle handle returned from connect | ||
77 | */ | ||
78 | void | ||
79 | GNUNET_TRANSPORT_manipulation_disconnect (struct | ||
80 | GNUNET_TRANSPORT_ManipulationHandle * | ||
81 | handle); | ||
82 | |||
83 | |||
84 | /** | ||
85 | * Set transport metrics for a peer and a direction | ||
86 | * | ||
87 | * @param handle transport handle | ||
88 | * @param peer the peer to set the metric for | ||
89 | * @param prop the performance metrics to set | ||
90 | * @param delay_in inbound delay to introduce | ||
91 | * @param delay_out outbound delay to introduce | ||
92 | * | ||
93 | * Note: Delay restrictions in receiving direction will be enforced | ||
94 | * with one message delay. | ||
95 | */ | ||
96 | void | ||
97 | GNUNET_TRANSPORT_manipulation_set (struct | ||
98 | GNUNET_TRANSPORT_ManipulationHandle *handle, | ||
99 | const struct GNUNET_PeerIdentity *peer, | ||
100 | const struct GNUNET_ATS_Properties *prop, | ||
101 | struct GNUNET_TIME_Relative delay_in, | ||
102 | struct GNUNET_TIME_Relative delay_out); | ||
103 | |||
104 | |||
105 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
106 | { | ||
107 | #endif | ||
108 | #ifdef __cplusplus | ||
109 | } | ||
110 | #endif | ||
111 | |||
112 | /* ifndef GNUNET_TRANSPORT_MANIPULATION_SERVICE_H */ | ||
113 | #endif | ||
114 | |||
115 | /** @} */ /* end of group */ | ||
116 | |||
117 | /* end of gnunet_transport_manipulation_service.h */ | ||
diff --git a/src/include/gnunet_transport_monitor_service.h b/src/include/gnunet_transport_monitor_service.h index f39be16d7..7c586b51e 100644 --- a/src/include/gnunet_transport_monitor_service.h +++ b/src/include/gnunet_transport_monitor_service.h | |||
@@ -19,12 +19,15 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup Backbone | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
25 | * Monitoring / diagnostics API for the transport service | 28 | * Monitoring / diagnostics API for the transport service |
26 | * | 29 | * |
27 | * @defgroup transport TRANSPORT service | 30 | * @defgroup TNG Transport Next Generation service |
28 | * Communication with other peers | 31 | * Communication with other peers |
29 | * | 32 | * |
30 | * @see [Documentation](https://gnunet.org/transport-service) | 33 | * @see [Documentation](https://gnunet.org/transport-service) |
@@ -42,8 +45,8 @@ extern "C" | |||
42 | #endif | 45 | #endif |
43 | #endif | 46 | #endif |
44 | 47 | ||
48 | |||
45 | #include "gnunet_util_lib.h" | 49 | #include "gnunet_util_lib.h" |
46 | #include "gnunet_ats_transport_service.h" | ||
47 | #include "gnunet_transport_communication_service.h" | 50 | #include "gnunet_transport_communication_service.h" |
48 | 51 | ||
49 | 52 | ||
@@ -189,4 +192,6 @@ GNUNET_TRANSPORT_monitor_cancel (struct GNUNET_TRANSPORT_MonitorContext *mc); | |||
189 | 192 | ||
190 | /** @} */ /* end of group */ | 193 | /** @} */ /* end of group */ |
191 | 194 | ||
195 | /** @} */ /* end of group addition */ | ||
196 | |||
192 | /* end of gnunet_transport_monitor_service.h */ | 197 | /* end of gnunet_transport_monitor_service.h */ |
diff --git a/src/include/gnunet_transport_plugin.h b/src/include/gnunet_transport_plugin.h deleted file mode 100644 index 74b27923a..000000000 --- a/src/include/gnunet_transport_plugin.h +++ /dev/null | |||
@@ -1,727 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2009-2014 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your 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 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @author Christian Grothoff | ||
23 | * | ||
24 | * @file | ||
25 | * Transport service plugin API | ||
26 | * | ||
27 | * @defgroup transport-plugin Transport Service plugin API | ||
28 | * | ||
29 | * Specifies the struct that is given to the plugin's entry method and the other | ||
30 | * struct that must be returned. Note that the destructors of transport plugins | ||
31 | * will be given the value returned by the constructor and is expected to return | ||
32 | * a NULL pointer. | ||
33 | * | ||
34 | * @{ | ||
35 | */ | ||
36 | #ifndef PLUGIN_TRANSPORT_H | ||
37 | #define PLUGIN_TRANSPORT_H | ||
38 | |||
39 | #include "gnunet_configuration_lib.h" | ||
40 | #include "gnunet_scheduler_lib.h" | ||
41 | #include "gnunet_statistics_service.h" | ||
42 | #include "gnunet_transport_service.h" | ||
43 | #include "gnunet_ats_service.h" | ||
44 | |||
45 | #define TRANSPORT_SESSION_INBOUND_STRING "<inbound>" | ||
46 | |||
47 | /** | ||
48 | * Opaque pointer that plugins can use to distinguish specific | ||
49 | * connections to a given peer. Typically used by stateful plugins to | ||
50 | * allow the service to refer to specific streams instead of a more | ||
51 | * general notion of "some connection" to the given peer. This is | ||
52 | * useful since sometimes (e.g. for inbound TCP connections) a | ||
53 | * connection may not have an address that can be used for meaningful | ||
54 | * distinction between sessions to the same peer. | ||
55 | * | ||
56 | * Each 'struct GNUNET_ATS_Session' MUST start with the 'struct GNUNET_PeerIdentity' | ||
57 | * of the peer the session is for (which will be used for some error | ||
58 | * checking by the ATS code). | ||
59 | */ | ||
60 | struct GNUNET_ATS_Session; | ||
61 | |||
62 | |||
63 | /** | ||
64 | * Function that will be called whenever the plugin internally | ||
65 | * cleans up a session pointer and hence the service needs to | ||
66 | * discard all of those sessions as well. Plugins that do not | ||
67 | * use sessions can simply omit calling this function and always | ||
68 | * use NULL wherever a session pointer is needed. This function | ||
69 | * should be called BEFORE a potential "TransmitContinuation" | ||
70 | * from the "TransmitFunction". | ||
71 | * | ||
72 | * @param cls closure | ||
73 | * @param peer which peer was the session for | ||
74 | * @param session which session is being destroyed | ||
75 | */ | ||
76 | typedef void | ||
77 | (*GNUNET_TRANSPORT_SessionEnd) (void *cls, | ||
78 | const struct GNUNET_HELLO_Address *address, | ||
79 | struct GNUNET_ATS_Session *session); | ||
80 | |||
81 | |||
82 | /** | ||
83 | * Plugin tells transport service about a new inbound session | ||
84 | * | ||
85 | * @param cls unused | ||
86 | * @param address the address | ||
87 | * @param session the new session | ||
88 | * @param net network information | ||
89 | */ | ||
90 | typedef void | ||
91 | (*GNUNET_TRANSPORT_SessionStart) (void *cls, | ||
92 | const struct GNUNET_HELLO_Address *address, | ||
93 | struct GNUNET_ATS_Session *session, | ||
94 | enum GNUNET_NetworkType net); | ||
95 | |||
96 | |||
97 | /** | ||
98 | * Function called by the transport for each received message. | ||
99 | * This function should also be called with "NULL" for the | ||
100 | * message to signal that the other peer disconnected. | ||
101 | * | ||
102 | * @param cls closure | ||
103 | * @param peer (claimed) identity of the other peer | ||
104 | * @param message the message, NULL if we only care about | ||
105 | * learning about the delay until we should receive again | ||
106 | * @param session identifier used for this session (NULL for plugins | ||
107 | * that do not offer bi-directional communication to the sender | ||
108 | * using the same "connection") | ||
109 | * @param sender_address binary address of the sender (if we established the | ||
110 | * connection or are otherwise sure of it; should be NULL | ||
111 | * for inbound TCP/UDP connections since it it not clear | ||
112 | * that we could establish ourselves a connection to that | ||
113 | * IP address and get the same system) | ||
114 | * @param sender_address_len number of bytes in @a sender_address | ||
115 | * @return how long the plugin should wait until receiving more data; | ||
116 | * returning #GNUNET_TIME_UNIT_FOREVER_REL means that the | ||
117 | * connection should be closed | ||
118 | */ | ||
119 | typedef struct GNUNET_TIME_Relative | ||
120 | (*GNUNET_TRANSPORT_PluginReceiveCallback) (void *cls, | ||
121 | const struct | ||
122 | GNUNET_HELLO_Address *address, | ||
123 | struct GNUNET_ATS_Session *session, | ||
124 | const struct | ||
125 | GNUNET_MessageHeader *message); | ||
126 | |||
127 | |||
128 | /** | ||
129 | * Function that can be called by plugins to figure if an address is | ||
130 | * an loopback, LAN or WAN address. Ultimately invokes | ||
131 | * #GNUNET_ATS_address_get_type(). | ||
132 | * | ||
133 | * @param cls closure | ||
134 | * @param addr binary address | ||
135 | * @param addrlen length of the @a addr | ||
136 | * @return type of the network the address belongs to | ||
137 | */ | ||
138 | typedef enum GNUNET_NetworkType | ||
139 | (*GNUNET_TRANSPORT_AddressToType)(void *cls, | ||
140 | const struct sockaddr *addr, | ||
141 | size_t addrlen); | ||
142 | |||
143 | |||
144 | /** | ||
145 | * Function called when distance of an address changes. | ||
146 | * | ||
147 | * @param cls closure | ||
148 | * @param peer peer | ||
149 | * @param distance new distance | ||
150 | */ | ||
151 | typedef void | ||
152 | (*GNUNET_TRANSPORT_UpdateAddressDistance) (void *cls, | ||
153 | const struct | ||
154 | GNUNET_HELLO_Address *address, | ||
155 | uint32_t distance); | ||
156 | |||
157 | |||
158 | /** | ||
159 | * Function that will be called for each address the transport | ||
160 | * is aware that it might be reachable under. | ||
161 | * | ||
162 | * @param cls closure | ||
163 | * @param add_remove should the address added (#GNUNET_YES) or removed (#GNUNET_NO) from the | ||
164 | * set of valid addresses? | ||
165 | * @param address the address to add or remove | ||
166 | */ | ||
167 | typedef void | ||
168 | (*GNUNET_TRANSPORT_AddressNotification) (void *cls, | ||
169 | int add_remove, | ||
170 | const struct | ||
171 | GNUNET_HELLO_Address *address); | ||
172 | |||
173 | |||
174 | /** | ||
175 | * Function that will be called whenever the plugin receives data over | ||
176 | * the network and wants to determine how long it should wait until | ||
177 | * the next time it reads from the given peer. Note that some plugins | ||
178 | * (such as UDP) may not be able to wait (for a particular peer), so | ||
179 | * the waiting part is optional. Plugins that can wait should call | ||
180 | * this function, sleep the given amount of time, and call it again | ||
181 | * (with zero bytes read) UNTIL it returns zero and only then read. | ||
182 | * | ||
183 | * @param cls closure | ||
184 | * @param peer which peer did we read data from | ||
185 | * @param amount_recved number of bytes read (can be zero) | ||
186 | * @return how long to wait until reading more from this peer | ||
187 | * (to enforce inbound quotas); returning #GNUNET_TIME_UNIT_FOREVER_REL | ||
188 | * means that the connection should be closed | ||
189 | */ | ||
190 | typedef struct GNUNET_TIME_Relative | ||
191 | (*GNUNET_TRANSPORT_TrafficReport) (void *cls, | ||
192 | const struct GNUNET_PeerIdentity *peer, | ||
193 | size_t amount_recved); | ||
194 | |||
195 | |||
196 | /** | ||
197 | * Function that returns a HELLO message. | ||
198 | * | ||
199 | * @return HELLO message (FIXME with what?) | ||
200 | */ | ||
201 | typedef const struct GNUNET_MessageHeader * | ||
202 | (*GNUNET_TRANSPORT_GetHelloCallback) (void); | ||
203 | |||
204 | |||
205 | /** | ||
206 | * The transport service will pass a pointer to a struct | ||
207 | * of this type as the first and only argument to the | ||
208 | * entry point of each transport plugin. | ||
209 | */ | ||
210 | struct GNUNET_TRANSPORT_PluginEnvironment | ||
211 | { | ||
212 | /** | ||
213 | * Configuration to use. | ||
214 | */ | ||
215 | const struct GNUNET_CONFIGURATION_Handle *cfg; | ||
216 | |||
217 | /** | ||
218 | * Identity of this peer. | ||
219 | */ | ||
220 | const struct GNUNET_PeerIdentity *my_identity; | ||
221 | |||
222 | /** | ||
223 | * Closure for the various callbacks. | ||
224 | */ | ||
225 | void *cls; | ||
226 | |||
227 | /** | ||
228 | * Handle for reporting statistics. | ||
229 | */ | ||
230 | struct GNUNET_STATISTICS_Handle *stats; | ||
231 | |||
232 | /** | ||
233 | * Function that should be called by the transport plugin | ||
234 | * whenever a message is received. If this field is "NULL", | ||
235 | * the plugin should load in 'stub' mode and NOT fully | ||
236 | * initialize and instead only return an API with the | ||
237 | * @e address_pretty_printer, @e address_to_string and | ||
238 | * @e string_to_address functions. | ||
239 | */ | ||
240 | GNUNET_TRANSPORT_PluginReceiveCallback receive; | ||
241 | |||
242 | /** | ||
243 | * Function that returns our HELLO. | ||
244 | */ | ||
245 | GNUNET_TRANSPORT_GetHelloCallback get_our_hello; | ||
246 | |||
247 | /** | ||
248 | * Function that must be called by each plugin to notify the | ||
249 | * transport service about the addresses under which the transport | ||
250 | * provided by the plugin can be reached. | ||
251 | */ | ||
252 | GNUNET_TRANSPORT_AddressNotification notify_address; | ||
253 | |||
254 | /** | ||
255 | * Function that must be called by the plugin when a non-NULL | ||
256 | * session handle stops being valid (is destroyed). | ||
257 | */ | ||
258 | GNUNET_TRANSPORT_SessionEnd session_end; | ||
259 | |||
260 | /** | ||
261 | * Function called by the plugin when a new (incoming) session was created | ||
262 | * not explicitly created using the the get_session function | ||
263 | */ | ||
264 | GNUNET_TRANSPORT_SessionStart session_start; | ||
265 | |||
266 | /** | ||
267 | * Function that will be called to figure if an address is an loopback, | ||
268 | * LAN, WAN etc. address | ||
269 | */ | ||
270 | GNUNET_TRANSPORT_AddressToType get_address_type; | ||
271 | |||
272 | /** | ||
273 | * Function that will be called by DV to update distance for | ||
274 | * an address. | ||
275 | */ | ||
276 | GNUNET_TRANSPORT_UpdateAddressDistance update_address_distance; | ||
277 | |||
278 | /** | ||
279 | * What is the maximum number of connections that this transport | ||
280 | * should allow? Transports that do not have sessions (such as | ||
281 | * UDP) can ignore this value. | ||
282 | */ | ||
283 | uint32_t max_connections; | ||
284 | }; | ||
285 | |||
286 | |||
287 | /** | ||
288 | * Function called by the #GNUNET_TRANSPORT_TransmitFunction | ||
289 | * upon "completion". In the case that a peer disconnects, | ||
290 | * this function must be called for each pending request | ||
291 | * (with a 'failure' indication) AFTER notifying the service | ||
292 | * about the disconnect event (so that the service won't try | ||
293 | * to transmit more messages, believing the connection still | ||
294 | * exists...). | ||
295 | * | ||
296 | * @param cls closure | ||
297 | * @param target who was the recipient of the message? | ||
298 | * @param result #GNUNET_OK on success | ||
299 | * #GNUNET_SYSERR if the target disconnected; | ||
300 | * disconnect will ALSO be signalled using | ||
301 | * the ReceiveCallback. | ||
302 | * @param size_payload bytes of payload from transport service in message | ||
303 | * @param size_on_wire bytes required on wire for transmission, | ||
304 | * 0 if result == #GNUNET_SYSERR | ||
305 | */ | ||
306 | typedef void | ||
307 | (*GNUNET_TRANSPORT_TransmitContinuation) (void *cls, | ||
308 | const struct | ||
309 | GNUNET_PeerIdentity *target, | ||
310 | int result, | ||
311 | size_t size_payload, | ||
312 | size_t size_on_wire); | ||
313 | |||
314 | |||
315 | /** | ||
316 | * The new send function with just the session and no address | ||
317 | * | ||
318 | * Function that can be used by the transport service to transmit | ||
319 | * a message using the plugin. Note that in the case of a | ||
320 | * peer disconnecting, the continuation MUST be called | ||
321 | * prior to the disconnect notification itself. This function | ||
322 | * will be called with this peer's HELLO message to initiate | ||
323 | * a fresh connection to another peer. | ||
324 | * | ||
325 | * @param cls closure | ||
326 | * @param session which session must be used | ||
327 | * @param msgbuf the message to transmit | ||
328 | * @param msgbuf_size number of bytes in @a msgbuf | ||
329 | * @param priority how important is the message (most plugins will | ||
330 | * ignore message priority and just FIFO) | ||
331 | * @param to how long to wait at most for the transmission (does not | ||
332 | * require plugins to discard the message after the timeout, | ||
333 | * just advisory for the desired delay; most plugins will ignore | ||
334 | * this as well) | ||
335 | * @param cont continuation to call once the message has | ||
336 | * been transmitted (or if the transport is ready | ||
337 | * for the next transmission call; or if the | ||
338 | * peer disconnected...); can be NULL | ||
339 | * @param cont_cls closure for @a cont | ||
340 | * @return number of bytes used (on the physical network, with overheads); | ||
341 | * -1 on hard errors (i.e. address invalid); 0 is a legal value | ||
342 | * and does NOT mean that the message was not transmitted (DV) | ||
343 | */ | ||
344 | typedef ssize_t | ||
345 | (*GNUNET_TRANSPORT_TransmitFunction) (void *cls, | ||
346 | struct GNUNET_ATS_Session *session, | ||
347 | const char *msgbuf, | ||
348 | size_t msgbuf_size, | ||
349 | unsigned int priority, | ||
350 | struct GNUNET_TIME_Relative to, | ||
351 | GNUNET_TRANSPORT_TransmitContinuation cont, | ||
352 | void *cont_cls); | ||
353 | |||
354 | |||
355 | /** | ||
356 | * Function that can be called to force a disconnect from the | ||
357 | * specified neighbour for the given session only. . This should | ||
358 | * also cancel all previously scheduled transmissions for this | ||
359 | * session. Obviously the transmission may have been partially | ||
360 | * completed already, which is OK. The plugin is supposed to close | ||
361 | * the connection (if applicable). | ||
362 | * | ||
363 | * @param cls closure with the `struct Plugin` | ||
364 | * @param session session to destroy | ||
365 | * @return #GNUNET_OK on success | ||
366 | */ | ||
367 | typedef int | ||
368 | (*GNUNET_TRANSPORT_DisconnectSessionFunction) (void *cls, | ||
369 | struct GNUNET_ATS_Session * | ||
370 | session); | ||
371 | |||
372 | |||
373 | /** | ||
374 | * Function that is called to get the keepalive factor. | ||
375 | * #GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT is divided by this number to | ||
376 | * calculate the interval between keepalive packets. | ||
377 | * | ||
378 | * @param cls closure with the `struct Plugin` | ||
379 | * @return keepalive factor | ||
380 | */ | ||
381 | typedef unsigned int | ||
382 | (*GNUNET_TRANSPORT_QueryKeepaliveFactorFunction) (void *cls); | ||
383 | |||
384 | |||
385 | /** | ||
386 | * Function that can be called to force a disconnect from the | ||
387 | * specified neighbour. This should also cancel all previously | ||
388 | * scheduled transmissions. Obviously the transmission may have been | ||
389 | * partially completed already, which is OK. The plugin is supposed | ||
390 | * to close the connection (if applicable) and no longer call the | ||
391 | * transmit continuation(s). | ||
392 | * | ||
393 | * @param cls closure | ||
394 | * @param target peer for which the last transmission is | ||
395 | * to be cancelled | ||
396 | */ | ||
397 | typedef void | ||
398 | (*GNUNET_TRANSPORT_DisconnectPeerFunction) (void *cls, | ||
399 | const struct | ||
400 | GNUNET_PeerIdentity *target); | ||
401 | |||
402 | |||
403 | /** | ||
404 | * Function called by the pretty printer for the resolved address for | ||
405 | * each human-readable address obtained. The callback can be called | ||
406 | * several times. The last invocation must be with a @a address of | ||
407 | * NULL and a @a res of #GNUNET_OK. Thus, to indicate conversion | ||
408 | * errors, the callback might be called first with @a address NULL and | ||
409 | * @a res being #GNUNET_SYSERR. In that case, there must still be a | ||
410 | * subsequent call later with @a address NULL and @a res #GNUNET_OK. | ||
411 | * | ||
412 | * @param cls closure | ||
413 | * @param address one of the names for the host, NULL on last callback | ||
414 | * @param res #GNUNET_OK if conversion was successful, #GNUNET_SYSERR on failure, | ||
415 | * #GNUNET_OK on last callback | ||
416 | */ | ||
417 | typedef void | ||
418 | (*GNUNET_TRANSPORT_AddressStringCallback) (void *cls, | ||
419 | const char *address, | ||
420 | int res); | ||
421 | |||
422 | |||
423 | /** | ||
424 | * Convert the transports address to a nice, human-readable | ||
425 | * format. | ||
426 | * | ||
427 | * @param cls closure | ||
428 | * @param type name of the transport that generated the address | ||
429 | * @param addr one of the addresses of the host, NULL for the last address | ||
430 | * the specific address format depends on the transport | ||
431 | * @param addrlen length of the @a addr | ||
432 | * @param numeric should (IP) addresses be displayed in numeric form? | ||
433 | * @param timeout after how long should we give up? | ||
434 | * @param asc function to call on each string | ||
435 | * @param asc_cls closure for @a asc | ||
436 | */ | ||
437 | typedef void | ||
438 | (*GNUNET_TRANSPORT_AddressPrettyPrinter) (void *cls, | ||
439 | const char *type, | ||
440 | const void *addr, | ||
441 | size_t addrlen, | ||
442 | int numeric, | ||
443 | struct GNUNET_TIME_Relative timeout, | ||
444 | GNUNET_TRANSPORT_AddressStringCallback | ||
445 | asc, | ||
446 | void *asc_cls); | ||
447 | |||
448 | |||
449 | /** | ||
450 | * Another peer has suggested an address for this peer and transport | ||
451 | * plugin. Check that this could be a valid address. This function | ||
452 | * is not expected to 'validate' the address in the sense of trying to | ||
453 | * connect to it but simply to see if the binary format is technically | ||
454 | * legal for establishing a connection to this peer (and make sure that | ||
455 | * the address really corresponds to our network connection/settings | ||
456 | * and not some potential man-in-the-middle). | ||
457 | * | ||
458 | * @param addr pointer to the address | ||
459 | * @param addrlen length of @a addr | ||
460 | * @return #GNUNET_OK if this is a plausible address for this peer | ||
461 | * and transport, #GNUNET_SYSERR if not | ||
462 | */ | ||
463 | typedef int | ||
464 | (*GNUNET_TRANSPORT_CheckAddress) (void *cls, | ||
465 | const void *addr, | ||
466 | size_t addrlen); | ||
467 | |||
468 | |||
469 | /** | ||
470 | * Create a new session to transmit data to the target | ||
471 | * This session will used to send data to this peer and the plugin will | ||
472 | * notify us by calling the env->session_end function | ||
473 | * | ||
474 | * @param cls the plugin | ||
475 | * @param address the hello address | ||
476 | * @return the session if the address is valid, NULL otherwise | ||
477 | */ | ||
478 | typedef struct GNUNET_ATS_Session * | ||
479 | (*GNUNET_TRANSPORT_CreateSession) (void *cls, | ||
480 | const struct GNUNET_HELLO_Address *address); | ||
481 | |||
482 | |||
483 | /** | ||
484 | * Function that will be called whenever the transport service wants to | ||
485 | * notify the plugin that a session is still active and in use and | ||
486 | * therefore the session timeout for this session has to be updated | ||
487 | * | ||
488 | * @param cls closure | ||
489 | * @param peer which peer was the session for | ||
490 | * @param session which session is being updated | ||
491 | */ | ||
492 | typedef void | ||
493 | (*GNUNET_TRANSPORT_UpdateSessionTimeout) (void *cls, | ||
494 | const struct | ||
495 | GNUNET_PeerIdentity *peer, | ||
496 | struct GNUNET_ATS_Session *session); | ||
497 | |||
498 | |||
499 | /** | ||
500 | * Function that will be called whenever the transport service wants to | ||
501 | * notify the plugin that the inbound quota changed and that the plugin | ||
502 | * should update it's delay for the next receive value | ||
503 | * | ||
504 | * @param cls closure | ||
505 | * @param peer which peer was the session for | ||
506 | * @param session which session is being updated | ||
507 | * @param delay new delay to use for receiving | ||
508 | */ | ||
509 | typedef void | ||
510 | (*GNUNET_TRANSPORT_UpdateInboundDelay) (void *cls, | ||
511 | const struct GNUNET_PeerIdentity *peer, | ||
512 | struct GNUNET_ATS_Session *session, | ||
513 | struct GNUNET_TIME_Relative delay); | ||
514 | |||
515 | |||
516 | /** | ||
517 | * Function called for a quick conversion of the binary address to | ||
518 | * a numeric address. Note that the caller must not free the | ||
519 | * address and that the next call to this function is allowed | ||
520 | * to override the address again. | ||
521 | * | ||
522 | * @param cls closure | ||
523 | * @param addr binary address | ||
524 | * @param addr_len length of the @a addr | ||
525 | * @return string representing the same address | ||
526 | */ | ||
527 | typedef const char * | ||
528 | (*GNUNET_TRANSPORT_AddressToString) (void *cls, | ||
529 | const void *addr, | ||
530 | size_t addrlen); | ||
531 | |||
532 | |||
533 | /** | ||
534 | * Function called to convert a string address to | ||
535 | * a binary address. | ||
536 | * | ||
537 | * @param cls closure (`struct Plugin*`) | ||
538 | * @param addr string address | ||
539 | * @param addrlen length of the @a addr including \0 termination | ||
540 | * @param buf location to store the buffer | ||
541 | * If the function returns #GNUNET_SYSERR, its contents are undefined. | ||
542 | * @param added length of created address | ||
543 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure | ||
544 | */ | ||
545 | typedef int | ||
546 | (*GNUNET_TRANSPORT_StringToAddress) (void *cls, | ||
547 | const char *addr, | ||
548 | uint16_t addrlen, | ||
549 | void **buf, | ||
550 | size_t *added); | ||
551 | |||
552 | |||
553 | /** | ||
554 | * Function to obtain the network type for a session | ||
555 | * | ||
556 | * @param cls closure (`struct Plugin *`) | ||
557 | * @param session the session | ||
558 | * @return the network type | ||
559 | */ | ||
560 | typedef enum GNUNET_NetworkType | ||
561 | (*GNUNET_TRANSPORT_GetNetworkType)(void *cls, | ||
562 | struct GNUNET_ATS_Session *session); | ||
563 | |||
564 | |||
565 | /** | ||
566 | * Function to obtain the network type for an address. | ||
567 | * | ||
568 | * @param cls closure (`struct Plugin *`) | ||
569 | * @param address the address | ||
570 | * @return the network type | ||
571 | */ | ||
572 | typedef enum GNUNET_NetworkType | ||
573 | (*GNUNET_TRANSPORT_GetNetworkTypeForAddress)(void *cls, | ||
574 | const struct | ||
575 | GNUNET_HELLO_Address *address); | ||
576 | |||
577 | |||
578 | /** | ||
579 | * Function called by the plugin with information about the | ||
580 | * current sessions managed by the plugin (for monitoring). | ||
581 | * | ||
582 | * @param cls closure | ||
583 | * @param session session handle this information is about, | ||
584 | * NULL to indicate that we are "in sync" (initial | ||
585 | * iteration complete) | ||
586 | * @param info information about the state of the session, | ||
587 | * NULL if @a session is also NULL and we are | ||
588 | * merely signalling that the initial iteration is over | ||
589 | */ | ||
590 | typedef void | ||
591 | (*GNUNET_TRANSPORT_SessionInfoCallback) (void *cls, | ||
592 | struct GNUNET_ATS_Session *session, | ||
593 | const struct | ||
594 | GNUNET_TRANSPORT_SessionInfo *info); | ||
595 | |||
596 | |||
597 | /** | ||
598 | * Begin monitoring sessions of a plugin. There can only | ||
599 | * be one active monitor per plugin (i.e. if there are | ||
600 | * multiple monitors, the transport service needs to | ||
601 | * multiplex the generated events over all of them). | ||
602 | * | ||
603 | * @param cls closure of the plugin | ||
604 | * @param sic callback to invoke, NULL to disable monitor; | ||
605 | * plugin will being by iterating over all active | ||
606 | * sessions immediately and then enter monitor mode | ||
607 | * @param sic_cls closure for @a sic | ||
608 | */ | ||
609 | typedef void | ||
610 | (*GNUNET_TRANSPORT_SessionMonitorSetup) (void *cls, | ||
611 | GNUNET_TRANSPORT_SessionInfoCallback | ||
612 | sic, | ||
613 | void *sic_cls); | ||
614 | |||
615 | |||
616 | /** | ||
617 | * Each plugin is required to return a pointer to a struct of this | ||
618 | * type as the return value from its entry point. | ||
619 | */ | ||
620 | struct GNUNET_TRANSPORT_PluginFunctions | ||
621 | { | ||
622 | /** | ||
623 | * Closure for all of the callbacks. | ||
624 | */ | ||
625 | void *cls; | ||
626 | |||
627 | /** | ||
628 | * Function that the transport service will use to transmit data to | ||
629 | * another peer. May be NULL for plugins that only support | ||
630 | * receiving data. After this call, the plugin call the specified | ||
631 | * continuation with success or error before notifying us about the | ||
632 | * target having disconnected. | ||
633 | */ | ||
634 | GNUNET_TRANSPORT_TransmitFunction send; | ||
635 | |||
636 | /** | ||
637 | * Function that can be used to force the plugin to disconnect from | ||
638 | * the given peer and cancel all previous transmissions (and their | ||
639 | * continuations). | ||
640 | */ | ||
641 | GNUNET_TRANSPORT_DisconnectPeerFunction disconnect_peer; | ||
642 | |||
643 | /** | ||
644 | * Function that can be used to force the plugin to disconnect from | ||
645 | * the given peer and cancel all previous transmissions (and their | ||
646 | * continuations). | ||
647 | */ | ||
648 | GNUNET_TRANSPORT_DisconnectSessionFunction disconnect_session; | ||
649 | |||
650 | /** | ||
651 | * Function that will be called whenever the transport service wants to | ||
652 | * notify the plugin that a session is still active and in use and | ||
653 | * therefore the session timeout for this session has to be updated | ||
654 | */ | ||
655 | GNUNET_TRANSPORT_UpdateSessionTimeout update_session_timeout; | ||
656 | |||
657 | /** | ||
658 | * Function that will be called whenever the transport service wants to | ||
659 | * notify the plugin that the inbound quota changed and that the plugin | ||
660 | * should update it's delay for the next receive value | ||
661 | */ | ||
662 | GNUNET_TRANSPORT_UpdateInboundDelay update_inbound_delay; | ||
663 | |||
664 | /** | ||
665 | * Function that is used to query keepalive factor. | ||
666 | * #GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT is divided by this number to | ||
667 | * calculate the interval between keepalive packets. | ||
668 | */ | ||
669 | GNUNET_TRANSPORT_QueryKeepaliveFactorFunction query_keepalive_factor; | ||
670 | |||
671 | /** | ||
672 | * Function to pretty-print addresses. | ||
673 | */ | ||
674 | GNUNET_TRANSPORT_AddressPrettyPrinter address_pretty_printer; | ||
675 | |||
676 | /** | ||
677 | * Function that will be called to check if a binary address | ||
678 | * for this plugin is well-formed and corresponds to an | ||
679 | * address for THIS peer (as per our configuration). Naturally, | ||
680 | * if absolutely necessary, plugins can be a bit conservative in | ||
681 | * their answer, but in general plugins should make sure that the | ||
682 | * address does not redirect traffic to a 3rd party that might | ||
683 | * try to man-in-the-middle our traffic. | ||
684 | */ | ||
685 | GNUNET_TRANSPORT_CheckAddress check_address; | ||
686 | |||
687 | /** | ||
688 | * Function that will be called to convert a binary address | ||
689 | * to a string (numeric conversion only). | ||
690 | */ | ||
691 | GNUNET_TRANSPORT_AddressToString address_to_string; | ||
692 | |||
693 | /** | ||
694 | * Function that will be called to convert a string address | ||
695 | * to binary (numeric conversion only). | ||
696 | */ | ||
697 | GNUNET_TRANSPORT_StringToAddress string_to_address; | ||
698 | |||
699 | /** | ||
700 | * Function that will be called tell the plugin to create a session | ||
701 | * object. | ||
702 | */ | ||
703 | GNUNET_TRANSPORT_CreateSession get_session; | ||
704 | |||
705 | /** | ||
706 | * Function to obtain the network type for a session | ||
707 | */ | ||
708 | GNUNET_TRANSPORT_GetNetworkType get_network; | ||
709 | |||
710 | /** | ||
711 | * Function to obtain the network type for an address | ||
712 | */ | ||
713 | GNUNET_TRANSPORT_GetNetworkTypeForAddress get_network_for_address; | ||
714 | |||
715 | /** | ||
716 | * Function to monitor the sessions managed by the plugin. | ||
717 | */ | ||
718 | GNUNET_TRANSPORT_SessionMonitorSetup setup_monitor; | ||
719 | }; | ||
720 | |||
721 | |||
722 | /*#ifndef PLUGIN_TRANSPORT_H*/ | ||
723 | #endif | ||
724 | |||
725 | /** @} */ /* end of group */ | ||
726 | |||
727 | /* end of gnunet_transport_plugin.h */ | ||
diff --git a/src/include/gnunet_transport_service.h b/src/include/gnunet_transport_service.h deleted file mode 100644 index 459efc506..000000000 --- a/src/include/gnunet_transport_service.h +++ /dev/null | |||
@@ -1,708 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2009-2016 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your 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 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @author Christian Grothoff | ||
23 | * | ||
24 | * @file | ||
25 | * Low-level P2P IO | ||
26 | * | ||
27 | * @defgroup transport Transport service | ||
28 | * Low-level P2P IO | ||
29 | * | ||
30 | * @see [Documentation](https://gnunet.org/transport-service) | ||
31 | * | ||
32 | * @{ | ||
33 | */ | ||
34 | |||
35 | #ifndef GNUNET_TRANSPORT_SERVICE_H | ||
36 | #define GNUNET_TRANSPORT_SERVICE_H | ||
37 | |||
38 | #ifdef __cplusplus | ||
39 | extern "C" { | ||
40 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
41 | } | ||
42 | #endif | ||
43 | #endif | ||
44 | |||
45 | #include "gnunet_util_lib.h" | ||
46 | #include "gnunet_ats_service.h" | ||
47 | |||
48 | /** | ||
49 | * Version number of the transport API. | ||
50 | */ | ||
51 | #define GNUNET_TRANSPORT_VERSION 0x00000003 | ||
52 | |||
53 | |||
54 | /* *************************** HELLO *************************** */ | ||
55 | |||
56 | /** | ||
57 | * Handle for a #GNUNET_TRANSPORT_offer_hello operation | ||
58 | */ | ||
59 | struct GNUNET_TRANSPORT_OfferHelloHandle; | ||
60 | |||
61 | |||
62 | /** | ||
63 | * Offer the transport service the HELLO of another peer. Note that | ||
64 | * the transport service may just ignore this message if the HELLO is | ||
65 | * malformed or useless due to our local configuration. | ||
66 | * | ||
67 | * @param cfg configuration | ||
68 | * @param hello the hello message | ||
69 | * @param cont continuation to call when HELLO has been sent, | ||
70 | * tc reason #GNUNET_SCHEDULER_REASON_TIMEOUT for fail | ||
71 | * tc reasong #GNUNET_SCHEDULER_REASON_READ_READY for success | ||
72 | * @param cont_cls closure for @a cont | ||
73 | * @return a `struct GNUNET_TRANSPORT_OfferHelloHandle` handle or NULL on | ||
74 | * failure, in case of failure @a cont will not be called | ||
75 | * | ||
76 | */ | ||
77 | struct GNUNET_TRANSPORT_OfferHelloHandle * | ||
78 | GNUNET_TRANSPORT_offer_hello (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
79 | const struct GNUNET_MessageHeader *hello, | ||
80 | GNUNET_SCHEDULER_TaskCallback cont, | ||
81 | void *cont_cls); | ||
82 | |||
83 | |||
84 | /** | ||
85 | * Cancel the request to transport to offer the HELLO message | ||
86 | * | ||
87 | * @param ohh the `struct GNUNET_TRANSPORT_OfferHelloHandle` to cancel | ||
88 | */ | ||
89 | void | ||
90 | GNUNET_TRANSPORT_offer_hello_cancel ( | ||
91 | struct GNUNET_TRANSPORT_OfferHelloHandle *ohh); | ||
92 | |||
93 | |||
94 | /* *********************** Address to String ******************* */ | ||
95 | |||
96 | /** | ||
97 | * Handle to cancel a pending address lookup. | ||
98 | */ | ||
99 | struct GNUNET_TRANSPORT_AddressToStringContext; | ||
100 | |||
101 | |||
102 | /** | ||
103 | * Function to call with a textual representation of an address. This | ||
104 | * function will be called several times with different possible | ||
105 | * textual representations, and a last time with @a address being NULL | ||
106 | * to signal the end of the iteration. Note that @a address NULL | ||
107 | * always is the last call, regardless of the value in @a res. | ||
108 | * | ||
109 | * @param cls closure | ||
110 | * @param address NULL on end of iteration, | ||
111 | * otherwise 0-terminated printable UTF-8 string, | ||
112 | * in particular an empty string if @a res is #GNUNET_NO | ||
113 | * @param res result of the address to string conversion: | ||
114 | * if #GNUNET_OK: conversion successful | ||
115 | * if #GNUNET_NO: address was invalid (or not supported) | ||
116 | * if #GNUNET_SYSERR: communication error (IPC error) | ||
117 | */ | ||
118 | typedef void | ||
119 | (*GNUNET_TRANSPORT_AddressToStringCallback) (void *cls, | ||
120 | const char *address, | ||
121 | int res); | ||
122 | |||
123 | |||
124 | /** | ||
125 | * Convert a binary address into a human readable address. | ||
126 | * | ||
127 | * @param cfg configuration to use | ||
128 | * @param address address to convert (binary format) | ||
129 | * @param numeric should (IP) addresses be displayed in numeric form | ||
130 | * (otherwise do reverse DNS lookup) | ||
131 | * @param timeout how long is the lookup allowed to take at most | ||
132 | * @param aluc function to call with the results | ||
133 | * @param aluc_cls closure for @a aluc | ||
134 | * @return handle to cancel the operation, NULL on error | ||
135 | */ | ||
136 | struct GNUNET_TRANSPORT_AddressToStringContext * | ||
137 | GNUNET_TRANSPORT_address_to_string ( | ||
138 | const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
139 | const struct GNUNET_HELLO_Address *address, | ||
140 | int numeric, | ||
141 | struct GNUNET_TIME_Relative timeout, | ||
142 | GNUNET_TRANSPORT_AddressToStringCallback aluc, | ||
143 | void *aluc_cls); | ||
144 | |||
145 | |||
146 | /** | ||
147 | * Cancel request for address conversion. | ||
148 | * | ||
149 | * @param alc the context handle | ||
150 | */ | ||
151 | void | ||
152 | GNUNET_TRANSPORT_address_to_string_cancel ( | ||
153 | struct GNUNET_TRANSPORT_AddressToStringContext *alc); | ||
154 | |||
155 | |||
156 | /* *********************** Monitoring ************************** */ | ||
157 | |||
158 | |||
159 | /** | ||
160 | * Possible state of a neighbour. Initially, we are | ||
161 | * #GNUNET_TRANSPORT_PS_NOT_CONNECTED. | ||
162 | * | ||
163 | * Then, there are two main paths. If we receive a SYN message, we give | ||
164 | * the inbound address to ATS. After the check we ask ATS for a suggestion | ||
165 | * (#GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS). If ATS makes a suggestion, we | ||
166 | * send our SYN_ACK and go to #GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK. | ||
167 | * If we receive a ACK, we go to #GNUNET_TRANSPORT_PS_CONNECTED | ||
168 | * (and notify everyone about the new connection). If the operation times out, | ||
169 | * we go to #GNUNET_TRANSPORT_PS_DISCONNECT. | ||
170 | * | ||
171 | * The other case is where we transmit a SYN message first. We | ||
172 | * start with #GNUNET_TRANSPORT_PS_INIT_ATS. If we get an address, we send | ||
173 | * the SYN message and go to state #GNUNET_TRANSPORT_PS_CONNECT_SENT. | ||
174 | * Once we receive a SYN_ACK, we go to #GNUNET_TRANSPORT_PS_CONNECTED | ||
175 | * (and notify everyone about the new connection and send | ||
176 | * back a ACK). If the operation times out, we go to | ||
177 | * #GNUNET_TRANSPORT_PS_DISCONNECT. | ||
178 | * | ||
179 | * If the session is in trouble (i.e. transport-level disconnect or | ||
180 | * timeout), we go to #GNUNET_TRANSPORT_PS_RECONNECT_ATS where we ask ATS for a | ||
181 | * new address (we don't notify anyone about the disconnect yet). Once we have | ||
182 | * a new address, we enter #GNUNET_TRANSPORT_PS_RECONNECT_SENT and send a SYN | ||
183 | * message. If we receive a SYN_ACK, we go to #GNUNET_TRANSPORT_PS_CONNECTED | ||
184 | * and nobody noticed that we had trouble; we also send a ACK at this time just | ||
185 | * in case. If the operation times out, we go to | ||
186 | * #GNUNET_TRANSPORT_PS_DISCONNECT (and notify everyone about the lost | ||
187 | * connection). | ||
188 | * | ||
189 | * If ATS decides to switch addresses while we have a normal | ||
190 | * connection, we go to #GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_SYN_SENT | ||
191 | * and send a SESSION_CONNECT. If we get a ACK back, we switch the | ||
192 | * primary connection to the suggested alternative from ATS, go back | ||
193 | * to #GNUNET_TRANSPORT_PS_CONNECTED and send a ACK to the other peer just to be | ||
194 | * sure. If the operation times out | ||
195 | * we go to #GNUNET_TRANSPORT_PS_CONNECTED (and notify ATS that the given | ||
196 | * alternative address is "invalid"). | ||
197 | * | ||
198 | * Once a session is in #GNUNET_TRANSPORT_PS_DISCONNECT, it is cleaned up and | ||
199 | * then goes to (#GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED). If we receive an | ||
200 | * explicit disconnect request, we can go from any state to | ||
201 | * #GNUNET_TRANSPORT_PS_DISCONNECT, possibly after generating disconnect | ||
202 | * notifications. | ||
203 | * | ||
204 | * Note that it is quite possible that while we are in any of these | ||
205 | * states, we could receive a 'SYN' request from the other peer. | ||
206 | * We then enter a 'weird' state where we pursue our own primary state | ||
207 | * machine (as described above), but with the 'send_connect_ack' flag | ||
208 | * set to 1. If our state machine allows us to send a 'SYN_ACK' | ||
209 | * (because we have an acceptable address), we send the 'SYN_ACK' | ||
210 | * and set the 'send_connect_ack' to 2. If we then receive a | ||
211 | * 'ACK', we go to #GNUNET_TRANSPORT_PS_CONNECTED (and reset 'send_connect_ack' | ||
212 | * to 0). | ||
213 | * | ||
214 | */ | ||
215 | enum GNUNET_TRANSPORT_PeerState | ||
216 | { | ||
217 | /** | ||
218 | * Fresh peer or completely disconnected | ||
219 | */ | ||
220 | GNUNET_TRANSPORT_PS_NOT_CONNECTED = 0, | ||
221 | |||
222 | /** | ||
223 | * Asked to initiate connection, trying to get address from ATS | ||
224 | */ | ||
225 | GNUNET_TRANSPORT_PS_INIT_ATS, | ||
226 | |||
227 | /** | ||
228 | * Sent SYN message to other peer, waiting for SYN_ACK | ||
229 | */ | ||
230 | GNUNET_TRANSPORT_PS_SYN_SENT, | ||
231 | |||
232 | /** | ||
233 | * Received a SYN, asking ATS about address suggestions. | ||
234 | */ | ||
235 | GNUNET_TRANSPORT_PS_SYN_RECV_ATS, | ||
236 | |||
237 | /** | ||
238 | * SYN request from other peer was SYN_ACK'ed, waiting for ACK. | ||
239 | */ | ||
240 | GNUNET_TRANSPORT_PS_SYN_RECV_ACK, | ||
241 | |||
242 | /** | ||
243 | * Got our SYN_ACK/ACK, connection is up. | ||
244 | */ | ||
245 | GNUNET_TRANSPORT_PS_CONNECTED, | ||
246 | |||
247 | /** | ||
248 | * Connection got into trouble, rest of the system still believes | ||
249 | * it to be up, but we're getting a new address from ATS. | ||
250 | */ | ||
251 | GNUNET_TRANSPORT_PS_RECONNECT_ATS, | ||
252 | |||
253 | /** | ||
254 | * Sent SYN over new address (either by ATS telling us to switch | ||
255 | * addresses or from RECONNECT_ATS); if this fails, we need to tell | ||
256 | * the rest of the system about a disconnect. | ||
257 | */ | ||
258 | GNUNET_TRANSPORT_PS_RECONNECT_SENT, | ||
259 | |||
260 | /** | ||
261 | * We have some primary connection, but ATS suggested we switch | ||
262 | * to some alternative; we now sent a SYN message for the | ||
263 | * alternative session to the other peer and waiting for a | ||
264 | * SYN_ACK to make this our primary connection. | ||
265 | */ | ||
266 | GNUNET_TRANSPORT_PS_SWITCH_SYN_SENT, | ||
267 | |||
268 | /** | ||
269 | * Disconnect in progress (we're sending the DISCONNECT message to the | ||
270 | * other peer; after that is finished, the state will be cleaned up). | ||
271 | */ | ||
272 | GNUNET_TRANSPORT_PS_DISCONNECT, | ||
273 | |||
274 | /** | ||
275 | * We're finished with the disconnect; and are cleaning up the state | ||
276 | * now! We put the struct into this state when we are really in the | ||
277 | * task that calls 'free' on it and are about to remove the record | ||
278 | * from the map. We should never find a 'struct NeighbourMapEntry' | ||
279 | * in this state in the map. Accessing a 'struct NeighbourMapEntry' | ||
280 | * in this state virtually always means using memory that has been | ||
281 | * freed (the exception being the cleanup code in #free_neighbour()). | ||
282 | */ | ||
283 | GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED | ||
284 | }; | ||
285 | |||
286 | |||
287 | /** | ||
288 | * Convert a transport state to a human readable string. | ||
289 | * | ||
290 | * @param state the state | ||
291 | */ | ||
292 | const char * | ||
293 | GNUNET_TRANSPORT_ps2s (enum GNUNET_TRANSPORT_PeerState state); | ||
294 | |||
295 | |||
296 | /** | ||
297 | * Check if a state is defined as connected | ||
298 | * | ||
299 | * @param state the state value | ||
300 | * @return #GNUNET_YES or #GNUNET_NO | ||
301 | */ | ||
302 | int | ||
303 | GNUNET_TRANSPORT_is_connected (enum GNUNET_TRANSPORT_PeerState state); | ||
304 | |||
305 | |||
306 | /** | ||
307 | * Handle for a #GNUNET_TRANSPORT_monitor_peers operation. | ||
308 | */ | ||
309 | struct GNUNET_TRANSPORT_PeerMonitoringContext; | ||
310 | |||
311 | |||
312 | /** | ||
313 | * Function to call with information about a peer | ||
314 | * | ||
315 | * If one_shot was set to #GNUNET_YES to iterate over all peers once, | ||
316 | * a final call with NULL for peer and address will follow when done. | ||
317 | * In this case state and timeout do not contain valid values. | ||
318 | * | ||
319 | * The #GNUNET_TRANSPORT_monitor_peers_cancel() call MUST not be called from | ||
320 | * within this function! | ||
321 | * | ||
322 | * | ||
323 | * @param cls closure | ||
324 | * @param peer peer this update is about, | ||
325 | * NULL if this is the final last callback for a iteration operation | ||
326 | * @param address address, NULL if this is the final callback for iteration op | ||
327 | * @param state current state this peer is in | ||
328 | * @param state_timeout timeout for the current state of the peer | ||
329 | */ | ||
330 | typedef void | ||
331 | (*GNUNET_TRANSPORT_PeerIterateCallback) ( | ||
332 | void *cls, | ||
333 | const struct GNUNET_PeerIdentity *peer, | ||
334 | const struct GNUNET_HELLO_Address *address, | ||
335 | enum GNUNET_TRANSPORT_PeerState state, | ||
336 | struct GNUNET_TIME_Absolute state_timeout); | ||
337 | |||
338 | |||
339 | /** | ||
340 | * Return information about a specific peer or all peers currently known to | ||
341 | * transport service once or in monitoring mode. To obtain information about | ||
342 | * a specific peer, a peer identity can be passed. To obtain information about | ||
343 | * all peers currently known to transport service, NULL can be passed as peer | ||
344 | * identity. | ||
345 | * | ||
346 | * For each peer, the callback is called with information about the address used | ||
347 | * to communicate with this peer, the state this peer is currently in and the | ||
348 | * the current timeout for this state. | ||
349 | * | ||
350 | * Upon completion, the #GNUNET_TRANSPORT_PeerIterateCallback is called one | ||
351 | * more time with `NULL`. After this, the operation must no longer be | ||
352 | * explicitly canceled. | ||
353 | * | ||
354 | * The #GNUNET_TRANSPORT_monitor_peers_cancel call MUST not be called in the | ||
355 | * the peer_callback! | ||
356 | * | ||
357 | * @param cfg configuration to use | ||
358 | * @param peer a specific peer identity to obtain information for, | ||
359 | * NULL for all peers | ||
360 | * @param one_shot #GNUNET_YES to return the current state and then end (with | ||
361 | * NULL+NULL), #GNUNET_NO to monitor peers continuously | ||
362 | * @param peer_callback function to call with the results | ||
363 | * @param peer_callback_cls closure for @a peer_callback | ||
364 | */ | ||
365 | struct GNUNET_TRANSPORT_PeerMonitoringContext * | ||
366 | GNUNET_TRANSPORT_monitor_peers ( | ||
367 | const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
368 | const struct GNUNET_PeerIdentity *peer, | ||
369 | int one_shot, | ||
370 | GNUNET_TRANSPORT_PeerIterateCallback peer_callback, | ||
371 | void *peer_callback_cls); | ||
372 | |||
373 | |||
374 | /** | ||
375 | * Cancel request to monitor peers | ||
376 | * | ||
377 | * @param pic handle for the request to cancel | ||
378 | */ | ||
379 | void | ||
380 | GNUNET_TRANSPORT_monitor_peers_cancel ( | ||
381 | struct GNUNET_TRANSPORT_PeerMonitoringContext *pic); | ||
382 | |||
383 | |||
384 | /* *********************** Blacklisting ************************ */ | ||
385 | |||
386 | /** | ||
387 | * Handle for blacklisting peers. | ||
388 | */ | ||
389 | struct GNUNET_TRANSPORT_Blacklist; | ||
390 | |||
391 | |||
392 | /** | ||
393 | * Function that decides if a connection is acceptable or not. | ||
394 | * | ||
395 | * @param cls closure | ||
396 | * @param pid peer to approve or disapproave | ||
397 | * @return #GNUNET_OK if the connection is allowed, #GNUNET_SYSERR if not | ||
398 | */ | ||
399 | typedef int | ||
400 | (*GNUNET_TRANSPORT_BlacklistCallback) ( | ||
401 | void *cls, | ||
402 | const struct GNUNET_PeerIdentity *pid); | ||
403 | |||
404 | |||
405 | /** | ||
406 | * Install a blacklist callback. The service will be queried for all | ||
407 | * existing connections as well as any fresh connections to check if | ||
408 | * they are permitted. If the blacklisting callback is unregistered, | ||
409 | * all hosts that were denied in the past will automatically be | ||
410 | * whitelisted again. Cancelling the blacklist handle is also the | ||
411 | * only way to re-enable connections from peers that were previously | ||
412 | * blacklisted. | ||
413 | * | ||
414 | * @param cfg configuration to use | ||
415 | * @param cb callback to invoke to check if connections are allowed | ||
416 | * @param cb_cls closure for @a cb | ||
417 | * @return NULL on error, otherwise handle for cancellation | ||
418 | */ | ||
419 | struct GNUNET_TRANSPORT_Blacklist * | ||
420 | GNUNET_TRANSPORT_blacklist (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
421 | GNUNET_TRANSPORT_BlacklistCallback cb, | ||
422 | void *cb_cls); | ||
423 | |||
424 | |||
425 | /** | ||
426 | * Abort the blacklist. Note that this function is the only way for | ||
427 | * removing a peer from the blacklist. | ||
428 | * | ||
429 | * @param br handle of the request that is to be cancelled | ||
430 | */ | ||
431 | void | ||
432 | GNUNET_TRANSPORT_blacklist_cancel (struct GNUNET_TRANSPORT_Blacklist *br); | ||
433 | |||
434 | |||
435 | /** | ||
436 | * Handle for a plugin session state monitor. | ||
437 | */ | ||
438 | struct GNUNET_TRANSPORT_PluginMonitor; | ||
439 | |||
440 | /** | ||
441 | * Abstract representation of a plugin's session. | ||
442 | * Corresponds to the `struct GNUNET_ATS_Session` within the TRANSPORT service. | ||
443 | */ | ||
444 | struct GNUNET_TRANSPORT_PluginSession; | ||
445 | |||
446 | |||
447 | /** | ||
448 | * Possible states of a session in a plugin. | ||
449 | */ | ||
450 | enum GNUNET_TRANSPORT_SessionState | ||
451 | { | ||
452 | /** | ||
453 | * The session was created (first call for each session object). | ||
454 | */ | ||
455 | GNUNET_TRANSPORT_SS_INIT, | ||
456 | |||
457 | /** | ||
458 | * Initial session handshake is in progress. | ||
459 | */ | ||
460 | GNUNET_TRANSPORT_SS_HANDSHAKE, | ||
461 | |||
462 | /** | ||
463 | * Session is fully UP. | ||
464 | */ | ||
465 | GNUNET_TRANSPORT_SS_UP, | ||
466 | |||
467 | /** | ||
468 | * This is just an update about the session, | ||
469 | * the state did not change. | ||
470 | */ | ||
471 | GNUNET_TRANSPORT_SS_UPDATE, | ||
472 | |||
473 | /** | ||
474 | * Session is being torn down and about to disappear. | ||
475 | * Last call for each session object. | ||
476 | */ | ||
477 | GNUNET_TRANSPORT_SS_DONE | ||
478 | }; | ||
479 | |||
480 | |||
481 | /** | ||
482 | * Information about a plugin's session. | ||
483 | */ | ||
484 | struct GNUNET_TRANSPORT_SessionInfo | ||
485 | { | ||
486 | /** | ||
487 | * New state of the session. | ||
488 | */ | ||
489 | enum GNUNET_TRANSPORT_SessionState state; | ||
490 | |||
491 | /** | ||
492 | * #GNUNET_YES if this is an inbound connection, | ||
493 | * #GNUNET_NO if this is an outbound connection, | ||
494 | * #GNUNET_SYSERR if connections of this plugin | ||
495 | * are so fundamentally bidirectional | ||
496 | * that they have no 'initiator' | ||
497 | */ | ||
498 | int is_inbound; | ||
499 | |||
500 | /** | ||
501 | * Number of messages pending transmission for this session. | ||
502 | */ | ||
503 | uint32_t num_msg_pending; | ||
504 | |||
505 | /** | ||
506 | * Number of bytes pending transmission for this session. | ||
507 | */ | ||
508 | uint32_t num_bytes_pending; | ||
509 | |||
510 | /** | ||
511 | * Until when does this plugin refuse to receive to manage | ||
512 | * staying within the inbound quota? ZERO if receive is | ||
513 | * active. | ||
514 | */ | ||
515 | struct GNUNET_TIME_Absolute receive_delay; | ||
516 | |||
517 | /** | ||
518 | * At what time will this session timeout (unless activity | ||
519 | * happens)? | ||
520 | */ | ||
521 | struct GNUNET_TIME_Absolute session_timeout; | ||
522 | |||
523 | /** | ||
524 | * Address used by the session. Can be NULL if none is available. | ||
525 | */ | ||
526 | const struct GNUNET_HELLO_Address *address; | ||
527 | }; | ||
528 | |||
529 | |||
530 | /** | ||
531 | * Function called by the plugin with information about the | ||
532 | * current sessions managed by the plugin (for monitoring). | ||
533 | * | ||
534 | * @param cls closure | ||
535 | * @param session session handle this information is about, | ||
536 | * NULL to indicate that we are "in sync" (initial | ||
537 | * iteration complete) | ||
538 | * @param session_ctx storage location where the application | ||
539 | * can store data; will point to NULL on #GNUNET_TRANSPORT_SS_INIT, | ||
540 | * and must be reset to NULL on #GNUNET_TRANSPORT_SS_DONE | ||
541 | * @param info information about the state of the session, | ||
542 | * NULL if @a session is also NULL and we are | ||
543 | * merely signalling that the initial iteration is over; | ||
544 | * NULL with @a session being non-NULL if the monitor | ||
545 | * was being cancelled while sessions were active | ||
546 | */ | ||
547 | typedef void | ||
548 | (*GNUNET_TRANSPORT_SessionMonitorCallback) ( | ||
549 | void *cls, | ||
550 | struct GNUNET_TRANSPORT_PluginSession *session, | ||
551 | void **session_ctx, | ||
552 | const struct GNUNET_TRANSPORT_SessionInfo *info); | ||
553 | |||
554 | |||
555 | /** | ||
556 | * Install a plugin session state monitor callback. The callback | ||
557 | * will be notified whenever the session changes. | ||
558 | * | ||
559 | * @param cfg configuration to use | ||
560 | * @param cb callback to invoke on events | ||
561 | * @param cb_cls closure for @a cb | ||
562 | * @return NULL on error, otherwise handle for cancellation | ||
563 | */ | ||
564 | struct GNUNET_TRANSPORT_PluginMonitor * | ||
565 | GNUNET_TRANSPORT_monitor_plugins (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
566 | GNUNET_TRANSPORT_SessionMonitorCallback cb, | ||
567 | void *cb_cls); | ||
568 | |||
569 | |||
570 | /** | ||
571 | * Cancel monitoring the plugin session state. The callback will be | ||
572 | * called once for each session that is up with the "info" argument | ||
573 | * being NULL (this is just to enable client-side cleanup). | ||
574 | * | ||
575 | * @param pm handle of the request that is to be cancelled | ||
576 | */ | ||
577 | void | ||
578 | GNUNET_TRANSPORT_monitor_plugins_cancel ( | ||
579 | struct GNUNET_TRANSPORT_PluginMonitor *pm); | ||
580 | |||
581 | |||
582 | /** | ||
583 | * Opaque handle to the service. | ||
584 | */ | ||
585 | struct GNUNET_TRANSPORT_CoreHandle; | ||
586 | |||
587 | |||
588 | /** | ||
589 | * Function called to notify transport users that another | ||
590 | * peer connected to us. | ||
591 | * | ||
592 | * @param cls closure | ||
593 | * @param peer the identity of the peer that connected; this | ||
594 | * pointer will remain valid until the disconnect, hence | ||
595 | * applications do not necessarily have to make a copy | ||
596 | * of the value if they only need it until disconnect | ||
597 | * @param mq message queue to use to transmit to @a peer | ||
598 | * @return closure to use in MQ handlers | ||
599 | */ | ||
600 | typedef void * | ||
601 | (*GNUNET_TRANSPORT_NotifyConnect) ( | ||
602 | void *cls, | ||
603 | const struct GNUNET_PeerIdentity *peer, | ||
604 | struct GNUNET_MQ_Handle *mq); | ||
605 | |||
606 | |||
607 | /** | ||
608 | * Function called to notify transport users that another peer | ||
609 | * disconnected from us. The message queue that was given to the | ||
610 | * connect notification will be destroyed and must not be used | ||
611 | * henceforth. | ||
612 | * | ||
613 | * @param cls closure from #GNUNET_TRANSPORT_core_connect | ||
614 | * @param peer the peer that disconnected | ||
615 | * @param handlers_cls closure of the handlers, was returned from the | ||
616 | * connect notification callback | ||
617 | */ | ||
618 | typedef void | ||
619 | (*GNUNET_TRANSPORT_NotifyDisconnect) ( | ||
620 | void *cls, | ||
621 | const struct GNUNET_PeerIdentity *peer, | ||
622 | void *handler_cls); | ||
623 | |||
624 | |||
625 | /** | ||
626 | * Function called if we have "excess" bandwidth to a peer. | ||
627 | * The notification will happen the first time we have excess | ||
628 | * bandwidth, and then only again after the client has performed | ||
629 | * some transmission to the peer. | ||
630 | * | ||
631 | * Excess bandwidth is defined as being allowed (by ATS) to send | ||
632 | * more data, and us reaching the limit of the capacity build-up | ||
633 | * (which, if we go past it, means we don't use available bandwidth). | ||
634 | * See also the "max carry" in `struct GNUNET_BANDWIDTH_Tracker`. | ||
635 | * | ||
636 | * @param cls the closure | ||
637 | * @param neighbour peer that we have excess bandwidth to | ||
638 | * @param handlers_cls closure of the handlers, was returned from the | ||
639 | * connect notification callback | ||
640 | */ | ||
641 | typedef void | ||
642 | (*GNUNET_TRANSPORT_NotifyExcessBandwidth) ( | ||
643 | void *cls, | ||
644 | const struct GNUNET_PeerIdentity *neighbour, | ||
645 | void *handlers_cls); | ||
646 | |||
647 | |||
648 | /** | ||
649 | * Connect to the transport service. Note that the connection may | ||
650 | * complete (or fail) asynchronously. | ||
651 | * | ||
652 | * @param cfg configuration to use | ||
653 | * @param self our own identity (API should check that it matches | ||
654 | * the identity found by transport), or NULL (no check) | ||
655 | * @param handlers array of message handlers; note that the | ||
656 | * closures provided will be ignored and replaced | ||
657 | * with the respective return value from @a nc | ||
658 | * @param handlers array with handlers to call when we receive messages, or NULL | ||
659 | * @param cls closure for the @a nc, @a nd and @a neb callbacks | ||
660 | * @param nc function to call on connect events, or NULL | ||
661 | * @param nd function to call on disconnect events, or NULL | ||
662 | * @param neb function to call if we have excess bandwidth to a peer, or NULL | ||
663 | * @return NULL on error | ||
664 | */ | ||
665 | struct GNUNET_TRANSPORT_CoreHandle * | ||
666 | GNUNET_TRANSPORT_core_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
667 | const struct GNUNET_PeerIdentity *self, | ||
668 | const struct GNUNET_MQ_MessageHandler *handlers, | ||
669 | void *cls, | ||
670 | GNUNET_TRANSPORT_NotifyConnect nc, | ||
671 | GNUNET_TRANSPORT_NotifyDisconnect nd, | ||
672 | GNUNET_TRANSPORT_NotifyExcessBandwidth neb); | ||
673 | |||
674 | |||
675 | /** | ||
676 | * Disconnect from the transport service. | ||
677 | * | ||
678 | * @param handle handle returned from connect | ||
679 | */ | ||
680 | void | ||
681 | GNUNET_TRANSPORT_core_disconnect (struct GNUNET_TRANSPORT_CoreHandle *handle); | ||
682 | |||
683 | |||
684 | /** | ||
685 | * Checks if a given peer is connected to us and get the message queue. | ||
686 | * | ||
687 | * @param handle connection to transport service | ||
688 | * @param peer the peer to check | ||
689 | * @return NULL if disconnected, otherwise message queue for @a peer | ||
690 | */ | ||
691 | struct GNUNET_MQ_Handle * | ||
692 | GNUNET_TRANSPORT_core_get_mq (struct GNUNET_TRANSPORT_CoreHandle *handle, | ||
693 | const struct GNUNET_PeerIdentity *peer); | ||
694 | |||
695 | |||
696 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
697 | { | ||
698 | #endif | ||
699 | #ifdef __cplusplus | ||
700 | } | ||
701 | #endif | ||
702 | |||
703 | /* ifndef GNUNET_TRANSPORT_SERVICE_H */ | ||
704 | #endif | ||
705 | |||
706 | /** @} */ /* end of group */ | ||
707 | |||
708 | /* end of gnunet_transport_service.h */ | ||
diff --git a/src/include/gnunet_transport_testing_ng_lib.h b/src/include/gnunet_transport_testing_ng_lib.h new file mode 100644 index 000000000..be904cf4c --- /dev/null +++ b/src/include/gnunet_transport_testing_ng_lib.h | |||
@@ -0,0 +1,211 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2021-2023 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your 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 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @brief API for cmds working with transport sub system. | ||
23 | * @author t3sserakt | ||
24 | */ | ||
25 | #ifndef GNUNET_TRANSPORT_TESTING_NG_LIB_H | ||
26 | #define GNUNET_TRANSPORT_TESTING_NG_LIB_H | ||
27 | |||
28 | |||
29 | #include "gnunet_util_lib.h" | ||
30 | #include "gnunet_testing_ng_lib.h" | ||
31 | |||
32 | /** | ||
33 | * Application handle; FIXME: what exactly is this? | ||
34 | */ | ||
35 | struct GNUNET_TRANSPORT_ApplicationHandle; | ||
36 | |||
37 | /** | ||
38 | * FIXME: what is this? | ||
39 | */ | ||
40 | struct GNUNET_TESTING_StartPeerState; | ||
41 | |||
42 | |||
43 | // FIXME: breaks naming conventions | ||
44 | typedef void * | ||
45 | (*GNUNET_TESTING_notify_connect_cb) (struct GNUNET_TESTING_Interpreter *is, | ||
46 | const struct GNUNET_PeerIdentity *peer); | ||
47 | |||
48 | |||
49 | |||
50 | // FIXME: breaks naming conventions! Needed public? | ||
51 | struct GNUNET_TESTING_StartPeerState | ||
52 | { | ||
53 | /** | ||
54 | * Context for our asynchronous completion. | ||
55 | */ | ||
56 | struct GNUNET_TESTING_AsyncContext ac; | ||
57 | |||
58 | /** | ||
59 | * The ip of a node. | ||
60 | */ | ||
61 | char *node_ip; | ||
62 | |||
63 | /** | ||
64 | * Receive callback | ||
65 | */ | ||
66 | struct GNUNET_MQ_MessageHandler *handlers; | ||
67 | |||
68 | /** | ||
69 | * GNUnet configuration file used to start a peer. | ||
70 | */ | ||
71 | char *cfgname; | ||
72 | |||
73 | /** | ||
74 | * Peer's configuration | ||
75 | */ | ||
76 | struct GNUNET_CONFIGURATION_Handle *cfg; | ||
77 | |||
78 | /** | ||
79 | * struct GNUNET_TESTING_Peer returned by GNUNET_TESTING_peer_configure. | ||
80 | */ | ||
81 | struct GNUNET_TESTING_Peer *peer; | ||
82 | |||
83 | /** | ||
84 | * Peer identity | ||
85 | */ | ||
86 | struct GNUNET_PeerIdentity id; | ||
87 | |||
88 | /** | ||
89 | * Peer's transport service handle | ||
90 | */ | ||
91 | struct GNUNET_TRANSPORT_CoreHandle *th; | ||
92 | |||
93 | /** | ||
94 | * Application handle | ||
95 | */ | ||
96 | struct GNUNET_TRANSPORT_ApplicationHandle *ah; | ||
97 | |||
98 | /** | ||
99 | * Peer's PEERSTORE Handle | ||
100 | */ | ||
101 | struct GNUNET_PEERSTORE_Handle *ph; | ||
102 | |||
103 | /** | ||
104 | * Hello get task | ||
105 | */ | ||
106 | struct GNUNET_SCHEDULER_Task *rh_task; | ||
107 | |||
108 | /** | ||
109 | * Peer's transport get hello handle to retrieve peer's HELLO message | ||
110 | */ | ||
111 | struct GNUNET_PEERSTORE_IterateContext *pic; | ||
112 | |||
113 | /** | ||
114 | * Hello | ||
115 | */ | ||
116 | char *hello; | ||
117 | |||
118 | /** | ||
119 | * Hello size | ||
120 | */ | ||
121 | size_t hello_size; | ||
122 | |||
123 | /** | ||
124 | * The label of the command which was started by calling GNUNET_TESTING_cmd_system_create. | ||
125 | */ | ||
126 | char *system_label; | ||
127 | |||
128 | /** | ||
129 | * An unique number to identify the peer | ||
130 | */ | ||
131 | unsigned int no; | ||
132 | |||
133 | /** | ||
134 | * A map with struct GNUNET_MQ_Handle values for each peer this peer | ||
135 | * is connected to. | ||
136 | */ | ||
137 | struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map; | ||
138 | |||
139 | /** | ||
140 | * Test setup for this peer. | ||
141 | */ | ||
142 | const struct GNUNET_TESTING_System *tl_system; | ||
143 | |||
144 | /** | ||
145 | * Callback which is called on neighbour connect events. | ||
146 | */ | ||
147 | GNUNET_TESTING_notify_connect_cb notify_connect; | ||
148 | |||
149 | /** | ||
150 | * Flag indicating, if udp broadcast should be switched on. | ||
151 | */ | ||
152 | enum GNUNET_GenericReturnValue broadcast; | ||
153 | }; | ||
154 | |||
155 | |||
156 | |||
157 | /** | ||
158 | * Create command. | ||
159 | * | ||
160 | * @param label name for command. | ||
161 | * @param system_label Label of the cmd to setup a test environment. | ||
162 | * @param no Decimal number representing the last byte of the IP address of this peer. | ||
163 | * @param node_ip The IP address of this node. | ||
164 | * @param cfgname Configuration file name for this peer. | ||
165 | * @param broadcast Flag indicating, if broadcast should be switched on. | ||
166 | * @return command. | ||
167 | */ | ||
168 | struct GNUNET_TESTING_Command | ||
169 | GNUNET_TESTING_cmd_start_peer (const char *label, | ||
170 | const char *system_label, | ||
171 | uint32_t no, | ||
172 | const char *node_ip, | ||
173 | const char *cfgname, | ||
174 | unsigned int broadcast); | ||
175 | |||
176 | |||
177 | struct GNUNET_TESTING_Command | ||
178 | GNUNET_TESTING_cmd_stop_peer (const char *label, | ||
179 | const char *start_label); | ||
180 | |||
181 | |||
182 | /** | ||
183 | * Retrieve peer identity from the test system with the unique node id. | ||
184 | * | ||
185 | * @param num The unique node id. | ||
186 | * @param tl_system The test system. | ||
187 | * @return The peer identity wrapping the public key. | ||
188 | */ | ||
189 | struct GNUNET_PeerIdentity * | ||
190 | GNUNET_TESTING_get_peer (unsigned int num, | ||
191 | const struct GNUNET_TESTING_System *tl_system); | ||
192 | |||
193 | |||
194 | |||
195 | |||
196 | /** | ||
197 | * Call #op on all simple traits. | ||
198 | */ | ||
199 | #define GNUNET_TRANSPORT_TESTING_SIMPLE_TRAITS(op, prefix) \ | ||
200 | op (prefix, connected_peers_map, const struct GNUNET_CONTAINER_MultiShortmap) \ | ||
201 | op (prefix, peer_id, const struct GNUNET_PeerIdentity) \ | ||
202 | op (prefix, hello_size, const size_t) \ | ||
203 | op (prefix, hello, const char) \ | ||
204 | op (prefix, application_handle, const struct GNUNET_TRANSPORT_ApplicationHandle) \ | ||
205 | op (prefix, state, const struct GNUNET_TESTING_StartPeerState) \ | ||
206 | op (prefix, broadcast, const enum GNUNET_GenericReturnValue) | ||
207 | |||
208 | |||
209 | GNUNET_TRANSPORT_TESTING_SIMPLE_TRAITS (GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT, GNUNET_TRANSPORT_TESTING) | ||
210 | |||
211 | #endif | ||
diff --git a/src/include/gnunet_tun_lib.h b/src/include/gnunet_tun_lib.h index 61880cea1..6c7d2cd42 100644 --- a/src/include/gnunet_tun_lib.h +++ b/src/include/gnunet_tun_lib.h | |||
@@ -18,7 +18,14 @@ | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) | ||
22 | #error "Only <gnunet_util_lib.h> can be included directly." | ||
23 | #endif | ||
24 | |||
21 | /** | 25 | /** |
26 | * @addtogroup vpn_suite VPN services and libraries | ||
27 | * @{ | ||
28 | * | ||
22 | * @author Philipp Toelke | 29 | * @author Philipp Toelke |
23 | * @author Christian Grothoff | 30 | * @author Christian Grothoff |
24 | * | 31 | * |
@@ -34,9 +41,6 @@ | |||
34 | #ifndef GNUNET_TUN_LIB_H | 41 | #ifndef GNUNET_TUN_LIB_H |
35 | #define GNUNET_TUN_LIB_H | 42 | #define GNUNET_TUN_LIB_H |
36 | 43 | ||
37 | #include "gnunet_common.h" | ||
38 | #include "gnunet_crypto_lib.h" | ||
39 | |||
40 | 44 | ||
41 | /* see http://www.iana.org/assignments/ethernet-numbers */ | 45 | /* see http://www.iana.org/assignments/ethernet-numbers */ |
42 | #ifndef ETH_P_IPV4 | 46 | #ifndef ETH_P_IPV4 |
@@ -546,6 +550,29 @@ struct GNUNET_TUN_DnsSrvRecord | |||
546 | 550 | ||
547 | 551 | ||
548 | /** | 552 | /** |
553 | * Payload of DNS URI record (header). | ||
554 | */ | ||
555 | struct GNUNET_TUN_DnsUriRecord | ||
556 | { | ||
557 | /** | ||
558 | * Preference for this entry (lower value is higher preference). Clients | ||
559 | * will contact hosts from the lowest-priority group first and fall back | ||
560 | * to higher priorities if the low-priority entries are unavailable. (NBO) | ||
561 | */ | ||
562 | uint16_t prio GNUNET_PACKED; | ||
563 | |||
564 | /** | ||
565 | * Relative weight for records with the same priority. Clients will use | ||
566 | * the hosts of the same (lowest) priority with a probability proportional | ||
567 | * to the weight given. (NBO) | ||
568 | */ | ||
569 | uint16_t weight GNUNET_PACKED; | ||
570 | |||
571 | /* followed by 'target' name */ | ||
572 | }; | ||
573 | |||
574 | |||
575 | /** | ||
549 | * Payload of DNS CERT record. | 576 | * Payload of DNS CERT record. |
550 | */ | 577 | */ |
551 | struct GNUNET_TUN_DnsCertRecord | 578 | struct GNUNET_TUN_DnsCertRecord |
@@ -946,3 +973,5 @@ GNUNET_TUN_compute_service_cadet_port (const struct GNUNET_HashCode *desc, | |||
946 | #endif | 973 | #endif |
947 | 974 | ||
948 | /** @} */ /* end of group */ | 975 | /** @} */ /* end of group */ |
976 | |||
977 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/gnunet_util_lib.h b/src/include/gnunet_util_lib.h index cc4f3a01e..ee850bc3c 100644 --- a/src/include/gnunet_util_lib.h +++ b/src/include/gnunet_util_lib.h | |||
@@ -30,6 +30,10 @@ | |||
30 | #ifndef GNUNET_UTIL_LIB_H | 30 | #ifndef GNUNET_UTIL_LIB_H |
31 | #define GNUNET_UTIL_LIB_H | 31 | #define GNUNET_UTIL_LIB_H |
32 | 32 | ||
33 | #define __GNUNET_UTIL_LIB_H_INSIDE__ | ||
34 | |||
35 | #include <sys/socket.h> | ||
36 | |||
33 | #ifdef __cplusplus | 37 | #ifdef __cplusplus |
34 | extern "C" | 38 | extern "C" |
35 | { | 39 | { |
@@ -59,9 +63,10 @@ extern "C" | |||
59 | * this service available to anyone but yourself. | 63 | * this service available to anyone but yourself. |
60 | */ | 64 | */ |
61 | #define GNUNET_AGPL_URL "https://git.gnunet.org/gnunet.git/tag/?h=v" \ | 65 | #define GNUNET_AGPL_URL "https://git.gnunet.org/gnunet.git/tag/?h=v" \ |
62 | PACKAGE_VERSION | 66 | GNUNET_VERSION |
63 | |||
64 | 67 | ||
68 | #include "gnunet_config.h" | ||
69 | #include "gnunet_common.h" | ||
65 | #include "gnunet_crypto_lib.h" | 70 | #include "gnunet_crypto_lib.h" |
66 | #include "gnunet_bandwidth_lib.h" | 71 | #include "gnunet_bandwidth_lib.h" |
67 | #include "gnunet_bio_lib.h" | 72 | #include "gnunet_bio_lib.h" |
@@ -72,6 +77,7 @@ extern "C" | |||
72 | #include "gnunet_helper_lib.h" | 77 | #include "gnunet_helper_lib.h" |
73 | #include "gnunet_mst_lib.h" | 78 | #include "gnunet_mst_lib.h" |
74 | #include "gnunet_mq_lib.h" | 79 | #include "gnunet_mq_lib.h" |
80 | #include "gnunet_nt_lib.h" | ||
75 | #include "gnunet_nc_lib.h" | 81 | #include "gnunet_nc_lib.h" |
76 | #include "gnunet_op_lib.h" | 82 | #include "gnunet_op_lib.h" |
77 | #include "gnunet_os_lib.h" | 83 | #include "gnunet_os_lib.h" |
@@ -86,6 +92,53 @@ extern "C" | |||
86 | #include "gnunet_dnsstub_lib.h" | 92 | #include "gnunet_dnsstub_lib.h" |
87 | #include "gnunet_dnsparser_lib.h" | 93 | #include "gnunet_dnsparser_lib.h" |
88 | #include "gnunet_child_management_lib.h" | 94 | #include "gnunet_child_management_lib.h" |
95 | #include "gnunet_error_codes.h" | ||
96 | |||
97 | |||
98 | /** | ||
99 | * Stringify operator. | ||
100 | * | ||
101 | * @param a some expression to stringify. Must NOT be a macro. | ||
102 | * @return same expression as a constant string. | ||
103 | */ | ||
104 | #define GNUNET_S(a) #a | ||
105 | |||
106 | /** | ||
107 | * Try to compress the given block of data using libz. Only returns | ||
108 | * the compressed block if compression worked and the new block is | ||
109 | * actually smaller. Decompress using #GNUNET_decompress(). | ||
110 | * | ||
111 | * @param data block to compress; if compression | ||
112 | * resulted in a smaller block, the first | ||
113 | * bytes of data are updated to the compressed | ||
114 | * data | ||
115 | * @param old_size number of bytes in data | ||
116 | * @param[out] result set to the compressed data, if compression worked | ||
117 | * @param[out] new_size set to size of result, if compression worked | ||
118 | * @return #GNUNET_YES if compression reduce the size, | ||
119 | * #GNUNET_NO if compression did not help | ||
120 | */ | ||
121 | int | ||
122 | GNUNET_try_compression (const char *data, | ||
123 | size_t old_size, | ||
124 | char **result, | ||
125 | size_t *new_size); | ||
126 | |||
127 | /** | ||
128 | * Decompress input, return the decompressed data as output. Dual to | ||
129 | * #GNUNET_try_compression(). Caller must set @a output_size to the | ||
130 | * number of bytes that were originally compressed. | ||
131 | * | ||
132 | * @param input compressed data | ||
133 | * @param input_size number of bytes in input | ||
134 | * @param output_size expected size of the output | ||
135 | * @return NULL on error, buffer of @a output_size decompressed bytes otherwise | ||
136 | */ | ||
137 | char * | ||
138 | GNUNET_decompress (const char *input, | ||
139 | size_t input_size, | ||
140 | size_t output_size); | ||
141 | |||
89 | 142 | ||
90 | #if 0 /* keep Emacsens' auto-indent happy */ | 143 | #if 0 /* keep Emacsens' auto-indent happy */ |
91 | { | 144 | { |
@@ -94,4 +147,6 @@ extern "C" | |||
94 | } | 147 | } |
95 | #endif | 148 | #endif |
96 | 149 | ||
150 | #undef __GNUNET_UTIL_LIB_H_INSIDE__ | ||
151 | |||
97 | #endif | 152 | #endif |
diff --git a/src/include/gnunet_vpn_service.h b/src/include/gnunet_vpn_service.h index 31476e140..f0a04ae1b 100644 --- a/src/include/gnunet_vpn_service.h +++ b/src/include/gnunet_vpn_service.h | |||
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup vpn_suite VPN services and libraries | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
@@ -31,6 +34,7 @@ | |||
31 | #ifndef GNUNET_VPN_SERVICE_H | 34 | #ifndef GNUNET_VPN_SERVICE_H |
32 | #define GNUNET_VPN_SERVICE_H | 35 | #define GNUNET_VPN_SERVICE_H |
33 | 36 | ||
37 | |||
34 | #include "gnunet_util_lib.h" | 38 | #include "gnunet_util_lib.h" |
35 | 39 | ||
36 | 40 | ||
@@ -159,3 +163,5 @@ GNUNET_VPN_disconnect (struct GNUNET_VPN_Handle *vh); | |||
159 | #endif | 163 | #endif |
160 | 164 | ||
161 | /** @} */ /* end of group */ | 165 | /** @} */ /* end of group */ |
166 | |||
167 | /** @} */ /* end of group addition */ | ||
diff --git a/src/include/meson.build b/src/include/meson.build new file mode 100644 index 000000000..3127a6a40 --- /dev/null +++ b/src/include/meson.build | |||
@@ -0,0 +1,122 @@ | |||
1 | configure_file( | ||
2 | input : 'gnunet_config.h.in', | ||
3 | output : 'gnunet_config.h', | ||
4 | configuration : cdata, | ||
5 | install: true, | ||
6 | install_dir: get_option('includedir')/'gnunet' | ||
7 | ) | ||
8 | |||
9 | install_headers( | ||
10 | 'gettext.h', | ||
11 | 'compat.h', | ||
12 | 'gnunet_abd_service.h', | ||
13 | 'gnunet_applications.h', | ||
14 | 'gnunet_arm_service.h', | ||
15 | 'gnunet_bandwidth_lib.h', | ||
16 | 'gnunet_bio_lib.h', | ||
17 | 'gnunet_dht_block_types.h', | ||
18 | 'gnunet_block_lib.h', | ||
19 | 'gnunet_block_group_lib.h', | ||
20 | 'gnunet_block_plugin.h', | ||
21 | 'gnunet_buffer_lib.h', | ||
22 | 'gnunet_child_management_lib.h', | ||
23 | 'gnunet_client_lib.h', | ||
24 | 'gnunet_common.h', | ||
25 | 'gnunet_constants.h', | ||
26 | 'gnunet_configuration_lib.h', | ||
27 | 'gnunet_consensus_service.h', | ||
28 | 'gnunet_container_lib.h', | ||
29 | 'gnunet_conversation_service.h', | ||
30 | 'gnunet_core_service.h', | ||
31 | 'gnunet_crypto_lib.h', | ||
32 | 'gnunet_curl_lib.h', | ||
33 | 'gnunet_datacache_lib.h', | ||
34 | 'gnunet_datacache_plugin.h', | ||
35 | 'gnunet_datastore_service.h', | ||
36 | 'gnunet_datastore_plugin.h', | ||
37 | 'gnunet_db_lib.h', | ||
38 | 'gnunet_dht_service.h', | ||
39 | 'gnunet_dhtu_plugin.h', | ||
40 | 'gnunet_disk_lib.h', | ||
41 | 'gnunet_dnsparser_lib.h', | ||
42 | 'gnunet_dnsstub_lib.h', | ||
43 | 'gnunet_dns_service.h', | ||
44 | 'gnunet_error_codes.h', | ||
45 | 'gnunet_fs_service.h', | ||
46 | 'gnunet_getopt_lib.h', | ||
47 | 'gnunet_gns_service.h', | ||
48 | 'gnunet_gnsrecord_lib.h', | ||
49 | 'gnunet_gnsrecord_json_lib.h', | ||
50 | 'gnunet_gnsrecord_plugin.h', | ||
51 | 'gnu_name_system_protocols.h', | ||
52 | 'gnu_name_system_service_ports.h', | ||
53 | 'gnu_name_system_record_types.h', | ||
54 | 'gnunet_hello_uri_lib.h', | ||
55 | 'gnunet_helper_lib.h', | ||
56 | 'gnunet_identity_service.h', | ||
57 | 'gnunet_reclaim_lib.h', | ||
58 | 'gnunet_reclaim_plugin.h', | ||
59 | 'gnunet_reclaim_service.h', | ||
60 | 'gnunet_json_lib.h', | ||
61 | 'gnunet_load_lib.h', | ||
62 | 'gnunet_cadet_service.h', | ||
63 | 'gnunet_messenger_service.h', | ||
64 | 'gnunet_mhd_compat.h', | ||
65 | 'gnunet_microphone_lib.h', | ||
66 | 'gnunet_mst_lib.h', | ||
67 | 'gnunet_mq_lib.h', | ||
68 | 'gnunet_namecache_plugin.h', | ||
69 | 'gnunet_namecache_service.h', | ||
70 | 'gnunet_namestore_plugin.h', | ||
71 | 'gnunet_namestore_service.h', | ||
72 | 'gnunet_nat_auto_service.h', | ||
73 | 'gnunet_nat_service.h', | ||
74 | 'gnunet_nc_lib.h', | ||
75 | 'gnunet_network_lib.h', | ||
76 | 'gnunet_nse_service.h', | ||
77 | 'gnunet_nt_lib.h', | ||
78 | 'gnunet_op_lib.h', | ||
79 | 'gnunet_os_lib.h', | ||
80 | 'gnunet_peer_lib.h', | ||
81 | 'gnunet_peerstore_plugin.h', | ||
82 | 'gnunet_peerstore_service.h', | ||
83 | 'gnunet_plugin_lib.h', | ||
84 | 'gnunet_pq_lib.h', | ||
85 | 'gnunet_program_lib.h', | ||
86 | 'gnunet_protocols.h', | ||
87 | 'gnunet_resolver_service.h', | ||
88 | 'gnunet_regex_service.h', | ||
89 | 'gnunet_rest_lib.h', | ||
90 | 'gnunet_rest_plugin.h', | ||
91 | 'gnunet_rps_service.h', | ||
92 | 'gnunet_revocation_service.h', | ||
93 | 'gnunet_scalarproduct_service.h', | ||
94 | 'gnunet_scheduler_lib.h', | ||
95 | 'gnunet_secretsharing_service.h', | ||
96 | 'gnunet_service_lib.h', | ||
97 | 'gnunet_set_service.h', | ||
98 | 'gnunet_seti_service.h', | ||
99 | 'gnunet_setu_service.h', | ||
100 | 'gnunet_signal_lib.h', | ||
101 | 'gnunet_signatures.h', | ||
102 | 'gnunet_socks.h', | ||
103 | 'gnunet_speaker_lib.h', | ||
104 | 'gnunet_sq_lib.h', | ||
105 | 'gnunet_statistics_service.h', | ||
106 | 'gnunet_strings_lib.h', | ||
107 | 'gnunet_testing_barrier.h', | ||
108 | 'gnunet_testing_lib.h', | ||
109 | 'gnunet_testing_plugin.h', | ||
110 | 'gnunet_testing_ng_lib.h', | ||
111 | 'gnunet_testing_netjail_lib.h', | ||
112 | 'gnunet_time_lib.h', | ||
113 | 'gnunet_transport_application_service.h', | ||
114 | 'gnunet_transport_communication_service.h', | ||
115 | 'gnunet_transport_core_service.h', | ||
116 | 'gnunet_transport_monitor_service.h', | ||
117 | 'gnunet_tun_lib.h', | ||
118 | 'gnunet_uri_lib.h', | ||
119 | 'gnunet_util_lib.h', | ||
120 | 'gnunet_vpn_service.h', | ||
121 | install_dir: get_option('includedir')/'gnunet' | ||
122 | ) | ||
diff --git a/src/include/platform.h b/src/include/platform.h index e44f9f51a..c04d8d487 100644 --- a/src/include/platform.h +++ b/src/include/platform.h | |||
@@ -34,7 +34,7 @@ | |||
34 | #ifndef HAVE_USED_CONFIG_H | 34 | #ifndef HAVE_USED_CONFIG_H |
35 | #define HAVE_USED_CONFIG_H | 35 | #define HAVE_USED_CONFIG_H |
36 | #if HAVE_CONFIG_H | 36 | #if HAVE_CONFIG_H |
37 | #include "gnunet_config.h" | 37 | #include "gnunet_private_config.h" |
38 | #endif | 38 | #endif |
39 | #endif | 39 | #endif |
40 | 40 | ||
@@ -44,6 +44,7 @@ | |||
44 | #ifdef HAVE_SYS_TYPES_H | 44 | #ifdef HAVE_SYS_TYPES_H |
45 | #include <sys/types.h> | 45 | #include <sys/types.h> |
46 | #endif | 46 | #endif |
47 | #include <inttypes.h> | ||
47 | 48 | ||
48 | #ifdef __clang__ | 49 | #ifdef __clang__ |
49 | #undef HAVE_STATIC_ASSERT | 50 | #undef HAVE_STATIC_ASSERT |
@@ -272,6 +273,10 @@ atoll (const char *nptr); | |||
272 | #define EXIT_NOTRUNNING 7 | 273 | #define EXIT_NOTRUNNING 7 |
273 | #endif | 274 | #endif |
274 | 275 | ||
276 | #ifndef EXIT_NO_RESTART | ||
277 | #define EXIT_NO_RESTART 9 | ||
278 | #endif | ||
279 | |||
275 | /** | 280 | /** |
276 | * clang et al do not have such an attribute | 281 | * clang et al do not have such an attribute |
277 | */ | 282 | */ |