add a IsUpdate function

This commit is contained in:
Miek Gieben 2011-03-25 10:16:55 +01:00
parent 15518a578f
commit 9ac4df6b1d
1 changed files with 10 additions and 2 deletions

View File

@ -13,8 +13,6 @@ func (dns *Msg) SetReply(request *Msg) {
dns.Question[0] = request.Question[0] dns.Question[0] = request.Question[0]
} }
// IsReply?
// Create a notify packet. // Create a notify packet.
func (dns *Msg) SetNotify(z string, class uint16) { func (dns *Msg) SetNotify(z string, class uint16) {
dns.MsgHdr.Opcode = OpcodeNotify dns.MsgHdr.Opcode = OpcodeNotify
@ -24,6 +22,16 @@ func (dns *Msg) SetNotify(z string, class uint16) {
dns.Question[0] = Question{z, TypeSOA, class} 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? // Is the message a valid notify packet?
func (dns *Msg) IsNotify() (ok bool) { func (dns *Msg) IsNotify() (ok bool) {
if len(dns.Question) == 0 { if len(dns.Question) == 0 {