From f16ad2a7afdc88946d850b70897e5f698c881521 Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Thu, 23 Dec 2010 14:27:04 +0100 Subject: [PATCH] Add some helper function for ENDS cleanups - starts to work. Still FORMERR on EDNS0 request, but we are getting there --- edns.go | 24 ++++++++++++++++++++---- edns0-parsing | 33 --------------------------------- 2 files changed, 20 insertions(+), 37 deletions(-) delete mode 100644 edns0-parsing diff --git a/edns.go b/edns.go index 72fcde45..2c51d3cf 100644 --- a/edns.go +++ b/edns.go @@ -16,15 +16,16 @@ type Option struct { // EDNS extended RR. // Not used yet -type EDNS0_Header struct { - Name string "extended-name" +/* +This is the EDNS0 Header + Name string "domain-name" Opt uint16 // was type, but is always TypeOPT 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 -} +*/ type RR_OPT struct { Hdr RR_Header // this must become a EDNS0_Header @@ -36,7 +37,7 @@ func (rr *RR_OPT) Header() *RR_Header { } func (rr *RR_OPT) String() string { - s := rr.Hdr.String() + s := rr.Hdr.String() // Hier misschien andere representatie for _, o := range rr.Option { switch o.Code { case OptionCodeNSID: @@ -45,3 +46,18 @@ func (rr *RR_OPT) String() string { } return s } + +// 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 "" +} diff --git a/edns0-parsing b/edns0-parsing deleted file mode 100644 index d7c3ac6b..00000000 --- a/edns0-parsing +++ /dev/null @@ -1,33 +0,0 @@ - // check with what kind of RR header we are dealing with - // I'm sitting on the start byte of the name, with off? - // ifso I can check the. From RFC 1035 4.1.4 - // The first two bits are ones. This allows a pointer to be distinguished - // from a label, since the label must begin with two zero bits because - // labels are restricted to 63 octets or less. (The 10 and 01 combinations - // are reserved for future use.) - // EDNS takes 01 - c := int(msg[off]) - switch c & 0xC0 { - case 0x00,0xC0: - // normal name - // pack twice, once to find end of header - // and again to find end of packet. - // a bit inefficient but this doesn't need to be fast. - // off1 is end of header - // off2 is end of rr - off1, ok = packStruct(rr.Header(), msg, off) - off2, ok = packStruct(rr, msg, off) - if !ok { - return len(msg), false - } - // pack a third time; redo header with correct data length - rr.Header().Rdlength = uint16(off2 - off1) - packStruct(rr.Header(), msg, off) - return off2, true - case 0x40: - // EDNS0 header - return 0,true - } - return 0, true // BUG in Go -} -