From 9ac4df6b1dc7be1cecc2c4f67f365d9a4e312b8c Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Fri, 25 Mar 2011 10:16:55 +0100 Subject: [PATCH] add a IsUpdate function --- defaults.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/defaults.go b/defaults.go index eaf52730..2b36742f 100644 --- a/defaults.go +++ b/defaults.go @@ -13,8 +13,6 @@ func (dns *Msg) SetReply(request *Msg) { dns.Question[0] = request.Question[0] } -// IsReply? - // Create a notify packet. func (dns *Msg) SetNotify(z string, class uint16) { dns.MsgHdr.Opcode = OpcodeNotify @@ -24,6 +22,16 @@ func (dns *Msg) SetNotify(z string, class uint16) { dns.Question[0] = Question{z, TypeSOA, class} } +// Is the message a dynamic update packet? +func (dns *Msg) IsUpdate() (ok bool) { + if len(dns.Question) == 0 { + return false + } + ok = dns.MsgHdr.Opcode == OpcodeUpdate + ok = ok && dns.Question[0].Qtype == TypeSOA + return +} + // Is the message a valid notify packet? func (dns *Msg) IsNotify() (ok bool) { if len(dns.Question) == 0 {