summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2007-01-21 23:56:48 +0000
committerMarcel Holtmann <marcel@holtmann.org>2007-01-21 23:56:48 +0000
commitb4ccc4c8dec3b4421f5f644424103eb0274d446a (patch)
treede1ca2e78620fd45f790d3980a85801887b7f743 /test
parent137a41351e834e4ca98edbfdb40c4726dc3d2f04 (diff)
Check socket address to get the dynamic PSM and channel values
Diffstat (limited to 'test')
-rw-r--r--test/l2test.c12
-rw-r--r--test/rctest.c14
2 files changed, 25 insertions, 1 deletions
diff --git a/test/l2test.c b/test/l2test.c
index c7155e73..733c0524 100644
--- a/test/l2test.c
+++ b/test/l2test.c
@@ -370,6 +370,18 @@ static void do_listen(void (*handler)(int sk))
goto error;
}
+ /* Check for socket address */
+ memset(&addr, 0, sizeof(addr));
+ optlen = sizeof(addr);
+
+ if (getsockname(sk, (struct sockaddr *) &addr, &optlen) < 0) {
+ syslog(LOG_ERR, "Can't get socket name: %s (%d)",
+ strerror(errno), errno);
+ goto error;
+ }
+
+ psm = btohs(addr.l2_psm);
+
syslog(LOG_INFO, "Waiting for connection on psm %d ...", psm);
while(1) {
diff --git a/test/rctest.c b/test/rctest.c
index ff3b50e8..80117d23 100644
--- a/test/rctest.c
+++ b/test/rctest.c
@@ -206,7 +206,19 @@ static void do_listen(void (*handler)(int sk))
goto error;
}
- syslog(LOG_INFO,"Waiting for connection on channel %d ...", channel);
+ /* Check for socket address */
+ memset(&addr, 0, sizeof(addr));
+ optlen = sizeof(addr);
+
+ if (getsockname(sk, (struct sockaddr *) &addr, &optlen) < 0) {
+ syslog(LOG_ERR, "Can't get socket name: %s (%d)",
+ strerror(errno), errno);
+ goto error;
+ }
+
+ channel = addr.rc_channel;
+
+ syslog(LOG_INFO, "Waiting for connection on channel %d ...", channel);
while(1) {
memset(&addr, 0, sizeof(addr));