Commit Graph

1978 Commits

Author SHA1 Message Date
Szymon Janc d0aa85096c Bluetooth: Add simple advertise command to shell app
This allows to enable advertising with some fixed Advertising Data
and Scan Reponse.

Change-Id: Ie3a33a49fe8517c9e931b7805694bd9c7b05fcdb
Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
2016-02-05 20:14:35 -05:00
Szymon Janc 0d7739f389 Bluetooth: Add support for enabling security as slave
As slave send Security Request for master to initiate security.

> HCI Event: LE Meta Event (0x3e) plen 19             [hci0] 569.228544
      LE Connection Complete (0x01)
        Status: Success (0x00)
        Handle: 64
        Role: Slave (0x01)
        Peer address type: Public (0x00)
        Peer address: 00:1B:DC:07:32:7E (Vencer Co., Ltd.)
        Connection interval: 70.00 msec (0x0038)
        Connection latency: 0.00 msec (0x0000)
        Supervision timeout: 420 msec (0x002a)
        Master clock accuracy: 0x01
.....

< ACL Data TX: Handle 64 flags 0x00 dlen 6            [hci0] 600.801709
      SMP: Security Request (0x0b) len 1
        Authentication requirement: Bonding, No MITM, Legacy,
          No Keypresses (0x01)
> ACL Data RX: Handle 64 flags 0x02 dlen 11           [hci0] 600.930641
      SMP: Pairing Request (0x01) len 6
        IO capability: DisplayYesNo (0x01)
        OOB data: Authentication data not present (0x00)
        Authentication requirement: Bonding, No MITM, Legacy,
          No Keypresses (0x01)
        Max encryption key size: 16
        Initiator key distribution: EncKey Sign (0x05)
        Responder key distribution: EncKey IdKey Sign (0x07)

Change-Id: I201cb99d7cbcf3115bc8a5e2968108034ab9189c
Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
2016-02-05 20:14:35 -05:00
Szymon Janc 59e78e4d41 Bluetooth: SMP: Add support for sending security request
This allows to request sequrity as a slave.

Change-Id: Ieab15c2ab20403a5a22b13a331405276a7d4074f
Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
2016-02-05 20:14:35 -05:00
Mariusz Skamra 8beeb0f3d3 Bluetooth: SMP: Fix smp_send_pairing_req function name
Prefix smp_send_pairing_req with bt_* to maintain proper
namespace in API.

Change-Id: Ia1f0d1291c5298034b9f1312b0d5a94aaa099cd0
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:14:35 -05:00
Jukka Rissanen 4d42645012 net: 15.4: Fix the loopback test
The listening socket was creted after we started to send data
so data was discarded. Now we first create listener and then
start to send data to it.

Change-Id: Iee706c7c862d16a582ee973b10598dde5e5f0bd0
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:35 -05:00
Jukka Rissanen ea970e2ce1 net: Change the remaining doxygen comments to javadoc style
Change-Id: I942558ca9e4c140145de6e4a1bcebf8d9d16f3d2
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:35 -05:00
Jukka Rissanen f48fb5f3ec net: tools: Add IPv4 support for echo-client tool
The IPv4 support is activated automatically if the IP address
parameter is a real IPv4 address.

Change-Id: Ief7b2a216a143416b5eec095cd6f813729a40b92
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:35 -05:00
Jukka Rissanen 0605e89ec1 net: apps: Enable IPv4 support for echo-server test application
Change-Id: Ibcedaeeae06767461ee53492fc055d05c635137f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:35 -05:00
Jukka Rissanen 7ef1a726d4 net: apps: Add IPv4 support for listener application
Change-Id: Ifa5378463dde1bcfc4c701dc4b881175395cd9fd
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:35 -05:00
Jukka Rissanen 9a59d70cf5 net: tools: Add tunslip application for IPv4
The tunslip program will setup the tun device for IPv4 traffic.

Change-Id: I1192a704f691e17016e187167dfca09df00b974f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:35 -05:00
Jukka Rissanen f2886e2af3 net: uip: Traverse only through valid UDP connections
The uip.c:uip_process() was not checking the upper bound of
the UDP connection list when traversing the connection list.
Now the code checks the upper bound of the array (UIP_UDP_CONNS)
and will not go beyond the max number of items in the array.

This commit fixes the IPv4 branch, the IPv6 branch was already
fixed by commit 07a5959c2ae9ffce27092c2a0a6161111facdb6c

Change-Id: I5c31176190e0f063b72d6742c4a9c23b433026ad
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:35 -05:00
Jukka Rissanen e6020d1701 net: uip: Initial IPv4 support
Enabling IPv4 support and modifying code so that it compiles ok.

Change-Id: I605cd94adfda7675be2f2cf798588c69eb1f152e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:35 -05:00
Jukka Rissanen 3c9fd82c5b net: Add INADDR_ANY for IPv4 connectivity
Change-Id: I027ec85c9e15f0a4aae494f766414faab7f2012b
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:35 -05:00
Jukka Rissanen 7d743ce57b net: uip: Remove obsolete file
The declarations in this header file are already provided by
other header files so this file can be removed.

Change-Id: I63cd99ed201af7bebb14943bf965dafd11be14fe
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:35 -05:00
Johan Hedberg d7ccefd0bd Bluetooth: Fix doxygen comment style
Change-Id: I37b85e83b54f7efb8aded70ec95fd87cafaf7e2b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:35 -05:00
Ravi kumar Veeramally cb73239de2 net: tests: Fix improper rebase
set_mac was removed in net_set_mac is in init_test(). Rebase was
not done successfully.

Change-Id: I0d1a2f37cdb441064ae97a0e34ae41e9c7e77984
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-02-05 20:14:35 -05:00
Mariusz Skamra 3fcf60a6e6 Bluetooth: Fix sending dummy buffer to kill invalid tx fiber
This fix prevents from sending dummy buffer to kill tx fiber
if this fiber didn't started.

Tx fiber is started during transition from BT_CONN_CONNECT state
(for outgoing connections) or BT_CONN_DISCONNECTED (incoming)
to BT_CONN_CONNECTED state.
So the only states that have tx fiber running are BT_CONN_CONNECTED
and BT_CONN_DISCONNECT and only transitions from these states
should be taken into account.

Change-Id: I558c937812368b0bd305f6c9935cced565c70606
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:14:35 -05:00
Luiz Augusto von Dentz a52d54cc3e Bluetooth: Add gatt-discover command to btshell
This adds gatt-discover which works as follow:

btshell> gatt-discover <bdaddr> <bdaddr_type> <uuid> [start_handle] [end_handle]
bt: bt_gatt_discover (0x0010cb10): uuid 0x180d start_handle 0x0001 end_handle 0xffff
Discover pending
btshell> bt: bt_att_recv (0x0010ed0c): Received ATT code 0x07 len 5
bt: att_handle_find_type_rsp (0x0010ed0c):
bt: att_find_type_rsp (0x0010ed0c): err 0x00
bt: att_find_type_rsp (0x0010ed0c): start_handle 0x000a end_handle 0x0011
Discover found handle 10
bt: bt_gatt_discover (0x0010ed0c): uuid 0x180d start_handle 0x0011 end_handle 0xffff
bt: bt_att_recv (0x0010ed0c): Received ATT code 0x01 len 5
bt: att_error_rsp (0x0010ed0c): request 0x06 handle 0x0011 error 0x0a
bt: att_find_type_rsp (0x0010ed0c): err 0x0a
Discover destroy

Change-Id: Ic0b28f19e4932e26b2eae2d19f62f6be6e1efa9c
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:35 -05:00
Luiz Augusto von Dentz 1e7016a823 Bluetooth: GATT: Include uuid.h
gatt.h API depend on bt_uuid so make use uuid.h is always included.

Change-Id: If9d4e5a668ac4e0b167eda8fe41e8b4810dfe298
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:35 -05:00
Luiz Augusto von Dentz 4c640515c7 Bluetooth: GATT: Add bt_gatt_discover
bt_gatt_discover can be used to discover primary GATT service by UUID in
a selected handle range, after it attribute found the function callback
is called so the user can interact the attribute found and decide to
continue to the next or stop.

Change-Id: I37514f00c82ce5520d7a14757a6ff12ee34f0736
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:35 -05:00
Luiz Augusto von Dentz df0cc2697d Bluetooth: ATT: Handle Find By Type response
This adds function handler for Find By Type Response PDU which call the
request callback:

< ACL Data TX: Handle 3585 flags 0x00 dlen 13
      ATT: Find By Type Value Request (0x06) len 8
        Handle range: 0x000a-0xffff
        Attribute type: Primary Service (0x2800)
          UUID: Heart Rate (0x180d)
> ACL Data RX: Handle 3585 flags 0x02 dlen 9
      ATT: Find By Type Value Response (0x07) len 4
        Handle range: 0x000a-0x0011
< ACL Data TX: Handle 3585 flags 0x00 dlen 13
      ATT: Find By Type Value Request (0x06) len 8
        Handle range: 0x0011-0xffff
        Attribute type: Primary Service (0x2800)
          UUID: Heart Rate (0x180d)
> ACL Data RX: Handle 3585 flags 0x02 dlen 9
      ATT: Error Response (0x01) len 4
        Find By Type Value Request (0x06)
        Handle: 0x0011
        Error: Attribute Not Found (0x0a)

Change-Id: Ib5799d0530c8de40b7c7170f1b32312a42456484
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:35 -05:00
Luiz Augusto von Dentz f6f64c2cda Bluetooth: ATT: Fix missing new line in BT_DBG
Change-Id: I1a9643e3d5d22cfc23baa0ebf2e5722777eaf213
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:35 -05:00
Mariusz Skamra f4d142e861 Bluetooth: Remove not needed code
This check is already made in bt_start_scanning and is valid only
when task wants to enable active scanning when it's already enabled.

Change-Id: Ic8843d51d4c91a533250d8ddb4139814015f7aa4
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:14:35 -05:00
Mariusz Skamra 8ce5eda9bd Bluetooth: Move scan_enable check to trigger_scan()
bt_hci_start_scanning is called from API's bt_start_scanning to enable
active scanning and from trigger_scan to enable passive/active scan.

bt_start_scanning have already this check, it stops passive scanning
if enabled and then starts active scan.

So "if (dev.scan_enable)" check can be moved to trigger_scan to avoid
unnecessary checks.

Change-Id: I5eaa4bb5c611418b8519b0dda680f59a3a9332fc
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:14:35 -05:00
Mariusz Skamra d699296a45 Bluetooth: Add passive scanning support
Part of General Connection Establishment Procedure.

Active scanning is enabled by task and has higher priority than
passive scan. If passive scan is running and task wants to enable
scan (active) scanning will be restarted in active mode. Passive
scan is enabled implitly while app calls bt_connect_le.
Instead of directly call hci_le_create_conn, it is called from
device_found if addr obtained from advertisement matches address
we want to connect. App calling bt_stop_scanning can only stop
active scan.

Change-Id: I01805c51f3d821bbd827af75e5d1d4350169241d
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:14:35 -05:00
Mariusz Skamra 911b91d82e Bluetooth: Move start_scanning stop_scanning and le_create_conn
Move bt_hci_start_scanning, bt_hci_stop_scanning and hci_le_create_conn.
It's needed to avoid a forward declaration in a subsequent patch.

Change-Id: I0ee048ca6e8add6a481ac4fdc8a8e2cbdf4f007c
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:14:35 -05:00
Mariusz Skamra 7ec1617b9f Bluetooth: Introduce BT_CONN_CONNECT_SCAN state
This state will be used for connection establishment during passive scan.
This additional state is necessary, because only one connection can be
in BT_CONN_CONNECT state (LE Create Connection has been sent).
It's because the LE Create Connection Cancel looks for connection in this
state (we cannot look by address, if some controllers respond with
LE Create Connection with address set to 00:00:00:00:00:00).

If connection is BT_CONN_CONNECT_SCAN state it means that we wait for
an advertisement from remote to send LE Create Connection and then we
can change the bt_conn state to BT_CONN_CONNECT.

Change-Id: I48b0352fe08e438f7bfbb1dd12de3d1719f994d8
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:14:35 -05:00
Ravi kumar Veeramally 5e571ec7fb net: tests: Update 15.4 test with proper link local addresses
6lowpan HC1 compression technique expecting proper link local
addresses for compression, otherwise compression fails.

Change-Id: I083b749a7b50d93d65ea56b80b9ed6245b571200
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-02-05 20:14:35 -05:00
Ravi kumar Veeramally 5d2e81c8ab net: Copy mac address to uip_lladdr
uip_lladdr is global variable which is used to generate link
local address based on mac address. Right now it is empty.

Change-Id: I89bf7ac4c7770858044ef0c4f3d667e9316c4269
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-02-05 20:14:35 -05:00
Ravi kumar Veeramally 5d2e9db894 net: sicslowpan: if compression fails then send uncompressed packet
If HC1 or HC06 compression fails then send uncompressed ipv6 packet
by adding IPv6 dispatch header infront of the header.

Change-Id: Ie15fb9d61def45066fb606417ba4f46ae6c628b1
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-02-05 20:14:35 -05:00
Ravi kumar Veeramally 1f8cb9b4dc net: sicslowpan: Fix length and packetbuf issues
Fix IPv6 packet lenght in header. packetbuf_copyfom clears all
pointers which is causing an issue, so assign uip_packetbuf_ptr
after packetbuf_copyfom.

Change-Id: I943273bb0a079d3ac86da0761c3f32043a280a87
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-02-05 20:14:35 -05:00
Ravi kumar Veeramally 944b580266 net: Remove net_buf forward declaration in sisclowmac
Change-Id: I5f202c7241b885e85a428b625a7170a5300b7237
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-02-05 20:14:35 -05:00
Ravi kumar Veeramally fda66bfa34 net: Enable 802.15.4 related macros
UIP_CONF_LL_802154: 802.15.4 support in uIP, default compression
is none(SICSLOWPAN_COMPRESSION_IPV6: just add IPV6 dispatch infront
of header, enable HC06 or HC1 depends upon requirement).

Change-Id: I5c298652783a560d227b77c293c3d13844647f56
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-02-05 20:14:34 -05:00
Jukka Rissanen cc3afa6346 net: Add net_mbuf validation
Add infrastructure and checks to validate the net_mbuf during
its lifecycle.

Change-Id: Id4b638fff991325d2247b1f24152552038888915
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:34 -05:00
Jukka Rissanen 6ffb93553e net: apps: Do proper initialization for 802.15.4 tester
Set the MAC address so that the stack can generate a link
local address and mark internal variables as static to avoid
namespace pollution.

Change-Id: Ic8447054629fcdd5f7e1f8b8c5e2bb477bd63809
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:34 -05:00
Jukka Rissanen 4f4700e32c net: Use correct IPv6 address when registering UDP socket
The code used wrong IPv6 address pointer for UDP registration.
This caused the packet sending to fail because the generated
IPv6 address was bogus and not routable.

Change-Id: I933d6920c6455b271e775f5cbe15afdaa948abae
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:34 -05:00
Jukka Rissanen 17b269682e net: The local address was allocated from stack
We cannot use stack variable for local address as the address
needs to point to static memory. So change the type of the laddr
to be static. This is not a problem here as there is only one
local address defined anyway in the system.

Change-Id: Ie8763f761eea08997f0984394984050be946ae18
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:34 -05:00
Jukka Rissanen d644eb8175 net: Add missing curly braces
Follow the style guide here.

Change-Id: Icd4053434f509aee4787bf2d5aae42cefb830a36
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:34 -05:00
Jukka Rissanen fdadfc95a7 net: uip: Reset the rxbuf if we run out of buffers
We need to reset the slip receive buffer pointers if we cannot
process the incoming message. If this is not done the rxbuf
will overflow and overwrite core kernel data.

Change-Id: If6a96177a3de57148268e48940fbc33d2e08b36a
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:34 -05:00
Jukka Rissanen 5ac5211093 net: uip: Free net_buf if it cannot be pushed to slip rx queue
This is a sanity check.

Change-Id: I1e747887b3f77203c6a2945810c8203243c41fe3
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:34 -05:00
Jukka Rissanen 90ca5ff779 net: Validate that net_buf allocation is correct
Add macros that check that we are not trying to use already
freed net_buf and vice versa.

Change-Id: Ifdb6a7e24cd6d7a0de46fa7b991c358ea8828d6f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:34 -05:00
Jukka Rissanen 73fc66d86a net: Rework the includes so that they are inside include guard
Making sure we do not include anything unless they
are inside include guard.

Change-Id: Ie88cbc0ed6dbbf4033f3c8c310df7d084ab8b126
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:34 -05:00
Jukka Rissanen a64f6995bb net: tools: Simple echo client that sends data to echo server
This client sends pre-defined UDP data to server, reads back
the reply and verifies that the data is the same.
This test application is only usable when running in Linux
host and it is not meant to be run inside Zephyr.

Change-Id: I6df83f3a5b1ab92c724b4d3c245738eb5c56a91f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:34 -05:00
Jukka Rissanen c16d29ec0f net: apps: Simple echo server that sends back the data
The echo server is listening on port 4242 and when it receives
UDP packet, it will reverse the data and send it back to the
caller. This can be used to verify that the IP stack is doing
something useful.

Change-Id: Ibbc48c21f2513d59480c5a3bb34c775eb3df8170
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:34 -05:00
Jukka Rissanen 3e4d890d72 net: slip: Add slip driver for testing purposes
This slip driver is needed for sending packets outside of qemu.

Change-Id: Ifc37181094ddebce08d97ae889f3a58c03d01ae1
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:34 -05:00
Jukka Rissanen 6421d6eba8 net: The UDP remote address was incorrectly set
We need to use correct IPv6 address when registering UDP
socket.

Change-Id: I38f55bc16f72a71cb8cd58d20b3288be2f4cd475
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:34 -05:00
Jukka Rissanen 54ab6fad20 net: Add net_reply() function
The net_reply() can be used if the application wants to reply
something to peer right after receiving the data. The function
will reverse the source and destination addresses and ports,
and set the uIP internal structures in such a way that the
reply is possible. Using this function saves the application
from allocating a separate net_buf for just sending simple
message back.

Change-Id: Ia960c83b77a8f300222159ee085fed99e2b007c2
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:34 -05:00
Szymon Janc bdb7044f09 Bluetooth: SMP: Make bt_smp_init parameters explicit void
Change-Id: I307ebd13cf031af3359176a19d6a9d4c067cf0ec
Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
2016-02-05 20:14:34 -05:00
Mariusz Skamra 296c76c7a8 Bluetooth: Fix status returned by bt_stop_scanning and bt_start_scanning
If the Command Complete status is read, this status shall be returned.

Change-Id: Ic3fe102c16da4b01d002a2d39952fd401e9f832d
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:14:34 -05:00
Luiz Augusto von Dentz 81546cfc0a Bluetooth: Add gatt-exchange-mtu command to btshell
This adds gatt-exchange-mtu which works as follow:

btshell> gatt-exchange-mtu <bdaddr> <bdaddr_type>
bt: bt_gatt_exchange_mtu (0x0010c138): Client MTU 65
Exchange pending
btshell> bt: bt_att_recv (0x0010e310): Received ATT code 0x03 len 3
bt: att_mtu_rsp (0x0010e310): Server MTU 517
Exchange successful

Change-Id: I7280fb9d9fafc0f4bd1ef0f2226c255a5acf2592
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:34 -05:00