3 // NameUsed sets the RRs in the prereq section to
4 // "Name is in use" RRs. RFC 2136 section 2.4.4.
5 func (u *Msg) NameUsed(rr []RR) {
7 u.Answer = make([]RR, 0, len(rr))
10 u.Answer = append(u.Answer, &ANY{Hdr: RR_Header{Name: r.Header().Name, Ttl: 0, Rrtype: TypeANY, Class: ClassANY}})
14 // NameNotUsed sets the RRs in the prereq section to
15 // "Name is in not use" RRs. RFC 2136 section 2.4.5.
16 func (u *Msg) NameNotUsed(rr []RR) {
18 u.Answer = make([]RR, 0, len(rr))
20 for _, r := range rr {
21 u.Answer = append(u.Answer, &ANY{Hdr: RR_Header{Name: r.Header().Name, Ttl: 0, Rrtype: TypeANY, Class: ClassNONE}})
25 // Used sets the RRs in the prereq section to
26 // "RRset exists (value dependent -- with rdata)" RRs. RFC 2136 section 2.4.2.
27 func (u *Msg) Used(rr []RR) {
28 if len(u.Question) == 0 {
29 panic("dns: empty question section")
32 u.Answer = make([]RR, 0, len(rr))
34 for _, r := range rr {
35 r.Header().Class = u.Question[0].Qclass
36 u.Answer = append(u.Answer, r)
40 // RRsetUsed sets the RRs in the prereq section to
41 // "RRset exists (value independent -- no rdata)" RRs. RFC 2136 section 2.4.1.
42 func (u *Msg) RRsetUsed(rr []RR) {
44 u.Answer = make([]RR, 0, len(rr))
46 for _, r := range rr {
48 u.Answer = append(u.Answer, &ANY{Hdr: RR_Header{Name: h.Name, Ttl: 0, Rrtype: h.Rrtype, Class: ClassANY}})
52 // RRsetNotUsed sets the RRs in the prereq section to
53 // "RRset does not exist" RRs. RFC 2136 section 2.4.3.
54 func (u *Msg) RRsetNotUsed(rr []RR) {
56 u.Answer = make([]RR, 0, len(rr))
58 for _, r := range rr {
60 u.Answer = append(u.Answer, &ANY{Hdr: RR_Header{Name: h.Name, Ttl: 0, Rrtype: h.Rrtype, Class: ClassNONE}})
64 // Insert creates a dynamic update packet that adds an complete RRset, see RFC 2136 section 2.5.1.
65 func (u *Msg) Insert(rr []RR) {
66 if len(u.Question) == 0 {
67 panic("dns: empty question section")
70 u.Ns = make([]RR, 0, len(rr))
72 for _, r := range rr {
73 r.Header().Class = u.Question[0].Qclass
74 u.Ns = append(u.Ns, r)
78 // RemoveRRset creates a dynamic update packet that deletes an RRset, see RFC 2136 section 2.5.2.
79 func (u *Msg) RemoveRRset(rr []RR) {
81 u.Ns = make([]RR, 0, len(rr))
83 for _, r := range rr {
85 u.Ns = append(u.Ns, &ANY{Hdr: RR_Header{Name: h.Name, Ttl: 0, Rrtype: h.Rrtype, Class: ClassANY}})
89 // RemoveName creates a dynamic update packet that deletes all RRsets of a name, see RFC 2136 section 2.5.3
90 func (u *Msg) RemoveName(rr []RR) {
92 u.Ns = make([]RR, 0, len(rr))
94 for _, r := range rr {
95 u.Ns = append(u.Ns, &ANY{Hdr: RR_Header{Name: r.Header().Name, Ttl: 0, Rrtype: TypeANY, Class: ClassANY}})
99 // Remove creates a dynamic update packet deletes RR from a RRSset, see RFC 2136 section 2.5.4
100 func (u *Msg) Remove(rr []RR) {
102 u.Ns = make([]RR, 0, len(rr))
104 for _, r := range rr {
108 u.Ns = append(u.Ns, r)