Ticket #9: 600_win32_bluetooth.patch
| File 600_win32_bluetooth.patch, 11.9 KB (added by hsattler, 18 months ago) |
|---|
-
(a) /dev/null vs. (b) openobex-anoncvs/lib/bluez_compat.h
a b 1 2 /* Here are the defines that make it possible to 3 * implement bluetooth with the Bluez API 4 */ 5 6 #ifdef HAVE_CONFIG_H 7 #include <config.h> 8 #endif 9 10 #ifdef _WIN32 11 /* you need the headers files from the Platform SDK */ 12 #include <winsock2.h> 13 #include <ws2bth.h> 14 #define bdaddr_t BTH_ADDR 15 #define sockaddr_rc _SOCKADDR_BTH 16 #define rc_family addressFamily 17 #define rc_bdaddr btAddr 18 #define rc_channel port 19 #define PF_BLUETOOTH PF_BTH 20 #define AF_BLUETOOTH PF_BLUETOOTH 21 #define BTPROTO_RFCOMM BTHPROTO_RFCOMM 22 #define BDADDR_ANY (&(BTH_ADDR){BTH_ADDR_NULL}) 23 #define bacpy(dst,src) memcpy((dst),(src),sizeof(BTH_ADDR)) 24 #define bacmp(a,b) memcmp((a),(b),sizeof(BTH_ADDR)) 25 26 #else /* _WIN32 */ 27 /* Linux/FreeBSD/NetBSD case */ 28 29 #if defined(HAVE_BLUETOOTH_LINUX) 30 #include <bluetooth/bluetooth.h> 31 #include <bluetooth/rfcomm.h> 32 33 #elif defined(HAVE_BLUETOOTH_FREEBSD) 34 #include <bluetooth.h> 35 #define sockaddr_rc sockaddr_rfcomm 36 #define rc_family rfcomm_family 37 #define rc_bdaddr rfcomm_bdaddr 38 #define rc_channel rfcomm_channel 39 40 #elif defined(HAVE_BLUETOOTH_NETBSD) 41 #include <bluetooth.h> 42 #include <netbt/rfcomm.h> 43 #define sockaddr_rc sockaddr_bt 44 #define rc_family bt_family 45 #define rc_bdaddr bt_bdaddr 46 #define rc_channel bt_channel 47 #define BDADDR_ANY NG_HCI_BDADDR_ANY 48 49 #endif /* HAVE_BLUETOOTH_* */ 50 51 #endif /* _WIN32 */ -
openobex-anoncvs
old new 45 45 #include <errno.h> /* errno and EADDRNOTAVAIL */ 46 46 #include <netinet/in.h> 47 47 #include <sys/socket.h> 48 49 #ifdef HAVE_BLUETOOTH_LINUX50 #include <bluetooth/bluetooth.h>51 #include <bluetooth/rfcomm.h>52 #endif53 #ifdef HAVE_BLUETOOTH_FREEBSD54 #include <bluetooth.h>55 #define sockaddr_rc sockaddr_rfcomm56 #define rc_family rfcomm_family57 #define rc_bdaddr rfcomm_bdaddr58 #define rc_channel rfcomm_channel59 #endif60 #ifdef HAVE_BLUETOOTH_NETBSD61 #define rc_family bt_family62 #define rc_bdaddr bt_bdaddr63 #define rc_channel bt_channel64 #define sockaddr_rc sockaddr_bt65 #include <bluetooth.h>66 #include <netbt/rfcomm.h>67 #endif68 69 48 #endif /* _WIN32 */ 70 49 71 50 #include "obex_main.h" … … 79 58 */ 80 59 void btobex_prepare_connect(obex_t *self, bdaddr_t *src, bdaddr_t *dst, uint8_t channel) 81 60 { 82 #ifndef _WIN3283 61 self->trans.self.rfcomm.rc_family = AF_BLUETOOTH; 84 62 bacpy(&self->trans.self.rfcomm.rc_bdaddr, src); 85 63 self->trans.self.rfcomm.rc_channel = 0; … … 87 65 self->trans.peer.rfcomm.rc_family = AF_BLUETOOTH; 88 66 bacpy(&self->trans.peer.rfcomm.rc_bdaddr, dst); 89 67 self->trans.peer.rfcomm.rc_channel = channel; 90 #endif /* _WIN32 */91 68 } 92 69 93 70 /* … … 98 75 */ 99 76 void btobex_prepare_listen(obex_t *self, bdaddr_t *src, uint8_t channel) 100 77 { 101 #ifndef _WIN32102 78 /* Bind local service */ 103 79 self->trans.self.rfcomm.rc_family = AF_BLUETOOTH; 104 80 bacpy(&self->trans.self.rfcomm.rc_bdaddr, src); 105 81 self->trans.self.rfcomm.rc_channel = channel; 106 #endif /* _WIN32 */107 82 } 108 83 109 84 /* … … 114 89 */ 115 90 int btobex_listen(obex_t *self) 116 91 { 117 #ifndef _WIN32118 92 DEBUG(3, "\n"); 119 93 120 94 self->serverfd = obex_create_socket(self, AF_BLUETOOTH); … … 142 116 out_freesock: 143 117 obex_delete_socket(self, self->serverfd); 144 118 self->serverfd = INVALID_SOCKET; 145 #endif /* _WIN32 */146 119 return -1; 147 120 } 148 121 … … 156 129 */ 157 130 int btobex_accept(obex_t *self) 158 131 { 159 #ifndef _WIN32160 132 socklen_t addrlen = sizeof(struct sockaddr_rc); 161 133 //int mtu; 162 134 //int len = sizeof(int); … … 170 142 } 171 143 172 144 self->trans.mtu = OBEX_DEFAULT_MTU; 173 #endif /* _WIN32 */174 145 return 0; 175 146 } 176 147 … … 183 154 int btobex_connect_request(obex_t *self) 184 155 { 185 156 int ret; 186 #ifndef _WIN32187 157 int mtu = 0; 188 158 //int len = sizeof(int); 189 159 … … 220 190 out_freesock: 221 191 obex_delete_socket(self, self->fd); 222 192 self->fd = INVALID_SOCKET; 223 #endif /* _WIN32 */224 193 return ret; 225 194 } 226 195 … … 233 202 int btobex_disconnect_request(obex_t *self) 234 203 { 235 204 int ret; 236 #ifndef _WIN32237 205 DEBUG(4, "\n"); 238 206 ret = obex_delete_socket(self, self->fd); 239 207 if(ret < 0) 240 208 return ret; 241 209 self->fd = INVALID_SOCKET; 242 #endif /* _WIN32 */243 210 return ret; 244 211 } 245 212 … … 254 221 int btobex_disconnect_server(obex_t *self) 255 222 { 256 223 int ret; 257 #ifndef _WIN32258 224 DEBUG(4, "\n"); 259 225 ret = obex_delete_socket(self, self->serverfd); 260 226 self->serverfd = INVALID_SOCKET; 261 #endif /* _WIN32 */262 227 return ret; 263 228 } 264 229 -
openobex-anoncvs
old new 30 30 #ifndef BTOBEX_H 31 31 #define BTOBEX_H 32 32 33 #include "bluez_compat.h" 34 33 35 void btobex_prepare_connect(obex_t *self, bdaddr_t *src, bdaddr_t *dst, uint8_t channel); 34 36 void btobex_prepare_listen(obex_t *self, bdaddr_t *src, uint8_t channel); 35 37 int btobex_listen(obex_t *self); -
openobex-anoncvs
old new 43 43 #ifdef DLL_EXPORT 44 44 #define LIB_SYMBOL __declspec(dllexport) 45 45 #endif 46 static unsigned long wsa_init = 0; 47 #define WSA_VER_MAJOR 2 48 #define WSA_VER_MINOR 2 46 49 47 50 #else /* _WIN32 */ 48 51 #include <fcntl.h> … … 63 66 #include "obex_client.h" 64 67 65 68 #include "inobex.h" 69 66 70 #ifdef HAVE_IRDA 67 71 #include "irobex.h" 68 72 #endif 73 69 74 #ifdef HAVE_USB 70 75 #include "usbobex.h" 71 76 #endif 77 72 78 #ifdef HAVE_BLUETOOTH 73 79 #include "btobex.h" 74 #ifdef HAVE_BLUETOOTH_FREEBSD75 #define BDADDR_ANY NG_HCI_BDADDR_ANY76 #endif77 80 #else 78 81 // This is to workaround compilation without Bluetooth support. - Jean II 79 82 typedef char *bdaddr_t; … … 126 129 obex_return_val_if_fail(eventcb != NULL, NULL); 127 130 128 131 #ifdef _WIN32 129 { 130 WSADATA WSAData; 131 if (WSAStartup (MAKEWORD(2,0), &WSAData) != 0) { 132 DEBUG(4, "WSAStartup failed\n"); 133 return NULL; 134 } 135 } 132 if (!wsa_init) { 133 WORD ver = MAKEWORD(WSA_VER_MAJOR,WSA_VER_MINOR); 134 WSADATA WSAData; 135 if (WSAStartup (ver, &WSAData) != 0) { 136 DEBUG(4, "WSAStartup failed (%d)\n",WSAGetLastError()); 137 return NULL; 138 } 139 if (LOBYTE(WSAData.wVersion) != WSA_VER_MAJOR || 140 HIBYTE(WSAData.wVersion) != WSA_VER_MINOR) { 141 DEBUG(4, "WSA version mismatch\n"); 142 WSACleanup(); 143 return NULL; 144 } 145 } 146 ++wsa_init; 136 147 #endif 137 148 138 149 self = malloc(sizeof(obex_t)); -
openobex-anoncvs
old new 64 64 ]) 65 65 ]) 66 66 67 AC_DEFUN([AC_PATH_WINBT], [ 68 AC_CACHE_VAL(winbt_found,[ 69 AC_CHECK_HEADERS(ws2bth.h, winbt_found=yes, winbt_found=no, 70 [ 71 #include <winsock2.h> 72 ]) 73 ]) 74 AC_MSG_CHECKING([for Windows Bluetooth support]) 75 AC_MSG_RESULT([$winbt_found]) 76 ]) 77 78 67 79 AC_DEFUN([AC_PATH_NETBSDBT], [ 68 80 AC_CACHE_CHECK([for NetBSD Bluetooth support], netbsdbt_found, [ 69 81 AC_TRY_COMPILE([ … … 85 97 ]) 86 98 87 99 AC_DEFUN([AC_PATH_BLUEZ], [ 88 PKG_CHECK_MODULES(BLUEZ, bluez, bluez_found=yes, AC_MSG_RESULT(no)) 89 AC_SUBST(BLUEZ_CFLAGS) 90 AC_SUBST(BLUEZ_LIBS) 100 PKG_CHECK_MODULES(BLUETOOTH, bluez, bluez_found=yes, AC_MSG_RESULT(no)) 91 101 ]) 92 102 93 103 AC_DEFUN([AC_PATH_BLUETOOTH], [ … … 101 111 *-*-netbsd*) 102 112 AC_PATH_NETBSDBT 103 113 ;; 114 *-*-mingw32*) 115 AC_PATH_WINBT 116 ;; 104 117 esac 118 AC_SUBST(BLUETOOTH_CFLAGS) 119 AC_SUBST(BLUETOOTH_LIBS) 105 120 ]) 106 121 107 122 AC_DEFUN([AC_PATH_USB], [ … … 200 215 AC_DEFINE(HAVE_IRDA, 1, [Define if system supports IrDA and it's enabled]) 201 216 fi 202 217 218 if (test "${bluetooth_enable}" = "yes" && test "${winbt_found}" = "yes"); then 219 AC_DEFINE(HAVE_BLUETOOTH, 1, [Define if system supports Bluetooth and it's enabled]) 220 fi 221 203 222 if (test "${bluetooth_enable}" = "yes" && test "${netbsdbt_found}" = "yes"); then 204 223 AC_DEFINE(HAVE_BLUETOOTH, 1, [Define if system supports Bluetooth and it's enabled]) 205 224 AC_DEFINE(HAVE_BLUETOOTH_NETBSD, 1, [Define if system supports Bluetooth stack for NetBSD]) -
apps/Makefile.am
old new 14 14 obex_test_server.c obex_test_server.h \ 15 15 obex_test_cable.c obex_test_cable.h 16 16 17 obex_test_LDADD = $(top_builddir)/lib/libopenobex.la @BLUE Z_LIBS@ libmisc.a17 obex_test_LDADD = $(top_builddir)/lib/libopenobex.la @BLUETOOTH_LIBS@ libmisc.a 18 18 19 19 LDADD = $(top_builddir)/lib/libopenobex.la libmisc.a 20 20 21 INCLUDES = @BLUE Z_CFLAGS@ -I$(top_builddir)/include21 INCLUDES = @BLUETOOTH_CFLAGS@ -I$(top_builddir)/include 22 22 endif 23 23 24 24 MAINTAINERCLEANFILES = Makefile.in -
lib/obex_transport.h
old new 41 41 #include "irda_wrap.h" 42 42 #endif /*HAVE_IRDA*/ 43 43 #ifdef HAVE_BLUETOOTH 44 #ifdef HAVE_BLUETOOTH_LINUX 45 #include <bluetooth/bluetooth.h> 46 #include <bluetooth/rfcomm.h> 47 #endif 48 #ifdef HAVE_BLUETOOTH_FREEBSD 49 #include <bluetooth.h> 50 #define sockaddr_rc sockaddr_rfcomm 51 #endif 52 #ifdef HAVE_BLUETOOTH_NETBSD 53 #include <bluetooth.h> 54 #include <netbt/rfcomm.h> 55 #endif 44 #include "bluez_compat.h" 56 45 #endif /*HAVE_BLUETOOTH*/ 57 46 #ifdef HAVE_USB 58 47 #include "usbobex.h" … … 66 55 #endif /*HAVE_IRDA*/ 67 56 struct sockaddr_in6 inet6; 68 57 #ifdef HAVE_BLUETOOTH 69 #ifdef HAVE_BLUETOOTH_LINUX70 58 struct sockaddr_rc rfcomm; 71 #endif72 #ifdef HAVE_BLUETOOTH_NETBSD73 struct sockaddr_bt rfcomm;74 #endif75 59 #endif /*HAVE_BLUETOOTH*/ 76 60 #ifdef HAVE_USB 77 61 struct obex_usb_intf_transport_t usb; -
openobex-anoncvs
old new 60 60 typedef void* obex_object_t; 61 61 typedef void (*obex_event_t)(obex_t *handle, obex_object_t *obj, int mode, int event, int obex_cmd, int obex_rsp); 62 62 // This is to workaround compilation without Bluetooth support. - Jean II 63 #ifndef SOL_RFCOMM64 typedef char* bdaddr_t;65 #endif66 63 67 64 #include <openobex/obex_const.h> 68 65 … … 146 143 /* 147 144 * Bluetooth OBEX API 148 145 */ 146 #ifdef SOL_RFCOMM 147 #ifdef _WIN32 148 #define bdaddr_t BTH_ADDR 149 #endif 149 150 LIB_SYMBOL int BtOBEX_ServerRegister(obex_t *self, bdaddr_t *src, uint8_t channel); 150 151 LIB_SYMBOL int BtOBEX_TransportConnect(obex_t *self, bdaddr_t *src, bdaddr_t *dst, uint8_t channel); 152 #endif 151 153 152 154 /* 153 155 * OBEX File API -
lib/obex_main.c
old new 45 45 #include <sys/types.h> 46 46 #include <stdio.h> 47 47 48 #endif /* _WIN32 */ 49 48 50 #ifdef HAVE_BLUETOOTH 49 #ifdef HAVE_BLUETOOTH_LINUX 50 #include <bluetooth/bluetooth.h> 51 #endif 52 #ifdef HAVE_BLUETOOTH_FREEBSD 53 #include <bluetooth.h> 54 #define BTPROTO_RFCOMM BLUETOOTH_PROTO_RFCOMM 55 #endif 56 #ifdef HAVE_BLUETOOTH_NETBSB 57 #include <bluetooth.h> 58 #endif 51 #include "bluez_compat.h" 59 52 #endif /*HAVE_BLUETOOTH*/ 60 53 61 #endif /* _WIN32 */62 63 54 #include "obex_main.h" 64 55 #include "obex_header.h" 65 56 #include "obex_server.h"
