Fix for bug 5422:
[obnox/wireshark/wip.git] / epan / dissectors / packet-mac-lte.h
1 /* packet-mac-lte.h
2  *
3  * Martin Mathieson
4  * $Id$
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23  *
24  * This header file may also be distributed under
25  * the terms of the BSD Licence as follows:
26  * 
27  * Copyright (C) 2009 Martin Mathieson. All rights reserved.
28  * 
29  * Redistribution and use in source and binary forms, with or without
30  * modification, are permitted provided that the following conditions
31  * are met:
32  * 1. Redistributions of source code must retain the above copyright
33  *    notice, this list of conditions and the following disclaimer.
34  * 2. Redistributions in binary form must reproduce the above copyright
35  *    notice, this list of conditions and the following disclaimer in the
36  *    documentation and/or other materials provided with the distribution.
37  * 
38  * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
39  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
41  * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
42  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
43  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
44  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
45  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
46  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
47  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
48  * SUCH DAMAGE
49  */
50
51 /* radioType */
52 #define FDD_RADIO 1
53 #define TDD_RADIO 2
54
55 /* Direction */
56 #define DIRECTION_UPLINK   0
57 #define DIRECTION_DOWNLINK 1
58
59 /* rntiType */
60 #define NO_RNTI  0
61 #define P_RNTI   1
62 #define RA_RNTI  2
63 #define C_RNTI   3
64 #define SI_RNTI  4
65 #define SPS_RNTI 5
66
67
68 typedef enum mac_lte_oob_event {
69     ltemac_send_preamble,
70     ltemac_send_sr,
71     ltemac_sr_failure
72 } mac_lte_oob_event;
73
74 typedef enum mac_lte_dl_retx {
75     dl_retx_no,
76     dl_retx_yes,
77     dl_retx_unknown
78 } mac_lte_dl_retx;
79
80 typedef enum mac_lte_crc_status {
81     crc_fail = 0,
82     crc_success = 1,
83     crc_high_code_rate = 2,
84     crc_pdsch_lost = 3
85 } mac_lte_crc_status;
86
87 /* Context info attached to each LTE MAC frame */
88 typedef struct mac_lte_info
89 {
90     /* Needed for decode */
91     guint8          radioType;
92     guint8          direction;
93     guint8          rntiType;
94
95     /* Extra info to display */
96     guint16         rnti;
97     guint16         ueid;
98     guint16         subframeNumber;
99     gboolean        subframeNumberOfGrantPresent;
100     guint16         subframeNumberOfGrant;
101     gboolean        isPredefinedData;
102     guint16         length;
103     guint8          reTxCount;   /* UL */
104     mac_lte_crc_status   crcStatusValid;
105
106     mac_lte_dl_retx dl_retx;
107
108     /* More Physical layer info (direction-specific) */
109     union {
110         struct mac_lte_ul_phy_info
111         {
112             guint8 present;
113             guint8 modulation_type;
114             guint8 tbs_index;
115             guint8 resource_block_length;
116             guint8 resource_block_start;
117         } ul_info;
118         struct mac_lte_dl_phy_info
119         {
120             guint8 present;
121             guint8 dci_format;
122             guint8 resource_allocation_type;
123             guint8 aggregation_level;
124             guint8 mcs_index;
125             guint8 redundancy_version_index;
126             guint8 resource_block_length;
127             mac_lte_crc_status crc_status;
128             guint8 harq_id;
129             gboolean ndi;
130         } dl_info;
131     } detailed_phy_info;
132     
133     /* Relating to out-of-band events */
134     mac_lte_oob_event  oob_event;
135     guint8             rapid;
136     guint8             rach_attempt_number;
137 } mac_lte_info;
138
139
140 typedef struct mac_lte_tap_info {
141     /* Info from context */
142     guint16  rnti;
143     guint16  ueid;
144     guint8   rntiType;
145     guint8   isPredefinedData;
146     guint8   crcStatusValid;
147     mac_lte_crc_status   crcStatus;
148     guint8   direction;
149
150     guint8   isPHYRetx;
151
152     nstime_t time;
153
154     /* Number of bytes (which part is used depends upon context settings) */
155     guint32  single_number_of_bytes;
156     guint32  bytes_for_lcid[11];
157     guint32  sdus_for_lcid[11];
158     guint8   number_of_rars;
159
160     /* Number of padding bytes includes padding subheaders and trailing padding */
161     guint16  padding_bytes;
162     guint16  raw_length;
163 } mac_lte_tap_info;
164
165
166 /* Accessor function to check if a frame was considered to be ReTx */
167 int is_mac_lte_frame_retx(packet_info *pinfo, guint8 direction);
168
169 /*****************************************************************/
170 /* UDP framing format                                            */
171 /* -----------------------                                       */
172 /* Several people have asked about dissecting MAC by framing     */
173 /* PDUs over IP.  A suggested format over UDP has been created   */
174 /* and implemented by this dissector, using the definitions      */
175 /* below. A link to an example program showing you how to encode */
176 /* these headers and send LTE MAC PDUs on a UDP socket is        */
177 /* provided at http://wiki.wireshark.org/MAC-LTE                 */
178 /*                                                               */
179 /* A heuristic dissecter (enabled by a preference) will          */
180 /* recognise a signature at the beginning of these frames   .    */
181 /* Until someone is using this format, suggestions for changes   */
182 /* are welcome.                                                  */
183 /*****************************************************************/
184
185
186 /* Signature.  Rather than try to define a port for this, or make the
187    port number a preference, frames will start with this string (with no
188    terminating NULL */
189 #define MAC_LTE_START_STRING "mac-lte"
190
191 /* Fixed fields.  This is followed by the following 3 mandatory fields:
192    - radioType (1 byte)
193    - direction (1 byte) 
194    - rntiType (1 byte)
195    (where the allowed values are defined above */
196
197 /* Optional fields. Attaching this info to frames will allow you
198    to show you display/filter/plot/add-custom-columns on these fields, so should
199    be added if available.
200    The format is to have the tag, followed by the value (there is no length field,
201    its implicit from the tag) */
202
203 #define MAC_LTE_RNTI_TAG            0x02
204 /* 2 bytes, network order */
205
206 #define MAC_LTE_UEID_TAG            0x03
207 /* 2 bytes, network order */
208
209 #define MAC_LTE_SUBFRAME_TAG        0x04
210 /* 2 bytes, network order */
211
212 #define MAC_LTE_PREDFINED_DATA_TAG  0x05
213 /* 1 byte */
214
215 #define MAC_LTE_RETX_TAG            0x06
216 /* 1 byte */
217
218 #define MAC_LTE_CRC_STATUS_TAG      0x07
219 /* 1 byte */
220
221
222 /* MAC PDU. Following this tag comes the actual MAC PDU (there is no length, the PDU
223    continues until the end of the frame) */
224 #define MAC_LTE_PAYLOAD_TAG 0x01
225