Forum Discussion
Altera_Forum
Honored Contributor
19 years agoIt's available in one of two existing data structures:
nets netstatic Just try debugging your code, and you'll see what I mean. Here's a quick sample, using netstatic:/* Declare local ipaddr variable. */
ip_addr* ipaddr;
/* Assign ipaddr to the network interface's IP Address.
* NOTE: This code assumes that only a single network
* interface exists
*/
ipaddr = &netstatic.n_ipaddr; including the header, ipport.h, then gets you the ip4_addr[1-4] convenience macros... For example, the following should print your attained IP address: printf("\nIP Address\n%d.%d.%d.%d\n",
ip4_addr1(*ipaddr),
ip4_addr2(*ipaddr),
ip4_addr3(*ipaddr),
ip4_addr4(*ipaddr)); NOTE: You could also do the same thing with nets, I believe, though I've not tried that. Cheers, - slacker