/src/wireshark/epan/dissectors/packet-bctp.c
Line | Count | Source |
1 | | /* |
2 | | * packet-bctp.c |
3 | | * Q.1990 BICC bearer control tunnelling protocol |
4 | | * |
5 | | * (c) 2007, Luis E. Garcia Ontanon <luis@ontanon.org> |
6 | | * |
7 | | * Wireshark - Network traffic analyzer |
8 | | * By Gerald Combs <gerald@wireshark.org> |
9 | | * Copyright 1998 Gerald Combs |
10 | | * |
11 | | * SPDX-License-Identifier: GPL-2.0-or-later |
12 | | * |
13 | | * Ref ITU-T Rec. Q.1990 (07/2001) |
14 | | */ |
15 | | |
16 | | #include "config.h" |
17 | | |
18 | | #include <epan/packet.h> |
19 | | |
20 | | void proto_register_bctp(void); |
21 | | void proto_reg_handoff_bctp(void); |
22 | | |
23 | | static int proto_bctp; |
24 | | static int hf_bctp_bvei; |
25 | | static int hf_bctp_bvi; |
26 | | static int hf_bctp_tpei; |
27 | | static int hf_bctp_tpi; |
28 | | |
29 | | static int ett_bctp; |
30 | | static dissector_table_t bctp_dissector_table; |
31 | | static dissector_handle_t text_handle; |
32 | | |
33 | | /* |
34 | | static const range_string tpi_vals[] = { |
35 | | {0x00,0x17,"spare (binary encoded protocols)"}, |
36 | | {0x18,0x1f,"reserved for national use (binary encoded protocols)"}, |
37 | | {0x20,0x20,"IPBCP (text encoded)"}, |
38 | | {0x21,0x21,"spare (text encoded protocol)"}, |
39 | | {0x22,0x22,"not used"}, |
40 | | {0x23,0x37,"spare (text encoded protocols)"}, |
41 | | {0x38,0x3f,"reserved for national use (text encoded protocols)"}, |
42 | | {0,0,NULL} |
43 | | }; |
44 | | */ |
45 | | |
46 | | static const value_string bvei_vals[] = { |
47 | | {0,"No indication"}, |
48 | | {1,"Version Error Indication, BCTP version not supported"}, |
49 | | {0,NULL} |
50 | | }; |
51 | | |
52 | | |
53 | 0 | static int dissect_bctp(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data _U_) { |
54 | 0 | proto_item* pi = proto_tree_add_item(tree, proto_bctp, tvb,0,2, ENC_NA); |
55 | 0 | proto_tree* pt = proto_item_add_subtree(pi,ett_bctp); |
56 | 0 | tvbuff_t* sub_tvb = tvb_new_subset_remaining(tvb, 2); |
57 | 0 | uint8_t tpi = tvb_get_uint8(tvb,1) & 0x3f; |
58 | |
|
59 | 0 | proto_tree_add_item(pt, hf_bctp_bvei, tvb,0,2, ENC_BIG_ENDIAN); |
60 | 0 | proto_tree_add_item(pt, hf_bctp_bvi, tvb,0,2, ENC_BIG_ENDIAN); |
61 | 0 | proto_tree_add_item(pt, hf_bctp_tpei, tvb,0,2, ENC_BIG_ENDIAN); |
62 | 0 | proto_tree_add_item(pt, hf_bctp_tpi, tvb,0,2, ENC_BIG_ENDIAN); |
63 | |
|
64 | 0 | if (!dissector_try_uint(bctp_dissector_table, tpi, sub_tvb, pinfo, tree) ) { |
65 | 0 | if (tpi <= 0x22) { |
66 | 0 | call_data_dissector(sub_tvb, pinfo, tree); |
67 | 0 | } else { |
68 | | /* tpi > 0x22 */ |
69 | 0 | call_dissector(text_handle,sub_tvb, pinfo, tree); |
70 | 0 | } |
71 | 0 | } |
72 | 0 | return tvb_captured_length(tvb); |
73 | 0 | } |
74 | | |
75 | | void |
76 | | proto_register_bctp (void) |
77 | 15 | { |
78 | 15 | static hf_register_info hf[] = { |
79 | 15 | {&hf_bctp_bvei, {"BVEI", "bctp.bvei", FT_UINT16, BASE_HEX, VALS(bvei_vals), 0x4000, "BCTP Version Error Indicator", HFILL }}, |
80 | 15 | {&hf_bctp_bvi, {"BVI", "bctp.bvi", FT_UINT16, BASE_HEX, NULL, 0x1F00, "BCTP Version Indicator", HFILL }}, |
81 | 15 | {&hf_bctp_tpei, {"TPEI", "bctp.tpei", FT_UINT16, BASE_HEX, NULL, 0x0040, "Tunneled Protocol Error Indicator", HFILL }}, |
82 | 15 | {&hf_bctp_tpi, {"TPI", "bctp.tpi", FT_UINT16, BASE_HEX, NULL, 0x003F, "Tunneled Protocol Indicator", HFILL }}, |
83 | 15 | }; |
84 | 15 | static int *ett[] = { |
85 | 15 | &ett_bctp |
86 | 15 | }; |
87 | | |
88 | 15 | proto_bctp = proto_register_protocol("BCTP Q.1990", "BCTP", "bctp"); |
89 | 15 | proto_register_field_array(proto_bctp, hf, array_length(hf)); |
90 | 15 | proto_register_subtree_array(ett, array_length(ett)); |
91 | | |
92 | 15 | register_dissector("bctp", dissect_bctp, proto_bctp); |
93 | | |
94 | 15 | bctp_dissector_table = register_dissector_table("bctp.tpi", "BCTP Tunneled Protocol Indicator", proto_bctp, FT_UINT32, BASE_DEC); |
95 | 15 | } |
96 | | |
97 | | void |
98 | | proto_reg_handoff_bctp(void) |
99 | 15 | { |
100 | 15 | text_handle = find_dissector_add_dependency("data-text-lines", proto_bctp); |
101 | 15 | } |
102 | | |
103 | | /* |
104 | | * Editor modelines - https://www.wireshark.org/tools/modelines.html |
105 | | * |
106 | | * Local variables: |
107 | | * c-basic-offset: 8 |
108 | | * tab-width: 8 |
109 | | * indent-tabs-mode: t |
110 | | * End: |
111 | | * |
112 | | * vi: set shiftwidth=8 tabstop=8 noexpandtab: |
113 | | * :indentSize=8:tabSize=8:noTabs=false: |
114 | | */ |