AzureMXChip/MXCHIPAZ3166/core/lib/netxduo/samples/demo_netx_duo_multihome_tcp.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(&thread_0, "thread 0", thread_0_entry, 0,
                     pointer, DEMO_STACK_SIZE,
                     4, 4, TX_NO_TIME_SLICE, TX_AUTO_START);

    pointer =  pointer + DEMO_STACK_SIZE;

    /* Create the main thread.  */
    tx_thread_create(&thread_1, "thread 1", thread_1_entry, 0,
                     pointer, DEMO_STACK_SIZE,
                     3, 3, TX_NO_TIME_SLICE, TX_AUTO_START);

    pointer =  pointer + DEMO_STACK_SIZE;


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

    /* Create a packet pool.  */
    status =  nx_packet_pool_create(&pool_0, "NetX Main Packet Pool", PACKET_SIZE, pool_buffer, POOL_SIZE);

    if (status)
    {
        error_counter++;
    }

    /* Create an IP instance.  */
    status = nx_ip_create(&ip_0, "NetX IP Instance 0", IP_ADDRESS(1, 2, 3, 4), 0xFFFFFF00UL, &pool_0, _nx_ram_network_driver,
                          pointer, 2048, 1);
    pointer =  pointer + 2048;

    /* Create another IP instance.  */
    status += nx_ip_create(&ip_1, "NetX IP Instance 1", IP_ADDRESS(1, 2, 3, 5), 0xFFFFFF00UL, &pool_0, _nx_ram_network_driver,
                           pointer, 2048, 1);
    pointer =  pointer + 2048;

    if (status)
    {
        error_counter++;
    }

#ifndef NX_DISABLE_IPV4
    /* Set the server IP address to ip_1 primary IPv4 address. */
    ip1_primary_ipv4_address.nxd_ip_version = NX_IP_VERSION_V4;
    ip1_primary_ipv4_address.nxd_ip_address.v4 = IP_ADDRESS(1, 2, 3, 5);
#endif /* NX_DISABLE_IPV4 */


    /* Attach the second interface to IP_0. Note that this interface is attached during initialization time.
       Alternatively the second interface may also be attached in thread context, as illustrated below
       in thead_0_entry function. */
    status = nx_ip_interface_attach(&ip_0, "IP_0 Secondary Interface", IP_ADDRESS(2, 2, 3, 4), 0xFFFFFF00, _nx_ram_network_driver);

    if (status)
    {
        error_counter++;
    }

#ifndef NX_DISABLE_IPV4
    /* Enable ARP and supply ARP cache memory for IP Instance 0.  */
    status =  nx_arp_enable(&ip_0, (void *)pointer, 1024);
    pointer = pointer + 1024;

    /* Enable ARP and supply ARP cache memory for IP Instance 1.  */
    status +=  nx_arp_enable(&ip_1, (void *)pointer, 1024);
    pointer = pointer + 1024;

    /* Check ARP enable status.  */
    if (status)
    {
        error_counter++;
    }
#endif /* NX_DISABLE_IPV4 */
#ifndef NX_DISABLE_IPV6

    /* Enable IPv6 */
    status = nxd_ipv6_enable(&ip_0);
    if (status)
    {
        error_counter++;
    }

    status = nxd_ipv6_enable(&ip_1);
    if (status)
    {
        error_counter++;
    }
#endif /* !NX_DISABLE_IPV6 */

    /* Enable ICMP */
    status = nxd_icmp_enable(&ip_0);
    if (status)
    {
        error_counter++;
    }

    status = nxd_icmp_enable(&ip_1);
    if (status)
    {
        error_counter++;
    }


    /* Enable TCP processing for both IP instances.  */
    status =  nx_tcp_enable(&ip_0);
    status += nx_tcp_enable(&ip_1);

    if (status)
    {
        error_counter++;
    }
}
/* 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(&thread_0, "thread 0", thread_0_entry, 0,
                     pointer, DEMO_STACK_SIZE,
                     4, 4, TX_NO_TIME_SLICE, TX_AUTO_START);
    pointer =  pointer + DEMO_STACK_SIZE;
    tx_thread_create(&thread_1, "thread 1", thread_1_entry, 0,
                     pointer, DEMO_STACK_SIZE,
                     3, 3, TX_NO_TIME_SLICE, TX_AUTO_START);
    pointer =  pointer + DEMO_STACK_SIZE;
    nx_system_initialize();
    status =  nx_packet_pool_create(&pool_0, "NetX Main Packet Pool", PACKET_SIZE, pool_buffer, POOL_SIZE);
    if (status)
    {
        error_counter++;
    }
    status = nx_ip_create(&ip_0, "NetX IP Instance 0", IP_ADDRESS(1, 2, 3, 4), 0xFFFFFF00UL, &pool_0, _nx_ram_network_driver,
                          pointer, 2048, 1);
    pointer =  pointer + 2048;
    status += nx_ip_create(&ip_1, "NetX IP Instance 1", IP_ADDRESS(1, 2, 3, 5), 0xFFFFFF00UL, &pool_0, _nx_ram_network_driver,
                           pointer, 2048, 1);
    pointer =  pointer + 2048;
    if (status)
    {
        error_counter++;
    }
#ifndef NX_DISABLE_IPV4
    ip1_primary_ipv4_address.nxd_ip_version = NX_IP_VERSION_V4;
    ip1_primary_ipv4_address.nxd_ip_address.v4 = IP_ADDRESS(1, 2, 3, 5);
#endif 
    status = nx_ip_interface_attach(&ip_0, "IP_0 Secondary Interface", IP_ADDRESS(2, 2, 3, 4), 0xFFFFFF00, _nx_ram_network_driver);
    if (status)
    {
        error_counter++;
    }
#ifndef NX_DISABLE_IPV4
    status =  nx_arp_enable(&ip_0, (void *)pointer, 1024);
    pointer = pointer + 1024;
    status +=  nx_arp_enable(&ip_1, (void *)pointer, 1024);
    pointer = pointer + 1024;
    if (status)
    {
        error_counter++;
    }
#endif 
#ifndef NX_DISABLE_IPV6
    status = nxd_ipv6_enable(&ip_0);
    if (status)
    {
        error_counter++;
    }
    status = nxd_ipv6_enable(&ip_1);
    if (status)
    {
        error_counter++;
    }
#endif 
    status = nxd_icmp_enable(&ip_0);
    if (status)
    {
        error_counter++;
    }
    status = nxd_icmp_enable(&ip_1);
    if (status)
    {
        error_counter++;
    }
    status =  nx_tcp_enable(&ip_0);
    status += nx_tcp_enable(&ip_1);
    if (status)
    {
        error_counter++;
    }
}
void tx_application_define ( void * first_unused_memory ) { CHAR * pointer ; UINT status ; pointer = ( CHAR * ) first_unused_memory ; tx_thread_create ( & thread_0 , " " , thread_0_entry , 0 , pointer , DEMO_STACK_SIZE , 4 , 4 , TX_NO_TIME_SLICE , TX_AUTO_START ) ; pointer = pointer + DEMO_STACK_SIZE ; tx_thread_create ( & thread_1 , " " , thread_1_entry , 0 , pointer , DEMO_STACK_SIZE , 3 , 3 , TX_NO_TIME_SLICE , TX_AUTO_START ) ; pointer = pointer + DEMO_STACK_SIZE ; nx_system_initialize ( ) ; status = nx_packet_pool_create ( & pool_0 , " " , PACKET_SIZE , pool_buffer , POOL_SIZE ) ; if ( status ) { error_counter ++ ; } status = nx_ip_create ( & ip_0 , " " , IP_ADDRESS ( 1 , 2 , 3 , 4 ) , 0xFFFFFF00UL , & pool_0 , _nx_ram_network_driver , pointer , 2048 , 1 ) ; pointer = pointer + 2048 ; status += nx_ip_create ( & ip_1 , " " , IP_ADDRESS ( 1 , 2 , 3 , 5 ) , 0xFFFFFF00UL , & pool_0 , _nx_ram_network_driver , pointer , 2048 , 1 ) ; pointer = pointer + 2048 ; if ( status ) { error_counter ++ ; } #ifndef NX_DISABLE_IPV4 ip1_primary_ipv4_address . nxd_ip_version = NX_IP_VERSION_V4 ; ip1_primary_ipv4_address . nxd_ip_address . v4 = IP_ADDRESS ( 1 , 2 , 3 , 5 ) ; #endif status = nx_ip_interface_attach ( & ip_0 , " " , IP_ADDRESS ( 2 , 2 , 3 , 4 ) , 0xFFFFFF00 , _nx_ram_network_driver ) ; if ( status ) { error_counter ++ ; } #ifndef NX_DISABLE_IPV4 status = nx_arp_enable ( & ip_0 , ( void * ) pointer , 1024 ) ; pointer = pointer + 1024 ; status += nx_arp_enable ( & ip_1 , ( void * ) pointer , 1024 ) ; pointer = pointer + 1024 ; if ( status ) { error_counter ++ ; } #endif #ifndef NX_DISABLE_IPV6 status = nxd_ipv6_enable ( & ip_0 ) ; if ( status ) { error_counter ++ ; } status = nxd_ipv6_enable ( & ip_1 ) ; if ( status ) { error_counter ++ ; } #endif status = nxd_icmp_enable ( & ip_0 ) ; if ( status ) { error_counter ++ ; } status = nxd_icmp_enable ( & ip_1 ) ; if ( status ) { error_counter ++ ; } status = nx_tcp_enable ( & ip_0 ) ; status += nx_tcp_enable ( & ip_1 ) ; if ( status ) { error_counter ++ ; } }
Define what the initial system looks like.
Define what the initial system looks like .
/* Setup the working pointer.  */ /* Create the main thread.  */ /* Create the main thread.  */ /* Initialize the NetX system.  */ /* Create a packet pool.  */ /* Create an IP instance.  */ /* Create another IP instance.  */ /* Set the server IP address to ip_1 primary IPv4 address. */ /* NX_DISABLE_IPV4 */ /* Attach the second interface to IP_0. Note that this interface is attached during initialization time.
       Alternatively the second interface may also be attached in thread context, as illustrated below
       in thead_0_entry function. */ /* Enable ARP and supply ARP cache memory for IP Instance 0.  */ /* Enable ARP and supply ARP cache memory for IP Instance 1.  */ /* Check ARP enable status.  */ /* NX_DISABLE_IPV4 */ /* Enable IPv6 */ /* !NX_DISABLE_IPV6 */ /* Enable ICMP */ /* Enable TCP processing for both IP instances.  */