summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Pelly <npelly@google.com>2009-09-15 08:22:01 -0700
committerNick Pelly <npelly@google.com>2009-09-15 08:22:01 -0700
commitfcdaefeec9091b104adfd3ba967bdebe14c34cdf (patch)
tree3677914b03beb3569cf5007405840c1d272db61c
parentf95f92bccbeb441bfc20479f65f5c079a371cca7 (diff)
downloadbluetooth-fcdaefeec9091b104adfd3ba967bdebe14c34cdf.tar.gz
Change-Id: I4a4f00cca3569c62770b323a24b1754873778e91
-rw-r--r--tools/Android.mk53
-rw-r--r--tools/sock_shutdown_bug_rfcomm.c56
-rw-r--r--tools/sock_shutdown_bug_tcp.c63
3 files changed, 152 insertions, 20 deletions
diff --git a/tools/Android.mk b/tools/Android.mk
index 4d2cf10..2ad7540 100644
--- a/tools/Android.mk
+++ b/tools/Android.mk
@@ -79,6 +79,59 @@ LOCAL_MODULE := sock_shutdown_test
include $(BUILD_EXECUTABLE)
#
+# sock_shutdown_bug_l2cap
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := sock_shutdown_bug_l2cap.c
+
+LOCAL_C_INCLUDES := \
+ $(LOCAL_PATH)/../bluez-clean-headers
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE := sock_shutdown_bug_l2cap
+
+LOCAL_SHARED_LIBRARIES := libbluetooth
+
+include $(BUILD_EXECUTABLE)
+
+#
+# sock_shutdown_bug_rfcomm
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := sock_shutdown_bug_rfcomm.c
+
+LOCAL_C_INCLUDES := \
+ $(LOCAL_PATH)/../bluez-clean-headers
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE := sock_shutdown_bug_rfcomm
+
+LOCAL_SHARED_LIBRARIES := libbluetooth
+
+include $(BUILD_EXECUTABLE)
+
+#
+# sock_shutdown_bug_tcp
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := sock_shutdown_bug_tcp.c
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE := sock_shutdown_bug_tcp
+
+LOCAL_SHARED_LIBRARIES := libbluetooth
+
+include $(BUILD_EXECUTABLE)
+#
# pipetest
#
diff --git a/tools/sock_shutdown_bug_rfcomm.c b/tools/sock_shutdown_bug_rfcomm.c
index d0a18de..7c4a37f 100644
--- a/tools/sock_shutdown_bug_rfcomm.c
+++ b/tools/sock_shutdown_bug_rfcomm.c
@@ -19,29 +19,45 @@
#include <unistd.h>
#include <sys/socket.h>
#include <fcntl.h>
+#include <errno.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/rfcomm.h>
int main(int argc, char **argv) {
- int fd;
- int ret;
- long flags;
- struct sockaddr_rc addr;
-
- addr.rc_family = AF_BLUETOOTH;
- addr.rc_channel = 19;
- str2ba("00:17:E8:2C:A8:00", &addr.rc_bdaddr);
-
- fd = socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
- flags = fcntl(fd, F_GETFL);
- fcntl(fd, F_SETFL, flags | O_NONBLOCK);
-
- connect(fd, (struct sockaddr *)&addr, sizeof(addr));
-
- sleep(2);
- shutdown(fd, SHUT_RDWR);
- sleep(2);
- close(fd);
- return 0;
+ int fd;
+ int ret;
+ long flags;
+ struct sockaddr_rc addr;
+
+ addr.rc_family = AF_BLUETOOTH;
+ addr.rc_channel = 19;
+ str2ba("00:17:E8:2C:A8:00", &addr.rc_bdaddr);
+
+ fd = socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
+ flags = fcntl(fd, F_GETFL);
+ fcntl(fd, F_SETFL, flags | O_NONBLOCK);
+
+ ret = connect(fd, (struct sockaddr *)&addr, sizeof(addr));
+ if (ret < 0) {
+ printf("%d errno %d %s\n", __LINE__, errno, strerror(errno));
+ }
+
+ sleep(2);
+ shutdown(fd, SHUT_RDWR);
+
+
+ fd = socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
+
+ ret = connect(fd, (struct sockaddr *)&addr, sizeof(addr));
+ if (ret < 0) {
+ printf("%d errno %d %s\n", __LINE__, errno, strerror(errno));
+ }
+
+ sleep(2);
+
+ shutdown(fd, SHUT_RDWR);
+
+ sleep(2);
+ return 0;
}
diff --git a/tools/sock_shutdown_bug_tcp.c b/tools/sock_shutdown_bug_tcp.c
new file mode 100644
index 0000000..6333320
--- /dev/null
+++ b/tools/sock_shutdown_bug_tcp.c
@@ -0,0 +1,63 @@
+/*
+** Copyright 2009 The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/socket.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <netinet/in.h>
+
+int main(int argc, char **argv) {
+ int fd;
+ int ret;
+ long flags;
+ struct sockaddr_in addr;
+
+ addr.sin_family = AF_INET;
+ addr.sin_port = 12348;
+
+ fd = socket(PF_INET, SOCK_STREAM, 0);
+
+ ret = bind(fd, (struct sockaddr *)&addr, sizeof(addr));
+ if (ret < 0) {
+ printf("%d errno %d %s\n", __LINE__, errno, strerror(errno));
+ }
+
+ ret = listen(fd, 1);
+ if (ret < 0) {
+ printf("%d errno %d %s\n", __LINE__, errno, strerror(errno));
+ }
+
+ sleep(2);
+
+ close(fd);
+
+ sleep(2);
+
+ fd = socket(PF_INET, SOCK_STREAM, 0);
+
+ ret = bind(fd, (struct sockaddr *)&addr, sizeof(addr));
+ if (ret < 0) {
+ printf("%d errno %d %s\n", __LINE__, errno, strerror(errno));
+ }
+
+ sleep(2000000000);
+
+ return 0;
+}
+