FreeCalypso > hg > themwi-system-sw
comparison sip-in/invite.c @ 77:fe39404092d9
sip-in: generate To tags
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 20 Sep 2022 16:49:24 -0800 |
parents | 21276f045026 |
children | ce3b1db7d1d7 |
comparison
equal
deleted
inserted
replaced
76:21276f045026 | 77:fe39404092d9 |
---|---|
86 invite_new_call(req, ess, sin) | 86 invite_new_call(req, ess, sin) |
87 struct sip_pkt_rx *req; | 87 struct sip_pkt_rx *req; |
88 struct uas_parse_hdrs *ess; | 88 struct uas_parse_hdrs *ess; |
89 struct sockaddr_in *sin; | 89 struct sockaddr_in *sin; |
90 { | 90 { |
91 static unsigned cycle_tag_num, cycle_sdp_addend; | |
91 char uri_user[13], *called_nanp; | 92 char uri_user[13], *called_nanp; |
92 struct sip_msg_out resp; | 93 struct sip_msg_out resp; |
93 struct grok_from gfrom; | 94 struct grok_from gfrom; |
94 struct supported_ext supp_ext; | 95 struct supported_ext supp_ext; |
95 char *hval, *unsup_ext; | 96 char *hval, *unsup_ext; |
242 start_response_out_msg(&resp, "480 GSM service is offline"); | 243 start_response_out_msg(&resp, "480 GSM service is offline"); |
243 goto error_resp; | 244 goto error_resp; |
244 } | 245 } |
245 /* stateful processing begins */ | 246 /* stateful processing begins */ |
246 call = malloc(sizeof(struct call) + strlen(ess->call_id) + | 247 call = malloc(sizeof(struct call) + strlen(ess->call_id) + |
247 strlen(ess->from) + strlen(ess->to) + strlen(ess->via) | 248 strlen(ess->from) + req_uri_len + strlen(ess->via) + 19); |
248 + 4); | |
249 if (!call) { | 249 if (!call) { |
250 syslog(LOG_CRIT, "failed malloc for incoming call!"); | 250 syslog(LOG_CRIT, "failed malloc for incoming call!"); |
251 start_response_out_msg(&resp, | 251 start_response_out_msg(&resp, |
252 "503 Gateway resource allocation failure"); | 252 "503 Gateway resource allocation failure"); |
253 goto error_resp; | 253 goto error_resp; |
254 } | 254 } |
255 cycle_tag_num++; | |
256 if (cycle_tag_num >= 1000000) | |
257 cycle_tag_num = 0; | |
258 cycle_sdp_addend++; | |
259 if (cycle_sdp_addend >= 0x10000) | |
260 cycle_sdp_addend = 0; | |
255 bzero(call, sizeof(struct call)); | 261 bzero(call, sizeof(struct call)); |
256 dp = (char *)(call + 1); | 262 dp = (char *)(call + 1); |
257 copylen = strlen(ess->call_id) + 1; | 263 copylen = strlen(ess->call_id) + 1; |
258 call->sip_call_id = dp; | 264 call->sip_call_id = dp; |
259 bcopy(ess->call_id, dp, copylen); | 265 bcopy(ess->call_id, dp, copylen); |
260 dp += copylen; | 266 dp += copylen; |
261 copylen = strlen(ess->from) + 1; | 267 copylen = strlen(ess->from) + 1; |
262 call->invite_from = dp; | 268 call->invite_from = dp; |
263 bcopy(ess->from, dp, copylen); | 269 bcopy(ess->from, dp, copylen); |
264 dp += copylen; | 270 dp += copylen; |
265 copylen = strlen(ess->to) + 1; | |
266 call->invite_to = dp; | 271 call->invite_to = dp; |
267 bcopy(ess->to, dp, copylen); | 272 *dp++ = '<'; |
268 dp += copylen; | 273 bcopy(req->req_uri, dp, req_uri_len); |
274 dp += req_uri_len; | |
275 *dp++ = '>'; | |
276 sprintf(dp, ";tag=in%06u", cycle_tag_num); | |
277 dp += 14; | |
269 copylen = strlen(ess->via) + 1; | 278 copylen = strlen(ess->via) + 1; |
270 call->invite_via = dp; | 279 call->invite_via = dp; |
271 bcopy(ess->via, dp, copylen); | 280 bcopy(ess->via, dp, copylen); |
272 call->invite_cseq = ess->cseq_num; | 281 call->invite_cseq = ess->cseq_num; |
273 bcopy(sin, &call->udp_sin, sizeof(struct sockaddr_in)); | 282 bcopy(sin, &call->udp_sin, sizeof(struct sockaddr_in)); |
279 call->use_100rel = use_100rel; | 288 call->use_100rel = use_100rel; |
280 call->pstn_rtp_remote.sin_family = AF_INET; | 289 call->pstn_rtp_remote.sin_family = AF_INET; |
281 call->pstn_rtp_remote.sin_addr = sdp_parse.ip_addr; | 290 call->pstn_rtp_remote.sin_addr = sdp_parse.ip_addr; |
282 call->pstn_rtp_remote.sin_port = htons(sdp_parse.audio_port); | 291 call->pstn_rtp_remote.sin_port = htons(sdp_parse.audio_port); |
283 call->use_pcma = use_pcma; | 292 call->use_pcma = use_pcma; |
293 call->sdp_addend = cycle_sdp_addend; | |
284 /* generate 100 response */ | 294 /* generate 100 response */ |
285 start_response_out_msg(&resp, "100 Proceeding"); | 295 start_response_out_msg(&resp, "100 Proceeding"); |
286 rc = fill_invite_resp_from_call(&resp, call); | 296 rc = fill_invite_resp_from_call(&resp, call); |
287 if (rc < 0) { | 297 if (rc < 0) { |
288 syslog(LOG_ERR, "INVITE 100 response length exceeded"); | 298 syslog(LOG_ERR, "INVITE 100 response length exceeded"); |