AzureMXChip/MXCHIPAZ3166/core/lib/netxduo/addons/dhcp/nxd_dhcpv6_server.c
UINT _nx_dhcpv6_retrieve_ip_address_lease(NX_DHCPV6_SERVER *dhcpv6_server_ptr, UINT table_index, NXD_ADDRESS *lease_IP_address, 
                                       ULONG *T1, ULONG *T2, ULONG *valid_lifetime, ULONG *preferred_lifetime)
{

NX_DHCPV6_ADDRESS_LEASE *lease_ptr;


    /* Check for valid table index. */
    if (table_index >= NX_DHCPV6_MAX_LEASES)
    {

        /* No good. Exceeds the size of the table. */
        return NX_DHCPV6_PARAM_ERROR;
    }

    /* Get a local pointer for convenience. */
    lease_ptr = &(dhcpv6_server_ptr -> nx_dhcpv6_lease_list[table_index]);

    /* Copy the lease data into the input pointer buffers.  */
    COPY_NXD_ADDRESS(&(lease_ptr -> nx_dhcpv6_lease_IP_address), lease_IP_address);
    *T1 = lease_ptr -> nx_dhcpv6_lease_T1_lifetime;                     
    *T2 = lease_ptr -> nx_dhcpv6_lease_T2_lifetime;                     
    *valid_lifetime = lease_ptr -> nx_dhcpv6_lease_valid_lifetime;              
    *preferred_lifetime = lease_ptr -> nx_dhcpv6_lease_preferred_lifetime;   

    return NX_SUCCESS;
}
/**************************************************************************/
/*                                                                        */
/*  FUNCTION                                               RELEASE        */
/*                                                                        */
/*    _nx_dhcpv6_retrieve_ip_address_lease                PORTABLE C      */
/*                                                           6.1          */
/*  AUTHOR                                                                */
/*                                                                        */
/*    Yuxin Zhou, Microsoft Corporation                                   */
/*                                                                        */
/*  DESCRIPTION                                                           */
/*                                                                        */
/*   This function retrieves lease data from the Server IP lease table.   */
/*   The caller must specify which slot with a index value up to the size */
/*   of the lease table, (NX_DHCPV6_MAX_LEASES - 1).                      */
/*                                                                        */
/*   This is intended to satisfy the DHCPv6 protocol requirement that a   */
/*   DHPCv6 Server be able to store and retrieve lease data from          */
/*   nonvolatile memory e..g between reboots.                             */
/*                                                                        */
/*  INPUT                                                                 */
/*                                                                        */
/*    dhcpv6_server_ptr                  Pointer to DHCPv6 server         */
/*    table_index                        Table index to obtain data       */
/*    lease_IP_address                   Lease IP address                 */
/*    T1                                 T1 lifetime (when to renew)      */
/*    T2                                 T2 lifetime (when to rebind)     */
/*    preferred_lifetime                 When address becomes deprecated  */
/*    valid_lifetime                     When address becomes invalid     */
/*                                                                        */
/*  OUTPUT                                                                */
/*                                                                        */
/*    NX_SUCCESS                         Successful IP address copy       */
/*    NX_DHCPV6_PARAM_ERROR              Invalid table index              */
/*                                                                        */
/*  CALLS                                                                 */
/*                                                                        */
/*    None                                                                */
/*                                                                        */
/*  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_retrieve_ip_address_lease                PORTABLE C
6.1
AUTHOR

Yuxin Zhou, Microsoft Corporation

DESCRIPTION

This function retrieves lease data from the Server IP lease table.
The caller must specify which slot with a index value up to the size
of the lease table, (NX_DHCPV6_MAX_LEASES - 1).

This is intended to satisfy the DHCPv6 protocol requirement that a
DHPCv6 Server be able to store and retrieve lease data from
nonvolatile memory e..g between reboots.

INPUT

dhcpv6_server_ptr                  Pointer to DHCPv6 server
table_index                        Table index to obtain data
lease_IP_address                   Lease IP address
T1                                 T1 lifetime (when to renew)
T2                                 T2 lifetime (when to rebind)
preferred_lifetime                 When address becomes deprecated
valid_lifetime                     When address becomes invalid

OUTPUT

NX_SUCCESS                         Successful IP address copy
NX_DHCPV6_PARAM_ERROR              Invalid table index

CALLS

None

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_retrieve_ip_address_lease PORTABLE C 6 . 1 AUTHOR Yuxin Zhou Microsoft Corporation DESCRIPTION This function retrieves lease data from the Server IP lease table . The caller must specify which slot with a index value up to the size of the lease table ( NX_DHCPV6_MAX_LEASES - 1 ) . This is intended to satisfy the DHCPv6 protocol requirement that a DHPCv6 Server be able to store and retrieve lease data from nonvolatile memory e .. g between reboots . INPUT dhcpv6_server_ptr Pointer to DHCPv6 server table_index Table index to obtain data lease_IP_address Lease IP address T1 T1 lifetime ( when to renew ) T2 T2 lifetime ( when to rebind ) preferred_lifetime When address becomes deprecated valid_lifetime When address becomes invalid OUTPUT NX_SUCCESS Successful IP address copy NX_DHCPV6_PARAM_ERROR Invalid table index CALLS None 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_retrieve_ip_address_lease(NX_DHCPV6_SERVER *dhcpv6_server_ptr, UINT table_index, NXD_ADDRESS *lease_IP_address, 
                                       ULONG *T1, ULONG *T2, ULONG *valid_lifetime, ULONG *preferred_lifetime)
{
NX_DHCPV6_ADDRESS_LEASE *lease_ptr;
    if (table_index >= NX_DHCPV6_MAX_LEASES)
    {
        return NX_DHCPV6_PARAM_ERROR;
    }
    lease_ptr = &(dhcpv6_server_ptr -> nx_dhcpv6_lease_list[table_index]);
    COPY_NXD_ADDRESS(&(lease_ptr -> nx_dhcpv6_lease_IP_address), lease_IP_address);
    *T1 = lease_ptr -> nx_dhcpv6_lease_T1_lifetime;                     
    *T2 = lease_ptr -> nx_dhcpv6_lease_T2_lifetime;                     
    *valid_lifetime = lease_ptr -> nx_dhcpv6_lease_valid_lifetime;              
    *preferred_lifetime = lease_ptr -> nx_dhcpv6_lease_preferred_lifetime;   
    return NX_SUCCESS;
}
UINT _nx_dhcpv6_retrieve_ip_address_lease ( NX_DHCPV6_SERVER * dhcpv6_server_ptr , UINT table_index , NXD_ADDRESS * lease_IP_address , ULONG * T1 , ULONG * T2 , ULONG * valid_lifetime , ULONG * preferred_lifetime ) { NX_DHCPV6_ADDRESS_LEASE * lease_ptr ; if ( table_index >= NX_DHCPV6_MAX_LEASES ) { return NX_DHCPV6_PARAM_ERROR ; } lease_ptr = & ( dhcpv6_server_ptr -> nx_dhcpv6_lease_list [ table_index ] ) ; COPY_NXD_ADDRESS ( & ( lease_ptr -> nx_dhcpv6_lease_IP_address ) , lease_IP_address ) ; * T1 = lease_ptr -> nx_dhcpv6_lease_T1_lifetime ; * T2 = lease_ptr -> nx_dhcpv6_lease_T2_lifetime ; * valid_lifetime = lease_ptr -> nx_dhcpv6_lease_valid_lifetime ; * preferred_lifetime = lease_ptr -> nx_dhcpv6_lease_preferred_lifetime ; return NX_SUCCESS ; }
FUNCTION                                               RELEASE
FUNCTION RELEASE
/* Check for valid table index. */ /* No good. Exceeds the size of the table. */ /* Get a local pointer for convenience. */ /* Copy the lease data into the input pointer buffers.  */