*c = 0;
if (sipdebug && option_debug > 3)
- ast_log(LOG_DEBUG, "Header: %s (%d)\n", req->header[f], (int) strlen(req->header[f]));
+ ast_log(LOG_DEBUG, "Header %d: %s (%d)\n", f, req->header[f], (int) strlen(req->header[f]));
if (ast_strlen_zero(req->header[f])) {
/* Line by itself means we're now in content */
c++;
c++;
}
/* Check for last header */
- if (!ast_strlen_zero(req->header[f]))
+ if (!ast_strlen_zero(req->header[f])) {
+ if (sipdebug && option_debug > 3)
+ ast_log(LOG_DEBUG, "Header %d: %s (%d)\n", f, req->header[f], (int) strlen(req->header[f]));
f++;
+ }
req->headers = f;
/* Now we process any mime content */
f = 0;
char iabuf[INET_ADDRSTRLEN];
int debug = sip_debug_test_pvt(p);
char *e;
+ int error = 0;
/* Clear out potential response */
memset(&resp, 0, sizeof(resp));
cmd = req->header[0];
/* Must have Cseq */
- if (ast_strlen_zero(cmd) || ast_strlen_zero(cseq))
- return -1;
- if (sscanf(cseq, "%d%n", &seqno, &len) != 1) {
- ast_log(LOG_DEBUG, "No seqno in '%s'\n", cmd);
+ if (ast_strlen_zero(cmd) || 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);
+ error = 1;
+ }
+ if (error) {
+ if (!p->initreq.header) /* New call */
+ ast_set_flag(p, SIP_NEEDDESTROY); /* Make sure we destroy this dialog */
return -1;
}
/* Get the command XXX */
ast_log(LOG_WARNING, "Recv error: %s\n", strerror(errno));
return 1;
}
+ if (res == sizeof(req.data)) {
+ ast_log(LOG_DEBUG, "Received packet exceeds buffer. Data is possibly lost\n");
+ }
req.data[res] = '\0';
req.len = res;
if(sip_debug_test_addr(&sin))
append_history(p, "Rx", tmp);
}
nounlock = 0;
- handle_request(p, &req, &sin, &recount, &nounlock);
+ if (handle_request(p, &req, &sin, &recount, &nounlock) == -1) {
+ /* Request failed */
+ ast_log(LOG_DEBUG, "SIP message could not be handled, bad request: %-70.70s\n", p->callid[0] ? p->callid : "<no callid>");
+ }
+
if (p->owner && !nounlock)
ast_mutex_unlock(&p->owner->lock);
ast_mutex_unlock(&p->lock);