[asterisk-commits] rizzo: branch rizzo/astobj2 r47939 -
/team/rizzo/astobj2/channels/chan_sip.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Wed Nov 22 11:39:06 MST 2006
Author: rizzo
Date: Wed Nov 22 12:39:05 2006
New Revision: 47939
URL: http://svn.digium.com/view/asterisk?view=rev&rev=47939
Log:
start simplifying handle_request() - localization of variables and so on.
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=47939&r1=47938&r2=47939
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Wed Nov 22 12:39:05 2006
@@ -14962,28 +14962,23 @@
{
/* Called with p->lock held, as well as p->owner->lock if appropriate, keeping things
relatively static */
- const char *cmd;
- const char *cseq;
- const char *useragent;
+ const char *cseq = get_header(req, "Cseq");
int seqno;
int len;
- int respid;
int res = 0;
int debug = sip_debug_test_pvt(p);
- char *e;
int error = 0;
+ char *e = req->rlPart2;
/* Get Method and Cseq */
- cseq = get_header(req, "Cseq");
- cmd = req->header[0];
/* Must have Cseq */
- if (ast_strlen_zero(cmd) || ast_strlen_zero(cseq)) {
+ if (ast_strlen_zero(req->header[0]) || ast_strlen_zero(cseq)) {
ast_log(LOG_ERROR, "Missing Cseq. Dropping this SIP message, it's incomplete.\n");
error = 1;
}
if (!error && sscanf(cseq, "%d%n", &seqno, &len) != 1) {
- ast_log(LOG_ERROR, "No seqno in '%s'. Dropping incomplete message.\n", cmd);
+ ast_log(LOG_ERROR, "No seqno in '%s'. Dropping incomplete message.\n", req->header[0]);
error = 1;
}
if (error) {
@@ -14991,18 +14986,18 @@
set_destroy(p); /* Make sure we destroy this dialog */
return -1;
}
- /* Get the command XXX */
-
- cmd = req->rlPart1;
- e = req->rlPart2;
-
- /* Save useragent of the client */
- useragent = get_header(req, "User-Agent");
- if (!ast_strlen_zero(useragent))
- ast_string_field_set(p, useragent, useragent);
+
+ if (1) {
+ /* Save useragent of the client */
+ /* XXX I doubt this belongs here, because we have not validated sequence numbers yet. */
+ const char *useragent = get_header(req, "User-Agent");
+ if (!ast_strlen_zero(useragent))
+ ast_string_field_set(p, useragent, useragent);
+ }
/* Find out SIP method for incoming request */
if (req->method == SIP_RESPONSE) { /* Response to our request */
+ int respid;
/* When we get here, we know this is a SIP dialog where we've sent
a request and have a response, or at least get a response
within an existing dialog */
@@ -15036,7 +15031,7 @@
p->method = req->method; /* Find out which SIP method they are using */
if (option_debug > 3)
- ast_log(LOG_DEBUG, "**** Received %s (%d) - Command in SIP %s\n", sip_methods[p->method].text, sip_methods[p->method].id, cmd);
+ ast_log(LOG_DEBUG, "**** Received %s (%d) - Command in SIP %s\n", sip_methods[p->method].text, sip_methods[p->method].id, req->rlPart1);
if (p->icseq && (p->icseq > seqno)) {
if (option_debug)
@@ -15069,7 +15064,7 @@
gettag(req, "From", tag, sizeof(tag));
ast_string_field_set(p, theirtag, tag);
}
- snprintf(p->lastmsg, sizeof(p->lastmsg), "Rx: %s", cmd);
+ snprintf(p->lastmsg, sizeof(p->lastmsg), "Rx: %s", req->rlPart1);
if (pedanticsipchecking) {
/* If this is a request packet without a from tag, it's not
@@ -15148,7 +15143,7 @@
default:
transmit_response_with_allow(p, "501 Method Not Implemented", req, 0);
ast_log(LOG_NOTICE, "Unknown SIP command '%s' from '%s'\n",
- cmd, ast_inet_ntoa(p->sa.sin_addr));
+ req->rlPart1, ast_inet_ntoa(p->sa.sin_addr));
/* If this is some new method, and we don't have a call, destroy it now */
if (!p->initreq.headers)
set_destroy(p);
More information about the asterisk-commits
mailing list