2 * Routines for ppp packet disassembly
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@ethereal.com>
10 * This file created and by Mike Hall <mlh@io.com>
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.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 #include <epan/prefs.h>
35 #include <epan/packet.h>
36 #include <epan/emem.h>
37 #include "packet-ppp.h"
38 #include <epan/ppptypes.h>
39 #include <epan/etypes.h>
40 #include <epan/ip_opts.h>
41 #include <epan/atalk-utils.h>
42 #include "packet-chdlc.h"
43 #include "packet-ip.h"
44 #include "packet-ipx.h"
45 #include "packet-vines.h"
46 #include <epan/nlpid.h>
47 #include <epan/crc16.h>
48 #include <epan/crc32.h>
50 #define ppp_min(a, b) ((a<b) ? a : b)
52 static int proto_ppp = -1;
53 static int hf_ppp_address = -1;
54 static int hf_ppp_control = -1;
55 static int hf_ppp_protocol = -1;
57 static gint ett_ppp = -1;
59 static int proto_ppp_hdlc = -1;
61 static gint ett_ppp_hdlc_data = -1;
63 static int proto_lcp = -1;
65 static gint ett_lcp = -1;
66 static gint ett_lcp_options = -1;
67 static gint ett_lcp_authprot_opt = -1;
68 static gint ett_lcp_qualprot_opt = -1;
69 static gint ett_lcp_fcs_alternatives_opt = -1;
70 static gint ett_lcp_numbered_mode_opt = -1;
71 static gint ett_lcp_callback_opt = -1;
72 static gint ett_lcp_multilink_ep_disc_opt = -1;
73 static gint ett_lcp_internationalization_opt = -1;
75 static int proto_ipcp = -1;
77 static gint ett_ipcp = -1;
78 static gint ett_ipcp_options = -1;
79 static gint ett_ipcp_ipaddrs_opt = -1;
80 static gint ett_ipcp_compress_opt = -1;
81 static gint ett_ipcp_iphc_disableprot_opt = -1;
83 static int proto_osicp = -1;
85 static gint ett_osicp = -1;
86 static gint ett_osicp_options = -1;
87 static gint ett_osicp_align_npdu_opt = -1;
89 static int proto_ccp = -1;
91 static gint ett_ccp = -1;
92 static gint ett_ccp_options = -1;
93 static gint ett_ccp_stac_opt = -1;
94 static gint ett_ccp_mppc_opt = -1;
95 static gint ett_ccp_bsdcomp_opt = -1;
96 static gint ett_ccp_lzsdcp_opt = -1;
97 static gint ett_ccp_mvrca_opt = -1;
98 static gint ett_ccp_deflate_opt = -1;
100 static int proto_cbcp = -1;
102 static gint ett_cbcp = -1;
103 static gint ett_cbcp_options = -1;
104 static gint ett_cbcp_callback_opt = -1;
105 static gint ett_cbcp_callback_opt_addr = -1;
107 static int proto_bacp = -1;
109 static gint ett_bacp = -1;
110 static gint ett_bacp_options = -1;
111 static gint ett_bacp_favored_peer_opt = -1;
113 static int proto_bap = -1;
115 static gint ett_bap = -1;
116 static gint ett_bap_options = -1;
117 static gint ett_bap_link_type_opt = -1;
118 static gint ett_bap_phone_delta_opt = -1;
119 static gint ett_bap_phone_delta_subopt = -1;
120 static gint ett_bap_call_status_opt = -1;
122 static int proto_comp_data = -1;
124 static gint ett_comp_data = -1;
126 static int proto_pppmuxcp = -1;
128 static gint ett_pppmuxcp = -1;
129 static gint ett_pppmuxcp_options = -1;
131 static int proto_pppmux = -1;
133 static gint ett_pppmux = -1;
134 static gint ett_pppmux_subframe = -1;
135 static gint ett_pppmux_subframe_hdr = -1;
136 static gint ett_pppmux_subframe_flags = -1;
137 static gint ett_pppmux_subframe_info = -1;
139 static int proto_mp = -1;
140 static int hf_mp_frag_first = -1;
141 static int hf_mp_frag_last = -1;
142 static int hf_mp_sequence_num = -1;
144 static int ett_mp = -1;
145 static int ett_mp_flags = -1;
147 static int proto_mplscp = -1;
148 static gint ett_mplscp = -1;
149 static gint ett_mplscp_options = -1;
151 static int proto_cdpcp = -1;
152 static gint ett_cdpcp = -1;
153 static gint ett_cdpcp_options = -1;
155 static int proto_pap = -1; /* PAP vars */
156 static gint ett_pap = -1;
157 static gint ett_pap_data = -1;
158 static gint ett_pap_peer_id = -1;
159 static gint ett_pap_password = -1;
160 static gint ett_pap_message = -1;
162 static int proto_chap = -1; /* CHAP vars */
163 static gint ett_chap = -1;
164 static gint ett_chap_data = -1;
165 static gint ett_chap_value = -1;
166 static gint ett_chap_name = -1;
167 static gint ett_chap_message = -1;
170 static gint hf_chap_code = -1;
171 static gint hf_chap_identifier = -1;
172 static gint hf_chap_length = -1;
173 static gint hf_chap_value_size = -1;
174 static gint hf_chap_value = -1;
175 static gint hf_chap_name = -1;
176 static gint hf_chap_message = -1;
179 static int proto_ipv6cp = -1; /* IPv6CP vars */
181 static gint ett_ipv6cp = -1;
182 static gint ett_ipv6cp_options = -1;
183 static gint ett_ipv6cp_if_id_opt = -1;
184 static gint ett_ipv6cp_compress_opt = -1;
186 static dissector_table_t ppp_subdissector_table;
187 static dissector_handle_t chdlc_handle;
188 static dissector_handle_t data_handle;
191 static gint ppp_fcs_decode = 0; /* 0 = No FCS, 1 = 16 bit FCS, 2 = 32 bit FCS */
196 const enum_val_t fcs_options[] = {
197 {"none", "None", NO_FCS},
198 {"16-bit", "16-Bit", FCS_16},
199 {"32-bit", "32-Bit", FCS_32},
203 gboolean ppp_vj_decomp = TRUE; /* Default to VJ header decompression */
206 * For Default Protocol ID negotiated with PPPMuxCP. We need to
207 * this ID so that if the first subframe doesn't have protocol
211 static guint pppmux_def_prot_id = 0;
213 /* PPP definitions */
216 * Used by the GTP dissector as well.
218 const value_string ppp_vals[] = {
219 {PPP_PADDING, "Padding Protocol" },
220 {PPP_ROHC_SCID, "ROHC small-CID" },
221 {PPP_ROHC_LCID, "ROHC large-CID" },
224 {PPP_DEC4, "DECnet Phase IV" },
225 {PPP_AT, "Appletalk" },
226 {PPP_IPX, "Netware IPX/SPX"},
227 {PPP_VJC_COMP, "VJ compressed TCP"},
228 {PPP_VJC_UNCOMP,"VJ uncompressed TCP"},
229 {PPP_BPDU, "Bridging PDU"},
230 {PPP_ST, "Stream Protocol (ST-II)" },
231 {PPP_VINES, "Vines" },
232 {PPP_AT_EDDP, "AppleTalk EDDP" },
233 {PPP_AT_SB, "AppleTalk SmartBuffered" },
234 {PPP_MP, "Multilink"},
235 {PPP_NB, "NETBIOS Framing" },
236 {PPP_CISCO, "Cisco Systems" },
237 {PPP_ASCOM, "Ascom Timeplex" },
238 {PPP_LBLB, "Fujitsu Link Backup and Load Balancing" },
239 {PPP_RL, "DCA Remote Lan" },
240 {PPP_SDTP, "Serial Data Transport Protocol" },
241 {PPP_LLC, "SNA over LLC" },
243 {PPP_IPV6HC, "IPv6 Header Compression " },
244 {PPP_KNX, "KNX Bridging Data" },
245 {PPP_ENCRYPT, "Encryption" },
246 {PPP_ILE, "Individual Link Encryption" },
248 {PPP_MUX, "PPP Multiplexing"},
249 {PPP_RTP_FH, "RTP IPHC Full Header" },
250 {PPP_RTP_CTCP, "RTP IPHC Compressed TCP" },
251 {PPP_RTP_CNTCP, "RTP IPHC Compressed Non TCP" },
252 {PPP_RTP_CUDP8, "RTP IPHC Compressed UDP 8" },
253 {PPP_RTP_CRTP8, "RTP IPHC Compressed RTP 8" },
254 {PPP_STAMPEDE, "Stampede Bridging" },
255 {PPP_MPPLUS, "MP+ Protocol" },
256 {PPP_NTCITS_IPI,"NTCITS IPI" },
257 {PPP_ML_SLCOMP, "single link compression in multilink" },
258 {PPP_COMP, "compressed packet" },
259 {PPP_STP_HELLO, "802.1D Hello Packet" },
260 {PPP_IBM_SR, "IBM Source Routing BPDU" },
261 {PPP_DEC_LB, "DEC LANBridge100 Spanning Tree"},
262 {PPP_CDP, "Cisco Discovery Protocol" },
263 {PPP_NETCS, "Netcs Twin Routing" },
264 {PPP_STP, "Scheduled Transfer Protocol" },
265 {PPP_EDP, "Extreme Discovery Protocol" },
266 {PPP_OSCP, "Optical Supervisory Channel Protocol" },
267 {PPP_OSCP2, "Optical Supervisory Channel Protocol" },
268 {PPP_LUXCOM, "Luxcom" },
269 {PPP_SIGMA, "Sigma Network Systems" },
270 {PPP_ACSP, "Apple Client Server Protocol" },
271 {PPP_MPLS_UNI, "MPLS Unicast"},
272 {PPP_MPLS_MULTI, "MPLS Multicast"},
273 {PPP_P12844, "IEEE p1284.4 standard - data packets" },
274 {PPP_ETSI, "ETSI TETRA Networks Procotol Type 1" },
275 {PPP_MFTP, "Multichannel Flow Treatment Protocol" },
276 {PPP_RTP_CTCPND,"RTP IPHC Compressed TCP No Delta" },
277 {PPP_RTP_CS, "RTP IPHC Context State" },
278 {PPP_RTP_CUDP16,"RTP IPHC Compressed UDP 16" },
279 {PPP_RTP_CRDP16,"RTP IPHC Compressed RTP 16" },
280 {PPP_CCCP, "Cray Communications Control Protocol" },
281 {PPP_CDPD_MNRP, "CDPD Mobile Network Registration Protocol" },
282 {PPP_EXPANDAP, "Expand accelerator protocol" },
283 {PPP_ODSICP, "ODSICP NCP" },
284 {PPP_DOCSIS, "DOCSIS DLL" },
285 {PPP_LZS, "Stacker LZS" },
286 {PPP_REFTEK, "RefTek Protocol" },
287 {PPP_FC, "Fibre Channel" },
288 {PPP_EMIT, "EMIT Protocols" },
289 {PPP_IPCP, "IP Control Protocol" },
290 {PPP_OSICP, "OSI Control Protocol" },
291 {PPP_XNSIDPCP, "Xerox NS IDP Control Protocol" },
292 {PPP_DECNETCP, "DECnet Phase IV Control Protocol" },
293 {PPP_ATCP, "AppleTalk Control Protocol" },
294 {PPP_IPXCP, "IPX Control Protocol" },
295 {PPP_BRIDGENCP, "Bridging NCP" },
296 {PPP_SPCP, "Stream Protocol Control Protocol" },
297 {PPP_BVCP, "Banyan Vines Control Protocol" },
298 {PPP_MLCP, "Multi-Link Control Protocol" },
299 {PPP_NBCP, "NETBIOS Framing Control Protocol" },
300 {PPP_CISCOCP, "Cisco Systems Control Protocol" },
301 {PPP_ASCOMCP, "Ascom Timeplex" },
302 {PPP_LBLBCP, "Fujitsu LBLB Control Protocol" },
303 {PPP_RLNCP, "DCA Remote Lan Network Control Protocol" },
304 {PPP_SDCP, "Serial Data Control Protocol" },
305 {PPP_LLCCP, "SNA over LLC Control Protocol" },
306 {PPP_SNACP, "SNA Control Protocol" },
307 {PPP_KNXCP, "KNX Bridging Control Protocol" },
308 {PPP_ECP, "Encryption Control Protocol" },
309 {PPP_ILECP, "Individual Encryption Control Protocol" },
310 {PPP_IPV6CP, "IPv6 Control Protocol" },
311 {PPP_MUXCP, "PPPMux Control Protocol"},
312 {PPP_STAMPEDECP,"Stampede Bridging Control Protocol" },
313 {PPP_MPPCP, "MP+ Contorol Protocol" },
314 {PPP_IPICP, "NTCITS IPI Control Protocol" },
315 {PPP_SLCC, "single link compression in multilink control" },
316 {PPP_CCP, "Compression Control Protocol" },
317 {PPP_CDPCP, "CDP Control Protocol" },
318 {PPP_NETCSCP, "Netcs Twin Routing" },
319 {PPP_STPCP, "STP - Control Protocol" },
320 {PPP_EDPCP, "EDP Control Protocol" },
321 {PPP_ACSPC, "Apple Client Server Protocol Control" },
322 {PPP_MPLSCP, "MPLS Control Protocol" },
323 {PPP_P12844CP, "IEEE p1284.4 standard - Protocol Control" },
324 {PPP_ETSICP, "ETSI TETRA TNP1 Control Protocol" },
325 {PPP_MFTPCP, "Multichannel Flow Treatment Protocol" },
326 {PPP_LCP, "Link Control Protocol" },
327 {PPP_PAP, "Password Authentication Protocol" },
328 {PPP_LQR, "Link Quality Report protocol" },
329 {PPP_SPAP, "Shiva Password Authentication Protocol" },
330 {PPP_CBCP, "Callback Control Protocol" },
331 {PPP_BACP, "Bandwidth Allocation Control Protocol" },
332 {PPP_BAP, "Bandwidth Allocation Protocol" },
333 {PPP_CONTCP, "Container Control Protocol" },
334 {PPP_CHAP, "Challenge Handshake Authentication Protocol" },
335 {PPP_RSAAP, "RSA Authentication Protocol" },
336 {PPP_EAP, "Extensible Authentication Protocol" },
337 {PPP_SIEP, "Mitsubishi Security Information Exchange Protocol"},
338 {PPP_SBAP, "Stampede Bridging Authorization Protocol" },
339 {PPP_PRPAP, "Proprietary Authentication Protocol" },
340 {PPP_PRPAP2, "Proprietary Authentication Protocol" },
341 {PPP_PRPNIAP, "Proprietary Node ID Authentication Protocol" },
345 /* CP (LCP, IPCP, etc.) codes.
348 #define CONFREQ 1 /* Configuration Request */
349 #define CONFACK 2 /* Configuration Ack */
350 #define CONFNAK 3 /* Configuration Nak */
351 #define CONFREJ 4 /* Configuration Reject */
352 #define TERMREQ 5 /* Termination Request */
353 #define TERMACK 6 /* Termination Ack */
354 #define CODEREJ 7 /* Code Reject */
356 static const value_string cp_vals[] = {
357 {CONFREQ, "Configuration Request" },
358 {CONFACK, "Configuration Ack" },
359 {CONFNAK, "Configuration Nak" },
360 {CONFREJ, "Configuration Reject" },
361 {TERMREQ, "Termination Request" },
362 {TERMACK, "Termination Ack" },
363 {CODEREJ, "Code Reject" },
367 * LCP-specific packet types.
369 #define PROTREJ 8 /* Protocol Reject */
370 #define ECHOREQ 9 /* Echo Request */
371 #define ECHOREP 10 /* Echo Reply */
372 #define DISCREQ 11 /* Discard Request */
373 #define IDENT 12 /* Identification */
374 #define TIMEREMAIN 13 /* Time remaining */
377 * CCP-specific packet types.
379 #define RESETREQ 14 /* Reset Request */
380 #define RESETACK 15 /* Reset Ack */
383 * CBCP-specific packet types.
385 #define CBREQ 1 /* Callback Request */
386 #define CBRES 2 /* Callback Response */
387 #define CBACK 3 /* Callback Ack */
389 #define CBCP_OPT 6 /* Use callback control protocol */
392 * BAP-specific packet types.
394 #define BAP_CREQ 1 /* Call Request */
395 #define BAP_CRES 2 /* Call Response */
396 #define BAP_CBREQ 3 /* Callback Request */
397 #define BAP_CBRES 4 /* Callback Response */
398 #define BAP_LDQREQ 5 /* Link Drop Query Request */
399 #define BAP_LDQRES 6 /* Link Drop Query Response */
400 #define BAP_CSI 7 /* Call Status Indication */
401 #define BAP_CSRES 8 /* Call Status Response */
403 static const value_string lcp_vals[] = {
404 {CONFREQ, "Configuration Request" },
405 {CONFACK, "Configuration Ack" },
406 {CONFNAK, "Configuration Nak" },
407 {CONFREJ, "Configuration Reject" },
408 {TERMREQ, "Termination Request" },
409 {TERMACK, "Termination Ack" },
410 {CODEREJ, "Code Reject" },
411 {PROTREJ, "Protocol Reject" },
412 {ECHOREQ, "Echo Request" },
413 {ECHOREP, "Echo Reply" },
414 {DISCREQ, "Discard Request" },
415 {IDENT, "Identification" },
416 {TIMEREMAIN, "Time Remaining" },
420 static const value_string ccp_vals[] = {
421 {CONFREQ, "Configuration Request" },
422 {CONFACK, "Configuration Ack" },
423 {CONFNAK, "Configuration Nak" },
424 {CONFREJ, "Configuration Reject" },
425 {TERMREQ, "Termination Request" },
426 {TERMACK, "Termination Ack" },
427 {CODEREJ, "Code Reject" },
428 {RESETREQ, "Reset Request" },
429 {RESETACK, "Reset Ack" },
433 static const value_string cbcp_vals[] = {
434 {CBREQ, "Callback Request" },
435 {CBRES, "Callback Response" },
436 {CBACK, "Callback Ack" },
440 static const value_string bap_vals[] = {
441 {BAP_CREQ, "Call Request" },
442 {BAP_CRES, "Call Response" },
443 {BAP_CBREQ, "Callback Request" },
444 {BAP_CBRES, "Callback Response" },
445 {BAP_LDQREQ, "Link Drop Query Request" },
446 {BAP_LDQRES, "Link Drop Query Response" },
447 {BAP_CSI, "Call Status Indication" },
448 {BAP_CSRES, "Call Status Response" },
452 #define BAP_RESP_CODE_REQACK 0x00
453 #define BAP_RESP_CODE_REQNAK 0x01
454 #define BAP_RESP_CODE_REQREJ 0x02
455 #define BAP_RESP_CODE_REQFULLNAK 0x03
456 static const value_string bap_resp_code_vals[] = {
457 {BAP_RESP_CODE_REQACK, "Request Ack" },
458 {BAP_RESP_CODE_REQNAK, "Request Nak" },
459 {BAP_RESP_CODE_REQREJ, "Request Rej" },
460 {BAP_RESP_CODE_REQFULLNAK, "Request Full Nak" },
464 #define BAP_LINK_TYPE_ISDN 0 /* ISDN */
465 #define BAP_LINK_TYPE_X25 1 /* X.25 */
466 #define BAP_LINK_TYPE_ANALOG 2 /* Analog */
467 #define BAP_LINK_TYPE_SD 3 /* Switched Digital (non-ISDN) */
468 #define BAP_LINK_TYPE_ISDNOV 4 /* ISDN data over voice */
469 #define BAP_LINK_TYPE_RESV5 5 /* Reserved */
470 #define BAP_LINK_TYPE_RESV6 6 /* Reserved */
471 #define BAP_LINK_TYPE_RESV7 7 /* Reserved */
472 static const value_string bap_link_type_vals[] = {
473 {BAP_LINK_TYPE_ISDN, "ISDN" },
474 {BAP_LINK_TYPE_X25, "X.25" },
475 {BAP_LINK_TYPE_ANALOG, "Analog" },
476 {BAP_LINK_TYPE_SD, "Switched Digital (non-ISDN)" },
477 {BAP_LINK_TYPE_ISDNOV, "ISDN data over voice" },
478 {BAP_LINK_TYPE_RESV5, "Reserved" },
479 {BAP_LINK_TYPE_RESV6, "Reserved" },
480 {BAP_LINK_TYPE_RESV7, "Reserved" },
484 #define BAP_PHONE_DELTA_SUBOPT_UNIQ_DIGIT 1 /* Unique Digit */
485 #define BAP_PHONE_DELTA_SUBOPT_SUBSC_NUM 2 /* Subscriber Number */
486 #define BAP_PHONE_DELTA_SUBOPT_PHONENUM_SUBADDR 3 /* Phone Number Sub Address */
487 static const value_string bap_phone_delta_subopt_vals[] = {
488 {BAP_PHONE_DELTA_SUBOPT_UNIQ_DIGIT, "Unique Digit" },
489 {BAP_PHONE_DELTA_SUBOPT_SUBSC_NUM, "Subscriber Number" },
490 {BAP_PHONE_DELTA_SUBOPT_PHONENUM_SUBADDR, "Phone Number Sub Address" },
495 * Cause codes for Cause.
497 * The following code table is taken from packet-q931.c but is slightly
498 * adapted to BAP protocol.
500 static const value_string q931_cause_code_vals[] = {
501 { 0x00, "Call successful" },
502 { 0x01, "Unallocated (unassigned) number" },
503 { 0x02, "No route to specified transit network" },
504 { 0x03, "No route to destination" },
505 { 0x04, "Send special information tone" },
506 { 0x05, "Misdialled trunk prefix" },
507 { 0x06, "Channel unacceptable" },
508 { 0x07, "Call awarded and being delivered in an established channel" },
509 { 0x08, "Prefix 0 dialed but not allowed" },
510 { 0x09, "Prefix 1 dialed but not allowed" },
511 { 0x0A, "Prefix 1 dialed but not required" },
512 { 0x0B, "More digits received than allowed, call is proceeding" },
513 { 0x10, "Normal call clearing" },
514 { 0x11, "User busy" },
515 { 0x12, "No user responding" },
516 { 0x13, "No answer from user (user alerted)" },
517 { 0x14, "Subscriber absent" },
518 { 0x15, "Call rejected" },
519 { 0x16, "Number changed" },
520 { 0x17, "Reverse charging rejected" },
521 { 0x18, "Call suspended" },
522 { 0x19, "Call resumed" },
523 { 0x1A, "Non-selected user clearing" },
524 { 0x1B, "Destination out of order" },
525 { 0x1C, "Invalid number format (incomplete number)" },
526 { 0x1D, "Facility rejected" },
527 { 0x1E, "Response to STATUS ENQUIRY" },
528 { 0x1F, "Normal unspecified" },
529 { 0x21, "Circuit out of order" },
530 { 0x22, "No circuit/channel available" },
531 { 0x23, "Destination unattainable" },
532 { 0x25, "Degraded service" },
533 { 0x26, "Network out of order" },
534 { 0x27, "Transit delay range cannot be achieved" },
535 { 0x28, "Throughput range cannot be achieved" },
536 { 0x29, "Temporary failure" },
537 { 0x2A, "Switching equipment congestion" },
538 { 0x2B, "Access information discarded" },
539 { 0x2C, "Requested circuit/channel not available" },
540 { 0x2D, "Pre-empted" },
541 { 0x2E, "Precedence call blocked" },
542 { 0x2F, "Resources unavailable, unspecified" },
543 { 0x31, "Quality of service unavailable" },
544 { 0x32, "Requested facility not subscribed" },
545 { 0x33, "Reverse charging not allowed" },
546 { 0x34, "Outgoing calls barred" },
547 { 0x35, "Outgoing calls barred within CUG" },
548 { 0x36, "Incoming calls barred" },
549 { 0x37, "Incoming calls barred within CUG" },
550 { 0x38, "Call waiting not subscribed" },
551 { 0x39, "Bearer capability not authorized" },
552 { 0x3A, "Bearer capability not presently available" },
553 { 0x3E, "Inconsistency in designated outgoing access information and subscriber class" },
554 { 0x3F, "Service or option not available, unspecified" },
555 { 0x41, "Bearer capability not implemented" },
556 { 0x42, "Channel type not implemented" },
557 { 0x43, "Transit network selection not implemented" },
558 { 0x44, "Message not implemented" },
559 { 0x45, "Requested facility not implemented" },
560 { 0x46, "Only restricted digital information bearer capability is available" },
561 { 0x4F, "Service or option not implemented, unspecified" },
562 { 0x51, "Invalid call reference value" },
563 { 0x52, "Identified channel does not exist" },
564 { 0x53, "Call identity does not exist for suspended call" },
565 { 0x54, "Call identity in use" },
566 { 0x55, "No call suspended" },
567 { 0x56, "Call having the requested call identity has been cleared" },
568 { 0x57, "Called user not member of CUG" },
569 { 0x58, "Incompatible destination" },
570 { 0x59, "Non-existent abbreviated address entry" },
571 { 0x5A, "Destination address missing, and direct call not subscribed" },
572 { 0x5B, "Invalid transit network selection (national use)" },
573 { 0x5C, "Invalid facility parameter" },
574 { 0x5D, "Mandatory information element is missing" },
575 { 0x5F, "Invalid message, unspecified" },
576 { 0x60, "Mandatory information element is missing" },
577 { 0x61, "Message type non-existent or not implemented" },
578 { 0x62, "Message not compatible with call state or message type non-existent or not implemented" },
579 { 0x63, "Information element nonexistant or not implemented" },
580 { 0x64, "Invalid information element contents" },
581 { 0x65, "Message not compatible with call state" },
582 { 0x66, "Recovery on timer expiry" },
583 { 0x67, "Parameter non-existent or not implemented - passed on" },
584 { 0x6E, "Message with unrecognized parameter discarded" },
585 { 0x6F, "Protocol error, unspecified" },
586 { 0x7F, "Internetworking, unspecified" },
587 { 0xFF, "Non-specific failure" },
591 static const value_string bap_call_status_opt_action_vals[] = {
597 #define STAC_CM_NONE 0
598 #define STAC_CM_LCB 1
599 #define STAC_CM_CRC 2
601 #define STAC_CM_EXTMODE 4
602 static const value_string stac_checkmode_vals[] = {
603 {STAC_CM_NONE, "None" },
604 {STAC_CM_LCB, "LCB" },
605 {STAC_CM_CRC, "CRC" },
606 {STAC_CM_SN, "Sequence Number" },
607 {STAC_CM_EXTMODE, "Extended Mode" },
611 #define LZSDCP_CM_NONE 0
612 #define LZSDCP_CM_LCB 1
613 #define LZSDCP_CM_SN 2
614 #define LZSDCP_CM_SN_LCB 3
615 static const value_string lzsdcp_checkmode_vals[] = {
616 {LZSDCP_CM_NONE, "None" },
617 {LZSDCP_CM_LCB, "LCB" },
618 {LZSDCP_CM_SN, "Sequence Number" },
619 {LZSDCP_CM_SN_LCB, "Sequence Number + LCB" },
623 #define LZSDCP_PM_NONE 0
624 #define LZSDCP_PM_PROC_UNCOMP 1
625 static const value_string lzsdcp_processmode_vals[] = {
626 {LZSDCP_PM_NONE, "None" },
627 {LZSDCP_PM_PROC_UNCOMP, "Process-Uncompressed" },
634 #define CI_MRU 1 /* Maximum Receive Unit */
635 #define CI_ASYNCMAP 2 /* Async Control Character Map */
636 #define CI_AUTHTYPE 3 /* Authentication Type */
637 #define CI_QUALITY 4 /* Quality Protocol */
638 #define CI_MAGICNUMBER 5 /* Magic Number */
639 #define CI_PCOMPRESSION 7 /* Protocol Field Compression */
640 #define CI_ACCOMPRESSION 8 /* Address/Control Field Compression */
641 #define CI_FCS_ALTERNATIVES 9 /* FCS Alternatives (RFC 1570) */
642 #define CI_SELF_DESCRIBING_PAD 10 /* Self-Describing Pad (RFC 1570) */
643 #define CI_NUMBERED_MODE 11 /* Numbered Mode (RFC 1663) */
644 #define CI_CALLBACK 13 /* Callback (RFC 1570) */
645 #define CI_COMPOUND_FRAMES 15 /* Compound frames (RFC 1570) */
646 #define CI_MULTILINK_MRRU 17 /* Multilink MRRU (RFC 1717) */
647 #define CI_MULTILINK_SSNH 18 /* Multilink Short Sequence Number
649 #define CI_MULTILINK_EP_DISC 19 /* Multilink Endpoint Discriminator
651 #define CI_DCE_IDENTIFIER 21 /* DCE Identifier */
652 #define CI_MULTILINK_PLUS_PROC 22 /* Multilink Plus Procedure */
653 #define CI_LINK_DISC_FOR_BACP 23 /* Link Discriminator for BACP
655 #define CI_LCP_AUTHENTICATION 24 /* LCP Authentication Option */
656 #define CI_COBS 25 /* Consistent Overhead Byte
658 #define CI_PREFIX_ELISION 26 /* Prefix elision */
659 #define CI_MULTILINK_HDR_FMT 27 /* Multilink header format */
660 #define CI_INTERNATIONALIZATION 28 /* Internationalization (RFC 2484) */
661 #define CI_SDL_ON_SONET_SDH 29 /* Simple Data Link on SONET/SDH */
663 static void dissect_lcp_mru_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
664 int offset, guint length, packet_info *pinfo,
666 static void dissect_lcp_async_map_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
667 int offset, guint length, packet_info *pinfo,
669 static void dissect_lcp_protocol_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
670 int offset, guint length, packet_info *pinfo,
672 static void dissect_lcp_authprot_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
673 int offset, guint length, packet_info *pinfo,
675 static void dissect_lcp_magicnumber_opt(const ip_tcp_opt *optp,
676 tvbuff_t *tvb, int offset, guint length,
677 packet_info *pinfo, proto_tree *tree);
678 static void dissect_lcp_fcs_alternatives_opt(const ip_tcp_opt *optp,
679 tvbuff_t *tvb, int offset, guint length,
680 packet_info *pinfo, proto_tree *tree);
681 static void dissect_lcp_numbered_mode_opt(const ip_tcp_opt *optp,
682 tvbuff_t *tvb, int offset, guint length,
683 packet_info *pinfo, proto_tree *tree);
684 static void dissect_lcp_self_describing_pad_opt(const ip_tcp_opt *optp,
685 tvbuff_t *tvb, int offset, guint length,
686 packet_info *pinfo, proto_tree *tree);
687 static void dissect_lcp_callback_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
688 int offset, guint length, packet_info *pinfo,
690 static void dissect_lcp_multilink_mrru_opt(const ip_tcp_opt *optp,
691 tvbuff_t *tvb, int offset, guint length,
692 packet_info *pinfo, proto_tree *tree);
693 static void dissect_lcp_multilink_ep_disc_opt(const ip_tcp_opt *optp,
694 tvbuff_t *tvb, int offset, guint length,
695 packet_info *pinfo, proto_tree *tree);
696 static void dissect_lcp_bap_link_discriminator_opt(const ip_tcp_opt *optp,
697 tvbuff_t *tvb, int offset, guint length,
698 packet_info *pinfo, proto_tree *tree);
699 static void dissect_lcp_internationalization_opt(const ip_tcp_opt *optp,
700 tvbuff_t *tvb, int offset, guint length,
701 packet_info *pinfo, proto_tree *tree);
702 static void dissect_mp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
704 static const ip_tcp_opt lcp_opts[] = {
707 "Maximum Receive Unit",
715 "Async Control Character Map",
719 dissect_lcp_async_map_opt
723 "Authentication protocol",
724 &ett_lcp_authprot_opt,
727 dissect_lcp_authprot_opt
732 &ett_lcp_qualprot_opt,
735 dissect_lcp_protocol_opt
743 dissect_lcp_magicnumber_opt
747 "Protocol field compression",
755 "Address/control field compression",
764 &ett_lcp_fcs_alternatives_opt,
767 dissect_lcp_fcs_alternatives_opt
770 CI_SELF_DESCRIBING_PAD,
771 "Maximum octets of self-describing padding",
775 dissect_lcp_self_describing_pad_opt
780 &ett_lcp_numbered_mode_opt,
783 dissect_lcp_numbered_mode_opt
788 &ett_lcp_callback_opt,
791 dissect_lcp_callback_opt,
807 dissect_lcp_multilink_mrru_opt
811 "Use short sequence number headers",
818 CI_MULTILINK_EP_DISC,
819 "Multilink endpoint discriminator",
820 &ett_lcp_multilink_ep_disc_opt,
823 dissect_lcp_multilink_ep_disc_opt,
834 CI_MULTILINK_PLUS_PROC,
835 "Multilink Plus Procedure",
842 CI_LINK_DISC_FOR_BACP,
843 "Link discriminator for BAP",
847 dissect_lcp_bap_link_discriminator_opt
850 CI_LCP_AUTHENTICATION,
851 "LCP authentication",
859 "Consistent Overhead Byte Stuffing",
874 CI_MULTILINK_HDR_FMT,
875 "Multilink header format",
882 CI_INTERNATIONALIZATION,
883 "Internationalization",
884 &ett_lcp_internationalization_opt,
887 dissect_lcp_internationalization_opt
891 "Simple data link on SONET/SDH",
899 #define N_LCP_OPTS (sizeof lcp_opts / sizeof lcp_opts[0])
904 #define CHAP_ALG_MD5 0x05 /* CHAP with MD5 */
905 #define CHAP_ALG_MSV1 0x80 /* MS-CHAPv1 */
906 #define CHAP_ALG_MSV2 0x81 /* MS-CHAPv2 */
908 static const value_string chap_alg_vals[] = {
909 {CHAP_ALG_MD5, "CHAP with MD5" },
910 {CHAP_ALG_MSV1, "MS-CHAP" },
911 {CHAP_ALG_MSV2, "MS-CHAP-2" },
919 #define CI_ADDRS 1 /* IP Addresses (deprecated) (RFC 1172) */
920 #define CI_COMPRESSTYPE 2 /* Compression Type (RFC 1332) */
921 #define CI_ADDR 3 /* IP Address (RFC 1332) */
922 #define CI_MOBILE_IPv4 4 /* Mobile IPv4 (RFC 2290) */
923 #define CI_MS_DNS1 129 /* Primary DNS value (RFC 1877) */
924 #define CI_MS_WINS1 130 /* Primary WINS value (RFC 1877) */
925 #define CI_MS_DNS2 131 /* Secondary DNS value (RFC 1877) */
926 #define CI_MS_WINS2 132 /* Secondary WINS value (RFC 1877) */
928 static void dissect_ipcp_addrs_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
929 int offset, guint length, packet_info *pinfo,
931 static void dissect_ipcp_addr_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
932 int offset, guint length, packet_info *pinfo,
934 static void dissect_ipcp_compress_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
935 int offset, guint length, packet_info *pinfo,
937 static void dissect_ipcp_iphc_disableprot_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
938 int offset, guint length, packet_info *pinfo,
941 static const ip_tcp_opt ipcp_opts[] = {
944 "IP addresses (deprecated)",
945 &ett_ipcp_ipaddrs_opt,
948 dissect_ipcp_addrs_opt
953 &ett_ipcp_compress_opt,
956 dissect_ipcp_compress_opt
964 dissect_ipcp_addr_opt
968 "Mobile node's home IP address",
972 dissect_ipcp_addr_opt
976 "Primary DNS server IP address",
980 dissect_ipcp_addr_opt
984 "Primary WINS server IP address",
988 dissect_ipcp_addr_opt
992 "Secondary DNS server IP address",
996 dissect_ipcp_addr_opt
1000 "Secondary WINS server IP address",
1004 dissect_ipcp_addr_opt
1008 #define N_IPCP_OPTS (sizeof ipcp_opts / sizeof ipcp_opts[0])
1012 * IP Compression options
1014 #define IPCP_COMPRESS_VJ_1172 0x37 /* value defined in RFC1172 (typo) */
1015 #define IPCP_COMPRESS_VJ 0x2d /* value defined in RFC1332 (correct) */
1016 #define IPCP_COMPRESS_IPHC 0x61
1018 const value_string ipcp_compress_proto_vals[] = {
1019 { IPCP_COMPRESS_VJ_1172, "VJ compression (RFC1172-typo)" },
1020 { IPCP_COMPRESS_VJ, "VJ compression" },
1021 { IPCP_COMPRESS_IPHC, "IPHC compression" },
1025 /* IPHC suboptions (RFC2508, 3544) */
1026 #define IPCP_IPHC_CRTP 1
1027 #define IPCP_IPHC_ECRTP 2
1028 #define IPCP_IPHC_DISABLE_PROTO 3 /* Disable compression for protocol */
1030 const value_string ipcp_iphc_disable_proto_vals[] = {
1036 static const ip_tcp_opt ipcp_iphc_subopts[] = {
1039 "RTP compression (RFC2508)",
1047 "Enhanced RTP compression (RFC3545)",
1054 IPCP_IPHC_DISABLE_PROTO,
1055 "Enhanced RTP compression (RFC3545)",
1056 &ett_ipcp_iphc_disableprot_opt,
1059 dissect_ipcp_iphc_disableprot_opt
1063 #define N_IPCP_IPHC_SUBOPTS (sizeof ipcp_iphc_subopts / sizeof ipcp_iphc_subopts[0])
1069 #define CI_OSICP_ALIGN_NPDU 1 /* Alignment of the OSI NPDU (RFC 1377) */
1071 static void dissect_osicp_align_npdu_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
1072 int offset, guint length, packet_info *pinfo,
1075 static const ip_tcp_opt osicp_opts[] = {
1077 CI_OSICP_ALIGN_NPDU,
1079 &ett_osicp_align_npdu_opt,
1082 dissect_osicp_align_npdu_opt
1086 #define N_OSICP_OPTS (sizeof osicp_opts / sizeof osicp_opts[0])
1091 #define CI_CCP_OUI 0 /* OUI (RFC1962) */
1092 #define CI_CCP_PREDICT1 1 /* Predictor type 1 (RFC1962) */
1093 #define CI_CCP_PREDICT2 2 /* Predictor type 2 (RFC1962) */
1094 #define CI_CCP_PUDDLE 3 /* Puddle Jumper (RFC1962) */
1095 #define CI_CCP_HPPPC 16 /* Hewlett-Packard PPC (RFC1962) */
1096 #define CI_CCP_STAC 17 /* stac Electronics LZS (RFC1974) */
1097 #define CI_CCP_MPPC 18 /* Microsoft PPC (RFC2218/3078) */
1098 #define CI_CCP_GFZA 19 /* Gandalf FZA (RFC1962) */
1099 #define CI_CCP_V42BIS 20 /* V.42bis compression */
1100 #define CI_CCP_BSDLZW 21 /* BSD LZW Compress (RFC1977) */
1101 #define CI_CCP_LZSDCP 23 /* LZS-DCP (RFC1967) */
1102 #define CI_CCP_MVRCA 24 /* MVRCA (Magnalink) (RFC1975) */
1103 #define CI_CCP_DEFLATE 26 /* Deflate (RFC1979) */
1104 #define CI_CCP_RESERVED 255 /* Reserved (RFC1962) */
1107 * Microsoft Point-To-Point Compression (MPPC) and Encryption (MPPE)
1110 #define MPPC_SUPPORTED_BITS_C 0x00000001 /* MPPC negotiation */
1111 #define MPPE_SUPPORTED_BITS_D 0x00000010 /* Obsolete */
1112 #define MPPE_SUPPORTED_BITS_L 0x00000020 /* 40-bit encryption */
1113 #define MPPE_SUPPORTED_BITS_S 0x00000040 /* 128-bit encryption */
1114 #define MPPE_SUPPORTED_BITS_M 0x00000080 /* 56-bit encryption */
1115 #define MPPE_SUPPORTED_BITS_H 0x01000000 /* stateless mode */
1117 static void dissect_ccp_stac_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
1118 int offset, guint length, packet_info *pinfo,
1121 static void dissect_ccp_mppc_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
1122 int offset, guint length, packet_info *pinfo,
1125 static void dissect_ccp_bsdcomp_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
1126 int offset, guint length, packet_info *pinfo,
1129 static void dissect_ccp_lzsdcp_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
1130 int offset, guint length, packet_info *pinfo,
1133 static void dissect_ccp_mvrca_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
1134 int offset, guint length, packet_info *pinfo,
1137 static void dissect_ccp_deflate_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
1138 int offset, guint length, packet_info *pinfo,
1141 static const ip_tcp_opt ccp_opts[] = {
1144 "Stac Electronics LZS",
1148 /* In RFC 1974, this is a fixed-length field of size 5,
1149 but in Ascend Proprietary STAC compression this field
1150 is 6 octets. Sigh... */
1151 dissect_ccp_stac_opt
1159 dissect_ccp_mppc_opt
1164 &ett_ccp_bsdcomp_opt,
1167 dissect_ccp_bsdcomp_opt
1172 &ett_ccp_lzsdcp_opt,
1175 dissect_ccp_lzsdcp_opt
1179 "MVRCA (Magnalink)",
1183 dissect_ccp_mvrca_opt
1188 &ett_ccp_deflate_opt,
1190 4, /* RFC1979 says the length is 3 but it's actually 4. */
1191 dissect_ccp_deflate_opt
1195 #define N_CCP_OPTS (sizeof ccp_opts / sizeof ccp_opts[0])
1200 #define CI_CBCP_NO_CALLBACK 1 /* No callback */
1201 #define CI_CBCP_CB_USER 2 /* Callback to a user-specified number */
1202 #define CI_CBCP_CB_PRE 3 /* Callback to a pre-specified or
1203 administrator specified number */
1204 #define CI_CBCP_CB_ANY 4 /* Callback to any of a list of numbers */
1206 static void dissect_cbcp_no_callback_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
1207 int offset, guint length, packet_info *pinfo,
1210 static void dissect_cbcp_callback_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
1211 int offset, guint length, packet_info *pinfo,
1214 static const ip_tcp_opt cbcp_opts[] = {
1216 CI_CBCP_NO_CALLBACK,
1221 dissect_cbcp_no_callback_opt
1225 "Callback to a user-specified number",
1226 &ett_cbcp_callback_opt,
1229 dissect_cbcp_callback_opt
1233 "Callback to a pre-specified or admin-specified number",
1234 &ett_cbcp_callback_opt,
1237 dissect_cbcp_callback_opt
1241 "Callback to any of a list of numbers",
1242 &ett_cbcp_callback_opt,
1245 dissect_cbcp_callback_opt
1250 #define N_CBCP_OPTS (sizeof cbcp_opts / sizeof cbcp_opts[0])
1255 #define CI_BACP_FAVORED_PEER 1 /* Favored-Peer */
1257 static void dissect_bacp_favored_peer_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
1258 int offset, guint length, packet_info *pinfo,
1261 static const ip_tcp_opt bacp_opts[] = {
1263 CI_BACP_FAVORED_PEER,
1265 &ett_bacp_favored_peer_opt,
1268 dissect_bacp_favored_peer_opt
1272 #define N_BACP_OPTS (sizeof bacp_opts / sizeof bacp_opts[0])
1277 #define CI_BAP_LINK_TYPE 1 /* Link Type */
1278 #define CI_BAP_PHONE_DELTA 2 /* Phone-Delta */
1279 #define CI_BAP_NO_PHONE_NUM_NEEDED 3 /* No Phone Number Needed */
1280 #define CI_BAP_REASON 4 /* Reason */
1281 #define CI_BAP_LINK_DISC 5 /* Link Discriminator */
1282 #define CI_BAP_CALL_STATUS 6 /* Call Status */
1284 static void dissect_bap_link_type_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
1285 int offset, guint length, packet_info *pinfo,
1288 static void dissect_bap_phone_delta_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
1289 int offset, guint length, packet_info *pinfo,
1292 static void dissect_bap_link_disc_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
1293 int offset, guint length, packet_info *pinfo,
1296 static void dissect_bap_reason_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
1297 int offset, guint length, packet_info *pinfo,
1300 static void dissect_bap_call_status_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
1301 int offset, guint length, packet_info *pinfo,
1304 static const ip_tcp_opt bap_opts[] = {
1308 &ett_bap_link_type_opt,
1311 dissect_bap_link_type_opt
1316 &ett_bap_phone_delta_opt,
1319 dissect_bap_phone_delta_opt
1322 CI_BAP_NO_PHONE_NUM_NEEDED,
1323 "No Phone Number Needed",
1335 dissect_bap_reason_opt
1339 "Link Discriminator",
1343 dissect_bap_link_disc_opt
1348 &ett_bap_call_status_opt,
1351 dissect_bap_call_status_opt
1355 #define N_BAP_OPTS (sizeof bap_opts / sizeof bap_opts[0])
1357 static void dissect_ppp(tvbuff_t *tvb, packet_info *pinfo,
1360 static const value_string pap_vals[] = {
1361 {CONFREQ, "Authenticate-Request" },
1362 {CONFACK, "Authenticate-Ack" },
1363 {CONFNAK, "Authenticate-Nak" },
1366 static void dissect_pap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
1368 #define CHAP_CHAL 1 /* CHAP Challenge */
1369 #define CHAP_RESP 2 /* CHAP Response */
1370 #define CHAP_SUCC 3 /* CHAP Success */
1371 #define CHAP_FAIL 4 /* CHAP Failure */
1373 static const value_string chap_vals[] = {
1374 {CHAP_CHAL, "Challenge" },
1375 {CHAP_RESP, "Response" },
1376 {CHAP_SUCC, "Success" },
1377 {CHAP_FAIL, "Failure" },
1380 static void dissect_chap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
1382 static const value_string pppmuxcp_vals[] = {
1383 {CONFREQ, "Configuration Request" },
1384 {CONFACK, "Configuration Ack" },
1392 #define CI_DEFAULT_PID 1
1394 static void dissect_pppmuxcp_def_pid_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
1395 int offset, guint length, packet_info *pinfo, proto_tree *tree);
1398 static const ip_tcp_opt pppmuxcp_opts[] = {
1401 "Default Protocol ID",
1405 dissect_pppmuxcp_def_pid_opt
1409 #define N_PPPMUXCP_OPTS (sizeof pppmuxcp_opts / sizeof pppmuxcp_opts[0])
1414 #define CI_IPV6CP_IF_ID 1 /* Interface Identifier (RFC 2472) */
1415 #define CI_IPV6CP_COMPRESSTYPE 2 /* Compression Type (RFC 2472) */
1417 static void dissect_ipv6cp_if_id_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
1418 int offset, guint length, packet_info *pinfo,
1421 static const ip_tcp_opt ipv6cp_opts[] = {
1424 "Interface Identifier",
1425 &ett_ipv6cp_if_id_opt,
1428 dissect_ipv6cp_if_id_opt
1433 &ett_ipv6cp_compress_opt,
1436 dissect_ipcp_compress_opt
1440 #define N_IPV6CP_OPTS (sizeof ipv6cp_opts / sizeof ipv6cp_opts[0])
1443 *******************************************************************************
1444 * DETAILS : Calculate a new FCS-16 given the current FCS-16 and the new data.
1445 *******************************************************************************
1448 fcs16(tvbuff_t * tvbuff)
1450 guint len = tvb_length(tvbuff)-2;
1452 /* Check for Invalid Length */
1455 return crc16_ccitt_tvb(tvbuff, len);
1459 *******************************************************************************
1460 * DETAILS : Calculate a new FCS-32 given the current FCS-32 and the new data.
1461 *******************************************************************************
1464 fcs32(tvbuff_t * tvbuff)
1466 guint len = tvb_length(tvbuff)-4;
1468 /* Check for invalid Length */
1470 return (0x00000000);
1471 return crc32_ccitt_tvb(tvbuff, len);
1475 decode_fcs(tvbuff_t *tvb, proto_tree *fh_tree, int fcs_decode, int proto_offset)
1478 gint len, reported_len;
1484 * Remove the FCS, if any, from the packet data.
1486 switch (fcs_decode) {
1489 next_tvb = tvb_new_subset(tvb, proto_offset, -1, -1);
1494 * Do we have the entire packet, and does it include a 2-byte FCS?
1496 len = tvb_length_remaining(tvb, proto_offset);
1497 reported_len = tvb_reported_length_remaining(tvb, proto_offset);
1498 if (reported_len < 2 || len < 0) {
1500 * The packet is claimed not to even have enough data for a 2-byte FCS,
1501 * or we're already past the end of the captured data.
1502 * Don't slice anything off.
1504 next_tvb = tvb_new_subset(tvb, proto_offset, -1, -1);
1505 } else if (len < reported_len) {
1507 * The packet is claimed to have enough data for a 2-byte FCS, but
1508 * we didn't capture all of the packet.
1509 * Slice off the 2-byte FCS from the reported length, and trim the
1510 * captured length so it's no more than the reported length; that
1511 * will slice off what of the FCS, if any, is in the captured
1515 if (len > reported_len)
1517 next_tvb = tvb_new_subset(tvb, proto_offset, len, reported_len);
1520 * We have the entire packet, and it includes a 2-byte FCS.
1525 next_tvb = tvb_new_subset(tvb, proto_offset, len, reported_len);
1528 * Compute the FCS and put it into the tree.
1530 rx_fcs_offset = proto_offset + len;
1531 rx_fcs_exp = fcs16(tvb);
1532 rx_fcs_got = tvb_get_letohs(tvb, rx_fcs_offset);
1533 if (rx_fcs_got != rx_fcs_exp) {
1534 proto_tree_add_text(fh_tree, tvb, rx_fcs_offset, 2,
1535 "FCS 16: 0x%04x [incorrect, should be 0x%04x]",
1536 rx_fcs_got, rx_fcs_exp);
1538 proto_tree_add_text(fh_tree, tvb, rx_fcs_offset, 2,
1539 "FCS 16: 0x%04x [correct]",
1547 * Do we have the entire packet, and does it include a 4-byte FCS?
1549 len = tvb_length_remaining(tvb, proto_offset);
1550 reported_len = tvb_reported_length_remaining(tvb, proto_offset);
1551 if (reported_len < 4) {
1553 * The packet is claimed not to even have enough data for a 4-byte FCS.
1554 * Just pass on the tvbuff as is.
1556 next_tvb = tvb_new_subset(tvb, proto_offset, -1, -1);
1557 } else if (len < reported_len) {
1559 * The packet is claimed to have enough data for a 4-byte FCS, but
1560 * we didn't capture all of the packet.
1561 * Slice off the 4-byte FCS from the reported length, and trim the
1562 * captured length so it's no more than the reported length; that
1563 * will slice off what of the FCS, if any, is in the captured
1567 if (len > reported_len)
1569 next_tvb = tvb_new_subset(tvb, proto_offset, len, reported_len);
1572 * We have the entire packet, and it includes a 4-byte FCS.
1577 next_tvb = tvb_new_subset(tvb, proto_offset, len, reported_len);
1580 * Compute the FCS and put it into the tree.
1582 rx_fcs_offset = proto_offset + len;
1583 rx_fcs_exp = fcs32(tvb);
1584 rx_fcs_got = tvb_get_letohl(tvb, rx_fcs_offset);
1585 if (rx_fcs_got != rx_fcs_exp) {
1586 proto_tree_add_text(fh_tree, tvb, rx_fcs_offset, 4,
1587 "FCS 32: 0x%08x [incorrect, should be 0x%08x]",
1588 rx_fcs_got, rx_fcs_exp);
1590 proto_tree_add_text(fh_tree, tvb, rx_fcs_offset, 4,
1591 "FCS 32: 0x%08x [correct]",
1598 DISSECTOR_ASSERT_NOT_REACHED();
1606 capture_ppp_hdlc( const guchar *pd, int offset, int len, packet_counts *ld ) {
1607 if (!BYTES_ARE_IN_FRAME(offset, len, 2)) {
1611 if (pd[0] == CHDLC_ADDR_UNICAST || pd[0] == CHDLC_ADDR_MULTICAST) {
1612 capture_chdlc(pd, offset, len, ld);
1615 if (!BYTES_ARE_IN_FRAME(offset, len, 4)) {
1619 switch (pntohs(&pd[offset + 2])) {
1621 capture_ip(pd, offset + 4, len, ld);
1636 dissect_lcp_mru_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
1637 guint length, packet_info *pinfo _U_,
1640 proto_tree_add_text(tree, tvb, offset, length, "%s: %u", optp->name,
1641 tvb_get_ntohs(tvb, offset + 2));
1645 dissect_lcp_async_map_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
1646 guint length, packet_info *pinfo _U_,
1651 static const char *ctrlchars[32] = {
1652 "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL",
1653 "BS", "HT", "NL", "VT", "NP (FF)", "CR", "SO", "SI",
1654 "DLE", "DC1 (XON)", "DC2", "DC3 (XOFF)", "DC4", "NAK", "SYN", "ETB",
1655 "CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US"
1661 * XXX - walk through the map and show the characters to map?
1662 * Put them in a subtree of this item, and have the top-level item
1663 * either say "None", "All", or give a list of the characters?)
1665 map = tvb_get_ntohl(tvb, offset + 2);
1666 if (map == 0x00000000)
1667 mapstr = "None"; /* don't map any control characters */
1668 else if (map == 0xffffffff)
1669 mapstr = "All"; /* map all control characters */
1671 #define MAX_MAPSTR_LEN (32*(10+2)+1)
1672 mapstr=ep_alloc(MAX_MAPSTR_LEN);
1674 * Show the names of the control characters being mapped.
1677 for (i = 0; i < 32; i++) {
1678 if (map & (1 << i)) {
1679 mapp+=g_snprintf(mapp, MAX_MAPSTR_LEN-(mapp-mapstr), "%s%s", (mapp==mapstr)?"":", ", ctrlchars[i]);
1683 proto_tree_add_text(tree, tvb, offset, length, "%s: 0x%08x (%s)", optp->name,
1688 dissect_lcp_protocol_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
1689 guint length, packet_info *pinfo _U_,
1694 proto_tree *field_tree = NULL;
1696 tf = proto_tree_add_text(tree, tvb, offset, length, "%s: %u byte%s",
1697 optp->name, length, plurality(length, "", "s"));
1698 field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
1701 protocol = tvb_get_ntohs(tvb, offset);
1702 proto_tree_add_text(field_tree, tvb, offset, 2, "%s: %s (0x%02x)", optp->name,
1703 val_to_str(protocol, ppp_vals, "Unknown"), protocol);
1707 proto_tree_add_text(field_tree, tvb, offset, length, "Data (%d byte%s)", length,
1708 plurality(length, "", "s"));
1712 dissect_lcp_authprot_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
1713 guint length, packet_info *pinfo _U_,
1719 proto_tree *field_tree = NULL;
1721 tf = proto_tree_add_text(tree, tvb, offset, length, "%s: %u byte%s",
1722 optp->name, length, plurality(length, "", "s"));
1723 field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
1726 protocol = tvb_get_ntohs(tvb, offset);
1727 proto_tree_add_text(field_tree, tvb, offset, 2, "%s: %s (0x%02x)", optp->name,
1728 val_to_str(protocol, ppp_vals, "Unknown"), protocol);
1732 if (protocol == PPP_CHAP) {
1733 algorithm = tvb_get_guint8(tvb, offset);
1734 proto_tree_add_text(field_tree, tvb, offset, length,
1735 "Algorithm: %s (0x%02x)",
1736 val_to_str(algorithm, chap_alg_vals, "Unknown"),
1740 proto_tree_add_text(field_tree, tvb, offset, length, "Data (%d byte%s)", length,
1741 plurality(length, "", "s"));
1747 dissect_lcp_magicnumber_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
1748 int offset, guint length, packet_info *pinfo _U_,
1751 proto_tree_add_text(tree, tvb, offset, length, "%s: 0x%08x", optp->name,
1752 tvb_get_ntohl(tvb, offset + 2));
1756 dissect_lcp_fcs_alternatives_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
1757 int offset, guint length, packet_info *pinfo _U_,
1761 proto_tree *field_tree = NULL;
1762 guint8 alternatives;
1764 alternatives = tvb_get_guint8(tvb, offset + 2);
1765 tf = proto_tree_add_text(tree, tvb, offset, length, "%s: 0x%02x",
1766 optp->name, alternatives);
1767 field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
1769 if (alternatives & 0x1)
1770 proto_tree_add_text(field_tree, tvb, offset + 2, 1, "%s",
1771 decode_boolean_bitfield(alternatives, 0x1, 8, "Null FCS", NULL));
1772 if (alternatives & 0x2)
1773 proto_tree_add_text(field_tree, tvb, offset + 2, 1, "%s",
1774 decode_boolean_bitfield(alternatives, 0x2, 8, "CCITT 16-bit FCS", NULL));
1775 if (alternatives & 0x4)
1776 proto_tree_add_text(field_tree, tvb, offset + 2, 1, "%s",
1777 decode_boolean_bitfield(alternatives, 0x4, 8, "CCITT 32-bit FCS", NULL));
1781 dissect_lcp_self_describing_pad_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
1782 int offset, guint length, packet_info *pinfo _U_,
1785 proto_tree_add_text(tree, tvb, offset, length, "%s: %u", optp->name,
1786 tvb_get_guint8(tvb, offset + 2));
1790 dissect_lcp_numbered_mode_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
1791 int offset, guint length, packet_info *pinfo _U_,
1795 proto_tree *field_tree = NULL;
1797 tf = proto_tree_add_text(tree, tvb, offset, length, "%s: %u byte%s",
1798 optp->name, length, plurality(length, "", "s"));
1799 field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
1802 proto_tree_add_text(field_tree, tvb, offset, 1, "Window: %u",
1803 tvb_get_guint8(tvb, offset));
1807 proto_tree_add_text(field_tree, tvb, offset, length, "Address (%d byte%s)",
1808 length, plurality(length, "", "s"));
1811 static const value_string callback_op_vals[] = {
1812 {0, "Location is determined by user authentication" },
1813 {1, "Message is dialing string" },
1814 {2, "Message is location identifier" },
1815 {3, "Message is E.164" },
1816 {4, "Message is distinguished name" },
1818 {6, "Location is determined during CBCP negotiation" },
1823 dissect_lcp_callback_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
1824 guint length, packet_info *pinfo _U_,
1828 proto_tree *field_tree = NULL;
1831 tf = proto_tree_add_text(tree, tvb, offset, length, "%s: %u byte%s",
1832 optp->name, length, plurality(length, "", "s"));
1833 field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
1836 operation = tvb_get_guint8(tvb, offset);
1837 proto_tree_add_text(field_tree, tvb, offset, 1, "Operation: %s (0x%02x)",
1838 val_to_str(operation, callback_op_vals, "Unknown"),
1843 proto_tree_add_text(field_tree, tvb, offset, length, "Message (%d byte%s)",
1844 length, plurality(length, "", "s"));
1848 dissect_lcp_multilink_mrru_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
1849 int offset, guint length, packet_info *pinfo _U_,
1852 proto_tree_add_text(tree, tvb, offset, length, "%s: %u", optp->name,
1853 tvb_get_ntohs(tvb, offset + 2));
1856 #define CLASS_NULL 0
1857 #define CLASS_LOCAL 1
1859 #define CLASS_IEEE_802_1 3
1860 #define CLASS_PPP_MAGIC_NUMBER 4
1861 #define CLASS_PSDN_DIRECTORY_NUMBER 5
1863 static const value_string multilink_ep_disc_class_vals[] = {
1864 {CLASS_NULL, "Null" },
1865 {CLASS_LOCAL, "Locally assigned address" },
1866 {CLASS_IP, "IP address" },
1867 {CLASS_IEEE_802_1, "IEEE 802.1 globally assigned MAC address" },
1868 {CLASS_PPP_MAGIC_NUMBER, "PPP magic-number block" },
1869 {CLASS_PSDN_DIRECTORY_NUMBER, "Public switched network directory number" },
1874 dissect_lcp_multilink_ep_disc_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
1875 int offset, guint length, packet_info *pinfo _U_,
1879 proto_tree *field_tree = NULL;
1880 guint8 ep_disc_class;
1882 tf = proto_tree_add_text(tree, tvb, offset, length, "%s: %u byte%s",
1883 optp->name, length, plurality(length, "", "s"));
1884 field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
1887 ep_disc_class = tvb_get_guint8(tvb, offset);
1888 proto_tree_add_text(field_tree, tvb, offset, 1, "Class: %s (%u)",
1889 val_to_str(ep_disc_class, multilink_ep_disc_class_vals, "Unknown"),
1894 switch (ep_disc_class) {
1897 proto_tree_add_text(field_tree, tvb, offset, length,
1898 "Address (%d byte%s), should have been empty",
1899 length, plurality(length, "", "s"));
1904 proto_tree_add_text(field_tree, tvb, offset, length,
1905 "Address (%d byte%s), should have been <20",
1906 length, plurality(length, "", "s"));
1908 proto_tree_add_text(field_tree, tvb, offset, length,
1909 "Address (%d byte%s)",
1910 length, plurality(length, "", "s"));
1916 proto_tree_add_text(field_tree, tvb, offset, length,
1917 "Address (%d byte%s), should have been 4",
1918 length, plurality(length, "", "s"));
1920 proto_tree_add_text(field_tree, tvb, offset, length,
1921 "Address: %s", ip_to_str(tvb_get_ptr(tvb, offset, 4)));
1925 case CLASS_IEEE_802_1:
1927 proto_tree_add_text(field_tree, tvb, offset, length,
1928 "Address (%d byte%s), should have been 6",
1929 length, plurality(length, "", "s"));
1931 proto_tree_add_text(field_tree, tvb, offset, length,
1932 "Address: %s", ether_to_str(tvb_get_ptr(tvb, offset, 6)));
1936 case CLASS_PPP_MAGIC_NUMBER:
1937 /* XXX - dissect as 32-bit magic numbers */
1939 proto_tree_add_text(field_tree, tvb, offset, length,
1940 "Address (%d byte%s), should have been <20",
1941 length, plurality(length, "", "s"));
1943 proto_tree_add_text(field_tree, tvb, offset, length,
1944 "Address (%d byte%s)",
1945 length, plurality(length, "", "s"));
1949 case CLASS_PSDN_DIRECTORY_NUMBER:
1951 proto_tree_add_text(field_tree, tvb, offset, length,
1952 "Address (%d byte%s), should have been <20",
1953 length, plurality(length, "", "s"));
1955 proto_tree_add_text(field_tree, tvb, offset, length,
1956 "Address (%d byte%s)",
1957 length, plurality(length, "", "s"));
1962 proto_tree_add_text(field_tree, tvb, offset, length,
1963 "Address (%d byte%s)",
1964 length, plurality(length, "", "s"));
1971 dissect_lcp_bap_link_discriminator_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
1972 int offset, guint length, packet_info *pinfo _U_,
1975 proto_tree_add_text(tree, tvb, offset, length,
1976 "%s: 0x%04x", optp->name,
1977 tvb_get_ntohs(tvb, offset + 2));
1980 /* Character set numbers from the IANA charset registry. */
1981 static const value_string charset_num_vals[] = {
1987 dissect_lcp_internationalization_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
1988 int offset, guint length, packet_info *pinfo _U_,
1992 proto_tree *field_tree = NULL;
1995 tf = proto_tree_add_text(tree, tvb, offset, length, "%s: %u byte%s",
1996 optp->name, length, plurality(length, "", "s"));
1997 field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
2000 charset = tvb_get_ntohl(tvb, offset);
2001 proto_tree_add_text(field_tree, tvb, offset, 4, "Character set: %s (0x%04x)",
2002 val_to_str(charset, charset_num_vals, "Unknown"),
2007 /* XXX - should be displayed as an ASCII string */
2008 proto_tree_add_text(field_tree, tvb, offset, length, "Language tag (%d byte%s)",
2009 length, plurality(length, "", "s"));
2014 dissect_ipcp_addrs_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
2015 int offset, guint length, packet_info *pinfo _U_,
2019 proto_tree *field_tree = NULL;
2021 tf = proto_tree_add_text(tree, tvb, offset, length, "%s: %u byte%s",
2022 optp->name, length, plurality(length, "", "s"));
2023 field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
2026 proto_tree_add_text(field_tree, tvb, offset, 4,
2027 "Source IP address: %s",
2028 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
2031 proto_tree_add_text(field_tree, tvb, offset, 4,
2032 "Destination IP address: %s",
2033 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
2036 static void dissect_ipcp_addr_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
2037 int offset, guint length, packet_info *pinfo _U_,
2040 proto_tree_add_text(tree, tvb, offset, length, "%s: %s", optp->name,
2041 ip_to_str(tvb_get_ptr(tvb, offset + 2, 4)));
2044 static void dissect_ipcp_compress_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
2045 int offset, guint length, packet_info *pinfo _U_,
2051 proto_tree *field_tree = NULL;
2053 tf = proto_tree_add_text(tree, tvb, offset, length, "%s: %u byte%s",
2054 optp->name, length, plurality(length, "", "s"));
2056 field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
2057 offset += 2; /* Skip option type + length */
2060 us = tvb_get_ntohs(tvb, offset);
2061 proto_tree_add_text( field_tree, tvb, offset, 2, "IP compression protocol: %s (0x%04x)",
2062 val_to_str( us, ipcp_compress_proto_vals, "Unknown protocol" ),
2064 offset += 2; /* skip protocol */
2069 case IPCP_COMPRESS_VJ_1172:
2070 case IPCP_COMPRESS_VJ:
2071 /* First byte is max slot id */
2072 ub = tvb_get_guint8( tvb, offset );
2073 proto_tree_add_text( field_tree, tvb, offset, 1,
2074 "Max slot id: %u (0x%02x)",
2080 /* second byte is "compress slot id" */
2081 ub = tvb_get_guint8( tvb, offset );
2082 proto_tree_add_text( field_tree, tvb, offset, 1,
2083 "Compress slot id: %s (0x%02x)",
2084 ub ? "yes" : "no", ub );
2091 case IPCP_COMPRESS_IPHC:
2095 us = tvb_get_ntohs(tvb, offset);
2096 proto_tree_add_text( field_tree, tvb, offset, 2,
2097 "TCP space: %u (0x%04x)",
2106 us = tvb_get_ntohs(tvb, offset);
2107 proto_tree_add_text( field_tree, tvb, offset, 2,
2108 "Non-TCP space: %u (0x%04x)",
2117 us = tvb_get_ntohs(tvb, offset);
2118 proto_tree_add_text( field_tree, tvb, offset, 2,
2119 "Max period: %u (0x%04x) compressed packets",
2128 us = tvb_get_ntohs(tvb, offset);
2129 proto_tree_add_text( field_tree, tvb, offset, 2,
2130 "Max time: %u (0x%04x) seconds",
2139 us = tvb_get_ntohs(tvb, offset);
2140 proto_tree_add_text( field_tree, tvb, offset, 2,
2141 "Max header: %u (0x%04x) bytes",
2148 tf = proto_tree_add_text(field_tree, tvb, offset, length,
2149 "Suboptions: (%u byte%s)",
2150 length, plurality(length, "", "s"));
2151 field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
2152 dissect_ip_tcp_options(tvb, offset, length,
2153 ipcp_iphc_subopts, N_IPCP_IPHC_SUBOPTS, -1,
2160 proto_tree_add_text(field_tree, tvb, offset, length,
2161 "Data (%d byte%s)", length,
2162 plurality(length, "", "s"));
2167 static void dissect_ipcp_iphc_disableprot_opt(const ip_tcp_opt *optp,
2169 int offset, guint length,
2170 packet_info *pinfo _U_,
2174 proto_tree *field_tree;
2177 tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
2178 field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
2180 param = tvb_get_guint8(tvb, offset + 2);
2181 proto_tree_add_text(field_tree, tvb, offset + 2, 1,
2182 "Protocol: %s (0x%02x)",
2183 val_to_str( param, ipcp_iphc_disable_proto_vals, "Unknown" ),
2188 static void dissect_osicp_align_npdu_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
2189 int offset, guint length, packet_info *pinfo _U_,
2193 proto_tree *field_tree;
2196 tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
2197 field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
2199 alignment = tvb_get_guint8(tvb, offset + 2);
2200 proto_tree_add_text(field_tree, tvb, offset + 2, 1,
2201 "Alignment: %u", alignment);
2204 static void dissect_pppmuxcp_def_pid_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
2205 int offset, guint length, packet_info *pinfo _U_,
2208 pppmux_def_prot_id = tvb_get_ntohs(tvb, offset + 2);
2209 proto_tree_add_text(tree, tvb, offset + 2, length - 2, "%s: %s (0x%02x)",optp->name,
2210 val_to_str(pppmux_def_prot_id, ppp_vals, "Unknown"), pppmux_def_prot_id);
2215 dissect_ccp_stac_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
2216 int offset, guint length, packet_info *pinfo _U_,
2220 proto_tree *field_tree;
2224 proto_tree_add_text(tree, tvb, offset, length,
2225 "%s (Ascend Proprietary version)", optp->name);
2226 /* We don't know how to decode the following 4 octets, since
2227 there's no public document that describe their usage. */
2229 tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
2230 field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
2232 proto_tree_add_text(field_tree, tvb, offset + 2, 2,
2233 "History Count: %u", tvb_get_ntohs(tvb, offset + 2));
2234 check_mode = tvb_get_guint8(tvb, offset + 4);
2235 proto_tree_add_text(field_tree, tvb, offset + 4, 1,
2236 "Check Mode: %s (0x%02X)",
2237 val_to_str(check_mode, stac_checkmode_vals, "Unknown"),
2243 dissect_ccp_mppc_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
2244 int offset, guint length, packet_info *pinfo _U_,
2248 proto_tree *flags_tree;
2249 guint32 supported_bits;
2251 supported_bits = tvb_get_ntohl(tvb, offset + 2);
2252 tf = proto_tree_add_text(tree, tvb, offset, length,
2253 "%s: Supported Bits: 0x%08X", optp->name, supported_bits);
2254 flags_tree = proto_item_add_subtree(tf, *optp->subtree_index);
2255 proto_tree_add_text(flags_tree, tvb, offset + 2, 4, "%s",
2256 decode_boolean_bitfield(supported_bits, MPPC_SUPPORTED_BITS_C, 8*4,
2257 "Desire to negotiate MPPC", "NO Desire to negotiate MPPC"));
2258 proto_tree_add_text(flags_tree, tvb, offset + 2, 4, "%s",
2259 decode_boolean_bitfield(supported_bits, MPPE_SUPPORTED_BITS_D, 8*4,
2260 "Obsolete (should NOT be 1)", "Obsolete (should ALWAYS be 0)"));
2261 proto_tree_add_text(flags_tree, tvb, offset + 2, 4, "%s",
2262 decode_boolean_bitfield(supported_bits, MPPE_SUPPORTED_BITS_L, 8*4,
2263 "40-bit encryption ON", "40-bit encryption OFF"));
2264 proto_tree_add_text(flags_tree, tvb, offset + 2, 4, "%s",
2265 decode_boolean_bitfield(supported_bits, MPPE_SUPPORTED_BITS_S, 8*4,
2266 "128-bit encryption ON", "128-bit encryption OFF"));
2267 proto_tree_add_text(flags_tree, tvb, offset + 2, 4, "%s",
2268 decode_boolean_bitfield(supported_bits, MPPE_SUPPORTED_BITS_M, 8*4,
2269 "56-bit encryption ON", "56-bit encryption OFF"));
2270 proto_tree_add_text(flags_tree, tvb, offset + 2, 4, "%s",
2271 decode_boolean_bitfield(supported_bits, MPPE_SUPPORTED_BITS_H, 8*4,
2272 "Stateless mode ON", "Stateless mode OFF"));
2276 dissect_ccp_bsdcomp_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
2277 int offset, guint length, packet_info *pinfo _U_,
2281 proto_tree *field_tree;
2283 tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
2284 field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
2286 proto_tree_add_text(field_tree, tvb, offset + 2, 1,
2287 "Version: %u", tvb_get_guint8(tvb, offset + 2) >> 5);
2288 proto_tree_add_text(field_tree, tvb, offset + 2, 1,
2290 tvb_get_guint8(tvb, offset + 2) & 0x1f);
2294 dissect_ccp_lzsdcp_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
2295 int offset, guint length, packet_info *pinfo _U_,
2299 proto_tree *field_tree;
2301 guint8 process_mode;
2303 tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
2304 field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
2306 proto_tree_add_text(field_tree, tvb, offset + 2, 2,
2307 "History Count: %u", tvb_get_ntohs(tvb, offset + 2));
2308 check_mode = tvb_get_guint8(tvb, offset + 4);
2309 proto_tree_add_text(field_tree, tvb, offset + 4, 1,
2310 "Check Mode: %s (0x%02X)",
2311 val_to_str(check_mode, lzsdcp_checkmode_vals, "Unknown"),
2313 process_mode = tvb_get_guint8(tvb, offset + 5);
2314 proto_tree_add_text(field_tree, tvb, offset + 5, 1,
2315 "Process Mode: %s (0x%02X)",
2316 val_to_str(process_mode, lzsdcp_processmode_vals, "Unkown"),
2321 dissect_ccp_mvrca_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
2322 int offset, guint length, packet_info *pinfo _U_,
2326 proto_tree *field_tree;
2328 tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
2329 field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
2331 proto_tree_add_text(field_tree, tvb, offset + 2, 1,
2332 "Features: %u", tvb_get_guint8(tvb, offset + 2) >> 5);
2333 proto_tree_add_text(field_tree, tvb, offset + 2, 1,
2334 "Packet by Packet flag: %s",
2335 tvb_get_guint8(tvb, offset + 2) & 0x20 ? "true" : "false");
2336 proto_tree_add_text(field_tree, tvb, offset + 2, 1,
2337 "History: %u", tvb_get_guint8(tvb, offset + 2) & 0x20);
2338 proto_tree_add_text(field_tree, tvb, offset + 3, 1,
2339 "Number of contexts: %u", tvb_get_guint8(tvb, offset + 3));
2343 dissect_ccp_deflate_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
2344 int offset, guint length, packet_info *pinfo _U_,
2348 proto_tree *field_tree;
2351 tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
2352 field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
2354 proto_tree_add_text(field_tree, tvb, offset + 2, 1,
2355 "Window: %u", hi_nibble(tvb_get_guint8(tvb, offset + 2)));
2356 method = lo_nibble(tvb_get_guint8(tvb, offset + 2));
2357 proto_tree_add_text(field_tree, tvb, offset + 2, 1,
2358 "Method: %s (0x%02x)",
2359 method == 0x08 ? "zlib compression" : "other", method);
2360 proto_tree_add_text(field_tree, tvb, offset + 3, 1,
2361 "Sequence number check method: %u",
2362 tvb_get_guint8(tvb, offset + 2) & 0x03);
2366 dissect_cbcp_no_callback_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
2367 int offset, guint length, packet_info *pinfo _U_,
2370 proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
2374 dissect_cbcp_callback_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
2375 int offset, guint length, packet_info *pinfo _U_,
2379 proto_tree *field_tree;
2381 proto_tree *addr_tree;
2385 tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
2386 field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
2388 proto_tree_add_text(field_tree, tvb, offset + 2, 1,
2389 "Callback delay: %u", tvb_get_guint8(tvb, offset + 2));
2393 while (length > 0) {
2394 ta = proto_tree_add_text(field_tree, tvb, offset, length,
2395 "Callback Address");
2396 addr_type = tvb_get_guint8(tvb, offset);
2397 addr_tree = proto_item_add_subtree(tf, ett_cbcp_callback_opt_addr);
2398 proto_tree_add_text(addr_tree, tvb, offset, 1,
2399 "Address Type: %s (%u)",
2400 ((addr_type == 1) ? "PSTN/ISDN" : "Other"), addr_type);
2403 addr_len = tvb_strsize(tvb, offset);
2404 if (addr_len > length) {
2405 proto_tree_add_text(addr_tree, tvb, offset, length,
2406 "Address: (runs past end of option)");
2409 proto_tree_add_text(addr_tree, tvb, offset, addr_len,
2411 tvb_format_text(tvb, offset, addr_len - 1));
2418 dissect_bacp_favored_peer_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
2419 int offset, guint length, packet_info *pinfo _U_,
2423 proto_tree *field_tree;
2425 tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
2426 field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
2428 proto_tree_add_text(field_tree, tvb, offset + 2, 4,
2429 "Magic number: 0x%08x", tvb_get_ntohl(tvb, offset + 2));
2433 dissect_bap_link_type_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
2434 int offset, guint length, packet_info *pinfo _U_,
2438 proto_tree *field_tree;
2441 tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
2442 field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
2444 proto_tree_add_text(field_tree, tvb, offset + 2, 2,
2445 "Link Speed: %u kbps", tvb_get_ntohs(tvb, offset + 2));
2446 link_type = tvb_get_guint8(tvb, offset + 4);
2447 proto_tree_add_text(field_tree, tvb, offset + 4, 1,
2448 "Link Type: %s (%u)", val_to_str(link_type, bap_link_type_vals,
2449 "Unknown"), link_type);
2453 dissect_bap_phone_delta_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
2454 int offset, guint length, packet_info *pinfo _U_,
2458 proto_tree *field_tree;
2460 proto_tree *suboption_tree;
2464 tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
2465 field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
2470 while (length > 0) {
2471 subopt_type = tvb_get_guint8(tvb, offset);
2472 subopt_len = tvb_get_guint8(tvb, offset + 1);
2473 ti = proto_tree_add_text(field_tree, tvb, offset, subopt_len,
2474 "Sub-Option (%u byte%s)",
2475 subopt_len, plurality(subopt_len, "", "s"));
2476 suboption_tree = proto_item_add_subtree(ti, ett_bap_phone_delta_subopt);
2478 proto_tree_add_text(suboption_tree, tvb, offset, 1,
2479 "Sub-Option Type: %s (%u)",
2480 val_to_str(subopt_type, bap_phone_delta_subopt_vals, "Unknown"),
2483 if (subopt_len < 2) {
2484 proto_tree_add_text(suboption_tree, tvb, offset + 1, 1,
2485 "Sub-Option Length: %u (invalid, must be >= 2)", subopt_len);
2488 if (subopt_len > length) {
2489 proto_tree_add_text(suboption_tree, tvb, offset + 1, 1,
2490 "Sub-Option Length: %u (invalid, must be <= length remaining in option %u)", subopt_len, length);
2494 proto_tree_add_text(suboption_tree, tvb, offset + 1, 1,
2495 "Sub-Option Length: %u", subopt_len);
2497 switch (subopt_type) {
2498 case BAP_PHONE_DELTA_SUBOPT_UNIQ_DIGIT:
2499 if (subopt_len == 3) {
2500 proto_tree_add_text(suboption_tree, tvb, offset + 2, 1, "Unique Digit: %u",
2501 tvb_get_guint8(tvb, offset + 2));
2503 proto_tree_add_text(suboption_tree, tvb, offset + 1, 1,
2504 "Invalid suboption length: %u (must be == 3)",
2508 case BAP_PHONE_DELTA_SUBOPT_SUBSC_NUM:
2509 if (subopt_len > 2) {
2510 proto_tree_add_text(suboption_tree, tvb, offset + 2, subopt_len - 2,
2511 "Subscriber Number: %s",
2512 tvb_format_text(tvb, offset + 2, subopt_len - 2));
2514 proto_tree_add_text(suboption_tree, tvb, offset + 1, 1,
2515 "Invalid suboption length: %u (must be > 2)",
2519 case BAP_PHONE_DELTA_SUBOPT_PHONENUM_SUBADDR:
2520 if (subopt_len > 2) {
2521 proto_tree_add_text(suboption_tree, tvb, offset + 2, subopt_len - 2,
2522 "Phone Number Sub Address: %s",
2523 tvb_format_text(tvb, offset + 2, subopt_len - 2));
2525 proto_tree_add_text(suboption_tree, tvb, offset + 1, 1,
2526 "Invalid suboption length: %u (must be > 2)",
2531 if (subopt_len > 2) {
2532 proto_tree_add_text(suboption_tree, tvb, offset + 2, subopt_len - 2,
2535 proto_tree_add_text(suboption_tree, tvb, offset + 1, 1,
2536 "Invalid suboption length: %u (must be > 2)",
2541 offset += subopt_len;
2542 length -= subopt_len;
2547 dissect_bap_reason_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
2548 int offset, guint length, packet_info *pinfo _U_,
2552 proto_tree_add_text(tree, tvb, offset, length, "%s: %s",
2554 tvb_format_text(tvb, offset + 2, length - 2));
2559 dissect_bap_link_disc_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
2560 int offset, guint length, packet_info *pinfo _U_,
2563 proto_tree_add_text(tree, tvb, offset, length, "%s: 0x%04x",
2564 optp->name, tvb_get_ntohs(tvb, offset + 2));
2568 dissect_bap_call_status_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
2569 int offset, guint length, packet_info *pinfo _U_,
2573 proto_tree *field_tree;
2574 guint8 status, action;
2576 tf = proto_tree_add_text(tree, tvb, offset, length, "%s", optp->name);
2577 field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
2579 status = tvb_get_guint8(tvb, offset + 2);
2580 proto_tree_add_text(field_tree, tvb, offset + 2, 1,
2581 "Status: %s (0x%02x)",
2582 val_to_str(status, q931_cause_code_vals, "Unknown"), status);
2584 action = tvb_get_guint8(tvb, offset + 3);
2585 proto_tree_add_text(field_tree, tvb, offset + 3, 1,
2586 "Action: %s (0x%02x)",
2587 val_to_str(action, bap_call_status_opt_action_vals, "Unknown"), action);
2591 dissect_cp( tvbuff_t *tvb, int proto_id, int proto_subtree_index,
2592 const value_string *proto_vals, int options_subtree_index,
2593 const ip_tcp_opt *opts, int nopts, packet_info *pinfo,
2597 proto_tree *fh_tree = NULL;
2599 proto_tree *field_tree;
2606 code = tvb_get_guint8(tvb, 0);
2607 id = tvb_get_guint8(tvb, 1);
2608 length = tvb_get_ntohs(tvb, 2);
2610 if(check_col(pinfo->cinfo, COL_PROTOCOL))
2611 col_set_str(pinfo->cinfo, COL_PROTOCOL,
2612 proto_get_protocol_short_name(find_protocol_by_id(proto_id)));
2614 if(check_col(pinfo->cinfo, COL_INFO))
2615 col_add_str(pinfo->cinfo, COL_INFO,
2616 val_to_str(code, proto_vals, "Unknown"));
2619 ti = proto_tree_add_item(tree, proto_id, tvb, 0, length, FALSE);
2620 fh_tree = proto_item_add_subtree(ti, proto_subtree_index);
2621 proto_tree_add_text(fh_tree, tvb, 0, 1, "Code: %s (0x%02x)",
2622 val_to_str(code, proto_vals, "Unknown"), code);
2623 proto_tree_add_text(fh_tree, tvb, 1, 1, "Identifier: 0x%02x",
2625 proto_tree_add_text(fh_tree, tvb, 2, 2, "Length: %u",
2638 tf = proto_tree_add_text(fh_tree, tvb, offset, length,
2639 "Options: (%d byte%s)", length, plurality(length, "", "s"));
2640 field_tree = proto_item_add_subtree(tf, options_subtree_index);
2641 dissect_ip_tcp_options(tvb, offset, length, opts, nopts, -1,
2651 proto_tree_add_text(fh_tree, tvb, offset, 4, "Magic number: 0x%08x",
2652 tvb_get_ntohl(tvb, offset));
2656 proto_tree_add_text(fh_tree, tvb, offset, length, "Message (%d byte%s)",
2657 length, plurality(length, "", "s"));
2663 proto_tree_add_text(fh_tree, tvb, offset, 4, "Magic number: 0x%08x",
2664 tvb_get_ntohl(tvb, offset));
2668 proto_tree_add_text(fh_tree, tvb, offset, length, "Message: %s",
2669 tvb_format_text(tvb, offset, length));
2675 proto_tree_add_text(fh_tree, tvb, offset, 4, "Magic number: 0x%08x",
2676 tvb_get_ntohl(tvb, offset));
2679 proto_tree_add_text(fh_tree, tvb, offset, 4, "Seconds remaining: %u",
2680 tvb_get_ntohl(tvb, offset));
2684 proto_tree_add_text(fh_tree, tvb, offset, length, "Message (%d byte%s)",
2685 length, plurality(length, "", "s"));
2691 gboolean save_in_error_pkt;
2694 protocol = tvb_get_ntohs(tvb, offset);
2695 proto_tree_add_text(fh_tree, tvb, offset, 2,
2696 "Rejected protocol: %s (0x%04x)",
2697 val_to_str(protocol, ppp_vals, "Unknown"),
2702 proto_tree_add_text(fh_tree, tvb, offset, length,
2703 "Rejected packet (%d byte%s)",
2704 length, plurality(length, "", "s"));
2706 /* Save the current value of the "we're inside an error packet"
2707 flag, and set that flag; subdissectors may treat packets
2708 that are the payload of error packets differently from
2710 save_in_error_pkt = pinfo->in_error_pkt;
2711 pinfo->in_error_pkt = TRUE;
2713 /* Decode the rejected packet. */
2714 next_tvb = tvb_new_subset(tvb, offset, length, length);
2715 if (!dissector_try_port(ppp_subdissector_table, protocol,
2716 next_tvb, pinfo, fh_tree)) {
2717 call_dissector(data_handle, next_tvb, pinfo, fh_tree);
2720 /* Restore the "we're inside an error packet" flag. */
2721 pinfo->in_error_pkt = save_in_error_pkt;
2727 /* decode the rejected LCP packet here. */
2729 proto_tree_add_text(fh_tree, tvb, offset, length, "Rejected packet (%d byte%s)",
2730 length, plurality(length, "", "s"));
2736 proto_tree_add_text(fh_tree, tvb, offset, length, "Data (%d byte%s)",
2737 length, plurality(length, "", "s"));
2742 proto_tree_add_text(fh_tree, tvb, offset, length, "Stuff (%d byte%s)",
2743 length, plurality(length, "", "s"));
2748 /* Protocol field compression */
2749 #define PFC_BIT 0x01
2752 dissect_ppp_common( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
2753 proto_tree *fh_tree, proto_item *ti, int proto_offset )
2759 ppp_prot = tvb_get_guint8(tvb, 0);
2760 if (ppp_prot & PFC_BIT) {
2761 /* Compressed protocol field - just the byte we fetched. */
2764 /* Uncompressed protocol field - fetch all of it. */
2765 ppp_prot = tvb_get_ntohs(tvb, 0);
2769 /* If "ti" is not null, it refers to the top-level "proto_ppp" item
2770 for PPP, and proto_offset is the length of any stuff in the header
2771 preceding the protocol type, e.g. an HDLC header; add the length
2772 of the protocol type field to it, and set the length of that item
2775 proto_item_set_len(ti, proto_offset + proto_len);
2778 proto_tree_add_uint(fh_tree, hf_ppp_protocol, tvb, 0, proto_len, ppp_prot);
2780 next_tvb = tvb_new_subset(tvb, proto_len, -1, -1);
2782 /* do lookup with the subdissector table */
2783 if (!dissector_try_port(ppp_subdissector_table, ppp_prot, next_tvb, pinfo, tree)) {
2784 if (check_col(pinfo->cinfo, COL_PROTOCOL))
2785 col_add_fstr(pinfo->cinfo, COL_PROTOCOL, "0x%04x", ppp_prot);
2786 if (check_col(pinfo->cinfo, COL_INFO))
2787 col_add_fstr(pinfo->cinfo, COL_INFO, "PPP %s (0x%04x)",
2788 val_to_str(ppp_prot, ppp_vals, "Unknown"), ppp_prot);
2789 call_dissector(data_handle,next_tvb, pinfo, tree);
2794 dissect_lcp_options(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2796 dissect_ip_tcp_options(tvb, 0, tvb_reported_length(tvb), lcp_opts, N_LCP_OPTS,
2804 dissect_lcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2806 dissect_cp(tvb, proto_lcp, ett_lcp, lcp_vals, ett_lcp_options,
2807 lcp_opts, N_LCP_OPTS, pinfo, tree);
2814 dissect_ipcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2816 dissect_cp(tvb, proto_ipcp, ett_ipcp, cp_vals, ett_ipcp_options,
2817 ipcp_opts, N_IPCP_OPTS, pinfo, tree);
2824 dissect_osicp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2826 dissect_cp(tvb, proto_osicp, ett_osicp, cp_vals, ett_osicp_options,
2827 osicp_opts, N_OSICP_OPTS, pinfo, tree);
2834 dissect_ccp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2836 dissect_cp(tvb, proto_ccp, ett_ccp, ccp_vals, ett_ccp_options,
2837 ccp_opts, N_CCP_OPTS, pinfo, tree);
2841 * Callback Control Protocol - see
2843 * http://www.linet.gr.jp/~manabe/PPxP/doc/Standards/draft-gidwani-ppp-callback-cp-00.txt
2846 dissect_cbcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2848 dissect_cp(tvb, proto_cbcp, ett_cbcp, cbcp_vals, ett_cbcp_options,
2849 cbcp_opts, N_CBCP_OPTS, pinfo, tree);
2853 * RFC 2125 (BACP and BAP).
2856 dissect_bacp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2858 dissect_cp(tvb, proto_bacp, ett_bacp, cp_vals, ett_bacp_options,
2859 bacp_opts, N_BACP_OPTS, pinfo, tree);
2863 dissect_bap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2866 proto_tree *fh_tree = NULL;
2868 proto_tree *field_tree;
2875 type = tvb_get_guint8(tvb, 0);
2876 id = tvb_get_guint8(tvb, 1);
2877 length = tvb_get_ntohs(tvb, 2);
2879 if(check_col(pinfo->cinfo, COL_PROTOCOL))
2880 col_set_str(pinfo->cinfo, COL_PROTOCOL, "PPP BAP");
2882 if(check_col(pinfo->cinfo, COL_INFO))
2883 col_add_str(pinfo->cinfo, COL_INFO,
2884 val_to_str(type, bap_vals, "Unknown"));
2887 ti = proto_tree_add_item(tree, proto_bap, tvb, 0, length, FALSE);
2888 fh_tree = proto_item_add_subtree(ti, ett_bap_options);
2889 proto_tree_add_text(fh_tree, tvb, 0, 1, "Type: %s (0x%02x)",
2890 val_to_str(type, bap_vals, "Unknown"), type);
2891 proto_tree_add_text(fh_tree, tvb, 1, 1, "Identifier: 0x%02x",
2893 proto_tree_add_text(fh_tree, tvb, 2, 2, "Length: %u",
2899 if (type == BAP_CRES || type == BAP_CBRES ||
2900 type == BAP_LDQRES || type == BAP_CSRES) {
2901 resp_code = tvb_get_guint8(tvb, offset);
2902 proto_tree_add_text(fh_tree, tvb, offset, 1, "Response Code: %s (0x%02x)",
2903 val_to_str(resp_code, bap_resp_code_vals, "Unknown"), resp_code);
2910 tf = proto_tree_add_text(fh_tree, tvb, offset, length,
2911 "Data (%d byte%s)", length, plurality(length, "", "s"));
2912 field_tree = proto_item_add_subtree(tf, ett_bap_options);
2913 dissect_ip_tcp_options(tvb, offset, length, bap_opts, N_BAP_OPTS, -1,
2920 dissect_comp_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2923 proto_tree *comp_data_tree;
2925 if (check_col(pinfo->cinfo, COL_PROTOCOL))
2926 col_set_str(pinfo->cinfo, COL_PROTOCOL, "PPP Comp");
2928 if(check_col(pinfo->cinfo, COL_INFO))
2929 col_set_str(pinfo->cinfo, COL_INFO, "Compressed data");
2932 ti = proto_tree_add_item(tree, proto_comp_data, tvb, 0, -1, FALSE);
2933 comp_data_tree = proto_item_add_subtree(ti, ett_comp_data);
2938 * RFC 3153 (both PPPMuxCP and PPPMux).
2941 dissect_pppmuxcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2943 dissect_cp(tvb,proto_pppmuxcp,ett_pppmuxcp,pppmuxcp_vals,
2944 ett_pppmuxcp_options,pppmuxcp_opts,N_PPPMUXCP_OPTS,pinfo,tree);
2947 #define PPPMUX_FLAGS_MASK 0xc0
2948 #define PPPMUX_PFF_BIT_SET 0x80
2949 #define PPPMUX_LXT_BIT_SET 0x40
2952 dissect_pppmux(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2954 proto_tree *mux_tree, *hdr_tree, *sub_tree, *flag_tree;
2955 proto_tree *info_tree;
2956 proto_item *ti = NULL,*sub_ti = NULL;
2961 int offset = 0, length_remaining;
2962 int length_field = 0, pid_field = 0,hdr_length = 0;
2964 if (check_col(pinfo->cinfo, COL_PROTOCOL))
2965 col_set_str(pinfo->cinfo,COL_PROTOCOL, "PPP PPPMux");
2967 if (check_col(pinfo->cinfo, COL_INFO))
2968 col_set_str(pinfo->cinfo, COL_INFO, "PPP Multiplexing");
2970 length_remaining = tvb_reported_length(tvb);
2973 ti = proto_tree_add_item(tree, proto_pppmux, tvb, 0, -1, FALSE);
2974 mux_tree = proto_item_add_subtree(ti,ett_pppmux);
2976 while (length_remaining > 0) {
2978 flags = tvb_get_guint8(tvb,offset) & PPPMUX_FLAGS_MASK;
2980 if (flags && PPPMUX_LXT_BIT_SET ) {
2981 length = tvb_get_ntohs(tvb,offset) & 0x3fff;
2984 length = tvb_get_guint8(tvb,offset) & 0x3f;
2988 if (flags && PPPMUX_PFF_BIT_SET) {
2989 byte = tvb_get_guint8(tvb,offset + length_field);
2990 if (byte && PFC_BIT) { /* Compressed PID field*/
2993 } else { /*PID field is 2 bytes*/
2994 pid = tvb_get_ntohs(tvb,offset + length_field);
2998 if (!pid){ /*No Last PID, hence use the default */
2999 if (pppmux_def_prot_id)
3000 pid = pppmux_def_prot_id;
3004 hdr_length = length_field + pid_field;
3006 ti = proto_tree_add_text(mux_tree, tvb, offset, length + length_field,
3007 "PPPMux Sub-frame");
3008 sub_tree = proto_item_add_subtree(ti,ett_pppmux_subframe);
3009 sub_ti = proto_tree_add_text(sub_tree, tvb, offset,
3010 hdr_length,"Header field");
3012 hdr_tree = proto_item_add_subtree(sub_ti,ett_pppmux_subframe_hdr);
3013 ti = proto_tree_add_text(hdr_tree, tvb, offset, length_field, "PFF/LXT: 0x%02X",
3016 flag_tree = proto_item_add_subtree(ti,ett_pppmux_subframe_flags);
3017 proto_tree_add_text(flag_tree,tvb,offset,length_field,"%s",
3018 decode_boolean_bitfield(flags,0x80,8,"PID Present","PID not present"));
3019 proto_tree_add_text(flag_tree,tvb,offset,length_field,"%s",
3020 decode_boolean_bitfield(flags,0x40,8,"2 bytes ength field ","1 byte length field"));
3022 ti = proto_tree_add_text(hdr_tree,tvb,offset,length_field,"Sub-frame Length = %u",length);
3024 if (flags && PPPMUX_PFF_BIT_SET)
3025 proto_tree_add_text(hdr_tree,tvb,offset + length_field,pid_field,"%s: %s(0x%02x)",
3026 "Protocol ID",val_to_str(pid,ppp_vals,"Unknown"), pid);
3028 offset += hdr_length;
3029 length_remaining -= hdr_length;
3030 length -= pid_field;
3032 tvb_ensure_bytes_exist (tvb,offset,length);
3033 sub_ti = proto_tree_add_text(sub_tree,tvb,offset,length,"Information Field");
3034 info_tree = proto_item_add_subtree(sub_ti,ett_pppmux_subframe_info);
3036 next_tvb = tvb_new_subset(tvb,offset,length,-1);
3038 if (!dissector_try_port(ppp_subdissector_table, pid, next_tvb, pinfo, info_tree)) {
3039 call_dissector(data_handle, next_tvb, pinfo, info_tree);
3042 length_remaining -= length;
3043 } /* While length_remaining */
3052 dissect_mplscp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3054 dissect_cp(tvb, proto_mplscp, ett_mplscp, cp_vals, ett_mplscp_options,
3055 NULL, 0, pinfo, tree);
3059 * Cisco Discovery Protocol Control Protocol.
3060 * XXX - where is this documented?
3063 dissect_cdpcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3065 dissect_cp(tvb, proto_cdpcp, ett_cdpcp, cp_vals, ett_cdpcp_options,
3066 NULL, 0, pinfo, tree);
3069 #define MP_FRAG_MASK 0xC0
3070 #define MP_FRAG(bits) ((bits) & MP_FRAG_MASK)
3071 #define MP_FRAG_FIRST 0x80
3072 #define MP_FRAG_LAST 0x40
3073 #define MP_FRAG_RESERVED 0x3f
3075 static const true_false_string frag_truth = {
3080 /* According to RFC 1717, the length the MP header isn't indicated anywhere
3081 in the header itself. It starts out at four bytes and can be
3082 negotiated down to two using LCP. We currently assume that all
3083 headers are four bytes. - gcc
3086 dissect_mp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3088 proto_tree *mp_tree, *hdr_tree;
3089 proto_item *ti = NULL;
3091 const gchar *flag_str;
3094 if (check_col(pinfo->cinfo, COL_PROTOCOL))
3095 col_set_str(pinfo->cinfo, COL_PROTOCOL, "PPP MP");
3097 if (check_col(pinfo->cinfo, COL_INFO))
3098 col_set_str(pinfo->cinfo, COL_INFO, "PPP Multilink");
3100 flags = tvb_get_guint8(tvb, 0);
3110 case MP_FRAG_FIRST|MP_FRAG_LAST:
3111 flag_str = "First, Last";
3114 flag_str = "Unknown";
3117 ti = proto_tree_add_item(tree, proto_mp, tvb, 0, 4, FALSE);
3118 mp_tree = proto_item_add_subtree(ti, ett_mp);
3119 ti = proto_tree_add_text(mp_tree, tvb, 0, 1, "Fragment: 0x%2X (%s)",
3121 hdr_tree = proto_item_add_subtree(ti, ett_mp_flags);
3122 proto_tree_add_boolean(hdr_tree, hf_mp_frag_first, tvb, 0, 1, flags);
3123 proto_tree_add_boolean(hdr_tree, hf_mp_frag_last, tvb, 0, 1, flags),
3124 proto_tree_add_text(hdr_tree, tvb, 0, 1, "%s",
3125 decode_boolean_bitfield(flags, MP_FRAG_RESERVED, sizeof(flags) * 8,
3126 "reserved", "reserved"));
3127 proto_tree_add_item(mp_tree, hf_mp_sequence_num, tvb, 1, 3, FALSE);
3130 if (tvb_reported_length_remaining(tvb, 4) > 0) {
3131 next_tvb = tvb_new_subset(tvb, 4, -1, -1);
3132 dissect_ppp(next_tvb, pinfo, tree);
3137 * Handles PPP without HDLC framing, just a protocol field (RFC 1661).
3140 dissect_ppp( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree ) {
3141 proto_item *ti = NULL;
3142 proto_tree *fh_tree = NULL;
3145 ti = proto_tree_add_item(tree, proto_ppp, tvb, 0, -1, FALSE);
3146 fh_tree = proto_item_add_subtree(ti, ett_ppp);
3149 dissect_ppp_common(tvb, pinfo, tree, fh_tree, ti, 0);
3153 dissect_ppp_hdlc_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3155 proto_item *ti = NULL;
3156 proto_tree *fh_tree = NULL;
3161 byte0 = tvb_get_guint8(tvb, 0);
3163 /* PPP HDLC encapsulation */
3167 /* address and control are compressed (NULL) */
3171 /* load the top pane info. This should be overwritten by
3172 the next protocol in the stack */
3174 ti = proto_tree_add_item(tree, proto_ppp, tvb, 0, -1, FALSE);
3175 fh_tree = proto_item_add_subtree(ti, ett_ppp);
3176 if (byte0 == 0xff) {
3177 proto_tree_add_item(fh_tree, hf_ppp_address, tvb, 0, 1, FALSE);
3178 proto_tree_add_item(fh_tree, hf_ppp_control, tvb, 1, 1, FALSE);
3182 next_tvb = decode_fcs(tvb, fh_tree, ppp_fcs_decode, proto_offset);
3184 dissect_ppp_common(next_tvb, pinfo, tree, fh_tree, ti, proto_offset);
3188 * Handles link-layer encapsulations where the frame might be
3189 * a PPP in HDLC-like Framing frame (RFC 1662) or a Cisco HDLC frame.
3192 dissect_ppp_hdlc( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
3196 byte0 = tvb_get_guint8(tvb, 0);
3197 if (byte0 == CHDLC_ADDR_UNICAST || byte0 == CHDLC_ADDR_MULTICAST) {
3198 /* Cisco HDLC encapsulation */
3199 call_dissector(chdlc_handle, tvb, pinfo, tree);
3204 * XXX - should we have an exported dissector that always dissects PPP,
3205 * for use when we know the packets are PPP, not CHDLC?
3207 if(check_col(pinfo->cinfo, COL_PROTOCOL))
3208 col_set_str(pinfo->cinfo, COL_PROTOCOL, "PPP");
3209 switch (pinfo->p2p_dir) {
3212 if(check_col(pinfo->cinfo, COL_RES_DL_SRC))
3213 col_set_str(pinfo->cinfo, COL_RES_DL_SRC, "DTE");
3214 if(check_col(pinfo->cinfo, COL_RES_DL_DST))
3215 col_set_str(pinfo->cinfo, COL_RES_DL_DST, "DCE");
3219 if(check_col(pinfo->cinfo, COL_RES_DL_SRC))
3220 col_set_str(pinfo->cinfo, COL_RES_DL_SRC, "DCE");
3221 if(check_col(pinfo->cinfo, COL_RES_DL_DST))
3222 col_set_str(pinfo->cinfo, COL_RES_DL_DST, "DTE");
3226 if(check_col(pinfo->cinfo, COL_RES_DL_SRC))
3227 col_set_str(pinfo->cinfo, COL_RES_DL_SRC, "N/A");
3228 if(check_col(pinfo->cinfo, COL_RES_DL_DST))
3229 col_set_str(pinfo->cinfo, COL_RES_DL_DST, "N/A");
3233 dissect_ppp_hdlc_common(tvb, pinfo, tree);
3237 remove_escape_chars(tvbuff_t *tvb, int offset, int length)
3241 int scanned_len = 0;
3245 buff = g_malloc(length);
3247 while ( scanned_len < length ){
3248 octet = tvb_get_guint8(tvb,offset);
3252 if (scanned_len >= length)
3254 octet = tvb_get_guint8(tvb,offset);
3255 buff[i] = octet ^ 0x20;
3267 next_tvb = tvb_new_real_data(buff,i,i);
3269 /* Arrange that the allocated packet data copy be freed when the
3272 tvb_set_free_cb( next_tvb, g_free );
3274 tvb_set_child_real_data_tvbuff(tvb,next_tvb);
3280 * Handles link-layer encapsulations where we have a raw RFC 1662
3281 * HDLC-like asynchronous framing byte stream, and have to
3282 * break the byte stream into frames and remove escapes.
3285 dissect_ppp_raw_hdlc( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
3288 proto_tree *bs_tree = NULL;
3289 gint offset, end_offset, data_offset;
3290 int length, data_length;
3292 gboolean first = TRUE;
3294 if(check_col(pinfo->cinfo, COL_PROTOCOL))
3295 col_set_str(pinfo->cinfo, COL_PROTOCOL, "PPP" );
3298 ti = proto_tree_add_item(tree, proto_ppp_hdlc, tvb, 0, -1, FALSE);
3299 bs_tree = proto_item_add_subtree(ti, ett_ppp_hdlc_data);
3303 * XXX - this needs to handle a PPP frame split over multiple higher-level
3308 * Look for a frame delimiter.
3310 offset = tvb_find_guint8(tvb, 0, -1, 0x7e);
3313 * None found - this is presumably continued from an earlier
3314 * packet and continued in a later packet.
3316 if (check_col(pinfo->cinfo, COL_INFO)){
3317 col_add_str(pinfo->cinfo, COL_INFO,"PPP Fragment");
3320 proto_tree_add_text(bs_tree, tvb, offset, -1, "PPP Fragment");
3322 length = tvb_length_remaining(tvb,offset);
3323 ppp_tvb = remove_escape_chars(tvb, offset,length);
3324 if (ppp_tvb != NULL) {
3325 add_new_data_source(pinfo, ppp_tvb, "PPP Fragment");
3326 call_dissector(data_handle, ppp_tvb, pinfo, tree);
3332 * We have some data preceding the first PPP packet;
3333 * mark it as a PPP fragment.
3335 if(check_col(pinfo->cinfo, COL_INFO)){
3336 col_add_str(pinfo->cinfo, COL_INFO,"PPP Fragment");
3340 proto_tree_add_text(bs_tree, tvb, 0, length, "PPP Fragment");
3342 ppp_tvb = remove_escape_chars(tvb, 0, length - 1);
3343 if (ppp_tvb != NULL) {
3344 add_new_data_source(pinfo, ppp_tvb, "PPP Fragment");
3345 call_dissector(data_handle, ppp_tvb, pinfo, tree);
3349 while ( tvb_reported_length_remaining(tvb, offset) > 0 ){
3351 * Look for the next frame delimiter.
3353 end_offset = tvb_find_guint8(tvb, offset+1, -1, 0x7e);
3354 if ( end_offset == -1 ){
3356 * We didn't find one. This is probably continued in
3360 if(check_col(pinfo->cinfo, COL_INFO)){
3361 col_add_str(pinfo->cinfo, COL_INFO,"PPP Fragment");
3365 proto_tree_add_text(bs_tree, tvb, offset, -1, "PPP Fragment");
3367 length = tvb_length_remaining(tvb, offset);
3368 ppp_tvb = remove_escape_chars(tvb, offset,length);
3369 if (ppp_tvb != NULL) {
3370 add_new_data_source(pinfo, ppp_tvb, "PPP Fragment");
3371 call_dissector(data_handle, ppp_tvb, pinfo, tree);
3376 data_offset = offset+1; /* skip starting frame delimiter */
3377 data_length = end_offset - data_offset;
3380 * Is that frame delimiter immediately followed by another one?
3381 * Some PPP implementations put a frame delimiter at the
3382 * beginning and the end of each frame, although RFC 1662
3383 * appears only to require that there be one frame delimiter
3384 * between adjacent frames:
3386 * Each frame begins and ends with a Flag Sequence, which is the
3387 * binary sequence 01111110 (hexadecimal 0x7e). All implementations
3388 * continuously check for this flag, which is used for frame
3391 * Only one Flag Sequence is required between two frames. Two
3392 * consecutive Flag Sequences constitute an empty frame, which is
3393 * silently discarded, and not counted as a FCS error.
3395 * If the delimiter at the end of this frame is followed by
3396 * another delimiter, we consider the first delimiter part
3399 if (tvb_offset_exists(tvb, end_offset+1) &&
3400 tvb_get_guint8(tvb, end_offset+1) == 0x7e)
3402 length = end_offset - offset;
3404 proto_tree_add_text(bs_tree, tvb, offset, length, "PPP Data");
3406 ppp_tvb = remove_escape_chars(tvb, data_offset, data_length);
3407 if (ppp_tvb != NULL) {
3408 add_new_data_source(pinfo, ppp_tvb, "PPP Message");
3409 dissect_ppp_hdlc_common(ppp_tvb, pinfo, tree);
3413 offset = end_offset;
3418 proto_register_ppp_raw_hdlc(void)
3420 static gint *ett[] = {
3424 proto_ppp_hdlc = proto_register_protocol("PPP In HDLC-Like Framing", "PPP-HDLC", "ppp_hdlc");
3425 proto_register_subtree_array(ett, array_length(ett));
3429 proto_reg_handoff_ppp_raw_hdlc(void)
3431 dissector_handle_t ppp_raw_hdlc_handle;
3433 ppp_raw_hdlc_handle = create_dissector_handle(dissect_ppp_raw_hdlc, proto_ppp);
3434 dissector_add("gre.proto", ETHERTYPE_CDMA2000_A10_UBS, ppp_raw_hdlc_handle);
3438 * Handles PAP just as a protocol field
3441 dissect_pap( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree ) {
3443 proto_tree *fh_tree = NULL;
3445 proto_tree *field_tree;
3447 proto_tree *message_tree;
3449 proto_tree *peer_id_tree;
3451 proto_tree *passwd_tree;
3454 guint8 id, peer_id_length, password_length, msg_length;
3457 code = tvb_get_guint8(tvb, 0);
3458 id = tvb_get_guint8(tvb, 1);
3459 length = tvb_get_ntohs(tvb, 2);
3461 if(check_col(pinfo->cinfo, COL_PROTOCOL))
3462 col_set_str(pinfo->cinfo, COL_PROTOCOL, "PPP PAP");
3464 if(check_col(pinfo->cinfo, COL_INFO))
3465 col_add_str(pinfo->cinfo, COL_INFO,
3466 val_to_str(code, pap_vals, "Unknown"));
3469 ti = proto_tree_add_item(tree, proto_pap, tvb, 0, length, FALSE);
3470 fh_tree = proto_item_add_subtree(ti, ett_pap);
3471 proto_tree_add_text(fh_tree, tvb, 0, 1, "Code: %s (0x%02x)",
3472 val_to_str(code, pap_vals, "Unknown"), code);
3473 proto_tree_add_text(fh_tree, tvb, 1, 1, "Identifier: 0x%02x",
3475 proto_tree_add_text(fh_tree, tvb, 2, 2, "Length: %u",
3485 tf = proto_tree_add_text(fh_tree, tvb, offset, length,
3486 "Data (%d byte%s)", length, plurality(length, "", "s"));
3487 field_tree = proto_item_add_subtree(tf, ett_pap_data);
3488 peer_id_length = tvb_get_guint8(tvb, offset);
3489 tp = proto_tree_add_text(field_tree, tvb, offset, 1,
3490 "Peer ID length: %d byte%s", peer_id_length, plurality(peer_id_length, "", "s"));
3492 peer_id_tree = proto_item_add_subtree(tp, ett_pap_peer_id);
3493 proto_tree_add_text(peer_id_tree, tvb, ++offset, ppp_min(peer_id_length, length),
3494 "Peer-ID (%d byte%s)", peer_id_length, plurality(peer_id_length, "", "s"));
3495 offset+=peer_id_length;
3496 length-=peer_id_length;
3498 password_length = tvb_get_guint8(tvb, offset);
3500 tpw = proto_tree_add_text(field_tree, tvb, offset, 1,
3501 "Password length: %d byte%s", password_length, plurality(password_length, "", "s"));
3502 passwd_tree = proto_item_add_subtree(tpw, ett_pap_password);
3503 proto_tree_add_text(passwd_tree, tvb, ++offset, ppp_min(password_length, length),
3504 "Password (%d byte%s)", password_length, plurality(password_length, "", "s"));
3516 tf = proto_tree_add_text(fh_tree, tvb, offset, length,
3517 "Data (%d byte%s)", length, plurality(length, "", "s"));
3518 field_tree = proto_item_add_subtree(tf, ett_pap_data);
3519 msg_length = tvb_get_guint8(tvb, offset);
3520 tm = proto_tree_add_text(field_tree, tvb, offset, 1,
3521 "Message length: %d byte%s", msg_length, plurality(msg_length, "", "s"));
3523 message_tree = proto_item_add_subtree(tm, ett_pap_message);
3524 proto_tree_add_text(message_tree, tvb, ++offset, ppp_min(msg_length, length),
3525 "Message (%d byte%s)", msg_length, plurality(msg_length, "", "s"));
3532 proto_tree_add_text(fh_tree, tvb, offset, length, "Stuff (%d byte%s)",
3533 length, plurality(length, "", "s"));
3540 * Handles CHAP just as a protocol field
3543 dissect_chap( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree ) {
3544 proto_item *ti = NULL;
3545 proto_tree *fh_tree = NULL;
3547 proto_tree *field_tree;
3549 guint8 code, value_size;
3553 code = tvb_get_guint8(tvb, 0);
3554 if(check_col(pinfo->cinfo, COL_PROTOCOL))
3555 col_set_str(pinfo->cinfo, COL_PROTOCOL, "PPP CHAP");
3557 if(check_col(pinfo->cinfo, COL_INFO))
3558 col_add_str(pinfo->cinfo, COL_INFO,
3559 val_to_str(code, chap_vals, "Unknown"));
3562 /* Create CHAP protocol tree */
3563 ti = proto_tree_add_item(tree, proto_chap, tvb, 0, -1, FALSE);
3564 fh_tree = proto_item_add_subtree(ti, ett_chap);
3567 proto_tree_add_item(fh_tree, hf_chap_code, tvb, 0, 1, FALSE);
3570 proto_tree_add_item(fh_tree, hf_chap_identifier, tvb, 1, 1, FALSE);
3573 /* Length - make sure it's valid */
3574 length = tvb_get_ntohs(tvb, 2);
3577 proto_tree_add_uint_format(fh_tree, hf_chap_length, tvb, 2, 2, length,
3578 "Length: %u (invalid, must be >= 4)",
3583 proto_item_set_len(ti, length);
3585 proto_tree_add_item(fh_tree, hf_chap_length, tvb, 2, 2, FALSE);
3588 /* Offset moved to after length field */
3590 /* Length includes previous 4 bytes, subtract */
3594 /* Challenge or Response data */
3599 guint value_offset=0;
3600 guint name_offset=0, name_size = 0;
3602 /* Create data subtree */
3603 tf = proto_tree_add_text(fh_tree, tvb, offset, length,
3604 "Data (%d byte%s)", length,
3605 plurality(length, "", "s"));
3606 field_tree = proto_item_add_subtree(tf, ett_chap_data);
3610 value_size = tvb_get_guint8(tvb, offset);
3611 if (value_size > length) {
3612 proto_tree_add_text(field_tree, tvb, offset, 1,
3613 "Value Size: %d byte%s (invalid, must be <= %u)",
3614 value_size, plurality(value_size, "", "s"),
3618 proto_tree_add_item(field_tree, hf_chap_value_size, tvb, offset, 1, FALSE);
3623 value_offset = offset;
3624 proto_tree_add_item(field_tree, hf_chap_value, tvb, offset, value_size, FALSE);
3626 /* Move along value_size bytes */
3630 /* Find name in remaining bytes */
3632 tvb_ensure_bytes_exist(tvb, offset, length);
3633 proto_tree_add_item(field_tree, hf_chap_name, tvb, offset, length, FALSE);
3634 name_offset = offset;
3638 /* Show name and value in info column */
3639 if(check_col(pinfo->cinfo, COL_INFO)){
3640 col_append_fstr(pinfo->cinfo, COL_INFO, " (NAME='%s%s', VALUE=0x%s)",
3641 tvb_format_text(tvb, name_offset,
3642 (name_size > 20) ? 20 : name_size),
3643 (name_size > 20) ? "..." : "",
3644 tvb_bytes_to_str(tvb, value_offset, value_size));
3651 /* Success or Failure data */
3656 proto_tree_add_item(fh_tree, hf_chap_message, tvb, offset, length, FALSE);
3660 /* Show message in info column */
3661 if(check_col(pinfo->cinfo, COL_INFO)){
3662 col_append_fstr(pinfo->cinfo, COL_INFO, " (MESSAGE='%s')",
3663 tvb_format_text(tvb, offset, length));
3667 /* Code from unknown code type... */
3670 proto_tree_add_text(fh_tree, tvb, offset, length, "Stuff (%u byte%s)",
3671 length, plurality(length, "", "s"));
3680 dissect_ipv6cp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3682 dissect_cp(tvb, proto_ipv6cp, ett_ipv6cp, cp_vals, ett_ipv6cp_options,
3683 ipv6cp_opts, N_IPV6CP_OPTS, pinfo, tree);
3686 static void dissect_ipv6cp_if_id_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
3687 int offset, guint length, packet_info *pinfo _U_,
3690 proto_tree_add_text(tree, tvb, offset, length, "%s: %02x%02x:%02x%02x:%02x%x:%02x%02x",
3692 tvb_get_guint8(tvb, offset + 2),
3693 tvb_get_guint8(tvb, offset + 3),
3694 tvb_get_guint8(tvb, offset + 4),
3695 tvb_get_guint8(tvb, offset + 5),
3696 tvb_get_guint8(tvb, offset + 6),
3697 tvb_get_guint8(tvb, offset + 7),
3698 tvb_get_guint8(tvb, offset + 8),
3699 tvb_get_guint8(tvb, offset + 9)
3704 proto_register_ppp(void)
3706 static hf_register_info hf[] = {
3708 { "Address", "ppp.address", FT_UINT8, BASE_HEX,
3709 NULL, 0x0, "", HFILL }},
3712 { "Control", "ppp.control", FT_UINT8, BASE_HEX,
3713 NULL, 0x0, "", HFILL }},
3716 { "Protocol", "ppp.protocol", FT_UINT16, BASE_HEX,
3717 VALS(ppp_vals), 0x0, "", HFILL }},
3719 static gint *ett[] = {
3723 module_t *ppp_module;
3725 proto_ppp = proto_register_protocol("Point-to-Point Protocol", "PPP", "ppp");
3726 proto_register_field_array(proto_ppp, hf, array_length(hf));
3727 proto_register_subtree_array(ett, array_length(ett));
3729 /* subdissector code */
3730 ppp_subdissector_table = register_dissector_table("ppp.protocol",
3731 "PPP protocol", FT_UINT16, BASE_HEX);
3733 register_dissector("ppp_hdlc", dissect_ppp_hdlc, proto_ppp);
3734 register_dissector("ppp_lcp_options", dissect_lcp_options, proto_ppp);
3735 register_dissector("ppp", dissect_ppp, proto_ppp);
3737 /* Register the preferences for the ppp protocol */
3738 ppp_module = prefs_register_protocol(proto_ppp, NULL);
3740 prefs_register_enum_preference(ppp_module,
3742 "PPP Frame Checksum Type",
3743 "The type of PPP frame checksum (none, 16-bit, 32-bit)",
3745 fcs_options, FALSE);
3746 prefs_register_bool_preference(ppp_module,
3748 "Decompress Van Jacobson-compressed frames",
3749 "Whether Van Jacobson-compressed PPP frames should be decompressed",
3751 prefs_register_uint_preference(ppp_module,
3753 "PPPMuxCP Default PID",
3754 "Default Protocol ID to be used for PPPMuxCP",
3755 16, &pppmux_def_prot_id);
3759 proto_reg_handoff_ppp(void)
3761 dissector_handle_t ppp_hdlc_handle, ppp_handle;
3764 * Get a handle for the CHDLC dissector.
3766 chdlc_handle = find_dissector("chdlc");
3767 data_handle = find_dissector("data");
3769 ppp_handle = find_dissector("ppp");
3770 dissector_add("fr.ietf", NLPID_PPP, ppp_handle);
3772 ppp_hdlc_handle = find_dissector("ppp_hdlc");
3773 dissector_add("wtap_encap", WTAP_ENCAP_PPP, ppp_hdlc_handle);
3774 dissector_add("wtap_encap", WTAP_ENCAP_PPP_WITH_PHDR, ppp_hdlc_handle);
3775 dissector_add("osinl.excl", NLPID_PPP, ppp_handle);
3776 dissector_add("gre.proto", ETHERTYPE_PPP, ppp_hdlc_handle);
3780 proto_register_mp(void)
3782 static hf_register_info hf[] = {
3783 { &hf_mp_frag_first,
3784 { "First fragment", "mp.first", FT_BOOLEAN, 8,
3785 TFS(&frag_truth), MP_FRAG_FIRST, "", HFILL }},
3788 { "Last fragment", "mp.last", FT_BOOLEAN, 8,
3789 TFS(&frag_truth), MP_FRAG_LAST, "", HFILL }},
3791 { &hf_mp_sequence_num,
3792 { "Sequence number", "mp.seq", FT_UINT24, BASE_DEC, NULL, 0x0,
3795 static gint *ett[] = {
3800 proto_mp = proto_register_protocol("PPP Multilink Protocol", "PPP MP", "mp");
3801 proto_register_field_array(proto_mp, hf, array_length(hf));
3802 proto_register_subtree_array(ett, array_length(ett));
3806 proto_reg_handoff_mp(void)
3808 dissector_handle_t mp_handle;
3810 mp_handle = create_dissector_handle(dissect_mp, proto_mp);
3811 dissector_add("ppp.protocol", PPP_MP, mp_handle);
3815 proto_register_lcp(void)
3817 static gint *ett[] = {
3820 &ett_lcp_authprot_opt,
3821 &ett_lcp_qualprot_opt,
3822 &ett_lcp_fcs_alternatives_opt,
3823 &ett_lcp_numbered_mode_opt,
3824 &ett_lcp_callback_opt,
3825 &ett_lcp_multilink_ep_disc_opt,
3826 &ett_lcp_internationalization_opt,
3829 proto_lcp = proto_register_protocol("PPP Link Control Protocol", "PPP LCP",
3831 proto_register_subtree_array(ett, array_length(ett));
3835 proto_reg_handoff_lcp(void)
3837 dissector_handle_t lcp_handle;
3839 lcp_handle = create_dissector_handle(dissect_lcp, proto_lcp);
3840 dissector_add("ppp.protocol", PPP_LCP, lcp_handle);
3843 * NDISWAN on Windows translates Ethernet frames from higher-level
3844 * protocols into PPP frames to hand to the PPP driver, and translates
3845 * PPP frames from the PPP driver to hand to the higher-level protocols.
3847 * Apparently the PPP driver, on at least some versions of Windows,
3848 * passes frames for internal-to-PPP protocols up through NDISWAN;
3849 * the protocol type field appears to be passed through unchanged
3850 * (unlike what's done with, for example, the protocol type field
3851 * for IP, which is mapped from its PPP value to its Ethernet value).
3853 * This means that we may see, on Ethernet captures, frames for
3854 * protocols internal to PPP, so we register PPP_LCP with the
3855 * "ethertype" dissector table as well as the PPP protocol dissector
3858 dissector_add("ethertype", PPP_LCP, lcp_handle);
3861 * for GSM-A / MobileL3 / GPRS SM / PCO
3863 dissector_add("sm_pco.protocol", PPP_LCP, lcp_handle);
3868 proto_register_ipcp(void)
3870 static gint *ett[] = {
3873 &ett_ipcp_ipaddrs_opt,
3874 &ett_ipcp_compress_opt,
3877 proto_ipcp = proto_register_protocol("PPP IP Control Protocol", "PPP IPCP",
3879 proto_register_subtree_array(ett, array_length(ett));
3883 proto_reg_handoff_ipcp(void)
3885 dissector_handle_t ipcp_handle;
3887 ipcp_handle = create_dissector_handle(dissect_ipcp, proto_ipcp);
3888 dissector_add("ppp.protocol", PPP_IPCP, ipcp_handle);
3891 * See above comment about NDISWAN for an explanation of why we're
3892 * registering with the "ethertype" dissector table.
3894 dissector_add("ethertype", PPP_IPCP, ipcp_handle);
3897 * for GSM-A / MobileL3 / GPRS SM / PCO
3899 dissector_add("sm_pco.protocol", PPP_IPCP, ipcp_handle);
3904 proto_register_osicp(void)
3906 static gint *ett[] = {
3909 &ett_osicp_align_npdu_opt,
3912 proto_osicp = proto_register_protocol("PPP OSI Control Protocol", "PPP OSICP",
3914 proto_register_subtree_array(ett, array_length(ett));
3918 proto_reg_handoff_osicp(void)
3920 dissector_handle_t osicp_handle;
3922 osicp_handle = create_dissector_handle(dissect_osicp, proto_osicp);
3923 dissector_add("ppp.protocol", PPP_OSICP, osicp_handle);
3926 * See above comment about NDISWAN for an explanation of why we're
3927 * registering with the "ethertype" dissector table.
3929 dissector_add("ethertype", PPP_OSICP, osicp_handle);
3933 proto_register_ccp(void)
3935 static gint *ett[] = {
3940 &ett_ccp_bsdcomp_opt,
3941 &ett_ccp_lzsdcp_opt,
3943 &ett_ccp_deflate_opt,
3946 proto_ccp = proto_register_protocol("PPP Compression Control Protocol",
3948 proto_register_subtree_array(ett, array_length(ett));
3952 proto_reg_handoff_ccp(void)
3954 dissector_handle_t ccp_handle;
3956 ccp_handle = create_dissector_handle(dissect_ccp, proto_ccp);
3957 dissector_add("ppp.protocol", PPP_CCP, ccp_handle);
3960 * See above comment about NDISWAN for an explanation of why we're
3961 * registering with the "ethertype" dissector table.
3963 dissector_add("ethertype", PPP_CCP, ccp_handle);
3967 proto_register_cbcp(void)
3969 static gint *ett[] = {
3972 &ett_cbcp_callback_opt,
3973 &ett_cbcp_callback_opt_addr
3976 proto_cbcp = proto_register_protocol("PPP Callback Control Protocol",
3977 "PPP CBCP", "cbcp");
3978 proto_register_subtree_array(ett, array_length(ett));
3982 proto_reg_handoff_cbcp(void)
3984 dissector_handle_t cbcp_handle;
3986 cbcp_handle = create_dissector_handle(dissect_cbcp, proto_cbcp);
3987 dissector_add("ppp.protocol", PPP_CBCP, cbcp_handle);
3990 * See above comment about NDISWAN for an explanation of why we're
3991 * registering with the "ethertype" dissector table.
3993 dissector_add("ethertype", PPP_CBCP, cbcp_handle);
3997 proto_register_bacp(void)
3999 static gint *ett[] = {
4002 &ett_bacp_favored_peer_opt
4005 proto_bacp = proto_register_protocol("PPP Bandwidth Allocation Control Protocol",
4006 "PPP BACP", "bacp");
4007 proto_register_subtree_array(ett, array_length(ett));
4011 proto_reg_handoff_bacp(void)
4013 dissector_handle_t bacp_handle;
4015 bacp_handle = create_dissector_handle(dissect_bacp, proto_bacp);
4016 dissector_add("ppp.protocol", PPP_BACP, bacp_handle);
4019 * See above comment about NDISWAN for an explanation of why we're
4020 * registering with the "ethertype" dissector table.
4022 dissector_add("ethertype", PPP_BACP, bacp_handle);
4026 proto_register_bap(void)
4028 static gint *ett[] = {
4031 &ett_bap_link_type_opt,
4032 &ett_bap_phone_delta_opt,
4033 &ett_bap_phone_delta_subopt,
4034 &ett_bap_call_status_opt
4037 proto_bap = proto_register_protocol("PPP Bandwidth Allocation Protocol",
4039 proto_register_subtree_array(ett, array_length(ett));
4043 proto_reg_handoff_bap(void)
4045 dissector_handle_t bap_handle;
4047 bap_handle = create_dissector_handle(dissect_bap, proto_bap);
4048 dissector_add("ppp.protocol", PPP_BAP, bap_handle);
4051 * See above comment about NDISWAN for an explanation of why we're
4052 * registering with the "ethertype" dissector table.
4054 dissector_add("ethertype", PPP_BAP, bap_handle);
4058 proto_register_comp_data(void)
4060 static gint *ett[] = {
4064 proto_comp_data = proto_register_protocol("PPP Compressed Datagram",
4065 "PPP Comp", "comp_data");
4066 proto_register_subtree_array(ett, array_length(ett));
4070 proto_reg_handoff_comp_data(void)
4072 dissector_handle_t comp_data_handle;
4074 comp_data_handle = create_dissector_handle(dissect_comp_data,
4076 dissector_add("ppp.protocol", PPP_COMP, comp_data_handle);
4079 * See above comment about NDISWAN for an explanation of why we're
4080 * registering with the "ethertype" dissector table.
4082 dissector_add("ethertype", PPP_COMP, comp_data_handle);
4086 proto_register_pap(void)
4088 static gint *ett[] = {
4096 proto_pap = proto_register_protocol("PPP Password Authentication Protocol", "PPP PAP",
4098 proto_register_subtree_array(ett, array_length(ett));
4102 proto_reg_handoff_pap(void)
4104 dissector_handle_t pap_handle;
4106 pap_handle = create_dissector_handle(dissect_pap, proto_pap);
4107 dissector_add("ppp.protocol", PPP_PAP, pap_handle);
4110 * See above comment about NDISWAN for an explanation of why we're
4111 * registering with the "ethertype" dissector table.
4113 dissector_add("ethertype", PPP_PAP, pap_handle);
4116 * for GSM-A / MobileL3 / GPRS SM / PCO
4118 dissector_add("sm_pco.protocol", PPP_PAP, pap_handle);
4122 proto_register_chap(void)
4124 static gint *ett[] = {
4132 static hf_register_info hf[] =
4137 "Code", "chap.code",
4139 VALS(chap_vals), 0x0,
4144 &hf_chap_identifier,
4146 "Identifier", "chap.identifier",
4149 "CHAP identifier", HFILL
4155 "Length", "chap.length",
4156 FT_UINT16, BASE_DEC,
4158 "CHAP length", HFILL
4162 &hf_chap_value_size,
4164 "Value Size", "chap.value_size",
4167 "CHAP value size", HFILL
4173 "Value", "chap.value",
4174 FT_BYTES, BASE_NONE,
4176 "CHAP value data", HFILL
4182 "Name", "chap.name",
4183 FT_STRING, BASE_NONE,
4191 "Message", "chap.message",
4192 FT_STRING, BASE_NONE,
4194 "CHAP message", HFILL
4200 proto_chap = proto_register_protocol("PPP Challenge Handshake Authentication Protocol", "PPP CHAP",
4202 proto_register_field_array(proto_chap, hf, array_length(hf));
4203 proto_register_subtree_array(ett, array_length(ett));
4207 proto_reg_handoff_chap(void)
4209 dissector_handle_t chap_handle = create_dissector_handle(dissect_chap, proto_chap);
4210 dissector_add("ppp.protocol", PPP_CHAP, chap_handle);
4213 * See above comment about NDISWAN for an explanation of why we're
4214 * registering with the "ethertype" dissector table.
4216 dissector_add("ethertype", PPP_CHAP, chap_handle);
4219 * for GSM-A / MobileL3 / GPRS SM / PCO
4221 dissector_add("sm_pco.protocol", PPP_CHAP, chap_handle);
4225 proto_register_pppmuxcp(void)
4227 static gint *ett[] = {
4229 &ett_pppmuxcp_options,
4232 proto_pppmuxcp = proto_register_protocol("PPPMux Control Protocol",
4235 proto_register_subtree_array(ett, array_length(ett));
4240 proto_reg_handoff_pppmuxcp(void)
4242 dissector_handle_t muxcp_handle;
4244 muxcp_handle = create_dissector_handle(dissect_pppmuxcp, proto_pppmuxcp);
4245 dissector_add("ppp.protocol", PPP_MUXCP, muxcp_handle);
4248 * See above comment about NDISWAN for an explanation of why we're
4249 * registering with the "ethertype" dissector table.
4251 dissector_add("ethertype", PPP_MUXCP, muxcp_handle);
4256 proto_register_pppmux(void)
4258 static gint *ett[] = {
4260 &ett_pppmux_subframe,
4261 &ett_pppmux_subframe_hdr,
4262 &ett_pppmux_subframe_flags,
4263 &ett_pppmux_subframe_info,
4266 proto_pppmux = proto_register_protocol("PPP Multiplexing",
4269 proto_register_subtree_array(ett, array_length(ett));
4273 proto_reg_handoff_pppmux(void)
4275 dissector_handle_t pppmux_handle;
4277 pppmux_handle = create_dissector_handle(dissect_pppmux, proto_pppmux);
4278 dissector_add("ppp.protocol", PPP_MUX, pppmux_handle);
4281 * See above comment about NDISWAN for an explanation of why we're
4282 * registering with the "ethertype" dissector table.
4284 dissector_add("ethertype", PPP_MUX, pppmux_handle);
4288 proto_register_mplscp(void)
4290 static gint *ett[] = {
4292 &ett_mplscp_options,
4295 proto_mplscp = proto_register_protocol("PPP MPLS Control Protocol",
4296 "PPP MPLSCP", "mplscp");
4297 proto_register_subtree_array(ett, array_length(ett));
4301 proto_reg_handoff_mplscp(void)
4303 dissector_handle_t mplscp_handle;
4305 mplscp_handle = create_dissector_handle(dissect_mplscp, proto_mplscp);
4306 dissector_add("ppp.protocol", PPP_MPLSCP, mplscp_handle);
4309 * See above comment about NDISWAN for an explanation of why we're
4310 * registering with the "ethertype" dissector table.
4312 dissector_add("ethertype", PPP_MPLSCP, mplscp_handle);
4316 proto_register_cdpcp(void)
4318 static gint *ett[] = {
4323 proto_cdpcp = proto_register_protocol("PPP CDP Control Protocol",
4324 "PPP CDPCP", "cdpcp");
4325 proto_register_subtree_array(ett, array_length(ett));
4329 proto_reg_handoff_cdpcp(void)
4331 dissector_handle_t cdpcp_handle;
4333 cdpcp_handle = create_dissector_handle(dissect_cdpcp, proto_cdpcp);
4334 dissector_add("ppp.protocol", PPP_CDPCP, cdpcp_handle);
4337 * See above comment about NDISWAN for an explanation of why we're
4338 * registering with the "ethertype" dissector table.
4340 dissector_add("ethertype", PPP_CDPCP, cdpcp_handle);
4344 proto_register_ipv6cp(void)
4346 static gint *ett[] = {
4348 &ett_ipv6cp_options,
4349 &ett_ipv6cp_if_id_opt,
4350 &ett_ipv6cp_compress_opt,
4353 proto_ipv6cp = proto_register_protocol("PPP IPv6 Control Protocol",
4354 "PPP IPV6CP", "ipv6cp");
4355 proto_register_subtree_array(ett, array_length(ett));
4359 proto_reg_handoff_ipv6cp(void)
4361 dissector_handle_t ipv6cp_handle;
4363 ipv6cp_handle = create_dissector_handle(dissect_ipv6cp, proto_ipv6cp);
4364 dissector_add("ppp.protocol", PPP_IPV6CP, ipv6cp_handle);
4367 * See above comment about NDISWAN for an explanation of why we're
4368 * registering with the "ethertype" dissector table.
4370 dissector_add("ethertype", PPP_IPV6CP, ipv6cp_handle);