add: setUpdate to create update packets

This commit is contained in:
Miek Gieben 2011-08-22 10:29:39 +02:00
parent 146845ebde
commit aaf4af6401
1 changed files with 10 additions and 2 deletions

View File

@ -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 {