# HG changeset patch # User Mychaela Falconia # Date 1663721364 28800 # Node ID fe39404092d932c8c566e0d61b123c17780187f4 # Parent 21276f0450266ccd4e0145576f30bf250a35bae6 sip-in: generate To tags diff -r 21276f045026 -r fe39404092d9 sip-in/invite.c --- a/sip-in/invite.c Tue Sep 20 16:40:07 2022 -0800 +++ b/sip-in/invite.c Tue Sep 20 16:49:24 2022 -0800 @@ -88,6 +88,7 @@ struct uas_parse_hdrs *ess; struct sockaddr_in *sin; { + static unsigned cycle_tag_num, cycle_sdp_addend; char uri_user[13], *called_nanp; struct sip_msg_out resp; struct grok_from gfrom; @@ -244,14 +245,19 @@ } /* stateful processing begins */ call = malloc(sizeof(struct call) + strlen(ess->call_id) + - strlen(ess->from) + strlen(ess->to) + strlen(ess->via) - + 4); + strlen(ess->from) + req_uri_len + strlen(ess->via) + 19); if (!call) { syslog(LOG_CRIT, "failed malloc for incoming call!"); start_response_out_msg(&resp, "503 Gateway resource allocation failure"); goto error_resp; } + cycle_tag_num++; + if (cycle_tag_num >= 1000000) + cycle_tag_num = 0; + cycle_sdp_addend++; + if (cycle_sdp_addend >= 0x10000) + cycle_sdp_addend = 0; bzero(call, sizeof(struct call)); dp = (char *)(call + 1); copylen = strlen(ess->call_id) + 1; @@ -262,10 +268,13 @@ call->invite_from = dp; bcopy(ess->from, dp, copylen); dp += copylen; - copylen = strlen(ess->to) + 1; call->invite_to = dp; - bcopy(ess->to, dp, copylen); - dp += copylen; + *dp++ = '<'; + bcopy(req->req_uri, dp, req_uri_len); + dp += req_uri_len; + *dp++ = '>'; + sprintf(dp, ";tag=in%06u", cycle_tag_num); + dp += 14; copylen = strlen(ess->via) + 1; call->invite_via = dp; bcopy(ess->via, dp, copylen); @@ -281,6 +290,7 @@ call->pstn_rtp_remote.sin_addr = sdp_parse.ip_addr; call->pstn_rtp_remote.sin_port = htons(sdp_parse.audio_port); call->use_pcma = use_pcma; + call->sdp_addend = cycle_sdp_addend; /* generate 100 response */ start_response_out_msg(&resp, "100 Proceeding"); rc = fill_invite_resp_from_call(&resp, call);