Hi,all
These patches support opp and ftp over l2cap. Currently I just modified OPP and FTP.
Please help review these patches.
Thanks.
---
plugins/opp.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/plugins/opp.c b/plugins/opp.c
index 17c4356..7ea7e18 100644
--- a/plugins/opp.c
+++ b/plugins/opp.c
@@ -71,7 +71,7 @@
<sequence> \
<sequence> \
<uuid value=\"0x1105\"/> \
- <uint16 value=\"0x0100\" name=\"version\"/> \
+ <uint16 value=\"0x0102\" name=\"version\"/> \
</sequence> \
</sequence> \
</attribute> \
@@ -91,6 +91,10 @@
<uint8 value=\"0xff\"/> \
</sequence> \
</attribute> \
+ \
+ <attribute id=\"0x0200\"> \
+ <uint16 value=\"%u\" name=\"psm\"/> \
+ </attribute> \
</record>"
static void *opp_connect(struct obex_session *os, int *err)
--
1.7.1
SGksDQo+Tm90IHN1cmUgd2h5IHlvdSBoYXZlIHRvIGNyZWF0ZSB0aG9zZSBlbXB0eSBmdW5jdGlv
bnMsIHRoZSByZWFsIGNvZGUgaXMgaW4gYW5vdGhlciBwYXRjaCBJIHN1cHBvc2U/DQogWWVhaCwg
SSBwdXQgdGhlIGRldGFpbGVkIGZ1bmN0aW9uIGNvZGUgaW4gbmV4dCBwYXRjaC4gTWF5YmUgSSBz
cGxpdCBwYXRjaGVzIHRvbyBzbWFsbC4gU29ycnkgZm9yIG15IGxpdHRsZSBleHBlcmllbmNlIGlu
IHVwc3RyZWFtLg0KPk5vdCBzdXJlIHdoeSB5b3UgbmVlZCBsMmNhcFBzbSwgd2hpY2ggaWlyYyBk
byBub3QgY29uZm9ybSB3aXRoIG91ciBjb2RlIHN0eWxpbmcgZ3VpZGVsaW5lcywgd2h5IGNhbid0
IHlvdSBtb3ZlIGwycHNtIG91dHNpZGUgdGhlIGRvIHdoaWxlIHNjb3BlIGFuZCBqdXN0IHVzZSBp
dCBkaXJlY3RseT8NCiBPaywgSWBsbCB1cGRhdGUgY29kZSBpbiBuZXh0IHZlcnNpb24gZm9sbG93
aW5nIHlvdXIgYWR2aWNlLg0KDQpUaGFua3MuDQpOYW1pDQo=
Hi Nami,
On Tue, Jun 21, 2011 at 9:25 AM, Li, Nami <[email protected]> wrote:
> Hi, Luiz
> ?Thanks for your reply. I understand and agree with your opinion. The "start_l2cap" and "l2cap_confirm_event" functions were written according to "start" and "confirm_event".
> I just keep the parameters passed same with "start" and "confirm_event" functions. I find that "user_data" passed by "start" is also not used in "confirm_event".
> I think keep same parameters is more unified on the structure.
> What do you think ?
I would fix the RFCOMM listen to pass service instead and completely
remove the use of find_service.
--
Luiz Augusto von Dentz
SGksIEx1aXoNCiAgVGhhbmtzIGZvciB5b3VyIHJlcGx5LiBJIHVuZGVyc3RhbmQgYW5kIGFncmVl
IHdpdGggeW91ciBvcGluaW9uLiBUaGUgInN0YXJ0X2wyY2FwIiBhbmQgImwyY2FwX2NvbmZpcm1f
ZXZlbnQiIGZ1bmN0aW9ucyB3ZXJlIHdyaXR0ZW4gYWNjb3JkaW5nIHRvICJzdGFydCIgYW5kICJj
b25maXJtX2V2ZW50Ii4gDQpJIGp1c3Qga2VlcCB0aGUgcGFyYW1ldGVycyBwYXNzZWQgc2FtZSB3
aXRoICJzdGFydCIgYW5kICJjb25maXJtX2V2ZW50IiBmdW5jdGlvbnMuIEkgZmluZCB0aGF0ICJ1
c2VyX2RhdGEiIHBhc3NlZCBieSAic3RhcnQiIGlzIGFsc28gbm90IHVzZWQgaW4gImNvbmZpcm1f
ZXZlbnQiLg0KSSB0aGluayBrZWVwIHNhbWUgcGFyYW1ldGVycyBpcyBtb3JlIHVuaWZpZWQgb24g
dGhlIHN0cnVjdHVyZS4NCldoYXQgZG8geW91IHRoaW5rID8NCg0KVGhhbmtzLg0KTmFtaQ0K
Hi Nami,
On Mon, Jun 20, 2011 at 12:44 PM, Nami <[email protected]> wrote:
> Hi,all
> ?These patches support opp and ftp over l2cap. Currently I just modified OPP and FTP.
> ?Please help review these patches.
> ?Thanks.
>
> ---
> ?plugins/opp.c | ? ?6 +++++-
> ?1 files changed, 5 insertions(+), 1 deletions(-)
>
> diff --git a/plugins/opp.c b/plugins/opp.c
> index 17c4356..7ea7e18 100644
> --- a/plugins/opp.c
> +++ b/plugins/opp.c
> @@ -71,7 +71,7 @@
> ? ? <sequence> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
> ? ? ? <sequence> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
> ? ? ? ? <uuid value=\"0x1105\"/> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
> - ? ? ? ?<uint16 value=\"0x0100\" name=\"version\"/> ? ? ? ? ? ?\
> + ? ? ? ?<uint16 value=\"0x0102\" name=\"version\"/> ? ? ? ? ? ?\
> ? ? ? </sequence> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\
> ? ? </sequence> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\
> ? </attribute> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
> @@ -91,6 +91,10 @@
> ? ? ? <uint8 value=\"0xff\"/> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\
> ? ? </sequence> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\
> ? </attribute> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\
> + ?<attribute id=\"0x0200\"> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\
> + ? ? ? <uint16 value=\"%u\" name=\"psm\"/> ? ? ? ? ? ? ? ? ? ? \
> + ?</attribute> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
> ?</record>"
>
> ?static void *opp_connect(struct obex_session *os, int *err)
> --
> 1.7.1
>
> --
I review some of the more obvious issues, but you please next send the
obex-client and obexd in different series? It confuses use since the
sometimes are similar but for different purposes (client/server), also
personally I don't suggest sending big series (> 5 patches), split
them into logical sets e.g server, client, gwobex (this is actually
necessary to apply to gwobex repository too) and send them separated
waiting them to get applied before sending the next one.
--
Luiz Augusto von Dentz
Hi,
On Mon, Jun 20, 2011 at 12:44 PM, Nami <[email protected]> wrote:
> ---
> ?client/session.c | ? 52 +++++++++++++++++++++++++++++++++++++++++++++-------
> ?client/session.h | ? ?4 ++++
> ?2 files changed, 49 insertions(+), 7 deletions(-)
>
> diff --git a/client/session.c b/client/session.c
> index 8a6ee2c..0e21994 100755
> --- a/client/session.c
> +++ b/client/session.c
> @@ -282,6 +282,14 @@ static GIOChannel *rfcomm_connect(const bdaddr_t *src, const bdaddr_t *dst,
> ? ? ? ?g_error_free(err);
> ? ? ? ?return NULL;
> ?}
> +static void l2cap_callback(GIOChannel *io, GError *err, gpointer user_data)
> +{
> +}
> +static GIOChannel *l2cap_connect(const bdaddr_t *src, const bdaddr_t *dst,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? uint16_t psm, BtIOConnect function,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? gpointer user_data)
> +{
> +}
Not sure why you have to create those empty functions, the real code
is in another patch I suppose?
> ?static void search_callback(uint8_t type, uint16_t status,
> ? ? ? ? ? ? ? ? ? ? ? ?uint8_t *rsp, size_t size, void *user_data)
> @@ -291,6 +299,7 @@ static void search_callback(uint8_t type, uint16_t status,
> ? ? ? ?unsigned int scanned, bytesleft = size;
> ? ? ? ?int seqlen = 0;
> ? ? ? ?uint8_t dataType, channel = 0;
> + ? ? ? uint16_t l2capPsm = 0;
> ? ? ? ?GError *gerr = NULL;
>
> ? ? ? ?if (status || type != SDP_SVC_SEARCH_ATTR_RSP)
> @@ -305,7 +314,9 @@ static void search_callback(uint8_t type, uint16_t status,
> ? ? ? ?do {
> ? ? ? ? ? ? ? ?sdp_record_t *rec;
> ? ? ? ? ? ? ? ?sdp_list_t *protos;
> + ? ? ? ? ? ? ? sdp_data_t *data;
> ? ? ? ? ? ? ? ?int recsize, ch = -1;
> + ? ? ? ? ? ? ? int l2psm = -1;
>
> ? ? ? ? ? ? ? ?recsize = 0;
> ? ? ? ? ? ? ? ?rec = sdp_extract_pdu(rsp, bytesleft, &recsize);
> @@ -316,7 +327,11 @@ static void search_callback(uint8_t type, uint16_t status,
> ? ? ? ? ? ? ? ? ? ? ? ?sdp_record_free(rec);
> ? ? ? ? ? ? ? ? ? ? ? ?break;
> ? ? ? ? ? ? ? ?}
> -
> + ? ? ? ? ? ? ? data = sdp_data_get(rec, SDP_ATTR_GOEP_L2CAP_PSM);
> + ? ? ? ? ? ? ? if(data != NULL){
> + ? ? ? ? ? ? ? ? ? ? ? l2psm = data->val.uint16;
> + ? ? ? ? ? ? ? ? ? ? ? DBG("sdp l2psm is %d,",l2psm);
> + ? ? ? ? ? ? ? }
> ? ? ? ? ? ? ? ?if (!sdp_get_access_protos(rec, &protos)) {
> ? ? ? ? ? ? ? ? ? ? ? ?ch = sdp_get_proto_port(protos, RFCOMM_UUID);
> ? ? ? ? ? ? ? ? ? ? ? ?sdp_list_foreach(protos,
> @@ -327,6 +342,11 @@ static void search_callback(uint8_t type, uint16_t status,
>
> ? ? ? ? ? ? ? ?sdp_record_free(rec);
>
> + ? ? ? ? ? ? ? if (l2psm > 0) {
> + ? ? ? ? ? ? ? ? ? ? ? l2capPsm = l2psm;
> + ? ? ? ? ? ? ? ? ? ? ? break;
> + ? ? ? ? ? ? ? }
Not sure why you need l2capPsm, which iirc do not conform with our
code styling guidelines, why can't you move l2psm outside the do while
scope and just use it directly?
> +
> ? ? ? ? ? ? ? ?if (ch > 0) {
> ? ? ? ? ? ? ? ? ? ? ? ?channel = ch;
> ? ? ? ? ? ? ? ? ? ? ? ?break;
> @@ -337,16 +357,28 @@ static void search_callback(uint8_t type, uint16_t status,
> ? ? ? ? ? ? ? ?bytesleft -= recsize;
> ? ? ? ?} while (scanned < size && bytesleft > 0);
>
> - ? ? ? if (channel == 0)
> + ? ? ? if ((l2capPsm == 0)&&(channel == 0))
> ? ? ? ? ? ? ? ?goto failed;
>
> - ? ? ? session->channel = channel;
> + ? ? ? if(l2capPsm > 0){
> + ? ? ? ? ? ? ? session->psm = l2capPsm;
>
> - ? ? ? g_io_channel_set_close_on_unref(session->io, FALSE);
> - ? ? ? g_io_channel_unref(session->io);
> + ? ? ? ? ? ? ? g_io_channel_set_close_on_unref(session->io, FALSE);
> + ? ? ? ? ? ? ? g_io_channel_unref(session->io);
> +
> + ? ? ? ? ? ? ? session->io = l2cap_connect(&session->src, &session->dst, l2capPsm,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? l2cap_callback, callback);
> + ? ? ? }else{
> +
> + ? ? ? ? ? ? ? session->channel = channel;
> +
> + ? ? ? ? ? ? ? g_io_channel_set_close_on_unref(session->io, FALSE);
> + ? ? ? ? ? ? ? g_io_channel_unref(session->io);
> +
> + ? ? ? ? ? ? ? session->io = rfcomm_connect(&session->src, &session->dst, channel,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? rfcomm_callback, callback);
> + ? ? ? }
>
> - ? ? ? session->io = rfcomm_connect(&session->src, &session->dst, channel,
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? rfcomm_callback, callback);
> ? ? ? ?if (session->io != NULL) {
> ? ? ? ? ? ? ? ?sdp_close(callback->sdp);
> ? ? ? ? ? ? ? ?return;
> @@ -611,6 +643,12 @@ proceed:
> ? ? ? ?if (session->obex) {
> ? ? ? ? ? ? ? ?g_idle_add(connection_complete, callback);
> ? ? ? ? ? ? ? ?err = 0;
> + ? ? ? } else if (session->psm > 0) {
> + ? ? ? ? ? ? ? session->io = l2cap_connect(&session->src, &session->dst,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? session->psm,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? l2cap_callback,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? callback);
> + ? ? ? ? ? ? ? err = (session->io == NULL) ? -EINVAL : 0;
> ? ? ? ?} else if (session->channel > 0) {
> ? ? ? ? ? ? ? ?session->io = rfcomm_connect(&session->src, &session->dst,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?session->channel,
> diff --git a/client/session.h b/client/session.h
> index 9180e75..24b1ec5 100755
> --- a/client/session.h
> +++ b/client/session.h
> @@ -54,6 +54,10 @@ struct session_data {
> ? ? ? ?void *priv;
> ?};
>
> +#ifndef SDP_ATTR_GOEP_L2CAP_PSM
> +#define SDP_ATTR_GOEP_L2CAP_PSM ? ? ? ? ? ? ? ?0x0200
> +#endif
> +
> ?typedef void (*session_callback_t) (struct session_data *session,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?GError *err, void *user_data);
>
> --
> 1.7.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to [email protected]
> More majordomo info at ?http://vger.kernel.org/majordomo-info.html
>
--
Luiz Augusto von Dentz
Hi,
On Mon, Jun 20, 2011 at 12:45 PM, Nami <[email protected]> wrote:
> ---
> ?test/main.c | ? ?2 +-
> ?1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/test/main.c b/test/main.c
> index 37b307c..4bd8e19 100644
> --- a/test/main.c
> +++ b/test/main.c
> @@ -256,7 +256,7 @@ int main(int argc, char *argv[])
> ? ? ? ? ? ? ? ?exit(1);
> ? ? ? ?}
>
> - ? ? ? obex = gw_obex_setup_fd(sk, target, target_len, NULL, &error);
> + ? ? ? obex = gw_obex_setup_fd(sk, target, target_len, NULL, &error,FDOBEX_MT_STREAM);
> ? ? ? ?if (obex == NULL) {
> ? ? ? ? ? ? ? ?fprintf(stderr, "Failed to create OBEX session\n");
> ? ? ? ? ? ? ? ?close(sk);
> --
> 1.7.1
>
> --
Fixes in place please, don't add fixes to code not upstream, git
rebase -i and/or git stash can help you with that.
--
Luiz Augusto von Dentz
Hi,
On Mon, Jun 20, 2011 at 12:44 PM, Nami <[email protected]> wrote:
> ---
> ?plugins/bluetooth.c | ? 93 +++++++++++++++++++++++++++++++++++++++++++++++++++
> ?1 files changed, 93 insertions(+), 0 deletions(-)
>
> diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
> index 7f81e14..632e148 100644
> --- a/plugins/bluetooth.c
> +++ b/plugins/bluetooth.c
> @@ -31,6 +31,8 @@
>
> ?#include <openobex/obex.h>
> ?#include <openobex/obex_const.h>
> +#include <bluetooth/bluetooth.h>
> +#include <bluetooth/l2cap.h>
>
> ?#include <glib.h>
> ?#include <gdbus.h>
> @@ -146,6 +148,26 @@ static struct bluetooth_service *find_service(
> ? ? ? ?return NULL;
> ?}
>
> +static struct bluetooth_service *find_service_psm(
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? struct obex_service_driver *driver,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? uint16_t psm)
> +{
> + ? ? ? GSList *l;
> + ? ? ? DBG("");
> + ? ? ? for (l = any->services; l; l = l->next) {
> + ? ? ? ? ? ? ? struct bluetooth_service *service = l->data;
> +
> + ? ? ? ? ? ? ? if (driver != NULL && service->driver != driver)
> + ? ? ? ? ? ? ? ? ? ? ? continue;
> +
> + ? ? ? ? ? ? ? if (psm != 0 && service->driver->psm != psm)
> + ? ? ? ? ? ? ? ? ? ? ? continue;
> +
> + ? ? ? ? ? ? ? return service;
> + ? ? ? }
> +
> + ? ? ? return NULL;
> +}
> ?static void register_record(struct obex_server *server)
> ?{
> ? ? ? ?const GSList *l;
> @@ -503,6 +525,49 @@ drop:
> ? ? ? ?g_io_channel_shutdown(io, TRUE, NULL);
> ?}
>
> +static void l2cap_confirm_event(GIOChannel *io, void *user_data)
> +{
> + ? ? ? struct bluetooth_service *service;
> + ? ? ? GError *err = NULL;
> + ? ? ? char address[18];
> + ? ? ? uint16_t psm;
> +
> + ? ? ? bt_io_get(io, BT_IO_L2CAP, &err,
> + ? ? ? ? ? ? ? ? ? ? ? BT_IO_OPT_DEST, address,
> + ? ? ? ? ? ? ? ? ? ? ? BT_IO_OPT_PSM, &psm,
> + ? ? ? ? ? ? ? ? ? ? ? BT_IO_OPT_INVALID);
> + ? ? ? if (err) {
> + ? ? ? ? ? ? ? error("%s", err->message);
> + ? ? ? ? ? ? ? g_error_free(err);
> + ? ? ? ? ? ? ? goto drop;
> + ? ? ? }
> +
> + ? ? ? info("bluetooth: New connection from: %s, psm 0x%x", address,
> + ? ? ? ? ? ? ? ? ? ? ? psm);
> +
> + ? ? ? service = find_service_psm(NULL, psm);
You don't seems to be using the user_data for anything, so you could
use to pass the service driver instead of the server in start_l2cap,
if that works than you don't really need find_service_psm at all.
> + ? ? ? if (service == NULL) {
> + ? ? ? ? ? ? ? error("bluetooth: Unable to find service");
> + ? ? ? ? ? ? ? goto drop;
> + ? ? ? }
> + ? ? ? if (service->driver->service != OBEX_OPP) {
> + ? ? ? ? ? ? ? if (request_service_authorization(service, io, address) < 0)
> + ? ? ? ? ? ? ? ? ? ? ? goto drop;
> +
> + ? ? ? ? ? ? ? return;
> + ? ? ? }
> +
> + ? ? ? if (!bt_io_accept(io, connect_event, service, NULL, &err)) {
> + ? ? ? ? ? ? ? error("%s", err->message);
> + ? ? ? ? ? ? ? g_error_free(err);
> + ? ? ? ? ? ? ? goto drop;
> + ? ? ? }
> +
> + ? ? ? return;
> +
> +drop:
> + ? ? ? g_io_channel_shutdown(io, TRUE, NULL);
> +}
> ?static GIOChannel *start(struct obex_server *server,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?struct obex_service_driver *service,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?BtIOSecLevel sec_level)
> @@ -525,6 +590,28 @@ static GIOChannel *start(struct obex_server *server,
> ? ? ? ?return io;
> ?}
>
> +static GIOChannel *start_l2cap(struct obex_server *server,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? struct obex_service_driver *service,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? BtIOSecLevel sec_level)
> +{
> + ? ? ? GIOChannel *io;
> + ? ? ? GError *err = NULL;
> + ? ? ? io = bt_io_listen(BT_IO_L2CAP, NULL, l2cap_confirm_event,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? server, NULL, &err,
See the user_data pointer you pass here (server) is never used in the callback.
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? BT_IO_OPT_PSM, service->psm,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? BT_IO_OPT_SEC_LEVEL, sec_level,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? BT_IO_OPT_MTU, BT_RX_MTU,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? BT_IO_OPT_MODE, L2CAP_MODE_ERTM,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? BT_IO_OPT_INVALID);
> + ? ? ? if (io == NULL) {
> + ? ? ? ? ? ? ? error("bluetooth: unable to listen in psm 0x%x: %s",
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? service->psm, err->message);
> + ? ? ? ? ? ? ? g_error_free(err);
> + ? ? ? } else
> + ? ? ? ? ? ? ? DBG("listening on psm 0x%x", service->psm);
> +
> + ? ? ? return io;
> +}
> ?static void *bluetooth_start(struct obex_server *server, int *err)
> ?{
> ? ? ? ?BtIOSecLevel sec_level;
> @@ -545,6 +632,12 @@ static void *bluetooth_start(struct obex_server *server, int *err)
> ? ? ? ? ? ? ? ? ? ? ? ?continue;
>
> ? ? ? ? ? ? ? ?ios = g_slist_prepend(ios, io);
> +
> + ? ? ? ? ? ? ? io = start_l2cap(server, service, sec_level);
> + ? ? ? ? ? ? ? if (io == NULL)
> + ? ? ? ? ? ? ? ? ? ? ? continue;
> +
> + ? ? ? ? ? ? ? ios = g_slist_prepend(ios, io);
> ? ? ? ?}
>
> ? ? ? ?register_record(server);
> --
> 1.7.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to [email protected]
> More majordomo info at ?http://vger.kernel.org/majordomo-info.html
>
--
Luiz Augusto von Dentz
Hi,
On Mon, Jun 20, 2011 at 12:58 PM, Luiz Augusto von Dentz
<[email protected]> wrote:
> Hi,
>
> On Mon, Jun 20, 2011 at 12:44 PM, Nami <[email protected]> wrote:
>> ---
>> ?src/service.h | ? ?1 +
>> ?1 files changed, 1 insertions(+), 0 deletions(-)
>>
>> diff --git a/src/service.h b/src/service.h
>> index a844885..313b1f2 100644
>> --- a/src/service.h
>> +++ b/src/service.h
>> @@ -25,6 +25,7 @@ struct obex_service_driver {
>> ? ? ? ?const char *name;
>> ? ? ? ?uint16_t service;
>> ? ? ? ?uint8_t channel;
>> + ? ? ? uint16_t psm;
>> ? ? ? ?const uint8_t *target;
>> ? ? ? ?unsigned int target_size;
>> ? ? ? ?const uint8_t *who;
>> --
>> 1.7.1
>>
>> --
>
> This one alone would generate a warning which is not nice if cherry
> picked, so perhaps you should merge with other code that really uses
> it.
Nevermind, this is not a variable definition as I (wrongly) assumed.
--
Luiz Augusto von Dentz
Hi,
On Mon, Jun 20, 2011 at 12:44 PM, Nami <[email protected]> wrote:
> ---
> ?src/service.h | ? ?1 +
> ?1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/src/service.h b/src/service.h
> index a844885..313b1f2 100644
> --- a/src/service.h
> +++ b/src/service.h
> @@ -25,6 +25,7 @@ struct obex_service_driver {
> ? ? ? ?const char *name;
> ? ? ? ?uint16_t service;
> ? ? ? ?uint8_t channel;
> + ? ? ? uint16_t psm;
> ? ? ? ?const uint8_t *target;
> ? ? ? ?unsigned int target_size;
> ? ? ? ?const uint8_t *who;
> --
> 1.7.1
>
> --
This one alone would generate a warning which is not nice if cherry
picked, so perhaps you should merge with other code that really uses
it.
--
Luiz Augusto von Dentz
---
client/main.c | 26 +++++++++++++++++---------
client/session.c | 1 +
client/session.h | 1 +
3 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/client/main.c b/client/main.c
index 478181c..5752831 100644
--- a/client/main.c
+++ b/client/main.c
@@ -125,7 +125,7 @@ done:
static int parse_device_dict(DBusMessageIter *iter,
const char **source, const char **dest, const char **target,
- uint8_t *channel)
+ uint8_t *channel, uint16_t *psm)
{
while (dbus_message_iter_get_arg_type(iter) == DBUS_TYPE_DICT_ENTRY) {
DBusMessageIter entry, value;
@@ -150,6 +150,10 @@ static int parse_device_dict(DBusMessageIter *iter,
if (g_str_equal(key, "Channel") == TRUE)
dbus_message_iter_get_basic(&value, channel);
break;
+ case DBUS_TYPE_UINT16:
+ if (g_str_equal(key, "Psm") == TRUE)
+ dbus_message_iter_get_basic(&value, psm);
+ break;
}
dbus_message_iter_next(iter);
@@ -168,11 +172,12 @@ static DBusMessage *send_files(DBusConnection *connection,
const char *agent, *source = NULL, *dest = NULL, *target = NULL;
const char *sender;
uint8_t channel = 0;
+ uint16_t psm = 0;
dbus_message_iter_init(message, &iter);
dbus_message_iter_recurse(&iter, &array);
- parse_device_dict(&array, &source, &dest, &target, &channel);
+ parse_device_dict(&array, &source, &dest, &target, &channel, &psm);
if (dest == NULL)
return g_dbus_create_error(message,
"org.openobex.Error.InvalidArguments", NULL);
@@ -218,7 +223,7 @@ static DBusMessage *send_files(DBusConnection *connection,
data->agent = g_strdup(agent);
data->files = files;
- session = session_create(source, dest, "OPP", channel, sender,
+ session = session_create(source, dest, "OPP", channel, psm, sender,
create_callback, data);
if (session != NULL) {
sessions = g_slist_append(sessions, session);
@@ -295,11 +300,12 @@ static DBusMessage *pull_business_card(DBusConnection *connection,
const char *source = NULL, *dest = NULL, *target = NULL;
const char *name = NULL;
uint8_t channel = 0;
+ uint16_t psm = 0;
dbus_message_iter_init(message, &iter);
dbus_message_iter_recurse(&iter, &dict);
- parse_device_dict(&dict, &source, &dest, &target, &channel);
+ parse_device_dict(&dict, &source, &dest, &target, &channel, &psm);
if (dest == NULL)
return g_dbus_create_error(message,
"org.openobex.Error.InvalidArguments", NULL);
@@ -322,7 +328,7 @@ static DBusMessage *pull_business_card(DBusConnection *connection,
data->sender = g_strdup(dbus_message_get_sender(message));
data->filename = g_strdup(name);
- session = session_create(source, dest, "OPP", channel, data->sender,
+ session = session_create(source, dest, "OPP", channel, psm, data->sender,
pull_session_callback, data);
if (session != NULL) {
sessions = g_slist_append(sessions, session);
@@ -366,11 +372,12 @@ static DBusMessage *create_session(DBusConnection *connection,
struct send_data *data;
const char *source = NULL, *dest = NULL, *target = NULL;
uint8_t channel = 0;
+ uint16_t psm = 0;
dbus_message_iter_init(message, &iter);
dbus_message_iter_recurse(&iter, &dict);
- parse_device_dict(&dict, &source, &dest, &target, &channel);
+ parse_device_dict(&dict, &source, &dest, &target, &channel, &psm);
if (dest == NULL || target == NULL)
return g_dbus_create_error(message,
"org.openobex.Error.InvalidArguments", NULL);
@@ -384,7 +391,7 @@ static DBusMessage *create_session(DBusConnection *connection,
data->message = dbus_message_ref(message);
data->sender = g_strdup(dbus_message_get_sender(message));
- session = session_create(source, dest, target, channel, data->sender,
+ session = session_create(source, dest, target, channel, psm, data->sender,
create_callback, data);
if (session != NULL) {
sessions = g_slist_append(sessions, session);
@@ -493,11 +500,12 @@ static DBusMessage *get_capabilities(DBusConnection *connection,
struct send_data *data;
const char *source = NULL, *dest = NULL, *target = NULL;
uint8_t channel = 0;
+ uint16_t psm = 0;
dbus_message_iter_init(message, &iter);
dbus_message_iter_recurse(&iter, &dict);
- parse_device_dict(&dict, &source, &dest, &target, &channel);
+ parse_device_dict(&dict, &source, &dest, &target, &channel, &psm);
if (dest == NULL)
return g_dbus_create_error(message,
"org.openobex.Error.InvalidArguments", NULL);
@@ -514,7 +522,7 @@ static DBusMessage *get_capabilities(DBusConnection *connection,
if (!target)
target = "OPP";
- session = session_create(source, dest, target, channel, data->sender,
+ session = session_create(source, dest, target, channel, psm, data->sender,
capability_session_callback, data);
if (session != NULL) {
sessions = g_slist_append(sessions, session);
diff --git a/client/session.c b/client/session.c
index 266d00c..dd08610 100644
--- a/client/session.c
+++ b/client/session.c
@@ -535,6 +535,7 @@ struct session_data *session_create(const char *source,
const char *destination,
const char *service,
uint8_t channel,
+ uint16_t psm,
const char *owner,
session_callback_t function,
void *user_data)
diff --git a/client/session.h b/client/session.h
index 6f8a434..af79ac8 100644
--- a/client/session.h
+++ b/client/session.h
@@ -60,6 +60,7 @@ struct session_data *session_create(const char *source,
const char *destination,
const char *service,
uint8_t channel,
+ uint16_t psm,
const char *owner,
session_callback_t function,
void *user_data);
--
1.7.1
---
client/session.c | 52 +++++++++++++++++++++++++++++++++++++++++++++-------
client/session.h | 4 ++++
2 files changed, 49 insertions(+), 7 deletions(-)
diff --git a/client/session.c b/client/session.c
index 8a6ee2c..0e21994 100755
--- a/client/session.c
+++ b/client/session.c
@@ -282,6 +282,14 @@ static GIOChannel *rfcomm_connect(const bdaddr_t *src, const bdaddr_t *dst,
g_error_free(err);
return NULL;
}
+static void l2cap_callback(GIOChannel *io, GError *err, gpointer user_data)
+{
+}
+static GIOChannel *l2cap_connect(const bdaddr_t *src, const bdaddr_t *dst,
+ uint16_t psm, BtIOConnect function,
+ gpointer user_data)
+{
+}
static void search_callback(uint8_t type, uint16_t status,
uint8_t *rsp, size_t size, void *user_data)
@@ -291,6 +299,7 @@ static void search_callback(uint8_t type, uint16_t status,
unsigned int scanned, bytesleft = size;
int seqlen = 0;
uint8_t dataType, channel = 0;
+ uint16_t l2capPsm = 0;
GError *gerr = NULL;
if (status || type != SDP_SVC_SEARCH_ATTR_RSP)
@@ -305,7 +314,9 @@ static void search_callback(uint8_t type, uint16_t status,
do {
sdp_record_t *rec;
sdp_list_t *protos;
+ sdp_data_t *data;
int recsize, ch = -1;
+ int l2psm = -1;
recsize = 0;
rec = sdp_extract_pdu(rsp, bytesleft, &recsize);
@@ -316,7 +327,11 @@ static void search_callback(uint8_t type, uint16_t status,
sdp_record_free(rec);
break;
}
-
+ data = sdp_data_get(rec, SDP_ATTR_GOEP_L2CAP_PSM);
+ if(data != NULL){
+ l2psm = data->val.uint16;
+ DBG("sdp l2psm is %d,",l2psm);
+ }
if (!sdp_get_access_protos(rec, &protos)) {
ch = sdp_get_proto_port(protos, RFCOMM_UUID);
sdp_list_foreach(protos,
@@ -327,6 +342,11 @@ static void search_callback(uint8_t type, uint16_t status,
sdp_record_free(rec);
+ if (l2psm > 0) {
+ l2capPsm = l2psm;
+ break;
+ }
+
if (ch > 0) {
channel = ch;
break;
@@ -337,16 +357,28 @@ static void search_callback(uint8_t type, uint16_t status,
bytesleft -= recsize;
} while (scanned < size && bytesleft > 0);
- if (channel == 0)
+ if ((l2capPsm == 0)&&(channel == 0))
goto failed;
- session->channel = channel;
+ if(l2capPsm > 0){
+ session->psm = l2capPsm;
- g_io_channel_set_close_on_unref(session->io, FALSE);
- g_io_channel_unref(session->io);
+ g_io_channel_set_close_on_unref(session->io, FALSE);
+ g_io_channel_unref(session->io);
+
+ session->io = l2cap_connect(&session->src, &session->dst, l2capPsm,
+ l2cap_callback, callback);
+ }else{
+
+ session->channel = channel;
+
+ g_io_channel_set_close_on_unref(session->io, FALSE);
+ g_io_channel_unref(session->io);
+
+ session->io = rfcomm_connect(&session->src, &session->dst, channel,
+ rfcomm_callback, callback);
+ }
- session->io = rfcomm_connect(&session->src, &session->dst, channel,
- rfcomm_callback, callback);
if (session->io != NULL) {
sdp_close(callback->sdp);
return;
@@ -611,6 +643,12 @@ proceed:
if (session->obex) {
g_idle_add(connection_complete, callback);
err = 0;
+ } else if (session->psm > 0) {
+ session->io = l2cap_connect(&session->src, &session->dst,
+ session->psm,
+ l2cap_callback,
+ callback);
+ err = (session->io == NULL) ? -EINVAL : 0;
} else if (session->channel > 0) {
session->io = rfcomm_connect(&session->src, &session->dst,
session->channel,
diff --git a/client/session.h b/client/session.h
index 9180e75..24b1ec5 100755
--- a/client/session.h
+++ b/client/session.h
@@ -54,6 +54,10 @@ struct session_data {
void *priv;
};
+#ifndef SDP_ATTR_GOEP_L2CAP_PSM
+#define SDP_ATTR_GOEP_L2CAP_PSM 0x0200
+#endif
+
typedef void (*session_callback_t) (struct session_data *session,
GError *err, void *user_data);
--
1.7.1
---
client/session.c | 1 +
client/session.h | 1 +
2 files changed, 2 insertions(+), 0 deletions(-)
mode change 100644 => 100755 client/session.h
diff --git a/client/session.c b/client/session.c
index 3db1c1d..8a6ee2c 100755
--- a/client/session.c
+++ b/client/session.c
@@ -561,6 +561,7 @@ struct session_data *session_create(const char *source,
session->refcount = 1;
session->channel = channel;
+ session->psm = psm;
session->conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
if (session->conn == NULL) {
diff --git a/client/session.h b/client/session.h
old mode 100644
new mode 100755
index af79ac8..9180e75
--- a/client/session.h
+++ b/client/session.h
@@ -36,6 +36,7 @@ struct session_data {
bdaddr_t src;
bdaddr_t dst;
uint8_t channel;
+ uint16_t psm; /* GOEP v2.0 and later supprot OBEX over L2CAP */
char *service; /* Service friendly name */
const char *target; /* OBEX Target UUID */
int target_len;
--
1.7.1
---
test/main.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/main.c b/test/main.c
index 37b307c..4bd8e19 100644
--- a/test/main.c
+++ b/test/main.c
@@ -256,7 +256,7 @@ int main(int argc, char *argv[])
exit(1);
}
- obex = gw_obex_setup_fd(sk, target, target_len, NULL, &error);
+ obex = gw_obex_setup_fd(sk, target, target_len, NULL, &error,FDOBEX_MT_STREAM);
if (obex == NULL) {
fprintf(stderr, "Failed to create OBEX session\n");
close(sk);
--
1.7.1
---
client/session.c | 4 ++--
gwobex/gw-obex.c | 6 +++---
gwobex/gw-obex.h | 3 ++-
gwobex/obex-priv.c | 4 ++--
gwobex/obex-priv.h | 2 +-
5 files changed, 10 insertions(+), 9 deletions(-)
mode change 100755 => 100644 client/session.c
diff --git a/client/session.c b/client/session.c
old mode 100755
new mode 100644
index 8119801..7acd3bb
--- a/client/session.c
+++ b/client/session.c
@@ -247,7 +247,7 @@ static void rfcomm_callback(GIOChannel *io, GError *err, gpointer user_data)
fd = g_io_channel_unix_get_fd(io);
obex = gw_obex_setup_fd(fd, session->target,
- session->target_len, NULL, NULL);
+ session->target_len, NULL, NULL, FDOBEX_MT_STREAM);
session->obex = obex;
@@ -306,7 +306,7 @@ static void l2cap_callback(GIOChannel *io, GError *err, gpointer user_data)
obex = gw_obex_setup_fd(fd, session->target,
- session->target_len, NULL, NULL);
+ session->target_len, NULL, NULL,FDOBEX_MT_SEQPACKET);
session->obex = obex;
diff --git a/gwobex/gw-obex.c b/gwobex/gw-obex.c
index 4481212..32331ed 100644
--- a/gwobex/gw-obex.c
+++ b/gwobex/gw-obex.c
@@ -322,11 +322,11 @@ void gw_obex_close(GwObex *ctx) {
}
GwObex *gw_obex_setup_fd(int fd, const gchar *uuid, gint uuid_len,
- GMainContext *context, gint *error) {
+ GMainContext *context, gint *error, gint fmt) {
obex_t *handle;
GwObex *ctx;
- if (!gw_obex_transport_setup(fd, &handle)) {
+ if (!gw_obex_transport_setup(fd, &handle, fmt)) {
debug("gw_obex_open() failed\n");
if (error)
*error = GW_OBEX_ERROR_CONNECT_FAILED;
@@ -394,7 +394,7 @@ GwObex *gw_obex_setup_dev(const char *dev, const gchar *uuid, gint uuid_len,
return NULL;
}
- ctx = gw_obex_setup_fd(fd, uuid, uuid_len, context, error);
+ ctx = gw_obex_setup_fd(fd, uuid, uuid_len, context, error, FDOBEX_MT_STREAM);
if (ctx == NULL) {
close(fd);
}
diff --git a/gwobex/gw-obex.h b/gwobex/gw-obex.h
index c858341..985c85b 100644
--- a/gwobex/gw-obex.h
+++ b/gwobex/gw-obex.h
@@ -183,7 +183,8 @@ GwObex *gw_obex_setup_fd(int fd,
const gchar *uuid,
gint uuid_len,
GMainContext *context,
- gint *error);
+ gint *error,
+ gint fmt);
/** Close GW OBEX connection and free all memory associated with it.
diff --git a/gwobex/obex-priv.c b/gwobex/obex-priv.c
index aba7dd7..ba24f8c 100644
--- a/gwobex/obex-priv.c
+++ b/gwobex/obex-priv.c
@@ -612,7 +612,7 @@ void obex_link_error(GwObex *ctx) {
}
}
-gboolean gw_obex_transport_setup(int fd, obex_t **handle) {
+gboolean gw_obex_transport_setup(int fd, obex_t **handle, int fmt) {
*handle = OBEX_Init(OBEX_TRANS_FD, obex_event_handler, 0);
if (*handle == NULL) {
debug("OBEX_Init() failed\n");
@@ -621,7 +621,7 @@ gboolean gw_obex_transport_setup(int fd, obex_t **handle) {
(void) OBEX_SetTransportMTU(*handle, GW_OBEX_RX_MTU, GW_OBEX_TX_MTU);
- if (FdOBEX_TransportSetup(*handle, fd, fd, 0) < 0) {
+ if (FdOBEX_TransportSetup(*handle, fd, fd, 0, fmt) < 0) {
debug("FdOBEX_TransportSetup() failed\n");
OBEX_Cleanup(*handle);
return FALSE;
diff --git a/gwobex/obex-priv.h b/gwobex/obex-priv.h
index f4e3e5b..66738a4 100644
--- a/gwobex/obex-priv.h
+++ b/gwobex/obex-priv.h
@@ -181,7 +181,7 @@ gboolean gw_obex_connect(GwObex *ctx, const char *target, size_t target_len);
gboolean gw_obex_disconnect(GwObex *ctx);
-gboolean gw_obex_transport_setup(int fd, obex_t **handle);
+gboolean gw_obex_transport_setup(int fd, obex_t **handle, int fmt);
gboolean gw_obex_action_op(GwObex *ctx, const gchar *src, const gchar *dst,
uint8_t action);
--
1.7.1
---
src/obex.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/obex.c b/src/obex.c
index e6585ca..4c032bc 100644
--- a/src/obex.c
+++ b/src/obex.c
@@ -1264,11 +1264,13 @@ int obex_session_start(GIOChannel *io, uint16_t tx_mtu, uint16_t rx_mtu,
struct obex_session *os;
obex_t *obex;
int ret, fd;
+ int fmt = FDOBEX_MT_STREAM;
os = g_new0(struct obex_session, 1);
- os->service = obex_service_driver_find(server->drivers, NULL,
- 0, NULL, 0);
+ //os->service = obex_service_driver_find(server->drivers, NULL,
+ // 0, NULL, 0);
+ os->service = server->drivers->data;
os->server = server;
os->rx_mtu = rx_mtu != 0 ? rx_mtu : DEFAULT_RX_MTU;
os->tx_mtu = tx_mtu != 0 ? tx_mtu : DEFAULT_TX_MTU;
@@ -1287,7 +1289,9 @@ int obex_session_start(GIOChannel *io, uint16_t tx_mtu, uint16_t rx_mtu,
fd = g_io_channel_unix_get_fd(io);
- ret = FdOBEX_TransportSetup(obex, fd, fd, 0);
+ if(os->service->protocol == L2CAP_OBEX)
+ fmt = FDOBEX_MT_SEQPACKET;
+ ret = FdOBEX_TransportSetup(obex, fd, fd, 0, fmt);
if (ret < 0) {
obex_session_free(os);
OBEX_Cleanup(obex);
--
1.7.1
---
plugins/bluetooth.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 93 insertions(+), 0 deletions(-)
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 7f81e14..632e148 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -31,6 +31,8 @@
#include <openobex/obex.h>
#include <openobex/obex_const.h>
+#include <bluetooth/bluetooth.h>
+#include <bluetooth/l2cap.h>
#include <glib.h>
#include <gdbus.h>
@@ -146,6 +148,26 @@ static struct bluetooth_service *find_service(
return NULL;
}
+static struct bluetooth_service *find_service_psm(
+ struct obex_service_driver *driver,
+ uint16_t psm)
+{
+ GSList *l;
+ DBG("");
+ for (l = any->services; l; l = l->next) {
+ struct bluetooth_service *service = l->data;
+
+ if (driver != NULL && service->driver != driver)
+ continue;
+
+ if (psm != 0 && service->driver->psm != psm)
+ continue;
+
+ return service;
+ }
+
+ return NULL;
+}
static void register_record(struct obex_server *server)
{
const GSList *l;
@@ -503,6 +525,49 @@ drop:
g_io_channel_shutdown(io, TRUE, NULL);
}
+static void l2cap_confirm_event(GIOChannel *io, void *user_data)
+{
+ struct bluetooth_service *service;
+ GError *err = NULL;
+ char address[18];
+ uint16_t psm;
+
+ bt_io_get(io, BT_IO_L2CAP, &err,
+ BT_IO_OPT_DEST, address,
+ BT_IO_OPT_PSM, &psm,
+ BT_IO_OPT_INVALID);
+ if (err) {
+ error("%s", err->message);
+ g_error_free(err);
+ goto drop;
+ }
+
+ info("bluetooth: New connection from: %s, psm 0x%x", address,
+ psm);
+
+ service = find_service_psm(NULL, psm);
+ if (service == NULL) {
+ error("bluetooth: Unable to find service");
+ goto drop;
+ }
+ if (service->driver->service != OBEX_OPP) {
+ if (request_service_authorization(service, io, address) < 0)
+ goto drop;
+
+ return;
+ }
+
+ if (!bt_io_accept(io, connect_event, service, NULL, &err)) {
+ error("%s", err->message);
+ g_error_free(err);
+ goto drop;
+ }
+
+ return;
+
+drop:
+ g_io_channel_shutdown(io, TRUE, NULL);
+}
static GIOChannel *start(struct obex_server *server,
struct obex_service_driver *service,
BtIOSecLevel sec_level)
@@ -525,6 +590,28 @@ static GIOChannel *start(struct obex_server *server,
return io;
}
+static GIOChannel *start_l2cap(struct obex_server *server,
+ struct obex_service_driver *service,
+ BtIOSecLevel sec_level)
+{
+ GIOChannel *io;
+ GError *err = NULL;
+ io = bt_io_listen(BT_IO_L2CAP, NULL, l2cap_confirm_event,
+ server, NULL, &err,
+ BT_IO_OPT_PSM, service->psm,
+ BT_IO_OPT_SEC_LEVEL, sec_level,
+ BT_IO_OPT_MTU, BT_RX_MTU,
+ BT_IO_OPT_MODE, L2CAP_MODE_ERTM,
+ BT_IO_OPT_INVALID);
+ if (io == NULL) {
+ error("bluetooth: unable to listen in psm 0x%x: %s",
+ service->psm, err->message);
+ g_error_free(err);
+ } else
+ DBG("listening on psm 0x%x", service->psm);
+
+ return io;
+}
static void *bluetooth_start(struct obex_server *server, int *err)
{
BtIOSecLevel sec_level;
@@ -545,6 +632,12 @@ static void *bluetooth_start(struct obex_server *server, int *err)
continue;
ios = g_slist_prepend(ios, io);
+
+ io = start_l2cap(server, service, sec_level);
+ if (io == NULL)
+ continue;
+
+ ios = g_slist_prepend(ios, io);
}
register_record(server);
--
1.7.1
---
plugins/bluetooth.c | 5 +++--
plugins/ftp.c | 2 ++
plugins/opp.c | 2 ++
3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 851daa2..7f81e14 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -175,7 +175,7 @@ static void register_record(struct obex_server *server)
continue;
xml = g_markup_printf_escaped(driver->record, driver->channel,
- driver->name);
+ driver->name, driver->psm);
add_record(any->path, xml, service);
g_free(xml);
}
@@ -207,7 +207,8 @@ static void find_adapter_any_reply(DBusPendingCall *call, void *user_data)
xml = g_markup_printf_escaped(service->driver->record,
service->driver->channel,
- service->driver->name);
+ service->driver->name,
+ service->driver->psm);
add_record(any->path, xml, service);
g_free(xml);
}
diff --git a/plugins/ftp.c b/plugins/ftp.c
index d8e5356..c057fae 100644
--- a/plugins/ftp.c
+++ b/plugins/ftp.c
@@ -56,6 +56,7 @@
#define CAP_TYPE "x-obex/capability"
#define FTP_CHANNEL 10
+#define FTP_PSM 0x1015
#define FTP_RECORD "<?xml version=\"1.0\" encoding=\"UTF-8\" ?> \
<record> \
<attribute id=\"0x0001\"> \
@@ -423,6 +424,7 @@ static struct obex_service_driver ftp = {
.name = "File Transfer server",
.service = OBEX_FTP,
.channel = FTP_CHANNEL,
+ .psm = FTP_PSM,
.record = FTP_RECORD,
.target = FTP_TARGET,
.target_size = TARGET_SIZE,
diff --git a/plugins/opp.c b/plugins/opp.c
index 7ea7e18..6fa71c3 100644
--- a/plugins/opp.c
+++ b/plugins/opp.c
@@ -44,6 +44,7 @@
#define VCARD_FILE CONFIGDIR "/vcard.vcf"
#define OPP_CHANNEL 9
+#define OPP_PSM 0x1009
#define OPP_RECORD "<?xml version=\"1.0\" encoding=\"UTF-8\" ?> \
<record> \
<attribute id=\"0x0001\"> \
@@ -214,6 +215,7 @@ static struct obex_service_driver driver = {
.name = "Object Push server",
.service = OBEX_OPP,
.channel = OPP_CHANNEL,
+ .psm = OPP_PSM,
.record = OPP_RECORD,
.connect = opp_connect,
.progress = opp_progress,
--
1.7.1
---
src/service.h | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/service.h b/src/service.h
index a844885..313b1f2 100644
--- a/src/service.h
+++ b/src/service.h
@@ -25,6 +25,7 @@ struct obex_service_driver {
const char *name;
uint16_t service;
uint8_t channel;
+ uint16_t psm;
const uint8_t *target;
unsigned int target_size;
const uint8_t *who;
--
1.7.1