2010-12-22 20:30:41 +11:00
|
|
|
package dns
|
|
|
|
|
2010-12-25 21:14:11 +11:00
|
|
|
// EDNS0 option codes
|
2010-12-22 20:30:41 +11:00
|
|
|
const (
|
2010-12-25 21:14:11 +11:00
|
|
|
OptionCodeLLQ = 1 // Not used
|
|
|
|
OptionCodeUL = 2 // Not used
|
|
|
|
OptionCodeNSID = 3 // NSID, RFC5001
|
2010-12-23 21:02:01 +11:00
|
|
|
// EDNS flag bits (put in Z section)
|
|
|
|
_DO = 1 << 15 // dnssec ok
|
2010-12-22 20:30:41 +11:00
|
|
|
)
|
|
|
|
|
2010-12-25 23:09:27 +11:00
|
|
|
// An ENDS0 option rdata element.
|
2010-12-22 22:26:50 +11:00
|
|
|
type Option struct {
|
2010-12-23 21:02:01 +11:00
|
|
|
Code uint16
|
|
|
|
Data string "hex"
|
2010-12-22 20:30:41 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
// EDNS extended RR.
|
2010-12-24 00:07:35 +11:00
|
|
|
// Not used yet
|
2010-12-24 00:27:04 +11:00
|
|
|
/*
|
|
|
|
This is the EDNS0 Header
|
|
|
|
Name string "domain-name"
|
2010-12-24 00:07:35 +11:00
|
|
|
Opt uint16 // was type, but is always TypeOPT
|
2010-12-23 21:02:01 +11:00
|
|
|
UDPSize uint16 // was class
|
|
|
|
ExtendedRcode uint8 // was TTL
|
|
|
|
Version uint8 // was TTL
|
|
|
|
Z uint16 // was TTL (all flags should be put here)
|
|
|
|
Rdlength uint16 // length of data after the header
|
2010-12-24 00:27:04 +11:00
|
|
|
*/
|
2010-12-22 20:30:41 +11:00
|
|
|
|
2010-12-23 06:53:18 +11:00
|
|
|
type RR_OPT struct {
|
2010-12-23 21:02:01 +11:00
|
|
|
Hdr RR_Header // this must become a EDNS0_Header
|
|
|
|
Option []Option "OPT" // Tag is used in pack and unpack
|
2010-12-22 20:30:41 +11:00
|
|
|
}
|
|
|
|
|
2010-12-23 06:53:18 +11:00
|
|
|
func (rr *RR_OPT) Header() *RR_Header {
|
2010-12-23 21:02:01 +11:00
|
|
|
return &rr.Hdr
|
2010-12-22 20:30:41 +11:00
|
|
|
}
|
|
|
|
|
2010-12-23 06:53:18 +11:00
|
|
|
func (rr *RR_OPT) String() string {
|
2010-12-24 00:27:04 +11:00
|
|
|
s := rr.Hdr.String() // Hier misschien andere representatie
|
2010-12-23 21:02:01 +11:00
|
|
|
for _, o := range rr.Option {
|
|
|
|
switch o.Code {
|
|
|
|
case OptionCodeNSID:
|
|
|
|
s += "NSID: " + o.Data
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return s
|
2010-12-22 20:30:41 +11:00
|
|
|
}
|
2010-12-24 00:27:04 +11:00
|
|
|
|
|
|
|
// when set is true, set the size otherwise get it
|
|
|
|
func (rr *RR_OPT) UDPSize(size int, set bool) int {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
// when set is true, set the Do bit, otherwise get it
|
|
|
|
func (rr *RR_OPT) DoBit(do, set bool) bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
// when set is true, set the nsid, otherwise get it
|
|
|
|
func (rr *RR_OPT) Nsid(nsid string, set bool) string {
|
|
|
|
return ""
|
|
|
|
}
|