-DUSE_STATIC_BOOT_INFO and -DEXIT_ON_FILE_LOAD_ERROR
authormarty_connor <marty_connor>
Thu, 30 Mar 2006 07:17:33 +0000 (07:17 +0000)
committermarty_connor <marty_connor>
Thu, 30 Mar 2006 07:17:33 +0000 (07:17 +0000)
src/Config
src/Makefile.main
src/core/nic.c

index 512010d..225d7dd 100644 (file)
 #                      Use BOOTP instead of DHCP.
 #      -DRARP_NOT_BOOTP
 #                      Use RARP instead of BOOTP/DHCP.
+#
+#      -DUSE_STATIC_BOOT_INFO  
+#                      Use static ip insted of dynamic protocols
+#                      When USE_STATIC_BOOT_INFO is defined, the following
+#                      must also be defined:
+#                      -DSTATIC_CLIENT_IP
+#                      -DSTATIC_SUBNET_MASK
+#                      -DSTATIC_SERVER_IP
+#                      -DSTATIC_GATEWAY_IP
+#                      -DSTATIC_BOOTFILE
+#
+#      -DSTATIC_CLIENT_IP=\"1.2.3.4\"
+#                      Static client IP address.  Requires -DUSE_STATIC_BOOT_INFO
+#                      be set to be used.
+#      -DSTATIC_SUBNET_MASK=\"255.255.255.0\"
+#                      Static subnet address.  Requires -DUSE_STATIC_BOOT_INFO
+#                      be set to be used.
+#      -DSTATIC_SERVER_IP=\"1.2.4.5\"
+#                      Static server IP address.  Requires -DUSE_STATIC_BOOT_INFO
+#                      be set to be used.
+#      -DSTATIC_GATEWAY_IP=\"1.2.3.254\"
+#                      Static gateway IP address.  Requires -DUSE_STATIC_BOOT_INFO
+#                      be set to be used.
+#      -DSTATIC_BOOTFILE=\"tftp://1.2.4.5/pxelinux.0\"
+#                      Static gateway IP address.  Requires -DUSE_STATIC_BOOT_INFO
+#                      be set to be used.
+#
+#      -DEXIT_ON_FILE_LOAD_ERROR
+#                      Exit Etherboot if unable to load the requested boot file
+#
 #      -DREQUIRE_VCI_ETHERBOOT
 #                      Require an encapsulated Vendor Class Identifier
 #                      of "Etherboot" in the DHCP reply
 #                      encapsulated Etherboot options.
 #      -DDEFAULT_BOOTFILE=\"default_bootfile_name\"
 #                      Define a default bootfile for the case where your DHCP
-#                      server does not provide the information.  Example:
-#                        -DDEFAULT_BOOTFILE="tftp:///tftpboot/kernel"
+#                      server does not provide the information.  Examples:
+#                        -DDEFAULT_BOOTFILE=\"tftp:///tftpboot/kernel.nbi\"
+#                        -DDEFAULT_BOOTFILE-\"tftp://1.2.4.5/lts/pxelinux.0\"
 #                      If you do not specify this option, then DHCP offers that
 #                      do not specify bootfiles will be ignored.
 #
@@ -379,10 +410,24 @@ CFLAGS+=  -DALLOW_ONLY_ENCAPSULATED
 # Disable DHCP support
 # CFLAGS+=     -DNO_DHCP_SUPPORT
 
+# Set to enable static boot information
+# CFLAGS+=     -DUSE_STATIC_BOOT_INFO
+
+# Specify the static boot values
+# All must be specified, if -DUSE_STATIC_BOOT_INFO is defined
+# CFLAGS+=     -DSTATIC_CLIENT_IP=\"192.168.25.25\"
+# CFLAGS+=     -DSTATIC_SUBNET_MASK=\"255.255.255.0\"
+# CFLAGS+=     -DSTATIC_SERVER_IP=\"192.168.25.101\"
+# CFLAGS+=     -DSTATIC_GATEWAY_IP=\"192.168.25.1\"
+# CFLAGS+=     -DSTATIC_BOOTFILE=\"tftp://192.168.25.101/pxelinux.0\"
+
 # Specify a default bootfile to be used if the DHCP server does not
 # provide the information.  If you do not specify this option, then
 # DHCP offers that do not contain bootfiles will be ignored.
-# CFLAGS+=     -DDEFAULT_BOOTFILE=\"tftp:///tftpboot/kernel\"
+# CFLAGS+=     -DDEFAULT_BOOTFILE=\"tftp://192.168.1.254/lts/pxelinux.0\"
+
+# Exit if there is an error loading the boot file
+# CFLAGS+=     -DEXIT_ON_FILE_LOAD_ERROR
 
 # Limit the delay on packet loss/congestion to a more bearable value. See
 # description above.  If unset, do not limit the delay between resend.
index fabd044..51b90b0 100644 (file)
@@ -102,8 +102,8 @@ BOBJS:=
 MAKEROM=       $(PERL) ./util/makerom.pl
 VERSION_MAJOR= 5
 VERSION_MINOR= 4
-VERSION_PATCH= 1
-EXTRAVERSION=  
+VERSION_PATCH= 2
+EXTRAVERSION=   pre1
 VERSION=       $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)$(EXTRAVERSION)
 MM_VERSION=    $(VERSION_MAJOR).$(VERSION_MINOR)
 CFLAGS+=       -DVERSION_MAJOR=$(VERSION_MAJOR) \
@@ -402,13 +402,41 @@ tarball: ../index.html ../index-berlios.html
 
 cvs-tarball: ../index.html ../index-berlios.html
        (echo -n $(VERSION) ''; date -u +'%Y-%m-%d') > ../VERSION
-       rm -rf /tmp/etherboot-$(MM_VERSION)cvs
-       mkdir /tmp/etherboot-$(MM_VERSION)cvs
-       cp -rP .. /tmp/etherboot-$(MM_VERSION)cvs
-       ( cd /tmp; tar cf /tmp/etherboot-$(MM_VERSION)cvs.tar --exclude CVS --exclude "#*" \
-            --exclude "*~" etherboot-$(MM_VERSION)cvs )
-       bzip2 -9 < /tmp/etherboot-$(MM_VERSION)cvs.tar > /tmp/etherboot-$(MM_VERSION)cvs.tar.bz2
-       gzip -9 < /tmp/etherboot-$(MM_VERSION)cvs.tar > /tmp/etherboot-$(MM_VERSION)cvs.tar.gz
+       rm -rf /tmp/etherboot-$(VERSION)
+       mkdir /tmp/etherboot-$(VERSION)
+       cp -rP .. /tmp/etherboot-$(VERSION)
+       ( cd /tmp; tar cf /tmp/etherboot-$(VERSION).tar --exclude CVS --exclude "#*" \
+            --exclude "*~" etherboot-$(VERSION) )
+       bzip2 -9 < /tmp/etherboot-$(VERSION).tar > /tmp/etherboot-$(VERSION).tar.bz2
+       gzip -9 < /tmp/etherboot-$(VERSION).tar > /tmp/etherboot-$(VERSION).tar.gz
+       ( cd /tmp; rm -rf /tmp/etherboot-$(VERSION) ; rm /tmp/etherboot-$(VERSION).tar ; \
+       tar -zxf /tmp/etherboot-$(VERSION).tar.gz )
+
+# If static boot info is used, all static values must be supplied
+
+ifneq ($(findstring -DUSE_STATIC_BOOT_INFO, $(CFLAGS)),)
+
+ifeq ($(findstring -DSTATIC_CLIENT_IP, $(CFLAGS)),)
+$(error "-DUSE_STATIC_BOOT_INFO defined, but -DSTATIC_CLIENT_IP not defined!")
+endif
+
+ifeq ($(findstring -DSTATIC_SUBNET_MASK, $(CFLAGS)),)
+$(error "-DUSE_STATIC_BOOT_INFO defined, but -DSTATIC_SUBNET_MASK not defined!")
+endif
+
+ifeq ($(findstring -DSTATIC_SERVER_IP, $(CFLAGS)),)
+$(error "-DUSE_STATIC_BOOT_INFO defined, but -DSTATIC_SERVER_IP not defined!")
+endif
+
+ifeq ($(findstring -DSTATIC_GATEWAY_IP, $(CFLAGS)),)
+$(error "-DUSE_STATIC_BOOT_INFO defined, but -DSTATIC_GATEWAY_IP not defined!")
+endif
+
+ifeq ($(findstring -DSTATIC_BOOTFILE, $(CFLAGS)),)
+$(error "-DUSE_STATIC_BOOT_INFO defined, but -DSTATIC_BOOTFILE not defined!")
+endif
+
+endif
 
 # Auto-incrementing build serial number.  Is auto-incremented for each
 # make run that specifies a final image file (e.g. bin/undi.zpxe) as a
index 95998de..d0d4090 100644 (file)
@@ -29,7 +29,9 @@ static unsigned long  netmask;
 /* Used by nfs.c */
 char *hostname = "";
 int hostnamelen = 0;
+#ifndef USE_STATIC_BOOT_INFO
 static uint32_t xid;
+#endif /* USE_STATIC_BOOT_INFO */
 unsigned char *end_of_rfc1533 = NULL;
 unsigned char *addparam;
 int addparamlen;
@@ -51,9 +53,10 @@ static unsigned char rfc1533_cookie[5] = { RFC1533_COOKIE, RFC1533_END };
 #else  /* !NO_DHCP_SUPPORT */
 static int dhcp_reply;
 static in_addr dhcp_server = { 0L };
-static in_addr dhcp_addr = { 0L };
 static unsigned char   rfc1533_cookie[] = { RFC1533_COOKIE };
 #define DHCP_MACHINE_INFO_SIZE (sizeof dhcp_machine_info)
+#ifndef USE_STATIC_BOOT_INFO
+static in_addr dhcp_addr = { 0L };
 static unsigned char dhcp_machine_info[] = {
        /* Our enclosing DHCP tag */
        RFC1533_VENDOR_ETHERBOOT_ENCAP, 11,
@@ -68,6 +71,7 @@ static unsigned char dhcp_machine_info[] = {
 #define DHCP_MACHINE_INFO_SIZE (sizeof(dhcp_machine_info) - (EM_CURRENT_64_PRESENT? 0: 4))
 #endif /* EM_CURRENT_64 */
 };
+#endif /* USE_STATIC_BOOT_INFO */
 static const unsigned char dhcpdiscover[] = {
        RFC2132_MSG_TYPE,1,DHCPDISCOVER,
        RFC2132_MAX_SIZE,2,     /* request as much as we can */
@@ -278,8 +282,12 @@ struct nic nic =
 #ifdef RARP_NOT_BOOTP
 static int rarp(void);
 #else
+#ifdef USE_STATIC_BOOT_INFO
+static int get_static_boot_info(void);
+#else  
 static int bootp(void);
 #endif
+#endif
 static unsigned short tcpudpchksum(struct iphdr *ip);
 
 
@@ -322,6 +330,9 @@ int eth_load_configuration(struct dev *dev __unused)
 {
        int server_found;
        /* Find a server to get BOOTP reply from */
+#ifdef  USE_STATIC_BOOT_INFO
+       printf("Using Static IP Information...");
+#else  
 #ifdef RARP_NOT_BOOTP
        printf("Searching for server (RARP)...");
 #else
@@ -331,11 +342,16 @@ int eth_load_configuration(struct dev *dev __unused)
        printf("Searching for server (BOOTP)...");
 #endif
 #endif
-
+#endif
+       
+#ifdef  USE_STATIC_BOOT_INFO
+       server_found = get_static_boot_info();
+#else  
 #ifdef RARP_NOT_BOOTP
        server_found = rarp();
 #else
        server_found = bootp();
+#endif
 #endif
        if (!server_found) {
                printf("No Server found\n");
@@ -352,6 +368,7 @@ int eth_load(struct dev *dev __unused)
 {
        const char      *kernel;
        printf("\nMe: %@", arptable[ARP_CLIENT].ipaddr.s_addr );
+#ifndef USE_STATIC_BOOT_INFO
 #ifndef NO_DHCP_SUPPORT
        printf(", DHCP: %@", dhcp_server );
 #ifdef PXE_EXPORT       
@@ -360,6 +377,7 @@ int eth_load(struct dev *dev __unused)
                       arptable[ARP_PROXYDHCP].ipaddr.s_addr);
 #endif /* PXE_EXPORT */
 #endif /* ! NO_DHCP_SUPPORT */
+#endif /* USE_STATIC_BOOT_INFO */      
        printf(", TFTP: %@", arptable[ARP_SERVER].ipaddr.s_addr);
        if (bootp_data.bootp_reply.bp_giaddr.s_addr)
                printf(", Relay: %@", bootp_data.bootp_reply.bp_giaddr.s_addr);
@@ -379,13 +397,23 @@ int eth_load(struct dev *dev __unused)
 #ifdef DOWNLOAD_PROTO_NFS
        rpc_init();
 #endif
-       kernel = KERNEL_BUF[0] == '\0' ? 
-#ifdef DEFAULT_BOOTFILE
-               DEFAULT_BOOTFILE
+
+       /* Handle boot filename static and default cases */
+
+       if ( KERNEL_BUF[0] != '\0' ) {
+         kernel = KERNEL_BUF;
+       } else {
+#if defined(USE_STATIC_BOOT_INFO) && defined(STATIC_BOOTFILE)
+         kernel = STATIC_BOOTFILE;
+#elif defined(DEFAULT_BOOTFILE)
+         kernel = DEFAULT_BOOTFILE;
 #else
-               NULL
+         kernel = NULL;
 #endif
-               : KERNEL_BUF;
+       }
+
+       /* Remove .zpxe from filename if it exists */
+
 #ifdef  ZPXE_SUFFIX_STRIP
         {
           int i = 0;
@@ -402,9 +430,13 @@ int eth_load(struct dev *dev __unused)
           }
         }
 #endif
+
        if ( kernel ) {
                loadkernel(kernel); /* We don't return except on error */
                printf("Unable to load file.\n");
+#ifdef EXIT_ON_FILE_LOAD_ERROR
+               longjmp(restart_etherboot, 255);
+#endif
        } else {        
                printf("No filename\n");
        }
@@ -795,7 +827,33 @@ int tftp_block ( struct tftpreq_info_t *request, struct tftpblk_info_t *block )
 }
 #endif /* DOWNLOAD_PROTO_TFTP */
 
+#ifdef  USE_STATIC_BOOT_INFO
+/***************************************************************************
+get_static_boot_info - construct bootp response from supplied CFLAG values
+***************************************************************************/
+static int get_static_boot_info (void)
+{
+       in_addr client_addr, server_addr, gateway_addr, netmask_addr;
+
+       inet_aton( STATIC_CLIENT_IP, &client_addr );
+       memcpy ( &arptable[ARP_CLIENT].ipaddr, &client_addr.s_addr, sizeof(in_addr) );
+
+       inet_aton( STATIC_SERVER_IP, &server_addr );
+       memcpy( &arptable[ARP_SERVER].ipaddr, &server_addr.s_addr, sizeof(in_addr) );
+
+       inet_aton( STATIC_GATEWAY_IP, &gateway_addr );
+       memcpy( &arptable[ARP_GATEWAY].ipaddr, &gateway_addr.s_addr, sizeof(in_addr) );
+
+       inet_aton( STATIC_SUBNET_MASK, &netmask_addr );
+       netmask = ntohl( netmask_addr.s_addr );
+
+       bootp_data.bootp_reply.bp_op = BOOTP_REPLY;
+
+       return (1);
+}
+#else
 #ifdef RARP_NOT_BOOTP
+
 /**************************************************************************
 RARP - Get my IP address and load information
 **************************************************************************/
@@ -858,7 +916,6 @@ static int rarp(void)
 }
 
 #else
-
 /**************************************************************************
 BOOTP - Get my IP address and load information
 **************************************************************************/
@@ -1058,6 +1115,8 @@ static int bootp(void)
 }
 #endif /* RARP_NOT_BOOTP */
 
+#endif
+
 static uint16_t tcpudpchksum(struct iphdr *ip)
 {
        struct udp_pseudo_hdr pseudo;