Introduce a way for boot programs to modify the behavior of
bootp(). Add a BOOTP_PXE flag which causes bootp() to send "PXEClient" in the DHCP class field. Derived from similar code in FreeBSD.
This commit is contained in:
parent
6a3b366a8c
commit
29b685b9f0
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: bootp.c,v 1.19 2000/03/30 12:19:47 augustss Exp $ */
|
||||
/* $NetBSD: bootp.c,v 1.20 2000/11/02 03:22:23 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992 Regents of the University of California.
|
||||
@ -84,6 +84,12 @@ static char expected_dhcpmsgtype = -1, dhcp_ok;
|
||||
struct in_addr dhcp_serverip;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Boot programs can patch this at run-time to change the behavior
|
||||
* of bootp/dhcp.
|
||||
*/
|
||||
int bootp_flags;
|
||||
|
||||
/* Fetch required bootp infomation */
|
||||
void
|
||||
bootp(sock)
|
||||
@ -130,6 +136,17 @@ bootp(sock)
|
||||
bp->bp_vend[4] = TAG_DHCP_MSGTYPE;
|
||||
bp->bp_vend[5] = 1;
|
||||
bp->bp_vend[6] = DHCPDISCOVER;
|
||||
/*
|
||||
* If we are booting from PXE, we want to send the string
|
||||
* "PXEClient" to the DHCP server in case it only wants to
|
||||
* respond to PXE clients.
|
||||
*/
|
||||
if (bootp_flags & BOOTP_PXE) {
|
||||
bp->bp_vend[7] = TAG_CLASSID;
|
||||
bp->bp_vend[8] = 9;
|
||||
bcopy("PXEClient", &bp->bp_vend[9], 9);
|
||||
bp->bp_vend[18] = TAG_END;
|
||||
} else
|
||||
bp->bp_vend[7] = TAG_END;
|
||||
#else
|
||||
bp->bp_vend[4] = TAG_END;
|
||||
@ -167,6 +184,12 @@ bootp(sock)
|
||||
bp->bp_vend[20] = 4;
|
||||
leasetime = htonl(300);
|
||||
bcopy(&leasetime, &bp->bp_vend[21], 4);
|
||||
if (bootp_flags & BOOTP_PXE) {
|
||||
bp->bp_vend[25] = TAG_CLASSID;
|
||||
bp->bp_vend[26] = 9;
|
||||
bcopy("PXEClient", &bp->bp_vend[27], 9);
|
||||
bp->bp_vend[36] = TAG_END;
|
||||
}
|
||||
bp->bp_vend[25] = TAG_END;
|
||||
|
||||
expected_dhcpmsgtype = DHCPACK;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: bootp.h,v 1.5 1999/02/11 09:10:43 pk Exp $ */
|
||||
/* $NetBSD: bootp.h,v 1.6 2000/11/02 03:22:23 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Bootstrap Protocol (BOOTP). RFC951 and RFC1048.
|
||||
@ -117,6 +117,13 @@ struct bootp {
|
||||
#define DHCPRELEASE 7
|
||||
#endif
|
||||
|
||||
extern int bootp_flags;
|
||||
|
||||
/*
|
||||
* Flags for bootp_flags.
|
||||
*/
|
||||
#define BOOTP_PXE 0x01 /* we're a PXE client */
|
||||
|
||||
/*
|
||||
* "vendor" data permitted for CMU bootp clients.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user