SMall fixes

This commit is contained in:
Miek Gieben 2011-07-26 21:41:24 +02:00
parent e7a8eece9b
commit 5087f5a993
1 changed files with 18 additions and 2 deletions

View File

@ -41,9 +41,16 @@ func (dns *Msg) SetRcode(request *Msg, rcode int) {
dns.Question = make([]Question, 1)
dns.Question[0] = request.Question[0]
}
// TODO isRcode for symmetry
// Create a FormError packet.
func (dns *Msg) IsRcode(rcode int) (ok bool) {
if len(dns.Question) == 0 {
return false
}
ok = dns.MsgHdr.Rcode == rcode
return
}
// Create a packet with FormError set.
func (dns *Msg) SetRcodeFormatError(request *Msg) {
dns.MsgHdr.Rcode = RcodeFormatError
dns.MsgHdr.Opcode = OpcodeQuery
@ -52,6 +59,15 @@ func (dns *Msg) SetRcodeFormatError(request *Msg) {
dns.MsgHdr.Id = request.MsgHdr.Id
}
// Is the message a packet with the FormErr set?
func (dns *Msg) IsRcodeFormatError() (ok bool) {
if len(dns.Question) == 0 {
return false
}
ok = dns.MsgHdr.Rcode == RcodeFormatError
return
}
// Is the message a dynamic update packet?
func (dns *Msg) IsUpdate() (ok bool) {
if len(dns.Question) == 0 {