Forum Discussion
Altera_Forum
Honored Contributor
16 years agoHow do Nios-II handle IP address change during the TCP/IP connection?
Dear all, I have problem with changing IP address in the FPGA board. Here is my case, let say I have a FPGA board which is connected to PC. The PC sends a command to the FPGA that asks th...
Altera_Forum
Honored Contributor
15 years agoHi Jakobjones!
I've checked the "set_ipaddr()" function and "alt_iniche_dev.c", then I made my own function to change the ip address. Here is the code :
int change_ip (int dhcp_actv)
{
alt_iniche_dev *p_dev;
NET p_net;
ip_addr ipaddr, netmask, gw;
NetInfo new_ip;
new_ip.ipaddr_in = 192;
new_ip.ipaddr_in = 168;
new_ip.ipaddr_in = 1;
new_ip.ipaddr_in = 3;
new_ip.netmask_in = 255;
new_ip.netmask_in = 255;
new_ip.netmask_in = 255;
new_ip.netmask_in = 0;
new_ip.gw_in = 192;
new_ip.gw_in = 168;
new_ip.gw_in = 1;
new_ip.gw_in = 1;
p_dev -> p_net = nets;
// Get the new ip address
printf(" Get the new ip address\n");
if(dhcp_actv) p_net -> n_flags |= NF_DHCPC;
else
{
IP4_ADDR( ipaddr, new_ip.ipaddr_in, new_ip.ipaddr_in, new_ip.ipaddr_in, new_ip.ipaddr_in );
IP4_ADDR( netmask, new_ip.netmask_in, new_ip.netmask_in, new_ip.netmask_in, new_ip.netmask_in );
IP4_ADDR( gw, new_ip.gw_in, new_ip.gw_in, new_ip.gw_in, new_ip.gw_in );
p_net -> n_ipaddr = ipaddr;
p_net -> snmask = netmask;
p_net -> n_defgw = gw;
}
return 0;
}
There was no error either during the compilation or after the program execution, but the Nios' IP address didn't change (I've checked it by ping the Nios from my pc). It still used the old IP address. Do you know what's wrong with my code? I'm thinking that I need to reset the NicheStack or force the NicheStack to read the new assigned IP address. But I don't know how to do that. Hopefully you can help me.. Thanks before.