summaryrefslogtreecommitdiff
path: root/lib/tests/udp.c
diff options
context:
space:
mode:
authorlinus <linus@nordu.net>2011-01-21 16:32:28 +0100
committerlinus <linus@nordu.net>2011-01-21 16:32:28 +0100
commitf58ce3d98a13e9c8d0930b54c5f593cbfa196d65 (patch)
treef20db3c05fa49c3b9ddad748b8a0b9dc6c79404f /lib/tests/udp.c
parent7b928a0509a668b99679a1bbedd189575fe71559 (diff)
Some more UDP tests.
Diffstat (limited to 'lib/tests/udp.c')
-rw-r--r--lib/tests/udp.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/tests/udp.c b/lib/tests/udp.c
index 184325e..a29880a 100644
--- a/lib/tests/udp.c
+++ b/lib/tests/udp.c
@@ -40,6 +40,19 @@ _resolve (const char *str)
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)
{
@@ -106,3 +119,19 @@ udp_server (const char *bindto, struct timeval *timeout, data_cb cb)
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;
+}