summaryrefslogtreecommitdiff
path: root/test/regression/usbx_cdc_ecm_host_non_ip_packet_received_test.c
blob: 599fa3ac123080d01e14b661cc6b477d7fa69c4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/***************************************************************************/
/* Copyright (c) 2024 Microsoft Corporation                                */
/* Copyright (c) 2026 Eclipse ThreadX contributors                         */
/*                                                                         */
/* This program and the accompanying materials are made available under    */
/* the terms of the MIT License which is available at                      */
/* https://opensource.org/licenses/MIT.                                    */
/*                                                                         */
/* SPDX-License-Identifier: MIT                                            */
/***************************************************************************/

/* This tests the case where the host receives a non-IP packet. */

#include "usbx_ux_test_cdc_ecm.h"

/* Define what the initial system looks like.  */
#ifdef CTEST
void test_application_define(void *first_unused_memory)
#else
void usbx_cdc_ecm_host_non_ip_packet_received_test_application_define(void *first_unused_memory)
#endif
{

    /* Inform user.  */
    printf("Running CDC-ECM Host Non IP Packet Received Test.................... ");

    stepinfo("\n");

    ux_test_cdc_ecm_initialize(first_unused_memory);
}

static void post_init_host()
{

NX_PACKET   *out_packet;

    /* Note that the packets we send to the host will just get released by NetX
       for being invalid. */

    /** Test '*(packet -> nx_packet_prepend_ptr + 12) != 0x08' **/

    UX_TEST_CHECK_SUCCESS(nx_packet_allocate(&packet_pool_device, &out_packet, NX_UDP_PACKET, NX_WAIT_FOREVER));

    out_packet->nx_packet_length = (ULONG)(out_packet->nx_packet_data_end - out_packet->nx_packet_prepend_ptr);
    memset(out_packet->nx_packet_prepend_ptr, 'a', out_packet->nx_packet_length);
    out_packet->nx_packet_prepend_ptr[12] = 0x00;

    /* Now send the packet. */
    _ux_device_class_cdc_ecm_write(cdc_ecm_device, out_packet);

    /* Wait for host to receive it. */
    tx_thread_sleep(500);

    /** Test '*(packet -> nx_packet_prepend_ptr + 13) != 0' **/

    UX_TEST_CHECK_SUCCESS(nx_packet_allocate(&packet_pool_device, &out_packet, NX_UDP_PACKET, NX_WAIT_FOREVER));

    out_packet->nx_packet_length = (ULONG)(out_packet->nx_packet_data_end - out_packet->nx_packet_prepend_ptr);
    memset(out_packet->nx_packet_prepend_ptr, 'a', out_packet->nx_packet_length);
    out_packet->nx_packet_prepend_ptr[12] = 0x08;
    out_packet->nx_packet_prepend_ptr[13] = 0x01;

    /* Now send the packet. */
    _ux_device_class_cdc_ecm_write(cdc_ecm_device, out_packet);

    /* Wait for host to receive it. */
    tx_thread_sleep(500);

    /* We're done!? */
}

static void post_init_device()
{
}