Permalink
Browse files

XX-10177: There are some devices that sends more than 4 bytes of CRLF…

… keep-alives and this is not handled properly by the stack. We now simply count CRLF and if the entire buffer is entirely CRLF, we treat it as keep-alive
  • Loading branch information...
1 parent 212fd89 commit 9292dcff9a566ca690cb893bc9da16f36ba182cf Joegen Baclor committed Oct 24, 2012
Showing with 16 additions and 5 deletions.
  1. +16 −5 sipXtackLib/src/net/SipClient.cpp
@@ -716,11 +716,22 @@ int SipClient::run(void* runArg)
// Note that input was processed at this time.
touch();
- if ((res == 2 &&
- readBuffer(0) == '\r' && readBuffer(1) == '\n') ||
- (res == 4 &&
- readBuffer(0) == '\r' && readBuffer(1) == '\n' &&
- readBuffer(2) == '\r' && readBuffer(3) == '\n'))
+ //
+ // Count the CR/LF to see if this is a keep-alive
+ //
+ int crlfCount = 0;
+ for (int i = 0; i < res; i++)
+ {
+ if (readBuffer(i) == '\r' || readBuffer(i) == '\n')
+ {
+ crlfCount++;
+ } else
+ {
+ break;
+ }
+ }
+
+ if (res == crlfCount)
{
repeatedEOFs = 0;
// The 'message' was a keepalive (CR-LF or CR-LF-CR-LF).

0 comments on commit 9292dcf

Please sign in to comment.