| 1 |
asnwish - An ASN.1 Tcl/Tk interpreter based on snacc table files |
| 2 |
|
| 3 |
The only extension to standard Tcl/Tk is a command called |
| 4 |
|
| 5 |
"asn", |
| 6 |
which reads a binary ASN.1 grammar file (as generated |
| 7 |
by "snacc -T") into an internal data structure |
| 8 |
and returns a new command "asn<n>". |
| 9 |
|
| 10 |
"asn<n>" offers the following possibilities: |
| 11 |
|
| 12 |
"asn<n> modules" |
| 13 |
Returns a list of all modules of the grammar. |
| 14 |
|
| 15 |
"asn<n> types ?module?" |
| 16 |
Returns a list of all type definitions of the |
| 17 |
grammar respectively of the module given. |
| 18 |
Each type definition is returned as a list |
| 19 |
consisting of the module name and the type name. |
| 20 |
|
| 21 |
"asn<n> type ?-followref? {?module? typedef ?subtype? ...} |
| 22 |
Returns a description of the given type. |
| 23 |
The description format is |
| 24 |
"<typeid> <type> <range> <namedvalues> ?<subtypelist>?". |
| 25 |
|
| 26 |
In case of a type definition, "<typeid>" is a three- |
| 27 |
element list "{<module> <typename> "pdu"|"sub"}". |
| 28 |
In case of a subtype, <typeid> is the fieldname, |
| 29 |
if any, or an empty list "{}". |
| 30 |
|
| 31 |
"<type>" is one out of "BOOLEAN", "INTEGER", "BIT STRING", |
| 32 |
"OCTET STRING", "NULL", "OBJECT IDENTIFIER", "REAL", |
| 33 |
"ENUMERATED", "SEQUENCE", "SET", "SEQUENCE OF", "SET OF", |
| 34 |
"CHOICE" or "TYPEREF". |
| 35 |
|
| 36 |
"<range>" is either empty, or a single numeric value, |
| 37 |
or a list of two numeric vaules. It can be available |
| 38 |
for types "SEQUENCE OF" (giving the lower and, optionally, |
| 39 |
the upper bounds of the index), "INTEGER" (giving the lowest |
| 40 |
and the highest possible value) and "OCTET STRING" (giving |
| 41 |
the minimum and, optionally, the maximum length). |
| 42 |
|
| 43 |
"<namedvalues>" is either empty, or a list of two-element |
| 44 |
lists, each consisting of an integer value and a name. |
| 45 |
It can be available for types "BIT STRING" and "ENUMERATED". |
| 46 |
|
| 47 |
"?<subtypelist>?" is available for types "TYPEREF" (where it |
| 48 |
is a two-element list "{<module> <typename>}" and "SEQUENCE", |
| 49 |
"SET", "SEQUENCE OF", "SET OF", "CHOICE" (where it is a list |
| 50 |
of subtype descriptions, each of the format given here). |
| 51 |
|
| 52 |
"asn<n> decode channel {?module? typedef ?subtype? ...} valcmd ?typecmd?" |
| 53 |
Reads from the channel the given type, BER encoded, and decodes it. |
| 54 |
During decoding, whenever a compound type is entered or left, |
| 55 |
the Tcl/Tk "typecmd" (if any) is executed, with the type path |
| 56 |
as first parameter, and a "1" resp. "-1" as second, and |
| 57 |
whenever a value is decoded, the Tcl/Tk "valcmd" is executed, |
| 58 |
with the type path as the first and the value as the second |
| 59 |
parameter. BOOLEAN values are represented as "TRUE" resp. |
| 60 |
"FALSE". INTEGER and ENUMERATED values are represented by |
| 61 |
their decimal representation. BIT STRINGs are represented by |
| 62 |
a string of "0" and "1" characters. OCTET STRINGs and OIDs |
| 63 |
are represented as following: printable characters (except the |
| 64 |
character "\") are copied unchanged; non-printable characters |
| 65 |
and the character "\" are represented by \OOO (e.g., their ASCII |
| 66 |
value encoded by three octal digits with leading 0). The NULL |
| 67 |
type is encoded as "NULL". REAL numbers representation follows |
| 68 |
sprintf %G. |
| 69 |
|
| 70 |
Returns the number of bytes decoded. |
| 71 |
|
| 72 |
"asn<n> encode channel {?module? typedef ?subtype? ...} valcmd ?typecmd?" |
| 73 |
|
| 74 |
"asn<n> close" |
| 75 |
Closes the grammar and deletes the internal data structure. |