From 6471c6389671f3c2444ec641ab19edaf99161bec Mon Sep 17 00:00:00 2001 From: juha-h Date: Sat, 21 Oct 2023 13:55:35 +0300 Subject: [PATCH] This PR reverts https://github.com/baresip/re/commit/fc588b9cf7162133f96ee38b236d9ecea6c8ee20 which broke common re-invite usage (hold/unhold) (#986) --- src/sip/dialog.c | 43 +++---------------------------------------- 1 file changed, 3 insertions(+), 40 deletions(-) diff --git a/src/sip/dialog.c b/src/sip/dialog.c index aef4b7449..4585e22b6 100644 --- a/src/sip/dialog.c +++ b/src/sip/dialog.c @@ -35,7 +35,6 @@ struct sip_dialog { uint32_t lseq; uint32_t rseq; size_t cpos; - size_t rpos; enum sip_transp tp; uint32_t srcport; }; @@ -120,7 +119,7 @@ int sip_dialog_alloc(struct sip_dialog **dlgp, rend = dlg->mb->pos - 2; } err |= mbuf_printf(dlg->mb, "To: <%s>\r\n", to_uri); - dlg->cpos = dlg->rpos = dlg->mb->pos; + dlg->cpos = dlg->mb->pos; err |= mbuf_printf(dlg->mb, "From: %s%s%s<%s>;tag=%016llx\r\n", from_name ? "\"" : "", from_name, from_name ? "\" " : "", @@ -309,7 +308,6 @@ int sip_dialog_create(struct sip_dialog *dlg, const struct sip_msg *msg) msg->req ? &msg->from.val : &msg->to.val); dlg->mb->pos = dlg->cpos; - dlg->rpos = renc.mb->pos; err |= mbuf_write_mem(renc.mb, mbuf_buf(dlg->mb), mbuf_get_left(dlg->mb)); dlg->mb->pos = 0; @@ -464,8 +462,6 @@ int sip_dialog_update(struct sip_dialog *dlg, const struct sip_msg *msg) { const struct sip_hdr *contact; struct sip_addr addr; - struct route_enc renc; - struct pl pl; char *uri; int err; @@ -479,43 +475,14 @@ int sip_dialog_update(struct sip_dialog *dlg, const struct sip_msg *msg) if (sip_addr_decode(&addr, &contact->val)) return EBADMSG; - renc.mb = mbuf_alloc(512); - if (!renc.mb) - return ENOMEM; - err = pl_strdup(&uri, &addr.auri); if (err) return err; - renc.end = 0; - - err |= sip_msg_hdr_apply(msg, msg->req, SIP_HDR_RECORD_ROUTE, - record_route_handler, &renc) ? EINVAL : 0; - err |= mbuf_printf(renc.mb, "To: %r\r\n", - msg->req ? &msg->from.val : &msg->to.val); - - dlg->mb->pos = dlg->rpos; - dlg->rpos = renc.mb->pos; - err |= mbuf_write_mem(renc.mb, mbuf_buf(dlg->mb), - mbuf_get_left(dlg->mb)); - dlg->mb->pos = 0; - - if (err) - goto out; - - renc.mb->pos = 0; + if (dlg->route.scheme.p == dlg->uri) { - if (renc.end) { - pl.p = (const char *)mbuf_buf(renc.mb) + ROUTE_OFFSET; - pl.l = renc.end - ROUTE_OFFSET; - err = sip_addr_decode(&addr, &pl); - if (err) - goto out; - - dlg->route = addr.uri; - } - else { struct uri tmp; + struct pl pl; pl_set_str(&pl, uri); err = uri_decode(&tmp, &pl); @@ -525,14 +492,10 @@ int sip_dialog_update(struct sip_dialog *dlg, const struct sip_msg *msg) dlg->route = tmp; } - mem_deref(dlg->mb); mem_deref(dlg->uri); - - dlg->mb = mem_ref(renc.mb); dlg->uri = mem_ref(uri); out: - mem_deref(renc.mb); mem_deref(uri); return err;