Diff markup
1 /* 1 /*
>> 2 * $Id: ipconfig.c,v 1.46 2002/02/01 22:01:04 davem Exp $
>> 3 *
2 * Automatic Configuration of IP -- use DHCP, 4 * Automatic Configuration of IP -- use DHCP, BOOTP, RARP, or
3 * user-supplied information to configure own 5 * user-supplied information to configure own IP address and routes.
4 * 6 *
5 * Copyright (C) 1996-1998 Martin Mares <mj@a 7 * Copyright (C) 1996-1998 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
6 * 8 *
7 * Derived from network configuration code in 9 * Derived from network configuration code in fs/nfs/nfsroot.c,
8 * originally Copyright (C) 1995, 1996 Gero K 10 * originally Copyright (C) 1995, 1996 Gero Kuhlmann and me.
9 * 11 *
10 * BOOTP rewritten to construct and analyse p 12 * BOOTP rewritten to construct and analyse packets itself instead
11 * of misusing the IP layer. num_bugs_causing 13 * of misusing the IP layer. num_bugs_causing_wrong_arp_replies--;
12 * - 14 * -- MJ, December 1998
13 * !! 15 *
14 * Fixed ip_auto_config_setup calling at star 16 * Fixed ip_auto_config_setup calling at startup in the new "Linker Magic"
15 * initialization scheme. 17 * initialization scheme.
16 * - Arnaldo Carvalho de Melo <acme@conec 18 * - Arnaldo Carvalho de Melo <acme@conectiva.com.br>, 08/11/1999
17 * 19 *
18 * DHCP support added. To users this looks l 20 * DHCP support added. To users this looks like a whole separate
19 * protocol, but we know it's just a bag on t 21 * protocol, but we know it's just a bag on the side of BOOTP.
20 * -- Chip Salzenberg <chip@valin 22 * -- Chip Salzenberg <chip@valinux.com>, May 2000
21 * 23 *
22 * Ported DHCP support from 2.2.16 to 2.4.0-t 24 * Ported DHCP support from 2.2.16 to 2.4.0-test4
23 * -- Eric Biederman <ebiederman@ 25 * -- Eric Biederman <ebiederman@lnxi.com>, 30 Aug 2000
24 * 26 *
25 * Merged changes from 2.2.19 into 2.4.3 27 * Merged changes from 2.2.19 into 2.4.3
26 * -- Eric Biederman <ebiederman@ 28 * -- Eric Biederman <ebiederman@lnxi.com>, 22 April Aug 2001
27 * 29 *
28 * Multiple Nameservers in /proc/net/pnp 30 * Multiple Nameservers in /proc/net/pnp
29 * -- Josef Siemes <jsiemes@web. 31 * -- Josef Siemes <jsiemes@web.de>, Aug 2002
30 */ 32 */
31 33
>> 34 #include <linux/config.h>
32 #include <linux/types.h> 35 #include <linux/types.h>
33 #include <linux/string.h> 36 #include <linux/string.h>
34 #include <linux/kernel.h> 37 #include <linux/kernel.h>
35 #include <linux/jiffies.h> 38 #include <linux/jiffies.h>
36 #include <linux/random.h> 39 #include <linux/random.h>
37 #include <linux/init.h> 40 #include <linux/init.h>
38 #include <linux/utsname.h> 41 #include <linux/utsname.h>
39 #include <linux/in.h> 42 #include <linux/in.h>
40 #include <linux/if.h> 43 #include <linux/if.h>
41 #include <linux/inet.h> 44 #include <linux/inet.h>
42 #include <linux/inetdevice.h> <<
43 #include <linux/netdevice.h> 45 #include <linux/netdevice.h>
44 #include <linux/if_arp.h> 46 #include <linux/if_arp.h>
45 #include <linux/skbuff.h> 47 #include <linux/skbuff.h>
46 #include <linux/ip.h> 48 #include <linux/ip.h>
47 #include <linux/socket.h> 49 #include <linux/socket.h>
48 #include <linux/route.h> 50 #include <linux/route.h>
49 #include <linux/udp.h> 51 #include <linux/udp.h>
50 #include <linux/proc_fs.h> 52 #include <linux/proc_fs.h>
51 #include <linux/seq_file.h> 53 #include <linux/seq_file.h>
52 #include <linux/major.h> 54 #include <linux/major.h>
53 #include <linux/root_dev.h> 55 #include <linux/root_dev.h>
54 #include <linux/delay.h> 56 #include <linux/delay.h>
55 #include <linux/nfs_fs.h> <<
56 #include <net/net_namespace.h> <<
57 #include <net/arp.h> 57 #include <net/arp.h>
58 #include <net/ip.h> 58 #include <net/ip.h>
59 #include <net/ipconfig.h> 59 #include <net/ipconfig.h>
60 #include <net/route.h> <<
61 60
62 #include <asm/uaccess.h> 61 #include <asm/uaccess.h>
63 #include <net/checksum.h> 62 #include <net/checksum.h>
64 #include <asm/processor.h> 63 #include <asm/processor.h>
65 64
66 /* Define this to allow debugging output */ 65 /* Define this to allow debugging output */
67 #undef IPCONFIG_DEBUG 66 #undef IPCONFIG_DEBUG
68 67
69 #ifdef IPCONFIG_DEBUG 68 #ifdef IPCONFIG_DEBUG
70 #define DBG(x) printk x 69 #define DBG(x) printk x
71 #else 70 #else
72 #define DBG(x) do { } while(0) 71 #define DBG(x) do { } while(0)
73 #endif 72 #endif
74 73
75 #if defined(CONFIG_IP_PNP_DHCP) 74 #if defined(CONFIG_IP_PNP_DHCP)
76 #define IPCONFIG_DHCP 75 #define IPCONFIG_DHCP
77 #endif 76 #endif
78 #if defined(CONFIG_IP_PNP_BOOTP) || defined(CO 77 #if defined(CONFIG_IP_PNP_BOOTP) || defined(CONFIG_IP_PNP_DHCP)
79 #define IPCONFIG_BOOTP 78 #define IPCONFIG_BOOTP
80 #endif 79 #endif
81 #if defined(CONFIG_IP_PNP_RARP) 80 #if defined(CONFIG_IP_PNP_RARP)
82 #define IPCONFIG_RARP 81 #define IPCONFIG_RARP
83 #endif 82 #endif
84 #if defined(IPCONFIG_BOOTP) || defined(IPCONFI 83 #if defined(IPCONFIG_BOOTP) || defined(IPCONFIG_RARP)
85 #define IPCONFIG_DYNAMIC 84 #define IPCONFIG_DYNAMIC
86 #endif 85 #endif
87 86
88 /* Define the friendly delay before and after 87 /* Define the friendly delay before and after opening net devices */
89 #define CONF_PRE_OPEN 500 /* Bef 88 #define CONF_PRE_OPEN 500 /* Before opening: 1/2 second */
90 #define CONF_POST_OPEN 1 /* Aft 89 #define CONF_POST_OPEN 1 /* After opening: 1 second */
91 90
92 /* Define the timeout for waiting for a DHCP/B 91 /* Define the timeout for waiting for a DHCP/BOOTP/RARP reply */
93 #define CONF_OPEN_RETRIES 2 /* (Re 92 #define CONF_OPEN_RETRIES 2 /* (Re)open devices twice */
94 #define CONF_SEND_RETRIES 6 /* Sen 93 #define CONF_SEND_RETRIES 6 /* Send six requests per open */
95 #define CONF_INTER_TIMEOUT (HZ/2) /* Int 94 #define CONF_INTER_TIMEOUT (HZ/2) /* Inter-device timeout: 1/2 second */
96 #define CONF_BASE_TIMEOUT (HZ*2) /* Ini 95 #define CONF_BASE_TIMEOUT (HZ*2) /* Initial timeout: 2 seconds */
97 #define CONF_TIMEOUT_RANDOM (HZ) /* Max 96 #define CONF_TIMEOUT_RANDOM (HZ) /* Maximum amount of randomization */
98 #define CONF_TIMEOUT_MULT *7/4 /* Rat 97 #define CONF_TIMEOUT_MULT *7/4 /* Rate of timeout growth */
99 #define CONF_TIMEOUT_MAX (HZ*30) /* Max 98 #define CONF_TIMEOUT_MAX (HZ*30) /* Maximum allowed timeout */
100 #define CONF_NAMESERVERS_MAX 3 /* Maxi !! 99 #define CONF_NAMESERVERS_MAX 3 /* Maximum number of nameservers
101 - ' !! 100 - '3' from resolv.h */
102 101
103 #define NONE cpu_to_be32(INADDR_NONE) <<
104 #define ANY cpu_to_be32(INADDR_ANY) <<
105 102
106 /* 103 /*
107 * Public IP configuration 104 * Public IP configuration
108 */ 105 */
109 106
110 /* This is used by platforms which might be ab 107 /* This is used by platforms which might be able to set the ipconfig
111 * variables using firmware environment vars. 108 * variables using firmware environment vars. If this is set, it will
112 * ignore such firmware variables. 109 * ignore such firmware variables.
113 */ 110 */
114 int ic_set_manually __initdata = 0; 111 int ic_set_manually __initdata = 0; /* IPconfig parameters set manually */
115 112
116 static int ic_enable __initdata = 0; 113 static int ic_enable __initdata = 0; /* IP config enabled? */
117 114
118 /* Protocol choice */ 115 /* Protocol choice */
119 int ic_proto_enabled __initdata = 0 116 int ic_proto_enabled __initdata = 0
120 #ifdef IPCONFIG_BOOTP 117 #ifdef IPCONFIG_BOOTP
121 | IC_BOOTP 118 | IC_BOOTP
122 #endif 119 #endif
123 #ifdef CONFIG_IP_PNP_DHCP 120 #ifdef CONFIG_IP_PNP_DHCP
124 | IC_USE_DHCP 121 | IC_USE_DHCP
125 #endif 122 #endif
126 #ifdef IPCONFIG_RARP 123 #ifdef IPCONFIG_RARP
127 | IC_RARP 124 | IC_RARP
128 #endif 125 #endif
129 ; 126 ;
130 127
131 static int ic_host_name_set __initdata = 0; 128 static int ic_host_name_set __initdata = 0; /* Host name set by us? */
132 129
133 __be32 ic_myaddr = NONE; /* My !! 130 u32 ic_myaddr = INADDR_NONE; /* My IP address */
134 static __be32 ic_netmask = NONE; /* Net !! 131 static u32 ic_netmask = INADDR_NONE; /* Netmask for local subnet */
135 __be32 ic_gateway = NONE; /* Gateway IP !! 132 u32 ic_gateway = INADDR_NONE; /* Gateway IP address */
136 133
137 __be32 ic_servaddr = NONE; /* Boot server !! 134 u32 ic_servaddr = INADDR_NONE; /* Boot server IP address */
138 135
139 __be32 root_server_addr = NONE; /* Address of !! 136 u32 root_server_addr = INADDR_NONE; /* Address of NFS server */
140 u8 root_server_path[256] = { 0, }; /* Pat 137 u8 root_server_path[256] = { 0, }; /* Path to mount as root */
141 138
142 u32 ic_dev_xid; /* Device under config <<
143 <<
144 /* vendor class identifier */ <<
145 static char vendor_class_identifier[253] __ini <<
146 <<
147 /* Persistent data: */ 139 /* Persistent data: */
148 140
149 static int ic_proto_used; 141 static int ic_proto_used; /* Protocol used, if any */
150 static __be32 ic_nameservers[CONF_NAMESERVERS_ !! 142 static u32 ic_nameservers[CONF_NAMESERVERS_MAX]; /* DNS Server IP addresses */
151 static u8 ic_domain[64]; /* DNS 143 static u8 ic_domain[64]; /* DNS (not NIS) domain name */
152 144
153 /* 145 /*
154 * Private state. 146 * Private state.
155 */ 147 */
156 148
157 /* Name of user-selected boot device */ 149 /* Name of user-selected boot device */
158 static char user_dev_name[IFNAMSIZ] __initdata 150 static char user_dev_name[IFNAMSIZ] __initdata = { 0, };
159 151
160 /* Protocols supported by available interfaces 152 /* Protocols supported by available interfaces */
161 static int ic_proto_have_if __initdata = 0; 153 static int ic_proto_have_if __initdata = 0;
162 154
163 /* MTU for boot device */ <<
164 static int ic_dev_mtu __initdata = 0; <<
165 <<
166 #ifdef IPCONFIG_DYNAMIC 155 #ifdef IPCONFIG_DYNAMIC
167 static DEFINE_SPINLOCK(ic_recv_lock); 156 static DEFINE_SPINLOCK(ic_recv_lock);
168 static volatile int ic_got_reply __initdata = 157 static volatile int ic_got_reply __initdata = 0; /* Proto(s) that replied */
169 #endif 158 #endif
170 #ifdef IPCONFIG_DHCP 159 #ifdef IPCONFIG_DHCP
171 static int ic_dhcp_msgtype __initdata = 0; 160 static int ic_dhcp_msgtype __initdata = 0; /* DHCP msg type received */
172 #endif 161 #endif
173 162
174 163
175 /* 164 /*
176 * Network devices 165 * Network devices
177 */ 166 */
178 167
179 struct ic_device { 168 struct ic_device {
180 struct ic_device *next; 169 struct ic_device *next;
181 struct net_device *dev; 170 struct net_device *dev;
182 unsigned short flags; 171 unsigned short flags;
183 short able; 172 short able;
184 __be32 xid; !! 173 u32 xid;
185 }; 174 };
186 175
187 static struct ic_device *ic_first_dev __initda 176 static struct ic_device *ic_first_dev __initdata = NULL;/* List of open device */
188 static struct net_device *ic_dev __initdata = 177 static struct net_device *ic_dev __initdata = NULL; /* Selected device */
189 178
190 static int __init ic_open_devs(void) 179 static int __init ic_open_devs(void)
191 { 180 {
192 struct ic_device *d, **last; 181 struct ic_device *d, **last;
193 struct net_device *dev; 182 struct net_device *dev;
194 unsigned short oflags; 183 unsigned short oflags;
195 184
196 last = &ic_first_dev; 185 last = &ic_first_dev;
197 rtnl_lock(); !! 186 rtnl_shlock();
198 187
199 /* bring loopback device up first */ 188 /* bring loopback device up first */
200 for_each_netdev(&init_net, dev) { !! 189 if (dev_change_flags(&loopback_dev, loopback_dev.flags | IFF_UP) < 0)
201 if (!(dev->flags & IFF_LOOPBAC !! 190 printk(KERN_ERR "IP-Config: Failed to open %s\n", loopback_dev.name);
202 continue; <<
203 if (dev_change_flags(dev, dev- <<
204 printk(KERN_ERR "IP-Co <<
205 } <<
206 191
207 for_each_netdev(&init_net, dev) { !! 192 for (dev = dev_base; dev; dev = dev->next) {
208 if (dev->flags & IFF_LOOPBACK) !! 193 if (dev == &loopback_dev)
209 continue; 194 continue;
210 if (user_dev_name[0] ? !strcmp 195 if (user_dev_name[0] ? !strcmp(dev->name, user_dev_name) :
211 (!(dev->flags & IFF_LOOPBA 196 (!(dev->flags & IFF_LOOPBACK) &&
212 (dev->flags & (IFF_POINTO 197 (dev->flags & (IFF_POINTOPOINT|IFF_BROADCAST)) &&
213 strncmp(dev->name, "dummy 198 strncmp(dev->name, "dummy", 5))) {
214 int able = 0; 199 int able = 0;
215 if (dev->mtu >= 364) 200 if (dev->mtu >= 364)
216 able |= IC_BOO 201 able |= IC_BOOTP;
217 else 202 else
218 printk(KERN_WA 203 printk(KERN_WARNING "DHCP/BOOTP: Ignoring device %s, MTU %d too small", dev->name, dev->mtu);
219 if (!(dev->flags & IFF 204 if (!(dev->flags & IFF_NOARP))
220 able |= IC_RAR 205 able |= IC_RARP;
221 able &= ic_proto_enabl 206 able &= ic_proto_enabled;
222 if (ic_proto_enabled & 207 if (ic_proto_enabled && !able)
223 continue; 208 continue;
224 oflags = dev->flags; 209 oflags = dev->flags;
225 if (dev_change_flags(d 210 if (dev_change_flags(dev, oflags | IFF_UP) < 0) {
226 printk(KERN_ER 211 printk(KERN_ERR "IP-Config: Failed to open %s\n", dev->name);
227 continue; 212 continue;
228 } 213 }
229 if (!(d = kmalloc(size 214 if (!(d = kmalloc(sizeof(struct ic_device), GFP_KERNEL))) {
230 rtnl_unlock(); !! 215 rtnl_shunlock();
231 return -1; 216 return -1;
232 } 217 }
233 d->dev = dev; 218 d->dev = dev;
234 *last = d; 219 *last = d;
235 last = &d->next; 220 last = &d->next;
236 d->flags = oflags; 221 d->flags = oflags;
237 d->able = able; 222 d->able = able;
238 if (able & IC_BOOTP) 223 if (able & IC_BOOTP)
239 get_random_byt !! 224 get_random_bytes(&d->xid, sizeof(u32));
240 else 225 else
241 d->xid = 0; 226 d->xid = 0;
242 ic_proto_have_if |= ab 227 ic_proto_have_if |= able;
243 DBG(("IP-Config: %s UP 228 DBG(("IP-Config: %s UP (able=%d, xid=%08x)\n",
244 dev->name, abl 229 dev->name, able, d->xid));
245 } 230 }
246 } 231 }
247 rtnl_unlock(); !! 232 rtnl_shunlock();
248 233
249 *last = NULL; 234 *last = NULL;
250 235
251 if (!ic_first_dev) { 236 if (!ic_first_dev) {
252 if (user_dev_name[0]) 237 if (user_dev_name[0])
253 printk(KERN_ERR "IP-Co 238 printk(KERN_ERR "IP-Config: Device `%s' not found.\n", user_dev_name);
254 else 239 else
255 printk(KERN_ERR "IP-Co 240 printk(KERN_ERR "IP-Config: No network devices available.\n");
256 return -1; 241 return -1;
257 } 242 }
258 return 0; 243 return 0;
259 } 244 }
260 245
261 static void __init ic_close_devs(void) 246 static void __init ic_close_devs(void)
262 { 247 {
263 struct ic_device *d, *next; 248 struct ic_device *d, *next;
264 struct net_device *dev; 249 struct net_device *dev;
265 250
266 rtnl_lock(); !! 251 rtnl_shlock();
267 next = ic_first_dev; 252 next = ic_first_dev;
268 while ((d = next)) { 253 while ((d = next)) {
269 next = d->next; 254 next = d->next;
270 dev = d->dev; 255 dev = d->dev;
271 if (dev != ic_dev) { 256 if (dev != ic_dev) {
272 DBG(("IP-Config: Downi 257 DBG(("IP-Config: Downing %s\n", dev->name));
273 dev_change_flags(dev, 258 dev_change_flags(dev, d->flags);
274 } 259 }
275 kfree(d); 260 kfree(d);
276 } 261 }
277 rtnl_unlock(); !! 262 rtnl_shunlock();
278 } 263 }
279 264
280 /* 265 /*
281 * Interface to various network functions 266 * Interface to various network functions.
282 */ 267 */
283 268
284 static inline void 269 static inline void
285 set_sockaddr(struct sockaddr_in *sin, __be32 a !! 270 set_sockaddr(struct sockaddr_in *sin, u32 addr, u16 port)
286 { 271 {
287 sin->sin_family = AF_INET; 272 sin->sin_family = AF_INET;
288 sin->sin_addr.s_addr = addr; 273 sin->sin_addr.s_addr = addr;
289 sin->sin_port = port; 274 sin->sin_port = port;
290 } 275 }
291 276
292 static int __init ic_devinet_ioctl(unsigned in <<
293 { <<
294 int res; <<
295 <<
296 mm_segment_t oldfs = get_fs(); <<
297 set_fs(get_ds()); <<
298 res = devinet_ioctl(&init_net, cmd, (s <<
299 set_fs(oldfs); <<
300 return res; <<
301 } <<
302 <<
303 static int __init ic_dev_ioctl(unsigned int cm 277 static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
304 { 278 {
305 int res; 279 int res;
306 280
307 mm_segment_t oldfs = get_fs(); 281 mm_segment_t oldfs = get_fs();
308 set_fs(get_ds()); 282 set_fs(get_ds());
309 res = dev_ioctl(&init_net, cmd, (struc !! 283 res = devinet_ioctl(cmd, (struct ifreq __user *) arg);
310 set_fs(oldfs); 284 set_fs(oldfs);
311 return res; 285 return res;
312 } 286 }
313 287
314 static int __init ic_route_ioctl(unsigned int 288 static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
315 { 289 {
316 int res; 290 int res;
317 291
318 mm_segment_t oldfs = get_fs(); 292 mm_segment_t oldfs = get_fs();
319 set_fs(get_ds()); 293 set_fs(get_ds());
320 res = ip_rt_ioctl(&init_net, cmd, (voi !! 294 res = ip_rt_ioctl(cmd, (void __user *) arg);
321 set_fs(oldfs); 295 set_fs(oldfs);
322 return res; 296 return res;
323 } 297 }
324 298
325 /* 299 /*
326 * Set up interface addresses and routes. 300 * Set up interface addresses and routes.
327 */ 301 */
328 302
329 static int __init ic_setup_if(void) 303 static int __init ic_setup_if(void)
330 { 304 {
331 struct ifreq ir; 305 struct ifreq ir;
332 struct sockaddr_in *sin = (void *) &ir 306 struct sockaddr_in *sin = (void *) &ir.ifr_ifru.ifru_addr;
333 int err; 307 int err;
334 308
335 memset(&ir, 0, sizeof(ir)); 309 memset(&ir, 0, sizeof(ir));
336 strcpy(ir.ifr_ifrn.ifrn_name, ic_dev-> 310 strcpy(ir.ifr_ifrn.ifrn_name, ic_dev->name);
337 set_sockaddr(sin, ic_myaddr, 0); 311 set_sockaddr(sin, ic_myaddr, 0);
338 if ((err = ic_devinet_ioctl(SIOCSIFADD !! 312 if ((err = ic_dev_ioctl(SIOCSIFADDR, &ir)) < 0) {
339 printk(KERN_ERR "IP-Config: Un 313 printk(KERN_ERR "IP-Config: Unable to set interface address (%d).\n", err);
340 return -1; 314 return -1;
341 } 315 }
342 set_sockaddr(sin, ic_netmask, 0); 316 set_sockaddr(sin, ic_netmask, 0);
343 if ((err = ic_devinet_ioctl(SIOCSIFNET !! 317 if ((err = ic_dev_ioctl(SIOCSIFNETMASK, &ir)) < 0) {
344 printk(KERN_ERR "IP-Config: Un 318 printk(KERN_ERR "IP-Config: Unable to set interface netmask (%d).\n", err);
345 return -1; 319 return -1;
346 } 320 }
347 set_sockaddr(sin, ic_myaddr | ~ic_netm 321 set_sockaddr(sin, ic_myaddr | ~ic_netmask, 0);
348 if ((err = ic_devinet_ioctl(SIOCSIFBRD !! 322 if ((err = ic_dev_ioctl(SIOCSIFBRDADDR, &ir)) < 0) {
349 printk(KERN_ERR "IP-Config: Un 323 printk(KERN_ERR "IP-Config: Unable to set interface broadcast address (%d).\n", err);
350 return -1; 324 return -1;
351 } 325 }
352 /* Handle the case where we need non-s <<
353 * using jumbo frames, for instance). <<
354 * out, we'll try to muddle along. <<
355 */ <<
356 if (ic_dev_mtu != 0) { <<
357 strcpy(ir.ifr_name, ic_dev->na <<
358 ir.ifr_mtu = ic_dev_mtu; <<
359 if ((err = ic_dev_ioctl(SIOCSI <<
360 printk(KERN_ERR "IP-Co <<
361 ic_de <<
362 } <<
363 return 0; 326 return 0;
364 } 327 }
365 328
366 static int __init ic_setup_routes(void) 329 static int __init ic_setup_routes(void)
367 { 330 {
368 /* No need to setup device routes, onl 331 /* No need to setup device routes, only the default route... */
369 332
370 if (ic_gateway != NONE) { !! 333 if (ic_gateway != INADDR_NONE) {
371 struct rtentry rm; 334 struct rtentry rm;
372 int err; 335 int err;
373 336
374 memset(&rm, 0, sizeof(rm)); 337 memset(&rm, 0, sizeof(rm));
375 if ((ic_gateway ^ ic_myaddr) & 338 if ((ic_gateway ^ ic_myaddr) & ic_netmask) {
376 printk(KERN_ERR "IP-Co 339 printk(KERN_ERR "IP-Config: Gateway not on directly connected network.\n");
377 return -1; 340 return -1;
378 } 341 }
379 set_sockaddr((struct sockaddr_ 342 set_sockaddr((struct sockaddr_in *) &rm.rt_dst, 0, 0);
380 set_sockaddr((struct sockaddr_ 343 set_sockaddr((struct sockaddr_in *) &rm.rt_genmask, 0, 0);
381 set_sockaddr((struct sockaddr_ 344 set_sockaddr((struct sockaddr_in *) &rm.rt_gateway, ic_gateway, 0);
382 rm.rt_flags = RTF_UP | RTF_GAT 345 rm.rt_flags = RTF_UP | RTF_GATEWAY;
383 if ((err = ic_route_ioctl(SIOC 346 if ((err = ic_route_ioctl(SIOCADDRT, &rm)) < 0) {
384 printk(KERN_ERR "IP-Co 347 printk(KERN_ERR "IP-Config: Cannot add default route (%d).\n", err);
385 return -1; 348 return -1;
386 } 349 }
387 } 350 }
388 351
389 return 0; 352 return 0;
390 } 353 }
391 354
392 /* 355 /*
393 * Fill in default values for all missing 356 * Fill in default values for all missing parameters.
394 */ 357 */
395 358
396 static int __init ic_defaults(void) 359 static int __init ic_defaults(void)
397 { 360 {
398 /* 361 /*
399 * At this point we have no users 362 * At this point we have no userspace running so need not
400 * claim locks on system_utsname 363 * claim locks on system_utsname
401 */ 364 */
402 !! 365
403 if (!ic_host_name_set) 366 if (!ic_host_name_set)
404 sprintf(init_utsname()->nodena !! 367 sprintf(system_utsname.nodename, "%u.%u.%u.%u", NIPQUAD(ic_myaddr));
405 368
406 if (root_server_addr == NONE) !! 369 if (root_server_addr == INADDR_NONE)
407 root_server_addr = ic_servaddr 370 root_server_addr = ic_servaddr;
408 371
409 if (ic_netmask == NONE) { !! 372 if (ic_netmask == INADDR_NONE) {
410 if (IN_CLASSA(ntohl(ic_myaddr) 373 if (IN_CLASSA(ntohl(ic_myaddr)))
411 ic_netmask = htonl(IN_ 374 ic_netmask = htonl(IN_CLASSA_NET);
412 else if (IN_CLASSB(ntohl(ic_my 375 else if (IN_CLASSB(ntohl(ic_myaddr)))
413 ic_netmask = htonl(IN_ 376 ic_netmask = htonl(IN_CLASSB_NET);
414 else if (IN_CLASSC(ntohl(ic_my 377 else if (IN_CLASSC(ntohl(ic_myaddr)))
415 ic_netmask = htonl(IN_ 378 ic_netmask = htonl(IN_CLASSC_NET);
416 else { 379 else {
417 printk(KERN_ERR "IP-Co !! 380 printk(KERN_ERR "IP-Config: Unable to guess netmask for address %u.%u.%u.%u\n",
418 &ic_myaddr); !! 381 NIPQUAD(ic_myaddr));
419 return -1; 382 return -1;
420 } 383 }
421 printk("IP-Config: Guessing ne !! 384 printk("IP-Config: Guessing netmask %u.%u.%u.%u\n", NIPQUAD(ic_netmask));
422 } 385 }
423 386
424 return 0; 387 return 0;
425 } 388 }
426 389
427 /* 390 /*
428 * RARP support. 391 * RARP support.
429 */ 392 */
430 393
431 #ifdef IPCONFIG_RARP 394 #ifdef IPCONFIG_RARP
432 395
433 static int ic_rarp_recv(struct sk_buff *skb, s !! 396 static int ic_rarp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt);
434 397
435 static struct packet_type rarp_packet_type __i 398 static struct packet_type rarp_packet_type __initdata = {
436 .type = cpu_to_be16(ETH_P_RARP), !! 399 .type = __constant_htons(ETH_P_RARP),
437 .func = ic_rarp_recv, 400 .func = ic_rarp_recv,
438 }; 401 };
439 402
440 static inline void __init ic_rarp_init(void) !! 403 static inline void ic_rarp_init(void)
441 { 404 {
442 dev_add_pack(&rarp_packet_type); 405 dev_add_pack(&rarp_packet_type);
443 } 406 }
444 407
445 static inline void __init ic_rarp_cleanup(void !! 408 static inline void ic_rarp_cleanup(void)
446 { 409 {
447 dev_remove_pack(&rarp_packet_type); 410 dev_remove_pack(&rarp_packet_type);
448 } 411 }
449 412
450 /* 413 /*
451 * Process received RARP packet. 414 * Process received RARP packet.
452 */ 415 */
453 static int __init 416 static int __init
454 ic_rarp_recv(struct sk_buff *skb, struct net_d !! 417 ic_rarp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt)
455 { 418 {
456 struct arphdr *rarp; 419 struct arphdr *rarp;
457 unsigned char *rarp_ptr; 420 unsigned char *rarp_ptr;
458 __be32 sip, tip; !! 421 unsigned long sip, tip;
459 unsigned char *sha, *tha; 422 unsigned char *sha, *tha; /* s for "source", t for "target" */
460 struct ic_device *d; 423 struct ic_device *d;
461 424
462 if (!net_eq(dev_net(dev), &init_net)) <<
463 goto drop; <<
464 <<
465 if ((skb = skb_share_check(skb, GFP_AT 425 if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL)
466 return NET_RX_DROP; 426 return NET_RX_DROP;
467 427
468 if (!pskb_may_pull(skb, sizeof(struct 428 if (!pskb_may_pull(skb, sizeof(struct arphdr)))
469 goto drop; 429 goto drop;
470 430
471 /* Basic sanity checks can be done wit 431 /* Basic sanity checks can be done without the lock. */
472 rarp = (struct arphdr *)skb_transport_ !! 432 rarp = (struct arphdr *)skb->h.raw;
473 433
474 /* If this test doesn't pass, it's not 434 /* If this test doesn't pass, it's not IP, or we should
475 * ignore it anyway. 435 * ignore it anyway.
476 */ 436 */
477 if (rarp->ar_hln != dev->addr_len || d 437 if (rarp->ar_hln != dev->addr_len || dev->type != ntohs(rarp->ar_hrd))
478 goto drop; 438 goto drop;
479 439
480 /* If it's not a RARP reply, delete it 440 /* If it's not a RARP reply, delete it. */
481 if (rarp->ar_op != htons(ARPOP_RREPLY) 441 if (rarp->ar_op != htons(ARPOP_RREPLY))
482 goto drop; 442 goto drop;
483 443
484 /* If it's not Ethernet, delete it. */ 444 /* If it's not Ethernet, delete it. */
485 if (rarp->ar_pro != htons(ETH_P_IP)) 445 if (rarp->ar_pro != htons(ETH_P_IP))
486 goto drop; 446 goto drop;
487 447
488 if (!pskb_may_pull(skb, arp_hdr_len(de !! 448 if (!pskb_may_pull(skb,
>> 449 sizeof(struct arphdr) +
>> 450 (2 * dev->addr_len) +
>> 451 (2 * 4)))
489 goto drop; 452 goto drop;
490 453
491 /* OK, it is all there and looks valid 454 /* OK, it is all there and looks valid, process... */
492 rarp = (struct arphdr *)skb_transport_ !! 455 rarp = (struct arphdr *)skb->h.raw;
493 rarp_ptr = (unsigned char *) (rarp + 1 456 rarp_ptr = (unsigned char *) (rarp + 1);
494 457
495 /* One reply at a time, please. */ 458 /* One reply at a time, please. */
496 spin_lock(&ic_recv_lock); 459 spin_lock(&ic_recv_lock);
497 460
498 /* If we already have a reply, just dr 461 /* If we already have a reply, just drop the packet */
499 if (ic_got_reply) 462 if (ic_got_reply)
500 goto drop_unlock; 463 goto drop_unlock;
501 464
502 /* Find the ic_device that the packet 465 /* Find the ic_device that the packet arrived on */
503 d = ic_first_dev; 466 d = ic_first_dev;
504 while (d && d->dev != dev) 467 while (d && d->dev != dev)
505 d = d->next; 468 d = d->next;
506 if (!d) 469 if (!d)
507 goto drop_unlock; /* sho 470 goto drop_unlock; /* should never happen */
508 471
509 /* Extract variable-width fields */ 472 /* Extract variable-width fields */
510 sha = rarp_ptr; 473 sha = rarp_ptr;
511 rarp_ptr += dev->addr_len; 474 rarp_ptr += dev->addr_len;
512 memcpy(&sip, rarp_ptr, 4); 475 memcpy(&sip, rarp_ptr, 4);
513 rarp_ptr += 4; 476 rarp_ptr += 4;
514 tha = rarp_ptr; 477 tha = rarp_ptr;
515 rarp_ptr += dev->addr_len; 478 rarp_ptr += dev->addr_len;
516 memcpy(&tip, rarp_ptr, 4); 479 memcpy(&tip, rarp_ptr, 4);
517 480
518 /* Discard packets which are not meant 481 /* Discard packets which are not meant for us. */
519 if (memcmp(tha, dev->dev_addr, dev->ad 482 if (memcmp(tha, dev->dev_addr, dev->addr_len))
520 goto drop_unlock; 483 goto drop_unlock;
521 484
522 /* Discard packets which are not from 485 /* Discard packets which are not from specified server. */
523 if (ic_servaddr != NONE && ic_servaddr !! 486 if (ic_servaddr != INADDR_NONE && ic_servaddr != sip)
524 goto drop_unlock; 487 goto drop_unlock;
525 488
526 /* We have a winner! */ 489 /* We have a winner! */
527 ic_dev = dev; 490 ic_dev = dev;
528 if (ic_myaddr == NONE) !! 491 if (ic_myaddr == INADDR_NONE)
529 ic_myaddr = tip; 492 ic_myaddr = tip;
530 ic_servaddr = sip; 493 ic_servaddr = sip;
531 ic_got_reply = IC_RARP; 494 ic_got_reply = IC_RARP;
532 495
533 drop_unlock: 496 drop_unlock:
534 /* Show's over. Nothing to see here. 497 /* Show's over. Nothing to see here. */
535 spin_unlock(&ic_recv_lock); 498 spin_unlock(&ic_recv_lock);
536 499
537 drop: 500 drop:
538 /* Throw the packet out. */ 501 /* Throw the packet out. */
539 kfree_skb(skb); 502 kfree_skb(skb);
540 return 0; 503 return 0;
541 } 504 }
542 505
543 506
544 /* 507 /*
545 * Send RARP request packet over a single int 508 * Send RARP request packet over a single interface.
546 */ 509 */
547 static void __init ic_rarp_send_if(struct ic_d 510 static void __init ic_rarp_send_if(struct ic_device *d)
548 { 511 {
549 struct net_device *dev = d->dev; 512 struct net_device *dev = d->dev;
550 arp_send(ARPOP_RREQUEST, ETH_P_RARP, 0 513 arp_send(ARPOP_RREQUEST, ETH_P_RARP, 0, dev, 0, NULL,
551 dev->dev_addr, dev->dev_addr) 514 dev->dev_addr, dev->dev_addr);
552 } 515 }
553 #endif 516 #endif
554 517
555 /* 518 /*
556 * DHCP/BOOTP support. 519 * DHCP/BOOTP support.
557 */ 520 */
558 521
559 #ifdef IPCONFIG_BOOTP 522 #ifdef IPCONFIG_BOOTP
560 523
561 struct bootp_pkt { /* BOOTP packe 524 struct bootp_pkt { /* BOOTP packet format */
562 struct iphdr iph; /* IP header * 525 struct iphdr iph; /* IP header */
563 struct udphdr udph; /* UDP header 526 struct udphdr udph; /* UDP header */
564 u8 op; /* 1=request, 527 u8 op; /* 1=request, 2=reply */
565 u8 htype; /* HW address 528 u8 htype; /* HW address type */
566 u8 hlen; /* HW address 529 u8 hlen; /* HW address length */
567 u8 hops; /* Used only b 530 u8 hops; /* Used only by gateways */
568 __be32 xid; /* Transaction !! 531 u32 xid; /* Transaction ID */
569 __be16 secs; /* Seconds sin !! 532 u16 secs; /* Seconds since we started */
570 __be16 flags; /* Just what i !! 533 u16 flags; /* Just what it says */
571 __be32 client_ip; /* Cli !! 534 u32 client_ip; /* Client's IP address if known */
572 __be32 your_ip; /* Assigned IP !! 535 u32 your_ip; /* Assigned IP address */
573 __be32 server_ip; /* (Ne !! 536 u32 server_ip; /* (Next, e.g. NFS) Server's IP address */
574 __be32 relay_ip; /* IP !! 537 u32 relay_ip; /* IP address of BOOTP relay */
575 u8 hw_addr[16]; /* Client's HW 538 u8 hw_addr[16]; /* Client's HW address */
576 u8 serv_name[64]; /* Server host 539 u8 serv_name[64]; /* Server host name */
577 u8 boot_file[128]; /* Name of boo 540 u8 boot_file[128]; /* Name of boot file */
578 u8 exten[312]; /* DHCP option 541 u8 exten[312]; /* DHCP options / BOOTP vendor extensions */
579 }; 542 };
580 543
581 /* packet ops */ 544 /* packet ops */
582 #define BOOTP_REQUEST 1 545 #define BOOTP_REQUEST 1
583 #define BOOTP_REPLY 2 546 #define BOOTP_REPLY 2
584 547
585 /* DHCP message types */ 548 /* DHCP message types */
586 #define DHCPDISCOVER 1 549 #define DHCPDISCOVER 1
587 #define DHCPOFFER 2 550 #define DHCPOFFER 2
588 #define DHCPREQUEST 3 551 #define DHCPREQUEST 3
589 #define DHCPDECLINE 4 552 #define DHCPDECLINE 4
590 #define DHCPACK 5 553 #define DHCPACK 5
591 #define DHCPNAK 6 554 #define DHCPNAK 6
592 #define DHCPRELEASE 7 555 #define DHCPRELEASE 7
593 #define DHCPINFORM 8 556 #define DHCPINFORM 8
594 557
595 static int ic_bootp_recv(struct sk_buff *skb, !! 558 static int ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt);
596 559
597 static struct packet_type bootp_packet_type __ 560 static struct packet_type bootp_packet_type __initdata = {
598 .type = cpu_to_be16(ETH_P_IP), !! 561 .type = __constant_htons(ETH_P_IP),
599 .func = ic_bootp_recv, 562 .func = ic_bootp_recv,
600 }; 563 };
601 564
602 565
603 /* 566 /*
604 * Initialize DHCP/BOOTP extension fields in 567 * Initialize DHCP/BOOTP extension fields in the request.
605 */ 568 */
606 569
607 static const u8 ic_bootp_cookie[4] = { 99, 130 570 static const u8 ic_bootp_cookie[4] = { 99, 130, 83, 99 };
608 571
609 #ifdef IPCONFIG_DHCP 572 #ifdef IPCONFIG_DHCP
610 573
611 static void __init 574 static void __init
612 ic_dhcp_init_options(u8 *options) 575 ic_dhcp_init_options(u8 *options)
613 { 576 {
614 u8 mt = ((ic_servaddr == NONE) !! 577 u8 mt = ((ic_servaddr == INADDR_NONE)
615 ? DHCPDISCOVER : DHCPREQUEST) 578 ? DHCPDISCOVER : DHCPREQUEST);
616 u8 *e = options; 579 u8 *e = options;
617 int len; <<
618 580
619 #ifdef IPCONFIG_DEBUG 581 #ifdef IPCONFIG_DEBUG
620 printk("DHCP: Sending message type %d\ 582 printk("DHCP: Sending message type %d\n", mt);
621 #endif 583 #endif
622 584
623 memcpy(e, ic_bootp_cookie, 4); /* RFC 585 memcpy(e, ic_bootp_cookie, 4); /* RFC1048 Magic Cookie */
624 e += 4; 586 e += 4;
625 587
626 *e++ = 53; /* DHCP messag 588 *e++ = 53; /* DHCP message type */
627 *e++ = 1; 589 *e++ = 1;
628 *e++ = mt; 590 *e++ = mt;
629 591
630 if (mt == DHCPREQUEST) { 592 if (mt == DHCPREQUEST) {
631 *e++ = 54; /* Server ID ( 593 *e++ = 54; /* Server ID (IP address) */
632 *e++ = 4; 594 *e++ = 4;
633 memcpy(e, &ic_servaddr, 4); 595 memcpy(e, &ic_servaddr, 4);
634 e += 4; 596 e += 4;
635 597
636 *e++ = 50; /* Requested I 598 *e++ = 50; /* Requested IP address */
637 *e++ = 4; 599 *e++ = 4;
638 memcpy(e, &ic_myaddr, 4); 600 memcpy(e, &ic_myaddr, 4);
639 e += 4; 601 e += 4;
640 } 602 }
641 603
642 /* always? */ 604 /* always? */
643 { 605 {
644 static const u8 ic_req_params[ 606 static const u8 ic_req_params[] = {
645 1, /* Subnet mask 607 1, /* Subnet mask */
646 3, /* Default gat 608 3, /* Default gateway */
647 6, /* DNS server 609 6, /* DNS server */
648 12, /* Host name * 610 12, /* Host name */
649 15, /* Domain name 611 15, /* Domain name */
650 17, /* Boot path * 612 17, /* Boot path */
651 26, /* MTU */ <<
652 40, /* NIS domain 613 40, /* NIS domain name */
653 }; 614 };
654 615
655 *e++ = 55; /* Parameter r 616 *e++ = 55; /* Parameter request list */
656 *e++ = sizeof(ic_req_params); 617 *e++ = sizeof(ic_req_params);
657 memcpy(e, ic_req_params, sizeo 618 memcpy(e, ic_req_params, sizeof(ic_req_params));
658 e += sizeof(ic_req_params); 619 e += sizeof(ic_req_params);
659 <<
660 if (*vendor_class_identifier) <<
661 printk(KERN_INFO "DHCP <<
662 vendor_class_id <<
663 *e++ = 60; /* Cla <<
664 len = strlen(vendor_cl <<
665 *e++ = len; <<
666 memcpy(e, vendor_class <<
667 e += len; <<
668 } <<
669 } 620 }
670 621
671 *e++ = 255; /* End of the list */ 622 *e++ = 255; /* End of the list */
672 } 623 }
673 624
674 #endif /* IPCONFIG_DHCP */ 625 #endif /* IPCONFIG_DHCP */
675 626
676 static void __init ic_bootp_init_ext(u8 *e) 627 static void __init ic_bootp_init_ext(u8 *e)
677 { 628 {
678 memcpy(e, ic_bootp_cookie, 4); /* RFC 629 memcpy(e, ic_bootp_cookie, 4); /* RFC1048 Magic Cookie */
679 e += 4; 630 e += 4;
680 *e++ = 1; /* Subnet mask 631 *e++ = 1; /* Subnet mask request */
681 *e++ = 4; 632 *e++ = 4;
682 e += 4; 633 e += 4;
683 *e++ = 3; /* Default gat 634 *e++ = 3; /* Default gateway request */
684 *e++ = 4; 635 *e++ = 4;
685 e += 4; 636 e += 4;
686 *e++ = 5; /* Name server 637 *e++ = 5; /* Name server request */
687 *e++ = 8; 638 *e++ = 8;
688 e += 8; 639 e += 8;
689 *e++ = 12; /* Host name r 640 *e++ = 12; /* Host name request */
690 *e++ = 32; 641 *e++ = 32;
691 e += 32; 642 e += 32;
692 *e++ = 40; /* NIS Domain 643 *e++ = 40; /* NIS Domain name request */
693 *e++ = 32; 644 *e++ = 32;
694 e += 32; 645 e += 32;
695 *e++ = 17; /* Boot path * 646 *e++ = 17; /* Boot path */
696 *e++ = 40; 647 *e++ = 40;
697 e += 40; 648 e += 40;
698 649
699 *e++ = 57; /* set extensi !! 650 *e++ = 57; /* set extension buffer size for reply */
700 *e++ = 2; 651 *e++ = 2;
701 *e++ = 1; /* 128+236+8+2 !! 652 *e++ = 1; /* 128+236+8+20+14, see dhcpd sources */
702 *e++ = 150; 653 *e++ = 150;
703 654
704 *e++ = 255; /* End of the 655 *e++ = 255; /* End of the list */
705 } 656 }
706 657
707 658
708 /* 659 /*
709 * Initialize the DHCP/BOOTP mechanism. 660 * Initialize the DHCP/BOOTP mechanism.
710 */ 661 */
711 static inline void __init ic_bootp_init(void) !! 662 static inline void ic_bootp_init(void)
712 { 663 {
713 int i; 664 int i;
714 665
715 for (i = 0; i < CONF_NAMESERVERS_MAX; 666 for (i = 0; i < CONF_NAMESERVERS_MAX; i++)
716 ic_nameservers[i] = NONE; !! 667 ic_nameservers[i] = INADDR_NONE;
717 668
718 dev_add_pack(&bootp_packet_type); 669 dev_add_pack(&bootp_packet_type);
719 } 670 }
720 671
721 672
722 /* 673 /*
723 * DHCP/BOOTP cleanup. 674 * DHCP/BOOTP cleanup.
724 */ 675 */
725 static inline void __init ic_bootp_cleanup(voi !! 676 static inline void ic_bootp_cleanup(void)
726 { 677 {
727 dev_remove_pack(&bootp_packet_type); 678 dev_remove_pack(&bootp_packet_type);
728 } 679 }
729 680
730 681
731 /* 682 /*
732 * Send DHCP/BOOTP request to single interfac 683 * Send DHCP/BOOTP request to single interface.
733 */ 684 */
734 static void __init ic_bootp_send_if(struct ic_ 685 static void __init ic_bootp_send_if(struct ic_device *d, unsigned long jiffies_diff)
735 { 686 {
736 struct net_device *dev = d->dev; 687 struct net_device *dev = d->dev;
737 struct sk_buff *skb; 688 struct sk_buff *skb;
738 struct bootp_pkt *b; 689 struct bootp_pkt *b;
>> 690 int hh_len = LL_RESERVED_SPACE(dev);
739 struct iphdr *h; 691 struct iphdr *h;
740 692
741 /* Allocate packet */ 693 /* Allocate packet */
742 skb = alloc_skb(sizeof(struct bootp_pk !! 694 skb = alloc_skb(sizeof(struct bootp_pkt) + hh_len + 15, GFP_KERNEL);
743 GFP_KERNEL); <<
744 if (!skb) 695 if (!skb)
745 return; 696 return;
746 skb_reserve(skb, LL_RESERVED_SPACE(dev !! 697 skb_reserve(skb, hh_len);
747 b = (struct bootp_pkt *) skb_put(skb, 698 b = (struct bootp_pkt *) skb_put(skb, sizeof(struct bootp_pkt));
748 memset(b, 0, sizeof(struct bootp_pkt)) 699 memset(b, 0, sizeof(struct bootp_pkt));
749 700
750 /* Construct IP header */ 701 /* Construct IP header */
751 skb_reset_network_header(skb); !! 702 skb->nh.iph = h = &b->iph;
752 h = ip_hdr(skb); <<
753 h->version = 4; 703 h->version = 4;
754 h->ihl = 5; 704 h->ihl = 5;
755 h->tot_len = htons(sizeof(struct bootp 705 h->tot_len = htons(sizeof(struct bootp_pkt));
756 h->frag_off = htons(IP_DF); 706 h->frag_off = htons(IP_DF);
757 h->ttl = 64; 707 h->ttl = 64;
758 h->protocol = IPPROTO_UDP; 708 h->protocol = IPPROTO_UDP;
759 h->daddr = htonl(INADDR_BROADCAST); !! 709 h->daddr = INADDR_BROADCAST;
760 h->check = ip_fast_csum((unsigned char 710 h->check = ip_fast_csum((unsigned char *) h, h->ihl);
761 711
762 /* Construct UDP header */ 712 /* Construct UDP header */
763 b->udph.source = htons(68); 713 b->udph.source = htons(68);
764 b->udph.dest = htons(67); 714 b->udph.dest = htons(67);
765 b->udph.len = htons(sizeof(struct boot 715 b->udph.len = htons(sizeof(struct bootp_pkt) - sizeof(struct iphdr));
766 /* UDP checksum not calculated -- expl 716 /* UDP checksum not calculated -- explicitly allowed in BOOTP RFC */
767 717
768 /* Construct DHCP/BOOTP header */ 718 /* Construct DHCP/BOOTP header */
769 b->op = BOOTP_REQUEST; 719 b->op = BOOTP_REQUEST;
770 if (dev->type < 256) /* check for fals 720 if (dev->type < 256) /* check for false types */
771 b->htype = dev->type; 721 b->htype = dev->type;
772 else if (dev->type == ARPHRD_IEEE802_T 722 else if (dev->type == ARPHRD_IEEE802_TR) /* fix for token ring */
773 b->htype = ARPHRD_IEEE802; 723 b->htype = ARPHRD_IEEE802;
774 else if (dev->type == ARPHRD_FDDI) 724 else if (dev->type == ARPHRD_FDDI)
775 b->htype = ARPHRD_ETHER; 725 b->htype = ARPHRD_ETHER;
776 else { 726 else {
777 printk("Unknown ARP type 0x%04 727 printk("Unknown ARP type 0x%04x for device %s\n", dev->type, dev->name);
778 b->htype = dev->type; /* can c 728 b->htype = dev->type; /* can cause undefined behavior */
779 } 729 }
780 <<
781 /* server_ip and your_ip address are b <<
782 b->hlen = dev->addr_len; 730 b->hlen = dev->addr_len;
>> 731 b->your_ip = INADDR_NONE;
>> 732 b->server_ip = INADDR_NONE;
783 memcpy(b->hw_addr, dev->dev_addr, dev- 733 memcpy(b->hw_addr, dev->dev_addr, dev->addr_len);
784 b->secs = htons(jiffies_diff / HZ); 734 b->secs = htons(jiffies_diff / HZ);
785 b->xid = d->xid; 735 b->xid = d->xid;
786 736
787 /* add DHCP options or BOOTP extension 737 /* add DHCP options or BOOTP extensions */
788 #ifdef IPCONFIG_DHCP 738 #ifdef IPCONFIG_DHCP
789 if (ic_proto_enabled & IC_USE_DHCP) 739 if (ic_proto_enabled & IC_USE_DHCP)
790 ic_dhcp_init_options(b->exten) 740 ic_dhcp_init_options(b->exten);
791 else 741 else
792 #endif 742 #endif
793 ic_bootp_init_ext(b->exten); 743 ic_bootp_init_ext(b->exten);
794 744
795 /* Chain packet down the line... */ 745 /* Chain packet down the line... */
796 skb->dev = dev; 746 skb->dev = dev;
797 skb->protocol = htons(ETH_P_IP); 747 skb->protocol = htons(ETH_P_IP);
798 if (dev_hard_header(skb, dev, ntohs(sk !! 748 if ((dev->hard_header &&
799 dev->broadcast, de !! 749 dev->hard_header(skb, dev, ntohs(skb->protocol), dev->broadcast, dev->dev_addr, skb->len) < 0) ||
800 dev_queue_xmit(skb) < 0) 750 dev_queue_xmit(skb) < 0)
801 printk("E"); 751 printk("E");
802 } 752 }
803 753
804 754
805 /* 755 /*
806 * Copy BOOTP-supplied string if not already 756 * Copy BOOTP-supplied string if not already set.
807 */ 757 */
808 static int __init ic_bootp_string(char *dest, 758 static int __init ic_bootp_string(char *dest, char *src, int len, int max)
809 { 759 {
810 if (!len) 760 if (!len)
811 return 0; 761 return 0;
812 if (len > max-1) 762 if (len > max-1)
813 len = max-1; 763 len = max-1;
814 memcpy(dest, src, len); 764 memcpy(dest, src, len);
815 dest[len] = '\0'; 765 dest[len] = '\0';
816 return 1; 766 return 1;
817 } 767 }
818 768
819 769
820 /* 770 /*
821 * Process BOOTP extensions. 771 * Process BOOTP extensions.
822 */ 772 */
823 static void __init ic_do_bootp_ext(u8 *ext) 773 static void __init ic_do_bootp_ext(u8 *ext)
824 { 774 {
825 u8 servers; 775 u8 servers;
826 int i; 776 int i;
827 u16 mtu; <<
828 777
829 #ifdef IPCONFIG_DEBUG 778 #ifdef IPCONFIG_DEBUG
830 u8 *c; 779 u8 *c;
831 780
832 printk("DHCP/BOOTP: Got extension %d:" 781 printk("DHCP/BOOTP: Got extension %d:",*ext);
833 for (c=ext+2; c<ext+2+ext[1]; c++) !! 782 for(c=ext+2; c<ext+2+ext[1]; c++)
834 printk(" %02x", *c); 783 printk(" %02x", *c);
835 printk("\n"); 784 printk("\n");
836 #endif 785 #endif
837 786
838 switch (*ext++) { 787 switch (*ext++) {
839 case 1: /* Subnet mask 788 case 1: /* Subnet mask */
840 if (ic_netmask == NONE !! 789 if (ic_netmask == INADDR_NONE)
841 memcpy(&ic_net 790 memcpy(&ic_netmask, ext+1, 4);
842 break; 791 break;
843 case 3: /* Default gat 792 case 3: /* Default gateway */
844 if (ic_gateway == NONE !! 793 if (ic_gateway == INADDR_NONE)
845 memcpy(&ic_gat 794 memcpy(&ic_gateway, ext+1, 4);
846 break; 795 break;
847 case 6: /* DNS server 796 case 6: /* DNS server */
848 servers= *ext/4; 797 servers= *ext/4;
849 if (servers > CONF_NAM 798 if (servers > CONF_NAMESERVERS_MAX)
850 servers = CONF 799 servers = CONF_NAMESERVERS_MAX;
851 for (i = 0; i < server 800 for (i = 0; i < servers; i++) {
852 if (ic_nameser !! 801 if (ic_nameservers[i] == INADDR_NONE)
853 memcpy 802 memcpy(&ic_nameservers[i], ext+1+4*i, 4);
854 } 803 }
855 break; 804 break;
856 case 12: /* Host name * 805 case 12: /* Host name */
857 ic_bootp_string(utsnam !! 806 ic_bootp_string(system_utsname.nodename, ext+1, *ext, __NEW_UTS_LEN);
858 ic_host_name_set = 1; 807 ic_host_name_set = 1;
859 break; 808 break;
860 case 15: /* Domain name 809 case 15: /* Domain name (DNS) */
861 ic_bootp_string(ic_dom 810 ic_bootp_string(ic_domain, ext+1, *ext, sizeof(ic_domain));
862 break; 811 break;
863 case 17: /* Root path * 812 case 17: /* Root path */
864 if (!root_server_path[ 813 if (!root_server_path[0])
865 ic_bootp_strin 814 ic_bootp_string(root_server_path, ext+1, *ext, sizeof(root_server_path));
866 break; 815 break;
867 case 26: /* Interface M <<
868 memcpy(&mtu, ext+1, si <<
869 ic_dev_mtu = ntohs(mtu <<
870 break; <<
871 case 40: /* NIS Domain 816 case 40: /* NIS Domain name (_not_ DNS) */
872 ic_bootp_string(utsnam !! 817 ic_bootp_string(system_utsname.domainname, ext+1, *ext, __NEW_UTS_LEN);
873 break; 818 break;
874 } 819 }
875 } 820 }
876 821
877 822
878 /* 823 /*
879 * Receive BOOTP reply. 824 * Receive BOOTP reply.
880 */ 825 */
881 static int __init ic_bootp_recv(struct sk_buff !! 826 static int __init ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt)
882 { 827 {
883 struct bootp_pkt *b; 828 struct bootp_pkt *b;
884 struct iphdr *h; 829 struct iphdr *h;
885 struct ic_device *d; 830 struct ic_device *d;
886 int len, ext_len; 831 int len, ext_len;
887 832
888 if (!net_eq(dev_net(dev), &init_net)) <<
889 goto drop; <<
890 <<
891 /* Perform verifications before taking 833 /* Perform verifications before taking the lock. */
892 if (skb->pkt_type == PACKET_OTHERHOST) 834 if (skb->pkt_type == PACKET_OTHERHOST)
893 goto drop; 835 goto drop;
894 836
895 if ((skb = skb_share_check(skb, GFP_AT 837 if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL)
896 return NET_RX_DROP; 838 return NET_RX_DROP;
897 839
898 if (!pskb_may_pull(skb, 840 if (!pskb_may_pull(skb,
899 sizeof(struct iphdr 841 sizeof(struct iphdr) +
900 sizeof(struct udphd 842 sizeof(struct udphdr)))
901 goto drop; 843 goto drop;
902 844
903 b = (struct bootp_pkt *)skb_network_he !! 845 b = (struct bootp_pkt *) skb->nh.iph;
904 h = &b->iph; 846 h = &b->iph;
905 847
906 if (h->ihl != 5 || h->version != 4 || 848 if (h->ihl != 5 || h->version != 4 || h->protocol != IPPROTO_UDP)
907 goto drop; 849 goto drop;
908 850
909 /* Fragments are not supported */ 851 /* Fragments are not supported */
910 if (h->frag_off & htons(IP_OFFSET | IP 852 if (h->frag_off & htons(IP_OFFSET | IP_MF)) {
911 if (net_ratelimit()) 853 if (net_ratelimit())
912 printk(KERN_ERR "DHCP/ 854 printk(KERN_ERR "DHCP/BOOTP: Ignoring fragmented "
913 "reply.\n"); 855 "reply.\n");
914 goto drop; 856 goto drop;
915 } 857 }
916 858
917 if (skb->len < ntohs(h->tot_len)) 859 if (skb->len < ntohs(h->tot_len))
918 goto drop; 860 goto drop;
919 861
920 if (ip_fast_csum((char *) h, h->ihl)) 862 if (ip_fast_csum((char *) h, h->ihl))
921 goto drop; 863 goto drop;
922 864
923 if (b->udph.source != htons(67) || b-> 865 if (b->udph.source != htons(67) || b->udph.dest != htons(68))
924 goto drop; 866 goto drop;
925 867
926 if (ntohs(h->tot_len) < ntohs(b->udph. 868 if (ntohs(h->tot_len) < ntohs(b->udph.len) + sizeof(struct iphdr))
927 goto drop; 869 goto drop;
928 870
929 len = ntohs(b->udph.len) - sizeof(stru 871 len = ntohs(b->udph.len) - sizeof(struct udphdr);
930 ext_len = len - (sizeof(*b) - 872 ext_len = len - (sizeof(*b) -
931 sizeof(struct iphdr) 873 sizeof(struct iphdr) -
932 sizeof(struct udphdr) 874 sizeof(struct udphdr) -
933 sizeof(b->exten)); 875 sizeof(b->exten));
934 if (ext_len < 0) 876 if (ext_len < 0)
935 goto drop; 877 goto drop;
936 878
937 /* Ok the front looks good, make sure 879 /* Ok the front looks good, make sure we can get at the rest. */
938 if (!pskb_may_pull(skb, skb->len)) 880 if (!pskb_may_pull(skb, skb->len))
939 goto drop; 881 goto drop;
940 882
941 b = (struct bootp_pkt *)skb_network_he !! 883 b = (struct bootp_pkt *) skb->nh.iph;
942 h = &b->iph; 884 h = &b->iph;
943 885
944 /* One reply at a time, please. */ 886 /* One reply at a time, please. */
945 spin_lock(&ic_recv_lock); 887 spin_lock(&ic_recv_lock);
946 888
947 /* If we already have a reply, just dr 889 /* If we already have a reply, just drop the packet */
948 if (ic_got_reply) 890 if (ic_got_reply)
949 goto drop_unlock; 891 goto drop_unlock;
950 892
951 /* Find the ic_device that the packet 893 /* Find the ic_device that the packet arrived on */
952 d = ic_first_dev; 894 d = ic_first_dev;
953 while (d && d->dev != dev) 895 while (d && d->dev != dev)
954 d = d->next; 896 d = d->next;
955 if (!d) 897 if (!d)
956 goto drop_unlock; /* should n 898 goto drop_unlock; /* should never happen */
957 899
958 /* Is it a reply to our BOOTP request? 900 /* Is it a reply to our BOOTP request? */
959 if (b->op != BOOTP_REPLY || 901 if (b->op != BOOTP_REPLY ||
960 b->xid != d->xid) { 902 b->xid != d->xid) {
961 if (net_ratelimit()) 903 if (net_ratelimit())
962 printk(KERN_ERR "DHCP/ 904 printk(KERN_ERR "DHCP/BOOTP: Reply not for us, "
963 "op[%x] xid[%x] 905 "op[%x] xid[%x]\n",
964 b->op, b->xid); 906 b->op, b->xid);
965 goto drop_unlock; 907 goto drop_unlock;
966 } 908 }
967 909
968 /* Is it a reply for the device we are <<
969 if (b->xid != ic_dev_xid) { <<
970 if (net_ratelimit()) <<
971 printk(KERN_ERR "DHCP/ <<
972 goto drop_unlock; <<
973 } <<
974 <<
975 /* Parse extensions */ 910 /* Parse extensions */
976 if (ext_len >= 4 && 911 if (ext_len >= 4 &&
977 !memcmp(b->exten, ic_bootp_cookie, 912 !memcmp(b->exten, ic_bootp_cookie, 4)) { /* Check magic cookie */
978 u8 *end = (u8 *) b + ntohs(b-> !! 913 u8 *end = (u8 *) b + ntohs(b->iph.tot_len);
979 u8 *ext; 914 u8 *ext;
980 915
981 #ifdef IPCONFIG_DHCP 916 #ifdef IPCONFIG_DHCP
982 if (ic_proto_enabled & IC_USE_ 917 if (ic_proto_enabled & IC_USE_DHCP) {
983 __be32 server_id = NON !! 918 u32 server_id = INADDR_NONE;
984 int mt = 0; 919 int mt = 0;
985 920
986 ext = &b->exten[4]; 921 ext = &b->exten[4];
987 while (ext < end && *e 922 while (ext < end && *ext != 0xff) {
988 u8 *opt = ext+ 923 u8 *opt = ext++;
989 if (*opt == 0) 924 if (*opt == 0) /* Padding */
990 contin 925 continue;
991 ext += *ext + 926 ext += *ext + 1;
992 if (ext >= end 927 if (ext >= end)
993 break; 928 break;
994 switch (*opt) 929 switch (*opt) {
995 case 53: 930 case 53: /* Message type */
996 if (op 931 if (opt[1])
997 932 mt = opt[2];
998 break; 933 break;
999 case 54: 934 case 54: /* Server ID (IP address) */
1000 if (o 935 if (opt[1] >= 4)
1001 936 memcpy(&server_id, opt + 2, 4);
1002 break 937 break;
1003 } !! 938 };
1004 } 939 }
1005 940
1006 #ifdef IPCONFIG_DEBUG 941 #ifdef IPCONFIG_DEBUG
1007 printk("DHCP: Got mes 942 printk("DHCP: Got message type %d\n", mt);
1008 #endif 943 #endif
1009 944
1010 switch (mt) { 945 switch (mt) {
1011 case DHCPOFFER: 946 case DHCPOFFER:
1012 /* While in t 947 /* While in the process of accepting one offer,
1013 * ignore all 948 * ignore all others.
1014 */ 949 */
1015 if (ic_myaddr !! 950 if (ic_myaddr != INADDR_NONE)
1016 goto 951 goto drop_unlock;
1017 952
1018 /* Let's acce 953 /* Let's accept that offer. */
1019 ic_myaddr = b 954 ic_myaddr = b->your_ip;
1020 ic_servaddr = 955 ic_servaddr = server_id;
1021 #ifdef IPCONFIG_DEBUG 956 #ifdef IPCONFIG_DEBUG
1022 printk("DHCP: !! 957 printk("DHCP: Offered address %u.%u.%u.%u",
1023 &ic_my !! 958 NIPQUAD(ic_myaddr));
>> 959 printk(" by server %u.%u.%u.%u\n",
>> 960 NIPQUAD(ic_servaddr));
1024 #endif 961 #endif
1025 /* The DHCP i 962 /* The DHCP indicated server address takes
1026 * precedence 963 * precedence over the bootp header one if
1027 * they are d 964 * they are different.
1028 */ 965 */
1029 if ((server_i !! 966 if ((server_id != INADDR_NONE) &&
1030 (b->serve 967 (b->server_ip != server_id))
1031 b->se 968 b->server_ip = ic_servaddr;
1032 break; 969 break;
1033 970
1034 case DHCPACK: 971 case DHCPACK:
1035 if (memcmp(de 972 if (memcmp(dev->dev_addr, b->hw_addr, dev->addr_len) != 0)
1036 goto 973 goto drop_unlock;
1037 974
1038 /* Yeah! */ 975 /* Yeah! */
1039 break; 976 break;
1040 977
1041 default: 978 default:
1042 /* Urque. Fo 979 /* Urque. Forget it*/
1043 ic_myaddr = N !! 980 ic_myaddr = INADDR_NONE;
1044 ic_servaddr = !! 981 ic_servaddr = INADDR_NONE;
1045 goto drop_unl 982 goto drop_unlock;
1046 } !! 983 };
1047 984
1048 ic_dhcp_msgtype = mt; 985 ic_dhcp_msgtype = mt;
1049 986
1050 } 987 }
1051 #endif /* IPCONFIG_DHCP */ 988 #endif /* IPCONFIG_DHCP */
1052 989
1053 ext = &b->exten[4]; 990 ext = &b->exten[4];
1054 while (ext < end && *ext != 0 991 while (ext < end && *ext != 0xff) {
1055 u8 *opt = ext++; 992 u8 *opt = ext++;
1056 if (*opt == 0) /* Pa 993 if (*opt == 0) /* Padding */
1057 continue; 994 continue;
1058 ext += *ext + 1; 995 ext += *ext + 1;
1059 if (ext < end) 996 if (ext < end)
1060 ic_do_bootp_e 997 ic_do_bootp_ext(opt);
1061 } 998 }
1062 } 999 }
1063 1000
1064 /* We have a winner! */ 1001 /* We have a winner! */
1065 ic_dev = dev; 1002 ic_dev = dev;
1066 ic_myaddr = b->your_ip; 1003 ic_myaddr = b->your_ip;
1067 ic_servaddr = b->server_ip; 1004 ic_servaddr = b->server_ip;
1068 if (ic_gateway == NONE && b->relay_ip !! 1005 if (ic_gateway == INADDR_NONE && b->relay_ip)
1069 ic_gateway = b->relay_ip; 1006 ic_gateway = b->relay_ip;
1070 if (ic_nameservers[0] == NONE) !! 1007 if (ic_nameservers[0] == INADDR_NONE)
1071 ic_nameservers[0] = ic_servad 1008 ic_nameservers[0] = ic_servaddr;
1072 ic_got_reply = IC_BOOTP; 1009 ic_got_reply = IC_BOOTP;
1073 1010
1074 drop_unlock: 1011 drop_unlock:
1075 /* Show's over. Nothing to see here. 1012 /* Show's over. Nothing to see here. */
1076 spin_unlock(&ic_recv_lock); 1013 spin_unlock(&ic_recv_lock);
1077 1014
1078 drop: 1015 drop:
1079 /* Throw the packet out. */ 1016 /* Throw the packet out. */
1080 kfree_skb(skb); 1017 kfree_skb(skb);
1081 1018
1082 return 0; 1019 return 0;
1083 } !! 1020 }
1084 1021
1085 1022
1086 #endif 1023 #endif
1087 1024
1088 1025
1089 /* 1026 /*
1090 * Dynamic IP configuration -- DHCP, BOO 1027 * Dynamic IP configuration -- DHCP, BOOTP, RARP.
1091 */ 1028 */
1092 1029
1093 #ifdef IPCONFIG_DYNAMIC 1030 #ifdef IPCONFIG_DYNAMIC
1094 1031
1095 static int __init ic_dynamic(void) 1032 static int __init ic_dynamic(void)
1096 { 1033 {
1097 int retries; 1034 int retries;
1098 struct ic_device *d; 1035 struct ic_device *d;
1099 unsigned long start_jiffies, timeout, 1036 unsigned long start_jiffies, timeout, jiff;
1100 int do_bootp = ic_proto_have_if & IC_ 1037 int do_bootp = ic_proto_have_if & IC_BOOTP;
1101 int do_rarp = ic_proto_have_if & IC_R 1038 int do_rarp = ic_proto_have_if & IC_RARP;
1102 1039
1103 /* 1040 /*
1104 * If none of DHCP/BOOTP/RARP was sel 1041 * If none of DHCP/BOOTP/RARP was selected, return with an error.
1105 * This routine gets only called when 1042 * This routine gets only called when some pieces of information
1106 * are missing, and without DHCP/BOOT 1043 * are missing, and without DHCP/BOOTP/RARP we are unable to get it.
1107 */ 1044 */
1108 if (!ic_proto_enabled) { 1045 if (!ic_proto_enabled) {
1109 printk(KERN_ERR "IP-Config: I 1046 printk(KERN_ERR "IP-Config: Incomplete network configuration information.\n");
1110 return -1; 1047 return -1;
1111 } 1048 }
1112 1049
1113 #ifdef IPCONFIG_BOOTP 1050 #ifdef IPCONFIG_BOOTP
1114 if ((ic_proto_enabled ^ ic_proto_have 1051 if ((ic_proto_enabled ^ ic_proto_have_if) & IC_BOOTP)
1115 printk(KERN_ERR "DHCP/BOOTP: 1052 printk(KERN_ERR "DHCP/BOOTP: No suitable device found.\n");
1116 #endif 1053 #endif
1117 #ifdef IPCONFIG_RARP 1054 #ifdef IPCONFIG_RARP
1118 if ((ic_proto_enabled ^ ic_proto_have 1055 if ((ic_proto_enabled ^ ic_proto_have_if) & IC_RARP)
1119 printk(KERN_ERR "RARP: No sui 1056 printk(KERN_ERR "RARP: No suitable device found.\n");
1120 #endif 1057 #endif
1121 1058
1122 if (!ic_proto_have_if) 1059 if (!ic_proto_have_if)
1123 /* Error message already prin 1060 /* Error message already printed */
1124 return -1; 1061 return -1;
1125 1062
1126 /* 1063 /*
1127 * Setup protocols 1064 * Setup protocols
1128 */ 1065 */
1129 #ifdef IPCONFIG_BOOTP 1066 #ifdef IPCONFIG_BOOTP
1130 if (do_bootp) 1067 if (do_bootp)
1131 ic_bootp_init(); 1068 ic_bootp_init();
1132 #endif 1069 #endif
1133 #ifdef IPCONFIG_RARP 1070 #ifdef IPCONFIG_RARP
1134 if (do_rarp) 1071 if (do_rarp)
1135 ic_rarp_init(); 1072 ic_rarp_init();
1136 #endif 1073 #endif
1137 1074
1138 /* 1075 /*
1139 * Send requests and wait, until we g 1076 * Send requests and wait, until we get an answer. This loop
1140 * seems to be a terrible waste of CP 1077 * seems to be a terrible waste of CPU time, but actually there is
1141 * only one process running at all, s 1078 * only one process running at all, so we don't need to use any
1142 * scheduler functions. 1079 * scheduler functions.
1143 * [Actually we could now, but the no !! 1080 * [Actually we could now, but the nothing else running note still
1144 * applies.. - AC] 1081 * applies.. - AC]
1145 */ 1082 */
1146 printk(KERN_NOTICE "Sending %s%s%s re 1083 printk(KERN_NOTICE "Sending %s%s%s requests .",
1147 do_bootp 1084 do_bootp
1148 ? ((ic_proto_enabled & IC_USE 1085 ? ((ic_proto_enabled & IC_USE_DHCP) ? "DHCP" : "BOOTP") : "",
1149 (do_bootp && do_rarp) ? " and 1086 (do_bootp && do_rarp) ? " and " : "",
1150 do_rarp ? "RARP" : ""); 1087 do_rarp ? "RARP" : "");
1151 1088
1152 start_jiffies = jiffies; 1089 start_jiffies = jiffies;
1153 d = ic_first_dev; 1090 d = ic_first_dev;
1154 retries = CONF_SEND_RETRIES; 1091 retries = CONF_SEND_RETRIES;
1155 get_random_bytes(&timeout, sizeof(tim 1092 get_random_bytes(&timeout, sizeof(timeout));
1156 timeout = CONF_BASE_TIMEOUT + (timeou 1093 timeout = CONF_BASE_TIMEOUT + (timeout % (unsigned) CONF_TIMEOUT_RANDOM);
1157 for (;;) { !! 1094 for(;;) {
1158 /* Track the device we are co <<
1159 ic_dev_xid = d->xid; <<
1160 <<
1161 #ifdef IPCONFIG_BOOTP 1095 #ifdef IPCONFIG_BOOTP
1162 if (do_bootp && (d->able & IC 1096 if (do_bootp && (d->able & IC_BOOTP))
1163 ic_bootp_send_if(d, j 1097 ic_bootp_send_if(d, jiffies - start_jiffies);
1164 #endif 1098 #endif
1165 #ifdef IPCONFIG_RARP 1099 #ifdef IPCONFIG_RARP
1166 if (do_rarp && (d->able & IC_ 1100 if (do_rarp && (d->able & IC_RARP))
1167 ic_rarp_send_if(d); 1101 ic_rarp_send_if(d);
1168 #endif 1102 #endif
1169 1103
1170 jiff = jiffies + (d->next ? C 1104 jiff = jiffies + (d->next ? CONF_INTER_TIMEOUT : timeout);
1171 while (time_before(jiffies, j !! 1105 while (time_before(jiffies, jiff) && !ic_got_reply) {
1172 schedule_timeout_unin !! 1106 set_current_state(TASK_UNINTERRUPTIBLE);
>> 1107 schedule_timeout(1);
>> 1108 }
1173 #ifdef IPCONFIG_DHCP 1109 #ifdef IPCONFIG_DHCP
1174 /* DHCP isn't done until we g 1110 /* DHCP isn't done until we get a DHCPACK. */
1175 if ((ic_got_reply & IC_BOOTP) 1111 if ((ic_got_reply & IC_BOOTP)
1176 && (ic_proto_enabled & IC 1112 && (ic_proto_enabled & IC_USE_DHCP)
1177 && ic_dhcp_msgtype != DHC 1113 && ic_dhcp_msgtype != DHCPACK)
1178 { 1114 {
1179 ic_got_reply = 0; 1115 ic_got_reply = 0;
1180 printk(","); 1116 printk(",");
1181 continue; 1117 continue;
1182 } 1118 }
1183 #endif /* IPCONFIG_DHCP */ 1119 #endif /* IPCONFIG_DHCP */
1184 1120
1185 if (ic_got_reply) { 1121 if (ic_got_reply) {
1186 printk(" OK\n"); 1122 printk(" OK\n");
1187 break; 1123 break;
1188 } 1124 }
1189 1125
1190 if ((d = d->next)) 1126 if ((d = d->next))
1191 continue; 1127 continue;
1192 1128
1193 if (! --retries) { 1129 if (! --retries) {
1194 printk(" timed out!\n 1130 printk(" timed out!\n");
1195 break; 1131 break;
1196 } 1132 }
1197 1133
1198 d = ic_first_dev; 1134 d = ic_first_dev;
1199 1135
1200 timeout = timeout CONF_TIMEOU 1136 timeout = timeout CONF_TIMEOUT_MULT;
1201 if (timeout > CONF_TIMEOUT_MA 1137 if (timeout > CONF_TIMEOUT_MAX)
1202 timeout = CONF_TIMEOU 1138 timeout = CONF_TIMEOUT_MAX;
1203 1139
1204 printk("."); 1140 printk(".");
1205 } 1141 }
1206 1142
1207 #ifdef IPCONFIG_BOOTP 1143 #ifdef IPCONFIG_BOOTP
1208 if (do_bootp) 1144 if (do_bootp)
1209 ic_bootp_cleanup(); 1145 ic_bootp_cleanup();
1210 #endif 1146 #endif
1211 #ifdef IPCONFIG_RARP 1147 #ifdef IPCONFIG_RARP
1212 if (do_rarp) 1148 if (do_rarp)
1213 ic_rarp_cleanup(); 1149 ic_rarp_cleanup();
1214 #endif 1150 #endif
1215 1151
1216 if (!ic_got_reply) { !! 1152 if (!ic_got_reply)
1217 ic_myaddr = NONE; <<
1218 return -1; 1153 return -1;
1219 } <<
1220 1154
1221 printk("IP-Config: Got %s answer from !! 1155 printk("IP-Config: Got %s answer from %u.%u.%u.%u, ",
1222 ((ic_got_reply & IC_RARP) ? " !! 1156 ((ic_got_reply & IC_RARP) ? "RARP"
1223 : (ic_proto_enabled & IC_USE 1157 : (ic_proto_enabled & IC_USE_DHCP) ? "DHCP" : "BOOTP"),
1224 &ic_servaddr); !! 1158 NIPQUAD(ic_servaddr));
1225 printk("my address is %pI4\n", &ic_my !! 1159 printk("my address is %u.%u.%u.%u\n", NIPQUAD(ic_myaddr));
1226 1160
1227 return 0; 1161 return 0;
1228 } 1162 }
1229 1163
1230 #endif /* IPCONFIG_DYNAMIC */ 1164 #endif /* IPCONFIG_DYNAMIC */
1231 1165
1232 #ifdef CONFIG_PROC_FS 1166 #ifdef CONFIG_PROC_FS
1233 1167
1234 static int pnp_seq_show(struct seq_file *seq, 1168 static int pnp_seq_show(struct seq_file *seq, void *v)
1235 { 1169 {
1236 int i; 1170 int i;
1237 1171
1238 if (ic_proto_used & IC_PROTO) 1172 if (ic_proto_used & IC_PROTO)
1239 seq_printf(seq, "#PROTO: %s\n 1173 seq_printf(seq, "#PROTO: %s\n",
1240 (ic_proto_used & I 1174 (ic_proto_used & IC_RARP) ? "RARP"
1241 : (ic_proto_used & 1175 : (ic_proto_used & IC_USE_DHCP) ? "DHCP" : "BOOTP");
1242 else 1176 else
1243 seq_puts(seq, "#MANUAL\n"); 1177 seq_puts(seq, "#MANUAL\n");
1244 1178
1245 if (ic_domain[0]) 1179 if (ic_domain[0])
1246 seq_printf(seq, 1180 seq_printf(seq,
1247 "domain %s\n", ic_ 1181 "domain %s\n", ic_domain);
1248 for (i = 0; i < CONF_NAMESERVERS_MAX; 1182 for (i = 0; i < CONF_NAMESERVERS_MAX; i++) {
1249 if (ic_nameservers[i] != NONE !! 1183 if (ic_nameservers[i] != INADDR_NONE)
1250 seq_printf(seq, "name !! 1184 seq_printf(seq,
1251 &ic_namese !! 1185 "nameserver %u.%u.%u.%u\n",
1252 } !! 1186 NIPQUAD(ic_nameservers[i]));
1253 if (ic_servaddr != NONE) !! 1187 }
1254 seq_printf(seq, "bootserver % !! 1188 if (ic_servaddr != INADDR_NONE)
1255 &ic_servaddr); !! 1189 seq_printf(seq,
>> 1190 "bootserver %u.%u.%u.%u\n",
>> 1191 NIPQUAD(ic_servaddr));
1256 return 0; 1192 return 0;
1257 } 1193 }
1258 1194
1259 static int pnp_seq_open(struct inode *indoe, 1195 static int pnp_seq_open(struct inode *indoe, struct file *file)
1260 { 1196 {
1261 return single_open(file, pnp_seq_show 1197 return single_open(file, pnp_seq_show, NULL);
1262 } 1198 }
1263 1199
1264 static const struct file_operations pnp_seq_f !! 1200 static struct file_operations pnp_seq_fops = {
1265 .owner = THIS_MODULE, 1201 .owner = THIS_MODULE,
1266 .open = pnp_seq_open, 1202 .open = pnp_seq_open,
1267 .read = seq_read, 1203 .read = seq_read,
1268 .llseek = seq_lseek, 1204 .llseek = seq_lseek,
1269 .release = single_release, 1205 .release = single_release,
1270 }; 1206 };
1271 #endif /* CONFIG_PROC_FS */ 1207 #endif /* CONFIG_PROC_FS */
1272 1208
1273 /* 1209 /*
1274 * Extract IP address from the parameter str 1210 * Extract IP address from the parameter string if needed. Note that we
1275 * need to have root_server_addr set _before 1211 * need to have root_server_addr set _before_ IPConfig gets called as it
1276 * can override it. 1212 * can override it.
1277 */ 1213 */
1278 __be32 __init root_nfs_parse_addr(char *name) !! 1214 u32 __init root_nfs_parse_addr(char *name)
1279 { 1215 {
1280 __be32 addr; !! 1216 u32 addr;
1281 int octets = 0; 1217 int octets = 0;
1282 char *cp, *cq; 1218 char *cp, *cq;
1283 1219
1284 cp = cq = name; 1220 cp = cq = name;
1285 while (octets < 4) { 1221 while (octets < 4) {
1286 while (*cp >= '' && *cp <= '9 1222 while (*cp >= '' && *cp <= '9')
1287 cp++; 1223 cp++;
1288 if (cp == cq || cp - cq > 3) 1224 if (cp == cq || cp - cq > 3)
1289 break; 1225 break;
1290 if (*cp == '.' || octets == 3 1226 if (*cp == '.' || octets == 3)
1291 octets++; 1227 octets++;
1292 if (octets < 4) 1228 if (octets < 4)
1293 cp++; 1229 cp++;
1294 cq = cp; 1230 cq = cp;
1295 } 1231 }
1296 if (octets == 4 && (*cp == ':' || *cp 1232 if (octets == 4 && (*cp == ':' || *cp == '\0')) {
1297 if (*cp == ':') 1233 if (*cp == ':')
1298 *cp++ = '\0'; 1234 *cp++ = '\0';
1299 addr = in_aton(name); 1235 addr = in_aton(name);
1300 memmove(name, cp, strlen(cp) 1236 memmove(name, cp, strlen(cp) + 1);
1301 } else 1237 } else
1302 addr = NONE; !! 1238 addr = INADDR_NONE;
1303 1239
1304 return addr; 1240 return addr;
1305 } 1241 }
1306 1242
1307 /* 1243 /*
1308 * IP Autoconfig dispatcher. 1244 * IP Autoconfig dispatcher.
1309 */ 1245 */
1310 1246
1311 static int __init ip_auto_config(void) 1247 static int __init ip_auto_config(void)
1312 { 1248 {
1313 __be32 addr; !! 1249 u32 addr;
1314 #ifdef IPCONFIG_DYNAMIC <<
1315 int retries = CONF_OPEN_RETRIES; <<
1316 #endif <<
1317 1250
1318 #ifdef CONFIG_PROC_FS 1251 #ifdef CONFIG_PROC_FS
1319 proc_net_fops_create(&init_net, "pnp" !! 1252 proc_net_fops_create("pnp", S_IRUGO, &pnp_seq_fops);
1320 #endif /* CONFIG_PROC_FS */ 1253 #endif /* CONFIG_PROC_FS */
1321 1254
1322 if (!ic_enable) 1255 if (!ic_enable)
1323 return 0; 1256 return 0;
1324 1257
1325 DBG(("IP-Config: Entered.\n")); 1258 DBG(("IP-Config: Entered.\n"));
1326 #ifdef IPCONFIG_DYNAMIC 1259 #ifdef IPCONFIG_DYNAMIC
1327 try_try_again: 1260 try_try_again:
1328 #endif 1261 #endif
1329 /* Give hardware a chance to settle * 1262 /* Give hardware a chance to settle */
1330 msleep(CONF_PRE_OPEN); 1263 msleep(CONF_PRE_OPEN);
1331 1264
1332 /* Setup all network devices */ 1265 /* Setup all network devices */
1333 if (ic_open_devs() < 0) 1266 if (ic_open_devs() < 0)
1334 return -1; 1267 return -1;
1335 1268
1336 /* Give drivers a chance to settle */ 1269 /* Give drivers a chance to settle */
1337 ssleep(CONF_POST_OPEN); 1270 ssleep(CONF_POST_OPEN);
1338 1271
1339 /* 1272 /*
1340 * If the config information is insuf 1273 * If the config information is insufficient (e.g., our IP address or
1341 * IP address of the boot server is m 1274 * IP address of the boot server is missing or we have multiple network
1342 * interfaces and no default was set) 1275 * interfaces and no default was set), use BOOTP or RARP to get the
1343 * missing values. 1276 * missing values.
1344 */ 1277 */
1345 if (ic_myaddr == NONE || !! 1278 if (ic_myaddr == INADDR_NONE ||
1346 #ifdef CONFIG_ROOT_NFS 1279 #ifdef CONFIG_ROOT_NFS
1347 (root_server_addr == NONE !! 1280 (MAJOR(ROOT_DEV) == UNNAMED_MAJOR
1348 && ic_servaddr == NONE !! 1281 && root_server_addr == INADDR_NONE
1349 && ROOT_DEV == Root_NFS) || !! 1282 && ic_servaddr == INADDR_NONE) ||
1350 #endif 1283 #endif
1351 ic_first_dev->next) { 1284 ic_first_dev->next) {
1352 #ifdef IPCONFIG_DYNAMIC 1285 #ifdef IPCONFIG_DYNAMIC
>> 1286
>> 1287 int retries = CONF_OPEN_RETRIES;
>> 1288
1353 if (ic_dynamic() < 0) { 1289 if (ic_dynamic() < 0) {
1354 ic_close_devs(); 1290 ic_close_devs();
1355 1291
1356 /* 1292 /*
1357 * I don't know why, 1293 * I don't know why, but sometimes the
1358 * eepro100 driver (a 1294 * eepro100 driver (at least) gets upset and
1359 * doesn't work the f 1295 * doesn't work the first time it's opened.
1360 * But then if you cl 1296 * But then if you close it and reopen it, it
1361 * works just fine. 1297 * works just fine. So we need to try that at
1362 * least once before 1298 * least once before giving up.
1363 * 1299 *
1364 * Also, if the root 1300 * Also, if the root will be NFS-mounted, we
1365 * have nowhere to go 1301 * have nowhere to go if DHCP fails. So we
1366 * just have to keep 1302 * just have to keep trying forever.
1367 * 1303 *
1368 * 1304 * -- Chip
1369 */ 1305 */
1370 #ifdef CONFIG_ROOT_NFS 1306 #ifdef CONFIG_ROOT_NFS
1371 if (ROOT_DEV == Root 1307 if (ROOT_DEV == Root_NFS) {
1372 printk(KERN_E !! 1308 printk(KERN_ERR
1373 "IP-C 1309 "IP-Config: Retrying forever (NFS root)...\n");
1374 goto try_try_ 1310 goto try_try_again;
1375 } 1311 }
1376 #endif 1312 #endif
1377 1313
1378 if (--retries) { 1314 if (--retries) {
1379 printk(KERN_E !! 1315 printk(KERN_ERR
1380 "IP-Co 1316 "IP-Config: Reopening network devices...\n");
1381 goto try_try_ 1317 goto try_try_again;
1382 } 1318 }
1383 1319
1384 /* Oh, well. At leas 1320 /* Oh, well. At least we tried. */
1385 printk(KERN_ERR "IP-C 1321 printk(KERN_ERR "IP-Config: Auto-configuration of network failed.\n");
1386 return -1; 1322 return -1;
1387 } 1323 }
1388 #else /* !DYNAMIC */ 1324 #else /* !DYNAMIC */
1389 printk(KERN_ERR "IP-Config: I 1325 printk(KERN_ERR "IP-Config: Incomplete network configuration information.\n");
1390 ic_close_devs(); 1326 ic_close_devs();
1391 return -1; 1327 return -1;
1392 #endif /* IPCONFIG_DYNAMIC */ 1328 #endif /* IPCONFIG_DYNAMIC */
1393 } else { 1329 } else {
1394 /* Device selected manually o 1330 /* Device selected manually or only one device -> use it */
1395 ic_dev = ic_first_dev->dev; 1331 ic_dev = ic_first_dev->dev;
1396 } 1332 }
1397 1333
1398 addr = root_nfs_parse_addr(root_serve 1334 addr = root_nfs_parse_addr(root_server_path);
1399 if (root_server_addr == NONE) !! 1335 if (root_server_addr == INADDR_NONE)
1400 root_server_addr = addr; 1336 root_server_addr = addr;
1401 1337
1402 /* 1338 /*
1403 * Use defaults whereever applicable. 1339 * Use defaults whereever applicable.
1404 */ 1340 */
1405 if (ic_defaults() < 0) 1341 if (ic_defaults() < 0)
1406 return -1; 1342 return -1;
1407 1343
1408 /* 1344 /*
1409 * Close all network devices except t 1345 * Close all network devices except the device we've
1410 * autoconfigured and set up routes. 1346 * autoconfigured and set up routes.
1411 */ 1347 */
1412 ic_close_devs(); 1348 ic_close_devs();
1413 if (ic_setup_if() < 0 || ic_setup_rou 1349 if (ic_setup_if() < 0 || ic_setup_routes() < 0)
1414 return -1; 1350 return -1;
1415 1351
1416 /* 1352 /*
1417 * Record which protocol was actually 1353 * Record which protocol was actually used.
1418 */ 1354 */
1419 #ifdef IPCONFIG_DYNAMIC 1355 #ifdef IPCONFIG_DYNAMIC
1420 ic_proto_used = ic_got_reply | (ic_pr 1356 ic_proto_used = ic_got_reply | (ic_proto_enabled & IC_USE_DHCP);
1421 #endif 1357 #endif
1422 1358
1423 #ifndef IPCONFIG_SILENT 1359 #ifndef IPCONFIG_SILENT
1424 /* 1360 /*
1425 * Clue in the operator. 1361 * Clue in the operator.
1426 */ 1362 */
1427 printk("IP-Config: Complete:"); 1363 printk("IP-Config: Complete:");
1428 printk("\n device=%s", ic_dev->na !! 1364 printk("\n device=%s", ic_dev->name);
1429 printk(", addr=%pI4", &ic_myaddr); !! 1365 printk(", addr=%u.%u.%u.%u", NIPQUAD(ic_myaddr));
1430 printk(", mask=%pI4", &ic_netmask); !! 1366 printk(", mask=%u.%u.%u.%u", NIPQUAD(ic_netmask));
1431 printk(", gw=%pI4", &ic_gateway); !! 1367 printk(", gw=%u.%u.%u.%u", NIPQUAD(ic_gateway));
1432 printk(",\n host=%s, domain=%s, n 1368 printk(",\n host=%s, domain=%s, nis-domain=%s",
1433 utsname()->nodename, ic_domain !! 1369 system_utsname.nodename, ic_domain, system_utsname.domainname);
1434 printk(",\n bootserver=%pI4", &ic !! 1370 printk(",\n bootserver=%u.%u.%u.%u", NIPQUAD(ic_servaddr));
1435 printk(", rootserver=%pI4", &root_ser !! 1371 printk(", rootserver=%u.%u.%u.%u", NIPQUAD(root_server_addr));
1436 printk(", rootpath=%s", root_server_p 1372 printk(", rootpath=%s", root_server_path);
1437 if (ic_dev_mtu) <<
1438 printk(", mtu=%d", ic_dev_mtu <<
1439 printk("\n"); 1373 printk("\n");
1440 #endif /* !SILENT */ 1374 #endif /* !SILENT */
1441 1375
1442 return 0; 1376 return 0;
1443 } 1377 }
1444 1378
1445 late_initcall(ip_auto_config); 1379 late_initcall(ip_auto_config);
1446 1380
1447 1381
1448 /* 1382 /*
1449 * Decode any IP configuration options in th 1383 * Decode any IP configuration options in the "ip=" or "nfsaddrs=" kernel
1450 * command line parameter. See Documentatio !! 1384 * command line parameter. It consists of option fields separated by colons in
>> 1385 * the following order:
>> 1386 *
>> 1387 * <client-ip>:<server-ip>:<gw-ip>:<netmask>:<host name>:<device>:<PROTO>
>> 1388 *
>> 1389 * Any of the fields can be empty which means to use a default value:
>> 1390 * <client-ip> - address given by BOOTP or RARP
>> 1391 * <server-ip> - address of host returning BOOTP or RARP packet
>> 1392 * <gw-ip> - none, or the address returned by BOOTP
>> 1393 * <netmask> - automatically determined from <client-ip>, or the
>> 1394 * one returned by BOOTP
>> 1395 * <host name> - <client-ip> in ASCII notation, or the name returned
>> 1396 * by BOOTP
>> 1397 * <device> - use all available devices
>> 1398 * <PROTO>:
>> 1399 * off|none - don't do autoconfig at all (DEFAULT)
>> 1400 * on|any - use any configured protocol
>> 1401 * dhcp|bootp|rarp - use only the specified protocol
>> 1402 * both - use both BOOTP and RARP (not DHCP)
1451 */ 1403 */
1452 static int __init ic_proto_name(char *name) 1404 static int __init ic_proto_name(char *name)
1453 { 1405 {
1454 if (!strcmp(name, "on") || !strcmp(na 1406 if (!strcmp(name, "on") || !strcmp(name, "any")) {
1455 return 1; 1407 return 1;
1456 } 1408 }
1457 if (!strcmp(name, "off") || !strcmp(n <<
1458 return 0; <<
1459 } <<
1460 #ifdef CONFIG_IP_PNP_DHCP 1409 #ifdef CONFIG_IP_PNP_DHCP
1461 else if (!strcmp(name, "dhcp")) { 1410 else if (!strcmp(name, "dhcp")) {
1462 ic_proto_enabled &= ~IC_RARP; 1411 ic_proto_enabled &= ~IC_RARP;
1463 return 1; 1412 return 1;
1464 } 1413 }
1465 #endif 1414 #endif
1466 #ifdef CONFIG_IP_PNP_BOOTP 1415 #ifdef CONFIG_IP_PNP_BOOTP
1467 else if (!strcmp(name, "bootp")) { 1416 else if (!strcmp(name, "bootp")) {
1468 ic_proto_enabled &= ~(IC_RARP 1417 ic_proto_enabled &= ~(IC_RARP | IC_USE_DHCP);
1469 return 1; 1418 return 1;
1470 } 1419 }
1471 #endif 1420 #endif
1472 #ifdef CONFIG_IP_PNP_RARP 1421 #ifdef CONFIG_IP_PNP_RARP
1473 else if (!strcmp(name, "rarp")) { 1422 else if (!strcmp(name, "rarp")) {
1474 ic_proto_enabled &= ~(IC_BOOT 1423 ic_proto_enabled &= ~(IC_BOOTP | IC_USE_DHCP);
1475 return 1; 1424 return 1;
1476 } 1425 }
1477 #endif 1426 #endif
1478 #ifdef IPCONFIG_DYNAMIC 1427 #ifdef IPCONFIG_DYNAMIC
1479 else if (!strcmp(name, "both")) { 1428 else if (!strcmp(name, "both")) {
1480 ic_proto_enabled &= ~IC_USE_D 1429 ic_proto_enabled &= ~IC_USE_DHCP; /* backward compat :-( */
1481 return 1; 1430 return 1;
1482 } 1431 }
1483 #endif 1432 #endif
1484 return 0; 1433 return 0;
1485 } 1434 }
1486 1435
1487 static int __init ip_auto_config_setup(char * 1436 static int __init ip_auto_config_setup(char *addrs)
1488 { 1437 {
1489 char *cp, *ip, *dp; 1438 char *cp, *ip, *dp;
1490 int num = 0; 1439 int num = 0;
1491 1440
1492 ic_set_manually = 1; 1441 ic_set_manually = 1;
1493 ic_enable = 1; <<
1494 1442
1495 /* !! 1443 ic_enable = (*addrs &&
1496 * If any dhcp, bootp etc options are !! 1444 (strcmp(addrs, "off") != 0) &&
1497 * and skip the below static IP proce !! 1445 (strcmp(addrs, "none") != 0));
1498 */ !! 1446 if (!ic_enable)
1499 if (ic_proto_name(addrs)) <<
1500 return 1; 1447 return 1;
1501 1448
1502 /* If no static IP is given, turn off !! 1449 if (ic_proto_name(addrs))
1503 if (*addrs == 0 || <<
1504 strcmp(addrs, "off") == 0 || <<
1505 strcmp(addrs, "none") == 0) { <<
1506 ic_enable = 0; <<
1507 return 1; 1450 return 1;
1508 } <<
1509 1451
1510 /* Parse string for static IP assignm !! 1452 /* Parse the whole string */
1511 ip = addrs; 1453 ip = addrs;
1512 while (ip && *ip) { 1454 while (ip && *ip) {
1513 if ((cp = strchr(ip, ':'))) 1455 if ((cp = strchr(ip, ':')))
1514 *cp++ = '\0'; 1456 *cp++ = '\0';
1515 if (strlen(ip) > 0) { 1457 if (strlen(ip) > 0) {
1516 DBG(("IP-Config: Para 1458 DBG(("IP-Config: Parameter #%d: `%s'\n", num, ip));
1517 switch (num) { 1459 switch (num) {
1518 case 0: 1460 case 0:
1519 if ((ic_myadd !! 1461 if ((ic_myaddr = in_aton(ip)) == INADDR_ANY)
1520 ic_my !! 1462 ic_myaddr = INADDR_NONE;
1521 break; 1463 break;
1522 case 1: 1464 case 1:
1523 if ((ic_serva !! 1465 if ((ic_servaddr = in_aton(ip)) == INADDR_ANY)
1524 ic_se !! 1466 ic_servaddr = INADDR_NONE;
1525 break; 1467 break;
1526 case 2: 1468 case 2:
1527 if ((ic_gatew !! 1469 if ((ic_gateway = in_aton(ip)) == INADDR_ANY)
1528 ic_ga !! 1470 ic_gateway = INADDR_NONE;
1529 break; 1471 break;
1530 case 3: 1472 case 3:
1531 if ((ic_netma !! 1473 if ((ic_netmask = in_aton(ip)) == INADDR_ANY)
1532 ic_ne !! 1474 ic_netmask = INADDR_NONE;
1533 break; 1475 break;
1534 case 4: 1476 case 4:
1535 if ((dp = str 1477 if ((dp = strchr(ip, '.'))) {
1536 *dp++ 1478 *dp++ = '\0';
1537 strlc !! 1479 strlcpy(system_utsname.domainname, dp,
1538 !! 1480 sizeof(system_utsname.domainname));
1539 } 1481 }
1540 strlcpy(utsna !! 1482 strlcpy(system_utsname.nodename, ip,
1541 sizeo !! 1483 sizeof(system_utsname.nodename));
1542 ic_host_name_ 1484 ic_host_name_set = 1;
1543 break; 1485 break;
1544 case 5: 1486 case 5:
1545 strlcpy(user_ 1487 strlcpy(user_dev_name, ip, sizeof(user_dev_name));
1546 break; 1488 break;
1547 case 6: 1489 case 6:
1548 if (ic_proto_ !! 1490 ic_proto_name(ip);
1549 ic_myaddr <<
1550 ic_en <<
1551 } <<
1552 break; 1491 break;
1553 } 1492 }
1554 } 1493 }
1555 ip = cp; 1494 ip = cp;
1556 num++; 1495 num++;
1557 } 1496 }
1558 1497
1559 return 1; 1498 return 1;
1560 } 1499 }
1561 1500
1562 static int __init nfsaddrs_config_setup(char 1501 static int __init nfsaddrs_config_setup(char *addrs)
1563 { 1502 {
1564 return ip_auto_config_setup(addrs); 1503 return ip_auto_config_setup(addrs);
1565 } 1504 }
1566 1505
1567 static int __init vendor_class_identifier_set <<
1568 { <<
1569 if (strlcpy(vendor_class_identifier, <<
1570 sizeof(vendor_class_ident <<
1571 >= sizeof(vendor_class_identifier <<
1572 printk(KERN_WARNING "DHCP: ve <<
1573 vendor_class_identifie <<
1574 return 1; <<
1575 } <<
1576 <<
1577 __setup("ip=", ip_auto_config_setup); 1506 __setup("ip=", ip_auto_config_setup);
1578 __setup("nfsaddrs=", nfsaddrs_config_setup); 1507 __setup("nfsaddrs=", nfsaddrs_config_setup);
1579 __setup("dhcpclass=", vendor_class_identifier <<
1580 1508
|
This page was automatically generated by the
LXR engine.
|