1 (RCS control information is at the end of this file.)
7 This example shows how the snacc compiler handles the ANY DEFINED BY
8 type in C. ANY types (not ANY DEFINED BY) require the modifications
9 to the generated code. Type "make" to build this example.
11 This directory should have the following files in it:
18 There are 3 programs generated by the makefile:
20 genber - builds a BER value of the AnyTestType and writes it
21 to a file called "att.ber"
23 def - takes file name of an AnyTestType value. Decodes the
24 file and re-encodes it to stdout. Uses definite
25 lengths for constructed values.
27 indef - takes file name of an AnyTestType value. Decodes the
28 file and re-encodes it to stdout. Uses indefinite
29 lengths for constructed values.
32 These files use the code generated by snacc from the
33 snacc/asn1specs/any.asn1 file. (see the makefile)
35 Look at genber.c to see how values can be built and printed.
37 Look at the generated code in any_test.c and any_test.h to see how the
38 any hash table is built.
41 try the following commands in your c-shell:
43 %1 genber # generate the att.ber file
44 %2 indef att.ber > tmp.ber # decode att.ber an re-encode into tmp.ber
45 %3 def tmp.ber > tmp2.ber # decode tmp.ber an re-encode into tmp2.ber
46 %4 diff att.ber tmp2.ber # compare .ber files (should be the same)
48 When you are finished with the example type "make clean" to remove
49 the binaries and generated code.
56 Snacc ASN.1 comment commands
58 In the snacc/asn1specs/any.asn1 file, the AnyTestType has a special
59 "--snacc" ASN.1 comment after ::= to give snacc some extra information
60 about the AnyTestType.
62 AnyTestType ::= --snacc isPdu:"TRUE" -- SEQUENCE { ... etc. ... }
64 The "isPdu" flag tells snacc that the AnyTestType is a PDU type that
65 you will be calling the encoding and decoding routines directly
66 from your code. This causes snacc to generate the "BEncAnyTestType"
67 and "BDecAnyTestType" routines in addition to the standard
68 "BEncAnyTestTypeContent" and "BDecAnyTestTypeContent".
70 The Content encoding and decoding routines only deal with the content
71 of the type, ignoring all of the tag and length pairs on the given
72 type (in this case the UNIVERSAL (CONSTRUCTED) 16 tag and the length
73 for the SEQUENCE). The "BEncAnyTestType" and "BDecAnyTestType"
74 routines do encode the SEQUENCE tag and its length. This design is
75 motivated by IMPLICIT tagging.
77 The compiler generated routines generally only call the content
78 oriented routines except in the case of ANY and ANY DEFINED BY types.
79 For ANY and ANY DEFINED BY types the PDU form of the rouine is called
80 since the tags are not known by the containing type.
83 SNMP OBJECT-TYPE Macro
85 The SNMP OBJECT-TYPE macro is used to define the id to type mapping
86 for ANY DEFINED BY types. The macro has been modified to accept both
87 INTEGERs and OBJECT IDENTIFIERs as values (see
88 snacc/asn1specs/any.asn1). This macro can be used with other
89 protocols to define the id to type mapping.
91 Two hash tables are used to hold the id to type mappings. One for
92 INTEGER to type mappings and the other for OBJECT IDENTIFIER to type
93 mappings. You must explicitly initialize the hash tables by calling
94 generated init routines once at the beginning of your program. Each
95 module that has OBJECT-TYPE macros in it will generate an
96 "InitAny<module name>" routine. You must call every init routine to
97 add all the mappings to the hash table(s).
99 #-------------------------------------------------------------------------------
100 # $Header: /cvs/Darwin/src/live/Security/SecuritySNACCRuntime/c-examples/any/README,v 1.1.1.1 2001/05/18 23:14:07 mb Exp $
102 # Revision 1.1.1.1 2001/05/18 23:14:07 mb
103 # Move from private repository to open source repository
105 # Revision 1.1.1.1 1999/03/16 18:06:08 aram
106 # Originals from SMIME Free Library.
108 # Revision 1.2 1997/02/16 20:26:14 rj
109 # check-in of a few cosmetic changes
111 # Revision 1.1 1994/08/31 08:46:17 rj
112 # first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog.