Updated NSAP support according to RFC1706
New text format 0x and no more length in the object itself.
This commit is contained in:
parent
d2bed60478
commit
2e9176243e
|
@ -907,8 +907,9 @@ func TestILNP(t *testing.T) {
|
|||
|
||||
func TestNsapGposEidNimloc(t *testing.T) {
|
||||
dt := map[string]string{
|
||||
"foo.bar.com. IN NSAP 21 47000580ffff000000321099991111222233334444": "foo.bar.com.\t3600\tIN\tNSAP\t21 47000580ffff000000321099991111222233334444",
|
||||
"host.school.de IN NSAP 17 39276f3100111100002222333344449876": "host.school.de.\t3600\tIN\tNSAP\t17 39276f3100111100002222333344449876",
|
||||
"foo.bar.com. IN NSAP 21 47000580ffff000000321099991111222233334444": "foo.bar.com.\t3600\tIN\tNSAP\t0x47000580ffff000000321099991111222233334444",
|
||||
"foo.bar.com. IN NSAP 0x47000580ffff000000321099991111222233334444": "foo.bar.com.\t3600\tIN\tNSAP\t0x47000580ffff000000321099991111222233334444",
|
||||
"host.school.de IN NSAP 17 39276f3100111100002222333344449876": "host.school.de.\t3600\tIN\tNSAP\t0x39276f3100111100002222333344449876",
|
||||
"444433332222111199990123000000ff. NSAP-PTR foo.bar.com.": "444433332222111199990123000000ff.\t3600\tIN\tNSAP-PTR\tfoo.bar.com.",
|
||||
"lillee. IN GPOS -32.6882 116.8652 10.0": "lillee.\t3600\tIN\tGPOS\t-32.6882 116.8652 10.0",
|
||||
"hinault. IN GPOS -22.6882 116.8652 250.0": "hinault.\t3600\tIN\tGPOS\t-22.6882 116.8652 250.0",
|
||||
|
|
9
types.go
9
types.go
|
@ -1146,14 +1146,13 @@ func (rr *RKEY) String() string {
|
|||
}
|
||||
|
||||
type NSAP struct {
|
||||
Hdr RR_Header
|
||||
Length uint8
|
||||
Nsap string
|
||||
Hdr RR_Header
|
||||
Nsap string
|
||||
}
|
||||
|
||||
func (rr *NSAP) Header() *RR_Header { return &rr.Hdr }
|
||||
func (rr *NSAP) copy() RR { return &NSAP{*rr.Hdr.copyHeader(), rr.Length, rr.Nsap} }
|
||||
func (rr *NSAP) String() string { return rr.Hdr.String() + strconv.Itoa(int(rr.Length)) + " " + rr.Nsap }
|
||||
func (rr *NSAP) copy() RR { return &NSAP{*rr.Hdr.copyHeader(), rr.Nsap} }
|
||||
func (rr *NSAP) String() string { return rr.Hdr.String() + "0x" + rr.Nsap }
|
||||
func (rr *NSAP) len() int { return rr.Hdr.len() + 1 + len(rr.Nsap) + 1 }
|
||||
|
||||
type NSAPPTR struct {
|
||||
|
|
25
zscan_rr.go
25
zscan_rr.go
|
@ -1609,15 +1609,28 @@ func setNIMLOC(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) {
|
|||
func setNSAP(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) {
|
||||
rr := new(NSAP)
|
||||
rr.Hdr = h
|
||||
l := <-c
|
||||
if l.length == 0 {
|
||||
return rr, nil, l.comment
|
||||
}
|
||||
s, e1, c1 := endingToString(c, "bad NSAP Nsap", f)
|
||||
chunks, e1, c1 := endingToTxtSlice(c, "bad NSAP Nsap", f)
|
||||
if e1 != nil {
|
||||
return nil, e1, c1
|
||||
}
|
||||
rr.Nsap = s
|
||||
// data would come as one string or multiple... Just to ignore possible
|
||||
// variety let's merge things back together and split to actual "words"
|
||||
s := strings.Fields(strings.Join(chunks, " "))
|
||||
if len(s) == 0 {
|
||||
return rr, nil, c1
|
||||
}
|
||||
if len(s[0]) >= 2 && s[0][0:2] == "0x" || s[0][0:2] == "0X" {
|
||||
// although RFC only suggests 0x there is no clarification that X is not allowed
|
||||
rr.Nsap = strings.Join(s, "")[2:]
|
||||
} else {
|
||||
// since we do not know what to do with this data, and, we would not use original length
|
||||
// in formatting, it's moot to check correctness of the length
|
||||
_, err := strconv.Atoi(s[0])
|
||||
if err != nil {
|
||||
return nil, &ParseError{f, "bad NSAP Length", lex{token: s[0]}}, ""
|
||||
}
|
||||
rr.Nsap = strings.Join(s[1:], "")
|
||||
}
|
||||
return rr, nil, c1
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue