Add openobex, a library for OBEX (Object Exchange), a protocol to exchange

a data over infrared and Bluetooth.

This port is adapted to work with FreeBSD Bluetooth stack.

PR:		ports/64596
Submitted by:	Guido Falsi <mad@madpilot.net>
This commit is contained in:
Pav Lucistnik 2004-03-23 19:57:59 +00:00
parent 9859e5fe3e
commit cae842bacf
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=105079
15 changed files with 363 additions and 0 deletions

View File

@ -43,6 +43,7 @@
SUBDIR += mlan3
SUBDIR += mserver
SUBDIR += mwavem
SUBDIR += openobex
SUBDIR += p5-Device-Modem
SUBDIR += p5-Device-SerialPort
SUBDIR += plp

23
comms/openobex/Makefile Normal file
View File

@ -0,0 +1,23 @@
# New ports collection makefile for: openobex
# Date created: 15 March 2004
# Whom: Guido Falsi <mad@madpilot.net>
#
# $FreeBSD$
#
PORTNAME= openobex
PORTVERSION= 1.0.1
CATEGORIES= comms net
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE}
MASTER_SITE_SUBDIR= ${PORTNAME}
MAINTAINER= mad@madpilot.net
COMMENT= Open source implementation of the OBEX protocol
WANT_AUTOCONF_VER= 213
WANT_AUTOMAKE_VER= 14
USE_GMAKE= yes
WANT_LIBTOOL_VER= 14
INSTALLS_SHLIB= yes
.include <bsd.port.mk>

1
comms/openobex/distinfo Normal file
View File

@ -0,0 +1 @@
MD5 (openobex-1.0.1.tar.gz) = 3742666bb98259face76be49b73ea89d

View File

@ -0,0 +1,38 @@
--- aclocal.m4.orig Mon Mar 22 16:19:39 2004
+++ aclocal.m4 Mon Mar 22 16:22:51 2004
@@ -67,6 +67,35 @@
BLUETOOTH_HOOK([],failure)
])
+dnl adding a check for FreeBSD blutooth netgraph support.
+
+AC_DEFUN([FREEBSD_BLUETOOTH_HOOK],[
+ AC_MSG_CHECKING([for the FreeBSD/netgraph bluetooth support])
+ echo
+ AC_CACHE_CHECK(for the struct sockaddr_rfcomm in <netgraph/.../ng_btsocket.h>, ac_cv_have_sockaddr_rfcomm,
+ [AC_TRY_COMPILE([#include <sys/types.h>
+ #include <sys/socket.h>
+ #include <bitstring.h>
+ #include <netgraph/bluetooth/include/ng_hci.h>
+ #include <netgraph/bluetooth/include/ng_l2cap.h>
+ #include <netgraph/bluetooth/include/ng_btsocket.h>],
+ [struct sockaddr_rfcomm rc;],
+ ac_cv_have_sockaddr_rfcomm=yes,
+ ac_cv_have_sockaddr_rfcomm=no)])
+
+ if test $ac_cv_have_sockaddr_rfcomm = yes; then
+ AC_DEFINE(HAVE_BLUETOOTH)
+ AC_DEFINE(HAVE_BLUETOOTH_NETGRAPH,1,[Compile on FreeBSD])
+ USE_BLUETOOTH="yes"
+ AC_CHECK_LIB(bluetooth, bt_aton,
+ [LIBS="$LIBS -lbluetooth" AC_DEFINE(HAVE_BT_ATON,1,[Define to 1 if you have the \`bt_aton' function.])])
+ fi
+])
+
+AC_DEFUN([FREEBSD_BLUETOOTH_CHECK], [
+ FREEBSD_BLUETOOTH_HOOK([],failure)
+])
+
# Do all the work for Automake. This macro actually does too much --
# some checks are only needed if your package does certain things.
# But this isn't really a big deal.

View File

@ -0,0 +1,10 @@
--- configure.in.orig Sun Mar 7 17:07:07 2004
+++ configure.in Sun Mar 7 17:07:20 2004
@@ -39,6 +39,7 @@
IRDA_CHECK
BLUETOOTH_CHECK
+FREEBSD_BLUETOOTH_CHECK
dnl Configure debug facilities
AC_ARG_WITH(debug,[ --with-debug=level Debug level],

View File

@ -0,0 +1,42 @@
--- ltmain.sh.orig Wed Oct 1 13:17:13 2003
+++ ltmain.sh Mon Mar 22 10:54:43 2004
@@ -1037,8 +1037,16 @@
continue
;;
+ -pthread)
+ compile_command="$compile_command -pthread"
+ finalize_command="$finalize_command -pthread"
+ compiler_flags="$compiler_flags -pthread"
+ continue
+ ;;
+
-module)
module=yes
+ build_old_libs=no
continue
;;
@@ -2408,6 +2416,9 @@
*-*-netbsd*)
# Don't link with libc until the a.out ld.so is fixed.
;;
+ *-*-freebsd*)
+ # FreeBSD doesn't need this...
+ ;;
*)
# Add libc to deplibs on all other systems if necessary.
if test "$build_libtool_need_lc" = "yes"; then
@@ -4175,10 +4186,12 @@
fi
# Install the pseudo-library for information purposes.
+ if /usr/bin/false; then
name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
instname="$dir/$name"i
$show "$install_prog $instname $destdir/$name"
$run eval "$install_prog $instname $destdir/$name" || exit $?
+ fi
# Maybe install the static library, too.
test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"

View File

@ -0,0 +1,110 @@
--- src/btobex.c.orig Mon Mar 22 18:31:43 2004
+++ src/btobex.c Mon Mar 22 18:44:46 2004
@@ -46,8 +46,12 @@
#include <netinet/in.h>
#include <sys/socket.h>
+#ifdef HAVE_BLUETOOTH_NETGRAPH
+#include <bluetooth.h>
+#else /*HAVE_BLUETOOTH_NETGRAPH*/
#include <bluetooth/bluetooth.h>
#include <bluetooth/rfcomm.h>
+#endif /*HAVE_BLUETOOTH_NETGRAPH*/
#endif /* _WIN32 */
@@ -65,6 +69,15 @@
void btobex_prepare_connect(obex_t *self, bdaddr_t *src, bdaddr_t *dst, uint8_t channel)
{
#ifndef _WIN32
+#ifdef HAVE_BLUETOOTH_NETGRAPH
+ self->trans.self.rfcomm.rfcomm_family = AF_BLUETOOTH;
+ bacpy(&self->trans.self.rfcomm.rfcomm_bdaddr, src);
+ self->trans.self.rfcomm.rfcomm_channel = 0;
+
+ self->trans.peer.rfcomm.rfcomm_family = AF_BLUETOOTH;
+ bacpy(&self->trans.peer.rfcomm.rfcomm_bdaddr, dst);
+ self->trans.peer.rfcomm.rfcomm_channel = channel;
+#else /*HAVE_BLUETOOTH_NETGRAPH*/
self->trans.self.rfcomm.rc_family = AF_BLUETOOTH;
bacpy(&self->trans.self.rfcomm.rc_bdaddr, src);
self->trans.self.rfcomm.rc_channel = 0;
@@ -72,6 +85,7 @@
self->trans.peer.rfcomm.rc_family = AF_BLUETOOTH;
bacpy(&self->trans.peer.rfcomm.rc_bdaddr, dst);
self->trans.peer.rfcomm.rc_channel = channel;
+#endif /*HAVE_BLUETOOTH_NETGRAPH*/
#endif /* _WIN32 */
}
@@ -85,9 +99,15 @@
{
#ifndef _WIN32
/* Bind local service */
+#ifdef HAVE_BLUETOOTH_NETGRAPH
+ self->trans.self.rfcomm.rfcomm_family = AF_BLUETOOTH;
+ bacpy(&self->trans.self.rfcomm.rfcomm_bdaddr, src);
+ self->trans.self.rfcomm.rfcomm_channel = channel;
+#else /*HAVE_BLUETOOTH_NETGRAPH*/
self->trans.self.rfcomm.rc_family = AF_BLUETOOTH;
bacpy(&self->trans.self.rfcomm.rc_bdaddr, src);
self->trans.self.rfcomm.rc_channel = channel;
+#endif /*HAVE_BLUETOOTH_NETGRAPH*/
#endif /* _WIN32 */
}
@@ -108,9 +128,15 @@
return -1;
}
+#ifdef HAVE_BLUETOOTH_NETGRAPH
+ if (bind(self->serverfd, (struct sockaddr*) &self->trans.self.rfcomm,
+ sizeof(struct sockaddr_rfcomm)))
+ {
+#else /*HAVE_BLUETOOTH_NETGRAPH*/
if (bind(self->serverfd, (struct sockaddr*) &self->trans.self.rfcomm,
sizeof(struct sockaddr_rc)))
{
+#endif /*HAVE_BLUETOOTH_NETGRAPH*/
DEBUG(0, "Error doing bind\n");
goto out_freesock;
}
@@ -142,7 +168,11 @@
int btobex_accept(obex_t *self)
{
#ifndef _WIN32
+#ifdef HAVE_BLUETOOTH_NETGRAPH
+ int addrlen = sizeof(struct sockaddr_rfcomm);
+#else /*HAVE_BLUETOOTH_NETGRAPH*/
int addrlen = sizeof(struct sockaddr_rc);
+#endif /*HAVE_BLUETOOTH_NETGRAPH*/
//int mtu;
//int len = sizeof(int);
@@ -180,16 +210,26 @@
return -1;
}
+#ifdef HAVE_BLUETOOTH_NETGRAPH
+ ret = bind(self->fd, (struct sockaddr*) &self->trans.self.rfcomm,
+ sizeof(struct sockaddr_rfcomm));
+#else /*HAVE_BLUETOOTH_NETGRAPH*/
ret = bind(self->fd, (struct sockaddr*) &self->trans.self.rfcomm,
sizeof(struct sockaddr_rc));
+#endif /*HAVE_BLUETOOTH_NETGRAPH*/
if (ret < 0) {
DEBUG(4, "ret=%d\n", ret);
goto out_freesock;
}
+#ifdef HAVE_BLUETOOTH_NETGRAPH
+ ret = connect(self->fd, (struct sockaddr*) &self->trans.peer.rfcomm,
+ sizeof(struct sockaddr_rfcomm));
+#else /*HAVE_BLUETOOTH_NETGRAPH*/
ret = connect(self->fd, (struct sockaddr*) &self->trans.peer.rfcomm,
sizeof(struct sockaddr_rc));
+#endif /*HAVE_BLUETOOTH_NETGRAPH*/
if (ret < 0) {
DEBUG(4, "ret=%d\n", ret);
goto out_freesock;

View File

@ -0,0 +1,11 @@
--- src/netbuf.h.orig Wed Oct 1 13:17:13 2003
+++ src/netbuf.h Mon Mar 22 10:47:07 2004
@@ -37,7 +37,7 @@
#ifndef G_NETBUF_H
#define G_NETBUF_H
-#include <stdint.h>
+#include <sys/types.h>
typedef struct _slist_t{
void *data;

View File

@ -0,0 +1,26 @@
--- src/obex.c.orig Mon Mar 22 18:16:53 2004
+++ src/obex.c Mon Mar 22 18:21:35 2004
@@ -990,7 +990,11 @@
#ifdef HAVE_BLUETOOTH
if(src == NULL)
+#ifdef HAVE_BLUETOOTH_NETGRAPH
+ src = NG_HCI_BDADDR_ANY;
+#else /*HAVE_BLUETOOTH_NETGRAPH*/
src = BDADDR_ANY;
+#endif /*HAVE_BLUETOOTH_NETGRAPH*/
btobex_prepare_listen(self, src, channel);
return obex_transport_listen(self);
#else
@@ -1019,7 +1023,11 @@
#ifdef HAVE_BLUETOOTH
if(src == NULL)
+#ifdef HAVE_BLUETOOTH_NETGRAPH
+ src = NG_HCI_BDADDR_ANY;
+#else /*HAVE_BLUETOOTH_NETGRAPH*/
src = BDADDR_ANY;
+#endif /*HAVE_BLUETOOTH_NETGRAPH*/
btobex_prepare_connect(self, src, dst, channel);
return obex_transport_connect_request(self);
#else

View File

@ -0,0 +1,11 @@
--- src/obex.h.orig Wed Oct 1 13:17:13 2003
+++ src/obex.h Mon Mar 22 11:11:11 2004
@@ -30,7 +30,7 @@
#ifndef OBEX_H
#define OBEX_H
-#include <stdint.h>
+#include <sys/types.h>
#ifdef _WIN32
#include <winsock.h>

View File

@ -0,0 +1,11 @@
--- src/obex_const.h.orig Wed Oct 1 13:17:13 2003
+++ src/obex_const.h Mon Mar 22 10:44:58 2004
@@ -30,8 +30,6 @@
#ifndef OBEX_CONST_H
#define OBEX_CONST_H
-#include <stdint.h>
-
typedef union {
uint32_t bq4;
uint8_t bq1;

View File

@ -0,0 +1,26 @@
--- src/obex_main.c.orig Mon Mar 22 18:25:05 2004
+++ src/obex_main.c Mon Mar 22 18:27:55 2004
@@ -46,7 +46,11 @@
#include <stdio.h>
#ifdef HAVE_BLUETOOTH
+#ifdef HAVE_BLUETOOTH_NETGRAPH
+#include <bluetooth.h>
+#else /*HAVE_BLUETOOTH_NETGRAPH*/
#include <bluetooth/bluetooth.h>
+#endif /*HAVE_BLUETOOTH_NETGRAPH*/
#endif /*HAVE_BLUETOOTH*/
#endif /* _WIN32 */
@@ -79,7 +83,11 @@
#ifdef HAVE_BLUETOOTH
if (domain == AF_BLUETOOTH)
+#ifdef HAVE_BLUETOOTH_NETGRAPH
+ proto = BLUETOOTH_PROTO_RFCOMM;
+#else /*HAVE_BLUETOOTH_NETGRAPH*/
proto = BTPROTO_RFCOMM;
+#endif /*HAVE_BLUETOOTH_NETGRAPH*/
#endif /*HAVE_BLUETOOTH*/
fd = socket(domain, SOCK_STREAM, proto);

View File

@ -0,0 +1,36 @@
--- src/obex_transport.h.orig Mon Mar 22 18:02:08 2004
+++ src/obex_transport.h Mon Mar 22 18:05:08 2004
@@ -40,8 +40,12 @@
#include "irda_wrap.h"
#endif /*HAVE_IRDA*/
#ifdef HAVE_BLUETOOTH
+#ifdef HAVE_BLUETOOTH_NETGRAPH
+#include <bluetooth.h>
+#else /*HAVE_BLUETOOTH_NETGRAPH*/
#include <bluetooth/bluetooth.h>
#include <bluetooth/rfcomm.h>
+#endif /*HAVE_BLUETOOTH_NETGRAPH*/
#endif /*HAVE_BLUETOOTH*/
#include "obex_main.h"
@@ -52,7 +56,11 @@
#endif /*HAVE_IRDA*/
struct sockaddr_in inet;
#ifdef HAVE_BLUETOOTH
+#ifdef HAVE_BLUETOOTH_NETGRAPH
+ struct sockaddr_rfcomm rfcomm;
+#else /*HAVE_BLUETOOTH_NETGRAPH*/
struct sockaddr_rc rfcomm;
+#endif /*HAVE_BLUETOOTH_NETGRAPH*/
#endif /*HAVE_BLUETOOTH*/
} saddr_t;
@@ -76,7 +84,4 @@
int obex_transport_read(obex_t *self, int count, uint8_t *buf, int buflen);
-#endif OBEX_TRANSPORT_H
-
-
-
+#endif /*OBEX_TRANSPORT_H*/

8
comms/openobex/pkg-descr Normal file
View File

@ -0,0 +1,8 @@
The overall goal of this project is to make an open source
implementation of the Object Exchange (OBEX) protocol. OBEX is a
session protocol and can best be described as a binary HTTP protocol.
It's used mainly for Infrared and Bluetooth communication.
WWW: http://openobex.sourceforge.net/
- Guido Falsi <mad@madpilot.net>

9
comms/openobex/pkg-plist Normal file
View File

@ -0,0 +1,9 @@
bin/openobex-config
include/openobex/obex.h
include/openobex/obex_const.h
lib/libopenobex-1.0.so
lib/libopenobex-1.0.so.1
lib/libopenobex.a
lib/libopenobex.so
share/aclocal/openobex.m4
@dirrm include/openobex