2 * Routines for output and filtering of E164 numbers common
4 * Copyright 2004, Anders Broman <anders.broman@ericsson.com>
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
12 * Ref ITU-T E.164 05/97
13 * Annex to ITU Operational Bulletin No. 991 - 1.XI.2011
14 * Amendment No. 10 ITU Operational Bulletin No. 1057 - 1.VIII.2014
15 * Find the bulletins here:
16 * http://www.itu.int/pub/T-SP-OB
21 #include <epan/packet.h>
22 #include "packet-e164.h"
25 void proto_register_e164(void);
27 const value_string E164_country_code_value
[] = {
30 { 7, "Russian Federation, Kazakstan (Republic of)"},
31 { 20, "Egypt (Arab Republic of)"},
32 { 27, "South Africa (Republic of)"},
34 { 31, "Netherlands (Kingdom of the)"},
38 { 36, "Hungary (Republic of)"},
41 { 41, "Switzerland (Confederation of)"},
43 { 44, "United Kingdom of Great Britain and Northern Ireland"},
47 { 48, "Poland (Republic of)"},
48 { 49, "Germany (Federal Republic of)"},
52 { 54, "Argentine Republic"},
53 { 55, "Brazil (Federative Republic of)"},
55 { 57, "Colombia (Republic of)"},
56 { 58, "Venezuela(Bolivarian Republic of)"},
59 { 62, "Indonesia (Republic of)"},
60 { 63, "Philippines (Republic of the)"},
62 { 65, "Singapore (Republic of)"},
65 { 82, "Korea (Republic of)"},
66 { 84, "Viet Nam (Socialist Republic of)"},
67 { 86, "China (People's Republic of)"},
69 { 91, "India (Republic of)"},
70 { 92, "Pakistan (Islamic Republic of)"},
72 { 94, "Sri Lanka (Democratic Socialist Republic of)"},
73 { 95, "Myanmar (the Republic of the Union of)"},
74 { 98, "Iran (Islamic Republic of)"},
76 { 211, "South Sudan (Republic of)"},
77 { 212, "Morocco (Kingdom of)"},
78 { 213, "Algeria (People's Democratic Republic of)"},
83 { 218, "Libya (Socialist People's Libyan Arab Jamahiriya)"},
85 { 220, "Gambia (Republic of)"},
86 { 221, "Senegal (Republic of)"},
87 { 222, "Mauritania (Islamic Republic of)"},
88 { 223, "Mali (Republic of)"},
89 { 224, "Guinea (Republic of)"},
90 { 225, "Cote d'Ivoire (Republic of)"},
91 { 226, "Burkina Faso"},
92 { 227, "Niger (Republic of the)"},
93 { 228, "Togolese Republic"},
94 { 229, "Benin (Republic of)"},
95 { 230, "Mauritius (Republic of)"},
96 { 231, "Liberia (Republic of)"},
97 { 232, "Sierra Leone"},
99 { 234, "Nigeria (Federal Republic of)"},
100 { 235, "Chad (Republic of)"},
101 { 236, "Central African Republic"},
102 { 237, "Cameroon (Republic of)"},
103 { 238, "Cape Verde (Republic of)"},
104 { 239, "Sao Tome and Principe (Democratic Republic of)"},
105 { 240, "Equatorial Guinea (Republic of)"},
106 { 241, "Gabonese Republic"},
107 { 242, "Congo (Republic of the)"},
108 { 243, "Democratic Republic of Congo"},
109 { 244, "Angola (Republic of)"},
110 { 245, "Guinea-Bissau (Republic of)"},
111 { 246, "Diego Garcia"},
112 { 247, "Saint Helena, Ascension and Tristan da Cunha"},
113 { 248, "Seychelles (Republic of)"},
114 { 249, "Sudan (Republic of the)"},
115 { 250, "Rwanda (Republic of)"},
116 { 251, "Ethiopia (Federal Democratic Republic of)"},
117 { 252, "Somali Democratic Republic"},
118 { 253, "Djibouti (Republic of)"},
119 { 254, "Kenya (Republic of)"},
120 { 255, "Tanzania (United Republic of)"},
121 { 256, "Uganda (Republic of)"},
122 { 257, "Burundi (Republic of)"},
123 { 258, "Mozambique (Republic of)"},
124 { 259, "Spare code"},
125 { 260, "Zambia (Republic of)"},
126 { 261, "Madagascar (Republic of)"},
127 { 262, "French Departments and Territories in the Indian Ocean"},
128 { 263, "Zimbabwe (Republic of)"},
129 { 264, "Namibia (Republic of)"},
131 { 266, "Lesotho (Kingdom of)"},
132 { 267, "Botswana (Republic of)"},
133 { 268, "Swaziland (Kingdom of)"},
134 { 269, "Comoros (Union of the)"},
135 { 280, "Spare code"},
136 { 281, "Spare code"},
137 { 282, "Spare code"},
138 { 283, "Spare code"},
139 { 284, "Spare code"},
140 { 285, "Spare code"},
141 { 286, "Spare code"},
142 { 287, "Spare code"},
143 { 288, "Spare code"},
144 { 289, "Spare code"},
145 { 290, "Saint Helena, Ascension and Tristan da Cunha"},
147 { 292, "Spare code"},
148 { 293, "Spare code"},
149 { 294, "Spare code"},
150 { 295, "Spare code"},
151 { 296, "Spare code"},
153 { 298, "Faroe Islands"},
154 { 299, "Greenland (Denmark)"},
157 { 352, "Luxembourg"},
160 { 355, "Albania (Republic of)"},
162 { 357, "Cyprus (Republic of)"},
164 { 359, "Bulgaria (Republic of)"},
165 { 370, "Lithuania (Republic of)"},
166 { 371, "Latvia (Republic of)"},
167 { 372, "Estonia (Republic of)"},
168 { 373, "Moldova (Republic of)"},
169 { 374, "Armenia (Republic of)"},
170 { 375, "Belarus (Republic of)"},
171 { 376, "Andorra (Principality of)"},
172 { 377, "Monaco (Principality of)"},
173 { 378, "San Marino (Republic of)"},
174 { 379, "Vatican City State"},
176 { 381, "Serbia (Republic of)"},
177 { 382, "Montenegro (Republic of)"},
178 { 383, "Spare code"},
179 { 384, "Spare code"},
180 { 385, "Croatia (Republic of)"},
181 { 386, "Slovenia (Republic of)"},
182 { 387, "Bosnia and Herzegovina"},
183 { 388, "Group of countries, shared code"},
184 { 389, "The Former Yugoslav Republic of Macedonia"},
185 { 420, "Czech Republic"},
186 { 421, "Slovak Republic"},
187 { 422, "Spare code"},
188 { 423, "Liechtenstein (Principality of)"},
189 { 424, "Spare code"},
190 { 425, "Spare code"},
191 { 426, "Spare code"},
192 { 427, "Spare code"},
193 { 428, "Spare code"},
194 { 429, "Spare code"},
195 { 500, "Falkland Islands (Malvinas)"},
197 { 502, "Guatemala (Republic of)"},
198 { 503, "El Salvador (Republic of)"},
199 { 504, "Honduras (Republic of)"},
201 { 506, "Costa Rica"},
202 { 507, "Panama (Republic of)"},
203 { 508, "Saint Pierre and Miquelon (Collectivite territoriale de la Republique francaise)"},
204 { 509, "Haiti (Republic of)"},
205 { 590, "Guadeloupe (French Department of)"},
206 { 591, "Bolivia (Plurinational State of)"},
209 { 594, "French Guiana (French Department of)"},
210 { 595, "Paraguay (Republic of)"},
211 { 596, "Martinique (French Department of)"},
212 { 597, "Suriname (Republic of)"},
213 { 598, "Uruguay (Eastern Republic of)"},
214 { 599, "Bonaire, Saint Eustatius and Saba, Curacao"},
215 { 670, "Democratic Republic of Timor-Leste"},
216 { 671, "Spare code"},
217 { 672, "Australian External Territories"},
218 { 673, "Brunei Darussalam"},
219 { 674, "Nauru (Republic of)"},
220 { 675, "Papua New Guinea"},
221 { 676, "Tonga (Kingdom of)"},
222 { 677, "Solomon Islands"},
223 { 678, "Vanuatu (Republic of)"},
224 { 679, "Fiji (Republic of)"},
225 { 680, "Palau (Republic of)"},
226 { 681, "Wallis and Futuna (Territoire francais d'outre-mer)"},
227 { 682, "Cook Islands"},
229 { 684, "Spare code"},
230 { 685, "Samoa (Independent State of)"},
231 { 686, "Kiribati (Republic of)"},
232 { 687, "New Caledonia (Territoire francais d'outre-mer)"},
234 { 689, "French Polynesia (Territoire francais d'outre-mer)"},
236 { 691, "Micronesia (Federated States of)"},
237 { 692, "Marshall Islands (Republic of the)"},
238 { 693, "Spare code"},
239 { 694, "Spare code"},
240 { 695, "Spare code"},
241 { 696, "Spare code"},
242 { 697, "Spare code"},
243 { 698, "Spare code"},
244 { 699, "Spare code"},
245 { 800, "International Freephone Service"},
246 { 801, "Spare code"},
247 { 802, "Spare code"},
248 { 803, "Spare code"},
249 { 804, "Spare code"},
250 { 805, "Spare code"},
251 { 806, "Spare code"},
252 { 807, "Spare code"},
253 { 808, "International Shared Cost Service (ISCS)"},
254 { 809, "Spare code"},
255 { 830, "Spare code"},
256 { 831, "Spare code"},
257 { 832, "Spare code"},
258 { 833, "Spare code"},
259 { 834, "Spare code"},
260 { 835, "Spare code"},
261 { 836, "Spare code"},
262 { 837, "Spare code"},
263 { 838, "Spare code"},
264 { 839, "Spare code"},
265 { 850, "Democratic People's Republic of Korea"},
266 { 851, "Spare code"},
267 { 852, "Hong Kong, China"},
268 { 853, "Macau, China"},
269 { 854, "Spare code"},
270 { 855, "Cambodia (Kingdom of)"},
271 { 856, "Lao People's Democratic Republic"},
272 { 857, "Spare code"},
273 { 858, "Spare code"},
274 { 859, "Spare code"},
275 { 870, "Inmarsat SNAC"},
276 { 871, "Spare code"},
277 { 872, "Spare code"},
278 { 873, "Spare code"},
279 { 874, "Spare code"},
280 { 875, "Reserved - Maritime Mobile Service Applications"},
281 { 876, "Reserved - Maritime Mobile Service Applications"},
282 { 877, "Reserved - Maritime Mobile Service Applications"},
283 { 878, "Universal Personal Telecommunication Service (UPT)"},
284 { 879, "Reserved for national non-commercial purposes"},
285 { 880, "Bangladesh"},
286 { 881, "Global Mobile Satellite System (GMSS), shared code"},
287 { 882, "International Networks, shared code"},
288 { 883, "International Networks, shared code"},
289 { 884, "Spare code"},
290 { 885, "Spare code"},
291 { 886, "Taiwan, China"},
292 { 887, "Spare code"},
293 { 888, "Telecommunications for Disaster Relief (TDR)"},
294 { 889, "Spare code"},
295 { 890, "Spare code"},
296 { 891, "Spare code"},
297 { 892, "Spare code"},
298 { 893, "Spare code"},
299 { 894, "Spare code"},
300 { 895, "Spare code"},
301 { 896, "Spare code"},
302 { 897, "Spare code"},
303 { 898, "Spare code"},
304 { 899, "Spare code"},
305 { 960, "Maldives (Republic of)"},
307 { 962, "Jordan (Hashemite Kingdom of)"},
308 { 963, "Syrian Arab Republic"},
309 { 964, "Iraq (Republic of)"},
310 { 965, "Kuwait (State of)"},
311 { 966, "Saudi Arabia (Kingdom of)"},
312 { 967, "Yemen (Republic of)"},
313 { 968, "Oman (Sultanate of)"},
314 { 969, "Reserved - reservation currently under investigation"},
316 { 971, "United Arab Emirates"},
317 { 972, "Israel (State of)"},
318 { 973, "Bahrain (Kingdom of)"},
319 { 974, "Qatar (State of)"},
320 { 975, "Bhutan (Kingdom of)"},
322 { 977, "Nepal (Federal Democratic Republic of)"},
323 { 978, "Spare code"},
324 { 979, "International Premium Rate Service (IPRS)"},
325 { 990, "Spare code"},
326 { 991, "Trial of a proposed new international telecommunication public correspondence service, shared code"},
327 { 992, "Tajikstan (Republic of)"},
328 { 993, "Turkmenistan"},
329 { 994, "Azerbaijan"},
331 { 996, "Kyrgyz Republic"},
332 { 997, "Spare code"},
333 { 998, "Uzbekistan (Republic of)"},
334 { 999, "Reserved for future global service"},
337 static value_string_ext E164_country_code_value_ext
= VALUE_STRING_EXT_INIT(E164_country_code_value
);
339 /* Country code from ITU-T E.164 to ISO 3166 two letters country name */
340 const value_string E164_ISO3166_country_code_short_value
[] = {
341 { 1, "us" }, { 7, "ru" }, { 20, "eg" }, { 27, "za" },
342 { 30, "gr" }, { 31, "nl" }, { 32, "be" }, { 33, "fr" },
343 { 34, "es" }, { 36, "hu" }, { 39, "it" }, { 40, "ro" },
344 { 41, "ch" }, { 43, "at" }, { 44, "gb" }, { 45, "dk" },
345 { 46, "se" }, { 47, "no" }, { 48, "pl" }, { 49, "de" },
346 { 51, "pe" }, { 52, "mx" }, { 53, "cu" }, { 54, "ar" },
347 { 55, "br" }, { 56, "cl" }, { 57, "co" }, { 58, "ve" },
348 { 60, "my" }, { 61, "au" }, { 62, "id" }, { 63, "ph" },
349 { 64, "nz" }, { 65, "sg" }, { 66, "th" }, { 81, "jp" },
350 { 82, "kr" }, { 84, "vn" }, { 86, "cn" }, { 90, "tr" },
351 { 91, "in" }, { 92, "pk" }, { 93, "af" }, { 94, "lk" },
352 { 98, "ir" }, { 95, "mm" },
354 { 212, "ma" }, { 213, "dz" }, { 216, "tn" }, { 218, "ly" },
355 { 220, "gm" }, { 221, "sn" }, { 222, "mr" }, { 223, "ml" },
356 { 224, "gn" }, { 225, "ci" }, { 226, "bf" }, { 227, "ne" },
357 { 228, "tg" }, { 229, "bj" }, { 230, "mu" }, { 231, "lr" },
358 { 232, "sl" }, { 233, "gh" }, { 234, "ng" }, { 235, "td" },
359 { 236, "cf" }, { 237, "cm" }, { 238, "cv" }, { 239, "st" },
360 { 240, "gq" }, { 241, "ga" }, { 242, "cg" }, { 243, "cd" },
361 { 244, "ao" }, { 245, "gw" }, { 248, "sc" }, { 249, "sd" },
362 { 250, "rw" }, { 251, "et" }, { 252, "so" }, { 253, "dj" },
363 { 254, "ke" }, { 255, "tz" }, { 256, "ug" }, { 257, "bi" },
364 { 258, "mz" }, { 260, "zm" }, { 261, "mg" }, { 262, "fr" },
365 { 263, "zw" }, { 264, "na" }, { 265, "mw" }, { 266, "ls" },
366 { 267, "bw" }, { 268, "sz" }, { 269, "km" }, { 290, "sh" },
367 { 291, "er" }, { 297, "aw" }, { 298, "fo" }, { 299, "gl" },
369 { 350, "gi" }, { 351, "pt" }, { 352, "lu" }, { 353, "ie" },
370 { 354, "is" }, { 355, "al" }, { 356, "mt" }, { 357, "cy" },
371 { 358, "fi" }, { 359, "bg" }, { 370, "lt" }, { 371, "lv" },
372 { 372, "ee" }, { 373, "md" }, { 374, "am" }, { 375, "by" },
373 { 376, "ad" }, { 377, "mc" }, { 378, "sm" }, { 379, "va" },
374 { 380, "ua" }, { 385, "hr" }, { 386, "si" }, { 387, "ba" },
376 { 420, "cz" }, { 421, "sk" }, { 423, "li" },
378 { 500, "fk" }, { 501, "bz" }, { 502, "gt" }, { 503, "sv" },
379 { 504, "hn" }, { 505, "ni" }, { 506, "cr" }, { 507, "pa" },
380 { 508, "pm" }, { 509, "ht" }, { 590, "gp" }, { 591, "bo" },
381 { 592, "gy" }, { 593, "ec" }, { 594, "gf" }, { 595, "py" },
382 { 596, "mq" }, { 597, "sr" }, { 598, "uy" },
384 { 673, "bn" }, { 682, "ck" }, { 670, "tl" }, { 674, "nr" },
385 { 675, "pg" }, { 676, "to" }, { 677, "sb" }, { 678, "vu" },
386 { 679, "fj" }, { 680, "pw" }, { 681, "wf" }, { 683, "nu" },
387 { 685, "ws" }, { 686, "ki" }, { 687, "nc" }, { 688, "tv" },
388 { 689, "pf" }, { 690, "tk" }, { 691, "fm" }, { 692, "mh" },
390 { 850, "kp" }, { 852, "hk" }, { 853, "mo" }, { 855, "kh" },
391 { 856, "la" }, { 880, "bd" },
393 { 960, "mv" }, { 961, "lb" }, { 962, "jo" }, { 963, "sy" },
394 { 964, "iq" }, { 965, "kw" }, { 966, "sa" }, { 967, "ye" },
395 { 968, "om" }, { 971, "ae" }, { 972, "il" }, { 973, "bh" },
396 { 974, "qa" }, { 975, "bt" }, { 976, "mn" }, { 977, "np" },
397 { 992, "tj" }, { 993, "tm" }, { 994, "az" }, { 995, "ge" },
398 { 996, "kg" }, { 998, "uz" },
402 value_string_ext E164_ISO3166_country_code_short_value_ext
= VALUE_STRING_EXT_INIT(E164_ISO3166_country_code_short_value
);
404 static const value_string E164_GMSS_vals
[] = {
405 { 6, "Iridium Satellite LLC"},
406 { 7, "Iridium Satellite LLC"},
412 static const value_string E164_International_Networks_882_vals
[] = {
413 { 10, "Global Office Application"},
414 { 12, "HyperStream International (HSI) Data Network"},
415 { 13, "EMS Regional Mobile Satellite System"},
416 { 15, "Global international ATM Network"},
417 { 16, "Thuraya RMSS Network"},
418 { 20, "Garuda Mobile Telecommunication Satellite System"},
419 { 22, "Cable & Wireless Global Network"},
420 { 23, "Sita-Equant Network"},
421 { 24, "TeliaSonera Sverige AB"},
422 { 28, "Deutsche Telekom's Next Generation Network"},
423 { 31, "Global International ATM Network"},
424 { 32, "MCP network"},
425 { 33, "Oration Technologies Network"},
426 { 34, "BebbiCell AG"},
427 { 35, "Jasper System"},
428 { 36, "Jersey Telecom"},
429 { 37, "Cingular Wireless netwok"},
430 { 39, "Vodafone Malta"},
431 { 40, "Oy Communications"},
432 { 41, "Intermatica"},
433 { 42, "Seanet Maritime Communication"},
435 { 45, "Telecom Italia"},
436 { 46, "Tyntec GmbH"},
438 { 97, "Smart Communications Inc"},
439 { 98, "Onair GSM services"},
440 { 99, "Telenor GSM network - services in aircraft"},
443 static value_string_ext E164_International_Networks_882_vals_ext
= VALUE_STRING_EXT_INIT(E164_International_Networks_882_vals
);
445 static const value_string E164_International_Networks_883_vals
[] = {
446 { 100, "MediaLincc Ltd"},
447 { 110, "Aicent Inc"},
448 { 120, "Telenor Connexion AB"},
449 { 130, "France Telecom Orange"},
450 { 140, "Multiregional TransitTelecom (MTT)"},
451 { 150, "BodyTrace Netherlands B.V"},
452 { 5100, "Voxbone SA"},
453 { 5110, "Bandwidth.com Inc"},
454 { 5120, "MTX Connect Ltd"},
455 { 5130, "SIMPE Ltd"},
456 { 5140, "Ellipsat Inc"},
457 { 5150, "Wins Limited"},
461 static int proto_e164
;
462 static int hf_E164_calling_party_number
;
463 static int hf_E164_called_party_number
;
464 static int hf_E164_msisdn
;
465 static int hf_E164_isdn
;
466 static int hf_E164_identification_code
;
467 static int hf_E164_country_code
;
469 static int ett_e164_msisdn
;
471 static expert_field ei_E164_country_code_non_decimal
;
472 static expert_field ei_E164_identification_code_non_decimal
;
475 dissect_e164_number(tvbuff_t
*tvb
, proto_tree
*tree
, int offset
, int length
, e164_info_t e164_info
)
479 switch (e164_info
.e164_number_type
) {
480 case CALLING_PARTY_NUMBER
:
481 proto_tree_add_string(tree
, hf_E164_calling_party_number
, tvb
, offset
,
482 length
, e164_info
.E164_number_str
);
485 case CALLED_PARTY_NUMBER
:
486 proto_tree_add_string(tree
, hf_E164_called_party_number
, tvb
, offset
,
487 length
, e164_info
.E164_number_str
);
494 if (e164_info
.nature_of_address
== E164_NA_INTERNATIONAL_NUMBER
) {
495 pi
= proto_tree_add_string(tree
, hf_E164_msisdn
, tvb
, offset
, length
, e164_info
.E164_number_str
);
496 proto_item_set_hidden(pi
);
501 * Convert 16bit integer in BCD encoding to decimal.
502 * @param bcd BCD value to convert.
503 * @param[out] dec Pointer to decimal result.
504 * @return true if ok, false if bcd contains a nibble > 9.
507 convert_bcd_to_dec(uint16_t bcd
, uint16_t * dec
)
513 if ((bcd
& 0x0f) > 9)
515 result
+= (bcd
& 0x0f) * mult
;
524 dissect_e164_cc(tvbuff_t
*tvb
, proto_tree
*tree
, int offset
, e164_encoding_t encoding
)
527 uint8_t address_digit_pair
;
528 uint16_t id_code
= 0;
533 proto_item
*item
= NULL
;
536 address_digit_pair
= tvb_get_uint8(tvb
, cc_offset
);
538 /* Get the first 3 digits of the MSISDN */
540 case E164_ENC_BINARY
:
541 /* Dissect country code after removing non significant zeros */
542 while (address_digit_pair
== 0) {
543 cc_offset
= cc_offset
+ 1;
544 address_digit_pair
= tvb_get_uint8(tvb
, cc_offset
);
546 cc
= tvb_get_ntohs(tvb
, cc_offset
);
547 if ((address_digit_pair
& 0xf0) != 0) {
552 cc
= address_digit_pair
&0x0f;
554 cc
= cc
| (address_digit_pair
&0xf0)>>4;
556 if (tvb_bytes_exist(tvb
, cc_offset
+1, 1)) {
557 address_digit_pair
= tvb_get_uint8(tvb
, cc_offset
+1);
558 cc
= cc
| (address_digit_pair
&0x0f);
562 /* XXX - do we need to worry about leading 0s? */
563 cc
= (tvb_get_uint8(tvb
, cc_offset
) - '0') << 8;
564 cc
|= (tvb_get_uint8(tvb
, cc_offset
+1) - '0') << 4;
565 cc
|= (tvb_get_uint8(tvb
, cc_offset
+2) - '0');
569 /* Determine how many of those digits are the Country Code */
570 switch (cc
& 0x0f00) {
578 switch (cc
& 0x00f0) {
589 switch (cc
& 0x00f0) {
605 switch (cc
& 0x00f0) {
615 switch (cc
& 0x00f0) {
626 switch (cc
& 0x00f0) {
641 switch (cc
& 0x00f0) {
654 switch (cc
& 0x00f0) {
673 } /* End switch cc */
675 /* (Now that we know how long the CC is,)
676 * shift off any extra digits we got.
690 } /* end switch cc_length */
692 /* Now process the CC as decimal */
693 bcd_ok
= convert_bcd_to_dec(cc
, &cc
);
696 if (encoding
== E164_ENC_UTF8
)
697 item
= proto_tree_add_uint(tree
, hf_E164_country_code
, tvb
, cc_offset
, cc_length
, cc
);
699 item
= proto_tree_add_uint(tree
, hf_E164_country_code
, tvb
, cc_offset
, length
, cc
);
701 expert_add_info(NULL
, item
, &ei_E164_country_code_non_decimal
);
704 /* Handle special Country Codes */
707 /* Get the 1-digit ID code */
709 case E164_ENC_BINARY
:
710 id_code
= tvb_get_uint8(tvb
, cc_offset
+ 1) & 0x0f;
713 id_code
= (tvb_get_uint8(tvb
, cc_offset
+ 1) & 0xf0) >> 4;
716 id_code
= tvb_get_uint8(tvb
, cc_offset
+ cc_length
) - '0';
719 bcd_ok
= (id_code
<= 9);
720 item
= proto_tree_add_uint_format_value(tree
, hf_E164_identification_code
, tvb
, (cc_offset
+ 1), 1,
721 id_code
, "%d %s", id_code
, val_to_str_const(id_code
, E164_GMSS_vals
, "Unknown"));
723 expert_add_info(NULL
, item
, &ei_E164_identification_code_non_decimal
);
727 /* Get the 2-digit ID code */
729 case E164_ENC_BINARY
:
730 id_code
= tvb_get_ntohs(tvb
, cc_offset
+ 1);
731 id_code
= (id_code
& 0x0ff0) >> 4;
734 id_code
= tvb_get_uint8(tvb
, cc_offset
+ 1) & 0xf0;
735 id_code
|= tvb_get_uint8(tvb
, cc_offset
+ 2) & 0x0f;
738 id_code
= (tvb_get_uint8(tvb
, cc_offset
+cc_length
) - '0') << 4;
739 id_code
|= (tvb_get_uint8(tvb
, cc_offset
+cc_length
+1) - '0');
742 bcd_ok
= convert_bcd_to_dec(id_code
, &id_code
);
743 item
= proto_tree_add_uint_format_value(tree
, hf_E164_identification_code
, tvb
, (cc_offset
+ 1), 2,
744 id_code
, "%d %s", id_code
, val_to_str_ext_const(id_code
, &E164_International_Networks_882_vals_ext
, "Unknown"));
746 expert_add_info(NULL
, item
, &ei_E164_identification_code_non_decimal
);
750 /* Get the 3-digit ID code */
752 case E164_ENC_BINARY
:
753 id_code
= tvb_get_ntohs(tvb
, cc_offset
+ 1);
754 id_code
= id_code
& 0x0fff;
757 id_code
= (tvb_get_uint8(tvb
, cc_offset
+ 1) & 0xf0) << 4;
758 id_code
|= (tvb_get_uint8(tvb
, cc_offset
+ 2) & 0x0f) << 4;
759 id_code
|= (tvb_get_uint8(tvb
, cc_offset
+ 2) & 0xf0) >> 4;
762 id_code
= (tvb_get_uint8(tvb
, cc_offset
+cc_length
) - '0') << 8;
763 id_code
|= (tvb_get_uint8(tvb
, cc_offset
+cc_length
+1) - '0') << 4;
764 id_code
|= (tvb_get_uint8(tvb
, cc_offset
+cc_length
+2) - '0');
767 if ((id_code
& 0x0ff0) == 0x510) {
768 /* Get the 4th digit of the ID code */
770 case E164_ENC_BINARY
:
771 id_code
= (id_code
<< 4) | ((tvb_get_uint8(tvb
, cc_offset
+ 3) & 0xf0) >> 4);
774 id_code
= (id_code
<< 4) | (tvb_get_uint8(tvb
, cc_offset
+ 3) & 0x0f);
777 id_code
= (id_code
<< 4) | (tvb_get_uint8(tvb
, cc_offset
+ cc_length
+ 3) - '0');
780 bcd_ok
= convert_bcd_to_dec(id_code
, &id_code
);
781 item
= proto_tree_add_uint_format_value(tree
, hf_E164_identification_code
, tvb
, (cc_offset
+ 1), 3,
782 id_code
, "%d %s", id_code
, val_to_str_const(id_code
, E164_International_Networks_883_vals
, "Unknown"));
784 expert_add_info(NULL
, item
, &ei_E164_identification_code_non_decimal
);
787 bcd_ok
= convert_bcd_to_dec(id_code
, &id_code
);
788 item
= proto_tree_add_uint_format_value(tree
, hf_E164_identification_code
, tvb
, (cc_offset
+ 1), 2,
789 id_code
, "%d %s", id_code
, val_to_str_const(id_code
, E164_International_Networks_883_vals
, "Unknown"));
791 expert_add_info(NULL
, item
, &ei_E164_identification_code_non_decimal
);
802 dissect_e164(tvbuff_t
*tvb
, proto_tree
*tree
, int offset
, int length
, e164_encoding_t encoding
, int name_type
)
806 unsigned str_encoding
;
811 str_encoding
= ENC_UTF_8
;
814 str_encoding
= ENC_BCD_DIGITS_0_9
|ENC_LITTLE_ENDIAN
;
816 case E164_ENC_BINARY
:
818 DISSECTOR_ASSERT_NOT_REACHED();
821 pi
= proto_tree_add_item_ret_display_string(tree
, name_type
, tvb
, offset
, length
, str_encoding
, wmem_packet_scope(), &number_str
);
823 subtree
= proto_item_add_subtree(pi
, ett_e164_msisdn
);
825 dissect_e164_cc(tvb
, subtree
, offset
, encoding
);
831 dissect_e164_msisdn(tvbuff_t
*tvb
, proto_tree
*tree
, int offset
, int length
, e164_encoding_t encoding
)
833 return dissect_e164(tvb
, tree
, offset
, length
, encoding
, hf_E164_msisdn
);
837 dissect_e164_isdn(tvbuff_t
*tvb
, proto_tree
*tree
, int offset
, int length
, e164_encoding_t encoding
)
839 return dissect_e164(tvb
, tree
, offset
, length
, encoding
, hf_E164_isdn
);
843 * Register the protocol with Wireshark.
847 proto_register_e164(void)
850 /* Setup list of header fields See Section 1.6.1 for details */
851 static hf_register_info hf
[] = {
852 { &hf_E164_calling_party_number
,
853 { "E.164 Calling party number digits", "e164.calling_party_number.digits",
854 FT_STRING
, BASE_NONE
, NULL
, 0x0,
857 { &hf_E164_called_party_number
,
858 { "E.164 Called party number digits", "e164.called_party_number.digits",
859 FT_STRING
, BASE_NONE
, NULL
, 0x0,
863 { "E.164 number (MSISDN)", "e164.msisdn",
864 FT_STRING
, BASE_NONE
, NULL
, 0x0,
868 { "E.164 number (ISDN)", "e164.isdn",
869 FT_STRING
, BASE_NONE
, NULL
, 0x0,
872 { &hf_E164_identification_code
,
873 { "Identification Code", "e164.identification_code",
874 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
877 { &hf_E164_country_code
,
878 { "Country Code", "e164.country_code",
879 FT_UINT16
, BASE_DEC
|BASE_EXT_STRING
, &E164_country_code_value_ext
, 0x0,
883 static int *ett_e164_array
[] = {
887 static ei_register_info ei
[] = {
888 { &ei_E164_country_code_non_decimal
, { "e164.country_code.non_decimal", PI_MALFORMED
, PI_WARN
, "Country Code contains non-decimal digits", EXPFILL
}},
889 { &ei_E164_identification_code_non_decimal
, { "e164.identification_code.non_decimal", PI_MALFORMED
, PI_WARN
, "Identification Code contains non-decimal digits", EXPFILL
}},
892 expert_module_t
* expert_e164
;
895 proto_e164
= proto_register_protocol("ITU-T E.164 number", "E.164", "e164");
897 proto_register_field_array(proto_e164
, hf
, array_length(hf
));
898 proto_register_subtree_array(ett_e164_array
, array_length(ett_e164_array
));
900 expert_e164
= expert_register_protocol(proto_e164
);
901 expert_register_field_array(expert_e164
, ei
, array_length(ei
));
905 * Editor modelines - https://www.wireshark.org/tools/modelines.html
910 * indent-tabs-mode: t
913 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
914 * :indentSize=8:tabSize=8:noTabs=false: