mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-01-18 02:39:44 +00:00
Add route_link.h
This commit is contained in:
parent
a276fc9d28
commit
79e8a94792
@ -15,6 +15,7 @@ HDRS= fifo.h \
|
||||
serval_types.h \
|
||||
serval.h \
|
||||
server.h \
|
||||
route_link.h \
|
||||
keyring.h \
|
||||
socket.h \
|
||||
cli.h \
|
||||
|
@ -36,6 +36,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#include "mem.h"
|
||||
#include "rotbuf.h"
|
||||
#include "server.h"
|
||||
#include "route_link.h"
|
||||
|
||||
static keyring_file *keyring_open_or_create(const char *path, int writeable);
|
||||
static int keyring_initialise(keyring_file *k);
|
||||
|
@ -66,6 +66,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#include "socket.h"
|
||||
#include "dataformats.h"
|
||||
#include "server.h"
|
||||
#include "route_link.h"
|
||||
|
||||
#ifdef HAVE_UCRED_H
|
||||
#include <ucred.h>
|
||||
|
@ -36,6 +36,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#include "overlay_interface.h"
|
||||
#include "overlay_packet.h"
|
||||
#include "server.h"
|
||||
#include "route_link.h"
|
||||
|
||||
#define MAX_BPIS 1024
|
||||
#define BPI_MASK 0x3ff
|
||||
|
@ -38,6 +38,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#include "str.h"
|
||||
#include "radio_link.h"
|
||||
#include "server.h"
|
||||
#include "route_link.h"
|
||||
|
||||
#ifdef HAVE_IFADDRS_H
|
||||
#include <ifaddrs.h>
|
||||
|
@ -27,6 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#include "overlay_packet.h"
|
||||
#include "keyring.h"
|
||||
#include "strbuf_helpers.h"
|
||||
#include "route_link.h"
|
||||
|
||||
int set_reachable(struct subscriber *subscriber,
|
||||
struct network_destination *destination, struct subscriber *next_hop){
|
||||
|
@ -32,6 +32,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#include "debug.h"
|
||||
#include "keyring.h"
|
||||
#include "dataformats.h"
|
||||
#include "route_link.h"
|
||||
|
||||
int rhizome_mdp_send_block(struct subscriber *dest, const rhizome_bid_t *bid, uint64_t version, uint64_t fileOffset, uint32_t bitmap, uint16_t blockLength)
|
||||
{
|
||||
|
@ -66,6 +66,7 @@
|
||||
#include "overlay_packet.h"
|
||||
#include "overlay_buffer.h"
|
||||
#include "overlay_address.h"
|
||||
#include "route_link.h"
|
||||
|
||||
#define PACKET_FORMAT_NUMBER 123
|
||||
|
||||
|
@ -26,7 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#include "overlay_buffer.h"
|
||||
#include "overlay_interface.h"
|
||||
#include "overlay_packet.h"
|
||||
|
||||
#include "route_link.h"
|
||||
|
||||
struct sockaddr_in loopback;
|
||||
|
||||
@ -260,7 +260,7 @@ int parseMdpPacketHeader(struct decode_context *context, struct overlay_frame *f
|
||||
int parseEnvelopeHeader(struct decode_context *context, struct overlay_interface *interface,
|
||||
struct socket_address *addr, struct overlay_buffer *buffer){
|
||||
IN();
|
||||
|
||||
|
||||
context->interface = interface;
|
||||
if (interface->ifconfig.point_to_point && interface->other_device)
|
||||
context->point_to_point_device = interface->other_device;
|
||||
@ -422,7 +422,10 @@ int packetOkOverlay(struct overlay_interface *interface,unsigned char *packet, s
|
||||
unsigned char *current = ob_ptr(b)+ob_position(b);
|
||||
if (IF_DEBUG(overlayframes))
|
||||
dump("Payload Header", header_start, current - header_start);
|
||||
ret = WHYF("Invalid payload length (%zd)", payload_len);
|
||||
ret = WHYF("Payload length %zd suggests frame should be %zd bytes, but was only %zd",
|
||||
payload_len, ob_position(b)+payload_len, len);
|
||||
|
||||
// TODO signal reduced MTU?
|
||||
goto end;
|
||||
}
|
||||
break;
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "radio_link.h"
|
||||
#include "str.h"
|
||||
#include "strbuf.h"
|
||||
#include "route_link.h"
|
||||
|
||||
typedef struct overlay_txqueue {
|
||||
struct overlay_frame *first;
|
||||
|
19
route_link.c
19
route_link.c
@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#include "keyring.h"
|
||||
#include "server.h"
|
||||
#include "mdp_client.h"
|
||||
#include "route_link.h"
|
||||
|
||||
/*
|
||||
Link state routing;
|
||||
@ -746,6 +747,22 @@ int link_interface_has_neighbours(struct overlay_interface *interface)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int link_destination_has_neighbours(struct network_destination *dest)
|
||||
{
|
||||
struct neighbour *n = neighbours;
|
||||
time_ms_t now = gettime_ms();
|
||||
while(n){
|
||||
struct link_out *l = n->out_links;
|
||||
while(l){
|
||||
if (l->destination == dest && l->timeout >= now)
|
||||
return 1;
|
||||
l=l->_next;
|
||||
}
|
||||
n=n->_next;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int send_legacy_self_announce_ack(struct neighbour *neighbour, struct link_in *link, time_ms_t now){
|
||||
struct overlay_frame *frame=emalloc_zero(sizeof(struct overlay_frame));
|
||||
frame->type = OF_TYPE_SELFANNOUNCE_ACK;
|
||||
@ -1232,7 +1249,7 @@ static void create_out_links(struct neighbour *neighbour, overlay_interface *int
|
||||
}
|
||||
|
||||
// track stats for receiving packets from this neighbour
|
||||
int link_received_packet(struct decode_context *context, int sender_seq, char unicast)
|
||||
int link_received_packet(struct decode_context *context, int sender_seq, uint8_t unicast)
|
||||
{
|
||||
if (!context->sender)
|
||||
return 0;
|
||||
|
49
route_link.h
Normal file
49
route_link.h
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
Serval DNA header file
|
||||
Copyright (C) 2015 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 __SERVAL_DNA__ROUTE_LINK_H
|
||||
#define __SERVAL_DNA__ROUTE_LINK_H
|
||||
|
||||
struct strbuf;
|
||||
struct overlay_interface;
|
||||
struct network_destination;
|
||||
struct subscriber;
|
||||
struct overlay_frame;
|
||||
struct decode_context;
|
||||
struct internal_mdp_header;
|
||||
|
||||
int link_state_announce_links();
|
||||
void link_neighbour_short_status_html(struct strbuf *b, const char *link_prefix);
|
||||
void link_neighbour_status_html(struct strbuf *b, struct subscriber *neighbour);
|
||||
int link_has_neighbours();
|
||||
int link_interface_has_neighbours(struct overlay_interface *interface);
|
||||
int link_destination_has_neighbours(struct network_destination *dest);
|
||||
int link_stop_routing(struct subscriber *subscriber);
|
||||
int link_add_destinations(struct overlay_frame *frame);
|
||||
int link_state_should_forward_broadcast(struct subscriber *transmitter);
|
||||
int link_state_ack_soon(struct subscriber *subscriber);
|
||||
int link_received_duplicate(struct decode_context *context, int payload_seq);
|
||||
int link_received_packet(struct decode_context *context, int sender_seq, uint8_t unicast);
|
||||
int link_unicast_ack(struct subscriber *subscriber, struct overlay_interface *interface, struct socket_address *addr);
|
||||
int link_receive(struct internal_mdp_header *header, struct overlay_buffer *payload);
|
||||
void link_explained(struct subscriber *subscriber);
|
||||
void link_interface_down(struct overlay_interface *interface);
|
||||
int link_state_legacy_ack(struct overlay_frame *frame, time_ms_t now);
|
||||
|
||||
#endif
|
17
serval.h
17
serval.h
@ -302,21 +302,4 @@ int unpack_uint(unsigned char *buffer, int buff_size, uint64_t *v);
|
||||
void rhizome_fetch_log_short_status();
|
||||
extern char crash_handler_clue[1024];
|
||||
|
||||
int link_received_duplicate(struct decode_context *context, int payload_seq);
|
||||
int link_received_packet(struct decode_context *context, int sender_seq, char unicast);
|
||||
int link_receive(struct internal_mdp_header *header, struct overlay_buffer *payload);
|
||||
void link_explained(struct subscriber *subscriber);
|
||||
void link_interface_down(struct overlay_interface *interface);
|
||||
int link_state_announce_links();
|
||||
int link_state_legacy_ack(struct overlay_frame *frame, time_ms_t now);
|
||||
int link_state_ack_soon(struct subscriber *sender);
|
||||
int link_state_should_forward_broadcast(struct subscriber *transmitter);
|
||||
int link_unicast_ack(struct subscriber *subscriber, struct overlay_interface *interface, struct socket_address *addr);
|
||||
int link_add_destinations(struct overlay_frame *frame);
|
||||
void link_neighbour_short_status_html(struct strbuf *b, const char *link_prefix);
|
||||
void link_neighbour_status_html(struct strbuf *b, struct subscriber *neighbour);
|
||||
int link_stop_routing(struct subscriber *subscriber);
|
||||
int link_has_neighbours();
|
||||
int link_interface_has_neighbours(struct overlay_interface *interface);
|
||||
|
||||
#endif // __SERVAL_DNA__SERVAL_H
|
||||
|
1
server.c
1
server.c
@ -38,6 +38,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#include "keyring.h"
|
||||
#include "commandline.h"
|
||||
#include "mdp_client.h"
|
||||
#include "route_link.h"
|
||||
|
||||
#define PROC_SUBDIR "proc"
|
||||
#define PIDFILE_NAME "servald.pid"
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "overlay_address.h"
|
||||
#include "overlay_interface.h"
|
||||
#include "os.h"
|
||||
#include "route_link.h"
|
||||
|
||||
DECLARE_HANDLER("/static/", static_page);
|
||||
DECLARE_HANDLER("/interface/", interface_page);
|
||||
|
Loading…
Reference in New Issue
Block a user