]> git.samba.org - metze/wireshark/wip.git/blob - epan/dissectors/packet-g723.c
GSM A DTAP: add UMTS EVS to supported codecs list IE
[metze/wireshark/wip.git] / epan / dissectors / packet-g723.c
1 /* packet-g723.c
2  * Routines for G.723 dissection
3  * Copyright 2005, Anders Broman <anders.broman[at]ericsson.com>
4  *
5  * Wireshark - Network traffic analyzer
6  * By Gerald Combs <gerald@wireshark.org>
7  * Copyright 1998 Gerald Combs
8  *
9  * SPDX-License-Identifier: GPL-2.0-or-later
10  *
11  * References:
12  */
13
14 #include "config.h"
15
16 #include <epan/packet.h>
17 #include <epan/rtp_pt.h>
18
19 void proto_reg_handoff_g723(void);
20 void proto_register_g723(void);
21
22 /* Initialize the protocol and registered fields */
23 static int proto_g723                                   = -1;
24 static int hf_g723_frame_size_and_codec = -1;
25 static int hf_g723_lpc_B5_B0                    = -1;
26
27 /* Initialize the subtree pointers */
28 static int ett_g723 = -1;
29
30
31 /*               RFC 3551
32         The least significant two bits of the first
33         octet in the frame determine the frame size and codec type:
34          bits  content                      octets/frame
35          00    high-rate speech (6.3 kb/s)            24
36          01    low-rate speech  (5.3 kb/s)            20
37          10    SID frame                               4
38          11    reserved
39
40  */
41 static const value_string g723_frame_size_and_codec_type_value[] = {
42         {0,                     "High-rate speech (6.3 kb/s)"},
43         {1,                     "Low-rate speech  (5.3 kb/s)"}, /* Not coded */
44         {2,                     "SID frame"},
45         {3,                     "Reserved"},
46         { 0,    NULL }
47 };
48
49
50 /* Dissection */
51 static int
52 dissect_g723(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
53 {
54         int offset = 0;
55         guint octet;
56
57         proto_item *ti;
58         proto_tree *g723_tree;
59
60         col_set_str(pinfo->cinfo, COL_PROTOCOL, "G.723.1");
61         if (tree) {
62                 ti = proto_tree_add_item(tree, proto_g723, tvb, 0, -1, ENC_NA);
63
64                 g723_tree = proto_item_add_subtree(ti, ett_g723);
65
66                 octet = tvb_get_guint8(tvb,offset);
67                 proto_tree_add_item(g723_tree, hf_g723_frame_size_and_codec, tvb, offset, 1, ENC_BIG_ENDIAN);
68                 proto_tree_add_item(g723_tree, hf_g723_lpc_B5_B0, tvb, offset, 1, ENC_BIG_ENDIAN);
69
70                 if ((octet & 0x1) == 1 ) /* Low rate */
71                         return tvb_captured_length(tvb);
72         }/* if tree */
73
74         return tvb_captured_length(tvb);
75 }
76
77 void
78 proto_reg_handoff_g723(void)
79 {
80         dissector_handle_t g723_handle;
81
82         g723_handle = create_dissector_handle(dissect_g723, proto_g723);
83
84         dissector_add_uint("rtp.pt", PT_G723, g723_handle);
85
86 }
87
88 void
89 proto_register_g723(void)
90 {
91
92
93         static hf_register_info hf[] = {
94                 { &hf_g723_frame_size_and_codec,
95                         { "Frame size and codec type", "g723.frame_size_and_codec",
96                         FT_UINT8, BASE_HEX, VALS(g723_frame_size_and_codec_type_value), 0x03,
97                         "RATEFLAG_B0", HFILL }
98                 },
99                 { &hf_g723_lpc_B5_B0,
100                         { "LPC_B5...LPC_B0",           "g723.lpc.b5b0",
101                         FT_UINT8, BASE_HEX, NULL, 0xfc,
102                         NULL, HFILL }
103                 },
104
105         };
106
107         static gint *ett[] = {
108                 &ett_g723,
109         };
110
111         proto_g723 = proto_register_protocol("G.723","G.723", "g723");
112
113         proto_register_field_array(proto_g723, hf, array_length(hf));
114         proto_register_subtree_array(ett, array_length(ett));
115
116 }
117
118 /*
119  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
120  *
121  * Local variables:
122  * c-basic-offset: 8
123  * tab-width: 8
124  * indent-tabs-mode: t
125  * End:
126  *
127  * vi: set shiftwidth=8 tabstop=8 noexpandtab:
128  * :indentSize=8:tabSize=8:noTabs=false:
129  */