* Laurent Cazalet <laurent.cazalet@mailclub.net>
* Thomas Parvais <thomas.parvais@advalvas.be>
*
- * $Id: packet-l2tp.c,v 1.6 2000/03/22 23:49:20 guy Exp $
+ * $Id: packet-l2tp.c,v 1.24 2001/06/18 02:17:48 guy Exp $
*
* Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * By Gerald Combs <gerald@ethereal.com>
* Copyright 1998 Gerald Combs
- *
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
static int proto_l2tp = -1;
+static int hf_l2tp_type = -1;
+static int hf_l2tp_length_bit = -1;
+static int hf_l2tp_seq_bit = -1;
+static int hf_l2tp_offset_bit = -1;
+static int hf_l2tp_priority = -1;
+static int hf_l2tp_version = -1;
static int hf_l2tp_length = -1;
-static int hf_l2tp_code = -1;
-static int hf_l2tp_id =-1;
+static int hf_l2tp_tunnel = -1;
+static int hf_l2tp_session = -1;
+static int hf_l2tp_Ns = -1;
+static int hf_l2tp_Nr = -1;
+static int hf_l2tp_offset = -1;
+static int hf_l2tp_avp_mandatory = -1;
+static int hf_l2tp_avp_hidden = -1;
+static int hf_l2tp_avp_length = -1;
+static int hf_l2tp_avp_vendor_id = -1;
+static int hf_l2tp_avp_type = -1;
#ifdef HAVE_CONFIG_H
#include "config.h"
#include "packet.h"
#include "resolv.h"
-
+#define UDP_PORT_L2TP 1701
#define CONTROL_BIT(msg_info) (msg_info & 0x8000) /* Type bit control = 1 data = 0 */
#define LENGTH_BIT(msg_info) (msg_info & 0x4000) /* Length bit = 1 */
#define RESERVE_BITS(msg_info) (msg_info &0x37F8) /* Reserved bit - usused */
#define SEQUENCE_BIT(msg_info) (msg_info & 0x0800) /* SEQUENCE bit = 1 Ns and Nr fields */
-#define OFFSET_BIT(msg_info) (msg_info & 0x0300) /* Offset */
+#define OFFSET_BIT(msg_info) (msg_info & 0x0200) /* Offset */
#define PRIORITY_BIT(msg_info) (msg_info & 0x0100) /* Priority */
-#define L2TP_VERSION(msg_info) (msg_info & 0x0007) /* Version of l2tp */
+#define L2TP_VERSION(msg_info) (msg_info & 0x000f) /* Version of l2tp */
#define MANDATORY_BIT(msg_info) (msg_info & 0x8000) /* Mandatory = 1 */
#define HIDDEN_BIT(msg_info) (msg_info & 0x4000) /* Hidden = 1 */
#define AVP_LENGTH(msg_info) (msg_info & 0x03ff) /* AVP Length */
-#define FRAMING_ASYNC(msg_info) (msg_info & 0x0001) /* ASYNCFraming Type */
-#define FRAMING_SYNC(msg_info) (msg_info & 0x0002) /* SYNC Type */
-
-
+#define FRAMING_SYNC(msg_info) (msg_info & 0x0001) /* SYNC Framing Type */
+#define FRAMING_ASYNC(msg_info) (msg_info & 0x0002) /* ASYNC Framing Type */
+#define BEARER_DIGITAL(msg_info) (msg_info & 0x0001) /* Digital Bearer Type */
+#define BEARER_ANALOG(msg_info) (msg_info & 0x0002) /* Analog Bearer Type */
static gint ett_l2tp = -1;
+static gint ett_l2tp_ctrl = -1;
static gint ett_l2tp_avp = -1;
#define AVP_SCCRQ 1
};
- static const char *control_msg="Control Message";
- static const char *data_msg="Data Message";
+static const char *control_msg = "Control Message";
+static const char *data_msg = "Data Message";
+static const value_string l2tp_type_vals[] = {
+ { 0, "Data Message" },
+ { 1, "Control Message" },
+ { 0, NULL },
+};
+static const true_false_string l2tp_length_bit_truth =
+ { "Length field is present", "Length field is not present" };
-#define NUM_AUTH_TYPES 6
-static const char *authen_types[NUM_AUTH_TYPES] = {
- "Reserved",
- "Textual username and password",
- "PPP CHAP",
- "PPP PAP",
- "No Authentication",
- "Microsoft CHAP Version 1",
+static const true_false_string l2tp_seq_bit_truth =
+ { "Ns and Nr fields are present", "Ns and Nr fields are not present" };
+
+static const true_false_string l2tp_offset_bit_truth =
+ { "Offset Size field is present", "Offset size field is not present" };
+
+static const true_false_string l2tp_priority_truth =
+ { "This data message has priority", "No priority" };
+
+static const value_string authen_type_vals[] = {
+ { 0, "Reserved" },
+ { 1, "Textual username and password" },
+ { 2, "PPP CHAP" },
+ { 3, "PPP PAP" },
+ { 4, "No Authentication" },
+ { 5, "Microsoft CHAP Version 1" },
+ { 0, NULL }
};
#define CONTROL_MESSAGE 0
#define RESULT_ERROR_CODE 1
#define PROTOCOL_VERSION 2
-#define FRAMING_CAPABIlITIES 3
-#define BEARER_CAPABIlITIES 4
+#define FRAMING_CAPABILITIES 3
+#define BEARER_CAPABILITIES 4
#define TIE_BREAKER 5
#define FIRMWARE_REVISION 6
#define HOST_NAME 7
#define MAXIMUM_BPS 17
#define BEARER_TYPE 18
#define FRAMING_TYPE 19
-#define UNKNOWN_MESSAGE 20
#define CALLED_NUMBER 21
#define CALLING_NUMBER 22
#define SUB_ADDRESS 23
#define PROXY_AUTHEN_RESPONSE 33
#define CALL_STATUS_AVPS 34
#define ACCM 35
-#define UNOWN_MESSAGE_36
+#define RANDOM_VECTOR 36
#define PRIVATE_GROUP_ID 37
#define RX_CONNECT_SPEED 38
#define SEQUENCING_REQUIRED 39
#define NUM_AVP_TYPES 40
-static const char *avptypestr[NUM_AVP_TYPES] = {
- "Control Message ",
- "Result-Error Code ",
- "Protocol Version ",
- "Framing Capabilities ",
- "Bearer Capabilities ",
- "Tie Breaker ",
- "Firmware Revision ",
- "Host Name ",
- "Vendor Name ",
- "Assigned Tunnel ID ",
- "Receive Window Size ",
- "Challlenge ",
- "Cause Code ",
- "Challenge Response ",
- "Assigned Session ",
- "Call Serial Number ",
- "Minimun BPS ",
- "Maximum bps ",
- "Bearer Type ",
- "Framing Type ",
- "Unknown Message ",
- "Called Number ",
- "Calling Number ",
- "Sub-Address ",
- "Connect Speed ",
- "Physical Channel ",
- "Initial Received lcP ",
- "Last Send LCP CONFREQ ",
- "Last Received LCP CONFREQ ",
- "Proxy Authen Type ",
- "Proxy Authen Name ",
- "Proxy Authen Challenge ",
- "Proxy Authen ID ",
- "Proxy Authen Response ",
- "Call status AVPs ",
- "ACCM ",
- "Unknown Message ",
- "Private group ID ",
- "RxConnect Speed ",
- "Sequencing Required ",
+static const value_string avp_type_vals[] = {
+ { CONTROL_MESSAGE, "Control Message" },
+ { RESULT_ERROR_CODE, "Result-Error Code" },
+ { PROTOCOL_VERSION, "Protocol Version" },
+ { FRAMING_CAPABILITIES, "Framing Capabilities" },
+ { BEARER_CAPABILITIES, "Bearer Capabilities" },
+ { TIE_BREAKER, "Tie Breaker" },
+ { FIRMWARE_REVISION, "Firmware Revision" },
+ { HOST_NAME, "Host Name" },
+ { VENDOR_NAME, "Vendor Name" },
+ { ASSIGNED_TUNNEL_ID, "Assigned Tunnel ID" },
+ { RECEIVE_WINDOW_SIZE, "Receive Window Size" },
+ { CHALLENGE, "Challenge" },
+ { CAUSE_CODE, "Cause Code" },
+ { CHALLENGE_RESPONSE, "Challenge Response" },
+ { ASSIGNED_SESSION, "Assigned Session" },
+ { CALL_SERIAL_NUMBER, "Call Serial Number" },
+ { MINIMUM_BPS, "Minimum BPS" },
+ { MAXIMUM_BPS, "Maximum BPS" },
+ { BEARER_TYPE, "Bearer Type" },
+ { FRAMING_TYPE, "Framing Type" },
+ { CALLED_NUMBER, "Called Number" },
+ { CALLING_NUMBER, "Calling Number" },
+ { SUB_ADDRESS, "Sub-Address" },
+ { TX_CONNECT_SPEED, "Connect Speed" },
+ { PHYSICAL_CHANNEL, "Physical Channel" },
+ { INITIAL_RECEIVED_LCP, "Initial Received LCP" },
+ { LAST_SEND_LCP_CONFREQ, "Last Send LCP CONFREQ" },
+ { LAST_RECEIVED_LCP_CONFREQ, "Last Received LCP CONFREQ" },
+ { PROXY_AUTHEN_TYPE, "Proxy Authen Type" },
+ { PROXY_AUTHEN_NAME, "Proxy Authen Name" },
+ { PROXY_AUTHEN_CHALLENGE, "Proxy Authen Challenge" },
+ { PROXY_AUTHEN_ID, "Proxy Authen ID" },
+ { PROXY_AUTHEN_RESPONSE, "Proxy Authen Response" },
+ { CALL_STATUS_AVPS, "Call status AVPs" },
+ { ACCM, "ACCM" },
+ { RANDOM_VECTOR, "Random Vector" },
+ { PRIVATE_GROUP_ID, "Private group ID" },
+ { RX_CONNECT_SPEED, "RxConnect Speed" },
+ { SEQUENCING_REQUIRED, "Sequencing Required" },
+ { 0, NULL }
};
static gchar textbuffer[200];
-void dissect_l2tp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
+
+static dissector_handle_t ppp_hdlc_handle;
+
+static void
+dissect_l2tp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
- proto_tree *l2tp_tree, *l2tp_avp_tree;
+ proto_tree *l2tp_tree=NULL, *l2tp_avp_tree, *ctrl_tree;
proto_item *ti, *tf;
int rhcode;
- u_char *tmp_ptr; /* temp pointer used during AVP decode */
- u_char *ptr; /* pointer used during l2tp decode */
- int index = 2; /* keeps track of depth into the AVP */
- unsigned short ver; /* Version and more */
- unsigned short length; /* Length field */
- unsigned short tid; /* Tunnel ID */
- unsigned short cid; /* Call ID */
- unsigned short Nr; /* Next recv */
- unsigned short Ns; /* Next sent */
- unsigned short ver_len_hidden;
- unsigned short vendor;
- unsigned short avp_type;
- unsigned short msg_type;
- unsigned short avp_len;
- unsigned short result_code;
- unsigned short error_code;
- unsigned short avp_ver;
- unsigned short avp_rev;
- unsigned short framing;
- unsigned short firmware_rev;
- unsigned short gen_type;
- unsigned long long_type;
- char error_string[100];
- char message_string[200];
-
- ptr = (u_char * )pd; /* point to the frame */
- ptr = ptr + offset; /* current offset into the decoded frame */
- memcpy(&ver,ptr,sizeof(unsigned short)); /* collect the version */
- ver = htons(ver);
+ int index = 0;
+ int tmp_index;
+ int proto_length = 0;
+ guint16 length = 0; /* Length field */
+ guint16 tid; /* Tunnel ID */
+ guint16 cid; /* Call ID */
+ guint16 offset_size; /* Offset size */
+ guint16 ver_len_hidden;
+ guint16 avp_type;
+ guint16 msg_type;
+ guint16 avp_len;
+ guint16 result_code;
+ guint16 error_code;
+ guint32 bits;
+ guint16 firmware_rev;
+ guint16 control;
+ tvbuff_t *next_tvb;
+
+ if (check_col(pinfo->fd, COL_PROTOCOL)) /* build output for closed L2tp frame displayed */
+ col_set_str(pinfo->fd, COL_PROTOCOL, "L2TP");
+ if (check_col(pinfo->fd, COL_INFO))
+ col_clear(pinfo->fd, COL_INFO);
+
+ control = tvb_get_ntohs(tvb, 0);
+
+ if (L2TP_VERSION(control) != 2) {
+ if (check_col(pinfo->fd, COL_INFO)) {
+ col_add_fstr(pinfo->fd, COL_INFO, "L2TP Version %u", L2TP_VERSION(control) );
+ }
+ return;
+ }
+
rhcode= 10;
- Ns = Nr = 0;
- if (LENGTH_BIT(ver)) { /* length field included ? */
- ptr += 2; index += 2; /* skip ahead */
- memcpy(&length,ptr,sizeof(unsigned short)); /* collect the length */
- length = (htons(length));
+ if (LENGTH_BIT(control)) { /* length field included ? */
+ index += 2; /* skip ahead */
+ length = tvb_get_ntohs(tvb, index);
}
- memcpy(&tid,(ptr+=2),sizeof(unsigned short)); /* collect the tunnel id & call id */
- memcpy(&cid,(ptr+=2),sizeof(unsigned short));
- index += 4;
- if (check_col(fd, COL_PROTOCOL)) /* build output for closed L2tp frame displayed */
- col_add_str(fd, COL_PROTOCOL, "L2TP");
- if (check_col(fd, COL_INFO)) {
- tid = htons(tid); cid = htons(cid);
+ /* collect the tunnel id & call id */
+ index += 2;
+ tid = tvb_get_ntohs(tvb, index);
+ index += 2;
+ cid = tvb_get_ntohs(tvb, index);
- if (CONTROL_BIT(ver)) {
+ if (check_col(pinfo->fd, COL_INFO)) {
+ if (CONTROL_BIT(control)) {
/* CONTROL MESSAGE */
- tmp_ptr = ptr;
+ tmp_index = index;
- if ((LENGTH_BIT(ver))&&(length==12)) /* ZLB Message */
+ if ((LENGTH_BIT(control))&&(length==12)) /* ZLB Message */
sprintf(textbuffer,"%s - ZLB (tunnel id=%d, session id=%d)",
control_msg , tid ,cid);
else
{
- if (SEQUENCE_BIT(ver)) {
- tmp_ptr=tmp_ptr+4;
+ if (SEQUENCE_BIT(control)) {
+ tmp_index += 4;
}
- tmp_ptr+=4;
+ tmp_index+=4;
- memcpy(&avp_type,(tmp_ptr+=2),sizeof(unsigned short));
- avp_type=htons(avp_type);
+ avp_type = tvb_get_ntohs(tvb, (tmp_index+=2));
if (avp_type == CONTROL_MESSAGE)
{
/* We print message type */
- memcpy(&msg_type,(tmp_ptr+=2),sizeof(unsigned short));
- msg_type=ntohs(msg_type);
+ msg_type = tvb_get_ntohs(tvb, (tmp_index+=2));
sprintf(textbuffer,"%s - %s (tunnel id=%d, session id=%d)",
control_msg ,
((NUM_CONTROL_CALL_TYPES + 1 ) > msg_type) ?
sprintf(textbuffer,"%s (tunnel id=%d, session id=%d)",
data_msg, tid ,cid);
}
- col_add_fstr(fd,COL_INFO,textbuffer);
+ col_add_fstr(pinfo->fd,COL_INFO,textbuffer);
}
- if (tree) {
- ti = proto_tree_add_item(tree,proto_l2tp, offset, length , NULL);
- l2tp_tree = proto_item_add_subtree(ti, ett_l2tp);
- proto_tree_add_uint_format(l2tp_tree,hf_l2tp_code, offset ,1,
- rhcode, "Packet Type: %s Tunnel Id=%d Session Id=%d",( CONTROL_BIT(ver) ? control_msg : data_msg) ,tid,cid);
- if (LENGTH_BIT(ver)) {
- proto_tree_add_uint_format(l2tp_tree,hf_l2tp_code, (offset += 2), 2,
- rhcode, "Length: %d ", length);
- }
- if (SEQUENCE_BIT(ver)) {
- memcpy(&Ns,(ptr+=2),sizeof(unsigned short));
- memcpy(&Nr,(ptr+=2),sizeof(unsigned short));
- index += 4;
- proto_tree_add_uint_format(l2tp_tree,hf_l2tp_code, (offset += 6 ), 4,
- rhcode, "Ns: %d Nr: %d ", htons(Ns), htons(Nr));
- }
- if ((LENGTH_BIT(ver))&&(length==12)) {
- proto_tree_add_uint_format(l2tp_tree,hf_l2tp_code,offset,1,rhcode,
- "Zero Length Bit message");
- }
- if (!CONTROL_BIT(ver)) { /* Data Messages so we are done */
- proto_tree_add_uint_format(l2tp_tree,hf_l2tp_code, (offset += 4) , (length - 12 ) , rhcode, "Data: ");
- return;
- }
-
- offset += 4;
- while (index < length ) { /* Process AVP's */
- tmp_ptr = ptr;
- memcpy(&ver_len_hidden,(tmp_ptr+=2),sizeof(unsigned short));
- avp_len = AVP_LENGTH(htons(ver_len_hidden));
- index += avp_len; /* track how far into the control msg */
- memcpy(&vendor,(tmp_ptr+=2),sizeof(unsigned short));
- memcpy(&avp_type,(tmp_ptr+=2),sizeof(unsigned short));
- avp_type=htons(avp_type);
- tf = proto_tree_add_uint_format(l2tp_tree,hf_l2tp_code, offset , avp_len,
- rhcode, "AVP Type %s ", (NUM_AVP_TYPES > avp_type)
- ? avptypestr[avp_type] : "Unknown");
- l2tp_avp_tree = proto_item_add_subtree(tf, ett_l2tp_avp);
-
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code, offset , 1,
- rhcode, " Mandatory:%s" , (MANDATORY_BIT(htons(ver_len_hidden))) ? "True" : "False" );
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code, offset , 1,
- rhcode, " Hidden:%s" , (HIDDEN_BIT(htons(ver_len_hidden))) ? "True" : "False" );
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code, (offset + 1), 1,
- rhcode, " Length:%d" , avp_len );
-
- if (HIDDEN_BIT(htons(ver_len_hidden))) { /* don't try do display hidden */
- ptr = ptr + avp_len;
- continue;
- }
-
- switch (avp_type) {
-
- case CONTROL_MESSAGE:
- memcpy(&msg_type,(tmp_ptr+=2),sizeof(unsigned short));
- msg_type=htons(msg_type);
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code, offset + 6, 2 ,
- rhcode, " Control Message Type: (%d) %s", msg_type,
- ((NUM_CONTROL_CALL_TYPES + 1 ) > msg_type) ?
- calltypestr[msg_type] : "Unknown" );
- break;
-
- case RESULT_ERROR_CODE:
- if ( avp_len >= 8 ) {
- memcpy(&result_code,(tmp_ptr+=2),sizeof(unsigned short));
- result_code=htons(result_code);
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset + 6,
- 2, rhcode,
- " Result code: %d", result_code );
-
- }
- if ( avp_len >= 10 ) {
- memcpy(&error_code,(tmp_ptr+=2),sizeof(unsigned short));
- error_code=htons(error_code);
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset + 8,
- 2, rhcode,
- " Error code: %d", error_code);
- }
- if ( avp_len > 10 ) {
- memset(error_string,'\0' ,sizeof(error_string));
- strncpy(error_string,(tmp_ptr),(avp_len - 10));
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code, offset + 10, (avp_len - 10),
- rhcode, " Error Message: %s", error_string );
- }
- break;
-
- case PROTOCOL_VERSION:
- tmp_ptr+=2;
- memcpy(&avp_ver,(tmp_ptr),sizeof(unsigned short));
- memcpy(&avp_rev,(tmp_ptr),sizeof(unsigned short));
- avp_ver=(htons(avp_ver));
- avp_rev=(htons(avp_rev));
- memcpy(&avp_rev,(tmp_ptr+=2),sizeof(unsigned short));
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code, offset + 6, 1,
- rhcode, " Version: %d", ((avp_ver&0xff00)>>8) );
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code, offset + 7, 1,
- rhcode, " Revision: %d", (avp_ver&0x00ff));
- break;
-
- case FRAMING_CAPABIlITIES:
- tmp_ptr+=2;
- memcpy(&framing,(tmp_ptr+=2),sizeof(unsigned short));
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code, offset + 6, 4,
- rhcode, " ASYNC FRAMING: %s" , (FRAMING_ASYNC(htons(framing))) ? "True" : "False" );
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code, offset + 6, 4,
- rhcode, " SYNC FRAMING: %s" , (FRAMING_SYNC(htons(framing))) ? "True" : "False" );
- break;
-
- case BEARER_CAPABIlITIES:
- tmp_ptr+=2;
- memcpy(&framing,(tmp_ptr+=2),sizeof(unsigned short));
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code, offset + 6, 4 ,
- rhcode, " Analog Access: %s" , (FRAMING_ASYNC(htons(framing))) ? "True" : "False" );
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code, offset + 6, 4,
- rhcode, " Digital Access: %s" , (FRAMING_SYNC(htons(framing))) ? "True" : "False" );
- break;
-
- case TIE_BREAKER:
- memcpy(&long_type,(tmp_ptr+=8),sizeof(unsigned long));
- long_type = htonl(long_type);
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code, offset + 6, 1,
- rhcode, " TIE_BREAKER %lu 0x%lx", long_type,long_type );
- break;
-
- case FIRMWARE_REVISION:
- memcpy(&firmware_rev,(tmp_ptr+=2),sizeof(unsigned short));
- firmware_rev=htons(firmware_rev);
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code, offset + 6, 2,
- rhcode, " Firmware Revision: %d 0x%x", firmware_rev,firmware_rev );
- break;
-
- case HOST_NAME:
- memset(error_string,'\0',sizeof(error_string));
- strncpy(error_string,(tmp_ptr+=2),(avp_len - 6));
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code, offset + 6,
- (avp_len - 6), rhcode, " Host Name: %s", error_string );
- break;
-
- case VENDOR_NAME:
- memset(message_string,'\0' ,sizeof(message_string));
- strncpy(message_string,(tmp_ptr+=2),(avp_len - 6));
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code, offset + 6,
- (avp_len - 6), rhcode, " Vendor Name: %s", message_string );
- break;
-
- case ASSIGNED_TUNNEL_ID:
- memcpy(&gen_type,(tmp_ptr+=2),sizeof(unsigned short));
- gen_type=htons(gen_type);
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset + 6,
- 2, rhcode, " Tunnel ID: %d", gen_type );
- break;
-
- case RECEIVE_WINDOW_SIZE:
- memcpy(&gen_type,(tmp_ptr+=2),sizeof(unsigned short));
- gen_type=htons(gen_type);
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset + 6,
- 2, rhcode, " Receive Window Size: %d", gen_type );
- break;
-
- case CHALLENGE:
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset + 6,
- (avp_len - 6 ), rhcode, " CHAP Challenge: ");
- break;
-
- case CHALLENGE_RESPONSE:
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset + 6,
- (avp_len - 6 ), rhcode, " CHAP Challenge Response: ");
- break;
- case CAUSE_CODE:
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset + 6,
- 1, rhcode, " Cause Code: ");
- break;
+ if (LENGTH_BIT(control)) {
+ proto_length = length;
+ }
+ else {
+ proto_length = tvb_length(tvb);
+ }
- case ASSIGNED_SESSION:
- memcpy(&gen_type,(tmp_ptr+=2),sizeof(unsigned short));
- gen_type=htons(gen_type);
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset + 6,
- 2, rhcode, " Assigned Session: %d", gen_type );
- break;
+ if (tree) {
+ ti = proto_tree_add_item(tree,proto_l2tp, tvb, 0, proto_length, FALSE);
+ l2tp_tree = proto_item_add_subtree(ti, ett_l2tp);
- case CALL_SERIAL_NUMBER:
- memcpy(&gen_type,(tmp_ptr+=2),sizeof(unsigned short));
- gen_type=htons(gen_type);
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset + 6,
- 4, rhcode, " Call Serial Number: %d", gen_type );
- break;
+ ti = proto_tree_add_text(l2tp_tree, tvb, 0, 2,
+ "Packet Type: %s Tunnel Id=%d Session Id=%d",
+ (CONTROL_BIT(control) ? control_msg : data_msg), tid, cid);
+
+ ctrl_tree = proto_item_add_subtree(ti, ett_l2tp_ctrl);
+ proto_tree_add_uint(ctrl_tree, hf_l2tp_type, tvb, 0, 2, control);
+ proto_tree_add_boolean(ctrl_tree, hf_l2tp_length_bit, tvb, 0, 2, control);
+ proto_tree_add_boolean(ctrl_tree, hf_l2tp_seq_bit, tvb, 0, 2, control);
+ proto_tree_add_boolean(ctrl_tree, hf_l2tp_offset_bit, tvb, 0, 2, control);
+ proto_tree_add_boolean(ctrl_tree, hf_l2tp_priority, tvb, 0, 2, control);
+ proto_tree_add_uint(ctrl_tree, hf_l2tp_version, tvb, 0, 2, control);
+ }
+ index = 2;
+ if (LENGTH_BIT(control)) {
+ if (tree) {
+ proto_tree_add_item(l2tp_tree, hf_l2tp_length, tvb, index, 2, FALSE);
+ }
+ index += 2;
+ }
- case MINIMUM_BPS:
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset + 6,
- 4, rhcode, " Minimum BPS: ");
- break;
+ if (tree) {
+ proto_tree_add_item(l2tp_tree, hf_l2tp_tunnel, tvb, index, 2, FALSE);
+ }
+ index += 2;
+ if (tree) {
+ proto_tree_add_item(l2tp_tree, hf_l2tp_session, tvb, index, 2, FALSE);
+ }
+ index += 2;
+
+ if (SEQUENCE_BIT(control)) {
+ if (tree) {
+ proto_tree_add_item(l2tp_tree, hf_l2tp_Ns, tvb, index, 2, FALSE);
+ }
+ index += 2;
+ if (tree) {
+ proto_tree_add_item(l2tp_tree, hf_l2tp_Nr, tvb, index, 2, FALSE);
+ }
+ index += 2;
+ }
+ if (OFFSET_BIT(control)) {
+ offset_size = tvb_get_ntohs(tvb, index);
+ if (tree) {
+ proto_tree_add_uint(l2tp_tree, hf_l2tp_offset, tvb, index, 2, FALSE);
+ }
+ index += 2;
+ if (tree) {
+ proto_tree_add_text(l2tp_tree, tvb, index, offset_size, "Offset Padding");
+ }
+ index += offset_size;
+ }
+ if (tree && (LENGTH_BIT(control))&&(length==12)) {
+ proto_tree_add_text(l2tp_tree, tvb, 0, 0, "Zero Length Bit message");
+ }
- case MAXIMUM_BPS:
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset + 6,
- 4, rhcode, " Maximum BPS ");
- break;
+ if (!CONTROL_BIT(control)) { /* Data Messages so we are done */
+ /* If we have data, signified by having a length bit, dissect it */
+ if (tvb_offset_exists(tvb, index)) {
+ next_tvb = tvb_new_subset(tvb, index, -1, proto_length - index);
+ call_dissector(ppp_hdlc_handle, next_tvb, pinfo, tree);
+ }
+ return;
+ }
- case BEARER_TYPE:
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset + 6,
- 4, rhcode, " Bearer Type: ");
- break;
+ if (tree) {
+ if (!LENGTH_BIT(control)) {
+ return;
+ }
+ while (index < length ) { /* Process AVP's */
+ ver_len_hidden = tvb_get_ntohs(tvb, index);
+ avp_len = AVP_LENGTH(ver_len_hidden);
+ avp_type = tvb_get_ntohs(tvb, index + 4);
- case FRAMING_TYPE:
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset + 6,
- 4, rhcode, " Framing Type: ");
- break;
+ tf = proto_tree_add_text(l2tp_tree, tvb, index, avp_len,
+ "%s AVP",
+ val_to_str(avp_type, avp_type_vals, "Unknown (%u)"));
+ l2tp_avp_tree = proto_item_add_subtree(tf, ett_l2tp_avp);
- case UNKNOWN_MESSAGE:
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset + 6,
- 1, rhcode, " Unknown Message: ");
- break;
+ proto_tree_add_boolean_format(l2tp_avp_tree,hf_l2tp_avp_mandatory, tvb, index, 1,
+ rhcode, "Mandatory: %s",
+ (MANDATORY_BIT(ver_len_hidden)) ? "True" : "False" );
+ proto_tree_add_boolean_format(l2tp_avp_tree,hf_l2tp_avp_hidden, tvb, index, 1,
+ rhcode, "Hidden: %s",
+ (HIDDEN_BIT(ver_len_hidden)) ? "True" : "False" );
+ proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_avp_length, tvb, index, 2,
+ rhcode, "Length: %u", avp_len);
+ if (HIDDEN_BIT(ver_len_hidden)) { /* don't try do display hidden */
+ index += avp_len;
+ continue;
+ }
- case CALLED_NUMBER:
- memset(message_string,'\0' ,sizeof(message_string));
- strncpy(message_string,(tmp_ptr+=2),(avp_len - 6));
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code, offset + 6,
- (avp_len - 6), rhcode, " Called Number: %s", message_string );
- break;
+ if (avp_len == 0) {
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, 0,
+ "AVP length must not be zero");
+ return;
+ }
+ index += 2;
+ avp_len -= 2;
+
+ proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_vendor_id,
+ tvb, index, 2, FALSE);
+ index += 2;
+ avp_len -= 2;
+
+ proto_tree_add_uint(l2tp_avp_tree, hf_l2tp_avp_type,
+ tvb, index, 2, avp_type);
+ index += 2;
+ avp_len -= 2;
+
+ switch (avp_type) {
+
+ case CONTROL_MESSAGE:
+ msg_type = tvb_get_ntohs(tvb, index);
+ proto_tree_add_text(l2tp_avp_tree,tvb, index, 2,
+ "Control Message Type: (%u) %s", msg_type,
+ ((NUM_CONTROL_CALL_TYPES + 1 ) > msg_type) ?
+ calltypestr[msg_type] : "Unknown");
+ break;
+
+ case RESULT_ERROR_CODE:
+ if (avp_len < 2)
+ break;
+ result_code = tvb_get_ntohs(tvb, index);
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
+ "Result code: %u", result_code);
+ index += 2;
+ avp_len -= 2;
+
+ if (avp_len < 2)
+ break;
+ error_code = tvb_get_ntohs(tvb, index);
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
+ "Error code: %u", error_code);
+ index += 2;
+ avp_len -= 2;
+
+ if (avp_len == 0)
+ break;
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
+ "Error Message: %.*s", avp_len,
+ tvb_get_ptr(tvb, index, avp_len));
+ break;
+
+ case PROTOCOL_VERSION:
+ if (avp_len < 1)
+ break;
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, 1,
+ "Version: %u", tvb_get_guint8(tvb, index));
+ index += 1;
+ avp_len -= 1;
+
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, 1,
+ "Revision: %u", tvb_get_guint8(tvb, index));
+ break;
+
+ case FRAMING_CAPABILITIES:
+ bits = tvb_get_ntohl(tvb, index);
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
+ "Async Framing Supported: %s",
+ (FRAMING_ASYNC(bits)) ? "True" : "False");
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
+ "Sync Framing Supported: %s",
+ (FRAMING_SYNC(bits)) ? "True" : "False");
+ break;
+
+ case BEARER_CAPABILITIES:
+ bits = tvb_get_ntohl(tvb, index);
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
+ "Analog Access Supported: %s",
+ (BEARER_ANALOG(bits)) ? "True" : "False");
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
+ "Digital Access Supported: %s",
+ (BEARER_DIGITAL(bits)) ? "True" : "False");
+ break;
+
+ case TIE_BREAKER:
+ /*
+ * XXX - 64-bit values aren't supported on
+ * platforms/compilers where "guint64" isn't
+ * supported, and, even on those platforms,
+ * there's no *printf standard for the format
+ * to use when printing those values, so we print it
+ * as a string of hex digits.
+ */
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, 8,
+ "Tie Breaker: %s",
+ tvb_bytes_to_str(tvb, index, 8));
+ break;
+
+ case FIRMWARE_REVISION:
+ firmware_rev = tvb_get_ntohs(tvb, index);
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
+ "Firmware Revision: %d 0x%x", firmware_rev,firmware_rev );
+ break;
+
+ case HOST_NAME:
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
+ "Host Name: %.*s", avp_len,
+ tvb_get_ptr(tvb, index, avp_len));
+ break;
+
+ case VENDOR_NAME:
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
+ "Vendor Name: %.*s", avp_len,
+ tvb_get_ptr(tvb, index, avp_len));
+ break;
+
+ case ASSIGNED_TUNNEL_ID:
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
+ "Tunnel ID: %u", tvb_get_ntohs(tvb, index));
+ break;
+
+ case RECEIVE_WINDOW_SIZE:
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
+ "Receive Window Size: %u",
+ tvb_get_ntohs(tvb, index));
+ break;
+
+ case CHALLENGE:
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
+ "CHAP Challenge: %s",
+ tvb_bytes_to_str(tvb, index, avp_len));
+ break;
+
+ case CAUSE_CODE:
+ /*
+ * XXX - export stuff from the Q.931 dissector
+ * to dissect the cause code and cause message,
+ * and use it.
+ */
+ if (avp_len < 2)
+ break;
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
+ "Cause Code: %u",
+ tvb_get_ntohs(tvb, index));
+ index += 2;
+ avp_len -= 2;
+
+ if (avp_len < 1)
+ break;
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, 1,
+ "Cause Msg: %u",
+ tvb_get_guint8(tvb, index));
+ index += 1;
+ avp_len -= 1;
+
+ if (avp_len == 0)
+ break;
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
+ "Advisory Msg: %.*s", avp_len,
+ tvb_get_ptr(tvb, index, avp_len));
+ break;
+
+ case CHALLENGE_RESPONSE:
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, 16,
+ "CHAP Challenge Response: %s",
+ tvb_bytes_to_str(tvb, index, 16));
+ break;
+
+ case ASSIGNED_SESSION:
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
+ "Assigned Session: %u",
+ tvb_get_ntohs(tvb, index));
+ break;
+
+ case CALL_SERIAL_NUMBER:
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
+ "Call Serial Number: %u",
+ tvb_get_ntohl(tvb, index));
+ break;
+
+ case MINIMUM_BPS:
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
+ "Minimum BPS: %u",
+ tvb_get_ntohl(tvb, index));
+ break;
+
+ case MAXIMUM_BPS:
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
+ "Maximum BPS: %u",
+ tvb_get_ntohl(tvb, index));
+ break;
+
+ case BEARER_TYPE:
+ bits = tvb_get_ntohl(tvb, index);
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
+ "Analog Bearer Type: %s",
+ (BEARER_ANALOG(bits)) ? "True" : "False");
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
+ "Digital Bearer Type: %s",
+ (BEARER_DIGITAL(bits)) ? "True" : "False");
+ break;
+
+ case FRAMING_TYPE:
+ bits = tvb_get_ntohl(tvb, index);
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
+ "Async Framing Type: %s",
+ (FRAMING_ASYNC(bits)) ? "True" : "False");
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
+ "Sync Framing Type: %s",
+ (FRAMING_SYNC(bits)) ? "True" : "False");
+ break;
+
+ case CALLED_NUMBER:
+ if (avp_len == 0)
+ break;
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
+ "Called Number: %.*s", avp_len,
+ tvb_get_ptr(tvb, index, avp_len));
+ break;
+
+ case CALLING_NUMBER:
+ if (avp_len == 0)
+ break;
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
+ "Calling Number: %.*s", avp_len,
+ tvb_get_ptr(tvb, index, avp_len));
+ break;
+
+ case SUB_ADDRESS:
+ if (avp_len == 0)
+ break;
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
+ "Sub-Address: %.*s", avp_len,
+ tvb_get_ptr(tvb, index, avp_len));
+ break;
+
+ case TX_CONNECT_SPEED:
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
+ "Connect Speed: %u",
+ tvb_get_ntohl(tvb, index));
+ break;
+
+ case PHYSICAL_CHANNEL:
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
+ "Physical Channel: %u",
+ tvb_get_ntohl(tvb, index));
+ break;
+
+ case INITIAL_RECEIVED_LCP:
+ /*
+ * XXX - can this be dissected by stuff in the
+ * LCP dissector?
+ */
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
+ "Initial LCP CONFREQ: %s",
+ tvb_bytes_to_str(tvb, index, avp_len));
+ break;
+
+ case LAST_SEND_LCP_CONFREQ:
+ /*
+ * XXX - can this be dissected by stuff in the
+ * LCP dissector?
+ */
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
+ "Last Sent LCP CONFREQ: %s",
+ tvb_bytes_to_str(tvb, index, avp_len));
+ break;
+
+ case LAST_RECEIVED_LCP_CONFREQ:
+ /*
+ * XXX - can this be dissected by stuff in the
+ * LCP dissector?
+ */
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
+ "Last Received LCP CONFREQ: %s",
+ tvb_bytes_to_str(tvb, index, avp_len));
+ break;
+
+ case PROXY_AUTHEN_TYPE:
+ msg_type = tvb_get_ntohs(tvb, index);
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
+ "Proxy Authen Type: %s",
+ val_to_str(msg_type, authen_type_vals, "Unknown (%u)"));
+ break;
+
+ case PROXY_AUTHEN_NAME:
+ if (avp_len == 0)
+ break;
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
+ "Proxy Authen Name: %.*s", avp_len,
+ tvb_get_ptr(tvb, index, avp_len));
+ break;
+
+ case PROXY_AUTHEN_CHALLENGE:
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
+ "Proxy Authen Challenge: %s",
+ tvb_bytes_to_str(tvb, index, avp_len));
+ break;
+
+ case PROXY_AUTHEN_ID:
+ proto_tree_add_text(l2tp_avp_tree, tvb, index + 1, 1,
+ "Proxy Authen ID: %u",
+ tvb_get_guint8(tvb, index + 1));
+ break;
+
+ case PROXY_AUTHEN_RESPONSE:
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
+ "Proxy Authen Response: %s",
+ tvb_bytes_to_str(tvb, index, avp_len));
+ break;
+
+ case CALL_STATUS_AVPS:
+ if (avp_len < 2)
+ break;
+ index += 2;
+ avp_len -= 2;
+
+ if (avp_len < 4)
+ break;
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
+ "CRC Errors: %u", tvb_get_ntohl(tvb, index));
+ index += 4;
+ avp_len -= 4;
+
+ if (avp_len < 4)
+ break;
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
+ "Framing Errors: %u", tvb_get_ntohl(tvb, index));
+ index += 4;
+ avp_len -= 4;
+
+ if (avp_len < 4)
+ break;
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
+ "Hardware Overruns: %u", tvb_get_ntohl(tvb, index));
+ index += 4;
+ avp_len -= 4;
+
+ if (avp_len < 4)
+ break;
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
+ "Buffer Overruns: %u", tvb_get_ntohl(tvb, index));
+ index += 4;
+ avp_len -= 4;
+
+ if (avp_len < 4)
+ break;
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
+ "Time-out Errors: %u", tvb_get_ntohl(tvb, index));
+ index += 4;
+ avp_len -= 4;
+
+ if (avp_len < 4)
+ break;
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
+ "Alignment Errors: %u", tvb_get_ntohl(tvb, index));
+ index += 4;
+ avp_len -= 4;
+ break;
+
+ case ACCM:
+ if (avp_len < 2)
+ break;
+ index += 2;
+ avp_len -= 2;
+
+ if (avp_len < 4)
+ break;
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
+ "Send ACCM: %u", tvb_get_ntohl(tvb, index));
+ index += 4;
+ avp_len -= 4;
+
+ if (avp_len < 4)
+ break;
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
+ "Receive ACCM: %u", tvb_get_ntohl(tvb, index));
+ index += 4;
+ avp_len -= 4;
+ break;
+
+ case RANDOM_VECTOR:
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
+ "Random Vector: %s",
+ tvb_bytes_to_str(tvb, index, avp_len));
+ break;
+
+ case PRIVATE_GROUP_ID:
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
+ "Private Group ID: %s",
+ tvb_bytes_to_str(tvb, index, avp_len));
+ break;
- case CALLING_NUMBER:
- memset(message_string,'\0' ,sizeof(message_string));
- strncpy(message_string,(tmp_ptr+=2),(avp_len - 6));
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code, offset + 6,
- (avp_len - 6), rhcode, " Calling Number: %s", message_string );
- break;
+ case RX_CONNECT_SPEED:
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
+ "Rx Connect Speed: %u",
+ tvb_get_ntohl(tvb, index));
+ break;
- case SUB_ADDRESS:
- memset(message_string,'\0' ,sizeof(message_string));
- strncpy(message_string,(tmp_ptr+=2),(avp_len - 6));
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code, offset + 6,
- (avp_len - 6), rhcode, " Sub-Address: %s", message_string );
- break;
+ default:
+ proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
+ "Unknown AVP");
+ break;
+ }
- case TX_CONNECT_SPEED:
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset + 6,
- 4, rhcode, " Connect Speed: ");
- break;
+ /* printf("Avp Decode avp_len= %d index= %d length= %d %x\n ",avp_len,
+ index,length,length); */
- case PHYSICAL_CHANNEL:
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset + 6,
- 4, rhcode, " Physical Channel: ");
- break;
+ index += avp_len;
+ }
- case INITIAL_RECEIVED_LCP:
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset + 6,
- (avp_len - 6 ), rhcode, " Initial LCP Conf REQ: ");
- break;
+ }
+}
- case LAST_SEND_LCP_CONFREQ:
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset + 6,
- (avp_len - 6 ), rhcode, " Last Sent LCP Conf REQ: ");
- break;
+/* registration with the filtering engine */
+void
+proto_register_l2tp(void)
+{
+ static hf_register_info hf[] = {
+ { &hf_l2tp_type,
+ { "Type", "lt2p.type", FT_UINT16, BASE_DEC, VALS(l2tp_type_vals), 0x8000,
+ "Type bit", HFILL }},
- case LAST_RECEIVED_LCP_CONFREQ:
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset + 6,
- (avp_len - 6 ), rhcode, " Last Received LCP Conf REQ: ");
- break;
+ { &hf_l2tp_length_bit,
+ { "Length Bit", "lt2p.length_bit", FT_BOOLEAN, 16, TFS(&l2tp_length_bit_truth), 0x4000,
+ "Length bit", HFILL }},
- case PROXY_AUTHEN_TYPE:
- memcpy(&msg_type,(tmp_ptr+=2),sizeof(unsigned short));
- msg_type=htons(msg_type);
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset + 6,
- 1, rhcode, " Proxy Authen Type: %s ", authen_types[msg_type] );
- break;
+ { &hf_l2tp_seq_bit,
+ { "Sequence Bit", "lt2p.seq_bit", FT_BOOLEAN, 16, TFS(&l2tp_seq_bit_truth), 0x0800,
+ "Sequence bit", HFILL }},
- case PROXY_AUTHEN_NAME:
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset + 6,
- (avp_len - 6 ), rhcode, " Proxy Authen Name: ");
- break;
+ { &hf_l2tp_offset_bit,
+ { "Offset bit", "lt2p.offset_bit", FT_BOOLEAN, 16, TFS(&l2tp_offset_bit_truth), 0x0200,
+ "Offset bit", HFILL }},
- case PROXY_AUTHEN_CHALLENGE:
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset + 6,
- (avp_len - 6 ), rhcode, " Proxy Authen Challenge: ");
- break;
+ { &hf_l2tp_priority,
+ { "Priority", "lt2p.priority", FT_BOOLEAN, 16, TFS(&l2tp_priority_truth), 0x0100,
+ "Priority bit", HFILL }},
- case PROXY_AUTHEN_ID:
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset + 6,
- 2, rhcode, " Paorx Authen ID: ");
- break;
+ { &hf_l2tp_version,
+ { "Version", "lt2p.version", FT_UINT16, BASE_DEC, NULL, 0x000f,
+ "Version", HFILL }},
- case PROXY_AUTHEN_RESPONSE:
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset + 6,
- (avp_len - 6 ), rhcode, " Proxy Authen Response: ");
- break;
+ { &hf_l2tp_length,
+ { "Length","l2tp.length", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "", HFILL }},
- case CALL_STATUS_AVPS:
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset + 6,
- 4, rhcode, " CRC Errors: ");
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset + 10,
- 4, rhcode, " Framing Errors: ");
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset + 14,
- 4, rhcode, " Hardware Overruns: ");
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset + 18,
- 4, rhcode, " Buffer Overruns: ");
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset + 23,
- 4, rhcode, " Time-out Errors: ");
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset + 26,
- 4, rhcode, " Alignment Errors: ");
- break;
+ { &hf_l2tp_tunnel,
+ { "Tunnel ID","l2tp.tunnel", FT_UINT16, BASE_DEC, NULL, 0x0, /* Probably should be FT_BYTES */
+ "Tunnel ID", HFILL }},
- case ACCM:
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset + 6,
- 2, rhcode, " Reserve Quantity: ");
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset + 8,
- 4, rhcode, " Send ACCM: ");
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset + 12,
- 4, rhcode, " Recv ACCM: ");
- break;
+ { &hf_l2tp_session,
+ { "Session ID","l2tp.session", FT_UINT16, BASE_DEC, NULL, 0x0, /* Probably should be FT_BYTES */
+ "Session ID", HFILL }},
- case PRIVATE_GROUP_ID:
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset + 6,
- 1, rhcode, " Private Group ID: ");
- break;
+ { &hf_l2tp_Ns,
+ { "Ns","l2tp.Ns", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "", HFILL }},
- case RX_CONNECT_SPEED:
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset + 6,
- 4, rhcode, " RX Connect Speed: ");
- break;
+ { &hf_l2tp_Nr,
+ { "Nr","l2tp.Nr", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "", HFILL }},
- case SEQUENCING_REQUIRED:
- proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset ,
- 1, rhcode, " Sequencing Required: ");
- break;
- }
+ { &hf_l2tp_offset,
+ { "Offset","l2tp.offset", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "Number of octest past the L2TP header at which the"
+ "payload data starts.", HFILL }},
- /* printf("Avp Decode avp_len= %d index= %d length= %d %x\n ",avp_len,
- index,length,length); */
+ { &hf_l2tp_avp_mandatory,
+ { "Mandatory", "lt2p.avp.mandatory", FT_BOOLEAN, BASE_NONE, NULL, 0,
+ "Mandatory AVP", HFILL }},
- ptr = ptr + avp_len;
- offset += avp_len;
- }
- }
-}
+ { &hf_l2tp_avp_hidden,
+ { "Hidden", "lt2p.avp.hidden", FT_BOOLEAN, BASE_NONE, NULL, 0,
+ "Hidden AVP", HFILL }},
-/* registration with the filtering engine */
-void
-proto_register_l2tp(void)
-{
- static hf_register_info hf[] = {
- { &hf_l2tp_code,
- { "Code","l2tp.code", FT_UINT8, BASE_DEC, NULL, 0x0,
- "" }},
+ { &hf_l2tp_avp_length,
+ { "Length", "lt2p.avp.length", FT_UINT16, BASE_DEC, NULL, 0,
+ "AVP Length", HFILL }},
- { &hf_l2tp_id,
- { "Identifier", "l2tp.id", FT_UINT8, BASE_DEC, NULL, 0x0,
- "" }},
+ { &hf_l2tp_avp_vendor_id,
+ { "Vendor ID", "lt2p.avp.vendor_id", FT_UINT16, BASE_DEC, NULL, 0,
+ "AVP Vendor ID", HFILL }},
- { &hf_l2tp_length,
- { "Length","l2tp.length", FT_UINT16, BASE_DEC, NULL, 0x0,
- "" }}
+ { &hf_l2tp_avp_type,
+ { "Type", "lt2p.avp.type", FT_UINT16, BASE_DEC, VALS(avp_type_vals), 0,
+ "AVP Type", HFILL }},
};
static gint *ett[] = {
&ett_l2tp,
+ &ett_l2tp_ctrl,
&ett_l2tp_avp,
};
- proto_l2tp = proto_register_protocol ("L2TP Protocol", "l2tp");
+ proto_l2tp = proto_register_protocol(
+ "Layer 2 Tunneling Protocol", "L2TP", "l2tp");
proto_register_field_array(proto_l2tp, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
}
+
+void
+proto_reg_handoff_l2tp(void)
+{
+ dissector_add("udp.port", UDP_PORT_L2TP, dissect_l2tp,
+ proto_l2tp);
+
+ /*
+ * Get a handle for the PPP-in-HDLC-like-framing dissector.
+ */
+ ppp_hdlc_handle = find_dissector("ppp_hdlc");
+}