UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Voyager
Voyager
4,201 Views
Registered: ‎02-10-2012

Printing the DHCP aquired configuration.

Can any one suggest how to print the newly acquired DHCP configuration after using the dhcp_start(netif) function. ?

Tags (3)
0 Kudos
4 Replies
Xilinx Employee
Xilinx Employee
4,198 Views
Registered: ‎02-01-2008

Re: Printing the DHCP aquired configuration.

So in one thread after dhcp_start, manage the counters as follows:

 

    // Start the DHCP "Client Daemon"
    xil_printf("Starting DHCP_CD...\r\n");    
    dhcp_start(netif);
    while (1) {
        sleep(DHCP_FINE_TIMER_MSECS);
        dhcp_fine_tmr();
        millisec_cnt += DHCP_FINE_TIMER_MSECS;
        if (millisec_cnt >= DHCP_COARSE_TIMER_SECS*1000) {
            dhcp_coarse_tmr();
            millisec_cnt = 0;
         }
    }

 

Then in another thread, wait for the network to negotiate, then wait for an IP address to be assigned.

 

    //wait for network link to negotiate
    print("Waiting for network interface to negotiate\n\r");
    while (1) {
            sleep(500);
            if(netif_is_up(netif)) {
                   xil_printf("Network interface up\n\r");
                   break;
            }
    }
    
    // Wait for DHCP IP configuration
    while (1) {
        sleep(DHCP_FINE_TIMER_MSECS);
        if (netif->ip_addr.addr) {
            xil_printf("DHCP request success\r\n");
            break;
        }
        millisec_cnt += DHCP_FINE_TIMER_MSECS;
        if (millisec_cnt >= DHCP_TIMEOUT_MS) {
            xil_printf("ERROR: DHCP request timed out\r\n");
            return;
        }
    }            

    /* print out IP settings of the board */
    print_ip_settings(&netif->ip_addr, &netif->netmask, &netif->gw);

 

 

See attached for full main.c

0 Kudos
Voyager
Voyager
4,195 Views
Registered: ‎02-10-2012

Re: Printing the DHCP aquired configuration.

Hey John 

 

i am working with a single threaded system using RAW APIs. So.. i was trying another method using the netif set status callback function . I have attached the main c file in this. Is it the correct way of doing it for a single threaded system?

I am still facing some errors so working on it. But in gereral is it the right concept?

 

0 Kudos
Xilinx Employee
Xilinx Employee
4,187 Views
Registered: ‎02-01-2008

Re: Printing the DHCP aquired configuration.

Sorry but I can't help you as I haven't looked at this portion of lwip for a few years. I was hoping my working code snippet would have been enough to get you rolling.

 

One thing I would check is that your timers are working. I'm not sure what errors you've been experiencing. Also, use wireshark to make sure you are receiving dhcp responses.

0 Kudos
Voyager
Voyager
4,183 Views
Registered: ‎02-10-2012

Re: Printing the DHCP aquired configuration.

Thank you John.

 

I will try and adapt your code snippet into the single threaded system . 

 

 

0 Kudos