Mistake on this page?
Report an issue in GitHub or email us
bb_ble_sniffer_api.h
Go to the documentation of this file.
1 /*************************************************************************************************/
2 /*!
3  * \file
4  *
5  * \brief Packet sniffer interface file.
6  *
7  * Copyright (c) 2019 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_SNIFFER_API_H
26 #define BB_BLE_SNIFFER_API_H
27 
28 #include "wsf_types.h"
29 #include "bb_api.h"
30 #include "pal_bb_ble.h"
31 #include "ll_defs.h"
32 #include "bb_ble_api.h"
33 
34 #ifndef BB_SNIFFER_ENABLED
35 /*! \brief Sniffer enabled for controller */
36 #define BB_SNIFFER_ENABLED FALSE
37 #endif
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 /**************************************************************************************************
43  Constants
44 **************************************************************************************************/
45 
46 /*! \brief Maximum number of buffer. */
47 #define BB_SNIFFER_MAX_NUM_BUF 20
48 
49 /*! \brief Max packet size for a sniffer packet. */
50 #define BB_SNIFFER_MAX_PKT_SIZE 28
51 
52 /*! \brief Output methods of sniffer. */
53 enum
54 {
55  BB_SNIFFER_OUTPUT_HCI_TOKEN, /*!< Output over HCI through tokens. */
56  BB_SNIFFER_OUTPUT_TOTAL_METHODS, /*!< Total output methods. */
57 
58  BB_SNIFFER_OUTPUT_NULL_METHOD /*!< Null output method. */
59 };
60 
61 /**************************************************************************************************
62  Data Types
63 **************************************************************************************************/
64 
65 /*! \brief Sniffer Packet types (Used to parse packet for sniffer). */
66 enum
67 {
68  BB_SNIFF_PKT_TYPE_TX, /*!< Transmit packets. */
69  BB_SNIFF_PKT_TYPE_RX /*!< Receive packets. */
70 };
71 
72 /*! \brief Sniffer packet metadata. */
73 typedef struct
74 {
75  uint8_t type; /*!< TX/RX. */
76  uint8_t status; /*!< TX/RX status. */
77  uint8_t state; /*!< State of the operation. */
78  uint32_t timeStamp; /*!< Timestamp. */
79  uint8_t rssi; /*!< Signal power (TxPower, or RSSI). */
80  PalBbBleChan_t chan; /*!< channelization params. */
82 
83 /*! \brief Sniffer data packet. */
84 typedef struct
85 {
86  BbBleSnifferMeta_t meta; /*!< Metadata header. */
87  uint8_t hdr[LL_DATA_HDR_MAX_LEN]; /*!< Header raw data. */
89 
90 /*! \brief Sniffer advertisement packet. */
91 typedef struct
92 {
93  BbBleSnifferMeta_t meta; /*!< Metadata header. */
94  uint8_t hdr[LL_ADV_HDR_LEN]; /*!< Header raw data. */
96 
97 /*! \brief Sniffer generic packet. */
98 typedef struct
99 {
100  union
101  {
102  BbBleSnifferMeta_t meta; /*!< Metadata. */
103  BbBleDataSniffPkt_t dataPkt; /*!< Data packet. */
104  BbBleAdvSniffPkt_t advPkt; /*!< Advertising packet. */
105  } pktType; /*!< Packet type. */
107 
108 /*! \brief Sniffer output call signature. */
109 typedef void (*bbSnifferFn_t)(BbBleSnifferPkt_t *pPkt);
110 
111 /*! \brief Sniffer get packet call signature. */
112 typedef BbBleSnifferPkt_t* (*bbSnifferGetPktFn_t)(void);
113 
114 /*! \brief HCI output context. */
115 typedef struct
116 {
117  uint16_t bufIdx; /*!< Current packet buffer index. */
118  BbBleSnifferPkt_t pktBuf[BB_SNIFFER_MAX_NUM_BUF]; /*!< Sotrage for packet buffer. */
120 
121 /*! \brief Sniffer context. */
122 typedef struct
123 {
124  /* Control variables. */
125  bool_t enabled; /*!< Enable status of sniffer. */
126  bbSnifferGetPktFn_t snifferGetPktFn; /*!< Sniffer get packet function callback. */
127  bbSnifferFn_t snifferOutCb; /*!< Sniffer output callback. */
128  uint32_t packetCtr; /*!< Number of packets processed. */
129 
130  /* Temporary storage. */
131  uint8_t txBuf[LL_DATA_HDR_MAX_LEN]; /*!< Temporary storage for conn tx buf. */
132  uint8_t chanIdx; /*!< Temporary storage for adv channel index. */
133 
134  /* Output contexts. */
135  union
136  {
137  BbBleSnifferHciCtx_t hci; /*!< HCI Output context. */
138  } outputCtx; /*!< Output context union. */
140 
141 /**************************************************************************************************
142  Globals
143 **************************************************************************************************/
144 
145 extern bbSnifferCtx_t bbSnifferCtx;
146 
147 /**************************************************************************************************
148  Function Declarations
149 **************************************************************************************************/
150 
151 uint8_t BbBleInitSniffer(uint8_t outMethod, bool_t enable);
152 void bbBleSnifferMstScanPktHandler(BbOpDesc_t * pBod, BbBleSnifferPkt_t *pPktData);
153 void bbBleSnifferMstAuxScanPktHandler(BbOpDesc_t * pBod, BbBleSnifferPkt_t *pPktData);
154 void bbBleSnifferSlvAdvPktHandler(BbOpDesc_t * pBod, BbBleSnifferPkt_t * pPktData);
155 void bbBleSnifferSlvAuxAdvPktHandler(BbOpDesc_t * pBod, BbBleSnifferPkt_t * pPktData);
156 void bbBleSnifferMstPerScanPktHandler(BbOpDesc_t * pBod, BbBleSnifferPkt_t *pPktData);
157 void bbBleSnifferConnPktHandler(BbOpDesc_t * pBod, BbBleSnifferPkt_t * pPktData);
158 
159 #ifdef __cplusplus
160 };
161 #endif
162 
163 #endif /* BB_BLE_TESTER_API_H */
BbBleSnifferHciCtx_t hci
BbBleDataSniffPkt_t dataPkt
BLE baseband interface file.
void(* bbSnifferFn_t)(BbBleSnifferPkt_t *pPkt)
Sniffer output call signature.
bbSnifferFn_t snifferOutCb
Sniffer packet metadata.
Sniffer advertisement packet.
#define LL_DATA_HDR_MAX_LEN
Definition: ll_defs.h:283
HCI output context.
Sniffer context.
BbBleSnifferMeta_t meta
Sniffer generic packet.
Platform-independent data types.
#define BB_SNIFFER_MAX_NUM_BUF
Maximum number of buffer.
BbBleSnifferMeta_t meta
BbBleAdvSniffPkt_t advPkt
BLE channelization parameters.
Definition: pal_bb_ble.h:67
Link layer constant definitions.
#define LL_ADV_HDR_LEN
Definition: ll_defs.h:119
Baseband interface file.
BbBleSnifferPkt_t *(* bbSnifferGetPktFn_t)(void)
Sniffer get packet call signature.
Sniffer data packet.
bbSnifferGetPktFn_t snifferGetPktFn
BbBleSnifferMeta_t meta
Baseband operation descriptor (BOD).
Definition: bb_api.h:149
BLE Baseband interface file.
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.