Select one of the symbols to view example projects that use it.
 
Outline
#include <string.h>
#include <errno.h>
#include "mesh/config.h"
#include "mesh/trace.h"
#include "mesh.h"
#include "settings.h"
bt_mesh_update_rpl(struct bt_mesh_rpl *, struct bt_mesh_net_rx *)
rpl_check_and_store(struct bt_mesh_net_rx *, struct bt_mesh_rpl **)
bt_mesh_rpl_check(struct bt_mesh_net_rx *, struct bt_mesh_rpl **)
bt_mesh_rpl_update()
bt_mesh_rpl_reset_single(uint16_t, bool)
bt_mesh_rpl_reset(bool)
Files
ESP-IDF
components
app_trace
app_update
bootloader_support
bt
common
controller
esp_ble_mesh
api
btc
common
core
bluedroid_host
include
storage
lib
models
v1.1
host
include
porting
cmock
console
cxx
driver
efuse
esp_adc
esp_app_format
esp_bootloader_format
esp_coex
esp_common
esp_driver_ana_cmpr
esp_driver_cam
esp_driver_dac
esp_driver_gpio
esp_driver_gptimer
esp_driver_i2c
esp_driver_i2s
esp_driver_jpeg
esp_driver_ledc
esp_driver_mcpwm
esp_driver_parlio
esp_driver_pcnt
esp_driver_rmt
esp_driver_sdio
esp_driver_sdm
esp_driver_sdmmc
esp_driver_sdspi
esp_driver_spi
esp_driver_tsens
esp_driver_uart
esp_driver_usb_serial_jtag
esp_eth
esp_event
esp_gdbstub
esp_hid
esp_http_client
esp_http_server
esp_https_ota
esp_https_server
esp_hw_support
esp_lcd
esp_local_ctrl
esp_mm
esp_netif
esp_partition
esp_phy
esp_pm
esp_psram
esp_ringbuf
esp_rom
esp_security
esp_system
esp_timer
esp_vfs_console
esp_wifi
esp-tls
espcoredump
hal
heap
http_parser
ieee802154
log
mqtt
newlib
nvs_flash
nvs_sec_provider
openthread
perfmon
protobuf-c
protocomm
pthread
rt
sdmmc
soc
spi_flash
spiffs
tcp_transport
ulp
unity
vfs
wear_levelling
wifi_provisioning
wpa_supplicant
xtensa
examples
lwIP
FreeRTOS
cJSON
mbedTLS
SourceVuESP-IDF Framework and ExamplesESP-IDFcomponents/bt/esp_ble_mesh/core/rpl.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/* Bluetooth Mesh */ /* * SPDX-FileCopyrightText: 2017 Intel Corporation * SPDX-FileContributor: 2018-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 *//* ... */ #include <string.h> #include <errno.h> #include "mesh/config.h" #include "mesh/trace.h" #include "mesh.h" #include "settings.h"6 includes void bt_mesh_update_rpl(struct bt_mesh_rpl *rpl, struct bt_mesh_net_rx *rx) { rpl->src = rx->ctx.addr; rpl->seq = rx->seq; rpl->old_iv = rx->old_iv; if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) { bt_mesh_store_rpl(rpl); }{...} }{ ... } /* Check the Replay Protection List for a replay attempt. If non-NULL match * parameter is given the RPL slot is returned but it is not immediately * updated (needed for segmented messages), whereas if a NULL match is given * the RPL is immediately updated (used for unsegmented messages). *//* ... */ static bool rpl_check_and_store(struct bt_mesh_net_rx *rx, struct bt_mesh_rpl **match) { for (size_t i = 0; i < ARRAY_SIZE(bt_mesh.rpl); i++) { struct bt_mesh_rpl *rpl = &bt_mesh.rpl[i]; /* Empty slot */ if (rpl->src == BLE_MESH_ADDR_UNASSIGNED) { if (match) { *match = rpl; }{...} else { bt_mesh_update_rpl(rpl, rx); }{...} return false; }{...} /* Existing slot for given address */ if (rpl->src == rx->ctx.addr) { if (rx->old_iv && !rpl->old_iv) { return true; }{...} if ((!rx->old_iv && rpl->old_iv) || rpl->seq < rx->seq) { if (match) { *match = rpl; }{...} else { bt_mesh_update_rpl(rpl, rx); }{...} return false; }{...} #if CONFIG_BLE_MESH_NOT_RELAY_REPLAY_MSG rx->replay_msg = 1; #endif return true; }{...} }{...} BT_ERR("RPL is full!"); return true; }{ ... } bool bt_mesh_rpl_check(struct bt_mesh_net_rx *rx, struct bt_mesh_rpl **match) { /* Don't bother checking messages from ourselves */ if (rx->net_if == BLE_MESH_NET_IF_LOCAL) { return false; }{...} /* The RPL is used only for the local node */ if (!rx->local_match) { return false; }{...} return rpl_check_and_store(rx, match); }{ ... } void bt_mesh_rpl_update(void) { /* Discard "old old" IV Index entries from RPL and flag * any other ones (which are valid) as old. *//* ... */ for (size_t i = 0; i < ARRAY_SIZE(bt_mesh.rpl); i++) { struct bt_mesh_rpl *rpl = &bt_mesh.rpl[i]; if (rpl->src) { if (rpl->old_iv) { (void)memset(rpl, 0, sizeof(*rpl)); }{...} else { rpl->old_iv = true; }{...} if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) { bt_mesh_store_rpl(rpl); }{...} }{...} }{...} }{ ... } void bt_mesh_rpl_reset_single(uint16_t src, bool erase) { if (!BLE_MESH_ADDR_IS_UNICAST(src)) { return; }{...} for (size_t i = 0; i < ARRAY_SIZE(bt_mesh.rpl); i++) { if (src == bt_mesh.rpl[i].src) { memset(&bt_mesh.rpl[i], 0, sizeof(struct bt_mesh_rpl)); if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS) && erase) { bt_mesh_clear_rpl_single(src); }{...} }{...} }{...} }{ ... } void bt_mesh_rpl_reset(bool erase) { (void)memset(bt_mesh.rpl, 0, sizeof(bt_mesh.rpl)); if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS) && erase) { bt_mesh_clear_rpl(); }{...} }{ ... }
Details