-
Notifications
You must be signed in to change notification settings - Fork 141
Closed
Description
Hey Keichi
I was wondering if it's somehow possible to use a variable from a parent scope from inside a choice type item. If it's not implemented I would greatly appreciate a pointer on how to do so.
My use-case is parsing of a DNSRecord:
var TXTRecord = new Parser()
.string('txt' { length: 'rdlength' }) // rdlength is undefined
var answer = new Parser()
.nest('name', { type: fqdn_pretty })
.uint16be('type')
.uint16be('class')
.uint32be('ttl')
.uint16be('rdlength')
.choice('record', {
tag: 'type',
choices: {
0x01: ARecord,
0x02: PTRRecord, 0x05: PTRRecord, 0x0c: PTRRecord,
0x10: TXTRecord,
0x21: SRVRecord,
0x1C: AAAARecord
},
defaultChoice: new Parser().buffer('rdata', { length: 'rdlength' }) //rdlength is undefined
})
I enjoy working with your module, thanks for the help in advance!
Secretmapper
Metadata
Metadata
Assignees
Labels
No labels