Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion nmostesting/IS05Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,10 @@ def check_sdp_matches_params(self, portId):
sdp_global = sdp_sections[0]
sdp_media_sections = sdp_sections[1:]
sdp_groups_line = re.search(r"a=group:DUP (.+)", sdp_global)
connection_global = None
connection_global_line = re.search(r"c=IN IP[4,6] ([^/\r\n]*)(?:/[0-9]+){0,2}", sdp_global)
if connection_global_line is not None:
connection_global = connection_global_line.group(1)
Comment on lines +538 to +541
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest getting rid of the connection_global temp variable in the interest of compactness and understandability.

Suggested change
connection_global = None
connection_global_line = re.search(r"c=IN IP[4,6] ([^/\r\n]*)(?:/[0-9]+){0,2}", sdp_global)
if connection_global_line is not None:
connection_global = connection_global_line.group(1)
connection_global_line = re.search(r"c=IN IP[4,6] ([^/\r\n]*)(?:/[0-9]+){0,2}", sdp_global)

tp_compare = []
if sdp_groups_line:
sdp_group_names = sdp_groups_line.group(1).split()
Expand All @@ -553,7 +557,14 @@ def check_sdp_matches_params(self, portId):
return False, "SDP destination port {} does not match transport_params: {}" \
.format(media_line.group(2), transport_params["destination_port"])
connection_line = re.search(r"c=IN IP[4,6] ([^/\r\n]*)(?:/[0-9]+){0,2}", sdp_data)
if connection_line.group(1) != transport_params["destination_ip"]:
if connection_line is None:
if connection_global is None:
return False, "SDP has no session-level connection description, and no connection line in media description {}"\
.format(index)
elif connection_global != transport_params["destination_ip"]:
return False, "SDP has no connection line for media description {}, and session destination IP {} does not match transport_params: {}" \
.format(index, connection_global, transport_params["destination_ip"])
elif connection_line.group(1) != transport_params["destination_ip"]:
Comment on lines +560 to +567
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if connection_line is None:
if connection_global is None:
return False, "SDP has no session-level connection description, and no connection line in media description {}"\
.format(index)
elif connection_global != transport_params["destination_ip"]:
return False, "SDP has no connection line for media description {}, and session destination IP {} does not match transport_params: {}" \
.format(index, connection_global, transport_params["destination_ip"])
elif connection_line.group(1) != transport_params["destination_ip"]:
if connection_line is None:
if connection_global_line is None:
return False, "SDP has no session-level connection description, and no connection line in media description {}"\
.format(index)
elif connection_global_line.group(1) != transport_params["destination_ip"]:
return False, "SDP has no connection line for media description {}, and session destination IP {} does not match transport_params: {}" \
.format(index, connection_global_line.group(1), transport_params["destination_ip"])
elif connection_line.group(1) != transport_params["destination_ip"]:

return False, "SDP destination IP {} does not match transport_params: {}" \
.format(connection_line.group(1), transport_params["destination_ip"])
filter_line = re.search(r"a=source-filter: incl IN IP[4,6] (\S*) (\S*)", sdp_data)
Expand Down