Skip to content

Commit

Permalink
rtp_relay: match reply leg by index, if tag not present
Browse files Browse the repository at this point in the history
  • Loading branch information
razvancrainea committed Jan 16, 2024
1 parent 1a11c03 commit 1339b7a
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions modules/rtp_relay/rtp_relay.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,16 +241,23 @@ struct rtp_relay_leg *rtp_relay_get_leg(struct rtp_relay_ctx *ctx,
if (tag && !tag->len)
tag = NULL;

LM_RTP_DBG("searching for tag [%.*s] idx [%d]\n", tag?tag->len:0, tag?tag->s:"", idx);

list_for_each(it, &ctx->legs) {
leg = list_entry(it, struct rtp_relay_leg, list);
if (tag) {
/* match by tag */
if (leg->tag.len && str_match(tag, &leg->tag))
return leg;
} else if (leg->index != PV_IDX_ALL && leg->index == idx)
if (leg->tag.len) {
if (str_match(tag, &leg->tag))
return leg;
continue;
}
}
if (leg->index != PV_IDX_ALL && leg->index == idx)
return leg;
}

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

Expand Down Expand Up @@ -399,12 +406,10 @@ static struct rtp_relay_leg *pv_get_rtp_relay_leg(struct sip_msg *msg,
LM_ERR("cannot parse To header!\n");
return NULL;
}
if (get_to(msg)->tag_value.len) {
if (get_to(msg)->tag_value.len)
/* a sequential should always have a to_tag */
tag = get_to(msg)->tag_value;
} else {
idx = rtp_relay_ctx_branch();
}
idx = rtp_relay_ctx_branch();
} else if (route_type == LOCAL_ROUTE) {
/* we always force index 0 for local_route */
idx = rtp_relay_get_last_branch(ctx, msg);
Expand Down

0 comments on commit 1339b7a

Please sign in to comment.