118 slen = strlen (
address->transport_name) + 1;
123 alen = htons ((uint16_t)
address->address_length);
126 slen +=
sizeof(uint16_t);
130 slen +=
address->address_length;
156 while ((left > 0) && (
'\0' != *pos))
219 max =
sizeof(buffer);
286 inptr = (
const char *) &
msg[1];
289 woff = (NULL !=
ret) ? (
char *) &
ret[1] : NULL;
292 "HELLO has %u bytes of address data\n",
293 (
unsigned int) insize);
308 &inptr[esize - alen -
sizeof(
struct
311 address.address = &inptr[esize - alen];
313 address.transport_name = inptr;
824 ec.expiration_limit = now;
947 char *client_str =
"_client";
951 papi =
ctx->plugins_find (
address->transport_name);
960 "URI conversion not implemented for plugin `%s'\n",
967 if ((NULL == addr) ||
968 (0 == strlen (addr)))
972 if (NULL != (pos = strstr (addr_dup,
"_server")))
975 strlen (client_str));
977 seconds =
expiration.abs_value_us / 1000LL / 1000LL;
978 t = gmtime (&seconds);
1053 struct tm expiration_time;
1054 time_t expiration_seconds;
1062 if (NULL ==
ctx->pos)
1072 if ((
'0' ==
ctx->pos[0]) &&
1076 tname =
ctx->pos + 1;
1080 memset (&expiration_time, 0,
sizeof(expiration_time));
1081 tname = strptime (
ctx->pos,
1089 "Failed to parse HELLO message: missing expiration time\n"));
1094 expiration_seconds = mktime (&expiration_time);
1095 if (expiration_seconds == (time_t) -1)
1099 "Failed to parse HELLO message: invalid expiration time\n"));
1104 expire.abs_value_us = expiration_seconds * 1000LL * 1000LL;
1109 _ (
"Failed to parse HELLO message: malformed\n"));
1121 "Failed to parse HELLO message: missing transport plugin\n"));
1129 ctx->counter_total++;
1139 _ (
"Plugin `%s' not found, skipping address\n"),
1147 _ (
"Plugin `%s' does not support URIs yet\n"),
1157 strlen (uri_address) + 1,
1162 _ (
"Failed to parse `%s' as an address for plugin `%s'\n"),
1178 ctx->counter_added++;
1205 if (0 == strncmp (
uri,
1212 else if (0 == strncmp (
uri,
1225 (NULL == exc) ? strlen (pks) : (exc - pks),
1226 (
unsigned char *)
pubkey,
1232 ctx.counter_total = 0;
1233 ctx.counter_added = 0;
1241 "HELLO URI contained %u addresses, added %u addresses\n",
struct GNUNET_MessageHeader * msg
static char * expiration
Credential TTL.
static int ret
Return value of the commandline.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
static int end
Set if we are to shutdown all services (including ARM).
static char * address
GNS address for this phone.
static char * expire
DID Document expiration Date Attribut String.
static struct GNUNET_FS_DownloadContext * dc
static char * pkey
Public key of the zone to look in, in ASCII.
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 ...
static struct GNUNET_TESTBED_Controller * mc
Handle to the master controller.
static char * plugin_name
Name of our plugin.
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
static struct GNUNET_SCHEDULER_Task * t
Main task.
Helper library for handling HELLOs.
Constants for network protocols.
Transport service plugin API.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message,...
int GNUNET_HELLO_get_id(const struct GNUNET_HELLO_Message *hello, struct GNUNET_PeerIdentity *peer)
Get the peer identity from a HELLO message.
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.
uint16_t GNUNET_HELLO_size(const struct GNUNET_HELLO_Message *hello)
Return the size of the given HELLO message.
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?
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...
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...
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.
#define GNUNET_FRIEND_HELLO_URI_PREFIX
Prefix that every FRIEND HELLO URI must start with.
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.
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.
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.
#define GNUNET_HELLO_URI_PREFIX
Prefix that every HELLO URI must start with.
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.
int(* GNUNET_HELLO_AddressIterator)(void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_TIME_Absolute expiration)
Iterator callback to go over all addresses.
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.
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.
#define GNUNET_HELLO_URI_SEP
Separator used in HELLO URI.
int GNUNET_HELLO_address_cmp(const struct GNUNET_HELLO_Address *a1, const struct GNUNET_HELLO_Address *a2)
Compare two addresses.
@ GNUNET_HELLO_ADDRESS_INFO_NONE
No additional information.
#define GNUNET_log(kind,...)
char * GNUNET_CRYPTO_eddsa_public_key_to_string(const struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Convert a public key to a string.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#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_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_strndup(a, length)
Wrapper around GNUNET_xstrndup_.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_MESSAGE_TYPE_HELLO
HELLO message with friend only flag used for communicating peer addresses.
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_max(struct GNUNET_TIME_Absolute t1, struct GNUNET_TIME_Absolute t2)
Return the maximum of two absolute time values.
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_absolute_min(struct GNUNET_TIME_Absolute t1, struct GNUNET_TIME_Absolute t2)
Return the minimum of two absolute time values.
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
#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.
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
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...
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.
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.
static int find_matching(void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_TIME_Absolute expiration)
Helper function for GNUNET_HELLO_equals().
static int get_match_exp(void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_TIME_Absolute expiration)
Store the expiration time of an address that matches the template.
static ssize_t add_address_to_hello(void *cls, size_t max, void *buffer)
We're building a HELLO.
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".
static int find_other_matching(void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_TIME_Absolute expiration)
Check if the given address matches the address we are currently looking for.
static int copy_latest(void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_TIME_Absolute expiration)
Append the address address to the buffer from the merge context IF it is more recent than equivalent ...
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.
Context used in GNUNET_HELLO_iterate_new_addresses() to figure out which addresses are in fact 'new'.
void * it_cls
Closure for it.
const struct GNUNET_HELLO_Message * old_hello
HELLO with known addresses, addresses in this HELLO we must always ignore.
GNUNET_HELLO_AddressIterator it
Function to call on addresses that are indeed new.
struct GNUNET_TIME_Absolute expiration_limit
We should ignore addresses that expire before this time.
Context used for comparing HELLOs in GNUNET_HELLO_equals().
struct GNUNET_TIME_Absolute expiration
Expiration time of address.
struct GNUNET_TIME_Absolute result
Earliest expiration time for which we found a match with a difference in expiration times.
const struct GNUNET_HELLO_Message * ref
HELLO message to compare against.
struct GNUNET_TIME_Absolute expiration_limit
Addresses that expired before this date are ignored for the comparison.
int found
Did we find the address we were looking for?
const struct GNUNET_HELLO_Address * address
Address we are currently looking for.
Closure for get_match_exp().
const struct GNUNET_HELLO_Address * address
Address we are looking for.
struct GNUNET_TIME_Absolute expiration
Set to the expiration of the match if found is GNUNET_YES.
int found
Set to GNUNET_YES if we found the address.
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.
const void * address
Binary representation of the address (plugin-specific).
Context used for building our own URI.
GNUNET_HELLO_TransportPluginsFind plugins_find
Function for finding transport plugins by name.
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.
Context for add_address_to_hello().
unsigned int counter_total
Counter.
int ret
Set to GNUNET_SYSERR to indicate parse errors.
const char * pos
Position in the URI with the next address to parse.
unsigned int counter_added
Counter skipped addresses.
GNUNET_HELLO_TransportPluginsFind plugins_find
Function for finding transport plugins by name.
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.
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
void * cls
Closure for all of the callbacks.
GNUNET_TRANSPORT_AddressToString address_to_string
Function that will be called to convert a binary address to a string (numeric conversion only).
GNUNET_TRANSPORT_StringToAddress string_to_address
Function that will be called to convert a string address to binary (numeric conversion only).
const struct GNUNET_HELLO_Message * other
Either h1 or h2, used when copying to compare against (so we only copy the most recent entry).
size_t max
Number of bytes allocated in buf.
int take_equal
Should we copy addresses with an identical value and expiration time in other, or do we only copy add...
const struct GNUNET_HELLO_Message * h1
First HELLO we are merging.
size_t ret
Current (write) offset in buf.
const struct GNUNET_HELLO_Message * h2
Second HELLO we are merging.
char * buf
Buffer where we copy to.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.