Adds pan connect disconnect and get role methods
cover Adds pan connect disconnect and get role methods
This patch set supports PANU role with a minor fix in android. Added CAP_NET_RAW capability for bnep services. Creates bnep connection and up the inreface on connect call and free the device on disconnect call. Interface name(bnepX) will be notified on control state cb. Android environment will create IP address with dhcp calls.
Ravi kumar Veeramally (4):
android: Add CAP_NET_RAW capability
android/pan: Implement pan connect method in daemon android/pan: Implement pan disconnect method in daemon android/pan: Implement the get local role method in daemon
android/Android.mk | 2 + android/Makefile.am | 3 +- android/main.c | 1 + android/pan.c | 340 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 336 insertions(+), 10 deletions(-)
Signature · 1 line
1.8.3.2
PATCH 1/4 android: Add CAP_NET_RAW capability
CAP_NET_RAW capability is required to up the bnep interfaces in android environment.
--- android/main.c | 1 + 1 file changed, 1 insertion(+)
android/main.c +1 -0
@@ -506,6 +506,7 @@ static bool set_capabilities(void) header.pid =0 ; cap.effective = cap.permitted = +CAP_TO_MASK (CAP_NET_RAW ) |CAP_TO_MASK (CAP_NET_ADMIN ) |CAP_TO_MASK (CAP_NET_BIND_SERVICE ); cap.inheritable =0 ;
Signature · 1 line
1.8.3.2
Re: [PATCH 1/4] android: Add CAP_NET_RAW capability
Hi Ravi,
Quoted 11 lines · Ravi kumar Veeramally
CAP_NET_RAWcapability is required to up the bnep interfaces in android environment.--- android/main.c | 1 + 1 file changed, 1 insertion(+)android/main.c +0
-0
android/main.c static bool set_capabilities(void) · line 512
Quoted 7 lines
android/main.c +1
-0@@ -506,6 +506,7 @@ static bool set_capabilities(void) header.pid =0 ; cap.effective = cap.permitted = +CAP_TO_MASK (CAP_NET_RAW ) |CAP_TO_MASK (CAP_NET_ADMIN ) |CAP_TO_MASK (CAP_NET_BIND_SERVICE ); cap.inheritable =0 ;
Would you then say that commit 9bda7e8c2130de9a3340ebd0e6cc1dedc2eae338 is incorrect? A quick grep doesn't show any instances of checking this capability in the BNEP code of the kernel. Exactly which system call is it that needs it?
If you answered positively to my first question, please send a patch for that as well.
Johan
Re: [PATCH 1/4] android: Add CAP_NET_RAW capability
Hi Johan,
Quoted 16 lines · Johan Hedberg
Hi Ravi,
Quoted 13 lines · Ravi kumar Veeramally
CAP_NET_RAWcapability is required to up the bnep interfaces in android environment.--- android/main.c | 1 + 1 file changed, 1 insertion(+)android/main.c +0
-0@@ -506,6 +506,7 @@ static bool set_capabilities(void) header.pid =0 ;
Quoted 9 lines
android/main.c static bool set_capabilities(void) · line 512
Quoted 5 lines
android/main.c +1
-0cap.effective = cap.permitted = +CAP_TO_MASK (CAP_NET_RAW ) |CAP_TO_MASK (CAP_NET_ADMIN ) |CAP_TO_MASK (CAP_NET_BIND_SERVICE ); cap.inheritable =0 ;Would you then say that commit
9bda7e8c2130de9a3340ebd0e6cc1dedc2eae338is incorrect? A quick grep doesn't show any instances of checking this capability in the BNEP code of the kernel. Exactly which system call is it that needs it?
bnep_if_up from profiles/network/common.c
---
ifr.ifr_flags |= IFF_UP;
ifr.ifr_flags |= IFF_MULTICAST;
err = ioctl(sk, SIOCSIFFLAGS, (caddr_t) &ifr);---
requires this capability in android environment only. this code is under android macro.
Quoted 2 lines
If you answered positively to my first question, please send a patch for that as well.
I didn't understand this, sorry.
Thanks,
Ravi.
Re: [PATCH 1/4] android: Add CAP_NET_RAW capability
Hi Ravi,
Quoted 27 lines · Ravi kumar Veeramally
Quoted 9 lines · Johan Hedberg
Hi Ravi,
Quoted 6 lines · Ravi kumar Veeramally
CAP_NET_RAWcapability is required to up the bnep interfaces in android environment.--- android/main.c | 1 + 1 file changed, 1 insertion(+)Quoted 15 lines
android/main.c static bool set_capabilities(void) · line 511
Quoted 11 lines
android/main.c +1
-0@@ -506,6 +506,7 @@ static bool set_capabilities(void) header.pid =0 ; cap.effective = cap.permitted = +CAP_TO_MASK (CAP_NET_RAW ) |CAP_TO_MASK (CAP_NET_ADMIN ) |CAP_TO_MASK (CAP_NET_BIND_SERVICE ); cap.inheritable =0 ;Would you then say that commit
9bda7e8c2130de9a3340ebd0e6cc1dedc2eae338is incorrect? A quick grep doesn't show any instances of checking this capability in the BNEP code of the kernel. Exactly which system call is it that needs it?
bnep_if_upfromprofiles/network/common.c
---
Quoted 7 lines
ifr.ifr_flags |= IFF_UP; ifr.ifr_flags |= IFF_MULTICAST; err = ioctl(sk, SIOCSIFFLAGS, (caddr_t) &ifr);---
requires this capability in android environment only. this code is under android macro.
So you've verified that under "normal" Linux this ioctl does not require the NET_RAW capability?
Quoted 3 lines
Quoted 2 lines
If you answered positively to my first question, please send a patch for that as well.
I didn't understand this, sorry.
My first question was: "Would you then say that
commit 9bda7e8c2130de9a3340ebd0e6cc1dedc2eae338 is incorrect?". Do you not understand that question or what I asked you to do in case the answer is "yes"?
Johan
Re: [PATCH 1/4] android: Add CAP_NET_RAW capability
Hi Johan,
Quoted 40 lines · Johan Hedberg
Hi Ravi,
Quoted 27 lines · Ravi kumar Veeramally
Quoted 9 lines · Johan Hedberg
Hi Ravi,
Quoted 6 lines · Ravi kumar Veeramally
CAP_NET_RAWcapability is required to up the bnep interfaces in android environment.--- android/main.c | 1 + 1 file changed, 1 insertion(+)Quoted 15 lines
android/main.c static bool set_capabilities(void) · line 511
Quoted 11 lines
android/main.c +1
-0@@ -506,6 +506,7 @@ static bool set_capabilities(void) header.pid =0 ; cap.effective = cap.permitted = +CAP_TO_MASK (CAP_NET_RAW ) |CAP_TO_MASK (CAP_NET_ADMIN ) |CAP_TO_MASK (CAP_NET_BIND_SERVICE ); cap.inheritable =0 ;Would you then say that commit
9bda7e8c2130de9a3340ebd0e6cc1dedc2eae338is incorrect? A quick grep doesn't show any instances of checking this capability in the BNEP code of the kernel. Exactly which system call is it that needs it?
bnep_if_upfromprofiles/network/common.c
---Quoted 7 lines
ifr.ifr_flags |= IFF_UP; ifr.ifr_flags |= IFF_MULTICAST; err = ioctl(sk, SIOCSIFFLAGS, (caddr_t) &ifr);---
requires this capability in android environment only. this code is under android macro.So you've verified that under "normal" Linux this ioctl does not require the
NET_RAWcapability?
Quoted 7 lines
Quoted 3 lines
Quoted 2 lines
If you answered positively to my first question, please send a patch for that as well.
I didn't understand this, sorry.
My first question was: "Would you then say that
commit9bda7e8c2130de9a3340ebd0e6cc1dedc2eae338is incorrect?". Do you not understand that question or what I asked you to do in case the answer is "yes"?
I tried on host with systemd configure options and limiting
capabilities to
only CAP_NET_ADMIN and CAP_NET_BIND_SERVICE. ioctl call for
interface(bnepX)
up works well. Android throws an error("Permission denied").CAP_NET_RAW is required
for android.
Thanks,
Ravi.
PATCH 2/4 android/pan: Implement pan connect method in daemon
In reply to Ravi kumar VeeramallyImplements the PAN connect method in android daemon with PANU role only. Setting up the bnep environment, adds connection and makes bnep interface up. Notifies bnep interface on control state call back and connection status on connection state call back.
--- android/Android.mk | 2 + android/Makefile.am | 3 +- android/pan.c | 289 +++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 291 insertions(+), 3 deletions(-)
android/Android.mk +2 -0
@@ -41,6 +41,7 @@ LOCAL_SRC_FILES := \ ../lib/hci.c \ ../btio/btio.c \ ../src/sdp-client.c \ + ../profiles/network/common.c \ LOCAL_C_INCLUDES := \ $(call include-path-for, glib) \
@@ -65,6 +66,7 @@ lib_headers := \ sdp.h \ rfcomm.h \ sco.h \ + bnep.h \ $(shell mkdir -p $(LOCAL_PATH)/../lib/bluetooth)
android/Makefile.am +2 -1
@@ -23,7 +23,8 @@ android_bluetoothd_SOURCES = android/main.c \ android/socket.h android/socket.c \ android/pan.h android/pan.c \ btio/btio.h btio/btio.c \ - src/sdp-client.h src/sdp-client.c + src/sdp-client.h src/sdp-client.c \ + profiles/network/common.c profiles/network/common.h android_bluetoothd_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@
android/pan.c +287 -2
324 lines not on this page · raw message
Signature · 1 line
1.8.3.2
Re: [PATCH 2/4] android/pan: Implement pan connect method in daemon
Hi Ravi,
Quoted 9 lines · Ravi kumar Veeramally
Implements the PAN connect method in android daemon with PANU role only. Setting up the bnep environment, adds connection and makes bnep interface up. Notifies bnep interface on control state call back and connection status on connection state call back.
--- android/Android.mk | 2 + android/Makefile.am | 3 +- android/pan.c | 289 +++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 291 insertions(+), 3 deletions(-)
I've applied the first patch in this set, however I'll wait for a new revision of the rest including the refactoring of profiles/network/common.c and profiles/network/connection.c.
Johan
PATCH 3/4 android/pan: Implement pan disconnect method in daemon
In reply to Ravi kumar VeeramallyDisconnect ongoing PANU role connection betweek devices, free the device and notify the connection state.
--- android/pan.c | 59 +++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 14 deletions(-)
android/pan.c +45 -14
@@ -270,20 +270,6 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer data) bnep_setup_cb, np); } -static uint8_t bt_pan_enable (struct hal_cmd_pan_enable *cmd,uint16_t len) -{ -DBG ("Not Implemented" ); - -return HAL_STATUS_FAILED ; -} - -static uint8_t bt_pan_get_role (void *cmd,uint16_t len) -{ -DBG ("Not Implemented" ); - -return HAL_STATUS_FAILED ; -} -static uint8_t bt_pan_connect (struct hal_cmd_pan_connect *cmd,uint16_t len) {struct network_peer *np;
@@ -335,6 +321,51 @@ static uint8_t bt_pan_connect(struct hal_cmd_pan_connect *cmd, uint16_t len)static uint8_t bt_pan_disconnect (struct hal_cmd_pan_disconnect *cmd,uint16_t len) { +struct network_peer *np; +GSList *l; +bdaddr_t dst; + +DBG ("" ); + +if (len <sizeof (*cmd)) +return HAL_STATUS_INVALID ; + +android2bdaddr (&cmd->bdaddr, &dst); + + l =g_slist_find_custom (peers, &dst, peer_cmp); +if (!l) +return HAL_STATUS_FAILED ; + + np = l->data; + +if (np->conn_state ==HAL_PAN_STATE_CONNECTED ) { +if (np->watch) { +g_source_remove (np->watch); + np->watch =0 ; + } + +bnep_if_down (np->dev); +bnep_kill_connection (&dst); +bt_pan_notify_conn_state (np,HAL_PAN_STATE_DISCONNECTED ); +network_peer_free (np); + + }else if (np->io) { +bt_pan_notify_conn_state (np,HAL_PAN_STATE_DISCONNECTING ); +g_io_channel_shutdown (np->io, TRUE,NULL ); + } + +return HAL_STATUS_SUCCESS ; +} + +static uint8_t bt_pan_enable (struct hal_cmd_pan_enable *cmd,uint16_t len) +{ +DBG ("Not Implemented" ); + +return HAL_STATUS_FAILED ; +} + +static uint8_t bt_pan_get_role (void *cmd,uint16_t len) +{DBG ("Not Implemented" );return HAL_STATUS_FAILED ;
Signature · 1 line
1.8.3.2
PATCH 4/4 android/pan: Implement the get local role method in daemon
In reply to Ravi kumar VeeramallyReturns local role of the device (NONE, PANU or NAP).
--- android/pan.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
android/pan.c +10 -4
@@ -364,11 +364,17 @@ static uint8_t bt_pan_enable(struct hal_cmd_pan_enable *cmd, uint16_t len)return HAL_STATUS_FAILED ; } -static uint8_t bt_pan_get_role (void *cmd,uint16_t len) +static uint8_t bt_pan_get_role (int sk,void *cmd,uint16_t len) { -DBG ("Not Implemented" ); +struct hal_rsp_pan_get_role rsp; -return HAL_STATUS_FAILED ; +DBG ("" ); + + rsp.local_role = local_role; +ipc_send (sk,HAL_SERVICE_ID_PAN ,HAL_OP_PAN_GET_ROLE ,sizeof (rsp), + &rsp,-1 ); + +return HAL_STATUS_SUCCESS ; }void bt_pan_handle_cmd (int sk,uint8_t opcode,void *buf,uint16_t len)
@@ -380,7 +386,7 @@ void bt_pan_handle_cmd(int sk, uint8_t opcode, void *buf, uint16_t len) status =bt_pan_enable (buf, len);break ;case HAL_OP_PAN_GET_ROLE : - status =bt_pan_get_role (buf, len); + status =bt_pan_get_role (sk, buf, len);break ;case HAL_OP_PAN_CONNECT : status =bt_pan_connect (buf, len);
Signature · 1 line
1.8.3.2