mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-01-29 15:43:56 +00:00
Merge network simulator into development
This commit is contained in:
commit
757e6c62ab
@ -230,41 +230,27 @@ STRUCT(debug)
|
||||
ATOM(bool_t, verbose, 0, boolean,, "")
|
||||
ATOM(bool_t, ack, 0, boolean,, "")
|
||||
ATOM(bool_t, config, 0, boolean,, "")
|
||||
ATOM(bool_t, dnaresponses, 0, boolean,, "")
|
||||
ATOM(bool_t, dnahelper, 0, boolean,, "")
|
||||
ATOM(bool_t, queues, 0, boolean,, "")
|
||||
ATOM(bool_t, timing, 0, boolean,, "")
|
||||
ATOM(bool_t, http_server, 0, boolean,, "")
|
||||
ATOM(bool_t, httpd, 0, boolean,, "")
|
||||
ATOM(bool_t, nohttptx, 0, boolean,, "")
|
||||
ATOM(bool_t, io, 0, boolean,, "")
|
||||
ATOM(bool_t, verbose_io, 0, boolean,, "")
|
||||
ATOM(bool_t, interactive_io, 0, boolean,, "")
|
||||
ATOM(bool_t, packetformats, 0, boolean,, "")
|
||||
ATOM(bool_t, gateway, 0, boolean,, "")
|
||||
ATOM(bool_t, keyring, 0, boolean,, "")
|
||||
ATOM(bool_t, security, 0, boolean,, "")
|
||||
ATOM(bool_t, mdprequests, 0, boolean,, "")
|
||||
ATOM(bool_t, mdp_filter, 0, boolean,, "")
|
||||
ATOM(bool_t, msp, 0, boolean,, "")
|
||||
ATOM(bool_t, monitor, 0, boolean,, "")
|
||||
ATOM(bool_t, radio_link, 0, boolean,, "")
|
||||
ATOM(bool_t, peers, 0, boolean,, "")
|
||||
ATOM(bool_t, overlaybuffer, 0, boolean,, "")
|
||||
ATOM(bool_t, overlayframes, 0, boolean,, "")
|
||||
ATOM(bool_t, overlayabbreviations, 0, boolean,, "")
|
||||
ATOM(bool_t, overlayrouting, 0, boolean,, "")
|
||||
ATOM(bool_t, overlayroutemonitor, 0, boolean,, "")
|
||||
ATOM(bool_t, overlayinterfaces, 0, boolean,, "")
|
||||
ATOM(bool_t, broadcasts, 0, boolean,, "")
|
||||
ATOM(bool_t, packettx, 0, boolean,, "")
|
||||
ATOM(bool_t, packetrx, 0, boolean,, "")
|
||||
ATOM(bool_t, packetradio, 0, boolean,, "")
|
||||
ATOM(bool_t, rejecteddata, 0, boolean,, "")
|
||||
ATOM(bool_t, slip, 0, boolean,, "")
|
||||
ATOM(bool_t, slipdecode, 0, boolean,, "")
|
||||
ATOM(bool_t, slipbytestream, 0, boolean,, "")
|
||||
ATOM(bool_t, packetconstruction, 0, boolean,, "")
|
||||
ATOM(bool_t, rhizome, 0, boolean,, "")
|
||||
ATOM(bool_t, rhizome_manifest, 0, boolean,, "")
|
||||
ATOM(bool_t, rhizome_sql_bind, 0, boolean,, "")
|
||||
@ -274,11 +260,9 @@ ATOM(bool_t, rhizome_rx, 0, boolean,, "")
|
||||
ATOM(bool_t, rhizome_ads, 0, boolean,, "")
|
||||
ATOM(bool_t, rhizome_mdp_rx, 0, boolean,, "")
|
||||
ATOM(bool_t, subscriber, 0, boolean,, "")
|
||||
ATOM(bool_t, throttling, 0, boolean,, "")
|
||||
ATOM(bool_t, meshms, 0, boolean,, "")
|
||||
ATOM(bool_t, manifests, 0, boolean,, "")
|
||||
ATOM(bool_t, vomp, 0, boolean,, "")
|
||||
ATOM(bool_t, trace, 0, boolean,, "")
|
||||
ATOM(bool_t, profiling, 0, boolean,, "")
|
||||
ATOM(bool_t, linkstate, 0, boolean,, "")
|
||||
ATOM(bool_t, watchdog, 0, boolean,, "")
|
||||
@ -491,7 +475,7 @@ ATOM(short, type, OVERLAY_INTERFACE_WIFI, interface_t
|
||||
SUB_STRUCT(mdp_iftype, mdp,)
|
||||
ATOM(bool_t, send_broadcasts, 1, boolean,, "If false, don't send any broadcast packets")
|
||||
ATOM(bool_t, default_route, 0, boolean,, "If true, use this interface as a default route")
|
||||
ATOM(bool_t, prefer_unicast, 0, boolean,, "If true, send unicast data as unicast IP packets if available")
|
||||
ATOM(bool_t, prefer_unicast, 1, boolean,, "If true, send data as unicast IP packets if available")
|
||||
ATOM(bool_t, debug, 0, boolean,, "If true, log details of every outgoing packet")
|
||||
ATOM(bool_t, point_to_point, 0, boolean,, "If true, assume there will only be two devices on this interface")
|
||||
ATOM(bool_t, ctsrts, 0, boolean,, "If true, enable CTS/RTS hardware handshaking")
|
||||
|
@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "str.h"
|
||||
#define __SERVAL_LOG_INLINE
|
||||
#include "log.h"
|
||||
#include "conf.h"
|
||||
|
||||
|
200
doc/Mesh-Packet-Filtering.md
Normal file
200
doc/Mesh-Packet-Filtering.md
Normal file
@ -0,0 +1,200 @@
|
||||
Serval DNA Mesh Packet Filtering
|
||||
================================
|
||||
[Serval Project][], May 2014
|
||||
|
||||
The [Serval DNA][] daemon can perform filtering on all incoming and outgoing
|
||||
[MDP][] packets, ie, packets that are addressed to the local node and packets
|
||||
that originate from the local node.
|
||||
|
||||
[Serval DNA][] cannot filter packets that it is forwarding to other nodes.
|
||||
|
||||
The original MDP packet filtering capability was funded by a [grant][] from the
|
||||
[New America Foundation][NAF]'s [Open Technology Institute][OTI].
|
||||
|
||||
How to configure packet filtering
|
||||
---------------------------------
|
||||
|
||||
Packet filtering is disabled by default, so all packets are allowed.
|
||||
|
||||
To enable MDP packet filtering, set the `mdp.filter_rules_path` [config
|
||||
option][] to the absolute or relative path of a _filter rules_ file. Relative
|
||||
paths are interpreted with respect to the same directory that contains the
|
||||
configuration file.
|
||||
|
||||
### Example 1
|
||||
|
||||
allow <>*:1-7
|
||||
allow *:1-10 <>*
|
||||
allow broadcast:70 <DEADDEADDEADDEADDEADDEADDEADDEADDEADDEADDEADDEADDEADDEADDEADDEAD
|
||||
allow >ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB:20100
|
||||
drop <*:8
|
||||
allow <>0123012301230123012301230123012301230123012301230123012301230123
|
||||
allow <>4567456745674567456745674567456745674567456745674567456745674567:12-18
|
||||
drop all
|
||||
|
||||
### Grammar
|
||||
|
||||
rules := optspace [ rule optspace ( sep optspace rule optspace ){0..} ]
|
||||
sep := "\n" | ";"
|
||||
rule := verb space which
|
||||
verb := "allow" | "drop"
|
||||
which := "all" | pattern
|
||||
pattern := [ endpoint optspace ] direction optspace endpoint
|
||||
direction := ">" | "<" | "<>"
|
||||
endpoint := sidany [ optspace ":" optspace portrange ]
|
||||
sidany := "*" | sidhex | "broadcast"
|
||||
sidhex := hexdigit {64}
|
||||
portrange := port optspace [ "-" optspace port ]
|
||||
port := hexport | decport
|
||||
hexport := "0x" hexdigit {1..8}
|
||||
decport := decdigit {1..10}
|
||||
decdigit := "0".."9"
|
||||
hexdigit := decdigit | "A".."F" | "a".."f"
|
||||
optspace := " " {0..}
|
||||
space := " " {1..}
|
||||
|
||||
### How rules work
|
||||
|
||||
For each incoming and outgoing packet, all packet rules are tested in the order
|
||||
that they appear in the rules file. The first rule that matches the packet
|
||||
determines whether the packet is *allowed* or *dropped*, and no more rules are
|
||||
tested. If no rules match, the packet is *allowed* by default.
|
||||
|
||||
* Rules are separated by a single newline (ASCII 10) or semicolon `;`.
|
||||
|
||||
* Each rule is an *action* (`drop` or `allow`) followed either by the word
|
||||
`all` or followed by an optional *local pattern* followed by a *direction*
|
||||
and a *remote pattern*.
|
||||
|
||||
* A rule with the `all` word matches all packets, which means that any
|
||||
following rules are ignored. So an *all rule* should be the last rule in
|
||||
the file.
|
||||
|
||||
* A non-all rule only matches a packet if its local pattern, direction, *AND*
|
||||
remote pattern all match.
|
||||
|
||||
* The local pattern, if given, is tested against the packet's *local address*;
|
||||
if absent, all local addresses match. For incoming packets this means the
|
||||
recipient (destination) address, and for outgoing packets this means the
|
||||
sending (originating) address.
|
||||
|
||||
* The direction is one of `<`, `>` or `<>`, which causes the rule to match
|
||||
only incoming packets, only outgoing packets, or both.
|
||||
|
||||
* The remote pattern is tested against the packet's *remote address*. For
|
||||
incoming packets this means the sending (originating) address, and for
|
||||
outgoing packets this means the recipient (destination) address.
|
||||
|
||||
* A pattern (local or remote) is a SID optionally followed by a colon `:` and
|
||||
a range of [MDP port][] numbers.
|
||||
|
||||
* A pattern only matches an address if its SID matches the address's [SID][]
|
||||
*AND* its port number lies within the address's port number range. If the
|
||||
pattern has no port number range, then it matches all port numbers.
|
||||
|
||||
* A pattern's SID can be given either as 64 hexadecimal digits, which matches
|
||||
that [SID][] exactly, or the word `broadcast`, which matches only the
|
||||
all-bits-set [SID][] (`FFFF....FF`), or the star symbol `*` which matches
|
||||
any [SID][].
|
||||
|
||||
* A port number range is either a single port number, which matches only that
|
||||
port number exactly, or a pair of port numbers separated by a dash `-` where
|
||||
the second number is greater than the first. Each port number is either a
|
||||
decimal integer in the range 1 to 4294967295 inclusive or a hexadecimal
|
||||
number prefixed with `0x` in the range `0x1` to `0xffffffff`.
|
||||
|
||||
### Interpretation of example 1
|
||||
|
||||
The rules file shown in Example 1 above has the following meaning:
|
||||
|
||||
* `allow <>*:1-7`
|
||||
|
||||
allows all incoming packets originating from remote ports 1 through 7, and
|
||||
allows all outgoing packets (which will probably be replies) to the same
|
||||
range of remote ports
|
||||
|
||||
* `allow *:1-10 <>*`
|
||||
|
||||
allows all incoming packets to local ports between 1 and 10 inclusive, and
|
||||
all outgoing packets from those ports
|
||||
|
||||
* `allow broadcast:70 <DEADDEADDEADDEADDEADDEADDEADDEADDEADDEADDEADDEADDEADDEADDEADDEAD`
|
||||
|
||||
allows all broadcast packets sent to local port 70 from any port on the node
|
||||
with SID `DEAD...DEAD`
|
||||
|
||||
* `allow >ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB:20100`
|
||||
|
||||
allows all outgoing packets to port 20100 on the node with SID `ABAB...ABAB`
|
||||
|
||||
* `drop <*:8`
|
||||
|
||||
drops all incoming packets (that were not allowed by prior rules) sent from
|
||||
port 8 on any remote node
|
||||
|
||||
* `allow <>0123012301230123012301230123012301230123012301230123012301230123`
|
||||
|
||||
allows all incoming and outgoing packets (that were not dropped by prior
|
||||
rules) from and to the node with SID `0123...0123`
|
||||
|
||||
* `allow <>4567456745674567456745674567456745674567456745674567456745674567:12-18`
|
||||
|
||||
allows all incoming and outgoing packets (that were not dropped by prior
|
||||
rules) from and to ports 12 through 18 inclusive on the node with SID
|
||||
`4567...4567`
|
||||
|
||||
* `drop all`
|
||||
|
||||
drops all incoming and outgoing packets that were not allowed by prior rules
|
||||
|
||||
Special case: SID whitelist
|
||||
---------------------------
|
||||
|
||||
A filter rules file that whitelists a set of [SID][]s will have the following
|
||||
form:
|
||||
|
||||
allow <>0001000100010001000100010001000100010001000100010001000100010001
|
||||
allow <>0002000200020002000200020002000200020002000200020002000200020002
|
||||
allow <>0003000300030003000300030003000300030003000300030003000300030003
|
||||
...
|
||||
allow <>000n000n000n000n000n000n000n000n000n000n000n000n000n000n000n000n
|
||||
drop all
|
||||
|
||||
where the symbols `0001...0001` through `000n...000n` are replaced by the
|
||||
hexadecimal representations of the actual SIDs in the whitelist.
|
||||
|
||||
**Note**: If the final line `drop all` is missing, then the whitelist will have
|
||||
no effect.
|
||||
|
||||
Special case: SID blacklist
|
||||
---------------------------
|
||||
|
||||
A filter rules file that blacklists a set of [SID][]s will have the following
|
||||
form:
|
||||
|
||||
drop <>0001000100010001000100010001000100010001000100010001000100010001
|
||||
drop <>0002000200020002000200020002000200020002000200020002000200020002
|
||||
drop <>0003000300030003000300030003000300030003000300030003000300030003
|
||||
...
|
||||
drop <>000n000n000n000n000n000n000n000n000n000n000n000n000n000n000n000n
|
||||
|
||||
where the symbols `0001...0001` through `000n...000n` are replaced by the
|
||||
hexadecimal representations of the actual SIDs in the blacklist.
|
||||
|
||||
|
||||
-----
|
||||
**Copyright 2014 Serval Project Inc.**
|
||||
![CC-BY-4.0](./cc-by-4.0.png)
|
||||
Available under the [Creative Commons Attribution 4.0 International licence][CC BY 4.0].
|
||||
|
||||
|
||||
[Serval Project]: http://www.servalproject.org/
|
||||
[CC BY 4.0]: ../LICENSE-DOCUMENTATION.md
|
||||
[grant]: http://developer.servalproject.org/dokuwiki/doku.php?id=content:activity:naf6
|
||||
[NAF]: http://www.newamerica.net/
|
||||
[OTI]: http://oti.newamerica.net/
|
||||
[Serval DNA]: http://developer.servalproject.org/dokuwiki/doku.php?id=content:servaldna:
|
||||
[config option]: ./Servald-Configuration.md
|
||||
[SID]: http://developer.servalproject.org/dokuwiki/doku.php?id=content:tech:sid
|
||||
[MDP]: ./Mesh-Datagram-Protocol.md
|
||||
[MDP port]: http://developer.servalproject.org/dokuwiki/doku.php?id=content:tech:mdp_port_number
|
@ -9,6 +9,10 @@ DNA][] component of the [Serval mesh network][].
|
||||
persistent configuration system and its command-line API, the built-in
|
||||
system file paths, daemon instances and basic network configuration.
|
||||
|
||||
* [MDP Packet Filtering](./Mesh-Packet-Filtering.md) describes the
|
||||
configuration options and rules file syntax for filtering incoming and
|
||||
outgoing MDP packets.
|
||||
|
||||
* [Tunnelling](./Tunnelling.md) describes how to tunnel IP over the Serval
|
||||
mesh network.
|
||||
|
||||
|
@ -643,11 +643,11 @@ public class ServalDCommand
|
||||
}
|
||||
|
||||
public static Process mspTunnnelCreate(String exec, int ip_port, int msp_port) throws IOException {
|
||||
return new ProcessBuilder(exec, "msp", "connect", "--forward="+ip_port, Integer.toString(msp_port)).start();
|
||||
return new ProcessBuilder(exec, "msp", "listen", "--forward="+ip_port, Integer.toString(msp_port)).start();
|
||||
}
|
||||
|
||||
public static Process mspTunnnelCreate(String exec, int ip_port, String serviceName, int msp_port) throws IOException {
|
||||
return new ProcessBuilder(exec, "msp", "connect", "--forward="+ip_port, "--service="+serviceName, Integer.toString(msp_port)).start();
|
||||
return new ProcessBuilder(exec, "msp", "listen", "--forward="+ip_port, "--service="+serviceName, Integer.toString(msp_port)).start();
|
||||
}
|
||||
|
||||
public static Process mspTunnelConnect(String exec, int ip_port, SubscriberId msp_sid, int msp_port) throws IOException {
|
||||
|
@ -782,8 +782,7 @@ static int process_packet(int mdp_sock, struct mdp_header *header, const uint8_t
|
||||
{
|
||||
// any kind of error reported by the daemon, close all related msp connections on this mdp socket
|
||||
if (header->flags & MDP_FLAG_ERROR){
|
||||
WHY("Error returned from daemon");
|
||||
msp_close_all(mdp_sock);
|
||||
WHY("Error returned from daemon!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -853,6 +852,7 @@ static int process_packet(int mdp_sock, struct mdp_header *header, const uint8_t
|
||||
uint8_t response = FLAG_STOP;
|
||||
// we don't have a matching socket, reply with STOP flag to force breaking the connection
|
||||
// TODO global rate limit?
|
||||
// Note that we might recieve a queued packet after sending a MDP_FLAG_CLOSE, so this might trigger an error
|
||||
mdp_send(mdp_sock, header, &response, 1);
|
||||
if (config.debug.msp)
|
||||
DEBUGF("Replying to unexpected packet with STOP packet");
|
||||
|
32
msp_proxy.c
32
msp_proxy.c
@ -30,6 +30,7 @@
|
||||
#include "strbuf_helpers.h"
|
||||
#include "dataformats.h"
|
||||
#include "socket.h"
|
||||
#include "conf.h"
|
||||
|
||||
struct buffer{
|
||||
size_t position;
|
||||
@ -208,7 +209,8 @@ static void remote_shutdown(struct connection *conn)
|
||||
WARNF_perror("shutdown(%d)", conn->alarm_out.poll.fd);
|
||||
}
|
||||
msp_get_remote(conn->sock, &remote);
|
||||
INFOF(" - Connection with %s:%d remote shutdown", alloca_tohex_sid_t(remote.sid), remote.port);
|
||||
if (config.debug.msp)
|
||||
DEBUGF(" - Connection with %s:%d remote shutdown", alloca_tohex_sid_t(remote.sid), remote.port);
|
||||
}
|
||||
|
||||
static void local_shutdown(struct connection *conn)
|
||||
@ -216,7 +218,8 @@ static void local_shutdown(struct connection *conn)
|
||||
struct mdp_sockaddr remote;
|
||||
msp_get_remote(conn->sock, &remote);
|
||||
msp_shutdown(conn->sock);
|
||||
INFOF(" - Connection with %s:%d local shutdown", alloca_tohex_sid_t(remote.sid), remote.port);
|
||||
if (config.debug.msp)
|
||||
DEBUGF(" - Connection with %s:%d local shutdown", alloca_tohex_sid_t(remote.sid), remote.port);
|
||||
}
|
||||
|
||||
static size_t msp_handler(MSP_SOCKET sock, msp_state_t state, const uint8_t *payload, size_t len, void *context)
|
||||
@ -260,9 +263,10 @@ static size_t msp_handler(MSP_SOCKET sock, msp_state_t state, const uint8_t *pay
|
||||
if (state & MSP_STATE_CLOSED){
|
||||
struct mdp_sockaddr remote;
|
||||
msp_get_remote(sock, &remote);
|
||||
INFOF(" - Connection with %s:%d closed %s",
|
||||
alloca_tohex_sid_t(remote.sid), remote.port,
|
||||
(state & MSP_STATE_STOPPED) ? "suddenly":"gracefully");
|
||||
if (config.debug.msp)
|
||||
DEBUGF(" - Connection with %s:%d closed %s",
|
||||
alloca_tohex_sid_t(remote.sid), remote.port,
|
||||
(state & MSP_STATE_STOPPED) ? "suddenly":"gracefully");
|
||||
|
||||
conn->sock = MSP_SOCKET_NULL;
|
||||
if (is_watching(&conn->alarm_in))
|
||||
@ -298,7 +302,8 @@ static size_t msp_listener(MSP_SOCKET sock, msp_state_t state, const uint8_t *pa
|
||||
|
||||
struct mdp_sockaddr remote;
|
||||
msp_get_remote(sock, &remote);
|
||||
INFOF(" - New connection from %s:%d", alloca_tohex_sid_t(remote.sid), remote.port);
|
||||
if (config.debug.msp)
|
||||
DEBUGF(" - New connection from %s:%d", alloca_tohex_sid_t(remote.sid), remote.port);
|
||||
int fd_in = STDIN_FILENO;
|
||||
int fd_out = STDOUT_FILENO;
|
||||
|
||||
@ -499,7 +504,8 @@ static void listen_poll(struct sched_ent *alarm)
|
||||
WHYF_perror("accept(%d)", alarm->poll.fd);
|
||||
return;
|
||||
}
|
||||
INFOF("- Incoming TCP connection from %s", alloca_socket_address(&addr));
|
||||
if (config.debug.msp)
|
||||
DEBUGF("- Incoming TCP connection from %s", alloca_socket_address(&addr));
|
||||
watch(&mdp_sock);
|
||||
MSP_SOCKET sock = msp_socket(mdp_sock.poll.fd, 0);
|
||||
if (msp_socket_is_null(sock))
|
||||
@ -616,7 +622,8 @@ int app_msp_connection(const struct cli_parsed *parsed, struct cli_context *UNUS
|
||||
if (socket_listen(listen_alarm.poll.fd, 0)==-1)
|
||||
goto end;
|
||||
watch(&listen_alarm);
|
||||
INFOF("- Forwarding from %s to %s:%d", alloca_socket_address(&ip_addr), alloca_tohex_sid_t(addr.sid), addr.port);
|
||||
if (config.debug.msp)
|
||||
DEBUGF("- Forwarding from %s to %s:%d", alloca_socket_address(&ip_addr), alloca_tohex_sid_t(addr.sid), addr.port);
|
||||
}else{
|
||||
watch(&mdp_sock);
|
||||
sock = msp_socket(mdp_sock.poll.fd, 0);
|
||||
@ -626,7 +633,8 @@ int app_msp_connection(const struct cli_parsed *parsed, struct cli_context *UNUS
|
||||
goto end;
|
||||
msp_set_handler(sock, msp_handler, conn);
|
||||
msp_connect(sock, &addr);
|
||||
INFOF("- Connecting to %s:%d", alloca_tohex_sid_t(addr.sid), addr.port);
|
||||
if (config.debug.msp)
|
||||
DEBUGF("- Connecting to %s:%d", alloca_tohex_sid_t(addr.sid), addr.port);
|
||||
}
|
||||
}else{
|
||||
watch(&mdp_sock);
|
||||
@ -640,10 +648,12 @@ int app_msp_connection(const struct cli_parsed *parsed, struct cli_context *UNUS
|
||||
|
||||
listener=sock;
|
||||
if (local_port_string){
|
||||
INFOF("- Forwarding from port %d to %s", addr.port, alloca_socket_address(&ip_addr));
|
||||
if (config.debug.msp)
|
||||
DEBUGF("- Forwarding from port %d to %s", addr.port, alloca_socket_address(&ip_addr));
|
||||
}else{
|
||||
once = 1;
|
||||
INFOF(" - Listening on port %d", addr.port);
|
||||
if (config.debug.msp)
|
||||
DEBUGF(" - Listening on port %d", addr.port);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -184,7 +184,7 @@ ssize_t _ob_makespace(struct __sourceloc __whence, struct overlay_buffer *b, siz
|
||||
if (b->position)
|
||||
assert(b->bytes != NULL);
|
||||
if (b->position + bytes > b->sizeLimit) {
|
||||
if (config.debug.packetformats)
|
||||
if (config.debug.overlaybuffer)
|
||||
DEBUGF("ob_makespace(): asked for space to %zu, beyond size limit of %zu", b->position + bytes, b->sizeLimit);
|
||||
return 0;
|
||||
}
|
||||
@ -192,7 +192,7 @@ ssize_t _ob_makespace(struct __sourceloc __whence, struct overlay_buffer *b, siz
|
||||
return 1;
|
||||
// Don't realloc a static buffer.
|
||||
if (b->bytes && b->allocated == NULL) {
|
||||
if (config.debug.packetformats)
|
||||
if (config.debug.overlaybuffer)
|
||||
DEBUGF("ob_makespace(): asked for space to %zu, beyond static buffer size of %zu", b->position + bytes, b->allocSize);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1345,8 +1345,8 @@ static void mdp_process_packet(struct socket_address *client, struct mdp_header
|
||||
// find the matching sid from our keyring
|
||||
internal_header.source = find_subscriber(header->local.sid.binary, sizeof(header->local.sid), 0);
|
||||
if (!internal_header.source || internal_header.source->reachable != REACHABLE_SELF){
|
||||
mdp_reply_error(client, header);
|
||||
WHY("Subscriber is not local");
|
||||
mdp_reply_error(client, header);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1393,14 +1393,14 @@ static void mdp_process_packet(struct socket_address *client, struct mdp_header
|
||||
|
||||
if (header->flags & MDP_FLAG_BIND){
|
||||
if (binding){
|
||||
mdp_reply_error(client, header);
|
||||
WHYF("Port %d already bound", header->local.port);
|
||||
mdp_reply_error(client, header);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!free_slot){
|
||||
mdp_reply_error(client, header);
|
||||
WHY("Max supported bindings reached");
|
||||
mdp_reply_error(client, header);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1431,11 +1431,10 @@ static void mdp_process_packet(struct socket_address *client, struct mdp_header
|
||||
if (!binding
|
||||
|| binding->internal
|
||||
|| cmp_sockaddr(&binding->client, client)!=0){
|
||||
mdp_reply_error(client, header);
|
||||
WHYF("Already bound by someone else? %s vs %s",
|
||||
alloca_socket_address(&binding->client),
|
||||
alloca_socket_address(client));
|
||||
|
||||
mdp_reply_error(client, header);
|
||||
}
|
||||
break;
|
||||
case MDP_IDENTITY:
|
||||
@ -1456,8 +1455,8 @@ static void mdp_process_packet(struct socket_address *client, struct mdp_header
|
||||
mdp_reply_ok(client, header);
|
||||
break;
|
||||
default:
|
||||
mdp_reply_error(client, header);
|
||||
WHYF("Unknown command port %d", header->remote.port);
|
||||
mdp_reply_error(client, header);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1468,8 +1467,8 @@ static void mdp_process_packet(struct socket_address *client, struct mdp_header
|
||||
|| !internal_header.source
|
||||
|| header->local.port == 0
|
||||
|| cmp_sockaddr(&binding->client, client)!=0){
|
||||
WHY("Can't send data packet, no matching port binding!");
|
||||
mdp_reply_error(client, header);
|
||||
WHY("No matching binding found");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -380,12 +380,6 @@ int packetOkOverlay(struct overlay_interface *interface,unsigned char *packet, s
|
||||
if (config.debug.packetrx || interface->debug) {
|
||||
DEBUGF("Received on %s, len %d", interface->name, (int)len);
|
||||
DEBUG_packet_visualise("Received packet",packet,len);
|
||||
if (config.debug.interactive_io) {
|
||||
fprintf(stderr,"Press ENTER to continue..."); fflush(stderr);
|
||||
char buffer[80];
|
||||
if (!fgets(buffer,80,stdin))
|
||||
FATAL_perror("calling fgets");
|
||||
}
|
||||
}
|
||||
|
||||
struct overlay_frame f;
|
||||
|
@ -88,15 +88,6 @@ int overlay_frame_append_payload(struct decode_context *context, int encapsulati
|
||||
|
||||
ob_checkpoint(b);
|
||||
|
||||
if (config.debug.packetconstruction){
|
||||
DEBUGF( "+++++\nFrame from %s to %s of type 0x%02x %s:",
|
||||
alloca_tohex_sid_t(p->source->sid),
|
||||
alloca_tohex_sid_t(p->destination->sid),p->type,
|
||||
"append_payload stuffing into packet");
|
||||
if (p->payload)
|
||||
dump("payload contents", &p->payload->bytes[0], ob_position(p->payload));
|
||||
}
|
||||
|
||||
struct broadcast *broadcast=NULL;
|
||||
if ((!p->destination) && !is_all_matching(p->broadcast_id.id,BROADCAST_LEN,0)){
|
||||
broadcast = &p->broadcast_id;
|
||||
|
@ -519,8 +519,6 @@ overlay_fill_send_packet(struct outgoing_packet *packet, time_ms_t now) {
|
||||
}
|
||||
|
||||
if(packet->buffer){
|
||||
if (config.debug.packetconstruction)
|
||||
ob_dump(packet->buffer,"assembled packet");
|
||||
|
||||
overlay_broadcast_ensemble(packet->destination, packet->buffer);
|
||||
ret=1;
|
||||
|
@ -34,7 +34,6 @@ setup_logging() {
|
||||
set debug.rhizome on \
|
||||
set debug.rhizome_manifest on \
|
||||
set debug.rhizome_store on \
|
||||
set debug.rejecteddata on \
|
||||
set log.console.level debug \
|
||||
set log.console.show_time on
|
||||
}
|
||||
|
@ -43,7 +43,6 @@ set_rhizome_config() {
|
||||
executeOk_servald config \
|
||||
set debug.rhizome on \
|
||||
set debug.rhizome_manifest on \
|
||||
set debug.rejecteddata on \
|
||||
set debug.verbose on \
|
||||
set log.console.level debug
|
||||
}
|
||||
|
@ -742,7 +742,6 @@ start_radio_instance() {
|
||||
set debug.rhizome_ads on \
|
||||
set debug.rhizome_tx on \
|
||||
set debug.rhizome_rx on \
|
||||
set debug.throttling on \
|
||||
set debug.radio_link on \
|
||||
set rhizome.advertise.interval 5000 \
|
||||
set rhizome.rhizome_mdp_block_size 375 \
|
||||
|
@ -142,13 +142,13 @@ test_multiple_ids() {
|
||||
executeOk_servald mdp ping --timeout=3 $SIDB2 1
|
||||
tfw_cat --stdout --stderr
|
||||
executeOk_servald route print
|
||||
link_matches --broadcast $SIDB1
|
||||
link_matches $SIDB1
|
||||
link_matches --via $SIDB1 $SIDB2
|
||||
set_instance +B
|
||||
executeOk_servald mdp ping --timeout=3 $SIDA2 1
|
||||
tfw_cat --stdout --stderr
|
||||
executeOk_servald route print
|
||||
link_matches --broadcast $SIDA1
|
||||
link_matches $SIDA1
|
||||
link_matches --via $SIDA1 $SIDA2
|
||||
}
|
||||
|
||||
@ -284,7 +284,6 @@ setup_simulate_extender() {
|
||||
set interfaces.1.file "$END2"
|
||||
foreach_instance +A +B \
|
||||
executeOk_servald config \
|
||||
set debug.throttling on \
|
||||
set debug.packetradio on \
|
||||
set debug.radio_link on \
|
||||
set interfaces.1.type CATEAR \
|
||||
@ -424,6 +423,9 @@ setup_single_filter() {
|
||||
set_instance +B
|
||||
executeOk_servald config \
|
||||
set interfaces.1.drop_broadcasts on
|
||||
set_instance +A
|
||||
executeOk_servald config \
|
||||
set interfaces.1.drop_unicasts on
|
||||
foreach_instance +A +B start_servald_server
|
||||
}
|
||||
test_single_filter() {
|
||||
@ -485,6 +487,30 @@ test_prefer_unicast() {
|
||||
tfw_cat --stdout --stderr
|
||||
}
|
||||
|
||||
doc_prefer_broadcast="Prefer broadcast packets"
|
||||
setup_prefer_broadcast() {
|
||||
setup_servald
|
||||
assert_no_servald_processes
|
||||
foreach_instance +A +B create_single_identity
|
||||
foreach_instance +A +B add_servald_interface 1
|
||||
foreach_instance +A +B \
|
||||
executeOk_servald config \
|
||||
set interfaces.1.prefer_unicast 0 \
|
||||
set debug.overlayframes 1
|
||||
foreach_instance +A +B start_servald_server
|
||||
}
|
||||
test_prefer_broadcast() {
|
||||
set_instance +A
|
||||
wait_until has_link --broadcast $SIDB
|
||||
set_instance +B
|
||||
wait_until has_link --broadcast $SIDA
|
||||
wait_until path_exists +A +B
|
||||
wait_until path_exists +B +A
|
||||
set_instance +A
|
||||
executeOk_servald mdp ping --timeout=3 $SIDB 1
|
||||
tfw_cat --stdout --stderr
|
||||
}
|
||||
|
||||
doc_multihop_linear="Start 4 instances in a linear arrangement"
|
||||
setup_multihop_linear() {
|
||||
setup_servald
|
||||
|
Loading…
x
Reference in New Issue
Block a user