Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
1,655 Views

NicheStack - changing IP address without rebooting

Hi, 

 

is there a way of changing IP address of the Nios2 without rebooting the whole Nios? 

Looking through the sources of iniche I can see there is only a alt_iniche_init() procedure, but nothing for shutting it down or re-starting it...  

 

So far I have tried something like 

 

tse_mac_close(0); delete_network_tasks(); netmain(); create_network_tasks();  

 

but instead of closing and reopening the same interface, it "discovers" a 2nd interface  

 

.................................... prep_tse_mac 0 Your Ethernet MAC address is 00:07:35:04:b2:77 Static IP Address is 172.16.100.81 prepped 1 interface, initializing... .................................... iniche restart triggered... Deleting network tasks...DONE InterNiche Portable TCP/IP, v3.1 Copyright 1996-2008 by InterNiche Technologies. All rights reserved. prep_tse_mac 1 Your Ethernet MAC address is 00:07:35:04:b2:77 Static IP Address is 172.16.100.64 prepped 2 interfaces, initializing... ....................................  

 

 

 

 

Thanks!
0 Kudos
5 Replies
Altera_Forum
Honored Contributor I
58 Views

I believe you're looking for ni_set_config(). See net.h and iface.c in the iniche files. 

 

 

/* FUNCTION: ni_set_config() * * set IP address and subnet for a particular device. * * PARAM1: NET ifp * PARAM2: struct niconfig_0 * cfg * * RETURNS: 0 */
Altera_Forum
Honored Contributor I
58 Views

Thanks, that worked nicely (and seems safer than this solution (http://www.alteraforum.com/forum/showthread.php?t=24101)).

Altera_Forum
Honored Contributor I
58 Views

Hi there, 

 

I'm reviving this thread with a follow-up question:  

 

is it possible to change the mac address on the fly in nichestack? 

 

 

I didn't consider this need at start, but yesterday I configured on a system a MAC address (possibly a reserved group) and subsequently was unable to access it via switched network.
Altera_Forum
Honored Contributor I
58 Views

 

--- Quote Start ---  

I believe you're looking for ni_set_config(). See net.h and iface.c in the iniche files. 

 

 

/* FUNCTION: ni_set_config() * * set IP address and subnet for a particular device. * * PARAM1: NET ifp * PARAM2: struct niconfig_0 * cfg * * RETURNS: 0 */  

--- Quote End ---  

 

 

the proposed solution worked just fine until I realized I need the possibility to change the gateway as well. Are you aware of any such function to allow me that?
Altera_Forum
Honored Contributor I
58 Views

You probably need to write your own function to do that, as it doesn't look like there is one around already.

Reply