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_s = -1;
83 static int hf_l2tp_l2_spec_sequence = -1;
84 static int hf_l2tp_l2_spec_t = -1;
85 static int hf_l2tp_l2_spec_g = -1;
86 static int hf_l2tp_l2_spec_c = -1;
87 static int hf_l2tp_l2_spec_u = -1;
88 static int hf_l2tp_cisco_avp_type = -1;
99 #include <epan/packet.h>
100 #include <epan/addr_resolv.h>
101 #include <epan/ipproto.h>
102 #include <epan/sminmpec.h>
103 #include <epan/prefs.h>
105 #define UDP_PORT_L2TP 1701
107 #define CONTROL_BIT(msg_info) (msg_info & 0x8000) /* Type bit control = 1 data = 0 */
108 #define LENGTH_BIT(msg_info) (msg_info & 0x4000) /* Length bit = 1 */
109 #define RESERVE_BITS(msg_info) (msg_info &0x37F8) /* Reserved bit - usused */
110 #define SEQUENCE_BIT(msg_info) (msg_info & 0x0800) /* SEQUENCE bit = 1 Ns and Nr fields */
111 #define OFFSET_BIT(msg_info) (msg_info & 0x0200) /* Offset */
112 #define PRIORITY_BIT(msg_info) (msg_info & 0x0100) /* Priority */
113 #define L2TP_VERSION(msg_info) (msg_info & 0x000f) /* Version of l2tp */
114 #define MANDATORY_BIT(msg_info) (msg_info & 0x8000) /* Mandatory = 1 */
115 #define HIDDEN_BIT(msg_info) (msg_info & 0x4000) /* Hidden = 1 */
116 #define AVP_LENGTH(msg_info) (msg_info & 0x03ff) /* AVP Length */
117 #define FRAMING_SYNC(msg_info) (msg_info & 0x0001) /* SYNC Framing Type */
118 #define FRAMING_ASYNC(msg_info) (msg_info & 0x0002) /* ASYNC Framing Type */
119 #define BEARER_DIGITAL(msg_info) (msg_info & 0x0001) /* Digital Bearer Type */
120 #define BEARER_ANALOG(msg_info) (msg_info & 0x0002) /* Analog Bearer Type */
121 #define CIRCUIT_STATUS_BIT(msg_info) (msg_info & 0x0001) /* Circuit Status */
122 #define CIRCUIT_TYPE_BIT(msg_info) (msg_info & 0x0001) /* Circuit Condition */
124 static gint ett_l2tp = -1;
125 static gint ett_l2tp_ctrl = -1;
126 static gint ett_l2tp_avp = -1;
127 static gint ett_l2tp_avp_sub = -1;
128 static gint ett_l2tp_lcp = -1;
129 static gint ett_l2tp_l2_spec = -1;
131 static enum_val_t l2tpv3_cookies[] = {
132 {"cookie0", "None", 0},
133 {"cookie4", "4 Byte Cookie", 4},
134 {"cookie8", "8 Byte Cookie", 8},
138 #define L2TPv3_PROTOCOL_ETH 0
139 #define L2TPv3_PROTOCOL_CHDLC 1
140 #define L2TPv3_PROTOCOL_FR 2
141 #define L2TPv3_PROTOCOL_PPP 3
142 #define L2TPv3_PROTOCOL_IP 4
143 #define L2TPv3_PROTOCOL_MPLS 5
144 #define L2TPv3_PROTOCOL_AAL5 6
145 #define L2TPv3_PROTOCOL_LAPD 7
147 static enum_val_t l2tpv3_protocols[] = {
148 {"eth", "Ethernet", L2TPv3_PROTOCOL_ETH},
149 {"chdlc", "Cisco HDLC", L2TPv3_PROTOCOL_CHDLC},
150 {"fr", "Frame Relay", L2TPv3_PROTOCOL_FR},
151 {"ppp", "PPP", L2TPv3_PROTOCOL_PPP},
152 {"ip", "IP", L2TPv3_PROTOCOL_IP},
153 {"mpls", "MPLS", L2TPv3_PROTOCOL_MPLS},
154 {"aal5", "AAL5", L2TPv3_PROTOCOL_AAL5},
155 {"lapd", "LAPD", L2TPv3_PROTOCOL_LAPD},
159 #define L2TPv3_L2_SPECIFIC_NONE 0
160 #define L2TPv3_L2_SPECIFIC_DEFAULT 1
161 #define L2TPv3_L2_SPECIFIC_ATM 2
162 #define L2TPv3_L2_SPECIFIC_LAPD 3
164 static enum_val_t l2tpv3_l2_specifics[] = {
165 {"none", "None", L2TPv3_L2_SPECIFIC_NONE},
166 {"default", "Default L2-Specific", L2TPv3_L2_SPECIFIC_DEFAULT},
167 {"atm", "ATM-Specific", L2TPv3_L2_SPECIFIC_ATM},
168 {"lapd", "LAPD-Specific", L2TPv3_L2_SPECIFIC_LAPD},
172 static gint l2tpv3_cookie = 4;
173 static gint l2tpv3_protocol = L2TPv3_PROTOCOL_CHDLC;
174 static gint l2tpv3_l2_specific = L2TPv3_L2_SPECIFIC_DEFAULT;
179 #define AVP_StopCCN 4
180 #define AVP_Reserved 5
188 #define AVP_Reserved1 13
191 #define NUM_CONTROL_CALL_TYPES 27
192 static const char *calltypestr[NUM_CONTROL_CALL_TYPES+1] = {
194 "Start_Control_Request",
195 "Start_Control_Reply",
196 "Start_Control_Connected",
197 "Stop_Control_Notification",
200 "Outgoing_Call_Request",
201 "Outgoing_Call_Reply",
202 "Outgoing_Call_Connected",
203 "Incoming_Call_Request", /* 10 */
204 "Incoming_Call_Reply",
205 "Incoming_Call_Connected",
207 "Call_Disconnect_Notification",
208 "WAN_Error_Notify", /* 15 */
211 "Service_Relay_Request_Msg",
212 "Service_Relay_Reply_Message",
213 "Explicit_Acknowledgement", /* 20 */
214 "Failover_Session_Query_Message", /* 21 [RFC4951] */
215 "Failover_Session_Response_Message", /* 22 [RFC4951] */
216 /* Multicast Management */
217 "Multicast-Session-Request", /* 23 [RFC4045]*/
218 "Multicast-Session-Response ", /* 24 [RFC4045]*/
219 "Multicast-Session-Establishment", /* 25 [RFC4045]*/
220 "Multicast-Session-Information", /* 26 [RFC4045]*/
221 "Multicast-Session-End-Notify", /* 27 [RFC4045]*/
225 static const char *calltype_short_str[NUM_CONTROL_CALL_TYPES+1] = {
258 static const char *control_msg = "Control Message";
259 static const char *data_msg = "Data Message";
260 static const value_string l2tp_type_vals[] = {
261 { 0, "Data Message" },
262 { 1, "Control Message" },
266 static const value_string cause_code_direction_vals[] = {
267 { 0, "global error" },
273 static const true_false_string l2tp_length_bit_truth =
274 { "Length field is present", "Length field is not present" };
276 static const true_false_string l2tp_seq_bit_truth =
277 { "Ns and Nr fields are present", "Ns and Nr fields are not present" };
279 static const true_false_string l2tp_offset_bit_truth =
280 { "Offset Size field is present", "Offset size field is not present" };
282 static const true_false_string l2tp_priority_truth =
283 { "This data message has priority", "No priority" };
285 static const value_string authen_type_vals[] = {
287 { 1, "Textual username/password exchange" },
290 { 4, "No Authentication" },
291 { 5, "Microsoft CHAP Version 1" },
297 static const value_string data_sequencing_vals[] = {
298 { 0, "No incoming data packets require sequencing" },
299 { 1, "Only non-IP data packets require sequencing" },
300 { 2, "All incoming data packets require sequencing" },
304 static const value_string l2_sublayer_vals[] = {
305 { 0, "No L2-Specific Sublayer" },
306 { 1, "Default L2-Specific Sublayer present" },
307 { 2, "ATM-Specific Sublayer present" },
308 { 3, "MPT-Specific Sublayer" },
309 { 4, "PSP-Specific Sublayer" },
313 static const value_string result_code_stopccn_vals[] = {
315 { 1, "General request to clear control connection", },
316 { 2, "General error, Error Code indicates the problem", },
317 { 3, "Control connection already exists", },
318 { 4, "Requester is not authorized to establish a control connection", },
319 { 5, "The protocol version of the requester is not supported", },
320 { 6, "Requester is being shut down", },
321 { 7, "Finite state machine error or timeout", },
322 { 8, "Control connection due to mismatching CCDS value", }, /* [RFC3308] */
326 static const value_string result_code_cdn_vals[] = {
328 { 1, "Session disconnected due to loss of carrier or circuit disconnect", },
329 { 2, "Session disconnected for the reason indicated in Error Code", },
330 { 3, "Session disconnected for administrative reasons", },
331 { 4, "Appropriate facilities unavailable (temporary condition)", },
332 { 5, "Appropriate facilities unavailable (permanent condition)", },
333 { 6, "Invalid destination", },
334 { 7, "Call failed due to no carrier detected", },
335 { 8, "Call failed due to detection of a busy signal", },
336 { 9, "Call failed due to lack of a dial tone", },
337 { 10, "Call was not established within time allotted by LAC", },
338 { 11, "Call was connected but no appropriate framing was detected", },
339 { 12, "Disconnecting call due to mismatching SDS value", },
340 { 13, "Session not established due to losing tie breaker", },
341 { 14, "Session not established due to unsupported PW type", },
342 { 15, "Session not established, sequencing required without valid L2-Specific Sublayer", },
343 { 16, "Finite state machine error or timeout", },
344 { 17, "FR PVC was deleted permanently (no longer provisioned) ", }, /* [RFC4591] */
345 { 18, "FR PVC has been INACTIVE for an extended period of time", }, /* [RFC4591] */
346 { 19, "Mismatched FR Header Length", }, /* [RFC4591] */
347 { 20, "HDLC Link was deleted permanently (no longer provisioned)", }, /* [RFC4349] */
348 { 21, "HDLC Link has been INACTIVE for an extended period of time", }, /* [RFC4349] */
349 { 22, "Session not established due to other LCCE can not support the OAM Cell Emulation", }, /* [RFC4454] */
350 { 23, "Mismatching interface MTU", }, /* [RFC4667] */
351 { 24, "Attempt to connect to non-existent forwarder", }, /* [RFC4667] */
352 { 25, "Attempt to connect to unauthorized forwarder", }, /* [RFC4667] */
353 { 26, "Loop Detected", }, /* [draft-ietf-l2tpext-tunnel-switching-06.txt] */
359 static const value_string error_code_vals[] = {
360 { 0, "No General Error", },
361 { 1, "No control connection exists yet for this pair of LCCEs", },
362 { 2, "Length is wrong", },
363 { 3, "One of the field values was out of range", },
364 { 4, "Insufficient resources to handle this operation now", },
365 { 5, "Invalid Session ID", },
366 { 6, "A generic vendor-specific error occurred", },
367 { 7, "Try another", },
368 { 8, "Receipt of an unknown AVP with the M bit set", },
369 { 9, "Try another directed", },
370 { 10, "Next hop unreachable", },
371 { 11, "Next hop busy", },
376 #define CONTROL_MESSAGE 0
377 #define RESULT_ERROR_CODE 1
378 #define PROTOCOL_VERSION 2
379 #define FRAMING_CAPABILITIES 3
380 #define BEARER_CAPABILITIES 4
381 #define TIE_BREAKER 5
382 #define FIRMWARE_REVISION 6
384 #define VENDOR_NAME 8
385 #define ASSIGNED_TUNNEL_ID 9
386 #define RECEIVE_WINDOW_SIZE 10
388 #define CAUSE_CODE 12
389 #define CHALLENGE_RESPONSE 13
390 #define ASSIGNED_SESSION 14
391 #define CALL_SERIAL_NUMBER 15
392 #define MINIMUM_BPS 16
393 #define MAXIMUM_BPS 17
394 #define BEARER_TYPE 18
395 #define FRAMING_TYPE 19
396 #define CALLED_NUMBER 21
397 #define CALLING_NUMBER 22
398 #define SUB_ADDRESS 23
399 #define TX_CONNECT_SPEED 24
400 #define PHYSICAL_CHANNEL 25
401 #define INITIAL_RECEIVED_LCP_CONFREQ 26
402 #define LAST_SENT_LCP_CONFREQ 27
403 #define LAST_RECEIVED_LCP_CONFREQ 28
404 #define PROXY_AUTHEN_TYPE 29
405 #define PROXY_AUTHEN_NAME 30
406 #define PROXY_AUTHEN_CHALLENGE 31
407 #define PROXY_AUTHEN_ID 32
408 #define PROXY_AUTHEN_RESPONSE 33
409 #define CALL_STATUS_AVPS 34
411 #define RANDOM_VECTOR 36
412 #define PRIVATE_GROUP_ID 37
413 #define RX_CONNECT_SPEED 38
414 #define SEQUENCING_REQUIRED 39
415 #define PPP_DISCONNECT_CAUSE_CODE 46 /* RFC 3145 */
416 #define EXTENDED_VENDOR_ID 58
417 #define MESSAGE_DIGEST 59
419 #define ASSIGNED_CONTROL_CONN_ID 61
420 #define PW_CAPABILITY_LIST 62
421 #define LOCAL_SESSION_ID 63
422 #define REMOTE_SESSION_ID 64
423 #define ASSIGNED_COOKIE 65
424 #define REMOTE_END_ID 66
426 #define L2_SPECIFIC_SUBLAYER 69
427 #define DATA_SEQUENCING 70
428 #define CIRCUIT_STATUS 71
429 #define PREFERRED_LANGUAGE 72
430 #define CTL_MSG_AUTH_NONCE 73
431 #define TX_CONNECT_SPEED_V3 74
432 #define RX_CONNECT_SPEED_V3 75
434 #define NUM_AVP_TYPES 96
435 static const value_string avp_type_vals[] = {
436 { CONTROL_MESSAGE, "Control Message" },
437 { RESULT_ERROR_CODE, "Result-Error Code" },
438 { PROTOCOL_VERSION, "Protocol Version" },
439 { FRAMING_CAPABILITIES, "Framing Capabilities" },
440 { BEARER_CAPABILITIES, "Bearer Capabilities" },
441 { TIE_BREAKER, "Tie Breaker" },
442 { FIRMWARE_REVISION, "Firmware Revision" },
443 { HOST_NAME, "Host Name" },
444 { VENDOR_NAME, "Vendor Name" },
445 { ASSIGNED_TUNNEL_ID, "Assigned Tunnel ID" },
446 { RECEIVE_WINDOW_SIZE, "Receive Window Size" },
447 { CHALLENGE, "Challenge" },
448 { CAUSE_CODE, "Cause Code" },
449 { CHALLENGE_RESPONSE, "Challenge Response" },
450 { ASSIGNED_SESSION, "Assigned Session" },
451 { CALL_SERIAL_NUMBER, "Call Serial Number" },
452 { MINIMUM_BPS, "Minimum BPS" },
453 { MAXIMUM_BPS, "Maximum BPS" },
454 { BEARER_TYPE, "Bearer Type" },
455 { FRAMING_TYPE, "Framing Type" },
456 { CALLED_NUMBER, "Called Number" },
457 { CALLING_NUMBER, "Calling Number" },
458 { SUB_ADDRESS, "Sub-Address" },
459 { TX_CONNECT_SPEED, "Connect Speed" },
460 { PHYSICAL_CHANNEL, "Physical Channel" },
461 { INITIAL_RECEIVED_LCP_CONFREQ, "Initial Received LCP CONFREQ" },
462 { LAST_SENT_LCP_CONFREQ, "Last Sent LCP CONFREQ" },
463 { LAST_RECEIVED_LCP_CONFREQ, "Last Received LCP CONFREQ" },
464 { PROXY_AUTHEN_TYPE, "Proxy Authen Type" },
465 { PROXY_AUTHEN_NAME, "Proxy Authen Name" },
466 { PROXY_AUTHEN_CHALLENGE, "Proxy Authen Challenge" },
467 { PROXY_AUTHEN_ID, "Proxy Authen ID" },
468 { PROXY_AUTHEN_RESPONSE, "Proxy Authen Response" },
469 { CALL_STATUS_AVPS, "Call status AVPs" },
471 { RANDOM_VECTOR, "Random Vector" },
472 { PRIVATE_GROUP_ID, "Private group ID" },
473 { RX_CONNECT_SPEED, "RxConnect Speed" },
474 { SEQUENCING_REQUIRED, "Sequencing Required" },
475 { PPP_DISCONNECT_CAUSE_CODE, "PPP Disconnect Cause Code" },
476 { EXTENDED_VENDOR_ID, "Extended Vendor ID" },
477 { MESSAGE_DIGEST, "Message Digest" },
478 { ROUTER_ID, "Router ID" },
479 { ASSIGNED_CONTROL_CONN_ID, "Assigned Control Connection ID" },
480 { PW_CAPABILITY_LIST, "Pseudowire Capability List" },
481 { LOCAL_SESSION_ID, "Local Session ID" },
482 { REMOTE_SESSION_ID, "Remote Session ID" },
483 { ASSIGNED_COOKIE, "Assigned Cookie" },
484 { REMOTE_END_ID, "Remote End ID" },
485 { PW_TYPE, "Pseudowire Type" },
486 { L2_SPECIFIC_SUBLAYER, "Layer2 Specific Sublayer" },
487 { DATA_SEQUENCING, "Data Sequencing" },
488 { CIRCUIT_STATUS, "Circuit Status" },
489 { PREFERRED_LANGUAGE, "Preferred Language" },
490 { CTL_MSG_AUTH_NONCE, "Control Message Authentication Nonce" },
491 { TX_CONNECT_SPEED_V3, "Tx Connect Speed Version 3" },
492 { RX_CONNECT_SPEED_V3, "Rx Connect Speed Version 3" },
493 { 76, "Failover Capability" }, /*[RFC4951] */
494 { 77, "Tunnel Recovery" }, /*[RFC4951] */
495 { 78, "Suggested Control Sequence" }, /*[RFC4951] */
496 { 79, "Failover Session State" }, /*[RFC4951] */
497 { 80, "Multicast Capability" }, /*[RFC4045] */
498 { 81, "New Outgoing Sessions" }, /*[RFC4045] */
499 { 82, "New Outgoing Sessions Acknowledgement" }, /*[RFC4045] */
500 { 83, "Withdraw Outgoing Sessions" }, /*[RFC4045] */
501 { 84, "Multicast Packets Priority" }, /*[RFC4045] */
502 { 85, "Frame-Relay Header Length" }, /*[RFC4591] */
503 { 86, "ATM Maximum Concatenated Cells AVP" }, /*[RFC4454] */
504 { 87, "OAM Emulation Required AVP" }, /*[RFC4454] */
505 { 88, "ATM Alarm Status AVP" }, /*[RFC4454] */
506 /* Also, see ATM Alarm Status AVP Values below */
507 { 89, "Attachment Group Identifier" }, /*[RFC4667] */
508 { 90, "Local End Identifier" }, /*[RFC4667] */
509 { 91, "Interface Maximum Transmission Unit" }, /*[RFC4667] */
510 { 92, "FCS Retention" }, /*[RFC4720] */
511 { 93, "Tunnel Switching Aggregator ID AVP" }, /*[draft-ietf-l2tpext-tunnel-switching-06.txt] */
512 { 94, "Maximum Receive Unit (MRU) AVP" }, /*[RFC4623] */
513 { 95, "Maximum Reassembled Receive Unit (MRRU) AVP" }, /*[RFC4623] */
519 #define CISCO_ASSIGNED_CONNECTION_ID 1
520 #define CISCO_PW_CAPABILITY_LIST 2
521 #define CISCO_LOCAL_SESSION_ID 3
522 #define CISCO_REMOTE_SESSION_ID 4
523 #define CISCO_ASSIGNED_COOKIE 5
524 #define CISCO_REMOTE_END_ID 6
525 #define CISCO_PW_TYPE 7
526 #define CISCO_CIRCUIT_STATUS 8
527 #define CISCO_SESSION_TIE_BREAKER 9
528 #define CISCO_DRAFT_AVP_VERSION 10
529 #define CISCO_MESSAGE_DIGEST 12
530 #define CISCO_AUTH_NONCE 13
531 #define CISCO_INTERFACE_MTU 14
533 static const value_string cisco_avp_type_vals[] = {
534 { CISCO_ASSIGNED_CONNECTION_ID, "Assigned Connection ID" },
535 { CISCO_PW_CAPABILITY_LIST, "Pseudowire Capabilities List" },
536 { CISCO_LOCAL_SESSION_ID, "Local Session ID" },
537 { CISCO_REMOTE_SESSION_ID, "Remote Session ID" },
538 { CISCO_ASSIGNED_COOKIE, "Assigned Cookie" },
539 { CISCO_REMOTE_END_ID, "Remote End ID" },
540 { CISCO_PW_TYPE, "Pseudowire Type" },
541 { CISCO_CIRCUIT_STATUS, "Circuit Status" },
542 { CISCO_SESSION_TIE_BREAKER, "Session Tie Breaker" },
543 { CISCO_DRAFT_AVP_VERSION, "Draft AVP Version" },
544 { CISCO_MESSAGE_DIGEST, "Message Digest" },
545 { CISCO_AUTH_NONCE, "Control Message Authentication Nonce" },
546 { CISCO_INTERFACE_MTU, "Interface MTU" },
550 static const value_string pw_types_vals[] = {
551 { 0x0001, "Frame Relay DLCI" },
552 { 0x0002, "ATM AAL5 SDU VCC transport" },
553 { 0x0003, "ATM Cell transparent Port Mode" },
554 { 0x0004, "Ethernet VLAN" },
555 { 0x0005, "Ethernet" },
558 { 0x0009, "ATM Cell transport VCC Mode" },
559 { 0x000A, "ATM Cell transport VPC Mode" },
560 { 0x000B, "IP Transport" },
561 { 0x000C, "MPEG-TS Payload Type (MPTPW)" },
562 { 0x000D, "Packet Streaming Protocol (PSPPW)" },
566 static dissector_handle_t ppp_hdlc_handle;
567 static dissector_handle_t ppp_lcp_options_handle;
569 static dissector_handle_t eth_withoutfcs_handle;
570 static dissector_handle_t chdlc_handle;
571 static dissector_handle_t fr_handle;
572 static dissector_handle_t ip_handle;
573 static dissector_handle_t mpls_handle;
574 static dissector_handle_t atm_oam_handle;
575 static dissector_handle_t llc_handle;
576 static dissector_handle_t lapd_handle;
577 static dissector_handle_t data_handle;
580 * Processes AVPs for Control Messages all versions and transports
582 static void process_control_avps(tvbuff_t *tvb,
584 proto_tree *l2tp_tree,
588 proto_tree *l2tp_lcp_avp_tree, *l2tp_avp_tree, *l2tp_avp_tree_sub;
592 gboolean isStopCcn = FALSE;
594 guint32 avp_vendor_id;
596 guint16 ver_len_hidden;
602 guint16 firmware_rev;
604 while (index < length) { /* Process AVP's */
605 ver_len_hidden = tvb_get_ntohs(tvb, index);
606 avp_len = AVP_LENGTH(ver_len_hidden);
607 avp_vendor_id = tvb_get_ntohs(tvb, index + 2);
608 avp_type = tvb_get_ntohs(tvb, index + 4);
611 proto_tree_add_text(l2tp_tree, tvb, index, 0,
612 "AVP length must be >= 1");
616 if (avp_vendor_id == VENDOR_IETF) {
617 tf = proto_tree_add_text(l2tp_tree, tvb, index,
619 val_to_str(avp_type, avp_type_vals, "Unknown (%u)"));
620 } else if (avp_vendor_id == VENDOR_CISCO) { /* Vendor-Specific AVP */
621 tf = proto_tree_add_text(l2tp_tree, tvb, index,
622 avp_len, "Vendor %s: %s AVP",
623 val_to_str(avp_vendor_id, sminmpec_values, "Unknown (%u)"),
624 val_to_str(avp_type, cisco_avp_type_vals, "Unknown (%u)"));
625 } else { /* Vendor-Specific AVP */
626 tf = proto_tree_add_text(l2tp_tree, tvb, index,
627 avp_len, "Vendor %s AVP Type %u",
628 val_to_str(avp_vendor_id, sminmpec_values, "Unknown (%u)"),
633 l2tp_avp_tree = proto_item_add_subtree(tf, ett_l2tp_avp);
635 proto_tree_add_boolean_format(l2tp_avp_tree,hf_l2tp_avp_mandatory, tvb, index, 1,
636 rhcode, "Mandatory: %s",
637 (MANDATORY_BIT(ver_len_hidden)) ? "True" : "False" );
638 proto_tree_add_boolean_format(l2tp_avp_tree,hf_l2tp_avp_hidden, tvb, index, 1,
639 rhcode, "Hidden: %s",
640 (HIDDEN_BIT(ver_len_hidden)) ? "True" : "False" );
641 proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_avp_length, tvb, index, 2,
642 rhcode, "Length: %u", avp_len);
643 if (HIDDEN_BIT(ver_len_hidden)) { /* don't try do display hidden */
649 proto_tree_add_text(l2tp_avp_tree, tvb, index, 0,
650 "AVP length must be >= 6");
656 /* Special Case for handling Extended Vendor Id */
657 if (avp_type == EXTENDED_VENDOR_ID) {
660 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_vendor_id,
661 tvb, index, 4, FALSE);
663 avp_vendor_id = tvb_get_ntohl(tvb, index);
670 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_vendor_id,
671 tvb, index, 2, FALSE);
676 if (avp_vendor_id == VENDOR_CISCO) {
677 proto_tree_add_uint(l2tp_avp_tree, hf_l2tp_cisco_avp_type,
678 tvb, index, 2, avp_type);
682 /* For the time being, we don't decode any Vendor-
685 case CISCO_ASSIGNED_CONNECTION_ID:
686 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
687 "Assigned Control Connection ID: %u",
688 tvb_get_ntohl(tvb, index));
691 case CISCO_PW_CAPABILITY_LIST:
692 te = proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
693 "Pseudowire Capabilities List");
694 l2tp_avp_tree_sub = proto_item_add_subtree(te, ett_l2tp_avp_sub);
695 while (avp_len >= 2) {
696 int pw_type = tvb_get_ntohs(tvb, index);
698 proto_tree_add_text(l2tp_avp_tree_sub, tvb, index,
699 2, "PW Type: (%u) %s",
701 val_to_str(pw_type, pw_types_vals,
702 "Unknown (0x%04x)"));
708 case CISCO_LOCAL_SESSION_ID:
709 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
710 "Local Session ID: %u",
711 tvb_get_ntohl(tvb, index));
713 case CISCO_REMOTE_SESSION_ID:
714 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
715 "Remote Session ID: %u",
716 tvb_get_ntohl(tvb, index));
718 case CISCO_ASSIGNED_COOKIE:
719 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
720 "Assigned Cookie: %s",
721 tvb_bytes_to_str(tvb, index, avp_len));
723 case CISCO_REMOTE_END_ID:
724 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
726 tvb_format_text(tvb, index, avp_len));
729 proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
730 "Pseudowire Type: %u - %s",
731 tvb_get_ntohs(tvb, index),
732 val_to_str(tvb_get_ntohs(tvb, index),
733 pw_types_vals, "Unknown (0x%04x)"));
735 case CISCO_CIRCUIT_STATUS:
736 bits = tvb_get_ntohs(tvb, index);
737 proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
738 "Circuit Status: %s",
739 (CIRCUIT_STATUS_BIT(bits)) ? "Up" : "Down");
740 proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
742 (CIRCUIT_TYPE_BIT(bits)) ? "New" : "Existing");
744 case CISCO_SESSION_TIE_BREAKER:
745 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_tie_breaker,
746 tvb, index, 8, FALSE);
748 case CISCO_DRAFT_AVP_VERSION:
749 proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
750 "Draft AVP Version: %u",
751 tvb_get_ntohs(tvb, index));
753 case CISCO_MESSAGE_DIGEST:
754 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
755 "Message Digest: %s",
756 tvb_bytes_to_str(tvb, index, avp_len));
758 case CISCO_AUTH_NONCE:
759 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
761 tvb_bytes_to_str(tvb, index, avp_len));
763 case CISCO_INTERFACE_MTU:
764 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
766 tvb_get_ntohs(tvb, index));
770 proto_tree_add_text(l2tp_avp_tree, tvb, index,
771 avp_len, "Vendor-Specific AVP");
776 } else if (avp_vendor_id != VENDOR_IETF) {
778 proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
779 "Type: %u", avp_type);
783 proto_tree_add_text(l2tp_avp_tree, tvb, index,
784 avp_len, "Vendor-Specific AVP");
791 proto_tree_add_uint(l2tp_avp_tree, hf_l2tp_avp_type,
792 tvb, index, 2, avp_type);
798 case CONTROL_MESSAGE:
799 msg_type = tvb_get_ntohs(tvb, index);
800 proto_tree_add_text(l2tp_avp_tree,tvb, index, 2,
801 "Control Message Type: (%u) %s", msg_type,
802 ((NUM_CONTROL_CALL_TYPES + 1 ) > msg_type) ?
803 calltypestr[msg_type] : "Unknown");
805 if (msg_type == AVP_StopCCN) {
810 case RESULT_ERROR_CODE:
813 result_code = tvb_get_ntohs(tvb, index);
815 proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
816 "Result code: %u - %s", result_code,
817 val_to_str(result_code, result_code_stopccn_vals, "Unknown (%u)"));
820 proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
821 "Result code: %u - %s", result_code,
822 val_to_str(result_code, result_code_cdn_vals, "Unknown (%u)"));
829 error_code = tvb_get_ntohs(tvb, index);
830 proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
831 "Error code: %u - %s", error_code,
832 val_to_str(error_code, error_code_vals, "Unknown (%u)"));
838 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
840 tvb_format_text(tvb, index, avp_len));
843 case PROTOCOL_VERSION:
846 proto_tree_add_text(l2tp_avp_tree, tvb, index, 1,
847 "Version: %u", tvb_get_guint8(tvb, index));
851 proto_tree_add_text(l2tp_avp_tree, tvb, index, 1,
852 "Revision: %u", tvb_get_guint8(tvb, index));
855 case FRAMING_CAPABILITIES:
856 bits = tvb_get_ntohl(tvb, index);
857 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
858 "Async Framing Supported: %s",
859 (FRAMING_ASYNC(bits)) ? "True" : "False");
860 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
861 "Sync Framing Supported: %s",
862 (FRAMING_SYNC(bits)) ? "True" : "False");
865 case BEARER_CAPABILITIES:
866 bits = tvb_get_ntohl(tvb, index);
867 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
868 "Analog Access Supported: %s",
869 (BEARER_ANALOG(bits)) ? "True" : "False");
870 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
871 "Digital Access Supported: %s",
872 (BEARER_DIGITAL(bits)) ? "True" : "False");
876 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_tie_breaker, tvb, index, 8, FALSE);
879 case FIRMWARE_REVISION:
880 firmware_rev = tvb_get_ntohs(tvb, index);
881 proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
882 "Firmware Revision: %d 0x%x", firmware_rev,firmware_rev );
886 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
888 tvb_format_text(tvb, index, avp_len));
892 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
894 tvb_format_text(tvb, index, avp_len));
897 case ASSIGNED_TUNNEL_ID:
898 proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
899 "Tunnel ID: %u", tvb_get_ntohs(tvb, index));
902 case RECEIVE_WINDOW_SIZE:
903 proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
904 "Receive Window Size: %u",
905 tvb_get_ntohs(tvb, index));
909 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
910 "CHAP Challenge: %s",
911 tvb_bytes_to_str(tvb, index, avp_len));
916 * XXX - export stuff from the Q.931 dissector
917 * to dissect the cause code and cause message,
922 proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
924 tvb_get_ntohs(tvb, index));
930 proto_tree_add_text(l2tp_avp_tree, tvb, index, 1,
932 tvb_get_guint8(tvb, index));
938 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
940 tvb_format_text(tvb, index, avp_len));
943 case CHALLENGE_RESPONSE:
944 proto_tree_add_text(l2tp_avp_tree, tvb, index, 16,
945 "CHAP Challenge Response: %s",
946 tvb_bytes_to_str(tvb, index, 16));
949 case ASSIGNED_SESSION:
950 proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
951 "Assigned Session: %u",
952 tvb_get_ntohs(tvb, index));
955 case CALL_SERIAL_NUMBER:
956 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
957 "Call Serial Number: %u",
958 tvb_get_ntohl(tvb, index));
962 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
964 tvb_get_ntohl(tvb, index));
968 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
970 tvb_get_ntohl(tvb, index));
974 bits = tvb_get_ntohl(tvb, index);
975 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
976 "Analog Bearer Type: %s",
977 (BEARER_ANALOG(bits)) ? "True" : "False");
978 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
979 "Digital Bearer Type: %s",
980 (BEARER_DIGITAL(bits)) ? "True" : "False");
984 bits = tvb_get_ntohl(tvb, index);
985 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
986 "Async Framing Type: %s",
987 (FRAMING_ASYNC(bits)) ? "True" : "False");
988 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
989 "Sync Framing Type: %s",
990 (FRAMING_SYNC(bits)) ? "True" : "False");
996 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
998 tvb_format_text(tvb, index, avp_len));
1001 case CALLING_NUMBER:
1004 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
1005 "Calling Number: %s",
1006 tvb_format_text(tvb, index, avp_len));
1012 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
1014 tvb_format_text(tvb, index, avp_len));
1017 case TX_CONNECT_SPEED:
1018 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
1019 "Connect Speed: %u",
1020 tvb_get_ntohl(tvb, index));
1023 case PHYSICAL_CHANNEL:
1024 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
1025 "Physical Channel: %u",
1026 tvb_get_ntohl(tvb, index));
1029 case INITIAL_RECEIVED_LCP_CONFREQ:
1030 te = proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
1031 "Initial Received LCP CONFREQ: %s",
1032 tvb_bytes_to_str(tvb, index, avp_len));
1033 l2tp_lcp_avp_tree = proto_item_add_subtree(te, ett_l2tp_lcp);
1034 next_tvb = tvb_new_subset(tvb, index, avp_len, avp_len);
1035 call_dissector(ppp_lcp_options_handle, next_tvb, pinfo, l2tp_lcp_avp_tree );
1038 case LAST_SENT_LCP_CONFREQ:
1039 te = proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
1040 "Last Sent LCP CONFREQ: %s",
1041 tvb_bytes_to_str(tvb, index, avp_len));
1042 l2tp_lcp_avp_tree = proto_item_add_subtree(te, ett_l2tp_lcp);
1043 next_tvb = tvb_new_subset(tvb, index, avp_len, avp_len);
1044 call_dissector(ppp_lcp_options_handle, next_tvb, pinfo, l2tp_lcp_avp_tree );
1047 case LAST_RECEIVED_LCP_CONFREQ:
1048 te = proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
1049 "Last Received LCP CONFREQ: %s",
1050 tvb_bytes_to_str(tvb, index, avp_len));
1051 l2tp_lcp_avp_tree = proto_item_add_subtree(te, ett_l2tp_lcp);
1052 next_tvb = tvb_new_subset(tvb, index, avp_len, avp_len);
1053 call_dissector(ppp_lcp_options_handle, next_tvb, pinfo, l2tp_lcp_avp_tree );
1056 case PROXY_AUTHEN_TYPE:
1057 msg_type = tvb_get_ntohs(tvb, index);
1058 proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
1059 "Proxy Authen Type: %s",
1060 val_to_str(msg_type, authen_type_vals, "Unknown (%u)"));
1063 case PROXY_AUTHEN_NAME:
1066 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
1067 "Proxy Authen Name: %s",
1068 tvb_format_text(tvb, index, avp_len));
1071 case PROXY_AUTHEN_CHALLENGE:
1072 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
1073 "Proxy Authen Challenge: %s",
1074 tvb_bytes_to_str(tvb, index, avp_len));
1077 case PROXY_AUTHEN_ID:
1078 proto_tree_add_text(l2tp_avp_tree, tvb, index + 1, 1,
1079 "Proxy Authen ID: %u",
1080 tvb_get_guint8(tvb, index + 1));
1083 case PROXY_AUTHEN_RESPONSE:
1084 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
1085 "Proxy Authen Response: %s",
1086 tvb_bytes_to_str(tvb, index, avp_len));
1089 case CALL_STATUS_AVPS:
1097 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
1098 "CRC Errors: %u", tvb_get_ntohl(tvb, index));
1104 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
1105 "Framing Errors: %u", tvb_get_ntohl(tvb, index));
1111 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
1112 "Hardware Overruns: %u", tvb_get_ntohl(tvb, index));
1118 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
1119 "Buffer Overruns: %u", tvb_get_ntohl(tvb, index));
1125 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
1126 "Time-out Errors: %u", tvb_get_ntohl(tvb, index));
1132 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
1133 "Alignment Errors: %u", tvb_get_ntohl(tvb, index));
1146 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
1147 "Send ACCM: %u", tvb_get_ntohl(tvb, index));
1153 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
1154 "Receive ACCM: %u", tvb_get_ntohl(tvb, index));
1160 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
1161 "Random Vector: %s",
1162 tvb_bytes_to_str(tvb, index, avp_len));
1165 case PRIVATE_GROUP_ID:
1166 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
1167 "Private Group ID: %s",
1168 tvb_bytes_to_str(tvb, index, avp_len));
1171 case RX_CONNECT_SPEED:
1172 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
1173 "Rx Connect Speed: %u",
1174 tvb_get_ntohl(tvb, index));
1177 case PPP_DISCONNECT_CAUSE_CODE:
1180 proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
1181 "Disconnect Code: %u",
1182 tvb_get_ntohs(tvb, index));
1188 proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
1189 "Control Protocol Number: %u",
1190 tvb_get_ntohs(tvb, index));
1196 proto_tree_add_text(l2tp_avp_tree, tvb, index, 1,
1198 val_to_str(tvb_get_guint8(tvb, index),
1199 cause_code_direction_vals,
1206 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
1208 tvb_format_text(tvb, index, avp_len));
1211 case MESSAGE_DIGEST:
1212 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
1213 "Message Digest: %s",
1214 tvb_bytes_to_str(tvb, index, avp_len));
1217 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
1219 tvb_get_ntohl(tvb, index));
1221 case ASSIGNED_CONTROL_CONN_ID:
1222 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
1223 "Assigned Control Connection ID: %u",
1224 tvb_get_ntohl(tvb, index));
1226 case PW_CAPABILITY_LIST:
1227 te = proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
1228 "Pseudowire Capabilities List");
1229 l2tp_avp_tree_sub = proto_item_add_subtree(te, ett_l2tp_avp_sub);
1231 while (avp_len >= 2) {
1232 int pw_type = tvb_get_ntohs(tvb, index);
1233 proto_tree_add_text(l2tp_avp_tree_sub, tvb, index,
1234 2, "PW Type: (%u) %s",
1236 val_to_str(pw_type, pw_types_vals,
1237 "Unknown (0x%04x)"));
1242 case LOCAL_SESSION_ID:
1243 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
1244 "Local Session ID: %u",
1245 tvb_get_ntohl(tvb, index));
1247 case REMOTE_SESSION_ID:
1248 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
1249 "Remote Session ID: %u",
1250 tvb_get_ntohl(tvb, index));
1252 case ASSIGNED_COOKIE:
1253 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
1254 "Assigned Cookie: %s",
1255 tvb_bytes_to_str(tvb, index, avp_len));
1258 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
1259 "Remote End ID: %s",
1260 tvb_format_text(tvb, index, avp_len));
1263 proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
1264 "Pseudowire Type: %u - %s",
1265 tvb_get_ntohs(tvb, index),
1266 val_to_str(tvb_get_ntohs(tvb, index),
1267 pw_types_vals, "Unknown (0x%04x)"));
1269 case L2_SPECIFIC_SUBLAYER:
1270 proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
1271 "Layer2 Specific Sublayer: %s",
1272 val_to_str(tvb_get_ntohs(tvb, index),
1273 l2_sublayer_vals, "Invalid (%u)"));
1275 case DATA_SEQUENCING:
1276 proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
1277 "Data Sequencing: %s",
1278 val_to_str(tvb_get_ntohs(tvb, index),
1279 data_sequencing_vals, "Invalid (%u)"));
1281 case CIRCUIT_STATUS:
1282 bits = tvb_get_ntohs(tvb, index);
1283 proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
1284 "Circuit Status: %s",
1285 (CIRCUIT_STATUS_BIT(bits)) ? "Up" : "Down");
1286 proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
1288 (CIRCUIT_TYPE_BIT(bits)) ? "New" : "Existing");
1290 case PREFERRED_LANGUAGE:
1291 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
1292 "Preferred Language: %s",
1293 tvb_format_text(tvb, index, avp_len));
1295 case CTL_MSG_AUTH_NONCE:
1296 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
1298 tvb_bytes_to_str(tvb, index, avp_len));
1300 case TX_CONNECT_SPEED_V3:
1302 guint32 l_int, h_int;
1306 h_int = tvb_get_ntohl(tvb, index);
1307 l_int = tvb_get_ntohl(tvb, index+4);
1308 if (!h_int && !l_int) {
1309 proto_tree_add_text(l2tp_avp_tree, tvb, index, 8,
1310 "Tx Connect Speed v3: indeterminable or no physical p2p link");
1313 proto_tree_add_text(l2tp_avp_tree, tvb, index, 8,
1314 "Tx Connect Speed v3: %#x%04x",
1319 case RX_CONNECT_SPEED_V3:
1321 guint32 l_int, h_int;
1325 h_int = tvb_get_ntohl(tvb, index);
1326 l_int = tvb_get_ntohl(tvb, index+4);
1327 if (!h_int && !l_int) {
1328 proto_tree_add_text(l2tp_avp_tree, tvb, index, 8,
1329 "Rx Connect Speed v3: indeterminable or no physical p2p link");
1332 proto_tree_add_text(l2tp_avp_tree, tvb, index, 8,
1333 "Rx Connect Speed v3: %#x%04x",
1339 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
1350 * Processes Data Messages for v3 IP and UDP, starting from the Session ID
1351 * (common to IP and UDP). Dissects the L2TPv3 Session header, the (optional)
1352 * L2-Specific sublayer and calls the appropriate dissector for the payload.
1355 process_l2tpv3_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
1356 proto_tree *l2tp_tree, proto_item *l2tp_item, int *pIndex)
1358 int index = *pIndex;
1360 guint8 oam_cell = 0;
1361 proto_tree *l2_specific = NULL;
1362 proto_item *ti = NULL;
1365 /* Get Session ID */
1366 sid = tvb_get_ntohl(tvb, index);
1369 if (check_col(pinfo->cinfo, COL_INFO)) {
1370 col_add_fstr(pinfo->cinfo,COL_INFO,
1371 "%s (session id=%u)",
1376 proto_tree_add_item(l2tp_tree, hf_l2tp_sid, tvb, index-4, 4, FALSE);
1377 proto_item_set_len(l2tp_item, index);
1378 if (!(tvb_offset_exists(tvb, index)))
1380 if (l2tpv3_cookie != 0)
1381 proto_tree_add_item(l2tp_tree, hf_l2tp_cookie, tvb, index, l2tpv3_cookie, FALSE);
1384 switch(l2tpv3_l2_specific){
1385 case L2TPv3_L2_SPECIFIC_DEFAULT:
1387 ti = proto_tree_add_item(tree, hf_l2tp_l2_spec_def,
1388 tvb, index + l2tpv3_cookie, 4, FALSE);
1389 l2_specific = proto_item_add_subtree(ti, ett_l2tp_l2_spec);
1391 proto_tree_add_item(l2_specific, hf_l2tp_l2_spec_s, tvb, index + l2tpv3_cookie,
1393 proto_tree_add_item(l2_specific, hf_l2tp_l2_spec_sequence, tvb,
1394 index + l2tpv3_cookie + 1, 3, FALSE);
1396 next_tvb = tvb_new_subset_remaining(tvb, index + l2tpv3_cookie + 4);
1398 case L2TPv3_L2_SPECIFIC_ATM:
1400 ti = proto_tree_add_item(tree, hf_l2tp_l2_spec_atm,
1401 tvb, index + l2tpv3_cookie, 4, FALSE);
1402 l2_specific = proto_item_add_subtree(ti, ett_l2tp_l2_spec);
1404 proto_tree_add_item(l2_specific, hf_l2tp_l2_spec_s, tvb, index + l2tpv3_cookie,
1406 proto_tree_add_item(l2_specific, hf_l2tp_l2_spec_t, tvb, index + l2tpv3_cookie,
1409 * As per RFC 4454, the T bit specifies whether
1410 * we're transporting an OAM cell or an AAL5 frame.
1412 oam_cell = tvb_get_guint8(tvb, index + l2tpv3_cookie) & 0x08;
1413 proto_tree_add_item(l2_specific, hf_l2tp_l2_spec_g, tvb, index + l2tpv3_cookie,
1415 proto_tree_add_item(l2_specific, hf_l2tp_l2_spec_c, tvb, index + l2tpv3_cookie,
1417 proto_tree_add_item(l2_specific, hf_l2tp_l2_spec_u, tvb, index + l2tpv3_cookie,
1419 proto_tree_add_item(l2_specific, hf_l2tp_l2_spec_sequence, tvb,
1420 index + l2tpv3_cookie + 1, 3, FALSE);
1422 next_tvb = tvb_new_subset_remaining(tvb, index + l2tpv3_cookie + 4);
1424 case L2TPv3_L2_SPECIFIC_LAPD:
1426 proto_tree_add_text(tree, tvb, index + l2tpv3_cookie + 4, 3,"LAPD info");
1427 next_tvb = tvb_new_subset_remaining(tvb, index + l2tpv3_cookie+4+3);
1429 case L2TPv3_L2_SPECIFIC_NONE:
1431 next_tvb = tvb_new_subset_remaining(tvb, index + l2tpv3_cookie);
1435 switch(l2tpv3_protocol){
1436 case L2TPv3_PROTOCOL_ETH:
1437 call_dissector(eth_withoutfcs_handle, next_tvb, pinfo, tree);
1439 case L2TPv3_PROTOCOL_CHDLC:
1440 call_dissector(chdlc_handle, next_tvb, pinfo, tree);
1442 case L2TPv3_PROTOCOL_FR:
1443 call_dissector(fr_handle, next_tvb, pinfo, tree);
1445 case L2TPv3_PROTOCOL_PPP:
1447 * PPP is transported without Address and Control
1448 * fields, ppp_hdlc_handle can handle that as if if
1449 * was ACFC (NULL Address and Control)
1451 call_dissector(ppp_hdlc_handle, next_tvb, pinfo, tree);
1453 case L2TPv3_PROTOCOL_IP:
1454 call_dissector(ip_handle, next_tvb, pinfo, tree);
1456 case L2TPv3_PROTOCOL_MPLS:
1457 call_dissector(mpls_handle, next_tvb, pinfo, tree);
1459 case L2TPv3_PROTOCOL_AAL5:
1461 call_dissector(atm_oam_handle, next_tvb, pinfo, tree);
1463 call_dissector(llc_handle, next_tvb, pinfo, tree);
1466 case L2TPv3_PROTOCOL_LAPD:
1467 call_dissector(lapd_handle, next_tvb, pinfo, tree);
1470 call_dissector(data_handle, next_tvb, pinfo, tree);
1476 * Processes v3 data message over UDP, to then call process_l2tpv3_data
1477 * from the common part (Session ID)
1480 process_l2tpv3_data_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1482 proto_tree *l2tp_tree = NULL, *ctrl_tree;
1483 proto_item *l2tp_item = NULL, *ti;
1489 control = tvb_get_ntohs(tvb, index);
1490 index += 2; /* skip ahead */
1491 index += 2; /* Skip the reserved */
1492 sid = tvb_get_ntohl(tvb, index);
1495 l2tp_item = proto_tree_add_item(tree, proto_l2tp, tvb, 0, -1, FALSE);
1496 l2tp_tree = proto_item_add_subtree(l2tp_item, ett_l2tp);
1497 proto_item_append_text(l2tp_item, " version 3");
1499 ti = proto_tree_add_text(l2tp_tree, tvb, 0, 2,
1500 "Packet Type: %s Session Id=%u",
1503 ctrl_tree = proto_item_add_subtree(ti, ett_l2tp_ctrl);
1504 proto_tree_add_uint(ctrl_tree, hf_l2tp_type, tvb, 0, 2, control);
1505 proto_tree_add_boolean(ctrl_tree, hf_l2tp_length_bit, tvb, 0, 2, control);
1506 proto_tree_add_boolean(ctrl_tree, hf_l2tp_seq_bit, tvb, 0, 2, control);
1507 proto_tree_add_uint(ctrl_tree, hf_l2tp_version, tvb, 0, 2, control);
1508 /* Data in v3 over UDP has this reserved */
1509 proto_tree_add_item(l2tp_tree, hf_l2tp_res, tvb, 2, 2, FALSE);
1512 /* Call process_l2tpv3_data from Session ID (offset in index of 4) */
1513 process_l2tpv3_data(tvb, pinfo, tree, l2tp_tree, l2tp_item, &index);
1517 * Processes v3 data message over IP, to then call process_l2tpv3_data
1518 * from the common part (Session ID)
1521 process_l2tpv3_data_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1523 proto_tree *l2tp_tree = NULL;
1524 proto_item *l2tp_item = NULL, *ti;
1529 sid = tvb_get_ntohl(tvb, index);
1532 l2tp_item = proto_tree_add_item(tree, proto_l2tp, tvb, 0, -1, FALSE);
1533 l2tp_tree = proto_item_add_subtree(l2tp_item, ett_l2tp);
1534 proto_item_append_text(l2tp_item, " version 3");
1536 ti = proto_tree_add_text(l2tp_tree, tvb, 0, 4,
1537 "Packet Type: %s Session Id=%u",
1541 /* Call process_l2tpv3_data from Session ID (offset in index of 0) */
1542 process_l2tpv3_data(tvb, pinfo, tree, l2tp_tree, l2tp_item, &index);
1546 * Processes v3 Control Message over IP, that carries NULL Session ID
1547 * to then call process_control_avps after dissecting the control.
1550 process_l2tpv3_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int baseIndex)
1552 proto_tree *l2tp_tree=NULL, *ctrl_tree;
1553 proto_item *l2tp_item = NULL, *ti;
1555 int index = baseIndex;
1557 guint16 length = 0; /* Length field */
1558 guint32 ccid = 0; /* Control Connection ID */
1561 guint16 control = 0;
1563 control = tvb_get_ntohs(tvb, index);
1564 index += 2; /* skip ahead */
1565 if (LENGTH_BIT(control)) { /* length field included ? */
1566 length = tvb_get_ntohs(tvb, index);
1570 /* Get Control Channel ID */
1571 ccid = tvb_get_ntohl(tvb, index);
1574 if (check_col(pinfo->cinfo, COL_INFO)) {
1577 if ((LENGTH_BIT(control))&&(length==12)) /* ZLB Message */
1578 col_add_fstr(pinfo->cinfo, COL_INFO,
1579 "%s - ZLB (tunnel id=%u)",
1580 control_msg , ccid);
1583 if (SEQUENCE_BIT(control)) {
1589 avp_type = tvb_get_ntohs(tvb, tmp_index);
1592 if (avp_type == CONTROL_MESSAGE) {
1593 /* We print message type */
1594 msg_type = tvb_get_ntohs(tvb, tmp_index);
1596 col_add_fstr(pinfo->cinfo, COL_INFO,
1597 "%s - %s (tunnel id=%u)",
1599 ((NUM_CONTROL_CALL_TYPES + 1 ) > msg_type) ?
1600 calltype_short_str[msg_type] : "Unknown",
1605 * This is not a control message.
1606 * We never pass here except in case of bad l2tp packet!
1608 col_add_fstr(pinfo->cinfo, COL_INFO,
1609 "%s (tunnel id=%u)",
1615 if (LENGTH_BIT(control)) {
1617 * Set the length of this tvbuff to be no longer than the length
1620 * XXX - complain if that length is longer than the length of
1621 * the tvbuff? Have "set_actual_length()" return a Boolean
1622 * and have its callers check the result?
1624 set_actual_length(tvb, length+baseIndex);
1628 l2tp_item = proto_tree_add_item(tree, proto_l2tp, tvb, 0, -1, FALSE);
1629 l2tp_tree = proto_item_add_subtree(l2tp_item, ett_l2tp);
1630 proto_item_append_text(l2tp_item, " version 3");
1633 proto_tree_add_item(l2tp_tree, hf_l2tp_sid, tvb, 0, 4, FALSE);
1635 ti = proto_tree_add_text(l2tp_tree, tvb, baseIndex, 2,
1636 "Packet Type: %s Control Connection Id=%d",
1637 (CONTROL_BIT(control) ? control_msg : data_msg), ccid);
1639 ctrl_tree = proto_item_add_subtree(ti, ett_l2tp_ctrl);
1640 proto_tree_add_uint(ctrl_tree, hf_l2tp_type, tvb, baseIndex, 2, control);
1641 proto_tree_add_boolean(ctrl_tree, hf_l2tp_length_bit, tvb, baseIndex, 2, control);
1642 proto_tree_add_boolean(ctrl_tree, hf_l2tp_seq_bit, tvb, baseIndex, 2, control);
1643 proto_tree_add_uint(ctrl_tree, hf_l2tp_version, tvb, baseIndex, 2, control);
1645 index = baseIndex + 2;
1646 if (LENGTH_BIT(control)) {
1648 proto_tree_add_item(l2tp_tree, hf_l2tp_length, tvb, index, 2, FALSE);
1654 proto_tree_add_item(l2tp_tree, hf_l2tp_ccid, tvb, index, 4, FALSE);
1658 if (SEQUENCE_BIT(control)) {
1660 proto_tree_add_item(l2tp_tree, hf_l2tp_Ns, tvb, index, 2, FALSE);
1664 proto_tree_add_item(l2tp_tree, hf_l2tp_Nr, tvb, index, 2, FALSE);
1669 if (tree && (LENGTH_BIT(control))&&(length==12)) {
1670 proto_tree_add_text(l2tp_tree, tvb, 0, 0, "Zero Length Bit message");
1673 if (!LENGTH_BIT(control)) {
1677 process_control_avps(tvb, pinfo, l2tp_tree, index, length+baseIndex);
1681 * Dissector for L2TP over UDP. For v2, calls process_control_avps for
1682 * control messages, or the ppp dissector based on the control bit.
1683 * For v3, calls either process_l2tpv3_control or process_l2tpv3_data_udp
1684 * based on the control bit.
1687 dissect_l2tp_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1689 proto_tree *l2tp_tree=NULL, *ctrl_tree;
1690 proto_item *l2tp_item = NULL, *ti;
1693 guint16 length = 0; /* Length field */
1694 guint16 tid; /* Tunnel ID */
1695 guint16 cid; /* Call ID */
1696 guint16 offset_size; /* Offset size */
1703 * Don't accept packets that aren't for an L2TP version we know,
1704 * as they might not be L2TP packets even though they happen
1705 * to be coming from or going to the L2TP port.
1707 if (tvb_length(tvb) < 2)
1708 return 0; /* not enough information to check */
1709 control = tvb_get_ntohs(tvb, 0);
1710 switch (L2TP_VERSION(control)) {
1720 if (check_col(pinfo->cinfo, COL_PROTOCOL)) /* build output for closed L2tp frame displayed */
1721 col_set_str(pinfo->cinfo, COL_PROTOCOL, "L2TP");
1722 col_clear(pinfo->cinfo, COL_INFO);
1724 switch (L2TP_VERSION(control)) {
1730 col_set_str(pinfo->cinfo, COL_PROTOCOL, "L2TPv3");
1731 if (CONTROL_BIT(control)) {
1732 /* Call to process l2tp v3 control message */
1733 process_l2tpv3_control(tvb, pinfo, tree, 0);
1736 /* Call to process l2tp v3 data message */
1737 process_l2tpv3_data_udp(tvb, pinfo, tree);
1739 return tvb_length(tvb);
1742 if (LENGTH_BIT(control)) { /* length field included ? */
1743 index += 2; /* skip ahead */
1744 length = tvb_get_ntohs(tvb, index);
1747 /* collect the tunnel id & call id */
1749 tid = tvb_get_ntohs(tvb, index);
1751 cid = tvb_get_ntohs(tvb, index);
1753 if (check_col(pinfo->cinfo, COL_INFO)) {
1754 if (CONTROL_BIT(control)) {
1755 /* CONTROL MESSAGE */
1758 if ((LENGTH_BIT(control))&&(length==12)) /* ZLB Message */
1759 col_add_fstr(pinfo->cinfo, COL_INFO,
1760 "%s - ZLB (tunnel id=%d, session id=%u)",
1761 control_msg, tid, cid);
1764 if (SEQUENCE_BIT(control)) {
1770 avp_type = tvb_get_ntohs(tvb, (tmp_index+=2));
1772 if (avp_type == CONTROL_MESSAGE) {
1773 /* We print message type */
1774 msg_type = tvb_get_ntohs(tvb, (tmp_index+=2));
1775 col_add_fstr(pinfo->cinfo, COL_INFO,
1776 "%s - %s (tunnel id=%u, session id=%u)",
1778 ((NUM_CONTROL_CALL_TYPES + 1 ) > msg_type) ?
1779 calltype_short_str[msg_type] : "Unknown",
1785 * This is not a control message.
1786 * We never pass here except in case of bad l2tp packet!
1788 col_add_fstr(pinfo->cinfo, COL_INFO,
1789 "%s (tunnel id=%u, session id=%u)",
1790 control_msg, tid, cid);
1797 col_add_fstr(pinfo->cinfo, COL_INFO,
1798 "%s (tunnel id=%u, session id=%u)",
1799 data_msg, tid, cid);
1803 if (LENGTH_BIT(control)) {
1805 * Set the length of this tvbuff to be no longer than the length
1808 * XXX - complain if that length is longer than the length of
1809 * the tvbuff? Have "set_actual_length()" return a Boolean
1810 * and have its callers check the result?
1812 set_actual_length(tvb, length);
1816 l2tp_item = proto_tree_add_item(tree,proto_l2tp, tvb, 0, -1, FALSE);
1817 l2tp_tree = proto_item_add_subtree(l2tp_item, ett_l2tp);
1819 ti = proto_tree_add_text(l2tp_tree, tvb, 0, 2,
1820 "Packet Type: %s Tunnel Id=%d Session Id=%d",
1821 (CONTROL_BIT(control) ? control_msg : data_msg), tid, cid);
1823 ctrl_tree = proto_item_add_subtree(ti, ett_l2tp_ctrl);
1824 proto_tree_add_uint(ctrl_tree, hf_l2tp_type, tvb, 0, 2, control);
1825 proto_tree_add_boolean(ctrl_tree, hf_l2tp_length_bit, tvb, 0, 2, control);
1826 proto_tree_add_boolean(ctrl_tree, hf_l2tp_seq_bit, tvb, 0, 2, control);
1827 proto_tree_add_boolean(ctrl_tree, hf_l2tp_offset_bit, tvb, 0, 2, control);
1828 proto_tree_add_boolean(ctrl_tree, hf_l2tp_priority, tvb, 0, 2, control);
1829 proto_tree_add_uint(ctrl_tree, hf_l2tp_version, tvb, 0, 2, control);
1832 if (LENGTH_BIT(control)) {
1834 proto_tree_add_item(l2tp_tree, hf_l2tp_length, tvb, index, 2, FALSE);
1840 proto_tree_add_item(l2tp_tree, hf_l2tp_tunnel, tvb, index, 2, FALSE);
1844 proto_tree_add_item(l2tp_tree, hf_l2tp_session, tvb, index, 2, FALSE);
1848 if (SEQUENCE_BIT(control)) {
1850 proto_tree_add_item(l2tp_tree, hf_l2tp_Ns, tvb, index, 2, FALSE);
1854 proto_tree_add_item(l2tp_tree, hf_l2tp_Nr, tvb, index, 2, FALSE);
1858 if (OFFSET_BIT(control)) {
1859 offset_size = tvb_get_ntohs(tvb, index);
1861 proto_tree_add_uint(l2tp_tree, hf_l2tp_offset, tvb, index, 2,
1865 if (offset_size != 0) {
1867 proto_tree_add_text(l2tp_tree, tvb, index, offset_size, "Offset Padding");
1869 index += offset_size;
1873 if (tree && (LENGTH_BIT(control))&&(length==12)) {
1874 proto_tree_add_text(l2tp_tree, tvb, 0, 0, "Zero Length Bit message");
1877 if (!CONTROL_BIT(control)) { /* Data Messages so we are done */
1879 proto_item_set_len(l2tp_item, index);
1880 /* If we have data, signified by having a length bit, dissect it */
1881 if (tvb_offset_exists(tvb, index)) {
1882 next_tvb = tvb_new_subset_remaining(tvb, index);
1883 call_dissector(ppp_hdlc_handle, next_tvb, pinfo, tree);
1885 return tvb_length(tvb);
1888 if (LENGTH_BIT(control))
1889 process_control_avps(tvb, pinfo, l2tp_tree, index, length);
1891 return tvb_length(tvb);
1896 * Only L2TPv3 runs directly over IP, and dissect_l2tp_ip starts dissecting
1897 * those packets to call either process_l2tpv3_control for Control Messages
1898 * or process_l2tpv3_data_ip for Data Messages over IP, based on the
1902 dissect_l2tp_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1905 guint32 sid; /* Session ID */
1907 if (check_col(pinfo->cinfo, COL_PROTOCOL)) /* Only L2TPv3 runs directly over IP */
1908 col_set_str(pinfo->cinfo, COL_PROTOCOL, "L2TPv3");
1910 col_clear(pinfo->cinfo, COL_INFO);
1912 sid = tvb_get_ntohl(tvb, index);
1914 /* This is control message */
1915 /* Call to process l2tp v3 control message */
1916 process_l2tpv3_control(tvb, pinfo, tree, 4);
1919 /* Call to process l2tp v3 data message */
1920 process_l2tpv3_data_ip(tvb, pinfo, tree);
1926 /* registration with the filtering engine */
1928 proto_register_l2tp(void)
1930 static hf_register_info hf[] = {
1932 { "Type", "l2tp.type", FT_UINT16, BASE_DEC, VALS(l2tp_type_vals), 0x8000,
1933 "Type bit", HFILL }},
1935 { &hf_l2tp_length_bit,
1936 { "Length Bit", "l2tp.length_bit", FT_BOOLEAN, 16, TFS(&l2tp_length_bit_truth), 0x4000,
1937 "Length bit", HFILL }},
1940 { "Sequence Bit", "l2tp.seq_bit", FT_BOOLEAN, 16, TFS(&l2tp_seq_bit_truth), 0x0800,
1941 "Sequence bit", HFILL }},
1943 { &hf_l2tp_offset_bit,
1944 { "Offset bit", "l2tp.offset_bit", FT_BOOLEAN, 16, TFS(&l2tp_offset_bit_truth), 0x0200,
1947 { &hf_l2tp_priority,
1948 { "Priority", "l2tp.priority", FT_BOOLEAN, 16, TFS(&l2tp_priority_truth), 0x0100,
1949 "Priority bit", HFILL }},
1952 { "Version", "l2tp.version", FT_UINT16, BASE_DEC, NULL, 0x000f,
1956 { "Length","l2tp.length", FT_UINT16, BASE_DEC, NULL, 0x0,
1960 { "Tunnel ID","l2tp.tunnel", FT_UINT16, BASE_DEC, NULL, 0x0, /* Probably should be FT_BYTES */
1964 { "Session ID","l2tp.session", FT_UINT16, BASE_DEC, NULL, 0x0, /* Probably should be FT_BYTES */
1968 { "Ns","l2tp.Ns", FT_UINT16, BASE_DEC, NULL, 0x0,
1972 { "Nr","l2tp.Nr", FT_UINT16, BASE_DEC, NULL, 0x0,
1976 { "Offset","l2tp.offset", FT_UINT16, BASE_DEC, NULL, 0x0,
1977 "Number of octest past the L2TP header at which thepayload data starts.", HFILL }},
1979 { &hf_l2tp_avp_mandatory,
1980 { "Mandatory", "l2tp.avp.mandatory", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
1981 "Mandatory AVP", HFILL }},
1983 { &hf_l2tp_avp_hidden,
1984 { "Hidden", "l2tp.avp.hidden", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
1985 "Hidden AVP", HFILL }},
1987 { &hf_l2tp_avp_length,
1988 { "Length", "l2tp.avp.length", FT_UINT16, BASE_DEC, NULL, 0,
1989 "AVP Length", HFILL }},
1991 { &hf_l2tp_avp_vendor_id,
1992 { "Vendor ID", "l2tp.avp.vendor_id", FT_UINT16, BASE_DEC, VALS(sminmpec_values), 0,
1993 "AVP Vendor ID", HFILL }},
1995 { &hf_l2tp_avp_type,
1996 { "Type", "l2tp.avp.type", FT_UINT16, BASE_DEC, VALS(avp_type_vals), 0,
1997 "AVP Type", HFILL }},
1999 { &hf_l2tp_tie_breaker,
2000 { "Tie Breaker", "l2tp.tie_breaker", FT_UINT64, BASE_HEX, NULL, 0,
2004 { "Session ID","l2tp.sid", FT_UINT32, BASE_DEC, NULL, 0x0,
2008 { "Control Connection ID","l2tp.ccid", FT_UINT32, BASE_DEC, NULL, 0x0,
2012 { "Reserved","l2tp.res", FT_UINT16, BASE_HEX, NULL, 0x0,
2016 { "Cookie","lt2p.cookie", FT_BYTES, BASE_NONE, NULL, 0x0,
2019 { &hf_l2tp_l2_spec_def,
2020 { "Default L2-Specific Sublayer","lt2p.l2_spec_def", FT_NONE, BASE_NONE, NULL, 0x0,
2023 { &hf_l2tp_l2_spec_atm,
2024 { "ATM-Specific Sublayer","lt2p.l2_spec_atm", FT_NONE, BASE_NONE, NULL, 0x0,
2027 { &hf_l2tp_l2_spec_s,
2028 { "S-bit","lt2p.l2_spec_s", FT_BOOLEAN, 8, NULL, 0x40,
2029 "Sequence Bit", HFILL }},
2031 { &hf_l2tp_l2_spec_t,
2032 { "T-bit","lt2p.l2_spec_t", FT_BOOLEAN, 8, NULL, 0x08,
2033 "Transport Type Bit", HFILL }},
2035 { &hf_l2tp_l2_spec_g,
2036 { "G-bit","lt2p.l2_spec_g", FT_BOOLEAN, 8, NULL, 0x04,
2037 "EFCI Bit", HFILL }},
2039 { &hf_l2tp_l2_spec_c,
2040 { "C-bit","lt2p.l2_spec_c", FT_BOOLEAN, 8, NULL, 0x02,
2041 "CLP Bit", HFILL }},
2043 { &hf_l2tp_l2_spec_u,
2044 { "U-bit","lt2p.l2_spec_u", FT_BOOLEAN, 8, NULL, 0x01,
2045 "C/R Bit", HFILL }},
2047 { &hf_l2tp_l2_spec_sequence,
2048 { "Sequence Number","lt2p.l2_spec_sequence", FT_UINT24, BASE_DEC, NULL, 0x0,
2051 { &hf_l2tp_cisco_avp_type,
2052 { "Type", "l2tp.avp.ciscotype", FT_UINT16, BASE_DEC, VALS(cisco_avp_type_vals), 0,
2053 "AVP Type", HFILL }},
2057 static gint *ett[] = {
2066 module_t *l2tp_module;
2068 proto_l2tp = proto_register_protocol(
2069 "Layer 2 Tunneling Protocol", "L2TP", "l2tp");
2070 proto_register_field_array(proto_l2tp, hf, array_length(hf));
2071 proto_register_subtree_array(ett, array_length(ett));
2073 l2tp_module = prefs_register_protocol(proto_l2tp, NULL);
2075 prefs_register_enum_preference(l2tp_module,
2077 "L2TPv3 Cookie Size",
2078 "L2TPv3 Cookie Size",
2083 prefs_register_enum_preference(l2tp_module,
2085 "L2TPv3 L2-Specific Sublayer",
2086 "L2TPv3 L2-Specific Sublayer",
2087 &l2tpv3_l2_specific,
2088 l2tpv3_l2_specifics,
2091 prefs_register_enum_preference(l2tp_module,
2093 "Decode L2TPv3 packet contents as this protocol",
2094 "Decode L2TPv3 packet contents as this protocol",
2102 proto_reg_handoff_l2tp(void)
2104 dissector_handle_t l2tp_udp_handle;
2105 dissector_handle_t l2tp_ip_handle;
2107 l2tp_udp_handle = new_create_dissector_handle(dissect_l2tp_udp, proto_l2tp);
2108 dissector_add("udp.port", UDP_PORT_L2TP, l2tp_udp_handle);
2110 l2tp_ip_handle = create_dissector_handle(dissect_l2tp_ip, proto_l2tp);
2111 dissector_add("ip.proto", IP_PROTO_L2TP, l2tp_ip_handle);
2114 * Get a handle for the PPP-in-HDLC-like-framing dissector.
2116 ppp_hdlc_handle = find_dissector("ppp_hdlc");
2117 ppp_lcp_options_handle = find_dissector("ppp_lcp_options");
2120 * Get a handle for the dissectors used in v3.
2122 eth_withoutfcs_handle = find_dissector("eth_withoutfcs");
2123 chdlc_handle = find_dissector("chdlc");
2124 fr_handle = find_dissector("fr");
2125 ip_handle = find_dissector("ip");
2126 mpls_handle = find_dissector("mpls");
2127 atm_oam_handle = find_dissector("atm_oam_cell");
2128 llc_handle = find_dissector("llc");
2129 lapd_handle = find_dissector("lapd");
2131 data_handle = find_dissector("data");