[Dnsmasq-discuss] Booting WinPE on Legacy and UEFI mode

David Müller dave.mueller at gmx.ch
Thu Apr 8 08:42:01 UTC 2021


Hello

I'm trying to use Dnsmasq to boot WinPE (both in legacy and UEFI mode)
over PXE based on the instructions on
https://docs.microsoft.com/en-us/windows/deployment/configure-a-pxe-server-to-load-windows-pe


While the same "boot.sdi" and "boot.wim" files work for both modes,
different bootloaders and slightly adjusted BCD files need to be provide
for legacy and UEFI mode.

The different bootloaders I can handle using appropriately tagged
"pxe-service" directives, but I seems like DHCP option 252 must be used
to tell the Windows PXE bootloaders which BCD file to use.

Unfortunately Dnsmasq does not seem to provide the necessary
functionality to specify the correct BCD file for different architectures.

Am I missing something here?
Or would a patch as shown below be acceptable?


diff --git a/src/rfc2131.c b/src/rfc2131.c
index 3f50755..2a2f08f 100644
--- a/src/rfc2131.c
+++ b/src/rfc2131.c
@@ -40,6 +40,7 @@ static unsigned char *option_find1(unsigned char *p,
unsigned char *end, int opt
 static size_t dhcp_packet_size(struct dhcp_packet *mess, unsigned char
*agent_id, unsigned char *real_end);
 static void clear_packet(struct dhcp_packet *mess, unsigned char *end);
 static int in_list(unsigned char *list, int opt);
+static struct dhcp_opt *option_find2(int opt);
 static void do_options(struct dhcp_context *context,
                       struct dhcp_packet *mess,
                       unsigned char *end,
@@ -911,7 +912,15 @@ size_t dhcp_reply(struct dhcp_context *context,
char *iface_name, int int_index,
          opt71.netid = NULL;
          opt71.next = daemon->dhcp_opts;
          do_encap_opts(&opt71, OPTION_VENDOR_CLASS_OPT,
DHOPT_VENDOR_MATCH, mess, end, 0);
-
+
+         /*
+          * DHCP option 252 allows to change to BCD file name (+ path)
+          * used by Windows PXE network bootloaders
+          */
+         o = option_find2(252);
+         if (o && (o->flags & DHOPT_FORCE))
+           option_put_string(mess, end, 252, (const char *)o->val, 1);
+
          log_packet("PXE", &mess->yiaddr, emac, emac_len, iface_name,
(char *)mess->file, NULL, mess->xid);
          log_tags(tagif_netid, ntohl(mess->xid));
          return dhcp_packet_size(mess, agent_id, real_end);

Thanks



More information about the Dnsmasq-discuss mailing list