5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
11 * This header file may also be distributed under
12 * the terms of the BSD Licence as follows:
14 * Copyright (C) 2009 Martin Mathieson. All rights reserved.
16 * SPDX-License-Identifier: BSD-2-Clause
19 #include "ws_symbol_export.h"
21 #include "packet-mac-3gpp-common.h"
29 #define DIRECTION_UPLINK 0
30 #define DIRECTION_DOWNLINK 1
45 typedef enum mac_lte_oob_event
{
51 typedef enum mac_lte_dl_retx
{
57 /* N.B. These error codes are too specific to one old implementation, */
58 /* all just shown as failures */
59 typedef enum mac_lte_crc_status
{
62 crc_high_code_rate
= 2,
64 crc_duplicate_nonzero_rv
= 4,
68 /* N.B. for SCellIndex-r13 extends to 31 */
69 typedef enum mac_lte_carrier_id
{
71 carrier_id_secondary_1
,
72 carrier_id_secondary_2
,
73 carrier_id_secondary_3
,
74 carrier_id_secondary_4
,
75 carrier_id_secondary_5
,
76 carrier_id_secondary_6
,
77 carrier_id_secondary_7
80 typedef enum mac_lte_ce_mode
{
86 typedef enum mac_lte_nb_mode
{
91 /* Context info attached to each LTE MAC frame */
92 typedef struct mac_lte_info
94 /* Needed for decode */
99 /* Extra info to display */
104 uint16_t sysframeNumber
;
105 uint16_t subframeNumber
;
106 bool sfnSfInfoPresent
;
108 /* Optional field. More interesting for TDD (FDD is always -4 subframeNumber) */
109 bool subframeNumberOfGrantPresent
;
110 uint16_t subframeNumberOfGrant
;
112 /* Flag set only if doing PHY-level data test - i.e. there may not be a
113 well-formed MAC PDU so just show as raw data */
114 bool isPredefinedData
;
116 /* Length of DL PDU or UL grant size in bytes */
119 /* 0=newTx, 1=first-retx, etc */
121 uint8_t isPHICHNACK
; /* false=PDCCH retx grant, true=PHICH NACK */
123 /* UL only. Indicates if the R10 extendedBSR-Sizes parameter is set */
124 bool isExtendedBSRSizes
;
126 /* UL only. Indicates if the R10 simultaneousPUCCH-PUSCH parameter is set for PCell */
127 bool isSimultPUCCHPUSCHPCell
;
129 /* UL only. Indicates if the R10 extendedBSR-Sizes parameter is set for PSCell */
130 bool isSimultPUCCHPUSCHPSCell
;
132 /* Status of CRC check. For UE it is DL only. For eNodeB it is UL
133 only. For an analyzer, it is present for both DL and UL. */
135 mac_lte_crc_status crcStatus
;
138 mac_lte_carrier_id carrierId
;
140 /* DL only. Is this known to be a retransmission? */
141 mac_lte_dl_retx dl_retx
;
143 /* DL only. CE mode to be used for RAR decoding */
144 mac_lte_ce_mode ceMode
;
146 /* DL and UL. NB-IoT mode of the UE */
147 mac_lte_nb_mode nbMode
;
149 /* UL only, for now used for CE mode A RAR decoding */
152 /* More Physical layer info (see direction above for which side of union to use) */
154 struct mac_lte_ul_phy_info
156 uint8_t present
; /* Remaining UL fields are present and should be displayed */
157 uint8_t modulation_type
;
159 uint8_t resource_block_length
;
160 uint8_t resource_block_start
;
164 struct mac_lte_dl_phy_info
166 uint8_t present
; /* Remaining DL fields are present and should be displayed */
168 uint8_t resource_allocation_type
;
169 uint8_t aggregation_level
;
171 uint8_t redundancy_version_index
;
172 uint8_t resource_block_length
;
175 uint8_t transport_block
; /* 0..1 */
179 /* Relating to out-of-band events */
180 /* N.B. dissector will only look to these fields if length is 0... */
181 mac_lte_oob_event oob_event
;
183 uint8_t rach_attempt_number
;
185 uint16_t number_of_srs
;
186 uint16_t oob_ueid
[MAX_SRs
];
187 uint16_t oob_rnti
[MAX_SRs
];
191 /* Accessor function to check if a frame was considered to be ReTx */
192 bool is_mac_lte_frame_retx(packet_info
*pinfo
, uint8_t direction
);
194 /**********************************************************************/
195 /* UDP framing format */
196 /* ----------------------- */
197 /* Several people have asked about dissecting MAC by framing */
198 /* PDUs over IP. A suggested format over UDP has been created */
199 /* and implemented by this dissector, using the definitions */
200 /* below. A link to an example program showing you how to encode */
201 /* these headers and send LTE MAC PDUs on a UDP socket is */
202 /* provided at https://gitlab.com/wireshark/wireshark/-/wikis/MAC-LTE */
204 /* A heuristic dissector (enabled by a preference) will */
205 /* recognise a signature at the beginning of these frames. */
206 /**********************************************************************/
209 /* Signature. Rather than try to define a port for this, or make the
210 port number a preference, frames will start with this string (with no
212 #define MAC_LTE_START_STRING "mac-lte"
214 /* Fixed fields. This is followed by the following 3 mandatory fields:
218 (where the allowed values are defined above */
220 /* Optional fields. Attaching this info to frames will allow you
221 to show you display/filter/plot/add-custom-columns on these fields, so should
222 be added if available.
223 The format is to have the tag, followed by the value (there is no length field,
224 it's implicit from the tag) */
226 #define MAC_LTE_RNTI_TAG 0x02
227 /* 2 bytes, network order */
229 #define MAC_LTE_UEID_TAG 0x03
230 /* 2 bytes, network order */
232 #define MAC_LTE_FRAME_SUBFRAME_TAG 0x04
233 /* 2 bytes, network order, SFN is stored in 12 MSB and SF in 4 LSB */
235 #define MAC_LTE_PREDEFINED_DATA_TAG 0x05
238 #define MAC_LTE_RETX_TAG 0x06
241 #define MAC_LTE_CRC_STATUS_TAG 0x07
244 #define MAC_LTE_EXT_BSR_SIZES_TAG 0x08
247 #define MAC_LTE_SEND_PREAMBLE_TAG 0x09
248 /* 2 bytes, RAPID value (1 byte) followed by RACH attempt number (1 byte) */
250 #define MAC_LTE_CARRIER_ID_TAG 0x0A
253 #define MAC_LTE_PHY_TAG 0x0B
254 /* variable length, length (1 byte) then depending on direction
255 in UL: modulation type (1 byte), TBS index (1 byte), RB length (1 byte),
256 RB start (1 byte), HARQ id (1 byte), NDI (1 byte)
257 in DL: DCI format (1 byte), resource allocation type (1 byte), aggregation level (1 byte),
258 MCS index (1 byte), redundancy version (1 byte), resource block length (1 byte),
259 HARQ id (1 byte), NDI (1 byte), TB (1 byte), DL reTx (1 byte) */
261 #define MAC_LTE_SIMULT_PUCCH_PUSCH_PCELL_TAG 0x0C
264 #define MAC_LTE_SIMULT_PUCCH_PUSCH_PSCELL_TAG 0x0D
267 #define MAC_LTE_CE_MODE_TAG 0x0E
268 /* 1 byte containing mac_lte_ce_mode enum value */
270 #define MAC_LTE_NB_MODE_TAG 0x0F
271 /* 1 byte containing mac_lte_nb_mode enum value */
273 #define MAC_LTE_N_UL_RB_TAG 0x10
274 /* 1 byte containing the number of UL resource blocks: 6, 15, 25, 50, 75 or 100 */
276 #define MAC_LTE_SR_TAG 0x11
277 /* 2 bytes for the number of items, followed by that number of ueid, rnti (2 bytes each) */
280 /* MAC PDU. Following this tag comes the actual MAC PDU (there is no length, the PDU
281 continues until the end of the frame) */
282 #define MAC_LTE_PAYLOAD_TAG 0x01
285 /* Type to store parameters for configuring LCID->RLC channel settings for DRB */
286 /* Some are optional, and may not be seen (e.g. on reestablishment) */
287 typedef struct drb_mapping_t
289 uint16_t ueid
; /* Mandatory */
290 uint8_t drbid
; /* Mandatory */
292 uint8_t lcid
; /* Part of LogicalChannelConfig - optional */
293 bool rlcMode_present
;
294 uint8_t rlcMode
; /* Part of RLC config - optional */
295 bool rlc_ul_ext_li_field
; /* Part of RLC config - optional */
296 bool rlc_dl_ext_li_field
; /* Part of RLC config - optional */
297 bool rlc_ul_ext_am_sn
; /* Part of RLC config - optional */
298 bool rlc_dl_ext_am_sn
; /* Part of RLC config - optional */
299 bool um_sn_length_present
;
300 uint8_t um_sn_length
; /* Part of RLC config - optional */
301 bool ul_priority_present
;
302 uint8_t ul_priority
; /* Part of LogicalChannelConfig - optional */
303 bool pdcp_sn_size_present
;
304 uint8_t pdcp_sn_size
; /* Part of pdcp-Config - optional */
308 /* Set details of an LCID -> drb channel mapping. To be called from
309 configuration protocol (e.g. RRC) */
310 void set_mac_lte_channel_mapping(drb_mapping_t
*drb_mapping
);
312 /* Return mode of bearer, or 0 if not found/known */
313 uint8_t get_mac_lte_channel_mode(uint16_t ueid
, uint8_t drbid
);
315 /* Dedicated DRX config. Used to verify that a sensible config is given.
316 Also, beginning to configure MAC with this config and (optionally) show
317 DRX config and state (cycles/timers) attached to each UL/DL PDU! */
318 typedef struct drx_config_t
{
321 uint32_t previousFrameNum
;
323 uint32_t onDurationTimer
;
324 uint32_t inactivityTimer
;
325 uint32_t retransmissionTimer
;
327 uint32_t cycleOffset
;
328 /* Optional Short cycle */
329 bool shortCycleConfigured
;
331 uint32_t shortCycleTimer
;
334 /* Functions to set/release up dedicated DRX config */
335 void set_mac_lte_drx_config(uint16_t ueid
, drx_config_t
*drx_config
, packet_info
*pinfo
);
336 void set_mac_lte_drx_config_release(uint16_t ueid
, packet_info
*pinfo
);
338 /* RRC can tell this dissector which RAPIDs are Group A, Group A&B */
339 void set_mac_lte_rapid_ranges(unsigned groupA
, unsigned all_RA
);
341 /* RRC can indicate whether extended BSR sizes are used */
342 void set_mac_lte_extended_bsr_sizes(uint16_t ueid
, bool use_ext_bsr_sizes
, packet_info
*pinfo
);
344 /* RRC can indicate whether simultaneous PUCCH/PUSCH is used */
346 SIMULT_PUCCH_PUSCH_PCELL
= 0,
347 SIMULT_PUCCH_PUSCH_PSCELL
348 } simult_pucch_pusch_cell_type
;
349 void set_mac_lte_simult_pucch_pusch(uint16_t ueid
, simult_pucch_pusch_cell_type cell_type
, bool use_simult_pucch_pusch
, packet_info
*pinfo
);
351 /* Functions to be called from outside this module (e.g. in a plugin, where mac_lte_info
352 isn't available) to get/set per-packet data */
354 mac_lte_info
*get_mac_lte_proto_data(packet_info
*pinfo
);
356 void set_mac_lte_proto_data(packet_info
*pinfo
, mac_lte_info
*p_mac_lte_info
);
358 /* Function to attempt to populate p_mac_lte_info using framing definition above */
359 bool dissect_mac_lte_context_fields(struct mac_lte_info
*p_mac_lte_info
, tvbuff_t
*tvb
,
360 packet_info
*pinfo
, proto_tree
*tree
, int *p_offset
);
363 * Editor modelines - https://www.wireshark.org/tools/modelines.html
368 * indent-tabs-mode: nil
371 * vi: set shiftwidth=4 tabstop=8 expandtab:
372 * :indentSize=4:tabSize=8:noTabs=true: