| Ticket UUID: | 1680877 | |||
| Title: | procedures to get/set ber encoded data independ of tag | |||
| Type: | RFE | Version: | None | |
| Submitter: | mpc_janssen | Created on: | 2007-03-14 18:09:25 | |
| Subsystem: | asn | Assigned To: | mic42 | |
| Priority: | 5 Medium | Severity: | ||
| Status: | Open | Last Modified: | 2007-03-15 01:19:13 | |
| Resolution: | Closed By: | |||
| Closed on: | ||||
| Description: |
On occasions it is very useful to either extract a TLV structure or create a TLV structure independend of the tag (not in the least in the asn lib itself).
This is also very useful in handeling sequences of implicit types.
I therefore would find it useful if two procedures are added:
proc ::asn::asnGetTLV { data_var tlv_var } {
# gets a tag/length/value structure from the start of the data.
# return false if data exhausted, true if data left
upvar $data_var data $tlv_var tlv
asnGetByte data tag
asnGetLength data length
asnGetBytes data $length temp
set tlv [asnTLV $tag $temp]
if {[string length $data] > 0} {
return true
} {
return false
}
}
proc ::asn::asnTLV {tag value} {
set len [string length $value]
return [binary format H2a*a$len [format %02X $tag] [asnLength $len] $value]
}
| |||
| User Comments: |
mpc_janssen added on 2007-03-15 01:14:46:
Logged In: YES
user_id=1463011
Originator: YES
Actually using it in http://wiki.tcl.tk/16631 suggest that for the asnTLV proc the following semantics are more useful:
proc asnGetTLV { data_var tlv_var } {
# gets a tag/length/value from the start of the data.
# return false if no data available, true if succesful
upvar $data_var data $tlv_var tlv
dputs "Getting the first element from: [util::string2hex $data]"
if {[string length $data] < 2} {
return false
}
asnGetByte data tag
asnGetLength data length
asnGetBytes data $length temp
set tlv [asnTLV $tag $temp]
return true
}
| |||
Home
Blog
Docs
Downloads
Tickets
Timeline
Branches
Tags
Wiki