+/* Copyright 2011,2013, NORDUnet A/S. All rights reserved. */
+/* See LICENSE for licensing information. */
+
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <netdb.h>
#include <sys/select.h>
#include <sys/time.h>
+#include "radius/client.h"
#include "udp.h"
static struct addrinfo *
return rp;
}
+void
+udp_free_polldata (struct polldata *data)
+{
+ if (data)
+ {
+ if (data->timeout)
+ free (data->timeout);
+ free (data);
+ }
+}
+
+/* @return if select() returns error or timeout, return select()
+ else return value from invoked callback function */
ssize_t
udp_poll (struct polldata *data)
{
int r;
- long timeout;
+ long timeout = 0;
fd_set rfds;
ssize_t len;
- uint8_t buf[4096];
+ uint8_t buf[RS_MAX_PACKET_LEN];
FD_ZERO (&rfds);
FD_SET (data->s, &rfds);
return NULL;
}
+
+ssize_t
+hd (const uint8_t *buf, ssize_t len)
+{
+ int i;
+
+ printf ("# len: %ld\n", len);
+ for (i = 0; i < len; i++)
+ {
+ printf ("%02x%s", buf[i], (i+1) % 8 ? " " : " ");
+ if ((i + 1) % 16 == 0)
+ printf ("\n");
+ }
+ printf ("\n");
+ return len;
+}