blob: 03bf7ca64fdb86c287597b65f86c9decb5c83bfe [file] [log] [blame]
vlme18adea2004-06-03 03:49:45 +00001#LyX 1.3 created this file. For more info see http://www.lyx.org/
2\lyxformat 221
3\textclass book
vlmfcec8e52004-08-23 15:12:04 +00004\begin_preamble
vlmfcec8e52004-08-23 15:12:04 +00005\usepackage{extramarks}
6\lhead{\firstxmark}
7\rfoot{\lastxmark}
vlmc3bfd812004-09-30 22:26:19 +00008\usepackage{color}
9\definecolor{gray40}{gray}{.4}
10\definecolor{urlblue}{rgb}{0,0,.6}
11\usepackage[colorlinks=true,
12linkcolor={gray40},
13urlcolor={urlblue},
14pdfauthor={Lev Walkin},
15pdftitle={Using the OpenSource ASN.1 Compiler},
16pdfkeywords={ASN.1,asn1c,compiler}
17]{hyperref}
18%\fancyhf{}
19%\fancyhead[LE,RO]{\thepage}
20%\fancyhead[LO]{\rightmark}
21%\fancyhead[RE]{\leftmark}
22%\fancyfoot[R]{\lastxmark}
vlmfcec8e52004-08-23 15:12:04 +000023\end_preamble
vlme18adea2004-06-03 03:49:45 +000024\language english
25\inputencoding latin1
vlmfcec8e52004-08-23 15:12:04 +000026\fontscheme times
vlme18adea2004-06-03 03:49:45 +000027\graphics default
28\paperfontsize default
29\spacing single
30\papersize Default
31\paperpackage a4
32\use_geometry 0
33\use_amsmath 0
34\use_natbib 0
35\use_numerical_citations 0
36\paperorientation portrait
vlmc3bfd812004-09-30 22:26:19 +000037\secnumdepth 2
38\tocdepth 2
vlme18adea2004-06-03 03:49:45 +000039\paragraph_separation indent
40\defskip medskip
41\quotes_language swedish
42\quotes_times 2
43\papercolumns 1
vlmfcec8e52004-08-23 15:12:04 +000044\papersides 2
45\paperpagestyle fancy
vlme18adea2004-06-03 03:49:45 +000046
47\layout Title
48
vlmc3bfd812004-09-30 22:26:19 +000049Using the OpenSource ASN.1 Compiler
vlme18adea2004-06-03 03:49:45 +000050\layout Author
51
52Lev Walkin <
vlmc3bfd812004-09-30 22:26:19 +000053\begin_inset ERT
54status Collapsed
vlme18adea2004-06-03 03:49:45 +000055
vlmc3bfd812004-09-30 22:26:19 +000056\layout Standard
57
58\backslash
59href{mailto:vlm@lionet.info?Subject=asn1c}{vlm@lionet.info}
vlme18adea2004-06-03 03:49:45 +000060\end_inset
61
62>
63\layout Standard
64
65
vlmfcec8e52004-08-23 15:12:04 +000066\begin_inset ERT
67status Open
68
69\layout Standard
70
71\backslash
vlmc3bfd812004-09-30 22:26:19 +000072lhead{Document describes
73\backslash
vlm60e7ef02004-10-13 09:13:56 +000074href{http://lionet.info/asn1c}{asn1c-0.9.8}}
vlmc3bfd812004-09-30 22:26:19 +000075\layout Standard
76
77\backslash
78rhead{$Revision$}
vlmfcec8e52004-08-23 15:12:04 +000079\end_inset
80
81
82\layout Standard
83
84
vlme18adea2004-06-03 03:49:45 +000085\begin_inset LatexCommand \tableofcontents{}
86
87\end_inset
88
89
vlmfcec8e52004-08-23 15:12:04 +000090\layout Standard
91
92
93\begin_inset ERT
vlmc3bfd812004-09-30 22:26:19 +000094status Open
vlmfcec8e52004-08-23 15:12:04 +000095
96\layout Standard
97
98\backslash
99pagestyle{headings}
100\end_inset
101
102
vlmcaba97b2004-08-07 05:00:07 +0000103\layout Part
104
105ASN.1 Basics
vlme18adea2004-06-03 03:49:45 +0000106\layout Chapter
107
vlmcaba97b2004-08-07 05:00:07 +0000108Abstract Syntax Notation: ASN.1
vlme18adea2004-06-03 03:49:45 +0000109\layout Standard
110
111
112\emph on
113This chapter defines some basic ASN.1 concepts and describes several most
114 widely used types.
115 It is by no means an authoritative or complete reference.
116 For more complete ASN.1 description, please refer to Olivier Dubuisson's
117 book
118\begin_inset LatexCommand \cite{Dub00}
119
120\end_inset
121
vlmcaba97b2004-08-07 05:00:07 +0000122 or the ASN.1 body of standards itself
vlme18adea2004-06-03 03:49:45 +0000123\begin_inset LatexCommand \cite{ITU-T/ASN.1}
124
125\end_inset
126
127.
128\layout Standard
129
130The Abstract Syntax Notation One is used to formally describe the semantics
131 of data transmitted across the network.
132 Two communicating parties may have different formats of their native data
133 types (i.e.
134 number of bits in the integer type), thus it is important to have a way
135 to describe the data in a manner which is independent from the particular
136 machine's representation.
vlm4cb0edf2005-01-14 11:38:49 +0000137 The ASN.1 specifications are used to achieve the following:
vlme18adea2004-06-03 03:49:45 +0000138\layout Itemize
139
140The specification expressed in the ASN.1 notation is a formal and precise
141 way to communicate the data semantics to human readers;
142\layout Itemize
143
144The ASN.1 specifications may be used as input for automatic compilers which
145 produce the code for some target language (C, C++, Java, etc) to encode
146 and decode the data according to some encoding rules (which are also defined
147 by the ASN.1 standard).
148\layout Standard
149
150Consider the following example:
151\layout LyX-Code
152
153Rectangle ::= SEQUENCE {
154\layout LyX-Code
155
156 height INTEGER,
157\layout LyX-Code
158
159 width INTEGER
160\layout LyX-Code
161
162}
163\layout Standard
164
165This ASN.1 specification describes a constructed type,
166\emph on
167Rectangle
168\emph default
169, containing two integer fields.
vlm4cb0edf2005-01-14 11:38:49 +0000170 This specification may tell the reader that there exists this kind of data
vlme18adea2004-06-03 03:49:45 +0000171 structure and that some entity may be prepared to send or receive it.
172 The question on
173\emph on
174how
175\emph default
176 that entity is going to send or receive the
177\emph on
178encoded data
179\emph default
180 is outside the scope of ASN.1.
181 For example, this data structure may be encoded according to some encoding
182 rules and sent to the destination using the TCP protocol.
183 The ASN.1 specifies several ways of encoding (or
184\begin_inset Quotes sld
185\end_inset
186
187serializing
188\begin_inset Quotes srd
189\end_inset
190
191, or
192\begin_inset Quotes sld
193\end_inset
194
195marshaling
196\begin_inset Quotes srd
197\end_inset
198
vlm4cb0edf2005-01-14 11:38:49 +0000199) the data: BER, CER, DER and XER, some of them which will be outlined later.
vlme18adea2004-06-03 03:49:45 +0000200\layout Standard
201
202The complete specification must be wrapped in a module, which looks like
203 this:
204\layout LyX-Code
205
vlm4cb0edf2005-01-14 11:38:49 +0000206RectangleModule1
vlme18adea2004-06-03 03:49:45 +0000207\layout LyX-Code
208
209 { iso org(3) dod(6) internet(1) private(4)
210\layout LyX-Code
211
212 enterprise(1) spelio(9363) software(1)
213\layout LyX-Code
214
vlm4cb0edf2005-01-14 11:38:49 +0000215 asn1c(5) docs(2) rectangle(1) 1 }
vlme18adea2004-06-03 03:49:45 +0000216\layout LyX-Code
217
vlmfcec8e52004-08-23 15:12:04 +0000218 DEFINITIONS AUTOMATIC TAGS ::=
vlme18adea2004-06-03 03:49:45 +0000219\layout LyX-Code
220
221BEGIN
222\layout LyX-Code
223
224
225\layout LyX-Code
226
227-- This is a comment which describes nothing.
228\layout LyX-Code
229
230Rectangle ::= SEQUENCE {
231\layout LyX-Code
232
233 height INTEGER, -- Height of the rectangle
234\layout LyX-Code
235
vlmfcec8e52004-08-23 15:12:04 +0000236 width INTEGER -- Width of the rectangle
vlme18adea2004-06-03 03:49:45 +0000237\layout LyX-Code
238
239}
240\layout LyX-Code
241
242
243\layout LyX-Code
244
245END
246\layout Standard
247
vlm4cb0edf2005-01-14 11:38:49 +0000248The module header consists of module name (RectangleModule1), the module
vlmfcec8e52004-08-23 15:12:04 +0000249 object identifier ({...}), a keyword
vlme18adea2004-06-03 03:49:45 +0000250\begin_inset Quotes sld
251\end_inset
252
vlmfcec8e52004-08-23 15:12:04 +0000253DEFINITIONS
254\begin_inset Quotes srd
255\end_inset
256
257, a set of module flags (AUTOMATIC TAGS) and
258\begin_inset Quotes sld
259\end_inset
260
261::= BEGIN
vlme18adea2004-06-03 03:49:45 +0000262\begin_inset Quotes srd
263\end_inset
264
265.
266 The module ends with an
267\begin_inset Quotes sld
268\end_inset
269
270END
271\begin_inset Quotes srd
272\end_inset
273
274 statement.
275\layout Section
276
277Some of the ASN.1 Basic Types
278\layout Subsection
279
280The BOOLEAN type
281\layout Standard
282
283The BOOLEAN type models the simple binary TRUE/FALSE, YES/NO, ON/OFF or
284 a similar kind of two-way choice.
285\layout Subsection
286
287The INTEGER type
288\layout Standard
289
290The INTEGER type is a signed natural number type without any restrictions
291 on its size.
292 If the automatic checking on INTEGER value bounds are necessary, the subtype
293 constraints must be used.
294\layout LyX-Code
295
296SimpleInteger ::= INTEGER
297\layout LyX-Code
298
vlmfcec8e52004-08-23 15:12:04 +0000299
300\layout LyX-Code
301
vlme18adea2004-06-03 03:49:45 +0000302-- An integer with a very limited range
303\layout LyX-Code
304
vlmba56d852004-09-29 13:29:17 +0000305SmallPositiveInt ::= INTEGER (0..127)
vlme18adea2004-06-03 03:49:45 +0000306\layout LyX-Code
307
vlmfcec8e52004-08-23 15:12:04 +0000308
309\layout LyX-Code
310
vlme18adea2004-06-03 03:49:45 +0000311-- Integer, negative
312\layout LyX-Code
313
314NegativeInt ::= INTEGER (MIN..0)
315\layout Subsection
316
317The ENUMERATED type
318\layout Standard
319
320The ENUMERATED type is semantically equivalent to the INTEGER type with
321 some integer values explicitly named.
322\layout LyX-Code
323
324FruitId ::= ENUMERATED { apple(1), orange(2) }
325\layout LyX-Code
326
vlmfcec8e52004-08-23 15:12:04 +0000327
328\layout LyX-Code
329
vlme18adea2004-06-03 03:49:45 +0000330-- The numbers in braces are optional,
331\layout LyX-Code
332
vlmfcec8e52004-08-23 15:12:04 +0000333-- the enumeration can be performed
vlme18adea2004-06-03 03:49:45 +0000334\layout LyX-Code
335
336-- automatically by the compiler
337\layout LyX-Code
338
339ComputerOSType ::= ENUMERATED {
340\layout LyX-Code
341
vlmc3bfd812004-09-30 22:26:19 +0000342 FreeBSD, -- acquires value 0
vlme18adea2004-06-03 03:49:45 +0000343\layout LyX-Code
344
vlmc3bfd812004-09-30 22:26:19 +0000345 Windows, -- acquires value 1
vlme18adea2004-06-03 03:49:45 +0000346\layout LyX-Code
347
vlmc3bfd812004-09-30 22:26:19 +0000348 Solaris(5), -- remains 5
vlme18adea2004-06-03 03:49:45 +0000349\layout LyX-Code
350
vlmc3bfd812004-09-30 22:26:19 +0000351 Linux, -- becomes 6
vlme18adea2004-06-03 03:49:45 +0000352\layout LyX-Code
353
vlmc3bfd812004-09-30 22:26:19 +0000354 MacOS -- becomes 7
vlme18adea2004-06-03 03:49:45 +0000355\layout LyX-Code
356
357}
358\layout Subsection
359
360The OCTET STRING type
361\layout Standard
362
363This type models the sequence of 8-bit bytes.
364 This may be used to transmit some opaque data or data serialized by other
365 types of encoders (i.e.
366 video file, photo picture, etc).
367\layout Subsection
368
369The OBJECT IDENTIFIER type
370\layout Standard
371
372The OBJECT IDENTIFIER is used to represent the unique identifier of any
373 object, starting from the very root of the registration tree.
374 If your organization needs to uniquely identify something (a router, a
375 room, a person, a standard, or whatever), you are encouraged to get your
376 own identification subtree at
377\begin_inset LatexCommand \htmlurl{http://www.iana.org/protocols/forms.htm}
378
379\end_inset
380
381.
382\layout Standard
383
384For example, the very first ASN.1 module in this document has the following
385 OBJECT IDENTIFIER: 1 3 6 1 4 1 9363 1 5 2 1 1.
386\layout LyX-Code
387
388ExampleOID ::= OBJECT IDENTIFIER
389\layout LyX-Code
390
vlmfcec8e52004-08-23 15:12:04 +0000391
392\layout LyX-Code
393
vlm4cb0edf2005-01-14 11:38:49 +0000394rectangleModule1-oid ExampleOID
vlme18adea2004-06-03 03:49:45 +0000395\layout LyX-Code
396
397 ::= { 1 3 6 1 4 1 9363 1 5 2 1 1 }
398\layout LyX-Code
399
vlmfcec8e52004-08-23 15:12:04 +0000400
401\layout LyX-Code
402
vlme18adea2004-06-03 03:49:45 +0000403-- An identifier of the Internet.
404\layout LyX-Code
405
406internet-id OBJECT IDENTIFIER
407\layout LyX-Code
408
409 ::= { iso(1) identified-organization(3)
410\layout LyX-Code
411
412 dod(6) internet(1) }
413\layout Standard
414
415As you see, names are optional.
416\layout Subsection
417
418The RELATIVE-OID type
419\layout Standard
420
421The RELATIVE-OID type has the semantics of a subtree of an OBJECT IDENTIFIER.
422 There may be no need to repeat the whole sequence of numbers from the root
423 of the registration tree where the only thing of interest is some of the
424 tree's subsequence.
425\layout LyX-Code
426
427this-document RELATIVE-OID ::= { docs(2) usage(1) }
428\layout LyX-Code
429
vlmfcec8e52004-08-23 15:12:04 +0000430
431\layout LyX-Code
432
vlme18adea2004-06-03 03:49:45 +0000433this-example RELATIVE-OID ::= {
434\layout LyX-Code
435
436 this-document assorted-examples(0) this-example(1) }
437\layout Section
438
439Some of the ASN.1 String Types
440\layout Subsection
441
442The IA5String type
443\layout Standard
444
445This is essentially the ASCII, with 128 character codes available (7 lower
vlmfcec8e52004-08-23 15:12:04 +0000446 bits of an 8-bit byte).
vlme18adea2004-06-03 03:49:45 +0000447\layout Subsection
448
449The UTF8String type
450\layout Standard
451
452This is the character string which encodes the full Unicode range (4 bytes)
453 using multibyte character sequences.
454\layout Subsection
455
456The NumericString type
457\layout Standard
458
459This type represents the character string with the alphabet consisting of
460 numbers (
461\begin_inset Quotes sld
462\end_inset
463
4640
465\begin_inset Quotes srd
466\end_inset
467
468 to
469\begin_inset Quotes sld
470\end_inset
471
4729
473\begin_inset Quotes srd
474\end_inset
475
476) and a space.
477\layout Subsection
478
479The PrintableString type
480\layout Standard
481
482The character string with the following alphabet: space,
483\begin_inset Quotes sld
484\end_inset
485
486
487\series bold
488'
489\series default
490
491\begin_inset Quotes srd
492\end_inset
493
494 (single quote),
495\begin_inset Quotes sld
496\end_inset
497
498
499\series bold
500(
501\series default
502
503\begin_inset Quotes sld
504\end_inset
505
506,
507\begin_inset Quotes sld
508\end_inset
509
510
511\series bold
512)
513\series default
514
515\begin_inset Quotes srd
516\end_inset
517
518,
519\begin_inset Quotes sld
520\end_inset
521
522
523\series bold
524+
525\series default
526
527\begin_inset Quotes srd
528\end_inset
529
530,
531\begin_inset Quotes sld
532\end_inset
533
vlmba56d852004-09-29 13:29:17 +0000534
535\series bold
vlme18adea2004-06-03 03:49:45 +0000536,
vlmba56d852004-09-29 13:29:17 +0000537\series default
538
vlme18adea2004-06-03 03:49:45 +0000539\begin_inset Quotes srd
540\end_inset
541
542 (comma),
543\begin_inset Quotes sld
544\end_inset
545
546
547\series bold
548-
549\series default
550
551\begin_inset Quotes srd
552\end_inset
553
554,
555\begin_inset Quotes sld
556\end_inset
557
558
559\series bold
560.
561\series default
562
563\begin_inset Quotes srd
564\end_inset
565
566,
567\begin_inset Quotes sld
568\end_inset
569
570
571\series bold
572/
573\series default
574
575\begin_inset Quotes srd
576\end_inset
577
578, digits (
579\begin_inset Quotes sld
580\end_inset
581
5820
583\begin_inset Quotes srd
584\end_inset
585
586 to
587\begin_inset Quotes sld
588\end_inset
589
5909
591\begin_inset Quotes srd
592\end_inset
593
594),
595\begin_inset Quotes sld
596\end_inset
597
598
599\series bold
600:
601\series default
602
603\begin_inset Quotes srd
604\end_inset
605
606,
607\begin_inset Quotes sld
608\end_inset
609
610
611\series bold
612=
613\series default
614
615\begin_inset Quotes srd
616\end_inset
617
618,
619\begin_inset Quotes sld
620\end_inset
621
622
623\series bold
624?
625\series default
626
627\begin_inset Quotes srd
628\end_inset
629
630, upper-case and lower-case letters (
631\begin_inset Quotes sld
632\end_inset
633
634A
635\begin_inset Quotes srd
636\end_inset
637
638 to
639\begin_inset Quotes sld
640\end_inset
641
642Z
643\begin_inset Quotes srd
644\end_inset
645
646 and
647\begin_inset Quotes sld
648\end_inset
649
650a
651\begin_inset Quotes srd
652\end_inset
653
654 to
655\begin_inset Quotes sld
656\end_inset
657
658z
659\begin_inset Quotes srd
660\end_inset
661
vlmba56d852004-09-29 13:29:17 +0000662).
vlme18adea2004-06-03 03:49:45 +0000663\layout Subsection
664
665The VisibleString type
666\layout Standard
667
668The character string with the alphabet which is more or less a subset of
vlmba56d852004-09-29 13:29:17 +0000669 ASCII between the space and the
vlme18adea2004-06-03 03:49:45 +0000670\begin_inset Quotes sld
671\end_inset
672
vlmfcec8e52004-08-23 15:12:04 +0000673
674\series bold
vlme18adea2004-06-03 03:49:45 +0000675~
vlmfcec8e52004-08-23 15:12:04 +0000676\series default
677
vlme18adea2004-06-03 03:49:45 +0000678\begin_inset Quotes srd
679\end_inset
680
vlmba56d852004-09-29 13:29:17 +0000681 symbol (tilde).
682\layout Standard
683
684Alternatively, the alphabet may be described as the PrintableString alphabet
vlmfcec8e52004-08-23 15:12:04 +0000685 presented earlier, plus the following characters:
vlme18adea2004-06-03 03:49:45 +0000686\begin_inset Quotes sld
687\end_inset
688
689
690\series bold
691!
692\series default
693
694\begin_inset Quotes srd
695\end_inset
696
697,
698\begin_inset Quotes sld
699\end_inset
700
701
702\series bold
703
704\begin_inset Quotes srd
705\end_inset
706
707
708\series default
709
710\begin_inset Quotes srd
711\end_inset
712
713,
714\begin_inset Quotes sld
715\end_inset
716
717
718\series bold
719#
720\series default
721
722\begin_inset Quotes srd
723\end_inset
724
725,
726\begin_inset Quotes sld
727\end_inset
728
729
730\series bold
731$
732\series default
733
734\begin_inset Quotes srd
735\end_inset
736
737,
738\begin_inset Quotes sld
739\end_inset
740
741
742\series bold
743%
744\series default
745
746\begin_inset Quotes srd
747\end_inset
748
749,
750\begin_inset Quotes sld
751\end_inset
752
753
754\series bold
755&
756\series default
757
758\begin_inset Quotes srd
759\end_inset
760
761,
762\begin_inset Quotes sld
763\end_inset
764
765
766\series bold
767*
768\series default
769
770\begin_inset Quotes srd
771\end_inset
772
773,
774\begin_inset Quotes sld
775\end_inset
776
777
778\series bold
779;
780\series default
781
782\begin_inset Quotes srd
783\end_inset
784
785,
786\begin_inset Quotes sld
787\end_inset
788
789
790\series bold
791<
792\series default
793
794\begin_inset Quotes srd
795\end_inset
796
797,
798\begin_inset Quotes sld
799\end_inset
800
801
802\series bold
803>
804\series default
805
806\begin_inset Quotes srd
807\end_inset
808
809,
810\begin_inset Quotes sld
811\end_inset
812
813
814\series bold
815[
816\series default
817
818\begin_inset Quotes srd
819\end_inset
820
821,
822\begin_inset Quotes sld
823\end_inset
824
825
826\series bold
827
828\backslash
829
830\series default
831
832\begin_inset Quotes srd
833\end_inset
834
835,
836\begin_inset Quotes sld
837\end_inset
838
839
840\series bold
841]
842\series default
843
844\begin_inset Quotes srd
845\end_inset
846
847,
848\begin_inset Quotes sld
849\end_inset
850
851
852\series bold
853^
854\series default
855
856\begin_inset Quotes srd
857\end_inset
858
859,
860\begin_inset Quotes sld
861\end_inset
862
863
864\series bold
865_
866\series default
867
868\begin_inset Quotes srd
869\end_inset
870
871,
872\begin_inset Quotes sld
873\end_inset
874
875
876\series bold
877`
878\series default
879
880\begin_inset Quotes srd
881\end_inset
882
883 (single left quote),
884\begin_inset Quotes sld
885\end_inset
886
887
888\series bold
889{
890\series default
891
892\begin_inset Quotes srd
893\end_inset
894
895,
896\begin_inset Quotes sld
897\end_inset
898
899
900\series bold
901|
902\series default
903
904\begin_inset Quotes srd
905\end_inset
906
907,
908\begin_inset Quotes sld
909\end_inset
910
911
912\series bold
913}
914\series default
915
916\begin_inset Quotes srd
917\end_inset
918
919,
920\begin_inset Quotes sld
921\end_inset
922
vlmfcec8e52004-08-23 15:12:04 +0000923
924\series bold
vlme18adea2004-06-03 03:49:45 +0000925~
vlmfcec8e52004-08-23 15:12:04 +0000926\series default
927
vlme18adea2004-06-03 03:49:45 +0000928\begin_inset Quotes srd
929\end_inset
930
931.
932\layout Section
933
934ASN.1 Constructed Types
935\layout Subsection
936
937The SEQUENCE type
938\layout Standard
939
940This is an ordered collection of other simple or constructed types.
941 The SEQUENCE constructed type resembles the C
942\begin_inset Quotes sld
943\end_inset
944
945struct
946\begin_inset Quotes srd
947\end_inset
948
949 statement.
950\layout LyX-Code
951
952Address ::= SEQUENCE {
953\layout LyX-Code
954
955 -- The apartment number may be omitted
956\layout LyX-Code
957
vlmc3bfd812004-09-30 22:26:19 +0000958 apartmentNumber NumericString OPTIONAL,
vlme18adea2004-06-03 03:49:45 +0000959\layout LyX-Code
960
961 streetName PrintableString,
962\layout LyX-Code
963
964 cityName PrintableString,
965\layout LyX-Code
966
967 stateName PrintableString,
968\layout LyX-Code
969
970 -- This one may be omitted too
971\layout LyX-Code
972
973 zipNo NumericString OPTIONAL
974\layout LyX-Code
975
976}
977\layout Subsection
978
979The SET type
980\layout Standard
981
982This is a collection of other simple or constructed types.
983 Ordering is not important.
984 The data may arrive in the order which is different from the order of specifica
985tion.
986 Data is encoded in the order not necessarily corresponding to the order
987 of specification.
988\layout Subsection
989
990The CHOICE type
991\layout Standard
992
993This type is just a choice between the subtypes specified in it.
994 The CHOICE type contains at most one of the subtypes specified, and it
995 is always implicitly known which choice is being decoded or encoded.
996 This one resembles the C
997\begin_inset Quotes sld
998\end_inset
999
1000union
1001\begin_inset Quotes srd
1002\end_inset
1003
1004 statement.
1005\layout Standard
1006
1007The following type defines a response code, which may be either an integer
1008 code or a boolean
1009\begin_inset Quotes sld
1010\end_inset
1011
1012true
1013\begin_inset Quotes srd
1014\end_inset
1015
1016/
1017\begin_inset Quotes srd
1018\end_inset
1019
1020false
1021\begin_inset Quotes srd
1022\end_inset
1023
1024 code.
1025\layout LyX-Code
1026
1027ResponseCode ::= CHOICE {
1028\layout LyX-Code
1029
1030 intCode INTEGER,
1031\layout LyX-Code
1032
1033 boolCode BOOLEAN
1034\layout LyX-Code
1035
1036}
1037\layout LyX-Code
1038
1039\layout Subsection
1040
1041The SEQUENCE OF type
1042\layout Standard
1043
1044This one is the list (array) of simple or constructed types:
1045\layout LyX-Code
1046
1047-- Example 1
1048\layout LyX-Code
1049
1050ManyIntegers ::= SEQUENCE OF INTEGER
1051\layout LyX-Code
1052
vlmfcec8e52004-08-23 15:12:04 +00001053
1054\layout LyX-Code
1055
vlme18adea2004-06-03 03:49:45 +00001056-- Example 2
1057\layout LyX-Code
1058
1059ManyRectangles ::= SEQUENCE OF Rectangle
1060\layout LyX-Code
1061
vlmfcec8e52004-08-23 15:12:04 +00001062
1063\layout LyX-Code
1064
vlme18adea2004-06-03 03:49:45 +00001065-- More complex example:
1066\layout LyX-Code
1067
1068-- an array of structures defined in place.
1069\layout LyX-Code
1070
1071ManyCircles ::= SEQUENCE OF SEQUENCE {
1072\layout LyX-Code
1073
1074 radius INTEGER
1075\layout LyX-Code
1076
1077 }
1078\layout Subsection
1079
1080The SET OF type
1081\layout Standard
1082
1083The SET OF type models the bag of structures.
1084 It resembles the SEQUENCE OF type, but the order is not important: i.e.
1085 the elements may arrive in the order which is not necessarily the same
1086 as the in-memory order on the remote machines.
1087\layout LyX-Code
1088
1089-- A set of structures defined elsewhere
1090\layout LyX-Code
1091
1092SetOfApples :: SET OF Apple
1093\layout LyX-Code
1094
vlmfcec8e52004-08-23 15:12:04 +00001095
1096\layout LyX-Code
1097
vlme18adea2004-06-03 03:49:45 +00001098-- Set of integers encoding the kind of a fruit
1099\layout LyX-Code
1100
1101FruitBag ::= SET OF ENUMERATED { apple, orange }
vlmcaba97b2004-08-07 05:00:07 +00001102\layout Part
1103
1104Using the ASN.1 Compiler
vlme18adea2004-06-03 03:49:45 +00001105\layout Chapter
1106
vlmcaba97b2004-08-07 05:00:07 +00001107Introduction to the ASN.1 Compiler
vlme18adea2004-06-03 03:49:45 +00001108\layout Standard
1109
1110The purpose of the ASN.1 compiler, of which this document is part, is to
1111 convert the ASN.1 specifications to some other target language (currently,
1112 only C is supported
1113\begin_inset Foot
1114collapsed false
1115
1116\layout Standard
1117
1118C++ is
1119\begin_inset Quotes sld
1120\end_inset
1121
1122supported
1123\begin_inset Quotes srd
1124\end_inset
1125
vlmfcec8e52004-08-23 15:12:04 +00001126 too, as long as an class-based approach is not a definitive factor.
vlme18adea2004-06-03 03:49:45 +00001127\end_inset
1128
1129).
1130 The compiler reads the specification and emits a series of target language
1131 structures and surrounding maintenance code.
1132 For example, the C structure which may be created by compiler to represent
1133 the simple
1134\emph on
1135Rectangle
1136\emph default
1137 specification defined earlier in this document, may look like this
1138\begin_inset Foot
1139collapsed false
1140
1141\layout Standard
1142
1143
1144\emph on
vlm03af0f02004-09-14 12:48:17 +00001145-fnative-types
vlme18adea2004-06-03 03:49:45 +00001146\emph default
1147 compiler option is used to produce basic C
1148\emph on
1149int
1150\emph default
vlmfcec8e52004-08-23 15:12:04 +00001151 types instead of infinite width INTEGER_t structures.
1152 See Table
1153\begin_inset LatexCommand \vref{cap:asn1c-cmdopts}
1154
1155\end_inset
1156
1157.
vlme18adea2004-06-03 03:49:45 +00001158\end_inset
1159
1160:
1161\layout LyX-Code
1162
1163typedef struct Rectangle_s {
1164\layout LyX-Code
1165
1166 int height;
1167\layout LyX-Code
1168
1169 int width;
1170\layout LyX-Code
1171
1172} Rectangle_t;
1173\layout Standard
1174
1175This would not be of much value for such a simple specification, so the
1176 compiler goes further and actually produces the code which fills in this
vlmfcec8e52004-08-23 15:12:04 +00001177 structure by parsing the opaque binary
vlme18adea2004-06-03 03:49:45 +00001178\begin_inset Foot
vlmfcec8e52004-08-23 15:12:04 +00001179collapsed true
vlme18adea2004-06-03 03:49:45 +00001180
1181\layout Standard
1182
1183BER, CER and DER encodings are binary.
1184 However, the XER encoding is text (XML) based.
1185\end_inset
1186
1187 data provided in some buffer.
1188 It also produces the code that takes this structure as an argument and
1189 performs structure serialization by emitting a series of bytes.
vlmfcec8e52004-08-23 15:12:04 +00001190\layout Chapter
vlme18adea2004-06-03 03:49:45 +00001191
1192Quick start
1193\layout Standard
1194
vlmfcec8e52004-08-23 15:12:04 +00001195After building and installing the compiler, the
1196\emph on
1197asn1c
1198\begin_inset Foot
1199collapsed false
1200
1201\layout Standard
1202
1203The 1 symbol in asn
1204\series bold
12051
1206\series default
1207c is a digit, not an
1208\begin_inset Quotes sld
1209\end_inset
1210
1211ell
1212\begin_inset Quotes srd
1213\end_inset
1214
1215 letter.
1216\end_inset
1217
1218
1219\emph default
1220 command may be used to compile the ASN.1 specification
vlme18adea2004-06-03 03:49:45 +00001221\begin_inset Foot
1222collapsed false
1223
1224\layout Standard
1225
1226This is probably
1227\series bold
1228not
1229\series default
1230 what you want to try out right now -- read through the rest of this chapter
vlmfcec8e52004-08-23 15:12:04 +00001231 to find out about
1232\series bold
1233-P
1234\series default
1235 and
1236\series bold
1237-R
1238\series default
1239 options.
vlme18adea2004-06-03 03:49:45 +00001240\end_inset
1241
1242:
1243\layout LyX-Code
1244
1245asn1c
1246\emph on
1247<spec.asn1>
1248\layout Standard
1249
vlmfcec8e52004-08-23 15:12:04 +00001250If several specifications contain interdependencies, all of the files must
1251 be specified altogether:
vlme18adea2004-06-03 03:49:45 +00001252\layout LyX-Code
1253
1254asn1c
1255\emph on
1256<spec1.asn1> <spec2.asn1> ...
1257\layout Standard
1258
vlmfcec8e52004-08-23 15:12:04 +00001259The compiler
1260\series bold
1261-E
1262\series default
1263 and
1264\series bold
1265-EF
1266\series default
1267 options are used for testing the parser and the semantic fixer, respectively.
1268 These options will instruct the compiler to dump out the parsed (and fixed,
1269 if
1270\series bold
1271-F
1272\series default
1273 is involved) ASN.1 specification as it was "understood" by the compiler.
1274 It might be useful to check whether a particular syntactic construction
vlme18adea2004-06-03 03:49:45 +00001275 is properly supported by the compiler.
1276\layout LyX-Code
1277
vlmfcec8e52004-08-23 15:12:04 +00001278asn1c
1279\series bold
1280-EF
1281\series default
1282
vlme18adea2004-06-03 03:49:45 +00001283\emph on
1284<spec-to-test.asn1>
1285\layout Standard
1286
vlmfcec8e52004-08-23 15:12:04 +00001287The
1288\series bold
1289-P
1290\series default
1291 option is used to dump the compiled output on the screen instead of creating
1292 a bunch of .c and .h files on disk in the current directory.
1293 You would probably want to start with
1294\series bold
1295-P
1296\series default
1297 option instead of creating a mess in your current directory.
1298 Another option,
1299\series bold
1300-R
1301\series default
1302, asks compiler to only generate the files which need to be generated, and
1303 supress linking in the numerous support files.
1304\layout Standard
1305
1306Print the compiled output instead of creating multiple source files:
1307\layout LyX-Code
1308
1309asn1c
1310\series bold
1311-P
1312\series default
1313
1314\emph on
1315<spec-to-compile-and-print.asn1>
1316\layout LyX-Code
1317
1318\layout Chapter
1319
1320Using the ASN.1 Compiler
vlme18adea2004-06-03 03:49:45 +00001321\layout Section
1322
vlmfcec8e52004-08-23 15:12:04 +00001323Command-line options
1324\layout Standard
1325
1326The Table
1327\begin_inset LatexCommand \vref{cap:asn1c-cmdopts}
1328
1329\end_inset
1330
1331 summarizes various options affecting the compiler's behavior.
1332\layout Standard
1333
1334
1335\begin_inset Float table
1336wide false
vlm12c8f692004-09-06 08:07:29 +00001337collapsed false
vlmfcec8e52004-08-23 15:12:04 +00001338
1339\layout Standard
1340
1341
1342\begin_inset Tabular
vlm60e7ef02004-10-13 09:13:56 +00001343<lyxtabular version="3" rows="22" columns="2">
vlmc3bfd812004-09-30 22:26:19 +00001344<features islongtable="true">
vlmfcec8e52004-08-23 15:12:04 +00001345<column alignment="left" valignment="top" leftline="true" width="0">
1346<column alignment="block" valignment="top" leftline="true" rightline="true" width="3in">
1347<row topline="true" bottomline="true">
1348<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1349\begin_inset Text
1350
1351\layout Standard
1352
1353
1354\series bold
1355Overall Options
1356\end_inset
1357</cell>
1358<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1359\begin_inset Text
1360
1361\layout Standard
1362
1363
1364\series bold
1365Description
1366\end_inset
1367</cell>
1368</row>
1369<row topline="true">
1370<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1371\begin_inset Text
1372
1373\layout Standard
1374
1375-E
1376\end_inset
1377</cell>
1378<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1379\begin_inset Text
1380
1381\layout Standard
1382
1383
1384\size small
1385Stop after the parsing stage and print the reconstructed ASN.1 specification
1386 code to the standard output.
1387\end_inset
1388</cell>
1389</row>
1390<row topline="true">
1391<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1392\begin_inset Text
1393
1394\layout Standard
1395
1396-F
1397\end_inset
1398</cell>
1399<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1400\begin_inset Text
1401
1402\layout Standard
1403
1404
1405\size small
1406Used together with -E, instructs the compiler to stop after the ASN.1 syntax
1407 tree fixing stage and dump the reconstructed ASN.1 specification to the
1408 standard output.
1409\end_inset
1410</cell>
1411</row>
1412<row topline="true">
1413<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1414\begin_inset Text
1415
1416\layout Standard
1417
1418-P
1419\end_inset
1420</cell>
1421<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1422\begin_inset Text
1423
1424\layout Standard
1425
1426
1427\size small
1428Dump the compiled output to the standard output instead of cre- ating the
1429 target language files on disk.
1430\end_inset
1431</cell>
1432</row>
1433<row topline="true">
1434<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1435\begin_inset Text
1436
1437\layout Standard
1438
1439-R
1440\end_inset
1441</cell>
1442<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1443\begin_inset Text
1444
1445\layout Standard
1446
1447
1448\size small
1449Restrict the compiler to generate only the ASN.1 tables, omit- ting the usual
1450 support code.
1451\end_inset
1452</cell>
1453</row>
vlm60e7ef02004-10-13 09:13:56 +00001454<row topline="true">
vlmfcec8e52004-08-23 15:12:04 +00001455<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1456\begin_inset Text
1457
1458\layout Standard
1459
1460-S
1461\emph on
1462<directory>
1463\end_inset
1464</cell>
1465<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1466\begin_inset Text
1467
1468\layout Standard
1469
1470
1471\size small
1472Use the specified directory with ASN.1 skeleton files.
1473\end_inset
1474</cell>
1475</row>
vlm60e7ef02004-10-13 09:13:56 +00001476<row topline="true" bottomline="true">
1477<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1478\begin_inset Text
1479
1480\layout Standard
1481
1482-X
1483\end_inset
1484</cell>
1485<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1486\begin_inset Text
1487
1488\layout Standard
1489
1490Generate the XML DTD for the specified ASN.1 modules.
1491\end_inset
1492</cell>
1493</row>
vlmfcec8e52004-08-23 15:12:04 +00001494<row topline="true">
1495<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1496\begin_inset Text
1497
1498\layout Standard
1499
1500
1501\series bold
1502Warning Options
1503\end_inset
1504</cell>
1505<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1506\begin_inset Text
1507
1508\layout Standard
1509
1510
1511\series bold
1512Description
1513\end_inset
1514</cell>
1515</row>
1516<row topline="true">
1517<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1518\begin_inset Text
1519
1520\layout Standard
1521
1522-Werror
1523\end_inset
1524</cell>
1525<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1526\begin_inset Text
1527
1528\layout Standard
1529
1530
1531\size small
1532Treat warnings as errors; abort if any warning is produced.
1533\end_inset
1534</cell>
1535</row>
1536<row topline="true">
1537<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1538\begin_inset Text
1539
1540\layout Standard
1541
1542-Wdebug-lexer
1543\end_inset
1544</cell>
1545<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1546\begin_inset Text
1547
1548\layout Standard
1549
1550
1551\size small
1552Enable lexer debugging during the ASN.1 parsing stage.
1553\end_inset
1554</cell>
1555</row>
1556<row topline="true">
1557<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1558\begin_inset Text
1559
1560\layout Standard
1561
1562-Wdebug-fixer
1563\end_inset
1564</cell>
1565<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1566\begin_inset Text
1567
1568\layout Standard
1569
1570
1571\size small
1572 Enable ASN.1 syntax tree fixer debugging during the fixing stage.
1573\end_inset
1574</cell>
1575</row>
1576<row topline="true" bottomline="true">
1577<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1578\begin_inset Text
1579
1580\layout Standard
1581
1582-Wdebug-compiler
1583\end_inset
1584</cell>
1585<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1586\begin_inset Text
1587
1588\layout Standard
1589
1590
1591\size small
1592Enable debugging during the actual compile time.
1593\end_inset
1594</cell>
1595</row>
1596<row topline="true">
1597<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1598\begin_inset Text
1599
1600\layout Standard
1601
1602
1603\series bold
1604Language Options
1605\end_inset
1606</cell>
1607<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1608\begin_inset Text
1609
1610\layout Standard
1611
1612
1613\series bold
1614Description
1615\end_inset
1616</cell>
1617</row>
1618<row topline="true">
1619<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1620\begin_inset Text
1621
1622\layout Standard
1623
vlm12c8f692004-09-06 08:07:29 +00001624-fall-defs-global
1625\end_inset
1626</cell>
1627<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1628\begin_inset Text
1629
1630\layout Standard
1631
vlmba56d852004-09-29 13:29:17 +00001632Normally the compiler hides the definitions (asn_DEF_xxx) of the inner structure
1633 elements (members of SEQUENCE, SET and other types).
vlm12c8f692004-09-06 08:07:29 +00001634 This option makes all such definitions global.
vlmba56d852004-09-29 13:29:17 +00001635 Enabling this option may pollute the namespace by making lots of asn_DEF_xxx
vlm12c8f692004-09-06 08:07:29 +00001636 structures globally visible, but will allow you to manipulate (encode and
1637 decode) the individual members of any complex ASN.1 structure.
1638\end_inset
1639</cell>
1640</row>
1641<row topline="true">
1642<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1643\begin_inset Text
1644
1645\layout Standard
1646
vlmfcec8e52004-08-23 15:12:04 +00001647-fbless-SIZE
1648\end_inset
1649</cell>
1650<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1651\begin_inset Text
1652
1653\layout Standard
1654
1655
1656\size small
1657Allow SIZE() constraint for INTEGER, ENUMERATED, and other types for which
1658 this constraint is normally prohibited by the standard.
1659 This is a violation of an ASN.1 standard and compiler may fail to produce
1660 the meaningful code.
1661\end_inset
1662</cell>
1663</row>
1664<row topline="true">
1665<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1666\begin_inset Text
1667
1668\layout Standard
1669
vlm03af0f02004-09-14 12:48:17 +00001670-fnative-types
vlmfcec8e52004-08-23 15:12:04 +00001671\end_inset
1672</cell>
1673<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1674\begin_inset Text
1675
1676\layout Standard
1677
1678
1679\size small
vlm03af0f02004-09-14 12:48:17 +00001680Use the native machine's data types (int, double) whenever possible, instead
vlmc3bfd812004-09-30 22:26:19 +00001681 of the compound INTEGER_t, ENUMERATED_t and REAL_t types.
vlmfcec8e52004-08-23 15:12:04 +00001682
1683\end_inset
1684</cell>
1685</row>
1686<row topline="true">
1687<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1688\begin_inset Text
1689
1690\layout Standard
1691
vlmbfc49bd2004-09-26 13:13:13 +00001692-fno-constraints
1693\end_inset
1694</cell>
1695<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1696\begin_inset Text
1697
1698\layout Standard
1699
1700Do not generate ASN.1 subtype constraint checking code.
1701 This may make a shorter executable.
1702\end_inset
1703</cell>
1704</row>
1705<row topline="true">
1706<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1707\begin_inset Text
1708
1709\layout Standard
1710
vlmfcec8e52004-08-23 15:12:04 +00001711-funnamed-unions
1712\end_inset
1713</cell>
1714<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1715\begin_inset Text
1716
1717\layout Standard
1718
1719
1720\size small
1721Enable unnamed unions in the definitions of target language's structures.
1722\end_inset
1723</cell>
1724</row>
1725<row topline="true" bottomline="true">
1726<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1727\begin_inset Text
1728
1729\layout Standard
1730
1731-ftypes88
1732\end_inset
1733</cell>
1734<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1735\begin_inset Text
1736
1737\layout Standard
1738
1739
1740\size small
vlmc3bfd812004-09-30 22:26:19 +00001741Pretend to support only ASN.1:1988 embedded types.
1742 Certain reserved words, such as UniversalString and BMPString, become ordinary
1743 type references and may be redefined by the specification.
vlmfcec8e52004-08-23 15:12:04 +00001744\end_inset
1745</cell>
1746</row>
vlmc3bfd812004-09-30 22:26:19 +00001747<row topline="true" newpage="true">
vlmfcec8e52004-08-23 15:12:04 +00001748<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1749\begin_inset Text
1750
1751\layout Standard
1752
1753
1754\series bold
1755Output Options
1756\end_inset
1757</cell>
1758<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1759\begin_inset Text
1760
1761\layout Standard
1762
1763
1764\series bold
1765Description
1766\end_inset
1767</cell>
1768</row>
1769<row topline="true">
1770<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1771\begin_inset Text
1772
1773\layout Standard
1774
1775-print-constraints
1776\end_inset
1777</cell>
1778<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1779\begin_inset Text
1780
1781\layout Standard
1782
1783
1784\size small
1785When -EF are also specified, this option forces the compiler to explain
1786 its internal understanding of subtype constraints.
1787\end_inset
1788</cell>
1789</row>
1790<row topline="true" bottomline="true">
1791<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1792\begin_inset Text
1793
1794\layout Standard
1795
1796-print-lines
1797\end_inset
1798</cell>
1799<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1800\begin_inset Text
1801
1802\layout Standard
1803
1804
1805\size small
1806Generate "-- #line" comments in -E output.
1807\end_inset
1808</cell>
1809</row>
1810</lyxtabular>
1811
1812\end_inset
1813
1814
1815\layout Caption
1816
1817
1818\begin_inset LatexCommand \label{cap:asn1c-cmdopts}
1819
1820\end_inset
1821
1822The list of asn1c command line options
1823\end_inset
1824
1825
1826\layout Section
vlme18adea2004-06-03 03:49:45 +00001827
1828Recognizing compiler output
1829\layout Standard
1830
1831After compiling, the following entities will be created in your current
1832 directory:
1833\layout Itemize
1834
1835A set of .c and .h files, generally a single pair for each type defined in
1836 the ASN.1 specifications.
1837 These files will be named similarly to the ASN.1 types (
1838\emph on
1839Rectangle.c
1840\emph default
1841 and
1842\emph on
1843Rectangle.h
1844\emph default
1845 for the specification defined in the beginning of this document).
1846\layout Itemize
1847
1848A set of helper .c and .h files which contain generic encoders, decoders and
1849 other useful routines.
vlmfcec8e52004-08-23 15:12:04 +00001850 There will be quite a few of them, some of them even are not always necessary,
1851 but the overall amount of code after compiling will be rather small anyway.
vlme18adea2004-06-03 03:49:45 +00001852\layout Standard
1853
1854It is your responsibility to create .c file with the
1855\emph on
1856 int main()
1857\emph default
1858 routine and the Makefile (if needed).
1859 Compiler helps you with the latter by creating the Makefile.am.sample, containing
1860 the skeleton definition for the automake, should you want to use autotools.
1861\layout Standard
1862
1863In other words, after compiling the Rectangle module, you have the following
1864 set of files: { Makefile.am.sample, Rectangle.c, Rectangle.h,
1865\series bold
1866\SpecialChar \ldots{}
1867
1868\series default
1869 }, where
1870\series bold
1871
1872\begin_inset Quotes sld
1873\end_inset
1874
1875\SpecialChar \ldots{}
1876
1877\begin_inset Quotes srd
1878\end_inset
1879
1880
1881\series default
1882 stands for the set of additional
1883\begin_inset Quotes sld
1884\end_inset
1885
1886helper
1887\begin_inset Quotes srd
1888\end_inset
1889
1890 files created by the compiler.
1891 If you add the simple file with the
1892\emph on
1893int main()
1894\emph default
1895 routine, it would even be possible to compile everything with the single
1896 instruction:
1897\layout LyX-Code
1898
1899cc -o rectangle *.c # It could be
1900\emph on
1901that
1902\emph default
1903 simple
1904\begin_inset Foot
1905collapsed false
1906
1907\layout Standard
1908
1909Provided that you've also created a .c file with the
1910\emph on
1911int main()
1912\emph default
1913 routine.
1914\end_inset
1915
1916
vlmfcec8e52004-08-23 15:12:04 +00001917\layout Section
vlme18adea2004-06-03 03:49:45 +00001918
vlmc3bfd812004-09-30 22:26:19 +00001919Invoking the ASN.1 helper code from an application
1920\begin_inset OptArg
1921collapsed true
1922
1923\layout Standard
1924
1925Invoking the helper code
1926\end_inset
1927
1928
vlme18adea2004-06-03 03:49:45 +00001929\layout Standard
1930
vlmfcec8e52004-08-23 15:12:04 +00001931First of all, you should to include one or more header files into your applicati
1932on.
1933 For our Rectangle module, including the Rectangle.h file is enough:
vlme18adea2004-06-03 03:49:45 +00001934\layout LyX-Code
1935
1936#include <Rectangle.h>
1937\layout Standard
1938
1939The header files defines the C structure corresponding to the ASN.1 definition
1940 of a rectangle and the declaration of the ASN.1 type descriptor, which is
1941 used as an argument to most of the functions provided by the ASN.1 module.
1942 For example, here is the code which frees the Rectangle_t structure:
1943\layout LyX-Code
1944
vlmfcec8e52004-08-23 15:12:04 +00001945Rectangle_t *rect = ...;
1946\layout LyX-Code
1947
1948
vlme18adea2004-06-03 03:49:45 +00001949\layout LyX-Code
1950
vlmba56d852004-09-29 13:29:17 +00001951asn_DEF_Rectangle->free_struct(&asn_DEF_Rectangle,
vlme18adea2004-06-03 03:49:45 +00001952\layout LyX-Code
1953
1954 rect, 0);
1955\layout Standard
1956
1957This code defines a
1958\emph on
1959rect
1960\emph default
1961 pointer which points to the Rectangle_t structure which needs to be freed.
1962 The second line invokes the generic free_struct routine created specifically
1963 for this Rectangle_t structure.
1964 The
1965\emph on
vlmba56d852004-09-29 13:29:17 +00001966asn_DEF_Rectangle
vlme18adea2004-06-03 03:49:45 +00001967\emph default
1968 is the type descriptor, which holds a collection of generic routines to
1969 deal with the Rectangle_t structure.
1970\layout Standard
1971
1972There are several generic functions available:
1973\layout Description
1974
vlme18adea2004-06-03 03:49:45 +00001975ber_decoder This is the generic
1976\emph on
1977restartable
1978\begin_inset Foot
1979collapsed false
1980
1981\layout Standard
1982
1983Restartable means that if the decoder encounters the end of the buffer,
1984 it will fail, but may later be invoked again with the rest of the buffer
1985 to continue decoding.
1986\end_inset
1987
1988
1989\emph default
1990BER decoder (Basic Encoding Rules).
1991 This decoder would create and/or fill the target structure for you.
1992 Please refer to Section
1993\begin_inset LatexCommand \ref{sub:Decoding-BER}
1994
1995\end_inset
1996
1997.
1998\layout Description
1999
2000der_encoder This is the generic DER encoder (Distinguished Encoding Rules).
vlm68d43e92004-09-24 20:56:07 +00002001 This encoder will take the target structure and encode it into a series
vlme18adea2004-06-03 03:49:45 +00002002 of bytes.
2003 Please refer to Section
2004\begin_inset LatexCommand \ref{sub:Encoding-DER}
2005
2006\end_inset
2007
2008.
2009\layout Description
2010
vlm68d43e92004-09-24 20:56:07 +00002011xer_encoder This is the generic XER encoder (XML Encoding Rules).
2012 This encoder will take the target structure and represent it as an XML
2013 (text) document.
2014 Please refer to Section
2015\begin_inset LatexCommand \ref{sub:Encoding-XER}
2016
2017\end_inset
2018
2019.
2020\layout Description
2021
2022check_constraints Check that the contents of the target structure are semantical
2023ly valid and constrained to appropriate implicit or explicit subtype constraints.
2024 Please refer to Section
2025\begin_inset LatexCommand \vref{sub:Validating-the-target}
2026
2027\end_inset
2028
2029.
2030\layout Description
2031
vlme18adea2004-06-03 03:49:45 +00002032print_struct This function convert the contents of the passed target structure
2033 into human readable form.
2034 This form is not formal and cannot be converted back into the structure,
2035 but it may turn out to be useful for debugging or quick-n-dirty printing.
2036 Please refer to Section
2037\begin_inset LatexCommand \ref{sub:Printing-the-target}
2038
2039\end_inset
2040
2041.
2042\layout Description
2043
2044free_struct This is a generic disposal which frees the target structure.
2045 Please refer to Section
2046\begin_inset LatexCommand \ref{sub:Freeing-the-target}
2047
2048\end_inset
2049
2050.
2051\layout Standard
2052
vlm68d43e92004-09-24 20:56:07 +00002053check_constraints Check that the contents of the target structure are semantical
2054ly valid and constrained to appropriate implicit or explicit subtype constraints.
2055 Please refer to Section
2056\begin_inset LatexCommand \vref{sub:Validating-the-target}
2057
2058\end_inset
2059
2060.
2061\layout Standard
2062
vlme18adea2004-06-03 03:49:45 +00002063Each of the above function takes the type descriptor (
2064\emph on
vlmba56d852004-09-29 13:29:17 +00002065asn_DEF_\SpecialChar \ldots{}
vlme18adea2004-06-03 03:49:45 +00002066
2067\emph default
2068) and the target structure (
2069\emph on
2070rect
2071\emph default
2072, in the above example).
2073 The target structure is typically created by the generic BER decoder or
2074 by the application itself.
2075\layout Standard
2076
2077Here is how the buffer can be deserialized into the structure:
2078\layout LyX-Code
2079
2080Rectangle_t *
2081\layout LyX-Code
2082
vlmfcec8e52004-08-23 15:12:04 +00002083simple_deserializer(const void *buffer, size_t buf_size) {
vlme18adea2004-06-03 03:49:45 +00002084\layout LyX-Code
2085
2086 Rectangle_t *rect = 0; /* Note this 0! */
2087\layout LyX-Code
2088
vlmaf2155e2004-10-20 15:48:55 +00002089 asn_dec_rval_t rval;
vlme18adea2004-06-03 03:49:45 +00002090\layout LyX-Code
2091
2092
2093\layout LyX-Code
2094
vlmba56d852004-09-29 13:29:17 +00002095 rval = asn_DEF_Rectangle->ber_decoder(0,
vlme18adea2004-06-03 03:49:45 +00002096\layout LyX-Code
2097
vlmba56d852004-09-29 13:29:17 +00002098 &asn_DEF_Rectangle,
vlme18adea2004-06-03 03:49:45 +00002099\layout LyX-Code
2100
2101 (void **)&rect,
2102\layout LyX-Code
2103
2104 buffer, buf_size,
2105\layout LyX-Code
2106
2107 0);
2108\layout LyX-Code
2109
2110
2111\layout LyX-Code
2112
2113 if(rval
2114\series bold
2115.code
2116\series default
2117 == RC_OK) {
2118\layout LyX-Code
2119
2120 return rect; /* Decoding succeeded */
2121\layout LyX-Code
2122
2123 } else {
2124\layout LyX-Code
2125
vlmfcec8e52004-08-23 15:12:04 +00002126 /* Free partially decoded rect */
2127\layout LyX-Code
2128
vlmba56d852004-09-29 13:29:17 +00002129 asn_DEF_Rectangle->free_struct(
vlme18adea2004-06-03 03:49:45 +00002130\layout LyX-Code
2131
vlmba56d852004-09-29 13:29:17 +00002132 &asn_DEF_Rectangle, rect, 0);
vlme18adea2004-06-03 03:49:45 +00002133\layout LyX-Code
2134
2135 return 0;
2136\layout LyX-Code
2137
2138 }
2139\layout LyX-Code
2140
2141}
2142\layout Standard
2143
2144The code above defines a function,
2145\emph on
2146simple_deserializer
2147\emph default
2148, which takes a buffer and its length and expected to return a pointer to
2149 the Rectangle_t structure.
2150 Inside, it tries to convert the bytes passed into the target structure
2151 (rect) using the generic BER decoder and returns the rect pointer afterwards.
2152 If the structure cannot be deserialized, it frees the memory which might
2153 be left allocated by the unfinished
2154\emph on
2155ber_decoder
2156\emph default
2157 routine and returns NULL.
2158
2159\series bold
2160This freeing is necessary
2161\series default
2162 because the ber_decoder is a restartable procedure, and may fail just because
2163 there is more data needs to be provided before decoding could be finalized.
2164 The code above obviously does not take into account the way the
2165\emph on
2166ber_decoder
2167\emph default
2168 failed, so the freeing is necessary because the part of the buffer may
2169 already be decoded into the structure by the time something goes wrong.
2170\layout Standard
2171
2172Restartable decoding is a little bit trickier: you need to provide the old
2173 target structure pointer (which might be already half-decoded) and react
2174 on RC_WMORE return code.
2175 This will be explained later in Section
2176\begin_inset LatexCommand \vref{sub:Decoding-BER}
2177
2178\end_inset
2179
2180
vlmfcec8e52004-08-23 15:12:04 +00002181\layout Subsection
vlme18adea2004-06-03 03:49:45 +00002182
2183
2184\begin_inset LatexCommand \label{sub:Decoding-BER}
2185
2186\end_inset
2187
2188Decoding BER
2189\layout Standard
2190
2191The Basic Encoding Rules describe the basic way how the structure can be
2192 encoded and decoded.
2193 Several other encoding rules (CER, DER) define a more restrictive versions
2194 of BER, so the generic BER parser is also capable of decoding the data
2195 encoded by CER and DER encoders.
2196 The opposite is not true.
2197\layout Standard
2198
2199The ASN.1 compiler provides the generic BER decoder which is implicitly capable
2200 of decoding BER, CER and DER encoded data.
2201\layout Standard
2202
2203The decoder is restartable (stream-oriented), which means that in case the
2204 buffer has less data than it is expected, the decoder will process whatever
2205 it is available and ask for more data to be provided.
2206 Please note that the decoder may actually process less data than it is
2207 given in the buffer, which means that you should be able to make the next
2208 buffer contain the unprocessed part of the previous buffer.
2209\layout Standard
2210
2211Suppose, you have two buffers of encoded data: 100 bytes and 200 bytes.
2212\layout Itemize
2213
2214You may concatenate these buffers and feed the BER decoder with 300 bytes
2215 of data, or
2216\layout Itemize
2217
2218You may feed it the first buffer of 100 bytes of data, realize that the
2219 ber_decoder consumed only 95 bytes from it and later feed the decoder with
2220 205 bytes buffer which consists of 5 unprocessed bytes from the first buffer
2221 and the latter 200 bytes from the second buffer.
2222\layout Standard
2223
2224This is not as convenient as it could be (like, the BER encoder would consume
2225 the whole 100 bytes and keep these 5 bytes in some temporary storage),
2226 but in case of stream-based processing it might actually be OK.
2227 Suggestions are welcome.
2228\layout Standard
2229
2230There are two ways to invoke a BER decoder.
2231 The first one is a direct reference of the type-specific decoder.
2232 This way was shown in the previous example of
2233\emph on
2234simple_deserializer
2235\emph default
2236 function.
2237 The second way is to invoke a
2238\emph on
2239ber_decode
2240\emph default
2241 function, which is just a simple wrapper of the former approach into a
2242 less wordy notation:
2243\layout LyX-Code
2244
vlmba56d852004-09-29 13:29:17 +00002245rval = ber_decode(0, &asn_DEF_Rectangle, (void **)&rect,
vlme18adea2004-06-03 03:49:45 +00002246\layout LyX-Code
2247
2248 buffer, buf_size);
2249\layout Standard
2250
vlmba56d852004-09-29 13:29:17 +00002251Note that the initial (asn_DEF_Rectangle->ber_decoder) reference is gone,
vlme18adea2004-06-03 03:49:45 +00002252 and also the last argument (0) is no longer necessary.
2253\layout Standard
2254
2255These two ways of invocations are fully equivalent.
2256\layout Standard
2257
2258The BER de
2259\emph on
2260coder
2261\emph default
vlmba56d852004-09-29 13:29:17 +00002262 may fail because of (
vlme18adea2004-06-03 03:49:45 +00002263\emph on
2264the following RC_\SpecialChar \ldots{}
2265 codes are defined in ber_decoder.h
2266\emph default
2267):
2268\layout Itemize
2269
2270RC_WMORE: There is more data expected than it is provided (stream mode continuat
2271ion feature);
2272\layout Itemize
2273
2274RC_FAIL: General failure to decode the buffer;
2275\layout Itemize
2276
2277\SpecialChar \ldots{}
2278 other codes may be defined as well.
2279\layout Standard
2280
vlmaf2155e2004-10-20 15:48:55 +00002281Together with the return code (.code) the asn_dec_rval_t type contains the
vlme18adea2004-06-03 03:49:45 +00002282 number of bytes which is consumed from the buffer.
2283 In the previous hypothetical example of two buffers (of 100 and 200 bytes),
2284 the first call to ber_decode() would return with .code = RC_WMORE and .consumed
2285 = 95.
2286 The .consumed field of the BER decoder return value is
2287\series bold
2288always
2289\series default
2290 valid, even if the decoder succeeds or fails with any other return code.
2291\layout Standard
2292
2293Please look into ber_decoder.h for the precise definition of ber_decode()
2294 and related types.
vlmfcec8e52004-08-23 15:12:04 +00002295\layout Subsection
vlme18adea2004-06-03 03:49:45 +00002296
2297
2298\begin_inset LatexCommand \label{sub:Encoding-DER}
2299
2300\end_inset
2301
2302Encoding DER
2303\layout Standard
2304
vlm68d43e92004-09-24 20:56:07 +00002305The Distinguished Encoding Rules is the
2306\emph on
2307canonical
2308\emph default
2309 variant of BER encoding rules.
2310 The DER is best suited to encode the structures where all the lengths are
2311 known beforehand.
vlme18adea2004-06-03 03:49:45 +00002312 This is probably exactly how you want to encode: either after a BER decoding
2313 or after a manual fill-up, the target structure contains the data which
2314 size is implicitly known before encoding.
2315 The DER encoding is used, for example, to encode X.509 certificates.
2316\layout Standard
2317
2318As with BER decoder, the DER encoder may be invoked either directly from
vlmba56d852004-09-29 13:29:17 +00002319 the ASN.1 type descriptor (asn_DEF_Rectangle) or from the stand-alone function,
vlme18adea2004-06-03 03:49:45 +00002320 which is somewhat simpler:
2321\layout LyX-Code
2322
vlme18adea2004-06-03 03:49:45 +00002323
2324\layout LyX-Code
2325
2326/*
2327\layout LyX-Code
2328
2329 * This is the serializer itself,
2330\layout LyX-Code
2331
2332 * it supplies the DER encoder with the
2333\layout LyX-Code
2334
2335 * pointer to the custom output function.
2336\layout LyX-Code
2337
2338 */
2339\layout LyX-Code
2340
2341ssize_t
2342\layout LyX-Code
2343
2344simple_serializer(FILE *ostream, Rectangle_t *rect) {
2345\layout LyX-Code
2346
vlm68d43e92004-09-24 20:56:07 +00002347 asn_enc_rval_t er; /* Encoder return value */
vlme18adea2004-06-03 03:49:45 +00002348\layout LyX-Code
2349
2350
2351\layout LyX-Code
2352
vlmba56d852004-09-29 13:29:17 +00002353 er = der_encode(&asn_DEF_Rect, rect,
vlme18adea2004-06-03 03:49:45 +00002354\layout LyX-Code
2355
vlmfcec8e52004-08-23 15:12:04 +00002356 write_stream, ostream);
vlme18adea2004-06-03 03:49:45 +00002357\layout LyX-Code
2358
vlm68d43e92004-09-24 20:56:07 +00002359 if(er.
vlme18adea2004-06-03 03:49:45 +00002360\series bold
vlm68d43e92004-09-24 20:56:07 +00002361encoded
vlme18adea2004-06-03 03:49:45 +00002362\series default
2363 == -1) {
2364\layout LyX-Code
2365
2366 /*
2367\layout LyX-Code
2368
vlm68d43e92004-09-24 20:56:07 +00002369 * Failed to encode the rectangle data.
vlme18adea2004-06-03 03:49:45 +00002370\layout LyX-Code
2371
2372 */
2373\layout LyX-Code
2374
2375 fprintf(stderr,
2376\begin_inset Quotes sld
2377\end_inset
2378
2379Cannot encode %s: %s
2380\backslash
2381n
2382\begin_inset Quotes srd
2383\end_inset
2384
2385,
2386\layout LyX-Code
2387
vlm68d43e92004-09-24 20:56:07 +00002388 er.
vlme18adea2004-06-03 03:49:45 +00002389\series bold
vlm68d43e92004-09-24 20:56:07 +00002390failed_type
vlme18adea2004-06-03 03:49:45 +00002391\series default
2392->name,
2393\layout LyX-Code
2394
2395 strerror(errno));
2396\layout LyX-Code
2397
2398 return -1;
2399\layout LyX-Code
2400
2401 } else {
2402\layout LyX-Code
2403
2404 /* Return the number of bytes */
2405\layout LyX-Code
2406
vlm68d43e92004-09-24 20:56:07 +00002407 return er.encoded;
vlme18adea2004-06-03 03:49:45 +00002408\layout LyX-Code
2409
2410 }
2411\layout LyX-Code
2412
2413}
2414\layout Standard
2415
2416As you see, the DER encoder does not write into some sort of buffer or something.
2417 It just invokes the custom function (possible, multiple times) which would
2418 save the data into appropriate storage.
2419 The optional argument
2420\emph on
2421app_key
2422\emph default
2423 is opaque for the DER encoder code and just used by
2424\emph on
2425_write_stream()
2426\emph default
2427 as the pointer to the appropriate output stream to be used.
2428\layout Standard
2429
2430If the custom write function is not given (passed as 0), then the DER encoder
2431 will essentially do the same thing (i.e., encode the data) but no callbacks
2432 will be invoked (so the data goes nowhere).
2433 It may prove useful to determine the size of the structure's encoding before
2434 actually doing the encoding
2435\begin_inset Foot
2436collapsed false
2437
2438\layout Standard
2439
2440It is actually faster too: the encoder might skip over some computations
2441 which aren't important for the size determination.
2442\end_inset
2443
2444.
2445\layout Standard
2446
2447Please look into der_encoder.h for the precise definition of der_encode()
2448 and related types.
vlmfcec8e52004-08-23 15:12:04 +00002449\layout Subsection
vlme18adea2004-06-03 03:49:45 +00002450
2451
vlm68d43e92004-09-24 20:56:07 +00002452\begin_inset LatexCommand \label{sub:Encoding-XER}
2453
2454\end_inset
2455
2456Encoding XER
2457\layout Standard
2458
2459The XER stands for XML Encoding Rules, where XML, in turn, is eXtensible
2460 Markup Language, a text-based format for information exchange.
2461 The encoder routine API comes in two flavors: stdio-based and callback-based.
2462 With the callback-based encoder, the encoding process is very similar to
2463 the DER one, described in Section
2464\begin_inset LatexCommand \vref{sub:Encoding-DER}
2465
2466\end_inset
2467
2468.
2469 The following example uses the definition of write_stream() from up there.
2470\layout LyX-Code
2471
2472/*
2473\layout LyX-Code
2474
2475 * This procedure generates the XML document
2476\layout LyX-Code
2477
2478 * by invoking the XER encoder.
2479\layout LyX-Code
2480
2481 * NOTE: Do not copy this code verbatim!
2482\layout LyX-Code
2483
2484 * If the stdio output is necessary,
2485\layout LyX-Code
2486
2487 * use the xer_fprint() procedure instead.
2488\layout LyX-Code
2489
2490 * See Section
2491\begin_inset LatexCommand \vref{sub:Printing-the-target}
2492
2493\end_inset
2494
2495.
2496\layout LyX-Code
2497
2498 */
2499\layout LyX-Code
2500
2501int
2502\layout LyX-Code
2503
2504print_as_XML(FILE *ostream, Rectangle_t *rect) {
2505\layout LyX-Code
2506
2507 asn_enc_rval_t er; /* Encoder return value */
2508\layout LyX-Code
2509
2510
2511\layout LyX-Code
2512
vlmba56d852004-09-29 13:29:17 +00002513 er = xer_encode(&asn_DEF_Rect, rect,
vlm68d43e92004-09-24 20:56:07 +00002514\layout LyX-Code
2515
2516 XER_F_BASIC, /* BASIC-XER or CANONICAL-XER */
2517\layout LyX-Code
2518
2519 write_stream, ostream);
2520\layout LyX-Code
2521
2522
2523\layout LyX-Code
2524
2525 return (er.encoded == -1) ? -1 : 0;
2526\layout LyX-Code
2527
2528}
2529\layout Standard
2530
2531Please look into xer_encoder.h for the precise definition of xer_encode()
2532 and related types.
2533\layout Standard
2534
2535See Section
2536\begin_inset LatexCommand \ref{sub:Printing-the-target}
2537
2538\end_inset
2539
2540 for the example of stdio-based XML encoder and other pretty-printing suggestion
2541s.
2542\layout Subsection
2543
2544
vlme18adea2004-06-03 03:49:45 +00002545\begin_inset LatexCommand \label{sub:Validating-the-target}
2546
2547\end_inset
2548
2549Validating the target structure
2550\layout Standard
2551
2552Sometimes the target structure needs to be validated.
2553 For example, if the structure was created by the application (as opposed
2554 to being decoded from some external source), some important information
2555 required by the ASN.1 specification might be missing.
2556 On the other hand, the successful decoding of the data from some external
2557 source does not necessarily mean that the data is fully valid either.
2558 It might well be the case that the specification describes some subtype
2559 constraints that were not taken into account during decoding, and it would
2560 actually be useful to perform the last check when the data is ready to
2561 be encoded or when the data has just been decoded to ensure its validity
2562 according to some stricter rules.
2563\layout Standard
2564
2565The asn_check_constraints() function checks the type for various implicit
2566 and explicit constraints.
2567 It is recommended to use asn_check_constraints() function after each decoding
2568 and before each encoding.
2569\layout Standard
2570
2571Please look into constraints.h for the precise definition of asn_check_constraint
2572s() and related types.
vlmfcec8e52004-08-23 15:12:04 +00002573\layout Subsection
vlme18adea2004-06-03 03:49:45 +00002574
2575
2576\begin_inset LatexCommand \label{sub:Printing-the-target}
2577
2578\end_inset
2579
2580Printing the target structure
2581\layout Standard
2582
2583There are two ways to print the target structure: either invoke the print_struct
2584 member of the ASN.1 type descriptor, or using the asn_fprint() function,
2585 which is a simpler wrapper of the former:
2586\layout LyX-Code
2587
vlmba56d852004-09-29 13:29:17 +00002588asn_fprint(stdout, &asn_DEF_Rectangle, rect);
vlme18adea2004-06-03 03:49:45 +00002589\layout Standard
2590
2591Please look into constr_TYPE.h for the precise definition of asn_fprint()
2592 and related types.
vlm68d43e92004-09-24 20:56:07 +00002593\layout Standard
2594
2595Another practical alternative to this custom format printing would be to
2596 invoke XER encoder.
2597 The default BASIC-XER encoder performs reasonable formatting for the output
2598 to be useful and human readable.
2599 To invoke the XER decoder in a manner similar to asn_fprint(), use the
2600 xer_fprint() call:
2601\layout LyX-Code
2602
vlmba56d852004-09-29 13:29:17 +00002603xer_fprint(stdout, &asn_DEF_Rectangle, rect);
vlm68d43e92004-09-24 20:56:07 +00002604\layout Standard
2605
2606See Section
2607\begin_inset LatexCommand \vref{sub:Encoding-XER}
2608
2609\end_inset
2610
2611 for XML-related details.
vlmfcec8e52004-08-23 15:12:04 +00002612\layout Subsection
vlme18adea2004-06-03 03:49:45 +00002613
2614
2615\begin_inset LatexCommand \label{sub:Freeing-the-target}
2616
2617\end_inset
2618
2619Freeing the target structure
2620\layout Standard
2621
2622Freeing the structure is slightly more complex than it may seem to.
2623 When the ASN.1 structure is freed, all the members of the structure and
2624 their submembers etc etc are recursively freed too.
2625 But it might not be feasible to free the structure itself.
2626 Consider the following case:
2627\layout LyX-Code
2628
2629struct my_figure { /* The custom structure */
2630\layout LyX-Code
2631
2632 int flags; /* <some custom member> */
2633\layout LyX-Code
2634
2635 /* The type is generated by the ASN.1 compiler */
2636\layout LyX-Code
2637
2638
2639\emph on
2640Rectangle_t rect;
2641\layout LyX-Code
2642
2643 /* other members of the structure */
2644\layout LyX-Code
2645
2646};
2647\layout Standard
2648
2649In this example, the application programmer defined a custom structure with
2650 one ASN.1-derived member (rect).
2651 This member is not a reference to the Rectangle_t, but an in-place inclusion
2652 of the Rectangle_t structure.
2653 If the freeing is necessary, the usual procedure of freeing everything
2654 must not be applied to the &rect pointer itself, because it does not point
2655 to the memory block directly allocated by memory allocation routine, but
2656 instead lies within such a block allocated for my_figure structure.
2657\layout Standard
2658
2659To solve this problem, the free_struct routine has the additional argument
2660 (besides the intuitive type descriptor and target structure pointers),
2661 which is the flag specifying whether the outer pointer itself must be freed
2662 (0, default) or it should be left intact (non-zero value).
2663\layout LyX-Code
2664
2665/* Rectangle_t is defined within my_figure */
2666\layout LyX-Code
2667
2668struct my_figure *mf =
2669\series bold
2670...
2671\series default
2672;
2673\layout LyX-Code
2674
2675/*
2676\layout LyX-Code
2677
2678 * Freeing the Rectangle_td
2679\layout LyX-Code
2680
2681 * without freeing the mf->rect pointer
2682\layout LyX-Code
2683
2684 */
2685\layout LyX-Code
2686
vlmba56d852004-09-29 13:29:17 +00002687asn_DEF_Rectangle->free_struct(
vlme18adea2004-06-03 03:49:45 +00002688\layout LyX-Code
2689
vlmba56d852004-09-29 13:29:17 +00002690 &asn_DEF_Rectangle, &mf->rect,
vlme18adea2004-06-03 03:49:45 +00002691\emph on
26921
2693\emph default
2694 /* !free */);
2695\layout LyX-Code
2696
2697
2698\layout LyX-Code
2699
2700/* Rectangle_t is a stand-alone pointer */
2701\layout LyX-Code
2702
2703Rectangle_t *rect =
2704\series bold
2705...
2706\series default
2707;
2708\layout LyX-Code
2709
2710/*
2711\layout LyX-Code
2712
2713 * Freeing the Rectangle_t
2714\layout LyX-Code
2715
2716 * and freeing the rect pointer
2717\layout LyX-Code
2718
2719 */
2720\layout LyX-Code
2721
vlmba56d852004-09-29 13:29:17 +00002722asn_DEF_Rectangle->free_struct(
vlme18adea2004-06-03 03:49:45 +00002723\layout LyX-Code
2724
vlmba56d852004-09-29 13:29:17 +00002725 &asn_DEF_Rectangle, rect,
vlme18adea2004-06-03 03:49:45 +00002726\emph on
27270
2728\emph default
2729 /* free the pointer too */);
2730\layout Standard
2731
2732It is safe to invoke the
2733\emph on
2734free_struct
2735\emph default
2736 function with the target structure pointer set to 0 (NULL), the function
2737 will do nothing.
vlm4cb0edf2005-01-14 11:38:49 +00002738\layout Part
2739
2740Examples
vlma1fd7f92005-01-31 10:10:04 +00002741\layout Chapter
vlm4cb0edf2005-01-14 11:38:49 +00002742
vlma1fd7f92005-01-31 10:10:04 +00002743Step by step examples
2744\layout Section
2745
2746A
2747\begin_inset Quotes sld
2748\end_inset
2749
2750Rectangle
2751\begin_inset Quotes srd
2752\end_inset
2753
2754 Encoder
2755\layout Standard
2756
2757This chapter will help you to create a simple BER and XER encoder of a
2758\begin_inset Quotes sld
2759\end_inset
2760
2761Rectangle
2762\begin_inset Quotes srd
2763\end_inset
2764
2765 type used throughout this document.
2766\layout Enumerate
2767
2768Create a file named
2769\series bold
2770rectangle.asn1
2771\series default
2772 with the following contents:
2773\begin_deeper
2774\layout LyX-Code
2775
2776RectangleModule1 DEFINITIONS ::=
2777\layout LyX-Code
2778
2779BEGIN
2780\layout LyX-Code
2781
2782
2783\layout LyX-Code
2784
2785Rectangle ::= SEQUENCE {
2786\layout LyX-Code
2787
2788 height INTEGER,
2789\layout LyX-Code
2790
2791 width INTEGER
2792\layout LyX-Code
2793
2794}
2795\layout LyX-Code
2796
2797
2798\layout LyX-Code
2799
2800END
2801\end_deeper
2802\layout Enumerate
2803
2804Compile it into the set of .c and .h files using asn1c compiler
2805\begin_inset LatexCommand \cite{ASN1C}
2806
2807\end_inset
2808
2809:
2810\begin_deeper
2811\layout LyX-Code
2812
2813
2814\emph on
2815asn1c -fnative-types
2816\series bold
2817\emph default
2818rectangle.asn1
2819\end_deeper
2820\layout Enumerate
2821
2822Alternatively, use the Online ASN.1 compiler
2823\begin_inset LatexCommand \cite{AONL}
2824
2825\end_inset
2826
2827 by uploading the
2828\series bold
2829rectangle.asn1
2830\series default
2831 file into the Web form and unpacking the produced archive on your computer.
2832\layout Enumerate
2833
2834By this time, you should have gotten multiple files in the current directory,
2835 including the
2836\series bold
2837Rectangle.c
2838\series default
2839 and
2840\series bold
2841Rectangle.h
2842\series default
2843.
2844\layout Enumerate
2845
2846Create a main() routine which creates the Rectangle_t structure in memory
2847 and encodes it using BER and XER encoding rules.
2848 Let's name the file
2849\series bold
2850main.c
2851\series default
2852:
2853\begin_inset ERT
2854status Open
2855
2856\layout Standard
2857
2858\backslash
2859clearpage{}
2860\end_inset
2861
2862
2863\begin_deeper
2864\layout LyX-Code
2865
2866
2867\size small
2868#include <stdio.h>
2869\layout LyX-Code
2870
2871
2872\size small
2873#include <sys/types.h>
2874\layout LyX-Code
2875
2876
2877\size small
2878#include <Rectangle.h> /* Rectangle ASN.1 type */
2879\layout LyX-Code
2880
2881
2882\layout LyX-Code
2883
2884
2885\size small
2886/*
2887\layout LyX-Code
2888
2889
2890\size small
2891 * This is a custom function which writes the
2892\layout LyX-Code
2893
2894
2895\size small
2896 * encoded output into some FILE stream.
2897\layout LyX-Code
2898
2899
2900\size small
2901 */
2902\layout LyX-Code
2903
2904
2905\size small
2906static int
2907\layout LyX-Code
2908
2909
2910\size small
2911write_out(const void *buffer, size_t size, void *app_key) {
2912\layout LyX-Code
2913
2914
2915\size small
2916 FILE *out_fp = app_key;
2917\layout LyX-Code
2918
2919
2920\size small
2921 size_t wrote;
2922\layout LyX-Code
2923
2924
2925\size small
2926
2927\layout LyX-Code
2928
2929
2930\size small
2931 wrote = fwrite(buffer, 1, size, out_fp);
2932\layout LyX-Code
2933
2934
2935\size small
2936
2937\layout LyX-Code
2938
2939
2940\size small
2941 return (wrote == size) ? 0 : -1;
2942\layout LyX-Code
2943
2944
2945\size small
2946}
2947\layout LyX-Code
2948
2949
2950\layout LyX-Code
2951
2952
2953\size small
2954int main(int ac, char *av) {
2955\layout LyX-Code
2956
2957
2958\size small
2959 Rectangle_t *rectangle; /* Type to encode */
2960\layout LyX-Code
2961
2962
2963\size small
2964 asn_enc_rval_t ec; /* Encoder return value */
2965\layout LyX-Code
2966
2967
2968\size small
2969
2970\layout LyX-Code
2971
2972
2973\size small
2974 /* Allocate the Rectangle_t */
2975\layout LyX-Code
2976
2977
2978\size small
2979 rectangle = calloc(1, sizeof(Rectangle_t); /* not malloc! */
2980\layout LyX-Code
2981
2982
2983\size small
2984 if(!rectangle) {
2985\layout LyX-Code
2986
2987
2988\size small
2989 perror(
2990\begin_inset Quotes sld
2991\end_inset
2992
2993calloc() failed
2994\begin_inset Quotes srd
2995\end_inset
2996
2997);
2998\layout LyX-Code
2999
3000
3001\size small
3002 exit(71); /* better, EX_OSERR */
3003\layout LyX-Code
3004
3005
3006\size small
3007 }
3008\layout LyX-Code
3009
3010
3011\size small
3012
3013\layout LyX-Code
3014
3015
3016\size small
3017 /* Initialize the Rectangle members */
3018\layout LyX-Code
3019
3020
3021\size small
3022 rectangle->height = 42; /* any random value */
3023\layout LyX-Code
3024
3025
3026\size small
3027 rectangle->width = 23; /* any random value */
3028\layout LyX-Code
3029
3030
3031\size small
3032
3033\layout LyX-Code
3034
3035
3036\size small
3037 /* BER encode the data if filename is given */
3038\layout LyX-Code
3039
3040
3041\size small
3042 if(ac < 2) {
3043\layout LyX-Code
3044
3045
3046\size small
3047 fprintf(stderr,
3048\begin_inset Quotes sld
3049\end_inset
3050
3051Specify filename for BER output
3052\backslash
3053n
3054\begin_inset Quotes srd
3055\end_inset
3056
3057);
3058\layout LyX-Code
3059
3060
3061\size small
3062 } else {
3063\layout LyX-Code
3064
3065
3066\size small
3067 const char *filename = av[1];
3068\layout LyX-Code
3069
3070
3071\size small
3072 FILE *fp = fopen(filename,
3073\begin_inset Quotes sld
3074\end_inset
3075
3076w
3077\begin_inset Quotes srd
3078\end_inset
3079
3080); /* for BER output */
3081\layout LyX-Code
3082
3083
3084\layout LyX-Code
3085
3086
3087\size small
3088 if(!fp) {
3089\layout LyX-Code
3090
3091
3092\size small
3093 perror(filename);
3094\layout LyX-Code
3095
3096
3097\size small
3098 exit(71); /* better, EX_OSERR */
3099\layout LyX-Code
3100
3101
3102\size small
3103 }
3104\layout LyX-Code
3105
3106
3107\size small
3108
3109\layout LyX-Code
3110
3111
3112\size small
3113 /* Encode the Rectangle type as BER (DER) */
3114\layout LyX-Code
3115
3116
3117\size small
3118 ec = der_encode(&asn_DEF_Rectangle,
3119\layout LyX-Code
3120
3121
3122\size small
3123 rectangle, write_out, stream);
3124\layout LyX-Code
3125
3126
3127\size small
3128 fclose(fp);
3129\layout LyX-Code
3130
3131
3132\size small
3133 if(ec.encoded == -1) {
3134\layout LyX-Code
3135
3136
3137\size small
3138 fprintf(stderr,
3139\layout LyX-Code
3140
3141
3142\size small
3143
3144\begin_inset Quotes sld
3145\end_inset
3146
3147Could not encode Rectangle (at %s)
3148\backslash
3149n
3150\begin_inset Quotes srd
3151\end_inset
3152
3153,
3154\layout LyX-Code
3155
3156
3157\size small
3158 ec.failed_type ? ec.failed_type->name :
3159\begin_inset Quotes sld
3160\end_inset
3161
3162unknown
3163\begin_inset Quotes srd
3164\end_inset
3165
3166);
3167\layout LyX-Code
3168
3169
3170\size small
3171 exit(65); /* better, EX_DATAERR */
3172\layout LyX-Code
3173
3174
3175\size small
3176 } else {
3177\layout LyX-Code
3178
3179
3180\size small
3181 fprintf(stderr,
3182\begin_inset Quotes sld
3183\end_inset
3184
3185Created %s with BER encoded Rectangle
3186\backslash
3187n
3188\begin_inset Quotes srd
3189\end_inset
3190
3191,
3192\layout LyX-Code
3193
3194
3195\size small
3196 filename);
3197\layout LyX-Code
3198
3199
3200\size small
3201 }
3202\layout LyX-Code
3203
3204
3205\size small
3206 }
3207\layout LyX-Code
3208
3209
3210\size small
3211
3212\layout LyX-Code
3213
3214
3215\size small
3216 /* Also print the constructed Rectangle XER encoded (XML) */
3217\layout LyX-Code
3218
3219
3220\size small
3221 xer_fprint(stdout, &asn_DEF_Rectangle, rectangle);
3222\layout LyX-Code
3223
3224
3225\size small
3226
3227\layout LyX-Code
3228
3229
3230\size small
3231 return 0; /* Encoding finished successfully */
3232\layout LyX-Code
3233
3234
3235\size small
3236}
3237\end_deeper
3238\layout Enumerate
3239
3240Compile all files together using C compiler (varies by platform):
3241\begin_deeper
3242\layout LyX-Code
3243
3244
3245\emph on
3246cc -I.
3247 -o
3248\series bold
3249rencode
3250\series default
3251 *.c
3252\end_deeper
3253\layout Enumerate
3254
3255Voila! You have just created the BER and XER encoder of a Rectangle type,
3256 named
3257\series bold
3258rencode
3259\series default
3260!
3261\layout Standard
3262
3263
3264\begin_inset ERT
3265status Collapsed
3266
3267\layout Standard
3268
3269\backslash
3270clearpage{}
3271\end_inset
3272
3273
3274\layout Section
3275
3276A
vlm4cb0edf2005-01-14 11:38:49 +00003277\begin_inset Quotes sld
3278\end_inset
3279
3280Rectangle
3281\begin_inset Quotes srd
3282\end_inset
3283
3284 Decoder
3285\layout Standard
3286
vlma1fd7f92005-01-31 10:10:04 +00003287This chapter will help you to create a simple BER decoder of a simple
vlm4cb0edf2005-01-14 11:38:49 +00003288\begin_inset Quotes sld
3289\end_inset
3290
3291Rectangle
3292\begin_inset Quotes srd
3293\end_inset
3294
3295 type used throughout this document.
3296\layout Enumerate
3297
3298Create a file named
3299\series bold
3300rectangle.asn1
3301\series default
3302 with the following contents:
3303\begin_deeper
3304\layout LyX-Code
3305
3306RectangleModule1 DEFINITIONS ::=
3307\layout LyX-Code
3308
3309BEGIN
3310\layout LyX-Code
3311
3312
3313\layout LyX-Code
3314
3315Rectangle ::= SEQUENCE {
3316\layout LyX-Code
3317
3318 height INTEGER,
3319\layout LyX-Code
3320
3321 width INTEGER
3322\layout LyX-Code
3323
3324}
3325\layout LyX-Code
3326
3327
3328\layout LyX-Code
3329
3330END
3331\end_deeper
3332\layout Enumerate
3333
3334Compile it into the set of .c and .h files using asn1c compiler
3335\begin_inset LatexCommand \cite{ASN1C}
3336
3337\end_inset
3338
3339:
3340\begin_deeper
3341\layout LyX-Code
3342
3343
3344\emph on
3345asn1c -fnative-types
3346\series bold
3347\emph default
3348rectangle.asn1
3349\end_deeper
3350\layout Enumerate
3351
3352Alternatively, use the Online ASN.1 compiler
3353\begin_inset LatexCommand \cite{AONL}
3354
3355\end_inset
3356
3357 by uploading the
3358\series bold
3359rectangle.asn1
3360\series default
vlmabd51e22005-01-17 11:05:04 +00003361 file into the Web form and unpacking the produced archive on your computer.
vlm4cb0edf2005-01-14 11:38:49 +00003362\layout Enumerate
3363
vlmabd51e22005-01-17 11:05:04 +00003364By this time, you should have gotten multiple files in the current directory,
3365 including the
3366\series bold
3367Rectangle.c
3368\series default
3369 and
3370\series bold
3371Rectangle.h
3372\series default
3373.
vlm4cb0edf2005-01-14 11:38:49 +00003374\layout Enumerate
3375
3376Create a main() routine which takes the binary input file, decodes it as
vlmabd51e22005-01-17 11:05:04 +00003377 it were a BER-encoded Rectangle type, and prints out the text (XML) representat
3378ion of the Rectangle type.
vlm4cb0edf2005-01-14 11:38:49 +00003379 Let's name the file
3380\series bold
3381main.c
3382\series default
3383:
vlmabd51e22005-01-17 11:05:04 +00003384\begin_inset ERT
3385status Open
3386
3387\layout Standard
3388
3389\backslash
3390clearpage{}
3391\end_inset
3392
3393
vlm4cb0edf2005-01-14 11:38:49 +00003394\begin_deeper
3395\layout LyX-Code
3396
3397
3398\size small
3399#include <stdio.h>
3400\layout LyX-Code
3401
3402
3403\size small
3404#include <sys/types.h>
3405\layout LyX-Code
3406
3407
3408\size small
3409#include <Rectangle.h> /* Rectangle ASN.1 type */
3410\layout LyX-Code
3411
3412
3413\size small
3414
3415\layout LyX-Code
3416
3417
3418\size small
3419int main(int ac, char **av) {
3420\layout LyX-Code
3421
3422
3423\size small
3424 char buf[1024]; /* Temporary buffer */
3425\layout LyX-Code
3426
3427
3428\size small
3429 Rectangle_t *rectangle = 0; /* Type to decode */
3430\layout LyX-Code
3431
3432
3433\size small
3434 asn_dec_rval_t rval; /* Decoder return value */
3435\layout LyX-Code
3436
3437
3438\size small
3439 FILE *fp; /* Input file handler */
3440\layout LyX-Code
3441
3442
3443\size small
3444 size_t size; /* Number of bytes read */
3445\layout LyX-Code
3446
3447
3448\size small
3449 char *filename; /* Input file name */
3450\layout LyX-Code
3451
3452
3453\size small
3454
3455\layout LyX-Code
3456
3457
3458\size small
3459 /* Require a single filename argument */
3460\layout LyX-Code
3461
3462
3463\size small
3464 if(ac != 2) {
3465\layout LyX-Code
3466
3467
3468\size small
3469 fprintf(stderr,
3470\begin_inset Quotes sld
3471\end_inset
3472
3473Usage: %s <file.ber>
3474\backslash
3475n
3476\begin_inset Quotes srd
3477\end_inset
3478
3479, av[0]);
3480\layout LyX-Code
3481
3482
3483\size small
3484 exit(64); /* better, EX_USAGE */
3485\layout LyX-Code
3486
3487
3488\size small
3489 } else {
3490\layout LyX-Code
3491
3492
3493\size small
3494 filename = av[1];
3495\layout LyX-Code
3496
3497
3498\size small
3499 }
3500\layout LyX-Code
3501
3502
3503\size small
3504
3505\layout LyX-Code
3506
3507
3508\size small
3509 /* Open input file as read-only binary */
3510\layout LyX-Code
3511
3512
3513\size small
3514 fp = fopen(filename,
3515\begin_inset Quotes sld
3516\end_inset
3517
3518rb
3519\begin_inset Quotes srd
3520\end_inset
3521
3522);
3523\layout LyX-Code
3524
3525
3526\size small
3527 if(!fp) {
3528\layout LyX-Code
3529
3530
3531\size small
3532 perror(filename);
3533\layout LyX-Code
3534
3535
3536\size small
3537 exit(66); /* better, EX_NOINPUT */
3538\layout LyX-Code
3539
3540
3541\size small
3542 }
3543\layout LyX-Code
3544
3545
3546\size small
3547
3548\layout LyX-Code
3549
3550
3551\size small
3552 /* Read up to the buffer size */
3553\layout LyX-Code
3554
3555
3556\size small
3557 size = fread(buf, 1, sizeof(buf), fp);
3558\layout LyX-Code
3559
3560
3561\size small
3562 fclose(fp);
3563\layout LyX-Code
3564
3565
3566\size small
3567 if(!size) {
3568\layout LyX-Code
3569
3570
3571\size small
3572 fprintf(stderr,
3573\begin_inset Quotes sld
3574\end_inset
3575
3576%s: Empty or broken
3577\backslash
3578n
3579\begin_inset Quotes srd
3580\end_inset
3581
3582, filename);
3583\layout LyX-Code
3584
3585
3586\size small
3587 exit(65); /* better, EX_DATAERR */
3588\layout LyX-Code
3589
3590
3591\size small
3592 }
3593\layout LyX-Code
3594
3595
3596\size small
3597
3598\layout LyX-Code
3599
3600
3601\size small
3602 /* Decode the input buffer as Rectangle type */
3603\layout LyX-Code
3604
3605
3606\size small
3607 rval = ber_decode(0, &asn_DEF_Rectangle,
3608\layout LyX-Code
3609
3610
3611\size small
3612 (void **)&rectangle, buf, size);
3613\layout LyX-Code
3614
3615
3616\size small
3617 if(rval.code != RC_OK) {
3618\layout LyX-Code
3619
3620
3621\size small
3622 fprintf(stderr,
3623\layout LyX-Code
3624
3625
3626\size small
3627
3628\begin_inset Quotes sld
3629\end_inset
3630
3631%s: Broken Rectangle encoding at byte %ld
3632\backslash
3633n
3634\begin_inset Quotes srd
3635\end_inset
3636
3637,
3638\layout LyX-Code
3639
3640
3641\size small
3642 filename, (long)rval.consumed);
3643\layout LyX-Code
3644
3645
3646\size small
3647 exit(65); /* better, EX_DATAERR */
3648\layout LyX-Code
3649
3650
3651\size small
3652 }
3653\layout LyX-Code
3654
3655
3656\size small
3657
3658\layout LyX-Code
3659
3660
3661\size small
3662 /* Print the decoded Rectangle type as XML */
3663\layout LyX-Code
3664
3665
3666\size small
3667 xer_fprint(stdout, &asn_DEF_Rectangle, rectangle);
3668\layout LyX-Code
3669
3670
3671\size small
3672
3673\layout LyX-Code
3674
3675
3676\size small
3677 return 0; /* Decoding finished successfully */
3678\layout LyX-Code
3679
3680
3681\size small
3682}
3683\end_deeper
3684\layout Enumerate
3685
vlmabd51e22005-01-17 11:05:04 +00003686Compile all files together using C compiler (varies by platform):
vlm4cb0edf2005-01-14 11:38:49 +00003687\begin_deeper
3688\layout LyX-Code
3689
3690
3691\emph on
3692cc -I.
vlmabd51e22005-01-17 11:05:04 +00003693 -o
3694\series bold
3695rdecode
3696\series default
3697 *.c
vlm4cb0edf2005-01-14 11:38:49 +00003698\end_deeper
3699\layout Enumerate
3700
vlma1fd7f92005-01-31 10:10:04 +00003701Voila! You have just created the BER decoder of a Rectangle type, named
3702
vlm4cb0edf2005-01-14 11:38:49 +00003703\series bold
3704rdecode
3705\series default
3706!
vlme18adea2004-06-03 03:49:45 +00003707\layout Bibliography
vlmfcec8e52004-08-23 15:12:04 +00003708\bibitem [ASN1C]{ASN1C}
3709
vlm89d219b2004-09-08 03:01:06 +00003710The OpenSource ASN.1 Compiler.
vlmfcec8e52004-08-23 15:12:04 +00003711
vlmc3bfd812004-09-30 22:26:19 +00003712\begin_inset LatexCommand \htmlurl{http://lionet.info/asn1c/}
vlmfcec8e52004-08-23 15:12:04 +00003713
3714\end_inset
3715
3716
3717\layout Bibliography
vlm4cb0edf2005-01-14 11:38:49 +00003718\bibitem [AONL]{AONL}
3719
3720Online ASN.1 Compiler.
3721
3722\begin_inset LatexCommand \htmlurl{http://lionet.info/asn1c/asn1c.cgi}
3723
3724\end_inset
3725
3726
3727\layout Bibliography
vlme18adea2004-06-03 03:49:45 +00003728\bibitem [Dub00]{Dub00}
3729
vlmaf2155e2004-10-20 15:48:55 +00003730Olivier Dubuisson ---
vlme18adea2004-06-03 03:49:45 +00003731\emph on
3732ASN.1 Communication between heterogeneous systems
3733\emph default
vlmaf2155e2004-10-20 15:48:55 +00003734 --- Morgan Kaufmann Publishers, 2000.
vlme18adea2004-06-03 03:49:45 +00003735
3736\begin_inset LatexCommand \htmlurl{http://asn1.elibel.tm.fr/en/book/}
3737
3738\end_inset
3739
3740.
3741 ISBN:0-12-6333361-0.
3742\layout Bibliography
3743\bibitem [ITU-T/ASN.1]{ITU-T/ASN.1}
3744
3745ITU-T Study Group 17 -- Languages for Telecommunication Systems
3746\begin_inset LatexCommand \url{http://www.itu.int/ITU-T/studygroups/com17/languages/}
3747
3748\end_inset
3749
3750
3751\the_end