[En-Nut-Discussion] Fixed IP and DHCP

Christoph Hillebrand chr.hillebrand at online.de
Mon Nov 17 15:46:14 CET 2008


Dear all,

 

I´ve got a problem with my Ethernut 3 board. 

During the test period I want to drive the board with a fixed IP-address
over a crossover cable. I use an “if “-clause to configure the IP-address. 

Here is my source code:

 

                               /* Register Ethernut device */

      if (NutRegisterDevice(&DEV_ETHER, 0x8300, 5)) {

      #ifdef DEBUG

        printf("Failed to register eth device!\n");

      #endif

      }

 

    #ifdef DEBUG

        printf("Configuring eth0...\n ");

      #endif

 

 

      /*

       * don't use EEPROM mac

       * look at Ethernet Software manual, Revision: 2.4, page 37/38

       */

 

      /* try to get IP via DHCP */

      if (NutDhcpIfConfig("eth0", mac, DHCP_TIMEOUT)) {

 

            ip_addr = inet_addr(MY_IPADDR);

            ip_mask = inet_addr(MY_IPMASK);

 

 

        /* if DHCP fails, use fixed values */

        #ifdef DEBUG

          printf("DHCP failed! Using fixed values..\n");

        #endif

            NutNetIfConfig("eth0", mac, ip_addr, ip_mask);

 

      }

      else {

        /* set these two variables to the values we got via DHCP */

        ip_addr = confnet.cdn_ip_addr;

        ip_mask = confnet.cdn_ip_mask;

 

        #ifdef DEBUG

          printf("DHCP OK\n");

        #endif

 

      }

      #ifdef DEBUG

        printf("\n*********************************\n");

        printf("* -> %-10s %15s *\n", "IP:",        inet_ntoa(ip_addr));

        printf("* -> %-10s %15s *\n", "Mask:",      inet_ntoa(ip_mask));

        printf("* -> %-10s %15s *\n", "Broadcast:",
inet_ntoa(ip_broadcast));

        printf("*********************************\n\n");

      #endif

 

The fixed IP is stored in the variable MY_IPADDR.  

Now the problem. After the clause runs through , the IP-address is 0.0.0.0
and not 10.66.125.200 e.g.. 

Have I forgotten to configurate something in  the NUT/OS Conifgurator or is
there an mistake in the clause.

 

Thank you for help

 

Greetings

Christoph Hillebrand 

 



More information about the En-Nut-Discussion mailing list