logger(DEBUG_TRAFFIC, LOG_INFO, "Broadcasting packet of %d bytes from %s (%s)",
packet->len, from->name, from->hostname);
- switch(broadcast_mode) {
- // In MST mode, broadcast packets travel via the Minimum Spanning Tree.
- // This guarantees all nodes receive the broadcast packet, and
- // usually distributes the sending of broadcast packets over all nodes.
- case BMODE_MST:
- for list_each(connection_t, c, connection_list)
- if(c->status.active && c->status.mst && c != from->nexthop->connection)
- send_packet(c->node, packet);
- break;
-
- // In direct mode, we send copies to each node we know of.
- // However, this only reaches nodes that can be reached in a single hop.
- // We don't have enough information to forward broadcast packets in this case.
- case BMODE_DIRECT:
- if(from != myself)
- break;
-
- for splay_each(node_t, n, node_tree)
- if(n->status.reachable && n != myself && ((n->via == myself && n->nexthop == n) || n->via == n))
- send_packet(n, packet);
- break;
-
- default:
- break;
- }
+ for list_each(connection_t, c, connection_list)
+ if(c->status.active && c->status.mst && c != from->nexthop->connection)
+ send_packet(c->node, packet);
}
static node_t *try_harder(const sockaddr_t *from, const vpn_packet_t *pkt) {
#include "utils.h"
#include "libmeshlink.h"
-fmode_t forwarding_mode = FMODE_INTERNAL;
-bmode_t broadcast_mode = BMODE_MST;
bool decrement_ttl = false;
-bool directonly = false;
-bool priorityinheritance = false;
-int macexpire = 600;
-mac_t mymac = {{0xFE, 0xFD, 0, 0, 0, 0}};
-bool pcap = false;
static bool ratelimit(int frequency) {
static time_t lasttime = 0;
return;
}
- if (directonly && owner!=via) {
- logger(DEBUG_TRAFFIC, LOG_WARNING, "Direct Only is requested. Dropping packet because direct connection not available \n");
- return;
- }
-
send_packet(owner,packet);
return;
}
#include "net.h"
#include "node.h"
-typedef enum rmode_t {
- RMODE_HUB = 0,
- RMODE_SWITCH,
- RMODE_ROUTER,
-} rmode_t;
-
-typedef enum fmode_t {
- FMODE_OFF = 0,
- FMODE_INTERNAL,
- FMODE_KERNEL,
-} fmode_t;
-
-typedef enum bmode_t {
- BMODE_NONE = 0,
- BMODE_MST,
- BMODE_DIRECT,
-} bmode_t;
-
-extern fmode_t forwarding_mode;
-extern bmode_t broadcast_mode;
extern bool decrement_ttl;
-extern bool directonly;
-extern bool priorityinheritance;
-extern int macexpire;
-extern bool pcap;
-
-extern mac_t mymac;
extern void route(struct node_t *, struct vpn_packet_t *);