31#include "gnunet_signatures.h"
35#define LOG(kind, ...) GNUNET_log_from (kind, "gnsrecord", __VA_ARGS__)
41#define DEBUG_GNSRECORDS 0
87 for (
unsigned int i = 0; i <
rd_count; i++)
131 return (ssize_t)
ret;
145 for (
unsigned int i = 0; i <
rd_count; i++)
148 "Serializing record %u with flags %d and expiration time %llu\n",
156 if ((off +
sizeof(rec) > dest_size) ||
157 (off +
sizeof(rec) < off))
207 memset (&rec_zero, 0,
sizeof (rec_zero));
210 for (off = 0; (off +
sizeof(rec) <= len) && (off +
sizeof(rec) >= off);)
222 if ((off + ntohs ((uint16_t) rec.
data_size) > len) ||
223 (off + ntohs ((uint16_t) rec.
data_size) < off))
253 for (
unsigned int i = 0; i <
rd_count; i++)
255 if ((off +
sizeof(rec) > len) ||
256 (off +
sizeof(rec) < off))
270 (off +
dest[i].data_size < off))
275 dest[i].data = &src[off];
276 off +=
dest[i].data_size;
277#if GNUNET_EXTRA_LOGGING
293 "Deserialized record %u with flags %d and expiration time %llu\n",
static int ret
Final status code.
static char * data
The data to insert into the dht.
static unsigned int rd_count
Number of records for currently parsed set.
static struct GNUNET_GNSRECORD_Data rd[50]
The record data under a single label.
static size_t data_size
Number of bytes in data.
API that can be used to manipulate GNS record data.
int GNUNET_GNSRECORD_records_deserialize(size_t len, const char *src, unsigned int rd_count, struct GNUNET_GNSRECORD_Data *dest)
Deserialize the given records to the given destination.
ssize_t GNUNET_GNSRECORD_records_serialize(unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, size_t dest_size, char *dest)
Serialize the given records to the given destination buffer.
unsigned int GNUNET_GNSRECORD_records_deserialize_get_size(size_t len, const char *src)
GNUNET_NETWORK_STRUCT_END ssize_t GNUNET_GNSRECORD_records_get_size(unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Calculate how many bytes we will need to serialize the given records.
char * GNUNET_GNSRECORD_value_to_string(uint32_t type, const void *data, size_t data_size)
Convert the binary value data of a record of type type to a human-readable string.
#define GNUNET_NETWORK_STRUCT_BEGIN
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
#define GNUNET_NETWORK_STRUCT_END
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32;.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#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_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.
#define GNUNET_GNSRECORD_TYPE_PKEY
WARNING: This header is generated! In order to add GNS record types, you must register them in GANA,...
#define GNUNET_GNSRECORD_TYPE_EDKEY
GNS zone delegation (EDKEY)
uint32_t record_type
Type of the GNS/DNS record.
size_t data_size
Number of bytes in data.
Internal format of a record in the serialized form.
uint64_t expiration_time
Expiration time for the DNS record; relative or absolute depends on flags, network byte order.
uint32_t record_type
Type of the GNS/DNS record, network byte order.
uint16_t flags
Flags for the record, network byte order.
uint16_t data_size
Number of bytes in 'data', network byte order.