Commit graph

2591 commits

Author SHA1 Message Date
Vinayak Kariappa Chettimada fe0cebedcf Bluetooth: controller: Refactor phy req/rsp PDU struct
Refactor the pdu_data_llctrl_phy_req_rsp struct into
pdu_data_llctrl_phy_req and pdu_data_llctrl_phy_req structs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-02-05 16:48:37 +01:00
Vinayak Kariappa Chettimada 9abf8ce0a0 Bluetooth: controller: Refactor length req/rsp PDU struct
Refactor the pdu_data_llctrl_length_req_rsp struct into
pdu_data_llctrl_length_req and pdu_data_llctrl_length_req
structs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-02-05 16:48:37 +01:00
Ioannis Glaropoulos d09baafe64 Bluetooth: controller: inline implementation of radio-enable-on-tIFS
This commit implements a minor refactoring of the implementation
for enabling the Radio on TIFS expiration. It inlines a function
that is defined in the local radio_nrf5_ppi header file.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2018-02-05 16:25:41 +01:00
Ioannis Glaropoulos 2764084561 Bluetooth: controller: implement sw-switch with the event timer
This commit contributes the implementation of the sw-switch for
tIFS in nRF5 Radio using the EVENT_TIMER instead of a dedicated
TIMER instance. A Kconfig configuration is added so the user can
select whether to use the EVENT_TIMER for the tIFS switch or use
a dedicated TIMER instance.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-02-05 16:25:41 +01:00
Ioannis Glaropoulos 0ec1095dd6 Bluetooth: controller: sw-switch with the event timer (prepare commit)
This commit implements minor refactoring of radio.c and ctrl.c,
to prepare for adding the implementation of sw-switch based on
the event timer.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2018-02-05 16:25:41 +01:00
Ioannis Glaropoulos 9c4dc04ba5 Bluetooth: controller: conditionally reuse CC for ISR profiling
This commit adds the option of conditionally reuse an existing
CC register of the event timer for timer sampling used in ISR
profiling, in case SW tIFS switching is implemented based on the
event timer.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-02-05 16:25:41 +01:00
Ioannis Glaropoulos 2a85dda206 Bluetooth: controller: symbolic name for CC used in ISR profiling
This commit adds a symbolic name for the event timer
CC offset that is used to sample the event timer during
ISR profiling.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-02-05 16:25:41 +01:00
Vinayak Kariappa Chettimada d4cc46c453 Bluetooth: controller: refactor radio_nrf5* headers
Refactor radio_nrf5* header files to group together
definitions and have less #if-#else-#endif.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-02-05 16:25:41 +01:00
Marti Bolivar e2c9be1a18 dfu: mcuboot: add boot_read_bank_header()
This is an accessor function for the MCUboot image header of an image
bank. The interface may seem a little cumbersome, but it is
future-proof against MCUboot feature and incompatible header version
changes.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-02-05 06:42:15 -08:00
Marti Bolivar 01aa12bffd dfu: mcuboot: add boot_is_img_confirmed()
Applications chainloaded by MCUboot may want to change their behavior
based on whether or not they are confirmed.

Here are some examples:

  - performing a built-in self test (BIST) if the image is not yet
    confirmed, and marking it OK if it passes (this enables reverting
    to an older working image if the BIST fails, and allows future
    resets to skip the BIST if it passes to improve boot time)

  - interacting with persistent metadata related to image state on
    other flash partitions during test upgrades (these are required in
    cases when the update source provides runtime metadata, such as
    monotonic counters, related to an upgrade attempt which must be
    used to report results)

To enable these use cases, add boot_is_img_confirmed(), which reads
the "image OK" field for the current firmware image and returns true
if and only if it is set.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-02-05 06:42:15 -08:00
Marti Bolivar 4877dd22ea dfu: mcuboot: delete misleading comment
There is more information in the trailer than indicated by this comment.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-02-05 06:42:15 -08:00
Marti Bolivar 389060fb00 dfu: mcuboot: don't use magic when confirming image
The current implementation of boot_write_img_confirmed() does not
write the image OK byte in flash bank 0 if the magic "request upgrade"
bytes in that bank are "good". This is not robust behavior.

The MCUboot design document has this to say about the image OK byte:

   Upgrading an old image with a new one by swapping can be a two-step
   process. In this process, mcuboot performs a "test" swap of image
   data in flash and boots the new image. The new image can then
   update the contents of flash at runtime to mark itself "OK", and
   mcuboot will then still choose to run it during the next boot.

   [...]

    4. Image OK: A single byte indicating whether the image in this
       slot has been confirmed as good by the user (0x01=confirmed;
       0xff=not confirmed).

This says nothing about the magic bytes, so it'd be better not to make
assumptions about their effect here.

Further, MCUboot itself does not use the magic field when marking the
only known-good image on flash "OK" after either reverting a failed
upgrade or refusing to boot an upgrade iamge with an invalid
signature: instead, it unconditionally ensures the Image OK byte is
set to 0x01.

For consistency with MCUboot's design and implementation, remove the
lines that look at the magic bytes from boot_write_img_confirmed().

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-02-05 06:42:15 -08:00
Johan Hedberg 2ff98636a5 Bluetooth: Mesh: Add support for OOB info and URI in provisioning data
Until now the OOB info and URI fields in unprovisioned beacons were
generally ignored by the implementation. Add fields for these to
bt_mesh_prov and make sure to take them into account when encoding
advertising data, both for PB-ADV and PB-GATT. For PB-ADV the URI goes
out in a separate beacon, whereas for PB-GATT it is placed in the scan
response data.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-02-05 12:46:05 +02:00
Robert Chou 54d7207e09 net: lwm2m: check content-format and respond with error if not support
Currently, we always set the content-format as "plain/text" when
it is unrecognized. This is wrong for it's possible that payload
is actually something else.

For example, we don't support JSON as incoming format right now.
But if I send a PUT request to /1/0/1 (server objectinstance/lifetime
resource) with value 3200 in JSON format: {"e":[{"n":"","v":3200}]}.
The client will still handle the request and respond with changed (2.04)
except the lifetime resource is updated incorrectly due to parsing
error.

Correct the behavior by not setting a default format and respond with
content-format-not-support error code (4.15)

Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
2018-02-05 09:05:00 +02:00
Alberto Escolar Piedras bfabdf1de5 shell: Added noprompt command
Added noprompt command to shell. It will disable printing
the prompt.
For the native port, when feeding commands from a file or
pipe the prompt reprinting after each command (without echoing)
just confuses the user.

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2018-02-02 07:48:46 -08:00
Alberto Escolar Piedras e3f727cc6e native: added stdin handling for shell
Now the native console driver also handles stdin
so we can drive the shell from the command line,
a pipe or a file

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2018-02-02 07:48:46 -08:00
Ravi kumar Veeramally 9489fa54cc net: http: Fix http_prepare_and_send
net_pkt_append() has been changed. If payload reached max value
of 'data_len' in net packet, net_pkt_append will not append.
So the caller has to create new packet and append remaining payload.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2018-02-02 16:50:07 +02:00
Ravi kumar Veeramally d6ca4decea net: Unlink the neighbor after unref
Unlinking of neighbor also needed after nbr_unref. Otherwise
neighbor id is still in use and can not be linked further.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2018-02-02 16:50:07 +02:00
Ravi kumar Veeramally 82f23bc276 net: rpl: Fix handling of DAO message
When a node receives DIO message from peer then node adds peer as
a neighbor (nbr with linklayer address). But when a node receives
DAO message from different peer (chances are peer selected
different route to reach this node), remove peer with previous
link layer address and add as a neighbor with new link layer address
with new route information. Now node can properly route packets to
peer from neighbor table or based on nexthop information from
routing table.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2018-02-02 16:50:07 +02:00
Ravi kumar Veeramally 6245dd68d9 net: rpl: Ignore parents with lower rank
When a node joins in DAG network, it chooses neighbor (node or border
router) as its parent. But if it receives DIO message from another
peer, it can only act as a neighbor, not as a parent. If peer rank
is better than current preferred parent rank then node will select
new peer as it's best parent.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2018-02-02 16:50:07 +02:00
Ravi kumar Veeramally cfc8749133 net: rpl: Fix debug information and alignment issues
RPL prints lot of debug information which is difficult to track.
Minimized debugs in timer specific information and parsing of
DIO and DAO options. Also fixed alignment issues (no changes in
functionality)

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2018-02-02 16:50:07 +02:00
Ravi kumar Veeramally ebf56ed1a6 net: mgmt: Fix mgmt push event
Do not even consider the push event if CONFIG_NET_MGMT_EVENT_INFO
enabled and info length is more than NET_EVENT_INFO_MAX_SIZE.
Print error message and ignore the event.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2018-02-02 16:50:07 +02:00
Ravi kumar Veeramally ed2fcaeb8a net: rpl: Change default value for NET_RPL_INIT_LINK_METRIC
Current default value for NET_RPL_INIT_LINK_METRIC is 2, changing it
to 1.

e.g. NET_RPL_MIN_HOP_RANK_INC is 256 and NET_RPL_MC_ETX_DIVISOR is 256.
     Rank calculation for nodes is
     rank_increase = CONFIG_NET_RPL_INIT_LINK_METRIC *
                             NET_RPL_MC_ETX_DIVISOR;

     Which gives 768 for first set of child nodes. It would be good if
     CONFIG_NET_RPL_INIT_LINK_METRIC value is 1 and nodes ranks will be
     245, 512, 768 based on the path they choose.

User can absolutely change their configuration to maintain proper ranks.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2018-02-02 16:50:07 +02:00
Ravi kumar Veeramally e567ca4f44 net: rpl: Do not run IPv6 DAD for global addresses
When CONFIG_NET_RPL enabled, do not run DAD (duplicate address
detection) for global addresses. In RPL mesh network global addresses
for nodes are determined by prefix from Border Router. DAD is not
necessary in this case.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2018-02-02 16:50:07 +02:00
Ravi kumar Veeramally 83bda0f037 net: Add IPv6 route add and delete event with info
If CONFIG_NET_MGMT_EVENT_INFO is enabled then provide mgmt info
about the route, which is added or deleted.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2018-02-02 16:50:07 +02:00
Ravi kumar Veeramally 9010def93e net: Add IPv6 neighbor add and delete event with info
If CONFIG_NET_MGMT_EVENT_INFO is enabled then provide mgmt info
about the neighbor, which is added or deleted.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2018-02-02 16:50:07 +02:00
Ravi kumar Veeramally 5e65444d04 net: ipv6: Remove route information before deleting neighbor
Remove any routes with neighbor as a nexthop first and then remove
neighbor from neighbor table.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2018-02-02 16:50:07 +02:00
Ravi kumar Veeramally 49894b98e4 net: Improve net management event information
Provided separate event information structs based on events. This way
user will know what kind of information will be received to that
particular event.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2018-02-02 16:50:07 +02:00
Ravi kumar Veeramally ef36088608 net: Fix RPL header update
When net_ipv6_prepare_for_send() needs to route packets, it missed
updating of RPL header.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2018-02-02 16:50:07 +02:00
Jukka Rissanen 182b054a9f net: rpl: Setup DAG prefix into network interface
This is needed in routing if we are acting as border router.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-02-02 16:50:07 +02:00
Jukka Rissanen 6167f0f70c net: rpl: Do not do neighbor discovery for RPL network
Doing neighbor discovery in RPL network is not necessary and
that can be disabled in RPL nodes. Unfortunately the border
router needs to have ND enabled as it has also non-RPL network
interfaces in use. So in this case, mark RPL node as always
reachable.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-02-02 16:50:07 +02:00
Jukka Rissanen d4d0ddd4f7 net: ipv6: Add some extra debug when updating link address length
As this is very specialized info which is not normally needed,
do not print it by default.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-02-02 16:50:07 +02:00
Jukka Rissanen e5b9e4d6ad net: ipv6: Add routing support between interfaces
Introduce CONFIG_NET_ROUTING option that allows the IP stack
to route IPv6 packets between multiple network interfaces.
No support for IPv4 routing is implemented by this commit.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-02-02 16:50:07 +02:00
Juan Manuel Torres Palma ff7f1bf9db net: arp: remove shadowing variable
Removes variable shadowing another declared
previously but does not change anything
functionally.

Signed-off-by: Juan Manuel Torres Palma <j.m.torrespalma@gmail.com>
2018-02-02 16:48:53 +02:00
Vinayak Kariappa Chettimada 258c7ccff1 Bluetooth: controller: Fix HCI LE Set PHY invalid behavior check
Fix HCI LE Set PHY command for invalid behavior testing for
invalid parameters and unsupported features.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-02-02 10:41:46 +01:00
Vinayak Kariappa Chettimada a1f12eb238 Bluetooth: controller: Fix redundant length update event
Fix generation of redundant length update event when no
change in effective octets or time.

Fixes LL.TS.5.0.2 conformance tests:
LL/CON/MAS/BV-73-C [Master Data Length Update - Responding
	to Data Length Update Procedure; LE 1M PHY]
LL/CON/MAS/BV-74-C [Master Data Length Update - Initiating
	Data Length Update Procedure; LE 1M PHY]
LL/CON/MAS/BV-76-C [Master Data Length Update - Responding
	to Data Length Update Procedure; LE 2M PHY]
LL/CON/MAS/BV-77-C [Master Data Length Update - Initiating
	Data Length Update Procedure; LE 2M PHY]
LL/CON/SLA/BV-77-C [Slave Data Length Update - Responding
	to Data Length Update Procedure; LE 1M PHY]
LL/CON/SLA/BV-78-C [Slave Data Length Update - Initiating
	Data Length Update Procedure; LE 1M PHY]
LL/CON/SLA/BV-80-C [Slave Data Length Update - Responding
	to Data Length Update Procedure; LE 2M PHY]
LL/CON/SLA/BV-81-C [Slave Data Length Update - Initiating
	Data Length Update Procedure; LE 2M PHY]

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-02-02 10:40:52 +01:00
Johan Hedberg 0b7ac73eb6 Bluetooth: Mesh: fix BT_MESH_LPN_POLL_TIMEOUT description
The calculation was off by a factor of 10.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-02-01 12:37:09 -08:00
Vinayak Kariappa Chettimada 5c57027f53 Bluetooth: controller: Fix to use CPR preferred periodicity value
Fixed implementation to use Connection Parameter Request
Procedure Preferred Periodicity value in calculating the new
connection interval used by the master role in Connection
Update Indication.

Fixes LL.TS.5.0.2 conformance tests:
LL/CON/MAS/BV-32-C [Accepting Connection Parameter Request –
	Preferred_Periodicity]
LL/CON/MAS/BV-33-C [Accepting Connection Parameter Request –
	Preferred_Periodicity and preferred anchor points]

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-02-01 16:51:54 +01:00
Paul Sokolovsky fbaa3b1724 net: tcp: prepare_segment: Return detailed error codes.
prepare_segment() returned NULL in case of any error, which then
net_context_send() translated into -EINVAL. That's highly confusing
though, because a common case of failure for prepare_segment() is
being unable to allocate data fragment(s) (for TCP header, etc.)
So, return output pkt by reference, and detailed error status as
a return value.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-02-01 13:13:32 +01:00
Johan Hedberg d6b905910b Bluetooth: Mesh: Fix passing CID to model publication messages
The vendor variants of the model publication client messages were not
passing onward the CID, rather passing CID_NVAL which is clearly not
right.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-01-31 13:35:36 -08:00
Vinayak Kariappa Chettimada 9acfc7fb5c Bluetooth: controller: Fix to restrict addr set in initiator
Fix controller implementation to restrict HCI LE Set Random
Address command when advertising and/or active scanning
and/or initiator state is enable.

Fixes LL.TS.5.0.2 conformance tests:
LL/CON/INI/BV-01-C [Connection Initiation]
LL/SEC/ADV/BV-01-C [Advertising With Static Address]
LL/SEC/SCN/BV-01-C [Random Address Scanning]

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-01-31 10:54:26 -08:00
Vinayak Kariappa Chettimada 7af9c7108f Bluetooth: controller: Fix for CPR with/without Feature Exchange
Fix implementation to support Connection Parameter Request
Procedure initiation with and without use of Feature
Exchange Procedure being performed in a connection.

Fixes LL.TS.5.0.2 conformance tests:
LL/CON/MAS/BV-81-C [Initiating Connection Parameter Request
	- Unsupported Without Feature Exchange]
LL/CON/MAS/BV-82-C [Initiating Connection Parameter Request
	- Unsupported With Feature Exchange]
LL/CON/SLA/BV-85-C [Initiating Connection Parameter Request
	- Unsupported Without Feature Exchange]
LL/CON/SLA/BV-86-C [Initiating Connection Parameter Request
	- Unsupported With Feature Exchange]

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-01-31 16:02:14 +01:00
Johan Hedberg 8fc4c99496 Bluetooth: Remove redundant AD parsing check
A few lines earlier the code bails out in case len is 0. Checking for
buf->len < 1 is the same as checking for buf->len == 0. Since len is
guaranteed to be > 0 here the check len > buf->len implicitly checks
for buf->len == 0, i.e. the second test can be removed.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-01-31 07:01:10 -08:00
Johan Hedberg 7ae78c9928 Bluetooth: Mesh: Fix segment transmission timeout
The timeout was hard-coded to 400ms, but the spec actually states:

"This timer shall be set to a minimum of 200 + 50 * TTL milliseconds."

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-01-31 06:59:49 -08:00
Johan Hedberg 1150858d8f Bluetooth: Mesh: Fix ack timeout calculation
The caculation was wrong since the value may be BT_MESH_TTL_DEFAULT,
i.e. 0xff, leading to much too large values.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-01-31 06:59:49 -08:00
Johan Hedberg fee8734874 Bluetooth: Mesh: Clear segment rx context when incomplete timer expires
https://www.bluetooth.org/errata/errata_view.cfm?errata_id=10321

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-01-31 06:59:49 -08:00
Johan Hedberg fde013b254 Bluetooth: Mesh: Take advantage of K_SECONDS macro
This makes the code slightly more readable.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-01-31 06:59:49 -08:00
Johan Hedberg a0ab6086e3 Bluetooth: Mesh: Fix ignoring old SeqAuth values
Replay protection is not enforced at the Lower Transport Layer, so it
is possible to get an old replayed segment here. In such a case
cleanly discard it instead of causing a valid existing transaction
from being discarded.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-01-31 06:59:49 -08:00
Michael Hope cff16051bb disk: delete the GET_DISK_SIZE IOCTL.
The argument is a u32_t which limits the maximum disk size to 4 GiB.
Rather than fix this, delete the ioctl and switch the only use to
GET_SECTOR_COUNT instead.

Signed-off-by: Michael Hope <mlhx@google.com>
2018-01-31 09:14:40 -05:00
Andrei Emeltchenko e8ccb16986 usb: hid: Add Human Interface Device (HID) class
Add support for Human Interface Device USB class.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-31 07:42:19 -05:00
Andrei Emeltchenko 8f21a37861 usb: Clean up code to meet Zephyr standard
Add missing "{}" braces and remove unneeded "()" braces.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-31 07:42:19 -05:00
Andrei Emeltchenko 60f8c6e272 usb: usbnet: Clean up code
Use common logging method and correct braces.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-31 07:42:19 -05:00
Andrei Emeltchenko 17735e8a04 usb: netusb: Remove USB custom_handler()
Custom handler is not used, cleaning code.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-31 07:42:19 -05:00
Andrei Emeltchenko 6e2e2dbb1b usb: msc: Clean up comment
Trivial cleaning

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-31 07:42:19 -05:00
Michael Scott afb9830441 net: lwm2m: fix retransmit_request() pending process / packet send
During the CoAP API change, slight changes were made the ref / unref
packet pending process.  Let's re-align with the coap-client sample
in how we apply the packet refs in retransmit_request() and also
replace the lwm2m_send_message() call with a direct call of
net_app_send_pkt().  This avoids a second processing of the pending
packets and keeps the ref/unref flow cleaner.

Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
2018-01-31 12:20:41 +02:00
Michael Scott db09596b1d net: lwm2m: correct packet pending process in lwm2m_send_message()
During the CoAP API change, the way packets were ref'd and then
unref'd in order to stop the packet sending functions from releasing
the net_pkts was changed and never updated in the LwM2M library.

Let's use coap_pending_cycle() and coap_pending_clear() to do the
ref/unref the same way as the coap-client samples in order to
match the pending process with the current CoAP APIs.

Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
2018-01-31 12:20:41 +02:00
Vinayak Kariappa Chettimada d03ad43dbb Bluetooth: controller: Fix to restrict addr set in active scan
Fix controller implementation to only restrict HCI LE Set
Random Address command when advertising and/or active
scanning is enable.

Continues to pass the following LL.TS.5.0.2 conformance
test:
LL/SEC/SCN/BV-01-C [Random Address Scanning]

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-01-31 10:16:47 +01:00
David B. Kinder baed5a59c7 doc: fix misspellings in Kconfig files
Fix misspellings in Kconfig files used for configuration docs.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-01-30 20:03:40 -05:00
Ramakrishna Pallala 5155e68105 subsys: disk: Kconfig: add prompt messages for config options
Add prompt messages for config options dependent on DISK_ACCESS_FLASH

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
2018-01-30 11:32:02 -05:00
Robert Chou 6fbd86113d net: lwm2m: fix reporting attributes with negative fraction
Fraction could be stored with negative value.
The implementation was only considering the positive value case.
Therefore, we have to modify the code to take care of the case.

To test it
======================================================================
1. launch eclipse/wakaama lwm2m server
2. launch zephyr lwm2m client and wait for registration completed
3. Issue commands from server
   * attr 0 /1/0/1 -0.1 0.1
   * disc 0 /1/0

Current output
----------------------------------------------------------------------
Client #0 /1/0 : 2.05 (COAP_205_CONTENT)
105 bytes received of type application/link-format:
</1/0>,</1/0/0>,</1/0/1>;gt=0.1;lt=0/00000,</1/0/2>,</1/0/3>,</1/0/4>,
</1/0/5>,</1/0/6>,</1/0/7>,</1/0/8>

Expected output
----------------------------------------------------------------------
Client #0 /1/0 : 2.05 (COAP_205_CONTENT)
102 bytes received of type application/link-format:
</1/0>,</1/0/0>,</1/0/1>;gt=0.1;lt=-0.1,</1/0/2>,</1/0/3>,</1/0/4>,
</1/0/5>,</1/0/6>,</1/0/7>,</1/0/8>

Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
2018-01-29 23:30:44 -05:00
Jukka Rissanen d1675bf3e6 net: http: Remove the old legacy API
There are no internal users for old HTTP API so removing it.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-01-29 22:44:45 -05:00
Kamil Sroka 95cb365fae subsys: net: ip: l2: Add OpenThread L2
Add OpenThread to Zephyrs net stack as data link layer.
OpenThread requires to call process function when an event occurs.
This process function is called from cooperative thread.

Packet conversion and dispaching is implemented in openthread.c
as well as addresses forwarding.

Signed-off-by: Kamil Sroka <kamil.sroka@nordicsemi.no>
2018-01-29 22:42:03 -05:00
Kamil Sroka 83b2218ab5 subsys: net: lib: Add OpenThread platform
OpenThread requires platform definition with standarized API
so we have to add wrappers to make it compatible with Zephyr.
OpenThread is based on autoconf, this requires
more specific CMakeLists.txt which allows to clone specific
commit or point to local copy of openthread.

Signed-off-by: Kamil Sroka <kamil.sroka@nordicsemi.no>
2018-01-29 22:42:03 -05:00
Vinayak Kariappa Chettimada f117505773 Bluetooth: controller: Fix to restrict addr set in active states
Fixed implementation to disallow setting Bluetooth device
address under active advertising or scanning states.

Fixes LL.TS.5.0.2 conformance tests:
LL/CON/INI/BV-01-C [Connection Initiation]
LL/SEC/ADV/BV-01-C [Advertising With Static Address]
LL/SEC/SCN/BV-01-C [Random Address Scanning]

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-01-29 18:03:15 +01:00
Alberto Escolar Piedras ec7727077b native: nrf52 changes to HAL to support running on simulated HW
Conditionally compiled changes to the NRF52 HAL so it can
run on simulated HW on the native port.
(HW models are not included in this commit)

All changes are under ifdefs and therefore will not have any
effect on normal builds

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2018-01-29 16:02:29 +01:00
Vinayak Kariappa Chettimada 619bcf56c4 Bluetooth: controller: Refactor mayfly integration into hal
Refactor mayfly based execution context solution out into
the HAL folder. This opens up the possibility to use
tasklets (if and when kernel gets the support) style
execution contexts.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-01-29 13:04:15 +01:00
Vinayak Kariappa Chettimada f5d64aafaa Bluetooth: controller: Fix CPR initiation while in Enc. setup
Fixes a bug where in Connection Parameter Request was
initiated by slave role while Encryption Setup had been
started by the peer master.

Fixes: #5823

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-01-26 11:35:17 +01:00
Johann Fischer daa83f8823 usb: mass_storage: rework and cleanup logging
This patch reworked logging so that the logging levels are more
finely graded and the locations with non-critical error handling
(below usb_ep_set_stall's) are logged with SYS_LOG_WRN.
Also cleanup, add log domain and fix indents.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-01-26 08:35:08 +05:30
Kumar Gala 26e4da52cf arm: nordic: flash: Use FLASH_DEV_NAME define
We want to move to use a common FLASH_DEV_NAME across the various flash
drivers. So samples, tests, or other code can be a bit more generic.  So
replace CONFIG_SOC_FLASH_NRF5_DEV_NAME with FLASH_DEV_NAME.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-01-25 15:23:00 -06:00
Vinayak Kariappa Chettimada 4d7d9de342 Bluetooth: controller: Refactor LL up and downstream interface
Rename some legacy upstream and downstream interfaces in
radio_* namespace to ll_* namespace for consistency.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-01-25 22:09:17 +01:00
Vinayak Kariappa Chettimada 5b0cd2c69b Bluetooth: controller: Conditional compile BT_LL_SW variant
Refactor Kconfig and CMakelists.txt to be able to
conditionally compile in BT_LL_SW variant in the controller
subsystem. This is done to support future controller with
vendor specific variant implementations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-01-25 11:51:10 +01:00
Vinayak Kariappa Chettimada ae9f5b38d0 Bluetooth: controller: Add missing CPR and DLE cond. compilation
Add missing conditional compilation in controller's HCI
implementation, removing redundant code being compiled in.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-01-25 11:16:45 +01:00
Vinayak Kariappa Chettimada 5f4a7ea119 Bluetooth: shell: Support a non-connectable build
Add conditional compilation and move code to support
building a non-connectable Bluetooth shell application.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-01-25 10:51:54 +02:00
Vinayak Kariappa Chettimada be0aa2ac2c Bluetooth: controller: Remove redundant clear of NRF_RADIO events
Remove redundant code that clears NRF_RADIO->EVENT_*
registers that are only used in PPI context. Only EVENT_*
registers that are read back need to be cleared.

Relates to: #5753

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-01-24 11:07:06 +01:00
Ioannis Glaropoulos 9d1ca9c390 Bluetooth: controller: remove redundant PPI channel and TIMER CC
This commit implements the SW-based radio switch for TIFS for LE
Coded PHY S2 in nRF52840 with a single PPI channel and a single
TIMER CC register.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2018-01-24 11:06:33 +01:00
Ioannis Glaropoulos adaef465e4 Bluetooth: controller: minor refactoring in nrf5 radio driver
This commit moves the radio enable on-tick functionality in
function hal_radio_enable_on_tick_ppi_config_and_enable() in
radio_nrf5_ppi.h.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2018-01-24 11:06:33 +01:00
Ioannis Glaropoulos 36ded0b516 Bluetooth: controller: adjust nRF52840 HW radio timings for Coded PHY
This commit adjust the nRF52840 HW Radio timings for LE Coded PHY.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2018-01-24 11:06:33 +01:00
Vinayak Kariappa Chettimada 13130dbe73 Bluetooth: controller: Fix BT_CTLR_DEBUG_PINS Kconfig help text
Help text for BT_CTLR_DEBUG_PINS incorrectly mentioned
specific GPIO pins being reserved for this feature, but in
reality the pins reserved vary on the SoC selected, hence
any specific mention of pin details is removed from help
text.

Fixes: #5499

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-01-24 11:05:51 +01:00
Paul Sokolovsky 996c6dd603 net: if: Handle new address type of NET_ADDR_OVERRIDABLE
The meaning of this address type is the same as NET_ADDR_MANUAL,
but with a provision that DHCP can override such an address.
It's intended for the usecase when there's a default static
configuration for when DHCP is not available, but DHCP should
override it.

Before going to add another address type, there was an attempt
to repurpose TENTATIVE address state, but it doesn't work as
expected, as indeed, all existing address types/states already
have clearly semantics, and it makes sense to just another
address type to avoid confusion and unexpected behavior.

Fixes: #5696

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-01-23 09:25:51 +02:00
Paul Sokolovsky c57abaa7c8 net: app: Allow to specify both static IP settings and DHCPv4.
The idea is that static config is used unless/until DHCP values
arrive. This allows to have the same network configuration values
for both a case of direct board - workstation connection (where
DHCP is usually not available), and a case where both a board and
workstation connect to a router (which serves DHCP).

The changes in this commit however take care of netmask and gateway
settings, but not about IP address itself. This is addressed in the
next patch.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-01-23 09:25:51 +02:00
Vinayak Kariappa Chettimada 5d4a32b70a Bluetooth: controller: Fix missing TIFS_HW cond. compilation
Fix a missing !CONFIG_BT_CTLR_TIFS_HW conditional
compilation when nRF52840 is configured to use hardware
Trx switching, that caused compile error.

Fixes: #5779
Fixes: #5761

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-01-22 15:33:15 -06:00
Anas Nashif e1d284f648 shell: rename get_mod_cmd
rename function and call out module in the name.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-19 12:01:08 -05:00
Anas Nashif d7777d3bd5 shell: support standalone commands
This will allow us to register commands directly without a need for a
module.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-19 12:01:08 -05:00
Anas Nashif 8d1931504a shell: rename module sections
Prepare for supporting stand-alone commands.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-19 12:01:08 -05:00
Anas Nashif 16424cf0bc shell: kernel: rename tasks -> threads
Rename tasks -> threads, task was the common name for threads before the
unified kernel was introduced.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-19 12:01:08 -05:00
Anas Nashif dd013691b2 shell: add a shell banner
Give details about running version and add a line about usage.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-19 12:01:08 -05:00
Mariusz Skamra 0572fe99ec Bluetooth: mesh: Check Heartbeat Pub count prior scheduling delayed work
This check is needed to not schedule the delayed work if current
message to be sent is the last heartbeat message.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-19 14:07:48 +02:00
Mariusz Skamra 37122d7205 Bluetooth: mesh: Reset Heartbeat Pub timer before sending message
The timer should be reset before sending to ensure correct
publication period.

This patch allows to pass MESH/NODE/CFG/HBP/BV-02-C.

This patch is ported from mynewt:
Commit: d4b84638df47e7ea21629e6919f547f5dcd47285

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-19 14:07:48 +02:00
John Andersen b0d8075709 net: ip: dhcpv4: Handle DHCPV4_OPTIONS_DNS_SERVER
Actually set Zephyr's default DNS server based on the corresponding
DHCP option received. This makes DHCP-based setup Zephyr complete:
now it's possible to connect Zephyr DHCP-enabled system to a typical
router, and it will fully auto-configure to access Internet.

This initial implementation uses just first DNS server address as
returned in DHCP message, it may need to be extended in the future
based on the need.

Signed-off-by: John Andersen <john.s.andersen@intel.com>
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-01-18 17:30:40 +02:00
Paul Sokolovsky d965598ee2 net: dns: Allow to initialize DNS servers from struct sockaddr[]
In some cases, we need to initialize DNS servers from a binary
addresses, e.g. in case of DHCP processing. With existing API,
such addresses would need to be converted to strings, just to
be converted back to struct sockaddr in dns_resolve_init().
This is not efficient, and with a number of addresses quite
cumbersome. So instead, allow to pass DNS server either as
strings, or as struct sockaddr's (or both).

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-01-18 17:30:40 +02:00
Paul Sokolovsky a3231798ae net: lib: dns: dns_resolve_close: Mark context as unused
So it can be dns_resolve_init()ed again.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-01-18 17:30:40 +02:00
Ioannis Glaropoulos 55d3ce111c Bluetooth: controller: Refactoring nRF5 radio driver
This commit refactors the nRF5 radio driver of Bluetooth controller
to use symbolic names for PPIs. It also revisits the Radio hardware
timing constants to align with experimental measurements.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2018-01-18 10:58:04 +01:00
Andrei Emeltchenko ca9c3ad8f1 usb: rndis: Use offsetof macro to ease offset calculations
Use macro offsetof() for calculating offset inside structure.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-17 18:53:05 -05:00
Andrei Emeltchenko be1d865409 usb: Add RNDIS packet boundary check
Add check for rndis_set_handle() packet.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-17 18:53:05 -05:00
Andrei Emeltchenko cd4cea0527 usb: netusb: Add Networking logging debug level
Adding Networking USB Device Debug level allows to fine-tune
logging.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-17 18:53:05 -05:00
Andrei Emeltchenko 6d61c2cf24 usb: rndis: Select USB_COMPOSITE_DEVICE for RNDIS
Windows works better with this option.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-17 18:53:05 -05:00
Andrei Emeltchenko 2a1bdc2549 usb: Set Class Handler buffer size to 256 for RNDIS
Set default value for RNDIS.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-17 18:53:05 -05:00
Andrei Emeltchenko 33e9851254 usb: rndis: Add Remote NDIS protocol handling
Add implementation of Microsoft Remote NDIS USB Ethernet protocol.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-17 18:53:05 -05:00
Andrei Emeltchenko 337601b42f usb: rndis: Add RNDIS device descriptors to the table
Add needed descriptors for USB Remote NDIS Ethernet Network.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-17 18:53:05 -05:00
Andrei Emeltchenko b4ae3ec32f usb: Add init() callback to network device functions
Add init() callback needed for RNDIS and maybe others functions.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-17 18:53:05 -05:00
Andrei Emeltchenko 2615658027 usb: Use standard SYS_LOG_USB_DEVICE_LEVEL for log level
Change hardcoded value to configuration defined.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-17 18:53:05 -05:00
Andrei Emeltchenko 7e80f41162 usb: Rename SYS_LOG_USB to SYS_LOG_USB_DEVICE
At the moment CONFIG_SYS_LOG_USB_LEVEL name does not specify that this
is log level for the Device Stack. Make it clear renaming to the
proper name.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-17 18:53:05 -05:00
Andrei Emeltchenko 42d160a315 usb: netusb: Remove unneeded debug
Remove old unneeded debug statements.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-17 18:53:05 -05:00
Paul Sokolovsky 9e37dbeabe net: shell: Fix typo in description of "dns" command.
Was "is configure", should be "is configure*d*".

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-01-17 17:08:54 -05:00
Mariusz Skamra 385240ad0c Bluetooth: Fix BT_TESTING option dependency
This removes BT_DEBUG dependency on BT_TESTING flag.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-16 14:40:54 +02:00
Michael Hope ed35aa8c63 net: use UNALIGNED_ACCESS when accessing s_addr on received packets.
The offset of the IP header in a received packet depends on the L2
header size.  For Ethernet this is 14 bytes which puts the u32 IPv4
addresses on a non-u32 byte boundary.  This causes chips that don't
support unaligned access (like the Cortex-M0) to fault.

The fixes in this patch are enough to ping the board and run the
http_server sample.

Signed-off-by: Michael Hope <mlhx@google.com>
2018-01-16 11:27:48 +02:00
Patrik Flykt 010fb40b95 subsys: usb: Set Zephyr project USB Vendor and Product IDs
Document USB Vendor and Product IDs and their intended usage.
Set the Vendor and Product IDs and define the USB bcdDevice
Device Descriptor Device Release Number to be the binary
coded decimal representation of the Zephyr major and minor
kernel version number.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-01-15 15:47:53 -05:00
Andrzej Puzdrowski f8a674b45e subsys: storage: flash_map: devices bindings fetch optimalization
Moved fetch of flash device bindings to early initialization of the
application.
Device bindings are constant while the application is running so
it is better to fetch it at startup, and not every time flash_map
procedures are called.


Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2018-01-15 15:46:37 -05:00
Andrzej Puzdrowski b7f1289847 subsys: fs: Add Flash Circular Buffer
Zephyr already supports NFFS as a storage layer, but it might
be a little bit too heavyweight for certain applications in
memory-restricted ICs.

This module is response for need of Lightweight flash storage
capability. FCB is ported form MyNewt as native zephyr module.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2018-01-15 15:46:37 -05:00
Andrzej Puzdrowski 25269fb0ed subsys: storage: Add flash_map abstraction module
Introduce flas_map module is abstraction over flash memory and its
driver for using flash memories along with description of
available flash areas.
Module provides simple API for write/read/erase and so one.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2018-01-15 15:46:37 -05:00
Tomasz Bursztyka 6eec2d2aa5 net/ieee802154: Normalize parameter on radio API helper
For some reason, ieee802154_verify_channel had a device parameter
instead of an iface like all the others.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-01-15 15:15:38 +02:00
Tomasz Bursztyka ebfa2df113 net/ieee802154: Use helpers to call radio API functions
Now the code is a bit cleaner.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-01-15 15:15:38 +02:00
Tomasz Bursztyka 6f51ac7f2b net/ieee802154: Introduce helpers to call radio api function
Basically to make code nicer and more readable.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-01-15 15:15:38 +02:00
Tomasz Bursztyka 208e7f2bf6 net/lib: 15.4 interface is set UP after channel is configured
Once it has - at least - set up the channel, it can request the iface to
be put up.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-01-15 15:15:38 +02:00
Tomasz Bursztyka 9078378bed net/ieee802154: Do not set the device UP by default
It will be up to the user to configure a valid channel, through
net_mgmt, and call net_if_up() in order to get the device up.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-01-15 15:15:38 +02:00
Tomasz Bursztyka 6fa3d0fa3e net/ieee802154: Verify in L2 the Sub-Ghz channel value
Depending on device's band, the upper channel limit can vary a lot in
Sub-Ghz. Thus verifying it directly in L2 before requesting it to the
device.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-01-15 15:15:38 +02:00
Tomasz Bursztyka 9aa2f45d23 net/ieee802154: Add Sub-Ghz dedicated function on the radio API
Sub-Ghz bands have different limit of channels. 10, or more than a
thousand is actually possible. Thus the device needs to expose such
limit to the L2 which is unaware of frequency band logic. L2 will
then allow user to select a proper channel.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-01-15 15:15:38 +02:00
Paul Sokolovsky cb140154b0 net: tcp Remove recv_max_ack field from struct net_tcp
This field is set and maintained, but not actually used for anything.
The only purpose for it would be to validate ACK numbers from peer,
but such a validation is now implemented by using send_seq field
directly.

Fixes: #4653

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-01-15 15:08:22 +02:00
Paul Sokolovsky e36f67d1d9 net: tcp: Remove incorrect logging of "ACK errors"
Case #1: If ACK received and our retransmit (i.e. unacked) queue is
empty, it's error. It's incorrect because TCP requires ACK to set for
every packet of established connection. For example, if we didn't
send anything to peer, but it sends us new data, it will reuse the
older ack number. It doesn't acknowledge anything new on our side,
but it's not an error in any way.

Case #2: If retransmit queue is only partially acknowledged, it's an
error. Consider that we have 2 packets in the queue, with sequence
numbers (inclusive) 100-199 and 200-399. There's nothing wrong if
we receive ACK with number 200 - it just acknowledges first packet,
we can remove and finish processing. Second packet remains in the
queue to be acknowledged later.

Fixes: #5504

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-01-15 15:07:49 +02:00
Paul Sokolovsky ac7b1291da net: tcp: Validate incoming ACK number
Per RFC 793:

  A new acknowledgment (called an "acceptable ack"), is one for which
  the inequality below holds:

    SND.UNA < SEG.ACK =< SND.NXT

If acknowledgement is received for sequence number which wasn't yet
sent, log an error and ignore it.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-01-15 15:07:49 +02:00
Robert Chou b7af740f3a net: lwm2m: update observe_node when attributes are written or cleared
As title, we should update the existing observe_node when new attributes
are written from server side. Add the implementation to handle that.

Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
2018-01-12 20:57:34 -05:00
Robert Chou 2281f6fd7d net: lwm2m: get attributes from obj/obj_inst/res for observe_node
1. Read notification attributes set by server to setup the
   minimum/maximum notification period of a observation request.
2. Reordering to check observe_node duplication first
   (bailout earlier)
3. Simplify remove observe_node condition checking

NOTE: attributes are inheritable, priority: res > obj_inst > obj
Reference: LwM2M spec V1_0_1-20170704-A, section 5.1

Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
2018-01-12 20:57:34 -05:00
Robert Chou b0e7a039ee net: lwm2m: report attributes on discover op
Since we've added storing notification attributes written by server.
We can now append these attributes as part of link-format for discover
op.

Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
2018-01-12 20:57:34 -05:00
Robert Chou 09fcd83b98 net: lwm2m: add write-attribute WRITE support
Implement write-attribute on obj/obj_inst/res according to LwM2M spec
20170704-A, sec 5.1.2. Support pmin/pmax/st/gt/lt parameters on WRITE
operation.

The basic idea is to add sys_slist_t to obj/obj_inst/res structure.
And attach struct lwm2m_attr to the list when attributes are written
from server side (implement lwm2m_write_attr_handler accordingly)

Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
2018-01-12 20:57:34 -05:00
Jukka Rissanen ff22595c31 net: ip: shell: Fix ipv4 echo reply callback to unref packet
The ICMPv4 handler needs to unref the received echo reply packet
because we are returning NET_OK to caller. Similar change was done
for IPv6 earlier.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-01-12 20:51:32 -05:00
Andrei Emeltchenko af0bf06aa3 usb: Fix USB Device dependency
USB Device stack should depend on supported drivers not on menuconfig
option.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-12 07:46:28 -05:00
Carles Cufi 7d764b35f3 cmake: Use path-corrected version of ZEPHYR_BASE
Instead of accessing the environment variable ZEPHYR_BASE every time we
require accessing the source code root, use an intermediate variable
that has OS path separators correctly set to '/' to avoid issues on
Windows.

Note: This removes the ZEPHYR_SOURCE_DIR CMake variable. External
applications using that will need to change to use the new ZEPHYR_BASE
variable.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-01-11 14:59:03 -05:00
Paul Sokolovsky 84e3d3e7e8 libc: Kconfig: Move STDOUT_CONSOLE from subsys/debug
This option is clearly not related to debugging, but affects libc
features.

Fixes: #5566

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-01-11 12:47:10 -05:00
Pedro Martucci df37588b6f net: ip: shell: Fix ipv6 echo reply callback to unref packet
When testing ping6 with net shell, it was noticed that after some
sucessive calls the applications stopped to handle rx packets.
Analyzing other icmpv6 register callbacks it was verified that is
necessary to unref packets before returning NET_OK.

Signed-off-by: Pedro Martucci <pedropaulomartucci@gmail.com>
2018-01-11 09:19:48 +02:00
Michael Scott a21563d1a8 net: lib: lwm2m: fix coap proxy resource option
commit 2a7546fb5a ("net: lwm2m: add support for coap2coap proxy")
erroneously changed the COAP_OPTION_* used to specify the coap2coap
or coap2http proxy resource used from COAP_OPTION_URI_PATH to
COAP_OPTION_PROXY_SCHEME.

Changing it back to COAP_OPTION_URI_PATH requires us to re-order how
the coap options are appended to the packet as the coap options must
be added in the order specified by the numbers in:
https://tools.ietf.org/html/rfc7252#section-12.2

Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
2018-01-11 09:18:45 +02:00
Robert Chou 33030721c4 net: lwm2m: increase packet reference to avoid packet being freed
CoAP packet w/ confirmation flag set is required to be retransmitted
before it got the ACK message from the peer.

However, the packet is usally unreference once it's sent to the network.
Although we set the timeout as no wait when calling function
net_app_send_pkt(), it's still possible that the packet is unreferenced
before we got a chance to increase the packet reference by calling
coap_pending_cycle().

Usually, the IP stack will generate an ARP packet first and then send
out the packet.  However, this is not the case when the remote is a
loopback address.

As issue #5101 described, when asking client to perform a firmware pull
on URL "coap://127.0.0.1:7783/large". The packet will be unreferenced
immediately after calling net_app_send_pkt(). Which then result in
client hang.

The solution to the issue is to increase the reference count on the
sending packet and decrease it after the process is finished.

Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
2018-01-11 09:18:10 +02:00
Michael Scott 33ea1b5c89 net: skip TX max send calculation in net_pkt_append() for RX packets
We shouldn't limit the amount of data appended to RX packets based on
the max send size of TX packets.  Skip this check for packets in the
RX slab.

Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
2018-01-10 21:48:20 -05:00
Michael Scott 6338ec0546 Revert "net: net_app: set packet data_len on incoming packets"
This reverts commit 3599d793c2.

Setting a packet's data_len here doesn't fix the fact that we shouldn't
be using it at all on RX packets.  Fix belongs in net_pkt_append().

Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
2018-01-10 21:48:20 -05:00
Michael Scott a75458131a net: lib: app: trigger TLS closure when connection is closed
When testing TLS connections on production web server, it was noticed
that the TLS mainloop was getting "hung" after a connection was made
via HTTPS and then closed by the server.  The TLS mainloop was never
being notified that the connection was closed and was stuck waiting
for more data.

The next time that connection was used, TLS would fail to start.

Let's force trigger a closure of the TLS process when the net-app layer
is notified of the connection closure.  This allows the connection to
be successfully reused later.

Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
2018-01-10 21:47:46 -05:00
Mariusz Skamra 2f81942754 Bluetooth: mesh: Fix model subscription groups cleanup
Virtual address labels array entries were not updated on va deletion,
so that STATUS_INSUFF_RESOURCES error was returned after few
subsequent Config Model Subscription Virtual Address Add, Delete,
Overwrite commands, even if there shall be free space available.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-10 16:38:53 +02:00
Mariusz Skamra 4ba9543bdd Bluetooth: mesh: Fix LPN subsciption groups update on VA deletion
This fixes missing bt_mesh_lpn_group_del call in mod_sub_va_del.
If Config Model Subscription Virtual Address Delete was received
and successfully proceeded, subscription address shall be also
deleted from LPN Subscribe Groups.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-10 16:38:53 +02:00
Anas Nashif 4d2ad0a8a5 Bluetooth: remove unused BT_DEBUG_COLOR
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-09 10:59:41 -05:00
Paul Sokolovsky d9e886bc6e net: Kconfig: Don't select STDOUT_CONSOLE
The net code doesn't use libc stdio stdout in any way, so there's no
need tweak those options.

Fixes: #5565

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-01-05 10:00:26 -05:00
Mariusz Skamra 253e40ad0e Bluetooth: mesh: Do not set RFU bits in Heartbeat Publication Features
Features received in Config Heartbeat Publication Set message can have
Feature bits set to RFU values.
This patch fixes setting this RFU bits in Heartbeat Publication
Features, so that those are not indicated in Config Heartbeat
Publication Status message.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-05 09:31:50 +02:00
Paul Sokolovsky 7c7223982a net: shell: conn: Cross-ref TCP control block to owning context
Previously "conn" command dumped TCP control blocks without
referencing it to an owning context, making it hard to figure
out what happens. Now, dump context address.

Example before:

net> conn
     Context    Iface         Flags Local               Remote
[ 1] 0x00403360 0x0041fac0    6ST   [::]:4242   [::]:0
[ 2] 0x004033c8 0x0041fac0    4ST   0.0.0.0:4242        0.0.0.0:0
[ 3] 0x00403430 0x0041fac0    6DU   [::]:4242   [::]:0
[ 4] 0x00403498 0x0041fac0    4DU   0.0.0.0:4242        0.0.0.0:0
[ 5] 0x00403500 0x0041fac0    4ST   192.0.2.1:4242      192.0.2.2:55314

TCP        Src port  Dst port   Send-Seq   Send-Ack  MSS
0x00403c00     4242         0 2541690653          0  1440
0x00403cbc     4242         0 2797902539 3233948882  1460
0x00403d78     4242     55314 2797902539 3233948882  1460

Example after:

net> conn
     Context    Iface         Flags Local               Remote
[ 1] 0x00403360 0x0041fac0    6ST   [::]:4242   [::]:0
[ 2] 0x004033c8 0x0041fac0    4ST   0.0.0.0:4242        0.0.0.0:0
[ 3] 0x00403430 0x0041fac0    6DU   [::]:4242   [::]:0
[ 4] 0x00403498 0x0041fac0    4DU   0.0.0.0:4242        0.0.0.0:0
[ 5] 0x00403500 0x0041fac0    4ST   192.0.2.1:4242      192.0.2.2:55424

TCP        Context   Src port Dst port   Send-Seq   Send-Ack  MSS
0x00403c00 0x00403360    4242        0 1854382523          0  1440
0x00403cbc 0x004033c8    4242        0 1420360158 2064582979  1460
0x00403d78 0x00403500    4242    55424 1420360158 2064582979  1460

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-01-04 18:38:19 -05:00
Paul Sokolovsky 94995cbd0f net: ip: Optimize statements for setting packet lengths.
Use native C operators for converting a word to bytes.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-01-04 18:37:18 -05:00
Mariusz Skamra fdca8d8f54 Revert "Bluetooth: Mesh: Fix ignoring invalid Transport OpCode as LPN"
This reverts commit ada5771d7c.

MESH/NODE/FRND/LPN/BI-02-C in Mesh Test Specification 1.0.1
has been fixed according to TSE #9774.

IUT shall ignore the message with an RFU Transport Control Opcode
but another Friend Poll message shall be sent with an alternating
FSN value.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-04 15:33:19 +01:00
Mariusz Skamra cc1a960730 Bluetooth: mesh: Fix status returned from mod_unbind
According to Mesh Specification v1.0 4.3.2.48 Config Model App Status:
"The Status Code shall be Success if the received request was redundant
(bind request of existing binding, or unbind of a non-existing binding),
with no further action taken."

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-04 15:08:43 +01:00
Michael Scott 3599d793c2 net: net_app: set packet data_len on incoming packets
This fixes a bug when calling net_pkt_append[_all] which uses
pkt->data_len as part of the maximum packet length calculation
when the net_context is set.

Without this change the maximum packet length is calculated as 0
(the value of pkt->data_len) and an ENOMEM error is returned.

Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
2018-01-03 19:02:31 -05:00
Michael Scott e71f95b946 net: ip: net_pkt: set pkt context, iface and family in net_pkt_get()
Commit 753daa6 ("net: pkt: Compute TX payload data length")
removed the default packet setup on incoming packets when they
belong to the rx_pkt pool.

Let's restore this behavior, as MBEDTLS processing in net_app library
needs to use packet family to determine IP header length on
incoming packets.

NOTE: A future cleanup patch could set the IP header length based
on the context IP family.  However, there are many places in the code
where this is being set, so care should be taken.

Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
2018-01-03 19:02:31 -05:00
Mariusz Skamra 813ec50838 Bluetooth: btp: Add event indicating expiration of incomp timer
This event indicates that segmented message incomplete timer
expired.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-03 10:48:13 +01:00
Mariusz Skamra 9977caefa1 Bluetooth: testing: Move bt_test_mesh_net_recv to internal API
This function is called only within mesh stack.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-03 10:48:13 +01:00
Mariusz Skamra 8274cbabf6 Bluetooth: btp: Add Mesh Clear Replay Protection List Cache command
This command is needed for Bluetooth Mesh testing against PTS.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-03 10:48:13 +01:00
Mariusz Skamra a909aa3a0b Bluetooth: btp: Add LPN Subscribe/Unsubscribe commands
This adds commands to manage Friend node Subscription List.
Those will be used to add or remove and group/virtual address
from subscription list.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-03 10:48:13 +01:00
Mariusz Skamra 0bd3790d5b Bluetooth: btp: Add event indicating invalid provisioning BearerOpcode
This adds BTP event indicating reception of provisioning message
with invalid (RFU) BearerOpcode.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-03 10:48:13 +01:00