AzureMXChip/MXCHIPAZ3166/core/lib/netxduo/samples/demo_netx_ppp.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, 
            5, 5, 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, 
            5, 5, 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", 128, pointer, 2048);
    pointer = pointer + 2048;

    /* Check for pool creation error.  */
    if (status)
        error_counter++;

    /* Create the first PPP instance.  */
    status =  nx_ppp_create(&ppp_0, "NetX PPP Instance 0", &ip_0, pointer, 2048, 1, &pool_0, invalid_packet_handler, ppp_0_serial_byte_output);
    pointer =  pointer + 2048;

    /* Check for PPP create error.   */
    if (status)
        error_counter++;

    /* Define IP address. This PPP instance is effectively the server since it has both IP addresses. */
    status =  nx_ppp_ip_address_assign(&ppp_0, IP_ADDRESS(1, 2, 3, 4), IP_ADDRESS(1, 2, 3, 5));
    
    /* Check for PPP IP address assign error.   */
    if (status)
        error_counter++;

    /* Register the link up/down callbacks.  */
    status =  nx_ppp_link_up_notify(&ppp_0, link_up_callback);
    status += nx_ppp_link_down_notify(&ppp_0, link_down_callback);

    /* Check for PPP link up/down callback registration error(s).   */
    if (status)
        error_counter++;

    /* Setup PAP, this PPP instance is effectively the server since it will verify the name and password.  */
    status =  nx_ppp_pap_enable(&ppp_0, NX_NULL, verify_login);

    /* Check for PPP PAP enable error.  */
    if (status)
        error_counter++;

    /* Create an IP instance.  */
    status = nx_ip_create(&ip_0, "NetX IP Instance 0", IP_ADDRESS(0, 0, 0, 0), 0xFFFFF000UL, &pool_0, nx_ppp_driver,
                    pointer, 2048, 1);
    pointer =  pointer + 2048;
  
    /* Create the next PPP instance.  */
    status =  nx_ppp_create(&ppp_1, "NetX PPP Instance 1", &ip_1, pointer, 2048, 1, &pool_0, invalid_packet_handler, ppp_1_serial_byte_output);
    pointer =  pointer + 2048;

    /* Check for PPP create error.   */
    if (status)
        error_counter++;

    /* Define IP address. This PPP instance is effectively the client since it doesn't have any IP addresses. */
    status =  nx_ppp_ip_address_assign(&ppp_1, IP_ADDRESS(0, 0, 0, 0), IP_ADDRESS(0, 0, 0, 0));

    /* Check for PPP IP address assign error.   */
    if (status)
        error_counter++;

    /* Register the link up/down callbacks.  */
    status =  nx_ppp_link_up_notify(&ppp_1, link_up_callback);
    status += nx_ppp_link_down_notify(&ppp_1, link_down_callback);

    /* Check for PPP link up/down callback registration error(s).   */
    if (status)
        error_counter++;

    /* Setup PAP, this PPP instance is effectively the since it generates the name and password for the peer.  */
    status =  nx_ppp_pap_enable(&ppp_1, generate_login, NX_NULL);

    /* Check for PPP PAP enable error.  */
    if (status)
        error_counter++;

    /* Create another IP instance.  */
    status += nx_ip_create(&ip_1, "NetX IP Instance 1", IP_ADDRESS(0, 0, 0, 0), 0xFFFFF000UL, &pool_0, nx_ppp_driver,
                    pointer, 2048, 1);
    pointer =  pointer + 2048;

    /* Enable UDP traffic.  */
    status =  nx_udp_enable(&ip_0);
    status += nx_udp_enable(&ip_1);

    /* Check for UDP enable errors.  */
    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, 
            5, 5, 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, 
            5, 5, 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", 128, pointer, 2048);
    pointer = pointer + 2048;
    if (status)
        error_counter++;
    status =  nx_ppp_create(&ppp_0, "NetX PPP Instance 0", &ip_0, pointer, 2048, 1, &pool_0, invalid_packet_handler, ppp_0_serial_byte_output);
    pointer =  pointer + 2048;
    if (status)
        error_counter++;
    status =  nx_ppp_ip_address_assign(&ppp_0, IP_ADDRESS(1, 2, 3, 4), IP_ADDRESS(1, 2, 3, 5));
    if (status)
        error_counter++;
    status =  nx_ppp_link_up_notify(&ppp_0, link_up_callback);
    status += nx_ppp_link_down_notify(&ppp_0, link_down_callback);
    if (status)
        error_counter++;
    status =  nx_ppp_pap_enable(&ppp_0, NX_NULL, verify_login);
    if (status)
        error_counter++;
    status = nx_ip_create(&ip_0, "NetX IP Instance 0", IP_ADDRESS(0, 0, 0, 0), 0xFFFFF000UL, &pool_0, nx_ppp_driver,
                    pointer, 2048, 1);
    pointer =  pointer + 2048;
    status =  nx_ppp_create(&ppp_1, "NetX PPP Instance 1", &ip_1, pointer, 2048, 1, &pool_0, invalid_packet_handler, ppp_1_serial_byte_output);
    pointer =  pointer + 2048;
    if (status)
        error_counter++;
    status =  nx_ppp_ip_address_assign(&ppp_1, IP_ADDRESS(0, 0, 0, 0), IP_ADDRESS(0, 0, 0, 0));
    if (status)
        error_counter++;
    status =  nx_ppp_link_up_notify(&ppp_1, link_up_callback);
    status += nx_ppp_link_down_notify(&ppp_1, link_down_callback);
    if (status)
        error_counter++;
    status =  nx_ppp_pap_enable(&ppp_1, generate_login, NX_NULL);
    if (status)
        error_counter++;
    status += nx_ip_create(&ip_1, "NetX IP Instance 1", IP_ADDRESS(0, 0, 0, 0), 0xFFFFF000UL, &pool_0, nx_ppp_driver,
                    pointer, 2048, 1);
    pointer =  pointer + 2048;
    status =  nx_udp_enable(&ip_0);
    status += nx_udp_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 , 5 , 5 , 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 , 5 , 5 , TX_NO_TIME_SLICE , TX_AUTO_START ) ; pointer = pointer + DEMO_STACK_SIZE ; nx_system_initialize ( ) ; status = nx_packet_pool_create ( & pool_0 , " " , 128 , pointer , 2048 ) ; pointer = pointer + 2048 ; if ( status ) error_counter ++ ; status = nx_ppp_create ( & ppp_0 , " " , & ip_0 , pointer , 2048 , 1 , & pool_0 , invalid_packet_handler , ppp_0_serial_byte_output ) ; pointer = pointer + 2048 ; if ( status ) error_counter ++ ; status = nx_ppp_ip_address_assign ( & ppp_0 , IP_ADDRESS ( 1 , 2 , 3 , 4 ) , IP_ADDRESS ( 1 , 2 , 3 , 5 ) ) ; if ( status ) error_counter ++ ; status = nx_ppp_link_up_notify ( & ppp_0 , link_up_callback ) ; status += nx_ppp_link_down_notify ( & ppp_0 , link_down_callback ) ; if ( status ) error_counter ++ ; status = nx_ppp_pap_enable ( & ppp_0 , NX_NULL , verify_login ) ; if ( status ) error_counter ++ ; status = nx_ip_create ( & ip_0 , " " , IP_ADDRESS ( 0 , 0 , 0 , 0 ) , 0xFFFFF000UL , & pool_0 , nx_ppp_driver , pointer , 2048 , 1 ) ; pointer = pointer + 2048 ; status = nx_ppp_create ( & ppp_1 , " " , & ip_1 , pointer , 2048 , 1 , & pool_0 , invalid_packet_handler , ppp_1_serial_byte_output ) ; pointer = pointer + 2048 ; if ( status ) error_counter ++ ; status = nx_ppp_ip_address_assign ( & ppp_1 , IP_ADDRESS ( 0 , 0 , 0 , 0 ) , IP_ADDRESS ( 0 , 0 , 0 , 0 ) ) ; if ( status ) error_counter ++ ; status = nx_ppp_link_up_notify ( & ppp_1 , link_up_callback ) ; status += nx_ppp_link_down_notify ( & ppp_1 , link_down_callback ) ; if ( status ) error_counter ++ ; status = nx_ppp_pap_enable ( & ppp_1 , generate_login , NX_NULL ) ; if ( status ) error_counter ++ ; status += nx_ip_create ( & ip_1 , " " , IP_ADDRESS ( 0 , 0 , 0 , 0 ) , 0xFFFFF000UL , & pool_0 , nx_ppp_driver , pointer , 2048 , 1 ) ; pointer = pointer + 2048 ; status = nx_udp_enable ( & ip_0 ) ; status += nx_udp_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.  */ /* .  */ /* Initialize the NetX system.  */ /* Create a packet pool.  */ /* Check for pool creation error.  */ /* Create the first PPP instance.  */ /* Check for PPP create error.   */ /* Define IP address. This PPP instance is effectively the server since it has both IP addresses. */ /* Check for PPP IP address assign error.   */ /* Register the link up/down callbacks.  */ /* Check for PPP link up/down callback registration error(s).   */ /* Setup PAP, this PPP instance is effectively the server since it will verify the name and password.  */ /* Check for PPP PAP enable error.  */ /* Create an IP instance.  */ /* Create the next PPP instance.  */ /* Check for PPP create error.   */ /* Define IP address. This PPP instance is effectively the client since it doesn't have any IP addresses. */ /* Check for PPP IP address assign error.   */ /* Register the link up/down callbacks.  */ /* Check for PPP link up/down callback registration error(s).   */ /* Setup PAP, this PPP instance is effectively the since it generates the name and password for the peer.  */ /* Check for PPP PAP enable error.  */ /* Create another IP instance.  */ /* Enable UDP traffic.  */ /* Check for UDP enable errors.  */