Commit Graph

1928 Commits

Author SHA1 Message Date
Szymon Janc 68592f06f6 Bluetooth: SMP: Add support for LTK derivation from LinkKey
This allows to derive LTK from Link Key using H6 function.

Jira: ZEP-625

Change-Id: Ife1e0d770f196174b6d7fc5e8074d76af49934cb
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-09-14 06:02:15 +00:00
Szymon Janc 790a28ccf4 Bluetooth: SMP: Allow to force BR/EDR without SC support
This option allows to register BR/EDR SMP channel without required
Secure Connections support in controller. This is solely for testing
and should never be enabled in production.

Jira: ZEP-605

Change-Id: I1909c900e323f61acef9fa2b46f22e853beeda75
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-09-14 06:02:10 +00:00
Szymon Janc 756ac5f63c Bluetooth: SMP: Support Pairing Response over BR/EDR
Handle Pairing Response and distribute keys if required.

Jira: ZEP-605

Change-Id: I2014d38896f9f67095228cb09dab017040570448
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-09-14 06:02:05 +00:00
Szymon Janc 1d06d941da Bluetooth: SMP: Fix encryption key size check in BR/EDR pairing req
Encryption key size for derived LTK should match one used for BR/EDR
encryption.

Change-Id: Ibcb1c3320cd191ce0d2fda8f5cacaf1ee295fcc4
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-09-14 06:02:00 +00:00
Szymon Janc 85195d2d2e Bluetooth: Add support for reading encryption key size for BR/EDR
Make use of "Read Encryption Key Size" HCI command to read real
encryption key size for BR/EDR connection instead of assuming 16
bytes key size.

< HCI Command: Read Encryption Key Size (0x05|0x0008) plen 2
        Handle: 11
> HCI Event: Command Complete (0x0e) plen 7
      Read Encryption Key Size (0x05|0x0008) ncmd 1
        Status: Success (0x00)
        Handle: 11
        Key size: 16

Change-Id: I372028ce73115d34aedbb6b5ce420144844cfce0
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-09-14 06:01:55 +00:00
Johan Hedberg 37d204e03d Bluetooth: Fix giving back pkts semaphore when disconnecting
The TX fiber might be blocked waiting for the num_pkts semaphore when
a disconnection occurs. If we only give back the semaphore once
exiting the while-loop we may end up in a deadlock. Giving back the
semaphore in the connection disconnect handler solves this.

An additional fix this patch does is to ensure that we don't perform
integer underflow because of the last iteration.

Change-Id: Ia67dc506885d0c2bad25c598ea349f1fd251218b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-09-14 08:45:45 +03:00
Szymon Janc c31fcf4e5a Bluetooth: SMP: Distribute local keys over BR/EDR
< ACL Data TX: Handle 11 flags 0x00 dlen 21
      BR/EDR SMP: Identity Information (0x08) len 16
        Identity resolving key: 732bf430116b328587de5fda0a4b8c80
< ACL Data TX: Handle 11 flags 0x00 dlen 12
      BR/EDR SMP: Identity Address Information (0x09) len 7
        Address type: Public (0x00)
        Address: 00:02:72:33:45:88

Jira: ZEP-605

Change-Id: I6ba203ea4bbd64c0f05150d3865e6c3bb630b41d
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-09-14 08:45:45 +03:00
Szymon Janc 8f9eccac25 Bluetooth: SMP: Support Pairing Failed over BR/EDR
Invalidate received keys on Pairing Failed.

Jira: ZEP-605

Change-Id: I4eec85233ed27312b9f61d89d71329cc665b382b
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-09-14 08:45:45 +03:00
Szymon Janc 2cac219a36 Bluetooth: SMP: Support Pairing Request over BR/EDR
This allows to handle Pairing Request and reply with Pairing Response.

> ACL Data RX: Handle 11 flags 0x02 dlen 11
      BR/EDR SMP: Pairing Request (0x01) len 6
        IO capability: DisplayOnly (0x00)
        OOB data: Authentication data not present (0x00)
        Authentication requirement: No bonding, No MITM, Legacy,
                                    No Keypresses (0x00)
        Max encryption key size: 16
        Initiator key distribution: IdKey (0x02)
        Responder key distribution: IdKey (0x02)
< ACL Data TX: Handle 11 flags 0x00 dlen 11
      BR/EDR SMP: Pairing Response (0x02) len 6
        IO capability: DisplayOnly (0x00)
        OOB data: Authentication data not present (0x00)
        Authentication requirement: No bonding, No MITM, Legacy,
                                    No Keypresses (0x00)
        Max encryption key size: 16
        Initiator key distribution: IdKey (0x02)
        Responder key distribution: IdKey (0x02)

Jira: ZEP-605

Change-Id: I886c8d345b87dafae93d692ab39b7f1214bff733
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-09-14 08:45:45 +03:00
Szymon Janc 355ef5a5a0 Bluetooth: SMP: Clear keys on timeout when running over BR/EDR
If SMP Timeout occured pairing failed and any keys distributed should
be invalidated.

Jira: ZEP-605

Change-Id: Ibdb9d61c720f9da10232c9bc6148d9ff73ccfa6c
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-09-14 08:45:45 +03:00
Johan Hedberg 3a3238d1b0 Bluetooth: GATT: Fix potential bt_conn reference leak
There was a missing bt_conn_unref() when bt_conn_lookup_addr_le()
returns a connection that's not in BT_CONN_CONNECTED state.

Change-Id: I4c6271d5bf596ea4d9b899e99ce1c7b7c8693f5e
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-09-14 08:45:45 +03:00
Szymon Janc d27447c674 Bluetooth: SMP: Add initial code for BR/EDR support
This allows to register SMP over BR/EDR fixed channel is Secure
Connections are supported by controller.

Change-Id: I681bc1cc789ae30a115594c1143485e8a7a8acb3
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-09-14 08:45:45 +03:00
Szymon Janc fa726a8d99 Bluetooth: SMP: Move smp_create_pdu function up in a file
This is in prepartion for BR/EDR support.

Change-Id: Ie9e8f6368b74e6e9768e775d6ccf718fb6927e3a
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-09-14 08:45:45 +03:00
Sathish Narasimman 9738e83285 Bluetooth: HFP HF: Initialize Handsfree profile
Initialize Handsfree profile for HF Role and register RFCOMM server
channel number to the RFCOMM. And also exposes some basic callbacks
which is required for the application.

Change-Id: Ic79cbd66ef9529c4eb134cc21efcdbc388bb707d
Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
2016-09-14 08:45:45 +03:00
Jaganath Kanakkassery d73814a1d5 Bluetooth: RFCOMM: Implement RX flow control
RX credits is defined based on the number of acl buffers and
it will be updated to remote if it goes beyond the defined
threshold. Controller to host flow control will take care if
acl buffers are not free wrt outstanding RX credits.

Change-Id: Ie597513bda07f39b6934a704f6db6dad14e323d5
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-14 08:45:45 +03:00
Luiz Augusto von Dentz c5dc094f7e Bluetooth: ATT: Fix not handling error response properly
The code should check if there is an existing buffer to match with the
response code.

Change-Id: I08546fdf416884560cf497a34cc4eee95079a589
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-09-14 08:45:45 +03:00
Vinayak Chettimada 190ac96fad Bluetooth: ATT: Remove unnecessary call to BT_ASSERT
Change-id: Ic8038392e540445b718beb05a3375aaa6a50ad61
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2016-09-14 08:45:45 +03:00
Carles Cufi 80d1fba9e9 Bluetooth: HCI: Fix the length of supported commands
The length of the commands array in the return parameters of
the HCI Read Local Supported Commands event is 64 bytes
according to the spec. This was mistakenly set as 36 bytes due
to the fact that only 36 out of the 64 bytes currently contain
meaningful data. The actual array as received from the driver
will always be 64 bytes however, and is therefore sized
accordingly.

Change-Id: Iee7f1fc18045dff96efcc808fd81661eced37b03
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2016-09-14 08:45:45 +03:00
Genaro Saucedo Tejada 4dc8078435 fix: net samples no longer include unneeded 802.15.4 files
Some samples were including nullsec.c, simplerdc.c and
framer-nullmac.c, those files are not needed but introduce some
symbol dependencies, causing link to fail when optimization is not
-Os, e.g. when compiling with CONFIG_DEBUG.

Change-Id: Id227470a4517e8e2c3b9af942b0893783075cd40
Signed-off-by: Genaro Saucedo Tejada <genaro.saucedo.tejada@intel.com>
2016-09-12 12:29:09 +00:00
Jukka Rissanen 33d92af1cf net: Initial trickle algorithm support for legacy IP stack
This commit only provides the Trickle algorithm support.
Some other entity must call its functions in order to be
useful.

Fixes: ZEP-627

Change-Id: Ice1fcfe9c57269309eeab06eab000622662e2929
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-09-12 02:00:12 +00:00
Vinicius Costa Gomes f0882c2c80 net/buf: Add missing line break in debug statement
Without this line break, when CONFIG_NET_BUF_DEBUG is enabled, the
output may get confusing.

Change-Id: Ic467511f1dbbd283710f51ef14f94e0269c7c0ea
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-09-08 11:29:29 +00:00
Jaganath Kanakkassery 028bf3fb88 Bluetooth: RFCOMM: Modify bt_rfcomm_dlc() to return dlc
Currently bt_rfcomm_dlc() is returning error code and dlc is returned
as output param. Since caller does not need to check error, it can
return NULL if some error happens

Change-Id: I86e85b67545edb960b4b745267e6645017373bf6
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 07:22:38 +00:00
Jaganath Kanakkassery 2df4bf6237 Bluetooth: RFCOMM: Implement TX flow control
Data sent by user will be queued in a FIFO. A TX fiber will be
started for each DLC which process this FIFO and write to L2CAP.
Fiber will sleep in two scenarios - no buffer in FIFO, no TX
credit. Credit is handled using semaphore. So if credit is 0
then fiber will wait on semaphore and will be scheduled when
it receives credit.

Change-Id: Id6e796eed594b28d6fb6e4259d3ed52634db9335
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 07:22:32 +00:00
Vinayak Chettimada d72b06da56 Bluetooth: GATT: Fix ccc cfg leak
ccc cfg is allocated when a peer updates a ccc value. This
fix will retain a cfg only if the new value is not default.

Change-id: I586082818145e43c771a6fccdb0bf2b3cecdd30c
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2016-09-07 05:19:45 +00:00
Vinayak Chettimada 73808e25d6 Bluetooth: GAP: Support multiple peripheral role connections
Fix the use of BT_DEV_KEEP_ADVERTISING and BT_DEV_ADVERTISING
so as to permit multiple peripheral role connections if the
controller supports Bluetooth Spec. v4.2 LE Topology.

Change-Id: Ia363181754cb788c13e9050e5fe5416201593c07
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2016-09-07 08:17:26 +03:00
Carles Cufi 49583b10d0 Bluetooth: HCI: Rename cmd complete struct
For consistency, add the bt_ prefix to
hci_evt_cmd_complete.

Jira: ZEP-726

Change-Id: I0deb9f12913991bf52ccffc8c85b86c83da1c045
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2016-09-07 08:17:26 +03:00
Luiz Augusto von Dentz 4f418a6b42 Bluetooth: GATT: Fix unaligned accesses
Use net_buf helper whenever accessing data by reference.

Change-Id: I3c7eb3af33a3d22741f73c094fb4a39e3e3d3440
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-09-07 08:17:26 +03:00
Kaustav Dey Biswas 68e58af67e Bluetooth: UUID: Add 32bit UUID support
This adds helper support for handling 32bit UUIDs

Change-Id: I4874b5f092bdbe30039b8031485bf856e4268f2a
Signed-off-by: Kaustav Dey Biswas <kaustav.d.biswas@intel.com>
2016-09-07 08:17:26 +03:00
Johan Hedberg 3b61beca20 Bluetooth: GATT: Fix unaligned access to CCC value
The CCC value behind the 'buf' pointer in bt_gatt_attr_write_ccc() may
not be appropriately aligned. It should therefore be accessed with
sys_get_le16() instead of sys_le16_to_cpu(). This also eliminates the
need of a separate uint16_t helper variable in the function.

Change-Id: I93d50f894e877f25ec6ed2f576cf6bf6d440190b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-09-07 08:17:26 +03:00
Vinayak Chettimada 1553ccc492 Bluetooth: Add LE read supported states
To fully support BT Spec. v4.2 LE Topology use LE read supported
states HCI command to find the supported states in the
controller.

Change-id: I6b4cf4cbefdff44e51bb0a4242e0aef3755f43db
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2016-09-07 08:17:26 +03:00
Jaganath Kanakkassery ca938e0dcd Bluetooth: RFCOMM: Fix BT_RFCOMM_BUF_SIZE to include FCS and len
Profiles uses this helper to allocate net buf, so it should include
2 byte length in RFCOMM header and FCS which will be appended in the
tail by RFCOMM.

Change-Id: I0118eb9b0e0ab1daa9267c165af62bb50f1575d9
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 08:17:26 +03:00
Jaganath Kanakkassery 6ffbf795ce Bluetooth: RFCOMM: Introduce Kconfig for max L2CAP MTU
Intorduces CONFIG_BLUETOOTH_RFCOMM_L2CAP_MTU which sets default as
CONFIG_BLUETOOTH_L2CAP_IN_MTU since it will make sure that RFCOMM
frames can be fit in ACL buffer to avoid fragmentation and at the
same time profiles can utilize the size of ACL buffer while configuring
RFCOMM MTU.

Once fragementation is handled, this can be configured to higher values
based on the profiles supported and its L2CAP PDU size requirement.

The maximum value possible is 32676 which is max RFCOMM frame size
given in the spec.

Change-Id: I57e178ea4da846243067c3e072d1f4c5536a3ee3
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 08:17:26 +03:00
Szymon Janc 68adceed5e Bluetooth: Move reading extended features to BR/EDR section of init
Those are needed only for BR/EDR and in fact was read was never issued
on LE only system due to pages count being 1 in such case.

Change-Id: I8facb77edb9cd03b392034423d8bb261f685b725
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-09-07 08:17:26 +03:00
Jaganath Kanakkassery 6198f07637 Bluetooth: RFCOMM: Introduce helper to create rfcomm pdu
Profiles can use this helper to create buffer which reserves the
headroom for rfcomm, l2cap and acl headers

Change-Id: I22f97b54423d66fe0c133a8e9903b652fb6a6854
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 08:17:26 +03:00
Vinayak Chettimada f77d06ae09 Bluetooth: GATT: Fix notifications to non-bonded peers
GATT implementation fixed so that two or more non-bonded peers
can now independently enable/disable notification and/or
indications; and subsequently receive them too.

Change-id: Ifae78297b6ba13f8ea3db58694302bb7f3449e97
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2016-09-07 08:17:26 +03:00
Johan Hedberg 91c7d938e3 Bluetooth: Kconfig: Be consistent with the use of tabs vs spaces
The most common convention is a space between "config" and the
variable name.

Change-Id: I0f97d5fee56b7db1808dcf07f21016b11f821fa3
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-09-07 08:17:26 +03:00
Jaganath Kanakkassery 5d8f6bf2eb Bluetooth: Kconfig: Add default for L2CAP_IN_MTU if BREDR is enabled
Currently set value as 200 since the HFP needs atleast 132 for CIND
response. AVDTP requirement is less that that and SDP protocol can
handle partial responses.

Note that currently only A2DP offload is considered and for non offload
case (which will need a seperate Kconfig anyway) another default will be
required.

Change-Id: Ief0854365ec47baf754b0a657203e1dc93f0d154
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 08:17:26 +03:00
Johan Hedberg 9966337daf Bluetooth: ATT: Fix usage of unsupported %zu format specifier
The Zephyr libc doesn't currently support %zu (it just produces
garbage), so use %u instead.

Change-Id: Ifcaaec79e21f600f00a9336b5267d2d1654adfd7
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-09-07 08:17:26 +03:00
Johan Hedberg 50318d2e4f Bluetooth: Clean up feature test macros
The lmp_*_capable() macros were neither following the appropriate name
space (BT_*) nor the appropriate style (macros should be upper-case).
Introduce a new BT_FEAT_TEST() macro which gives a clearer mapping to
the feature tables found in the core specification. Each specific
feature test macro is now also named with the appropriate BT_FEAT_*
prefix.

Change-Id: Ia6b18b066927908f9bda646e737e63d46a1d17df
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-09-07 08:17:26 +03:00
Johan Hedberg 8d6b12f235 Bluetooth: Fix feature page count for single-mode configuration
Single-mode controllers only have features page 0 (plus the LE
features), so allocating three pages in struct bt_dev is a waste of
space.

Change-Id: Idad73ded12bd153776019d0e5f8adbdb74724845
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-09-07 08:17:26 +03:00
Johan Hedberg 0af62d309f Bluetooth: Fix reading local features
Page 0 should be read with the "non-ext" HCI command whereas pages 1-n
with the extended features command (and only if the controller
supports extended features).

Change-Id: I1ddddd367e6883eb83e98983b545f3ffb6159e97
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-09-07 08:17:26 +03:00
Johan Hedberg 00eda80c59 Bluetooth: Make lmp_ext_feat_capable() more generic
Make is possible to use lmp_ext_feat_capable() both for local as well
as remote features.

Change-Id: I05bb6a25303c0dd2f5e0bbc4f7f412210f668aa3
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-09-07 08:17:26 +03:00
Szymon Janc 29cbaa864d Bluetooth: Enable Secure Connections if supported
Enable BR/EDR Secure Connections if Write Secure Connections Host
Support Command is supported in controller.

Change-Id: Ic0c989217be3cd95e5c0ce1ae2b18d3557c774b8
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-09-07 08:17:26 +03:00
Szymon Janc a5ab11708e Bluetooth: Read local extended features on init
Use Read Local Extended Features command to read local features and
extended local features on init.

Change-Id: I4c8594783895f439af36214881aeff24e116e783
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-09-07 08:17:26 +03:00
Szymon Janc 0bb0acc8a7 Bluetooth: Add support for P256 Link Keys
If P256 Link Key is received in Link Key notification event is should
be marked appropriately.

Change-Id: I09c2f5560d95dd360ef046330e5d85451b02821c
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-09-07 08:17:26 +03:00
Szymon Janc d48f19d3cc Bluetooth: Refactor Link Key notification event handling
Make sure that Link Key flags are always synced with key type received
in event. Also make sure that no garbage data is stored in key value.

Change-Id: I06d91da19a7c3497a3051d66f43c0d22f24f5e7d
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-09-07 08:17:26 +03:00
Arkadiusz Lichwa b082216e2f Bluetooth: L2CAP: Implement connect command on BR/EDR
Adds functionality to do connect to remote PSM. Connecting to remote
PSM other than SDP when both support SSP involves raising security
to at least BT_SECURITY_MEDIUM before any CoC traffic on L2CAP layer.
If connection response is send back with status 'pending' it means
remote doing additional job, so restarts RTX timer. If the command
timer is fired detach the apps channel from connection and make it
ready for reuse.

Change-Id: I81f57bc2f5738754f872ce52cb25027db6db5ccf
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-09-07 08:17:26 +03:00
Jaganath Kanakkassery f598f3f3f6 Bluetooth: RFCOMM: Implement send data API
Sends the data to l2cap after adding rfcomm header. Profile should
reserve the head room for rfcomm, l2cap and hci headers. Data length
should not be more than dlc mtu.

Flow control is not included in this patch

< ACL Data TX: Handle 256 flags 0x00 dlen 38
      Channel: 64 len 34 [PSM 3 mode 0] {chan 0}
      RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
         Address: 0x09 cr 0 dlci 0x02
         Control: 0xef poll/final 0
         Length: 30
         FCS: 0x40
        ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
        ff ff ff ff ff ff ff ff ff ff ff ff ff ff 40

Change-Id: Ib97dbf85e236a5f75fda6037bb75bc6be00b9dc7
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 08:17:26 +03:00
Johan Hedberg 3931b402e8 Bluetooth: Kconfig: Remove unnecessary default conditionals
There should always be one unconditional default and then a
conditional for each exception.

Change-Id: If1043c70eaae631c0a46c0af065a77199eb8e91b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-09-07 08:17:26 +03:00
Jaganath Kanakkassery cb3120d440 Bluetooth: L2CAP: Disable fragmentation of rx pdu
Currently if rx mtu is more than ACL in buffer size, then controller
fragments the data (if its more than buffer size) but recombination
in host is failing because of buf limiation (and seeing below error)
"Not enough buffer space for L2CAP data" in bt_conn_recv()

Change-Id: Iac0455eb1848fa228fce88fec9810d20542b0759
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 08:17:26 +03:00
Luiz Augusto von Dentz 50997f2ccd Bluetooth: GATT: Add queuing support
This adds queueing support for requests that requires a response making
it simpler to use the API. The storage is keep in the parameters of the
request so it is up to the application to define how many can be queued
but in case the application don't want a request to block waiting for
a buffer it can use BLUETOOTH_ATT_REQ_COUNT to control the available
buffers which is recommended in case the requests will be sent from the
RX fiber.

Change-Id: I407c3982a7ecdc4a9eff7172d9d0addd46949783
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-09-07 08:17:26 +03:00
Szymon Janc 5ff76656b0 Bluetooth: Fix typo in code comment
Change-Id: Ic1901fd6b8ab6c2e8f4dc20a60d29e6f19671fef
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-09-07 08:17:26 +03:00
Jaganath Kanakkassery febdf2dc0b Bluetooth: RFCOMM: Fix cr bit of address in MSC response
cr bit of address in MSC should be always 1 irrespective of whether it
is command or response. Command/Response would be identified by cr bit
of msg type in UIH

Change-Id: I8e8b8446fa98aa07269953cfb6e54be915d4aba7
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 08:17:26 +03:00
Arkadiusz Lichwa 1c34f1e322 Bluetooth: L2CAP: Fix reset channel state context
Since now CoC on each transport has registered own 'destroy' handler
it can be used to reset per transport L2CAP channel context. Then when
bt_l2cap_chan_del() API is called there's no more need to use
preprocessor to handle reset channel's state.

Change-Id: I1abb5d380a31ec54e2b6613d994ffdb0f94b93a5
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-09-07 08:17:26 +03:00
Arkadiusz Lichwa 0569ef32b9 Bluetooth: L2CAP: Refactor connection security handler
Makes main security handler verifying incoming connection request on
BR/EDR transport to be more descriptive and readable. Its output
result is now more fine-grained.

Change-Id: Ifc3960bd16219e92f6e61700c61605cf05e4d6d3
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-09-07 08:17:26 +03:00
Jaganath Kanakkassery 407013f3c7 Bluetooth: RFCOMM: Handle data and credit from peer
Data is transferred in UIH frame to a valid dlci. In this case the
meaning of PF bit is different, if PF bit is 1 then credit is there
in the frame otherwise no credit (only user data). So basically UIH
frame to a valid dlci can be "Only data, Only credit, both credit and
data"

Only credit
> ACL Data RX: Handle 256 flags 0x02 dlen 9
      Channel: 64 len 5 [PSM 3 mode 0] {chan 0}
      RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
         Address: 0x0b cr 1 dlci 0x02
         Control: 0xff poll/final 1
         Length: 0
         FCS: 0x86
         Credits: 33
        86

Only data
> ACL Data RX: Handle 256 flags 0x02 dlen 9
      Channel: 64 len 5 [PSM 3 mode 0] {chan 0}
      RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
         Address: 0x0b cr 1 dlci 0x02
         Control: 0xef poll/final 0
         Length: 1
         FCS: 0x9a
        ff 9a

Change-Id: Iaa48f9aa022f33e1a1217f19dc59ce761cfeac74
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 08:17:26 +03:00
Jaganath Kanakkassery d6af0ef091 Bluetooth: RFCOMM: Perform MSC transaction after dlc
MSC (Modem status command) is used to convey RS-232 control and break
signals. This shall be sent prior to any user data after dlc. Remote
also would have sent it which is handled in this patch

This has meaning only if a port emulation entity is there on top (which
is not there in zephyr right now). So currently v24 signal is hard
coded like below.
DV = 1 IC = 0 RTR = 1 RTC = 1 FC = 0 EXT = 0

< ACL Data TX: Handle 256 flags 0x00 dlen 12
      Channel: 64 len 8 [PSM 3 mode 0] {chan 0}
      RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
         Address: 0x01 cr 0 dlci 0x00
         Control: 0xef poll/final 0
         Length: 4
         FCS: 0xaa
         MCC Message type: Modem Status Command CMD (0x38)
           Length: 2
           dlci 2
           fc 0 rtc 1 rtr 1 ic 0 dv 1
> ACL Data RX: Handle 256 flags 0x02 dlen 12
      Channel: 64 len 8 [PSM 3 mode 0] {chan 0}
      RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
         Address: 0x03 cr 1 dlci 0x00
         Control: 0xef poll/final 0
         Length: 4
         FCS: 0x70
         MCC Message type: Modem Status Command CMD (0x38)
           Length: 2
           dlci 2
           fc 0 rtc 1 rtr 1 ic 0 dv 1
< ACL Data TX: Handle 256 flags 0x00 dlen 12
      Channel: 64 len 8 [PSM 3 mode 0] {chan 0}
      RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
         Address: 0x01 cr 0 dlci 0x00
         Control: 0xef poll/final 0
         Length: 4
         FCS: 0xaa
         MCC Message type: Modem Status Command RSP (0x38)
           Length: 2
           dlci 2
           fc 0 rtc 1 rtr 1 ic 0 dv 1
> ACL Data RX: Handle 256 flags 0x02 dlen 12
      Channel: 64 len 8 [PSM 3 mode 0] {chan 0}
      RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
         Address: 0x03 cr 1 dlci 0x00
         Control: 0xef poll/final 0
         Length: 4
         FCS: 0x70
         MCC Message type: Modem Status Command RSP (0x38)
           Length: 2
           dlci 2
           fc 0 rtc 1 rtr 1 ic 0 dv 1

Change-Id: Iab06f12de2f2357485309eb622c8c5e13db7011c
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 08:17:26 +03:00
Jaganath Kanakkassery b773edc053 Bluetooth: RFCOMM: Move rfcomm_make_uih_msg() up
It has to be used to send MSC from rfcomm_dlc_connected()

Change-Id: I96fa161359c54d31e8cccb9fa3aa749465308f61
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 08:17:26 +03:00
Jaganath Kanakkassery d363b6896c Bluetooth: RFCOMM: Handle incoming dlc request
Handles SABM request to a valid dlci and sends UA response. If PN is
not negotiated for this dlci prior, then accept callback will be invoked
to profile. Dlc will be connected at this point and user can start
sending data over this dlc

> ACL Data RX: Handle 256 flags 0x02 dlen 8                                                                                                                                        [hci0] 210.138443
      Channel: 64 len 4 [PSM 3 mode 0] {chan 0}
      RFCOMM: Set Async Balance Mode (SABM) (0x2f)
         Address: 0x0b cr 1 dlci 0x02
         Control: 0x3f poll/final 1
         Length: 0
         FCS: 0x59
< ACL Data TX: Handle 256 flags 0x00 dlen 8                                                                                                                                        [hci0] 210.140102
      Channel: 64 len 4 [PSM 3 mode 0] {chan 0}
      RFCOMM: Unnumbered Ack (UA) (0x63)
         Address: 0x0b cr 1 dlci 0x02
         Control: 0x73 poll/final 1
         Length: 0
         FCS: 0x92

Change-Id: I6bf5efb811d3ca5b106c9dff67d3a50a74818956
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 08:17:26 +03:00
Jaganath Kanakkassery ab96eae52d Bluetooth: RFCOMM: Handle PN request
PN (Parameter negotiation) is used to negotiate parameters like mtu.
Initial credit for flow control is also sent in PN. If the dlci to which
PN requested is not found in the dlc list then it will be treated as
incoming dlc request and accept callback will be called to profile.
Dlc mtu has to be set by profile (before it returns dlc) which will be
negotiated with remote. But the final mtu will be min of mtu provided
by profile, mtu sent by remote, and session mtu

> ACL Data RX: Handle 256 flags 0x02 dlen 18                                                                                                                                       [hci0] 210.108444
      Channel: 64 len 14 [PSM 3 mode 0] {chan 0}
      RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
         Address: 0x03 cr 1 dlci 0x00
         Control: 0xef poll/final 0
         Length: 10
         FCS: 0x70
         MCC Message type: DLC Parameter Negotiation CMD (0x20)
           Length: 8
           dlci 2 frame_type 0 credit_flow 15 pri 7
           ack_timer 0 frame_size 122 max_retrans 0 credits 7
< ACL Data TX: Handle 256 flags 0x00 dlen 18                                                                                                                                       [hci0] 210.111452
      Channel: 64 len 14 [PSM 3 mode 0] {chan 0}
      RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
         Address: 0x01 cr 0 dlci 0x00
         Control: 0xef poll/final 0
         Length: 10
         FCS: 0xaa
         MCC Message type: DLC Parameter Negotiation RSP (0x20)
           Length: 8
           dlci 2 frame_type 0 credit_flow 14 pri 0
           ack_timer 0 frame_size 30 max_retrans 0 credits 7

Change-Id: Ifd466db6b3b868d04e38db02ebad6e47ab2da030
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 08:17:26 +03:00
Jaganath Kanakkassery 7eec8a4442 Bluetooth: RFCOMM: Handle signalling connection request
Handles the SABM request to dlci 0 and sends UA response which makes
session state as CONNECTED. Session mtu is set as min of l2cap tx and
rx mtu since in rfcomm mtu is symmetric (unlike L2CAP). This means that
mtu of all the dlcs should be less than or equal to its session mtu so
that each rfcomm frame can be contained in single l2cap pdu.

> ACL Data RX: Handle 256 flags 0x02 dlen 8                                                                                                                                        [hci0] 210.078442
      Channel: 64 len 4 [PSM 3 mode 0] {chan 0}
      RFCOMM: Set Async Balance Mode (SABM) (0x2f)
         Address: 0x03 cr 1 dlci 0x00
         Control: 0x3f poll/final 1
         Length: 0
         FCS: 0x1c
< ACL Data TX: Handle 256 flags 0x00 dlen 8                                                                                                                                        [hci0] 210.080586
      Channel: 64 len 4 [PSM 3 mode 0] {chan 0}
      RFCOMM: Unnumbered Ack (UA) (0x63)
         Address: 0x03 cr 1 dlci 0x00
         Control: 0x73 poll/final 1
         Length: 0
         FCS: 0xd7

This also inntroduces table and functions to calculate and
check FCS. These are taken from GSM 07.10 TS 101 369 V6.5.0

Change-Id: Ief5822b7f9350f50e700ff4f460c818a5a1068b7
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 08:17:26 +03:00
Jaganath Kanakkassery a816142687 Bluetooth: RFCOMM: Init buffer for outgoing signalling packets
Buffer size is currently set as rfcomm min mtu

Change-Id: Ie8fd3f1cef9d6d9b62d5aca272f0030181175460
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 08:17:26 +03:00
Andrei Emeltchenko 6ab1b9cdc4 Bluetooth: Add RAW API interface to Bluetooth
HCI RAW channel API is intended to expose HCI interface to the remote
entity. The local Bluetooth controller gets owned by the remote entity
and host Bluetooth stack is not used. RAW API provides direct access
to packets which are sent and received by Bluetooth HCI drivers.

Change-Id: I4ba2b7ca2c2b0d6c5de6ef1f231d1c5b82125e09
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-09-07 08:17:26 +03:00
Szymon Janc 017586707e Bluetooth: Set BR/EDR device name on init
This adds support for setting default BR/EDR name on init. For now
this is just static configuration but can be extended later on
to allow runtime configuration if requested.

< HCI Command: Write Local Name (0x03|0x0013) plen 248
        Name: Zephyr
> HCI Event: Command Complete (0x0e) plen 4
      Write Local Name (0x03|0x0013) ncmd 1
        Status: Success (0x00)

Change-Id: I59ecfc2be8e55c6f90cdb0f12c6fed7f7ce976f8
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-09-07 08:17:26 +03:00
Jaganath Kanakkassery 7859ffeab0 Bluetooth: RFCOMM: Implement Register Server channel API
Profiles can use this API to register the RFCOMM server channel.
DLC structure which represents individual connnection on a particular
server channel has to be defined in the profile and provide it in
accept callback.

Change-Id: I14e607ca65a29f29389deb2ac5d0658f5cd92883
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 08:17:26 +03:00
Jaganath Kanakkassery b4aa810f0c Bluetooth: RFCOMM: Initialize and register to L2CAP
Initialize RFCOMM layer and register PSM to L2CAP. RFCOMM session
which represents the signalling context is also defined. Only one
signalling context will be there per ACL connection and hence l2cap
chan object is embedded into session.

Change-Id: I9b0931b51753571f5da40c76f4b8a7d5f93546fb
Origin: Original
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 08:17:26 +03:00
Johan Hedberg 71680a6053 Bluetooth: Fix race condition when initializing ECC FIFO
First access to the ecc_queue may happen either from an application
task (calling bt_enable()) or from the internal ECC task. Since we
don't have control of this we need to do conditional initialization of
the FIFO.

Change-Id: I5c96782ec7a6f829da0fe15e13817934319381df
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-09-07 08:17:26 +03:00
Jaganath Kanakkassery 2f13527766 Bluetooth: L2CAP: Implement bt_l2cap_br_chan_send()
Sends the packet to HCI using bt_l2cap_send()

Change-Id: Iaec86ddc53adc632b597237a248acbd2e61fe4f6
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 08:17:26 +03:00
Vinayak Chettimada 8704406a84 Bluetooth: Fix race condition between ecc_send and ecc_task
Move initialization of ecc_queue from ecc_task into bt_hci_ecc_init,
so that calling ecc_send before ecc_task has no race condition and is
safe.

Change-Id: I775a1de3c5b6f56ae4ae37baa948ef19da6cee55
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2016-09-07 08:17:26 +03:00
Szymon Janc 3be711b17a Bluetooth: L2CAP: Make bt_l2cap_br_fixed_chan_register global
This will be used to register additional (ie SMP) BR/EDR fixed
channels and must be available for other modules.

Change-Id: Ie5d8ff5ccb6805379d6773254f4107434edaa076
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-09-07 08:17:26 +03:00
Szymon Janc 52d5966ac7 Bluetooth: L2CAP: Use BIT macro for supported BR/EDR fixed channels
There is no need for using extra mask define as BIT macro results in
better readability.

Change-Id: I95ac03f43274bfa5c571a6bfbc49a93513465bdf
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-09-07 08:17:26 +03:00
Szymon Janc cfb396955a Bluetooth: L2CAP: Remove mask from struct bt_l2cap_fixed_chan
There is no need to keep this info per channel. Information response
use fixed value so those were not used anyway.

Change-Id: I2e5d394f25075be12062394e4d9f2db4f133a796
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-09-07 08:17:26 +03:00
Szymon Janc c10d6156d6 Bluetooth: Fail on init if BR/EDR is enabled but not supported
For now if BR/EDR support is enabled we require chip to support it.
This is due to rest of the BR/EDR code doesn't do runtime check but
just assumes BR/EDR is there.

Change-Id: I26124a7f1a06cd65800c0b1b17842eb4a4ffb6cb
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-09-07 08:17:26 +03:00
Szymon Janc 945fbfe52b Bluetooth: SMP: Add self test for H6 function
This adds self test for H6 key derivation function based on sample data
from Core Specification Vol 3. Part H. Appendix D. D6.

Change-Id: I73eed5bfc6604bee0d1e81a23895f54ca6904807
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-09-07 08:17:26 +03:00
Szymon Janc d3bd10dda1 Bluetooth: SMP: Add support for Link Key derivation
This allows to derive BR/EDR Link Key from LE SC LTK so no further
BR/EDR pairing is needed to encrypt BR/EDR link with key as strong
as LTK.

Change-Id: Ie28e9ec7a250189b122f1bce291fa9468a758614
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-09-07 08:17:26 +03:00
Szymon Janc 66f523bf2e Bluetooth: SMP: Refactor keys distribution bitfields
This is in preparation for adding Link Key distirbution bit which
depends on BR/EDR support.

Change-Id: I156dcae1c3488cc7fc5cc3514a048affa89f449b
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-09-07 08:17:26 +03:00
Johan Hedberg bf098dff6d Bluetooth: monitor: Fix condition for disabling UART interrupts
If interrupt-driven UARTs are not use it makes no sense to try to
disable interrupts (in fact the build will fail).

Change-Id: Ib1e020895ced08183719a4cedd703d87e922b067
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-09-07 08:17:26 +03:00
Szymon Janc 28e47f60a4 Bluetooth: SMP: Add helper for notifying pairing complete
This will allow to have a single place where actions on pairing
complete would be called.

Change-Id: I7d097111e9643e98a168b6acf8d88ebb92b484a0
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-09-07 08:17:26 +03:00
Arkadiusz Lichwa 5287f4c49a Bluetooth: L2CAP: Add RTX timer for 'disconnect' command
Gets armed disconnect channel command on BR/EDR transport with RTX timer.
There's no need to implcitly cancel the timer in the response
since it's always called by channel 'destroy' handler indirectly.

Change-Id: I6e0a777be670f49a517b1145b2e012831214c539
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-09-07 08:17:26 +03:00
Arkadiusz Lichwa 06972f42be Bluetooth: L2CAP: Add RTX timer for 'configuration' command
Starts RTX timer when local host initiates configuration request
contract. Releases the timer when gets the response.

Change-Id: Ieb63fbce39542a5e7fad7792d8b5f1bd7d4e96a3
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-09-07 08:17:26 +03:00
Arkadiusz Lichwa 5f15f50d29 Bluetooth: L2CAP: Add RTX timer for 'get info' command
Starts the timer when 'get info' command was issued followed by
connection is made and stops it when gets back the response with no
timeout in the middle. Such pending timer need to be cancelled in any
case when ACL connection is dropped during pending command in question.
In a case the timeout gets fired skip the channel cleanup since
'get info' command has BR/EDR signal channel context and the one needs
to be operational when transport connection is alive.

Change-Id: I319becf3330f9be5633c15e5b39d77a619495494
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-09-07 08:17:26 +03:00
Arkadiusz Lichwa ad83797a6d Bluetooth: L2CAP: Initialize & cleanup RTX timer on BR/EDR
Adds generic RTX timer handler to BR/EDR L2CAP layer and adjusts its
initialization and cleanup resources using proper channel management
functions.

Change-Id: I87d320b4f34d4d0f28b8e48d01ebfbcc5adeadf0
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-09-07 08:17:26 +03:00
Szymon Janc b9610c392b Bluetooth: Mark AES encrypted BR/EDR link as FIPS security level
If enctyption changed event is recevied with value 0x02 it means
that AES-CCM is used for BR/EDR encryption. If link is also
authenticated then security level is FIPS.

Change-Id: I33cd1b87c6e4fb359018739e76ac4e72a777128e
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-09-07 08:17:26 +03:00
Szymon Janc cfe74b33fc Bluetooth: SMP: Remove not needed stubs from NULL backend
Those are not needed as calls are always under proper ifdefs.

Change-Id: I460a77af0e0d693bbecb6120e39ed6190cf49b72
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-09-07 08:17:26 +03:00
Szymon Janc 60691c4650 Bluetooth: Split keys into LE and BR/EDR specific storage
This make LE and BR/EDR keys store in separate storages. This is
to simplify handling of dual mode device handling where identity
information are distributed after LTK. BR/EDR has only one key
(Link Key) so this transport specific code can be further simplified.

Change-Id: I8f45d4491ce613aaac11f1d60cf42c38fc3eceec
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-09-07 08:17:26 +03:00
Andrei Emeltchenko 709111b813 Bluetooth: Simplify configuration and fix warnings
Fixes the warnings:
...
net/bluetooth/Kconfig:48:warning: defaults for choice values not
supported
warning: (BLUETOOTH) selects BLUETOOTH_LE which has unmet direct
dependencies (BLUETOOTH && BLUETOOTH_STACK_HCI)
...

Change-Id: I039a9e0e90ce4cb1732c9c764e2db441ba59660a
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-09-07 08:17:26 +03:00
Arkadiusz Lichwa cfcb1d20c4 Bluetooth: L2CAP: Make common RTX commands timer
There's a need to add timeout support for control commands on BR/EDR
transport. So far RTX timer feature has application to control protocols
only on LE. Here 'rtx_work' member is moved to common L2CAP context to
safe memory footprint and prepare L2CAP layer to handle RTX timeout
in BR/EDR context.

Change-Id: I9938268a5c4e5dd1f980bb3ec8697d0209c24065
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-09-07 08:17:26 +03:00
Rohit Grover 769e2541d1 net: revert tcpip_poll_tcp() to not require a data_buf
tcpip_poll_tcp() was changed with commit 61edc68c to take on a
data_buf parameter, which was then processed as the primary
buffer. That change led to incorrect behaviour where the handling
of the first data buffer on a connection got mixed with the SYN buf.
It is no longer clear why tcpip_poll_tcp() was modified with the
change 61edc68c originally. Reverting the modification to
tcpip_poll_tcp() leads to much better handling of TCP data; and
also obviates another pull-request submitted recently:
https://gerrit.zephyrproject.org/r/#/c/4226.

Change-Id: I947c0991495c538c41e6581c8d360526b1bb89ad
Signed-off-by: Rohit Grover <rohit.grover@arm.com>
2016-09-06 15:11:03 +00:00
Marcus Shawcroft 01f59b6d9e net: uip: Fix udp_socket_process receive data callback buffer handling.
Adjust the data pointer passed to a udp_socket_register() registered
callback to point to the udp data contents rather than the header
information.

Change-Id: Ib90eee91e0ec4d0290517fee7b929d39ce3e07c6
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-09-06 15:10:33 +00:00
Marcus Shawcroft 624cf83772 net: Fix code formatting
Re-instate correct code formatting.  No functional change.

Change-Id: If7c61214c07c6573ec25022ad47f83cc1b29e24c
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-09-06 15:10:12 +00:00
Marcus Shawcroft b92d10d879 net: uip: Fix compile fail with stats enabled, tcp disabled.
Add missing preprocessor conditional around statistics update.

Change-Id: I3e55b1512e913b2e9a60d0ab56264439ca417a23
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-09-06 15:09:58 +00:00
Tomasz Bursztyka 8a574fdd67 net: contiki: simplerdc: Fix an uninitialized variable warning
If retries are 0 (which should never be), ret will not be initialized.

Change-Id: I8ef9a2ccbf89191e48d407fdb1292554fa8f15d9
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-09-06 09:05:37 +00:00
Marcus Shawcroft 710e82faca net: Tighten ETHERTYPE decode.
The uip stack processes received packets by calling net_recv() but
does not discard packets marked with an ethertype other than IPv4 or
IPv6 resulting in confusion further up the stack.  Discard non IPv4/v6
packets from further processing by the IP stack.

Change-Id: Ic62f8d12b02da197b1abc774a581bff30330080c
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-08-30 10:48:48 +00:00
Andrew Boie ee5c0fb771 net: fix incorrect printk() usage
Change-Id: Ie8b61b6bd7e207664b31b1da64c44c7d04ccfd87
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-08-28 07:47:28 -04:00
Anas Nashif 78ce02f86d quark_se_devboard: We do not support capabilities via Kconfig yet
This will lead to conflicts and warning coming from Kconfig, so just
whitelist the board in the samples where this hardware is supported

Jira: ZEP-739

Change-Id: I4a2f3bdcfdb44fc75df0e272c237789ee16e0de1
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-08-25 06:12:00 -04:00
Jaakko Hannikainen db493450ac net: ip: Fix compiling with 15.4
Kconfig allows selecting NETWORKING_WITH_15_4_TI_CC2520 even if the
current board doesn't support it, and also selects it by default. This
breaks building the 15.4 sample with qemu_x86. Add a config option for
having CC2520 support and enable the choise only if it is available.

In addition, remove unused function from iee802154 code, as it now
fails the tests.

Jira: ZEP-697

Change-Id: Ib082f82acdd0f86d3306bbd3bb827f61b0fd0be1
Signed-off-by: Jaakko Hannikainen <jaakko.hannikainen@intel.com>
2016-08-23 13:13:59 +00:00
David B. Kinder d748577706 doc: Fix terminology in Kconfig files for 'platform'
Completing the terminology change started with change 4008
by updating the Kconfig files processed to produce the
online documentation, plus header files processed by
doxygen.  References to 'platform' are change to 'board'

Change-Id: Id0ed3dc1439a0ea0a4bd19d4904889cf79bec33e
Jira: ZEP-534
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2016-08-18 21:17:29 +00:00
Jaakko Hannikainen a8cd2ff368 net: Add NULL check to eventhandler
The eventhandler gets called with NULL buf, but it can't handle it. Add
a NULL check to prevent crashing.

Change-Id: Id16c2aa093a145e0442dfc61dd0b6e1b81b701f5
Signed-off-by: Jaakko Hannikainen <jaakko.hannikainen@intel.com>
2016-08-12 15:43:14 +03:00
Szymon Janc 079ba81fd1 Bluetooth: Fix typos in code comments
Change-Id: I38fd93796f4f5efb361ed85a8f9a2f7804af61cf
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-08-11 17:43:36 +00:00
Szymon Janc 553a78b4f5 Bluetooth: Remove not needed BT_KEYS_BR_LEGACY flag
We map legacy and SSP link keys to equivalent security levels so there
is no need for storing if key is legacy. This flag was never used
anyway.

Change-Id: I6867f43a1ed132f67a564de34436cf83b922a138
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-08-11 17:38:01 +00:00
Szymon Janc 89228d890c Bluetooth: Remove redundant ifdefs from keys.h
There is no need to ifdef type definitions and whole file is already
under (CONFIG_BLUETOOTH_SMP) || defined(CONFIG_BLUETOOTH_BREDR).

This improves file readability.

Change-Id: I9bcceb01023f75e016ad71873f87b3393a09fe26
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-08-11 17:38:00 +00:00
Szymon Janc b944c0bd65 Revert "Bluetooth: SMP: Workaround LE SC bug in iOS"
This reverts commit 15c1fed5b6.

This workaround is no longer needed as it was verified that pairing
succeed without it. Also I'm no longer sure if initial pairing issue
was due to missing bit in key distirbution field or if it was due to
iOS already had device with this address paired (ie removing device
bonding from settings application fix the problem).

Change-Id: I6d69b9afb04afc83139d57d2dffe1b62d40afe5b
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-08-10 15:29:20 +00:00
Szymon Janc 39aeb18f5f Bluetooth: SMP: Fix non-ASCII characters in comments
Change-Id: I4e3f7e7ea97e90e49e37e3ba9d6fbc1a80df968f
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-08-10 15:28:00 +00:00
Andrei Emeltchenko 8703bd8132 Bluetooth: trivial: Remove extra line
Change-Id: I24fa104a5c5fab20b133102700604cc254d606ac
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-08-10 15:27:37 +00:00
Jaakko Hannikainen f77191976a net: contiki: Fix timer callback condition
etimer_expired will return true only once. This means periodic timers in
the netstack won't get to run since etimer_process calls etimer_expired
for all timers in the stack.

Jira: ZEP-475

Change-Id: I28da638789b0604f9dd0a0598a7fa590e6b0a746
Signed-off-by: Jaakko Hannikainen <jaakko.hannikainen@intel.com>
2016-08-10 15:25:59 +00:00
Leyi Rong e72a71a53d net: uip: Fix uip_udp_conns traverse loop in uip_process
the traverse step length should be sizeof(struct uip_udp_conn)
in uip_process when matching the right uip_udp_conn for net_buf

Change-Id: I33c0499582a96e5031ba94f147ff2376726b3f9c
Signed-off-by: Leyi Rong <leyi.rong@intel.com>
2016-08-10 14:57:02 +00:00
Leyi Rong dcafc14162 net: net_context: Fix local ipv4 addr compare with INADDR_ANY
net_context_get will obtain ip addr from uip_hostaddr when the local
ipv4 addr is set to INADDR_ANY. So local_addr->in_addr.s_addr[0] is
represented for the local ipv4 addr content.

Change-Id: Ie6d77f27bdde5ea8568428a61b129eccb253df0a
Signed-off-by: Leyi Rong <leyi.rong@intel.com>
2016-08-08 20:57:17 +00:00
Jaakko Hannikainen 2652c0e5a9 net: contiki: Add NULL check to neighbor polling
The function is getting called with NULL bufs, so uip_len cannot be
called on them. The stack further down handles NULL buffers correctly.

Jira: ZEP-474

Change-Id: I85fb045ec76bea2a83c64d0f72eabba4e661f5f4
Signed-off-by: Jaakko Hannikainen <jaakko.hannikainen@intel.com>
2016-08-02 05:25:59 +00:00
Jaakko Hannikainen 0766d3b921 net: contiki: Prevent a null dereference
When first starting the board, uip_connr may be NULL. This causes an
invalid pointer dereference. Add a NULL check.

Change-Id: Ia5d9897038a22fe44aab5106dd6b84c5a358512d
Signed-off-by: Jaakko Hannikainen <jaakko.hannikainen@intel.com>
2016-07-29 18:05:45 +00:00
Tomasz Bursztyka 37405583d9 net: coap: Add a Kconfig option to enable/disable link format filters
This requires strstr() from minimal libc, thus requesting such extension
to be built relevantly.

Jira: ZEP-598
Change-Id: I943d8046b6165fbcebec9cbabd7b874b19160d48
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-07-29 17:33:53 +00:00
Ravi kumar Veeramally b325989ede net: Fix incorrect IP app data length
When application wants to send zero length data, packet is dropped.
And uip_appdatalen is wrongly assigned with total IP packet length.

Jira: ZEP-575

Change-Id: I7f714cbef74dc28b83db7a776ef80a3026ae120e
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-07-28 20:58:01 +00:00
Flavio Santes e6ffc0ed28 crypto: Update tinycrypt source files
Update Zephyr's tinycrypt to version 2.0. This new version adds support
for ECC_DH, ECC_DSA, CMAC, & CTR_PRNG.

The following doxygen documentation typos were detected and fixed:

- ctr_prng.h:84 change plen by pLen,
- ctr_prng.h:109 change entropylen by entropyLen,
- sha256.h:110 change Sha256 by s.

ecc_dh.h is also modified to fix the discrepancy of ecc_make_key
definition and declaration.
See https://gerrit.zephyrproject.org/r/#/c/1982/

TC_FAIL and TC_SUCCESS defines are renamed in this new version of
tinycrypt, so net/bluetooth/hci_core.c, net/bluetooth/hci_ecc.c and
net/bluetooth/smp.c are also updated to reflect those changes.

Origin: https://github.com/01org/tinycrypt/archive/v0.2.0.tar.gz

Jira: ZEP-590

Change-Id: I85f4f0ab61d9b0be6a60897e2b96f245dd8c51a8
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-07-27 21:33:42 +00:00
Johan Hedberg 9915378e8c Bluetooth: Take advantage of ATOMIC_DEFINE atomic_t based flags
Using ATOMIC_DEFINE removes the risk of the number of flags growing
past 32 and thereby causing an overflow of the flags variable.

Change-Id: Id3679a5a1b567b2681bc5bbd6384ed88478a32d6
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-07-27 17:14:59 +00:00
Luiz Augusto von Dentz 5194d2fb06 Bluetooth: GATT: Remove unused struct
prepare_write_data is no longer need since the ATT layer is now
responsible to queue the prepare writes using regular writes to commit
the data instead.

Change-Id: I8e35307a0489505b1475cdf31773c65a51165539
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-07-27 15:28:38 +03:00
Luiz Augusto von Dentz 78881ebd3b Bluetooth: GATT: Fix not passing params in the write callback
Write callback shall receive the params given in the request so the
struct itself needs to be passed.

Change-Id: Ia039c25c99efb57e4c441561067d0398d9e6277c
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-07-26 15:26:15 +03:00
Jaakko Hannikainen e6a34f8175 net: buf: Fix compiling with debug options
The small typo in the debug printed variable prevents compiling when
using debug printing in the netbuf code.

Change-Id: I6cafa82e7f5629e9021d7ad1a2130f2945b4f661
Signed-off-by: Jaakko Hannikainen <jaakko.hannikainen@intel.com>
2016-07-25 14:24:39 +00:00
Arkadiusz Lichwa ea5449dbcc Bluetooth: L2CAP: Add BR/EDR CoC channel disconnect
Implements CoC channel disconnect API initiated from local and handles
response to the disconnect request from remote.

Change-Id: I25f2495404cd405dc83ad56269e4897e53d602e6
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-07-25 14:24:04 +00:00
Arkadiusz Lichwa a49b9fcf57 Bluetooth: L2CAP: Handle BR/EDR configuration deferred by GAP
Marks successfuly allocated channel during incoming connection
request to dedicated channel context flag. Introduced here ACCEPTOR
role on L2CAP layer helps then resolve channel CoC state context when
incoming connection setup is deferred by changed security on GAP caused
by local L2CAP channel requirement.

> ACL Data RX: Handle 12 flags 0x02 dlen 12                   [hci1] 108.666944
      L2CAP: Connection Request (0x02) ident 3 len 4
        PSM: 3 (0x0003)
        Source CID: 64
> HCI Event: Number of Completed Packets (0x13) plen 5        [hci1] 108.668572
        Num handles: 1
        Handle: 12
        Count: 2
< ACL Data TX: Handle 12 flags 0x00 dlen 16                   [hci1] 108.673002
      L2CAP: Connection Response (0x03) ident 3 len 8
        Destination CID: 64
        Source CID: 64
        Result: Connection successful (0x0000)
        Status: No further information available (0x0000)
< HCI Command: Host Number of Complet.. (0x03|0x0035) plen 5  [hci1] 108.673548
        Num handles: 1
        Handle: 12
        Count: 1
< ACL Data TX: Handle 12 flags 0x00 dlen 16                   [hci1] 108.674725
      L2CAP: Configure Request (0x04) ident 5 len 8
        Destination CID: 64
        Flags: 0x0000
        Option: Maximum Transmission Unit (0x01) [mandatory]
          MTU: 48
> HCI Event: Number of Completed Packets (0x13) plen 5        [hci1] 108.707579
        Num handles: 1
        Handle: 12
        Count: 2
> ACL Data RX: Handle 12 flags 0x02 dlen 16                   [hci1] 108.714206
      L2CAP: Configure Request (0x04) ident 4 len 8
        Destination CID: 64
        Flags: 0x0000
        Option: Maximum Transmission Unit (0x01) [mandatory]
          MTU: 560
> ACL Data RX: Handle 12 flags 0x02 dlen 18                   [hci1] 108.715442
      L2CAP: Configure Response (0x05) ident 5 len 10
        Source CID: 64
        Flags: 0x0000
        Result: Success (0x0000)
        Option: Maximum Transmission Unit (0x01) [mandatory]
          MTU: 48
< HCI Command: Host Number of Complet.. (0x03|0x0035) plen 5  [hci1] 108.720451
        Num handles: 1
        Handle: 12
        Count: 1
< ACL Data TX: Handle 12 flags 0x00 dlen 14                   [hci1] 108.720472
      L2CAP: Configure Response (0x05) ident 4 len 6
        Source CID: 64
        Flags: 0x0000
        Result: Success (0x0000)
< HCI Command: Host Number of Complet.. (0x03|0x0035) plen 5  [hci1] 108.722324
        Num handles: 1
        Handle: 12
        Count: 1
> HCI Event: Number of Completed Packets (0x13) plen 5        [hci1] 108.976574
        Num handles: 1
        Handle: 12
        Count: 1
> ACL Data RX: Handle 12 flags 0x02 dlen 12                   [hci1] 116.297981
      L2CAP: Connection Request (0x02) ident 5 len 4
        PSM: 5 (0x0005)
        Source CID: 65
< HCI Command: Authentication Requested (0x01|0x0011) plen 2  [hci1] 116.302176
        Handle: 12
> HCI Event: Command Status (0x0f) plen 4                     [hci1] 116.303129
      Authentication Requested (0x01|0x0011) ncmd 1
        Status: Success (0x00)
> HCI Event: Link Key Request (0x17) plen 6                   [hci1] 116.304127
        Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
< HCI Command: Host Number of Complet.. (0x03|0x0035) plen 5  [hci1] 116.304327
        Num handles: 1
        Handle: 12
        Count: 1
< ACL Data TX: Handle 12 flags 0x00 dlen 16                   [hci1] 116.305841
      L2CAP: Connection Response (0x03) ident 5 len 8
        Destination CID: 65
        Source CID: 65
        Result: Connection pending (0x0001)
        Status: Authentication pending (0x0001)
< HCI Command: Link Key Request Negat.. (0x01|0x000c) plen 6  [hci1] 116.306913
        Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
> HCI Event: Command Complete (0x0e) plen 10                  [hci1] 116.308125
      Link Key Request Negative Reply (0x01|0x000c) ncmd 1
        Status: Success (0x00)
        Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
> HCI Event: IO Capability Request (0x31) plen 6              [hci1] 116.309126
        Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
< HCI Command: IO Capability Request... (0x01|0x002b) plen 9  [hci1] 116.310177
        Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
        IO capability: DisplayYesNo (0x01)
        OOB data: Authentication data not present (0x00)
        Authentication: Dedicated Bonding - MITM required (0x03)
> HCI Event: Command Complete (0x0e) plen 10                  [hci1] 116.311125
      IO Capability Request Reply (0x01|0x002b) ncmd 1
        Status: Success (0x00)
        Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
> HCI Event: IO Capability Response (0x32) plen 9             [hci1] 116.331128
        Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
        IO capability: DisplayYesNo (0x01)
        OOB data: Authentication data not present (0x00)
        Authentication: Dedicated Bonding - MITM required (0x03)
> HCI Event: Number of Completed Packets (0x13) plen 5        [hci1] 116.483125
        Num handles: 1
        Handle: 12
        Count: 1
> HCI Event: User Confirmation Request (0x33) plen 10         [hci1] 116.516225
        Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
        Passkey: 798417
< HCI Command: User Confirmation Requ.. (0x01|0x002c) plen 6  [hci1] 123.541708
        Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
> HCI Event: Command Complete (0x0e) plen 10                  [hci1] 123.555708
      User Confirmation Request Reply (0x01|0x002c) ncmd 1
        Status: Success (0x00)
        Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
> HCI Event: Simple Pairing Complete (0x36) plen 7            [hci1] 131.484303
        Status: Success (0x00)
        Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
> HCI Event: Link Key Notification (0x18) plen 23             [hci1] 131.524232
        Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
        Link key: 9355f679935c4e602ac1cc8a56ba121a
        Key type: Authenticated Combination key from P-192 (0x05)
> HCI Event: Auth Complete (0x06) plen 3                      [hci1] 131.525244
        Status: Success (0x00)
        Handle: 12
< HCI Command: Set Connection Encrypt.. (0x01|0x0013) plen 3  [hci1] 131.527348
        Handle: 12
        Encryption: Enabled (0x01)
> HCI Event: Command Status (0x0f) plen 4                     [hci1] 131.528234
      Set Connection Encryption (0x01|0x0013) ncmd 1
        Status: Success (0x00)
> HCI Event: Encryption Key Refresh Complete (0x30) plen 3    [hci1] 131.552238
        Status: Success (0x00)
        Handle: 12
> HCI Event: Encryption Change (0x08) plen 4                  [hci1] 131.553240
        Status: Success (0x00)
        Handle: 12
        Encryption: Enabled with E0 (0x01)
< ACL Data TX: Handle 12 flags 0x00 dlen 16                   [hci1] 131.556727
      L2CAP: Connection Response (0x03) ident 5 len 8
        Destination CID: 65
        Source CID: 65
        Result: Connection successful (0x0000)
        Status: No further information available (0x0000)
< ACL Data TX: Handle 12 flags 0x00 dlen 16                   [hci1] 131.562063
      L2CAP: Configure Request (0x04) ident 6 len 8
        Destination CID: 65
        Flags: 0x0000
        Option: Maximum Transmission Unit (0x01) [mandatory]
          MTU: 64
> ACL Data RX: Handle 12 flags 0x02 dlen 16                   [hci1] 131.562733
      L2CAP: Configure Request (0x04) ident 6 len 8
        Destination CID: 65
        Flags: 0x0000
        Option: Maximum Transmission Unit (0x01) [mandatory]
          MTU: 245
> HCI Event: Number of Completed Packets (0x13) plen 5        [hci1] 131.567286
        Num handles: 1
        Handle: 12
        Count: 2
> ACL Data RX: Handle 12 flags 0x02 dlen 18                   [hci1] 131.568858
      L2CAP: Configure Response (0x05) ident 6 len 10
        Source CID: 65
        Flags: 0x0000
        Result: Success (0x0000)
        Option: Maximum Transmission Unit (0x01) [mandatory]
          MTU: 64

Change-Id: I04aab5a0511ba09693f96faeeb66eef53e66ce0e
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-07-25 14:23:12 +00:00
Arkadiusz Lichwa f8f9de079a Bluetooth: L2CAP: Reset CoC channel state during cleanup
When user channel is disattached from connection object during channel
cleanup, resets its state to DISCONNECTED to be able reuse it from
well known init state.

Change-Id: I5733ade4be195821a1643383916c3a6fea5a88d3
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-07-25 14:22:57 +00:00
Arkadiusz Lichwa 37bb3e8049 Bluetooth: L2CAP: Split security changed handler for BR/EDR
Delegates own handler for changed security information happened on BR/EDR
link. Now L2CAP layer based on transport type can independently handle
updated security information.

Change-Id: I4838f1cc9d53cf6dfab19bb9f70ec6e307741e66
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-07-25 14:22:18 +00:00
Arkadiusz Lichwa 96e68fe654 Bluetooth: L2CAP: Introduce security requirements on CoC
Applies on L2CAP channel object security requirement member and
implements on BR/EDR transport basic security cases during incoming
CoC connection request. Since channel security requirements can involve
sending 2 separate connection responses with proper results depending on
context path, there's a need to store L2CAP signaling identifier set in
original connection request to be restored later to help match proper
response context.

Change-Id: Ibac9a5d2443f2975637e1bd15f61afcad53f843b
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-07-25 13:56:08 +00:00
Szymon Janc d2549115ca Bluetooth: Rename connectable_addr member in struct bt_le_oob
Depending on advertising options this can be non-connectable address.
NFC pairing application document also allows broadcaster/observer
roles.

Change-Id: I9b104ac8fb9752a083a7a31fc20598c66f23f608
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-07-22 13:09:30 +02:00
Arkadiusz Lichwa d5a07edde0 Bluetooth: L2CAP: Refactor channel context by ident
Moves 'ident' member so far included in bt_l2cap_le_chan context only
to common bt_l2cap_chan context. The change is driven by sharing ability
to store/restore 'ident' on both transports and makes use of it only if
CoC is configured. For default configuration there's channel addition
helper to be used internally by dedicated macros managing channel
objects enlisted in connection tracker list.
The common member is used in matching outstanding connection responses
on LE and to prepare a ground for BR/EDR transport context when
there'll be a need to match response to original incoming connection
request after in-between security changes that can happen.

Change-Id: I1a4cad7cd53c74774604a0e9794607081a8b6e80
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-07-22 09:20:20 +00:00
Luiz Augusto von Dentz c9a3809ab5 Bluetooth: Remove nano_work include from internal header
This include is no longer necessary since all .c files that include it
already have nano_work included as well.

Change-Id: I523d6c756e2e49d53fcb00459d8ed547113d9078
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-07-22 09:18:13 +00:00
Johan Hedberg cbf325a58d Bluetooth: Add warning for bt_pub_key_gen() when missing support
This makes it easier to track issues resulting from missing ECDH
support.

Change-Id: Iab104beed8cc622ea7bec2275ed69ca4ffe4cc87
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-07-22 09:17:51 +00:00
Johan Hedberg d43f4c27d0 Bluetooth: Remove conn & SMP dependency from BLUETOOTH_TINYCRYPT_ECC
Ever since we expose ECDH as a more generic API that's not bound to
SMP we shouldn't be requiring selcting SMP in the configuration for it
to be available. Move it outside of the BLUETOOTH_SMP and
BLUETOOTH_CONN dependencies.

Change-Id: I4ac15ff92b1d4fcf3061a487718d364aa7d43bc8
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-07-22 09:17:42 +00:00
Arkadiusz Lichwa 65ab753fe7 Bluetooth: L2CAP: Fix debug message in l2cap_chan_destroy
Removes redundant parameter value to be printed.

Change-Id: Ib719135b4f99265312b3a08f051d35d10adb0bcf
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-07-22 09:00:09 +02:00
Inaky Perez-Gonzalez 3e63a74514 net/yaip: revert merge
Follow up to TSC decission for further discussion in the networking
WIG.

Change-Id: I148b484dfe308661573e47ed3e60cceed673bddf
Signed-off-by: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
2016-07-22 04:43:09 +00:00
Kumar Gala 5249b8a52d Bluetooth: use sys_put_le16 macro instead of bswap
Use sys_put_le16 rather than having to explicitly have an ifdef
check in the code and use bswap_16.

Change-Id: Ia7b2b956c69993e29b1186da3d08e5eb449f096b
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2016-07-22 04:26:15 +00:00
Maureen Helm 1942a413fc net: tinydtls: Use assert.h from minimal libc
Now that minimal libc has assert.h, we can remove the workaround from
tinydtls.

Change-Id: I3bb001d1891f0b110b43133d30c262ba320450f7
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2016-07-21 16:22:20 +00:00
Ravi kumar Veeramally f93771a25c Revert "net: Restructured Ethernet driver menu"
This reverts commit 6de5643eb1.

Patch breaks applications running over Ethernet.

Jira: ZEP-565

Change-Id: Id147b7089f175c769c42c4e3dfb95408ee17ba9e
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-07-20 22:57:55 +00:00
Szymon Janc c6bcb591f6 Bluetooth: Add initial support for OOB data
This allows to query information needed for Out Of Band pairing
or connection creation. Currently supports only BT addresses.

Change-Id: I60bf9344baee552e7743fa8fc1b3cfb3a4765334
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-07-20 20:20:44 +02:00
Johan Hedberg 211ae314e8 Bluetooth: Pass net_buf_simple to scan callback
This lets the callback take advantage of the powerful net_buf API for
parsing the advertising data content.

Change-Id: Id65e6e83efd60c0f36c47bc5446a2e8ec2833d7c
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-07-20 16:19:01 +00:00
Szymon Janc a0a52691f2 Bluetooth: Add support for rotating RPA
If privacy is enabled we always use RPA, even for active scan.
This makes single point of controlling current random address
making code simple and not prone to subtle bugs with concurent
advertising, scanning and connecting.

Currently used RPA is rotated to improve privacy. Timeout value is
controlled by Kconfig and by default is 900 seconds (15 minutes).

Change-Id: I27a15666a4f2e2962cf6eb20c7cd06f90b7f2bb1
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-07-20 16:18:50 +00:00
Luiz Augusto von Dentz c51bcbb9d9 Bluetooth: GATT: Add write struct parameter to its callback
This makes bt_gatt_write consistent with the rest of the API where the
parameters are passed back to its callback.

Change-Id: Ie94208aa661d3620d0cbc5be4a4fb5b3c3ef061c
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-07-20 13:40:55 +00:00
Szymon Janc ae96c91109 Bluetooth: GATT: Fix using non-ASCII characters
Some non-ASCII characters were used in code comments.

Change-Id: Ie00e0b7d7a42a50503c601225cdd0896c375dee3
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-07-19 09:49:17 +00:00
Johan Hedberg 1de77488ae net: buf: Add net_buf_add_be32 helper
Add helper to add 32-bit big endian data to net_buf and
net_buf_simple.

Change-Id: Ib6359558abcbed824365928327277ad69aa51e99
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-07-19 11:13:08 +03:00
Arkadiusz Lichwa 796d467653 Bluetooth: L2CAP: Set BR/EDR CoC channel as connected
Finalizes CoC channel configuration setup. The channel's CONNECTED state
can be set depending on context path by two responsible for that handlers.
Then one of them announces to all registered clients the connection is
set successfully.

> ACL Data RX: Handle 12 flags 0x02 dlen 12                   [hci1] 108.666944
      L2CAP: Connection Request (0x02) ident 3 len 4
        PSM: 3 (0x0003)
        Source CID: 64
> HCI Event: Number of Completed Packets (0x13) plen 5        [hci1] 108.668572
        Num handles: 1
        Handle: 12
        Count: 2
< ACL Data TX: Handle 12 flags 0x00 dlen 16                   [hci1] 108.673002
      L2CAP: Connection Response (0x03) ident 3 len 8
        Destination CID: 64
        Source CID: 64
        Result: Connection successful (0x0000)
        Status: No further information available (0x0000)
< HCI Command: Host Number of Complet.. (0x03|0x0035) plen 5  [hci1] 108.673548
        Num handles: 1
        Handle: 12
        Count: 1
< ACL Data TX: Handle 12 flags 0x00 dlen 16                   [hci1] 108.674725
      L2CAP: Configure Request (0x04) ident 5 len 8
        Destination CID: 64
        Flags: 0x0000
        Option: Maximum Transmission Unit (0x01) [mandatory]
          MTU: 48
> HCI Event: Number of Completed Packets (0x13) plen 5        [hci1] 108.707579
        Num handles: 1
        Handle: 12
        Count: 2
> ACL Data RX: Handle 12 flags 0x02 dlen 16                   [hci1] 108.714206
      L2CAP: Configure Request (0x04) ident 4 len 8
        Destination CID: 64
        Flags: 0x0000
        Option: Maximum Transmission Unit (0x01) [mandatory]
          MTU: 560
> ACL Data RX: Handle 12 flags 0x02 dlen 18                   [hci1] 108.715442
      L2CAP: Configure Response (0x05) ident 5 len 10
        Source CID: 64
        Flags: 0x0000
        Result: Success (0x0000)
        Option: Maximum Transmission Unit (0x01) [mandatory]
          MTU: 48
< HCI Command: Host Number of Complet.. (0x03|0x0035) plen 5  [hci1] 108.720451
        Num handles: 1
        Handle: 12
        Count: 1
< ACL Data TX: Handle 12 flags 0x00 dlen 14                   [hci1] 108.720472
      L2CAP: Configure Response (0x05) ident 4 len 6
        Source CID: 64
        Flags: 0x0000
        Result: Success (0x0000)

Change-Id: If831777f7bd87489eefbd200a1ca8883b83aae3e
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-07-15 11:31:06 +02:00
Arkadiusz Lichwa 22bdf50615 Bluetooth: L2CAP: Mark finishing CoC configuration on BR/EDR
When each side involved in getting configured L2CAP CoC channel on
BR/EDR transport aggrees on configuration contract regarding in/out MTU,
set proper context flags to start prepare finalize config process.

Change-Id: Ic821ea3b961442be758ad4e2d91b2d812e2a54b5
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-07-15 11:01:17 +02:00
Arkadiusz Lichwa c28720f167 Bluetooth: L2CAP: Introduce CoC channel states
Adds CoC channel's context to hold channel setup state and SM routine
that evaluates validness of transitions.
At the beginning DISCONNECTED, CONNECT and CONFIG states are added and
used by CoC setup on BR/EDR transport.

Change-Id: I1bbd16ec2f59ea961791786b78f22834d6f4b4d8
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-07-15 04:54:03 +00:00
Szymon Janc c9e2fc1929 Bluetooth: Fix changing advertising random address when scanning
If active scan was started while advertising random adress was
set to NRPA. This results in device advertising with new adress
instead of RPA making it imposible to resolve its identity by
remote devices.

To fix this NRPA for active scan is set only if advertising is
not enabled. This resulst in RPA being used for scan requests
but this is OK since device is advertising anyway.

Change-Id: I35e98bee72f4abc033f5adc664698c14c5d8a2b0
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-07-14 15:26:50 +00:00
Szymon Janc 40cf82bc60 Bluetooth: Track if active scan is being perfomed
Add new bt_dev flag for tracking if performing active scan.

Change-Id: I7eacaa94372bae933f648a49d2f55fc200f9d0bf
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-07-14 15:26:42 +00:00
Szymon Janc 9303331bbd Bluetooth: SMP: Fix disabling debug logs
SMP debugs should be enabled only if CONFIG_BLUETOOTH_DEBUG_SMP is
defined.

Change-Id: I17f8ad5e1a9504dcbd3df545af9205db88ee2849
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-07-14 11:52:48 +02:00
Jani Pajarinen 6de5643eb1 net: Restructured Ethernet driver menu
Created menu for Ethernet driver and moved driver + debugging setting
under it. Changed prompt from "Grove log level" to more describing and
fixed typos.

Change-Id: If2f79fee1a002a42e89e2493a2294332abec05ee
Signed-off-by: Jani Pajarinen <jani.pajarinen@intel.com>
2016-07-13 14:33:44 +00:00
Mariusz Skamra d98b9bd139 Bluetooth: Get the included service 128bit UUID
This adds reading of included service attribute 128bit UUID.
The limitation of this solution is that if several attr handle-range
pairs will be received, this will read first attribute UUID and then
start discovery from the the succeeding handle.

ZEP-373

Discovery related test results:

 2/76   GATT   TC_GAD_CL_BV_02_C   PASS
 3/76   GATT   TC_GAD_CL_BV_03_C   PASS
 4/76   GATT   TC_GAD_CL_BV_04_C   PASS
 5/76   GATT   TC_GAD_CL_BV_05_C   PASS
 6/76   GATT   TC_GAD_CL_BV_06_C   PASS

Change-Id: I27185b3a3ae96c9c03b0f356492df18ba83b183a
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-07-13 14:18:03 +00:00
Johan Hedberg 477fedcf1f net: buf: Add more big endian helpers
Change-Id: I3f8d9a2810359a0cc7b7ce2097f86e03fa35d3bc
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-07-13 14:11:37 +00:00
Jukka Rissanen 02c83fd35d net: yaip: Print available DATA buffers during nbuf alloc
Print more debugging information about available DATA buffers
when allocating and de-allocating a net buf.

Change-Id: Id4aa4c46b5dc70e683029ccc525abed5b6cfbefb
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-13 14:06:24 +00:00
Jukka Rissanen b375394369 net: yaip: Make sure that RX is started before TX
The network stack initialization will need to make sure
that RX side is ready before TX side is started. So in
order to do that the TX init is called from RX fiber.

This is needed so that we can start to send network packets already
during the net_init(), like IPv6 neighbor solicitation messages
during duplicate address detection process.

Change-Id: I12fde3d388d9aab41daa93b1edc02f25b8c5511d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-13 14:06:24 +00:00
Jukka Rissanen d0daa97820 net: yaip: Moved ARP helper macro to arp.h
The helper macro NET_ARP_BUF() needs to be used from other
files so arp.h is proper place for it.

Change-Id: Ief7bbb385d9c180213ecd7cb08023f13999f5270
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-13 14:06:23 +00:00
Tomasz Bursztyka 402ea39dc1 net: yaip: Save some bytes on net_if logic
Instead of runtime checks, let's use NET_ASSERT() to verify that net if
API is properly set.

Change-Id: I8e5c769b8383aa9aec5a5e9600c07e05ca96d517
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-07-13 14:06:22 +00:00