From aaf4af6401540e9dffee645e2c6e7c6cb3211eae Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Mon, 22 Aug 2011 10:29:39 +0200 Subject: [PATCH] add: setUpdate to create update packets --- defaults.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/defaults.go b/defaults.go index 1f487b14..7aa1b0ca 100644 --- a/defaults.go +++ b/defaults.go @@ -42,7 +42,7 @@ func (dns *Msg) SetRcode(request *Msg, rcode int) { dns.Question[0] = request.Question[0] } -// IsRocde checks if the header of the packet has rcode set. +// IsRcode checks if the header of the packet has rcode set. func (dns *Msg) IsRcode(rcode int) (ok bool) { if len(dns.Question) == 0 { return false @@ -69,7 +69,7 @@ func (dns *Msg) IsRcodeFormatError() (ok bool) { return } -// Is the message a dynamic update packet? +// IsUpdate checks if the message is a dynamic update packet? func (dns *Msg) IsUpdate() (ok bool) { if len(dns.Question) == 0 { return false @@ -79,6 +79,14 @@ func (dns *Msg) IsUpdate() (ok bool) { return } +// SetUpdate makes the message a dynamic update packet. It +// sets the ZONE section to: z, TypeSOA, classINET. +func (dns *Msg) SetUpdate(z string) { + dns.MsgHdr.Opcode = OpcodeUpdate + dns.Question = make([]Question, 1) + dns.Question[0] = Question{z, TypeSOA, ClassINET} +} + // Is the message a valid notify packet? func (dns *Msg) IsNotify() (ok bool) { if len(dns.Question) == 0 {