diff --git a/mesh/net.c b/mesh/net.c
index 2adae70..b173e1c 100644
--- a/mesh/net.c
+++ b/mesh/net.c
bool proxy;
};
+struct net_queue_data {
+ struct mesh_io_recv_info *info;
+ struct mesh_net *net;
+ const uint8_t *data;
+ uint8_t *out;
+ size_t out_size;
+ enum _relay_advice relay_advice;
+ uint32_t key_id;
+ uint32_t iv_index;
+ uint16_t len;
+};
+
#define FAST_CACHE_SIZE 8
static struct l_queue *fast_cache;
static struct l_queue *nets;
+static void net_rx(void *net_ptr, void *user_data);
+
static inline struct mesh_subnet *get_primary_subnet(struct mesh_net *net)
{
return l_queue_peek_head(net->subnets);
static void send_msg_pkt(struct mesh_net *net, uint8_t *packet, uint8_t size)
{
struct mesh_io *io = net->io;
- struct mesh_io_send_info info = {
- .type = MESH_IO_TIMING_TYPE_GENERAL,
- .u.gen.interval = net->tx_interval,
- .u.gen.cnt = net->tx_cnt,
- .u.gen.min_delay = DEFAULT_MIN_DELAY,
- /* No extra randomization when sending regular mesh messages */
- .u.gen.max_delay = DEFAULT_MIN_DELAY
+ struct mesh_io_send_info info;
+ struct net_queue_data net_data = {
+ .info = NULL,
+ .data = packet + 1,
+ .len = size - 1,
+ .relay_advice = RELAY_NONE,
};
+ /* Send to local nodes first */
+ l_queue_foreach(nets, net_rx, &net_data);
+
+ if (net_data.relay_advice == RELAY_DISALLOWED)
+ return;
+
packet[0] = MESH_AD_TYPE_NETWORK;
+ info.type = MESH_IO_TIMING_TYPE_GENERAL;
+ info.u.gen.interval = net->tx_interval;
+ info.u.gen.cnt = net->tx_cnt;
+ info.u.gen.min_delay = DEFAULT_MIN_DELAY;
+ /* No extra randomization when sending regular mesh messages */
+ info.u.gen.max_delay = DEFAULT_MIN_DELAY;
mesh_io_send(io, &info, packet, size);
}
return RELAY_NONE;
}
-struct net_queue_data {
- struct mesh_io_recv_info *info;
- struct mesh_net *net;
- const uint8_t *data;
- uint8_t *out;
- size_t out_size;
- enum _relay_advice relay_advice;
- uint32_t key_id;
- uint32_t iv_index;
- uint16_t len;
-};
-
static void net_rx(void *net_ptr, void *user_data)
{
struct net_queue_data *data = user_data;