52
52
static int hf_amr_toc_f = -1;
53
53
static int hf_amr_toc_ft = -1;
54
54
static int hf_amr_toc_q = -1;
55
static int hf_amr_toc_f_unaligned1 = -1;
56
static int hf_amr_toc_ft_unaligned1 = -1;
57
static int hf_amr_toc_q_unaligned1 = -1;
58
static int hf_amr_toc_f_unaligned2 = -1;
59
static int hf_amr_toc_ft_unaligned2 = -1;
60
static int hf_amr_toc_q_unaligned2 = -1;
62
56
static int hf_amr_if1_ft = -1;
63
57
static int hf_amr_if1_fqi = -1;
182
181
col_append_fstr(pinfo->cinfo, COL_INFO, "%s ",
183
182
val_to_str(octet, amr_codec_mode_request_vals, "Unknown (%d)" ));
185
* 4.3.5.1. Single Channel Payload Carrying a Single Frame
187
* The following diagram shows a bandwidth-efficient AMR payload from a
188
* single channel session carrying a single speech frame-block.
190
* In the payload, no specific mode is requested (CMR=15), the speech
191
* frame is not damaged at the IP origin (Q=1), and the coding mode is
192
* AMR 7.4 kbps (FT=4). The encoded speech bits, d(0) to d(147), are
193
* arranged in descending sensitivity order according to [2]. Finally,
194
* two zero bits are added to the end as padding to make the payload
198
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
199
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
200
* | CMR=15|0| FT=4 |1|d(0) |
201
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
204
dissect_amr_be(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree){
209
proto_tree_add_item(tree, hf_amr_cmr, tvb, offset, 1, FALSE);
210
proto_tree_add_item(tree, hf_amr_be_reserved, tvb, offset, 1, FALSE);
211
octet = tvb_get_guint8(tvb,offset) & 0x08;
213
item = proto_tree_add_text(tree, tvb, offset, -1, "Reserved != 0, wrongly encoded or not bandwidth-efficient.");
214
PROTO_ITEM_SET_GENERATED(item);
217
proto_tree_add_item(tree, hf_amr_be_ft, tvb, offset, 2, FALSE);
218
proto_tree_add_item(tree, hf_amr_be_reserved2, tvb, offset, 2, FALSE);
220
octet = tvb_get_guint8(tvb,offset) & 0x40;
221
if ( octet != 0x40 ){
222
item = proto_tree_add_text(tree, tvb, offset, -1, "Reserved != 1, wrongly encoded or not bandwidth-efficient.");
223
PROTO_ITEM_SET_GENERATED(item);
186
228
/* Code to actually dissect the packets */
188
230
dissect_amr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
208
250
proto_tree_add_text(amr_tree, tvb, offset, -1, "Payload decoded as %s",val_to_str(amr_encoding_type, amr_encoding_type_value, "Unknown value - Error"));
210
252
switch (amr_encoding_type){
253
case 0: /* RFC 3267 Byte aligned */
255
case 1: /* RFC 3267 Bandwidth-efficient */
256
dissect_amr_be(tvb, pinfo, amr_tree);
214
258
case 2: /* AMR IF1 */
215
259
dissect_amr_if1(tvb, pinfo, amr_tree);
228
272
if ( octet != 0 ){
229
273
item = proto_tree_add_text(amr_tree, tvb, offset, -1, "Reserved != 0, wrongly encoded or not octet aligned. Decoding as bandwidth-efficient mode");
230
274
PROTO_ITEM_SET_GENERATED(item);
231
if (!tvb_length_remaining(tvb,offset))
239
toc_item = proto_tree_add_text(amr_tree, tvb, offset, -1, "Payload Table of Contents");
240
toc_tree = proto_item_add_subtree(toc_item, ett_amr_toc);
242
proto_tree_add_item(amr_tree, hf_amr_toc_f_unaligned1, tvb, offset, 2, FALSE);
243
proto_tree_add_item(amr_tree, hf_amr_toc_ft_unaligned1, tvb, offset, 2, FALSE);
244
proto_tree_add_item(amr_tree, hf_amr_toc_q_unaligned1, tvb, offset, 2, FALSE);
247
octet = tvb_get_guint8(tvb,offset+1);
248
proto_tree_add_item(amr_tree, hf_amr_toc_f_unaligned2, tvb, offset, 2, FALSE);
249
proto_tree_add_item(amr_tree, hf_amr_toc_ft_unaligned2, tvb, offset, 2, FALSE);
250
proto_tree_add_item(amr_tree, hf_amr_toc_q_unaligned2, tvb, offset, 2, FALSE);
256
279
proto_tree_add_item(amr_tree, hf_amr_reserved, tvb, offset, 1, FALSE);
258
281
toc_offset = offset;
259
/* If interleaced ILL and ILP follows here */
261
/* Payload Table of Contents
262
* A ToC entry takes the following format in octet-aligned mode:
283
* A ToC entry takes the following format in octet-aligned mode:
290
* F (1 bit): see definition in Section 4.3.2.
292
* FT (4 bits unsigned integer): see definition in Section 4.3.2.
294
* Q (1 bit): see definition in Section 4.3.2.
296
* P bits: padding bits, MUST be set to zero.
269
298
octet = tvb_get_guint8(tvb,offset);
270
299
toc_item = proto_tree_add_text(amr_tree, tvb, offset, -1, "Payload Table of Contents");
344
373
{ &hf_amr_toc_ft,
345
374
{ "FT bits", "amr.toc.ft",
346
375
FT_UINT8, BASE_DEC, VALS(amr_codec_mode_request_vals), 0x78,
376
"Frame type index", HFILL }
350
379
{ "Q bit", "amr.toc.q",
351
380
FT_BOOLEAN, 8, TFS(&toc_q_bit_vals), 0x04,
352
381
"Frame quality indicator bit", HFILL }
354
{ &hf_amr_toc_f_unaligned1,
355
{ "F bit", "amr.toc.f.ual1",
356
FT_BOOLEAN, 16, TFS(&toc_f_bit_vals), 0x0800,
359
{ &hf_amr_toc_ft_unaligned1,
360
{ "FT bits", "amr.toc.ft.ual1",
361
FT_UINT16, BASE_DEC, VALS(amr_codec_mode_request_vals), 0x0780,
364
{ &hf_amr_toc_q_unaligned1,
365
{ "Q bit", "amr.toc.ua1.q.ual1",
366
FT_BOOLEAN, 16, TFS(&toc_q_bit_vals), 0x0040,
367
"Frame quality indicator bit", HFILL }
369
{ &hf_amr_toc_f_unaligned2,
370
{ "F bit", "amr.toc.f.ual2",
371
FT_BOOLEAN, 16, TFS(&toc_f_bit_vals), 0x0020,
374
{ &hf_amr_toc_ft_unaligned2,
375
{ "FT bits", "amr.toc.ft.ual2",
376
FT_UINT16, BASE_DEC, VALS(amr_codec_mode_request_vals), 0x001e,
379
{ &hf_amr_toc_q_unaligned2,
380
{ "Q bit", "amr.toc.ua1.q.ual2",
381
FT_BOOLEAN, 16, TFS(&toc_q_bit_vals), 0x00001,
382
"Frame quality indicator bit", HFILL }
384
383
{ &hf_amr_if1_ft,
385
384
{ "Frame Type", "amr.if1.ft",
386
385
FT_UINT8, BASE_DEC, VALS(amr_codec_mode_request_vals), 0xf0,
421
420
FT_BOOLEAN, 8, TFS(&toc_q_bit_vals), 0x08,
422
421
"Frame quality indicator bit", HFILL }
423
{ &hf_amr_be_reserved,
424
{ "Reserved", "amr.be.reserved",
425
FT_UINT8, BASE_DEC, NULL, 0x08,
429
{ "Frame Type", "amr.be.ft",
430
FT_UINT16, BASE_DEC, VALS(amr_codec_mode_request_vals), 0x0780,
431
"Frame Type", HFILL }
433
{ &hf_amr_be_reserved2,
434
{ "Reserved", "amr.be.reserved2",
435
FT_UINT16, BASE_DEC, NULL, 0x0040,
426
440
/* Setup protocol subtree array */
431
445
static enum_val_t encoding_types[] = {
432
{"RFC 3267 Byte aligned", "RFC 3267", 0},
446
{"RFC 3267 Byte aligned", "RFC 3267 octet aligned", 0},
447
{"RFC 3267 Bandwidth-efficient", "RFC 3267 BW-efficient", 1},
433
448
{"AMR IF1", "AMR IF1", 2},
434
449
{"AMR IF2", "AMR IF2", 3},