Am Donnerstag 25 Januar 2007 01:27 schrieb Marcel Holtmann:
> > > > tcpobex.patch (needs testing):
> > > > adds IPv6 support (with transparent IPv4 support)
> > > > adds TcpOBEX_* and keeps InOBEX_* (as wrapper) for compatibility
> > > > server part usuably as non-root user
> > >
> > > I need this split out in logical parts. So first to the needed changes
> > > internally for the API extension and IPv6 and then provide the
> > > additional API.
> >
> > And here you go. I revised the ipv6 patch and tested it (IPv6 connection,
> > default) with obex_test (after applying the tcpobex.patch).
> > Order:
> > ipv6.patch
>
> the patch has been committed, but the coding style was really ugly
Well, let's not argue about "Coding Style"®. ;)
I usually do not care about the *'s position. Some like "type * name",
some "type* name" and some "type *name". I like all of 'em but actually
prefer the second type.
> > tcpobex.patch
>
> Please redo this since it no longer applies cleanly and keep a whitspace
> after the comma in parameter list. Also for pointers, the * belongs to
> the variable and not the type.
I hope I got them all.
HS
Index: openobex-anoncvs/lib/obex.c
===================================================================
--- openobex-anoncvs.orig/lib/obex.c 2007-01-24 22:14:14.159008527 +0100
+++ openobex-anoncvs/lib/obex.c 2007-01-24 22:18:31.599097527 +0100
@@ -941,47 +941,102 @@
}
/**
- * InOBEX_ServerRegister - Start listening for incoming connections
+ * TcpOBEX_ServerRegister - Start listening for incoming TCP connections
* @self: OBEX handle
+ * @addr: Address to bind to (*:650 if NULL)
+ * @addrlen: Length of address structure
*
- * An easier server function to use for TCP/IP (InOBEX) only.
+ * An easier server function to use for TCP/IP (TcpOBEX) only.
+ * It supports IPv4 (AF_INET) and IPv6 (AF_INET6).
+ * Note: INADDR_ANY will get mapped to IN6ADDR_ANY and using port 0
+ * will select the default OBEX port.
*
* Returns -1 on error.
*/
-int InOBEX_ServerRegister(obex_t *self)
+int TcpOBEX_ServerRegister(obex_t *self, struct sockaddr *addr, int addrlen)
{
DEBUG(3, "\n");
+ errno = EINVAL;
obex_return_val_if_fail(self != NULL, -1);
- inobex_prepare_listen(self, NULL, 0);
+ inobex_prepare_listen(self, addr, addrlen);
return obex_transport_listen(self);
}
/**
- * InOBEX_TransportConnect - Connect Inet transport
+ * TcpOBEX_TransportConnect - Connect TCP transport
* @self: OBEX handle
+ * @addr: Address to connect to ([::1]:650 if NULL)
+ * @addrlen: Length of address structure
+ *
+ * An easier connect function to use for TCP/IP (TcpOBEX) only.
+ * It supports IPv4 (AF_INET) and IPv6 (AF_INET6).
+ *
+ * Returns -1 on error.
+ */
+int TcpOBEX_TransportConnect(obex_t *self, struct sockaddr *addr, int addrlen)
+{
+ DEBUG(4, "\n");
+
+ errno = EINVAL;
+ obex_return_val_if_fail(self != NULL, -1);
+
+ if (self->object) {
+ DEBUG(1, "We are busy.\n");
+ errno = EBUSY;
+ return -1;
+ }
+
+ inobex_prepare_connect(self, addr, addrlen);
+ return obex_transport_connect_request(self);
+}
+/**
+ * InOBEX_ServerRegister - Start listening for incoming connections
+ * @self: OBEX handle
+ *
+ * An easier server function to use for TCP/IP (InOBEX) only.
+ *
+ * This function is deprecated, use TcpOBEX_ServerRegister() instead.
+ *
+ * Returns -1 on error.
+ */
+int InOBEX_ServerRegister(obex_t *self)
+{
+ DEBUG(3, "\n");
+
+ return TcpOBEX_ServerRegister(self,NULL,0);
+}
+
+/**
+ * InOBEX_TransportConnect - Connect Inet transport (deprecated)
+ * @self: OBEX handle
+ * @saddr: Address to connect to
+ * @addrlen: Length of address
*
* An easier connect function to use for TCP/IP (InOBEX) only.
*
- * Note : I would like feedback on this API to know which input
- * parameter make most sense. Thanks...
+ * This function is deprecated, use TcpOBEX_TransportConnect() instead.
+ *
+ * Returns -1 on error.
*/
int InOBEX_TransportConnect(obex_t *self, struct sockaddr *saddr, int addrlen)
{
DEBUG(4, "\n");
+ errno = EINVAL;
obex_return_val_if_fail(self != NULL, -1);
if (self->object) {
DEBUG(1, "We are busy.\n");
- return -EBUSY;
+ errno = EBUSY;
+ return -1;
}
+ errno = EINVAL;
obex_return_val_if_fail(saddr != NULL, -1);
- inobex_prepare_connect(self, saddr, addrlen);
- return obex_transport_connect_request(self);
+ return TcpOBEX_TransportConnect(self, saddr, addrlen);
}
/**
Index: openobex-anoncvs/include/obex.h
===================================================================
--- openobex-anoncvs.orig/include/obex.h 2007-01-24 22:14:14.343020027 +0100
+++ openobex-anoncvs/include/obex.h 2007-01-24 22:16:52.108879777 +0100
@@ -116,7 +116,13 @@
char* OBEX_GetResponseMessage(obex_t *self, int rsp);
/*
- * InOBEX API (TCP/IP)
+ * TcpOBEX API (IPv4/IPv6)
+ */
+ int TcpOBEX_ServerRegister(obex_t *self, struct sockaddr *addr, int addrlen);
+ int TcpOBEX_TransportConnect(obex_t *self, struct sockaddr *addr, int addrlen);
+
+/*
+ * InOBEX API (deprecated)
*/
int InOBEX_ServerRegister(obex_t *self);
int InOBEX_TransportConnect(obex_t *self, struct sockaddr *saddr, int addrlen);
Index: openobex-anoncvs/lib/obex.sym
===================================================================
--- openobex-anoncvs.orig/lib/obex.sym 2007-01-24 22:14:14.295017027 +0100
+++ openobex-anoncvs/lib/obex.sym 2007-01-24 22:16:22.103004527 +0100
@@ -33,6 +33,8 @@
OBEX_CharToUnicode
OBEX_ResponseToString
OBEX_GetResponseMessage
+TcpOBEX_ServerRegister
+TcpOBEX_TransportConnect
InOBEX_ServerRegister
InOBEX_TransportConnect
IrOBEX_ServerRegister
Index: openobex-anoncvs/apps/obex_test.c
===================================================================
--- openobex-anoncvs.orig/apps/obex_test.c 2007-01-24 22:14:14.395023277 +0100
+++ openobex-anoncvs/apps/obex_test.c 2007-01-24 22:16:22.171008777 +0100
@@ -359,7 +359,7 @@
case 'c':
/* First connect transport */
if(tcpobex) {
- if(inet_connect(handle) < 0) {
+ if(TcpOBEX_TransportConnect(handle, NULL, 0) < 0) {
printf("Transport connect error! (TCP)\n");
break;
}
@@ -405,7 +405,7 @@
case 's':
/* First register server */
if(tcpobex) {
- if(InOBEX_ServerRegister(handle) < 0) {
+ if(TcpOBEX_ServerRegister(handle, NULL, 0) < 0) {
printf("Server register error! (TCP)\n");
break;
}
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Openobex-users mailing list
[email protected]
http://lists.sourceforge.net/lists/listinfo/openobex-users