Skip to content

Commit

Permalink
Initial import of obexapp-1.4.4.
Browse files Browse the repository at this point in the history
An obex application to transfer objects (address book items, images, movies,
anything the target can handle) to mobile devices via IrDA, Bluetooth and other
protocol via the OBEX format.

xtraeme: now it should be possible to transfer files from/to my cellular
phone from NetBSD.
  • Loading branch information
xtraeme committed Jul 2, 2006
1 parent bee2fbd commit 1e1ee23
Show file tree
Hide file tree
Showing 9 changed files with 327 additions and 0 deletions.
3 changes: 3 additions & 0 deletions comms/obexapp/DESCR
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
An obex application to transfer objects (address book items, images, movies,
anything the target can handle) to mobile devices via IrDA, Bluetooth and other
protocol via the OBEX format.
36 changes: 36 additions & 0 deletions comms/obexapp/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# $NetBSD: Makefile,v 1.1.1.1 2006/07/02 18:18:34 xtraeme Exp $
#

DISTNAME= obexapp-1.4.4
CATEGORIES= comms
MASTER_SITES= http://www.geocities.com/m_evmenkin/

MAINTAINER= [email protected]
HOMEPAGE= http://www.geocities.com/m_evmenkin/
COMMENT= Obex application to transfer objects to mobile equipment

WRKSRC= ${WRKDIR}/obexapp

SUBST_CLASSES+= mk
SUBST_FILES.mk= Makefile
SUBST_STAGE.mk= post-configure
SUBST_SED.mk= -e "s|-lbsdxml|-lexpat|"
SUBST_SED.mk+= -e "s|/usr/local/man|${PREFIX}|"
SUBST_SED.mk+= -e "s|/usr/local|${PREFIX}|"
SUBST_SED.mk+= -e "s|CFLAGS=|CFLAGS+=|"

# Sigh, this needs the GNU libiconv.
USE_GNU_ICONV= yes

# Version that contains support for NetBSD/bluetooth.
BUILDLINK_ABI_DEPENDS.openobex+= openobex>=1.0.1nb3

# Sigh... too many warnings with GCC 4.x, disable them for now.
CFLAGS+= -w


.include "../../comms/openobex/buildlink3.mk"
.include "../../converters/libiconv/buildlink3.mk"
.include "../../devel/readline/buildlink3.mk"
.include "../../textproc/expat/buildlink3.mk"
.include "../../mk/bsd.pkg.mk"
4 changes: 4 additions & 0 deletions comms/obexapp/PLIST
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@comment $NetBSD: PLIST,v 1.1.1.1 2006/07/02 18:18:34 xtraeme Exp $
bin/obexapp
man/cat1/obexapp.0
man/man1/obexapp.1
10 changes: 10 additions & 0 deletions comms/obexapp/distinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
$NetBSD: distinfo,v 1.1.1.1 2006/07/02 18:18:34 xtraeme Exp $

SHA1 (obexapp-1.4.4.tar.gz) = 4d99ff1e636109dd8013d1c4bc5b2852103e4071
RMD160 (obexapp-1.4.4.tar.gz) = d4ca4229e8e63158366bef72e39323b249aca614
Size (obexapp-1.4.4.tar.gz) = 245156 bytes
SHA1 (patch-aa) = 72d58a720378787f2083f55a46dc62a146a10f95
SHA1 (patch-ab) = 8b6f6f84ba815bc3416822cfbe1fa76ae751b909
SHA1 (patch-ac) = 0ea10dd4847237fbc8dcb0bfce7e20248d2867b1
SHA1 (patch-ad) = 02c68786f9621ad4ff4c68653973a549e82de0f7
SHA1 (patch-ae) = d9a09e9ca0118ebb489507e2fe9965fbded4552b
16 changes: 16 additions & 0 deletions comms/obexapp/patches/patch-aa
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
$NetBSD: patch-aa,v 1.1.1.1 2006/07/02 18:18:34 xtraeme Exp $

--- obexapp.h.orig 2006-07-02 19:32:51.000000000 +0200
+++ obexapp.h 2006-07-02 19:33:45.000000000 +0200
@@ -71,7 +71,11 @@

struct context
{
+#ifdef __NetBSD__
+ struct sockaddr_bt addr; /* remote address */
+#else
struct sockaddr_rfcomm addr; /* remote address */
+#endif
bdaddr_t saddr; /* local address */
char *root; /* root path */
char *user; /* user */
113 changes: 113 additions & 0 deletions comms/obexapp/patches/patch-ab
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
$NetBSD: patch-ab,v 1.1.1.1 2006/07/02 18:18:34 xtraeme Exp $

--- main.c.orig 2004-12-24 00:09:48.000000000 +0100
+++ main.c 2006-07-02 19:48:19.000000000 +0200
@@ -90,8 +90,13 @@

/* Prepare context */
memset(&context, 0, sizeof(context));
+#ifdef __NetBSD__
+ context.addr.bt_len = sizeof(context.addr.bt_len);
+ context.addr.bt_family = AF_BLUETOOTH;
+#else
context.addr.rfcomm_len = sizeof(context.addr.rfcomm_len);
context.addr.rfcomm_family = AF_BLUETOOTH;
+#endif
context.tfd = context.sfd = -1;
context.detach = 1;

@@ -148,15 +153,23 @@
while ((n = getopt(argc, argv, "a:A:cC:dDfhnr:Ssu:")) != -1) {
switch (n) {
case 'a':
+#ifdef __NetBSD__
+ if (!bt_aton(optarg, &context.addr.bt_bdaddr)) {
+#else
if (!bt_aton(optarg, &context.addr.rfcomm_bdaddr)) {
+#endif
struct hostent *he = bt_gethostbyname(optarg);

if (he == NULL)
errx(1, "%s: %s", optarg,
hstrerror(h_errno));
-
+#ifdef __NetBSD__
+ memcpy(&context.addr.bt_bdaddr, he->h_addr,
+ sizeof(context.addr.bt_bdaddr));
+#else
memcpy(&context.addr.rfcomm_bdaddr, he->h_addr,
sizeof(context.addr.rfcomm_bdaddr));
+#endif
}
break;

@@ -178,11 +191,19 @@
break;

case 'C': /* channel to listen on or connect to */
+#ifdef __NetBSD__
+ context.addr.bt_channel = strtoul(optarg, &ep, 10);
+#else
context.addr.rfcomm_channel = strtoul(optarg, &ep, 10);
+#endif
if (*ep != '\0') {
+#ifdef __NetBSD__
+ context.addr.bt_channel = 0;
+#else
context.addr.rfcomm_channel = 0;
+#endif

- switch (tolower(optarg[0])) {
+ switch (tolower((unsigned char)optarg[0])) {
case 'i': /* IrMC */
service = SDP_SERVICE_CLASS_IR_MC_SYNC;
break;
@@ -254,10 +275,25 @@
argv += optind;

if (!context.server) {
+#ifdef __NetBSD__
+ if (memcmp(&context.addr.bt_bdaddr,
+ BDADDR_ANY, sizeof(context.addr.bt_bdaddr)) == 0)
+ errx(1, "Must specify server BD_ADDR");
+
+ /* Check channel, if was not set then obtain it via SDP */
+ if (context.addr.bt_channel == 0 && service != 0) {
+ int channel;
+
+ if (rfcomm_channel_lookup(NULL,
+ &context.addr.bt_bdaddr,
+ service, &channel, &n) != 0)
+ errx(1, "Could not obtain RFCOMM channel");
+
+ context.addr.bt_channel = (u_int8_t) channel;
+#else
if (memcmp(&context.addr.rfcomm_bdaddr,
NG_HCI_BDADDR_ANY, sizeof(context.addr.rfcomm_bdaddr)) == 0)
errx(1, "Must specify server BD_ADDR");
-
/* Check channel, if was not set then obtain it via SDP */
if (context.addr.rfcomm_channel == 0 && service != 0) {
int channel;
@@ -268,13 +304,21 @@
errc(1, n, "Could not obtain RFCOMM channel");

context.addr.rfcomm_channel = (u_int8_t) channel;
+#endif
}
}

+#ifdef __NetBSD__
+ if (context.addr.bt_channel <= 0 ||
+ context.addr.bt_channel > 30)
+ errx(1, "Invalid RFCOMM channel %d",
+ context.addr.bt_channel);
+#else
if (context.addr.rfcomm_channel <= 0 ||
context.addr.rfcomm_channel > 30)
errx(1, "Invalid RFCOMM channel %d",
context.addr.rfcomm_channel);
+#endif

/* Detach server (if required) */
if (context.server && context.detach) {
16 changes: 16 additions & 0 deletions comms/obexapp/patches/patch-ac
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
$NetBSD: patch-ac,v 1.1.1.1 2006/07/02 18:18:34 xtraeme Exp $

--- sdp.c.orig 2006-07-02 19:51:38.000000000 +0200
+++ sdp.c 2006-07-02 19:52:05.000000000 +0200
@@ -72,7 +72,11 @@
u_int32_t type, len;

if (local == NULL)
+#ifdef __NetBSD__
+ local = BDADDR_ANY;
+#else
local = NG_HCI_BDADDR_ANY;
+#endif
if (remote == NULL || channel == NULL)
rfcomm_channel_lookup_exit(EINVAL);

116 changes: 116 additions & 0 deletions comms/obexapp/patches/patch-ad
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
$NetBSD: patch-ad,v 1.1.1.1 2006/07/02 18:18:34 xtraeme Exp $

--- transport.c.orig 2006-07-02 19:52:50.000000000 +0200
+++ transport.c 2006-07-02 19:59:19.000000000 +0200
@@ -53,7 +53,11 @@
obexapp_transport_connect(obex_t *handle, void *userdata)
{
context_p context = (context_p) userdata;
- struct sockaddr_rfcomm addr;
+#ifdef __NetBSD__
+ struct sockaddr_bt addr;
+#else
+ struct sockaddr_rfcomm addr
+#endif

syslog(LOG_DEBUG, "%s()", __func__);

@@ -63,21 +67,36 @@
return (-1);
}

+#ifdef __NetBSD__
+ syslog(LOG_INFO, "%s(): Connecting to %s/%d, pid=%d",
+ __func__, bt_ntoa(&context->addr.bt_bdaddr, NULL),
+ context->addr.bt_channel, getpid());
+
+ context->tfd = socket(PF_BLUETOOTH,SOCK_STREAM,BTPROTO_RFCOMM);
+#else
syslog(LOG_INFO, "%s(): Connecting to %s/%d, pid=%d",
__func__, bt_ntoa(&context->addr.rfcomm_bdaddr, NULL),
context->addr.rfcomm_channel, getpid());

context->tfd = socket(PF_BLUETOOTH,SOCK_STREAM,BLUETOOTH_PROTO_RFCOMM);
+#endif
if (context->tfd < 0) {
syslog(LOG_ERR, "%s(): Could not create socket. %s (%d)",
__func__, strerror(errno), errno);
return (-1);
}

+#ifdef __NetBSD__
+ addr.bt_len = sizeof(addr);
+ addr.bt_family = AF_BLUETOOTH;
+ memcpy(&addr.bt_bdaddr, &context->saddr, sizeof(addr.bt_bdaddr));
+ addr.bt_channel = 0;
+#else
addr.rfcomm_len = sizeof(addr);
addr.rfcomm_family = AF_BLUETOOTH;
memcpy(&addr.rfcomm_bdaddr, &context->saddr, sizeof(addr.rfcomm_bdaddr));
addr.rfcomm_channel = 0;
+#endif

if (bind(context->tfd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
syslog(LOG_ERR, "%s(): Could not bind socket. %s (%d)",
@@ -157,7 +176,11 @@
obexapp_transport_listen(obex_t *handle, void *userdata)
{
context_p context = (context_p) userdata;
+#ifdef __NetBSD__
+ struct sockaddr_bt addr;
+#else
struct sockaddr_rfcomm addr;
+#endif
socklen_t addrlen;
pid_t pid;
int s;
@@ -171,7 +194,11 @@
return (1);
}

+#ifdef __NetBSD__
+ s = socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
+#else
s = socket(PF_BLUETOOTH, SOCK_STREAM, BLUETOOTH_PROTO_RFCOMM);
+#endif
if (s < 0) {
syslog(LOG_ERR, "%s(): Could not create socket. %s (%d)",
__func__, strerror(errno), errno);
@@ -192,7 +219,11 @@
}

memset(&opush, 0, sizeof(opush));
+#ifdef __NetBSD__
+ opush.server_channel = context->addr.bt_channel;
+#else
opush.server_channel = context->addr.rfcomm_channel;
+#endif
opush.supported_formats_size = 7;
opush.supported_formats[0] = 0x1;
opush.supported_formats[1] = 0x2;
@@ -204,7 +235,11 @@

if (sdp_register_service(context->ss,
SDP_SERVICE_CLASS_OBEX_OBJECT_PUSH,
+#ifdef __NetBSD__
+ &context->addr.bt_bdaddr,
+#else
&context->addr.rfcomm_bdaddr,
+#endif
(void *) &opush, sizeof(opush), NULL) != 0) {
syslog(LOG_ERR, "%s(): Could to register OPUSH service with " \
"local SDP daemon. %s (%d)",
@@ -239,8 +274,13 @@

syslog(LOG_INFO, "%s(): Accepted new connection from " \
"%s/%d, pid=%d", __func__,
+#ifdef __NetBSD__
+ bt_ntoa(&addr.bt_bdaddr, NULL),
+ addr.bt_channel, getpid());
+#else
bt_ntoa(&addr.rfcomm_bdaddr, NULL),
addr.rfcomm_channel, getpid());
+#endif

if (daemon(1, 0) < 0) {
syslog(LOG_ERR, "%s(): Could not daemon. %s (%d)",
13 changes: 13 additions & 0 deletions comms/obexapp/patches/patch-ae
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$NetBSD: patch-ae,v 1.1.1.1 2006/07/02 18:18:34 xtraeme Exp $

--- util.c.orig 2006-07-02 20:07:59.000000000 +0200
+++ util.c 2006-07-02 20:08:07.000000000 +0200
@@ -30,7 +30,7 @@
*/

#include <bluetooth.h>
-#include <bsdxml.h>
+#include <expat.h>
#include <ctype.h>
#include <errno.h>
#include <iconv.h>

0 comments on commit 1e1ee23

Please sign in to comment.