AzureMXChip/MXCHIPAZ3166/core/lib/netxduo/addons/dhcp/nxd_dhcpv6_server.c
UINT _nxe_dhcpv6_add_client_record(NX_DHCPV6_SERVER *dhcpv6_server_ptr, UINT table_index, ULONG message_xid, NXD_ADDRESS *client_address, UINT client_state, 
                                  ULONG IP_lease_time_accrued, ULONG valid_lifetime, UINT duid_type, UINT duid_hardware, ULONG physical_address_msw, 
                                  ULONG physical_address_lsw, ULONG duid_time, ULONG duid_vendor_number, UCHAR *duid_vendor_private, UINT duid_private_length)
{

UINT status;

    /* Check for invalid pointer input. */
    if ((dhcpv6_server_ptr == NX_NULL) || (client_address == NX_NULL))
    {

        return NX_PTR_ERROR;
    }

    /* Check for missing transaction ID or DUID type. */
    if ((message_xid == 0) || (duid_type == 0))
    {
        return NX_INVALID_PARAMETERS;
    }

    /* Check for missing time expired on the lease (if client in a bound state). */
    if ((IP_lease_time_accrued == 0) && (client_state == NX_DHCPV6_STATE_BOUND))
    {
        return NX_INVALID_PARAMETERS;
    }

    /* Check for invalid enterprise DUID data if type is enterprise. */
    if (duid_type == NX_DHCPV6_SERVER_DUID_TYPE_VENDOR_ASSIGNED)
    {

        if ((duid_private_length == 0) || (duid_vendor_private == NX_NULL))
        {

            return NX_INVALID_PARAMETERS;
        }
    }
    /* Check for invalid LINK LAYER duid data. */
    else if ((duid_type == NX_DHCPV6_SERVER_DUID_TYPE_LINK_TIME) || (duid_type == NX_DHCPV6_SERVER_DUID_TYPE_LINK_ONLY))
    {

        if ((physical_address_msw == 0) && (physical_address_lsw == 0))
        {
            return NX_INVALID_PARAMETERS;
        }

        if ((duid_type == NX_DHCPV6_SERVER_DUID_TYPE_LINK_TIME) && (duid_time == 0))
        {
            return NX_INVALID_PARAMETERS;
        }
    }

    /* Call the actual service and return completion status. */
    status =  _nx_dhcpv6_add_client_record(dhcpv6_server_ptr, table_index, message_xid, client_address, client_state, 
                                           IP_lease_time_accrued, valid_lifetime, duid_type, duid_hardware, physical_address_msw, physical_address_lsw, 
                                           duid_time, duid_vendor_number, duid_vendor_private, duid_private_length);
    return status;
}
/**************************************************************************/
/*                                                                        */
/*  FUNCTION                                               RELEASE        */
/*                                                                        */
/*    _nxe_dhcpv6_add_client_record                       PORTABLE C      */
/*                                                           6.1          */
/*  AUTHOR                                                                */
/*                                                                        */
/*    Yuxin Zhou, Microsoft Corporation                                   */
/*                                                                        */
/*  DESCRIPTION                                                           */
/*                                                                        */
/*   This function performs error checking for the copy client data       */
/*   service.                                                             */
/*                                                                        */
/*  INPUT                                                                 */
/*                                                                        */
/*    dhcpv6_server_ptr                  Pointer to DHCPv6 server         */
/*    table_index                        Table index to store client data */
/*    message_xid                        Client transaction ID            */
/*    client_address                     IP address leased to client      */
/*    client_state                       Client DHCPv6 state e.g. bound   */
/*    IP_lease_time_accrued              Time expired on current IP lease */
/*    valid_lifetime                     When address becomes invalid     */
/*    duid_type                          Type of Client DUID              */
/*    duid_hardware                      DUID hardware (usually ethernet) */
/*    physical_address_msw               MSB of client mac address        */
/*    physical_address_lsw               LSB of client mac address        */
/*    duid_time                          Time for link layer time DUID    */
/*    duid_vendor_number                 Enterprise ID for Vendor DUID    */
/*    duid_vendor_private                Pointer to private ID for DUID   */
/*    duid_private_length                Vendor Duid private ID length    */
/*                                                                        */
/*  OUTPUT                                                                */
/*                                                                        */
/*    NX_SUCCESS                         Successful IP address copy       */
/*    NX_DHCPV6_PARAM_ERROR              Invalid non pointer input        */
/*    NX_DHCPV6_TABLE_FULL               No empty slot for client data    */
/*                                                                        */
/*  CALLS                                                                 */
/*                                                                        */
/*    _nx_dhcpv6_add_client_record       Actual copy client data service  */
/*                                                                        */
/*  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

_nxe_dhcpv6_add_client_record                       PORTABLE C
6.1
AUTHOR

Yuxin Zhou, Microsoft Corporation

DESCRIPTION

This function performs error checking for the copy client data
service.

INPUT

dhcpv6_server_ptr                  Pointer to DHCPv6 server
table_index                        Table index to store client data
message_xid                        Client transaction ID
client_address                     IP address leased to client
client_state                       Client DHCPv6 state e.g. bound
IP_lease_time_accrued              Time expired on current IP lease
valid_lifetime                     When address becomes invalid
duid_type                          Type of Client DUID
duid_hardware                      DUID hardware (usually ethernet)
physical_address_msw               MSB of client mac address
physical_address_lsw               LSB of client mac address
duid_time                          Time for link layer time DUID
duid_vendor_number                 Enterprise ID for Vendor DUID
duid_vendor_private                Pointer to private ID for DUID
duid_private_length                Vendor Duid private ID length

OUTPUT

NX_SUCCESS                         Successful IP address copy
NX_DHCPV6_PARAM_ERROR              Invalid non pointer input
NX_DHCPV6_TABLE_FULL               No empty slot for client data

CALLS

_nx_dhcpv6_add_client_record       Actual copy client data service

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 _nxe_dhcpv6_add_client_record PORTABLE C 6 . 1 AUTHOR Yuxin Zhou Microsoft Corporation DESCRIPTION This function performs error checking for the copy client data service . INPUT dhcpv6_server_ptr Pointer to DHCPv6 server table_index Table index to store client data message_xid Client transaction ID client_address IP address leased to client client_state Client DHCPv6 state e . g . bound IP_lease_time_accrued Time expired on current IP lease valid_lifetime When address becomes invalid duid_type Type of Client DUID duid_hardware DUID hardware ( usually ethernet ) physical_address_msw MSB of client mac address physical_address_lsw LSB of client mac address duid_time Time for link layer time DUID duid_vendor_number Enterprise ID for Vendor DUID duid_vendor_private Pointer to private ID for DUID duid_private_length Vendor Duid private ID length OUTPUT NX_SUCCESS Successful IP address copy NX_DHCPV6_PARAM_ERROR Invalid non pointer input NX_DHCPV6_TABLE_FULL No empty slot for client data CALLS _nx_dhcpv6_add_client_record Actual copy client data service 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 _nxe_dhcpv6_add_client_record(NX_DHCPV6_SERVER *dhcpv6_server_ptr, UINT table_index, ULONG message_xid, NXD_ADDRESS *client_address, UINT client_state, 
                                  ULONG IP_lease_time_accrued, ULONG valid_lifetime, UINT duid_type, UINT duid_hardware, ULONG physical_address_msw, 
                                  ULONG physical_address_lsw, ULONG duid_time, ULONG duid_vendor_number, UCHAR *duid_vendor_private, UINT duid_private_length)
{
UINT status;
    if ((dhcpv6_server_ptr == NX_NULL) || (client_address == NX_NULL))
    {
        return NX_PTR_ERROR;
    }
    if ((message_xid == 0) || (duid_type == 0))
    {
        return NX_INVALID_PARAMETERS;
    }
    if ((IP_lease_time_accrued == 0) && (client_state == NX_DHCPV6_STATE_BOUND))
    {
        return NX_INVALID_PARAMETERS;
    }
    if (duid_type == NX_DHCPV6_SERVER_DUID_TYPE_VENDOR_ASSIGNED)
    {
        if ((duid_private_length == 0) || (duid_vendor_private == NX_NULL))
        {
            return NX_INVALID_PARAMETERS;
        }
    }
    else if ((duid_type == NX_DHCPV6_SERVER_DUID_TYPE_LINK_TIME) || (duid_type == NX_DHCPV6_SERVER_DUID_TYPE_LINK_ONLY))
    {
        if ((physical_address_msw == 0) && (physical_address_lsw == 0))
        {
            return NX_INVALID_PARAMETERS;
        }
        if ((duid_type == NX_DHCPV6_SERVER_DUID_TYPE_LINK_TIME) && (duid_time == 0))
        {
            return NX_INVALID_PARAMETERS;
        }
    }
    status =  _nx_dhcpv6_add_client_record(dhcpv6_server_ptr, table_index, message_xid, client_address, client_state, 
                                           IP_lease_time_accrued, valid_lifetime, duid_type, duid_hardware, physical_address_msw, physical_address_lsw, 
                                           duid_time, duid_vendor_number, duid_vendor_private, duid_private_length);
    return status;
}
UINT _nxe_dhcpv6_add_client_record ( NX_DHCPV6_SERVER * dhcpv6_server_ptr , UINT table_index , ULONG message_xid , NXD_ADDRESS * client_address , UINT client_state , ULONG IP_lease_time_accrued , ULONG valid_lifetime , UINT duid_type , UINT duid_hardware , ULONG physical_address_msw , ULONG physical_address_lsw , ULONG duid_time , ULONG duid_vendor_number , UCHAR * duid_vendor_private , UINT duid_private_length ) { UINT status ; if ( ( dhcpv6_server_ptr == NX_NULL ) || ( client_address == NX_NULL ) ) { return NX_PTR_ERROR ; } if ( ( message_xid == 0 ) || ( duid_type == 0 ) ) { return NX_INVALID_PARAMETERS ; } if ( ( IP_lease_time_accrued == 0 ) && ( client_state == NX_DHCPV6_STATE_BOUND ) ) { return NX_INVALID_PARAMETERS ; } if ( duid_type == NX_DHCPV6_SERVER_DUID_TYPE_VENDOR_ASSIGNED ) { if ( ( duid_private_length == 0 ) || ( duid_vendor_private == NX_NULL ) ) { return NX_INVALID_PARAMETERS ; } } else if ( ( duid_type == NX_DHCPV6_SERVER_DUID_TYPE_LINK_TIME ) || ( duid_type == NX_DHCPV6_SERVER_DUID_TYPE_LINK_ONLY ) ) { if ( ( physical_address_msw == 0 ) && ( physical_address_lsw == 0 ) ) { return NX_INVALID_PARAMETERS ; } if ( ( duid_type == NX_DHCPV6_SERVER_DUID_TYPE_LINK_TIME ) && ( duid_time == 0 ) ) { return NX_INVALID_PARAMETERS ; } } status = _nx_dhcpv6_add_client_record ( dhcpv6_server_ptr , table_index , message_xid , client_address , client_state , IP_lease_time_accrued , valid_lifetime , duid_type , duid_hardware , physical_address_msw , physical_address_lsw , duid_time , duid_vendor_number , duid_vendor_private , duid_private_length ) ; return status ; }
FUNCTION                                               RELEASE
FUNCTION RELEASE
/* Check for invalid pointer input. */ /* Check for missing transaction ID or DUID type. */ /* Check for missing time expired on the lease (if client in a bound state). */ /* Check for invalid enterprise DUID data if type is enterprise. */ /* Check for invalid LINK LAYER duid data. */ /* Call the actual service and return completion status. */