summaryrefslogtreecommitdiff
path: root/lib/udp.c
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordberg.se>2013-05-15 15:39:20 +0200
committerLinus Nordberg <linus@nordberg.se>2013-05-15 15:39:20 +0200
commitf8207d6d51b665d6af54262c593372dd73eae0d0 (patch)
tree2cb6ac122f8566566ca9bfb4efd5b0e4c1eddbfb /lib/udp.c
parentfba1c7d1a6418221a94965d0431bf7df0a9a74a0 (diff)
parent65b62d83ee72012d1171f1813b8f989f8805497c (diff)
Merge branch 'libradsec' into libradsec-server-support
Conflicts: lib/HACKING lib/Makefile.am lib/README lib/compat.h lib/conf.c lib/configure.ac lib/conn.c lib/conn.h lib/err.c lib/err.h lib/event.c lib/event.h lib/examples/Makefile.am lib/examples/client-blocking.c lib/examples/client.conf lib/include/radsec/radsec-impl.h lib/include/radsec/radsec.h lib/include/radsec/request-impl.h lib/include/radsec/request.h lib/packet.c lib/packet.h lib/peer.c lib/peer.h lib/request.c lib/send.c lib/tcp.c lib/tests/Makefile.am lib/tls.c lib/udp.c lib/util.c
Diffstat (limited to 'lib/udp.c')
-rw-r--r--lib/udp.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/lib/udp.c b/lib/udp.c
index de78fed..0512d7b 100644
--- a/lib/udp.c
+++ b/lib/udp.c
@@ -1,5 +1,5 @@
/* Copyright 2011,2013 NORDUnet A/S. All rights reserved.
- See LICENSE for licensing information. */
+ See LICENSE for licensing information. */
#if defined HAVE_CONFIG_H
#include <config.h>
@@ -64,15 +64,15 @@ _evcb (evutil_socket_t fd, short what, void *user_data)
{
int err;
struct rs_message *msg = (struct rs_message *) user_data;
- assert (msg);
- assert (msg->conn);
rs_debug (("%s: fd=%d what =", __func__, fd));
- if (what & EV_TIMEOUT) rs_debug ((" TIMEOUT"));
+ if (what & EV_TIMEOUT) rs_debug ((" TIMEOUT -- shouldn't happen!"));
if (what & EV_READ) rs_debug ((" READ"));
if (what & EV_WRITE) rs_debug ((" WRITE"));
rs_debug (("\n"));
+ assert (msg);
+ assert (msg->conn);
if (what & EV_READ)
{
/* Read a single UDP packet and stick it in the struct
@@ -91,7 +91,7 @@ _evcb (evutil_socket_t fd, short what, void *user_data)
/* FIXME: Really shouldn't happen since we've been told
that fd is readable! */
rs_debug (("%s: EAGAIN reading UDP packet -- wot?"));
- return;
+ goto err_out;
}
/* Hard error. */
@@ -99,23 +99,21 @@ _evcb (evutil_socket_t fd, short what, void *user_data)
"%d: recv: %d (%s)", fd, sockerr,
evutil_socket_error_to_string (sockerr));
event_del (msg->conn->tev);
- return;
+ goto err_out;
}
event_del (msg->conn->tev);
if (r < 20 || r > RS_MAX_PACKET_LEN) /* Short or long packet. */
{
rs_err_conn_push (msg->conn, RSE_INVALID_MSG,
- "invalid message length: %d",
- msg->rpkt->length);
- return;
+ "invalid message length: %d", r);
+ goto err_out;
}
msg->rpkt->length = (msg->rpkt->data[2] << 8) + msg->rpkt->data[3];
err = nr_packet_ok (msg->rpkt);
if (err)
{
- rs_err_conn_push_fl (msg->conn, err, __FILE__, __LINE__,
- "invalid message");
- return;
+ rs_err_conn_push (msg->conn, -err, "invalid message");
+ goto err_out;
}
/* Hand over message to user. This changes ownership of msg.
Don't touch it afterwards -- it might have been freed. */
@@ -142,11 +140,10 @@ _evcb (evutil_socket_t fd, short what, void *user_data)
if (msg->conn->callbacks.sent_cb)
msg->conn->callbacks.sent_cb (msg->conn->base_.user_data);
}
+ return;
-#if defined (DEBUG)
- if (what & EV_TIMEOUT)
- rs_debug (("%s: timeout on UDP event, shouldn't happen\n", __func__));
-#endif
+ err_out:
+ rs_conn_disconnect (msg->conn);
}
int