Commit Graph

13757 Commits

Author SHA1 Message Date
Kumar Gala 6da829690f subsys: convert to using newly introduced integer sized types
Convert code to use u{8,16,32,64}_t and s{8,16,32,64}_t instead of C99
integer types.

Jira: ZEP-2051

Change-Id: Icbf9e542b23208890a3a32358447d44cdc274ef1
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-21 09:36:22 -05:00
Kumar Gala a509441210 net: convert to using newly introduced integer sized types
Convert code to use u{8,16,32,64}_t and s{8,16,32,64}_t instead of C99
integer types.

Jira: ZEP-2051

Change-Id: I4ec03eb2183d59ef86ea2c20d956e5d272656837
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-21 09:30:38 -05:00
Jukka Rissanen 7f8d2d198b Merge net branch into master
Main changes:

- Refactoring net_nbuf usage.
- Fix null pointer access in IPv6.
- Fix compiler warnings.
- TCP ACK timer and retransmit fixes.
- Print enhancements in net-shell.
- RPL fixes.
- ZoAP fixes.

----------------------------------------------------------------
Andrei Emeltchenko (1):
      net: shell: Correct print format specifier

Jukka Rissanen (10):
      net: ipv6: Make sure not to access null pointer
      net: tcp: Avoid unused variable compiler warning
      net: pkt: Make the debug print eye friendly
      net: conn: Utility to print connection handlers
      net: Print debug info if packet is loopback back to us
      net: context: Set the local port correctly in accept
      net: tcp: Make sure ACK timer is not run if cancelled
      Bluetooth: ipsp: Fix compile error in sample app
      net: context: Connect callback was set too late
      net: shell: Fix compiler error when printing conn handlers

Mitul Shah (1):
      net: context: Fixing bug in net context put flow

Paul Sokolovsky (1):
      net: shell: conn: Dump local/remote ports for contexts.

Ravi kumar Veeramally (5):
      net: rpl: Fix rpl header update
      net: zoap: Refactor zoap utilities
      net: zoap: Fix memory overflow issue
      net: zoap: Remove unused helper function
      net: zoap: Prepare and send error response separately

Tomasz Bursztyka (7):
      net: Renaming net nbuf API to net pkt API
      net/net_pkt: Fully separate struct net_pkt from struct net_buf
      net_pkt: Removing legacy net_dir
      net_pkt: Externalize ext_bitmap handling
      net_pkt: Reordering the attributes for better alignment
      net: Rename all *_BUF() macros to *_HDR()
      net_pkt: Let's make all IPv6 related attributes prefixed with ipv6_

june li (1):
      net: tcp: Do buf ref when resending a segment

 .../networking/connectivity-example-app.c          |   22 +-
 .../networking/ip-stack-architecture.rst           |    2 +-
 doc/subsystems/networking/l2-and-drivers.rst       |   14 +-
 drivers/console/telnet_console.c                   |   54 +-
 drivers/ethernet/Kconfig.sam_gmac                  |   12 +-
 drivers/ethernet/eth_enc28j60.c                    |   40 +-
 drivers/ethernet/eth_mcux.c                        |   38 +-
 drivers/ethernet/eth_sam_gmac.c                    |  106 +-
 drivers/ethernet/eth_sam_gmac_priv.h               |    6 +-
 drivers/ieee802154/ieee802154_cc2520.c             |   60 +-
 drivers/ieee802154/ieee802154_mcr20a.c             |   46 +-
 drivers/ieee802154/ieee802154_nrf5.c               |   42 +-
 drivers/ieee802154/ieee802154_uart_pipe.c          |   36 +-
 drivers/slip/slip.c                                |   53 +-
 include/net/arp.h                                  |    6 +-
 include/net/buf.h                                  |    5 -
 include/net/ethernet.h                             |    4 +-
 include/net/ieee802154_radio.h                     |   12 +-
 include/net/mqtt.h                                 |    2 +-
 include/net/nbuf.h                                 | 1314 ----------------
 include/net/net_context.h                          |   59 +-
 include/net/net_core.h                             |   11 +-
 include/net/net_if.h                               |   25 +-
 include/net/net_l2.h                               |   10 +-
 include/net/net_offload.h                          |   34 +-
 include/net/net_pkt.h                              | 1297 ++++++++++++++++
 include/net/zoap.h                                 |  124 +-
 samples/bluetooth/ipsp/prj.conf                    |    8 +-
 samples/bluetooth/ipsp/src/main.c                  |   75 +-
 samples/net/coaps_client/prj_qemu_x86.conf         |    8 +-
 samples/net/coaps_client/src/coaps_client.c        |   37 +-
 samples/net/coaps_client/src/udp.c                 |   32 +-
 samples/net/coaps_client/src/udp.h                 |    2 +-
 samples/net/coaps_server/prj_arduino_101.conf      |    8 +-
 samples/net/coaps_server/prj_qemu_x86.conf         |    8 +-
 samples/net/coaps_server/src/coaps_server.c        |   64 +-
 samples/net/coaps_server/src/udp.c                 |   47 +-
 samples/net/coaps_server/src/udp.h                 |    2 +-
 samples/net/dhcpv4_client/prj_arduino_101.conf     |    8 +-
 samples/net/dhcpv4_client/prj_frdm_k64f.conf       |    8 +-
 samples/net/dhcpv4_client/prj_qemu_x86.conf        |    8 +-
 samples/net/dhcpv4_client/src/main.c               |    1 -
 samples/net/dns_resolve/prj_qemu_x86.conf          |   10 +-
 samples/net/echo_client/prj_arduino_101.conf       |    8 +-
 .../net/echo_client/prj_arduino_101_cc2520.conf    |   10 +-
 samples/net/echo_client/prj_bt.conf                |    8 +-
 samples/net/echo_client/prj_cc2520.conf            |   10 +-
 samples/net/echo_client/prj_frdm_k64f.conf         |    8 +-
 samples/net/echo_client/prj_frdm_k64f_cc2520.conf  |   10 +-
 samples/net/echo_client/prj_frdm_k64f_mcr20a.conf  |   10 +-
 samples/net/echo_client/prj_nrf5.conf              |   10 +-
 samples/net/echo_client/prj_qemu_802154.conf       |   10 +-
 samples/net/echo_client/prj_qemu_cortex_m3.conf    |    8 +-
 samples/net/echo_client/prj_qemu_x86.conf          |    8 +-
 samples/net/echo_client/prj_sam_e70_xplained.conf  |    8 +-
 samples/net/echo_client/src/echo-client.c          |  131 +-
 samples/net/echo_server/prj_arduino_101.conf       |    8 +-
 .../net/echo_server/prj_arduino_101_cc2520.conf    |   10 +-
 samples/net/echo_server/prj_bt.conf                |    8 +-
 samples/net/echo_server/prj_cc2520.conf            |   10 +-
 samples/net/echo_server/prj_frdm_k64f.conf         |    8 +-
 samples/net/echo_server/prj_frdm_k64f_cc2520.conf  |   10 +-
 samples/net/echo_server/prj_frdm_k64f_mcr20a.conf  |   10 +-
 samples/net/echo_server/prj_nrf5.conf              |   10 +-
 samples/net/echo_server/prj_qemu_802154.conf       |   10 +-
 samples/net/echo_server/prj_qemu_cortex_m3.conf    |    8 +-
 samples/net/echo_server/prj_qemu_x86.conf          |    8 +-
 samples/net/echo_server/prj_sam_e70_xplained.conf  |    8 +-
 samples/net/echo_server/src/echo-server.c          |  111 +-
 samples/net/http_client/prj_frdm_k64f.conf         |   10 +-
 samples/net/http_client/prj_qemu_x86.conf          |    8 +-
 samples/net/http_client/src/config.h               |    6 +-
 samples/net/http_client/src/http_client.c          |    1 -
 samples/net/http_client/src/http_client_rcv.c      |   34 +-
 samples/net/http_client/src/http_client_rcv.h      |    2 +-
 samples/net/http_client/src/tcp_client.c           |   10 +-
 samples/net/http_client/src/tcp_client.h           |    2 +-
 samples/net/http_server/README.rst                 |    2 +-
 samples/net/http_server/prj_arduino_101.conf       |    8 +-
 samples/net/http_server/prj_bt.conf                |    8 +-
 samples/net/http_server/prj_frdm_k64f.conf         |    8 +-
 samples/net/http_server/prj_qemu_x86.conf          |    8 +-
 samples/net/http_server/src/http_server.c          |   14 +-
 samples/net/http_server/src/http_server.h          |    4 +-
 samples/net/http_server/src/http_write_utils.c     |    1 -
 samples/net/http_server/src/ssl_utils.c            |   30 +-
 samples/net/http_server/src/ssl_utils.h            |    2 +-
 samples/net/ieee802154/hw/prj_cc2520_1.conf        |   10 +-
 samples/net/ieee802154/hw/prj_cc2520_2.conf        |   10 +-
 samples/net/ieee802154/hw/prj_mcr20a.conf          |   10 +-
 samples/net/ieee802154/hw/prj_nrf5.conf            |   10 +-
 samples/net/ieee802154/qemu/prj.conf               |   10 +-
 samples/net/ieee802154/qemu/prj_client.conf        |   10 +-
 samples/net/ieee802154/qemu/prj_server.conf        |   10 +-
 samples/net/irc_bot/prj_frdm_k64f.conf             |    8 +-
 samples/net/irc_bot/prj_qemu_x86.conf              |    8 +-
 samples/net/irc_bot/src/irc-bot.c                  |   28 +-
 samples/net/leds_demo/src/leds-demo.c              |   86 +-
 .../net/mbedtls_dtlsclient/prj_arduino_101.conf    |    8 +-
 samples/net/mbedtls_dtlsclient/src/udp.c           |   38 +-
 samples/net/mbedtls_dtlsclient/src/udp.h           |    2 +-
 samples/net/mbedtls_dtlsserver/src/udp.c           |   32 +-
 samples/net/mbedtls_dtlsserver/src/udp.h           |    2 +-
 samples/net/mbedtls_sslclient/prj_arduino_101.conf |    8 +-
 samples/net/mbedtls_sslclient/src/tcp.c            |   36 +-
 samples/net/mbedtls_sslclient/src/tcp.h            |    4 +-
 samples/net/mqtt_publisher/prj_96b_nitrogen.conf   |   10 +-
 samples/net/mqtt_publisher/prj_frdm_k64f.conf      |   12 +-
 samples/net/mqtt_publisher/prj_qemu_x86.conf       |   10 +-
 samples/net/mqtt_publisher/src/main.c              |    1 -
 samples/net/nats/prj_qemu_x86.conf                 |    5 +-
 samples/net/nats/src/main.c                        |    1 -
 samples/net/nats/src/nats.c                        |   36 +-
 samples/net/telnet/prj_frdm_k64f.conf              |    8 +-
 samples/net/telnet/prj_qemu_x86.conf               |    8 +-
 samples/net/telnet/prj_qemu_x86_iamcu.conf         |    8 +-
 samples/net/wpan_serial/prj.conf                   |    6 +-
 samples/net/wpan_serial/src/main.c                 |   77 +-
 samples/net/wpanusb/prj.conf                       |    4 +-
 samples/net/wpanusb/src/wpanusb.c                  |   52 +-
 samples/net/zoap_client/src/zoap-client.c          |   37 +-
 samples/net/zoap_server/src/zoap-server.c          |  188 +--
 samples/net/zperf/prj_bt.conf                      |   10 +-
 samples/net/zperf/prj_frdm_k64f.conf               |   10 +-
 samples/net/zperf/prj_frdm_k64f_prof.conf          |   10 +-
 samples/net/zperf/prj_qemu_x86.conf                |   10 +-
 samples/net/zperf/prj_quark_se_c1000_devboard.conf |    8 +-
 samples/net/zperf/src/zperf_session.c              |   28 +-
 samples/net/zperf/src/zperf_session.h              |    2 +-
 samples/net/zperf/src/zperf_tcp_receiver.c         |   16 +-
 samples/net/zperf/src/zperf_tcp_uploader.c         |   27 +-
 samples/net/zperf/src/zperf_udp_receiver.c         |  109 +-
 samples/net/zperf/src/zperf_udp_uploader.c         |  104 +-
 subsys/net/Makefile                                |    2 +-
 subsys/net/ip/6lo.c                                |  196 ++-
 subsys/net/ip/6lo.h                                |   12 +-
 subsys/net/ip/6lo_private.h                        |    4 +-
 subsys/net/ip/Kconfig                              |   34 +-
 subsys/net/ip/Kconfig.debug                        |   16 +-
 subsys/net/ip/Makefile                             |    2 +-
 subsys/net/ip/connection.c                         |  113 +-
 subsys/net/ip/connection.h                         |   29 +-
 subsys/net/ip/dhcpv4.c                             |  173 ++-
 subsys/net/ip/icmpv4.c                             |  176 +--
 subsys/net/ip/icmpv4.h                             |   16 +-
 subsys/net/ip/icmpv6.c                             |  255 +--
 subsys/net/ip/icmpv6.h                             |   32 +-
 subsys/net/ip/ipv4.c                               |   92 +-
 subsys/net/ip/ipv4.h                               |   28 +-
 subsys/net/ip/ipv6.c                               | 1271 +++++++--------
 subsys/net/ip/ipv6.h                               |   71 +-
 subsys/net/ip/l2/arp.c                             |  197 +--
 subsys/net/ip/l2/bluetooth.c                       |   50 +-
 subsys/net/ip/l2/dummy.c                           |   20 +-
 subsys/net/ip/l2/ethernet.c                        |  146 +-
 subsys/net/ip/l2/ieee802154/ieee802154.c           |  117 +-
 subsys/net/ip/l2/ieee802154/ieee802154_fragment.c  |  150 +-
 subsys/net/ip/l2/ieee802154/ieee802154_fragment.h  |   10 +-
 subsys/net/ip/l2/ieee802154/ieee802154_frame.c     |   43 +-
 subsys/net/ip/l2/ieee802154/ieee802154_frame.h     |   16 +-
 subsys/net/ip/l2/ieee802154/ieee802154_mgmt.c      |   42 +-
 .../net/ip/l2/ieee802154/ieee802154_radio_aloha.c  |   16 +-
 .../ip/l2/ieee802154/ieee802154_radio_csma_ca.c    |   16 +-
 .../net/ip/l2/ieee802154/ieee802154_radio_utils.h  |   20 +-
 subsys/net/ip/nbuf.c                               | 1611 -------------------
 subsys/net/ip/net_context.c                        |  358 +++--
 subsys/net/ip/net_core.c                           |  127 +-
 subsys/net/ip/net_if.c                             |   58 +-
 subsys/net/ip/net_pkt.c                            | 1627 ++++++++++++++++++++
 subsys/net/ip/net_private.h                        |   42 +-
 subsys/net/ip/net_shell.c                          |  258 +++-
 subsys/net/ip/route.c                              |   24 +-
 subsys/net/ip/route.h                              |    4 +-
 subsys/net/ip/rpl-mrhof.c                          |    1 -
 subsys/net/ip/rpl-of0.c                            |    1 -
 subsys/net/ip/rpl.c                                |  688 ++++-----
 subsys/net/ip/rpl.h                                |   16 +-
 subsys/net/ip/tcp.c                                |  223 +--
 subsys/net/ip/tcp.h                                |   31 +-
 subsys/net/ip/udp.h                                |   42 +-
 subsys/net/ip/utils.c                              |   41 +-
 subsys/net/lib/dns/resolve.c                       |   32 +-
 subsys/net/lib/http/http_client.c                  |   54 +-
 subsys/net/lib/http/http_server.c                  |   23 +-
 subsys/net/lib/mqtt/mqtt.c                         |  118 +-
 subsys/net/lib/zoap/zoap.c                         |  280 ++--
 subsys/net/lib/zoap/zoap_link_format.c             |  105 +-
 tests/net/6lo/prj.conf                             |   13 +-
 tests/net/6lo/src/main.c                           |   83 +-
 tests/net/arp/prj.conf                             |   10 +-
 tests/net/arp/src/main.c                           |  232 +--
 tests/net/context/prj.conf                         |   10 +-
 tests/net/context/src/main.c                       |  116 +-
 tests/net/dhcpv4/prj.conf                          |    8 +-
 tests/net/dhcpv4/src/main.c                        |  134 +-
 tests/net/icmpv6/prj.conf                          |    8 +-
 tests/net/icmpv6/src/main.c                        |   41 +-
 tests/net/ieee802154/crypto/prj.conf               |    7 +-
 tests/net/ieee802154/fragment/prj.conf             |   10 +-
 tests/net/ieee802154/fragment/src/main.c           |   86 +-
 tests/net/ieee802154/l2/prj.conf                   |    8 +-
 .../net/ieee802154/l2/src/ieee802154_fake_driver.c |   24 +-
 tests/net/ieee802154/l2/src/ieee802154_test.c      |   47 +-
 tests/net/iface/prj.conf                           |    8 +-
 tests/net/iface/src/main.c                         |   22 +-
 tests/net/ip-addr/prj.conf                         |    8 +-
 tests/net/ip-addr/src/main.c                       |    6 +-
 tests/net/ipv6/prj.conf                            |   10 +-
 tests/net/ipv6/src/main.c                          |  119 +-
 tests/net/lib/dns_resolve/src/main.c               |   10 +-
 .../net/lib/mqtt_publisher/src/test_mqtt_publish.c |    2 +-
 .../lib/mqtt_subscriber/src/test_mqtt_subscribe.c  |    2 +-
 tests/net/lib/zoap/prj.conf                        |    4 +-
 tests/net/lib/zoap/src/main.c                      |  318 ++--
 tests/net/mgmt/prj.conf                            |    8 +-
 tests/net/mgmt/src/mgmt.c                          |    6 +-
 tests/net/mld/prj.conf                             |    6 +-
 tests/net/mld/src/main.c                           |   66 +-
 tests/net/neighbor/prj.conf                        |   10 +-
 tests/net/neighbor/src/main.c                      |    1 -
 tests/net/{nbuf => net_pkt}/Makefile               |    0
 tests/net/{nbuf => net_pkt}/prj.conf               |   17 +-
 tests/net/{nbuf => net_pkt}/src/Makefile           |    0
 tests/net/{nbuf => net_pkt}/src/main.c             |  663 ++++----
 tests/net/{nbuf => net_pkt}/testcase.ini           |    0
 tests/net/route/prj.conf                           |    8 +-
 tests/net/route/src/main.c                         |   61 +-
 tests/net/rpl/prj.conf                             |   10 +-
 tests/net/rpl/src/main.c                           |   49 +-
 tests/net/tcp/prj.conf                             |   10 +-
 tests/net/tcp/src/main.c                           |  314 ++--
 tests/net/trickle/prj.conf                         |    8 +-
 tests/net/udp/prj.conf                             |   10 +-
 tests/net/udp/src/main.c                           |  106 +-
 tests/net/utils/prj.conf                           |    8 +-
 tests/net/utils/src/main.c                         |  139 +-
 236 files changed, 8793 insertions(+), 8685 deletions(-)
 delete mode 100644 include/net/nbuf.h
 create mode 100644 include/net/net_pkt.h
 delete mode 100644 subsys/net/ip/nbuf.c
 create mode 100644 subsys/net/ip/net_pkt.c
 rename tests/net/{nbuf => net_pkt}/Makefile (100%)
 rename tests/net/{nbuf => net_pkt}/prj.conf (53%)
 rename tests/net/{nbuf => net_pkt}/src/Makefile (100%)
 rename tests/net/{nbuf => net_pkt}/src/main.c (61%)
 rename tests/net/{nbuf => net_pkt}/testcase.ini (100%)

Change-Id: I7ce3d65b6e92d12a2f6536cd41ce1281bcdf9a7a
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-21 16:29:38 +03:00
Jukka Rissanen af1e3b9d32 net: shell: Fix compiler error when printing conn handlers
There was compiler error if CONFIG_NET_DEBUG_CONN was set.

Change-Id: Ibb6721c55dd2c56cd0097359a53563c6221859ea
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-21 15:44:22 +03:00
Jukka Rissanen d8dd91d7bf net: context: Connect callback was set too late
We need to set the connect_cb for the context before sending SYN packet.
This is required if we have a loopback connection in which case everything
is happening more or less synchronously and the connect_cb would not be
called in this case because its value would still be null.
For remote network connections this patch makes no difference.

Change-Id: Id7f837cd9e81cd79c4666c98cae84f6cb1a77af0
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-21 15:44:22 +03:00
Jukka Rissanen da6eba463d Bluetooth: ipsp: Fix compile error in sample app
Some incompatible changes were introduced when net and bluetooth
branches were changed at the same time.

Change-Id: Ifa03f85d26a63ade0fcc029377d54850c0e92451
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-21 15:44:20 +03:00
David B. Kinder 36bb36475f spell: fix Kconfig help typos: /arch
Fix misspellings in Kconfig help text

Change-Id: I2a753b57107f09073eb84ac757ac1e180ae89349
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-04-21 12:30:42 +00:00
Kumar Gala bf53ebf2c8 arch: convert to using newly introduced integer sized types
Convert code to use u{8,16,32,64}_t and s{8,16,32,64}_t instead of C99
integer types.  There are few places we dont convert over to the new
types because of compatiability with ext/HALs or for ease of transition
at this point.  Fixup a few of the PRI formatters so we build with newlib.

Jira: ZEP-2051

Change-Id: I7d2d3697cad04f20aaa8f6e77228f502cd9c8286
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-21 12:08:12 +00:00
Jukka Rissanen 1bf14853aa net: tcp: Make sure ACK timer is not run if cancelled
We must not let ACK timer to run if we have already cancelled it.
So keep track that the timer is cancelled and refuse to run it
if it was indeed cancelled. The reason why the timer might be run
in this case is because the timer might be scheduled to be triggered
after which one cannot cancel it.

Change-Id: I1c8b8cee72bc7a644e02db154d9d009b8d98ade2
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-21 14:19:52 +03:00
Jukka Rissanen 137e4e7256 net: context: Set the local port correctly in accept
The local port was set to 0 for IPv6 when registering
the connection handler. For IPv4, the code was not setting
the port in local_addr struct.

Change-Id: I82f0c08641a94d75d255ac306eca7bec6c332fba
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-21 14:19:52 +03:00
Jukka Rissanen a1c4f3fbd5 net: Print debug info if packet is loopback back to us
Without this info it is a bit difficult to notice what is going
on in loopback case.

Change-Id: I8f61330c01d025e41f00d663bd26947b8cafb5c0
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-21 14:19:51 +03:00
Jukka Rissanen a71a9f9ad1 net: conn: Utility to print connection handlers
Add support to print connection handler information in net-shell.
There exists one connection handler for each UDP/TCP port that we
are listening. These prints are only available if CONFIG_NET_DEBUG_CONN
is enabled because the net_context has the same information. Thus the
connection handler info is only printed if debugging is active in order
to verify that handler information is proper.

Change-Id: I0be39a5adb89b2cdbd85524c5d943e4a562b0fde
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-21 14:19:51 +03:00
Jukka Rissanen f498a90b77 net: pkt: Make the debug print eye friendly
Print "pkt" instead of "Pkt" when printing network packet
pointer value.

Change-Id: Id4225be9c55807def3d892d372cdfc5c79c871fc
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-21 14:19:51 +03:00
Jukka Rissanen 52339cdf5a net: tcp: Avoid unused variable compiler warning
If TCP debugging is enabled but if the loglevel is set to lower
than 4, then compiler prints warning about unused flags variable
in net_tcp_trace().

Change-Id: I2e663644b50fe97b75088202e21b286aa010953e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-21 14:19:51 +03:00
Tomasz Bursztyka f3ff4f7bd3 net_pkt: Let's make all IPv6 related attributes prefixed with ipv6_
Only 2 attributes lacked this prefix, which makes sense to have, so
applying it accordingly and changing the helpers as well.

Change-Id: I095b2729f977f8fb1624eff8801a4a4e21416693
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-04-21 14:19:51 +03:00
Tomasz Bursztyka e5896906f6 net: Rename all *_BUF() macros to *_HDR()
Most of these macros are not exactly exposing a buffer, but a specific
header pointer (ipv6, ivp4, ethernet and so on), so it relevant to
rename them accordingly.

Change-Id: I66e32f7c3f2bc75994befb28d823e24299a53f5c
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-04-21 14:19:51 +03:00
Tomasz Bursztyka 02cb7e6e71 net_pkt: Reordering the attributes for better alignment
Instead of using a bool, let's just use a bit in a bifield, shared among
various attribute. This saves space.

Make ext_len attribute enabled only on IPv6 (ipv6, icmpv6 and rpl are
the only code setting it) and reordering the helpers functions
accordingly.

Change-Id: Ifd3295d778959308ead7db9b2a59396e50f8e18c
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-04-21 14:19:51 +03:00
Tomasz Bursztyka c18016b69b net_pkt: Externalize ext_bitmap handling
IPv6 next headers are processed in a way so it is not required to store
which header has been already seen in the net_pkt, as the processing loop
can store internally which one it has seen already.

Change-Id: I266ba8a3a0081a162318cdafb474a0fc44a3185e
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-04-21 14:19:50 +03:00
Tomasz Bursztyka 2e331de690 net_pkt: Removing legacy net_dir
This is actually useless as there is only 1 RX memory slab, and thus can
be removed to reduce net_pkt structure size.

Change-Id: I62d716515120e7356ee1e2d75bbe1ec32e22c35d
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-04-21 14:19:50 +03:00
Tomasz Bursztyka db11fcd174 net/net_pkt: Fully separate struct net_pkt from struct net_buf
- net_pkt becomes a stand-alone structure with network packet meta
  information.
- network packet data is still managed through net_buf, mostly named
  'frag'.
- net_pkt memory management is done through k_mem_slab
- function got introduced or relevantly renamed to target eithe net_pkt
  or net_buf fragments.
- net_buf's sent_list ends up in net_pkt now, and thus helps to save
  memory when TCP is enabled.

Change-Id: Ibd5c17df4f75891dec79db723a4c9fc704eb843d
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-04-21 14:19:50 +03:00
Tomasz Bursztyka bf964cdd4c net: Renaming net nbuf API to net pkt API
There have been long lasting confusion between net_buf and net_nbuf.
While the first is actually a buffer, the second one is not. It's a
network buffer descriptor. More precisely it provides meta data about a
network packet, and holds the chain of buffer fragments made of net_buf.

Thus renaming net_nbuf to net_pkt and all names around it as well
(function, Kconfig option, ..).

Though net_pkt if the new name, it still inherit its logic from net_buf.
'
This patch is the first of a serie that will separate completely net_pkt
from net_buf.

Change-Id: Iecb32d2a0d8f4647692e5328e54b5c35454194cd
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-04-21 14:19:50 +03:00
Andrei Emeltchenko 9bf3ea071a net: shell: Correct print format specifier
Fix warning using incorrect format specifier

Change-Id: Ib6800c40b2cd769612ae6f107e41a941926d8e66
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2017-04-21 14:19:50 +03:00
june li 504b273b85 net: tcp: Do buf ref when resending a segment
We need to check whether buf_sent was true when resending the TCP
segment, and do a buf ref if needed. If this is not done, the buf
will be unref after send, which will cause unpredictable results.

Change-Id: Ibd4490305de88ac6ffd04ec42bba196e57da5c10
Signed-off-by: june li <junelizh@foxmail.com>
2017-04-21 14:19:50 +03:00
Jukka Rissanen 7ce82fea82 net: ipv6: Make sure not to access null pointer
While very unlikely it might happen that fragment pointer is NULL
when going through fragment list.

Coverity-CID: 167148

Change-Id: Ic3dbed7ee29c7b864d4830d726f65d7f62dcea84
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-21 14:19:49 +03:00
Ravi kumar Veeramally 651a0cb269 net: zoap: Prepare and send error response separately
If error occurs while preparing response to .well-known/core request,
do not send partly filled payload by simply changing code part only.
It's better to unref the partly filled reponse and prepare a new error
response and send.

Change-Id: I28013a4e331cfc6f01de873e80af48f765e49494
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-04-21 14:19:49 +03:00
Ravi kumar Veeramally a8ac7af37a net: zoap: Remove unused helper function
Commit "net: zoap: Fix memory overflow issue" fixed and implemented
./well-known/core response in a different way, so this api is not needed
anymore.

Change-Id: I8f945fb5842028be50ecfdef95cbe5da3189a538
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-04-21 14:19:49 +03:00
Ravi kumar Veeramally 79ff5ed5fa net: zoap: Fix memory overflow issue
If CoAP .well-known/core services list is bigger than single fragment
then current helper functions overwrites beyond fragment space. Which
corrupted whole stack. Right now sending response in multiple fragments
but preferred way is send response in block by block. This should
overcome packet loss across mesh scenarios. Recommended feature will
be supported with later patches.

Change-Id: I30ca55bde2516d80b3583731241ad295799c6614
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-04-21 14:19:49 +03:00
Ravi kumar Veeramally 09773f5a5f net: zoap: Refactor zoap utilities
Most of the zoap utilities deal with first fragment of buffer chain.
So accessing of buf->frags directly make less usage of stack than
delcaring another variable for frag and its data. Due to code
refactoring couple of lines removed and in between those lines
coverity complained two issues, which is not valid now.

Coverity-CID: 157597
Coverity-CID: 157598

Change-Id: I3035c0625a131d49a4f0250ff0052875d3382544
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-04-21 14:19:49 +03:00
Ravi kumar Veeramally 2f73c324aa net: rpl: Fix rpl header update
When net_ipv6_finalize_raw() inserts RPL(HBH) header after IPv6 header,
it updates IPv6 next header as HBH and HBH next header as original IPv6
next header.

Then net_ipv6_prepare_for_send() will update RPL HBH header if it exists.
But net_rpl_update_header() is comparing HBH option and IPv6 next header,
which is wrong. Wrong comparion does not update RPL instance id and
sender rank. Peer nodes drops all the packets due to invalid instance
ID and sender rank.

Change-Id: I91c1870a09c60f8e1ebc73e434dcc208caf6299a
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-04-21 14:19:49 +03:00
Mitul Shah d27ca378b6 net: context: Fixing bug in net context put flow
Following flow does not work:
net_context_get
net_context_bind
..
..
net_context_put
net_context_get
net_context_bind

At instance of call to net_context_bind, conn_handler
is not NULL and returns with EISCONN.

This patch sets conn_handler to NULL in net_context_unref

Change-Id: I56a50839101b22161644b3cd7c5f510fa1abae3e
Signed-off-by: Mitul Shah <mitul.a.shah@intel.com>
2017-04-21 14:19:49 +03:00
Paul Sokolovsky 52e3e5c68d net: shell: conn: Dump local/remote ports for contexts.
Without port numbers, information printed by net shell's "conn" command
is unclear and non-differentiating. Also, improve handling of unknown
address families - don't abort early, still pring context address, iface
address, etc.

Example of "conn" output with these changes from echo_server sample:

net> conn
     Context   	Iface         Flags Local           	Remote
[ 1] 0x001126e0	0x001121a0    6DU   [::]:4242	[::]:0
[ 2] 0x00112738	0x001121a0    4DU   0.0.0.0:4242	0.0.0.0:0
[ 3] 0x00112790	0x001121a0    6ST   [::]:4242	[::]:0
[ 4] 0x001127e8	0x001121a0    4ST   0.0.0.0:4242	0.0.0.0:0

TCP        Src port  Dst port   Send-Seq   Send-Ack  MSS    State
0x00112b00     4242         0  497073352          0  1280
0x00112b98     4242         0  497543793          0  1460

Change-Id: I2f03efd933979b5571f608c28a7a7a4bd7f5346a
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-04-21 14:19:49 +03:00
Leandro Pereira 99a7168b08 misc: Support left-justification in printk()
This is supported by printf(), and is an important formatting feature
to print out some complex, nicely-formatted information.  This is
accomplished by using a negative padding in the formatting string.

The following code:

      printk("none:         |%u| |%x|\n", 12345, 12345);
      printk("zero_before:  |%08u| |%08x|\n", 12345, 12345);
      printk("space_before: |%8u| |%8x|\n", 12345, 12345);
      printk("space_after:  |%-8u| |%-8x|\n", 12345, 12345);

Will produce the following output:

      none:         |12345| |3039|
      zero_before:  |00012345| |0000000000003039|
      space_before: |   12345| |            3039|
      space_after:  |12345   | |3039            |

Change-Id: I9c2d85a1790087d53b52b7713854adaf99282f09
Jira: ZEP-1599
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-04-21 11:06:16 +00:00
Mazen NEIFER 37352c809e xtensa port: Added documentation for xt-sim board.
Issue: ZEP-1899

Change-Id: I4cf2878468e8c1c9703a2af13d9c2b3ac6f78042
Signed-off-by: Mazen NEIFER <mazen@nestwave.com>
2017-04-20 21:07:15 +00:00
Kumar Gala d0eb235510 Bluetooth: convert to using newly introduced integer sized types
Convert code to use u{8,16,32,64}_t and s{8,16,32,64}_t instead of C99
integer types.

Jira: ZEP-2051

Change-Id: I8f57a17f78e674aca5400f005db8975c9f9e150e
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-20 13:25:23 -05:00
Kumar Gala bf50c245ec misc: convert to using newly introduced integer sized types
Convert code to use u{8,16,32,64}_t and s{8,16,32,64}_t instead of C99
integer types.

Jira: ZEP-2051

Change-Id: Ia38862a5d408f4b4512cd2840ee46e686ae342e3
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-20 11:56:00 -05:00
Kumar Gala 7352c4681d boards: convert to using newly introduced integer sized types
Convert code to use u{8,16,32,64}_t and s{8,16,32,64}_t instead of C99
integer types.

Jira: ZEP-2051

Change-Id: I27d51c316144251939b20cfa6787ff7ab8035fe6
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-20 11:56:00 -05:00
Kumar Gala 9a74ee1730 lib: convert to using newly introduced integer sized types
Convert code to use u{8,16,32,64}_t and s{8,16,32,64}_t instead of C99
integer types.

Jira: ZEP-2051

Change-Id: I74bc6384c4090f4ae322e3aa151874f583a5fe73
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-20 11:56:00 -05:00
Kumar Gala 3c454017b4 Merge "Merge bluetooth branch into master" 2017-04-20 16:55:36 +00:00
Kumar Gala 789081673f Introduce new sized integer typedefs
This is a start to move away from the C99 {u}int{8,16,32,64}_t types to
Zephyr defined u{8,16,32,64}_t and s{8,16,32,64}_t.  This allows Zephyr
to define the sized types in a consistent manor across all the
architectures we support and not conflict with what various compilers
and libc might do with regards to the C99 types.

We introduce <zephyr/types.h> as part of this and have it include
<stdint.h> for now until we transition all the code away from the C99
types.

We go with u{8,16,32,64}_t and s{8,16,32,64}_t as there are some
existing variables defined u8 & u16 as well as to be consistent with
Zephyr naming conventions.

Jira: ZEP-2051

Change-Id: I451fed0623b029d65866622e478225dfab2c0ca8
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-20 16:07:08 +00:00
Mazen NEIFER 01e9646638 xtensa port: Clear the CP descriptor of new created thread.
This commit should fix the concern about uninitialized memory of main
thread that was raised in https://gerrit.zephyrproject.org/r/#/c/12920/

The issue is more general, if it happens that the content of the
CPENABLE flag of any thread is set then any other thread using the CP
may cause a memory corruption.

I'd prefer to avoid the issue by initializing the CP descriptor to 0.
The descriptor itself is few words. We set them to 0 up to CP_ASA, which
is set to a real value.

As the dummy thread instantiated at the kernel startup does not use CP,
there is no CP area in its thread memory buffer. However it is mandatory
that it have the CP descriptor and that cpEnable in that descripot is
set to null. This is ensured by adding XT_CP_DESCR_SIZE to
_K_THREAD_NO_FLOAT_SIZEOF.

Change-Id: I6a36b5b363600ea1e6d98ab679981182b2b5a236
Signed-off-by: Mazen NEIFER <mazen@nestwave.com>
2017-04-20 16:01:55 +00:00
Max Filippov 59926490be xtensa: move #include <linker/common-*.ld> up
Move linker/common-rom.ld between .rodata sections so that it's together
with other immutable data.
Move linker/common-ram.ld before the .bss section, so that .bss does not
appear between data sections, which had two consequences:
- there's a .bss-sized gap in the ELF image, and
- PHDR segment that covers .bss overlaps the segment that covers .data,
  resulting in the following xt-run warning:

  ( [ sample_controller ] load_bfd ) *WARNING* Executable segment
    [ 60004d60, 600079a7 ] overlaps an existing executable segment

Change-Id: I2db46f4656e240016fe60883057cc000b6377180
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
2017-04-20 16:01:18 +00:00
Max Filippov 5c6276da72 toolchain: don't define __stack outside C code
__stack is defined as a C language attribute for on-stack arrays. Don't
define it outside C source code.
This definition conflicts with __stack symbol defined in xtensa linker.ld
files.

Change-Id: I59fe34603bc2bb5732ed45c7974de5f8b25d77ed
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
2017-04-20 16:01:17 +00:00
Johan Hedberg c52fa3c424 Merge bluetooth branch into master
- newlib related fixes for the AT parser
 - Channel Selection Algorithm #2 support (Bluetooth 5.0 feature)
 - Better tracking of outgoing data (with callback support)
 - Various smaller cleanups & fixes

----------------------------------------------------------------
Carles Cufi (3):
      Bluetooth: HCI: Add Bluetooth 5.0 LE commands and events
      Bluetooth: HCI: Naming consistency tweaks
      Bluetooth: Use event masks instead of bits in controller and host

Johan Hedberg (8):
      Bluetooth: hci_raw: Fix ECC support
      Bluetooth: Add support for tracking transmitted packets
      Bluetooth: ATT: Enforce flow for incoming requests & indications
      Bluetooth: SMP: Track when last key distribution PDU has been sent
      Bluetooth: Introduce a timeout for synchronous HCI command sending
      Bluetooth: ATT: Fix bogus CONTAINER_OF() usage
      Bluetooth: Introduce flow control for outgoing ATT packets
      Bluetooth: ATT: Start response timer only after actual transmission

Kumar Gala (3):
      Bluetooth: AT: use explicit unsigned char to avoid array subscript error
      Bluetooth: AT: Fix building with newlib
      Bluetooth: AT: Unit: Fixup include search path

Luiz Augusto von Dentz (4):
      Bluetooth: ipsp: Add TX pools for TCP
      Bluetooth: L2CAP: Try to allocate segment from the original pool
      net: buf: Add net_buf_reset
      Bluetooth: L2CAP: Reuse request buffer to respond

Vinayak Chettimada (5):
      Bluetooth: controller: Rename channel/chnl to chan
      Bluetooth: HCI: Add Bluetooth 5.0 FeatureSet field's bit mapping
      Bluetooth: Fix missing LE conn param req bit in set LE evt mask
      Bluetooth: controller: Support BT 5.0 feature set bit fields
      Bluetooth: controller: Channel Selection Algorithm #2

 include/bluetooth/hci.h                           | 495 +++++++++++++++--
 include/bluetooth/l2cap.h                         |   2 +-
 include/net/buf.h                                 |   9 +
 samples/bluetooth/ipsp/src/main.c                 |  15 +
 subsys/bluetooth/controller/Kconfig               |   7 +
 subsys/bluetooth/controller/hal/nrf5/radio.c      |   4 +-
 subsys/bluetooth/controller/hal/radio.h           |   2 +-
 subsys/bluetooth/controller/hci/hci.c             |  95 ++--
 subsys/bluetooth/controller/ll_sw/ctrl.c          | 622 ++++++++++++++++------
 subsys/bluetooth/controller/ll_sw/ctrl.h          |  71 ++-
 subsys/bluetooth/controller/ll_sw/ctrl_internal.h |  25 +-
 subsys/bluetooth/controller/ll_sw/ll.c            |  24 +-
 subsys/bluetooth/controller/ll_sw/pdu.h           |  12 +-
 subsys/bluetooth/host/Kconfig                     |  31 ++
 subsys/bluetooth/host/at.c                        |   2 +-
 subsys/bluetooth/host/at.h                        |   2 +-
 subsys/bluetooth/host/att.c                       | 230 ++++++--
 subsys/bluetooth/host/conn.c                      | 111 +++-
 subsys/bluetooth/host/conn_internal.h             |  23 +-
 subsys/bluetooth/host/hci_core.c                  | 163 +++---
 subsys/bluetooth/host/hci_core.h                  |   3 +-
 subsys/bluetooth/host/hci_ecc.c                   |   2 +-
 subsys/bluetooth/host/hci_raw.c                   |   4 +
 subsys/bluetooth/host/hfp_hf.c                    |   2 +
 subsys/bluetooth/host/l2cap.c                     |  79 ++-
 subsys/bluetooth/host/l2cap_internal.h            |  12 +-
 subsys/bluetooth/host/sdp.c                       |   2 +
 subsys/bluetooth/host/smp.c                       | 117 +++-
 subsys/net/buf.c                                  |  12 +-
 tests/bluetooth/init/prj_controller_4_0.conf      |   1 +
 tests/unit/bluetooth/at/src/Makefile              |   2 +-
 tests/unit/bluetooth/at/src/main.c                |   2 +-
 32 files changed, 1695 insertions(+), 488 deletions(-)

Change-Id: I17f9e49e1347a38bc78be3bdcaa596e41d83da56
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-04-20 18:45:15 +03:00
Andy Gross c8112aaeec build: Add separate DTS target
This patch adds an actual dts target for builds.  This required moving the
rules from Kbuild to Makefile and adding the correct dependencies to targets
requiring the dts files.

JIRA: ZEP-1979

Change-Id: I6ad568e2a821630911623cb227aa303fbf388515
Signed-off-by: Andy Gross <andy.gross@linaro.org>
2017-04-20 14:36:10 +00:00
Andy Gross 47eb5bf87c Build: Fix outputexports dependencies
This patch fixes the dependencies for the outputexports.  The
.config has to be created for the outputexports to work properly.

JIRA: ZEP-1979

Change-Id: I9b4fab44c10545c57f7b613074c3ddebded0d423
Signed-off-by: Andy Gross <andy.gross@linaro.org>
2017-04-20 14:36:09 +00:00
Anas Nashif 242f2ebbd5 MAINTAINERS: remove references to legacy headers
Change-Id: Ia29c0dbf29171839fc851dacb1151dddbf7078ad
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-04-20 14:11:16 +00:00
Johan Hedberg 2ec180aef5 Bluetooth: ATT: Start response timer only after actual transmission
If there are many connections there may be some delay before an ATT
PDU really gets transmitted over the air. Use the TX callback to
start the response timer so that it doesn't expire too soon.

Change-Id: Ibdd5bc1029ae4034caf329bf03892ac2093a0c67
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-04-20 13:00:57 +00:00
Johan Hedberg d893d31c16 Bluetooth: Introduce flow control for outgoing ATT packets
In order to not overload the TX buffer pool and potentially run out of
them, enforce flow control for outgoing ATT packets so that the send
functions block until the PDU has actually been transmitted over the
air.

Change-Id: Ic065bb88aec8c2d0ac2def8ef62131a427f7051f
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-04-20 13:00:40 +00:00
Johan Hedberg ea9a067a9a Bluetooth: ATT: Fix bogus CONTAINER_OF() usage
This CONTAINER_OF() worked by chance, but was actually wrong, since it
makes it look like bt_l2cap_le_chan is the parent container of bt_att.
Instead bt_l2cap_le_chan is simply a member of bt_att, i.e. we can
dereference it directly.

Change-Id: I7307517bae823e54b45db31f75462655ce6eb50d
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-04-20 13:00:04 +00:00
Anas Nashif 501734cbc2 ext: tinycrypt: update README to reflect correct version and hash
Change-Id: Ifd009f3ee048e17d97be4691763aa38ed4d20937
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-04-20 12:30:42 +00:00