* Re: [Bluez-devel] rejecting or accepting connection request
2005-04-05 17:35 Tzahi Efrati
@ 2005-04-05 16:49 ` Marcel Holtmann
0 siblings, 0 replies; 8+ messages in thread
From: Marcel Holtmann @ 2005-04-05 16:49 UTC (permalink / raw)
To: bluez-devel
Hi Tzahi,
> I'm trying to build an application which accepts or rejects incoming
> connections according to the requesting device's bd_Addr. My
> application compares the requesting device's bd_Addr to a list and if
> the address is in the list, the application accepts the request.
> Otherwise, it rejects it.
> I have set the event filter to EVT_CONN_REQEUST (and
> EVT_CONN_COMPLETE and EVT_DISCONN_COMPLETE) and I'm using select()
> followed by read() to get the events. My problem is that for every
> EVT_CONN_REQ I receive, the hci interface automatically accepts it.
> I've tried to set the link_mode with different values using the
> hciconfigure but it didn't help.
>
> It seems that the only way I can make this bd_addr filtering is by
> disconnecting the connections with un-listed bd_addreses. Am I right?
> any ideas?
what you are talking about will be handled by an in-kernel policy
manager, but actually this code is far away from being finished at the
moment. And you must do this inside the kernel, because it is not the
job of the userspace to handle HCI connections.
Regards
Marcel
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bluez-devel] rejecting or accepting connection request
@ 2005-04-05 17:35 Tzahi Efrati
2005-04-05 16:49 ` Marcel Holtmann
0 siblings, 1 reply; 8+ messages in thread
From: Tzahi Efrati @ 2005-04-05 17:35 UTC (permalink / raw)
To: bluez-devel
[-- Attachment #1: Type: text/plain, Size: 853 bytes --]
Hi,
I'm trying to build an application which accepts or rejects incoming
connections according to the requesting device's bd_Addr. My application
compares the requesting device's bd_Addr to a list and if the address
is in the list, the application accepts the request. Otherwise, it
rejects it.
I have set the event filter to EVT_CONN_REQEUST (and EVT_CONN_COMPLETE
and EVT_DISCONN_COMPLETE) and I'm using select() followed by read() to
get the events. My problem is that for every EVT_CONN_REQ I receive, the
hci interface automatically accepts it. I've tried to set the link_mode
with different values using the hciconfigure but it didn't help.
It seems that the only way I can make this bd_addr filtering is by
disconnecting the connections with un-listed bd_addreses. Am I right?
any ideas?
regards,
Tzahi Efrati
[-- Attachment #2: Type: text/html, Size: 2075 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [Bluez-devel] rejecting or accepting connection request
@ 2005-04-06 18:00 Tzahi Efrati
2005-04-07 10:32 ` Marcel Holtmann
0 siblings, 1 reply; 8+ messages in thread
From: Tzahi Efrati @ 2005-04-06 18:00 UTC (permalink / raw)
To: bluez-devel
Hi Marcel,
Thanks for the answer. I changed hci_conn_request_evt() to simply return
without doing anything, and hci_conn_complete_evt() to allocate (using
hci_add_conn()) the hci_conn struct. So far it seems to work with no
side-effects.
Regards,
Tzahi
-----Original Message-----
From: bluez-devel-admin@lists.sourceforge.net
[mailto:bluez-devel-admin@lists.sourceforge.net] On Behalf Of Marcel
Holtmann
Sent: Tuesday, April 05, 2005 7:49 PM
To: bluez-devel@lists.sourceforge.net
Subject: Re: [Bluez-devel] rejecting or accepting connection request
Hi Tzahi,
> I'm trying to build an application which accepts or rejects incoming=20
> connections according to the requesting device's bd_Addr. My=20
> application compares the requesting device's bd_Addr to a list and if=20
> the address is in the list, the application accepts the request.
> Otherwise, it rejects it.
> I have set the event filter to EVT_CONN_REQEUST (and =20
> EVT_CONN_COMPLETE and EVT_DISCONN_COMPLETE) and I'm using select()=20
> followed by read() to get the events. My problem is that for every=20
> EVT_CONN_REQ I receive, the hci interface automatically accepts it.
> I've tried to set the link_mode with different values using the=20
> hciconfigure but it didn't help.
> =20
> It seems that the only way I can make this bd_addr filtering is by=20
> disconnecting the connections with un-listed bd_addreses. Am I right?
> any ideas?
what you are talking about will be handled by an in-kernel policy
manager, but actually this code is far away from being finished at the
moment. And you must do this inside the kernel, because it is not the
job of the userspace to handle HCI connections.
Regards
Marcel
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide Read honest & candid
reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=3D6595&alloc_id=3D14396&op=3Dclick
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [Bluez-devel] rejecting or accepting connection request
2005-04-06 18:00 [Bluez-devel] rejecting or accepting connection request Tzahi Efrati
@ 2005-04-07 10:32 ` Marcel Holtmann
0 siblings, 0 replies; 8+ messages in thread
From: Marcel Holtmann @ 2005-04-07 10:32 UTC (permalink / raw)
To: BlueZ Mailing List
Hi Tzahi,
> Thanks for the answer. I changed hci_conn_request_evt() to simply return
> without doing anything, and hci_conn_complete_evt() to allocate (using
> hci_add_conn()) the hci_conn struct. So far it seems to work with no
> side-effects.
show me your patch and the daemon you use in userspace.
Regards
Marcel
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [Bluez-devel] rejecting or accepting connection request
2005-04-07 16:29 Tzahi Efrati
@ 2005-04-07 15:48 ` Marcel Holtmann
0 siblings, 0 replies; 8+ messages in thread
From: Marcel Holtmann @ 2005-04-07 15:48 UTC (permalink / raw)
To: BlueZ Mailing List
Hi Tzahi,
> Following are the two functions I modified:
please send a patch (diff -u) for it.
Regards
Marcel
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [Bluez-devel] rejecting or accepting connection request
@ 2005-04-07 16:29 Tzahi Efrati
2005-04-07 15:48 ` Marcel Holtmann
0 siblings, 1 reply; 8+ messages in thread
From: Tzahi Efrati @ 2005-04-07 16:29 UTC (permalink / raw)
To: bluez-devel
Hi Marcel,
Following are the two functions I modified:
Regards,
Tzahi
/* Connect Request */
static inline void hci_conn_request_evt(struct hci_dev *hdev, struct
sk_buff *skb)
{
int IsUserAppPolicy =3D 1;
evt_conn_request *cr =3D (evt_conn_request *) skb->data;
int mask =3D hdev->link_mode;
BT_DBG("%s Connection request: %s type 0x%x", hdev->name,
batostr(&cr->bdaddr), cr->link_type);
if ( IsUserAppPolicy=3D=3D1 )
{
BT_DBG("%s Connection request: %s letting the app decide
if to accept or reject", hdev->name);
return;
}
=09
mask |=3D hci_proto_connect_ind(hdev, &cr->bdaddr, cr->link_type);
if (mask & HCI_LM_ACCEPT) {
/* Connection accepted */
struct hci_conn *conn;
accept_conn_req_cp ac;
hci_dev_lock(hdev);
conn =3D conn_hash_lookup_ba(hdev, cr->link_type,
&cr->bdaddr);
if (!conn) {
if (!(conn =3D hci_conn_add(hdev, cr->link_type,
&cr->bdaddr))) {
BT_ERR("No memmory for new connection");
hci_dev_unlock(hdev);
return;
}
}
conn->state =3D BT_CONNECT;
hci_dev_unlock(hdev);
bacpy(&ac.bdaddr, &cr->bdaddr);
=09
if (lmp_rswitch_capable(hdev) && (mask & HCI_LM_MASTER))
ac.role =3D 0x00; /* Become master */
else
ac.role =3D 0x01; /* Remain slave */
hci_send_cmd(hdev, OGF_LINK_CTL, OCF_ACCEPT_CONN_REQ,=20
ACCEPT_CONN_REQ_CP_SIZE, &ac);
} else {
/* Connection rejected */
reject_conn_req_cp rc;
bacpy(&rc.bdaddr, &cr->bdaddr);
rc.reason =3D 0x0f;
hci_send_cmd(hdev, OGF_LINK_CTL, OCF_REJECT_CONN_REQ,
REJECT_CONN_REQ_CP_SIZE, &rc);
}
}
/* Connect Complete */
static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct
sk_buff *skb)
{
evt_conn_complete *cc =3D (evt_conn_complete *) skb->data;
struct hci_conn *conn =3D NULL;
BT_DBG("%s", hdev->name);
hci_dev_lock(hdev);
=09
conn =3D conn_hash_lookup_ba(hdev, cc->link_type, &cc->bdaddr);
if (!conn)=20
{
if (!(conn =3D hci_conn_add(hdev, cc->link_type,
&cc->bdaddr)))=20
{
BT_ERR("No memmory for new connection");
hci_dev_unlock(hdev);
return;
}
}
if (!cc->status) {
conn->handle =3D __le16_to_cpu(cc->handle);
conn->state =3D BT_CONNECTED;
if (test_bit(HCI_AUTH, &hdev->flags))
conn->link_mode |=3D HCI_LM_AUTH;
=09
if (test_bit(HCI_ENCRYPT, &hdev->flags))
conn->link_mode |=3D HCI_LM_ENCRYPT;
/* Set link policy */
if (conn->type =3D=3D ACL_LINK && hdev->link_policy) {
write_link_policy_cp lp;
lp.handle =3D cc->handle;
lp.policy =3D __cpu_to_le16(hdev->link_policy);
hci_send_cmd(hdev, OGF_LINK_POLICY,
OCF_WRITE_LINK_POLICY,
WRITE_LINK_POLICY_CP_SIZE, &lp);
}
/* Set packet type for incomming connection */
if (!conn->out) {
change_conn_ptype_cp cp;
cp.handle =3D cc->handle;
cp.pkt_type =3D (conn->type =3D=3D ACL_LINK) ?=20
__cpu_to_le16(hdev->pkt_type &
ACL_PTYPE_MASK):
__cpu_to_le16(hdev->pkt_type &
SCO_PTYPE_MASK);
hci_send_cmd(hdev, OGF_LINK_CTL,
OCF_CHANGE_CONN_PTYPE,
CHANGE_CONN_PTYPE_CP_SIZE, &cp);
}
} else
conn->state =3D BT_CLOSED;
if (conn->type =3D=3D ACL_LINK) {
struct hci_conn *sco =3D conn->link;
if (sco) {
if (!cc->status)
hci_add_sco(sco, conn->handle);
else {
hci_proto_connect_cfm(sco, cc->status);
hci_conn_del(sco);
}
}
}
hci_proto_connect_cfm(conn, cc->status);
if (cc->status)
hci_conn_del(conn);
hci_dev_unlock(hdev);
}=20
-----Original Message-----
From: bluez-devel-admin@lists.sourceforge.net
[mailto:bluez-devel-admin@lists.sourceforge.net] On Behalf Of Marcel
Holtmann
Sent: Thursday, April 07, 2005 1:32 PM
To: BlueZ Mailing List
Subject: RE: [Bluez-devel] rejecting or accepting connection request
Hi Tzahi,
> Thanks for the answer. I changed hci_conn_request_evt() to simply=20
> return without doing anything, and hci_conn_complete_evt() to allocate
> (using
> hci_add_conn()) the hci_conn struct. So far it seems to work with no=20
> side-effects.
show me your patch and the daemon you use in userspace.
Regards
Marcel
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide Read honest & candid
reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=3D6595&alloc_id=3D14396&op=3Dclick
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [Bluez-devel] rejecting or accepting connection request
2005-04-07 16:56 Tzahi Efrati
@ 2005-04-07 16:41 ` Marcel Holtmann
0 siblings, 0 replies; 8+ messages in thread
From: Marcel Holtmann @ 2005-04-07 16:41 UTC (permalink / raw)
To: BlueZ Mailing List
Hi Tzahi,
> + if ( IsUserAppPolicy==1 )
> + {
> + BT_DBG("%s Connection request: %s letting the app decide
> if to accept or reject", hdev->name);
> + return;
> + }
> +
I don't think that I will add this part of your patch, because I have
plans for a policy manager.
> conn = conn_hash_lookup_ba(hdev, cc->link_type, &cc->bdaddr);
> - if (!conn) {
> - hci_dev_unlock(hdev);
> - return;
> + if (!conn)
> + {
> + if (!(conn = hci_conn_add(hdev, cc->link_type,
> &cc->bdaddr)))
> + {
> + BT_ERR("No memmory for new connection");
> + hci_dev_unlock(hdev);
> + return;
> + }
This part is not so unhandy to have it anyway, but you forgot to think
about what this change means if the ev->status is not zero.
Regards
Marcel
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [Bluez-devel] rejecting or accepting connection request
@ 2005-04-07 16:56 Tzahi Efrati
2005-04-07 16:41 ` Marcel Holtmann
0 siblings, 1 reply; 8+ messages in thread
From: Tzahi Efrati @ 2005-04-07 16:56 UTC (permalink / raw)
To: bluez-devel
Here goes,
Regards
Tzahi
--- hci_event.c_orig_060405_auto_accept_incoming_conn Wed Apr 6
09:47:22 2005
+++ hci_event.c Wed Apr 6 13:48:42 2005
@@ -478,12 +478,19 @@
/* Connect Request */
static inline void hci_conn_request_evt(struct hci_dev *hdev, struct
sk_buff *skb)
{
+ int IsUserAppPolicy =3D 1;
evt_conn_request *cr =3D (evt_conn_request *) skb->data;
int mask =3D hdev->link_mode;
=20
BT_DBG("%s Connection request: %s type 0x%x", hdev->name,
batostr(&cr->bdaddr), cr->link_type);
=20
+ if ( IsUserAppPolicy=3D=3D1 )
+ {
+ BT_DBG("%s Connection request: %s letting the app decide
if to accept or reject", hdev->name);
+ return;
+ }
+ =09
mask |=3D hci_proto_connect_ind(hdev, &cr->bdaddr, cr->link_type);
=20
if (mask & HCI_LM_ACCEPT) {
@@ -534,9 +541,14 @@
hci_dev_lock(hdev);
=09
conn =3D conn_hash_lookup_ba(hdev, cc->link_type, &cc->bdaddr);
- if (!conn) {
- hci_dev_unlock(hdev);
- return;
+ if (!conn)=20
+ {
+ if (!(conn =3D hci_conn_add(hdev, cc->link_type,
&cc->bdaddr)))=20
+ {
+ BT_ERR("No memmory for new connection");
+ hci_dev_unlock(hdev);
+ return;
+ }
}
=20
if (!cc->status) {=20
-----Original Message-----
From: bluez-devel-admin@lists.sourceforge.net
[mailto:bluez-devel-admin@lists.sourceforge.net] On Behalf Of Marcel
Holtmann
Sent: Thursday, April 07, 2005 6:48 PM
To: BlueZ Mailing List
Subject: RE: [Bluez-devel] rejecting or accepting connection request
Hi Tzahi,
> Following are the two functions I modified:
please send a patch (diff -u) for it.
Regards
Marcel
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide Read honest & candid
reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=3D6595&alloc_id=3D14396&op=3Dclick
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2005-04-07 16:56 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-06 18:00 [Bluez-devel] rejecting or accepting connection request Tzahi Efrati
2005-04-07 10:32 ` Marcel Holtmann
-- strict thread matches above, loose matches on Subject: below --
2005-04-07 16:56 Tzahi Efrati
2005-04-07 16:41 ` Marcel Holtmann
2005-04-07 16:29 Tzahi Efrati
2005-04-07 15:48 ` Marcel Holtmann
2005-04-05 17:35 Tzahi Efrati
2005-04-05 16:49 ` Marcel Holtmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox