/epan/dissectors/packet-gtpv2.c

https://bitbucket.org/stevexiao/wireshark · C · 4504 lines · 3453 code · 379 blank · 672 comment · 58 complexity · f9a378f893bdf921e74fb028818d20aa MD5 · raw file

Large files are truncated click here to view the full file

  1. /* packet-gtpv2.c
  2. *
  3. * Routines for GTPv2 dissection
  4. * Copyright 2009 - 2011, Anders Broman <anders.broman [at] ericcsson.com>
  5. *
  6. * $Id: packet-gtpv2.c 38852 2011-09-01 23:27:28Z gerald $
  7. *
  8. * Wireshark - Network traffic analyzer
  9. * By Gerald Combs <gerald@wireshark.org>
  10. * Copyright 1998 Gerald Combs
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License
  14. * as published by the Free Software Foundation; either version 2
  15. * of the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  25. * Ref: 3GPP TS 29.274 version 8.1.1 Release 8 ETSI TS 129 274 V8.1.1 (2009-04)
  26. */
  27. #ifdef HAVE_CONFIG_H
  28. # include "config.h"
  29. #endif
  30. #include <stdlib.h>
  31. #include <glib.h>
  32. #include <epan/packet.h>
  33. #include <epan/asn1.h>
  34. #include <epan/expert.h>
  35. #include <epan/sminmpec.h>
  36. #include "packet-gsm_a_common.h"
  37. #include "packet-gsm_map.h"
  38. #include "packet-e164.h"
  39. #include "packet-e212.h"
  40. #include "packet-s1ap.h"
  41. #include "packet-ranap.h"
  42. static dissector_handle_t nas_eps_handle;
  43. /*GTPv2 Message->GTP Header(SB)*/
  44. static int proto_gtpv2 = -1;
  45. static int hf_gtpv2_reserved = -1;
  46. static int hf_gtpv2_spare_half_octet = -1;
  47. static int hf_gtpv2_spare_bits = -1;
  48. static int hf_gtpv2_flags = -1;
  49. static int hf_gtpv2_version = -1;
  50. static int hf_gtpv2_p = -1;
  51. static int hf_gtpv2_t = -1;
  52. static int hf_gtpv2_message_type = -1;
  53. static int hf_gtpv2_msg_length = -1;
  54. static int hf_gtpv2_teid = -1;
  55. static int hf_gtpv2_seq = -1;
  56. static int hf_gtpv2_spare = -1;
  57. static int hf_gtpv2_ie = -1;
  58. static int hf_gtpv2_ie_len = -1;
  59. static int hf_gtpv2_cr = -1;
  60. static int hf_gtpv2_instance = -1;
  61. static int hf_gtpv2_cause = -1;
  62. static int hf_gtpv2_cause_cs = -1;
  63. static int hf_gtpv2_cause_bce = -1;
  64. static int hf_gtpv2_cause_pce = -1;
  65. static int hf_gtpv2_cause_off_ie_t = -1;
  66. static int hf_gtpv2_rec = -1;
  67. static int hf_gtpv2_apn = -1;
  68. static int hf_gtpv2_ebi = -1;
  69. static int hf_gtpv2_daf = -1;
  70. static int hf_gtpv2_dtf = -1;
  71. static int hf_gtpv2_hi = -1;
  72. static int hf_gtpv2_dfi = -1;
  73. static int hf_gtpv2_oi = -1;
  74. static int hf_gtpv2_isrsi = -1;
  75. static int hf_gtpv2_israi = -1;
  76. static int hf_gtpv2_sgwci = -1;
  77. static int hf_gtpv2_sqci = -1;
  78. static int hf_gtpv2_uimsi = -1;
  79. static int hf_gtpv2_cfsi = -1;
  80. static int hf_gtpv2_crsi = -1;
  81. static int hf_gtpv2_pt = -1;
  82. static int hf_gtpv2_ps = -1;
  83. static int hf_gtpv2_si = -1;
  84. static int hf_gtpv2_msv = -1;
  85. static int hf_gtpv2_ccrsi = -1;
  86. static int hf_gtpv2_pdn_type = -1;
  87. static int hf_gtpv2_pdn_ipv4 = -1;
  88. static int hf_gtpv2_pdn_ipv6_len = -1;
  89. static int hf_gtpv2_pdn_ipv6 = -1;
  90. static int hf_gtpv2_pdn_numbers_nsapi = -1;
  91. static int hf_gtpv2_p_tmsi = -1;
  92. static int hf_gtpv2_p_tmsi_sig = -1;
  93. static int hf_gtpv2_rat_type = -1;
  94. static int hf_gtpv2_uli_ecgi_flg = -1;
  95. static int hf_gtpv2_uli_lai_flg = -1;
  96. static int hf_gtpv2_uli_tai_flg = -1;
  97. static int hf_gtpv2_uli_rai_flg = -1;
  98. static int hf_gtpv2_uli_sai_flg = -1;
  99. static int hf_gtpv2_uli_cgi_flg = -1;
  100. static int hf_gtpv2_cng_rep_act = -1;
  101. static int hf_gtpv2_selec_mode = -1;
  102. static int hf_gtpv2_source_type = -1;
  103. static int hf_gtpv2_f_teid_v4 = -1;
  104. static int hf_gtpv2_f_teid_v6 = -1;
  105. static int hf_gtpv2_f_teid_interface_type= -1;
  106. static int hf_gtpv2_f_teid_gre_key= -1;
  107. static int hf_gtpv2_f_teid_ipv4= -1;
  108. static int hf_gtpv2_f_teid_ipv6= -1;
  109. static int hf_gtpv2_tmsi = -1;
  110. static int hf_gtpv2_hsgw_addr_f_len = -1;
  111. static int hf_gtpv2_hsgw_addr_ipv4 = -1;
  112. static int hf_gtpv2_hsgw_addr_ipv6 = -1;
  113. static int hf_gtpv2_gre_key = -1;
  114. static int hf_gtpv2_sgw_addr_ipv4 = -1;
  115. static int hf_gtpv2_sgw_addr_ipv6 = -1;
  116. static int hf_gtpv2_sgw_s1u_teid = -1;
  117. static int hf_gtpv2_imsi= -1;
  118. static int hf_gtpv2_ipv4_addr = -1;
  119. static int hf_gtpv2_ambr_up= -1;
  120. static int hf_gtpv2_ambr_down= -1;
  121. static int hf_gtpv2_ip_address_ipv4= -1;
  122. static int hf_gtpv2_ip_address_ipv6= -1;
  123. static int hf_gtpv2_mei= -1;
  124. /* Trace Information */
  125. static int hf_gtpv2_tra_info = -1;
  126. static int hf_gtpv2_tra_info_msc_momt_calls = -1;
  127. static int hf_gtpv2_tra_info_msc_momt_sms = -1;
  128. static int hf_gtpv2_tra_info_msc_lu_imsi_ad = -1;
  129. static int hf_gtpv2_tra_info_msc_handovers = -1;
  130. static int hf_gtpv2_tra_info_msc_ss = -1;
  131. static int hf_gtpv2_tra_info_mgw_context = -1;
  132. static int hf_gtpv2_tra_info_sgsn_pdp_context = -1;
  133. static int hf_gtpv2_tra_info_sgsn_momt_sms = -1;
  134. static int hf_gtpv2_tra_info_sgsn_rau_gprs_ad = -1;
  135. static int hf_gtpv2_tra_info_sgsn_mbms = -1;
  136. static int hf_gtpv2_tra_info_sgsn_reserved = -1;
  137. static int hf_gtpv2_tra_info_ggsn_pdp = -1;
  138. static int hf_gtpv2_tra_info_ggsn_mbms = -1;
  139. static int hf_gtpv2_tra_info_bm_sc = -1;
  140. static int hf_gtpv2_tra_info_mme_sgw_ss = -1;
  141. static int hf_gtpv2_tra_info_mme_sgw_sr = -1;
  142. static int hf_gtpv2_tra_info_mme_sgw_iataud = -1;
  143. static int hf_gtpv2_tra_info_lne_msc_s = -1;
  144. static int hf_gtpv2_tra_info_lne_mgw = -1;
  145. static int hf_gtpv2_tra_info_lne_sgsn = -1;
  146. static int hf_gtpv2_tra_info_lne_ggsn = -1;
  147. static int hf_gtpv2_tra_info_lne_rnc = -1;
  148. static int hf_gtpv2_tra_info_lne_bm_sc = -1;
  149. static int hf_gtpv2_tra_info_lne_mme = -1;
  150. static int hf_gtpv2_tra_info_lne_sgw = -1;
  151. static int hf_gtpv2_tra_info_lne_pdn_gw = -1;
  152. static int hf_gtpv2_tra_info_lne_enb = -1;
  153. static int hf_gtpv2_tra_info_tdl = -1;
  154. static int hf_gtpv2_tra_info_lmsc_a = -1;
  155. static int hf_gtpv2_tra_info_lmsc_lu = -1;
  156. static int hf_gtpv2_tra_info_lmsc_mc = -1;
  157. static int hf_gtpv2_tra_info_lmsc_map_g = -1;
  158. static int hf_gtpv2_tra_info_lmsc_map_b = -1;
  159. static int hf_gtpv2_tra_info_lmsc_map_e = -1;
  160. static int hf_gtpv2_tra_info_lmsc_map_f = -1;
  161. static int hf_gtpv2_tra_info_lmsc_cap = -1;
  162. static int hf_gtpv2_tra_info_lmsc_map_d = -1;
  163. static int hf_gtpv2_tra_info_lmsc_map_c = -1;
  164. static int hf_gtpv2_tra_info_lmgw_mc = -1;
  165. static int hf_gtpv2_tra_info_lmgw_nb_up = -1;
  166. static int hf_gtpv2_tra_info_lmgw_lu_up = -1;
  167. static int hf_gtpv2_tra_info_lsgsn_gb = -1;
  168. static int hf_gtpv2_tra_info_lsgsn_lu = -1;
  169. static int hf_gtpv2_tra_info_lsgsn_gn = -1;
  170. static int hf_gtpv2_tra_info_lsgsn_map_gr = -1;
  171. static int hf_gtpv2_tra_info_lsgsn_map_gd = -1;
  172. static int hf_gtpv2_tra_info_lsgsn_map_gf = -1;
  173. static int hf_gtpv2_tra_info_lsgsn_gs = -1;
  174. static int hf_gtpv2_tra_info_lsgsn_ge = -1;
  175. static int hf_gtpv2_tra_info_lggsn_gn = -1;
  176. static int hf_gtpv2_tra_info_lggsn_gi = -1;
  177. static int hf_gtpv2_tra_info_lggsn_gmb = -1;
  178. static int hf_gtpv2_tra_info_lrnc_lu = -1;
  179. static int hf_gtpv2_tra_info_lrnc_lur = -1;
  180. static int hf_gtpv2_tra_info_lrnc_lub = -1;
  181. static int hf_gtpv2_tra_info_lrnc_uu = -1;
  182. static int hf_gtpv2_tra_info_lbm_sc_gmb = -1;
  183. static int hf_gtpv2_tra_info_lmme_s1_mme = -1;
  184. static int hf_gtpv2_tra_info_lmme_s3 = -1;
  185. static int hf_gtpv2_tra_info_lmme_s6a = -1;
  186. static int hf_gtpv2_tra_info_lmme_s10 = -1;
  187. static int hf_gtpv2_tra_info_lmme_s11 = -1;
  188. static int hf_gtpv2_tra_info_lsgw_s4 = -1;
  189. static int hf_gtpv2_tra_info_lsgw_s5 = -1;
  190. static int hf_gtpv2_tra_info_lsgw_s8b = -1;
  191. static int hf_gtpv2_tra_info_lsgw_s11 = -1;
  192. static int hf_gtpv2_tra_info_lpdn_gw_s2a = -1;
  193. static int hf_gtpv2_tra_info_lpdn_gw_s2b = -1;
  194. static int hf_gtpv2_tra_info_lpdn_gw_s2c = -1;
  195. static int hf_gtpv2_tra_info_lpdn_gw_s5 = -1;
  196. static int hf_gtpv2_tra_info_lpdn_gw_s6c = -1;
  197. static int hf_gtpv2_tra_info_lpdn_gw_gx = -1;
  198. static int hf_gtpv2_tra_info_lpdn_gw_s8b = -1;
  199. static int hf_gtpv2_tra_info_lpdn_gw_sgi = -1;
  200. static int hf_gtpv2_tra_info_lenb_s1_mme = -1;
  201. static int hf_gtpv2_tra_info_lenb_x2 = -1;
  202. static int hf_gtpv2_tra_info_lenb_uu = -1;
  203. static int hf_gtpv2_address_digits = -1;
  204. static int hf_gtpv2_ti = -1;
  205. static int hf_gtpv2_bearer_qos_pvi= -1;
  206. static int hf_gtpv2_bearer_qos_pl= -1;
  207. static int hf_gtpv2_bearer_qos_pci= -1;
  208. static int hf_gtpv2_bearer_qos_label_qci = -1;
  209. static int hf_gtpv2_bearer_qos_mbr_up = -1;
  210. static int hf_gtpv2_bearer_qos_mbr_down = -1;
  211. static int hf_gtpv2_bearer_qos_gbr_up = -1;
  212. static int hf_gtpv2_bearer_qos_gbr_down = -1;
  213. static int hf_gtpv2_flow_qos_label_qci = -1;
  214. static int hf_gtpv2_flow_qos_mbr_up = -1;
  215. static int hf_gtpv2_flow_qos_mbr_down = -1;
  216. static int hf_gtpv2_flow_qos_gbr_up = -1;
  217. static int hf_gtpv2_flow_qos_gbr_down = -1;
  218. static int hf_gtpv2_delay_value = -1;
  219. static int hf_gtpv2_charging_id = -1;
  220. static int hf_gtpv2_charging_characteristic = -1;
  221. static int hf_gtpv2_bearer_flag_ppc = -1;
  222. static int hf_gtpv2_bearer_flag_vb = -1;
  223. static int hf_gtpv2_ue_time_zone_dst = -1;
  224. static int hf_gtpv2_fq_csid_type = -1;
  225. static int hf_gtpv2_fq_csid_nr = -1;
  226. static int hf_gtpv2_fq_csid_ipv4 = -1;
  227. static int hf_gtpv2_fq_csid_ipv6 = -1;
  228. static int hf_gtpv2_fq_csid_id = -1;
  229. static int hf_gtpv2_complete_req_msg_type = -1;
  230. static int hf_gtpv2_mme_grp_id = -1;
  231. static int hf_gtpv2_mme_code = -1;
  232. static int hf_gtpv2_m_tmsi = -1;
  233. static int hf_gtpv2_container_type = -1;
  234. static int hf_gtpv2_cause_type = -1;
  235. static int hf_gtpv2_CauseRadioNetwork = -1;
  236. static int hf_gtpv2_CauseTransport = -1;
  237. static int hf_gtpv2_CauseNas = -1;
  238. static int hf_gtpv2_CauseProtocol = -1;
  239. static int hf_gtpv2_CauseMisc = -1;
  240. static int hf_gtpv2_target_type = -1;
  241. static int hf_gtpv2_macro_enodeb_id = -1;
  242. static int hf_gtpv2_node_type= -1;
  243. static int hf_gtpv2_fqdn = -1;
  244. static int hf_gtpv2_enterprise_id = -1;
  245. static int hf_gtpv2_apn_rest= -1;
  246. static int hf_gtpv2_pti= -1;
  247. static int hf_gtpv2_mm_context_sm = -1;
  248. static int hf_gtpv2_mm_context_nhi = -1;
  249. static int hf_gtpv2_mm_context_drxi = -1;
  250. static int hf_gtpv2_mm_context_cksn = -1;
  251. static int hf_gtpv2_mm_context_cksn_ksi = -1;
  252. static int hf_gtpv2_mm_context_ksi_a= -1;
  253. static int hf_gtpv2_mm_context_ksi = -1;
  254. static int hf_gtpv2_mm_context_nr_tri = -1;
  255. static int hf_gtpv2_mm_context_nr_qui = -1;
  256. static int hf_gtpv2_mm_context_nr_qua = -1;
  257. static int hf_gtpv2_mm_context_unipa = -1;
  258. static int hf_gtpv2_mm_context_unc = -1;
  259. static int hf_gtpv2_mm_context_nas_dl_cnt = -1;
  260. static int hf_gtpv2_mm_context_nas_ul_cnt = -1;
  261. static int hf_gtpv2_uli_cgi_lac= -1;
  262. static int hf_gtpv2_uli_cgi_ci= -1;
  263. static int hf_gtpv2_uli_sai_lac= -1;
  264. static int hf_gtpv2_uli_sai_sac= -1;
  265. static int hf_gtpv2_uli_rai_lac= -1;
  266. static int hf_gtpv2_uli_rai_rac= -1;
  267. static int hf_gtpv2_uli_tai_tac= -1;
  268. static int hf_gtpv2_uli_ecgi_eci= -1;
  269. static int hf_gtpv2_uli_lai_lac = -1;
  270. static int hf_gtpv2_uli_ecgi_eci_spare= -1;
  271. static int hf_gtpv2_nsapi = -1;
  272. static int hf_gtpv2_bearer_control_mode= -1;
  273. static gint ett_gtpv2 = -1;
  274. static gint ett_gtpv2_flags = -1;
  275. static gint ett_gtpv2_ie = -1;
  276. static gint ett_gtpv2_uli_flags = -1;
  277. static gint ett_gtpv2_uli_field = -1;
  278. static gint ett_gtpv2_bearer_ctx = -1;
  279. static gint ett_gtpv2_PDN_conn = -1;
  280. static gint ett_gtpv2_mm_context_flag = -1;
  281. static gint ett_gtpv2_pdn_numbers_nsapi = -1;
  282. static gint ett_gtpv2_tra_info_trigg = -1;
  283. static gint ett_gtpv2_tra_info_trigg_msc_server = -1;
  284. static gint ett_gtpv2_tra_info_trigg_mgw = -1;
  285. static gint ett_gtpv2_tra_info_trigg_sgsn = -1;
  286. static gint ett_gtpv2_tra_info_trigg_ggsn = -1;
  287. static gint ett_gtpv2_tra_info_trigg_bm_sc = -1;
  288. static gint ett_gtpv2_tra_info_trigg_sgw_mme = -1;
  289. static gint ett_gtpv2_tra_info_interfaces = -1;
  290. static gint ett_gtpv2_tra_info_interfaces_imsc_server = -1;
  291. static gint ett_gtpv2_tra_info_interfaces_lmgw = -1;
  292. static gint ett_gtpv2_tra_info_interfaces_lsgsn = -1;
  293. static gint ett_gtpv2_tra_info_interfaces_lggsn = -1;
  294. static gint ett_gtpv2_tra_info_interfaces_lrnc = -1;
  295. static gint ett_gtpv2_tra_info_interfaces_lbm_sc = -1;
  296. static gint ett_gtpv2_tra_info_interfaces_lmme = -1;
  297. static gint ett_gtpv2_tra_info_interfaces_lsgw = -1;
  298. static gint ett_gtpv2_tra_info_interfaces_lpdn_gw = -1;
  299. static gint ett_gtpv2_tra_info_interfaces_lpdn_lenb = -1;
  300. static gint ett_gtpv2_tra_info_ne_types = -1;
  301. /* Definition of User Location Info (AVP 22) masks */
  302. #define GTPv2_ULI_CGI_MASK 0x01
  303. #define GTPv2_ULI_SAI_MASK 0x02
  304. #define GTPv2_ULI_RAI_MASK 0x04
  305. #define GTPv2_ULI_TAI_MASK 0x08
  306. #define GTPv2_ULI_ECGI_MASK 0x10
  307. #define GTPv2_ULI_LAI_MASK 0x20
  308. #define GTPV2_CREATE_SESSION_REQUEST 32
  309. #define GTPV2_CREATE_SESSION_RESPONSE 33
  310. #define GTPV2_FORWARD_RELOCATION_REQ 133
  311. #define GTPV2_FORWARD_CTX_NOTIFICATION 137
  312. static void dissect_gtpv2_ie_common(tvbuff_t * tvb, packet_info * pinfo _U_, proto_tree * tree, gint offset, guint8 message_type);
  313. /*Message Types for GTPv2 (Refer Pg19 29.274) (SB)*/
  314. static const value_string gtpv2_message_type_vals[] = {
  315. {0, "Reserved"},
  316. {1, "Echo Request"},
  317. {2, "Echo Response"},
  318. {3, "Version Not Supported Indication"},
  319. /* 4-24 Reserved for S101 interface TS 29.276 */
  320. /* 25-31 Reserved for Sv interface TS 29.280 */
  321. /* SGSN/MME to PGW (S4/S11, S5/S8) */
  322. {32, "Create Session Request"},
  323. {33, "Create Session Response"},
  324. {34, "Modify Bearer Request"},
  325. {35, "Modify Bearer Response"},
  326. {36, "Delete Session Request"},
  327. {37, "Delete Session Response"},
  328. /* SGSN to PGW (S4, S5/S8) */
  329. {38, "Change Notification Request"},
  330. {39, "Change Notification Response"},
  331. /* 40-63 For future use */
  332. /* Messages without explicit response */
  333. {64, "Modify Bearer Command"}, /* (MME/SGSN to PGW -S11/S4, S5/S8) */
  334. {65, "Modify Bearer Failure Indication"}, /*(PGW to MME/SGSN -S5/S8, S11/S4) */
  335. {66, "Delete Bearer Command"}, /* (MME to PGW -S11, S5/S8) */
  336. {67, "Delete Bearer Failure Indication"}, /* (PGW to MME -S5/S8, S11) */
  337. {68, "Bearer Resource Command"}, /* (MME/SGSN to PGW -S11/S4, S5/S8) */
  338. {69, "Bearer Resource Failure Indication"}, /* (PGW to MME/SGSN -S5/S8, S11/S4) */
  339. {70, "Downlink Data Notification Failure Indication"}, /*(SGSN/MME to SGW -S4/S11) */
  340. {71, "Trace Session Activation"},
  341. {72, "Trace Session Deactivation"},
  342. {73, "Stop Paging Indication"},
  343. /* 74-94 For future use */
  344. /* PDN-GW to SGSN/MME (S5/S8, S4/S11) */
  345. {95, "Create Bearer Request"},
  346. {96, "Create Bearer Response"},
  347. {97, "Update Bearer Request"},
  348. {98, "Update Bearer Response"},
  349. {99, "Delete Bearer Request"},
  350. {100, "Delete Bearer Response"},
  351. /* PGW to MME, MME to PGW, SGW to PGW, SGW to MME (S5/S8, S11) */
  352. {101, "Delete PDN Connection Set Request"},
  353. {102, "Delete PDN Connection Set Response"},
  354. /* 103-127 For future use */
  355. /* MME to MME, SGSN to MME, MME to SGSN, SGSN to SGSN (S3/10/S16) */
  356. {128, "Identification Request"},
  357. {129, "Identification Response"},
  358. {130, "Context Request"},
  359. {131, "Context Response"},
  360. {132, "Context Acknowledge"},
  361. {133, "Forward Relocation Request"},
  362. {134, "Forward Relocation Response"},
  363. {135, "Forward Relocation Complete Notification"},
  364. {136, "Forward Relocation Complete Acknowledge"},
  365. {137, "Forward Access Context Notification"},
  366. {138, "Forward Access Context Acknowledge"},
  367. {139, "Relocation Cancel Request"},
  368. {140, "Relocation Cancel Response"},
  369. {141, "Configuration Transfer Tunnel"},
  370. /* 142-148 For future use */
  371. /* SGSN to MME, MME to SGSN (S3)*/
  372. {149, "Detach Notification"},
  373. {150, "Detach Acknowledge"},
  374. {151, "CS Paging Indication"},
  375. {152, "RAN Information Relay"},
  376. {153, "Alert MME Notification"},
  377. {154, "Alert MME Acknowledge"},
  378. {155, "UE Activity Notification"},
  379. {156, "UE Activity Acknowledge"},
  380. /* 157 to 159 For future use */
  381. /* MME to SGW (S11) */
  382. {160, "Create Forwarding Tunnel Request"},
  383. {161, "Create Forwarding Tunnel Response"},
  384. {162, "Suspend Notification"},
  385. {163, "Suspend Acknowledge"},
  386. {164, "Resume Notification"},
  387. {165, "Resume Acknowledge"},
  388. {166, "Create Indirect Data Forwarding Tunnel Request"},
  389. {167, "Create Indirect Data Forwarding Tunnel Response"},
  390. {168, "Delete Indirect Data Forwarding Tunnel Request"},
  391. {169, "Delete Indirect Data Forwarding Tunnel Response"},
  392. {170, "Release Access Bearers Request"},
  393. {171, "Release Access Bearers Response"},
  394. /* 172-175 For future use */
  395. /* SGW to SGSN/MME (S4/S11) */
  396. {176, "Downlink Data Notification"},
  397. {177, "Downlink Data Notification Acknowledgement"},
  398. /* SGW to SGSN (S4) */
  399. {178, "Update Bearer Complete"},
  400. /* 179-191 For future use */
  401. /* Other */
  402. {200, "Update PDN Connection Set Request"},
  403. {201, "Update PDN Connection Set Response"},
  404. /* 202 to 230 For future use */
  405. /* MBMS GW to MME/SGSN (Sm/Sn) */
  406. {231, "MBMS Session Start Request"},
  407. {323, "MBMS Session Start Response"},
  408. {233, "MBMS Session Update Request"},
  409. {234, "MBMS Session Update Response"},
  410. {235, "MBMS Session Stop Request"},
  411. {236, "MBMS Session Stop Response"},
  412. /* 237 to 239 For future use */
  413. /* 240-255 Reserved for GTP-U TS 29.281 [13] */
  414. {0, NULL}
  415. };
  416. #define GTPV2_IE_RESERVED 0
  417. #define GTPV2_IE_IMSI 1
  418. #define GTPV2_IE_CAUSE 2
  419. #define GTPV2_REC_REST_CNT 3
  420. #define GTPV2_APN 71
  421. #define GTPV2_AMBR 72
  422. #define GTPV2_EBI 73
  423. #define GTPV2_IP_ADDRESS 74
  424. #define GTPV2_MEI 75
  425. #define GTPV2_IE_MSISDN 76
  426. #define GTPV2_INDICATION 77
  427. #define GTPV2_PCO 78
  428. #define GTPV2_PAA 79
  429. #define GTPV2_BEARER_QOS 80
  430. #define GTPV2_IE_FLOW_QOS 81
  431. #define GTPV2_IE_RAT_TYPE 82
  432. #define GTPV2_IE_SERV_NET 83
  433. #define GTPV2_IE_BEARER_TFT 84
  434. #define GTPV2_IE_TAD 85
  435. #define GTPV2_IE_ULI 86
  436. #define GTPV2_IE_F_TEID 87
  437. #define GTPV2_IE_TMSI 88
  438. #define GTPV2_IE_GLOBAL_CNID 89
  439. #define GTPV2_IE_S103PDF 90
  440. #define GTPV2_IE_S1UDF 91
  441. #define GTPV2_IE_DEL_VAL 92
  442. #define GTPV2_IE_BEARER_CTX 93
  443. #define GTPV2_IE_CHAR_ID 94
  444. #define GTPV2_IE_CHAR_CHAR 95
  445. #define GTPV2_IE_TRA_INFO 96
  446. #define GTPV2_BEARER_FLAG 97
  447. /* define GTPV2_IE_PAGING_CAUSE 98 (void) */
  448. #define GTPV2_IE_PDN_TYPE 99
  449. #define GTPV2_IE_PTI 100
  450. #define GTPV2_IE_DRX_PARAM 101
  451. #define GTPV2_IE_UE_NET_CAPABILITY 102
  452. #define GTPV2_IE_MM_CONTEXT_GSM_T 103
  453. #define GTPV2_IE_MM_CONTEXT_UTMS_CQ 104
  454. #define GTPV2_IE_MM_CONTEXT_GSM_CQ 105
  455. #define GTPV2_IE_MM_CONTEXT_UTMS_Q 106
  456. #define GTPV2_IE_MM_CONTEXT_EPS_QQ 107
  457. #define GTPV2_IE_MM_CONTEXT_UTMS_QQ 108
  458. #define GTPV2_IE_PDN_CONNECTION 109
  459. #define GTPV2_IE_PDN_NUMBERS 110
  460. #define GTPV2_IE_P_TMSI 111
  461. #define GTPV2_IE_P_TMSI_SIG 112
  462. #define GTPV2_IE_HOP_COUNTER 113
  463. #define GTPV2_IE_UE_TIME_ZONE 114
  464. #define GTPV2_IE_TRACE_REFERENCE 115
  465. #define GTPV2_IE_COMPLETE_REQUEST_MSG 116
  466. #define GTPV2_IE_GUTI 117
  467. #define GTPV2_IE_F_CONTAINER 118
  468. #define GTPV2_IE_F_CAUSE 119
  469. #define GTPV2_IE_SEL_PLMN_ID 120
  470. #define GTPV2_IE_TARGET_ID 121
  471. /* GTPV2_IE_NSAPI 122 */
  472. #define GTPV2_IE_PKT_FLOW_ID 123
  473. #define GTPV2_IE_RAB_CONTEXT 124
  474. #define GTPV2_IE_S_RNC_PDCP_CTX_INFO 125
  475. #define GTPV2_IE_UDP_S_PORT_NR 126
  476. #define GTPV2_IE_APN_RESTRICTION 127
  477. #define GTPV2_IE_SEL_MODE 128
  478. #define GTPV2_IE_SOURCE_IDENT 129
  479. #define GTPV2_IE_BEARER_CONTROL_MODE 130
  480. #define GTPV2_IE_CNG_REP_ACT 131
  481. #define GTPV2_IE_FQ_CSID 132
  482. #define GTPV2_IE_CHANNEL_NEEDED 133
  483. #define GTPV2_IE_EMLPP_PRI 134
  484. #define GTPV2_IE_NODE_TYPE 135
  485. #define GTPV2_IE_FQDN 136
  486. #define GTPV2_IE_TI 137
  487. #define GTPV2_IE_PRIVATE_EXT 255
  488. #define SPARE 0X0
  489. #define CREATE_NEW_TFT 0X20
  490. #define DELETE_TFT 0X40
  491. #define ADD_PACKET_FILTERS_TFT 0X60
  492. #define REPLACE_PACKET_FILTERS_TFT 0X80
  493. #define DELETE_PACKET_FILTERS_TFT 0XA0
  494. #define NO_TFT_OPERATION 0XC0
  495. #define RESERVED 0XE0
  496. /* Table 8.1-1: Information Element types for GTPv2 */
  497. static const value_string gtpv2_element_type_vals[] = {
  498. {0, "Reserved"},
  499. {1, "International Mobile Subscriber Identity (IMSI)"}, /* Variable Length / 8.3 */
  500. {2, "Cause"}, /* Variable Length / 8.4 */
  501. {3, "Recovery (Restart Counter)"}, /* Variable Length / 8.5 */
  502. /* 4-50 Reserved for S101 interface Extendable / See 3GPP TS 29.276 [14] */
  503. /* 51-70 Reserved for Sv interface Extendable / See 3GPP TS 29.280 [15] */
  504. {71, "Access Point Name (APN)"}, /* Variable Length / 8.6 */
  505. {72, "Aggregate Maximum Bit Rate (AMBR)"}, /* Fixed Length / 8.7 */
  506. {73, "EPS Bearer ID (EBI)"}, /* Extendable / 8.8 */
  507. {74, "IP Address"}, /* Extendable / 8.9 */
  508. {75, "Mobile Equipment Identity (MEI)"}, /* Variable Length / 8.10 */
  509. {76, "MSISDN"}, /* Variable Length / 8.11 */
  510. {77, "Indication"}, /* Extendable / 8.12 */
  511. {78, "Protocol Configuration Options (PCO)"}, /* Variable Length / 8.13 */
  512. {79, "PDN Address Allocation (PAA)"}, /* Variable Length / 8.14 */
  513. {80, "Bearer Level Quality of Service (Bearer QoS)"}, /* Variable Length / 8.15 */
  514. {81, "Flow Quality of Service (Flow QoS)"}, /* Extendable / 8.16 */
  515. {82, "RAT Type"}, /* Extendable / 8.17 */
  516. {83, "Serving Network"}, /* Extendable / 8.18 */
  517. {84, "EPS Bearer Level Traffic Flow Template (Bearer TFT)"}, /* Variable Length / 8.19 */
  518. {85, "Traffic Aggregation Description (TAD)"}, /* Variable Length / 8.20 */
  519. {86, "User Location Info (ULI)"}, /* Variable Length / 8.21 */
  520. {87, "Fully Qualified Tunnel Endpoint Identifier (F-TEID)"}, /* Extendable / 8.22 */
  521. {88, "TMSI"}, /* Variable Length / 8.23 */
  522. {89, "Global CN-Id"}, /* Variable Length / 8.24 */
  523. {90, "S103 PDN Data Forwarding Info (S103PDF)"}, /* Variable Length / 8.25 */
  524. {91, "S1-U Data Forwarding Info (S1UDF)"}, /* Variable Length/ 8.26 */
  525. {92, "Delay Value"}, /* Extendable / 8.27 */
  526. {93, "Bearer Context"}, /* Extendable / 8.28 */
  527. {94, "Charging ID"}, /* Extendable / 8.29 */
  528. {95, "Charging Characteristics"}, /* Extendable / 8.30 */
  529. {96, "Trace Information"}, /* Extendable / 8.31 */
  530. {97, "Bearer Flags"}, /* Extendable / 8.32 */
  531. {98, "Paging Cause"}, /* Variable Length / 8.33 */
  532. {99, "PDN Type"}, /* Extendable / 8.34 */
  533. {100, "Procedure Transaction ID"}, /* Extendable / 8.35 */
  534. {101, "DRX Parameter"}, /* Variable Length/ 8.36 */
  535. {102, "UE Network Capability"}, /* Variable Length / 8.37 */
  536. {103, "MM Context (GSM Key and Triplets)"}, /* Variable Length / 8.38 */
  537. {104, "MM Context (UMTS Key, Used Cipher and Quintuplets)"}, /* Variable Length / 8.38 */
  538. {105, "MM Context (GSM Key, Used Cipher and Quintuplets)"}, /* Variable Length / 8.38 */
  539. {106, "MM Context (UMTS Key and Quintuplets)"}, /* Variable Length / 8.38 */
  540. {107, "MM Context (EPS Security Context, Quadruplets and Quintuplets)"}, /* Variable Length / 8.38 */
  541. {108, "MM Context (UMTS Key, Quadruplets and Quintuplets)"}, /* Variable Length / 8.38 */
  542. {109, "PDN Connection"}, /* Extendable / 8.39 */
  543. {110, "PDU Numbers"}, /* Extendable / 8.40 */
  544. {111, "P-TMSI"}, /* Variable Length / 8.41 */
  545. {112, "P-TMSI Signature"}, /* Variable Length / 8.42 */
  546. {113, "Hop Counter"}, /* Extendable / 8.43 */
  547. {114, "UE Time Zone"}, /* Variable Length / 8.44 */
  548. {115, "Trace Reference"}, /* Fixed Length / 8.45 */
  549. {116, "Complete Request Message"}, /* Variable Length / 8.46 */
  550. {117, "GUTI"}, /* Variable Length / 8.47 */
  551. {118, "F-Container"}, /* Variable Length / 8.48 */
  552. {119, "F-Cause"}, /* Variable Length / 8.49 */
  553. {120, "Selected PLMN ID"}, /* Variable Length / 8.50 */
  554. {121, "Target Identification"}, /* Variable Length / 8.51 */
  555. {122, "NSAPI"}, /* Extendable / 8.52 */
  556. {123, "Packet Flow ID"}, /* Variable Length / 8.53 */
  557. {124, "RAB Context"}, /* Fixed Length / 8.54 */
  558. {125, "Source RNC PDCP Context Info"}, /* Variable Length / 8.55 */
  559. {126, "UDP Source Port Number"}, /* Extendable / 8.56 */
  560. {127, "APN Restriction"}, /* Extendable / 8.57 */
  561. {128, "Selection Mode"}, /* Extendable / 8.58 */
  562. {129, "Source Identification"}, /* Variable Length / 8.50 */
  563. {130, "Bearer Control Mode"}, /* Extendable / 8.60 */
  564. {131, "Change Reporting Action"}, /* Variable Length / 8.61 */
  565. {132, "Fully Qualified PDN Connection Set Identifier (FQ-CSID)"}, /* Variable Length / 8.62 */
  566. {133, "Channel needed"}, /* Extendable / 8.63 */
  567. {134, "eMLPP Priority"}, /* Extendable / 8.64 */
  568. {135, "Node Type"}, /* Extendable / 8.65 */
  569. {136, "Fully Qualified Domain Name (FQDN)"}, /* Variable Length / 8.66 */
  570. {137, "Transaction Identifier (TI)"}, /* Variable Length / 8.68 */
  571. {138, "MBMS Session"}, /* Duration Extendable / 8.69 */
  572. {139, "MBMS Service Area"}, /* Extendable / 8.70 */
  573. {140, "MBMS Session Identifier"}, /* Extendable / 8.71 */
  574. {141, "MBMS Flow Identifier"}, /* Extendable / 8.72 */
  575. {142, "MBMS IP Multicast Distribution"}, /* Extendable / 8.73 */
  576. {143, "MBMS Distribution Acknowledge"}, /* Extendable / 8.74 */
  577. {144, "RFSP Index"}, /* Fixed Length / 8.77 */
  578. {145, "User CSG Information (UCI)"}, /* Extendable / 8.75 */
  579. {146, "CSG Information Reporting Action"}, /* Extendable / 8.76 */
  580. {147, "CSG ID"}, /* Extendable / 8.78 */
  581. {148, "CSG Membership Indication (CMI)"}, /* Extendable / 8.79 */
  582. {149, "Service indicator"}, /* Fixed Length / 8.80 */
  583. {150, "Detach Type"}, /* Fixed Length / 8.81 */
  584. {151, "Local Distiguished Name (LDN)"}, /* Variable / 8.82 */
  585. {152, "Node Features"}, /* Extendable / 8.83 */
  586. {153, "MBMS Time to Data Transfer"}, /* Extendable / 8.84 */
  587. {154, "Throttling"}, /* Extendable / 8.85 */
  588. {155, "Allocation/Retention Priority (ARP)"}, /* Extendable / 8.86 */
  589. /* 156 to 254 Spare. For future use. */ /* For future use. FFS */
  590. {255, "Private"}, /* Extension Extendable / 8.67 */
  591. {0, NULL}
  592. };
  593. /* Code to dissect IE's */
  594. static void
  595. dissect_gtpv2_unknown(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_,guint8 message_type _U_, guint8 instance _U_)
  596. {
  597. proto_item *expert_item;
  598. expert_item = proto_tree_add_text(tree, tvb, 0, length, "IE data not dissected yet");
  599. expert_add_info_format(pinfo, expert_item, PI_PROTOCOL, PI_NOTE, "IE data not dissected yet");
  600. PROTO_ITEM_SET_GENERATED(expert_item);
  601. }
  602. /*
  603. * 8.3 International Mobile Subscriber Identity (IMSI)
  604. *
  605. * IMSI is defined in 3GPP TS 23.003
  606. * Editor's note: IMSI coding will be defined in 3GPP TS 24.301
  607. * Editor's note: In the first release of GTPv2 spec (TS 29.274v8.0.0) n = 8.
  608. * That is, the overall length of the IE is 11 octets.
  609. */
  610. static void
  611. dissect_gtpv2_imsi(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_,guint8 message_type _U_, guint8 instance _U_)
  612. {
  613. int offset= 0;
  614. const gchar *imsi_str;
  615. /* Fetch the BCD encoded digits from tvb low half byte, formating the digits according to
  616. * a default digit set of 0-9 returning "?" for overdecadic digits a pointer to the EP
  617. * allocated string will be returned.
  618. */
  619. imsi_str = tvb_bcd_dig_to_ep_str( tvb, offset, length, NULL, FALSE);
  620. proto_tree_add_string(tree, hf_gtpv2_imsi, tvb, offset, length, imsi_str);
  621. proto_item_append_text(item, "%s", imsi_str);
  622. }
  623. /*
  624. * 8.4 Cause
  625. */
  626. /* Table 8.4-1: Cause values */
  627. static const value_string gtpv2_cause_vals[] = {
  628. {0, "Reserved"},
  629. /* Request */
  630. {1, "Paging Cause"},
  631. {2, "Local Detach"},
  632. {3, "Complete Detach"},
  633. {4, "RAT changed from 3GPP to Non-3GPP"},
  634. {5, "ISR is activated"},
  635. {6, "Error Indication received from RNC/eNodeB"},
  636. {7, "IMSI Detach Only"},
  637. {8, "Reactivation Requested"},
  638. {9, "PDN reconnection to this APN disallowed"},
  639. {10, "Access changed from Non-3GPP to 3GPP"},
  640. /* 11-15 Spare. This value range is reserved for Cause values in a request message */
  641. {11, "Spare"},
  642. {12, "Spare"},
  643. {13, "Spare"},
  644. {14, "Spare"},
  645. {15, "Spare"},
  646. /* Acceptance Response */
  647. {16, "Request accepted"},
  648. {17, "Request accepted partially"},
  649. {18, "New PDN type due to network preference"},
  650. {19, "New PDN type due to single address bearer only"},
  651. /* 20-63 Spare. This value range is reserved for Cause values in acceptance response message */
  652. /* Rejection Response */
  653. {20, "Spare"},
  654. {21, "Spare"},
  655. {22, "Spare"},
  656. {23, "Spare"},
  657. {24, "Spare"},
  658. {25, "Spare"},
  659. {26, "Spare"},
  660. {27, "Spare"},
  661. {28, "Spare"},
  662. {29, "Spare"},
  663. {30, "Spare"},
  664. {31, "Spare"},
  665. {32, "Spare"},
  666. {33, "Spare"},
  667. {34, "Spare"},
  668. {35, "Spare"},
  669. {36, "Spare"},
  670. {37, "Spare"},
  671. {38, "Spare"},
  672. {39, "Spare"},
  673. {40, "Spare"},
  674. {41, "Spare"},
  675. {42, "Spare"},
  676. {43, "Spare"},
  677. {44, "Spare"},
  678. {45, "Spare"},
  679. {46, "Spare"},
  680. {47, "Spare"},
  681. {48, "Spare"},
  682. {49, "Spare"},
  683. {50, "Spare"},
  684. {51, "Spare"},
  685. {52, "Spare"},
  686. {53, "Spare"},
  687. {54, "Spare"},
  688. {55, "Spare"},
  689. {56, "Spare"},
  690. {57, "Spare"},
  691. {58, "Spare"},
  692. {59, "Spare"},
  693. {60, "Spare"},
  694. {61, "Spare"},
  695. {62, "Spare"},
  696. {63, "Spare"},
  697. {64, "Context Not Found"},
  698. {65, "Invalid Message Format"},
  699. {66, "Version not supported by next peer"},
  700. {67, "Invalid length"},
  701. {68, "Service not supported"},
  702. {69, "Mandatory IE incorrect"},
  703. {70, "Mandatory IE missing"},
  704. {71, "Optional IE incorrect"},
  705. {72, "System failure"},
  706. {73, "No resources available"},
  707. {74, "Semantic error in the TFT operation"},
  708. {75, "Syntactic error in the TFT operation"},
  709. {76, "Semantic errors in packet filter(s)"},
  710. {77, "Syntactic errors in packet filter(s)"},
  711. {78, "Missing or unknown APN"},
  712. {79, "Unexpected repeated IE"},
  713. {80, "GRE key not found"},
  714. {81, "Reallocation failure"},
  715. {82, "Denied in RAT"},
  716. {83, "Preferred PDN type not supported"},
  717. {84, "All dynamic addresses are occupied"},
  718. {85, "UE context without TFT already activated"},
  719. {86, "Protocol type not supported"},
  720. {87, "UE not responding"},
  721. {88, "UE refuses"},
  722. {89, "Service denied"},
  723. {90, "Unable to page UE"},
  724. {91, "No memory available"},
  725. {92, "User authentication failed"},
  726. {93, "APN access denied - no subscription"},
  727. {94, "Request rejected"},
  728. {95, "P-TMSI Signature mismatch"},
  729. {96, "IMSI not known"},
  730. {97, "Semantic error in the TAD operation"},
  731. {98, "Syntactic error in the TAD operation"},
  732. {99, "Reserved Message Value Received"},
  733. {100, "PGW not responding"},
  734. {101, "Collision with network initiated request"},
  735. {102, "Unable to page UE due to Suspension"},
  736. {103, "Conditional IE missing"},
  737. {104, "APN Restriction type Incompatible with currently active PDN connection"},
  738. {105, "Invalid overall length of the triggered response message and a piggybacked initial message"},
  739. {106, "Data forwarding not supported"},
  740. {107, "Invalid reply from remote peer"},
  741. {108, "Fallback to GTPv1"},
  742. {109, "Invalid peer"},
  743. {110, "Temporarily rejected due to handover procedure in progress"},
  744. {111, "Modifications not limited to S1-U bearers"},
  745. {112, "Request rejected for a PMIPv6 reason "},
  746. /* 113-239 Spare. For future use in a triggered/response message */
  747. /* 240-255 Spare. For future use in an initial/request message */
  748. {0, NULL}
  749. };
  750. static value_string_ext gtpv2_cause_vals_ext = VALUE_STRING_EXT_INIT(gtpv2_cause_vals);
  751. /* Table 8.4-1: CS (Cause Source) */
  752. static const true_false_string gtpv2_cause_cs = {
  753. "Originated by remote node",
  754. "Originated by node sending the message",
  755. };
  756. static void
  757. dissect_gtpv2_cause(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_,guint8 message_type _U_, guint8 instance _U_)
  758. {
  759. int offset = 0;
  760. guint8 tmp;
  761. /* Cause value octet 5 */
  762. tmp = tvb_get_guint8(tvb, offset);
  763. proto_tree_add_item(tree, hf_gtpv2_cause, tvb, offset, 1, FALSE);
  764. /* Add Cause to ie_tree */
  765. proto_item_append_text(item, "%s (%u)", val_to_str_ext_const(tmp, &gtpv2_cause_vals_ext, "Unknown"),tmp);
  766. offset++;
  767. /* Octet 6 Spare PCE BCE CS */
  768. proto_tree_add_bits_item(tree, hf_gtpv2_spare_bits, tvb, offset<<3, 5, FALSE);
  769. proto_tree_add_item(tree, hf_gtpv2_cause_pce, tvb, offset, 1, FALSE);
  770. proto_tree_add_item(tree, hf_gtpv2_cause_bce, tvb, offset, 1, FALSE);
  771. proto_tree_add_item(tree, hf_gtpv2_cause_cs, tvb, offset, 1, FALSE);
  772. offset++;
  773. /* If n = 2, a = 0 and the Cause IE shall be 6 octets long.
  774. * Therefore, octets "a(n+1) to a(n+4)" will not be present.
  775. * If n = 6, a = 1 and the Cause IE will be 10 octets long.
  776. */
  777. if ( length == 2 ) {
  778. return;
  779. }
  780. /*
  781. * If the rejection is due to a mandatory IE or a verifiable conditional IE is faulty
  782. * or missing, the offending IE shall be included within an additional field "a(n+1)
  783. * to a(n+4)". Only Type and Instance fields of the offending IE that caused the
  784. * rejection have a meaning. The length in the Octet 8-9 and spare bits in the Octet 10
  785. * shall be set to "0". In this case, the value of "n" shall be "6".
  786. * Otherwise, the value of "n" is equal to "2".
  787. */
  788. /* Type of the offending IE */
  789. proto_tree_add_item(tree, hf_gtpv2_cause_off_ie_t, tvb, offset, 1, FALSE);
  790. offset++;
  791. /* Length */
  792. proto_tree_add_item(tree, hf_gtpv2_ie_len, tvb, offset, 2, FALSE);
  793. offset+=2;
  794. /* a(n+4) Spare Instance */
  795. proto_tree_add_bits_item(tree, hf_gtpv2_spare_half_octet, tvb, offset>>3, 4, FALSE);
  796. proto_tree_add_item(tree, hf_gtpv2_instance, tvb, offset, 1, FALSE);
  797. offset++;
  798. }
  799. /*
  800. * 8.5 Recovery (Restart Counter)
  801. */
  802. static void
  803. dissect_gtpv2_recovery(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_,guint8 message_type _U_, guint8 instance _U_)
  804. {
  805. int offset = 0;
  806. guint8 recovery;
  807. recovery = tvb_get_guint8(tvb, offset);
  808. proto_tree_add_item(tree, hf_gtpv2_rec, tvb, offset, 1, FALSE);
  809. proto_item_append_text(item, "%u", recovery);
  810. }
  811. /*
  812. * 8.6 Access Point Name (APN)
  813. * The encoding the APN field follows 3GPP TS 23.003 [2] subclause 9.1.
  814. * The content of the APN field shall be the full APN with both the APN Network Identifier
  815. * and APN Operator Identifier being present as specified in 3GPP TS 23.003 [2]
  816. * subclauses 9.1.1 and 9.1.2, 3GPP TS 23.060 [35] Annex A and 3GPP TS 23.401 [3] subclauses 4.3.8.1.
  817. */
  818. static void
  819. dissect_gtpv2_apn(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
  820. {
  821. int offset = 0;
  822. guint8 *apn = NULL;
  823. int name_len, tmp;
  824. if (length > 0) {
  825. name_len = tvb_get_guint8(tvb, offset);
  826. if (name_len < 0x20) {
  827. apn = tvb_get_ephemeral_string(tvb, offset + 1, length - 1);
  828. for (;;) {
  829. if (name_len >= length - 1)
  830. break;
  831. tmp = name_len;
  832. name_len = name_len + apn[tmp] + 1;
  833. apn[tmp] = '.';
  834. }
  835. } else{
  836. apn = tvb_get_ephemeral_string(tvb, offset, length);
  837. }
  838. proto_tree_add_string(tree, hf_gtpv2_apn, tvb, offset, length, apn);
  839. }
  840. if (apn)
  841. proto_item_append_text(item, "%s", apn);
  842. }
  843. /*
  844. * 8.7 Aggregate Maximum Bit Rate (AMBR)
  845. */
  846. static void
  847. dissect_gtpv2_ambr(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_,guint8 message_type _U_, guint8 instance _U_)
  848. {
  849. int offset = 0;
  850. proto_tree_add_item(tree, hf_gtpv2_ambr_up, tvb, offset, 4, FALSE);
  851. offset= offset + 4;
  852. proto_tree_add_item(tree, hf_gtpv2_ambr_down, tvb, offset, 4, FALSE);
  853. }
  854. /*
  855. * 8.8 EPS Bearer ID (EBI)
  856. */
  857. static void
  858. dissect_gtpv2_ebi(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_,guint8 message_type _U_, guint8 instance _U_)
  859. {
  860. int offset = 0;
  861. guint8 ebi;
  862. /* Spare (all bits set to 0) B8 - B5*/
  863. proto_tree_add_bits_item(tree, hf_gtpv2_spare_bits, tvb, offset, 4, FALSE);
  864. /* EPS Bearer ID (EBI) B4 - B1 */
  865. ebi = tvb_get_guint8(tvb, offset);
  866. proto_tree_add_item(tree, hf_gtpv2_ebi, tvb, offset, 1, FALSE);
  867. proto_item_append_text(item, "%u", ebi);
  868. }
  869. /*
  870. * 8.9 IP Address
  871. */
  872. static void
  873. dissect_gtpv2_ip_address(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_,guint8 message_type _U_, guint8 instance _U_)
  874. {
  875. int offset = 0;
  876. struct e_in6_addr ipv6_addr;
  877. if (length==4)
  878. {
  879. proto_tree_add_item(tree, hf_gtpv2_ip_address_ipv4, tvb, offset, length, FALSE);
  880. proto_item_append_text(item, "IPv4 %s", tvb_ip_to_str(tvb, offset));
  881. }
  882. else if (length==16)
  883. {
  884. proto_tree_add_item(tree, hf_gtpv2_ip_address_ipv6, tvb, offset, length, FALSE);
  885. tvb_get_ipv6(tvb, offset, &ipv6_addr);
  886. proto_item_append_text(item, "IPv6 %s", ip6_to_str(&ipv6_addr));
  887. }
  888. }
  889. /*
  890. * 8.10 Mobile Equipment Identity (MEI)
  891. * The ME Identity field contains either the IMEI or the IMEISV
  892. * as defined in clause 6.2 of 3GPP TS 23.003 [2]. It is encoded
  893. * as specified in clause 7.7.53 of 3GPP TS 29.060 [4], beginning
  894. * with octet 4 of Figure 7.7.53.1. The IMEI(SV) digits are encoded
  895. * using BCD coding where IMEI is 15 BCD digits and IMEISV is 16 BCD
  896. * digits. For IMEI, bits 5 to 8 of the last octet shall be filled
  897. * with an end mark coded as '1111'.
  898. */
  899. static void
  900. dissect_gtpv2_mei(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_,guint8 message_type _U_, guint8 instance _U_)
  901. {
  902. int offset= 0;
  903. const gchar *mei_str;
  904. /* Fetch the BCD encoded digits from tvb low half byte, formating the digits according to
  905. * a default digit set of 0-9 returning "?" for overdecadic digits a pointer to the EP
  906. * allocated string will be returned.
  907. */
  908. mei_str = tvb_bcd_dig_to_ep_str( tvb, 0, length, NULL, FALSE);
  909. proto_tree_add_string(tree, hf_gtpv2_mei, tvb, offset, length, mei_str);
  910. proto_item_append_text(item, "%s", mei_str);
  911. }
  912. /*
  913. * 8.11 MSISDN
  914. *
  915. * MSISDN is defined in 3GPP TS 23.003
  916. * Editor's note: MSISDN coding will be defined in TS 24.301.
  917. */
  918. static void
  919. dissect_gtpv2_msisdn(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_,guint8 message_type _U_, guint8 instance _U_)
  920. {
  921. const char *digit_str;
  922. /* Octets 5 to (n+4) represent the MSISDN value is in international number format
  923. * as described in ITU-T Rec E.164 [25] and 3GPP TS 29.002 [41].
  924. * MSISDN value contains only the actual MSISDN number (does not contain the "nature of
  925. * address indicator" octet, which indicates "international number"
  926. * as in 3GPP TS 29.002 [41]) and is encoded as TBCD digits, i.e.
  927. * digits from 0 through 9 are encoded "0000" to "1001".
  928. * When there is an odd number of digits, bits 8 to 5 of the last octet are encoded with
  929. * the filler "1111".
  930. */
  931. dissect_e164_cc(tvb, tree, 0, TRUE);
  932. /* Fetch the BCD encoded digits from tvb low half byte, formating the digits according to
  933. * a default digit set of 0-9 returning "?" for overdecadic digits a pointer to the EP
  934. * allocated string will be returned.
  935. */
  936. digit_str = tvb_bcd_dig_to_ep_str( tvb, 0, length, NULL, FALSE);
  937. proto_tree_add_string(tree, hf_gtpv2_address_digits, tvb, 0, length, digit_str);
  938. proto_item_append_text(item, "%s", digit_str);
  939. }
  940. /*
  941. * 8.12 Indication
  942. */
  943. static void
  944. dissect_gtpv2_ind(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_)
  945. {
  946. int offset = 0;
  947. /* Octet 5 DAF DTF HI DFI OI ISRSI ISRAI SGWCI */
  948. proto_tree_add_item(tree, hf_gtpv2_daf, tvb, offset, 1, FALSE);
  949. proto_tree_add_item(tree, hf_gtpv2_dtf, tvb, offset, 1, FALSE);
  950. proto_tree_add_item(tree, hf_gtpv2_hi, tvb, offset, 1, FALSE);
  951. proto_tree_add_item(tree, hf_gtpv2_dfi, tvb, offset, 1, FALSE);
  952. proto_tree_add_item(tree, hf_gtpv2_oi, tvb, offset, 1, FALSE);
  953. proto_tree_add_item(tree, hf_gtpv2_isrsi, tvb, offset, 1, FALSE);
  954. proto_tree_add_item(tree, hf_gtpv2_israi, tvb, offset, 1, FALSE);
  955. proto_tree_add_item(tree, hf_gtpv2_sgwci, tvb, offset, 1, FALSE);
  956. if(length==1) {
  957. proto_tree_add_text(tree, tvb, 0, length, "Older version?, should be 2 octets in 8.0.0");
  958. return;
  959. }
  960. offset++;
  961. /* Octet 6 SQCI UIMSI CFSI CRSI P PT SI MSV
  962. * 3GPP TS 29.274 version 9.4.0 Release 9
  963. */
  964. proto_tree_add_item(tree, hf_gtpv2_sqci, tvb, offset, 1, FALSE);
  965. proto_tree_add_item(tree, hf_gtpv2_uimsi, tvb, offset, 1, FALSE);
  966. proto_tree_add_item(tree, hf_gtpv2_cfsi, tvb, offset, 1, FALSE);
  967. proto_tree_add_item(tree, hf_gtpv2_crsi, tvb, offset, 1, FALSE);
  968. proto_tree_add_item(tree, hf_gtpv2_ps, tvb, offset, 1, FALSE);
  969. proto_tree_add_item(tree, hf_gtpv2_pt, tvb, offset, 1, FALSE);
  970. proto_tree_add_item(tree, hf_gtpv2_si, tvb, offset, 1, FALSE);
  971. proto_tree_add_item(tree, hf_gtpv2_msv, tvb, offset, 1, FALSE);
  972. offset++;
  973. if(length==2){
  974. return;
  975. }
  976. /* Only present in version 9 and higher */
  977. /* Octet 7 Spare Spare Spare Spare Spare Spare Spare CCRSI */
  978. proto_tree_add_item(tree, hf_gtpv2_ccrsi, tvb, offset, 1, FALSE);
  979. }
  980. /*
  981. * 8.13 Protocol Configuration Options (PCO)
  982. * Protocol Configuration Options (PCO) is transferred via GTP tunnels. The sending entity copies the value part of the
  983. * PCO into the Value field of the PCO IE. The detailed coding of the PCO field from octets 5 to (n+4) shall be specified
  984. * as per clause 10.5.6.3 of 3GPP TS 24.008 [5], starting with octet 3.
  985. * Dissected in packet-gsm_a_gm.c
  986. */
  987. static void
  988. dissect_gtpv2_pco(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 length _U_,guint8 message_type _U_, guint8 instance _U_)
  989. {
  990. switch(message_type){
  991. case GTPV2_CREATE_SESSION_REQUEST:
  992. /* PCO options as MS to network direction */
  993. pinfo->link_dir = P2P_DIR_UL;
  994. break;
  995. case GTPV2_CREATE_SESSION_RESPONSE:
  996. /* PCO options as Network to MS direction: */
  997. pinfo->link_dir = P2P_DIR_DL;
  998. break;
  999. default:
  1000. break;
  1001. }
  1002. de_sm_pco(tvb, tree, pinfo, 0, length, NULL, 0);
  1003. }
  1004. /*
  1005. * 8.14 PDN Address Allocation (PAA)
  1006. */
  1007. static const value_string gtpv2_pdn_type_vals[] = {
  1008. {1, "IPv4"},
  1009. {2, "IPv6"},
  1010. {3, "IPv4/IPv6"},
  1011. {0, NULL}
  1012. };
  1013. static void
  1014. dissect_gtpv2_paa(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_, guint8 message_type _U_, guint8 instance _U_)
  1015. {
  1016. int offset = 0;
  1017. guint8 pdn_type;
  1018. pdn_type = tvb_get_guint8(tvb, offset);
  1019. proto_tree_add_item(tree, hf_gtpv2_pdn_type, tvb, offset, 1, FALSE);
  1020. offset++;
  1021. switch(pdn_type)
  1022. {
  1023. case 1:
  1024. /* IPv4 */
  1025. proto_tree_add_item(tree, hf_gtpv2_pdn_ipv4, tvb, offset, 4, FALSE);
  1026. offset+=4;
  1027. break;
  1028. case 2:
  1029. /* IPv6*/
  1030. /* If PDN type value indicates IPv6, octet 6 contains the IPv6 Prefix Length.
  1031. * Octets 7 through 22 contain an IPv6 Prefix and Interface Identifier.
  1032. * Bit 8 of octet 7 represents the most significant bit of the IPv6 Prefix
  1033. * and Interface Identifier and bit 1 of octet 22 the least significant bit.
  1034. */
  1035. proto_tree_add_item(tree, hf_gtpv2_pdn_ipv6_len, tvb, offset, 1, FALSE);
  1036. offset++;
  1037. proto_tree_add_item(tree, hf_gtpv2_pdn_ipv6, tvb, offset, 16, FALSE);
  1038. offset+=16;
  1039. break;
  1040. case 3:
  1041. /* IPv4/IPv6 */
  1042. /* If PDN type value indicates IPv4v6, octet 6 contains the IPv6 Prefix Length.
  1043. * Octets 7 through 22 contain an IPv6 Prefix and Interface Identifier.
  1044. * Bit 8 of octet 7 represents the most significant bit of the IPv6 Prefix
  1045. * and Interface Identifier and bit 1 of octet 22 the least significant bit.
  1046. * Octets 23 through 26 contain an IPv4 address. Bit 8 of octet 23 represents
  1047. * the most significant bit of the IPv4 address and bit 1 of octet 26 the least
  1048. * significant bit.
  1049. */
  1050. proto_tree_add_item(tree, hf_gtpv2_pdn_ipv6_len, tvb, offset, 1, FALSE);
  1051. offset++;
  1052. proto_tree_add_item(tree, hf_gtpv2_pdn_ipv6, tvb, offset, 16, FALSE);
  1053. offset+=16;
  1054. proto_tree_add_item(tree, hf_gtpv2_pdn_ipv4, tvb, offset, 4, FALSE);
  1055. offset+=4;
  1056. break;
  1057. default:
  1058. break;
  1059. }
  1060. }
  1061. /*
  1062. * 8.15 Bearer Quality of Service (Bearer QoS)
  1063. */
  1064. static void
  1065. dissect_gtpv2_bearer_qos(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_,guint8 message_type _U_, guint8 instance _U_)
  1066. {
  1067. int offset = 0;
  1068. proto_tree_add_item(tree, hf_gtpv2_bearer_qos_pvi, tvb, offset, 1, FALSE);
  1069. proto_tree_add_item(tree, hf_gtpv2_bearer_qos_pl, tvb, offset, 1, FALSE);
  1070. proto_tree_add_item(tree, hf_gtpv2_bearer_qos_pci, tvb, offset, 1, FALSE);
  1071. offset++;
  1072. proto_tree_add_item(tree, hf_gtpv2_bearer_qos_label_qci, tvb, offset, 1, FALSE);
  1073. offset++;
  1074. proto_tree_add_item(tree, hf_gtpv2_bearer_qos_mbr_up, tvb, offset, 5, FALSE);
  1075. offset= offset+5;
  1076. proto_tree_add_item(tree, hf_gtpv2_bearer_qos_mbr_down, tvb, offset, 5, FALSE);
  1077. offset= offset+5;
  1078. proto_tree_add_item(tree, hf_gtpv2_bearer_qos_gbr_up, tvb, offset, 5, FALSE);
  1079. offset= offset+5;
  1080. proto_tree_add_item(tree, hf_gtpv2_bearer_qos_gbr_down, tvb, offset, 5, FALSE);
  1081. offset= offset+5;
  1082. }
  1083. /*
  1084. * 8.16 Flow Quality of Service (Flow QoS)
  1085. */
  1086. static void
  1087. dissect_gtpv2_flow_qos(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint16 length _U_,guint8 message_type _U_, guint8 instance _U_)
  1088. {
  1089. int offset = 0;
  1090. proto_tree_add_item(tree, hf_gtpv2_flow_qos_label_qci, tvb, offset, 1, FALSE);
  1091. offset++;
  1092. proto_tree_add_item(tree, hf_gtpv2_flow_qos_mbr_up, tvb, o