Change IP address at runtime

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

Change IP address at runtime

944 Views
angeloborghi
Contributor I

Hi,
I have a board with mpc8309 processor, MQX V3.8.0 and I use CW power pc windows classic  8.80.

At the program startup I initilize the three fec with this sequence:

1) ENET_get_mac_address(device, newMac, mac);
2) result = ipcfg_init_device(device, mac);
3) ipcfg_bind_staticip(device, &ip_data);

And it works.

If I try to reassign a new IP address a runtime to a one of three fec it doesn't work. In particulary:

4) I call the function ipcfg_bind_staticip(device, &ip_data) with a new IP
5) the function exit with no errors
6) but the new IP doesn't work

How can I do to change IP at Runtime?

Labels (1)
0 Kudos
5 Replies

557 Views
RadekS
NXP Employee
NXP Employee

I didn’t found any documented issue according your description, but you version of MQX is quite old.

IPCFG layer could keep maximum one IP address.

If 1 IP address is fine for you, please try unbinding first address by ipcfg_unbind() function and after that bind new ip address by ipcfg_bind_staticip() function.

If you need more than one IP address for your interface, please use functions RTCS_if_bind() instead of ipcfg_bind.

I hope it helps.
Have a great day,
RadekS

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

0 Kudos

557 Views
angeloborghi
Contributor I

Thanks.

I need only one IP for each ethernet. I also use the ipcfg_unbind() function before ipcfg_bind_staticip() but the result doesn't change. To use the new IP I must restart the board.

0 Kudos

557 Views
RadekS
NXP Employee
NXP Employee

Thank you for additional information.

In that case it looks like some bug in MQX 3.8.0

In attachment you can find ipcfg.c file from MQX v 4.0.2.2 with small modification at line 808 (just added brackets). I checked that content of this file is almost identical to current version. However since MQX 4.1 we use different types and it is not necessary confuse you by this change.

Please compare attached file with your version …

0 Kudos

557 Views
angeloborghi
Contributor I

I compared the 2 version of "ipcfg.c" and apply the modification at line 808. I also verify that "ipcfg_bind_autoip_internal_actual" is never called.

I put the call to the function "ipcfg_unbind" before "ipcfg_bind_staticip" but it doesn't work.

I copy in our "ipcfg.c" file the "ipcfg_release_device", "ipcfg_release_interface" and "ipcfg_del_interface" functions from your file. After that, I put the next code before to call "ipcfg_unbind" to change IP at Runtime.

 

Step 1)

  if(ipcfg_release_device(device) != RTCS_OK)

  {

   return;

  }   // OK it work

Step 2)

ENET_get_mac_address(device, newMac, mac);

result = ipcfg_init_device(device, mac);   // KO

The step 2 failed in "ipcfg_init_interface" on call to:

if (_lwsem_create (&ipcfg_data[device].control_semaphore, 1) != MQX_OK)
{
    return RTCSERR_IPCFG_INIT;
}

and the program end to breakpoint on "_int_unexpected_isr" function.

0 Kudos

557 Views
Luis_Garabo
NXP TechSupport
NXP TechSupport

Hi Angelo,

I think you need to restart the TCPIP task. There are some variables that are not resetting or so. Kill your TCPIP task and then run again your networking initialization code.

Have a great day,
Garabo

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

0 Kudos