/***************************************************************************/ /* 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 */ /***************************************************************************/ #include "tls_test_frame.h" /* Define the ThreadX and NetX object control blocks... */ NX_PACKET_POOL pool_0; NX_IP ip_0; NX_TCP_SOCKET tcp_socket; NX_SECURE_TLS_SESSION tls_session; NX_SECURE_X509_CERT certificate; NX_SECURE_X509_CERT remote_certificate, remote_issuer; NX_SECURE_X509_CERT trusted_certificate; UCHAR tls_packet_buffer[4000]; /* Define the IP thread's stack area. */ ULONG ip_thread_stack[3 * 1024 / sizeof(ULONG)]; /* Define packet pool for the demonstration. */ #define NX_PACKET_POOL_SIZE ((1536 + sizeof(NX_PACKET)) * 32) ULONG packet_pool_area[NX_PACKET_POOL_SIZE/sizeof(ULONG) + 64 / sizeof(ULONG)]; /* Define the ARP cache area. */ ULONG arp_space_area[512 / sizeof(ULONG)]; /* Define the demo thread. */ ULONG demo_thread_stack[6 * 1024 / sizeof(ULONG)]; TX_THREAD demo_thread; void server_thread_entry(ULONG thread_input); extern const NX_SECURE_TLS_CRYPTO nx_crypto_tls_ciphers; /* Define external references. */ VOID _nx_pcap_network_driver(NX_IP_DRIVER *driver_req_ptr); int demo_func_entry_0( void *ctx) { /* Enter the ThreadX kernel. */ tx_kernel_enter(); } /* Define what the initial system looks like. */ void tx_application_define(void *first_unused_memory) { ULONG gateway_ipv4_address; UINT status; /* Initialize the NetX system. */ nx_system_initialize(); /* Create a packet pool. */ status = nx_packet_pool_create(&pool_0, "NetX Main Packet Pool", 1536, (ULONG*)(((int)packet_pool_area + 64) & ~63) , NX_PACKET_POOL_SIZE); show_error_message_if_fail( status == NX_SUCCESS); /* Create an IP instance. */ status = nx_ip_create(&ip_0, "NetX IP Instance 0", DEVICE_IP_ADDRESS, 0xFFFFFF00UL, &pool_0, _nx_pcap_network_driver, (UCHAR*)ip_thread_stack, sizeof(ip_thread_stack), 1); show_error_message_if_fail( status == NX_SUCCESS); /* Enable ARP and supply ARP cache memory for IP Instance 0. */ status = nx_arp_enable(&ip_0, (void *)arp_space_area, sizeof(arp_space_area)); show_error_message_if_fail( status == NX_SUCCESS); /* Enable TCP traffic. */ status = nx_tcp_enable(&ip_0); show_error_message_if_fail( status == NX_SUCCESS); /* Enable UDP traffic. */ status = nx_udp_enable(&ip_0); show_error_message_if_fail( status == NX_SUCCESS); /* Enable ICMP. */ status = nx_icmp_enable(&ip_0); show_error_message_if_fail( status == NX_SUCCESS); status = nx_ip_fragment_enable(&ip_0); show_error_message_if_fail( status == NX_SUCCESS); tx_thread_create(&demo_thread, "demo thread", server_thread_entry, 0, demo_thread_stack, sizeof(demo_thread_stack), 16, 16, 4, TX_AUTO_START); } /* TLS Server example application thread. */ void server_thread_entry(ULONG thread_input) { tx_thread_sleep( 500); exit(0); }