* [PATCH BlueZ v2] mesh: Enable local loopback
@ 2019-03-08 22:40 Brian Gix
2019-03-11 22:19 ` Gix, Brian
0 siblings, 1 reply; 2+ messages in thread
From: Brian Gix @ 2019-03-08 22:40 UTC (permalink / raw)
To: linux-bluetooth; +Cc: inga.stotland, brian.gix
Implements mechanism to allow direct messaging between local
nodes without requiring an external relay node.
---
mesh/net.c | 51 ++++++++++++++++++++++++++++++++-------------------
1 file changed, 32 insertions(+), 19 deletions(-)
diff --git a/mesh/net.c b/mesh/net.c
index 2adae70c3..b173e1c09 100644
--- a/mesh/net.c
+++ b/mesh/net.c
@@ -254,10 +254,24 @@ struct net_decode {
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);
@@ -2267,16 +2281,27 @@ static void send_relay_pkt(struct mesh_net *net, uint8_t *data, uint8_t size)
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);
}
@@ -2461,18 +2486,6 @@ static enum _relay_advice packet_received(void *user_data,
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;
--
2.14.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH BlueZ v2] mesh: Enable local loopback
2019-03-08 22:40 [PATCH BlueZ v2] mesh: Enable local loopback Brian Gix
@ 2019-03-11 22:19 ` Gix, Brian
0 siblings, 0 replies; 2+ messages in thread
From: Gix, Brian @ 2019-03-11 22:19 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Stotland, Inga
Applied
On Fri, 2019-03-08 at 14:40 -0800, Brian Gix wrote:
> Implements mechanism to allow direct messaging between local
> nodes without requiring an external relay node.
> ---
> mesh/net.c | 51 ++++++++++++++++++++++++++++++++-------------------
> 1 file changed, 32 insertions(+), 19 deletions(-)
>
> diff --git a/mesh/net.c b/mesh/net.c
> index 2adae70c3..b173e1c09 100644
> --- a/mesh/net.c
> +++ b/mesh/net.c
> @@ -254,10 +254,24 @@ struct net_decode {
> 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);
> @@ -2267,16 +2281,27 @@ static void send_relay_pkt(struct mesh_net *net, uint8_t *data, uint8_t size)
> 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);
> }
> @@ -2461,18 +2486,6 @@ static enum _relay_advice packet_received(void *user_data,
> 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;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-03-11 22:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-08 22:40 [PATCH BlueZ v2] mesh: Enable local loopback Brian Gix
2019-03-11 22:19 ` Gix, Brian
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).