GNUnet  0.19.2
gnunet_hello_lib.h
Go to the documentation of this file.
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 
37 #ifndef GNUNET_HELLO_LIB_H
38 #define GNUNET_HELLO_LIB_H
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #if 0 /* keep Emacsens' auto-indent happy */
43 }
44 #endif
45 #endif
46 
47 
48 #include "gnunet_util_lib.h"
49 
53 #define GNUNET_HELLO_URI_PREFIX "gnunet://hello/"
54 
58 #define GNUNET_FRIEND_HELLO_URI_PREFIX "gnunet://friend-hello/"
59 
63 #define GNUNET_HELLO_URI_SEP '+'
64 
65 
73 {
78 
84 };
85 
86 
94 {
99 
104  const char *transport_name;
105 
109  const void *address;
110 
115 
127 };
128 
129 
140 struct GNUNET_HELLO_Address *
142  const char *transport_name,
143  const void *address,
144  size_t address_length,
146 
147 
154 struct GNUNET_HELLO_Address *
156 
157 
166 int
168  const struct GNUNET_HELLO_Address *a2);
169 
170 
177 size_t
179 
180 
188 int
190  enum GNUNET_HELLO_AddressInfo option);
191 
192 
198 #define GNUNET_HELLO_address_free(addr) GNUNET_free (addr)
199 
200 
202 
217 {
222 
227 
232 };
234 
235 
242 int
244 
245 
257 size_t
260  char *target,
261  size_t max);
262 
263 
275 typedef ssize_t
277  size_t max,
278  void *buf);
279 
280 
295 struct GNUNET_HELLO_Message *
296 GNUNET_HELLO_create (const struct GNUNET_CRYPTO_EddsaPublicKey *public_key,
298  void *addrgen_cls,
299  int friend_only);
300 
301 
308 uint16_t
309 GNUNET_HELLO_size (const struct GNUNET_HELLO_Message *hello);
310 
311 
321 struct GNUNET_HELLO_Message *
322 GNUNET_HELLO_merge (const struct GNUNET_HELLO_Message *h1,
323  const struct GNUNET_HELLO_Message *h2);
324 
325 
343 GNUNET_HELLO_equals (const struct GNUNET_HELLO_Message *h1,
344  const struct GNUNET_HELLO_Message *h2,
345  struct GNUNET_TIME_Absolute now);
346 
347 
359  void *cls,
360  const struct GNUNET_HELLO_Address *address,
362 
363 
372 
373 
386 struct GNUNET_HELLO_Message *
388  int return_modified,
390  void *it_cls);
391 
392 
406 void
408  const struct GNUNET_HELLO_Message *new_hello,
409  const struct GNUNET_HELLO_Message *old_hello,
410  struct GNUNET_TIME_Absolute expiration_limit,
412  void *it_cls);
413 
414 
422 int
423 GNUNET_HELLO_get_id (const struct GNUNET_HELLO_Message *hello,
424  struct GNUNET_PeerIdentity *peer);
425 
426 
435 struct GNUNET_MessageHeader *
437 
438 
446 typedef struct GNUNET_TRANSPORT_PluginFunctions *(
448 
449 
457 char *
459  GNUNET_HELLO_TransportPluginsFind plugins_find);
460 
461 
471 int
472 GNUNET_HELLO_parse_uri (const char *uri,
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 
492 void
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 
512 char *
513 GNUNET_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 
527 char *
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  /* end of group */
542  /* end of group addition */
544 
545 /* end of gnunet_hello_lib.h */
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
static char * expiration
Credential TTL.
Definition: gnunet-abd.c:96
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static char * address
GNS address for this phone.
static int raw
raw output
Definition: gnunet-gns.c:78
static struct GNUNET_IDENTITY_PublicKey pubkey
Public key of the zone to look in.
static struct GNUNET_NAT_AUTO_Test * nt
Handle to a NAT test operation.
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
static int result
Global testing status.
static char buf[2048]
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
int GNUNET_HELLO_get_id(const struct GNUNET_HELLO_Message *hello, struct GNUNET_PeerIdentity *peer)
Get the peer identity from a HELLO message.
Definition: hello.c:649
void GNUNET_HELLO_sign_address(const char *address, enum GNUNET_NetworkType nt, struct GNUNET_TIME_Absolute mono_time, const struct GNUNET_CRYPTO_EddsaPrivateKey *private_key, void **result, size_t *result_size)
Build address record by signing raw information with private key.
Definition: hello-ng.c:67
void GNUNET_HELLO_iterate_new_addresses(const struct GNUNET_HELLO_Message *new_hello, const struct GNUNET_HELLO_Message *old_hello, struct GNUNET_TIME_Absolute expiration_limit, GNUNET_HELLO_AddressIterator it, void *it_cls)
Iterate over addresses in new_hello that are NOT already present in old_hello.
Definition: hello.c:601
uint16_t GNUNET_HELLO_size(const struct GNUNET_HELLO_Message *hello)
Return the size of the given HELLO message.
Definition: hello.c:630
struct GNUNET_TIME_Absolute GNUNET_HELLO_get_last_expiration(const struct GNUNET_HELLO_Message *msg)
When does the last address in the given HELLO expire?
Definition: hello.c:870
struct GNUNET_HELLO_Message * GNUNET_HELLO_create(const struct GNUNET_CRYPTO_EddsaPublicKey *public_key, GNUNET_HELLO_GenerateAddressListCallback addrgen, void *addrgen_cls, int friend_only)
Construct a HELLO message given the public key, expiration time and an iterator that spews the transp...
Definition: hello.c:204
struct GNUNET_HELLO_Message * GNUNET_HELLO_merge(const struct GNUNET_HELLO_Message *h1, const struct GNUNET_HELLO_Message *h2)
Construct a HELLO message by merging the addresses in two existing HELLOs (which must be for the same...
Definition: hello.c:515
struct GNUNET_HELLO_Address * GNUNET_HELLO_address_allocate(const struct GNUNET_PeerIdentity *peer, const char *transport_name, const void *address, size_t address_length, enum GNUNET_HELLO_AddressInfo local_info)
Allocate an address struct.
Definition: address.c:63
int GNUNET_HELLO_parse_uri(const char *uri, struct GNUNET_CRYPTO_EddsaPublicKey *pubkey, struct GNUNET_HELLO_Message **hello, GNUNET_HELLO_TransportPluginsFind plugins_find)
Parse a hello URI string to a hello message.
Definition: hello.c:1195
char * GNUNET_HELLO_address_to_prefix(const char *address)
Given an address as a string, extract the prefix that identifies the communicator offering transmissi...
Definition: hello-ng.c:189
ssize_t(* GNUNET_HELLO_GenerateAddressListCallback)(void *cls, size_t max, void *buf)
Callback function used to fill a buffer of max bytes with a list of addresses in the format used by H...
int GNUNET_HELLO_is_friend_only(const struct GNUNET_HELLO_Message *h)
Return HELLO type.
Definition: hello.c:89
struct GNUNET_MessageHeader * GNUNET_HELLO_get_header(struct GNUNET_HELLO_Message *hello)
Get the header from a HELLO message, used so other code can correctly send HELLO messages.
Definition: hello.c:671
size_t GNUNET_HELLO_add_address(const struct GNUNET_HELLO_Address *address, struct GNUNET_TIME_Absolute expiration, char *target, size_t max)
Copy the given address information into the given buffer using the format of HELLOs.
Definition: hello.c:109
struct GNUNET_TIME_Absolute GNUNET_HELLO_equals(const struct GNUNET_HELLO_Message *h1, const struct GNUNET_HELLO_Message *h2, struct GNUNET_TIME_Absolute now)
Test if two HELLO messages contain the same addresses.
Definition: hello.c:812
struct GNUNET_HELLO_Address * GNUNET_HELLO_address_copy(const struct GNUNET_HELLO_Address *address)
Copy an address struct.
Definition: address.c:99
int(* GNUNET_HELLO_AddressIterator)(void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_TIME_Absolute expiration)
Iterator callback to go over all addresses.
size_t GNUNET_HELLO_address_get_size(const struct GNUNET_HELLO_Address *address)
Get the size of an address struct.
Definition: address.c:55
int GNUNET_HELLO_address_check_option(const struct GNUNET_HELLO_Address *address, enum GNUNET_HELLO_AddressInfo option)
Check if an address has a local option set.
Definition: address.c:39
struct GNUNET_TRANSPORT_PluginFunctions *(* GNUNET_HELLO_TransportPluginsFind)(const char *name)
Helper function to load/access transport plugins.
char * GNUNET_HELLO_compose_uri(const struct GNUNET_HELLO_Message *hello, GNUNET_HELLO_TransportPluginsFind plugins_find)
Compose a hello URI string from a hello message.
Definition: hello.c:1007
char * GNUNET_HELLO_extract_address(const void *raw, size_t raw_size, const struct GNUNET_PeerIdentity *pid, enum GNUNET_NetworkType *nt, struct GNUNET_TIME_Absolute *mono_time)
Check signature and extract address record.
Definition: hello-ng.c:108
struct GNUNET_HELLO_Message * GNUNET_HELLO_iterate_addresses(const struct GNUNET_HELLO_Message *msg, int return_modified, GNUNET_HELLO_AddressIterator it, void *it_cls)
Iterate over all of the addresses in the HELLO.
Definition: hello.c:254
GNUNET_HELLO_AddressInfo
Additional local information about an address.
int GNUNET_HELLO_address_cmp(const struct GNUNET_HELLO_Address *a1, const struct GNUNET_HELLO_Address *a2)
Compare two addresses.
Definition: address.c:112
@ GNUNET_HELLO_ADDRESS_INFO_INBOUND
This is an inbound address and cannot be used to initiate an outbound connection to another peer.
@ GNUNET_HELLO_ADDRESS_INFO_NONE
No additional information.
#define GNUNET_NETWORK_STRUCT_BEGIN
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32.
#define GNUNET_NETWORK_STRUCT_END
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32;.
#define GNUNET_PACKED
gcc-ism to get packed structs.
GNUNET_NetworkType
Types of networks (with separate quotas) we support.
Definition: gnunet_nt_lib.h:39
#define max(x, y)
const char * name
Private ECC key encoded for transmission.
Public ECC key (always for curve Ed25519) encoded in a format suitable for network transmission and E...
An address for communicating with a peer.
const char * transport_name
Name of the transport plugin enabling the communication using this address.
size_t address_length
Number of bytes in address.
struct GNUNET_PeerIdentity peer
For which peer is this an address?
enum GNUNET_HELLO_AddressInfo local_info
Extended information about address.
const void * address
Binary representation of the address (plugin-specific).
A HELLO message is used to exchange information about transports with other peers.
uint32_t friend_only
Use in F2F mode: Do not gossip this HELLO message.
struct GNUNET_CRYPTO_EddsaPublicKey publicKey
The public key of the peer.
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_HELLO.
Header for all communications.
The identity of the host (wraps the signing key of the peer).
Time for absolute times used by GNUnet, in microseconds.
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.