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

Make IsOptionRequested() work with GenericOptionCode #528

Merged
merged 2 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dhcpv4/dhcpv4.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ func (d *DHCPv4) IsOptionRequested(requested OptionCode) bool {
}

for _, o := range rq {
if o == requested {
if o.Code() == requested.Code() {
return true
}
}
Expand Down
13 changes: 13 additions & 0 deletions dhcpv4/dhcpv4_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,19 @@ func TestIsOptionRequested(t *testing.T) {
require.True(t, pkt.IsOptionRequested(OptionDomainNameServer))
}

func TestIsGenericOptionRequested(t *testing.T) {
pkt, err := New()
require.NoError(t, err)

var genericOption224 = GenericOptionCode(224)
var genericOption225 = GenericOptionCode(225)
pkt.UpdateOption(OptParameterRequestList(OptionBroadcastAddress, genericOption224))
require.True(t, pkt.IsOptionRequested(OptionBroadcastAddress))
require.False(t, pkt.IsOptionRequested(OptionSwapServer))
require.True(t, pkt.IsOptionRequested(genericOption224), "Did not detect generic option 224 in <%v>", pkt.ParameterRequestList())
require.False(t, pkt.IsOptionRequested(genericOption225), "Detected generic option 225 in <%v>", pkt.ParameterRequestList())
}

// TODO
// test Summary() and String()
func TestSummary(t *testing.T) {
Expand Down
Loading