Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-g723.c
blob74918498e0e539475ae854b96e598ef776d28c86
1 /* packet-g723.c
2 * Routines for G.723 dissection
3 * Copyright 2005, Anders Broman <anders.broman[at]ericsson.com>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
11 * References:
14 #include "config.h"
16 #include <epan/packet.h>
17 #include <epan/rtp_pt.h>
19 void proto_reg_handoff_g723(void);
20 void proto_register_g723(void);
22 static dissector_handle_t g723_handle;
24 /* Initialize the protocol and registered fields */
25 static int proto_g723;
26 static int hf_g723_frame_size_and_codec;
27 static int hf_g723_lpc_B5_B0;
29 /* Initialize the subtree pointers */
30 static int ett_g723;
33 /* RFC 3551
34 The least significant two bits of the first
35 octet in the frame determine the frame size and codec type:
36 bits content octets/frame
37 00 high-rate speech (6.3 kb/s) 24
38 01 low-rate speech (5.3 kb/s) 20
39 10 SID frame 4
40 11 reserved
43 static const value_string g723_frame_size_and_codec_type_value[] = {
44 {0, "High-rate speech (6.3 kb/s)"},
45 {1, "Low-rate speech (5.3 kb/s)"}, /* Not coded */
46 {2, "SID frame"},
47 {3, "Reserved"},
48 { 0, NULL }
52 /* Dissection */
53 static int
54 dissect_g723(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
56 int offset = 0;
57 unsigned octet;
59 proto_item *ti;
60 proto_tree *g723_tree;
62 col_set_str(pinfo->cinfo, COL_PROTOCOL, "G.723.1");
63 if (tree) {
64 ti = proto_tree_add_item(tree, proto_g723, tvb, 0, -1, ENC_NA);
66 g723_tree = proto_item_add_subtree(ti, ett_g723);
68 octet = tvb_get_uint8(tvb,offset);
69 proto_tree_add_item(g723_tree, hf_g723_frame_size_and_codec, tvb, offset, 1, ENC_BIG_ENDIAN);
70 proto_tree_add_item(g723_tree, hf_g723_lpc_B5_B0, tvb, offset, 1, ENC_BIG_ENDIAN);
72 if ((octet & 0x1) == 1 ) /* Low rate */
73 return tvb_captured_length(tvb);
74 }/* if tree */
76 return tvb_captured_length(tvb);
79 void
80 proto_reg_handoff_g723(void)
82 dissector_add_uint("rtp.pt", PT_G723, g723_handle);
86 void
87 proto_register_g723(void)
91 static hf_register_info hf[] = {
92 { &hf_g723_frame_size_and_codec,
93 { "Frame size and codec type", "g723.frame_size_and_codec",
94 FT_UINT8, BASE_HEX, VALS(g723_frame_size_and_codec_type_value), 0x03,
95 "RATEFLAG_B0", HFILL }
97 { &hf_g723_lpc_B5_B0,
98 { "LPC_B5...LPC_B0", "g723.lpc.b5b0",
99 FT_UINT8, BASE_HEX, NULL, 0xfc,
100 NULL, HFILL }
105 static int *ett[] = {
106 &ett_g723,
109 proto_g723 = proto_register_protocol("G.723","G.723", "g723");
111 proto_register_field_array(proto_g723, hf, array_length(hf));
112 proto_register_subtree_array(ett, array_length(ett));
114 g723_handle = register_dissector("g723", dissect_g723, proto_g723);
118 * Editor modelines - https://www.wireshark.org/tools/modelines.html
120 * Local variables:
121 * c-basic-offset: 8
122 * tab-width: 8
123 * indent-tabs-mode: t
124 * End:
126 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
127 * :indentSize=8:tabSize=8:noTabs=false: