273#if HELLO_DETERMINISTIC_PID_DERIVATION
274 for (
const struct Address *a = addr_start;
279 "Hashing over %.*s\n",
319 &parser->pid.public_key))
322 "HELLO signature invalid, rejecting.\n");
383 while (NULL != (a = parser->a_head))
401 while (NULL != (a =
builder->a_head))
442 if (NULL == (e = strstr (
address,
447 "Invalid address `%s'\n",
457 if ( (! isalpha ((
unsigned char) *
p)) &&
479 return strcmp (a->
uri, b->
uri);
489 size_t alen = strlen (
address) + 1;
495 "Failed to add address to builder\n");
499 for (a = parser->a_head;
510 a->
uri = (
const char *) &a[1];
540 if (block_size <
sizeof (*bh))
546 block +=
sizeof (*bh);
547 block_size -=
sizeof (*bh);
548 while (block_size > 0)
550 const void *
end = memchr (block,
569 block_size -= (
end - block);
629 size_t alen = strlen (
address) + 1;
635 "Failed to add address to builder\n");
650 a->
uri = (
const char *) &a[1];
674 if (0 != strncasecmp (url,
676 strlen (
"gnunet://hello/")))
678 url += strlen (
"gnunet://hello/");
679 s1 = strchr (url,
'/');
685 s2 = strchr (s1 + 1,
'/');
691 q = strchr (url,
'?');
693 q = url + strlen (url);
716 if ( (0 == sscanf (s2 + 1,
742 eq = strchr (
q,
'=');
750 amp = strchr (eq,
'&');
756 if ( (NULL == addr) ||
757 (0 == strlen (addr)) )
808 const char *sep =
"?";
811 sizeof (parser->pid));
813 sizeof (parser->sig));
815 "gnunet://hello/%s/%s/%" PRIu64,
818 parser->et.abs_value_us);
821 for (
struct Address *a = parser->a_head;
830 eou = strstr (a->uri,
838 pfx_len = eou - a->uri;
865 size_t needed =
sizeof (bh);
868 for (
struct Address *a = parser->a_head;
873 needed += a->uri_len;
875 if ( (NULL == block) ||
876 (needed < *block_size) )
878 *block_size = needed;
881 bh.
pid = parser->pid;
882 bh.
sig = parser->sig;
887 pos = block +
sizeof (bh);
888 for (
struct Address *a = parser->a_head;
897 *block_size = needed;
909 if (parser->a_length > UINT16_MAX)
922 msg->url_counter = htons ((uint16_t) parser->a_length);
983 for (
struct Address *a = parser->a_head;
1005 uint16_t len = ntohs (hello->
size);
1015 if (len <
sizeof (*
msg))
1020 len -=
sizeof (*msg);
1021 *block_size = len +
sizeof (*bh);
1082 const char *sep =
"?";
1089 "gnunet://hello/%s/%s/%" PRIu64,
1104 eou = strstr (a->uri,
1112 pfx_len = eou - a->uri;
1152 if (
builder->a_length > UINT16_MAX)
1161 msg->url_counter = htons ((uint16_t)
builder->a_length);
1197 (
char*) block +
sizeof (*block),
1198 block_size -
sizeof (*block));
1203 msg->url_counter = htons ((uint16_t) parser->a_length);
1204 return &
msg->header;
1232 (
char*) block +
sizeof (*block),
1233 block_size -
sizeof (*block));
1238 msg->url_counter = htons ((uint16_t)
builder->a_length);
1239 return &
msg->header;
1262 et = expiration_time;
1267 pos = block +
sizeof (bh);
1268 for (
struct Address *a =
builder->a_head; NULL != a; a = a->next)
1316 size_t needed =
sizeof (bh);
1323 needed += a->uri_len;
1336 for (
struct Address *a = abuilder->
a_head; NULL != a; a = a->next)
1338 for (
struct Address *b = bbuilder->
a_head; NULL != b; b = b->next)
1340 if (0 != strcmp (b->uri, a->uri))
struct GNUNET_MessageHeader * msg
struct GNUNET_MQ_Envelope * env
static struct GNUNET_ARM_Handle * h
Connection with ARM.
static int ret
Final status code.
static int end
Set if we are to shutdown all services (including ARM).
static char * address
GNS address for this phone.
static struct HostSet * builder
NULL if we are not currently iterating over peer information.
static struct GNUNET_TIME_Relative expiration
User supplied expiration value.
static struct in_addr dummy
Target "dummy" address of the packet we pretend to respond to.
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 struct GNUNET_REVOCATION_Query * q
Handle for revocation query.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
static struct GNUNET_FS_UnindexContext * uc
static struct GNUNET_OS_Process * p
Helper process we started.
Helper library for handling HELLO URIs.
Constants for network protocols.
#define GNUNET_SIGNATURE_PURPOSE_HELLO
Signature by which a peer affirms its address.
#define GNUNET_CRYPTO_eddsa_verify(purp, ps, sig, pub)
Verify EdDSA signature.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
void GNUNET_HELLO_parser_free(struct GNUNET_HELLO_Parser *parser)
Release resources of a builder.
struct GNUNET_HELLO_Parser * GNUNET_HELLO_parser_from_msg(const struct GNUNET_MessageHeader *msg)
Parse msg.
void GNUNET_HELLO_builder_to_block(const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_PeerIdentity *pid, const struct GNUNET_CRYPTO_EddsaSignature *sig, struct GNUNET_TIME_Absolute expiration_time, char *block)
Generate DHT block from a builder.
void GNUNET_HELLO_builder_free(struct GNUNET_HELLO_Builder *builder)
Release resources of a builder.
char * GNUNET_HELLO_parser_to_url(const struct GNUNET_HELLO_Parser *parser)
Generate GNUnet HELLO URI from a parser.
struct GNUNET_HELLO_Builder * GNUNET_HELLO_builder_new()
Allocate builder.
enum GNUNET_GenericReturnValue GNUNET_HELLO_dht_msg_to_block(const struct GNUNET_MessageHeader *hello, const struct GNUNET_PeerIdentity *pid, void **block, size_t *block_size, struct GNUNET_TIME_Absolute *block_expiration)
Convert a DHT hello message to a HELLO block.
struct GNUNET_HELLO_Parser * GNUNET_HELLO_parser_from_block_(const void *block, size_t block_size, int noverify)
Parse block.
void GNUNET_HELLO_builder_iterate(const struct GNUNET_HELLO_Builder *builder, GNUNET_HELLO_UriCallback uc, void *uc_cls)
Iterate over URIs in a builder.
enum GNUNET_GenericReturnValue GNUNET_HELLO_parser_to_block(const struct GNUNET_HELLO_Parser *parser, void *block, size_t *block_size)
Generate DHT block from a parser.
enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_to_url(const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_PeerIdentity *pid, const struct GNUNET_CRYPTO_EddsaSignature *sig, char **result)
Generate GNUnet HELLO URI from a builder.
struct GNUNET_HELLO_Builder * GNUNET_HELLO_builder_from_parser(const struct GNUNET_HELLO_Parser *p, struct GNUNET_PeerIdentity *pid)
Allocate builder from parser.
const struct GNUNET_PeerIdentity * GNUNET_HELLO_parser_iterate(const struct GNUNET_HELLO_Parser *parser, GNUNET_HELLO_UriCallback uc, void *uc_cls)
Iterate over URIs in a parser.
struct GNUNET_MessageHeader * GNUNET_HELLO_parser_to_dht_hello_msg(const struct GNUNET_HELLO_Parser *parser)
Generate DHT HELLO message from a parser.
enum GNUNET_GenericReturnValue GNUNET_HELLO_build_url(const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_PeerIdentity *pid, const struct GNUNET_CRYPTO_EddsaSignature *sig, struct GNUNET_TIME_Absolute expiration, char **result)
struct GNUNET_MQ_Envelope * GNUNET_HELLO_parser_to_env(const struct GNUNET_HELLO_Parser *parser)
Generate envelope with GNUnet HELLO message (including peer ID) from a parser.
enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_address_list_cmp(const struct GNUNET_HELLO_Builder *abuilder, const struct GNUNET_HELLO_Builder *bbuilder)
Compare address lists of two builders.
enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_del_address(struct GNUNET_HELLO_Builder *builder, const char *address)
Remove individual address from the builder.
struct GNUNET_TIME_Absolute GNUNET_HELLO_get_expiration_time_from_msg(const struct GNUNET_MessageHeader *msg)
Get the expiration time for this HELLO.
size_t GNUNET_HELLO_get_builder_to_block_size(const struct GNUNET_HELLO_Builder *builder)
Get projected block size for builder.
const struct GNUNET_PeerIdentity * GNUNET_HELLO_parser_get_id(const struct GNUNET_HELLO_Parser *parser)
Get the PeerIdentity for this builder.
void(* GNUNET_HELLO_UriCallback)(void *cls, const struct GNUNET_PeerIdentity *pid, const char *uri)
Callback function used to extract URIs from a builder.
#define GNUNET_HELLO_ADDRESS_EXPIRATION
For how long are HELLO signatures valid?
enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_add_address(struct GNUNET_HELLO_Builder *builder, const char *address)
Add individual address to the builder.
struct GNUNET_HELLO_Parser * GNUNET_HELLO_parser_from_url(const char *url)
Parse GNUnet HELLO url.
enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_to_url2(const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_PeerIdentity *pid, const struct GNUNET_CRYPTO_EddsaSignature *sig, struct GNUNET_TIME_Absolute validity, char **result)
Generate GNUnet HELLO URI from a builder.
struct GNUNET_MessageHeader * GNUNET_HELLO_builder_to_dht_hello_msg(const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_PeerIdentity *pid, const struct GNUNET_CRYPTO_EddsaSignature *hello_sig, struct GNUNET_TIME_Absolute expiration_time)
Generate DHT HELLO message (without peer ID) from a builder.
struct GNUNET_HELLO_Parser * GNUNET_HELLO_parser_from_block(const void *block, size_t block_size)
Parse block.
char * GNUNET_HELLO_address_to_prefix(const char *address)
Given an address as a string, extract the prefix that identifies the communicator offering transmissi...
void GNUNET_HELLO_builder_hash_addresses(const struct GNUNET_HELLO_Builder *builder, struct GNUNET_HashCode *hash)
Compute hash over addresses in builder.
struct GNUNET_MQ_Envelope * GNUNET_HELLO_builder_to_env(const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_PeerIdentity *pid, const struct GNUNET_CRYPTO_EddsaSignature *hello_sig, struct GNUNET_TIME_Absolute expiration_time)
Generate envelope with GNUnet HELLO message (including peer ID) from a builder.
#define GNUNET_NETWORK_STRUCT_BEGIN
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
#define GNUNET_log(kind,...)
void GNUNET_CRYPTO_hash_context_read(struct GNUNET_HashContext *hc, const void *buf, size_t size)
Add data to be hashed.
#define GNUNET_NETWORK_STRUCT_END
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32;.
void GNUNET_CRYPTO_hash_context_finish(struct GNUNET_HashContext *hc, struct GNUNET_HashCode *r_hash)
Finish the hash computation.
#define GNUNET_CONTAINER_DLL_insert_sorted(TYPE, comparator, comparator_cls, head, tail, element)
Insertion sort of element into DLL from head to tail sorted by comparator.
GNUNET_GenericReturnValue
Named constants for return values.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
struct GNUNET_HashContext * GNUNET_CRYPTO_hash_context_start(void)
Start incremental hashing operation.
#define GNUNET_PACKED
gcc-ism to get packed structs.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_strndup(a, length)
Wrapper around GNUNET_xstrndup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
#define GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO
HELLO advertising a neighbours addresses.
#define GNUNET_MESSAGE_TYPE_HELLO_URI
Latest HELLO messages used for communicating peer addresses.
size_t GNUNET_STRINGS_urlencode(size_t len, const char data[static len], char **out)
url/percent encode (RFC3986).
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
size_t GNUNET_STRINGS_urldecode(const char *data, size_t len, char **out)
url/percent encode (RFC3986).
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.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
bool GNUNET_TIME_absolute_is_past(struct GNUNET_TIME_Absolute abs)
Test if abs is truly in the past (excluding now).
static enum GNUNET_GenericReturnValue verify_hello(const struct GNUNET_HELLO_Parser *parser, struct GNUNET_TIME_Absolute et, const struct GNUNET_CRYPTO_EddsaSignature *sig)
Verify HELLO signature.
static void hash_addresses(const struct Address *addr_start, struct GNUNET_HashCode *hash)
static struct GNUNET_HELLO_Parser * parser_new(const struct GNUNET_PeerIdentity *pid)
static int cmp_address(void *cls, struct Address *a, struct Address *b)
Alphanumeric sorting for addresses.
static enum GNUNET_GenericReturnValue check_address(const char *address)
static enum GNUNET_GenericReturnValue parser_add_address(struct GNUNET_HELLO_Parser *parser, const char *address)
static unsigned int size
Size of the "table".
Struct to wrap data to do the merge of to hello uris.
unsigned int merged
Did we found at least one address to merge.
struct GNUNET_HELLO_Builder * builder
The builder of the hello uri we merge with.
unsigned int found
Did we found the actual address to check.
const char * address_uri
The actual address to check, if it is already in the hello uri we merge with.
struct Address * next
Kept in a DLL.
size_t uri_len
Length of uri including 0-terminator.
struct Address * prev
Kept in a DLL.
const char * uri
Actual URI, allocated at the end of this struct.
Message used when a DHT provides its HELLO to direct neighbours.
uint16_t reserved
Reserved.
struct GNUNET_TIME_AbsoluteNBO expiration_time
When does the HELLO expire?
struct GNUNET_MessageHeader header
Type must be GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO.
struct GNUNET_CRYPTO_EddsaSignature sig
Signature over the block, of purpose GNUNET_SIGNATURE_PURPOSE_HELLO.
uint16_t url_counter
Number of URLs encoded after the end of the struct, in NBO.
header of what an ECC signature signs this must be followed by "size - 8" bytes of the actual signed ...
uint32_t size
How many bytes does this signature sign? (including this purpose header); in network byte order (!...
an ECC signature using EdDSA.
Context for building (or parsing) HELLO URIs.
struct Address * a_tail
Tail of the addresses DLL.
struct Address * a_head
Head of the addresses DLL.
unsigned int a_length
Length of the a_head DLL.
Context for parsing HELLOs.
struct GNUNET_PeerIdentity pid
Public key of the peer.
struct GNUNET_TIME_Absolute et
Expiration time parsed.
struct GNUNET_CRYPTO_EddsaSignature sig
The signature (may have been provided)
struct Address * a_tail
Tail of the addresses DLL.
unsigned int a_length
Length of the a_head DLL.
struct Address * a_head
Head of the addresses DLL.
pid_t pid
PID of the process.
The identity of the host (wraps the signing key of the peer).
Time for absolute time used by GNUnet, in microseconds and in network byte order.
Time for absolute times used by GNUnet, in microseconds.
uint64_t abs_value_us
The actual value.
Message used when gossiping HELLOs between peers.
uint16_t reserved
Reserved.
uint16_t url_counter
Number of URLs encoded after the end of the struct, in NBO.
struct GNUNET_MessageHeader header
Type must be GNUNET_MESSAGE_TYPE_HELLO_URI.
Message signed as part of a HELLO block/URL.
struct GNUNET_HashCode h_addrs
Hash over all addresses.
struct GNUNET_TIME_AbsoluteNBO expiration_time
When does the signature expire?
struct GNUNET_CRYPTO_EccSignaturePurpose purpose
Purpose must be GNUNET_SIGNATURE_PURPOSE_HELLO.