Wireshark-commits: [Wireshark-commits] master 38f45e1: SDP: reduce code duplication
URL: https://code.wireshark.org/review/gitweb?p=wireshark.git;a=commit;h=38f45e1e222589987d95e79f59430403f40bdd49
Submitter: Michael Mann (mmann78@xxxxxxxxxxxx)
Changed: branch: master
Repository: wireshark
Commits:
38f45e1 by Peter Wu (peter@xxxxxxxxxxxxx):
SDP: reduce code duplication
Observe that some code in setup_sdp_transport is effectively the same
code as a part from dissect_sdp with these differences:
- Removal of these two conditions (setup_sdp_transport already returns
early when a packet is visited):
(!pinfo->fd->flags.visited) && (transport_info == &local_transport_info)
- "establish_frame" in setup_sdp_transport is replaced by "pinfo->num"
in dissect_sdp.
dissect_sdp further has two additional blocks that add information to
the VoIP calls dialog. This is preserved.
Freeing of the RTP payload information has also been simplified. Instead
of checking it inside the main loop that adds addresses (now moved to a
new function, "apply_sdp_transport"), let the caller do it outside the
loop.
The transformation in this patch is rather mechanical:
0. Add a comment on what the new function is supposed to do.
1. Move code from setup_sdp_transport into a new function,
apply_sdp_transport and reduce indentation level.
2. Copy all variables to the new function and populate the parameter
list.
3. Compile result, remove unused variables that the compiler warns for.
4. Move freeing of unused media outside the loop to the caller.
5. Create a new conditional statement before the duplicated loop, which
checks whether setup_sdp_transport has been used before. (SIP first
calls setup_sdp_transport, then it invokes the media type dissector
which calls dissect_sdp to populate the tree.)
6. Remove the duplicated code from the dissect_sdp loop until only the
VoIP Calls dialog info remains.
There is no functional change intended.
Change-Id: I928379466af56ef1729cccbf4a5b60895ddb3227
Reviewed-on: https://code.wireshark.org/review/19047
Reviewed-by: Peter Wu <peter@xxxxxxxxxxxxx>
Petri-Dish: Peter Wu <peter@xxxxxxxxxxxxx>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@xxxxxxxxxxxxx>
Reviewed-by: Michael Mann <mmann78@xxxxxxxxxxxx>
Actions performed:
from 2994e63 SDP: add basic ICE candidate attribute dissection (RFC 5245)
adds 38f45e1 SDP: reduce code duplication
Summary of changes:
epan/dissectors/packet-sdp.c | 370 ++++++++++++++++--------------------------
1 file changed, 140 insertions(+), 230 deletions(-)