summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2008-06-23 18:45:52 +0000
committerMarcel Holtmann <marcel@holtmann.org>2008-06-23 18:45:52 +0000
commit5b675858211437ea5d42ca49bbfbe15aeece65a9 (patch)
treec5254df8dde730696d57cbaad4aa0b100dc9f8d5
parent30ea633a54cbc0b3352f026d8f3f039eae25d472 (diff)
Add timestamp option
-rw-r--r--test/l2test.c34
-rw-r--r--test/rctest.c32
2 files changed, 61 insertions, 5 deletions
diff --git a/test/l2test.c b/test/l2test.c
index 8338886c..fffa7fd8 100644
--- a/test/l2test.c
+++ b/test/l2test.c
@@ -94,6 +94,7 @@ static int secure = 0;
static int socktype = SOCK_SEQPACKET;
static int linger = 0;
static int reliable = 0;
+static int timestamp = 0;
static float tv2fl(struct timeval tv)
{
@@ -221,6 +222,17 @@ static int do_connect(char *svr)
goto error;
}
+ /* Enable SO_TIMESTAMP */
+ if (timestamp) {
+ int t = 1;
+
+ if (setsockopt(sk, SOL_SOCKET, SO_TIMESTAMP, &t, sizeof(t)) < 0) {
+ syslog(LOG_ERR, "Can't enable SO_TIMESTAMP: %s (%d)",
+ strerror(errno), errno);
+ goto error;
+ }
+ }
+
/* Enable SO_LINGER */
if (linger) {
struct linger l = { .l_onoff = 1, .l_linger = linger };
@@ -228,7 +240,7 @@ static int do_connect(char *svr)
if (setsockopt(sk, SOL_SOCKET, SO_LINGER, &l, sizeof(l)) < 0) {
syslog(LOG_ERR, "Can't enable SO_LINGER: %s (%d)",
strerror(errno), errno);
- return -1;
+ goto error;
}
}
@@ -431,6 +443,17 @@ 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]);
+ /* Enable SO_TIMESTAMP */
+ if (timestamp) {
+ int t = 1;
+
+ if (setsockopt(sk, SOL_SOCKET, SO_TIMESTAMP, &t, sizeof(t)) < 0) {
+ syslog(LOG_ERR, "Can't enable SO_TIMESTAMP: %s (%d)",
+ strerror(errno), errno);
+ goto error;
+ }
+ }
+
/* Enable SO_LINGER */
if (linger) {
struct linger l = { .l_onoff = 1, .l_linger = linger };
@@ -821,7 +844,8 @@ static void usage(void)
"\t[-A] request authentication\n"
"\t[-E] request encryption\n"
"\t[-S] secure connection\n"
- "\t[-M] become master\n");
+ "\t[-M] become master\n"
+ "\t[-T] enable timestamps\n");
}
int main(int argc, char *argv[])
@@ -831,7 +855,7 @@ int main(int argc, char *argv[])
bacpy(&bdaddr, BDADDR_ANY);
- while ((opt=getopt(argc,argv,"rdscuwmnxyzb:i:P:I:O:B:N:L:C:D:X:RGAESM")) != EOF) {
+ while ((opt=getopt(argc,argv,"rdscuwmnxyzb:i:P:I:O:B:N:L:C:D:X:RGAESMT")) != EOF) {
switch(opt) {
case 'r':
mode = RECV;
@@ -954,6 +978,10 @@ int main(int argc, char *argv[])
socktype = SOCK_DGRAM;
break;
+ case 'T':
+ timestamp = 1;
+ break;
+
default:
usage();
exit(1);
diff --git a/test/rctest.c b/test/rctest.c
index 1ee4827b..2e366c72 100644
--- a/test/rctest.c
+++ b/test/rctest.c
@@ -79,6 +79,7 @@ static int encrypt = 0;
static int secure = 0;
static int socktype = SOCK_STREAM;
static int linger = 0;
+static int timestamp = 0;
static float tv2fl(struct timeval tv)
{
@@ -100,6 +101,17 @@ static int do_connect(char *svr)
return -1;
}
+ /* Enable SO_TIMESTAMP */
+ if (timestamp) {
+ int t = 1;
+
+ if (setsockopt(sk, SOL_SOCKET, SO_TIMESTAMP, &t, sizeof(t)) < 0) {
+ syslog(LOG_ERR, "Can't enable SO_TIMESTAMP: %s (%d)",
+ strerror(errno), errno);
+ goto error;
+ }
+ }
+
/* Enable SO_LINGER */
if (linger) {
struct linger l = { .l_onoff = 1, .l_linger = linger };
@@ -254,6 +266,17 @@ static void do_listen(void (*handler)(int sk))
ba, conn.hci_handle,
conn.dev_class[2], conn.dev_class[1], conn.dev_class[0]);
+ /* Enable SO_TIMESTAMP */
+ if (timestamp) {
+ int t = 1;
+
+ if (setsockopt(sk, SOL_SOCKET, SO_TIMESTAMP, &t, sizeof(t)) < 0) {
+ syslog(LOG_ERR, "Can't enable SO_TIMESTAMP: %s (%d)",
+ strerror(errno), errno);
+ goto error;
+ }
+ }
+
/* Enable SO_LINGER */
if (linger) {
struct linger l = { .l_onoff = 1, .l_linger = linger };
@@ -448,7 +471,8 @@ static void usage(void)
"\t[-A] request authentication\n"
"\t[-E] request encryption\n"
"\t[-S] secure connection\n"
- "\t[-M] become master\n");
+ "\t[-M] become master\n"
+ "\t[-T] enable timestamps\n");
}
int main(int argc, char *argv[])
@@ -458,7 +482,7 @@ int main(int argc, char *argv[])
bacpy(&bdaddr, BDADDR_ANY);
- while ((opt=getopt(argc,argv,"rdscuwmnb:i:P:B:N:MAESL:C:D:")) != EOF) {
+ while ((opt=getopt(argc,argv,"rdscuwmnb:i:P:B:N:MAESL:C:D:T")) != EOF) {
switch (opt) {
case 'r':
mode = RECV;
@@ -548,6 +572,10 @@ int main(int argc, char *argv[])
delay = atoi(optarg) * 1000;
break;
+ case 'T':
+ timestamp = 1;
+ break;
+
default:
usage();
exit(1);