mirror of
https://github.com/miekg/dns.git
synced 2025-12-10 22:31:20 +01:00
Half the parsing of the EDNS LLQ package
This commit is contained in:
parent
71e3d1dfcb
commit
ec9ac92fad
31
edns.go
31
edns.go
@ -345,7 +345,12 @@ func (e *EDNS0_UL) String() string {
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
type EDNS0_LLQ struct {
|
type EDNS0_LLQ struct {
|
||||||
Code uint16 // Always EDNS0LLQ
|
Code uint16 // Always EDNS0LLQ
|
||||||
|
Version uint16
|
||||||
|
Opcode uint16
|
||||||
|
Error uint16
|
||||||
|
Id uint64
|
||||||
|
LeaseLife uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *EDNS0_LLQ) Option() uint16 {
|
func (e *EDNS0_LLQ) Option() uint16 {
|
||||||
@ -353,16 +358,32 @@ func (e *EDNS0_LLQ) Option() uint16 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e *EDNS0_LLQ) pack() ([]byte, error) {
|
func (e *EDNS0_LLQ) pack() ([]byte, error) {
|
||||||
|
b := make([]byte, 16)
|
||||||
|
b[0], b[1] = packUint16(e.Version)
|
||||||
|
b[2], b[3] = packUint16(e.Opcode)
|
||||||
|
b[2], b[3] = packUint16(e.Error)
|
||||||
|
b[4] = byte(e.Id >> 56)
|
||||||
|
b[5] = byte(e.Id >> 48)
|
||||||
|
b[6] = byte(e.Id >> 40)
|
||||||
|
b[7] = byte(e.Id >> 32)
|
||||||
|
b[8] = byte(e.Id >> 24)
|
||||||
|
b[9] = byte(e.Id >> 16)
|
||||||
|
b[10] = byte(e.Id >> 8)
|
||||||
|
b[11] = byte(e.Id)
|
||||||
|
b[12] = byte(e.LeaseLife >> 24)
|
||||||
|
b[13] = byte(e.LeaseLife >> 16)
|
||||||
|
b[14] = byte(e.LeaseLife >> 8)
|
||||||
|
b[15] = byte(e.LeaseLife)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *EDNS0_LLQ) unpack(b []byte) {
|
func (e *EDNS0_LLQ) unpack(b []byte) {
|
||||||
|
e.Version, _ = unpackUint16(b, 0)
|
||||||
|
e.Opcode, _ = unpackUint16(b, 2)
|
||||||
|
e.Error, _ = unpackUint16(b, 4)
|
||||||
|
// ... the rest
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *EDNS0_LLQ) String() string {
|
func (e *EDNS0_LLQ) String() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
5
msg.go
5
msg.go
@ -755,6 +755,11 @@ func unpackStructValue(val reflect.Value, msg []byte, off int) (off1 int, err er
|
|||||||
e.unpack(msg[off1 : off1+int(optlen)])
|
e.unpack(msg[off1 : off1+int(optlen)])
|
||||||
edns = append(edns, e)
|
edns = append(edns, e)
|
||||||
off = off1 + int(optlen)
|
off = off1 + int(optlen)
|
||||||
|
case EDNS0LLQ:
|
||||||
|
e := new(EDNS0_LLQ)
|
||||||
|
e.unpack(msg[off1 : off1+int(optlen)])
|
||||||
|
edns = append(edns, e)
|
||||||
|
off = off1 + int(optlen)
|
||||||
default:
|
default:
|
||||||
// do nothing?
|
// do nothing?
|
||||||
off = off1 + int(optlen)
|
off = off1 + int(optlen)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user