Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse --dhcp-host #24

Merged
merged 20 commits into from
Dec 12, 2024
Merged

Parse --dhcp-host #24

merged 20 commits into from
Dec 12, 2024

Conversation

reynir
Copy link
Contributor

@reynir reynir commented Dec 11, 2024

I think the parser is more or less there. I plan on adding tests.

I still don't quite understand how all the values are to be used. We may want to error out on certain values and combinations. Part of the values are for matching a client, some are values to assign to the client. Then we have the ignore flag which means we should not handle a client matching - in that case the values to assign have questionable meaning.

Dnsmasq uses a function parse_hex() for parsing mac addresses but also id:s if there are any colons in the id value. The function is really obscure, and allows you to write an id id:41------424344:*:*:*:* that, likely due to a safety bug, is the same as id:ABCD----. There's a lot of nonsense in there that I don't think we should support.

Mac address parsing could as well be improved. In particular there's no wildcards yet (you can write a mac address "pattern" 00:11:*:*:44:55 where the middle two bytes match any value).

@reynir reynir marked this pull request as ready for review December 11, 2024 17:16
@reynir
Copy link
Contributor Author

reynir commented Dec 11, 2024

I added a number of tests. There are two tests that are commented out with a TODO. Namely one featuring wildcards in mac addresses, and another one with an ipv6 address. I think the latter should be easy to implement, but if that is only applicable for DHCPv6, which I don't think we have an implementation for, it's maybe not worth implementing.

@hannesm
Copy link
Contributor

hannesm commented Dec 12, 2024

looks fine to me, should there be a test using the tag stuff?

The "net:" thing is deprecated and the documentation only uses "set:".
@reynir
Copy link
Contributor Author

reynir commented Dec 12, 2024

I pushed a commit that changes some internal naming. The net: and set: fields are stored in the same struct member, but I see that the documentation only ever mentions set: so let's use that over the undocumented one.

We should allow non-decimal hex characters in the first byte of a mac
address. This also changes one of the tests to trigger this bug.
The set: field assigns a tag while tag: matches with a previously
assigned tag.
reynir and others added 3 commits December 12, 2024 11:46
Co-authored-by: Hannes Mehnert <[email protected]>
The net: syntax is a backwards compatible form of set:
Dnsmasq will silently ignore duplicate values for some of the dhcp-host
arguments. We will error out and inform the user of this.
@reynir reynir merged commit ddb88b4 into main Dec 12, 2024
2 of 3 checks passed
@reynir reynir deleted the conf-dhcp-host branch December 12, 2024 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants