* Fix un/packing of EDNS0 TCP keepalive extension
The current code is assuming the OPT code and length are part of the
data passed to the unpacker and that it should be appenedded during
packing while those fields are parsed by the caller.
This change fixes the parsing and make sure a request with a keepalive
won't fail.
* added tests for EDNS0_TCP_KEEPALIVE pack/unpack
* mark Length as deprecated
* removed named returns
* restored String
Co-authored-by: Olivier Poitrey <rs@rhapsodyk.net>
Replace all the private methods in the EDNS0 with public methods.
Additionally, as suggested in issue #857, made Pack receive a
pre-allocated byte array, introduce a Len method, and have Pack
and Unpack return the number of octets written and read (respectively)
if there was no error.
Closes#857
* properly set extended rcode when packing
When calling `SetExtendedRcode`, we expect to get the full extended
rcode, not the rcode after we shift 4 bytes right.
* fix extended rcode
* fix TestOPTTtl test
* set error messages in TestPackExtendedBadCookie
* Set Rcode with extended rcode
* |=
* Set extended RCODE field to 0 when RCODE is not an extended one.
+ unittests
* Force setting extended rcode if we have an OPT available.
* go fmt + @tmthrgd comments
* comments and nits
* reformat comment
* Function to clear the DO bit from an OPT RR.
* Tests for ClearDo() function.
* Changed from ClearDo() to SetDo() with an optional argument.
* Update doc string for SetDo(). Make tests for SetDo() comprehensive.
We were off by a value of 15. This fixes it. Hard to come up with a test
as writing and reading it yourself will be consistent.
Don't allows extended rcodes smaller than 16. And fix the tests as well.