CyberShadow / dhcptest

Cross-platform DHCP test client
https://blog.cy.md/2013/01/10/dhcp-test-client
363 stars 57 forks source link

Setting lease time does not work correctly #11

Closed mrock42 closed 7 years ago

mrock42 commented 8 years ago

When specifying a lease time, such as with --option 51=0060 , I see an output like:

  2 options:
     53 (DHCP Message Type): discover
     51 (IP Address Lease Time): 808465968 (1336 weeks, 5 days, 5 hours, 52 minutes, and 48 secs)

Using --option 51="0060" or --option "51=0060" results in the same output as above.

CyberShadow commented 8 years ago

I think you meant --option 51[hex]=0060?

mrock42 commented 8 years ago

Using it as "--option 51[hex]=0000003C" works correctly to use a timeout of 60 seconds. So when passing in like "--option 51=0060" it is using the ascii values... that's unusual. Without the [hex], shouldn't it use the displayed number as the value? so "--option 51=60" would be 60 seconds?

CyberShadow commented 8 years ago

Well, DHCPTest can't know all possible DHCP options, as there are some used privately, so it can't know how the value is encoded for every option. Right now the default encoding is string (ASCII). Autodetecting the type from the value is also problematic because a numeric value might be actually intended as a string one.

mrock42 commented 8 years ago

I'm happy with the hex. I'm happy that you put this together, even if there was no way to set the option!

No pressure from me, but if you wanted, it seems that leasetime, timeoffset, renewaltime, rebindingtime are all specially handled currently, and that you could extend that to parse a numeric string.

CyberShadow commented 8 years ago

Okay. Sorry, I haven't looked at the code in a while, and I think the type specification was actually implemented by someone else.