Skip to content

Commit 1339b7a

Browse files
committed
rtp_relay: match reply leg by index, if tag not present
1 parent 1a11c03 commit 1339b7a

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

modules/rtp_relay/rtp_relay.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -241,16 +241,23 @@ struct rtp_relay_leg *rtp_relay_get_leg(struct rtp_relay_ctx *ctx,
241241
if (tag && !tag->len)
242242
tag = NULL;
243243

244+
LM_RTP_DBG("searching for tag [%.*s] idx [%d]\n", tag?tag->len:0, tag?tag->s:"", idx);
245+
244246
list_for_each(it, &ctx->legs) {
245247
leg = list_entry(it, struct rtp_relay_leg, list);
246248
if (tag) {
247249
/* match by tag */
248-
if (leg->tag.len && str_match(tag, &leg->tag))
249-
return leg;
250-
} else if (leg->index != PV_IDX_ALL && leg->index == idx)
250+
if (leg->tag.len) {
251+
if (str_match(tag, &leg->tag))
252+
return leg;
253+
continue;
254+
}
255+
}
256+
if (leg->index != PV_IDX_ALL && leg->index == idx)
251257
return leg;
252258
}
253259

260+
LM_RTP_DBG("no leg for tag [%.*s] idx [%d]\n", tag?tag->len:0, tag?tag->s:"", idx);
254261
return NULL;
255262
}
256263

@@ -399,12 +406,10 @@ static struct rtp_relay_leg *pv_get_rtp_relay_leg(struct sip_msg *msg,
399406
LM_ERR("cannot parse To header!\n");
400407
return NULL;
401408
}
402-
if (get_to(msg)->tag_value.len) {
409+
if (get_to(msg)->tag_value.len)
403410
/* a sequential should always have a to_tag */
404411
tag = get_to(msg)->tag_value;
405-
} else {
406-
idx = rtp_relay_ctx_branch();
407-
}
412+
idx = rtp_relay_ctx_branch();
408413
} else if (route_type == LOCAL_ROUTE) {
409414
/* we always force index 0 for local_route */
410415
idx = rtp_relay_get_last_branch(ctx, msg);

0 commit comments

Comments
 (0)