wok view gpxe/stuff/cmdline.u @ rev 1122

gpxe: accept empty cmdline
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Jul 21 14:45:55 2008 +0000 (2008-07-21)
parents c135cd14d789
children e35a8dffd011
line source
1 --- gpxe-0.9.3/src/arch/i386/prefix/lkrnprefix.S
2 +++ gpxe-0.9.3/src/arch/i386/prefix/lkrnprefix.S
3 @@ -77,7 +77,9 @@
4 popw %ax
5 addw $(0x100/16), %ax /* Adjust cs */
6 pushw %ax
7 - jmp go_setup_code
8 + pushw $run_etherboot_floppy
9 + /* Calculated lcall to _start with %cs:0000 = image start */
10 + lret
12 bootsector:
13 jmp $BOOTSEG, $go /* reload cs:ip to match relocation addr */
14 @@ -197,7 +199,7 @@
15 */
17 /* Jump to loaded copy */
18 - ljmp $SYSSEG, $run_etherboot2
19 + ljmp $SYSSEG, $run_etherboot_floppy
21 endseg: .word SYSSEG + _load_size_pgh
22 .section ".zinfo.fixup", "a" /* Compressor fixup information */
23 @@ -436,8 +438,7 @@
24 * we just have to ensure that %cs:0000 is where the start of
25 * the Etherboot image *would* be.
26 */
27 -go_setup_code:
28 - pushw $run_etherboot
29 + pushw $run_etherboot_zImage
30 /* Calculated lcall to _start with %cs:0000 = image start */
31 lret
33 @@ -448,7 +449,25 @@
34 /*
35 We're now at the beginning of the kernel proper.
36 */
37 -run_etherboot2:
38 +run_etherboot_zImage:
39 + mov $0x0020, %si
40 + lodsw
41 + cmp $0xA33F, %ax
42 + jne run_etherboot
43 + lodsw
44 + xchg %ax, %si
45 + cmpb (%si),%ah
46 + je run_etherboot
47 + push %ds
48 + pop %es
49 + movw $boot_url, %di
50 +copy_cmdline:
51 + lodsb
52 + stosb
53 + or %al, %al
54 + jne copy_cmdline
55 + jmp run_etherboot
56 +run_etherboot_floppy:
57 push %cs
58 pop %ds
59 run_etherboot:
61 --- gpxe-0.9.3/src/net/udp/dns.c
62 +++ gpxe-0.9.3/src/net/udp/dns.c
63 @@ -506,6 +506,19 @@
64 .resolv = dns_resolv,
65 };
67 +int apply_nameserver(struct in_addr sin_addr)
68 +{
69 + struct sockaddr_in *sin_nameserver;
70 +
71 + sin_nameserver = ( struct sockaddr_in * ) &nameserver;
72 + sin_nameserver->sin_family = AF_INET;
73 + sin_nameserver->sin_addr = sin_addr;
74 + DBG ( "DNS using nameserver %s\n",
75 + inet_ntoa ( sin_addr ) );
76 +
77 + return 0;
78 +}
79 +
80 /**
81 * Apply DHCP nameserver option
82 *
83 @@ -514,16 +527,10 @@
84 */
85 static int apply_dhcp_nameserver ( unsigned int tag __unused,
86 struct dhcp_option *option ) {
87 - struct sockaddr_in *sin_nameserver;
88 -
89 - sin_nameserver = ( struct sockaddr_in * ) &nameserver;
90 - sin_nameserver->sin_family = AF_INET;
91 - dhcp_ipv4_option ( option, &sin_nameserver->sin_addr );
92 -
93 - DBG ( "DNS using nameserver %s\n",
94 - inet_ntoa ( sin_nameserver->sin_addr ) );
95 + struct in_addr sin_addr;
97 - return 0;
98 + dhcp_ipv4_option ( option, &sin_addr );
99 + return apply_nameserver(sin_addr);
100 }
102 /** DHCP nameserver applicator */
104 --- gpxe-0.9.3/src/usr/autoboot.c
105 +++ gpxe-0.9.3/src/usr/autoboot.c
106 @@ -23,6 +23,7 @@
107 #include <gpxe/dhcp.h>
108 #include <gpxe/image.h>
109 #include <gpxe/embedded.h>
110 +#include <gpxe/ip.h>
111 #include <usr/ifmgmt.h>
112 #include <usr/route.h>
113 #include <usr/dhcpmgmt.h>
114 @@ -150,16 +151,68 @@
115 */
116 static int netboot ( struct net_device *netdev ) {
117 char buf[256];
118 - int rc;
119 + int rc, nodhcp;
120 + char *ip, *gw, *dns, *s;
121 + extern int apply_nameserver(struct in_addr sin_addr);
123 /* Open device and display device status */
124 if ( ( rc = ifopen ( netdev ) ) != 0 )
125 return rc;
126 ifstat ( netdev );
128 + ip = gw = dns = NULL;
129 + nodhcp = 0;
130 + for (s = forced_url.url; *s && s < forced_url.url + 256;) {
131 + while (*s == ' ') s++;
132 + if (!strncmp(s,"ip=",3)) ip = s + 3, *s++ = 0;
133 + if (!strncmp(s,"gw=",3)) gw = s + 3, *s++ = 0;
134 + if (!strncmp(s,"dns=",4)) dns = s + 4, *s++ = 0;
135 + if (!strncmp(s,"nodhcp",5)) nodhcp++, *s++ = 0;
136 + if (!strncmp(s,"url=",4)) {
137 + char *p = forced_url.url;
138 + for (s += 4; *s && *s != ' '; *p++ = *s++);
139 + *p = 0;
140 + }
141 + while (*s && *s != ' ') s++;
142 + *s++ = 0;
143 + }
144 +
145 /* Configure device via DHCP */
146 - if ( ( rc = dhcp ( netdev ) ) != 0 )
147 - return rc;
148 + if (forced_url.url[0]) printf("url=%s\n",forced_url.url);
149 + if ( nodhcp || ( rc = dhcp ( netdev ) ) != 0 ) {
150 +#define IN_CLASSA(x) (( (x).s_addr & 0x80000000) == 0)
151 +#define IN_CLASSB(x) (( (x).s_addr & 0xc0000000) == 0x80000000)
152 +#define IN_CLASSA_NET 0xff000000
153 +#define IN_CLASSB_NET 0xffff0000
154 +#define IN_CLASSC_NET 0xffffff00
155 +#define IN_CLASSLESS_NET(x) (0xffffffff << (32 - (x)))
156 + struct in_addr address, netmask, gateway, nameserver;
157 + char *p;
158 +
159 + if (!ip || !gw || !inet_aton(gw, &gateway))
160 + return rc;
161 + p = strchr(ip,'/');
162 + if (p) *p++ = 0;
163 + if (!inet_aton(ip, &address))
164 + return rc;
165 + if (p) {
166 + int n;
167 + for (n = 0; *p >= '0' && *p <= '9';
168 + n *= 10, n += *p++ - 10);
169 + netmask.s_addr = IN_CLASSLESS_NET(n);
170 + }
171 + else if (IN_CLASSA(address)) netmask.s_addr = IN_CLASSA_NET;
172 + else if (IN_CLASSB(address)) netmask.s_addr = IN_CLASSB_NET;
173 + else netmask.s_addr = IN_CLASSC_NET;
174 + del_ipv4_address ( netdev );
175 + if ( ( rc = add_ipv4_address ( netdev, address, netmask,
176 + gateway ) ) != 0 ) {
177 + return rc;
178 + }
179 + if (dns) printf("dns=%s\n",dns);
180 + if (dns && inet_aton(dns, &nameserver))
181 + apply_nameserver(nameserver);
182 + }
183 route();
185 /* Try to boot an embedded image if we have one */