more Copy() functions

This commit is contained in:
Miek Gieben 2012-06-20 17:44:18 +02:00
parent 4177512abe
commit 01442e58af
4 changed files with 23 additions and 1 deletions

2
dns.go
View File

@ -105,6 +105,8 @@ type RR interface {
String() string
// Len returns the length (in octects) of the uncompressed RR in wire format.
Len() int
// Copy returns a copy of the RR
// Copy() RR
}
// Exchange is used in (asynchronous) communication with the resolver. If the

View File

@ -83,6 +83,10 @@ func (rr *RR_OPT) Len() int {
return l
}
func (rr *RR_OPT) Copy() *RR_OPT {
return &RR_OPT{*rr.Hdr.Copy(), rr.Option}
}
// Version returns the EDNS version used. Only zero is defined.
func (rr *RR_OPT) Version() uint8 {
return uint8(rr.Hdr.Ttl & 0x00FF00FFFF)

View File

@ -110,6 +110,10 @@ func (rr *RR_TSIG) Len() int {
4 + len(rr.MAC)/2 + 1 + 6 + len(rr.OtherData)/2 + 1
}
func (rr *RR_TSIG) Copy() *RR_TSIG {
return &RR_TSIG{*rr.Hdr.Copy(), rr.Algorithm, rr.TimeSigned, rr.Fudge, rr.MACSize, rr.MAC, rr.OrigId, rr.Error, rr.OtherLen, rr.OtherData}
}
// The following values must be put in wireformat, so that the MAC can be calculated.
// RFC 2845, section 3.4.2. TSIG Variables.
type tsigWireFmt struct {

View File

@ -679,6 +679,10 @@ func (rr *RR_DNAME) Len() int {
return rr.Hdr.Len() + l
}
func (rr *RR_DNAME) Copy() *RR_DNAME {
return &RR_DNAME{*rr.Hdr.Copy(), rr.Target}
}
type RR_A struct {
Hdr RR_Header
A net.IP `dns:"a"`
@ -696,6 +700,10 @@ func (rr *RR_A) Len() int {
return rr.Hdr.Len() + net.IPv4len
}
func (rr *RR_A) Copy() *RR_A {
return &RR_A{*rr.Hdr.Copy(), rr.A}
}
type RR_AAAA struct {
Hdr RR_Header
AAAA net.IP `dns:"aaaa"`
@ -713,6 +721,10 @@ func (rr *RR_AAAA) Len() int {
return rr.Hdr.Len() + net.IPv6len
}
func (rr *RR_AAAA) Copy() *RR_AAAA {
return &RR_AAAA{*rr.Hdr.Copy(), rr.AAAA}
}
type RR_LOC struct {
Hdr RR_Header
Version uint8
@ -778,7 +790,7 @@ func (rr *RR_LOC) Len() int {
}
func (rr *RR_LOC) Copy() *RR_LOC {
return &RR_LOC{*rr.Hdr.Copy(), rr.TypeCovered, rr.Algorithm, rr.Labels, rr.OrigTtl, rr.Expiration, rr.Inception, rr.KeyTag, rr.SignerName, rr.Signature}
return &RR_LOC{*rr.Hdr.Copy(), rr.Version, rr.Size, rr.HorizPre, rr.VertPre, rr.Latitude, rr.Longitude, rr.Altitude}
}
type RR_RRSIG struct {