infusion / node-dhcp

A DHCP server and client written in pure JavaScript
https://raw.org/article/a-pure-javascript-dhcp-implementation/
MIT License
299 stars 75 forks source link

DHCP OFFER message missing / broken in Microsoft devices #56

Closed XantheFIN closed 5 years ago

XantheFIN commented 5 years ago

I was thinking why my Thinkpad WinXP laptop doesn't understand DHCP offer or Xbox 360 and https://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol example here i noticed that it sends message like this:

Option 1 : Subnet Mask Option 3: Router Option 6:Domain Name Server Option 12:Host Name Option 51:IP address Lease time Option 53:DHCP Message Type Option 54:DHCP Server Identifier Option 255:-End-

When example macOS InternetSharing makes too message like in wikipedia:

Option 53:DHCP Message Type Option 54:DHCP Server Identifier Option 51:IP address Lease time Option 1 : Subnet Mask Option 3: Router Option 6:Domain Name Server Option 12:Host Name (not actually send on it) Option 255:-End-

Maybe solves that issue when rearranged? I tried take a look how it is done but sorry i didn't get the code honestly now myself how to fix it... at least yet.

At the _getOptions: function(pre, required, requested) { Function.

infusion commented 5 years ago

I never heard of a specific order of DHCP options. Can you find a reference for that if that exists? If you want to have an ordering quickly hacked into it, I would add it to the addOption function of SeqBuffer.

XantheFIN commented 5 years ago

Hmm..

From RFC 2132

9.8. Parameter Request List

This option is used by a DHCP client to request values for specified configuration parameters. The list of requested parameters is specified as n octets, where each octet is a valid DHCP option code as defined in this document.

The client MAY list the options in order of preference. The DHCP server is not required to return the options in the requested order, but MUST try to insert the requested options in the order requested by the client.

But then Microsoft shows their example in order: https://support.microsoft.com/en-us/help/169289/dhcp-dynamic-host-configuration-protocol-basics

I can't test changing order because i looked couple hours and tried Object key and so but because of array opt.type wasn't working... So my skills ends there for now sorry to even try theory.

 1, 15,  3,  6,  44,
      46, 47, 31, 33, 249,
      43

These is been asked options.. But nothing really missing anything else than order is different when compared to working one (macOS own) which confuses me.

Thanks for comment!

PS3, Linux works but Microsoft doesn't get DHCP Offer.

XantheFIN commented 5 years ago

Update i managed to get them in same order than working solution in place what was suggested. BUT It still fails so i look other areas than options now to fix this issue. There is couple spots still what is kinda of lacking of data.

Will work on my fork of this.