2010-07-13 12:15:46 +00:00
|
|
|
/*
|
2013-10-18 00:04:43 +00:00
|
|
|
Serval DNA header file
|
2012-07-30 03:28:21 +00:00
|
|
|
Copyright (C) 2010-2012 Paul Gardner-Stephen
|
2013-10-18 00:04:43 +00:00
|
|
|
Copyright (C) 2012-2013 Serval Project, Inc.
|
2010-07-13 12:15:46 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2012-07-30 03:28:21 +00:00
|
|
|
#ifndef __SERVALD_SERVALD_H
|
|
|
|
#define __SERVALD_SERVALD_H
|
2012-07-23 04:17:59 +00:00
|
|
|
|
2010-07-13 12:15:46 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <stdlib.h>
|
2012-05-10 03:23:57 +00:00
|
|
|
#include <stdarg.h>
|
2010-07-13 12:15:46 +00:00
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
#include <strings.h>
|
|
|
|
#endif
|
|
|
|
#include <string.h>
|
2011-12-01 19:14:32 +00:00
|
|
|
#include <signal.h>
|
2012-05-14 09:02:10 +00:00
|
|
|
#include <sys/types.h>
|
2011-03-30 05:04:23 +00:00
|
|
|
|
|
|
|
#ifdef WIN32
|
2013-11-12 01:09:06 +00:00
|
|
|
# include "win32/win32.h"
|
2011-03-30 05:04:23 +00:00
|
|
|
#else
|
2013-11-12 01:09:06 +00:00
|
|
|
# include <unistd.h>
|
|
|
|
# ifdef HAVE_SYS_SOCKET_H
|
|
|
|
# include <sys/socket.h>
|
|
|
|
# endif
|
|
|
|
# ifdef HAVE_NET_ROUTE_H
|
|
|
|
# include <net/route.h>
|
|
|
|
# endif
|
|
|
|
# ifdef HAVE_LINUX_IF_H
|
|
|
|
# include <linux/if.h>
|
|
|
|
# else
|
|
|
|
# ifdef HAVE_NET_IF_H
|
|
|
|
# include <net/if.h>
|
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
# ifdef HAVE_NETINET_IN_H
|
|
|
|
# include <netinet/in.h>
|
|
|
|
# endif
|
|
|
|
# ifdef HAVE_LINUX_NETLINK_H
|
|
|
|
# include <linux/netlink.h>
|
|
|
|
# endif
|
|
|
|
# ifdef HAVE_LINUX_RTNETLINK_H
|
|
|
|
# include <linux/rtnetlink.h>
|
|
|
|
# endif
|
|
|
|
# ifdef HAVE_IFADDRS_H
|
|
|
|
# include <ifaddrs.h>
|
|
|
|
# endif
|
|
|
|
# ifdef HAVE_SYS_SOCKIO_H
|
|
|
|
# include <sys/sockio.h>
|
|
|
|
# endif
|
|
|
|
# ifdef HAVE_SYS_UCRED_H
|
|
|
|
# include <sys/ucred.h>
|
|
|
|
# endif
|
|
|
|
#endif //!WIN32
|
2011-03-30 05:04:23 +00:00
|
|
|
|
|
|
|
#if !defined(FORASTERISK) && !defined(s_addr)
|
2010-07-13 12:15:46 +00:00
|
|
|
#ifdef HAVE_ARPA_INET_H
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
#else
|
2013-10-09 08:24:21 +00:00
|
|
|
typedef uint32_t in_addr_t;
|
2010-07-13 12:15:46 +00:00
|
|
|
struct in_addr {
|
|
|
|
in_addr_t s_addr;
|
|
|
|
};
|
|
|
|
#endif
|
2011-03-21 02:38:35 +00:00
|
|
|
#endif
|
2011-03-30 05:04:23 +00:00
|
|
|
|
2010-07-13 12:15:46 +00:00
|
|
|
#ifdef HAVE_SYS_SOCKET_H
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_MMAN_H
|
|
|
|
#include <sys/mman.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_TIME_H
|
|
|
|
#include <sys/time.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_NETDB_H
|
|
|
|
#include <netdb.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_CTYPE_H
|
|
|
|
#include <ctype.h>
|
|
|
|
#endif
|
2011-03-30 05:04:23 +00:00
|
|
|
|
|
|
|
#ifndef WIN32
|
2010-07-13 12:15:46 +00:00
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/un.h>
|
2011-03-30 05:04:23 +00:00
|
|
|
#endif
|
|
|
|
|
2010-07-13 12:15:46 +00:00
|
|
|
#include <fcntl.h>
|
2012-05-10 07:28:25 +00:00
|
|
|
#include <sys/stat.h>
|
2010-07-13 12:15:46 +00:00
|
|
|
|
2013-10-18 00:04:43 +00:00
|
|
|
#include "fdqueue.h"
|
2013-02-12 07:30:37 +00:00
|
|
|
#include "cli.h"
|
2012-07-29 03:05:53 +00:00
|
|
|
#include "constants.h"
|
2012-12-03 23:26:24 +00:00
|
|
|
#include "mem.h"
|
2012-08-03 07:14:05 +00:00
|
|
|
#include "xprintf.h"
|
2012-07-29 03:05:53 +00:00
|
|
|
#include "log.h"
|
2012-08-23 03:01:07 +00:00
|
|
|
#include "net.h"
|
2012-12-03 23:42:35 +00:00
|
|
|
#include "os.h"
|
2012-05-14 09:02:10 +00:00
|
|
|
|
2011-08-08 14:41:46 +00:00
|
|
|
/* UDP Port numbers for various Serval services.
|
|
|
|
The overlay mesh works over DNA */
|
2011-04-27 11:48:09 +00:00
|
|
|
#define PORT_DNA 4110
|
2010-07-13 12:15:46 +00:00
|
|
|
|
|
|
|
#define BATCH 1
|
|
|
|
#define NONBATCH 0
|
|
|
|
|
|
|
|
#define REQ_SERIAL 0
|
|
|
|
#define REQ_PARALLEL -1
|
|
|
|
#define REQ_FIRSTREPLY -2
|
|
|
|
#define REQ_REPLY -101
|
|
|
|
|
|
|
|
|
|
|
|
#define SET_NOREPLACE 1
|
|
|
|
#define SET_REPLACE 2
|
|
|
|
#define SET_NOCREATE 3
|
|
|
|
#define SET_FRAGMENT 0x80
|
|
|
|
|
|
|
|
#define WITHDATA 1
|
|
|
|
#define WITHOUTDATA 0
|
|
|
|
|
|
|
|
/* Limit packet payloads to minimise packet loss of big packets in mesh networks */
|
|
|
|
#define MAX_DATA_BYTES 256
|
|
|
|
|
2013-03-12 03:33:33 +00:00
|
|
|
|
|
|
|
extern const char version_servald[];
|
|
|
|
|
2013-10-09 08:24:21 +00:00
|
|
|
/* Fundamental types.
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct sid_binary {
|
|
|
|
unsigned char binary[SID_SIZE];
|
|
|
|
} sid_t;
|
|
|
|
|
|
|
|
#define SID_ANY ((sid_t){{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}})
|
|
|
|
#define SID_BROADCAST ((sid_t){{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}})
|
|
|
|
|
|
|
|
// is the SID entirely 0xFF?
|
|
|
|
#define is_sid_t_broadcast(SID) is_all_matching((SID).binary, sizeof (*(sid_t*)0).binary, 0xFF)
|
|
|
|
|
|
|
|
// is the SID entirely 0x00?
|
|
|
|
#define is_sid_t_any(SID) is_all_matching((SID).binary, sizeof (*(sid_t*)0).binary, 0)
|
|
|
|
|
|
|
|
#define alloca_tohex_sid_t(sid) alloca_tohex((sid).binary, sizeof (*(sid_t*)0).binary)
|
2013-11-15 06:40:33 +00:00
|
|
|
#define alloca_tohex_sid_t_trunc(sid,strlen) tohex((char *)alloca((strlen)+1), (strlen), (sid).binary)
|
2013-10-09 08:24:21 +00:00
|
|
|
|
|
|
|
int cmp_sid_t(const sid_t *a, const sid_t *b);
|
|
|
|
int str_to_sid_t(sid_t *sid, const char *hex);
|
|
|
|
int strn_to_sid_t(sid_t *sid, const char *hex, const char **endp);
|
|
|
|
|
|
|
|
#define alloca_tohex_sas(sas) alloca_tohex((sas), SAS_SIZE)
|
|
|
|
|
2012-12-07 03:39:55 +00:00
|
|
|
/*
|
|
|
|
* INSTANCE_PATH can be set via the ./configure option --enable-instance-path=<path>
|
|
|
|
*/
|
|
|
|
#ifdef INSTANCE_PATH
|
|
|
|
#define DEFAULT_INSTANCE_PATH INSTANCE_PATH
|
|
|
|
#else
|
2012-12-04 03:42:28 +00:00
|
|
|
#ifdef ANDROID
|
|
|
|
#define DEFAULT_INSTANCE_PATH "/data/data/org.servalproject/var/serval-node"
|
|
|
|
#else
|
|
|
|
#define DEFAULT_INSTANCE_PATH "/var/serval-node"
|
|
|
|
#endif
|
2012-12-07 03:39:55 +00:00
|
|
|
#endif
|
2012-12-04 03:42:28 +00:00
|
|
|
|
|
|
|
/* Handy statement for forming a path to an instance file in a char buffer whose declaration
|
|
|
|
* is in scope (so that sizeof(buf) will work). Evaluates to true if the pathname fitted into
|
|
|
|
* the provided buffer, false (0) otherwise (after logging an error).
|
|
|
|
*/
|
2013-09-19 07:49:37 +00:00
|
|
|
#define FORM_SERVAL_INSTANCE_PATH(buf, path) (formf_serval_instance_path(__WHENCE__, buf, sizeof(buf), "%s", (path)))
|
2012-12-04 03:42:28 +00:00
|
|
|
|
|
|
|
const char *serval_instancepath();
|
|
|
|
int create_serval_instance_dir();
|
2013-09-19 07:49:37 +00:00
|
|
|
int formf_serval_instance_path(struct __sourceloc, char *buf, size_t bufsiz, const char *fmt, ...) __attribute__((format(printf,4,5)));
|
|
|
|
int vformf_serval_instance_path(struct __sourceloc, char *buf, size_t bufsiz, const char *fmt, va_list);
|
2012-12-04 03:42:28 +00:00
|
|
|
void serval_setinstancepath(const char *instancepath);
|
2010-07-13 12:15:46 +00:00
|
|
|
|
2012-12-14 05:57:04 +00:00
|
|
|
#define SERVER_CONFIG_RELOAD_INTERVAL_MS 1000
|
|
|
|
|
2013-08-29 07:59:32 +00:00
|
|
|
struct cli_parsed;
|
|
|
|
|
2012-03-04 22:57:31 +00:00
|
|
|
extern int servalShutdown;
|
2010-07-13 12:15:46 +00:00
|
|
|
|
2011-08-10 13:38:59 +00:00
|
|
|
extern char *gatewayspec;
|
2011-05-06 02:27:33 +00:00
|
|
|
|
2012-05-15 03:26:10 +00:00
|
|
|
int rhizome_enabled();
|
2012-07-12 02:40:59 +00:00
|
|
|
int rhizome_http_server_running();
|
2012-05-15 03:26:10 +00:00
|
|
|
const char *rhizome_datastore_path();
|
2011-12-17 01:41:32 +00:00
|
|
|
|
2010-07-13 12:15:46 +00:00
|
|
|
#define MAX_PEERS 1024
|
|
|
|
extern int peer_count;
|
2011-04-27 11:48:09 +00:00
|
|
|
extern struct in_addr peers[MAX_PEERS];
|
2010-07-13 12:15:46 +00:00
|
|
|
|
|
|
|
extern char *outputtemplate;
|
2011-05-05 09:10:38 +00:00
|
|
|
extern char *instrumentation_file;
|
2010-07-13 12:15:46 +00:00
|
|
|
extern char *batman_socket;
|
2011-03-21 02:38:35 +00:00
|
|
|
extern char *batman_peerfile;
|
2010-07-13 12:15:46 +00:00
|
|
|
|
2012-10-03 04:29:46 +00:00
|
|
|
struct subscriber;
|
2012-10-09 01:34:02 +00:00
|
|
|
struct decode_context;
|
2012-10-03 04:29:46 +00:00
|
|
|
|
2010-07-13 12:15:46 +00:00
|
|
|
/* Make sure we have space to put bytes of the packet as we go along */
|
2012-05-24 07:41:55 +00:00
|
|
|
#define CHECK_PACKET_LEN(B) {if (((*packet_len)+(B))>=packet_maxlen) { return WHY("Packet composition ran out of space."); } }
|
2010-07-13 12:15:46 +00:00
|
|
|
|
|
|
|
extern int sock;
|
|
|
|
|
2012-12-13 07:20:09 +00:00
|
|
|
struct limit_state{
|
|
|
|
// length of time for a burst
|
|
|
|
time_ms_t burst_length;
|
|
|
|
// how many in a burst
|
|
|
|
int burst_size;
|
|
|
|
|
|
|
|
// how many have we sent in this burst so far
|
|
|
|
int sent;
|
|
|
|
// when can we allow another burst
|
|
|
|
time_ms_t next_interval;
|
|
|
|
};
|
|
|
|
|
2012-08-27 00:34:59 +00:00
|
|
|
struct overlay_buffer;
|
2012-11-20 06:11:06 +00:00
|
|
|
struct overlay_frame;
|
2012-11-23 05:55:32 +00:00
|
|
|
struct broadcast;
|
|
|
|
|
2013-06-19 05:57:17 +00:00
|
|
|
#define STRUCT_SCHED_ENT_UNUSED {.poll.fd=-1, ._poll_index=-1,}
|
2012-07-02 03:49:54 +00:00
|
|
|
|
2011-08-08 14:41:46 +00:00
|
|
|
extern int overlayMode;
|
2012-04-13 18:36:08 +00:00
|
|
|
|
2012-07-25 07:23:44 +00:00
|
|
|
#define INTERFACE_STATE_FREE 0
|
|
|
|
#define INTERFACE_STATE_UP 1
|
|
|
|
#define INTERFACE_STATE_DOWN 2
|
|
|
|
#define INTERFACE_STATE_DETECTING 3
|
|
|
|
|
2013-02-04 19:12:50 +00:00
|
|
|
// Specify the size of the receive buffer.
|
|
|
|
// This effectively sets the MRU for packet radio interfaces
|
|
|
|
// where we have to buffer packets on the receive side
|
|
|
|
#define OVERLAY_INTERFACE_RX_BUFFER_SIZE 2048
|
2013-02-05 04:56:40 +00:00
|
|
|
// TX buffer must handle FEC encoded and encapsulated data, so needs to be
|
|
|
|
// larger.
|
|
|
|
#define OVERLAY_INTERFACE_TX_BUFFER_SIZE (2+2048*2)
|
2013-02-14 19:37:51 +00:00
|
|
|
// buffer size for reading RFD900 RSSI reports
|
|
|
|
// (minimum length is ~87 bytes, and includes 13 numeric fields
|
|
|
|
// each of which may presumably end up being ~10 bytes, so 256 bytes
|
|
|
|
// should be a safe size).
|
|
|
|
#define RSSI_TEXT_SIZE 256
|
2013-02-04 19:12:50 +00:00
|
|
|
|
2013-02-14 03:48:56 +00:00
|
|
|
struct slip_decode_state{
|
2013-02-14 19:37:51 +00:00
|
|
|
#define SLIP_FORMAT_SLIP 0
|
|
|
|
#define SLIP_FORMAT_UPPER7 1
|
2013-08-29 06:20:13 +00:00
|
|
|
#define SLIP_FORMAT_MAVLINK 2
|
2013-02-14 19:37:51 +00:00
|
|
|
int encapsulator;
|
2013-02-14 03:48:56 +00:00
|
|
|
int state;
|
|
|
|
unsigned char *src;
|
|
|
|
int src_size;
|
2013-02-14 19:37:51 +00:00
|
|
|
char rssi_text[RSSI_TEXT_SIZE];
|
|
|
|
int rssi_len;
|
|
|
|
int packet_length;
|
2013-02-14 03:48:56 +00:00
|
|
|
unsigned char dst[OVERLAY_INTERFACE_RX_BUFFER_SIZE];
|
2013-02-15 01:52:31 +00:00
|
|
|
uint32_t crc;
|
2013-02-14 03:48:56 +00:00
|
|
|
int src_offset;
|
|
|
|
int dst_offset;
|
|
|
|
};
|
|
|
|
|
2013-06-04 02:42:45 +00:00
|
|
|
struct overlay_interface;
|
|
|
|
|
2013-08-08 05:50:31 +00:00
|
|
|
// where should packets be sent to?
|
2013-06-04 02:42:45 +00:00
|
|
|
struct network_destination {
|
2013-08-08 05:50:31 +00:00
|
|
|
int _ref_count;
|
|
|
|
|
|
|
|
// which interface are we actually sending packets out of
|
2013-06-04 02:42:45 +00:00
|
|
|
struct overlay_interface *interface;
|
2013-08-08 05:50:31 +00:00
|
|
|
|
|
|
|
// The IPv4 destination address, this may be the interface broadcast address.
|
|
|
|
struct sockaddr_in address;
|
|
|
|
|
|
|
|
// should outgoing packets be marked as unicast?
|
|
|
|
char unicast;
|
|
|
|
|
|
|
|
char packet_version;
|
|
|
|
|
|
|
|
// should we aggregate packets, or send one at a time
|
|
|
|
char encapsulation;
|
|
|
|
|
|
|
|
// time last packet was sent
|
|
|
|
time_ms_t last_tx;
|
2013-08-29 05:35:32 +00:00
|
|
|
|
|
|
|
int min_rtt;
|
|
|
|
int max_rtt;
|
|
|
|
int resend_delay;
|
2013-08-08 05:50:31 +00:00
|
|
|
|
|
|
|
// sequence number of last packet sent to this destination.
|
|
|
|
// Used to allow NACKs that can request retransmission of recent packets.
|
|
|
|
int sequence_number;
|
|
|
|
|
|
|
|
// rate limit for outgoing packets
|
|
|
|
struct limit_state transfer_limit;
|
|
|
|
|
2013-10-08 06:06:07 +00:00
|
|
|
/* Number of milli-seconds per tick for this interface, which is basically
|
|
|
|
* related to the the typical TX range divided by the maximum expected
|
|
|
|
* speed of nodes in the network. This means that short-range communications
|
|
|
|
* has a higher bandwidth requirement than long-range communications because
|
|
|
|
* the tick interval has to be shorter to still allow fast-convergence time
|
|
|
|
* to allow for mobility.
|
|
|
|
*
|
|
|
|
* For wifi (nominal range 100m) it is usually 500ms.
|
|
|
|
* For ~100K ISM915MHz (nominal range 1000m) it will probably be about 5000ms.
|
|
|
|
* For ~10K ISM915MHz (nominal range ~3000m) it will probably be about 15000ms.
|
|
|
|
*
|
|
|
|
* These figures will be refined over time, and we will allow people to set
|
|
|
|
* them per-interface.
|
2013-06-04 02:42:45 +00:00
|
|
|
*/
|
2013-10-08 06:06:07 +00:00
|
|
|
unsigned tick_ms;
|
|
|
|
|
|
|
|
// Number of milliseconds of no packets until we assume the link is dead.
|
|
|
|
unsigned reachable_timeout_ms;
|
2013-06-04 02:42:45 +00:00
|
|
|
};
|
|
|
|
|
2013-08-08 05:50:31 +00:00
|
|
|
struct network_destination * new_destination(struct overlay_interface *interface, char encapsulation);
|
|
|
|
struct network_destination * create_unicast_destination(struct sockaddr_in addr, struct overlay_interface *interface);
|
|
|
|
struct network_destination * add_destination_ref(struct network_destination *ref);
|
|
|
|
void release_destination_ref(struct network_destination *ref);
|
2013-08-09 02:48:14 +00:00
|
|
|
int set_destination_ref(struct network_destination **ptr, struct network_destination *ref);
|
2013-08-08 05:50:31 +00:00
|
|
|
|
2011-08-08 06:41:05 +00:00
|
|
|
typedef struct overlay_interface {
|
2012-07-02 03:49:54 +00:00
|
|
|
struct sched_ent alarm;
|
2013-02-14 03:48:56 +00:00
|
|
|
|
2012-11-09 03:10:55 +00:00
|
|
|
char name[256];
|
2013-02-14 03:48:56 +00:00
|
|
|
|
|
|
|
int recv_offset; /* file offset */
|
2013-09-11 07:45:43 +00:00
|
|
|
|
2013-09-23 01:41:58 +00:00
|
|
|
int recv_count;
|
|
|
|
int tx_count;
|
|
|
|
|
2013-10-30 06:39:37 +00:00
|
|
|
struct radio_link_state *radio_link_state;
|
2013-02-14 03:48:56 +00:00
|
|
|
|
|
|
|
// copy of ifconfig flags
|
2013-08-12 04:51:31 +00:00
|
|
|
uint16_t drop_packets;
|
|
|
|
char drop_broadcasts;
|
2013-01-29 00:57:13 +00:00
|
|
|
char drop_unicasts;
|
2011-08-08 06:41:05 +00:00
|
|
|
int port;
|
|
|
|
int type;
|
2013-02-14 03:48:56 +00:00
|
|
|
int socket_type;
|
|
|
|
char send_broadcasts;
|
|
|
|
char prefer_unicast;
|
2013-08-08 05:50:31 +00:00
|
|
|
/* Not necessarily the real MTU, but the largest frame size we are willing to TX.
|
|
|
|
For radio links the actual maximum and the maximum that is likely to be delivered reliably are
|
|
|
|
potentially two quite different values. */
|
|
|
|
int mtu;
|
2013-02-14 03:48:56 +00:00
|
|
|
// can we use this interface for routes to addresses in other subnets?
|
|
|
|
int default_route;
|
2013-07-16 05:46:07 +00:00
|
|
|
// should we log more debug info on this interace? eg hex dumps of packets
|
2013-07-15 05:59:14 +00:00
|
|
|
char debug;
|
2013-07-16 05:46:07 +00:00
|
|
|
char local_echo;
|
|
|
|
|
2013-04-26 05:46:51 +00:00
|
|
|
unsigned int uartbps; // set serial port speed (which might be different from link speed)
|
|
|
|
int ctsrts; // enabled hardware flow control if non-zero
|
2013-04-30 07:05:45 +00:00
|
|
|
|
2013-08-08 05:50:31 +00:00
|
|
|
struct network_destination *destination;
|
2013-04-30 07:05:45 +00:00
|
|
|
|
2013-08-08 05:50:31 +00:00
|
|
|
// can we assume that we will only receive packets from one device?
|
|
|
|
char point_to_point;
|
|
|
|
struct subscriber *other_device;
|
|
|
|
|
2013-06-04 02:42:45 +00:00
|
|
|
// the actual address of the interface.
|
2012-07-25 07:23:44 +00:00
|
|
|
struct sockaddr_in address;
|
2012-08-08 05:27:27 +00:00
|
|
|
struct in_addr netmask;
|
2012-07-02 03:49:54 +00:00
|
|
|
|
2012-07-25 07:23:44 +00:00
|
|
|
/* Use one of the INTERFACE_STATE_* constants to indicate the state of this interface.
|
|
|
|
If the interface stops working or disappears, it will be marked as DOWN and the socket closed.
|
|
|
|
But if it comes back up again, we should try to reuse this structure, even if the broadcast address has changed.
|
|
|
|
*/
|
2013-10-09 08:24:21 +00:00
|
|
|
int state;
|
2011-08-08 06:41:05 +00:00
|
|
|
} overlay_interface;
|
|
|
|
|
|
|
|
/* Maximum interface count is rather arbitrary.
|
2012-07-02 03:49:54 +00:00
|
|
|
Memory consumption is O(n) with respect to this parameter, so let's not make it too big for now.
|
|
|
|
*/
|
2011-08-08 06:41:05 +00:00
|
|
|
extern overlay_interface overlay_interfaces[OVERLAY_MAX_INTERFACES];
|
2012-01-08 17:49:52 +00:00
|
|
|
extern int overlay_last_interface_number; // used to remember where a packet came from
|
2011-08-20 09:36:15 +00:00
|
|
|
extern unsigned int overlay_sequence_number;
|
2011-08-08 06:41:05 +00:00
|
|
|
|
2012-07-02 03:49:54 +00:00
|
|
|
int server_pid();
|
|
|
|
void server_save_argv(int argc, const char *const *argv);
|
2013-08-29 07:59:32 +00:00
|
|
|
int server(const struct cli_parsed *parsed);
|
2012-07-02 03:49:54 +00:00
|
|
|
int server_create_stopfile();
|
|
|
|
int server_remove_stopfile();
|
|
|
|
int server_check_stopfile();
|
|
|
|
void serverCleanUp();
|
|
|
|
int isTransactionInCache(unsigned char *transaction_id);
|
|
|
|
void insertTransactionInCache(unsigned char *transaction_id);
|
|
|
|
|
2012-08-27 00:34:59 +00:00
|
|
|
int overlay_forward_payload(struct overlay_frame *f);
|
2012-07-03 06:06:51 +00:00
|
|
|
int packetOkOverlay(struct overlay_interface *interface,unsigned char *packet, size_t len,
|
2013-10-08 03:41:00 +00:00
|
|
|
int recvttl, struct sockaddr *recvaddr, socklen_t recvaddrlen);
|
2013-02-07 04:46:07 +00:00
|
|
|
int parseMdpPacketHeader(struct decode_context *context, struct overlay_frame *frame,
|
|
|
|
struct overlay_buffer *buffer, struct subscriber **nexthop);
|
|
|
|
int parseEnvelopeHeader(struct decode_context *context, struct overlay_interface *interface,
|
|
|
|
struct sockaddr_in *addr, struct overlay_buffer *buffer);
|
|
|
|
int process_incoming_frame(time_ms_t now, struct overlay_interface *interface,
|
|
|
|
struct overlay_frame *f, struct decode_context *context);
|
2012-07-02 03:49:54 +00:00
|
|
|
|
2012-08-27 00:34:59 +00:00
|
|
|
int overlay_frame_process(struct overlay_interface *interface, struct overlay_frame *f);
|
|
|
|
int overlay_frame_resolve_addresses(struct overlay_frame *f);
|
2012-07-02 03:49:54 +00:00
|
|
|
|
2012-08-09 02:44:32 +00:00
|
|
|
time_ms_t overlay_time_until_next_tick();
|
2012-07-02 03:49:54 +00:00
|
|
|
|
2013-08-08 05:50:31 +00:00
|
|
|
int overlay_frame_append_payload(struct decode_context *context, int encapsulation,
|
2013-08-30 07:54:52 +00:00
|
|
|
struct overlay_frame *p, struct overlay_buffer *b,
|
|
|
|
char will_retransmit);
|
2013-05-24 04:22:31 +00:00
|
|
|
int overlay_packet_init_header(int packet_version, int encapsulation,
|
2013-02-14 03:48:56 +00:00
|
|
|
struct decode_context *context, struct overlay_buffer *buff,
|
2013-05-15 02:03:43 +00:00
|
|
|
char unicast, char interface, int seq);
|
2012-05-07 04:19:38 +00:00
|
|
|
int overlay_interface_args(const char *arg);
|
2013-02-12 00:04:04 +00:00
|
|
|
void overlay_rhizome_advertise(struct sched_ent *alarm);
|
2013-09-24 02:31:00 +00:00
|
|
|
void rhizome_sync_status_html(struct strbuf *b, struct subscriber *subscriber);
|
2013-09-24 04:53:40 +00:00
|
|
|
int rhizome_cache_count();
|
2012-01-08 23:25:21 +00:00
|
|
|
int overlay_add_local_identity(unsigned char *s);
|
2011-08-08 14:41:46 +00:00
|
|
|
|
|
|
|
extern int overlay_interface_count;
|
2011-08-12 06:15:26 +00:00
|
|
|
|
2012-01-08 23:25:21 +00:00
|
|
|
extern int overlay_local_identity_count;
|
|
|
|
extern unsigned char *overlay_local_identities[OVERLAY_MAX_LOCAL_IDENTITIES];
|
|
|
|
|
2011-08-17 01:22:17 +00:00
|
|
|
int rfs_length(int l);
|
|
|
|
int rfs_encode(int l,unsigned char *b);
|
|
|
|
int rfs_decode(unsigned char *b,int *offset);
|
2011-08-15 07:27:29 +00:00
|
|
|
|
2013-08-29 07:59:32 +00:00
|
|
|
int overlayServerMode(const struct cli_parsed *parsed);
|
2012-10-09 05:14:37 +00:00
|
|
|
int overlay_payload_enqueue(struct overlay_frame *p);
|
2013-01-28 02:35:24 +00:00
|
|
|
int overlay_queue_remaining(int queue);
|
2013-02-06 06:40:43 +00:00
|
|
|
int overlay_queue_schedule_next(time_ms_t next_allowed_packet);
|
2013-08-08 05:50:31 +00:00
|
|
|
int overlay_send_tick_packet(struct network_destination *destination);
|
|
|
|
int overlay_queue_ack(struct subscriber *neighbour, struct network_destination *destination, uint32_t ack_mask, int ack_seq);
|
2013-05-13 02:53:44 +00:00
|
|
|
|
2013-08-08 05:50:31 +00:00
|
|
|
int overlay_rhizome_saw_advertisements(int i, struct decode_context *context, struct overlay_frame *f, time_ms_t now);
|
2011-12-22 11:28:18 +00:00
|
|
|
int rhizome_server_get_fds(struct pollfd *fds,int *fdcount,int fdmax);
|
2012-05-22 03:35:29 +00:00
|
|
|
int rhizome_saw_voice_traffic();
|
2012-08-27 00:34:59 +00:00
|
|
|
int overlay_saw_mdp_containing_frame(struct overlay_frame *f, time_ms_t now);
|
2011-10-16 21:41:05 +00:00
|
|
|
|
2013-09-02 05:24:33 +00:00
|
|
|
int serval_packetvisualise(const char *message, const unsigned char *packet, size_t len);
|
|
|
|
int serval_packetvisualise_xpf(XPRINTF xpf, const char *message, const unsigned char *packet, size_t len);
|
2013-09-18 04:14:18 +00:00
|
|
|
void logServalPacket(int level, struct __sourceloc __whence, const char *message, const unsigned char *packet, size_t len);
|
|
|
|
#define DEBUG_packet_visualise(M,P,N) logServalPacket(LOG_LEVEL_DEBUG, __WHENCE__, (M), (P), (N))
|
2012-01-10 11:26:07 +00:00
|
|
|
|
2012-02-15 13:08:23 +00:00
|
|
|
int rhizome_fetching_get_fds(struct pollfd *fds,int *fdcount,int fdmax);
|
2012-03-04 22:57:31 +00:00
|
|
|
int rhizome_opendb();
|
2012-01-10 11:26:07 +00:00
|
|
|
|
2013-07-03 07:21:27 +00:00
|
|
|
int parseCommandLine(struct cli_context *context, const char *argv0, int argc, const char *const *argv);
|
2012-02-23 02:09:31 +00:00
|
|
|
|
2012-03-17 02:32:09 +00:00
|
|
|
int overlay_mdp_get_fds(struct pollfd *fds,int *fdcount,int fdmax);
|
2012-03-19 05:36:34 +00:00
|
|
|
|
2013-10-09 08:24:21 +00:00
|
|
|
typedef uint32_t mdp_port_t;
|
2013-11-26 07:14:49 +00:00
|
|
|
#define PRImdp_port_t "#08" PRIx32
|
2013-10-09 08:24:21 +00:00
|
|
|
|
2012-03-19 05:36:34 +00:00
|
|
|
typedef struct sockaddr_mdp {
|
2013-10-09 08:24:21 +00:00
|
|
|
sid_t sid;
|
|
|
|
mdp_port_t port;
|
2012-03-19 05:36:34 +00:00
|
|
|
} sockaddr_mdp;
|
|
|
|
|
2012-04-10 03:25:46 +00:00
|
|
|
typedef struct overlay_mdp_data_frame {
|
2012-03-27 08:55:38 +00:00
|
|
|
sockaddr_mdp src;
|
2012-03-19 05:36:34 +00:00
|
|
|
sockaddr_mdp dst;
|
2012-09-28 01:58:01 +00:00
|
|
|
uint16_t payload_length;
|
2012-10-09 05:39:33 +00:00
|
|
|
int queue;
|
2012-10-10 05:52:31 +00:00
|
|
|
int ttl;
|
2012-04-10 03:25:46 +00:00
|
|
|
unsigned char payload[MDP_MTU-100];
|
2012-03-28 00:58:04 +00:00
|
|
|
} overlay_mdp_data_frame;
|
2012-03-19 05:36:34 +00:00
|
|
|
|
|
|
|
typedef struct overlay_mdp_error {
|
|
|
|
unsigned int error;
|
2012-03-20 06:41:58 +00:00
|
|
|
char message[128];
|
2012-03-19 05:36:34 +00:00
|
|
|
} overlay_mdp_error;
|
|
|
|
|
2012-03-27 08:55:38 +00:00
|
|
|
typedef struct overlay_mdp_addrlist {
|
2012-07-04 02:36:15 +00:00
|
|
|
int mode;
|
2013-04-12 07:46:50 +00:00
|
|
|
#define OVERLAY_MDP_ADDRLIST_MAX_SID_COUNT (~(unsigned int)0)
|
2012-03-27 08:55:38 +00:00
|
|
|
unsigned int server_sid_count;
|
|
|
|
unsigned int first_sid;
|
|
|
|
unsigned int last_sid;
|
2012-07-04 02:36:15 +00:00
|
|
|
unsigned int frame_sid_count; /* how many of the following 59 slots are populated */
|
2013-10-09 08:24:21 +00:00
|
|
|
sid_t sids[MDP_MAX_SID_REQUEST];
|
2012-03-27 08:55:38 +00:00
|
|
|
} overlay_mdp_addrlist;
|
|
|
|
|
2012-04-25 21:44:01 +00:00
|
|
|
typedef struct overlay_mdp_nodeinfo {
|
2013-10-09 08:24:21 +00:00
|
|
|
sid_t sid;
|
2012-08-15 04:06:10 +00:00
|
|
|
int sid_prefix_length; /* must be long enough to be unique */
|
2012-04-25 21:44:01 +00:00
|
|
|
int foundP;
|
|
|
|
int localP;
|
|
|
|
int neighbourP;
|
|
|
|
int score;
|
|
|
|
int interface_number;
|
2012-08-09 02:44:32 +00:00
|
|
|
time_ms_t time_since_last_observation;
|
2012-04-25 21:44:01 +00:00
|
|
|
} overlay_mdp_nodeinfo;
|
|
|
|
|
2012-03-19 05:36:34 +00:00
|
|
|
typedef struct overlay_mdp_frame {
|
2012-09-28 01:58:01 +00:00
|
|
|
uint16_t packetTypeAndFlags;
|
2012-03-19 05:36:34 +00:00
|
|
|
union {
|
2012-03-28 00:58:04 +00:00
|
|
|
overlay_mdp_data_frame out;
|
|
|
|
overlay_mdp_data_frame in;
|
2012-09-28 01:58:01 +00:00
|
|
|
sockaddr_mdp bind;
|
2012-03-27 08:55:38 +00:00
|
|
|
overlay_mdp_addrlist addrlist;
|
2012-04-25 21:44:01 +00:00
|
|
|
overlay_mdp_nodeinfo nodeinfo;
|
2012-03-19 05:36:34 +00:00
|
|
|
overlay_mdp_error error;
|
|
|
|
/* 2048 is too large (causes EMSGSIZE errors on OSX, but probably fine on
|
|
|
|
Linux) */
|
2012-04-10 03:25:46 +00:00
|
|
|
char raw[MDP_MTU];
|
2012-03-19 05:36:34 +00:00
|
|
|
};
|
|
|
|
} overlay_mdp_frame;
|
|
|
|
|
2012-03-28 00:58:04 +00:00
|
|
|
/* Server-side MDP functions */
|
2012-04-15 20:36:43 +00:00
|
|
|
int overlay_mdp_swap_src_dst(overlay_mdp_frame *mdp);
|
2013-11-25 01:45:20 +00:00
|
|
|
struct socket_address;
|
|
|
|
int overlay_mdp_dispatch(overlay_mdp_frame *mdp, struct socket_address *client);
|
2013-11-25 06:13:32 +00:00
|
|
|
void overlay_mdp_encode_ports(struct overlay_buffer *plaintext, mdp_port_t dst_port, mdp_port_t src_port);
|
2013-10-09 08:24:21 +00:00
|
|
|
int overlay_mdp_dnalookup_reply(const sockaddr_mdp *dstaddr, const sid_t *resolved_sidp, const char *uri, const char *did, const char *name);
|
2012-03-20 17:25:13 +00:00
|
|
|
|
2013-11-18 02:42:52 +00:00
|
|
|
struct mdp_header;
|
|
|
|
int mdp_bind_internal(struct subscriber *subscriber, mdp_port_t port,
|
|
|
|
int (*internal)(const struct mdp_header *header, const uint8_t *payload, size_t len));
|
|
|
|
int mdp_unbind_internal(struct subscriber *subscriber, mdp_port_t port,
|
|
|
|
int (*internal)(const struct mdp_header *header, const uint8_t *payload, size_t len));
|
|
|
|
|
|
|
|
|
2012-08-06 05:16:46 +00:00
|
|
|
struct vomp_call_state;
|
2012-09-27 06:57:37 +00:00
|
|
|
|
|
|
|
void set_codec_flag(int codec, unsigned char *flags);
|
|
|
|
int is_codec_set(int codec, unsigned char *flags);
|
|
|
|
|
2012-08-06 05:16:46 +00:00
|
|
|
struct vomp_call_state *vomp_find_call_by_session(int session_token);
|
2012-04-18 23:17:59 +00:00
|
|
|
int vomp_mdp_received(overlay_mdp_frame *mdp);
|
2012-05-03 18:14:41 +00:00
|
|
|
int vomp_parse_dtmf_digit(char c);
|
2012-12-07 05:32:58 +00:00
|
|
|
int vomp_dial(struct subscriber *local, struct subscriber *remote, const char *local_did, const char *remote_did);
|
2012-08-06 05:16:46 +00:00
|
|
|
int vomp_pickup(struct vomp_call_state *call);
|
|
|
|
int vomp_hangup(struct vomp_call_state *call);
|
|
|
|
int vomp_ringing(struct vomp_call_state *call);
|
2012-11-14 05:20:22 +00:00
|
|
|
int vomp_received_audio(struct vomp_call_state *call, int audio_codec, int time, int sequence,
|
|
|
|
const unsigned char *audio, int audio_length);
|
2012-09-27 06:57:37 +00:00
|
|
|
void monitor_get_all_supported_codecs(unsigned char *codecs);
|
2012-07-05 06:22:21 +00:00
|
|
|
|
2012-10-03 06:51:06 +00:00
|
|
|
int overlay_route_node_info(overlay_mdp_nodeinfo *node_info);
|
2012-06-08 07:31:50 +00:00
|
|
|
int overlay_interface_register(char *name,
|
2012-08-08 05:27:27 +00:00
|
|
|
struct in_addr addr,
|
|
|
|
struct in_addr mask);
|
2012-12-07 05:34:40 +00:00
|
|
|
overlay_interface * overlay_interface_get_default();
|
|
|
|
overlay_interface * overlay_interface_find(struct in_addr addr, int return_default);
|
2012-09-14 02:20:45 +00:00
|
|
|
overlay_interface * overlay_interface_find_name(const char *name);
|
2013-05-01 06:16:47 +00:00
|
|
|
int overlay_interface_compare(overlay_interface *one, overlay_interface *two);
|
2013-09-11 01:43:33 +00:00
|
|
|
int overlay_broadcast_ensemble(struct network_destination *destination, struct overlay_buffer *buffer);
|
2013-09-23 01:41:58 +00:00
|
|
|
void interface_state_html(struct strbuf *b, struct overlay_interface *interface);
|
2012-09-14 02:20:45 +00:00
|
|
|
|
2012-09-18 02:56:30 +00:00
|
|
|
int directory_registration();
|
|
|
|
int directory_service_init();
|
2012-04-20 06:11:13 +00:00
|
|
|
|
2013-07-03 07:21:27 +00:00
|
|
|
int app_nonce_test(const struct cli_parsed *parsed, struct cli_context *context);
|
|
|
|
int app_rhizome_direct_sync(const struct cli_parsed *parsed, struct cli_context *context);
|
|
|
|
int app_monitor_cli(const struct cli_parsed *parsed, struct cli_context *context);
|
|
|
|
int app_vomp_console(const struct cli_parsed *parsed, struct cli_context *context);
|
2013-07-22 08:25:02 +00:00
|
|
|
int app_meshms_conversations(const struct cli_parsed *parsed, struct cli_context *context);
|
|
|
|
int app_meshms_send_message(const struct cli_parsed *parsed, struct cli_context *context);
|
|
|
|
int app_meshms_list_messages(const struct cli_parsed *parsed, struct cli_context *context);
|
2013-07-26 05:06:11 +00:00
|
|
|
int app_meshms_mark_read(const struct cli_parsed *parsed, struct cli_context *context);
|
2012-05-02 16:58:39 +00:00
|
|
|
|
|
|
|
int monitor_get_fds(struct pollfd *fds,int *fdcount,int fdmax);
|
|
|
|
|
|
|
|
int monitor_setup_sockets();
|
|
|
|
int monitor_get_fds(struct pollfd *fds,int *fdcount,int fdmax);
|
2013-10-09 08:24:21 +00:00
|
|
|
int monitor_announce_peer(const sid_t *sidp);
|
|
|
|
int monitor_announce_unreachable_peer(const sid_t *sidp);
|
2013-05-02 04:57:23 +00:00
|
|
|
int monitor_announce_link(int hop_count, struct subscriber *transmitter, struct subscriber *receiver);
|
2012-06-25 05:30:07 +00:00
|
|
|
int monitor_tell_clients(char *msg, int msglen, int mask);
|
2012-08-08 01:26:05 +00:00
|
|
|
int monitor_tell_formatted(int mask, char *fmt, ...);
|
2012-08-06 05:16:46 +00:00
|
|
|
int monitor_client_interested(int mask);
|
2012-05-02 17:30:34 +00:00
|
|
|
extern int monitor_socket_count;
|
2012-05-09 18:16:27 +00:00
|
|
|
|
2012-05-10 07:28:25 +00:00
|
|
|
|
|
|
|
typedef struct monitor_audio {
|
|
|
|
char name[128];
|
|
|
|
int (*start)();
|
|
|
|
int (*stop)();
|
|
|
|
int (*poll_fds)(struct pollfd *,int);
|
|
|
|
int (*read)(unsigned char *,int);
|
|
|
|
int (*write)(unsigned char *,int);
|
|
|
|
} monitor_audio;
|
|
|
|
extern monitor_audio *audev;
|
|
|
|
|
|
|
|
monitor_audio *audio_msm_g1_detect();
|
|
|
|
monitor_audio *audio_alsa_detect();
|
2012-05-10 22:30:09 +00:00
|
|
|
monitor_audio *audio_reflector_detect();
|
2012-05-09 18:16:27 +00:00
|
|
|
int detectAudioDevice();
|
2012-05-10 08:59:00 +00:00
|
|
|
int getAudioPlayFd();
|
|
|
|
int getAudioRecordFd();
|
2012-05-09 18:16:27 +00:00
|
|
|
int getAudioBytes(unsigned char *buffer,
|
|
|
|
int offset,
|
|
|
|
int bufferSize);
|
|
|
|
int encodeAndDispatchRecordedAudio(int fd,int callSessionToken,
|
|
|
|
int recordCodec,
|
|
|
|
unsigned char *sampleData,
|
|
|
|
int sampleBytes);
|
2012-05-10 04:37:11 +00:00
|
|
|
int scrapeProcNetRoute();
|
2012-05-28 05:24:33 +00:00
|
|
|
int lsif();
|
2012-06-08 07:01:59 +00:00
|
|
|
int doifaddrs();
|
2012-08-09 02:44:32 +00:00
|
|
|
int bufferAudioForPlayback(int codec, time_ms_t start_time, time_ms_t end_time,
|
2012-05-10 22:30:09 +00:00
|
|
|
unsigned char *data,int dataLen);
|
|
|
|
int startAudio();
|
|
|
|
int stopAudio();
|
2012-05-21 11:15:07 +00:00
|
|
|
|
|
|
|
#define SERVER_UNKNOWN 1
|
|
|
|
#define SERVER_NOTRESPONDING 2
|
|
|
|
#define SERVER_NOTRUNNING 3
|
|
|
|
#define SERVER_RUNNING 4
|
|
|
|
int server_probe(int *pid);
|
2012-06-20 22:37:03 +00:00
|
|
|
|
2012-09-18 02:54:33 +00:00
|
|
|
int dna_helper_start();
|
2012-07-20 08:47:43 +00:00
|
|
|
int dna_helper_shutdown();
|
2013-10-09 08:24:21 +00:00
|
|
|
int dna_helper_enqueue(overlay_mdp_frame *mdp, const char *did, const sid_t *requestorSidp);
|
2012-06-20 22:37:03 +00:00
|
|
|
int dna_return_resolution(overlay_mdp_frame *mdp, unsigned char *fromSid,
|
|
|
|
const char *did,const char *name,const char *uri);
|
2012-07-23 08:59:57 +00:00
|
|
|
int parseDnaReply(const char *buf, size_t len, char *token, char *did, char *name, char *uri, const char **bufp);
|
2012-06-21 01:00:08 +00:00
|
|
|
extern int sigPipeFlag;
|
|
|
|
extern int sigIoFlag;
|
|
|
|
void sigPipeHandler(int signal);
|
|
|
|
void sigIoHandler(int signal);
|
2012-06-21 05:05:05 +00:00
|
|
|
|
2012-06-25 23:52:51 +00:00
|
|
|
int overlay_mdp_setup_sockets();
|
|
|
|
|
2012-07-02 03:49:54 +00:00
|
|
|
void overlay_interface_discover(struct sched_ent *alarm);
|
2013-02-04 11:36:49 +00:00
|
|
|
void overlay_packetradio_poll(struct sched_ent *alarm);
|
2013-02-04 19:36:44 +00:00
|
|
|
int overlay_packetradio_setup_port(overlay_interface *interface);
|
2013-02-07 04:46:07 +00:00
|
|
|
int overlay_packetradio_tx_packet(struct overlay_frame *frame);
|
2012-07-02 03:49:54 +00:00
|
|
|
void overlay_dummy_poll(struct sched_ent *alarm);
|
2012-12-14 05:57:04 +00:00
|
|
|
void server_config_reload(struct sched_ent *alarm);
|
2012-07-02 03:49:54 +00:00
|
|
|
void server_shutdown_check(struct sched_ent *alarm);
|
2013-11-25 01:45:20 +00:00
|
|
|
int overlay_mdp_try_internal_services(struct overlay_frame *frame, overlay_mdp_frame *mdp);
|
2013-08-08 05:50:31 +00:00
|
|
|
int overlay_send_probe(struct subscriber *peer, struct network_destination *destination, int queue);
|
2012-12-07 05:34:40 +00:00
|
|
|
int overlay_send_stun_request(struct subscriber *server, struct subscriber *request);
|
2012-07-02 03:49:54 +00:00
|
|
|
void fd_periodicstats(struct sched_ent *alarm);
|
|
|
|
void rhizome_check_connections(struct sched_ent *alarm);
|
|
|
|
|
2012-11-20 06:11:06 +00:00
|
|
|
int overlay_tick_interface(int i, time_ms_t now);
|
|
|
|
int overlay_queue_init();
|
|
|
|
|
2012-07-02 03:49:54 +00:00
|
|
|
void monitor_client_poll(struct sched_ent *alarm);
|
|
|
|
void monitor_poll(struct sched_ent *alarm);
|
|
|
|
void rhizome_fetch_poll(struct sched_ent *alarm);
|
|
|
|
void rhizome_server_poll(struct sched_ent *alarm);
|
|
|
|
|
2012-12-12 03:10:00 +00:00
|
|
|
int overlay_mdp_service_stun_req(overlay_mdp_frame *mdp);
|
|
|
|
int overlay_mdp_service_stun(overlay_mdp_frame *mdp);
|
2013-08-08 05:50:31 +00:00
|
|
|
int overlay_mdp_service_probe(struct overlay_frame *frame, overlay_mdp_frame *mdp);
|
2012-12-12 03:10:00 +00:00
|
|
|
|
2012-12-13 07:20:09 +00:00
|
|
|
time_ms_t limit_next_allowed(struct limit_state *state);
|
|
|
|
int limit_is_allowed(struct limit_state *state);
|
|
|
|
int limit_init(struct limit_state *state, int rate_micro_seconds);
|
|
|
|
|
2012-08-31 05:28:40 +00:00
|
|
|
int olsr_init_socket(void);
|
|
|
|
int olsr_send(struct overlay_frame *frame);
|
|
|
|
|
2013-07-23 04:51:46 +00:00
|
|
|
int pack_uint(unsigned char *buffer, uint64_t v);
|
|
|
|
int measure_packed_uint(uint64_t v);
|
|
|
|
int unpack_uint(unsigned char *buffer, int buff_size, uint64_t *v);
|
|
|
|
|
2013-02-14 19:37:51 +00:00
|
|
|
int slip_encode(int format,
|
2013-09-11 01:43:33 +00:00
|
|
|
const unsigned char *src, int src_bytes, unsigned char *dst, int dst_len);
|
2013-02-14 03:48:56 +00:00
|
|
|
int slip_decode(struct slip_decode_state *state);
|
2013-02-15 03:04:53 +00:00
|
|
|
int upper7_decode(struct slip_decode_state *state,unsigned char byte);
|
2013-02-15 01:52:31 +00:00
|
|
|
uint32_t Crc32_ComputeBuf( uint32_t inCrc32, const void *buf,
|
|
|
|
size_t bufLen );
|
2013-11-04 03:45:08 +00:00
|
|
|
void rhizome_fetch_log_short_status();
|
2013-07-13 05:17:06 +00:00
|
|
|
extern int64_t bundles_available;
|
2013-02-15 22:39:36 +00:00
|
|
|
extern char crash_handler_clue[1024];
|
2013-02-15 05:07:39 +00:00
|
|
|
|
2013-04-26 07:23:04 +00:00
|
|
|
|
2013-05-15 06:26:43 +00:00
|
|
|
int link_received_duplicate(struct subscriber *subscriber, struct overlay_interface *interface, int sender_interface, int previous_seq, int unicast);
|
2013-08-09 02:48:14 +00:00
|
|
|
int link_received_packet(struct decode_context *context, int sender_seq, char unicast);
|
2013-08-08 05:50:31 +00:00
|
|
|
int link_receive(struct overlay_frame *frame, overlay_mdp_frame *mdp);
|
2013-04-26 07:23:04 +00:00
|
|
|
void link_explained(struct subscriber *subscriber);
|
2013-04-29 07:37:36 +00:00
|
|
|
void link_interface_down(struct overlay_interface *interface);
|
2013-05-08 04:12:11 +00:00
|
|
|
int link_state_announce_links();
|
2013-05-09 05:29:33 +00:00
|
|
|
int link_state_legacy_ack(struct overlay_frame *frame, time_ms_t now);
|
2013-05-15 02:03:43 +00:00
|
|
|
int link_state_ack_soon(struct subscriber *sender);
|
2013-05-29 01:44:26 +00:00
|
|
|
int link_state_should_forward_broadcast(struct subscriber *transmitter);
|
2013-08-08 05:50:31 +00:00
|
|
|
int link_unicast_ack(struct subscriber *subscriber, struct overlay_interface *interface, struct sockaddr_in addr);
|
2013-08-09 06:49:45 +00:00
|
|
|
int link_add_destinations(struct overlay_frame *frame);
|
2013-09-23 01:41:58 +00:00
|
|
|
void link_neighbour_short_status_html(struct strbuf *b, const char *link_prefix);
|
|
|
|
void link_neighbour_status_html(struct strbuf *b, struct subscriber *neighbour);
|
2013-10-14 03:58:48 +00:00
|
|
|
int link_stop_routing(struct subscriber *subscriber);
|
2013-04-26 07:23:04 +00:00
|
|
|
|
2013-05-07 05:11:59 +00:00
|
|
|
int generate_nonce(unsigned char *nonce,int bytes);
|
|
|
|
|
2012-07-30 03:28:21 +00:00
|
|
|
#endif // __SERVALD_SERVALD_H
|