Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*! \brief Transfer call before connect with a 302 redirect
- \note Called by the transfer() dialplan application through the sip_transfer()
- pbx interface function if the call is in ringing state
- \todo Fix this function so that we wait for reply to the REFER and
- react to errors, denials or other issues the other end might have.
- */
- static int sip_sipredirect(struct sip_pvt *p, const char *dest)
- {
- char *cdest;
- char *extension, *domain;
- cdest = ast_strdupa(dest);
- extension = strsep(&cdest, "@");
- domain = cdest;
- if (ast_strlen_zero(extension)) {
- ast_log(LOG_ERROR, "Missing mandatory argument: extension\n");
- return 0;
- }
- /* we'll issue the redirect message here */
- if (!domain) {
- char *local_to_header;
- char to_header[256];
- ast_copy_string(to_header, get_header(&p->initreq, "To"), sizeof(to_header));
- if (ast_strlen_zero(to_header)) {
- ast_log(LOG_ERROR, "Cannot retrieve the 'To' header from the original SIP request!\n");
- return 0;
- }
- if (((local_to_header = strcasestr(to_header, "sip:")) || (local_to_header = strcasestr(to_header, "sips:")))
- && (local_to_header = strchr(local_to_header, '@'))) {
- char ldomain[256];
- memset(ldomain, 0, sizeof(ldomain));
- local_to_header++;
- /* This is okey because lhost and lport are as big as tmp */
- sscanf(local_to_header, "%256[^<>; ]", ldomain);
- if (ast_strlen_zero(ldomain)) {
- ast_log(LOG_ERROR, "Can't find the host address\n");
- return 0;
- }
- domain = ast_strdupa(ldomain);
- }
- }
- add_diversion(&p->initreq, p);
- ast_string_field_build(p, our_contact, "Transfer <sip:%s@%s>", extension, domain);
- transmit_response_reliable(p, "302 Moved Temporarily", &p->initreq);
- sip_scheddestroy(p, SIP_TRANS_TIMEOUT); /* Make sure we stop send this reply. */
- sip_alreadygone(p);
- if (p->owner) {
- enum ast_control_transfer message = AST_TRANSFER_SUCCESS;
- ast_queue_control_data(p->owner, AST_CONTROL_TRANSFER, &message, sizeof(message));
- }
- /* hangup here */
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement