Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
16 years ago

DHCP timed out, going back to default IP address(es)

I am using simple socket server. After I run the program, there is a long wait and then "DHCP timed out, going back to default IP address(es)" comes. I wanted to know how to decrease this timeout value of DHCP. I am also giving static IP, so I am a bit confused whether DHCP should run or not?

5 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    If you want to disable DHCP you have two options:

    1 - Open the BSP editor for your project and disable the DHCP client for the InterNiche Stack.

    2 - Edit the function "get_ip_addr" in the file "network_utilities.c" for the simple socket server example so that it doesn't set the variable "*use_dhcp" to 1 before returning.

    If you want to reduce the DHCP timeout, there is a function called "dhc_set_timeout" which you can call before initializing the InterNiche stack.

    What you would do is put the declaration:

    extern void dhc_set_timeout(int timeout_sec);

    at the top of your file. Then you simply call dhc_set_timeout with the timeout value in seconds before the call to "iniche_initialize".

    Jake
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    If you want to disable DHCP you have two options:

    1 - Open the BSP editor for your project and disable the DHCP client for the InterNiche Stack.

    2 - Edit the function "get_ip_addr" in the file "network_utilities.c" for the simple socket server example so that it doesn't set the variable "*use_dhcp" to 1 before returning.

    If you want to reduce the DHCP timeout, there is a function called "dhc_set_timeout" which you can call before initializing the InterNiche stack.

    What you would do is put the declaration:

    extern void dhc_set_timeout(int timeout_sec);
    at the top of your file. Then you simply call dhc_set_timeout with the timeout value in seconds before the call to "iniche_initialize".

    Jake

    --- Quote End ---

    Sorry for the graveyard rez, but I am trying to set the timeout with a function like in this post, but there is no "dhc_set_timeout" in my workspace. Has the name of this function changed?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    Sorry for the graveyard rez, but I am trying to set the timeout with a function like in this post, but there is no "dhc_set_timeout" in my workspace. Has the name of this function changed?

    --- Quote End ---

    Hi all it seems to me too. Is there any way to set the dhcp timeout in inche?

    memes
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    Hi all it seems to me too. Is there any way to set the dhcp timeout in inche?

    memes

    --- Quote End ---

    I use the superloop setup and for me the file that needed to be changed was at this path:

    superloop_iniche_lib\iniche\src\misclib\dhcsetup.c

    Changed this code:

       /* wait for DHCP activity to conclude */
       /* 
        * Altera Niche Stack Nios port modification:
        * Increase DHCP timeout to > 2 minutes 
        */
       while (((cticks - dhcp_started) < (100*TPS)) &&
          (dhc_alldone() == FALSE))
       {
          /* let other tasks spin. This is required, since some systems
           * increment cticks in tasks, or use a polling task to receive
           * packets. Without this activity this loop will never exit.
           */
          tk_yield();
          pktdemux();# ifdef SUPERLOOP
          dhc_second ();# endif
       }

    I think the "100" used to be some other value.