Receive buffer size for SIP UDP packets is now configurable.

git-svn-id: http://yate.null.ro/svn/yate/trunk@2468 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2009-02-02 16:09:02 +00:00
parent 8c36cc8fe6
commit 5ff2e4fe80
2 changed files with 17 additions and 4 deletions

View File

@ -7,10 +7,13 @@
; addr: ipaddress: IP address to bind to
;addr=0.0.0.0
; maxpkt: int: Maximum received packet size, 524 to 65528, default 1500
;maxpkt=1500
; buffer: int: Requested size of socket's receive buffer, 0 to use default
;buffer=0
; floodevents: int: How many SIP events retrived in a row trigger flood warning
; floodevents: int: How many SIP events retrieved in a row trigger flood warning
;floodevents=20
; maxforwards: int: Default Max-Forwards header, used to avoid looping calls

View File

@ -321,6 +321,7 @@ private:
Socket* m_sock;
SocketAddr m_addr;
YateSIPEngine *m_engine;
DataBlock m_buffer;
};
class YateSIPRefer : public Thread
@ -1499,7 +1500,16 @@ bool YateSIPEndPoint::Init()
Debug(&plugin,DebugGoOn,"Unable to set non-blocking mode");
return false;
}
Debug(&plugin,DebugCall,"Started on %s:%d", addr.host().safe(), addr.port());
int maxpkt = s_cfg.getIntValue("general","maxpkt");
if (maxpkt <= 0)
maxpkt = 1500;
else if (maxpkt > 65528)
maxpkt = 65528;
else if (maxpkt < 524)
maxpkt = 524;
m_buffer.assign(0,maxpkt);
Debug(&plugin,DebugCall,"Started on %s:%d, max %d bytes",
addr.host().safe(),addr.port(),maxpkt);
if (addr.host() != "0.0.0.0")
m_local = addr.host();
m_port = addr.port();
@ -1536,8 +1546,8 @@ void YateSIPEndPoint::addMessage(const char* buf, int len, const SocketAddr& add
void YateSIPEndPoint::run()
{
struct timeval tv;
char buf[1500];
int evCount = 0;
char* buf = (char*)m_buffer.data();
for (;;)
{
@ -1560,7 +1570,7 @@ void YateSIPEndPoint::run()
if (ok)
{
// we can read the data
int res = m_sock->recvFrom(buf,sizeof(buf)-1,m_addr);
int res = m_sock->recvFrom(buf,m_buffer.length()-1,m_addr);
if (res <= 0) {
if (!m_sock->canRetry()) {
Debug(&plugin,DebugGoOn,"Error on read: %d", m_sock->error());