PageRenderTime 46ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 2ms

/epan/dissectors/packet-ppp.c

https://github.com/labx-technologies-llc/wireshark
C | 6870 lines | 5576 code | 732 blank | 562 comment | 274 complexity | d565937fffc7e1d4a6d6170abe1b6cf1 MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause
  1. /* packet-ppp.c
  2. * Routines for ppp packet disassembly
  3. * RFC 1661, RFC 1662
  4. *
  5. * $Id$
  6. *
  7. * Wireshark - Network traffic analyzer
  8. * By Gerald Combs <gerald@wireshark.org>
  9. *
  10. * This file created and by Mike Hall <mlh@io.com>
  11. * Copyright 1998
  12. *
  13. * This program is free software; you can redistribute it and/or
  14. * modify it under the terms of the GNU General Public License
  15. * as published by the Free Software Foundation; either version 2
  16. * of the License, or (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software
  25. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  26. */
  27. #include "config.h"
  28. #include <glib.h>
  29. #include <epan/packet.h>
  30. #include <epan/prefs.h>
  31. #include <epan/wmem/wmem.h>
  32. #include "packet-ppp.h"
  33. #include <epan/ppptypes.h>
  34. #include <epan/etypes.h>
  35. #include <epan/expert.h>
  36. #include <epan/ip_opts.h>
  37. #include <epan/atalk-utils.h>
  38. #include "packet-chdlc.h"
  39. #include "packet-ip.h"
  40. #include "packet-ipx.h"
  41. #include "packet-vines.h"
  42. #include <epan/nlpid.h>
  43. #include <epan/crc16-tvb.h>
  44. #include <epan/crc32-tvb.h>
  45. #include <epan/ipproto.h>
  46. #include <epan/addr_resolv.h>
  47. #include <epan/oui.h>
  48. #include "packet-usb.h"
  49. #include "packet-sll.h"
  50. static int proto_ppp = -1;
  51. static int hf_ppp_direction = -1;
  52. static int hf_ppp_address = -1;
  53. static int hf_ppp_control = -1;
  54. static int hf_ppp_protocol = -1;
  55. static int hf_ppp_code = -1;
  56. static int hf_ppp_identifier = -1;
  57. static int hf_ppp_length = -1;
  58. static int hf_ppp_magic_number = -1;
  59. static int hf_ppp_oui = -1;
  60. static int hf_ppp_kind = -1;
  61. static int hf_ppp_data = -1;
  62. static int hf_ppp_opt_type = -1;
  63. static int hf_ppp_opt_type_copy = -1;
  64. static int hf_ppp_opt_type_class = -1;
  65. static int hf_ppp_opt_type_number = -1;
  66. static gint ett_ppp = -1;
  67. static gint ett_ppp_opt_type = -1;
  68. static expert_field ei_ppp_opt_len_invalid = EI_INIT;
  69. static int proto_ppp_hdlc = -1;
  70. static gint ett_ppp_hdlc_data = -1;
  71. static int proto_lcp = -1;
  72. static gint ett_lcp = -1;
  73. static gint ett_lcp_options = -1;
  74. static gint ett_lcp_vendor_opt = -1;
  75. static gint ett_lcp_mru_opt = -1;
  76. static gint ett_lcp_asyncmap_opt = -1;
  77. static gint ett_lcp_authprot_opt = -1;
  78. static gint ett_lcp_qualprot_opt = -1;
  79. static gint ett_lcp_magicnumber_opt = -1;
  80. static gint ett_lcp_linkqualmon_opt = -1;
  81. static gint ett_lcp_pcomp_opt = -1;
  82. static gint ett_lcp_acccomp_opt = -1;
  83. static gint ett_lcp_fcs_alternatives_opt = -1;
  84. static gint ett_lcp_self_desc_pad_opt = -1;
  85. static gint ett_lcp_numbered_mode_opt = -1;
  86. static gint ett_lcp_callback_opt = -1;
  87. static gint ett_lcp_compound_frames_opt = -1;
  88. static gint ett_lcp_nomdataencap_opt = -1;
  89. static gint ett_lcp_multilink_mrru_opt = -1;
  90. static gint ett_lcp_multilink_ssnh_opt = -1;
  91. static gint ett_lcp_multilink_ep_disc_opt = -1;
  92. static gint ett_lcp_magic_block = -1;
  93. static gint ett_lcp_dce_identifier_opt = -1;
  94. static gint ett_lcp_multilink_pp_opt = -1;
  95. static gint ett_lcp_bacp_link_discrim_opt = -1;
  96. static gint ett_lcp_auth_opt = -1;
  97. static gint ett_lcp_cobs_opt = -1;
  98. static gint ett_lcp_prefix_elision_opt = -1;
  99. static gint ett_multilink_hdr_fmt_opt = -1;
  100. static gint ett_lcp_internationalization_opt = -1;
  101. static gint ett_lcp_simple_opt = -1;
  102. static int proto_ipcp = -1;
  103. static gint ett_ipcp = -1;
  104. static gint ett_ipcp_options = -1;
  105. static gint ett_ipcp_ipaddrs_opt = -1;
  106. static gint ett_ipcp_compress_opt = -1;
  107. static gint ett_ipcp_ipaddr_opt = -1;
  108. static gint ett_ipcp_mobileipv4_opt = -1;
  109. static gint ett_ipcp_pridns_opt = -1;
  110. static gint ett_ipcp_secdns_opt = -1;
  111. static gint ett_ipcp_prinbns_opt = -1;
  112. static gint ett_ipcp_secnbns_opt = -1;
  113. static gint ett_ipcp_iphc_rtp_compress_opt = -1;
  114. static gint ett_ipcp_iphc_enhanced_rtp_compress_opt = -1;
  115. static gint ett_ipcp_iphc_neghdrcomp_opt = -1;
  116. static gint ett_ipcp_rohc_profiles_opt = -1;
  117. static int proto_vsncp = -1;
  118. static gint ett_vsncp = -1;
  119. static gint ett_vsncp_options = -1;
  120. static int proto_vsnp = -1;
  121. static gint hf_vsnp_pdnid = -1;
  122. static gint ett_vsnp =-1;
  123. static int proto_osinlcp = -1;
  124. static gint ett_osinlcp = -1;
  125. static gint ett_osinlcp_options = -1;
  126. static gint ett_osinlcp_align_npdu_opt = -1;
  127. static int proto_bcp = -1;
  128. static int hf_bcp_flags = -1;
  129. static int hf_bcp_fcs_present = -1;
  130. static int hf_bcp_zeropad = -1;
  131. static int hf_bcp_bcontrol = -1;
  132. static int hf_bcp_pads = -1;
  133. static int hf_bcp_mac_type = -1;
  134. static gint ett_bcp = -1;
  135. static gint ett_bcp_flags = -1;
  136. static int proto_ccp = -1;
  137. static gint ett_ccp = -1;
  138. static gint ett_ccp_options = -1;
  139. static gint ett_ccp_oui_opt = -1;
  140. static gint ett_ccp_predict1_opt = -1;
  141. static gint ett_ccp_predict2_opt = -1;
  142. static gint ett_ccp_puddle_opt = -1;
  143. static gint ett_ccp_hpppc_opt = -1;
  144. static gint ett_ccp_stac_opt = -1;
  145. static gint ett_ccp_stac_opt_check_mode = -1;
  146. static gint ett_ccp_mppe_opt = -1;
  147. static gint ett_ccp_mppe_opt_supp_bits = -1;
  148. static gint ett_ccp_gfza_opt = -1;
  149. static gint ett_ccp_v42bis_opt = -1;
  150. static gint ett_ccp_bsdcomp_opt = -1;
  151. static gint ett_ccp_lzsdcp_opt = -1;
  152. static gint ett_ccp_mvrca_opt = -1;
  153. static gint ett_ccp_dce_opt = -1;
  154. static gint ett_ccp_deflate_opt = -1;
  155. static gint ett_ccp_v44lzjh_opt = -1;
  156. static int proto_cbcp = -1;
  157. static gint ett_cbcp = -1;
  158. static gint ett_cbcp_options = -1;
  159. static gint ett_cbcp_callback_opt = -1;
  160. static gint ett_cbcp_callback_opt_addr = -1;
  161. static int proto_bacp = -1;
  162. static gint ett_bacp = -1;
  163. static gint ett_bacp_options = -1;
  164. static gint ett_bacp_favored_peer_opt = -1;
  165. static int proto_bap = -1;
  166. static gint ett_bap = -1;
  167. static gint ett_bap_options = -1;
  168. static gint ett_bap_link_type_opt = -1;
  169. static gint ett_bap_phone_delta_opt = -1;
  170. static gint ett_bap_phone_delta_subopt = -1;
  171. static gint ett_bap_call_status_opt = -1;
  172. static int proto_comp_data = -1;
  173. #if 0 /* see dissect_comp_data() */
  174. static gint ett_comp_data = -1;
  175. #endif
  176. static int proto_pppmuxcp = -1;
  177. static int hf_pppmux_flags_pid = -1;
  178. static int hf_pppmux_flags_field_length = -1;
  179. static gint ett_pppmuxcp = -1;
  180. static gint ett_pppmuxcp_options = -1;
  181. static int proto_pppmux = -1;
  182. static int hf_pppmux_protocol = -1;
  183. static gint ett_pppmux = -1;
  184. static gint ett_pppmux_subframe = -1;
  185. static gint ett_pppmux_subframe_hdr = -1;
  186. static gint ett_pppmux_subframe_flags = -1;
  187. static gint ett_pppmux_subframe_info = -1;
  188. static int proto_mp = -1;
  189. static int hf_mp_frag_first = -1;
  190. static int hf_mp_frag_last = -1;
  191. static int hf_mp_short_sequence_num_reserved = -1;
  192. static int hf_mp_sequence_num = -1;
  193. static int hf_mp_sequence_num_reserved = -1;
  194. static int hf_mp_short_sequence_num = -1;
  195. static int ett_mp = -1;
  196. static int ett_mp_flags = -1;
  197. static int proto_mplscp = -1;
  198. static gint ett_mplscp = -1;
  199. static gint ett_mplscp_options = -1;
  200. static int proto_cdpcp = -1;
  201. static gint ett_cdpcp = -1;
  202. static gint ett_cdpcp_options = -1;
  203. static int proto_pap = -1; /* PAP vars */
  204. static gint ett_pap = -1;
  205. static gint ett_pap_data = -1;
  206. static gint hf_pap_code = -1;
  207. static gint hf_pap_identifier = -1;
  208. static gint hf_pap_length = -1;
  209. static gint hf_pap_data = -1;
  210. static gint hf_pap_peer_id = -1;
  211. static gint hf_pap_peer_id_length = -1;
  212. static gint hf_pap_password = -1;
  213. static gint hf_pap_password_length = -1;
  214. static gint hf_pap_message = -1;
  215. static gint hf_pap_message_length = -1;
  216. static gint hf_pap_stuff = -1;
  217. static int proto_chap = -1; /* CHAP vars */
  218. static gint ett_chap = -1;
  219. static gint ett_chap_data = -1;
  220. static gint hf_chap_code = -1;
  221. static gint hf_chap_identifier = -1;
  222. static gint hf_chap_length = -1;
  223. static gint hf_chap_data = -1;
  224. static gint hf_chap_value_size = -1;
  225. static gint hf_chap_value = -1;
  226. static gint hf_chap_name = -1;
  227. static gint hf_chap_message = -1;
  228. static int proto_ipv6cp = -1; /* IPv6CP vars */
  229. static gint ett_ipv6cp = -1;
  230. static gint ett_ipv6cp_options = -1;
  231. static gint ett_ipv6cp_if_id_opt = -1;
  232. static gint ett_ipv6cp_compress_opt = -1;
  233. static int proto_iphc_crtp = -1; /* CRTP vars */
  234. static int hf_iphc_crtp_cid8 = -1;
  235. static int hf_iphc_crtp_cid16 = -1;
  236. static int hf_iphc_crtp_gen = -1;
  237. static int hf_iphc_crtp_seq = -1;
  238. static int hf_iphc_crtp_fh_flags = -1;
  239. static int hf_iphc_crtp_cs_flags = -1;
  240. static int hf_iphc_crtp_cs_cnt = -1;
  241. static int hf_iphc_crtp_cs_invalid = -1;
  242. static gint ett_iphc_crtp = -1;
  243. static gint ett_iphc_crtp_hdr = -1;
  244. static gint ett_iphc_crtp_info = -1;
  245. static dissector_table_t ppp_subdissector_table;
  246. static dissector_handle_t chdlc_handle;
  247. static dissector_handle_t data_handle;
  248. static dissector_handle_t eth_withfcs_handle;
  249. static dissector_handle_t eth_withoutfcs_handle;
  250. static const value_string ppp_direction_vals[] = {
  251. {P2P_DIR_RECV, "DCE->DTE"},
  252. {P2P_DIR_SENT, "DTE->DCE"},
  253. {0, NULL}
  254. };
  255. /* options */
  256. static gint ppp_fcs_decode = 0; /* 0 = No FCS, 1 = 16 bit FCS, 2 = 32 bit FCS */
  257. #define NO_FCS 0
  258. #define FCS_16 1
  259. #define FCS_32 2
  260. const enum_val_t fcs_options[] = {
  261. {"none", "None", NO_FCS},
  262. {"16-bit", "16-Bit", FCS_16},
  263. {"32-bit", "32-Bit", FCS_32},
  264. {NULL, NULL, -1}
  265. };
  266. gboolean ppp_vj_decomp = TRUE; /* Default to VJ header decompression */
  267. /*
  268. * For Default Protocol ID negotiated with PPPMuxCP. We need to
  269. * this ID so that if the first subframe doesn't have protocol
  270. * ID, we can use it
  271. */
  272. static guint pppmux_def_prot_id = 0;
  273. /* PPP definitions */
  274. /*
  275. * Used by the GTP dissector as well.
  276. * www.iana.org/assignments/ppp-numbers
  277. */
  278. static const value_string ppp_vals[] = {
  279. {PPP_PADDING, "Padding Protocol"},
  280. {PPP_ROHC_SCID, "ROHC small-CID"},
  281. {PPP_ROHC_LCID, "ROHC large-CID"},
  282. {PPP_IP, "Internet Protocol version 4"},
  283. {PPP_OSI, "OSI Network Layer"},
  284. {PPP_XNSIDP, "Xerox NS IDP"},
  285. {PPP_DEC4, "DECnet Phase IV"},
  286. {PPP_AT, "Appletalk"},
  287. {PPP_IPX, "Novell IPX"},
  288. {PPP_VJC_COMP, "Van Jacobson Compressed TCP/IP"},
  289. {PPP_VJC_UNCOMP, "Van Jacobson Uncompressed TCP/IP"},
  290. {PPP_BCP, "Bridging PDU"},
  291. {PPP_ST, "Stream Protocol (ST-II)"},
  292. {PPP_VINES, "Banyan Vines"},
  293. {PPP_AT_EDDP, "AppleTalk EDDP"},
  294. {PPP_AT_SB, "AppleTalk SmartBuffered"},
  295. {PPP_MP, "Multi-Link"},
  296. {PPP_NB, "NETBIOS Framing"},
  297. {PPP_CISCO, "Cisco Systems"},
  298. {PPP_ASCOM, "Ascom Timeplex"},
  299. {PPP_LBLB, "Fujitsu Link Backup and Load Balancing (LBLB)"},
  300. {PPP_RL, "DCA Remote Lan"},
  301. {PPP_SDTP, "Serial Data Transport Protocol (PPP-SDTP)"},
  302. {PPP_LLC, "SNA over 802.2"},
  303. {PPP_SNA, "SNA"},
  304. {PPP_IPV6HC, "IPv6 Header Compression "},
  305. {PPP_KNX, "KNX Bridging Data"},
  306. {PPP_ENCRYPT, "Encryption"},
  307. {PPP_ILE, "Individual Link Encryption"},
  308. {PPP_IPV6, "Internet Protocol version 6"},
  309. {PPP_MUX, "PPP Muxing"},
  310. {PPP_VSNP, "Vendor-Specific Network Protocol (VSNP)"},
  311. {PPP_TNP, "TRILL Network Protocol (TNP)"},
  312. {PPP_RTP_FH, "RTP IPHC Full Header"},
  313. {PPP_RTP_CTCP, "RTP IPHC Compressed TCP"},
  314. {PPP_RTP_CNTCP, "RTP IPHC Compressed Non TCP"},
  315. {PPP_RTP_CUDP8, "RTP IPHC Compressed UDP 8"},
  316. {PPP_RTP_CRTP8, "RTP IPHC Compressed RTP 8"},
  317. {PPP_STAMPEDE, "Stampede Bridging"},
  318. {PPP_MPPLUS, "MP+ Protocol"},
  319. {PPP_NTCITS_IPI, "NTCITS IPI"},
  320. {PPP_ML_SLCOMP, "Single link compression in multilink"},
  321. {PPP_COMP, "Compressed datagram"},
  322. {PPP_STP_HELLO, "802.1d Hello Packets"},
  323. {PPP_IBM_SR, "IBM Source Routing BPDU"},
  324. {PPP_DEC_LB, "DEC LANBridge100 Spanning Tree"},
  325. {PPP_CDP, "Cisco Discovery Protocol"},
  326. {PPP_NETCS, "Netcs Twin Routing"},
  327. {PPP_STP, "STP - Scheduled Transfer Protocol"},
  328. {PPP_EDP, "EDP - Extreme Discovery Protocol"},
  329. {PPP_OSCP, "Optical Supervisory Channel Protocol (OSCP)"},
  330. {PPP_OSCP2, "Optical Supervisory Channel Protocol (OSCP)"},
  331. {PPP_LUXCOM, "Luxcom"},
  332. {PPP_SIGMA, "Sigma Network Systems"},
  333. {PPP_ACSP, "Apple Client Server Protocol"},
  334. {PPP_MPLS_UNI, "MPLS Unicast"},
  335. {PPP_MPLS_MULTI, "MPLS Multicast"},
  336. {PPP_P12844, "IEEE p1284.4 standard - data packets"},
  337. {PPP_TETRA, "ETSI TETRA Network Protocol Type 1"},
  338. {PPP_MFTP, "Multichannel Flow Treatment Protocol"},
  339. {PPP_RTP_CTCPND, "RTP IPHC Compressed TCP No Delta"},
  340. {PPP_RTP_CS, "RTP IPHC Context State"},
  341. {PPP_RTP_CUDP16, "RTP IPHC Compressed UDP 16"},
  342. {PPP_RTP_CRDP16, "RTP IPHC Compressed RTP 16"},
  343. {PPP_CCCP, "Cray Communications Control Protocol"},
  344. {PPP_CDPD_MNRP, "CDPD Mobile Network Registration Protocol"},
  345. {PPP_EXPANDAP, "Expand accelerator protocol"},
  346. {PPP_ODSICP, "ODSICP NCP"},
  347. {PPP_DOCSIS, "DOCSIS DLL"},
  348. {PPP_CETACEANNDP, "Cetacean Network Detection Protocol"},
  349. {PPP_LZS, "Stacker LZS"},
  350. {PPP_REFTEK, "RefTek Protocol"},
  351. {PPP_FC, "Fibre Channel"},
  352. {PPP_EMIT, "EMIT Protocols"},
  353. {PPP_VSP, "Vendor-Specific Protocol (VSP)"},
  354. {PPP_TLSP, "TRILL Link State Protocol (TLSP)"},
  355. {PPP_IPCP, "Internet Protocol Control Protocol"},
  356. {PPP_OSINLCP, "OSI Network Layer Control Protocol"},
  357. {PPP_XNSIDPCP, "Xerox NS IDP Control Protocol"},
  358. {PPP_DECNETCP, "DECnet Phase IV Control Protocol"},
  359. {PPP_ATCP, "AppleTalk Control Protocol"},
  360. {PPP_IPXCP, "Novell IPX Control Protocol"},
  361. {PPP_BRIDGENCP, "Bridging NCP"},
  362. {PPP_SPCP, "Stream Protocol Control Protocol"},
  363. {PPP_BVCP, "Banyan Vines Control Protocol"},
  364. {PPP_MLCP, "Multi-Link Control Protocol"},
  365. {PPP_NBCP, "NETBIOS Framing Control Protocol"},
  366. {PPP_CISCOCP, "Cisco Systems Control Protocol"},
  367. {PPP_ASCOMCP, "Ascom Timeplex"},
  368. {PPP_LBLBCP, "Fujitsu LBLB Control Protocol"},
  369. {PPP_RLNCP, "DCA Remote Lan Network Control Protocol (RLNCP)"},
  370. {PPP_SDCP, "Serial Data Control Protocol (PPP-SDCP)"},
  371. {PPP_LLCCP, "SNA over 802.2 Control Protocol"},
  372. {PPP_SNACP, "SNA Control Protocol"},
  373. {PPP_IP6HCCP, "IP6 Header Compression Control Protocol"},
  374. {PPP_KNXCP, "KNX Bridging Control Protocol"},
  375. {PPP_ECP, "Encryption Control Protocol"},
  376. {PPP_ILECP, "Individual Link Encryption Control Protocol"},
  377. {PPP_IPV6CP, "IPv6 Control Protocol"},
  378. {PPP_MUXCP, "PPP Muxing Control Protocol"},
  379. {PPP_VSNCP, "Vendor-Specific Network Control Protocol (VSNCP)"},
  380. {PPP_TNCP, "TRILL Network Control Protocol"},
  381. {PPP_STAMPEDECP, "Stampede Bridging Control Protocol"},
  382. {PPP_MPPCP, "MP+ Control Protocol"},
  383. {PPP_IPICP, "NTCITS IPI Control Protocol"},
  384. {PPP_SLCC, "Single link compression in multilink control"},
  385. {PPP_CCP, "Compression Control Protocol"},
  386. {PPP_CDPCP, "Cisco Discovery Protocol Control Protocol"},
  387. {PPP_NETCSCP, "Netcs Twin Routing"},
  388. {PPP_STPCP, "STP - Control Protocol"},
  389. {PPP_EDPCP, "EDPCP - Extreme Discovery Protocol Control Protocol"},
  390. {PPP_ACSPC, "Apple Client Server Protocol Control"},
  391. {PPP_MPLSCP, "MPLS Control Protocol"},
  392. {PPP_P12844CP, "IEEE p1284.4 standard - Protocol Control"},
  393. {PPP_TETRACP, "ETSI TETRA TNP1 Control Protocol"},
  394. {PPP_MFTPCP, "Multichannel Flow Treatment Protocol"},
  395. {PPP_LCP, "Link Control Protocol"},
  396. {PPP_PAP, "Password Authentication Protocol"},
  397. {PPP_LQR, "Link Quality Report"},
  398. {PPP_SPAP, "Shiva Password Authentication Protocol"},
  399. {PPP_CBCP, "Callback Control Protocol (CBCP)"},
  400. {PPP_BACP, "BACP Bandwidth Allocation Control Protocol"},
  401. {PPP_BAP, "BAP Bandwidth Allocation Protocol"},
  402. {PPP_VSAP, "Vendor-Specific Authentication Protocol (VSAP)"},
  403. {PPP_CONTCP, "Container Control Protocol"},
  404. {PPP_CHAP, "Challenge Handshake Authentication Protocol"},
  405. {PPP_RSAAP, "RSA Authentication Protocol"},
  406. {PPP_EAP, "Extensible Authentication Protocol"},
  407. {PPP_SIEP, "Mitsubishi Security Information Exchange Protocol (SIEP)"},
  408. {PPP_SBAP, "Stampede Bridging Authorization Protocol"},
  409. {PPP_PRPAP, "Proprietary Authentication Protocol"},
  410. {PPP_PRPAP2, "Proprietary Authentication Protocol"},
  411. {PPP_PRPNIAP, "Proprietary Node ID Authentication Protocol"},
  412. {0, NULL}
  413. };
  414. value_string_ext ppp_vals_ext = VALUE_STRING_EXT_INIT(ppp_vals);
  415. /* CP (LCP, CCP, IPCP, etc.) codes.
  416. * from pppd fsm.h
  417. */
  418. #define VNDRSPCFC 0 /* Vendor Specific: RFC 2153 */
  419. #define CONFREQ 1 /* Configuration Request */
  420. #define CONFACK 2 /* Configuration Ack */
  421. #define CONFNAK 3 /* Configuration Nak */
  422. #define CONFREJ 4 /* Configuration Reject */
  423. #define TERMREQ 5 /* Termination Request */
  424. #define TERMACK 6 /* Termination Ack */
  425. #define CODEREJ 7 /* Code Reject */
  426. static const value_string cp_vals[] = {
  427. {VNDRSPCFC, "Vendor Specific"},
  428. {CONFREQ, "Configuration Request"},
  429. {CONFACK, "Configuration Ack"},
  430. {CONFNAK, "Configuration Nak"},
  431. {CONFREJ, "Configuration Reject"},
  432. {TERMREQ, "Termination Request"},
  433. {TERMACK, "Termination Ack"},
  434. {CODEREJ, "Code Reject"},
  435. {0, NULL}
  436. };
  437. /*
  438. * LCP-specific packet types.
  439. */
  440. #define PROTREJ 8 /* Protocol Reject */
  441. #define ECHOREQ 9 /* Echo Request */
  442. #define ECHOREP 10 /* Echo Reply */
  443. #define DISCREQ 11 /* Discard Request */
  444. #define IDENT 12 /* Identification */
  445. #define TIMEREMAIN 13 /* Time remaining */
  446. /*
  447. * CCP-specific packet types.
  448. */
  449. #define RESETREQ 14 /* Reset Request */
  450. #define RESETACK 15 /* Reset Ack */
  451. /*
  452. * CBCP-specific packet types.
  453. */
  454. #define CBREQ 1 /* Callback Request */
  455. #define CBRES 2 /* Callback Response */
  456. #define CBACK 3 /* Callback Ack */
  457. #define CBCP_OPT 6 /* Use callback control protocol */
  458. /*
  459. * BAP-specific packet types.
  460. */
  461. #define BAP_CREQ 1 /* Call Request */
  462. #define BAP_CRES 2 /* Call Response */
  463. #define BAP_CBREQ 3 /* Callback Request */
  464. #define BAP_CBRES 4 /* Callback Response */
  465. #define BAP_LDQREQ 5 /* Link Drop Query Request */
  466. #define BAP_LDQRES 6 /* Link Drop Query Response */
  467. #define BAP_CSI 7 /* Call Status Indication */
  468. #define BAP_CSRES 8 /* Call Status Response */
  469. static const value_string lcp_vals[] = {
  470. {VNDRSPCFC, "Vendor Specific"},
  471. {CONFREQ, "Configuration Request"},
  472. {CONFACK, "Configuration Ack"},
  473. {CONFNAK, "Configuration Nak"},
  474. {CONFREJ, "Configuration Reject"},
  475. {TERMREQ, "Termination Request"},
  476. {TERMACK, "Termination Ack"},
  477. {CODEREJ, "Code Reject"},
  478. {PROTREJ, "Protocol Reject"},
  479. {ECHOREQ, "Echo Request"},
  480. {ECHOREP, "Echo Reply"},
  481. {DISCREQ, "Discard Request"},
  482. {IDENT, "Identification"},
  483. {TIMEREMAIN, "Time Remaining"},
  484. {0, NULL}
  485. };
  486. static const value_string ccp_vals[] = {
  487. {VNDRSPCFC, "Vendor Specific"},
  488. {CONFREQ, "Configuration Request"},
  489. {CONFACK, "Configuration Ack"},
  490. {CONFNAK, "Configuration Nak"},
  491. {CONFREJ, "Configuration Reject"},
  492. {TERMREQ, "Termination Request"},
  493. {TERMACK, "Termination Ack"},
  494. {CODEREJ, "Code Reject"},
  495. {RESETREQ, "Reset Request"},
  496. {RESETACK, "Reset Ack"},
  497. {0, NULL}
  498. };
  499. static const value_string cbcp_vals[] = {
  500. {CBREQ, "Callback Request"},
  501. {CBRES, "Callback Response"},
  502. {CBACK, "Callback Ack"},
  503. {0, NULL}
  504. };
  505. static const value_string bap_vals[] = {
  506. {BAP_CREQ, "Call Request"},
  507. {BAP_CRES, "Call Response"},
  508. {BAP_CBREQ, "Callback Request"},
  509. {BAP_CBRES, "Callback Response"},
  510. {BAP_LDQREQ, "Link Drop Query Request"},
  511. {BAP_LDQRES, "Link Drop Query Response"},
  512. {BAP_CSI, "Call Status Indication"},
  513. {BAP_CSRES, "Call Status Response"},
  514. {0, NULL}
  515. };
  516. #define BAP_RESP_CODE_REQACK 0x00
  517. #define BAP_RESP_CODE_REQNAK 0x01
  518. #define BAP_RESP_CODE_REQREJ 0x02
  519. #define BAP_RESP_CODE_REQFULLNAK 0x03
  520. static const value_string bap_resp_code_vals[] = {
  521. {BAP_RESP_CODE_REQACK, "Request Ack"},
  522. {BAP_RESP_CODE_REQNAK, "Request Nak"},
  523. {BAP_RESP_CODE_REQREJ, "Request Rej"},
  524. {BAP_RESP_CODE_REQFULLNAK, "Request Full Nak"},
  525. {0, NULL}
  526. };
  527. #define BAP_LINK_TYPE_ISDN 0 /* ISDN */
  528. #define BAP_LINK_TYPE_X25 1 /* X.25 */
  529. #define BAP_LINK_TYPE_ANALOG 2 /* Analog */
  530. #define BAP_LINK_TYPE_SD 3 /* Switched Digital (non-ISDN) */
  531. #define BAP_LINK_TYPE_ISDNOV 4 /* ISDN data over voice */
  532. #define BAP_LINK_TYPE_RESV5 5 /* Reserved */
  533. #define BAP_LINK_TYPE_RESV6 6 /* Reserved */
  534. #define BAP_LINK_TYPE_RESV7 7 /* Reserved */
  535. static const value_string bap_link_type_vals[] = {
  536. {BAP_LINK_TYPE_ISDN, "ISDN"},
  537. {BAP_LINK_TYPE_X25, "X.25"},
  538. {BAP_LINK_TYPE_ANALOG, "Analog"},
  539. {BAP_LINK_TYPE_SD, "Switched Digital (non-ISDN)"},
  540. {BAP_LINK_TYPE_ISDNOV, "ISDN data over voice"},
  541. {BAP_LINK_TYPE_RESV5, "Reserved"},
  542. {BAP_LINK_TYPE_RESV6, "Reserved"},
  543. {BAP_LINK_TYPE_RESV7, "Reserved"},
  544. {0, NULL}
  545. };
  546. #define BAP_PHONE_DELTA_SUBOPT_UNIQ_DIGIT 1 /* Unique Digit */
  547. #define BAP_PHONE_DELTA_SUBOPT_SUBSC_NUM 2 /* Subscriber Number */
  548. #define BAP_PHONE_DELTA_SUBOPT_PHONENUM_SUBADDR 3 /* Phone Number Sub Address */
  549. static const value_string bap_phone_delta_subopt_vals[] = {
  550. {BAP_PHONE_DELTA_SUBOPT_UNIQ_DIGIT, "Unique Digit"},
  551. {BAP_PHONE_DELTA_SUBOPT_SUBSC_NUM, "Subscriber Number"},
  552. {BAP_PHONE_DELTA_SUBOPT_PHONENUM_SUBADDR, "Phone Number Sub Address"},
  553. {0, NULL}
  554. };
  555. /*
  556. * Cause codes for Cause.
  557. *
  558. * The following code table is taken from packet-q931.c but is slightly
  559. * adapted to BAP protocol.
  560. */
  561. static const value_string q931_cause_code_vals[] = {
  562. {0x00, "Call successful"},
  563. {0x01, "Unallocated (unassigned) number"},
  564. {0x02, "No route to specified transit network"},
  565. {0x03, "No route to destination"},
  566. {0x04, "Send special information tone"},
  567. {0x05, "Misdialled trunk prefix"},
  568. {0x06, "Channel unacceptable"},
  569. {0x07, "Call awarded and being delivered in an established channel"},
  570. {0x08, "Prefix 0 dialed but not allowed"},
  571. {0x09, "Prefix 1 dialed but not allowed"},
  572. {0x0A, "Prefix 1 dialed but not required"},
  573. {0x0B, "More digits received than allowed, call is proceeding"},
  574. {0x10, "Normal call clearing"},
  575. {0x11, "User busy"},
  576. {0x12, "No user responding"},
  577. {0x13, "No answer from user (user alerted)"},
  578. {0x14, "Subscriber absent"},
  579. {0x15, "Call rejected"},
  580. {0x16, "Number changed"},
  581. {0x17, "Reverse charging rejected"},
  582. {0x18, "Call suspended"},
  583. {0x19, "Call resumed"},
  584. {0x1A, "Non-selected user clearing"},
  585. {0x1B, "Destination out of order"},
  586. {0x1C, "Invalid number format (incomplete number)"},
  587. {0x1D, "Facility rejected"},
  588. {0x1E, "Response to STATUS ENQUIRY"},
  589. {0x1F, "Normal unspecified"},
  590. {0x21, "Circuit out of order"},
  591. {0x22, "No circuit/channel available"},
  592. {0x23, "Destination unattainable"},
  593. {0x25, "Degraded service"},
  594. {0x26, "Network out of order"},
  595. {0x27, "Transit delay range cannot be achieved"},
  596. {0x28, "Throughput range cannot be achieved"},
  597. {0x29, "Temporary failure"},
  598. {0x2A, "Switching equipment congestion"},
  599. {0x2B, "Access information discarded"},
  600. {0x2C, "Requested circuit/channel not available"},
  601. {0x2D, "Pre-empted"},
  602. {0x2E, "Precedence call blocked"},
  603. {0x2F, "Resources unavailable, unspecified"},
  604. {0x31, "Quality of service unavailable"},
  605. {0x32, "Requested facility not subscribed"},
  606. {0x33, "Reverse charging not allowed"},
  607. {0x34, "Outgoing calls barred"},
  608. {0x35, "Outgoing calls barred within CUG"},
  609. {0x36, "Incoming calls barred"},
  610. {0x37, "Incoming calls barred within CUG"},
  611. {0x38, "Call waiting not subscribed"},
  612. {0x39, "Bearer capability not authorized"},
  613. {0x3A, "Bearer capability not presently available"},
  614. {0x3E, "Inconsistency in designated outgoing access information and subscriber class"},
  615. {0x3F, "Service or option not available, unspecified"},
  616. {0x41, "Bearer capability not implemented"},
  617. {0x42, "Channel type not implemented"},
  618. {0x43, "Transit network selection not implemented"},
  619. {0x44, "Message not implemented"},
  620. {0x45, "Requested facility not implemented"},
  621. {0x46, "Only restricted digital information bearer capability is available"},
  622. {0x4F, "Service or option not implemented, unspecified"},
  623. {0x51, "Invalid call reference value"},
  624. {0x52, "Identified channel does not exist"},
  625. {0x53, "Call identity does not exist for suspended call"},
  626. {0x54, "Call identity in use"},
  627. {0x55, "No call suspended"},
  628. {0x56, "Call having the requested call identity has been cleared"},
  629. {0x57, "Called user not member of CUG"},
  630. {0x58, "Incompatible destination"},
  631. {0x59, "Non-existent abbreviated address entry"},
  632. {0x5A, "Destination address missing, and direct call not subscribed"},
  633. {0x5B, "Invalid transit network selection (national use)"},
  634. {0x5C, "Invalid facility parameter"},
  635. {0x5D, "Mandatory information element is missing"},
  636. {0x5F, "Invalid message, unspecified"},
  637. {0x60, "Mandatory information element is missing"},
  638. {0x61, "Message type non-existent or not implemented"},
  639. {0x62, "Message not compatible with call state or message type non-existent or not implemented"},
  640. {0x63, "Information element non-existent or not implemented"},
  641. {0x64, "Invalid information element contents"},
  642. {0x65, "Message not compatible with call state"},
  643. {0x66, "Recovery on timer expiry"},
  644. {0x67, "Parameter non-existent or not implemented - passed on"},
  645. {0x6E, "Message with unrecognized parameter discarded"},
  646. {0x6F, "Protocol error, unspecified"},
  647. {0x7F, "Internetworking, unspecified"},
  648. {0xFF, "Non-specific failure"},
  649. {0, NULL}
  650. };
  651. static value_string_ext q931_cause_code_vals_ext = VALUE_STRING_EXT_INIT(q931_cause_code_vals);
  652. static const value_string bap_call_status_opt_action_vals[] = {
  653. {0, "No retry"},
  654. {1, "Retry"},
  655. {0, NULL}
  656. };
  657. #define STAC_CM_NONE 0
  658. #define STAC_CM_LCB 1
  659. #define STAC_CM_CRC 2
  660. #define STAC_CM_SN 3
  661. #define STAC_CM_EXTMODE 4
  662. static const value_string stac_checkmode_vals[] = {
  663. {STAC_CM_NONE, "None"},
  664. {STAC_CM_LCB, "LCB"},
  665. {STAC_CM_CRC, "CRC"},
  666. {STAC_CM_SN, "Sequence Number"},
  667. {STAC_CM_EXTMODE, "Extended Mode"},
  668. {0, NULL}
  669. };
  670. #define LZSDCP_CM_NONE 0
  671. #define LZSDCP_CM_LCB 1
  672. #define LZSDCP_CM_SN 2
  673. #define LZSDCP_CM_SN_LCB 3
  674. static const value_string lzsdcp_checkmode_vals[] = {
  675. {LZSDCP_CM_NONE, "None"},
  676. {LZSDCP_CM_LCB, "LCB"},
  677. {LZSDCP_CM_SN, "Sequence Number"},
  678. {LZSDCP_CM_SN_LCB, "Sequence Number + LCB (default)"},
  679. {0, NULL}
  680. };
  681. #define LZSDCP_PM_NONE 0
  682. #define LZSDCP_PM_PROC_UNCOMP 1
  683. static const value_string lzsdcp_processmode_vals[] = {
  684. {LZSDCP_PM_NONE, "None (default)"},
  685. {LZSDCP_PM_PROC_UNCOMP, "Process-Uncompressed"},
  686. {0, NULL}
  687. };
  688. #define DCE_MODE_1 1
  689. #define DCE_MODE_2 2
  690. static const value_string dce_mode_vals[] = {
  691. {DCE_MODE_1, "No Additional Negotiation"},
  692. {DCE_MODE_2, "Full PPP Negotiation and State Machine"},
  693. {0, NULL}
  694. };
  695. /*
  696. * Options. (LCP)
  697. */
  698. #define CI_VENDORSPECIFIC 0 /* Vendor Specific [RFC2153] */
  699. #define CI_MRU 1 /* Maximum Receive Unit [RFC1661] */
  700. #define CI_ASYNCMAP 2 /* Async Control Character Map */
  701. #define CI_AUTHPROT 3 /* Authentication Protocol [RFC1661] */
  702. #define CI_QUALITY 4 /* Quality Protocol [RFC1661] */
  703. #define CI_MAGICNUMBER 5 /* Magic Number [RFC1661] */
  704. #define CI_LINKQUALMON 6 /* DEPRECATED (Quality Protocol) [RFC1172] */
  705. #define CI_PCOMPRESSION 7 /* Protocol Field Compression [RFC1661] */
  706. #define CI_ACCOMPRESSION 8 /* Address/Control Field Compression
  707. [RFC1661] */
  708. #define CI_FCS_ALTERNATIVES 9 /* FCS Alternatives [RFC1570] */
  709. #define CI_SELF_DESCRIBING_PAD 10 /* Self-Describing Pad [RFC1570] */
  710. #define CI_NUMBERED_MODE 11 /* Numbered Mode [RFC1663] */
  711. #define CI_MULTILINK_PROC 12 /* DEPRECATED (Multi-Link Procedure) */
  712. #define CI_CALLBACK 13 /* Callback [RFC1570] */
  713. #define CI_CONNECTTIME 14 /* DEPRECATED (Connect Time) */
  714. #define CI_COMPOUND_FRAMES 15 /* DEPRECATED (Compound Frames) [RFC1570] */
  715. #define CI_NOMDATAENCAP 16 /* DEPRECATED (Nominal Data Encapsulation) */
  716. /* NOTE: IANA lists CI_NOMDATAENCAP as 16, but it is listed as 14 in
  717. * http://tools.ietf.org/html/draft-ietf-pppext-dataencap-03.
  718. * Which is correct is anyone's guess. */
  719. #define CI_MULTILINK_MRRU 17 /* Multilink MRRU [RFC1990] */
  720. #define CI_MULTILINK_SSNH 18 /* Multilink Short Sequence Number Header
  721. [RFC1990] */
  722. #define CI_MULTILINK_EP_DISC 19 /* Multilink Endpoint Discriminator
  723. [RFC1990] */
  724. #define CI_PROP_KEN 20 /* Proprietary [Ken Culbert] ken@funk.com */
  725. #define CI_DCE_IDENTIFIER 21 /* DCE Identifier [RFC1976]: Warning:
  726. Option type 25 in the RFC is incorrect */
  727. #define CI_MULTILINK_PLUS_PROC 22 /* Multilink Plus Procedure [RFC1934] */
  728. #define CI_LINK_DISC_FOR_BACP 23 /* Link Discriminator for BACP [RFC2125] */
  729. #define CI_LCP_AUTHENTICATION 24 /* LCP Authentication Option [Culbert] */
  730. #define CI_COBS 25 /* Consistent Overhead Byte Stuffing (COBS)
  731. [Carlson] */
  732. #define CI_PREFIX_ELISION 26 /* Prefix elision [RFC2686][RFC2687] */
  733. #define CI_MULTILINK_HDR_FMT 27 /* Multilink header format
  734. [RFC2686][RFC2687] */
  735. #define CI_INTERNATIONALIZATION 28 /* Internationalization [RFC2484] */
  736. #define CI_SDL_ON_SONET_SDH 29 /* Simple Data Link on SONET/SDH
  737. [RFC2823] */
  738. #define CI_UNASSIGNED 30 /* Unassigned ... but so are 31-255, so
  739. why do they bother specifically
  740. mentioning this one, I wonder? */
  741. static int hf_lcp_magic_number = -1;
  742. static int hf_lcp_data = -1;
  743. static int hf_lcp_message = -1;
  744. static int hf_lcp_secs_remaining = -1;
  745. static int hf_lcp_rej_proto = -1;
  746. static int hf_lcp_opt_type = -1;
  747. static int hf_lcp_opt_length = -1;
  748. static int hf_lcp_opt_oui = -1;
  749. static int hf_lcp_opt_kind = -1;
  750. static int hf_lcp_opt_data = -1;
  751. static int hf_lcp_opt_mru = -1;
  752. static int hf_lcp_opt_asyncmap = -1;
  753. static int hf_lcp_opt_asyncmap_nul = -1;
  754. static int hf_lcp_opt_asyncmap_soh = -1;
  755. static int hf_lcp_opt_asyncmap_stx = -1;
  756. static int hf_lcp_opt_asyncmap_etx = -1;
  757. static int hf_lcp_opt_asyncmap_eot = -1;
  758. static int hf_lcp_opt_asyncmap_enq = -1;
  759. static int hf_lcp_opt_asyncmap_ack = -1;
  760. static int hf_lcp_opt_asyncmap_bel = -1;
  761. static int hf_lcp_opt_asyncmap_bs = -1;
  762. static int hf_lcp_opt_asyncmap_ht = -1;
  763. static int hf_lcp_opt_asyncmap_lf = -1;
  764. static int hf_lcp_opt_asyncmap_vt = -1;
  765. static int hf_lcp_opt_asyncmap_ff = -1;
  766. static int hf_lcp_opt_asyncmap_cr = -1;
  767. static int hf_lcp_opt_asyncmap_so = -1;
  768. static int hf_lcp_opt_asyncmap_si = -1;
  769. static int hf_lcp_opt_asyncmap_dle = -1;
  770. static int hf_lcp_opt_asyncmap_dc1 = -1;
  771. static int hf_lcp_opt_asyncmap_dc2 = -1;
  772. static int hf_lcp_opt_asyncmap_dc3 = -1;
  773. static int hf_lcp_opt_asyncmap_dc4 = -1;
  774. static int hf_lcp_opt_asyncmap_nak = -1;
  775. static int hf_lcp_opt_asyncmap_syn = -1;
  776. static int hf_lcp_opt_asyncmap_etb = -1;
  777. static int hf_lcp_opt_asyncmap_can = -1;
  778. static int hf_lcp_opt_asyncmap_em = -1;
  779. static int hf_lcp_opt_asyncmap_sub = -1;
  780. static int hf_lcp_opt_asyncmap_esc = -1;
  781. static int hf_lcp_opt_asyncmap_fs = -1;
  782. static int hf_lcp_opt_asyncmap_gs = -1;
  783. static int hf_lcp_opt_asyncmap_rs = -1;
  784. static int hf_lcp_opt_asyncmap_us = -1;
  785. static int hf_lcp_opt_auth_protocol = -1;
  786. static int hf_lcp_opt_algorithm = -1;
  787. static int hf_lcp_opt_quality_protocol = -1;
  788. static int hf_lcp_opt_magic_number = -1;
  789. static int hf_lcp_opt_reportingperiod = -1;
  790. static int hf_lcp_opt_fcs_alternatives = -1;
  791. static int hf_lcp_opt_fcs_alternatives_null = -1;
  792. static int hf_lcp_opt_fcs_alternatives_ccitt16 = -1;
  793. static int hf_lcp_opt_fcs_alternatives_ccitt32 = -1;
  794. static int hf_lcp_opt_maximum = -1;
  795. static int hf_lcp_opt_window = -1;
  796. static int hf_lcp_opt_hdlc_address = -1;
  797. static int hf_lcp_opt_operation = -1;
  798. static int hf_lcp_opt_message = -1;
  799. static int hf_lcp_opt_mrru = -1;
  800. static int hf_lcp_opt_ep_disc_class = -1;
  801. static int hf_lcp_opt_ip_address = -1;
  802. static int hf_lcp_opt_802_1_address = -1;
  803. static int hf_lcp_opt_magic_block = -1;
  804. static int hf_lcp_opt_psndn = -1;
  805. static int hf_lcp_opt_mode = -1;
  806. static int hf_lcp_opt_unused = -1;
  807. static int hf_lcp_opt_link_discrim = -1;
  808. static int hf_lcp_opt_id = -1;
  809. static int hf_lcp_opt_cobs_flags = -1;
  810. static int hf_lcp_opt_cobs_flags_res = -1;
  811. static int hf_lcp_opt_cobs_flags_pre = -1;
  812. static int hf_lcp_opt_cobs_flags_zxe = -1;
  813. static int hf_lcp_opt_class = -1;
  814. static int hf_lcp_opt_prefix = -1;
  815. static int hf_lcp_opt_code = -1;
  816. static int hf_lcp_opt_max_susp_classes = -1;
  817. static int hf_lcp_opt_MIBenum = -1;
  818. static int hf_lcp_opt_language_tag = -1;
  819. static void dissect_lcp_vendor_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  820. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_);
  821. static void dissect_lcp_mru_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  822. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_);
  823. static void dissect_lcp_async_map_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  824. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_);
  825. static void dissect_lcp_authprot_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  826. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_);
  827. static void dissect_lcp_qualprot_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  828. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_);
  829. static void dissect_lcp_magicnumber_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  830. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_);
  831. static void dissect_lcp_linkqualmon_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  832. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_);
  833. static void dissect_lcp_simple_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  834. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_);
  835. static void dissect_lcp_fcs_alternatives_opt(const ip_tcp_opt *optp,
  836. tvbuff_t *tvb, int offset, guint length, packet_info *pinfo _U_,
  837. proto_tree *tree, void *data _U_);
  838. static void dissect_lcp_self_describing_pad_opt(const ip_tcp_opt *optp,
  839. tvbuff_t *tvb, int offset, guint length, packet_info *pinfo _U_,
  840. proto_tree *tree, void *data _U_);
  841. static void dissect_lcp_numbered_mode_opt(const ip_tcp_opt *optp,
  842. tvbuff_t *tvb, int offset, guint length, packet_info *pinfo _U_,
  843. proto_tree *tree, void *data _U_);
  844. static void dissect_lcp_callback_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  845. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_);
  846. static void dissect_lcp_multilink_mrru_opt(const ip_tcp_opt *optp,
  847. tvbuff_t *tvb, int offset, guint length, packet_info *pinfo _U_,
  848. proto_tree *tree, void *data _U_);
  849. static void dissect_lcp_multilink_ep_disc_opt(const ip_tcp_opt *optp,
  850. tvbuff_t *tvb, int offset, guint length, packet_info *pinfo _U_,
  851. proto_tree *tree, void *data _U_);
  852. static void dissect_lcp_dce_identifier_opt(const ip_tcp_opt *optp,
  853. tvbuff_t *tvb, int offset, guint length, packet_info *pinfo _U_,
  854. proto_tree *tree, void *data _U_);
  855. static void dissect_lcp_multilink_pp_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  856. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_);
  857. static void dissect_lcp_bacp_link_discriminator_opt(const ip_tcp_opt *optp,
  858. tvbuff_t *tvb, int offset, guint length, packet_info *pinfo _U_,
  859. proto_tree *tree, void *data _U_);
  860. static void dissect_lcp_auth_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  861. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_);
  862. static void dissect_lcp_cobs_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  863. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_);
  864. static void dissect_lcp_prefix_elision_opt(const ip_tcp_opt *optp,
  865. tvbuff_t *tvb, int offset, guint length, packet_info *pinfo _U_,
  866. proto_tree *tree, void *data _U_);
  867. static void dissect_lcp_multilink_hdr_fmt_opt(const ip_tcp_opt *optp,
  868. tvbuff_t *tvb, int offset, guint length, packet_info *pinfo _U_,
  869. proto_tree *tree, void *data _U_);
  870. static void dissect_lcp_internationalization_opt(const ip_tcp_opt *optp,
  871. tvbuff_t *tvb, int offset, guint length, packet_info *pinfo _U_,
  872. proto_tree *tree, void *data _U_);
  873. static void dissect_mp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
  874. static const ip_tcp_opt lcp_opts[] = {
  875. {CI_VENDORSPECIFIC, "Vendor Specific", &ett_lcp_vendor_opt,
  876. OPT_LEN_VARIABLE_LENGTH, 6, dissect_lcp_vendor_opt},
  877. {CI_MRU, "Maximum Receive Unit", &ett_lcp_mru_opt,
  878. OPT_LEN_FIXED_LENGTH, 4, dissect_lcp_mru_opt},
  879. {CI_ASYNCMAP, "Async Control Character Map", &ett_lcp_asyncmap_opt,
  880. OPT_LEN_FIXED_LENGTH, 6, dissect_lcp_async_map_opt},
  881. {CI_AUTHPROT, "Authentication Protocol", &ett_lcp_authprot_opt,
  882. OPT_LEN_VARIABLE_LENGTH, 4, dissect_lcp_authprot_opt},
  883. {CI_QUALITY, "Quality Protocol", &ett_lcp_qualprot_opt,
  884. OPT_LEN_VARIABLE_LENGTH, 4, dissect_lcp_qualprot_opt},
  885. {CI_MAGICNUMBER, "Magic Number", &ett_lcp_magicnumber_opt,
  886. OPT_LEN_FIXED_LENGTH, 6, dissect_lcp_magicnumber_opt},
  887. {CI_LINKQUALMON, "Link Quality Monitoring", &ett_lcp_linkqualmon_opt,
  888. OPT_LEN_FIXED_LENGTH, 6, dissect_lcp_linkqualmon_opt},
  889. {CI_PCOMPRESSION, "Protocol Field Compression", &ett_lcp_pcomp_opt,
  890. OPT_LEN_FIXED_LENGTH, 2, dissect_lcp_simple_opt},
  891. {CI_ACCOMPRESSION, "Address and Control Field Compression", &ett_lcp_acccomp_opt,
  892. OPT_LEN_FIXED_LENGTH, 2, dissect_lcp_simple_opt},
  893. {CI_FCS_ALTERNATIVES, "FCS Alternatives", &ett_lcp_fcs_alternatives_opt,
  894. OPT_LEN_FIXED_LENGTH, 3, dissect_lcp_fcs_alternatives_opt},
  895. {CI_SELF_DESCRIBING_PAD, "Self Describing Pad", &ett_lcp_self_desc_pad_opt,
  896. OPT_LEN_FIXED_LENGTH, 3, dissect_lcp_self_describing_pad_opt},
  897. {CI_NUMBERED_MODE, "Numbered Mode", &ett_lcp_numbered_mode_opt,
  898. OPT_LEN_VARIABLE_LENGTH, 4, dissect_lcp_numbered_mode_opt},
  899. /* TODO? CI_MULTILINK_PROC */
  900. {CI_CALLBACK, "Callback", &ett_lcp_callback_opt,
  901. OPT_LEN_VARIABLE_LENGTH, 3, dissect_lcp_callback_opt},
  902. /* TODO? CI_CONNECTTIME */
  903. {CI_COMPOUND_FRAMES, "Compound Frames (Deprecated)", &ett_lcp_compound_frames_opt,
  904. OPT_LEN_FIXED_LENGTH, 2, dissect_lcp_simple_opt},
  905. {CI_NOMDATAENCAP, "Nominal Data Encapsulation (Deprecated)", &ett_lcp_nomdataencap_opt,
  906. OPT_LEN_FIXED_LENGTH, 2, dissect_lcp_simple_opt},
  907. {CI_MULTILINK_MRRU, "Multilink MRRU", &ett_lcp_multilink_mrru_opt,
  908. OPT_LEN_FIXED_LENGTH, 4, dissect_lcp_multilink_mrru_opt},
  909. {CI_MULTILINK_SSNH, "Multilink Short Sequence Number Header", &ett_lcp_multilink_ssnh_opt,
  910. OPT_LEN_FIXED_LENGTH, 2, dissect_lcp_simple_opt},
  911. {CI_MULTILINK_EP_DISC, "Multilink Endpoint Discriminator", &ett_lcp_multilink_ep_disc_opt,
  912. OPT_LEN_VARIABLE_LENGTH, 3, dissect_lcp_multilink_ep_disc_opt},
  913. /* TODO? CI_PROP_KEN: ken@funk.com: www.funk.com => www.juniper.net */
  914. {CI_DCE_IDENTIFIER, "DCE Identifier", &ett_lcp_dce_identifier_opt,
  915. OPT_LEN_FIXED_LENGTH, 3, dissect_lcp_dce_identifier_opt},
  916. {CI_MULTILINK_PLUS_PROC, "Multi Link Plus Procedure", &ett_lcp_multilink_pp_opt,
  917. OPT_LEN_FIXED_LENGTH, 4, dissect_lcp_multilink_pp_opt},
  918. {CI_LINK_DISC_FOR_BACP, "Link Discriminator for BACP", &ett_lcp_bacp_link_discrim_opt,
  919. OPT_LEN_FIXED_LENGTH, 4, dissect_lcp_bacp_link_discriminator_opt},
  920. {CI_LCP_AUTHENTICATION, "LCP Authentication Option", &ett_lcp_auth_opt,
  921. OPT_LEN_VARIABLE_LENGTH, 3, dissect_lcp_auth_opt},
  922. {CI_COBS, "Consistent Overhead Byte Stuffing (COBS)", &ett_lcp_cobs_opt,
  923. OPT_LEN_FIXED_LENGTH, 3, dissect_lcp_cobs_opt},
  924. {CI_PREFIX_ELISION, "Prefix Elision", &ett_lcp_prefix_elision_opt,
  925. OPT_LEN_VARIABLE_LENGTH, 2, dissect_lcp_prefix_elision_opt},
  926. {CI_MULTILINK_HDR_FMT, "Multilink header format", &ett_multilink_hdr_fmt_opt,
  927. OPT_LEN_FIXED_LENGTH, 4, dissect_lcp_multilink_hdr_fmt_opt},
  928. {CI_INTERNATIONALIZATION, "Internationalization", &ett_lcp_internationalization_opt,
  929. OPT_LEN_VARIABLE_LENGTH, 7, dissect_lcp_internationalization_opt},
  930. {CI_SDL_ON_SONET_SDH, "Simple Data Link on SONET/SDH", &ett_lcp_simple_opt,
  931. OPT_LEN_FIXED_LENGTH, 2, dissect_lcp_simple_opt}
  932. /* TODO? CI_UNASSIGNED */
  933. };
  934. #define N_LCP_OPTS (sizeof lcp_opts / sizeof lcp_opts[0])
  935. /* 3GPP2 X.S0057-B v1.0
  936. * 9.1.4.1 3GPP2 VSNCP Configuration Options
  937. * Options. (VSNCP)
  938. */
  939. #define CI_PDN_IDENTIFIER 1
  940. #define CI_ACCESS_POINT_NM 2
  941. #define CI_PDN_TYPE 3
  942. #define CI_PDN_ADDRESS 4
  943. #define CI_PROTOCOL_CONFIG 5
  944. #define CI_ERROR_CODE 6
  945. #define CI_ATTACH_TYPE 7
  946. #define CI_IPv4DEFAULT_ROUTER 8
  947. #define CI_ADDRESS_ALLOC 9
  948. #define CI_APN_AMBR 10
  949. #define CI_IPv6_HSGW_LLA_IID 11
  950. static void dissect_vsncp_pdnid_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  951. int offset, guint length, packet_info *pinfo, proto_tree *tree, void *data _U_);
  952. static void dissect_vsncp_apname_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  953. int offset, guint length, packet_info *pinfo, proto_tree *tree, void *data _U_);
  954. static void dissect_vsncp_pdntype_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  955. int offset, guint length, packet_info *pinfo, proto_tree *tree, void *data _U_);
  956. static void dissect_vsncp_pdnaddress_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  957. int offset, guint length, packet_info *pinfo, proto_tree *tree, void *data _U_);
  958. static void dissect_vsncp_pco_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  959. int offset, guint length, packet_info *pinfo, proto_tree *tree, void *data _U_);
  960. static void dissect_vsncp_errorcode_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  961. int offset, guint length, packet_info *pinfo, proto_tree *tree, void *data _U_);
  962. static void dissect_vsncp_attachtype_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  963. int offset, guint length, packet_info *pinfo, proto_tree *tree, void *data _U_);
  964. static void dissect_vsncp_ipv4address_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  965. int offset, guint length, packet_info *pinfo, proto_tree *tree, void *data _U_);
  966. static void dissect_vsncp_addressalloc_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  967. int offset, guint length, packet_info *pinfo, proto_tree *tree, void *data _U_);
  968. static void dissect_vsncp_apn_ambr_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  969. int offset, guint length, packet_info *pinfo, proto_tree *tree, void *data _U_);
  970. static void dissect_vsncp_ipv6_hsgw_lla_iid_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  971. int offset, guint length, packet_info *pinfo, proto_tree *tree, void *data _U_);
  972. static const ip_tcp_opt vsncp_opts[] = {
  973. {CI_PDN_IDENTIFIER, "PDN Identifier", NULL,
  974. OPT_LEN_FIXED_LENGTH, 3, dissect_vsncp_pdnid_opt},
  975. {CI_ACCESS_POINT_NM, "Access Point Name", NULL,
  976. OPT_LEN_VARIABLE_LENGTH, 2, dissect_vsncp_apname_opt},
  977. {CI_PDN_TYPE, "PDN Type", NULL,
  978. OPT_LEN_FIXED_LENGTH, 3, dissect_vsncp_pdntype_opt},
  979. {CI_PDN_ADDRESS, "PDN Address", NULL,
  980. OPT_LEN_VARIABLE_LENGTH, 3, dissect_vsncp_pdnaddress_opt},
  981. {CI_PROTOCOL_CONFIG, "Protocol Configuration Options", NULL,
  982. OPT_LEN_VARIABLE_LENGTH, 3, dissect_vsncp_pco_opt},
  983. {CI_ERROR_CODE, "Error Code", NULL,
  984. OPT_LEN_FIXED_LENGTH, 3, dissect_vsncp_errorcode_opt},
  985. {CI_ATTACH_TYPE, "Attach Type", NULL,
  986. OPT_LEN_FIXED_LENGTH, 3, dissect_vsncp_attachtype_opt},
  987. {CI_IPv4DEFAULT_ROUTER, "IPv4 Default Router Address", NULL,
  988. OPT_LEN_FIXED_LENGTH, 6, dissect_vsncp_ipv4address_opt},
  989. {CI_ADDRESS_ALLOC, "Address Allocation Cause", NULL,
  990. OPT_LEN_FIXED_LENGTH, 3, dissect_vsncp_addressalloc_opt},
  991. {CI_APN_AMBR, "APN Aggregate Maximum Bit Rate(APN-AMBR)", NULL,
  992. OPT_LEN_VARIABLE_LENGTH, 4, dissect_vsncp_apn_ambr_opt},
  993. {CI_IPv6_HSGW_LLA_IID, "IPv6 HSGW Link Local Address IID", NULL,
  994. OPT_LEN_FIXED_LENGTH, 10, dissect_vsncp_ipv6_hsgw_lla_iid_opt}
  995. };
  996. #define N_VSNCP_OPTS (sizeof vsncp_opts / sizeof vsncp_opts[0])
  997. /*
  998. * CHAP Algorithms
  999. */
  1000. /* 0-4: Reserved */
  1001. #define CHAP_ALG_MD5 5 /* CHAP with MD5 */
  1002. #define CHAP_AGL_SHA1 6 /* CHAP with SHA-1 [Black] */
  1003. /* 7-127: Unassigned */
  1004. #define CHAP_ALG_MSV1 128 /* MS-CHAP */
  1005. #define CHAP_ALG_MSV2 129 /* MS-CHAP-2 */
  1006. static const range_string chap_alg_rvals[] = {
  1007. {0, 4, "Reserved"},
  1008. {CHAP_ALG_MD5, CHAP_ALG_MD5, "CHAP with MD5"},
  1009. {CHAP_AGL_SHA1, CHAP_AGL_SHA1, "CHAP with SHA-1"},
  1010. {CHAP_ALG_MSV1, CHAP_ALG_MSV1, "MS-CHAP"},
  1011. {CHAP_ALG_MSV2, CHAP_ALG_MSV2, "MS-CHAP-2"},
  1012. {0, 0, NULL}
  1013. };
  1014. /*
  1015. * Options. (IPCP)
  1016. * http://tools.ietf.org/html/rfc1172
  1017. * http://tools.ietf.org/html/rfc1332
  1018. * http://tools.ietf.org/html/rfc1877
  1019. * http://tools.ietf.org/html/rfc2290
  1020. * http://tools.ietf.org/html/rfc3241
  1021. * http://tools.ietf.org/html/rfc3545
  1022. */
  1023. #define CI_ADDRS 1 /* IP Addresses (deprecated) (RFC 1172) */
  1024. #define CI_COMPRESS_PROTO 2 /* Compression Protocol (RFC 1332) */
  1025. #define CI_ADDR 3 /* IP Address (RFC 1332) */
  1026. #define CI_MOBILE_IPv4 4 /* Mobile IPv4 (RFC 2290) */
  1027. #define CI_PRI_DNS 129 /* Primary DNS value (RFC 1877) */
  1028. #define CI_PRI_NBNS 130 /* Primary NBNS value (RFC 1877) */
  1029. #define CI_SEC_DNS 131 /* Secondary DNS value (RFC 1877) */
  1030. #define CI_SEC_NBNS 132 /* Secondary NBNS value (RFC 1877) */
  1031. static int hf_ipcp_opt_type = -1;
  1032. static int hf_ipcp_opt_length = -1;
  1033. static int hf_ipcp_opt_src_address = -1;
  1034. static int hf_ipcp_opt_dst_address = -1;
  1035. static int hf_ipcp_opt_compress_proto = -1;
  1036. static int hf_ipcp_opt_max_cid = -1;
  1037. static int hf_ipcp_opt_mrru = -1;
  1038. static int hf_ipcp_opt_max_slot_id = -1;
  1039. static int hf_ipcp_opt_comp_slot_id = -1;
  1040. static int hf_ipcp_opt_tcp_space = -1;
  1041. static int hf_ipcp_opt_non_tcp_space = -1;
  1042. static int hf_ipcp_opt_f_max_period = -1;
  1043. static int hf_ipcp_opt_f_max_time = -1;
  1044. static int hf_ipcp_opt_max_header = -1;
  1045. static int hf_ipcp_data = -1;
  1046. static int hf_ipcp_opt_ip_address = -1;
  1047. static int hf_ipcp_opt_mobilenodehomeaddr = -1;
  1048. static int hf_ipcp_opt_pri_dns_address = -1;
  1049. static int hf_ipcp_opt_pri_nbns_address = -1;
  1050. static int hf_ipcp_opt_sec_dns_address = -1;
  1051. static int hf_ipcp_opt_sec_nbns_address = -1;
  1052. static int hf_ipcp_opt_rohc_type = -1;
  1053. static int hf_ipcp_opt_rohc_length = -1;
  1054. static int hf_ipcp_opt_rohc_profile = -1;
  1055. static int hf_ipcp_opt_iphc_type = -1;
  1056. static int hf_ipcp_opt_iphc_length = -1;
  1057. static int hf_ipcp_opt_iphc_param = -1;
  1058. static void dissect_ipcp_addrs_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  1059. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_);
  1060. static void dissect_ipcp_compress_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  1061. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_);
  1062. static void dissect_ipcp_rohc_profiles_opt(const ip_tcp_opt *optp,
  1063. tvbuff_t *tvb, int offset, guint length, packet_info *pinfo _U_,
  1064. proto_tree *tree, void *data _U_);
  1065. static void dissect_ipcp_iphc_simple_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  1066. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_);
  1067. static void dissect_ipcp_iphc_neghdrcomp_opt(const ip_tcp_opt *optp,
  1068. tvbuff_t *tvb, int offset, guint length, packet_info *pinfo _U_,
  1069. proto_tree *tree, void *data _U_);
  1070. static void dissect_ipcp_addr_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  1071. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_);
  1072. static void dissect_ipcp_mobileipv4_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  1073. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_);
  1074. static void dissect_ipcp_pri_dns_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  1075. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_);
  1076. static void dissect_ipcp_pri_nbns_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  1077. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_);
  1078. static void dissect_ipcp_sec_dns_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  1079. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_);
  1080. static void dissect_ipcp_sec_nbns_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  1081. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_);
  1082. static const ip_tcp_opt ipcp_opts[] = {
  1083. {CI_ADDRS, "IP Addresses (deprecated)", &ett_ipcp_ipaddrs_opt,
  1084. OPT_LEN_FIXED_LENGTH, 10, dissect_ipcp_addrs_opt},
  1085. {CI_COMPRESS_PROTO, "IP Compression Protocol", &ett_ipcp_compress_opt,
  1086. OPT_LEN_VARIABLE_LENGTH, 4, dissect_ipcp_compress_opt},
  1087. {CI_ADDR, "IP address", &ett_ipcp_ipaddr_opt,
  1088. OPT_LEN_FIXED_LENGTH, 6, dissect_ipcp_addr_opt},
  1089. {CI_MOBILE_IPv4, "Mobile Node's Home IP Address", &ett_ipcp_mobileipv4_opt,
  1090. OPT_LEN_FIXED_LENGTH, 6, dissect_ipcp_mobileipv4_opt},
  1091. {CI_PRI_DNS, "Primary DNS Server IP Address", &ett_ipcp_pridns_opt,
  1092. OPT_LEN_FIXED_LENGTH, 6, dissect_ipcp_pri_dns_opt},
  1093. {CI_PRI_NBNS, "Primary NBNS Server IP Address", &ett_ipcp_prinbns_opt,
  1094. OPT_LEN_FIXED_LENGTH, 6, dissect_ipcp_pri_nbns_opt},
  1095. {CI_SEC_DNS, "Secondary DNS Server IP Address", &ett_ipcp_secdns_opt,
  1096. OPT_LEN_FIXED_LENGTH, 6, dissect_ipcp_sec_dns_opt},
  1097. {CI_SEC_NBNS, "Secondary NBNS Server IP Address", &ett_ipcp_secnbns_opt,
  1098. OPT_LEN_FIXED_LENGTH, 6, dissect_ipcp_sec_nbns_opt}
  1099. };
  1100. #define N_IPCP_OPTS (sizeof ipcp_opts / sizeof ipcp_opts[0])
  1101. /*
  1102. * IP Compression options
  1103. */
  1104. #define IPCP_ROHC 0x0003 /* RFC3241 */
  1105. #define IPCP_COMPRESS_VJ_1172 0x0037 /* value defined in RFC1172 (typo) */
  1106. #define IPCP_COMPRESS_VJ 0x002d /* value defined in RFC1332 (correct) */
  1107. #define IPCP_COMPRESS_IPHC 0x0061 /* RFC3544 (and RFC2509) */
  1108. static const value_string ipcp_compress_proto_vals[] = {
  1109. {IPCP_ROHC, "Robust Header Compression (ROHC)"},
  1110. {IPCP_COMPRESS_VJ, "VJ compression"},
  1111. {IPCP_COMPRESS_VJ_1172, "VJ compression (RFC1172-typo)"},
  1112. {IPCP_COMPRESS_IPHC, "IPHC compression"},
  1113. {0, NULL}
  1114. };
  1115. /* IPHC suboptions (RFC2508, 3544) */
  1116. #define IPCP_IPHC_CRTP 1
  1117. #define IPCP_IPHC_ECRTP 2
  1118. #define IPCP_IPHC_NEGHC 3
  1119. static const value_string ipcp_iphc_parameter_vals[] = {
  1120. {1, "The number of contexts for TCP Space is 0"},
  1121. {2, "The number of contexts for Non TCP Space is 0"},
  1122. {0, NULL}
  1123. };
  1124. static const ip_tcp_opt ipcp_iphc_subopts[] = {
  1125. {IPCP_IPHC_CRTP, "RTP compression (RFC2508)",
  1126. &ett_ipcp_iphc_rtp_compress_opt, OPT_LEN_FIXED_LENGTH, 2,
  1127. dissect_ipcp_iphc_simple_opt},
  1128. {IPCP_IPHC_ECRTP, "Enhanced RTP compression (RFC3545)",
  1129. &ett_ipcp_iphc_enhanced_rtp_compress_opt, OPT_LEN_FIXED_LENGTH, 2,
  1130. dissect_ipcp_iphc_simple_opt},
  1131. {IPCP_IPHC_NEGHC, "Negotiating header compression (RFC3545)",
  1132. &ett_ipcp_iphc_neghdrcomp_opt, OPT_LEN_FIXED_LENGTH, 3,
  1133. dissect_ipcp_iphc_neghdrcomp_opt}
  1134. };
  1135. #define N_IPCP_IPHC_SUBOPTS (sizeof ipcp_iphc_subopts / sizeof ipcp_iphc_subopts[0])
  1136. /* ROHC suboptions */
  1137. #define IPCP_ROHC_PROFILES 1
  1138. /* From http://tools.ietf.org/html/rfc3095 */
  1139. static const value_string ipcp_rohc_profile_vals[] = {
  1140. {0x0000, "ROHC uncompressed -- no compression"},
  1141. {0x0002, "ROHC UDP -- non-RTP UDP/IP compression"},
  1142. {0x0003, "ROHC ESP -- ESP/IP compression"},
  1143. {0, NULL}
  1144. };
  1145. static const ip_tcp_opt ipcp_rohc_subopts[] = {
  1146. {IPCP_ROHC_PROFILES, "Profiles (RFC3241)", &ett_ipcp_rohc_profiles_opt,
  1147. OPT_LEN_VARIABLE_LENGTH, 2, dissect_ipcp_rohc_profiles_opt}
  1148. };
  1149. #define N_IPCP_ROHC_SUBOPTS (sizeof ipcp_rohc_subopts / sizeof ipcp_rohc_subopts[0])
  1150. static ip_tcp_opt_type PPP_OPT_TYPES = {&hf_ppp_opt_type, &ett_ppp_opt_type,
  1151. &hf_ppp_opt_type_copy, &hf_ppp_opt_type_class, &hf_ppp_opt_type_number};
  1152. /*
  1153. * Options. (OSINLCP)
  1154. */
  1155. #define CI_OSINLCP_ALIGN_NPDU 1 /* Alignment of the OSI NPDU (RFC 1377) */
  1156. static int hf_osinlcp_opt_type = -1;
  1157. static int hf_osinlcp_opt_length = -1;
  1158. static int hf_osinlcp_opt_alignment = -1;
  1159. static void dissect_osinlcp_align_npdu_opt(const ip_tcp_opt *optp,
  1160. tvbuff_t *tvb, int offset, guint length, packet_info *pinfo,
  1161. proto_tree *tree, void *data _U_);
  1162. static const ip_tcp_opt osinlcp_opts[] = {
  1163. {CI_OSINLCP_ALIGN_NPDU, "Align-NPDU", &ett_osinlcp_align_npdu_opt,
  1164. OPT_LEN_FIXED_LENGTH, 3, dissect_osinlcp_align_npdu_opt}
  1165. };
  1166. #define N_OSINLCP_OPTS (sizeof osinlcp_opts / sizeof osinlcp_opts[0])
  1167. /*
  1168. * Options. (CCP)
  1169. */
  1170. #define CI_CCP_OUI 0 /* OUI (RFC1962) */
  1171. #define CI_CCP_PREDICT1 1 /* Predictor type 1 (RFC1962) */
  1172. #define CI_CCP_PREDICT2 2 /* Predictor type 2 (RFC1962) */
  1173. #define CI_CCP_PUDDLE 3 /* Puddle Jumper (RFC1962) */
  1174. #define CI_CCP_HPPPC 16 /* Hewlett-Packard PPC (RFC1962) */
  1175. #define CI_CCP_STAC 17 /* stac Electronics LZS (RFC1974) */
  1176. #define CI_CCP_MPPE 18 /* Microsoft PPE/C (RFC2118/3078) */
  1177. #define CI_CCP_GFZA 19 /* Gandalf FZA (RFC1962) */
  1178. #define CI_CCP_V42BIS 20 /* V.42bis compression */
  1179. #define CI_CCP_BSDLZW 21 /* BSD LZW Compress (RFC1977) */
  1180. #define CI_CCP_LZSDCP 23 /* LZS-DCP (RFC1967) */
  1181. #define CI_CCP_MVRCA 24 /* MVRCA (Magnalink) (RFC1975) */
  1182. #define CI_CCP_DCE 25 /* DCE (RFC1976) */
  1183. #define CI_CCP_DEFLATE 26 /* Deflate (RFC1979) */
  1184. #define CI_CCP_V44LZJH 27 /* V.44/LZJH (http://www.watersprings.org/pub/id/draft-heath-ppp-v44-01.txt) */
  1185. #define CI_CCP_RESERVED 255 /* Reserved (RFC1962) */
  1186. static int hf_ccp_opt_type = -1;
  1187. static int hf_ccp_opt_length = -1;
  1188. static int hf_ccp_opt_oui = -1;
  1189. static int hf_ccp_opt_subtype = -1;
  1190. static int hf_ccp_opt_data = -1;
  1191. static int hf_ccp_opt_history_count = -1;
  1192. static int hf_ccp_opt_cm = -1;
  1193. static int hf_ccp_opt_cm_reserved = -1;
  1194. static int hf_ccp_opt_cm_check_mode = -1;
  1195. static int hf_ccp_opt_supported_bits = -1;
  1196. static int hf_ccp_opt_supported_bits_h = -1;
  1197. static int hf_ccp_opt_supported_bits_m = -1;
  1198. static int hf_ccp_opt_supported_bits_s = -1;
  1199. static int hf_ccp_opt_supported_bits_l = -1;
  1200. static int hf_ccp_opt_supported_bits_d = -1;
  1201. static int hf_ccp_opt_supported_bits_c = -1;
  1202. static int hf_ccp_opt_history = -1;
  1203. static int hf_ccp_opt_version = -1;
  1204. static int hf_ccp_opt_vd = -1;
  1205. static int hf_ccp_opt_vd_vers = -1;
  1206. static int hf_ccp_opt_vd_dict = -1;
  1207. static int hf_ccp_opt_check_mode = -1;
  1208. static int hf_ccp_opt_process_mode = -1;
  1209. static int hf_ccp_opt_fe = -1;
  1210. static int hf_ccp_opt_p = -1;
  1211. static int hf_ccp_opt_History = -1; /* Different than hf_ccp_opt_history */
  1212. static int hf_ccp_opt_contexts = -1;
  1213. static int hf_ccp_opt_mode = -1;
  1214. static int hf_ccp_opt_window = -1;
  1215. static int hf_ccp_opt_method = -1;
  1216. static int hf_ccp_opt_mbz = -1;
  1217. static int hf_ccp_opt_chk = -1;
  1218. static int hf_ccp_opt_mode_dictcount = -1;
  1219. static int hf_ccp_opt_dict_size = -1;
  1220. static int hf_ccp_opt_history_length = -1;
  1221. static void dissect_ccp_oui_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  1222. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_);
  1223. static void dissect_ccp_other_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  1224. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_);
  1225. #define dissect_ccp_predict1_opt dissect_ccp_other_opt
  1226. #define dissect_ccp_predict2_opt dissect_ccp_other_opt
  1227. #define dissect_ccp_puddle_opt dissect_ccp_other_opt
  1228. #define dissect_ccp_hpppc_opt dissect_ccp_other_opt
  1229. static void dissect_ccp_stac_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  1230. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_);
  1231. static void dissect_ccp_mppe_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  1232. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_);
  1233. static void dissect_ccp_gfza_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  1234. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_);
  1235. #define dissect_ccp_v42bis_opt dissect_ccp_other_opt
  1236. static void dissect_ccp_bsdcomp_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  1237. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_);
  1238. static void dissect_ccp_lzsdcp_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  1239. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_);
  1240. static void dissect_ccp_mvrca_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  1241. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_);
  1242. static void dissect_ccp_dce_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  1243. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_);
  1244. static void dissect_ccp_deflate_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  1245. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_);
  1246. static void dissect_ccp_v44lzjh_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  1247. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_);
  1248. static const ip_tcp_opt ccp_opts[] = {
  1249. {CI_CCP_OUI, "OUI", &ett_ccp_oui_opt,
  1250. OPT_LEN_VARIABLE_LENGTH, 6, dissect_ccp_oui_opt},
  1251. {CI_CCP_PREDICT1, "Predictor type 1", &ett_ccp_predict1_opt,
  1252. OPT_LEN_VARIABLE_LENGTH, 2, dissect_ccp_predict1_opt},
  1253. {CI_CCP_PREDICT2, "Predictor type 2", &ett_ccp_predict2_opt,
  1254. OPT_LEN_VARIABLE_LENGTH, 2, dissect_ccp_predict2_opt},
  1255. {CI_CCP_PUDDLE, "Puddle Jumper", &ett_ccp_puddle_opt,
  1256. OPT_LEN_VARIABLE_LENGTH, 2, dissect_ccp_puddle_opt},
  1257. {CI_CCP_HPPPC, "Hewlett-Packard PPC", &ett_ccp_hpppc_opt,
  1258. OPT_LEN_VARIABLE_LENGTH, 2, dissect_ccp_hpppc_opt},
  1259. {CI_CCP_STAC, "Stac Electronics LZS", &ett_ccp_stac_opt,
  1260. /* In RFC 1974, this is a fixed-length field of size 5, but in
  1261. * Ascend Proprietary STAC compression this field is 6 octets. */
  1262. OPT_LEN_VARIABLE_LENGTH, 5, dissect_ccp_stac_opt},
  1263. {CI_CCP_MPPE, "Microsoft PPE/PPC", &ett_ccp_mppe_opt,
  1264. OPT_LEN_FIXED_LENGTH, 6, dissect_ccp_mppe_opt},
  1265. {CI_CCP_GFZA, "Gandalf FZA", &ett_ccp_gfza_opt,
  1266. OPT_LEN_VARIABLE_LENGTH, 3, dissect_ccp_gfza_opt},
  1267. {CI_CCP_V42BIS, "V.42bis compression", &ett_ccp_v42bis_opt,
  1268. OPT_LEN_VARIABLE_LENGTH, 2, dissect_ccp_v42bis_opt},
  1269. {CI_CCP_BSDLZW, "BSD LZW Compress", &ett_ccp_bsdcomp_opt,
  1270. OPT_LEN_FIXED_LENGTH, 3, dissect_ccp_bsdcomp_opt},
  1271. {CI_CCP_LZSDCP, "LZS-DCP", &ett_ccp_lzsdcp_opt,
  1272. OPT_LEN_FIXED_LENGTH, 6, dissect_ccp_lzsdcp_opt},
  1273. {CI_CCP_MVRCA, "MVRCA (Magnalink)", &ett_ccp_mvrca_opt,
  1274. OPT_LEN_FIXED_LENGTH, 4, dissect_ccp_mvrca_opt},
  1275. {CI_CCP_DCE,
  1276. "PPP for Data Compression in Data Circuit-Terminating Equipment (DCE)",
  1277. &ett_ccp_dce_opt,
  1278. OPT_LEN_FIXED_LENGTH, 3, dissect_ccp_dce_opt},
  1279. {CI_CCP_DEFLATE, "Deflate", &ett_ccp_deflate_opt,
  1280. /* RFC1979 says the length is 3 but it's actually 4. */
  1281. OPT_LEN_FIXED_LENGTH, 4, dissect_ccp_deflate_opt},
  1282. {CI_CCP_V44LZJH, "V.44/LZJH compression", &ett_ccp_v44lzjh_opt,
  1283. OPT_LEN_VARIABLE_LENGTH, 4, dissect_ccp_v44lzjh_opt}
  1284. };
  1285. #define N_CCP_OPTS (sizeof ccp_opts / sizeof ccp_opts[0])
  1286. /*
  1287. * Options. (CBCP)
  1288. */
  1289. #define CI_CBCP_NO_CALLBACK 1 /* No callback */
  1290. #define CI_CBCP_CB_USER 2 /* Callback to a user-specified number */
  1291. #define CI_CBCP_CB_PRE 3 /* Callback to a pre-specified or
  1292. administrator specified number */
  1293. #define CI_CBCP_CB_ANY 4 /* Callback to any of a list of numbers */
  1294. static void dissect_cbcp_no_callback_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  1295. int offset, guint length, packet_info *pinfo, proto_tree *tree, void *data _U_);
  1296. static void dissect_cbcp_callback_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  1297. int offset, guint length, packet_info *pinfo, proto_tree *tree, void *data _U_);
  1298. static const ip_tcp_opt cbcp_opts[] = {
  1299. {CI_CBCP_NO_CALLBACK, "No callback", NULL,
  1300. OPT_LEN_FIXED_LENGTH, 2, dissect_cbcp_no_callback_opt},
  1301. {CI_CBCP_CB_USER, "Callback to a user-specified number", &ett_cbcp_callback_opt,
  1302. OPT_LEN_VARIABLE_LENGTH, 4, dissect_cbcp_callback_opt},
  1303. {CI_CBCP_CB_PRE, "Callback to a pre-specified or admin-specified number", &ett_cbcp_callback_opt,
  1304. OPT_LEN_FIXED_LENGTH, 3, dissect_cbcp_callback_opt},
  1305. {CI_CBCP_CB_ANY, "Callback to any of a list of numbers", &ett_cbcp_callback_opt,
  1306. OPT_LEN_VARIABLE_LENGTH, 4, dissect_cbcp_callback_opt}
  1307. };
  1308. #define N_CBCP_OPTS (sizeof cbcp_opts / sizeof cbcp_opts[0])
  1309. /*
  1310. * Options. (BACP)
  1311. */
  1312. #define CI_BACP_FAVORED_PEER 1 /* Favored-Peer */
  1313. static void dissect_bacp_favored_peer_opt(const ip_tcp_opt *optp,
  1314. tvbuff_t *tvb, int offset, guint length, packet_info *pinfo,
  1315. proto_tree *tree, void *data _U_);
  1316. static const ip_tcp_opt bacp_opts[] = {
  1317. {CI_BACP_FAVORED_PEER, "Favored-Peer", &ett_bacp_favored_peer_opt,
  1318. OPT_LEN_FIXED_LENGTH, 6, dissect_bacp_favored_peer_opt}
  1319. };
  1320. #define N_BACP_OPTS (sizeof bacp_opts / sizeof bacp_opts[0])
  1321. /*
  1322. * Options. (BAP)
  1323. */
  1324. #define CI_BAP_LINK_TYPE 1 /* Link Type */
  1325. #define CI_BAP_PHONE_DELTA 2 /* Phone-Delta */
  1326. #define CI_BAP_NO_PHONE_NUM_NEEDED 3 /* No Phone Number Needed */
  1327. #define CI_BAP_REASON 4 /* Reason */
  1328. #define CI_BAP_LINK_DISC 5 /* Link Discriminator */
  1329. #define CI_BAP_CALL_STATUS 6 /* Call Status */
  1330. static void dissect_bap_link_type_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  1331. int offset, guint length, packet_info *pinfo, proto_tree *tree, void *data _U_);
  1332. static void dissect_bap_phone_delta_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  1333. int offset, guint length, packet_info *pinfo, proto_tree *tree, void *data _U_);
  1334. static void dissect_bap_link_disc_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  1335. int offset, guint length, packet_info *pinfo, proto_tree *tree, void *data _U_);
  1336. static void dissect_bap_reason_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  1337. int offset, guint length, packet_info *pinfo, proto_tree *tree, void *data _U_);
  1338. static void dissect_bap_call_status_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  1339. int offset, guint length, packet_info *pinfo, proto_tree *tree, void *data _U_);
  1340. static const ip_tcp_opt bap_opts[] = {
  1341. {CI_BAP_LINK_TYPE, "Link Type", &ett_bap_link_type_opt,
  1342. OPT_LEN_FIXED_LENGTH, 5, dissect_bap_link_type_opt},
  1343. {CI_BAP_PHONE_DELTA, "Phone Delta", &ett_bap_phone_delta_opt,
  1344. OPT_LEN_VARIABLE_LENGTH, 4, dissect_bap_phone_delta_opt},
  1345. {CI_BAP_NO_PHONE_NUM_NEEDED, "No Phone Number Needed", NULL,
  1346. OPT_LEN_FIXED_LENGTH, 2, NULL},
  1347. {CI_BAP_REASON, "Reason", NULL,
  1348. OPT_LEN_VARIABLE_LENGTH, 2, dissect_bap_reason_opt},
  1349. {CI_BAP_LINK_DISC, "Link Discriminator", NULL,
  1350. OPT_LEN_FIXED_LENGTH, 4, dissect_bap_link_disc_opt},
  1351. {CI_BAP_CALL_STATUS, "Call Status", &ett_bap_call_status_opt,
  1352. OPT_LEN_FIXED_LENGTH, 4, dissect_bap_call_status_opt}
  1353. };
  1354. #define N_BAP_OPTS (sizeof bap_opts / sizeof bap_opts[0])
  1355. static void dissect_ppp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
  1356. static const value_string pap_vals[] = {
  1357. {CONFREQ, "Authenticate-Request"},
  1358. {CONFACK, "Authenticate-Ack"},
  1359. {CONFNAK, "Authenticate-Nak"},
  1360. {0, NULL}
  1361. };
  1362. static void dissect_pap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
  1363. #define CHAP_CHAL 1 /* CHAP Challenge */
  1364. #define CHAP_RESP 2 /* CHAP Response */
  1365. #define CHAP_SUCC 3 /* CHAP Success */
  1366. #define CHAP_FAIL 4 /* CHAP Failure */
  1367. static const value_string chap_vals[] = {
  1368. {CHAP_CHAL, "Challenge"},
  1369. {CHAP_RESP, "Response"},
  1370. {CHAP_SUCC, "Success"},
  1371. {CHAP_FAIL, "Failure"},
  1372. {0, NULL}
  1373. };
  1374. static void dissect_chap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
  1375. static const value_string pppmuxcp_vals[] = {
  1376. {CONFREQ, "Configuration Request"},
  1377. {CONFACK, "Configuration Ack"},
  1378. {0, NULL}
  1379. };
  1380. /*
  1381. * PPPMuxCP options
  1382. */
  1383. #define CI_DEFAULT_PID 1
  1384. static void dissect_pppmuxcp_def_pid_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  1385. int offset, guint length, packet_info *pinfo, proto_tree *tree, void *data _U_);
  1386. static const ip_tcp_opt pppmuxcp_opts[] = {
  1387. {CI_DEFAULT_PID, "Default Protocol ID", NULL,
  1388. OPT_LEN_FIXED_LENGTH, 4, dissect_pppmuxcp_def_pid_opt}
  1389. };
  1390. static const true_false_string tfs_pppmux_length_field = { "2 bytes", "1 byte" };
  1391. #define N_PPPMUXCP_OPTS (sizeof pppmuxcp_opts / sizeof pppmuxcp_opts[0])
  1392. /*
  1393. * Options. (IPv6CP)
  1394. */
  1395. #define CI_IPV6CP_IF_ID 1 /* Interface Identifier (RFC 2472) */
  1396. #define CI_IPV6CP_COMPRESSTYPE 2 /* Compression Type (RFC 2472) */
  1397. static void dissect_ipv6cp_if_id_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  1398. int offset, guint length, packet_info *pinfo, proto_tree *tree, void *data _U_);
  1399. static const ip_tcp_opt ipv6cp_opts[] = {
  1400. {CI_IPV6CP_IF_ID, "Interface Identifier", &ett_ipv6cp_if_id_opt,
  1401. OPT_LEN_FIXED_LENGTH, 10, dissect_ipv6cp_if_id_opt},
  1402. {CI_COMPRESS_PROTO, "IPv6 compression", &ett_ipv6cp_compress_opt,
  1403. OPT_LEN_VARIABLE_LENGTH, 4, dissect_ipcp_compress_opt}
  1404. };
  1405. #define N_IPV6CP_OPTS (sizeof ipv6cp_opts / sizeof ipv6cp_opts[0])
  1406. /*
  1407. *******************************************************************************
  1408. * DETAILS : Calculate a new FCS-16 given the current FCS-16 and the new data.
  1409. *******************************************************************************
  1410. */
  1411. static guint16
  1412. fcs16(tvbuff_t *tvbuff)
  1413. {
  1414. guint len = tvb_length(tvbuff) - 2;
  1415. /* Check for Invalid Length */
  1416. if (len == 0)
  1417. return (0x0000);
  1418. return crc16_ccitt_tvb(tvbuff, len);
  1419. }
  1420. /*
  1421. *******************************************************************************
  1422. * DETAILS : Calculate a new FCS-32 given the current FCS-32 and the new data.
  1423. *******************************************************************************
  1424. */
  1425. static guint32
  1426. fcs32(tvbuff_t *tvbuff)
  1427. {
  1428. guint len = tvb_length(tvbuff) - 4;
  1429. /* Check for invalid Length */
  1430. if (len == 0)
  1431. return (0x00000000);
  1432. return crc32_ccitt_tvb(tvbuff, len);
  1433. }
  1434. tvbuff_t *
  1435. decode_fcs(tvbuff_t *tvb, proto_tree *fh_tree, int fcs_decode, int proto_offset)
  1436. {
  1437. tvbuff_t *next_tvb;
  1438. gint len, reported_len;
  1439. int rx_fcs_offset;
  1440. guint32 rx_fcs_exp;
  1441. guint32 rx_fcs_got;
  1442. /*
  1443. * Remove the FCS, if any, from the packet data.
  1444. */
  1445. switch (fcs_decode) {
  1446. case NO_FCS:
  1447. next_tvb = tvb_new_subset_remaining(tvb, proto_offset);
  1448. break;
  1449. case FCS_16:
  1450. /*
  1451. * Do we have the entire packet, and does it include a 2-byte FCS?
  1452. */
  1453. len = tvb_length_remaining(tvb, proto_offset);
  1454. reported_len = tvb_reported_length_remaining(tvb, proto_offset);
  1455. if (reported_len < 2 || len < 0) {
  1456. /*
  1457. * The packet is claimed not to even have enough data for a 2-byte
  1458. * FCS, or we're already past the end of the captured data.
  1459. * Don't slice anything off.
  1460. */
  1461. next_tvb = tvb_new_subset_remaining(tvb, proto_offset);
  1462. } else if (len < reported_len) {
  1463. /*
  1464. * The packet is claimed to have enough data for a 2-byte FCS, but
  1465. * we didn't capture all of the packet.
  1466. * Slice off the 2-byte FCS from the reported length, and trim the
  1467. * captured length so it's no more than the reported length; that
  1468. * will slice off what of the FCS, if any, is in the captured
  1469. * length.
  1470. */
  1471. reported_len -= 2;
  1472. if (len > reported_len)
  1473. len = reported_len;
  1474. next_tvb = tvb_new_subset(tvb, proto_offset, len, reported_len);
  1475. } else {
  1476. /*
  1477. * We have the entire packet, and it includes a 2-byte FCS.
  1478. * Slice it off.
  1479. */
  1480. len -= 2;
  1481. reported_len -= 2;
  1482. next_tvb = tvb_new_subset(tvb, proto_offset, len, reported_len);
  1483. /*
  1484. * Compute the FCS and put it into the tree.
  1485. */
  1486. rx_fcs_offset = proto_offset + len;
  1487. rx_fcs_exp = fcs16(tvb);
  1488. rx_fcs_got = tvb_get_letohs(tvb, rx_fcs_offset);
  1489. if (rx_fcs_got != rx_fcs_exp) {
  1490. proto_tree_add_text(fh_tree, tvb, rx_fcs_offset, 2,
  1491. "FCS 16: 0x%04x [incorrect, should be 0x%04x]",
  1492. rx_fcs_got, rx_fcs_exp);
  1493. } else {
  1494. proto_tree_add_text(fh_tree, tvb, rx_fcs_offset, 2,
  1495. "FCS 16: 0x%04x [correct]", rx_fcs_got);
  1496. }
  1497. }
  1498. break;
  1499. case FCS_32:
  1500. /*
  1501. * Do we have the entire packet, and does it include a 4-byte FCS?
  1502. */
  1503. len = tvb_length_remaining(tvb, proto_offset);
  1504. reported_len = tvb_reported_length_remaining(tvb, proto_offset);
  1505. if (reported_len < 4) {
  1506. /*
  1507. * The packet is claimed not to even have enough data for a 4-byte
  1508. * FCS. Just pass on the tvbuff as is.
  1509. */
  1510. next_tvb = tvb_new_subset_remaining(tvb, proto_offset);
  1511. } else if (len < reported_len) {
  1512. /*
  1513. * The packet is claimed to have enough data for a 4-byte FCS, but
  1514. * we didn't capture all of the packet.
  1515. * Slice off the 4-byte FCS from the reported length, and trim the
  1516. * captured length so it's no more than the reported length; that
  1517. * will slice off what of the FCS, if any, is in the captured
  1518. * length.
  1519. */
  1520. reported_len -= 4;
  1521. if (len > reported_len)
  1522. len = reported_len;
  1523. next_tvb = tvb_new_subset(tvb, proto_offset, len, reported_len);
  1524. } else {
  1525. /*
  1526. * We have the entire packet, and it includes a 4-byte FCS.
  1527. * Slice it off.
  1528. */
  1529. len -= 4;
  1530. reported_len -= 4;
  1531. next_tvb = tvb_new_subset(tvb, proto_offset, len, reported_len);
  1532. /*
  1533. * Compute the FCS and put it into the tree.
  1534. */
  1535. rx_fcs_offset = proto_offset + len;
  1536. rx_fcs_exp = fcs32(tvb);
  1537. rx_fcs_got = tvb_get_letohl(tvb, rx_fcs_offset);
  1538. if (rx_fcs_got != rx_fcs_exp) {
  1539. proto_tree_add_text(fh_tree, tvb, rx_fcs_offset, 4,
  1540. "FCS 32: 0x%08x [incorrect, should be 0x%08x]",
  1541. rx_fcs_got, rx_fcs_exp);
  1542. } else {
  1543. proto_tree_add_text(fh_tree, tvb, rx_fcs_offset, 4,
  1544. "FCS 32: 0x%08x [correct]", rx_fcs_got);
  1545. }
  1546. }
  1547. break;
  1548. default:
  1549. DISSECTOR_ASSERT_NOT_REACHED();
  1550. next_tvb = NULL;
  1551. break;
  1552. }
  1553. return next_tvb;
  1554. }
  1555. void
  1556. capture_ppp_hdlc(const guchar *pd, int offset, int len, packet_counts *ld)
  1557. {
  1558. if (!BYTES_ARE_IN_FRAME(offset, len, 2)) {
  1559. ld->other++;
  1560. return;
  1561. }
  1562. if (pd[0] == CHDLC_ADDR_UNICAST || pd[0] == CHDLC_ADDR_MULTICAST) {
  1563. capture_chdlc(pd, offset, len, ld);
  1564. return;
  1565. }
  1566. if (!BYTES_ARE_IN_FRAME(offset, len, 4)) {
  1567. ld->other++;
  1568. return;
  1569. }
  1570. switch (pntohs(&pd[offset + 2])) {
  1571. case PPP_IP:
  1572. capture_ip(pd, offset + 4, len, ld);
  1573. break;
  1574. case PPP_IPX:
  1575. capture_ipx(ld);
  1576. break;
  1577. case PPP_VINES:
  1578. capture_vines(ld);
  1579. break;
  1580. default:
  1581. ld->other++;
  1582. break;
  1583. }
  1584. }
  1585. static void
  1586. dissect_lcp_opt_type_len(tvbuff_t *tvb, int offset, proto_tree *tree,
  1587. const char *name)
  1588. {
  1589. guint8 type;
  1590. type = tvb_get_guint8(tvb, offset);
  1591. proto_tree_add_uint_format_value(tree, hf_lcp_opt_type, tvb, offset, 1,
  1592. type, "%s (%u)", name, type);
  1593. proto_tree_add_item(tree, hf_lcp_opt_length, tvb, offset + 1, 1, ENC_NA);
  1594. }
  1595. static void
  1596. dissect_lcp_vendor_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  1597. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  1598. {
  1599. proto_tree *field_tree;
  1600. proto_item *tf, *ti;
  1601. guint32 oui;
  1602. const gchar *manuf;
  1603. oui = tvb_get_ntoh24(tvb, offset + 2);
  1604. tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
  1605. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  1606. dissect_lcp_opt_type_len(tvb, offset, field_tree, optp->name);
  1607. ti = proto_tree_add_uint_format_value(field_tree, hf_lcp_opt_oui, tvb,
  1608. offset + 2, 3, oui, "%02x:%02x:%02x",
  1609. (oui >> 16) & 0xff, (oui >> 8) & 0xff, oui & 0xff);
  1610. manuf = uint_get_manuf_name_if_known(oui);
  1611. if (manuf)
  1612. proto_item_append_text(ti, "(%s)", manuf);
  1613. proto_tree_add_item(field_tree, hf_lcp_opt_kind, tvb, offset + 5, 1,
  1614. ENC_NA);
  1615. if (length > 6) {
  1616. proto_tree_add_item(field_tree, hf_lcp_opt_data, tvb, offset + 6,
  1617. length - 6, ENC_NA);
  1618. }
  1619. }
  1620. static void
  1621. dissect_lcp_mru_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  1622. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  1623. {
  1624. proto_tree *field_tree;
  1625. proto_item *tf;
  1626. tf = proto_tree_add_text(tree, tvb, offset, length, "%s: %u", optp->name,
  1627. tvb_get_ntohs(tvb, offset + 2));
  1628. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  1629. dissect_lcp_opt_type_len(tvb, offset, field_tree, optp->name);
  1630. proto_tree_add_item(field_tree, hf_lcp_opt_mru, tvb, offset + 2, 2,
  1631. ENC_BIG_ENDIAN);
  1632. }
  1633. static void
  1634. dissect_lcp_async_map_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  1635. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  1636. {
  1637. proto_tree *field_tree;
  1638. proto_item *tf, *ti;
  1639. static const int *asyncmap_fields[] = {
  1640. &hf_lcp_opt_asyncmap_us, &hf_lcp_opt_asyncmap_rs,
  1641. &hf_lcp_opt_asyncmap_gs, &hf_lcp_opt_asyncmap_fs,
  1642. &hf_lcp_opt_asyncmap_esc, &hf_lcp_opt_asyncmap_sub,
  1643. &hf_lcp_opt_asyncmap_em, &hf_lcp_opt_asyncmap_can,
  1644. &hf_lcp_opt_asyncmap_etb, &hf_lcp_opt_asyncmap_syn,
  1645. &hf_lcp_opt_asyncmap_nak, &hf_lcp_opt_asyncmap_dc4,
  1646. &hf_lcp_opt_asyncmap_dc3, &hf_lcp_opt_asyncmap_dc2,
  1647. &hf_lcp_opt_asyncmap_dc1, &hf_lcp_opt_asyncmap_dle,
  1648. &hf_lcp_opt_asyncmap_si, &hf_lcp_opt_asyncmap_so,
  1649. &hf_lcp_opt_asyncmap_cr, &hf_lcp_opt_asyncmap_ff,
  1650. &hf_lcp_opt_asyncmap_vt, &hf_lcp_opt_asyncmap_lf,
  1651. &hf_lcp_opt_asyncmap_ht, &hf_lcp_opt_asyncmap_bs,
  1652. &hf_lcp_opt_asyncmap_bel, &hf_lcp_opt_asyncmap_ack,
  1653. &hf_lcp_opt_asyncmap_enq, &hf_lcp_opt_asyncmap_eot,
  1654. &hf_lcp_opt_asyncmap_etx, &hf_lcp_opt_asyncmap_stx,
  1655. &hf_lcp_opt_asyncmap_soh, &hf_lcp_opt_asyncmap_nul,
  1656. NULL
  1657. };
  1658. static const char *ctrlchars[32] = {
  1659. "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL",
  1660. "BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI",
  1661. "DLE", "DC1 (XON)", "DC2", "DC3 (XOFF)", "DC4", "NAK", "SYN", "ETB",
  1662. "CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US"
  1663. };
  1664. gboolean anyctrlchars;
  1665. guint32 map;
  1666. int i;
  1667. map = tvb_get_ntohl(tvb, offset + 2);
  1668. tf = proto_tree_add_text(tree, tvb, offset, length, "%s: 0x%08x (",
  1669. optp->name, map);
  1670. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  1671. dissect_lcp_opt_type_len(tvb, offset, field_tree, optp->name);
  1672. ti = proto_tree_add_bitmask(field_tree, tvb, offset + 2,
  1673. hf_lcp_opt_asyncmap, *optp->subtree_index, asyncmap_fields,
  1674. ENC_BIG_ENDIAN);
  1675. if (map == 0x00000000) {
  1676. proto_item_append_text(tf, "None)");
  1677. proto_item_append_text(ti, " (None)");
  1678. } else if (map == 0xffffffff) {
  1679. proto_item_append_text(tf, "All)");
  1680. proto_item_append_text(ti, " (All)");
  1681. } else {
  1682. for (anyctrlchars = FALSE, i = 31; i >= 0; i--) {
  1683. if (map & (1 << i)) {
  1684. if (anyctrlchars)
  1685. proto_item_append_text(tf, ", %s", ctrlchars[i]);
  1686. else {
  1687. anyctrlchars = TRUE;
  1688. proto_item_append_text(tf, "%s", ctrlchars[i]);
  1689. }
  1690. }
  1691. }
  1692. proto_item_append_text(tf, ")");
  1693. }
  1694. }
  1695. static void
  1696. dissect_lcp_authprot_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  1697. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  1698. {
  1699. proto_tree *field_tree;
  1700. proto_item *tf;
  1701. guint16 protocol;
  1702. protocol = tvb_get_ntohs(tvb, offset + 2);
  1703. tf = proto_tree_add_text(tree, tvb, offset, length, "%s: %s (0x%02x)",
  1704. optp->name, val_to_str_ext_const(protocol, &ppp_vals_ext, "Unknown"),
  1705. protocol);
  1706. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  1707. dissect_lcp_opt_type_len(tvb, offset, field_tree, optp->name);
  1708. proto_tree_add_item(field_tree, hf_lcp_opt_auth_protocol, tvb, offset + 2,
  1709. 2, ENC_BIG_ENDIAN);
  1710. if (length > 4) {
  1711. offset += 4;
  1712. length -= 4;
  1713. if (protocol == PPP_CHAP) {
  1714. proto_tree_add_item(field_tree, hf_lcp_opt_algorithm, tvb, offset,
  1715. 1, ENC_NA);
  1716. if (length > 1) {
  1717. proto_tree_add_item(field_tree, hf_lcp_opt_data, tvb,
  1718. offset + 1, length - 1, ENC_NA);
  1719. }
  1720. } else {
  1721. proto_tree_add_item(field_tree, hf_lcp_opt_data, tvb, offset,
  1722. length, ENC_NA);
  1723. }
  1724. }
  1725. }
  1726. static void
  1727. dissect_lcp_qualprot_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  1728. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  1729. {
  1730. proto_tree *field_tree;
  1731. proto_item *tf;
  1732. guint16 protocol;
  1733. protocol = tvb_get_ntohs(tvb, offset + 2);
  1734. tf = proto_tree_add_text(tree, tvb, offset, length, "%s: %s (0x%02x)",
  1735. optp->name, val_to_str_ext_const(protocol, &ppp_vals_ext, "Unknown"),
  1736. protocol);
  1737. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  1738. dissect_lcp_opt_type_len(tvb, offset, field_tree, optp->name);
  1739. proto_tree_add_item(field_tree, hf_lcp_opt_quality_protocol, tvb,
  1740. offset + 2, 2, ENC_BIG_ENDIAN);
  1741. if (length > 4) {
  1742. proto_tree_add_item(field_tree, hf_lcp_opt_data, tvb, offset + 4,
  1743. length + 4, ENC_NA);
  1744. }
  1745. }
  1746. static void
  1747. dissect_lcp_magicnumber_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  1748. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  1749. {
  1750. proto_tree *field_tree;
  1751. proto_item *tf;
  1752. tf = proto_tree_add_text(tree, tvb, offset, length, "%s: 0x%08x",
  1753. optp->name, tvb_get_ntohl(tvb, offset + 2));
  1754. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  1755. dissect_lcp_opt_type_len(tvb, offset, field_tree, optp->name);
  1756. proto_tree_add_item(field_tree, hf_lcp_opt_magic_number, tvb, offset + 2,
  1757. 4, ENC_BIG_ENDIAN);
  1758. }
  1759. static void
  1760. dissect_lcp_linkqualmon_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  1761. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  1762. {
  1763. proto_tree *field_tree;
  1764. proto_item *tf;
  1765. guint32 reportingperiod;
  1766. reportingperiod = tvb_get_ntohl(tvb, offset + 2);
  1767. tf = proto_tree_add_text(tree, tvb, offset, length,
  1768. "%s: %u microsecond%s%s", optp->name, reportingperiod,
  1769. plurality(reportingperiod, "", "s"),
  1770. reportingperiod ? "" : " [illegal]");
  1771. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  1772. dissect_lcp_opt_type_len(tvb, offset, field_tree, optp->name);
  1773. proto_tree_add_uint_format_value(field_tree, hf_lcp_opt_reportingperiod,
  1774. tvb, offset + 2, 4, reportingperiod, "%u microsecond%s%s",
  1775. reportingperiod, plurality(reportingperiod, "", "s"),
  1776. reportingperiod ? "" : "[illegal]");
  1777. }
  1778. /* Used for:
  1779. * Protocol Field Compression
  1780. * Address and Control Field Compression
  1781. * Compound Frames (Deprecated)
  1782. * Nominal Data Encapsulation (Deprecated)
  1783. * Multilink Short Sequence Number Header
  1784. * Simple Data Link on SONET/SDH
  1785. */
  1786. static void
  1787. dissect_lcp_simple_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  1788. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  1789. {
  1790. proto_tree *field_tree;
  1791. proto_item *tf;
  1792. tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
  1793. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  1794. dissect_lcp_opt_type_len(tvb, offset, field_tree, optp->name);
  1795. }
  1796. static void
  1797. dissect_lcp_fcs_alternatives_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  1798. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree,
  1799. void *data _U_)
  1800. {
  1801. proto_tree *field_tree;
  1802. proto_item *tf;
  1803. static const int *fcs_alternatives_fields[] = {
  1804. &hf_lcp_opt_fcs_alternatives_ccitt32,
  1805. &hf_lcp_opt_fcs_alternatives_ccitt16,
  1806. &hf_lcp_opt_fcs_alternatives_null,
  1807. NULL
  1808. };
  1809. tf = proto_tree_add_text(tree, tvb, offset, length, "%s: 0x%02x",
  1810. optp->name, tvb_get_guint8(tvb, offset + 2));
  1811. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  1812. dissect_lcp_opt_type_len(tvb, offset, field_tree, optp->name);
  1813. proto_tree_add_bitmask(field_tree, tvb, offset + 2,
  1814. hf_lcp_opt_fcs_alternatives, *optp->subtree_index,
  1815. fcs_alternatives_fields, ENC_NA);
  1816. }
  1817. static void
  1818. dissect_lcp_self_describing_pad_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  1819. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree,
  1820. void *data _U_)
  1821. {
  1822. proto_tree *field_tree;
  1823. proto_item *tf;
  1824. guint8 maximum;
  1825. maximum = tvb_get_guint8(tvb, offset + 2);
  1826. tf = proto_tree_add_text(tree, tvb, offset, length, "%s: %u octet%s%s",
  1827. optp->name, maximum, plurality(maximum, "", "s"),
  1828. maximum ? "" : " [invalid]");
  1829. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  1830. dissect_lcp_opt_type_len(tvb, offset, field_tree, optp->name);
  1831. proto_tree_add_uint_format_value(field_tree, hf_lcp_opt_maximum, tvb,
  1832. offset + 2, 1, maximum, "%u octet%s%s", maximum,
  1833. plurality(maximum, "", "s"), maximum ? "" : " [invalid]");
  1834. }
  1835. static void
  1836. dissect_lcp_numbered_mode_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  1837. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree,
  1838. void *data _U_)
  1839. {
  1840. proto_tree *field_tree;
  1841. proto_item *tf;
  1842. guint8 window;
  1843. window = tvb_get_guint8(tvb, offset + 2);
  1844. tf = proto_tree_add_text(tree, tvb, offset, length, "%s: %u frame%s%s",
  1845. optp->name, window, plurality(window, "", "s"),
  1846. (window == 0 || window > 127) ? " [invalid]" : "");
  1847. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  1848. dissect_lcp_opt_type_len(tvb, offset, field_tree, optp->name);
  1849. proto_tree_add_uint_format_value(field_tree, hf_lcp_opt_window, tvb,
  1850. offset + 2, 1, window, "%u frame%s%s", window,
  1851. plurality(window, "", "s"),
  1852. (window == 0 || window > 127) ? " [invalid]" : "");
  1853. if (length > 3) {
  1854. proto_tree_add_item(field_tree, hf_lcp_opt_hdlc_address, tvb,
  1855. offset + 3, length - 3, ENC_NA);
  1856. }
  1857. }
  1858. /* http://tools.ietf.org/html/rfc1570#section-2.3 only lists 0-4, but
  1859. * http://tools.ietf.org/html/draft-ietf-pppext-callback-ds-02 lists 5 as
  1860. * "E.165 number", rather than "unassigned", and
  1861. * http://msdn.microsoft.com/en-us/library/ff632847%28v=prot.10%29.aspx does
  1862. * indicate 6 as below. Since 5 is only mentioned in the draft, leave it as
  1863. * "unassigned"?
  1864. */
  1865. static const value_string callback_op_vals[] = {
  1866. {0, "Location is determined by user authentication"},
  1867. {1, "Message is dialing string"},
  1868. {2, "Message is location identifier"},
  1869. {3, "Message is E.164"},
  1870. {4, "Message is distinguished name"},
  1871. {5, "unassigned"}, /* "Message is E.165"? */
  1872. {6, "Location is determined during CBCP negotiation"},
  1873. {0, NULL}
  1874. };
  1875. static void
  1876. dissect_lcp_callback_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  1877. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  1878. {
  1879. proto_tree *field_tree;
  1880. proto_item *tf;
  1881. guint8 operation;
  1882. operation = tvb_get_guint8(tvb, offset + 2);
  1883. tf = proto_tree_add_text(tree, tvb, offset, length, "%s: %s", optp->name,
  1884. val_to_str_const(operation, callback_op_vals, "Unknown"));
  1885. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  1886. dissect_lcp_opt_type_len(tvb, offset, field_tree, optp->name);
  1887. proto_tree_add_item(field_tree, hf_lcp_opt_operation, tvb, offset + 2, 1,
  1888. ENC_NA);
  1889. if (length > 3) {
  1890. proto_tree_add_item(field_tree, hf_lcp_opt_message, tvb, offset + 3,
  1891. length - 3, ENC_NA);
  1892. }
  1893. }
  1894. /* http://tools.ietf.org/html/rfc1990#section-5.1.1 */
  1895. static void
  1896. dissect_lcp_multilink_mrru_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  1897. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree,
  1898. void *data _U_)
  1899. {
  1900. proto_tree *field_tree;
  1901. proto_item *tf;
  1902. tf = proto_tree_add_text(tree, tvb, offset, length, "%s: %u", optp->name,
  1903. tvb_get_ntohs(tvb, offset + 2));
  1904. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  1905. dissect_lcp_opt_type_len(tvb, offset, field_tree, optp->name);
  1906. proto_tree_add_item(field_tree, hf_lcp_opt_mrru, tvb, offset + 2, 2,
  1907. ENC_BIG_ENDIAN);
  1908. }
  1909. #define CLASS_NULL 0
  1910. #define CLASS_LOCAL 1
  1911. #define CLASS_IP 2
  1912. #define CLASS_IEEE_802_1 3
  1913. #define CLASS_PPP_MAGIC_NUMBER 4
  1914. #define CLASS_PSDN_DIRECTORY_NUMBER 5
  1915. static const value_string multilink_ep_disc_class_vals[] = {
  1916. {CLASS_NULL, "Null"},
  1917. {CLASS_LOCAL, "Locally assigned address"},
  1918. {CLASS_IP, "Internet Protocol (IP) address"},
  1919. {CLASS_IEEE_802_1, "IEEE 802.1 globally assigned MAC address"},
  1920. {CLASS_PPP_MAGIC_NUMBER, "PPP magic-number block"},
  1921. {CLASS_PSDN_DIRECTORY_NUMBER, "Public switched network directory number"},
  1922. {0, NULL}
  1923. };
  1924. static void
  1925. dissect_lcp_multilink_ep_disc_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  1926. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree,
  1927. void *data _U_)
  1928. {
  1929. proto_tree *field_tree;
  1930. proto_tree *magic_tree;
  1931. proto_item *tf, *tm;
  1932. guint8 ep_disc_class;
  1933. ep_disc_class = tvb_get_guint8(tvb, offset + 2);
  1934. tf = proto_tree_add_text(tree, tvb, offset, length, "%s: Class: %s",
  1935. optp->name, val_to_str_const(ep_disc_class,
  1936. multilink_ep_disc_class_vals, "Unknown"));
  1937. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  1938. dissect_lcp_opt_type_len(tvb, offset, field_tree, optp->name);
  1939. proto_tree_add_item(field_tree, hf_lcp_opt_ep_disc_class, tvb, offset + 2,
  1940. 1, ENC_NA);
  1941. if (length <= 3)
  1942. return;
  1943. length -= 3;
  1944. offset += 3;
  1945. switch (ep_disc_class) {
  1946. case CLASS_NULL:
  1947. break;
  1948. case CLASS_LOCAL:
  1949. proto_tree_add_item(field_tree, hf_lcp_opt_data, tvb, offset,
  1950. length <= 20 ? length : 20, ENC_NA);
  1951. break;
  1952. case CLASS_IP:
  1953. if (length >= 4) {
  1954. proto_tree_add_item(field_tree, hf_lcp_opt_ip_address, tvb, offset,
  1955. 4, ENC_BIG_ENDIAN);
  1956. } else {
  1957. proto_tree_add_item(field_tree, hf_lcp_opt_data, tvb, offset,
  1958. length, ENC_NA);
  1959. }
  1960. break;
  1961. case CLASS_IEEE_802_1:
  1962. if (length >= 6) {
  1963. proto_tree_add_item(field_tree, hf_lcp_opt_802_1_address, tvb,
  1964. offset, 6, ENC_NA);
  1965. } else {
  1966. proto_tree_add_item(field_tree, hf_lcp_opt_data, tvb, offset,
  1967. length, ENC_NA);
  1968. }
  1969. break;
  1970. case CLASS_PPP_MAGIC_NUMBER:
  1971. if (length % 4) {
  1972. proto_tree_add_item(field_tree, hf_lcp_opt_data, tvb, offset,
  1973. length, ENC_NA);
  1974. } else {
  1975. tm = proto_tree_add_item(field_tree, hf_lcp_opt_magic_block, tvb,
  1976. offset, length <= 20 ? length : 20, ENC_NA);
  1977. magic_tree = proto_item_add_subtree(tm, ett_lcp_magic_block);
  1978. for ( ; length >= 4; length -= 4, offset += 4) {
  1979. proto_tree_add_item(magic_tree, hf_lcp_opt_magic_number, tvb,
  1980. offset, 4, ENC_BIG_ENDIAN);
  1981. }
  1982. }
  1983. break;
  1984. case CLASS_PSDN_DIRECTORY_NUMBER:
  1985. proto_tree_add_item(field_tree, hf_lcp_opt_psndn, tvb, offset,
  1986. length > 15 ? 15 : length, ENC_NA);
  1987. break;
  1988. default:
  1989. proto_tree_add_item(field_tree, hf_lcp_opt_data, tvb, offset, length,
  1990. ENC_NA);
  1991. break;
  1992. }
  1993. }
  1994. static const value_string dce_id_mode_vals[] = {
  1995. {1, "Mode-1 (No Additional Negotiation)"},
  1996. {2, "Mode-2 (Full PPP Negotiation and State Machine)"},
  1997. {0, NULL}
  1998. };
  1999. static void
  2000. dissect_lcp_dce_identifier_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  2001. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  2002. {
  2003. proto_tree *field_tree;
  2004. proto_item *tf;
  2005. guint8 mode;
  2006. mode = tvb_get_guint8(tvb, offset + 2);
  2007. tf = proto_tree_add_text(tree, tvb, offset, length, "%s: %s", optp->name,
  2008. val_to_str_const(mode, dce_id_mode_vals, "Unknown"));
  2009. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  2010. dissect_lcp_opt_type_len(tvb, offset, field_tree, optp->name);
  2011. proto_tree_add_item(field_tree, hf_lcp_opt_mode, tvb, offset + 2, 1,
  2012. ENC_NA);
  2013. }
  2014. static void
  2015. dissect_lcp_multilink_pp_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  2016. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  2017. {
  2018. proto_tree *field_tree;
  2019. proto_item *tf;
  2020. tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
  2021. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  2022. dissect_lcp_opt_type_len(tvb, offset, field_tree, optp->name);
  2023. proto_tree_add_item(field_tree, hf_lcp_opt_unused, tvb, offset + 2, 2,
  2024. ENC_NA);
  2025. }
  2026. static void
  2027. dissect_lcp_bacp_link_discriminator_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  2028. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  2029. {
  2030. proto_tree *field_tree;
  2031. proto_item *tf;
  2032. tf = proto_tree_add_text(tree, tvb, offset, length, "%s: %u (0x%04x)",
  2033. optp->name, tvb_get_ntohs(tvb, offset + 2),
  2034. tvb_get_ntohs(tvb, offset + 2));
  2035. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  2036. dissect_lcp_opt_type_len(tvb, offset, field_tree, optp->name);
  2037. proto_tree_add_item(field_tree, hf_lcp_opt_link_discrim, tvb, offset + 2,
  2038. 2, ENC_BIG_ENDIAN);
  2039. }
  2040. /* Assuming it's this one:
  2041. * http://tools.ietf.org/html/draft-ietf-pppext-link-negot-00
  2042. */
  2043. static void
  2044. dissect_lcp_auth_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  2045. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  2046. {
  2047. proto_tree *field_tree;
  2048. proto_item *tf;
  2049. guint8 id_len;
  2050. tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
  2051. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  2052. dissect_lcp_opt_type_len(tvb, offset, field_tree, optp->name);
  2053. proto_tree_add_item(field_tree, hf_lcp_opt_id, tvb, offset + 2, 1, ENC_NA);
  2054. if (length > 3) {
  2055. id_len = tvb_get_guint8(tvb, offset + 2);
  2056. length -= 3;
  2057. offset += 3;
  2058. if (id_len < length) {
  2059. length -= id_len;
  2060. offset += id_len;
  2061. proto_tree_add_item(field_tree, hf_lcp_opt_data, tvb, offset,
  2062. length, ENC_NA);
  2063. }
  2064. }
  2065. }
  2066. /* Asuming it's this one:
  2067. * http://tools.ietf.org/html/draft-ietf-pppext-cobs-00
  2068. */
  2069. static void
  2070. dissect_lcp_cobs_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  2071. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  2072. {
  2073. proto_tree *field_tree;
  2074. proto_item *tf;
  2075. static const int *cobs_flags_fields[] = {
  2076. &hf_lcp_opt_cobs_flags_res,
  2077. &hf_lcp_opt_cobs_flags_pre,
  2078. &hf_lcp_opt_cobs_flags_zxe,
  2079. NULL
  2080. };
  2081. tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
  2082. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  2083. dissect_lcp_opt_type_len(tvb, offset, field_tree, optp->name);
  2084. proto_tree_add_bitmask(field_tree, tvb, offset + 2, hf_lcp_opt_cobs_flags,
  2085. *optp->subtree_index, cobs_flags_fields, ENC_NA);
  2086. }
  2087. static void
  2088. dissect_lcp_prefix_elision_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  2089. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  2090. {
  2091. proto_tree *field_tree;
  2092. proto_item *tf;
  2093. guint8 pre_len;
  2094. tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
  2095. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  2096. dissect_lcp_opt_type_len(tvb, offset, field_tree, optp->name);
  2097. if (length > 2) {
  2098. length -= 2;
  2099. offset += 2;
  2100. while (length >= 2) {
  2101. proto_tree_add_item(field_tree, hf_lcp_opt_class, tvb, offset, 1,
  2102. ENC_NA);
  2103. pre_len = tvb_get_guint8(tvb, offset + 1);
  2104. if ((guint)(pre_len + 2) <= length) {
  2105. proto_tree_add_item(field_tree, hf_lcp_opt_prefix, tvb,
  2106. offset + 2, 1, ENC_NA);
  2107. length -= (2 + pre_len);
  2108. } else {
  2109. /* Prefix length doesn't make sense, so bail out */
  2110. length = 0;
  2111. }
  2112. }
  2113. }
  2114. }
  2115. static const value_string ml_hdr_fmt_code_vals[] = {
  2116. {2, "Long sequence number fragment format with classes"},
  2117. {6, "Short sequence number fragment format with classes"},
  2118. {0, NULL}
  2119. };
  2120. static void
  2121. dissect_lcp_multilink_hdr_fmt_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  2122. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  2123. {
  2124. proto_tree *field_tree;
  2125. proto_item *tf;
  2126. tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
  2127. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  2128. dissect_lcp_opt_type_len(tvb, offset, field_tree, optp->name);
  2129. proto_tree_add_item(field_tree, hf_lcp_opt_code, tvb, offset + 2, 1,
  2130. ENC_NA);
  2131. proto_tree_add_item(field_tree, hf_lcp_opt_max_susp_classes, tvb,
  2132. offset + 3, 1, ENC_NA);
  2133. }
  2134. /* Character sets from http://www.iana.org/assignments/character-sets. */
  2135. static const value_string charset_vals[] = {
  2136. {3, "ANSI_X3.4-1968"},
  2137. {4, "ISO_8859-1:1987"},
  2138. {5, "ISO_8859-2:1987"},
  2139. {6, "ISO_8859-3:1988"},
  2140. {7, "ISO_8859-4:1988"},
  2141. {8, "ISO_8859-5:1988"},
  2142. {9, "ISO_8859-6:1987"},
  2143. {10, "ISO_8859-7:1987"},
  2144. {11, "ISO_8859-8:1988"},
  2145. {12, "ISO_8859-9:1989"},
  2146. {13, "ISO-8859-10"},
  2147. {14, "ISO_6937-2-add"},
  2148. {15, "JIS_X0201"},
  2149. {16, "JIS_Encoding"},
  2150. {17, "Shift_JIS"},
  2151. {18, "Extended_UNIX_Code_Packed_Format_for_Japanese"},
  2152. {19, "Extended_UNIX_Code_Fixed_Width_for_Japanese"},
  2153. {20, "BS_4730"},
  2154. {21, "SEN_850200_C"},
  2155. {22, "IT"},
  2156. {23, "ES"},
  2157. {24, "DIN_66003"},
  2158. {25, "NS_4551-1"},
  2159. {26, "NF_Z_62-010"},
  2160. {27, "ISO-10646-UTF-1"},
  2161. {28, "ISO_646.basic:1983"},
  2162. {29, "INVARIANT"},
  2163. {30, "ISO_646.irv:1983"},
  2164. {31, "NATS-SEFI"},
  2165. {32, "NATS-SEFI-ADD"},
  2166. {33, "NATS-DANO"},
  2167. {34, "NATS-DANO-ADD"},
  2168. {35, "SEN_850200_B"},
  2169. {36, "KS_C_5601-1987"},
  2170. {37, "ISO-2022-KR"},
  2171. {38, "EUC-KR"},
  2172. {39, "ISO-2022-JP"},
  2173. {40, "ISO-2022-JP-2"},
  2174. {41, "JIS_C6220-1969-jp"},
  2175. {42, "JIS_C6220-1969-ro"},
  2176. {43, "PT"},
  2177. {44, "greek7-old"},
  2178. {45, "latin-greek"},
  2179. {46, "NF_Z_62-010_(1973)"},
  2180. {47, "Latin-greek-1"},
  2181. {48, "ISO_5427"},
  2182. {49, "JIS_C6226-1978"},
  2183. {50, "BS_viewdata"},
  2184. {51, "INIS"},
  2185. {52, "INIS-8"},
  2186. {53, "INIS-cyrillic"},
  2187. {54, "ISO_5427:1981"},
  2188. {55, "ISO_5428:1980"},
  2189. {56, "GB_1988-80"},
  2190. {57, "GB_2312-80"},
  2191. {58, "NS_4551-2"},
  2192. {59, "videotex-suppl"},
  2193. {60, "PT2"},
  2194. {61, "ES2"},
  2195. {62, "MSZ_7795.3"},
  2196. {63, "JIS_C6226-1983"},
  2197. {64, "greek7"},
  2198. {65, "ASMO_449"},
  2199. {66, "iso-ir-90"},
  2200. {67, "JIS_C6229-1984-a"},
  2201. {68, "JIS_C6229-1984-b"},
  2202. {69, "JIS_C6229-1984-b-add"},
  2203. {70, "JIS_C6229-1984-hand"},
  2204. {71, "JIS_C6229-1984-hand-add"},
  2205. {72, "JIS_C6229-1984-kana"},
  2206. {73, "ISO_2033-1983"},
  2207. {74, "ANSI_X3.110-1983"},
  2208. {75, "T.61-7bit"},
  2209. {76, "T.61-8bit"},
  2210. {77, "ECMA-cyrillic"},
  2211. {78, "CSA_Z243.4-1985-1"},
  2212. {79, "CSA_Z243.4-1985-2"},
  2213. {80, "CSA_Z243.4-1985-gr"},
  2214. {81, "ISO_8859-6-E"},
  2215. {82, "ISO_8859-6-I"},
  2216. {83, "T.101-G2"},
  2217. {84, "ISO_8859-8-E"},
  2218. {85, "ISO_8859-8-I"},
  2219. {86, "CSN_369103"},
  2220. {87, "JUS_I.B1.002"},
  2221. {88, "IEC_P27-1"},
  2222. {89, "JUS_I.B1.003-serb"},
  2223. {90, "JUS_I.B1.003-mac"},
  2224. {91, "greek-ccitt"},
  2225. {92, "NC_NC00-10:81"},
  2226. {93, "ISO_6937-2-25"},
  2227. {94, "GOST_19768-74"},
  2228. {95, "ISO_8859-supp"},
  2229. {96, "ISO_10367-box"},
  2230. {97, "latin-lap"},
  2231. {98, "JIS_X0212-1990"},
  2232. {99, "DS_2089"},
  2233. {100, "us-dk"},
  2234. {101, "dk-us"},
  2235. {102, "KSC5636"},
  2236. {103, "UNICODE-1-1-UTF-7"},
  2237. {104, "ISO-2022-CN"},
  2238. {105, "ISO-2022-CN-EXT"},
  2239. {106, "UTF-8"},
  2240. {109, "ISO-8859-13"},
  2241. {110, "ISO-8859-14"},
  2242. {111, "ISO-8859-15"},
  2243. {112, "ISO-8859-16"},
  2244. {113, "GBK"},
  2245. {114, "GB18030"},
  2246. {115, "OSD_EBCDIC_DF04_15"},
  2247. {116, "OSD_EBCDIC_DF03_IRV"},
  2248. {117, "OSD_EBCDIC_DF04_1"},
  2249. {118, "ISO-11548-1"},
  2250. {119, "KZ-1048"},
  2251. {1000, "ISO-10646-UCS-2"},
  2252. {1001, "ISO-10646-UCS-4"},
  2253. {1002, "ISO-10646-UCS-Basic"},
  2254. {1003, "ISO-10646-Unicode-Latin1"},
  2255. {1004, "ISO-10646-J-1"},
  2256. {1005, "ISO-Unicode-IBM-1261"},
  2257. {1006, "ISO-Unicode-IBM-1268"},
  2258. {1007, "ISO-Unicode-IBM-1276"},
  2259. {1008, "ISO-Unicode-IBM-1264"},
  2260. {1009, "ISO-Unicode-IBM-1265"},
  2261. {1010, "UNICODE-1-1"},
  2262. {1011, "SCSU"},
  2263. {1012, "UTF-7"},
  2264. {1013, "UTF-16BE"},
  2265. {1014, "UTF-16LE"},
  2266. {1015, "UTF-16"},
  2267. {1016, "CESU-8"},
  2268. {1017, "UTF-32"},
  2269. {1018, "UTF-32BE"},
  2270. {1019, "UTF-32LE"},
  2271. {1020, "BOCU-1"},
  2272. {2000, "ISO-8859-1-Windows-3.0-Latin-1"},
  2273. {2001, "ISO-8859-1-Windows-3.1-Latin-1"},
  2274. {2002, "ISO-8859-2-Windows-Latin-2"},
  2275. {2003, "ISO-8859-9-Windows-Latin-5"},
  2276. {2004, "hp-roman8"},
  2277. {2005, "Adobe-Standard-Encoding"},
  2278. {2006, "Ventura-US"},
  2279. {2007, "Ventura-International"},
  2280. {2008, "DEC-MCS"},
  2281. {2009, "IBM850"},
  2282. {2010, "IBM852"},
  2283. {2011, "IBM437"},
  2284. {2012, "PC8-Danish-Norwegian"},
  2285. {2013, "IBM862"},
  2286. {2014, "PC8-Turkish"},
  2287. {2015, "IBM-Symbols"},
  2288. {2016, "IBM-Thai"},
  2289. {2017, "HP-Legal"},
  2290. {2018, "HP-Pi-font"},
  2291. {2019, "HP-Math8"},
  2292. {2020, "Adobe-Symbol-Encoding"},
  2293. {2021, "HP-DeskTop"},
  2294. {2022, "Ventura-Math"},
  2295. {2023, "Microsoft-Publishing"},
  2296. {2024, "Windows-31J"},
  2297. {2025, "GB2312"},
  2298. {2026, "Big5"},
  2299. {2027, "macintosh"},
  2300. {2028, "IBM037"},
  2301. {2029, "IBM038"},
  2302. {2030, "IBM273"},
  2303. {2031, "IBM274"},
  2304. {2032, "IBM275"},
  2305. {2033, "IBM277"},
  2306. {2034, "IBM278"},
  2307. {2035, "IBM280"},
  2308. {2036, "IBM281"},
  2309. {2037, "IBM284"},
  2310. {2038, "IBM285"},
  2311. {2039, "IBM290"},
  2312. {2040, "IBM297"},
  2313. {2041, "IBM420"},
  2314. {2042, "IBM423"},
  2315. {2043, "IBM424"},
  2316. {2044, "IBM500"},
  2317. {2045, "IBM851"},
  2318. {2046, "IBM855"},
  2319. {2047, "IBM857"},
  2320. {2048, "IBM860"},
  2321. {2049, "IBM861"},
  2322. {2050, "IBM863"},
  2323. {2051, "IBM864"},
  2324. {2052, "IBM865"},
  2325. {2053, "IBM868"},
  2326. {2054, "IBM869"},
  2327. {2055, "IBM870"},
  2328. {2056, "IBM871"},
  2329. {2057, "IBM880"},
  2330. {2058, "IBM891"},
  2331. {2059, "IBM903"},
  2332. {2060, "IBM904"},
  2333. {2061, "IBM905"},
  2334. {2062, "IBM918"},
  2335. {2063, "IBM1026"},
  2336. {2064, "EBCDIC-AT-DE"},
  2337. {2065, "EBCDIC-AT-DE-A"},
  2338. {2066, "EBCDIC-CA-FR"},
  2339. {2067, "EBCDIC-DK-NO"},
  2340. {2068, "EBCDIC-DK-NO-A"},
  2341. {2069, "EBCDIC-FI-SE"},
  2342. {2070, "EBCDIC-FI-SE-A"},
  2343. {2071, "EBCDIC-FR"},
  2344. {2072, "EBCDIC-IT"},
  2345. {2073, "EBCDIC-PT"},
  2346. {2074, "EBCDIC-ES"},
  2347. {2075, "EBCDIC-ES-A"},
  2348. {2076, "EBCDIC-ES-S"},
  2349. {2077, "EBCDIC-UK"},
  2350. {2078, "EBCDIC-US"},
  2351. {2079, "UNKNOWN-8BIT"},
  2352. {2080, "MNEMONIC"},
  2353. {2081, "MNEM"},
  2354. {2082, "VISCII"},
  2355. {2083, "VIQR"},
  2356. {2084, "KOI8-R"},
  2357. {2085, "HZ-GB-2312"},
  2358. {2086, "IBM866"},
  2359. {2087, "IBM775"},
  2360. {2088, "KOI8-U"},
  2361. {2089, "IBM00858"},
  2362. {2090, "IBM00924"},
  2363. {2091, "IBM01140"},
  2364. {2092, "IBM01141"},
  2365. {2093, "IBM01142"},
  2366. {2094, "IBM01143"},
  2367. {2095, "IBM01144"},
  2368. {2096, "IBM01145"},
  2369. {2097, "IBM01146"},
  2370. {2098, "IBM01147"},
  2371. {2099, "IBM01148"},
  2372. {2100, "IBM01149"},
  2373. {2101, "Big5-HKSCS"},
  2374. {2102, "IBM1047"},
  2375. {2103, "PTCP154"},
  2376. {2104, "Amiga-1251"},
  2377. {2105, "KOI7-switched"},
  2378. {2106, "BRF"},
  2379. {2107, "TSCII"},
  2380. {2108, "CP51932"},
  2381. {2109, "windows-874"},
  2382. {2250, "windows-1250"},
  2383. {2251, "windows-1251"},
  2384. {2252, "windows-1252"},
  2385. {2253, "windows-1253"},
  2386. {2254, "windows-1254"},
  2387. {2255, "windows-1255"},
  2388. {2256, "windows-1256"},
  2389. {2257, "windows-1257"},
  2390. {2258, "windows-1258"},
  2391. {2259, "TIS-620"},
  2392. {2260, "CP50220"},
  2393. {0, NULL}
  2394. };
  2395. value_string_ext charset_vals_ext = VALUE_STRING_EXT_INIT(charset_vals);
  2396. static void
  2397. dissect_lcp_internationalization_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  2398. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  2399. {
  2400. proto_tree *field_tree;
  2401. proto_item *tf;
  2402. tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
  2403. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  2404. dissect_lcp_opt_type_len(tvb, offset, field_tree, optp->name);
  2405. proto_tree_add_item(field_tree, hf_lcp_opt_MIBenum, tvb, offset + 2, 4,
  2406. ENC_BIG_ENDIAN);
  2407. proto_tree_add_item(field_tree, hf_lcp_opt_language_tag, tvb, offset + 6,
  2408. length - 6, ENC_NA);
  2409. }
  2410. static void
  2411. dissect_ipcp_opt_type_len(tvbuff_t *tvb, int offset, proto_tree *tree,
  2412. const char *name)
  2413. {
  2414. guint8 type;
  2415. type = tvb_get_guint8(tvb, offset);
  2416. proto_tree_add_uint_format_value(tree, hf_ipcp_opt_type, tvb, offset, 1,
  2417. type, "%s (%u)", name, type);
  2418. proto_tree_add_item(tree, hf_ipcp_opt_length, tvb, offset + 1, 1, ENC_NA);
  2419. }
  2420. /* http://tools.ietf.org/html/rfc1172#section-5.1 */
  2421. static void
  2422. dissect_ipcp_addrs_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  2423. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  2424. {
  2425. proto_item *tf;
  2426. proto_tree *field_tree;
  2427. tf = proto_tree_add_text(tree, tvb, offset, length, "%s: Src: %s, Dst: %s",
  2428. optp->name, tvb_ip_to_str(tvb, offset + 2),
  2429. tvb_ip_to_str(tvb, offset + 6));
  2430. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  2431. dissect_ipcp_opt_type_len(tvb, offset, field_tree, optp->name);
  2432. proto_tree_add_item(field_tree, hf_ipcp_opt_src_address, tvb, offset + 2,
  2433. 4, ENC_BIG_ENDIAN);
  2434. proto_tree_add_item(field_tree, hf_ipcp_opt_dst_address, tvb, offset + 6,
  2435. 4, ENC_BIG_ENDIAN);
  2436. }
  2437. static const true_false_string tfs_comp_slot_id = {
  2438. "The slot identifier may be compressed",
  2439. "The slot identifier must not be compressed"
  2440. };
  2441. /* http://tools.ietf.org/html/rfc1332#section-3.2 */
  2442. static void
  2443. dissect_ipcp_compress_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  2444. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  2445. {
  2446. proto_item *tf;
  2447. proto_tree *field_tree;
  2448. guint16 us;
  2449. tf = proto_tree_add_text(tree, tvb, offset, length, "%s: %s", optp->name,
  2450. val_to_str_const(tvb_get_ntohs(tvb, offset + 2),
  2451. ipcp_compress_proto_vals, "Unknown"));
  2452. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  2453. dissect_ipcp_opt_type_len(tvb, offset, field_tree, optp->name);
  2454. proto_tree_add_item(field_tree, hf_ipcp_opt_compress_proto, tvb,
  2455. offset + 2, 2, ENC_BIG_ENDIAN);
  2456. us = tvb_get_ntohs(tvb, offset + 2);
  2457. switch (us) {
  2458. case IPCP_ROHC:
  2459. proto_tree_add_item(field_tree, hf_ipcp_opt_max_cid, tvb, offset + 4,
  2460. 2, ENC_BIG_ENDIAN);
  2461. proto_tree_add_item(field_tree, hf_ipcp_opt_mrru, tvb, offset + 6, 2,
  2462. ENC_BIG_ENDIAN);
  2463. proto_tree_add_item(field_tree, hf_ipcp_opt_max_header, tvb,
  2464. offset + 8, 2, ENC_BIG_ENDIAN);
  2465. if (length > 10) {
  2466. proto_item *tso;
  2467. proto_tree *subopt_tree;
  2468. /* suboptions */
  2469. offset += 10;
  2470. length -= 10;
  2471. tso = proto_tree_add_text(field_tree, tvb, offset, length,
  2472. "Suboptions: (%u byte%s)", length, plurality(length, "", "s"));
  2473. subopt_tree = proto_item_add_subtree(tso, *optp->subtree_index);
  2474. dissect_ip_tcp_options(tvb, offset, length, ipcp_rohc_subopts,
  2475. N_IPCP_ROHC_SUBOPTS, -1, &PPP_OPT_TYPES, &ei_ppp_opt_len_invalid, pinfo, subopt_tree, NULL, NULL);
  2476. }
  2477. break;
  2478. case IPCP_COMPRESS_VJ_1172:
  2479. case IPCP_COMPRESS_VJ:
  2480. proto_tree_add_item(field_tree, hf_ipcp_opt_max_slot_id, tvb,
  2481. offset + 4, 1, ENC_NA);
  2482. proto_tree_add_item(field_tree, hf_ipcp_opt_comp_slot_id, tvb,
  2483. offset + 5, 1, ENC_NA);
  2484. break;
  2485. case IPCP_COMPRESS_IPHC:
  2486. proto_tree_add_item(field_tree, hf_ipcp_opt_tcp_space, tvb, offset + 4,
  2487. 2, ENC_BIG_ENDIAN);
  2488. proto_tree_add_item(field_tree, hf_ipcp_opt_non_tcp_space, tvb,
  2489. offset + 6, 2, ENC_BIG_ENDIAN);
  2490. us = tvb_get_ntohs(tvb, offset + 8);
  2491. proto_tree_add_uint_format_value(field_tree, hf_ipcp_opt_f_max_period,
  2492. tvb, offset + 8, 2, us, "%u%s", us,
  2493. (us == 0) ? " (infinity)" : "");
  2494. us = tvb_get_ntohs(tvb, offset + 10);
  2495. proto_tree_add_uint_format_value(field_tree, hf_ipcp_opt_f_max_time,
  2496. tvb, offset + 10, 2, us, "%u%s", us,
  2497. (us == 0) ? " (infinity)" : "");
  2498. proto_tree_add_item(field_tree, hf_ipcp_opt_max_header, tvb,
  2499. offset + 12, 2, ENC_BIG_ENDIAN);
  2500. if ( length > 14 ) {
  2501. proto_item *tso;
  2502. proto_tree *subopt_tree;
  2503. /* suboptions */
  2504. offset += 14;
  2505. length -= 14;
  2506. tso = proto_tree_add_text(field_tree, tvb, offset, length,
  2507. "Suboptions: (%u byte%s)", length, plurality(length, "", "s"));
  2508. subopt_tree = proto_item_add_subtree(tso, *optp->subtree_index);
  2509. dissect_ip_tcp_options(tvb, offset, length, ipcp_iphc_subopts,
  2510. N_IPCP_IPHC_SUBOPTS, -1, &PPP_OPT_TYPES, &ei_ppp_opt_len_invalid, pinfo, subopt_tree, NULL, NULL);
  2511. }
  2512. break;
  2513. default:
  2514. if (length > 4) {
  2515. proto_tree_add_item(field_tree, hf_ipcp_data, tvb, offset + 4,
  2516. length - 4, ENC_NA);
  2517. }
  2518. break;
  2519. }
  2520. }
  2521. static void
  2522. dissect_ipcp_opt_rohc_type_len(tvbuff_t *tvb, int offset, proto_tree *tree,
  2523. const char *name)
  2524. {
  2525. guint8 type;
  2526. type = tvb_get_guint8(tvb, offset);
  2527. proto_tree_add_uint_format_value(tree, hf_ipcp_opt_rohc_type, tvb, offset,
  2528. 1, type, "%s (%u)", name, type);
  2529. proto_tree_add_item(tree, hf_ipcp_opt_rohc_length, tvb, offset + 1, 1,
  2530. ENC_NA);
  2531. }
  2532. static void
  2533. dissect_ipcp_rohc_profiles_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  2534. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  2535. {
  2536. proto_tree *field_tree;
  2537. proto_item *tf;
  2538. tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
  2539. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  2540. dissect_ipcp_opt_rohc_type_len(tvb, offset, field_tree, optp->name);
  2541. if (length <= 2)
  2542. return;
  2543. for (offset += 2, length -= 2; length >= 2; length -= 2, offset += 2) {
  2544. proto_tree_add_item(field_tree, hf_ipcp_opt_rohc_profile, tvb,
  2545. offset, 2, ENC_BIG_ENDIAN);
  2546. }
  2547. }
  2548. static void
  2549. dissect_ipcp_opt_iphc_type_len(tvbuff_t *tvb, int offset, proto_tree *tree,
  2550. const char *name)
  2551. {
  2552. guint8 type;
  2553. type = tvb_get_guint8(tvb, offset);
  2554. proto_tree_add_uint_format_value(tree, hf_ipcp_opt_iphc_type, tvb, offset,
  2555. 1, type, "%s (%u)", name, type);
  2556. proto_tree_add_item(tree, hf_ipcp_opt_iphc_length, tvb, offset + 1, 1,
  2557. ENC_NA);
  2558. }
  2559. static void
  2560. dissect_ipcp_iphc_simple_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  2561. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  2562. {
  2563. proto_tree *field_tree;
  2564. proto_item *tf;
  2565. tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
  2566. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  2567. dissect_ipcp_opt_iphc_type_len(tvb, offset, field_tree, optp->name);
  2568. }
  2569. static void
  2570. dissect_ipcp_iphc_neghdrcomp_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  2571. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  2572. {
  2573. proto_tree *field_tree;
  2574. proto_item *tf;
  2575. tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
  2576. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  2577. dissect_ipcp_opt_iphc_type_len(tvb, offset, field_tree, optp->name);
  2578. proto_tree_add_item(field_tree, hf_ipcp_opt_iphc_param, tvb, offset + 2, 1,
  2579. ENC_NA);
  2580. }
  2581. static void
  2582. dissect_ipcp_addr_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  2583. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  2584. {
  2585. proto_item *tf;
  2586. proto_tree *field_tree;
  2587. tf = proto_tree_add_text(tree, tvb, offset, length, "%s: %s", optp->name,
  2588. tvb_ip_to_str(tvb, offset + 2));
  2589. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  2590. dissect_ipcp_opt_type_len(tvb, offset, field_tree, optp->name);
  2591. proto_tree_add_item(field_tree, hf_ipcp_opt_ip_address, tvb, offset + 2, 4,
  2592. ENC_BIG_ENDIAN);
  2593. }
  2594. static void
  2595. dissect_ipcp_mobileipv4_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  2596. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  2597. {
  2598. proto_item *tf;
  2599. proto_tree *field_tree;
  2600. tf = proto_tree_add_text(tree, tvb, offset, length, "%s: %s", optp->name,
  2601. tvb_ip_to_str(tvb, offset + 2));
  2602. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  2603. dissect_ipcp_opt_type_len(tvb, offset, field_tree, optp->name);
  2604. proto_tree_add_item(field_tree, hf_ipcp_opt_mobilenodehomeaddr, tvb,
  2605. offset + 2, 4, ENC_BIG_ENDIAN);
  2606. }
  2607. static void
  2608. dissect_ipcp_pri_dns_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  2609. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  2610. {
  2611. proto_item *tf;
  2612. proto_tree *field_tree;
  2613. tf = proto_tree_add_text(tree, tvb, offset, length, "%s: %s", optp->name,
  2614. tvb_ip_to_str(tvb, offset + 2));
  2615. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  2616. dissect_ipcp_opt_type_len(tvb, offset, field_tree, optp->name);
  2617. proto_tree_add_item(field_tree, hf_ipcp_opt_pri_dns_address, tvb,
  2618. offset + 2, 4, ENC_BIG_ENDIAN);
  2619. }
  2620. static void
  2621. dissect_ipcp_pri_nbns_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  2622. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  2623. {
  2624. proto_item *tf;
  2625. proto_tree *field_tree;
  2626. tf = proto_tree_add_text(tree, tvb, offset, length, "%s: %s", optp->name,
  2627. tvb_ip_to_str(tvb, offset + 2));
  2628. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  2629. dissect_ipcp_opt_type_len(tvb, offset, field_tree, optp->name);
  2630. proto_tree_add_item(field_tree, hf_ipcp_opt_pri_nbns_address, tvb,
  2631. offset + 2, 4, ENC_BIG_ENDIAN);
  2632. }
  2633. static void
  2634. dissect_ipcp_sec_dns_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  2635. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  2636. {
  2637. proto_item *tf;
  2638. proto_tree *field_tree;
  2639. tf = proto_tree_add_text(tree, tvb, offset, length, "%s: %s", optp->name,
  2640. tvb_ip_to_str(tvb, offset + 2));
  2641. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  2642. dissect_ipcp_opt_type_len(tvb, offset, field_tree, optp->name);
  2643. proto_tree_add_item(field_tree, hf_ipcp_opt_sec_dns_address, tvb,
  2644. offset + 2, 4, ENC_BIG_ENDIAN);
  2645. }
  2646. static void
  2647. dissect_ipcp_sec_nbns_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  2648. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  2649. {
  2650. proto_item *tf;
  2651. proto_tree *field_tree;
  2652. tf = proto_tree_add_text(tree, tvb, offset, length, "%s: %s", optp->name,
  2653. tvb_ip_to_str(tvb, offset + 2));
  2654. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  2655. dissect_ipcp_opt_type_len(tvb, offset, field_tree, optp->name);
  2656. proto_tree_add_item(field_tree, hf_ipcp_opt_sec_nbns_address, tvb,
  2657. offset + 2, 4, ENC_BIG_ENDIAN);
  2658. }
  2659. static void
  2660. dissect_osinlcp_opt_type_len(tvbuff_t *tvb, int offset, proto_tree *tree,
  2661. const char *name)
  2662. {
  2663. guint8 type;
  2664. type = tvb_get_guint8(tvb, offset);
  2665. proto_tree_add_uint_format_value(tree, hf_osinlcp_opt_type, tvb, offset, 1,
  2666. type, "%s (%u)", name, type);
  2667. proto_tree_add_item(tree, hf_osinlcp_opt_length, tvb, offset + 1, 1,
  2668. ENC_NA);
  2669. }
  2670. static void
  2671. dissect_osinlcp_align_npdu_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  2672. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  2673. {
  2674. proto_item *tf;
  2675. proto_tree *field_tree;
  2676. tf = proto_tree_add_text(tree, tvb, offset, length, "%s: Alignment: %u",
  2677. optp->name, tvb_get_guint8(tvb, offset + 2));
  2678. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  2679. dissect_osinlcp_opt_type_len(tvb, offset, field_tree, optp->name);
  2680. proto_tree_add_item(field_tree, hf_osinlcp_opt_alignment, tvb, offset + 2,
  2681. 1, ENC_NA);
  2682. }
  2683. static void
  2684. dissect_pppmuxcp_def_pid_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  2685. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  2686. {
  2687. pppmux_def_prot_id = tvb_get_ntohs(tvb, offset + 2);
  2688. proto_tree_add_text(tree, tvb, offset + 2, length - 2, "%s: %s (0x%02x)",
  2689. optp->name,
  2690. val_to_str_ext_const(pppmux_def_prot_id, &ppp_vals_ext, "Unknown"),
  2691. pppmux_def_prot_id);
  2692. }
  2693. static void
  2694. dissect_ccp_opt_type_len(tvbuff_t *tvb, int offset, proto_tree *tree,
  2695. const char *name)
  2696. {
  2697. guint8 type;
  2698. type = tvb_get_guint8(tvb, offset);
  2699. proto_tree_add_uint_format_value(tree, hf_ccp_opt_type, tvb, offset, 1,
  2700. type, "%s (%u)", name, type);
  2701. proto_tree_add_item(tree, hf_ccp_opt_length, tvb, offset + 1, 1, ENC_NA);
  2702. }
  2703. /* http://tools.ietf.org/html/rfc1962 */
  2704. static void dissect_ccp_oui_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  2705. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  2706. {
  2707. proto_tree *field_tree;
  2708. proto_item *tf, *ti;
  2709. guint32 oui;
  2710. const gchar *manuf;
  2711. oui = tvb_get_ntoh24(tvb, offset + 2);
  2712. tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
  2713. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  2714. dissect_ccp_opt_type_len(tvb, offset, field_tree, optp->name);
  2715. ti = proto_tree_add_uint_format_value(field_tree, hf_ccp_opt_oui, tvb,
  2716. offset + 2, 3, oui, "%02x:%02x:%02x",
  2717. (oui >> 16) & 0xff, (oui >> 8) & 0xff, oui & 0xff);
  2718. manuf = uint_get_manuf_name_if_known(oui);
  2719. if (manuf)
  2720. proto_item_append_text(ti, "(%s)", manuf);
  2721. proto_tree_add_item(field_tree, hf_ccp_opt_subtype, tvb, offset + 5, 1,
  2722. ENC_NA);
  2723. if (length > 6) {
  2724. proto_tree_add_item(field_tree, hf_ccp_opt_data, tvb, offset + 6,
  2725. length - 6, ENC_NA);
  2726. }
  2727. }
  2728. /* The following configuration option types are mentioned at
  2729. * http://www.iana.org/assignments/ppp-numbers as referencing RFC1962; however,
  2730. * RFC1962 only mentions Proprietary Compression OUI in section 4.1. These
  2731. * others are therefore being treated as section 4.2 "Other Compression Types",
  2732. * in terms of how they are dissected:
  2733. * 1) Predictor type 1
  2734. * 2) Predictor type 2
  2735. * 3) Puddle Jumper
  2736. * 16) Hewlett-Packard PPC
  2737. * 20) V.42bis compression
  2738. */
  2739. static void dissect_ccp_other_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  2740. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  2741. {
  2742. proto_tree *field_tree;
  2743. proto_item *tf;
  2744. tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
  2745. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  2746. dissect_ccp_opt_type_len(tvb, offset, field_tree, optp->name);
  2747. if (length > 2) {
  2748. proto_tree_add_item(field_tree, hf_ccp_opt_data, tvb, offset + 2,
  2749. length - 2, ENC_NA);
  2750. }
  2751. }
  2752. /* http://tools.ietf.org/html/rfc1974 */
  2753. static void
  2754. dissect_ccp_stac_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  2755. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  2756. {
  2757. proto_item *tf;
  2758. proto_tree *field_tree;
  2759. const char *stac_ascend = "Stac Electronics LZS (Ascend Proprietary version)";
  2760. static const int *check_mode_fields[] = {
  2761. &hf_ccp_opt_cm_reserved,
  2762. &hf_ccp_opt_cm_check_mode,
  2763. NULL
  2764. };
  2765. if (length == 6) {
  2766. tf = proto_tree_add_text(tree, tvb, offset, length, "%s", stac_ascend);
  2767. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  2768. dissect_ccp_opt_type_len(tvb, offset, field_tree, stac_ascend);
  2769. /* We don't know how to decode the following 4 octets, since
  2770. there are no public documents that describe their usage. */
  2771. proto_tree_add_item(field_tree, hf_ccp_opt_data, tvb, offset + 2,
  2772. length - 2, ENC_NA);
  2773. } else {
  2774. tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
  2775. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  2776. dissect_ccp_opt_type_len(tvb, offset, field_tree, optp->name);
  2777. proto_tree_add_item(field_tree, hf_ccp_opt_history_count, tvb,
  2778. offset + 2, 2, ENC_BIG_ENDIAN);
  2779. proto_tree_add_bitmask(field_tree, tvb, offset + 4, hf_ccp_opt_cm,
  2780. ett_ccp_stac_opt_check_mode, check_mode_fields, ENC_NA);
  2781. }
  2782. }
  2783. /*
  2784. * Microsoft Point-To-Point Compression (MPPC) and Encryption (MPPE)
  2785. * supported bits.
  2786. */
  2787. #define MPPC_SUPPORTED_BITS_C 0x00000001 /* MPPC negotiation */
  2788. #define MPPE_SUPPORTED_BITS_D 0x00000010 /* Obsolete */
  2789. #define MPPE_SUPPORTED_BITS_L 0x00000020 /* 40-bit encryption */
  2790. #define MPPE_SUPPORTED_BITS_S 0x00000040 /* 128-bit encryption */
  2791. #define MPPE_SUPPORTED_BITS_M 0x00000080 /* 56-bit encryption */
  2792. #define MPPE_SUPPORTED_BITS_H 0x01000000 /* stateless mode */
  2793. static const true_false_string ccp_mppe_h_tfs = {
  2794. "Stateless mode ON",
  2795. "Stateless mode OFF"
  2796. };
  2797. static const true_false_string ccp_mppe_m_tfs = {
  2798. "56-bit encryption ON",
  2799. "56-bit encryption OFF"
  2800. };
  2801. static const true_false_string ccp_mppe_s_tfs = {
  2802. "128-bit encryption ON",
  2803. "128-bit encryption OFF"
  2804. };
  2805. static const true_false_string ccp_mppe_l_tfs = {
  2806. "40-bit encryption ON",
  2807. "40-bit encryption OFF"
  2808. };
  2809. static const true_false_string ccp_mppe_d_tfs = {
  2810. "Obsolete (should NOT be 1)",
  2811. "Obsolete (should ALWAYS be 0)"
  2812. };
  2813. static const true_false_string ccp_mppe_c_tfs = {
  2814. "Desire to negotiate MPPC",
  2815. "No desire to negotiate MPPC"
  2816. };
  2817. /* http://tools.ietf.org/html/rfc2118,
  2818. * http://tools.ietf.org/html/rfc3078 */
  2819. static void
  2820. dissect_ccp_mppe_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  2821. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  2822. {
  2823. proto_item *tf;
  2824. proto_tree *field_tree;
  2825. static const int *supported_bits_fields[] = {
  2826. &hf_ccp_opt_supported_bits_h,
  2827. &hf_ccp_opt_supported_bits_m,
  2828. &hf_ccp_opt_supported_bits_s,
  2829. &hf_ccp_opt_supported_bits_l,
  2830. &hf_ccp_opt_supported_bits_d,
  2831. &hf_ccp_opt_supported_bits_c,
  2832. NULL
  2833. };
  2834. tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
  2835. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  2836. dissect_ccp_opt_type_len(tvb, offset, field_tree, optp->name);
  2837. proto_tree_add_bitmask(field_tree, tvb, offset + 2,
  2838. hf_ccp_opt_supported_bits, ett_ccp_mppe_opt_supp_bits,
  2839. supported_bits_fields, ENC_BIG_ENDIAN);
  2840. }
  2841. /* http://tools.ietf.org/html/rfc1993 */
  2842. static void dissect_ccp_gfza_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  2843. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  2844. {
  2845. proto_tree *field_tree;
  2846. proto_item *tf;
  2847. tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
  2848. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  2849. dissect_ccp_opt_type_len(tvb, offset, field_tree, optp->name);
  2850. proto_tree_add_item(field_tree, hf_ccp_opt_history, tvb, offset + 2, 1,
  2851. ENC_NA);
  2852. if (length > 3) {
  2853. proto_tree_add_item(field_tree, hf_ccp_opt_version, tvb, offset + 3,
  2854. length - 3, ENC_NA);
  2855. }
  2856. }
  2857. /* http://tools.ietf.org/html/rfc1977 */
  2858. static void
  2859. dissect_ccp_bsdcomp_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  2860. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  2861. {
  2862. proto_item *tf;
  2863. proto_tree *field_tree;
  2864. static const int *vd_fields[] = {
  2865. &hf_ccp_opt_vd_vers,
  2866. &hf_ccp_opt_vd_dict,
  2867. NULL
  2868. };
  2869. tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
  2870. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  2871. dissect_ccp_opt_type_len(tvb, offset, field_tree, optp->name);
  2872. proto_tree_add_bitmask(field_tree, tvb, offset + 2, hf_ccp_opt_vd,
  2873. *optp->subtree_index, vd_fields, ENC_BIG_ENDIAN);
  2874. }
  2875. /* http://tools.ietf.org/html/rfc1967 */
  2876. static void
  2877. dissect_ccp_lzsdcp_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  2878. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  2879. {
  2880. proto_item *tf;
  2881. proto_tree *field_tree;
  2882. tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
  2883. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  2884. dissect_ccp_opt_type_len(tvb, offset, field_tree, optp->name);
  2885. proto_tree_add_item(field_tree, hf_ccp_opt_history_count, tvb,
  2886. offset + 2, 2, ENC_BIG_ENDIAN);
  2887. proto_tree_add_item(field_tree, hf_ccp_opt_check_mode, tvb, offset + 4, 1,
  2888. ENC_NA);
  2889. proto_tree_add_item(field_tree, hf_ccp_opt_process_mode, tvb, offset + 5,
  2890. 1, ENC_NA);
  2891. }
  2892. /* http://tools.ietf.org/html/rfc1975 */
  2893. static void
  2894. dissect_ccp_mvrca_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  2895. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  2896. {
  2897. proto_item *tf;
  2898. proto_tree *field_tree;
  2899. tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
  2900. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  2901. dissect_ccp_opt_type_len(tvb, offset, field_tree, optp->name);
  2902. proto_tree_add_item(field_tree, hf_ccp_opt_fe, tvb, offset + 2, 1, ENC_NA);
  2903. proto_tree_add_item(field_tree, hf_ccp_opt_p, tvb, offset + 2, 1, ENC_NA);
  2904. proto_tree_add_item(field_tree, hf_ccp_opt_History, tvb, offset + 2, 1,
  2905. ENC_NA);
  2906. proto_tree_add_item(field_tree, hf_ccp_opt_contexts, tvb, offset + 3, 1,
  2907. ENC_NA);
  2908. }
  2909. /* http://tools.ietf.org/html/rfc1976 */
  2910. static void
  2911. dissect_ccp_dce_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  2912. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  2913. {
  2914. proto_item *tf;
  2915. proto_tree *field_tree;
  2916. tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
  2917. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  2918. dissect_ccp_opt_type_len(tvb, offset, field_tree, optp->name);
  2919. proto_tree_add_item(field_tree, hf_ccp_opt_mode, tvb, offset + 2, 1,
  2920. ENC_NA);
  2921. }
  2922. static const value_string deflate_method_vals[] = {
  2923. {8, "zlib compression"},
  2924. {0, NULL}
  2925. };
  2926. static const value_string deflate_chk_vals[] = {
  2927. {0, "sequence number check method"},
  2928. {0, NULL}
  2929. };
  2930. /* http://tools.ietf.org/html/rfc1979 */
  2931. static void
  2932. dissect_ccp_deflate_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  2933. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  2934. {
  2935. proto_item *tf;
  2936. proto_tree *field_tree;
  2937. guint8 window;
  2938. tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
  2939. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  2940. dissect_ccp_opt_type_len(tvb, offset, field_tree, optp->name);
  2941. window = tvb_get_guint8(tvb, offset + 2);
  2942. proto_tree_add_uint_format_value(field_tree, hf_ccp_opt_window, tvb,
  2943. offset + 2, 1, window, "%u", 1 << (hi_nibble(window) + 8));
  2944. proto_tree_add_item(field_tree, hf_ccp_opt_method, tvb, offset + 2, 1,
  2945. ENC_NA);
  2946. proto_tree_add_item(field_tree, hf_ccp_opt_mbz, tvb, offset + 3, 1,
  2947. ENC_NA);
  2948. proto_tree_add_item(field_tree, hf_ccp_opt_chk, tvb, offset + 3, 1,
  2949. ENC_NA);
  2950. }
  2951. static const range_string v44lzjh_mode_dict_rvals[] = {
  2952. {0, 0, "Datagram Mode (one dictionary and no history)"},
  2953. {1, 1, "Multi-Datagram Mode (one dictionary with history)"},
  2954. {2, G_MAXUINT16, "Individual Link Mode" /* "(and proposed number of
  2955. dictionaries each with a
  2956. corresponding history" */},
  2957. {0, 0, NULL}
  2958. };
  2959. /* http://www.watersprings.org/pub/id/draft-heath-ppp-v44-01.txt */
  2960. static void dissect_ccp_v44lzjh_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  2961. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  2962. {
  2963. proto_item *tf;
  2964. proto_tree *field_tree;
  2965. tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
  2966. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  2967. dissect_ccp_opt_type_len(tvb, offset, field_tree, optp->name);
  2968. proto_tree_add_item(field_tree, hf_ccp_opt_mode_dictcount, tvb, offset + 2,
  2969. 2, ENC_BIG_ENDIAN);
  2970. if (length > 4) {
  2971. proto_tree_add_item(field_tree, hf_ccp_opt_dict_size, tvb, offset + 4,
  2972. 2, ENC_BIG_ENDIAN);
  2973. if (length > 6) {
  2974. proto_tree_add_item(field_tree, hf_ccp_opt_history_length, tvb,
  2975. offset + 6, 2, ENC_BIG_ENDIAN);
  2976. }
  2977. }
  2978. }
  2979. static void
  2980. dissect_cbcp_no_callback_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  2981. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  2982. {
  2983. proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
  2984. }
  2985. static void
  2986. dissect_cbcp_callback_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  2987. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  2988. {
  2989. proto_item *tf;
  2990. proto_tree *field_tree;
  2991. proto_tree *addr_tree;
  2992. guint8 addr_type;
  2993. guint addr_len;
  2994. tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
  2995. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  2996. proto_tree_add_text(field_tree, tvb, offset + 2, 1, "Callback delay: %u",
  2997. tvb_get_guint8(tvb, offset + 2));
  2998. offset += 3;
  2999. length -= 3;
  3000. while (length > 0) {
  3001. proto_tree_add_text(field_tree, tvb, offset, length,
  3002. "Callback Address");
  3003. addr_type = tvb_get_guint8(tvb, offset);
  3004. addr_tree = proto_item_add_subtree(tf, ett_cbcp_callback_opt_addr);
  3005. proto_tree_add_text(addr_tree, tvb, offset, 1, "Address Type: %s (%u)",
  3006. ((addr_type == 1) ? "PSTN/ISDN" : "Other"), addr_type);
  3007. offset++;
  3008. length--;
  3009. addr_len = tvb_strsize(tvb, offset);
  3010. if (addr_len > length) {
  3011. proto_tree_add_text(addr_tree, tvb, offset, length,
  3012. "Address: (runs past end of option)");
  3013. break;
  3014. }
  3015. proto_tree_add_text(addr_tree, tvb, offset, addr_len, "Address: %s",
  3016. tvb_format_text(tvb, offset, addr_len - 1));
  3017. offset += addr_len;
  3018. length -= addr_len;
  3019. }
  3020. }
  3021. static void
  3022. dissect_bacp_favored_peer_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  3023. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  3024. {
  3025. proto_item *tf;
  3026. proto_tree *field_tree;
  3027. tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
  3028. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  3029. proto_tree_add_text(field_tree, tvb, offset + 2, 4, "Magic number: 0x%08x",
  3030. tvb_get_ntohl(tvb, offset + 2));
  3031. }
  3032. static void
  3033. dissect_bap_link_type_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  3034. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  3035. {
  3036. proto_item *tf;
  3037. proto_tree *field_tree;
  3038. guint8 link_type;
  3039. tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
  3040. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  3041. proto_tree_add_text(field_tree, tvb, offset + 2, 2, "Link Speed: %u kbps",
  3042. tvb_get_ntohs(tvb, offset + 2));
  3043. link_type = tvb_get_guint8(tvb, offset + 4);
  3044. proto_tree_add_text(field_tree, tvb, offset + 4, 1, "Link Type: %s (%u)",
  3045. val_to_str_const(link_type, bap_link_type_vals, "Unknown"), link_type);
  3046. }
  3047. static void
  3048. dissect_bap_phone_delta_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  3049. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  3050. {
  3051. proto_item *tf;
  3052. proto_tree *field_tree;
  3053. proto_item *ti;
  3054. proto_tree *suboption_tree;
  3055. guint8 subopt_type;
  3056. guint8 subopt_len;
  3057. tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
  3058. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  3059. offset += 2;
  3060. length -= 2;
  3061. while (length > 0) {
  3062. subopt_type = tvb_get_guint8(tvb, offset);
  3063. subopt_len = tvb_get_guint8(tvb, offset + 1);
  3064. ti = proto_tree_add_text(field_tree, tvb, offset, subopt_len,
  3065. "Sub-Option (%u byte%s)", subopt_len,
  3066. plurality(subopt_len, "", "s"));
  3067. suboption_tree = proto_item_add_subtree(ti,
  3068. ett_bap_phone_delta_subopt);
  3069. proto_tree_add_text(suboption_tree, tvb, offset, 1,
  3070. "Sub-Option Type: %s (%u)", val_to_str_const(subopt_type,
  3071. bap_phone_delta_subopt_vals, "Unknown"), subopt_type);
  3072. if (subopt_len < 2) {
  3073. proto_tree_add_text(suboption_tree, tvb, offset + 1, 1,
  3074. "Sub-Option Length: %u (invalid, must be >= 2)", subopt_len);
  3075. return;
  3076. }
  3077. if (subopt_len > length) {
  3078. proto_tree_add_text(suboption_tree, tvb, offset + 1, 1,
  3079. "Sub-Option Length: %u (invalid, must be <= length remaining "
  3080. "in option %u)", subopt_len, length);
  3081. return;
  3082. }
  3083. proto_tree_add_text(suboption_tree, tvb, offset + 1, 1,
  3084. "Sub-Option Length: %u", subopt_len);
  3085. switch (subopt_type) {
  3086. case BAP_PHONE_DELTA_SUBOPT_UNIQ_DIGIT:
  3087. if (subopt_len == 3) {
  3088. proto_tree_add_text(suboption_tree, tvb, offset + 2, 1,
  3089. "Unique Digit: %u", tvb_get_guint8(tvb, offset + 2));
  3090. } else {
  3091. proto_tree_add_text(suboption_tree, tvb, offset + 1, 1,
  3092. "Invalid suboption length: %u (must be == 3)", subopt_len);
  3093. }
  3094. break;
  3095. case BAP_PHONE_DELTA_SUBOPT_SUBSC_NUM:
  3096. if (subopt_len > 2) {
  3097. proto_tree_add_text(suboption_tree, tvb, offset + 2,
  3098. subopt_len - 2, "Subscriber Number: %s",
  3099. tvb_format_text(tvb, offset + 2, subopt_len - 2));
  3100. } else {
  3101. proto_tree_add_text(suboption_tree, tvb, offset + 1, 1,
  3102. "Invalid suboption length: %u (must be > 2)", subopt_len);
  3103. }
  3104. break;
  3105. case BAP_PHONE_DELTA_SUBOPT_PHONENUM_SUBADDR:
  3106. if (subopt_len > 2) {
  3107. proto_tree_add_text(suboption_tree, tvb, offset + 2,
  3108. subopt_len - 2, "Phone Number Sub Address: %s",
  3109. tvb_format_text(tvb, offset + 2, subopt_len - 2));
  3110. } else {
  3111. proto_tree_add_text(suboption_tree, tvb, offset + 1, 1,
  3112. "Invalid suboption length: %u (must be > 2)", subopt_len);
  3113. }
  3114. break;
  3115. default:
  3116. if (subopt_len > 2) {
  3117. proto_tree_add_text(suboption_tree, tvb, offset + 2,
  3118. subopt_len - 2, "Unknown");
  3119. } else {
  3120. proto_tree_add_text(suboption_tree, tvb, offset + 1, 1,
  3121. "Invalid suboption length: %u (must be > 2)", subopt_len);
  3122. }
  3123. break;
  3124. }
  3125. offset += subopt_len;
  3126. length -= subopt_len;
  3127. }
  3128. }
  3129. static void
  3130. dissect_bap_reason_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  3131. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  3132. {
  3133. if (length > 2) {
  3134. proto_tree_add_text(tree, tvb, offset, length, "%s: %s", optp->name,
  3135. tvb_format_text(tvb, offset + 2, length - 2));
  3136. }
  3137. }
  3138. static void
  3139. dissect_bap_link_disc_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  3140. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  3141. {
  3142. proto_tree_add_text(tree, tvb, offset, length, "%s: 0x%04x", optp->name,
  3143. tvb_get_ntohs(tvb, offset + 2));
  3144. }
  3145. static void
  3146. dissect_bap_call_status_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  3147. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  3148. {
  3149. proto_item *tf;
  3150. proto_tree *field_tree;
  3151. guint8 status, action;
  3152. tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
  3153. field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
  3154. status = tvb_get_guint8(tvb, offset + 2);
  3155. proto_tree_add_text(field_tree, tvb, offset + 2, 1, "Status: %s (0x%02x)",
  3156. val_to_str_ext_const(status, &q931_cause_code_vals_ext, "Unknown"),
  3157. status);
  3158. action = tvb_get_guint8(tvb, offset + 3);
  3159. proto_tree_add_text(field_tree, tvb, offset + 3, 1, "Action: %s (0x%02x)",
  3160. val_to_str_const(action, bap_call_status_opt_action_vals, "Unknown"),
  3161. action);
  3162. }
  3163. static void
  3164. dissect_vsncp_pdnid_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  3165. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  3166. {
  3167. guint8 PDNID;
  3168. PDNID = tvb_get_guint8(tvb, offset + 2);
  3169. proto_tree_add_text(tree, tvb, offset, length, "%s: 0x%02x", optp->name,
  3170. PDNID);
  3171. }
  3172. static void
  3173. dissect_vsncp_attachtype_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  3174. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  3175. {
  3176. static const value_string attach_vals[] = {
  3177. {1, "Initial Attach"},
  3178. {3, "Handover Attach"},
  3179. {0, NULL}
  3180. };
  3181. guint8 attach;
  3182. if (tree) {
  3183. attach = tvb_get_guint8(tvb, offset + 2);
  3184. proto_tree_add_text(tree, tvb, offset, length, "%s: %s (0x%02x)",
  3185. optp->name, val_to_str_const(attach , attach_vals, "Unknown"),
  3186. attach);
  3187. }
  3188. }
  3189. static void
  3190. dissect_vsncp_pdntype_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  3191. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  3192. {
  3193. static const value_string pdntype_vals[] = {
  3194. {1, "IPv4"},
  3195. {2, "IPv6"},
  3196. {3, "IPv6/IPv4"},
  3197. {0, NULL}
  3198. };
  3199. guint8 pdntype;
  3200. if (tree) {
  3201. pdntype = tvb_get_guint8(tvb, offset + 2);
  3202. proto_tree_add_text(tree, tvb, offset, length, "%s: %s (0x%02x)",
  3203. optp->name, val_to_str_const(pdntype, pdntype_vals, "Unknown"),
  3204. pdntype);
  3205. }
  3206. }
  3207. static void
  3208. dissect_vsncp_errorcode_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  3209. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  3210. {
  3211. static const value_string errorcode_vals[] = {
  3212. {0, "General Eror"},
  3213. {1, "Unauthorized APN"},
  3214. {2, "PDN Limit Exceeded"},
  3215. {3, "NO PG-W Available"},
  3216. {4, "P-GW Unreachable"},
  3217. {5, "P-GW Reject"},
  3218. {6, "Insufficient Parameters"},
  3219. {7, "Resource Unavailable"},
  3220. {8, "Admin Prohibited"},
  3221. {9, "PDN-ID Already in Use"},
  3222. {10, "Subscription Limitation"},
  3223. {11, "PDN connection already exists for APN"},
  3224. {12, "Emergency services not supported"},
  3225. {13, "Reconnect to this APN not allowed"},
  3226. {14, "APN congested"},
  3227. {0, NULL}
  3228. };
  3229. guint8 pdntype;
  3230. if (tree) {
  3231. pdntype = tvb_get_guint8(tvb, offset + 2);
  3232. proto_tree_add_text(tree, tvb, offset, length, "%s: %s (0x%02x)",
  3233. optp->name, val_to_str_const(pdntype, errorcode_vals, "Unknown"),
  3234. pdntype);
  3235. }
  3236. }
  3237. static void
  3238. dissect_vsncp_pdnaddress_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  3239. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  3240. {
  3241. guint8 pdnaddtype;
  3242. static const value_string pdntype_vals[] = {
  3243. {0, "Initial Request by UE"},
  3244. {1, "IPv4 Address"},
  3245. {2, "IPv6 Address"},
  3246. {3, "IPv6/IPv4 Address"},
  3247. {0, NULL}
  3248. };
  3249. proto_item *tf;
  3250. proto_tree *field_tree;
  3251. tf = proto_tree_add_text(tree, tvb, offset, length, "%s: (%d byte%s)",
  3252. optp->name, length, plurality(length, "", "s"));
  3253. field_tree = proto_item_add_subtree(tf, ett_lcp_options);
  3254. pdnaddtype = tvb_get_guint8(tvb, offset + 2);
  3255. proto_tree_add_text(field_tree, tvb, offset + 2, 1,
  3256. "PDN Type (%s): 0x%02x",
  3257. val_to_str_const(pdnaddtype, pdntype_vals, "Unknown"), pdnaddtype);
  3258. switch (pdnaddtype) {
  3259. case 1:
  3260. proto_tree_add_text(field_tree, tvb, offset + 3, length - 3, "%s: %s",
  3261. val_to_str_const(pdnaddtype, pdntype_vals, "Unknown"),
  3262. tvb_ip_to_str(tvb, offset + 3));
  3263. break;
  3264. case 2:
  3265. {
  3266. struct e_in6_addr *ad = wmem_new0(wmem_packet_scope(),struct e_in6_addr);
  3267. tvb_memcpy(tvb, &ad->bytes[8], offset + 3, 8);
  3268. proto_tree_add_text(field_tree, tvb, offset + 3, length - 3, "%s: %s",
  3269. val_to_str_const(pdnaddtype, pdntype_vals, "Unknown"),
  3270. ip6_to_str(ad));
  3271. break;
  3272. }
  3273. case 3:
  3274. {
  3275. struct e_in6_addr *ad = ep_new0(struct e_in6_addr);
  3276. tvb_memcpy(tvb, &ad->bytes[8], offset + 3, 8);
  3277. proto_tree_add_text(field_tree, tvb, offset + 3, length - 3, "%s: %s",
  3278. val_to_str_const(pdnaddtype, pdntype_vals, "Unknown"),
  3279. ip6_to_str(ad));
  3280. proto_tree_add_text(field_tree, tvb, offset + 11, length - 11,
  3281. "%s: %s", val_to_str_const(pdnaddtype, pdntype_vals, "Unknown"),
  3282. tvb_ip_to_str(tvb, offset + 11));
  3283. break;
  3284. }
  3285. default:
  3286. break;
  3287. }
  3288. }
  3289. static void
  3290. dissect_vsncp_ipv4address_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  3291. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  3292. {
  3293. proto_tree_add_text(tree, tvb, offset, length, "%s: %s", optp->name,
  3294. tvb_ip_to_str(tvb, offset + 2));
  3295. }
  3296. static void
  3297. dissect_vsncp_apname_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  3298. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  3299. {
  3300. proto_item *tf;
  3301. proto_tree *field_tree;
  3302. tf = proto_tree_add_text(tree, tvb, offset, length, "%s: (%d byte%s)",
  3303. optp->name, length, plurality(length, "", "s"));
  3304. field_tree = proto_item_add_subtree(tf, ett_lcp_options);
  3305. if (length > 2) {
  3306. guint8 i = 0;
  3307. guint8 j = 1;
  3308. guint8 lengthofapn;
  3309. int off = offset + 2;
  3310. while (i < (length - 2)) {
  3311. lengthofapn = tvb_get_guint8(tvb, off++);
  3312. proto_tree_add_text(field_tree, tvb, off, lengthofapn,
  3313. "Label%d (%d byte%s): %s", j++, lengthofapn,
  3314. plurality(lengthofapn, "", "s"),
  3315. tvb_format_text(tvb, off, lengthofapn));
  3316. off += lengthofapn;
  3317. i += lengthofapn + 1;
  3318. }
  3319. }
  3320. }
  3321. static void
  3322. dissect_vsncp_addressalloc_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  3323. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  3324. {
  3325. static const value_string alloc_vals[] = {
  3326. {0, "Null Value (Attach or Handover)"},
  3327. {18, "New PDN type due to network preference"},
  3328. {255, "Success"},
  3329. {0, NULL}
  3330. };
  3331. guint8 alloc;
  3332. if (tree) {
  3333. alloc = tvb_get_guint8(tvb, offset + 2);
  3334. proto_tree_add_text(tree, tvb, offset, length, "%s: %s (0x%02x)",
  3335. optp->name, val_to_str_const(alloc, alloc_vals, "Unknown"), alloc);
  3336. }
  3337. }
  3338. static void
  3339. dissect_vsncp_apn_ambr_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
  3340. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  3341. {
  3342. proto_item *tf;
  3343. proto_tree *field_tree;
  3344. if (tree) {
  3345. tf = proto_tree_add_text(tree, tvb, offset, length, "%s: (%d byte%s)",
  3346. optp->name, length, plurality(length, "", "s"));
  3347. field_tree = proto_item_add_subtree(tf, ett_lcp_options);
  3348. /*de_esm_apn_aggr_max_br(tvb, field_tree, pinfo, offset, length, NULL, 0);*/
  3349. proto_tree_add_text(field_tree, tvb, offset, length, "AMBR Data");
  3350. }
  3351. }
  3352. static void
  3353. dissect_vsncp_ipv6_hsgw_lla_iid_opt(const ip_tcp_opt *optp _U_, tvbuff_t *tvb,
  3354. int offset, guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  3355. {
  3356. proto_item *tf;
  3357. proto_tree *field_tree;
  3358. if (tree) {
  3359. tf = proto_tree_add_text(tree, tvb, offset, length, "%s: (%d byte%s)",
  3360. optp->name, length, plurality(length, "", "s"));
  3361. field_tree = proto_item_add_subtree(tf, ett_lcp_options);
  3362. proto_tree_add_text(field_tree, tvb, offset, length, "IPv6 interface identifier");
  3363. }
  3364. }
  3365. static void
  3366. dissect_vsncp_pco_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  3367. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  3368. {
  3369. /* Ch 10.5.6.3 3GPP TS 24.008 version 11.5.0 Release 11 */
  3370. static const value_string pco_vals[] = {
  3371. {0x8021, "IPCP (DNS Address Request)"},
  3372. {0x0001, "P-CSCF Address Request (IPv6)"},
  3373. {0x0005, "MS Support of Network Requested Bearer Control indicator"},
  3374. {0x0003, "DNS Server Address (IPv6)"},
  3375. {0x000A, "IP address allocation via NAS signalling"},
  3376. {0x000B, "IPv4 address allocation via DHCPv4"},
  3377. {0x000D, "DNS Server IPv4 Address Request"},
  3378. {0, NULL}
  3379. };
  3380. int off = offset + 3;
  3381. guint8 i = 0;
  3382. guint16 pcotype;
  3383. guint8 len;
  3384. proto_item *tf;
  3385. proto_tree *field_tree;
  3386. tf = proto_tree_add_text(tree, tvb, offset, length, "%s: (%d byte%s)",
  3387. optp->name, length, plurality(length, "", "s"));
  3388. field_tree = proto_item_add_subtree(tf, ett_lcp_options);
  3389. while (i < (length - 3)) {
  3390. pcotype = tvb_get_ntohs(tvb, off);
  3391. len = tvb_get_guint8(tvb, (off + 2));
  3392. proto_tree_add_text(field_tree, tvb, off, 2, "Protocol: %s (0x%02x)",
  3393. val_to_str_const(pcotype, pco_vals, "Unknown"), pcotype);
  3394. proto_tree_add_text(field_tree, tvb, off + 2, 1, "Length:(0x%02x)",
  3395. len);
  3396. if (len > 0) {
  3397. proto_tree_add_text(field_tree, tvb, off + 3, len,
  3398. "Data (%d byte%s)", len, plurality(len, "", "s"));
  3399. }
  3400. off += 3 + len;
  3401. i += 3 + len;
  3402. }
  3403. }
  3404. static void
  3405. dissect_cp(tvbuff_t *tvb, int proto_id, int proto_subtree_index,
  3406. const value_string *proto_vals, int options_subtree_index,
  3407. const ip_tcp_opt *opts, int nopts, packet_info *pinfo, proto_tree *tree)
  3408. {
  3409. proto_item *ti;
  3410. proto_tree *fh_tree = NULL;
  3411. guint8 code;
  3412. int length, offset;
  3413. code = tvb_get_guint8(tvb, 0);
  3414. length = tvb_get_ntohs(tvb, 2);
  3415. col_set_str(pinfo->cinfo, COL_PROTOCOL,
  3416. proto_get_protocol_short_name(find_protocol_by_id(proto_id)));
  3417. col_add_str(pinfo->cinfo, COL_INFO,
  3418. val_to_str_const(code, proto_vals, "Unknown"));
  3419. if (tree) {
  3420. ti = proto_tree_add_item(tree, proto_id, tvb, 0, length, ENC_NA);
  3421. fh_tree = proto_item_add_subtree(ti, proto_subtree_index);
  3422. proto_tree_add_uint_format_value(fh_tree, hf_ppp_code, tvb, 0, 1, code,
  3423. "%s (%u)", val_to_str_const(code, proto_vals, "Unknown"), code);
  3424. proto_tree_add_item(fh_tree, hf_ppp_identifier, tvb, 1, 1, ENC_NA);
  3425. proto_tree_add_item(fh_tree, hf_ppp_length, tvb, 2, 2, ENC_BIG_ENDIAN);
  3426. }
  3427. offset = 4;
  3428. length -= 4;
  3429. switch (code) {
  3430. case VNDRSPCFC:
  3431. if (tree) {
  3432. guint32 oui;
  3433. const gchar *manuf;
  3434. proto_tree_add_item(fh_tree, hf_ppp_magic_number, tvb, offset, 4,
  3435. ENC_BIG_ENDIAN);
  3436. oui = tvb_get_ntoh24(tvb, offset + 4);
  3437. ti = proto_tree_add_uint_format_value(fh_tree, hf_ppp_oui, tvb,
  3438. offset + 4, 3, oui, "%02x:%02x:%02x", (oui >> 16) & 0xff,
  3439. (oui >> 8) & 0xff, oui & 0xff);
  3440. manuf = uint_get_manuf_name_if_known(oui);
  3441. if (manuf){
  3442. proto_item_append_text(ti, "(%s)", manuf);
  3443. }else{
  3444. /* check if we have the name in oui_vals */
  3445. manuf = try_val_to_str(oui,oui_vals);
  3446. if (manuf){
  3447. proto_item_append_text(ti, "(%s)", manuf);
  3448. }
  3449. }
  3450. proto_tree_add_item(fh_tree, hf_ppp_kind, tvb, offset + 7, 1,
  3451. ENC_NA);
  3452. if (length > 8) {
  3453. proto_tree_add_item(fh_tree, hf_ppp_data, tvb, offset + 8,
  3454. length - 8, ENC_NA);
  3455. }
  3456. }
  3457. break;
  3458. case CONFREQ:
  3459. case CONFACK:
  3460. case CONFNAK:
  3461. case CONFREJ:
  3462. if (length > 0) {
  3463. proto_item *tf;
  3464. proto_tree *field_tree;
  3465. tf = proto_tree_add_text(fh_tree, tvb, offset, length,
  3466. "Options: (%d byte%s)", length, plurality(length, "", "s"));
  3467. field_tree = proto_item_add_subtree(tf, options_subtree_index);
  3468. dissect_ip_tcp_options(tvb, offset, length, opts, nopts, -1, &PPP_OPT_TYPES,
  3469. &ei_ppp_opt_len_invalid, pinfo, field_tree, NULL, NULL);
  3470. }
  3471. break;
  3472. case CODEREJ:
  3473. if (tree && (length > 0)) {
  3474. /* TODO: Decode the rejected packet here ... but wait until we have
  3475. * a valid capture file with a CODEREJ, since the only capture file
  3476. * with CODEREJ packets in it that I know of is pppoe.dump.gz from
  3477. * the menagerie, and that file appears to have malformed CODEREJ
  3478. * packets as they don't include the Code, Identifier or Length
  3479. * fields so it's impossible to do the decode. */
  3480. proto_tree_add_bytes_format(fh_tree, hf_ppp_data, tvb, offset,
  3481. length, NULL, "Rejected Packet (%d byte%s): %s", length,
  3482. plurality(length, "", "s"),
  3483. tvb_bytes_to_str(tvb, offset, length));
  3484. }
  3485. break;
  3486. case PROTREJ: /* LCP only: RFC 1661 */
  3487. if (tree) {
  3488. proto_tree_add_item(fh_tree, hf_lcp_rej_proto, tvb, offset, 2,
  3489. ENC_BIG_ENDIAN);
  3490. }
  3491. if (length > 2) {
  3492. gboolean save_in_error_pkt;
  3493. tvbuff_t *next_tvb;
  3494. guint16 protocol;
  3495. protocol = tvb_get_ntohs(tvb, offset);
  3496. offset += 2;
  3497. length -= 2;
  3498. /*
  3499. * Save the current value of the "we're inside an error packet"
  3500. * flag, and set that flag; subdissectors may treat packets that
  3501. * are the payload of error packets differently from "real"
  3502. * packets.
  3503. */
  3504. save_in_error_pkt = pinfo->flags.in_error_pkt;
  3505. pinfo->flags.in_error_pkt = TRUE;
  3506. /* Decode the rejected packet. */
  3507. next_tvb = tvb_new_subset(tvb, offset, length, length);
  3508. if (!dissector_try_uint(ppp_subdissector_table, protocol, next_tvb,
  3509. pinfo, fh_tree)) {
  3510. call_dissector(data_handle, next_tvb, pinfo, fh_tree);
  3511. }
  3512. /* Restore the "we're inside an error packet" flag. */
  3513. pinfo->flags.in_error_pkt = save_in_error_pkt;
  3514. }
  3515. break;
  3516. case ECHOREQ: /* All 3 are LCP only: RFC 1661 */
  3517. case ECHOREP:
  3518. case DISCREQ:
  3519. if (tree) {
  3520. proto_tree_add_item(fh_tree, hf_lcp_magic_number, tvb, offset, 4,
  3521. ENC_BIG_ENDIAN);
  3522. if (length > 4) {
  3523. proto_tree_add_item(fh_tree, hf_lcp_data, tvb, offset + 4,
  3524. length - 4, ENC_NA);
  3525. }
  3526. }
  3527. break;
  3528. case IDENT: /* LCP only: RFC 1570 */
  3529. if (tree) {
  3530. proto_tree_add_item(fh_tree, hf_lcp_magic_number, tvb, offset, 4,
  3531. ENC_BIG_ENDIAN);
  3532. if (length > 4) {
  3533. proto_tree_add_item(fh_tree, hf_lcp_message, tvb, offset + 4,
  3534. length - 4, ENC_NA);
  3535. }
  3536. }
  3537. break;
  3538. case TIMEREMAIN: /* LCP only: RFC 1570 */
  3539. if (tree) {
  3540. guint32 secs_remaining;
  3541. proto_tree_add_item(fh_tree, hf_lcp_magic_number, tvb, offset, 4,
  3542. ENC_BIG_ENDIAN);
  3543. secs_remaining = tvb_get_ntohl(tvb, offset + 4);
  3544. proto_tree_add_uint_format_value(fh_tree, hf_lcp_secs_remaining,
  3545. tvb, offset + 4, 4, secs_remaining, "%u %s", secs_remaining,
  3546. (secs_remaining == 0xffffffff) ? "(forever)" : "seconds");
  3547. if (length > 8) {
  3548. proto_tree_add_item(fh_tree, hf_lcp_message, tvb, offset + 8,
  3549. length - 8, ENC_NA);
  3550. }
  3551. }
  3552. break;
  3553. case TERMREQ:
  3554. case TERMACK:
  3555. case RESETREQ: /* RESETREQ and RESETACK are CCP only: RFC 1962 */
  3556. case RESETACK:
  3557. default:
  3558. if (tree && (length > 0)) {
  3559. proto_tree_add_item(fh_tree, hf_ppp_data, tvb, offset, length,
  3560. ENC_NA);
  3561. }
  3562. break;
  3563. }
  3564. }
  3565. /* Protocol field compression */
  3566. #define PFC_BIT 0x01
  3567. static void
  3568. dissect_ppp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
  3569. proto_tree *fh_tree, proto_item *ti, int proto_offset)
  3570. {
  3571. guint16 ppp_prot;
  3572. int proto_len;
  3573. tvbuff_t *next_tvb;
  3574. /* Make direction information filterable */
  3575. if (tree &&
  3576. (pinfo->p2p_dir == P2P_DIR_RECV || pinfo->p2p_dir == P2P_DIR_SENT)) {
  3577. proto_item *direction_ti = proto_tree_add_uint(tree, hf_ppp_direction,
  3578. tvb, 0, 0, pinfo->p2p_dir);
  3579. PROTO_ITEM_SET_GENERATED(direction_ti);
  3580. }
  3581. ppp_prot = tvb_get_guint8(tvb, 0);
  3582. if (ppp_prot & PFC_BIT) {
  3583. /* Compressed protocol field - just the byte we fetched. */
  3584. proto_len = 1;
  3585. } else {
  3586. /* Uncompressed protocol field - fetch all of it. */
  3587. ppp_prot = tvb_get_ntohs(tvb, 0);
  3588. proto_len = 2;
  3589. }
  3590. /* If "ti" is not null, it refers to the top-level "proto_ppp" item
  3591. for PPP, and proto_offset is the length of any stuff in the header
  3592. preceding the protocol type, e.g. an HDLC header; add the length
  3593. of the protocol type field to it, and set the length of that item
  3594. to the result. */
  3595. if (ti != NULL)
  3596. proto_item_set_len(ti, proto_offset + proto_len);
  3597. if (tree) {
  3598. proto_tree_add_uint(fh_tree, hf_ppp_protocol, tvb, 0, proto_len,
  3599. ppp_prot);
  3600. }
  3601. next_tvb = tvb_new_subset_remaining(tvb, proto_len);
  3602. /* do lookup with the subdissector table */
  3603. if (!dissector_try_uint(ppp_subdissector_table, ppp_prot, next_tvb, pinfo,
  3604. tree)) {
  3605. col_add_fstr(pinfo->cinfo, COL_PROTOCOL, "0x%04x", ppp_prot);
  3606. col_add_fstr(pinfo->cinfo, COL_INFO, "PPP %s (0x%04x)",
  3607. val_to_str_ext_const(ppp_prot, &ppp_vals_ext, "Unknown"),
  3608. ppp_prot);
  3609. call_dissector(data_handle,next_tvb, pinfo, tree);
  3610. }
  3611. }
  3612. static void
  3613. dissect_lcp_options(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
  3614. {
  3615. dissect_ip_tcp_options(tvb, 0, tvb_reported_length(tvb), lcp_opts,
  3616. N_LCP_OPTS, -1, &PPP_OPT_TYPES, &ei_ppp_opt_len_invalid, pinfo, tree, NULL, NULL);
  3617. }
  3618. /*
  3619. * RFC's 1661, 2153 and 1570.
  3620. */
  3621. static void
  3622. dissect_lcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
  3623. {
  3624. dissect_cp(tvb, proto_lcp, ett_lcp, lcp_vals, ett_lcp_options, lcp_opts,
  3625. N_LCP_OPTS, pinfo, tree);
  3626. }
  3627. static void
  3628. dissect_vsncp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
  3629. {
  3630. proto_item *ti;
  3631. proto_tree *fh_tree = NULL;
  3632. proto_item *tf;
  3633. proto_tree *field_tree;
  3634. guint8 code;
  3635. guint8 id;
  3636. int length, offset;
  3637. code = tvb_get_guint8(tvb, 0);
  3638. id = tvb_get_guint8(tvb, 1);
  3639. length = tvb_get_ntohs(tvb, 2);
  3640. col_set_str(pinfo->cinfo, COL_PROTOCOL, "VSNCP");
  3641. col_add_str(pinfo->cinfo, COL_INFO,
  3642. val_to_str_const(code, cp_vals, "Unknown"));
  3643. if (tree) {
  3644. ti = proto_tree_add_item(tree, proto_vsncp, tvb, 0, length, ENC_NA);
  3645. fh_tree = proto_item_add_subtree(ti, ett_vsncp);
  3646. proto_tree_add_text(fh_tree, tvb, 0, 1, "Code: %s (0x%02x)",
  3647. val_to_str_const(code, cp_vals, "Unknown"), code);
  3648. proto_tree_add_text(fh_tree, tvb, 1, 1, "Identifier: 0x%02x", id);
  3649. proto_tree_add_text(fh_tree, tvb, 2, 2, "Length: %u", length);
  3650. proto_tree_add_item(fh_tree, hf_ppp_oui, tvb, 4, 3, ENC_BIG_ENDIAN);
  3651. }
  3652. offset = 7;
  3653. length -= 7;
  3654. switch (code) {
  3655. case CONFREQ:
  3656. case CONFACK:
  3657. case CONFNAK:
  3658. case CONFREJ:
  3659. case TERMREQ:
  3660. case TERMACK:
  3661. if (length > 0) {
  3662. tf = proto_tree_add_text(fh_tree, tvb, offset, length,
  3663. "Options: (%d byte%s)", length,
  3664. plurality(length, "", "s"));
  3665. field_tree = proto_item_add_subtree(tf, ett_vsncp_options);
  3666. dissect_ip_tcp_options(tvb, offset, length, vsncp_opts, N_VSNCP_OPTS, -1, &PPP_OPT_TYPES,
  3667. &ei_ppp_opt_len_invalid, pinfo, field_tree, NULL, NULL);
  3668. }
  3669. break;
  3670. default:
  3671. /* TODO? */
  3672. break;
  3673. }
  3674. }
  3675. static void
  3676. dissect_vsnp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
  3677. {
  3678. proto_item *vsnp_item = NULL;
  3679. proto_tree *vsnp_tree = NULL;
  3680. guint32 offset = 0;
  3681. tvbuff_t *next_tvb;
  3682. col_set_str(pinfo->cinfo, COL_PROTOCOL, "VSNP");
  3683. if (tree) {
  3684. vsnp_item = proto_tree_add_item(tree, proto_vsnp, tvb, 0, -1, ENC_NA);
  3685. vsnp_tree = proto_item_add_subtree(vsnp_item, ett_vsnp);
  3686. proto_tree_add_item(vsnp_tree, hf_vsnp_pdnid, tvb, offset, 1,
  3687. ENC_BIG_ENDIAN);
  3688. }
  3689. next_tvb = tvb_new_subset_remaining(tvb, 1);
  3690. if (!dissector_try_uint(ppp_subdissector_table, PPP_IP, next_tvb, pinfo,
  3691. tree)) {
  3692. col_add_fstr(pinfo->cinfo, COL_PROTOCOL, "0x%04x", PPP_IP);
  3693. col_add_fstr(pinfo->cinfo, COL_INFO, "PPP %s (0x%04x)",
  3694. val_to_str_ext_const(PPP_IP, &ppp_vals_ext, "Unknown"), PPP_IP);
  3695. call_dissector(data_handle, next_tvb, pinfo, tree);
  3696. }
  3697. }
  3698. /*
  3699. * RFC 1332.
  3700. */
  3701. static void
  3702. dissect_ipcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
  3703. {
  3704. dissect_cp(tvb, proto_ipcp, ett_ipcp, cp_vals, ett_ipcp_options, ipcp_opts,
  3705. N_IPCP_OPTS, pinfo, tree);
  3706. }
  3707. /*
  3708. * RFC 3518
  3709. */
  3710. #define BCP_FCS_PRESENT 0x80
  3711. #define BCP_ZEROPAD 0x20
  3712. #define BCP_IS_BCONTROL 0x10
  3713. #define BCP_PADS_MASK 0x0f
  3714. #define BCP_MACT_ETHERNET 1
  3715. #define BCP_MACT_802_4 2
  3716. #define BCP_MACT_802_5_NONCANON 3
  3717. #define BCP_MACT_FDDI_NONCANON 4
  3718. #define BCP_MACT_802_5_CANON 11
  3719. #define BCP_MACT_FDDI_CANON 12
  3720. static const value_string bcp_mac_type_vals[] = {
  3721. {BCP_MACT_ETHERNET, "IEEE 802.3/Ethernet"},
  3722. {BCP_MACT_802_4, "IEEE 802.4"},
  3723. {BCP_MACT_802_5_NONCANON, "IEEE 802.5, non-canonical addresses"},
  3724. {BCP_MACT_FDDI_NONCANON, "FDDI, non-canonical addresses"},
  3725. {BCP_MACT_802_5_CANON, "IEEE 802.5, canonical addresses"},
  3726. {BCP_MACT_FDDI_CANON, "FDDI, canonical addresses"},
  3727. {0, NULL}
  3728. };
  3729. static void
  3730. dissect_bcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
  3731. {
  3732. proto_item *ti = NULL, *flags_item;
  3733. proto_tree *bcp_tree = NULL, *flags_tree;
  3734. int offset = 0;
  3735. guint8 flags;
  3736. guint8 mac_type;
  3737. gint captured_length, reported_length, pad_length;
  3738. tvbuff_t *next_tvb;
  3739. col_set_str(pinfo->cinfo, COL_PROTOCOL, "PPP BCP");
  3740. col_clear(pinfo->cinfo, COL_INFO);
  3741. if (tree) {
  3742. ti = proto_tree_add_item(tree, proto_bcp, tvb, 0, -1, ENC_NA);
  3743. bcp_tree = proto_item_add_subtree(ti, ett_bcp);
  3744. }
  3745. flags = tvb_get_guint8(tvb, offset);
  3746. if (flags & BCP_IS_BCONTROL) {
  3747. col_set_str(pinfo->cinfo, COL_INFO, "Bridge control");
  3748. }
  3749. if (tree) {
  3750. flags_item = proto_tree_add_uint(bcp_tree, hf_bcp_flags, tvb, offset,
  3751. 1, flags);
  3752. flags_tree = proto_item_add_subtree(flags_item, ett_bcp_flags);
  3753. proto_tree_add_boolean(flags_tree, hf_bcp_fcs_present, tvb, offset,
  3754. 1, flags);
  3755. proto_tree_add_boolean(flags_tree, hf_bcp_zeropad, tvb, offset, 1,
  3756. flags);
  3757. proto_tree_add_boolean(flags_tree, hf_bcp_bcontrol, tvb, offset, 1,
  3758. flags);
  3759. proto_tree_add_uint(flags_tree, hf_bcp_pads, tvb, offset, 1, flags);
  3760. }
  3761. offset++;
  3762. mac_type = tvb_get_guint8(tvb, offset);
  3763. if (!(flags & BCP_IS_BCONTROL)) {
  3764. col_add_str(pinfo->cinfo, COL_INFO,
  3765. val_to_str(mac_type, bcp_mac_type_vals,
  3766. "Unknown MAC type %u"));
  3767. }
  3768. if (tree) {
  3769. proto_tree_add_uint(bcp_tree, hf_bcp_mac_type, tvb, offset, 1,
  3770. mac_type);
  3771. }
  3772. offset++;
  3773. switch (mac_type) {
  3774. case BCP_MACT_802_4:
  3775. case BCP_MACT_802_5_NONCANON:
  3776. case BCP_MACT_FDDI_NONCANON:
  3777. case BCP_MACT_802_5_CANON:
  3778. case BCP_MACT_FDDI_CANON:
  3779. if (tree)
  3780. proto_tree_add_text(bcp_tree, tvb, offset, 1, "Pad");
  3781. offset++;
  3782. break;
  3783. default:
  3784. /* TODO? */
  3785. break;
  3786. }
  3787. if (!(flags & BCP_IS_BCONTROL)) {
  3788. captured_length = tvb_length_remaining(tvb, offset);
  3789. reported_length = tvb_reported_length_remaining(tvb, offset);
  3790. pad_length = flags & BCP_PADS_MASK;
  3791. if (reported_length >= pad_length) {
  3792. reported_length -= pad_length;
  3793. if (captured_length > reported_length)
  3794. captured_length = reported_length;
  3795. next_tvb = tvb_new_subset(tvb, offset, captured_length,
  3796. reported_length);
  3797. switch (mac_type) {
  3798. case BCP_MACT_ETHERNET:
  3799. if (flags & BCP_FCS_PRESENT) {
  3800. call_dissector(eth_withfcs_handle, next_tvb, pinfo, tree);
  3801. } else {
  3802. call_dissector(eth_withoutfcs_handle, next_tvb, pinfo,
  3803. tree);
  3804. }
  3805. break;
  3806. case BCP_MACT_802_4:
  3807. case BCP_MACT_802_5_NONCANON:
  3808. case BCP_MACT_FDDI_NONCANON:
  3809. case BCP_MACT_802_5_CANON:
  3810. case BCP_MACT_FDDI_CANON:
  3811. break;
  3812. default:
  3813. call_dissector(data_handle, next_tvb, pinfo, tree);
  3814. break;
  3815. }
  3816. }
  3817. }
  3818. }
  3819. /*
  3820. * RFC 1377.
  3821. */
  3822. static void
  3823. dissect_osinlcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
  3824. {
  3825. dissect_cp(tvb, proto_osinlcp, ett_osinlcp, cp_vals, ett_osinlcp_options,
  3826. osinlcp_opts, N_OSINLCP_OPTS, pinfo, tree);
  3827. }
  3828. /*
  3829. * RFC 1962.
  3830. */
  3831. static void
  3832. dissect_ccp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
  3833. {
  3834. dissect_cp(tvb, proto_ccp, ett_ccp, ccp_vals, ett_ccp_options, ccp_opts,
  3835. N_CCP_OPTS, pinfo, tree);
  3836. }
  3837. /*
  3838. * Callback Control Protocol - see
  3839. *
  3840. * http://www.linet.gr.jp/~manabe/PPxP/doc/Standards/draft-gidwani-ppp-callback-cp-00.txt
  3841. */
  3842. static void
  3843. dissect_cbcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
  3844. {
  3845. dissect_cp(tvb, proto_cbcp, ett_cbcp, cbcp_vals, ett_cbcp_options,
  3846. cbcp_opts, N_CBCP_OPTS, pinfo, tree);
  3847. }
  3848. /*
  3849. * RFC 2125 (BACP and BAP).
  3850. */
  3851. static void
  3852. dissect_bacp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
  3853. {
  3854. dissect_cp(tvb, proto_bacp, ett_bacp, cp_vals, ett_bacp_options, bacp_opts,
  3855. N_BACP_OPTS, pinfo, tree);
  3856. }
  3857. static void
  3858. dissect_bap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
  3859. {
  3860. proto_item *ti;
  3861. proto_tree *fh_tree = NULL;
  3862. proto_item *tf;
  3863. proto_tree *field_tree;
  3864. guint8 type;
  3865. guint8 id;
  3866. int length, offset;
  3867. guint8 resp_code;
  3868. type = tvb_get_guint8(tvb, 0);
  3869. id = tvb_get_guint8(tvb, 1);
  3870. length = tvb_get_ntohs(tvb, 2);
  3871. col_set_str(pinfo->cinfo, COL_PROTOCOL, "PPP BAP");
  3872. col_add_str(pinfo->cinfo, COL_INFO,
  3873. val_to_str_const(type, bap_vals, "Unknown"));
  3874. if (tree) {
  3875. ti = proto_tree_add_item(tree, proto_bap, tvb, 0, length, ENC_NA);
  3876. fh_tree = proto_item_add_subtree(ti, ett_bap_options);
  3877. proto_tree_add_text(fh_tree, tvb, 0, 1, "Type: %s (0x%02x)",
  3878. val_to_str_const(type, bap_vals, "Unknown"), type);
  3879. proto_tree_add_text(fh_tree, tvb, 1, 1, "Identifier: 0x%02x", id);
  3880. proto_tree_add_text(fh_tree, tvb, 2, 2, "Length: %u", length);
  3881. }
  3882. offset = 4;
  3883. length -= 4;
  3884. if (type == BAP_CRES || type == BAP_CBRES ||
  3885. type == BAP_LDQRES || type == BAP_CSRES) {
  3886. resp_code = tvb_get_guint8(tvb, offset);
  3887. proto_tree_add_text(fh_tree, tvb, offset, 1,
  3888. "Response Code: %s (0x%02x)",
  3889. val_to_str_const(resp_code, bap_resp_code_vals, "Unknown"),
  3890. resp_code);
  3891. offset++;
  3892. length--;
  3893. }
  3894. if (length > 0) {
  3895. tf = proto_tree_add_text(fh_tree, tvb, offset, length,
  3896. "Data (%d byte%s)", length, plurality(length, "", "s"));
  3897. field_tree = proto_item_add_subtree(tf, ett_bap_options);
  3898. dissect_ip_tcp_options(tvb, offset, length, bap_opts, N_BAP_OPTS, -1, &PPP_OPT_TYPES,
  3899. &ei_ppp_opt_len_invalid, pinfo, field_tree, NULL, NULL);
  3900. }
  3901. }
  3902. #if 0 /* TODO? */
  3903. static void
  3904. dissect_comp_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
  3905. {
  3906. proto_item *ti;
  3907. proto_tree *comp_data_tree;
  3908. col_set_str(pinfo->cinfo, COL_PROTOCOL, "PPP Comp");
  3909. col_set_str(pinfo->cinfo, COL_INFO, "Compressed data");
  3910. if (tree) {
  3911. ti = proto_tree_add_item(tree, proto_comp_data, tvb, 0, -1, ENC_NA);
  3912. comp_data_tree = proto_item_add_subtree(ti, ett_comp_data);
  3913. }
  3914. }
  3915. #else
  3916. static void
  3917. dissect_comp_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
  3918. {
  3919. col_set_str(pinfo->cinfo, COL_PROTOCOL, "PPP Comp");
  3920. col_set_str(pinfo->cinfo, COL_INFO, "Compressed data");
  3921. if (tree)
  3922. proto_tree_add_item(tree, proto_comp_data, tvb, 0, -1, ENC_NA);
  3923. }
  3924. #endif
  3925. /*
  3926. * RFC 3153 (both PPPMuxCP and PPPMux).
  3927. */
  3928. static void
  3929. dissect_pppmuxcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
  3930. {
  3931. dissect_cp(tvb, proto_pppmuxcp, ett_pppmuxcp, pppmuxcp_vals,
  3932. ett_pppmuxcp_options, pppmuxcp_opts, N_PPPMUXCP_OPTS,pinfo, tree);
  3933. }
  3934. #define PPPMUX_FLAGS_MASK 0xc0
  3935. #define PPPMUX_PFF_BIT_SET 0x80
  3936. #define PPPMUX_LXT_BIT_SET 0x40
  3937. static void
  3938. dissect_pppmux(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
  3939. {
  3940. proto_tree *mux_tree, *hdr_tree, *sub_tree, *flag_tree;
  3941. proto_tree *info_tree;
  3942. proto_item *ti = NULL, *sub_ti = NULL;
  3943. guint8 flags, byte;
  3944. guint16 length;
  3945. static guint16 pid;
  3946. tvbuff_t *next_tvb;
  3947. int offset = 0, length_remaining;
  3948. int length_field = 0, pid_field = 0, hdr_length = 0;
  3949. col_set_str(pinfo->cinfo,COL_PROTOCOL, "PPP PPPMux");
  3950. col_set_str(pinfo->cinfo, COL_INFO, "PPP Multiplexing");
  3951. length_remaining = tvb_reported_length(tvb);
  3952. ti = proto_tree_add_item(tree, proto_pppmux, tvb, 0, -1, ENC_NA);
  3953. mux_tree = proto_item_add_subtree(ti, ett_pppmux);
  3954. while (length_remaining > 0) {
  3955. flags = tvb_get_guint8(tvb,offset) & PPPMUX_FLAGS_MASK;
  3956. if (flags & PPPMUX_LXT_BIT_SET) {
  3957. length = tvb_get_ntohs(tvb,offset) & 0x3fff;
  3958. length_field = 2;
  3959. } else {
  3960. length = tvb_get_guint8(tvb,offset) & 0x3f;
  3961. length_field = 1;
  3962. }
  3963. if (flags & PPPMUX_PFF_BIT_SET) {
  3964. byte = tvb_get_guint8(tvb,offset + length_field);
  3965. if (byte & PFC_BIT) { /* Compressed PID field */
  3966. pid = byte;
  3967. pid_field = 1;
  3968. } else { /* PID field is 2 bytes */
  3969. pid = tvb_get_ntohs(tvb,offset + length_field);
  3970. pid_field = 2;
  3971. }
  3972. } else {
  3973. pid_field = 0; /* PID field is 0 bytes */
  3974. if (!pid) { /* No Last PID, hence use the default */
  3975. if (pppmux_def_prot_id)
  3976. pid = pppmux_def_prot_id;
  3977. }
  3978. }
  3979. hdr_length = length_field + pid_field;
  3980. ti = proto_tree_add_text(mux_tree, tvb, offset, length + length_field,
  3981. "PPPMux Sub-frame");
  3982. sub_tree = proto_item_add_subtree(ti, ett_pppmux_subframe);
  3983. sub_ti = proto_tree_add_text(sub_tree, tvb, offset, hdr_length,
  3984. "Header field");
  3985. hdr_tree = proto_item_add_subtree(sub_ti, ett_pppmux_subframe_hdr);
  3986. ti = proto_tree_add_text(hdr_tree, tvb, offset, length_field,
  3987. "PFF/LXT: 0x%02X", flags);
  3988. flag_tree = proto_item_add_subtree(ti, ett_pppmux_subframe_flags);
  3989. proto_tree_add_item(flag_tree, hf_pppmux_flags_pid, tvb, offset, length_field,
  3990. ENC_BIG_ENDIAN);
  3991. proto_tree_add_item(flag_tree, hf_pppmux_flags_field_length, tvb, offset, length_field,
  3992. ENC_BIG_ENDIAN);
  3993. proto_tree_add_text(hdr_tree, tvb,offset, length_field,
  3994. "Sub-frame Length = %u", length);
  3995. ti = proto_tree_add_uint(hdr_tree, hf_pppmux_protocol, tvb,
  3996. offset + length_field, pid_field, pid);
  3997. /* if protocol is not present in the sub-frame */
  3998. if (!(flags & PPPMUX_PFF_BIT_SET)) {
  3999. /* mark this item as generated */
  4000. PROTO_ITEM_SET_GENERATED(ti);
  4001. }
  4002. offset += hdr_length;
  4003. length_remaining -= hdr_length;
  4004. length -= pid_field;
  4005. tvb_ensure_bytes_exist (tvb, offset, length);
  4006. sub_ti = proto_tree_add_text(sub_tree, tvb,offset, length,
  4007. "Information Field");
  4008. info_tree = proto_item_add_subtree(sub_ti, ett_pppmux_subframe_info);
  4009. next_tvb = tvb_new_subset(tvb, offset, length, length);
  4010. if (!dissector_try_uint(ppp_subdissector_table, pid, next_tvb, pinfo,
  4011. info_tree)) {
  4012. call_dissector(data_handle, next_tvb, pinfo, info_tree);
  4013. }
  4014. offset += length;
  4015. length_remaining -= length;
  4016. }
  4017. }
  4018. /*
  4019. * RFC 2508 Internet Protocol Header Compression
  4020. */
  4021. #define IPHC_CRTP_FH_FLAG_MASK 0xc0
  4022. #define IPHC_CRTP_FH_FLAG_POS 6
  4023. #define IPHC_CRTP_FH_CID8 1
  4024. #define IPHC_CRTP_FH_CID16 3
  4025. #define IPHC_CRTP_CS_CID8 1
  4026. #define IPHC_CRTP_CS_CID16 2
  4027. static const value_string iphc_crtp_fh_flags[] = {
  4028. {IPHC_CRTP_FH_CID8, "8-bit Context Id"},
  4029. {IPHC_CRTP_FH_CID16, "16-bit Context Id"},
  4030. {0, NULL}
  4031. };
  4032. static const value_string iphc_crtp_cs_flags[] = {
  4033. {IPHC_CRTP_CS_CID8, "8-bit Context Id"},
  4034. {IPHC_CRTP_CS_CID16, "16-bit Context Id"},
  4035. {0, NULL}
  4036. };
  4037. /*
  4038. * 0x61 Packets: Full IP/UDP Header
  4039. */
  4040. static void
  4041. dissect_iphc_crtp_fh(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
  4042. {
  4043. proto_tree *fh_tree = NULL, *info_tree;
  4044. proto_item *ti = NULL;
  4045. guint ip_hdr_len, flags;
  4046. guint length;
  4047. guint hdr_len;
  4048. tvbuff_t *next_tvb;
  4049. int offset_seq;
  4050. int offset_cid;
  4051. guint8 ip_version;
  4052. guint8 next_protocol;
  4053. guchar *ip_packet;
  4054. length = tvb_reported_length(tvb);
  4055. col_set_str(pinfo->cinfo,COL_PROTOCOL, "CRTP");
  4056. col_set_str(pinfo->cinfo, COL_INFO, "Full Header");
  4057. /* only dissect IPv4 and UDP */
  4058. ip_version = tvb_get_guint8(tvb, 0) >> 4;
  4059. flags = (tvb_get_guint8(tvb, 2) & IPHC_CRTP_FH_FLAG_MASK) >>
  4060. IPHC_CRTP_FH_FLAG_POS;
  4061. next_protocol = tvb_get_guint8(tvb, 9);
  4062. if (tree) {
  4063. ti = proto_tree_add_protocol_format(tree, proto_iphc_crtp, tvb, 0, -1,
  4064. "%s", val_to_str_ext_const(PPP_RTP_FH, &ppp_vals_ext, "Unknown"));
  4065. fh_tree = proto_item_add_subtree(ti, ett_iphc_crtp);
  4066. proto_tree_add_item(fh_tree, hf_iphc_crtp_fh_flags, tvb, 2, 1,
  4067. ENC_BIG_ENDIAN);
  4068. proto_tree_add_item(fh_tree, hf_iphc_crtp_gen, tvb, 2, 1,
  4069. ENC_BIG_ENDIAN);
  4070. }
  4071. /* calculate length of IP header, assume IPv4 */
  4072. ip_hdr_len = (tvb_get_guint8(tvb, 0) & 0x0f) * 4;
  4073. /* calculate total hdr length, assume UDP */
  4074. hdr_len = ip_hdr_len + 8;
  4075. if (ip_version != 4) {
  4076. proto_tree_add_text(fh_tree, tvb, 3, -1,
  4077. "IP version is %u: the only supported version is 4",
  4078. ip_version);
  4079. return;
  4080. }
  4081. if (next_protocol != IP_PROTO_UDP) {
  4082. proto_tree_add_text(fh_tree, tvb, 3, -1,
  4083. "Next protocol is %s (%u): the only supported protocol is UDP",
  4084. ipprotostr(next_protocol), next_protocol);
  4085. return;
  4086. }
  4087. /* context id and sequence fields */
  4088. switch (flags) {
  4089. case IPHC_CRTP_FH_CID8:
  4090. offset_cid = 3;
  4091. offset_seq = ip_hdr_len + 5;
  4092. proto_tree_add_item(fh_tree, hf_iphc_crtp_cid8, tvb, offset_cid, 1,
  4093. ENC_BIG_ENDIAN);
  4094. proto_tree_add_item(fh_tree, hf_iphc_crtp_seq, tvb, offset_seq, 1,
  4095. ENC_BIG_ENDIAN);
  4096. break;
  4097. case IPHC_CRTP_FH_CID16:
  4098. offset_seq = 3;
  4099. offset_cid = ip_hdr_len + 4;
  4100. proto_tree_add_item(fh_tree, hf_iphc_crtp_seq, tvb, offset_seq, 1,
  4101. ENC_BIG_ENDIAN);
  4102. proto_tree_add_item(fh_tree, hf_iphc_crtp_cid16, tvb, offset_cid,
  4103. 2, ENC_BIG_ENDIAN);
  4104. break;
  4105. default:
  4106. /* TODO? */
  4107. break;
  4108. }
  4109. /* information field */
  4110. ti = proto_tree_add_text(fh_tree, tvb, 0, length, "Information Field");
  4111. info_tree = proto_item_add_subtree(ti,ett_iphc_crtp_info);
  4112. /* XXX: 1: May trap above; 2: really only need to check for ip_hdr_len+6 ?? */
  4113. tvb_ensure_bytes_exist (tvb, 0, hdr_len); /* ip_hdr_len + 8 */
  4114. /* allocate a copy of the IP packet */
  4115. ip_packet = (guchar *)tvb_memdup(tvb, 0, length);
  4116. /* restore the proper values to the IP and UDP length fields */
  4117. ip_packet[2] = length >> 8;
  4118. ip_packet[3] = length;
  4119. ip_packet[ip_hdr_len + 4] = (length - ip_hdr_len) >> 8;
  4120. ip_packet[ip_hdr_len + 5] = (length - ip_hdr_len);
  4121. next_tvb = tvb_new_child_real_data(tvb, ip_packet, length, length);
  4122. add_new_data_source(pinfo, next_tvb, "Decompressed Data");
  4123. tvb_set_free_cb(next_tvb, g_free);
  4124. if (!dissector_try_uint(ppp_subdissector_table, PPP_IP, next_tvb, pinfo,
  4125. info_tree)) {
  4126. call_dissector_only(data_handle, next_tvb, pinfo, info_tree, NULL);
  4127. }
  4128. }
  4129. /*
  4130. * 0x2067 Packets: Compressed UDP with 16-bit Context Identifier
  4131. */
  4132. static void
  4133. dissect_iphc_crtp_cudp16(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
  4134. {
  4135. proto_tree *cudp_tree;
  4136. proto_item *ti = NULL;
  4137. guint length;
  4138. guint hdr_length;
  4139. int offset = 0;
  4140. col_set_str(pinfo->cinfo,COL_PROTOCOL, "CRTP");
  4141. col_set_str(pinfo->cinfo, COL_INFO, "Compressed UDP 16");
  4142. length = tvb_reported_length(tvb);
  4143. if (tree) {
  4144. ti = proto_tree_add_protocol_format(tree, proto_iphc_crtp, tvb, 0, -1,
  4145. "%s",
  4146. val_to_str_ext_const(PPP_RTP_CUDP16, &ppp_vals_ext, "Unknown"));
  4147. cudp_tree = proto_item_add_subtree(ti, ett_iphc_crtp);
  4148. hdr_length = 3;
  4149. proto_tree_add_item(cudp_tree, hf_iphc_crtp_cid16, tvb, 0, 2,
  4150. ENC_BIG_ENDIAN);
  4151. proto_tree_add_item(cudp_tree, hf_iphc_crtp_seq, tvb, 2, 1,
  4152. ENC_BIG_ENDIAN);
  4153. offset += hdr_length;
  4154. length -= hdr_length;
  4155. proto_tree_add_text(cudp_tree, tvb, offset, length, "Data (%d bytes)",
  4156. length);
  4157. }
  4158. }
  4159. /*
  4160. * 0x67 Packets: Compressed UDP with 8-bit Context Identifier
  4161. */
  4162. static void
  4163. dissect_iphc_crtp_cudp8(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
  4164. {
  4165. proto_tree *cudp_tree;
  4166. proto_item *ti = NULL;
  4167. guint length;
  4168. guint hdr_length;
  4169. int offset = 0;
  4170. col_set_str(pinfo->cinfo,COL_PROTOCOL, "CRTP");
  4171. col_set_str(pinfo->cinfo, COL_INFO, "Compressed UDP 8");
  4172. length = tvb_reported_length(tvb);
  4173. if (tree) {
  4174. ti = proto_tree_add_protocol_format(tree, proto_iphc_crtp, tvb, 0, -1,
  4175. "%s",
  4176. val_to_str_ext_const(PPP_RTP_CUDP8, &ppp_vals_ext, "Unknown"));
  4177. cudp_tree = proto_item_add_subtree(ti, ett_iphc_crtp);
  4178. hdr_length = 2;
  4179. proto_tree_add_item(cudp_tree, hf_iphc_crtp_cid8, tvb, 0, 1,
  4180. ENC_BIG_ENDIAN);
  4181. proto_tree_add_item(cudp_tree, hf_iphc_crtp_seq, tvb, 1, 1,
  4182. ENC_BIG_ENDIAN);
  4183. offset += hdr_length;
  4184. length -= hdr_length;
  4185. proto_tree_add_text(cudp_tree, tvb, offset, length, "Data (%d bytes)",
  4186. length);
  4187. }
  4188. }
  4189. /*
  4190. * 0x2065 Packets: Context State
  4191. */
  4192. static void
  4193. dissect_iphc_crtp_cs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
  4194. {
  4195. proto_tree *cs_tree;
  4196. proto_item *ti = NULL;
  4197. guint8 flags, cnt;
  4198. guint length, cid_size;
  4199. guint offset = 2, hf;
  4200. col_set_str(pinfo->cinfo,COL_PROTOCOL, "CRTP");
  4201. col_set_str(pinfo->cinfo, COL_INFO, "Context State");
  4202. if (tree) {
  4203. ti = proto_tree_add_protocol_format(tree, proto_iphc_crtp, tvb, 0, -1,
  4204. "%s", val_to_str_ext_const(PPP_RTP_CS, &ppp_vals_ext, "Unknown"));
  4205. cs_tree = proto_item_add_subtree(ti, ett_iphc_crtp);
  4206. proto_tree_add_item(cs_tree, hf_iphc_crtp_cs_flags, tvb, 0, 1,
  4207. ENC_BIG_ENDIAN);
  4208. proto_tree_add_item(cs_tree, hf_iphc_crtp_cs_cnt, tvb, 1, 1,
  4209. ENC_BIG_ENDIAN);
  4210. /* calculate required length */
  4211. flags = tvb_get_guint8(tvb, 0);
  4212. cnt = tvb_get_guint8(tvb, 1);
  4213. if (flags == IPHC_CRTP_CS_CID8) {
  4214. hf = hf_iphc_crtp_cid8;
  4215. cid_size = 1;
  4216. length = 3 * cnt;
  4217. } else {
  4218. hf = hf_iphc_crtp_cid16;
  4219. cid_size = 2;
  4220. length = 4 * cnt;
  4221. }
  4222. tvb_ensure_bytes_exist(tvb, offset, length);
  4223. while (offset < length) {
  4224. proto_tree_add_item(cs_tree, hf, tvb, offset, cid_size,
  4225. ENC_BIG_ENDIAN);
  4226. offset += cid_size;
  4227. proto_tree_add_item(cs_tree, hf_iphc_crtp_cs_invalid, tvb, offset,
  4228. 1, ENC_BIG_ENDIAN);
  4229. proto_tree_add_item(cs_tree, hf_iphc_crtp_seq, tvb, offset, 1,
  4230. ENC_BIG_ENDIAN);
  4231. ++offset;
  4232. proto_tree_add_item(cs_tree, hf_iphc_crtp_gen, tvb, offset, 1,
  4233. ENC_BIG_ENDIAN);
  4234. ++offset;
  4235. }
  4236. }
  4237. }
  4238. /*
  4239. * RFC 3032.
  4240. */
  4241. static void
  4242. dissect_mplscp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
  4243. {
  4244. dissect_cp(tvb, proto_mplscp, ett_mplscp, cp_vals, ett_mplscp_options,
  4245. NULL, 0, pinfo, tree);
  4246. }
  4247. /*
  4248. * Cisco Discovery Protocol Control Protocol.
  4249. * XXX - where is this documented?
  4250. */
  4251. static void
  4252. dissect_cdpcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
  4253. {
  4254. dissect_cp(tvb, proto_cdpcp, ett_cdpcp, cp_vals, ett_cdpcp_options, NULL,
  4255. 0, pinfo, tree);
  4256. }
  4257. static gboolean mp_short_seqno = FALSE; /* Default to long sequence numbers */
  4258. #define MP_FRAG_MASK 0xC0
  4259. #define MP_FRAG(bits) ((bits) & MP_FRAG_MASK)
  4260. #define MP_FRAG_FIRST 0x80
  4261. #define MP_FRAG_LAST 0x40
  4262. #define MP_FRAG_RESERVED 0x3f
  4263. #define MP_FRAG_RESERVED_SHORT 0x30
  4264. /* According to RFC 1990, the length the MP header isn't indicated anywhere
  4265. in the header itself. It starts out at four bytes and can be
  4266. negotiated down to two using LCP. We currently have a preference
  4267. to select short headers. - gcc & gh
  4268. */
  4269. static void
  4270. dissect_mp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
  4271. {
  4272. proto_tree *mp_tree = NULL, *hdr_tree;
  4273. proto_item *ti = NULL;
  4274. guint8 flags;
  4275. const gchar *flag_str;
  4276. gint hdrlen;
  4277. tvbuff_t *next_tvb;
  4278. col_set_str(pinfo->cinfo, COL_PROTOCOL, "PPP MP");
  4279. col_set_str(pinfo->cinfo, COL_INFO, "PPP Multilink");
  4280. if (tree) {
  4281. ti = proto_tree_add_item(tree, proto_mp, tvb, 0,
  4282. mp_short_seqno ? 2 : 4, ENC_NA);
  4283. mp_tree = proto_item_add_subtree(ti, ett_mp);
  4284. }
  4285. flags = tvb_get_guint8(tvb, 0);
  4286. if (tree) {
  4287. switch (MP_FRAG(flags)) {
  4288. case MP_FRAG_FIRST:
  4289. flag_str = "First";
  4290. break;
  4291. case MP_FRAG_LAST:
  4292. flag_str = "Last";
  4293. break;
  4294. case MP_FRAG_FIRST|MP_FRAG_LAST:
  4295. flag_str = "First, Last";
  4296. break;
  4297. default:
  4298. flag_str = "Unknown";
  4299. break;
  4300. }
  4301. ti = proto_tree_add_text(mp_tree, tvb, 0, 1, "Fragment: 0x%2X (%s)",
  4302. MP_FRAG(flags), flag_str);
  4303. hdr_tree = proto_item_add_subtree(ti, ett_mp_flags);
  4304. proto_tree_add_boolean(hdr_tree, hf_mp_frag_first, tvb, 0, 1, flags);
  4305. proto_tree_add_boolean(hdr_tree, hf_mp_frag_last, tvb, 0, 1, flags);
  4306. if (mp_short_seqno) {
  4307. proto_tree_add_item(hdr_tree, hf_mp_short_sequence_num_reserved, tvb, 0, 1,
  4308. ENC_BIG_ENDIAN);
  4309. proto_tree_add_item(mp_tree, hf_mp_short_sequence_num, tvb, 0, 2,
  4310. ENC_BIG_ENDIAN);
  4311. } else {
  4312. proto_tree_add_item(hdr_tree, hf_mp_sequence_num_reserved, tvb, 0, 1,
  4313. ENC_BIG_ENDIAN);
  4314. proto_tree_add_item(mp_tree, hf_mp_sequence_num, tvb, 1, 3,
  4315. ENC_BIG_ENDIAN);
  4316. }
  4317. }
  4318. hdrlen = mp_short_seqno ? 2 : 4;
  4319. if (tvb_reported_length_remaining(tvb, hdrlen) > 0) {
  4320. next_tvb = tvb_new_subset_remaining(tvb, hdrlen);
  4321. dissect_ppp(next_tvb, pinfo, tree);
  4322. }
  4323. }
  4324. /*
  4325. * Handles PPP without HDLC framing, just a protocol field (RFC 1661).
  4326. */
  4327. static void
  4328. dissect_ppp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
  4329. {
  4330. proto_item *ti = NULL;
  4331. proto_tree *fh_tree = NULL;
  4332. if (tree) {
  4333. ti = proto_tree_add_item(tree, proto_ppp, tvb, 0, -1, ENC_NA);
  4334. fh_tree = proto_item_add_subtree(ti, ett_ppp);
  4335. }
  4336. dissect_ppp_common(tvb, pinfo, tree, fh_tree, ti, 0);
  4337. }
  4338. static void
  4339. dissect_ppp_hdlc_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
  4340. {
  4341. proto_item *ti = NULL;
  4342. proto_tree *fh_tree = NULL;
  4343. guint8 byte0;
  4344. int proto_offset;
  4345. tvbuff_t *next_tvb;
  4346. byte0 = tvb_get_guint8(tvb, 0);
  4347. /* PPP HDLC encapsulation */
  4348. if (byte0 == 0xff)
  4349. proto_offset = 2;
  4350. else {
  4351. /* address and control are compressed (NULL) */
  4352. proto_offset = 0;
  4353. }
  4354. /* load the top pane info. This should be overwritten by
  4355. the next protocol in the stack */
  4356. if (tree) {
  4357. ti = proto_tree_add_item(tree, proto_ppp, tvb, 0, -1, ENC_NA);
  4358. fh_tree = proto_item_add_subtree(ti, ett_ppp);
  4359. if (byte0 == 0xff) {
  4360. proto_tree_add_item(fh_tree, hf_ppp_address, tvb, 0, 1,
  4361. ENC_BIG_ENDIAN);
  4362. proto_tree_add_item(fh_tree, hf_ppp_control, tvb, 1, 1,
  4363. ENC_BIG_ENDIAN);
  4364. }
  4365. }
  4366. next_tvb = decode_fcs(tvb, fh_tree, ppp_fcs_decode, proto_offset);
  4367. dissect_ppp_common(next_tvb, pinfo, tree, fh_tree, ti, proto_offset);
  4368. }
  4369. /*
  4370. * Handles link-layer encapsulations where the frame might be
  4371. * a PPP in HDLC-like Framing frame (RFC 1662) or a Cisco HDLC frame.
  4372. */
  4373. static void
  4374. dissect_ppp_hdlc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
  4375. {
  4376. guint8 byte0;
  4377. byte0 = tvb_get_guint8(tvb, 0);
  4378. if (byte0 == CHDLC_ADDR_UNICAST || byte0 == CHDLC_ADDR_MULTICAST) {
  4379. /* Cisco HDLC encapsulation */
  4380. call_dissector(chdlc_handle, tvb, pinfo, tree);
  4381. return;
  4382. }
  4383. /*
  4384. * XXX - should we have an exported dissector that always dissects PPP,
  4385. * for use when we know the packets are PPP, not CHDLC?
  4386. */
  4387. col_set_str(pinfo->cinfo, COL_PROTOCOL, "PPP");
  4388. switch (pinfo->p2p_dir) {
  4389. case P2P_DIR_SENT:
  4390. col_set_str(pinfo->cinfo, COL_RES_DL_SRC, "DTE");
  4391. col_set_str(pinfo->cinfo, COL_RES_DL_DST, "DCE");
  4392. break;
  4393. case P2P_DIR_RECV:
  4394. col_set_str(pinfo->cinfo, COL_RES_DL_SRC, "DCE");
  4395. col_set_str(pinfo->cinfo, COL_RES_DL_DST, "DTE");
  4396. break;
  4397. default:
  4398. col_set_str(pinfo->cinfo, COL_RES_DL_SRC, "N/A");
  4399. col_set_str(pinfo->cinfo, COL_RES_DL_DST, "N/A");
  4400. break;
  4401. }
  4402. dissect_ppp_hdlc_common(tvb, pinfo, tree);
  4403. }
  4404. static tvbuff_t*
  4405. remove_escape_chars(tvbuff_t *tvb, packet_info *pinfo, int offset, int length)
  4406. {
  4407. guint8 *buff;
  4408. int i;
  4409. int scanned_len = 0;
  4410. guint8 octet;
  4411. tvbuff_t *next_tvb;
  4412. buff = (guint8 *)wmem_alloc(pinfo->pool, length);
  4413. i = 0;
  4414. while (scanned_len < length) {
  4415. octet = tvb_get_guint8(tvb, offset);
  4416. if (octet == 0x7d) {
  4417. offset++;
  4418. scanned_len++;
  4419. if (scanned_len >= length)
  4420. break;
  4421. octet = tvb_get_guint8(tvb, offset);
  4422. buff[i] = octet ^ 0x20;
  4423. } else {
  4424. buff[i] = octet;
  4425. }
  4426. offset++;
  4427. scanned_len++;
  4428. i++;
  4429. }
  4430. if (i == 0) {
  4431. return NULL;
  4432. }
  4433. next_tvb = tvb_new_child_real_data(tvb, buff, i, i);
  4434. return next_tvb;
  4435. }
  4436. /*
  4437. * Handles link-layer encapsulations where we have a raw RFC 1662
  4438. * HDLC-like asynchronous framing byte stream, and have to
  4439. * break the byte stream into frames and remove escapes.
  4440. */
  4441. static void
  4442. dissect_ppp_raw_hdlc( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
  4443. {
  4444. proto_item *ti;
  4445. proto_tree *bs_tree = NULL;
  4446. gint offset, end_offset, data_offset;
  4447. int length, data_length;
  4448. tvbuff_t *ppp_tvb;
  4449. gboolean first = TRUE;
  4450. col_set_str(pinfo->cinfo, COL_PROTOCOL, "PPP");
  4451. if (tree) {
  4452. ti = proto_tree_add_item(tree, proto_ppp_hdlc, tvb, 0, -1, ENC_NA);
  4453. bs_tree = proto_item_add_subtree(ti, ett_ppp_hdlc_data);
  4454. }
  4455. /*
  4456. * XXX - this needs to handle a PPP frame split over multiple higher-level
  4457. * packets.
  4458. */
  4459. /*
  4460. * Look for a frame delimiter.
  4461. */
  4462. offset = tvb_find_guint8(tvb, 0, -1, 0x7e);
  4463. if (offset == -1) {
  4464. /*
  4465. * None found - this is presumably continued from an earlier
  4466. * packet and continued in a later packet.
  4467. */
  4468. col_set_str(pinfo->cinfo, COL_INFO, "PPP Fragment");
  4469. if (tree)
  4470. proto_tree_add_text(bs_tree, tvb, offset, -1, "PPP Fragment");
  4471. offset++;
  4472. length = tvb_length_remaining(tvb,offset);
  4473. ppp_tvb = remove_escape_chars(tvb, pinfo, offset,length);
  4474. if (ppp_tvb != NULL) {
  4475. add_new_data_source(pinfo, ppp_tvb, "PPP Fragment");
  4476. call_dissector(data_handle, ppp_tvb, pinfo, tree);
  4477. }
  4478. return;
  4479. }
  4480. if (offset != 0) {
  4481. /*
  4482. * We have some data preceding the first PPP packet;
  4483. * mark it as a PPP fragment.
  4484. */
  4485. col_set_str(pinfo->cinfo, COL_INFO, "PPP Fragment");
  4486. length = offset;
  4487. if (tree)
  4488. proto_tree_add_text(bs_tree, tvb, 0, length, "PPP Fragment");
  4489. if (length != 0) {
  4490. ppp_tvb = remove_escape_chars(tvb, pinfo, 0, length - 1);
  4491. if (ppp_tvb != NULL) {
  4492. add_new_data_source(pinfo, ppp_tvb, "PPP Fragment");
  4493. call_dissector(data_handle, ppp_tvb, pinfo, tree);
  4494. }
  4495. }
  4496. }
  4497. while (tvb_reported_length_remaining(tvb, offset) > 0) {
  4498. /*
  4499. * Look for the next frame delimiter.
  4500. */
  4501. end_offset = tvb_find_guint8(tvb, offset + 1, -1, 0x7e);
  4502. if (end_offset == -1) {
  4503. /*
  4504. * We didn't find one. This is probably continued in a later
  4505. * packet.
  4506. */
  4507. if (first)
  4508. col_set_str(pinfo->cinfo, COL_INFO, "PPP Fragment");
  4509. if (tree)
  4510. proto_tree_add_text(bs_tree, tvb, offset, -1, "PPP Fragment");
  4511. offset++;
  4512. length = tvb_length_remaining(tvb, offset);
  4513. ppp_tvb = remove_escape_chars(tvb, pinfo, offset, length);
  4514. if (ppp_tvb != NULL) {
  4515. add_new_data_source(pinfo, ppp_tvb, "PPP Fragment");
  4516. call_dissector(data_handle, ppp_tvb, pinfo, tree);
  4517. }
  4518. return;
  4519. }
  4520. data_offset = offset + 1; /* skip starting frame delimiter */
  4521. data_length = end_offset - data_offset;
  4522. /*
  4523. * Is that frame delimiter immediately followed by another one?
  4524. * Some PPP implementations put a frame delimiter at the
  4525. * beginning and the end of each frame, although RFC 1662
  4526. * appears only to require that there be one frame delimiter
  4527. * between adjacent frames:
  4528. *
  4529. * Each frame begins and ends with a Flag Sequence, which is the
  4530. * binary sequence 01111110 (hexadecimal 0x7e). All implementations
  4531. * continuously check for this flag, which is used for frame
  4532. * synchronization.
  4533. *
  4534. * Only one Flag Sequence is required between two frames. Two
  4535. * consecutive Flag Sequences constitute an empty frame, which is
  4536. * silently discarded, and not counted as a FCS error.
  4537. *
  4538. * If the delimiter at the end of this frame is followed by
  4539. * another delimiter, we consider the first delimiter part
  4540. * of this frame.
  4541. */
  4542. if (tvb_offset_exists(tvb, end_offset + 1) &&
  4543. tvb_get_guint8(tvb, end_offset+1) == 0x7e) {
  4544. end_offset++;
  4545. }
  4546. length = end_offset - offset;
  4547. if (tree)
  4548. proto_tree_add_text(bs_tree, tvb, offset, length, "PPP Data");
  4549. if (length > 1) {
  4550. ppp_tvb = remove_escape_chars(tvb, pinfo, data_offset, data_length);
  4551. if (ppp_tvb != NULL) {
  4552. add_new_data_source(pinfo, ppp_tvb, "PPP Message");
  4553. dissect_ppp_hdlc_common(ppp_tvb, pinfo, tree);
  4554. first = FALSE;
  4555. }
  4556. }
  4557. offset = end_offset;
  4558. }
  4559. }
  4560. /*
  4561. * At least for the PPP/USB captures I've seen, the data either starts with
  4562. * 0x7eff03 or 0x7eff7d23 or 0xff03, so this function performs that heuristic
  4563. * matching first before calling dissect_ppp_raw_hdlc(). Otherwise, if we call
  4564. * it directly for USB captures, some captures like the following will not be
  4565. * dissected correctly:
  4566. * http://wiki.wireshark.org/SampleCaptures#head-886e340c31ca977f321c921f81cbec4c21bb7738
  4567. *
  4568. * NOTE: I don't know if these heuristics are sufficient. Time will tell ...
  4569. */
  4570. static gboolean
  4571. dissect_ppp_usb( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_ )
  4572. {
  4573. /*
  4574. * In some cases, the 0x03 normally in byte 3 is escaped so we must look
  4575. * for the 2 byte sequence of 0x7d23 instead of 0x03. The 0x23 is
  4576. * generated by 0x20^0x03 per section 4.2 of:
  4577. * http://tools.ietf.org/html/rfc1662.html.
  4578. */
  4579. const guchar buf1[3] = {0x7e, 0xff, 0x03};
  4580. const guchar buf2[4] = {0x7e, 0xff, 0x7d, 0x23};
  4581. tvbuff_t *next_tvb;
  4582. if ((tvb_memeql(tvb, 0, buf2, sizeof(buf2)) == 0) ||
  4583. (tvb_memeql(tvb, 0, buf1, sizeof(buf1)) == 0)) {
  4584. dissect_ppp_raw_hdlc(tvb, pinfo, tree);
  4585. } else if ((tvb_memeql(tvb, 0, &buf1[1], sizeof(buf1) - 1) == 0) ||
  4586. (tvb_memeql(tvb, 0, &buf2[1], sizeof(buf2) - 1) == 0)) {
  4587. /* It's missing the 0x7e framing character. What TODO?
  4588. * Should we try faking it by sticking 0x7e in front? Or try telling
  4589. * dissect_ppp_raw_hdlc() NOT to look for the 0x7e frame deliminator?
  4590. * Or is this a bug in libpcap (used 1.1.0)?
  4591. * Or a bug in the Linux kernel (tested with 2.6.24.4) Or a bug in
  4592. * usbmon? Or is the data we're looking at really just part of the
  4593. * payload and not control data? Well, at least in my case it's
  4594. * definitely not, but not sure if this is always the case. Is this
  4595. * issue applicable only to PPP/USB or PPP/XYZ, in which case a more
  4596. * general solution should be found?
  4597. */
  4598. /* For now, just try skipping the framing I guess??? */
  4599. if (tvb_get_guint8(tvb, 1) == 0x03)
  4600. next_tvb = tvb_new_subset_remaining(tvb, 2);
  4601. else
  4602. next_tvb = tvb_new_subset_remaining(tvb, 3);
  4603. dissect_ppp(next_tvb, pinfo, tree);
  4604. } else if (tvb_get_guint8(tvb, 0) == 0x7e) {
  4605. /* Well, let's guess that since the 1st byte is 0x7e that it really is
  4606. * a PPP frame, and the address and control bytes are compressed (NULL)
  4607. * per http://tools.ietf.org/html/rfc1662, section 3.2. */
  4608. next_tvb = tvb_new_subset_remaining(tvb, 1);
  4609. dissect_ppp_hdlc_common(next_tvb, pinfo, tree);
  4610. } else
  4611. return (FALSE);
  4612. return (TRUE);
  4613. }
  4614. void
  4615. proto_register_ppp_raw_hdlc(void)
  4616. {
  4617. static gint *ett[] = {
  4618. &ett_ppp_hdlc_data
  4619. };
  4620. proto_ppp_hdlc = proto_register_protocol("PPP In HDLC-Like Framing",
  4621. "PPP-HDLC", "ppp_hdlc");
  4622. proto_register_subtree_array(ett, array_length(ett));
  4623. }
  4624. void
  4625. proto_reg_handoff_ppp_raw_hdlc(void)
  4626. {
  4627. dissector_handle_t ppp_raw_hdlc_handle;
  4628. ppp_raw_hdlc_handle = create_dissector_handle(dissect_ppp_raw_hdlc,
  4629. proto_ppp);
  4630. dissector_add_uint("gre.proto", ETHERTYPE_CDMA2000_A10_UBS,
  4631. ppp_raw_hdlc_handle);
  4632. dissector_add_uint("gre.proto", ETHERTYPE_3GPP2, ppp_raw_hdlc_handle);
  4633. heur_dissector_add("usb.bulk", dissect_ppp_usb, proto_ppp);
  4634. }
  4635. /*
  4636. * Handles PAP just as a protocol field
  4637. */
  4638. static void
  4639. dissect_pap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
  4640. {
  4641. proto_item *ti, *data_ti;
  4642. proto_tree *fh_tree, *data_tree = NULL;
  4643. guint8 code;
  4644. gchar *peer_id, *password, *message;
  4645. guint8 peer_id_length, password_length, message_length;
  4646. int offset = 0;
  4647. code = tvb_get_guint8(tvb, 0);
  4648. col_set_str(pinfo->cinfo, COL_PROTOCOL, "PPP PAP");
  4649. col_add_str(pinfo->cinfo, COL_INFO,
  4650. val_to_str_const(code, pap_vals, "Unknown"));
  4651. ti = proto_tree_add_item(tree, proto_pap, tvb, 0, -1, ENC_NA);
  4652. fh_tree = proto_item_add_subtree(ti, ett_pap);
  4653. proto_tree_add_item(fh_tree, hf_pap_code, tvb, offset, 1,
  4654. ENC_BIG_ENDIAN);
  4655. offset++;
  4656. proto_tree_add_item(fh_tree, hf_pap_identifier, tvb, offset, 1,
  4657. ENC_BIG_ENDIAN);
  4658. offset++;
  4659. proto_tree_add_item(fh_tree, hf_pap_length, tvb, offset, 2,
  4660. ENC_BIG_ENDIAN);
  4661. offset += 2;
  4662. data_ti = proto_tree_add_item(fh_tree, hf_pap_data, tvb, offset, -1,
  4663. ENC_NA);
  4664. data_tree = proto_item_add_subtree(data_ti, ett_pap_data);
  4665. switch (code) {
  4666. case CONFREQ:
  4667. proto_tree_add_item(data_tree, hf_pap_peer_id_length, tvb, offset,
  4668. 1, ENC_BIG_ENDIAN);
  4669. peer_id_length = tvb_get_guint8(tvb, offset);
  4670. offset++;
  4671. proto_tree_add_item(data_tree, hf_pap_peer_id, tvb, offset,
  4672. peer_id_length, ENC_ASCII|ENC_NA);
  4673. peer_id = tvb_format_text(tvb, offset, peer_id_length);
  4674. offset += peer_id_length;
  4675. proto_tree_add_item(data_tree, hf_pap_password_length, tvb, offset,
  4676. 1, ENC_BIG_ENDIAN);
  4677. password_length = tvb_get_guint8(tvb, offset);
  4678. offset++;
  4679. proto_tree_add_item(data_tree, hf_pap_password, tvb, offset,
  4680. password_length, ENC_ASCII|ENC_NA);
  4681. password = tvb_format_text(tvb, offset, password_length);
  4682. col_append_fstr(pinfo->cinfo, COL_INFO,
  4683. " (Peer-ID='%s', Password='%s')", peer_id, password);
  4684. break;
  4685. case CONFACK:
  4686. case CONFNAK:
  4687. proto_tree_add_item(data_tree, hf_pap_message_length, tvb, offset,
  4688. 1, ENC_BIG_ENDIAN);
  4689. message_length = tvb_get_guint8(tvb, offset);
  4690. offset +=1;
  4691. proto_tree_add_item(data_tree, hf_pap_message, tvb, offset,
  4692. message_length, ENC_ASCII|ENC_NA);
  4693. message = tvb_format_text(tvb, offset, message_length);
  4694. col_append_fstr(pinfo->cinfo, COL_INFO, " (Message='%s')",
  4695. message);
  4696. break;
  4697. default:
  4698. proto_tree_add_item(data_tree, hf_pap_stuff, tvb, offset, -1,
  4699. ENC_NA);
  4700. break;
  4701. }
  4702. }
  4703. /*
  4704. * RFC 1994
  4705. * Handles CHAP just as a protocol field
  4706. */
  4707. static void
  4708. dissect_chap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
  4709. {
  4710. proto_item *ti = NULL;
  4711. proto_tree *fh_tree = NULL;
  4712. proto_item *tf;
  4713. proto_tree *field_tree;
  4714. guint8 code, value_size;
  4715. guint32 length;
  4716. int offset;
  4717. code = tvb_get_guint8(tvb, 0);
  4718. col_set_str(pinfo->cinfo, COL_PROTOCOL, "PPP CHAP");
  4719. col_add_str(pinfo->cinfo, COL_INFO,
  4720. val_to_str_const(code, chap_vals, "Unknown"));
  4721. if (tree) {
  4722. /* Create CHAP protocol tree */
  4723. ti = proto_tree_add_item(tree, proto_chap, tvb, 0, -1, ENC_NA);
  4724. fh_tree = proto_item_add_subtree(ti, ett_chap);
  4725. proto_tree_add_item(fh_tree, hf_chap_code, tvb, 0, 1, ENC_BIG_ENDIAN);
  4726. proto_tree_add_item(fh_tree, hf_chap_identifier, tvb, 1, 1,
  4727. ENC_BIG_ENDIAN);
  4728. }
  4729. /* Length - make sure it's valid */
  4730. length = tvb_get_ntohs(tvb, 2);
  4731. if (length < 4) {
  4732. if (tree) {
  4733. proto_tree_add_uint_format(fh_tree, hf_chap_length, tvb, 2, 2,
  4734. length, "Length: %u (invalid, must be >= 4)", length);
  4735. }
  4736. return;
  4737. }
  4738. proto_item_set_len(ti, length);
  4739. if (tree) {
  4740. proto_tree_add_item(fh_tree, hf_chap_length, tvb, 2, 2,
  4741. ENC_BIG_ENDIAN);
  4742. }
  4743. offset = 4; /* Offset moved to after length field */
  4744. length -= 4; /* Length includes previous 4 bytes, subtract */
  4745. switch (code) {
  4746. /* Challenge or Response data */
  4747. case CHAP_CHAL:
  4748. case CHAP_RESP:
  4749. if (length > 0) {
  4750. guint value_offset = 0;
  4751. guint name_offset = 0, name_size = 0;
  4752. /* Create data subtree */
  4753. tf = proto_tree_add_item(fh_tree, hf_chap_data, tvb, offset,
  4754. length, ENC_NA);
  4755. field_tree = proto_item_add_subtree(tf, ett_chap_data);
  4756. length--;
  4757. /* Value size */
  4758. value_size = tvb_get_guint8(tvb, offset);
  4759. if (value_size > length) {
  4760. proto_tree_add_text(field_tree, tvb, offset, 1,
  4761. "Value Size: %d byte%s (invalid, must be <= %u)",
  4762. value_size, plurality(value_size, "", "s"), length);
  4763. return;
  4764. }
  4765. proto_tree_add_item(field_tree, hf_chap_value_size, tvb,
  4766. offset, 1, ENC_BIG_ENDIAN);
  4767. offset++;
  4768. /* Value */
  4769. if (length > 0) {
  4770. value_offset = offset;
  4771. proto_tree_add_item(field_tree, hf_chap_value, tvb, offset,
  4772. value_size, ENC_NA);
  4773. /* Move along value_size bytes */
  4774. offset += value_size;
  4775. length -= value_size;
  4776. /* Find name in remaining bytes */
  4777. if (length > 0) {
  4778. tvb_ensure_bytes_exist(tvb, offset, length);
  4779. proto_tree_add_item(field_tree, hf_chap_name, tvb,
  4780. offset, length, ENC_ASCII|ENC_NA);
  4781. name_offset = offset;
  4782. name_size = length;
  4783. }
  4784. /* Show name and value in info column */
  4785. col_append_fstr(pinfo->cinfo, COL_INFO,
  4786. " (NAME='%s%s', VALUE=0x%s)",
  4787. tvb_format_text(tvb, name_offset,
  4788. (name_size > 20) ? 20 : name_size),
  4789. (name_size > 20) ? "..." : "",
  4790. tvb_bytes_to_str(tvb, value_offset, value_size));
  4791. }
  4792. }
  4793. break;
  4794. /* Success or Failure data */
  4795. case CHAP_SUCC:
  4796. case CHAP_FAIL:
  4797. if (tree) {
  4798. if (length > 0) {
  4799. proto_tree_add_item(fh_tree, hf_chap_message, tvb, offset,
  4800. length, ENC_ASCII|ENC_NA);
  4801. }
  4802. }
  4803. /* Show message in info column */
  4804. col_append_fstr(pinfo->cinfo, COL_INFO, " (MESSAGE='%s')",
  4805. tvb_format_text(tvb, offset, length));
  4806. break;
  4807. /* Code from unknown code type... */
  4808. default:
  4809. if (length > 0)
  4810. proto_tree_add_text(fh_tree, tvb, offset, length,
  4811. "Stuff (%u byte%s)", length, plurality(length, "", "s"));
  4812. break;
  4813. }
  4814. }
  4815. /*
  4816. * RFC 2472.
  4817. */
  4818. static void
  4819. dissect_ipv6cp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
  4820. {
  4821. dissect_cp(tvb, proto_ipv6cp, ett_ipv6cp, cp_vals, ett_ipv6cp_options,
  4822. ipv6cp_opts, N_IPV6CP_OPTS, pinfo, tree);
  4823. }
  4824. static void
  4825. dissect_ipv6cp_if_id_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
  4826. guint length, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
  4827. {
  4828. proto_tree_add_text(tree, tvb, offset, length,
  4829. "%s: %02x%02x:%02x%02x:%02x%x:%02x%02x", optp->name,
  4830. tvb_get_guint8(tvb, offset + 2), tvb_get_guint8(tvb, offset + 3),
  4831. tvb_get_guint8(tvb, offset + 4), tvb_get_guint8(tvb, offset + 5),
  4832. tvb_get_guint8(tvb, offset + 6), tvb_get_guint8(tvb, offset + 7),
  4833. tvb_get_guint8(tvb, offset + 8), tvb_get_guint8(tvb, offset + 9));
  4834. }
  4835. void
  4836. proto_register_ppp(void)
  4837. {
  4838. static hf_register_info hf[] = {
  4839. { &hf_ppp_direction,
  4840. { "Direction", "ppp.direction", FT_UINT8, BASE_DEC,
  4841. VALS(ppp_direction_vals), 0x0, "PPP direction", HFILL }},
  4842. { &hf_ppp_address,
  4843. { "Address", "ppp.address", FT_UINT8, BASE_HEX,
  4844. NULL, 0x0, NULL, HFILL }},
  4845. { &hf_ppp_control,
  4846. { "Control", "ppp.control", FT_UINT8, BASE_HEX,
  4847. NULL, 0x0, NULL, HFILL }},
  4848. { &hf_ppp_protocol,
  4849. { "Protocol", "ppp.protocol", FT_UINT16, BASE_HEX|BASE_EXT_STRING,
  4850. &ppp_vals_ext, 0x0, NULL, HFILL }},
  4851. { &hf_ppp_code,
  4852. { "Code", "ppp.code", FT_UINT8, BASE_DEC,
  4853. NULL, 0x0, NULL, HFILL }},
  4854. { &hf_ppp_identifier,
  4855. { "Identifier", "ppp.identifier", FT_UINT8, BASE_DEC_HEX,
  4856. NULL, 0x0, NULL, HFILL }},
  4857. { &hf_ppp_length,
  4858. { "Length", "ppp.length", FT_UINT16, BASE_DEC,
  4859. NULL, 0x0, NULL, HFILL }},
  4860. { &hf_ppp_magic_number,
  4861. { "Magic Number", "ppp.magic_number", FT_UINT32, BASE_HEX,
  4862. NULL, 0x0, NULL, HFILL }},
  4863. { &hf_ppp_oui,
  4864. { "OUI", "ppp.oui", FT_UINT24, BASE_HEX,
  4865. VALS(oui_vals), 0x0, NULL, HFILL }},
  4866. { &hf_ppp_kind,
  4867. { "Kind", "ppp.kind", FT_UINT8, BASE_DEC_HEX,
  4868. NULL, 0x0, NULL, HFILL }},
  4869. { &hf_ppp_data,
  4870. { "Data", "ppp.data", FT_BYTES, BASE_NONE,
  4871. NULL, 0x0, NULL, HFILL }},
  4872. { &hf_ppp_opt_type,
  4873. { "Type", "ppp.opt.type", FT_UINT8, BASE_DEC,
  4874. NULL, 0x0, NULL, HFILL}},
  4875. { &hf_ppp_opt_type_copy,
  4876. { "Copy on fragmentation", "ppp.opt.type.copy", FT_BOOLEAN, 8,
  4877. TFS(&tfs_yes_no), IPOPT_COPY_MASK, NULL, HFILL}},
  4878. { &hf_ppp_opt_type_class,
  4879. { "Class", "ppp.opt.type.class", FT_UINT8, BASE_DEC,
  4880. VALS(ipopt_type_class_vals), IPOPT_CLASS_MASK, NULL, HFILL}},
  4881. { &hf_ppp_opt_type_number,
  4882. { "Number", "ppp.opt.type.number", FT_UINT8, BASE_DEC,
  4883. VALS(ipopt_type_number_vals), IPOPT_NUMBER_MASK, NULL, HFILL}},
  4884. };
  4885. static gint *ett[] = {
  4886. &ett_ppp,
  4887. &ett_ppp_opt_type
  4888. };
  4889. static ei_register_info ei[] = {
  4890. { &ei_ppp_opt_len_invalid, { "ppp.opt.len.invalid", PI_PROTOCOL, PI_WARN, "Invalid length for option", EXPFILL }},
  4891. };
  4892. module_t *ppp_module;
  4893. expert_module_t* expert_ppp;
  4894. proto_ppp = proto_register_protocol("Point-to-Point Protocol", "PPP",
  4895. "ppp");
  4896. proto_register_field_array(proto_ppp, hf, array_length(hf));
  4897. proto_register_subtree_array(ett, array_length(ett));
  4898. expert_ppp = expert_register_protocol(proto_ppp);
  4899. expert_register_field_array(expert_ppp, ei, array_length(ei));
  4900. /* subdissector code */
  4901. ppp_subdissector_table = register_dissector_table("ppp.protocol",
  4902. "PPP protocol", FT_UINT16, BASE_HEX);
  4903. register_dissector("ppp_hdlc", dissect_ppp_hdlc, proto_ppp);
  4904. register_dissector("ppp_lcp_options", dissect_lcp_options, proto_ppp);
  4905. register_dissector("ppp", dissect_ppp, proto_ppp);
  4906. /* Register the preferences for the ppp protocol */
  4907. ppp_module = prefs_register_protocol(proto_ppp, NULL);
  4908. prefs_register_enum_preference(ppp_module, "fcs_type",
  4909. "PPP Frame Checksum Type",
  4910. "The type of PPP frame checksum (none, 16-bit, 32-bit)",
  4911. &ppp_fcs_decode, fcs_options, FALSE);
  4912. prefs_register_bool_preference(ppp_module, "decompress_vj",
  4913. "Decompress Van Jacobson-compressed frames",
  4914. "Whether Van Jacobson-compressed PPP frames should be decompressed",
  4915. &ppp_vj_decomp);
  4916. prefs_register_uint_preference(ppp_module, "default_proto_id",
  4917. "PPPMuxCP Default PID (in hex)",
  4918. "Default Protocol ID to be used for PPPMuxCP",
  4919. 16, &pppmux_def_prot_id);
  4920. }
  4921. void
  4922. proto_reg_handoff_ppp(void)
  4923. {
  4924. dissector_handle_t ppp_hdlc_handle, ppp_handle;
  4925. /*
  4926. * Get a handle for the CHDLC dissector.
  4927. */
  4928. chdlc_handle = find_dissector("chdlc");
  4929. data_handle = find_dissector("data");
  4930. ppp_handle = find_dissector("ppp");
  4931. dissector_add_uint("fr.ietf", NLPID_PPP, ppp_handle);
  4932. ppp_hdlc_handle = find_dissector("ppp_hdlc");
  4933. dissector_add_uint("wtap_encap", WTAP_ENCAP_PPP, ppp_hdlc_handle);
  4934. dissector_add_uint("wtap_encap", WTAP_ENCAP_PPP_WITH_PHDR,
  4935. ppp_hdlc_handle);
  4936. dissector_add_uint("sll.ltype", LINUX_SLL_P_PPPHDLC, ppp_hdlc_handle);
  4937. dissector_add_uint("osinl.excl", NLPID_PPP, ppp_handle);
  4938. dissector_add_uint("gre.proto", ETHERTYPE_PPP, ppp_hdlc_handle);
  4939. }
  4940. void
  4941. proto_register_mp(void)
  4942. {
  4943. static hf_register_info hf[] = {
  4944. { &hf_mp_frag_first,
  4945. { "First fragment", "mp.first", FT_BOOLEAN, 8,
  4946. TFS(&tfs_yes_no), MP_FRAG_FIRST, NULL, HFILL }},
  4947. { &hf_mp_frag_last,
  4948. { "Last fragment", "mp.last", FT_BOOLEAN, 8,
  4949. TFS(&tfs_yes_no), MP_FRAG_LAST, NULL, HFILL }},
  4950. { &hf_mp_sequence_num,
  4951. { "Sequence number", "mp.seq", FT_UINT24, BASE_DEC,
  4952. NULL, 0x0, NULL, HFILL }},
  4953. { &hf_mp_sequence_num_reserved,
  4954. { "Reserved", "mp.sequence_num_reserved", FT_BOOLEAN, 8,
  4955. NULL, MP_FRAG_RESERVED, NULL, HFILL }},
  4956. { &hf_mp_short_sequence_num,
  4957. { "Short Sequence number", "mp.sseq", FT_UINT16, BASE_DEC,
  4958. NULL, 0x0FFF, NULL, HFILL }},
  4959. { &hf_mp_short_sequence_num_reserved,
  4960. { "Reserved", "mp.short_sequence_num_reserved", FT_BOOLEAN, 8,
  4961. NULL, MP_FRAG_RESERVED_SHORT, NULL, HFILL }},
  4962. };
  4963. static gint *ett[] = {
  4964. &ett_mp,
  4965. &ett_mp_flags
  4966. };
  4967. module_t *mp_module;
  4968. proto_mp = proto_register_protocol("PPP Multilink Protocol", "PPP MP",
  4969. "mp");
  4970. proto_register_field_array(proto_mp, hf, array_length(hf));
  4971. proto_register_subtree_array(ett, array_length(ett));
  4972. /* Register the preferences for the PPP multilink protocol */
  4973. mp_module = prefs_register_protocol(proto_mp, NULL);
  4974. prefs_register_bool_preference(mp_module, "short_seqno",
  4975. "Short sequence numbers",
  4976. "Whether PPP Multilink frames use 12-bit sequence numbers",
  4977. &mp_short_seqno);
  4978. }
  4979. void
  4980. proto_reg_handoff_mp(void)
  4981. {
  4982. dissector_handle_t mp_handle;
  4983. mp_handle = create_dissector_handle(dissect_mp, proto_mp);
  4984. dissector_add_uint("ppp.protocol", PPP_MP, mp_handle);
  4985. }
  4986. void
  4987. proto_register_lcp(void)
  4988. {
  4989. static hf_register_info hf[] = {
  4990. { &hf_lcp_magic_number,
  4991. { "Magic Number", "lcp.magic_number", FT_UINT32, BASE_HEX,
  4992. NULL, 0x0, NULL, HFILL }},
  4993. { &hf_lcp_data,
  4994. { "Data", "lcp.data", FT_BYTES, BASE_NONE,
  4995. NULL, 0x0, NULL, HFILL }},
  4996. { &hf_lcp_message,
  4997. { "Message", "lcp.message", FT_STRING, BASE_NONE,
  4998. NULL, 0x0, NULL, HFILL }},
  4999. { &hf_lcp_secs_remaining,
  5000. { "Seconds Remaining", "lcp.secs_remaining", FT_UINT32, BASE_DEC,
  5001. NULL, 0x0, NULL, HFILL }},
  5002. { &hf_lcp_rej_proto,
  5003. { "Rejected Protocol", "lcp.rej_proto", FT_UINT16,
  5004. BASE_HEX | BASE_EXT_STRING, &ppp_vals_ext, 0x0, NULL, HFILL }},
  5005. { &hf_lcp_opt_type,
  5006. { "Type", "lcp.opt.type", FT_UINT8, BASE_DEC,
  5007. NULL, 0x0, NULL, HFILL }},
  5008. { &hf_lcp_opt_length,
  5009. { "Length", "lcp.opt.length", FT_UINT8, BASE_DEC,
  5010. NULL, 0x0, NULL, HFILL }},
  5011. { &hf_lcp_opt_oui,
  5012. { "OUI", "lcp.opt.oui", FT_UINT24, BASE_HEX,
  5013. NULL, 0x0, NULL, HFILL }},
  5014. { &hf_lcp_opt_kind,
  5015. { "Kind", "lcp.opt.kind", FT_UINT8, BASE_DEC_HEX,
  5016. NULL, 0x0, NULL, HFILL }},
  5017. { &hf_lcp_opt_data,
  5018. { "Data", "lcp.opt.data", FT_BYTES, BASE_NONE,
  5019. NULL, 0x0, NULL, HFILL }},
  5020. { &hf_lcp_opt_mru,
  5021. { "Maximum Receive Unit", "lcp.opt.mru", FT_UINT16, BASE_DEC,
  5022. NULL, 0x0, NULL, HFILL }},
  5023. { &hf_lcp_opt_asyncmap,
  5024. { "Async Control Character Map", "lcp.opt.asyncmap", FT_UINT32,
  5025. BASE_HEX, NULL, 0x0, NULL, HFILL }},
  5026. { &hf_lcp_opt_asyncmap_nul,
  5027. { "NUL", "lcp.opt.asyncmap.nul", FT_BOOLEAN, 32,
  5028. NULL, 0x00000001, NULL, HFILL }},
  5029. { &hf_lcp_opt_asyncmap_soh,
  5030. { "SOH", "lcp.opt.asyncmap.soh", FT_BOOLEAN, 32,
  5031. NULL, 0x00000002, NULL, HFILL }},
  5032. { &hf_lcp_opt_asyncmap_stx,
  5033. { "STX", "lcp.opt.asyncmap.stx", FT_BOOLEAN, 32,
  5034. NULL, 0x00000004, NULL, HFILL }},
  5035. { &hf_lcp_opt_asyncmap_etx,
  5036. { "ETX", "lcp.opt.asyncmap.etx", FT_BOOLEAN, 32,
  5037. NULL, 0x00000008, NULL, HFILL }},
  5038. { &hf_lcp_opt_asyncmap_eot,
  5039. { "EOT", "lcp.opt.asyncmap.eot", FT_BOOLEAN, 32,
  5040. NULL, 0x00000010, NULL, HFILL }},
  5041. { &hf_lcp_opt_asyncmap_enq,
  5042. { "ENQ", "lcp.opt.asyncmap.enq", FT_BOOLEAN, 32,
  5043. NULL, 0x00000020, NULL, HFILL }},
  5044. { &hf_lcp_opt_asyncmap_ack,
  5045. { "ACK", "lcp.opt.asyncmap.ack", FT_BOOLEAN, 32,
  5046. NULL, 0x00000040, NULL, HFILL }},
  5047. { &hf_lcp_opt_asyncmap_bel,
  5048. { "BEL", "lcp.opt.asyncmap.bel", FT_BOOLEAN, 32,
  5049. NULL, 0x00000080, NULL, HFILL }},
  5050. { &hf_lcp_opt_asyncmap_bs,
  5051. { "BS", "lcp.opt.asyncmap.bs", FT_BOOLEAN, 32,
  5052. NULL, 0x00000100, NULL, HFILL }},
  5053. { &hf_lcp_opt_asyncmap_ht,
  5054. { "HT", "lcp.opt.asyncmap.ht", FT_BOOLEAN, 32,
  5055. NULL, 0x00000200, NULL, HFILL }},
  5056. { &hf_lcp_opt_asyncmap_lf,
  5057. { "LF", "lcp.opt.asyncmap.lf", FT_BOOLEAN, 32,
  5058. NULL, 0x00000400, NULL, HFILL }},
  5059. { &hf_lcp_opt_asyncmap_vt,
  5060. { "VT", "lcp.opt.asyncmap.vt", FT_BOOLEAN, 32,
  5061. NULL, 0x00000800, NULL, HFILL }},
  5062. { &hf_lcp_opt_asyncmap_ff,
  5063. { "FF", "lcp.opt.asyncmap.ff", FT_BOOLEAN, 32,
  5064. NULL, 0x00001000, NULL, HFILL }},
  5065. { &hf_lcp_opt_asyncmap_cr,
  5066. { "CR", "lcp.opt.asyncmap.cr", FT_BOOLEAN, 32,
  5067. NULL, 0x00002000, NULL, HFILL }},
  5068. { &hf_lcp_opt_asyncmap_so,
  5069. { "SO", "lcp.opt.asyncmap.so", FT_BOOLEAN, 32,
  5070. NULL, 0x00004000, NULL, HFILL }},
  5071. { &hf_lcp_opt_asyncmap_si,
  5072. { "SI", "lcp.opt.asyncmap.si", FT_BOOLEAN, 32,
  5073. NULL, 0x00008000, NULL, HFILL }},
  5074. { &hf_lcp_opt_asyncmap_dle,
  5075. { "DLE", "lcp.opt.asyncmap.dle", FT_BOOLEAN, 32,
  5076. NULL, 0x00010000, NULL, HFILL }},
  5077. { &hf_lcp_opt_asyncmap_dc1,
  5078. { "DC1 (XON)", "lcp.opt.asyncmap.dc1", FT_BOOLEAN, 32,
  5079. NULL, 0x00020000, NULL, HFILL }},
  5080. { &hf_lcp_opt_asyncmap_dc2,
  5081. { "DC2", "lcp.opt.asyncmap.dc2", FT_BOOLEAN, 32,
  5082. NULL, 0x00040000, NULL, HFILL }},
  5083. { &hf_lcp_opt_asyncmap_dc3,
  5084. { "DC3 (XOFF)", "lcp.opt.asyncmap.dc3", FT_BOOLEAN, 32,
  5085. NULL, 0x00080000, NULL, HFILL }},
  5086. { &hf_lcp_opt_asyncmap_dc4,
  5087. { "DC4", "lcp.opt.asyncmap.dc4", FT_BOOLEAN, 32,
  5088. NULL, 0x00100000, NULL, HFILL }},
  5089. { &hf_lcp_opt_asyncmap_nak,
  5090. { "NAK", "lcp.opt.asyncmap.nak", FT_BOOLEAN, 32,
  5091. NULL, 0x00200000, NULL, HFILL }},
  5092. { &hf_lcp_opt_asyncmap_syn,
  5093. { "SYN", "lcp.opt.asyncmap.syn", FT_BOOLEAN, 32,
  5094. NULL, 0x00400000, NULL, HFILL }},
  5095. { &hf_lcp_opt_asyncmap_etb,
  5096. { "ETB", "lcp.opt.asyncmap.etb", FT_BOOLEAN, 32,
  5097. NULL, 0x00800000, NULL, HFILL }},
  5098. { &hf_lcp_opt_asyncmap_can,
  5099. { "CAN", "lcp.opt.asyncmap.can", FT_BOOLEAN, 32,
  5100. NULL, 0x01000000, NULL, HFILL }},
  5101. { &hf_lcp_opt_asyncmap_em,
  5102. { "EM", "lcp.opt.asyncmap.em", FT_BOOLEAN, 32,
  5103. NULL, 0x02000000, NULL, HFILL }},
  5104. { &hf_lcp_opt_asyncmap_sub,
  5105. { "SUB", "lcp.opt.asyncmap.sub", FT_BOOLEAN, 32,
  5106. NULL, 0x04000000, NULL, HFILL }},
  5107. { &hf_lcp_opt_asyncmap_esc,
  5108. { "ESC", "lcp.opt.asyncmap.esc", FT_BOOLEAN, 32,
  5109. NULL, 0x08000000, NULL, HFILL }},
  5110. { &hf_lcp_opt_asyncmap_fs,
  5111. { "FS", "lcp.opt.asyncmap.fs", FT_BOOLEAN, 32,
  5112. NULL, 0x10000000, NULL, HFILL }},
  5113. { &hf_lcp_opt_asyncmap_gs,
  5114. { "GS", "lcp.opt.asyncmap.gs", FT_BOOLEAN, 32,
  5115. NULL, 0x20000000, NULL, HFILL }},
  5116. { &hf_lcp_opt_asyncmap_rs,
  5117. { "RS", "lcp.opt.asyncmap.rs", FT_BOOLEAN, 32,
  5118. NULL, 0x40000000, NULL, HFILL }},
  5119. { &hf_lcp_opt_asyncmap_us,
  5120. { "US", "lcp.opt.asyncmap.us", FT_BOOLEAN, 32,
  5121. NULL, 0x80000000, NULL, HFILL }},
  5122. { &hf_lcp_opt_auth_protocol,
  5123. { "Authentication Protocol", "lcp.opt.auth_protocol", FT_UINT16,
  5124. BASE_HEX | BASE_EXT_STRING, &ppp_vals_ext, 0x0, NULL, HFILL }},
  5125. { &hf_lcp_opt_algorithm,
  5126. { "Algorithm", "lcp.opt.algorithm", FT_UINT8,
  5127. BASE_DEC | BASE_RANGE_STRING, &chap_alg_rvals,
  5128. 0x0, NULL, HFILL }},
  5129. { &hf_lcp_opt_quality_protocol,
  5130. { "Quality Protocol", "lcp.opt.quality_protocol", FT_UINT16,
  5131. BASE_HEX | BASE_EXT_STRING, &ppp_vals_ext, 0x0, NULL, HFILL }},
  5132. { &hf_lcp_opt_magic_number,
  5133. { "Magic Number", "lcp.opt.magic_number", FT_UINT32, BASE_HEX,
  5134. NULL, 0x0, NULL, HFILL }},
  5135. { &hf_lcp_opt_reportingperiod,
  5136. { "Reporting Period", "lcp.opt.reporting_period", FT_UINT32,
  5137. BASE_DEC, NULL, 0x0,
  5138. "Maximum time in micro-seconds that the remote end should "
  5139. "wait between transmission of LCP Link-Quality-Report packets",
  5140. HFILL }},
  5141. { &hf_lcp_opt_fcs_alternatives,
  5142. { "FCS Alternatives", "lcp.opt.fcs_alternatives", FT_UINT8,
  5143. BASE_HEX, NULL, 0x0, NULL, HFILL }},
  5144. { &hf_lcp_opt_fcs_alternatives_null,
  5145. { "NULL FCS", "lcp.opt.fcs_alternatives.null", FT_BOOLEAN, 8,
  5146. NULL, 0x01, NULL, HFILL }},
  5147. { &hf_lcp_opt_fcs_alternatives_ccitt16,
  5148. { "CCITT 16-bit", "lcp.opt.fcs_alternatives.ccitt16", FT_BOOLEAN,
  5149. 8, NULL, 0x02, NULL, HFILL }},
  5150. { &hf_lcp_opt_fcs_alternatives_ccitt32,
  5151. { "CCITT 32-bit", "lcp.opt.fcs_alternatives.ccitt32", FT_BOOLEAN,
  5152. 8, NULL, 0x04, NULL, HFILL }},
  5153. { &hf_lcp_opt_maximum,
  5154. { "Maximum", "lcp.opt.maximum", FT_UINT8, BASE_DEC, NULL, 0x0,
  5155. "The largest number of padding octets which may be added "
  5156. "to the frame.", HFILL }},
  5157. { &hf_lcp_opt_window,
  5158. { "Window", "lcp.opt.window", FT_UINT8, BASE_DEC, NULL, 0x0,
  5159. "The number of frames the receiver will buffer.", HFILL }},
  5160. { &hf_lcp_opt_hdlc_address,
  5161. { "Address", "lcp.opt.hdlc_address", FT_BYTES, BASE_NONE, NULL,
  5162. 0x0, "An HDLC Address as specified in ISO 3309.", HFILL }},
  5163. { &hf_lcp_opt_operation,
  5164. { "Operation", "lcp.opt.operation", FT_UINT8, BASE_DEC,
  5165. VALS(callback_op_vals), 0x0, NULL, HFILL }},
  5166. { &hf_lcp_opt_message,
  5167. { "Message", "lcp.opt.message", FT_BYTES, BASE_NONE,
  5168. NULL, 0x0, NULL, HFILL }},
  5169. { &hf_lcp_opt_mrru,
  5170. { "MRRU", "lcp.opt.mrru", FT_UINT16, BASE_DEC, NULL, 0x0,
  5171. "Maximum Receive Reconstructed Unit", HFILL }},
  5172. { &hf_lcp_opt_ep_disc_class,
  5173. { "Class", "lcp.opt.ep_disc_class", FT_UINT8, BASE_DEC,
  5174. VALS(multilink_ep_disc_class_vals), 0x0, NULL, HFILL }},
  5175. { &hf_lcp_opt_ip_address,
  5176. { "IP Address", "lcp.opt.ip_address", FT_IPv4, BASE_NONE,
  5177. NULL, 0x0, NULL, HFILL }},
  5178. { &hf_lcp_opt_802_1_address,
  5179. { "IEEE 802.1 Address", "lcp.opt.802_1_address", FT_ETHER,
  5180. BASE_NONE, NULL, 0x0, NULL, HFILL }},
  5181. { &hf_lcp_opt_magic_block,
  5182. { "PPP Magic-Number Block", "lcp.opt.magic_block", FT_BYTES,
  5183. BASE_NONE, NULL, 0x0, NULL, HFILL }},
  5184. { &hf_lcp_opt_psndn,
  5185. { "Public Switched Network Directory Number", "lcp.opt.psndn",
  5186. FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
  5187. { &hf_lcp_opt_mode,
  5188. { "Mode", "lcp.opt.mode", FT_UINT8, BASE_DEC,
  5189. VALS(dce_id_mode_vals), 0x0, NULL, HFILL }},
  5190. { &hf_lcp_opt_unused,
  5191. { "Unused", "lcp.opt.unused", FT_BYTES, BASE_NONE,
  5192. NULL, 0x0, NULL, HFILL }},
  5193. { &hf_lcp_opt_link_discrim,
  5194. { "Link Discriminator", "lcp.opt.link_discrim", FT_UINT16,
  5195. BASE_DEC_HEX, NULL, 0x0, NULL, HFILL }},
  5196. { &hf_lcp_opt_id,
  5197. { "Identification", "lcp.opt.id", FT_UINT_BYTES, BASE_NONE,
  5198. NULL, 0x0, NULL, HFILL }},
  5199. { &hf_lcp_opt_cobs_flags,
  5200. { "Flags", "lcp.opt.flags", FT_UINT8, BASE_HEX,
  5201. NULL, 0x0, NULL, HFILL }},
  5202. { &hf_lcp_opt_cobs_flags_res,
  5203. { "Reserved", "lcp.opt.flags.reserved", FT_UINT8, BASE_HEX,
  5204. NULL, 0xFC, NULL, HFILL }},
  5205. { &hf_lcp_opt_cobs_flags_pre,
  5206. { "PRE", "lcp.opt.flags.pre", FT_BOOLEAN, 8,
  5207. NULL, 0x02, "Preemption", HFILL }},
  5208. { &hf_lcp_opt_cobs_flags_zxe,
  5209. { "ZXE", "lcp.opt.flags.zxe", FT_BOOLEAN, 8,
  5210. NULL, 0x01, "Zero pair/run elimination", HFILL }},
  5211. { &hf_lcp_opt_class,
  5212. { "Class", "lcp.opt.class", FT_UINT8, BASE_DEC,
  5213. NULL, 0x0, NULL, HFILL }},
  5214. { &hf_lcp_opt_prefix,
  5215. { "Prefix", "lcp.opt.prefix", FT_UINT_BYTES, BASE_NONE,
  5216. NULL, 0x0, NULL, HFILL }},
  5217. { &hf_lcp_opt_code,
  5218. { "Code", "lcp.opt.code", FT_UINT8, BASE_DEC,
  5219. VALS(ml_hdr_fmt_code_vals), 0x0, NULL, HFILL }},
  5220. { &hf_lcp_opt_max_susp_classes,
  5221. { "Max suspendable classes", "lcp.opt.max_susp_classes",
  5222. FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
  5223. { &hf_lcp_opt_MIBenum,
  5224. { "MIBenum", "lcp.opt.MIBenum", FT_UINT32,
  5225. BASE_DEC | BASE_EXT_STRING, &charset_vals_ext, 0x0,
  5226. "A unique integer value identifying a charset", HFILL }},
  5227. { &hf_lcp_opt_language_tag,
  5228. { "Language-Tag", "lcp.opt.language_tag", FT_STRING, BASE_NONE,
  5229. NULL, 0x0, NULL, HFILL }}
  5230. };
  5231. static gint *ett[] = {
  5232. &ett_lcp,
  5233. &ett_lcp_options,
  5234. &ett_lcp_vendor_opt,
  5235. &ett_lcp_mru_opt,
  5236. &ett_lcp_asyncmap_opt,
  5237. &ett_lcp_authprot_opt,
  5238. &ett_lcp_qualprot_opt,
  5239. &ett_lcp_magicnumber_opt,
  5240. &ett_lcp_linkqualmon_opt,
  5241. &ett_lcp_pcomp_opt,
  5242. &ett_lcp_acccomp_opt,
  5243. &ett_lcp_fcs_alternatives_opt,
  5244. &ett_lcp_self_desc_pad_opt,
  5245. &ett_lcp_numbered_mode_opt,
  5246. &ett_lcp_callback_opt,
  5247. &ett_lcp_compound_frames_opt,
  5248. &ett_lcp_nomdataencap_opt,
  5249. &ett_lcp_multilink_mrru_opt,
  5250. &ett_lcp_multilink_ssnh_opt,
  5251. &ett_lcp_multilink_ep_disc_opt,
  5252. &ett_lcp_magic_block,
  5253. &ett_lcp_dce_identifier_opt,
  5254. &ett_lcp_multilink_pp_opt,
  5255. &ett_lcp_bacp_link_discrim_opt,
  5256. &ett_lcp_auth_opt,
  5257. &ett_lcp_cobs_opt,
  5258. &ett_lcp_prefix_elision_opt,
  5259. &ett_multilink_hdr_fmt_opt,
  5260. &ett_lcp_internationalization_opt,
  5261. &ett_lcp_simple_opt
  5262. };
  5263. proto_lcp = proto_register_protocol("PPP Link Control Protocol", "PPP LCP",
  5264. "lcp");
  5265. proto_register_field_array(proto_lcp, hf, array_length(hf));
  5266. proto_register_subtree_array(ett, array_length(ett));
  5267. }
  5268. void
  5269. proto_reg_handoff_lcp(void)
  5270. {
  5271. dissector_handle_t lcp_handle;
  5272. lcp_handle = create_dissector_handle(dissect_lcp, proto_lcp);
  5273. dissector_add_uint("ppp.protocol", PPP_LCP, lcp_handle);
  5274. /*
  5275. * NDISWAN on Windows translates Ethernet frames from higher-level
  5276. * protocols into PPP frames to hand to the PPP driver, and translates
  5277. * PPP frames from the PPP driver to hand to the higher-level protocols.
  5278. *
  5279. * Apparently the PPP driver, on at least some versions of Windows,
  5280. * passes frames for internal-to-PPP protocols up through NDISWAN;
  5281. * the protocol type field appears to be passed through unchanged
  5282. * (unlike what's done with, for example, the protocol type field
  5283. * for IP, which is mapped from its PPP value to its Ethernet value).
  5284. *
  5285. * This means that we may see, on Ethernet captures, frames for
  5286. * protocols internal to PPP, so we register PPP_LCP with the
  5287. * "ethertype" dissector table as well as the PPP protocol dissector
  5288. * table.
  5289. */
  5290. dissector_add_uint("ethertype", PPP_LCP, lcp_handle);
  5291. /*
  5292. * for GSM-A / MobileL3 / GPRS SM / PCO
  5293. */
  5294. dissector_add_uint("sm_pco.protocol", PPP_LCP, lcp_handle);
  5295. }
  5296. void
  5297. proto_register_vsncp(void)
  5298. {
  5299. static gint *ett[] = {
  5300. &ett_vsncp,
  5301. &ett_vsncp_options
  5302. };
  5303. proto_vsncp = proto_register_protocol("Vendor Specific Control Protocol",
  5304. "VSNCP", "vsncp");
  5305. proto_register_subtree_array(ett, array_length(ett));
  5306. }
  5307. void
  5308. proto_reg_handoff_vsncp(void)
  5309. {
  5310. dissector_handle_t vsncp_handle;
  5311. vsncp_handle = create_dissector_handle(dissect_vsncp, proto_vsncp);
  5312. dissector_add_uint("ppp.protocol", PPP_VSNCP, vsncp_handle);
  5313. }
  5314. void
  5315. proto_register_vsnp(void)
  5316. {
  5317. static gint *ett[] = {
  5318. &ett_vsnp
  5319. };
  5320. static hf_register_info hf[] = {
  5321. { &hf_vsnp_pdnid,
  5322. { "PDN ID", "vsnp.pdnid", FT_UINT8, BASE_HEX,
  5323. NULL, 0x0, NULL, HFILL }}
  5324. };
  5325. proto_vsnp = proto_register_protocol("Vendor Specific Network Protocol",
  5326. "PPP VSNP", "vsnp");
  5327. proto_register_subtree_array(ett, array_length(ett));
  5328. proto_register_field_array(proto_vsnp, hf, array_length(hf));
  5329. }
  5330. void
  5331. proto_reg_handoff_vsnp(void)
  5332. {
  5333. dissector_handle_t vsnp_handle;
  5334. vsnp_handle = create_dissector_handle(dissect_vsnp, proto_vsnp);
  5335. dissector_add_uint("ppp.protocol", PPP_VSNP, vsnp_handle);
  5336. }
  5337. void
  5338. proto_register_ipcp(void)
  5339. {
  5340. static hf_register_info hf[] = {
  5341. { &hf_ipcp_opt_type,
  5342. { "Type", "ipcp.opt.type", FT_UINT8, BASE_DEC,
  5343. NULL, 0x0, NULL, HFILL }},
  5344. { &hf_ipcp_opt_length,
  5345. { "Length", "ipcp.opt.length", FT_UINT8, BASE_DEC,
  5346. NULL, 0x0, NULL, HFILL }},
  5347. { &hf_ipcp_opt_src_address,
  5348. { "Source IP Address", "ipcp.opt.src_address", FT_IPv4, BASE_NONE,
  5349. NULL, 0x0, NULL, HFILL }},
  5350. { &hf_ipcp_opt_dst_address,
  5351. { "Destination IP Address", "ipcp.opt.dst_address", FT_IPv4,
  5352. BASE_NONE, NULL, 0x0, NULL, HFILL }},
  5353. { &hf_ipcp_opt_compress_proto,
  5354. { "IP Compression Protocol", "ipcp.opt.compress_proto", FT_UINT16,
  5355. BASE_HEX, VALS(ipcp_compress_proto_vals), 0x0, NULL, HFILL }},
  5356. { &hf_ipcp_opt_max_cid,
  5357. { "Max CID", "ipcp.opt.max_cid", FT_UINT16, BASE_DEC,
  5358. NULL, 0x0, "Maximum value of a context identifier", HFILL }},
  5359. { &hf_ipcp_opt_mrru,
  5360. { "MRRU", "ipcp.opt.mrru", FT_UINT16, BASE_DEC,
  5361. NULL, 0x0, "Maximum Reconstructed Reception Unit", HFILL }},
  5362. { &hf_ipcp_opt_max_slot_id,
  5363. { "Max Slot ID", "ipcp.opt.max_slot_id", FT_UINT8, BASE_DEC,
  5364. NULL, 0x0, NULL, HFILL }},
  5365. { &hf_ipcp_opt_comp_slot_id,
  5366. { "Comp Slot ID", "ipcp.opt.comp_slot_id", FT_BOOLEAN, 8,
  5367. TFS(&tfs_comp_slot_id), 0x01, NULL, HFILL }},
  5368. { &hf_ipcp_opt_tcp_space,
  5369. { "TCP Space", "ipcp.opt.tcp_space", FT_UINT16, BASE_DEC,
  5370. NULL, 0x0, NULL, HFILL }},
  5371. { &hf_ipcp_opt_non_tcp_space,
  5372. { "Non TCP Space", "ipcp.opt.non_tcp_space", FT_UINT16, BASE_DEC,
  5373. NULL, 0x0, NULL, HFILL }},
  5374. { &hf_ipcp_opt_f_max_period,
  5375. { "F Max Period", "ipcp.opt.f_max_period", FT_UINT16, BASE_DEC,
  5376. NULL, 0x0, "Maximum interval between full headers", HFILL }},
  5377. { &hf_ipcp_opt_f_max_time,
  5378. { "F Max Time", "ipcp.opt.f_max_time", FT_UINT16, BASE_DEC, NULL,
  5379. 0x0, "Maximum time interval between full headers", HFILL }},
  5380. { &hf_ipcp_opt_max_header,
  5381. { "Max Header", "ipcp.opt.max_header", FT_UINT16, BASE_DEC, NULL,
  5382. 0x0,
  5383. "The largest header size in octets that may be compressed",
  5384. HFILL }},
  5385. { &hf_ipcp_data,
  5386. { "Data", "ipcp.data", FT_BYTES, BASE_NONE,
  5387. NULL, 0x0, NULL, HFILL }},
  5388. { &hf_ipcp_opt_ip_address,
  5389. { "IP Address", "ipcp.opt.ip_address", FT_IPv4, BASE_NONE,
  5390. NULL, 0x0, NULL, HFILL }},
  5391. { &hf_ipcp_opt_mobilenodehomeaddr,
  5392. { "Mobile Node's Home Address", "ipcp.opt.mobilenodehomeaddress",
  5393. FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
  5394. { &hf_ipcp_opt_pri_dns_address,
  5395. { "Primary DNS Address", "ipcp.opt.pri_dns_address",
  5396. FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
  5397. { &hf_ipcp_opt_pri_nbns_address,
  5398. { "Primary NBNS Address", "ipcp.opt.pri_nbns_address",
  5399. FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
  5400. { &hf_ipcp_opt_sec_dns_address,
  5401. { "Secondary DNS Address", "ipcp.opt.sec_dns_address",
  5402. FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
  5403. { &hf_ipcp_opt_sec_nbns_address,
  5404. { "Secondary NBNS Address", "ipcp.opt.sec_nbns_address",
  5405. FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
  5406. { &hf_ipcp_opt_rohc_type,
  5407. { "Type", "ipcp.opt.rohc.type", FT_UINT8, BASE_DEC,
  5408. NULL, 0x0, NULL, HFILL }},
  5409. { &hf_ipcp_opt_rohc_length,
  5410. { "Length", "ipcp.opt.rohc.length", FT_UINT8, BASE_DEC,
  5411. NULL, 0x0, NULL, HFILL }},
  5412. { &hf_ipcp_opt_rohc_profile,
  5413. { "Profile", "ipcp.opt.rohc.profile", FT_UINT16, BASE_HEX,
  5414. VALS(ipcp_rohc_profile_vals), 0x0, NULL, HFILL }},
  5415. { &hf_ipcp_opt_iphc_type,
  5416. { "Type", "ipcp.opt.iphc.type", FT_UINT8, BASE_DEC,
  5417. NULL, 0x0, NULL, HFILL }},
  5418. { &hf_ipcp_opt_iphc_length,
  5419. { "Length", "ipcp.opt.iphc.length", FT_UINT8, BASE_DEC,
  5420. NULL, 0x0, NULL, HFILL }},
  5421. { &hf_ipcp_opt_iphc_param,
  5422. { "Parameter", "ipcp.opt.iphc.param", FT_UINT8, BASE_DEC,
  5423. VALS(ipcp_iphc_parameter_vals), 0x0, NULL, HFILL }}
  5424. };
  5425. static gint *ett[] = {
  5426. &ett_ipcp,
  5427. &ett_ipcp_options,
  5428. &ett_ipcp_ipaddrs_opt,
  5429. &ett_ipcp_compress_opt,
  5430. &ett_ipcp_ipaddr_opt,
  5431. &ett_ipcp_mobileipv4_opt,
  5432. &ett_ipcp_pridns_opt,
  5433. &ett_ipcp_secdns_opt,
  5434. &ett_ipcp_prinbns_opt,
  5435. &ett_ipcp_secnbns_opt,
  5436. &ett_ipcp_iphc_rtp_compress_opt,
  5437. &ett_ipcp_iphc_enhanced_rtp_compress_opt,
  5438. &ett_ipcp_iphc_neghdrcomp_opt,
  5439. &ett_ipcp_rohc_profiles_opt
  5440. };
  5441. proto_ipcp = proto_register_protocol("PPP IP Control Protocol", "PPP IPCP",
  5442. "ipcp");
  5443. proto_register_field_array(proto_ipcp, hf, array_length(hf));
  5444. proto_register_subtree_array(ett, array_length(ett));
  5445. }
  5446. void
  5447. proto_reg_handoff_ipcp(void)
  5448. {
  5449. dissector_handle_t ipcp_handle;
  5450. ipcp_handle = create_dissector_handle(dissect_ipcp, proto_ipcp);
  5451. dissector_add_uint("ppp.protocol", PPP_IPCP, ipcp_handle);
  5452. /*
  5453. * See above comment about NDISWAN for an explanation of why we're
  5454. * registering with the "ethertype" dissector table.
  5455. */
  5456. dissector_add_uint("ethertype", PPP_IPCP, ipcp_handle);
  5457. /*
  5458. * for GSM-A / MobileL3 / GPRS SM / PCO
  5459. */
  5460. dissector_add_uint("sm_pco.protocol", PPP_IPCP, ipcp_handle);
  5461. }
  5462. void
  5463. proto_register_bcp(void)
  5464. {
  5465. static hf_register_info hf[] = {
  5466. { &hf_bcp_flags,
  5467. { "Flags", "bcp.flags", FT_UINT8, BASE_HEX,
  5468. NULL, 0x0, NULL, HFILL }},
  5469. { &hf_bcp_fcs_present,
  5470. { "LAN FCS present", "bcp.flags.fcs_present", FT_BOOLEAN, 8,
  5471. TFS(&tfs_yes_no), BCP_FCS_PRESENT, NULL, HFILL }},
  5472. { &hf_bcp_zeropad,
  5473. { "802.3 pad zero-filled", "bcp.flags.zeropad", FT_BOOLEAN, 8,
  5474. TFS(&tfs_yes_no), BCP_ZEROPAD, NULL, HFILL }},
  5475. { &hf_bcp_bcontrol,
  5476. { "Bridge control", "bcp.flags.bcontrol", FT_BOOLEAN, 8,
  5477. TFS(&tfs_yes_no), BCP_IS_BCONTROL, NULL, HFILL }},
  5478. { &hf_bcp_pads,
  5479. { "Pads", "bcp.pads", FT_UINT8, BASE_DEC,
  5480. NULL, BCP_PADS_MASK, NULL, HFILL }},
  5481. { &hf_bcp_mac_type,
  5482. { "MAC Type", "bcp.mac_type", FT_UINT8, BASE_DEC,
  5483. VALS(bcp_mac_type_vals), 0x0, NULL, HFILL }}
  5484. };
  5485. static gint *ett[] = {
  5486. &ett_bcp,
  5487. &ett_bcp_flags
  5488. };
  5489. proto_bcp = proto_register_protocol("PPP Bridging Control Protocol",
  5490. "PPP BCP", "bcp");
  5491. proto_register_field_array(proto_bcp, hf, array_length(hf));
  5492. proto_register_subtree_array(ett, array_length(ett));
  5493. }
  5494. void
  5495. proto_register_osinlcp(void)
  5496. {
  5497. static hf_register_info hf[] = {
  5498. { &hf_osinlcp_opt_type,
  5499. { "Type", "osinlcp.opt.type", FT_UINT8, BASE_DEC,
  5500. NULL, 0x0, NULL, HFILL }},
  5501. { &hf_osinlcp_opt_length,
  5502. { "Length", "osinlcp.opt.length", FT_UINT8, BASE_DEC,
  5503. NULL, 0x0, NULL, HFILL }},
  5504. { &hf_osinlcp_opt_alignment,
  5505. { "Alignment", "osinlcp.opt.alignment", FT_UINT8, BASE_DEC,
  5506. NULL, 0x0, NULL, HFILL }}
  5507. };
  5508. static gint *ett[] = {
  5509. &ett_osinlcp,
  5510. &ett_osinlcp_options,
  5511. &ett_osinlcp_align_npdu_opt
  5512. };
  5513. proto_osinlcp = proto_register_protocol(
  5514. "PPP OSI Network Layer Control Protocol", "PPP OSINLCP", "osinlcp");
  5515. proto_register_field_array(proto_osinlcp, hf, array_length(hf));
  5516. proto_register_subtree_array(ett, array_length(ett));
  5517. }
  5518. void
  5519. proto_reg_handoff_bcp(void)
  5520. {
  5521. dissector_handle_t bcp_handle;
  5522. eth_withfcs_handle = find_dissector("eth_withfcs");
  5523. eth_withoutfcs_handle = find_dissector("eth_withoutfcs");
  5524. bcp_handle = create_dissector_handle(dissect_bcp, proto_bcp);
  5525. dissector_add_uint("ppp.protocol", PPP_BCP, bcp_handle);
  5526. }
  5527. void
  5528. proto_reg_handoff_osinlcp(void)
  5529. {
  5530. dissector_handle_t osinlcp_handle;
  5531. osinlcp_handle = create_dissector_handle(dissect_osinlcp, proto_osinlcp);
  5532. dissector_add_uint("ppp.protocol", PPP_OSINLCP, osinlcp_handle);
  5533. /*
  5534. * See above comment about NDISWAN for an explanation of why we're
  5535. * registering with the "ethertype" dissector table.
  5536. */
  5537. dissector_add_uint("ethertype", PPP_OSINLCP, osinlcp_handle);
  5538. }
  5539. void
  5540. proto_register_ccp(void)
  5541. {
  5542. static hf_register_info hf[] = {
  5543. { &hf_ccp_opt_type,
  5544. { "Type", "ccp.opt.type", FT_UINT8, BASE_DEC,
  5545. NULL, 0x0, NULL, HFILL }},
  5546. { &hf_ccp_opt_length,
  5547. { "Length", "ccp.opt.length", FT_UINT8, BASE_DEC,
  5548. NULL, 0x0, NULL, HFILL }},
  5549. { &hf_ccp_opt_oui,
  5550. { "OUI", "ccp.opt.oui", FT_UINT24, BASE_HEX,
  5551. NULL, 0x0, NULL, HFILL }},
  5552. { &hf_ccp_opt_subtype,
  5553. { "Subtype", "ccp.opt.subtype", FT_UINT8, BASE_DEC_HEX,
  5554. NULL, 0x0, NULL, HFILL }},
  5555. { &hf_ccp_opt_history_count,
  5556. { "History Count", "ccp.opt.history_count", FT_UINT16, BASE_DEC,
  5557. NULL, 0x0, "The maximum number of compression histories",
  5558. HFILL }},
  5559. { &hf_ccp_opt_cm,
  5560. { "Check Mode Field", "ccp.opt.cm", FT_UINT8, BASE_DEC,
  5561. NULL, 0x0, NULL, HFILL }},
  5562. { &hf_ccp_opt_cm_reserved,
  5563. { "Reserved", "ccp.opt.cm.reserved", FT_UINT8, BASE_DEC,
  5564. NULL, 0xF8, NULL, HFILL }},
  5565. { &hf_ccp_opt_cm_check_mode,
  5566. { "Check Mode", "ccp.opt.cm.check_mode", FT_UINT8, BASE_DEC,
  5567. VALS(stac_checkmode_vals), 0x07, NULL, HFILL }},
  5568. { &hf_ccp_opt_supported_bits,
  5569. { "Supported Bits", "ccp.opt.supported_bits", FT_UINT32, BASE_HEX,
  5570. NULL, 0x0, NULL, HFILL }},
  5571. { &hf_ccp_opt_supported_bits_h,
  5572. { "H", "ccp.opt.supported_bits.h", FT_BOOLEAN, 32,
  5573. TFS(&ccp_mppe_h_tfs), MPPE_SUPPORTED_BITS_H, NULL, HFILL }},
  5574. { &hf_ccp_opt_supported_bits_m,
  5575. { "M", "ccp.opt.supported_bits.m", FT_BOOLEAN, 32,
  5576. TFS(&ccp_mppe_m_tfs), MPPE_SUPPORTED_BITS_M, NULL, HFILL }},
  5577. { &hf_ccp_opt_supported_bits_s,
  5578. { "S", "ccp.opt.supported_bits.s", FT_BOOLEAN, 32,
  5579. TFS(&ccp_mppe_s_tfs), MPPE_SUPPORTED_BITS_S, NULL, HFILL }},
  5580. { &hf_ccp_opt_supported_bits_l,
  5581. { "L", "ccp.opt.supported_bits.l", FT_BOOLEAN, 32,
  5582. TFS(&ccp_mppe_l_tfs), MPPE_SUPPORTED_BITS_L, NULL, HFILL }},
  5583. { &hf_ccp_opt_supported_bits_d,
  5584. { "D", "ccp.opt.supported_bits.d", FT_BOOLEAN, 32,
  5585. TFS(&ccp_mppe_d_tfs), MPPE_SUPPORTED_BITS_D, NULL, HFILL }},
  5586. { &hf_ccp_opt_supported_bits_c,
  5587. { "C", "ccp.opt.supported_bits.c", FT_BOOLEAN, 32,
  5588. TFS(&ccp_mppe_c_tfs), MPPC_SUPPORTED_BITS_C, NULL, HFILL }},
  5589. { &hf_ccp_opt_history,
  5590. { "History", "ccp.opt.history", FT_UINT8, BASE_DEC, NULL, 0x0,
  5591. "Maximum size of the compression history in powers of 2",
  5592. HFILL }},
  5593. { &hf_ccp_opt_version,
  5594. { "Version", "ccp.opt.version", FT_BYTES, BASE_NONE,
  5595. NULL, 0x0, NULL, HFILL }},
  5596. { &hf_ccp_opt_vd,
  5597. { "Vers/Dict", "ccp.opt.vd", FT_UINT8, BASE_HEX,
  5598. NULL, 0x0, NULL, HFILL }},
  5599. { &hf_ccp_opt_vd_vers,
  5600. { "Vers", "ccp.opt.vd.vers", FT_UINT8, BASE_DEC,
  5601. NULL, 0xE0, NULL, HFILL }},
  5602. { &hf_ccp_opt_vd_dict,
  5603. { "Dict", "ccp.opt.vd.dict", FT_UINT8, BASE_DEC, NULL,
  5604. 0x1F, "The size in bits of the largest code used", HFILL }},
  5605. { &hf_ccp_opt_check_mode,
  5606. { "Check Mode", "ccp.opt.check_mode", FT_UINT8, BASE_DEC,
  5607. VALS(&lzsdcp_checkmode_vals), 0x0, NULL, HFILL }},
  5608. { &hf_ccp_opt_process_mode,
  5609. { "Process Mode", "ccp.opt.process_mode", FT_UINT8, BASE_DEC,
  5610. VALS(&lzsdcp_processmode_vals), 0x0, NULL, HFILL }},
  5611. { &hf_ccp_opt_fe,
  5612. { "Features", "ccp.opt.fe", FT_UINT8, BASE_DEC,
  5613. NULL, 0xC0, NULL, HFILL }},
  5614. { &hf_ccp_opt_p,
  5615. { "Packet by Packet flag", "ccp.opt.p", FT_BOOLEAN, 8,
  5616. TFS(&tfs_enabled_disabled), 0x20, NULL, HFILL }},
  5617. { &hf_ccp_opt_History,
  5618. { "History", "ccp.opt.History", FT_UINT8, BASE_DEC,
  5619. NULL, 0x1F, NULL, HFILL }},
  5620. { &hf_ccp_opt_contexts,
  5621. { "# Contexts", "ccp.opt.contexts", FT_UINT8, BASE_DEC,
  5622. NULL, 0x0, NULL, HFILL }},
  5623. { &hf_ccp_opt_mode,
  5624. { "Mode", "ccp.opt.mode", FT_UINT8, BASE_DEC,
  5625. VALS(&dce_mode_vals), 0x0, NULL, HFILL }},
  5626. { &hf_ccp_opt_window,
  5627. { "Window", "ccp.opt.window", FT_UINT8, BASE_DEC,
  5628. NULL, 0xF0, NULL, HFILL }},
  5629. { &hf_ccp_opt_method,
  5630. { "Method", "ccp.opt.method", FT_UINT8, BASE_DEC,
  5631. VALS(&deflate_method_vals), 0x0F, NULL, HFILL }},
  5632. { &hf_ccp_opt_mbz,
  5633. { "MBZ", "ccp.opt.mbz", FT_UINT8, BASE_DEC,
  5634. NULL, 0xFC, NULL, HFILL }},
  5635. { &hf_ccp_opt_chk,
  5636. { "Chk", "ccp.opt.chk", FT_UINT8, BASE_DEC,
  5637. VALS(&deflate_chk_vals), 0x03, NULL, HFILL }},
  5638. { &hf_ccp_opt_mode_dictcount,
  5639. { "Mode/Dictionary Count", "ccp.opt.mode_dictcount", FT_UINT16,
  5640. BASE_DEC | BASE_RANGE_STRING, RVALS(v44lzjh_mode_dict_rvals),
  5641. 0x0, NULL, HFILL }},
  5642. { &hf_ccp_opt_dict_size,
  5643. { "Dictionary Size", "ccp.opt.dict_size", FT_UINT16, BASE_DEC,
  5644. NULL, 0x0, NULL, HFILL }},
  5645. { &hf_ccp_opt_history_length,
  5646. { "History Length", "ccp.opt.history_length", FT_UINT16, BASE_DEC,
  5647. NULL, 0x0, NULL, HFILL }},
  5648. { &hf_ccp_opt_data,
  5649. { "Data", "ccp.opt.data", FT_BYTES, BASE_NONE,
  5650. NULL, 0x0, NULL, HFILL }},
  5651. };
  5652. static gint *ett[] = {
  5653. &ett_ccp,
  5654. &ett_ccp_options,
  5655. &ett_ccp_oui_opt,
  5656. &ett_ccp_predict1_opt,
  5657. &ett_ccp_predict2_opt,
  5658. &ett_ccp_puddle_opt,
  5659. &ett_ccp_hpppc_opt,
  5660. &ett_ccp_stac_opt,
  5661. &ett_ccp_stac_opt_check_mode,
  5662. &ett_ccp_mppe_opt,
  5663. &ett_ccp_mppe_opt_supp_bits,
  5664. &ett_ccp_gfza_opt,
  5665. &ett_ccp_v42bis_opt,
  5666. &ett_ccp_bsdcomp_opt,
  5667. &ett_ccp_lzsdcp_opt,
  5668. &ett_ccp_mvrca_opt,
  5669. &ett_ccp_dce_opt,
  5670. &ett_ccp_deflate_opt,
  5671. &ett_ccp_v44lzjh_opt
  5672. };
  5673. proto_ccp = proto_register_protocol("PPP Compression Control Protocol",
  5674. "PPP CCP", "ccp");
  5675. proto_register_field_array(proto_ccp, hf, array_length(hf));
  5676. proto_register_subtree_array(ett, array_length(ett));
  5677. }
  5678. void
  5679. proto_reg_handoff_ccp(void)
  5680. {
  5681. dissector_handle_t ccp_handle;
  5682. ccp_handle = create_dissector_handle(dissect_ccp, proto_ccp);
  5683. dissector_add_uint("ppp.protocol", PPP_CCP, ccp_handle);
  5684. /*
  5685. * See above comment about NDISWAN for an explanation of why we're
  5686. * registering with the "ethertype" dissector table.
  5687. */
  5688. dissector_add_uint("ethertype", PPP_CCP, ccp_handle);
  5689. }
  5690. void
  5691. proto_register_cbcp(void)
  5692. {
  5693. static gint *ett[] = {
  5694. &ett_cbcp,
  5695. &ett_cbcp_options,
  5696. &ett_cbcp_callback_opt,
  5697. &ett_cbcp_callback_opt_addr
  5698. };
  5699. proto_cbcp = proto_register_protocol("PPP Callback Control Protocol",
  5700. "PPP CBCP", "cbcp");
  5701. proto_register_subtree_array(ett, array_length(ett));
  5702. }
  5703. void
  5704. proto_reg_handoff_cbcp(void)
  5705. {
  5706. dissector_handle_t cbcp_handle;
  5707. cbcp_handle = create_dissector_handle(dissect_cbcp, proto_cbcp);
  5708. dissector_add_uint("ppp.protocol", PPP_CBCP, cbcp_handle);
  5709. /*
  5710. * See above comment about NDISWAN for an explanation of why we're
  5711. * registering with the "ethertype" dissector table.
  5712. */
  5713. dissector_add_uint("ethertype", PPP_CBCP, cbcp_handle);
  5714. }
  5715. void
  5716. proto_register_bacp(void)
  5717. {
  5718. static gint *ett[] = {
  5719. &ett_bacp,
  5720. &ett_bacp_options,
  5721. &ett_bacp_favored_peer_opt
  5722. };
  5723. proto_bacp = proto_register_protocol(
  5724. "PPP Bandwidth Allocation Control Protocol", "PPP BACP", "bacp");
  5725. proto_register_subtree_array(ett, array_length(ett));
  5726. }
  5727. void
  5728. proto_reg_handoff_bacp(void)
  5729. {
  5730. dissector_handle_t bacp_handle;
  5731. bacp_handle = create_dissector_handle(dissect_bacp, proto_bacp);
  5732. dissector_add_uint("ppp.protocol", PPP_BACP, bacp_handle);
  5733. /*
  5734. * See above comment about NDISWAN for an explanation of why we're
  5735. * registering with the "ethertype" dissector table.
  5736. */
  5737. dissector_add_uint("ethertype", PPP_BACP, bacp_handle);
  5738. }
  5739. void
  5740. proto_register_bap(void)
  5741. {
  5742. static gint *ett[] = {
  5743. &ett_bap,
  5744. &ett_bap_options,
  5745. &ett_bap_link_type_opt,
  5746. &ett_bap_phone_delta_opt,
  5747. &ett_bap_phone_delta_subopt,
  5748. &ett_bap_call_status_opt
  5749. };
  5750. proto_bap = proto_register_protocol("PPP Bandwidth Allocation Protocol",
  5751. "PPP BAP", "bap");
  5752. proto_register_subtree_array(ett, array_length(ett));
  5753. }
  5754. void
  5755. proto_reg_handoff_bap(void)
  5756. {
  5757. dissector_handle_t bap_handle;
  5758. bap_handle = create_dissector_handle(dissect_bap, proto_bap);
  5759. dissector_add_uint("ppp.protocol", PPP_BAP, bap_handle);
  5760. /*
  5761. * See above comment about NDISWAN for an explanation of why we're
  5762. * registering with the "ethertype" dissector table.
  5763. */
  5764. dissector_add_uint("ethertype", PPP_BAP, bap_handle);
  5765. }
  5766. void
  5767. proto_register_comp_data(void)
  5768. {
  5769. #if 0 /* See dissect_comp_data() */
  5770. static gint *ett[] = {
  5771. &ett_comp_data
  5772. };
  5773. #endif
  5774. proto_comp_data = proto_register_protocol("PPP Compressed Datagram",
  5775. "PPP Comp", "comp_data");
  5776. #if 0
  5777. proto_register_subtree_array(ett, array_length(ett));
  5778. #endif
  5779. }
  5780. void
  5781. proto_reg_handoff_comp_data(void)
  5782. {
  5783. dissector_handle_t comp_data_handle;
  5784. comp_data_handle = create_dissector_handle(dissect_comp_data,
  5785. proto_comp_data);
  5786. dissector_add_uint("ppp.protocol", PPP_COMP, comp_data_handle);
  5787. /*
  5788. * See above comment about NDISWAN for an explanation of why we're
  5789. * registering with the "ethertype" dissector table.
  5790. */
  5791. dissector_add_uint("ethertype", PPP_COMP, comp_data_handle);
  5792. }
  5793. void
  5794. proto_register_pap(void)
  5795. {
  5796. static gint *ett[] = {
  5797. &ett_pap,
  5798. &ett_pap_data
  5799. };
  5800. static hf_register_info hf[] = {
  5801. { &hf_pap_code,
  5802. { "Code", "pap.code", FT_UINT8, BASE_DEC, VALS(pap_vals), 0x0,
  5803. "The Code field is one octet and identifies the type of PAP "
  5804. "packet", HFILL }},
  5805. { &hf_pap_identifier,
  5806. { "Identifier", "pap.identifier", FT_UINT8, BASE_DEC, NULL, 0x0,
  5807. "The Identifier field is one octet and aids in matching "
  5808. "requests and replies.", HFILL }},
  5809. { &hf_pap_length,
  5810. { "Length", "pap.length", FT_UINT16, BASE_DEC, NULL, 0x0,
  5811. "The Length field is two octets and indicates the length of "
  5812. "the PAP packet", HFILL }},
  5813. { &hf_pap_data,
  5814. { "Data", "pap.data", FT_NONE, BASE_NONE, NULL, 0x0,
  5815. "The format of the Data field is determined by the Code field",
  5816. HFILL }},
  5817. { &hf_pap_peer_id_length,
  5818. { "Peer-ID-Length", "pap.peer_id.length",
  5819. FT_UINT8, BASE_DEC, NULL, 0x0,
  5820. "The Peer-ID-Length field is one octet and indicates the "
  5821. "length of the Peer-ID field", HFILL }},
  5822. { &hf_pap_peer_id,
  5823. { "Peer-ID", "pap.peer_id", FT_STRING, BASE_NONE, NULL, 0x0,
  5824. "The Peer-ID field is zero or more octets and indicates the "
  5825. "name of the peer to be authenticated", HFILL }},
  5826. { &hf_pap_password_length,
  5827. { "Password-Length", "pap.password.length",
  5828. FT_UINT8, BASE_DEC, NULL, 0x0,
  5829. "The Password-Length field is one octet and indicates the "
  5830. "length of the Password field", HFILL }},
  5831. { &hf_pap_password,
  5832. { "Password", "pap.password", FT_STRING, BASE_NONE, NULL, 0x0,
  5833. "The Password field is zero or more octets and indicates the "
  5834. "password to be used for authentication", HFILL }},
  5835. { &hf_pap_message_length,
  5836. { "Message-Length", "pap.message.length",
  5837. FT_UINT8, BASE_DEC, NULL, 0x0,
  5838. "The Message-Length field is one octet and indicates the "
  5839. "length of the Message field", HFILL }},
  5840. { &hf_pap_message,
  5841. { "Message", "pap.message", FT_STRING, BASE_NONE, NULL, 0x0,
  5842. "The Message field is zero or more octets, and its contents "
  5843. "are implementation dependent.", HFILL }},
  5844. { &hf_pap_stuff,
  5845. { "stuff", "pap.stuff", FT_BYTES, BASE_NONE,
  5846. NULL, 0x0, NULL, HFILL }}
  5847. };
  5848. proto_pap = proto_register_protocol("PPP Password Authentication Protocol",
  5849. "PPP PAP", "pap");
  5850. proto_register_field_array(proto_pap, hf, array_length(hf));
  5851. proto_register_subtree_array(ett, array_length(ett));
  5852. }
  5853. void
  5854. proto_reg_handoff_pap(void)
  5855. {
  5856. dissector_handle_t pap_handle;
  5857. pap_handle = create_dissector_handle(dissect_pap, proto_pap);
  5858. dissector_add_uint("ppp.protocol", PPP_PAP, pap_handle);
  5859. /*
  5860. * See above comment about NDISWAN for an explanation of why we're
  5861. * registering with the "ethertype" dissector table.
  5862. */
  5863. dissector_add_uint("ethertype", PPP_PAP, pap_handle);
  5864. /*
  5865. * for GSM-A / MobileL3 / GPRS SM / PCO
  5866. */
  5867. dissector_add_uint("sm_pco.protocol", PPP_PAP, pap_handle);
  5868. }
  5869. void
  5870. proto_register_chap(void)
  5871. {
  5872. static gint *ett[] = {
  5873. &ett_chap,
  5874. &ett_chap_data
  5875. };
  5876. static hf_register_info hf[] = {
  5877. { &hf_chap_code,
  5878. { "Code", "chap.code", FT_UINT8, BASE_DEC, VALS(chap_vals), 0x0,
  5879. "CHAP code", HFILL }},
  5880. { &hf_chap_identifier,
  5881. { "Identifier", "chap.identifier", FT_UINT8, BASE_DEC, NULL, 0x0,
  5882. "CHAP identifier", HFILL }},
  5883. { &hf_chap_length,
  5884. { "Length", "chap.length", FT_UINT16, BASE_DEC, NULL, 0x0,
  5885. "CHAP length", HFILL }},
  5886. { &hf_chap_data,
  5887. { "Data", "chap.data", FT_NONE, BASE_NONE, NULL, 0x0,
  5888. "CHAP Data", HFILL }},
  5889. { &hf_chap_value_size,
  5890. { "Value Size", "chap.value_size", FT_UINT8, BASE_DEC, NULL, 0x0,
  5891. "CHAP value size", HFILL }},
  5892. { &hf_chap_value,
  5893. { "Value", "chap.value", FT_BYTES, BASE_NONE, NULL, 0x0,
  5894. "CHAP value data", HFILL }},
  5895. { &hf_chap_name,
  5896. { "Name", "chap.name", FT_STRING, BASE_NONE, NULL, 0x0,
  5897. "CHAP name", HFILL }},
  5898. { &hf_chap_message,
  5899. { "Message", "chap.message", FT_STRING, BASE_NONE, NULL, 0x0,
  5900. "CHAP message", HFILL }}
  5901. };
  5902. proto_chap = proto_register_protocol(
  5903. "PPP Challenge Handshake Authentication Protocol", "PPP CHAP", "chap");
  5904. proto_register_field_array(proto_chap, hf, array_length(hf));
  5905. proto_register_subtree_array(ett, array_length(ett));
  5906. }
  5907. void
  5908. proto_reg_handoff_chap(void)
  5909. {
  5910. dissector_handle_t chap_handle = create_dissector_handle(dissect_chap,
  5911. proto_chap);
  5912. dissector_add_uint("ppp.protocol", PPP_CHAP, chap_handle);
  5913. /*
  5914. * See above comment about NDISWAN for an explanation of why we're
  5915. * registering with the "ethertype" dissector table.
  5916. */
  5917. dissector_add_uint("ethertype", PPP_CHAP, chap_handle);
  5918. /*
  5919. * for GSM-A / MobileL3 / GPRS SM / PCO
  5920. */
  5921. dissector_add_uint("sm_pco.protocol", PPP_CHAP, chap_handle);
  5922. }
  5923. void
  5924. proto_register_pppmuxcp(void)
  5925. {
  5926. static hf_register_info hf[] = {
  5927. { &hf_pppmux_flags_pid,
  5928. { "PID", "pppmuxcp.flags.pid", FT_BOOLEAN, 8, TFS(&tfs_present_not_present), 0x80,
  5929. NULL, HFILL }},
  5930. { &hf_pppmux_flags_field_length,
  5931. { "Length field", "pppmuxcp.flags.field_length", FT_BOOLEAN, 8, TFS(&tfs_pppmux_length_field), 0x40,
  5932. NULL, HFILL }},
  5933. };
  5934. static gint *ett[] = {
  5935. &ett_pppmuxcp,
  5936. &ett_pppmuxcp_options
  5937. };
  5938. proto_pppmuxcp = proto_register_protocol("PPPMux Control Protocol",
  5939. "PPP PPPMuxCP", "pppmuxcp");
  5940. proto_register_field_array(proto_pppmuxcp, hf, array_length(hf));
  5941. proto_register_subtree_array(ett, array_length(ett));
  5942. }
  5943. void
  5944. proto_reg_handoff_pppmuxcp(void)
  5945. {
  5946. dissector_handle_t muxcp_handle;
  5947. muxcp_handle = create_dissector_handle(dissect_pppmuxcp, proto_pppmuxcp);
  5948. dissector_add_uint("ppp.protocol", PPP_MUXCP, muxcp_handle);
  5949. /*
  5950. * See above comment about NDISWAN for an explanation of why we're
  5951. * registering with the "ethertype" dissector table.
  5952. */
  5953. dissector_add_uint("ethertype", PPP_MUXCP, muxcp_handle);
  5954. }
  5955. void
  5956. proto_register_pppmux(void)
  5957. {
  5958. static hf_register_info hf[] = {
  5959. { &hf_pppmux_protocol,
  5960. { "Protocol", "pppmux.protocol", FT_UINT16,
  5961. BASE_HEX|BASE_EXT_STRING, &ppp_vals_ext, 0x0,
  5962. "The protocol of the sub-frame.", HFILL }}
  5963. };
  5964. static gint *ett[] = {
  5965. &ett_pppmux,
  5966. &ett_pppmux_subframe,
  5967. &ett_pppmux_subframe_hdr,
  5968. &ett_pppmux_subframe_flags,
  5969. &ett_pppmux_subframe_info
  5970. };
  5971. proto_pppmux = proto_register_protocol("PPP Multiplexing", "PPP PPPMux",
  5972. "pppmux");
  5973. proto_register_field_array(proto_pppmux, hf, array_length(hf));
  5974. proto_register_subtree_array(ett, array_length(ett));
  5975. }
  5976. void
  5977. proto_reg_handoff_pppmux(void)
  5978. {
  5979. dissector_handle_t pppmux_handle;
  5980. pppmux_handle = create_dissector_handle(dissect_pppmux, proto_pppmux);
  5981. dissector_add_uint("ppp.protocol", PPP_MUX, pppmux_handle);
  5982. /*
  5983. * See above comment about NDISWAN for an explanation of why we're
  5984. * registering with the "ethertype" dissector table.
  5985. */
  5986. dissector_add_uint("ethertype", PPP_MUX, pppmux_handle);
  5987. }
  5988. void
  5989. proto_register_mplscp(void)
  5990. {
  5991. static gint *ett[] = {
  5992. &ett_mplscp,
  5993. &ett_mplscp_options
  5994. };
  5995. proto_mplscp = proto_register_protocol("PPP MPLS Control Protocol",
  5996. "PPP MPLSCP", "mplscp");
  5997. proto_register_subtree_array(ett, array_length(ett));
  5998. }
  5999. void
  6000. proto_reg_handoff_mplscp(void)
  6001. {
  6002. dissector_handle_t mplscp_handle;
  6003. mplscp_handle = create_dissector_handle(dissect_mplscp, proto_mplscp);
  6004. dissector_add_uint("ppp.protocol", PPP_MPLSCP, mplscp_handle);
  6005. /*
  6006. * See above comment about NDISWAN for an explanation of why we're
  6007. * registering with the "ethertype" dissector table.
  6008. */
  6009. dissector_add_uint("ethertype", PPP_MPLSCP, mplscp_handle);
  6010. }
  6011. void
  6012. proto_register_cdpcp(void)
  6013. {
  6014. static gint *ett[] = {
  6015. &ett_cdpcp,
  6016. &ett_cdpcp_options
  6017. };
  6018. proto_cdpcp = proto_register_protocol("PPP CDP Control Protocol",
  6019. "PPP CDPCP", "cdpcp");
  6020. proto_register_subtree_array(ett, array_length(ett));
  6021. }
  6022. void
  6023. proto_reg_handoff_cdpcp(void)
  6024. {
  6025. dissector_handle_t cdpcp_handle;
  6026. cdpcp_handle = create_dissector_handle(dissect_cdpcp, proto_cdpcp);
  6027. dissector_add_uint("ppp.protocol", PPP_CDPCP, cdpcp_handle);
  6028. /*
  6029. * See above comment about NDISWAN for an explanation of why we're
  6030. * registering with the "ethertype" dissector table.
  6031. */
  6032. dissector_add_uint("ethertype", PPP_CDPCP, cdpcp_handle);
  6033. }
  6034. void
  6035. proto_register_ipv6cp(void)
  6036. {
  6037. static gint *ett[] = {
  6038. &ett_ipv6cp,
  6039. &ett_ipv6cp_options,
  6040. &ett_ipv6cp_if_id_opt,
  6041. &ett_ipv6cp_compress_opt
  6042. };
  6043. proto_ipv6cp = proto_register_protocol("PPP IPv6 Control Protocol",
  6044. "PPP IPV6CP", "ipv6cp");
  6045. proto_register_subtree_array(ett, array_length(ett));
  6046. }
  6047. void
  6048. proto_reg_handoff_ipv6cp(void)
  6049. {
  6050. dissector_handle_t ipv6cp_handle;
  6051. ipv6cp_handle = create_dissector_handle(dissect_ipv6cp, proto_ipv6cp);
  6052. dissector_add_uint("ppp.protocol", PPP_IPV6CP, ipv6cp_handle);
  6053. /*
  6054. * See above comment about NDISWAN for an explanation of why we're
  6055. * registering with the "ethertype" dissector table.
  6056. */
  6057. dissector_add_uint("ethertype", PPP_IPV6CP, ipv6cp_handle);
  6058. /*
  6059. * for GSM-A / MobileL3 / GPRS SM / PCO
  6060. */
  6061. dissector_add_uint("sm_pco.protocol", PPP_IPV6CP, ipv6cp_handle);
  6062. }
  6063. void
  6064. proto_register_iphc_crtp(void)
  6065. {
  6066. static hf_register_info hf[] = {
  6067. { &hf_iphc_crtp_cid16,
  6068. { "Context Id", "crtp.cid", FT_UINT16, BASE_DEC, NULL, 0x0,
  6069. "The context identifier of the compressed packet.", HFILL }},
  6070. { &hf_iphc_crtp_cid8,
  6071. { "Context Id", "crtp.cid", FT_UINT8, BASE_DEC, NULL, 0x0,
  6072. "The context identifier of the compressed packet.", HFILL }},
  6073. { &hf_iphc_crtp_gen,
  6074. { "Generation", "crtp.gen", FT_UINT8, BASE_DEC, NULL, 0x3f,
  6075. "The generation of the compressed packet.", HFILL }},
  6076. { &hf_iphc_crtp_seq,
  6077. { "Sequence", "crtp.seq", FT_UINT8, BASE_DEC, NULL, 0x0f,
  6078. "The sequence of the compressed packet.", HFILL }},
  6079. { &hf_iphc_crtp_fh_flags,
  6080. { "Flags", "crtp.fh_flags", FT_UINT8, BASE_HEX, iphc_crtp_fh_flags,
  6081. 0xc0, "The flags of the full header packet.", HFILL }},
  6082. { &hf_iphc_crtp_cs_flags,
  6083. { "Flags", "crtp.cs_flags", FT_UINT8, BASE_DEC, iphc_crtp_cs_flags,
  6084. 0x0, "The flags of the context state packet.", HFILL }},
  6085. { &hf_iphc_crtp_cs_cnt,
  6086. { "Count", "crtp.cnt", FT_UINT8, BASE_DEC, NULL, 0x0,
  6087. "The count of the context state packet.", HFILL }},
  6088. { &hf_iphc_crtp_cs_invalid,
  6089. { "Invalid", "crtp.invalid", FT_BOOLEAN, 8, NULL, 0x80,
  6090. "The invalid bit of the context state packet.", HFILL }}
  6091. };
  6092. static gint *ett[] = {
  6093. &ett_iphc_crtp,
  6094. &ett_iphc_crtp_hdr,
  6095. &ett_iphc_crtp_info
  6096. };
  6097. proto_iphc_crtp = proto_register_protocol("CRTP", "CRTP", "crtp");
  6098. proto_register_field_array(proto_iphc_crtp, hf, array_length(hf));
  6099. proto_register_subtree_array(ett, array_length(ett));
  6100. }
  6101. void
  6102. proto_reg_handoff_iphc_crtp(void)
  6103. {
  6104. dissector_handle_t fh_handle;
  6105. dissector_handle_t cudp16_handle;
  6106. dissector_handle_t cudp8_handle;
  6107. dissector_handle_t cs_handle;
  6108. fh_handle = create_dissector_handle(dissect_iphc_crtp_fh, proto_iphc_crtp);
  6109. dissector_add_uint("ppp.protocol", PPP_RTP_FH, fh_handle);
  6110. cudp16_handle = create_dissector_handle(dissect_iphc_crtp_cudp16,
  6111. proto_iphc_crtp);
  6112. dissector_add_uint("ppp.protocol", PPP_RTP_CUDP16, cudp16_handle);
  6113. cudp8_handle = create_dissector_handle(dissect_iphc_crtp_cudp8,
  6114. proto_iphc_crtp);
  6115. dissector_add_uint("ppp.protocol", PPP_RTP_CUDP8, cudp8_handle);
  6116. cs_handle = create_dissector_handle(dissect_iphc_crtp_cs, proto_iphc_crtp);
  6117. dissector_add_uint("ppp.protocol", PPP_RTP_CS, cs_handle);
  6118. /*
  6119. * See above comment about NDISWAN for an explanation of why we're
  6120. * registering with the "ethertype" dissector table.
  6121. */
  6122. dissector_add_uint("ethertype", PPP_RTP_FH, fh_handle);
  6123. dissector_add_uint("ethertype", PPP_RTP_CUDP16, cudp16_handle);
  6124. dissector_add_uint("ethertype", PPP_RTP_CUDP8, cudp16_handle);
  6125. dissector_add_uint("ethertype", PPP_RTP_CS, cs_handle);
  6126. }
  6127. /*
  6128. * Editor modelines - http://www.wireshark.org/tools/modelines.html
  6129. *
  6130. * Local variables:
  6131. * c-basic-offset: 4
  6132. * tab-width: 8
  6133. * indent-tabs-mode: nil
  6134. * End:
  6135. *
  6136. * vi: set shiftwidth=4 tabstop=8 expandtab:
  6137. * :indentSize=4:tabSize=8:noTabs=true:
  6138. */