re-export these - I use them in unbound

This commit is contained in:
Miek Gieben 2012-08-20 18:03:15 +02:00
parent 6ee385b083
commit b0fc5a2f22
4 changed files with 16 additions and 16 deletions

View File

@ -117,7 +117,7 @@ func (k *RR_DNSKEY) KeyTag() uint16 {
keywire.Algorithm = k.Algorithm
keywire.PublicKey = k.PublicKey
wire := make([]byte, DefaultMsgSize)
n, ok := packStruct(keywire, wire, 0)
n, ok := PackStruct(keywire, wire, 0)
if !ok {
return 0
}
@ -155,7 +155,7 @@ func (k *RR_DNSKEY) ToDS(h int) *RR_DS {
keywire.Algorithm = k.Algorithm
keywire.PublicKey = k.PublicKey
wire := make([]byte, DefaultMsgSize)
n, ok := packStruct(keywire, wire, 0)
n, ok := PackStruct(keywire, wire, 0)
if !ok {
return nil
}
@ -236,7 +236,7 @@ func (s *RR_RRSIG) Sign(k PrivateKey, rrset []RR) error {
// Create the desired binary blob
signdata := make([]byte, DefaultMsgSize)
n, ok := packStruct(sigwire, signdata, 0)
n, ok := PackStruct(sigwire, signdata, 0)
if !ok {
return ErrPack
}
@ -348,7 +348,7 @@ func (s *RR_RRSIG) Verify(k *RR_DNSKEY, rrset []RR) error {
sigwire.SignerName = strings.ToLower(s.SignerName)
// Create the desired binary blob
signeddata := make([]byte, DefaultMsgSize)
n, ok := packStruct(sigwire, signeddata, 0)
n, ok := PackStruct(sigwire, signeddata, 0)
if !ok {
return ErrPack
}

12
msg.go
View File

@ -650,7 +650,7 @@ func structValue(any interface{}) reflect.Value {
return reflect.ValueOf(any).Elem()
}
func packStruct(any interface{}, msg []byte, off int) (off1 int, ok bool) {
func PackStruct(any interface{}, msg []byte, off int) (off1 int, ok bool) {
off, ok = packStructValue(structValue(any), msg, off, nil, false)
return off, ok
}
@ -1011,7 +1011,7 @@ func unpackUint16(msg []byte, off int) (v uint16, off1 int) {
return
}
func unpackStruct(any interface{}, msg []byte, off int) (off1 int, ok bool) {
func UnpackStruct(any interface{}, msg []byte, off int) (off1 int, ok bool) {
off, ok = unpackStructValue(structValue(any), msg, off)
return off, ok
}
@ -1075,7 +1075,7 @@ func UnpackRR(msg []byte, off int) (rr RR, off1 int, ok bool) {
// unpack just the header, to find the rr type and length
var h RR_Header
off0 := off
if off, ok = unpackStruct(&h, msg, off); !ok {
if off, ok = UnpackStruct(&h, msg, off); !ok {
return nil, len(msg), false
}
end := off + int(h.Rdlength)
@ -1086,7 +1086,7 @@ func UnpackRR(msg []byte, off int) (rr RR, off1 int, ok bool) {
} else {
rr = mk()
}
off, ok = unpackStruct(rr, msg, off0)
off, ok = UnpackStruct(rr, msg, off0)
if off != end {
return &h, end, true
}
@ -1240,7 +1240,7 @@ func (dns *Msg) Unpack(msg []byte) bool {
var dh Header
off := 0
var ok bool
if off, ok = unpackStruct(&dh, msg, off); !ok {
if off, ok = UnpackStruct(&dh, msg, off); !ok {
return false
}
dns.Id = dh.Id
@ -1262,7 +1262,7 @@ func (dns *Msg) Unpack(msg []byte) bool {
dns.Extra = make([]RR, dh.Arcount)
for i := 0; i < len(dns.Question); i++ {
off, ok = unpackStruct(&dns.Question[i], msg, off)
off, ok = UnpackStruct(&dns.Question[i], msg, off)
}
for i := 0; i < len(dns.Answer); i++ {
dns.Answer[i], off, ok = UnpackRR(msg, off)

View File

@ -38,7 +38,7 @@ func HashName(label string, ha uint8, iter uint16, salt string) string {
saltwire := new(saltWireFmt)
saltwire.Salt = salt
wire := make([]byte, DefaultMsgSize)
n, ok := packStruct(saltwire, wire, 0)
n, ok := PackStruct(saltwire, wire, 0)
if !ok {
return ""
}

10
tsig.go
View File

@ -259,7 +259,7 @@ func tsigBuffer(msgbuf []byte, rr *RR_TSIG, requestMAC string, timersOnly bool)
m.MACSize = uint16(len(requestMAC) / 2)
m.MAC = requestMAC
buf = make([]byte, len(requestMAC)) // long enough
n, _ := packStruct(m, buf, 0)
n, _ := PackStruct(m, buf, 0)
buf = buf[:n]
}
@ -268,7 +268,7 @@ func tsigBuffer(msgbuf []byte, rr *RR_TSIG, requestMAC string, timersOnly bool)
tsig := new(timerWireFmt)
tsig.TimeSigned = rr.TimeSigned
tsig.Fudge = rr.Fudge
n, _ := packStruct(tsig, tsigvar, 0)
n, _ := PackStruct(tsig, tsigvar, 0)
tsigvar = tsigvar[:n]
} else {
tsig := new(tsigWireFmt)
@ -281,7 +281,7 @@ func tsigBuffer(msgbuf []byte, rr *RR_TSIG, requestMAC string, timersOnly bool)
tsig.Error = rr.Error
tsig.OtherLen = rr.OtherLen
tsig.OtherData = rr.OtherData
n, _ := packStruct(tsig, tsigvar, 0)
n, _ := PackStruct(tsig, tsigvar, 0)
tsigvar = tsigvar[:n]
}
@ -304,7 +304,7 @@ func stripTsig(msg []byte) ([]byte, *RR_TSIG, error) {
off := 0
tsigoff := 0
var ok bool
if off, ok = unpackStruct(&dh, msg, off); !ok {
if off, ok = UnpackStruct(&dh, msg, off); !ok {
return nil, nil, ErrUnpack
}
if dh.Arcount == 0 {
@ -322,7 +322,7 @@ func stripTsig(msg []byte) ([]byte, *RR_TSIG, error) {
dns.Extra = make([]RR, dh.Arcount)
for i := 0; i < len(dns.Question); i++ {
off, ok = unpackStruct(&dns.Question[i], msg, off)
off, ok = UnpackStruct(&dns.Question[i], msg, off)
}
for i := 0; i < len(dns.Answer); i++ {
dns.Answer[i], off, ok = UnpackRR(msg, off)