Commit Graph

2776 Commits

Author SHA1 Message Date
Jukka Rissanen 48186c99f5 net: Get debug info about available net buffers
Print additional information about how many net buffers
are available when allocating (get) or de-allocating (put)
them. The prints are only available if Kconfig option
CONFIG_NETWORKING_WITH_LOGGING is set.

Change-Id: I85e6a5813356d8fe00f0ba633c3ebf5379e56bff
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:15:39 -05:00
Jukka Rissanen 4d745b70b0 net: Create separate net_buf pool for RX and TX use
Have a separate network buffer pool for received and transmitted
data. This way incoming packet flood cannot prevent from sending
IP packets out.

Change-Id: I2aae3bcb4ea63f36355f758de44532b167edfdb8
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:15:39 -05:00
Jukka Rissanen 458ed33fa7 net: apps: Implement CoAP test server
The CoAP test server runs in Zephyr and it receives CoAP messages
sent by coap client. The server can receive both plain or DTLS
encrypted CoAP messages. The server has various resource plugins
available but currently activates only three that are needed
by coap-client tester.

Change-Id: I6465a3a057eaf8b412699bba57bf7213548f0377
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:15:39 -05:00
Jukka Rissanen c00a7aa320 net: tools: Add CoAP client
Add simple CoAP client that can be used to test
the CoAP server running in Zephyr inside qemu.
The coap-client is run in the host.

Change-Id: I50e4b0e13aa657a0d805b0438050b8b9187d3839
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:15:39 -05:00
Jukka Rissanen 6ed897f907 net: coap: Initial client support
Adding CoAP client support to Kconfig and Makefile.

Change-Id: I857169feac8b6c4347af4369b0cdfb806c6aedb0
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:15:39 -05:00
Jukka Rissanen 20b9a6f845 net: coap: Activate Erbium CoAP support
Add CoAP switches to Kconfig and enable them in Makefile.

Change-Id: I3d5e18f34c0ab0853838c2e883748dd4ae62aed2
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:15:39 -05:00
Jukka Rissanen 8848f33030 net: coap: Use CoAP context also in non-DTLS case
The use of CoAP context is needed as we do not have
global buffers any longer. This commit adds support
for CoAP context when user does not have DTLS enabled.

Change-Id: Ief716e2a3290bd1f7e5a3286a20deba690b3c1c5
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:15:39 -05:00
Jukka Rissanen 77b15eba04 net: coap: Port DTLS code to Zephyr
Make the DTLS code in CoAP context to work in Zephyr.

Change-Id: I0c9cd30a02fa6b3f0221f78e1dadd1d476bad646
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:15:39 -05:00
Jukka Rissanen 39e5eeef9d net: coap: Initial port to Zephyr
Initial port of er-coap code into Zephyr.

Change-Id: Icb45903387eb08418a3610c1bd0933a9a9c6f8dd
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:15:39 -05:00
Jukka Rissanen 036eda7b9f net: coap: Use uIP debug macros
Use the debug macros from uip-debug.h so that they are
in one place.

Change-Id: I342d727d4c6af9a655729db6245668968bee4b07
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:15:39 -05:00
Jukka Rissanen d60155d02f net: rest-engine: Initial commit
This is originally from git@github.com:YanziNetworks/netcontiki.git
commit e7d7ee5b142fb7b0695677dac9cc1899620b0fe0

Change-Id: I606b26420b9df841f03bc955039f25970553e481
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:15:39 -05:00
Jukka Rissanen 7da5d379e1 net: coap: Initial commit importing er-coap
This is originally from git@github.com:YanziNetworks/netcontiki.git
commit 02bb8eed066c012b4b6033cbe17a31ff15879a24

Change-Id: I4b19302266a6ff562532c493bb34b7cd9a27ee5d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:15:39 -05:00
Mariusz Skamra 252ddb1565 Bluetooth: Shorten LE Conn Param define names
Shorten LE Remote Connection Parameters Request Event
HCI define and struct name.

Change-Id: Ia094b16caa2716f24afd4cc7db57404050fafeef
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:15:39 -05:00
Szymon Janc 8ac1577641 Bluetooth: SMP: Remove not need double debug
More informative debug is already printed below.

Change-Id: Iff70fef4922bbce649647773a2bc6eb624a13795
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:15:39 -05:00
Szymon Janc 46f04f3e00 Bluetooth: SMP: Fix not storing IRK on re-pair
conn->dst might already contain identity address from previous
pairing. In order to store IRK distributed in new pairing we
should check address used in connection.

Change-Id: If4bfaf445d31684125246cc98cfad1aab45875ca
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:15:39 -05:00
Szymon Janc 9764e3dc84 Bluetooth: Implement security_changed callback in shell app
This callback is called when security level of connection changed.

Change-Id: Ifec130163fffe291cd012c99247017bd31173660
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:15:38 -05:00
Szymon Janc 57daca9341 Bluetooth: Add callback for security changed
This callback is called if security level of a connection was changed.

Change-Id: I268da245cf4b7f6d2bfbd57969ce2da6c34fc69f
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:15:38 -05:00
Grzegorz Kolodziejczyk 76bf6f60aa Bluetooth: Use generic read string handler for db descriptors
There is no need to define for each descriptor its own read handler.
Each string descriptor will use generic string read handler if
possible.

Change-Id: I468a082c6875400ec4515588131132ef27cc8082
Signed-off-by: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
2016-02-05 20:15:38 -05:00
Arkadiusz Lichwa 93968a91bf Bluetooth: Add defines for LE Remote Connection Parameter Request
Adds HCI layer defines to be used by LE Remote Connection Parameter
Request routines.

Change-Id: I7274a33c704c47d81612dd67bd732ba48d3aa1c8
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:15:38 -05:00
Arkadiusz Lichwa aa7226b6f7 Bluetooth: Add additional HCI error defines
Adds new error codes to be used by Remote Connection Parameter
Request handlers.

Change-Id: Ief163350c677f251ea30c0ff2f1b70b86ee2a5f6
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:15:38 -05:00
Arkadiusz Lichwa 134ae99d35 Bluetooth: Refactor LE Connection Params validator
Move le_validate_conn_params() interface to internal HCI
header to be commonly shared between HCI and L2CAP layers.
Refactor the interface and its users and rename related to Connection
Parameters Update procedure values used for validation.

< ACL Data TX: Handle 42 flags 0x00 dlen 16                                                                                                                          [hci1] 2832.387859
      LE L2CAP: Connection Parameter Update Request (0x12) ident 1 len 8
        Min interval: 40
        Max interval: 56
        Slave latency: 0
        Timeout multiplier: 0
@ Device Connected: 00:AA:01:00:00:23 (1) flags 0x0000
< HCI Command: LE Read Remote Used Features (0x08|0x0016) plen 2                                                                                                     [hci0] 2832.389374
        Handle: 42
> ACL Data RX: Handle 42 flags 0x02 dlen 16                                                                                                                          [hci0] 2832.389437
      LE L2CAP: Connection Parameter Update Request (0x12) ident 1 len 8
        Min interval: 40
        Max interval: 56
        Slave latency: 0
        Timeout multiplier: 0
> HCI Event: Number of Completed Packets (0x13) plen 5                                                                                                               [hci1] 2832.389440
        Num handles: 1
        Handle: 42
        Count: 1
> HCI Event: Command Status (0x0f) plen 4                                                                                                                            [hci0] 2832.389443
      LE Read Remote Used Features (0x08|0x0016) ncmd 1
        Status: Success (0x00)
> HCI Event: LE Meta Event (0x3e) plen 12                                                                                                                            [hci0] 2832.389444
      LE Read Remote Used Features (0x04)
        Status: Success (0x00)
        Handle: 42
        Features: 0x03 0x00 0x00 0x00 0x00 0x00 0x00 0x00
          LE Encryption
          Connection Parameter Request Procedure

< ACL Data TX: Handle 42 flags 0x00 dlen 10                                                                                                                          [hci0] 2832.393154
      LE L2CAP: Connection Parameter Update Response (0x13) ident 1 len 2
        Result: Connection Parameters rejected (0x0001)
> ACL Data RX: Handle 42 flags 0x02 dlen 10                                                                                                                          [hci1] 2832.393181
      LE L2CAP: Connection Parameter Update Response (0x13) ident 1 len 2
        Result: Connection Parameters rejected (0x0001)

Rejected due to Timeout multiplier: 0.

Change-Id: Idaf4f452f560ff71d9637ec5d793154190e94b35
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:15:38 -05:00
Mariusz Skamra 26124136b1 Bluetooth: Set bt_conn role based on LE Connection Complete Event data
bt_conn role can be set when LE Connection Complete event is received.
Controller indicates to both Hosts forming the connection their role
in this connection.

Change-Id: I35455eff54afa30665611415ac52e19089f2e649
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:15:38 -05:00
Szymon Janc 272128fece Bluetooth: Implement identity resolved callback in shell app
When identity is resolved only Identity Address should be used for
identifying connection.

Change-Id: Ic179286b09afced4997a755f1977eea818bc6e54
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:15:38 -05:00
Szymon Janc 393dad0ccf Bluetooth: Add callback for identity resolution
This callback is called if identity was resolved for remote device
that was using Resolvable Private Address while connection. From
now on only Identity Address is used.

Change-Id: I5976be575a8e4ad8c13f56d7bc274d751ae37511
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:15:38 -05:00
Szymon Janc 81c445c02e Bluetooth: Remove not needed src from bt_conn
Since initiator and responder addresses are already tracked it is
no longer needed to store source address in bt_conn structure.

Change-Id: I048e4d4659f4b7d29b101f9f3c5708f66c773906
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:15:38 -05:00
Szymon Janc 4bf5573055 Bluetooth: SMP: Fix using identity address while re-pairing
When remote device initiate pairing but its IRK is already known
identity address was used to calculate confirmation value. This
resulted in 'Confirm Value Failed' error and pairing failure.

To avoid any confusion simply track initiator and responder addresses
used for connection.

This fix re-enabling security with iPhone if device was unpaired
only on iPhone side.

Change-Id: I07d9589bee5fea7f6b028472b1709090a5755e31
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:15:38 -05:00
Szymon Janc c0ee86d1bf Bluetooth: SMP: Fix security request auth requirements
When sending security request for connection with pending high
security level, authentication requirements should indicate that
MITM is required.

< ACL Data TX: Handle 64 flags 0x00 dlen 6
      SMP: Security Request (0x0b) len 1
        Authentication requirement: Bonding, MITM, Legacy,
                                    No Keypresses (0x05)

Change-Id: Ie78e021726063b0eee415bfa7189962fe0b2d94b
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:15:38 -05:00
Szymon Janc 6b20c8c40d Bluetooth: SMP: Cleanup all old keys on re-pairing
When re-pairing was successful (indicated by enabling encryption with
STK) old keys are no longer needed as those will be replaced by keys
distributed in new pairing.

Change-Id: If2a81e8e94f35eb04ce9a7e4d782094632cbd77a
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:15:38 -05:00
Jukka Rissanen b617cbbfd1 net: tools: Usage info was missing -i option in echo-client
The -i (interface) option was not described in usage.

Change-Id: I50d01f0e639d3258234c5573abd8836a7144584e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:15:38 -05:00
Jukka Rissanen 607bc6deb2 net: tools: Clarify how to run echo-server in host
Add note about possible firewall issue in host.
Make sure you run echo-server as a root user.

Change-Id: I9ebe06db799eef8664d7d7ccb38827280e338f9d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:15:38 -05:00
Jukka Rissanen 882d53dce8 net: tools: echo-client did not return proper error code
So return 0 if all the tests run ok, and !=0 if some failed.

Change-Id: Ib66d84dbcc6cc29e5e46609b1e2b1b1748ce6fcc
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:15:38 -05:00
Jukka Rissanen 25dc3db624 net: apps: Fix the name of dtls-server
The test application name was printed incorrectly.

Change-Id: I1686dd886c26cd94dbf2482fe904bd61e66d4a78
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:15:38 -05:00
Jukka Rissanen 1098442d1f net: apps: Wait forever for network packets
Use the nano_fifo_get_wait() API when waiting network packets.
This function will block until there is data in the socket.
The timeout version called nano_fiber_fifo_get_wait_timeout()
is not working at the moment.

Change-Id: I42bddf8921cae0ed3caec8226b6086833534ae65
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:15:38 -05:00
Jukka Rissanen 662fc64009 net: Remove obsolete comment in net_init.c
Change-Id: I088c734317f0fe6efe1691fce26e2cab8febecb9
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:15:38 -05:00
Jukka Rissanen 1abb0b5792 net: Enhance debugging of mac net buffer allocations
Print information who allocated or freed mac net buffer.

Change-Id: I106e1703b7f5c3e5363d53d63c599a12b65577cb
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:15:38 -05:00
Jukka Rissanen b6230cac0a net: 15.4: Use stack analyze functions from net_buf.h
Use more generic stack analyze functions that are now
found in net_buf.h

Change-Id: I473665bbad8aa1a6749a4c5dc1d6952bdb56da5d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:15:38 -05:00
Jukka Rissanen 792bbbb6d8 net: Refactor the stack analyzer functions
Generalize the stack analyze functions so that they
can be used by other fibers.

Change-Id: If1fae51db45010b75f6ac58cd8d874b31ca336e2
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:15:38 -05:00
Jukka Rissanen 649a525329 net: Check NULL net_buf when releasing it
Make sure we are not trying to release a NULL net_buf.

Change-Id: Ie4d2e7cdbd4f85c5543874471cc7c7ce3bc0b9df
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:15:38 -05:00
Jukka Rissanen c9599d9d9b net: Fix the uip_buf() macro
The macro was incorrectly set and caused in certain case
wrong expansion.

Change-Id: I5198906a5066882d178c0fcff8c6816a5461f37a
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:15:38 -05:00
Jukka Rissanen 4b5a1d7172 net: tinydtls: Do not access NULL net_buf
If the net_buf allocation fails, then return and do not
try to access it.

Change-Id: Ib4c4a0b3a6669f6e6030357f3f2dd9af4dc638c8
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:15:38 -05:00
Jukka Rissanen 5ae65332ca net: Use new macros to access IP and UDP data
Use the new NET_BUF_IP() and NET_BUF_UDP() macros to access
IP and UDP data in the received network buffer.

Change-Id: Ic35ddf6fa8641aa6334b1207a8c2f1f19a39866f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:15:38 -05:00
Szymon Janc ae10411267 Bluetooth: SMP: Forbid JustWorks re-pairing of authenticated keys
Fail if we have keys that are stronger than keys that will be
distributed in new pairing. This is to avoid replacing authenticated
keys with unauthenticated ones.

Change-Id: If81b158f68a818d7a6e5d2854b482f34516b4737
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:15:38 -05:00
Szymon Janc 4f9ba8129b Bluetooth: Store key type in common structure
Keys from same pairing have are of similar key type and
this can be stored in single place.

Change-Id: I38426c282604769424098af6ee26e0cf9cb5f358
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:15:38 -05:00
Szymon Janc 90121208ab Bluetooth: Simplify keys management code
There is no need for separate lists of each key type as this
lookup optimization is of little benefit. Removing those results in
much simpler and smaller code. Using array over list also improves
data locality and thus cache utilization.

This patch results in following code size reduction:
keys.o from 14208 to 10028 bytes
microkernel.elf from 599417 to 597091 bytes

Change-Id: Ia8fe21ca3d79f668d8550c4376fa403e8778861e
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:15:38 -05:00
Szymon Janc b7f6e31264 Bluetooth: Fix cancelling outgoing connection in shell app
default_conn is assigned only on connected event so there was
no way to cancel pending outgoing connection.

Change-Id: Iba5018e887c5b3f87513fc5c8f4585fb6ec40c8d
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:15:37 -05:00
Grzegorz Kolodziejczyk e2673b539f Bluetooth: Use strcmp instead of strncmp
There is no need to use strncmp for string type arguments terminaded
by NUL character.

Change-Id: Ib90517f4657de8da64f145afd0ac28aefa697026
Signed-off-by: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
2016-02-05 20:15:37 -05:00
Grzegorz Kolodziejczyk c688f327b1 Bluetooth: Use unified help cmd tip label for advertise cmd
To avoid multiple prints with cmd help one label will be used.

Change-Id: Ieaaffd8b4321fdb2ad2f95894d293ec1d6eb8d10
Signed-off-by: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
2016-02-05 20:15:37 -05:00
Johan Hedberg bac8917917 Bluetooth: SMP: Clean up and unify remote key distribution tracking
Ensure smp->remote_dist tracks unreceived PDUs both for slave and
master role, and use the same logic in all PDU handlers for
remote_dist and allowed_cmds.

Change-Id: If4769d0be0118e8e764d7483f0d93ef8b61fa398
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:15:37 -05:00
Grzegorz Kolodziejczyk ee178d0970 Bluetooth: Fix wrong read included function name
Other function name was used "bt_gatt_attr_read_included" by include
than the implementation "bt_gatt_attr_read_include" has.
Function naming mismatch caused linker error if used included service
define.

Change-Id: Ib4b4d07050d634cb1578c8a8948322acad85a307
Signed-off-by: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
2016-02-05 20:15:37 -05:00
Johan Hedberg 49cc10dcfd Bluetooth: uart: Minor coding style fix
Change-Id: Ide37ce471d99e911507316ea720e7aaff1dac744
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:15:37 -05:00