How to read active ethernet configuration in MQX 3.8?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to read active ethernet configuration in MQX 3.8?

892 Views
namile
Contributor II

How can i read following information for an active ethernet device?

- IP Address, Netmask, Gateway, DNS server that are configured in the stack. This configuration can be static or dynamic(DHCP) assigned.

6 Replies

635 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi

You can try the high level network interface management API:  ipcfg_get_ip, it returns ip mask and gateway.

Please refer to MQX_RTCS_User_Guide.pdf

Have a great day,
Daniel

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

635 Views
namile
Contributor II

Looks like this function works only for DHCP not for static configuration.

0 Kudos

635 Views
Luis_Garabo
NXP TechSupport
NXP TechSupport

Hi Rajesh,

When the DHCP is used the gateway and DNS data is fulfilled automatically. If are using a fix IP then you need to set those values with the functions ipcfg_add_dns_ip() and RTCS_gate_add(). Then the function ipcfg_get_ip() will be able to return all that. The function ipcfg_task_create() is used to know if the Ethernet link is active.

Regards,

-Garabo

0 Kudos

635 Views
namile
Contributor II

Thank you. Garabo. Did not work for me with static info.

Here is what the function looks like(in ipcfg.c source file).

/*FUNCTION*--------------------------------------------------------------
*
* Function Name  : ipcfg_get_ip()
* Returned Value : TRUE and IP, mask and gateway, if successful
* Comments       : Returns actual ip information from DHCP response, if any.  <<=====
*
*END--------------------------------------------------------------------*/

boolean ipcfg_get_ip
    (
        uint_32                     device,
        IPCFG_IP_ADDRESS_DATA_PTR   data
    )
{
    if (device < IPCFG_DEVICE_COUNT)
    {
        if (ipcfg_data[device].actual_state != IPCFG_STATE_INIT)
        {
            *data = ipcfg_data[device].actual_ip_data;
            return TRUE;
        }
    }
    return FALSE;
}

0 Kudos

635 Views
Luis_Garabo
NXP TechSupport
NXP TechSupport

Hi Rajesh,

Try the example code I am attaching here. Code is in httpdsrv.c. It is working as explained before.


Regards,
Garabo

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

635 Views
namile
Contributor II

Thank you Garabo.

0 Kudos