CyberShadow / dhcptest

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

Adding Option 121 (Classless static route) #30

Closed Dronec closed 1 year ago

CyberShadow commented 1 year ago

I've read the RFC and it seems to describe something that doesn't align with the implementation here. For one thing, it looks like the route descriptors are variable-length.

Dronec commented 1 year ago

good point! I've oversimplifed it and only looked at the output of my local DHCP server. Should've read the RFC first. I'll update the code and make another push.

CyberShadow commented 1 year ago

I've made some small changes, could you please check if it still works on your end?

Dronec commented 1 year ago

I've made some small changes, could you please check if it still works on your end?

Pulled, recompiled and tested, looks good image

CyberShadow commented 1 year ago

Thanks!

CyberShadow commented 1 year ago

Oops, actually I forgot to push the bulk of the changes I wanted to include... I pushed them to master.

https://github.com/CyberShadow/dhcptest/commit/19cd1e2fe13c779bce67dc7bbfe526a6d3d31f08

Dronec commented 1 year ago

Thanks!

Thank you! This tool came very handy for testing DHCP design.

Dronec commented 1 year ago

Oops, actually I forgot to push the bulk of the changes I wanted to include... I pushed them to master.

19cd1e2

Hate to say that, but the refactoring broke it: image

You can fix it by changing row #406 to

ubyte subnetSignificantBytes = cast(ubyte)ceil(maskBits * 0.125);

image

CyberShadow commented 1 year ago

Hate to say that, but the refactoring broke it:

Well, thanks for saying it! I forgot the parens. 🤦

I pushed a fix, could you please test it?

Dronec commented 1 year ago

Hate to say that, but the refactoring broke it:

Well, thanks for saying it! I forgot the parens. 🤦

I pushed a fix, could you please test it?

tested, everything looks good. Thanks!

alexindigo commented 3 weeks ago

Trying to use option=121 with the test request, and it's erroring out:

dhcptest --query --option 121
dhcptest v0.9 - Created by Vladimir Panteleev
https://github.com/CyberShadow/dhcptest
Run with --help for a list of command-line options.

Listening for DHCP replies on port 68.
Error with parsing option 121:
Fatal error: Sorry, the format classlessStaticRoute is unsupported for parsing. Please specify another format explicitly.

Curious what's I'm missing there.

For context I'm trying to reproduce this dhcp request:

dnsmasq-dhcp[9]: 445169678 vendor class: dhcpcd-8.1.6:Linux-4.9.77:armv7l:ecobee
dnsmasq-dhcp[9]: 445169678 client provides name: Thermostat
dnsmasq-dhcp[9]: 445169678 DHCPREQUEST(eth2) 10.1.30.105 44:61:32:b1:89:d9 
dnsmasq-dhcp[9]: 445169678 tags: red, eth2
dnsmasq-dhcp[9]: 445169678 DHCPACK(eth2) 10.1.30.105 44:61:32:b1:89:d9 Thermostat
dnsmasq-dhcp[9]: 445169678 requested options: 1:netmask, 121:classless-static-route, 33:static-route, 
dnsmasq-dhcp[9]: 445169678 requested options: 3:router, 6:dns-server, 12:hostname, 15:domain-name, 
dnsmasq-dhcp[9]: 445169678 requested options: 26:mtu, 28:broadcast, 51:lease-time, 54:server-identifier, 
dnsmasq-dhcp[9]: 445169678 requested options: 58:T1, 59:T2, 119:domain-search

Thank you.