epan/dissectors/pidl/samr/samr.cnf cnf_dissect_lsa_BinaryString => lsarpc_dissect_str...
[wireshark-sm.git] / epan / dissectors / packet-l2tp.c
bloba0a54ef43099de444a8cd65a1a1f3aa0fda10ff5
1 /* packet-l2tp.c
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>
9 * Added RFC 5515 by Uli Heilmeier <uh@heilmeier.eu>, 2016-02-29
11 * Ericsson L2TP by Harald Welte <laforge@gnumonks.org>, 2016-07-16
13 * Wireshark - Network traffic analyzer
14 * By Gerald Combs <gerald@wireshark.org>
15 * Copyright 1998 Gerald Combs
17 * SPDX-License-Identifier: GPL-2.0-or-later
21 * RFC 2661 for L2TPv2
22 * https://tools.ietf.org/html/rfc2661
24 * RFC 3931 for L2TPv3
25 * https://tools.ietf.org/html/rfc3931
27 * Layer Two Tunneling Protocol "L2TP" number assignments:
28 * http://www.iana.org/assignments/l2tp-parameters
30 * Pseudowire types:
32 * RFC 4591 for Frame Relay
33 * https://tools.ietf.org/html/rfc4591
35 * RFC 4454 for ATM
36 * https://tools.ietf.org/html/rfc4454
38 * RFC 4719 for Ethernet
39 * https://tools.ietf.org/html/rfc4719
41 * RFC 4349 for HDLC
42 * https://tools.ietf.org/html/rfc4349
44 * XXX - what about LAPD?
47 #include "config.h"
49 #include <epan/packet.h>
50 #include <epan/ipproto.h>
51 #include <epan/sminmpec.h>
52 #include <epan/addr_resolv.h>
53 #include <epan/prefs.h>
54 #include <epan/conversation.h>
55 #include <epan/expert.h>
56 #include <epan/decode_as.h>
57 #include <epan/proto_data.h>
58 #include <epan/tfs.h>
59 #include <wsutil/array.h>
60 #include <wsutil/wsgcrypt.h>
62 #include "packet-l2tp.h"
64 void proto_register_l2tp(void);
65 void proto_reg_handoff_l2tp(void);
67 static int proto_l2tp;
68 static int hf_l2tp_flags;
69 static int hf_l2tp_type;
70 static int hf_l2tp_length_bit;
71 static int hf_l2tp_seq_bit;
72 static int hf_l2tp_offset_bit;
73 static int hf_l2tp_priority;
74 static int hf_l2tp_version;
75 static int hf_l2tp_length;
76 static int hf_l2tp_tunnel;
77 static int hf_l2tp_session;
78 static int hf_l2tp_Ns;
79 static int hf_l2tp_Nr;
80 static int hf_l2tp_offset;
81 static int hf_l2tp_avp_mandatory;
82 static int hf_l2tp_avp_hidden;
83 static int hf_l2tp_avp_length;
84 static int hf_l2tp_avp_vendor_id;
85 static int hf_l2tp_avp_type;
86 static int hf_l2tp_tie_breaker;
87 static int hf_l2tp_sid;
88 static int hf_l2tp_res;
89 static int hf_l2tp_ccid;
90 static int hf_l2tp_cookie;
91 static int hf_l2tp_l2_spec_def;
92 static int hf_l2tp_l2_spec_atm;
93 static int hf_l2tp_l2_spec_docsis_dmpt;
94 static int hf_l2tp_l2_spec_v;
95 static int hf_l2tp_l2_spec_s;
96 static int hf_l2tp_l2_spec_h;
97 static int hf_l2tp_l2_spec_flow_id;
98 static int hf_l2tp_l2_spec_sequence;
99 static int hf_l2tp_l2_spec_t;
100 static int hf_l2tp_l2_spec_g;
101 static int hf_l2tp_l2_spec_c;
102 static int hf_l2tp_l2_spec_u;
103 static int hf_l2tp_cisco_avp_type;
104 static int hf_l2tp_ericsson_avp_type;
105 static int hf_l2tp_broadband_avp_type;
106 static int hf_l2tp_cablelabs_avp_type;
107 static int hf_l2tp_avp_message_type;
108 static int hf_l2tp_avp_assigned_tunnel_id;
109 static int hf_l2tp_avp_assigned_control_conn_id;
110 static int hf_l2tp_avp_assigned_session_id;
111 static int hf_l2tp_avp_remote_session_id;
112 static int hf_l2tp_avp_local_session_id;
113 static int hf_l2tp_avp_called_number;
114 static int hf_l2tp_avp_calling_number;
115 static int hf_l2tp_cisco_tie_breaker;
116 static int hf_l2tp_cablel_avp_l_bit;
117 static int hf_l2tp_cablel_avp_tsid_group_id;
118 static int hf_l2tp_cablel_avp_frequency;
119 static int hf_l2tp_cablel_avp_modulation;
120 static int hf_l2tp_cablel_avp_m;
121 static int hf_l2tp_cablel_avp_n;
122 static int hf_l2tp_broadband_agent_circuit_id;
123 static int hf_l2tp_broadband_agent_remote_id;
124 static int hf_l2tp_broadband_actual_dr_up;
125 static int hf_l2tp_broadband_actual_dr_down;
126 static int hf_l2tp_broadband_minimum_dr_up;
127 static int hf_l2tp_broadband_minimum_dr_down;
128 static int hf_l2tp_broadband_attainable_dr_up;
129 static int hf_l2tp_broadband_attainable_dr_down;
130 static int hf_l2tp_broadband_maximum_dr_up;
131 static int hf_l2tp_broadband_maximum_dr_down;
132 static int hf_l2tp_broadband_minimum_dr_up_low_power;
133 static int hf_l2tp_broadband_minimum_dr_down_low_power;
134 static int hf_l2tp_broadband_maximum_interleaving_delay_up;
135 static int hf_l2tp_broadband_actual_interleaving_delay_up;
136 static int hf_l2tp_broadband_maximum_interleaving_delay_down;
137 static int hf_l2tp_broadband_actual_interleaving_delay_down;
138 static int hf_l2tp_broadband_access_loop_encapsulation;
139 static int hf_l2tp_broadband_access_loop_encapsulation_data_link;
140 static int hf_l2tp_broadband_access_loop_encapsulation_enc1;
141 static int hf_l2tp_broadband_access_loop_encapsulation_enc2;
142 static int hf_l2tp_broadband_ancp_access_line_type;
143 static int hf_l2tp_broadband_iwf_session;
144 static int hf_l2tp_avp_csu;
145 static int hf_l2tp_avp_csu_res;
146 static int hf_l2tp_avp_csu_remote_session_id_v2;
147 static int hf_l2tp_avp_csu_current_tx_speed_v2;
148 static int hf_l2tp_avp_csu_current_rx_speed_v2;
149 static int hf_l2tp_avp_csu_remote_session_id_v3;
150 static int hf_l2tp_avp_csu_current_tx_speed_v3;
151 static int hf_l2tp_avp_csu_current_rx_speed_v3;
153 static int hf_l2tp_ericsson_msg_type;
154 static int hf_l2tp_ericsson_conn_type;
155 static int hf_l2tp_ericsson_stn_name;
156 static int hf_l2tp_ericsson_crc32_enable;
157 static int hf_l2tp_ericsson_abis_lower_mode;
158 static int hf_l2tp_ericsson_tc_overl_thresh;
159 static int hf_l2tp_ericsson_tc_num_groups;
160 static int hf_l2tp_ericsson_tcg_group_id;
161 static int hf_l2tp_ericsson_tcg_num_sapis;
162 static int hf_l2tp_ericsson_tcg_sapi;
163 static int hf_l2tp_ericsson_tcg_ip;
164 static int hf_l2tp_ericsson_tcg_dscp;
165 static int hf_l2tp_ericsson_tcg_crc32_enable;
166 static int hf_l2tp_ericsson_tcg_bundling_tout;
167 static int hf_l2tp_ericsson_tcg_bundling_max_pkt;
168 static int hf_l2tp_ericsson_tc_num_maps;
169 static int hf_l2tp_ericsson_map_tei_low;
170 static int hf_l2tp_ericsson_map_tei_high;
171 static int hf_l2tp_ericsson_map_sc;
172 static int hf_l2tp_ericsson_ver_pref;
173 static int hf_l2tp_ericsson_ver_2;
174 static int hf_l2tp_ericsson_ver_3;
176 /* Generated from convert_proto_tree_add_text.pl */
177 static int hf_l2tp_cisco_pw_type;
178 static int hf_l2tp_avp_error_code;
179 static int hf_l2tp_avp_cause_msg;
180 static int hf_l2tp_avp_host_name;
181 static int hf_l2tp_avp_maximum_bps;
182 static int hf_l2tp_avp_pseudowire_type;
183 static int hf_l2tp_avp_minimum_bps;
184 static int hf_l2tp_avp_nonce;
185 static int hf_l2tp_avp_circuit_status;
186 static int hf_l2tp_avp_receive_window_size;
187 static int hf_l2tp_avp_vendor_name;
188 static int hf_l2tp_avp_layer2_specific_sublayer;
189 static int hf_l2tp_avp_disconnect_code;
190 static int hf_l2tp_cisco_circuit_status;
191 static int hf_l2tp_cisco_remote_session_id;
192 static int hf_l2tp_avp_router_id;
193 static int hf_l2tp_avp_send_accm;
194 static int hf_l2tp_avp_last_sent_lcp_confreq;
195 static int hf_l2tp_avp_sync_framing_supported;
196 static int hf_l2tp_cisco_assigned_control_connection_id;
197 static int hf_l2tp_avp_sync_framing_type;
198 static int hf_l2tp_avp_assigned_cookie;
199 static int hf_l2tp_avp_time_out_errors;
200 static int hf_l2tp_avp_sub_address;
201 static int hf_l2tp_avp_connect_speed;
202 static int hf_l2tp_avp_analog_access_supported;
203 static int hf_l2tp_avp_private_group_id;
204 static int hf_l2tp_avp_proxy_authen_response;
205 static int hf_l2tp_avp_chap_challenge;
206 static int hf_l2tp_avp_call_serial_number;
207 static int hf_l2tp_avp_digital_access_supported;
208 static int hf_l2tp_avp_physical_channel;
209 static int hf_l2tp_avp_advisory_msg;
210 static int hf_l2tp_avp_data_sequencing;
211 static int hf_l2tp_avp_control_protocol_number;
212 static int hf_l2tp_avp_error_message;
213 static int hf_l2tp_avp_initial_received_lcp_confreq;
214 static int hf_l2tp_avp_async_framing_supported;
215 static int hf_l2tp_cisco_message_digest;
216 static int hf_l2tp_avp_circuit_type;
217 static int hf_l2tp_cisco_circuit_type;
218 static int hf_l2tp_avp_proxy_authen_challenge;
219 static int hf_l2tp_cisco_assigned_cookie;
220 static int hf_l2tp_avp_receive_accm;
221 static int hf_l2tp_stop_ccn_result_code;
222 static int hf_l2tp_avp_proxy_authen_id;
223 static int hf_l2tp_avp_digital_bearer_type;
224 static int hf_l2tp_avp_rx_connect_speed;
225 static int hf_l2tp_cisco_nonce;
226 static int hf_l2tp_avp_chap_challenge_response;
227 static int hf_l2tp_avp_cause_code;
228 static int hf_l2tp_avp_protocol_revision;
229 static int hf_l2tp_avp_alignment_errors;
230 static int hf_l2tp_avp_last_received_lcp_confreq;
231 static int hf_l2tp_avp_crc_errors;
232 static int hf_l2tp_avp_random_vector;
233 static int hf_l2tp_avp_preferred_language;
234 static int hf_l2tp_cisco_interface_mtu;
235 static int hf_l2tp_avp_async_framing_type;
236 static int hf_l2tp_avp_pw_type;
237 static int hf_l2tp_cisco_local_session_id;
238 static int hf_l2tp_avp_hardware_overruns;
239 static int hf_l2tp_avp_proxy_authen_type;
240 static int hf_l2tp_cisco_draft_avp_version;
241 static int hf_l2tp_avp_protocol_version;
242 static int hf_l2tp_result_code;
243 static int hf_l2tp_avp_buffer_overruns;
244 static int hf_l2tp_avp_remote_end_id;
245 static int hf_l2tp_cisco_pseudowire_type;
246 static int hf_l2tp_avp_message_digest;
247 static int hf_l2tp_avp_proxy_authen_name;
248 static int hf_l2tp_avp_analog_bearer_type;
249 static int hf_l2tp_avp_cause_code_direction;
250 static int hf_l2tp_avp_firmware_revision;
251 static int hf_l2tp_avp_cause_code_message;
252 static int hf_l2tp_avp_framing_errors;
253 static int hf_l2tp_cisco_remote_end_id;
254 static int hf_l2tp_avp_tx_connect_speed_v3;
255 static int hf_l2tp_avp_rx_connect_speed_v3;
256 static int hf_l2tp_lapd_info;
257 static int hf_l2tp_zero_length_body_message;
258 static int hf_l2tp_offset_padding;
260 static dissector_table_t l2tp_vendor_avp_dissector_table;
261 static dissector_table_t pw_type_table;
263 #define UDP_PORT_L2TP 1701
265 #define CONTROL_BIT(msg_info) (msg_info & 0x8000) /* Type bit control = 1 data = 0 */
266 #define LENGTH_BIT(msg_info) (msg_info & 0x4000) /* Length bit = 1 */
267 #define RESERVE_BITS(msg_info) (msg_info &0x37F8) /* Reserved bit - unused */
268 #define SEQUENCE_BIT(msg_info) (msg_info & 0x0800) /* SEQUENCE bit = 1 Ns and Nr fields */
269 #define OFFSET_BIT(msg_info) (msg_info & 0x0200) /* Offset */
270 #define PRIORITY_BIT(msg_info) (msg_info & 0x0100) /* Priority */
271 #define L2TP_VERSION(msg_info) (msg_info & 0x000f) /* Version of l2tp */
272 #define MANDATORY_BIT(msg_info) (msg_info & 0x8000) /* Mandatory = 1 */
273 #define HIDDEN_BIT(msg_info) (msg_info & 0x4000) /* Hidden = 1 */
274 #define AVP_LENGTH(msg_info) (msg_info & 0x03ff) /* AVP Length */
275 #define FRAMING_SYNC(msg_info) (msg_info & 0x0001) /* SYNC Framing Type */
276 #define FRAMING_ASYNC(msg_info) (msg_info & 0x0002) /* ASYNC Framing Type */
277 #define BEARER_DIGITAL(msg_info) (msg_info & 0x0001) /* Digital Bearer Type */
278 #define BEARER_ANALOG(msg_info) (msg_info & 0x0002) /* Analog Bearer Type */
279 #define CIRCUIT_STATUS_BIT(msg_info) (msg_info & 0x0001) /* Circuit Status */
280 #define CIRCUIT_TYPE_BIT(msg_info) (msg_info & 0x0001) /* Circuit Condition */
282 /* DOCSIS DMPT Sub-Layer Header definitions */
283 #define FLOW_ID_MASK 0x0E
285 static int ett_l2tp;
286 static int ett_l2tp_flags;
287 static int ett_l2tp_avp;
288 static int ett_l2tp_avp_sub;
289 static int ett_l2tp_ale_sub;
290 static int ett_l2tp_lcp;
291 static int ett_l2tp_l2_spec;
292 static int ett_l2tp_csu;
293 static int ett_l2tp_ericsson_tcg;
294 static int ett_l2tp_ericsson_map;
296 static expert_field ei_l2tp_incorrect_digest;
297 /* Generated from convert_proto_tree_add_text.pl */
298 static expert_field ei_l2tp_vendor_specific_avp_data;
299 static expert_field ei_l2tp_avp_length;
301 static const enum_val_t l2tpv3_cookies[] = {
302 {"detect", "Detect", -1},
303 {"cookie0", "None", 0},
304 {"cookie4", "4 Byte Cookie", 4},
305 {"cookie8", "8 Byte Cookie", 8},
306 {NULL, NULL, 0}
309 #define L2TPv3_COOKIE_DEFAULT 0
311 #define L2TPv3_L2_SPECIFIC_NONE 0
312 #define L2TPv3_L2_SPECIFIC_DEFAULT 1
313 #define L2TPv3_L2_SPECIFIC_ATM 2
314 #define L2TPv3_L2_SPECIFIC_LAPD 3
315 #define L2TPv3_L2_SPECIFIC_DOCSIS_DMPT 4
316 #define L2TPv3_L2_SPECIFIC_MAX (L2TPv3_L2_SPECIFIC_DOCSIS_DMPT + 1)
318 static const enum_val_t l2tpv3_l2_specifics[] = {
319 {"detect", "Detect", -1},
320 {"none", "None", L2TPv3_L2_SPECIFIC_NONE},
321 {"default", "Default L2-Specific", L2TPv3_L2_SPECIFIC_DEFAULT},
322 {"atm", "ATM-Specific", L2TPv3_L2_SPECIFIC_ATM},
323 {"lapd", "LAPD-Specific", L2TPv3_L2_SPECIFIC_LAPD},
324 {"dmpt", "DOCSIS DMPT-Specific", L2TPv3_L2_SPECIFIC_DOCSIS_DMPT},
325 {NULL, NULL, 0}
328 static int l2tpv3_cookie = -1;
329 static int l2tpv3_l2_specific = -1;
331 #define MESSAGE_TYPE_SCCRQ 1
332 #define MESSAGE_TYPE_SCCRP 2
333 #define MESSAGE_TYPE_SCCCN 3
334 #define MESSAGE_TYPE_StopCCN 4
335 #define MESSAGE_TYPE_Reserved_5 5
336 #define MESSAGE_TYPE_HELLO 6
337 #define MESSAGE_TYPE_OCRQ 7
338 #define MESSAGE_TYPE_OCRP 8
339 #define MESSAGE_TYPE_OCCN 9
340 #define MESSAGE_TYPE_ICRQ 10
341 #define MESSAGE_TYPE_ICRP 11
342 #define MESSAGE_TYPE_ICCN 12
343 #define MESSAGE_TYPE_Reserved_13 13
344 #define MESSAGE_TYPE_CDN 14
345 #define MESSAGE_TYPE_WEN 15
346 #define MESSAGE_TYPE_SLI 16
347 #define MESSAGE_TYPE_MDMST 17
348 #define MESSAGE_TYPE_SRRQ 18
349 #define MESSAGE_TYPE_SRRP 19
350 #define MESSAGE_TYPE_ACK 20
351 #define MESSAGE_TYPE_FSQ 21
352 #define MESSAGE_TYPE_FSR 22
353 #define MESSAGE_TYPE_MSRQ 23
354 #define MESSAGE_TYPE_MSRP 24
355 #define MESSAGE_TYPE_MSE 25
356 #define MESSAGE_TYPE_MSI 26
357 #define MESSAGE_TYPE_MSEN 27
358 #define MESSAGE_TYPE_CSUN 28
359 #define MESSAGE_TYPE_CSURQ 29
361 static const value_string message_type_vals[] = {
362 { MESSAGE_TYPE_SCCRQ, "Start_Control_Request" },
363 { MESSAGE_TYPE_SCCRP, "Start_Control_Reply" },
364 { MESSAGE_TYPE_SCCCN, "Start_Control_Connected" },
365 { MESSAGE_TYPE_StopCCN, "Stop_Control_Notification" },
366 { MESSAGE_TYPE_Reserved_5, "Reserved" },
367 { MESSAGE_TYPE_HELLO, "Hello" },
368 { MESSAGE_TYPE_OCRQ, "Outgoing_Call_Request" },
369 { MESSAGE_TYPE_OCRP, "Outgoing_Call_Reply" },
370 { MESSAGE_TYPE_OCCN, "Outgoing_Call_Connected" },
371 { MESSAGE_TYPE_ICRQ, "Incoming_Call_Request" },
372 { MESSAGE_TYPE_ICRP, "Incoming_Call_Reply" },
373 { MESSAGE_TYPE_ICCN, "Incoming_Call_Connected" },
374 { MESSAGE_TYPE_Reserved_13, "Reserved" },
375 { MESSAGE_TYPE_CDN, "Call_Disconnect_Notification" },
376 { MESSAGE_TYPE_WEN, "WAN_Error_Notify" },
377 { MESSAGE_TYPE_SLI, "Set_Link_Info" },
378 { MESSAGE_TYPE_MDMST, "Modem_Status" },
379 { MESSAGE_TYPE_SRRQ, "Service_Relay_Request_Msg" },
380 { MESSAGE_TYPE_SRRP, "Service_Relay_Reply_Message" },
381 { MESSAGE_TYPE_ACK, "Explicit_Acknowledgement" },
382 /* Fail Over Extensions - RFC4951 */
383 { MESSAGE_TYPE_FSQ, "Failover_Session_Query_Message" },
384 { MESSAGE_TYPE_FSR, "Failover_Session_Response_Message" },
385 /* Multicast Management - RFC4045 */
386 { MESSAGE_TYPE_MSRQ, "Multicast-Session-Request" },
387 { MESSAGE_TYPE_MSRP, "Multicast-Session-Response" },
388 { MESSAGE_TYPE_MSE, "Multicast-Session-Establishment" },
389 { MESSAGE_TYPE_MSI, "Multicast-Session-Information" },
390 { MESSAGE_TYPE_MSEN, "Multicast-Session-End-Notify" },
391 { MESSAGE_TYPE_CSUN, "Connect-Speed-Update-Notification" },
392 { MESSAGE_TYPE_CSURQ, "Connect-Speed-Update-Request" },
393 { 0, NULL },
395 static value_string_ext message_type_vals_ext = VALUE_STRING_EXT_INIT(message_type_vals);
397 static const value_string l2tp_message_type_short_str_vals[] = {
398 { MESSAGE_TYPE_SCCRQ, "SCCRQ" },
399 { MESSAGE_TYPE_SCCRP, "SCCRP" },
400 { MESSAGE_TYPE_SCCCN, "SCCCN" },
401 { MESSAGE_TYPE_StopCCN, "StopCCN" },
402 { 5, "Reserved"},
403 { MESSAGE_TYPE_HELLO, "Hello" },
404 { MESSAGE_TYPE_OCRQ, "OCRQ" },
405 { MESSAGE_TYPE_OCRP, "OCRP" },
406 { MESSAGE_TYPE_OCCN, "OCCN" },
407 { MESSAGE_TYPE_ICRQ, "ICRQ" },
408 { MESSAGE_TYPE_ICRP, "ICRP" },
409 { MESSAGE_TYPE_ICCN, "ICCN" },
410 { 13, "Reserved"},
411 { MESSAGE_TYPE_CDN, "CDN" },
412 { MESSAGE_TYPE_WEN, "WEN" },
413 { MESSAGE_TYPE_SLI, "SLI" },
414 { MESSAGE_TYPE_MDMST, "MDMST" },
415 { MESSAGE_TYPE_SRRQ, "SRRQ" },
416 { MESSAGE_TYPE_SRRP, "SRRP" },
417 { MESSAGE_TYPE_ACK, "ACK" },
418 /* Fail Over Extensions - RFC4951 */
419 { MESSAGE_TYPE_FSQ, "FSQ" },
420 { MESSAGE_TYPE_FSR, "FSR" },
421 /* Multicast Management - RFC4045 */
422 { MESSAGE_TYPE_MSRQ, "MSRQ" },
423 { MESSAGE_TYPE_MSRP, "MSRP" },
424 { MESSAGE_TYPE_MSE, "MSE" },
425 { MESSAGE_TYPE_MSI, "MSI" },
426 { MESSAGE_TYPE_MSEN, "MSEN" },
427 { MESSAGE_TYPE_CSUN, "CSUN" },
428 { MESSAGE_TYPE_CSURQ, "CSURQ" },
429 { 0, NULL },
431 static value_string_ext l2tp_message_type_short_str_vals_ext = VALUE_STRING_EXT_INIT(l2tp_message_type_short_str_vals);
434 static const char *control_msg = "Control Message";
435 static const char *data_msg = "Data Message";
436 static const value_string l2tp_type_vals[] = {
437 { 0, "Data Message" },
438 { 1, "Control Message" },
439 { 0, NULL },
442 static const value_string cause_code_direction_vals[] = {
443 { 0, "global error" },
444 { 1, "at peer" },
445 { 2, "at local" },
446 { 0, NULL },
449 static const true_false_string l2tp_length_bit_truth =
450 { "Length field is present", "Length field is not present" };
452 static const true_false_string l2tp_seq_bit_truth =
453 { "Ns and Nr fields are present", "Ns and Nr fields are not present" };
455 static const true_false_string l2tp_offset_bit_truth =
456 { "Offset Size field is present", "Offset size field is not present" };
458 static const true_false_string l2tp_priority_truth =
459 { "This data message has priority", "No priority" };
461 static const value_string authen_type_vals[] = {
462 { 0, "Reserved" },
463 { 1, "Textual username/password exchange" },
464 { 2, "PPP CHAP" },
465 { 3, "PPP PAP" },
466 { 4, "No Authentication" },
467 { 5, "Microsoft CHAP Version 1" },
468 { 6, "Reserved" },
469 { 7, "EAP" },
470 { 0, NULL }
473 static const value_string data_sequencing_vals[] = {
474 { 0, "No incoming data packets require sequencing" },
475 { 1, "Only non-IP data packets require sequencing" },
476 { 2, "All incoming data packets require sequencing" },
477 { 0, NULL }
480 static const value_string l2_sublayer_vals[] = {
481 { 0, "No L2-Specific Sublayer" },
482 { 1, "Default L2-Specific Sublayer present" },
483 { 2, "ATM-Specific Sublayer present" },
484 { 3, "MPT-Specific Sublayer" },
485 { 4, "PSP-Specific Sublayer" },
486 { 0, NULL }
489 /* Result Code values for the StopCCN message */
490 static const value_string result_code_stopccn_vals[] = {
491 { 0, "Reserved", },
492 { 1, "General request to clear control connection", },
493 { 2, "General error, Error Code indicates the problem", },
494 { 3, "Control connection already exists", },
495 { 4, "Requester is not authorized to establish a control connection", },
496 { 5, "The protocol version of the requester is not supported", },
497 { 6, "Requester is being shut down", },
498 { 7, "Finite state machine error or timeout", },
499 { 8, "Control connection due to mismatching CCDS value", }, /* [RFC3308] */
500 { 0, NULL }
503 /* Result Code values for the CDN message */
504 static const value_string result_code_cdn_vals[] = {
505 { 0, "Reserved", },
506 { 1, "Session disconnected due to loss of carrier or circuit disconnect", },
507 { 2, "Session disconnected for the reason indicated in Error Code", },
508 { 3, "Session disconnected for administrative reasons", },
509 { 4, "Appropriate facilities unavailable (temporary condition)", },
510 { 5, "Appropriate facilities unavailable (permanent condition)", },
511 { 6, "Invalid destination", },
512 { 7, "Call failed due to no carrier detected", },
513 { 8, "Call failed due to detection of a busy signal", },
514 { 9, "Call failed due to lack of a dial tone", },
515 { 10, "Call was not established within time allotted by LAC", },
516 { 11, "Call was connected but no appropriate framing was detected", },
517 { 12, "Disconnecting call due to mismatching SDS value", },
518 { 13, "Session not established due to losing tie breaker", },
519 { 14, "Session not established due to unsupported PW type", },
520 { 15, "Session not established, sequencing required without valid L2-Specific Sublayer", },
521 { 16, "Finite state machine error or timeout", },
522 { 17, "FR PVC was deleted permanently (no longer provisioned) ", }, /* [RFC4591] */
523 { 18, "FR PVC has been INACTIVE for an extended period of time", }, /* [RFC4591] */
524 { 19, "Mismatched FR Header Length", }, /* [RFC4591] */
525 { 20, "HDLC Link was deleted permanently (no longer provisioned)", }, /* [RFC4349] */
526 { 21, "HDLC Link has been INACTIVE for an extended period of time", }, /* [RFC4349] */
527 { 22, "Session not established due to other LCCE can not support the OAM Cell Emulation", }, /* [RFC4454] */
528 { 23, "Mismatching interface MTU", }, /* [RFC4667] */
529 { 24, "Attempt to connect to non-existent forwarder", }, /* [RFC4667] */
530 { 25, "Attempt to connect to unauthorized forwarder", }, /* [RFC4667] */
531 { 26, "Loop Detected", }, /* [draft-ietf-l2tpext-tunnel-switching-06.txt] */
532 { 27, "Attachment Circuit bound to different PE", }, /* [RFC6074] */
533 { 28, "Attachment Circuit bound to different remote Attachment Circuit", }, /* [RFC6074] */
534 { 29, "Unassigned", },
535 { 30, "Return code to indicate connection was refused because of TDM PW parameters. The error code indicates the problem.", }, /* [RFC5611] */
536 { 31, "Sequencing not supported", }, /* [RFC6073] */
537 { 0, NULL }
539 static value_string_ext result_code_cdn_vals_ext = VALUE_STRING_EXT_INIT(result_code_cdn_vals);
542 static const value_string error_code_vals[] = {
543 { 0, "No General Error", },
544 { 1, "No control connection exists yet for this pair of LCCEs", },
545 { 2, "Length is wrong", },
546 { 3, "One of the field values was out of range", },
547 { 4, "Insufficient resources to handle this operation now", },
548 { 5, "Invalid Session ID", },
549 { 6, "A generic vendor-specific error occurred", },
550 { 7, "Try another", },
551 { 8, "Receipt of an unknown AVP with the M bit set", },
552 { 9, "Try another directed", },
553 { 10, "Next hop unreachable", },
554 { 11, "Next hop busy", },
555 { 12, "TSA busy", },
556 { 0, NULL }
559 #define CONTROL_MESSAGE 0
560 #define RESULT_ERROR_CODE 1
561 #define PROTOCOL_VERSION 2
562 #define FRAMING_CAPABILITIES 3
563 #define BEARER_CAPABILITIES 4
564 #define TIE_BREAKER 5
565 #define FIRMWARE_REVISION 6
566 #define HOST_NAME 7
567 #define VENDOR_NAME 8
568 #define ASSIGNED_TUNNEL_ID 9
569 #define RECEIVE_WINDOW_SIZE 10
570 #define CHALLENGE 11
571 #define CAUSE_CODE 12
572 #define CHALLENGE_RESPONSE 13
573 #define ASSIGNED_SESSION 14
574 #define CALL_SERIAL_NUMBER 15
575 #define MINIMUM_BPS 16
576 #define MAXIMUM_BPS 17
577 #define BEARER_TYPE 18
578 #define FRAMING_TYPE 19
579 #define CALLED_NUMBER 21
580 #define CALLING_NUMBER 22
581 #define SUB_ADDRESS 23
582 #define TX_CONNECT_SPEED 24
583 #define PHYSICAL_CHANNEL 25
584 #define INITIAL_RECEIVED_LCP_CONFREQ 26
585 #define LAST_SENT_LCP_CONFREQ 27
586 #define LAST_RECEIVED_LCP_CONFREQ 28
587 #define PROXY_AUTHEN_TYPE 29
588 #define PROXY_AUTHEN_NAME 30
589 #define PROXY_AUTHEN_CHALLENGE 31
590 #define PROXY_AUTHEN_ID 32
591 #define PROXY_AUTHEN_RESPONSE 33
592 #define CALL_STATUS_AVPS 34
593 #define ACCM 35
594 #define RANDOM_VECTOR 36
595 #define PRIVATE_GROUP_ID 37
596 #define RX_CONNECT_SPEED 38
597 #define SEQUENCING_REQUIRED 39
598 #define PPP_DISCONNECT_CAUSE_CODE 46 /* RFC 3145 */
599 #define EXTENDED_VENDOR_ID 58
600 #define MESSAGE_DIGEST 59
601 #define ROUTER_ID 60
602 #define ASSIGNED_CONTROL_CONN_ID 61
603 #define PW_CAPABILITY_LIST 62
604 #define LOCAL_SESSION_ID 63
605 #define REMOTE_SESSION_ID 64
606 #define ASSIGNED_COOKIE 65
607 #define REMOTE_END_ID 66
608 #define PW_TYPE 68
609 #define L2_SPECIFIC_SUBLAYER 69
610 #define DATA_SEQUENCING 70
611 #define CIRCUIT_STATUS 71
612 #define PREFERRED_LANGUAGE 72
613 #define CTL_MSG_AUTH_NONCE 73
614 #define TX_CONNECT_SPEED_V3 74
615 #define RX_CONNECT_SPEED_V3 75
616 #define CONNECT_SPEED_UPDATE 97
618 /* http://www.iana.org/assignments/l2tp-parameters/l2tp-parameters.xhtml */
619 #define NUM_AVP_TYPES 102
620 static const value_string avp_type_vals[] = {
621 { CONTROL_MESSAGE, "Control Message" },
622 { RESULT_ERROR_CODE, "Result-Error Code" },
623 { PROTOCOL_VERSION, "Protocol Version" },
624 { FRAMING_CAPABILITIES, "Framing Capabilities" },
625 { BEARER_CAPABILITIES, "Bearer Capabilities" },
626 { TIE_BREAKER, "Tie Breaker" },
627 { FIRMWARE_REVISION, "Firmware Revision" },
628 { HOST_NAME, "Host Name" },
629 { VENDOR_NAME, "Vendor Name" },
630 { ASSIGNED_TUNNEL_ID, "Assigned Tunnel ID" },
631 { RECEIVE_WINDOW_SIZE, "Receive Window Size" },
632 { CHALLENGE, "Challenge" },
633 { CAUSE_CODE, "Cause Code" },
634 { CHALLENGE_RESPONSE, "Challenge Response" },
635 { ASSIGNED_SESSION, "Assigned Session" },
636 { CALL_SERIAL_NUMBER, "Call Serial Number" },
637 { MINIMUM_BPS, "Minimum BPS" },
638 { MAXIMUM_BPS, "Maximum BPS" },
639 { BEARER_TYPE, "Bearer Type" },
640 { FRAMING_TYPE, "Framing Type" },
641 { 20, "Reserved" },
642 { CALLED_NUMBER, "Called Number" },
643 { CALLING_NUMBER, "Calling Number" },
644 { SUB_ADDRESS, "Sub-Address" },
645 { TX_CONNECT_SPEED, "Connect Speed" },
646 { PHYSICAL_CHANNEL, "Physical Channel" },
647 { INITIAL_RECEIVED_LCP_CONFREQ, "Initial Received LCP CONFREQ" },
648 { LAST_SENT_LCP_CONFREQ, "Last Sent LCP CONFREQ" },
649 { LAST_RECEIVED_LCP_CONFREQ, "Last Received LCP CONFREQ" },
650 { PROXY_AUTHEN_TYPE, "Proxy Authen Type" },
651 { PROXY_AUTHEN_NAME, "Proxy Authen Name" },
652 { PROXY_AUTHEN_CHALLENGE, "Proxy Authen Challenge" },
653 { PROXY_AUTHEN_ID, "Proxy Authen ID" },
654 { PROXY_AUTHEN_RESPONSE, "Proxy Authen Response" },
655 { CALL_STATUS_AVPS, "Call status AVPs" },
656 { ACCM, "ACCM" },
657 { RANDOM_VECTOR, "Random Vector" },
658 { PRIVATE_GROUP_ID, "Private group ID" },
659 { RX_CONNECT_SPEED, "RxConnect Speed" },
660 { SEQUENCING_REQUIRED, "Sequencing Required" },
661 { PPP_DISCONNECT_CAUSE_CODE, "PPP Disconnect Cause Code" },
662 { EXTENDED_VENDOR_ID, "Extended Vendor ID" },
663 { MESSAGE_DIGEST, "Message Digest" },
664 { ROUTER_ID, "Router ID" },
665 { ASSIGNED_CONTROL_CONN_ID, "Assigned Control Connection ID" },
666 { PW_CAPABILITY_LIST, "Pseudowire Capability List" },
667 { LOCAL_SESSION_ID, "Local Session ID" },
668 { REMOTE_SESSION_ID, "Remote Session ID" },
669 { ASSIGNED_COOKIE, "Assigned Cookie" },
670 { REMOTE_END_ID, "Remote End ID" },
671 { PW_TYPE, "Pseudowire Type" },
672 { L2_SPECIFIC_SUBLAYER, "Layer2 Specific Sublayer" },
673 { DATA_SEQUENCING, "Data Sequencing" },
674 { CIRCUIT_STATUS, "Circuit Status" },
675 { PREFERRED_LANGUAGE, "Preferred Language" },
676 { CTL_MSG_AUTH_NONCE, "Control Message Authentication Nonce" },
677 { TX_CONNECT_SPEED_V3, "Tx Connect Speed Version 3" },
678 { RX_CONNECT_SPEED_V3, "Rx Connect Speed Version 3" },
679 { 76, "Failover Capability" }, /*[RFC4951] */
680 { 77, "Tunnel Recovery" }, /*[RFC4951] */
681 { 78, "Suggested Control Sequence" }, /*[RFC4951] */
682 { 79, "Failover Session State" }, /*[RFC4951] */
683 { 80, "Multicast Capability" }, /*[RFC4045] */
684 { 81, "New Outgoing Sessions" }, /*[RFC4045] */
685 { 82, "New Outgoing Sessions Acknowledgement" }, /*[RFC4045] */
686 { 83, "Withdraw Outgoing Sessions" }, /*[RFC4045] */
687 { 84, "Multicast Packets Priority" }, /*[RFC4045] */
688 { 85, "Frame-Relay Header Length" }, /*[RFC4591] */
689 { 86, "ATM Maximum Concatenated Cells" }, /*[RFC4454] */
690 { 87, "OAM Emulation Required" }, /*[RFC4454] */
691 { 88, "ATM Alarm Status" }, /*[RFC4454] */
692 /* Also, see ATM Alarm Status AVP Values below */
693 { 89, "Attachment Group Identifier" }, /*[RFC4667] */
694 { 90, "Local End Identifier" }, /*[RFC4667] */
695 { 91, "Interface Maximum Transmission Unit" }, /*[RFC4667] */
696 { 92, "FCS Retention" }, /*[RFC4720] */
697 { 93, "Tunnel Switching Aggregator ID" }, /*[draft-ietf-l2tpext-tunnel-switching-06.txt] */
698 { 94, "Maximum Receive Unit (MRU)" }, /*[RFC4623] */
699 { 95, "Maximum Reassembled Receive Unit (MRRU)" }, /*[RFC4623] */
700 { 96, "VCCV Capability" }, /*[RFC5085] */
701 { CONNECT_SPEED_UPDATE, "Connect Speed Update" }, /*[RFC5515] */
702 { 98, "Connect Speed Update Enable" }, /*[RFC5515] */
703 { 99, "TDM Pseudowire" }, /*[RFC5611] */
704 { 100, "RTP AVP" }, /*[RFC5611] */
705 { 101, "PW Switching Point" }, /*[RFC6073] */
706 { 0, NULL }
709 static value_string_ext avp_type_vals_ext = VALUE_STRING_EXT_INIT(avp_type_vals);
711 #define CISCO_ACK 0
712 #define CISCO_ASSIGNED_CONNECTION_ID 1
713 #define CISCO_PW_CAPABILITY_LIST 2
714 #define CISCO_LOCAL_SESSION_ID 3
715 #define CISCO_REMOTE_SESSION_ID 4
716 #define CISCO_ASSIGNED_COOKIE 5
717 #define CISCO_REMOTE_END_ID 6
718 #define CISCO_PW_TYPE 7
719 #define CISCO_CIRCUIT_STATUS 8
720 #define CISCO_SESSION_TIE_BREAKER 9
721 #define CISCO_DRAFT_AVP_VERSION 10
722 #define CISCO_MESSAGE_DIGEST 12
723 #define CISCO_AUTH_NONCE 13
724 #define CISCO_INTERFACE_MTU 14
726 static const value_string cisco_avp_type_vals[] = {
727 { CISCO_ACK, "Cisco ACK" },
728 { CISCO_ASSIGNED_CONNECTION_ID, "Assigned Connection ID" },
729 { CISCO_PW_CAPABILITY_LIST, "Pseudowire Capabilities List" },
730 { CISCO_LOCAL_SESSION_ID, "Local Session ID" },
731 { CISCO_REMOTE_SESSION_ID, "Remote Session ID" },
732 { CISCO_ASSIGNED_COOKIE, "Assigned Cookie" },
733 { CISCO_REMOTE_END_ID, "Remote End ID" },
734 { CISCO_PW_TYPE, "Pseudowire Type" },
735 { CISCO_CIRCUIT_STATUS, "Circuit Status" },
736 { CISCO_SESSION_TIE_BREAKER, "Session Tie Breaker" },
737 { CISCO_DRAFT_AVP_VERSION, "Draft AVP Version" },
738 { CISCO_MESSAGE_DIGEST, "Message Digest" },
739 { CISCO_AUTH_NONCE, "Control Message Authentication Nonce" },
740 { CISCO_INTERFACE_MTU, "Interface MTU" },
741 { 0, NULL }
744 #define ERICSSON_MSG_TYPE 0
745 #define ERICSSON_TRANSPORT_CONFIG 1
746 #define ERICSSON_PACKET_LOSS 2
747 #define ERICSSON_PROTO_VERSION 3
748 #define ERICSSON_CONN_TYPE 4
749 #define ERICSSON_CRC_ENABLED 5
750 #define ERICSSON_STN_NAME 6
751 #define ERICSSON_ABIS_LOWER_MODE 7
752 #define ERICSSON_TEI_TO_SC_MAP 8
753 #define ERICSSON_CHAN_STATUS_LIST 9
754 #define ERICSSON_EXT_PROTO_VERSION 10
755 #define ERICSSON_CHAN_STATUS_LIST2 11
757 static const value_string ericsson_avp_type_vals[] = {
758 { ERICSSON_MSG_TYPE, "Message Type" },
759 { ERICSSON_TRANSPORT_CONFIG, "Transport Configuration" },
760 { ERICSSON_PACKET_LOSS, "Packet Loss" },
761 { ERICSSON_PROTO_VERSION, "Protocol Version" },
762 { ERICSSON_CONN_TYPE, "Connection Type" },
763 { ERICSSON_STN_NAME, "STN Name" },
764 { ERICSSON_CRC_ENABLED, "CRC32 Enabled" },
765 { ERICSSON_ABIS_LOWER_MODE, "Abis Lower Mode" },
766 { ERICSSON_TEI_TO_SC_MAP, "TEI to SC Map" },
767 { ERICSSON_CHAN_STATUS_LIST, "Channel Status List" },
768 { ERICSSON_EXT_PROTO_VERSION, "Extended Protocol Version" },
769 { ERICSSON_CHAN_STATUS_LIST2, "Channel Status List 2" },
770 { 0, NULL }
773 static const value_string ericsson_msg_type_vals[] = {
774 { 0, "Transport Configuration Notification" },
775 { 1, "Performance Notification" },
776 { 2, "Transport Configuration Request" },
777 { 3, "Transport Configuration Response" },
778 { 4, "Abis Lower Transport Config Request" },
779 { 5, "Abis Lower Transport Config Response" },
780 { 6, "Local Connect Channel Status Notification" },
781 { 0, NULL }
784 static const value_string ericsson_short_msg_type_vals[] = {
785 { 0, "TCN" },
786 { 1, "PN" },
787 { 2, "TCRQ" },
788 { 3, "TCRP" },
789 { 4, "ALTCRQ" },
790 { 5, "ALTCRP" },
791 { 6, "LCCSN" },
792 { 0, NULL }
795 static const value_string ericsson_conn_type_vals[] = {
796 { 0, "Primary" },
797 { 1, "Secondary" },
798 { 0, NULL }
801 static const value_string ericsson_abis_lower_mode_vals[] = {
802 { 0, "Single Timeslot" },
803 { 1, "Super Channel" },
804 { 0, NULL }
807 #define BROADBAND_AGENT_CIRCUIT_ID 1
808 #define BROADBAND_AGENT_REMOTE_ID 2
809 #define BROADBAND_ACTUAL_DR_UP 129
810 #define BROADBAND_ACTUAL_DR_DOWN 130
811 #define BROADBAND_MINIMUM_DR_UP 131
812 #define BROADBAND_MINIMUM_DR_DOWN 132
813 #define BROADBAND_ATTAINABLE_DR_UP 133
814 #define BROADBAND_ATTAINABLE_DR_DOWN 134
815 #define BROADBAND_MAXIMUM_DR_UP 135
816 #define BROADBAND_MAXIMUM_DR_DOWN 136
817 #define BROADBAND_MINIMUM_DR_UP_LOW_POWER 137
818 #define BROADBAND_MINIMUM_DR_DOWN_LOW_POWER 138
819 #define BROADBAND_MAXIMUM_INTERLEAVING_DELAY_UP 139
820 #define BROADBAND_ACTUAL_INTERLEAVING_DELAY_UP 140
821 #define BROADBAND_MAXIMUM_INTERLEAVING_DELAY_DOWN 141
822 #define BROADBAND_ACTUAL_INTERLEAVING_DELAY_DOWN 142
823 #define BROADBAND_ACCESS_LOOP_ENCAPSULATION 144
824 #define BROADBAND_ANCP_ACCESS_LINE_TYPE 145
825 #define BROADBAND_IWF_SESSION 254
827 static const value_string broadband_avp_type_vals[] = {
828 { BROADBAND_AGENT_CIRCUIT_ID, "Agent-Circuit-Id" },
829 { BROADBAND_AGENT_REMOTE_ID, "Agent-Remote-Id" },
830 { BROADBAND_ACTUAL_DR_UP, "Actual-Data-Rate-Upstream" },
831 { BROADBAND_ACTUAL_DR_DOWN, "Actual-Data-Rate-Downstream" },
832 { BROADBAND_MINIMUM_DR_UP, "Minimum-Data-Rate-Upstream" },
833 { BROADBAND_MINIMUM_DR_DOWN, "Minimum-Data-Rate-Downstream" },
834 { BROADBAND_ATTAINABLE_DR_UP, "Attainable-Data-Rate-Upstream" },
835 { BROADBAND_ATTAINABLE_DR_DOWN, "Attainable-Data-Rate-Downstream" },
836 { BROADBAND_MAXIMUM_DR_UP, "Maximum-Data-Rate-Upstream" },
837 { BROADBAND_MAXIMUM_DR_DOWN, "Maximum-Data-Rate-Downstream" },
838 { BROADBAND_MINIMUM_DR_UP_LOW_POWER, "Minimum-Data-Rate-Upstream-Low-Power" },
839 { BROADBAND_MINIMUM_DR_DOWN_LOW_POWER, "Minimum-Data-Rate-Downstream-Low-Power" },
840 { BROADBAND_MAXIMUM_INTERLEAVING_DELAY_UP, "Maximum-Interleaving-Delay-Upstream" },
841 { BROADBAND_ACTUAL_INTERLEAVING_DELAY_UP, "Actual-Interleaving-Delay-Upstream" },
842 { BROADBAND_MAXIMUM_INTERLEAVING_DELAY_DOWN, "Maximum-Interleaving-Delay-Downstream" },
843 { BROADBAND_ACTUAL_INTERLEAVING_DELAY_DOWN, "Actual-Interleaving-Delay-Downstream" },
844 { BROADBAND_ACCESS_LOOP_ENCAPSULATION, "Access-Loop-Encapsulation" },
845 { BROADBAND_ANCP_ACCESS_LINE_TYPE, "ANCP Access Line Type" },
846 { BROADBAND_IWF_SESSION, "IWF-Session" },
847 { 0, NULL }
850 static const value_string cablelabs_avp_type_vals[] = {
851 /* 7.5.2 DEPI Specific AVPs */
852 { 0, "Reserved" },
853 { 1, "DEPI Result Code" },
854 { 2, "DEPI Resource Allocation Request" },
855 { 3, "DEPI Resource Allocation Reply" },
856 { 4, "DEPI Local MTU" },
857 { 5, "DOCSIS SYNC Control" },
858 { 6, "EQAM Capability Bits" },
859 { 7, "DEPI Remote MTU" },
860 { 8, "DEPI Local UDP Port" },
861 { 9, "DPR Session Type" },
862 { 10, "DPR Session Status" },
863 /* 7.5.3 QAM Channel PHY AVPs */
864 { 100, "Downstream QAM Channel TSID Group" },
865 { 101, "Downstream QAM Channel Frequency" },
866 { 102, "Downstream QAM Channel Power" },
867 { 103, "Downstream QAM Channel Modulation" },
868 { 104, "Downstream QAM Channel J.83 Annex" },
869 { 105, "Downstream QAM Channel Symbol Rate" },
870 { 106, "Downstream QAM Channel Interleave Depth" },
871 { 107, "Downstream QAM Channel RF Block Muting53" },
872 /* 7.5.4 DEPI Redundancy Capabilities AVPs */
873 { 200, "DEPI Redundancy Capabilities" },
874 { 0, NULL }
877 static const value_string l2tp_cablel_modulation_vals[] = {
878 { 0, "64-QAM" },
879 { 1, "128-QAM" },
880 { 0, NULL }
883 static const value_string pw_types_vals[] = {
884 { L2TPv3_PW_FR, "Frame Relay DLCI" },
885 { L2TPv3_PW_AAL5, "ATM AAL5 SDU VCC transport" },
886 { L2TPv3_PW_ATM_PORT, "ATM Cell transparent Port Mode" },
887 { L2TPv3_PW_ETH_VLAN, "Ethernet VLAN" },
888 { L2TPv3_PW_ETH, "Ethernet" },
889 { L2TPv3_PW_CHDLC, "HDLC" },
890 { L2TPv3_PW_PPP, "PPP" }, /* Currently unassigned */
891 { L2TPv3_PW_ATM_VCC, "ATM Cell transport VCC Mode" },
892 { L2TPv3_PW_ATM_VPC, "ATM Cell transport VPC Mode" },
893 { L2TPv3_PW_IP, "IP Transport" }, /* Currently unassigned */
894 { L2TPv3_PW_DOCSIS_DMPT, "MPEG-TS Payload Type (MPTPW)" },
895 { L2TPv3_PW_DOCSIS_PSP, "Packet Streaming Protocol (PSPPW)" },
896 /* 0x000E-0x0010 Unassigned */
897 { L2TPv3_PW_E1, "Structure-agnostic E1 circuit" }, /* [RFC5611] */
898 { L2TPv3_PW_T1, "Structure-agnostic T1 (DS1) circuit" }, /* [RFC5611] */
899 { L2TPv3_PW_E3, "Structure-agnostic E3 circuit" }, /* [RFC5611] */
900 { L2TPv3_PW_T3, "Structure-agnostic T3 (DS3) circuit" }, /* [RFC5611] */
901 { L2TPv3_PW_CESOPSN, "CESoPSN basic mode" }, /* [RFC5611] */
902 { 0x0016, "Unassigned" },
903 { L2TPv3_PW_CESOPSN_CAS, "CESoPSN TDM with CAS" }, /* [RFC5611] */
905 { 0, NULL },
908 static const value_string ale_datalink_types_vals[] = {
909 { 0x00, "ATM AAL5" },
910 { 0x01, "Ethernet" },
911 { 0, NULL },
914 static const value_string ale_enc1_types_vals[] = {
915 { 0x00, "NA - Not Available" },
916 { 0x01, "Untagged Ethernet" },
917 { 0x02, "Single-Tagged Ethernet" },
918 { 0, NULL },
921 static const value_string ale_enc2_types_vals[] = {
922 { 0x00, "NA - Not Available" },
923 { 0x01, "PPPoA LLC" },
924 { 0x02, "PPPoA Null" },
925 { 0x03, "IP over ATM (IPoA) LLC" },
926 { 0x04, "IPoA Null" },
927 { 0x05, "Ethernet over AAL5 LLC with Frame Check Sequence (FCS)" },
928 { 0x06, "Ethernet over AAL5 LLC without FCS" },
929 { 0x07, "Ethernet over AAL5 Null with FCS" },
930 { 0x08, "Ethernet over AAL5 Null without FCS" },
931 { 0, NULL },
934 static const value_string ancp_types_vals[] = {
935 { 0x01, "ADSL1" },
936 { 0x02, "ADSL2" },
937 { 0x03, "ADSL2+" },
938 { 0x04, "VDSL1" },
939 { 0x05, "VDSL2" },
940 { 0x06, "SDSL" },
941 { 0x07, "UNKNOWN" },
942 { 0, NULL },
945 static const value_string iwf_types_vals[] = {
946 { 0x00, "IWF not performed" },
947 { 0x01, "IWF performed" },
948 { 0, NULL },
951 static const val64_string unique_indeterminable_or_no_link[] = {
952 { 0, "indeterminable or no physical p2p link" },
953 { 0, NULL },
956 static const true_false_string tfs_new_existing = { "New", "Existing" };
958 static dissector_handle_t ppp_hdlc_handle;
959 static dissector_handle_t ppp_lcp_options_handle;
961 static dissector_handle_t atm_oam_handle;
962 static dissector_handle_t llc_handle;
964 static dissector_handle_t l2tp_udp_handle;
965 static dissector_handle_t l2tp_ip_handle;
966 static dissector_handle_t atm_oam_llc_handle;
968 #define L2TP_HMAC_MD5 0
969 #define L2TP_HMAC_SHA1 1
971 typedef struct l2tpv3_conversation {
972 address lcce1;
973 uint16_t lcce1_port;
974 address lcce2;
975 uint16_t lcce2_port;
976 port_type pt;
977 struct l2tpv3_tunnel *tunnel;
978 } l2tpv3_conversation_t;
980 typedef struct l2tpv3_tunnel {
981 l2tpv3_conversation_t *conv;
983 address lcce1;
984 uint32_t lcce1_id;
985 uint8_t *lcce1_nonce;
986 int lcce1_nonce_len;
988 address lcce2;
989 uint32_t lcce2_id;
990 uint8_t *lcce2_nonce;
991 int lcce2_nonce_len;
993 char *shared_key_secret;
994 uint8_t shared_key[HASH_MD5_LENGTH];
996 GSList *sessions;
997 } l2tpv3_tunnel_t;
999 typedef struct lcce_settings {
1000 uint32_t id;
1001 int cookie_len;
1002 int l2_specific;
1003 } lcce_settings_t;
1005 typedef struct l2tpv3_session {
1006 lcce_settings_t lcce1;
1007 lcce_settings_t lcce2;
1009 unsigned pw_type;
1010 } l2tpv3_session_t;
1012 static const char* shared_secret = "";
1014 static GSList *list_heads;
1016 static void update_shared_key(l2tpv3_tunnel_t *tunnel)
1018 const char *secret = "";
1020 /* There is at least one nonce in the packet, so we can do authentication,
1021 otherwise it's just a plain digest without nonces. */
1022 if (tunnel->lcce1_nonce != NULL || tunnel->lcce2_nonce != NULL) {
1023 secret = shared_secret;
1026 /* If there's no shared key in the conversation context, or the secret has been changed */
1027 if (tunnel->shared_key_secret == NULL || strcmp(secret, tunnel->shared_key_secret) != 0) {
1028 /* For secret specification, see RFC 3931 pg 37 */
1029 uint8_t data = 2;
1030 if (ws_hmac_buffer(GCRY_MD_MD5, tunnel->shared_key, &data, 1, secret, strlen(secret))) {
1031 return;
1033 tunnel->shared_key_secret = wmem_strdup(wmem_file_scope(), secret);
1037 static void md5_hmac_digest(l2tpv3_tunnel_t *tunnel,
1038 tvbuff_t *tvb,
1039 int length,
1040 int idx,
1041 int avp_len,
1042 int msg_type,
1043 packet_info *pinfo,
1044 uint8_t digest[20])
1046 uint8_t zero[HASH_MD5_LENGTH] = { 0 };
1047 gcry_md_hd_t hmac_handle;
1048 int remainder;
1049 int offset = 0;
1051 if (tunnel->conv->pt == PT_NONE) /* IP encapsulated L2TPv3 */
1052 offset = 4;
1054 if (gcry_md_open(&hmac_handle, GCRY_MD_MD5, GCRY_MD_FLAG_HMAC)) {
1055 return;
1057 if (gcry_md_setkey(hmac_handle, tunnel->shared_key, HASH_MD5_LENGTH)) {
1058 gcry_md_close(hmac_handle);
1059 return;
1062 if (msg_type != MESSAGE_TYPE_SCCRQ) {
1063 if (tunnel->lcce1_nonce != NULL && tunnel->lcce2_nonce != NULL) {
1064 if (addresses_equal(&tunnel->lcce1, &pinfo->src)) {
1065 gcry_md_write(hmac_handle, tunnel->lcce1_nonce, tunnel->lcce1_nonce_len);
1066 gcry_md_write(hmac_handle, tunnel->lcce2_nonce, tunnel->lcce2_nonce_len);
1067 } else {
1068 gcry_md_write(hmac_handle, tunnel->lcce2_nonce, tunnel->lcce2_nonce_len);
1069 gcry_md_write(hmac_handle, tunnel->lcce1_nonce, tunnel->lcce1_nonce_len);
1074 gcry_md_write(hmac_handle, tvb_get_ptr(tvb, offset, idx + 1 - offset), idx + 1 - offset);
1075 /* Message digest is calculated with an empty message digest field */
1076 gcry_md_write(hmac_handle, zero, avp_len - 1);
1077 remainder = length - (idx + avp_len);
1078 gcry_md_write(hmac_handle, tvb_get_ptr(tvb, idx + avp_len, remainder), remainder);
1079 memcpy(digest, gcry_md_read(hmac_handle, 0), HASH_MD5_LENGTH);
1080 gcry_md_close(hmac_handle);
1083 static void sha1_hmac_digest(l2tpv3_tunnel_t *tunnel,
1084 tvbuff_t *tvb,
1085 int length,
1086 int idx,
1087 int avp_len,
1088 int msg_type,
1089 packet_info *pinfo,
1090 uint8_t digest[20])
1092 uint8_t zero[HASH_SHA1_LENGTH] = { 0 };
1093 gcry_md_hd_t hmac_handle;
1094 int remainder;
1095 int offset = 0;
1097 if (tunnel->conv->pt == PT_NONE) /* IP encapsulated L2TPv3 */
1098 offset = 4;
1100 if (gcry_md_open(&hmac_handle, GCRY_MD_SHA1, GCRY_MD_FLAG_HMAC)) {
1101 return;
1103 if (gcry_md_setkey(hmac_handle, tunnel->shared_key, HASH_MD5_LENGTH)) {
1104 gcry_md_close(hmac_handle);
1105 return;
1108 if (msg_type != MESSAGE_TYPE_SCCRQ) {
1109 if (tunnel->lcce1_nonce != NULL && tunnel->lcce2_nonce != NULL) {
1110 if (addresses_equal(&tunnel->lcce1, &pinfo->src)) {
1111 gcry_md_write(hmac_handle, tunnel->lcce1_nonce, tunnel->lcce1_nonce_len);
1112 gcry_md_write(hmac_handle, tunnel->lcce2_nonce, tunnel->lcce2_nonce_len);
1113 } else {
1114 gcry_md_write(hmac_handle, tunnel->lcce2_nonce, tunnel->lcce2_nonce_len);
1115 gcry_md_write(hmac_handle, tunnel->lcce1_nonce, tunnel->lcce1_nonce_len);
1120 gcry_md_write(hmac_handle, tvb_get_ptr(tvb, offset, idx + 1 - offset), idx + 1 - offset);
1121 /* Message digest is calculated with an empty message digest field */
1122 gcry_md_write(hmac_handle, zero, avp_len - 1);
1123 remainder = length - (idx + avp_len);
1124 gcry_md_write(hmac_handle, tvb_get_ptr(tvb, idx + avp_len, remainder), remainder);
1125 memcpy(digest, gcry_md_read(hmac_handle, 0), HASH_SHA1_LENGTH);
1126 gcry_md_close(hmac_handle);
1129 static int check_control_digest(l2tpv3_tunnel_t *tunnel,
1130 tvbuff_t *tvb,
1131 int length,
1132 int idx,
1133 int avp_len,
1134 int msg_type,
1135 packet_info *pinfo)
1137 uint8_t digest[HASH_SHA1_LENGTH];
1139 if (!tunnel)
1140 return 1;
1142 update_shared_key(tunnel);
1144 switch (tvb_get_uint8(tvb, idx)) {
1145 case L2TP_HMAC_MD5:
1146 if ((avp_len - 1) != HASH_MD5_LENGTH)
1147 return -1;
1148 md5_hmac_digest(tunnel, tvb, length, idx, avp_len, msg_type, pinfo, digest);
1149 break;
1150 case L2TP_HMAC_SHA1:
1151 if ((avp_len - 1) != HASH_SHA1_LENGTH)
1152 return -1;
1153 sha1_hmac_digest(tunnel, tvb, length, idx, avp_len, msg_type, pinfo, digest);
1154 break;
1155 default:
1156 return 1;
1159 return tvb_memeql(tvb, idx + 1, digest, avp_len - 1);
1162 static void store_cma_nonce(l2tpv3_tunnel_t *tunnel,
1163 tvbuff_t *tvb,
1164 int offset,
1165 int length,
1166 int msg_type)
1168 uint8_t *nonce = NULL;
1170 if (!tunnel)
1171 return;
1173 switch (msg_type) {
1174 case MESSAGE_TYPE_SCCRQ:
1175 if (!tunnel->lcce1_nonce) {
1176 tunnel->lcce1_nonce = (uint8_t *)wmem_alloc(wmem_file_scope(), length);
1177 tunnel->lcce1_nonce_len = length;
1178 nonce = tunnel->lcce1_nonce;
1180 break;
1181 case MESSAGE_TYPE_SCCRP:
1182 if (!tunnel->lcce2_nonce) {
1183 tunnel->lcce2_nonce = (uint8_t *)wmem_alloc(wmem_file_scope(), length);
1184 tunnel->lcce2_nonce_len = length;
1185 nonce = tunnel->lcce2_nonce;
1187 break;
1188 default:
1189 break;
1192 if (nonce)
1193 tvb_memcpy(tvb, (void *)nonce, offset, length);
1195 return;
1198 static void store_ccid(l2tpv3_tunnel_t *tunnel,
1199 tvbuff_t *tvb,
1200 int offset,
1201 int msg_type)
1203 if (!tunnel)
1204 return;
1206 switch (msg_type) {
1207 case MESSAGE_TYPE_SCCRQ:
1208 tunnel->lcce1_id = tvb_get_ntohl(tvb, offset);
1209 break;
1210 case MESSAGE_TYPE_SCCRP:
1211 tunnel->lcce2_id = tvb_get_ntohl(tvb, offset);
1212 break;
1213 default:
1214 break;
1217 return;
1220 static l2tpv3_session_t *find_session(l2tpv3_tunnel_t *tunnel,
1221 uint32_t lcce1_id,
1222 uint32_t lcce2_id)
1224 l2tpv3_session_t *session = NULL;
1225 GSList *iterator;
1227 iterator = tunnel->sessions;
1228 while (iterator) {
1229 session = (l2tpv3_session_t *)iterator->data;
1231 if ((session->lcce1.id == lcce1_id) ||
1232 (session->lcce2.id == lcce2_id)) {
1233 return session;
1236 iterator = g_slist_next(iterator);
1239 return NULL;
1242 static void init_session(l2tpv3_session_t *session)
1244 session->lcce1.cookie_len = session->lcce2.cookie_len = -1;
1245 session->lcce1.l2_specific = session->lcce2.l2_specific = -1;
1246 session->pw_type = L2TPv3_PW_DEFAULT;
1249 static l2tpv3_session_t *alloc_session(void)
1251 l2tpv3_session_t *session = wmem_new0(wmem_packet_scope(), l2tpv3_session_t);
1252 init_session(session);
1254 return session;
1257 static l2tpv3_session_t *store_lsession_id(l2tpv3_session_t *_session,
1258 tvbuff_t *tvb,
1259 int offset,
1260 int msg_type)
1262 l2tpv3_session_t *session = _session;
1264 switch (msg_type) {
1265 case MESSAGE_TYPE_ICRQ:
1266 case MESSAGE_TYPE_OCRQ:
1267 case MESSAGE_TYPE_ICRP:
1268 case MESSAGE_TYPE_OCRP:
1269 break;
1270 default:
1271 return session;
1274 if (session == NULL)
1275 session = alloc_session();
1277 switch (msg_type) {
1278 case MESSAGE_TYPE_ICRQ:
1279 case MESSAGE_TYPE_OCRQ:
1280 session->lcce1.id = tvb_get_ntohl(tvb, offset);
1281 break;
1282 case MESSAGE_TYPE_ICRP:
1283 case MESSAGE_TYPE_OCRP:
1284 session->lcce2.id = tvb_get_ntohl(tvb, offset);
1285 break;
1288 return session;
1291 static l2tpv3_session_t *store_rsession_id(l2tpv3_session_t *_session,
1292 tvbuff_t *tvb,
1293 int offset,
1294 int msg_type)
1296 l2tpv3_session_t *session = _session;
1298 switch (msg_type) {
1299 case MESSAGE_TYPE_ICRP:
1300 case MESSAGE_TYPE_OCRP:
1301 break;
1302 default:
1303 return session;
1306 if (session == NULL)
1307 session = alloc_session();
1309 session->lcce1.id = tvb_get_ntohl(tvb, offset);
1311 return session;
1314 static l2tpv3_session_t *store_cookie_len(l2tpv3_session_t *_session,
1315 int len,
1316 int msg_type)
1318 l2tpv3_session_t *session = _session;
1320 switch (msg_type) {
1321 case MESSAGE_TYPE_ICRQ:
1322 case MESSAGE_TYPE_OCRQ:
1323 case MESSAGE_TYPE_ICRP:
1324 case MESSAGE_TYPE_OCRP:
1325 break;
1326 default:
1327 return session;
1330 if (session == NULL)
1331 session = alloc_session();
1333 switch (msg_type) {
1334 case MESSAGE_TYPE_ICRQ:
1335 case MESSAGE_TYPE_OCRQ:
1336 session->lcce1.cookie_len = len;
1337 break;
1338 case MESSAGE_TYPE_ICRP:
1339 case MESSAGE_TYPE_OCRP:
1340 session->lcce2.cookie_len = len;
1341 break;
1344 return session;
1347 static l2tpv3_session_t *store_pw_type(l2tpv3_session_t *_session,
1348 tvbuff_t *tvb,
1349 int offset,
1350 int msg_type)
1352 l2tpv3_session_t *session = _session;
1354 switch (msg_type) {
1355 case MESSAGE_TYPE_ICRQ:
1356 case MESSAGE_TYPE_OCRQ:
1357 break;
1358 default:
1359 return session;
1362 if (session == NULL)
1363 session = alloc_session();
1365 session->pw_type = tvb_get_ntohs(tvb, offset);
1367 return session;
1370 static l2tpv3_session_t *store_l2_sublayer(l2tpv3_session_t *_session,
1371 tvbuff_t *tvb,
1372 int offset,
1373 int msg_type)
1375 l2tpv3_session_t *session = _session;
1376 int result = l2tpv3_l2_specific;
1377 uint16_t l2_sublayer;
1379 switch (msg_type) {
1380 case MESSAGE_TYPE_ICRQ:
1381 case MESSAGE_TYPE_OCRQ:
1382 case MESSAGE_TYPE_ICCN:
1383 case MESSAGE_TYPE_OCCN:
1384 case MESSAGE_TYPE_ICRP:
1385 case MESSAGE_TYPE_OCRP:
1386 break;
1387 default:
1388 return session;
1391 if (session == NULL)
1392 session = alloc_session();
1394 l2_sublayer = tvb_get_ntohs(tvb, offset);
1395 switch (l2_sublayer) {
1396 case 0x0000:
1397 result = L2TPv3_L2_SPECIFIC_NONE; break;
1398 case 0x0001:
1399 result = L2TPv3_L2_SPECIFIC_DEFAULT; break;
1400 case 0x0002:
1401 result = L2TPv3_L2_SPECIFIC_ATM; break;
1402 case 0x0003:
1403 result = L2TPv3_L2_SPECIFIC_DOCSIS_DMPT; break;
1404 default:
1405 break;
1408 switch (msg_type) {
1409 case MESSAGE_TYPE_ICRQ:
1410 case MESSAGE_TYPE_OCRQ:
1411 case MESSAGE_TYPE_ICCN:
1412 case MESSAGE_TYPE_OCCN:
1413 session->lcce1.l2_specific = result;
1414 /* FALL THROUGH */
1415 case MESSAGE_TYPE_ICRP:
1416 case MESSAGE_TYPE_OCRP:
1417 session->lcce2.l2_specific = result;
1418 break;
1421 return session;
1424 static void update_session(l2tpv3_tunnel_t *tunnel, l2tpv3_session_t *session)
1426 l2tpv3_session_t *existing = NULL;
1428 if (tunnel == NULL || session == NULL)
1429 return;
1431 if (session->lcce1.id == 0 && session->lcce2.id == 0)
1432 return;
1434 existing = find_session(tunnel, session->lcce1.id, session->lcce2.id);
1435 if (!existing) {
1436 existing = wmem_new0(wmem_file_scope(), l2tpv3_session_t);
1437 init_session(existing);
1440 if (session->lcce1.id != 0)
1441 existing->lcce1.id = session->lcce1.id;
1443 if (session->lcce2.id != 0)
1444 existing->lcce2.id = session->lcce2.id;
1446 if (session->lcce1.cookie_len != -1)
1447 existing->lcce1.cookie_len = session->lcce1.cookie_len;
1449 if (session->lcce2.cookie_len != -1)
1450 existing->lcce2.cookie_len = session->lcce2.cookie_len;
1452 if (session->lcce1.l2_specific != -1)
1453 existing->lcce1.l2_specific = session->lcce1.l2_specific;
1455 if (session->lcce2.l2_specific != -1)
1456 existing->lcce2.l2_specific = session->lcce2.l2_specific;
1458 if (session->pw_type != L2TPv3_PW_DEFAULT)
1459 existing->pw_type = session->pw_type;
1461 if (tunnel->sessions == NULL) {
1462 tunnel->sessions = g_slist_append(tunnel->sessions, existing);
1463 list_heads = g_slist_append(list_heads, tunnel->sessions);
1464 } else {
1465 tunnel->sessions = g_slist_append(tunnel->sessions, existing);
1469 static void l2tp_prompt(packet_info *pinfo _U_, char* result)
1471 snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "Decode L2TPv3 pseudowire type 0x%04x as",
1472 GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, proto_l2tp, 0)));
1475 static void *l2tp_value(packet_info *pinfo _U_)
1477 return p_get_proto_data(pinfo->pool, pinfo, proto_l2tp, 0);
1481 * Dissect CISCO AVP:s
1483 static int dissect_l2tp_cisco_avps(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, l2tp_cntrl_data_t *l2tp_cntrl_data, l2tpv3_session_t **session) {
1485 int offset = 0;
1486 int avp_type;
1487 uint32_t avp_vendor_id;
1488 uint16_t avp_len;
1489 uint16_t ver_len_hidden;
1490 proto_tree *l2tp_avp_tree, *l2tp_avp_tree_sub;
1492 ver_len_hidden = tvb_get_ntohs(tvb, offset);
1493 avp_len = AVP_LENGTH(ver_len_hidden);
1494 avp_vendor_id = tvb_get_ntohs(tvb, offset + 2);
1495 avp_type = tvb_get_ntohs(tvb, offset + 4);
1497 l2tp_avp_tree = proto_tree_add_subtree_format(tree, tvb, offset,
1498 avp_len, ett_l2tp_avp, NULL, "Vendor %s (%u): %s AVP",
1499 enterprises_lookup(avp_vendor_id, "Unknown"), avp_vendor_id,
1500 val_to_str(avp_type, cisco_avp_type_vals, "Unknown (%u)"));
1502 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_mandatory, tvb, offset, 2, ENC_BIG_ENDIAN);
1503 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_hidden, tvb, offset, 2, ENC_BIG_ENDIAN);
1504 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_length, tvb, offset, 2, ENC_BIG_ENDIAN);
1506 if (HIDDEN_BIT(ver_len_hidden)) { /* don't try do display hidden */
1507 offset += avp_len;
1508 return offset;
1511 offset += 2;
1512 avp_len -= 2;
1514 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_vendor_id, tvb, offset, 2, ENC_BIG_ENDIAN);
1515 offset += 2;
1516 avp_len -= 2;
1518 proto_tree_add_uint(l2tp_avp_tree, hf_l2tp_cisco_avp_type, tvb, offset, 2, avp_type);
1519 offset += 2;
1520 avp_len -= 2;
1522 switch (avp_type) {
1523 case CISCO_ACK:
1524 /* process_l2tpv3_control does not set COL_INFO for vendor messages */
1525 col_add_fstr(pinfo->cinfo, COL_INFO, "%s - Cisco ACK (ccid=%u)", control_msg, l2tp_cntrl_data->ccid);
1526 break;
1528 case CISCO_ASSIGNED_CONNECTION_ID:
1529 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_cisco_assigned_control_connection_id, tvb, offset, 4, ENC_BIG_ENDIAN);
1530 break;
1532 case CISCO_PW_CAPABILITY_LIST:
1533 l2tp_avp_tree_sub = proto_tree_add_subtree(l2tp_avp_tree, tvb, offset, avp_len,
1534 ett_l2tp_avp_sub, NULL, "Pseudowire Capabilities List");
1535 while (avp_len >= 2) {
1536 proto_tree_add_item(l2tp_avp_tree_sub, hf_l2tp_cisco_pw_type, tvb, offset, 2, ENC_BIG_ENDIAN);
1537 offset += 2;
1538 avp_len -= 2;
1540 break;
1542 case CISCO_LOCAL_SESSION_ID:
1543 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_cisco_local_session_id, tvb, offset, 4, ENC_BIG_ENDIAN);
1544 *session = store_lsession_id(*session, tvb, offset, l2tp_cntrl_data->msg_type);
1545 break;
1546 case CISCO_REMOTE_SESSION_ID:
1547 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_cisco_remote_session_id, tvb, offset, 4, ENC_BIG_ENDIAN);
1548 *session = store_rsession_id(*session, tvb, offset, l2tp_cntrl_data->msg_type);
1549 break;
1550 case CISCO_ASSIGNED_COOKIE:
1551 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_cisco_assigned_cookie, tvb, offset, avp_len, ENC_NA);
1552 *session = store_cookie_len(*session, avp_len, l2tp_cntrl_data->msg_type);
1553 break;
1554 case CISCO_REMOTE_END_ID:
1555 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_cisco_remote_end_id, tvb, offset, avp_len, ENC_NA|ENC_ASCII);
1556 break;
1557 case CISCO_PW_TYPE:
1558 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_cisco_pseudowire_type, tvb, offset, 2, ENC_BIG_ENDIAN);
1559 *session = store_pw_type(*session, tvb, offset, l2tp_cntrl_data->msg_type);
1560 break;
1561 case CISCO_CIRCUIT_STATUS:
1562 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_cisco_circuit_status, tvb, offset, 2, ENC_BIG_ENDIAN);
1563 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_cisco_circuit_type, tvb, offset, 2, ENC_BIG_ENDIAN);
1564 break;
1565 case CISCO_SESSION_TIE_BREAKER:
1566 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_cisco_tie_breaker,
1567 tvb, offset, 8, ENC_BIG_ENDIAN);
1568 break;
1569 case CISCO_DRAFT_AVP_VERSION:
1570 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_cisco_draft_avp_version, tvb, offset, 2, ENC_BIG_ENDIAN);
1571 break;
1572 case CISCO_MESSAGE_DIGEST:
1573 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_cisco_message_digest, tvb, offset, avp_len, ENC_NA);
1574 break;
1575 case CISCO_AUTH_NONCE:
1576 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_cisco_nonce, tvb, offset, avp_len, ENC_NA);
1577 break;
1578 case CISCO_INTERFACE_MTU:
1579 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_cisco_interface_mtu, tvb, offset, avp_len, ENC_BIG_ENDIAN);
1580 break;
1582 default:
1583 proto_tree_add_expert(l2tp_avp_tree, pinfo, &ei_l2tp_vendor_specific_avp_data, tvb, offset, avp_len);
1584 break;
1586 offset += avp_len;
1588 return offset;
1592 * Dissect Broadband Forums AVP:s
1594 static int dissect_l2tp_broadband_avps(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree) {
1596 int offset = 0;
1597 int avp_type;
1598 uint32_t avp_vendor_id;
1599 uint16_t avp_len;
1600 uint16_t ver_len_hidden;
1601 proto_tree *l2tp_avp_tree, *l2tp_avp_ale_tree;
1602 proto_item *ta;
1604 ver_len_hidden = tvb_get_ntohs(tvb, offset);
1605 avp_len = AVP_LENGTH(ver_len_hidden);
1606 avp_vendor_id = tvb_get_ntohs(tvb, offset + 2);
1607 avp_type = tvb_get_ntohs(tvb, offset + 4);
1609 l2tp_avp_tree = proto_tree_add_subtree_format(tree, tvb, offset,
1610 avp_len, ett_l2tp_avp, NULL, "Vendor %s (%u): %s AVP",
1611 enterprises_lookup(avp_vendor_id, "Unknown"), avp_vendor_id,
1612 val_to_str(avp_type, broadband_avp_type_vals, "Unknown (%u)"));
1614 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_mandatory, tvb, offset, 2, ENC_BIG_ENDIAN);
1615 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_hidden, tvb, offset, 2, ENC_BIG_ENDIAN);
1616 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_length, tvb, offset, 2, ENC_BIG_ENDIAN);
1618 if (HIDDEN_BIT(ver_len_hidden)) { /* don't try do display hidden */
1619 offset += avp_len;
1620 return offset;
1623 offset += 2;
1624 avp_len -= 2;
1626 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_vendor_id, tvb, offset, 2, ENC_BIG_ENDIAN);
1627 offset += 2;
1628 avp_len -= 2;
1630 proto_tree_add_uint(l2tp_avp_tree, hf_l2tp_broadband_avp_type, tvb, offset, 2, avp_type);
1631 offset += 2;
1632 avp_len -= 2;
1634 switch (avp_type) {
1636 case BROADBAND_AGENT_CIRCUIT_ID:
1637 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_broadband_agent_circuit_id, tvb, offset, avp_len, ENC_UTF_8);
1638 break;
1640 case BROADBAND_AGENT_REMOTE_ID:
1641 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_broadband_agent_remote_id, tvb, offset, avp_len, ENC_UTF_8);
1642 break;
1644 case BROADBAND_ACTUAL_DR_UP:
1645 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_broadband_actual_dr_up, tvb, offset, 8, ENC_BIG_ENDIAN);
1646 break;
1648 case BROADBAND_ACTUAL_DR_DOWN:
1649 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_broadband_actual_dr_down, tvb, offset, 8, ENC_BIG_ENDIAN);
1650 break;
1652 case BROADBAND_MINIMUM_DR_UP:
1653 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_broadband_minimum_dr_up, tvb, offset, 8, ENC_BIG_ENDIAN);
1654 break;
1656 case BROADBAND_MINIMUM_DR_DOWN:
1657 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_broadband_minimum_dr_down, tvb, offset, 8, ENC_BIG_ENDIAN);
1658 break;
1660 case BROADBAND_ATTAINABLE_DR_UP:
1661 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_broadband_attainable_dr_up, tvb, offset, 8, ENC_BIG_ENDIAN);
1662 break;
1664 case BROADBAND_ATTAINABLE_DR_DOWN:
1665 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_broadband_attainable_dr_down, tvb, offset, 8, ENC_BIG_ENDIAN);
1666 break;
1668 case BROADBAND_MAXIMUM_DR_UP:
1669 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_broadband_maximum_dr_up, tvb, offset, 8, ENC_BIG_ENDIAN);
1670 break;
1672 case BROADBAND_MAXIMUM_DR_DOWN:
1673 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_broadband_maximum_dr_down, tvb, offset, 8, ENC_BIG_ENDIAN);
1674 break;
1676 case BROADBAND_MINIMUM_DR_UP_LOW_POWER:
1677 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_broadband_minimum_dr_up_low_power, tvb, offset, 8, ENC_BIG_ENDIAN);
1678 break;
1680 case BROADBAND_MINIMUM_DR_DOWN_LOW_POWER:
1681 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_broadband_minimum_dr_down_low_power, tvb, offset, 8, ENC_BIG_ENDIAN);
1682 break;
1684 case BROADBAND_MAXIMUM_INTERLEAVING_DELAY_UP:
1685 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_broadband_maximum_interleaving_delay_up, tvb, offset, 4, ENC_BIG_ENDIAN);
1686 break;
1688 case BROADBAND_ACTUAL_INTERLEAVING_DELAY_UP:
1689 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_broadband_actual_interleaving_delay_up, tvb, offset, 4, ENC_BIG_ENDIAN);
1690 break;
1692 case BROADBAND_MAXIMUM_INTERLEAVING_DELAY_DOWN:
1693 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_broadband_maximum_interleaving_delay_down, tvb, offset, 4, ENC_BIG_ENDIAN);
1694 break;
1696 case BROADBAND_ACTUAL_INTERLEAVING_DELAY_DOWN:
1697 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_broadband_actual_interleaving_delay_down, tvb, offset, 4, ENC_BIG_ENDIAN);
1698 break;
1700 case BROADBAND_ACCESS_LOOP_ENCAPSULATION:
1702 ta = proto_tree_add_item(l2tp_avp_tree, hf_l2tp_broadband_access_loop_encapsulation, tvb, offset, avp_len, ENC_NA);
1703 l2tp_avp_ale_tree = proto_item_add_subtree(ta, ett_l2tp_ale_sub);
1704 proto_tree_add_item(l2tp_avp_ale_tree, hf_l2tp_broadband_access_loop_encapsulation_data_link, tvb, offset, 1, ENC_BIG_ENDIAN);
1705 proto_tree_add_item(l2tp_avp_ale_tree, hf_l2tp_broadband_access_loop_encapsulation_enc1, tvb, offset+1, 1, ENC_BIG_ENDIAN);
1706 proto_tree_add_item(l2tp_avp_ale_tree, hf_l2tp_broadband_access_loop_encapsulation_enc2, tvb, offset+2, 1, ENC_BIG_ENDIAN);
1708 break;
1710 case BROADBAND_ANCP_ACCESS_LINE_TYPE:
1711 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_broadband_ancp_access_line_type, tvb, offset, avp_len, ENC_BIG_ENDIAN);
1712 break;
1714 case BROADBAND_IWF_SESSION:
1715 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_broadband_iwf_session, tvb, offset, avp_len, ENC_BIG_ENDIAN);
1716 break;
1718 default:
1719 proto_tree_add_expert(l2tp_avp_tree, pinfo, &ei_l2tp_vendor_specific_avp_data, tvb, offset, avp_len);
1720 break;
1722 offset += avp_len;
1724 return offset;
1728 * Dissect Ericsson AVP:s
1731 /* Dissect a single variable-length Ericsson Transport Configuration Group */
1732 static int dissect_l2tp_ericsson_transp_cfg(tvbuff_t *tvb, proto_tree *parent_tree)
1734 int offset = 0;
1735 uint32_t i, num_sapis;
1736 proto_tree *tree;
1738 while (tvb_reported_length_remaining(tvb, offset) >= 8) {
1739 tree = proto_tree_add_subtree_format(parent_tree, tvb, 0, -1, ett_l2tp_ericsson_tcg,
1740 NULL, "Transport Config Bundling Group");
1741 proto_tree_add_item(tree, hf_l2tp_ericsson_tcg_group_id, tvb, offset++, 1, ENC_NA);
1742 proto_tree_add_item_ret_uint(tree, hf_l2tp_ericsson_tcg_num_sapis, tvb, offset++, 1, ENC_NA, &num_sapis);
1743 for (i = 0; i < num_sapis; i++) {
1744 proto_tree_add_item(tree, hf_l2tp_ericsson_tcg_sapi, tvb, offset++, 1, ENC_NA);
1746 proto_tree_add_item(tree, hf_l2tp_ericsson_tcg_ip, tvb, offset, 4, ENC_NA);
1747 offset += 4;
1748 proto_tree_add_item(tree, hf_l2tp_ericsson_tcg_dscp, tvb, offset++, 1, ENC_NA);
1749 proto_tree_add_item(tree, hf_l2tp_ericsson_tcg_crc32_enable, tvb, offset++, 1, ENC_NA);
1750 proto_tree_add_item(tree, hf_l2tp_ericsson_tcg_bundling_tout, tvb, offset++, 1, ENC_NA);
1751 proto_tree_add_item(tree, hf_l2tp_ericsson_tcg_bundling_max_pkt, tvb, offset, 2, ENC_BIG_ENDIAN);
1752 offset += 2;
1755 return offset;
1758 /* Dissect a single 3-byte Ericsson TEI-to-SC Map */
1759 static int dissect_l2tp_ericsson_tei_sc_map(tvbuff_t *tvb, proto_tree *parent_tree)
1761 int i = 0, offset = 0;
1762 proto_tree *tree;
1764 while (tvb_reported_length_remaining(tvb, offset) >= 3) {
1765 tree = proto_tree_add_subtree_format(parent_tree, tvb, offset, 3, ett_l2tp_ericsson_map,
1766 NULL, "Transport Config Bundling Group %u", i);
1767 proto_tree_add_item(tree, hf_l2tp_ericsson_map_tei_low, tvb, offset++, 1, ENC_NA);
1768 proto_tree_add_item(tree, hf_l2tp_ericsson_map_tei_high, tvb, offset++, 1, ENC_NA);
1769 proto_tree_add_item(tree, hf_l2tp_ericsson_map_sc, tvb, offset++, 1, ENC_NA);
1770 i++;
1772 return offset;
1775 static int dissect_l2tp_ericsson_avps(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, uint32_t ccid _U_)
1777 int offset = 0;
1778 int avp_type;
1779 uint32_t avp_vendor_id;
1780 uint16_t avp_len;
1781 uint16_t ver_len_hidden;
1782 uint32_t msg_type;
1783 proto_tree *l2tp_avp_tree;
1784 tvbuff_t *tcg_tvb;
1786 ver_len_hidden = tvb_get_ntohs(tvb, offset);
1787 avp_len = AVP_LENGTH(ver_len_hidden);
1788 avp_vendor_id = tvb_get_ntohs(tvb, offset + 2);
1789 avp_type = tvb_get_ntohs(tvb, offset + 4);
1791 l2tp_avp_tree = proto_tree_add_subtree_format(tree, tvb, offset,
1792 avp_len, ett_l2tp_avp, NULL, "Vendor %s (%u): %s AVP",
1793 enterprises_lookup(avp_vendor_id, "Unknown"), avp_vendor_id,
1794 val_to_str(avp_type, ericsson_avp_type_vals, "Unknown (%u)"));
1796 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_mandatory, tvb, offset, 2, ENC_BIG_ENDIAN);
1797 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_hidden, tvb, offset, 2, ENC_BIG_ENDIAN);
1798 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_length, tvb, offset, 2, ENC_BIG_ENDIAN);
1800 if (HIDDEN_BIT(ver_len_hidden)) { /* don't try do display hidden */
1801 offset += avp_len;
1802 return offset;
1805 offset += 2;
1806 avp_len -= 2;
1808 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_vendor_id, tvb, offset, 2, ENC_BIG_ENDIAN);
1809 offset += 2;
1810 avp_len -= 2;
1812 proto_tree_add_uint(l2tp_avp_tree, hf_l2tp_ericsson_avp_type, tvb, offset, 2, avp_type);
1813 offset += 2;
1814 avp_len -= 2;
1816 switch (avp_type) {
1817 case ERICSSON_MSG_TYPE:
1818 proto_tree_add_item_ret_uint(l2tp_avp_tree, hf_l2tp_ericsson_msg_type, tvb, offset, 2, ENC_BIG_ENDIAN, &msg_type);
1819 col_add_fstr(pinfo->cinfo, COL_INFO, "%s - %s", control_msg, val_to_str(msg_type, ericsson_short_msg_type_vals, "Unknown (0x%x)"));
1820 break;
1821 case ERICSSON_PROTO_VERSION:
1822 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_ericsson_ver_pref, tvb, offset, 4, ENC_BIG_ENDIAN);
1823 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_ericsson_ver_2, tvb, offset+4, 4, ENC_BIG_ENDIAN);
1824 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_ericsson_ver_3, tvb, offset+8, 4, ENC_BIG_ENDIAN);
1825 break;
1826 case ERICSSON_CONN_TYPE:
1827 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_ericsson_conn_type, tvb, offset, 1, ENC_NA);
1828 break;
1829 case ERICSSON_STN_NAME:
1830 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_ericsson_stn_name, tvb, offset, avp_len, ENC_ASCII);
1831 break;
1832 case ERICSSON_CRC_ENABLED:
1833 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_ericsson_crc32_enable, tvb, offset, avp_len, ENC_NA);
1834 break;
1835 case ERICSSON_ABIS_LOWER_MODE:
1836 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_ericsson_abis_lower_mode, tvb, offset, 1, ENC_NA);
1837 break;
1838 case ERICSSON_TRANSPORT_CONFIG:
1839 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_ericsson_tc_overl_thresh, tvb, offset, 2, ENC_BIG_ENDIAN);
1840 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_ericsson_tc_num_groups, tvb, offset+2, 1, ENC_NA);
1841 /* FIXME: iterate over multiple groups */
1842 tcg_tvb = tvb_new_subset_length(tvb, offset+3, avp_len-3);
1843 dissect_l2tp_ericsson_transp_cfg(tcg_tvb, l2tp_avp_tree);
1844 break;
1845 case ERICSSON_TEI_TO_SC_MAP:
1846 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_ericsson_tc_num_maps, tvb, offset++, 1, ENC_NA);
1847 tcg_tvb = tvb_new_subset_length(tvb, offset, avp_len);
1848 offset += dissect_l2tp_ericsson_tei_sc_map(tcg_tvb, l2tp_avp_tree);
1849 break;
1851 default:
1852 proto_tree_add_expert(l2tp_avp_tree, pinfo, &ei_l2tp_vendor_specific_avp_data, tvb, offset, avp_len);
1853 break;
1855 offset += avp_len;
1857 return offset;
1861 * Ref: http://www.cablelabs.com/specifications/CM-SP-DEPI-I08-100611.pdf
1863 static int
1864 dissect_l2tp_vnd_cablelabs_avps(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
1866 int offset = 0;
1867 int avp_type;
1868 uint32_t avp_vendor_id;
1869 uint32_t avp_len;
1870 uint16_t ver_len_hidden;
1871 proto_tree *l2tp_avp_tree;
1873 ver_len_hidden = tvb_get_ntohs(tvb, offset);
1874 avp_len = AVP_LENGTH(ver_len_hidden);
1875 avp_vendor_id = tvb_get_ntohs(tvb, offset + 2);
1876 avp_type = tvb_get_ntohs(tvb, offset + 4);
1878 l2tp_avp_tree = proto_tree_add_subtree_format(tree, tvb, offset,
1879 avp_len, ett_l2tp_avp, NULL, "Vendor %s (%u): %s AVP",
1880 enterprises_lookup(avp_vendor_id, "Unknown"), avp_vendor_id,
1881 val_to_str(avp_type, cablelabs_avp_type_vals, "Unknown (%u)"));
1883 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_mandatory, tvb, offset, 2, ENC_BIG_ENDIAN);
1884 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_hidden, tvb, offset, 2, ENC_BIG_ENDIAN);
1885 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_length, tvb, offset, 2, ENC_BIG_ENDIAN);
1887 if (HIDDEN_BIT(ver_len_hidden)) { /* don't try do display hidden */
1888 offset += avp_len;
1889 return offset;
1892 offset += 2;
1893 avp_len -= 2;
1895 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_vendor_id, tvb, offset, 2, ENC_BIG_ENDIAN);
1896 offset += 2;
1897 avp_len -= 2;
1899 proto_tree_add_uint(l2tp_avp_tree, hf_l2tp_cablelabs_avp_type, tvb, offset, 2, avp_type);
1900 offset += 2;
1901 avp_len -= 2;
1903 switch (avp_type) {
1904 case 101:
1905 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_cablel_avp_l_bit, tvb, offset, 2, ENC_BIG_ENDIAN);
1906 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_cablel_avp_tsid_group_id, tvb, offset, 2, ENC_BIG_ENDIAN);
1907 offset+=2;
1908 avp_len-=2;
1909 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_cablel_avp_frequency, tvb, offset, 4, ENC_BIG_ENDIAN);
1910 avp_len -= 4;
1911 offset+=4;
1912 break;
1913 case 103:
1914 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_cablel_avp_l_bit, tvb, offset, 2, ENC_BIG_ENDIAN);
1915 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_cablel_avp_tsid_group_id, tvb, offset, 2, ENC_BIG_ENDIAN);
1916 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_cablel_avp_modulation, tvb, offset, 2, ENC_BIG_ENDIAN);
1917 offset+=2;
1918 avp_len-=2;
1919 break;
1920 case 105:
1921 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_cablel_avp_l_bit, tvb, offset, 2, ENC_BIG_ENDIAN);
1922 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_cablel_avp_tsid_group_id, tvb, offset, 2, ENC_BIG_ENDIAN);
1923 offset+=2;
1924 avp_len-=2;
1925 while(avp_len > 0){
1926 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_cablel_avp_m, tvb, offset, 2, ENC_BIG_ENDIAN);
1927 offset+=2;
1928 avp_len-=2;
1929 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_cablel_avp_n, tvb, offset, 2, ENC_BIG_ENDIAN);
1930 offset+=2;
1931 avp_len-=2;
1933 break;
1934 default:
1935 proto_tree_add_expert(l2tp_avp_tree, pinfo, &ei_l2tp_vendor_specific_avp_data, tvb, offset, avp_len);
1936 break;
1938 offset += avp_len;
1940 return offset;
1945 * Processes AVPs for Control Messages all versions and transports
1947 static void process_control_avps(tvbuff_t *tvb,
1948 packet_info *pinfo,
1949 proto_tree *l2tp_tree,
1950 int idx,
1951 int length,
1952 uint32_t ccid,
1953 l2tpv3_tunnel_t *tunnel)
1955 proto_tree *l2tp_lcp_avp_tree, *l2tp_avp_tree = NULL, *l2tp_avp_tree_sub, *l2tp_avp_csu_tree;
1956 proto_item *te, *tc;
1958 int msg_type = 0;
1959 bool isStopCcn = false;
1960 int avp_type;
1961 uint32_t avp_vendor_id;
1962 uint16_t avp_len;
1963 uint16_t ver_len_hidden;
1964 tvbuff_t *next_tvb, *avp_tvb;
1965 int digest_idx = 0;
1966 uint16_t digest_avp_len = 0;
1967 proto_item *digest_item = NULL;
1968 l2tp_cntrl_data_t *l2tp_cntrl_data = wmem_new0(pinfo->pool, l2tp_cntrl_data_t);
1970 l2tpv3_session_t *session = NULL;
1972 l2tp_cntrl_data->ccid = ccid;
1974 while (idx < length) { /* Process AVP's */
1975 ver_len_hidden = tvb_get_ntohs(tvb, idx);
1976 avp_len = AVP_LENGTH(ver_len_hidden);
1977 avp_vendor_id = tvb_get_ntohs(tvb, idx + 2);
1978 avp_type = tvb_get_ntohs(tvb, idx + 4);
1980 if (avp_len < 6) {
1981 proto_tree_add_expert_format(l2tp_avp_tree ? l2tp_avp_tree : l2tp_tree, pinfo, &ei_l2tp_avp_length, tvb, idx, 2, "AVP length must be >= 6, got %u", avp_len);
1982 return;
1985 if (avp_vendor_id != VENDOR_IETF) {
1987 avp_tvb = tvb_new_subset_length(tvb, idx, avp_len);
1989 if (avp_vendor_id == VENDOR_CISCO) { /* Vendor-Specific AVP */
1991 dissect_l2tp_cisco_avps(avp_tvb, pinfo, l2tp_tree, l2tp_cntrl_data, &session);
1992 idx += avp_len;
1993 continue;
1995 } else if (avp_vendor_id == VENDOR_BROADBAND_FORUM) { /* Vendor-Specific AVP */
1997 dissect_l2tp_broadband_avps(avp_tvb, pinfo, l2tp_tree);
1998 idx += avp_len;
1999 continue;
2001 } else if (avp_vendor_id == VENDOR_ERICSSON) { /* Vendor-Specific AVP */
2003 dissect_l2tp_ericsson_avps(avp_tvb, pinfo, l2tp_tree, ccid);
2004 idx += avp_len;
2005 continue;
2007 } else {
2008 /* Vendor-Specific AVP */
2009 if (!dissector_try_uint_new(l2tp_vendor_avp_dissector_table, avp_vendor_id, avp_tvb, pinfo, l2tp_tree, false, l2tp_cntrl_data)){
2010 l2tp_avp_tree = proto_tree_add_subtree_format(l2tp_tree, tvb, idx,
2011 avp_len, ett_l2tp_avp, NULL, "Vendor %s (%u) AVP Type %u",
2012 enterprises_lookup(avp_vendor_id, "Unknown"), avp_vendor_id,
2013 avp_type);
2015 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_mandatory, tvb, idx, 2, ENC_BIG_ENDIAN);
2016 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_hidden, tvb, idx, 2, ENC_BIG_ENDIAN);
2017 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_length, tvb, idx, 2, ENC_BIG_ENDIAN);
2019 if (HIDDEN_BIT(ver_len_hidden)) { /* don't try do display hidden */
2020 idx += avp_len;
2021 continue;
2023 idx += 2;
2024 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_vendor_id, tvb, idx, 2, ENC_BIG_ENDIAN);
2025 idx += 2;
2027 proto_tree_add_uint(l2tp_avp_tree, hf_l2tp_avp_type, tvb, idx, 2, avp_type);
2028 idx += 2;
2029 proto_tree_add_expert(l2tp_avp_tree, pinfo, &ei_l2tp_vendor_specific_avp_data, tvb, idx, avp_len-6);
2030 avp_len-=6;
2032 idx += avp_len;
2033 continue;
2037 /* IETF AVP:s */
2038 l2tp_avp_tree = proto_tree_add_subtree_format(l2tp_tree, tvb, idx,
2039 avp_len, ett_l2tp_avp, NULL, "%s AVP",
2040 val_to_str_ext(avp_type, &avp_type_vals_ext, "Unknown (%u)"));
2042 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_mandatory, tvb, idx, 2, ENC_BIG_ENDIAN);
2043 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_hidden, tvb, idx, 2, ENC_BIG_ENDIAN);
2044 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_length, tvb, idx, 2, ENC_BIG_ENDIAN);
2046 if (HIDDEN_BIT(ver_len_hidden)) { /* don't try do display hidden */
2047 idx += avp_len;
2048 continue;
2051 idx += 2;
2052 avp_len -= 2;
2054 /* Special Case for handling Extended Vendor Id */
2055 if (avp_type == EXTENDED_VENDOR_ID) {
2056 idx += 2;
2057 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_vendor_id,
2058 tvb, idx, 4, ENC_BIG_ENDIAN);
2061 idx += 4;
2062 continue;
2064 else {
2065 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_vendor_id,
2066 tvb, idx, 2, ENC_BIG_ENDIAN);
2067 idx += 2;
2068 avp_len -= 2;
2071 proto_tree_add_uint(l2tp_avp_tree, hf_l2tp_avp_type,
2072 tvb, idx, 2, avp_type);
2073 idx += 2;
2074 avp_len -= 2;
2076 switch (avp_type) {
2078 case CONTROL_MESSAGE:
2079 msg_type = tvb_get_ntohs(tvb, idx);
2080 l2tp_cntrl_data->msg_type = msg_type;
2081 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_message_type,
2082 tvb, idx, 2, ENC_BIG_ENDIAN);
2084 if (msg_type == MESSAGE_TYPE_StopCCN) {
2085 isStopCcn = true;
2087 break;
2089 case RESULT_ERROR_CODE:
2090 if (avp_len < 2)
2091 break;
2092 if (isStopCcn) {
2093 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_stop_ccn_result_code, tvb, idx, 2, ENC_BIG_ENDIAN);
2095 else {
2096 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_result_code, tvb, idx, 2, ENC_BIG_ENDIAN);
2098 idx += 2;
2099 avp_len -= 2;
2101 if (avp_len < 2)
2102 break;
2103 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_error_code, tvb, idx, 2, ENC_BIG_ENDIAN);
2104 idx += 2;
2105 avp_len -= 2;
2107 if (avp_len == 0)
2108 break;
2109 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_error_message, tvb, idx, avp_len, ENC_ASCII);
2110 break;
2112 case PROTOCOL_VERSION:
2113 if (avp_len < 1)
2114 break;
2115 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_protocol_version, tvb, idx, 1, ENC_BIG_ENDIAN);
2116 idx += 1;
2117 avp_len -= 1;
2119 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_protocol_revision, tvb, idx, 1, ENC_BIG_ENDIAN);
2120 break;
2122 case FRAMING_CAPABILITIES:
2123 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_async_framing_supported, tvb, idx, 4, ENC_BIG_ENDIAN);
2124 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_sync_framing_supported, tvb, idx, 4, ENC_BIG_ENDIAN);
2125 break;
2127 case BEARER_CAPABILITIES:
2128 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_analog_access_supported, tvb, idx, 4, ENC_BIG_ENDIAN);
2129 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_digital_access_supported, tvb, idx, 4, ENC_BIG_ENDIAN);
2130 break;
2132 case TIE_BREAKER:
2133 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_tie_breaker, tvb, idx, 8, ENC_BIG_ENDIAN);
2134 break;
2136 case FIRMWARE_REVISION:
2137 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_firmware_revision, tvb, idx, 2, ENC_BIG_ENDIAN);
2138 break;
2140 case HOST_NAME:
2141 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_host_name, tvb, idx, avp_len, ENC_NA|ENC_ASCII);
2142 break;
2144 case VENDOR_NAME:
2145 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_vendor_name, tvb, idx, avp_len, ENC_NA|ENC_ASCII);
2146 break;
2148 case ASSIGNED_TUNNEL_ID:
2149 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_assigned_tunnel_id, tvb, idx, 2, ENC_BIG_ENDIAN);
2150 break;
2152 case RECEIVE_WINDOW_SIZE:
2153 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_receive_window_size, tvb, idx, 2, ENC_BIG_ENDIAN);
2154 break;
2156 case CHALLENGE:
2157 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_chap_challenge, tvb, idx, avp_len, ENC_NA);
2158 break;
2160 case CAUSE_CODE:
2162 * XXX - export stuff from the Q.931 dissector
2163 * to dissect the cause code and cause message,
2164 * and use it.
2166 if (avp_len < 2)
2167 break;
2168 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_cause_code, tvb, idx, 2, ENC_BIG_ENDIAN);
2169 idx += 2;
2170 avp_len -= 2;
2172 if (avp_len < 1)
2173 break;
2174 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_cause_msg, tvb, idx, 1, ENC_BIG_ENDIAN);
2175 idx += 1;
2176 avp_len -= 1;
2178 if (avp_len == 0)
2179 break;
2180 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_advisory_msg, tvb, idx, avp_len, ENC_NA|ENC_ASCII);
2181 break;
2183 case CHALLENGE_RESPONSE:
2184 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_chap_challenge_response, tvb, idx, 16, ENC_NA);
2185 break;
2187 case ASSIGNED_SESSION:
2188 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_assigned_session_id, tvb, idx, 2, ENC_BIG_ENDIAN);
2189 break;
2191 case CALL_SERIAL_NUMBER:
2192 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_call_serial_number, tvb, idx, 4, ENC_BIG_ENDIAN);
2193 break;
2195 case MINIMUM_BPS:
2196 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_minimum_bps, tvb, idx, 4, ENC_BIG_ENDIAN);
2197 break;
2199 case MAXIMUM_BPS:
2200 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_maximum_bps, tvb, idx, 4, ENC_BIG_ENDIAN);
2201 break;
2203 case BEARER_TYPE:
2204 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_analog_bearer_type, tvb, idx, 4, ENC_BIG_ENDIAN);
2205 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_digital_bearer_type, tvb, idx, 4, ENC_BIG_ENDIAN);
2206 break;
2208 case FRAMING_TYPE:
2209 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_async_framing_type, tvb, idx, 4, ENC_BIG_ENDIAN);
2210 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_sync_framing_type, tvb, idx, 4, ENC_BIG_ENDIAN);
2211 break;
2213 case CALLED_NUMBER:
2214 if (avp_len == 0)
2215 break;
2216 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_called_number,
2217 tvb, idx, avp_len, ENC_ASCII);
2218 break;
2220 case CALLING_NUMBER:
2221 if (avp_len == 0)
2222 break;
2223 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_calling_number,
2224 tvb, idx, avp_len, ENC_ASCII);
2225 break;
2227 case SUB_ADDRESS:
2228 if (avp_len == 0)
2229 break;
2230 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_sub_address, tvb, idx, avp_len, ENC_NA|ENC_ASCII);
2231 break;
2233 case TX_CONNECT_SPEED:
2234 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_connect_speed, tvb, idx, 4, ENC_BIG_ENDIAN);
2235 break;
2237 case PHYSICAL_CHANNEL:
2238 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_physical_channel, tvb, idx, 4, ENC_BIG_ENDIAN);
2239 break;
2241 case INITIAL_RECEIVED_LCP_CONFREQ:
2242 te = proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_initial_received_lcp_confreq, tvb, idx, avp_len, ENC_NA);
2243 l2tp_lcp_avp_tree = proto_item_add_subtree(te, ett_l2tp_lcp);
2244 next_tvb = tvb_new_subset_length(tvb, idx, avp_len);
2245 call_dissector(ppp_lcp_options_handle, next_tvb, pinfo, l2tp_lcp_avp_tree );
2246 break;
2248 case LAST_SENT_LCP_CONFREQ:
2249 te = proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_last_sent_lcp_confreq, tvb, idx, avp_len, ENC_NA);
2250 l2tp_lcp_avp_tree = proto_item_add_subtree(te, ett_l2tp_lcp);
2251 next_tvb = tvb_new_subset_length(tvb, idx, avp_len);
2252 call_dissector(ppp_lcp_options_handle, next_tvb, pinfo, l2tp_lcp_avp_tree );
2253 break;
2255 case LAST_RECEIVED_LCP_CONFREQ:
2256 te = proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_last_received_lcp_confreq, tvb, idx, avp_len, ENC_NA);
2257 l2tp_lcp_avp_tree = proto_item_add_subtree(te, ett_l2tp_lcp);
2258 next_tvb = tvb_new_subset_length(tvb, idx, avp_len);
2259 call_dissector(ppp_lcp_options_handle, next_tvb, pinfo, l2tp_lcp_avp_tree );
2260 break;
2262 case PROXY_AUTHEN_TYPE:
2263 msg_type = tvb_get_ntohs(tvb, idx);
2264 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_proxy_authen_type, tvb, idx, 2, ENC_BIG_ENDIAN);
2265 break;
2267 case PROXY_AUTHEN_NAME:
2268 if (avp_len == 0)
2269 break;
2270 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_proxy_authen_name, tvb, idx, avp_len, ENC_NA|ENC_ASCII);
2271 break;
2273 case PROXY_AUTHEN_CHALLENGE:
2274 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_proxy_authen_challenge, tvb, idx, avp_len, ENC_NA);
2275 break;
2277 case PROXY_AUTHEN_ID:
2278 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_proxy_authen_id, tvb, idx + 1, 1, ENC_BIG_ENDIAN);
2279 break;
2281 case PROXY_AUTHEN_RESPONSE:
2282 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_proxy_authen_response, tvb, idx, avp_len, ENC_NA);
2283 break;
2285 case CALL_STATUS_AVPS:
2286 if (avp_len < 2)
2287 break;
2288 idx += 2;
2289 avp_len -= 2;
2291 if (avp_len < 4)
2292 break;
2293 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_crc_errors, tvb, idx, 4, ENC_BIG_ENDIAN);
2294 idx += 4;
2295 avp_len -= 4;
2297 if (avp_len < 4)
2298 break;
2299 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_framing_errors, tvb, idx, 4, ENC_BIG_ENDIAN);
2300 idx += 4;
2301 avp_len -= 4;
2303 if (avp_len < 4)
2304 break;
2305 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_hardware_overruns, tvb, idx, 4, ENC_BIG_ENDIAN);
2306 idx += 4;
2307 avp_len -= 4;
2309 if (avp_len < 4)
2310 break;
2311 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_buffer_overruns, tvb, idx, 4, ENC_BIG_ENDIAN);
2312 idx += 4;
2313 avp_len -= 4;
2315 if (avp_len < 4)
2316 break;
2317 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_time_out_errors, tvb, idx, 4, ENC_BIG_ENDIAN);
2318 idx += 4;
2319 avp_len -= 4;
2321 if (avp_len < 4)
2322 break;
2323 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_alignment_errors, tvb, idx, 4, ENC_BIG_ENDIAN);
2324 idx += 4;
2325 avp_len -= 4;
2326 break;
2328 case ACCM:
2329 if (avp_len < 2)
2330 break;
2331 idx += 2;
2332 avp_len -= 2;
2334 if (avp_len < 4)
2335 break;
2336 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_send_accm, tvb, idx, 4, ENC_BIG_ENDIAN);
2337 idx += 4;
2338 avp_len -= 4;
2340 if (avp_len < 4)
2341 break;
2342 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_receive_accm, tvb, idx, 4, ENC_BIG_ENDIAN);
2343 idx += 4;
2344 avp_len -= 4;
2345 break;
2347 case RANDOM_VECTOR:
2348 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_random_vector, tvb, idx, avp_len, ENC_NA);
2349 break;
2351 case PRIVATE_GROUP_ID:
2352 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_private_group_id, tvb, idx, avp_len, ENC_NA);
2353 break;
2355 case RX_CONNECT_SPEED:
2356 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_rx_connect_speed, tvb, idx, 4, ENC_BIG_ENDIAN);
2357 break;
2359 case PPP_DISCONNECT_CAUSE_CODE:
2360 if (avp_len < 2)
2361 break;
2362 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_disconnect_code, tvb, idx, 2, ENC_BIG_ENDIAN);
2363 idx += 2;
2364 avp_len -= 2;
2366 if (avp_len < 2)
2367 break;
2368 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_control_protocol_number, tvb, idx, 2, ENC_BIG_ENDIAN);
2369 idx += 2;
2370 avp_len -= 2;
2372 if (avp_len < 1)
2373 break;
2374 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_cause_code_direction, tvb, idx, 1, ENC_BIG_ENDIAN);
2375 idx += 1;
2376 avp_len -= 1;
2378 if (avp_len == 0)
2379 break;
2380 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_cause_code_message, tvb, idx, avp_len, ENC_NA|ENC_ASCII);
2381 break;
2383 case MESSAGE_DIGEST:
2385 digest_idx = idx;
2386 digest_avp_len = avp_len;
2387 digest_item = proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_message_digest, tvb, idx, avp_len, ENC_NA);
2388 break;
2390 case ROUTER_ID:
2391 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_router_id, tvb, idx, 4, ENC_BIG_ENDIAN);
2392 break;
2393 case ASSIGNED_CONTROL_CONN_ID:
2394 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_assigned_control_conn_id,
2395 tvb, idx, 4, ENC_BIG_ENDIAN);
2396 store_ccid(tunnel, tvb, idx, msg_type);
2397 break;
2398 case PW_CAPABILITY_LIST:
2399 l2tp_avp_tree_sub = proto_tree_add_subtree(l2tp_avp_tree, tvb, idx, avp_len,
2400 ett_l2tp_avp_sub, NULL, "Pseudowire Capabilities List");
2402 while (avp_len >= 2) {
2403 proto_tree_add_item(l2tp_avp_tree_sub, hf_l2tp_avp_pw_type, tvb, idx, 2, ENC_BIG_ENDIAN);
2404 idx += 2;
2405 avp_len -= 2;
2407 break;
2408 case LOCAL_SESSION_ID:
2409 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_local_session_id,
2410 tvb, idx, 4, ENC_BIG_ENDIAN);
2411 col_append_fstr(pinfo->cinfo,COL_INFO, ", LSID: %2u",
2412 tvb_get_ntohl(tvb, idx));
2413 session = store_lsession_id(session, tvb, idx, msg_type);
2414 break;
2415 case REMOTE_SESSION_ID:
2416 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_remote_session_id,
2417 tvb, idx, 4, ENC_BIG_ENDIAN);
2418 col_append_fstr(pinfo->cinfo,COL_INFO, ", RSID: %2u",
2419 tvb_get_ntohl(tvb, idx));
2420 session = store_rsession_id(session, tvb, idx, msg_type);
2421 break;
2422 case ASSIGNED_COOKIE:
2423 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_assigned_cookie, tvb, idx, avp_len, ENC_NA);
2424 session = store_cookie_len(session, avp_len, msg_type);
2425 break;
2426 case REMOTE_END_ID:
2427 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_remote_end_id, tvb, idx, avp_len, ENC_NA|ENC_ASCII);
2428 break;
2429 case PW_TYPE:
2430 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_pseudowire_type, tvb, idx, 2, ENC_BIG_ENDIAN);
2431 session = store_pw_type(session, tvb, idx, msg_type);
2432 break;
2433 case L2_SPECIFIC_SUBLAYER:
2434 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_layer2_specific_sublayer, tvb, idx, 2, ENC_BIG_ENDIAN);
2435 session = store_l2_sublayer(session, tvb, idx, msg_type);
2436 break;
2437 case DATA_SEQUENCING:
2438 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_data_sequencing, tvb, idx, 2, ENC_BIG_ENDIAN);
2439 break;
2440 case CIRCUIT_STATUS:
2441 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_circuit_status, tvb, idx, 2, ENC_BIG_ENDIAN);
2442 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_circuit_type, tvb, idx, 2, ENC_BIG_ENDIAN);
2443 break;
2444 case PREFERRED_LANGUAGE:
2445 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_preferred_language, tvb, idx, avp_len, ENC_NA|ENC_ASCII);
2446 break;
2447 case CTL_MSG_AUTH_NONCE:
2448 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_nonce, tvb, idx, avp_len, ENC_NA);
2449 store_cma_nonce(tunnel, tvb, idx, avp_len, msg_type);
2450 break;
2451 case TX_CONNECT_SPEED_V3:
2452 if (avp_len < 8)
2453 break;
2455 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_tx_connect_speed_v3, tvb, idx, 8, ENC_BIG_ENDIAN);
2456 break;
2457 case RX_CONNECT_SPEED_V3:
2458 if (avp_len < 8)
2459 break;
2461 proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_rx_connect_speed_v3, tvb, idx, 8, ENC_BIG_ENDIAN);
2462 break;
2463 case CONNECT_SPEED_UPDATE:
2465 tc = proto_tree_add_item(l2tp_avp_tree, hf_l2tp_avp_csu, tvb, idx, avp_len, ENC_NA);
2466 l2tp_avp_csu_tree = proto_item_add_subtree(tc, ett_l2tp_csu);
2467 if (avp_len == 12) {
2468 /* L2TPv2 */
2469 proto_tree_add_item(l2tp_avp_csu_tree, hf_l2tp_avp_csu_res, tvb, idx, 2, ENC_BIG_ENDIAN);
2470 proto_tree_add_item(l2tp_avp_csu_tree, hf_l2tp_avp_csu_remote_session_id_v2, tvb, idx+2, 2, ENC_BIG_ENDIAN);
2471 proto_tree_add_item(l2tp_avp_csu_tree, hf_l2tp_avp_csu_current_tx_speed_v2, tvb, idx+4, 4, ENC_BIG_ENDIAN);
2472 proto_tree_add_item(l2tp_avp_csu_tree, hf_l2tp_avp_csu_current_rx_speed_v2, tvb, idx+8, 4, ENC_BIG_ENDIAN);
2474 else if (avp_len == 20) {
2475 /* L2TPv3 */
2476 proto_tree_add_item(l2tp_avp_csu_tree, hf_l2tp_avp_csu_remote_session_id_v3, tvb, idx, 4, ENC_BIG_ENDIAN);
2477 proto_tree_add_item(l2tp_avp_csu_tree, hf_l2tp_avp_csu_current_tx_speed_v3, tvb, idx+4, 8, ENC_BIG_ENDIAN);
2478 proto_tree_add_item(l2tp_avp_csu_tree, hf_l2tp_avp_csu_current_rx_speed_v3, tvb, idx+12, 8, ENC_BIG_ENDIAN);
2480 break;
2483 default:
2484 if(avp_len>0)
2485 proto_tree_add_expert(l2tp_avp_tree, pinfo, &ei_l2tp_vendor_specific_avp_data, tvb, idx, avp_len);
2486 break;
2489 idx += avp_len;
2492 /* SCCRQ digest can only be calculated once we know whether nonces are being used */
2493 if (digest_avp_len) {
2494 if (check_control_digest(tunnel, tvb, length, digest_idx, digest_avp_len, msg_type, pinfo) < 0)
2495 expert_add_info(pinfo, digest_item, &ei_l2tp_incorrect_digest);
2498 update_session(tunnel, session);
2502 * Processes Data Messages for v3 IP and UDP, starting from the Session ID
2503 * (common to IP and UDP). Dissects the L2TPv3 Session header, the (optional)
2504 * L2-Specific sublayer and calls the appropriate dissector for the payload.
2506 static void
2507 process_l2tpv3_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
2508 proto_tree *l2tp_tree, proto_item *l2tp_item, int *pIdx,
2509 l2tpv3_tunnel_t *tunnel)
2511 int idx = *pIdx;
2512 int sid;
2513 uint32_t oam_cell = 0;
2514 proto_tree *l2_specific = NULL;
2515 proto_item *ti = NULL;
2516 tvbuff_t *next_tvb;
2517 int cookie_len = l2tpv3_cookie;
2518 int l2_spec = l2tpv3_l2_specific;
2519 unsigned pw_type = L2TPv3_PW_DEFAULT;
2521 lcce_settings_t *lcce = NULL;
2522 l2tpv3_session_t *session = NULL;
2524 /* Get Session ID */
2525 sid = tvb_get_ntohl(tvb, idx);
2526 idx += 4;
2528 if (tunnel) {
2529 if (addresses_equal(&tunnel->lcce1, &pinfo->dst)) {
2530 session = find_session(tunnel, sid, 0);
2531 if (session)
2532 lcce = &session->lcce1;
2533 } else {
2534 session = find_session(tunnel, 0, sid);
2535 if (session)
2536 lcce = &session->lcce2;
2540 if (lcce) {
2541 if (l2_spec == -1)
2542 l2_spec = lcce->l2_specific;
2543 if (cookie_len == -1)
2544 cookie_len = lcce->cookie_len;
2545 if (pw_type == L2TPv3_PW_DEFAULT)
2546 pw_type = session->pw_type;
2549 if (l2_spec == -1)
2550 l2_spec = L2TPv3_L2_SPECIFIC_NONE;
2552 if (cookie_len == -1)
2553 cookie_len = L2TPv3_COOKIE_DEFAULT;
2555 col_append_fstr(pinfo->cinfo, COL_INFO, "D[S:0x%08X]", sid);
2556 col_set_fence(pinfo->cinfo, COL_INFO);
2558 proto_tree_add_item(l2tp_tree, hf_l2tp_sid, tvb, idx-4, 4, ENC_BIG_ENDIAN);
2559 ti = proto_tree_add_uint(l2tp_tree, hf_l2tp_avp_pseudowire_type, tvb, 0, 0, pw_type);
2560 proto_item_set_generated(ti);
2561 if (!(tvb_offset_exists(tvb, idx))) {
2562 return;
2564 if (cookie_len != 0) {
2565 proto_tree_add_item(l2tp_tree, hf_l2tp_cookie, tvb, idx, cookie_len, ENC_NA);
2566 idx += cookie_len;
2567 proto_item_set_len(l2tp_item, idx);
2570 switch(l2_spec){
2571 case L2TPv3_L2_SPECIFIC_DEFAULT:
2572 if (tree) {
2573 ti = proto_tree_add_item(l2tp_tree, hf_l2tp_l2_spec_def,
2574 tvb, idx, 4, ENC_NA);
2575 l2_specific = proto_item_add_subtree(ti, ett_l2tp_l2_spec);
2577 proto_tree_add_item(l2_specific, hf_l2tp_l2_spec_s, tvb, idx,
2578 1, ENC_BIG_ENDIAN);
2579 proto_tree_add_item(l2_specific, hf_l2tp_l2_spec_sequence, tvb,
2580 idx + 1, 3, ENC_BIG_ENDIAN);
2582 idx += 4;
2583 break;
2584 case L2TPv3_L2_SPECIFIC_DOCSIS_DMPT:
2585 if (tree) {
2586 ti = proto_tree_add_item(l2tp_tree, hf_l2tp_l2_spec_docsis_dmpt,
2587 tvb, idx, 4, ENC_NA);
2588 l2_specific = proto_item_add_subtree(ti, ett_l2tp_l2_spec);
2590 proto_tree_add_item(l2_specific, hf_l2tp_l2_spec_v, tvb,
2591 idx, 1, ENC_BIG_ENDIAN);
2593 proto_tree_add_item(l2_specific, hf_l2tp_l2_spec_s, tvb,
2594 idx, 1, ENC_BIG_ENDIAN);
2596 proto_tree_add_item(l2_specific, hf_l2tp_l2_spec_h, tvb,
2597 idx, 1, ENC_BIG_ENDIAN);
2599 proto_tree_add_item(l2_specific, hf_l2tp_l2_spec_flow_id, tvb,
2600 idx, 1, ENC_BIG_ENDIAN);
2602 proto_tree_add_item(l2_specific, hf_l2tp_l2_spec_sequence, tvb,
2603 idx + 2, 2, ENC_BIG_ENDIAN);
2605 idx += 4;
2606 break;
2607 case L2TPv3_L2_SPECIFIC_ATM:
2608 if (tree) {
2609 ti = proto_tree_add_item(l2tp_tree, hf_l2tp_l2_spec_atm,
2610 tvb, idx, 4, ENC_NA);
2611 l2_specific = proto_item_add_subtree(ti, ett_l2tp_l2_spec);
2613 proto_tree_add_item(l2_specific, hf_l2tp_l2_spec_s, tvb, idx,
2614 1, ENC_BIG_ENDIAN);
2615 proto_tree_add_item(l2_specific, hf_l2tp_l2_spec_t, tvb, idx,
2616 1, ENC_BIG_ENDIAN);
2618 * As per RFC 4454, the T bit specifies whether
2619 * we're transporting an OAM cell or an AAL5 frame.
2621 oam_cell = tvb_get_uint8(tvb, idx) & 0x08;
2622 proto_tree_add_item(l2_specific, hf_l2tp_l2_spec_g, tvb, idx,
2623 1, ENC_BIG_ENDIAN);
2624 proto_tree_add_item(l2_specific, hf_l2tp_l2_spec_c, tvb, idx,
2625 1, ENC_BIG_ENDIAN);
2626 proto_tree_add_item(l2_specific, hf_l2tp_l2_spec_u, tvb, idx,
2627 1, ENC_BIG_ENDIAN);
2628 proto_tree_add_item(l2_specific, hf_l2tp_l2_spec_sequence, tvb,
2629 idx + 1, 3, ENC_BIG_ENDIAN);
2631 idx += 4;
2632 break;
2633 case L2TPv3_L2_SPECIFIC_LAPD:
2634 if (tree)
2635 proto_tree_add_item(l2tp_tree, hf_l2tp_lapd_info, tvb, idx + 4, 3, ENC_NA);
2636 idx += 4 + 3;
2637 break;
2638 case L2TPv3_L2_SPECIFIC_NONE:
2639 default:
2640 break;
2643 next_tvb = tvb_new_subset_remaining(tvb, idx);
2644 proto_item_set_len(l2tp_item, idx);
2645 p_add_proto_data(pinfo->pool, pinfo, proto_l2tp, 0, GUINT_TO_POINTER(pw_type));
2647 if (!dissector_try_uint_new(pw_type_table, pw_type, next_tvb, pinfo, tree, false, GUINT_TO_POINTER(oam_cell)))
2649 call_data_dissector(next_tvb, pinfo, tree);
2653 static int * const l2tp_control_fields[] = {
2654 &hf_l2tp_type,
2655 &hf_l2tp_length_bit,
2656 &hf_l2tp_seq_bit,
2657 &hf_l2tp_version,
2658 NULL
2662 * Processes v3 data message over UDP, to then call process_l2tpv3_data
2663 * from the common part (Session ID)
2665 static void
2666 process_l2tpv3_data_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
2667 l2tpv3_conversation_t *l2tp_conv)
2669 proto_tree *l2tp_tree;
2670 proto_item *l2tp_item;
2671 int idx = 4; /* skip to sid */
2673 l2tp_item = proto_tree_add_item(tree, proto_l2tp, tvb, 0, 8, ENC_NA);
2674 l2tp_tree = proto_item_add_subtree(l2tp_item, ett_l2tp);
2676 if (tree) {
2677 proto_item_append_text(l2tp_item, " version 3");
2679 proto_tree_add_bitmask(l2tp_tree, tvb, 0, hf_l2tp_flags, ett_l2tp_flags, l2tp_control_fields, ENC_BIG_ENDIAN);
2681 /* Data in v3 over UDP has this reserved */
2682 proto_tree_add_item(l2tp_tree, hf_l2tp_res, tvb, 2, 2, ENC_BIG_ENDIAN);
2685 /* Call process_l2tpv3_data from Session ID (offset in idx of 4) */
2686 process_l2tpv3_data(tvb, pinfo, tree, l2tp_tree, l2tp_item, &idx, l2tp_conv->tunnel);
2690 * Processes v3 data message over IP, to then call process_l2tpv3_data
2691 * from the common part (Session ID)
2693 static void
2694 process_l2tpv3_data_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
2695 l2tpv3_conversation_t *l2tp_conv)
2697 proto_tree *l2tp_tree;
2698 proto_item *l2tp_item;
2700 int idx = 0;
2702 l2tp_item = proto_tree_add_item(tree, proto_l2tp, tvb, 0, 4, ENC_NA);
2703 l2tp_tree = proto_item_add_subtree(l2tp_item, ett_l2tp);
2704 proto_item_append_text(l2tp_item, " version 3");
2706 /* Call process_l2tpv3_data from Session ID (offset in idx of 0) */
2707 process_l2tpv3_data(tvb, pinfo, tree, l2tp_tree, l2tp_item, &idx, l2tp_conv->tunnel);
2711 * Processes v3 Control Message over IP, that carries NULL Session ID
2712 * to then call process_control_avps after dissecting the control.
2714 static void
2715 process_l2tpv3_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int baseIdx,
2716 l2tpv3_conversation_t *l2tp_conv)
2718 proto_tree *l2tp_tree = NULL;
2719 proto_item *l2tp_item = NULL;
2721 int idx = baseIdx;
2722 int tmp_idx;
2723 uint16_t length = 0; /* Length field */
2724 uint32_t ccid = 0; /* Control Connection ID */
2725 uint16_t vendor_id = 0;
2726 uint16_t avp_type;
2727 uint16_t msg_type;
2728 uint16_t control = 0;
2730 l2tpv3_tunnel_t *tunnel = NULL;
2731 l2tpv3_tunnel_t tmp_tunnel;
2733 control = tvb_get_ntohs(tvb, idx);
2734 idx += 2; /* skip ahead */
2735 if (LENGTH_BIT(control)) { /* length field included ? */
2736 length = tvb_get_ntohs(tvb, idx);
2737 idx += 2;
2740 /* Get Control Channel ID */
2741 ccid = tvb_get_ntohl(tvb, idx);
2742 idx += 4;
2744 tmp_idx = idx;
2746 if ((LENGTH_BIT(control))&&(length==12)) /* ZLB Message */
2747 col_add_fstr(pinfo->cinfo, COL_INFO,
2748 "%s - ZLB (ccid=0x%08X)",
2749 control_msg , ccid);
2750 else
2752 if (SEQUENCE_BIT(control)) {
2753 tmp_idx += 4;
2756 tmp_idx+=2;
2758 vendor_id = tvb_get_ntohs(tvb, tmp_idx);
2759 tmp_idx+=2;
2761 avp_type = tvb_get_ntohs(tvb, tmp_idx);
2762 tmp_idx += 2;
2764 /* If it's a vendor AVP let the vendor AVP dissector fill in the info column */
2765 if ( vendor_id == VENDOR_IETF ) {
2766 if (avp_type == CONTROL_MESSAGE) {
2767 /* We print message type */
2768 msg_type = tvb_get_ntohs(tvb, tmp_idx);
2769 col_add_fstr(pinfo->cinfo, COL_INFO,
2770 "%s - %s (ccid=0x%08X)",
2771 control_msg ,
2772 val_to_str_ext(msg_type, &l2tp_message_type_short_str_vals_ext, "Unknown (%u)"),
2773 ccid);
2775 else {
2777 * This is not a control message.
2778 * We never pass here except in case of bad l2tp packet!
2780 col_add_fstr(pinfo->cinfo, COL_INFO,
2781 "%s (ccid=0x%08X)",
2782 control_msg, ccid);
2787 if (LENGTH_BIT(control)) {
2789 * Set the length of this tvbuff to be no longer than the length
2790 * in the header.
2792 * XXX - complain if that length is longer than the length of
2793 * the tvbuff? Have "set_actual_length()" return a Boolean
2794 * and have its callers check the result?
2796 set_actual_length(tvb, length+baseIdx);
2799 if (tree) {
2800 l2tp_item = proto_tree_add_item(tree, proto_l2tp, tvb, 0, -1, ENC_NA);
2801 l2tp_tree = proto_item_add_subtree(l2tp_item, ett_l2tp);
2802 proto_item_append_text(l2tp_item, " version 3");
2804 if (baseIdx) {
2805 proto_tree_add_item(l2tp_tree, hf_l2tp_sid, tvb, 0, 4, ENC_BIG_ENDIAN);
2807 proto_tree_add_bitmask(l2tp_tree, tvb, baseIdx, hf_l2tp_flags, ett_l2tp_flags, l2tp_control_fields, ENC_BIG_ENDIAN);
2809 idx = baseIdx + 2;
2810 if (LENGTH_BIT(control)) {
2811 proto_tree_add_item(l2tp_tree, hf_l2tp_length, tvb, idx, 2, ENC_BIG_ENDIAN);
2812 idx += 2;
2815 proto_tree_add_item(l2tp_tree, hf_l2tp_ccid, tvb, idx, 4, ENC_BIG_ENDIAN);
2816 idx += 4;
2818 if (SEQUENCE_BIT(control)) {
2819 proto_tree_add_item(l2tp_tree, hf_l2tp_Ns, tvb, idx, 2, ENC_BIG_ENDIAN);
2820 idx += 2;
2821 proto_tree_add_item(l2tp_tree, hf_l2tp_Nr, tvb, idx, 2, ENC_BIG_ENDIAN);
2822 idx += 2;
2826 if ((LENGTH_BIT(control))&&(length==12)) {
2827 proto_tree_add_item(l2tp_tree, hf_l2tp_zero_length_body_message, tvb, 0, 0, ENC_NA);
2828 } else {
2829 avp_type = tvb_get_ntohs(tvb, idx + 4);
2830 if (avp_type == CONTROL_MESSAGE) {
2832 msg_type = tvb_get_ntohs(tvb, idx + 6);
2833 if (msg_type == MESSAGE_TYPE_SCCRQ) {
2834 tunnel = &tmp_tunnel;
2835 memset(tunnel, 0, sizeof(l2tpv3_tunnel_t));
2836 tunnel->conv = l2tp_conv;
2837 copy_address_wmem(wmem_file_scope(), &tunnel->lcce1, &pinfo->src);
2838 copy_address_wmem(wmem_file_scope(), &tunnel->lcce2, &pinfo->dst);
2843 if (!LENGTH_BIT(control)) {
2844 return;
2847 if (tunnel == NULL) {
2848 tunnel = l2tp_conv->tunnel;
2851 process_control_avps(tvb, pinfo, l2tp_tree, idx, length+baseIdx, ccid, tunnel);
2853 if (tunnel == &tmp_tunnel && l2tp_conv->tunnel == NULL) {
2854 l2tp_conv->tunnel = wmem_new0(wmem_file_scope(), l2tpv3_tunnel_t);
2855 memcpy(l2tp_conv->tunnel, &tmp_tunnel, sizeof(l2tpv3_tunnel_t));
2860 * Dissector for L2TP over UDP. For v2, calls process_control_avps for
2861 * control messages, or the ppp dissector based on the control bit.
2862 * For v3, calls either process_l2tpv3_control or process_l2tpv3_data_udp
2863 * based on the control bit.
2865 static int
2866 dissect_l2tp_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
2868 proto_tree *l2tp_tree;
2869 proto_item *l2tp_item;
2870 int idx = 0;
2871 int tmp_idx;
2872 uint16_t length = 0; /* Length field */
2873 uint16_t tid; /* Tunnel ID */
2874 uint16_t cid; /* Call ID */
2875 uint16_t offset_size; /* Offset size */
2876 uint16_t avp_type;
2877 uint16_t msg_type;
2878 uint16_t control;
2879 tvbuff_t *next_tvb;
2880 conversation_t *conv = NULL;
2881 l2tpv3_conversation_t *l2tp_conv = NULL;
2884 * Don't accept packets that aren't for an L2TP version we know,
2885 * as they might not be L2TP packets even though they happen
2886 * to be coming from or going to the L2TP port.
2888 if (tvb_captured_length(tvb) < 2)
2889 return 0; /* not enough information to check */
2890 control = tvb_get_ntohs(tvb, 0);
2891 switch (L2TP_VERSION(control)) {
2893 case 2:
2894 case 3:
2895 break;
2897 default:
2898 return 0;
2901 /* RFCs 2661 and 3931 say that L2TPv2 and v3 use a TFTP-like method
2902 * of each side choosing their own port and only using the L2TP port
2903 * to establish the connection. In common practice, both parties use
2904 * the assigned L2TP port the entire time, due to NAT, firewalls, etc.
2905 * We support both methods by using conversations with no second port.
2907 conv = find_conversation(pinfo->num, &pinfo->src, &pinfo->dst, CONVERSATION_UDP,
2908 pinfo->srcport, pinfo->destport, NO_PORT_B);
2910 if (conv == NULL || (conversation_get_dissector(conv, pinfo->num) != l2tp_udp_handle)) {
2911 conv = find_conversation(pinfo->num, &pinfo->dst, &pinfo->src, CONVERSATION_UDP,
2912 pinfo->destport, pinfo->srcport, NO_PORT_B);
2915 if ((conv == NULL) || (conversation_get_dissector(conv, pinfo->num) != l2tp_udp_handle)) {
2916 conv = conversation_new(pinfo->num, &pinfo->src, &pinfo->dst, CONVERSATION_UDP,
2917 pinfo->srcport, 0, NO_PORT2);
2918 conversation_set_dissector(conv, l2tp_udp_handle);
2921 col_set_str(pinfo->cinfo, COL_PROTOCOL, "L2TP");
2922 col_clear(pinfo->cinfo, COL_INFO);
2924 switch (L2TP_VERSION(control)) {
2926 case 2:
2927 break;
2929 case 3:
2930 l2tp_conv = (l2tpv3_conversation_t *)conversation_get_proto_data(conv, proto_l2tp);
2931 if (!l2tp_conv) {
2932 l2tp_conv = wmem_new0(wmem_file_scope(), l2tpv3_conversation_t);
2933 l2tp_conv->pt = PT_UDP;
2934 conversation_add_proto_data(conv, proto_l2tp, (void *)l2tp_conv);
2937 col_set_str(pinfo->cinfo, COL_PROTOCOL, "L2TPv3");
2938 if (CONTROL_BIT(control)) {
2939 /* Call to process l2tp v3 control message */
2940 process_l2tpv3_control(tvb, pinfo, tree, 0, l2tp_conv);
2942 else {
2943 /* Call to process l2tp v3 data message */
2944 process_l2tpv3_data_udp(tvb, pinfo, tree, l2tp_conv);
2946 return tvb_reported_length(tvb);
2949 if (LENGTH_BIT(control)) { /* length field included ? */
2950 idx += 2; /* skip ahead */
2951 length = tvb_get_ntohs(tvb, idx);
2954 /* collect the tunnel id & call id */
2955 idx += 2;
2956 tid = tvb_get_ntohs(tvb, idx);
2957 idx += 2;
2958 cid = tvb_get_ntohs(tvb, idx);
2960 if (CONTROL_BIT(control)) {
2961 /* CONTROL MESSAGE */
2962 tmp_idx = idx;
2964 if ((LENGTH_BIT(control))&&(length==12)) /* ZLB Message */
2965 col_add_fstr(pinfo->cinfo, COL_INFO,
2966 "%s - ZLB (tunnel id=%d, session id=%u)",
2967 control_msg, tid, cid);
2968 else
2970 if (SEQUENCE_BIT(control)) {
2971 tmp_idx += 4;
2974 tmp_idx+=4;
2976 avp_type = tvb_get_ntohs(tvb, (tmp_idx+=2));
2978 if (avp_type == CONTROL_MESSAGE) {
2979 /* We print message type */
2980 msg_type = tvb_get_ntohs(tvb, tmp_idx+2);
2981 col_add_fstr(pinfo->cinfo, COL_INFO,
2982 "%s - %s (tunnel id=%u, session id=%u)",
2983 control_msg,
2984 val_to_str_ext(msg_type, &l2tp_message_type_short_str_vals_ext, "Unknown (%u)"),
2985 tid, cid);
2987 else
2990 * This is not a control message.
2991 * We never pass here except in case of bad l2tp packet!
2993 col_add_fstr(pinfo->cinfo, COL_INFO,
2994 "%s (tunnel id=%u, session id=%u)",
2995 control_msg, tid, cid);
3000 else {
3001 /* DATA Message */
3002 col_add_fstr(pinfo->cinfo, COL_INFO,
3003 "%s (tunnel id=%u, session id=%u)",
3004 data_msg, tid, cid);
3007 if (LENGTH_BIT(control)) {
3009 * Set the length of this tvbuff to be no longer than the length
3010 * in the header.
3012 * XXX - complain if that length is longer than the length of
3013 * the tvbuff? Have "set_actual_length()" return a Boolean
3014 * and have its callers check the result?
3016 set_actual_length(tvb, length);
3019 l2tp_item = proto_tree_add_item(tree,proto_l2tp, tvb, 0, -1, ENC_NA);
3020 l2tp_tree = proto_item_add_subtree(l2tp_item, ett_l2tp);
3022 if (tree) {
3023 static int * const control_fields[] = {
3024 &hf_l2tp_type,
3025 &hf_l2tp_length_bit,
3026 &hf_l2tp_seq_bit,
3027 &hf_l2tp_offset_bit,
3028 &hf_l2tp_priority,
3029 &hf_l2tp_version,
3030 NULL
3033 proto_tree_add_bitmask(l2tp_tree, tvb, 0, hf_l2tp_flags, ett_l2tp_flags, control_fields, ENC_BIG_ENDIAN);
3035 idx = 2;
3036 if (LENGTH_BIT(control)) {
3037 if (tree) {
3038 proto_tree_add_item(l2tp_tree, hf_l2tp_length, tvb, idx, 2, ENC_BIG_ENDIAN);
3040 idx += 2;
3043 if (tree) {
3044 proto_tree_add_item(l2tp_tree, hf_l2tp_tunnel, tvb, idx, 2, ENC_BIG_ENDIAN);
3046 idx += 2;
3047 if (tree) {
3048 proto_tree_add_item(l2tp_tree, hf_l2tp_session, tvb, idx, 2, ENC_BIG_ENDIAN);
3050 idx += 2;
3052 if (SEQUENCE_BIT(control)) {
3053 if (tree) {
3054 proto_tree_add_item(l2tp_tree, hf_l2tp_Ns, tvb, idx, 2, ENC_BIG_ENDIAN);
3056 idx += 2;
3057 if (tree) {
3058 proto_tree_add_item(l2tp_tree, hf_l2tp_Nr, tvb, idx, 2, ENC_BIG_ENDIAN);
3060 idx += 2;
3062 if (OFFSET_BIT(control)) {
3063 offset_size = tvb_get_ntohs(tvb, idx);
3064 if (tree) {
3065 proto_tree_add_uint(l2tp_tree, hf_l2tp_offset, tvb, idx, 2,
3066 offset_size);
3068 idx += 2;
3069 if (offset_size != 0) {
3070 if (tree) {
3071 proto_tree_add_item(l2tp_tree, hf_l2tp_offset_padding, tvb, idx, offset_size, ENC_NA);
3073 idx += offset_size;
3077 if (tree && (LENGTH_BIT(control))&&(length==12)) {
3078 proto_tree_add_item(l2tp_tree, hf_l2tp_zero_length_body_message, tvb, 0, 0, ENC_NA);
3081 if (!CONTROL_BIT(control)) { /* Data Messages so we are done */
3082 if (tree)
3083 proto_item_set_len(l2tp_item, idx);
3084 /* If we have data, signified by having a length bit, dissect it */
3085 if (tvb_offset_exists(tvb, idx)) {
3086 next_tvb = tvb_new_subset_remaining(tvb, idx);
3087 call_dissector(ppp_hdlc_handle, next_tvb, pinfo, tree);
3089 return tvb_reported_length(tvb);
3092 if (LENGTH_BIT(control))
3093 process_control_avps(tvb, pinfo, l2tp_tree, idx, length, -1, NULL);
3095 return tvb_reported_length(tvb);
3100 * Only L2TPv3 runs directly over IP, and dissect_l2tp_ip starts dissecting
3101 * those packets to call either process_l2tpv3_control for Control Messages
3102 * or process_l2tpv3_data_ip for Data Messages over IP, based on the
3103 * Session ID
3105 static int
3106 dissect_l2tp_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
3108 int idx = 0;
3109 uint32_t sid; /* Session ID */
3111 conversation_t *conv = NULL;
3112 l2tpv3_conversation_t *l2tp_conv = NULL;
3114 conv = find_or_create_conversation(pinfo);
3116 l2tp_conv = (l2tpv3_conversation_t *)conversation_get_proto_data(conv, proto_l2tp);
3117 if (!l2tp_conv) {
3118 l2tp_conv = wmem_new0(wmem_file_scope(), l2tpv3_conversation_t);
3119 l2tp_conv->pt = PT_NONE;
3120 conversation_add_proto_data(conv, proto_l2tp, (void *)l2tp_conv);
3123 /* Only L2TPv3 runs directly over IP */
3124 col_set_str(pinfo->cinfo, COL_PROTOCOL, "L2TPv3");
3126 col_clear(pinfo->cinfo, COL_INFO);
3128 sid = tvb_get_ntohl(tvb, idx);
3129 if (sid == 0) {
3130 /* This is control message */
3131 /* Call to process l2tp v3 control message */
3132 process_l2tpv3_control(tvb, pinfo, tree, 4, l2tp_conv);
3134 else {
3135 /* Call to process l2tp v3 data message */
3136 process_l2tpv3_data_ip(tvb, pinfo, tree, l2tp_conv);
3139 return tvb_captured_length(tvb);
3142 static int dissect_atm_oam_llc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
3144 uint32_t oam_cell = GPOINTER_TO_UINT(data);
3146 if (oam_cell) {
3147 call_dissector(atm_oam_handle, tvb, pinfo, tree);
3148 } else {
3149 call_dissector(llc_handle, tvb, pinfo, tree);
3152 return tvb_captured_length(tvb);
3155 static void l2tp_cleanup(void)
3157 GSList *iterator = list_heads;
3159 while (iterator) {
3160 g_slist_free((GSList *)iterator->data);
3161 iterator = g_slist_next(iterator);
3164 if (list_heads != NULL) {
3165 g_slist_free(list_heads);
3166 list_heads = NULL;
3170 /* registration with the filtering engine */
3171 void
3172 proto_register_l2tp(void)
3174 static hf_register_info hf[] = {
3175 { &hf_l2tp_flags,
3176 { "Flags", "l2tp.flags", FT_UINT16, BASE_HEX, NULL, 0,
3177 NULL, HFILL }},
3179 { &hf_l2tp_type,
3180 { "Type", "l2tp.type", FT_UINT16, BASE_DEC, VALS(l2tp_type_vals), 0x8000,
3181 "Type bit", HFILL }},
3183 { &hf_l2tp_length_bit,
3184 { "Length Bit", "l2tp.length_bit", FT_BOOLEAN, 16, TFS(&l2tp_length_bit_truth), 0x4000,
3185 NULL, HFILL }},
3187 { &hf_l2tp_seq_bit,
3188 { "Sequence Bit", "l2tp.seq_bit", FT_BOOLEAN, 16, TFS(&l2tp_seq_bit_truth), 0x0800,
3189 NULL, HFILL }},
3191 { &hf_l2tp_offset_bit,
3192 { "Offset bit", "l2tp.offset_bit", FT_BOOLEAN, 16, TFS(&l2tp_offset_bit_truth), 0x0200,
3193 NULL, HFILL }},
3195 { &hf_l2tp_priority,
3196 { "Priority", "l2tp.priority", FT_BOOLEAN, 16, TFS(&l2tp_priority_truth), 0x0100,
3197 "Priority bit", HFILL }},
3199 { &hf_l2tp_version,
3200 { "Version", "l2tp.version", FT_UINT16, BASE_DEC, NULL, 0x000f,
3201 NULL, HFILL }},
3203 { &hf_l2tp_length,
3204 { "Length","l2tp.length", FT_UINT16, BASE_DEC, NULL, 0x0,
3205 NULL, HFILL }},
3207 { &hf_l2tp_tunnel,
3208 { "Tunnel ID","l2tp.tunnel", FT_UINT16, BASE_DEC, NULL, 0x0, /* Probably should be FT_BYTES */
3209 NULL, HFILL }},
3211 { &hf_l2tp_session,
3212 { "Session ID","l2tp.session", FT_UINT16, BASE_DEC, NULL, 0x0, /* Probably should be FT_BYTES */
3213 NULL, HFILL }},
3215 { &hf_l2tp_Ns,
3216 { "Ns","l2tp.Ns", FT_UINT16, BASE_DEC, NULL, 0x0,
3217 NULL, HFILL }},
3219 { &hf_l2tp_Nr,
3220 { "Nr","l2tp.Nr", FT_UINT16, BASE_DEC, NULL, 0x0,
3221 NULL, HFILL }},
3223 { &hf_l2tp_offset,
3224 { "Offset","l2tp.offset", FT_UINT16, BASE_DEC, NULL, 0x0,
3225 "Number of octets past the L2TP header at which the payload data starts.", HFILL }},
3227 { &hf_l2tp_avp_mandatory,
3228 { "Mandatory", "l2tp.avp.mandatory", FT_BOOLEAN, 16, NULL, 0x8000,
3229 NULL, HFILL }},
3231 { &hf_l2tp_avp_hidden,
3232 { "Hidden", "l2tp.avp.hidden", FT_BOOLEAN, 16, NULL, 0x4000,
3233 NULL, HFILL }},
3235 { &hf_l2tp_avp_length,
3236 { "Length", "l2tp.avp.length", FT_UINT16, BASE_DEC, NULL, 0x03ff,
3237 NULL, HFILL }},
3239 { &hf_l2tp_avp_vendor_id,
3240 { "Vendor ID", "l2tp.avp.vendor_id", FT_UINT32, BASE_ENTERPRISES, STRINGS_ENTERPRISES, 0,
3241 "AVP Vendor ID", HFILL }},
3243 { &hf_l2tp_avp_type,
3244 { "AVP Type", "l2tp.avp.type", FT_UINT16, BASE_DEC|BASE_EXT_STRING, &avp_type_vals_ext, 0,
3245 NULL, HFILL }},
3247 { &hf_l2tp_tie_breaker,
3248 { "Tie Breaker", "l2tp.tie_breaker", FT_UINT64, BASE_HEX, NULL, 0,
3249 NULL, HFILL }},
3251 { &hf_l2tp_sid,
3252 { "Session ID","l2tp.sid", FT_UINT32, BASE_HEX, NULL, 0x0,
3253 NULL, HFILL }},
3255 { &hf_l2tp_ccid,
3256 { "Control Connection ID","l2tp.ccid", FT_UINT32, BASE_HEX, NULL, 0x0,
3257 NULL, HFILL }},
3259 { &hf_l2tp_res,
3260 { "Reserved","l2tp.res", FT_UINT16, BASE_HEX, NULL, 0x0,
3261 NULL, HFILL }},
3263 { &hf_l2tp_cookie,
3264 { "Cookie","l2tp.cookie", FT_BYTES, BASE_NONE, NULL, 0x0,
3265 NULL, HFILL }},
3267 { &hf_l2tp_l2_spec_def,
3268 { "Default L2-Specific Sublayer","l2tp.l2_spec_def", FT_NONE, BASE_NONE, NULL, 0x0,
3269 NULL, HFILL }},
3271 { &hf_l2tp_l2_spec_atm,
3272 { "ATM-Specific Sublayer","l2tp.l2_spec_atm", FT_NONE, BASE_NONE, NULL, 0x0,
3273 NULL, HFILL }},
3275 { &hf_l2tp_l2_spec_docsis_dmpt,
3276 { "DOCSIS DMPT - Specific Sublayer","l2tp.l2_spec_docsis_dmpt", FT_NONE, BASE_NONE, NULL, 0x0,
3277 NULL, HFILL }},
3279 { &hf_l2tp_l2_spec_v,
3280 { "V-bit","l2tp.l2_spec_v", FT_BOOLEAN, 8, NULL, 0x80,
3281 "VCCV Bit", HFILL }},
3283 { &hf_l2tp_l2_spec_s,
3284 { "S-bit","l2tp.l2_spec_s", FT_BOOLEAN, 8, NULL, 0x40,
3285 "Sequence Bit", HFILL }},
3287 { &hf_l2tp_l2_spec_h,
3288 { "H-bits","l2tp.l2_spec_h", FT_UINT8, BASE_HEX, NULL, 0x30,
3289 "Extended Header Bits", HFILL }},
3291 { &hf_l2tp_l2_spec_t,
3292 { "T-bit","l2tp.l2_spec_t", FT_BOOLEAN, 8, NULL, 0x08,
3293 "Transport Type Bit", HFILL }},
3295 { &hf_l2tp_l2_spec_g,
3296 { "G-bit","l2tp.l2_spec_g", FT_BOOLEAN, 8, NULL, 0x04,
3297 "EFCI Bit", HFILL }},
3299 { &hf_l2tp_l2_spec_c,
3300 { "C-bit","l2tp.l2_spec_c", FT_BOOLEAN, 8, NULL, 0x02,
3301 "CLP Bit", HFILL }},
3303 { &hf_l2tp_l2_spec_u,
3304 { "U-bit","l2tp.l2_spec_u", FT_BOOLEAN, 8, NULL, 0x01,
3305 "C/R Bit", HFILL }},
3307 { &hf_l2tp_l2_spec_flow_id,
3308 { "Flow ID","l2tp.l2_spec_flow_id", FT_UINT8, BASE_HEX, NULL, FLOW_ID_MASK,
3309 NULL, HFILL }},
3311 { &hf_l2tp_l2_spec_sequence,
3312 { "Sequence Number","l2tp.l2_spec_sequence", FT_UINT24, BASE_DEC, NULL, 0x0,
3313 NULL, HFILL }},
3315 { &hf_l2tp_cisco_avp_type,
3316 { "Type", "l2tp.avp.ciscotype", FT_UINT16, BASE_DEC, VALS(cisco_avp_type_vals), 0,
3317 "AVP Type", HFILL }},
3319 { &hf_l2tp_ericsson_avp_type,
3320 { "Type", "l2tp.avp.ericssontype", FT_UINT16, BASE_DEC, VALS(ericsson_avp_type_vals), 0,
3321 "AVP Type", HFILL }},
3323 { &hf_l2tp_broadband_avp_type,
3324 { "Type", "l2tp.avp.broadbandtype", FT_UINT16, BASE_DEC, VALS(broadband_avp_type_vals), 0,
3325 "AVP Type", HFILL }},
3327 { &hf_l2tp_cablelabs_avp_type,
3328 { "Type", "l2tp.avp.cablelabstype", FT_UINT16, BASE_DEC, VALS(cablelabs_avp_type_vals), 0,
3329 "AVP Type", HFILL }},
3331 { &hf_l2tp_avp_message_type,
3332 { "Message Type", "l2tp.avp.message_type", FT_UINT16, BASE_DEC|BASE_EXT_STRING, &message_type_vals_ext, 0,
3333 NULL, HFILL }},
3335 { &hf_l2tp_avp_assigned_tunnel_id,
3336 { "Assigned Tunnel ID", "l2tp.avp.assigned_tunnel_id", FT_UINT16, BASE_DEC, NULL, 0,
3337 NULL, HFILL }},
3339 { &hf_l2tp_avp_assigned_control_conn_id,
3340 { "Assigned Control Connection ID", "l2tp.avp.assigned_control_conn_id", FT_UINT32, BASE_DEC, NULL, 0,
3341 NULL, HFILL }},
3343 { &hf_l2tp_avp_assigned_session_id,
3344 { "Assigned Session ID", "l2tp.avp.assigned_session_id", FT_UINT16, BASE_DEC, NULL, 0,
3345 NULL, HFILL }},
3347 { &hf_l2tp_avp_remote_session_id,
3348 { "Remote Session ID", "l2tp.avp.remote_session_id", FT_UINT32, BASE_DEC, NULL, 0,
3349 NULL, HFILL }},
3351 { &hf_l2tp_avp_local_session_id,
3352 { "Local Session ID", "l2tp.avp.local_session_id", FT_UINT32, BASE_DEC, NULL, 0,
3353 NULL, HFILL }},
3355 { &hf_l2tp_avp_called_number,
3356 { "Called Number", "l2tp.avp.called_number", FT_STRING, BASE_NONE, NULL, 0,
3357 NULL, HFILL }},
3359 { &hf_l2tp_avp_calling_number,
3360 { "Calling Number", "l2tp.avp.calling_number", FT_STRING, BASE_NONE, NULL, 0,
3361 NULL, HFILL }},
3363 { &hf_l2tp_cisco_tie_breaker,
3364 { "Tie Breaker", "l2tp.cisco.tie_breaker", FT_UINT64, BASE_HEX, NULL, 0,
3365 NULL, HFILL }},
3367 { &hf_l2tp_cablel_avp_l_bit,
3368 { "L(lock bit)", "l2tp.cablel.l_bit", FT_BOOLEAN, 16, NULL, 0x8000,
3369 NULL, HFILL }},
3371 { &hf_l2tp_cablel_avp_tsid_group_id,
3372 { "TSID Group ID", "l2tp.cablel.tsid_group_id", FT_UINT16, BASE_DEC, NULL, 0x7f00,
3373 NULL, HFILL }},
3375 { &hf_l2tp_cablel_avp_frequency,
3376 { "Frequency", "l2tp.cablel.frequency", FT_UINT32, BASE_DEC, NULL, 0,
3377 NULL, HFILL }},
3379 { &hf_l2tp_cablel_avp_modulation,
3380 { "Modulation", "l2tp.cablel.modulation", FT_UINT16, BASE_DEC, VALS(l2tp_cablel_modulation_vals), 0x000f,
3381 NULL, HFILL }},
3383 { &hf_l2tp_cablel_avp_m,
3384 { "M", "l2tp.cablel.m", FT_UINT16, BASE_DEC, NULL, 0x0,
3385 NULL, HFILL }},
3387 { &hf_l2tp_cablel_avp_n,
3388 { "N", "l2tp.cablel.n", FT_UINT16, BASE_DEC, NULL, 0x0,
3389 NULL, HFILL }},
3391 { &hf_l2tp_broadband_agent_circuit_id,
3392 { "Agent Circuit ID", "l2tp.broadband.agent_circuit_id", FT_STRING, BASE_NONE, NULL, 0x0,
3393 NULL, HFILL }},
3395 { &hf_l2tp_broadband_agent_remote_id,
3396 { "Agent Remote ID", "l2tp.broadband.agent_remote_id", FT_STRING, BASE_NONE, NULL, 0x0,
3397 NULL, HFILL }},
3399 { &hf_l2tp_broadband_actual_dr_up,
3400 { "Actual Data Rate Upstream", "l2tp.broadband.actual_dr_up", FT_UINT64, BASE_DEC, NULL, 0x0,
3401 "Actual Data Rate Upstream in bits per seconds", HFILL }},
3403 { &hf_l2tp_broadband_actual_dr_down,
3404 { "Actual Data Rate Downstream", "l2tp.broadband.actual_dr_down", FT_UINT64, BASE_DEC, NULL, 0x0,
3405 "Actual Data Rate Downstream in bits per seconds", HFILL }},
3407 { &hf_l2tp_broadband_minimum_dr_up,
3408 { "Minimum Data Rate Upstream", "l2tp.broadband.minimum_dr_up", FT_UINT64, BASE_DEC, NULL, 0x0,
3409 "Minimum Data Rate Upstream in bits per seconds", HFILL }},
3411 { &hf_l2tp_broadband_minimum_dr_down,
3412 { "Minimum Data Rate Downstream", "l2tp.broadband.minimum_dr_down", FT_UINT64, BASE_DEC, NULL, 0x0,
3413 "Minimum Data Rate Downstream in bits per seconds", HFILL }},
3415 { &hf_l2tp_broadband_attainable_dr_up,
3416 { "Attainable Data Rate Upstream", "l2tp.broadband.attainable_dr_up", FT_UINT64, BASE_DEC, NULL, 0x0,
3417 "Attainable Data Rate Upstream in bits per seconds", HFILL }},
3419 { &hf_l2tp_broadband_attainable_dr_down,
3420 { "Attainable Data Rate Downstream", "l2tp.broadband.attainable_dr_down", FT_UINT64, BASE_DEC, NULL, 0x0,
3421 "Attainable Data Rate Downstream in bits per seconds", HFILL }},
3423 { &hf_l2tp_broadband_maximum_dr_up,
3424 { "Maximum Data Rate Upstream", "l2tp.broadband.maximum_dr_up", FT_UINT64, BASE_DEC, NULL, 0x0,
3425 "Maximum Data Rate Upstream in bits per seconds", HFILL }},
3427 { &hf_l2tp_broadband_maximum_dr_down,
3428 { "Maximum Data Rate Downstream", "l2tp.broadband.maximum_dr_down", FT_UINT64, BASE_DEC, NULL, 0x0,
3429 "Maximum Data Rate Downstream in bits per seconds", HFILL }},
3431 { &hf_l2tp_broadband_minimum_dr_up_low_power,
3432 { "Minimum Data Rate Upstream Low-Power", "l2tp.broadband.minimum_dr_up_low_power", FT_UINT64, BASE_DEC, NULL, 0x0,
3433 "Minimum Data Rate Upstream Low-Power in bits per seconds", HFILL }},
3435 { &hf_l2tp_broadband_minimum_dr_down_low_power,
3436 { "Minimum Data Rate Downstream Low-Power", "l2tp.broadband.minimum_dr_down_low_power", FT_UINT64, BASE_DEC, NULL, 0x0,
3437 "Minimum Data Rate Downstream Low-Power in bits per seconds", HFILL }},
3439 { &hf_l2tp_broadband_maximum_interleaving_delay_up,
3440 { "Maximum Interleaving Delay Upstream", "l2tp.broadband.maximum_interleaving_delay_up", FT_UINT32, BASE_DEC, NULL, 0x0,
3441 "Maximum Interleaving Delay Upstream in ms", HFILL }},
3443 { &hf_l2tp_broadband_actual_interleaving_delay_up,
3444 { "Actual Interleaving Delay Upstream", "l2tp.broadband.actual_interleaving_delay_up", FT_UINT32, BASE_DEC, NULL, 0x0,
3445 "Actual Interleaving Delay Upstream in ms", HFILL }},
3447 { &hf_l2tp_broadband_maximum_interleaving_delay_down,
3448 { "Maximum Interleaving Delay Downstream", "l2tp.broadband.maximum_interleaving_delay_down", FT_UINT32, BASE_DEC, NULL, 0x0,
3449 "Maximum Interleaving Delay Downstream in ms", HFILL }},
3451 { &hf_l2tp_broadband_actual_interleaving_delay_down,
3452 { "Actual Interleaving Delay Downstream", "l2tp.broadband.actual_interleaving_delay_down", FT_UINT32, BASE_DEC, NULL, 0x0,
3453 "Actual Interleaving Delay Downstream in ms", HFILL }},
3455 { &hf_l2tp_broadband_access_loop_encapsulation,
3456 { "Access Loop Encapsulation", "l2tp.broadband.access_loop_encapsulation", FT_NONE, BASE_NONE, NULL, 0x0,
3457 NULL, HFILL }},
3459 { &hf_l2tp_broadband_access_loop_encapsulation_data_link,
3460 { "Data Link", "l2tp.broadband.access_loop_encapsulation.data_link", FT_UINT8, BASE_HEX, VALS(ale_datalink_types_vals), 0x0,
3461 NULL, HFILL }},
3463 { &hf_l2tp_broadband_access_loop_encapsulation_enc1,
3464 { "Encaps 1", "l2tp.broadband.access_loop_encapsulation.enc1", FT_UINT8, BASE_HEX, VALS(ale_enc1_types_vals), 0x0,
3465 NULL, HFILL }},
3467 { &hf_l2tp_broadband_access_loop_encapsulation_enc2,
3468 { "Encaps 2", "l2tp.broadband.access_loop_encapsulation.enc2", FT_UINT8, BASE_HEX, VALS(ale_enc2_types_vals), 0x0,
3469 NULL, HFILL }},
3471 { &hf_l2tp_broadband_ancp_access_line_type,
3472 { "ANCP Access Line Type", "l2tp.broadband.ancp_access_line_type", FT_UINT32, BASE_HEX, VALS(ancp_types_vals), 0x0,
3473 NULL, HFILL }},
3475 { &hf_l2tp_broadband_iwf_session,
3476 { "IWF Session", "l2tp.broadband.iwf_session", FT_UINT32, BASE_HEX, VALS(iwf_types_vals), 0x0,
3477 NULL, HFILL }},
3479 { &hf_l2tp_avp_csu,
3480 { "Connect Speed Update","l2tp.avp.csu", FT_NONE, BASE_NONE, NULL, 0x0,
3481 NULL, HFILL }},
3483 { &hf_l2tp_avp_csu_res,
3484 { "Reserved", "l2tp.avp.csu.res", FT_UINT16, BASE_HEX, NULL, 0x0,
3485 NULL, HFILL }},
3487 { &hf_l2tp_avp_csu_remote_session_id_v2,
3488 { "Remote Session ID", "l2tp.avp.csu.remote_session_id", FT_UINT16, BASE_DEC_HEX, NULL, 0x0,
3489 NULL, HFILL }},
3491 { &hf_l2tp_avp_csu_current_tx_speed_v2,
3492 { "Current TX Connect Speed", "l2tp.avp.csu.current_tx_speed", FT_UINT32, BASE_DEC, NULL, 0x0,
3493 "Current TX Connect Speed in bps", HFILL }},
3495 { &hf_l2tp_avp_csu_current_rx_speed_v2,
3496 { "Current RX Connect Speed", "l2tp.avp.csu.current_rx_speed", FT_UINT32, BASE_DEC, NULL, 0x0,
3497 "Current RX Connect Speed in bps", HFILL }},
3499 { &hf_l2tp_avp_csu_remote_session_id_v3,
3500 { "Remote Session ID", "l2tp.avp.csu.remote_session_id", FT_UINT32, BASE_DEC_HEX, NULL, 0x0,
3501 NULL, HFILL }},
3503 { &hf_l2tp_avp_csu_current_tx_speed_v3,
3504 { "Current TX Connect Speed", "l2tp.avp.csu.current_tx_speed64", FT_UINT64, BASE_DEC, NULL, 0x0,
3505 "Current TX Connect Speed in bps", HFILL }},
3507 { &hf_l2tp_avp_csu_current_rx_speed_v3,
3508 { "Current RX Connect Speed", "l2tp.avp.csu.current_rx_speed64", FT_UINT64, BASE_DEC, NULL, 0x0,
3509 "Current RX Connect Speed in bps", HFILL }},
3511 { &hf_l2tp_ericsson_msg_type,
3512 { "Ericsson Message Type", "l2tp.ericsson.msg_type", FT_UINT16, BASE_DEC, VALS(ericsson_msg_type_vals), 0x0,
3513 NULL, HFILL }},
3515 { &hf_l2tp_ericsson_conn_type,
3516 { "Connection Type", "l2tp.ericsson.conn_type", FT_UINT8, BASE_DEC, VALS(ericsson_conn_type_vals), 0x0,
3517 NULL, HFILL }},
3519 { &hf_l2tp_ericsson_stn_name,
3520 { "STN Name", "l2tp.ericsson.stn_name", FT_STRING, BASE_NONE, NULL, 0x0,
3521 NULL, HFILL }},
3523 { &hf_l2tp_ericsson_crc32_enable,
3524 { "CRC32 Enabled", "l2tp.ericsson.crc32_enable", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3525 NULL, HFILL }},
3527 { &hf_l2tp_ericsson_abis_lower_mode,
3528 { "Abis Lower Type", "l2tp.ericsson.abis_lower_mode", FT_UINT8, BASE_DEC, VALS(ericsson_abis_lower_mode_vals), 0x0,
3529 NULL, HFILL }},
3531 { &hf_l2tp_ericsson_tc_overl_thresh,
3532 { "Overload Threshold in 0.1%", "l2tp.ericsson.overload_thresh", FT_UINT16, BASE_DEC, NULL, 0x0,
3533 NULL, HFILL }},
3535 { &hf_l2tp_ericsson_tc_num_groups,
3536 { "Number of Transport Config Groups", "l2tp.ericsson.tc_num_groups", FT_UINT8, BASE_DEC, NULL, 0x0,
3537 NULL, HFILL }},
3539 { &hf_l2tp_ericsson_tcg_group_id,
3540 { "Transport Config Group ID", "l2tp.ericsson.tc_group_id", FT_UINT8, BASE_DEC, NULL, 0x0,
3541 NULL, HFILL }},
3543 { &hf_l2tp_ericsson_tcg_num_sapis,
3544 { "Number of SAPIs in Transport Group", "l2tp.ericsson.tc_num_sapi", FT_UINT8, BASE_DEC, NULL, 0x0,
3545 NULL, HFILL }},
3547 { &hf_l2tp_ericsson_tcg_sapi,
3548 { "TCG SAPI", "l2tp.ericsson.tcg_sapi", FT_UINT8, BASE_DEC, NULL, 0x0,
3549 NULL, HFILL }},
3551 { &hf_l2tp_ericsson_tcg_ip,
3552 { "TCG IP Address", "l2tp.ericsson.tcg_ip", FT_IPv4, BASE_NONE, NULL, 0x0,
3553 NULL, HFILL }},
3555 { &hf_l2tp_ericsson_tcg_dscp,
3556 { "TCG DSCP", "l2tp.ericsson.tcg_dscp", FT_UINT8, BASE_HEX, NULL, 0x0,
3557 NULL, HFILL }},
3559 { &hf_l2tp_ericsson_tcg_crc32_enable,
3560 { "CRC32 Enabled", "l2tp.ericsson.crc32_en", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3561 NULL, HFILL }},
3563 { &hf_l2tp_ericsson_tcg_bundling_tout,
3564 { "TCG Bundling Timeout (ms)", "l2tp.ericsson.gcg.bundle_tout", FT_UINT8, BASE_DEC, NULL, 0x0,
3565 NULL, HFILL }},
3567 { &hf_l2tp_ericsson_tcg_bundling_max_pkt,
3568 { "TCG Bundling Max Packet Size", "l2tp.ericsson.tcg.bundle_max_pkt", FT_UINT16, BASE_DEC, NULL, 0x0,
3569 NULL, HFILL }},
3571 { &hf_l2tp_ericsson_tc_num_maps,
3572 { "Number of TEI-SC Maps", "l2tp.ericsson.num_maps", FT_UINT8, BASE_DEC, NULL, 0x0,
3573 NULL, HFILL }},
3575 { &hf_l2tp_ericsson_map_tei_low,
3576 { "TEI Range Lowest Value", "l2tp.ericsson.map_tei_low", FT_UINT8, BASE_DEC, NULL, 0x0,
3577 NULL, HFILL }},
3579 { &hf_l2tp_ericsson_map_tei_high,
3580 { "TEI Range Highest Value", "l2tp.ericsson.map_tei_high", FT_UINT8, BASE_DEC, NULL, 0x0,
3581 NULL, HFILL }},
3583 { &hf_l2tp_ericsson_map_sc,
3584 { "Super Channel", "l2tp.ericsson.map_ssc", FT_UINT8, BASE_DEC, NULL, 0x0,
3585 NULL, HFILL }},
3587 { &hf_l2tp_ericsson_ver_pref,
3588 { "Preferred/Chosen Version", "l2tp.ericsson.ver_pref", FT_UINT32, BASE_DEC, NULL, 0x0,
3589 NULL, HFILL }},
3591 { &hf_l2tp_ericsson_ver_2,
3592 { "Version (2)", "l2tp.ericsson.ver_2", FT_UINT32, BASE_DEC, NULL, 0x0,
3593 NULL, HFILL }},
3595 { &hf_l2tp_ericsson_ver_3,
3596 { "Version (3)", "l2tp.ericsson.ver_3", FT_UINT32, BASE_DEC, NULL, 0x0,
3597 NULL, HFILL }},
3599 /* Generated from convert_proto_tree_add_text.pl */
3600 { &hf_l2tp_cisco_assigned_control_connection_id, { "Assigned Control Connection ID", "l2tp.cisco.assigned_control_connection_id", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3601 { &hf_l2tp_cisco_pw_type, { "PW Type", "l2tp.cisco.pw_type", FT_UINT16, BASE_DEC, VALS(pw_types_vals), 0x0, NULL, HFILL }},
3602 { &hf_l2tp_cisco_local_session_id, { "Local Session ID", "l2tp.cisco.local_session_id", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3603 { &hf_l2tp_cisco_remote_session_id, { "Remote Session ID", "l2tp.cisco.remote_session_id", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3604 { &hf_l2tp_cisco_assigned_cookie, { "Assigned Cookie", "l2tp.cisco.assigned_cookie", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3605 { &hf_l2tp_cisco_remote_end_id, { "Remote End ID", "l2tp.cisco.remote_end_id", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3606 { &hf_l2tp_cisco_pseudowire_type, { "Pseudowire Type", "l2tp.cisco.pseudowire_type", FT_UINT16, BASE_DEC, VALS(pw_types_vals), 0x0, NULL, HFILL }},
3607 { &hf_l2tp_cisco_circuit_status, { "Circuit Status", "l2tp.cisco.circuit_status", FT_BOOLEAN, 16, TFS(&tfs_up_down), 0x0001, NULL, HFILL }},
3608 { &hf_l2tp_cisco_circuit_type, { "Circuit Type", "l2tp.cisco.circuit_type", FT_BOOLEAN, 16, TFS(&tfs_new_existing), 0x0001, NULL, HFILL }},
3609 { &hf_l2tp_cisco_draft_avp_version, { "Draft AVP Version", "l2tp.cisco.draft_avp_version", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3610 { &hf_l2tp_cisco_message_digest, { "Message Digest", "l2tp.cisco.message_digest", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3611 { &hf_l2tp_cisco_nonce, { "Nonce", "l2tp.cisco.nonce", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3612 { &hf_l2tp_cisco_interface_mtu, { "Interface MTU", "l2tp.cisco.interface_mtu", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3613 { &hf_l2tp_stop_ccn_result_code, { "Result code", "l2tp.result_code", FT_UINT16, BASE_DEC, VALS(result_code_stopccn_vals), 0x0, NULL, HFILL }},
3614 { &hf_l2tp_result_code, { "Result code", "l2tp.result_code", FT_UINT16, BASE_DEC|BASE_EXT_STRING, &result_code_cdn_vals_ext, 0x0, NULL, HFILL }},
3615 { &hf_l2tp_avp_error_code, { "Error code", "l2tp.avp.error_code", FT_UINT16, BASE_DEC, VALS(error_code_vals), 0x0, NULL, HFILL }},
3616 { &hf_l2tp_avp_error_message, { "Error Message", "l2tp.avp.error_message", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3617 { &hf_l2tp_avp_protocol_version, { "Version", "l2tp.avp.protocol_version", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3618 { &hf_l2tp_avp_protocol_revision, { "Revision", "l2tp.avp.protocol_revision", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3619 { &hf_l2tp_avp_async_framing_supported, { "Async Framing Supported", "l2tp.avp.async_framing_supported", FT_BOOLEAN, 32, NULL, 0x00000002, NULL, HFILL }},
3620 { &hf_l2tp_avp_sync_framing_supported, { "Sync Framing Supported", "l2tp.avp.sync_framing_supported", FT_BOOLEAN, 32, NULL, 0x00000001, NULL, HFILL }},
3621 { &hf_l2tp_avp_analog_access_supported, { "Analog Access Supported", "l2tp.avp.analog_access_supported", FT_BOOLEAN, 32, NULL, 0x00000002, NULL, HFILL }},
3622 { &hf_l2tp_avp_digital_access_supported, { "Digital Access Supported", "l2tp.avp.digital_access_supported", FT_BOOLEAN, 32, NULL, 0x00000001, NULL, HFILL }},
3623 { &hf_l2tp_avp_firmware_revision, { "Firmware Revision", "l2tp.avp.firmware_revision", FT_UINT16, BASE_DEC_HEX, NULL, 0x0, NULL, HFILL }},
3624 { &hf_l2tp_avp_host_name, { "Host Name", "l2tp.avp.host_name", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3625 { &hf_l2tp_avp_vendor_name, { "Vendor Name", "l2tp.avp.vendor_name", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3626 { &hf_l2tp_avp_receive_window_size, { "Receive Window Size", "l2tp.avp.receive_window_size", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3627 { &hf_l2tp_avp_chap_challenge, { "CHAP Challenge", "l2tp.avp.chap_challenge", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3628 { &hf_l2tp_avp_cause_code, { "Cause Code", "l2tp.avp.cause_code", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3629 { &hf_l2tp_avp_cause_msg, { "Cause Msg", "l2tp.avp.cause_msg", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3630 { &hf_l2tp_avp_advisory_msg, { "Advisory Msg", "l2tp.avp.advisory_msg", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3631 { &hf_l2tp_avp_chap_challenge_response, { "CHAP Challenge Response", "l2tp.avp.chap_challenge_response", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3632 { &hf_l2tp_avp_call_serial_number, { "Call Serial Number", "l2tp.avp.call_serial_number", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3633 { &hf_l2tp_avp_minimum_bps, { "Minimum BPS", "l2tp.avp.minimum_bps", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3634 { &hf_l2tp_avp_maximum_bps, { "Maximum BPS", "l2tp.avp.maximum_bps", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3635 { &hf_l2tp_avp_analog_bearer_type, { "Analog Bearer Type", "l2tp.avp.analog_bearer_type", FT_BOOLEAN, 32, NULL, 0x00000002, NULL, HFILL }},
3636 { &hf_l2tp_avp_digital_bearer_type, { "Digital Bearer Type", "l2tp.avp.digital_bearer_type", FT_BOOLEAN, 32, NULL, 0x00000001, NULL, HFILL }},
3637 { &hf_l2tp_avp_async_framing_type, { "Async Framing Type", "l2tp.avp.async_framing_type", FT_BOOLEAN, 32, NULL, 0x00000002, NULL, HFILL }},
3638 { &hf_l2tp_avp_sync_framing_type, { "Sync Framing Type", "l2tp.avp.sync_framing_type", FT_BOOLEAN, 32, NULL, 0x00000001, NULL, HFILL }},
3639 { &hf_l2tp_avp_sub_address, { "Sub-Address", "l2tp.avp.sub_address", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3640 { &hf_l2tp_avp_connect_speed, { "Connect Speed", "l2tp.avp.connect_speed", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3641 { &hf_l2tp_avp_physical_channel, { "Physical Channel", "l2tp.avp.physical_channel", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3642 { &hf_l2tp_avp_initial_received_lcp_confreq, { "Initial Received LCP CONFREQ", "l2tp.avp.initial_received_lcp_confreq", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3643 { &hf_l2tp_avp_last_sent_lcp_confreq, { "Last Sent LCP CONFREQ", "l2tp.avp.last_sent_lcp_confreq", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3644 { &hf_l2tp_avp_last_received_lcp_confreq, { "Last Received LCP CONFREQ", "l2tp.avp.last_received_lcp_confreq", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3645 { &hf_l2tp_avp_proxy_authen_type, { "Proxy Authen Type", "l2tp.avp.proxy_authen_type", FT_UINT16, BASE_DEC, VALS(authen_type_vals), 0x0, NULL, HFILL }},
3646 { &hf_l2tp_avp_proxy_authen_name, { "Proxy Authen Name", "l2tp.avp.proxy_authen_name", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3647 { &hf_l2tp_avp_proxy_authen_challenge, { "Proxy Authen Challenge", "l2tp.avp.proxy_authen_challenge", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3648 { &hf_l2tp_avp_proxy_authen_id, { "Proxy Authen ID", "l2tp.avp.proxy_authen_id", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3649 { &hf_l2tp_avp_proxy_authen_response, { "Proxy Authen Response", "l2tp.avp.proxy_authen_response", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3650 { &hf_l2tp_avp_crc_errors, { "CRC Errors", "l2tp.avp.crc_errors", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3651 { &hf_l2tp_avp_framing_errors, { "Framing Errors", "l2tp.avp.framing_errors", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3652 { &hf_l2tp_avp_hardware_overruns, { "Hardware Overruns", "l2tp.avp.hardware_overruns", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3653 { &hf_l2tp_avp_buffer_overruns, { "Buffer Overruns", "l2tp.avp.buffer_overruns", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3654 { &hf_l2tp_avp_time_out_errors, { "Time-out Errors", "l2tp.avp.time_out_errors", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3655 { &hf_l2tp_avp_alignment_errors, { "Alignment Errors", "l2tp.avp.alignment_errors", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3656 { &hf_l2tp_avp_send_accm, { "Send ACCM", "l2tp.avp.send_accm", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3657 { &hf_l2tp_avp_receive_accm, { "Receive ACCM", "l2tp.avp.receive_accm", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3658 { &hf_l2tp_avp_random_vector, { "Random Vector", "l2tp.avp.random_vector", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3659 { &hf_l2tp_avp_private_group_id, { "Private Group ID", "l2tp.avp.private_group_id", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3660 { &hf_l2tp_avp_rx_connect_speed, { "Rx Connect Speed", "l2tp.avp.rx_connect_speed", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3661 { &hf_l2tp_avp_disconnect_code, { "Disconnect Code", "l2tp.avp.disconnect_code", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3662 { &hf_l2tp_avp_control_protocol_number, { "Control Protocol Number", "l2tp.avp.control_protocol_number", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3663 { &hf_l2tp_avp_cause_code_direction, { "Direction", "l2tp.avp.cause_code_direction", FT_UINT8, BASE_DEC, VALS(cause_code_direction_vals), 0x0, NULL, HFILL }},
3664 { &hf_l2tp_avp_cause_code_message, { "Message", "l2tp.avp.cause_code_message", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3665 { &hf_l2tp_avp_message_digest, { "Message Digest", "l2tp.avp.message_digest", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3666 { &hf_l2tp_avp_router_id, { "Router ID", "l2tp.avp.router_id", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3667 { &hf_l2tp_avp_pw_type, { "PW Type", "l2tp.avp.pw_type", FT_UINT16, BASE_DEC, VALS(pw_types_vals), 0x0, NULL, HFILL }},
3668 { &hf_l2tp_avp_assigned_cookie, { "Assigned Cookie", "l2tp.avp.assigned_cookie", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3669 { &hf_l2tp_avp_remote_end_id, { "Remote End ID", "l2tp.avp.remote_end_id", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3670 { &hf_l2tp_avp_pseudowire_type, { "Pseudowire Type", "l2tp.avp.pseudowire_type", FT_UINT16, BASE_DEC, VALS(pw_types_vals), 0x0, NULL, HFILL }},
3671 { &hf_l2tp_avp_layer2_specific_sublayer, { "Layer2 Specific Sublayer", "l2tp.avp.layer2_specific_sublayer", FT_UINT16, BASE_DEC, VALS(l2_sublayer_vals), 0x0, NULL, HFILL }},
3672 { &hf_l2tp_avp_data_sequencing, { "Data Sequencing", "l2tp.avp.data_sequencing", FT_UINT16, BASE_DEC, VALS(data_sequencing_vals), 0x0, NULL, HFILL }},
3673 { &hf_l2tp_avp_circuit_status, { "Circuit Status", "l2tp.avp.circuit_status", FT_BOOLEAN, 16, TFS(&tfs_up_down), 0x0001, NULL, HFILL }},
3674 { &hf_l2tp_avp_circuit_type, { "Circuit Type", "l2tp.avp.circuit_type", FT_BOOLEAN, 16, TFS(&tfs_new_existing), 0x0002, NULL, HFILL }},
3675 { &hf_l2tp_avp_preferred_language, { "Preferred Language", "l2tp.avp.preferred_language", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3676 { &hf_l2tp_avp_nonce, { "Nonce", "l2tp.avp.nonce", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3677 { &hf_l2tp_avp_tx_connect_speed_v3, { "Tx Connect Speed v3", "l2tp.avp.tx_connect_speed_v3", FT_UINT64, BASE_HEX|BASE_VAL64_STRING|BASE_SPECIAL_VALS, VALS64(unique_indeterminable_or_no_link), 0x0, NULL, HFILL }},
3678 { &hf_l2tp_avp_rx_connect_speed_v3, { "Rx Connect Speed v3", "l2tp.avp.rx_connect_speed_v3", FT_UINT64, BASE_HEX|BASE_VAL64_STRING|BASE_SPECIAL_VALS, VALS64(unique_indeterminable_or_no_link), 0x0, NULL, HFILL }},
3679 { &hf_l2tp_lapd_info, { "LAPD info", "l2tp.lapd_info", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3680 { &hf_l2tp_zero_length_body_message, { "Zero Length Body message", "l2tp.zero_length_body_message", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3681 { &hf_l2tp_offset_padding, { "Offset Padding", "l2tp.offset_padding", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3684 static int *ett[] = {
3685 &ett_l2tp,
3686 &ett_l2tp_flags,
3687 &ett_l2tp_avp,
3688 &ett_l2tp_avp_sub,
3689 &ett_l2tp_ale_sub,
3690 &ett_l2tp_l2_spec,
3691 &ett_l2tp_lcp,
3692 &ett_l2tp_csu,
3693 &ett_l2tp_ericsson_tcg,
3694 &ett_l2tp_ericsson_map,
3697 static ei_register_info ei[] = {
3698 { &ei_l2tp_incorrect_digest, { "l2tp.incorrect_digest", PI_CHECKSUM, PI_WARN, "Incorrect Digest", EXPFILL }},
3699 /* Generated from convert_proto_tree_add_text.pl */
3700 { &ei_l2tp_vendor_specific_avp_data, { "l2tp.vendor_specific_avp_data", PI_UNDECODED, PI_WARN, "Vendor-Specific AVP data", EXPFILL }},
3701 { &ei_l2tp_avp_length, { "l2tp.avp_length.bad", PI_MALFORMED, PI_ERROR, "Bad AVP length", EXPFILL }},
3704 module_t *l2tp_module;
3705 expert_module_t* expert_l2tp;
3707 /* Decode As handling */
3708 static build_valid_func l2tp_da_build_value[1] = {l2tp_value};
3709 static decode_as_value_t l2tp_da_values = {l2tp_prompt, 1, l2tp_da_build_value};
3710 static decode_as_t l2tp_da = {"l2tp", "l2tp.pw_type", 1, 0, &l2tp_da_values, NULL, NULL,
3711 decode_as_default_populate_list, decode_as_default_reset, decode_as_default_change, NULL};
3713 proto_l2tp = proto_register_protocol("Layer 2 Tunneling Protocol", "L2TP", "l2tp");
3714 l2tp_udp_handle = register_dissector("lt2p_udp", dissect_l2tp_udp, proto_l2tp);
3715 l2tp_ip_handle = register_dissector("l2tp_ip", dissect_l2tp_ip, proto_l2tp);
3716 atm_oam_llc_handle = register_dissector("atm_oam_llc", dissect_atm_oam_llc, proto_l2tp );
3717 proto_register_field_array(proto_l2tp, hf, array_length(hf));
3718 proto_register_subtree_array(ett, array_length(ett));
3719 expert_l2tp = expert_register_protocol(proto_l2tp);
3720 expert_register_field_array(expert_l2tp, ei, array_length(ei));
3722 l2tp_vendor_avp_dissector_table = register_dissector_table("l2tp.vendor_avp", "L2TP vendor AVP dissector table", proto_l2tp, FT_UINT32, BASE_DEC);
3723 pw_type_table = register_dissector_table("l2tp.pw_type", "L2TPv3 pseudowire type", proto_l2tp, FT_UINT32, BASE_DEC);
3725 l2tp_module = prefs_register_protocol(proto_l2tp, NULL);
3727 prefs_register_enum_preference(l2tp_module,
3728 "cookie_size",
3729 "L2TPv3 Cookie Size",
3730 "L2TPv3 Cookie Size",
3731 &l2tpv3_cookie,
3732 l2tpv3_cookies,
3733 false);
3735 prefs_register_enum_preference(l2tp_module,
3736 "l2_specific",
3737 "L2TPv3 L2-Specific Sublayer",
3738 "L2TPv3 L2-Specific Sublayer",
3739 &l2tpv3_l2_specific,
3740 l2tpv3_l2_specifics,
3741 false);
3743 prefs_register_static_text_preference(l2tp_module, "protocol",
3744 "Dissection of pseudowire types is configured through \"Decode As\". "
3745 "Type 0 is used for sessions with unknown pseudowire type.",
3746 "Pseudowire Type \"Decode As\" instructions");
3748 prefs_register_string_preference(l2tp_module,"shared_secret","Shared Secret",
3749 "Shared secret used for control message digest authentication",
3750 &shared_secret);
3752 register_cleanup_routine(l2tp_cleanup);
3753 register_decode_as(&l2tp_da);
3756 void
3757 proto_reg_handoff_l2tp(void)
3759 dissector_add_uint_with_preference("udp.port", UDP_PORT_L2TP, l2tp_udp_handle);
3760 dissector_add_uint("ip.proto", IP_PROTO_L2TP, l2tp_ip_handle);
3763 * Get a handle for the PPP-in-HDLC-like-framing dissector.
3765 ppp_hdlc_handle = find_dissector_add_dependency("ppp_hdlc", proto_l2tp);
3766 ppp_lcp_options_handle = find_dissector_add_dependency("ppp_lcp_options", proto_l2tp);
3768 /* Register vendor AVP dissector(s)*/
3769 dissector_add_uint("l2tp.vendor_avp", VENDOR_CABLELABS, create_dissector_handle(dissect_l2tp_vnd_cablelabs_avps, proto_l2tp));
3773 * Get a handle for the dissectors used in v3.
3775 atm_oam_handle = find_dissector_add_dependency("atm_oam_cell", proto_l2tp);
3776 llc_handle = find_dissector_add_dependency("llc", proto_l2tp);
3778 dissector_add_uint("l2tp.pw_type", L2TPv3_PW_AAL5, atm_oam_llc_handle);
3781 * XXX: Should we register something (Ethernet?) to L2TPv3_PW_DEFAULT?
3782 * The user could always change it with Decode As.
3787 * Editor modelines - https://www.wireshark.org/tools/modelines.html
3789 * Local variables:
3790 * c-basic-offset: 4
3791 * tab-width: 8
3792 * indent-tabs-mode: nil
3793 * End:
3795 * vi: set shiftwidth=4 tabstop=8 expandtab:
3796 * :indentSize=4:tabSize=8:noTabs=true: