diff --git a/samples/net/coaps_client/README.rst b/samples/net/coaps_client/README.rst index c8266c499da51..2cdd265697b57 100644 --- a/samples/net/coaps_client/README.rst +++ b/samples/net/coaps_client/README.rst @@ -10,7 +10,7 @@ This sample code shows a CoAP over DTLS client using mbedTLS on top of Zephyr. Building and Running ******************** -Follow the steps for testing :ref:`networking with Qemu `. +Follow the steps for testing :ref:`networking_with_qemu`. Run the server application at samples/net/coaps_server, with the following command: diff --git a/samples/net/coaps_server/README.rst b/samples/net/coaps_server/README.rst index 2a630150141f1..7d229253f4b53 100644 --- a/samples/net/coaps_server/README.rst +++ b/samples/net/coaps_server/README.rst @@ -10,7 +10,7 @@ This sample code shows a CoAP over DTLS server using mbedTLS on top of Zephyr. Building and Running ******************** -Follow the steps for testing :ref:`networking with Qemu `. +Follow the steps for testing :ref:`networking_with_qemu`. In the application directory type: diff --git a/samples/net/dhcpv4_client/README.rst b/samples/net/dhcpv4_client/README.rst index 0da1e5252979d..24cbef425653d 100644 --- a/samples/net/dhcpv4_client/README.rst +++ b/samples/net/dhcpv4_client/README.rst @@ -13,33 +13,19 @@ information to a serial console. Requirements ************ -- :ref:`networking with Qemu ` +- :ref:`networking_with_qemu` Building and Running ******************** -QEMU x86 -======== +Running DHCPv4 client in Linux Host +=================================== These are instructions for how to use this sample application using QEMU on a Linux host to negotiate IP address from DHCPv4 server running on Linux host. -Follow readme from: - - Run 'loop_socat' and 'loop-slip-tap' scripts from net-tools. - - https://github.com/zephyrproject-rtos/net-tools - -.. code-block:: console - - $ ./loop_socat.sh - -In another window: - -.. code-block:: console - - $ sudo ./loop-slip-tap.sh +To use QEMU for testing, follow the :ref:`networking_with_qemu` guide. Here's a sample server configuration file '/etc/dhcpd/dhcp.conf' used to configure the DHCPv4 server: diff --git a/samples/net/dns_resolve/README.rst b/samples/net/dns_resolve/README.rst index 7529493c09593..fe0d1898d7373 100644 --- a/samples/net/dns_resolve/README.rst +++ b/samples/net/dns_resolve/README.rst @@ -21,7 +21,7 @@ For more information about DNS configuration variables, see: Requirements ************ -- :ref:`networking with Qemu ` +- :ref:`networking_with_qemu` - screen terminal emulator or equivalent. @@ -35,6 +35,7 @@ Requirements Dnsmasq version 2.76 Copyright (c) 2000-2016 Simon Kelley + Wiring ****** @@ -74,7 +75,6 @@ for example: CONFIG_NET_APP_MY_IPV6_ADDR="2001:db8::1" CONFIG_NET_APP_PEER_IPV6_ADDR="2001:db8::2" - are the IPv6 addresses for the DNS client running Zephyr and the DNS server, respectively. @@ -82,12 +82,8 @@ DNS server ========== The dnsmasq tool may be used for testing purposes. Sample dnsmasq start -script can be found in net-tools project. - -The net-tools can be downloaded from - - https://github.com/zephyrproject-rtos/net-tools - +script can be downloaded from the zephyrproject-rtos/net-tools project area: +https://github.com/zephyrproject-rtos/net-tools Open a terminal window and type: @@ -96,8 +92,23 @@ Open a terminal window and type: $ cd net-tools $ ./dnsmasq.sh +('su' or 'sudo' may be required.) + +The default project configurations settings for this sample uses the public +Google DNS servers. In order to use the local dnsmasq server, please edit +the appropriate 'prj.conf' file and update the DNS server addresses. For +instance, if using the usual IP addresses assigned to testing, update them +to the following values: -NOTE: some systems may require root privileges to run dnsmaq, use sudo or su. +.. code-block:: console + + CONFIG_DNS_SERVER1="192.0.2.2:5353" + CONFIG_DNS_SERVER2="[2001:db8::2]:5353" + +.. note:: + DNS uses port 53 by default, but the dnsmasq.conf file provided by + net-tools uses port 5353 to allow executing the daemon without + superuser privileges. If dnsmasq fails to start with an error like this: @@ -105,7 +116,6 @@ If dnsmasq fails to start with an error like this: dnsmasq: failed to create listening socket for port 5353: Address already in use - Open a terminal window and type: .. code-block:: console @@ -115,28 +125,10 @@ Open a terminal window and type: Try to launch the dnsmasq application again. - QEMU x86 ======== -Open a terminal window and type: - -.. code-block:: console - - $ make - - -Run 'loop_socat.sh' and 'loop-slip-tap.sh' as shown in the net-tools README -at: - - https://github.com/zephyrproject-rtos/net-tools - - -Open a terminal where the project was build (i.e. :file:`samples/net/dns_resolve`) and type: - -.. code-block:: console - - $ make run +To use QEMU for testing, follow the :ref:`networking_with_qemu` guide. FRDM K64F diff --git a/samples/net/echo_client/README.rst b/samples/net/echo_client/README.rst index a459cce96bb9a..cd14c19c677b3 100644 --- a/samples/net/echo_client/README.rst +++ b/samples/net/echo_client/README.rst @@ -13,12 +13,17 @@ and then verify it matches the data that was sent. The source code for this sample application can be found at: :file:`samples/net/echo_client`. +Requirements +************ + +- :ref:`networking_with_qemu` + Building and Running ******************** There are multiple ways to use this application. One of the most common usage scenario is to run echo-client application inside QEMU. This is -described in :ref:`networking with QEMU `. +described in :ref:`networking_with_qemu`. There are configuration files for different boards and setups in the echo-client directory: @@ -68,25 +73,15 @@ Build echo-client sample application like this: Make can select the default configuration file based on the BOARD you've specified automatically so you might not always need to mention it. -Running echo-server Linux Host -============================== +Running echo-server in Linux Host +================================= There is one useful testing scenario that can be used with Linux host. Here echo-client is run in QEMU and echo-server is run in Linux host. -Run 'loop_socat' and 'loop-slip-tap' scripts from net-tools in Linux host. - -.. code-block:: console - - $ ./loop_socat.sh +To use QEMU for testing, follow the :ref:`networking_with_qemu` guide. -In another window: - -.. code-block:: console - - $ sudo ./loop-slip-tap.sh - -In third window: +In a terminal window: .. code-block:: console @@ -96,5 +91,5 @@ Run echo-client application in QEMU: .. code-block:: console - $ cd $ZEPHYR_BASE/samples/net/echo-client + $ cd $ZEPHYR_BASE/samples/net/echo_client $ make pristine && make qemu diff --git a/samples/net/echo_server/README.rst b/samples/net/echo_server/README.rst index 341022df71093..aabd91058470e 100644 --- a/samples/net/echo_server/README.rst +++ b/samples/net/echo_server/README.rst @@ -14,12 +14,17 @@ them back. The source code for this sample application can be found at: :file:`samples/net/echo_server`. +Requirements +************ + +- :ref:`networking_with_qemu` + Building and Running ******************** There are multiple ways to use this application. One of the most common usage scenario is to run echo-server application inside QEMU. This is -described in :ref:`networking with QEMU `. +described in :ref:`networking_with_qemu`. There are configuration files for different boards and setups in the echo-server directory: @@ -75,26 +80,16 @@ Running echo-client in Linux Host There is one useful testing scenario that can be used with Linux host. Here echo-server is run in QEMU and echo-client is run in Linux host. -Run 'loop_socat' and 'loop-slip-tap' scripts from net-tools in Linux host. - -.. code-block:: console - - $ ./loop_socat.sh - -In another window: - -.. code-block:: console - - $ sudo ./loop-slip-tap.sh +To use QEMU for testing, follow the :ref:`networking_with_qemu` guide. Run echo-server application in QEMU: .. code-block:: console - $ cd $ZEPHYR_BASE/samples/net/echo-server + $ cd $ZEPHYR_BASE/samples/net/echo_server $ make pristine && make qemu -In third window: +In a terminal window: .. code-block:: console diff --git a/samples/net/http_client/README.rst b/samples/net/http_client/README.rst index 9574cad1fdc97..dd49c09673371 100644 --- a/samples/net/http_client/README.rst +++ b/samples/net/http_client/README.rst @@ -16,16 +16,20 @@ The source code for this sample application can be found at: Requirements ************ -- QEMU +- :ref:`networking_with_qemu` - Terminal emulator software - HTTP Server - DNS server (optional) + Building and Running ******************** Open the project configuration file for your platform, for example: :file:`prj_qemu_x86.conf` is the configuration file for QEMU. + +To use QEMU for testing, follow the :ref:`networking_with_qemu` guide. + For IPv4 networks, set the following variables: .. code-block:: console @@ -69,12 +73,9 @@ port is 8000. HTTP Server =========== -A very simple HTTP server is provided in net-tool project. - -The net-tools can be downloaded from - - https://github.com/zephyrproject-rtos/net-tools - +Sample code for a very simple HTTP server can be downloaded from the +zephyrproject-rtos/net-tools project area: +https://github.com/zephyrproject-rtos/net-tools Open a terminal window and type: @@ -87,7 +88,7 @@ Open a terminal window and type: DNS setup ========= -The net-tool project provides a simple DNS resolver. You can activate +The net-tools project provides a simple DNS resolver. You can activate it like this if you want to test the DNS resolving with HTTP client. Open a terminal window and type: diff --git a/samples/net/http_server/README.rst b/samples/net/http_server/README.rst index adb5416ee0387..9cd602a4d415b 100644 --- a/samples/net/http_server/README.rst +++ b/samples/net/http_server/README.rst @@ -23,8 +23,10 @@ Requirements - Linux machine with wget and the screen terminal emulator - Either QEMU or real device like Freedom Board (FRDM-K64F) +- For QEMU see this :ref:`networking_with_qemu` - LAN for testing purposes (Ethernet) + Building and Running ******************** @@ -33,6 +35,8 @@ If you want to modify the http-server sample application, please check the configuration settings in :file:`samples/net/http_server/src/main.c` file and also in the :file:`samples/net/http_server/src/config.h` file. +To use QEMU for testing, follow the :ref:`networking_with_qemu` guide. + This sample code supports both static and dynamic (DHCPv4) IP addresses that can be defined in the project configuration file: @@ -249,9 +253,6 @@ In order to compile and run the code execute: make BOARD=qemu_x86 run -The sample code supports only one hard-coded valid URL (index.html) and -will return 404 code for other requests. - Sample Output ============= diff --git a/samples/net/mbedtls_dtlsclient/README.rst b/samples/net/mbedtls_dtlsclient/README.rst index 991e81dd65f48..dc8dc94eab4ea 100644 --- a/samples/net/mbedtls_dtlsclient/README.rst +++ b/samples/net/mbedtls_dtlsclient/README.rst @@ -10,7 +10,7 @@ This sample code shows a simple DTLS client using mbed TLS on top of Zephyr Building and running ******************** -Follow the steps for testing :ref:`networking with Qemu `. +Follow the steps for testing :ref:`networking_with_qemu`. Obtain the mbed TLS code from: @@ -50,7 +50,7 @@ From the application directory type $ make run -This will result in Qemu running with the following output: +This will result in QEMU running with the following output: .. code-block:: console diff --git a/samples/net/mbedtls_dtlsserver/README.rst b/samples/net/mbedtls_dtlsserver/README.rst index 627651f4914fc..9bd1fc6129688 100644 --- a/samples/net/mbedtls_dtlsserver/README.rst +++ b/samples/net/mbedtls_dtlsserver/README.rst @@ -10,7 +10,7 @@ This sample code shows a simple DTLS server using mbedTLS on top of Zephyr. Building and Running ******************** -Follow the steps for testing :ref:`networking with Qemu `. +Follow the steps for testing :ref:`networking_with_qemu`. In the application directory type: diff --git a/samples/net/telnet/README.rst b/samples/net/telnet/README.rst index a2ee9a57e96b3..bf5d698778363 100644 --- a/samples/net/telnet/README.rst +++ b/samples/net/telnet/README.rst @@ -15,7 +15,7 @@ using a telnet client. Requirements ************ -- :ref:`Networking with Qemu ` +- :ref:`networking_with_qemu` Building and Running @@ -27,20 +27,7 @@ QEMU x86 These are instructions for how to use this sample application using QEMU on a Linux host connected to a network with DHCP service. -To use QEMU for testing, follow the :ref:`Networking with Qemu -` guide. - -Run 'loop_socat' and 'loop-slip-tap' scripts from net-tools. - -.. code-block:: console - - $ ./loop_socat.sh - -In another window: - -.. code-block:: console - - $ sudo ./loop-slip-tap.sh +To use QEMU for testing, follow the :ref:`networking_with_qemu` guide. Run Zephyr samples/net/telnet application in QEMU: diff --git a/subsys/net/ip/6lo.c b/subsys/net/ip/6lo.c index ab53cb9b7db8c..924d78aaf2311 100644 --- a/subsys/net/ip/6lo.c +++ b/subsys/net/ip/6lo.c @@ -862,11 +862,6 @@ static inline u8_t uncompress_sa(struct net_pkt *pkt, struct net_ipv6_hdr *ipv6, u8_t offset) { - if (CIPHC[1] & NET_6LO_IPHC_SAC_1) { - NET_DBG("SAC_1"); - NET_DBG("SAM_00 unspecified address"); - return offset; - } NET_DBG("SAC_0"); @@ -913,16 +908,11 @@ static inline u8_t uncompress_sa_ctx(struct net_pkt *pkt, u8_t offset, struct net_6lo_context *ctx) { - if (!ctx) { - return uncompress_sa(pkt, ipv6, offset); - } + NET_DBG("SAC_1"); switch (CIPHC[1] & NET_6LO_IPHC_SAM_11) { case NET_6LO_IPHC_SAM_00: - NET_DBG("SAM_00 full src addr inlined"); - - memcpy(ipv6->src.s6_addr, &CIPHC[offset], 16); - offset += 16; + NET_DBG("SAM_00 unspecified address"); break; case NET_6LO_IPHC_SAM_01: NET_DBG("SAM_01 last 64 bits are inlined"); @@ -978,8 +968,6 @@ static inline u8_t uncompress_da_mcast(struct net_pkt *pkt, NET_DBG("Dst is multicast"); if (CIPHC[1] & NET_6LO_IPHC_DAC_1) { - /* TODO: DAM00 Unicast-Prefix-based IPv6 Multicast Addresses */ - /* Reserved DAM_01, DAM_10, DAM_11 */ NET_WARN("Unsupported DAM options"); return 0; } @@ -1033,17 +1021,12 @@ static inline u8_t uncompress_da(struct net_pkt *pkt, struct net_ipv6_hdr *ipv6, u8_t offset) { + NET_DBG("DAC_0"); + if (CIPHC[1] & NET_6LO_IPHC_M_1) { return uncompress_da_mcast(pkt, ipv6, offset); } - if (CIPHC[1] & NET_6LO_IPHC_DAC_1) { - /* Invalid case: ctx doesn't exists , but DAC is 1*/ - return 0; - } - - NET_DBG("DAC_0"); - switch (CIPHC[1] & NET_6LO_IPHC_DAM_11) { case NET_6LO_IPHC_DAM_00: NET_DBG("DAM_00 full dst addr inlined"); @@ -1087,21 +1070,12 @@ static inline u8_t uncompress_da_ctx(struct net_pkt *pkt, u8_t offset, struct net_6lo_context *ctx) { - if (!ctx) { - return uncompress_da(pkt, ipv6, offset); - } + NET_DBG("DAC_1"); if (CIPHC[1] & NET_6LO_IPHC_M_1) { return uncompress_da_mcast(pkt, ipv6, offset); } - if (!(CIPHC[1] & NET_6LO_IPHC_DAC_1)) { - /* Invalid case: ctx exists but DAC is 0. */ - return 0; - } - - NET_DBG("DAC_1"); - switch (CIPHC[1] & NET_6LO_IPHC_DAM_11) { case NET_6LO_IPHC_DAM_01: NET_DBG("DAM_01 last 64 bits are inlined"); @@ -1210,7 +1184,7 @@ static inline u8_t uncompress_nh_udp(struct net_pkt *pkt, #if defined(CONFIG_NET_6LO_CONTEXT) /* Helper function to uncompress src and dst contexts */ -static inline bool uncompress_cid(struct net_pkt *pkt, +static inline void uncompress_cid(struct net_pkt *pkt, struct net_6lo_context **src, struct net_6lo_context **dst) { @@ -1230,17 +1204,6 @@ static inline bool uncompress_cid(struct net_pkt *pkt, if (!(*dst)) { NET_DBG("Unknown dst cid %d", cid); } - - /* If CID flag set and src or dst context not available means, - * either we don't have context information or we received - * corrupted packet. - */ - if (!*src && !*dst) { - NET_ERR("Context information does not exist in cache"); - return false; - } - - return true; } #endif @@ -1259,10 +1222,7 @@ static inline bool uncompress_IPHC_header(struct net_pkt *pkt) if (CIPHC[1] & NET_6LO_IPHC_CID_1) { #if defined(CONFIG_NET_6LO_CONTEXT) - if (!uncompress_cid(pkt, &src, &dst)) { - return false; - } - + uncompress_cid(pkt, &src, &dst); offset++; #else NET_WARN("Context based uncompression not enabled"); @@ -1298,9 +1258,15 @@ static inline bool uncompress_IPHC_header(struct net_pkt *pkt) /* Uncompress Source Address */ #if defined(CONFIG_NET_6LO_CONTEXT) - offset = uncompress_sa_ctx(pkt, ipv6, offset, src); - if (!offset) { - goto fail; + if (CIPHC[1] & NET_6LO_IPHC_SAC_1) { + if (!src) { + NET_ERR("SAC is set but src context doesn't exists"); + goto fail; + } + + offset = uncompress_sa_ctx(pkt, ipv6, offset, src); + } else { + offset = uncompress_sa(pkt, ipv6, offset); } #else offset = uncompress_sa(pkt, ipv6, offset); @@ -1308,15 +1274,26 @@ static inline bool uncompress_IPHC_header(struct net_pkt *pkt) /* Uncompress Destination Address */ #if defined(CONFIG_NET_6LO_CONTEXT) - offset = uncompress_da_ctx(pkt, ipv6, offset, dst); - if (!offset) { - goto fail; + if (CIPHC[1] & NET_6LO_IPHC_DAC_1) { + if (CIPHC[1] & NET_6LO_IPHC_M_1) { + /* TODO: DAM00 Unicast-Prefix-based IPv6 Multicast + * Addresses. DAM_01, DAM_10 and DAM_11 are reserved. + */ + NET_ERR("DAC_1 and M_1 is not supported"); + goto fail; + } + + if (!dst) { + NET_ERR("DAC is set but dst context doesn't exists"); + goto fail; + } + + offset = uncompress_da_ctx(pkt, ipv6, offset, dst); + } else { + offset = uncompress_da(pkt, ipv6, offset); } #else offset = uncompress_da(pkt, ipv6, offset); - if (!offset) { - goto fail; - } #endif net_buf_add(frag, NET_IPV6H_LEN); diff --git a/subsys/net/ip/ipv6.c b/subsys/net/ip/ipv6.c index faf3861995059..854371aaeb08a 100644 --- a/subsys/net/ip/ipv6.c +++ b/subsys/net/ip/ipv6.c @@ -855,11 +855,23 @@ struct net_pkt *net_ipv6_prepare_for_send(struct net_pkt *pkt) * https://jira.zephyrproject.org/browse/ZEP-1656 */ if (atomic_test_bit(net_pkt_iface(pkt)->flags, NET_IF_POINTOPOINT)) { + /* Update RPL header */ + if (net_rpl_update_header(pkt, &NET_IPV6_HDR(pkt)->dst) < 0) { + net_pkt_unref(pkt); + return NULL; + } + return pkt; } if (net_pkt_ll_dst(pkt)->addr || net_is_ipv6_addr_mcast(&NET_IPV6_HDR(pkt)->dst)) { + /* Update RPL header */ + if (net_rpl_update_header(pkt, &NET_IPV6_HDR(pkt)->dst) < 0) { + net_pkt_unref(pkt); + return NULL; + } + return update_ll_reserve(pkt, &NET_IPV6_HDR(pkt)->dst); } diff --git a/subsys/net/ip/net_context.c b/subsys/net/ip/net_context.c index 1da453727ce68..32c61fe2cb308 100644 --- a/subsys/net/ip/net_context.c +++ b/subsys/net/ip/net_context.c @@ -646,7 +646,7 @@ int net_context_listen(struct net_context *context, int backlog) NET_ASSERT(PART_OF_ARRAY(contexts, context)); if (!net_context_is_used(context)) { - return -ENOENT; + return -EBADF; } #if defined(CONFIG_NET_OFFLOAD) @@ -776,7 +776,7 @@ static int send_reset(struct net_context *context, int ret; ret = net_tcp_prepare_reset(context->tcp, remote, &pkt); - if (ret) { + if (ret || !pkt) { return ret; } @@ -1064,7 +1064,7 @@ int net_context_connect(struct net_context *context, #endif if (!net_context_is_used(context)) { - return -ENOENT; + return -EBADF; } if (addr->family != net_context_get_family(context)) { @@ -1577,7 +1577,7 @@ int net_context_accept(struct net_context *context, NET_ASSERT(PART_OF_ARRAY(contexts, context)); if (!net_context_is_used(context)) { - return -ENOENT; + return -EBADF; } #if defined(CONFIG_NET_OFFLOAD) @@ -1748,7 +1748,7 @@ static int sendto(struct net_pkt *pkt, int ret; if (!net_context_is_used(context)) { - return -ENOENT; + return -EBADF; } #if defined(CONFIG_NET_TCP) @@ -2051,7 +2051,7 @@ int net_context_recv(struct net_context *context, NET_ASSERT(context); if (!net_context_is_used(context)) { - return -ENOENT; + return -EBADF; } #if defined(CONFIG_NET_OFFLOAD) diff --git a/subsys/net/lib/http/http_server.c b/subsys/net/lib/http/http_server.c index c267633fc4dbc..bddbcd26462a3 100644 --- a/subsys/net/lib/http/http_server.c +++ b/subsys/net/lib/http/http_server.c @@ -29,6 +29,13 @@ static void https_disable(struct http_server_ctx *ctx); #if defined(MBEDTLS_DEBUG_C) #include +/* - Debug levels (from ext/lib/crypto/mbedtls/include/mbedtls/debug.h) + * - 0 No debug + * - 1 Error + * - 2 State change + * - 3 Informational + * - 4 Verbose + */ #define DEBUG_THRESHOLD 0 #endif @@ -958,6 +965,7 @@ static void my_debug(void *ctx, int level, const char *file, int line, const char *str) { const char *p, *basename; + int len; ARG_UNUSED(ctx); @@ -969,6 +977,12 @@ static void my_debug(void *ctx, int level, } + /* Avoid printing double newlines */ + len = strlen(str); + if (str[len - 1] == '\n') { + ((char *)str)[len - 1] = '\0'; + } + NET_DBG("%s:%04d: |%d| %s", basename, line, level, str); } #endif /* MBEDTLS_DEBUG_C && CONFIG_NET_DEBUG_HTTP */ @@ -1281,11 +1295,6 @@ static void https_handler(struct http_server_ctx *ctx) heap_init(ctx); -#if defined(MBEDTLS_DEBUG_C) && defined(CONFIG_NET_DEBUG_HTTP) - mbedtls_debug_set_threshold(DEBUG_THRESHOLD); - mbedtls_ssl_conf_dbg(&ctx->https.mbedtls.conf, my_debug, NULL); -#endif - #if defined(MBEDTLS_X509_CRT_PARSE_C) mbedtls_x509_crt_init(&ctx->https.mbedtls.srvcert); #endif @@ -1296,6 +1305,11 @@ static void https_handler(struct http_server_ctx *ctx) mbedtls_entropy_init(&ctx->https.mbedtls.entropy); mbedtls_ctr_drbg_init(&ctx->https.mbedtls.ctr_drbg); +#if defined(MBEDTLS_DEBUG_C) && defined(CONFIG_NET_DEBUG_HTTP) + mbedtls_debug_set_threshold(DEBUG_THRESHOLD); + mbedtls_ssl_conf_dbg(&ctx->https.mbedtls.conf, my_debug, NULL); +#endif + /* Load the certificates and private RSA key. This needs to be done * by the user so we call a callback that user must have provided. */ diff --git a/tests/net/6lo/src/main.c b/tests/net/6lo/src/main.c index 66a76eb109fc4..835a977e4bc67 100644 --- a/tests/net/6lo/src/main.c +++ b/tests/net/6lo/src/main.c @@ -456,7 +456,7 @@ static struct net_6lo_data test_data_4 = { .ipv6.len = { 0x00, 0x00 }, .ipv6.nexthdr = IPPROTO_UDP, .ipv6.hop_limit = 0xff, - .ipv6.src = src_sac1_sam00, + .ipv6.src = src_sam00, .ipv6.dst = dst_m1_dam00, .nh.udp.src_port = htons(udp_src_port_16bit), .nh.udp.dst_port = htons(udp_dst_port_16bit), @@ -795,6 +795,25 @@ static struct net_6lo_data test_data_22 = { .small = true, .iphc = true }; + +static struct net_6lo_data test_data_23 = { + .ipv6.vtc = 0x60, + .ipv6.tcflow = 0x20, + .ipv6.flow = 0x3412, + .ipv6.len = { 0x00, 0x00 }, + .ipv6.nexthdr = IPPROTO_UDP, + .ipv6.hop_limit = 0xff, + .ipv6.src = src_sam00, + .ipv6.dst = dst_dac1_dam01, + .nh.udp.src_port = htons(udp_src_port_8bit_y), + .nh.udp.dst_port = htons(udp_dst_port_8bit), + .nh.udp.len = 0x00, + .nh.udp.chksum = 0x00, + .nh_udp = true, + .nh_icmp = false, + .small = false, + .iphc = true +}; #endif static int test_6lo(struct net_6lo_data *data) @@ -856,7 +875,7 @@ static const struct { { "test_6lo_sam00_dam00", &test_data_1}, { "test_6lo_sam01_dam01", &test_data_2}, { "test_6lo_sam10_dam10", &test_data_3}, - { "test_6lo_sac1_sam00_m1_dam00", &test_data_4}, + { "test_6lo_sam00_m1_dam00", &test_data_4}, { "test_6lo_sam01_m1_dam01", &test_data_5}, { "test_6lo_sam10_m1_dam10", &test_data_6}, { "test_6lo_sam10_m1_dam10_no_udp", &test_data_7}, @@ -876,6 +895,7 @@ static const struct { { "test_6lo_sac1_sam01_m1_dam01", &test_data_20}, { "test_6lo_sac1_sam10_m1_dam10", &test_data_21}, { "test_6lo_sac1_sam11_m1_dam10", &test_data_22}, + { "test_6lo_sac0_sam00_dac1_dam01", &test_data_23}, #endif }; diff --git a/tests/net/ieee802154/fragment/src/main.c b/tests/net/ieee802154/fragment/src/main.c index 34f9d6ca0de21..bf94cd447b456 100644 --- a/tests/net/ieee802154/fragment/src/main.c +++ b/tests/net/ieee802154/fragment/src/main.c @@ -337,7 +337,7 @@ static struct net_fragment_data test_data_4 = { .ipv6.len = { 0x00, 0x00 }, .ipv6.nexthdr = IPPROTO_UDP, .ipv6.hop_limit = 0xff, - .ipv6.src = src_sac1_sam00, + .ipv6.src = src_sam00, .ipv6.dst = dst_m1_dam00, .udp.src_port = htons(udp_src_port_16bit), .udp.dst_port = htons(udp_dst_port_16bit), @@ -506,7 +506,7 @@ static const struct { { "test_fragment_sam00_dam00", &test_data_1}, { "test_fragment_sam01_dam01", &test_data_2}, { "test_fragment_sam10_dam10", &test_data_3}, - { "test_fragment_sac1_sam00_m1_dam00", &test_data_4}, + { "test_fragment_sam00_m1_dam00", &test_data_4}, { "test_fragment_sam01_m1_dam01", &test_data_5}, { "test_fragment_sam10_m1_dam10", &test_data_6}, { "test_fragment_ipv6_dispatch_small", &test_data_7},