Index: chan_sip.c =================================================================== --- chan_sip.c (revision 189266) +++ chan_sip.c (working copy) @@ -2853,6 +2853,24 @@ ast_str_append(&req.data, 0, "%s", buf); req.len = req.data->used; } + /* i have seen this with a softphone that brodcast every five sec. SIP dummy messages as NAT opener + and the content was just "\r\n" which was bufferd in the buf before and then we get SIP messages with + a extra blank line at the beginning. This blank line then totally confuses the following parser with the + result that no incoming call were possibly. So i just check if the first line is a blank line, and remove it. + */ + if (strncmp(req.data->str, "\r\n", 2) == 0) { + ast_log(LOG_WARNING, "There was a blank line at the top this message and i removed it. Probably this is because your phone sent us brocken SIP dummy packages before\n"); + /* + int i; + for (i=0 ; req.data->str[i] != '\0' ; i++) { + req.data->str[i] = req.data->str[i+2]; + } + * choose which one is better, the loop or the strstr/strcpy variant + */ + strcpy(req.data->str, strstr(req.data->str, "\r\n") + 2 ); + req.data->used = req.data->used -2; + req.len = req.data->used; + } copy_request(&reqcpy, &req); parse_request(&reqcpy); /* In order to know how much to read, we need the content-length header */