This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How the dhcp is set up

I am looking at C:\Keil_v5\Boards\Keil\MCB4300\RL\TCPNet\FTP_Demo\FTP_Demo.uvproj

The main code looks like below

extern LOCALM localm[];                       /* Local Machine Settings      */
#define MY_IP localm[NETIF_ETH].IpAdr

int main (void) {
  /* Main Thread of the TcpNet */

  init ();

  init_display ();

  init_TcpNet ();

  finit (NULL);

  dhcp_tout = DHCP_TOUT;

  while (1) {

    timer_poll ();

    main_TcpNet ();

    dhcp_check ();

    blink_led ();

  }

}

Under dhcp_check() function, we are checking the MY_IP, whether it got the IP address after init_TcPNet() and main_TcpNet() are called in the main().

static void dhcp_check () {

  /* Monitor DHCP IP address assignment. */

  if (tick == __FALSE || dhcp_tout == 0) {

    return;

  }
  if (mem_test (&MY_IP, 0, IP_ADRLEN) == __FALSE && !(dhcp_tout & 0x80000000)) {

    /* Success, DHCP has already got the IP address. */

    dhcp_tout = 0;

    sprintf((char *)lcd_text[0],"IP address:");

    sprintf((char *)lcd_text[1],"%d.%d.%d.%d", MY_IP[0], MY_IP[1],
                                               MY_IP[2], MY_IP[3]);

    LCDupdate = __TRUE;

    return;

  }

}

I do not even see localm or MY_IP being passed as a parameter. Is localm declared as a global variable in the library and as a result of one of the calls (like init_TcpNet() or main_TcpNet()) localm (and MY_IP is getting modified?

Can someone please explain.. its confusing me a lot.

0