GNUnet  0.18.1
Hello library

Helper library for handling HELLOs. More...

Collaboration diagram for Hello library:

Data Structures

struct  GNUNET_HELLO_Address
 An address for communicating with a peer. More...
 
struct  GNUNET_HELLO_Message
 A HELLO message is used to exchange information about transports with other peers. More...
 

Macros

#define GNUNET_HELLO_URI_PREFIX   "gnunet://hello/"
 Prefix that every HELLO URI must start with. More...
 
#define GNUNET_FRIEND_HELLO_URI_PREFIX   "gnunet://friend-hello/"
 Prefix that every FRIEND HELLO URI must start with. More...
 
#define GNUNET_HELLO_URI_SEP   '+'
 Separator used in HELLO URI. More...
 
#define GNUNET_HELLO_address_free(addr)   GNUNET_free (addr)
 Free an address. More...
 

Typedefs

typedef 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 HELLOs. More...
 
typedef int(* GNUNET_HELLO_AddressIterator) (void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_TIME_Absolute expiration)
 Iterator callback to go over all addresses. More...
 
typedef struct GNUNET_TRANSPORT_PluginFunctions *(* GNUNET_HELLO_TransportPluginsFind) (const char *name)
 Helper function to load/access transport plugins. More...
 

Enumerations

enum  GNUNET_HELLO_AddressInfo { GNUNET_HELLO_ADDRESS_INFO_NONE = 0 , GNUNET_HELLO_ADDRESS_INFO_INBOUND = 1 }
 Additional local information about an address. More...
 

Functions

struct GNUNET_HELLO_AddressGNUNET_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. More...
 
struct GNUNET_HELLO_AddressGNUNET_HELLO_address_copy (const struct GNUNET_HELLO_Address *address)
 Copy an address struct. More...
 
int GNUNET_HELLO_address_cmp (const struct GNUNET_HELLO_Address *a1, const struct GNUNET_HELLO_Address *a2)
 Compare two addresses. More...
 
size_t GNUNET_HELLO_address_get_size (const struct GNUNET_HELLO_Address *address)
 Get the size of an address struct. More...
 
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. More...
 
int GNUNET_HELLO_is_friend_only (const struct GNUNET_HELLO_Message *h)
 Return HELLO type. More...
 
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. More...
 
struct GNUNET_HELLO_MessageGNUNET_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 transport addresses. More...
 
uint16_t GNUNET_HELLO_size (const struct GNUNET_HELLO_Message *hello)
 Return the size of the given HELLO message. More...
 
struct GNUNET_HELLO_MessageGNUNET_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 peer). More...
 
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. More...
 
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? More...
 
struct GNUNET_HELLO_MessageGNUNET_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. More...
 
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. More...
 
int GNUNET_HELLO_get_id (const struct GNUNET_HELLO_Message *hello, struct GNUNET_PeerIdentity *peer)
 Get the peer identity from a HELLO message. More...
 
struct GNUNET_MessageHeaderGNUNET_HELLO_get_header (struct GNUNET_HELLO_Message *hello)
 Get the header from a HELLO message, used so other code can correctly send HELLO messages. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
char * GNUNET_HELLO_address_to_prefix (const char *address)
 Given an address as a string, extract the prefix that identifies the communicator offering transmissions to that address. More...
 

Detailed Description

Helper library for handling HELLOs.

See also
Documentation

Macro Definition Documentation

◆ GNUNET_HELLO_URI_PREFIX

#define GNUNET_HELLO_URI_PREFIX   "gnunet://hello/"

Prefix that every HELLO URI must start with.

Definition at line 53 of file gnunet_hello_lib.h.

◆ GNUNET_FRIEND_HELLO_URI_PREFIX

#define GNUNET_FRIEND_HELLO_URI_PREFIX   "gnunet://friend-hello/"

Prefix that every FRIEND HELLO URI must start with.

Definition at line 58 of file gnunet_hello_lib.h.

◆ GNUNET_HELLO_URI_SEP

#define GNUNET_HELLO_URI_SEP   '+'

Separator used in HELLO URI.

Definition at line 63 of file gnunet_hello_lib.h.

◆ GNUNET_HELLO_address_free

#define GNUNET_HELLO_address_free (   addr)    GNUNET_free (addr)

Free an address.

Parameters
addraddress to free

Definition at line 198 of file gnunet_hello_lib.h.

Typedef Documentation

◆ GNUNET_HELLO_GenerateAddressListCallback

typedef 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 HELLOs.

Should use GNUNET_HELLO_add_address() as a helper function.

Parameters
clsclosure
maxmaximum number of bytes that can be written to buf
bufwhere to write the address information
Returns
number of bytes written or 0, GNUNET_SYSERR to signal the end of the iteration.

Definition at line 275 of file gnunet_hello_lib.h.

◆ GNUNET_HELLO_AddressIterator

typedef int(* GNUNET_HELLO_AddressIterator) (void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_TIME_Absolute expiration)

Iterator callback to go over all addresses.

Parameters
clsclosure
addressthe address
expirationexpiration time
Returns
GNUNET_OK to keep the address, GNUNET_NO to delete it from the HELLO GNUNET_SYSERR to stop iterating (but keep current address)

Definition at line 358 of file gnunet_hello_lib.h.

◆ GNUNET_HELLO_TransportPluginsFind

typedef struct GNUNET_TRANSPORT_PluginFunctions*( * GNUNET_HELLO_TransportPluginsFind) (const char *name)

Helper function to load/access transport plugins.

FIXME: pass closure!

Parameters
namename of the transport plugin to load
Returns
NULL if a plugin with name name is not known/loadable

Definition at line 436 of file gnunet_hello_lib.h.

Enumeration Type Documentation

◆ GNUNET_HELLO_AddressInfo

Additional local information about an address.

These information are only valid for the local peer and are not serialized when a GNUNET_HELLO_Message is created

Enumerator
GNUNET_HELLO_ADDRESS_INFO_NONE 

No additional information.

GNUNET_HELLO_ADDRESS_INFO_INBOUND 

This is an inbound address and cannot be used to initiate an outbound connection to another peer.

Definition at line 72 of file gnunet_hello_lib.h.

73 {
78 
84 };
@ 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.

Function Documentation

◆ GNUNET_HELLO_address_allocate()

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.

Parameters
peerthe peer
transport_nameplugin name
addressbinary address
address_lengthnumber of bytes in address
local_infoadditional local information for the address
Returns
the address struct

Definition at line 63 of file address.c.

68 {
69  struct GNUNET_HELLO_Address *addr;
70  size_t slen;
71  char *end;
72 
73  slen = strlen (transport_name) + 1;
74  addr = GNUNET_malloc (sizeof(struct GNUNET_HELLO_Address)
75  + address_length + slen);
76  addr->peer = *peer;
77  addr->address = &addr[1];
79  addr->local_info = local_info;
80  end = (char *) &addr[1];
83  address,
87  slen);
88  return addr;
89 }
static int end
Set if we are to shutdown all services (including ARM).
Definition: gnunet-arm.c:34
static char * address
GNS address for this phone.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_malloc(size)
Wrapper around malloc.
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).
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.

References address, GNUNET_HELLO_Address::address, GNUNET_HELLO_Address::address_length, end, GNUNET_malloc, GNUNET_memcpy, GNUNET_HELLO_Address::local_info, GNUNET_HELLO_Address::peer, peer, and GNUNET_HELLO_Address::transport_name.

Referenced by ack_proc(), address_notification(), broadcast_mst_cb(), create_session(), GNUNET_HELLO_address_copy(), handle_helper_message(), handle_response(), handle_tcp_nat_probe(), handle_tcp_welcome(), LIBGNUNET_PLUGIN_TRANSPORT_DONE(), libgnunet_plugin_transport_unix_done(), process_data(), process_udp_message(), read_process_ack(), server_add_address(), server_lookup_connection(), server_notify_external_hostname(), server_remove_address(), tcp_nat_port_map_callback(), udp_nat_port_map_callback(), and unix_demultiplexer().

Here is the caller graph for this function:

◆ GNUNET_HELLO_address_copy()

struct GNUNET_HELLO_Address* GNUNET_HELLO_address_copy ( const struct GNUNET_HELLO_Address address)

Copy an address struct.

Parameters
addressaddress to copy
Returns
a copy of the address struct

Definition at line 99 of file address.c.

100 {
101  if (NULL == address)
102  return NULL;
103  return GNUNET_HELLO_address_allocate (&address->peer,
104  address->transport_name,
105  address->address,
106  address->address_length,
107  address->local_info);
108 }
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

References address, and GNUNET_HELLO_address_allocate().

Referenced by ats_perf_cb(), ats_perf_mon_cb(), create_session(), find_validation_entry(), GNUNET_ATS_address_add(), GST_ats_add_address(), GST_ats_add_inbound_address(), GST_blacklist_test_allowed(), GST_hello_modify_addresses(), http_client_plugin_get_session(), process_peer_monitoring_cb(), resolve_peer_address(), send_with_session(), set_primary_address(), test_connection_ok(), udp_plugin_create_session(), and unix_plugin_get_session().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_HELLO_address_cmp()

int GNUNET_HELLO_address_cmp ( const struct GNUNET_HELLO_Address a1,
const struct GNUNET_HELLO_Address a2 
)

Compare two addresses.

Does NOT compare the peer identity, that is assumed already to match!

Parameters
a1first address
a2second address
Returns
0 if the addresses are equal, -1 if a1< a2, 1 if a1> a2.

Definition at line 112 of file address.c.

114 {
115  int ret;
116 
117  if ((NULL == a1) &&
118  (NULL == a2))
119  return 0;
120  if (NULL == a1)
121  return 1;
122  if (NULL == a2)
123  return -1;
124  ret = strcmp (a1->transport_name, a2->transport_name);
125  if (0 != ret)
126  return ret;
127  if (a1->local_info != a2->local_info)
128  return (((int) a1->local_info) < ((int) a2->local_info)) ? -1 : 1;
129  if (a1->address_length < a2->address_length)
130  return -1;
131  if (a1->address_length > a2->address_length)
132  return 1;
133  return memcmp (a1->address,
134  a2->address,
135  a1->address_length);
136 }
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81

References GNUNET_HELLO_Address::address, GNUNET_HELLO_Address::address_length, GNUNET_HELLO_Address::local_info, ret, and GNUNET_HELLO_Address::transport_name.

Referenced by find_address_it(), find_ai_cb(), find_ai_no_session_cb(), find_other_matching(), find_session_id(), get_match_exp(), GST_blacklist_abort_matching(), GST_hello_modify_addresses(), GST_hello_test_address(), lookup_session_it(), process_peer_monitoring_cb(), session_cmp_it(), session_lookup_client_by_address(), session_lookup_it(), set_primary_address(), switch_address_bl_check_cont(), try_run_fast_ats_update(), and validation_entry_match().

Here is the caller graph for this function:

◆ GNUNET_HELLO_address_get_size()

size_t GNUNET_HELLO_address_get_size ( const struct GNUNET_HELLO_Address address)

Get the size of an address struct.

Parameters
addressaddress
Returns
the size

Definition at line 55 of file address.c.

56 {
57  return sizeof(struct GNUNET_HELLO_Address) + address->address_length
58  + strlen (address->transport_name) + 1;
59 }

References address, GNUNET_HELLO_Address::address_length, and GNUNET_HELLO_Address::transport_name.

◆ GNUNET_HELLO_address_check_option()

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.

Parameters
addressthe address to check
optionthe respective option to check for
Returns
GNUNET_YES or GNUNET_NO

Definition at line 39 of file address.c.

41 {
42  if (option == (address->local_info & option))
43  return GNUNET_YES;
44  return GNUNET_NO;
45 }
@ GNUNET_YES
@ GNUNET_NO

References address, GNUNET_NO, and GNUNET_YES.

Referenced by GNUNET_ATS_address_del_session(), GST_ats_add_address(), GST_ats_add_inbound_address(), GST_ats_block_address(), GST_ats_del_session(), GST_neighbours_switch_to_address(), handle_ats_address_suggestion(), handle_tcp_welcome(), notify_session_monitor(), plugin_env_session_start(), plugin_env_session_start_bl_check_cont(), switch_address_bl_check_cont(), and tcp_plugin_get_session().

Here is the caller graph for this function:

◆ GNUNET_HELLO_is_friend_only()

int GNUNET_HELLO_is_friend_only ( const struct GNUNET_HELLO_Message h)

Return HELLO type.

Parameters
hHELLO Message to test
Returns
GNUNET_YES for friend-only or GNUNET_NO otherwise

Definition at line 89 of file hello.c.

90 {
91  if (GNUNET_YES == ntohl (h->friend_only))
92  return GNUNET_YES;
93  return GNUNET_NO;
94 }
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99

References GNUNET_NO, GNUNET_YES, and h.

Referenced by dump_my_hello(), GNUNET_HELLO_compose_uri(), GST_validation_handle_hello(), main(), peerinfo_list_iteration(), print_peer_info(), read_host_file(), update_friend_hello(), and update_hello().

Here is the caller graph for this function:

◆ GNUNET_HELLO_add_address()

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.

Parameters
addressaddress to add
expirationexpiration for the address
targetwhere to copy the address
maxmaximum number of bytes to copy to target
Returns
number of bytes copied, 0 if the target buffer was not big enough.
Parameters
addressthe address
expirationexpiration for the address
targetwhere to copy the address
maxmaximum number of bytes to copy to target
Returns
number of bytes copied, 0 if the target buffer was not big enough.

Definition at line 109 of file hello.c.

113 {
114  uint16_t alen;
115  size_t slen;
116  struct GNUNET_TIME_AbsoluteNBO exp;
117 
118  slen = strlen (address->transport_name) + 1;
119  if (slen + sizeof(uint16_t) + sizeof(struct GNUNET_TIME_AbsoluteNBO)
120  + address->address_length > max)
121  return 0;
123  alen = htons ((uint16_t) address->address_length);
124  GNUNET_memcpy (target, address->transport_name, slen);
125  GNUNET_memcpy (&target[slen], &alen, sizeof(uint16_t));
126  slen += sizeof(uint16_t);
127  GNUNET_memcpy (&target[slen], &exp, sizeof(struct GNUNET_TIME_AbsoluteNBO));
128  slen += sizeof(struct GNUNET_TIME_AbsoluteNBO);
129  GNUNET_memcpy (&target[slen], address->address, address->address_length);
130  slen += address->address_length;
131  return slen;
132 }
static char * expiration
Credential TTL.
Definition: gnunet-abd.c:96
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:638
#define max(x, y)
Time for absolute time used by GNUnet, in microseconds and in network byte order.

References address, expiration, GNUNET_memcpy, GNUNET_TIME_absolute_hton(), and max.

Referenced by add_address_to_hello(), add_to_buf(), add_valid_peer_address(), address_generator(), and copy_latest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_HELLO_create()

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 transport addresses.

If friend only is set to GNUNET_YES we create a FRIEND_HELLO which will not be gossiped to other peers.

Parameters
public_keypublic key to include in the HELLO
addrgencallback to invoke to get addresses
addrgen_clsclosure for addrgen
friend_onlyshould the returned HELLO be only visible to friends?
Returns
the hello message

Definition at line 204 of file hello.c.

208 {
209  char buffer[GNUNET_MAX_MESSAGE_SIZE - 1 - 256
210  - sizeof(struct GNUNET_HELLO_Message)];
211  size_t max;
212  size_t used;
213  size_t ret;
214  struct GNUNET_HELLO_Message *hello;
215 
216  GNUNET_assert (NULL != public_key);
218  (GNUNET_NO == friend_only));
219  max = sizeof(buffer);
220  used = 0;
221  if (NULL != addrgen)
222  {
223  while (GNUNET_SYSERR != (ret = addrgen (addrgen_cls,
224  max,
225  &buffer[used])))
226  {
227  max -= ret;
228  used += ret;
229  }
230  }
231  hello = GNUNET_malloc (sizeof(struct GNUNET_HELLO_Message) + used);
232  hello->header.type = htons (GNUNET_MESSAGE_TYPE_HELLO);
233  hello->header.size = htons (sizeof(struct GNUNET_HELLO_Message) + used);
234  hello->friend_only = htonl (friend_only);
235  hello->publicKey = *public_key;
236  GNUNET_memcpy (&hello[1],
237  buffer,
238  used);
239  return hello;
240 }
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message,...
@ GNUNET_SYSERR
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_MESSAGE_TYPE_HELLO
HELLO message with friend only flag used for communicating peer addresses.
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.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.

References GNUNET_HELLO_Message::friend_only, GNUNET_assert, GNUNET_malloc, GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_HELLO, GNUNET_NO, GNUNET_SYSERR, GNUNET_YES, GNUNET_HELLO_Message::header, max, GNUNET_HELLO_Message::publicKey, ret, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.

Referenced by GNUNET_HELLO_merge(), GNUNET_HELLO_parse_uri(), GST_validation_handle_pong(), main(), refresh_hello_task(), and update_friend_hello().

Here is the caller graph for this function:

◆ GNUNET_HELLO_size()

uint16_t GNUNET_HELLO_size ( const struct GNUNET_HELLO_Message hello)

Return the size of the given HELLO message.

Parameters
helloto inspect
Returns
the size, 0 if HELLO is invalid

Definition at line 630 of file hello.c.

631 {
632  uint16_t ret = ntohs (hello->header.size);
633 
634  if ((ret < sizeof(struct GNUNET_HELLO_Message)) ||
635  (ntohs (hello->header.type) != GNUNET_MESSAGE_TYPE_HELLO))
636  return 0;
637  return ret;
638 }

References GNUNET_MESSAGE_TYPE_HELLO, GNUNET_HELLO_Message::header, ret, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.

Referenced by add_to_tc(), announce_id(), callback_download(), check_info(), check_notification(), consider_for_advertising(), dht_get_id_handler(), discard_hosts_helper(), dump_my_hello(), find_advertisable_hello(), GCP_set_hello(), GNUNET_HELLO_iterate_addresses(), got_hello(), host_processor(), main(), make_info_message(), make_peer(), offer_hello(), prepare_beacon(), read_host_file(), refresh_hello_task(), schedule_next_hello(), send_hello_beacon(), and update_hello().

Here is the caller graph for this function:

◆ GNUNET_HELLO_merge()

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 peer).

Parameters
h1first HELLO message
h2the second HELLO message
Returns
the combined hello message

Definition at line 515 of file hello.c.

517 {
518  struct MergeContext mc = { h1, h2, NULL, NULL, 0, 0, 0 };
519  int friend_only;
520 
521  if (h1->friend_only != h2->friend_only)
522  friend_only = GNUNET_YES; /* One of the HELLOs is friend only */
523  else
524  friend_only = ntohl (h1->friend_only); /* Both HELLO's have the same type */
525 
526  return GNUNET_HELLO_create (&h1->publicKey,
527  &merge_addr,
528  &mc,
529  friend_only);
530 }
static struct GNUNET_TESTBED_Controller * mc
Handle to the master controller.
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
static ssize_t merge_addr(void *cls, size_t max, void *buf)
Function called to build the HELLO during GNUNET_HELLO_merge() by merging addresses from two original...
Definition: hello.c:483
Closure for merge_pr().
const struct GNUNET_HELLO_Message * h1
First HELLO we are merging.
Definition: hello.c:393
const struct GNUNET_HELLO_Message * h2
Second HELLO we are merging.
Definition: hello.c:398

References GNUNET_HELLO_Message::friend_only, GNUNET_HELLO_create(), GNUNET_YES, MergeContext::h1, MergeContext::h2, mc, merge_addr(), and GNUNET_HELLO_Message::publicKey.

Referenced by consider_for_advertising(), GCP_set_hello(), update_friend_hello(), and update_hello().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_HELLO_equals()

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.

If they only differ in expiration time, the lowest expiration time larger than 'now' where they differ is returned.

Parameters
h1first HELLO message
h2the second HELLO message
nowtime to use for deciding which addresses have expired and should not be considered at all
Returns
absolute time forever if the two HELLOs are totally identical; smallest timestamp >= now if they only differ in timestamps; zero if the some addresses with expirations >= now do not match at all

If they only differ in expiration time, the lowest expiration time larger than now where they differ is returned.

Parameters
h1first HELLO message
h2the second HELLO message
nowtime to use for deciding which addresses have expired and should not be considered at all
Returns
absolute time forever if the two HELLOs are totally identical; smallest timestamp >= now if they only differ in timestamps; zero if the some addresses with expirations >= now do not match at all

Definition at line 770 of file hello.c.

815 {
816  struct EqualsContext ec;
817 
818  if (h1->header.type != h2->header.type)
820  if (0 !=
821  GNUNET_memcmp (&h1->publicKey,
822  &h2->publicKey))
824  ec.expiration_limit = now;
825  ec.result = GNUNET_TIME_UNIT_FOREVER_ABS;
826  ec.ref = h2;
828  GNUNET_NO,
829  &find_matching,
830  &ec);
831  if (ec.result.abs_value_us == GNUNET_TIME_UNIT_ZERO.rel_value_us)
832  return ec.result;
833  ec.ref = h1;
835  GNUNET_NO,
836  &find_matching,
837  &ec);
838  return ec.result;
839 }
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
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
static int find_matching(void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_TIME_Absolute expiration)
Helper function for GNUNET_HELLO_equals().
Definition: hello.c:770
Context used for comparing HELLOs in GNUNET_HELLO_equals().
Definition: hello.c:687

Referenced by consider_for_advertising(), and update_hello().

Here is the caller graph for this function:

◆ GNUNET_HELLO_get_last_expiration()

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?

Parameters
msgHELLO to inspect
Returns
time the last address expires, 0 if there are no addresses in the HELLO

Definition at line 852 of file hello.c.

871 {
872  struct GNUNET_TIME_Absolute ret;
873 
876  GNUNET_NO,
878  &ret);
879  return ret;
880 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
static int find_max_expire(void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_TIME_Absolute expiration)
Iterator to find the time when the last address will expire.
Definition: hello.c:852
Time for absolute times used by GNUnet, in microseconds.

Referenced by announce_id(), consider_peer_destroy(), and got_hello().

Here is the caller graph for this function:

◆ GNUNET_HELLO_iterate_addresses()

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.

Parameters
msgHELLO to iterate over; client does not need to have verified that msg is well-formed (beyond starting with a GNUNET_MessageHeader of the right type).
return_modifiedif a modified copy should be returned, otherwise NULL will be returned
ititerator to call on each address
it_clsclosure for it
Returns
the modified HELLO or NULL
Parameters
msgHELLO to iterate over
return_modifiedif a modified copy should be returned, otherwise NULL will be returned
ititerator to call on each address
it_clsclosure for it
Returns
modified HELLO message

Definition at line 254 of file hello.c.

258 {
260  uint16_t msize;
261  struct GNUNET_HELLO_Message *ret;
262  const char *inptr;
263  size_t insize;
264  size_t esize;
265  size_t wpos;
266  char *woff;
267  uint16_t alen;
269  int iret;
270 
271  msize = GNUNET_HELLO_size (msg);
272  if ((msize < sizeof(struct GNUNET_HELLO_Message)) ||
273  (ntohs (msg->header.type) != GNUNET_MESSAGE_TYPE_HELLO))
274  {
275  GNUNET_break_op (0);
276  return NULL;
277  }
278  ret = NULL;
279  if (return_modified)
280  {
281  ret = GNUNET_malloc (msize);
283  msg,
284  msize);
285  }
286  inptr = (const char *) &msg[1];
287  insize = msize - sizeof(struct GNUNET_HELLO_Message);
288  wpos = 0;
289  woff = (NULL != ret) ? (char *) &ret[1] : NULL;
290  address.peer.public_key = msg->publicKey;
292  "HELLO has %u bytes of address data\n",
293  (unsigned int) insize);
294 
295  while (insize > 0)
296  {
297  esize = get_hello_address_size (inptr,
298  insize,
299  &alen);
300  if (0 == esize)
301  {
302  GNUNET_break (0);
303  GNUNET_free (ret);
304  return NULL;
305  }
306  /* need GNUNET_memcpy() due to possibility of misalignment */
308  &inptr[esize - alen - sizeof(struct
310  sizeof(struct GNUNET_TIME_AbsoluteNBO));
311  address.address = &inptr[esize - alen];
312  address.address_length = alen;
313  address.transport_name = inptr;
315  iret = it (it_cls,
316  &address,
318  if (GNUNET_SYSERR == iret)
319  break;
320  if ((GNUNET_OK == iret) &&
321  (NULL != ret))
322  {
323  /* copy address over */
324  GNUNET_memcpy (woff,
325  inptr,
326  esize);
327  woff += esize;
328  wpos += esize;
329  }
330  insize -= esize;
331  inptr += esize;
332  }
333  if (NULL != ret)
334  ret->header.size = ntohs (sizeof(struct GNUNET_HELLO_Message) + wpos);
335  return ret;
336 }
static char * expire
DID Document expiration Date Attribut String.
Definition: gnunet-did.c:101
uint16_t GNUNET_HELLO_size(const struct GNUNET_HELLO_Message *hello)
Return the size of the given HELLO message.
Definition: hello.c:630
#define GNUNET_log(kind,...)
@ GNUNET_OK
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:737
static size_t get_hello_address_size(const char *buf, size_t max, uint16_t *ralen)
Get the size of an address entry in a HELLO message.
Definition: hello.c:144

References address, expire, get_hello_address_size(), GNUNET_break, GNUNET_break_op, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_HELLO_ADDRESS_INFO_NONE, GNUNET_HELLO_size(), GNUNET_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_HELLO, GNUNET_OK, GNUNET_SYSERR, GNUNET_TIME_absolute_ntoh(), msg, ret, and GNUNET_MessageHeader::type.

Referenced by add_from_hello(), consider_for_advertising(), copy_latest(), delta_match(), discard_hosts_helper(), dump_my_hello(), find_matching(), GNUNET_HELLO_compose_uri(), GNUNET_HELLO_iterate_new_addresses(), GST_validation_handle_hello(), hello_update_cb(), host_processor(), merge_addr(), peerinfo_list_iteration(), print_peer_info(), process_peerinfo_hello(), read_host_file(), and update_hello().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_HELLO_iterate_new_addresses()

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.

Note that if the address is present in old_hello but the expiration time in new_hello is more recent, the iterator is also called.

Parameters
new_helloa HELLO message
old_helloa HELLO message
expiration_limitignore addresses in old_hello that expired before the given time stamp
ititerator to call on each address
it_clsclosure for it

Definition at line 601 of file hello.c.

609 {
610  struct DeltaContext dc;
611 
612  dc.expiration_limit = expiration_limit;
613  dc.it = it;
614  dc.it_cls = it_cls;
615  dc.old_hello = old_hello;
616  GNUNET_assert (NULL ==
618  GNUNET_NO,
619  &delta_match,
620  &dc));
621 }
static struct GNUNET_FS_DownloadContext * dc
static int delta_match(void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_TIME_Absolute expiration)
Check if the given address is 'new', and if so, call the iterator.
Definition: hello.c:575
Context used in GNUNET_HELLO_iterate_new_addresses() to figure out which addresses are in fact 'new'.
Definition: hello.c:538
void * it_cls
Closure for it.
Definition: hello.c:552
const struct GNUNET_HELLO_Message * old_hello
HELLO with known addresses, addresses in this HELLO we must always ignore.
Definition: hello.c:558
GNUNET_HELLO_AddressIterator it
Function to call on addresses that are indeed new.
Definition: hello.c:547
struct GNUNET_TIME_Absolute expiration_limit
We should ignore addresses that expire before this time.
Definition: hello.c:542

References dc, delta_match(), DeltaContext::expiration_limit, GNUNET_assert, GNUNET_HELLO_iterate_addresses(), GNUNET_NO, DeltaContext::it, DeltaContext::it_cls, and DeltaContext::old_hello.

Here is the call graph for this function:

◆ GNUNET_HELLO_get_id()

int GNUNET_HELLO_get_id ( const struct GNUNET_HELLO_Message hello,
struct GNUNET_PeerIdentity peer 
)

Get the peer identity from a HELLO message.

Parameters
hellothe hello message
peerwhere to store the peer's identity
Returns
GNUNET_SYSERR if the HELLO was malformed

Definition at line 649 of file hello.c.

651 {
652  uint16_t ret = ntohs (hello->header.size);
653 
654  if ((ret < sizeof(struct GNUNET_HELLO_Message)) ||
655  (ntohs (hello->header.type) != GNUNET_MESSAGE_TYPE_HELLO))
656  return GNUNET_SYSERR;
657  peer->public_key = hello->publicKey;
658  return GNUNET_OK;
659 }

References GNUNET_MESSAGE_TYPE_HELLO, GNUNET_OK, GNUNET_SYSERR, GNUNET_HELLO_Message::header, peer, GNUNET_HELLO_Message::publicKey, ret, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.

Referenced by add_valid_address(), check_hello(), check_info(), consider_for_advertising(), get_hello(), GNUNET_PEERINFO_add_peer(), GNUNET_TRANSPORT_offer_hello(), GST_validation_handle_hello(), handle_hello(), hello_callback(), hosts_directory_scan_callback(), main(), process_data(), and update_friend_hello().

Here is the caller graph for this function:

◆ GNUNET_HELLO_get_header()

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.

Parameters
hellothe hello message
Returns
header or NULL if the HELLO was malformed

Definition at line 671 of file hello.c.

672 {
673  uint16_t ret = ntohs (hello->header.size);
674 
675  if ((ret < sizeof(struct GNUNET_HELLO_Message)) ||
676  (ntohs (hello->header.type) != GNUNET_MESSAGE_TYPE_HELLO))
677  return NULL;
678 
679  return &hello->header;
680 }

References GNUNET_MESSAGE_TYPE_HELLO, GNUNET_HELLO_Message::header, ret, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.

Referenced by GCP_set_hello().

Here is the caller graph for this function:

◆ GNUNET_HELLO_compose_uri()

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.

Parameters
helloHello message
plugins_findFunction to find transport plugins by name
Returns
Hello URI string

Definition at line 1007 of file hello.c.

1009 {
1011  char *pkey;
1012 
1013  ctx.plugins_find = plugins_find;
1015  GNUNET_asprintf (&ctx.uri,
1016  "%s%s",
1020  pkey);
1021  GNUNET_free (pkey);
1023  GNUNET_NO,
1025  &ctx);
1026  return ctx.uri;
1027 }
static char * pkey
Public key of the zone to look in, in ASCII.
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
#define GNUNET_FRIEND_HELLO_URI_PREFIX
Prefix that every FRIEND HELLO URI must start with.
int GNUNET_HELLO_is_friend_only(const struct GNUNET_HELLO_Message *h)
Return HELLO type.
Definition: hello.c:89
#define GNUNET_HELLO_URI_PREFIX
Prefix that every HELLO URI must start with.
char * GNUNET_CRYPTO_eddsa_public_key_to_string(const struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Convert a public key to a string.
Definition: crypto_ecc.c:251
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
static int add_address_to_uri(void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_TIME_Absolute expiration)
GNUnet URIs are of the general form "gnunet://MODULE/IDENTIFIER".
Definition: hello.c:936
Context used for building our own URI.
Definition: hello.c:37
GNUNET_HELLO_TransportPluginsFind plugins_find
Function for finding transport plugins by name.
Definition: hello.c:46

References add_address_to_uri(), ctx, GNUNET_asprintf(), GNUNET_CRYPTO_eddsa_public_key_to_string(), GNUNET_free, GNUNET_FRIEND_HELLO_URI_PREFIX, GNUNET_HELLO_is_friend_only(), GNUNET_HELLO_iterate_addresses(), GNUNET_HELLO_URI_PREFIX, GNUNET_NO, GNUNET_YES, pkey, GNUNET_HELLO_ComposeUriContext::plugins_find, and GNUNET_HELLO_Message::publicKey.

Referenced by peerinfo_cb(), and print_my_uri().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_HELLO_parse_uri()

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.

Parameters
uriURI string to parse
pubkeyPointer to struct where public key is parsed
helloPointer to struct where hello message is parsed
plugins_findFunction to find transport plugins by name
Returns
GNUNET_OK on success, GNUNET_SYSERR if the URI was invalid, GNUNET_NO on other errors

Definition at line 1195 of file hello.c.

1199 {
1200  const char *pks;
1201  const char *exc;
1202  int friend_only;
1204 
1205  if (0 == strncmp (uri,
1207  strlen (GNUNET_HELLO_URI_PREFIX)))
1208  {
1209  pks = &uri[strlen (GNUNET_HELLO_URI_PREFIX)];
1210  friend_only = GNUNET_NO;
1211  }
1212  else if (0 == strncmp (uri,
1215  {
1216  pks = &uri[strlen (GNUNET_FRIEND_HELLO_URI_PREFIX)];
1217  friend_only = GNUNET_YES;
1218  }
1219  else
1220  return GNUNET_SYSERR;
1221  exc = strchr (pks, GNUNET_HELLO_URI_SEP);
1222 
1223  if (GNUNET_OK !=
1225  (NULL == exc) ? strlen (pks) : (exc - pks),
1226  (unsigned char *) pubkey,
1227  sizeof(*pubkey)))
1228  return GNUNET_SYSERR;
1229 
1230  ctx.pos = exc;
1231  ctx.ret = GNUNET_OK;
1232  ctx.counter_total = 0;
1233  ctx.counter_added = 0;
1234  ctx.plugins_find = plugins_find;
1235  *hello = GNUNET_HELLO_create (pubkey,
1237  &ctx,
1238  friend_only);
1239 
1241  "HELLO URI contained %u addresses, added %u addresses\n",
1242  ctx.counter_total,
1243  ctx.counter_added);
1244 
1245  return ctx.ret;
1246 }
static struct GNUNET_IDENTITY_PublicKey pubkey
Public key of the zone to look in.
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
#define GNUNET_HELLO_URI_SEP
Separator used in HELLO URI.
enum GNUNET_GenericReturnValue GNUNET_STRINGS_string_to_data(const char *enc, size_t enclen, void *out, size_t out_size)
Convert CrockfordBase32 encoding back to data.
Definition: strings.c:788
static ssize_t add_address_to_hello(void *cls, size_t max, void *buffer)
We're building a HELLO.
Definition: hello.c:1043
Context for add_address_to_hello().
Definition: hello.c:54
GNUNET_HELLO_TransportPluginsFind plugins_find
Function for finding transport plugins by name.
Definition: hello.c:78

References add_address_to_hello(), ctx, GNUNET_ERROR_TYPE_DEBUG, GNUNET_FRIEND_HELLO_URI_PREFIX, GNUNET_HELLO_create(), GNUNET_HELLO_URI_PREFIX, GNUNET_HELLO_URI_SEP, GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_STRINGS_string_to_data(), GNUNET_SYSERR, GNUNET_YES, GNUNET_HELLO_ParseUriContext::plugins_find, pubkey, and uri.

Referenced by gnunet_try_connect(), and parse_hello_uri().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_HELLO_sign_address()

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.

Parameters
addresstext address to sign
ntnetwork type of address
mono_timewhen was address valid
private_keysigning key to use
[out]resultwhere to write address record (allocated)
[out]result_sizeset to size of result
addresstext address at communicator to sign
ntnetwork type of address
mono_timemonotonic time at which address was valid
private_keysigning key to use
[out]resultwhere to write address record (allocated)
[out]result_sizeset to size of result

Definition at line 67 of file hello-ng.c.

74 {
75  struct SignedAddress sa;
77  char *sig_str;
78 
79  sa.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_ADDRESS);
80  sa.purpose.size = htonl (sizeof(sa));
81  sa.mono_time = GNUNET_TIME_absolute_hton (mono_time);
82  GNUNET_CRYPTO_hash (address, strlen (address), &sa.addr_hash);
83  GNUNET_CRYPTO_eddsa_sign (private_key, &sa, &sig);
84  sig_str = NULL;
85  (void) GNUNET_STRINGS_base64_encode (&sig, sizeof(sig), &sig_str);
86  *result_size =
87  1 + GNUNET_asprintf ((char **) result,
88  "%s;%llu;%u;%s",
89  sig_str,
90  (unsigned long long) mono_time.abs_value_us,
91  (unsigned int) nt,
92  address);
93  GNUNET_free (sig_str);
94 }
#define GNUNET_SIGNATURE_PURPOSE_TRANSPORT_ADDRESS
Signature by a peer affirming that this is one of its addresses for the given time period.
static struct GNUNET_NAT_AUTO_Test * nt
Handle to a NAT test operation.
static int result
Global testing status.
#define GNUNET_CRYPTO_eddsa_sign(priv, ps, sig)
EdDSA sign a given block.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:41
size_t GNUNET_STRINGS_base64_encode(const void *in, size_t len, char **output)
Encode into Base64.
Definition: strings.c:1607
an ECC signature using EdDSA.
uint64_t abs_value_us
The actual value.
Binary block we sign when we sign an address.
Definition: hello-ng.c:38

References GNUNET_TIME_Absolute::abs_value_us, SignedAddress::addr_hash, address, GNUNET_asprintf(), GNUNET_CRYPTO_eddsa_sign, GNUNET_CRYPTO_hash(), GNUNET_free, GNUNET_SIGNATURE_PURPOSE_TRANSPORT_ADDRESS, GNUNET_STRINGS_base64_encode(), GNUNET_TIME_absolute_hton(), SignedAddress::mono_time, nt, SignedAddress::purpose, GNUNET_CRYPTO_EccSignaturePurpose::purpose, result, and GNUNET_CRYPTO_EccSignaturePurpose::size.

Referenced by store_pi().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_HELLO_extract_address()

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.

Parameters
rawraw signed address
raw_sizesize of raw
pidpublic key to use for signature verification
[out]ntset to network type
[out]mono_timewhen was the address generated
Returns
NULL on error, otherwise the address
Parameters
rawraw signed address
raw_sizesize of raw
pidpublic key to use for signature verification
nt[out]set to network type
mono_time[out]when was the address generated
Returns
NULL on error, otherwise the address

Definition at line 108 of file hello-ng.c.

113 {
114  const struct GNUNET_CRYPTO_EddsaPublicKey *public_key = &pid->public_key;
115  const char *raws = raw;
116  unsigned long long raw_us = 0;
117  unsigned int raw_nt = 0;
118  const char *sc;
119  const char *sc2;
120  const char *sc3;
121  const char *raw_addr;
122  char *data = NULL;
123  struct GNUNET_TIME_Absolute raw_mono_time;
124  struct SignedAddress sa;
125  struct GNUNET_CRYPTO_EddsaSignature *sig;
126 
127  if ('\0' != raws[raw_size-1])
128  {
129  GNUNET_break_op (0);
130  return NULL;
131  }
132  if (NULL == (sc = strchr (raws, ';')))
133  {
134  GNUNET_break_op (0);
135  return NULL;
136  }
137  if (NULL == (sc2 = strchr (sc + 1, ';')))
138  {
139  GNUNET_break_op (0);
140  return NULL;
141  }
142  if (NULL == (sc3 = strchr (sc2 + 1, ';')))
143  {
144  GNUNET_break_op (0);
145  return NULL;
146  }
147  if (2 != sscanf (sc + 1, "%llu;%u;%*s", &raw_us, &raw_nt))
148  {
149  GNUNET_break_op (0);
150  return NULL;
151  }
152  raw_addr = sc3 + 1;
153  raw_mono_time.abs_value_us = raw_us;
154  if (sizeof(struct GNUNET_CRYPTO_EddsaSignature) !=
155  GNUNET_STRINGS_base64_decode (raws, sc - raws, (void **) &data))
156  {
157  GNUNET_break_op (0);
158  GNUNET_free (data);
159  return NULL;
160  }
161  sig = (struct GNUNET_CRYPTO_EddsaSignature*) data;
162  sa.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_ADDRESS);
163  sa.purpose.size = htonl (sizeof(sa));
164  sa.mono_time = GNUNET_TIME_absolute_hton (raw_mono_time);
165  GNUNET_CRYPTO_hash (raw_addr, strlen (raw_addr), &sa.addr_hash);
166  if (GNUNET_YES !=
168  &sa,
169  sig,
170  public_key))
171  {
172  GNUNET_break_op (0);
173  return NULL;
174  }
175  *mono_time = raw_mono_time;
176  *nt = raw_nt;
177  return GNUNET_strdup (raw_addr);
178 }
static int raw
raw output
Definition: gnunet-gns.c:78
uint32_t data
The data value.
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:87
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
#define GNUNET_CRYPTO_eddsa_verify(purp, ps, sig, pub)
Verify EdDSA signature.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
size_t GNUNET_STRINGS_base64_decode(const char *data, size_t len, void **output)
Decode from Base64.
Definition: strings.c:1695
Public ECC key (always for curve Ed25519) encoded in a format suitable for network transmission and E...
struct GNUNET_CRYPTO_EddsaPublicKey public_key

References GNUNET_TIME_Absolute::abs_value_us, SignedAddress::addr_hash, data, GNUNET_break_op, GNUNET_CRYPTO_eddsa_verify, GNUNET_CRYPTO_hash(), GNUNET_free, GNUNET_SIGNATURE_PURPOSE_TRANSPORT_ADDRESS, GNUNET_strdup, GNUNET_STRINGS_base64_decode(), GNUNET_TIME_absolute_hton(), GNUNET_YES, SignedAddress::mono_time, nt, pid, GNUNET_PeerIdentity::public_key, SignedAddress::purpose, GNUNET_CRYPTO_EccSignaturePurpose::purpose, raw, sc, and GNUNET_CRYPTO_EccSignaturePurpose::size.

Referenced by offer_hello().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_HELLO_address_to_prefix()

char* GNUNET_HELLO_address_to_prefix ( const char *  address)

Given an address as a string, extract the prefix that identifies the communicator offering transmissions to that address.

Parameters
addressa peer's address
Returns
NULL if the address is mal-formed, otherwise the prefix

Definition at line 189 of file hello-ng.c.

190 {
191  const char *dash;
192 
193  dash = strchr (address, '-');
194  if (NULL == dash)
195  return NULL;
196  return GNUNET_strndup (address, dash - address);
197 }
#define GNUNET_strndup(a, length)
Wrapper around GNUNET_xstrndup_.

Referenced by GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue(), and suggest_to_connect().

Here is the caller graph for this function: