From 74dc757659552fd42152ca43a0a5496fb30d5128 Mon Sep 17 00:00:00 2001 From: Alberto Panizzo Date: Thu, 23 Jun 2022 19:04:33 +0200 Subject: [PATCH] Allow sending sip INFO messages after 183 Session Progress is received When we receive a 183 Session Progress (Remote require us to send early media) the To header can contain a not NULL tag: SIP/2.0 183 Session progress Via: SIP/2.0/UDP 192.168.77.15;rport;branch=z9hG4bKNyU9Kg28QD3eK From: ;tag=jvl5hu58Y To: ;tag=hjmfxOj Call-ID: 7979747314492623079 ... So for the remote user agent the dialog id will become the sum of Call-ID + From-Tag + To-Tag. At this stage, if we want to send an INFO message to the other end we need to provide all three IDs like in follows: INFO sip:1@192.168.77.15:5060;transport=udp SIP/2.0 Via: SIP/2.0/UDP 192.168.77.14;rport;branch=z9hG4bKp7m2NBKcNpS1e From: ;tag=jvl5hu58Y To: ;tag=hjmfxOj Call-ID: 7979747314492623079 ... Before this patch the iNFO message was sent with the To header without any tag. The same as in original INVITE message sent to the other end Signed-off-by: Alberto Panizzo --- libsofia-sip-ua/nua/nua_client.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/libsofia-sip-ua/nua/nua_client.c b/libsofia-sip-ua/nua/nua_client.c index 00cca1ea0..faf582977 100644 --- a/libsofia-sip-ua/nua/nua_client.c +++ b/libsofia-sip-ua/nua/nua_client.c @@ -1053,7 +1053,17 @@ int nua_client_response(nua_client_request_t *cr, cr->cr_status = status; cr->cr_phrase = phrase; - if (status < 200) { + if (status == 183) { + /** + * Save the new remote tag on To header during Session Progress + * to allow sending INFO messages to remote peer before 200 OK + */ + if (sip) { + if (cr->cr_contactize) + nua_dialog_uac_route(nh, nh->nh_ds, sip, 1, cr->cr_initial); + } + } + else if (status < 200) { /* Xyzzy */ } else if (sip && nua_client_check_restart(cr, status, phrase, sip)) { @@ -1524,6 +1534,17 @@ int nua_base_client_response(nua_client_request_t *cr, nua_client_report(cr, status, phrase, sip, cr->cr_orq, tags); + /** + * In Session Progress we need to update our sip_to tag to allow correct + * INFO messages to be sent before a 200 OK is received + */ + if (status == 183 && method == sip_method_invite && !cr->cr_acked) { + nua_dialog_state_t *ds = nh->nh_ds; + if (ds && ds->ds_remote_tag && ds->ds_remote_tag[0] && + sip_to_tag(nh->nh_home, sip->sip_to, ds->ds_remote_tag) < 0) + SU_DEBUG_3(("%s Cannot store remote tag in sip_to header\n", __func__)); + } + if (status < 200 || /* Un-ACKed 2XX response to INVITE */ (method == sip_method_invite && status < 300 && !cr->cr_acked)) {