pkgsrc/comms/obexftp/patches/patch-ak

73 lines
1.5 KiB
Text

$NetBSD: patch-ak,v 1.3 2009/07/20 05:56:03 hasso Exp $
--- apps/obexftp_sdp.c.orig 2006-03-08 00:34:15.000000000 +0100
+++ apps/obexftp_sdp.c
@@ -25,6 +25,8 @@
#include <config.h>
#endif
+#ifdef HAVE_BLUETOOTH
+
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
@@ -34,6 +36,53 @@
#include <sys/types.h>
#include <sys/socket.h>
+#if defined(__NetBSD__) || defined(__DragonFly__)
+#include <bluetooth.h>
+#include <sdp.h>
+
+#include "obexftp_sdp.h"
+
+#define OBEXFTP_RFCOMM_CHANNEL 10
+
+static void *session;
+
+void
+obexftp_sdp_unregister(void)
+{
+ sdp_close(session);
+}
+
+int
+obexftp_sdp_register(void)
+{
+ sdp_ftrn_profile_t ftrn;
+ bdaddr_t bdaddr;
+
+ memset(&ftrn, 0, sizeof(ftrn));
+ ftrn.server_channel = OBEXFTP_RFCOMM_CHANNEL;
+
+ bdaddr_copy(&bdaddr, BDADDR_ANY);
+
+ session = sdp_open_local(NULL);
+ if (session == NULL || (errno = sdp_error(session))) {
+ syslog(LOG_ERR, "Failed to connect to the local SDP server. %s(%d)",
+ strerror(errno), errno);
+
+ return -1;
+ }
+
+ if (sdp_register_service(session, SDP_SERVICE_CLASS_OBEX_FILE_TRANSFER,
+ &bdaddr, (uint8_t *)&ftrn, sizeof(ftrn), NULL) != 0) {
+ errno = sdp_error(session);
+ syslog(LOG_ERR, "SDP registration failed. %s(%d)",
+ strerror(errno), errno);
+ sdp_close(session);
+ return -1;
+ }
+
+ return 0;
+}
+#else /* __NetBSD__ */
#include <bluetooth/bluetooth.h>
#include <bluetooth/sdp.h>
#include <bluetooth/sdp_lib.h>
@@ -173,3 +222,5 @@ int obexftp_sdp_search(bdaddr_t *src, bd
return 0;
}
*/
+#endif /* !__NetBSD__ */
+#endif /* HAVE_BLUETOOTH */