GNUnet  0.10.x
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 
34 #ifndef GNUNET_HELLO_LIB_H
35 #define GNUNET_HELLO_LIB_H
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #if 0 /* keep Emacsens' auto-indent happy */
40 }
41 #endif
42 #endif
43 
44 #include "gnunet_util_lib.h"
45 
49 #define GNUNET_HELLO_URI_PREFIX "gnunet://hello/"
50 
54 #define GNUNET_FRIEND_HELLO_URI_PREFIX "gnunet://friend-hello/"
55 
59 #define GNUNET_HELLO_URI_SEP '+'
60 
61 
69 {
74 
80 };
81 
82 
90 {
91 
96 
101  const char *transport_name;
102 
106  const void *address;
107 
112 
124 };
125 
126 
137 struct GNUNET_HELLO_Address *
139  const char *transport_name,
140  const void *address,
141  size_t address_length,
143 
144 
151 struct GNUNET_HELLO_Address *
153 
154 
163 int
165  const struct GNUNET_HELLO_Address *a2);
166 
167 
174 size_t
176 
177 
185 int
188 
189 
195 #define GNUNET_HELLO_address_free(addr) GNUNET_free (addr)
196 
197 
199 
214 {
218  struct GNUNET_MessageHeader header;
219 
223  uint32_t friend_only GNUNET_PACKED;
224 
229 };
231 
232 
239 int
241 
242 
254 size_t
257  char *target,
258  size_t max);
259 
260 
272 typedef ssize_t (*GNUNET_HELLO_GenerateAddressListCallback) (void *cls,
273  size_t max,
274  void *buf);
275 
276 
291 struct GNUNET_HELLO_Message *
292 GNUNET_HELLO_create (const struct GNUNET_CRYPTO_EddsaPublicKey *public_key,
294  void *addrgen_cls,
295  int friend_only);
296 
297 
304 uint16_t
305 GNUNET_HELLO_size (const struct GNUNET_HELLO_Message *hello);
306 
307 
317 struct GNUNET_HELLO_Message *
318 GNUNET_HELLO_merge (const struct GNUNET_HELLO_Message *h1,
319  const struct GNUNET_HELLO_Message *h2);
320 
321 
339 GNUNET_HELLO_equals (const struct GNUNET_HELLO_Message *h1,
340  const struct GNUNET_HELLO_Message *h2,
341  struct GNUNET_TIME_Absolute now);
342 
343 
355  void *cls,
356  const struct GNUNET_HELLO_Address *address,
358 
359 
368 
369 
382 struct GNUNET_HELLO_Message *
384  int return_modified,
386  void *it_cls);
387 
388 
402 void
404  const struct GNUNET_HELLO_Message *new_hello,
405  const struct GNUNET_HELLO_Message *old_hello,
406  struct GNUNET_TIME_Absolute expiration_limit,
408  void *it_cls);
409 
410 
418 int
419 GNUNET_HELLO_get_id (const struct GNUNET_HELLO_Message *hello,
420  struct GNUNET_PeerIdentity *peer);
421 
422 
431 struct GNUNET_MessageHeader *
433 
434 
442 typedef struct GNUNET_TRANSPORT_PluginFunctions *(
444 
445 
453 char *
455  GNUNET_HELLO_TransportPluginsFind plugins_find);
456 
457 
467 int
468 GNUNET_HELLO_parse_uri (const char *uri,
470  struct GNUNET_HELLO_Message **hello,
471  GNUNET_HELLO_TransportPluginsFind plugins_find);
472 
473 
474 /* NG API */
475 #include "gnunet_nt_lib.h"
476 
477 
488 void
490  const char *address,
491  enum GNUNET_NetworkType nt,
492  struct GNUNET_TIME_Absolute mono_time,
493  const struct GNUNET_CRYPTO_EddsaPrivateKey *private_key,
494  void **result,
495  size_t *result_size);
496 
497 
508 char *
509 GNUNET_HELLO_extract_address (const void *raw,
510  size_t raw_size,
511  const struct GNUNET_PeerIdentity *pid,
512  enum GNUNET_NetworkType *nt,
513  struct GNUNET_TIME_Absolute *mono_time);
514 
515 
523 char *
524 GNUNET_HELLO_address_to_prefix (const char *address);
525 
526 
527 #if 0 /* keep Emacsens' auto-indent happy */
528 {
529 #endif
530 #ifdef __cplusplus
531 }
532 #endif
533 
534 /* ifndef GNUNET_HELLO_LIB_H */
535 #endif
536  /* end of group */
538 
539 /* end of gnunet_hello_lib.h */
size_t address_length
Number of bytes in address.
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:668
enum GNUNET_HELLO_AddressInfo local_info
Extended information about address.
A HELLO message is used to exchange information about transports with other peers.
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
static struct GNUNET_CRYPTO_EcdsaPublicKey pubkey
Public key of the zone to look in.
static char * expiration
Credential TTL.
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:73
const void * address
Binary representation of the address (plugin-specific).
static int raw
raw output
Definition: gnunet-gns.c:55
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:524
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
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:1028
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
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:832
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:690
GNUNET_NetworkType
Types of networks (with separate quotas) we support.
Definition: gnunet_nt_lib.h:35
#define GNUNET_NETWORK_STRUCT_BEGIN
Define as empty, GNUNET_PACKED should suffice, but this won&#39;t work on W32.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
struct GNUNET_TRANSPORT_PluginFunctions *(* GNUNET_HELLO_TransportPluginsFind)(const char *name)
Helper function to load/access transport plugins.
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
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
int GNUNET_HELLO_address_cmp(const struct GNUNET_HELLO_Address *a1, const struct GNUNET_HELLO_Address *a2)
Compare two addresses.
Definition: address.c:130
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
This is an inbound address and cannot be used to initiate an outbound connection to another peer...
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:1213
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:66
static char * option
Name of the option.
Definition: gnunet-config.c:38
static char buf[2048]
const char * transport_name
Name of the transport plugin enabling the communication using this address.
static int result
Global testing status.
static struct GNUNET_NAT_AUTO_Test * nt
Handle to a NAT test operation.
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
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:191
const char * name
int GNUNET_HELLO_is_friend_only(const struct GNUNET_HELLO_Message *h)
Return HELLO type.
Definition: hello.c:89
struct GNUNET_PeerIdentity peer
For which peer is this an address?
#define GNUNET_NETWORK_STRUCT_END
Define as empty, GNUNET_PACKED should suffice, but this won&#39;t work on W32;.
Private ECC key encoded for transmission.
The identity of the host (wraps the signing key of the peer).
No additional information.
int(* GNUNET_HELLO_AddressIterator)(void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_TIME_Absolute expiration)
Iterator callback to go over all addresses.
#define GNUNET_PACKED
gcc-ism to get packed structs.
An address for communicating with a peer.
struct GNUNET_HELLO_Address * GNUNET_HELLO_address_copy(const struct GNUNET_HELLO_Address *address)
Copy an address struct.
Definition: address.c:109
uint16_t GNUNET_HELLO_size(const struct GNUNET_HELLO_Message *hello)
Return the size of the given HELLO message.
Definition: hello.c:649
size_t GNUNET_HELLO_address_get_size(const struct GNUNET_HELLO_Address *address)
Get the size of an address struct.
Definition: address.c:55
Header for all communications.
Time for absolute times used by GNUnet, in microseconds.
uint32_t friend_only
Use in F2F mode: Do not gossip this HELLO message.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
GNUNET_HELLO_AddressInfo
Additional local information about an address.
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:890
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
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...
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:623
Public ECC key (always for curve Ed25519) encoded in a format suitable for network transmission and E...