/src/wireshark/epan/dissectors/packet-cell_broadcast.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* packet-gsm_cell_broadcast.c |
2 | | * Routines for GSM Cell Broadcast Service dissection - A.K.A. 3GPP 23.041 (GSM 03.41) section 9.4 |
3 | | * |
4 | | * Copyright 2011, Mike Morrin <mike.morrin [AT] ipaccess.com> |
5 | | * |
6 | | * Wireshark - Network traffic analyzer |
7 | | * By Gerald Combs <gerald@wireshark.org> |
8 | | * Copyright 1998 Gerald Combs |
9 | | * |
10 | | * SPDX-License-Identifier: GPL-2.0-or-later |
11 | | */ |
12 | | |
13 | | #include "config.h" |
14 | | |
15 | | #include <epan/packet.h> |
16 | | |
17 | | #include <epan/asn1.h> |
18 | | |
19 | | #include <epan/expert.h> |
20 | | #include <epan/reassemble.h> |
21 | | |
22 | | #include "packet-gsm_map.h" |
23 | | |
24 | | #include "packet-cell_broadcast.h" |
25 | | |
26 | | void proto_register_cbs(void); |
27 | | |
28 | | #define GSM_CBS_PAGE_SIZE 88 |
29 | | |
30 | | static const value_string message_id_values[] = { |
31 | | { 0, "Index"}, |
32 | | { 10, "Flashes"}, |
33 | | { 20, "Hospitals"}, |
34 | | { 22, "Doctors"}, |
35 | | { 24, "Pharmacy"}, |
36 | | { 30, "Long Distance Road Reports"}, |
37 | | { 32, "Local Road Reports"}, |
38 | | { 34, "Taxis"}, |
39 | | { 40, "Weather"}, |
40 | | { 50, "Regional Services (local phone prefixes) / District (Base Station Identity)"}, |
41 | | { 52, "Network Information"}, |
42 | | { 54, "Operator Service"}, |
43 | | { 56, "Directory Enquiries (national)"}, |
44 | | { 57, "Directory Enquiries (international)"}, |
45 | | { 58, "Customer Care (national)"}, |
46 | | { 59, "Customer Care (international)"}, |
47 | | { 60, "Local Date/Time Group incl. Time Zone"}, |
48 | | { 100, "Regional Services (local phone prefixes)"}, |
49 | | { 101, "planned for news, events, whether, traffic, TV station and News of the day"}, |
50 | | { 102, "planned for news, events, whether, traffic, TV station and News of the day"}, |
51 | | { 103, "planned for news, events, whether, traffic, TV station and News of the day"}, |
52 | | { 104, "planned for news, events, whether, traffic, TV station and News of the day"}, |
53 | | { 105, "planned for news, events, whether, traffic, TV station and News of the day"}, |
54 | | { 106, "planned for news, events, whether, traffic, TV station and News of the day"}, |
55 | | { 107, "planned for news, events, whether, traffic, TV station and News of the day"}, |
56 | | { 123, "Mobile Auction"}, |
57 | | { 140, "Handelsblatt (latest info from stock exchange)"}, |
58 | | { 666, "PASSO Traffic Alert (brief teaser information for IVR)"}, |
59 | | { 1000, "LCS CBS Message Identifier for E-OTD Assistance Data message"}, |
60 | | { 1001, "LCS CBS Message Identifier for DGPS Correction Data message"}, |
61 | | { 1002, "LCS CBS Message Identifier for GPS Ephemeris and Clock Correction Data message"}, |
62 | | { 1003, "LCS CBS Message Identifier for GPS Almanac and Other Data message"}, |
63 | | { 4352, "ETWS CBS Message Identifier for earthquake warning message"}, |
64 | | { 4353, "ETWS CBS Message Identifier for tsunami warning message"}, |
65 | | { 4354, "ETWS CBS Message Identifier for earthquake and tsunami combined warning message"}, |
66 | | { 4355, "ETWS CBS Message Identifier for test message"}, |
67 | | { 4356, "ETWS CBS Message Identifier for messages related to other emergency types"}, |
68 | | { 4370, "CMAS CBS Message Identifier for CMAS Presidential Level Alerts"}, |
69 | | { 4371, "CMAS CBS Message Identifier for CMAS Extreme Alerts with Severity of Extreme, Urgency of Immediate, and Certainty of Observed"}, |
70 | | { 4372, "CMAS CBS Message Identifier for CMAS Extreme Alerts with Severity of Extreme, Urgency of Immediate, and Certainty of Likely"}, |
71 | | { 4373, "CMAS CBS Message Identifier for CMAS Severe Alerts with Severity of Extreme, Urgency of Expected, and Certainty of Observed"}, |
72 | | { 4374, "CMAS CBS Message Identifier for CMAS Severe Alerts with Severity of Extreme, Urgency of Expected, and Certainty of Likely"}, |
73 | | { 4375, "CMAS CBS Message Identifier for CMAS Severe Alerts with Severity of Severe, Urgency of Immediate, and Certainty of Observed"}, |
74 | | { 4376, "CMAS CBS Message Identifier for CMAS Severe Alerts with Severity of Severe, Urgency of Immediate, and Certainty of Likely"}, |
75 | | { 4377, "CMAS CBS Message Identifier for CMAS Severe Alerts with Severity of Severe, Urgency of Expected, and Certainty of Observed"}, |
76 | | { 4378, "CMAS CBS Message Identifier for CMAS Severe Alerts with Severity of Severe, Urgency of Expected, and Certainty of Likely"}, |
77 | | { 4379, "CMAS CBS Message Identifier for Child Abduction Emergency (or Amber Alert)"}, |
78 | | { 4380, "CMAS CBS Message Identifier for the Required Monthly Test"}, |
79 | | { 4381, "CMAS CBS Message Identifier for CMAS Exercise"}, |
80 | | { 4382, "CMAS CBS Message Identifier for operator defined use"}, |
81 | | { 65535, "Message Identifier Reserved, and should not be used for new services"}, |
82 | | { 0, NULL } |
83 | | }; |
84 | | |
85 | | static const value_string geographic_scope_values[] = { |
86 | | { 0x00, "Cell-wide (immediate display)" }, |
87 | | { 0x01, "PLMN-wide" }, |
88 | | { 0x02, "Location Area-wide (GSM) or Service Area-wide (UMTS)" }, |
89 | | { 0x03, "Cell-wide (normal display)" }, |
90 | | { 0, NULL } |
91 | | }; |
92 | | |
93 | | /* Initialize the protocol and registered fields */ |
94 | | static int proto_cell_broadcast; |
95 | | |
96 | | static int hf_gsm_cbs_serial_number; |
97 | | static int hf_gsm_cbs_geographic_scope; |
98 | | static int hf_gsm_cbs_message_code; |
99 | | static int hf_gsm_cbs_update_number; |
100 | | static int hf_gsm_cbs_message_identifier; |
101 | | static int hf_gsm_cbs_total_pages; |
102 | | static int hf_gsm_cbs_current_page; |
103 | | |
104 | | /* These fields are used when reassembling multi-page gsm cbs messages */ |
105 | | static int hf_gsm_cbs_pages; |
106 | | static int hf_gsm_cbs_page_num; |
107 | | static int hf_gsm_cbs_page_overlap; |
108 | | static int hf_gsm_cbs_page_overlap_conflict; |
109 | | static int hf_gsm_cbs_page_multiple_tails; |
110 | | static int hf_gsm_cbs_page_too_long_fragment; |
111 | | static int hf_gsm_cbs_page_error; |
112 | | static int hf_gsm_cbs_page_count; |
113 | | static int hf_gsm_cbs_message_reassembled_in; |
114 | | static int hf_gsm_cbs_message_reassembled_length; |
115 | | static int hf_gsm_cbs_page_content; |
116 | | static int hf_gsm_cbs_page_content_padding; |
117 | | static int hf_gsm_cbs_message_content; |
118 | | |
119 | | /* Initialize the subtree pointers */ |
120 | | static int ett_cbs_msg; |
121 | | static int ett_cbs_serial_no; |
122 | | static int ett_cbs_coding; |
123 | | static int ett_gsm_cbs_page; |
124 | | static int ett_gsm_cbs_page_content; |
125 | | static int ett_gsm_cbs_pages; |
126 | | |
127 | | static expert_field ei_gsm_cbs_unhandled_encoding; |
128 | | |
129 | | /* reassembly of GSM multi-page messages */ |
130 | | static reassembly_table gsm_cbs_reassembly_table; |
131 | | |
132 | | /* Structure needed for the fragmentation routines in reassemble.c */ |
133 | | static const fragment_items gsm_page_items = { |
134 | | &ett_gsm_cbs_page, |
135 | | &ett_gsm_cbs_pages, |
136 | | &hf_gsm_cbs_pages, |
137 | | &hf_gsm_cbs_page_num, |
138 | | &hf_gsm_cbs_page_overlap, |
139 | | &hf_gsm_cbs_page_overlap_conflict, |
140 | | &hf_gsm_cbs_page_multiple_tails, |
141 | | &hf_gsm_cbs_page_too_long_fragment, |
142 | | &hf_gsm_cbs_page_error, |
143 | | &hf_gsm_cbs_page_count, |
144 | | &hf_gsm_cbs_message_reassembled_in, |
145 | | &hf_gsm_cbs_message_reassembled_length, |
146 | | /* Reassembled data field */ |
147 | | NULL, |
148 | | "pages" |
149 | | }; |
150 | | |
151 | | unsigned dissect_cbs_serial_number(tvbuff_t *tvb, proto_tree *tree, unsigned offset) |
152 | 24 | { |
153 | 24 | uint16_t serial_number = tvb_get_ntohs(tvb, offset) ; |
154 | 24 | proto_item *item; |
155 | 24 | proto_tree *subtree; |
156 | | |
157 | 24 | item = proto_tree_add_item(tree, hf_gsm_cbs_serial_number, tvb, offset, 2, ENC_BIG_ENDIAN); |
158 | 24 | proto_item_append_text(item, ", Message Code: %d, Update Number: %d", (serial_number & 0x3FF) >> 4, serial_number & 0x0F); |
159 | 24 | subtree = proto_item_add_subtree(item, ett_cbs_serial_no); |
160 | 24 | proto_tree_add_item(subtree, hf_gsm_cbs_geographic_scope, tvb, offset, 2, ENC_BIG_ENDIAN); |
161 | 24 | proto_tree_add_item(subtree, hf_gsm_cbs_message_code, tvb, offset, 2, ENC_BIG_ENDIAN); |
162 | 24 | proto_tree_add_item(subtree, hf_gsm_cbs_update_number, tvb, offset, 2, ENC_BIG_ENDIAN); |
163 | 24 | offset += 2; |
164 | 24 | return offset; |
165 | 24 | } |
166 | | |
167 | | unsigned dissect_cbs_message_identifier(tvbuff_t *tvb, proto_tree *tree, unsigned offset) |
168 | 23 | { |
169 | 23 | uint16_t msg_id; |
170 | 23 | const char *msg_id_string = NULL; |
171 | | |
172 | 23 | msg_id = tvb_get_ntohs(tvb, offset); |
173 | 23 | msg_id_string = try_val_to_str(msg_id, message_id_values); |
174 | 23 | if (msg_id_string == NULL) |
175 | 15 | { |
176 | 15 | if (msg_id < 1000) |
177 | 2 | { |
178 | 2 | msg_id_string = "Message ID to be allocated by GSMA"; |
179 | 2 | } |
180 | 13 | else if (msg_id < 4096) |
181 | 0 | { |
182 | 0 | msg_id_string = "Message ID intended for standardization in future versions of 3GPP TS 23.041"; |
183 | 0 | } |
184 | 13 | else if (msg_id < 4224) |
185 | 0 | { |
186 | 0 | msg_id_string = "Message ID reserved for Cell Broadcast Data Download (unsecured) to the SIM "; |
187 | 0 | } |
188 | 13 | else if (msg_id < 4352) |
189 | 0 | { |
190 | 0 | msg_id_string = "Message ID reserved for Cell Broadcast Data Download (secured) to the SIM "; |
191 | 0 | } |
192 | 13 | else if (msg_id < 4360) |
193 | 0 | { |
194 | 0 | msg_id_string = "ETWS CBS Message Identifier for future extension"; |
195 | 0 | } |
196 | 13 | else if (msg_id < 4400) |
197 | 0 | { |
198 | 0 | msg_id_string = "CMAS CBS Message Identifier for future extension"; |
199 | 0 | } |
200 | 13 | else if (msg_id < 6400) |
201 | 0 | { |
202 | 0 | msg_id_string = "CBS Message Identifier for future PWS use"; |
203 | 0 | } |
204 | 13 | else if (msg_id < 40960) |
205 | 12 | { |
206 | 12 | msg_id_string = "Intended for standardization in future versions of 3GPP TS 23.041"; |
207 | 12 | } |
208 | 1 | else if (msg_id < 43500) |
209 | 0 | { |
210 | 0 | msg_id_string = "Message ID in PLMN operator specific range"; |
211 | 0 | } |
212 | 1 | else if (msg_id < 43530) |
213 | 0 | { |
214 | 0 | msg_id_string = "Traffic Information Traffic Master UK"; |
215 | 0 | } |
216 | 1 | else if (msg_id < 43585) |
217 | 0 | { |
218 | 0 | msg_id_string = "Traffic information Mannesmann Telecommerce"; |
219 | 0 | } |
220 | 1 | else if (msg_id < 45056) |
221 | 0 | { |
222 | 0 | msg_id_string = "Message ID in PLMN operator specific range"; |
223 | 0 | } |
224 | 1 | else |
225 | 1 | { |
226 | 1 | msg_id_string = "Message ID intended as PLMN operator specific range in future versions of 3GPP TS 23.041"; |
227 | 1 | } |
228 | 15 | } |
229 | 23 | proto_tree_add_uint_format_value(tree, hf_gsm_cbs_message_identifier, tvb, offset, 2, msg_id, "%s (%d)", msg_id_string, msg_id); |
230 | 23 | offset += 2; |
231 | 23 | return offset; |
232 | 23 | } |
233 | | |
234 | | tvbuff_t * dissect_cbs_data(uint8_t sms_encoding, tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, unsigned offset ) |
235 | 23 | { |
236 | 23 | tvbuff_t * tvb_out = NULL; |
237 | 23 | int length = tvb_reported_length(tvb) - offset; |
238 | 23 | char *text; |
239 | | |
240 | 23 | switch(sms_encoding){ |
241 | 8 | case SMS_ENCODING_7BIT: |
242 | 8 | case SMS_ENCODING_7BIT_LANG: |
243 | 8 | text = tvb_get_ts_23_038_7bits_string_packed(pinfo->pool, tvb, offset<<3, (length*8)/7); |
244 | 8 | tvb_out = tvb_new_child_real_data(tvb, text, (unsigned)strlen(text), (unsigned)strlen(text)); |
245 | 8 | add_new_data_source(pinfo, tvb_out, "unpacked 7 bit data"); |
246 | 8 | break; |
247 | | |
248 | 2 | case SMS_ENCODING_8BIT: |
249 | | /* |
250 | | * XXX - encoding is "user-defined". Have a preference? |
251 | | */ |
252 | 2 | text = tvb_get_string_enc(pinfo->pool, tvb, offset, length, ENC_ASCII|ENC_NA); |
253 | 2 | tvb_out = tvb_new_child_real_data(tvb, text, (unsigned)strlen(text), (unsigned)strlen(text)); |
254 | 2 | add_new_data_source(pinfo, tvb_out, "8 bit data"); |
255 | 2 | break; |
256 | | |
257 | 1 | case SMS_ENCODING_UCS2: |
258 | 9 | case SMS_ENCODING_UCS2_LANG: |
259 | 9 | text = tvb_get_string_enc(pinfo->pool, tvb, offset, length, ENC_UCS_2|ENC_BIG_ENDIAN); |
260 | 9 | tvb_out = tvb_new_child_real_data(tvb, text, (unsigned)strlen(text), (unsigned)strlen(text)); |
261 | 9 | add_new_data_source(pinfo, tvb_out, "UCS-2 data"); |
262 | 9 | break; |
263 | | |
264 | 4 | default: |
265 | 4 | proto_tree_add_expert_format(tree, pinfo, &ei_gsm_cbs_unhandled_encoding, tvb, offset, length, |
266 | 4 | "Unhandled encoding %d of CBS String", sms_encoding); |
267 | 4 | break; |
268 | 23 | } |
269 | 21 | return tvb_out; |
270 | 23 | } |
271 | | |
272 | | static int |
273 | | dissect_gsm_cell_broadcast(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) |
274 | 25 | { |
275 | 25 | uint8_t sms_encoding, total_pages, current_page; |
276 | 25 | uint32_t offset = 0; |
277 | 25 | unsigned len, text_len; |
278 | 25 | uint32_t msg_key; |
279 | 25 | proto_item *cbs_page_item = NULL; |
280 | 25 | proto_tree *cbs_page_tree = NULL; |
281 | 25 | uint16_t serial_number, message_id; |
282 | 25 | tvbuff_t *cbs_page_tvb = NULL; |
283 | 25 | tvbuff_t *cbs_msg_tvb = NULL; |
284 | 25 | fragment_head * frag_data = NULL; |
285 | | |
286 | 25 | len = tvb_reported_length(tvb); |
287 | | |
288 | 25 | col_append_str(pinfo->cinfo, COL_PROTOCOL, " Cell Broadcast"); |
289 | 25 | col_append_str(pinfo->cinfo, COL_INFO, " (CBS Page)"); |
290 | | |
291 | 25 | cbs_page_item = proto_tree_add_protocol_format(proto_tree_get_root(tree), proto_cell_broadcast, tvb, 0, len, "GSM Cell Broadcast"); |
292 | 25 | cbs_page_tree = proto_item_add_subtree(cbs_page_item, ett_gsm_cbs_page); |
293 | | |
294 | 25 | serial_number = tvb_get_ntohs(tvb, offset); |
295 | 25 | offset = dissect_cbs_serial_number(tvb, cbs_page_tree, offset); |
296 | 25 | message_id = tvb_get_ntohs(tvb, offset); |
297 | 25 | offset = dissect_cbs_message_identifier(tvb, cbs_page_tree, offset); |
298 | 25 | sms_encoding = dissect_cbs_data_coding_scheme(tvb, pinfo, cbs_page_tree, offset++); |
299 | 25 | total_pages = tvb_get_uint8(tvb, offset); |
300 | 25 | current_page = (total_pages & 0xF0) >> 4; |
301 | 25 | total_pages &= 0x0F; |
302 | 25 | proto_tree_add_item(cbs_page_tree, hf_gsm_cbs_current_page, tvb, offset, 1, ENC_BIG_ENDIAN); |
303 | 25 | proto_tree_add_item(cbs_page_tree, hf_gsm_cbs_total_pages, tvb, offset++, 1, ENC_BIG_ENDIAN); |
304 | 25 | cbs_page_tvb = dissect_cbs_data(sms_encoding, tvb, cbs_page_tree, pinfo, offset ); |
305 | | |
306 | 25 | if (cbs_page_tvb != NULL) |
307 | 19 | { |
308 | 19 | text_len = tvb_reported_length(cbs_page_tvb); |
309 | 19 | while (text_len && (tvb_get_uint8(cbs_page_tvb, text_len-1) == '\r')) { |
310 | 0 | text_len--; |
311 | 0 | } |
312 | 19 | if (tree != NULL) |
313 | 19 | { |
314 | 19 | proto_tree *cbs_page_subtree = proto_tree_add_subtree(cbs_page_tree, tvb, offset, -1, |
315 | 19 | ett_gsm_cbs_page_content, NULL, "Cell Broadcast Page Contents"); |
316 | 19 | len = tvb_reported_length(cbs_page_tvb); |
317 | 19 | proto_tree_add_item(cbs_page_subtree, hf_gsm_cbs_page_content, cbs_page_tvb, 0, text_len, ENC_UTF_8); |
318 | 19 | len -= text_len; |
319 | 19 | if (len) |
320 | 0 | { |
321 | 0 | proto_tree_add_item(cbs_page_subtree, hf_gsm_cbs_page_content_padding, cbs_page_tvb, text_len, len, ENC_UTF_8); |
322 | 0 | } |
323 | 19 | } |
324 | 19 | if (text_len) |
325 | 19 | { |
326 | 19 | cbs_page_tvb = tvb_new_subset_length(cbs_page_tvb, 0, text_len); |
327 | 19 | if (total_pages == 1) |
328 | 1 | { |
329 | | /* no need for reassembly */ |
330 | 1 | cbs_msg_tvb = cbs_page_tvb; |
331 | 1 | } |
332 | 18 | else |
333 | 18 | { |
334 | | /* now we have a complete page, try to concatenate the full message */ |
335 | | /* we can use the serial number and message ID as keys, as they are the same for all pages of a message */ |
336 | 18 | msg_key = (serial_number << 16) + message_id; |
337 | 18 | frag_data = fragment_add_seq_check(&gsm_cbs_reassembly_table, |
338 | 18 | cbs_page_tvb, 0, pinfo, msg_key, NULL, |
339 | 18 | (current_page -1), text_len, |
340 | 18 | (current_page!=total_pages)); |
341 | 18 | cbs_msg_tvb = process_reassembled_data(cbs_page_tvb, 0, pinfo, "Reassembled Cell Broadcast message", |
342 | 18 | frag_data, &gsm_page_items, NULL, cbs_page_tree); |
343 | 18 | } |
344 | 19 | } |
345 | 19 | } |
346 | 25 | if (cbs_msg_tvb != NULL) |
347 | 1 | { |
348 | 1 | proto_item *cbs_msg_item = NULL; |
349 | 1 | proto_tree *cbs_msg_tree = NULL; |
350 | | |
351 | 1 | len = tvb_reported_length(cbs_msg_tvb); |
352 | 1 | col_append_str(pinfo->cinfo, COL_INFO, " (CBS Message)"); |
353 | | |
354 | 1 | cbs_msg_item = proto_tree_add_protocol_format(proto_tree_get_root(tree), proto_cell_broadcast, cbs_msg_tvb, 0, len, "GSM Cell Broadcast Message"); |
355 | 1 | cbs_msg_tree = proto_item_add_subtree(cbs_msg_item, ett_cbs_msg); |
356 | | |
357 | 1 | proto_tree_add_item(cbs_msg_tree, hf_gsm_cbs_message_content, cbs_msg_tvb, 0, len, ENC_UTF_8); |
358 | 1 | } |
359 | | |
360 | 25 | return tvb_captured_length(tvb); |
361 | 25 | } |
362 | | |
363 | | int dissect_umts_cell_broadcast_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) |
364 | 0 | { |
365 | 0 | uint8_t sms_encoding; |
366 | 0 | uint32_t offset = 0; |
367 | 0 | uint32_t len; |
368 | 0 | proto_item *cbs_item; |
369 | 0 | proto_tree *cbs_tree, *cbs_subtree; |
370 | 0 | unsigned msg_len; |
371 | 0 | uint8_t *msg; |
372 | 0 | tvbuff_t * cbs_msg_tvb = NULL; |
373 | |
|
374 | 0 | len = tvb_reported_length(tvb); |
375 | |
|
376 | 0 | col_append_str(pinfo->cinfo, COL_PROTOCOL, " Cell Broadcast"); |
377 | 0 | col_append_str(pinfo->cinfo, COL_INFO, " (CBS Message)"); |
378 | |
|
379 | 0 | cbs_item = proto_tree_add_protocol_format(proto_tree_get_root(tree), proto_cell_broadcast, tvb, 0, len, "Cell Broadcast"); |
380 | 0 | cbs_tree = proto_item_add_subtree(cbs_item, ett_cbs_msg); |
381 | |
|
382 | 0 | sms_encoding = dissect_cbs_data_coding_scheme(tvb, pinfo, cbs_tree, 0); |
383 | 0 | offset++; |
384 | 0 | cbs_msg_tvb = dissect_cbs_data(sms_encoding, tvb, cbs_tree, pinfo, offset ); |
385 | |
|
386 | 0 | msg_len = tvb_reported_length(cbs_msg_tvb); |
387 | 0 | cbs_subtree = proto_tree_add_subtree_format(cbs_tree, tvb, offset, -1, |
388 | 0 | ett_cbs_msg, NULL, "Cell Broadcast Message Contents (length: %d)", msg_len); |
389 | 0 | msg = tvb_get_string_enc(pinfo->pool, cbs_msg_tvb, 0, msg_len, ENC_UTF_8|ENC_NA); |
390 | 0 | proto_tree_add_string_format(cbs_subtree, hf_gsm_cbs_message_content, cbs_msg_tvb, 0, -1, msg, "%s", msg); |
391 | 0 | return tvb_captured_length(tvb); |
392 | 0 | } |
393 | | |
394 | | /* Register the protocol with Wireshark */ |
395 | | void |
396 | | proto_register_cbs(void) |
397 | 14 | { |
398 | | /* Setup list of header fields */ |
399 | 14 | static hf_register_info hf_cbs[] = |
400 | 14 | { |
401 | 14 | { &hf_gsm_cbs_serial_number, |
402 | 14 | { "GSM CBS Serial Number", "gsm_cbs.serial_number", |
403 | 14 | FT_UINT16, BASE_HEX_DEC, NULL, 0x00, |
404 | 14 | NULL, HFILL } |
405 | 14 | }, |
406 | 14 | { &hf_gsm_cbs_message_code, |
407 | 14 | { "GSM CBS Message Code", "gsm_cbs.message_code", |
408 | 14 | FT_UINT16, BASE_DEC_HEX, NULL, 0x3FF0, |
409 | 14 | NULL, HFILL } |
410 | 14 | }, |
411 | 14 | { &hf_gsm_cbs_geographic_scope, |
412 | 14 | { "GSM CBS Geographic Scope", "gsm_cbs.geographic_scope", |
413 | 14 | FT_UINT16, BASE_DEC, VALS(geographic_scope_values), 0xC000, |
414 | 14 | NULL, HFILL } |
415 | 14 | }, |
416 | 14 | { &hf_gsm_cbs_update_number, |
417 | 14 | { "GSM CBS Update Number", "gsm_cbs.update_number", |
418 | 14 | FT_UINT16, BASE_DEC, NULL, 0x000F, |
419 | 14 | NULL, HFILL } |
420 | 14 | }, |
421 | 14 | { &hf_gsm_cbs_message_identifier, |
422 | 14 | { "GSM CBS Message Identifier", "gsm_cbs.message-identifier", |
423 | 14 | FT_UINT16, BASE_DEC_HEX, NULL, 0x00, |
424 | 14 | NULL, HFILL } |
425 | 14 | }, |
426 | 14 | { &hf_gsm_cbs_total_pages, |
427 | 14 | { "GSM CBS Total Pages", "gsm_cbs.total_pages", |
428 | 14 | FT_UINT8, BASE_DEC, NULL, 0x0F, |
429 | 14 | NULL, HFILL } |
430 | 14 | }, |
431 | 14 | { &hf_gsm_cbs_current_page, |
432 | 14 | { "GSM CBS Current Page", "gsm_cbs.current_page", |
433 | 14 | FT_UINT8, BASE_DEC, NULL, 0xF0, |
434 | 14 | NULL, HFILL } |
435 | 14 | }, |
436 | | /* Fragment fields |
437 | | */ |
438 | 14 | { &hf_gsm_cbs_page_overlap, |
439 | 14 | { "page overlap", |
440 | 14 | "gsm_cbs.page.overlap", |
441 | 14 | FT_BOOLEAN, BASE_NONE, NULL, 0x0, |
442 | 14 | "GSM CBS page overlaps with other fragments", HFILL |
443 | 14 | } |
444 | 14 | }, |
445 | 14 | { &hf_gsm_cbs_page_overlap_conflict, |
446 | 14 | { "Conflicting data in page overlap", |
447 | 14 | "gsm_cbs.page.overlap.conflict", |
448 | 14 | FT_BOOLEAN, BASE_NONE, NULL, 0x0, |
449 | 14 | "Overlapping pages contained conflicting data", HFILL |
450 | 14 | } |
451 | 14 | }, |
452 | 14 | { &hf_gsm_cbs_page_multiple_tails, |
453 | 14 | { "Multiple final pages found", |
454 | 14 | "gsm_cbs.page.multipletails", |
455 | 14 | FT_BOOLEAN, BASE_NONE, NULL, 0x0, |
456 | 14 | "Several copies of the final page were found when reassembling the message", HFILL |
457 | 14 | } |
458 | 14 | }, |
459 | 14 | { &hf_gsm_cbs_page_too_long_fragment, |
460 | 14 | { "Page too long", |
461 | 14 | "gsm_cbs.page.toolongfragment", |
462 | 14 | FT_BOOLEAN, BASE_NONE, NULL, 0x0, |
463 | 14 | "Page contained data past end of packet", HFILL |
464 | 14 | } |
465 | 14 | }, |
466 | 14 | { &hf_gsm_cbs_page_error, |
467 | 14 | { "Reassembly error", |
468 | 14 | "gsm_cbs.fragment.error", |
469 | 14 | FT_FRAMENUM, BASE_NONE, NULL, 0x0, |
470 | 14 | "Reassembly error due to illegal fragments", HFILL |
471 | 14 | } |
472 | 14 | }, |
473 | 14 | { &hf_gsm_cbs_page_count, |
474 | 14 | { "Fragment count", |
475 | 14 | "gsm_cbs.fragment.count", |
476 | 14 | FT_UINT32, BASE_DEC, NULL, 0x0, |
477 | 14 | "Count of Page Fragment", HFILL |
478 | 14 | } |
479 | 14 | }, |
480 | 14 | { &hf_gsm_cbs_message_reassembled_in, |
481 | 14 | { "Reassembled in", |
482 | 14 | "gsm_cbs.reassembled.in", |
483 | 14 | FT_FRAMENUM, BASE_NONE, NULL, 0x0, |
484 | 14 | "CBS pages are reassembled in the given packet", HFILL |
485 | 14 | } |
486 | 14 | }, |
487 | 14 | { &hf_gsm_cbs_message_reassembled_length, |
488 | 14 | { "Reassembled message length", |
489 | 14 | "gsm_cbs.reassembled.length", |
490 | 14 | FT_UINT32, BASE_DEC, NULL, 0x0, |
491 | 14 | "The total length of the reassembled message", HFILL |
492 | 14 | } |
493 | 14 | }, |
494 | 14 | { &hf_gsm_cbs_page_num, |
495 | 14 | { "CBS Page Number", |
496 | 14 | "gsm_cbs.page_number", |
497 | 14 | FT_FRAMENUM, BASE_NONE, NULL, 0x0, |
498 | 14 | NULL, HFILL |
499 | 14 | } |
500 | 14 | }, |
501 | 14 | { &hf_gsm_cbs_pages, |
502 | 14 | { "CBS Pages", |
503 | 14 | "gsm_cbs.pages", |
504 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
505 | 14 | NULL, HFILL |
506 | 14 | } |
507 | 14 | }, |
508 | 14 | { &hf_gsm_cbs_page_content, |
509 | 14 | { "CBS Page Content", |
510 | 14 | "gsm_cbs.page_content", |
511 | 14 | FT_STRING, BASE_NONE, NULL, 0x0, |
512 | 14 | NULL, HFILL |
513 | 14 | } |
514 | 14 | }, |
515 | 14 | { &hf_gsm_cbs_page_content_padding, |
516 | 14 | { "CBS Page Content Padding", |
517 | 14 | "gsm_cbs.page_content_padding", |
518 | 14 | FT_STRING, BASE_NONE, NULL, 0x0, |
519 | 14 | NULL, HFILL |
520 | 14 | } |
521 | 14 | }, |
522 | 14 | { &hf_gsm_cbs_message_content, |
523 | 14 | { "CBS Message Content", |
524 | 14 | "gsm_cbs.message_content", |
525 | 14 | FT_STRING, BASE_NONE, NULL, 0x0, |
526 | 14 | NULL, HFILL |
527 | 14 | } |
528 | 14 | } |
529 | 14 | }; |
530 | | |
531 | | /* Setup protocol subtree array */ |
532 | 14 | static int *ett[] = { |
533 | 14 | &ett_cbs_msg, |
534 | 14 | &ett_cbs_serial_no, |
535 | 14 | &ett_cbs_coding, |
536 | 14 | &ett_gsm_cbs_page, |
537 | 14 | &ett_gsm_cbs_page_content, |
538 | 14 | &ett_gsm_cbs_pages, |
539 | 14 | }; |
540 | | |
541 | 14 | static ei_register_info ei[] = { |
542 | 14 | { &ei_gsm_cbs_unhandled_encoding, { "gsm_cbs.unhandled_encoding", PI_PROTOCOL, PI_WARN, "Unhandled encoding", EXPFILL }}, |
543 | 14 | }; |
544 | 14 | expert_module_t* expert_cell_broadcast; |
545 | | |
546 | | /* Register the protocol name and description */ |
547 | 14 | proto_cell_broadcast = proto_register_protocol("GSM Cell Broadcast Service", "GSM Cell Broadcast Service", "gsm_cbs"); |
548 | | |
549 | 14 | proto_register_field_array(proto_cell_broadcast, hf_cbs, array_length(hf_cbs)); |
550 | | |
551 | 14 | reassembly_table_register(&gsm_cbs_reassembly_table, |
552 | 14 | &addresses_reassembly_table_functions); |
553 | | |
554 | | /* subdissector code */ |
555 | 14 | register_dissector("gsm_cbs", dissect_gsm_cell_broadcast, proto_cell_broadcast); |
556 | 14 | register_dissector("umts_cell_broadcast", dissect_umts_cell_broadcast_message, proto_cell_broadcast); |
557 | | |
558 | | /* subtree array */ |
559 | 14 | proto_register_subtree_array(ett, array_length(ett)); |
560 | 14 | expert_cell_broadcast = expert_register_protocol(proto_cell_broadcast); |
561 | 14 | expert_register_field_array(expert_cell_broadcast, ei, array_length(ei)); |
562 | 14 | } |
563 | | |
564 | | /* |
565 | | * Editor modelines - https://www.wireshark.org/tools/modelines.html |
566 | | * |
567 | | * Local Variables: |
568 | | * c-basic-offset: 3 |
569 | | * tab-width: 8 |
570 | | * indent-tabs-mode: nil |
571 | | * End: |
572 | | * |
573 | | * ex: set shiftwidth=3 tabstop=8 expandtab: |
574 | | * :indentSize=3:tabSize=8:noTabs=true: |
575 | | */ |