2 * Routines for LAPD frame disassembly
3 * Gilbert Ramirez <gram@alumni.rice.edu>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 * LAPD bitstream over RTP handling
27 * Copyright 2008, Ericsson AB
28 * Written by Balint Reczey <balint.reczey@ericsson.com>
30 * ISDN/LAPD references:
32 * http://www.cisco.com/univercd/cc/td/doc/cisintwk/ito_doc/isdn.htm
33 * http://www.ece.wpi.edu/courses/ee535/hwk11cd95/agrebe/agrebe.html
34 * http://www.acacia-net.com/Clarinet/Protocol/q9213o84.htm
35 * http://www.itu.int/rec/T-REC-Q.921/en
36 * Base Station Controller - Base Transceiver Station (BSC - BTS) interface; Layer 2 specification
37 * http://www.3gpp.org/ftp/Specs/html-info/48056.htm
46 #include <epan/packet.h>
47 #include <epan/conversation.h>
48 #include <epan/xdlc.h>
49 #include <epan/crc16-tvb.h>
50 #include <epan/prefs.h>
51 #include <epan/lapd_sapi.h>
53 static int proto_lapd = -1;
54 static int hf_lapd_direction = -1;
55 static int hf_lapd_address = -1;
56 static int hf_lapd_sapi = -1;
57 static int hf_lapd_gsm_sapi = -1;
58 static int hf_lapd_cr = -1;
59 static int hf_lapd_ea1 = -1;
60 static int hf_lapd_tei = -1;
61 static int hf_lapd_ea2 = -1;
62 static int hf_lapd_control = -1;
63 static int hf_lapd_n_r = -1;
64 static int hf_lapd_n_s = -1;
65 static int hf_lapd_p = -1;
66 static int hf_lapd_p_ext = -1;
67 static int hf_lapd_f = -1;
68 static int hf_lapd_f_ext = -1;
69 static int hf_lapd_s_ftype = -1;
70 static int hf_lapd_u_modifier_cmd = -1;
71 static int hf_lapd_u_modifier_resp = -1;
72 static int hf_lapd_ftype_i = -1;
73 static int hf_lapd_ftype_s_u = -1;
74 static int hf_lapd_ftype_s_u_ext = -1;
75 static int hf_lapd_checksum = -1;
76 static int hf_lapd_checksum_good = -1;
77 static int hf_lapd_checksum_bad = -1;
79 static gint ett_lapd = -1;
80 static gint ett_lapd_address = -1;
81 static gint ett_lapd_control = -1;
82 static gint ett_lapd_checksum = -1;
83 static gint pref_lapd_rtp_payload_type = 0;
85 static dissector_table_t lapd_sapi_dissector_table;
86 static dissector_table_t lapd_gsm_sapi_dissector_table;
88 /* Whether to use GSM SAPI vals or not */
89 static gboolean global_lapd_gsm_sapis = FALSE;
91 static dissector_handle_t data_handle;
94 * Bits in the address field.
96 #define LAPD_SAPI 0xfc00 /* Service Access Point Identifier */
97 #define LAPD_SAPI_SHIFT 10
98 #define LAPD_CR 0x0200 /* Command/Response bit */
99 #define LAPD_EA1 0x0100 /* First Address Extension bit */
100 #define LAPD_TEI 0x00fe /* Terminal Endpoint Identifier */
101 #define LAPD_TEI_SHIFT 1
102 #define LAPD_EA2 0x0001 /* Second Address Extension bit */
104 static const value_string lapd_direction_vals[] = {
105 { P2P_DIR_RECV, "Network->User"},
106 { P2P_DIR_SENT, "User->Network"},
110 static const value_string lapd_sapi_vals[] = {
111 { LAPD_SAPI_Q931, "Q.931 Call control procedure" },
112 { LAPD_SAPI_PM_Q931, "Packet mode Q.931 Call control procedure" },
113 { LAPD_SAPI_X25, "X.25 Level 3 procedures" },
114 { LAPD_SAPI_L2, "Layer 2 management procedures" },
118 static const value_string lapd_gsm_sapi_vals[] = {
119 { LAPD_GSM_SAPI_RA_SIG_PROC, "Radio signalling procedures" },
120 { LAPD_GSM_SAPI_NOT_USED_1, "(Not used in GSM PLMN)" },
121 { LAPD_GSM_SAPI_NOT_USED_16, "(Not used in GSM PLMN)" },
122 { LAPD_GSM_SAPI_OM_PROC, "Operation and maintenance procedure" },
123 { LAPD_SAPI_L2, "Layer 2 management procedures" },
127 /* Used only for U frames */
128 static const xdlc_cf_items lapd_cf_items = {
134 &hf_lapd_u_modifier_cmd,
135 &hf_lapd_u_modifier_resp,
140 /* Used only for I and S frames */
141 static const xdlc_cf_items lapd_cf_items_ext = {
150 &hf_lapd_ftype_s_u_ext
154 /* LAPD frame detection state */
155 enum lapd_bitstream_states {OUT_OF_SYNC, FLAGS, DATA};
157 typedef struct lapd_byte_state {
158 enum lapd_bitstream_states state; /* frame detection state */
159 char full_byte; /* part of a full byte */
160 char bit_offset; /* number of bits already got in the full byte */
161 int ones; /* number of consecutive ones since the last zero */
164 typedef struct lapd_ppi {
165 gboolean has_crc; /* CRC is captured with LAPD the frames */
166 lapd_byte_state_t start_byte_state; /* LAPD bitstream byte state at the beginnigng of processing the packet */
169 /* Fill values in lapd_byte_state struct */
171 fill_lapd_byte_state(lapd_byte_state_t *ptr, enum lapd_bitstream_states state, char full_byte, char bit_offset, int ones)
174 ptr->full_byte = full_byte;
175 ptr->bit_offset = bit_offset;
179 typedef struct lapd_convo_data {
184 lapd_byte_state_t *byte_state_a;
185 lapd_byte_state_t *byte_state_b;
188 #define MAX_LAPD_PACKET_LEN 1024
191 dissect_lapd(tvbuff_t*, packet_info*, proto_tree*);
193 /* got new LAPD frame byte */
194 static void new_byte(char full_byte, char data[], int *data_len) {
195 if (*data_len < MAX_LAPD_PACKET_LEN) {
196 data[*data_len] = full_byte;
199 /* XXX : we are not prepared for that big messages, drop the last byte */
204 dissect_lapd_bitstream(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
206 guint8 byte, full_byte = 0x00, bit_offset = 0;
208 guint8 i, ones = 0, data[MAX_LAPD_PACKET_LEN];
210 guint offset = 0, available;
214 enum lapd_bitstream_states state = OUT_OF_SYNC;
215 lapd_ppi_t *lapd_ppi;
216 conversation_t *conversation = NULL;
217 lapd_convo_data_t *convo_data = NULL;
218 lapd_byte_state_t *lapd_byte_state, *prev_byte_state = NULL;
219 gboolean forward_stream = TRUE;
221 /* get remaining data from previous packets */
222 conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst,
223 pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
224 lapd_ppi = (lapd_ppi_t*)p_get_proto_data(pinfo->fd, proto_lapd);
226 prev_byte_state = &lapd_ppi->start_byte_state;
227 if (prev_byte_state) {
228 state = prev_byte_state->state;
229 full_byte = prev_byte_state->full_byte;
230 bit_offset = prev_byte_state->bit_offset;
231 ones = prev_byte_state->ones;
234 } else if (conversation) {
235 convo_data = (lapd_convo_data_t*)conversation_get_proto_data(conversation, proto_lapd);
236 if (NULL != convo_data) {
237 if (ADDRESSES_EQUAL(&convo_data->addr_a, &pinfo->src)
238 && ADDRESSES_EQUAL(&convo_data->addr_b, &pinfo->dst)
239 && convo_data-> port_a == pinfo->srcport
240 && convo_data-> port_b == pinfo->destport) {
241 /* "forward" direction */
242 forward_stream = TRUE;
243 prev_byte_state = convo_data->byte_state_a;
244 } else if (ADDRESSES_EQUAL(&convo_data-> addr_b, &pinfo->src)
245 && ADDRESSES_EQUAL(&convo_data->addr_a, &pinfo->dst)
246 && convo_data-> port_b == pinfo->srcport
247 && convo_data-> port_a == pinfo->destport) {
248 /* "backward" direction */
249 forward_stream = FALSE;
250 prev_byte_state = convo_data->byte_state_b;
253 if (prev_byte_state) {
254 state = prev_byte_state->state;
255 full_byte = prev_byte_state->full_byte;
256 bit_offset = prev_byte_state->bit_offset;
257 ones = prev_byte_state->ones;
261 /* Consume tvb bytes */
262 available = tvb_length_remaining(tvb, offset);
263 while (offset < available) {
264 byte = tvb_get_guint8(tvb,offset);
266 for (i=0; i < 8; i++) { /* cycle through bits */
267 bit = byte & (0x80 >> i) ? TRUE : FALSE;
272 full_byte |= (1 << bit_offset++);
274 if (ones == 5 && state == DATA) {
275 /* we don't increase bit_offset, it is an inserted zero */
276 } else if (ones == 6 && state == DATA) { /* probably starting flag sequence */
277 buff = g_memdup(data, data_len);
278 /* Allocate new tvb for the LAPD frame */
279 new_tvb = tvb_new_child_real_data(tvb, buff, data_len, data_len);
280 tvb_set_free_cb(new_tvb, g_free);
281 add_new_data_source(pinfo, new_tvb, "Decoded LAPD bitstream");
282 dissect_lapd(new_tvb, pinfo, tree);
286 } else if (ones >= 7) { /* frame reset or 11111111 flag byte */
296 if (bit_offset == 8) { /* we have a new complete byte */
299 if (full_byte == 0x7E) { /* we have a flag byte */
303 } else { /* no sync yet, wait for a new byte */
304 full_byte = (full_byte >> 1) & 0x7F;
310 if (full_byte == 0x7E) { /* we have a flag byte */
313 } else { /* we got the first data byte */
315 new_byte(full_byte, data, &data_len);
322 /* we got a new data byte */
323 new_byte(full_byte, data, &data_len);
332 if (state == DATA) { /* we are in the middle of an LAPD frame, we need more bytes */
333 pinfo->desegment_offset = 0;
334 pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT;
336 } else { /* finished processing LAPD frame(s) */
337 if (NULL == p_get_proto_data(pinfo->fd, proto_lapd)) {
338 /* Per packet information */
339 lapd_ppi = g_malloc(sizeof(lapd_ppi_t));
340 lapd_ppi->has_crc = TRUE;
342 fill_lapd_byte_state(&lapd_ppi->start_byte_state, prev_byte_state->state,
343 prev_byte_state->full_byte, prev_byte_state->bit_offset,
344 prev_byte_state->ones);
346 fill_lapd_byte_state(&lapd_ppi->start_byte_state, OUT_OF_SYNC, 0x00, 0, 0);
348 p_add_proto_data(pinfo->fd, proto_lapd, lapd_ppi);
351 /* Conversation info*/
354 if (convo_data) { /* already have lapd convo data */
356 fill_lapd_byte_state(convo_data->byte_state_a, state, full_byte, bit_offset, ones);
358 if (!convo_data->byte_state_b)
359 convo_data->byte_state_b = g_malloc(sizeof(lapd_byte_state_t));
360 fill_lapd_byte_state(convo_data->byte_state_b, state, full_byte, bit_offset, ones);
362 } else { /* lapd convo data has to be created */
363 lapd_byte_state = g_malloc(sizeof(lapd_byte_state_t));
364 fill_lapd_byte_state(lapd_byte_state, state, full_byte, bit_offset, ones);
365 convo_data = g_malloc(sizeof(lapd_convo_data_t));
366 COPY_ADDRESS(&convo_data->addr_a, &pinfo->src);
367 COPY_ADDRESS(&convo_data->addr_b, &pinfo->dst);
368 convo_data->port_a = pinfo->srcport;
369 convo_data->port_b = pinfo->destport;
370 convo_data->byte_state_a = lapd_byte_state;
371 convo_data->byte_state_b = NULL;
372 conversation_add_proto_data(conversation, proto_lapd, convo_data);
381 dissect_lapd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
383 proto_tree *lapd_tree, *addr_tree, *checksum_tree;
384 proto_item *lapd_ti, *addr_ti, *checksum_ti;
386 guint16 control, checksum, checksum_calculated;
387 int lapd_header_len, checksum_offset;
388 guint16 addr, cr, sapi, tei;
389 gboolean is_response = 0;
391 const char *srcname = "?";
392 const char *dstname = "?";
394 col_set_str(pinfo->cinfo, COL_PROTOCOL, "LAPD");
395 col_clear(pinfo->cinfo, COL_INFO);
397 addr = tvb_get_ntohs(tvb, 0);
399 tei = (addr & LAPD_TEI) >> LAPD_TEI_SHIFT;
400 sapi = (addr & LAPD_SAPI) >> LAPD_SAPI_SHIFT;
401 lapd_header_len = 2; /* addr */
403 if (check_col(pinfo->cinfo, COL_TEI))
404 col_add_fstr(pinfo->cinfo, COL_TEI, "%u", tei);
406 if (pinfo->fd->lnk_t == WTAP_ENCAP_LINUX_LAPD) {
407 /* frame is captured via libpcap */
408 if (pinfo->pseudo_header->lapd.pkttype == 4 /*PACKET_OUTGOING*/) {
409 if (pinfo->pseudo_header->lapd.we_network) {
410 is_response = cr ? FALSE : TRUE;
411 srcname = "Local Network";
412 dstname = "Remote User";
413 direction = P2P_DIR_RECV; /* Network->User */
415 srcname = "Local User";
416 dstname = "Remote Network";
417 direction = P2P_DIR_SENT; /* User->Network */
420 else if (pinfo->pseudo_header->lapd.pkttype == 3 /*PACKET_OTHERHOST*/) {
421 /* We must be a TE, sniffing what other TE transmit */
423 is_response = cr ? TRUE : FALSE;
424 srcname = "Remote User";
425 dstname = "Remote Network";
426 direction = P2P_DIR_SENT; /* User->Network */
429 /* The frame is incoming */
430 if (pinfo->pseudo_header->lapd.we_network) {
431 is_response = cr ? TRUE : FALSE;
432 srcname = "Remote User";
433 dstname = "Local Network";
434 direction = P2P_DIR_SENT; /* User->Network */
436 is_response = cr ? FALSE : TRUE;
437 srcname = "Remote Network";
438 dstname = "Local User";
439 direction = P2P_DIR_RECV; /* Network->User */
443 direction = pinfo->p2p_dir;
444 if (pinfo->p2p_dir == P2P_DIR_RECV) {
445 is_response = cr ? FALSE : TRUE;
449 else if (pinfo->p2p_dir == P2P_DIR_SENT) {
450 is_response = cr ? TRUE : FALSE;
456 col_set_str(pinfo->cinfo, COL_RES_DL_SRC, srcname);
457 col_set_str(pinfo->cinfo, COL_RES_DL_DST, dstname);
460 proto_item *direction_ti;
462 lapd_ti = proto_tree_add_item(tree, proto_lapd, tvb, 0, -1,
464 lapd_tree = proto_item_add_subtree(lapd_ti, ett_lapd);
467 * Don't show the direction if we don't know it.
469 if (direction != P2P_DIR_UNKNOWN) {
470 direction_ti = proto_tree_add_uint(lapd_tree, hf_lapd_direction,
471 tvb, 0, 0, pinfo->p2p_dir);
472 PROTO_ITEM_SET_GENERATED(direction_ti);
475 addr_ti = proto_tree_add_uint(lapd_tree, hf_lapd_address, tvb,
477 addr_tree = proto_item_add_subtree(addr_ti, ett_lapd_address);
479 if(global_lapd_gsm_sapis){
480 proto_tree_add_uint(addr_tree, hf_lapd_gsm_sapi,tvb, 0, 1, addr);
482 proto_tree_add_uint(addr_tree, hf_lapd_sapi,tvb, 0, 1, addr);
484 proto_tree_add_uint(addr_tree, hf_lapd_cr, tvb, 0, 1, addr);
485 proto_tree_add_uint(addr_tree, hf_lapd_ea1, tvb, 0, 1, addr);
486 proto_tree_add_uint(addr_tree, hf_lapd_tei, tvb, 1, 1, addr);
487 proto_tree_add_uint(addr_tree, hf_lapd_ea2, tvb, 1, 1, addr);
494 control = dissect_xdlc_control(tvb, 2, pinfo, lapd_tree, hf_lapd_control,
495 ett_lapd_control, &lapd_cf_items, &lapd_cf_items_ext, NULL, NULL,
496 is_response, TRUE, FALSE);
497 lapd_header_len += XDLC_CONTROL_LEN(control, TRUE);
500 proto_item_set_len(lapd_ti, lapd_header_len);
502 if (NULL != p_get_proto_data(pinfo->fd, proto_lapd)
503 && ((lapd_ppi_t*)p_get_proto_data(pinfo->fd, proto_lapd))->has_crc) {
506 checksum_offset = tvb_length(tvb) - 2;
507 checksum = tvb_get_guint8(tvb, checksum_offset); /* high byte */
509 checksum |= tvb_get_guint8(tvb, checksum_offset+1) & 0x00FF; /* low byte */
510 checksum_calculated = g_htons(crc16_ccitt_tvb(tvb, tvb_length(tvb) - 2));
512 if (checksum == checksum_calculated) {
513 checksum_ti = proto_tree_add_uint_format(lapd_tree, hf_lapd_checksum, tvb, checksum_offset, 2, 0,"Checksum: 0x%04x [correct]", checksum);
514 checksum_tree = proto_item_add_subtree(checksum_ti, ett_lapd_checksum);
515 proto_tree_add_boolean(checksum_tree, hf_lapd_checksum_good, tvb, checksum_offset, 2, TRUE);
516 proto_tree_add_boolean(checksum_tree, hf_lapd_checksum_bad, tvb, checksum_offset, 2, FALSE);
518 checksum_ti = proto_tree_add_uint_format(lapd_tree, hf_lapd_checksum, tvb, checksum_offset, 2, 0,"Checksum: 0x%04x [incorrect, should be 0x%04x]", checksum, checksum_calculated);
519 checksum_tree = proto_item_add_subtree(checksum_ti, ett_lapd_checksum);
520 proto_tree_add_boolean(checksum_tree, hf_lapd_checksum_good, tvb, checksum_offset, 2, FALSE);
521 proto_tree_add_boolean(checksum_tree, hf_lapd_checksum_bad, tvb, checksum_offset, 2, TRUE);
524 next_tvb = tvb_new_subset(tvb, lapd_header_len, tvb_length_remaining(tvb,lapd_header_len) - 2, -1);
527 next_tvb = tvb_new_subset_remaining(tvb, lapd_header_len);
529 if (XDLC_IS_INFORMATION(control)) {
530 /* call next protocol */
531 if(global_lapd_gsm_sapis){
532 if (!dissector_try_uint(lapd_gsm_sapi_dissector_table, sapi,
533 next_tvb, pinfo, tree))
534 call_dissector(data_handle,next_tvb, pinfo, tree);
536 if (!dissector_try_uint(lapd_sapi_dissector_table, sapi,
537 next_tvb, pinfo, tree))
538 call_dissector(data_handle,next_tvb, pinfo, tree);
541 call_dissector(data_handle,next_tvb, pinfo, tree);
545 proto_reg_handoff_lapd(void);
548 proto_register_lapd(void)
550 static hf_register_info hf[] = {
552 { &hf_lapd_direction,
553 { "Direction", "lapd.direction", FT_UINT8, BASE_DEC, VALS(lapd_direction_vals), 0x0,
557 { "Address Field", "lapd.address", FT_UINT16, BASE_HEX, NULL, 0x0,
561 { "SAPI", "lapd.sapi", FT_UINT16, BASE_DEC, VALS(lapd_sapi_vals), LAPD_SAPI,
562 "Service Access Point Identifier", HFILL }},
565 { "SAPI", "lapd.sapi", FT_UINT16, BASE_DEC, VALS(lapd_gsm_sapi_vals), LAPD_SAPI,
566 "Service Access Point Identifier", HFILL }},
569 { "C/R", "lapd.cr", FT_UINT16, BASE_DEC, NULL, LAPD_CR,
570 "Command/Response bit", HFILL }},
573 { "EA1", "lapd.ea1", FT_UINT16, BASE_DEC, NULL, LAPD_EA1,
574 "First Address Extension bit", HFILL }},
577 { "TEI", "lapd.tei", FT_UINT16, BASE_DEC, NULL, LAPD_TEI,
578 "Terminal Endpoint Identifier", HFILL }},
581 { "EA2", "lapd.ea2", FT_UINT16, BASE_DEC, NULL, LAPD_EA2,
582 "Second Address Extension bit", HFILL }},
585 { "Control Field", "lapd.control", FT_UINT16, BASE_HEX, NULL, 0x0,
589 { "N(R)", "lapd.control.n_r", FT_UINT16, BASE_DEC,
590 NULL, XDLC_N_R_EXT_MASK, NULL, HFILL }},
593 { "N(S)", "lapd.control.n_s", FT_UINT16, BASE_DEC,
594 NULL, XDLC_N_S_EXT_MASK, NULL, HFILL }},
597 { "Poll", "lapd.control.p", FT_BOOLEAN, 8,
598 TFS(&tfs_set_notset), XDLC_P_F, NULL, HFILL }},
601 { "Poll", "lapd.control.p", FT_BOOLEAN, 16,
602 TFS(&tfs_set_notset), XDLC_P_F_EXT, NULL, HFILL }},
605 { "Final", "lapd.control.f", FT_BOOLEAN, 8,
606 TFS(&tfs_set_notset), XDLC_P_F, NULL, HFILL }},
609 { "Final", "lapd.control.f", FT_BOOLEAN, 16,
610 TFS(&tfs_set_notset), XDLC_P_F_EXT, NULL, HFILL }},
613 { "Supervisory frame type", "lapd.control.s_ftype", FT_UINT16, BASE_HEX,
614 VALS(stype_vals), XDLC_S_FTYPE_MASK, NULL, HFILL }},
616 { &hf_lapd_u_modifier_cmd,
617 { "Command", "lapd.control.u_modifier_cmd", FT_UINT8, BASE_HEX,
618 VALS(modifier_vals_cmd), XDLC_U_MODIFIER_MASK, NULL, HFILL }},
620 { &hf_lapd_u_modifier_resp,
621 { "Response", "lapd.control.u_modifier_resp", FT_UINT8, BASE_HEX,
622 VALS(modifier_vals_resp), XDLC_U_MODIFIER_MASK, NULL, HFILL }},
625 { "Frame type", "lapd.control.ftype", FT_UINT16, BASE_HEX,
626 VALS(ftype_vals), XDLC_I_MASK, NULL, HFILL }},
628 { &hf_lapd_ftype_s_u,
629 { "Frame type", "lapd.control.ftype", FT_UINT8, BASE_HEX,
630 VALS(ftype_vals), XDLC_S_U_MASK, NULL, HFILL }},
632 { &hf_lapd_ftype_s_u_ext,
633 { "Frame type", "lapd.control.ftype", FT_UINT16, BASE_HEX,
634 VALS(ftype_vals), XDLC_S_U_MASK, NULL, HFILL }},
637 { "Checksum", "lapd.checksum", FT_UINT16, BASE_HEX,
638 NULL, 0x0, "Details at: http://www.wireshark.org/docs/wsug_html_chunked/ChAdvChecksums.html", HFILL }},
640 { &hf_lapd_checksum_good,
641 { "Good Checksum", "lapd.checksum_good", FT_BOOLEAN, BASE_NONE,
642 NULL, 0x0, "True: checksum matches packet content; False: doesn't match content or not checked", HFILL }},
644 { &hf_lapd_checksum_bad,
645 { "Bad Checksum", "lapd.checksum_bad", FT_BOOLEAN, BASE_NONE,
646 NULL, 0x0, "True: checksum doesn't match packet content; False: matches content or not checked", HFILL }}
649 static gint *ett[] = {
656 module_t *lapd_module;
658 proto_lapd = proto_register_protocol("Link Access Procedure, Channel D (LAPD)",
660 proto_register_field_array (proto_lapd, hf, array_length(hf));
661 proto_register_subtree_array(ett, array_length(ett));
663 register_dissector("lapd", dissect_lapd, proto_lapd);
665 lapd_sapi_dissector_table = register_dissector_table("lapd.sapi",
666 "LAPD SAPI", FT_UINT16, BASE_DEC);
668 lapd_gsm_sapi_dissector_table = register_dissector_table("lapd.gsm.sapi",
669 "LAPD GSM SAPI", FT_UINT16, BASE_DEC);
671 lapd_module = prefs_register_protocol(proto_lapd, proto_reg_handoff_lapd);
673 prefs_register_bool_preference(lapd_module, "use_gsm_sapi_values",
674 "Use GSM SAPI values",
675 "Use SAPI values as specified in TS 48 056",
676 &global_lapd_gsm_sapis);
677 prefs_register_uint_preference(lapd_module, "rtp_payload_type",
678 "RTP payload type for embedded LAPD",
679 "RTP payload type for embedded LAPD. It must be one of the dynamic types "
680 "from 96 to 127. Set it to 0 to disable.",
681 10, &pref_lapd_rtp_payload_type);
686 proto_reg_handoff_lapd(void)
688 static gboolean init = FALSE;
689 static dissector_handle_t lapd_bitstream_handle;
690 static gint lapd_rtp_payload_type;
693 dissector_handle_t lapd_handle;
695 lapd_handle = find_dissector("lapd");
696 dissector_add_uint("wtap_encap", WTAP_ENCAP_LINUX_LAPD, lapd_handle);
697 dissector_add_uint("wtap_encap", WTAP_ENCAP_LAPD, lapd_handle);
699 lapd_bitstream_handle = create_dissector_handle(dissect_lapd_bitstream, proto_lapd);
700 data_handle = find_dissector("data");
704 if ((lapd_rtp_payload_type > 95) && (lapd_rtp_payload_type < 128))
705 dissector_delete_uint("rtp.pt", lapd_rtp_payload_type, lapd_bitstream_handle);
708 lapd_rtp_payload_type = pref_lapd_rtp_payload_type;
709 if ((lapd_rtp_payload_type > 95) && (lapd_rtp_payload_type < 128))
710 dissector_add_uint("rtp.pt", lapd_rtp_payload_type, lapd_bitstream_handle);