2 * Routines for Layer Two Tunnelling Protocol (L2TP) packet disassembly
3 * John Thomes <john@ensemblecom.com>
5 * Minor changes by: (2000-01-10)
6 * Laurent Cazalet <laurent.cazalet@mailclub.net>
7 * Thomas Parvais <thomas.parvais@advalvas.be>
11 * Wireshark - Network traffic analyzer
12 * By Gerald Combs <gerald@wireshark.org>
13 * Copyright 1998 Gerald Combs
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 * http://tools.ietf.org/html/rfc2661
35 * http://tools.ietf.org/html/rfc3931
37 * Layer Two Tunneling Protocol "L2TP" number assignments:
38 * http://www.iana.org/assignments/l2tp-parameters
42 * RFC 4591 for Frame Relay
43 * http://tools.ietf.org/html/rfc4591
46 * http://tools.ietf.org/html/rfc4454
48 * RFC 4719 for Ethernet
49 * http://tools.ietf.org/html/rfc4719
52 * http://tools.ietf.org/html/rfc4349
54 * XXX - what about LAPD?
57 static int proto_l2tp = -1;
58 static int hf_l2tp_type = -1;
59 static int hf_l2tp_length_bit = -1;
60 static int hf_l2tp_seq_bit = -1;
61 static int hf_l2tp_offset_bit = -1;
62 static int hf_l2tp_priority = -1;
63 static int hf_l2tp_version = -1;
64 static int hf_l2tp_length = -1;
65 static int hf_l2tp_tunnel = -1;
66 static int hf_l2tp_session = -1;
67 static int hf_l2tp_Ns = -1;
68 static int hf_l2tp_Nr = -1;
69 static int hf_l2tp_offset = -1;
70 static int hf_l2tp_avp_mandatory = -1;
71 static int hf_l2tp_avp_hidden = -1;
72 static int hf_l2tp_avp_length = -1;
73 static int hf_l2tp_avp_vendor_id = -1;
74 static int hf_l2tp_avp_type = -1;
75 static int hf_l2tp_tie_breaker = -1;
76 static int hf_l2tp_sid = -1;
77 static int hf_l2tp_res = -1;
78 static int hf_l2tp_ccid = -1;
79 static int hf_l2tp_cookie = -1;
80 static int hf_l2tp_l2_spec_def = -1;
81 static int hf_l2tp_l2_spec_atm = -1;
82 static int hf_l2tp_l2_spec_docsis_dmpt = -1;
83 static int hf_l2tp_l2_spec_v = -1;
84 static int hf_l2tp_l2_spec_s = -1;
85 static int hf_l2tp_l2_spec_flow_id = -1;
86 static int hf_l2tp_l2_spec_sequence = -1;
87 static int hf_l2tp_l2_spec_t = -1;
88 static int hf_l2tp_l2_spec_g = -1;
89 static int hf_l2tp_l2_spec_c = -1;
90 static int hf_l2tp_l2_spec_u = -1;
91 static int hf_l2tp_cisco_avp_type = -1;
100 #include <epan/packet.h>
101 #include <epan/addr_resolv.h>
102 #include <epan/ipproto.h>
103 #include <epan/sminmpec.h>
104 #include <epan/prefs.h>
106 #define UDP_PORT_L2TP 1701
108 #define CONTROL_BIT(msg_info) (msg_info & 0x8000) /* Type bit control = 1 data = 0 */
109 #define LENGTH_BIT(msg_info) (msg_info & 0x4000) /* Length bit = 1 */
110 #define RESERVE_BITS(msg_info) (msg_info &0x37F8) /* Reserved bit - usused */
111 #define SEQUENCE_BIT(msg_info) (msg_info & 0x0800) /* SEQUENCE bit = 1 Ns and Nr fields */
112 #define OFFSET_BIT(msg_info) (msg_info & 0x0200) /* Offset */
113 #define PRIORITY_BIT(msg_info) (msg_info & 0x0100) /* Priority */
114 #define L2TP_VERSION(msg_info) (msg_info & 0x000f) /* Version of l2tp */
115 #define MANDATORY_BIT(msg_info) (msg_info & 0x8000) /* Mandatory = 1 */
116 #define HIDDEN_BIT(msg_info) (msg_info & 0x4000) /* Hidden = 1 */
117 #define AVP_LENGTH(msg_info) (msg_info & 0x03ff) /* AVP Length */
118 #define FRAMING_SYNC(msg_info) (msg_info & 0x0001) /* SYNC Framing Type */
119 #define FRAMING_ASYNC(msg_info) (msg_info & 0x0002) /* ASYNC Framing Type */
120 #define BEARER_DIGITAL(msg_info) (msg_info & 0x0001) /* Digital Bearer Type */
121 #define BEARER_ANALOG(msg_info) (msg_info & 0x0002) /* Analog Bearer Type */
122 #define CIRCUIT_STATUS_BIT(msg_info) (msg_info & 0x0001) /* Circuit Status */
123 #define CIRCUIT_TYPE_BIT(msg_info) (msg_info & 0x0001) /* Circuit Condition */
125 /* DOCSIS DMPT Sub-Layer Header definitions */
126 #define FLOW_ID_MASK 0x0E
128 static gint ett_l2tp = -1;
129 static gint ett_l2tp_ctrl = -1;
130 static gint ett_l2tp_avp = -1;
131 static gint ett_l2tp_avp_sub = -1;
132 static gint ett_l2tp_lcp = -1;
133 static gint ett_l2tp_l2_spec = -1;
135 static enum_val_t l2tpv3_cookies[] = {
136 {"cookie0", "None", 0},
137 {"cookie4", "4 Byte Cookie", 4},
138 {"cookie8", "8 Byte Cookie", 8},
142 #define L2TPv3_PROTOCOL_ETH 0
143 #define L2TPv3_PROTOCOL_CHDLC 1
144 #define L2TPv3_PROTOCOL_FR 2
145 #define L2TPv3_PROTOCOL_PPP 3
146 #define L2TPv3_PROTOCOL_IP 4
147 #define L2TPv3_PROTOCOL_MPLS 5
148 #define L2TPv3_PROTOCOL_AAL5 6
149 #define L2TPv3_PROTOCOL_LAPD 7
150 #define L2TPv3_PROTOCOL_DOCSIS_DMPT 8
152 static enum_val_t l2tpv3_protocols[] = {
153 {"eth", "Ethernet", L2TPv3_PROTOCOL_ETH},
154 {"chdlc", "Cisco HDLC", L2TPv3_PROTOCOL_CHDLC},
155 {"fr", "Frame Relay", L2TPv3_PROTOCOL_FR},
156 {"ppp", "PPP", L2TPv3_PROTOCOL_PPP},
157 {"ip", "IP", L2TPv3_PROTOCOL_IP},
158 {"mpls", "MPLS", L2TPv3_PROTOCOL_MPLS},
159 {"aal5", "AAL5", L2TPv3_PROTOCOL_AAL5},
160 {"lapd", "LAPD", L2TPv3_PROTOCOL_LAPD},
161 {"docsis-dmpt", "DOCSIS-DMPT", L2TPv3_PROTOCOL_DOCSIS_DMPT},
165 #define L2TPv3_L2_SPECIFIC_NONE 0
166 #define L2TPv3_L2_SPECIFIC_DEFAULT 1
167 #define L2TPv3_L2_SPECIFIC_ATM 2
168 #define L2TPv3_L2_SPECIFIC_LAPD 3
169 #define L2TPv3_L2_SPECIFIC_DOCSIS_DMPT 4
171 static enum_val_t l2tpv3_l2_specifics[] = {
172 {"none", "None", L2TPv3_L2_SPECIFIC_NONE},
173 {"default", "Default L2-Specific", L2TPv3_L2_SPECIFIC_DEFAULT},
174 {"atm", "ATM-Specific", L2TPv3_L2_SPECIFIC_ATM},
175 {"lapd", "LAPD-Specific", L2TPv3_L2_SPECIFIC_LAPD},
176 {"dmpt", "DOCSIS DMPT-Specific", L2TPv3_L2_SPECIFIC_DOCSIS_DMPT},
180 static gint l2tpv3_cookie = 4;
181 static gint l2tpv3_protocol = L2TPv3_PROTOCOL_CHDLC;
182 static gint l2tpv3_l2_specific = L2TPv3_L2_SPECIFIC_DEFAULT;
187 #define AVP_StopCCN 4
188 #define AVP_Reserved 5
196 #define AVP_Reserved1 13
199 #define NUM_CONTROL_CALL_TYPES 27
200 static const char *calltypestr[NUM_CONTROL_CALL_TYPES+1] = {
202 "Start_Control_Request",
203 "Start_Control_Reply",
204 "Start_Control_Connected",
205 "Stop_Control_Notification",
208 "Outgoing_Call_Request",
209 "Outgoing_Call_Reply",
210 "Outgoing_Call_Connected",
211 "Incoming_Call_Request", /* 10 */
212 "Incoming_Call_Reply",
213 "Incoming_Call_Connected",
215 "Call_Disconnect_Notification",
216 "WAN_Error_Notify", /* 15 */
219 "Service_Relay_Request_Msg",
220 "Service_Relay_Reply_Message",
221 "Explicit_Acknowledgement", /* 20 */
222 "Failover_Session_Query_Message", /* 21 [RFC4951] */
223 "Failover_Session_Response_Message", /* 22 [RFC4951] */
224 /* Multicast Management */
225 "Multicast-Session-Request", /* 23 [RFC4045]*/
226 "Multicast-Session-Response ", /* 24 [RFC4045]*/
227 "Multicast-Session-Establishment", /* 25 [RFC4045]*/
228 "Multicast-Session-Information", /* 26 [RFC4045]*/
229 "Multicast-Session-End-Notify", /* 27 [RFC4045]*/
233 static const char *calltype_short_str[NUM_CONTROL_CALL_TYPES+1] = {
266 static const char *control_msg = "Control Message";
267 static const char *data_msg = "Data Message";
268 static const value_string l2tp_type_vals[] = {
269 { 0, "Data Message" },
270 { 1, "Control Message" },
274 static const value_string cause_code_direction_vals[] = {
275 { 0, "global error" },
281 static const true_false_string l2tp_length_bit_truth =
282 { "Length field is present", "Length field is not present" };
284 static const true_false_string l2tp_seq_bit_truth =
285 { "Ns and Nr fields are present", "Ns and Nr fields are not present" };
287 static const true_false_string l2tp_offset_bit_truth =
288 { "Offset Size field is present", "Offset size field is not present" };
290 static const true_false_string l2tp_priority_truth =
291 { "This data message has priority", "No priority" };
293 static const value_string authen_type_vals[] = {
295 { 1, "Textual username/password exchange" },
298 { 4, "No Authentication" },
299 { 5, "Microsoft CHAP Version 1" },
305 static const value_string data_sequencing_vals[] = {
306 { 0, "No incoming data packets require sequencing" },
307 { 1, "Only non-IP data packets require sequencing" },
308 { 2, "All incoming data packets require sequencing" },
312 static const value_string l2_sublayer_vals[] = {
313 { 0, "No L2-Specific Sublayer" },
314 { 1, "Default L2-Specific Sublayer present" },
315 { 2, "ATM-Specific Sublayer present" },
316 { 3, "MPT-Specific Sublayer" },
317 { 4, "PSP-Specific Sublayer" },
321 static const value_string result_code_stopccn_vals[] = {
323 { 1, "General request to clear control connection", },
324 { 2, "General error, Error Code indicates the problem", },
325 { 3, "Control connection already exists", },
326 { 4, "Requester is not authorized to establish a control connection", },
327 { 5, "The protocol version of the requester is not supported", },
328 { 6, "Requester is being shut down", },
329 { 7, "Finite state machine error or timeout", },
330 { 8, "Control connection due to mismatching CCDS value", }, /* [RFC3308] */
334 static const value_string result_code_cdn_vals[] = {
336 { 1, "Session disconnected due to loss of carrier or circuit disconnect", },
337 { 2, "Session disconnected for the reason indicated in Error Code", },
338 { 3, "Session disconnected for administrative reasons", },
339 { 4, "Appropriate facilities unavailable (temporary condition)", },
340 { 5, "Appropriate facilities unavailable (permanent condition)", },
341 { 6, "Invalid destination", },
342 { 7, "Call failed due to no carrier detected", },
343 { 8, "Call failed due to detection of a busy signal", },
344 { 9, "Call failed due to lack of a dial tone", },
345 { 10, "Call was not established within time allotted by LAC", },
346 { 11, "Call was connected but no appropriate framing was detected", },
347 { 12, "Disconnecting call due to mismatching SDS value", },
348 { 13, "Session not established due to losing tie breaker", },
349 { 14, "Session not established due to unsupported PW type", },
350 { 15, "Session not established, sequencing required without valid L2-Specific Sublayer", },
351 { 16, "Finite state machine error or timeout", },
352 { 17, "FR PVC was deleted permanently (no longer provisioned) ", }, /* [RFC4591] */
353 { 18, "FR PVC has been INACTIVE for an extended period of time", }, /* [RFC4591] */
354 { 19, "Mismatched FR Header Length", }, /* [RFC4591] */
355 { 20, "HDLC Link was deleted permanently (no longer provisioned)", }, /* [RFC4349] */
356 { 21, "HDLC Link has been INACTIVE for an extended period of time", }, /* [RFC4349] */
357 { 22, "Session not established due to other LCCE can not support the OAM Cell Emulation", }, /* [RFC4454] */
358 { 23, "Mismatching interface MTU", }, /* [RFC4667] */
359 { 24, "Attempt to connect to non-existent forwarder", }, /* [RFC4667] */
360 { 25, "Attempt to connect to unauthorized forwarder", }, /* [RFC4667] */
361 { 26, "Loop Detected", }, /* [draft-ietf-l2tpext-tunnel-switching-06.txt] */
367 static const value_string error_code_vals[] = {
368 { 0, "No General Error", },
369 { 1, "No control connection exists yet for this pair of LCCEs", },
370 { 2, "Length is wrong", },
371 { 3, "One of the field values was out of range", },
372 { 4, "Insufficient resources to handle this operation now", },
373 { 5, "Invalid Session ID", },
374 { 6, "A generic vendor-specific error occurred", },
375 { 7, "Try another", },
376 { 8, "Receipt of an unknown AVP with the M bit set", },
377 { 9, "Try another directed", },
378 { 10, "Next hop unreachable", },
379 { 11, "Next hop busy", },
384 #define CONTROL_MESSAGE 0
385 #define RESULT_ERROR_CODE 1
386 #define PROTOCOL_VERSION 2
387 #define FRAMING_CAPABILITIES 3
388 #define BEARER_CAPABILITIES 4
389 #define TIE_BREAKER 5
390 #define FIRMWARE_REVISION 6
392 #define VENDOR_NAME 8
393 #define ASSIGNED_TUNNEL_ID 9
394 #define RECEIVE_WINDOW_SIZE 10
396 #define CAUSE_CODE 12
397 #define CHALLENGE_RESPONSE 13
398 #define ASSIGNED_SESSION 14
399 #define CALL_SERIAL_NUMBER 15
400 #define MINIMUM_BPS 16
401 #define MAXIMUM_BPS 17
402 #define BEARER_TYPE 18
403 #define FRAMING_TYPE 19
404 #define CALLED_NUMBER 21
405 #define CALLING_NUMBER 22
406 #define SUB_ADDRESS 23
407 #define TX_CONNECT_SPEED 24
408 #define PHYSICAL_CHANNEL 25
409 #define INITIAL_RECEIVED_LCP_CONFREQ 26
410 #define LAST_SENT_LCP_CONFREQ 27
411 #define LAST_RECEIVED_LCP_CONFREQ 28
412 #define PROXY_AUTHEN_TYPE 29
413 #define PROXY_AUTHEN_NAME 30
414 #define PROXY_AUTHEN_CHALLENGE 31
415 #define PROXY_AUTHEN_ID 32
416 #define PROXY_AUTHEN_RESPONSE 33
417 #define CALL_STATUS_AVPS 34
419 #define RANDOM_VECTOR 36
420 #define PRIVATE_GROUP_ID 37
421 #define RX_CONNECT_SPEED 38
422 #define SEQUENCING_REQUIRED 39
423 #define PPP_DISCONNECT_CAUSE_CODE 46 /* RFC 3145 */
424 #define EXTENDED_VENDOR_ID 58
425 #define MESSAGE_DIGEST 59
427 #define ASSIGNED_CONTROL_CONN_ID 61
428 #define PW_CAPABILITY_LIST 62
429 #define LOCAL_SESSION_ID 63
430 #define REMOTE_SESSION_ID 64
431 #define ASSIGNED_COOKIE 65
432 #define REMOTE_END_ID 66
434 #define L2_SPECIFIC_SUBLAYER 69
435 #define DATA_SEQUENCING 70
436 #define CIRCUIT_STATUS 71
437 #define PREFERRED_LANGUAGE 72
438 #define CTL_MSG_AUTH_NONCE 73
439 #define TX_CONNECT_SPEED_V3 74
440 #define RX_CONNECT_SPEED_V3 75
442 #define NUM_AVP_TYPES 96
443 static const value_string avp_type_vals[] = {
444 { CONTROL_MESSAGE, "Control Message" },
445 { RESULT_ERROR_CODE, "Result-Error Code" },
446 { PROTOCOL_VERSION, "Protocol Version" },
447 { FRAMING_CAPABILITIES, "Framing Capabilities" },
448 { BEARER_CAPABILITIES, "Bearer Capabilities" },
449 { TIE_BREAKER, "Tie Breaker" },
450 { FIRMWARE_REVISION, "Firmware Revision" },
451 { HOST_NAME, "Host Name" },
452 { VENDOR_NAME, "Vendor Name" },
453 { ASSIGNED_TUNNEL_ID, "Assigned Tunnel ID" },
454 { RECEIVE_WINDOW_SIZE, "Receive Window Size" },
455 { CHALLENGE, "Challenge" },
456 { CAUSE_CODE, "Cause Code" },
457 { CHALLENGE_RESPONSE, "Challenge Response" },
458 { ASSIGNED_SESSION, "Assigned Session" },
459 { CALL_SERIAL_NUMBER, "Call Serial Number" },
460 { MINIMUM_BPS, "Minimum BPS" },
461 { MAXIMUM_BPS, "Maximum BPS" },
462 { BEARER_TYPE, "Bearer Type" },
463 { FRAMING_TYPE, "Framing Type" },
464 { CALLED_NUMBER, "Called Number" },
465 { CALLING_NUMBER, "Calling Number" },
466 { SUB_ADDRESS, "Sub-Address" },
467 { TX_CONNECT_SPEED, "Connect Speed" },
468 { PHYSICAL_CHANNEL, "Physical Channel" },
469 { INITIAL_RECEIVED_LCP_CONFREQ, "Initial Received LCP CONFREQ" },
470 { LAST_SENT_LCP_CONFREQ, "Last Sent LCP CONFREQ" },
471 { LAST_RECEIVED_LCP_CONFREQ, "Last Received LCP CONFREQ" },
472 { PROXY_AUTHEN_TYPE, "Proxy Authen Type" },
473 { PROXY_AUTHEN_NAME, "Proxy Authen Name" },
474 { PROXY_AUTHEN_CHALLENGE, "Proxy Authen Challenge" },
475 { PROXY_AUTHEN_ID, "Proxy Authen ID" },
476 { PROXY_AUTHEN_RESPONSE, "Proxy Authen Response" },
477 { CALL_STATUS_AVPS, "Call status AVPs" },
479 { RANDOM_VECTOR, "Random Vector" },
480 { PRIVATE_GROUP_ID, "Private group ID" },
481 { RX_CONNECT_SPEED, "RxConnect Speed" },
482 { SEQUENCING_REQUIRED, "Sequencing Required" },
483 { PPP_DISCONNECT_CAUSE_CODE, "PPP Disconnect Cause Code" },
484 { EXTENDED_VENDOR_ID, "Extended Vendor ID" },
485 { MESSAGE_DIGEST, "Message Digest" },
486 { ROUTER_ID, "Router ID" },
487 { ASSIGNED_CONTROL_CONN_ID, "Assigned Control Connection ID" },
488 { PW_CAPABILITY_LIST, "Pseudowire Capability List" },
489 { LOCAL_SESSION_ID, "Local Session ID" },
490 { REMOTE_SESSION_ID, "Remote Session ID" },
491 { ASSIGNED_COOKIE, "Assigned Cookie" },
492 { REMOTE_END_ID, "Remote End ID" },
493 { PW_TYPE, "Pseudowire Type" },
494 { L2_SPECIFIC_SUBLAYER, "Layer2 Specific Sublayer" },
495 { DATA_SEQUENCING, "Data Sequencing" },
496 { CIRCUIT_STATUS, "Circuit Status" },
497 { PREFERRED_LANGUAGE, "Preferred Language" },
498 { CTL_MSG_AUTH_NONCE, "Control Message Authentication Nonce" },
499 { TX_CONNECT_SPEED_V3, "Tx Connect Speed Version 3" },
500 { RX_CONNECT_SPEED_V3, "Rx Connect Speed Version 3" },
501 { 76, "Failover Capability" }, /*[RFC4951] */
502 { 77, "Tunnel Recovery" }, /*[RFC4951] */
503 { 78, "Suggested Control Sequence" }, /*[RFC4951] */
504 { 79, "Failover Session State" }, /*[RFC4951] */
505 { 80, "Multicast Capability" }, /*[RFC4045] */
506 { 81, "New Outgoing Sessions" }, /*[RFC4045] */
507 { 82, "New Outgoing Sessions Acknowledgement" }, /*[RFC4045] */
508 { 83, "Withdraw Outgoing Sessions" }, /*[RFC4045] */
509 { 84, "Multicast Packets Priority" }, /*[RFC4045] */
510 { 85, "Frame-Relay Header Length" }, /*[RFC4591] */
511 { 86, "ATM Maximum Concatenated Cells AVP" }, /*[RFC4454] */
512 { 87, "OAM Emulation Required AVP" }, /*[RFC4454] */
513 { 88, "ATM Alarm Status AVP" }, /*[RFC4454] */
514 /* Also, see ATM Alarm Status AVP Values below */
515 { 89, "Attachment Group Identifier" }, /*[RFC4667] */
516 { 90, "Local End Identifier" }, /*[RFC4667] */
517 { 91, "Interface Maximum Transmission Unit" }, /*[RFC4667] */
518 { 92, "FCS Retention" }, /*[RFC4720] */
519 { 93, "Tunnel Switching Aggregator ID AVP" }, /*[draft-ietf-l2tpext-tunnel-switching-06.txt] */
520 { 94, "Maximum Receive Unit (MRU) AVP" }, /*[RFC4623] */
521 { 95, "Maximum Reassembled Receive Unit (MRRU) AVP" }, /*[RFC4623] */
527 #define CISCO_ASSIGNED_CONNECTION_ID 1
528 #define CISCO_PW_CAPABILITY_LIST 2
529 #define CISCO_LOCAL_SESSION_ID 3
530 #define CISCO_REMOTE_SESSION_ID 4
531 #define CISCO_ASSIGNED_COOKIE 5
532 #define CISCO_REMOTE_END_ID 6
533 #define CISCO_PW_TYPE 7
534 #define CISCO_CIRCUIT_STATUS 8
535 #define CISCO_SESSION_TIE_BREAKER 9
536 #define CISCO_DRAFT_AVP_VERSION 10
537 #define CISCO_MESSAGE_DIGEST 12
538 #define CISCO_AUTH_NONCE 13
539 #define CISCO_INTERFACE_MTU 14
541 static const value_string cisco_avp_type_vals[] = {
542 { CISCO_ASSIGNED_CONNECTION_ID, "Assigned Connection ID" },
543 { CISCO_PW_CAPABILITY_LIST, "Pseudowire Capabilities List" },
544 { CISCO_LOCAL_SESSION_ID, "Local Session ID" },
545 { CISCO_REMOTE_SESSION_ID, "Remote Session ID" },
546 { CISCO_ASSIGNED_COOKIE, "Assigned Cookie" },
547 { CISCO_REMOTE_END_ID, "Remote End ID" },
548 { CISCO_PW_TYPE, "Pseudowire Type" },
549 { CISCO_CIRCUIT_STATUS, "Circuit Status" },
550 { CISCO_SESSION_TIE_BREAKER, "Session Tie Breaker" },
551 { CISCO_DRAFT_AVP_VERSION, "Draft AVP Version" },
552 { CISCO_MESSAGE_DIGEST, "Message Digest" },
553 { CISCO_AUTH_NONCE, "Control Message Authentication Nonce" },
554 { CISCO_INTERFACE_MTU, "Interface MTU" },
558 static const value_string pw_types_vals[] = {
559 { 0x0001, "Frame Relay DLCI" },
560 { 0x0002, "ATM AAL5 SDU VCC transport" },
561 { 0x0003, "ATM Cell transparent Port Mode" },
562 { 0x0004, "Ethernet VLAN" },
563 { 0x0005, "Ethernet" },
566 { 0x0009, "ATM Cell transport VCC Mode" },
567 { 0x000A, "ATM Cell transport VPC Mode" },
568 { 0x000B, "IP Transport" },
569 { 0x000C, "MPEG-TS Payload Type (MPTPW)" },
570 { 0x000D, "Packet Streaming Protocol (PSPPW)" },
574 static dissector_handle_t ppp_hdlc_handle;
575 static dissector_handle_t ppp_lcp_options_handle;
577 static dissector_handle_t eth_withoutfcs_handle;
578 static dissector_handle_t chdlc_handle;
579 static dissector_handle_t fr_handle;
580 static dissector_handle_t ip_handle;
581 static dissector_handle_t mpls_handle;
582 static dissector_handle_t atm_oam_handle;
583 static dissector_handle_t llc_handle;
584 static dissector_handle_t lapd_handle;
585 static dissector_handle_t mp2t_handle;
586 static dissector_handle_t data_handle;
589 * Processes AVPs for Control Messages all versions and transports
591 static void process_control_avps(tvbuff_t *tvb,
593 proto_tree *l2tp_tree,
597 proto_tree *l2tp_lcp_avp_tree, *l2tp_avp_tree, *l2tp_avp_tree_sub;
601 gboolean isStopCcn = FALSE;
603 guint32 avp_vendor_id;
605 guint16 ver_len_hidden;
611 guint16 firmware_rev;
613 while (idx < length) { /* Process AVP's */
614 ver_len_hidden = tvb_get_ntohs(tvb, idx);
615 avp_len = AVP_LENGTH(ver_len_hidden);
616 avp_vendor_id = tvb_get_ntohs(tvb, idx + 2);
617 avp_type = tvb_get_ntohs(tvb, idx + 4);
620 proto_tree_add_text(l2tp_tree, tvb, idx, 0,
621 "AVP length must be >= 1");
625 if (avp_vendor_id == VENDOR_IETF) {
626 tf = proto_tree_add_text(l2tp_tree, tvb, idx,
628 val_to_str(avp_type, avp_type_vals, "Unknown (%u)"));
629 } else if (avp_vendor_id == VENDOR_CISCO) { /* Vendor-Specific AVP */
630 tf = proto_tree_add_text(l2tp_tree, tvb, idx,
631 avp_len, "Vendor %s: %s AVP",
632 val_to_str_ext(avp_vendor_id, &sminmpec_values_ext, "Unknown (%u)"),
633 val_to_str(avp_type, cisco_avp_type_vals, "Unknown (%u)"));
634 } else { /* Vendor-Specific AVP */
635 tf = proto_tree_add_text(l2tp_tree, tvb, idx,
636 avp_len, "Vendor %s AVP Type %u",
637 val_to_str_ext(avp_vendor_id, &sminmpec_values_ext, "Unknown (%u)"),
642 l2tp_avp_tree = proto_item_add_subtree(tf, ett_l2tp_avp);
644 proto_tree_add_boolean_format(l2tp_avp_tree,hf_l2tp_avp_mandatory, tvb, idx, 1,
645 rhcode, "Mandatory: %s",
646 (MANDATORY_BIT(ver_len_hidden)) ? "True" : "False" );
647 proto_tree_add_boolean_format(l2tp_avp_tree,hf_l2tp_avp_hidden, tvb, idx, 1,
648 rhcode, "Hidden: %s",
649 (HIDDEN_BIT(ver_len_hidden)) ? "True" : "False" );
650 proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_avp_length, tvb, idx, 2,
651 rhcode, "Length: %u", avp_len);
652 if (HIDDEN_BIT(ver_len_hidden)) { /* don't try do display hidden */
658 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 0,
659 "AVP length must be >= 6");
665 /* Special Case for handling Extended Vendor Id */
666 if (avp_type == EXTENDED_VENDOR_ID) {
669 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_vendor_id,
672 avp_vendor_id = tvb_get_ntohl(tvb, idx);
679 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_vendor_id,
685 if (avp_vendor_id == VENDOR_CISCO) {
686 proto_tree_add_uint(l2tp_avp_tree, hf_l2tp_cisco_avp_type,
687 tvb, idx, 2, avp_type);
691 /* For the time being, we don't decode any Vendor-
694 case CISCO_ASSIGNED_CONNECTION_ID:
695 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 4,
696 "Assigned Control Connection ID: %u",
697 tvb_get_ntohl(tvb, idx));
700 case CISCO_PW_CAPABILITY_LIST:
701 te = proto_tree_add_text(l2tp_avp_tree, tvb, idx, avp_len,
702 "Pseudowire Capabilities List");
703 l2tp_avp_tree_sub = proto_item_add_subtree(te, ett_l2tp_avp_sub);
704 while (avp_len >= 2) {
705 int pw_type = tvb_get_ntohs(tvb, idx);
707 proto_tree_add_text(l2tp_avp_tree_sub, tvb, idx,
708 2, "PW Type: (%u) %s",
710 val_to_str(pw_type, pw_types_vals,
711 "Unknown (0x%04x)"));
717 case CISCO_LOCAL_SESSION_ID:
718 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 4,
719 "Local Session ID: %u",
720 tvb_get_ntohl(tvb, idx));
722 case CISCO_REMOTE_SESSION_ID:
723 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 4,
724 "Remote Session ID: %u",
725 tvb_get_ntohl(tvb, idx));
727 case CISCO_ASSIGNED_COOKIE:
728 proto_tree_add_text(l2tp_avp_tree, tvb, idx, avp_len,
729 "Assigned Cookie: %s",
730 tvb_bytes_to_str(tvb, idx, avp_len));
732 case CISCO_REMOTE_END_ID:
733 proto_tree_add_text(l2tp_avp_tree, tvb, idx, avp_len,
735 tvb_format_text(tvb, idx, avp_len));
738 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 2,
739 "Pseudowire Type: %u - %s",
740 tvb_get_ntohs(tvb, idx),
741 val_to_str(tvb_get_ntohs(tvb, idx),
742 pw_types_vals, "Unknown (0x%04x)"));
744 case CISCO_CIRCUIT_STATUS:
745 bits = tvb_get_ntohs(tvb, idx);
746 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 2,
747 "Circuit Status: %s",
748 (CIRCUIT_STATUS_BIT(bits)) ? "Up" : "Down");
749 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 2,
751 (CIRCUIT_TYPE_BIT(bits)) ? "New" : "Existing");
753 case CISCO_SESSION_TIE_BREAKER:
754 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_tie_breaker,
757 case CISCO_DRAFT_AVP_VERSION:
758 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 2,
759 "Draft AVP Version: %u",
760 tvb_get_ntohs(tvb, idx));
762 case CISCO_MESSAGE_DIGEST:
763 proto_tree_add_text(l2tp_avp_tree, tvb, idx, avp_len,
764 "Message Digest: %s",
765 tvb_bytes_to_str(tvb, idx, avp_len));
767 case CISCO_AUTH_NONCE:
768 proto_tree_add_text(l2tp_avp_tree, tvb, idx, avp_len,
770 tvb_bytes_to_str(tvb, idx, avp_len));
772 case CISCO_INTERFACE_MTU:
773 proto_tree_add_text(l2tp_avp_tree, tvb, idx, avp_len,
775 tvb_get_ntohs(tvb, idx));
779 proto_tree_add_text(l2tp_avp_tree, tvb, idx,
780 avp_len, "Vendor-Specific AVP");
785 } else if (avp_vendor_id != VENDOR_IETF) {
787 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 2,
788 "Type: %u", avp_type);
792 proto_tree_add_text(l2tp_avp_tree, tvb, idx,
793 avp_len, "Vendor-Specific AVP");
800 proto_tree_add_uint(l2tp_avp_tree, hf_l2tp_avp_type,
801 tvb, idx, 2, avp_type);
807 case CONTROL_MESSAGE:
808 msg_type = tvb_get_ntohs(tvb, idx);
809 proto_tree_add_text(l2tp_avp_tree,tvb, idx, 2,
810 "Control Message Type: (%u) %s", msg_type,
811 ((NUM_CONTROL_CALL_TYPES + 1 ) > msg_type) ?
812 calltypestr[msg_type] : "Unknown");
814 if (msg_type == AVP_StopCCN) {
819 case RESULT_ERROR_CODE:
822 result_code = tvb_get_ntohs(tvb, idx);
824 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 2,
825 "Result code: %u - %s", result_code,
826 val_to_str(result_code, result_code_stopccn_vals, "Unknown (%u)"));
829 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 2,
830 "Result code: %u - %s", result_code,
831 val_to_str(result_code, result_code_cdn_vals, "Unknown (%u)"));
838 error_code = tvb_get_ntohs(tvb, idx);
839 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 2,
840 "Error code: %u - %s", error_code,
841 val_to_str(error_code, error_code_vals, "Unknown (%u)"));
847 proto_tree_add_text(l2tp_avp_tree, tvb, idx, avp_len,
849 tvb_format_text(tvb, idx, avp_len));
852 case PROTOCOL_VERSION:
855 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 1,
856 "Version: %u", tvb_get_guint8(tvb, idx));
860 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 1,
861 "Revision: %u", tvb_get_guint8(tvb, idx));
864 case FRAMING_CAPABILITIES:
865 bits = tvb_get_ntohl(tvb, idx);
866 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 4,
867 "Async Framing Supported: %s",
868 (FRAMING_ASYNC(bits)) ? "True" : "False");
869 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 4,
870 "Sync Framing Supported: %s",
871 (FRAMING_SYNC(bits)) ? "True" : "False");
874 case BEARER_CAPABILITIES:
875 bits = tvb_get_ntohl(tvb, idx);
876 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 4,
877 "Analog Access Supported: %s",
878 (BEARER_ANALOG(bits)) ? "True" : "False");
879 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 4,
880 "Digital Access Supported: %s",
881 (BEARER_DIGITAL(bits)) ? "True" : "False");
885 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_tie_breaker, tvb, idx, 8, FALSE);
888 case FIRMWARE_REVISION:
889 firmware_rev = tvb_get_ntohs(tvb, idx);
890 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 2,
891 "Firmware Revision: %d 0x%x", firmware_rev,firmware_rev );
895 proto_tree_add_text(l2tp_avp_tree, tvb, idx, avp_len,
897 tvb_format_text(tvb, idx, avp_len));
901 proto_tree_add_text(l2tp_avp_tree, tvb, idx, avp_len,
903 tvb_format_text(tvb, idx, avp_len));
906 case ASSIGNED_TUNNEL_ID:
907 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 2,
908 "Tunnel ID: %u", tvb_get_ntohs(tvb, idx));
911 case RECEIVE_WINDOW_SIZE:
912 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 2,
913 "Receive Window Size: %u",
914 tvb_get_ntohs(tvb, idx));
918 proto_tree_add_text(l2tp_avp_tree, tvb, idx, avp_len,
919 "CHAP Challenge: %s",
920 tvb_bytes_to_str(tvb, idx, avp_len));
925 * XXX - export stuff from the Q.931 dissector
926 * to dissect the cause code and cause message,
931 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 2,
933 tvb_get_ntohs(tvb, idx));
939 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 1,
941 tvb_get_guint8(tvb, idx));
947 proto_tree_add_text(l2tp_avp_tree, tvb, idx, avp_len,
949 tvb_format_text(tvb, idx, avp_len));
952 case CHALLENGE_RESPONSE:
953 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 16,
954 "CHAP Challenge Response: %s",
955 tvb_bytes_to_str(tvb, idx, 16));
958 case ASSIGNED_SESSION:
959 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 2,
960 "Assigned Session: %u",
961 tvb_get_ntohs(tvb, idx));
964 case CALL_SERIAL_NUMBER:
965 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 4,
966 "Call Serial Number: %u",
967 tvb_get_ntohl(tvb, idx));
971 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 4,
973 tvb_get_ntohl(tvb, idx));
977 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 4,
979 tvb_get_ntohl(tvb, idx));
983 bits = tvb_get_ntohl(tvb, idx);
984 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 4,
985 "Analog Bearer Type: %s",
986 (BEARER_ANALOG(bits)) ? "True" : "False");
987 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 4,
988 "Digital Bearer Type: %s",
989 (BEARER_DIGITAL(bits)) ? "True" : "False");
993 bits = tvb_get_ntohl(tvb, idx);
994 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 4,
995 "Async Framing Type: %s",
996 (FRAMING_ASYNC(bits)) ? "True" : "False");
997 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 4,
998 "Sync Framing Type: %s",
999 (FRAMING_SYNC(bits)) ? "True" : "False");
1005 proto_tree_add_text(l2tp_avp_tree, tvb, idx, avp_len,
1006 "Called Number: %s",
1007 tvb_format_text(tvb, idx, avp_len));
1010 case CALLING_NUMBER:
1013 proto_tree_add_text(l2tp_avp_tree, tvb, idx, avp_len,
1014 "Calling Number: %s",
1015 tvb_format_text(tvb, idx, avp_len));
1021 proto_tree_add_text(l2tp_avp_tree, tvb, idx, avp_len,
1023 tvb_format_text(tvb, idx, avp_len));
1026 case TX_CONNECT_SPEED:
1027 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 4,
1028 "Connect Speed: %u",
1029 tvb_get_ntohl(tvb, idx));
1032 case PHYSICAL_CHANNEL:
1033 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 4,
1034 "Physical Channel: %u",
1035 tvb_get_ntohl(tvb, idx));
1038 case INITIAL_RECEIVED_LCP_CONFREQ:
1039 te = proto_tree_add_text(l2tp_avp_tree, tvb, idx, avp_len,
1040 "Initial Received LCP CONFREQ: %s",
1041 tvb_bytes_to_str(tvb, idx, avp_len));
1042 l2tp_lcp_avp_tree = proto_item_add_subtree(te, ett_l2tp_lcp);
1043 next_tvb = tvb_new_subset(tvb, idx, avp_len, avp_len);
1044 call_dissector(ppp_lcp_options_handle, next_tvb, pinfo, l2tp_lcp_avp_tree );
1047 case LAST_SENT_LCP_CONFREQ:
1048 te = proto_tree_add_text(l2tp_avp_tree, tvb, idx, avp_len,
1049 "Last Sent LCP CONFREQ: %s",
1050 tvb_bytes_to_str(tvb, idx, avp_len));
1051 l2tp_lcp_avp_tree = proto_item_add_subtree(te, ett_l2tp_lcp);
1052 next_tvb = tvb_new_subset(tvb, idx, avp_len, avp_len);
1053 call_dissector(ppp_lcp_options_handle, next_tvb, pinfo, l2tp_lcp_avp_tree );
1056 case LAST_RECEIVED_LCP_CONFREQ:
1057 te = proto_tree_add_text(l2tp_avp_tree, tvb, idx, avp_len,
1058 "Last Received LCP CONFREQ: %s",
1059 tvb_bytes_to_str(tvb, idx, avp_len));
1060 l2tp_lcp_avp_tree = proto_item_add_subtree(te, ett_l2tp_lcp);
1061 next_tvb = tvb_new_subset(tvb, idx, avp_len, avp_len);
1062 call_dissector(ppp_lcp_options_handle, next_tvb, pinfo, l2tp_lcp_avp_tree );
1065 case PROXY_AUTHEN_TYPE:
1066 msg_type = tvb_get_ntohs(tvb, idx);
1067 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 2,
1068 "Proxy Authen Type: %s",
1069 val_to_str(msg_type, authen_type_vals, "Unknown (%u)"));
1072 case PROXY_AUTHEN_NAME:
1075 proto_tree_add_text(l2tp_avp_tree, tvb, idx, avp_len,
1076 "Proxy Authen Name: %s",
1077 tvb_format_text(tvb, idx, avp_len));
1080 case PROXY_AUTHEN_CHALLENGE:
1081 proto_tree_add_text(l2tp_avp_tree, tvb, idx, avp_len,
1082 "Proxy Authen Challenge: %s",
1083 tvb_bytes_to_str(tvb, idx, avp_len));
1086 case PROXY_AUTHEN_ID:
1087 proto_tree_add_text(l2tp_avp_tree, tvb, idx + 1, 1,
1088 "Proxy Authen ID: %u",
1089 tvb_get_guint8(tvb, idx + 1));
1092 case PROXY_AUTHEN_RESPONSE:
1093 proto_tree_add_text(l2tp_avp_tree, tvb, idx, avp_len,
1094 "Proxy Authen Response: %s",
1095 tvb_bytes_to_str(tvb, idx, avp_len));
1098 case CALL_STATUS_AVPS:
1106 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 4,
1107 "CRC Errors: %u", tvb_get_ntohl(tvb, idx));
1113 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 4,
1114 "Framing Errors: %u", tvb_get_ntohl(tvb, idx));
1120 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 4,
1121 "Hardware Overruns: %u", tvb_get_ntohl(tvb, idx));
1127 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 4,
1128 "Buffer Overruns: %u", tvb_get_ntohl(tvb, idx));
1134 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 4,
1135 "Time-out Errors: %u", tvb_get_ntohl(tvb, idx));
1141 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 4,
1142 "Alignment Errors: %u", tvb_get_ntohl(tvb, idx));
1155 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 4,
1156 "Send ACCM: %u", tvb_get_ntohl(tvb, idx));
1162 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 4,
1163 "Receive ACCM: %u", tvb_get_ntohl(tvb, idx));
1169 proto_tree_add_text(l2tp_avp_tree, tvb, idx, avp_len,
1170 "Random Vector: %s",
1171 tvb_bytes_to_str(tvb, idx, avp_len));
1174 case PRIVATE_GROUP_ID:
1175 proto_tree_add_text(l2tp_avp_tree, tvb, idx, avp_len,
1176 "Private Group ID: %s",
1177 tvb_bytes_to_str(tvb, idx, avp_len));
1180 case RX_CONNECT_SPEED:
1181 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 4,
1182 "Rx Connect Speed: %u",
1183 tvb_get_ntohl(tvb, idx));
1186 case PPP_DISCONNECT_CAUSE_CODE:
1189 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 2,
1190 "Disconnect Code: %u",
1191 tvb_get_ntohs(tvb, idx));
1197 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 2,
1198 "Control Protocol Number: %u",
1199 tvb_get_ntohs(tvb, idx));
1205 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 1,
1207 val_to_str(tvb_get_guint8(tvb, idx),
1208 cause_code_direction_vals,
1215 proto_tree_add_text(l2tp_avp_tree, tvb, idx, avp_len,
1217 tvb_format_text(tvb, idx, avp_len));
1220 case MESSAGE_DIGEST:
1221 proto_tree_add_text(l2tp_avp_tree, tvb, idx, avp_len,
1222 "Message Digest: %s",
1223 tvb_bytes_to_str(tvb, idx, avp_len));
1226 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 4,
1228 tvb_get_ntohl(tvb, idx));
1230 case ASSIGNED_CONTROL_CONN_ID:
1231 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 4,
1232 "Assigned Control Connection ID: %u",
1233 tvb_get_ntohl(tvb, idx));
1235 case PW_CAPABILITY_LIST:
1236 te = proto_tree_add_text(l2tp_avp_tree, tvb, idx, avp_len,
1237 "Pseudowire Capabilities List");
1238 l2tp_avp_tree_sub = proto_item_add_subtree(te, ett_l2tp_avp_sub);
1240 while (avp_len >= 2) {
1241 int pw_type = tvb_get_ntohs(tvb, idx);
1242 proto_tree_add_text(l2tp_avp_tree_sub, tvb, idx,
1243 2, "PW Type: (%u) %s",
1245 val_to_str(pw_type, pw_types_vals,
1246 "Unknown (0x%04x)"));
1251 case LOCAL_SESSION_ID:
1252 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 4,
1253 "Local Session ID: %u",
1254 tvb_get_ntohl(tvb, idx));
1256 case REMOTE_SESSION_ID:
1257 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 4,
1258 "Remote Session ID: %u",
1259 tvb_get_ntohl(tvb, idx));
1261 case ASSIGNED_COOKIE:
1262 proto_tree_add_text(l2tp_avp_tree, tvb, idx, avp_len,
1263 "Assigned Cookie: %s",
1264 tvb_bytes_to_str(tvb, idx, avp_len));
1267 proto_tree_add_text(l2tp_avp_tree, tvb, idx, avp_len,
1268 "Remote End ID: %s",
1269 tvb_format_text(tvb, idx, avp_len));
1272 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 2,
1273 "Pseudowire Type: %u - %s",
1274 tvb_get_ntohs(tvb, idx),
1275 val_to_str(tvb_get_ntohs(tvb, idx),
1276 pw_types_vals, "Unknown (0x%04x)"));
1278 case L2_SPECIFIC_SUBLAYER:
1279 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 2,
1280 "Layer2 Specific Sublayer: %s",
1281 val_to_str(tvb_get_ntohs(tvb, idx),
1282 l2_sublayer_vals, "Invalid (%u)"));
1284 case DATA_SEQUENCING:
1285 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 2,
1286 "Data Sequencing: %s",
1287 val_to_str(tvb_get_ntohs(tvb, idx),
1288 data_sequencing_vals, "Invalid (%u)"));
1290 case CIRCUIT_STATUS:
1291 bits = tvb_get_ntohs(tvb, idx);
1292 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 2,
1293 "Circuit Status: %s",
1294 (CIRCUIT_STATUS_BIT(bits)) ? "Up" : "Down");
1295 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 2,
1297 (CIRCUIT_TYPE_BIT(bits)) ? "New" : "Existing");
1299 case PREFERRED_LANGUAGE:
1300 proto_tree_add_text(l2tp_avp_tree, tvb, idx, avp_len,
1301 "Preferred Language: %s",
1302 tvb_format_text(tvb, idx, avp_len));
1304 case CTL_MSG_AUTH_NONCE:
1305 proto_tree_add_text(l2tp_avp_tree, tvb, idx, avp_len,
1307 tvb_bytes_to_str(tvb, idx, avp_len));
1309 case TX_CONNECT_SPEED_V3:
1311 guint32 l_int, h_int;
1315 h_int = tvb_get_ntohl(tvb, idx);
1316 l_int = tvb_get_ntohl(tvb, idx+4);
1317 if (!h_int && !l_int) {
1318 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 8,
1319 "Tx Connect Speed v3: indeterminable or no physical p2p link");
1322 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 8,
1323 "Tx Connect Speed v3: %#x%04x",
1328 case RX_CONNECT_SPEED_V3:
1330 guint32 l_int, h_int;
1334 h_int = tvb_get_ntohl(tvb, idx);
1335 l_int = tvb_get_ntohl(tvb, idx+4);
1336 if (!h_int && !l_int) {
1337 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 8,
1338 "Rx Connect Speed v3: indeterminable or no physical p2p link");
1341 proto_tree_add_text(l2tp_avp_tree, tvb, idx, 8,
1342 "Rx Connect Speed v3: %#x%04x",
1348 proto_tree_add_text(l2tp_avp_tree, tvb, idx, avp_len,
1359 * Processes Data Messages for v3 IP and UDP, starting from the Session ID
1360 * (common to IP and UDP). Dissects the L2TPv3 Session header, the (optional)
1361 * L2-Specific sublayer and calls the appropriate dissector for the payload.
1364 process_l2tpv3_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
1365 proto_tree *l2tp_tree, proto_item *l2tp_item, int *pIdx)
1369 guint8 oam_cell = 0;
1370 proto_tree *l2_specific = NULL;
1371 proto_item *ti = NULL;
1374 /* Get Session ID */
1375 sid = tvb_get_ntohl(tvb, idx);
1378 if (check_col(pinfo->cinfo, COL_INFO)) {
1379 col_add_fstr(pinfo->cinfo,COL_INFO,
1380 "%s (session id=%u)",
1385 proto_tree_add_item(l2tp_tree, hf_l2tp_sid, tvb, idx-4, 4, FALSE);
1386 proto_item_set_len(l2tp_item, idx);
1387 if (!(tvb_offset_exists(tvb, idx)))
1389 if (l2tpv3_cookie != 0)
1390 proto_tree_add_item(l2tp_tree, hf_l2tp_cookie, tvb, idx, l2tpv3_cookie, FALSE);
1393 switch(l2tpv3_l2_specific){
1394 case L2TPv3_L2_SPECIFIC_DEFAULT:
1396 ti = proto_tree_add_item(tree, hf_l2tp_l2_spec_def,
1397 tvb, idx + l2tpv3_cookie, 4, FALSE);
1398 l2_specific = proto_item_add_subtree(ti, ett_l2tp_l2_spec);
1400 proto_tree_add_item(l2_specific, hf_l2tp_l2_spec_s, tvb, idx + l2tpv3_cookie,
1402 proto_tree_add_item(l2_specific, hf_l2tp_l2_spec_sequence, tvb,
1403 idx + l2tpv3_cookie + 1, 3, FALSE);
1405 next_tvb = tvb_new_subset_remaining(tvb, idx + l2tpv3_cookie + 4);
1407 case L2TPv3_L2_SPECIFIC_DOCSIS_DMPT:
1409 ti = proto_tree_add_item(tree, hf_l2tp_l2_spec_docsis_dmpt,
1410 tvb, idx + l2tpv3_cookie, 4, FALSE);
1411 l2_specific = proto_item_add_subtree(ti, ett_l2tp_l2_spec);
1413 proto_tree_add_item(l2_specific, hf_l2tp_l2_spec_v, tvb,
1414 idx + l2tpv3_cookie,1, FALSE);
1416 proto_tree_add_item(l2_specific, hf_l2tp_l2_spec_s, tvb,
1417 idx + l2tpv3_cookie,1, FALSE);
1419 proto_tree_add_item(l2_specific, hf_l2tp_l2_spec_flow_id, tvb,
1420 idx + l2tpv3_cookie,1, FALSE);
1422 proto_tree_add_item(l2_specific, hf_l2tp_l2_spec_sequence, tvb,
1423 idx + l2tpv3_cookie + 2,2, FALSE);
1425 next_tvb = tvb_new_subset_remaining(tvb, idx + l2tpv3_cookie + 4);
1427 case L2TPv3_L2_SPECIFIC_ATM:
1429 ti = proto_tree_add_item(tree, hf_l2tp_l2_spec_atm,
1430 tvb, idx + l2tpv3_cookie, 4, FALSE);
1431 l2_specific = proto_item_add_subtree(ti, ett_l2tp_l2_spec);
1433 proto_tree_add_item(l2_specific, hf_l2tp_l2_spec_s, tvb, idx + l2tpv3_cookie,
1435 proto_tree_add_item(l2_specific, hf_l2tp_l2_spec_t, tvb, idx + l2tpv3_cookie,
1438 * As per RFC 4454, the T bit specifies whether
1439 * we're transporting an OAM cell or an AAL5 frame.
1441 oam_cell = tvb_get_guint8(tvb, idx + l2tpv3_cookie) & 0x08;
1442 proto_tree_add_item(l2_specific, hf_l2tp_l2_spec_g, tvb, idx + l2tpv3_cookie,
1444 proto_tree_add_item(l2_specific, hf_l2tp_l2_spec_c, tvb, idx + l2tpv3_cookie,
1446 proto_tree_add_item(l2_specific, hf_l2tp_l2_spec_u, tvb, idx + l2tpv3_cookie,
1448 proto_tree_add_item(l2_specific, hf_l2tp_l2_spec_sequence, tvb,
1449 idx + l2tpv3_cookie + 1, 3, FALSE);
1451 next_tvb = tvb_new_subset_remaining(tvb, idx + l2tpv3_cookie + 4);
1453 case L2TPv3_L2_SPECIFIC_LAPD:
1455 proto_tree_add_text(tree, tvb, idx + l2tpv3_cookie + 4, 3,"LAPD info");
1456 next_tvb = tvb_new_subset_remaining(tvb, idx + l2tpv3_cookie+4+3);
1458 case L2TPv3_L2_SPECIFIC_NONE:
1460 next_tvb = tvb_new_subset_remaining(tvb, idx + l2tpv3_cookie);
1464 switch(l2tpv3_protocol){
1465 case L2TPv3_PROTOCOL_ETH:
1466 call_dissector(eth_withoutfcs_handle, next_tvb, pinfo, tree);
1468 case L2TPv3_PROTOCOL_CHDLC:
1469 call_dissector(chdlc_handle, next_tvb, pinfo, tree);
1471 case L2TPv3_PROTOCOL_FR:
1472 call_dissector(fr_handle, next_tvb, pinfo, tree);
1474 case L2TPv3_PROTOCOL_PPP:
1476 * PPP is transported without Address and Control
1477 * fields, ppp_hdlc_handle can handle that as if if
1478 * was ACFC (NULL Address and Control)
1480 call_dissector(ppp_hdlc_handle, next_tvb, pinfo, tree);
1482 case L2TPv3_PROTOCOL_IP:
1483 call_dissector(ip_handle, next_tvb, pinfo, tree);
1485 case L2TPv3_PROTOCOL_MPLS:
1486 call_dissector(mpls_handle, next_tvb, pinfo, tree);
1488 case L2TPv3_PROTOCOL_DOCSIS_DMPT:
1489 call_dissector(mp2t_handle, next_tvb, pinfo, tree);
1491 case L2TPv3_PROTOCOL_AAL5:
1493 call_dissector(atm_oam_handle, next_tvb, pinfo, tree);
1495 call_dissector(llc_handle, next_tvb, pinfo, tree);
1498 case L2TPv3_PROTOCOL_LAPD:
1499 call_dissector(lapd_handle, next_tvb, pinfo, tree);
1502 call_dissector(data_handle, next_tvb, pinfo, tree);
1508 * Processes v3 data message over UDP, to then call process_l2tpv3_data
1509 * from the common part (Session ID)
1512 process_l2tpv3_data_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1514 proto_tree *l2tp_tree = NULL, *ctrl_tree;
1515 proto_item *l2tp_item = NULL, *ti;
1521 control = tvb_get_ntohs(tvb, idx);
1522 idx += 2; /* skip ahead */
1523 idx += 2; /* Skip the reserved */
1524 sid = tvb_get_ntohl(tvb, idx);
1527 l2tp_item = proto_tree_add_item(tree, proto_l2tp, tvb, 0, -1, FALSE);
1528 l2tp_tree = proto_item_add_subtree(l2tp_item, ett_l2tp);
1529 proto_item_append_text(l2tp_item, " version 3");
1531 ti = proto_tree_add_text(l2tp_tree, tvb, 0, 2,
1532 "Packet Type: %s Session Id=%u",
1535 ctrl_tree = proto_item_add_subtree(ti, ett_l2tp_ctrl);
1536 proto_tree_add_uint(ctrl_tree, hf_l2tp_type, tvb, 0, 2, control);
1537 proto_tree_add_boolean(ctrl_tree, hf_l2tp_length_bit, tvb, 0, 2, control);
1538 proto_tree_add_boolean(ctrl_tree, hf_l2tp_seq_bit, tvb, 0, 2, control);
1539 proto_tree_add_uint(ctrl_tree, hf_l2tp_version, tvb, 0, 2, control);
1540 /* Data in v3 over UDP has this reserved */
1541 proto_tree_add_item(l2tp_tree, hf_l2tp_res, tvb, 2, 2, FALSE);
1544 /* Call process_l2tpv3_data from Session ID (offset in idx of 4) */
1545 process_l2tpv3_data(tvb, pinfo, tree, l2tp_tree, l2tp_item, &idx);
1549 * Processes v3 data message over IP, to then call process_l2tpv3_data
1550 * from the common part (Session ID)
1553 process_l2tpv3_data_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1555 proto_tree *l2tp_tree = NULL;
1556 proto_item *l2tp_item = NULL, *ti;
1561 sid = tvb_get_ntohl(tvb, idx);
1564 l2tp_item = proto_tree_add_item(tree, proto_l2tp, tvb, 0, -1, FALSE);
1565 l2tp_tree = proto_item_add_subtree(l2tp_item, ett_l2tp);
1566 proto_item_append_text(l2tp_item, " version 3");
1568 ti = proto_tree_add_text(l2tp_tree, tvb, 0, 4,
1569 "Packet Type: %s Session Id=%u",
1573 /* Call process_l2tpv3_data from Session ID (offset in idx of 0) */
1574 process_l2tpv3_data(tvb, pinfo, tree, l2tp_tree, l2tp_item, &idx);
1578 * Processes v3 Control Message over IP, that carries NULL Session ID
1579 * to then call process_control_avps after dissecting the control.
1582 process_l2tpv3_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int baseIdx)
1584 proto_tree *l2tp_tree=NULL, *ctrl_tree;
1585 proto_item *l2tp_item = NULL, *ti;
1589 guint16 length = 0; /* Length field */
1590 guint32 ccid = 0; /* Control Connection ID */
1593 guint16 control = 0;
1595 control = tvb_get_ntohs(tvb, idx);
1596 idx += 2; /* skip ahead */
1597 if (LENGTH_BIT(control)) { /* length field included ? */
1598 length = tvb_get_ntohs(tvb, idx);
1602 /* Get Control Channel ID */
1603 ccid = tvb_get_ntohl(tvb, idx);
1606 if (check_col(pinfo->cinfo, COL_INFO)) {
1609 if ((LENGTH_BIT(control))&&(length==12)) /* ZLB Message */
1610 col_add_fstr(pinfo->cinfo, COL_INFO,
1611 "%s - ZLB (tunnel id=%u)",
1612 control_msg , ccid);
1615 if (SEQUENCE_BIT(control)) {
1621 avp_type = tvb_get_ntohs(tvb, tmp_idx);
1624 if (avp_type == CONTROL_MESSAGE) {
1625 /* We print message type */
1626 msg_type = tvb_get_ntohs(tvb, tmp_idx);
1628 col_add_fstr(pinfo->cinfo, COL_INFO,
1629 "%s - %s (tunnel id=%u)",
1631 ((NUM_CONTROL_CALL_TYPES + 1 ) > msg_type) ?
1632 calltype_short_str[msg_type] : "Unknown",
1637 * This is not a control message.
1638 * We never pass here except in case of bad l2tp packet!
1640 col_add_fstr(pinfo->cinfo, COL_INFO,
1641 "%s (tunnel id=%u)",
1647 if (LENGTH_BIT(control)) {
1649 * Set the length of this tvbuff to be no longer than the length
1652 * XXX - complain if that length is longer than the length of
1653 * the tvbuff? Have "set_actual_length()" return a Boolean
1654 * and have its callers check the result?
1656 set_actual_length(tvb, length+baseIdx);
1660 l2tp_item = proto_tree_add_item(tree, proto_l2tp, tvb, 0, -1, FALSE);
1661 l2tp_tree = proto_item_add_subtree(l2tp_item, ett_l2tp);
1662 proto_item_append_text(l2tp_item, " version 3");
1665 proto_tree_add_item(l2tp_tree, hf_l2tp_sid, tvb, 0, 4, FALSE);
1667 ti = proto_tree_add_text(l2tp_tree, tvb, baseIdx, 2,
1668 "Packet Type: %s Control Connection Id=%d",
1669 (CONTROL_BIT(control) ? control_msg : data_msg), ccid);
1671 ctrl_tree = proto_item_add_subtree(ti, ett_l2tp_ctrl);
1672 proto_tree_add_uint(ctrl_tree, hf_l2tp_type, tvb, baseIdx, 2, control);
1673 proto_tree_add_boolean(ctrl_tree, hf_l2tp_length_bit, tvb, baseIdx, 2, control);
1674 proto_tree_add_boolean(ctrl_tree, hf_l2tp_seq_bit, tvb, baseIdx, 2, control);
1675 proto_tree_add_uint(ctrl_tree, hf_l2tp_version, tvb, baseIdx, 2, control);
1678 if (LENGTH_BIT(control)) {
1680 proto_tree_add_item(l2tp_tree, hf_l2tp_length, tvb, idx, 2, FALSE);
1686 proto_tree_add_item(l2tp_tree, hf_l2tp_ccid, tvb, idx, 4, FALSE);
1690 if (SEQUENCE_BIT(control)) {
1692 proto_tree_add_item(l2tp_tree, hf_l2tp_Ns, tvb, idx, 2, FALSE);
1696 proto_tree_add_item(l2tp_tree, hf_l2tp_Nr, tvb, idx, 2, FALSE);
1701 if (tree && (LENGTH_BIT(control))&&(length==12)) {
1702 proto_tree_add_text(l2tp_tree, tvb, 0, 0, "Zero Length Bit message");
1705 if (!LENGTH_BIT(control)) {
1709 process_control_avps(tvb, pinfo, l2tp_tree, idx, length+baseIdx);
1713 * Dissector for L2TP over UDP. For v2, calls process_control_avps for
1714 * control messages, or the ppp dissector based on the control bit.
1715 * For v3, calls either process_l2tpv3_control or process_l2tpv3_data_udp
1716 * based on the control bit.
1719 dissect_l2tp_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1721 proto_tree *l2tp_tree=NULL, *ctrl_tree;
1722 proto_item *l2tp_item = NULL, *ti;
1725 guint16 length = 0; /* Length field */
1726 guint16 tid; /* Tunnel ID */
1727 guint16 cid; /* Call ID */
1728 guint16 offset_size; /* Offset size */
1735 * Don't accept packets that aren't for an L2TP version we know,
1736 * as they might not be L2TP packets even though they happen
1737 * to be coming from or going to the L2TP port.
1739 if (tvb_length(tvb) < 2)
1740 return 0; /* not enough information to check */
1741 control = tvb_get_ntohs(tvb, 0);
1742 switch (L2TP_VERSION(control)) {
1752 col_set_str(pinfo->cinfo, COL_PROTOCOL, "L2TP");
1753 col_clear(pinfo->cinfo, COL_INFO);
1755 switch (L2TP_VERSION(control)) {
1761 col_set_str(pinfo->cinfo, COL_PROTOCOL, "L2TPv3");
1762 if (CONTROL_BIT(control)) {
1763 /* Call to process l2tp v3 control message */
1764 process_l2tpv3_control(tvb, pinfo, tree, 0);
1767 /* Call to process l2tp v3 data message */
1768 process_l2tpv3_data_udp(tvb, pinfo, tree);
1770 return tvb_length(tvb);
1773 if (LENGTH_BIT(control)) { /* length field included ? */
1774 idx += 2; /* skip ahead */
1775 length = tvb_get_ntohs(tvb, idx);
1778 /* collect the tunnel id & call id */
1780 tid = tvb_get_ntohs(tvb, idx);
1782 cid = tvb_get_ntohs(tvb, idx);
1784 if (check_col(pinfo->cinfo, COL_INFO)) {
1785 if (CONTROL_BIT(control)) {
1786 /* CONTROL MESSAGE */
1789 if ((LENGTH_BIT(control))&&(length==12)) /* ZLB Message */
1790 col_add_fstr(pinfo->cinfo, COL_INFO,
1791 "%s - ZLB (tunnel id=%d, session id=%u)",
1792 control_msg, tid, cid);
1795 if (SEQUENCE_BIT(control)) {
1801 avp_type = tvb_get_ntohs(tvb, (tmp_idx+=2));
1803 if (avp_type == CONTROL_MESSAGE) {
1804 /* We print message type */
1805 msg_type = tvb_get_ntohs(tvb, (tmp_idx+=2));
1806 col_add_fstr(pinfo->cinfo, COL_INFO,
1807 "%s - %s (tunnel id=%u, session id=%u)",
1809 ((NUM_CONTROL_CALL_TYPES + 1 ) > msg_type) ?
1810 calltype_short_str[msg_type] : "Unknown",
1816 * This is not a control message.
1817 * We never pass here except in case of bad l2tp packet!
1819 col_add_fstr(pinfo->cinfo, COL_INFO,
1820 "%s (tunnel id=%u, session id=%u)",
1821 control_msg, tid, cid);
1828 col_add_fstr(pinfo->cinfo, COL_INFO,
1829 "%s (tunnel id=%u, session id=%u)",
1830 data_msg, tid, cid);
1834 if (LENGTH_BIT(control)) {
1836 * Set the length of this tvbuff to be no longer than the length
1839 * XXX - complain if that length is longer than the length of
1840 * the tvbuff? Have "set_actual_length()" return a Boolean
1841 * and have its callers check the result?
1843 set_actual_length(tvb, length);
1847 l2tp_item = proto_tree_add_item(tree,proto_l2tp, tvb, 0, -1, FALSE);
1848 l2tp_tree = proto_item_add_subtree(l2tp_item, ett_l2tp);
1850 ti = proto_tree_add_text(l2tp_tree, tvb, 0, 2,
1851 "Packet Type: %s Tunnel Id=%d Session Id=%d",
1852 (CONTROL_BIT(control) ? control_msg : data_msg), tid, cid);
1854 ctrl_tree = proto_item_add_subtree(ti, ett_l2tp_ctrl);
1855 proto_tree_add_uint(ctrl_tree, hf_l2tp_type, tvb, 0, 2, control);
1856 proto_tree_add_boolean(ctrl_tree, hf_l2tp_length_bit, tvb, 0, 2, control);
1857 proto_tree_add_boolean(ctrl_tree, hf_l2tp_seq_bit, tvb, 0, 2, control);
1858 proto_tree_add_boolean(ctrl_tree, hf_l2tp_offset_bit, tvb, 0, 2, control);
1859 proto_tree_add_boolean(ctrl_tree, hf_l2tp_priority, tvb, 0, 2, control);
1860 proto_tree_add_uint(ctrl_tree, hf_l2tp_version, tvb, 0, 2, control);
1863 if (LENGTH_BIT(control)) {
1865 proto_tree_add_item(l2tp_tree, hf_l2tp_length, tvb, idx, 2, FALSE);
1871 proto_tree_add_item(l2tp_tree, hf_l2tp_tunnel, tvb, idx, 2, FALSE);
1875 proto_tree_add_item(l2tp_tree, hf_l2tp_session, tvb, idx, 2, FALSE);
1879 if (SEQUENCE_BIT(control)) {
1881 proto_tree_add_item(l2tp_tree, hf_l2tp_Ns, tvb, idx, 2, FALSE);
1885 proto_tree_add_item(l2tp_tree, hf_l2tp_Nr, tvb, idx, 2, FALSE);
1889 if (OFFSET_BIT(control)) {
1890 offset_size = tvb_get_ntohs(tvb, idx);
1892 proto_tree_add_uint(l2tp_tree, hf_l2tp_offset, tvb, idx, 2,
1896 if (offset_size != 0) {
1898 proto_tree_add_text(l2tp_tree, tvb, idx, offset_size, "Offset Padding");
1904 if (tree && (LENGTH_BIT(control))&&(length==12)) {
1905 proto_tree_add_text(l2tp_tree, tvb, 0, 0, "Zero Length Bit message");
1908 if (!CONTROL_BIT(control)) { /* Data Messages so we are done */
1910 proto_item_set_len(l2tp_item, idx);
1911 /* If we have data, signified by having a length bit, dissect it */
1912 if (tvb_offset_exists(tvb, idx)) {
1913 next_tvb = tvb_new_subset_remaining(tvb, idx);
1914 call_dissector(ppp_hdlc_handle, next_tvb, pinfo, tree);
1916 return tvb_length(tvb);
1919 if (LENGTH_BIT(control))
1920 process_control_avps(tvb, pinfo, l2tp_tree, idx, length);
1922 return tvb_length(tvb);
1927 * Only L2TPv3 runs directly over IP, and dissect_l2tp_ip starts dissecting
1928 * those packets to call either process_l2tpv3_control for Control Messages
1929 * or process_l2tpv3_data_ip for Data Messages over IP, based on the
1933 dissect_l2tp_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1936 guint32 sid; /* Session ID */
1938 /* Only L2TPv3 runs directly over IP */
1939 col_set_str(pinfo->cinfo, COL_PROTOCOL, "L2TPv3");
1941 col_clear(pinfo->cinfo, COL_INFO);
1943 sid = tvb_get_ntohl(tvb, idx);
1945 /* This is control message */
1946 /* Call to process l2tp v3 control message */
1947 process_l2tpv3_control(tvb, pinfo, tree, 4);
1950 /* Call to process l2tp v3 data message */
1951 process_l2tpv3_data_ip(tvb, pinfo, tree);
1957 /* registration with the filtering engine */
1959 proto_register_l2tp(void)
1961 static hf_register_info hf[] = {
1963 { "Type", "l2tp.type", FT_UINT16, BASE_DEC, VALS(l2tp_type_vals), 0x8000,
1964 "Type bit", HFILL }},
1966 { &hf_l2tp_length_bit,
1967 { "Length Bit", "l2tp.length_bit", FT_BOOLEAN, 16, TFS(&l2tp_length_bit_truth), 0x4000,
1971 { "Sequence Bit", "l2tp.seq_bit", FT_BOOLEAN, 16, TFS(&l2tp_seq_bit_truth), 0x0800,
1974 { &hf_l2tp_offset_bit,
1975 { "Offset bit", "l2tp.offset_bit", FT_BOOLEAN, 16, TFS(&l2tp_offset_bit_truth), 0x0200,
1978 { &hf_l2tp_priority,
1979 { "Priority", "l2tp.priority", FT_BOOLEAN, 16, TFS(&l2tp_priority_truth), 0x0100,
1980 "Priority bit", HFILL }},
1983 { "Version", "l2tp.version", FT_UINT16, BASE_DEC, NULL, 0x000f,
1987 { "Length","l2tp.length", FT_UINT16, BASE_DEC, NULL, 0x0,
1991 { "Tunnel ID","l2tp.tunnel", FT_UINT16, BASE_DEC, NULL, 0x0, /* Probably should be FT_BYTES */
1995 { "Session ID","l2tp.session", FT_UINT16, BASE_DEC, NULL, 0x0, /* Probably should be FT_BYTES */
1999 { "Ns","l2tp.Ns", FT_UINT16, BASE_DEC, NULL, 0x0,
2003 { "Nr","l2tp.Nr", FT_UINT16, BASE_DEC, NULL, 0x0,
2007 { "Offset","l2tp.offset", FT_UINT16, BASE_DEC, NULL, 0x0,
2008 "Number of octest past the L2TP header at which thepayload data starts.", HFILL }},
2010 { &hf_l2tp_avp_mandatory,
2011 { "Mandatory", "l2tp.avp.mandatory", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
2012 "Mandatory AVP", HFILL }},
2014 { &hf_l2tp_avp_hidden,
2015 { "Hidden", "l2tp.avp.hidden", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
2016 "Hidden AVP", HFILL }},
2018 { &hf_l2tp_avp_length,
2019 { "Length", "l2tp.avp.length", FT_UINT16, BASE_DEC, NULL, 0,
2020 "AVP Length", HFILL }},
2022 { &hf_l2tp_avp_vendor_id,
2023 { "Vendor ID", "l2tp.avp.vendor_id", FT_UINT16, BASE_DEC|BASE_EXT_STRING, &sminmpec_values_ext, 0,
2024 "AVP Vendor ID", HFILL }},
2026 { &hf_l2tp_avp_type,
2027 { "Type", "l2tp.avp.type", FT_UINT16, BASE_DEC, VALS(avp_type_vals), 0,
2028 "AVP Type", HFILL }},
2030 { &hf_l2tp_tie_breaker,
2031 { "Tie Breaker", "l2tp.tie_breaker", FT_UINT64, BASE_HEX, NULL, 0,
2035 { "Session ID","l2tp.sid", FT_UINT32, BASE_DEC, NULL, 0x0,
2039 { "Control Connection ID","l2tp.ccid", FT_UINT32, BASE_DEC, NULL, 0x0,
2043 { "Reserved","l2tp.res", FT_UINT16, BASE_HEX, NULL, 0x0,
2047 { "Cookie","lt2p.cookie", FT_BYTES, BASE_NONE, NULL, 0x0,
2050 { &hf_l2tp_l2_spec_def,
2051 { "Default L2-Specific Sublayer","lt2p.l2_spec_def", FT_NONE, BASE_NONE, NULL, 0x0,
2054 { &hf_l2tp_l2_spec_atm,
2055 { "ATM-Specific Sublayer","lt2p.l2_spec_atm", FT_NONE, BASE_NONE, NULL, 0x0,
2058 { &hf_l2tp_l2_spec_docsis_dmpt,
2059 { "DOCSIS DMPT - Specific Sublayer","lt2p.l2_spec_docsis_dmpt", FT_NONE, BASE_NONE, NULL, 0x0,
2062 { &hf_l2tp_l2_spec_v,
2063 { "V-bit","lt2p.l2_spec_v", FT_BOOLEAN, 8, NULL, 0x80,
2064 "VCCV Bit", HFILL }},
2066 { &hf_l2tp_l2_spec_s,
2067 { "S-bit","lt2p.l2_spec_s", FT_BOOLEAN, 8, NULL, 0x40,
2068 "Sequence Bit", HFILL }},
2070 { &hf_l2tp_l2_spec_t,
2071 { "T-bit","lt2p.l2_spec_t", FT_BOOLEAN, 8, NULL, 0x08,
2072 "Transport Type Bit", HFILL }},
2074 { &hf_l2tp_l2_spec_g,
2075 { "G-bit","lt2p.l2_spec_g", FT_BOOLEAN, 8, NULL, 0x04,
2076 "EFCI Bit", HFILL }},
2078 { &hf_l2tp_l2_spec_c,
2079 { "C-bit","lt2p.l2_spec_c", FT_BOOLEAN, 8, NULL, 0x02,
2080 "CLP Bit", HFILL }},
2082 { &hf_l2tp_l2_spec_u,
2083 { "U-bit","lt2p.l2_spec_u", FT_BOOLEAN, 8, NULL, 0x01,
2084 "C/R Bit", HFILL }},
2086 { &hf_l2tp_l2_spec_flow_id,
2087 { "Flow ID","lt2p.l2_spec_flow_id", FT_UINT8, BASE_HEX, NULL, FLOW_ID_MASK,
2090 { &hf_l2tp_l2_spec_sequence,
2091 { "Sequence Number","lt2p.l2_spec_sequence", FT_UINT24, BASE_DEC, NULL, 0x0,
2094 { &hf_l2tp_cisco_avp_type,
2095 { "Type", "l2tp.avp.ciscotype", FT_UINT16, BASE_DEC, VALS(cisco_avp_type_vals), 0,
2096 "AVP Type", HFILL }},
2100 static gint *ett[] = {
2109 module_t *l2tp_module;
2111 proto_l2tp = proto_register_protocol(
2112 "Layer 2 Tunneling Protocol", "L2TP", "l2tp");
2113 proto_register_field_array(proto_l2tp, hf, array_length(hf));
2114 proto_register_subtree_array(ett, array_length(ett));
2116 l2tp_module = prefs_register_protocol(proto_l2tp, NULL);
2118 prefs_register_enum_preference(l2tp_module,
2120 "L2TPv3 Cookie Size",
2121 "L2TPv3 Cookie Size",
2126 prefs_register_enum_preference(l2tp_module,
2128 "L2TPv3 L2-Specific Sublayer",
2129 "L2TPv3 L2-Specific Sublayer",
2130 &l2tpv3_l2_specific,
2131 l2tpv3_l2_specifics,
2134 prefs_register_enum_preference(l2tp_module,
2136 "Decode L2TPv3 packet contents as this protocol",
2137 "Decode L2TPv3 packet contents as this protocol",
2145 proto_reg_handoff_l2tp(void)
2147 dissector_handle_t l2tp_udp_handle;
2148 dissector_handle_t l2tp_ip_handle;
2150 l2tp_udp_handle = new_create_dissector_handle(dissect_l2tp_udp, proto_l2tp);
2151 dissector_add_uint("udp.port", UDP_PORT_L2TP, l2tp_udp_handle);
2153 l2tp_ip_handle = create_dissector_handle(dissect_l2tp_ip, proto_l2tp);
2154 dissector_add_uint("ip.proto", IP_PROTO_L2TP, l2tp_ip_handle);
2157 * Get a handle for the PPP-in-HDLC-like-framing dissector.
2159 ppp_hdlc_handle = find_dissector("ppp_hdlc");
2160 ppp_lcp_options_handle = find_dissector("ppp_lcp_options");
2163 * Get a handle for the dissectors used in v3.
2165 eth_withoutfcs_handle = find_dissector("eth_withoutfcs");
2166 chdlc_handle = find_dissector("chdlc");
2167 fr_handle = find_dissector("fr");
2168 ip_handle = find_dissector("ip");
2169 mpls_handle = find_dissector("mpls");
2170 atm_oam_handle = find_dissector("atm_oam_cell");
2171 llc_handle = find_dissector("llc");
2172 lapd_handle = find_dissector("lapd");
2173 mp2t_handle = find_dissector("mp2t");
2174 data_handle = find_dissector("data");