Mistake on this page?
Report an issue in GitHub or email us
bb_ble_api_pdufilt.h
Go to the documentation of this file.
1 /*************************************************************************************************/
2 /*!
3  * \file
4  *
5  * \brief BLE baseband PDU filtering interface file.
6  *
7  * Copyright (c) 2016-2018 Arm Ltd. All Rights Reserved.
8  *
9  * Copyright (c) 2019-2020 Packetcraft, Inc.
10  *
11  * Licensed under the Apache License, Version 2.0 (the "License");
12  * you may not use this file except in compliance with the License.
13  * You may obtain a copy of the License at
14  *
15  * http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  */
23 /*************************************************************************************************/
24 
25 #ifndef BB_BLE_API_PDUFILT_H
26 #define BB_BLE_API_PDUFILT_H
27 
28 #include "wsf_types.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 /*! \addtogroup BB_API_BLE_PDU_FILT
35  * \{ */
36 
37 /**************************************************************************************************
38  Data Types
39 **************************************************************************************************/
40 
41 /*! \brief Check whether a flag is set. */
42 #define BB_BLE_PDU_FILT_FLAG_IS_SET(pFilt, flag) (((pFilt)->flags & BB_BLE_PDU_FILT_FLAG_##flag) != 0)
43 
44 /*! \brief Set a flag. */
45 #define BB_BLE_PDU_FILT_SET_FLAG(pFilt, flag) (pFilt)->flags |= BB_BLE_PDU_FILT_FLAG_##flag;
46 
47 /*! \brief PDU filtering flags. */
48 enum
49 {
50  /* Common flags. */
51  BB_BLE_PDU_FILT_FLAG_LOCAL_ADDR_MATCH_ENA = (1 << 0), /*!< Local address should be matched. */
52  BB_BLE_PDU_FILT_FLAG_LOCAL_ADDR_MATCH_RAND = (1 << 1), /*!< Local address to match is a random address. */
53  BB_BLE_PDU_FILT_FLAG_PEER_ADDR_MATCH_ENA = (1 << 2), /*!< Peer address should be matched. */
54  BB_BLE_PDU_FILT_FLAG_PEER_ADDR_MATCH_RAND = (1 << 3), /*!< Peer address to match is a random address. */
55 
56  /* Privacy flags. */
57  BB_BLE_PDU_FILT_FLAG_LOCAL_ADDR_RES_ENA = (1 << 4), /*!< Local address resolution is enabled. */
58  BB_BLE_PDU_FILT_FLAG_LOCAL_ADDR_RES_OPT = (1 << 5), /*!< Local address resolution is optional. */
59  BB_BLE_PDU_FILT_FLAG_PEER_ADDR_RES_ENA = (1 << 6), /*!< Peer address resolution is enabled. */
60 };
61 
62 /*! \brief Periodic PDU filtering parameters. */
63 typedef struct
64 {
65  uint8_t filterPolicy; /*!< Filter policy. */
66  uint8_t advSID; /*!< Advertising SID. */
67  uint8_t advAddrType; /*!< Advertiser Address Type. */
68  uint64_t advAddr; /*!< Advertiser Address. */
70 
71 /*! \brief PDU filtering parameters. */
72 typedef struct
73 {
74  uint16_t pduTypeFilt; /*!< Bit map of the PDUs the BB should allow. */
75  uint16_t wlPduTypeFilt; /*!< Bit map of the PDUs the BB should pass through the whitelist. */
76  uint32_t flags; /*!< Flags for PDU filtering. */
77  uint64_t localAddrMatch; /*!< Local address to match. */
78  uint64_t peerAddrMatch; /*!< Peer address to match. */
80 
81 /*! \brief Extended PDU filtering parameters. */
82 typedef struct
83 {
84  uint64_t peerAddr; /*!< Peer address. */
85  uint64_t localAddr; /*!< Local address. */
86  uint8_t pduType; /*!< PDU type. */
87  uint8_t extHdrFlags; /*!< Extended header flags. */
88  bool_t peerAddrRand; /*!< TRUE if peer address is random, FALSE otherwise. */
89  bool_t localAddrRand; /*!< TRUE if local address is random, FALSE otherwise. */
91 
92 /*! \brief PDU filtering results. */
93 typedef struct
94 {
95  uint64_t peerAddr; /*!< Peer address. */
96  uint64_t peerIdAddr; /*!< Peer ID address. */
97  uint8_t pduType; /*!< PDU type. */
98  uint8_t pduLen; /*!< PDU length. */
99  bool_t peerAddrRand; /*!< TRUE if peer address is random. */
100  bool_t peerIdAddrRand; /*!< TRUE if peer ID address is random. */
101  bool_t peerMatch; /*!< TRUE if peer address was resolved or matched. */
102  bool_t localMatch; /*!< TRUE if local address was resolved or matched. */
104 
105 /**************************************************************************************************
106  Function Declarations
107 **************************************************************************************************/
108 
109 /*************************************************************************************************/
110 /*!
111  * \brief Check if PDU is allowed, i.e., should not be ignored.
112  *
113  * \param pBuf PDU buffer.
114  * \param pFiltParams Filter parameters.
115  * \param forceRes TRUE if address resolution should be forced.
116  * \param pFiltResults Storage for filter results.
117  *
118  * \return TRUE if PDU is allowed, FALSE if PDU should be ignored.
119  */
120 /*************************************************************************************************/
121 bool_t BbBlePduFiltCheck(const uint8_t *pBuf, const bbBlePduFiltParams_t *pFiltParams,
122  bool_t forceRes, bbBlePduFiltResults_t *pFiltResults);
123 
124 /*************************************************************************************************/
125 /*!
126  * \brief Check if PDU is allowed, i.e., should not be ignored.
127  *
128  * \param pExtFiltParams Extended filter parameters.
129  * \param pFiltParams Filter parameters.
130  * \param forceRes TRUE if address resolution should be forced.
131  * \param pFiltResults Storage for filter results.
132  *
133  * \return TRUE if PDU is allowed, FALSE if PDU should be ignored.
134  */
135 /*************************************************************************************************/
136 bool_t BbBleExtPduFiltCheck(const bbBlePduExtFiltParams_t *pExtFiltParams,
137  const bbBlePduFiltParams_t *pFiltParams,
138  bool_t forceRes, bbBlePduFiltResults_t *pFiltResults);
139 
140 /*************************************************************************************************/
141 /*!
142  * \brief Get the peer ID address.
143  *
144  * \param pFiltResults Filter results.
145  * \param pPeerIdAddr Storage for peer ID address.
146  * \param pPeerIdAddrType Storage for peer ID address type;
147  */
148 /*************************************************************************************************/
149 static inline void BbBlePduFiltResultsGetPeerIdAddr(const bbBlePduFiltResults_t *pFiltResults, uint64_t *pPeerIdAddr, uint8_t *pPeerIdAddrType)
150 {
151  const unsigned int addrIdBit = 1 << 1;
152 
153  *pPeerIdAddrType = pFiltResults->peerIdAddrRand;
154  if ((pFiltResults->peerIdAddrRand != pFiltResults->peerAddrRand) ||
155  (pFiltResults->peerIdAddr != pFiltResults->peerAddr))
156  {
157  *pPeerIdAddrType |= addrIdBit;
158  }
159  *pPeerIdAddr = pFiltResults->peerIdAddr;
160 }
161 
162 /*************************************************************************************************/
163 /*!
164  * \brief Get the peer RPA.
165  *
166  * \param pFiltResults Filter results.
167  * \param pPeerRpa Storage for peer RPA or 0.
168  */
169 /*************************************************************************************************/
170 static inline void BbBlePduFiltResultsGetPeerRpa(const bbBlePduFiltResults_t *pFiltResults, uint64_t *pPeerRpa)
171 {
172  *pPeerRpa = 0;
173  if ((pFiltResults->peerIdAddrRand != pFiltResults->peerAddrRand) ||
174  (pFiltResults->peerIdAddr != pFiltResults->peerAddr))
175  {
176  *pPeerRpa = pFiltResults->peerAddr;
177  }
178 }
179 
180 /*! \} */ /* BB_API_BLE_PDU_FILT */
181 
182 #ifdef __cplusplus
183 };
184 #endif
185 
186 #endif /* BB_BLE_API_PDUFILT_H */
Extended PDU filtering parameters.
static void BbBlePduFiltResultsGetPeerIdAddr(const bbBlePduFiltResults_t *pFiltResults, uint64_t *pPeerIdAddr, uint8_t *pPeerIdAddrType)
Get the peer ID address.
static void BbBlePduFiltResultsGetPeerRpa(const bbBlePduFiltResults_t *pFiltResults, uint64_t *pPeerRpa)
Get the peer RPA.
Periodic PDU filtering parameters.
PDU filtering parameters.
PDU filtering results.
Platform-independent data types.
bool_t BbBleExtPduFiltCheck(const bbBlePduExtFiltParams_t *pExtFiltParams, const bbBlePduFiltParams_t *pFiltParams, bool_t forceRes, bbBlePduFiltResults_t *pFiltResults)
Check if PDU is allowed, i.e., should not be ignored.
bool_t BbBlePduFiltCheck(const uint8_t *pBuf, const bbBlePduFiltParams_t *pFiltParams, bool_t forceRes, bbBlePduFiltResults_t *pFiltResults)
Check if PDU is allowed, i.e., should not be ignored.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.