More convience functions

This commit is contained in:
Miek Gieben 2011-01-06 15:24:18 +01:00
parent 7888cd96b8
commit 0040c9b30e
2 changed files with 8 additions and 4 deletions

View File

@ -117,7 +117,12 @@ func (rr *RR_OPT) Nsid() string {
}
// Set the NSID
func (rr *RR_OPT) SetNsid(nsid string) {
func (rr *RR_OPT) SetNsidToHex(hexnsid string) {
rr.Option[0].Code = OptionCodeNSID
rr.Option[0].Data = nsid
rr.Option[0].Data = hexnsid
}
func (rr *RR_OPT) SetNsidToString(nsid string) {
rr.Option[0].Code = OptionCodeNSID
rr.Option[0].Data = hex.EncodeToString([]byte(nsid))
}

View File

@ -31,8 +31,7 @@ func TestPackUnpack(t *testing.T) {
edns.Hdr.Class = ClassINET
edns.Hdr.Ttl = 3600
edns.Option = make([]Option, 1)
edns.Option[0].Code = OptionCodeNSID
edns.Option[0].Data = "lalalala"
edns.SetNsidToString("lalalala")
_, ok = packRR(edns, msg, 0)
if !ok {