summaryrefslogtreecommitdiff
path: root/mesh/net.c
diff options
context:
space:
mode:
authorBrian Gix <brian.gix@intel.com>2020-02-23 10:47:37 -0800
committerBrian Gix <brian.gix@intel.com>2020-02-26 11:20:08 -0800
commit6a6fe856a900fb53ce38dd3584d5d1d417d8aede (patch)
tree365d79ac9d3557d2d8fef133b2e516f8efc1cf48 /mesh/net.c
parent4ec7da4037ac59102b70e9edb34d429f8af42f4f (diff)
downloadbluez-6a6fe856a900fb53ce38dd3584d5d1d417d8aede.tar.gz
mesh: rework incoming advertisement filtering
Future versions of Mesh will introduce new advertising packets, which do not fit in the limited and rigid filtering currently used. This minor rewrite allows registering and receiving of *any* AD types, including the filtering on multiple octets of the incoming AD parts.
Diffstat (limited to 'mesh/net.c')
-rw-r--r--mesh/net.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/mesh/net.c b/mesh/net.c
index ec05b6be9..5cf358fbd 100644
--- a/mesh/net.c
+++ b/mesh/net.c
@@ -2884,6 +2884,9 @@ bool mesh_net_attach(struct mesh_net *net, struct mesh_io *io)
first = l_queue_isempty(nets);
if (first) {
+ uint8_t snb[] = {MESH_AD_TYPE_BEACON, 0x01};
+ uint8_t pkt[] = {MESH_AD_TYPE_NETWORK};
+
if (!nets)
nets = l_queue_new();
@@ -2891,9 +2894,9 @@ bool mesh_net_attach(struct mesh_net *net, struct mesh_io *io)
fast_cache = l_queue_new();
l_info("Register io cb");
- mesh_io_register_recv_cb(io, MESH_IO_FILTER_BEACON,
+ mesh_io_register_recv_cb(io, snb, sizeof(snb),
beacon_recv, NULL);
- mesh_io_register_recv_cb(io, MESH_IO_FILTER_NET,
+ mesh_io_register_recv_cb(io, pkt, sizeof(pkt),
net_msg_recv, NULL);
}
@@ -2909,6 +2912,8 @@ bool mesh_net_attach(struct mesh_net *net, struct mesh_io *io)
struct mesh_io *mesh_net_detach(struct mesh_net *net)
{
+ uint8_t snb[] = {MESH_AD_TYPE_BEACON, 0x01};
+ uint8_t pkt[] = {MESH_AD_TYPE_NETWORK};
struct mesh_io *io;
uint8_t type = 0;
@@ -2918,8 +2923,8 @@ struct mesh_io *mesh_net_detach(struct mesh_net *net)
io = net->io;
mesh_io_send_cancel(net->io, &type, 1);
- mesh_io_deregister_recv_cb(io, MESH_IO_FILTER_BEACON);
- mesh_io_deregister_recv_cb(io, MESH_IO_FILTER_NET);
+ mesh_io_deregister_recv_cb(io, snb, sizeof(snb));
+ mesh_io_deregister_recv_cb(io, pkt, sizeof(pkt));
net->io = NULL;
l_queue_remove(nets, net);