AzureMXChip/MXCHIPAZ3166/core/lib/netxduo/addons/dhcp/nxd_dhcpv6_server.c
UINT  _nx_dhcpv6_server_create(NX_DHCPV6_SERVER *dhcpv6_server_ptr, NX_IP *ip_ptr, CHAR *name_ptr, 
                       NX_PACKET_POOL *packet_pool_ptr, VOID *stack_ptr,  ULONG stack_size,
                       VOID (*dhcpv6_address_declined_handler)(struct NX_DHCPV6_SERVER_STRUCT *dhcpv6_server_ptr, NX_DHCPV6_CLIENT *dhcpv6_client_ptr, UINT message),
                       VOID (*dhcpv6_option_request_handler)(struct NX_DHCPV6_SERVER_STRUCT *dhcpv6_server_ptr, UINT option_request, UCHAR *buffer_ptr, UINT *index))
{

UINT                i, status;
NX_DHCPV6_CLIENT    *dhcpv6_client_ptr;


    /* Initialize the DHCPV6 control block to zero.  */
    memset((void *) dhcpv6_server_ptr, 0, sizeof(NX_DHCPV6_SERVER));

    /* Default the server global index to index 1. If otherwise, the host
       application must set the DHCPv6 interface before it can start
       the Server (nx_dhcpv6_server_interface_set). */
    dhcpv6_server_ptr -> nx_dhcpv6_server_ga_address_index = 1;

    /* Link the DHCPv6 server with the IP instance. */
    dhcpv6_server_ptr -> nx_dhcpv6_ip_ptr =  ip_ptr;

    /* Set the DHCPV6 name.  */
    dhcpv6_server_ptr -> nx_dhcpv6_server_name =  name_ptr;

    /* Set the server packet pool. */
    dhcpv6_server_ptr -> nx_dhcpv6_packet_pool_ptr = packet_pool_ptr;

    /* Create the IP timer event flag instance.  */
    status = tx_event_flags_create(&dhcpv6_server_ptr -> nx_dhcpv6_server_timer_events, "DHCPv6 Server Timer Events Queue");

    /* Check for error. */
    if (status != TX_SUCCESS)
    {

        return status;
    }

    /* Create the DHCPV6 mutex for the Server instance.  */
    status =  tx_mutex_create(&(dhcpv6_server_ptr -> nx_dhcpv6_server_mutex), "DHCPV6 Server Mutex", TX_NO_INHERIT);

    /* Determine if the mutexes creation was successful.  */
    if (status)
    {

        /* Delete the flag queue.  */
        tx_event_flags_delete(&dhcpv6_server_ptr -> nx_dhcpv6_server_timer_events);

        /* No, return error status.  */
        return status;
    }

    /* Create the DHCPV6 processing thread. */
    status =  tx_thread_create(&(dhcpv6_server_ptr -> nx_dhcpv6_server_thread), "NetX DHCPV6 Server", _nx_dhcpv6_server_thread_entry, 
                               (ULONG)(ALIGN_TYPE)dhcpv6_server_ptr, stack_ptr, stack_size, 
                               NX_DHCPV6_SERVER_THREAD_PRIORITY, NX_DHCPV6_SERVER_THREAD_PRIORITY, 1, TX_DONT_START);

    NX_THREAD_EXTENSION_PTR_SET(&(dhcpv6_server_ptr -> nx_dhcpv6_server_thread), dhcpv6_server_ptr)

    /* Determine if the thread creation was successful. */
    if (status)
    {

        /* Delete the server protection mutex.  */
        tx_mutex_delete(&(dhcpv6_server_ptr -> nx_dhcpv6_server_mutex));

        /* Delete the flag queue.  */
        tx_event_flags_delete(&dhcpv6_server_ptr -> nx_dhcpv6_server_timer_events);

        /* No, return error status.  */
        return status;
    }

    /* Create the DHCPV6 timer for keeping track of IP lease time expiration.  */
    status =  tx_timer_create(&(dhcpv6_server_ptr -> nx_dhcpv6_lease_timer), "NetX DHCPV6 Server Lease timer",
                              _nx_dhcpv6_server_lease_timeout_entry, (ULONG)(ALIGN_TYPE)dhcpv6_server_ptr,
                              (NX_DHCPV6_IP_LEASE_TIMER_INTERVAL * NX_DHCPV6_SERVER_TICKS_PER_SECOND) , 
                              (NX_DHCPV6_IP_LEASE_TIMER_INTERVAL * NX_DHCPV6_SERVER_TICKS_PER_SECOND), 
                              TX_NO_ACTIVATE);

    NX_TIMER_EXTENSION_PTR_SET(&(dhcpv6_server_ptr -> nx_dhcpv6_lease_timer), dhcpv6_server_ptr)

    if (status != NX_SUCCESS)
    {

        /* Delete the DHCPv6 Server thread. */
        tx_thread_delete(&(dhcpv6_server_ptr -> nx_dhcpv6_server_thread));

        /* Delete the server protection mutex.  */
        tx_mutex_delete(&(dhcpv6_server_ptr -> nx_dhcpv6_server_mutex));

        /* Delete the flag queue.  */
        tx_event_flags_delete(&dhcpv6_server_ptr -> nx_dhcpv6_server_timer_events);
    }

    /* Create the DHCPV6 timer for keeping track of the DHCPv6 Client session time.  */
    status =  tx_timer_create(&(dhcpv6_server_ptr -> nx_dhcpv6_session_timer), "NetX DHCPV6 Session Duration timer",
                              _nx_dhcpv6_server_session_timeout_entry, (ULONG)(ALIGN_TYPE)dhcpv6_server_ptr,
                              (NX_DHCPV6_SESSION_TIMER_INTERVAL * NX_DHCPV6_SERVER_TICKS_PER_SECOND),
                              (NX_DHCPV6_SESSION_TIMER_INTERVAL * NX_DHCPV6_SERVER_TICKS_PER_SECOND), 
                              TX_NO_ACTIVATE);

    NX_TIMER_EXTENSION_PTR_SET(&(dhcpv6_server_ptr -> nx_dhcpv6_session_timer), dhcpv6_server_ptr)

    if (status != NX_SUCCESS)
    {

        /* Delete the server lease timer. */
        tx_timer_delete( &(dhcpv6_server_ptr -> nx_dhcpv6_lease_timer));

        /* Delete the DHCPv6 Server thread. */
        tx_thread_delete(&(dhcpv6_server_ptr -> nx_dhcpv6_server_thread));

        /* Delete the server protection mutex.  */
        tx_mutex_delete(&(dhcpv6_server_ptr -> nx_dhcpv6_server_mutex));

        /* Delete the flag queue.  */
        tx_event_flags_delete(&dhcpv6_server_ptr -> nx_dhcpv6_server_timer_events);
    }

    /*  Initialize the DHCPv6 client control blocks */
    for (i = 0; i < NX_DHCPV6_MAX_CLIENTS; i++)
    {

        /* Set a local pointer for convenience. */
        dhcpv6_client_ptr = &dhcpv6_server_ptr -> nx_dhcpv6_clients[i];

        /* Clear the client record. */
        memset(dhcpv6_client_ptr, 0, sizeof(NX_DHCPV6_CLIENT));
    }

    /* Determine if the timers creation were successful.  */
    if (status)
    {

        /* Delete the server lease timer. */
        tx_timer_delete( &(dhcpv6_server_ptr -> nx_dhcpv6_lease_timer));

        /* Delete the server serssion timer. */
        tx_timer_delete( &(dhcpv6_server_ptr -> nx_dhcpv6_session_timer));

        /* Delete the DHCPv6 Server thread. */
        tx_thread_delete(&(dhcpv6_server_ptr -> nx_dhcpv6_server_thread));

        /* Delete the server protection mutex.  */
        tx_mutex_delete(&(dhcpv6_server_ptr -> nx_dhcpv6_server_mutex));

        /* Delete the flag queue.  */
        tx_event_flags_delete(&dhcpv6_server_ptr -> nx_dhcpv6_server_timer_events);

        /* Return error status. */
        return status;
    }

    /* Save the DHCPV6 instance pointer in the socket. */
    dhcpv6_server_ptr -> nx_dhcpv6_server_socket.nx_udp_socket_reserved_ptr =  (void *) dhcpv6_server_ptr;

    /* Set the DHCPv6 Client ID.  */
    dhcpv6_server_ptr -> nx_dhcpv6_id =  NX_DHCPV6_SERVER_ID;

    /* Set the server preference for clients using multicast only for all request message types.  */
    dhcpv6_server_ptr -> nx_dhcpv6_server_multicast_only = NX_TRUE;

    /* Assign the various handlers (server error messages, state change and expired/deprecated addresses). */
    dhcpv6_server_ptr -> nx_dhcpv6_IP_address_declined_handler =  dhcpv6_address_declined_handler;
    dhcpv6_server_ptr -> nx_dhcpv6_server_option_request_handler = dhcpv6_option_request_handler;

    /* Return a successful status.  */
    return(NX_SUCCESS);
}
/**************************************************************************/
/*                                                                        */
/*  FUNCTION                                               RELEASE        */
/*                                                                        */
/*    _nx_dhcpv6_server_create                            PORTABLE C      */
/*                                                           6.1          */
/*  AUTHOR                                                                */
/*                                                                        */
/*    Yuxin Zhou, Microsoft Corporation                                   */
/*                                                                        */
/*  DESCRIPTION                                                           */
/*                                                                        */
/*    This function creates the DHCPv6 Client instance with a Netx packet */
/*    pool, processing thread, and various flag event queues, timers and  */
/*    mutexes necessary for DHCPv6 Client operations.                     */
/*                                                                        */
/*    Note: User is encouraged to call nx_dhcpv6_server_option_request    */
/*    _handler_set to set the option request handler.                     */
/*                                                                        */
/*  INPUT                                                                 */
/*                                                                        */
/*    dhcpv6_server_ptr                   Pointer to DHCPV6 Server        */
/*    ip_ptr                              Pointer to Server IP instance   */
/*    name_ptr                            DHCPV6 name pointer             */
/*    packet_pool_ptr                     Pointer to Server packet pool   */
/*    stack_ptr                           Pointer to free memory          */
/*    stack_size                          Size of server stack memory     */
/*    dhcpv6_address_declined_handler     Declined address request handler*/
/*    dhcpv6_option_request_handler       Option request handler          */
/*                                                                        */
/*  OUTPUT                                                                */
/*                                                                        */
/*    status                                Actual completion status      */
/*    NX_SUCCESS                            Successful completion status  */
/*                                                                        */
/*  CALLS                                                                 */
/*                                                                        */
/*    tx_event_flags_create                Create ThreadX flag event queue*/
/*    tx_mutex_create                      Create mutex lock on resource  */
/*    nx_packet_pool_delete                Delete the DHCPV6 packet pool  */
/*    nx_udp_socket_create                 Create the DHCPV6 UDP socket   */
/*    nx_udp_socket_delete                 Delete the DHCPV6 UDP socket   */
/*    tx_mutex_create                      Create DHCPV6 mutex            */
/*    tx_mutex_delete                      Delete DHCPV6 mutex            */
/*    tx_thread_create                     Create DHCPV6 processing thread*/
/*    tx_thread_delete                     Delete DHCPV6 processing thread*/
/*    tx_timer_create                      Create DHCPV6 timer            */
/*    tx_timer_delete                      Delete DHCPV6 timer            */
/*                                                                        */
/*  CALLED BY                                                             */
/*                                                                        */
/*    Application Code                                                    */
/*                                                                        */
/*  RELEASE HISTORY                                                       */
/*                                                                        */
/*    DATE              NAME                      DESCRIPTION             */
/*                                                                        */
/*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
/*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
/*                                            resulting in version 6.1    */
/*                                                                        */
/**************************************************************************/
FUNCTION                                               RELEASE

_nx_dhcpv6_server_create                            PORTABLE C
6.1
AUTHOR

Yuxin Zhou, Microsoft Corporation

DESCRIPTION

This function creates the DHCPv6 Client instance with a Netx packet
pool, processing thread, and various flag event queues, timers and
mutexes necessary for DHCPv6 Client operations.

User is encouraged to call nx_dhcpv6_server_option_request
_handler_set to set the option request handler.

INPUT

dhcpv6_server_ptr                   Pointer to DHCPV6 Server
ip_ptr                              Pointer to Server IP instance
name_ptr                            DHCPV6 name pointer
packet_pool_ptr                     Pointer to Server packet pool
stack_ptr                           Pointer to free memory
stack_size                          Size of server stack memory
dhcpv6_address_declined_handler     Declined address request handler
dhcpv6_option_request_handler       Option request handler

OUTPUT



CALLS

tx_event_flags_create                Create ThreadX flag event queue
tx_mutex_create                      Create mutex lock on resource
nx_packet_pool_delete                Delete the DHCPV6 packet pool
nx_udp_socket_create                 Create the DHCPV6 UDP socket
nx_udp_socket_delete                 Delete the DHCPV6 UDP socket
tx_mutex_create                      Create DHCPV6 mutex
tx_mutex_delete                      Delete DHCPV6 mutex
tx_thread_create                     Create DHCPV6 processing thread
tx_thread_delete                     Delete DHCPV6 processing thread
tx_timer_create                      Create DHCPV6 timer
tx_timer_delete                      Delete DHCPV6 timer

CALLED BY

Application Code

RELEASE HISTORY

DATE              NAME                      DESCRIPTION

05-19-2020     Yuxin Zhou               Initial Version 6.0
09-30-2020     Yuxin Zhou               Modified comment(s),
resulting in version 6.1
FUNCTION RELEASE _nx_dhcpv6_server_create PORTABLE C 6 . 1 AUTHOR Yuxin Zhou Microsoft Corporation DESCRIPTION This function creates the DHCPv6 Client instance with a Netx packet pool processing thread and various flag event queues timers and mutexes necessary for DHCPv6 Client operations . User is encouraged to call nx_dhcpv6_server_option_request _handler_set to set the option request handler . INPUT dhcpv6_server_ptr Pointer to DHCPV6 Server ip_ptr Pointer to Server IP instance name_ptr DHCPV6 name pointer packet_pool_ptr Pointer to Server packet pool stack_ptr Pointer to free memory stack_size Size of server stack memory dhcpv6_address_declined_handler Declined address request handler dhcpv6_option_request_handler Option request handler OUTPUT CALLS tx_event_flags_create Create ThreadX flag event queue tx_mutex_create Create mutex lock on resource nx_packet_pool_delete Delete the DHCPV6 packet pool nx_udp_socket_create Create the DHCPV6 UDP socket nx_udp_socket_delete Delete the DHCPV6 UDP socket tx_mutex_create Create DHCPV6 mutex tx_mutex_delete Delete DHCPV6 mutex tx_thread_create Create DHCPV6 processing thread tx_thread_delete Delete DHCPV6 processing thread tx_timer_create Create DHCPV6 timer tx_timer_delete Delete DHCPV6 timer CALLED BY Application Code RELEASE HISTORY DATE NAME DESCRIPTION 05 - 19 - 2020 Yuxin Zhou Initial Version 6 . 0 09 - 30 - 2020 Yuxin Zhou Modified comment ( s ) resulting in version 6 . 1
UINT  _nx_dhcpv6_server_create(NX_DHCPV6_SERVER *dhcpv6_server_ptr, NX_IP *ip_ptr, CHAR *name_ptr, 
                       NX_PACKET_POOL *packet_pool_ptr, VOID *stack_ptr,  ULONG stack_size,
                       VOID (*dhcpv6_address_declined_handler)(struct NX_DHCPV6_SERVER_STRUCT *dhcpv6_server_ptr, NX_DHCPV6_CLIENT *dhcpv6_client_ptr, UINT message),
                       VOID (*dhcpv6_option_request_handler)(struct NX_DHCPV6_SERVER_STRUCT *dhcpv6_server_ptr, UINT option_request, UCHAR *buffer_ptr, UINT *index))
{
UINT                i, status;
NX_DHCPV6_CLIENT    *dhcpv6_client_ptr;
    memset((void *) dhcpv6_server_ptr, 0, sizeof(NX_DHCPV6_SERVER));
    dhcpv6_server_ptr -> nx_dhcpv6_server_ga_address_index = 1;
    dhcpv6_server_ptr -> nx_dhcpv6_ip_ptr =  ip_ptr;
    dhcpv6_server_ptr -> nx_dhcpv6_server_name =  name_ptr;
    dhcpv6_server_ptr -> nx_dhcpv6_packet_pool_ptr = packet_pool_ptr;
    status = tx_event_flags_create(&dhcpv6_server_ptr -> nx_dhcpv6_server_timer_events, "DHCPv6 Server Timer Events Queue");
    if (status != TX_SUCCESS)
    {
        return status;
    }
    status =  tx_mutex_create(&(dhcpv6_server_ptr -> nx_dhcpv6_server_mutex), "DHCPV6 Server Mutex", TX_NO_INHERIT);
    if (status)
    {
        tx_event_flags_delete(&dhcpv6_server_ptr -> nx_dhcpv6_server_timer_events);
        return status;
    }
    status =  tx_thread_create(&(dhcpv6_server_ptr -> nx_dhcpv6_server_thread), "NetX DHCPV6 Server", _nx_dhcpv6_server_thread_entry, 
                               (ULONG)(ALIGN_TYPE)dhcpv6_server_ptr, stack_ptr, stack_size, 
                               NX_DHCPV6_SERVER_THREAD_PRIORITY, NX_DHCPV6_SERVER_THREAD_PRIORITY, 1, TX_DONT_START);
    NX_THREAD_EXTENSION_PTR_SET(&(dhcpv6_server_ptr -> nx_dhcpv6_server_thread), dhcpv6_server_ptr)
    if (status)
    {
        tx_mutex_delete(&(dhcpv6_server_ptr -> nx_dhcpv6_server_mutex));
        tx_event_flags_delete(&dhcpv6_server_ptr -> nx_dhcpv6_server_timer_events);
        return status;
    }
    status =  tx_timer_create(&(dhcpv6_server_ptr -> nx_dhcpv6_lease_timer), "NetX DHCPV6 Server Lease timer",
                              _nx_dhcpv6_server_lease_timeout_entry, (ULONG)(ALIGN_TYPE)dhcpv6_server_ptr,
                              (NX_DHCPV6_IP_LEASE_TIMER_INTERVAL * NX_DHCPV6_SERVER_TICKS_PER_SECOND) , 
                              (NX_DHCPV6_IP_LEASE_TIMER_INTERVAL * NX_DHCPV6_SERVER_TICKS_PER_SECOND), 
                              TX_NO_ACTIVATE);
    NX_TIMER_EXTENSION_PTR_SET(&(dhcpv6_server_ptr -> nx_dhcpv6_lease_timer), dhcpv6_server_ptr)
    if (status != NX_SUCCESS)
    {
        tx_thread_delete(&(dhcpv6_server_ptr -> nx_dhcpv6_server_thread));
        tx_mutex_delete(&(dhcpv6_server_ptr -> nx_dhcpv6_server_mutex));
        tx_event_flags_delete(&dhcpv6_server_ptr -> nx_dhcpv6_server_timer_events);
    }
    status =  tx_timer_create(&(dhcpv6_server_ptr -> nx_dhcpv6_session_timer), "NetX DHCPV6 Session Duration timer",
                              _nx_dhcpv6_server_session_timeout_entry, (ULONG)(ALIGN_TYPE)dhcpv6_server_ptr,
                              (NX_DHCPV6_SESSION_TIMER_INTERVAL * NX_DHCPV6_SERVER_TICKS_PER_SECOND),
                              (NX_DHCPV6_SESSION_TIMER_INTERVAL * NX_DHCPV6_SERVER_TICKS_PER_SECOND), 
                              TX_NO_ACTIVATE);
    NX_TIMER_EXTENSION_PTR_SET(&(dhcpv6_server_ptr -> nx_dhcpv6_session_timer), dhcpv6_server_ptr)
    if (status != NX_SUCCESS)
    {
        tx_timer_delete( &(dhcpv6_server_ptr -> nx_dhcpv6_lease_timer));
        tx_thread_delete(&(dhcpv6_server_ptr -> nx_dhcpv6_server_thread));
        tx_mutex_delete(&(dhcpv6_server_ptr -> nx_dhcpv6_server_mutex));
        tx_event_flags_delete(&dhcpv6_server_ptr -> nx_dhcpv6_server_timer_events);
    }
    for (i = 0; i < NX_DHCPV6_MAX_CLIENTS; i++)
    {
        dhcpv6_client_ptr = &dhcpv6_server_ptr -> nx_dhcpv6_clients[i];
        memset(dhcpv6_client_ptr, 0, sizeof(NX_DHCPV6_CLIENT));
    }
    if (status)
    {
        tx_timer_delete( &(dhcpv6_server_ptr -> nx_dhcpv6_lease_timer));
        tx_timer_delete( &(dhcpv6_server_ptr -> nx_dhcpv6_session_timer));
        tx_thread_delete(&(dhcpv6_server_ptr -> nx_dhcpv6_server_thread));
        tx_mutex_delete(&(dhcpv6_server_ptr -> nx_dhcpv6_server_mutex));
        tx_event_flags_delete(&dhcpv6_server_ptr -> nx_dhcpv6_server_timer_events);
        return status;
    }
    dhcpv6_server_ptr -> nx_dhcpv6_server_socket.nx_udp_socket_reserved_ptr =  (void *) dhcpv6_server_ptr;
    dhcpv6_server_ptr -> nx_dhcpv6_id =  NX_DHCPV6_SERVER_ID;
    dhcpv6_server_ptr -> nx_dhcpv6_server_multicast_only = NX_TRUE;
    dhcpv6_server_ptr -> nx_dhcpv6_IP_address_declined_handler =  dhcpv6_address_declined_handler;
    dhcpv6_server_ptr -> nx_dhcpv6_server_option_request_handler = dhcpv6_option_request_handler;
    return(NX_SUCCESS);
}
UINT _nx_dhcpv6_server_create ( NX_DHCPV6_SERVER * dhcpv6_server_ptr , NX_IP * ip_ptr , CHAR * name_ptr , NX_PACKET_POOL * packet_pool_ptr , VOID * stack_ptr , ULONG stack_size , VOID ( * dhcpv6_address_declined_handler ) ( struct NX_DHCPV6_SERVER_STRUCT * dhcpv6_server_ptr , NX_DHCPV6_CLIENT * dhcpv6_client_ptr , UINT message ) , VOID ( * dhcpv6_option_request_handler ) ( struct NX_DHCPV6_SERVER_STRUCT * dhcpv6_server_ptr , UINT option_request , UCHAR * buffer_ptr , UINT * index ) ) { UINT i , status ; NX_DHCPV6_CLIENT * dhcpv6_client_ptr ; memset ( ( void * ) dhcpv6_server_ptr , 0 , sizeof ( NX_DHCPV6_SERVER ) ) ; dhcpv6_server_ptr -> nx_dhcpv6_server_ga_address_index = 1 ; dhcpv6_server_ptr -> nx_dhcpv6_ip_ptr = ip_ptr ; dhcpv6_server_ptr -> nx_dhcpv6_server_name = name_ptr ; dhcpv6_server_ptr -> nx_dhcpv6_packet_pool_ptr = packet_pool_ptr ; status = tx_event_flags_create ( & dhcpv6_server_ptr -> nx_dhcpv6_server_timer_events , " " ) ; if ( status != TX_SUCCESS ) { return status ; } status = tx_mutex_create ( & ( dhcpv6_server_ptr -> nx_dhcpv6_server_mutex ) , " " , TX_NO_INHERIT ) ; if ( status ) { tx_event_flags_delete ( & dhcpv6_server_ptr -> nx_dhcpv6_server_timer_events ) ; return status ; } status = tx_thread_create ( & ( dhcpv6_server_ptr -> nx_dhcpv6_server_thread ) , " " , _nx_dhcpv6_server_thread_entry , ( ULONG ) ( ALIGN_TYPE ) dhcpv6_server_ptr , stack_ptr , stack_size , NX_DHCPV6_SERVER_THREAD_PRIORITY , NX_DHCPV6_SERVER_THREAD_PRIORITY , 1 , TX_DONT_START ) ; NX_THREAD_EXTENSION_PTR_SET ( & ( dhcpv6_server_ptr -> nx_dhcpv6_server_thread ) , dhcpv6_server_ptr ) if ( status ) { tx_mutex_delete ( & ( dhcpv6_server_ptr -> nx_dhcpv6_server_mutex ) ) ; tx_event_flags_delete ( & dhcpv6_server_ptr -> nx_dhcpv6_server_timer_events ) ; return status ; } status = tx_timer_create ( & ( dhcpv6_server_ptr -> nx_dhcpv6_lease_timer ) , " " , _nx_dhcpv6_server_lease_timeout_entry , ( ULONG ) ( ALIGN_TYPE ) dhcpv6_server_ptr , ( NX_DHCPV6_IP_LEASE_TIMER_INTERVAL * NX_DHCPV6_SERVER_TICKS_PER_SECOND ) , ( NX_DHCPV6_IP_LEASE_TIMER_INTERVAL * NX_DHCPV6_SERVER_TICKS_PER_SECOND ) , TX_NO_ACTIVATE ) ; NX_TIMER_EXTENSION_PTR_SET ( & ( dhcpv6_server_ptr -> nx_dhcpv6_lease_timer ) , dhcpv6_server_ptr ) if ( status != NX_SUCCESS ) { tx_thread_delete ( & ( dhcpv6_server_ptr -> nx_dhcpv6_server_thread ) ) ; tx_mutex_delete ( & ( dhcpv6_server_ptr -> nx_dhcpv6_server_mutex ) ) ; tx_event_flags_delete ( & dhcpv6_server_ptr -> nx_dhcpv6_server_timer_events ) ; } status = tx_timer_create ( & ( dhcpv6_server_ptr -> nx_dhcpv6_session_timer ) , " " , _nx_dhcpv6_server_session_timeout_entry , ( ULONG ) ( ALIGN_TYPE ) dhcpv6_server_ptr , ( NX_DHCPV6_SESSION_TIMER_INTERVAL * NX_DHCPV6_SERVER_TICKS_PER_SECOND ) , ( NX_DHCPV6_SESSION_TIMER_INTERVAL * NX_DHCPV6_SERVER_TICKS_PER_SECOND ) , TX_NO_ACTIVATE ) ; NX_TIMER_EXTENSION_PTR_SET ( & ( dhcpv6_server_ptr -> nx_dhcpv6_session_timer ) , dhcpv6_server_ptr ) if ( status != NX_SUCCESS ) { tx_timer_delete ( & ( dhcpv6_server_ptr -> nx_dhcpv6_lease_timer ) ) ; tx_thread_delete ( & ( dhcpv6_server_ptr -> nx_dhcpv6_server_thread ) ) ; tx_mutex_delete ( & ( dhcpv6_server_ptr -> nx_dhcpv6_server_mutex ) ) ; tx_event_flags_delete ( & dhcpv6_server_ptr -> nx_dhcpv6_server_timer_events ) ; } for ( i = 0 ; i < NX_DHCPV6_MAX_CLIENTS ; i ++ ) { dhcpv6_client_ptr = & dhcpv6_server_ptr -> nx_dhcpv6_clients [ i ] ; memset ( dhcpv6_client_ptr , 0 , sizeof ( NX_DHCPV6_CLIENT ) ) ; } if ( status ) { tx_timer_delete ( & ( dhcpv6_server_ptr -> nx_dhcpv6_lease_timer ) ) ; tx_timer_delete ( & ( dhcpv6_server_ptr -> nx_dhcpv6_session_timer ) ) ; tx_thread_delete ( & ( dhcpv6_server_ptr -> nx_dhcpv6_server_thread ) ) ; tx_mutex_delete ( & ( dhcpv6_server_ptr -> nx_dhcpv6_server_mutex ) ) ; tx_event_flags_delete ( & dhcpv6_server_ptr -> nx_dhcpv6_server_timer_events ) ; return status ; } dhcpv6_server_ptr -> nx_dhcpv6_server_socket . nx_udp_socket_reserved_ptr = ( void * ) dhcpv6_server_ptr ; dhcpv6_server_ptr -> nx_dhcpv6_id = NX_DHCPV6_SERVER_ID ; dhcpv6_server_ptr -> nx_dhcpv6_server_multicast_only = NX_TRUE ; dhcpv6_server_ptr -> nx_dhcpv6_IP_address_declined_handler = dhcpv6_address_declined_handler ; dhcpv6_server_ptr -> nx_dhcpv6_server_option_request_handler = dhcpv6_option_request_handler ; return ( NX_SUCCESS ) ; }
FUNCTION                                               RELEASE
FUNCTION RELEASE
/* Initialize the DHCPV6 control block to zero.  */ /* Default the server global index to index 1. If otherwise, the host
       application must set the DHCPv6 interface before it can start
       the Server (nx_dhcpv6_server_interface_set). */ /* Link the DHCPv6 server with the IP instance. */ /* Set the DHCPV6 name.  */ /* Set the server packet pool. */ /* Create the IP timer event flag instance.  */ /* Check for error. */ /* Create the DHCPV6 mutex for the Server instance.  */ /* Determine if the mutexes creation was successful.  */ /* Delete the flag queue.  */ /* No, return error status.  */ /* Create the DHCPV6 processing thread. */ /* Determine if the thread creation was successful. */ /* Delete the server protection mutex.  */ /* Delete the flag queue.  */ /* No, return error status.  */ /* Create the DHCPV6 timer for keeping track of IP lease time expiration.  */ /* Delete the DHCPv6 Server thread. */ /* Delete the server protection mutex.  */ /* Delete the flag queue.  */ /* Create the DHCPV6 timer for keeping track of the DHCPv6 Client session time.  */ /* Delete the server lease timer. */ /* Delete the DHCPv6 Server thread. */ /* Delete the server protection mutex.  */ /* Delete the flag queue.  */ /*  Initialize the DHCPv6 client control blocks */ /* Set a local pointer for convenience. */ /* Clear the client record. */ /* Determine if the timers creation were successful.  */ /* Delete the server lease timer. */ /* Delete the server serssion timer. */ /* Delete the DHCPv6 Server thread. */ /* Delete the server protection mutex.  */ /* Delete the flag queue.  */ /* Return error status. */ /* Save the DHCPV6 instance pointer in the socket. */ /* Set the DHCPv6 Client ID.  */ /* Set the server preference for clients using multicast only for all request message types.  */ /* Assign the various handlers (server error messages, state change and expired/deprecated addresses). */ /* Return a successful status.  */