| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: nfs_bootdhcp.c,v 1.46 2009/05/02 21:06:51 manu Exp $ */ | | 1 | /* $NetBSD: nfs_bootdhcp.c,v 1.47 2009/05/05 12:48:31 cegger Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1995, 1997 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1995, 1997 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Adam Glass and Gordon W. Ross. | | 8 | * by Adam Glass and Gordon W. Ross. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -34,27 +34,27 @@ | | | @@ -34,27 +34,27 @@ |
34 | * | | 34 | * |
35 | * History: | | 35 | * History: |
36 | * | | 36 | * |
37 | * Tor Egge developed the initial version of this code based on | | 37 | * Tor Egge developed the initial version of this code based on |
38 | * the Sun RPC/bootparam sources nfs_boot.c and krpc_subr.c and | | 38 | * the Sun RPC/bootparam sources nfs_boot.c and krpc_subr.c and |
39 | * submitted that work to NetBSD as bugreport "kern/2351" on | | 39 | * submitted that work to NetBSD as bugreport "kern/2351" on |
40 | * 29 Apr 1996. | | 40 | * 29 Apr 1996. |
41 | * | | 41 | * |
42 | * Gordon Ross reorganized Tor's version into this form and | | 42 | * Gordon Ross reorganized Tor's version into this form and |
43 | * integrated it into the NetBSD sources during Aug 1997. | | 43 | * integrated it into the NetBSD sources during Aug 1997. |
44 | */ | | 44 | */ |
45 | | | 45 | |
46 | #include <sys/cdefs.h> | | 46 | #include <sys/cdefs.h> |
47 | __KERNEL_RCSID(0, "$NetBSD: nfs_bootdhcp.c,v 1.46 2009/05/02 21:06:51 manu Exp $"); | | 47 | __KERNEL_RCSID(0, "$NetBSD: nfs_bootdhcp.c,v 1.47 2009/05/05 12:48:31 cegger Exp $"); |
48 | | | 48 | |
49 | #ifdef _KERNEL_OPT | | 49 | #ifdef _KERNEL_OPT |
50 | #include "opt_nfs_boot.h" | | 50 | #include "opt_nfs_boot.h" |
51 | #include "opt_tftproot.h" | | 51 | #include "opt_tftproot.h" |
52 | #endif | | 52 | #endif |
53 | | | 53 | |
54 | #include <sys/param.h> | | 54 | #include <sys/param.h> |
55 | #include <sys/systm.h> | | 55 | #include <sys/systm.h> |
56 | #include <sys/kernel.h> | | 56 | #include <sys/kernel.h> |
57 | #include <sys/device.h> | | 57 | #include <sys/device.h> |
58 | #include <sys/ioctl.h> | | 58 | #include <sys/ioctl.h> |
59 | #include <sys/proc.h> | | 59 | #include <sys/proc.h> |
60 | #include <sys/mount.h> | | 60 | #include <sys/mount.h> |
| @@ -315,32 +315,32 @@ bootpset(struct mbuf *m, void *context, | | | @@ -315,32 +315,32 @@ bootpset(struct mbuf *m, void *context, |
315 | | | 315 | |
316 | static int | | 316 | static int |
317 | bootpcheck(struct mbuf *m, void *context) | | 317 | bootpcheck(struct mbuf *m, void *context) |
318 | { | | 318 | { |
319 | struct bootp *bootp; | | 319 | struct bootp *bootp; |
320 | struct bootpcontext *bpc = context; | | 320 | struct bootpcontext *bpc = context; |
321 | u_int tag, len; | | 321 | u_int tag, len; |
322 | u_char *p, *limit; | | 322 | u_char *p, *limit; |
323 | | | 323 | |
324 | /* | | 324 | /* |
325 | * Is this a valid reply? | | 325 | * Is this a valid reply? |
326 | */ | | 326 | */ |
327 | if (m->m_pkthdr.len < BOOTP_SIZE_MIN) { | | 327 | if (m->m_pkthdr.len < BOOTP_SIZE_MIN) { |
328 | DPRINTF(("bootpcheck: short packet %d < %ld\n", | | 328 | DPRINTF(("bootpcheck: short packet %d < %d\n", |
329 | m->m_pkthdr.len, BOOTP_SIZE_MIN)); | | 329 | m->m_pkthdr.len, BOOTP_SIZE_MIN)); |
330 | return (-1); | | 330 | return (-1); |
331 | } | | 331 | } |
332 | if (m->m_pkthdr.len > BOOTP_SIZE_MAX) { | | 332 | if (m->m_pkthdr.len > BOOTP_SIZE_MAX) { |
333 | DPRINTF(("Bootpcheck: long packet %d > %ld\n", | | 333 | DPRINTF(("Bootpcheck: long packet %d > %d\n", |
334 | m->m_pkthdr.len, BOOTP_SIZE_MAX)); | | 334 | m->m_pkthdr.len, BOOTP_SIZE_MAX)); |
335 | return (-1); | | 335 | return (-1); |
336 | } | | 336 | } |
337 | | | 337 | |
338 | /* | | 338 | /* |
339 | * don't make first checks more expensive than necessary | | 339 | * don't make first checks more expensive than necessary |
340 | */ | | 340 | */ |
341 | if (m->m_len < offsetof(struct bootp, bp_sname)) { | | 341 | if (m->m_len < offsetof(struct bootp, bp_sname)) { |
342 | m = m_pullup(m, offsetof(struct bootp, bp_sname)); | | 342 | m = m_pullup(m, offsetof(struct bootp, bp_sname)); |
343 | if (m == NULL) { | | 343 | if (m == NULL) { |
344 | DPRINTF(("bootpcheck: m_pullup failed\n")); | | 344 | DPRINTF(("bootpcheck: m_pullup failed\n")); |
345 | return (-1); | | 345 | return (-1); |
346 | } | | 346 | } |