Re: Static ip patch problems

"Ricardo Carrillo Cruz" <[email protected]> Thu, 9 Mar 2006 13:57:47 +0100
Newsgroups gmane.network.etherboot.devel
Message-ID <[email protected]>
These are the new patches.They don't work yet :(
I have added static_server_ip() function and gateway settings.

Kind regards

Ricky
Config.diff (application/octet-stream, 1.7 KB)
--- Config.orig	2006-03-07 10:32:43.000000000 +0100
+++ Config	2006-03-08 13:15:13.000000000 +0100
@@ -60,6 +60,10 @@
 #			Use BOOTP instead of DHCP.
 #	-DRARP_NOT_BOOTP
 #			Use RARP instead of BOOTP/DHCP.
+#	-DSTATIC_ADDRESS	Use static ip insted of dynamic protocol
+#	-DSTATIC_CLIENT_IP=\"1.2.3.4\"
+#	-DSTATIC_SERVER_IP=\"1.2.4.5\"
+#	-DSTATIC_GATEWAY_IP=\"1.2.3.254\"
 #	-DREQUIRE_VCI_ETHERBOOT
 #			Require an encapsulated Vendor Class Identifier
 #			of "Etherboot" in the DHCP reply
@@ -374,15 +378,23 @@
 # This option should be enabled unless you have a legacy DHCP server
 # configuration from the bad old days before the use of
 # encapsulated Etherboot options.
-CFLAGS+=	-DALLOW_ONLY_ENCAPSULATED
+#CFLAGS+=	-DALLOW_ONLY_ENCAPSULATED
 
 # Disable DHCP support
-# CFLAGS+=	-DNO_DHCP_SUPPORT
+#CFLAGS+=	-DNO_DHCP_SUPPORT
+
+# Enable static ip
+CFLAGS+=	-DSTATIC_ADDRESS
+
+#Specify the client IP
+CFLAGS+=	-DSTATIC_CLIENT_IP=\"10.205.99.74\"
+CFLAGS+=	-DSTATIC_SERVER_IP=\"10.205.99.73\"
+CFLAGS+=	-DSTATIC_GATEWAY_IP=\"10.205.99.1\"
 
 # 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://10.205.99.73/thinstation.nbi\"
 
 # Limit the delay on packet loss/congestion to a more bearable value. See
 # description above.  If unset, do not limit the delay between resend.
@@ -439,12 +451,12 @@
 # CFLAGS+=	-DNORELOCATE
 
 # you should normally not need to change these
-HOST_CC=	gcc
+HOST_CC=	gcc-3.4
 CPP=		gcc -E -Wp,-Wall
 RM=		rm -f
 TOUCH=		touch
 PERL=		/usr/bin/perl
-CC=		gcc
+CC=		gcc-3.4
 AS=		as
 LD=		ld
 SIZE=		size
nic.diff (application/octet-stream, 2.9 KB)
--- nic_orig.c	2006-03-07 10:38:52.000000000 +0100
+++ nic.c	2006-03-08 13:44:46.000000000 +0100
@@ -270,8 +270,13 @@
 #ifdef RARP_NOT_BOOTP
 static int rarp(void);
 #else
+#ifdef STATIC_ADDRESS
+static void static_client_ip(void);
+static int static_server_ip(void);
+#else	
 static int bootp(void);
 #endif
+#endif
 static unsigned short tcpudpchksum(struct iphdr *ip);
 
 
@@ -314,6 +319,9 @@
 {
 	int server_found;
 	/* Find a server to get BOOTP reply from */
+#ifdef  STATIC_ADDRESS
+	printf("Booting with static ip address...");
+#else	
 #ifdef	RARP_NOT_BOOTP
 	printf("Searching for server (RARP)...");
 #else
@@ -323,12 +331,18 @@
 	printf("Searching for server (BOOTP)...");
 #endif
 #endif
-
+#endif
+	
+#ifdef  STATIC_ADDRESS
+	static_client_ip();
+	server_found= static_server_ip();
+#else	
 #ifdef	RARP_NOT_BOOTP
 	server_found = rarp();
 #else
 	server_found = bootp();
 #endif
+#endif
 	if (!server_found) {
 		printf("No Server found\n");
 		longjmp(restart_etherboot, -1);
@@ -344,6 +358,7 @@
 {
 	const char	*kernel;
 	printf("\nMe: %@", arptable[ARP_CLIENT].ipaddr.s_addr );
+#ifndef STATIC_ADDRESS
 #ifndef NO_DHCP_SUPPORT
 	printf(", DHCP: %@", dhcp_server );
 #ifdef PXE_EXPORT       
@@ -352,6 +367,7 @@
 		       arptable[ARP_PROXYDHCP].ipaddr.s_addr);
 #endif /* PXE_EXPORT */
 #endif /* ! NO_DHCP_SUPPORT */
+#endif /* STATIC_ADDRESS */	
 	printf(", TFTP: %@", arptable[ARP_SERVER].ipaddr.s_addr);
 	if (BOOTP_DATA_ADDR->bootp_reply.bp_giaddr.s_addr)
 		printf(", Relay: %@",
@@ -788,7 +804,29 @@
 }
 #endif	/* DOWNLOAD_PROTO_TFTP */
 
+#ifdef  STATIC_ADDRESS
+/***************************************************************************
+STATIC - Set my IP address and load information
+***************************************************************************/
+void static_client_ip(void)
+{
+	in_addr client_addr;
+	inet_aton(STATIC_CLIENT_IP,&client_addr);
+	memcpy(&arptable[ARP_CLIENT].ipaddr,&client_addr.s_addr,sizeof(in_addr));
+}
+
+int static_server_ip(void)
+{
+	in_addr server_addr,gateway_addr;
+	inet_aton(STATIC_SERVER_IP,&server_addr);
+	inet_aton(STATIC_GATEWAY_IP,&gateway_addr);
+	netmask=default_netmask();
+	memcpy(&arptable[ARP_SERVER].ipaddr,&server_addr.s_addr,sizeof(in_addr));
+	memcpy(&arptable[ARP_GATEWAY].ipaddr,&gateway_addr.s_addr,sizeof(in_addr));
+}
+#else
 #ifdef	RARP_NOT_BOOTP
+
 /**************************************************************************
 RARP - Get my IP address and load information
 **************************************************************************/
@@ -851,7 +889,6 @@
 }
 
 #else
-
 /**************************************************************************
 BOOTP - Get my IP address and load information
 **************************************************************************/
@@ -1049,6 +1086,8 @@
 }
 #endif	/* RARP_NOT_BOOTP */
 
+#endif
+
 static uint16_t tcpudpchksum(struct iphdr *ip)
 {
 	struct udp_pseudo_hdr pseudo;