From b0fc5a2f22177bb021d95bd64adaf30cef77269e Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Mon, 20 Aug 2012 18:03:15 +0200 Subject: [PATCH] re-export these - I use them in unbound --- dnssec.go | 8 ++++---- msg.go | 12 ++++++------ nsecx.go | 2 +- tsig.go | 10 +++++----- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/dnssec.go b/dnssec.go index 7ae66752..c5f11a82 100644 --- a/dnssec.go +++ b/dnssec.go @@ -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 } diff --git a/msg.go b/msg.go index 55b89043..bd0f69d9 100644 --- a/msg.go +++ b/msg.go @@ -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) diff --git a/nsecx.go b/nsecx.go index 314fdc7e..d5727958 100644 --- a/nsecx.go +++ b/nsecx.go @@ -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 "" } diff --git a/tsig.go b/tsig.go index 74e7a080..8d11e6e0 100644 --- a/tsig.go +++ b/tsig.go @@ -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)