lhip("I7188EX",&host_ip);
if(bUseDhcp){ // bUseDhcp is a global variable defined on the tcpip.lib
extern struct NETDATA netdata[];
// for using DHCP, Set the IP address/MASK to 0 before call Ninit().
*(long *)netdata[0].Iaddr.c=
*(long *)netdata[0].Imask.c=
*(long *)netdata[1].Iaddr.c=
*(long *)netdata[1].Imask.c=0L;
netdata[0].name=(char *)sHostName;
strcpy(netdata[0].name,"7188E01"); //Host name
// DhcpLeaseTime=xxxx; // by default DhcpLeaseTime=0,
DhcpLeaseTime=20;
// that is the time is assigned by the DHCP server.
// the time unit is second.
Install_DHCP(); // must call Install_DHCP() for DHCP function to work.
}
err = Ninit(); /* initiate host environment */
if (err < 0) {
¡K¡K¡K¡K.
}
err = Portinit( "*" ); /* initiate network device */
if (err < 0) { //Portinit() failed! error
¡K¡K¡K¡K.
}
In the TCP/IP library, the kernel will detect whether the IP/mask address of netdata structure are 0 or not.
If the addresses are zero, the kernel will send the DCHCP request to DHCP server.
If the addresses aren¡¦t zero, the IP/MASK address will be obtained from the EEPROM, not from DHCP server.
Note: