2 * Routines for Layer Two Tunnelling Protocol (L2TP) (RFC 2661) packet
4 * John Thomes <john@ensemblecom.com>
6 * Minor changes by: (2000-01-10)
7 * Laurent Cazalet <laurent.cazalet@mailclub.net>
8 * Thomas Parvais <thomas.parvais@advalvas.be>
10 * $Id: packet-l2tp.c,v 1.27 2001/10/29 21:13:07 guy Exp $
12 * Ethereal - Network traffic analyzer
13 * By Gerald Combs <gerald@ethereal.com>
14 * Copyright 1998 Gerald Combs
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation; either version 2
19 * of the License, or (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 static int proto_l2tp = -1;
33 static int hf_l2tp_type = -1;
34 static int hf_l2tp_length_bit = -1;
35 static int hf_l2tp_seq_bit = -1;
36 static int hf_l2tp_offset_bit = -1;
37 static int hf_l2tp_priority = -1;
38 static int hf_l2tp_version = -1;
39 static int hf_l2tp_length = -1;
40 static int hf_l2tp_tunnel = -1;
41 static int hf_l2tp_session = -1;
42 static int hf_l2tp_Ns = -1;
43 static int hf_l2tp_Nr = -1;
44 static int hf_l2tp_offset = -1;
45 static int hf_l2tp_avp_mandatory = -1;
46 static int hf_l2tp_avp_hidden = -1;
47 static int hf_l2tp_avp_length = -1;
48 static int hf_l2tp_avp_vendor_id = -1;
49 static int hf_l2tp_avp_type = -1;
50 static int hf_l2tp_tie_breaker = -1;
56 #ifdef HAVE_SYS_TYPES_H
57 # include <sys/types.h>
60 #ifdef HAVE_NETINET_IN_H
61 #include <netinet/in.h>
72 #define UDP_PORT_L2TP 1701
74 #define CONTROL_BIT(msg_info) (msg_info & 0x8000) /* Type bit control = 1 data = 0 */
75 #define LENGTH_BIT(msg_info) (msg_info & 0x4000) /* Length bit = 1 */
76 #define RESERVE_BITS(msg_info) (msg_info &0x37F8) /* Reserved bit - usused */
77 #define SEQUENCE_BIT(msg_info) (msg_info & 0x0800) /* SEQUENCE bit = 1 Ns and Nr fields */
78 #define OFFSET_BIT(msg_info) (msg_info & 0x0200) /* Offset */
79 #define PRIORITY_BIT(msg_info) (msg_info & 0x0100) /* Priority */
80 #define L2TP_VERSION(msg_info) (msg_info & 0x000f) /* Version of l2tp */
81 #define MANDATORY_BIT(msg_info) (msg_info & 0x8000) /* Mandatory = 1 */
82 #define HIDDEN_BIT(msg_info) (msg_info & 0x4000) /* Hidden = 1 */
83 #define AVP_LENGTH(msg_info) (msg_info & 0x03ff) /* AVP Length */
84 #define FRAMING_SYNC(msg_info) (msg_info & 0x0001) /* SYNC Framing Type */
85 #define FRAMING_ASYNC(msg_info) (msg_info & 0x0002) /* ASYNC Framing Type */
86 #define BEARER_DIGITAL(msg_info) (msg_info & 0x0001) /* Digital Bearer Type */
87 #define BEARER_ANALOG(msg_info) (msg_info & 0x0002) /* Analog Bearer Type */
89 static gint ett_l2tp = -1;
90 static gint ett_l2tp_ctrl = -1;
91 static gint ett_l2tp_avp = -1;
97 #define AVP_Reserved 5
105 #define AVP_Reserved1 13
109 #define NUM_CONTROL_CALL_TYPES 16
110 static const char *calltypestr[NUM_CONTROL_CALL_TYPES+1] = {
111 "Unknown Call Type ",
112 "Start_Control_Request ",
113 "Start_Control_Reply ",
114 "Start_Control_Connected ",
115 "Stop_Control_Notification ",
118 "Outgoing_Call_Request ",
119 "Outgoing_Call_Reply ",
120 "Outgoing_Call_Connected ",
121 "Incoming_Call_Request ",
122 "Incoming_Call_Reply ",
123 "Incoming_Call_Connected ",
125 "Call_Disconnect_Notification",
130 static const char *calltype_short_str[NUM_CONTROL_CALL_TYPES+1] = {
151 static const char *control_msg = "Control Message";
152 static const char *data_msg = "Data Message";
153 static const value_string l2tp_type_vals[] = {
154 { 0, "Data Message" },
155 { 1, "Control Message" },
159 static const value_string cause_code_direction_vals[] = {
160 { 0, "global error" },
166 static const true_false_string l2tp_length_bit_truth =
167 { "Length field is present", "Length field is not present" };
169 static const true_false_string l2tp_seq_bit_truth =
170 { "Ns and Nr fields are present", "Ns and Nr fields are not present" };
172 static const true_false_string l2tp_offset_bit_truth =
173 { "Offset Size field is present", "Offset size field is not present" };
175 static const true_false_string l2tp_priority_truth =
176 { "This data message has priority", "No priority" };
178 static const value_string authen_type_vals[] = {
180 { 1, "Textual username and password" },
183 { 4, "No Authentication" },
184 { 5, "Microsoft CHAP Version 1" },
188 #define CONTROL_MESSAGE 0
189 #define RESULT_ERROR_CODE 1
190 #define PROTOCOL_VERSION 2
191 #define FRAMING_CAPABILITIES 3
192 #define BEARER_CAPABILITIES 4
193 #define TIE_BREAKER 5
194 #define FIRMWARE_REVISION 6
196 #define VENDOR_NAME 8
197 #define ASSIGNED_TUNNEL_ID 9
198 #define RECEIVE_WINDOW_SIZE 10
200 #define CAUSE_CODE 12
201 #define CHALLENGE_RESPONSE 13
202 #define ASSIGNED_SESSION 14
203 #define CALL_SERIAL_NUMBER 15
204 #define MINIMUM_BPS 16
205 #define MAXIMUM_BPS 17
206 #define BEARER_TYPE 18
207 #define FRAMING_TYPE 19
208 #define CALLED_NUMBER 21
209 #define CALLING_NUMBER 22
210 #define SUB_ADDRESS 23
211 #define TX_CONNECT_SPEED 24
212 #define PHYSICAL_CHANNEL 25
213 #define INITIAL_RECEIVED_LCP 26
214 #define LAST_SEND_LCP_CONFREQ 27
215 #define LAST_RECEIVED_LCP_CONFREQ 28
216 #define PROXY_AUTHEN_TYPE 29
217 #define PROXY_AUTHEN_NAME 30
218 #define PROXY_AUTHEN_CHALLENGE 31
219 #define PROXY_AUTHEN_ID 32
220 #define PROXY_AUTHEN_RESPONSE 33
221 #define CALL_STATUS_AVPS 34
223 #define RANDOM_VECTOR 36
224 #define PRIVATE_GROUP_ID 37
225 #define RX_CONNECT_SPEED 38
226 #define SEQUENCING_REQUIRED 39
227 #define PPP_DISCONNECT_CAUSE_CODE 46 /* RFC 3145 */
229 #define NUM_AVP_TYPES 40
230 static const value_string avp_type_vals[] = {
231 { CONTROL_MESSAGE, "Control Message" },
232 { RESULT_ERROR_CODE, "Result-Error Code" },
233 { PROTOCOL_VERSION, "Protocol Version" },
234 { FRAMING_CAPABILITIES, "Framing Capabilities" },
235 { BEARER_CAPABILITIES, "Bearer Capabilities" },
236 { TIE_BREAKER, "Tie Breaker" },
237 { FIRMWARE_REVISION, "Firmware Revision" },
238 { HOST_NAME, "Host Name" },
239 { VENDOR_NAME, "Vendor Name" },
240 { ASSIGNED_TUNNEL_ID, "Assigned Tunnel ID" },
241 { RECEIVE_WINDOW_SIZE, "Receive Window Size" },
242 { CHALLENGE, "Challenge" },
243 { CAUSE_CODE, "Cause Code" },
244 { CHALLENGE_RESPONSE, "Challenge Response" },
245 { ASSIGNED_SESSION, "Assigned Session" },
246 { CALL_SERIAL_NUMBER, "Call Serial Number" },
247 { MINIMUM_BPS, "Minimum BPS" },
248 { MAXIMUM_BPS, "Maximum BPS" },
249 { BEARER_TYPE, "Bearer Type" },
250 { FRAMING_TYPE, "Framing Type" },
251 { CALLED_NUMBER, "Called Number" },
252 { CALLING_NUMBER, "Calling Number" },
253 { SUB_ADDRESS, "Sub-Address" },
254 { TX_CONNECT_SPEED, "Connect Speed" },
255 { PHYSICAL_CHANNEL, "Physical Channel" },
256 { INITIAL_RECEIVED_LCP, "Initial Received LCP" },
257 { LAST_SEND_LCP_CONFREQ, "Last Send LCP CONFREQ" },
258 { LAST_RECEIVED_LCP_CONFREQ, "Last Received LCP CONFREQ" },
259 { PROXY_AUTHEN_TYPE, "Proxy Authen Type" },
260 { PROXY_AUTHEN_NAME, "Proxy Authen Name" },
261 { PROXY_AUTHEN_CHALLENGE, "Proxy Authen Challenge" },
262 { PROXY_AUTHEN_ID, "Proxy Authen ID" },
263 { PROXY_AUTHEN_RESPONSE, "Proxy Authen Response" },
264 { CALL_STATUS_AVPS, "Call status AVPs" },
266 { RANDOM_VECTOR, "Random Vector" },
267 { PRIVATE_GROUP_ID, "Private group ID" },
268 { RX_CONNECT_SPEED, "RxConnect Speed" },
269 { SEQUENCING_REQUIRED, "Sequencing Required" },
270 { PPP_DISCONNECT_CAUSE_CODE, "PPP Disconnect Cause Code" },
275 * These are SMI Network Management Private Enterprise Codes for
278 * http://www.isi.edu/in-notes/iana/assignments/enterprise-numbers
282 #define VENDOR_IETF 0
284 #define VENDOR_CISCO 9
285 #define VENDOR_SHIVA 166
286 #define VENDOR_LIVINGSTON 307
287 #define VENDOR_3COM 429
288 #define VENDOR_ASCEND 529
289 #define VENDOR_BAY 1584
290 #define VENDOR_JUNIPER 2636
291 #define VENDOR_COSINE 3085
292 #define VENDOR_UNISPHERE 4874
294 static const value_string avp_vendor_id_vals[] =
295 {{VENDOR_IETF,"IETF"},
297 {VENDOR_CISCO,"Cisco"},
298 {VENDOR_SHIVA,"Shiva"},
299 {VENDOR_LIVINGSTON,"Livingston"},
300 {VENDOR_3COM,"3Com"},
301 {VENDOR_ASCEND,"Ascend"},
302 {VENDOR_BAY,"Bay Networks"},
303 {VENDOR_JUNIPER,"Juniper Networks"},
304 {VENDOR_COSINE,"CoSine Communications"},
305 {VENDOR_UNISPHERE,"Unisphere Networks"},
308 static gchar textbuffer[200];
310 static dissector_handle_t ppp_hdlc_handle;
313 dissect_l2tp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
315 proto_tree *l2tp_tree=NULL, *l2tp_avp_tree, *ctrl_tree;
320 int proto_length = 0;
321 guint16 length = 0; /* Length field */
322 guint16 tid; /* Tunnel ID */
323 guint16 cid; /* Call ID */
324 guint16 offset_size; /* Offset size */
325 guint16 ver_len_hidden;
326 guint16 avp_vendor_id;
333 guint16 firmware_rev;
337 if (check_col(pinfo->fd, COL_PROTOCOL)) /* build output for closed L2tp frame displayed */
338 col_set_str(pinfo->fd, COL_PROTOCOL, "L2TP");
339 if (check_col(pinfo->fd, COL_INFO))
340 col_clear(pinfo->fd, COL_INFO);
342 control = tvb_get_ntohs(tvb, 0);
344 if (L2TP_VERSION(control) != 2) {
345 if (check_col(pinfo->fd, COL_INFO)) {
346 col_add_fstr(pinfo->fd, COL_INFO, "L2TP Version %u", L2TP_VERSION(control) );
353 if (LENGTH_BIT(control)) { /* length field included ? */
354 index += 2; /* skip ahead */
355 length = tvb_get_ntohs(tvb, index);
358 /* collect the tunnel id & call id */
360 tid = tvb_get_ntohs(tvb, index);
362 cid = tvb_get_ntohs(tvb, index);
364 if (check_col(pinfo->fd, COL_INFO)) {
365 if (CONTROL_BIT(control)) {
366 /* CONTROL MESSAGE */
369 if ((LENGTH_BIT(control))&&(length==12)) /* ZLB Message */
370 sprintf(textbuffer,"%s - ZLB (tunnel id=%d, session id=%d)",
371 control_msg , tid ,cid);
374 if (SEQUENCE_BIT(control)) {
380 avp_type = tvb_get_ntohs(tvb, (tmp_index+=2));
382 if (avp_type == CONTROL_MESSAGE)
384 /* We print message type */
385 msg_type = tvb_get_ntohs(tvb, (tmp_index+=2));
386 sprintf(textbuffer,"%s - %s (tunnel id=%d, session id=%d)",
388 ((NUM_CONTROL_CALL_TYPES + 1 ) > msg_type) ?
389 calltype_short_str[msg_type] : "Unknown",
395 * This is not a control message.
396 * We never pass here except in case of bad l2tp packet!
398 sprintf(textbuffer,"%s (tunnel id=%d, session id=%d)",
399 control_msg , tid ,cid);
406 sprintf(textbuffer,"%s (tunnel id=%d, session id=%d)",
409 col_add_fstr(pinfo->fd,COL_INFO,textbuffer);
412 if (LENGTH_BIT(control)) {
413 proto_length = length;
416 proto_length = tvb_length(tvb);
420 ti = proto_tree_add_item(tree,proto_l2tp, tvb, 0, proto_length, FALSE);
421 l2tp_tree = proto_item_add_subtree(ti, ett_l2tp);
423 ti = proto_tree_add_text(l2tp_tree, tvb, 0, 2,
424 "Packet Type: %s Tunnel Id=%d Session Id=%d",
425 (CONTROL_BIT(control) ? control_msg : data_msg), tid, cid);
427 ctrl_tree = proto_item_add_subtree(ti, ett_l2tp_ctrl);
428 proto_tree_add_uint(ctrl_tree, hf_l2tp_type, tvb, 0, 2, control);
429 proto_tree_add_boolean(ctrl_tree, hf_l2tp_length_bit, tvb, 0, 2, control);
430 proto_tree_add_boolean(ctrl_tree, hf_l2tp_seq_bit, tvb, 0, 2, control);
431 proto_tree_add_boolean(ctrl_tree, hf_l2tp_offset_bit, tvb, 0, 2, control);
432 proto_tree_add_boolean(ctrl_tree, hf_l2tp_priority, tvb, 0, 2, control);
433 proto_tree_add_uint(ctrl_tree, hf_l2tp_version, tvb, 0, 2, control);
436 if (LENGTH_BIT(control)) {
438 proto_tree_add_item(l2tp_tree, hf_l2tp_length, tvb, index, 2, FALSE);
444 proto_tree_add_item(l2tp_tree, hf_l2tp_tunnel, tvb, index, 2, FALSE);
448 proto_tree_add_item(l2tp_tree, hf_l2tp_session, tvb, index, 2, FALSE);
452 if (SEQUENCE_BIT(control)) {
454 proto_tree_add_item(l2tp_tree, hf_l2tp_Ns, tvb, index, 2, FALSE);
458 proto_tree_add_item(l2tp_tree, hf_l2tp_Nr, tvb, index, 2, FALSE);
462 if (OFFSET_BIT(control)) {
463 offset_size = tvb_get_ntohs(tvb, index);
465 proto_tree_add_uint(l2tp_tree, hf_l2tp_offset, tvb, index, 2, FALSE);
469 proto_tree_add_text(l2tp_tree, tvb, index, offset_size, "Offset Padding");
471 index += offset_size;
473 if (tree && (LENGTH_BIT(control))&&(length==12)) {
474 proto_tree_add_text(l2tp_tree, tvb, 0, 0, "Zero Length Bit message");
477 if (!CONTROL_BIT(control)) { /* Data Messages so we are done */
478 /* If we have data, signified by having a length bit, dissect it */
479 if (tvb_offset_exists(tvb, index)) {
480 next_tvb = tvb_new_subset(tvb, index, -1, proto_length - index);
481 call_dissector(ppp_hdlc_handle, next_tvb, pinfo, tree);
487 if (!LENGTH_BIT(control)) {
490 while (index < length ) { /* Process AVP's */
491 ver_len_hidden = tvb_get_ntohs(tvb, index);
492 avp_len = AVP_LENGTH(ver_len_hidden);
493 avp_vendor_id = tvb_get_ntohs(tvb, index + 2);
494 avp_type = tvb_get_ntohs(tvb, index + 4);
496 if (avp_vendor_id == VENDOR_IETF) {
497 tf = proto_tree_add_text(l2tp_tree, tvb, index,
499 val_to_str(avp_type, avp_type_vals, "Unknown (%u)"));
500 } else { /* Vendor-Specific AVP */
501 tf = proto_tree_add_text(l2tp_tree, tvb, index,
502 avp_len, "Vendor %s AVP",
503 val_to_str(avp_vendor_id, avp_vendor_id_vals, "Unknown (%u)"));
506 l2tp_avp_tree = proto_item_add_subtree(tf, ett_l2tp_avp);
508 proto_tree_add_boolean_format(l2tp_avp_tree,hf_l2tp_avp_mandatory, tvb, index, 1,
509 rhcode, "Mandatory: %s",
510 (MANDATORY_BIT(ver_len_hidden)) ? "True" : "False" );
511 proto_tree_add_boolean_format(l2tp_avp_tree,hf_l2tp_avp_hidden, tvb, index, 1,
512 rhcode, "Hidden: %s",
513 (HIDDEN_BIT(ver_len_hidden)) ? "True" : "False" );
514 proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_avp_length, tvb, index, 2,
515 rhcode, "Length: %u", avp_len);
516 if (HIDDEN_BIT(ver_len_hidden)) { /* don't try do display hidden */
522 proto_tree_add_text(l2tp_avp_tree, tvb, index, 0,
523 "AVP length must not be zero");
529 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_vendor_id,
530 tvb, index, 2, FALSE);
534 if (avp_vendor_id != VENDOR_IETF) {
535 proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
536 "Type: %u", avp_type);
540 /* For the time being, we don't decode any Vendor-
542 proto_tree_add_text(l2tp_avp_tree, tvb, index,
543 avp_len, "Vendor-Specific AVP");
549 proto_tree_add_uint(l2tp_avp_tree, hf_l2tp_avp_type,
550 tvb, index, 2, avp_type);
556 case CONTROL_MESSAGE:
557 msg_type = tvb_get_ntohs(tvb, index);
558 proto_tree_add_text(l2tp_avp_tree,tvb, index, 2,
559 "Control Message Type: (%u) %s", msg_type,
560 ((NUM_CONTROL_CALL_TYPES + 1 ) > msg_type) ?
561 calltypestr[msg_type] : "Unknown");
564 case RESULT_ERROR_CODE:
567 result_code = tvb_get_ntohs(tvb, index);
568 proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
569 "Result code: %u", result_code);
575 error_code = tvb_get_ntohs(tvb, index);
576 proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
577 "Error code: %u", error_code);
583 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
584 "Error Message: %.*s", avp_len,
585 tvb_get_ptr(tvb, index, avp_len));
588 case PROTOCOL_VERSION:
591 proto_tree_add_text(l2tp_avp_tree, tvb, index, 1,
592 "Version: %u", tvb_get_guint8(tvb, index));
596 proto_tree_add_text(l2tp_avp_tree, tvb, index, 1,
597 "Revision: %u", tvb_get_guint8(tvb, index));
600 case FRAMING_CAPABILITIES:
601 bits = tvb_get_ntohl(tvb, index);
602 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
603 "Async Framing Supported: %s",
604 (FRAMING_ASYNC(bits)) ? "True" : "False");
605 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
606 "Sync Framing Supported: %s",
607 (FRAMING_SYNC(bits)) ? "True" : "False");
610 case BEARER_CAPABILITIES:
611 bits = tvb_get_ntohl(tvb, index);
612 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
613 "Analog Access Supported: %s",
614 (BEARER_ANALOG(bits)) ? "True" : "False");
615 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
616 "Digital Access Supported: %s",
617 (BEARER_DIGITAL(bits)) ? "True" : "False");
621 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_tie_breaker, tvb, index, 8, FALSE);
624 case FIRMWARE_REVISION:
625 firmware_rev = tvb_get_ntohs(tvb, index);
626 proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
627 "Firmware Revision: %d 0x%x", firmware_rev,firmware_rev );
631 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
632 "Host Name: %.*s", avp_len,
633 tvb_get_ptr(tvb, index, avp_len));
637 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
638 "Vendor Name: %.*s", avp_len,
639 tvb_get_ptr(tvb, index, avp_len));
642 case ASSIGNED_TUNNEL_ID:
643 proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
644 "Tunnel ID: %u", tvb_get_ntohs(tvb, index));
647 case RECEIVE_WINDOW_SIZE:
648 proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
649 "Receive Window Size: %u",
650 tvb_get_ntohs(tvb, index));
654 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
655 "CHAP Challenge: %s",
656 tvb_bytes_to_str(tvb, index, avp_len));
661 * XXX - export stuff from the Q.931 dissector
662 * to dissect the cause code and cause message,
667 proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
669 tvb_get_ntohs(tvb, index));
675 proto_tree_add_text(l2tp_avp_tree, tvb, index, 1,
677 tvb_get_guint8(tvb, index));
683 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
684 "Advisory Msg: %.*s", avp_len,
685 tvb_get_ptr(tvb, index, avp_len));
688 case CHALLENGE_RESPONSE:
689 proto_tree_add_text(l2tp_avp_tree, tvb, index, 16,
690 "CHAP Challenge Response: %s",
691 tvb_bytes_to_str(tvb, index, 16));
694 case ASSIGNED_SESSION:
695 proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
696 "Assigned Session: %u",
697 tvb_get_ntohs(tvb, index));
700 case CALL_SERIAL_NUMBER:
701 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
702 "Call Serial Number: %u",
703 tvb_get_ntohl(tvb, index));
707 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
709 tvb_get_ntohl(tvb, index));
713 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
715 tvb_get_ntohl(tvb, index));
719 bits = tvb_get_ntohl(tvb, index);
720 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
721 "Analog Bearer Type: %s",
722 (BEARER_ANALOG(bits)) ? "True" : "False");
723 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
724 "Digital Bearer Type: %s",
725 (BEARER_DIGITAL(bits)) ? "True" : "False");
729 bits = tvb_get_ntohl(tvb, index);
730 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
731 "Async Framing Type: %s",
732 (FRAMING_ASYNC(bits)) ? "True" : "False");
733 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
734 "Sync Framing Type: %s",
735 (FRAMING_SYNC(bits)) ? "True" : "False");
741 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
742 "Called Number: %.*s", avp_len,
743 tvb_get_ptr(tvb, index, avp_len));
749 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
750 "Calling Number: %.*s", avp_len,
751 tvb_get_ptr(tvb, index, avp_len));
757 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
758 "Sub-Address: %.*s", avp_len,
759 tvb_get_ptr(tvb, index, avp_len));
762 case TX_CONNECT_SPEED:
763 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
765 tvb_get_ntohl(tvb, index));
768 case PHYSICAL_CHANNEL:
769 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
770 "Physical Channel: %u",
771 tvb_get_ntohl(tvb, index));
774 case INITIAL_RECEIVED_LCP:
776 * XXX - can this be dissected by stuff in the
779 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
780 "Initial LCP CONFREQ: %s",
781 tvb_bytes_to_str(tvb, index, avp_len));
784 case LAST_SEND_LCP_CONFREQ:
786 * XXX - can this be dissected by stuff in the
789 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
790 "Last Sent LCP CONFREQ: %s",
791 tvb_bytes_to_str(tvb, index, avp_len));
794 case LAST_RECEIVED_LCP_CONFREQ:
796 * XXX - can this be dissected by stuff in the
799 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
800 "Last Received LCP CONFREQ: %s",
801 tvb_bytes_to_str(tvb, index, avp_len));
804 case PROXY_AUTHEN_TYPE:
805 msg_type = tvb_get_ntohs(tvb, index);
806 proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
807 "Proxy Authen Type: %s",
808 val_to_str(msg_type, authen_type_vals, "Unknown (%u)"));
811 case PROXY_AUTHEN_NAME:
814 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
815 "Proxy Authen Name: %.*s", avp_len,
816 tvb_get_ptr(tvb, index, avp_len));
819 case PROXY_AUTHEN_CHALLENGE:
820 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
821 "Proxy Authen Challenge: %s",
822 tvb_bytes_to_str(tvb, index, avp_len));
825 case PROXY_AUTHEN_ID:
826 proto_tree_add_text(l2tp_avp_tree, tvb, index + 1, 1,
827 "Proxy Authen ID: %u",
828 tvb_get_guint8(tvb, index + 1));
831 case PROXY_AUTHEN_RESPONSE:
832 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
833 "Proxy Authen Response: %s",
834 tvb_bytes_to_str(tvb, index, avp_len));
837 case CALL_STATUS_AVPS:
845 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
846 "CRC Errors: %u", tvb_get_ntohl(tvb, index));
852 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
853 "Framing Errors: %u", tvb_get_ntohl(tvb, index));
859 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
860 "Hardware Overruns: %u", tvb_get_ntohl(tvb, index));
866 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
867 "Buffer Overruns: %u", tvb_get_ntohl(tvb, index));
873 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
874 "Time-out Errors: %u", tvb_get_ntohl(tvb, index));
880 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
881 "Alignment Errors: %u", tvb_get_ntohl(tvb, index));
894 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
895 "Send ACCM: %u", tvb_get_ntohl(tvb, index));
901 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
902 "Receive ACCM: %u", tvb_get_ntohl(tvb, index));
908 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
910 tvb_bytes_to_str(tvb, index, avp_len));
913 case PRIVATE_GROUP_ID:
914 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
915 "Private Group ID: %s",
916 tvb_bytes_to_str(tvb, index, avp_len));
919 case RX_CONNECT_SPEED:
920 proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
921 "Rx Connect Speed: %u",
922 tvb_get_ntohl(tvb, index));
925 case PPP_DISCONNECT_CAUSE_CODE:
928 proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
929 "Disconnect Code: %u",
930 tvb_get_ntohs(tvb, index));
936 proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
937 "Control Protocol Number: %u",
938 tvb_get_ntohs(tvb, index));
944 proto_tree_add_text(l2tp_avp_tree, tvb, index, 1,
946 val_to_str(tvb_get_guint8(tvb, index),
947 cause_code_direction_vals,
954 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
955 "Message: %.*s", avp_len,
956 tvb_get_ptr(tvb, index, avp_len));
960 proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
965 /* printf("Avp Decode avp_len= %d index= %d length= %d %x\n ",avp_len,
966 index,length,length); */
974 /* registration with the filtering engine */
976 proto_register_l2tp(void)
978 static hf_register_info hf[] = {
980 { "Type", "lt2p.type", FT_UINT16, BASE_DEC, VALS(l2tp_type_vals), 0x8000,
981 "Type bit", HFILL }},
983 { &hf_l2tp_length_bit,
984 { "Length Bit", "lt2p.length_bit", FT_BOOLEAN, 16, TFS(&l2tp_length_bit_truth), 0x4000,
985 "Length bit", HFILL }},
988 { "Sequence Bit", "lt2p.seq_bit", FT_BOOLEAN, 16, TFS(&l2tp_seq_bit_truth), 0x0800,
989 "Sequence bit", HFILL }},
991 { &hf_l2tp_offset_bit,
992 { "Offset bit", "lt2p.offset_bit", FT_BOOLEAN, 16, TFS(&l2tp_offset_bit_truth), 0x0200,
993 "Offset bit", HFILL }},
996 { "Priority", "lt2p.priority", FT_BOOLEAN, 16, TFS(&l2tp_priority_truth), 0x0100,
997 "Priority bit", HFILL }},
1000 { "Version", "lt2p.version", FT_UINT16, BASE_DEC, NULL, 0x000f,
1001 "Version", HFILL }},
1004 { "Length","l2tp.length", FT_UINT16, BASE_DEC, NULL, 0x0,
1008 { "Tunnel ID","l2tp.tunnel", FT_UINT16, BASE_DEC, NULL, 0x0, /* Probably should be FT_BYTES */
1009 "Tunnel ID", HFILL }},
1012 { "Session ID","l2tp.session", FT_UINT16, BASE_DEC, NULL, 0x0, /* Probably should be FT_BYTES */
1013 "Session ID", HFILL }},
1016 { "Ns","l2tp.Ns", FT_UINT16, BASE_DEC, NULL, 0x0,
1020 { "Nr","l2tp.Nr", FT_UINT16, BASE_DEC, NULL, 0x0,
1024 { "Offset","l2tp.offset", FT_UINT16, BASE_DEC, NULL, 0x0,
1025 "Number of octest past the L2TP header at which the"
1026 "payload data starts.", HFILL }},
1028 { &hf_l2tp_avp_mandatory,
1029 { "Mandatory", "lt2p.avp.mandatory", FT_BOOLEAN, BASE_NONE, NULL, 0,
1030 "Mandatory AVP", HFILL }},
1032 { &hf_l2tp_avp_hidden,
1033 { "Hidden", "lt2p.avp.hidden", FT_BOOLEAN, BASE_NONE, NULL, 0,
1034 "Hidden AVP", HFILL }},
1036 { &hf_l2tp_avp_length,
1037 { "Length", "lt2p.avp.length", FT_UINT16, BASE_DEC, NULL, 0,
1038 "AVP Length", HFILL }},
1040 { &hf_l2tp_avp_vendor_id,
1041 { "Vendor ID", "lt2p.avp.vendor_id", FT_UINT16, BASE_DEC, VALS(avp_vendor_id_vals), 0,
1042 "AVP Vendor ID", HFILL }},
1044 { &hf_l2tp_avp_type,
1045 { "Type", "lt2p.avp.type", FT_UINT16, BASE_DEC, VALS(avp_type_vals), 0,
1046 "AVP Type", HFILL }},
1048 { &hf_l2tp_tie_breaker,
1049 { "Tie Breaker", "lt2p.tie_breaker", FT_UINT64, BASE_HEX, NULL, 0,
1050 "Tie Breaker", HFILL }},
1054 static gint *ett[] = {
1060 proto_l2tp = proto_register_protocol(
1061 "Layer 2 Tunneling Protocol", "L2TP", "l2tp");
1062 proto_register_field_array(proto_l2tp, hf, array_length(hf));
1063 proto_register_subtree_array(ett, array_length(ett));
1067 proto_reg_handoff_l2tp(void)
1069 dissector_add("udp.port", UDP_PORT_L2TP, dissect_l2tp,
1073 * Get a handle for the PPP-in-HDLC-like-framing dissector.
1075 ppp_hdlc_handle = find_dissector("ppp_hdlc");