[asterisk-commits] kpfleming: trunk r65814 -
/trunk/channels/chan_sip.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Thu May 24 04:38:21 MST 2007
Author: kpfleming
Date: Thu May 24 06:38:20 2007
New Revision: 65814
URL: http://svn.digium.com/view/asterisk?view=rev&rev=65814
Log:
Yes Virginia, there is a reason why we have stringfields in the sip_pvt structure...
Modified:
trunk/channels/chan_sip.c
Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?view=diff&rev=65814&r1=65813&r2=65814
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Thu May 24 06:38:20 2007
@@ -969,6 +969,7 @@
AST_STRING_FIELD(our_contact); /*!< Our contact header */
AST_STRING_FIELD(rpid); /*!< Our RPID header */
AST_STRING_FIELD(rpid_from); /*!< Our RPID From header */
+ AST_STRING_FIELD(url); /*!< URL to be sent with next message to peer */
);
unsigned int ocseq; /*!< Current outgoing seqno */
unsigned int icseq; /*!< Current incoming seqno */
@@ -1037,8 +1038,6 @@
struct ast_rtp *rtp; /*!< RTP Session */
struct ast_rtp *vrtp; /*!< Video RTP session */
struct ast_rtp *trtp; /*!< Text RTP session */
- const char *url; /*!< Temporary URI for next response */
- int freeurl; /*!< Whether URI should be free()'d */
struct sip_pkt *packets; /*!< Packets scheduled for re-transmission */
struct sip_history_head *history; /*!< History of this SIP dialog */
struct ast_variable *chanvars; /*!< Channel variables to set for inbound call */
@@ -2546,15 +2545,11 @@
static int sip_sendhtml(struct ast_channel *chan, int subclass, const char *data, int datalen)
{
struct sip_pvt *p = chan->tech_pvt;
- struct ast_str *buf;
if (subclass != AST_HTML_URL)
return -1;
- buf = ast_str_alloca(64);
-
- ast_str_set(&buf, 0, "<%s>;mode=active", data);
- p->url = buf->str;
+ ast_string_field_build(p, url, "<%s>;mode=active", data);
if (sip_debug_test_pvt(p) && option_debug)
ast_log(LOG_DEBUG, "Send URL %s, state = %d!\n", data, chan->_state);
@@ -2570,18 +2565,12 @@
if (!p->pendinginvite) { /* We are up, and have no outstanding invite */
transmit_reinvite_with_sdp(p, FALSE);
} else if (!ast_test_flag(&p->flags[0], SIP_PENDINGBYE)) {
- /* We have a pending Invite. Send re-invite when we're done with the invite */
ast_set_flag(&p->flags[0], SIP_NEEDREINVITE);
- if ((p->url = ast_strdup(p->url)))
- p->freeurl = 1;
}
break;
default:
ast_log(LOG_WARNING, "Don't know how to send URI when state is %d!\n", chan->_state);
}
-
- if (p->url && !p->freeurl)
- ast_log(LOG_WARNING, "Whoa, didn't expect URI to hang around!\n");
return 0;
}
@@ -6152,12 +6141,12 @@
} else if (msg[0] != '4' && p->our_contact[0]) {
add_header(resp, "Contact", p->our_contact);
}
+
if (p->url) {
add_header(resp, "Access-URL", p->url);
- if (p->freeurl)
- free((char *)p->url);
- p->url = NULL;
- }
+ ast_string_field_free(p, url);
+ }
+
return 0;
}
@@ -6262,12 +6251,12 @@
if (!ast_strlen_zero(p->rpid))
add_header(req, "Remote-Party-ID", p->rpid);
+
if (p->url) {
add_header(req, "Access-URL", p->url);
- if (p->freeurl)
- free((char *)p->url);
- p->url = NULL;
- }
+ ast_string_field_free(p, url);
+ }
+
return 0;
}
More information about the asterisk-commits
mailing list