dns/edns.go

50 lines
1.3 KiB
Go
Raw Normal View History

package dns
// Implementation of EDNS0, RFC 2671
const (
OptionCodeLLQ = 1
OptionCodeUL = 2
OptionCodeNSID = 3
// EDNS flag bits (put in Z section)
_DO = 1 << 15 // dnssec ok
)
2010-12-22 22:26:50 +11:00
type Option struct {
Code uint16
Data string "hex"
}
// EDNS extended RR.
2010-12-23 09:05:21 +11:00
// If we are dealing with this, we might copy
// the RR_Header over to this type and allow for
// easy access
type EDNS0_Header struct {
Name string "extended-name"
Opt uint16 // was type
UDPSize uint16 // was class
ExtendedRcode uint8 // was TTL
Version uint8 // was TTL
2010-12-23 09:05:21 +11:00
Z uint16 // was TTL (all flags should be put here)
Rdlength uint16 // length of data after the header
}
type RR_OPT struct {
Hdr RR_Header // this must become a EDNS0_Header
Option []Option "OPT" // Tag is used in pack and unpack
}
func (rr *RR_OPT) Header() *RR_Header {
return &rr.Hdr
}
func (rr *RR_OPT) String() string {
s := rr.Hdr.String()
for _, o := range rr.Option {
switch o.Code {
case OptionCodeNSID:
s += "NSID: " + o.Data
}
}
return s
}