Pass a "FREEBSD" user-class in PXE dhcp request

rfc3004 allows to pass multiple user classes on dhcp requests
this is used by dhcp servers to differentiate the caller if needed.

As an example with isc dhcp server it will be possible to make options
only for the FreeBSD loaders:

if exists user-class and option user-class = "FREEBSD" {
   option root-path "tftp://192.168.42.1/FreeBSD;
}

Reviewed by:	tsoome
Differential Revision:	https://reviews.freebsd.org/D10951
This commit is contained in:
Baptiste Daroussin 2017-05-27 10:50:35 +00:00
parent 335917f071
commit 6180f83d95
2 changed files with 15 additions and 10 deletions

View File

@ -146,16 +146,20 @@ bootp(int sock, int flag)
bp->bp_vend[7] = TAG_CLASSID;
bp->bp_vend[8] = 9;
bcopy("PXEClient", &bp->bp_vend[9], 9);
bp->bp_vend[18] = TAG_PARAM_REQ;
bp->bp_vend[19] = 7;
bp->bp_vend[20] = TAG_ROOTPATH;
bp->bp_vend[21] = TAG_HOSTNAME;
bp->bp_vend[22] = TAG_SWAPSERVER;
bp->bp_vend[23] = TAG_GATEWAY;
bp->bp_vend[24] = TAG_SUBNET_MASK;
bp->bp_vend[25] = TAG_INTF_MTU;
bp->bp_vend[26] = TAG_SERVERID;
bp->bp_vend[27] = TAG_END;
bp->bp_vend[18] = TAG_USER_CLASS;
bp->bp_vend[19] = 8;
bp->bp_vend[20] = 7;
bcopy("FREEBSD", &bp->bp_vend[21], 7);
bp->bp_vend[28] = TAG_PARAM_REQ;
bp->bp_vend[29] = 7;
bp->bp_vend[30] = TAG_ROOTPATH;
bp->bp_vend[31] = TAG_HOSTNAME;
bp->bp_vend[32] = TAG_SWAPSERVER;
bp->bp_vend[33] = TAG_GATEWAY;
bp->bp_vend[34] = TAG_SUBNET_MASK;
bp->bp_vend[35] = TAG_INTF_MTU;
bp->bp_vend[36] = TAG_SERVERID;
bp->bp_vend[37] = TAG_END;
} else
bp->bp_vend[7] = TAG_END;
#else

View File

@ -108,6 +108,7 @@ struct bootp {
#define TAG_T2 ((unsigned char) 59)
#define TAG_CLASSID ((unsigned char) 60)
#define TAG_CLIENTID ((unsigned char) 61)
#define TAG_USER_CLASS ((unsigned char) 77)
#endif
#define TAG_END ((unsigned char) 255)