AzureMXChip/MXCHIPAZ3166/core/lib/netxduo/samples/demo_netxduo_dns.c
void    tx_application_define(void *first_unused_memory)
{

CHAR    *pointer;
UINT    status;

   
    /* Setup the working pointer.  */
    pointer =  (CHAR *) first_unused_memory;

    /* Create the main thread.  */
    tx_thread_create(&client_thread, "Client thread", thread_client_entry, 0,  
            pointer, DEMO_STACK_SIZE, 4, 4, TX_NO_TIME_SLICE, TX_AUTO_START);

    pointer =  pointer + DEMO_STACK_SIZE;

    /* Initialize the NetX system.  */
    nx_system_initialize();

#ifdef NX_DNS_CLIENT_USER_CREATE_PACKET_POOL   

    /* Create the packet pool for the DNS Client to send packets. 

        If the DNS Client is configured for letting the host application create 
        the DNS packet pool, (see NX_DNS_CLIENT_USER_CREATE_PACKET_POOL option), see
       nx_dns_create() for guidelines on packet payload size and pool size. 
       packet traffic for NetX processes. 
    */
    status =  nx_packet_pool_create(&client_pool, "DNS Client Packet Pool", NX_DNS_PACKET_PAYLOAD, pointer, NX_DNS_PACKET_POOL_SIZE);

    pointer = pointer + NX_DNS_PACKET_POOL_SIZE;

    /* Check for pool creation error.  */
    if (status)
    {

        error_counter++;
        return;
     }
#endif

    /* Create the packet pool which the IP task will use to send packets. Also available to the host
       application to send packet. */
    status =  nx_packet_pool_create(&main_pool, "Main Packet Pool", NX_PACKET_PAYLOAD, pointer, NX_PACKET_POOL_SIZE);

    pointer = pointer + NX_PACKET_POOL_SIZE;

    /* Check for pool creation error.  */
    if (status)
    {

        error_counter++;
        return;
     }

    /* Create an IP instance for the DNS Client.  */
    status = nx_ip_create(&client_ip, "DNS Client IP Instance", CLIENT_ADDRESS, 0xFFFFFF00UL, 
                          &main_pool, _nx_ram_network_driver, pointer, 2048, 1);

    pointer =  pointer + 2048;

    /* Check for IP create errors.  */
    if (status)
    {

        error_counter++;
        return;
     }

#ifndef NX_DISABLE_IPV4
    /* Enable ARP and supply ARP cache memory for the DNS Client IP.  */
    status =  nx_arp_enable(&client_ip, (void *) pointer, 1024);
    pointer = pointer + 1024;

    /* Check for ARP enable errors.  */
    if (status)
    {

        error_counter++;
        return;
     }
#endif /* NX_DISABLE_IPV4 */

    /* Enable UDP traffic because DNS is a UDP based protocol.  */
    status =  nx_udp_enable(&client_ip);

    /* Check for UDP enable errors.  */
    if (status)
    {

        error_counter++;
        return;
     }
}
/* Define what the initial system looks like.  */
Define what the initial system looks like.
Define what the initial system looks like .
void    tx_application_define(void *first_unused_memory)
{
CHAR    *pointer;
UINT    status;
    pointer =  (CHAR *) first_unused_memory;
    tx_thread_create(&client_thread, "Client thread", thread_client_entry, 0,  
            pointer, DEMO_STACK_SIZE, 4, 4, TX_NO_TIME_SLICE, TX_AUTO_START);
    pointer =  pointer + DEMO_STACK_SIZE;
    nx_system_initialize();
#ifdef NX_DNS_CLIENT_USER_CREATE_PACKET_POOL   
    status =  nx_packet_pool_create(&client_pool, "DNS Client Packet Pool", NX_DNS_PACKET_PAYLOAD, pointer, NX_DNS_PACKET_POOL_SIZE);
    pointer = pointer + NX_DNS_PACKET_POOL_SIZE;
    if (status)
    {
        error_counter++;
        return;
     }
#endif
    status =  nx_packet_pool_create(&main_pool, "Main Packet Pool", NX_PACKET_PAYLOAD, pointer, NX_PACKET_POOL_SIZE);
    pointer = pointer + NX_PACKET_POOL_SIZE;
    if (status)
    {
        error_counter++;
        return;
     }
    status = nx_ip_create(&client_ip, "DNS Client IP Instance", CLIENT_ADDRESS, 0xFFFFFF00UL, 
                          &main_pool, _nx_ram_network_driver, pointer, 2048, 1);
    pointer =  pointer + 2048;
    if (status)
    {
        error_counter++;
        return;
     }
#ifndef NX_DISABLE_IPV4
    status =  nx_arp_enable(&client_ip, (void *) pointer, 1024);
    pointer = pointer + 1024;
    if (status)
    {
        error_counter++;
        return;
     }
#endif 
    status =  nx_udp_enable(&client_ip);
    if (status)
    {
        error_counter++;
        return;
     }
}
void tx_application_define ( void * first_unused_memory ) { CHAR * pointer ; UINT status ; pointer = ( CHAR * ) first_unused_memory ; tx_thread_create ( & client_thread , " " , thread_client_entry , 0 , pointer , DEMO_STACK_SIZE , 4 , 4 , TX_NO_TIME_SLICE , TX_AUTO_START ) ; pointer = pointer + DEMO_STACK_SIZE ; nx_system_initialize ( ) ; #ifdef NX_DNS_CLIENT_USER_CREATE_PACKET_POOL status = nx_packet_pool_create ( & client_pool , " " , NX_DNS_PACKET_PAYLOAD , pointer , NX_DNS_PACKET_POOL_SIZE ) ; pointer = pointer + NX_DNS_PACKET_POOL_SIZE ; if ( status ) { error_counter ++ ; return ; } #endif status = nx_packet_pool_create ( & main_pool , " " , NX_PACKET_PAYLOAD , pointer , NX_PACKET_POOL_SIZE ) ; pointer = pointer + NX_PACKET_POOL_SIZE ; if ( status ) { error_counter ++ ; return ; } status = nx_ip_create ( & client_ip , " " , CLIENT_ADDRESS , 0xFFFFFF00UL , & main_pool , _nx_ram_network_driver , pointer , 2048 , 1 ) ; pointer = pointer + 2048 ; if ( status ) { error_counter ++ ; return ; } #ifndef NX_DISABLE_IPV4 status = nx_arp_enable ( & client_ip , ( void * ) pointer , 1024 ) ; pointer = pointer + 1024 ; if ( status ) { error_counter ++ ; return ; } #endif status = nx_udp_enable ( & client_ip ) ; if ( status ) { error_counter ++ ; return ; } }
Define what the initial system looks like.
Define what the initial system looks like .
/* Setup the working pointer.  */ /* Create the main thread.  */ /* Initialize the NetX system.  */ /* Create the packet pool for the DNS Client to send packets. 

        If the DNS Client is configured for letting the host application create 
        the DNS packet pool, (see NX_DNS_CLIENT_USER_CREATE_PACKET_POOL option), see
       nx_dns_create() for guidelines on packet payload size and pool size. 
       packet traffic for NetX processes. 
    */ /* Check for pool creation error.  */ /* Create the packet pool which the IP task will use to send packets. Also available to the host
       application to send packet. */ /* Check for pool creation error.  */ /* Create an IP instance for the DNS Client.  */ /* Check for IP create errors.  */ /* Enable ARP and supply ARP cache memory for the DNS Client IP.  */ /* Check for ARP enable errors.  */ /* NX_DISABLE_IPV4 */ /* Enable UDP traffic because DNS is a UDP based protocol.  */ /* Check for UDP enable errors.  */