mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-04-09 03:54:15 +00:00
Merge branch 'naf4' into 'development'
Copyright notices added to most source files and headers New 'config_test' make target Add RHIZOME_BUNDLE_ID_xxx, deprecate RHIZOME_MANIFEST_ID_xxx Consolidate Rhizome string functions
This commit is contained in:
commit
56309886f3
1
.gitignore
vendored
1
.gitignore
vendored
@ -21,6 +21,7 @@ serval.c
|
||||
/directory_service
|
||||
/tfw_createfile
|
||||
/fakeradio
|
||||
/config_test
|
||||
*.so
|
||||
test.*.log
|
||||
testlog
|
||||
|
@ -28,6 +28,7 @@ MONITORCLIENTSRCS=conf.c \
|
||||
conf_schema.c \
|
||||
dataformats.c \
|
||||
log.c \
|
||||
log_util.c \
|
||||
xprintf.c \
|
||||
os.c \
|
||||
mem.c \
|
||||
@ -48,10 +49,12 @@ MDPCLIENTSRCS=conf.c \
|
||||
os.c \
|
||||
mem.c \
|
||||
log.c \
|
||||
log_util.c \
|
||||
xprintf.c \
|
||||
mdp_client.c \
|
||||
instance.c \
|
||||
net.c \
|
||||
mdp_net.c \
|
||||
socket.c \
|
||||
str.c \
|
||||
strbuf.c \
|
||||
@ -86,7 +89,7 @@ DEFS= @DEFS@
|
||||
|
||||
all: servald libmonitorclient.so libmonitorclient.a test
|
||||
|
||||
test: tfw_createfile directory_service fakeradio
|
||||
test: tfw_createfile directory_service fakeradio config_test
|
||||
|
||||
sqlite-amalgamation-3070900/sqlite3.o: sqlite-amalgamation-3070900/sqlite3.c
|
||||
@echo CC $<
|
||||
@ -121,6 +124,10 @@ fakeradio: fakeradio.o
|
||||
@echo LINK $@
|
||||
@$(CC) $(CFLAGS) -Wall -o $@ fakeradio.o
|
||||
|
||||
config_test: config_test.o conf_om.o conf_schema.o conf_parse.o str.o strbuf.o strbuf_helpers.o mem.o dataformats.o net.o log_util.o
|
||||
@echo LINK $@
|
||||
@$(CC) $(CFLAGS) -Wall -o $@ config_test.o conf_om.o conf_schema.o conf_parse.o str.o strbuf.o strbuf_helpers.o mem.o dataformats.o net.o log_util.o
|
||||
|
||||
# This does not build on 64 bit elf platforms as NaCL isn't built with -fPIC
|
||||
# DOC 20120615
|
||||
libservald.so: $(OBJS) version.o
|
||||
|
@ -1,3 +1,22 @@
|
||||
/*
|
||||
Serval DNA source code checker
|
||||
Copyright 2013 Serval Project, Inc.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
6
cli.c
6
cli.c
@ -340,17 +340,17 @@ int cli_optional_sid(const char *arg)
|
||||
|
||||
int cli_optional_bundle_key(const char *arg)
|
||||
{
|
||||
return !arg[0] || rhizome_str_is_bundle_key(arg);
|
||||
return !arg[0] || str_to_rhizome_bk_t(NULL, arg) != -1;
|
||||
}
|
||||
|
||||
int cli_manifestid(const char *arg)
|
||||
{
|
||||
return rhizome_str_is_manifest_id(arg);
|
||||
return str_to_rhizome_bid_t(NULL, arg) != -1;
|
||||
}
|
||||
|
||||
int cli_fileid(const char *arg)
|
||||
{
|
||||
return rhizome_str_is_file_hash(arg);
|
||||
return str_to_rhizome_filehash_t(NULL, arg) != -1;
|
||||
}
|
||||
|
||||
int cli_optional_bundle_crypt_key(const char *arg)
|
||||
|
6
conf.h
6
conf.h
@ -222,8 +222,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
* @author Andrew Bettison <andrew@servalproject.com>
|
||||
*/
|
||||
|
||||
#ifndef __SERVALDNA_CONFIG_H
|
||||
#define __SERVALDNA_CONFIG_H
|
||||
#ifndef __SERVALDNA_CONF_H
|
||||
#define __SERVALDNA_CONF_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <arpa/inet.h>
|
||||
@ -701,4 +701,4 @@ int cf_reload();
|
||||
int cf_reload_strict();
|
||||
int cf_reload_permissive();
|
||||
|
||||
#endif //__SERVALDNA_CONFIG_H
|
||||
#endif //__SERVALDNA_CONF_H
|
||||
|
@ -633,11 +633,7 @@ int cf_cmp_sid(const sid_t *a, const sid_t *b)
|
||||
|
||||
int cf_opt_rhizome_bk(rhizome_bk_t *bkp, const char *text)
|
||||
{
|
||||
if (!rhizome_str_is_bundle_key(text))
|
||||
return CFINVALID;
|
||||
size_t n = fromhex(bkp->binary, text, RHIZOME_BUNDLE_KEY_BYTES);
|
||||
assert(n == RHIZOME_BUNDLE_KEY_BYTES);
|
||||
return CFOK;
|
||||
return str_to_rhizome_bk_t(bkp, text) ? CFOK : CFINVALID;
|
||||
}
|
||||
|
||||
int cf_fmt_rhizome_bk(const char **textp, const rhizome_bk_t *bkp)
|
||||
|
@ -1,8 +1,28 @@
|
||||
/*
|
||||
Serval DNA configuration stand-alone configuration check utility
|
||||
Copyright 2013 Serval Project, Inc.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <poll.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "str.h"
|
||||
@ -30,7 +50,7 @@ int main(int argc, char **argv)
|
||||
exit(1);
|
||||
}
|
||||
struct cf_om_node *root = NULL;
|
||||
int ret = cf_parse_to_om(argv[i], buf, st.st_size, &root);
|
||||
int ret = cf_om_parse(argv[i], buf, st.st_size, &root);
|
||||
close(fd);
|
||||
DEBUGF("ret = %s", strbuf_str(strbuf_cf_flags(strbuf_alloca(128), ret)));
|
||||
//cf_dump_node(root, 0);
|
||||
@ -38,17 +58,17 @@ int main(int argc, char **argv)
|
||||
memset(&config, 0, sizeof config);
|
||||
cf_dfl_config_main(&config);
|
||||
int result = root ? cf_opt_config_main(&config, root) : CFEMPTY;
|
||||
cf_free_node(&root);
|
||||
cf_om_free_node(&root);
|
||||
free(buf);
|
||||
DEBUGF("result = %s", strbuf_str(strbuf_cf_flags(strbuf_alloca(128), result)));
|
||||
DEBUGF("config.log.file = %s", alloca_str_toprint(config.log.file));
|
||||
DEBUGF("config.log.show_pid = %d", config.log.show_pid);
|
||||
DEBUGF("config.log.show_time = %d", config.log.show_time);
|
||||
DEBUGF("config.log.file.path = %s", alloca_str_toprint(config.log.file.path));
|
||||
DEBUGF("config.log.file.show_pid = %d", config.log.file.show_pid);
|
||||
DEBUGF("config.log.file.show_time = %d", config.log.file.show_time);
|
||||
DEBUGF("config.server.chdir = %s", alloca_str_toprint(config.server.chdir));
|
||||
DEBUGF("config.debug = %"PRIx64, (uint64_t) config.debug);
|
||||
DEBUGF("config.debug.verbose = %d", config.debug.verbose);
|
||||
DEBUGF("config.directory.service = %s", alloca_tohex_sid_t(config.directory.service));
|
||||
DEBUGF("config.rhizome.api.addfile.allow_host = %s", inet_ntoa(config.rhizome.api.addfile.allow_host));
|
||||
int j;
|
||||
unsigned j;
|
||||
for (j = 0; j < config.mdp.iftype.ac; ++j) {
|
||||
DEBUGF("config.mdp.iftype.%u", config.mdp.iftype.av[j].key);
|
||||
DEBUGF(" .tick_ms = %u", config.mdp.iftype.av[j].value.tick_ms);
|
||||
@ -63,7 +83,7 @@ int main(int argc, char **argv)
|
||||
DEBUGF(" .port = %u", config.rhizome.direct.peer.av[j].value.port);
|
||||
}
|
||||
for (j = 0; j < config.interfaces.ac; ++j) {
|
||||
DEBUGF("config.interfaces.%s", config.interfaces.av[j].key);
|
||||
DEBUGF("config.interfaces.%u", config.interfaces.av[j].key);
|
||||
DEBUGF(" .exclude = %d", config.interfaces.av[j].value.exclude);
|
||||
DEBUGF(" .match = [");
|
||||
int k;
|
||||
@ -72,7 +92,9 @@ int main(int argc, char **argv)
|
||||
DEBUGF(" ]");
|
||||
DEBUGF(" .type = %d", config.interfaces.av[j].value.type);
|
||||
DEBUGF(" .port = %u", config.interfaces.av[j].value.port);
|
||||
DEBUGF(" .speed = %llu", (unsigned long long) config.interfaces.av[j].value.speed);
|
||||
DEBUGF(" .drop_broadcasts = %llu", (unsigned long long) config.interfaces.av[j].value.drop_broadcasts);
|
||||
DEBUGF(" .drop_unicasts = %llu", (unsigned long long) config.interfaces.av[j].value.drop_unicasts);
|
||||
DEBUGF(" .drop_packets = %llu", (unsigned long long) config.interfaces.av[j].value.drop_packets);
|
||||
}
|
||||
for (j = 0; j < config.hosts.ac; ++j) {
|
||||
char sidhex[SID_STRLEN + 1];
|
||||
@ -129,37 +151,3 @@ void logMessage(int level, struct __sourceloc whence, const char *fmt, ...)
|
||||
va_end(ap);
|
||||
fputc('\n', stderr);
|
||||
}
|
||||
|
||||
debugflags_t debugFlagMask(const char *flagname)
|
||||
{
|
||||
if (!strcasecmp(flagname,"all")) return ~0;
|
||||
else if (!strcasecmp(flagname,"interfaces")) return 1 << 0;
|
||||
else if (!strcasecmp(flagname,"rx")) return 1 << 1;
|
||||
else if (!strcasecmp(flagname,"tx")) return 1 << 2;
|
||||
else if (!strcasecmp(flagname,"verbose")) return 1 << 3;
|
||||
else if (!strcasecmp(flagname,"verbio")) return 1 << 4;
|
||||
else if (!strcasecmp(flagname,"peers")) return 1 << 5;
|
||||
else if (!strcasecmp(flagname,"dnaresponses")) return 1 << 6;
|
||||
else if (!strcasecmp(flagname,"dnahelper")) return 1 << 7;
|
||||
else if (!strcasecmp(flagname,"vomp")) return 1 << 8;
|
||||
else if (!strcasecmp(flagname,"packetformats")) return 1 << 9;
|
||||
else if (!strcasecmp(flagname,"packetconstruction")) return 1 << 10;
|
||||
else if (!strcasecmp(flagname,"gateway")) return 1 << 11;
|
||||
else if (!strcasecmp(flagname,"keyring")) return 1 << 12;
|
||||
else if (!strcasecmp(flagname,"sockio")) return 1 << 13;
|
||||
else if (!strcasecmp(flagname,"frames")) return 1 << 14;
|
||||
else if (!strcasecmp(flagname,"abbreviations")) return 1 << 15;
|
||||
else if (!strcasecmp(flagname,"routing")) return 1 << 16;
|
||||
else if (!strcasecmp(flagname,"security")) return 1 << 17;
|
||||
else if (!strcasecmp(flagname,"rhizome")) return 1 << 18;
|
||||
else if (!strcasecmp(flagname,"rhizometx")) return 1 << 19;
|
||||
else if (!strcasecmp(flagname,"rhizomerx")) return 1 << 20;
|
||||
else if (!strcasecmp(flagname,"rhizomeads")) return 1 << 21;
|
||||
else if (!strcasecmp(flagname,"monitorroutes")) return 1 << 22;
|
||||
else if (!strcasecmp(flagname,"queues")) return 1 << 23;
|
||||
else if (!strcasecmp(flagname,"broadcasts")) return 1 << 24;
|
||||
else if (!strcasecmp(flagname,"manifests")) return 1 << 25;
|
||||
else if (!strcasecmp(flagname,"mdprequests")) return 1 << 26;
|
||||
else if (!strcasecmp(flagname,"timing")) return 1 << 27;
|
||||
return 0;
|
||||
}
|
||||
|
19
crypto.c
19
crypto.c
@ -1,3 +1,22 @@
|
||||
/*
|
||||
Serval DNA internal cryptographic operations
|
||||
Copyright 2013 Serval Project, Inc.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#include "crypto_sign_edwards25519sha512batch.h"
|
||||
#include "nacl/src/crypto_sign_edwards25519sha512batch_ref/ge.h"
|
||||
#include "serval.h"
|
||||
|
18
crypto.h
18
crypto.h
@ -1,3 +1,21 @@
|
||||
/*
|
||||
Serval DNA internal cryptographic operations
|
||||
Copyright 2013 Serval Project, Inc.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef __SERVALD_CRYPTO_H
|
||||
#define __SERVALD_CRYPTO_H
|
||||
|
@ -28,17 +28,20 @@ int cmp_sid_t(const sid_t *a, const sid_t *b)
|
||||
return memcmp(a, b, sizeof a->binary);
|
||||
}
|
||||
|
||||
int str_to_sid_t(sid_t *sid, const char *hex) {
|
||||
int str_to_sid_t(sid_t *sid, const char *hex)
|
||||
{
|
||||
if (strcmp(hex, "broadcast") == 0) {
|
||||
*sid = SID_BROADCAST;
|
||||
if (sid)
|
||||
*sid = SID_BROADCAST;
|
||||
return 0;
|
||||
}
|
||||
return fromhexstr(sid->binary, hex, sizeof sid->binary);
|
||||
return sid ? fromhexstr(sid->binary, hex, sizeof sid->binary) : is_xstring(hex, SID_STRLEN) ? 0 : -1;
|
||||
}
|
||||
|
||||
int strn_to_sid_t(sid_t *sid, const char *hex, const char **endp)
|
||||
{
|
||||
if (str_startswith(hex, "broadcast", endp) == 0) {
|
||||
if (sid)
|
||||
*sid = SID_BROADCAST;
|
||||
return 0;
|
||||
}
|
||||
@ -80,7 +83,7 @@ int cmp_rhizome_bid_t(const rhizome_bid_t *a, const rhizome_bid_t *b)
|
||||
|
||||
int str_to_rhizome_bid_t(rhizome_bid_t *bid, const char *hex)
|
||||
{
|
||||
return fromhexstr(bid->binary, hex, sizeof bid->binary);
|
||||
return bid ? fromhexstr(bid->binary, hex, sizeof bid->binary) : is_xstring(hex, RHIZOME_BUNDLE_ID_STRLEN) ? 0 : -1;
|
||||
}
|
||||
|
||||
int strn_to_rhizome_bid_t(rhizome_bid_t *bid, const char *hex, const char **endp)
|
||||
@ -102,7 +105,7 @@ int cmp_rhizome_filehash_t(const rhizome_filehash_t *a, const rhizome_filehash_t
|
||||
|
||||
int str_to_rhizome_filehash_t(rhizome_filehash_t *hashp, const char *hex)
|
||||
{
|
||||
return fromhexstr(hashp->binary, hex, sizeof hashp->binary);
|
||||
return hashp ? fromhexstr(hashp->binary, hex, sizeof hashp->binary) : is_xstring(hex, RHIZOME_FILEHASH_STRLEN) ? 0 : -1;
|
||||
}
|
||||
|
||||
int strn_to_rhizome_filehash_t(rhizome_filehash_t *hashp, const char *hex, const char **endp)
|
||||
@ -119,27 +122,7 @@ int strn_to_rhizome_filehash_t(rhizome_filehash_t *hashp, const char *hex, const
|
||||
|
||||
int str_to_rhizome_bk_t(rhizome_bk_t *bkp, const char *hex)
|
||||
{
|
||||
return fromhexstr(bkp->binary, hex, sizeof bkp->binary);
|
||||
}
|
||||
|
||||
int rhizome_strn_is_manifest_id(const char *id)
|
||||
{
|
||||
return is_xsubstring(id, RHIZOME_MANIFEST_ID_STRLEN);
|
||||
}
|
||||
|
||||
int rhizome_str_is_manifest_id(const char *id)
|
||||
{
|
||||
return is_xstring(id, RHIZOME_MANIFEST_ID_STRLEN);
|
||||
}
|
||||
|
||||
int rhizome_strn_is_bundle_key(const char *key)
|
||||
{
|
||||
return is_xsubstring(key, RHIZOME_BUNDLE_KEY_STRLEN);
|
||||
}
|
||||
|
||||
int rhizome_str_is_bundle_key(const char *key)
|
||||
{
|
||||
return is_xstring(key, RHIZOME_BUNDLE_KEY_STRLEN);
|
||||
return bkp ? fromhexstr(bkp->binary, hex, sizeof bkp->binary) : is_xstring(hex, RHIZOME_BUNDLE_KEY_STRLEN) ? 0 : -1;
|
||||
}
|
||||
|
||||
int rhizome_strn_is_bundle_crypt_key(const char *key)
|
||||
@ -152,16 +135,6 @@ int rhizome_str_is_bundle_crypt_key(const char *key)
|
||||
return is_xstring(key, RHIZOME_CRYPT_KEY_STRLEN);
|
||||
}
|
||||
|
||||
int rhizome_strn_is_file_hash(const char *hash)
|
||||
{
|
||||
return is_xsubstring(hash, RHIZOME_FILEHASH_STRLEN);
|
||||
}
|
||||
|
||||
int rhizome_str_is_file_hash(const char *hash)
|
||||
{
|
||||
return is_xstring(hash, RHIZOME_FILEHASH_STRLEN);
|
||||
}
|
||||
|
||||
int rhizome_str_is_manifest_service(const char *text)
|
||||
{
|
||||
if (text[0] == '\0')
|
||||
|
@ -1,3 +1,21 @@
|
||||
/*
|
||||
Serval DNA directory service client
|
||||
Copyright (C) 2013 Serval Project, Inc.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
@ -1,3 +1,21 @@
|
||||
/*
|
||||
Serval DNA directory service
|
||||
Copyright (C) 2013 Serval Project, Inc.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_POLL_H
|
||||
#include <poll.h>
|
||||
|
19
fakeradio.c
19
fakeradio.c
@ -1,3 +1,22 @@
|
||||
/*
|
||||
Serval DNA radio serial modem simulator
|
||||
Copyright (C) 2013 Serval Project, Inc.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
19
fifo.c
19
fifo.c
@ -1,3 +1,22 @@
|
||||
/*
|
||||
Serval DNA FIFO primitives
|
||||
Copyright (C) 2012 Serval Project, Inc.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This is a simple FIFO implementation using a circular buffer.
|
||||
*
|
||||
|
26
fifo.h
26
fifo.h
@ -1,3 +1,24 @@
|
||||
/*
|
||||
Serval DNA FIFO primitives
|
||||
Copyright (C) 2012 Serval Project, Inc.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
struct fifo;
|
||||
|
||||
struct fifo *fifo_alloc(unsigned int size);
|
||||
void fifo_free(struct fifo *fifo);
|
||||
void fifo_reset(struct fifo *fifo);
|
||||
@ -6,8 +27,3 @@ unsigned int fifo_get(struct fifo *fifo, uint8_t *buffer, unsigned int len);
|
||||
unsigned int fifo_unget(struct fifo *fifo, uint8_t *buffer, unsigned int len);
|
||||
unsigned int fifo_avail(struct fifo *fifo);
|
||||
unsigned int fifo_space(struct fifo *fifo);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
18
golay.c
18
golay.c
@ -1,3 +1,21 @@
|
||||
/*
|
||||
Serval DNA Golay coding
|
||||
Copyright (C) 2013 Serval Project, Inc.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#define POLY 0xAE3 /* or use the other polynomial, 0xC75 */
|
||||
#include <inttypes.h>
|
||||
|
20
golay.h
20
golay.h
@ -1,3 +1,21 @@
|
||||
/*
|
||||
Serval DNA Golay coding
|
||||
Copyright (C) 2013 Serval Project, Inc.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef __SERVALD_GOLAY_H
|
||||
#define __SERVALD_GOLAY_H
|
||||
@ -5,4 +23,4 @@
|
||||
int golay_encode(uint8_t *data);
|
||||
int golay_decode(int *errs, uint8_t *data);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -1,5 +1,7 @@
|
||||
/*
|
||||
Copyright (C) 2010-2012 Paul Gardner-Stephen, Serval Project.
|
||||
Serval DNA keyring
|
||||
Copyright (C) 2013 Serval Project, Inc.
|
||||
Copyright (C) 2010-2012 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
|
||||
|
20
keyring.h
20
keyring.h
@ -1,3 +1,23 @@
|
||||
/*
|
||||
Serval DNA keyring
|
||||
Copyright (C) 2013 Serval Project, Inc.
|
||||
Copyright (C) 2010-2012 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.
|
||||
*/
|
||||
|
||||
#ifndef __SERVALD_KEYRING_H
|
||||
#define __SERVALD_KEYRING_H
|
||||
|
||||
|
54
log.c
54
log.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Serval DNA logging.
|
||||
Serval DNA logging
|
||||
Copyright 2013 Serval Project Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
@ -717,30 +717,6 @@ void logConfigChanged()
|
||||
logFlush();
|
||||
}
|
||||
|
||||
int logDump(int level, struct __sourceloc whence, char *name, const unsigned char *addr, size_t len)
|
||||
{
|
||||
if (level != LOG_LEVEL_SILENT) {
|
||||
char buf[100];
|
||||
size_t i;
|
||||
if (name)
|
||||
logMessage(level, whence, "Dump of %s", name);
|
||||
for(i = 0; i < len; i += 16) {
|
||||
strbuf b = strbuf_local(buf, sizeof buf);
|
||||
strbuf_sprintf(b, " %04zx :", i);
|
||||
int j;
|
||||
for (j = 0; j < 16 && i + j < len; j++)
|
||||
strbuf_sprintf(b, " %02x", addr[i + j]);
|
||||
for (; j < 16; j++)
|
||||
strbuf_puts(b, " ");
|
||||
strbuf_puts(b, " ");
|
||||
for (j = 0; j < 16 && i + j < len; j++)
|
||||
strbuf_sprintf(b, "%c", addr[i+j] >= ' ' && addr[i+j] < 0x7f ? addr[i+j] : '.');
|
||||
logMessage(level, whence, "%s", strbuf_str(b));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
ssize_t get_self_executable_path(char *buf, size_t len)
|
||||
{
|
||||
#if defined(linux)
|
||||
@ -860,31 +836,3 @@ int log_backtrace(int level, struct __sourceloc whence)
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *log_level_as_string(int level)
|
||||
{
|
||||
switch (level) {
|
||||
case LOG_LEVEL_SILENT: return "silent";
|
||||
case LOG_LEVEL_DEBUG: return "debug";
|
||||
case LOG_LEVEL_INFO: return "info";
|
||||
case LOG_LEVEL_HINT: return "hint";
|
||||
case LOG_LEVEL_WARN: return "warn";
|
||||
case LOG_LEVEL_ERROR: return "error";
|
||||
case LOG_LEVEL_FATAL: return "fatal";
|
||||
case LOG_LEVEL_NONE: return "none";
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int string_to_log_level(const char *text)
|
||||
{
|
||||
if (strcasecmp(text, "none") == 0) return LOG_LEVEL_NONE;
|
||||
if (strcasecmp(text, "fatal") == 0) return LOG_LEVEL_FATAL;
|
||||
if (strcasecmp(text, "error") == 0) return LOG_LEVEL_ERROR;
|
||||
if (strcasecmp(text, "warn") == 0) return LOG_LEVEL_WARN;
|
||||
if (strcasecmp(text, "hint") == 0) return LOG_LEVEL_HINT;
|
||||
if (strcasecmp(text, "info") == 0) return LOG_LEVEL_INFO;
|
||||
if (strcasecmp(text, "debug") == 0) return LOG_LEVEL_DEBUG;
|
||||
if (strcasecmp(text, "silent") == 0) return LOG_LEVEL_SILENT;
|
||||
return LOG_LEVEL_INVALID;
|
||||
}
|
||||
|
73
log_util.c
Normal file
73
log_util.c
Normal file
@ -0,0 +1,73 @@
|
||||
/*
|
||||
Serval DNA logging utility functions
|
||||
Copyright 2013 Serval Project Inc.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#include "log.h"
|
||||
#include "strbuf.h"
|
||||
|
||||
int logDump(int level, struct __sourceloc whence, char *name, const unsigned char *addr, size_t len)
|
||||
{
|
||||
if (level != LOG_LEVEL_SILENT) {
|
||||
char buf[100];
|
||||
size_t i;
|
||||
if (name)
|
||||
logMessage(level, whence, "Dump of %s", name);
|
||||
for(i = 0; i < len; i += 16) {
|
||||
strbuf b = strbuf_local(buf, sizeof buf);
|
||||
strbuf_sprintf(b, " %04zx :", i);
|
||||
int j;
|
||||
for (j = 0; j < 16 && i + j < len; j++)
|
||||
strbuf_sprintf(b, " %02x", addr[i + j]);
|
||||
for (; j < 16; j++)
|
||||
strbuf_puts(b, " ");
|
||||
strbuf_puts(b, " ");
|
||||
for (j = 0; j < 16 && i + j < len; j++)
|
||||
strbuf_sprintf(b, "%c", addr[i+j] >= ' ' && addr[i+j] < 0x7f ? addr[i+j] : '.');
|
||||
logMessage(level, whence, "%s", strbuf_str(b));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *log_level_as_string(int level)
|
||||
{
|
||||
switch (level) {
|
||||
case LOG_LEVEL_SILENT: return "silent";
|
||||
case LOG_LEVEL_DEBUG: return "debug";
|
||||
case LOG_LEVEL_INFO: return "info";
|
||||
case LOG_LEVEL_HINT: return "hint";
|
||||
case LOG_LEVEL_WARN: return "warn";
|
||||
case LOG_LEVEL_ERROR: return "error";
|
||||
case LOG_LEVEL_FATAL: return "fatal";
|
||||
case LOG_LEVEL_NONE: return "none";
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int string_to_log_level(const char *text)
|
||||
{
|
||||
if (strcasecmp(text, "none") == 0) return LOG_LEVEL_NONE;
|
||||
if (strcasecmp(text, "fatal") == 0) return LOG_LEVEL_FATAL;
|
||||
if (strcasecmp(text, "error") == 0) return LOG_LEVEL_ERROR;
|
||||
if (strcasecmp(text, "warn") == 0) return LOG_LEVEL_WARN;
|
||||
if (strcasecmp(text, "hint") == 0) return LOG_LEVEL_HINT;
|
||||
if (strcasecmp(text, "info") == 0) return LOG_LEVEL_INFO;
|
||||
if (strcasecmp(text, "debug") == 0) return LOG_LEVEL_DEBUG;
|
||||
if (strcasecmp(text, "silent") == 0) return LOG_LEVEL_SILENT;
|
||||
return LOG_LEVEL_INVALID;
|
||||
}
|
74
mdp_net.c
Normal file
74
mdp_net.c
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
Copyright (C) 2013 Serval Project, Inc.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#include "socket.h"
|
||||
#include "conf.h"
|
||||
#include "log.h"
|
||||
|
||||
ssize_t recvwithttl(int sock,unsigned char *buffer, size_t bufferlen,int *ttl, struct socket_address *recvaddr)
|
||||
{
|
||||
struct msghdr msg;
|
||||
struct iovec iov[1];
|
||||
struct cmsghdr cmsgcmsg[16];
|
||||
iov[0].iov_base=buffer;
|
||||
iov[0].iov_len=bufferlen;
|
||||
bzero(&msg,sizeof(msg));
|
||||
msg.msg_name = &recvaddr->store;
|
||||
msg.msg_namelen = recvaddr->addrlen;
|
||||
msg.msg_iov = &iov[0];
|
||||
msg.msg_iovlen = 1;
|
||||
msg.msg_control = cmsgcmsg;
|
||||
msg.msg_controllen = sizeof cmsgcmsg;
|
||||
msg.msg_flags = 0;
|
||||
|
||||
ssize_t len = recvmsg(sock,&msg,0);
|
||||
if (len == -1 && errno != EAGAIN && errno != EWOULDBLOCK)
|
||||
return WHYF_perror("recvmsg(%d,%p,0)", sock, &msg);
|
||||
|
||||
#if 0
|
||||
if (config.debug.packetrx) {
|
||||
DEBUGF("recvmsg returned %d (flags=%d, msg_controllen=%d)", (int) len, msg.msg_flags, (int)msg.msg_controllen);
|
||||
dump("received data", buffer, len);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (len > 0) {
|
||||
struct cmsghdr *cmsg;
|
||||
for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
|
||||
if ( cmsg->cmsg_level == IPPROTO_IP
|
||||
&& ((cmsg->cmsg_type == IP_RECVTTL) || (cmsg->cmsg_type == IP_TTL))
|
||||
&& cmsg->cmsg_len
|
||||
) {
|
||||
if (config.debug.packetrx)
|
||||
DEBUGF(" TTL (%p) data location resolves to %p", ttl,CMSG_DATA(cmsg));
|
||||
if (CMSG_DATA(cmsg)) {
|
||||
*ttl = *(unsigned char *) CMSG_DATA(cmsg);
|
||||
if (config.debug.packetrx)
|
||||
DEBUGF(" TTL of packet is %d", *ttl);
|
||||
}
|
||||
} else {
|
||||
if (config.debug.packetrx)
|
||||
DEBUGF("I didn't expect to see level=%02x, type=%02x",
|
||||
cmsg->cmsg_level,cmsg->cmsg_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
recvaddr->addrlen = msg.msg_namelen;
|
||||
|
||||
return len;
|
||||
}
|
26
meshms.c
26
meshms.c
@ -1,3 +1,22 @@
|
||||
/*
|
||||
Serval DNA MeshMS
|
||||
Copyright (C) 2013 Serval Project, Inc.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include "serval.h"
|
||||
#include "rhizome.h"
|
||||
@ -385,10 +404,6 @@ static int update_conversation(const sid_t *my_sid, struct conversations *conv){
|
||||
if (config.debug.meshms)
|
||||
DEBUG("Locating their last message");
|
||||
|
||||
// find the offset of their last message
|
||||
if (rhizome_retrieve_manifest(&conv->their_ply.bundle_id, m_theirs))
|
||||
goto end;
|
||||
|
||||
if (ply_read_open(&ply, &conv->their_ply.bundle_id, m_theirs))
|
||||
goto end;
|
||||
|
||||
@ -421,9 +436,6 @@ static int update_conversation(const sid_t *my_sid, struct conversations *conv){
|
||||
m_ours = rhizome_new_manifest();
|
||||
if (!m_ours)
|
||||
goto end;
|
||||
if (rhizome_retrieve_manifest(&conv->my_ply.bundle_id, m_ours))
|
||||
goto end;
|
||||
|
||||
if (ply_read_open(&ply, &conv->my_ply.bundle_id, m_ours))
|
||||
goto end;
|
||||
|
||||
|
53
net.c
53
net.c
@ -138,56 +138,3 @@ ssize_t _write_str_nonblock(int fd, const char *str, struct __sourceloc __whence
|
||||
{
|
||||
return _write_all_nonblock(fd, str, strlen(str), __whence);
|
||||
}
|
||||
|
||||
ssize_t recvwithttl(int sock,unsigned char *buffer, size_t bufferlen,int *ttl, struct socket_address *recvaddr)
|
||||
{
|
||||
struct msghdr msg;
|
||||
struct iovec iov[1];
|
||||
struct cmsghdr cmsgcmsg[16];
|
||||
iov[0].iov_base=buffer;
|
||||
iov[0].iov_len=bufferlen;
|
||||
bzero(&msg,sizeof(msg));
|
||||
msg.msg_name = &recvaddr->store;
|
||||
msg.msg_namelen = recvaddr->addrlen;
|
||||
msg.msg_iov = &iov[0];
|
||||
msg.msg_iovlen = 1;
|
||||
msg.msg_control = cmsgcmsg;
|
||||
msg.msg_controllen = sizeof cmsgcmsg;
|
||||
msg.msg_flags = 0;
|
||||
|
||||
ssize_t len = recvmsg(sock,&msg,0);
|
||||
if (len == -1 && errno != EAGAIN && errno != EWOULDBLOCK)
|
||||
return WHYF_perror("recvmsg(%d,%p,0)", sock, &msg);
|
||||
|
||||
#if 0
|
||||
if (config.debug.packetrx) {
|
||||
DEBUGF("recvmsg returned %d (flags=%d, msg_controllen=%d)", (int) len, msg.msg_flags, (int)msg.msg_controllen);
|
||||
dump("received data", buffer, len);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (len > 0) {
|
||||
struct cmsghdr *cmsg;
|
||||
for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
|
||||
if ( cmsg->cmsg_level == IPPROTO_IP
|
||||
&& ((cmsg->cmsg_type == IP_RECVTTL) || (cmsg->cmsg_type == IP_TTL))
|
||||
&& cmsg->cmsg_len
|
||||
) {
|
||||
if (config.debug.packetrx)
|
||||
DEBUGF(" TTL (%p) data location resolves to %p", ttl,CMSG_DATA(cmsg));
|
||||
if (CMSG_DATA(cmsg)) {
|
||||
*ttl = *(unsigned char *) CMSG_DATA(cmsg);
|
||||
if (config.debug.packetrx)
|
||||
DEBUGF(" TTL of packet is %d", *ttl);
|
||||
}
|
||||
} else {
|
||||
if (config.debug.packetrx)
|
||||
DEBUGF("I didn't expect to see level=%02x, type=%02x",
|
||||
cmsg->cmsg_level,cmsg->cmsg_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
recvaddr->addrlen = msg.msg_namelen;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
3
net.h
3
net.h
@ -53,7 +53,4 @@ ssize_t _writev_all(int fd, const struct iovec *iov, int iovcnt, struct __source
|
||||
ssize_t _write_str(int fd, const char *str, struct __sourceloc __whence);
|
||||
ssize_t _write_str_nonblock(int fd, const char *str, struct __sourceloc __whence);
|
||||
|
||||
struct socket_address;
|
||||
ssize_t recvwithttl(int sock, unsigned char *buffer, size_t bufferlen, int *ttl, struct socket_address *);
|
||||
|
||||
#endif // __SERVALD_NET_H
|
||||
|
@ -1,4 +1,23 @@
|
||||
#include <assert.h>
|
||||
/*
|
||||
Serval DNA MDP overlay network link tracking
|
||||
Copyright (C) 2012-2013 Serval Project, Inc.
|
||||
Copyright (C) 2010-2012 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.
|
||||
*/
|
||||
|
||||
#include "serval.h"
|
||||
#include "conf.h"
|
||||
#include "str.h"
|
||||
|
@ -1,5 +1,7 @@
|
||||
/*
|
||||
Copyright (C) 2010-2012 Paul Gardner-Stephen, Serval Project.
|
||||
Serval DNA MDP overlay network
|
||||
Copyright (C) 2012-2013 Serval Project, Inc.
|
||||
Copyright (C) 2010-2012 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
|
||||
|
@ -1,3 +1,23 @@
|
||||
/*
|
||||
Serval DNA packet radio interface
|
||||
Copyright (C) 2013 Serval Project, Inc.
|
||||
Copyright (C) 2013 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.
|
||||
*/
|
||||
|
||||
#include "serval.h"
|
||||
#include "conf.h"
|
||||
#include <termios.h>
|
||||
|
19
pa_phone.c
19
pa_phone.c
@ -1,3 +1,22 @@
|
||||
/*
|
||||
Serval DNA Portaudio phone interface
|
||||
Copyright (C) 2012 Serval Project, Inc.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#include <codec2.h>
|
||||
#include <spandsp.h>
|
||||
#include "fifo.h"
|
||||
|
@ -1,6 +1,7 @@
|
||||
/*
|
||||
Serval Distributed Numbering Architecture (DNA)
|
||||
Copyright (C) 2010 Paul Gardner-Stephen
|
||||
Serval DNA Rhizome file distribution
|
||||
Copyright (C) 2012-2013 Serval Project, Inc.
|
||||
Copyright (C) 2011-2012 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
|
||||
|
14
rhizome.h
14
rhizome.h
@ -37,17 +37,21 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// TODO Rename MANIFEST_ID to BUNDLE_ID
|
||||
#define RHIZOME_MANIFEST_ID_BYTES crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES
|
||||
#define RHIZOME_MANIFEST_ID_STRLEN (RHIZOME_MANIFEST_ID_BYTES * 2)
|
||||
#define RHIZOME_BUNDLE_KEY_BYTES (crypto_sign_edwards25519sha512batch_SECRETKEYBYTES-crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES)
|
||||
#define RHIZOME_BUNDLE_KEY_STRLEN (RHIZOME_BUNDLE_KEY_BYTES * 2)
|
||||
#define RHIZOME_BUNDLE_ID_BYTES crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES
|
||||
#define RHIZOME_BUNDLE_ID_STRLEN (RHIZOME_BUNDLE_ID_BYTES * 2)
|
||||
#define RHIZOME_BUNDLE_KEY_BYTES (crypto_sign_edwards25519sha512batch_SECRETKEYBYTES - crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES)
|
||||
#define RHIZOME_BUNDLE_KEY_STRLEN (RHIZOME_BUNDLE_KEY_BYTES * 2)
|
||||
#define RHIZOME_FILEHASH_BYTES SHA512_DIGEST_LENGTH
|
||||
#define RHIZOME_FILEHASH_STRLEN (RHIZOME_FILEHASH_BYTES * 2)
|
||||
|
||||
#define RHIZOME_CRYPT_KEY_BYTES crypto_stream_xsalsa20_ref_KEYBYTES
|
||||
#define RHIZOME_CRYPT_KEY_STRLEN (RHIZOME_CRYPT_KEY_BYTES * 2)
|
||||
|
||||
// TODO Rename MANIFEST_ID to BUNDLE_ID
|
||||
// The following constants are deprecated, use the BUNDLE_ID forms instead
|
||||
#define RHIZOME_MANIFEST_ID_BYTES RHIZOME_BUNDLE_ID_BYTES
|
||||
#define RHIZOME_MANIFEST_ID_STRLEN RHIZOME_BUNDLE_ID_STRLEN
|
||||
|
||||
// assumed to always be 2^n
|
||||
#define RHIZOME_CRYPT_PAGE_SIZE 4096
|
||||
|
||||
|
@ -1,3 +1,22 @@
|
||||
/*
|
||||
Serval DNA Rhizome storage
|
||||
Copyright (C) 2013 Serval Project, Inc.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include "serval.h"
|
||||
#include "rhizome.h"
|
||||
|
19
route_link.c
19
route_link.c
@ -1,3 +1,22 @@
|
||||
/*
|
||||
Serval DNA link state routing
|
||||
Copyright (C) 2013 Serval Project, Inc.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#include "serval.h"
|
||||
#include "overlay_address.h"
|
||||
#include "overlay_buffer.h"
|
||||
|
2
serval.h
2
serval.h
@ -213,6 +213,7 @@ extern char *batman_peerfile;
|
||||
|
||||
struct subscriber;
|
||||
struct decode_context;
|
||||
struct socket_address;
|
||||
|
||||
/* Make sure we have space to put bytes of the packet as we go along */
|
||||
#define CHECK_PACKET_LEN(B) {if (((*packet_len)+(B))>=packet_maxlen) { return WHY("Packet composition ran out of space."); } }
|
||||
@ -522,7 +523,6 @@ typedef struct overlay_mdp_frame {
|
||||
|
||||
/* Server-side MDP functions */
|
||||
int overlay_mdp_swap_src_dst(overlay_mdp_frame *mdp);
|
||||
struct socket_address;
|
||||
int overlay_mdp_dispatch(overlay_mdp_frame *mdp, struct socket_address *client);
|
||||
void overlay_mdp_encode_ports(struct overlay_buffer *plaintext, mdp_port_t dst_port, mdp_port_t src_port);
|
||||
int overlay_mdp_dnalookup_reply(const sockaddr_mdp *dstaddr, const sid_t *resolved_sidp, const char *uri, const char *did, const char *name);
|
||||
|
16
socket.h
16
socket.h
@ -1,10 +1,20 @@
|
||||
#ifndef __SERVALD_SOCKET_H
|
||||
#define __SERVALD_SOCKET_H
|
||||
|
||||
#ifndef WIN32
|
||||
#include <sys/un.h>
|
||||
#ifdef WIN32
|
||||
# include "win32/win32.h"
|
||||
#else
|
||||
# include <sys/un.h>
|
||||
# ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
# endif
|
||||
# ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include "log.h"
|
||||
|
||||
struct socket_address{
|
||||
socklen_t addrlen;
|
||||
union{
|
||||
@ -54,4 +64,6 @@ ssize_t _recv_message(struct __sourceloc, int fd, struct socket_address *address
|
||||
#define send_message(fd, address, data) _send_message(__WHENCE__, (fd), (address), (data))
|
||||
#define recv_message(fd, address, data) _recv_message(__WHENCE__, (fd), (address), (data))
|
||||
|
||||
ssize_t recvwithttl(int sock, unsigned char *buffer, size_t bufferlen, int *ttl, struct socket_address *recvaddr);
|
||||
|
||||
#endif
|
||||
|
@ -17,11 +17,13 @@ SERVAL_SOURCES = \
|
||||
$(SERVAL_BASE)http_server.c \
|
||||
$(SERVAL_BASE)keyring.c \
|
||||
$(SERVAL_BASE)log.c \
|
||||
$(SERVAL_BASE)log_util.c \
|
||||
$(SERVAL_BASE)lsif.c \
|
||||
$(SERVAL_BASE)main.c \
|
||||
$(SERVAL_BASE)radio_link.c \
|
||||
$(SERVAL_BASE)meshms.c \
|
||||
$(SERVAL_BASE)mdp_client.c \
|
||||
$(SERVAL_BASE)mdp_net.c \
|
||||
$(SERVAL_BASE)os.c \
|
||||
$(SERVAL_BASE)mem.c \
|
||||
$(SERVAL_BASE)instance.c \
|
||||
|
19
testnacl.c
19
testnacl.c
@ -1,3 +1,22 @@
|
||||
/*
|
||||
Serval DNA crypto NaCl test utility
|
||||
Copyright (C) 2011 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.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
|
@ -1,3 +1,22 @@
|
||||
/*
|
||||
Serval DNA version string
|
||||
Copyright (C) 2013 Serval Project, Inc.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef SERVALD_VERSION
|
||||
#error "SERVALD_VERSION is not defined"
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user