Name some numeric constants#27
Conversation
240 is the minimum size of a DHCP packet. Since it is used at various places, use a named constant instead. It is also exposed to the user. The DHCP magic cookie also gets a named variable.
|
240 is really the Options start point, and calling it Minimal packet size where it relates to Option handling (which is all but one time) would in my opinion cause confusion. It could be a private const inside server.go where only that 240 is changed (that may increase clarity, but the comment explains the purpose anyway). If 240 is turned into a const inside packet.go, it should be called something else (i.e OptionStart), and then all the other start points would have to follow - which I don't believe is necessary or helpful. Magic cookie, IMHO need not to be exposed to the user. If it needs to checked, for received message validation, then that check should be added to server.go, in which case a var may be beneficial. |
|
In my case, I don't use As for the cookie, same as above, I don't user |
|
I've very cautious about making changes for convenience (now that large organisations are using it), especially when adding two lines to your own code will solve your issue. It's unfortunate, my library wasn't designed like dhcpr, but what's done is done. I'm leaving this open to think on this some more. |
|
The change is about adding constants. This won't break any existing code (unlike other changes, like not sending the lease time anymore). |
240 is the minimum size of a DHCP packet. Since it is used at various
places, use a named constant instead. It is also exposed to the
user. The DHCP magic cookie also gets a named variable.