6 year68 = 1 << 31 // For RFC1982 (Serial Arithmetic) calculations in 32 bits.
7 // DefaultMsgSize is the standard default for messages larger than 512 bytes.
9 // MinMsgSize is the minimal size of a DNS packet.
11 // MaxMsgSize is the largest possible DNS packet.
13 defaultTtl = 3600 // Default internal TTL.
16 // Error represents a DNS error
17 type Error struct{ err string }
19 func (e *Error) Error() string {
23 return "dns: " + e.err
26 // An RR represents a resource record.
28 // Header returns the header of an resource record. The header contains
29 // everything up to the rdata.
31 // String returns the text representation of the resource record.
33 // copy returns a copy of the RR
35 // len returns the length (in octets) of the uncompressed RR in wire format.
39 // RR_Header is the header all DNS resource records share.
40 type RR_Header struct {
41 Name string `dns:"cdomain-name"`
45 Rdlength uint16 // length of data after header
48 // Header returns itself. This is here to make RR_Header implement the RR interface.
49 func (h *RR_Header) Header() *RR_Header { return h }
51 // Just to imlement the RR interface.
52 func (h *RR_Header) copy() RR { return nil }
54 func (h *RR_Header) copyHeader() *RR_Header {
60 r.Rdlength = h.Rdlength
64 func (h *RR_Header) String() string {
67 if h.Rrtype == TypeOPT {
69 // and maybe other things
72 s += sprintName(h.Name) + "\t"
73 s += strconv.FormatInt(int64(h.Ttl), 10) + "\t"
74 s += Class(h.Class).String() + "\t"
75 s += Type(h.Rrtype).String() + "\t"
79 func (h *RR_Header) len() int {
81 l += 10 // rrtype(2) + class(2) + ttl(4) + rdlength(2)
85 // ToRFC3597 converts a known RR to the unknown RR representation
87 func (rr *RFC3597) ToRFC3597(r RR) error {
88 buf := make([]byte, r.len()*2)
89 off, err := PackStruct(r, buf, 0)
94 rawSetRdlength(buf, 0, off)
95 _, err = UnpackStruct(rr, buf, 0)