Skip to content

Commit 18ffd52

Browse files
johnthackerAndersBroman
authored andcommitted
RTP: Make Decode As handling consistent across subdissectors
RTP has two dissector tables, one directly associated with payload types, and one which is associated with strings that appear in SDP commands. This makes all dissectors that are registered as a dynamic payload type that can be configured by SDP appear as a Decode As option for the RTP PT table. Some protocols were registered in the table for configuration by SDP but had no way to register with the rtp.pt table. These include EVRC, H.223, and v150fw. Other protocols had a long standing preference to set a dynamic payload type, but they still did not appear in the Decode As menu unless that preference was changed from the default, largely because of the way that the preference was not actually registered with the rtp.pt table unless it had a value in the dynamic payload type range. These include EVS, H.263P, H.264, H.265, ISMACryp, IuUP, LAPD, MP4V-ES, RTP-MIDI, and VP8. RFC 3551 says that not just the dynamic payload types, but also the unassigned and even the statically assigned payload types MAY be dynamically reassigned as necessary, so this patch also allows these preferences to be set for payload types less than 96. The only payload type not allowed is 0 (which RFCs 3551 and 7007 say must be μ-law PCM), which is handy anyone for backwards compatibility with preferences that used to be uints (where 0 meant disabled.) All protcols which formerly used a uint preference are all converted to a range preference, and the text is changed to be similar for each. This works in a backwards compatible fashion, and any defaults are maintained. The patch also adds some of the dissector variants as PINOs so that they will show up with distinct names in the Decode As menus, and changes some of the protocol short names so that the entry in Decode As is clearer and matches what is used for other similar protocols. Change-Id: I68627b5c3e495d9fc813d88208f3b62e47e0c4de Reviewed-on: https://code.wireshark.org/review/37396 Petri-Dish: Alexis La Goutte <[email protected]> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <[email protected]>
1 parent eddfa0f commit 18ffd52

18 files changed

+222
-217
lines changed

epan/dissectors/packet-amr.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ static expert_field ei_amr_padding_bits_correct = EI_INIT;
7979
static expert_field ei_amr_reserved = EI_INIT;
8080

8181
/* The dynamic payload types which will be dissected as AMR */
82-
#define AMR_DEFAULT_DYN_PT_RANGE "0"
8382
static range_t *global_amr_dynamic_payload_types;
8483
static range_t *global_amr_wb_dynamic_payload_types;
8584
static gint amr_encoding_type = 0;
@@ -790,14 +789,14 @@ proto_register_amr(void)
790789

791790
prefs_register_range_preference(amr_module, "dynamic.payload.type",
792791
"AMR dynamic payload types",
793-
"The dynamic payload types which will be interpreted as AMR"
794-
"(default " AMR_DEFAULT_DYN_PT_RANGE ")",
792+
"Dynamic payload types which will be interpreted as AMR"
793+
"; values must be in the range 1 - 127",
795794
&global_amr_dynamic_payload_types, 127);
796795

797796
prefs_register_range_preference(amr_module, "wb.dynamic.payload.type",
798797
"AMR-WB dynamic payload types",
799-
"The dynamic payload types which will be interpreted as AMR-WB"
800-
"(default " AMR_DEFAULT_DYN_PT_RANGE ")",
798+
"Dynamic payload types which will be interpreted as AMR-WB"
799+
"; values must be in the range 1-127",
801800
&global_amr_wb_dynamic_payload_types, 127);
802801

803802
prefs_register_enum_preference(amr_module, "encoding.version",
@@ -853,17 +852,17 @@ proto_reg_handoff_amr(void)
853852
} else {
854853
dissector_delete_uint_range("rtp.pt", amr_dynamic_payload_types, amr_handle);
855854
dissector_delete_uint_range("rtp.pt", amr_wb_dynamic_payload_types, amr_wb_handle);
855+
wmem_free(wmem_epan_scope(), amr_dynamic_payload_types);
856+
wmem_free(wmem_epan_scope(), amr_wb_dynamic_payload_types);
856857
}
857858

858859
amr_dynamic_payload_types = range_copy(wmem_epan_scope(), global_amr_dynamic_payload_types);
859860
amr_wb_dynamic_payload_types = range_copy(wmem_epan_scope(), global_amr_wb_dynamic_payload_types);
860861

861-
if(!value_is_in_range(amr_dynamic_payload_types, 0)){
862-
dissector_add_uint_range("rtp.pt", amr_dynamic_payload_types, amr_handle);
863-
}
864-
if (!value_is_in_range(amr_wb_dynamic_payload_types, 0)) {
865-
dissector_add_uint_range("rtp.pt", amr_wb_dynamic_payload_types, amr_wb_handle);
866-
}
862+
range_remove_value(wmem_epan_scope(), &amr_dynamic_payload_types, 0);
863+
dissector_add_uint_range("rtp.pt", amr_dynamic_payload_types, amr_handle);
864+
range_remove_value(wmem_epan_scope(), &amr_wb_dynamic_payload_types, 0);
865+
dissector_add_uint_range("rtp.pt", amr_wb_dynamic_payload_types, amr_wb_handle);
867866
}
868867

869868
/*

epan/dissectors/packet-evrc.c

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@ evrc_variant_t;
147147

148148
/* Initialize the protocol and registered fields */
149149
static int proto_evrc = -1;
150+
static int proto_evrcb = -1;
151+
static int proto_evrcwb = -1;
152+
static int proto_evrcnw = -1;
153+
static int proto_evrcnw2k = -1;
154+
static int proto_evrc_legacy = -1;
150155

151156
static int hf_evrc_reserved = -1;
152157
static int hf_evrc_reserved_2k = -1;
@@ -570,6 +575,21 @@ proto_register_evrc(void)
570575
proto_evrc =
571576
proto_register_protocol("Enhanced Variable Rate Codec", "EVRC", "evrc");
572577

578+
proto_evrcb =
579+
proto_register_protocol_in_name_only("Enhanced Variable Rate Codec B",
580+
"EVRC-B", "evrcb", proto_evrc, FT_PROTOCOL);
581+
proto_evrcwb =
582+
proto_register_protocol_in_name_only("Enhanced Variable Rate Codec - Wideband",
583+
"EVRC-WB", "evrcwb", proto_evrc, FT_PROTOCOL);
584+
proto_evrcnw =
585+
proto_register_protocol_in_name_only("Enhanced Variable Rate Codec - Narrowband-Wideband",
586+
"EVRC-NW", "evrcnw", proto_evrc, FT_PROTOCOL);
587+
proto_evrcnw2k =
588+
proto_register_protocol_in_name_only("Enhanced Variable Rate Codec - Narrowband-Wideband plus 2kpbs",
589+
"EVRC-NW2K", "evrcnw2k", proto_evrc, FT_PROTOCOL);
590+
proto_evrc_legacy =
591+
proto_register_protocol_in_name_only("Enhanced Variable Rate Codec (Legacy Encapsulation)",
592+
"EVRC (Legacy)", "evrc_legacy", proto_evrc, FT_PROTOCOL);
573593
proto_register_field_array(proto_evrc, hf, array_length(hf));
574594

575595
proto_register_subtree_array(ett, array_length(ett));
@@ -606,11 +626,11 @@ proto_reg_handoff_evrc(void)
606626
dissector_handle_t evrcnw2k_handle;
607627

608628
evrc_handle = create_dissector_handle(dissect_evrc, proto_evrc);
609-
evrcb_handle = create_dissector_handle(dissect_evrcb, proto_evrc);
610-
evrcwb_handle = create_dissector_handle(dissect_evrcwb, proto_evrc);
611-
evrcnw_handle = create_dissector_handle(dissect_evrcnw, proto_evrc);
612-
evrcnw2k_handle = create_dissector_handle(dissect_evrcnw2k, proto_evrc);
613-
evrc_legacy_handle = create_dissector_handle(dissect_evrc_legacy, proto_evrc);
629+
evrcb_handle = create_dissector_handle(dissect_evrcb, proto_evrcb);
630+
evrcwb_handle = create_dissector_handle(dissect_evrcwb, proto_evrcwb);
631+
evrcnw_handle = create_dissector_handle(dissect_evrcnw, proto_evrcnw);
632+
evrcnw2k_handle = create_dissector_handle(dissect_evrcnw2k, proto_evrcnw2k);
633+
evrc_legacy_handle = create_dissector_handle(dissect_evrc_legacy, proto_evrc_legacy);
614634

615635
/* header-full mime types */
616636
dissector_add_string("rtp_dyn_payload_type", "EVRC", evrc_handle);
@@ -619,6 +639,14 @@ proto_reg_handoff_evrc(void)
619639
dissector_add_string("rtp_dyn_payload_type", "EVRCNW", evrcnw_handle);
620640
dissector_add_string("rtp_dyn_payload_type", "EVRCNW2K", evrcnw2k_handle);
621641

642+
dissector_add_for_decode_as("rtp.pt", evrc_handle);
643+
dissector_add_for_decode_as("rtp.pt", evrcb_handle);
644+
dissector_add_for_decode_as("rtp.pt", evrcwb_handle);
645+
dissector_add_for_decode_as("rtp.pt", evrcnw_handle);
646+
dissector_add_for_decode_as("rtp.pt", evrcnw2k_handle);
647+
/* Since the draft legacy encapsulation only appears on PT 60, not
648+
* adding it to decode as */
649+
/* dissector_add_for_decode_as("rtp.pt", evrc_legacy_handle); */
622650
evrc_prefs_initialized = TRUE;
623651
}
624652
else

epan/dissectors/packet-evs.c

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ static int ett_evs_header = -1;
5959
static int ett_evs_speech = -1;
6060
static int ett_evs_voice_data = -1;
6161

62-
/* The dynamic payload type which will be dissected as EVS */
63-
static guint temp_dynamic_payload_type = 0;
62+
/* The dynamic payload type range which will be dissected as EVS */
63+
static range_t *temp_dynamic_payload_type_range = NULL;
6464

6565
static const value_string evs_protected_payload_sizes_value[] = {
6666
{ 48, "EVS Primary SID 2.4" },
@@ -905,12 +905,11 @@ proto_register_evs(void)
905905

906906
evs_module = prefs_register_protocol(proto_evs, proto_reg_handoff_evs);
907907

908-
prefs_register_uint_preference(evs_module, "dynamic.payload.type",
909-
"EVS dynamic payload type",
910-
"The dynamic payload type which will be interpreted as EVS"
911-
"; The value must be greater than 95",
912-
10,
913-
&temp_dynamic_payload_type);
908+
prefs_register_range_preference(evs_module, "dynamic.payload.type",
909+
"EVS dynamic payload types",
910+
"Dynamic payload types which will be interpreted as EVS"
911+
"; values must be in the range 1 - 127",
912+
&temp_dynamic_payload_type_range, 127);
914913

915914
evs_handle = register_dissector("evs", dissect_evs, proto_evs);
916915

@@ -919,23 +918,22 @@ proto_register_evs(void)
919918
void
920919
proto_reg_handoff_evs(void)
921920
{
922-
static guint dynamic_payload_type;
921+
static range_t *dynamic_payload_type_range = NULL;
923922
static gboolean evs_prefs_initialized = FALSE;
924923

925924
if (!evs_prefs_initialized) {
926925
dissector_add_string("rtp_dyn_payload_type", "EVS", evs_handle);
927926
evs_prefs_initialized = TRUE;
928927
}
929928
else {
930-
if (dynamic_payload_type > 95)
931-
dissector_delete_uint("rtp.pt", dynamic_payload_type, evs_handle);
929+
dissector_delete_uint_range("rtp.pt", dynamic_payload_type_range, evs_handle);
930+
wmem_free(wmem_epan_scope(), dynamic_payload_type_range);
932931
}
933932

934-
dynamic_payload_type = temp_dynamic_payload_type;
933+
dynamic_payload_type_range = range_copy(wmem_epan_scope(), temp_dynamic_payload_type_range);
935934

936-
if (dynamic_payload_type > 95) {
937-
dissector_add_uint("rtp.pt", dynamic_payload_type, evs_handle);
938-
}
935+
range_remove_value(wmem_epan_scope(), &dynamic_payload_type_range, 0);
936+
dissector_add_uint_range("rtp.pt", dynamic_payload_type_range, evs_handle);
939937
}
940938

941939
/*

epan/dissectors/packet-h223.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,6 +1629,7 @@ void proto_reg_handoff_h223(void)
16291629
dissector_add_for_decode_as_with_preference("tcp.port", create_dissector_handle( dissect_h223, proto_h223));
16301630
dissector_add_for_decode_as_with_preference("tcp.port", h223_bitswapped);
16311631
dissector_add_string("rtp_dyn_payload_type","CLEARMODE", h223_bitswapped);
1632+
dissector_add_for_decode_as("rtp.pt", h223_bitswapped);
16321633
dissector_add_uint("iax2.dataformat", AST_DATAFORMAT_H223_H245, create_dissector_handle(dissect_h223_bitswapped_circuit_data, proto_h223_bitswapped));
16331634
}
16341635

epan/dissectors/packet-h263p.c

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ static gint ett_h263P_extra_hdr = -1;
4949
static gint ett_h263P_payload = -1;
5050
static gint ett_h263P_data = -1;
5151

52-
/* The dynamic payload type which will be dissected as H.263-1998/H263-2000 */
52+
/* The dynamic payload type which will be dissected as H.263-1998/H.263-2000 */
5353

54-
static guint temp_dynamic_payload_type = 0;
54+
static range_t *temp_dynamic_payload_type_range = NULL;
5555

5656
static dissector_handle_t h263P_handle;
5757

@@ -192,7 +192,7 @@ dissect_h263P( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _
192192
void
193193
proto_reg_handoff_h263P(void)
194194
{
195-
static guint dynamic_payload_type;
195+
static range_t *dynamic_payload_type_range;
196196
static gboolean h263P_prefs_initialized = FALSE;
197197

198198
if (!h263P_prefs_initialized) {
@@ -201,14 +201,12 @@ proto_reg_handoff_h263P(void)
201201
h263P_prefs_initialized = TRUE;
202202
}
203203
else {
204-
if ( dynamic_payload_type > 95 )
205-
dissector_delete_uint("rtp.pt", dynamic_payload_type, h263P_handle);
206-
}
207-
dynamic_payload_type = temp_dynamic_payload_type;
208-
209-
if ( dynamic_payload_type > 95 ){
210-
dissector_add_uint("rtp.pt", dynamic_payload_type, h263P_handle);
204+
dissector_delete_uint_range("rtp.pt", dynamic_payload_type_range, h263P_handle);
205+
wmem_free(wmem_epan_scope(), dynamic_payload_type_range);
211206
}
207+
dynamic_payload_type_range = range_copy(wmem_epan_scope(), temp_dynamic_payload_type_range);
208+
range_remove_value(wmem_epan_scope(), &dynamic_payload_type_range, 0);
209+
dissector_add_uint_range("rtp.pt", dynamic_payload_type_range, h263P_handle);
212210
}
213211

214212

@@ -382,20 +380,19 @@ proto_register_h263P(void)
382380

383381

384382
proto_h263P = proto_register_protocol("ITU-T Recommendation H.263 RTP Payload header (RFC4629)",
385-
"H263P", "h263p");
383+
"H.263P", "h263p");
386384

387385
proto_register_field_array(proto_h263P, hf, array_length(hf));
388386
proto_register_subtree_array(ett, array_length(ett));
389387

390388
h263P_module = prefs_register_protocol(proto_h263P, proto_reg_handoff_h263P);
391389

392-
prefs_register_uint_preference(h263P_module,
390+
prefs_register_range_preference(h263P_module,
393391
"dynamic.payload.type",
394-
"H263-1998 and H263-2000 dynamic payload type",
395-
"The dynamic payload type which will be interpreted as H264"
396-
"; The value must be greater than 95",
397-
10,
398-
&temp_dynamic_payload_type);
392+
"H.263-1998 and H.263-2000 dynamic payload types",
393+
"Dynamic payload types which will be interpreted as H.263"
394+
"; values must be in the range 1 - 127",
395+
&temp_dynamic_payload_type_range, 127);
399396

400397
h263P_handle = register_dissector("h263P", dissect_h263P, proto_h263P);
401398
}

epan/dissectors/packet-h264.c

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,6 @@ static dissector_handle_t h264_name_handle;
254254

255255
/* The dynamic payload type range which will be dissected as H.264 */
256256

257-
#define RTP_PT_DEFAULT_RANGE "0"
258257
static range_t *temp_dynamic_payload_type_range = NULL;
259258

260259
static dissector_handle_t h264_handle;
@@ -2711,16 +2710,6 @@ dissect_h264_name(tvbuff_t *tvb _U_, packet_info *pinfo, proto_tree *tree, void*
27112710
}
27122711

27132712

2714-
static void range_delete_h264_rtp_pt_callback(guint32 rtp_pt, gpointer ptr _U_) {
2715-
if (rtp_pt >= 96 && rtp_pt <= 127)
2716-
dissector_delete_uint("rtp.pt", rtp_pt, h264_handle);
2717-
}
2718-
2719-
static void range_add_h264_rtp_pt_callback(guint32 rtp_pt, gpointer ptr _U_) {
2720-
if (rtp_pt >= 96 && rtp_pt <= 127)
2721-
dissector_add_uint("rtp.pt", rtp_pt, h264_handle);
2722-
}
2723-
27242713
void
27252714
proto_register_h264(void)
27262715
{
@@ -3690,7 +3679,7 @@ proto_register_h264(void)
36903679
};
36913680

36923681
/* Register the protocol name and description */
3693-
proto_h264 = proto_register_protocol("H.264","H264", "h264");
3682+
proto_h264 = proto_register_protocol("H.264", "H.264", "h264");
36943683

36953684
/* Required function calls to register the header fields and subtrees used */
36963685
proto_register_field_array(proto_h264, hf, array_length(hf));
@@ -3704,9 +3693,9 @@ proto_register_h264(void)
37043693

37053694

37063695
prefs_register_range_preference(h264_module, "dynamic.payload.type",
3707-
"H264 dynamic payload types",
3708-
"Dynamic payload types which will be interpreted as H264"
3709-
"; Values must be in the range 96 - 127",
3696+
"H.264 dynamic payload types",
3697+
"Dynamic payload types which will be interpreted as H.264"
3698+
"; values must be in the range 1 - 127",
37103699
&temp_dynamic_payload_type_range, 127);
37113700

37123701
h264_handle = register_dissector("h264", dissect_h264, proto_h264);
@@ -3736,12 +3725,14 @@ proto_reg_handoff_h264(void)
37363725
}
37373726
h264_prefs_initialized = TRUE;
37383727
} else {
3739-
range_foreach(dynamic_payload_type_range, range_delete_h264_rtp_pt_callback, NULL);
3728+
dissector_delete_uint_range("rtp.pt", dynamic_payload_type_range, h264_handle);
37403729
wmem_free(wmem_epan_scope(), dynamic_payload_type_range);
37413730
}
37423731

37433732
dynamic_payload_type_range = range_copy(wmem_epan_scope(), temp_dynamic_payload_type_range);
3744-
range_foreach(dynamic_payload_type_range, range_add_h264_rtp_pt_callback, NULL);
3733+
range_remove_value(wmem_epan_scope(), &dynamic_payload_type_range, 0);
3734+
dissector_add_uint_range("rtp.pt", dynamic_payload_type_range, h264_handle);
3735+
37453736
}
37463737

37473738
/*

epan/dissectors/packet-h265.c

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,6 @@ static expert_field ei_h265_value_to_large = EI_INIT;
391391

392392
/* The dynamic payload type range which will be dissected as H.265 */
393393

394-
#define RTP_PT_DEFAULT_RANGE "0"
395394
static range_t *temp_dynamic_payload_type_range = NULL;
396395

397396
static dissector_handle_t h265_handle;
@@ -2988,18 +2987,6 @@ dissect_h265(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
29882987
return tvb_captured_length(tvb);
29892988
}
29902989

2991-
static void
2992-
range_delete_h265_rtp_pt_callback(guint32 rtp_pt, gpointer ptr _U_) {
2993-
if (rtp_pt >= 96 && rtp_pt <= 127)
2994-
dissector_delete_uint("rtp.pt", rtp_pt, h265_handle);
2995-
}
2996-
2997-
static void
2998-
range_add_h265_rtp_pt_callback(guint32 rtp_pt, gpointer ptr _U_) {
2999-
if (rtp_pt >= 96 && rtp_pt <= 127)
3000-
dissector_add_uint("rtp.pt", rtp_pt, h265_handle);
3001-
}
3002-
30032990
void
30042991
proto_register_h265(void)
30052992
{
@@ -4599,7 +4586,7 @@ proto_register_h265(void)
45994586
};
46004587

46014588
/* Register the protocol name and description */
4602-
proto_h265 = proto_register_protocol("H.265", "H265", "h265");
4589+
proto_h265 = proto_register_protocol("H.265", "H.265", "h265");
46034590

46044591
/* Required function calls to register the header fields and subtrees used */
46054592
proto_register_field_array(proto_h265, hf, array_length(hf));
@@ -4613,9 +4600,9 @@ proto_register_h265(void)
46134600

46144601

46154602
prefs_register_range_preference(h265_module, "dynamic.payload.type",
4616-
"H265 dynamic payload types",
4617-
"Dynamic payload types which will be interpreted as H265"
4618-
"; Values must be in the range 96 - 127",
4603+
"H.265 dynamic payload types",
4604+
"Dynamic payload types which will be interpreted as H.265"
4605+
"; values must be in the range 1 - 127",
46194606
&temp_dynamic_payload_type_range, 127);
46204607

46214608
h265_handle = register_dissector("h265", dissect_h265, proto_h265);
@@ -4634,12 +4621,13 @@ proto_reg_handoff_h265(void)
46344621
h265_prefs_initialized = TRUE;
46354622
}
46364623
else {
4637-
range_foreach(dynamic_payload_type_range, range_delete_h265_rtp_pt_callback, NULL);
4624+
dissector_delete_uint_range("rtp.pt", dynamic_payload_type_range, h265_handle);
46384625
wmem_free(wmem_epan_scope(), dynamic_payload_type_range);
46394626
}
46404627

46414628
dynamic_payload_type_range = range_copy(wmem_epan_scope(), temp_dynamic_payload_type_range);
4642-
range_foreach(dynamic_payload_type_range, range_add_h265_rtp_pt_callback, NULL);
4629+
range_remove_value(wmem_epan_scope(), &dynamic_payload_type_range, 0);
4630+
dissector_add_uint_range("rtp.pt", dynamic_payload_type_range, h265_handle);
46434631
}
46444632

46454633
/*

0 commit comments

Comments
 (0)