From: <pl...@ne...> - 2011-06-30 15:58:28
|
From: Iain Hibbert <pl...@ry...> --- obexftp/bt_kit.c | 4 ++-- obexftp/bt_kit.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/obexftp/bt_kit.c b/obexftp/bt_kit.c index db48161..41aa224 100644 --- a/obexftp/bt_kit.c +++ b/obexftp/bt_kit.c @@ -78,7 +78,7 @@ \note Needed for win32 winsock compatibility. */ -int btkit_init() +int btkit_init(void) { #ifdef _WIN32 WORD wVersionRequired = MAKEWORD(WSA_VER_MAJOR,WSA_VER_MINOR); @@ -103,7 +103,7 @@ int btkit_init() \note Needed for win32 winsock compatibility. */ -int btkit_exit() +int btkit_exit(void) { #ifdef _WIN32 if (WSACleanup() != 0) { diff --git a/obexftp/bt_kit.h b/obexftp/bt_kit.h index ed73cb5..154c73b 100644 --- a/obexftp/bt_kit.h +++ b/obexftp/bt_kit.h @@ -113,8 +113,8 @@ BTKITSYM int str2ba(const char *straddr, BTH_ADDR *btaddr); /* library setup/teardown functions (needed for win32) */ -BTKITSYM int btkit_init(); -BTKITSYM int btkit_exit(); +BTKITSYM int btkit_init(void); +BTKITSYM int btkit_exit(void); /* additional functions */ -- 1.7.4.1 |
From: <pl...@ne...> - 2011-06-30 15:58:32
|
From: Iain Hibbert <pl...@ga...> - don't test for HAVE_SYS_TIMES_H before we include "config.h" (in common.h) - Opengroup specification says that a struct tms * must be passed to times() and some implementations don't validate that, causing a segmentation fault if you pass NULL. - Opengroup also notes that the value of clock ticks per second can be retrieved by sysconf(), use that to produce output in milliseconds. - cast the clock_t to long for printing. --- apps/obexftp.c | 15 ++++++++------- 1 files changed, 8 insertions(+), 7 deletions(-) diff --git a/apps/obexftp.c b/apps/obexftp.c index bc1da89..4538c0f 100644 --- a/apps/obexftp.c +++ b/apps/obexftp.c @@ -29,10 +29,6 @@ #include <sys/types.h> -#ifdef HAVE_SYS_TIMES_H -#include <sys/times.h> -#endif - #include <obexftp/obexftp.h> #include <obexftp/client.h> #include <obexftp/uuid.h> @@ -47,6 +43,10 @@ #include <common.h> +#ifdef HAVE_SYS_TIMES_H +#include <sys/times.h> +#endif + // perhaps this scheme would be better? // IRDA irda://[nick?] // CABLE tty://path @@ -253,6 +253,7 @@ static int cli_connect_uuid(const char *uuid, int uuid_len) int ret, retry; #ifdef HAVE_SYS_TIMES_H clock_t clock; + struct tms tms; #endif if (cli == NULL) { @@ -283,12 +284,12 @@ static int cli_connect_uuid(const char *uuid, int uuid_len) /* Connect */ #ifdef HAVE_SYS_TIMES_H - clock = times(NULL); + clock = times(&tms); #endif ret = obexftp_connect_src(cli, src_dev, device, channel, uuid, uuid_len); #ifdef HAVE_SYS_TIMES_H - clock = times(NULL)-clock; - fprintf(stderr, "Tried to connect for %ldms\n", clock); + clock = (times(&tms) - clock) * 1000 / sysconf(_SC_CLK_TCK); + fprintf(stderr, "Tried to connect for %ldms\n", (long)clock); #endif if (ret >= 0) return ret; -- 1.7.4.1 |
From: <pl...@ne...> - 2011-06-30 15:58:35
|
From: Iain Hibbert <pl...@ne...> --- obexftp/client.c | 2 +- obexftp/unicode.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/obexftp/client.c b/obexftp/client.c index 17edb05..c0b557d 100644 --- a/obexftp/client.c +++ b/obexftp/client.c @@ -568,7 +568,7 @@ int obexftp_connect_uuid(obexftp_client_t *cli, const char *device, int port, co int obexftp_connect_service(obexftp_client_t *cli, const char *src, const char *device, int port, int service) { - uint8_t *uuid = NULL; + const uint8_t *uuid = NULL; uint32_t uuid_len = 0; if (service == OBEX_FTP_SERVICE) { uuid = UUID_FBS; diff --git a/obexftp/unicode.c b/obexftp/unicode.c index dda8c6d..f2e015b 100644 --- a/obexftp/unicode.c +++ b/obexftp/unicode.c @@ -82,7 +82,7 @@ int CharToUnicode(uint8_t *uc, const uint8_t *c, int size) size_t ni, no, nrc; int ret; /* avoid type-punned dereferecing (breaks strict aliasing) */ - char *cc = c; + const char *cc = c; char *ucc = uc; return_val_if_fail(uc != NULL, -1); @@ -191,7 +191,7 @@ int UnicodeToChar(uint8_t *c, const uint8_t *uc, int size) int ret; /* avoid type-punned dereferecing (breaks strict aliasing) */ char *cc = c; - char *ucc = uc; + const char *ucc = uc; return_val_if_fail(uc != NULL, -1); return_val_if_fail(c != NULL, -1); @@ -266,7 +266,7 @@ int Utf8ToChar(uint8_t *c, const uint8_t *uc, int size) int ret; /* avoid type-punned dereferecing (breaks strict aliasing) */ char *cc = c; - char *ucc = uc; + const char *ucc = uc; return_val_if_fail(uc != NULL, -1); return_val_if_fail(c != NULL, -1); -- 1.7.4.1 |
From: Hendrik S. <po...@he...> - 2011-06-30 16:24:37
|
Am Donnerstag, 30. Juni 2011, 17:57:13 schrieb pl...@ne...: > From: Iain Hibbert <pl...@ne...> > > --- > obexftp/client.c | 2 +- > obexftp/unicode.c | 6 +++--- > 2 files changed, 4 insertions(+), 4 deletions(-) .git/rebase-apply/patch:28: space before tab in indent. const char *cc = c; warning: 1 line adds whitespace errors. HS |
From: <pl...@ne...> - 2011-06-30 15:58:40
|
From: Iain Hibbert <pl...@ne...> --- apps/discovery.c | 2 +- apps/obexftp.c | 16 ++++++++-------- bfb/bfb_io.c | 6 +++--- bfb/bfb_io.h | 4 ++-- obexftp/client.c | 4 ++-- obexftp/client.h | 4 ++-- obexftp/unicode.c | 20 ++++++++++---------- 7 files changed, 28 insertions(+), 28 deletions(-) diff --git a/apps/discovery.c b/apps/discovery.c index 68f1b00..271d08a 100644 --- a/apps/discovery.c +++ b/apps/discovery.c @@ -193,7 +193,7 @@ static int do_at_cmd(fd_t fd, const char *cmd, char *rspbuf, int rspbuflen) static struct mobile_info *probe_tty(const char *ttyname) { int speed; - uint8_t rspbuf[200]; + char rspbuf[200]; struct mobile_info *info; char *p; #ifdef _WIN32 diff --git a/apps/obexftp.c b/apps/obexftp.c index 4538c0f..8d66e00 100644 --- a/apps/obexftp.c +++ b/apps/obexftp.c @@ -131,13 +131,13 @@ static void info_cb(int event, const char *msg, int len, void *UNUSED(data)) } /* create global uuid buffers */ -static const char *fbs_uuid = (const char *)UUID_FBS; -static const char *irmc_uuid = (const char *)UUID_IRMC; -static const char *s45_uuid = (const char *)UUID_S45; -static const char *pcsoftware_uuid = (const char *)UUID_PCSOFTWARE; +static const uint8_t *fbs_uuid = UUID_FBS; +static const uint8_t *irmc_uuid = UUID_IRMC; +static const uint8_t *s45_uuid = UUID_S45; +static const uint8_t *pcsoftware_uuid = UUID_PCSOFTWARE; /* parse UUID string to real bytes */ -static int parse_uuid(char *name, const char **uuid, int *uuid_len) +static int parse_uuid(char *name, const uint8_t **uuid, int *uuid_len) { if (name == NULL || *name == '\0' || !strncasecmp(name, "none", 4) || @@ -240,7 +240,7 @@ static int transport = OBEX_TRANS_IRDA; #endif /* HAVE_BLUETOOTH */ /*@only@*/ /*@null@*/ static char *device = NULL; static int channel = -1; -static const char *use_uuid = (const char *)UUID_FBS; +static const uint8_t *use_uuid = UUID_FBS; static int use_uuid_len = sizeof(UUID_FBS); static int use_conn=1; static int use_path=1; @@ -248,7 +248,7 @@ static int timeout = 20; /* default accept/reject timeout of 20 seconds */ /* connect with given uuid. re-connect every time */ -static int cli_connect_uuid(const char *uuid, int uuid_len) +static int cli_connect_uuid(const uint8_t *uuid, int uuid_len) { int ret, retry; #ifdef HAVE_SYS_TIMES_H @@ -348,7 +348,7 @@ static void cli_disconnect() } } -static void probe_device_uuid(const char *uuid, int uuid_len) +static void probe_device_uuid(const uint8_t *uuid, int uuid_len) { int rsp[10]; diff --git a/bfb/bfb_io.c b/bfb/bfb_io.c index abe3ad8..61941a6 100644 --- a/bfb/bfb_io.c +++ b/bfb/bfb_io.c @@ -51,7 +51,7 @@ #include <common.h> /* Write out an IO buffer */ -int bfb_io_write(fd_t fd, const uint8_t *buffer, int length) +int bfb_io_write(fd_t fd, const void *buffer, int length) { #ifdef _WIN32 DWORD bytes; @@ -79,7 +79,7 @@ int bfb_io_write(fd_t fd, const uint8_t *buffer, int length) } /* Read an answer to an IO buffer of max length bytes */ -int bfb_io_read(fd_t fd, uint8_t *buffer, int length, int timeout) +int bfb_io_read(fd_t fd, void *buffer, int length, int timeout) { #ifdef _WIN32 DWORD bytes; @@ -123,7 +123,7 @@ int bfb_io_read(fd_t fd, uint8_t *buffer, int length, int timeout) /** Read (repeatedly) from fd until a timeout or an error is encountered. */ -static int bfb_io_read_all(int fd, uint8_t *buffer, int length, int timeout) +static int bfb_io_read_all(int fd, char *buffer, int length, int timeout) { int actual; int pos = 0; diff --git a/bfb/bfb_io.h b/bfb/bfb_io.h index 39f54fd..6039340 100644 --- a/bfb/bfb_io.h +++ b/bfb/bfb_io.h @@ -38,10 +38,10 @@ extern "C" { #endif /* Write out a BFB buffer */ -int bfb_io_write(fd_t fd, const uint8_t *buffer, int length); +int bfb_io_write(fd_t fd, const void *buffer, int length); /* Read in a BFB answer */ -int bfb_io_read(fd_t fd, uint8_t *buffer, int length, int timeout); +int bfb_io_read(fd_t fd, void *buffer, int length, int timeout); /* Send an BFB init command an check for a valid answer frame */ int bfb_io_init(fd_t fd); diff --git a/obexftp/client.c b/obexftp/client.c index c0b557d..4283ee0 100644 --- a/obexftp/client.c +++ b/obexftp/client.c @@ -267,7 +267,7 @@ static void client_done(obex_t *handle, obex_object_t *object, int UNUSED(obex_c uint8_t hi; uint32_t hlen; const apparam_t *app = NULL; - uint8_t *p; + char *p; const uint8_t *body_data = NULL; uint32_t body_len = -1; @@ -1141,7 +1141,7 @@ int obexftp_put_file(obexftp_client_t *cli, const char *filename, const char *re \note A remotename must be given always. */ -int obexftp_put_data(obexftp_client_t *cli, const char *data, int size, +int obexftp_put_data(obexftp_client_t *cli, const uint8_t *data, int size, const char *remotename) { obex_object_t *object; diff --git a/obexftp/client.h b/obexftp/client.h index 01098d3..7712e0c 100644 --- a/obexftp/client.h +++ b/obexftp/client.h @@ -100,7 +100,7 @@ typedef struct { /* transfer (get) */ char *target_fn; /* used in get body */ uint32_t buf_size; /* not size but len... */ - uint8_t *buf_data; + char *buf_data; uint32_t apparam_info; /* persistence */ cache_object_t *cache; @@ -184,7 +184,7 @@ int obexftp_get_type(obexftp_client_t *cli, int obexftp_put_file(obexftp_client_t *cli, const char *filename, const char *remotename); -int obexftp_put_data(obexftp_client_t *cli, const char *data, int size, +int obexftp_put_data(obexftp_client_t *cli, const uint8_t *data, int size, const char *remotename); int obexftp_del(obexftp_client_t *cli, const char *name); diff --git a/obexftp/unicode.c b/obexftp/unicode.c index f2e015b..1237c68 100644 --- a/obexftp/unicode.c +++ b/obexftp/unicode.c @@ -82,8 +82,8 @@ int CharToUnicode(uint8_t *uc, const uint8_t *c, int size) size_t ni, no, nrc; int ret; /* avoid type-punned dereferecing (breaks strict aliasing) */ - const char *cc = c; - char *ucc = uc; + const char *cc = (const char *)c; + char *ucc = (char *)uc; return_val_if_fail(uc != NULL, -1); return_val_if_fail(c != NULL, -1); @@ -103,8 +103,8 @@ int CharToUnicode(uint8_t *uc, const uint8_t *c, int size) /* try current locale charset to UTF-16BE */ setlocale(LC_CTYPE, ""); DEBUG(2, "Iconv from locale \"%s\"\n", locale_charset); - cc = c; - ucc = uc; + cc = (const char *)c; + ucc = (char *)uc; ni = strlen(cc) + 1; no = size; utf16 = iconv_open("UTF-16BE", locale_charset); @@ -117,8 +117,8 @@ int CharToUnicode(uint8_t *uc, const uint8_t *c, int size) } /* fallback to ISO-8859-1 to UTF-16BE (every byte is valid here) */ - cc = c; - ucc = uc; + cc = (const char *)c; + ucc = (char *)uc; ni = strlen(cc) + 1; no = size; utf16 = iconv_open("UTF-16BE", "ISO-8859-1"); @@ -190,8 +190,8 @@ int UnicodeToChar(uint8_t *c, const uint8_t *uc, int size) size_t ni, no, nrc; int ret; /* avoid type-punned dereferecing (breaks strict aliasing) */ - char *cc = c; - const char *ucc = uc; + char *cc = (char *)c; + const char *ucc = (const char *)uc; return_val_if_fail(uc != NULL, -1); return_val_if_fail(c != NULL, -1); @@ -265,8 +265,8 @@ int Utf8ToChar(uint8_t *c, const uint8_t *uc, int size) size_t ni, no, nrc; int ret; /* avoid type-punned dereferecing (breaks strict aliasing) */ - char *cc = c; - const char *ucc = uc; + char *cc = (char *)c; + const char *ucc = (const char *)uc; return_val_if_fail(uc != NULL, -1); return_val_if_fail(c != NULL, -1); -- 1.7.4.1 |
From: <pl...@ne...> - 2011-06-30 15:58:40
|
From: Iain Hibbert <pl...@ne...> --- apps/obexftpd.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/apps/obexftpd.c b/apps/obexftpd.c index b21059e..3b268f6 100644 --- a/apps/obexftpd.c +++ b/apps/obexftpd.c @@ -63,6 +63,7 @@ #include <obexftp/obexftp.h> #include <obexftp/object.h> +#include <obexftp/unicode.h> #include <common.h> /* define this to "", "\r\n" or "\n" */ -- 1.7.4.1 |
From: <pl...@ne...> - 2011-06-30 15:58:45
|
From: Iain Hibbert <pl...@ne...> --- apps/Makefile.am | 1 + obexftp/Makefile.am | 1 + 2 files changed, 2 insertions(+), 0 deletions(-) diff --git a/apps/Makefile.am b/apps/Makefile.am index b15b0bc..5d03b77 100644 --- a/apps/Makefile.am +++ b/apps/Makefile.am @@ -1,4 +1,5 @@ AM_CFLAGS = @OPENOBEX_CFLAGS@ \ + @BLUETOOTH_CFLAGS@ \ -I$(top_builddir) \ -I$(top_srcdir) \ -I$(top_srcdir)/includes diff --git a/obexftp/Makefile.am b/obexftp/Makefile.am index f40a643..db09a0d 100644 --- a/obexftp/Makefile.am +++ b/obexftp/Makefile.am @@ -1,6 +1,7 @@ lib_LTLIBRARIES = libobexftp.la AM_CFLAGS = @OPENOBEX_CFLAGS@ \ + @BLUETOOTH_CFLAGS@ \ -I$(top_builddir) \ -I$(top_srcdir) \ -I$(top_srcdir)/includes -- 1.7.4.1 |
From: <pl...@ne...> - 2011-06-30 15:58:56
|
From: Iain Hibbert <pl...@ry...> add "nostdinc" to the automake arguments, to cut out the automatic "-I. -I$(top_srcdir)" in the makefiles as otherwise it is not possible to include <uuid.h> and "uuid.h" on NetBSD, then add "-I$(top_srcdir)" specifically back in, so that we can include <obexftp/*.h> files, and "-I$(top_builddir)" so that <config.h> can still be found --- apps/Makefile.am | 1 + bfb/Makefile.am | 4 +++- configure.in | 2 +- multicobex/Makefile.am | 1 + obexftp/Makefile.am | 1 + 5 files changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/Makefile.am b/apps/Makefile.am index 9f727e6..b15b0bc 100644 --- a/apps/Makefile.am +++ b/apps/Makefile.am @@ -1,4 +1,5 @@ AM_CFLAGS = @OPENOBEX_CFLAGS@ \ + -I$(top_builddir) \ -I$(top_srcdir) \ -I$(top_srcdir)/includes diff --git a/bfb/Makefile.am b/bfb/Makefile.am index b05c732..7a87fdf 100644 --- a/bfb/Makefile.am +++ b/bfb/Makefile.am @@ -1,6 +1,8 @@ lib_LTLIBRARIES = libbfb.la -AM_CFLAGS = -I$(top_srcdir)/includes +AM_CFLAGS = -I$(top_builddir) \ + -I$(top_srcdir) \ + -I$(top_srcdir)/includes bfbincludedir = $(includedir)/bfb diff --git a/configure.in b/configure.in index 5778899..bf755e1 100644 --- a/configure.in +++ b/configure.in @@ -2,7 +2,7 @@ # try CFLAGS="$CFLAGS -g -Wall -Wmissing-declarations -Wmissing-prototypes -Werror" AC_INIT(ObexFTP, 0.23, za...@tr...) #AC_CONFIG_SRCDIR(src/foo.c) -AM_INIT_AUTOMAKE(dist-bzip2) +AM_INIT_AUTOMAKE([dist-bzip2 nostdinc]) AM_CONFIG_HEADER(config.h) # note: AC_HELP_STRING is deprecated in autoconf 2.59 and later but diff --git a/multicobex/Makefile.am b/multicobex/Makefile.am index ea8eba5..471c611 100644 --- a/multicobex/Makefile.am +++ b/multicobex/Makefile.am @@ -1,6 +1,7 @@ lib_LTLIBRARIES = libmulticobex.la AM_CFLAGS = @OPENOBEX_CFLAGS@ \ + -I$(top_builddir) \ -I$(top_srcdir) \ -I$(top_srcdir)/includes diff --git a/obexftp/Makefile.am b/obexftp/Makefile.am index 78aef27..f40a643 100644 --- a/obexftp/Makefile.am +++ b/obexftp/Makefile.am @@ -1,6 +1,7 @@ lib_LTLIBRARIES = libobexftp.la AM_CFLAGS = @OPENOBEX_CFLAGS@ \ + -I$(top_builddir) \ -I$(top_srcdir) \ -I$(top_srcdir)/includes -- 1.7.4.1 |
From: <pl...@ne...> - 2011-06-30 15:58:58
|
From: Iain Hibbert <pl...@ga...> This should work on NetBSD and FreeBSD and possibly OpenBSD and DragonflyBSD also with a little work --- acinclude.m4 | 84 ++++++-------- obexftp/bt_kit.c | 347 +++++++++++++++++++++++++++++++++++++++++++++++++++++- obexftp/bt_kit.h | 34 +++--- obexftp/client.c | 7 +- 4 files changed, 405 insertions(+), 67 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index 9326885..c8ba777 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -50,31 +50,44 @@ AC_DEFUN([AC_PATH_WINBT], [ AC_MSG_RESULT([$winbt_found]) ]) -AC_DEFUN([AC_PATH_NETBSDBT], [ - AC_CACHE_CHECK([for NetBSD Bluetooth support], netbsdbt_found, [ +AC_DEFUN([AC_PATH_BSDBT], [ + AC_CACHE_CHECK([for BSD Bluetooth support], bsdbt_found, [ AC_TRY_COMPILE([ #include <bluetooth.h> ], [ - struct sockaddr_bt *bt; - ], netbsdbt_found=yes, netbsdbt_found=no) + #ifndef BTPROTO_RFCOMM + #define BTPROTO_RFCOMM BLUETOOTH_PROTO_RFCOMM + #endif + + bdaddr_t bdaddr; + int family = AF_BLUETOOTH; + int proto = BTPROTO_RFCOMM; + ], bsdbt_found=yes, bsdbt_found=no) ]) -]) - -AC_DEFUN([AC_PATH_FREEBSDBT], [ - AC_CACHE_CHECK([for FreeBSD Bluetooth support], freebsdbt_found, [ - AC_TRY_COMPILE([ - #include <bluetooth.h> - ], [ - struct sockaddr_rfcomm *rfcomm; - ], freebsdbt_found=yes, freebsdbt_found=no) - ]) - if test "${freebsdbt_found}" = "yes"; then + if test "${bsdbt_found}" = "yes"; then BLUETOOTH_LIBS=-lbluetooth + AC_CACHE_CHECK([for BSD Service Discovery support], bsdsdp_found, [ + AC_TRY_COMPILE([ + #include <bluetooth.h> + #include <sdp.h> + ], [ + struct bt_devinquiry di; + sdp_data_t data; + ], bsdsdp_found=yes, bsdsdp_found=no) + ]) fi ]) AC_DEFUN([AC_PATH_BLUEZ], [ - PKG_CHECK_MODULES(BLUETOOTH, bluez, bluez_found=yes, AC_MSG_RESULT(no)) + PKG_CHECK_MODULES(BLUETOOTH, bluez, [ + bluez_found=yes + AC_MSG_CHECKING(for BlueZ Service Discovery support) + AC_TRY_COMPILE([ + #include <bluetooth/sdp.h> + ],[ + sdp_list_t sdplist; + ], bluezsdp_found=yes, bluezsdp_found=no) + ], AC_MSG_RESULT(no)) ]) AC_DEFUN([AC_PATH_BLUETOOTH], [ @@ -83,10 +96,10 @@ AC_DEFUN([AC_PATH_BLUETOOTH], [ AC_PATH_BLUEZ ;; *-*-freebsd*) - AC_PATH_FREEBSDBT + AC_PATH_BSDBT ;; *-*-netbsd*) - AC_PATH_NETBSDBT + AC_PATH_BSDBT ;; *-*-mingw32*) AC_PATH_WINBT @@ -96,44 +109,21 @@ AC_DEFUN([AC_PATH_BLUETOOTH], [ AC_SUBST(BLUETOOTH_LIBS) ]) -AC_DEFUN([BLUETOOTH_CHECK],[ +AC_DEFUN([BLUETOOTH_CHECK],[ AC_ARG_ENABLE([bluetooth], [AC_HELP_STRING([--disable-bluetooth], [Disables bluetooth support @<:@default=auto@:>@])], [ac_bluetooth_enabled=$enableval], [ac_bluetooth_enabled=yes]) if test "$ac_bluetooth_enabled" = yes; then - AC_PATH_BLUETOOTH - if test "${netbsdbt_found}" = "yes" -o "${freebsdbt_found}" = "yes" -o "${bluez_found}" = "yes" -o "${winbt_found}" = "yes"; then + AC_PATH_BLUETOOTH + if test "${bsdbt_found}" = "yes" -o "${bluez_found}" = "yes" -o "${winbt_found}" = "yes"; then AC_DEFINE([HAVE_BLUETOOTH], [1], [Define if system supports Bluetooth and it's enabled]) fi -fi -]) - - -dnl -dnl Check for Bluetooth SDP library -dnl Waring: the AC_TRY_COMPILE won't work with -Werror -dnl - -AC_DEFUN([SDPLIB_CHECK],[ - AC_MSG_CHECKING(for Bluetooth SDP support) - - AC_TRY_COMPILE( [ - #include <bluetooth/sdp.h> - ],[ - sdp_list_t sdplist; - ], - am_cv_sdplib_found=yes, - am_cv_sdplib_found=no - ) - - if test $am_cv_sdplib_found = yes; then - AC_DEFINE(HAVE_SDPLIB,1,[Define if system supports Bluetooth SDP]) - + if test "${bsdsdp_found}" = "yes" -o "${bluezsdp_found}" = "yes"; then + AC_DEFINE([HAVE_SDP], [1], [Define if system supports Bluetooth Service Discovery]) fi - - AC_MSG_RESULT($am_cv_sdplib_found) +fi ]) diff --git a/obexftp/bt_kit.c b/obexftp/bt_kit.c index 41aa224..67ee4ec 100644 --- a/obexftp/bt_kit.c +++ b/obexftp/bt_kit.c @@ -349,8 +349,350 @@ int btkit_unregister_service(int UNUSED(svclass)) #else /* _WIN32 */ -#ifdef HAVE_SDPLIB /* should switch on OS here */ +#ifdef HAVE_SDP +#if defined(__NetBSD__) || defined(__FreeBSD__) +char **btkit_discover(const char *src) +{ + struct bt_devinquiry *di; + char **res; + int num_rsp = 10; + int length = 8; + int i; + + DEBUG(2, "%s: Scanning ...\n", __func__); + + num_rsp = bt_devinquiry(src, length, num_rsp, &di); + if(num_rsp < 0) { + DEBUG(1, "%s: Inquiry failed\n", __func__); + return NULL; + } + + res = calloc(num_rsp + 1, sizeof(char *)); + for(i = 0; i < num_rsp; i++) { + res[i] = bt_malloc(18); /* size of text bdaddr */ + bt_ntoa(&di->bdaddr, res[i]); + DEBUG(2, "%s: Found\t%s\n", __func__, res[i]); + } + + free(di); + + return res; +} + +static int btkit_getname_cb(int UNUSED(s), const struct bt_devinfo *di, void *arg) +{ + + if ((di->enabled)) { + strncpy(arg, di->devname, HCI_DEVNAME_SIZE); + return 1; + } + + return 0; +} + +char *btkit_getname(const char *src, const char *addr) +{ + hci_remote_name_req_cp cp; + hci_remote_name_req_compl_ep ep; + struct bt_devreq req; + int s; + + return_val_if_fail(addr != NULL, NULL); + + if (!src) { + if (bt_devenum(btkit_getname_cb, ep.name) == -1) { + DEBUG(1, "%s: device enumeration failed\n", __func__); + return NULL; + } + + src = (const char *)ep.name; + } + + s = bt_devopen(src, 0); + if (s == -1) { + DEBUG(1, "%s: HCI device open failed\n", __func__); + return NULL; + } + + memset(&cp, 0, sizeof(cp)); + bt_aton(addr, &cp.bdaddr); + + memset(&req, 0, sizeof(req)); + req.opcode = HCI_CMD_REMOTE_NAME_REQ; + req.cparam = &cp; + req.clen = sizeof(cp); + req.event = HCI_EVENT_REMOTE_NAME_REQ_COMPL; + req.rparam = &ep; + req.rlen = sizeof(ep); + + if (bt_devreq(s, &req, 100) == -1) { + DEBUG(1, "%s: remote name request failed\n", __func__); + strcpy(ep.name, "No Name"); + } + + close(s); + + return strndup(ep.name, sizeof(ep.name)); +} + +static int btkit_browse_sdp(sdp_session_t ss, uuid_t *uuid) +{ + uint8_t buf[19]; /* enough for uuid128 (ssp) and uint16 (ail) */ + sdp_data_t seq, ssp, ail, rsp, rec, value, pdl; + uintmax_t channel; + uint16_t attr; + + seq.next = buf; + seq.end = buf + sizeof(buf); + + /* build ServiceSearchPattern */ + ssp.next = seq.next; + sdp_put_uuid(&seq, uuid); + ssp.end = seq.next; + + /* build AttributeIDList */ + ail.next = seq.next; + sdp_put_uint16(&seq, SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST); + ail.end = seq.next; + + if (!sdp_service_search_attribute(ss, &ssp, &ail, &rsp)) { + DEBUG(1, "%s: SDP service search failed\n", __func__); + return -1; + } + + /* + * we expect the response to contain a list of records + * containing ProtocolDescriptorList. Return the first + * one with a valid RFCOMM channel. + */ + while (sdp_get_seq(&rsp, &rec)) { + if (!sdp_get_attr(&rec, &attr, &value) + || attr != SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST) + continue; + + /* drop any alt header */ + sdp_get_alt(&value, &value); + + /* for each protocol stack */ + while (sdp_get_seq(&value, &pdl)) { + /* and for each protocol */ + while (sdp_get_seq(&pdl, &seq)) { + /* check for RFCOMM */ + if (sdp_match_uuid16(&seq, SDP_UUID_PROTOCOL_RFCOMM) + && sdp_get_uint(&seq, &channel) + && channel >= RFCOMM_CHANNEL_MIN + && channel <= RFCOMM_CHANNEL_MAX) + return channel; + } + } + } + + DEBUG(1, "%s: no channel found\n", __func__); + + return -1; +} + +int btkit_browse(const char *src, const char *addr, int svclass) +{ + bdaddr_t laddr, raddr; + sdp_session_t ss; + uuid_t uuid; + int channel; + + return_val_if_fail(addr != NULL, -1); + bt_aton(addr, &raddr); + + if (src) { + if (!bt_devaddr(src, &laddr)) { + DEBUG(1, "%s: invalid source address\n", __func__); + return -1; + } + } else { + bdaddr_copy(&laddr, BDADDR_ANY); + } + + ss = sdp_open(&laddr, &raddr); + if (ss == NULL) { + DEBUG(1, "%s: Failed to connect to SDP server\n", __func__); + return -1; + } + + if (svclass >= 0x0001 && svclass <= 0x0004) { + uuid_dec_be(SVC_UUID_SYNCML, &uuid); + uuid.time_low = svclass; + } else if (svclass >= 0x1000 && svclass <= 0x12FF) { + uuid_dec_be(SVC_UUID_BASE, &uuid); + uuid.time_low = svclass; + } else { + svclass = SDP_SERVICE_CLASS_OBEX_FILE_TRANSFER; + } + + DEBUG(1, "%s: svclass 0x%04x\n", __func__, svclass); + + channel = -1; + + /* Try PCSUITE first */ + if (svclass == SDP_SERVICE_CLASS_OBEX_FILE_TRANSFER) { + DEBUG(1, "%s: trying PCSUITE first\n", __func__); + uuid_dec_be(SVC_UUID_PCSUITE, &uuid); + channel = btkit_browse_sdp(ss, &uuid); + + uuid_dec_be(SVC_UUID_BASE, &uuid); + uuid.time_low = svclass; + } + + if (channel == -1) + channel = btkit_browse_sdp(ss, &uuid); + + sdp_close(ss); + return channel; +} + +static sdp_session_t ss; +static uint32_t opush_handle; +static uint32_t ftrn_handle; +static uint32_t irmc_handle; + +int btkit_register_obex(int svclass, int channel) +{ + uint8_t buffer[256]; + sdp_data_t rec; + uint32_t *hp; + + DEBUG(1, "%s: svclass 0x%04x channel %d\n", __func__, svclass, channel); + + /* Build SDP record */ + rec.next = buffer; + rec.end = buffer + sizeof(buffer); + + sdp_put_uint16(&rec, SDP_ATTR_SERVICE_RECORD_HANDLE); + sdp_put_uint32(&rec, 0x00000000); + + sdp_put_uint16(&rec, SDP_ATTR_SERVICE_CLASS_ID_LIST); + sdp_put_seq(&rec, 3); + sdp_put_uuid16(&rec, (uint16_t)svclass); + + sdp_put_uint16(&rec, SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST); + sdp_put_seq(&rec, 17); + sdp_put_seq(&rec, 3); + sdp_put_uuid16(&rec, SDP_UUID_PROTOCOL_L2CAP); + sdp_put_seq(&rec, 5); + sdp_put_uuid16(&rec, SDP_UUID_PROTOCOL_RFCOMM); + sdp_put_uint8(&rec, (uint8_t)channel); + sdp_put_seq(&rec, 3); + sdp_put_uuid16(&rec, SDP_UUID_PROTOCOL_OBEX); + + sdp_put_uint16(&rec, SDP_ATTR_BROWSE_GROUP_LIST); + sdp_put_seq(&rec, 3); + sdp_put_uuid16(&rec, SDP_SERVICE_CLASS_PUBLIC_BROWSE_GROUP); + + sdp_put_uint16(&rec, SDP_ATTR_LANGUAGE_BASE_ATTRIBUTE_ID_LIST); + sdp_put_seq(&rec, 9); + sdp_put_uint16(&rec, 0x656e); /* "en" */ + sdp_put_uint16(&rec, 106); /* UTF-8 */ + sdp_put_uint16(&rec, SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID); + + sdp_put_uint16(&rec, SDP_ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST); + sdp_put_seq(&rec, 8); + sdp_put_seq(&rec, 6); + sdp_put_uuid16(&rec, (uint16_t)svclass); + sdp_put_uint16(&rec, 0x0100); /* v1.0 */ + + sdp_put_uint16(&rec, SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_SERVICE_NAME_OFFSET); + switch (svclass) { + case SDP_SERVICE_CLASS_OBEX_OBJECT_PUSH: + sdp_put_str(&rec, "OBEX Object Push", -1); + + sdp_put_uint16(&rec, SDP_ATTR_SUPPORTED_FORMATS_LIST); + sdp_put_seq(&rec, 2); + sdp_put_uint8(&rec, 0xff); /* Any */ + hp = &opush_handle; + break; + + case SDP_SERVICE_CLASS_OBEX_FILE_TRANSFER: + sdp_put_str(&rec, "OBEX File Transfer", -1); + hp = &ftrn_handle; + break; + + case SDP_SERVICE_CLASS_IR_MC_SYNC: + sdp_put_str(&rec, "IrMC Sync", -1); + hp = &irmc_handle; + break; + + default: + DEBUG(1, "%s: unknown svclass\n", __func__); + return -1; + break; + } + + rec.end = rec.next; + rec.next = buffer; + + /* Register service with SDP server */ + if (ss == NULL) { + ss = sdp_open_local(NULL); + if (ss == NULL) { + DEBUG(1, "%s: failed to open SDP session\n", __func__); + return -1; + } + DEBUG(2, "%s: opened SDP session\n", __func__); + } + + if (!sdp_record_insert(ss, NULL, hp, &rec)) { + DEBUG(1, "%s: failed to insert SDP record\n", __func__); + sdp_data_print(&rec, 2); + return -1; + } + + return 0; +} + +int btkit_unregister_service(int svclass) +{ + uint32_t *hp; + + if (ss == NULL) { + DEBUG(1, "%s: no session open\n", __func__); + return -1; + } + + switch (svclass) { + case SDP_SERVICE_CLASS_OBEX_OBJECT_PUSH: + hp = &opush_handle; + break; + + case SDP_SERVICE_CLASS_OBEX_FILE_TRANSFER: + hp = &ftrn_handle; + break; + + case SDP_SERVICE_CLASS_IR_MC_SYNC: + hp = &irmc_handle; + break; + + default: + DEBUG(1, "%s: unknown svclass\n", __func__); + return -1; + break; + } + + if (!sdp_record_remove(ss, *hp)) { + DEBUG(1, "%s: failed to remove SDP record\n", __func__); + return -1; + } + + *hp = 0; + + if (opush_handle == 0 && ftrn_handle == 0 && irmc_handle == 0) { + DEBUG(2, "%s: closed SDP session\n", __func__); + sdp_close(ss); + ss = NULL; + } + + return 0; +} + +#else /* defined(__NetBSD__) || defined(__FreeBSD__) */ /** Discover all bluetooth devices in range. @@ -695,6 +1037,7 @@ int btkit_register_obex(int service, int channel) return 0; } +#endif /* BlueZ/Linux */ #else #warning "no bluetooth sdp support for this platform" @@ -723,7 +1066,7 @@ int btkit_unregister_service(int UNUSED(svclass)) return -1; } -#endif /* HAVE_SDPLIB */ +#endif /* HAVE_SDP */ #endif /* _WIN32 */ #else diff --git a/obexftp/bt_kit.h b/obexftp/bt_kit.h index 154c73b..6eeba6b 100644 --- a/obexftp/bt_kit.h +++ b/obexftp/bt_kit.h @@ -79,26 +79,26 @@ extern "C" { BTKITSYM int ba2str(const bdaddr_t *btaddr, char *straddr); BTKITSYM int str2ba(const char *straddr, BTH_ADDR *btaddr); -/* FreeBSD 5 and up */ -#elif defined(__FreeBSD__) -//#include <sys/types.h> +/* Various BSD systems */ +#elif defined(__NetBSD__) || defined(__FreeBSD__) +#define COMPAT_BLUEZ #include <bluetooth.h> -#define sockaddr_rc sockaddr_rfcomm -#define rc_family rfcomm_family -#define rc_bdaddr rfcomm_bdaddr -#define rc_channel rfcomm_channel -#define BTPROTO_RFCOMM BLUETOOTH_PROTO_RFCOMM -#define BDADDR_ANY NG_HCI_BDADDR_ANY +#ifdef HAVE_SDP +#include <sdp.h> +#include <string.h> +#endif -/* NetBSD-4 and up */ -#elif defined(__NetBSD__) -#include <bluetooth.h> -#include <netbt/rfcomm.h> -#define sockaddr_rc sockaddr_bt -#define rc_family bt_family -#define rc_bdaddr bt_bdaddr -#define rc_channel bt_channel +#ifndef BDADDR_ANY #define BDADDR_ANY NG_HCI_BDADDR_ANY +#endif + +#ifndef RFCOMM_CHANNEL_MIN +#define RFCOMM_CHANNEL_MIN 1 +#endif + +#ifndef RFCOMM_CHANNEL_MAX +#define RFCOMM_CHANNEL_MAX 30 +#endif /* BlueZ, Linux 2.4.6 and up (incl. 2.6) */ #else diff --git a/obexftp/client.c b/obexftp/client.c index 4283ee0..136150d 100644 --- a/obexftp/client.c +++ b/obexftp/client.c @@ -663,7 +663,12 @@ int obexftp_connect_src(obexftp_client_t *cli, const char *src, const char *devi if (!src) { bacpy(&src_addr, BDADDR_ANY); } -#ifdef HAVE_SDPLIB +#if defined(_WIN32) + /* nothing */ +#elif defined(__NetBSD__) || defined(__FreeBSD__) + else if (bt_devaddr(src, &src_addr)) { + } +#else else if (!strncmp(src, "hci", 3)) { hci_devba(atoi(src + 3), &src_addr); } -- 1.7.4.1 |
From: Hendrik S. <po...@he...> - 2011-06-30 16:26:45
|
Am Donnerstag, 30. Juni 2011, 17:57:14 schrieb pl...@ne...: > From: Iain Hibbert <pl...@ne...> > > --- > apps/discovery.c | 2 +- > apps/obexftp.c | 16 ++++++++-------- > bfb/bfb_io.c | 6 +++--- > bfb/bfb_io.h | 4 ++-- > obexftp/client.c | 4 ++-- > obexftp/client.h | 4 ++-- > obexftp/unicode.c | 20 ++++++++++---------- > 7 files changed, 28 insertions(+), 28 deletions(-) .git/rebase-apply/patch:176: space before tab in indent. const char *cc = (const char *)c; .git/rebase-apply/patch:187: space before tab in indent. cc = (const char *)c; .git/rebase-apply/patch:198: space before tab in indent. cc = (const char *)c; .git/rebase-apply/patch:209: space before tab in indent. char *cc = (char *)c; .git/rebase-apply/patch:220: space before tab in indent. char *cc = (char *)c; warning: 5 lines add whitespace errors. HS |
From: Iain H. <pl...@ry...> - 2011-06-30 20:39:54
|
On Thu, 30 Jun 2011, Hendrik Sattler wrote: > .git/rebase-apply/patch:220: space before tab in indent. > char *cc = (char *)c; > warning: 5 lines add whitespace errors. its a lie.. that file was full of whitespace errors already! > This results in > checking for BlueZ Service Discovery support... ../configure: line 13598: > SDPLIB_CHECK: command not found Hmm.. oh I see it hiding there in configure.in.. and I see you switched it to quiet mode which makes the errors easier to see.. though actually I left those alone as they were deeper to deal with resending the patch set then.. iain |
From: <pl...@ne...> - 2011-06-30 20:41:05
|
From: Iain Hibbert <pl...@ry...> --- obexftp/bt_kit.c | 4 ++-- obexftp/bt_kit.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/obexftp/bt_kit.c b/obexftp/bt_kit.c index db48161..41aa224 100644 --- a/obexftp/bt_kit.c +++ b/obexftp/bt_kit.c @@ -78,7 +78,7 @@ \note Needed for win32 winsock compatibility. */ -int btkit_init() +int btkit_init(void) { #ifdef _WIN32 WORD wVersionRequired = MAKEWORD(WSA_VER_MAJOR,WSA_VER_MINOR); @@ -103,7 +103,7 @@ int btkit_init() \note Needed for win32 winsock compatibility. */ -int btkit_exit() +int btkit_exit(void) { #ifdef _WIN32 if (WSACleanup() != 0) { diff --git a/obexftp/bt_kit.h b/obexftp/bt_kit.h index ed73cb5..154c73b 100644 --- a/obexftp/bt_kit.h +++ b/obexftp/bt_kit.h @@ -113,8 +113,8 @@ BTKITSYM int str2ba(const char *straddr, BTH_ADDR *btaddr); /* library setup/teardown functions (needed for win32) */ -BTKITSYM int btkit_init(); -BTKITSYM int btkit_exit(); +BTKITSYM int btkit_init(void); +BTKITSYM int btkit_exit(void); /* additional functions */ -- 1.7.4.1 |
From: <pl...@ne...> - 2011-06-30 20:41:05
|
From: Iain Hibbert <pl...@ne...> --- apps/obexftpd.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/apps/obexftpd.c b/apps/obexftpd.c index b21059e..3b268f6 100644 --- a/apps/obexftpd.c +++ b/apps/obexftpd.c @@ -63,6 +63,7 @@ #include <obexftp/obexftp.h> #include <obexftp/object.h> +#include <obexftp/unicode.h> #include <common.h> /* define this to "", "\r\n" or "\n" */ -- 1.7.4.1 |
From: <pl...@ne...> - 2011-06-30 20:41:13
|
From: Iain Hibbert <pl...@ne...> --- apps/discovery.c | 2 +- apps/obexftp.c | 16 ++++++++-------- bfb/bfb.h | 2 +- bfb/bfb_io.c | 6 +++--- bfb/bfb_io.h | 4 ++-- obexftp/client.c | 4 ++-- obexftp/client.h | 4 ++-- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/apps/discovery.c b/apps/discovery.c index 68f1b00..271d08a 100644 --- a/apps/discovery.c +++ b/apps/discovery.c @@ -193,7 +193,7 @@ static int do_at_cmd(fd_t fd, const char *cmd, char *rspbuf, int rspbuflen) static struct mobile_info *probe_tty(const char *ttyname) { int speed; - uint8_t rspbuf[200]; + char rspbuf[200]; struct mobile_info *info; char *p; #ifdef _WIN32 diff --git a/apps/obexftp.c b/apps/obexftp.c index 4538c0f..8d66e00 100644 --- a/apps/obexftp.c +++ b/apps/obexftp.c @@ -131,13 +131,13 @@ static void info_cb(int event, const char *msg, int len, void *UNUSED(data)) } /* create global uuid buffers */ -static const char *fbs_uuid = (const char *)UUID_FBS; -static const char *irmc_uuid = (const char *)UUID_IRMC; -static const char *s45_uuid = (const char *)UUID_S45; -static const char *pcsoftware_uuid = (const char *)UUID_PCSOFTWARE; +static const uint8_t *fbs_uuid = UUID_FBS; +static const uint8_t *irmc_uuid = UUID_IRMC; +static const uint8_t *s45_uuid = UUID_S45; +static const uint8_t *pcsoftware_uuid = UUID_PCSOFTWARE; /* parse UUID string to real bytes */ -static int parse_uuid(char *name, const char **uuid, int *uuid_len) +static int parse_uuid(char *name, const uint8_t **uuid, int *uuid_len) { if (name == NULL || *name == '\0' || !strncasecmp(name, "none", 4) || @@ -240,7 +240,7 @@ static int transport = OBEX_TRANS_IRDA; #endif /* HAVE_BLUETOOTH */ /*@only@*/ /*@null@*/ static char *device = NULL; static int channel = -1; -static const char *use_uuid = (const char *)UUID_FBS; +static const uint8_t *use_uuid = UUID_FBS; static int use_uuid_len = sizeof(UUID_FBS); static int use_conn=1; static int use_path=1; @@ -248,7 +248,7 @@ static int timeout = 20; /* default accept/reject timeout of 20 seconds */ /* connect with given uuid. re-connect every time */ -static int cli_connect_uuid(const char *uuid, int uuid_len) +static int cli_connect_uuid(const uint8_t *uuid, int uuid_len) { int ret, retry; #ifdef HAVE_SYS_TIMES_H @@ -348,7 +348,7 @@ static void cli_disconnect() } } -static void probe_device_uuid(const char *uuid, int uuid_len) +static void probe_device_uuid(const uint8_t *uuid, int uuid_len) { int rsp[10]; diff --git a/bfb/bfb.h b/bfb/bfb.h index 349a0ef..b13bb93 100644 --- a/bfb/bfb.h +++ b/bfb/bfb.h @@ -90,7 +90,7 @@ int bfb_stuff_data(/*@out@*/ uint8_t *buffer, uint8_t type, uint8_t *data, uint1 int bfb_write_packets(fd_t fd, uint8_t type, uint8_t *buffer, int length); #define bfb_write_at(fd, data) \ - bfb_write_packets(fd, BFB_FRAME_AT, data, strlen(data)) + bfb_write_packets(fd, BFB_FRAME_AT, (uint8_t *)data, strlen(data)) #define bfb_write_key(fd, data) \ bfb_write_subcmd8(fd, BFB_FRAME_KEY, BFB_KEY_PRESS, data) diff --git a/bfb/bfb_io.c b/bfb/bfb_io.c index abe3ad8..61941a6 100644 --- a/bfb/bfb_io.c +++ b/bfb/bfb_io.c @@ -51,7 +51,7 @@ #include <common.h> /* Write out an IO buffer */ -int bfb_io_write(fd_t fd, const uint8_t *buffer, int length) +int bfb_io_write(fd_t fd, const void *buffer, int length) { #ifdef _WIN32 DWORD bytes; @@ -79,7 +79,7 @@ int bfb_io_write(fd_t fd, const uint8_t *buffer, int length) } /* Read an answer to an IO buffer of max length bytes */ -int bfb_io_read(fd_t fd, uint8_t *buffer, int length, int timeout) +int bfb_io_read(fd_t fd, void *buffer, int length, int timeout) { #ifdef _WIN32 DWORD bytes; @@ -123,7 +123,7 @@ int bfb_io_read(fd_t fd, uint8_t *buffer, int length, int timeout) /** Read (repeatedly) from fd until a timeout or an error is encountered. */ -static int bfb_io_read_all(int fd, uint8_t *buffer, int length, int timeout) +static int bfb_io_read_all(int fd, char *buffer, int length, int timeout) { int actual; int pos = 0; diff --git a/bfb/bfb_io.h b/bfb/bfb_io.h index 39f54fd..6039340 100644 --- a/bfb/bfb_io.h +++ b/bfb/bfb_io.h @@ -38,10 +38,10 @@ extern "C" { #endif /* Write out a BFB buffer */ -int bfb_io_write(fd_t fd, const uint8_t *buffer, int length); +int bfb_io_write(fd_t fd, const void *buffer, int length); /* Read in a BFB answer */ -int bfb_io_read(fd_t fd, uint8_t *buffer, int length, int timeout); +int bfb_io_read(fd_t fd, void *buffer, int length, int timeout); /* Send an BFB init command an check for a valid answer frame */ int bfb_io_init(fd_t fd); diff --git a/obexftp/client.c b/obexftp/client.c index f7ae5f7..b5243e7 100644 --- a/obexftp/client.c +++ b/obexftp/client.c @@ -267,7 +267,7 @@ static void client_done(obex_t *handle, obex_object_t *object, int UNUSED(obex_c uint8_t hi; uint32_t hlen; const apparam_t *app = NULL; - uint8_t *p; + char *p; const uint8_t *body_data = NULL; uint32_t body_len = -1; @@ -1142,7 +1142,7 @@ int obexftp_put_file(obexftp_client_t *cli, const char *filename, const char *re \note A remotename must be given always. */ -int obexftp_put_data(obexftp_client_t *cli, const char *data, int size, +int obexftp_put_data(obexftp_client_t *cli, const uint8_t *data, int size, const char *remotename) { obex_object_t *object; diff --git a/obexftp/client.h b/obexftp/client.h index 01098d3..7712e0c 100644 --- a/obexftp/client.h +++ b/obexftp/client.h @@ -100,7 +100,7 @@ typedef struct { /* transfer (get) */ char *target_fn; /* used in get body */ uint32_t buf_size; /* not size but len... */ - uint8_t *buf_data; + char *buf_data; uint32_t apparam_info; /* persistence */ cache_object_t *cache; @@ -184,7 +184,7 @@ int obexftp_get_type(obexftp_client_t *cli, int obexftp_put_file(obexftp_client_t *cli, const char *filename, const char *remotename); -int obexftp_put_data(obexftp_client_t *cli, const char *data, int size, +int obexftp_put_data(obexftp_client_t *cli, const uint8_t *data, int size, const char *remotename); int obexftp_del(obexftp_client_t *cli, const char *name); -- 1.7.4.1 |
From: <pl...@ne...> - 2011-06-30 20:41:13
|
From: Iain Hibbert <pl...@ga...> - don't test for HAVE_SYS_TIMES_H before we include "config.h" (in common.h) - Opengroup specification says that a struct tms * must be passed to times() and some implementations don't validate that, causing a segmentation fault if you pass NULL. - Opengroup also notes that the value of clock ticks per second can be retrieved by sysconf(), use that to produce output in milliseconds. - cast the clock_t to long for printing. --- apps/obexftp.c | 15 ++++++++------- 1 files changed, 8 insertions(+), 7 deletions(-) diff --git a/apps/obexftp.c b/apps/obexftp.c index bc1da89..4538c0f 100644 --- a/apps/obexftp.c +++ b/apps/obexftp.c @@ -29,10 +29,6 @@ #include <sys/types.h> -#ifdef HAVE_SYS_TIMES_H -#include <sys/times.h> -#endif - #include <obexftp/obexftp.h> #include <obexftp/client.h> #include <obexftp/uuid.h> @@ -47,6 +43,10 @@ #include <common.h> +#ifdef HAVE_SYS_TIMES_H +#include <sys/times.h> +#endif + // perhaps this scheme would be better? // IRDA irda://[nick?] // CABLE tty://path @@ -253,6 +253,7 @@ static int cli_connect_uuid(const char *uuid, int uuid_len) int ret, retry; #ifdef HAVE_SYS_TIMES_H clock_t clock; + struct tms tms; #endif if (cli == NULL) { @@ -283,12 +284,12 @@ static int cli_connect_uuid(const char *uuid, int uuid_len) /* Connect */ #ifdef HAVE_SYS_TIMES_H - clock = times(NULL); + clock = times(&tms); #endif ret = obexftp_connect_src(cli, src_dev, device, channel, uuid, uuid_len); #ifdef HAVE_SYS_TIMES_H - clock = times(NULL)-clock; - fprintf(stderr, "Tried to connect for %ldms\n", clock); + clock = (times(&tms) - clock) * 1000 / sysconf(_SC_CLK_TCK); + fprintf(stderr, "Tried to connect for %ldms\n", (long)clock); #endif if (ret >= 0) return ret; -- 1.7.4.1 |
From: <pl...@ne...> - 2011-06-30 20:41:19
|
From: Iain Hibbert <pl...@ne...> --- apps/Makefile.am | 1 + obexftp/Makefile.am | 1 + 2 files changed, 2 insertions(+), 0 deletions(-) diff --git a/apps/Makefile.am b/apps/Makefile.am index b15b0bc..5d03b77 100644 --- a/apps/Makefile.am +++ b/apps/Makefile.am @@ -1,4 +1,5 @@ AM_CFLAGS = @OPENOBEX_CFLAGS@ \ + @BLUETOOTH_CFLAGS@ \ -I$(top_builddir) \ -I$(top_srcdir) \ -I$(top_srcdir)/includes diff --git a/obexftp/Makefile.am b/obexftp/Makefile.am index f40a643..db09a0d 100644 --- a/obexftp/Makefile.am +++ b/obexftp/Makefile.am @@ -1,6 +1,7 @@ lib_LTLIBRARIES = libobexftp.la AM_CFLAGS = @OPENOBEX_CFLAGS@ \ + @BLUETOOTH_CFLAGS@ \ -I$(top_builddir) \ -I$(top_srcdir) \ -I$(top_srcdir)/includes -- 1.7.4.1 |
From: <pl...@ne...> - 2011-06-30 20:41:22
|
From: Iain Hibbert <pl...@ry...> add "nostdinc" to the automake arguments, to cut out the automatic "-I. -I$(top_srcdir)" in the makefiles as otherwise it is not possible to include <uuid.h> and "uuid.h" on NetBSD, then add "-I$(top_srcdir)" specifically back in, so that we can include <obexftp/*.h> files, and "-I$(top_builddir)" so that <config.h> can still be found --- apps/Makefile.am | 1 + bfb/Makefile.am | 4 +++- configure.in | 2 +- multicobex/Makefile.am | 1 + obexftp/Makefile.am | 1 + 5 files changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/Makefile.am b/apps/Makefile.am index 9f727e6..b15b0bc 100644 --- a/apps/Makefile.am +++ b/apps/Makefile.am @@ -1,4 +1,5 @@ AM_CFLAGS = @OPENOBEX_CFLAGS@ \ + -I$(top_builddir) \ -I$(top_srcdir) \ -I$(top_srcdir)/includes diff --git a/bfb/Makefile.am b/bfb/Makefile.am index b05c732..7a87fdf 100644 --- a/bfb/Makefile.am +++ b/bfb/Makefile.am @@ -1,6 +1,8 @@ lib_LTLIBRARIES = libbfb.la -AM_CFLAGS = -I$(top_srcdir)/includes +AM_CFLAGS = -I$(top_builddir) \ + -I$(top_srcdir) \ + -I$(top_srcdir)/includes bfbincludedir = $(includedir)/bfb diff --git a/configure.in b/configure.in index b8d20bc..16bf3ca 100644 --- a/configure.in +++ b/configure.in @@ -3,7 +3,7 @@ AC_PREREQ(2.60) AC_INIT(ObexFTP, 0.23, za...@tr...) #AC_CONFIG_SRCDIR(src/foo.c) -AM_INIT_AUTOMAKE(dist-bzip2) +AM_INIT_AUTOMAKE([dist-bzip2 nostdinc]) AM_CONFIG_HEADER(config.h) # note: AC_HELP_STRING is deprecated in autoconf 2.59 and later but diff --git a/multicobex/Makefile.am b/multicobex/Makefile.am index ea8eba5..471c611 100644 --- a/multicobex/Makefile.am +++ b/multicobex/Makefile.am @@ -1,6 +1,7 @@ lib_LTLIBRARIES = libmulticobex.la AM_CFLAGS = @OPENOBEX_CFLAGS@ \ + -I$(top_builddir) \ -I$(top_srcdir) \ -I$(top_srcdir)/includes diff --git a/obexftp/Makefile.am b/obexftp/Makefile.am index 78aef27..f40a643 100644 --- a/obexftp/Makefile.am +++ b/obexftp/Makefile.am @@ -1,6 +1,7 @@ lib_LTLIBRARIES = libobexftp.la AM_CFLAGS = @OPENOBEX_CFLAGS@ \ + -I$(top_builddir) \ -I$(top_srcdir) \ -I$(top_srcdir)/includes -- 1.7.4.1 |
From: <pl...@ne...> - 2011-06-30 20:41:34
|
From: Iain Hibbert <pl...@ne...> This should work on NetBSD and FreeBSD and possibly OpenBSD and DragonflyBSD also with a little work --- acinclude.m4 | 84 ++++++-------- configure.in | 1 - obexftp/bt_kit.c | 347 +++++++++++++++++++++++++++++++++++++++++++++++++++++- obexftp/bt_kit.h | 34 +++--- obexftp/client.c | 7 +- 5 files changed, 405 insertions(+), 68 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index c0ca90f..9a18ea1 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -50,31 +50,44 @@ AC_DEFUN([AC_PATH_WINBT], [ AC_MSG_RESULT([$winbt_cv_found]) ]) -AC_DEFUN([AC_PATH_NETBSDBT], [ - AC_CACHE_CHECK([for NetBSD Bluetooth support], netbsdbt_cv_found, [ +AC_DEFUN([AC_PATH_BSDBT], [ + AC_CACHE_CHECK([for BSD Bluetooth support], bsdbt_cv_found, [ AC_TRY_COMPILE([ #include <bluetooth.h> ], [ - struct sockaddr_bt *bt; - ], netbsdbt_cv_found=yes, netbsdbt_cv_found=no) + #ifndef BTPROTO_RFCOMM + #define BTPROTO_RFCOMM BLUETOOTH_PROTO_RFCOMM + #endif + + bdaddr_t bdaddr; + int family = AF_BLUETOOTH; + int proto = BTPROTO_RFCOMM; + ], bsdbt_cv_found=yes, bsdbt_cv_found=no) ]) -]) - -AC_DEFUN([AC_PATH_FREEBSDBT], [ - AC_CACHE_CHECK([for FreeBSD Bluetooth support], freebsdbt_cv_found, [ - AC_TRY_COMPILE([ - #include <bluetooth.h> - ], [ - struct sockaddr_rfcomm *rfcomm; - ], freebsdbt_cv_found=yes, freebsdbt_cv_found=no) - ]) - if test "${freebsdbt_cv_found}" = "yes"; then + if test "${bsdbt_cv_found}" = "yes"; then BLUETOOTH_LIBS=-lbluetooth + AC_CACHE_CHECK([for BSD Service Discovery support], bsdsdp_cv_found, [ + AC_TRY_COMPILE([ + #include <bluetooth.h> + #include <sdp.h> + ], [ + struct bt_devinquiry di; + sdp_data_t data; + ], bsdsdp_cv_found=yes, bsdsdp_cv_found=no) + ]) fi ]) AC_DEFUN([AC_PATH_BLUEZ], [ - PKG_CHECK_MODULES(BLUETOOTH, bluez, bluez_found=yes, AC_MSG_RESULT(no)) + PKG_CHECK_MODULES(BLUETOOTH, bluez, [ + bluez_found=yes + AC_MSG_CHECKING(for BlueZ Service Discovery support) + AC_TRY_COMPILE([ + #include <bluetooth/sdp.h> + ],[ + sdp_list_t sdplist; + ], bluezsdp_found=yes, bluezsdp_found=no) + ], AC_MSG_RESULT(no)) ]) AC_DEFUN([AC_PATH_BLUETOOTH], [ @@ -83,10 +96,10 @@ AC_DEFUN([AC_PATH_BLUETOOTH], [ AC_PATH_BLUEZ ;; *-*-freebsd*) - AC_PATH_FREEBSDBT + AC_PATH_BSDBT ;; *-*-netbsd*) - AC_PATH_NETBSDBT + AC_PATH_BSDBT ;; *-*-mingw32*) AC_PATH_WINBT @@ -96,44 +109,21 @@ AC_DEFUN([AC_PATH_BLUETOOTH], [ AC_SUBST(BLUETOOTH_LIBS) ]) -AC_DEFUN([BLUETOOTH_CHECK],[ +AC_DEFUN([BLUETOOTH_CHECK],[ AC_ARG_ENABLE([bluetooth], [AC_HELP_STRING([--disable-bluetooth], [Disables bluetooth support @<:@default=auto@:>@])], [ac_bluetooth_enabled=$enableval], [ac_bluetooth_enabled=yes]) if test "$ac_bluetooth_enabled" = yes; then - AC_PATH_BLUETOOTH - if test "${netbsdbt_cv_found}" = "yes" -o "${freebsdbt_cv_found}" = "yes" -o "${bluez_found}" = "yes" -o "${winbt_cv_found}" = "yes"; then + AC_PATH_BLUETOOTH + if test "${bsdbt_cv_found}" = "yes" -o "${bluez_found}" = "yes" -o "${winbt_cv_found}" = "yes"; then AC_DEFINE([HAVE_BLUETOOTH], [1], [Define if system supports Bluetooth and it's enabled]) fi -fi -]) - - -dnl -dnl Check for Bluetooth SDP library -dnl Waring: the AC_TRY_COMPILE won't work with -Werror -dnl - -AC_DEFUN([SDPLIB_CHECK],[ - AC_MSG_CHECKING(for Bluetooth SDP support) - - AC_TRY_COMPILE( [ - #include <bluetooth/sdp.h> - ],[ - sdp_list_t sdplist; - ], - am_cv_sdplib_found=yes, - am_cv_sdplib_found=no - ) - - if test $am_cv_sdplib_found = yes; then - AC_DEFINE(HAVE_SDPLIB,1,[Define if system supports Bluetooth SDP]) - + if test "${bsdsdp_cv_found}" = "yes" -o "${bluezsdp_found}" = "yes"; then + AC_DEFINE([HAVE_SDP], [1], [Define if system supports Bluetooth Service Discovery]) fi - - AC_MSG_RESULT($am_cv_sdplib_found) +fi ]) diff --git a/configure.in b/configure.in index 16bf3ca..9b1439d 100644 --- a/configure.in +++ b/configure.in @@ -41,7 +41,6 @@ dnl IRDA_CHECK BLUETOOTH_CHECK if test "${bluez_found}" = "yes"; then REQUIRES="$REQUIRES bluez" - SDPLIB_CHECK fi USB_CHECK if test "${am_cv_usb_found}" = "yes"; then diff --git a/obexftp/bt_kit.c b/obexftp/bt_kit.c index 41aa224..67ee4ec 100644 --- a/obexftp/bt_kit.c +++ b/obexftp/bt_kit.c @@ -349,8 +349,350 @@ int btkit_unregister_service(int UNUSED(svclass)) #else /* _WIN32 */ -#ifdef HAVE_SDPLIB /* should switch on OS here */ +#ifdef HAVE_SDP +#if defined(__NetBSD__) || defined(__FreeBSD__) +char **btkit_discover(const char *src) +{ + struct bt_devinquiry *di; + char **res; + int num_rsp = 10; + int length = 8; + int i; + + DEBUG(2, "%s: Scanning ...\n", __func__); + + num_rsp = bt_devinquiry(src, length, num_rsp, &di); + if(num_rsp < 0) { + DEBUG(1, "%s: Inquiry failed\n", __func__); + return NULL; + } + + res = calloc(num_rsp + 1, sizeof(char *)); + for(i = 0; i < num_rsp; i++) { + res[i] = bt_malloc(18); /* size of text bdaddr */ + bt_ntoa(&di->bdaddr, res[i]); + DEBUG(2, "%s: Found\t%s\n", __func__, res[i]); + } + + free(di); + + return res; +} + +static int btkit_getname_cb(int UNUSED(s), const struct bt_devinfo *di, void *arg) +{ + + if ((di->enabled)) { + strncpy(arg, di->devname, HCI_DEVNAME_SIZE); + return 1; + } + + return 0; +} + +char *btkit_getname(const char *src, const char *addr) +{ + hci_remote_name_req_cp cp; + hci_remote_name_req_compl_ep ep; + struct bt_devreq req; + int s; + + return_val_if_fail(addr != NULL, NULL); + + if (!src) { + if (bt_devenum(btkit_getname_cb, ep.name) == -1) { + DEBUG(1, "%s: device enumeration failed\n", __func__); + return NULL; + } + + src = (const char *)ep.name; + } + + s = bt_devopen(src, 0); + if (s == -1) { + DEBUG(1, "%s: HCI device open failed\n", __func__); + return NULL; + } + + memset(&cp, 0, sizeof(cp)); + bt_aton(addr, &cp.bdaddr); + + memset(&req, 0, sizeof(req)); + req.opcode = HCI_CMD_REMOTE_NAME_REQ; + req.cparam = &cp; + req.clen = sizeof(cp); + req.event = HCI_EVENT_REMOTE_NAME_REQ_COMPL; + req.rparam = &ep; + req.rlen = sizeof(ep); + + if (bt_devreq(s, &req, 100) == -1) { + DEBUG(1, "%s: remote name request failed\n", __func__); + strcpy(ep.name, "No Name"); + } + + close(s); + + return strndup(ep.name, sizeof(ep.name)); +} + +static int btkit_browse_sdp(sdp_session_t ss, uuid_t *uuid) +{ + uint8_t buf[19]; /* enough for uuid128 (ssp) and uint16 (ail) */ + sdp_data_t seq, ssp, ail, rsp, rec, value, pdl; + uintmax_t channel; + uint16_t attr; + + seq.next = buf; + seq.end = buf + sizeof(buf); + + /* build ServiceSearchPattern */ + ssp.next = seq.next; + sdp_put_uuid(&seq, uuid); + ssp.end = seq.next; + + /* build AttributeIDList */ + ail.next = seq.next; + sdp_put_uint16(&seq, SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST); + ail.end = seq.next; + + if (!sdp_service_search_attribute(ss, &ssp, &ail, &rsp)) { + DEBUG(1, "%s: SDP service search failed\n", __func__); + return -1; + } + + /* + * we expect the response to contain a list of records + * containing ProtocolDescriptorList. Return the first + * one with a valid RFCOMM channel. + */ + while (sdp_get_seq(&rsp, &rec)) { + if (!sdp_get_attr(&rec, &attr, &value) + || attr != SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST) + continue; + + /* drop any alt header */ + sdp_get_alt(&value, &value); + + /* for each protocol stack */ + while (sdp_get_seq(&value, &pdl)) { + /* and for each protocol */ + while (sdp_get_seq(&pdl, &seq)) { + /* check for RFCOMM */ + if (sdp_match_uuid16(&seq, SDP_UUID_PROTOCOL_RFCOMM) + && sdp_get_uint(&seq, &channel) + && channel >= RFCOMM_CHANNEL_MIN + && channel <= RFCOMM_CHANNEL_MAX) + return channel; + } + } + } + + DEBUG(1, "%s: no channel found\n", __func__); + + return -1; +} + +int btkit_browse(const char *src, const char *addr, int svclass) +{ + bdaddr_t laddr, raddr; + sdp_session_t ss; + uuid_t uuid; + int channel; + + return_val_if_fail(addr != NULL, -1); + bt_aton(addr, &raddr); + + if (src) { + if (!bt_devaddr(src, &laddr)) { + DEBUG(1, "%s: invalid source address\n", __func__); + return -1; + } + } else { + bdaddr_copy(&laddr, BDADDR_ANY); + } + + ss = sdp_open(&laddr, &raddr); + if (ss == NULL) { + DEBUG(1, "%s: Failed to connect to SDP server\n", __func__); + return -1; + } + + if (svclass >= 0x0001 && svclass <= 0x0004) { + uuid_dec_be(SVC_UUID_SYNCML, &uuid); + uuid.time_low = svclass; + } else if (svclass >= 0x1000 && svclass <= 0x12FF) { + uuid_dec_be(SVC_UUID_BASE, &uuid); + uuid.time_low = svclass; + } else { + svclass = SDP_SERVICE_CLASS_OBEX_FILE_TRANSFER; + } + + DEBUG(1, "%s: svclass 0x%04x\n", __func__, svclass); + + channel = -1; + + /* Try PCSUITE first */ + if (svclass == SDP_SERVICE_CLASS_OBEX_FILE_TRANSFER) { + DEBUG(1, "%s: trying PCSUITE first\n", __func__); + uuid_dec_be(SVC_UUID_PCSUITE, &uuid); + channel = btkit_browse_sdp(ss, &uuid); + + uuid_dec_be(SVC_UUID_BASE, &uuid); + uuid.time_low = svclass; + } + + if (channel == -1) + channel = btkit_browse_sdp(ss, &uuid); + + sdp_close(ss); + return channel; +} + +static sdp_session_t ss; +static uint32_t opush_handle; +static uint32_t ftrn_handle; +static uint32_t irmc_handle; + +int btkit_register_obex(int svclass, int channel) +{ + uint8_t buffer[256]; + sdp_data_t rec; + uint32_t *hp; + + DEBUG(1, "%s: svclass 0x%04x channel %d\n", __func__, svclass, channel); + + /* Build SDP record */ + rec.next = buffer; + rec.end = buffer + sizeof(buffer); + + sdp_put_uint16(&rec, SDP_ATTR_SERVICE_RECORD_HANDLE); + sdp_put_uint32(&rec, 0x00000000); + + sdp_put_uint16(&rec, SDP_ATTR_SERVICE_CLASS_ID_LIST); + sdp_put_seq(&rec, 3); + sdp_put_uuid16(&rec, (uint16_t)svclass); + + sdp_put_uint16(&rec, SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST); + sdp_put_seq(&rec, 17); + sdp_put_seq(&rec, 3); + sdp_put_uuid16(&rec, SDP_UUID_PROTOCOL_L2CAP); + sdp_put_seq(&rec, 5); + sdp_put_uuid16(&rec, SDP_UUID_PROTOCOL_RFCOMM); + sdp_put_uint8(&rec, (uint8_t)channel); + sdp_put_seq(&rec, 3); + sdp_put_uuid16(&rec, SDP_UUID_PROTOCOL_OBEX); + + sdp_put_uint16(&rec, SDP_ATTR_BROWSE_GROUP_LIST); + sdp_put_seq(&rec, 3); + sdp_put_uuid16(&rec, SDP_SERVICE_CLASS_PUBLIC_BROWSE_GROUP); + + sdp_put_uint16(&rec, SDP_ATTR_LANGUAGE_BASE_ATTRIBUTE_ID_LIST); + sdp_put_seq(&rec, 9); + sdp_put_uint16(&rec, 0x656e); /* "en" */ + sdp_put_uint16(&rec, 106); /* UTF-8 */ + sdp_put_uint16(&rec, SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID); + + sdp_put_uint16(&rec, SDP_ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST); + sdp_put_seq(&rec, 8); + sdp_put_seq(&rec, 6); + sdp_put_uuid16(&rec, (uint16_t)svclass); + sdp_put_uint16(&rec, 0x0100); /* v1.0 */ + + sdp_put_uint16(&rec, SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_SERVICE_NAME_OFFSET); + switch (svclass) { + case SDP_SERVICE_CLASS_OBEX_OBJECT_PUSH: + sdp_put_str(&rec, "OBEX Object Push", -1); + + sdp_put_uint16(&rec, SDP_ATTR_SUPPORTED_FORMATS_LIST); + sdp_put_seq(&rec, 2); + sdp_put_uint8(&rec, 0xff); /* Any */ + hp = &opush_handle; + break; + + case SDP_SERVICE_CLASS_OBEX_FILE_TRANSFER: + sdp_put_str(&rec, "OBEX File Transfer", -1); + hp = &ftrn_handle; + break; + + case SDP_SERVICE_CLASS_IR_MC_SYNC: + sdp_put_str(&rec, "IrMC Sync", -1); + hp = &irmc_handle; + break; + + default: + DEBUG(1, "%s: unknown svclass\n", __func__); + return -1; + break; + } + + rec.end = rec.next; + rec.next = buffer; + + /* Register service with SDP server */ + if (ss == NULL) { + ss = sdp_open_local(NULL); + if (ss == NULL) { + DEBUG(1, "%s: failed to open SDP session\n", __func__); + return -1; + } + DEBUG(2, "%s: opened SDP session\n", __func__); + } + + if (!sdp_record_insert(ss, NULL, hp, &rec)) { + DEBUG(1, "%s: failed to insert SDP record\n", __func__); + sdp_data_print(&rec, 2); + return -1; + } + + return 0; +} + +int btkit_unregister_service(int svclass) +{ + uint32_t *hp; + + if (ss == NULL) { + DEBUG(1, "%s: no session open\n", __func__); + return -1; + } + + switch (svclass) { + case SDP_SERVICE_CLASS_OBEX_OBJECT_PUSH: + hp = &opush_handle; + break; + + case SDP_SERVICE_CLASS_OBEX_FILE_TRANSFER: + hp = &ftrn_handle; + break; + + case SDP_SERVICE_CLASS_IR_MC_SYNC: + hp = &irmc_handle; + break; + + default: + DEBUG(1, "%s: unknown svclass\n", __func__); + return -1; + break; + } + + if (!sdp_record_remove(ss, *hp)) { + DEBUG(1, "%s: failed to remove SDP record\n", __func__); + return -1; + } + + *hp = 0; + + if (opush_handle == 0 && ftrn_handle == 0 && irmc_handle == 0) { + DEBUG(2, "%s: closed SDP session\n", __func__); + sdp_close(ss); + ss = NULL; + } + + return 0; +} + +#else /* defined(__NetBSD__) || defined(__FreeBSD__) */ /** Discover all bluetooth devices in range. @@ -695,6 +1037,7 @@ int btkit_register_obex(int service, int channel) return 0; } +#endif /* BlueZ/Linux */ #else #warning "no bluetooth sdp support for this platform" @@ -723,7 +1066,7 @@ int btkit_unregister_service(int UNUSED(svclass)) return -1; } -#endif /* HAVE_SDPLIB */ +#endif /* HAVE_SDP */ #endif /* _WIN32 */ #else diff --git a/obexftp/bt_kit.h b/obexftp/bt_kit.h index 154c73b..6eeba6b 100644 --- a/obexftp/bt_kit.h +++ b/obexftp/bt_kit.h @@ -79,26 +79,26 @@ extern "C" { BTKITSYM int ba2str(const bdaddr_t *btaddr, char *straddr); BTKITSYM int str2ba(const char *straddr, BTH_ADDR *btaddr); -/* FreeBSD 5 and up */ -#elif defined(__FreeBSD__) -//#include <sys/types.h> +/* Various BSD systems */ +#elif defined(__NetBSD__) || defined(__FreeBSD__) +#define COMPAT_BLUEZ #include <bluetooth.h> -#define sockaddr_rc sockaddr_rfcomm -#define rc_family rfcomm_family -#define rc_bdaddr rfcomm_bdaddr -#define rc_channel rfcomm_channel -#define BTPROTO_RFCOMM BLUETOOTH_PROTO_RFCOMM -#define BDADDR_ANY NG_HCI_BDADDR_ANY +#ifdef HAVE_SDP +#include <sdp.h> +#include <string.h> +#endif -/* NetBSD-4 and up */ -#elif defined(__NetBSD__) -#include <bluetooth.h> -#include <netbt/rfcomm.h> -#define sockaddr_rc sockaddr_bt -#define rc_family bt_family -#define rc_bdaddr bt_bdaddr -#define rc_channel bt_channel +#ifndef BDADDR_ANY #define BDADDR_ANY NG_HCI_BDADDR_ANY +#endif + +#ifndef RFCOMM_CHANNEL_MIN +#define RFCOMM_CHANNEL_MIN 1 +#endif + +#ifndef RFCOMM_CHANNEL_MAX +#define RFCOMM_CHANNEL_MAX 30 +#endif /* BlueZ, Linux 2.4.6 and up (incl. 2.6) */ #else diff --git a/obexftp/client.c b/obexftp/client.c index e0f494f..15ec298 100644 --- a/obexftp/client.c +++ b/obexftp/client.c @@ -664,7 +664,12 @@ int obexftp_connect_src(obexftp_client_t *cli, const char *src, const char *devi if (!src) { bacpy(&src_addr, BDADDR_ANY); } -#ifdef HAVE_SDPLIB +#if defined(_WIN32) + /* nothing */ +#elif defined(__NetBSD__) || defined(__FreeBSD__) + else if (bt_devaddr(src, &src_addr)) { + } +#else else if (!strncmp(src, "hci", 3)) { hci_devba(atoi(src + 3), &src_addr); } -- 1.7.4.1 |
From: <pl...@ne...> - 2011-06-30 20:45:33
|
From: Iain Hibbert <pl...@ne...> --- obexftp/client.c | 2 +- obexftp/unicode.c | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/obexftp/client.c b/obexftp/client.c index b5243e7..e0f494f 100644 --- a/obexftp/client.c +++ b/obexftp/client.c @@ -569,7 +569,7 @@ int obexftp_connect_uuid(obexftp_client_t *cli, const char *device, int port, co int obexftp_connect_service(obexftp_client_t *cli, const char *src, const char *device, int port, int service) { - uint8_t *uuid = NULL; + const uint8_t *uuid = NULL; uint32_t uuid_len = 0; if (service == OBEX_FTP_SERVICE) { uuid = UUID_FBS; diff --git a/obexftp/unicode.c b/obexftp/unicode.c index dda8c6d..0c6c935 100644 --- a/obexftp/unicode.c +++ b/obexftp/unicode.c @@ -82,8 +82,8 @@ int CharToUnicode(uint8_t *uc, const uint8_t *c, int size) size_t ni, no, nrc; int ret; /* avoid type-punned dereferecing (breaks strict aliasing) */ - char *cc = c; - char *ucc = uc; + const char *cc = (const char *)c; + char *ucc = (char *)uc; return_val_if_fail(uc != NULL, -1); return_val_if_fail(c != NULL, -1); @@ -103,8 +103,8 @@ int CharToUnicode(uint8_t *uc, const uint8_t *c, int size) /* try current locale charset to UTF-16BE */ setlocale(LC_CTYPE, ""); DEBUG(2, "Iconv from locale \"%s\"\n", locale_charset); - cc = c; - ucc = uc; + cc = (const char *)c; + ucc = (char *)uc; ni = strlen(cc) + 1; no = size; utf16 = iconv_open("UTF-16BE", locale_charset); @@ -117,8 +117,8 @@ int CharToUnicode(uint8_t *uc, const uint8_t *c, int size) } /* fallback to ISO-8859-1 to UTF-16BE (every byte is valid here) */ - cc = c; - ucc = uc; + cc = (const char *)c; + ucc = (char *)uc; ni = strlen(cc) + 1; no = size; utf16 = iconv_open("UTF-16BE", "ISO-8859-1"); @@ -190,8 +190,8 @@ int UnicodeToChar(uint8_t *c, const uint8_t *uc, int size) size_t ni, no, nrc; int ret; /* avoid type-punned dereferecing (breaks strict aliasing) */ - char *cc = c; - char *ucc = uc; + char *cc = (char *)c; + const char *ucc = (const char *)uc; return_val_if_fail(uc != NULL, -1); return_val_if_fail(c != NULL, -1); @@ -265,8 +265,8 @@ int Utf8ToChar(uint8_t *c, const uint8_t *uc, int size) size_t ni, no, nrc; int ret; /* avoid type-punned dereferecing (breaks strict aliasing) */ - char *cc = c; - char *ucc = uc; + char *cc = (char *)c; + const char *ucc = (const char *)uc; return_val_if_fail(uc != NULL, -1); return_val_if_fail(c != NULL, -1); -- 1.7.4.1 |
From: Hendrik S. <po...@he...> - 2011-07-01 18:11:36
|
Am Donnerstag, 30. Juni 2011, 22:39:33 schrieb pl...@ne...: > From: Iain Hibbert <pl...@ry...> I pushed all 8 patches to my repository... Thanks :-) HS |
From: Iain H. <pl...@ry...> - 2011-07-02 11:13:37
|
On Fri, 1 Jul 2011, Hendrik Sattler wrote: > Am Donnerstag, 30. Juni 2011, 22:39:33 schrieb pl...@ne...: > > From: Iain Hibbert <pl...@ry...> > > I pushed all 8 patches to my repository... ok thanks, at least it is outside my hard disk :) there may be one more issue, with the change I proposed to openobex wrt the bt_addr_t definition and the BtOBEX_ prototypes - apps/obexftpd uses BtOBEX_ServerRegister() directly, so <obexftp/bt_kit.h> would need to be included before <openobex/obex.h> as per below, but will leave that for later.. regards, iain --- apps/obexftpd.c.orig +++ apps/obexftpd.c @@ -56,6 +56,8 @@ #include <netdb.h> #endif +#include <obexftp/bt_kit.h> + /* just until there is a server layer in obexftp */ #include <openobex/obex.h> |
From: Hendrik S. <po...@he...> - 2011-07-02 14:45:36
|
Am Samstag, 2. Juli 2011, 13:13:31 schrieb Iain Hibbert: > On Fri, 1 Jul 2011, Hendrik Sattler wrote: > > Am Donnerstag, 30. Juni 2011, 22:39:33 schrieb pl...@ne...: > > > From: Iain Hibbert <pl...@ry...> > > > > I pushed all 8 patches to my repository... > > ok thanks, at least it is outside my hard disk :) > > there may be one more issue, with the change I proposed to openobex wrt > the bt_addr_t definition and the BtOBEX_ prototypes - apps/obexftpd uses > BtOBEX_ServerRegister() directly, so <obexftp/bt_kit.h> would need to be > included before <openobex/obex.h> as per below, but will leave that for > later.. > > regards, > iain > > --- apps/obexftpd.c.orig > +++ apps/obexftpd.c > @@ -56,6 +56,8 @@ > #include <netdb.h> > #endif > > +#include <obexftp/bt_kit.h> > + > /* just until there is a server layer in obexftp */ > #include <openobex/obex.h> That's ok because the previous solution did hide this bug. Can you post that as something that "git am" can eat? HS |
From: <pl...@ry...> - 2011-07-02 16:36:46
|
From: Iain Hibbert <pl...@ne...> --- apps/obexftpd.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/apps/obexftpd.c b/apps/obexftpd.c index 8833ad0..3b268f6 100644 --- a/apps/obexftpd.c +++ b/apps/obexftpd.c @@ -56,6 +56,8 @@ #include <netdb.h> #endif +#include <obexftp/bt_kit.h> + /* just until there is a server layer in obexftp */ #include <openobex/obex.h> -- 1.7.4.1 |
From: Hendrik S. <po...@he...> - 2011-06-30 16:34:03
|
Am Donnerstag, 30. Juni 2011, 17:57:18 schrieb pl...@ne...: > -dnl > -dnl Check for Bluetooth SDP library > -dnl Waring: the AC_TRY_COMPILE won't work with -Werror > -dnl > - > -AC_DEFUN([SDPLIB_CHECK],[ > - AC_MSG_CHECKING(for Bluetooth SDP support) > - > - AC_TRY_COMPILE( [ > - #include <bluetooth/sdp.h> > - ],[ > - sdp_list_t sdplist; > - ], > - am_cv_sdplib_found=yes, > - am_cv_sdplib_found=no > - ) > - > - if test $am_cv_sdplib_found = yes; then > - AC_DEFINE(HAVE_SDPLIB,1,[Define if system supports Bluetooth SDP]) > - > + if test "${bsdsdp_found}" = "yes" -o "${bluezsdp_found}" = "yes"; then > + AC_DEFINE([HAVE_SDP], [1], [Define if system supports Bluetooth Service > Discovery]) fi > - > - AC_MSG_RESULT($am_cv_sdplib_found) > +fi > ]) This results in checking for BlueZ Service Discovery support... ../configure: line 13598: SDPLIB_CHECK: command not found HS |
From: Hendrik S. <po...@he...> - 2011-06-30 17:35:23
|
Am Donnerstag, 30. Juni 2011, 18:33:51 schrieb Hendrik Sattler: > Am Donnerstag, 30. Juni 2011, 17:57:18 schrieb pl...@ne...: > > -dnl > > -dnl Check for Bluetooth SDP library > > -dnl Waring: the AC_TRY_COMPILE won't work with -Werror > > -dnl > > - > > -AC_DEFUN([SDPLIB_CHECK],[ > > - AC_MSG_CHECKING(for Bluetooth SDP support) > > - > > - AC_TRY_COMPILE( [ > > - #include <bluetooth/sdp.h> > > - ],[ > > - sdp_list_t sdplist; > > - ], > > - am_cv_sdplib_found=yes, > > - am_cv_sdplib_found=no > > - ) > > - > > - if test $am_cv_sdplib_found = yes; then > > - AC_DEFINE(HAVE_SDPLIB,1,[Define if system supports Bluetooth SDP]) > > - > > + if test "${bsdsdp_found}" = "yes" -o "${bluezsdp_found}" = "yes"; then > > + AC_DEFINE([HAVE_SDP], [1], [Define if system supports Bluetooth > > Service > > > Discovery]) fi > > - > > - AC_MSG_RESULT($am_cv_sdplib_found) > > +fi > > > > ]) > > This results in > checking for BlueZ Service Discovery support... ../configure: line 13598: > SDPLIB_CHECK: command not found And maybe you want to pull my tree, I added three useful commits :-) However, one may conflict with this one but nothing difficult... HS |