* [PATCH 1/2] android/pts: Add PTS PICS and PIXIT for MAP
From: Jakub Tyszkowski @ 2013-12-17 10:53 UTC (permalink / raw)
To: linux-bluetooth
Add PICS and PIXIT targetting Android 4.4 and PTS version 5.0.
---
android/Makefile.am | 3 +-
android/pics-map.txt | 175 ++++++++++++++++++++++++++++++++++++++++++++++++++
android/pixit-map.txt | 45 +++++++++++++
3 files changed, 222 insertions(+), 1 deletion(-)
create mode 100644 android/pics-map.txt
create mode 100644 android/pixit-map.txt
diff --git a/android/Makefile.am b/android/Makefile.am
index 0034487..abeda84 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -122,4 +122,5 @@ EXTRA_DIST += android/Android.mk android/hal-ipc-api.txt android/README \
android/pixit-opp.txt android/pixit-pan.txt \
android/pixit-pbap.txt android/pts-gap.txt android/pts-hid.txt \
android/pts-opp.txt android/pts-pbap.txt \
- android/audio-ipc-api.txt
+ android/audio-ipc-api.txt android/pics-map.txt \
+ android/pixit-map.txt
diff --git a/android/pics-map.txt b/android/pics-map.txt
new file mode 100644
index 0000000..2875885
--- /dev/null
+++ b/android/pics-map.txt
@@ -0,0 +1,175 @@
+MAP PICS for the PTS tool.
+
+PTS version: 5.0
+
+* - different than PTS defaults
+# - not yet implemented/supported
+
+M - mandatory
+O - optional
+
+ Profile Version
+-------------------------------------------------------------------------------
+Parameter Name Selected Description
+-------------------------------------------------------------------------------
+TSPC_MAP_0_1 False Role: Map 1.0 (C1)
+TSPC_MAP_0_2 True (*) Role: Map 1.1 (C1)
+TSPC_MAP_0_3 False Role: Map 1.2 (C1)
+-------------------------------------------------------------------------------
+C.1: Mandatory to support only one Profile version.
+-------------------------------------------------------------------------------
+
+
+ Roles
+-------------------------------------------------------------------------------
+Parameter Name Selected Description
+-------------------------------------------------------------------------------
+TSPC_MAP_1_1 True (*) Role: Messaging Server Equipment (C1)
+TSPC_MAP_1_2 False Role: Messaging Client Equipment (C1)
+-------------------------------------------------------------------------------
+C.1: It is mandatory to support at least one of the defined roles.
+-------------------------------------------------------------------------------
+
+
+ Supported features MCE
+-------------------------------------------------------------------------------
+Parameter Name Selected Description
+-------------------------------------------------------------------------------
+TSPC_MAP_2_1 False MCE: Message Notification (C1)
+TSPC_MAP_2_1a False MCE: SendEvent (C4)
+TSPC_MAP_2_2 False MCE: Message Browsing (C1)
+TSPC_MAP_2_2a False MCE: SetFolder (C5)
+TSPC_MAP_2_2b False MCE: GetFoldersListing (C5)
+TSPC_MAP_2_2c False MCE: GetMessagesListing (C5)
+TSPC_MAP_2_2d False MCE: GetMessage (O)
+TSPC_MAP_2_2e False MCE: SetMessageStatus (O)
+TSPC_MAP_2_2f False MCE: UpdateInbox (O)
+TSPC_MAP_2_2g False MCE: Filtering (O)
+TSPC_MAP_2_2h False MCE: Multiple simultaneous MAS instances (O)
+TSPC_MAP_2_3 False MCE: Message Uploading (O)
+TSPC_MAP_2_3a False MCE: SetFolder (C6)
+TSPC_MAP_2_3b False MCE: GetFoldersListing (C6)
+TSPC_MAP_2_3c False MCE: PushMessage (C6)
+TSPC_MAP_2_4 False MCE: Message Delete (O)
+TSPC_MAP_2_4a False MCE: SetMessageStatus (C7)
+TSPC_MAP_2_5 False MCE: Notification Registration (C2)
+TSPC_MAP_2_5a False MCE: SetNotificationRegistration off (O)
+TSPC_MAP_2_5b False MCE: SetNotificationRegistration on (C8)
+TSPC_MAP_2_6 False MCE: Supported Message Types
+TSPC_MAP_2_6a False (*) MCE: EMAIL (C3)
+TSPC_MAP_2_6b False (*) MCE: SMS_GSM (C3)
+TSPC_MAP_2_6c False (*) MCE: SMS_CDMA (C3)
+TSPC_MAP_2_6d False (*) MCE: MMS (C3)
+TSPC_MAP_2_7 False MCE: Instance Information (Not Supported)
+TSPC_MAP_2_7a False (*) MCE: GetMASInstanceInformation (Not Supported)
+TSPC_MAP_2_8 False MCE: Extended MAP-Event-Report (Not Supported)
+TSPC_MAP_2_8a False (*) MCE: MAP-Event-Report: Version 1.1
+ (Not Supported)
+-------------------------------------------------------------------------------
+C.1: Mandatory to support at least one of the defined features TSPC_MAP_2_1 or
+ TSPC_MAP_2_2.
+C.2: Mandatory to support TSPC_MAP_2_5 if TSPC_MAP_2_1 is supported.
+C.3: Mandatory to support at least one of the defined message types
+ TSPC_MAP_2_6a to TSPC_MAP_2_6d IF TSPC_MAP_2_2 or TSPC_MAP_2_3 is
+ supported.
+C.4: Support of functionality TSPC_MAP_2_1a mandatory IF related feature
+ TSPC_MAP_2_1 supported.
+C.5: Support of functionality mandatory IF TSPC_MAP_2_2 supported.
+C.6: Support of functionality mandatory IF TSPC_MAP_2_3 supported.
+C.7: Support of functionality mandatory IF TSPC_MAP_2_4 supported.
+C.8: Mandatory to support IF TSPC_MAP_2_5 (Notification Registration) is
+ supported, otherwise excluded.
+C.9: Optional to support IF TSPC_MAP_0_3 (MAP v1.2) is supported, otherwise
+ excluded.
+C.10: Mandatory to support IF TSPC_MAP_0_3 (MAP v1.2) and TSPC_MAP_2_1
+ (Message Notification) is supported, otherwise excluded.
+-------------------------------------------------------------------------------
+
+
+ Supported features MSE
+-------------------------------------------------------------------------------
+Parameter Name Selected Description
+-------------------------------------------------------------------------------
+TSPC_MAP_3_1 True MSE: Message Notification (M)
+TSPC_MAP_3_1a True MSE: SendEvent (M)
+TSPC_MAP_3_2 True MSE: Message Browsing (M)
+TSPC_MAP_3_2a True MSE: SetFolder (M)
+TSPC_MAP_3_2b True MSE: GetFoldersListing (M)
+TSPC_MAP_3_2c True MSE: GetMessagesListing (M)
+TSPC_MAP_3_2d True MSE: GetMessage (M)
+TSPC_MAP_3_2e True MSE: SetMessageStatus (M)
+TSPC_MAP_3_2f True MSE: UpdateInbox (M)
+TSPC_MAP_3_2g False MSE: Multiple simultaneous MAS instances (O)
+TSPC_MAP_3_3 True MSE: Message Uploading (M)
+TSPC_MAP_3_3a True MSE: SetFolder (M)
+TSPC_MAP_3_3b True MSE: GetFoldersListing (M)
+TSPC_MAP_3_3c True MSE: PushMessage (M)
+TSPC_MAP_3_4 True MSE: Message Delete (M)
+TSPC_MAP_3_4a True MSE: SetMessageStatus (M)
+TSPC_MAP_3_5 True MSE: Notification Registration (M)
+TSPC_MAP_3_5a True MSE: SetNotificationRegistration (M)
+TSPC_MAP_3_6 False MSE: Supported Message Types
+TSPC_MAP_3_6a False MSE: EMAIL (C1)
+TSPC_MAP_3_6b True MSE: SMS_GSM (C1)
+TSPC_MAP_3_6c False MSE: SMS_CDMA (C1)
+TSPC_MAP_3_6d False (*) MSE: MMS (C1)
+TSPC_MAP_3_7 False MSE: Instance Information (Not Supported)
+TSPC_MAP_3_7a False (*) MSE: GetMASInstanceInformation (Not Supported)
+TSPC_MAP_3_8 False MSE: Extended MAP-Event-Report (Not Supported)
+TSPC_MAP_3_8a False (*) MSE: MAP-Event-Report: Version 1.1
+ (Not Supported)
+-------------------------------------------------------------------------------
+C.1: Mandatory to support at least one of the defined message types
+ TSPC_MAP_3_6a to TSPC_MAP_3_6d IF TSPC_MAP_3_2 or TSPC_MAP_3_3
+ is supported.
+C.2: Mandatory to support IF TSPC_MAP_0_3 (MAP v1.2) is supported,
+ otherwise excluded.
+-------------------------------------------------------------------------------
+
+
+ GOEP v2.0 or later Features
+-------------------------------------------------------------------------------
+Parameter Name Selected Description
+-------------------------------------------------------------------------------
+TSPC_MAP_7b_1 False GOEP v2.0 or later (C1)
+TSPC_MAP_7b_2 False GOEP v2 Backwards Compatibility (C1)
+TSPC_MAP_7b_3 False OBEX over L2CAP (C1)
+-------------------------------------------------------------------------------
+C.1: Mandatory if TSPC_MAP_0_3 (MAP v1.2) is supported else excluded.
+-------------------------------------------------------------------------------
+
+
+ MCE OBEX Header Support
+-------------------------------------------------------------------------------
+Parameter Name Selected Description
+-------------------------------------------------------------------------------
+TSPC_MAP_10_1 False (*) Name (M)
+TSPC_MAP_10_2 False (*) Typr (M)
+TSPC_MAP_10_3 False (*) Body (M)
+TSPC_MAP_10_4 False (*) End of Body (M)
+TSPC_MAP_10_5 False (*) Target (M)
+TSPC_MAP_10_6 False (*) Who (M)
+TSPC_MAP_10_7 False (*) Connection ID (M)
+TSPC_MAP_10_8 False (*) Application Parameters (M)
+TSPC_MAP_10_9 False SRM (C2)
+TSPC_MAP_10_10 False Receive SRMP (C2)
+TSPC_MAP_10_11 False Send SRMP (C2)
+-------------------------------------------------------------------------------
+C.1: Mandatory if TSPC_MAP_0_3 (MAP v1.2) is supported else excluded.
+C.2: Optional if TSPC_MAP_0_3 (MAP v1.2) is supported else excluded.
+-------------------------------------------------------------------------------
+
+
+ GetMessagesListing Filtering Parameter Support
+-------------------------------------------------------------------------------
+Parameter Name Selected Description
+-------------------------------------------------------------------------------
+TSPC_MAP_20_1 False (*) MCE: FilterMessageType (O)
+TSPC_MAP_20_2 False (*) MCE: FilterPeriodBegin (O)
+TSPC_MAP_20_3 False (*) MCE: FilterPeriodEnd (O)
+TSPC_MAP_20_4 False (*) MCE: FilterReadStatus (O)
+TSPC_MAP_20_5 False (*) MCE: FilterRecipient (O)
+TSPC_MAP_20_6 False (*) MCE: FilterOriginator (O)
+TSPC_MAP_20_7 False (*) MCE: FilterPriority (O)
+TSPC_ALL False (*) Turns on all the test cases
+-------------------------------------------------------------------------------
diff --git a/android/pixit-map.txt b/android/pixit-map.txt
new file mode 100644
index 0000000..c8e2591
--- /dev/null
+++ b/android/pixit-map.txt
@@ -0,0 +1,45 @@
+MAP PIXIT for the PTS tool.
+
+PTS version: 5.0
+
+* - different than PTS defaults
+& - should be set to IUT Bluetooth address
+
+ Required PIXIT settings
+-------------------------------------------------------------------------------
+Parameter Name Value
+-------------------------------------------------------------------------------
+TSPX_auth_password 0000
+TSPX_auth_user_id PTS
+TSPX_bd_addr_iut 08606E414394 (*&)
+TSPX_client_class_of_device 100204
+TSPX_delete_link_key FALSE
+TSPX_get_object_name put.gif
+TSPX_initial_path
+TSPX_l2cap_psm 1001
+TSPX_no_confirmations FALSE
+TSPX_pin_code 0000
+TSPX_rfcomm_channel 8
+TSPX_secure_simple_pairing_pass_key_confirmation FALSE
+TSPX_security_enabled TRUE
+TSPX_server_class_of_device 100204
+TSPX_time_guard 300000
+TSPX_use_implicit_send TRUE
+TSPX_Message_Access_rfcomm_channel 1
+TSPX_Message_Notification_rfcomm_channel 2
+TSPX_SPP_rfcomm_channel 03
+TSPX_filter_period_begin 20100101T000000
+TSPX_filter_period_end 20111231T125959
+TSPX_filter_recipient PTS
+TSPX_filter_originator PTS
+TSPX_default_message_upload_folder_in_msg draft
+TSPX_default_test_folder_in_msg inbox
+TSPX_use_fixed_MASInstanceID FALSE
+TSPX_MASInstanceID_SMS 0
+TSPX_MASInstanceID_MMS 0
+TSPX_MASInstanceID_Email 0
+TSPX_message_notification_l2cap_psm 1003
+TSPX_message_notification_rfcomm_channel 9
+TSPX_upload_msg_phonenumber 123456789
+TSPX_upload_msg_emailaddress PTS_Test@bluetooth.com
+-------------------------------------------------------------------------------
--
1.8.5
^ permalink raw reply related
* [PATCH 2/2] android/pts: Add PTS test results for MAP
From: Jakub Tyszkowski @ 2013-12-17 10:53 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1387277633-6008-1-git-send-email-jakub.tyszkowski@tieto.com>
Stock Bluedroid PTS results.
---
android/Makefile.am | 2 +-
android/pts-map.txt | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 94 insertions(+), 1 deletion(-)
create mode 100644 android/pts-map.txt
diff --git a/android/Makefile.am b/android/Makefile.am
index abeda84..909846e 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -123,4 +123,4 @@ EXTRA_DIST += android/Android.mk android/hal-ipc-api.txt android/README \
android/pixit-pbap.txt android/pts-gap.txt android/pts-hid.txt \
android/pts-opp.txt android/pts-pbap.txt \
android/audio-ipc-api.txt android/pics-map.txt \
- android/pixit-map.txt
+ android/pixit-map.txt android/pts-map.txt
diff --git a/android/pts-map.txt b/android/pts-map.txt
new file mode 100644
index 0000000..26702af
--- /dev/null
+++ b/android/pts-map.txt
@@ -0,0 +1,93 @@
+PTS test results for MAP
+
+PTS version: 5.0
+Tested: 17.12.2013
+
+Results:
+PASS test passed
+FAIL test failed
+INC test is inconclusive
+N/A test is disabled due to PICS setup
+
+-------------------------------------------------------------------------------
+Test Name Result Notes
+-------------------------------------------------------------------------------
+TC_MCE_MSM_BV_01_I N/A
+TC_MCE_MSM_BV_02_I N/A
+TC_MCE_MSM_BV_03_I N/A
+TC_MCE_MSM_BV_04_I N/A
+TC_MCE_MSM_BV_13_I N/A
+TC_MCE_MSM_BV_14_I N/A
+TC_MCE_MNR_BV_01_I N/A
+TC_MCE_MNR_BV_02_I N/A
+TC_MCE_MMB_BV_01_I N/A
+TC_MCE_MMB_BV_02_I N/A
+TC_MCE_MMB_BV_03_I N/A
+TC_MCE_MMB_BV_19_I N/A
+TC_MCE_MMB_BV_04_I N/A
+TC_MCE_MMB_BV_17_I N/A
+TC_MCE_MMB_BV_06_I N/A
+TC_MCE_MMB_BV_07_I N/A
+TC_MCE_MMB_BV_08_I N/A
+TC_MCE_MMD_BV_01_I N/A
+TC_MCE_MMU_BV_01_I N/A
+TC_MCE_MMN_BV_01_I N/A
+TC_MCE_MMN_BV_03_I N/A
+TC_MCE_MMI_BV_01_I N/A
+TC_MCE_MFB_BV_01_I N/A
+TC_MCE_MFB_BV_03_I N/A
+TC_MCE_MFB_BV_04_I N/A
+TC_MCE_BC_BV_02_I N/A
+TC_MCE_BC_BV_04_I N/A
+TC_MCE_CON_BV_01_I N/A
+TC_MCE_CON_BV_02_I N/A
+TC_MCE_ROB_BV_01_I N/A
+TC_MCE_SRM_BV_03_I N/A
+TC_MCE_SRM_BV_07_I N/A
+TC_MCE_SRMP_BI_01_I N/A
+TC_MCE_SRMP_BV_01_I N/A
+TC_MCE_SRMP_BV_04_I N/A
+TC_MCE_SRMP_BV_05_I N/A
+TC_MCE_SRMP_BV_06_I N/A
+TC_MSE_MSM_BV_05_I PASS
+TC_MSE_MSM_BV_06_I PASS
+TC_MSE_MSM_BV_07_I PASS
+TC_MSE_MSM_BV_08_I PASS
+TC_MSE_MSM_BV_09_I N/A
+TC_MSE_MSM_BV_10_I N/A
+TC_MSE_MSM_BV_11_I N/A
+TC_MSE_MSM_BV_12_I N/A
+TC_MSE_MNR_BV_03_I PASS
+TC_MSE_MNR_BV_04_I PASS
+TC_MSE_MMB_BV_09_I PASS
+TC_MSE_MMB_BV_10_I PASS
+TC_MSE_MMB_BV_11_I PASS
+TC_MSE_MMB_BV_20_I PASS
+TC_MSE_MMB_BV_12_I N/A
+TC_MSE_MMB_BV_18_I N/A
+TC_MSE_MMB_BV_13_I PASS
+TC_MSE_MMB_BV_14_I PASS
+TC_MSE_MMB_BV_15_I PASS
+TC_MSE_MMB_BV_16_I INC Mailbox MAS instance not available on IUT.
+TC_MSE_MMD_BV_02_I PASS
+TC_MSE_MMU_BV_02_I PASS
+TC_MSE_MMU_BV_03_I PASS
+TC_MSE_MMN_BV_02_I PASS
+TC_MSE_MMN_BV_04_I N/A
+TC_MSE_MMI_BV_02_I N/A
+TC_MSE_MFB_BV_02_I N/A
+TC_MSE_MFB_BV_05_I N/A
+TC_MSE_BC_BV_01_I N/A
+TC_MSE_BC_BV_03_I N/A
+TC_MSE_CON_BV_01_I N/A
+TC_MSE_CON_BV_02_I N/A
+TC_MSE_ROB_BV_01_I N/A
+TC_MSE_SRM_BI_02_I N/A
+TC_MSE_SRM_BI_03_I N/A
+TC_MSE_SRM_BI_05_I N/A
+TC_MSE_SRM_BV_04_I N/A
+TC_MSE_SRM_BV_08_I N/A
+TC_MSE_SRMP_BI_02_I N/A
+TC_MSE_SRMP_BV_02_I N/A
+TC_MSE_SRMP_BV_03_I N/A
+-------------------------------------------------------------------------------
--
1.8.5
^ permalink raw reply related
* Re: [PATCH v2 bluetooth-next 1/7] 6lowpan: fix udp nullpointer dereferencing
From: Anderson Lizardo @ 2013-12-17 10:58 UTC (permalink / raw)
To: Alexander Aring; +Cc: linux-zigbee-devel, werner, BlueZ development
In-Reply-To: <1387276373-23882-2-git-send-email-alex.aring@gmail.com>
Hi Alexander,
On Tue, Dec 17, 2013 at 6:32 AM, Alexander Aring <alex.aring@gmail.com> wrote:
> Sometimes a nullpointer dereferencing occurs because of using a wrong
> pointer arithmetic in udp_uncompression.
>
> This patch changes "**(hc06_ptr + 3)" to the right one "*(*hc06_ptr +
> 3)". Dereferencing like "**(hc06_ptr + 3)" works in a random case only.
And why not use hc06_ptr[0][3] ? IMHO it is more readable and the
arithmetic is the same (as far as I know).
Best Regards,
--
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
^ permalink raw reply
* Re: [PATCH v2 bluetooth-next 1/7] 6lowpan: fix udp nullpointer dereferencing
From: Alexander Aring @ 2013-12-17 11:06 UTC (permalink / raw)
To: Anderson Lizardo; +Cc: linux-zigbee-devel, werner, BlueZ development
In-Reply-To: <CAJdJm_MC7DOYZ_nf-Sv6c61s0X-i2yY-7chgd5gA9ScFvVkRBg@mail.gmail.com>
On Tue, Dec 17, 2013 at 06:58:12AM -0400, Anderson Lizardo wrote:
> Hi Alexander,
>
> On Tue, Dec 17, 2013 at 6:32 AM, Alexander Aring <alex.aring@gmail.com> wrote:
> > Sometimes a nullpointer dereferencing occurs because of using a wrong
> > pointer arithmetic in udp_uncompression.
> >
> > This patch changes "**(hc06_ptr + 3)" to the right one "*(*hc06_ptr +
> > 3)". Dereferencing like "**(hc06_ptr + 3)" works in a random case only.
>
> And why not use hc06_ptr[0][3] ? IMHO it is more readable and the
> arithmetic is the same (as far as I know).
>
mhh maybe we change it to *hc06_ptr[3] ? Otherwise we have always
something like [0][#] for access.
- Alex
^ permalink raw reply
* [PATCH] Bluetooth: Fix HCI User Channel permission check in hci_sock_sendmsg
From: Marcel Holtmann @ 2013-12-17 11:21 UTC (permalink / raw)
To: linux-bluetooth
The HCI User Channel is an admin operation which enforces CAP_NET_ADMIN
when binding the socket. Problem now is that it then requires also
CAP_NET_RAW when calling into hci_sock_sendmsg. This is not intended
and just an oversight since general HCI sockets (which do not require
special permission to bind) and HCI User Channel share the same code
path here.
Remove the extra CAP_NET_RAW check for HCI User Channel write operation
since the permission check has already been enforced when binding the
socket. This also makes it possible to open HCI User Channel from a
privileged process and then hand the file descriptor to an unprivilged
process.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
net/bluetooth/hci_sock.c | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index 6a6c8bb4fd72..7552f9e3089c 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -940,8 +940,22 @@ static int hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
bt_cb(skb)->pkt_type = *((unsigned char *) skb->data);
skb_pull(skb, 1);
- if (hci_pi(sk)->channel == HCI_CHANNEL_RAW &&
- bt_cb(skb)->pkt_type == HCI_COMMAND_PKT) {
+ if (hci_pi(sk)->channel == HCI_CHANNEL_USER) {
+ /* No permission check is needed for user channel
+ * since that gets enforced when binding the socket.
+ *
+ * However check that the packet type is valid.
+ */
+ if (bt_cb(skb)->pkt_type != HCI_COMMAND_PKT &&
+ bt_cb(skb)->pkt_type != HCI_ACLDATA_PKT &&
+ bt_cb(skb)->pkt_type != HCI_SCODATA_PKT) {
+ err = -EINVAL;
+ goto drop;
+ }
+
+ skb_queue_tail(&hdev->raw_q, skb);
+ queue_work(hdev->workqueue, &hdev->tx_work);
+ } else if (bt_cb(skb)->pkt_type == HCI_COMMAND_PKT) {
u16 opcode = get_unaligned_le16(skb->data);
u16 ogf = hci_opcode_ogf(opcode);
u16 ocf = hci_opcode_ocf(opcode);
@@ -972,14 +986,6 @@ static int hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
goto drop;
}
- if (hci_pi(sk)->channel == HCI_CHANNEL_USER &&
- bt_cb(skb)->pkt_type != HCI_COMMAND_PKT &&
- bt_cb(skb)->pkt_type != HCI_ACLDATA_PKT &&
- bt_cb(skb)->pkt_type != HCI_SCODATA_PKT) {
- err = -EINVAL;
- goto drop;
- }
-
skb_queue_tail(&hdev->raw_q, skb);
queue_work(hdev->workqueue, &hdev->tx_work);
}
--
1.8.3.1
^ permalink raw reply related
* Re: [PATCH v2 bluetooth-next 1/7] 6lowpan: fix udp nullpointer dereferencing
From: Alexander Aring @ 2013-12-17 11:25 UTC (permalink / raw)
To: Anderson Lizardo; +Cc: linux-zigbee-devel, werner, BlueZ development
In-Reply-To: <20131217110601.GA21663@omega>
On Tue, Dec 17, 2013 at 12:06:01PM +0100, Alexander Aring wrote:
> On Tue, Dec 17, 2013 at 06:58:12AM -0400, Anderson Lizardo wrote:
> > Hi Alexander,
> >
> > On Tue, Dec 17, 2013 at 6:32 AM, Alexander Aring <alex.aring@gmail.com> wrote:
> > > Sometimes a nullpointer dereferencing occurs because of using a wrong
> > > pointer arithmetic in udp_uncompression.
> > >
> > > This patch changes "**(hc06_ptr + 3)" to the right one "*(*hc06_ptr +
> > > 3)". Dereferencing like "**(hc06_ptr + 3)" works in a random case only.
> >
> > And why not use hc06_ptr[0][3] ? IMHO it is more readable and the
> > arithmetic is the same (as far as I know).
> >
>
> mhh maybe we change it to *hc06_ptr[3] ? Otherwise we have always
> something like [0][#] for access.
>
meant (*hc06_ptr)[3] here, but I have a better idea to add a function
wich sets some data and increment it automatically. Will send v3 with
that soon.
- Alex
^ permalink raw reply
* Re: [PATCH 1/2] android/pts: Add PTS PICS and PIXIT for MAP
From: Luiz Augusto von Dentz @ 2013-12-17 11:38 UTC (permalink / raw)
To: Jakub Tyszkowski; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1387277633-6008-1-git-send-email-jakub.tyszkowski@tieto.com>
Hi Jakub,
On Tue, Dec 17, 2013 at 12:53 PM, Jakub Tyszkowski
<jakub.tyszkowski@tieto.com> wrote:
> Add PICS and PIXIT targetting Android 4.4 and PTS version 5.0.
> ---
> android/Makefile.am | 3 +-
> android/pics-map.txt | 175 ++++++++++++++++++++++++++++++++++++++++++++++++++
> android/pixit-map.txt | 45 +++++++++++++
> 3 files changed, 222 insertions(+), 1 deletion(-)
> create mode 100644 android/pics-map.txt
> create mode 100644 android/pixit-map.txt
>
> diff --git a/android/Makefile.am b/android/Makefile.am
> index 0034487..abeda84 100644
> --- a/android/Makefile.am
> +++ b/android/Makefile.am
> @@ -122,4 +122,5 @@ EXTRA_DIST += android/Android.mk android/hal-ipc-api.txt android/README \
> android/pixit-opp.txt android/pixit-pan.txt \
> android/pixit-pbap.txt android/pts-gap.txt android/pts-hid.txt \
> android/pts-opp.txt android/pts-pbap.txt \
> - android/audio-ipc-api.txt
> + android/audio-ipc-api.txt android/pics-map.txt \
> + android/pixit-map.txt
> diff --git a/android/pics-map.txt b/android/pics-map.txt
> new file mode 100644
> index 0000000..2875885
> --- /dev/null
> +++ b/android/pics-map.txt
> @@ -0,0 +1,175 @@
> +MAP PICS for the PTS tool.
> +
> +PTS version: 5.0
> +
> +* - different than PTS defaults
> +# - not yet implemented/supported
> +
> +M - mandatory
> +O - optional
> +
> + Profile Version
> +-------------------------------------------------------------------------------
> +Parameter Name Selected Description
> +-------------------------------------------------------------------------------
> +TSPC_MAP_0_1 False Role: Map 1.0 (C1)
> +TSPC_MAP_0_2 True (*) Role: Map 1.1 (C1)
> +TSPC_MAP_0_3 False Role: Map 1.2 (C1)
> +-------------------------------------------------------------------------------
> +C.1: Mandatory to support only one Profile version.
> +-------------------------------------------------------------------------------
> +
> +
> + Roles
> +-------------------------------------------------------------------------------
> +Parameter Name Selected Description
> +-------------------------------------------------------------------------------
> +TSPC_MAP_1_1 True (*) Role: Messaging Server Equipment (C1)
> +TSPC_MAP_1_2 False Role: Messaging Client Equipment (C1)
> +-------------------------------------------------------------------------------
> +C.1: It is mandatory to support at least one of the defined roles.
> +-------------------------------------------------------------------------------
> +
> +
> + Supported features MCE
> +-------------------------------------------------------------------------------
> +Parameter Name Selected Description
> +-------------------------------------------------------------------------------
> +TSPC_MAP_2_1 False MCE: Message Notification (C1)
> +TSPC_MAP_2_1a False MCE: SendEvent (C4)
> +TSPC_MAP_2_2 False MCE: Message Browsing (C1)
> +TSPC_MAP_2_2a False MCE: SetFolder (C5)
> +TSPC_MAP_2_2b False MCE: GetFoldersListing (C5)
> +TSPC_MAP_2_2c False MCE: GetMessagesListing (C5)
> +TSPC_MAP_2_2d False MCE: GetMessage (O)
> +TSPC_MAP_2_2e False MCE: SetMessageStatus (O)
> +TSPC_MAP_2_2f False MCE: UpdateInbox (O)
> +TSPC_MAP_2_2g False MCE: Filtering (O)
> +TSPC_MAP_2_2h False MCE: Multiple simultaneous MAS instances (O)
> +TSPC_MAP_2_3 False MCE: Message Uploading (O)
> +TSPC_MAP_2_3a False MCE: SetFolder (C6)
> +TSPC_MAP_2_3b False MCE: GetFoldersListing (C6)
> +TSPC_MAP_2_3c False MCE: PushMessage (C6)
> +TSPC_MAP_2_4 False MCE: Message Delete (O)
> +TSPC_MAP_2_4a False MCE: SetMessageStatus (C7)
> +TSPC_MAP_2_5 False MCE: Notification Registration (C2)
> +TSPC_MAP_2_5a False MCE: SetNotificationRegistration off (O)
> +TSPC_MAP_2_5b False MCE: SetNotificationRegistration on (C8)
> +TSPC_MAP_2_6 False MCE: Supported Message Types
> +TSPC_MAP_2_6a False (*) MCE: EMAIL (C3)
> +TSPC_MAP_2_6b False (*) MCE: SMS_GSM (C3)
> +TSPC_MAP_2_6c False (*) MCE: SMS_CDMA (C3)
> +TSPC_MAP_2_6d False (*) MCE: MMS (C3)
> +TSPC_MAP_2_7 False MCE: Instance Information (Not Supported)
> +TSPC_MAP_2_7a False (*) MCE: GetMASInstanceInformation (Not Supported)
> +TSPC_MAP_2_8 False MCE: Extended MAP-Event-Report (Not Supported)
> +TSPC_MAP_2_8a False (*) MCE: MAP-Event-Report: Version 1.1
> + (Not Supported)
> +-------------------------------------------------------------------------------
> +C.1: Mandatory to support at least one of the defined features TSPC_MAP_2_1 or
> + TSPC_MAP_2_2.
> +C.2: Mandatory to support TSPC_MAP_2_5 if TSPC_MAP_2_1 is supported.
> +C.3: Mandatory to support at least one of the defined message types
> + TSPC_MAP_2_6a to TSPC_MAP_2_6d IF TSPC_MAP_2_2 or TSPC_MAP_2_3 is
> + supported.
> +C.4: Support of functionality TSPC_MAP_2_1a mandatory IF related feature
> + TSPC_MAP_2_1 supported.
> +C.5: Support of functionality mandatory IF TSPC_MAP_2_2 supported.
> +C.6: Support of functionality mandatory IF TSPC_MAP_2_3 supported.
> +C.7: Support of functionality mandatory IF TSPC_MAP_2_4 supported.
> +C.8: Mandatory to support IF TSPC_MAP_2_5 (Notification Registration) is
> + supported, otherwise excluded.
> +C.9: Optional to support IF TSPC_MAP_0_3 (MAP v1.2) is supported, otherwise
> + excluded.
> +C.10: Mandatory to support IF TSPC_MAP_0_3 (MAP v1.2) and TSPC_MAP_2_1
> + (Message Notification) is supported, otherwise excluded.
> +-------------------------------------------------------------------------------
> +
> +
> + Supported features MSE
> +-------------------------------------------------------------------------------
> +Parameter Name Selected Description
> +-------------------------------------------------------------------------------
> +TSPC_MAP_3_1 True MSE: Message Notification (M)
> +TSPC_MAP_3_1a True MSE: SendEvent (M)
> +TSPC_MAP_3_2 True MSE: Message Browsing (M)
> +TSPC_MAP_3_2a True MSE: SetFolder (M)
> +TSPC_MAP_3_2b True MSE: GetFoldersListing (M)
> +TSPC_MAP_3_2c True MSE: GetMessagesListing (M)
> +TSPC_MAP_3_2d True MSE: GetMessage (M)
> +TSPC_MAP_3_2e True MSE: SetMessageStatus (M)
> +TSPC_MAP_3_2f True MSE: UpdateInbox (M)
> +TSPC_MAP_3_2g False MSE: Multiple simultaneous MAS instances (O)
> +TSPC_MAP_3_3 True MSE: Message Uploading (M)
> +TSPC_MAP_3_3a True MSE: SetFolder (M)
> +TSPC_MAP_3_3b True MSE: GetFoldersListing (M)
> +TSPC_MAP_3_3c True MSE: PushMessage (M)
> +TSPC_MAP_3_4 True MSE: Message Delete (M)
> +TSPC_MAP_3_4a True MSE: SetMessageStatus (M)
> +TSPC_MAP_3_5 True MSE: Notification Registration (M)
> +TSPC_MAP_3_5a True MSE: SetNotificationRegistration (M)
> +TSPC_MAP_3_6 False MSE: Supported Message Types
> +TSPC_MAP_3_6a False MSE: EMAIL (C1)
> +TSPC_MAP_3_6b True MSE: SMS_GSM (C1)
> +TSPC_MAP_3_6c False MSE: SMS_CDMA (C1)
> +TSPC_MAP_3_6d False (*) MSE: MMS (C1)
> +TSPC_MAP_3_7 False MSE: Instance Information (Not Supported)
> +TSPC_MAP_3_7a False (*) MSE: GetMASInstanceInformation (Not Supported)
> +TSPC_MAP_3_8 False MSE: Extended MAP-Event-Report (Not Supported)
> +TSPC_MAP_3_8a False (*) MSE: MAP-Event-Report: Version 1.1
> + (Not Supported)
> +-------------------------------------------------------------------------------
> +C.1: Mandatory to support at least one of the defined message types
> + TSPC_MAP_3_6a to TSPC_MAP_3_6d IF TSPC_MAP_3_2 or TSPC_MAP_3_3
> + is supported.
> +C.2: Mandatory to support IF TSPC_MAP_0_3 (MAP v1.2) is supported,
> + otherwise excluded.
> +-------------------------------------------------------------------------------
> +
> +
> + GOEP v2.0 or later Features
> +-------------------------------------------------------------------------------
> +Parameter Name Selected Description
> +-------------------------------------------------------------------------------
> +TSPC_MAP_7b_1 False GOEP v2.0 or later (C1)
> +TSPC_MAP_7b_2 False GOEP v2 Backwards Compatibility (C1)
> +TSPC_MAP_7b_3 False OBEX over L2CAP (C1)
> +-------------------------------------------------------------------------------
> +C.1: Mandatory if TSPC_MAP_0_3 (MAP v1.2) is supported else excluded.
> +-------------------------------------------------------------------------------
> +
> +
> + MCE OBEX Header Support
> +-------------------------------------------------------------------------------
> +Parameter Name Selected Description
> +-------------------------------------------------------------------------------
> +TSPC_MAP_10_1 False (*) Name (M)
> +TSPC_MAP_10_2 False (*) Typr (M)
> +TSPC_MAP_10_3 False (*) Body (M)
> +TSPC_MAP_10_4 False (*) End of Body (M)
> +TSPC_MAP_10_5 False (*) Target (M)
> +TSPC_MAP_10_6 False (*) Who (M)
> +TSPC_MAP_10_7 False (*) Connection ID (M)
> +TSPC_MAP_10_8 False (*) Application Parameters (M)
> +TSPC_MAP_10_9 False SRM (C2)
> +TSPC_MAP_10_10 False Receive SRMP (C2)
> +TSPC_MAP_10_11 False Send SRMP (C2)
> +-------------------------------------------------------------------------------
> +C.1: Mandatory if TSPC_MAP_0_3 (MAP v1.2) is supported else excluded.
> +C.2: Optional if TSPC_MAP_0_3 (MAP v1.2) is supported else excluded.
> +-------------------------------------------------------------------------------
> +
> +
> + GetMessagesListing Filtering Parameter Support
> +-------------------------------------------------------------------------------
> +Parameter Name Selected Description
> +-------------------------------------------------------------------------------
> +TSPC_MAP_20_1 False (*) MCE: FilterMessageType (O)
> +TSPC_MAP_20_2 False (*) MCE: FilterPeriodBegin (O)
> +TSPC_MAP_20_3 False (*) MCE: FilterPeriodEnd (O)
> +TSPC_MAP_20_4 False (*) MCE: FilterReadStatus (O)
> +TSPC_MAP_20_5 False (*) MCE: FilterRecipient (O)
> +TSPC_MAP_20_6 False (*) MCE: FilterOriginator (O)
> +TSPC_MAP_20_7 False (*) MCE: FilterPriority (O)
> +TSPC_ALL False (*) Turns on all the test cases
> +-------------------------------------------------------------------------------
> diff --git a/android/pixit-map.txt b/android/pixit-map.txt
> new file mode 100644
> index 0000000..c8e2591
> --- /dev/null
> +++ b/android/pixit-map.txt
> @@ -0,0 +1,45 @@
> +MAP PIXIT for the PTS tool.
> +
> +PTS version: 5.0
> +
> +* - different than PTS defaults
> +& - should be set to IUT Bluetooth address
> +
> + Required PIXIT settings
> +-------------------------------------------------------------------------------
> +Parameter Name Value
> +-------------------------------------------------------------------------------
> +TSPX_auth_password 0000
> +TSPX_auth_user_id PTS
> +TSPX_bd_addr_iut 08606E414394 (*&)
> +TSPX_client_class_of_device 100204
> +TSPX_delete_link_key FALSE
> +TSPX_get_object_name put.gif
> +TSPX_initial_path
> +TSPX_l2cap_psm 1001
> +TSPX_no_confirmations FALSE
> +TSPX_pin_code 0000
> +TSPX_rfcomm_channel 8
> +TSPX_secure_simple_pairing_pass_key_confirmation FALSE
> +TSPX_security_enabled TRUE
> +TSPX_server_class_of_device 100204
> +TSPX_time_guard 300000
> +TSPX_use_implicit_send TRUE
> +TSPX_Message_Access_rfcomm_channel 1
> +TSPX_Message_Notification_rfcomm_channel 2
> +TSPX_SPP_rfcomm_channel 03
> +TSPX_filter_period_begin 20100101T000000
> +TSPX_filter_period_end 20111231T125959
> +TSPX_filter_recipient PTS
> +TSPX_filter_originator PTS
> +TSPX_default_message_upload_folder_in_msg draft
> +TSPX_default_test_folder_in_msg inbox
> +TSPX_use_fixed_MASInstanceID FALSE
> +TSPX_MASInstanceID_SMS 0
> +TSPX_MASInstanceID_MMS 0
> +TSPX_MASInstanceID_Email 0
> +TSPX_message_notification_l2cap_psm 1003
> +TSPX_message_notification_rfcomm_channel 9
> +TSPX_upload_msg_phonenumber 123456789
> +TSPX_upload_msg_emailaddress PTS_Test@bluetooth.com
> +-------------------------------------------------------------------------------
> --
> 1.8.5
Applied, thanks.
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [PATCH] Bluetooth: Fix HCI User Channel permission check in hci_sock_sendmsg
From: Johan Hedberg @ 2013-12-17 11:50 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1387279285-60237-1-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Tue, Dec 17, 2013, Marcel Holtmann wrote:
> The HCI User Channel is an admin operation which enforces CAP_NET_ADMIN
> when binding the socket. Problem now is that it then requires also
> CAP_NET_RAW when calling into hci_sock_sendmsg. This is not intended
> and just an oversight since general HCI sockets (which do not require
> special permission to bind) and HCI User Channel share the same code
> path here.
>
> Remove the extra CAP_NET_RAW check for HCI User Channel write operation
> since the permission check has already been enforced when binding the
> socket. This also makes it possible to open HCI User Channel from a
> privileged process and then hand the file descriptor to an unprivilged
> process.
>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> ---
> net/bluetooth/hci_sock.c | 26 ++++++++++++++++----------
> 1 file changed, 16 insertions(+), 10 deletions(-)
Applied to bluetooth.git. Thanks.
Johan
^ permalink raw reply
* [PATCH BlueZ] build: Add coverage support
From: Luiz Augusto von Dentz @ 2013-12-17 12:25 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Coverage is enabled with --enable-maintainer-mode, 2 new targets are
added 'coverage' and 'clean-coverage', the first generate the reports
using lcov and depend on the second to cleanup previous generated
reports and .gcda files.
---
.gitignore | 4 ++++
Makefile.am | 18 ++++++++++++++++++
acinclude.m4 | 4 ++++
configure.ac | 4 ++++
4 files changed, 30 insertions(+)
diff --git a/.gitignore b/.gitignore
index c570728..21dbe26 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,8 @@
*.lo
*.la
*.so
+*.gcno
+*.gcda
.deps
.libs
.dirstamp
@@ -27,7 +29,9 @@ stamp-h1
autom4te.cache
test-driver
test-suite.log
+coverage.info
+coverage
lib/bluez.pc
lib/bluetooth
src/builtin.h
diff --git a/Makefile.am b/Makefile.am
index 15cc149..337d849 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -331,5 +331,23 @@ lib/bluetooth/%.h: lib/%.h
$(AM_V_at)$(MKDIR_P) lib/bluetooth
$(AM_V_GEN)$(LN_S) -f "$(abs_top_builddir)"/$< $@
+if MAINTAINER_MODE
+clean-coverage:
+ -find $(top_builddir) -name "*.gcda" -delete
+ @lcov --directory $(top_builddir) --zerocounters
+ $(RM) -r coverage
+
+coverage: clean-coverage check
+ @lcov --compat-libtool --directory $(top_builddir) --capture \
+ --output-file $(top_builddir)/coverage.info
+ $(AM_V_at)$(MKDIR_P) -p coverage
+ @genhtml -o coverage/ $(top_builddir)/coverage.info
+
+clean-local: clean-coverage
+ -find $(top_builddir) -name "*.gcno" -delete
+ $(RM) -r lib/bluetooth
+
+else
clean-local:
$(RM) -r lib/bluetooth
+endif
diff --git a/acinclude.m4 b/acinclude.m4
index 2065852..afc7c6d 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -51,6 +51,10 @@ AC_DEFUN([MISC_FLAGS], [
misc_ldflags="$misc_ldflags -pie"
fi
])
+ if (test "$USE_MAINTAINER_MODE" = "yes"); then
+ misc_cflags="$misc_cflags --coverage"
+ misc_ldflags="$misc_ldflags --coverage"
+ fi
AC_SUBST([MISC_CFLAGS], $misc_cflags)
AC_SUBST([MISC_LDFLAGS], $misc_ldflags)
])
diff --git a/configure.ac b/configure.ac
index 18d0b55..4f36355 100644
--- a/configure.ac
+++ b/configure.ac
@@ -252,4 +252,8 @@ AC_ARG_ENABLE(android, AC_HELP_STRING([--enable-android],
[enable_android=${enableval}])
AM_CONDITIONAL(ANDROID, test "${enable_android}" = "yes")
+if (test "$USE_MAINTAINER_MODE" = "yes"); then
+ AC_CHECK_PROG([LCOV], [lcov], [yes], AC_MSG_ERROR(lcov is required))
+fi
+
AC_OUTPUT(Makefile src/bluetoothd.8 lib/bluez.pc)
--
1.8.3.1
^ permalink raw reply related
* [PATCH 1/7] android/tester: Fix enum and define coding style
From: Grzegorz Kolodziejczyk @ 2013-12-17 12:37 UTC (permalink / raw)
To: linux-bluetooth
This changes all enums values and defines to uppercase instead of
lowercase according to coding style.
---
android/android-tester.c | 86 ++++++++++++++++++++++++------------------------
1 file changed, 43 insertions(+), 43 deletions(-)
diff --git a/android/android-tester.c b/android/android-tester.c
index eb938d0..4eb265b 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -37,10 +37,10 @@
#include <hardware/bluetooth.h>
#include <hardware/bt_sock.h>
-#define adapter_props adapter_prop_bdaddr, adapter_prop_bdname, \
- adapter_prop_uuids, adapter_prop_cod, \
- adapter_prop_type, adapter_prop_scan_mode, \
- adapter_prop_bonded_devices, adapter_prop_disc_timeout
+#define ADAPTER_PROPS ADAPTER_PROP_BDADDR, ADAPTER_PROP_BDNAME, \
+ ADAPTER_PROP_UUIDS, ADAPTER_PROP_COD, \
+ ADAPTER_PROP_TYPE, ADAPTER_PROP_SCAN_MODE, \
+ ADAPTER_PROP_BONDED_DEVICES, ADAPTER_PROP_DISC_TIMEOUT
static bt_scan_mode_t test_setprop_scanmode_val =
BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE;
@@ -52,19 +52,19 @@ static uint32_t test_setprop_disctimeout_val = 120;
*/
enum hal_bluetooth_callbacks_id {
- adapter_test_end,
- adapter_test_setup_mode,
- adapter_state_changed_on,
- adapter_state_changed_off,
- adapter_prop_bdaddr,
- adapter_prop_bdname,
- adapter_prop_uuids,
- adapter_prop_cod,
- adapter_prop_type,
- adapter_prop_scan_mode,
- adapter_prop_disc_timeout,
- adapter_prop_service_record,
- adapter_prop_bonded_devices
+ ADAPTER_TEST_END,
+ ADAPTER_TEST_SETUP_MODE,
+ ADAPTER_STATE_CHANGED_ON,
+ ADAPTER_STATE_CHANGED_OFF,
+ ADAPTER_PROP_BDADDR,
+ ADAPTER_PROP_BDNAME,
+ ADAPTER_PROP_UUIDS,
+ ADAPTER_PROP_COD,
+ ADAPTER_PROP_TYPE,
+ ADAPTER_PROP_SCAN_MODE,
+ ADAPTER_PROP_DISC_TIMEOUT,
+ ADAPTER_PROP_SERVICE_RECORD,
+ ADAPTER_PROP_BONDED_DEVICES
};
struct generic_data {
@@ -250,7 +250,7 @@ static int get_expected_hal_cb(void)
struct test_data *data = tester_get_data();
if (!(g_slist_length(data->expected_callbacks)))
- return adapter_test_setup_mode;
+ return ADAPTER_TEST_SETUP_MODE;
return GPOINTER_TO_INT(data->expected_callbacks->data);
}
@@ -470,19 +470,19 @@ static void adapter_state_changed_cb(bt_state_t state)
hal_cb = get_expected_hal_cb();
switch (hal_cb) {
- case adapter_state_changed_on:
+ case ADAPTER_STATE_CHANGED_ON:
if (state == BT_STATE_ON)
remove_expected_hal_cb();
else
tester_test_failed();
break;
- case adapter_state_changed_off:
+ case ADAPTER_STATE_CHANGED_OFF:
if (state == BT_STATE_OFF)
remove_expected_hal_cb();
else
tester_test_failed();
break;
- case adapter_test_setup_mode:
+ case ADAPTER_TEST_SETUP_MODE:
if (state == BT_STATE_ON)
tester_setup_complete();
else
@@ -502,50 +502,50 @@ static void adapter_properties_cb(bt_status_t status, int num_properties,
for (i = 0; i < num_properties; i++) {
hal_cb = get_expected_hal_cb();
- if (hal_cb == adapter_test_setup_mode)
+ if (hal_cb == ADAPTER_TEST_SETUP_MODE)
break;
data->test_property = *properties;
if (g_slist_next(data->expected_callbacks) ==
- adapter_test_end)
+ ADAPTER_TEST_END)
check_test_property();
switch (properties[i].type) {
case BT_PROPERTY_BDADDR:
- if (hal_cb != adapter_prop_bdaddr)
+ if (hal_cb != ADAPTER_PROP_BDADDR)
goto fail;
break;
case BT_PROPERTY_BDNAME:
- if (hal_cb != adapter_prop_bdname)
+ if (hal_cb != ADAPTER_PROP_BDNAME)
goto fail;
break;
case BT_PROPERTY_UUIDS:
- if (hal_cb != adapter_prop_uuids)
+ if (hal_cb != ADAPTER_PROP_UUIDS)
goto fail;
break;
case BT_PROPERTY_CLASS_OF_DEVICE:
- if (hal_cb != adapter_prop_cod)
+ if (hal_cb != ADAPTER_PROP_COD)
goto fail;
break;
case BT_PROPERTY_TYPE_OF_DEVICE:
- if (hal_cb != adapter_prop_type)
+ if (hal_cb != ADAPTER_PROP_TYPE)
goto fail;
break;
case BT_PROPERTY_SERVICE_RECORD:
- if (hal_cb != adapter_prop_service_record)
+ if (hal_cb != ADAPTER_PROP_SERVICE_RECORD)
goto fail;
break;
case BT_PROPERTY_ADAPTER_SCAN_MODE:
- if (hal_cb != adapter_prop_scan_mode)
+ if (hal_cb != ADAPTER_PROP_SCAN_MODE)
goto fail;
break;
case BT_PROPERTY_ADAPTER_BONDED_DEVICES:
- if (hal_cb != adapter_prop_bonded_devices)
+ if (hal_cb != ADAPTER_PROP_BONDED_DEVICES)
goto fail;
break;
case BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT:
- if (hal_cb != adapter_prop_disc_timeout)
+ if (hal_cb != ADAPTER_PROP_DISC_TIMEOUT)
goto fail;
break;
default:
@@ -563,21 +563,21 @@ fail:
}
static const struct generic_data bluetooth_enable_success_test = {
- .expected_hal_callbacks = {adapter_props, adapter_state_changed_on,
- adapter_test_end}
+ .expected_hal_callbacks = {ADAPTER_PROPS, ADAPTER_STATE_CHANGED_ON,
+ ADAPTER_TEST_END}
};
static const struct generic_data bluetooth_enable_done_test = {
- .expected_hal_callbacks = {adapter_props, adapter_test_end},
+ .expected_hal_callbacks = {ADAPTER_PROPS, ADAPTER_TEST_END},
.expected_adapter_status = BT_STATUS_DONE
};
static const struct generic_data bluetooth_disable_success_test = {
- .expected_hal_callbacks = {adapter_state_changed_off, adapter_test_end}
+ .expected_hal_callbacks = {ADAPTER_STATE_CHANGED_OFF, ADAPTER_TEST_END}
};
static const struct generic_data bluetooth_setprop_bdname_success_test = {
- .expected_hal_callbacks = {adapter_prop_bdname, adapter_test_end},
+ .expected_hal_callbacks = {ADAPTER_PROP_BDNAME, ADAPTER_TEST_END},
.expected_adapter_status = BT_STATUS_SUCCESS,
.expected_property.type = BT_PROPERTY_BDNAME,
.expected_property.val = "test_bdname",
@@ -585,8 +585,8 @@ static const struct generic_data bluetooth_setprop_bdname_success_test = {
};
static const struct generic_data bluetooth_setprop_scanmode_success_test = {
- .expected_hal_callbacks = {adapter_prop_scan_mode,
- adapter_prop_scan_mode, adapter_test_end},
+ .expected_hal_callbacks = {ADAPTER_PROP_SCAN_MODE,
+ ADAPTER_PROP_SCAN_MODE, ADAPTER_TEST_END},
.expected_adapter_status = BT_STATUS_SUCCESS,
.expected_property.type = BT_PROPERTY_ADAPTER_SCAN_MODE,
.expected_property.val = &test_setprop_scanmode_val,
@@ -594,7 +594,7 @@ static const struct generic_data bluetooth_setprop_scanmode_success_test = {
};
static const struct generic_data bluetooth_setprop_disctimeout_success_test = {
- .expected_hal_callbacks = {adapter_prop_disc_timeout, adapter_test_end},
+ .expected_hal_callbacks = {ADAPTER_PROP_DISC_TIMEOUT, ADAPTER_TEST_END},
.expected_adapter_status = BT_STATUS_SUCCESS,
.expected_property.type = BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
.expected_property.val = &test_setprop_disctimeout_val,
@@ -602,7 +602,7 @@ static const struct generic_data bluetooth_setprop_disctimeout_success_test = {
};
static const struct generic_data bluetooth_getprop_bdaddr_success_test = {
- .expected_hal_callbacks = {adapter_prop_bdaddr, adapter_test_end},
+ .expected_hal_callbacks = {ADAPTER_PROP_BDADDR, ADAPTER_TEST_END},
.expected_adapter_status = BT_STATUS_SUCCESS,
.expected_property.type = BT_PROPERTY_BDADDR,
.expected_property.val = NULL,
@@ -610,8 +610,8 @@ static const struct generic_data bluetooth_getprop_bdaddr_success_test = {
};
static const struct generic_data bluetooth_getprop_bdname_success_test = {
- .expected_hal_callbacks = {adapter_prop_bdname, adapter_prop_bdname,
- adapter_test_end},
+ .expected_hal_callbacks = {ADAPTER_PROP_BDNAME, ADAPTER_PROP_BDNAME,
+ ADAPTER_TEST_END},
.expected_adapter_status = BT_STATUS_SUCCESS,
.expected_property.type = BT_PROPERTY_BDNAME,
.expected_property.val = "test_bdname_setget",
--
1.8.4.2
^ permalink raw reply related
* [PATCH 2/7] android/tester: Check adapter cb irrespective of receiving order
From: Grzegorz Kolodziejczyk @ 2013-12-17 12:37 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1387283874-29721-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>
This patch change checking of expected callbacks from static order to
dynamic. For example properties can be received in different order
than now.
---
android/android-tester.c | 100 ++++++++++++++++++-----------------------------
1 file changed, 39 insertions(+), 61 deletions(-)
diff --git a/android/android-tester.c b/android/android-tester.c
index 4eb265b..92e6080 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -53,7 +53,6 @@ static uint32_t test_setprop_disctimeout_val = 120;
enum hal_bluetooth_callbacks_id {
ADAPTER_TEST_END,
- ADAPTER_TEST_SETUP_MODE,
ADAPTER_STATE_CHANGED_ON,
ADAPTER_STATE_CHANGED_OFF,
ADAPTER_PROP_BDADDR,
@@ -156,6 +155,13 @@ static void command_generic_new_settings(uint16_t index, uint16_t length,
mgmt_unregister(data->mgmt, data->mgmt_settings_id);
}
+static bool is_empty_halcb_list(void)
+{
+ struct test_data *data = tester_get_data();
+
+ return !(g_slist_length(data->expected_callbacks));
+}
+
static void hal_cb_init(struct test_data *data)
{
const struct generic_data *test_data = data->test_data;
@@ -167,6 +173,9 @@ static void hal_cb_init(struct test_data *data)
GINT_TO_POINTER(test_data->expected_hal_callbacks[i]));
i++;
}
+
+ if (is_empty_halcb_list())
+ data->hal_cb_called = true;
}
static void mgmt_cb_init(struct test_data *data)
@@ -193,7 +202,7 @@ static void test_property_init(struct test_data *data)
{
const struct generic_data *test_data = data->test_data;
- if (!(test_data->expected_property.type))
+ if (is_empty_halcb_list() || !(test_data->expected_property.type))
data->property_checked = true;
}
@@ -245,22 +254,16 @@ static void check_test_property(void)
test_update_state();
}
-static int get_expected_hal_cb(void)
+static void update_hal_cb_list(enum hal_bluetooth_callbacks_id
+ expected_callback)
{
struct test_data *data = tester_get_data();
- if (!(g_slist_length(data->expected_callbacks)))
- return ADAPTER_TEST_SETUP_MODE;
-
- return GPOINTER_TO_INT(data->expected_callbacks->data);
-}
-
-static void remove_expected_hal_cb(void)
-{
- struct test_data *data = tester_get_data();
+ if (is_empty_halcb_list())
+ return;
data->expected_callbacks = g_slist_remove(data->expected_callbacks,
- data->expected_callbacks->data);
+ GINT_TO_POINTER(expected_callback));
if (!data->expected_callbacks)
data->hal_cb_called = true;
@@ -465,28 +468,17 @@ failed:
static void adapter_state_changed_cb(bt_state_t state)
{
- enum hal_bluetooth_callbacks_id hal_cb;
-
- hal_cb = get_expected_hal_cb();
-
- switch (hal_cb) {
- case ADAPTER_STATE_CHANGED_ON:
- if (state == BT_STATE_ON)
- remove_expected_hal_cb();
- else
- tester_test_failed();
- break;
- case ADAPTER_STATE_CHANGED_OFF:
- if (state == BT_STATE_OFF)
- remove_expected_hal_cb();
- else
- tester_test_failed();
- break;
- case ADAPTER_TEST_SETUP_MODE:
- if (state == BT_STATE_ON)
+ switch (state) {
+ case BT_STATE_ON:
+ if (is_empty_halcb_list())
tester_setup_complete();
- else
+ update_hal_cb_list(ADAPTER_STATE_CHANGED_ON);
+ break;
+ case BT_STATE_OFF:
+ if (is_empty_halcb_list())
tester_setup_failed();
+ update_hal_cb_list(ADAPTER_STATE_CHANGED_OFF);
+ break;
default:
break;
}
@@ -495,65 +487,51 @@ static void adapter_state_changed_cb(bt_state_t state)
static void adapter_properties_cb(bt_status_t status, int num_properties,
bt_property_t *properties)
{
- enum hal_bluetooth_callbacks_id hal_cb;
struct test_data *data = tester_get_data();
int i;
- for (i = 0; i < num_properties; i++) {
- hal_cb = get_expected_hal_cb();
+ if (is_empty_halcb_list())
+ return;
- if (hal_cb == ADAPTER_TEST_SETUP_MODE)
- break;
+ for (i = 0; i < num_properties; i++) {
- data->test_property = *properties;
+ data->test_property = properties[i];
- if (g_slist_next(data->expected_callbacks) ==
- ADAPTER_TEST_END)
+ if (g_slist_length(data->expected_callbacks) == 1)
check_test_property();
switch (properties[i].type) {
case BT_PROPERTY_BDADDR:
- if (hal_cb != ADAPTER_PROP_BDADDR)
- goto fail;
+ update_hal_cb_list(ADAPTER_PROP_BDADDR);
break;
case BT_PROPERTY_BDNAME:
- if (hal_cb != ADAPTER_PROP_BDNAME)
- goto fail;
+ update_hal_cb_list(ADAPTER_PROP_BDNAME);
break;
case BT_PROPERTY_UUIDS:
- if (hal_cb != ADAPTER_PROP_UUIDS)
- goto fail;
+ update_hal_cb_list(ADAPTER_PROP_UUIDS);
break;
case BT_PROPERTY_CLASS_OF_DEVICE:
- if (hal_cb != ADAPTER_PROP_COD)
- goto fail;
+ update_hal_cb_list(ADAPTER_PROP_COD);
break;
case BT_PROPERTY_TYPE_OF_DEVICE:
- if (hal_cb != ADAPTER_PROP_TYPE)
- goto fail;
+ update_hal_cb_list(ADAPTER_PROP_TYPE);
break;
case BT_PROPERTY_SERVICE_RECORD:
- if (hal_cb != ADAPTER_PROP_SERVICE_RECORD)
- goto fail;
+ update_hal_cb_list(ADAPTER_PROP_SERVICE_RECORD);
break;
case BT_PROPERTY_ADAPTER_SCAN_MODE:
- if (hal_cb != ADAPTER_PROP_SCAN_MODE)
- goto fail;
+ update_hal_cb_list(ADAPTER_PROP_SCAN_MODE);
break;
case BT_PROPERTY_ADAPTER_BONDED_DEVICES:
- if (hal_cb != ADAPTER_PROP_BONDED_DEVICES)
- goto fail;
+ update_hal_cb_list(ADAPTER_PROP_BONDED_DEVICES);
break;
case BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT:
- if (hal_cb != ADAPTER_PROP_DISC_TIMEOUT)
- goto fail;
+ update_hal_cb_list(ADAPTER_PROP_DISC_TIMEOUT);
break;
default:
goto fail;
}
- remove_expected_hal_cb();
}
-
return;
fail:
--
1.8.4.2
^ permalink raw reply related
* [PATCH 3/7] android/tester: Add UUIDS set prop fail test case
From: Grzegorz Kolodziejczyk @ 2013-12-17 12:37 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1387283874-29721-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>
This adds UUIDS set property fail test case due to only get
possibility.
---
android/android-tester.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index 92e6080..4fe0033 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -596,6 +596,18 @@ static const struct generic_data bluetooth_getprop_bdname_success_test = {
.expected_property.len = 17
};
+static unsigned char setprop_uuids[] = { 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00,
+ 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00 };
+
+static const struct generic_data bluetooth_setprop_uuid_invalid_test = {
+ .expected_hal_callbacks = {ADAPTER_TEST_END},
+ .expected_adapter_status = BT_STATUS_FAIL,
+ .expected_property.type = BT_PROPERTY_UUIDS,
+ .expected_property.val = &setprop_uuids,
+ .expected_property.len = 17
+};
+
static bt_callbacks_t bt_callbacks = {
.size = sizeof(bt_callbacks),
.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -973,6 +985,19 @@ static void test_getprop_bdname_success(const void *test_data)
check_expected_status(adapter_status);
}
+static void test_setprop_uuid_invalid(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ const struct generic_data *test = data->test_data;
+ const bt_property_t *prop = &test->expected_property;
+ bt_status_t adapter_status;
+
+ init_test_conditions(data);
+
+ adapter_status = data->if_bluetooth->set_adapter_property(prop);
+ check_expected_status(adapter_status);
+}
+
#define test_bredrle(name, data, test_setup, test, test_teardown) \
do { \
struct test_data *user; \
@@ -1028,6 +1053,11 @@ int main(int argc, char *argv[])
setup_enabled_adapter,
test_getprop_bdname_success, teardown);
+ test_bredrle("Set UUID - Invalid",
+ &bluetooth_setprop_uuid_invalid_test,
+ setup_enabled_adapter,
+ test_setprop_uuid_invalid, teardown);
+
test_bredrle("Socket Init", NULL, setup_socket_interface,
test_dummy, teardown);
--
1.8.4.2
^ permalink raw reply related
* [PATCH 4/7] android/tester: Add COD set prop fail test case
From: Grzegorz Kolodziejczyk @ 2013-12-17 12:37 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1387283874-29721-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>
This adds CLASS_OF_DEVICE set property fail test case due to only
get possibility.
---
android/android-tester.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index 4fe0033..a6f66c2 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -608,6 +608,16 @@ static const struct generic_data bluetooth_setprop_uuid_invalid_test = {
.expected_property.len = 17
};
+static uint32_t setprop_class_of_device = 0;
+
+static const struct generic_data bluetooth_setprop_cod_invalid_test = {
+ .expected_hal_callbacks = {ADAPTER_TEST_END},
+ .expected_adapter_status = BT_STATUS_FAIL,
+ .expected_property.type = BT_PROPERTY_CLASS_OF_DEVICE,
+ .expected_property.val = &setprop_class_of_device,
+ .expected_property.len = sizeof(uint32_t)
+};
+
static bt_callbacks_t bt_callbacks = {
.size = sizeof(bt_callbacks),
.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -998,6 +1008,19 @@ static void test_setprop_uuid_invalid(const void *test_data)
check_expected_status(adapter_status);
}
+static void test_setprop_cod_invalid(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ const struct generic_data *test = data->test_data;
+ const bt_property_t *prop = &test->expected_property;
+ bt_status_t adapter_status;
+
+ init_test_conditions(data);
+
+ adapter_status = data->if_bluetooth->set_adapter_property(prop);
+ check_expected_status(adapter_status);
+}
+
#define test_bredrle(name, data, test_setup, test, test_teardown) \
do { \
struct test_data *user; \
@@ -1058,6 +1081,11 @@ int main(int argc, char *argv[])
setup_enabled_adapter,
test_setprop_uuid_invalid, teardown);
+ test_bredrle("Set CLASS_OF_DEVICE - Invalid",
+ &bluetooth_setprop_cod_invalid_test,
+ setup_enabled_adapter,
+ test_setprop_cod_invalid, teardown);
+
test_bredrle("Socket Init", NULL, setup_socket_interface,
test_dummy, teardown);
--
1.8.4.2
^ permalink raw reply related
* [PATCH 5/7] android/tester: Add TOD set prop fail test case
From: Grzegorz Kolodziejczyk @ 2013-12-17 12:37 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1387283874-29721-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>
This adds TYPE_OF_DEVICE set property fail test case due to only
get possibility.
---
android/android-tester.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index a6f66c2..4923a6c 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -618,6 +618,16 @@ static const struct generic_data bluetooth_setprop_cod_invalid_test = {
.expected_property.len = sizeof(uint32_t)
};
+static bt_device_type_t setprop_type_of_device = BT_DEVICE_DEVTYPE_BREDR;
+
+static const struct generic_data bluetooth_setprop_tod_invalid_test = {
+ .expected_hal_callbacks = {ADAPTER_TEST_END},
+ .expected_adapter_status = BT_STATUS_FAIL,
+ .expected_property.type = BT_PROPERTY_TYPE_OF_DEVICE,
+ .expected_property.val = &setprop_type_of_device,
+ .expected_property.len = sizeof(bt_device_type_t)
+};
+
static bt_callbacks_t bt_callbacks = {
.size = sizeof(bt_callbacks),
.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -1021,6 +1031,19 @@ static void test_setprop_cod_invalid(const void *test_data)
check_expected_status(adapter_status);
}
+static void test_setprop_tod_invalid(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ const struct generic_data *test = data->test_data;
+ const bt_property_t *prop = &test->expected_property;
+ bt_status_t adapter_status;
+
+ init_test_conditions(data);
+
+ adapter_status = data->if_bluetooth->set_adapter_property(prop);
+ check_expected_status(adapter_status);
+}
+
#define test_bredrle(name, data, test_setup, test, test_teardown) \
do { \
struct test_data *user; \
@@ -1086,6 +1109,11 @@ int main(int argc, char *argv[])
setup_enabled_adapter,
test_setprop_cod_invalid, teardown);
+ test_bredrle("Set TYPE_OF_DEVICE - Invalid",
+ &bluetooth_setprop_tod_invalid_test,
+ setup_enabled_adapter,
+ test_setprop_tod_invalid, teardown);
+
test_bredrle("Socket Init", NULL, setup_socket_interface,
test_dummy, teardown);
--
1.8.4.2
^ permalink raw reply related
* [PATCH 6/7] android/tester: Add RSSI set prop fail test case
From: Grzegorz Kolodziejczyk @ 2013-12-17 12:37 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1387283874-29721-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>
This adds RSSI set property fail test case due to be only remote device
property.
---
android/android-tester.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index 4923a6c..c260a69 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -628,6 +628,16 @@ static const struct generic_data bluetooth_setprop_tod_invalid_test = {
.expected_property.len = sizeof(bt_device_type_t)
};
+static int32_t setprop_remote_rssi = 0;
+
+static const struct generic_data bluetooth_setprop_remote_rssi_invalid_test = {
+ .expected_hal_callbacks = {ADAPTER_TEST_END},
+ .expected_adapter_status = BT_STATUS_FAIL,
+ .expected_property.type = BT_PROPERTY_REMOTE_RSSI,
+ .expected_property.val = &setprop_remote_rssi,
+ .expected_property.len = sizeof(int32_t)
+};
+
static bt_callbacks_t bt_callbacks = {
.size = sizeof(bt_callbacks),
.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -1044,6 +1054,19 @@ static void test_setprop_tod_invalid(const void *test_data)
check_expected_status(adapter_status);
}
+static void test_setprop_rssi_invalid(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ const struct generic_data *test = data->test_data;
+ const bt_property_t *prop = &test->expected_property;
+ bt_status_t adapter_status;
+
+ init_test_conditions(data);
+
+ adapter_status = data->if_bluetooth->set_adapter_property(prop);
+ check_expected_status(adapter_status);
+}
+
#define test_bredrle(name, data, test_setup, test, test_teardown) \
do { \
struct test_data *user; \
@@ -1114,6 +1137,11 @@ int main(int argc, char *argv[])
setup_enabled_adapter,
test_setprop_tod_invalid, teardown);
+ test_bredrle("Set REMOTE_RSSI - Invalid",
+ &bluetooth_setprop_remote_rssi_invalid_test,
+ setup_enabled_adapter,
+ test_setprop_rssi_invalid, teardown);
+
test_bredrle("Socket Init", NULL, setup_socket_interface,
test_dummy, teardown);
--
1.8.4.2
^ permalink raw reply related
* [PATCH 7/7] android/tester: Add SERVICE_RECORD set prop fail test case
From: Grzegorz Kolodziejczyk @ 2013-12-17 12:37 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1387283874-29721-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>
This adds SERVICE_RECORD set property fail test case due to only
get possibility.
---
android/android-tester.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index c260a69..2c1a089 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -638,6 +638,21 @@ static const struct generic_data bluetooth_setprop_remote_rssi_invalid_test = {
.expected_property.len = sizeof(int32_t)
};
+static bt_service_record_t setprop_remote_service = {
+ .uuid = { {0x00} },
+ .channel = 12,
+ .name = "bt_name"
+};
+
+static const struct generic_data
+ bluetooth_setprop_service_record_invalid_test = {
+ .expected_hal_callbacks = {ADAPTER_TEST_END},
+ .expected_adapter_status = BT_STATUS_FAIL,
+ .expected_property.type = BT_PROPERTY_SERVICE_RECORD,
+ .expected_property.val = &setprop_remote_service,
+ .expected_property.len = sizeof(bt_service_record_t)
+};
+
static bt_callbacks_t bt_callbacks = {
.size = sizeof(bt_callbacks),
.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -1067,6 +1082,19 @@ static void test_setprop_rssi_invalid(const void *test_data)
check_expected_status(adapter_status);
}
+static void test_setprop_service_record(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ const struct generic_data *test = data->test_data;
+ const bt_property_t *prop = &test->expected_property;
+ bt_status_t adapter_status;
+
+ init_test_conditions(data);
+
+ adapter_status = data->if_bluetooth->set_adapter_property(prop);
+ check_expected_status(adapter_status);
+}
+
#define test_bredrle(name, data, test_setup, test, test_teardown) \
do { \
struct test_data *user; \
@@ -1142,6 +1170,11 @@ int main(int argc, char *argv[])
setup_enabled_adapter,
test_setprop_rssi_invalid, teardown);
+ test_bredrle("Set SERVICE_RECORD - Invalid",
+ &bluetooth_setprop_service_record_invalid_test,
+ setup_enabled_adapter,
+ test_setprop_service_record, teardown);
+
test_bredrle("Socket Init", NULL, setup_socket_interface,
test_dummy, teardown);
--
1.8.4.2
^ permalink raw reply related
* Re: [PATCH BlueZ] build: Add coverage support
From: Anderson Lizardo @ 2013-12-17 13:07 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: BlueZ development
In-Reply-To: <1387283107-4356-1-git-send-email-luiz.dentz@gmail.com>
Hi Luiz,
On Tue, Dec 17, 2013 at 8:25 AM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> diff --git a/Makefile.am b/Makefile.am
> index 15cc149..337d849 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -331,5 +331,23 @@ lib/bluetooth/%.h: lib/%.h
> $(AM_V_at)$(MKDIR_P) lib/bluetooth
> $(AM_V_GEN)$(LN_S) -f "$(abs_top_builddir)"/$< $@
>
> +if MAINTAINER_MODE
> +clean-coverage:
> + -find $(top_builddir) -name "*.gcda" -delete
> + @lcov --directory $(top_builddir) --zerocounters
> + $(RM) -r coverage
You may want to remove coverage.info as well.
> +
> +coverage: clean-coverage check
> + @lcov --compat-libtool --directory $(top_builddir) --capture \
> + --output-file $(top_builddir)/coverage.info
> + $(AM_V_at)$(MKDIR_P) -p coverage
MKDIR_P already includes the "-p" option, so it should be
"$(AM_V_at)$(MKDIR_P) coverage" above.
> + @genhtml -o coverage/ $(top_builddir)/coverage.info
> +
> +clean-local: clean-coverage
> + -find $(top_builddir) -name "*.gcno" -delete
> + $(RM) -r lib/bluetooth
> +
> +else
> clean-local:
> $(RM) -r lib/bluetooth
> +endif
Best Regards,
--
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
^ permalink raw reply
* [PATCH v3 bluetooth-next 0/8] 6lowpan: udp compression/uncompression fix
From: Alexander Aring @ 2013-12-17 13:21 UTC (permalink / raw)
To: linux-zigbee-devel; +Cc: werner, linux-bluetooth, Alexander Aring
The current 6LoWPAN udp compression/uncompression is completely broken.
This patch series fix a lot of udp compression/uncompression issues and
add support parsing with lowpan_fetch_skb/lowpan_push_hc_data functions.
I tested it in all cases of compressions in wireshark and a contiki
sensornode.
Changes since v3:
- add patch to introduce lowpan_push_hc_data helper function.
- remove patch to fix nullpointer dereferencing and replace it with
a patch which use the lowpan_push_hc_data function in compress_udp_header
function. This fixes the nullpointer dereferencing problem also and is more
readable.
- add missing newline in pr_debug_ratelimited.
Changes since v2:
- remove unnecessary casts and brackes, suggested by Werner Almesberger.
- use pr_debug_ratelimited instead of pr_debug on patch 4/7.
Alexander Aring (8):
6lowpan: introduce lowpan_push_hc_data function
6lowpan: udp use lowpan_push_hc_data function
6lowpan: fix udp compress ordering
6lowpan: fix udp byte ordering
6lowpan: add udp warning for elided checksum
6lowpan: udp use lowpan_fetch_skb function
6lowpan: udp use subtraction on both conditions
6lowpan: cleanup udp compress function
net/ieee802154/6lowpan.h | 8 +++
net/ieee802154/6lowpan_iphc.c | 114 ++++++++++++++++++++++++------------------
2 files changed, 74 insertions(+), 48 deletions(-)
--
1.8.5.1
^ permalink raw reply
* [PATCH v3 bluetooth-next 1/8] 6lowpan: introduce lowpan_push_hc_data function
From: Alexander Aring @ 2013-12-17 13:21 UTC (permalink / raw)
To: linux-zigbee-devel; +Cc: werner, linux-bluetooth, Alexander Aring
In-Reply-To: <1387286488-29382-1-git-send-email-alex.aring@gmail.com>
This patch introduce the lowpan_push_hc_data function to set data in
the iphc buffer.
It's a common case to set data and increase the buffer pointer. This
helper function can be used many times in header_compress function to
generate the iphc header.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
net/ieee802154/6lowpan.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/net/ieee802154/6lowpan.h b/net/ieee802154/6lowpan.h
index 10909e5..4981bf8 100644
--- a/net/ieee802154/6lowpan.h
+++ b/net/ieee802154/6lowpan.h
@@ -298,6 +298,13 @@ static inline bool lowpan_fetch_skb(struct sk_buff *skb,
return false;
}
+static inline void lowpan_push_hc_data(u8 **hc_ptr, const void *data,
+ const size_t len)
+{
+ memcpy(*hc_ptr, data, len);
+ *hc_ptr += len;
+}
+
typedef int (*skb_delivery_cb)(struct sk_buff *skb, struct net_device *dev);
int lowpan_process_data(struct sk_buff *skb, struct net_device *dev,
--
1.8.5.1
^ permalink raw reply related
* [PATCH v3 bluetooth-next 2/8] 6lowpan: udp use lowpan_push_hc_data function
From: Alexander Aring @ 2013-12-17 13:21 UTC (permalink / raw)
To: linux-zigbee-devel; +Cc: werner, linux-bluetooth, Alexander Aring
In-Reply-To: <1387286488-29382-1-git-send-email-alex.aring@gmail.com>
This patch uses the lowpan_push_hc_data to generate iphc header.
The current implementation has some wrong pointer arithmetic issues and
works in a random case only.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
net/ieee802154/6lowpan_iphc.c | 37 ++++++++++++++++++++-----------------
1 file changed, 20 insertions(+), 17 deletions(-)
diff --git a/net/ieee802154/6lowpan_iphc.c b/net/ieee802154/6lowpan_iphc.c
index 88e7da5..77c0366 100644
--- a/net/ieee802154/6lowpan_iphc.c
+++ b/net/ieee802154/6lowpan_iphc.c
@@ -541,42 +541,45 @@ static u8 lowpan_compress_addr_64(u8 **hc06_ptr, u8 shift,
static void compress_udp_header(u8 **hc06_ptr, struct sk_buff *skb)
{
struct udphdr *uh = udp_hdr(skb);
+ u8 tmp;
if (((uh->source & LOWPAN_NHC_UDP_4BIT_MASK) ==
LOWPAN_NHC_UDP_4BIT_PORT) &&
((uh->dest & LOWPAN_NHC_UDP_4BIT_MASK) ==
LOWPAN_NHC_UDP_4BIT_PORT)) {
pr_debug("UDP header: both ports compression to 4 bits\n");
- **hc06_ptr = LOWPAN_NHC_UDP_CS_P_11;
- **(hc06_ptr + 1) = /* subtraction is faster */
+ tmp = LOWPAN_NHC_UDP_CS_P_11;
+ lowpan_push_hc_data(hc06_ptr, &tmp, sizeof(tmp));
+ tmp = /* subtraction is faster */
(u8)((uh->dest - LOWPAN_NHC_UDP_4BIT_PORT) +
((uh->source & LOWPAN_NHC_UDP_4BIT_PORT) << 4));
- *hc06_ptr += 2;
+ lowpan_push_hc_data(hc06_ptr, &tmp, sizeof(tmp));
} else if ((uh->dest & LOWPAN_NHC_UDP_8BIT_MASK) ==
LOWPAN_NHC_UDP_8BIT_PORT) {
pr_debug("UDP header: remove 8 bits of dest\n");
- **hc06_ptr = LOWPAN_NHC_UDP_CS_P_01;
- memcpy(*hc06_ptr + 1, &uh->source, 2);
- **(hc06_ptr + 3) = (u8)(uh->dest - LOWPAN_NHC_UDP_8BIT_PORT);
- *hc06_ptr += 4;
+ tmp = LOWPAN_NHC_UDP_CS_P_01;
+ lowpan_push_hc_data(hc06_ptr, &tmp, sizeof(tmp));
+ lowpan_push_hc_data(hc06_ptr, &uh->source, sizeof(uh->source));
+ tmp = (u8)(uh->dest - LOWPAN_NHC_UDP_8BIT_PORT);
+ lowpan_push_hc_data(hc06_ptr, &tmp, sizeof(tmp));
} else if ((uh->source & LOWPAN_NHC_UDP_8BIT_MASK) ==
LOWPAN_NHC_UDP_8BIT_PORT) {
pr_debug("UDP header: remove 8 bits of source\n");
- **hc06_ptr = LOWPAN_NHC_UDP_CS_P_10;
- memcpy(*hc06_ptr + 1, &uh->dest, 2);
- **(hc06_ptr + 3) = (u8)(uh->source - LOWPAN_NHC_UDP_8BIT_PORT);
- *hc06_ptr += 4;
+ tmp = LOWPAN_NHC_UDP_CS_P_10;
+ lowpan_push_hc_data(hc06_ptr, &tmp, sizeof(tmp));
+ lowpan_push_hc_data(hc06_ptr, &uh->dest, sizeof(uh->dest));
+ tmp = (u8)(uh->source - LOWPAN_NHC_UDP_8BIT_PORT);
+ lowpan_push_hc_data(hc06_ptr, &tmp, sizeof(tmp));
} else {
pr_debug("UDP header: can't compress\n");
- **hc06_ptr = LOWPAN_NHC_UDP_CS_P_00;
- memcpy(*hc06_ptr + 1, &uh->source, 2);
- memcpy(*hc06_ptr + 3, &uh->dest, 2);
- *hc06_ptr += 5;
+ tmp = LOWPAN_NHC_UDP_CS_P_00;
+ lowpan_push_hc_data(hc06_ptr, &tmp, sizeof(tmp));
+ lowpan_push_hc_data(hc06_ptr, &uh->source, sizeof(uh->source));
+ lowpan_push_hc_data(hc06_ptr, &uh->dest, sizeof(uh->dest));
}
/* checksum is always inline */
- memcpy(*hc06_ptr, &uh->check, 2);
- *hc06_ptr += 2;
+ lowpan_push_hc_data(hc06_ptr, &uh->check, sizeof(uh->check));
/* skip the UDP header */
skb_pull(skb, sizeof(struct udphdr));
--
1.8.5.1
^ permalink raw reply related
* [PATCH v3 bluetooth-next 3/8] 6lowpan: fix udp compress ordering
From: Alexander Aring @ 2013-12-17 13:21 UTC (permalink / raw)
To: linux-zigbee-devel; +Cc: werner, linux-bluetooth, Alexander Aring
In-Reply-To: <1387286488-29382-1-git-send-email-alex.aring@gmail.com>
In case ((ntohs(uh->source) & LOWPAN_NHC_UDP_8BIT_MASK) the order of
uncompression is wrong. It's always first source port then destination
port as second.
See:
http://tools.ietf.org/html/rfc6282#section-4.3.3
"Fields carried in-line (in part or in whole) appear in the same order
as they do in the UDP header format"
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
net/ieee802154/6lowpan_iphc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ieee802154/6lowpan_iphc.c b/net/ieee802154/6lowpan_iphc.c
index 77c0366..1933f5b 100644
--- a/net/ieee802154/6lowpan_iphc.c
+++ b/net/ieee802154/6lowpan_iphc.c
@@ -567,9 +567,9 @@ static void compress_udp_header(u8 **hc06_ptr, struct sk_buff *skb)
pr_debug("UDP header: remove 8 bits of source\n");
tmp = LOWPAN_NHC_UDP_CS_P_10;
lowpan_push_hc_data(hc06_ptr, &tmp, sizeof(tmp));
- lowpan_push_hc_data(hc06_ptr, &uh->dest, sizeof(uh->dest));
tmp = (u8)(uh->source - LOWPAN_NHC_UDP_8BIT_PORT);
lowpan_push_hc_data(hc06_ptr, &tmp, sizeof(tmp));
+ lowpan_push_hc_data(hc06_ptr, &uh->dest, sizeof(uh->dest));
} else {
pr_debug("UDP header: can't compress\n");
tmp = LOWPAN_NHC_UDP_CS_P_00;
--
1.8.5.1
^ permalink raw reply related
* [PATCH v3 bluetooth-next 4/8] 6lowpan: fix udp byte ordering
From: Alexander Aring @ 2013-12-17 13:21 UTC (permalink / raw)
To: linux-zigbee-devel; +Cc: werner, linux-bluetooth, Alexander Aring
In-Reply-To: <1387286488-29382-1-git-send-email-alex.aring@gmail.com>
The incoming udp header in lowpan_compress_udp_header function is
already in network byte order.
Everytime we read this values for source and destination port we need
to convert this value to host byte order.
In the outcoming header we need to set this value in network byte order
which the upcoming process assumes.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
net/ieee802154/6lowpan_iphc.c | 39 ++++++++++++++++++++-------------------
1 file changed, 20 insertions(+), 19 deletions(-)
diff --git a/net/ieee802154/6lowpan_iphc.c b/net/ieee802154/6lowpan_iphc.c
index 1933f5b..02bf74d 100644
--- a/net/ieee802154/6lowpan_iphc.c
+++ b/net/ieee802154/6lowpan_iphc.c
@@ -283,20 +283,21 @@ uncompress_udp_header(struct sk_buff *skb, struct udphdr *uh)
break;
case LOWPAN_NHC_UDP_CS_P_01:
memcpy(&uh->source, &skb->data[0], 2);
- uh->dest =
- skb->data[2] + LOWPAN_NHC_UDP_8BIT_PORT;
+ uh->dest = htons(skb->data[2] +
+ LOWPAN_NHC_UDP_8BIT_PORT);
skb_pull(skb, 3);
break;
case LOWPAN_NHC_UDP_CS_P_10:
- uh->source = skb->data[0] + LOWPAN_NHC_UDP_8BIT_PORT;
+ uh->source = htons(skb->data[0] +
+ LOWPAN_NHC_UDP_8BIT_PORT);
memcpy(&uh->dest, &skb->data[1], 2);
skb_pull(skb, 3);
break;
case LOWPAN_NHC_UDP_CS_P_11:
- uh->source =
- LOWPAN_NHC_UDP_4BIT_PORT + (skb->data[0] >> 4);
- uh->dest =
- LOWPAN_NHC_UDP_4BIT_PORT + (skb->data[0] & 0x0f);
+ uh->source = htons(LOWPAN_NHC_UDP_4BIT_PORT +
+ (skb->data[0] >> 4));
+ uh->dest = htons(LOWPAN_NHC_UDP_4BIT_PORT +
+ (skb->data[0] & 0x0f));
skb_pull(skb, 1);
break;
default:
@@ -306,7 +307,7 @@ uncompress_udp_header(struct sk_buff *skb, struct udphdr *uh)
}
pr_debug("uncompressed UDP ports: src = %d, dst = %d\n",
- uh->source, uh->dest);
+ ntohs(uh->source), ntohs(uh->dest));
/* copy checksum */
memcpy(&uh->check, &skb->data[0], 2);
@@ -318,7 +319,7 @@ uncompress_udp_header(struct sk_buff *skb, struct udphdr *uh)
* frame
*/
uh->len = htons(skb->len + sizeof(struct udphdr));
- pr_debug("uncompressed UDP length: src = %d", uh->len);
+ pr_debug("uncompressed UDP length: src = %d", ntohs(uh->len));
} else {
pr_debug("ERROR: unsupported NH format\n");
goto err;
@@ -543,31 +544,31 @@ static void compress_udp_header(u8 **hc06_ptr, struct sk_buff *skb)
struct udphdr *uh = udp_hdr(skb);
u8 tmp;
- if (((uh->source & LOWPAN_NHC_UDP_4BIT_MASK) ==
- LOWPAN_NHC_UDP_4BIT_PORT) &&
- ((uh->dest & LOWPAN_NHC_UDP_4BIT_MASK) ==
- LOWPAN_NHC_UDP_4BIT_PORT)) {
+ if (((ntohs(uh->source) & LOWPAN_NHC_UDP_4BIT_MASK) ==
+ LOWPAN_NHC_UDP_4BIT_PORT) &&
+ ((ntohs(uh->dest) & LOWPAN_NHC_UDP_4BIT_MASK) ==
+ LOWPAN_NHC_UDP_4BIT_PORT)) {
pr_debug("UDP header: both ports compression to 4 bits\n");
tmp = LOWPAN_NHC_UDP_CS_P_11;
lowpan_push_hc_data(hc06_ptr, &tmp, sizeof(tmp));
tmp = /* subtraction is faster */
- (u8)((uh->dest - LOWPAN_NHC_UDP_4BIT_PORT) +
- ((uh->source & LOWPAN_NHC_UDP_4BIT_PORT) << 4));
+ (u8)((ntohs(uh->dest) - LOWPAN_NHC_UDP_4BIT_PORT) +
+ ((ntohs(uh->source) & LOWPAN_NHC_UDP_4BIT_PORT) << 4));
lowpan_push_hc_data(hc06_ptr, &tmp, sizeof(tmp));
- } else if ((uh->dest & LOWPAN_NHC_UDP_8BIT_MASK) ==
+ } else if ((ntohs(uh->dest) & LOWPAN_NHC_UDP_8BIT_MASK) ==
LOWPAN_NHC_UDP_8BIT_PORT) {
pr_debug("UDP header: remove 8 bits of dest\n");
tmp = LOWPAN_NHC_UDP_CS_P_01;
lowpan_push_hc_data(hc06_ptr, &tmp, sizeof(tmp));
lowpan_push_hc_data(hc06_ptr, &uh->source, sizeof(uh->source));
- tmp = (u8)(uh->dest - LOWPAN_NHC_UDP_8BIT_PORT);
+ tmp = (u8)(ntohs(uh->dest) - LOWPAN_NHC_UDP_8BIT_PORT);
lowpan_push_hc_data(hc06_ptr, &tmp, sizeof(tmp));
- } else if ((uh->source & LOWPAN_NHC_UDP_8BIT_MASK) ==
+ } else if ((ntohs(uh->source) & LOWPAN_NHC_UDP_8BIT_MASK) ==
LOWPAN_NHC_UDP_8BIT_PORT) {
pr_debug("UDP header: remove 8 bits of source\n");
tmp = LOWPAN_NHC_UDP_CS_P_10;
lowpan_push_hc_data(hc06_ptr, &tmp, sizeof(tmp));
- tmp = (u8)(uh->source - LOWPAN_NHC_UDP_8BIT_PORT);
+ tmp = (u8)(ntohs(uh->source) - LOWPAN_NHC_UDP_8BIT_PORT);
lowpan_push_hc_data(hc06_ptr, &tmp, sizeof(tmp));
lowpan_push_hc_data(hc06_ptr, &uh->dest, sizeof(uh->dest));
} else {
--
1.8.5.1
^ permalink raw reply related
* [PATCH v3 bluetooth-next 5/8] 6lowpan: add udp warning for elided checksum
From: Alexander Aring @ 2013-12-17 13:21 UTC (permalink / raw)
To: linux-zigbee-devel; +Cc: werner, linux-bluetooth, Alexander Aring
In-Reply-To: <1387286488-29382-1-git-send-email-alex.aring@gmail.com>
Bit 5 of "UDP LOWPAN_NHC Format" indicate that the checksum can be
elided.
The host need to calculate the udp checksum afterwards but this isn't
supported right now.
See:
http://tools.ietf.org/html/rfc6282#section-4.3.3
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
net/ieee802154/6lowpan.h | 1 +
net/ieee802154/6lowpan_iphc.c | 11 ++++++++---
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/net/ieee802154/6lowpan.h b/net/ieee802154/6lowpan.h
index 4981bf8..2b835db 100644
--- a/net/ieee802154/6lowpan.h
+++ b/net/ieee802154/6lowpan.h
@@ -231,6 +231,7 @@
#define LOWPAN_NHC_UDP_CS_P_10 0xF2 /* source = 0xF0 + 8bit inline,
dest = 16 bit inline */
#define LOWPAN_NHC_UDP_CS_P_11 0xF3 /* source & dest = 0xF0B + 4bit inline */
+#define LOWPAN_NHC_UDP_CS_C 0x04 /* checksum elided */
#ifdef DEBUG
/* print data in line */
diff --git a/net/ieee802154/6lowpan_iphc.c b/net/ieee802154/6lowpan_iphc.c
index 02bf74d..a70fa66 100644
--- a/net/ieee802154/6lowpan_iphc.c
+++ b/net/ieee802154/6lowpan_iphc.c
@@ -309,9 +309,14 @@ uncompress_udp_header(struct sk_buff *skb, struct udphdr *uh)
pr_debug("uncompressed UDP ports: src = %d, dst = %d\n",
ntohs(uh->source), ntohs(uh->dest));
- /* copy checksum */
- memcpy(&uh->check, &skb->data[0], 2);
- skb_pull(skb, 2);
+ /* checksum */
+ if (tmp & LOWPAN_NHC_UDP_CS_C) {
+ pr_debug_ratelimited("checksum elided currently not supported\n");
+ goto err;
+ } else {
+ memcpy(&uh->check, &skb->data[0], 2);
+ skb_pull(skb, 2);
+ }
/*
* UDP lenght needs to be infered from the lower layers
--
1.8.5.1
^ permalink raw reply related
* [PATCH v3 bluetooth-next 6/8] 6lowpan: udp use lowpan_fetch_skb function
From: Alexander Aring @ 2013-12-17 13:21 UTC (permalink / raw)
To: linux-zigbee-devel; +Cc: werner, linux-bluetooth, Alexander Aring
In-Reply-To: <1387286488-29382-1-git-send-email-alex.aring@gmail.com>
Cleanup the lowpan_uncompress_udp_header function to use the
lowpan_fetch_skb function.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
net/ieee802154/6lowpan_iphc.c | 37 ++++++++++++++++++-------------------
1 file changed, 18 insertions(+), 19 deletions(-)
diff --git a/net/ieee802154/6lowpan_iphc.c b/net/ieee802154/6lowpan_iphc.c
index a70fa66..8857285 100644
--- a/net/ieee802154/6lowpan_iphc.c
+++ b/net/ieee802154/6lowpan_iphc.c
@@ -265,40 +265,37 @@ lowpan_uncompress_multicast_daddr(struct sk_buff *skb,
static int
uncompress_udp_header(struct sk_buff *skb, struct udphdr *uh)
{
- u8 tmp;
+ bool fail;
+ u8 tmp = 0, val = 0;
if (!uh)
goto err;
- if (lowpan_fetch_skb_u8(skb, &tmp))
- goto err;
+ fail = lowpan_fetch_skb(skb, &tmp, 1);
if ((tmp & LOWPAN_NHC_UDP_MASK) == LOWPAN_NHC_UDP_ID) {
pr_debug("UDP header uncompression\n");
switch (tmp & LOWPAN_NHC_UDP_CS_P_11) {
case LOWPAN_NHC_UDP_CS_P_00:
- memcpy(&uh->source, &skb->data[0], 2);
- memcpy(&uh->dest, &skb->data[2], 2);
- skb_pull(skb, 4);
+ fail |= lowpan_fetch_skb(skb, &uh->source, 2);
+ fail |= lowpan_fetch_skb(skb, &uh->dest, 2);
break;
case LOWPAN_NHC_UDP_CS_P_01:
- memcpy(&uh->source, &skb->data[0], 2);
- uh->dest = htons(skb->data[2] +
- LOWPAN_NHC_UDP_8BIT_PORT);
- skb_pull(skb, 3);
+ fail |= lowpan_fetch_skb(skb, &uh->source, 2);
+ fail |= lowpan_fetch_skb(skb, &val, 1);
+ uh->dest = htons(val + LOWPAN_NHC_UDP_8BIT_PORT);
break;
case LOWPAN_NHC_UDP_CS_P_10:
- uh->source = htons(skb->data[0] +
- LOWPAN_NHC_UDP_8BIT_PORT);
- memcpy(&uh->dest, &skb->data[1], 2);
- skb_pull(skb, 3);
+ fail |= lowpan_fetch_skb(skb, &val, 1);
+ uh->source = htons(val + LOWPAN_NHC_UDP_8BIT_PORT);
+ fail |= lowpan_fetch_skb(skb, &uh->dest, 2);
break;
case LOWPAN_NHC_UDP_CS_P_11:
+ fail |= lowpan_fetch_skb(skb, &val, 1);
uh->source = htons(LOWPAN_NHC_UDP_4BIT_PORT +
- (skb->data[0] >> 4));
+ (val >> 4));
uh->dest = htons(LOWPAN_NHC_UDP_4BIT_PORT +
- (skb->data[0] & 0x0f));
- skb_pull(skb, 1);
+ (val & 0x0f));
break;
default:
pr_debug("ERROR: unknown UDP format\n");
@@ -314,8 +311,7 @@ uncompress_udp_header(struct sk_buff *skb, struct udphdr *uh)
pr_debug_ratelimited("checksum elided currently not supported\n");
goto err;
} else {
- memcpy(&uh->check, &skb->data[0], 2);
- skb_pull(skb, 2);
+ fail |= lowpan_fetch_skb(skb, &uh->check, 2);
}
/*
@@ -330,6 +326,9 @@ uncompress_udp_header(struct sk_buff *skb, struct udphdr *uh)
goto err;
}
+ if (fail)
+ goto err;
+
return 0;
err:
return -EINVAL;
--
1.8.5.1
^ permalink raw reply related
* [PATCH v3 bluetooth-next 7/8] 6lowpan: udp use subtraction on both conditions
From: Alexander Aring @ 2013-12-17 13:21 UTC (permalink / raw)
To: linux-zigbee-devel; +Cc: werner, linux-bluetooth, Alexander Aring
In-Reply-To: <1387286488-29382-1-git-send-email-alex.aring@gmail.com>
Cleanup code to handle both calculation in the same way.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
net/ieee802154/6lowpan_iphc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ieee802154/6lowpan_iphc.c b/net/ieee802154/6lowpan_iphc.c
index 8857285..b298bfc 100644
--- a/net/ieee802154/6lowpan_iphc.c
+++ b/net/ieee802154/6lowpan_iphc.c
@@ -557,7 +557,7 @@ static void compress_udp_header(u8 **hc06_ptr, struct sk_buff *skb)
lowpan_push_hc_data(hc06_ptr, &tmp, sizeof(tmp));
tmp = /* subtraction is faster */
(u8)((ntohs(uh->dest) - LOWPAN_NHC_UDP_4BIT_PORT) +
- ((ntohs(uh->source) & LOWPAN_NHC_UDP_4BIT_PORT) << 4));
+ ((ntohs(uh->source) - LOWPAN_NHC_UDP_4BIT_PORT) << 4));
lowpan_push_hc_data(hc06_ptr, &tmp, sizeof(tmp));
} else if ((ntohs(uh->dest) & LOWPAN_NHC_UDP_8BIT_MASK) ==
LOWPAN_NHC_UDP_8BIT_PORT) {
--
1.8.5.1
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox