This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Redboot -- get DNS addr from DHCP info


Small change to set the DNS address from the DHCP info

-john

Index: current/include/net/net.h
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/include/net/net.h,v
retrieving revision 1.18
diff -c -r1.18 net.h
*** current/include/net/net.h	9 Oct 2003 20:23:36 -0000	1.18
--- current/include/net/net.h	5 Nov 2003 19:26:26 -0000
***************
*** 359,364 ****
--- 359,370 ----
  extern ip_addr_t   __local_ip_mask;
  #endif

+ #ifdef CYGPKG_REDBOOT_NETWORKING_DNS
+ extern struct in_addr __bootp_dns_addr;
+ extern cyg_bool __bootp_dns_set;
+ #endif
+
+
  /*
   * Set a timer. Caller is responsible for providing the timer_t struct.
   */
Index: current/src/net/bootp.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/src/net/bootp.c,v
retrieving revision 1.19
diff -c -r1.19 bootp.c
*** current/src/net/bootp.c	6 Oct 2003 22:37:51 -0000	1.19
--- current/src/net/bootp.c	5 Nov 2003 19:26:26 -0000
***************
*** 288,293 ****
--- 288,300 ----
                                  memcpy(__local_ip_gate,p,4);
                                  break;
  #endif
+ #ifdef CYGPKG_REDBOOT_NETWORKING_DNS
+ 			    case TAG_DOMAIN_SERVER:
+ 				diag_printf(" DNS server found!\n");
+ 				memcpy(&__bootp_dns_addr, p, 4);
+ 				__bootp_dns_set = 1;
+ 				break;
+ #endif
                              default:
                                  break;
                              }
Index: current/src/net/dns.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/src/net/dns.c,v
retrieving revision 1.2
diff -c -r1.2 dns.c
*** current/src/net/dns.c	23 May 2002 23:08:35 -0000	1.2
--- current/src/net/dns.c	5 Nov 2003 19:26:26 -0000
***************
*** 82,87 ****
--- 82,91 ----
  /* Some magic to make dns_impl.inl compile under RedBoot */
  #define sprintf diag_sprintf

+ /* DNS server address possibly returned from bootp */
+ struct in_addr __bootp_dns_addr;
+ cyg_bool __bootp_dns_set = false;
+
  struct sockaddr_in server;

  /* static buffers so we can make do without malloc */
***************
*** 252,257 ****
--- 256,267 ----
      server.sin_port = htons(DOMAIN_PORT);
      cyg_drv_mutex_init(&dns_mutex);

+     /* If we got a DNS server address from the DHCP/Bootp, then use that address */
+     if ( __bootp_dns_set ) {
+ 	memcpy(&server.sin_addr, &__bootp_dns_addr, sizeof(__bootp_dns_addr) );
+ 	s = 0;
+     }
+     else {
  #ifdef CYGSEM_REDBOOT_FLASH_CONFIG
      {
          ip_addr_t dns_ip;
***************
*** 264,272 ****
          s = 0;
      }
  #else
!     // Use static configuration
!     set_dns(__Xstr(CYGPKG_REDBOOT_NETWORKING_DNS_IP));
  #endif

      return 0;
  }
--- 274,283 ----
          s = 0;
      }
  #else
!       // Use static configuration
! 	set_dns(__Xstr(CYGPKG_REDBOOT_NETWORKING_DNS_IP));
  #endif
+     }

      return 0;
  }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]