2011-12-21 09:55:05 +00:00
|
|
|
/*
|
2014-01-22 05:21:59 +00:00
|
|
|
Serval DNA Rhizome file distribution
|
2014-11-19 13:31:12 +00:00
|
|
|
Copyright (C) 2010-2014 Serval Project Inc.
|
2011-12-21 09:55:05 +00:00
|
|
|
Copyright (C) 2010 Paul Gardner-Stephen
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2013-12-04 06:44:14 +00:00
|
|
|
#ifndef __SERVAL_DNA__RHIZOME_H
|
|
|
|
#define __SERVAL_DNA__RHIZOME_H
|
2012-12-04 03:42:28 +00:00
|
|
|
|
2012-02-24 06:51:22 +00:00
|
|
|
#include <sqlite3.h>
|
2014-05-23 08:19:00 +00:00
|
|
|
#include "serval_types.h"
|
|
|
|
#include "rhizome_types.h"
|
|
|
|
#include "overlay_address.h"
|
|
|
|
#include "overlay_packet.h"
|
|
|
|
#include "fdqueue.h"
|
|
|
|
#include "os.h"
|
2017-10-09 01:11:44 +00:00
|
|
|
#include "serval_uuid.h"
|
2015-05-25 09:05:10 +00:00
|
|
|
#include "trigger.h"
|
2011-12-18 21:40:02 +00:00
|
|
|
|
2012-08-24 05:56:25 +00:00
|
|
|
#ifndef __RHIZOME_INLINE
|
|
|
|
# if __GNUC__ && !__GNUC_STDC_INLINE__
|
|
|
|
# define __RHIZOME_INLINE extern inline
|
|
|
|
# else
|
|
|
|
# define __RHIZOME_INLINE inline
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2012-12-21 00:23:47 +00:00
|
|
|
// assumed to always be 2^n
|
2012-06-01 08:42:59 +00:00
|
|
|
#define RHIZOME_CRYPT_PAGE_SIZE 4096
|
2012-05-26 04:12:33 +00:00
|
|
|
|
2012-08-09 02:44:32 +00:00
|
|
|
extern time_ms_t rhizome_voice_timeout;
|
2012-05-22 03:35:29 +00:00
|
|
|
|
2013-09-17 02:37:20 +00:00
|
|
|
#define RHIZOME_IDLE_TIMEOUT 20000
|
2012-07-02 03:49:54 +00:00
|
|
|
|
2012-10-02 09:54:35 +00:00
|
|
|
#define RHIZOME_BAR_COMPARE_BYTES 31
|
|
|
|
#define RHIZOME_BAR_TTL_OFFSET 31
|
2012-01-03 06:05:02 +00:00
|
|
|
|
2011-12-18 21:34:31 +00:00
|
|
|
#define MAX_MANIFEST_VARS 256
|
|
|
|
#define MAX_MANIFEST_BYTES 8192
|
2014-11-17 13:11:03 +00:00
|
|
|
#define MAX_MANIFEST_FIELD_LABEL_LEN 80
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
|
|
|
|
typedef struct rhizome_manifest
|
|
|
|
{
|
2011-12-18 21:34:31 +00:00
|
|
|
|
2013-10-30 02:44:26 +00:00
|
|
|
/* CryptoSign key pair for this manifest. The public key is the Bundle ID
|
|
|
|
* (aka Manifest ID).
|
|
|
|
*/
|
2016-09-27 00:58:46 +00:00
|
|
|
sign_keypair_t keypair;
|
2011-12-18 21:34:31 +00:00
|
|
|
|
2016-09-27 00:58:46 +00:00
|
|
|
/* What do we know about keypair.private_key? (ie, bundle secret is known)
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
*/
|
2013-10-30 02:44:26 +00:00
|
|
|
enum { SECRET_UNKNOWN = 0, EXISTING_BUNDLE_ID, NEW_BUNDLE_ID } haveSecret;
|
2011-12-18 21:34:31 +00:00
|
|
|
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
/* Version of the manifest. Typically the number of milliseconds since 1970.
|
|
|
|
* A value of zero (0) means it has not been set yet.
|
|
|
|
*/
|
2013-12-11 00:41:34 +00:00
|
|
|
uint64_t version;
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
|
|
|
|
/* Payload is described by the offset of its tail (number of missing bytes
|
|
|
|
* before the first byte in the payload), its size (number of bytes) and the
|
|
|
|
* hash of its content. Bundle size = tail + filesize.
|
|
|
|
*/
|
2017-10-19 11:43:30 +00:00
|
|
|
uint64_t tail; // only valid if is_journal
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
uint64_t filesize;
|
2017-10-19 11:43:30 +00:00
|
|
|
rhizome_filehash_t filehash; // only valid if filesize != 0 and has_filehash
|
2011-12-18 21:34:31 +00:00
|
|
|
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
/* All the manifest fields in original order (the order affects the manifest
|
|
|
|
* hash which was used to sign the manifest, so the signature can only be
|
|
|
|
* checked if order is preserved).
|
|
|
|
*
|
|
|
|
* TODO: reduce to only unknown fields.
|
|
|
|
*
|
|
|
|
* TODO: store all vars and values as NUL terminated strings within
|
|
|
|
* manifestdata[], not malloc()/free() heap, to reduce memory fragmentation
|
|
|
|
* and allow manifest struct copying without string lifetime issues.
|
|
|
|
*/
|
2013-10-30 03:15:51 +00:00
|
|
|
unsigned short var_count;
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
const char *vars[MAX_MANIFEST_VARS];
|
|
|
|
const char *values[MAX_MANIFEST_VARS];
|
2011-12-18 21:34:31 +00:00
|
|
|
|
2013-10-30 03:15:51 +00:00
|
|
|
/* Parties who have signed this manifest (binary format, malloc(3)).
|
|
|
|
* Recognised signature types:
|
|
|
|
* 0x17 = crypto_sign_edwards25519sha512batch()
|
|
|
|
*/
|
|
|
|
unsigned short sig_count;
|
2011-12-20 21:16:12 +00:00
|
|
|
unsigned char *signatories[MAX_MANIFEST_VARS];
|
2013-10-30 03:15:51 +00:00
|
|
|
uint8_t signatureTypes[MAX_MANIFEST_VARS];
|
|
|
|
|
2014-07-09 19:49:38 +00:00
|
|
|
/* Set to non-NULL if a manifest has been parsed that cannot be fully
|
2013-11-28 07:14:37 +00:00
|
|
|
* understood by this version of Rhizome (probably from a future or a very
|
|
|
|
* old past version of Rhizome). During add (local injection), the manifest
|
|
|
|
* should not be imported. During extract (local decode) a warning or error
|
|
|
|
* message should be logged. Manifests marked as malformed are still
|
|
|
|
* transported, imported and exported normally, as long as their signature is
|
|
|
|
* valid.
|
2013-10-30 03:15:51 +00:00
|
|
|
*/
|
2014-07-09 19:49:38 +00:00
|
|
|
const char *malformed;
|
2013-10-30 03:15:51 +00:00
|
|
|
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
/* Set non-zero after variables have been packed and signature blocks
|
|
|
|
* appended. All fields below may not be valid until the manifest has been
|
|
|
|
* finalised.
|
|
|
|
*/
|
2016-05-24 05:16:46 +00:00
|
|
|
bool_t finalised:1;
|
2013-10-30 03:15:51 +00:00
|
|
|
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
/* Whether the manifest contains a signature that corresponds to the manifest
|
2013-11-28 07:14:37 +00:00
|
|
|
* id (ie public key).
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
*/
|
2016-05-24 05:16:46 +00:00
|
|
|
bool_t selfSigned:1;
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
|
2017-10-19 11:43:30 +00:00
|
|
|
/* Set if the ID field (keypair.public_key) contains a bundle ID.
|
2013-11-28 07:14:37 +00:00
|
|
|
*/
|
2016-05-24 05:16:46 +00:00
|
|
|
bool_t has_id:1;
|
2013-11-28 07:14:37 +00:00
|
|
|
|
2013-12-19 08:43:39 +00:00
|
|
|
/* Set if the filehash field contains a file hash.
|
|
|
|
*/
|
2016-05-24 05:16:46 +00:00
|
|
|
bool_t has_filehash:1;
|
2013-12-19 08:43:39 +00:00
|
|
|
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
/* Set if the tail field is valid, ie, the bundle is a journal.
|
|
|
|
*/
|
2016-05-24 05:16:46 +00:00
|
|
|
bool_t is_journal:1;
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
|
|
|
|
/* Set if the date field is valid, ie, the manifest contains a valid "date"
|
|
|
|
* field.
|
|
|
|
*/
|
2016-05-24 05:16:46 +00:00
|
|
|
bool_t has_date:1;
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
|
|
|
|
/* Set if the bundle_key field is valid, ie, the manifest contains a valid
|
|
|
|
* "BK" field.
|
|
|
|
*/
|
2016-05-24 05:16:46 +00:00
|
|
|
bool_t has_bundle_key:1;
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
|
|
|
|
/* Set if the sender and recipient fields are valid, ie, the manifest
|
|
|
|
* contains a valid "sender"/"recipient" field.
|
|
|
|
*/
|
2016-05-24 05:16:46 +00:00
|
|
|
bool_t has_sender:1;
|
|
|
|
bool_t has_recipient:1;
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
|
2013-11-04 13:17:09 +00:00
|
|
|
/* Local authorship. Useful for dividing bundle lists between "sent" and
|
|
|
|
* "inbox" views.
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
*/
|
2013-11-04 13:17:09 +00:00
|
|
|
enum rhizome_bundle_authorship {
|
2013-11-05 07:28:03 +00:00
|
|
|
ANONYMOUS = 0, // 'author' element is not valid
|
|
|
|
AUTHOR_NOT_CHECKED, // 'author' element is valid but not checked
|
|
|
|
AUTHENTICATION_ERROR, // author check failed, don't try again
|
2013-11-04 13:17:09 +00:00
|
|
|
AUTHOR_UNKNOWN, // author is not a local identity
|
|
|
|
AUTHOR_LOCAL, // author is in keyring (unlocked) but not verified
|
|
|
|
AUTHOR_IMPOSTOR, // author is a local identity but fails verification
|
2016-10-16 00:14:36 +00:00
|
|
|
AUTHOR_AUTHENTIC, // a local identity is the verified author
|
|
|
|
AUTHOR_REMOTE // the author of this bundle has signed it, but isn't in our keyring
|
2013-11-04 13:17:09 +00:00
|
|
|
} authorship;
|
2011-12-18 21:34:31 +00:00
|
|
|
|
2012-05-25 15:20:48 +00:00
|
|
|
/* Whether the paylaod is encrypted or not */
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
enum rhizome_manifest_crypt {
|
|
|
|
PAYLOAD_CRYPT_UNKNOWN = 0,
|
|
|
|
PAYLOAD_CLEAR,
|
|
|
|
PAYLOAD_ENCRYPTED
|
|
|
|
} payloadEncryption;
|
2013-01-03 05:42:24 +00:00
|
|
|
unsigned char payloadKey[RHIZOME_CRYPT_KEY_BYTES];
|
2016-04-12 06:13:56 +00:00
|
|
|
unsigned char payloadNonce[crypto_box_NONCEBYTES];
|
2011-12-18 21:34:31 +00:00
|
|
|
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
/* From the "date" field, if present. The number of milliseconds since 1970
|
|
|
|
* when the bundle was last modified.
|
|
|
|
*/
|
|
|
|
time_ms_t date;
|
2011-12-20 05:18:26 +00:00
|
|
|
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
/* From the "service" field, which should always be present.
|
|
|
|
*/
|
|
|
|
const char *service;
|
|
|
|
|
|
|
|
/* From the optional "name" field. NULL if there is no "name" field in the
|
|
|
|
* manifest.
|
|
|
|
*/
|
|
|
|
const char *name;
|
2011-12-20 02:54:09 +00:00
|
|
|
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
/* Bundle Key "BK" field from the manifest.
|
|
|
|
*/
|
|
|
|
rhizome_bk_t bundle_key;
|
|
|
|
|
|
|
|
/* Sender and recipient fields, if present in the manifest.
|
|
|
|
*/
|
|
|
|
sid_t sender;
|
|
|
|
sid_t recipient;
|
|
|
|
|
2013-11-11 07:43:38 +00:00
|
|
|
/* Local data, not encapsulated in the bundle. The ROWID of the SQLite
|
|
|
|
* MANIFESTS table row in which this manifest is stored. Zero if the
|
|
|
|
* manifest has not been stored yet.
|
|
|
|
*/
|
|
|
|
uint64_t rowid;
|
|
|
|
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
/* Local data, not encapsulated in the bundle. The system time of the most
|
2013-11-05 07:28:03 +00:00
|
|
|
* recent INSERT or UPDATE of the manifest into the store. Zero if the manifest
|
|
|
|
* has not been stored yet.
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
*/
|
|
|
|
time_ms_t inserttime;
|
2011-12-20 02:54:09 +00:00
|
|
|
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
/* Local data, not encapsulated in the bundle. The author of the manifest.
|
|
|
|
* A reference to a local keyring entry. Manifests not authored locally will
|
|
|
|
* have an ANY author (all zeros).
|
2012-10-09 07:13:34 +00:00
|
|
|
*/
|
2013-10-09 08:24:21 +00:00
|
|
|
sid_t author;
|
2016-05-31 03:20:32 +00:00
|
|
|
const struct keyring_identity *author_identity;
|
2012-10-09 07:13:34 +00:00
|
|
|
|
2013-11-28 07:14:37 +00:00
|
|
|
size_t manifest_body_bytes;
|
|
|
|
size_t manifest_all_bytes;
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
unsigned char manifestdata[MAX_MANIFEST_BYTES];
|
2016-03-07 04:04:53 +00:00
|
|
|
rhizome_filehash_t manifesthash;
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
|
2011-12-18 21:34:31 +00:00
|
|
|
} rhizome_manifest;
|
|
|
|
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
/* These setter functions (methods) are needed because the relevant attributes
|
|
|
|
* are stored in two places: in the vars[] array and in a dedicated struct
|
|
|
|
* element.
|
|
|
|
*
|
|
|
|
* TODO: refactor to remove the redundancy, possibly removing these setter
|
|
|
|
* functions as well.
|
|
|
|
*
|
|
|
|
* @author Andrew Bettison <andrew@servalproject.com>
|
|
|
|
*/
|
2013-11-05 07:28:03 +00:00
|
|
|
#define rhizome_manifest_set_id(m,v) _rhizome_manifest_set_id(__WHENCE__,(m),(v))
|
|
|
|
#define rhizome_manifest_set_version(m,v) _rhizome_manifest_set_version(__WHENCE__,(m),(v))
|
2015-03-18 16:51:27 +00:00
|
|
|
#define rhizome_manifest_del_version(m) _rhizome_manifest_del_version(__WHENCE__,(m))
|
2013-11-05 07:28:03 +00:00
|
|
|
#define rhizome_manifest_set_filesize(m,v) _rhizome_manifest_set_filesize(__WHENCE__,(m),(v))
|
2015-03-18 16:51:27 +00:00
|
|
|
#define rhizome_manifest_del_filesize(m) _rhizome_manifest_del_filesize(__WHENCE__,(m))
|
2013-11-05 07:28:03 +00:00
|
|
|
#define rhizome_manifest_set_filehash(m,v) _rhizome_manifest_set_filehash(__WHENCE__,(m),(v))
|
2015-03-18 16:51:27 +00:00
|
|
|
#define rhizome_manifest_del_filehash(m) _rhizome_manifest_del_filehash(__WHENCE__,(m))
|
2013-11-05 07:28:03 +00:00
|
|
|
#define rhizome_manifest_set_tail(m,v) _rhizome_manifest_set_tail(__WHENCE__,(m),(v))
|
|
|
|
#define rhizome_manifest_set_bundle_key(m,v) _rhizome_manifest_set_bundle_key(__WHENCE__,(m),(v))
|
|
|
|
#define rhizome_manifest_del_bundle_key(m) _rhizome_manifest_del_bundle_key(__WHENCE__,(m))
|
|
|
|
#define rhizome_manifest_set_service(m,v) _rhizome_manifest_set_service(__WHENCE__,(m),(v))
|
|
|
|
#define rhizome_manifest_del_service(m) _rhizome_manifest_del_service(__WHENCE__,(m))
|
|
|
|
#define rhizome_manifest_set_name(m,v) _rhizome_manifest_set_name(__WHENCE__,(m),(v))
|
|
|
|
#define rhizome_manifest_del_name(m) _rhizome_manifest_del_name(__WHENCE__,(m))
|
|
|
|
#define rhizome_manifest_set_date(m,v) _rhizome_manifest_set_date(__WHENCE__,(m),(v))
|
|
|
|
#define rhizome_manifest_del_date(m) _rhizome_manifest_del_date(__WHENCE__,(m))
|
|
|
|
#define rhizome_manifest_set_sender(m,v) _rhizome_manifest_set_sender(__WHENCE__,(m),(v))
|
|
|
|
#define rhizome_manifest_del_sender(m) _rhizome_manifest_del_sender(__WHENCE__,(m))
|
|
|
|
#define rhizome_manifest_set_recipient(m,v) _rhizome_manifest_set_recipient(__WHENCE__,(m),(v))
|
|
|
|
#define rhizome_manifest_del_recipient(m) _rhizome_manifest_del_recipient(__WHENCE__,(m))
|
|
|
|
#define rhizome_manifest_set_crypt(m,v) _rhizome_manifest_set_crypt(__WHENCE__,(m),(v))
|
2013-11-11 07:43:38 +00:00
|
|
|
#define rhizome_manifest_set_rowid(m,v) _rhizome_manifest_set_rowid(__WHENCE__,(m),(v))
|
2013-11-05 07:28:03 +00:00
|
|
|
#define rhizome_manifest_set_inserttime(m,v) _rhizome_manifest_set_inserttime(__WHENCE__,(m),(v))
|
2016-05-31 03:20:32 +00:00
|
|
|
#define rhizome_manifest_set_author(m,v) _rhizome_manifest_set_author(__WHENCE__,(m),NULL,(v))
|
|
|
|
#define rhizome_manifest_set_author_identity(m,v) _rhizome_manifest_set_author(__WHENCE__,(m),(v),NULL)
|
2013-11-05 07:28:03 +00:00
|
|
|
#define rhizome_manifest_del_author(m) _rhizome_manifest_del_author(__WHENCE__,(m))
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
|
|
|
|
void _rhizome_manifest_set_id(struct __sourceloc, rhizome_manifest *, const rhizome_bid_t *);
|
2013-12-11 00:41:34 +00:00
|
|
|
void _rhizome_manifest_set_version(struct __sourceloc, rhizome_manifest *, uint64_t);
|
2015-03-18 16:51:27 +00:00
|
|
|
void _rhizome_manifest_del_version(struct __sourceloc, rhizome_manifest *);
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
void _rhizome_manifest_set_filesize(struct __sourceloc, rhizome_manifest *, uint64_t);
|
2015-03-18 16:51:27 +00:00
|
|
|
void _rhizome_manifest_del_filesize(struct __sourceloc, rhizome_manifest *);
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
void _rhizome_manifest_set_filehash(struct __sourceloc, rhizome_manifest *, const rhizome_filehash_t *);
|
2015-03-18 16:51:27 +00:00
|
|
|
void _rhizome_manifest_del_filehash(struct __sourceloc, rhizome_manifest *);
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
void _rhizome_manifest_set_tail(struct __sourceloc, rhizome_manifest *, uint64_t);
|
|
|
|
void _rhizome_manifest_set_bundle_key(struct __sourceloc, rhizome_manifest *, const rhizome_bk_t *);
|
2013-11-05 07:28:03 +00:00
|
|
|
void _rhizome_manifest_del_bundle_key(struct __sourceloc, rhizome_manifest *);
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
void _rhizome_manifest_set_service(struct __sourceloc, rhizome_manifest *, const char *);
|
2013-11-05 07:28:03 +00:00
|
|
|
void _rhizome_manifest_del_service(struct __sourceloc, rhizome_manifest *);
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
void _rhizome_manifest_set_name(struct __sourceloc, rhizome_manifest *, const char *);
|
2013-11-05 07:28:03 +00:00
|
|
|
void _rhizome_manifest_del_name(struct __sourceloc, rhizome_manifest *);
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
void _rhizome_manifest_set_date(struct __sourceloc, rhizome_manifest *, time_ms_t);
|
2013-11-05 07:28:03 +00:00
|
|
|
void _rhizome_manifest_del_date(struct __sourceloc, rhizome_manifest *);
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
void _rhizome_manifest_set_sender(struct __sourceloc, rhizome_manifest *, const sid_t *);
|
2013-11-05 07:28:03 +00:00
|
|
|
void _rhizome_manifest_del_sender(struct __sourceloc, rhizome_manifest *);
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
void _rhizome_manifest_set_recipient(struct __sourceloc, rhizome_manifest *, const sid_t *);
|
2013-11-05 07:28:03 +00:00
|
|
|
void _rhizome_manifest_del_recipient(struct __sourceloc, rhizome_manifest *);
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
void _rhizome_manifest_set_crypt(struct __sourceloc, rhizome_manifest *, enum rhizome_manifest_crypt);
|
2013-11-11 07:43:38 +00:00
|
|
|
void _rhizome_manifest_set_rowid(struct __sourceloc, rhizome_manifest *, uint64_t);
|
2013-11-05 07:28:03 +00:00
|
|
|
void _rhizome_manifest_set_inserttime(struct __sourceloc, rhizome_manifest *, time_ms_t);
|
2016-05-31 03:20:32 +00:00
|
|
|
void _rhizome_manifest_set_author(struct __sourceloc, rhizome_manifest *, const struct keyring_identity *, const sid_t *);
|
2013-11-05 07:28:03 +00:00
|
|
|
void _rhizome_manifest_del_author(struct __sourceloc, rhizome_manifest *);
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
|
2015-03-23 07:08:46 +00:00
|
|
|
#define rhizome_manifest_overwrite(dstm,srcm) _rhizome_manifest_overwrite(__WHENCE__,(dstm),(srcm))
|
|
|
|
|
|
|
|
int _rhizome_manifest_overwrite(struct __sourceloc, rhizome_manifest *m, const rhizome_manifest *srcm);
|
|
|
|
|
2014-11-17 13:11:03 +00:00
|
|
|
enum rhizome_manifest_parse_status {
|
|
|
|
RHIZOME_MANIFEST_ERROR = -1, // unrecoverable error while constructing manifest
|
|
|
|
RHIZOME_MANIFEST_OK = 0, // field parsed ok; manifest updated
|
|
|
|
RHIZOME_MANIFEST_SYNTAX_ERROR = 1, // field label violates syntax
|
|
|
|
RHIZOME_MANIFEST_DUPLICATE_FIELD = 2, // field is already set in manifest
|
|
|
|
RHIZOME_MANIFEST_INVALID = 3, // core field value does not parse
|
|
|
|
RHIZOME_MANIFEST_MALFORMED = 4, // non-core field value does not parse
|
|
|
|
RHIZOME_MANIFEST_OVERFLOW = 5, // maximum field count exceeded
|
|
|
|
};
|
|
|
|
|
2015-03-23 07:08:46 +00:00
|
|
|
/* This structure represents a manifest field assignment as received by the API
|
|
|
|
* operations "add file" or "journal append" or any other operation that takes an
|
|
|
|
* existing manifest and modifies it to produce a new one.
|
|
|
|
*
|
|
|
|
* The 'label' and 'value' strings are pointer-length instead of NUL terminated,
|
|
|
|
* to allow them to refer directly to fragments of an existing, larger text
|
|
|
|
* without requiring the caller to allocate new strings to hold them.
|
|
|
|
*/
|
|
|
|
struct rhizome_manifest_field_assignment {
|
|
|
|
const char *label;
|
|
|
|
size_t labellen;
|
|
|
|
const char *value;
|
|
|
|
size_t valuelen;
|
|
|
|
};
|
|
|
|
|
2014-11-19 02:47:40 +00:00
|
|
|
int rhizome_manifest_field_label_is_valid(const char *field_label, size_t field_label_len);
|
|
|
|
int rhizome_manifest_field_value_is_valid(const char *field_value, size_t field_value_len);
|
2014-11-17 13:11:03 +00:00
|
|
|
enum rhizome_manifest_parse_status
|
|
|
|
rhizome_manifest_parse_field(rhizome_manifest *m,
|
|
|
|
const char *field_label, size_t field_label_len,
|
|
|
|
const char *field_value, size_t field_value_len);
|
|
|
|
int rhizome_manifest_remove_field(rhizome_manifest *, const char *field_label, size_t field_label_len);
|
|
|
|
|
2012-05-20 06:37:22 +00:00
|
|
|
/* Supported service identifiers. These go in the 'service' field of every
|
|
|
|
* manifest, and indicate which application must be used to process the bundle
|
|
|
|
* after it is received by Rhizome.
|
|
|
|
*/
|
|
|
|
#define RHIZOME_SERVICE_FILE "file"
|
|
|
|
#define RHIZOME_SERVICE_MESHMS "MeshMS1"
|
2013-08-01 02:07:35 +00:00
|
|
|
#define RHIZOME_SERVICE_MESHMS2 "MeshMS2"
|
2016-08-16 05:34:15 +00:00
|
|
|
#define RHIZOME_SERVICE_MESHMB "MeshMB1"
|
2017-03-20 04:51:28 +00:00
|
|
|
#define RHIZOME_SERVICE_PRIVATE "private"
|
2012-05-20 06:37:22 +00:00
|
|
|
|
2013-07-13 05:17:06 +00:00
|
|
|
extern int64_t rhizome_space;
|
2012-07-11 07:20:50 +00:00
|
|
|
|
2013-07-13 05:17:06 +00:00
|
|
|
int log2ll(uint64_t x);
|
2012-07-11 07:20:50 +00:00
|
|
|
int rhizome_configure();
|
2012-10-24 04:43:50 +00:00
|
|
|
int rhizome_enabled();
|
|
|
|
int rhizome_fetch_delay_ms();
|
2012-05-24 01:58:32 +00:00
|
|
|
|
2014-03-07 06:25:38 +00:00
|
|
|
#define RHIZOME_BLOB_SUBDIR "blob"
|
2016-05-24 05:16:46 +00:00
|
|
|
#define RHIZOME_HASH_SUBDIR "hash"
|
2011-12-18 21:34:31 +00:00
|
|
|
|
2015-05-25 02:16:37 +00:00
|
|
|
extern __thread sqlite3 *rhizome_db;
|
2016-11-07 03:46:51 +00:00
|
|
|
extern serval_uuid_t rhizome_db_uuid;
|
2011-12-18 21:34:31 +00:00
|
|
|
|
2011-12-20 00:55:52 +00:00
|
|
|
int rhizome_opendb();
|
2012-10-29 01:25:14 +00:00
|
|
|
int rhizome_close_db();
|
2013-06-14 02:28:19 +00:00
|
|
|
void verify_bundles();
|
2012-07-12 07:09:01 +00:00
|
|
|
|
2012-08-23 08:13:35 +00:00
|
|
|
typedef struct sqlite_retry_state {
|
|
|
|
unsigned int limit; // do not retry once elapsed >= limit
|
|
|
|
unsigned int sleep; // number of milliseconds to sleep between retries
|
|
|
|
unsigned int elapsed; // the total number of milliseconds elapsed doing retries
|
2012-08-24 05:56:25 +00:00
|
|
|
time_ms_t start; // the gettime_ms() value just after the current SQL query first returned BUSY
|
|
|
|
unsigned int busytries; // the number of times the current SQL query has returned BUSY
|
2012-08-23 08:13:35 +00:00
|
|
|
}
|
|
|
|
sqlite_retry_state;
|
|
|
|
|
|
|
|
sqlite_retry_state sqlite_retry_state_init(int serverLimit, int serverSleep, int otherLimit, int otherSleep);
|
|
|
|
|
|
|
|
#define SQLITE_RETRY_STATE_DEFAULT sqlite_retry_state_init(-1,-1,-1,-1)
|
|
|
|
|
2014-06-19 04:28:01 +00:00
|
|
|
struct rhizome_cleanup_report {
|
|
|
|
unsigned deleted_stale_incoming_files;
|
|
|
|
unsigned deleted_expired_files;
|
|
|
|
unsigned deleted_orphan_files;
|
|
|
|
unsigned deleted_orphan_fileblobs;
|
|
|
|
unsigned deleted_orphan_manifests;
|
|
|
|
};
|
|
|
|
|
|
|
|
int rhizome_cleanup(struct rhizome_cleanup_report *report);
|
|
|
|
int rhizome_store_cleanup(struct rhizome_cleanup_report *report);
|
|
|
|
void rhizome_vacuum_db(sqlite_retry_state *retry);
|
|
|
|
int rhizome_manifest_createid(rhizome_manifest *m);
|
2016-11-14 05:55:51 +00:00
|
|
|
struct rhizome_bundle_result rhizome_private_bundle(rhizome_manifest *m, const sign_keypair_t *keypair);
|
2015-03-23 07:01:06 +00:00
|
|
|
void rhizome_new_bundle_from_secret(rhizome_manifest *m, const rhizome_bk_t *bsk);
|
2014-06-19 04:28:01 +00:00
|
|
|
|
2013-11-28 07:14:37 +00:00
|
|
|
struct rhizome_manifest_summary {
|
|
|
|
rhizome_bid_t bid;
|
2013-12-11 00:41:34 +00:00
|
|
|
uint64_t version;
|
2013-11-28 07:14:37 +00:00
|
|
|
size_t body_len;
|
|
|
|
};
|
|
|
|
|
|
|
|
int rhizome_manifest_inspect(const char *buf, size_t len, struct rhizome_manifest_summary *summ);
|
|
|
|
|
2013-12-19 08:43:39 +00:00
|
|
|
enum rhizome_bundle_status {
|
|
|
|
RHIZOME_BUNDLE_STATUS_ERROR = -1,
|
|
|
|
RHIZOME_BUNDLE_STATUS_NEW = 0, // bundle is newer than store
|
|
|
|
RHIZOME_BUNDLE_STATUS_SAME = 1, // same version already in store
|
|
|
|
RHIZOME_BUNDLE_STATUS_DUPLICATE = 2, // equivalent bundle already in store
|
|
|
|
RHIZOME_BUNDLE_STATUS_OLD = 3, // newer version already in store
|
|
|
|
RHIZOME_BUNDLE_STATUS_INVALID = 4, // manifest is invalid
|
|
|
|
RHIZOME_BUNDLE_STATUS_FAKE = 5, // manifest signature not valid
|
|
|
|
RHIZOME_BUNDLE_STATUS_INCONSISTENT = 6, // manifest filesize/filehash does not match supplied payload
|
2014-07-02 07:46:19 +00:00
|
|
|
RHIZOME_BUNDLE_STATUS_NO_ROOM = 7, // doesn't fit; store may contain more important bundles
|
|
|
|
RHIZOME_BUNDLE_STATUS_READONLY = 8, // cannot modify manifest; secret unknown
|
2014-09-08 07:44:55 +00:00
|
|
|
RHIZOME_BUNDLE_STATUS_BUSY = 9, // the database is currently busy
|
2015-12-07 11:30:52 +00:00
|
|
|
RHIZOME_BUNDLE_STATUS_MANIFEST_TOO_BIG = 10, // manifest + signature exceeds size limit
|
2013-12-19 08:43:39 +00:00
|
|
|
};
|
|
|
|
|
2015-11-16 13:48:21 +00:00
|
|
|
// Useful for initialising a variable then checking later that it was set to a
|
|
|
|
// valid value (typically FATAL if not).
|
2014-07-02 07:46:19 +00:00
|
|
|
#define INVALID_RHIZOME_BUNDLE_STATUS ((enum rhizome_bundle_status)-2)
|
|
|
|
|
|
|
|
const char *rhizome_bundle_status_message(enum rhizome_bundle_status);
|
2015-03-30 07:45:41 +00:00
|
|
|
const char *rhizome_bundle_status_message_nonnull(enum rhizome_bundle_status);
|
2014-07-02 07:46:19 +00:00
|
|
|
|
2015-11-30 13:53:15 +00:00
|
|
|
// Encapsulate a status enum value and an optional text message to assist with
|
|
|
|
// diagnostics. Useful as a return value from functions that can fail in all
|
|
|
|
// sorts of ways.
|
|
|
|
struct rhizome_bundle_result {
|
|
|
|
enum rhizome_bundle_status status;
|
|
|
|
const char *message;
|
2016-10-31 04:51:22 +00:00
|
|
|
void (*release)(void *); // call r.release(r.message) before destroying r
|
2015-11-30 13:53:15 +00:00
|
|
|
};
|
|
|
|
|
2016-10-31 04:51:22 +00:00
|
|
|
#define INVALID_RHIZOME_BUNDLE_RESULT ((struct rhizome_bundle_result){ .status = INVALID_RHIZOME_BUNDLE_STATUS, .message = NULL, .release = NULL })
|
2015-11-30 13:53:15 +00:00
|
|
|
|
|
|
|
// Call this before discarding a struct rhizome_bundle_result.
|
|
|
|
void rhizome_bundle_result_free(struct rhizome_bundle_result *);
|
|
|
|
|
|
|
|
// Convenience functions for constructing a struct rhizome_bundle_result and
|
|
|
|
// logging errors and debug messages in the process.
|
|
|
|
struct rhizome_bundle_result _rhizome_bundle_result(struct __sourceloc, enum rhizome_bundle_status);
|
|
|
|
struct rhizome_bundle_result _rhizome_bundle_result_static(struct __sourceloc, enum rhizome_bundle_status, const char *);
|
|
|
|
struct rhizome_bundle_result _rhizome_bundle_result_strdup(struct __sourceloc, enum rhizome_bundle_status, const char *);
|
|
|
|
struct rhizome_bundle_result _rhizome_bundle_result_sprintf(struct __sourceloc, enum rhizome_bundle_status, const char *fmt, ...);
|
|
|
|
|
|
|
|
#define rhizome_bundle_result(status) _rhizome_bundle_result(__WHENCE__, status)
|
2015-12-07 11:30:52 +00:00
|
|
|
#define rhizome_bundle_result_static(status, str) _rhizome_bundle_result_static(__WHENCE__, status, str)
|
|
|
|
#define rhizome_bundle_result_strdup(status, str) _rhizome_bundle_result_strdup(__WHENCE__, status, str)
|
2015-11-30 13:53:15 +00:00
|
|
|
#define rhizome_bundle_result_sprintf(status, fmt, ...) _rhizome_bundle_result_sprintf(__WHENCE__, status, fmt, ## __VA_ARGS__);
|
|
|
|
|
|
|
|
// Functions for extracting information from a struct rhizome_bundle_result.
|
|
|
|
const char *rhizome_bundle_result_message(struct rhizome_bundle_result); // NULL only if invalid
|
|
|
|
const char *rhizome_bundle_result_message_nonnull(struct rhizome_bundle_result);
|
|
|
|
|
|
|
|
// Function to assist logging struct rhizome_bundle_result.
|
|
|
|
#define alloca_rhizome_bundle_result(result) strbuf_str(strbuf_append_rhizome_bundle_result(strbuf_alloca(50 + (result.message ? strlen(result.message) : 0)), result))
|
|
|
|
strbuf strbuf_append_rhizome_bundle_result(strbuf, struct rhizome_bundle_result);
|
|
|
|
|
2013-12-27 18:56:22 +00:00
|
|
|
enum rhizome_payload_status {
|
|
|
|
RHIZOME_PAYLOAD_STATUS_ERROR = -1,
|
|
|
|
RHIZOME_PAYLOAD_STATUS_EMPTY = 0, // payload is empty (zero length)
|
2014-07-02 07:46:19 +00:00
|
|
|
RHIZOME_PAYLOAD_STATUS_NEW = 1, // payload is not yet in store (added)
|
2013-12-27 18:56:22 +00:00
|
|
|
RHIZOME_PAYLOAD_STATUS_STORED = 2, // payload is already in store
|
|
|
|
RHIZOME_PAYLOAD_STATUS_WRONG_SIZE = 3, // payload's size does not match manifest
|
|
|
|
RHIZOME_PAYLOAD_STATUS_WRONG_HASH = 4, // payload's hash does not match manifest
|
|
|
|
RHIZOME_PAYLOAD_STATUS_CRYPTO_FAIL = 5, // cannot encrypt/decrypt (payload key unknown)
|
2014-06-18 07:55:15 +00:00
|
|
|
RHIZOME_PAYLOAD_STATUS_TOO_BIG = 6, // payload will never fit in our store
|
2014-07-02 07:46:19 +00:00
|
|
|
RHIZOME_PAYLOAD_STATUS_EVICTED = 7, // other payloads in our store are more important
|
2017-02-27 05:15:24 +00:00
|
|
|
RHIZOME_PAYLOAD_STATUS_BUSY = 8, // storage is currently busy, you may try again at a later time
|
2013-12-27 18:56:22 +00:00
|
|
|
};
|
|
|
|
|
2015-11-16 13:48:21 +00:00
|
|
|
// Useful for initialising a variable then checking later that it was set to a
|
|
|
|
// valid value (typically FATAL if not).
|
2014-07-14 06:31:10 +00:00
|
|
|
#define INVALID_RHIZOME_PAYLOAD_STATUS ((enum rhizome_payload_status)-2)
|
2014-07-02 07:46:19 +00:00
|
|
|
|
|
|
|
const char *rhizome_payload_status_message(enum rhizome_payload_status);
|
2015-03-30 07:45:41 +00:00
|
|
|
const char *rhizome_payload_status_message_nonnull(enum rhizome_payload_status);
|
2013-12-27 18:56:22 +00:00
|
|
|
|
2013-01-11 03:49:26 +00:00
|
|
|
int rhizome_write_manifest_file(rhizome_manifest *m, const char *filename, char append);
|
2013-12-19 08:37:14 +00:00
|
|
|
int rhizome_read_manifest_from_file(rhizome_manifest *m, const char *filename);
|
2013-11-28 07:14:37 +00:00
|
|
|
int rhizome_manifest_validate(rhizome_manifest *m);
|
2014-07-09 19:49:38 +00:00
|
|
|
const char *rhizome_manifest_validate_reason(rhizome_manifest *m);
|
2013-12-19 08:37:14 +00:00
|
|
|
int rhizome_manifest_parse(rhizome_manifest *m);
|
|
|
|
int rhizome_manifest_verify(rhizome_manifest *m);
|
|
|
|
|
2014-03-07 06:25:38 +00:00
|
|
|
void _rhizome_manifest_free(struct __sourceloc, rhizome_manifest *m);
|
2012-10-16 06:16:52 +00:00
|
|
|
#define rhizome_manifest_free(m) _rhizome_manifest_free(__WHENCE__,m)
|
2014-03-07 06:25:38 +00:00
|
|
|
rhizome_manifest *_rhizome_new_manifest(struct __sourceloc);
|
2012-10-16 06:16:52 +00:00
|
|
|
#define rhizome_new_manifest() _rhizome_new_manifest(__WHENCE__)
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
|
2012-05-26 04:19:13 +00:00
|
|
|
int rhizome_store_file(rhizome_manifest *m,const unsigned char *key);
|
2015-03-23 07:08:46 +00:00
|
|
|
|
2016-10-12 03:04:03 +00:00
|
|
|
int rhizome_add_field_assignment(struct rhizome_manifest_field_assignment *field, const char *arg, size_t arglen);
|
2016-08-24 07:03:39 +00:00
|
|
|
int rhizome_parse_field_assignments(struct rhizome_manifest_field_assignment *fields, unsigned argc, const char *const *args);
|
|
|
|
struct rhizome_bundle_result rhizome_apply_assignments(rhizome_manifest *m,
|
|
|
|
unsigned nassignments, const struct rhizome_manifest_field_assignment *assignments);
|
|
|
|
|
2015-11-30 13:53:15 +00:00
|
|
|
struct rhizome_bundle_result rhizome_manifest_add_file(int appending,
|
|
|
|
rhizome_manifest *m,
|
|
|
|
rhizome_manifest **mout,
|
|
|
|
const rhizome_bid_t *bid,
|
|
|
|
const rhizome_bk_t *bsk,
|
|
|
|
const sid_t *author,
|
|
|
|
const char *file_path,
|
|
|
|
unsigned nassignments,
|
|
|
|
const struct rhizome_manifest_field_assignment *assignments);
|
2016-03-30 05:02:50 +00:00
|
|
|
int rhizome_bundle_import_files(rhizome_manifest *m, rhizome_manifest **m_out, const char *manifest_path, const char *filepath, int zip_files);
|
2013-11-05 07:28:03 +00:00
|
|
|
|
2013-12-30 05:28:45 +00:00
|
|
|
int rhizome_manifest_set_name_from_path(rhizome_manifest *m, const char *filepath);
|
2016-05-31 03:20:32 +00:00
|
|
|
struct rhizome_bundle_result rhizome_fill_manifest(rhizome_manifest *m, const char *filepath);
|
2013-11-05 07:28:03 +00:00
|
|
|
|
|
|
|
int rhizome_apply_bundle_secret(rhizome_manifest *, const rhizome_bk_t *);
|
|
|
|
int rhizome_manifest_add_bundle_key(rhizome_manifest *);
|
|
|
|
|
2013-11-04 13:17:09 +00:00
|
|
|
int rhizome_lookup_author(rhizome_manifest *m);
|
2013-11-05 07:28:03 +00:00
|
|
|
void rhizome_authenticate_author(rhizome_manifest *m);
|
2012-05-25 15:20:48 +00:00
|
|
|
|
2015-12-07 11:30:52 +00:00
|
|
|
struct rhizome_bundle_result rhizome_manifest_finalise(rhizome_manifest *m, rhizome_manifest **m_out, int deduplicate);
|
2013-12-19 08:43:39 +00:00
|
|
|
enum rhizome_bundle_status rhizome_manifest_check_stored(rhizome_manifest *m, rhizome_manifest **m_out);
|
2015-12-07 11:30:52 +00:00
|
|
|
enum rhizome_bundle_status rhizome_add_manifest_to_store(rhizome_manifest *m_in, rhizome_manifest **m_out);
|
2012-05-25 15:20:48 +00:00
|
|
|
|
2012-05-23 06:34:00 +00:00
|
|
|
void rhizome_bytes_to_hex_upper(unsigned const char *in, char *out, int byteCount);
|
2012-05-15 07:54:25 +00:00
|
|
|
int rhizome_find_privatekey(rhizome_manifest *m);
|
2012-08-23 08:13:35 +00:00
|
|
|
|
2012-08-24 05:56:25 +00:00
|
|
|
__RHIZOME_INLINE int sqlite_code_ok(int code)
|
|
|
|
{
|
2014-09-08 07:44:55 +00:00
|
|
|
return code == SQLITE_OK || code == SQLITE_DONE || code == SQLITE_ROW;
|
2012-08-24 05:56:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
__RHIZOME_INLINE int sqlite_code_busy(int code)
|
|
|
|
{
|
|
|
|
return code == SQLITE_BUSY || code == SQLITE_LOCKED;
|
|
|
|
}
|
|
|
|
|
2012-12-11 05:29:46 +00:00
|
|
|
int (*sqlite_set_tracefunc(int (*newfunc)()))();
|
|
|
|
int is_debug_rhizome();
|
|
|
|
int is_debug_rhizome_ads();
|
2012-10-10 02:52:30 +00:00
|
|
|
|
2013-10-02 15:46:10 +00:00
|
|
|
enum sqlbind_type {
|
2013-10-10 07:53:06 +00:00
|
|
|
INT = 1, // int value
|
|
|
|
INT_TOSTR, // int value
|
|
|
|
UINT_TOSTR, // unsigned value
|
|
|
|
INT64, // int64_t value
|
|
|
|
INT64_TOSTR, // int64_t value
|
|
|
|
UINT64_TOSTR, // uint64_t value
|
|
|
|
TEXT, // const char *text,
|
|
|
|
TEXT_LEN, // const char *text, int bytes
|
|
|
|
STATIC_TEXT, // const char *text,
|
|
|
|
STATIC_TEXT_LEN, // const char *text, int bytes
|
|
|
|
STATIC_BLOB, // const void *blob, int bytes
|
|
|
|
ZEROBLOB, // int bytes
|
|
|
|
SID_T, // const sid_t *sidp
|
|
|
|
RHIZOME_BID_T, // const rhizome_bid_t *bidp
|
2014-06-16 04:51:42 +00:00
|
|
|
RHIZOME_BAR_T, // const rhizome_bar_t *barp
|
2013-10-10 07:53:06 +00:00
|
|
|
RHIZOME_FILEHASH_T, // const rhizome_filehash_t *hashp
|
|
|
|
TOHEX, // const unsigned char *binary, unsigned bytes
|
|
|
|
TEXT_TOUPPER, // const char *text,
|
|
|
|
TEXT_LEN_TOUPPER, // const char *text, unsigned bytes
|
2014-02-17 02:56:03 +00:00
|
|
|
SERVAL_UUID_T, // const serval_uuid_t *uuidp
|
2016-11-07 03:46:51 +00:00
|
|
|
NUL = 1 << 8, // NUL (no arg) ; NUL|INT, ...
|
|
|
|
INDEX = 1 << 9, // INDEX|INT, int index, ...
|
|
|
|
NAMED = 1 << 10, // NAMED|INT, const char *label, ...
|
|
|
|
END = 1 << 11,
|
2013-10-02 15:46:10 +00:00
|
|
|
};
|
|
|
|
|
2013-10-03 05:45:30 +00:00
|
|
|
sqlite3_stmt *_sqlite_prepare(struct __sourceloc, int log_level, sqlite_retry_state *retry, const char *sqltext);
|
2013-10-02 15:46:10 +00:00
|
|
|
int _sqlite_bind(struct __sourceloc __whence, int log_level, sqlite_retry_state *retry, sqlite3_stmt *statement, ...);
|
|
|
|
int _sqlite_vbind(struct __sourceloc __whence, int log_level, sqlite_retry_state *retry, sqlite3_stmt *statement, va_list ap);
|
2013-10-03 05:45:30 +00:00
|
|
|
sqlite3_stmt *_sqlite_prepare_bind(struct __sourceloc, int log_level, sqlite_retry_state *retry, const char *sqltext, ...);
|
2013-02-20 04:14:29 +00:00
|
|
|
int _sqlite_retry(struct __sourceloc, sqlite_retry_state *retry, const char *action);
|
|
|
|
void _sqlite_retry_done(struct __sourceloc, sqlite_retry_state *retry, const char *action);
|
2013-10-03 05:45:30 +00:00
|
|
|
int _sqlite_step(struct __sourceloc, int log_level, sqlite_retry_state *retry, sqlite3_stmt *statement);
|
2017-03-06 05:26:58 +00:00
|
|
|
int _sqlite_exec_code(struct __sourceloc __whence, int log_level, sqlite_retry_state *retry, sqlite3_stmt *statement, int *rowcount);
|
2014-06-18 07:55:15 +00:00
|
|
|
int _sqlite_exec(struct __sourceloc __whence, int log_level, sqlite_retry_state *retry, sqlite3_stmt *statement);
|
2013-10-03 05:45:30 +00:00
|
|
|
int _sqlite_exec_void(struct __sourceloc, int log_level, const char *sqltext, ...);
|
|
|
|
int _sqlite_exec_void_retry(struct __sourceloc, int log_level, sqlite_retry_state *retry, const char *sqltext, ...);
|
2016-05-23 03:24:27 +00:00
|
|
|
int _sqlite_exec_changes_retry(struct __sourceloc __whence, int log_level, sqlite_retry_state *retry, int *rowcount, int *changes, const char *sqltext, ...);
|
2013-12-11 00:41:34 +00:00
|
|
|
int _sqlite_exec_uint64_retry(struct __sourceloc, sqlite_retry_state *retry, uint64_t *result, const char *sqltext, ...);
|
2013-10-02 15:46:10 +00:00
|
|
|
int _sqlite_exec_strbuf(struct __sourceloc, strbuf sb, const char *sqltext, ...);
|
|
|
|
int _sqlite_exec_strbuf_retry(struct __sourceloc, sqlite_retry_state *retry, strbuf sb, const char *sqltext, ...);
|
|
|
|
int _sqlite_vexec_strbuf_retry(struct __sourceloc, sqlite_retry_state *retry, strbuf sb, const char *sqltext, va_list ap);
|
2013-12-30 04:26:08 +00:00
|
|
|
int _sqlite_blob_open_retry(
|
|
|
|
struct __sourceloc,
|
|
|
|
int log_level,
|
|
|
|
sqlite_retry_state *retry,
|
|
|
|
const char *dbname,
|
|
|
|
const char *tablename,
|
|
|
|
const char *colname,
|
|
|
|
sqlite3_int64 rowid,
|
|
|
|
int flags,
|
|
|
|
sqlite3_blob **blobp
|
|
|
|
);
|
|
|
|
int _sqlite_blob_write_retry(
|
|
|
|
struct __sourceloc,
|
|
|
|
int log_level,
|
|
|
|
sqlite_retry_state *retry,
|
|
|
|
sqlite3_blob *blob,
|
|
|
|
const void *buf,
|
|
|
|
int len,
|
|
|
|
int offset
|
|
|
|
);
|
|
|
|
int _sqlite_blob_close(struct __sourceloc, int log_level, sqlite3_blob *blob);
|
2013-10-02 15:46:10 +00:00
|
|
|
|
|
|
|
// The 'arg' arguments in the following macros appear to be unnecessary, but
|
|
|
|
// they serve a very useful purpose, so don't remove them! They ensure that
|
|
|
|
// programmers do not forget the bind args, of which there must be at least
|
|
|
|
// one, even if it is only 'END' to make no bindings at all.
|
2013-10-03 05:45:30 +00:00
|
|
|
#define sqlite_prepare(rs,sql) _sqlite_prepare(__WHENCE__, LOG_LEVEL_ERROR, (rs), (sql))
|
|
|
|
#define sqlite_prepare_loglevel(ll,rs,sql) _sqlite_prepare(__WHENCE__, (ll), (rs), (sql))
|
|
|
|
#define sqlite_prepare_bind(rs,sql,arg,...) _sqlite_prepare_bind(__WHENCE__, LOG_LEVEL_ERROR, (rs), (sql), arg, ##__VA_ARGS__)
|
|
|
|
#define sqlite_prepare_bind_loglevel(ll,rs,sql,arg,...) _sqlite_prepare_bind(__WHENCE__, (ll), (rs), (sql), arg, ##__VA_ARGS__)
|
|
|
|
#define sqlite_bind(rs,stmt,arg,...) _sqlite_bind(__WHENCE__, LOG_LEVEL_ERROR, (rs), (stmt), arg, ##__VA_ARGS__)
|
|
|
|
#define sqlite_bind_loglevel(ll,rs,stmt,arg,...) _sqlite_bind(__WHENCE__, (ll), (rs), (stmt), arg, ##__VA_ARGS__)
|
2013-10-02 15:46:10 +00:00
|
|
|
#define sqlite_retry(rs,action) _sqlite_retry(__WHENCE__, (rs), (action))
|
|
|
|
#define sqlite_retry_done(rs,action) _sqlite_retry_done(__WHENCE__, (rs), (action))
|
2013-10-03 07:14:06 +00:00
|
|
|
#define sqlite_exec(stmt) _sqlite_exec(__WHENCE__, LOG_LEVEL_ERROR, NULL, (stmt))
|
|
|
|
#define sqlite_exec_retry(rs,stmt) _sqlite_exec(__WHENCE__, LOG_LEVEL_ERROR, (rs), (stmt))
|
|
|
|
#define sqlite_exec_retry_loglevel(ll,rs,stmt) _sqlite_exec(__WHENCE__, (ll), (rs), (stmt))
|
2017-03-06 05:26:58 +00:00
|
|
|
#define sqlite_exec_code(stmt, rowcount) _sqlite_exec_code(__WHENCE__, LOG_LEVEL_ERROR, NULL, (stmt), (rowcount))
|
|
|
|
#define sqlite_exec_code_retry(rs, stmt, rowcount) _sqlite_exec_code(__WHENCE__, LOG_LEVEL_ERROR, (rs), (stmt), (rowcount))
|
2013-10-03 05:45:30 +00:00
|
|
|
#define sqlite_step(stmt) _sqlite_step(__WHENCE__, LOG_LEVEL_ERROR, NULL, (stmt))
|
|
|
|
#define sqlite_step_retry(rs,stmt) _sqlite_step(__WHENCE__, LOG_LEVEL_ERROR, (rs), (stmt))
|
|
|
|
#define sqlite_exec_void(sql,arg,...) _sqlite_exec_void(__WHENCE__, LOG_LEVEL_ERROR, (sql), arg, ##__VA_ARGS__)
|
|
|
|
#define sqlite_exec_void_loglevel(ll,sql,arg,...) _sqlite_exec_void(__WHENCE__, (ll), (sql), arg, ##__VA_ARGS__)
|
|
|
|
#define sqlite_exec_void_retry(rs,sql,arg,...) _sqlite_exec_void_retry(__WHENCE__, LOG_LEVEL_ERROR, (rs), (sql), arg, ##__VA_ARGS__)
|
2016-05-23 03:24:27 +00:00
|
|
|
#define sqlite_exec_changes_retry(rs,ROWS,CHANGES,sql,arg,...) _sqlite_exec_changes_retry(__WHENCE__, LOG_LEVEL_ERROR, (rs), (ROWS), (CHANGES), (sql), arg, ##__VA_ARGS__)
|
|
|
|
#define sqlite_exec_changes_retry_loglevel(ll,rs,ROWS,CHANGES,sql,arg,...) _sqlite_exec_changes_retry(__WHENCE__, (ll), (rs), (ROWS), (CHANGES), (sql), arg, ##__VA_ARGS__)
|
2013-10-03 05:45:30 +00:00
|
|
|
#define sqlite_exec_void_retry_loglevel(ll,rs,sql,arg,...) _sqlite_exec_void_retry(__WHENCE__, (ll), (rs), (sql), arg, ##__VA_ARGS__)
|
2013-12-11 00:41:34 +00:00
|
|
|
#define sqlite_exec_uint64_retry(rs,res,sql,arg,...) _sqlite_exec_uint64_retry(__WHENCE__, (rs), (res), (sql), arg, ##__VA_ARGS__)
|
2013-10-02 15:46:10 +00:00
|
|
|
#define sqlite_exec_strbuf(sb,sql,arg,...) _sqlite_exec_strbuf(__WHENCE__, (sb), (sql), arg, ##__VA_ARGS__)
|
|
|
|
#define sqlite_exec_strbuf_retry(rs,sb,sql,arg,...) _sqlite_exec_strbuf_retry(__WHENCE__, (rs), (sb), (sql), arg, ##__VA_ARGS__)
|
2013-12-30 04:26:08 +00:00
|
|
|
#define sqlite_blob_open_retry(rs,db,table,col,row,flags,blobp) \
|
|
|
|
_sqlite_blob_open_retry(__WHENCE__, LOG_LEVEL_ERROR, (rs), (db), (table), (col), (row), (flags), (blobp))
|
|
|
|
#define sqlite_blob_close(blob) _sqlite_blob_close(__WHENCE__, LOG_LEVEL_ERROR, (blob));
|
|
|
|
#define sqlite_blob_write_retry(rs,blob,buf,siz,off) _sqlite_blob_write_retry(__WHENCE__, LOG_LEVEL_ERROR, (rs), (blob), (buf), (siz), (off))
|
2012-08-23 08:13:35 +00:00
|
|
|
|
2012-01-03 06:05:02 +00:00
|
|
|
double rhizome_manifest_get_double(rhizome_manifest *m,char *var,double default_value);
|
2013-10-30 03:15:51 +00:00
|
|
|
int rhizome_manifest_extract_signature(rhizome_manifest *m, unsigned *ofs);
|
2013-12-19 08:43:39 +00:00
|
|
|
enum rhizome_bundle_status rhizome_find_duplicate(const rhizome_manifest *m, rhizome_manifest **found);
|
2014-06-16 04:51:42 +00:00
|
|
|
int rhizome_manifest_to_bar(rhizome_manifest *m, rhizome_bar_t *bar);
|
2017-03-06 05:26:58 +00:00
|
|
|
enum rhizome_bundle_status rhizome_is_bar_interesting(const rhizome_bar_t *bar);
|
2017-10-19 11:43:30 +00:00
|
|
|
enum rhizome_bundle_status rhizome_is_interesting(const rhizome_bid_t *bid, uint64_t version, uint64_t *filesizep);
|
|
|
|
#define rhizome_is_manifest_interesting(M) rhizome_is_interesting(&(M)->keypair.public_key, (M)->version, NULL)
|
2014-09-08 07:44:55 +00:00
|
|
|
enum rhizome_bundle_status rhizome_retrieve_manifest(const rhizome_bid_t *bid, rhizome_manifest *m);
|
|
|
|
enum rhizome_bundle_status rhizome_retrieve_manifest_by_prefix(const unsigned char *prefix, unsigned prefix_len, rhizome_manifest *m);
|
2016-03-09 02:02:23 +00:00
|
|
|
enum rhizome_bundle_status rhizome_retrieve_manifest_by_hash_prefix(const uint8_t *prefix, unsigned prefix_len, rhizome_manifest *m);
|
2016-03-22 05:58:44 +00:00
|
|
|
enum rhizome_bundle_status rhizome_retrieve_bar_by_hash_prefix(const uint8_t *prefix, unsigned prefix_len, rhizome_bar_t *bar);
|
2013-08-20 23:51:40 +00:00
|
|
|
int rhizome_advertise_manifest(struct subscriber *dest, rhizome_manifest *m);
|
2013-10-03 13:46:45 +00:00
|
|
|
int rhizome_delete_bundle(const rhizome_bid_t *bidp);
|
|
|
|
int rhizome_delete_manifest(const rhizome_bid_t *bidp);
|
|
|
|
int rhizome_delete_payload(const rhizome_bid_t *bidp);
|
2014-06-18 07:55:15 +00:00
|
|
|
int rhizome_delete_file_id(const char *id);
|
2013-10-10 07:53:06 +00:00
|
|
|
int rhizome_delete_file(const rhizome_filehash_t *hashp);
|
2012-01-12 03:35:05 +00:00
|
|
|
|
|
|
|
#define RHIZOME_DONTVERIFY 0
|
|
|
|
#define RHIZOME_VERIFY 1
|
2012-01-13 06:51:06 +00:00
|
|
|
|
|
|
|
int rhizome_fetching_get_fds(struct pollfd *fds,int *fdcount,int fdmax);
|
2016-09-27 05:50:12 +00:00
|
|
|
|
2014-06-16 04:51:42 +00:00
|
|
|
int rhizome_queue_ignore_manifest(const unsigned char *bid_prefix, int prefix_len, int timeout);
|
|
|
|
int rhizome_ignore_manifest_check(const unsigned char *bid_prefix, int prefix_len);
|
2012-05-22 05:32:28 +00:00
|
|
|
|
2013-11-06 23:51:11 +00:00
|
|
|
/* Rhizome list cursor for iterating over all or a subset of manifests in the store.
|
|
|
|
*/
|
|
|
|
struct rhizome_list_cursor {
|
|
|
|
// Query parameters that narrow the set of listed bundles.
|
|
|
|
const char *service;
|
|
|
|
const char *name;
|
|
|
|
bool_t is_sender_set;
|
|
|
|
bool_t is_recipient_set;
|
2016-07-18 06:49:16 +00:00
|
|
|
bool_t oldest_first;
|
2013-11-06 23:51:11 +00:00
|
|
|
sid_t sender;
|
|
|
|
sid_t recipient;
|
2013-11-19 05:11:12 +00:00
|
|
|
// If set, then the cursor moves in ascending (chronological) order starting
|
|
|
|
// from the first bundle with rowid > rowid_since. If zero, then the cursor
|
|
|
|
// moves in descending (reverse chronological) order starting from the most
|
|
|
|
// recent bundle.
|
2013-11-13 06:28:28 +00:00
|
|
|
uint64_t rowid_since;
|
2013-11-06 23:51:11 +00:00
|
|
|
// Set by calling the next() function.
|
|
|
|
rhizome_manifest *manifest;
|
2014-01-22 06:50:06 +00:00
|
|
|
// Private state - implementation that could change.
|
|
|
|
sqlite_retry_state _retry;
|
2013-11-06 23:51:11 +00:00
|
|
|
sqlite3_stmt *_statement;
|
2013-11-13 06:28:28 +00:00
|
|
|
uint64_t _rowid_current;
|
|
|
|
uint64_t _rowid_last; // for re-opening query
|
2013-11-06 23:51:11 +00:00
|
|
|
};
|
|
|
|
|
2014-01-22 06:50:06 +00:00
|
|
|
int rhizome_list_open(struct rhizome_list_cursor *);
|
|
|
|
int rhizome_list_next(struct rhizome_list_cursor *);
|
2013-11-08 07:59:49 +00:00
|
|
|
void rhizome_list_commit(struct rhizome_list_cursor *);
|
2013-11-06 23:51:11 +00:00
|
|
|
void rhizome_list_release(struct rhizome_list_cursor *);
|
|
|
|
|
2013-04-11 05:54:13 +00:00
|
|
|
#define MAX_CANDIDATES 32
|
2012-05-22 06:06:21 +00:00
|
|
|
|
2014-02-05 04:56:56 +00:00
|
|
|
int rhizome_suggest_queue_manifest_import(rhizome_manifest *m, const struct socket_address *addr, const struct subscriber *peer);
|
2013-09-13 04:32:35 +00:00
|
|
|
rhizome_manifest * rhizome_fetch_search(const unsigned char *id, int prefix_length);
|
2014-06-28 10:53:57 +00:00
|
|
|
int rhizome_fetch_bar_queued(const rhizome_bar_t *bar);
|
2012-08-28 05:02:12 +00:00
|
|
|
|
2013-02-20 03:59:08 +00:00
|
|
|
/* Rhizome file storage api */
|
2013-10-10 07:53:06 +00:00
|
|
|
struct rhizome_write_buffer
|
|
|
|
{
|
2013-07-17 06:17:35 +00:00
|
|
|
struct rhizome_write_buffer *_next;
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
uint64_t offset;
|
2013-10-17 12:47:41 +00:00
|
|
|
size_t buffer_size;
|
|
|
|
size_t data_size;
|
2013-07-17 06:17:35 +00:00
|
|
|
unsigned char data[0];
|
|
|
|
};
|
|
|
|
|
2013-10-10 07:53:06 +00:00
|
|
|
struct rhizome_write
|
|
|
|
{
|
2013-08-27 06:45:51 +00:00
|
|
|
uint64_t temp_id;
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
uint64_t tail;
|
|
|
|
uint64_t file_offset;
|
|
|
|
uint64_t written_offset;
|
|
|
|
uint64_t file_length;
|
2013-07-18 07:34:12 +00:00
|
|
|
struct rhizome_write_buffer *buffer_list;
|
2013-10-17 12:47:41 +00:00
|
|
|
size_t buffer_size;
|
2013-02-20 03:59:08 +00:00
|
|
|
|
2016-01-25 06:40:42 +00:00
|
|
|
struct crypto_hash_sha512_state sha512_context;
|
2013-12-11 00:41:34 +00:00
|
|
|
uint64_t blob_rowid;
|
2013-02-20 03:59:08 +00:00
|
|
|
int blob_fd;
|
2013-07-18 04:22:42 +00:00
|
|
|
sqlite3_blob *sql_blob;
|
2016-01-25 06:40:42 +00:00
|
|
|
|
|
|
|
rhizome_filehash_t id;
|
2016-05-24 05:16:46 +00:00
|
|
|
uint8_t id_known:1;
|
|
|
|
uint8_t crypt:1;
|
|
|
|
uint8_t journal:1;
|
|
|
|
|
2016-01-25 06:40:42 +00:00
|
|
|
unsigned char key[RHIZOME_CRYPT_KEY_BYTES];
|
2016-04-12 06:13:56 +00:00
|
|
|
unsigned char nonce[crypto_box_NONCEBYTES];
|
2013-02-20 03:59:08 +00:00
|
|
|
};
|
|
|
|
|
2013-07-25 05:12:30 +00:00
|
|
|
struct rhizome_read_buffer{
|
|
|
|
uint64_t offset;
|
|
|
|
unsigned char data[RHIZOME_CRYPT_PAGE_SIZE];
|
2013-10-17 12:47:41 +00:00
|
|
|
size_t len;
|
2013-07-25 05:12:30 +00:00
|
|
|
};
|
|
|
|
|
2013-10-10 07:53:06 +00:00
|
|
|
struct rhizome_read
|
|
|
|
{
|
2013-12-10 06:22:53 +00:00
|
|
|
uint64_t hash_offset;
|
2016-01-25 06:40:42 +00:00
|
|
|
struct crypto_hash_sha512_state sha512_context;
|
2013-02-20 03:59:08 +00:00
|
|
|
|
2013-12-11 00:41:34 +00:00
|
|
|
uint64_t blob_rowid;
|
2013-02-20 03:59:08 +00:00
|
|
|
int blob_fd;
|
|
|
|
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
uint64_t tail;
|
|
|
|
uint64_t offset;
|
|
|
|
uint64_t length;
|
2016-01-25 06:40:42 +00:00
|
|
|
|
|
|
|
int8_t verified;
|
|
|
|
uint8_t crypt;
|
|
|
|
rhizome_filehash_t id;
|
|
|
|
unsigned char key[RHIZOME_CRYPT_KEY_BYTES];
|
2016-04-12 06:13:56 +00:00
|
|
|
unsigned char nonce[crypto_box_NONCEBYTES];
|
2013-02-20 03:59:08 +00:00
|
|
|
};
|
|
|
|
|
2013-10-03 13:46:45 +00:00
|
|
|
int rhizome_received_content(const unsigned char *bidprefix,uint64_t version,
|
2013-12-09 07:52:18 +00:00
|
|
|
uint64_t offset, size_t count,unsigned char *bytes);
|
2012-09-08 10:56:18 +00:00
|
|
|
|
2012-11-30 04:17:27 +00:00
|
|
|
int is_rhizome_enabled();
|
|
|
|
int is_rhizome_mdp_enabled();
|
|
|
|
int is_rhizome_http_enabled();
|
|
|
|
int is_rhizome_advertise_enabled();
|
|
|
|
int is_rhizome_mdp_server_running();
|
|
|
|
|
2012-09-08 10:56:18 +00:00
|
|
|
typedef struct rhizome_direct_bundle_cursor {
|
2012-09-08 23:00:38 +00:00
|
|
|
/* Where the current fill started */
|
2013-07-13 05:17:06 +00:00
|
|
|
int64_t start_size_high;
|
2013-10-03 13:46:45 +00:00
|
|
|
rhizome_bid_t start_bid_low;
|
2012-09-08 23:00:38 +00:00
|
|
|
|
|
|
|
/* Limit of where this cursor may traverse */
|
2013-07-13 05:17:06 +00:00
|
|
|
int64_t limit_size_high;
|
2013-10-03 13:46:45 +00:00
|
|
|
rhizome_bid_t limit_bid_high;
|
2012-09-08 23:00:38 +00:00
|
|
|
|
2013-07-13 05:17:06 +00:00
|
|
|
int64_t size_low;
|
|
|
|
int64_t size_high;
|
2013-10-03 13:46:45 +00:00
|
|
|
rhizome_bid_t bid_low;
|
|
|
|
rhizome_bid_t bid_high;
|
2012-09-08 10:56:18 +00:00
|
|
|
unsigned char *buffer;
|
2013-10-17 12:47:41 +00:00
|
|
|
size_t buffer_size;
|
|
|
|
size_t buffer_used;
|
|
|
|
size_t buffer_offset_bytes;
|
2012-09-08 10:56:18 +00:00
|
|
|
} rhizome_direct_bundle_cursor;
|
|
|
|
|
2013-10-17 12:47:41 +00:00
|
|
|
rhizome_direct_bundle_cursor *rhizome_direct_bundle_iterator(size_t buffer_size);
|
2012-09-08 23:00:38 +00:00
|
|
|
void rhizome_direct_bundle_iterator_unlimit(rhizome_direct_bundle_cursor *r);
|
|
|
|
int rhizome_direct_bundle_iterator_pickle_range(rhizome_direct_bundle_cursor *r,
|
|
|
|
unsigned char *pickled,
|
|
|
|
int pickle_buffer_size);
|
|
|
|
int rhizome_direct_bundle_iterator_unpickle_range(rhizome_direct_bundle_cursor *r,
|
|
|
|
const unsigned char *pickled,
|
|
|
|
int pickle_buffer_size);
|
2012-09-08 10:56:18 +00:00
|
|
|
int rhizome_direct_bundle_iterator_fill(rhizome_direct_bundle_cursor *c,
|
|
|
|
int max_bars);
|
|
|
|
void rhizome_direct_bundle_iterator_free(rhizome_direct_bundle_cursor **c);
|
2013-10-03 13:46:45 +00:00
|
|
|
int rhizome_direct_get_bars(const rhizome_bid_t *bid_low,
|
|
|
|
rhizome_bid_t *bid_high,
|
2013-07-13 05:17:06 +00:00
|
|
|
int64_t size_low, int64_t size_high,
|
2013-10-03 13:46:45 +00:00
|
|
|
const rhizome_bid_t *bid_max,
|
2012-09-07 22:25:57 +00:00
|
|
|
unsigned char *bars_out,
|
|
|
|
int bars_requested);
|
2012-08-28 05:10:17 +00:00
|
|
|
|
2012-09-09 23:46:27 +00:00
|
|
|
typedef struct rhizome_direct_sync_request {
|
|
|
|
struct sched_ent alarm;
|
|
|
|
rhizome_direct_bundle_cursor *cursor;
|
|
|
|
|
|
|
|
int pushP;
|
|
|
|
int pullP;
|
|
|
|
|
|
|
|
/* Sync interval in seconds. zero = sync only once */
|
|
|
|
int interval;
|
|
|
|
|
|
|
|
/* The dispatch function will be called each time a sync request can
|
|
|
|
be sent off, i.e., one cursor->buffer full of data.
|
|
|
|
Will differ based on underlying transport. HTTP is the initial
|
|
|
|
supported transport, but deLorme inReach will likely follow soon after.
|
|
|
|
*/
|
|
|
|
void (*dispatch_function)(struct rhizome_direct_sync_request *);
|
|
|
|
|
|
|
|
/* General purpose pointer for transport-dependent state */
|
|
|
|
void *transport_specific_state;
|
|
|
|
|
|
|
|
/* Statistics.
|
|
|
|
Each sync will consist of one or more "fills" of the cursor buffer, which
|
|
|
|
will then be dispatched by the transport-specific dispatch function.
|
|
|
|
Each of those dispatches may then result in zero or
|
|
|
|
*/
|
|
|
|
int syncs_started;
|
|
|
|
int syncs_completed;
|
|
|
|
int fills_sent;
|
|
|
|
int fill_responses_processed;
|
|
|
|
int bundles_pushed;
|
|
|
|
int bundles_pulled;
|
|
|
|
int bundle_transfers_in_progress;
|
|
|
|
|
|
|
|
} rhizome_direct_sync_request;
|
|
|
|
|
|
|
|
#define RHIZOME_DIRECT_MAX_SYNC_HANDLES 16
|
|
|
|
extern rhizome_direct_sync_request *rd_sync_handles[RHIZOME_DIRECT_MAX_SYNC_HANDLES];
|
|
|
|
extern int rd_sync_handle_count;
|
|
|
|
|
|
|
|
rhizome_direct_sync_request
|
Switch to feature-driven linking
This introduces a new way of linking Serval executables and dynamic
libraries from static libraries like libservald.a -- called
"feature-driven" linking.
The Makefile now links servald and serval-tests from libservald.a,
rather than from an explicit list of object (.o) files. Thanks to the
section-based method for registering functions such as HTTP handlers,
CLI commands and MDP handlers, these object files had become
"stand-alone" and hence were no longer included in the link because
there was no unresolved reference that required them to be linked in.
The new "feature.h" provides the DECLARE_FEATURE(name) macro that each
stand-alone source file uses to declare the named feature(s) it
provides. Each executable can call the USE_FEATURE(name) macro in any
of its explicitly-linked source files to cause the corresponding
object(s) to be included in the link, eg, servald_features.c.
The DEFINE_BINDING() macro has been extended so that every individual
MDP binding is given a feature name based on its port number macro, eg,
"mdp_binding_MDP_PORT_ECHO".
Some features have been factored into their own separate source files so
they can be omitted or included in a build independently of each other:
- the MDP bindings for MDP_PORT_DNALOOKUP, MDP_PORT_ECHO,
MDP_PORT_TRACE, MDP_PORT_KEYMAPREQUEST, MDP_PORT_RHIZOME_xxx,
MDP_PORT_PROBE, MDP_PORT_STUN, MDP_PORT_STUNREQ
- the CLI "log" and "echo" commands
- the CLI "rhizome direct" command
The JNI source files are only compiled if the <jni.h> header is present,
otherwise they are omitted from libservald.so.
2016-10-13 02:58:23 +00:00
|
|
|
*rhizome_direct_new_sync_request(void (*transport_specific_dispatch_function)(struct rhizome_direct_sync_request *),
|
|
|
|
size_t buffer_size,
|
|
|
|
int interval,
|
|
|
|
int mode,
|
2012-09-09 23:46:27 +00:00
|
|
|
void *transport_specific_state);
|
|
|
|
int rhizome_direct_continue_sync_request(rhizome_direct_sync_request *r);
|
|
|
|
int rhizome_direct_conclude_sync_request(rhizome_direct_sync_request *r);
|
Switch to feature-driven linking
This introduces a new way of linking Serval executables and dynamic
libraries from static libraries like libservald.a -- called
"feature-driven" linking.
The Makefile now links servald and serval-tests from libservald.a,
rather than from an explicit list of object (.o) files. Thanks to the
section-based method for registering functions such as HTTP handlers,
CLI commands and MDP handlers, these object files had become
"stand-alone" and hence were no longer included in the link because
there was no unresolved reference that required them to be linked in.
The new "feature.h" provides the DECLARE_FEATURE(name) macro that each
stand-alone source file uses to declare the named feature(s) it
provides. Each executable can call the USE_FEATURE(name) macro in any
of its explicitly-linked source files to cause the corresponding
object(s) to be included in the link, eg, servald_features.c.
The DEFINE_BINDING() macro has been extended so that every individual
MDP binding is given a feature name based on its port number macro, eg,
"mdp_binding_MDP_PORT_ECHO".
Some features have been factored into their own separate source files so
they can be omitted or included in a build independently of each other:
- the MDP bindings for MDP_PORT_DNALOOKUP, MDP_PORT_ECHO,
MDP_PORT_TRACE, MDP_PORT_KEYMAPREQUEST, MDP_PORT_RHIZOME_xxx,
MDP_PORT_PROBE, MDP_PORT_STUN, MDP_PORT_STUNREQ
- the CLI "log" and "echo" commands
- the CLI "rhizome direct" command
The JNI source files are only compiled if the <jni.h> header is present,
otherwise they are omitted from libservald.so.
2016-10-13 02:58:23 +00:00
|
|
|
rhizome_direct_bundle_cursor *rhizome_direct_get_fill_response(unsigned char *buffer,int size,int max_response_bytes);
|
2012-09-09 23:46:27 +00:00
|
|
|
|
2012-09-10 10:52:14 +00:00
|
|
|
typedef struct rhizome_direct_transport_state_http {
|
|
|
|
int port;
|
|
|
|
char host[1024];
|
|
|
|
} rhizome_direct_transport_state_http;
|
|
|
|
|
2012-09-09 23:46:27 +00:00
|
|
|
void rhizome_direct_http_dispatch(rhizome_direct_sync_request *);
|
|
|
|
|
2012-08-28 05:10:17 +00:00
|
|
|
extern unsigned char favicon_bytes[];
|
|
|
|
extern int favicon_len;
|
2012-10-02 10:53:44 +00:00
|
|
|
|
|
|
|
int rhizome_import_from_files(const char *manifestpath,const char *filepath);
|
2012-10-24 01:38:41 +00:00
|
|
|
|
|
|
|
enum rhizome_start_fetch_result {
|
|
|
|
STARTED = 0,
|
|
|
|
SAMEBUNDLE,
|
|
|
|
SAMEPAYLOAD,
|
|
|
|
SUPERSEDED,
|
|
|
|
OLDERBUNDLE,
|
|
|
|
NEWERBUNDLE,
|
2014-06-18 07:55:15 +00:00
|
|
|
DONOTWANT,
|
2012-10-24 01:38:41 +00:00
|
|
|
IMPORTED,
|
|
|
|
SLOTBUSY
|
|
|
|
};
|
|
|
|
|
2013-12-09 07:15:47 +00:00
|
|
|
enum rhizome_start_fetch_result
|
|
|
|
rhizome_fetch_request_manifest_by_prefix(const struct socket_address *addr,
|
2014-02-05 04:56:56 +00:00
|
|
|
const struct subscriber *peer,
|
2013-12-09 07:15:47 +00:00
|
|
|
const unsigned char *prefix, size_t prefix_length);
|
2012-10-23 07:40:20 +00:00
|
|
|
int rhizome_any_fetch_active();
|
2012-11-12 05:51:38 +00:00
|
|
|
int rhizome_any_fetch_queued();
|
2013-07-11 03:02:06 +00:00
|
|
|
int rhizome_fetch_status_html(struct strbuf *b);
|
2013-04-11 05:54:13 +00:00
|
|
|
int rhizome_fetch_has_queue_space(unsigned char log2_size);
|
2012-10-04 08:08:33 +00:00
|
|
|
|
2015-05-25 09:05:10 +00:00
|
|
|
/* Rhizome storage methods */
|
2012-12-17 05:11:27 +00:00
|
|
|
|
2017-03-06 05:26:58 +00:00
|
|
|
enum rhizome_payload_status rhizome_exists(const rhizome_filehash_t *hashp);
|
2014-06-18 07:55:15 +00:00
|
|
|
enum rhizome_payload_status rhizome_open_write(struct rhizome_write *write, const rhizome_filehash_t *expectedHashp, uint64_t file_length);
|
2014-06-28 08:06:06 +00:00
|
|
|
int rhizome_write_buffer(struct rhizome_write *write_state, uint8_t *buffer, size_t data_size);
|
|
|
|
int rhizome_random_write(struct rhizome_write *write_state, uint64_t offset, uint8_t *buffer, size_t data_size);
|
2013-12-27 18:56:22 +00:00
|
|
|
enum rhizome_payload_status rhizome_write_open_manifest(struct rhizome_write *write, rhizome_manifest *m);
|
2015-03-02 08:22:12 +00:00
|
|
|
enum rhizome_payload_status rhizome_write_open_journal(struct rhizome_write *write, rhizome_manifest *m, uint64_t advance_by, uint64_t append_size);
|
2016-03-30 05:02:50 +00:00
|
|
|
int rhizome_write_file(struct rhizome_write *write, const char *filename, off_t offset, uint64_t length);
|
2013-12-27 18:56:22 +00:00
|
|
|
void rhizome_fail_write(struct rhizome_write *write);
|
2017-02-14 00:15:06 +00:00
|
|
|
int is_rhizome_write_open(const struct rhizome_write *write);
|
2013-12-27 18:56:22 +00:00
|
|
|
enum rhizome_payload_status rhizome_finish_write(struct rhizome_write *write);
|
2015-03-27 18:38:07 +00:00
|
|
|
enum rhizome_payload_status rhizome_finish_store(struct rhizome_write *write, rhizome_manifest *m, enum rhizome_payload_status status);
|
2013-12-27 18:56:22 +00:00
|
|
|
enum rhizome_payload_status rhizome_import_payload_from_file(rhizome_manifest *m, const char *filepath);
|
2014-06-28 08:06:06 +00:00
|
|
|
enum rhizome_payload_status rhizome_import_buffer(rhizome_manifest *m, uint8_t *buffer, size_t length);
|
2013-12-27 18:56:22 +00:00
|
|
|
enum rhizome_payload_status rhizome_stat_payload_file(rhizome_manifest *m, const char *filepath);
|
|
|
|
enum rhizome_payload_status rhizome_store_payload_file(rhizome_manifest *m, const char *filepath);
|
2013-11-05 07:28:03 +00:00
|
|
|
int rhizome_derive_payload_key(rhizome_manifest *m);
|
2013-07-05 06:54:50 +00:00
|
|
|
|
2014-06-28 08:06:06 +00:00
|
|
|
enum rhizome_payload_status rhizome_append_journal_buffer(rhizome_manifest *m, uint64_t advance_by, uint8_t *buffer, size_t len);
|
2013-12-27 18:56:22 +00:00
|
|
|
enum rhizome_payload_status rhizome_append_journal_file(rhizome_manifest *m, uint64_t advance_by, const char *filename);
|
|
|
|
enum rhizome_payload_status rhizome_journal_pipe(struct rhizome_write *write, const rhizome_filehash_t *hashp, uint64_t start_offset, uint64_t length);
|
2013-07-05 06:54:50 +00:00
|
|
|
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
int rhizome_crypt_xor_block(unsigned char *buffer, size_t buffer_size, uint64_t stream_offset,
|
2013-01-02 04:35:22 +00:00
|
|
|
const unsigned char *key, const unsigned char *nonce);
|
2013-12-27 18:56:22 +00:00
|
|
|
enum rhizome_payload_status rhizome_open_read(struct rhizome_read *read, const rhizome_filehash_t *hashp);
|
2013-10-30 06:53:44 +00:00
|
|
|
ssize_t rhizome_read(struct rhizome_read *read, unsigned char *buffer, size_t buffer_length);
|
2013-11-06 02:57:48 +00:00
|
|
|
ssize_t rhizome_read_buffered(struct rhizome_read *read, struct rhizome_read_buffer *buffer, unsigned char *data, size_t len);
|
2013-12-27 18:56:22 +00:00
|
|
|
void rhizome_read_close(struct rhizome_read *read);
|
|
|
|
enum rhizome_payload_status rhizome_open_decrypt_read(rhizome_manifest *m, struct rhizome_read *read_state);
|
|
|
|
enum rhizome_payload_status rhizome_extract_file(rhizome_manifest *m, const char *filepath);
|
|
|
|
enum rhizome_payload_status rhizome_dump_file(const rhizome_filehash_t *hashp, const char *filepath, uint64_t *lengthp);
|
|
|
|
ssize_t rhizome_read_cached(const rhizome_bid_t *bid, uint64_t version, time_ms_t timeout,
|
|
|
|
uint64_t fileOffset, unsigned char *buffer, size_t length);
|
2013-08-16 05:27:28 +00:00
|
|
|
int rhizome_cache_close();
|
2013-02-20 03:59:08 +00:00
|
|
|
|
2013-10-10 07:53:06 +00:00
|
|
|
int rhizome_database_filehash_from_id(const rhizome_bid_t *bidp, uint64_t version, rhizome_filehash_t *hashp);
|
2013-06-18 03:57:26 +00:00
|
|
|
|
2014-06-28 10:53:57 +00:00
|
|
|
void rhizome_sync_status();
|
2013-06-18 03:57:26 +00:00
|
|
|
|
2014-06-28 08:11:05 +00:00
|
|
|
DECLARE_ALARM(rhizome_fetch_status);
|
2015-05-25 09:05:10 +00:00
|
|
|
|
|
|
|
/* Rhizome triggers */
|
|
|
|
|
2015-10-19 11:46:15 +00:00
|
|
|
DECLARE_TRIGGER(bundle_add, rhizome_manifest*);
|
2015-05-25 09:05:10 +00:00
|
|
|
|
2013-12-04 06:44:14 +00:00
|
|
|
#endif //__SERVAL_DNA__RHIZOME_H
|