Author: rizzo
Date: Fri Jul 20 23:07:07 2007
New Revision: 76232
URL: http://svn.digium.com/view/asterisk?view=rev&rev=76232
Log:
replace SIP_NO_HISTORY with a proper variable
Modified:
team/rizzo/astobj2/channels/chan_sip.c
Modified: team/rizzo/astobj2/channels/chan_sip.c
URL:
http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_sip.c?view=diff&rev=76232&r1=76231&r2=76232
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Fri Jul 20 23:07:07 2007
@@ -805,7 +805,7 @@
#define SIP_PROG_INBAND_NO (1 << 25)
#define SIP_PROG_INBAND_YES (2 << 25)
-#define SIP_NO_HISTORY (1 << 27) /*!< Suppress recording
request/response history */
+#define __SIP_NO_HISTORY (1 << 27) /*!< Suppress recording
request/response history */
#define SIP_CALL_LIMIT (1 << 28) /*!< Call limit enforced for
this call */
#define SIP_SENDRPID (1 << 29) /*!< Remote Party-ID Support */
#define SIP_INC_COUNT (1 << 30) /*!< Did this connection
increment the counter of in-use calls? */
@@ -1009,6 +1009,10 @@
ast_group_t pickupgroup; /*!< Pickup group */
int lastinvite; /*!< Last Cseq of invite */
struct ast_flags flags[2]; /*!< SIP_ flags */
+
+ /* boolean or small integers that don't belong in flags */
+ char do_history; /*!< Set if we want to record
history */
+
int timer_t1; /*!< SIP timer T1, ms rtt */
unsigned int sipoptions; /*!< Supported SIP options on
the other end */
struct ast_codec_pref prefs; /*!< codec prefs */
@@ -2258,11 +2262,6 @@
}
}
-static inline int record_history(const struct sip_pvt *p)
-{
- return !ast_test_flag(&p->flags[0], SIP_NO_HISTORY);
-}
-
/*! \brief Append to SIP dialog history with arg list */
static void append_history_va(struct sip_pvt *p, const char *fmt, va_list ap)
{
@@ -2270,6 +2269,8 @@
struct sip_history *hist;
int l;
+ if (!p)
+ return;
vsnprintf(buf, sizeof(buf), fmt, ap);
strsep(&c, "\r\n"); /* Trim up everything after \r or \n */
l = strlen(buf) + 1;
@@ -2502,7 +2503,8 @@
}
if (sip_debug_test_pvt(p))
ast_verbose("Scheduling destruction of SIP dialog '%s' in %d ms
(Method: %s)\n", p->callid, ms, sip_methods[p->method].text);
- append_history(p, "SchedDestroy", "%d ms", ms);
+ if (p->do_history)
+ append_history(p, "SchedDestroy", "%d ms", ms);
if (p->autokillid > -1) /* cancel previous schedule, but keep the
reference */
ast_sched_del(sched, p->autokillid);
@@ -2529,6 +2531,7 @@
const char *msg = "Not Found"; /* used only for debugging */
sip_pvt_lock(p);
+
/* If we have an outbound proxy for this dialog, then delete it now
since
the rest of the requests in this dialog needs to follow the routing.
If obforcing is set, we will keep the outbound proxy during the whole
@@ -2651,7 +2654,7 @@
ast_inet_ntoa(dst->sin_addr),
ntohs(dst->sin_port), req->data);
}
- if (record_history(p)) {
+ if (p->do_history) {
struct sip_request tmp;
parse_copy(&tmp, req);
append_history(p, reliable ? "TxRespRel" : "TxResp", "%s / %s -
%s", tmp.data, get_header(&tmp, "CSeq"),
@@ -2682,7 +2685,7 @@
ast_inet_ntoa(dst->sin_addr),
ntohs(dst->sin_port), req->data);
}
- if (record_history(p)) {
+ if (p->do_history) {
struct sip_request tmp;
parse_copy(&tmp, req);
append_history(p, reliable ? "TxReqRel" : "TxReq", "%s / %s -
%s", tmp.data, get_header(&tmp, "CSeq"), sip_methods[tmp.method].text);
@@ -2766,9 +2769,9 @@
* Init pointers to empty string so we never get NULL dereferencing.
* Overwrites the string.
* return 0 on success, other values on error.
-\verbatim
+ * \verbatim
* general form we are expecting is sip[s]:username[:password][;[EMAIL
PROTECTED]:port][;...]
-\endverbatim
+ * \endverbatim
*/
static int parse_uri(char *uri, char *scheme,
char **ret_name, char **pass, char **domain, char **port, char
**options)
@@ -3460,6 +3463,7 @@
ast_debug(1, "Outgoing Call for %s\n", p->username);
res = update_call_counter(p, INC_CALL_RINGING);
+
if (res == -1)
return res;
@@ -4043,7 +4047,7 @@
transmit_request_with_auth(p, SIP_BYE, 0,
XMIT_RELIABLE, 1);
/* Get RTCP quality before end of call */
- if (record_history(p)) {
+ if (p->do_history) {
if (p->rtp)
append_history(p, "RTCPaudio",
"Quality:%s", audioqos);
if (p->vrtp)
@@ -4499,6 +4503,8 @@
else
ast_debug(3, "This channel will not be able to handle
video.\n");
+
+
if (ast_test_flag(&i->flags[0], SIP_DTMF) == SIP_DTMF_INBAND) {
i->vad = ast_dsp_new();
ast_dsp_set_features(i->vad, DSP_FEATURE_DTMF_DETECT);
@@ -4575,7 +4581,8 @@
tmp = NULL;
}
- append_history(i, "NewChan", "Channel %s - from %s", tmp->name,
i->callid);
+ if (i->do_history)
+ append_history(i, "NewChan", "Channel %s - from %s", tmp->name,
i->callid);
/* Inform manager user about new channel and their SIP call ID */
if (global_callevents)
@@ -4662,6 +4669,8 @@
{ "Reject-Contact", "j" },
{ "Request-Disposition", "d" },
{ "Session-Expires", "x" },
+ { "Identity", "y" },
+ { "Identity-Info", "n" },
};
int x;
@@ -4769,10 +4778,10 @@
return &ast_null_frame;
/* We already hold the channel lock */
- if (!p->owner || f->frametype != AST_FRAME_VOICE)
+ if (!p->owner || (f && f->frametype != AST_FRAME_VOICE))
return f;
- if (f->subclass != (p->owner->nativeformats & AST_FORMAT_AUDIO_MASK)) {
+ if (f && f->subclass != (p->owner->nativeformats &
AST_FORMAT_AUDIO_MASK)) {
if (!(f->subclass & p->jointcapability)) {
ast_debug(1, "Bogus frame of format '%s' received from
'%s'!\n",
ast_getformatname(f->subclass), p->owner->name);
@@ -4783,14 +4792,16 @@
ast_set_read_format(p->owner, p->owner->readformat);
ast_set_write_format(p->owner, p->owner->writeformat);
}
+
if ((ast_test_flag(&p->flags[0], SIP_DTMF) == SIP_DTMF_INBAND) &&
p->vad) {
f = ast_dsp_process(p->owner, p->vad, f);
if (f && f->frametype == AST_FRAME_DTMF) {
if (ast_test_flag(&p->t38.t38support,
SIP_PAGE2_T38SUPPORT_UDPTL) && f->subclass == 'f') {
ast_debug(1, "Fax CNG detected on %s\n",
ast->name);
*faxdetect = 1;
- } else
+ } else {
ast_debug(1, "* Detected inband DTMF '%c'\n",
f->subclass);
+ }
}
}
return f;
@@ -4933,7 +4944,7 @@
ast_copy_flags(&p->flags[0], &global_flags[0], SIP_FLAGS_TO_COPY);
ast_copy_flags(&p->flags[1], &global_flags[1], SIP_PAGE2_FLAGS_TO_COPY);
- ast_set2_flag(&p->flags[0], !recordhistory, SIP_NO_HISTORY);
+ p->do_history = recordhistory;
p->branch = ast_random();
make_our_tag(p->tag, sizeof(p->tag));
@@ -6063,7 +6074,7 @@
if (!(p->owner->nativeformats & p->jointcapability) &&
(p->jointcapability & AST_FORMAT_AUDIO_MASK)) {
if (debug) {
char s1[BUFSIZ], s2[BUFSIZ];
- ast_log(LOG_DEBUG, "Oooh, we need to change our audio
formats since our peer supports only %s and not %s\n",
+ ast_debug(1, "Oooh, we need to change our audio formats
since our peer supports only %s and not %s\n",
ast_getformatname_multiple(s1, BUFSIZ,
p->jointcapability),
ast_getformatname_multiple(s2, BUFSIZ,
p->owner->nativeformats));
}
@@ -6218,7 +6229,9 @@
\note If the client indicates that it wishes to know the port we received
from,
it adds ;rport without an argument to the topmost via header. We need to
add the port number (from our point of view) to that parameter.
+\verbatim
We always add ;received=<ip address> to the topmost via header.
+\endverbatim
Received: RFC 3261, rport RFC 3581 */
static int copy_via_headers(struct sip_pvt *p, struct sip_msg_out *req, const
struct sip_request *orig, const char *field)
{
@@ -6379,6 +6392,7 @@
/*! \brief Initialize SIP response, based on SIP request */
static int init_resp(struct sip_msg_out *resp, const char *msg)
{
+ /* Initialize a response */
char *dst = resp->data;
memset(resp, 0, sizeof(*resp));
@@ -6392,10 +6406,11 @@
/*! \brief Initialize SIP request */
static int init_req(struct sip_msg_out *req, int sipmethod, const char *recip)
{
+ /* Initialize a request */
char *dst = req->data;
memset(req, 0, sizeof(*req));
- req->method = sipmethod;
+ req->method = sipmethod;
snprintf(dst, sizeof(req->data) - 4, "%s %s SIP/2.0\r\n",
sip_methods[sipmethod].text, recip);
req->len = strlen(dst);
req->headers++;
@@ -6448,6 +6463,7 @@
} else if (msg[0] != '4' && p->our_contact[0]) {
add_header(resp, "Contact", p->our_contact);
}
+
return 0;
}
@@ -6584,7 +6600,7 @@
{
struct sip_pvt *p = data;
- ast_set_flag(&p->flags[0], SIP_NO_HISTORY);
+ p->do_history = 0; /* XXX do we need it ? isn't already all 0 ? */
return ast_string_field_init(p, 512);
}
@@ -7416,7 +7432,8 @@
add_header(&req, "Supported", SUPPORTED_EXTENSIONS);
if (sipdebug)
add_header(&req, "X-asterisk-Info", "SIP re-invite (External
RTP bridge)");
- append_history(p, "ReInv", "Re-invite sent");
+ if (p->do_history)
+ append_history(p, "ReInv", "Re-invite sent");
if (t38version)
add_t38_sdp(&req, p);
else
@@ -8056,7 +8073,7 @@
r->register_pvt, r->username, r->hostname);
r->register_pvt = pvt_unref(r->register_pvt);
}
-
+
/* Since registry's are only added/removed by the the monitor thread,
this
may be overkill to reference/dereference at all here */
if (sipdebug)
@@ -8160,7 +8177,8 @@
if (!(p = sip_alloc(r->callid, NULL, 0, SIP_REGISTER))) {
ast_log(LOG_WARNING, "Unable to allocate registration
transaction (memory or socket error)\n");
} else {
- append_history(p, "RegistryInit", "Account: [EMAIL
PROTECTED]", r->username, r->hostname);
+ if (p->do_history)
+ append_history(p, "RegistryInit", "Account:
[EMAIL PROTECTED]", r->username, r->hostname);
p->outboundproxy = obproxy_get(p, NULL);
if (create_addr(p, r->hostname)) { /* lookup the
address */
/* Address lookup error, hopefully just a DNS
problem, so retry later */
@@ -14703,7 +14721,8 @@
p->jointcapability = p->capability;
ast_debug(1, "Hm.... No sdp for the moment\n");
}
- append_history(p, "ReInv", "Re-invite received"); /*
This is a response, note what it was for */
+ if (p->do_history) /* This is a response, note what it
was for */
+ append_history(p, "ReInv", "Re-invite
received");
}
}
@@ -15547,23 +15566,26 @@
sip_alreadygone(p);
/* Get RTCP quality before end of call */
- if (record_history(p) || p->owner) {
+ if (p->do_history || p->owner) {
char *audioqos, *videoqos, *textqos;
if (p->rtp) {
audioqos = ast_rtp_get_quality(p->rtp, NULL);
- append_history(p, "RTCPaudio", "Quality:%s", audioqos);
+ if (p->do_history)
+ append_history(p, "RTCPaudio", "Quality:%s",
audioqos);
if (p->owner)
pbx_builtin_setvar_helper(p->owner,
"RTPAUDIOQOS", audioqos);
}
if (p->vrtp) {
videoqos = ast_rtp_get_quality(p->vrtp, NULL);
- append_history(p, "RTCPvideo", "Quality:%s", videoqos);
+ if (p->do_history)
+ append_history(p, "RTCPvideo", "Quality:%s",
videoqos);
if (p->owner)
pbx_builtin_setvar_helper(p->owner,
"RTPVIDEOQOS", videoqos);
}
if (p->trtp) {
textqos = ast_rtp_get_quality(p->trtp, NULL);
- append_history(p, "RTCPtext", "Quality:%s", textqos);
+ if (p->do_history)
+ append_history(p, "RTCPtext", "Quality:%s",
textqos);
if (p->owner)
pbx_builtin_setvar_helper(p->owner,
"RTPTEXTQOS", textqos);
}
@@ -18334,7 +18356,8 @@
}
if (changed && !ast_test_flag(&p->flags[0], SIP_GOTREFER)) {
if (chan->_state != AST_STATE_UP) { /* We are in early
state */
- append_history(p, "ExtInv", "Initial invite sent with
remote bridge proposal.");
+ if (p->do_history)
+ append_history(p, "ExtInv", "Initial invite
sent with remote bridge proposal.");
ast_debug(1, "Early remote bridge setting SIP '%s' -
Sending media to %s\n", p->callid, ast_inet_ntoa(rtp ? p->redirip.sin_addr :
p->ourip.sin_addr));
} else if (!p->pendinginvite) { /* We are up, and have
no outstanding invite */
ast_debug(3, "Sending reinvite on SIP '%s' - It's audio
soon redirected to IP %s\n", p->callid, ast_inet_ntoa(rtp ? p->redirip.sin_addr
: p->ourip.sin_addr));
_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--
svn-commits mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/svn-commits