Commit 0638801f authored by Kai Vehmanen's avatar Kai Vehmanen

Improve error handling in STUN test server.

darcs-hash:20070720213137-77cd4-b5233e9b34fec1e42c49fa98551c78a3499cf579.gz
parent f0260d6b
...@@ -139,7 +139,7 @@ error: ...@@ -139,7 +139,7 @@ error:
} }
static inline int err_dequeue (int fd) static int err_dequeue (int fd)
{ {
#ifdef MSG_ERRQUEUE #ifdef MSG_ERRQUEUE
struct msghdr hdr; struct msghdr hdr;
...@@ -149,13 +149,12 @@ static inline int err_dequeue (int fd) ...@@ -149,13 +149,12 @@ static inline int err_dequeue (int fd)
} }
#include "stun-msg.h" // FIXME: remove
#include "bind.h" #include "bind.h"
static int dgram_process (int sock) static int dgram_process (int sock)
{ {
struct sockaddr_storage addr; struct sockaddr_storage addr;
stun_msg_t buf; uint8_t buf[1500];
char ctlbuf[CMSG_SPACE (sizeof (struct in6_pktinfo))]; char ctlbuf[CMSG_SPACE (sizeof (struct in6_pktinfo))];
struct iovec iov = { buf, sizeof (buf) }; struct iovec iov = { buf, sizeof (buf) };
struct msghdr mh; struct msghdr mh;
...@@ -171,15 +170,12 @@ static int dgram_process (int sock) ...@@ -171,15 +170,12 @@ static int dgram_process (int sock)
ssize_t len = recvmsg (sock, &mh, 0); ssize_t len = recvmsg (sock, &mh, 0);
if (len < 0) if (len < 0)
{ {
DBG ("Receive error: %s\n", strerror (errno)); err_dequeue (sock);
return -1; return -1;
} }
if (mh.msg_flags & MSG_TRUNC) if (mh.msg_flags & MSG_TRUNC)
{
DBG ("Truncated datagram ignored.\n");
return -1; return -1;
}
if (stun_validate (buf, len) <= 0) if (stun_validate (buf, len) <= 0)
return -1; return -1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment