Browse Source

Merge from Etherboot 5.4

tags/v0.9.3
Michael Brown 18 years ago
parent
commit
708bbc43bc
5 changed files with 60 additions and 16 deletions
  1. 10
    5
      src/core/main.c
  2. 44
    6
      src/core/nic.c
  3. 4
    3
      src/core/vsprintf.c
  4. 1
    1
      src/include/vsprintf.h
  5. 1
    1
      src/interface/pxe/pxe_preboot.c

+ 10
- 5
src/core/main.c View File

@@ -39,11 +39,6 @@ int	url_port;
39 39
 
40 40
 char as_main_program = 1;
41 41
 
42
-#ifdef	IMAGE_FREEBSD
43
-int freebsd_howto = 0;
44
-char freebsd_kernel_env[FREEBSD_KERNEL_ENV_SIZE];
45
-#endif
46
-
47 42
 #if 0
48 43
 
49 44
 static inline unsigned long ask_boot(unsigned *index)
@@ -282,6 +277,16 @@ static int main_loop(int state)
282 277
 			if (dev->how_probe == PROBE_FAILED) {
283 278
 				state = -1;
284 279
 			}
280
+			if (state == 1) {
281
+				/* The bootp reply might have been changed, re-parse.  */
282
+				decode_rfc1533(bootp_data.bootp_reply.bp_vend, 0,
283
+#ifdef	NO_DHCP_SUPPORT
284
+				               BOOTP_VENDOR_LEN + MAX_BOOTP_EXTLEN, 
285
+#else
286
+				               DHCP_OPT_LEN + MAX_BOOTP_EXTLEN, 
287
+#endif	/* NO_DHCP_SUPPORT */
288
+				               1);
289
+			}
285 290
 		}
286 291
 	}
287 292
 	switch(state) {

+ 44
- 6
src/core/nic.c View File

@@ -33,6 +33,14 @@ char *hostname = "";
33 33
 int hostnamelen = 0;
34 34
 static uint32_t xid;
35 35
 unsigned char *end_of_rfc1533 = NULL;
36
+unsigned char *addparam;
37
+int addparamlen;
38
+
39
+#ifdef IMAGE_FREEBSD
40
+int freebsd_howto = 0;
41
+char freebsd_kernel_env[FREEBSD_KERNEL_ENV_SIZE];
42
+#endif /* IMAGE_FREEBSD */
43
+
36 44
 static int vendorext_isvalid;
37 45
 static const unsigned char vendorext_magic[] = {0xE4,0x45,0x74,0x68}; /* äEth */
38 46
 static const unsigned char broadcast[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
@@ -261,9 +269,8 @@ static int nic_configure ( struct type_dev *type_dev ) {
261 269
 #endif /* PXE_EXPORT */
262 270
 #endif /* ! NO_DHCP_SUPPORT */
263 271
 	printf(", TFTP: %@", arptable[ARP_SERVER].ipaddr.s_addr);
264
-	if (BOOTP_DATA_ADDR->bootp_reply.bp_giaddr.s_addr)
265
-		printf(", Relay: %@",
266
-			BOOTP_DATA_ADDR->bootp_reply.bp_giaddr.s_addr);
272
+	if (bootp_data.bootp_reply.bp_giaddr.s_addr)
273
+		printf(", Relay: %@", bootp_data.bootp_reply.bp_giaddr.s_addr);
267 274
 	if (arptable[ARP_GATEWAY].ipaddr.s_addr)
268 275
 		printf(", Gateway %@", arptable[ARP_GATEWAY].ipaddr.s_addr);
269 276
 	if (arptable[ARP_NAMESERVER].ipaddr.s_addr)
@@ -316,6 +323,22 @@ static int nic_load ( struct type_dev *type_dev, struct buffer *buffer ) {
316 323
 		NULL
317 324
 #endif
318 325
 		: KERNEL_BUF;
326
+#ifdef  ZPXE_SUFFIX_STRIP
327
+        {
328
+          int i = 0;
329
+          while (kernel[i++]);
330
+          if(i > 5) {
331
+            if(kernel[i - 6] == '.' &&
332
+               kernel[i - 5] == 'z' &&
333
+               kernel[i - 4] == 'p' &&
334
+               kernel[i - 3] == 'x' &&
335
+               kernel[i - 2] == 'e') {
336
+              printf("Trimming .zpxe extension\n");
337
+              kernel[i - 6] = 0;
338
+            }
339
+          }
340
+        }
341
+#endif
319 342
 	if ( kernel ) {
320 343
 		return download_url ( kernel, buffer );
321 344
 	} else {	
@@ -659,8 +682,8 @@ static int await_bootp(int ival __unused, void *ptr __unused,
659 682
 #endif	/* NO_DHCP_SUPPORT */
660 683
 		netmask = default_netmask();
661 684
 		/* bootpreply->bp_file will be copied to KERNEL_BUF in the memcpy */
662
-		memcpy((char *)BOOTP_DATA_ADDR, (char *)bootpreply, sizeof(struct bootpd_t));
663
-		decode_rfc1533(BOOTP_DATA_ADDR->bootp_reply.bp_vend, 0,
685
+		memcpy((char *)&bootp_data, (char *)bootpreply, sizeof(struct bootpd_t));
686
+		decode_rfc1533(bootp_data.bootp_reply.bp_vend, 0,
664 687
 #ifdef	NO_DHCP_SUPPORT
665 688
 			       BOOTP_VENDOR_LEN + MAX_BOOTP_EXTLEN, 
666 689
 #else
@@ -740,6 +763,8 @@ static int bootp(void)
740 763
 #else
741 764
 		while ( remaining_time > 0 ) {
742 765
 			if (await_reply(await_bootp, 0, NULL, remaining_time)){
766
+				if (arptable[ARP_CLIENT].ipaddr.s_addr)
767
+					break;
743 768
 			}
744 769
 			remaining_time = stop_time - currticks();
745 770
 		}
@@ -1029,6 +1054,8 @@ int decode_rfc1533(unsigned char *p, unsigned int block, unsigned int len, int e
1029 1054
 #else
1030 1055
 		vendorext_isvalid = 0;
1031 1056
 #endif
1057
+		addparam = NULL;
1058
+		addparamlen = 0;
1032 1059
 		if (memcmp(p, rfc1533_cookie, 4))
1033 1060
 			return(0); /* no RFC 1533 header found */
1034 1061
 		p += 4;
@@ -1039,7 +1066,7 @@ int decode_rfc1533(unsigned char *p, unsigned int block, unsigned int len, int e
1039 1066
 				return(0); /* no RFC 1533 header found */
1040 1067
 			p += 4;
1041 1068
 			len -= 4; }
1042
-		if (extend + len <= (unsigned char *)&(BOOTP_DATA_ADDR->bootp_extension[MAX_BOOTP_EXTLEN])) {
1069
+		if (extend + len <= (unsigned char *)&(bootp_data.bootp_extension[MAX_BOOTP_EXTLEN])) {
1043 1070
 			memcpy(extend, p, len);
1044 1071
 			extend += len;
1045 1072
 		} else {
@@ -1096,6 +1123,17 @@ int decode_rfc1533(unsigned char *p, unsigned int block, unsigned int len, int e
1096 1123
 			  p[6] == RFC1533_VENDOR_MAJOR
1097 1124
 			)
1098 1125
 			vendorext_isvalid++;
1126
+		else if (c == RFC1533_VENDOR_ADDPARM) {
1127
+			/* This tag intentionally works for BOTH the encapsulated and
1128
+			 * non-encapsulated case, since the current menu code (in mknbi)
1129
+			 * creates this tag without encapsulation.  In the future both the
1130
+			 * menu from mknbi and this code should learn about the proper
1131
+			 * encapsulation (which will require substantial changes to various
1132
+			 * stuff from mknbi, which will break compatibility with older
1133
+			 * versions of Etherboot).  */
1134
+			addparam = p + 2;
1135
+			addparamlen = *(p + 1);
1136
+		}
1099 1137
 		else if (NON_ENCAP_OPT c == RFC1533_VENDOR_ETHERBOOT_ENCAP) {
1100 1138
 			in_encapsulated_options = 1;
1101 1139
 			decode_rfc1533(p+2, 0, TAG_LEN(p), -1);

+ 4
- 3
src/core/vsprintf.c View File

@@ -45,7 +45,7 @@ static int vsprintf(char *buf, const char *fmt, va_list args)
45 45
 		while (*fmt >= '0' && *fmt <= '9')
46 46
 			fmt++;
47 47
 		if (*fmt == 's') {
48
-			for(p = va_arg(args, char *); *p != '\0'; p++) 
48
+			for(p = va_arg(args, char *); *p != '\0'; p++)
49 49
 				buf ? *s++ = *p : putchar(*p);
50 50
 		} else if (*fmt == 'm') {
51 51
 			for(p = strerror(errno); *p != '\0'; p++)
@@ -70,7 +70,7 @@ static int vsprintf(char *buf, const char *fmt, va_list args)
70 70
 					fmt++;
71 71
 				}
72 72
 			}
73
-			
73
+
74 74
 			/*
75 75
 			 * Before each format q points to tmp buffer
76 76
 			 * After each format q points past end of item
@@ -182,11 +182,12 @@ int sprintf(char *buf, const char *fmt, ...)
182 182
  * @err None		-
183 183
  *
184 184
  */
185
-void printf(const char *fmt, ...)
185
+int printf(const char *fmt, ...)
186 186
 {
187 187
 	va_list args;
188 188
 	int i;
189 189
 	va_start(args, fmt);
190 190
 	i=vsprintf(0, fmt, args);
191 191
 	va_end(args);
192
+	return i;
192 193
 }

+ 1
- 1
src/include/vsprintf.h View File

@@ -45,6 +45,6 @@
45 45
  */
46 46
 
47 47
 extern int sprintf ( char *buf, const char *fmt, ... );
48
-extern void printf ( const char *fmt, ... );
48
+extern int printf ( const char *fmt, ... );
49 49
 
50 50
 #endif /* VSPRINTF_H */

+ 1
- 1
src/interface/pxe/pxe_preboot.c View File

@@ -99,7 +99,7 @@ PXENV_EXIT_t pxenv_get_cached_info ( struct s_PXENV_GET_CACHED_INFO
99 99
 	memcpy ( cached_info->bootfile, KERNEL_BUF,
100 100
 		 sizeof(cached_info->bootfile) );
101 101
 	/* Copy DHCP vendor options */
102
-	memcpy ( &cached_info->vendor.d, BOOTP_DATA_ADDR->bootp_reply.bp_vend,
102
+	memcpy ( &cached_info->vendor.d, bootp_data.bootp_reply.bp_vend,
103 103
 		 sizeof(cached_info->vendor.d) );
104 104
 	
105 105
 	/* Copy to user-specified buffer, or set pointer to our buffer */

Loading…
Cancel
Save