aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTheJackiMonster <thejackimonster@gmail.com>2023-11-14 17:51:34 +0100
committerTheJackiMonster <thejackimonster@gmail.com>2023-11-14 17:51:34 +0100
commitb8672206edfb2047132311b9a3ab3a0138bdc422 (patch)
tree3c9361a0ba00b5f1d4944fec66cbc9a266d31ca9 /src/include
parent34587531b0ed15bbc8d73d21123101b7ca482389 (diff)
parent8e8c3f1e1c8c81a269c57e635153ec22fbfe216e (diff)
downloadgnunet-b8672206edfb2047132311b9a3ab3a0138bdc422.tar.gz
gnunet-b8672206edfb2047132311b9a3ab3a0138bdc422.zip
Merge branch 'master' of ssh://git.gnunet.org/gnunet
Diffstat (limited to 'src/include')
-rw-r--r--src/include/.gitignore7
-rw-r--r--src/include/Makefile.am17
-rw-r--r--src/include/gnu_name_system_record_types.h192
-rw-r--r--src/include/gnunet_abd_service.h28
-rw-r--r--src/include/gnunet_ats_application_service.h109
-rw-r--r--src/include/gnunet_ats_plugin.h492
-rw-r--r--src/include/gnunet_ats_service.h631
-rw-r--r--src/include/gnunet_ats_transport_service.h241
-rw-r--r--src/include/gnunet_bandwidth_lib.h4
-rw-r--r--src/include/gnunet_bio_lib.h37
-rw-r--r--src/include/gnunet_cadet_service.h2
-rw-r--r--src/include/gnunet_container_lib.h13
-rw-r--r--src/include/gnunet_conversation_service.h2
-rw-r--r--src/include/gnunet_core_service.h1
-rw-r--r--src/include/gnunet_crypto_lib.h1418
-rw-r--r--src/include/gnunet_curl_lib.h2
-rw-r--r--src/include/gnunet_dht_block_types.h156
-rw-r--r--src/include/gnunet_dht_service.h1
-rw-r--r--src/include/gnunet_error_codes.h242
-rw-r--r--src/include/gnunet_fragmentation_lib.h235
-rw-r--r--src/include/gnunet_friends_lib.h124
-rw-r--r--src/include/gnunet_gns_service.h4
-rw-r--r--src/include/gnunet_gnsrecord_lib.h164
-rw-r--r--src/include/gnunet_hello_lib.h545
-rw-r--r--src/include/gnunet_hello_uri_lib.h62
-rw-r--r--src/include/gnunet_identity_service.h575
-rw-r--r--src/include/gnunet_json_lib.h24
-rw-r--r--src/include/gnunet_messenger_service.h17
-rw-r--r--src/include/gnunet_mq_lib.h3
-rw-r--r--src/include/gnunet_mst_lib.h4
-rw-r--r--src/include/gnunet_my_lib.h511
-rw-r--r--src/include/gnunet_mysql_compat.h.in57
-rw-r--r--src/include/gnunet_mysql_lib.h151
-rw-r--r--src/include/gnunet_namestore_plugin.h14
-rw-r--r--src/include/gnunet_namestore_service.h28
-rw-r--r--src/include/gnunet_network_lib.h3
-rw-r--r--src/include/gnunet_nt_lib.h5
-rw-r--r--src/include/gnunet_peerstore_service.h148
-rw-r--r--src/include/gnunet_plugin_lib.h2
-rw-r--r--src/include/gnunet_pq_lib.h2
-rw-r--r--src/include/gnunet_program_lib.h41
-rw-r--r--src/include/gnunet_reclaim_service.h32
-rw-r--r--src/include/gnunet_rest_plugin.h21
-rw-r--r--src/include/gnunet_revocation_service.h134
-rw-r--r--src/include/gnunet_service_lib.h112
-rw-r--r--src/include/gnunet_signatures.h254
-rw-r--r--src/include/gnunet_testing_netjail_lib.h21
-rw-r--r--src/include/gnunet_testing_ng_lib.h311
-rw-r--r--src/include/gnunet_testing_plugin.h8
-rw-r--r--src/include/gnunet_transport_application_service.h3
-rw-r--r--src/include/gnunet_transport_communication_service.h3
-rw-r--r--src/include/gnunet_transport_hello_service.h207
-rw-r--r--src/include/gnunet_transport_manipulation_service.h123
-rw-r--r--src/include/gnunet_transport_monitor_service.h1
-rw-r--r--src/include/gnunet_transport_plugin.h733
-rw-r--r--src/include/gnunet_transport_service.h715
-rw-r--r--src/include/gnunet_transport_testing_ng_lib.h81
-rw-r--r--src/include/gnunet_util_lib.h1
-rw-r--r--src/include/meson.build123
59 files changed, 3344 insertions, 5853 deletions
diff --git a/src/include/.gitignore b/src/include/.gitignore
index dba282e99..76ca45ab4 100644
--- a/src/include/.gitignore
+++ b/src/include/.gitignore
@@ -1,8 +1,3 @@
1gnunet_error_codes.h
2gnu_name_system_record_flags.h
3gnu_name_system_record_types.h
4gnunet_dht_block_types.h
5gnunet_signatures.h
6!gnunet_config.h.in 1!gnunet_config.h.in
7gnunet_config.h 2gnunet_config.h
8gnunet_mysql_compat.h \ No newline at end of file 3gnunet_mysql_compat.h
diff --git a/src/include/Makefile.am b/src/include/Makefile.am
index 8519883c9..cf8c49cf1 100644
--- a/src/include/Makefile.am
+++ b/src/include/Makefile.am
@@ -17,10 +17,6 @@ gnunetinclude_HEADERS = \
17 gnunet_abd_service.h \ 17 gnunet_abd_service.h \
18 gnunet_applications.h \ 18 gnunet_applications.h \
19 gnunet_arm_service.h \ 19 gnunet_arm_service.h \
20 gnunet_ats_service.h \
21 gnunet_ats_application_service.h \
22 gnunet_ats_transport_service.h \
23 gnunet_ats_plugin.h \
24 gnunet_bandwidth_lib.h \ 20 gnunet_bandwidth_lib.h \
25 gnunet_bio_lib.h \ 21 gnunet_bio_lib.h \
26 gnunet_dht_block_types.h \ 22 gnunet_dht_block_types.h \
@@ -51,8 +47,6 @@ gnunetinclude_HEADERS = \
51 gnunet_dnsstub_lib.h \ 47 gnunet_dnsstub_lib.h \
52 gnunet_dns_service.h \ 48 gnunet_dns_service.h \
53 gnunet_error_codes.h \ 49 gnunet_error_codes.h \
54 gnunet_fragmentation_lib.h \
55 gnunet_friends_lib.h \
56 gnunet_fs_service.h \ 50 gnunet_fs_service.h \
57 gnunet_getopt_lib.h \ 51 gnunet_getopt_lib.h \
58 gnunet_gns_service.h \ 52 gnunet_gns_service.h \
@@ -60,7 +54,6 @@ gnunetinclude_HEADERS = \
60 gnunet_gnsrecord_json_lib.h \ 54 gnunet_gnsrecord_json_lib.h \
61 gnunet_gnsrecord_plugin.h \ 55 gnunet_gnsrecord_plugin.h \
62 gnu_name_system_record_types.h \ 56 gnu_name_system_record_types.h \
63 gnunet_hello_lib.h \
64 gnunet_hello_uri_lib.h \ 57 gnunet_hello_uri_lib.h \
65 gnunet_helper_lib.h \ 58 gnunet_helper_lib.h \
66 gnunet_identity_service.h \ 59 gnunet_identity_service.h \
@@ -75,9 +68,6 @@ gnunetinclude_HEADERS = \
75 gnunet_microphone_lib.h \ 68 gnunet_microphone_lib.h \
76 gnunet_mst_lib.h \ 69 gnunet_mst_lib.h \
77 gnunet_mq_lib.h \ 70 gnunet_mq_lib.h \
78 gnunet_my_lib.h \
79 gnunet_mysql_compat.h \
80 gnunet_mysql_lib.h \
81 gnunet_namecache_plugin.h \ 71 gnunet_namecache_plugin.h \
82 gnunet_namecache_service.h \ 72 gnunet_namecache_service.h \
83 gnunet_namestore_plugin.h \ 73 gnunet_namestore_plugin.h \
@@ -126,14 +116,11 @@ gnunetinclude_HEADERS = \
126 gnunet_testing_ng_lib.h \ 116 gnunet_testing_ng_lib.h \
127 gnunet_testing_netjail_lib.h \ 117 gnunet_testing_netjail_lib.h \
128 gnunet_time_lib.h \ 118 gnunet_time_lib.h \
129 gnunet_transport_service.h \
130 gnunet_transport_application_service.h \ 119 gnunet_transport_application_service.h \
131 gnunet_transport_communication_service.h \ 120 gnunet_transport_communication_service.h \
132 gnunet_transport_core_service.h \
133 gnunet_transport_hello_service.h \
134 gnunet_transport_manipulation_service.h \
135 gnunet_transport_monitor_service.h \ 121 gnunet_transport_monitor_service.h \
136 gnunet_transport_plugin.h \ 122 gnunet_transport_core_service.h \
123 gnunet_transport_testing_ng_lib.h \
137 gnunet_tun_lib.h \ 124 gnunet_tun_lib.h \
138 gnunet_uri_lib.h \ 125 gnunet_uri_lib.h \
139 gnunet_util_lib.h \ 126 gnunet_util_lib.h \
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..2cefce589
--- /dev/null
+++ b/src/include/gnu_name_system_record_types.h
@@ -0,0 +1,192 @@
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
33extern "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 * For ABD policies
102 */
103#define GNUNET_GNSRECORD_TYPE_DELEGATE 65548
104
105
106/**
107 * For ABD reverse lookups
108 */
109#define GNUNET_GNSRECORD_TYPE_ATTRIBUTE 65549
110
111
112/**
113 * for reclaim records
114 */
115#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF 65550
116
117
118/**
119 * Redirection record
120 */
121#define GNUNET_GNSRECORD_TYPE_REDIRECT 65551
122
123
124/**
125 * For reclaim OIDC client names.
126 */
127#define GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT 65552
128
129
130/**
131 * Used reclaimID OIDC client redirect URIs.
132 */
133#define GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT 65553
134
135
136/**
137 * Record type for an attribute attestation (e.g. JWT).
138 */
139#define GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL 65554
140
141
142/**
143 * Record type for a presentation of a credential.
144 */
145#define GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION 65555
146
147
148/**
149 * GNS zone delegation (EDKEY)
150 */
151#define GNUNET_GNSRECORD_TYPE_EDKEY 65556
152
153
154/**
155 * Encoding for Robust Immutable Storage (ERIS) binary read capability
156 */
157#define GNUNET_GNSRECORD_TYPE_ERIS_READ_CAPABILITY 65557
158
159
160/**
161 * Record type to share an entry of a messenger room
162 */
163#define GNUNET_GNSRECORD_TYPE_MESSENGER_ROOM_ENTRY 65558
164
165
166/**
167 * Record type to indicate a previously delete record (PRIVATE only)
168 */
169#define GNUNET_GNSRECORD_TYPE_TOMBSTONE 65559
170
171
172/**
173 * Record type to store details about a messenger room
174 */
175#define GNUNET_GNSRECORD_TYPE_MESSENGER_ROOM_DETAILS 65560
176
177
178/**
179 * Record type to store DID Documents
180 */
181#define GNUNET_GNSRECORD_TYPE_DID_DOCUMENT 65561
182
183
184
185#if 0 /* keep Emacsens' auto-indent happy */
186{
187#endif
188#ifdef __cplusplus
189}
190#endif
191
192#endif
diff --git a/src/include/gnunet_abd_service.h b/src/include/gnunet_abd_service.h
index 75c1757ab..cb6e77256 100644
--- a/src/include/gnunet_abd_service.h
+++ b/src/include/gnunet_abd_service.h
@@ -107,7 +107,7 @@ struct GNUNET_ABD_DelegationRecordSet
107 /** 107 /**
108 * Public key of the subject this attribute was delegated to 108 * Public key of the subject this attribute was delegated to
109 */ 109 */
110 struct GNUNET_IDENTITY_PublicKey subject_key; 110 struct GNUNET_CRYPTO_PublicKey subject_key;
111 111
112 /** 112 /**
113 * Length of attribute, may be 0 113 * Length of attribute, may be 0
@@ -127,7 +127,7 @@ struct GNUNET_ABD_DelegationSet
127 /** 127 /**
128 * Public key of the subject this attribute was delegated to 128 * Public key of the subject this attribute was delegated to
129 */ 129 */
130 struct GNUNET_IDENTITY_PublicKey subject_key; 130 struct GNUNET_CRYPTO_PublicKey subject_key;
131 131
132 uint32_t subject_attribute_len; 132 uint32_t subject_attribute_len;
133 133
@@ -147,12 +147,12 @@ struct GNUNET_ABD_Delegation
147 /** 147 /**
148 * The issuer of the delegation 148 * The issuer of the delegation
149 */ 149 */
150 struct GNUNET_IDENTITY_PublicKey issuer_key; 150 struct GNUNET_CRYPTO_PublicKey issuer_key;
151 151
152 /** 152 /**
153 * Public key of the subject this attribute was delegated to 153 * Public key of the subject this attribute was delegated to
154 */ 154 */
155 struct GNUNET_IDENTITY_PublicKey subject_key; 155 struct GNUNET_CRYPTO_PublicKey subject_key;
156 156
157 /** 157 /**
158 * Length of the attribute 158 * Length of the attribute
@@ -185,17 +185,17 @@ struct GNUNET_ABD_Delegate
185 /** 185 /**
186 * The issuer of the credential 186 * The issuer of the credential
187 */ 187 */
188 struct GNUNET_IDENTITY_PublicKey issuer_key; 188 struct GNUNET_CRYPTO_PublicKey issuer_key;
189 189
190 /** 190 /**
191 * Public key of the subject this credential was issued to 191 * Public key of the subject this credential was issued to
192 */ 192 */
193 struct GNUNET_IDENTITY_PublicKey subject_key; 193 struct GNUNET_CRYPTO_PublicKey subject_key;
194 194
195 /** 195 /**
196 * Signature of this credential 196 * Signature of this credential
197 */ 197 */
198 struct GNUNET_IDENTITY_Signature signature; 198 struct GNUNET_CRYPTO_Signature signature;
199 199
200 /** 200 /**
201 * Expiration of this credential 201 * Expiration of this credential
@@ -322,9 +322,9 @@ typedef void (*GNUNET_ABD_RemoveDelegateResultProcessor) (void *cls,
322 */ 322 */
323struct GNUNET_ABD_Request* 323struct GNUNET_ABD_Request*
324 GNUNET_ABD_verify (struct GNUNET_ABD_Handle *handle, 324 GNUNET_ABD_verify (struct GNUNET_ABD_Handle *handle,
325 const struct GNUNET_IDENTITY_PublicKey *issuer_key, 325 const struct GNUNET_CRYPTO_PublicKey *issuer_key,
326 const char *issuer_attribute, 326 const char *issuer_attribute,
327 const struct GNUNET_IDENTITY_PublicKey *subject_key, 327 const struct GNUNET_CRYPTO_PublicKey *subject_key,
328 uint32_t delegate_count, 328 uint32_t delegate_count,
329 const struct GNUNET_ABD_Delegate *delegates, 329 const struct GNUNET_ABD_Delegate *delegates,
330 enum GNUNET_ABD_AlgoDirectionFlags direction, 330 enum GNUNET_ABD_AlgoDirectionFlags direction,
@@ -335,9 +335,9 @@ struct GNUNET_ABD_Request*
335 335
336struct GNUNET_ABD_Request* 336struct GNUNET_ABD_Request*
337 GNUNET_ABD_collect (struct GNUNET_ABD_Handle *handle, 337 GNUNET_ABD_collect (struct GNUNET_ABD_Handle *handle,
338 const struct GNUNET_IDENTITY_PublicKey *issuer_key, 338 const struct GNUNET_CRYPTO_PublicKey *issuer_key,
339 const char *issuer_attribute, 339 const char *issuer_attribute,
340 const struct GNUNET_IDENTITY_PrivateKey *subject_key, 340 const struct GNUNET_CRYPTO_PrivateKey *subject_key,
341 enum GNUNET_ABD_AlgoDirectionFlags direction, 341 enum GNUNET_ABD_AlgoDirectionFlags direction,
342 GNUNET_ABD_CredentialResultProcessor proc, 342 GNUNET_ABD_CredentialResultProcessor proc,
343 void *proc_cls, 343 void *proc_cls,
@@ -360,7 +360,7 @@ struct GNUNET_ABD_Request *
360GNUNET_ABD_add_delegation (struct GNUNET_ABD_Handle *handle, 360GNUNET_ABD_add_delegation (struct GNUNET_ABD_Handle *handle,
361 struct GNUNET_IDENTITY_Ego *issuer, 361 struct GNUNET_IDENTITY_Ego *issuer,
362 const char *attribute, 362 const char *attribute,
363 struct GNUNET_IDENTITY_PublicKey *subject, 363 struct GNUNET_CRYPTO_PublicKey *subject,
364 const char *delegated_attribute, 364 const char *delegated_attribute,
365 GNUNET_ABD_DelegateResultProcessor proc, 365 GNUNET_ABD_DelegateResultProcessor proc,
366 void *proc_cls); 366 void *proc_cls);
@@ -393,8 +393,8 @@ GNUNET_ABD_remove_delegation (struct GNUNET_ABD_Handle *handle,
393 * @return handle to the queued request 393 * @return handle to the queued request
394 */ 394 */
395struct GNUNET_ABD_Delegate* 395struct GNUNET_ABD_Delegate*
396GNUNET_ABD_delegate_issue (const struct GNUNET_IDENTITY_PrivateKey *issuer, 396GNUNET_ABD_delegate_issue (const struct GNUNET_CRYPTO_PrivateKey *issuer,
397 struct GNUNET_IDENTITY_PublicKey *subject, 397 struct GNUNET_CRYPTO_PublicKey *subject,
398 const char *iss_attr, 398 const char *iss_attr,
399 const char *sub_attr, 399 const char *sub_attr,
400 struct GNUNET_TIME_Absolute *expiration); 400 struct GNUNET_TIME_Absolute *expiration);
diff --git a/src/include/gnunet_ats_application_service.h b/src/include/gnunet_ats_application_service.h
deleted file mode 100644
index da7fd4b52..000000000
--- a/src/include/gnunet_ats_application_service.h
+++ /dev/null
@@ -1,109 +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 * @addtogroup Backbone
22 * @{
23 *
24 * @file
25 * Bandwidth allocation API for applications to interact with
26 *
27 * @author Christian Grothoff
28 * @author Matthias Wachs
29 *
30 * @defgroup ats ATS service
31 * Bandwidth allocation
32 *
33 * @see [Documentation](https://gnunet.org/ats-subsystem)
34 *
35 * @{
36 */
37#ifndef GNUNET_ATS_APPLICATION_SERVICE_H
38#define GNUNET_ATS_APPLICATION_SERVICE_H
39
40
41#include "gnunet_constants.h"
42#include "gnunet_util_lib.h"
43
44/**
45 * Handle to the ATS subsystem for making suggestions about
46 * connections the peer would like to have.
47 */
48struct GNUNET_ATS_ApplicationHandle;
49
50
51/**
52 * Initialize the ATS application client handle.
53 *
54 * @param cfg configuration to use
55 * @return ats application handle, NULL on error
56 */
57struct GNUNET_ATS_ApplicationHandle *
58GNUNET_ATS_application_init (const struct GNUNET_CONFIGURATION_Handle *cfg);
59
60
61/**
62 * Shutdown ATS application client.
63 *
64 * @param ch handle to destroy
65 */
66void
67GNUNET_ATS_application_done (struct GNUNET_ATS_ApplicationHandle *ch);
68
69
70/**
71 * Handle for suggestion requests.
72 */
73struct GNUNET_ATS_ApplicationSuggestHandle;
74
75
76/**
77 * An application would like to communicate with a peer. ATS should
78 * allocate bandwidth using a suitable address for requiremetns @a pk
79 * to transport.
80 *
81 * @param ch handle
82 * @param peer identity of the peer we need an address for
83 * @param pk what kind of application will the application require (can be
84 * #GNUNET_MQ_PREFERENCE_NONE, we will still try to connect)
85 * @param bw desired bandwidth, can be zero (we will still try to connect)
86 * @return suggestion handle, NULL if request is already pending
87 */
88struct GNUNET_ATS_ApplicationSuggestHandle *
89GNUNET_ATS_application_suggest (struct GNUNET_ATS_ApplicationHandle *ch,
90 const struct GNUNET_PeerIdentity *peer,
91 enum GNUNET_MQ_PreferenceKind pk,
92 struct GNUNET_BANDWIDTH_Value32NBO bw);
93
94
95/**
96 * We no longer care about communicating with a peer.
97 *
98 * @param sh handle
99 */
100void
101GNUNET_ATS_application_suggest_cancel (struct
102 GNUNET_ATS_ApplicationSuggestHandle *sh);
103
104/** @} */ /* end of group */
105
106/** @} */ /* end of Backbone addition*/
107
108#endif
109/* 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 206f2dd52..000000000
--- a/src/include/gnunet_ats_plugin.h
+++ /dev/null
@@ -1,492 +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 * @addtogroup Backbone
23 * @{
24 *
25 * @author Christian Grothoff
26 *
27 * @file
28 * API for the ATS solvers.
29 *
30 * @defgroup ats-plugin ATS service plugin API
31 * Plugin API for the ATS service.
32 *
33 * Specifies the struct that is given to the plugin's entry method and the other
34 * struct that must be returned. Note that the destructors of ATS plugins will
35 * be given the value returned by the constructor and is expected to return a
36 * NULL pointer.
37 *
38 * @{
39 */
40#ifndef PLUGIN_ATS_H
41#define PLUGIN_ATS_H
42
43
44#include "gnunet_ats_service.h"
45#include "gnunet_statistics_service.h"
46
47/**
48 * Representation of an address the plugin can choose from.
49 */
50struct ATS_Address;
51
52/**
53 * Change the preference for a peer
54 *
55 * @param handle the solver handle
56 * @param client the client sending this request
57 * @param peer the peer id
58 * @param kind the preference kind to change
59 * @param score the new preference score
60 * @param pref_rel the normalized preference value for this kind over all clients
61 */
62typedef void
63(*GAS_solver_address_change_preference) (void *solver,
64 const struct GNUNET_PeerIdentity *peer,
65 enum GNUNET_ATS_PreferenceKind kind,
66 double pref_rel);
67
68
69/**
70 * Give feedback about the current assignment
71 *
72 * @param handle the solver handle
73 * @param application the application sending this request
74 * @param peer the peer id
75 * @param scope the time interval for this feedback: [now - scope .. now]
76 * @param kind the preference kind for this feedback
77 * @param score the feedback score
78 */
79typedef void
80(*GAS_solver_address_feedback_preference) (void *solver,
81 struct GNUNET_SERVICE_Client *
82 application,
83 const struct
84 GNUNET_PeerIdentity *peer,
85 const struct GNUNET_TIME_Relative
86 scope,
87 enum GNUNET_ATS_PreferenceKind kind,
88 double score);
89
90/**
91 * Notify the solver about a bulk operation changing possibly a lot of values
92 * Solver will not resolve until all bulk operations are marked as done
93 *
94 * @param solver the solver
95 */
96typedef void
97(*GAS_solver_bulk_start) (void *solver);
98
99
100/**
101 * Mark a bulk operation as done
102 * Solver will resolve if values have changed
103 *
104 * @param solver the solver
105 */
106typedef void
107(*GAS_solver_bulk_stop) (void *solver);
108
109
110/**
111 * Add a single address within a network to the solver
112 *
113 * @param solver the solver Handle
114 * @param address the address to add
115 * @param network network type of this address
116 */
117typedef void
118(*GAS_solver_address_add) (void *solver,
119 struct ATS_Address *address,
120 uint32_t network);
121
122
123/**
124 * Delete an address or just the session from the solver
125 *
126 * @param solver the solver Handle
127 * @param address the address to delete
128 */
129typedef void
130(*GAS_solver_address_delete) (void *solver,
131 struct ATS_Address *address);
132
133
134/**
135 * Transport properties for this address have changed
136 *
137 * @param solver solver handle
138 * @param address the address
139 */
140typedef void
141(*GAS_solver_address_property_changed) (void *solver,
142 struct ATS_Address *address);
143
144
145/**
146 * Get the preferred address for a peer from solver
147 *
148 * @param solver the solver to use
149 * @param peer the peer
150 */
151typedef void
152(*GAS_solver_get_preferred_address) (void *solver,
153 const struct GNUNET_PeerIdentity *peer);
154
155
156/**
157 * Stop getting the preferred address for a peer from solver
158 *
159 * @param solver the solver to use
160 * @param peer the peer
161 */
162typedef void
163(*GAS_solver_stop_get_preferred_address) (void *solver,
164 const struct
165 GNUNET_PeerIdentity *peer);
166
167
168/**
169 * Solver functions.
170 *
171 * Each solver is required to set up and return an instance
172 * of this struct during initialization.
173 */
174struct GNUNET_ATS_SolverFunctions
175{
176 /**
177 * Closure to pass to all solver functions in this struct.
178 */
179 void *cls;
180
181 /**
182 * Add a new address for a peer to the solver
183 *
184 * The address is already contained in the addresses hashmap!
185 */
186 GAS_solver_address_add s_add;
187
188 /**
189 * Update the properties of an address in the solver
190 */
191 GAS_solver_address_property_changed s_address_update_property;
192
193 /**
194 * Tell solver to notify ATS if the address to use changes for a specific
195 * peer using the bandwidth changed callback
196 *
197 * The solver must only notify about changes for peers with pending address
198 * requests!
199 */
200 GAS_solver_get_preferred_address s_get;
201
202 /**
203 * Tell solver stop notifying ATS about changes for this peers
204 *
205 * The solver must only notify about changes for peers with pending address
206 * requests!
207 */
208 GAS_solver_stop_get_preferred_address s_get_stop;
209
210 /**
211 * Delete an address in the solver
212 *
213 * The address is not contained in the address hashmap anymore!
214 */
215 GAS_solver_address_delete s_del;
216
217 /**
218 * Change relative preference for quality in solver
219 */
220 GAS_solver_address_change_preference s_pref;
221
222 /**
223 * Give feedback about the current assignment
224 */
225 GAS_solver_address_feedback_preference s_feedback;
226
227 /**
228 * Start a bulk operation
229 *
230 * Used if many values have to be updated at the same time.
231 * When a bulk operation is pending the solver does not have to resolve
232 * the problem since more updates will follow anyway
233 *
234 * For each call to bulk_start, a call to bulk_stop is required!
235 */
236 GAS_solver_bulk_start s_bulk_start;
237
238 /**
239 * Bulk operation done
240 *
241 * If no more bulk operations are pending, the solver can solve the problem
242 * with the updated values
243 */
244 GAS_solver_bulk_stop s_bulk_stop;
245};
246
247
248/**
249 * Operation codes for solver information callback
250 *
251 * Order of calls is expected to be:
252 * #GAS_OP_SOLVE_START
253 * #GAS_OP_SOLVE_STOP
254 * #GAS_OP_SOLVE_UPDATE_NOTIFICATION_START
255 * #GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP
256 *
257 */
258enum GAS_Solver_Operation
259{
260 /**
261 * A solution iteration has been started
262 */
263 GAS_OP_SOLVE_START,
264
265 /**
266 * A solution iteration has been finished
267 */
268 GAS_OP_SOLVE_STOP,
269
270 /**
271 * The setup of the problem as a preparation to solve it was started
272 */
273 GAS_OP_SOLVE_SETUP_START,
274
275 /**
276 * The setup of the problem as a preparation to solve is finished
277 */
278 GAS_OP_SOLVE_SETUP_STOP,
279
280 /**
281 * Solving of the LP problem was started
282 * MLP solver only
283 */
284 GAS_OP_SOLVE_MLP_LP_START,
285
286 /**
287 * Solving of the LP problem is done
288 * MLP solver only
289 */
290 GAS_OP_SOLVE_MLP_LP_STOP,
291
292 /**
293 * Solving of the MLP problem was started
294 * MLP solver only
295 */
296 GAS_OP_SOLVE_MLP_MLP_START,
297
298 /**
299 * Solving of the MLP problem is done
300 * MLP solver only
301 */
302 GAS_OP_SOLVE_MLP_MLP_STOP,
303
304 /**
305 * After the problem was finished, start notifications about changes
306 * to addresses
307 */
308 GAS_OP_SOLVE_UPDATE_NOTIFICATION_START,
309
310 /**
311 * After the problem was finished, notifications about changes to addresses
312 * are done
313 */
314 GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP
315};
316
317
318/**
319 * Status of a GAS_Solver_Operation operation
320 */
321enum GAS_Solver_Status
322{
323 /**
324 * Success
325 */
326 GAS_STAT_SUCCESS,
327
328 /**
329 * Failure
330 */
331 GAS_STAT_FAIL
332};
333
334
335/**
336 * Status of the operation
337 */
338enum GAS_Solver_Additional_Information
339{
340 /**
341 * No more specific information
342 */
343 GAS_INFO_NONE,
344
345 /**
346 * A full solution process is performed
347 * Quite specific to the MLP solver
348 */
349 GAS_INFO_FULL,
350
351 /**
352 * An existing solution was reused
353 * Quite specific to the MLP solver
354 */
355 GAS_INFO_UPDATED,
356
357 /**
358 * The proportional solver had to recalculate for a single network
359 */
360 GAS_INFO_PROP_SINGLE,
361
362 /**
363 * The proportional solver had to recalculate for all networks
364 */
365 GAS_INFO_PROP_ALL
366};
367
368
369/**
370 * Callback to call with additional information
371 * Used for measurement
372 *
373 * @param cls the closure
374 * @param op the operation
375 */
376typedef void
377(*GAS_solver_information_callback) (void *cls,
378 enum GAS_Solver_Operation op,
379 enum GAS_Solver_Status stat,
380 enum GAS_Solver_Additional_Information);
381
382
383/**
384 * Callback to call from solver when bandwidth for address has changed
385 *
386 * @param address the with changed bandwidth assigned
387 */
388typedef void
389(*GAS_bandwidth_changed_cb) (void *cls,
390 struct ATS_Address *address);
391
392
393/**
394 * Callback to call from solver to obtain application preference
395 * values for a peer.
396 *
397 * @param cls the cls
398 * @param id the peer id
399 * @return carry of double values containing the preferences with
400 * GNUNET_ATS_PreferenceCount elements
401 */
402typedef const double *
403(*GAS_get_preferences) (void *cls,
404 const struct GNUNET_PeerIdentity *id);
405
406
407/**
408 * Callback to call from solver to obtain application connectivity
409 * preferences for a peer.
410 *
411 * @param cls the cls
412 * @param id the peer id
413 * @return 0 if connectivity is not desired, non-null if address
414 * suggestions are requested
415 */
416typedef unsigned int
417(*GAS_get_connectivity) (void *cls,
418 const struct GNUNET_PeerIdentity *id);
419
420
421/**
422 * The ATS plugin will pass a pointer to a struct
423 * of this type as to the initialization function
424 * of the ATS plugins.
425 */
426struct GNUNET_ATS_PluginEnvironment
427{
428 /**
429 * Configuration handle to be used by the solver
430 */
431 const struct GNUNET_CONFIGURATION_Handle *cfg;
432
433 /**
434 * Statistics handle to be used by the solver
435 */
436 struct GNUNET_STATISTICS_Handle *stats;
437
438 /**
439 * Closure to pass to all callbacks in this struct.
440 */
441 void *cls;
442
443 /**
444 * Hashmap containing all addresses available
445 */
446 struct GNUNET_CONTAINER_MultiPeerMap *addresses;
447
448 /**
449 * ATS addresses callback to be notified about bandwidth assignment changes
450 */
451 GAS_bandwidth_changed_cb bandwidth_changed_cb;
452
453 /**
454 * ATS addresses function to obtain preference values
455 */
456 GAS_get_preferences get_preferences;
457
458 /**
459 * ATS addresses function to obtain preference values
460 */
461 GAS_get_connectivity get_connectivity;
462
463 /**
464 * Callback for solver to call with status information,
465 * can be NULL
466 */
467 GAS_solver_information_callback info_cb;
468
469 /**
470 * Number of networks available, size of the @e out_quota
471 * and @e in_quota arrays.
472 */
473 unsigned int network_count;
474
475 /**
476 * Array of configured outbound quotas
477 * Order according to networks in network array
478 */
479 unsigned long long out_quota[GNUNET_NT_COUNT];
480
481 /**
482 * Array of configured inbound quotas
483 * Order according to networks in network array
484 */
485 unsigned long long in_quota[GNUNET_NT_COUNT];
486};
487
488#endif
489
490/** @} */ /* end of group */
491
492/** @} */ /* end of group addition */
diff --git a/src/include/gnunet_ats_service.h b/src/include/gnunet_ats_service.h
deleted file mode 100644
index ce149875a..000000000
--- a/src/include/gnunet_ats_service.h
+++ /dev/null
@@ -1,631 +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 * @addtogroup Backbone
22 * @{
23 *
24 * @file
25 * Automatic transport selection and outbound bandwidth determination
26 *
27 * @author Christian Grothoff
28 * @author Matthias Wachs
29 *
30 * @defgroup ats ATS service
31 * Automatic Transport Selection and outbound bandwidth determination
32 *
33 * @see [Documentation](https://gnunet.org/ats-subsystem)
34 *
35 * @{
36 */
37#ifndef GNUNET_ATS_SERVICE_H
38#define GNUNET_ATS_SERVICE_H
39
40
41#include "gnunet_constants.h"
42#include "gnunet_util_lib.h"
43#include "gnunet_hello_lib.h"
44
45
46/**
47 * Default bandwidth assigned to a network : 64 KB/s
48 */
49#define GNUNET_ATS_DefaultBandwidth 65536
50
51/**
52 * Undefined value for an `enum GNUNET_ATS_Property`
53 */
54#define GNUNET_ATS_VALUE_UNDEFINED UINT32_MAX
55
56/**
57 * String representation for GNUNET_ATS_VALUE_UNDEFINED
58 */
59#define GNUNET_ATS_VALUE_UNDEFINED_STR "undefined"
60
61/**
62 * Maximum bandwidth assigned to a network : 4095 MB/s
63 */
64#define GNUNET_ATS_MaxBandwidth UINT32_MAX
65
66/**
67 * Textual equivalent for GNUNET_ATS_MaxBandwidth
68 */
69#define GNUNET_ATS_MaxBandwidthString "unlimited"
70
71
72/**
73 * ATS performance characteristics for an address.
74 */
75struct GNUNET_ATS_Properties
76{
77 /**
78 * Delay. Time between when the time packet is sent and the packet
79 * arrives. FOREVER if we did not measure yet.
80 */
81 struct GNUNET_TIME_Relative delay;
82
83 /**
84 * Actual traffic on this connection from this peer to the other peer.
85 * Includes transport overhead.
86 *
87 * Unit: [bytes/second]
88 */
89 uint32_t utilization_out;
90
91 /**
92 * Actual traffic on this connection from the other peer to this peer.
93 * Includes transport overhead.
94 *
95 * Unit: [bytes/second]
96 */
97 uint32_t utilization_in;
98
99 /**
100 * Distance on network layer (required for distance-vector routing)
101 * in hops. Zero for direct connections (e.g. plain TCP/UDP).
102 */
103 unsigned int distance;
104
105 /**
106 * Which network scope does the respective address belong to?
107 * This property does not change.
108 */
109 enum GNUNET_NetworkType scope;
110};
111
112
113/**
114 * ATS performance characteristics for an address in
115 * network byte order (for IPC).
116 */
117struct GNUNET_ATS_PropertiesNBO
118{
119 /**
120 * Actual traffic on this connection from this peer to the other peer.
121 * Includes transport overhead.
122 *
123 * Unit: [bytes/second]
124 */
125 uint32_t utilization_out GNUNET_PACKED;
126
127 /**
128 * Actual traffic on this connection from the other peer to this peer.
129 * Includes transport overhead.
130 *
131 * Unit: [bytes/second]
132 */
133 uint32_t utilization_in GNUNET_PACKED;
134
135 /**
136 * Which network scope does the respective address belong to?
137 * This property does not change.
138 */
139 uint32_t scope GNUNET_PACKED;
140
141 /**
142 * Distance on network layer (required for distance-vector routing)
143 * in hops. Zero for direct connections (e.g. plain TCP/UDP).
144 */
145 uint32_t distance GNUNET_PACKED;
146
147 /**
148 * Delay. Time between when the time packet is sent and the packet
149 * arrives. FOREVER if we did not measure yet.
150 */
151 struct GNUNET_TIME_RelativeNBO delay;
152};
153
154
155/* ********************* LAN Characterization library ************************ */
156/* Note: these functions do not really communicate with the ATS service */
157
158
159/**
160 * Convert ATS properties from host to network byte order.
161 *
162 * @param nbo[out] value written
163 * @param hbo value read
164 */
165void
166GNUNET_ATS_properties_hton (struct GNUNET_ATS_PropertiesNBO *nbo,
167 const struct GNUNET_ATS_Properties *hbo);
168
169
170/**
171 * Convert ATS properties from network to host byte order.
172 *
173 * @param hbo[out] value written
174 * @param nbo value read
175 */
176void
177GNUNET_ATS_properties_ntoh (struct GNUNET_ATS_Properties *hbo,
178 const struct GNUNET_ATS_PropertiesNBO *nbo);
179
180
181/* ********************Connection Suggestion API ***************************** */
182
183/**
184 * Handle to the ATS subsystem for making suggestions about
185 * connections the peer would like to have.
186 */
187struct GNUNET_ATS_ConnectivityHandle;
188
189/**
190 * Handle for address suggestion requests.
191 */
192struct GNUNET_ATS_ConnectivitySuggestHandle;
193
194
195/**
196 * Initialize the ATS connectivity suggestion client handle.
197 *
198 * @param cfg configuration to use
199 * @return ats connectivity handle, NULL on error
200 */
201struct GNUNET_ATS_ConnectivityHandle *
202GNUNET_ATS_connectivity_init (const struct GNUNET_CONFIGURATION_Handle *cfg);
203
204
205/**
206 * Shutdown ATS connectivity suggestion client.
207 *
208 * @param ch handle to destroy
209 */
210void
211GNUNET_ATS_connectivity_done (struct GNUNET_ATS_ConnectivityHandle *ch);
212
213
214/**
215 * We would like to establish a new connection with a peer. ATS
216 * should suggest a good address to begin with.
217 *
218 * @param ch handle
219 * @param peer identity of the peer we need an address for
220 * @param strength how urgent is the need for such a suggestion
221 * @return suggestion handle, NULL if request is already pending
222 */
223struct GNUNET_ATS_ConnectivitySuggestHandle *
224GNUNET_ATS_connectivity_suggest (struct GNUNET_ATS_ConnectivityHandle *ch,
225 const struct GNUNET_PeerIdentity *peer,
226 uint32_t strength);
227
228
229/**
230 * We no longer care about being connected to a peer.
231 *
232 * @param sh handle to stop
233 */
234void
235GNUNET_ATS_connectivity_suggest_cancel (struct
236 GNUNET_ATS_ConnectivitySuggestHandle *sh);
237
238
239/* ******************************** Scheduling API ***************************** */
240
241/**
242 * Handle to the ATS subsystem for bandwidth/transport scheduling information.
243 */
244struct GNUNET_ATS_SchedulingHandle;
245
246/**
247 * Opaque session handle, defined by plugins. Contents not known to ATS.
248 */
249struct GNUNET_ATS_Session;
250
251
252/**
253 * Signature of a function called by ATS with the current bandwidth
254 * and address preferences as determined by ATS. If our connection
255 * to ATS dies and thus all suggestions become invalid, this function
256 * is called ONCE with all arguments (except @a cls) being NULL/0.
257 *
258 * @param cls closure
259 * @param peer for which we suggest an address, NULL if ATS connection died
260 * @param address suggested address (including peer identity of the peer),
261 * may be NULL to signal disconnect from peer
262 * @param session session to use, NULL to establish a new outgoing session
263 * @param bandwidth_out assigned outbound bandwidth for the connection,
264 * 0 to signal disconnect
265 * @param bandwidth_in assigned inbound bandwidth for the connection,
266 * 0 to signal disconnect
267 */
268typedef void
269(*GNUNET_ATS_AddressSuggestionCallback) (void *cls,
270 const struct GNUNET_PeerIdentity *peer,
271 const struct
272 GNUNET_HELLO_Address *address,
273 struct GNUNET_ATS_Session *session,
274 struct GNUNET_BANDWIDTH_Value32NBO
275 bandwidth_out,
276 struct GNUNET_BANDWIDTH_Value32NBO
277 bandwidth_in);
278
279
280/**
281 * Initialize the ATS scheduling subsystem.
282 *
283 * @param cfg configuration to use
284 * @param suggest_cb notification to call whenever the suggestation changed
285 * @param suggest_cb_cls closure for @a suggest_cb
286 * @return ats context
287 */
288struct GNUNET_ATS_SchedulingHandle *
289GNUNET_ATS_scheduling_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
290 GNUNET_ATS_AddressSuggestionCallback suggest_cb,
291 void *suggest_cb_cls);
292
293
294/**
295 * Client is done with ATS scheduling, release resources.
296 *
297 * @param sh handle to release
298 */
299void
300GNUNET_ATS_scheduling_done (struct GNUNET_ATS_SchedulingHandle *sh);
301
302
303/**
304 * Handle used within ATS to track an address.
305 */
306struct GNUNET_ATS_AddressRecord;
307
308
309/**
310 * We have a new address ATS should know. Addresses have to be added with this
311 * function before they can be: updated, set in use and destroyed
312 *
313 * @param sh handle
314 * @param address the address
315 * @param session session handle (if available, e.g for incoming connections)
316 * @param prop performance data for the address
317 * @return handle to the address representation inside ATS, NULL
318 * on error (i.e. ATS knows this exact address already, or
319 * address is invalid)
320 */
321struct GNUNET_ATS_AddressRecord *
322GNUNET_ATS_address_add (struct GNUNET_ATS_SchedulingHandle *sh,
323 const struct GNUNET_HELLO_Address *address,
324 struct GNUNET_ATS_Session *session,
325 const struct GNUNET_ATS_Properties *prop);
326
327
328/**
329 * An address was used to initiate a session.
330 *
331 * @param ar address record to update information for
332 * @param session session handle
333 */
334void
335GNUNET_ATS_address_add_session (struct GNUNET_ATS_AddressRecord *ar,
336 struct GNUNET_ATS_Session *session);
337
338
339/**
340 * A @a session was destroyed, disassociate it from the given address
341 * record. If this was an incoming address, destroys the address as
342 * well.
343 *
344 * @param ar address record to update information for
345 * @param session session handle
346 * @return #GNUNET_YES if the @a ar was destroyed because
347 * it was an incoming address,
348 * #GNUNET_NO if the @a ar was kept because we can
349 * use it still to establish a new session
350 */
351int
352GNUNET_ATS_address_del_session (struct GNUNET_ATS_AddressRecord *ar,
353 struct GNUNET_ATS_Session *session);
354
355
356/**
357 * We have updated performance statistics for a given address. Note
358 * that this function can be called for addresses that are currently
359 * in use as well as addresses that are valid but not actively in use.
360 * Furthermore, the peer may not even be connected to us right now (@a
361 * session value of NULL used to signal disconnect, or somehow we
362 * otherwise got updated on @a ats information). Based on the
363 * information provided, ATS may update bandwidth assignments and
364 * suggest to switch addresses.
365 *
366 * @param ar address record to update information for
367 * @param prop performance data for the address
368 */
369void
370GNUNET_ATS_address_update (struct GNUNET_ATS_AddressRecord *ar,
371 const struct GNUNET_ATS_Properties *prop);
372
373
374/**
375 * An address got destroyed, stop using it as a valid address.
376 *
377 * @param ar address record to destroy, its validation has
378 * expired and ATS may no longer use it
379 */
380void
381GNUNET_ATS_address_destroy (struct GNUNET_ATS_AddressRecord *ar);
382
383
384/* ******************************** Performance API ***************************** */
385
386/**
387 * ATS Handle to obtain and/or modify performance information.
388 */
389struct GNUNET_ATS_PerformanceHandle;
390
391/**
392 * Signature of a function that is called with QoS information about an address.
393 *
394 * @param cls closure
395 * @param address the address, NULL if ATS service was disconnected or
396 * when the iteration is completed in the case of
397 * #GNUNET_ATS_performance_list_addresses()
398 * @param address_active #GNUNET_YES if this address is actively used
399 * to maintain a connection to a peer;
400 * #GNUNET_NO if the address is not actively used;
401 * #GNUNET_SYSERR if this address is no longer available for ATS
402 * @param bandwidth_out assigned outbound bandwidth for the connection
403 * @param bandwidth_in assigned inbound bandwidth for the connection
404 * @param prop performance data for the address
405 */
406typedef void
407(*GNUNET_ATS_AddressInformationCallback) (void *cls,
408 const struct
409 GNUNET_HELLO_Address *address,
410 int address_active,
411 struct GNUNET_BANDWIDTH_Value32NBO
412 bandwidth_out,
413 struct GNUNET_BANDWIDTH_Value32NBO
414 bandwidth_in,
415 const struct
416 GNUNET_ATS_Properties *prop);
417
418
419/**
420 * Handle for an address listing operation
421 */
422struct GNUNET_ATS_AddressListHandle;
423
424
425/**
426 * Get handle to access performance API of the ATS subsystem.
427 *
428 * @param cfg configuration to use
429 * @param addr_info_cb callback called when performance characteristics for
430 * an address change
431 * @param addr_info_cb_cls closure for @a addr_info_cb
432 * @return ats performance context
433 */
434struct GNUNET_ATS_PerformanceHandle *
435GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
436 GNUNET_ATS_AddressInformationCallback addr_info_cb,
437 void *addr_info_cb_cls);
438
439
440/**
441 * Get information about addresses known to the ATS subsystem.
442 *
443 * @param ph the performance handle to use
444 * @param peer peer idm can be NULL for all peers
445 * @param all #GNUNET_YES to get information about all addresses or #GNUNET_NO to
446 * get only address currently used
447 * @param infocb callback to call with the addresses,
448 * will callback with address == NULL when done
449 * @param infocb_cls closure for @a infocb
450 * @return handle to abort the operation
451 */
452struct GNUNET_ATS_AddressListHandle *
453GNUNET_ATS_performance_list_addresses (struct GNUNET_ATS_PerformanceHandle *ph,
454 const struct GNUNET_PeerIdentity *peer,
455 int all,
456 GNUNET_ATS_AddressInformationCallback
457 infocb,
458 void *infocb_cls);
459
460
461/**
462 * Cancel a pending address listing operation
463 *
464 * @param alh the `struct GNUNET_ATS_AddressListHandle` handle to cancel
465 */
466void
467GNUNET_ATS_performance_list_addresses_cancel (struct
468 GNUNET_ATS_AddressListHandle *alh);
469
470
471/**
472 * Client is done using the ATS performance subsystem, release resources.
473 *
474 * @param ph handle
475 */
476void
477GNUNET_ATS_performance_done (struct GNUNET_ATS_PerformanceHandle *ph);
478
479
480/**
481 * Function called with reservation result.
482 *
483 * @param cls closure
484 * @param peer identifies the peer
485 * @param amount set to the amount that was actually reserved or unreserved;
486 * either the full requested amount or zero (no partial reservations)
487 * @param res_delay if the reservation could not be satisfied (amount was 0), how
488 * long should the client wait until re-trying?
489 */
490typedef void
491(*GNUNET_ATS_ReservationCallback) (void *cls,
492 const struct GNUNET_PeerIdentity *peer,
493 int32_t amount,
494 struct GNUNET_TIME_Relative res_delay);
495
496
497/**
498 * Context that can be used to cancel a peer information request.
499 */
500struct GNUNET_ATS_ReservationContext;
501
502
503/**
504 * Reserve inbound bandwidth from the given peer. ATS will look at
505 * the current amount of traffic we receive from the peer and ensure
506 * that the peer could add 'amount' of data to its stream.
507 *
508 * @param ph performance handle
509 * @param peer identifies the peer
510 * @param amount reserve N bytes for receiving, negative
511 * amounts can be used to undo a (recent) reservation;
512 * @param rcb function to call with the resulting reservation information
513 * @param rcb_cls closure for @a rcb
514 * @return NULL on error
515 * @deprecated will be replaced soon
516 */
517struct GNUNET_ATS_ReservationContext *
518GNUNET_ATS_reserve_bandwidth (struct GNUNET_ATS_PerformanceHandle *ph,
519 const struct GNUNET_PeerIdentity *peer,
520 int32_t amount,
521 GNUNET_ATS_ReservationCallback rcb,
522 void *rcb_cls);
523
524
525/**
526 * Cancel request for reserving bandwidth.
527 *
528 * @param rc context returned by the original #GNUNET_ATS_reserve_bandwidth() call
529 */
530void
531GNUNET_ATS_reserve_bandwidth_cancel (struct GNUNET_ATS_ReservationContext *rc);
532
533
534/**
535 * ATS preference types as array initializer
536 */
537#define GNUNET_ATS_PreferenceType { GNUNET_ATS_PREFERENCE_BANDWIDTH, \
538 GNUNET_ATS_PREFERENCE_LATENCY, \
539 GNUNET_ATS_PREFERENCE_END }
540
541/**
542 * ATS preference types as string array initializer
543 */
544#define GNUNET_ATS_PreferenceTypeString { "BANDWIDTH", "LATENCY", "END" }
545
546/**
547 * Enum defining all known preference categories.
548 */
549enum GNUNET_ATS_PreferenceKind
550{
551 /**
552 * Change the peer's bandwidth value (value per byte of bandwidth in
553 * the goal function) to the given amount. The argument is followed
554 * by a double value giving the desired value (can be negative).
555 * Preference changes are forgotten if peers disconnect.
556 */
557 GNUNET_ATS_PREFERENCE_BANDWIDTH = 0,
558
559 /**
560 * Change the peer's latency value to the given amount. The
561 * argument is followed by a double value giving the desired value
562 * (can be negative). The absolute score in the goal function is
563 * the inverse of the latency in microseconds (minimum: 1
564 * microsecond) multiplied by the latency preferences.
565 */
566 GNUNET_ATS_PREFERENCE_LATENCY = 1,
567
568 /**
569 * End of preference list.
570 */
571 GNUNET_ATS_PREFERENCE_END = 2
572};
573
574
575/**
576 * Convert an `enum GNUNET_ATS_PreferenceType` to a string
577 *
578 * @param type the preference type
579 * @return a string or NULL if invalid
580 */
581const char *
582GNUNET_ATS_print_preference_type (enum GNUNET_ATS_PreferenceKind type);
583
584
585/**
586 * Change preferences for the given peer. Preference changes are
587 * forgotten if peers disconnect.
588 *
589 * @param ph performance handle
590 * @param peer identifies the peer
591 * @param ... #GNUNET_ATS_PREFERENCE_END-terminated specification of the
592 * desired changes
593 */
594void
595GNUNET_ATS_performance_change_preference (struct
596 GNUNET_ATS_PerformanceHandle *ph,
597 const struct
598 GNUNET_PeerIdentity *peer,
599 ...);
600
601
602/**
603 * Application feedback on how good preference requirements are fulfilled
604 * for the preferences included in the given time scope [now - scope .. now]
605 *
606 * An application notifies ATS if (and only if) it has feedback information
607 * for specific properties. This values are valid until the feedback scores are
608 * updated by the application.
609 *
610 * If the application has no feedback for this preference kind the application
611 * will not explicitly call for this property and will not include it in this
612 * function call.
613 *
614 * @param ph performance handle
615 * @param scope the time interval this valid for: [now - scope .. now]
616 * @param peer identifies the peer
617 * @param ... #GNUNET_ATS_PREFERENCE_END-terminated specification of the desired changes
618 */
619void
620GNUNET_ATS_performance_give_feedback (struct GNUNET_ATS_PerformanceHandle *ph,
621 const struct GNUNET_PeerIdentity *peer,
622 const struct GNUNET_TIME_Relative scope,
623 ...);
624
625#endif
626
627/** @} */ /* end of group */
628
629/** @} */ /* end of Backbone addition */
630
631/* 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 b6c7b15ae..000000000
--- a/src/include/gnunet_ats_transport_service.h
+++ /dev/null
@@ -1,241 +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
38#include "gnunet_constants.h"
39#include "gnunet_util_lib.h"
40#include "gnunet_nt_lib.h"
41#include "gnunet_transport_communication_service.h"
42
43
44/**
45 * ATS performance characteristics for a session.
46 */
47struct GNUNET_ATS_Properties
48{
49 /**
50 * Delay. Time between when the time packet is sent and the packet
51 * arrives. FOREVER if we did not (successfully) measure yet.
52 */
53 struct GNUNET_TIME_Relative delay;
54
55 /**
56 * Confirmed successful payload on this connection from this peer to
57 * the other peer.
58 *
59 * Unit: [bytes/second]
60 */
61 uint32_t goodput_out;
62
63 /**
64 * Confirmed useful payload on this connection to this peer from
65 * the other peer.
66 *
67 * Unit: [bytes/second]
68 */
69 uint32_t goodput_in;
70
71 /**
72 * Actual traffic on this connection from this peer to the other peer.
73 * Includes transport overhead.
74 *
75 * Unit: [bytes/second]
76 */
77 uint32_t utilization_out;
78
79 /**
80 * Actual traffic on this connection from the other peer to this peer.
81 * Includes transport overhead.
82 *
83 * Unit: [bytes/second]
84 */
85 uint32_t utilization_in;
86
87 /**
88 * Distance on network layer (required for distance-vector routing)
89 * in hops. Zero for direct connections (e.g. plain TCP/UDP).
90 */
91 uint32_t distance;
92
93 /**
94 * MTU of the network layer, UINT32_MAX for no MTU (stream).
95 *
96 * Unit: [bytes]
97 */
98 uint32_t mtu;
99
100 /**
101 * Which network scope does the respective address belong to?
102 */
103 enum GNUNET_NetworkType nt;
104
105 /**
106 * What characteristics does this communicator have?
107 */
108 enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc;
109};
110
111
112/* ******************************** Transport API ***************************** */
113
114/**
115 * Handle to the ATS subsystem for bandwidth/transport transport information.
116 */
117struct GNUNET_ATS_TransportHandle;
118
119/**
120 * Opaque session handle, to be defined by transport. Contents not known to ATS.
121 */
122struct GNUNET_ATS_Session;
123
124
125/**
126 * Signature of a function called by ATS with the current bandwidth
127 * allocation to be used as determined by ATS.
128 *
129 * @param cls closure
130 * @param session session this is about
131 * @param bandwidth_out assigned outbound bandwidth for the connection,
132 * 0 to signal disconnect
133 * @param bandwidth_in assigned inbound bandwidth for the connection,
134 * 0 to signal disconnect
135 */
136typedef void
137(*GNUNET_ATS_AllocationCallback) (void *cls,
138 struct GNUNET_ATS_Session *session,
139 struct GNUNET_BANDWIDTH_Value32NBO
140 bandwidth_out,
141 struct GNUNET_BANDWIDTH_Value32NBO
142 bandwidth_in);
143
144
145/**
146 * Signature of a function called by ATS suggesting transport to
147 * try connecting with a particular address.
148 *
149 * @param cls closure
150 * @param pid target peer
151 * @param address the address to try
152 */
153typedef void
154(*GNUNET_ATS_SuggestionCallback) (void *cls,
155 const struct GNUNET_PeerIdentity *pid,
156 const char *address);
157
158
159/**
160 * Initialize the ATS transport subsystem.
161 *
162 * @param cfg configuration to use
163 * @param alloc_cb notification to call whenever the allocation changed
164 * @param alloc_cb_cls closure for @a alloc_cb
165 * @param suggest_cb notification to call whenever the suggestation is made
166 * @param suggest_cb_cls closure for @a suggest_cb
167 * @return ats context
168 */
169struct GNUNET_ATS_TransportHandle *
170GNUNET_ATS_transport_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
171 GNUNET_ATS_AllocationCallback alloc_cb,
172 void *alloc_cb_cls,
173 GNUNET_ATS_SuggestionCallback suggest_cb,
174 void *suggest_cb_cls);
175
176
177/**
178 * Client is done with ATS transport, release resources.
179 *
180 * @param ath handle to release
181 */
182void
183GNUNET_ATS_transport_done (struct GNUNET_ATS_TransportHandle *ath);
184
185
186/**
187 * Handle used within ATS to track an session.
188 */
189struct GNUNET_ATS_SessionRecord;
190
191
192/**
193 * We have a new session ATS should know. Sessiones have to be added with this
194 * function before they can be: updated, set in use and destroyed
195 *
196 * @param ath handle
197 * @param pid peer we connected to
198 * @param address the address (human readable version),
199 * @param session transport-internal handle for the session/queue, NULL if
200 * the session is inbound-only
201 * @param prop performance data for the session
202 * @return handle to the session representation inside ATS, NULL
203 * on error (i.e. ATS knows this exact session already, or
204 * session is invalid)
205 */
206struct GNUNET_ATS_SessionRecord *
207GNUNET_ATS_session_add (struct GNUNET_ATS_TransportHandle *ath,
208 const struct GNUNET_PeerIdentity *pid,
209 const char *address,
210 struct GNUNET_ATS_Session *session,
211 const struct GNUNET_ATS_Properties *prop);
212
213
214/**
215 * We have updated performance statistics for a given session. Based
216 * on the information provided, ATS may update bandwidth assignments.
217 *
218 * @param ar session record to update information for
219 * @param prop performance data for the session
220 */
221void
222GNUNET_ATS_session_update (struct GNUNET_ATS_SessionRecord *ar,
223 const struct GNUNET_ATS_Properties *prop);
224
225
226/**
227 * A session was destroyed, ATS should now schedule and
228 * allocate under the assumption that this @a ar is no
229 * longer in use.
230 *
231 * @param ar session record to drop
232 */
233void
234GNUNET_ATS_session_del (struct GNUNET_ATS_SessionRecord *ar);
235
236
237#endif
238
239/** @} */ /* end of group */
240
241/* 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 7c854aab5..00a7d6c5d 100644
--- a/src/include/gnunet_bandwidth_lib.h
+++ b/src/include/gnunet_bandwidth_lib.h
@@ -18,10 +18,6 @@
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 * @addtogroup libgnunetutil 22 * @addtogroup libgnunetutil
27 * Multi-function utilities library for GNUnet programs 23 * Multi-function utilities library for GNUnet programs
diff --git a/src/include/gnunet_bio_lib.h b/src/include/gnunet_bio_lib.h
index 48a1a512d..73550db7e 100644
--- a/src/include/gnunet_bio_lib.h
+++ b/src/include/gnunet_bio_lib.h
@@ -33,6 +33,7 @@
33 * @{ 33 * @{
34 */ 34 */
35 35
36#include "gnunet_common.h"
36#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) 37#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__)
37#error "Only <gnunet_util_lib.h> can be included directly." 38#error "Only <gnunet_util_lib.h> can be included directly."
38#endif 39#endif
@@ -88,7 +89,7 @@ GNUNET_BIO_read_open_buffer (void *buffer, size_t size);
88 * @param emsg set to the error message 89 * @param emsg set to the error message
89 * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise 90 * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
90 */ 91 */
91int 92enum GNUNET_GenericReturnValue
92GNUNET_BIO_read_close (struct GNUNET_BIO_ReadHandle *h, char **emsg); 93GNUNET_BIO_read_close (struct GNUNET_BIO_ReadHandle *h, char **emsg);
93 94
94/** 95/**
@@ -110,7 +111,7 @@ GNUNET_BIO_read_set_error (struct GNUNET_BIO_ReadHandle *h, const char* emsg);
110 * @param len the number of bytes to read 111 * @param len the number of bytes to read
111 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure 112 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
112 */ 113 */
113int 114enum GNUNET_GenericReturnValue
114GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h, 115GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h,
115 const char *what, 116 const char *what,
116 void *result, 117 void *result,
@@ -127,7 +128,7 @@ GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h,
127 * @param max_length maximum allowed length for the string 128 * @param max_length maximum allowed length for the string
128 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure 129 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
129 */ 130 */
130int 131enum GNUNET_GenericReturnValue
131GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h, 132GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h,
132 const char *what, 133 const char *what,
133 char **result, 134 char **result,
@@ -142,7 +143,7 @@ GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h,
142 * @param what describes what is being read (for error message creation) 143 * @param what describes what is being read (for error message creation)
143 * @param f address of float to read 144 * @param f address of float to read
144 */ 145 */
145int 146enum GNUNET_GenericReturnValue
146GNUNET_BIO_read_float (struct GNUNET_BIO_ReadHandle *h, 147GNUNET_BIO_read_float (struct GNUNET_BIO_ReadHandle *h,
147 const char *what, 148 const char *what,
148 float *f); 149 float *f);
@@ -155,7 +156,7 @@ GNUNET_BIO_read_float (struct GNUNET_BIO_ReadHandle *h,
155 * @param what describes what is being read (for error message creation) 156 * @param what describes what is being read (for error message creation)
156 * @param f address of double to read 157 * @param f address of double to read
157 */ 158 */
158int 159enum GNUNET_GenericReturnValue
159GNUNET_BIO_read_double (struct GNUNET_BIO_ReadHandle *h, 160GNUNET_BIO_read_double (struct GNUNET_BIO_ReadHandle *h,
160 const char *what, 161 const char *what,
161 double *f); 162 double *f);
@@ -169,7 +170,7 @@ GNUNET_BIO_read_double (struct GNUNET_BIO_ReadHandle *h,
169 * @param i where to store the data 170 * @param i where to store the data
170 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 171 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
171 */ 172 */
172int 173enum GNUNET_GenericReturnValue
173GNUNET_BIO_read_int32 (struct GNUNET_BIO_ReadHandle *h, 174GNUNET_BIO_read_int32 (struct GNUNET_BIO_ReadHandle *h,
174 const char *what, 175 const char *what,
175 int32_t *i); 176 int32_t *i);
@@ -183,7 +184,7 @@ GNUNET_BIO_read_int32 (struct GNUNET_BIO_ReadHandle *h,
183 * @param i where to store the data 184 * @param i where to store the data
184 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 185 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
185 */ 186 */
186int 187enum GNUNET_GenericReturnValue
187GNUNET_BIO_read_int64 (struct GNUNET_BIO_ReadHandle *h, 188GNUNET_BIO_read_int64 (struct GNUNET_BIO_ReadHandle *h,
188 const char *what, 189 const char *what,
189 int64_t *i); 190 int64_t *i);
@@ -224,7 +225,7 @@ GNUNET_BIO_write_open_buffer (void);
224 * @return #GNUNET_OK upon success. Upon failure #GNUNET_SYSERR is returned 225 * @return #GNUNET_OK upon success. Upon failure #GNUNET_SYSERR is returned
225 * and the file is closed 226 * and the file is closed
226 */ 227 */
227int 228enum GNUNET_GenericReturnValue
228GNUNET_BIO_flush (struct GNUNET_BIO_WriteHandle *h); 229GNUNET_BIO_flush (struct GNUNET_BIO_WriteHandle *h);
229 230
230 231
@@ -240,7 +241,7 @@ GNUNET_BIO_flush (struct GNUNET_BIO_WriteHandle *h);
240 * @param size where to store the size of @e contents 241 * @param size where to store the size of @e contents
241 * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise 242 * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
242 */ 243 */
243int 244enum GNUNET_GenericReturnValue
244GNUNET_BIO_get_buffer_contents (struct GNUNET_BIO_WriteHandle *h, 245GNUNET_BIO_get_buffer_contents (struct GNUNET_BIO_WriteHandle *h,
245 char **emsg, 246 char **emsg,
246 void **contents, 247 void **contents,
@@ -256,7 +257,7 @@ GNUNET_BIO_get_buffer_contents (struct GNUNET_BIO_WriteHandle *h,
256 * 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
257 * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise 258 * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
258 */ 259 */
259int 260enum GNUNET_GenericReturnValue
260GNUNET_BIO_write_close (struct GNUNET_BIO_WriteHandle *h, char **emsg); 261GNUNET_BIO_write_close (struct GNUNET_BIO_WriteHandle *h, char **emsg);
261 262
262 263
@@ -269,7 +270,7 @@ GNUNET_BIO_write_close (struct GNUNET_BIO_WriteHandle *h, char **emsg);
269 * @param n number of bytes to write 270 * @param n number of bytes to write
270 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 271 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
271 */ 272 */
272int 273enum GNUNET_GenericReturnValue
273GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h, 274GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h,
274 const char *what, 275 const char *what,
275 const void *buffer, 276 const void *buffer,
@@ -284,7 +285,7 @@ GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h,
284 * @param s string to write (can be NULL) 285 * @param s string to write (can be NULL)
285 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 286 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
286 */ 287 */
287int 288enum GNUNET_GenericReturnValue
288GNUNET_BIO_write_string (struct GNUNET_BIO_WriteHandle *h, 289GNUNET_BIO_write_string (struct GNUNET_BIO_WriteHandle *h,
289 const char *what, 290 const char *what,
290 const char *s); 291 const char *s);
@@ -298,7 +299,7 @@ GNUNET_BIO_write_string (struct GNUNET_BIO_WriteHandle *h,
298 * @param what what is being written (for error message creation) 299 * @param what what is being written (for error message creation)
299 * @param f float to write (must be a variable) 300 * @param f float to write (must be a variable)
300 */ 301 */
301int 302enum GNUNET_GenericReturnValue
302GNUNET_BIO_write_float (struct GNUNET_BIO_WriteHandle *h, 303GNUNET_BIO_write_float (struct GNUNET_BIO_WriteHandle *h,
303 const char *what, 304 const char *what,
304 float f); 305 float f);
@@ -310,7 +311,7 @@ GNUNET_BIO_write_float (struct GNUNET_BIO_WriteHandle *h,
310 * @param what what is being written (for error message creation) 311 * @param what what is being written (for error message creation)
311 * @param f double to write (must be a variable) 312 * @param f double to write (must be a variable)
312 */ 313 */
313int 314enum GNUNET_GenericReturnValue
314GNUNET_BIO_write_double (struct GNUNET_BIO_WriteHandle *h, 315GNUNET_BIO_write_double (struct GNUNET_BIO_WriteHandle *h,
315 const char *what, 316 const char *what,
316 double f); 317 double f);
@@ -324,7 +325,7 @@ GNUNET_BIO_write_double (struct GNUNET_BIO_WriteHandle *h,
324 * @param i 32-bit integer to write 325 * @param i 32-bit integer to write
325 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 326 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
326 */ 327 */
327int 328enum GNUNET_GenericReturnValue
328GNUNET_BIO_write_int32 (struct GNUNET_BIO_WriteHandle *h, 329GNUNET_BIO_write_int32 (struct GNUNET_BIO_WriteHandle *h,
329 const char *what, 330 const char *what,
330 int32_t i); 331 int32_t i);
@@ -338,7 +339,7 @@ GNUNET_BIO_write_int32 (struct GNUNET_BIO_WriteHandle *h,
338 * @param i 64-bit integer to write 339 * @param i 64-bit integer to write
339 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 340 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
340 */ 341 */
341int 342enum GNUNET_GenericReturnValue
342GNUNET_BIO_write_int64 (struct GNUNET_BIO_WriteHandle *h, 343GNUNET_BIO_write_int64 (struct GNUNET_BIO_WriteHandle *h,
343 const char *what, 344 const char *what,
344 int64_t i); 345 int64_t i);
@@ -489,7 +490,7 @@ GNUNET_BIO_read_spec_double (const char *what, double *f);
489 * the last element must be #GNUNET_BIO_read_spec_end 490 * the last element must be #GNUNET_BIO_read_spec_end
490 * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise 491 * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
491 */ 492 */
492int 493enum GNUNET_GenericReturnValue
493GNUNET_BIO_read_spec_commit (struct GNUNET_BIO_ReadHandle *h, 494GNUNET_BIO_read_spec_commit (struct GNUNET_BIO_ReadHandle *h,
494 struct GNUNET_BIO_ReadSpec *rs); 495 struct GNUNET_BIO_ReadSpec *rs);
495 496
@@ -635,7 +636,7 @@ GNUNET_BIO_write_spec_double (const char *what, double *f);
635 * the last element must be #GNUNET_BIO_write_spec_end 636 * the last element must be #GNUNET_BIO_write_spec_end
636 * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise 637 * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
637 */ 638 */
638int 639enum GNUNET_GenericReturnValue
639GNUNET_BIO_write_spec_commit (struct GNUNET_BIO_WriteHandle *h, 640GNUNET_BIO_write_spec_commit (struct GNUNET_BIO_WriteHandle *h,
640 struct GNUNET_BIO_WriteSpec *ws); 641 struct GNUNET_BIO_WriteSpec *ws);
641 642
diff --git a/src/include/gnunet_cadet_service.h b/src/include/gnunet_cadet_service.h
index acc7bb330..ab53d2bd8 100644
--- a/src/include/gnunet_cadet_service.h
+++ b/src/include/gnunet_cadet_service.h
@@ -47,7 +47,6 @@ extern "C" {
47 47
48 48
49#include "gnunet_util_lib.h" 49#include "gnunet_util_lib.h"
50#include "gnunet_transport_service.h"
51 50
52/** 51/**
53 * Version number of GNUnet-cadet API. 52 * Version number of GNUnet-cadet API.
@@ -636,4 +635,3 @@ GNUNET_CADET_list_tunnels_cancel (struct GNUNET_CADET_ListTunnels *lt);
636/** @} */ /* end of group addition */ 635/** @} */ /* end of group addition */
637 636
638/* end of gnunet_cadet_service.h */ 637/* end of gnunet_cadet_service.h */
639
diff --git a/src/include/gnunet_container_lib.h b/src/include/gnunet_container_lib.h
index ce1b8f296..df38317ca 100644
--- a/src/include/gnunet_container_lib.h
+++ b/src/include/gnunet_container_lib.h
@@ -52,6 +52,7 @@
52 * @} 52 * @}
53 */ 53 */
54 54
55#include "gnunet_common.h"
55#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) 56#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__)
56#error "Only <gnunet_util_lib.h> can be included directly." 57#error "Only <gnunet_util_lib.h> can be included directly."
57#endif 58#endif
@@ -177,7 +178,7 @@ GNUNET_CONTAINER_bloomfilter_init (const char *data,
177 * @param size the size of the given @a data array 178 * @param size the size of the given @a data array
178 * @return #GNUNET_SYSERR if the data array of the wrong size 179 * @return #GNUNET_SYSERR if the data array of the wrong size
179 */ 180 */
180int 181enum GNUNET_GenericReturnValue
181GNUNET_CONTAINER_bloomfilter_get_raw_data ( 182GNUNET_CONTAINER_bloomfilter_get_raw_data (
182 const struct GNUNET_CONTAINER_BloomFilter *bf, 183 const struct GNUNET_CONTAINER_BloomFilter *bf,
183 char *data, 184 char *data,
@@ -291,7 +292,7 @@ GNUNET_CONTAINER_bloomfilter_clear (struct GNUNET_CONTAINER_BloomFilter *bf);
291 * @param size size of @a data 292 * @param size size of @a data
292 * @return #GNUNET_OK on success 293 * @return #GNUNET_OK on success
293 */ 294 */
294int 295enum GNUNET_GenericReturnValue
295GNUNET_CONTAINER_bloomfilter_or (struct GNUNET_CONTAINER_BloomFilter *bf, 296GNUNET_CONTAINER_bloomfilter_or (struct GNUNET_CONTAINER_BloomFilter *bf,
296 const char *data, 297 const char *data,
297 size_t size); 298 size_t size);
@@ -307,7 +308,7 @@ GNUNET_CONTAINER_bloomfilter_or (struct GNUNET_CONTAINER_BloomFilter *bf,
307 * @param to_or the bloomfilter to or-in 308 * @param to_or the bloomfilter to or-in
308 * @return #GNUNET_OK on success 309 * @return #GNUNET_OK on success
309 */ 310 */
310int 311enum GNUNET_GenericReturnValue
311GNUNET_CONTAINER_bloomfilter_or2 ( 312GNUNET_CONTAINER_bloomfilter_or2 (
312 struct GNUNET_CONTAINER_BloomFilter *bf, 313 struct GNUNET_CONTAINER_BloomFilter *bf,
313 const struct GNUNET_CONTAINER_BloomFilter *to_or); 314 const struct GNUNET_CONTAINER_BloomFilter *to_or);
@@ -577,7 +578,7 @@ GNUNET_CONTAINER_multihashmap_size (
577 * @return the number of key value pairs processed, 578 * @return the number of key value pairs processed,
578 * #GNUNET_SYSERR if it aborted iteration 579 * #GNUNET_SYSERR if it aborted iteration
579 */ 580 */
580int 581enum GNUNET_GenericReturnValue
581GNUNET_CONTAINER_multihashmap_iterate ( 582GNUNET_CONTAINER_multihashmap_iterate (
582 struct GNUNET_CONTAINER_MultiHashMap *map, 583 struct GNUNET_CONTAINER_MultiHashMap *map,
583 GNUNET_CONTAINER_MultiHashMapIteratorCallback it, 584 GNUNET_CONTAINER_MultiHashMapIteratorCallback it,
@@ -646,7 +647,7 @@ GNUNET_CONTAINER_multihashmap_iterator_destroy (
646 * @return the number of key value pairs processed, 647 * @return the number of key value pairs processed,
647 * #GNUNET_SYSERR if it aborted iteration 648 * #GNUNET_SYSERR if it aborted iteration
648 */ 649 */
649int 650enum GNUNET_GenericReturnValue
650GNUNET_CONTAINER_multihashmap_get_multiple ( 651GNUNET_CONTAINER_multihashmap_get_multiple (
651 struct GNUNET_CONTAINER_MultiHashMap *map, 652 struct GNUNET_CONTAINER_MultiHashMap *map,
652 const struct GNUNET_HashCode *key, 653 const struct GNUNET_HashCode *key,
@@ -1423,7 +1424,7 @@ GNUNET_CONTAINER_multiuuidmap_size (
1423 * @return the number of key value pairs processed, 1424 * @return the number of key value pairs processed,
1424 * #GNUNET_SYSERR if it aborted iteration 1425 * #GNUNET_SYSERR if it aborted iteration
1425 */ 1426 */
1426int 1427enum GNUNET_GenericReturnValue
1427GNUNET_CONTAINER_multiuuidmap_iterate ( 1428GNUNET_CONTAINER_multiuuidmap_iterate (
1428 struct GNUNET_CONTAINER_MultiUuidmap *map, 1429 struct GNUNET_CONTAINER_MultiUuidmap *map,
1429 GNUNET_CONTAINER_MultiUuidmapIteratorCallback it, 1430 GNUNET_CONTAINER_MultiUuidmapIteratorCallback it,
diff --git a/src/include/gnunet_conversation_service.h b/src/include/gnunet_conversation_service.h
index 7d54914d1..7857a49cf 100644
--- a/src/include/gnunet_conversation_service.h
+++ b/src/include/gnunet_conversation_service.h
@@ -151,7 +151,7 @@ typedef void
151 struct GNUNET_CONVERSATION_Caller * 151 struct GNUNET_CONVERSATION_Caller *
152 caller, 152 caller,
153 const struct 153 const struct
154 GNUNET_IDENTITY_PublicKey *caller_id); 154 GNUNET_CRYPTO_PublicKey *caller_id);
155 155
156 156
157/** 157/**
diff --git a/src/include/gnunet_core_service.h b/src/include/gnunet_core_service.h
index 4e188df87..c3069be81 100644
--- a/src/include/gnunet_core_service.h
+++ b/src/include/gnunet_core_service.h
@@ -45,7 +45,6 @@ extern "C" {
45 45
46 46
47#include "gnunet_util_lib.h" 47#include "gnunet_util_lib.h"
48#include "gnunet_transport_service.h"
49 48
50/** 49/**
51 * Version number of GNUnet-core API. 50 * Version number of GNUnet-core API.
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h
index 4fb5d8874..f508d02f6 100644
--- a/src/include/gnunet_crypto_lib.h
+++ b/src/include/gnunet_crypto_lib.h
@@ -348,6 +348,105 @@ struct GNUNET_CRYPTO_Edx25519Signature
348 unsigned char s[256 / 8]; 348 unsigned char s[256 / 8];
349}; 349};
350 350
351/**
352 * Key type for the generic public key union
353 */
354enum GNUNET_CRYPTO_KeyType
355{
356 /**
357 * The identity type. The value is the same as the
358 * PKEY record type.
359 */
360 GNUNET_PUBLIC_KEY_TYPE_ECDSA = 65536,
361
362 /**
363 * EDDSA identity. The value is the same as the EDKEY
364 * record type.
365 */
366 GNUNET_PUBLIC_KEY_TYPE_EDDSA = 65556
367};
368
369/**
370 * A private key for an identity as per LSD0001.
371 * Note that these types are NOT packed and MUST NOT be used in RPC
372 * messages. Use the respective serialization functions.
373 */
374struct GNUNET_CRYPTO_PrivateKey
375{
376 /**
377 * Type of public key.
378 * Defined by the GNS zone type value.
379 * In NBO.
380 */
381 uint32_t type;
382
383 union
384 {
385 /**
386 * An ECDSA identity key.
387 */
388 struct GNUNET_CRYPTO_EcdsaPrivateKey ecdsa_key;
389
390 /**
391 * AN EdDSA identtiy key
392 */
393 struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_key;
394 };
395};
396
397
398/**
399 * An identity key as per LSD0001.
400 */
401struct GNUNET_CRYPTO_PublicKey
402{
403 /**
404 * Type of public key.
405 * Defined by the GNS zone type value.
406 * In NBO.
407 */
408 uint32_t type;
409
410 union
411 {
412 /**
413 * An ECDSA identity key.
414 */
415 struct GNUNET_CRYPTO_EcdsaPublicKey ecdsa_key;
416
417 /**
418 * AN EdDSA identtiy key
419 */
420 struct GNUNET_CRYPTO_EddsaPublicKey eddsa_key;
421 };
422};
423
424
425/**
426 * An identity signature as per LSD0001.
427 */
428struct GNUNET_CRYPTO_Signature
429{
430 /**
431 * Type of signature.
432 * Defined by the GNS zone type value.
433 * In NBO.
434 */
435 uint32_t type;
436
437 union
438 {
439 /**
440 * An ECDSA signature
441 */
442 struct GNUNET_CRYPTO_EcdsaSignature ecdsa_signature;
443
444 /**
445 * AN EdDSA signature
446 */
447 struct GNUNET_CRYPTO_EddsaSignature eddsa_signature;
448 };
449};
351 450
352/** 451/**
353 * @brief type for session keys 452 * @brief type for session keys
@@ -561,17 +660,33 @@ struct GNUNET_CRYPTO_CsSignature
561 * Schnorr signatures are composed of a scalar s and a curve point 660 * Schnorr signatures are composed of a scalar s and a curve point
562 */ 661 */
563 struct GNUNET_CRYPTO_CsS s_scalar; 662 struct GNUNET_CRYPTO_CsS s_scalar;
663
664 /**
665 * Curve point of the Schnorr signature.
666 */
564 struct GNUNET_CRYPTO_CsRPublic r_point; 667 struct GNUNET_CRYPTO_CsRPublic r_point;
565}; 668};
566 669
567 670
568/** 671/**
569 * Nonce 672 * Nonce for the session, picked by client,
673 * shared with the signer.
570 */ 674 */
571struct GNUNET_CRYPTO_CsNonce 675struct GNUNET_CRYPTO_CsSessionNonce
572{ 676{
573 /*a nonce*/ 677 /*a nonce*/
574 unsigned char nonce[256 / 8]; 678 unsigned char snonce[256 / 8];
679};
680
681
682/**
683 * Nonce for computing blinding factors. Not
684 * shared with the signer.
685 */
686struct GNUNET_CRYPTO_CsBlindingNonce
687{
688 /*a nonce*/
689 unsigned char bnonce[256 / 8];
575}; 690};
576 691
577 692
@@ -846,7 +961,7 @@ GNUNET_CRYPTO_hash_from_string2 (const char *enc,
846 * @return #GNUNET_OK on success, #GNUNET_SYSERR if result has the wrong encoding 961 * @return #GNUNET_OK on success, #GNUNET_SYSERR if result has the wrong encoding
847 */ 962 */
848#define GNUNET_CRYPTO_hash_from_string(enc, result) \ 963#define GNUNET_CRYPTO_hash_from_string(enc, result) \
849 GNUNET_CRYPTO_hash_from_string2 (enc, strlen (enc), result) 964 GNUNET_CRYPTO_hash_from_string2 (enc, strlen (enc), result)
850 965
851 966
852/** 967/**
@@ -2074,15 +2189,15 @@ GNUNET_CRYPTO_eddsa_sign_ (
2074 * @param[out] sig where to write the signature 2189 * @param[out] sig where to write the signature
2075 */ 2190 */
2076#define GNUNET_CRYPTO_eddsa_sign(priv,ps,sig) do { \ 2191#define GNUNET_CRYPTO_eddsa_sign(priv,ps,sig) do { \
2077 /* check size is set correctly */ \ 2192 /* check size is set correctly */ \
2078 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*ps)); \ 2193 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*ps)); \
2079 /* check 'ps' begins with the purpose */ \ 2194 /* check 'ps' begins with the purpose */ \
2080 GNUNET_static_assert (((void*) (ps)) == \ 2195 GNUNET_static_assert (((void*) (ps)) == \
2081 ((void*) &(ps)->purpose)); \ 2196 ((void*) &(ps)->purpose)); \
2082 GNUNET_assert (GNUNET_OK == \ 2197 GNUNET_assert (GNUNET_OK == \
2083 GNUNET_CRYPTO_eddsa_sign_ (priv, \ 2198 GNUNET_CRYPTO_eddsa_sign_ (priv, \
2084 &(ps)->purpose, \ 2199 &(ps)->purpose, \
2085 sig)); \ 2200 sig)); \
2086} while (0) 2201} while (0)
2087 2202
2088 2203
@@ -2136,15 +2251,15 @@ GNUNET_CRYPTO_eddsa_sign_raw (
2136 * @param[out] sig where to write the signature 2251 * @param[out] sig where to write the signature
2137 */ 2252 */
2138#define GNUNET_CRYPTO_ecdsa_sign(priv,ps,sig) do { \ 2253#define GNUNET_CRYPTO_ecdsa_sign(priv,ps,sig) do { \
2139 /* check size is set correctly */ \ 2254 /* check size is set correctly */ \
2140 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \ 2255 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
2141 /* check 'ps' begins with the purpose */ \ 2256 /* check 'ps' begins with the purpose */ \
2142 GNUNET_static_assert (((void*) (ps)) == \ 2257 GNUNET_static_assert (((void*) (ps)) == \
2143 ((void*) &(ps)->purpose)); \ 2258 ((void*) &(ps)->purpose)); \
2144 GNUNET_assert (GNUNET_OK == \ 2259 GNUNET_assert (GNUNET_OK == \
2145 GNUNET_CRYPTO_ecdsa_sign_ (priv, \ 2260 GNUNET_CRYPTO_ecdsa_sign_ (priv, \
2146 &(ps)->purpose, \ 2261 &(ps)->purpose, \
2147 sig)); \ 2262 sig)); \
2148} while (0) 2263} while (0)
2149 2264
2150/** 2265/**
@@ -2183,15 +2298,15 @@ GNUNET_CRYPTO_edx25519_sign_ (
2183 * @param[out] sig where to write the signature 2298 * @param[out] sig where to write the signature
2184 */ 2299 */
2185#define GNUNET_CRYPTO_edx25519_sign(priv,ps,sig) do { \ 2300#define GNUNET_CRYPTO_edx25519_sign(priv,ps,sig) do { \
2186 /* check size is set correctly */ \ 2301 /* check size is set correctly */ \
2187 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \ 2302 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
2188 /* check 'ps' begins with the purpose */ \ 2303 /* check 'ps' begins with the purpose */ \
2189 GNUNET_static_assert (((void*) (ps)) == \ 2304 GNUNET_static_assert (((void*) (ps)) == \
2190 ((void*) &(ps)->purpose)); \ 2305 ((void*) &(ps)->purpose)); \
2191 GNUNET_assert (GNUNET_OK == \ 2306 GNUNET_assert (GNUNET_OK == \
2192 GNUNET_CRYPTO_edx25519_sign_ (priv, \ 2307 GNUNET_CRYPTO_edx25519_sign_ (priv, \
2193 &(ps)->purpose, \ 2308 &(ps)->purpose, \
2194 sig)); \ 2309 sig)); \
2195} while (0) 2310} while (0)
2196 2311
2197 2312
@@ -2739,8 +2854,9 @@ GNUNET_CRYPTO_rsa_private_key_get_public (
2739 * @param hc where to store the hash code 2854 * @param hc where to store the hash code
2740 */ 2855 */
2741void 2856void
2742GNUNET_CRYPTO_rsa_public_key_hash (const struct GNUNET_CRYPTO_RsaPublicKey *key, 2857GNUNET_CRYPTO_rsa_public_key_hash (
2743 struct GNUNET_HashCode *hc); 2858 const struct GNUNET_CRYPTO_RsaPublicKey *key,
2859 struct GNUNET_HashCode *hc);
2744 2860
2745 2861
2746/** 2862/**
@@ -2845,53 +2961,83 @@ GNUNET_CRYPTO_rsa_public_key_cmp (const struct GNUNET_CRYPTO_RsaPublicKey *p1,
2845 2961
2846 2962
2847/** 2963/**
2964 * @brief RSA Parameters to create blinded signature
2965 */
2966struct GNUNET_CRYPTO_RsaBlindedMessage
2967{
2968 /**
2969 * Blinded message to be signed
2970 * Note: is malloc()'ed!
2971 */
2972 void *blinded_msg;
2973
2974 /**
2975 * Size of the @e blinded_msg to be signed.
2976 */
2977 size_t blinded_msg_size;
2978};
2979
2980
2981/**
2848 * Blinds the given message with the given blinding key 2982 * Blinds the given message with the given blinding key
2849 * 2983 *
2850 * @param hash hash of the message to sign 2984 * @param message the message to sign
2985 * @param message_size number of bytes in @a message
2851 * @param bks the blinding key 2986 * @param bks the blinding key
2852 * @param pkey the public key of the signer 2987 * @param pkey the public key of the signer
2853 * @param[out] buf set to a buffer with the blinded message to be signed 2988 * @param[out] bm set to the blinded message
2854 * @param[out] buf_size number of bytes stored in @a buf
2855 * @return #GNUNET_YES if successful, #GNUNET_NO if RSA key is malicious 2989 * @return #GNUNET_YES if successful, #GNUNET_NO if RSA key is malicious
2856 */ 2990 */
2857int 2991enum GNUNET_GenericReturnValue
2858GNUNET_CRYPTO_rsa_blind (const struct GNUNET_HashCode *hash, 2992GNUNET_CRYPTO_rsa_blind (const void *message,
2993 size_t message_size,
2859 const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks, 2994 const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks,
2860 struct GNUNET_CRYPTO_RsaPublicKey *pkey, 2995 struct GNUNET_CRYPTO_RsaPublicKey *pkey,
2861 void **buf, 2996 struct GNUNET_CRYPTO_RsaBlindedMessage *bm);
2862 size_t *buf_size);
2863 2997
2864 2998
2865/** 2999/**
2866 * Sign a blinded value, which must be a full domain hash of a message. 3000 * Sign a blinded value, which must be a full domain hash of a message.
2867 * 3001 *
2868 * @param key private key to use for the signing 3002 * @param key private key to use for the signing
2869 * @param msg the (blinded) message to sign 3003 * @param bm the (blinded) message to sign
2870 * @param msg_len number of bytes in @a msg to sign
2871 * @return NULL on error, signature on success 3004 * @return NULL on error, signature on success
2872 */ 3005 */
2873struct GNUNET_CRYPTO_RsaSignature * 3006struct GNUNET_CRYPTO_RsaSignature *
2874GNUNET_CRYPTO_rsa_sign_blinded (const struct GNUNET_CRYPTO_RsaPrivateKey *key, 3007GNUNET_CRYPTO_rsa_sign_blinded (const struct GNUNET_CRYPTO_RsaPrivateKey *key,
2875 const void *msg, 3008 const struct
2876 size_t msg_len); 3009 GNUNET_CRYPTO_RsaBlindedMessage *bm);
2877 3010
2878 3011
2879/** 3012/**
2880 * Create and sign a full domain hash of a message. 3013 * Create and sign a full domain hash of a message.
2881 * 3014 *
2882 * @param key private key to use for the signing 3015 * @param key private key to use for the signing
2883 * @param hash the hash of the message to sign 3016 * @param message the message to sign
3017 * @param message_size number of bytes in @a message
2884 * @return NULL on error, including a malicious RSA key, signature on success 3018 * @return NULL on error, including a malicious RSA key, signature on success
2885 */ 3019 */
2886struct GNUNET_CRYPTO_RsaSignature * 3020struct GNUNET_CRYPTO_RsaSignature *
2887GNUNET_CRYPTO_rsa_sign_fdh (const struct GNUNET_CRYPTO_RsaPrivateKey *key, 3021GNUNET_CRYPTO_rsa_sign_fdh (const struct GNUNET_CRYPTO_RsaPrivateKey *key,
2888 const struct GNUNET_HashCode *hash); 3022 const void *message,
3023 size_t message_size);
3024
3025
3026/**
3027 * Free memory occupied by blinded message. Only frees contents, not
3028 * @a bm itself.
3029 *
3030 * @param[in] bm memory to free
3031 */
3032void
3033GNUNET_CRYPTO_rsa_blinded_message_free (
3034 struct GNUNET_CRYPTO_RsaBlindedMessage *bm);
2889 3035
2890 3036
2891/** 3037/**
2892 * Free memory occupied by signature. 3038 * Free memory occupied by signature.
2893 * 3039 *
2894 * @param sig memory to free 3040 * @param[in] sig memory to free
2895 */ 3041 */
2896void 3042void
2897GNUNET_CRYPTO_rsa_signature_free (struct GNUNET_CRYPTO_RsaSignature *sig); 3043GNUNET_CRYPTO_rsa_signature_free (struct GNUNET_CRYPTO_RsaSignature *sig);
@@ -2919,8 +3065,9 @@ GNUNET_CRYPTO_rsa_signature_encode (
2919 * @return NULL on error 3065 * @return NULL on error
2920 */ 3066 */
2921struct GNUNET_CRYPTO_RsaSignature * 3067struct GNUNET_CRYPTO_RsaSignature *
2922GNUNET_CRYPTO_rsa_signature_decode (const void *buf, 3068GNUNET_CRYPTO_rsa_signature_decode (
2923 size_t buf_size); 3069 const void *buf,
3070 size_t buf_size);
2924 3071
2925 3072
2926/** 3073/**
@@ -2930,7 +3077,8 @@ GNUNET_CRYPTO_rsa_signature_decode (const void *buf,
2930 * @return the duplicate key; NULL upon error 3077 * @return the duplicate key; NULL upon error
2931 */ 3078 */
2932struct GNUNET_CRYPTO_RsaSignature * 3079struct GNUNET_CRYPTO_RsaSignature *
2933GNUNET_CRYPTO_rsa_signature_dup (const struct GNUNET_CRYPTO_RsaSignature *sig); 3080GNUNET_CRYPTO_rsa_signature_dup (
3081 const struct GNUNET_CRYPTO_RsaSignature *sig);
2934 3082
2935 3083
2936/** 3084/**
@@ -2953,13 +3101,15 @@ GNUNET_CRYPTO_rsa_unblind (const struct GNUNET_CRYPTO_RsaSignature *sig,
2953 * Verify whether the given hash corresponds to the given signature and the 3101 * Verify whether the given hash corresponds to the given signature and the
2954 * signature is valid with respect to the given public key. 3102 * signature is valid with respect to the given public key.
2955 * 3103 *
2956 * @param hash the message to verify to match the @a sig 3104 * @param message the message to sign
3105 * @param message_size number of bytes in @a message
2957 * @param sig signature that is being validated 3106 * @param sig signature that is being validated
2958 * @param public_key public key of the signer 3107 * @param public_key public key of the signer
2959 * @returns #GNUNET_YES if ok, #GNUNET_NO if RSA key is malicious, #GNUNET_SYSERR if signature 3108 * @returns #GNUNET_YES if ok, #GNUNET_NO if RSA key is malicious, #GNUNET_SYSERR if signature
2960 */ 3109 */
2961enum GNUNET_GenericReturnValue 3110enum GNUNET_GenericReturnValue
2962GNUNET_CRYPTO_rsa_verify (const struct GNUNET_HashCode *hash, 3111GNUNET_CRYPTO_rsa_verify (const void *message,
3112 size_t message_size,
2963 const struct GNUNET_CRYPTO_RsaSignature *sig, 3113 const struct GNUNET_CRYPTO_RsaSignature *sig,
2964 const struct GNUNET_CRYPTO_RsaPublicKey *public_key); 3114 const struct GNUNET_CRYPTO_RsaPublicKey *public_key);
2965 3115
@@ -2999,10 +3149,11 @@ GNUNET_CRYPTO_cs_private_key_get_public (
2999 * @param[out] r array containing derived secrets r0 and r1 3149 * @param[out] r array containing derived secrets r0 and r1
3000 */ 3150 */
3001void 3151void
3002GNUNET_CRYPTO_cs_r_derive (const struct GNUNET_CRYPTO_CsNonce *nonce, 3152GNUNET_CRYPTO_cs_r_derive (
3003 const char *seed, 3153 const struct GNUNET_CRYPTO_CsSessionNonce *nonce,
3004 const struct GNUNET_CRYPTO_CsPrivateKey *lts, 3154 const char *seed,
3005 struct GNUNET_CRYPTO_CsRSecret r[2]); 3155 const struct GNUNET_CRYPTO_CsPrivateKey *lts,
3156 struct GNUNET_CRYPTO_CsRSecret r[2]);
3006 3157
3007 3158
3008/** 3159/**
@@ -3012,27 +3163,57 @@ GNUNET_CRYPTO_cs_r_derive (const struct GNUNET_CRYPTO_CsNonce *nonce,
3012 * @param[out] r_pub where to write the public key 3163 * @param[out] r_pub where to write the public key
3013 */ 3164 */
3014void 3165void
3015GNUNET_CRYPTO_cs_r_get_public (const struct GNUNET_CRYPTO_CsRSecret *r_priv, 3166GNUNET_CRYPTO_cs_r_get_public (
3016 struct GNUNET_CRYPTO_CsRPublic *r_pub); 3167 const struct GNUNET_CRYPTO_CsRSecret *r_priv,
3168 struct GNUNET_CRYPTO_CsRPublic *r_pub);
3169
3017 3170
3018/** 3171/**
3019 * Derives new random blinding factors. 3172 * Derives new random blinding factors.
3020 * In original papers blinding factors are generated randomly 3173 * In original papers blinding factors are generated randomly
3021 * To provide abort-idempotency, blinding factors need to be derived but still need to be UNPREDICTABLE 3174 * To provide abort-idempotency, blinding factors need to be derived but still need to be UNPREDICTABLE.
3022 * To ensure unpredictability a new nonce has to be used. 3175 * To ensure unpredictability a new nonce has to be used.
3023 * Uses HKDF internally 3176 * Uses HKDF internally.
3024 * 3177 *
3025 * @param blind_seed is the blinding seed to derive blinding factors 3178 * @param blind_seed is the blinding seed to derive blinding factors
3026 * @param[out] bs array containing the two derived blinding secrets 3179 * @param[out] bs array containing the two derived blinding secrets
3027 */ 3180 */
3028void 3181void
3029GNUNET_CRYPTO_cs_blinding_secrets_derive ( 3182GNUNET_CRYPTO_cs_blinding_secrets_derive (
3030 const struct GNUNET_CRYPTO_CsNonce *blind_seed, 3183 const struct GNUNET_CRYPTO_CsBlindingNonce *blind_seed,
3031 struct GNUNET_CRYPTO_CsBlindingSecret bs[2]); 3184 struct GNUNET_CRYPTO_CsBlindingSecret bs[2]);
3032 3185
3033 3186
3034/** 3187/**
3035 * Calculate two blinded c's 3188 * @brief CS Parameters derived from the message
3189 * during blinding to create blinded signature
3190 */
3191struct GNUNET_CRYPTO_CsBlindedMessage
3192{
3193 /**
3194 * The Clause Schnorr c_0 and c_1 containing the blinded message
3195 */
3196 struct GNUNET_CRYPTO_CsC c[2];
3197
3198 /**
3199 * Nonce used in initial request.
3200 */
3201 struct GNUNET_CRYPTO_CsSessionNonce nonce;
3202
3203};
3204
3205
3206/**
3207 * Pair of Public R values for Cs denominations
3208 */
3209struct GNUNET_CRYPTO_CSPublicRPairP
3210{
3211 struct GNUNET_CRYPTO_CsRPublic r_pub[2];
3212};
3213
3214
3215/**
3216 * Calculate two blinded c's.
3036 * Comment: One would be insecure due to Wagner's algorithm solving ROS 3217 * Comment: One would be insecure due to Wagner's algorithm solving ROS
3037 * 3218 *
3038 * @param bs array of the two blinding factor structs each containing alpha and beta 3219 * @param bs array of the two blinding factor structs each containing alpha and beta
@@ -3041,7 +3222,7 @@ GNUNET_CRYPTO_cs_blinding_secrets_derive (
3041 * @param msg the message to blind in preparation for signing 3222 * @param msg the message to blind in preparation for signing
3042 * @param msg_len length of message msg 3223 * @param msg_len length of message msg
3043 * @param[out] blinded_c array of the two blinded c's 3224 * @param[out] blinded_c array of the two blinded c's
3044 * @param[out] blinded_r_pub array of the two blinded R 3225 * @param[out] r_pub_blind array of the two blinded R
3045 */ 3226 */
3046void 3227void
3047GNUNET_CRYPTO_cs_calc_blinded_c ( 3228GNUNET_CRYPTO_cs_calc_blinded_c (
@@ -3051,32 +3232,49 @@ GNUNET_CRYPTO_cs_calc_blinded_c (
3051 const void *msg, 3232 const void *msg,
3052 size_t msg_len, 3233 size_t msg_len,
3053 struct GNUNET_CRYPTO_CsC blinded_c[2], 3234 struct GNUNET_CRYPTO_CsC blinded_c[2],
3054 struct GNUNET_CRYPTO_CsRPublic blinded_r_pub[2]); 3235 struct GNUNET_CRYPTO_CSPublicRPairP *r_pub_blind);
3055 3236
3056 3237
3057/** 3238/**
3058 * Sign a blinded c 3239 * The Sign Answer for Clause Blind Schnorr signature.
3059 * This function derives b from a nonce and a longterm secret 3240 * The sign operation returns a parameter @param b and the signature
3060 * In original papers b is generated randomly 3241 * scalar @param s_scalar.
3242 */
3243struct GNUNET_CRYPTO_CsBlindSignature
3244{
3245 /**
3246 * To make ROS problem harder, the signer chooses an unpredictable b and
3247 * only calculates signature of c_b
3248 */
3249 unsigned int b;
3250
3251 /**
3252 * The blinded s scalar calculated from c_b
3253 */
3254 struct GNUNET_CRYPTO_CsBlindS s_scalar;
3255};
3256
3257
3258/**
3259 * Sign a blinded @a c.
3260 * This function derives b from a nonce and a longterm secret.
3261 * In the original papers b is generated randomly.
3061 * To provide abort-idempotency, b needs to be derived but still need to be UNPREDICTABLE. 3262 * To provide abort-idempotency, b needs to be derived but still need to be UNPREDICTABLE.
3062 * To ensure unpredictability a new nonce has to be used for every signature 3263 * To ensure unpredictability a new nonce has to be used for every signature.
3063 * HKDF is used internally for derivation 3264 * HKDF is used internally for derivation.
3064 * r0 and r1 can be derived prior by using GNUNET_CRYPTO_cs_r_derive 3265 * r0 and r1 can be derived prior by using GNUNET_CRYPTO_cs_r_derive.
3065 * 3266 *
3066 * @param priv private key to use for the signing and as LTS in HKDF 3267 * @param priv private key to use for the signing and as LTS in HKDF
3067 * @param r array of the two secret nonce from the signer 3268 * @param r array of the two secret inputs from the signer
3068 * @param c array of the two blinded c to sign c_b 3269 * @param bm blinded message, including array of the two blinded c to sign c_b and the random nonce
3069 * @param nonce is a random nonce 3270 * @param[out] cs_blind_sig where to write the blind signature
3070 * @param[out] blinded_signature_scalar where to write the signature
3071 * @return 0 or 1 for b (see Clause Blind Signature Scheme)
3072 */ 3271 */
3073unsigned int 3272void
3074GNUNET_CRYPTO_cs_sign_derive ( 3273GNUNET_CRYPTO_cs_sign_derive (
3075 const struct GNUNET_CRYPTO_CsPrivateKey *priv, 3274 const struct GNUNET_CRYPTO_CsPrivateKey *priv,
3076 const struct GNUNET_CRYPTO_CsRSecret r[2], 3275 const struct GNUNET_CRYPTO_CsRSecret r[2],
3077 const struct GNUNET_CRYPTO_CsC c[2], 3276 const struct GNUNET_CRYPTO_CsBlindedMessage *bm,
3078 const struct GNUNET_CRYPTO_CsNonce *nonce, 3277 struct GNUNET_CRYPTO_CsBlindSignature *cs_blind_sig);
3079 struct GNUNET_CRYPTO_CsBlindS *blinded_signature_scalar);
3080 3278
3081 3279
3082/** 3280/**
@@ -3104,11 +3302,1065 @@ GNUNET_CRYPTO_cs_unblind (
3104 * @returns #GNUNET_YES on success, #GNUNET_SYSERR if signature invalid 3302 * @returns #GNUNET_YES on success, #GNUNET_SYSERR if signature invalid
3105 */ 3303 */
3106enum GNUNET_GenericReturnValue 3304enum GNUNET_GenericReturnValue
3107GNUNET_CRYPTO_cs_verify (const struct GNUNET_CRYPTO_CsSignature *sig, 3305GNUNET_CRYPTO_cs_verify (
3108 const struct GNUNET_CRYPTO_CsPublicKey *pub, 3306 const struct GNUNET_CRYPTO_CsSignature *sig,
3109 const void *msg, 3307 const struct GNUNET_CRYPTO_CsPublicKey *pub,
3110 size_t msg_len); 3308 const void *msg,
3309 size_t msg_len);
3310
3311
3312/**
3313 * Types of public keys used for blind signatures.
3314 */
3315enum GNUNET_CRYPTO_BlindSignatureAlgorithm
3316{
3317
3318 /**
3319 * Invalid type of signature.
3320 */
3321 GNUNET_CRYPTO_BSA_INVALID = 0,
3322
3323 /**
3324 * RSA blind signature.
3325 */
3326 GNUNET_CRYPTO_BSA_RSA = 1,
3327
3328 /**
3329 * Clause Blind Schnorr signature.
3330 */
3331 GNUNET_CRYPTO_BSA_CS = 2
3332};
3333
3334
3335/**
3336 * @brief Type of (unblinded) signatures.
3337 */
3338struct GNUNET_CRYPTO_UnblindedSignature
3339{
3340
3341 /**
3342 * Type of the signature.
3343 */
3344 enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher;
3345
3346 /**
3347 * Reference counter.
3348 */
3349 unsigned int rc;
3350
3351 /**
3352 * Details, depending on @e cipher.
3353 */
3354 union
3355 {
3356 /**
3357 * If we use #GNUNET_CRYPTO_BSA_CS in @a cipher.
3358 */
3359 struct GNUNET_CRYPTO_CsSignature cs_signature;
3360
3361 /**
3362 * If we use #GNUNET_CRYPTO_BSA_RSA in @a cipher.
3363 */
3364 struct GNUNET_CRYPTO_RsaSignature *rsa_signature;
3365
3366 } details;
3367
3368};
3369
3370
3371/**
3372 * @brief Type for *blinded* signatures.
3373 * Must be unblinded before it becomes valid.
3374 */
3375struct GNUNET_CRYPTO_BlindedSignature
3376{
3111 3377
3378 /**
3379 * Type of the signature.
3380 */
3381 enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher;
3382
3383 /**
3384 * Reference counter.
3385 */
3386 unsigned int rc;
3387
3388 /**
3389 * Details, depending on @e cipher.
3390 */
3391 union
3392 {
3393 /**
3394 * If we use #GNUNET_CRYPTO_BSA_CS in @a cipher.
3395 * At this point only the blinded s scalar is used.
3396 * The final signature consisting of r,s is built after unblinding.
3397 */
3398 struct GNUNET_CRYPTO_CsBlindSignature blinded_cs_answer;
3399
3400 /**
3401 * If we use #GNUNET_CRYPTO_BSA_RSA in @a cipher.
3402 */
3403 struct GNUNET_CRYPTO_RsaSignature *blinded_rsa_signature;
3404
3405 } details;
3406
3407};
3408
3409
3410/**
3411 * @brief Type of public signing keys for blind signatures.
3412 */
3413struct GNUNET_CRYPTO_BlindSignPublicKey
3414{
3415
3416 /**
3417 * Type of the public key.
3418 */
3419 enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher;
3420
3421 /**
3422 * Reference counter.
3423 */
3424 unsigned int rc;
3425
3426 /**
3427 * Hash of the public key.
3428 */
3429 struct GNUNET_HashCode pub_key_hash;
3430
3431 /**
3432 * Details, depending on @e cipher.
3433 */
3434 union
3435 {
3436 /**
3437 * If we use #GNUNET_CRYPTO_BSA_CS in @a cipher.
3438 */
3439 struct GNUNET_CRYPTO_CsPublicKey cs_public_key;
3440
3441 /**
3442 * If we use #GNUNET_CRYPTO_BSA_RSA in @a cipher.
3443 */
3444 struct GNUNET_CRYPTO_RsaPublicKey *rsa_public_key;
3445
3446 } details;
3447};
3448
3449
3450/**
3451 * @brief Type of private signing keys for blind signing.
3452 */
3453struct GNUNET_CRYPTO_BlindSignPrivateKey
3454{
3455
3456 /**
3457 * Type of the public key.
3458 */
3459 enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher;
3460
3461 /**
3462 * Reference counter.
3463 */
3464 unsigned int rc;
3465
3466 /**
3467 * Details, depending on @e cipher.
3468 */
3469 union
3470 {
3471 /**
3472 * If we use #GNUNET_CRYPTO_BSA_CS in @a cipher.
3473 */
3474 struct GNUNET_CRYPTO_CsPrivateKey cs_private_key;
3475
3476 /**
3477 * If we use #GNUNET_CRYPTO_BSA_RSA in @a cipher.
3478 */
3479 struct GNUNET_CRYPTO_RsaPrivateKey *rsa_private_key;
3480
3481 } details;
3482};
3483
3484
3485/**
3486 * @brief Blinded message ready for blind signing.
3487 */
3488struct GNUNET_CRYPTO_BlindedMessage
3489{
3490 /**
3491 * Type of the sign blinded message
3492 */
3493 enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher;
3494
3495 /**
3496 * Reference counter.
3497 */
3498 unsigned int rc;
3499
3500 /**
3501 * Details, depending on @e cipher.
3502 */
3503 union
3504 {
3505 /**
3506 * If we use #GNUNET_CRYPTO_BSA_CS in @a cipher.
3507 */
3508 struct GNUNET_CRYPTO_CsBlindedMessage cs_blinded_message;
3509
3510 /**
3511 * If we use #GNUNET_CRYPTO_BSA_RSA in @a cipher.
3512 */
3513 struct GNUNET_CRYPTO_RsaBlindedMessage rsa_blinded_message;
3514
3515 } details;
3516};
3517
3518
3519/**
3520 * Secret r for Cs denominations
3521 */
3522struct GNUNET_CRYPTO_CSPrivateRPairP
3523{
3524 struct GNUNET_CRYPTO_CsRSecret r[2];
3525};
3526
3527
3528/**
3529 * @brief Input needed for blinding a message.
3530 */
3531struct GNUNET_CRYPTO_BlindingInputValues
3532{
3533
3534 /**
3535 * Type of the signature.
3536 */
3537 enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher;
3538
3539 /**
3540 * Reference counter.
3541 */
3542 unsigned int rc;
3543
3544 /**
3545 * Details, depending on @e cipher.
3546 */
3547 union
3548 {
3549 /**
3550 * If we use #GNUNET_CRYPTO_BSA_CS in @a cipher.
3551 */
3552 struct GNUNET_CRYPTO_CSPublicRPairP cs_values;
3553
3554 } details;
3555
3556};
3557
3558
3559/**
3560 * Nonce used to deterministiacally derive input values
3561 * used in multi-round blind signature protocols.
3562 */
3563union GNUNET_CRYPTO_BlindSessionNonce
3564{
3565 /**
3566 * Nonce used when signing with CS.
3567 */
3568 struct GNUNET_CRYPTO_CsSessionNonce cs_nonce;
3569};
3570
3571
3572/**
3573 * Compute blinding input values for a given @a nonce and
3574 * @a salt.
3575 *
3576 * @param bsign_priv private key to compute input values for
3577 * @param nonce session nonce to derive input values from
3578 * @param salt salt to include in derivation logic
3579 * @return blinding input values
3580 */
3581struct GNUNET_CRYPTO_BlindingInputValues *
3582GNUNET_CRYPTO_get_blinding_input_values (
3583 const struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv,
3584 const union GNUNET_CRYPTO_BlindSessionNonce *nonce,
3585 const char *salt);
3586
3587
3588/**
3589 * Decrement reference counter of a @a bsign_pub, and free it if it reaches zero.
3590 *
3591 * @param[in] bsign_pub key to free
3592 */
3593void
3594GNUNET_CRYPTO_blind_sign_pub_decref (
3595 struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub);
3596
3597
3598/**
3599 * Decrement reference counter of a @a bsign_priv, and free it if it reaches zero.
3600 *
3601 * @param[in] bsign_priv key to free
3602 */
3603void
3604GNUNET_CRYPTO_blind_sign_priv_decref (
3605 struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv);
3606
3607
3608/**
3609 * Decrement reference counter of a @a ub_sig, and free it if it reaches zero.
3610 *
3611 * @param[in] ub_sig signature to free
3612 */
3613void
3614GNUNET_CRYPTO_unblinded_sig_decref (
3615 struct GNUNET_CRYPTO_UnblindedSignature *ub_sig);
3616
3617
3618/**
3619 * Decrement reference counter of a @a blind_sig, and free it if it reaches zero.
3620 *
3621 * @param[in] blind_sig signature to free
3622 */
3623void
3624GNUNET_CRYPTO_blinded_sig_decref (
3625 struct GNUNET_CRYPTO_BlindedSignature *blind_sig);
3626
3627
3628/**
3629 * Decrement reference counter of a @a bm, and free it if it reaches zero.
3630 *
3631 * @param[in] bm blinded message to free
3632 */
3633void
3634GNUNET_CRYPTO_blinded_message_decref (
3635 struct GNUNET_CRYPTO_BlindedMessage *bm);
3636
3637
3638/**
3639 * Increment reference counter of the given @a bm.
3640 *
3641 * @param[in,out] bm blinded message to increment reference counter for
3642 * @return alias of @a bm with RC incremented
3643 */
3644struct GNUNET_CRYPTO_BlindedMessage *
3645GNUNET_CRYPTO_blinded_message_incref (
3646 struct GNUNET_CRYPTO_BlindedMessage *bm);
3647
3648
3649/**
3650 * Increment reference counter of the given @a bi.
3651 *
3652 * @param[in,out] bi blinding input values to increment reference counter for
3653 * @return alias of @a bi with RC incremented
3654 */
3655struct GNUNET_CRYPTO_BlindingInputValues *
3656GNUNET_CRYPTO_blinding_input_values_incref (
3657 struct GNUNET_CRYPTO_BlindingInputValues *bm);
3658
3659
3660/**
3661 * Decrement reference counter of the given @a bi, and free it if it reaches
3662 * zero.
3663 *
3664 * @param[in,out] bi blinding input values to decrement reference counter for
3665 */
3666void
3667GNUNET_CRYPTO_blinding_input_values_decref (
3668 struct GNUNET_CRYPTO_BlindingInputValues *bm);
3669
3670
3671/**
3672 * Increment reference counter of the given @a bsign_pub.
3673 *
3674 * @param[in,out] bsign_pub public key to increment reference counter for
3675 * @return alias of @a bsign_pub with RC incremented
3676 */
3677struct GNUNET_CRYPTO_BlindSignPublicKey *
3678GNUNET_CRYPTO_bsign_pub_incref (
3679 struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub);
3680
3681
3682/**
3683 * Increment reference counter of the given @a bsign_priv.
3684 *
3685 * @param[in,out] bsign_priv private key to increment reference counter for
3686 * @return alias of @a bsign_priv with RC incremented
3687 */
3688struct GNUNET_CRYPTO_BlindSignPrivateKey *
3689GNUNET_CRYPTO_bsign_priv_incref (
3690 struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv);
3691
3692
3693/**
3694 * Increment reference counter of the given @a ub_sig.
3695 *
3696 * @param[in,out] ub_sig signature to increment reference counter for
3697 * @return alias of @a ub_sig with RC incremented
3698 */
3699struct GNUNET_CRYPTO_UnblindedSignature *
3700GNUNET_CRYPTO_ub_sig_incref (struct GNUNET_CRYPTO_UnblindedSignature *ub_sig);
3701
3702
3703/**
3704 * Increment reference counter of the given @a blind_sig.
3705 *
3706 * @param[in,out] blind_sig signature to increment reference counter for
3707 * @return alias of @a blind_sig with RC incremented
3708 */
3709struct GNUNET_CRYPTO_BlindedSignature *
3710GNUNET_CRYPTO_blind_sig_incref (
3711 struct GNUNET_CRYPTO_BlindedSignature *blind_sig);
3712
3713
3714/**
3715 * Compare two denomination public keys.
3716 *
3717 * @param bp1 first key
3718 * @param bp2 second key
3719 * @return 0 if the keys are equal, otherwise -1 or 1
3720 */
3721int
3722GNUNET_CRYPTO_bsign_pub_cmp (
3723 const struct GNUNET_CRYPTO_BlindSignPublicKey *bp1,
3724 const struct GNUNET_CRYPTO_BlindSignPublicKey *bp2);
3725
3726
3727/**
3728 * Compare two denomination signatures.
3729 *
3730 * @param sig1 first signature
3731 * @param sig2 second signature
3732 * @return 0 if the keys are equal, otherwise -1 or 1
3733 */
3734int
3735GNUNET_CRYPTO_ub_sig_cmp (const struct GNUNET_CRYPTO_UnblindedSignature *sig1,
3736 const struct GNUNET_CRYPTO_UnblindedSignature *sig2);
3737
3738
3739/**
3740 * Compare two blinded denomination signatures.
3741 *
3742 * @param sig1 first signature
3743 * @param sig2 second signature
3744 * @return 0 if the keys are equal, otherwise -1 or 1
3745 */
3746int
3747GNUNET_CRYPTO_blind_sig_cmp (
3748 const struct GNUNET_CRYPTO_BlindedSignature *sig1,
3749 const struct GNUNET_CRYPTO_BlindedSignature *sig2);
3750
3751
3752/**
3753 * Compare two blinded messages.
3754 *
3755 * @param bp1 first blinded message
3756 * @param bp2 second blinded message
3757 * @return 0 if the keys are equal, otherwise -1 or 1
3758 */
3759int
3760GNUNET_CRYPTO_blinded_message_cmp (
3761 const struct GNUNET_CRYPTO_BlindedMessage *bp1,
3762 const struct GNUNET_CRYPTO_BlindedMessage *bp2);
3763
3764
3765/**
3766 * Initialize public-private key pair for blind signatures.
3767 *
3768 * For #GNUNET_CRYPTO_BSA_RSA, an additional "unsigned int"
3769 * argument with the number of bits for 'n' (e.g. 2048) must
3770 * be passed.
3771 *
3772 * @param[out] bsign_priv where to write the private key with RC 1
3773 * @param[out] bsign_pub where to write the public key with RC 1
3774 * @param cipher which type of cipher to use
3775 * @param ... RSA key size (eg. 2048/3072/4096)
3776 * @return #GNUNET_OK on success, #GNUNET_NO if parameterst were invalid
3777 */
3778enum GNUNET_GenericReturnValue
3779GNUNET_CRYPTO_blind_sign_keys_create (
3780 struct GNUNET_CRYPTO_BlindSignPrivateKey **bsign_priv,
3781 struct GNUNET_CRYPTO_BlindSignPublicKey **bsign_pub,
3782 enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher,
3783 ...);
3784
3785
3786/**
3787 * Initialize public-private key pair for blind signatures.
3788 *
3789 * For #GNUNET_CRYPTO_BSA_RSA, an additional "unsigned int"
3790 * argument with the number of bits for 'n' (e.g. 2048) must
3791 * be passed.
3792 *
3793 * @param[out] bsign_priv where to write the private key with RC 1
3794 * @param[out] bsign_pub where to write the public key with RC 1
3795 * @param cipher which type of cipher to use
3796 * @param ap RSA key size (eg. 2048/3072/4096)
3797 * @return #GNUNET_OK on success, #GNUNET_NO if parameterst were invalid
3798 */
3799enum GNUNET_GenericReturnValue
3800GNUNET_CRYPTO_blind_sign_keys_create_va (
3801 struct GNUNET_CRYPTO_BlindSignPrivateKey **bsign_priv,
3802 struct GNUNET_CRYPTO_BlindSignPublicKey **bsign_pub,
3803 enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher,
3804 va_list ap);
3805
3806
3807/**
3808 * @brief Type of blinding secrets. Must be exactly 32 bytes (DB).
3809 */
3810union GNUNET_CRYPTO_BlindingSecretP
3811{
3812 /**
3813 * Clause Schnorr nonce.
3814 */
3815 struct GNUNET_CRYPTO_CsBlindingNonce nonce;
3816
3817 /**
3818 * Variant for RSA for blind signatures.
3819 */
3820 struct GNUNET_CRYPTO_RsaBlindingKeySecret rsa_bks;
3821};
3822
3823
3824/**
3825 * Blind message for blind signing with @a dk using blinding secret @a coin_bks.
3826 *
3827 * @param bsign_pub public key to blind for
3828 * @param bks blinding secret to use
3829 * @param nonce nonce used to obtain @a alg_values
3830 * can be NULL if input values are not used for the cipher
3831 * @param message message to sign
3832 * @param message_size number of bytes in @a message
3833 * @param alg_values algorithm specific values to blind the @a message
3834 * @return blinded message to give to signer, NULL on error
3835 */
3836struct GNUNET_CRYPTO_BlindedMessage *
3837GNUNET_CRYPTO_message_blind_to_sign (
3838 const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub,
3839 const union GNUNET_CRYPTO_BlindingSecretP *bks,
3840 const union GNUNET_CRYPTO_BlindSessionNonce *nonce,
3841 const void *message,
3842 size_t message_size,
3843 const struct GNUNET_CRYPTO_BlindingInputValues *alg_values);
3844
3845
3846/**
3847 * Create blind signature.
3848 *
3849 * @param bsign_priv private key to use for signing
3850 * @param salt salt value to use for the HKDF,
3851 * can be NULL if input values are not used for the cipher
3852 * @param blinded_message the already blinded message to sign
3853 * @return blind signature with RC=1, NULL on failure
3854 */
3855struct GNUNET_CRYPTO_BlindedSignature *
3856GNUNET_CRYPTO_blind_sign (
3857 const struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv,
3858 const char *salt,
3859 const struct GNUNET_CRYPTO_BlindedMessage *blinded_message);
3860
3861
3862/**
3863 * Unblind blind signature.
3864 *
3865 * @param blinded_sig the blind signature
3866 * @param bks blinding secret to use
3867 * @param message message that was supposedly signed
3868 * @param message_size number of bytes in @a message
3869 * @param alg_values algorithm specific values
3870 * @param bsign_pub public key used for signing
3871 * @return unblinded signature with RC=1, NULL on error
3872 */
3873struct GNUNET_CRYPTO_UnblindedSignature *
3874GNUNET_CRYPTO_blind_sig_unblind (
3875 const struct GNUNET_CRYPTO_BlindedSignature *blinded_sig,
3876 const union GNUNET_CRYPTO_BlindingSecretP *bks,
3877 const void *message,
3878 size_t message_size,
3879 const struct GNUNET_CRYPTO_BlindingInputValues *alg_values,
3880 const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub);
3881
3882
3883/**
3884 * Verify signature made blindly.
3885 *
3886 * @param bsign_pub public key
3887 * @param ub_sig signature made blindly with the private key
3888 * @param message message that was supposedly signed
3889 * @param message_size number of bytes in @a message
3890 * @return #GNUNET_OK if the signature is valid
3891 */
3892enum GNUNET_GenericReturnValue
3893GNUNET_CRYPTO_blind_sig_verify (
3894 const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub,
3895 const struct GNUNET_CRYPTO_UnblindedSignature *ub_sig,
3896 const void *message,
3897 size_t message_size);
3898
3899
3900/**
3901 * Get the compacted length of a #GNUNET_CRYPTO_PublicKey.
3902 * Compacted means that it returns the minimum number of bytes this
3903 * key is long, as opposed to the union structure inside
3904 * #GNUNET_CRYPTO_PublicKey.
3905 * Useful for compact serializations.
3906 *
3907 * @param key the key.
3908 * @return -1 on error, else the compacted length of the key.
3909 */
3910ssize_t
3911GNUNET_CRYPTO_public_key_get_length (const struct
3912 GNUNET_CRYPTO_PublicKey *key);
3913
3914/**
3915 * Reads a #GNUNET_CRYPTO_PublicKey from a compact buffer.
3916 * The buffer has to contain at least the compacted length of
3917 * a #GNUNET_CRYPTO_PublicKey in bytes.
3918 * If the buffer is too small, the function returns -1 as error.
3919 * If the buffer does not contain a valid key, it returns -2 as error.
3920 *
3921 * @param buffer the buffer
3922 * @param len the length of buffer
3923 * @param key the key
3924 * @param the amount of bytes read from the buffer
3925 * @return #GNUNET_SYSERR on error
3926 */
3927enum GNUNET_GenericReturnValue
3928GNUNET_CRYPTO_read_public_key_from_buffer (
3929 const void *buffer,
3930 size_t len,
3931 struct GNUNET_CRYPTO_PublicKey *key,
3932 size_t *read);
3933
3934/**
3935 * Get the compacted length of a #GNUNET_CRYPTO_PrivateKey.
3936 * Compacted means that it returns the minimum number of bytes this
3937 * key is long, as opposed to the union structure inside
3938 * #GNUNET_CRYPTO_PrivateKey.
3939 * Useful for compact serializations.
3940 *
3941 * @param key the key.
3942 * @return -1 on error, else the compacted length of the key.
3943 */
3944ssize_t
3945GNUNET_CRYPTO_private_key_get_length (
3946 const struct GNUNET_CRYPTO_PrivateKey *key);
3947
3948
3949/**
3950 * Writes a #GNUNET_CRYPTO_PublicKey to a compact buffer.
3951 * The buffer requires space for at least the compacted length of
3952 * a #GNUNET_CRYPTO_PublicKey in bytes.
3953 * If the buffer is too small, the function returns -1 as error.
3954 * If the key is not valid, it returns -2 as error.
3955 *
3956 * @param key the key
3957 * @param buffer the buffer
3958 * @param len the length of buffer
3959 * @return -1 or -2 on error, else the amount of bytes written to the buffer
3960 */
3961ssize_t
3962GNUNET_CRYPTO_write_public_key_to_buffer (const struct
3963 GNUNET_CRYPTO_PublicKey *key,
3964 void*buffer,
3965 size_t len);
3966
3967
3968/**
3969 * Reads a #GNUNET_CRYPTO_PrivateKey from a compact buffer.
3970 * The buffer has to contain at least the compacted length of
3971 * a #GNUNET_CRYPTO_PrivateKey in bytes.
3972 * If the buffer is too small, the function returns GNUNET_SYSERR as error.
3973 *
3974 * @param buffer the buffer
3975 * @param len the length of buffer
3976 * @param key the key
3977 * @param the amount of bytes read from the buffer
3978 * @return #GNUNET_SYSERR on error
3979 */
3980enum GNUNET_GenericReturnValue
3981GNUNET_CRYPTO_read_private_key_from_buffer (
3982 const void*buffer,
3983 size_t len,
3984 struct GNUNET_CRYPTO_PrivateKey *key,
3985 size_t *read);
3986
3987
3988/**
3989 * Writes a #GNUNET_CRYPTO_PrivateKey to a compact buffer.
3990 * The buffer requires space for at least the compacted length of
3991 * a #GNUNET_CRYPTO_PrivateKey in bytes.
3992 * If the buffer is too small, the function returns -1 as error.
3993 * If the key is not valid, it returns -2 as error.
3994 *
3995 * @param key the key
3996 * @param buffer the buffer
3997 * @param len the length of buffer
3998 * @return -1 or -2 on error, else the amount of bytes written to the buffer
3999 */
4000ssize_t
4001GNUNET_CRYPTO_write_private_key_to_buffer (
4002 const struct GNUNET_CRYPTO_PrivateKey *key,
4003 void*buffer,
4004 size_t len);
4005
4006
4007/**
4008 * Get the compacted length of a #GNUNET_CRYPTO_Signature.
4009 * Compacted means that it returns the minimum number of bytes this
4010 * signature is long, as opposed to the union structure inside
4011 * #GNUNET_CRYPTO_Signature.
4012 * Useful for compact serializations.
4013 *
4014 * @param sig the signature.
4015 * @return -1 on error, else the compacted length of the signature.
4016 */
4017ssize_t
4018GNUNET_CRYPTO_signature_get_length (
4019 const struct GNUNET_CRYPTO_Signature *sig);
4020
4021
4022/**
4023 * Get the compacted length of a signature by type.
4024 * Compacted means that it returns the minimum number of bytes this
4025 * signature is long, as opposed to the union structure inside
4026 * #GNUNET_CRYPTO_Signature.
4027 * Useful for compact serializations.
4028 *
4029 * @param sig the signature.
4030 * @return -1 on error, else the compacted length of the signature.
4031 */
4032ssize_t
4033GNUNET_CRYPTO_signature_get_raw_length_by_type (uint32_t type);
4034
4035
4036/**
4037 * Reads a #GNUNET_CRYPTO_Signature from a compact buffer.
4038 * The buffer has to contain at least the compacted length of
4039 * a #GNUNET_CRYPTO_Signature in bytes.
4040 * If the buffer is too small, the function returns -1 as error.
4041 * If the buffer does not contain a valid key, it returns -2 as error.
4042 *
4043 * @param sig the signature
4044 * @param buffer the buffer
4045 * @param len the length of buffer
4046 * @return -1 or -2 on error, else the amount of bytes read from the buffer
4047 */
4048ssize_t
4049GNUNET_CRYPTO_read_signature_from_buffer (
4050 struct GNUNET_CRYPTO_Signature *sig,
4051 const void*buffer,
4052 size_t len);
4053
4054
4055/**
4056 * Writes a #GNUNET_CRYPTO_Signature to a compact buffer.
4057 * The buffer requires space for at least the compacted length of
4058 * a #GNUNET_CRYPTO_Signature in bytes.
4059 * If the buffer is too small, the function returns -1 as error.
4060 * If the key is not valid, it returns -2 as error.
4061 *
4062 * @param sig the signature
4063 * @param buffer the buffer
4064 * @param len the length of buffer
4065 * @return -1 or -2 on error, else the amount of bytes written to the buffer
4066 */
4067ssize_t
4068GNUNET_CRYPTO_write_signature_to_buffer (
4069 const struct GNUNET_CRYPTO_Signature *sig,
4070 void*buffer,
4071 size_t len);
4072
4073
4074/**
4075 * @brief Sign a given block.
4076 *
4077 * The @a purpose data is the beginning of the data of which the signature is
4078 * to be created. The `size` field in @a purpose must correctly indicate the
4079 * number of bytes of the data structure, including its header. If possible,
4080 * use #GNUNET_CRYPTO_sign() instead of this function.
4081 *
4082 * @param priv private key to use for the signing
4083 * @param purpose what to sign (size, purpose)
4084 * @param[out] sig where to write the signature
4085 * @return #GNUNET_SYSERR on error, #GNUNET_OK on success
4086 */
4087enum GNUNET_GenericReturnValue
4088GNUNET_CRYPTO_sign_ (
4089 const struct GNUNET_CRYPTO_PrivateKey *priv,
4090 const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
4091 struct GNUNET_CRYPTO_Signature *sig);
4092
4093/**
4094 * @brief Sign a given block.
4095 *
4096 * The @a purpose data is the beginning of the data of which the signature is
4097 * to be created. The `size` field in @a purpose must correctly indicate the
4098 * number of bytes of the data structure, including its header.
4099 * The signature payload and length depends on the key type.
4100 *
4101 * @param priv private key to use for the signing
4102 * @param purpose what to sign (size, purpose)
4103 * @param[out] sig where to write the signature
4104 * @return #GNUNET_SYSERR on error, #GNUNET_OK on success
4105 */
4106enum GNUNET_GenericReturnValue
4107GNUNET_CRYPTO_sign_raw_ (
4108 const struct GNUNET_CRYPTO_PrivateKey *priv,
4109 const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
4110 unsigned char *sig);
4111
4112
4113/**
4114 * @brief Sign a given block with #GNUNET_CRYPTO_PrivateKey.
4115 *
4116 * The @a ps data must be a fixed-size struct for which the signature is to be
4117 * created. The `size` field in @a ps->purpose must correctly indicate the
4118 * number of bytes of the data structure, including its header.
4119 *
4120 * @param priv private key to use for the signing
4121 * @param ps packed struct with what to sign, MUST begin with a purpose
4122 * @param[out] sig where to write the signature
4123 */
4124#define GNUNET_CRYPTO_sign(priv,ps,sig) do { \
4125 /* check size is set correctly */ \
4126 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
4127 /* check 'ps' begins with the purpose */ \
4128 GNUNET_static_assert (((void*) (ps)) == \
4129 ((void*) &(ps)->purpose)); \
4130 GNUNET_assert (GNUNET_OK == \
4131 GNUNET_CRYPTO_sign_ (priv, \
4132 &(ps)->purpose, \
4133 sig)); \
4134} while (0)
4135
4136
4137/**
4138 * @brief Verify a given signature.
4139 *
4140 * The @a validate data is the beginning of the data of which the signature
4141 * is to be verified. The `size` field in @a validate must correctly indicate
4142 * the number of bytes of the data structure, including its header. If @a
4143 * purpose does not match the purpose given in @a validate (the latter must be
4144 * in big endian), signature verification fails. If possible,
4145 * use #GNUNET_CRYPTO_signature_verify() instead of this function (only if @a validate
4146 * is not fixed-size, you must use this function directly).
4147 *
4148 * @param purpose what is the purpose that the signature should have?
4149 * @param validate block to validate (size, purpose, data)
4150 * @param sig signature that is being validated
4151 * @param pub public key of the signer
4152 * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid
4153 */
4154enum GNUNET_GenericReturnValue
4155GNUNET_CRYPTO_signature_verify_ (
4156 uint32_t purpose,
4157 const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
4158 const struct GNUNET_CRYPTO_Signature *sig,
4159 const struct GNUNET_CRYPTO_PublicKey *pub);
4160
4161/**
4162 * @brief Verify a given signature.
4163 *
4164 * The @a validate data is the beginning of the data of which the signature
4165 * is to be verified. The `size` field in @a validate must correctly indicate
4166 * the number of bytes of the data structure, including its header. If @a
4167 * purpose does not match the purpose given in @a validate (the latter must be
4168 * in big endian), signature verification fails.
4169 *
4170 * @param purpose what is the purpose that the signature should have?
4171 * @param validate block to validate (size, purpose, data)
4172 * @param sig signature that is being validated
4173 * @param pub public key of the signer
4174 * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid
4175 */
4176enum GNUNET_GenericReturnValue
4177GNUNET_CRYPTO_signature_verify_raw_ (
4178 uint32_t purpose,
4179 const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
4180 const unsigned char *sig,
4181 const struct GNUNET_CRYPTO_PublicKey *pub);
4182
4183
4184/**
4185 * @brief Verify a given signature with #GNUNET_CRYPTO_PublicKey.
4186 *
4187 * The @a ps data must be a fixed-size struct for which the signature is to be
4188 * created. The `size` field in @a ps->purpose must correctly indicate the
4189 * number of bytes of the data structure, including its header.
4190 *
4191 * @param purp purpose of the signature, must match 'ps->purpose.purpose'
4192 * (except in host byte order)
4193 * @param ps packed struct with what to sign, MUST begin with a purpose
4194 * @param sig where to read the signature from
4195 * @param pub public key to use for the verifying
4196 */
4197#define GNUNET_CRYPTO_signature_verify(purp,ps,sig,pub) ({ \
4198 /* check size is set correctly */ \
4199 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
4200 /* check 'ps' begins with the purpose */ \
4201 GNUNET_static_assert (((void*) (ps)) == \
4202 ((void*) &(ps)->purpose)); \
4203 GNUNET_CRYPTO_signature_verify_ (purp, \
4204 &(ps)->purpose, \
4205 sig, \
4206 pub); \
4207 })
4208
4209
4210/**
4211 * Encrypt a block with #GNUNET_CRYPTO_PublicKey and derives a
4212 * #GNUNET_CRYPTO_EcdhePublicKey which is required for decryption
4213 * using ecdh to derive a symmetric key.
4214 *
4215 * @param block the block to encrypt
4216 * @param size the size of the @a block
4217 * @param pub public key to use for ecdh
4218 * @param ecc where to write the ecc public key
4219 * @param result the output parameter in which to store the encrypted result
4220 * can be the same or overlap with @c block
4221 * @returns the size of the encrypted block, -1 for errors.
4222 * Due to the use of CFB and therefore an effective stream cipher,
4223 * this size should be the same as @c len.
4224 */
4225ssize_t
4226GNUNET_CRYPTO_encrypt_old (const void *block,
4227 size_t size,
4228 const struct GNUNET_CRYPTO_PublicKey *pub,
4229 struct GNUNET_CRYPTO_EcdhePublicKey *ecc,
4230 void *result);
4231
4232
4233/**
4234 * Decrypt a given block with #GNUNET_CRYPTO_PrivateKey and a given
4235 * #GNUNET_CRYPTO_EcdhePublicKey using ecdh to derive a symmetric key.
4236 *
4237 * @param block the data to decrypt, encoded as returned by encrypt
4238 * @param size the size of the @a block to decrypt
4239 * @param priv private key to use for ecdh
4240 * @param ecc the ecc public key
4241 * @param result address to store the result at
4242 * can be the same or overlap with @c block
4243 * @return -1 on failure, size of decrypted block on success.
4244 * Due to the use of CFB and therefore an effective stream cipher,
4245 * this size should be the same as @c size.
4246 */
4247ssize_t
4248GNUNET_CRYPTO_decrypt_old (
4249 const void *block,
4250 size_t size,
4251 const struct GNUNET_CRYPTO_PrivateKey *priv,
4252 const struct GNUNET_CRYPTO_EcdhePublicKey *ecc,
4253 void *result);
4254
4255#define GNUNET_CRYPTO_ENCRYPT_OVERHEAD_BYTES (crypto_secretbox_MACBYTES \
4256 + sizeof (struct \
4257 GNUNET_CRYPTO_FoKemC))
4258
4259/**
4260 * Encrypt a block with #GNUNET_CRYPTO_PublicKey and derives a
4261 * #GNUNET_CRYPTO_EcdhePublicKey which is required for decryption
4262 * using ecdh to derive a symmetric key.
4263 *
4264 * Note that the result buffer for the ciphertext must be the length of
4265 * the message to encrypt plus #GNUNET_CRYPTO_ENCRYPT_OVERHEAD_BYTES.
4266 *
4267 * @param block the block to encrypt
4268 * @param size the size of the @a block
4269 * @param pub public key to encrypt for
4270 * @param result the output parameter in which to store the encrypted result
4271 * can be the same or overlap with @c block
4272 * @returns GNUNET_OK on success.
4273 */
4274enum GNUNET_GenericReturnValue
4275GNUNET_CRYPTO_encrypt (const void *block,
4276 size_t size,
4277 const struct GNUNET_CRYPTO_PublicKey *pub,
4278 void *result,
4279 size_t result_size);
4280
4281
4282/**
4283 * Decrypt a given block with #GNUNET_CRYPTO_PrivateKey and a given
4284 * #GNUNET_CRYPTO_EcdhePublicKey using ecdh to derive a symmetric key.
4285 *
4286 * @param block the data to decrypt, encoded as returned by encrypt
4287 * @param size the size of the @a block to decrypt
4288 * @param priv private key to use for ecdh
4289 * @param result address to store the result at
4290 * can be the same or overlap with @c block
4291 * @returns GNUNET_OK on success.
4292 */
4293enum GNUNET_GenericReturnValue
4294GNUNET_CRYPTO_decrypt (const void *block,
4295 size_t size,
4296 const struct GNUNET_CRYPTO_PrivateKey *priv,
4297 void *result,
4298 size_t result_size);
4299
4300
4301/**
4302 * Creates a (Base32) string representation of the public key.
4303 * The resulting string encodes a compacted representation of the key.
4304 * See also #GNUNET_CRYPTO_key_get_length.
4305 *
4306 * @param key the key.
4307 * @return the string representation of the key, or NULL on error.
4308 */
4309char *
4310GNUNET_CRYPTO_public_key_to_string (
4311 const struct GNUNET_CRYPTO_PublicKey *key);
4312
4313
4314/**
4315 * Creates a (Base32) string representation of the private key.
4316 * The resulting string encodes a compacted representation of the key.
4317 * See also #GNUNET_CRYPTO_key_get_length.
4318 *
4319 * @param key the key.
4320 * @return the string representation of the key, or NULL on error.
4321 */
4322char *
4323GNUNET_CRYPTO_private_key_to_string (
4324 const struct GNUNET_CRYPTO_PrivateKey *key);
4325
4326
4327/**
4328 * Parses a (Base32) string representation of the public key.
4329 * See also #GNUNET_CRYPTO_public_key_to_string.
4330 *
4331 * @param str the encoded key.
4332 * @param key where to write the key.
4333 * @return GNUNET_SYSERR on error.
4334 */
4335enum GNUNET_GenericReturnValue
4336GNUNET_CRYPTO_public_key_from_string (const char*str,
4337 struct GNUNET_CRYPTO_PublicKey *key);
4338
4339
4340/**
4341 * Parses a (Base32) string representation of the private key.
4342 * See also #GNUNET_CRYPTO_private_key_to_string.
4343 *
4344 * @param str the encoded key.
4345 * @param key where to write the key.
4346 * @return GNUNET_SYSERR on error.
4347 */
4348enum GNUNET_GenericReturnValue
4349GNUNET_CRYPTO_private_key_from_string (const char*str,
4350 struct GNUNET_CRYPTO_PrivateKey *key);
4351
4352
4353/**
4354 * Retrieves the public key representation of a private key.
4355 *
4356 * @param privkey the private key.
4357 * @param key the public key result.
4358 * @return GNUNET_SYSERR on error.
4359 */
4360enum GNUNET_GenericReturnValue
4361GNUNET_CRYPTO_key_get_public (const struct
4362 GNUNET_CRYPTO_PrivateKey *privkey,
4363 struct GNUNET_CRYPTO_PublicKey *key);
3112 4364
3113#if 0 /* keep Emacsens' auto-indent happy */ 4365#if 0 /* keep Emacsens' auto-indent happy */
3114{ 4366{
diff --git a/src/include/gnunet_curl_lib.h b/src/include/gnunet_curl_lib.h
index bdf3843b1..967170085 100644
--- a/src/include/gnunet_curl_lib.h
+++ b/src/include/gnunet_curl_lib.h
@@ -433,7 +433,7 @@ GNUNET_CURL_enable_async_scope_header (struct GNUNET_CURL_Context *ctx,
433 * 433 *
434 * @returns #GNUNET_YES iff given a valid scope ID 434 * @returns #GNUNET_YES iff given a valid scope ID
435 */ 435 */
436int 436enum GNUNET_GenericReturnValue
437GNUNET_CURL_is_valid_scope_id (const char *scope_id); 437GNUNET_CURL_is_valid_scope_id (const char *scope_id);
438 438
439 439
diff --git a/src/include/gnunet_dht_block_types.h b/src/include/gnunet_dht_block_types.h
new file mode 100644
index 000000000..ab46af410
--- /dev/null
+++ b/src/include/gnunet_dht_block_types.h
@@ -0,0 +1,156 @@
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_DHT_BLOCK_TYPES_H
21#define GNUNET_DHT_BLOCK_TYPES_H
22
23/**
24 * WARNING:
25 * This header is generated!
26 * In order to add DHT block 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
33extern "C" {
34#if 0 /* keep Emacsens' auto-indent happy */
35}
36#endif
37#endif
38
39/**
40 * Blocks in the datastore and the datacache must have a unique type.
41 */
42enum GNUNET_BLOCK_Type
43{
44
45
46 /**
47 * Identifier for any block.
48 */
49 GNUNET_BLOCK_TYPE_ANY = 0,
50
51
52 /**
53 * Data block (leaf) in the CHK tree.
54 */
55 GNUNET_BLOCK_TYPE_FS_DBLOCK = 1,
56
57
58 /**
59 * Inner block in the CHK tree.
60 */
61 GNUNET_BLOCK_TYPE_FS_IBLOCK = 2,
62
63
64 /**
65 * Type of a block representing a block to be encoded on demand from disk. Should never appear on the network directly.
66 */
67 GNUNET_BLOCK_TYPE_FS_ONDEMAND = 6,
68
69
70 /**
71 * Legacy type of a block that contains a HELLO for a peer.
72 */
73 GNUNET_BLOCK_TYPE_LEGACY_HELLO = 7,
74
75
76 /**
77 * Block for testing.
78 */
79 GNUNET_BLOCK_TYPE_TEST = 8,
80
81
82 /**
83 * Type of a block representing any type of search result (universal).
84 */
85 GNUNET_BLOCK_TYPE_FS_UBLOCK = 9,
86
87
88 /**
89 * Block for storing DNS exit service advertisements.
90 */
91 GNUNET_BLOCK_TYPE_DNS = 10,
92
93
94 /**
95 * Block for storing GNS record data.
96 */
97 GNUNET_BLOCK_TYPE_GNS_NAMERECORD = 11,
98
99
100 /**
101 * Block type for a revocation message by which a key is revoked.
102 */
103 GNUNET_BLOCK_TYPE_REVOCATION = 12,
104
105
106 /**
107 * Type of a block that contains a DHT-NG HELLO for a peer.
108 */
109 GNUNET_BLOCK_TYPE_DHT_HELLO = 13,
110
111
112 /**
113 * Block to store a cadet regex state
114 */
115 GNUNET_BLOCK_TYPE_REGEX = 22,
116
117
118 /**
119 * Block to store a cadet regex accepting state
120 */
121 GNUNET_BLOCK_TYPE_REGEX_ACCEPT = 23,
122
123
124 /**
125 * Block for testing set/consensus. If first byte of the block is non-zero, the block is considered invalid.
126 */
127 GNUNET_BLOCK_TYPE_SET_TEST = 24,
128
129
130 /**
131 * Block type for consensus elements. Contains either special marker elements or a nested block.
132 */
133 GNUNET_BLOCK_TYPE_CONSENSUS_ELEMENT = 25,
134
135
136 /**
137 * Block for testing set intersection. If first byte of the block is non-zero, the block is considered invalid.
138 */
139 GNUNET_BLOCK_TYPE_SETI_TEST = 26,
140
141
142 /**
143 * Block for testing set union. If first byte of the block is non-zero, the block is considered invalid.
144 */
145 GNUNET_BLOCK_TYPE_SETU_TEST = 27,
146};
147
148
149#if 0 /* keep Emacsens' auto-indent happy */
150{
151#endif
152#ifdef __cplusplus
153}
154#endif
155
156#endif
diff --git a/src/include/gnunet_dht_service.h b/src/include/gnunet_dht_service.h
index 3d1264991..a1ea31c25 100644
--- a/src/include/gnunet_dht_service.h
+++ b/src/include/gnunet_dht_service.h
@@ -43,7 +43,6 @@
43 43
44#include "gnunet_util_lib.h" 44#include "gnunet_util_lib.h"
45#include "gnunet_block_lib.h" 45#include "gnunet_block_lib.h"
46#include "gnunet_hello_lib.h"
47 46
48#ifdef __cplusplus 47#ifdef __cplusplus
49extern "C" 48extern "C"
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
30extern "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 */
42enum 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 */
209const char *
210GNUNET_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 */
219unsigned int
220GNUNET_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 */
231unsigned int
232GNUNET_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 c8e99826a..000000000
--- a/src/include/gnunet_fragmentation_lib.h
+++ /dev/null
@@ -1,235 +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 * @addtogroup Backbone
22 * @{
23 *
24 * @author Christian Grothoff
25 *
26 * @file
27 * Library to help fragment messages
28 *
29 * @defgroup fragmentation Fragmentation library
30 * Library to help fragment messages
31 * @{
32 *
33 * @todo Consider additional flow-control for sending from
34 * fragmentation based on continuations.
35 */
36
37#ifndef GNUNET_FRAGMENTATION_LIB_H
38#define GNUNET_FRAGMENTATION_LIB_H
39
40
41#include "gnunet_util_lib.h"
42#include "gnunet_statistics_service.h"
43
44#ifdef __cplusplus
45extern "C"
46{
47#if 0 /* keep Emacsens' auto-indent happy */
48}
49#endif
50#endif
51
52
53/**
54 * Fragmentation context.
55 */
56struct GNUNET_FRAGMENT_Context;
57
58
59/**
60 * Function that is called with messages created by the fragmentation
61 * module. In the case of the 'proc' callback of the
62 * #GNUNET_FRAGMENT_context_create() function, this function must
63 * eventually call #GNUNET_FRAGMENT_context_transmission_done().
64 *
65 * @param cls closure
66 * @param msg the message that was created
67 */
68typedef void
69(*GNUNET_FRAGMENT_MessageProcessor) (void *cls,
70 const struct GNUNET_MessageHeader *msg);
71
72
73/**
74 * Create a fragmentation context for the given message.
75 * Fragments the message into fragments of size @a mtu or
76 * less. Calls @a proc on each un-acknowledged fragment,
77 * using both the expected @a msg_delay between messages and
78 * acknowledgements and the given @a tracker to guide the
79 * frequency of calls to @a proc.
80 *
81 * @param stats statistics context
82 * @param mtu the maximum message size for each fragment
83 * @param tracker bandwidth tracker to use for flow control (can be NULL)
84 * @param msg_delay initial delay to insert between fragment transmissions
85 * based on previous messages
86 * @param ack_delay expected delay between fragment transmission
87 * and ACK based on previous messages
88 * @param msg the message to fragment
89 * @param proc function to call for each fragment to transmit
90 * @param proc_cls closure for proc
91 * @return the fragmentation context
92 */
93struct GNUNET_FRAGMENT_Context *
94GNUNET_FRAGMENT_context_create (struct GNUNET_STATISTICS_Handle *stats,
95 uint16_t mtu,
96 struct GNUNET_BANDWIDTH_Tracker *tracker,
97 struct GNUNET_TIME_Relative msg_delay,
98 struct GNUNET_TIME_Relative ack_delay,
99 const struct GNUNET_MessageHeader *msg,
100 GNUNET_FRAGMENT_MessageProcessor proc,
101 void *proc_cls);
102
103
104/**
105 * Continuation to call from the 'proc' function after the fragment
106 * has been transmitted (and hence the next fragment can now be
107 * given to proc).
108 *
109 * @param fc fragmentation context
110 */
111void
112GNUNET_FRAGMENT_context_transmission_done (struct GNUNET_FRAGMENT_Context *fc);
113
114
115/**
116 * Process an acknowledgement message we got from the other
117 * side (to control re-transmits).
118 *
119 * @param fc fragmentation context
120 * @param msg acknowledgement message we received
121 * @return #GNUNET_OK if this ack completes the work of the 'fc'
122 * (all fragments have been received);
123 * #GNUNET_NO if more messages are pending
124 * #GNUNET_SYSERR if this ack is not valid for this fc
125 */
126int
127GNUNET_FRAGMENT_process_ack (struct GNUNET_FRAGMENT_Context *fc,
128 const struct GNUNET_MessageHeader *msg);
129
130
131/**
132 * Destroy the given fragmentation context (stop calling 'proc', free
133 * resources).
134 *
135 * @param fc fragmentation context
136 * @param msg_delay where to store average delay between individual message transmissions the
137 * last message (OUT only)
138 * @param ack_delay where to store average delay between transmission and ACK for the
139 * last message, set to FOREVER if the message was not fully transmitted (OUT only)
140 */
141void
142GNUNET_FRAGMENT_context_destroy (struct GNUNET_FRAGMENT_Context *fc,
143 struct GNUNET_TIME_Relative *msg_delay,
144 struct GNUNET_TIME_Relative *ack_delay);
145
146
147/**
148 * Convert an ACK message to a printable format suitable for logging.
149 *
150 * @param ack message to print
151 * @return ack in human-readable format
152 */
153const char *
154GNUNET_FRAGMENT_print_ack (const struct GNUNET_MessageHeader *ack);
155
156
157/**
158 * Defragmentation context (one per connection).
159 */
160struct GNUNET_DEFRAGMENT_Context;
161
162
163/**
164 * Function that is called with acknowledgement messages created by
165 * the fragmentation module. Acknowledgements are cumulative,
166 * so it is OK to only transmit the 'latest' ack message for the same
167 * message ID.
168 *
169 * @param cls closure
170 * @param id unique message ID (modulo collisions)
171 * @param msg the message that was created
172 */
173typedef void
174(*GNUNET_DEFRAGMENT_AckProcessor) (void *cls,
175 uint32_t id,
176 const struct GNUNET_MessageHeader *msg);
177
178
179/**
180 * Create a defragmentation context.
181 *
182 * @param stats statistics context
183 * @param mtu the maximum message size for each fragment
184 * @param num_msgs how many fragmented messages
185 * to we defragment at most at the same time?
186 * @param cls closure for @a proc and @a ackp
187 * @param proc function to call with defragmented messages
188 * @param ackp function to call with acknowledgements (to send
189 * back to the other side)
190 * @return the defragmentation context
191 */
192struct GNUNET_DEFRAGMENT_Context *
193GNUNET_DEFRAGMENT_context_create (struct GNUNET_STATISTICS_Handle *stats,
194 uint16_t mtu,
195 unsigned int num_msgs,
196 void *cls,
197 GNUNET_FRAGMENT_MessageProcessor proc,
198 GNUNET_DEFRAGMENT_AckProcessor ackp);
199
200
201/**
202 * Destroy the given defragmentation context.
203 *
204 * @param dc defragmentation context
205 */
206void
207GNUNET_DEFRAGMENT_context_destroy (struct GNUNET_DEFRAGMENT_Context *dc);
208
209
210/**
211 * We have received a fragment. Process it.
212 *
213 * @param dc the context
214 * @param msg the message that was received
215 * @return #GNUNET_OK on success,
216 * #GNUNET_NO if this was a duplicate,
217 * #GNUNET_SYSERR on error
218 */
219int
220GNUNET_DEFRAGMENT_process_fragment (struct GNUNET_DEFRAGMENT_Context *dc,
221 const struct GNUNET_MessageHeader *msg);
222
223
224#if 0 /* keep Emacsens' auto-indent happy */
225{
226#endif
227#ifdef __cplusplus
228}
229#endif
230
231#endif
232
233/** @} */ /* end of group */
234
235/** @} */ /* end of group addition */
diff --git a/src/include/gnunet_friends_lib.h b/src/include/gnunet_friends_lib.h
deleted file mode 100644
index 4f4d5e88b..000000000
--- a/src/include/gnunet_friends_lib.h
+++ /dev/null
@@ -1,124 +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 * @addtogroup Backbone
23 * @{
24 *
25 * @author Christian Grothoff
26 *
27 * @file
28 * Library to read and write the FRIENDS file
29 *
30 * @defgroup friends Friends library
31 * Library to read and write the FRIENDS file
32 * @{
33 */
34#ifndef GNUNET_FRIENDS_LIB_H
35#define GNUNET_FRIENDS_LIB_H
36
37#ifdef __cplusplus
38extern "C"
39{
40#if 0 /* keep Emacsens' auto-indent happy */
41}
42#endif
43#endif
44
45
46#include "gnunet_util_lib.h"
47
48
49/**
50 * Signature of a function called on each friend found.
51 *
52 * @param cls closure
53 * @param friend_id peer identity of the friend
54 */
55typedef void (*GNUNET_FRIENDS_Callback)(void *cls,
56 const struct
57 GNUNET_PeerIdentity *friend_id);
58
59
60/**
61 * Parse the FRIENDS file.
62 *
63 * @param cfg our configuration
64 * @param cb function to call on each friend found
65 * @param cb_cls closure for @a cb
66 * @return #GNUNET_OK on success, #GNUNET_SYSERR on parsing errors
67 */
68int
69GNUNET_FRIENDS_parse (const struct GNUNET_CONFIGURATION_Handle *cfg,
70 GNUNET_FRIENDS_Callback cb,
71 void *cb_cls);
72
73
74/**
75 * Handle for writing a friends file.
76 */
77struct GNUNET_FRIENDS_Writer;
78
79
80/**
81 * Start writing a fresh FRIENDS file. Will make a backup of the
82 * old one.
83 *
84 * @param cfg configuration to use.
85 * @return NULL on error
86 */
87struct GNUNET_FRIENDS_Writer *
88GNUNET_FRIENDS_write_start (const struct GNUNET_CONFIGURATION_Handle *cfg);
89
90
91/**
92 * Finish writing out the friends file.
93 *
94 * @param w write handle
95 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
96 */
97int
98GNUNET_FRIENDS_write_stop (struct GNUNET_FRIENDS_Writer *w);
99
100
101/**
102 * Add a friend to the friends file.
103 *
104 * @param w write handle
105 * @param friend_id friend to add
106 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
107 */
108int
109GNUNET_FRIENDS_write (struct GNUNET_FRIENDS_Writer *w,
110 const struct GNUNET_PeerIdentity *friend_id);
111
112
113#if 0 /* keep Emacsens' auto-indent happy */
114{
115#endif
116#ifdef __cplusplus
117}
118#endif
119
120#endif
121
122/** @} */ /* end of group */
123
124/** @} */ /* end of group addition to backbone */
diff --git a/src/include/gnunet_gns_service.h b/src/include/gnunet_gns_service.h
index 1fcf7aa8b..1f19e58ac 100644
--- a/src/include/gnunet_gns_service.h
+++ b/src/include/gnunet_gns_service.h
@@ -137,7 +137,7 @@ enum GNUNET_GNS_LocalOptions
137struct GNUNET_GNS_LookupRequest * 137struct GNUNET_GNS_LookupRequest *
138GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle, 138GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
139 const char *name, 139 const char *name,
140 const struct GNUNET_IDENTITY_PublicKey *zone, 140 const struct GNUNET_CRYPTO_PublicKey *zone,
141 uint32_t type, 141 uint32_t type,
142 enum GNUNET_GNS_LocalOptions options, 142 enum GNUNET_GNS_LocalOptions options,
143 GNUNET_GNS_LookupResultProcessor proc, 143 GNUNET_GNS_LookupResultProcessor proc,
@@ -161,7 +161,7 @@ GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
161struct GNUNET_GNS_LookupRequest * 161struct GNUNET_GNS_LookupRequest *
162GNUNET_GNS_lookup_limited (struct GNUNET_GNS_Handle *handle, 162GNUNET_GNS_lookup_limited (struct GNUNET_GNS_Handle *handle,
163 const char *name, 163 const char *name,
164 const struct GNUNET_IDENTITY_PublicKey *zone, 164 const struct GNUNET_CRYPTO_PublicKey *zone,
165 uint32_t type, 165 uint32_t type,
166 enum GNUNET_GNS_LocalOptions options, 166 enum GNUNET_GNS_LocalOptions options,
167 uint16_t recursion_depth_limit, 167 uint16_t recursion_depth_limit,
diff --git a/src/include/gnunet_gnsrecord_lib.h b/src/include/gnunet_gnsrecord_lib.h
index 3aee30117..3f1830498 100644
--- a/src/include/gnunet_gnsrecord_lib.h
+++ b/src/include/gnunet_gnsrecord_lib.h
@@ -38,6 +38,7 @@
38#define GNUNET_GNSRECORD_LIB_H 38#define GNUNET_GNSRECORD_LIB_H
39 39
40 40
41#include "gnunet_common.h"
41#include "gnunet_identity_service.h" 42#include "gnunet_identity_service.h"
42 43
43#ifdef __cplusplus 44#ifdef __cplusplus
@@ -338,7 +339,7 @@ struct GNUNET_GNSRECORD_ReverseRecord
338 /** 339 /**
339 * The public key of the namespace the is delegating to our namespace 340 * The public key of the namespace the is delegating to our namespace
340 */ 341 */
341 struct GNUNET_IDENTITY_PublicKey pkey; 342 struct GNUNET_CRYPTO_PublicKey pkey;
342 343
343 /** 344 /**
344 * The expiration time of the delegation 345 * The expiration time of the delegation
@@ -493,7 +494,7 @@ GNUNET_GNSRECORD_string_normalize (const char *src);
493 * #GNUNET_GNSRECORD_z2s. 494 * #GNUNET_GNSRECORD_z2s.
494 */ 495 */
495const char * 496const char *
496GNUNET_GNSRECORD_z2s (const struct GNUNET_IDENTITY_PublicKey *z); 497GNUNET_GNSRECORD_z2s (const struct GNUNET_CRYPTO_PublicKey *z);
497 498
498 499
499/** 500/**
@@ -507,7 +508,7 @@ GNUNET_GNSRECORD_z2s (const struct GNUNET_IDENTITY_PublicKey *z);
507 * key in an encoding suitable for DNS labels. 508 * key in an encoding suitable for DNS labels.
508 */ 509 */
509const char * 510const char *
510GNUNET_GNSRECORD_pkey_to_zkey (const struct GNUNET_IDENTITY_PublicKey *pkey); 511GNUNET_GNSRECORD_pkey_to_zkey (const struct GNUNET_CRYPTO_PublicKey *pkey);
511 512
512 513
513/** 514/**
@@ -521,7 +522,7 @@ GNUNET_GNSRECORD_pkey_to_zkey (const struct GNUNET_IDENTITY_PublicKey *pkey);
521 */ 522 */
522int 523int
523GNUNET_GNSRECORD_zkey_to_pkey (const char *zkey, 524GNUNET_GNSRECORD_zkey_to_pkey (const char *zkey,
524 struct GNUNET_IDENTITY_PublicKey *pkey); 525 struct GNUNET_CRYPTO_PublicKey *pkey);
525 526
526 527
527/** 528/**
@@ -533,7 +534,7 @@ GNUNET_GNSRECORD_zkey_to_pkey (const char *zkey,
533 */ 534 */
534void 535void
535GNUNET_GNSRECORD_query_from_private_key ( 536GNUNET_GNSRECORD_query_from_private_key (
536 const struct GNUNET_IDENTITY_PrivateKey *zone, const char *label, 537 const struct GNUNET_CRYPTO_PrivateKey *zone, const char *label,
537 struct GNUNET_HashCode *query); 538 struct GNUNET_HashCode *query);
538 539
539 540
@@ -547,7 +548,7 @@ GNUNET_GNSRECORD_query_from_private_key (
547 */ 548 */
548void 549void
549GNUNET_GNSRECORD_query_from_public_key ( 550GNUNET_GNSRECORD_query_from_public_key (
550 const struct GNUNET_IDENTITY_PublicKey *pub, const char *label, 551 const struct GNUNET_CRYPTO_PublicKey *pub, const char *label,
551 struct GNUNET_HashCode *query); 552 struct GNUNET_HashCode *query);
552 553
553 554
@@ -561,7 +562,7 @@ GNUNET_GNSRECORD_query_from_public_key (
561 */ 562 */
562ssize_t 563ssize_t
563GNUNET_GNSRECORD_block_calculate_size (const struct 564GNUNET_GNSRECORD_block_calculate_size (const struct
564 GNUNET_IDENTITY_PrivateKey *key, 565 GNUNET_CRYPTO_PrivateKey *key,
565 const struct GNUNET_GNSRECORD_Data *rd, 566 const struct GNUNET_GNSRECORD_Data *rd,
566 unsigned int rd_count); 567 unsigned int rd_count);
567 568
@@ -575,7 +576,7 @@ GNUNET_GNSRECORD_block_calculate_size (const struct
575 */ 576 */
576enum GNUNET_GenericReturnValue 577enum GNUNET_GenericReturnValue
577GNUNET_GNSRECORD_block_sign (const struct 578GNUNET_GNSRECORD_block_sign (const struct
578 GNUNET_IDENTITY_PrivateKey *key, 579 GNUNET_CRYPTO_PrivateKey *key,
579 const char *label, 580 const char *label,
580 struct GNUNET_GNSRECORD_Block *block); 581 struct GNUNET_GNSRECORD_Block *block);
581 582
@@ -591,7 +592,7 @@ GNUNET_GNSRECORD_block_sign (const struct
591 * @return GNUNET_OK on success 592 * @return GNUNET_OK on success
592 */ 593 */
593enum GNUNET_GenericReturnValue 594enum GNUNET_GenericReturnValue
594GNUNET_GNSRECORD_block_create (const struct GNUNET_IDENTITY_PrivateKey *key, 595GNUNET_GNSRECORD_block_create (const struct GNUNET_CRYPTO_PrivateKey *key,
595 struct GNUNET_TIME_Absolute expire, 596 struct GNUNET_TIME_Absolute expire,
596 const char *label, 597 const char *label,
597 const struct GNUNET_GNSRECORD_Data *rd, 598 const struct GNUNET_GNSRECORD_Data *rd,
@@ -616,7 +617,7 @@ GNUNET_GNSRECORD_block_create (const struct GNUNET_IDENTITY_PrivateKey *key,
616 */ 617 */
617enum GNUNET_GenericReturnValue 618enum GNUNET_GenericReturnValue
618GNUNET_GNSRECORD_block_create_unsigned (const struct 619GNUNET_GNSRECORD_block_create_unsigned (const struct
619 GNUNET_IDENTITY_PrivateKey *key, 620 GNUNET_CRYPTO_PrivateKey *key,
620 struct GNUNET_TIME_Absolute expire, 621 struct GNUNET_TIME_Absolute expire,
621 const char *label, 622 const char *label,
622 const struct GNUNET_GNSRECORD_Data *rd, 623 const struct GNUNET_GNSRECORD_Data *rd,
@@ -638,7 +639,7 @@ GNUNET_GNSRECORD_block_create_unsigned (const struct
638 * @return GNUNET_OK on success. 639 * @return GNUNET_OK on success.
639 */ 640 */
640enum GNUNET_GenericReturnValue 641enum GNUNET_GenericReturnValue
641GNUNET_GNSRECORD_block_create2 (const struct GNUNET_IDENTITY_PrivateKey *key, 642GNUNET_GNSRECORD_block_create2 (const struct GNUNET_CRYPTO_PrivateKey *key,
642 struct GNUNET_TIME_Absolute expire, 643 struct GNUNET_TIME_Absolute expire,
643 const char *label, 644 const char *label,
644 const struct GNUNET_GNSRECORD_Data *rd, 645 const struct GNUNET_GNSRECORD_Data *rd,
@@ -653,7 +654,7 @@ GNUNET_GNSRECORD_block_create2 (const struct GNUNET_IDENTITY_PrivateKey *key,
653 * @param block block to verify 654 * @param block block to verify
654 * @return #GNUNET_OK if the signature is valid 655 * @return #GNUNET_OK if the signature is valid
655 */ 656 */
656int 657enum GNUNET_GenericReturnValue
657GNUNET_GNSRECORD_block_verify (const struct GNUNET_GNSRECORD_Block *block); 658GNUNET_GNSRECORD_block_verify (const struct GNUNET_GNSRECORD_Block *block);
658 659
659 660
@@ -668,10 +669,10 @@ GNUNET_GNSRECORD_block_verify (const struct GNUNET_GNSRECORD_Block *block);
668 * @return #GNUNET_OK on success, #GNUNET_SYSERR if the block was 669 * @return #GNUNET_OK on success, #GNUNET_SYSERR if the block was
669 * not well-formed 670 * not well-formed
670 */ 671 */
671int 672enum GNUNET_GenericReturnValue
672GNUNET_GNSRECORD_block_decrypt ( 673GNUNET_GNSRECORD_block_decrypt (
673 const struct GNUNET_GNSRECORD_Block *block, 674 const struct GNUNET_GNSRECORD_Block *block,
674 const struct GNUNET_IDENTITY_PublicKey *zone_key, const char *label, 675 const struct GNUNET_CRYPTO_PublicKey *zone_key, const char *label,
675 GNUNET_GNSRECORD_RecordCallback proc, void *proc_cls); 676 GNUNET_GNSRECORD_RecordCallback proc, void *proc_cls);
676 677
677 678
@@ -682,7 +683,7 @@ GNUNET_GNSRECORD_block_decrypt (
682 * @param b another record 683 * @param b another record
683 * @return #GNUNET_YES if the records are equal, or #GNUNET_NO if not. 684 * @return #GNUNET_YES if the records are equal, or #GNUNET_NO if not.
684 */ 685 */
685int 686enum GNUNET_GenericReturnValue
686GNUNET_GNSRECORD_records_cmp (const struct GNUNET_GNSRECORD_Data *a, 687GNUNET_GNSRECORD_records_cmp (const struct GNUNET_GNSRECORD_Data *a,
687 const struct GNUNET_GNSRECORD_Data *b); 688 const struct GNUNET_GNSRECORD_Data *b);
688 689
@@ -751,7 +752,7 @@ enum GNUNET_GenericReturnValue
751GNUNET_GNSRECORD_identity_from_data (const char *data, 752GNUNET_GNSRECORD_identity_from_data (const char *data,
752 size_t data_size, 753 size_t data_size,
753 uint32_t type, 754 uint32_t type,
754 struct GNUNET_IDENTITY_PublicKey *key); 755 struct GNUNET_CRYPTO_PublicKey *key);
755 756
756 757
757/** 758/**
@@ -765,7 +766,7 @@ GNUNET_GNSRECORD_identity_from_data (const char *data,
765 */ 766 */
766enum GNUNET_GenericReturnValue 767enum GNUNET_GenericReturnValue
767GNUNET_GNSRECORD_data_from_identity (const struct 768GNUNET_GNSRECORD_data_from_identity (const struct
768 GNUNET_IDENTITY_PublicKey *key, 769 GNUNET_CRYPTO_PublicKey *key,
769 char **data, 770 char **data,
770 size_t *data_size, 771 size_t *data_size,
771 uint32_t *type); 772 uint32_t *type);
@@ -828,6 +829,135 @@ GNUNET_GNSRECORD_normalize_record_set (const char *label,
828enum GNUNET_GenericReturnValue 829enum GNUNET_GenericReturnValue
829GNUNET_GNSRECORD_label_check (const char*label, char **emsg); 830GNUNET_GNSRECORD_label_check (const char*label, char **emsg);
830 831
832/**
833 * Maximum length of a revocation
834 */
835#define GNUNET_MAX_POW_SIZE sizeof(struct GNUNET_GNSRECORD_PowP) +\
836 sizeof(struct GNUNET_CRYPTO_PublicKey) +\
837 1024 //FIXME max sig_len
838
839/**
840 * The proof-of-work narrowing factor.
841 * The number of PoWs that are calculates as part of revocation.
842 */
843#define POW_COUNT 32
844
845
846GNUNET_NETWORK_STRUCT_BEGIN
847
848/**
849 * Struct for a proof of work as part of the revocation.
850 */
851struct GNUNET_GNSRECORD_PowP
852{
853 /**
854 * The timestamp of the revocation
855 */
856 struct GNUNET_TIME_AbsoluteNBO timestamp;
857
858 /**
859 * The TTL of this revocation (purely informational)
860 */
861 struct GNUNET_TIME_RelativeNBO ttl;
862
863 /**
864 * The PoWs
865 */
866 uint64_t pow[POW_COUNT] GNUNET_PACKED;
867
868 /** followed by the public key type, the key and a signature **/
869};
870
871
872/**
873 * The signature object we use for the PoW
874 */
875struct GNUNET_GNSRECORD_SignaturePurposePS
876{
877 /**
878 * The signature purpose
879 */
880 struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
881
882 /**
883 * The timestamp of the revocation
884 */
885 struct GNUNET_TIME_AbsoluteNBO timestamp;
886
887 /** Followed by the zone public key type and key **/
888};
889
890GNUNET_NETWORK_STRUCT_END
891
892
893/**
894 * Handle to a running proof-of-work calculation.
895 */
896struct GNUNET_GNSRECORD_PowCalculationHandle;
897
898
899/**
900 * Check if the given proof-of-work is valid.
901 *
902 * @param pow proof of work
903 * @param matching_bits how many bits must match (configuration)
904 * @param epoch_duration length of single epoch in configuration
905 * @return #GNUNET_YES if the @a pow is acceptable, #GNUNET_NO if not
906 */
907enum GNUNET_GenericReturnValue
908GNUNET_GNSRECORD_check_pow (const struct GNUNET_GNSRECORD_PowP *pow,
909 unsigned int matching_bits,
910 struct GNUNET_TIME_Relative epoch_duration);
911
912
913/**
914 * Initializes a fresh PoW computation.
915 *
916 * @param key the key to calculate the PoW for.
917 * @param pow the pow object to work with in the calculation.
918 */
919void
920GNUNET_GNSRECORD_pow_init (const struct GNUNET_CRYPTO_PrivateKey *key,
921 struct GNUNET_GNSRECORD_PowP *pow);
922
923
924/**
925 * Starts a proof-of-work calculation given the pow object as well as
926 * target epochs and difficulty.
927 *
928 * @param pow the PoW to based calculations on.
929 * @param epochs the number of epochs for which the PoW must be valid.
930 * @param difficulty the base difficulty of the PoW.
931 * @return a handle for use in PoW rounds
932 */
933struct GNUNET_GNSRECORD_PowCalculationHandle*
934GNUNET_GNSRECORD_pow_start (struct GNUNET_GNSRECORD_PowP *pow,
935 int epochs,
936 unsigned int difficulty);
937
938
939/**
940 * Calculate a single round in the key revocation PoW.
941 *
942 * @param pc handle to the PoW, initially called with NULL.
943 * @return GNUNET_YES if the @a pow is acceptable, GNUNET_NO if not
944 */
945enum GNUNET_GenericReturnValue
946GNUNET_GNSRECORD_pow_round (struct GNUNET_GNSRECORD_PowCalculationHandle *pc);
947
948size_t
949GNUNET_GNSRECORD_proof_get_size (const struct GNUNET_GNSRECORD_PowP *pow);
950
951/**
952 * Stop a PoW calculation
953 *
954 * @param pc the calculation to clean up
955 * @return #GNUNET_YES if pow valid, #GNUNET_NO if pow was set but is not
956 * valid
957 */
958void
959GNUNET_GNSRECORD_pow_stop (struct GNUNET_GNSRECORD_PowCalculationHandle *pc);
960
831#if 0 /* keep Emacsens' auto-indent happy */ 961#if 0 /* keep Emacsens' auto-indent happy */
832{ 962{
833#endif 963#endif
diff --git a/src/include/gnunet_hello_lib.h b/src/include/gnunet_hello_lib.h
deleted file mode 100644
index 20a61cbfb..000000000
--- a/src/include/gnunet_hello_lib.h
+++ /dev/null
@@ -1,545 +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 * @addtogroup Backbone
23 * @{
24 *
25 * @author Christian Grothoff
26 * @file
27 * Helper library for handling HELLOs
28 *
29 * @defgroup hello Hello library
30 * Helper library for handling HELLOs
31 *
32 * @see [Documentation](https://gnunet.org/gnunets-hostlist-subsystem)
33 *
34 * @{
35 */
36
37#ifndef GNUNET_HELLO_LIB_H
38#define GNUNET_HELLO_LIB_H
39
40#ifdef __cplusplus
41extern "C" {
42#if 0 /* keep Emacsens' auto-indent happy */
43}
44#endif
45#endif
46
47
48#include "gnunet_util_lib.h"
49
50/**
51 * Prefix that every HELLO URI must start with.
52 */
53#define GNUNET_HELLO_URI_PREFIX "gnunet://hello/"
54
55/**
56 * Prefix that every FRIEND HELLO URI must start with.
57 */
58#define GNUNET_FRIEND_HELLO_URI_PREFIX "gnunet://friend-hello/"
59
60/**
61 * Separator used in HELLO URI
62 */
63#define GNUNET_HELLO_URI_SEP '+'
64
65
66/**
67 * Additional local information about an address
68 *
69 * These information are only valid for the local peer and are not serialized
70 * when a #GNUNET_HELLO_Message is created
71 */
72enum GNUNET_HELLO_AddressInfo
73{
74 /**
75 * No additional information
76 */
77 GNUNET_HELLO_ADDRESS_INFO_NONE = 0,
78
79 /**
80 * This is an inbound address and cannot be used to initiate an outbound
81 * connection to another peer
82 */
83 GNUNET_HELLO_ADDRESS_INFO_INBOUND = 1
84};
85
86
87/**
88 * An address for communicating with a peer. We frequently
89 * need this tuple and the components cannot really be
90 * separated. This is NOT the format that would be used
91 * on the wire.
92 */
93struct GNUNET_HELLO_Address
94{
95 /**
96 * For which peer is this an address?
97 */
98 struct GNUNET_PeerIdentity peer;
99
100 /**
101 * Name of the transport plugin enabling the communication using
102 * this address.
103 */
104 const char *transport_name;
105
106 /**
107 * Binary representation of the address (plugin-specific).
108 */
109 const void *address;
110
111 /**
112 * Number of bytes in @e address.
113 */
114 size_t address_length;
115
116 /**
117 * Extended information about address
118 *
119 * This field contains additional #GNUNET_HELLO_AddressInfo flags e.g.
120 * to indicate an address is inbound and cannot be used to initiate an
121 * outbound connection.
122 *
123 * These information are only valid for the local peer and are not serialized
124 * when a #GNUNET_HELLO_Message is created
125 */
126 enum GNUNET_HELLO_AddressInfo local_info;
127};
128
129
130/**
131 * Allocate an address struct.
132 *
133 * @param peer the peer
134 * @param transport_name plugin name
135 * @param address binary address
136 * @param address_length number of bytes in @a address
137 * @param local_info additional local information for the address
138 * @return the address struct
139 */
140struct GNUNET_HELLO_Address *
141GNUNET_HELLO_address_allocate (const struct GNUNET_PeerIdentity *peer,
142 const char *transport_name,
143 const void *address,
144 size_t address_length,
145 enum GNUNET_HELLO_AddressInfo local_info);
146
147
148/**
149 * Copy an address struct.
150 *
151 * @param address address to copy
152 * @return a copy of the address struct
153 */
154struct GNUNET_HELLO_Address *
155GNUNET_HELLO_address_copy (const struct GNUNET_HELLO_Address *address);
156
157
158/**
159 * Compare two addresses. Does NOT compare the peer identity,
160 * that is assumed already to match!
161 *
162 * @param a1 first address
163 * @param a2 second address
164 * @return 0 if the addresses are equal, -1 if @a a1< @a a2, 1 if @a a1> @a a2.
165 */
166int
167GNUNET_HELLO_address_cmp (const struct GNUNET_HELLO_Address *a1,
168 const struct GNUNET_HELLO_Address *a2);
169
170
171/**
172 * Get the size of an address struct.
173 *
174 * @param address address
175 * @return the size
176 */
177size_t
178GNUNET_HELLO_address_get_size (const struct GNUNET_HELLO_Address *address);
179
180
181/**
182 * Check if an address has a local option set
183 *
184 * @param address the address to check
185 * @param option the respective option to check for
186 * @return #GNUNET_YES or #GNUNET_NO
187 */
188int
189GNUNET_HELLO_address_check_option (const struct GNUNET_HELLO_Address *address,
190 enum GNUNET_HELLO_AddressInfo option);
191
192
193/**
194 * Free an address.
195 *
196 * @param addr address to free
197 */
198#define GNUNET_HELLO_address_free(addr) GNUNET_free (addr)
199
200
201GNUNET_NETWORK_STRUCT_BEGIN
202
203/**
204 * A HELLO message is used to exchange information about
205 * transports with other peers. This struct is always
206 * followed by the actual network addresses which have
207 * the format:
208 *
209 * 1) transport-name (0-terminated)
210 * 2) address-length (uint16_t, network byte order; possibly
211 * unaligned!)
212 * 3) address expiration (`struct GNUNET_TIME_AbsoluteNBO`); possibly
213 * unaligned!)
214 * 4) address (address-length bytes; possibly unaligned!)
215 */
216struct GNUNET_HELLO_Message
217{
218 /**
219 * Type will be #GNUNET_MESSAGE_TYPE_HELLO.
220 */
221 struct GNUNET_MessageHeader header;
222
223 /**
224 * Use in F2F mode: Do not gossip this HELLO message
225 */
226 uint32_t friend_only GNUNET_PACKED;
227
228 /**
229 * The public key of the peer.
230 */
231 struct GNUNET_CRYPTO_EddsaPublicKey publicKey;
232};
233GNUNET_NETWORK_STRUCT_END
234
235
236/**
237 * Return HELLO type
238 *
239 * @param h HELLO Message to test
240 * @return #GNUNET_YES for friend-only or #GNUNET_NO otherwise
241 */
242int
243GNUNET_HELLO_is_friend_only (const struct GNUNET_HELLO_Message *h);
244
245
246/**
247 * Copy the given address information into
248 * the given buffer using the format of HELLOs.
249 *
250 * @param address address to add
251 * @param expiration expiration for the address
252 * @param target where to copy the address
253 * @param max maximum number of bytes to copy to @a target
254 * @return number of bytes copied, 0 if
255 * the target buffer was not big enough.
256 */
257size_t
258GNUNET_HELLO_add_address (const struct GNUNET_HELLO_Address *address,
259 struct GNUNET_TIME_Absolute expiration,
260 char *target,
261 size_t max);
262
263
264/**
265 * Callback function used to fill a buffer of max bytes with a list of
266 * addresses in the format used by HELLOs. Should use
267 * #GNUNET_HELLO_add_address() as a helper function.
268 *
269 * @param cls closure
270 * @param max maximum number of bytes that can be written to @a buf
271 * @param buf where to write the address information
272 * @return number of bytes written or 0, #GNUNET_SYSERR to signal the
273 * end of the iteration.
274 */
275typedef ssize_t
276(*GNUNET_HELLO_GenerateAddressListCallback) (void *cls,
277 size_t max,
278 void *buf);
279
280
281/**
282 * Construct a HELLO message given the public key,
283 * expiration time and an iterator that spews the
284 * transport addresses.
285 *
286 * If friend only is set to #GNUNET_YES we create a FRIEND_HELLO which
287 * will not be gossiped to other peers.
288 *
289 * @param public_key public key to include in the HELLO
290 * @param addrgen callback to invoke to get addresses
291 * @param addrgen_cls closure for @a addrgen
292 * @param friend_only should the returned HELLO be only visible to friends?
293 * @return the hello message
294 */
295struct GNUNET_HELLO_Message *
296GNUNET_HELLO_create (const struct GNUNET_CRYPTO_EddsaPublicKey *public_key,
297 GNUNET_HELLO_GenerateAddressListCallback addrgen,
298 void *addrgen_cls,
299 int friend_only);
300
301
302/**
303 * Return the size of the given HELLO message.
304 *
305 * @param hello to inspect
306 * @return the size, 0 if HELLO is invalid
307 */
308uint16_t
309GNUNET_HELLO_size (const struct GNUNET_HELLO_Message *hello);
310
311
312/**
313 * Construct a HELLO message by merging the
314 * addresses in two existing HELLOs (which
315 * must be for the same peer).
316 *
317 * @param h1 first HELLO message
318 * @param h2 the second HELLO message
319 * @return the combined hello message
320 */
321struct GNUNET_HELLO_Message *
322GNUNET_HELLO_merge (const struct GNUNET_HELLO_Message *h1,
323 const struct GNUNET_HELLO_Message *h2);
324
325
326/**
327 * Test if two HELLO messages contain the same addresses.
328 * If they only differ in expiration time, the lowest
329 * expiration time larger than 'now' where they differ
330 * is returned.
331 *
332 * @param h1 first HELLO message
333 * @param h2 the second HELLO message
334 * @param now time to use for deciding which addresses have
335 * expired and should not be considered at all
336 * @return absolute time forever if the two HELLOs are
337 * totally identical; smallest timestamp >= now if
338 * they only differ in timestamps;
339 * zero if the some addresses with expirations >= now
340 * do not match at all
341 */
342struct GNUNET_TIME_Absolute
343GNUNET_HELLO_equals (const struct GNUNET_HELLO_Message *h1,
344 const struct GNUNET_HELLO_Message *h2,
345 struct GNUNET_TIME_Absolute now);
346
347
348/**
349 * Iterator callback to go over all addresses.
350 *
351 * @param cls closure
352 * @param address the address
353 * @param expiration expiration time
354 * @return #GNUNET_OK to keep the address,
355 * #GNUNET_NO to delete it from the HELLO
356 * #GNUNET_SYSERR to stop iterating (but keep current address)
357 */
358typedef int (*GNUNET_HELLO_AddressIterator) (
359 void *cls,
360 const struct GNUNET_HELLO_Address *address,
361 struct GNUNET_TIME_Absolute expiration);
362
363
364/**
365 * When does the last address in the given HELLO expire?
366 *
367 * @param msg HELLO to inspect
368 * @return time the last address expires, 0 if there are no addresses in the HELLO
369 */
370struct GNUNET_TIME_Absolute
371GNUNET_HELLO_get_last_expiration (const struct GNUNET_HELLO_Message *msg);
372
373
374/**
375 * Iterate over all of the addresses in the HELLO.
376 *
377 * @param msg HELLO to iterate over; client does not need to
378 * have verified that msg is well-formed (beyond starting
379 * with a GNUNET_MessageHeader of the right type).
380 * @param return_modified if a modified copy should be returned,
381 * otherwise NULL will be returned
382 * @param it iterator to call on each address
383 * @param it_cls closure for @a it
384 * @return the modified HELLO or NULL
385 */
386struct GNUNET_HELLO_Message *
387GNUNET_HELLO_iterate_addresses (const struct GNUNET_HELLO_Message *msg,
388 int return_modified,
389 GNUNET_HELLO_AddressIterator it,
390 void *it_cls);
391
392
393/**
394 * Iterate over addresses in @a new_hello that are NOT already present
395 * in @a old_hello. Note that if the address is present in @a old_hello
396 * but the expiration time in @a new_hello is more recent, the
397 * iterator is also called.
398 *
399 * @param new_hello a HELLO message
400 * @param old_hello a HELLO message
401 * @param expiration_limit ignore addresses in old_hello
402 * that expired before the given time stamp
403 * @param it iterator to call on each address
404 * @param it_cls closure for @a it
405 */
406void
407GNUNET_HELLO_iterate_new_addresses (
408 const struct GNUNET_HELLO_Message *new_hello,
409 const struct GNUNET_HELLO_Message *old_hello,
410 struct GNUNET_TIME_Absolute expiration_limit,
411 GNUNET_HELLO_AddressIterator it,
412 void *it_cls);
413
414
415/**
416 * Get the peer identity from a HELLO message.
417 *
418 * @param hello the hello message
419 * @param peer where to store the peer's identity
420 * @return #GNUNET_SYSERR if the HELLO was malformed
421 */
422int
423GNUNET_HELLO_get_id (const struct GNUNET_HELLO_Message *hello,
424 struct GNUNET_PeerIdentity *peer);
425
426
427/**
428 * Get the header from a HELLO message, used so other code
429 * can correctly send HELLO messages.
430 *
431 * @param hello the hello message
432 *
433 * @return header or NULL if the HELLO was malformed
434 */
435struct GNUNET_MessageHeader *
436GNUNET_HELLO_get_header (struct GNUNET_HELLO_Message *hello);
437
438
439/**
440 * Helper function to load/access transport plugins.
441 * FIXME: pass closure!
442 *
443 * @param name name of the transport plugin to load
444 * @return NULL if a plugin with name @a name is not known/loadable
445 */
446typedef struct GNUNET_TRANSPORT_PluginFunctions *(
447*GNUNET_HELLO_TransportPluginsFind) (const char *name);
448
449
450/**
451 * Compose a hello URI string from a hello message.
452 *
453 * @param hello Hello message
454 * @param plugins_find Function to find transport plugins by name
455 * @return Hello URI string
456 */
457char *
458GNUNET_HELLO_compose_uri (const struct GNUNET_HELLO_Message *hello,
459 GNUNET_HELLO_TransportPluginsFind plugins_find);
460
461
462/**
463 * Parse a hello URI string to a hello message.
464 *
465 * @param uri URI string to parse
466 * @param pubkey Pointer to struct where public key is parsed
467 * @param hello Pointer to struct where hello message is parsed
468 * @param plugins_find Function to find transport plugins by name
469 * @return #GNUNET_OK on success, #GNUNET_SYSERR if the URI was invalid, #GNUNET_NO on other errors
470 */
471int
472GNUNET_HELLO_parse_uri (const char *uri,
473 struct GNUNET_CRYPTO_EddsaPublicKey *pubkey,
474 struct GNUNET_HELLO_Message **hello,
475 GNUNET_HELLO_TransportPluginsFind plugins_find);
476
477
478/* NG API */
479#include "gnunet_nt_lib.h"
480
481
482/**
483 * Build address record by signing raw information with private key.
484 *
485 * @param address text address to sign
486 * @param nt network type of @a address
487 * @param mono_time when was @a address valid
488 * @param private_key signing key to use
489 * @param[out] result where to write address record (allocated)
490 * @param[out] result_size set to size of @a result
491 */
492void
493GNUNET_HELLO_sign_address (
494 const char *address,
495 enum GNUNET_NetworkType nt,
496 struct GNUNET_TIME_Absolute mono_time,
497 const struct GNUNET_CRYPTO_EddsaPrivateKey *private_key,
498 void **result,
499 size_t *result_size);
500
501
502/**
503 * Check signature and extract address record.
504 *
505 * @param raw raw signed address
506 * @param raw_size size of @a raw
507 * @param pid public key to use for signature verification
508 * @param[out] nt set to network type
509 * @param[out] mono_time when was the address generated
510 * @return NULL on error, otherwise the address
511 */
512char *
513GNUNET_HELLO_extract_address (const void *raw,
514 size_t raw_size,
515 const struct GNUNET_PeerIdentity *pid,
516 enum GNUNET_NetworkType *nt,
517 struct GNUNET_TIME_Absolute *mono_time);
518
519
520/**
521 * Given an address as a string, extract the prefix that identifies
522 * the communicator offering transmissions to that address.
523 *
524 * @param address a peer's address
525 * @return NULL if the address is mal-formed, otherwise the prefix
526 */
527char *
528GNUNET_HELLO_address_to_prefix (const char *address);
529
530
531#if 0 /* keep Emacsens' auto-indent happy */
532{
533#endif
534#ifdef __cplusplus
535}
536#endif
537
538/* ifndef GNUNET_HELLO_LIB_H */
539#endif
540
541/** @} */ /* end of group */
542
543/** @} */ /* end of group addition */
544
545/* 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 bba7078e6..aecda0885 100644
--- a/src/include/gnunet_hello_uri_lib.h
+++ b/src/include/gnunet_hello_uri_lib.h
@@ -70,6 +70,13 @@ GNUNET_HELLO_builder_new (const struct GNUNET_PeerIdentity *pid);
70 70
71 71
72/** 72/**
73 * Get the PeerIdentity for this builder.
74 */
75const struct GNUNET_PeerIdentity *
76GNUNET_HELLO_builder_get_id (const struct GNUNET_HELLO_Builder *builder);
77
78
79/**
73 * Release resources of a @a builder. 80 * Release resources of a @a builder.
74 * 81 *
75 * @param[in] builder to free 82 * @param[in] builder to free
@@ -111,6 +118,17 @@ GNUNET_HELLO_builder_from_url (const char *url);
111 118
112 119
113/** 120/**
121 * Get the expiration time for this HELLO.
122 *
123 * @param msg The hello msg.
124 * @return The expiration time.
125 */
126struct GNUNET_TIME_Absolute
127GNUNET_HELLO_builder_get_expiration_time (const struct
128 GNUNET_MessageHeader *msg);
129
130
131/**
114 * Generate envelope with GNUnet HELLO message (including 132 * Generate envelope with GNUnet HELLO message (including
115 * peer ID) from a @a builder 133 * peer ID) from a @a builder
116 * 134 *
@@ -120,7 +138,8 @@ GNUNET_HELLO_builder_from_url (const char *url);
120 */ 138 */
121struct GNUNET_MQ_Envelope * 139struct GNUNET_MQ_Envelope *
122GNUNET_HELLO_builder_to_env (const struct GNUNET_HELLO_Builder *builder, 140GNUNET_HELLO_builder_to_env (const struct GNUNET_HELLO_Builder *builder,
123 const struct GNUNET_CRYPTO_EddsaPrivateKey *priv); 141 const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
142 struct GNUNET_TIME_Relative expiration_time);
124 143
125 144
126/** 145/**
@@ -133,7 +152,8 @@ GNUNET_HELLO_builder_to_env (const struct GNUNET_HELLO_Builder *builder,
133struct GNUNET_MessageHeader * 152struct GNUNET_MessageHeader *
134GNUNET_HELLO_builder_to_dht_hello_msg ( 153GNUNET_HELLO_builder_to_dht_hello_msg (
135 const struct GNUNET_HELLO_Builder *builder, 154 const struct GNUNET_HELLO_Builder *builder,
136 const struct GNUNET_CRYPTO_EddsaPrivateKey *priv); 155 const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
156 struct GNUNET_TIME_Relative expiration_time);
137 157
138 158
139/** 159/**
@@ -162,7 +182,8 @@ enum GNUNET_GenericReturnValue
162GNUNET_HELLO_builder_to_block (const struct GNUNET_HELLO_Builder *builder, 182GNUNET_HELLO_builder_to_block (const struct GNUNET_HELLO_Builder *builder,
163 const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, 183 const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
164 void *block, 184 void *block,
165 size_t *block_size); 185 size_t *block_size,
186 struct GNUNET_TIME_Relative expiration_time);
166 187
167 188
168/** 189/**
@@ -199,6 +220,7 @@ GNUNET_HELLO_builder_del_address (struct GNUNET_HELLO_Builder *builder,
199 */ 220 */
200typedef void 221typedef void
201(*GNUNET_HELLO_UriCallback) (void *cls, 222(*GNUNET_HELLO_UriCallback) (void *cls,
223 const struct GNUNET_PeerIdentity* pid,
202 const char *uri); 224 const char *uri);
203 225
204 226
@@ -206,13 +228,12 @@ typedef void
206 * Iterate over URIs in a builder. 228 * Iterate over URIs in a builder.
207 * 229 *
208 * @param builder builder to iterate over 230 * @param builder builder to iterate over
209 * @param[out] pid set to the peer the @a builder is for
210 * @param uc callback invoked for each URI, can be NULL 231 * @param uc callback invoked for each URI, can be NULL
211 * @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
212 */ 234 */
213void 235const struct GNUNET_PeerIdentity *
214GNUNET_HELLO_builder_iterate (const struct GNUNET_HELLO_Builder *builder, 236GNUNET_HELLO_builder_iterate (const struct GNUNET_HELLO_Builder *builder,
215 struct GNUNET_PeerIdentity *pid,
216 GNUNET_HELLO_UriCallback uc, 237 GNUNET_HELLO_UriCallback uc,
217 void *uc_cls); 238 void *uc_cls);
218 239
@@ -237,6 +258,35 @@ GNUNET_HELLO_dht_msg_to_block (const struct GNUNET_MessageHeader *hello,
237 struct GNUNET_TIME_Absolute *block_expiration); 258 struct GNUNET_TIME_Absolute *block_expiration);
238 259
239 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 */
268char *
269GNUNET_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 */
281void
282GNUNET_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
240#if 0 /* keep Emacsens' auto-indent happy */ 290#if 0 /* keep Emacsens' auto-indent happy */
241{ 291{
242#endif 292#endif
diff --git a/src/include/gnunet_identity_service.h b/src/include/gnunet_identity_service.h
index d4192a77f..270f4d26f 100644
--- a/src/include/gnunet_identity_service.h
+++ b/src/include/gnunet_identity_service.h
@@ -62,20 +62,6 @@ extern "C" {
62 */ 62 */
63#define GNUNET_IDENTITY_VERSION 0x00000100 63#define GNUNET_IDENTITY_VERSION 0x00000100
64 64
65enum GNUNET_IDENTITY_KeyType
66{
67 /**
68 * The identity type. The value is the same as the
69 * PKEY record type.
70 */
71 GNUNET_IDENTITY_TYPE_ECDSA = 65536,
72
73 /**
74 * EDDSA identity. The value is the same as the EDKEY
75 * record type.
76 */
77 GNUNET_IDENTITY_TYPE_EDDSA = 65556
78};
79 65
80/** 66/**
81 * Handle to access the identity service. 67 * Handle to access the identity service.
@@ -88,89 +74,6 @@ struct GNUNET_IDENTITY_Handle;
88struct GNUNET_IDENTITY_Ego; 74struct GNUNET_IDENTITY_Ego;
89 75
90/** 76/**
91 * A private key for an identity as per LSD0001.
92 * Note that these types are NOT packed and MUST NOT be used in RPC
93 * messages. Use the respective serialization functions.
94 */
95struct GNUNET_IDENTITY_PrivateKey
96{
97 /**
98 * Type of public key.
99 * Defined by the GNS zone type value.
100 * In NBO.
101 */
102 uint32_t type;
103
104 union
105 {
106 /**
107 * An ECDSA identity key.
108 */
109 struct GNUNET_CRYPTO_EcdsaPrivateKey ecdsa_key;
110
111 /**
112 * AN EdDSA identtiy key
113 */
114 struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_key;
115 };
116};
117
118
119/**
120 * An identity key as per LSD0001.
121 */
122struct GNUNET_IDENTITY_PublicKey
123{
124 /**
125 * Type of public key.
126 * Defined by the GNS zone type value.
127 * In NBO.
128 */
129 uint32_t type;
130
131 union
132 {
133 /**
134 * An ECDSA identity key.
135 */
136 struct GNUNET_CRYPTO_EcdsaPublicKey ecdsa_key;
137
138 /**
139 * AN EdDSA identtiy key
140 */
141 struct GNUNET_CRYPTO_EddsaPublicKey eddsa_key;
142 };
143};
144
145
146/**
147 * An identity signature as per LSD0001.
148 */
149struct GNUNET_IDENTITY_Signature
150{
151 /**
152 * Type of signature.
153 * Defined by the GNS zone type value.
154 * In NBO.
155 */
156 uint32_t type;
157
158 union
159 {
160 /**
161 * An ECDSA signature
162 */
163 struct GNUNET_CRYPTO_EcdsaSignature ecdsa_signature;
164
165 /**
166 * AN EdDSA signature
167 */
168 struct GNUNET_CRYPTO_EddsaSignature eddsa_signature;
169 };
170};
171
172
173/**
174 * Handle for an operation with the identity service. 77 * Handle for an operation with the identity service.
175 */ 78 */
176struct GNUNET_IDENTITY_Operation; 79struct GNUNET_IDENTITY_Operation;
@@ -182,7 +85,7 @@ struct GNUNET_IDENTITY_Operation;
182 * @param ego the ego 85 * @param ego the ego
183 * @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
184 */ 87 */
185const struct GNUNET_IDENTITY_PrivateKey * 88const struct GNUNET_CRYPTO_PrivateKey *
186GNUNET_IDENTITY_ego_get_private_key (const struct GNUNET_IDENTITY_Ego *ego); 89GNUNET_IDENTITY_ego_get_private_key (const struct GNUNET_IDENTITY_Ego *ego);
187 90
188 91
@@ -203,7 +106,7 @@ GNUNET_IDENTITY_ego_get_anonymous (void);
203 */ 106 */
204void 107void
205GNUNET_IDENTITY_ego_get_public_key (struct GNUNET_IDENTITY_Ego *ego, 108GNUNET_IDENTITY_ego_get_public_key (struct GNUNET_IDENTITY_Ego *ego,
206 struct GNUNET_IDENTITY_PublicKey *pk); 109 struct GNUNET_CRYPTO_PublicKey *pk);
207 110
208 111
209/** 112/**
@@ -336,7 +239,7 @@ GNUNET_IDENTITY_disconnect (struct GNUNET_IDENTITY_Handle *h);
336typedef void 239typedef void
337(*GNUNET_IDENTITY_CreateContinuation) ( 240(*GNUNET_IDENTITY_CreateContinuation) (
338 void *cls, 241 void *cls,
339 const struct GNUNET_IDENTITY_PrivateKey *pk, 242 const struct GNUNET_CRYPTO_PrivateKey *pk,
340 enum GNUNET_ErrorCode ec); 243 enum GNUNET_ErrorCode ec);
341 244
342 245
@@ -354,8 +257,8 @@ typedef void
354struct GNUNET_IDENTITY_Operation * 257struct GNUNET_IDENTITY_Operation *
355GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *id, 258GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *id,
356 const char *name, 259 const char *name,
357 const struct GNUNET_IDENTITY_PrivateKey *privkey, 260 const struct GNUNET_CRYPTO_PrivateKey *privkey,
358 enum GNUNET_IDENTITY_KeyType ktype, 261 enum GNUNET_CRYPTO_KeyType ktype,
359 GNUNET_IDENTITY_CreateContinuation cont, 262 GNUNET_IDENTITY_CreateContinuation cont,
360 void *cont_cls); 263 void *cont_cls);
361 264
@@ -406,472 +309,6 @@ void
406GNUNET_IDENTITY_cancel (struct GNUNET_IDENTITY_Operation *op); 309GNUNET_IDENTITY_cancel (struct GNUNET_IDENTITY_Operation *op);
407 310
408 311
409/**
410 * Get the compacted length of a #GNUNET_IDENTITY_PublicKey.
411 * Compacted means that it returns the minimum number of bytes this
412 * key is long, as opposed to the union structure inside
413 * #GNUNET_IDENTITY_PublicKey.
414 * Useful for compact serializations.
415 *
416 * @param key the key.
417 * @return -1 on error, else the compacted length of the key.
418 */
419ssize_t
420GNUNET_IDENTITY_public_key_get_length (const struct
421 GNUNET_IDENTITY_PublicKey *key);
422
423/**
424 * Reads a #GNUNET_IDENTITY_PublicKey from a compact buffer.
425 * The buffer has to contain at least the compacted length of
426 * a #GNUNET_IDENTITY_PublicKey in bytes.
427 * If the buffer is too small, the function returns -1 as error.
428 * If the buffer does not contain a valid key, it returns -2 as error.
429 *
430 * @param buffer the buffer
431 * @param len the length of buffer
432 * @param key the key
433 * @param the amount of bytes read from the buffer
434 * @return #GNUNET_SYSERR on error
435 */
436enum GNUNET_GenericReturnValue
437GNUNET_IDENTITY_read_public_key_from_buffer (
438 const void *buffer,
439 size_t len,
440 struct GNUNET_IDENTITY_PublicKey *key,
441 size_t *read);
442
443/**
444 * Get the compacted length of a #GNUNET_IDENTITY_PrivateKey.
445 * Compacted means that it returns the minimum number of bytes this
446 * key is long, as opposed to the union structure inside
447 * #GNUNET_IDENTITY_PrivateKey.
448 * Useful for compact serializations.
449 *
450 * @param key the key.
451 * @return -1 on error, else the compacted length of the key.
452 */
453ssize_t
454GNUNET_IDENTITY_private_key_get_length (
455 const struct GNUNET_IDENTITY_PrivateKey *key);
456
457
458/**
459 * Writes a #GNUNET_IDENTITY_PublicKey to a compact buffer.
460 * The buffer requires space for at least the compacted length of
461 * a #GNUNET_IDENTITY_PublicKey in bytes.
462 * If the buffer is too small, the function returns -1 as error.
463 * If the key is not valid, it returns -2 as error.
464 *
465 * @param key the key
466 * @param buffer the buffer
467 * @param len the length of buffer
468 * @return -1 or -2 on error, else the amount of bytes written to the buffer
469 */
470ssize_t
471GNUNET_IDENTITY_write_public_key_to_buffer (const struct
472 GNUNET_IDENTITY_PublicKey *key,
473 void*buffer,
474 size_t len);
475
476
477/**
478 * Reads a #GNUNET_IDENTITY_PrivateKey from a compact buffer.
479 * The buffer has to contain at least the compacted length of
480 * a #GNUNET_IDENTITY_PrivateKey in bytes.
481 * If the buffer is too small, the function returns GNUNET_SYSERR as error.
482 *
483 * @param buffer the buffer
484 * @param len the length of buffer
485 * @param key the key
486 * @param the amount of bytes read from the buffer
487 * @return #GNUNET_SYSERR on error
488 */
489enum GNUNET_GenericReturnValue
490GNUNET_IDENTITY_read_private_key_from_buffer (
491 const void*buffer,
492 size_t len,
493 struct GNUNET_IDENTITY_PrivateKey *key,
494 size_t *read);
495
496
497/**
498 * Writes a #GNUNET_IDENTITY_PrivateKey to a compact buffer.
499 * The buffer requires space for at least the compacted length of
500 * a #GNUNET_IDENTITY_PrivateKey in bytes.
501 * If the buffer is too small, the function returns -1 as error.
502 * If the key is not valid, it returns -2 as error.
503 *
504 * @param key the key
505 * @param buffer the buffer
506 * @param len the length of buffer
507 * @return -1 or -2 on error, else the amount of bytes written to the buffer
508 */
509ssize_t
510GNUNET_IDENTITY_write_private_key_to_buffer (
511 const struct GNUNET_IDENTITY_PrivateKey *key,
512 void*buffer,
513 size_t len);
514
515
516/**
517 * Get the compacted length of a #GNUNET_IDENTITY_Signature.
518 * Compacted means that it returns the minimum number of bytes this
519 * signature is long, as opposed to the union structure inside
520 * #GNUNET_IDENTITY_Signature.
521 * Useful for compact serializations.
522 *
523 * @param sig the signature.
524 * @return -1 on error, else the compacted length of the signature.
525 */
526ssize_t
527GNUNET_IDENTITY_signature_get_length (
528 const struct GNUNET_IDENTITY_Signature *sig);
529
530
531/**
532 * Get the compacted length of a signature by type.
533 * Compacted means that it returns the minimum number of bytes this
534 * signature is long, as opposed to the union structure inside
535 * #GNUNET_IDENTITY_Signature.
536 * Useful for compact serializations.
537 *
538 * @param sig the signature.
539 * @return -1 on error, else the compacted length of the signature.
540 */
541ssize_t
542GNUNET_IDENTITY_signature_get_raw_length_by_type (uint32_t type);
543
544
545/**
546 * Reads a #GNUNET_IDENTITY_Signature from a compact buffer.
547 * The buffer has to contain at least the compacted length of
548 * a #GNUNET_IDENTITY_Signature in bytes.
549 * If the buffer is too small, the function returns -1 as error.
550 * If the buffer does not contain a valid key, it returns -2 as error.
551 *
552 * @param sig the signature
553 * @param buffer the buffer
554 * @param len the length of buffer
555 * @return -1 or -2 on error, else the amount of bytes read from the buffer
556 */
557ssize_t
558GNUNET_IDENTITY_read_signature_from_buffer (
559 struct GNUNET_IDENTITY_Signature *sig,
560 const void*buffer,
561 size_t len);
562
563
564/**
565 * Writes a #GNUNET_IDENTITY_Signature to a compact buffer.
566 * The buffer requires space for at least the compacted length of
567 * a #GNUNET_IDENTITY_Signature in bytes.
568 * If the buffer is too small, the function returns -1 as error.
569 * If the key is not valid, it returns -2 as error.
570 *
571 * @param sig the signature
572 * @param buffer the buffer
573 * @param len the length of buffer
574 * @return -1 or -2 on error, else the amount of bytes written to the buffer
575 */
576ssize_t
577GNUNET_IDENTITY_write_signature_to_buffer (
578 const struct GNUNET_IDENTITY_Signature *sig,
579 void*buffer,
580 size_t len);
581
582
583/**
584 * @brief Sign a given block.
585 *
586 * The @a purpose data is the beginning of the data of which the signature is
587 * to be created. The `size` field in @a purpose must correctly indicate the
588 * number of bytes of the data structure, including its header. If possible,
589 * use #GNUNET_IDENTITY_sign() instead of this function.
590 *
591 * @param priv private key to use for the signing
592 * @param purpose what to sign (size, purpose)
593 * @param[out] sig where to write the signature
594 * @return #GNUNET_SYSERR on error, #GNUNET_OK on success
595 */
596enum GNUNET_GenericReturnValue
597GNUNET_IDENTITY_sign_ (
598 const struct GNUNET_IDENTITY_PrivateKey *priv,
599 const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
600 struct GNUNET_IDENTITY_Signature *sig);
601
602/**
603 * @brief Sign a given block.
604 *
605 * The @a purpose data is the beginning of the data of which the signature is
606 * to be created. The `size` field in @a purpose must correctly indicate the
607 * number of bytes of the data structure, including its header.
608 * The signature payload and length depends on the key type.
609 *
610 * @param priv private key to use for the signing
611 * @param purpose what to sign (size, purpose)
612 * @param[out] sig where to write the signature
613 * @return #GNUNET_SYSERR on error, #GNUNET_OK on success
614 */
615enum GNUNET_GenericReturnValue
616GNUNET_IDENTITY_sign_raw_ (
617 const struct GNUNET_IDENTITY_PrivateKey *priv,
618 const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
619 unsigned char *sig);
620
621
622/**
623 * @brief Sign a given block with #GNUNET_IDENTITY_PrivateKey.
624 *
625 * The @a ps data must be a fixed-size struct for which the signature is to be
626 * created. The `size` field in @a ps->purpose must correctly indicate the
627 * number of bytes of the data structure, including its header.
628 *
629 * @param priv private key to use for the signing
630 * @param ps packed struct with what to sign, MUST begin with a purpose
631 * @param[out] sig where to write the signature
632 */
633#define GNUNET_IDENTITY_sign(priv,ps,sig) do { \
634 /* check size is set correctly */ \
635 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
636 /* check 'ps' begins with the purpose */ \
637 GNUNET_static_assert (((void*) (ps)) == \
638 ((void*) &(ps)->purpose)); \
639 GNUNET_assert (GNUNET_OK == \
640 GNUNET_IDENTITY_sign_ (priv, \
641 &(ps)->purpose, \
642 sig)); \
643} while (0)
644
645
646/**
647 * @brief Verify a given signature.
648 *
649 * The @a validate data is the beginning of the data of which the signature
650 * is to be verified. The `size` field in @a validate must correctly indicate
651 * the number of bytes of the data structure, including its header. If @a
652 * purpose does not match the purpose given in @a validate (the latter must be
653 * in big endian), signature verification fails. If possible,
654 * use #GNUNET_IDENTITY_signature_verify() instead of this function (only if @a validate
655 * is not fixed-size, you must use this function directly).
656 *
657 * @param purpose what is the purpose that the signature should have?
658 * @param validate block to validate (size, purpose, data)
659 * @param sig signature that is being validated
660 * @param pub public key of the signer
661 * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid
662 */
663enum GNUNET_GenericReturnValue
664GNUNET_IDENTITY_signature_verify_ (
665 uint32_t purpose,
666 const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
667 const struct GNUNET_IDENTITY_Signature *sig,
668 const struct GNUNET_IDENTITY_PublicKey *pub);
669
670/**
671 * @brief Verify a given signature.
672 *
673 * The @a validate data is the beginning of the data of which the signature
674 * is to be verified. The `size` field in @a validate must correctly indicate
675 * the number of bytes of the data structure, including its header. If @a
676 * purpose does not match the purpose given in @a validate (the latter must be
677 * in big endian), signature verification fails.
678 *
679 * @param purpose what is the purpose that the signature should have?
680 * @param validate block to validate (size, purpose, data)
681 * @param sig signature that is being validated
682 * @param pub public key of the signer
683 * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid
684 */
685enum GNUNET_GenericReturnValue
686GNUNET_IDENTITY_signature_verify_raw_ (
687 uint32_t purpose,
688 const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
689 const unsigned char *sig,
690 const struct GNUNET_IDENTITY_PublicKey *pub);
691
692
693/**
694 * @brief Verify a given signature with #GNUNET_IDENTITY_PublicKey.
695 *
696 * The @a ps data must be a fixed-size struct for which the signature is to be
697 * created. The `size` field in @a ps->purpose must correctly indicate the
698 * number of bytes of the data structure, including its header.
699 *
700 * @param purp purpose of the signature, must match 'ps->purpose.purpose'
701 * (except in host byte order)
702 * @param ps packed struct with what to sign, MUST begin with a purpose
703 * @param sig where to read the signature from
704 * @param pub public key to use for the verifying
705 */
706#define GNUNET_IDENTITY_signature_verify(purp,ps,sig,pub) ({ \
707 /* check size is set correctly */ \
708 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
709 /* check 'ps' begins with the purpose */ \
710 GNUNET_static_assert (((void*) (ps)) == \
711 ((void*) &(ps)->purpose)); \
712 GNUNET_IDENTITY_signature_verify_ (purp, \
713 &(ps)->purpose, \
714 sig, \
715 pub); \
716 })
717
718
719/**
720 * Encrypt a block with #GNUNET_IDENTITY_PublicKey and derives a
721 * #GNUNET_CRYPTO_EcdhePublicKey which is required for decryption
722 * using ecdh to derive a symmetric key.
723 *
724 * @param block the block to encrypt
725 * @param size the size of the @a block
726 * @param pub public key to use for ecdh
727 * @param ecc where to write the ecc public key
728 * @param result the output parameter in which to store the encrypted result
729 * can be the same or overlap with @c block
730 * @returns the size of the encrypted block, -1 for errors.
731 * Due to the use of CFB and therefore an effective stream cipher,
732 * this size should be the same as @c len.
733 */
734ssize_t
735GNUNET_IDENTITY_encrypt_old (const void *block,
736 size_t size,
737 const struct GNUNET_IDENTITY_PublicKey *pub,
738 struct GNUNET_CRYPTO_EcdhePublicKey *ecc,
739 void *result);
740
741
742/**
743 * Decrypt a given block with #GNUNET_IDENTITY_PrivateKey and a given
744 * #GNUNET_CRYPTO_EcdhePublicKey using ecdh to derive a symmetric key.
745 *
746 * @param block the data to decrypt, encoded as returned by encrypt
747 * @param size the size of the @a block to decrypt
748 * @param priv private key to use for ecdh
749 * @param ecc the ecc public key
750 * @param result address to store the result at
751 * can be the same or overlap with @c block
752 * @return -1 on failure, size of decrypted block on success.
753 * Due to the use of CFB and therefore an effective stream cipher,
754 * this size should be the same as @c size.
755 */
756ssize_t
757GNUNET_IDENTITY_decrypt_old (
758 const void *block,
759 size_t size,
760 const struct GNUNET_IDENTITY_PrivateKey *priv,
761 const struct GNUNET_CRYPTO_EcdhePublicKey *ecc,
762 void *result);
763
764#define GNUNET_IDENTITY_ENCRYPT_OVERHEAD_BYTES (crypto_secretbox_MACBYTES \
765 + sizeof (struct \
766 GNUNET_CRYPTO_FoKemC))
767
768/**
769 * Encrypt a block with #GNUNET_IDENTITY_PublicKey and derives a
770 * #GNUNET_CRYPTO_EcdhePublicKey which is required for decryption
771 * using ecdh to derive a symmetric key.
772 *
773 * Note that the result buffer for the ciphertext must be the length of
774 * the message to encrypt plus #GNUNET_IDENTITY_ENCRYPT_OVERHEAD_BYTES.
775 *
776 * @param block the block to encrypt
777 * @param size the size of the @a block
778 * @param pub public key to encrypt for
779 * @param result the output parameter in which to store the encrypted result
780 * can be the same or overlap with @c block
781 * @returns GNUNET_OK on success.
782 */
783enum GNUNET_GenericReturnValue
784GNUNET_IDENTITY_encrypt (const void *block,
785 size_t size,
786 const struct GNUNET_IDENTITY_PublicKey *pub,
787 void *result,
788 size_t result_size);
789
790
791/**
792 * Decrypt a given block with #GNUNET_IDENTITY_PrivateKey and a given
793 * #GNUNET_CRYPTO_EcdhePublicKey using ecdh to derive a symmetric key.
794 *
795 * @param block the data to decrypt, encoded as returned by encrypt
796 * @param size the size of the @a block to decrypt
797 * @param priv private key to use for ecdh
798 * @param result address to store the result at
799 * can be the same or overlap with @c block
800 * @returns GNUNET_OK on success.
801 */
802enum GNUNET_GenericReturnValue
803GNUNET_IDENTITY_decrypt (const void *block,
804 size_t size,
805 const struct GNUNET_IDENTITY_PrivateKey *priv,
806 void *result,
807 size_t result_size);
808
809
810/**
811 * Creates a (Base32) string representation of the public key.
812 * The resulting string encodes a compacted representation of the key.
813 * See also #GNUNET_IDENTITY_key_get_length.
814 *
815 * @param key the key.
816 * @return the string representation of the key, or NULL on error.
817 */
818char *
819GNUNET_IDENTITY_public_key_to_string (
820 const struct GNUNET_IDENTITY_PublicKey *key);
821
822
823/**
824 * Creates a (Base32) string representation of the private key.
825 * The resulting string encodes a compacted representation of the key.
826 * See also #GNUNET_IDENTITY_key_get_length.
827 *
828 * @param key the key.
829 * @return the string representation of the key, or NULL on error.
830 */
831char *
832GNUNET_IDENTITY_private_key_to_string (
833 const struct GNUNET_IDENTITY_PrivateKey *key);
834
835
836/**
837 * Parses a (Base32) string representation of the public key.
838 * See also #GNUNET_IDENTITY_public_key_to_string.
839 *
840 * @param str the encoded key.
841 * @param key where to write the key.
842 * @return GNUNET_SYSERR on error.
843 */
844enum GNUNET_GenericReturnValue
845GNUNET_IDENTITY_public_key_from_string (const char*str,
846 struct GNUNET_IDENTITY_PublicKey *key);
847
848
849/**
850 * Parses a (Base32) string representation of the private key.
851 * See also #GNUNET_IDENTITY_private_key_to_string.
852 *
853 * @param str the encoded key.
854 * @param key where to write the key.
855 * @return GNUNET_SYSERR on error.
856 */
857enum GNUNET_GenericReturnValue
858GNUNET_IDENTITY_private_key_from_string (const char*str,
859 struct GNUNET_IDENTITY_PrivateKey *key);
860
861
862/**
863 * Retrieves the public key representation of a private key.
864 *
865 * @param privkey the private key.
866 * @param key the public key result.
867 * @return GNUNET_SYSERR on error.
868 */
869enum GNUNET_GenericReturnValue
870GNUNET_IDENTITY_key_get_public (const struct
871 GNUNET_IDENTITY_PrivateKey *privkey,
872 struct GNUNET_IDENTITY_PublicKey *key);
873
874
875/* ************* convenience API to lookup an ego ***************** */ 312/* ************* convenience API to lookup an ego ***************** */
876 313
877/** 314/**
@@ -924,7 +361,7 @@ GNUNET_IDENTITY_ego_lookup_cancel (struct GNUNET_IDENTITY_EgoLookup *el);
924typedef void 361typedef void
925(*GNUNET_IDENTITY_EgoSuffixCallback) ( 362(*GNUNET_IDENTITY_EgoSuffixCallback) (
926 void *cls, 363 void *cls,
927 const struct GNUNET_IDENTITY_PrivateKey *priv, 364 const struct GNUNET_CRYPTO_PrivateKey *priv,
928 const char *ego_name); 365 const char *ego_name);
929 366
930 367
diff --git a/src/include/gnunet_json_lib.h b/src/include/gnunet_json_lib.h
index 26c68fed3..c3204026b 100644
--- a/src/include/gnunet_json_lib.h
+++ b/src/include/gnunet_json_lib.h
@@ -291,6 +291,17 @@ GNUNET_JSON_spec_bool (const char *name,
291 291
292 292
293/** 293/**
294 * double.
295 *
296 * @param name name of the JSON field
297 * @param[out] f where to store the double found under @a name
298 */
299struct GNUNET_JSON_Specification
300GNUNET_JSON_spec_double (const char *name,
301 double *f);
302
303
304/**
294 * 8-bit integer. 305 * 8-bit integer.
295 * 306 *
296 * @param name name of the JSON field 307 * @param name name of the JSON field
@@ -704,6 +715,19 @@ GNUNET_JSON_pack_bool (const char *name,
704 715
705/** 716/**
706 * Generate packer instruction for a JSON field of type 717 * Generate packer instruction for a JSON field of type
718 * double.
719 *
720 * @param name name of the field to add to the object
721 * @param f double value
722 * @return json pack specification
723 */
724struct GNUNET_JSON_PackSpec
725GNUNET_JSON_pack_double (const char *name,
726 double f);
727
728
729/**
730 * Generate packer instruction for a JSON field of type
707 * string. 731 * string.
708 * 732 *
709 * @param name name of the field to add to the object 733 * @param name name of the field to add to the object
diff --git a/src/include/gnunet_messenger_service.h b/src/include/gnunet_messenger_service.h
index 5b03ddecf..0388b7fb2 100644
--- a/src/include/gnunet_messenger_service.h
+++ b/src/include/gnunet_messenger_service.h
@@ -223,7 +223,7 @@ struct GNUNET_MESSENGER_MessageHeader
223 /** 223 /**
224 * The signature of the senders private key. 224 * The signature of the senders private key.
225 */ 225 */
226 struct GNUNET_IDENTITY_Signature signature; 226 struct GNUNET_CRYPTO_Signature signature;
227 227
228 /** 228 /**
229 * The timestamp of the message. 229 * The timestamp of the message.
@@ -275,7 +275,7 @@ struct GNUNET_MESSENGER_MessageJoin
275 /** 275 /**
276 * The senders public key to verify its signatures. 276 * The senders public key to verify its signatures.
277 */ 277 */
278 struct GNUNET_IDENTITY_PublicKey key; 278 struct GNUNET_CRYPTO_PublicKey key;
279}; 279};
280 280
281/** 281/**
@@ -313,7 +313,7 @@ struct GNUNET_MESSENGER_MessageKey
313 /** 313 /**
314 * The new public key which replaces the current senders public key. 314 * The new public key which replaces the current senders public key.
315 */ 315 */
316 struct GNUNET_IDENTITY_PublicKey key; 316 struct GNUNET_CRYPTO_PublicKey key;
317}; 317};
318 318
319/** 319/**
@@ -610,7 +610,7 @@ typedef int
610struct GNUNET_MESSENGER_Handle* 610struct GNUNET_MESSENGER_Handle*
611GNUNET_MESSENGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, 611GNUNET_MESSENGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
612 const char *name, 612 const char *name,
613 const struct GNUNET_IDENTITY_PrivateKey *key, 613 const struct GNUNET_CRYPTO_PrivateKey *key,
614 GNUNET_MESSENGER_MessageCallback msg_callback, 614 GNUNET_MESSENGER_MessageCallback msg_callback,
615 void *msg_cls); 615 void *msg_cls);
616 616
@@ -649,7 +649,7 @@ GNUNET_MESSENGER_set_name (struct GNUNET_MESSENGER_Handle *handle,
649 * @param[in] handle Messenger handle to use 649 * @param[in] handle Messenger handle to use
650 * @return Used public key or NULL 650 * @return Used public key or NULL
651 */ 651 */
652const struct GNUNET_IDENTITY_PublicKey* 652const struct GNUNET_CRYPTO_PublicKey*
653GNUNET_MESSENGER_get_key (const struct GNUNET_MESSENGER_Handle *handle); 653GNUNET_MESSENGER_get_key (const struct GNUNET_MESSENGER_Handle *handle);
654 654
655/** 655/**
@@ -663,7 +663,7 @@ GNUNET_MESSENGER_get_key (const struct GNUNET_MESSENGER_Handle *handle);
663 */ 663 */
664int 664int
665GNUNET_MESSENGER_set_key (struct GNUNET_MESSENGER_Handle *handle, 665GNUNET_MESSENGER_set_key (struct GNUNET_MESSENGER_Handle *handle,
666 const struct GNUNET_IDENTITY_PrivateKey *key); 666 const struct GNUNET_CRYPTO_PrivateKey *key);
667 667
668/** 668/**
669 * Open a room to send and receive messages. The room will use the specified <i>key</i> as port for the underlying cadet 669 * Open a room to send and receive messages. The room will use the specified <i>key</i> as port for the underlying cadet
@@ -775,9 +775,8 @@ GNUNET_MESSENGER_contact_get_name (const struct
775 * @param[in] contact Contact handle 775 * @param[in] contact Contact handle
776 * @return Public key used by <i>contact</i> or NULL 776 * @return Public key used by <i>contact</i> or NULL
777 */ 777 */
778const struct GNUNET_IDENTITY_PublicKey* 778const struct GNUNET_CRYPTO_PublicKey*
779GNUNET_MESSENGER_contact_get_key (const struct 779GNUNET_MESSENGER_contact_get_key (const struct GNUNET_MESSENGER_Contact *contact);
780 GNUNET_MESSENGER_Contact *contact);
781 780
782/** 781/**
783 * Send a <i>message</i> into a <i>room</i>. If you opened the <i>room</i> all entered members will receive the 782 * Send a <i>message</i> into a <i>room</i>. If you opened the <i>room</i> all entered members will receive the
diff --git a/src/include/gnunet_mq_lib.h b/src/include/gnunet_mq_lib.h
index f424c49c2..3eca71f0f 100644
--- a/src/include/gnunet_mq_lib.h
+++ b/src/include/gnunet_mq_lib.h
@@ -18,6 +18,7 @@
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"
21#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) 22#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__)
22#error "Only <gnunet_util_lib.h> can be included directly." 23#error "Only <gnunet_util_lib.h> can be included directly."
23#endif 24#endif
@@ -691,7 +692,7 @@ struct GNUNET_MQ_MessageHandler
691 * @return #GNUNET_OK on success, #GNUNET_NO if no handler matched, 692 * @return #GNUNET_OK on success, #GNUNET_NO if no handler matched,
692 * #GNUNET_SYSERR if message was rejected by check function 693 * #GNUNET_SYSERR if message was rejected by check function
693 */ 694 */
694int 695enum GNUNET_GenericReturnValue
695GNUNET_MQ_handle_message (const struct GNUNET_MQ_MessageHandler *handlers, 696GNUNET_MQ_handle_message (const struct GNUNET_MQ_MessageHandler *handlers,
696 const struct GNUNET_MessageHeader *mh); 697 const struct GNUNET_MessageHeader *mh);
697 698
diff --git a/src/include/gnunet_mst_lib.h b/src/include/gnunet_mst_lib.h
index af2dd3353..5b848bbd6 100644
--- a/src/include/gnunet_mst_lib.h
+++ b/src/include/gnunet_mst_lib.h
@@ -127,7 +127,7 @@ GNUNET_MST_from_buffer (struct GNUNET_MessageStreamTokenizer *mst,
127 * #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
128 * #GNUNET_SYSERR if the data stream is corrupt 128 * #GNUNET_SYSERR if the data stream is corrupt
129 */ 129 */
130int 130enum GNUNET_GenericReturnValue
131GNUNET_MST_read (struct GNUNET_MessageStreamTokenizer *mst, 131GNUNET_MST_read (struct GNUNET_MessageStreamTokenizer *mst,
132 struct GNUNET_NETWORK_Handle *sock, 132 struct GNUNET_NETWORK_Handle *sock,
133 int purge, 133 int purge,
@@ -145,7 +145,7 @@ GNUNET_MST_read (struct GNUNET_MessageStreamTokenizer *mst,
145 * #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
146 * #GNUNET_SYSERR if the data stream is corrupt 146 * #GNUNET_SYSERR if the data stream is corrupt
147 */ 147 */
148int 148enum GNUNET_GenericReturnValue
149GNUNET_MST_next (struct GNUNET_MessageStreamTokenizer *mst, 149GNUNET_MST_next (struct GNUNET_MessageStreamTokenizer *mst,
150 int one_shot); 150 int one_shot);
151 151
diff --git a/src/include/gnunet_my_lib.h b/src/include/gnunet_my_lib.h
deleted file mode 100644
index 283b2f7e6..000000000
--- a/src/include/gnunet_my_lib.h
+++ /dev/null
@@ -1,511 +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 * @addtogroup lib_extra
22 * @{
23 *
24 * @author Christian Grothoff
25 * @author Christophe Genevey
26 * @author Martin Schanzenbach
27 *
28 * @file
29 * Helper library to access a MySQL database
30 *
31 * @defgroup mysql MySQL library
32 * Helper library to access a MySQL database.
33 * @{
34 */
35#ifndef GNUNET_MY_LIB_H
36#define GNUNET_MY_LIB_H
37
38
39#include "gnunet_util_lib.h"
40#include "gnunet_mysql_lib.h"
41#include <mysql/mysql.h>
42
43#ifndef MYSQL_BOOL
44#error "You need to define MYSQL_BOOL. See (or include) gnunet_mysql_compat.h"
45#endif
46
47#ifdef __cplusplus
48extern "C"
49{
50#if 0 /* keep Emacsens' auto-indent happy */
51}
52#endif
53#endif
54
55
56/**
57 * Information we pass to #GNUNET_MY_exec_prepared() to
58 * initialize the arguments of the prepared statement.
59 */
60struct GNUNET_MY_QueryParam;
61
62
63/**
64 * Function called to convert input argument into SQL parameters.
65 *
66 * @param cls closure
67 * @param pq data about the query
68 * @param qbind array of parameters to initialize
69 * @return -1 on error
70 */
71typedef int
72(*GNUNET_MY_QueryConverter)(void *cls,
73 const struct GNUNET_MY_QueryParam *qp,
74 MYSQL_BIND *qbind);
75
76
77/**
78 * Function called to cleanup result data.
79 *
80 * @param cls closure
81 * @param rs spec to clean up
82 */
83typedef void
84(*GNUNET_MY_QueryCleanup)(void *cls,
85 MYSQL_BIND *qbind);
86/**
87 * Information we pass to #GNUNET_MY_exec_prepared() to
88 * initialize the arguments of the prepared statement.
89 */
90
91
92struct GNUNET_MY_QueryParam
93{
94 /**
95 * Function to call for the type conversion.
96 */
97 GNUNET_MY_QueryConverter conv;
98
99 /**
100 * Function to call for cleaning up the query. Can be NULL.
101 */
102 GNUNET_MY_QueryCleanup cleaner;
103
104 /**
105 * Closure for @e conv.
106 */
107 void *conv_cls;
108
109 /**
110 * Number of arguments the @a conv converter expects to initialize.
111 */
112 unsigned int num_params;
113
114 /**
115 * Information to pass to @e conv.
116 */
117 const void *data;
118
119 /**
120 * Information to pass to @e conv. Size of @a data.
121 */
122 unsigned long data_len;
123};
124
125/**
126 * End of query parameter specification.
127 *
128 * @return array last entry for the result specification to use
129 */
130#define GNUNET_MY_query_param_end { NULL, NULL, NULL, 0, NULL, 0 }
131
132
133/**
134 * Generate query parameter for a buffer @a ptr of
135 * @a ptr_size bytes.FG
136 *
137 * @param ptr pointer to the query parameter to pass
138 * @param ptr_size number of bytes in @a ptr
139 */
140struct GNUNET_MY_QueryParam
141GNUNET_MY_query_param_fixed_size (const void *ptr,
142 size_t ptr_size);
143
144
145/**
146 * Run a prepared SELECT statement.
147 *
148 * @param mc mysql context
149 * @param sh handle to SELECT statement
150 * @param params parameters to the statement
151 * @return TBD
152 */
153int
154GNUNET_MY_exec_prepared (struct GNUNET_MYSQL_Context *mc,
155 struct GNUNET_MYSQL_StatementHandle *sh,
156 struct GNUNET_MY_QueryParam *params);
157
158
159/**
160 * Information we pass to #GNUNET_MY_extract_result() to
161 * initialize the arguments of the prepared statement.
162 */
163struct GNUNET_MY_ResultParam;
164
165/**
166 * Information we pass to #GNUNET_MY_extract_result() to
167 * initialize the arguments of the prepared statement.
168 */
169struct GNUNET_MY_ResultSpec;
170
171/**
172 * Function called to convert input argument into SQL parameters.
173 *
174 * @param cls closure
175 * @param[in,out] rs
176 * @param stmt the mysql statement that is being run
177 * @param column the column that is being processed
178 * @param[out] results
179 * @return -1 on error
180 */
181typedef int
182(*GNUNET_MY_ResultConverter)(void *cls,
183 struct GNUNET_MY_ResultSpec *rs,
184 MYSQL_STMT *stmt,
185 unsigned int column,
186 MYSQL_BIND *results);
187
188/**
189 * Function called to cleanup result data.
190 *
191 * @param cls closure
192 * @param rs spec to clean up
193 */
194typedef void
195(*GNUNET_MY_ResultCleanup)(void *cls,
196 struct GNUNET_MY_ResultSpec *rs);
197
198
199/**
200 * Information we pass to #GNUNET_MY_extract_result() to
201 * initialize the arguments of the prepared statement.
202 */
203struct GNUNET_MY_ResultSpec
204{
205 /**
206 * Function to call to initialize the MYSQL_BIND array.
207 */
208 GNUNET_MY_ResultConverter pre_conv;
209
210 /**
211 * Function to call for converting the result. Can be NULL.
212 */
213 GNUNET_MY_ResultConverter post_conv;
214
215 /**
216 * Function to call for cleaning up the result. Can be NULL.
217 */
218 GNUNET_MY_ResultCleanup cleaner;
219
220 /**
221 * Closure for @e conv.
222 */
223 void *conv_cls;
224
225 /**
226 * Destination for the data.
227 */
228 void *dst;
229
230 /**
231 * Allowed size for the data, 0 for variable-size
232 * (in this case, the type of @e dst is a `void **`
233 * and we need to allocate a buffer of the right size).
234 */
235 size_t dst_size;
236
237 /**
238 * Where to store actual size of the result.
239 */
240 size_t *result_size;
241
242 /**
243 * How many fields does this result specification occupy
244 * in the result returned by MySQL.
245 */
246 unsigned int num_fields;
247
248 /**
249 * Location where we temporarily store the output buffer
250 * length from MySQL. Internal to libgnunetmy.
251 */
252 unsigned long mysql_bind_output_length;
253
254 /**
255 * Memory for MySQL to notify us about NULL values.
256 */
257 MYSQL_BOOL is_null;
258};
259
260
261/**
262 * End of result speceter specification.
263 *
264 * @return array last entry for the result specification to use
265 */
266#define GNUNET_MY_result_spec_end { NULL, NULL, NULL, 0, NULL, 0, 0 }
267
268
269/**
270 * Obtain fixed size result of @a ptr_size bytes from
271 * MySQL, store in already allocated buffer at @a ptr.
272 *
273 * @spec ptr where to write the result
274 * @param ptr_size number of bytes available at @a ptr
275 */
276struct GNUNET_MY_ResultSpec
277GNUNET_MY_result_spec_fixed_size (void *ptr,
278 size_t ptr_size);
279
280/**
281 * Generate query parameter for a string
282 *
283 * @param ptr pointer to the string query parameter to pass
284 */
285struct GNUNET_MY_QueryParam
286GNUNET_MY_query_param_string (const char *ptr);
287
288/**
289 * Generate fixed-size query parameter with size determined
290 * by variable type.
291 *
292 * @param x pointer to the query parameter to pass
293 */
294#define GNUNET_MY_query_param_auto_from_type( \
295 x) GNUNET_MY_query_param_fixed_size ((x), sizeof(*(x)))
296
297/**
298 * Generate query parameter for an RSA public key. The
299 * database must contain a BLOB type in the respective position.
300 *
301 * @param x the query parameter to pass
302 * @return array entry for the query parameters to use
303 */
304struct GNUNET_MY_QueryParam
305GNUNET_MY_query_param_rsa_public_key (const struct
306 GNUNET_CRYPTO_RsaPublicKey *x);
307
308/**
309 * Generate query parameter for an RSA signature. The
310 * database must contain a BLOB type in the respective position
311 *
312 *@param x the query parameter to pass
313 *@return array entry for the query parameters to use
314 */
315struct GNUNET_MY_QueryParam
316GNUNET_MY_query_param_rsa_signature (const struct
317 GNUNET_CRYPTO_RsaSignature *x);
318
319/**
320 * Generate query parameter for an absolute time value.
321 * The database must store a 64-bit integer.
322 *
323 *@param x pointer to the query parameter to pass
324 *@return array entry for the query parameters to use
325 */
326struct GNUNET_MY_QueryParam
327GNUNET_MY_query_param_absolute_time (const struct GNUNET_TIME_Absolute *x);
328
329
330/**
331 * Generate query parameter for an absolute time value.
332 * The database must store a 64-bit integer.
333 *
334 *@param x pointer to the query parameter to pass
335 */
336struct GNUNET_MY_QueryParam
337GNUNET_MY_query_param_absolute_time_nbo (const struct
338 GNUNET_TIME_AbsoluteNBO *x);
339
340/**
341 * Generate query parameter for an uint16_t in host byte order.
342 *
343 * @param x pointer to the query parameter to pass
344 */
345struct GNUNET_MY_QueryParam
346GNUNET_MY_query_param_uint16 (const uint16_t *x);
347
348/**
349 * Generate query parameter for an uint32_t in host byte order
350 *
351 * @param x pointer to the query parameter to pass
352 */
353struct GNUNET_MY_QueryParam
354GNUNET_MY_query_param_uint32 (const uint32_t *x);
355
356/**
357 * Generate query parameter for an uint64_t in host byte order
358 *
359 * @param x pointer to the query parameter to pass
360 */
361struct GNUNET_MY_QueryParam
362GNUNET_MY_query_param_uint64 (const uint64_t *x);
363
364/**
365 * We expect a fixed-size result, with size determined by the type of `* dst`
366 *
367 * @spec name name of the field in the table
368 * @spec dst point to where to store the result, type fits expected result size
369 * @return array entry for the result specification to use
370 */
371#define GNUNET_MY_result_spec_auto_from_type( \
372 dst) GNUNET_MY_result_spec_fixed_size ((dst), sizeof(*(dst)))
373
374
375/**
376 * Variable-size result expected
377 *
378 * @param[out] dst where to store the result, allocated
379 * @param[out] ptr_size where to store the size of @a dst
380 * @return array entry for the result specification to use
381 */
382struct GNUNET_MY_ResultSpec
383GNUNET_MY_result_spec_variable_size (void **dst,
384 size_t *ptr_size);
385
386/**
387 * RSA public key expected
388 *
389 * @param name name of the field in the table
390 * @param[out] rsa where to store the result
391 * @return array entry for the result specification to use
392 */
393struct GNUNET_MY_ResultSpec
394GNUNET_MY_result_spec_rsa_public_key (struct GNUNET_CRYPTO_RsaPublicKey **rsa);
395
396
397/**
398 * RSA signature expected.
399 *
400 * @param[out] sig where to store the result;
401 * @return array entry for the result specification to use
402 */
403struct GNUNET_MY_ResultSpec
404GNUNET_MY_result_spec_rsa_signature (struct GNUNET_CRYPTO_RsaSignature **sig);
405
406/**
407 * 0- terminated string exprected.
408 *
409 * @param[out] dst where to store the result, allocated
410 * @return array entry for the result specification to use
411 */
412struct GNUNET_MY_ResultSpec
413GNUNET_MY_result_spec_string (char **dst);
414
415/**
416 * Absolute time expected
417 *
418 * @param name name of the field in the table
419 * @param[out] at where to store the result
420 * @return array entry for the result specification to use
421 */
422struct GNUNET_MY_ResultSpec
423GNUNET_MY_result_spec_absolute_time (struct GNUNET_TIME_Absolute *at);
424
425/**
426 * Absolute time in network byte order expected
427 *
428 * @param[out] at where to store the result
429 * @return array entry for the result specification to use
430 */
431struct GNUNET_MY_ResultSpec
432GNUNET_MY_result_spec_absolute_time_nbo (struct GNUNET_TIME_AbsoluteNBO *at);
433
434/**
435 * uint16_t expected
436 *
437 * @param[out] u16 where to store the result
438 * @return array entry for the result specification to use
439 */
440struct GNUNET_MY_ResultSpec
441GNUNET_MY_result_spec_uint16 (uint16_t *u16);
442
443/**
444 * uint32_t expected
445 *
446 * @param[out] u32 where to store the result
447 * @return array entry for the result specification to use
448 */
449struct GNUNET_MY_ResultSpec
450GNUNET_MY_result_spec_uint32 (uint32_t *u32);
451
452/**
453 * uint64_t expected.
454 *
455 * @param[out] u64 where to store the result
456 * @return array entry for the result specification to use
457 */
458struct GNUNET_MY_ResultSpec
459GNUNET_MY_result_spec_uint64 (uint64_t *u64);
460
461
462/**
463 * Extract results from a query result according to the given
464 * specification. Always fetches the next row.
465 *
466 * @param sh statement that returned results
467 * @param rs specification to extract for
468 * @return
469 * #GNUNET_YES if all results could be extracted
470 * #GNUNET_NO if there is no more data in the result set
471 * #GNUNET_SYSERR if a result was invalid
472 */
473int
474GNUNET_MY_extract_result (struct GNUNET_MYSQL_StatementHandle *sh,
475 struct GNUNET_MY_ResultSpec *specs);
476
477
478/**
479 * Free all memory that was allocated in @a qp during
480 * #GNUNET_MY_exect_prepared().
481 *
482 * @param qp query specification to clean up
483 * @param qbind mysql query
484 */
485void
486GNUNET_MY_cleanup_query (struct GNUNET_MY_QueryParam *qp,
487 MYSQL_BIND *qbind);
488
489
490/**
491 * Free all memory that was allocated in @a rs during
492 * #GNUNET_MY_extract_result().
493 *
494 * @param rs reult specification to clean up
495 */
496void
497GNUNET_MY_cleanup_result (struct GNUNET_MY_ResultSpec *rs);
498
499
500#if 0 /* keep Emacsens' auto-indent happy */
501{
502#endif
503#ifdef __cplusplus
504}
505#endif
506
507#endif
508
509/** @} */ /* end of group */
510
511/** @} */ /* end of group addition to lib_extra */
diff --git a/src/include/gnunet_mysql_compat.h.in b/src/include/gnunet_mysql_compat.h.in
deleted file mode 100644
index 6218386aa..000000000
--- a/src/include/gnunet_mysql_compat.h.in
+++ /dev/null
@@ -1,57 +0,0 @@
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 * @author Martin Schanzenbach
22 *
23 * @file
24 * MySQL/MariaDB compatibility insanity helper header
25 * Note: gnunet_mysql_compat.h is AUTOGENERATED from gnunet_mysql_compat.h.in
26 * Please do not modify or commit gnunet_mysql_compat.h
27 *
28 * @defgroup mysql MySQL library
29 * Helper library to access a MySQL database.
30 * @{
31 */
32#ifndef GNUNET_MYSQL_COMPAT_H
33#define GNUNET_MYSQL_COMPAT_H
34
35
36#include <mysql/mysql.h>
37
38#ifdef __cplusplus
39extern "C"
40{
41#if 0 /* keep Emacsens' auto-indent happy */
42}
43#endif
44#endif
45
46#define MYSQL_BOOL @mysql_bool@
47
48#if 0 /* keep Emacsens' auto-indent happy */
49{
50#endif
51#ifdef __cplusplus
52}
53#endif
54
55#endif
56
57/** @} */ /* end of group */
diff --git a/src/include/gnunet_mysql_lib.h b/src/include/gnunet_mysql_lib.h
deleted file mode 100644
index 52be3ff11..000000000
--- a/src/include/gnunet_mysql_lib.h
+++ /dev/null
@@ -1,151 +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
34#include "gnunet_util_lib.h"
35#include <mysql/mysql.h>
36
37#ifdef __cplusplus
38extern "C"
39{
40#if 0 /* keep Emacsens' auto-indent happy */
41}
42#endif
43#endif
44
45/**
46 * Mysql context.
47 */
48struct GNUNET_MYSQL_Context;
49
50
51/**
52 * Handle for a prepared statement.
53 */
54struct GNUNET_MYSQL_StatementHandle;
55
56
57/**
58 * Type of a callback that will be called for each
59 * data set returned from MySQL.
60 *
61 * @param cls user-defined argument
62 * @param num_values number of elements in values
63 * @param values values returned by MySQL
64 * @return #GNUNET_OK to continue iterating, #GNUNET_SYSERR to abort
65 */
66typedef int
67(*GNUNET_MYSQL_DataProcessor) (void *cls,
68 unsigned int num_values,
69 MYSQL_BIND *values);
70
71
72/**
73 * Create a mysql context.
74 *
75 * @param cfg configuration
76 * @param section configuration section to use to get MySQL configuration options
77 * @return the mysql context
78 */
79struct GNUNET_MYSQL_Context *
80GNUNET_MYSQL_context_create (const struct GNUNET_CONFIGURATION_Handle *cfg,
81 const char *section);
82
83
84/**
85 * Destroy a mysql context. Also frees all associated prepared statements.
86 *
87 * @param mc context to destroy
88 */
89void
90GNUNET_MYSQL_context_destroy (struct GNUNET_MYSQL_Context *mc);
91
92
93/**
94 * Close database connection and all prepared statements (we got a DB
95 * error). The connection will automatically be re-opened and
96 * statements will be re-prepared if they are needed again later.
97 *
98 * @param mc mysql context
99 */
100void
101GNUNET_MYSQL_statements_invalidate (struct GNUNET_MYSQL_Context *mc);
102
103
104/**
105 * Get internal handle for a prepared statement. This function should rarely
106 * be used, and if, with caution! On failures during the interaction with
107 * the handle, you must call #GNUNET_MYSQL_statements_invalidate()!
108 *
109 * @param sh prepared statement to introspect
110 * @return MySQL statement handle, NULL on error
111 */
112MYSQL_STMT *
113GNUNET_MYSQL_statement_get_stmt (struct GNUNET_MYSQL_StatementHandle *sh);
114
115
116/**
117 * Prepare a statement. Prepared statements are automatically discarded
118 * when the MySQL context is destroyed.
119 *
120 * @param mc mysql context
121 * @param query query text
122 * @return prepared statement, NULL on error
123 */
124struct GNUNET_MYSQL_StatementHandle *
125GNUNET_MYSQL_statement_prepare (struct GNUNET_MYSQL_Context *mc,
126 const char *query);
127
128
129/**
130 * Run a SQL statement.
131 *
132 * @param mc mysql context
133 * @param sql SQL statement to run
134 * @return #GNUNET_OK on success
135 * #GNUNET_SYSERR if there was a problem
136 */
137int
138GNUNET_MYSQL_statement_run (struct GNUNET_MYSQL_Context *mc,
139 const char *sql);
140
141
142#if 0 /* keep Emacsens' auto-indent happy */
143{
144#endif
145#ifdef __cplusplus
146}
147#endif
148
149#endif
150
151/** @} */ /* end of group */
diff --git a/src/include/gnunet_namestore_plugin.h b/src/include/gnunet_namestore_plugin.h
index f2bdf7cc6..d8dde5af5 100644
--- a/src/include/gnunet_namestore_plugin.h
+++ b/src/include/gnunet_namestore_plugin.h
@@ -62,7 +62,7 @@ typedef void
62(*GNUNET_NAMESTORE_RecordIterator) (void *cls, 62(*GNUNET_NAMESTORE_RecordIterator) (void *cls,
63 uint64_t serial, 63 uint64_t serial,
64 const struct 64 const struct
65 GNUNET_IDENTITY_PrivateKey *private_key, 65 GNUNET_CRYPTO_PrivateKey *private_key,
66 const char *label, 66 const char *label,
67 unsigned int rd_count, 67 unsigned int rd_count,
68 const struct GNUNET_GNSRECORD_Data *rd); 68 const struct GNUNET_GNSRECORD_Data *rd);
@@ -91,7 +91,7 @@ struct GNUNET_NAMESTORE_PluginFunctions
91 */ 91 */
92 enum GNUNET_GenericReturnValue 92 enum GNUNET_GenericReturnValue
93 (*store_records)(void *cls, 93 (*store_records)(void *cls,
94 const struct GNUNET_IDENTITY_PrivateKey *zone, 94 const struct GNUNET_CRYPTO_PrivateKey *zone,
95 const char *label, 95 const char *label,
96 unsigned int rd_count, 96 unsigned int rd_count,
97 const struct GNUNET_GNSRECORD_Data *rd); 97 const struct GNUNET_GNSRECORD_Data *rd);
@@ -108,7 +108,7 @@ struct GNUNET_NAMESTORE_PluginFunctions
108 */ 108 */
109 enum GNUNET_GenericReturnValue 109 enum GNUNET_GenericReturnValue
110 (*lookup_records)(void *cls, 110 (*lookup_records)(void *cls,
111 const struct GNUNET_IDENTITY_PrivateKey *zone, 111 const struct GNUNET_CRYPTO_PrivateKey *zone,
112 const char *label, 112 const char *label,
113 GNUNET_NAMESTORE_RecordIterator iter, 113 GNUNET_NAMESTORE_RecordIterator iter,
114 void *iter_cls); 114 void *iter_cls);
@@ -130,7 +130,7 @@ struct GNUNET_NAMESTORE_PluginFunctions
130 */ 130 */
131 enum GNUNET_GenericReturnValue 131 enum GNUNET_GenericReturnValue
132 (*iterate_records)(void *cls, 132 (*iterate_records)(void *cls,
133 const struct GNUNET_IDENTITY_PrivateKey *zone, 133 const struct GNUNET_CRYPTO_PrivateKey *zone,
134 uint64_t serial, 134 uint64_t serial,
135 uint64_t limit, 135 uint64_t limit,
136 GNUNET_NAMESTORE_RecordIterator iter, 136 GNUNET_NAMESTORE_RecordIterator iter,
@@ -150,8 +150,8 @@ struct GNUNET_NAMESTORE_PluginFunctions
150 */ 150 */
151 enum GNUNET_GenericReturnValue 151 enum GNUNET_GenericReturnValue
152 (*zone_to_name)(void *cls, 152 (*zone_to_name)(void *cls,
153 const struct GNUNET_IDENTITY_PrivateKey *zone, 153 const struct GNUNET_CRYPTO_PrivateKey *zone,
154 const struct GNUNET_IDENTITY_PublicKey *value_zone, 154 const struct GNUNET_CRYPTO_PublicKey *value_zone,
155 GNUNET_NAMESTORE_RecordIterator iter, 155 GNUNET_NAMESTORE_RecordIterator iter,
156 void *iter_cls); 156 void *iter_cls);
157 157
@@ -201,7 +201,7 @@ struct GNUNET_NAMESTORE_PluginFunctions
201 */ 201 */
202 enum GNUNET_GenericReturnValue 202 enum GNUNET_GenericReturnValue
203 (*edit_records)(void *cls, 203 (*edit_records)(void *cls,
204 const struct GNUNET_IDENTITY_PrivateKey *zone, 204 const struct GNUNET_CRYPTO_PrivateKey *zone,
205 const char *label, 205 const char *label,
206 GNUNET_NAMESTORE_RecordIterator iter, 206 GNUNET_NAMESTORE_RecordIterator iter,
207 void *iter_cls); 207 void *iter_cls);
diff --git a/src/include/gnunet_namestore_service.h b/src/include/gnunet_namestore_service.h
index b93a345c7..61691ff55 100644
--- a/src/include/gnunet_namestore_service.h
+++ b/src/include/gnunet_namestore_service.h
@@ -153,7 +153,7 @@ typedef void
153 */ 153 */
154struct GNUNET_NAMESTORE_QueueEntry * 154struct GNUNET_NAMESTORE_QueueEntry *
155GNUNET_NAMESTORE_records_store (struct GNUNET_NAMESTORE_Handle *h, 155GNUNET_NAMESTORE_records_store (struct GNUNET_NAMESTORE_Handle *h,
156 const struct GNUNET_IDENTITY_PrivateKey *pkey, 156 const struct GNUNET_CRYPTO_PrivateKey *pkey,
157 const char *label, 157 const char *label,
158 unsigned int rd_count, 158 unsigned int rd_count,
159 const struct GNUNET_GNSRECORD_Data *rd, 159 const struct GNUNET_GNSRECORD_Data *rd,
@@ -187,7 +187,7 @@ GNUNET_NAMESTORE_records_store (struct GNUNET_NAMESTORE_Handle *h,
187struct GNUNET_NAMESTORE_QueueEntry * 187struct GNUNET_NAMESTORE_QueueEntry *
188GNUNET_NAMESTORE_records_store2 ( 188GNUNET_NAMESTORE_records_store2 (
189 struct GNUNET_NAMESTORE_Handle *h, 189 struct GNUNET_NAMESTORE_Handle *h,
190 const struct GNUNET_IDENTITY_PrivateKey *pkey, 190 const struct GNUNET_CRYPTO_PrivateKey *pkey,
191 unsigned int rd_set_count, 191 unsigned int rd_set_count,
192 const struct GNUNET_NAMESTORE_RecordInfo *record_info, 192 const struct GNUNET_NAMESTORE_RecordInfo *record_info,
193 unsigned int *rds_sent, 193 unsigned int *rds_sent,
@@ -217,7 +217,7 @@ GNUNET_NAMESTORE_records_store2 (
217 */ 217 */
218struct GNUNET_NAMESTORE_QueueEntry * 218struct GNUNET_NAMESTORE_QueueEntry *
219GNUNET_NAMESTORE_records_store_ (struct GNUNET_NAMESTORE_Handle *h, 219GNUNET_NAMESTORE_records_store_ (struct GNUNET_NAMESTORE_Handle *h,
220 const struct GNUNET_IDENTITY_PrivateKey *pkey, 220 const struct GNUNET_CRYPTO_PrivateKey *pkey,
221 const char *label, 221 const char *label,
222 unsigned int rd_count, 222 unsigned int rd_count,
223 const struct GNUNET_GNSRECORD_Data *rd, 223 const struct GNUNET_GNSRECORD_Data *rd,
@@ -240,7 +240,7 @@ GNUNET_NAMESTORE_records_store_ (struct GNUNET_NAMESTORE_Handle *h,
240typedef void 240typedef void
241(*GNUNET_NAMESTORE_RecordMonitor) (void *cls, 241(*GNUNET_NAMESTORE_RecordMonitor) (void *cls,
242 const struct 242 const struct
243 GNUNET_IDENTITY_PrivateKey *zone, 243 GNUNET_CRYPTO_PrivateKey *zone,
244 const char *label, 244 const char *label,
245 unsigned int rd_count, 245 unsigned int rd_count,
246 const struct GNUNET_GNSRECORD_Data *rd); 246 const struct GNUNET_GNSRECORD_Data *rd);
@@ -260,7 +260,7 @@ typedef void
260typedef void 260typedef void
261(*GNUNET_NAMESTORE_RecordSetMonitor) (void *cls, 261(*GNUNET_NAMESTORE_RecordSetMonitor) (void *cls,
262 const struct 262 const struct
263 GNUNET_IDENTITY_PrivateKey *zone, 263 GNUNET_CRYPTO_PrivateKey *zone,
264 const char *label, 264 const char *label,
265 unsigned int rd_count, 265 unsigned int rd_count,
266 const struct GNUNET_GNSRECORD_Data *rd, 266 const struct GNUNET_GNSRECORD_Data *rd,
@@ -284,7 +284,7 @@ typedef void
284struct GNUNET_NAMESTORE_QueueEntry * 284struct GNUNET_NAMESTORE_QueueEntry *
285GNUNET_NAMESTORE_records_lookup (struct GNUNET_NAMESTORE_Handle *h, 285GNUNET_NAMESTORE_records_lookup (struct GNUNET_NAMESTORE_Handle *h,
286 const struct 286 const struct
287 GNUNET_IDENTITY_PrivateKey *pkey, 287 GNUNET_CRYPTO_PrivateKey *pkey,
288 const char *label, 288 const char *label,
289 GNUNET_SCHEDULER_TaskCallback error_cb, 289 GNUNET_SCHEDULER_TaskCallback error_cb,
290 void *error_cb_cls, 290 void *error_cb_cls,
@@ -309,7 +309,7 @@ GNUNET_NAMESTORE_records_lookup (struct GNUNET_NAMESTORE_Handle *h,
309struct GNUNET_NAMESTORE_QueueEntry * 309struct GNUNET_NAMESTORE_QueueEntry *
310GNUNET_NAMESTORE_records_lookup2 (struct GNUNET_NAMESTORE_Handle *h, 310GNUNET_NAMESTORE_records_lookup2 (struct GNUNET_NAMESTORE_Handle *h,
311 const struct 311 const struct
312 GNUNET_IDENTITY_PrivateKey *pkey, 312 GNUNET_CRYPTO_PrivateKey *pkey,
313 const char *label, 313 const char *label,
314 GNUNET_SCHEDULER_TaskCallback error_cb, 314 GNUNET_SCHEDULER_TaskCallback error_cb,
315 void *error_cb_cls, 315 void *error_cb_cls,
@@ -338,9 +338,9 @@ GNUNET_NAMESTORE_records_lookup2 (struct GNUNET_NAMESTORE_Handle *h,
338 */ 338 */
339struct GNUNET_NAMESTORE_QueueEntry * 339struct GNUNET_NAMESTORE_QueueEntry *
340GNUNET_NAMESTORE_zone_to_name (struct GNUNET_NAMESTORE_Handle *h, 340GNUNET_NAMESTORE_zone_to_name (struct GNUNET_NAMESTORE_Handle *h,
341 const struct GNUNET_IDENTITY_PrivateKey *zone, 341 const struct GNUNET_CRYPTO_PrivateKey *zone,
342 const struct 342 const struct
343 GNUNET_IDENTITY_PublicKey *value_zone, 343 GNUNET_CRYPTO_PublicKey *value_zone,
344 GNUNET_SCHEDULER_TaskCallback error_cb, 344 GNUNET_SCHEDULER_TaskCallback error_cb,
345 void *error_cb_cls, 345 void *error_cb_cls,
346 GNUNET_NAMESTORE_RecordMonitor proc, 346 GNUNET_NAMESTORE_RecordMonitor proc,
@@ -390,7 +390,7 @@ GNUNET_NAMESTORE_cancel (struct GNUNET_NAMESTORE_QueueEntry *qe);
390struct GNUNET_NAMESTORE_ZoneIterator * 390struct GNUNET_NAMESTORE_ZoneIterator *
391GNUNET_NAMESTORE_zone_iteration_start (struct GNUNET_NAMESTORE_Handle *h, 391GNUNET_NAMESTORE_zone_iteration_start (struct GNUNET_NAMESTORE_Handle *h,
392 const struct 392 const struct
393 GNUNET_IDENTITY_PrivateKey *zone, 393 GNUNET_CRYPTO_PrivateKey *zone,
394 GNUNET_SCHEDULER_TaskCallback error_cb, 394 GNUNET_SCHEDULER_TaskCallback error_cb,
395 void *error_cb_cls, 395 void *error_cb_cls,
396 GNUNET_NAMESTORE_RecordMonitor proc, 396 GNUNET_NAMESTORE_RecordMonitor proc,
@@ -427,7 +427,7 @@ GNUNET_NAMESTORE_zone_iteration_start (struct GNUNET_NAMESTORE_Handle *h,
427struct GNUNET_NAMESTORE_ZoneIterator * 427struct GNUNET_NAMESTORE_ZoneIterator *
428GNUNET_NAMESTORE_zone_iteration_start2 (struct GNUNET_NAMESTORE_Handle *h, 428GNUNET_NAMESTORE_zone_iteration_start2 (struct GNUNET_NAMESTORE_Handle *h,
429 const struct 429 const struct
430 GNUNET_IDENTITY_PrivateKey *zone, 430 GNUNET_CRYPTO_PrivateKey *zone,
431 GNUNET_SCHEDULER_TaskCallback error_cb, 431 GNUNET_SCHEDULER_TaskCallback error_cb,
432 void *error_cb_cls, 432 void *error_cb_cls,
433 GNUNET_NAMESTORE_RecordSetMonitor proc, 433 GNUNET_NAMESTORE_RecordSetMonitor proc,
@@ -501,7 +501,7 @@ struct GNUNET_NAMESTORE_ZoneMonitor;
501struct GNUNET_NAMESTORE_ZoneMonitor * 501struct GNUNET_NAMESTORE_ZoneMonitor *
502GNUNET_NAMESTORE_zone_monitor_start ( 502GNUNET_NAMESTORE_zone_monitor_start (
503 const struct GNUNET_CONFIGURATION_Handle *cfg, 503 const struct GNUNET_CONFIGURATION_Handle *cfg,
504 const struct GNUNET_IDENTITY_PrivateKey *zone, 504 const struct GNUNET_CRYPTO_PrivateKey *zone,
505 int iterate_first, 505 int iterate_first,
506 GNUNET_SCHEDULER_TaskCallback error_cb, 506 GNUNET_SCHEDULER_TaskCallback error_cb,
507 void *error_cb_cls, 507 void *error_cb_cls,
@@ -541,7 +541,7 @@ GNUNET_NAMESTORE_zone_monitor_start (
541struct GNUNET_NAMESTORE_ZoneMonitor * 541struct GNUNET_NAMESTORE_ZoneMonitor *
542GNUNET_NAMESTORE_zone_monitor_start2 ( 542GNUNET_NAMESTORE_zone_monitor_start2 (
543 const struct GNUNET_CONFIGURATION_Handle *cfg, 543 const struct GNUNET_CONFIGURATION_Handle *cfg,
544 const struct GNUNET_IDENTITY_PrivateKey *zone, 544 const struct GNUNET_CRYPTO_PrivateKey *zone,
545 int iterate_first, 545 int iterate_first,
546 GNUNET_SCHEDULER_TaskCallback error_cb, 546 GNUNET_SCHEDULER_TaskCallback error_cb,
547 void *error_cb_cls, 547 void *error_cb_cls,
@@ -637,7 +637,7 @@ GNUNET_NAMESTORE_transaction_commit (struct GNUNET_NAMESTORE_Handle *h,
637struct GNUNET_NAMESTORE_QueueEntry * 637struct GNUNET_NAMESTORE_QueueEntry *
638GNUNET_NAMESTORE_records_edit ( 638GNUNET_NAMESTORE_records_edit (
639 struct GNUNET_NAMESTORE_Handle *h, 639 struct GNUNET_NAMESTORE_Handle *h,
640 const struct GNUNET_IDENTITY_PrivateKey *pkey, 640 const struct GNUNET_CRYPTO_PrivateKey *pkey,
641 const char *label, 641 const char *label,
642 GNUNET_SCHEDULER_TaskCallback error_cb, 642 GNUNET_SCHEDULER_TaskCallback error_cb,
643 void *error_cb_cls, 643 void *error_cb_cls,
diff --git a/src/include/gnunet_network_lib.h b/src/include/gnunet_network_lib.h
index 8d71d7764..764b7b29d 100644
--- a/src/include/gnunet_network_lib.h
+++ b/src/include/gnunet_network_lib.h
@@ -39,6 +39,7 @@
39#ifndef GNUNET_NETWORK_LIB_H 39#ifndef GNUNET_NETWORK_LIB_H
40#define GNUNET_NETWORK_LIB_H 40#define GNUNET_NETWORK_LIB_H
41 41
42#include "gnunet_common.h"
42#ifdef __cplusplus 43#ifdef __cplusplus
43extern "C" 44extern "C"
44{ 45{
@@ -157,7 +158,7 @@ GNUNET_NETWORK_socket_box_native (int fd);
157 * @param doBlock blocking mode 158 * @param doBlock blocking mode
158 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 159 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
159 */ 160 */
160int 161enum GNUNET_GenericReturnValue
161GNUNET_NETWORK_socket_set_blocking (struct GNUNET_NETWORK_Handle *fd, 162GNUNET_NETWORK_socket_set_blocking (struct GNUNET_NETWORK_Handle *fd,
162 int doBlock); 163 int doBlock);
163 164
diff --git a/src/include/gnunet_nt_lib.h b/src/include/gnunet_nt_lib.h
index 144a3daa3..014b4fbe0 100644
--- a/src/include/gnunet_nt_lib.h
+++ b/src/include/gnunet_nt_lib.h
@@ -17,6 +17,11 @@
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/**
21 * @addtogroup Backbone 26 * @addtogroup Backbone
22 * @{ 27 * @{
diff --git a/src/include/gnunet_peerstore_service.h b/src/include/gnunet_peerstore_service.h
index c4000c680..c57a66b1f 100644
--- a/src/include/gnunet_peerstore_service.h
+++ b/src/include/gnunet_peerstore_service.h
@@ -46,6 +46,10 @@ extern "C" {
46#endif 46#endif
47#endif 47#endif
48 48
49/**
50 * Key used for storing HELLO in the peerstore
51 */
52#define GNUNET_PEERSTORE_HELLO_KEY "peerstore-peer-hello-uri"
49 53
50/** 54/**
51 * Key used for storing addresses in URL format in the peerstore 55 * Key used for storing addresses in URL format in the peerstore
@@ -118,6 +122,11 @@ struct GNUNET_PEERSTORE_Handle;
118struct GNUNET_PEERSTORE_StoreContext; 122struct GNUNET_PEERSTORE_StoreContext;
119 123
120/** 124/**
125 * Context for the info handler.
126 */
127struct GNUNET_PEERSTORE_NotifyContext;
128
129/**
121 * Single PEERSTORE record 130 * Single PEERSTORE record
122 */ 131 */
123struct GNUNET_PEERSTORE_Record 132struct GNUNET_PEERSTORE_Record
@@ -170,6 +179,73 @@ typedef void (*GNUNET_PEERSTORE_Continuation) (void *cls, int success);
170 179
171 180
172/** 181/**
182 * Context for a add hello uri request.
183 */
184struct GNUNET_PEERSTORE_StoreHelloContext
185{
186 /**
187 * Kept (also) in a DLL.
188 */
189 struct GNUNET_PEERSTORE_StoreHelloContext *prev;
190
191 /**
192 * Kept (also) in a DLL.
193 */
194 struct GNUNET_PEERSTORE_StoreHelloContext *next;
195
196 /**
197 * Peerstore handle.
198 */
199 struct GNUNET_PEERSTORE_Handle *h;
200
201 /**
202 * Function to call with information.
203 */
204 GNUNET_PEERSTORE_Continuation cont;
205
206 /**
207 * Closure for @e callback.
208 */
209 void *cont_cls;
210
211 /**
212 * Map with all store contexts started during adding hello.
213 */
214 struct GNUNET_CONTAINER_MultiPeerMap *store_context_map;
215
216 /**
217 * Active watch to be notified about conflicting hello uri add requests.
218 */
219 struct GNUNET_PEERSTORE_WatchContext *wc;
220
221 /**
222 * Hello uri which was request for storing.
223 */
224 struct GNUNET_MessageHeader *hello;
225
226 /**
227 * The peer id for the hello.
228 */
229 struct GNUNET_PeerIdentity *pid;
230
231 /**
232 * Was this request successful.
233 */
234 int success;
235};
236
237/**
238 * Closure to hold a GNUNET_PEERSTORE_StoreHelloContext.
239 */
240struct GNUNET_PEERSTORE_StoreHelloContextClosure
241{
242 /**
243 * The GNUNET_PEERSTORE_StoreHelloContext to hold.
244 */
245 struct GNUNET_PEERSTORE_StoreHelloContext *shc;
246};
247
248/**
173 * Function called by PEERSTORE for each matching record. 249 * Function called by PEERSTORE for each matching record.
174 * 250 *
175 * @param cls closure 251 * @param cls closure
@@ -181,6 +257,75 @@ typedef void (*GNUNET_PEERSTORE_Processor) (
181 const struct GNUNET_PEERSTORE_Record *record, 257 const struct GNUNET_PEERSTORE_Record *record,
182 const char *emsg); 258 const char *emsg);
183 259
260/**
261 * Function called by PEERSTORE when notifying a client about a changed hello.
262 *
263 * @param cls closure
264 * @param hello_uri Hello uri.
265 */
266typedef void (*GNUNET_PEERSTORE_hello_notify_cb) (
267 void *cls,
268 const struct GNUNET_PeerIdentity *peer,
269 const struct GNUNET_MessageHeader *hello,
270 const char *err_msg);
271
272/**
273 * Call a method whenever our known information about peers
274 * changes. Initially calls the given function for all known
275 * peers and then only signals changes.
276 *
277 * If @a include_friend_only is set to #GNUNET_YES peerinfo will include HELLO
278 * messages which are intended for friend to friend mode and which do not
279 * have to be gossiped. Otherwise these messages are skipped. //FIXME Not implemented atm!
280 *
281 * @param h Handle to the PEERSTORE service
282 * @param include_friend_only include HELLO messages for friends only (not used at the moment)
283 * @param callback the method to call for getting the hello.
284 * @param callback_cls closure for @a callback
285 * @return NULL on error
286 */
287struct GNUNET_PEERSTORE_NotifyContext *
288GNUNET_PEERSTORE_hello_changed_notify (struct GNUNET_PEERSTORE_Handle *h,
289 int include_friend_only,
290 GNUNET_PEERSTORE_hello_notify_cb callback,
291 void *callback_cls);
292
293
294/**
295 * Stop notifying about changes.
296 *
297 * @param nc context to stop notifying
298 */
299void
300GNUNET_PEERSTORE_hello_changed_notify_cancel (struct
301 GNUNET_PEERSTORE_NotifyContext *nc);
302
303
304/**
305 * Add hello to peerstore.
306 *
307 * @param h handle for peerstore.
308 * @param msg The hello to add.
309 * @param cont The continuation function to execute after storing.
310 * @param cont_cls The continuation function closure.
311 * @return The context for storing.
312 */
313struct GNUNET_PEERSTORE_StoreHelloContext *
314GNUNET_PEERSTORE_hello_add (struct GNUNET_PEERSTORE_Handle *h,
315 const struct GNUNET_MessageHeader *msg,
316 GNUNET_PEERSTORE_Continuation cont,
317 void *cont_cls);
318
319
320/**
321 * Cancel the request to add a hello.
322 *
323 * @param huc The context for storing a hello.
324 */
325void
326GNUNET_PEERSTORE_hello_add_cancel (struct
327 GNUNET_PEERSTORE_StoreHelloContext *huc);
328
184 329
185/** 330/**
186 * Connect to the PEERSTORE service. 331 * Connect to the PEERSTORE service.
@@ -273,7 +418,8 @@ GNUNET_PEERSTORE_iterate_cancel (struct GNUNET_PEERSTORE_IterateContext *ic);
273 418
274/** 419/**
275 * Request watching a given key 420 * Request watching a given key
276 * User will be notified with any new values added to key. 421 * User will be notified with any new values added to key,
422 * all existing entries are supplied beforehand.
277 * 423 *
278 * @param h handle to the PEERSTORE service 424 * @param h handle to the PEERSTORE service
279 * @param sub_system name of sub system 425 * @param sub_system name of sub system
diff --git a/src/include/gnunet_plugin_lib.h b/src/include/gnunet_plugin_lib.h
index a3135e2cf..2a9cde47f 100644
--- a/src/include/gnunet_plugin_lib.h
+++ b/src/include/gnunet_plugin_lib.h
@@ -70,7 +70,7 @@ typedef void *
70 * @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
71 * @return #GNUNET_YES if the plugin exists, #GNUNET_NO if not 71 * @return #GNUNET_YES if the plugin exists, #GNUNET_NO if not
72 */ 72 */
73int 73enum GNUNET_GenericReturnValue
74GNUNET_PLUGIN_test (const char *library_name); 74GNUNET_PLUGIN_test (const char *library_name);
75 75
76 76
diff --git a/src/include/gnunet_pq_lib.h b/src/include/gnunet_pq_lib.h
index 7c6deb09d..15af66b5d 100644
--- a/src/include/gnunet_pq_lib.h
+++ b/src/include/gnunet_pq_lib.h
@@ -382,7 +382,7 @@ GNUNET_PQ_query_param_array_string (
382struct GNUNET_PQ_QueryParam 382struct GNUNET_PQ_QueryParam
383GNUNET_PQ_query_param_array_ptrs_string ( 383GNUNET_PQ_query_param_array_ptrs_string (
384 unsigned int num, 384 unsigned int num,
385 const char *elements[], 385 const char *elements[static num],
386 struct GNUNET_PQ_Context *db); 386 struct GNUNET_PQ_Context *db);
387 387
388 388
diff --git a/src/include/gnunet_program_lib.h b/src/include/gnunet_program_lib.h
index 0c51d6cf7..f06d95422 100644
--- a/src/include/gnunet_program_lib.h
+++ b/src/include/gnunet_program_lib.h
@@ -18,7 +18,7 @@
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__) 21#if ! defined (__GNUNET_UTIL_LIB_H_INSIDE__)
22#error "Only <gnunet_util_lib.h> can be included directly." 22#error "Only <gnunet_util_lib.h> can be included directly."
23#endif 23#endif
24 24
@@ -122,6 +122,45 @@ GNUNET_PROGRAM_run (int argc,
122 GNUNET_PROGRAM_Main task, 122 GNUNET_PROGRAM_Main task,
123 void *task_cls); 123 void *task_cls);
124 124
125enum GNUNET_GenericReturnValue
126GNUNET_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
125 164
126#if 0 /* keep Emacsens' auto-indent happy */ 165#if 0 /* keep Emacsens' auto-indent happy */
127{ 166{
diff --git a/src/include/gnunet_reclaim_service.h b/src/include/gnunet_reclaim_service.h
index 49a006e91..a8ab8776e 100644
--- a/src/include/gnunet_reclaim_service.h
+++ b/src/include/gnunet_reclaim_service.h
@@ -74,12 +74,12 @@ struct GNUNET_RECLAIM_Ticket
74 /** 74 /**
75 * The ticket issuer (= the user) 75 * The ticket issuer (= the user)
76 */ 76 */
77 struct GNUNET_IDENTITY_PublicKey identity; 77 struct GNUNET_CRYPTO_PublicKey identity;
78 78
79 /** 79 /**
80 * The ticket audience (= relying party) 80 * The ticket audience (= relying party)
81 */ 81 */
82 struct GNUNET_IDENTITY_PublicKey audience; 82 struct GNUNET_CRYPTO_PublicKey audience;
83 83
84 /** 84 /**
85 * The ticket random identifier 85 * The ticket random identifier
@@ -134,7 +134,7 @@ typedef void (*GNUNET_RECLAIM_ContinuationWithStatus) (void *cls,
134 * @param attr The attribute 134 * @param attr The attribute
135 */ 135 */
136typedef void (*GNUNET_RECLAIM_AttributeResult) ( 136typedef void (*GNUNET_RECLAIM_AttributeResult) (
137 void *cls, const struct GNUNET_IDENTITY_PublicKey *identity, 137 void *cls, const struct GNUNET_CRYPTO_PublicKey *identity,
138 const struct GNUNET_RECLAIM_Attribute *attr); 138 const struct GNUNET_RECLAIM_Attribute *attr);
139 139
140/** 140/**
@@ -146,7 +146,7 @@ typedef void (*GNUNET_RECLAIM_AttributeResult) (
146 * @param presentation The presentation for the credential (may be NULL) 146 * @param presentation The presentation for the credential (may be NULL)
147 */ 147 */
148typedef void (*GNUNET_RECLAIM_AttributeTicketResult) ( 148typedef void (*GNUNET_RECLAIM_AttributeTicketResult) (
149 void *cls, const struct GNUNET_IDENTITY_PublicKey *identity, 149 void *cls, const struct GNUNET_CRYPTO_PublicKey *identity,
150 const struct GNUNET_RECLAIM_Attribute *attr, 150 const struct GNUNET_RECLAIM_Attribute *attr,
151 const struct GNUNET_RECLAIM_Presentation *presentation); 151 const struct GNUNET_RECLAIM_Presentation *presentation);
152 152
@@ -160,7 +160,7 @@ typedef void (*GNUNET_RECLAIM_AttributeTicketResult) (
160 * @param attributes the parsed attributes 160 * @param attributes the parsed attributes
161 */ 161 */
162typedef void (*GNUNET_RECLAIM_CredentialResult) ( 162typedef void (*GNUNET_RECLAIM_CredentialResult) (
163 void *cls, const struct GNUNET_IDENTITY_PublicKey *identity, 163 void *cls, const struct GNUNET_CRYPTO_PublicKey *identity,
164 const struct GNUNET_RECLAIM_Credential *credential); 164 const struct GNUNET_RECLAIM_Credential *credential);
165 165
166 166
@@ -189,7 +189,7 @@ GNUNET_RECLAIM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
189struct GNUNET_RECLAIM_Operation * 189struct GNUNET_RECLAIM_Operation *
190GNUNET_RECLAIM_attribute_store ( 190GNUNET_RECLAIM_attribute_store (
191 struct GNUNET_RECLAIM_Handle *h, 191 struct GNUNET_RECLAIM_Handle *h,
192 const struct GNUNET_IDENTITY_PrivateKey *pkey, 192 const struct GNUNET_CRYPTO_PrivateKey *pkey,
193 const struct GNUNET_RECLAIM_Attribute *attr, 193 const struct GNUNET_RECLAIM_Attribute *attr,
194 const struct GNUNET_TIME_Relative *exp_interval, 194 const struct GNUNET_TIME_Relative *exp_interval,
195 GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls); 195 GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls);
@@ -210,7 +210,7 @@ GNUNET_RECLAIM_attribute_store (
210struct GNUNET_RECLAIM_Operation * 210struct GNUNET_RECLAIM_Operation *
211GNUNET_RECLAIM_credential_store ( 211GNUNET_RECLAIM_credential_store (
212 struct GNUNET_RECLAIM_Handle *h, 212 struct GNUNET_RECLAIM_Handle *h,
213 const struct GNUNET_IDENTITY_PrivateKey *pkey, 213 const struct GNUNET_CRYPTO_PrivateKey *pkey,
214 const struct GNUNET_RECLAIM_Credential *credential, 214 const struct GNUNET_RECLAIM_Credential *credential,
215 const struct GNUNET_TIME_Relative *exp_interval, 215 const struct GNUNET_TIME_Relative *exp_interval,
216 GNUNET_RECLAIM_ContinuationWithStatus cont, 216 GNUNET_RECLAIM_ContinuationWithStatus cont,
@@ -231,7 +231,7 @@ GNUNET_RECLAIM_credential_store (
231struct GNUNET_RECLAIM_Operation * 231struct GNUNET_RECLAIM_Operation *
232GNUNET_RECLAIM_attribute_delete ( 232GNUNET_RECLAIM_attribute_delete (
233 struct GNUNET_RECLAIM_Handle *h, 233 struct GNUNET_RECLAIM_Handle *h,
234 const struct GNUNET_IDENTITY_PrivateKey *pkey, 234 const struct GNUNET_CRYPTO_PrivateKey *pkey,
235 const struct GNUNET_RECLAIM_Attribute *attr, 235 const struct GNUNET_RECLAIM_Attribute *attr,
236 GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls); 236 GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls);
237 237
@@ -249,7 +249,7 @@ GNUNET_RECLAIM_attribute_delete (
249struct GNUNET_RECLAIM_Operation * 249struct GNUNET_RECLAIM_Operation *
250GNUNET_RECLAIM_credential_delete ( 250GNUNET_RECLAIM_credential_delete (
251 struct GNUNET_RECLAIM_Handle *h, 251 struct GNUNET_RECLAIM_Handle *h,
252 const struct GNUNET_IDENTITY_PrivateKey *pkey, 252 const struct GNUNET_CRYPTO_PrivateKey *pkey,
253 const struct GNUNET_RECLAIM_Credential *cred, 253 const struct GNUNET_RECLAIM_Credential *cred,
254 GNUNET_RECLAIM_ContinuationWithStatus cont, 254 GNUNET_RECLAIM_ContinuationWithStatus cont,
255 void *cont_cls); 255 void *cont_cls);
@@ -281,7 +281,7 @@ GNUNET_RECLAIM_credential_delete (
281struct GNUNET_RECLAIM_AttributeIterator * 281struct GNUNET_RECLAIM_AttributeIterator *
282GNUNET_RECLAIM_get_attributes_start ( 282GNUNET_RECLAIM_get_attributes_start (
283 struct GNUNET_RECLAIM_Handle *h, 283 struct GNUNET_RECLAIM_Handle *h,
284 const struct GNUNET_IDENTITY_PrivateKey *identity, 284 const struct GNUNET_CRYPTO_PrivateKey *identity,
285 GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, 285 GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls,
286 GNUNET_RECLAIM_AttributeResult proc, void *proc_cls, 286 GNUNET_RECLAIM_AttributeResult proc, void *proc_cls,
287 GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls); 287 GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls);
@@ -337,7 +337,7 @@ GNUNET_RECLAIM_get_attributes_stop (
337struct GNUNET_RECLAIM_CredentialIterator * 337struct GNUNET_RECLAIM_CredentialIterator *
338GNUNET_RECLAIM_get_credentials_start ( 338GNUNET_RECLAIM_get_credentials_start (
339 struct GNUNET_RECLAIM_Handle *h, 339 struct GNUNET_RECLAIM_Handle *h,
340 const struct GNUNET_IDENTITY_PrivateKey *identity, 340 const struct GNUNET_CRYPTO_PrivateKey *identity,
341 GNUNET_SCHEDULER_TaskCallback error_cb, 341 GNUNET_SCHEDULER_TaskCallback error_cb,
342 void *error_cb_cls, 342 void *error_cb_cls,
343 GNUNET_RECLAIM_CredentialResult proc, 343 GNUNET_RECLAIM_CredentialResult proc,
@@ -385,8 +385,8 @@ GNUNET_RECLAIM_get_credentials_stop (
385struct GNUNET_RECLAIM_Operation * 385struct GNUNET_RECLAIM_Operation *
386GNUNET_RECLAIM_ticket_issue ( 386GNUNET_RECLAIM_ticket_issue (
387 struct GNUNET_RECLAIM_Handle *h, 387 struct GNUNET_RECLAIM_Handle *h,
388 const struct GNUNET_IDENTITY_PrivateKey *iss, 388 const struct GNUNET_CRYPTO_PrivateKey *iss,
389 const struct GNUNET_IDENTITY_PublicKey *rp, 389 const struct GNUNET_CRYPTO_PublicKey *rp,
390 const struct GNUNET_RECLAIM_AttributeList *attrs, 390 const struct GNUNET_RECLAIM_AttributeList *attrs,
391 GNUNET_RECLAIM_IssueTicketCallback cb, void *cb_cls); 391 GNUNET_RECLAIM_IssueTicketCallback cb, void *cb_cls);
392 392
@@ -407,7 +407,7 @@ GNUNET_RECLAIM_ticket_issue (
407struct GNUNET_RECLAIM_Operation * 407struct GNUNET_RECLAIM_Operation *
408GNUNET_RECLAIM_ticket_revoke ( 408GNUNET_RECLAIM_ticket_revoke (
409 struct GNUNET_RECLAIM_Handle *h, 409 struct GNUNET_RECLAIM_Handle *h,
410 const struct GNUNET_IDENTITY_PrivateKey *identity, 410 const struct GNUNET_CRYPTO_PrivateKey *identity,
411 const struct GNUNET_RECLAIM_Ticket *ticket, 411 const struct GNUNET_RECLAIM_Ticket *ticket,
412 GNUNET_RECLAIM_ContinuationWithStatus cb, void *cb_cls); 412 GNUNET_RECLAIM_ContinuationWithStatus cb, void *cb_cls);
413 413
@@ -427,7 +427,7 @@ GNUNET_RECLAIM_ticket_revoke (
427struct GNUNET_RECLAIM_Operation * 427struct GNUNET_RECLAIM_Operation *
428GNUNET_RECLAIM_ticket_consume ( 428GNUNET_RECLAIM_ticket_consume (
429 struct GNUNET_RECLAIM_Handle *h, 429 struct GNUNET_RECLAIM_Handle *h,
430 const struct GNUNET_IDENTITY_PrivateKey *identity, 430 const struct GNUNET_CRYPTO_PrivateKey *identity,
431 const struct GNUNET_RECLAIM_Ticket *ticket, 431 const struct GNUNET_RECLAIM_Ticket *ticket,
432 GNUNET_RECLAIM_AttributeTicketResult cb, void *cb_cls); 432 GNUNET_RECLAIM_AttributeTicketResult cb, void *cb_cls);
433 433
@@ -452,7 +452,7 @@ GNUNET_RECLAIM_ticket_consume (
452struct GNUNET_RECLAIM_TicketIterator * 452struct GNUNET_RECLAIM_TicketIterator *
453GNUNET_RECLAIM_ticket_iteration_start ( 453GNUNET_RECLAIM_ticket_iteration_start (
454 struct GNUNET_RECLAIM_Handle *h, 454 struct GNUNET_RECLAIM_Handle *h,
455 const struct GNUNET_IDENTITY_PrivateKey *identity, 455 const struct GNUNET_CRYPTO_PrivateKey *identity,
456 GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, 456 GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls,
457 GNUNET_RECLAIM_TicketCallback proc, void *proc_cls, 457 GNUNET_RECLAIM_TicketCallback proc, void *proc_cls,
458 GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls); 458 GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls);
diff --git a/src/include/gnunet_rest_plugin.h b/src/include/gnunet_rest_plugin.h
index 45b391ca1..3a8af5389 100644
--- a/src/include/gnunet_rest_plugin.h
+++ b/src/include/gnunet_rest_plugin.h
@@ -63,24 +63,13 @@ struct GNUNET_REST_Plugin
63 * e.g. http://hostname:port/name 63 * e.g. http://hostname:port/name
64 */ 64 */
65 char *name; 65 char *name;
66
67 /**
68 * Function to process a REST call
69 *
70 * @param method the HTTP method called
71 * @param url the relative url accessed
72 * @param data the REST data (can be NULL)
73 * @param data_size the length of the data
74 * @param proc the callback for result
75 * @param proc_cls closure for callback
76 * @return GNUNET_YES if the request was processed
77 */
78 enum GNUNET_GenericReturnValue (*process_request)(
79 struct GNUNET_REST_RequestHandle *handle,
80 GNUNET_REST_ResultProcessor proc,
81 void *proc_cls);
82}; 66};
83 67
68typedef enum GNUNET_GenericReturnValue (*GNUNET_REST_ProcessingFunction)(
69 void *plugin,
70 struct GNUNET_REST_RequestHandle *handle,
71 GNUNET_REST_ResultProcessor proc,
72 void *proc_cls);
84 73
85#if 0 /* keep Emacsens' auto-indent happy */ 74#if 0 /* keep Emacsens' auto-indent happy */
86{ 75{
diff --git a/src/include/gnunet_revocation_service.h b/src/include/gnunet_revocation_service.h
index 81a90189b..427be62ac 100644
--- a/src/include/gnunet_revocation_service.h
+++ b/src/include/gnunet_revocation_service.h
@@ -22,6 +22,7 @@
22#define GNUNET_REVOCATION_SERVICE_H_ 22#define GNUNET_REVOCATION_SERVICE_H_
23 23
24 24
25#include "gnunet_gnsrecord_lib.h"
25#include "gnunet_identity_service.h" 26#include "gnunet_identity_service.h"
26 27
27/** 28/**
@@ -56,71 +57,6 @@ extern "C"
56 */ 57 */
57#define GNUNET_REVOCATION_VERSION 0x00000001 58#define GNUNET_REVOCATION_VERSION 0x00000001
58 59
59/**
60 * Maximum length of a revocation
61 */
62#define GNUNET_REVOCATION_MAX_PROOF_SIZE sizeof(struct GNUNET_REVOCATION_PowP) +\
63 sizeof(struct GNUNET_IDENTITY_PublicKey) +\
64 1024 //FIXME max sig_len
65
66/**
67 * The proof-of-work narrowing factor.
68 * The number of PoWs that are calculates as part of revocation.
69 */
70#define POW_COUNT 32
71
72
73GNUNET_NETWORK_STRUCT_BEGIN
74
75/**
76 * Struct for a proof of work as part of the revocation.
77 */
78struct GNUNET_REVOCATION_PowP
79{
80 /**
81 * The timestamp of the revocation
82 */
83 struct GNUNET_TIME_AbsoluteNBO timestamp;
84
85 /**
86 * The TTL of this revocation (purely informational)
87 */
88 struct GNUNET_TIME_RelativeNBO ttl;
89
90 /**
91 * The PoWs
92 */
93 uint64_t pow[POW_COUNT] GNUNET_PACKED;
94
95 /** followed by the public key type, the key and a signature **/
96};
97
98
99/**
100 * The signature object we use for the PoW
101 */
102struct GNUNET_REVOCATION_SignaturePurposePS
103{
104 /**
105 * The signature purpose
106 */
107 struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
108
109 /**
110 * The timestamp of the revocation
111 */
112 struct GNUNET_TIME_AbsoluteNBO timestamp;
113
114 /** Followed by the zone public key type and key **/
115};
116
117GNUNET_NETWORK_STRUCT_END
118
119
120/**
121 * Handle to a running proof-of-work calculation.
122 */
123struct GNUNET_REVOCATION_PowCalculationHandle;
124 60
125/** 61/**
126 * Handle for the key revocation query. 62 * Handle for the key revocation query.
@@ -152,7 +88,7 @@ typedef void (*GNUNET_REVOCATION_Callback) (void *cls,
152 */ 88 */
153struct GNUNET_REVOCATION_Query * 89struct GNUNET_REVOCATION_Query *
154GNUNET_REVOCATION_query (const struct GNUNET_CONFIGURATION_Handle *cfg, 90GNUNET_REVOCATION_query (const struct GNUNET_CONFIGURATION_Handle *cfg,
155 const struct GNUNET_IDENTITY_PublicKey *key, 91 const struct GNUNET_CRYPTO_PublicKey *key,
156 GNUNET_REVOCATION_Callback func, void *func_cls); 92 GNUNET_REVOCATION_Callback func, void *func_cls);
157 93
158 94
@@ -176,7 +112,7 @@ struct GNUNET_REVOCATION_Handle;
176 * 112 *
177 * @param cfg the configuration to use 113 * @param cfg the configuration to use
178 * @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
179 * iteratively calling #GNUNET_REVOCATION_pow_round) 115 * iteratively calling #GNUNET_CRYPTO_pow_round)
180 * @param func function to call with the result of the check 116 * @param func function to call with the result of the check
181 * (called with `is_valid` being #GNUNET_NO if 117 * (called with `is_valid` being #GNUNET_NO if
182 * the revocation worked). 118 * the revocation worked).
@@ -185,7 +121,7 @@ struct GNUNET_REVOCATION_Handle;
185 */ 121 */
186struct GNUNET_REVOCATION_Handle * 122struct GNUNET_REVOCATION_Handle *
187GNUNET_REVOCATION_revoke (const struct GNUNET_CONFIGURATION_Handle *cfg, 123GNUNET_REVOCATION_revoke (const struct GNUNET_CONFIGURATION_Handle *cfg,
188 const struct GNUNET_REVOCATION_PowP *pow, 124 const struct GNUNET_GNSRECORD_PowP *pow,
189 GNUNET_REVOCATION_Callback func, void *func_cls); 125 GNUNET_REVOCATION_Callback func, void *func_cls);
190 126
191 127
@@ -198,68 +134,6 @@ void
198GNUNET_REVOCATION_revoke_cancel (struct GNUNET_REVOCATION_Handle *h); 134GNUNET_REVOCATION_revoke_cancel (struct GNUNET_REVOCATION_Handle *h);
199 135
200 136
201/**
202 * Check if the given proof-of-work is valid.
203 *
204 * @param pow proof of work
205 * @param matching_bits how many bits must match (configuration)
206 * @param epoch_duration length of single epoch in configuration
207 * @return #GNUNET_YES if the @a pow is acceptable, #GNUNET_NO if not
208 */
209enum GNUNET_GenericReturnValue
210GNUNET_REVOCATION_check_pow (const struct GNUNET_REVOCATION_PowP *pow,
211 unsigned int matching_bits,
212 struct GNUNET_TIME_Relative epoch_duration);
213
214
215/**
216 * Initializes a fresh PoW computation.
217 *
218 * @param key the key to calculate the PoW for.
219 * @param pow the pow object to work with in the calculation.
220 */
221void
222GNUNET_REVOCATION_pow_init (const struct GNUNET_IDENTITY_PrivateKey *key,
223 struct GNUNET_REVOCATION_PowP *pow);
224
225
226/**
227 * Starts a proof-of-work calculation given the pow object as well as
228 * target epochs and difficulty.
229 *
230 * @param pow the PoW to based calculations on.
231 * @param epochs the number of epochs for which the PoW must be valid.
232 * @param difficulty the base difficulty of the PoW.
233 * @return a handle for use in PoW rounds
234 */
235struct GNUNET_REVOCATION_PowCalculationHandle*
236GNUNET_REVOCATION_pow_start (struct GNUNET_REVOCATION_PowP *pow,
237 int epochs,
238 unsigned int difficulty);
239
240
241/**
242 * Calculate a single round in the key revocation PoW.
243 *
244 * @param pc handle to the PoW, initially called with NULL.
245 * @return GNUNET_YES if the @a pow is acceptable, GNUNET_NO if not
246 */
247enum GNUNET_GenericReturnValue
248GNUNET_REVOCATION_pow_round (struct GNUNET_REVOCATION_PowCalculationHandle *pc);
249
250
251/**
252 * Stop a PoW calculation
253 *
254 * @param pc the calculation to clean up
255 * @return #GNUNET_YES if pow valid, #GNUNET_NO if pow was set but is not
256 * valid
257 */
258void
259GNUNET_REVOCATION_pow_stop (struct GNUNET_REVOCATION_PowCalculationHandle *pc);
260
261size_t
262GNUNET_REVOCATION_proof_get_size (const struct GNUNET_REVOCATION_PowP *pow);
263 137
264 138
265#if 0 /* keep Emacsens' auto-indent happy */ 139#if 0 /* keep Emacsens' auto-indent happy */
diff --git a/src/include/gnunet_service_lib.h b/src/include/gnunet_service_lib.h
index 7c6ce0c0e..0ad4fcc3c 100644
--- a/src/include/gnunet_service_lib.h
+++ b/src/include/gnunet_service_lib.h
@@ -19,7 +19,7 @@
19 */ 19 */
20 20
21 21
22#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) 22#if ! defined (__GNUNET_UTIL_LIB_H_INSIDE__)
23#error "Only <gnunet_util_lib.h> can be included directly." 23#error "Only <gnunet_util_lib.h> can be included directly."
24#endif 24#endif
25 25
@@ -203,7 +203,6 @@ GNUNET_SERVICE_start (const char *service_name,
203void 203void
204GNUNET_SERVICE_stop (struct GNUNET_SERVICE_Handle *srv); 204GNUNET_SERVICE_stop (struct GNUNET_SERVICE_Handle *srv);
205 205
206
207/** 206/**
208 * Creates the "main" function for a GNUnet service. You 207 * Creates the "main" function for a GNUnet service. You
209 * should almost always use the #GNUNET_SERVICE_MAIN macro 208 * should almost always use the #GNUNET_SERVICE_MAIN macro
@@ -258,6 +257,56 @@ GNUNET_SERVICE_run_ (int argc,
258 257
259 258
260/** 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 */
298int
299GNUNET_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/**
261 * Creates the "main" function for a GNUnet service. You 310 * Creates the "main" function for a GNUnet service. You
262 * MUST use this macro to define GNUnet services (except 311 * MUST use this macro to define GNUnet services (except
263 * for ARM, which MUST NOT use the macro). The reason is 312 * for ARM, which MUST NOT use the macro). The reason is
@@ -314,26 +363,51 @@ GNUNET_SERVICE_run_ (int argc,
314 * GNUNET_MQ_handler_end ()); 363 * GNUNET_MQ_handler_end ());
315 * </code> 364 * </code>
316 */ 365 */
366#ifndef HAVE_GNUNET_MONOLITH
317#define GNUNET_SERVICE_MAIN(service_name, service_options, init_cb, connect_cb, \ 367#define GNUNET_SERVICE_MAIN(service_name, service_options, init_cb, connect_cb, \
318 disconnect_cb, cls, ...) \ 368 disconnect_cb, cls, ...) \
319 int \ 369 int \
320 main (int argc, \ 370 main (int argc, \
321 char *const *argv) \ 371 char *const *argv) \
322 { \ 372 { \
323 struct GNUNET_MQ_MessageHandler mh[] = { \ 373 struct GNUNET_MQ_MessageHandler mh[] = { \
324 __VA_ARGS__ \ 374 __VA_ARGS__ \
325 }; \ 375 }; \
326 return GNUNET_SERVICE_run_ (argc, \ 376 return GNUNET_SERVICE_run_ (argc, \
327 argv, \ 377 argv, \
328 service_name, \ 378 service_name, \
329 service_options, \ 379 service_options, \
330 init_cb, \ 380 init_cb, \
331 connect_cb, \ 381 connect_cb, \
332 disconnect_cb, \ 382 disconnect_cb, \
333 cls, \ 383 cls, \
334 mh); \ 384 mh); \
335 } 385 }
386#else
387#define GNUNET_SERVICE_MAIN(service_name, service_options, init_cb, connect_cb, \
388 disconnect_cb, cls, ...) \
389 static int __attribute__ ((constructor)) \
390 init (void) \
391 { \
392 struct GNUNET_MQ_MessageHandler mh[] = { \
393 __VA_ARGS__ \
394 }; \
395 return GNUNET_SERVICE_register_ (service_name, \
396 service_options, \
397 init_cb, \
398 connect_cb, \
399 disconnect_cb, \
400 cls, \
401 mh); \
402 }
403#endif
336 404
405/**
406 * Run the mainloop in a monolithic libgnunet.
407 * Must be called such that services are actually launched.
408 */
409void
410GNUNET_SERVICE_main (int argc, char *const *argv);
337 411
338/** 412/**
339 * Suspend accepting connections from the listen socket temporarily. 413 * Suspend accepting connections from the listen socket temporarily.
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
35extern "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_testing_netjail_lib.h b/src/include/gnunet_testing_netjail_lib.h
index 1d6f114eb..9d016b33a 100644
--- a/src/include/gnunet_testing_netjail_lib.h
+++ b/src/include/gnunet_testing_netjail_lib.h
@@ -343,6 +343,7 @@ GNUNET_TESTING_calculate_num (struct
343 GNUNET_TESTING_NodeConnection *node_connection, 343 GNUNET_TESTING_NodeConnection *node_connection,
344 struct GNUNET_TESTING_NetjailTopology *topology); 344 struct GNUNET_TESTING_NetjailTopology *topology);
345 345
346
346/** 347/**
347 * Struct with information for callbacks. 348 * Struct with information for callbacks.
348 * 349 *
@@ -507,6 +508,26 @@ GNUNET_TESTING_cmd_local_test_prepared (const char *label,
507 write_message); 508 write_message);
508 509
509 510
511/**
512 * Create command.
513 *
514 * @param label name for command.
515 * @param system_label Label of the cmd to setup a test environment.
516 * @param no Decimal number representing the last byte of the IP address of this peer.
517 * @param node_ip The IP address of this node.
518 * @param cfgname Configuration file name for this peer.
519 * @param broadcast Flag indicating, if broadcast should be switched on.
520 * @return command.
521 */
522struct GNUNET_TESTING_Command
523GNUNET_TESTING_cmd_start_peer (const char *label,
524 const char *system_label,
525 uint32_t no,
526 const char *node_ip,
527 const char *cfgname,
528 unsigned int broadcast);
529
530
510/* ***** Netjail trait support ***** */ 531/* ***** Netjail trait support ***** */
511 532
512 533
diff --git a/src/include/gnunet_testing_ng_lib.h b/src/include/gnunet_testing_ng_lib.h
index 5c9079fdf..07cdac962 100644
--- a/src/include/gnunet_testing_ng_lib.h
+++ b/src/include/gnunet_testing_ng_lib.h
@@ -31,7 +31,13 @@
31#include "gnunet_util_lib.h" 31#include "gnunet_util_lib.h"
32#include "gnunet_testing_lib.h" 32#include "gnunet_testing_lib.h"
33 33
34 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
35 41
36/** 42/**
37 * Maximum length of label in command 43 * Maximum length of label in command
@@ -520,6 +526,20 @@ struct GNUNET_TESTING_Timer
520 unsigned int num_retries; 526 unsigned int num_retries;
521}; 527};
522 528
529/**
530 * Command to execute a script synchronously.
531 *
532 * @param label Label of the command.
533 * @param script The name of the script.
534 * @param script_argv The arguments of the script.
535*/
536const struct GNUNET_TESTING_Command
537GNUNET_TESTING_cmd_exec_bash_script (const char *label,
538 const char *script,
539 char *const script_argv[],
540 int argc,
541 GNUNET_ChildCompletedCallback cb);
542
523 543
524/** 544/**
525 * Retrieve peer identity from the test system with the unique node id. 545 * Retrieve peer identity from the test system with the unique node id.
@@ -530,7 +550,7 @@ struct GNUNET_TESTING_Timer
530 */ 550 */
531struct GNUNET_PeerIdentity * 551struct GNUNET_PeerIdentity *
532GNUNET_TESTING_get_peer (unsigned int num, 552GNUNET_TESTING_get_peer (unsigned int num,
533 const struct GNUNET_TESTING_System *tl_system); 553 const struct GNUNET_TESTING_System *tl_system);
534 554
535 555
536/** 556/**
@@ -546,12 +566,12 @@ GNUNET_TESTING_cmd_stat (struct GNUNET_TESTING_Timer *timers);
546/* *** Generic trait logic for implementing traits ********* */ 566/* *** Generic trait logic for implementing traits ********* */
547 567
548/** 568/**
549 * A struct GNUNET_TESTING_Trait can be used to exchange data between cmds. 569 * A struct GNUNET_TESTING_Trait can be used to exchange data between cmds.
550 * 570 *
551 * Therefor the cmd which like to provide data to other cmds has to implement 571 * Therefor the cmd which like to provide data to other cmds has to implement
552 * the trait function, where an array of traits is defined with the help of the 572 * the trait function, where an array of traits is defined with the help of the
553 * GNUNET_TESTING_make_trait_ macro. The data can be retrieved with the help of the 573 * GNUNET_TESTING_make_trait_ macro. The data can be retrieved with the help of the
554 * GNUNET_TESTING_get_trait_ macro. Traits name and type must be defined to make 574 * GNUNET_TESTING_get_trait_ macro. Traits name and type must be defined to make
555 * use of the macros. 575 * use of the macros.
556 */ 576 */
557struct GNUNET_TESTING_Trait 577struct GNUNET_TESTING_Trait
@@ -604,6 +624,277 @@ GNUNET_TESTING_get_trait (const struct GNUNET_TESTING_Trait *traits,
604/* ****** Specific traits supported by this component ******* */ 624/* ****** Specific traits supported by this component ******* */
605 625
606 626
627typedef void *
628(*GNUNET_TESTING_notify_connect_cb) (struct GNUNET_TESTING_Interpreter *is,
629 const struct GNUNET_PeerIdentity *peer);
630
631/**
632 * Struct to store information needed in callbacks.
633 *
634 */
635struct GNUNET_TESTING_ConnectPeersState
636{
637 /**
638 * Receive callback
639 */
640 struct GNUNET_MQ_MessageHandler *handlers;
641
642 /**
643 * A map with struct GNUNET_MQ_Handle values for each peer this peer
644 * is connected to.
645 */
646 struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
647
648 /**
649 * Handle for transport.
650 */
651 struct GNUNET_TRANSPORT_ApplicationHandle *ah;
652
653 /**
654 * Core handle.
655 */
656 struct GNUNET_TRANSPORT_CoreHandle *th;
657
658 /**
659 * Context for our asynchronous completion.
660 */
661 struct GNUNET_TESTING_AsyncContext ac;
662
663 /**
664 * The testing system of this node.
665 */
666 const struct GNUNET_TESTING_System *tl_system;
667
668 // Label of the cmd which started the test system.
669 const char *create_label;
670
671 /**
672 * Number globally identifying the node.
673 *
674 */
675 uint32_t num;
676
677 /**
678 * Label of the cmd to start a peer.
679 *
680 */
681 const char *start_peer_label;
682
683 /**
684 * The topology of the test setup.
685 */
686 struct GNUNET_TESTING_NetjailTopology *topology;
687
688 /**
689 * Connections to other peers.
690 */
691 struct GNUNET_TESTING_NodeConnection *node_connections_head;
692
693 struct GNUNET_TESTING_Interpreter *is;
694
695 /**
696 * Number of connections.
697 */
698 unsigned int con_num;
699
700 /**
701 * Number of additional connects this cmd will wait for not triggered by this cmd.
702 */
703 unsigned int additional_connects;
704
705 /**
706 * Number of connections we already have a notification for.
707 */
708 unsigned int con_num_notified;
709
710 /**
711 * Number of additional connects this cmd will wait for not triggered by this cmd we already have a notification for.
712 */
713 unsigned int additional_connects_notified;
714
715 /**
716 * Flag indicating, whether the command is waiting for peers to connect that are configured to connect.
717 */
718 unsigned int wait_for_connect;
719};
720
721/**
722 * Struct to store information needed in callbacks.
723 *
724 */
725struct ConnectPeersState
726{
727 /**
728 * Context for our asynchronous completion.
729 */
730 struct GNUNET_TESTING_AsyncContext ac;
731
732 GNUNET_TESTING_notify_connect_cb notify_connect;
733
734 /**
735 * The testing system of this node.
736 */
737 const struct GNUNET_TESTING_System *tl_system;
738
739 // Label of the cmd which started the test system.
740 const char *create_label;
741
742 /**
743 * Number globally identifying the node.
744 *
745 */
746 uint32_t num;
747
748 /**
749 * Label of the cmd to start a peer.
750 *
751 */
752 const char *start_peer_label;
753
754 /**
755 * The topology of the test setup.
756 */
757 struct GNUNET_TESTING_NetjailTopology *topology;
758
759 /**
760 * Connections to other peers.
761 */
762 struct GNUNET_TESTING_NodeConnection *node_connections_head;
763
764 struct GNUNET_TESTING_Interpreter *is;
765
766 /**
767 * Number of connections.
768 */
769 unsigned int con_num;
770
771 /**
772 * Number of additional connects this cmd will wait for not triggered by this cmd.
773 */
774 unsigned int additional_connects;
775
776 /**
777 * Number of connections we already have a notification for.
778 */
779 unsigned int con_num_notified;
780
781 /**
782 * Number of additional connects this cmd will wait for not triggered by this cmd we already have a notification for.
783 */
784 unsigned int additional_connects_notified;
785
786 /**
787 * Flag indicating, whether the command is waiting for peers to connect that are configured to connect.
788 */
789 unsigned int wait_for_connect;
790};
791
792
793struct GNUNET_TESTING_StartPeerState
794{
795 /**
796 * Context for our asynchronous completion.
797 */
798 struct GNUNET_TESTING_AsyncContext ac;
799
800 /**
801 * The ip of a node.
802 */
803 char *node_ip;
804
805 /**
806 * Receive callback
807 */
808 struct GNUNET_MQ_MessageHandler *handlers;
809
810 /**
811 * GNUnet configuration file used to start a peer.
812 */
813 char *cfgname;
814
815 /**
816 * Peer's configuration
817 */
818 struct GNUNET_CONFIGURATION_Handle *cfg;
819
820 /**
821 * struct GNUNET_TESTING_Peer returned by GNUNET_TESTING_peer_configure.
822 */
823 struct GNUNET_TESTING_Peer *peer;
824
825 /**
826 * Peer identity
827 */
828 struct GNUNET_PeerIdentity id;
829
830 /**
831 * Peer's transport service handle
832 */
833 struct GNUNET_TRANSPORT_CoreHandle *th;
834
835 /**
836 * Application handle
837 */
838 struct GNUNET_TRANSPORT_ApplicationHandle *ah;
839
840 /**
841 * Peer's PEERSTORE Handle
842 */
843 struct GNUNET_PEERSTORE_Handle *ph;
844
845 /**
846 * Hello get task
847 */
848 struct GNUNET_SCHEDULER_Task *rh_task;
849
850 /**
851 * Peer's transport get hello handle to retrieve peer's HELLO message
852 */
853 struct GNUNET_PEERSTORE_IterateContext *pic;
854
855 /**
856 * Hello
857 */
858 char *hello;
859
860 /**
861 * Hello size
862 */
863 size_t hello_size;
864
865 /**
866 * The label of the command which was started by calling GNUNET_TESTING_cmd_system_create.
867 */
868 char *system_label;
869
870 /**
871 * An unique number to identify the peer
872 */
873 unsigned int no;
874
875 /**
876 * A map with struct GNUNET_MQ_Handle values for each peer this peer
877 * is connected to.
878 */
879 struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
880
881 /**
882 * Test setup for this peer.
883 */
884 const struct GNUNET_TESTING_System *tl_system;
885
886 /**
887 * Callback which is called on neighbour connect events.
888 */
889 GNUNET_TESTING_notify_connect_cb notify_connect;
890
891 /**
892 * Flag indicating, if udp broadcast should be switched on.
893 */
894 enum GNUNET_GenericReturnValue broadcast;
895};
896
897
607/** 898/**
608 * Create headers for a trait with name @a name for 899 * Create headers for a trait with name @a name for
609 * statically allocated data of type @a type. 900 * statically allocated data of type @a type.
@@ -698,7 +989,15 @@ GNUNET_TESTING_get_trait (const struct GNUNET_TESTING_Trait *traits,
698 */ 989 */
699#define GNUNET_TESTING_SIMPLE_TRAITS(op) \ 990#define GNUNET_TESTING_SIMPLE_TRAITS(op) \
700 op (batch_cmds, struct GNUNET_TESTING_Command *) \ 991 op (batch_cmds, struct GNUNET_TESTING_Command *) \
701 op (process, struct GNUNET_OS_Process *) 992 op (process, struct GNUNET_OS_Process *) \
993 op (peer_id, const struct GNUNET_PeerIdentity) \
994 op (connected_peers_map, const struct GNUNET_CONTAINER_MultiShortmap) \
995 op (hello_size, const size_t) \
996 op (hello, const char) \
997 op (application_handle, const struct GNUNET_TRANSPORT_ApplicationHandle) \
998 op (connect_peer_state, const struct GNUNET_TESTING_ConnectPeersState) \
999 op (state, const struct GNUNET_TESTING_StartPeerState) \
1000 op (broadcast, const enum GNUNET_GenericReturnValue)
702 1001
703 1002
704/** 1003/**
diff --git a/src/include/gnunet_testing_plugin.h b/src/include/gnunet_testing_plugin.h
index 12fbd7b75..d6a3560ef 100644
--- a/src/include/gnunet_testing_plugin.h
+++ b/src/include/gnunet_testing_plugin.h
@@ -40,6 +40,7 @@ extern "C"
40 40
41struct GNUNET_TESTING_Barrier; 41struct GNUNET_TESTING_Barrier;
42 42
43
43/** 44/**
44 * Callback function to write messages from the helper process running on a netjail node to the master process. 45 * Callback function to write messages from the helper process running on a netjail node to the master process.
45 * 46 *
@@ -48,7 +49,7 @@ struct GNUNET_TESTING_Barrier;
48 */ 49 */
49typedef void 50typedef void
50(*GNUNET_TESTING_cmd_helper_write_cb) (struct GNUNET_MessageHeader *message, 51(*GNUNET_TESTING_cmd_helper_write_cb) (struct GNUNET_MessageHeader *message,
51 size_t msg_length); 52 size_t msg_length);
52 53
53/** 54/**
54 * 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. 55 * 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.
@@ -70,7 +71,7 @@ typedef void
70 * the topology configuration. 71 * the topology configuration.
71 * @param read_file If read_file is GNUNET_YES this string is the filename for the topology configuration, 72 * @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 * 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 * @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 * 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 * @return Returns The struct GNUNET_TESTING_Interpreter of the command loop running on this netjail node.
76 */ 77 */
@@ -84,7 +85,8 @@ typedef struct GNUNET_TESTING_Interpreter *
84 const char *local_m, 85 const char *local_m,
85 const char *topology_data, 86 const char *topology_data,
86 unsigned int *read_file, 87 unsigned int *read_file,
87 GNUNET_TESTING_cmd_helper_finish_cb finish_cb); 88 GNUNET_TESTING_cmd_helper_finish_cb
89 finish_cb);
88 90
89/** 91/**
90 * DEPRECATED 92 * DEPRECATED
diff --git a/src/include/gnunet_transport_application_service.h b/src/include/gnunet_transport_application_service.h
index 47f07a5f8..66512089a 100644
--- a/src/include/gnunet_transport_application_service.h
+++ b/src/include/gnunet_transport_application_service.h
@@ -19,7 +19,7 @@
19 */ 19 */
20/** 20/**
21 * @addtogroup Backbone 21 * @addtogroup Backbone
22 * @{ 22 * @{
23 * 23 *
24 * @file 24 * @file
25 * Bandwidth allocation API for applications to interact with 25 * Bandwidth allocation API for applications to interact with
@@ -36,7 +36,6 @@
36 36
37#include "gnunet_constants.h" 37#include "gnunet_constants.h"
38#include "gnunet_util_lib.h" 38#include "gnunet_util_lib.h"
39#include "gnunet_nt_lib.h"
40#include "gnunet_testing_lib.h" 39#include "gnunet_testing_lib.h"
41#include "gnunet_testing_ng_lib.h" 40#include "gnunet_testing_ng_lib.h"
42 41
diff --git a/src/include/gnunet_transport_communication_service.h b/src/include/gnunet_transport_communication_service.h
index a705b1970..92facb0e0 100644
--- a/src/include/gnunet_transport_communication_service.h
+++ b/src/include/gnunet_transport_communication_service.h
@@ -47,7 +47,6 @@ extern "C" {
47 47
48 48
49#include "gnunet_util_lib.h" 49#include "gnunet_util_lib.h"
50#include "gnunet_nt_lib.h"
51 50
52/** 51/**
53 * Version number of the transport communication API. 52 * Version number of the transport communication API.
@@ -139,7 +138,7 @@ typedef void (*GNUNET_TRANSPORT_CommunicatorNotify) (
139 * Connect to the transport service. 138 * Connect to the transport service.
140 * 139 *
141 * @param cfg configuration to use 140 * @param cfg configuration to use
142 * @param config_section_name section of the configuration to use for 141 * @param config_section_name section of the configuration to use for
143 * options 142 * options
144 * @param addr_prefix address prefix for addresses supported by this 143 * @param addr_prefix address prefix for addresses supported by this
145 * communicator, could be NULL for incoming-only communicators 144 * communicator, could be NULL for incoming-only communicators
diff --git a/src/include/gnunet_transport_hello_service.h b/src/include/gnunet_transport_hello_service.h
deleted file mode 100644
index 03305ec27..000000000
--- a/src/include/gnunet_transport_hello_service.h
+++ /dev/null
@@ -1,207 +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 * @addtogroup Backbone
23 * @{
24 *
25 * @author Christian Grothoff
26 *
27 * @file
28 * obtain information about our current address
29 *
30 * @deprecated, in TNG applications should query PEERSTORE directly!
31 *
32 * @defgroup transport Transport service
33 * address information
34 *
35 * @see [Documentation](https://gnunet.org/transport-service)
36 *
37 * @{
38 */
39#ifndef GNUNET_TRANSPORT_HELLO_SERVICE_H
40#define GNUNET_TRANSPORT_HELLO_SERVICE_H
41
42#ifdef __cplusplus
43extern "C" {
44#if 0 /* keep Emacsens' auto-indent happy */
45}
46#endif
47#endif
48
49
50#include "gnunet_util_lib.h"
51#include "gnunet_ats_service.h"
52
53/**
54 * Version number of the transport API.
55 */
56#define GNUNET_TRANSPORT_HELLO_VERSION 0x00000000
57
58
59/**
60 * Some addresses contain sensitive information or are
61 * not suitable for global distribution. We use address
62 * classes to filter addresses by which domain they make
63 * sense to be used in. These are used in a bitmask.
64 */
65enum GNUNET_TRANSPORT_AddressClass
66{
67 /**
68 * No address.
69 */
70 GNUNET_TRANSPORT_AC_NONE = 0,
71
72 /**
73 * Addresses that fall into no other category
74 * (i.e. incoming which we cannot use elsewhere).
75 */
76 GNUNET_TRANSPORT_AC_OTHER = 1,
77
78 /**
79 * Addresses that are global and are insensitive
80 * (i.e. IPv4).
81 */
82 GNUNET_TRANSPORT_AC_GLOBAL = 2,
83
84 /**
85 * Addresses that are global and are sensitive
86 * (i.e. IPv6 with our MAC).
87 */
88 GNUNET_TRANSPORT_AC_GLOBAL_PRIVATE = 4,
89
90 /**
91 * Addresses useful in the local wired network,
92 * i.e. a MAC. Sensitive, but obvious to people nearby.
93 * Useful for broadcasts.
94 */
95 GNUNET_TRANSPORT_AC_LAN = 8,
96
97 /**
98 * Addresses useful in the local wireless network,
99 * i.e. a MAC. Sensitive, but obvious to people nearby.
100 * Useful for broadcasts.
101 */
102 GNUNET_TRANSPORT_AC_WLAN = 16,
103
104 /**
105 * Addresses useful in the local bluetooth network. Sensitive, but
106 * obvious to people nearby. Useful for broadcasts.
107 */
108 GNUNET_TRANSPORT_AC_BT = 32,
109
110 /**
111 * Bitmask for "any" address.
112 */
113 GNUNET_TRANSPORT_AC_ANY = 65535
114};
115
116
117/**
118 * Function called whenever there is an update to the
119 * HELLO of this peer.
120 *
121 * @param cls closure
122 * @param hello our updated HELLO
123 */
124typedef void (*GNUNET_TRANSPORT_HelloUpdateCallback) (
125 void *cls,
126 const struct GNUNET_MessageHeader *hello);
127
128
129/**
130 * Handle to cancel a #GNUNET_TRANSPORT_hello_get() operation.
131 */
132struct GNUNET_TRANSPORT_HelloGetHandle;
133
134
135/**
136 * Obtain updates on changes to the HELLO message for this peer. The callback
137 * given in this function is never called synchronously.
138 *
139 * @param cfg configuration to use
140 * @param ac which network type should the addresses from the HELLO belong to?
141 * @param rec function to call with the HELLO
142 * @param rec_cls closure for @a rec
143 * @return handle to cancel the operation
144 */
145struct GNUNET_TRANSPORT_HelloGetHandle *
146GNUNET_TRANSPORT_hello_get (const struct GNUNET_CONFIGURATION_Handle *cfg,
147 enum GNUNET_TRANSPORT_AddressClass ac,
148 GNUNET_TRANSPORT_HelloUpdateCallback rec,
149 void *rec_cls);
150
151
152/**
153 * Stop receiving updates about changes to our HELLO message.
154 *
155 * @param ghh handle to cancel
156 */
157void
158GNUNET_TRANSPORT_hello_get_cancel (struct GNUNET_TRANSPORT_HelloGetHandle *ghh);
159
160
161/**
162 * Function with addresses found in a HELLO.
163 *
164 * @param cls closure
165 * @param peer identity of the peer
166 * @param address the address (UTF-8, 0-terminated)
167 * @param nt network type of the address
168 * @param expiration when does this address expire?
169 */
170typedef void (*GNUNET_TRANSPORT_AddressCallback) (
171 void *cls,
172 const struct GNUNET_PeerIdentity *peer,
173 const char *address,
174 enum GNUNET_NetworkType nt,
175 struct GNUNET_TIME_Absolute expiration);
176
177
178/**
179 * Parse a HELLO message that we have received into its
180 * constituent addresses.
181 *
182 * @param hello message to parse
183 * @param cb function to call on each address found
184 * @param cb_cls closure for @a cb
185 * @return #GNUNET_OK if hello was well-formed, #GNUNET_SYSERR if not
186 */
187int
188GNUNET_TRANSPORT_hello_parse (const struct GNUNET_MessageHeader *hello,
189 GNUNET_TRANSPORT_AddressCallback cb,
190 void *cb_cls);
191
192
193#if 0 /* keep Emacsens' auto-indent happy */
194{
195#endif
196#ifdef __cplusplus
197}
198#endif
199
200/* ifndef GNUNET_TRANSPORT_HELLO_SERVICE_H */
201#endif
202
203/** @} */ /* end of group */
204
205/** @} */ /* end of group addition */
206
207/* 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 694ca7dca..000000000
--- a/src/include/gnunet_transport_manipulation_service.h
+++ /dev/null
@@ -1,123 +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 * @addtogroup Backbone
23 * @{
24 *
25 * @author Christian Grothoff
26 *
27 * @file
28 * Low-level P2P IO
29 *
30 * @defgroup transport Transport service
31 * Low-level P2P IO
32 *
33 * @see [Documentation](https://gnunet.org/transport-service)
34 *
35 * @{
36 */
37
38#ifndef GNUNET_TRANSPORT_MANIPULATION_SERVICE_H
39#define GNUNET_TRANSPORT_MANIPULATION_SERVICE_H
40
41
42#ifdef __cplusplus
43extern "C"
44{
45#if 0 /* keep Emacsens' auto-indent happy */
46}
47#endif
48#endif
49
50
51#include "gnunet_util_lib.h"
52#include "gnunet_ats_service.h"
53
54/**
55 * Version number of the transport API.
56 */
57#define GNUNET_TRANSPORT_MANIPULATION_VERSION 0x00000003
58
59/**
60 * Handle for transport manipulation.
61 */
62struct GNUNET_TRANSPORT_ManipulationHandle;
63
64
65/**
66 * Connect to the transport service. Note that the connection may
67 * complete (or fail) asynchronously.
68 *
69 * @param cfg configuration to use
70 * @return NULL on error
71 */
72struct GNUNET_TRANSPORT_ManipulationHandle *
73GNUNET_TRANSPORT_manipulation_connect (const struct
74 GNUNET_CONFIGURATION_Handle *cfg);
75
76
77/**
78 * Disconnect from the transport service.
79 *
80 * @param handle handle returned from connect
81 */
82void
83GNUNET_TRANSPORT_manipulation_disconnect (struct
84 GNUNET_TRANSPORT_ManipulationHandle *
85 handle);
86
87
88/**
89 * Set transport metrics for a peer and a direction
90 *
91 * @param handle transport handle
92 * @param peer the peer to set the metric for
93 * @param prop the performance metrics to set
94 * @param delay_in inbound delay to introduce
95 * @param delay_out outbound delay to introduce
96 *
97 * Note: Delay restrictions in receiving direction will be enforced
98 * with one message delay.
99 */
100void
101GNUNET_TRANSPORT_manipulation_set (struct
102 GNUNET_TRANSPORT_ManipulationHandle *handle,
103 const struct GNUNET_PeerIdentity *peer,
104 const struct GNUNET_ATS_Properties *prop,
105 struct GNUNET_TIME_Relative delay_in,
106 struct GNUNET_TIME_Relative delay_out);
107
108
109#if 0 /* keep Emacsens' auto-indent happy */
110{
111#endif
112#ifdef __cplusplus
113}
114#endif
115
116/* ifndef GNUNET_TRANSPORT_MANIPULATION_SERVICE_H */
117#endif
118
119/** @} */ /* end of group */
120
121/** @} */ /* end of group addition */
122
123/* 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 6b9eb8076..7c586b51e 100644
--- a/src/include/gnunet_transport_monitor_service.h
+++ b/src/include/gnunet_transport_monitor_service.h
@@ -47,7 +47,6 @@ extern "C"
47 47
48 48
49#include "gnunet_util_lib.h" 49#include "gnunet_util_lib.h"
50#include "gnunet_ats_transport_service.h"
51#include "gnunet_transport_communication_service.h" 50#include "gnunet_transport_communication_service.h"
52 51
53 52
diff --git a/src/include/gnunet_transport_plugin.h b/src/include/gnunet_transport_plugin.h
deleted file mode 100644
index 0ab4a995c..000000000
--- a/src/include/gnunet_transport_plugin.h
+++ /dev/null
@@ -1,733 +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 * @addtogroup Backbone
23 * @{
24 *
25 * @author Christian Grothoff
26 *
27 * @file
28 * Transport service plugin API
29 *
30 * @defgroup transport-plugin Transport Service plugin API
31 *
32 * Specifies the struct that is given to the plugin's entry method and the other
33 * struct that must be returned. Note that the destructors of transport plugins
34 * will be given the value returned by the constructor and is expected to return
35 * a NULL pointer.
36 *
37 * @{
38 */
39#ifndef PLUGIN_TRANSPORT_H
40#define PLUGIN_TRANSPORT_H
41
42
43#include "gnunet_configuration_lib.h"
44#include "gnunet_scheduler_lib.h"
45#include "gnunet_statistics_service.h"
46#include "gnunet_transport_service.h"
47#include "gnunet_ats_service.h"
48
49#define TRANSPORT_SESSION_INBOUND_STRING "<inbound>"
50
51/**
52 * Opaque pointer that plugins can use to distinguish specific
53 * connections to a given peer. Typically used by stateful plugins to
54 * allow the service to refer to specific streams instead of a more
55 * general notion of "some connection" to the given peer. This is
56 * useful since sometimes (e.g. for inbound TCP connections) a
57 * connection may not have an address that can be used for meaningful
58 * distinction between sessions to the same peer.
59 *
60 * Each 'struct GNUNET_ATS_Session' MUST start with the 'struct GNUNET_PeerIdentity'
61 * of the peer the session is for (which will be used for some error
62 * checking by the ATS code).
63 */
64struct GNUNET_ATS_Session;
65
66
67/**
68 * Function that will be called whenever the plugin internally
69 * cleans up a session pointer and hence the service needs to
70 * discard all of those sessions as well. Plugins that do not
71 * use sessions can simply omit calling this function and always
72 * use NULL wherever a session pointer is needed. This function
73 * should be called BEFORE a potential "TransmitContinuation"
74 * from the "TransmitFunction".
75 *
76 * @param cls closure
77 * @param peer which peer was the session for
78 * @param session which session is being destroyed
79 */
80typedef void
81(*GNUNET_TRANSPORT_SessionEnd) (void *cls,
82 const struct GNUNET_HELLO_Address *address,
83 struct GNUNET_ATS_Session *session);
84
85
86/**
87 * Plugin tells transport service about a new inbound session
88 *
89 * @param cls unused
90 * @param address the address
91 * @param session the new session
92 * @param net network information
93 */
94typedef void
95(*GNUNET_TRANSPORT_SessionStart) (void *cls,
96 const struct GNUNET_HELLO_Address *address,
97 struct GNUNET_ATS_Session *session,
98 enum GNUNET_NetworkType net);
99
100
101/**
102 * Function called by the transport for each received message.
103 * This function should also be called with "NULL" for the
104 * message to signal that the other peer disconnected.
105 *
106 * @param cls closure
107 * @param peer (claimed) identity of the other peer
108 * @param message the message, NULL if we only care about
109 * learning about the delay until we should receive again
110 * @param session identifier used for this session (NULL for plugins
111 * that do not offer bi-directional communication to the sender
112 * using the same "connection")
113 * @param sender_address binary address of the sender (if we established the
114 * connection or are otherwise sure of it; should be NULL
115 * for inbound TCP/UDP connections since it it not clear
116 * that we could establish ourselves a connection to that
117 * IP address and get the same system)
118 * @param sender_address_len number of bytes in @a sender_address
119 * @return how long the plugin should wait until receiving more data;
120 * returning #GNUNET_TIME_UNIT_FOREVER_REL means that the
121 * connection should be closed
122 */
123typedef struct GNUNET_TIME_Relative
124(*GNUNET_TRANSPORT_PluginReceiveCallback) (void *cls,
125 const struct
126 GNUNET_HELLO_Address *address,
127 struct GNUNET_ATS_Session *session,
128 const struct
129 GNUNET_MessageHeader *message);
130
131
132/**
133 * Function that can be called by plugins to figure if an address is
134 * an loopback, LAN or WAN address. Ultimately invokes
135 * #GNUNET_ATS_address_get_type().
136 *
137 * @param cls closure
138 * @param addr binary address
139 * @param addrlen length of the @a addr
140 * @return type of the network the address belongs to
141 */
142typedef enum GNUNET_NetworkType
143(*GNUNET_TRANSPORT_AddressToType)(void *cls,
144 const struct sockaddr *addr,
145 size_t addrlen);
146
147
148/**
149 * Function called when distance of an address changes.
150 *
151 * @param cls closure
152 * @param peer peer
153 * @param distance new distance
154 */
155typedef void
156(*GNUNET_TRANSPORT_UpdateAddressDistance) (void *cls,
157 const struct
158 GNUNET_HELLO_Address *address,
159 uint32_t distance);
160
161
162/**
163 * Function that will be called for each address the transport
164 * is aware that it might be reachable under.
165 *
166 * @param cls closure
167 * @param add_remove should the address added (#GNUNET_YES) or removed (#GNUNET_NO) from the
168 * set of valid addresses?
169 * @param address the address to add or remove
170 */
171typedef void
172(*GNUNET_TRANSPORT_AddressNotification) (void *cls,
173 int add_remove,
174 const struct
175 GNUNET_HELLO_Address *address);
176
177
178/**
179 * Function that will be called whenever the plugin receives data over
180 * the network and wants to determine how long it should wait until
181 * the next time it reads from the given peer. Note that some plugins
182 * (such as UDP) may not be able to wait (for a particular peer), so
183 * the waiting part is optional. Plugins that can wait should call
184 * this function, sleep the given amount of time, and call it again
185 * (with zero bytes read) UNTIL it returns zero and only then read.
186 *
187 * @param cls closure
188 * @param peer which peer did we read data from
189 * @param amount_recved number of bytes read (can be zero)
190 * @return how long to wait until reading more from this peer
191 * (to enforce inbound quotas); returning #GNUNET_TIME_UNIT_FOREVER_REL
192 * means that the connection should be closed
193 */
194typedef struct GNUNET_TIME_Relative
195(*GNUNET_TRANSPORT_TrafficReport) (void *cls,
196 const struct GNUNET_PeerIdentity *peer,
197 size_t amount_recved);
198
199
200/**
201 * Function that returns a HELLO message.
202 *
203 * @return HELLO message (FIXME with what?)
204 */
205typedef const struct GNUNET_MessageHeader *
206(*GNUNET_TRANSPORT_GetHelloCallback) (void);
207
208
209/**
210 * The transport service will pass a pointer to a struct
211 * of this type as the first and only argument to the
212 * entry point of each transport plugin.
213 */
214struct GNUNET_TRANSPORT_PluginEnvironment
215{
216 /**
217 * Configuration to use.
218 */
219 const struct GNUNET_CONFIGURATION_Handle *cfg;
220
221 /**
222 * Identity of this peer.
223 */
224 const struct GNUNET_PeerIdentity *my_identity;
225
226 /**
227 * Closure for the various callbacks.
228 */
229 void *cls;
230
231 /**
232 * Handle for reporting statistics.
233 */
234 struct GNUNET_STATISTICS_Handle *stats;
235
236 /**
237 * Function that should be called by the transport plugin
238 * whenever a message is received. If this field is "NULL",
239 * the plugin should load in 'stub' mode and NOT fully
240 * initialize and instead only return an API with the
241 * @e address_pretty_printer, @e address_to_string and
242 * @e string_to_address functions.
243 */
244 GNUNET_TRANSPORT_PluginReceiveCallback receive;
245
246 /**
247 * Function that returns our HELLO.
248 */
249 GNUNET_TRANSPORT_GetHelloCallback get_our_hello;
250
251 /**
252 * Function that must be called by each plugin to notify the
253 * transport service about the addresses under which the transport
254 * provided by the plugin can be reached.
255 */
256 GNUNET_TRANSPORT_AddressNotification notify_address;
257
258 /**
259 * Function that must be called by the plugin when a non-NULL
260 * session handle stops being valid (is destroyed).
261 */
262 GNUNET_TRANSPORT_SessionEnd session_end;
263
264 /**
265 * Function called by the plugin when a new (incoming) session was created
266 * not explicitly created using the the get_session function
267 */
268 GNUNET_TRANSPORT_SessionStart session_start;
269
270 /**
271 * Function that will be called to figure if an address is an loopback,
272 * LAN, WAN etc. address
273 */
274 GNUNET_TRANSPORT_AddressToType get_address_type;
275
276 /**
277 * Function that will be called by DV to update distance for
278 * an address.
279 */
280 GNUNET_TRANSPORT_UpdateAddressDistance update_address_distance;
281
282 /**
283 * What is the maximum number of connections that this transport
284 * should allow? Transports that do not have sessions (such as
285 * UDP) can ignore this value.
286 */
287 uint32_t max_connections;
288};
289
290
291/**
292 * Function called by the #GNUNET_TRANSPORT_TransmitFunction
293 * upon "completion". In the case that a peer disconnects,
294 * this function must be called for each pending request
295 * (with a 'failure' indication) AFTER notifying the service
296 * about the disconnect event (so that the service won't try
297 * to transmit more messages, believing the connection still
298 * exists...).
299 *
300 * @param cls closure
301 * @param target who was the recipient of the message?
302 * @param result #GNUNET_OK on success
303 * #GNUNET_SYSERR if the target disconnected;
304 * disconnect will ALSO be signalled using
305 * the ReceiveCallback.
306 * @param size_payload bytes of payload from transport service in message
307 * @param size_on_wire bytes required on wire for transmission,
308 * 0 if result == #GNUNET_SYSERR
309 */
310typedef void
311(*GNUNET_TRANSPORT_TransmitContinuation) (void *cls,
312 const struct
313 GNUNET_PeerIdentity *target,
314 int result,
315 size_t size_payload,
316 size_t size_on_wire);
317
318
319/**
320 * The new send function with just the session and no address
321 *
322 * Function that can be used by the transport service to transmit
323 * a message using the plugin. Note that in the case of a
324 * peer disconnecting, the continuation MUST be called
325 * prior to the disconnect notification itself. This function
326 * will be called with this peer's HELLO message to initiate
327 * a fresh connection to another peer.
328 *
329 * @param cls closure
330 * @param session which session must be used
331 * @param msgbuf the message to transmit
332 * @param msgbuf_size number of bytes in @a msgbuf
333 * @param priority how important is the message (most plugins will
334 * ignore message priority and just FIFO)
335 * @param to how long to wait at most for the transmission (does not
336 * require plugins to discard the message after the timeout,
337 * just advisory for the desired delay; most plugins will ignore
338 * this as well)
339 * @param cont continuation to call once the message has
340 * been transmitted (or if the transport is ready
341 * for the next transmission call; or if the
342 * peer disconnected...); can be NULL
343 * @param cont_cls closure for @a cont
344 * @return number of bytes used (on the physical network, with overheads);
345 * -1 on hard errors (i.e. address invalid); 0 is a legal value
346 * and does NOT mean that the message was not transmitted (DV)
347 */
348typedef ssize_t
349(*GNUNET_TRANSPORT_TransmitFunction) (void *cls,
350 struct GNUNET_ATS_Session *session,
351 const char *msgbuf,
352 size_t msgbuf_size,
353 unsigned int priority,
354 struct GNUNET_TIME_Relative to,
355 GNUNET_TRANSPORT_TransmitContinuation cont,
356 void *cont_cls);
357
358
359/**
360 * Function that can be called to force a disconnect from the
361 * specified neighbour for the given session only. . This should
362 * also cancel all previously scheduled transmissions for this
363 * session. Obviously the transmission may have been partially
364 * completed already, which is OK. The plugin is supposed to close
365 * the connection (if applicable).
366 *
367 * @param cls closure with the `struct Plugin`
368 * @param session session to destroy
369 * @return #GNUNET_OK on success
370 */
371typedef int
372(*GNUNET_TRANSPORT_DisconnectSessionFunction) (void *cls,
373 struct GNUNET_ATS_Session *
374 session);
375
376
377/**
378 * Function that is called to get the keepalive factor.
379 * #GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT is divided by this number to
380 * calculate the interval between keepalive packets.
381 *
382 * @param cls closure with the `struct Plugin`
383 * @return keepalive factor
384 */
385typedef unsigned int
386(*GNUNET_TRANSPORT_QueryKeepaliveFactorFunction) (void *cls);
387
388
389/**
390 * Function that can be called to force a disconnect from the
391 * specified neighbour. This should also cancel all previously
392 * scheduled transmissions. Obviously the transmission may have been
393 * partially completed already, which is OK. The plugin is supposed
394 * to close the connection (if applicable) and no longer call the
395 * transmit continuation(s).
396 *
397 * @param cls closure
398 * @param target peer for which the last transmission is
399 * to be cancelled
400 */
401typedef void
402(*GNUNET_TRANSPORT_DisconnectPeerFunction) (void *cls,
403 const struct
404 GNUNET_PeerIdentity *target);
405
406
407/**
408 * Function called by the pretty printer for the resolved address for
409 * each human-readable address obtained. The callback can be called
410 * several times. The last invocation must be with a @a address of
411 * NULL and a @a res of #GNUNET_OK. Thus, to indicate conversion
412 * errors, the callback might be called first with @a address NULL and
413 * @a res being #GNUNET_SYSERR. In that case, there must still be a
414 * subsequent call later with @a address NULL and @a res #GNUNET_OK.
415 *
416 * @param cls closure
417 * @param address one of the names for the host, NULL on last callback
418 * @param res #GNUNET_OK if conversion was successful, #GNUNET_SYSERR on failure,
419 * #GNUNET_OK on last callback
420 */
421typedef void
422(*GNUNET_TRANSPORT_AddressStringCallback) (void *cls,
423 const char *address,
424 int res);
425
426
427/**
428 * Convert the transports address to a nice, human-readable
429 * format.
430 *
431 * @param cls closure
432 * @param type name of the transport that generated the address
433 * @param addr one of the addresses of the host, NULL for the last address
434 * the specific address format depends on the transport
435 * @param addrlen length of the @a addr
436 * @param numeric should (IP) addresses be displayed in numeric form?
437 * @param timeout after how long should we give up?
438 * @param asc function to call on each string
439 * @param asc_cls closure for @a asc
440 */
441typedef void
442(*GNUNET_TRANSPORT_AddressPrettyPrinter) (void *cls,
443 const char *type,
444 const void *addr,
445 size_t addrlen,
446 int numeric,
447 struct GNUNET_TIME_Relative timeout,
448 GNUNET_TRANSPORT_AddressStringCallback
449 asc,
450 void *asc_cls);
451
452
453/**
454 * Another peer has suggested an address for this peer and transport
455 * plugin. Check that this could be a valid address. This function
456 * is not expected to 'validate' the address in the sense of trying to
457 * connect to it but simply to see if the binary format is technically
458 * legal for establishing a connection to this peer (and make sure that
459 * the address really corresponds to our network connection/settings
460 * and not some potential man-in-the-middle).
461 *
462 * @param addr pointer to the address
463 * @param addrlen length of @a addr
464 * @return #GNUNET_OK if this is a plausible address for this peer
465 * and transport, #GNUNET_SYSERR if not
466 */
467typedef int
468(*GNUNET_TRANSPORT_CheckAddress) (void *cls,
469 const void *addr,
470 size_t addrlen);
471
472
473/**
474 * Create a new session to transmit data to the target
475 * This session will used to send data to this peer and the plugin will
476 * notify us by calling the env->session_end function
477 *
478 * @param cls the plugin
479 * @param address the hello address
480 * @return the session if the address is valid, NULL otherwise
481 */
482typedef struct GNUNET_ATS_Session *
483(*GNUNET_TRANSPORT_CreateSession) (void *cls,
484 const struct GNUNET_HELLO_Address *address);
485
486
487/**
488 * Function that will be called whenever the transport service wants to
489 * notify the plugin that a session is still active and in use and
490 * therefore the session timeout for this session has to be updated
491 *
492 * @param cls closure
493 * @param peer which peer was the session for
494 * @param session which session is being updated
495 */
496typedef void
497(*GNUNET_TRANSPORT_UpdateSessionTimeout) (void *cls,
498 const struct
499 GNUNET_PeerIdentity *peer,
500 struct GNUNET_ATS_Session *session);
501
502
503/**
504 * Function that will be called whenever the transport service wants to
505 * notify the plugin that the inbound quota changed and that the plugin
506 * should update it's delay for the next receive value
507 *
508 * @param cls closure
509 * @param peer which peer was the session for
510 * @param session which session is being updated
511 * @param delay new delay to use for receiving
512 */
513typedef void
514(*GNUNET_TRANSPORT_UpdateInboundDelay) (void *cls,
515 const struct GNUNET_PeerIdentity *peer,
516 struct GNUNET_ATS_Session *session,
517 struct GNUNET_TIME_Relative delay);
518
519
520/**
521 * Function called for a quick conversion of the binary address to
522 * a numeric address. Note that the caller must not free the
523 * address and that the next call to this function is allowed
524 * to override the address again.
525 *
526 * @param cls closure
527 * @param addr binary address
528 * @param addr_len length of the @a addr
529 * @return string representing the same address
530 */
531typedef const char *
532(*GNUNET_TRANSPORT_AddressToString) (void *cls,
533 const void *addr,
534 size_t addrlen);
535
536
537/**
538 * Function called to convert a string address to
539 * a binary address.
540 *
541 * @param cls closure (`struct Plugin*`)
542 * @param addr string address
543 * @param addrlen length of the @a addr including \0 termination
544 * @param buf location to store the buffer
545 * If the function returns #GNUNET_SYSERR, its contents are undefined.
546 * @param added length of created address
547 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
548 */
549typedef int
550(*GNUNET_TRANSPORT_StringToAddress) (void *cls,
551 const char *addr,
552 uint16_t addrlen,
553 void **buf,
554 size_t *added);
555
556
557/**
558 * Function to obtain the network type for a session
559 *
560 * @param cls closure (`struct Plugin *`)
561 * @param session the session
562 * @return the network type
563 */
564typedef enum GNUNET_NetworkType
565(*GNUNET_TRANSPORT_GetNetworkType)(void *cls,
566 struct GNUNET_ATS_Session *session);
567
568
569/**
570 * Function to obtain the network type for an address.
571 *
572 * @param cls closure (`struct Plugin *`)
573 * @param address the address
574 * @return the network type
575 */
576typedef enum GNUNET_NetworkType
577(*GNUNET_TRANSPORT_GetNetworkTypeForAddress)(void *cls,
578 const struct
579 GNUNET_HELLO_Address *address);
580
581
582/**
583 * Function called by the plugin with information about the
584 * current sessions managed by the plugin (for monitoring).
585 *
586 * @param cls closure
587 * @param session session handle this information is about,
588 * NULL to indicate that we are "in sync" (initial
589 * iteration complete)
590 * @param info information about the state of the session,
591 * NULL if @a session is also NULL and we are
592 * merely signalling that the initial iteration is over
593 */
594typedef void
595(*GNUNET_TRANSPORT_SessionInfoCallback) (void *cls,
596 struct GNUNET_ATS_Session *session,
597 const struct
598 GNUNET_TRANSPORT_SessionInfo *info);
599
600
601/**
602 * Begin monitoring sessions of a plugin. There can only
603 * be one active monitor per plugin (i.e. if there are
604 * multiple monitors, the transport service needs to
605 * multiplex the generated events over all of them).
606 *
607 * @param cls closure of the plugin
608 * @param sic callback to invoke, NULL to disable monitor;
609 * plugin will being by iterating over all active
610 * sessions immediately and then enter monitor mode
611 * @param sic_cls closure for @a sic
612 */
613typedef void
614(*GNUNET_TRANSPORT_SessionMonitorSetup) (void *cls,
615 GNUNET_TRANSPORT_SessionInfoCallback
616 sic,
617 void *sic_cls);
618
619
620/**
621 * Each plugin is required to return a pointer to a struct of this
622 * type as the return value from its entry point.
623 */
624struct GNUNET_TRANSPORT_PluginFunctions
625{
626 /**
627 * Closure for all of the callbacks.
628 */
629 void *cls;
630
631 /**
632 * Function that the transport service will use to transmit data to
633 * another peer. May be NULL for plugins that only support
634 * receiving data. After this call, the plugin call the specified
635 * continuation with success or error before notifying us about the
636 * target having disconnected.
637 */
638 GNUNET_TRANSPORT_TransmitFunction send;
639
640 /**
641 * Function that can be used to force the plugin to disconnect from
642 * the given peer and cancel all previous transmissions (and their
643 * continuations).
644 */
645 GNUNET_TRANSPORT_DisconnectPeerFunction disconnect_peer;
646
647 /**
648 * Function that can be used to force the plugin to disconnect from
649 * the given peer and cancel all previous transmissions (and their
650 * continuations).
651 */
652 GNUNET_TRANSPORT_DisconnectSessionFunction disconnect_session;
653
654 /**
655 * Function that will be called whenever the transport service wants to
656 * notify the plugin that a session is still active and in use and
657 * therefore the session timeout for this session has to be updated
658 */
659 GNUNET_TRANSPORT_UpdateSessionTimeout update_session_timeout;
660
661 /**
662 * Function that will be called whenever the transport service wants to
663 * notify the plugin that the inbound quota changed and that the plugin
664 * should update it's delay for the next receive value
665 */
666 GNUNET_TRANSPORT_UpdateInboundDelay update_inbound_delay;
667
668 /**
669 * Function that is used to query keepalive factor.
670 * #GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT is divided by this number to
671 * calculate the interval between keepalive packets.
672 */
673 GNUNET_TRANSPORT_QueryKeepaliveFactorFunction query_keepalive_factor;
674
675 /**
676 * Function to pretty-print addresses.
677 */
678 GNUNET_TRANSPORT_AddressPrettyPrinter address_pretty_printer;
679
680 /**
681 * Function that will be called to check if a binary address
682 * for this plugin is well-formed and corresponds to an
683 * address for THIS peer (as per our configuration). Naturally,
684 * if absolutely necessary, plugins can be a bit conservative in
685 * their answer, but in general plugins should make sure that the
686 * address does not redirect traffic to a 3rd party that might
687 * try to man-in-the-middle our traffic.
688 */
689 GNUNET_TRANSPORT_CheckAddress check_address;
690
691 /**
692 * Function that will be called to convert a binary address
693 * to a string (numeric conversion only).
694 */
695 GNUNET_TRANSPORT_AddressToString address_to_string;
696
697 /**
698 * Function that will be called to convert a string address
699 * to binary (numeric conversion only).
700 */
701 GNUNET_TRANSPORT_StringToAddress string_to_address;
702
703 /**
704 * Function that will be called tell the plugin to create a session
705 * object.
706 */
707 GNUNET_TRANSPORT_CreateSession get_session;
708
709 /**
710 * Function to obtain the network type for a session
711 */
712 GNUNET_TRANSPORT_GetNetworkType get_network;
713
714 /**
715 * Function to obtain the network type for an address
716 */
717 GNUNET_TRANSPORT_GetNetworkTypeForAddress get_network_for_address;
718
719 /**
720 * Function to monitor the sessions managed by the plugin.
721 */
722 GNUNET_TRANSPORT_SessionMonitorSetup setup_monitor;
723};
724
725
726/*#ifndef PLUGIN_TRANSPORT_H*/
727#endif
728
729/** @} */ /* end of group */
730
731/** @} */ /* end of group addition */
732
733/* 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 72cdbe0a7..000000000
--- a/src/include/gnunet_transport_service.h
+++ /dev/null
@@ -1,715 +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 * @addtogroup Backbone
23 * @{
24 *
25 * @author Christian Grothoff
26 *
27 * @file
28 * Low-level P2P IO
29 *
30 * @defgroup transport Transport service
31 * Low-level P2P IO
32 *
33 * @see [Documentation](https://gnunet.org/transport-service)
34 *
35 * @{
36 */
37
38#ifndef GNUNET_TRANSPORT_SERVICE_H
39#define GNUNET_TRANSPORT_SERVICE_H
40
41#ifdef __cplusplus
42extern "C" {
43#if 0 /* keep Emacsens' auto-indent happy */
44}
45#endif
46#endif
47
48
49#include "gnunet_util_lib.h"
50#include "gnunet_ats_service.h"
51
52/**
53 * Version number of the transport API.
54 */
55#define GNUNET_TRANSPORT_VERSION 0x00000003
56
57
58/* *************************** HELLO *************************** */
59
60/**
61 * Handle for a #GNUNET_TRANSPORT_offer_hello operation
62 */
63struct GNUNET_TRANSPORT_OfferHelloHandle;
64
65
66/**
67 * Offer the transport service the HELLO of another peer. Note that
68 * the transport service may just ignore this message if the HELLO is
69 * malformed or useless due to our local configuration.
70 *
71 * @param cfg configuration
72 * @param hello the hello message
73 * @param cont continuation to call when HELLO has been sent,
74 * tc reason #GNUNET_SCHEDULER_REASON_TIMEOUT for fail
75 * tc reasong #GNUNET_SCHEDULER_REASON_READ_READY for success
76 * @param cont_cls closure for @a cont
77 * @return a `struct GNUNET_TRANSPORT_OfferHelloHandle` handle or NULL on
78 * failure, in case of failure @a cont will not be called
79 *
80 */
81struct GNUNET_TRANSPORT_OfferHelloHandle *
82GNUNET_TRANSPORT_offer_hello (const struct GNUNET_CONFIGURATION_Handle *cfg,
83 const struct GNUNET_MessageHeader *hello,
84 GNUNET_SCHEDULER_TaskCallback cont,
85 void *cont_cls);
86
87
88/**
89 * Cancel the request to transport to offer the HELLO message
90 *
91 * @param ohh the `struct GNUNET_TRANSPORT_OfferHelloHandle` to cancel
92 */
93void
94GNUNET_TRANSPORT_offer_hello_cancel (
95 struct GNUNET_TRANSPORT_OfferHelloHandle *ohh);
96
97
98/* *********************** Address to String ******************* */
99
100/**
101 * Handle to cancel a pending address lookup.
102 */
103struct GNUNET_TRANSPORT_AddressToStringContext;
104
105
106/**
107 * Function to call with a textual representation of an address. This
108 * function will be called several times with different possible
109 * textual representations, and a last time with @a address being NULL
110 * to signal the end of the iteration. Note that @a address NULL
111 * always is the last call, regardless of the value in @a res.
112 *
113 * @param cls closure
114 * @param address NULL on end of iteration,
115 * otherwise 0-terminated printable UTF-8 string,
116 * in particular an empty string if @a res is #GNUNET_NO
117 * @param res result of the address to string conversion:
118 * if #GNUNET_OK: conversion successful
119 * if #GNUNET_NO: address was invalid (or not supported)
120 * if #GNUNET_SYSERR: communication error (IPC error)
121 */
122typedef void
123(*GNUNET_TRANSPORT_AddressToStringCallback) (void *cls,
124 const char *address,
125 int res);
126
127
128/**
129 * Convert a binary address into a human readable address.
130 *
131 * @param cfg configuration to use
132 * @param address address to convert (binary format)
133 * @param numeric should (IP) addresses be displayed in numeric form
134 * (otherwise do reverse DNS lookup)
135 * @param timeout how long is the lookup allowed to take at most
136 * @param aluc function to call with the results
137 * @param aluc_cls closure for @a aluc
138 * @return handle to cancel the operation, NULL on error
139 */
140struct GNUNET_TRANSPORT_AddressToStringContext *
141GNUNET_TRANSPORT_address_to_string (
142 const struct GNUNET_CONFIGURATION_Handle *cfg,
143 const struct GNUNET_HELLO_Address *address,
144 int numeric,
145 struct GNUNET_TIME_Relative timeout,
146 GNUNET_TRANSPORT_AddressToStringCallback aluc,
147 void *aluc_cls);
148
149
150/**
151 * Cancel request for address conversion.
152 *
153 * @param alc the context handle
154 */
155void
156GNUNET_TRANSPORT_address_to_string_cancel (
157 struct GNUNET_TRANSPORT_AddressToStringContext *alc);
158
159
160/* *********************** Monitoring ************************** */
161
162
163/**
164 * Possible state of a neighbour. Initially, we are
165 * #GNUNET_TRANSPORT_PS_NOT_CONNECTED.
166 *
167 * Then, there are two main paths. If we receive a SYN message, we give
168 * the inbound address to ATS. After the check we ask ATS for a suggestion
169 * (#GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS). If ATS makes a suggestion, we
170 * send our SYN_ACK and go to #GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK.
171 * If we receive a ACK, we go to #GNUNET_TRANSPORT_PS_CONNECTED
172 * (and notify everyone about the new connection). If the operation times out,
173 * we go to #GNUNET_TRANSPORT_PS_DISCONNECT.
174 *
175 * The other case is where we transmit a SYN message first. We
176 * start with #GNUNET_TRANSPORT_PS_INIT_ATS. If we get an address, we send
177 * the SYN message and go to state #GNUNET_TRANSPORT_PS_CONNECT_SENT.
178 * Once we receive a SYN_ACK, we go to #GNUNET_TRANSPORT_PS_CONNECTED
179 * (and notify everyone about the new connection and send
180 * back a ACK). If the operation times out, we go to
181 * #GNUNET_TRANSPORT_PS_DISCONNECT.
182 *
183 * If the session is in trouble (i.e. transport-level disconnect or
184 * timeout), we go to #GNUNET_TRANSPORT_PS_RECONNECT_ATS where we ask ATS for a
185 * new address (we don't notify anyone about the disconnect yet). Once we have
186 * a new address, we enter #GNUNET_TRANSPORT_PS_RECONNECT_SENT and send a SYN
187 * message. If we receive a SYN_ACK, we go to #GNUNET_TRANSPORT_PS_CONNECTED
188 * and nobody noticed that we had trouble; we also send a ACK at this time just
189 * in case. If the operation times out, we go to
190 * #GNUNET_TRANSPORT_PS_DISCONNECT (and notify everyone about the lost
191 * connection).
192 *
193 * If ATS decides to switch addresses while we have a normal
194 * connection, we go to #GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_SYN_SENT
195 * and send a SESSION_CONNECT. If we get a ACK back, we switch the
196 * primary connection to the suggested alternative from ATS, go back
197 * to #GNUNET_TRANSPORT_PS_CONNECTED and send a ACK to the other peer just to be
198 * sure. If the operation times out
199 * we go to #GNUNET_TRANSPORT_PS_CONNECTED (and notify ATS that the given
200 * alternative address is "invalid").
201 *
202 * Once a session is in #GNUNET_TRANSPORT_PS_DISCONNECT, it is cleaned up and
203 * then goes to (#GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED). If we receive an
204 * explicit disconnect request, we can go from any state to
205 * #GNUNET_TRANSPORT_PS_DISCONNECT, possibly after generating disconnect
206 * notifications.
207 *
208 * Note that it is quite possible that while we are in any of these
209 * states, we could receive a 'SYN' request from the other peer.
210 * We then enter a 'weird' state where we pursue our own primary state
211 * machine (as described above), but with the 'send_connect_ack' flag
212 * set to 1. If our state machine allows us to send a 'SYN_ACK'
213 * (because we have an acceptable address), we send the 'SYN_ACK'
214 * and set the 'send_connect_ack' to 2. If we then receive a
215 * 'ACK', we go to #GNUNET_TRANSPORT_PS_CONNECTED (and reset 'send_connect_ack'
216 * to 0).
217 *
218 */
219enum GNUNET_TRANSPORT_PeerState
220{
221 /**
222 * Fresh peer or completely disconnected
223 */
224 GNUNET_TRANSPORT_PS_NOT_CONNECTED = 0,
225
226 /**
227 * Asked to initiate connection, trying to get address from ATS
228 */
229 GNUNET_TRANSPORT_PS_INIT_ATS,
230
231 /**
232 * Sent SYN message to other peer, waiting for SYN_ACK
233 */
234 GNUNET_TRANSPORT_PS_SYN_SENT,
235
236 /**
237 * Received a SYN, asking ATS about address suggestions.
238 */
239 GNUNET_TRANSPORT_PS_SYN_RECV_ATS,
240
241 /**
242 * SYN request from other peer was SYN_ACK'ed, waiting for ACK.
243 */
244 GNUNET_TRANSPORT_PS_SYN_RECV_ACK,
245
246 /**
247 * Got our SYN_ACK/ACK, connection is up.
248 */
249 GNUNET_TRANSPORT_PS_CONNECTED,
250
251 /**
252 * Connection got into trouble, rest of the system still believes
253 * it to be up, but we're getting a new address from ATS.
254 */
255 GNUNET_TRANSPORT_PS_RECONNECT_ATS,
256
257 /**
258 * Sent SYN over new address (either by ATS telling us to switch
259 * addresses or from RECONNECT_ATS); if this fails, we need to tell
260 * the rest of the system about a disconnect.
261 */
262 GNUNET_TRANSPORT_PS_RECONNECT_SENT,
263
264 /**
265 * We have some primary connection, but ATS suggested we switch
266 * to some alternative; we now sent a SYN message for the
267 * alternative session to the other peer and waiting for a
268 * SYN_ACK to make this our primary connection.
269 */
270 GNUNET_TRANSPORT_PS_SWITCH_SYN_SENT,
271
272 /**
273 * Disconnect in progress (we're sending the DISCONNECT message to the
274 * other peer; after that is finished, the state will be cleaned up).
275 */
276 GNUNET_TRANSPORT_PS_DISCONNECT,
277
278 /**
279 * We're finished with the disconnect; and are cleaning up the state
280 * now! We put the struct into this state when we are really in the
281 * task that calls 'free' on it and are about to remove the record
282 * from the map. We should never find a 'struct NeighbourMapEntry'
283 * in this state in the map. Accessing a 'struct NeighbourMapEntry'
284 * in this state virtually always means using memory that has been
285 * freed (the exception being the cleanup code in #free_neighbour()).
286 */
287 GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED
288};
289
290
291/**
292 * Convert a transport state to a human readable string.
293 *
294 * @param state the state
295 */
296const char *
297GNUNET_TRANSPORT_ps2s (enum GNUNET_TRANSPORT_PeerState state);
298
299
300/**
301 * Check if a state is defined as connected
302 *
303 * @param state the state value
304 * @return #GNUNET_YES or #GNUNET_NO
305 */
306int
307GNUNET_TRANSPORT_is_connected (enum GNUNET_TRANSPORT_PeerState state);
308
309
310/**
311 * Handle for a #GNUNET_TRANSPORT_monitor_peers operation.
312 */
313struct GNUNET_TRANSPORT_PeerMonitoringContext;
314
315
316/**
317 * Function to call with information about a peer
318 *
319 * If one_shot was set to #GNUNET_YES to iterate over all peers once,
320 * a final call with NULL for peer and address will follow when done.
321 * In this case state and timeout do not contain valid values.
322 *
323 * The #GNUNET_TRANSPORT_monitor_peers_cancel() call MUST not be called from
324 * within this function!
325 *
326 *
327 * @param cls closure
328 * @param peer peer this update is about,
329 * NULL if this is the final last callback for a iteration operation
330 * @param address address, NULL if this is the final callback for iteration op
331 * @param state current state this peer is in
332 * @param state_timeout timeout for the current state of the peer
333 */
334typedef void
335(*GNUNET_TRANSPORT_PeerIterateCallback) (
336 void *cls,
337 const struct GNUNET_PeerIdentity *peer,
338 const struct GNUNET_HELLO_Address *address,
339 enum GNUNET_TRANSPORT_PeerState state,
340 struct GNUNET_TIME_Absolute state_timeout);
341
342
343/**
344 * Return information about a specific peer or all peers currently known to
345 * transport service once or in monitoring mode. To obtain information about
346 * a specific peer, a peer identity can be passed. To obtain information about
347 * all peers currently known to transport service, NULL can be passed as peer
348 * identity.
349 *
350 * For each peer, the callback is called with information about the address used
351 * to communicate with this peer, the state this peer is currently in and the
352 * the current timeout for this state.
353 *
354 * Upon completion, the #GNUNET_TRANSPORT_PeerIterateCallback is called one
355 * more time with `NULL`. After this, the operation must no longer be
356 * explicitly canceled.
357 *
358 * The #GNUNET_TRANSPORT_monitor_peers_cancel call MUST not be called in the
359 * the peer_callback!
360 *
361 * @param cfg configuration to use
362 * @param peer a specific peer identity to obtain information for,
363 * NULL for all peers
364 * @param one_shot #GNUNET_YES to return the current state and
365 * then end (with NULL+NULL),
366 * #GNUNET_NO to monitor peers continuously
367 * @param peer_callback function to call with the results
368 * @param peer_callback_cls closure for @a peer_callback
369 */
370struct GNUNET_TRANSPORT_PeerMonitoringContext *
371GNUNET_TRANSPORT_monitor_peers (
372 const struct GNUNET_CONFIGURATION_Handle *cfg,
373 const struct GNUNET_PeerIdentity *peer,
374 int one_shot,
375 GNUNET_TRANSPORT_PeerIterateCallback peer_callback,
376 void *peer_callback_cls);
377
378
379/**
380 * Cancel request to monitor peers
381 *
382 * @param pic handle for the request to cancel
383 */
384void
385GNUNET_TRANSPORT_monitor_peers_cancel (
386 struct GNUNET_TRANSPORT_PeerMonitoringContext *pic);
387
388
389/* *********************** Blacklisting ************************ */
390
391/**
392 * Handle for blacklisting peers.
393 */
394struct GNUNET_TRANSPORT_Blacklist;
395
396
397/**
398 * Function that decides if a connection is acceptable or not.
399 *
400 * @param cls closure
401 * @param pid peer to approve or disapproave
402 * @return #GNUNET_OK if the connection is allowed, #GNUNET_SYSERR if not
403 */
404typedef int
405(*GNUNET_TRANSPORT_BlacklistCallback) (
406 void *cls,
407 const struct GNUNET_PeerIdentity *pid);
408
409
410/**
411 * Install a blacklist callback. The service will be queried for all
412 * existing connections as well as any fresh connections to check if
413 * they are permitted. If the blacklisting callback is unregistered,
414 * all hosts that were denied in the past will automatically be
415 * whitelisted again. Cancelling the blacklist handle is also the
416 * only way to re-enable connections from peers that were previously
417 * blacklisted.
418 *
419 * @param cfg configuration to use
420 * @param cb callback to invoke to check if connections are allowed
421 * @param cb_cls closure for @a cb
422 * @return NULL on error, otherwise handle for cancellation
423 */
424struct GNUNET_TRANSPORT_Blacklist *
425GNUNET_TRANSPORT_blacklist (const struct GNUNET_CONFIGURATION_Handle *cfg,
426 GNUNET_TRANSPORT_BlacklistCallback cb,
427 void *cb_cls);
428
429
430/**
431 * Abort the blacklist. Note that this function is the only way for
432 * removing a peer from the blacklist.
433 *
434 * @param br handle of the request that is to be cancelled
435 */
436void
437GNUNET_TRANSPORT_blacklist_cancel (struct GNUNET_TRANSPORT_Blacklist *br);
438
439
440/**
441 * Handle for a plugin session state monitor.
442 */
443struct GNUNET_TRANSPORT_PluginMonitor;
444
445/**
446 * Abstract representation of a plugin's session.
447 * Corresponds to the `struct GNUNET_ATS_Session` within the TRANSPORT service.
448 */
449struct GNUNET_TRANSPORT_PluginSession;
450
451
452/**
453 * Possible states of a session in a plugin.
454 */
455enum GNUNET_TRANSPORT_SessionState
456{
457 /**
458 * The session was created (first call for each session object).
459 */
460 GNUNET_TRANSPORT_SS_INIT,
461
462 /**
463 * Initial session handshake is in progress.
464 */
465 GNUNET_TRANSPORT_SS_HANDSHAKE,
466
467 /**
468 * Session is fully UP.
469 */
470 GNUNET_TRANSPORT_SS_UP,
471
472 /**
473 * This is just an update about the session,
474 * the state did not change.
475 */
476 GNUNET_TRANSPORT_SS_UPDATE,
477
478 /**
479 * Session is being torn down and about to disappear.
480 * Last call for each session object.
481 */
482 GNUNET_TRANSPORT_SS_DONE
483};
484
485
486/**
487 * Information about a plugin's session.
488 */
489struct GNUNET_TRANSPORT_SessionInfo
490{
491 /**
492 * New state of the session.
493 */
494 enum GNUNET_TRANSPORT_SessionState state;
495
496 /**
497 * #GNUNET_YES if this is an inbound connection,
498 * #GNUNET_NO if this is an outbound connection,
499 * #GNUNET_SYSERR if connections of this plugin
500 * are so fundamentally bidirectional
501 * that they have no 'initiator'
502 */
503 int is_inbound;
504
505 /**
506 * Number of messages pending transmission for this session.
507 */
508 uint32_t num_msg_pending;
509
510 /**
511 * Number of bytes pending transmission for this session.
512 */
513 uint32_t num_bytes_pending;
514
515 /**
516 * Until when does this plugin refuse to receive to manage
517 * staying within the inbound quota? ZERO if receive is
518 * active.
519 */
520 struct GNUNET_TIME_Absolute receive_delay;
521
522 /**
523 * At what time will this session timeout (unless activity
524 * happens)?
525 */
526 struct GNUNET_TIME_Absolute session_timeout;
527
528 /**
529 * Address used by the session. Can be NULL if none is available.
530 */
531 const struct GNUNET_HELLO_Address *address;
532};
533
534
535/**
536 * Function called by the plugin with information about the
537 * current sessions managed by the plugin (for monitoring).
538 *
539 * @param cls closure
540 * @param session session handle this information is about,
541 * NULL to indicate that we are "in sync" (initial
542 * iteration complete)
543 * @param session_ctx storage location where the application
544 * can store data; will point to NULL on #GNUNET_TRANSPORT_SS_INIT,
545 * and must be reset to NULL on #GNUNET_TRANSPORT_SS_DONE
546 * @param info information about the state of the session,
547 * NULL if @a session is also NULL and we are
548 * merely signalling that the initial iteration is over;
549 * NULL with @a session being non-NULL if the monitor
550 * was being cancelled while sessions were active
551 */
552typedef void
553(*GNUNET_TRANSPORT_SessionMonitorCallback) (
554 void *cls,
555 struct GNUNET_TRANSPORT_PluginSession *session,
556 void **session_ctx,
557 const struct GNUNET_TRANSPORT_SessionInfo *info);
558
559
560/**
561 * Install a plugin session state monitor callback. The callback
562 * will be notified whenever the session changes.
563 *
564 * @param cfg configuration to use
565 * @param cb callback to invoke on events
566 * @param cb_cls closure for @a cb
567 * @return NULL on error, otherwise handle for cancellation
568 */
569struct GNUNET_TRANSPORT_PluginMonitor *
570GNUNET_TRANSPORT_monitor_plugins (const struct GNUNET_CONFIGURATION_Handle *cfg,
571 GNUNET_TRANSPORT_SessionMonitorCallback cb,
572 void *cb_cls);
573
574
575/**
576 * Cancel monitoring the plugin session state. The callback will be
577 * called once for each session that is up with the "info" argument
578 * being NULL (this is just to enable client-side cleanup).
579 *
580 * @param pm handle of the request that is to be cancelled
581 */
582void
583GNUNET_TRANSPORT_monitor_plugins_cancel (
584 struct GNUNET_TRANSPORT_PluginMonitor *pm);
585
586
587/**
588 * Opaque handle to the service.
589 */
590struct GNUNET_TRANSPORT_CoreHandle;
591
592
593/**
594 * Function called to notify transport users that another
595 * peer connected to us.
596 *
597 * @param cls closure
598 * @param peer the identity of the peer that connected; this
599 * pointer will remain valid until the disconnect, hence
600 * applications do not necessarily have to make a copy
601 * of the value if they only need it until disconnect
602 * @param mq message queue to use to transmit to @a peer
603 * @return closure to use in MQ handlers
604 */
605typedef void *
606(*GNUNET_TRANSPORT_NotifyConnect) (
607 void *cls,
608 const struct GNUNET_PeerIdentity *peer,
609 struct GNUNET_MQ_Handle *mq);
610
611
612/**
613 * Function called to notify transport users that another peer
614 * disconnected from us. The message queue that was given to the
615 * connect notification will be destroyed and must not be used
616 * henceforth.
617 *
618 * @param cls closure from #GNUNET_TRANSPORT_core_connect
619 * @param peer the peer that disconnected
620 * @param handlers_cls closure of the handlers, was returned from the
621 * connect notification callback
622 */
623typedef void
624(*GNUNET_TRANSPORT_NotifyDisconnect) (
625 void *cls,
626 const struct GNUNET_PeerIdentity *peer,
627 void *handler_cls);
628
629
630/**
631 * Function called if we have "excess" bandwidth to a peer.
632 * The notification will happen the first time we have excess
633 * bandwidth, and then only again after the client has performed
634 * some transmission to the peer.
635 *
636 * Excess bandwidth is defined as being allowed (by ATS) to send
637 * more data, and us reaching the limit of the capacity build-up
638 * (which, if we go past it, means we don't use available bandwidth).
639 * See also the "max carry" in `struct GNUNET_BANDWIDTH_Tracker`.
640 *
641 * @param cls the closure
642 * @param neighbour peer that we have excess bandwidth to
643 * @param handlers_cls closure of the handlers, was returned from the
644 * connect notification callback
645 */
646typedef void
647(*GNUNET_TRANSPORT_NotifyExcessBandwidth) (
648 void *cls,
649 const struct GNUNET_PeerIdentity *neighbour,
650 void *handlers_cls);
651
652
653/**
654 * Connect to the transport service. Note that the connection may
655 * complete (or fail) asynchronously.
656 *
657 * @param cfg configuration to use
658 * @param self our own identity (API should check that it matches
659 * the identity found by transport), or NULL (no check)
660 * @param handlers array of message handlers; note that the
661 * closures provided will be ignored and replaced
662 * with the respective return value from @a nc
663 * @param handlers array with handlers to call when we receive messages, or NULL
664 * @param cls closure for the @a nc, @a nd and @a neb callbacks
665 * @param nc function to call on connect events, or NULL
666 * @param nd function to call on disconnect events, or NULL
667 * @param neb function to call if we have excess bandwidth to a peer, or NULL
668 * @return NULL on error
669 */
670struct GNUNET_TRANSPORT_CoreHandle *
671GNUNET_TRANSPORT_core_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
672 const struct GNUNET_PeerIdentity *self,
673 const struct GNUNET_MQ_MessageHandler *handlers,
674 void *cls,
675 GNUNET_TRANSPORT_NotifyConnect nc,
676 GNUNET_TRANSPORT_NotifyDisconnect nd,
677 GNUNET_TRANSPORT_NotifyExcessBandwidth neb);
678
679
680/**
681 * Disconnect from the transport service.
682 *
683 * @param handle handle returned from connect
684 */
685void
686GNUNET_TRANSPORT_core_disconnect (struct GNUNET_TRANSPORT_CoreHandle *handle);
687
688
689/**
690 * Checks if a given peer is connected to us and get the message queue.
691 *
692 * @param handle connection to transport service
693 * @param peer the peer to check
694 * @return NULL if disconnected, otherwise message queue for @a peer
695 */
696struct GNUNET_MQ_Handle *
697GNUNET_TRANSPORT_core_get_mq (struct GNUNET_TRANSPORT_CoreHandle *handle,
698 const struct GNUNET_PeerIdentity *peer);
699
700
701#if 0 /* keep Emacsens' auto-indent happy */
702{
703#endif
704#ifdef __cplusplus
705}
706#endif
707
708/* ifndef GNUNET_TRANSPORT_SERVICE_H */
709#endif
710
711/** @} */ /* end of group */
712
713/** @} */ /* end of group addition */
714
715/* 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..72ec11eaf
--- /dev/null
+++ b/src/include/gnunet_transport_testing_ng_lib.h
@@ -0,0 +1,81 @@
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_lib.h"
31
32
33/**
34 * Create command.
35 *
36 * @param label name for command.
37 * @param system_label Label of the cmd to setup a test environment.
38 * @param no Decimal number representing the last byte of the IP address of this peer.
39 * @param node_ip The IP address of this node.
40 * @param cfgname Configuration file name for this peer.
41 * @param broadcast Flag indicating, if broadcast should be switched on.
42 * @return command.
43 */
44struct GNUNET_TESTING_Command
45GNUNET_TESTING_cmd_start_peer (const char *label,
46 const char *system_label,
47 uint32_t no,
48 const char *node_ip,
49 const char *cfgname,
50 unsigned int broadcast);
51
52
53struct GNUNET_TESTING_Command
54GNUNET_TESTING_cmd_stop_peer (const char *label,
55 const char *start_label);
56
57
58/**
59 * Create command
60 *
61 * @param label name for command
62 * @param start_peer_label Label of the cmd to start a peer.
63 * @param create_label Label of the cmd which started the test system.
64 * @param num Number globally identifying the node.
65 * @param topology The topology for the test setup.
66 * @param additional_connects Number of additional connects this cmd will wait for not triggered by this cmd.
67 * @return command.
68 */
69struct GNUNET_TESTING_Command
70GNUNET_CORE_cmd_connect_peers (
71 const char *label,
72 const char *start_peer_label,
73 const char *create_label,
74 uint32_t num,
75 struct GNUNET_TESTING_NetjailTopology *topology,
76 unsigned int additional_connects,
77 unsigned int wait_for_connect,
78 struct GNUNET_MQ_MessageHandler *handlers);
79
80
81#endif
diff --git a/src/include/gnunet_util_lib.h b/src/include/gnunet_util_lib.h
index c8737dc60..ee850bc3c 100644
--- a/src/include/gnunet_util_lib.h
+++ b/src/include/gnunet_util_lib.h
@@ -77,6 +77,7 @@ extern "C"
77#include "gnunet_helper_lib.h" 77#include "gnunet_helper_lib.h"
78#include "gnunet_mst_lib.h" 78#include "gnunet_mst_lib.h"
79#include "gnunet_mq_lib.h" 79#include "gnunet_mq_lib.h"
80#include "gnunet_nt_lib.h"
80#include "gnunet_nc_lib.h" 81#include "gnunet_nc_lib.h"
81#include "gnunet_op_lib.h" 82#include "gnunet_op_lib.h"
82#include "gnunet_os_lib.h" 83#include "gnunet_os_lib.h"
diff --git a/src/include/meson.build b/src/include/meson.build
new file mode 100644
index 000000000..57216c178
--- /dev/null
+++ b/src/include/meson.build
@@ -0,0 +1,123 @@
1configure_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
9install_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_record_types.h',
52 'gnunet_hello_uri_lib.h',
53 'gnunet_helper_lib.h',
54 'gnunet_identity_service.h',
55 'gnunet_reclaim_lib.h',
56 'gnunet_reclaim_plugin.h',
57 'gnunet_reclaim_service.h',
58 'gnunet_json_lib.h',
59 'gnunet_load_lib.h',
60 'gnunet_cadet_service.h',
61 'gnunet_messenger_service.h',
62 'gnunet_mhd_compat.h',
63 'gnunet_microphone_lib.h',
64 'gnunet_mst_lib.h',
65 'gnunet_mq_lib.h',
66 'gnunet_namecache_plugin.h',
67 'gnunet_namecache_service.h',
68 'gnunet_namestore_plugin.h',
69 'gnunet_namestore_service.h',
70 'gnunet_nat_auto_service.h',
71 'gnunet_nat_service.h',
72 'gnunet_nc_lib.h',
73 'gnunet_network_lib.h',
74 'gnunet_nse_service.h',
75 'gnunet_nt_lib.h',
76 'gnunet_op_lib.h',
77 'gnunet_os_lib.h',
78 'gnunet_peer_lib.h',
79 'gnunet_peerinfo_service.h',
80 'gnunet_peerstore_plugin.h',
81 'gnunet_peerstore_service.h',
82 'gnunet_plugin_lib.h',
83 'gnunet_pq_lib.h',
84 'gnunet_program_lib.h',
85 'gnunet_protocols.h',
86 'gnunet_resolver_service.h',
87 'gnunet_regex_service.h',
88 'gnunet_rest_lib.h',
89 'gnunet_rest_plugin.h',
90 'gnunet_rps_service.h',
91 'gnunet_revocation_service.h',
92 'gnunet_scalarproduct_service.h',
93 'gnunet_scheduler_lib.h',
94 'gnunet_secretsharing_service.h',
95 'gnunet_service_lib.h',
96 'gnunet_set_service.h',
97 'gnunet_seti_service.h',
98 'gnunet_setu_service.h',
99 'gnunet_signal_lib.h',
100 'gnunet_signatures.h',
101 'gnunet_socks.h',
102 'gnunet_speaker_lib.h',
103 'gnunet_sq_lib.h',
104 'gnunet_statistics_service.h',
105 'gnunet_strings_lib.h',
106 'gnunet_testbed_service.h',
107 'gnunet_testbed_logger_service.h',
108 'gnunet_testing_barrier.h',
109 'gnunet_testing_lib.h',
110 'gnunet_testing_plugin.h',
111 'gnunet_testing_ng_lib.h',
112 'gnunet_testing_netjail_lib.h',
113 'gnunet_time_lib.h',
114 'gnunet_transport_application_service.h',
115 'gnunet_transport_communication_service.h',
116 'gnunet_transport_core_service.h',
117 'gnunet_transport_monitor_service.h',
118 'gnunet_tun_lib.h',
119 'gnunet_uri_lib.h',
120 'gnunet_util_lib.h',
121 'gnunet_vpn_service.h',
122 install_dir: get_option('includedir')/'gnunet'
123 )