summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test/l2test.c24
-rw-r--r--test/rctest.c27
2 files changed, 46 insertions, 5 deletions
diff --git a/test/l2test.c b/test/l2test.c
index acf4a23c..a6ff75fa 100644
--- a/test/l2test.c
+++ b/test/l2test.c
@@ -38,6 +38,7 @@
#include <signal.h>
#include <sys/time.h>
#include <sys/poll.h>
+#include <sys/ioctl.h>
#include <sys/socket.h>
#include <bluetooth/bluetooth.h>
@@ -222,6 +223,7 @@ static int do_connect(char *svr)
goto error;
}
+#if 0
/* Enable SO_TIMESTAMP */
if (timestamp) {
int t = 1;
@@ -232,6 +234,7 @@ static int do_connect(char *svr)
goto error;
}
}
+#endif
/* Enable SO_LINGER */
if (linger) {
@@ -443,6 +446,7 @@ static void do_listen(void (*handler)(int sk))
ba, opts.imtu, opts.omtu, opts.flush_to, opts.mode, conn.hci_handle,
conn.dev_class[2], conn.dev_class[1], conn.dev_class[0]);
+#if 0
/* Enable SO_TIMESTAMP */
if (timestamp) {
int t = 1;
@@ -453,6 +457,7 @@ static void do_listen(void (*handler)(int sk))
goto error;
}
}
+#endif
/* Enable SO_LINGER */
if (linger) {
@@ -526,12 +531,15 @@ static void recv_mode(int sk)
{
struct timeval tv_beg, tv_end, tv_diff;
struct pollfd p;
+ char ts[30];
long total;
uint32_t seq;
socklen_t optlen;
int opt;
- syslog(LOG_INFO,"Receiving ...");
+ syslog(LOG_INFO, "Receiving ...");
+
+ memset(ts, 0, sizeof(ts));
p.fd = sk;
p.events = POLLIN | POLLERR | POLLHUP;
@@ -572,6 +580,18 @@ static void recv_mode(int sk)
if (len < 6)
break;
+ if (timestamp) {
+ struct timeval tv;
+
+ if (ioctl(sk, SIOCGSTAMP, &tv) < 0) {
+ timestamp = 0;
+ memset(ts, 0, sizeof(ts));
+ } else {
+ sprintf(ts, "[%ld.%ld] ",
+ tv.tv_sec, tv.tv_usec);
+ }
+ }
+
/* Check sequence */
sq = btohl(*(uint32_t *) buf);
if (seq != sq) {
@@ -599,7 +619,7 @@ static void recv_mode(int sk)
timersub(&tv_end, &tv_beg, &tv_diff);
- syslog(LOG_INFO,"%ld bytes in %.2f sec, %.2f kB/s", total,
+ syslog(LOG_INFO,"%s%ld bytes in %.2f sec, %.2f kB/s", ts, total,
tv2fl(tv_diff), (float)(total / tv2fl(tv_diff) ) / 1024.0);
}
}
diff --git a/test/rctest.c b/test/rctest.c
index 2c69b5b2..612855f3 100644
--- a/test/rctest.c
+++ b/test/rctest.c
@@ -36,6 +36,7 @@
#include <syslog.h>
#include <signal.h>
#include <sys/time.h>
+#include <sys/ioctl.h>
#include <sys/socket.h>
#include <bluetooth/bluetooth.h>
@@ -101,6 +102,7 @@ static int do_connect(char *svr)
return -1;
}
+#if 0
/* Enable SO_TIMESTAMP */
if (timestamp) {
int t = 1;
@@ -111,6 +113,7 @@ static int do_connect(char *svr)
goto error;
}
}
+#endif
/* Enable SO_LINGER */
if (linger) {
@@ -266,6 +269,7 @@ static void do_listen(void (*handler)(int sk))
ba, conn.hci_handle,
conn.dev_class[2], conn.dev_class[1], conn.dev_class[0]);
+#if 0
/* Enable SO_TIMESTAMP */
if (timestamp) {
int t = 1;
@@ -276,6 +280,7 @@ static void do_listen(void (*handler)(int sk))
goto error;
}
}
+#endif
/* Enable SO_LINGER */
if (linger) {
@@ -313,11 +318,14 @@ static void dump_mode(int sk)
static void recv_mode(int sk)
{
- struct timeval tv_beg,tv_end,tv_diff;
+ struct timeval tv_beg, tv_end, tv_diff;
+ char ts[30];
long total;
uint32_t seq;
- syslog(LOG_INFO,"Receiving ...");
+ syslog(LOG_INFO, "Receiving ...");
+
+ memset(ts, 0, sizeof(ts));
seq = 0;
while (1) {
@@ -334,6 +342,19 @@ static void recv_mode(int sk)
strerror(errno), errno);
return;
}
+
+ if (timestamp) {
+ struct timeval tv;
+
+ if (ioctl(sk, SIOCGSTAMP, &tv) < 0) {
+ timestamp = 0;
+ memset(ts, 0, sizeof(ts));
+ } else {
+ sprintf(ts, "[%ld.%ld] ",
+ tv.tv_sec, tv.tv_usec);
+ }
+ }
+
#if 0
/* Check sequence */
sq = btohl(*(uint32_t *) buf);
@@ -362,7 +383,7 @@ static void recv_mode(int sk)
timersub(&tv_end,&tv_beg,&tv_diff);
- syslog(LOG_INFO,"%ld bytes in %.2f sec, %.2f kB/s", total,
+ syslog(LOG_INFO,"%s%ld bytes in %.2f sec, %.2f kB/s", ts, total,
tv2fl(tv_diff), (float)(total / tv2fl(tv_diff) ) / 1024.0);
}
}