features/nanostack/sal-stack-nanostack/source/DHCPv6_client/dhcpv6_client_service.c
int dhcp_solicit_resp_cb(uint16_t instance_id, void *ptr, uint8_t msg_name,  uint8_t *msg_ptr, uint16_t msg_len)
{
    dhcp_ia_non_temporal_params_t dhcp_ia_non_temporal_params;
    dhcp_link_options_params_t clientId;
    dhcp_link_options_params_t serverId;
    dhcp_link_options_params_t interfaceId;
    dhcpv6_client_server_data_t *srv_data_ptr = NULL;
    (void)instance_id;

    srv_data_ptr = ptr;

    if (srv_data_ptr == NULL) {
        tr_error("server data not found");
        goto error_exit;
    }

    // Validate message
    if (msg_name != DHCPV6_REPLY_TYPE) {
        tr_error("invalid response");
        goto error_exit;
    }

    if (libdhcpv6_reply_message_option_validate(&clientId, &serverId, &dhcp_ia_non_temporal_params, msg_ptr, msg_len) != 0) {
        tr_error("Sol Not include all Options");
        goto error_exit;
    }

    if (libdhcpv6_nonTemporal_entry_get_by_iaid(dhcp_ia_non_temporal_params.iaId) != srv_data_ptr) {
        /* Validate server data availability */
        tr_error("Valid instance not found");
        goto error_exit;
    }

    if (srv_data_ptr->IAID != dhcp_ia_non_temporal_params.iaId) {
        tr_error("Wrong IAID");
        goto error_exit;
    }

    interfaceId.linkID = srv_data_ptr->clientId;
    interfaceId.linkType = srv_data_ptr->clientLinkIdType;
    if (libdhcpv6_compare_DUID(&interfaceId, &clientId) != 0) {
        tr_error("Not Valid Client Id");
        goto error_exit;
    }

    memcpy(srv_data_ptr->iaNontemporalAddress.addressPrefix, dhcp_ia_non_temporal_params.nonTemporalAddress, 16);
    srv_data_ptr->iaNontemporalAddress.preferredTime = dhcp_ia_non_temporal_params.preferredValidLifeTime;
    srv_data_ptr->iaNontemporalAddress.validLifetime = dhcp_ia_non_temporal_params.validLifeTime;
    memcpy(srv_data_ptr->serverLinkId, serverId.linkID, 8);
    srv_data_ptr->serverLinkType = serverId.linkType;
    srv_data_ptr->T0 = dhcp_ia_non_temporal_params.T0;
    srv_data_ptr->T1  = dhcp_ia_non_temporal_params.T1;
    srv_data_ptr->iaNonTemporalStructValid = true;

    dhcpv6_client_set_address(dhcp_client.interface, srv_data_ptr);


    if (dhcp_client.global_address_cb) {
        dhcp_client.global_address_cb(dhcp_client.interface, srv_data_ptr->server_address, srv_data_ptr->iaNontemporalAddress.addressPrefix, true);
    }
    return RET_MSG_ACCEPTED;
error_exit:
    dhcpv6_client_send_error_cb(srv_data_ptr);
    return RET_MSG_ACCEPTED;
}
/* solication responce received for either global address or routter id assignment */
solication responce received for either global address or routter id assignment
solication responce received for either global address or routter id assignment
int dhcp_solicit_resp_cb(uint16_t instance_id, void *ptr, uint8_t msg_name,  uint8_t *msg_ptr, uint16_t msg_len)
{
    dhcp_ia_non_temporal_params_t dhcp_ia_non_temporal_params;
    dhcp_link_options_params_t clientId;
    dhcp_link_options_params_t serverId;
    dhcp_link_options_params_t interfaceId;
    dhcpv6_client_server_data_t *srv_data_ptr = NULL;
    (void)instance_id;
    srv_data_ptr = ptr;
    if (srv_data_ptr == NULL) {
        tr_error("server data not found");
        goto error_exit;
    }
    if (msg_name != DHCPV6_REPLY_TYPE) {
        tr_error("invalid response");
        goto error_exit;
    }
    if (libdhcpv6_reply_message_option_validate(&clientId, &serverId, &dhcp_ia_non_temporal_params, msg_ptr, msg_len) != 0) {
        tr_error("Sol Not include all Options");
        goto error_exit;
    }
    if (libdhcpv6_nonTemporal_entry_get_by_iaid(dhcp_ia_non_temporal_params.iaId) != srv_data_ptr) {
        tr_error("Valid instance not found");
        goto error_exit;
    }
    if (srv_data_ptr->IAID != dhcp_ia_non_temporal_params.iaId) {
        tr_error("Wrong IAID");
        goto error_exit;
    }
    interfaceId.linkID = srv_data_ptr->clientId;
    interfaceId.linkType = srv_data_ptr->clientLinkIdType;
    if (libdhcpv6_compare_DUID(&interfaceId, &clientId) != 0) {
        tr_error("Not Valid Client Id");
        goto error_exit;
    }
    memcpy(srv_data_ptr->iaNontemporalAddress.addressPrefix, dhcp_ia_non_temporal_params.nonTemporalAddress, 16);
    srv_data_ptr->iaNontemporalAddress.preferredTime = dhcp_ia_non_temporal_params.preferredValidLifeTime;
    srv_data_ptr->iaNontemporalAddress.validLifetime = dhcp_ia_non_temporal_params.validLifeTime;
    memcpy(srv_data_ptr->serverLinkId, serverId.linkID, 8);
    srv_data_ptr->serverLinkType = serverId.linkType;
    srv_data_ptr->T0 = dhcp_ia_non_temporal_params.T0;
    srv_data_ptr->T1  = dhcp_ia_non_temporal_params.T1;
    srv_data_ptr->iaNonTemporalStructValid = true;
    dhcpv6_client_set_address(dhcp_client.interface, srv_data_ptr);
    if (dhcp_client.global_address_cb) {
        dhcp_client.global_address_cb(dhcp_client.interface, srv_data_ptr->server_address, srv_data_ptr->iaNontemporalAddress.addressPrefix, true);
    }
    return RET_MSG_ACCEPTED;
error_exit:
    dhcpv6_client_send_error_cb(srv_data_ptr);
    return RET_MSG_ACCEPTED;
}
int dhcp_solicit_resp_cb ( uint16_t instance_id , void * ptr , uint8_t msg_name , uint8_t * msg_ptr , uint16_t msg_len ) { dhcp_ia_non_temporal_params_t dhcp_ia_non_temporal_params ; dhcp_link_options_params_t clientId ; dhcp_link_options_params_t serverId ; dhcp_link_options_params_t interfaceId ; dhcpv6_client_server_data_t * srv_data_ptr = NULL ; ( void ) instance_id ; srv_data_ptr = ptr ; if ( srv_data_ptr == NULL ) { tr_error ( " " ) ; goto error_exit ; } if ( msg_name != DHCPV6_REPLY_TYPE ) { tr_error ( " " ) ; goto error_exit ; } if ( libdhcpv6_reply_message_option_validate ( & clientId , & serverId , & dhcp_ia_non_temporal_params , msg_ptr , msg_len ) != 0 ) { tr_error ( " " ) ; goto error_exit ; } if ( libdhcpv6_nonTemporal_entry_get_by_iaid ( dhcp_ia_non_temporal_params . iaId ) != srv_data_ptr ) { tr_error ( " " ) ; goto error_exit ; } if ( srv_data_ptr -> IAID != dhcp_ia_non_temporal_params . iaId ) { tr_error ( " " ) ; goto error_exit ; } interfaceId . linkID = srv_data_ptr -> clientId ; interfaceId . linkType = srv_data_ptr -> clientLinkIdType ; if ( libdhcpv6_compare_DUID ( & interfaceId , & clientId ) != 0 ) { tr_error ( " " ) ; goto error_exit ; } memcpy ( srv_data_ptr -> iaNontemporalAddress . addressPrefix , dhcp_ia_non_temporal_params . nonTemporalAddress , 16 ) ; srv_data_ptr -> iaNontemporalAddress . preferredTime = dhcp_ia_non_temporal_params . preferredValidLifeTime ; srv_data_ptr -> iaNontemporalAddress . validLifetime = dhcp_ia_non_temporal_params . validLifeTime ; memcpy ( srv_data_ptr -> serverLinkId , serverId . linkID , 8 ) ; srv_data_ptr -> serverLinkType = serverId . linkType ; srv_data_ptr -> T0 = dhcp_ia_non_temporal_params . T0 ; srv_data_ptr -> T1 = dhcp_ia_non_temporal_params . T1 ; srv_data_ptr -> iaNonTemporalStructValid = true ; dhcpv6_client_set_address ( dhcp_client . interface , srv_data_ptr ) ; if ( dhcp_client . global_address_cb ) { dhcp_client . global_address_cb ( dhcp_client . interface , srv_data_ptr -> server_address , srv_data_ptr -> iaNontemporalAddress . addressPrefix , true ) ; } return RET_MSG_ACCEPTED ; error_exit : dhcpv6_client_send_error_cb ( srv_data_ptr ) ; return RET_MSG_ACCEPTED ; }
solication responce received for either global address or routter id assignment
solication responce received for either global address or routter id assignment
// Validate message /* Validate server data availability */