blob: b146744183dc6efaee0cd9d3d19640d1dda15284 [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
5%\fancyhf{}
6%\renewcommand{\chaptermark}[1]{\markboth{\thechapter.\ #1\ sdf}{}}
7%\renewcommand{\sectionmark}[1]{\markright{\MakeUppercase{\thesection.\ #1}}}
8%\fancyhead[LE,RO]{\thepage}
9%\fancyhead[LO]{\rightmark}
10%\fancyhead[RE]]{\leftmark}
11\usepackage{extramarks}
12\lhead{\firstxmark}
13\rfoot{\lastxmark}
14\end_preamble
vlme18adea2004-06-03 03:49:45 +000015\language english
16\inputencoding latin1
vlmfcec8e52004-08-23 15:12:04 +000017\fontscheme times
vlme18adea2004-06-03 03:49:45 +000018\graphics default
19\paperfontsize default
20\spacing single
21\papersize Default
22\paperpackage a4
23\use_geometry 0
24\use_amsmath 0
25\use_natbib 0
26\use_numerical_citations 0
27\paperorientation portrait
28\secnumdepth 3
29\tocdepth 3
30\paragraph_separation indent
31\defskip medskip
32\quotes_language swedish
33\quotes_times 2
34\papercolumns 1
vlmfcec8e52004-08-23 15:12:04 +000035\papersides 2
36\paperpagestyle fancy
vlme18adea2004-06-03 03:49:45 +000037
38\layout Title
39
vlm89d219b2004-09-08 03:01:06 +000040Using the Open ASN.1 Compiler
vlme18adea2004-06-03 03:49:45 +000041\layout Author
42
43Lev Walkin <
44\begin_inset LatexCommand \url{vlm@lionet.info}
45
46\end_inset
47
48>
49\layout Standard
50
51
vlmfcec8e52004-08-23 15:12:04 +000052\begin_inset ERT
53status Open
54
55\layout Standard
56
57\backslash
vlm68d43e92004-09-24 20:56:07 +000058extramarks{$Revision$ -- describes asn1c-0.9.6}{}
vlmfcec8e52004-08-23 15:12:04 +000059\end_inset
60
61
62\layout Standard
63
64
vlme18adea2004-06-03 03:49:45 +000065\begin_inset LatexCommand \tableofcontents{}
66
67\end_inset
68
69
vlmfcec8e52004-08-23 15:12:04 +000070\layout Standard
71
72
73\begin_inset ERT
74status Collapsed
75
76\layout Standard
77
78\backslash
79pagestyle{headings}
80\end_inset
81
82
vlmcaba97b2004-08-07 05:00:07 +000083\layout Part
84
85ASN.1 Basics
vlme18adea2004-06-03 03:49:45 +000086\layout Chapter
87
vlmcaba97b2004-08-07 05:00:07 +000088Abstract Syntax Notation: ASN.1
vlme18adea2004-06-03 03:49:45 +000089\layout Standard
90
91
92\emph on
93This chapter defines some basic ASN.1 concepts and describes several most
94 widely used types.
95 It is by no means an authoritative or complete reference.
96 For more complete ASN.1 description, please refer to Olivier Dubuisson's
97 book
98\begin_inset LatexCommand \cite{Dub00}
99
100\end_inset
101
vlmcaba97b2004-08-07 05:00:07 +0000102 or the ASN.1 body of standards itself
vlme18adea2004-06-03 03:49:45 +0000103\begin_inset LatexCommand \cite{ITU-T/ASN.1}
104
105\end_inset
106
107.
108\layout Standard
109
110The Abstract Syntax Notation One is used to formally describe the semantics
111 of data transmitted across the network.
112 Two communicating parties may have different formats of their native data
113 types (i.e.
114 number of bits in the integer type), thus it is important to have a way
115 to describe the data in a manner which is independent from the particular
116 machine's representation.
117 The ASN.1 specifications is used to achieve one or more of the following:
118\layout Itemize
119
120The specification expressed in the ASN.1 notation is a formal and precise
121 way to communicate the data semantics to human readers;
122\layout Itemize
123
124The ASN.1 specifications may be used as input for automatic compilers which
125 produce the code for some target language (C, C++, Java, etc) to encode
126 and decode the data according to some encoding rules (which are also defined
127 by the ASN.1 standard).
128\layout Standard
129
130Consider the following example:
131\layout LyX-Code
132
133Rectangle ::= SEQUENCE {
134\layout LyX-Code
135
136 height INTEGER,
137\layout LyX-Code
138
139 width INTEGER
140\layout LyX-Code
141
142}
143\layout Standard
144
145This ASN.1 specification describes a constructed type,
146\emph on
147Rectangle
148\emph default
149, containing two integer fields.
150 This specification may tell the reader that there is this kind of data
151 structure and that some entity may be prepared to send or receive it.
152 The question on
153\emph on
154how
155\emph default
156 that entity is going to send or receive the
157\emph on
158encoded data
159\emph default
160 is outside the scope of ASN.1.
161 For example, this data structure may be encoded according to some encoding
162 rules and sent to the destination using the TCP protocol.
163 The ASN.1 specifies several ways of encoding (or
164\begin_inset Quotes sld
165\end_inset
166
167serializing
168\begin_inset Quotes srd
169\end_inset
170
171, or
172\begin_inset Quotes sld
173\end_inset
174
175marshaling
176\begin_inset Quotes srd
177\end_inset
178
179) the data: BER, CER, DER and XER, some of them which will be described
180 later.
181\layout Standard
182
183The complete specification must be wrapped in a module, which looks like
184 this:
185\layout LyX-Code
186
187UsageExampleModule1
188\layout LyX-Code
189
190 { iso org(3) dod(6) internet(1) private(4)
191\layout LyX-Code
192
193 enterprise(1) spelio(9363) software(1)
194\layout LyX-Code
195
196 asn1c(5) docs(2) usage(1) 1 }
197\layout LyX-Code
198
vlmfcec8e52004-08-23 15:12:04 +0000199 DEFINITIONS AUTOMATIC TAGS ::=
vlme18adea2004-06-03 03:49:45 +0000200\layout LyX-Code
201
202BEGIN
203\layout LyX-Code
204
205
206\layout LyX-Code
207
208-- This is a comment which describes nothing.
209\layout LyX-Code
210
211Rectangle ::= SEQUENCE {
212\layout LyX-Code
213
214 height INTEGER, -- Height of the rectangle
215\layout LyX-Code
216
vlmfcec8e52004-08-23 15:12:04 +0000217 width INTEGER -- Width of the rectangle
vlme18adea2004-06-03 03:49:45 +0000218\layout LyX-Code
219
220}
221\layout LyX-Code
222
223
224\layout LyX-Code
225
226END
227\layout Standard
228
229The module header consists of module name (UsageExampleModule1), the module
vlmfcec8e52004-08-23 15:12:04 +0000230 object identifier ({...}), a keyword
vlme18adea2004-06-03 03:49:45 +0000231\begin_inset Quotes sld
232\end_inset
233
vlmfcec8e52004-08-23 15:12:04 +0000234DEFINITIONS
235\begin_inset Quotes srd
236\end_inset
237
238, a set of module flags (AUTOMATIC TAGS) and
239\begin_inset Quotes sld
240\end_inset
241
242::= BEGIN
vlme18adea2004-06-03 03:49:45 +0000243\begin_inset Quotes srd
244\end_inset
245
246.
247 The module ends with an
248\begin_inset Quotes sld
249\end_inset
250
251END
252\begin_inset Quotes srd
253\end_inset
254
255 statement.
256\layout Section
257
258Some of the ASN.1 Basic Types
259\layout Subsection
260
261The BOOLEAN type
262\layout Standard
263
264The BOOLEAN type models the simple binary TRUE/FALSE, YES/NO, ON/OFF or
265 a similar kind of two-way choice.
266\layout Subsection
267
268The INTEGER type
269\layout Standard
270
271The INTEGER type is a signed natural number type without any restrictions
272 on its size.
273 If the automatic checking on INTEGER value bounds are necessary, the subtype
274 constraints must be used.
275\layout LyX-Code
276
277SimpleInteger ::= INTEGER
278\layout LyX-Code
279
vlmfcec8e52004-08-23 15:12:04 +0000280
281\layout LyX-Code
282
vlme18adea2004-06-03 03:49:45 +0000283-- An integer with a very limited range
284\layout LyX-Code
285
286SmallInt ::= INTEGER (0..127)
287\layout LyX-Code
288
vlmfcec8e52004-08-23 15:12:04 +0000289
290\layout LyX-Code
291
vlme18adea2004-06-03 03:49:45 +0000292-- Integer, negative
293\layout LyX-Code
294
295NegativeInt ::= INTEGER (MIN..0)
296\layout Subsection
297
298The ENUMERATED type
299\layout Standard
300
301The ENUMERATED type is semantically equivalent to the INTEGER type with
302 some integer values explicitly named.
303\layout LyX-Code
304
305FruitId ::= ENUMERATED { apple(1), orange(2) }
306\layout LyX-Code
307
vlmfcec8e52004-08-23 15:12:04 +0000308
309\layout LyX-Code
310
vlme18adea2004-06-03 03:49:45 +0000311-- The numbers in braces are optional,
312\layout LyX-Code
313
vlmfcec8e52004-08-23 15:12:04 +0000314-- the enumeration can be performed
vlme18adea2004-06-03 03:49:45 +0000315\layout LyX-Code
316
317-- automatically by the compiler
318\layout LyX-Code
319
320ComputerOSType ::= ENUMERATED {
321\layout LyX-Code
322
323 FreeBSD, -- will be 0
324\layout LyX-Code
325
326 Windows, -- will be 1
327\layout LyX-Code
328
329 Solaris(5), -- will remain 5
330\layout LyX-Code
331
332 Linux, -- will be 6
333\layout LyX-Code
334
335 MacOS -- will be 7
336\layout LyX-Code
337
338}
339\layout Subsection
340
341The OCTET STRING type
342\layout Standard
343
344This type models the sequence of 8-bit bytes.
345 This may be used to transmit some opaque data or data serialized by other
346 types of encoders (i.e.
347 video file, photo picture, etc).
348\layout Subsection
349
350The OBJECT IDENTIFIER type
351\layout Standard
352
353The OBJECT IDENTIFIER is used to represent the unique identifier of any
354 object, starting from the very root of the registration tree.
355 If your organization needs to uniquely identify something (a router, a
356 room, a person, a standard, or whatever), you are encouraged to get your
357 own identification subtree at
358\begin_inset LatexCommand \htmlurl{http://www.iana.org/protocols/forms.htm}
359
360\end_inset
361
362.
363\layout Standard
364
365For example, the very first ASN.1 module in this document has the following
366 OBJECT IDENTIFIER: 1 3 6 1 4 1 9363 1 5 2 1 1.
367\layout LyX-Code
368
369ExampleOID ::= OBJECT IDENTIFIER
370\layout LyX-Code
371
vlmfcec8e52004-08-23 15:12:04 +0000372
373\layout LyX-Code
374
vlme18adea2004-06-03 03:49:45 +0000375usageExampleModule1-oid ExampleOID
376\layout LyX-Code
377
378 ::= { 1 3 6 1 4 1 9363 1 5 2 1 1 }
379\layout LyX-Code
380
vlmfcec8e52004-08-23 15:12:04 +0000381
382\layout LyX-Code
383
vlme18adea2004-06-03 03:49:45 +0000384-- An identifier of the Internet.
385\layout LyX-Code
386
387internet-id OBJECT IDENTIFIER
388\layout LyX-Code
389
390 ::= { iso(1) identified-organization(3)
391\layout LyX-Code
392
393 dod(6) internet(1) }
394\layout Standard
395
396As you see, names are optional.
397\layout Subsection
398
399The RELATIVE-OID type
400\layout Standard
401
402The RELATIVE-OID type has the semantics of a subtree of an OBJECT IDENTIFIER.
403 There may be no need to repeat the whole sequence of numbers from the root
404 of the registration tree where the only thing of interest is some of the
405 tree's subsequence.
406\layout LyX-Code
407
408this-document RELATIVE-OID ::= { docs(2) usage(1) }
409\layout LyX-Code
410
vlmfcec8e52004-08-23 15:12:04 +0000411
412\layout LyX-Code
413
vlme18adea2004-06-03 03:49:45 +0000414this-example RELATIVE-OID ::= {
415\layout LyX-Code
416
417 this-document assorted-examples(0) this-example(1) }
418\layout Section
419
420Some of the ASN.1 String Types
421\layout Subsection
422
423The IA5String type
424\layout Standard
425
426This is essentially the ASCII, with 128 character codes available (7 lower
vlmfcec8e52004-08-23 15:12:04 +0000427 bits of an 8-bit byte).
vlme18adea2004-06-03 03:49:45 +0000428\layout Subsection
429
430The UTF8String type
431\layout Standard
432
433This is the character string which encodes the full Unicode range (4 bytes)
434 using multibyte character sequences.
435\layout Subsection
436
437The NumericString type
438\layout Standard
439
440This type represents the character string with the alphabet consisting of
441 numbers (
442\begin_inset Quotes sld
443\end_inset
444
4450
446\begin_inset Quotes srd
447\end_inset
448
449 to
450\begin_inset Quotes sld
451\end_inset
452
4539
454\begin_inset Quotes srd
455\end_inset
456
457) and a space.
458\layout Subsection
459
460The PrintableString type
461\layout Standard
462
463The character string with the following alphabet: space,
464\begin_inset Quotes sld
465\end_inset
466
467
468\series bold
469'
470\series default
471
472\begin_inset Quotes srd
473\end_inset
474
475 (single quote),
476\begin_inset Quotes sld
477\end_inset
478
479
480\series bold
481(
482\series default
483
484\begin_inset Quotes sld
485\end_inset
486
487,
488\begin_inset Quotes sld
489\end_inset
490
491
492\series bold
493)
494\series default
495
496\begin_inset Quotes srd
497\end_inset
498
499,
500\begin_inset Quotes sld
501\end_inset
502
503
504\series bold
505+
506\series default
507
508\begin_inset Quotes srd
509\end_inset
510
511,
512\begin_inset Quotes sld
513\end_inset
514
515,
516\begin_inset Quotes srd
517\end_inset
518
519 (comma),
520\begin_inset Quotes sld
521\end_inset
522
523
524\series bold
525-
526\series default
527
528\begin_inset Quotes srd
529\end_inset
530
531,
532\begin_inset Quotes sld
533\end_inset
534
535
536\series bold
537.
538\series default
539
540\begin_inset Quotes srd
541\end_inset
542
543,
544\begin_inset Quotes sld
545\end_inset
546
547
548\series bold
549/
550\series default
551
552\begin_inset Quotes srd
553\end_inset
554
555, digits (
556\begin_inset Quotes sld
557\end_inset
558
5590
560\begin_inset Quotes srd
561\end_inset
562
563 to
564\begin_inset Quotes sld
565\end_inset
566
5679
568\begin_inset Quotes srd
569\end_inset
570
571),
572\begin_inset Quotes sld
573\end_inset
574
575
576\series bold
577:
578\series default
579
580\begin_inset Quotes srd
581\end_inset
582
583,
584\begin_inset Quotes sld
585\end_inset
586
587
588\series bold
589=
590\series default
591
592\begin_inset Quotes srd
593\end_inset
594
595,
596\begin_inset Quotes sld
597\end_inset
598
599
600\series bold
601?
602\series default
603
604\begin_inset Quotes srd
605\end_inset
606
607, upper-case and lower-case letters (
608\begin_inset Quotes sld
609\end_inset
610
611A
612\begin_inset Quotes srd
613\end_inset
614
615 to
616\begin_inset Quotes sld
617\end_inset
618
619Z
620\begin_inset Quotes srd
621\end_inset
622
623 and
624\begin_inset Quotes sld
625\end_inset
626
627a
628\begin_inset Quotes srd
629\end_inset
630
631 to
632\begin_inset Quotes sld
633\end_inset
634
635z
636\begin_inset Quotes srd
637\end_inset
638
639)
640\layout Subsection
641
642The VisibleString type
643\layout Standard
644
645The character string with the alphabet which is more or less a subset of
646 ASCII between space and
647\begin_inset Quotes sld
648\end_inset
649
vlmfcec8e52004-08-23 15:12:04 +0000650
651\series bold
vlme18adea2004-06-03 03:49:45 +0000652~
vlmfcec8e52004-08-23 15:12:04 +0000653\series default
654
vlme18adea2004-06-03 03:49:45 +0000655\begin_inset Quotes srd
656\end_inset
657
658 (tilde).
vlmfcec8e52004-08-23 15:12:04 +0000659 Alternatively, the alphabet may be described as the PrintableString alphabet
660 presented earlier, plus the following characters:
vlme18adea2004-06-03 03:49:45 +0000661\begin_inset Quotes sld
662\end_inset
663
664
665\series bold
666!
667\series default
668
669\begin_inset Quotes srd
670\end_inset
671
672,
673\begin_inset Quotes sld
674\end_inset
675
676
677\series bold
678
679\begin_inset Quotes srd
680\end_inset
681
682
683\series default
684
685\begin_inset Quotes srd
686\end_inset
687
688,
689\begin_inset Quotes sld
690\end_inset
691
692
693\series bold
694#
695\series default
696
697\begin_inset Quotes srd
698\end_inset
699
700,
701\begin_inset Quotes sld
702\end_inset
703
704
705\series bold
706$
707\series default
708
709\begin_inset Quotes srd
710\end_inset
711
712,
713\begin_inset Quotes sld
714\end_inset
715
716
717\series bold
718%
719\series default
720
721\begin_inset Quotes srd
722\end_inset
723
724,
725\begin_inset Quotes sld
726\end_inset
727
728
729\series bold
730&
731\series default
732
733\begin_inset Quotes srd
734\end_inset
735
736,
737\begin_inset Quotes sld
738\end_inset
739
740
741\series bold
742*
743\series default
744
745\begin_inset Quotes srd
746\end_inset
747
748,
749\begin_inset Quotes sld
750\end_inset
751
752
753\series bold
754;
755\series default
756
757\begin_inset Quotes srd
758\end_inset
759
760,
761\begin_inset Quotes sld
762\end_inset
763
764
765\series bold
766<
767\series default
768
769\begin_inset Quotes srd
770\end_inset
771
772,
773\begin_inset Quotes sld
774\end_inset
775
776
777\series bold
778>
779\series default
780
781\begin_inset Quotes srd
782\end_inset
783
784,
785\begin_inset Quotes sld
786\end_inset
787
788
789\series bold
790[
791\series default
792
793\begin_inset Quotes srd
794\end_inset
795
796,
797\begin_inset Quotes sld
798\end_inset
799
800
801\series bold
802
803\backslash
804
805\series default
806
807\begin_inset Quotes srd
808\end_inset
809
810,
811\begin_inset Quotes sld
812\end_inset
813
814
815\series bold
816]
817\series default
818
819\begin_inset Quotes srd
820\end_inset
821
822,
823\begin_inset Quotes sld
824\end_inset
825
826
827\series bold
828^
829\series default
830
831\begin_inset Quotes srd
832\end_inset
833
834,
835\begin_inset Quotes sld
836\end_inset
837
838
839\series bold
840_
841\series default
842
843\begin_inset Quotes srd
844\end_inset
845
846,
847\begin_inset Quotes sld
848\end_inset
849
850
851\series bold
852`
853\series default
854
855\begin_inset Quotes srd
856\end_inset
857
858 (single left quote),
859\begin_inset Quotes sld
860\end_inset
861
862
863\series bold
864{
865\series default
866
867\begin_inset Quotes srd
868\end_inset
869
870,
871\begin_inset Quotes sld
872\end_inset
873
874
875\series bold
876|
877\series default
878
879\begin_inset Quotes srd
880\end_inset
881
882,
883\begin_inset Quotes sld
884\end_inset
885
886
887\series bold
888}
889\series default
890
891\begin_inset Quotes srd
892\end_inset
893
894,
895\begin_inset Quotes sld
896\end_inset
897
vlmfcec8e52004-08-23 15:12:04 +0000898
899\series bold
vlme18adea2004-06-03 03:49:45 +0000900~
vlmfcec8e52004-08-23 15:12:04 +0000901\series default
902
vlme18adea2004-06-03 03:49:45 +0000903\begin_inset Quotes srd
904\end_inset
905
906.
907\layout Section
908
909ASN.1 Constructed Types
910\layout Subsection
911
912The SEQUENCE type
913\layout Standard
914
915This is an ordered collection of other simple or constructed types.
916 The SEQUENCE constructed type resembles the C
917\begin_inset Quotes sld
918\end_inset
919
920struct
921\begin_inset Quotes srd
922\end_inset
923
924 statement.
925\layout LyX-Code
926
927Address ::= SEQUENCE {
928\layout LyX-Code
929
930 -- The apartment number may be omitted
931\layout LyX-Code
932
933 apartmentNumber NumericString OPTIONAL,
934\layout LyX-Code
935
936 streetName PrintableString,
937\layout LyX-Code
938
939 cityName PrintableString,
940\layout LyX-Code
941
942 stateName PrintableString,
943\layout LyX-Code
944
945 -- This one may be omitted too
946\layout LyX-Code
947
948 zipNo NumericString OPTIONAL
949\layout LyX-Code
950
951}
952\layout Subsection
953
954The SET type
955\layout Standard
956
957This is a collection of other simple or constructed types.
958 Ordering is not important.
959 The data may arrive in the order which is different from the order of specifica
960tion.
961 Data is encoded in the order not necessarily corresponding to the order
962 of specification.
963\layout Subsection
964
965The CHOICE type
966\layout Standard
967
968This type is just a choice between the subtypes specified in it.
969 The CHOICE type contains at most one of the subtypes specified, and it
970 is always implicitly known which choice is being decoded or encoded.
971 This one resembles the C
972\begin_inset Quotes sld
973\end_inset
974
975union
976\begin_inset Quotes srd
977\end_inset
978
979 statement.
980\layout Standard
981
982The following type defines a response code, which may be either an integer
983 code or a boolean
984\begin_inset Quotes sld
985\end_inset
986
987true
988\begin_inset Quotes srd
989\end_inset
990
991/
992\begin_inset Quotes srd
993\end_inset
994
995false
996\begin_inset Quotes srd
997\end_inset
998
999 code.
1000\layout LyX-Code
1001
1002ResponseCode ::= CHOICE {
1003\layout LyX-Code
1004
1005 intCode INTEGER,
1006\layout LyX-Code
1007
1008 boolCode BOOLEAN
1009\layout LyX-Code
1010
1011}
1012\layout LyX-Code
1013
1014\layout Subsection
1015
1016The SEQUENCE OF type
1017\layout Standard
1018
1019This one is the list (array) of simple or constructed types:
1020\layout LyX-Code
1021
1022-- Example 1
1023\layout LyX-Code
1024
1025ManyIntegers ::= SEQUENCE OF INTEGER
1026\layout LyX-Code
1027
vlmfcec8e52004-08-23 15:12:04 +00001028
1029\layout LyX-Code
1030
vlme18adea2004-06-03 03:49:45 +00001031-- Example 2
1032\layout LyX-Code
1033
1034ManyRectangles ::= SEQUENCE OF Rectangle
1035\layout LyX-Code
1036
vlmfcec8e52004-08-23 15:12:04 +00001037
1038\layout LyX-Code
1039
vlme18adea2004-06-03 03:49:45 +00001040-- More complex example:
1041\layout LyX-Code
1042
1043-- an array of structures defined in place.
1044\layout LyX-Code
1045
1046ManyCircles ::= SEQUENCE OF SEQUENCE {
1047\layout LyX-Code
1048
1049 radius INTEGER
1050\layout LyX-Code
1051
1052 }
1053\layout Subsection
1054
1055The SET OF type
1056\layout Standard
1057
1058The SET OF type models the bag of structures.
1059 It resembles the SEQUENCE OF type, but the order is not important: i.e.
1060 the elements may arrive in the order which is not necessarily the same
1061 as the in-memory order on the remote machines.
1062\layout LyX-Code
1063
1064-- A set of structures defined elsewhere
1065\layout LyX-Code
1066
1067SetOfApples :: SET OF Apple
1068\layout LyX-Code
1069
vlmfcec8e52004-08-23 15:12:04 +00001070
1071\layout LyX-Code
1072
vlme18adea2004-06-03 03:49:45 +00001073-- Set of integers encoding the kind of a fruit
1074\layout LyX-Code
1075
1076FruitBag ::= SET OF ENUMERATED { apple, orange }
vlmcaba97b2004-08-07 05:00:07 +00001077\layout Part
1078
1079Using the ASN.1 Compiler
vlme18adea2004-06-03 03:49:45 +00001080\layout Chapter
1081
vlmcaba97b2004-08-07 05:00:07 +00001082Introduction to the ASN.1 Compiler
vlme18adea2004-06-03 03:49:45 +00001083\layout Standard
1084
1085The purpose of the ASN.1 compiler, of which this document is part, is to
1086 convert the ASN.1 specifications to some other target language (currently,
1087 only C is supported
1088\begin_inset Foot
1089collapsed false
1090
1091\layout Standard
1092
1093C++ is
1094\begin_inset Quotes sld
1095\end_inset
1096
1097supported
1098\begin_inset Quotes srd
1099\end_inset
1100
vlmfcec8e52004-08-23 15:12:04 +00001101 too, as long as an class-based approach is not a definitive factor.
vlme18adea2004-06-03 03:49:45 +00001102\end_inset
1103
1104).
1105 The compiler reads the specification and emits a series of target language
1106 structures and surrounding maintenance code.
1107 For example, the C structure which may be created by compiler to represent
1108 the simple
1109\emph on
1110Rectangle
1111\emph default
1112 specification defined earlier in this document, may look like this
1113\begin_inset Foot
1114collapsed false
1115
1116\layout Standard
1117
1118
1119\emph on
vlm03af0f02004-09-14 12:48:17 +00001120-fnative-types
vlme18adea2004-06-03 03:49:45 +00001121\emph default
1122 compiler option is used to produce basic C
1123\emph on
1124int
1125\emph default
vlmfcec8e52004-08-23 15:12:04 +00001126 types instead of infinite width INTEGER_t structures.
1127 See Table
1128\begin_inset LatexCommand \vref{cap:asn1c-cmdopts}
1129
1130\end_inset
1131
1132.
vlme18adea2004-06-03 03:49:45 +00001133\end_inset
1134
1135:
1136\layout LyX-Code
1137
1138typedef struct Rectangle_s {
1139\layout LyX-Code
1140
1141 int height;
1142\layout LyX-Code
1143
1144 int width;
1145\layout LyX-Code
1146
1147} Rectangle_t;
1148\layout Standard
1149
1150This would not be of much value for such a simple specification, so the
1151 compiler goes further and actually produces the code which fills in this
vlmfcec8e52004-08-23 15:12:04 +00001152 structure by parsing the opaque binary
vlme18adea2004-06-03 03:49:45 +00001153\begin_inset Foot
vlmfcec8e52004-08-23 15:12:04 +00001154collapsed true
vlme18adea2004-06-03 03:49:45 +00001155
1156\layout Standard
1157
1158BER, CER and DER encodings are binary.
1159 However, the XER encoding is text (XML) based.
1160\end_inset
1161
1162 data provided in some buffer.
1163 It also produces the code that takes this structure as an argument and
1164 performs structure serialization by emitting a series of bytes.
vlmfcec8e52004-08-23 15:12:04 +00001165\layout Chapter
vlme18adea2004-06-03 03:49:45 +00001166
1167Quick start
1168\layout Standard
1169
vlmfcec8e52004-08-23 15:12:04 +00001170After building and installing the compiler, the
1171\emph on
1172asn1c
1173\begin_inset Foot
1174collapsed false
1175
1176\layout Standard
1177
1178The 1 symbol in asn
1179\series bold
11801
1181\series default
1182c is a digit, not an
1183\begin_inset Quotes sld
1184\end_inset
1185
1186ell
1187\begin_inset Quotes srd
1188\end_inset
1189
1190 letter.
1191\end_inset
1192
1193
1194\emph default
1195 command may be used to compile the ASN.1 specification
vlme18adea2004-06-03 03:49:45 +00001196\begin_inset Foot
1197collapsed false
1198
1199\layout Standard
1200
1201This is probably
1202\series bold
1203not
1204\series default
1205 what you want to try out right now -- read through the rest of this chapter
vlmfcec8e52004-08-23 15:12:04 +00001206 to find out about
1207\series bold
1208-P
1209\series default
1210 and
1211\series bold
1212-R
1213\series default
1214 options.
vlme18adea2004-06-03 03:49:45 +00001215\end_inset
1216
1217:
1218\layout LyX-Code
1219
1220asn1c
1221\emph on
1222<spec.asn1>
1223\layout Standard
1224
vlmfcec8e52004-08-23 15:12:04 +00001225If several specifications contain interdependencies, all of the files must
1226 be specified altogether:
vlme18adea2004-06-03 03:49:45 +00001227\layout LyX-Code
1228
1229asn1c
1230\emph on
1231<spec1.asn1> <spec2.asn1> ...
1232\layout Standard
1233
vlmfcec8e52004-08-23 15:12:04 +00001234The compiler
1235\series bold
1236-E
1237\series default
1238 and
1239\series bold
1240-EF
1241\series default
1242 options are used for testing the parser and the semantic fixer, respectively.
1243 These options will instruct the compiler to dump out the parsed (and fixed,
1244 if
1245\series bold
1246-F
1247\series default
1248 is involved) ASN.1 specification as it was "understood" by the compiler.
1249 It might be useful to check whether a particular syntactic construction
vlme18adea2004-06-03 03:49:45 +00001250 is properly supported by the compiler.
1251\layout LyX-Code
1252
vlmfcec8e52004-08-23 15:12:04 +00001253asn1c
1254\series bold
1255-EF
1256\series default
1257
vlme18adea2004-06-03 03:49:45 +00001258\emph on
1259<spec-to-test.asn1>
1260\layout Standard
1261
vlmfcec8e52004-08-23 15:12:04 +00001262The
1263\series bold
1264-P
1265\series default
1266 option is used to dump the compiled output on the screen instead of creating
1267 a bunch of .c and .h files on disk in the current directory.
1268 You would probably want to start with
1269\series bold
1270-P
1271\series default
1272 option instead of creating a mess in your current directory.
1273 Another option,
1274\series bold
1275-R
1276\series default
1277, asks compiler to only generate the files which need to be generated, and
1278 supress linking in the numerous support files.
1279\layout Standard
1280
1281Print the compiled output instead of creating multiple source files:
1282\layout LyX-Code
1283
1284asn1c
1285\series bold
1286-P
1287\series default
1288
1289\emph on
1290<spec-to-compile-and-print.asn1>
1291\layout LyX-Code
1292
1293\layout Chapter
1294
1295Using the ASN.1 Compiler
vlme18adea2004-06-03 03:49:45 +00001296\layout Section
1297
vlmfcec8e52004-08-23 15:12:04 +00001298Command-line options
1299\layout Standard
1300
1301The Table
1302\begin_inset LatexCommand \vref{cap:asn1c-cmdopts}
1303
1304\end_inset
1305
1306 summarizes various options affecting the compiler's behavior.
1307\layout Standard
1308
1309
1310\begin_inset Float table
1311wide false
vlm12c8f692004-09-06 08:07:29 +00001312collapsed false
vlmfcec8e52004-08-23 15:12:04 +00001313
1314\layout Standard
1315
1316
1317\begin_inset Tabular
vlmbfc49bd2004-09-26 13:13:13 +00001318<lyxtabular version="3" rows="21" columns="2">
vlmfcec8e52004-08-23 15:12:04 +00001319<features>
1320<column alignment="left" valignment="top" leftline="true" width="0">
1321<column alignment="block" valignment="top" leftline="true" rightline="true" width="3in">
1322<row topline="true" bottomline="true">
1323<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1324\begin_inset Text
1325
1326\layout Standard
1327
1328
1329\series bold
1330Overall Options
1331\end_inset
1332</cell>
1333<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1334\begin_inset Text
1335
1336\layout Standard
1337
1338
1339\series bold
1340Description
1341\end_inset
1342</cell>
1343</row>
1344<row topline="true">
1345<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1346\begin_inset Text
1347
1348\layout Standard
1349
1350-E
1351\end_inset
1352</cell>
1353<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1354\begin_inset Text
1355
1356\layout Standard
1357
1358
1359\size small
1360Stop after the parsing stage and print the reconstructed ASN.1 specification
1361 code to the standard output.
1362\end_inset
1363</cell>
1364</row>
1365<row topline="true">
1366<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1367\begin_inset Text
1368
1369\layout Standard
1370
1371-F
1372\end_inset
1373</cell>
1374<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1375\begin_inset Text
1376
1377\layout Standard
1378
1379
1380\size small
1381Used together with -E, instructs the compiler to stop after the ASN.1 syntax
1382 tree fixing stage and dump the reconstructed ASN.1 specification to the
1383 standard output.
1384\end_inset
1385</cell>
1386</row>
1387<row topline="true">
1388<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1389\begin_inset Text
1390
1391\layout Standard
1392
1393-P
1394\end_inset
1395</cell>
1396<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1397\begin_inset Text
1398
1399\layout Standard
1400
1401
1402\size small
1403Dump the compiled output to the standard output instead of cre- ating the
1404 target language files on disk.
1405\end_inset
1406</cell>
1407</row>
1408<row topline="true">
1409<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1410\begin_inset Text
1411
1412\layout Standard
1413
1414-R
1415\end_inset
1416</cell>
1417<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1418\begin_inset Text
1419
1420\layout Standard
1421
1422
1423\size small
1424Restrict the compiler to generate only the ASN.1 tables, omit- ting the usual
1425 support code.
1426\end_inset
1427</cell>
1428</row>
vlm68d43e92004-09-24 20:56:07 +00001429<row topline="true" bottomline="true">
vlmfcec8e52004-08-23 15:12:04 +00001430<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1431\begin_inset Text
1432
1433\layout Standard
1434
1435-S
1436\emph on
1437<directory>
1438\end_inset
1439</cell>
1440<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1441\begin_inset Text
1442
1443\layout Standard
1444
1445
1446\size small
1447Use the specified directory with ASN.1 skeleton files.
1448\end_inset
1449</cell>
1450</row>
vlmfcec8e52004-08-23 15:12:04 +00001451<row topline="true">
1452<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1453\begin_inset Text
1454
1455\layout Standard
1456
1457
1458\series bold
1459Warning Options
1460\end_inset
1461</cell>
1462<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1463\begin_inset Text
1464
1465\layout Standard
1466
1467
1468\series bold
1469Description
1470\end_inset
1471</cell>
1472</row>
1473<row topline="true">
1474<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1475\begin_inset Text
1476
1477\layout Standard
1478
1479-Werror
1480\end_inset
1481</cell>
1482<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1483\begin_inset Text
1484
1485\layout Standard
1486
1487
1488\size small
1489Treat warnings as errors; abort if any warning is produced.
1490\end_inset
1491</cell>
1492</row>
1493<row topline="true">
1494<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1495\begin_inset Text
1496
1497\layout Standard
1498
1499-Wdebug-lexer
1500\end_inset
1501</cell>
1502<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1503\begin_inset Text
1504
1505\layout Standard
1506
1507
1508\size small
1509Enable lexer debugging during the ASN.1 parsing stage.
1510\end_inset
1511</cell>
1512</row>
1513<row topline="true">
1514<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1515\begin_inset Text
1516
1517\layout Standard
1518
1519-Wdebug-fixer
1520\end_inset
1521</cell>
1522<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1523\begin_inset Text
1524
1525\layout Standard
1526
1527
1528\size small
1529 Enable ASN.1 syntax tree fixer debugging during the fixing stage.
1530\end_inset
1531</cell>
1532</row>
1533<row topline="true" bottomline="true">
1534<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1535\begin_inset Text
1536
1537\layout Standard
1538
1539-Wdebug-compiler
1540\end_inset
1541</cell>
1542<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1543\begin_inset Text
1544
1545\layout Standard
1546
1547
1548\size small
1549Enable debugging during the actual compile time.
1550\end_inset
1551</cell>
1552</row>
1553<row topline="true">
1554<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1555\begin_inset Text
1556
1557\layout Standard
1558
1559
1560\series bold
1561Language Options
1562\end_inset
1563</cell>
1564<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1565\begin_inset Text
1566
1567\layout Standard
1568
1569
1570\series bold
1571Description
1572\end_inset
1573</cell>
1574</row>
1575<row topline="true">
1576<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1577\begin_inset Text
1578
1579\layout Standard
1580
vlm12c8f692004-09-06 08:07:29 +00001581-fall-defs-global
1582\end_inset
1583</cell>
1584<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1585\begin_inset Text
1586
1587\layout Standard
1588
1589Normally the compiler hides the definitions (asn1_DEF_xxx) of the inner
1590 structure elements (members of SEQUENCE, SET and other types).
1591 This option makes all such definitions global.
1592 Enabling this option may pollute the namespace by making lots of asn1_DEF_xxx
1593 structures globally visible, but will allow you to manipulate (encode and
1594 decode) the individual members of any complex ASN.1 structure.
1595\end_inset
1596</cell>
1597</row>
1598<row topline="true">
1599<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1600\begin_inset Text
1601
1602\layout Standard
1603
vlmfcec8e52004-08-23 15:12:04 +00001604-fbless-SIZE
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\size small
1614Allow SIZE() constraint for INTEGER, ENUMERATED, and other types for which
1615 this constraint is normally prohibited by the standard.
1616 This is a violation of an ASN.1 standard and compiler may fail to produce
1617 the meaningful code.
1618\end_inset
1619</cell>
1620</row>
1621<row topline="true">
1622<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1623\begin_inset Text
1624
1625\layout Standard
1626
vlm03af0f02004-09-14 12:48:17 +00001627-fnative-types
vlmfcec8e52004-08-23 15:12:04 +00001628\end_inset
1629</cell>
1630<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1631\begin_inset Text
1632
1633\layout Standard
1634
1635
1636\size small
vlm03af0f02004-09-14 12:48:17 +00001637Use the native machine's data types (int, double) whenever possible, instead
1638 of the compound ASN.1 INTEGER_t, ENUMERATED_t and REAL_t types.
vlmfcec8e52004-08-23 15:12:04 +00001639
1640\end_inset
1641</cell>
1642</row>
1643<row topline="true">
1644<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1645\begin_inset Text
1646
1647\layout Standard
1648
vlmbfc49bd2004-09-26 13:13:13 +00001649-fno-constraints
1650\end_inset
1651</cell>
1652<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1653\begin_inset Text
1654
1655\layout Standard
1656
1657Do not generate ASN.1 subtype constraint checking code.
1658 This may make a shorter executable.
1659\end_inset
1660</cell>
1661</row>
1662<row topline="true">
1663<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1664\begin_inset Text
1665
1666\layout Standard
1667
vlmfcec8e52004-08-23 15:12:04 +00001668-funnamed-unions
1669\end_inset
1670</cell>
1671<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1672\begin_inset Text
1673
1674\layout Standard
1675
1676
1677\size small
1678Enable unnamed unions in the definitions of target language's structures.
1679\end_inset
1680</cell>
1681</row>
1682<row topline="true" bottomline="true">
1683<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1684\begin_inset Text
1685
1686\layout Standard
1687
1688-ftypes88
1689\end_inset
1690</cell>
1691<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1692\begin_inset Text
1693
1694\layout Standard
1695
1696
1697\size small
1698Use only ASN.1:1988 embedded types.
1699\end_inset
1700</cell>
1701</row>
1702<row topline="true">
1703<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1704\begin_inset Text
1705
1706\layout Standard
1707
1708
1709\series bold
1710Output Options
1711\end_inset
1712</cell>
1713<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1714\begin_inset Text
1715
1716\layout Standard
1717
1718
1719\series bold
1720Description
1721\end_inset
1722</cell>
1723</row>
1724<row topline="true">
1725<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1726\begin_inset Text
1727
1728\layout Standard
1729
1730-print-constraints
1731\end_inset
1732</cell>
1733<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1734\begin_inset Text
1735
1736\layout Standard
1737
1738
1739\size small
1740When -EF are also specified, this option forces the compiler to explain
1741 its internal understanding of subtype constraints.
1742\end_inset
1743</cell>
1744</row>
1745<row topline="true" bottomline="true">
1746<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1747\begin_inset Text
1748
1749\layout Standard
1750
1751-print-lines
1752\end_inset
1753</cell>
1754<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1755\begin_inset Text
1756
1757\layout Standard
1758
1759
1760\size small
1761Generate "-- #line" comments in -E output.
1762\end_inset
1763</cell>
1764</row>
1765</lyxtabular>
1766
1767\end_inset
1768
1769
1770\layout Caption
1771
1772
1773\begin_inset LatexCommand \label{cap:asn1c-cmdopts}
1774
1775\end_inset
1776
1777The list of asn1c command line options
1778\end_inset
1779
1780
1781\layout Section
vlme18adea2004-06-03 03:49:45 +00001782
1783Recognizing compiler output
1784\layout Standard
1785
1786After compiling, the following entities will be created in your current
1787 directory:
1788\layout Itemize
1789
1790A set of .c and .h files, generally a single pair for each type defined in
1791 the ASN.1 specifications.
1792 These files will be named similarly to the ASN.1 types (
1793\emph on
1794Rectangle.c
1795\emph default
1796 and
1797\emph on
1798Rectangle.h
1799\emph default
1800 for the specification defined in the beginning of this document).
1801\layout Itemize
1802
1803A set of helper .c and .h files which contain generic encoders, decoders and
1804 other useful routines.
vlmfcec8e52004-08-23 15:12:04 +00001805 There will be quite a few of them, some of them even are not always necessary,
1806 but the overall amount of code after compiling will be rather small anyway.
vlme18adea2004-06-03 03:49:45 +00001807\layout Standard
1808
1809It is your responsibility to create .c file with the
1810\emph on
1811 int main()
1812\emph default
1813 routine and the Makefile (if needed).
1814 Compiler helps you with the latter by creating the Makefile.am.sample, containing
1815 the skeleton definition for the automake, should you want to use autotools.
1816\layout Standard
1817
1818In other words, after compiling the Rectangle module, you have the following
1819 set of files: { Makefile.am.sample, Rectangle.c, Rectangle.h,
1820\series bold
1821\SpecialChar \ldots{}
1822
1823\series default
1824 }, where
1825\series bold
1826
1827\begin_inset Quotes sld
1828\end_inset
1829
1830\SpecialChar \ldots{}
1831
1832\begin_inset Quotes srd
1833\end_inset
1834
1835
1836\series default
1837 stands for the set of additional
1838\begin_inset Quotes sld
1839\end_inset
1840
1841helper
1842\begin_inset Quotes srd
1843\end_inset
1844
1845 files created by the compiler.
1846 If you add the simple file with the
1847\emph on
1848int main()
1849\emph default
1850 routine, it would even be possible to compile everything with the single
1851 instruction:
1852\layout LyX-Code
1853
1854cc -o rectangle *.c # It could be
1855\emph on
1856that
1857\emph default
1858 simple
1859\begin_inset Foot
1860collapsed false
1861
1862\layout Standard
1863
1864Provided that you've also created a .c file with the
1865\emph on
1866int main()
1867\emph default
1868 routine.
1869\end_inset
1870
1871
vlmfcec8e52004-08-23 15:12:04 +00001872\layout Section
vlme18adea2004-06-03 03:49:45 +00001873
1874Invoking the ASN.1 helper code from the application
1875\layout Standard
1876
vlmfcec8e52004-08-23 15:12:04 +00001877First of all, you should to include one or more header files into your applicati
1878on.
1879 For our Rectangle module, including the Rectangle.h file is enough:
vlme18adea2004-06-03 03:49:45 +00001880\layout LyX-Code
1881
1882#include <Rectangle.h>
1883\layout Standard
1884
1885The header files defines the C structure corresponding to the ASN.1 definition
1886 of a rectangle and the declaration of the ASN.1 type descriptor, which is
1887 used as an argument to most of the functions provided by the ASN.1 module.
1888 For example, here is the code which frees the Rectangle_t structure:
1889\layout LyX-Code
1890
vlmfcec8e52004-08-23 15:12:04 +00001891Rectangle_t *rect = ...;
1892\layout LyX-Code
1893
1894
vlme18adea2004-06-03 03:49:45 +00001895\layout LyX-Code
1896
1897asn1_DEF_Rectangle->free_struct(&asn1_DEF_Rectangle,
1898\layout LyX-Code
1899
1900 rect, 0);
1901\layout Standard
1902
1903This code defines a
1904\emph on
1905rect
1906\emph default
1907 pointer which points to the Rectangle_t structure which needs to be freed.
1908 The second line invokes the generic free_struct routine created specifically
1909 for this Rectangle_t structure.
1910 The
1911\emph on
1912asn1_DEF_Rectangle
1913\emph default
1914 is the type descriptor, which holds a collection of generic routines to
1915 deal with the Rectangle_t structure.
1916\layout Standard
1917
1918There are several generic functions available:
1919\layout Description
1920
vlme18adea2004-06-03 03:49:45 +00001921ber_decoder This is the generic
1922\emph on
1923restartable
1924\begin_inset Foot
1925collapsed false
1926
1927\layout Standard
1928
1929Restartable means that if the decoder encounters the end of the buffer,
1930 it will fail, but may later be invoked again with the rest of the buffer
1931 to continue decoding.
1932\end_inset
1933
1934
1935\emph default
1936BER decoder (Basic Encoding Rules).
1937 This decoder would create and/or fill the target structure for you.
1938 Please refer to Section
1939\begin_inset LatexCommand \ref{sub:Decoding-BER}
1940
1941\end_inset
1942
1943.
1944\layout Description
1945
1946der_encoder This is the generic DER encoder (Distinguished Encoding Rules).
vlm68d43e92004-09-24 20:56:07 +00001947 This encoder will take the target structure and encode it into a series
vlme18adea2004-06-03 03:49:45 +00001948 of bytes.
1949 Please refer to Section
1950\begin_inset LatexCommand \ref{sub:Encoding-DER}
1951
1952\end_inset
1953
1954.
1955\layout Description
1956
vlm68d43e92004-09-24 20:56:07 +00001957xer_encoder This is the generic XER encoder (XML Encoding Rules).
1958 This encoder will take the target structure and represent it as an XML
1959 (text) document.
1960 Please refer to Section
1961\begin_inset LatexCommand \ref{sub:Encoding-XER}
1962
1963\end_inset
1964
1965.
1966\layout Description
1967
1968check_constraints Check that the contents of the target structure are semantical
1969ly valid and constrained to appropriate implicit or explicit subtype constraints.
1970 Please refer to Section
1971\begin_inset LatexCommand \vref{sub:Validating-the-target}
1972
1973\end_inset
1974
1975.
1976\layout Description
1977
vlme18adea2004-06-03 03:49:45 +00001978print_struct This function convert the contents of the passed target structure
1979 into human readable form.
1980 This form is not formal and cannot be converted back into the structure,
1981 but it may turn out to be useful for debugging or quick-n-dirty printing.
1982 Please refer to Section
1983\begin_inset LatexCommand \ref{sub:Printing-the-target}
1984
1985\end_inset
1986
1987.
1988\layout Description
1989
1990free_struct This is a generic disposal which frees the target structure.
1991 Please refer to Section
1992\begin_inset LatexCommand \ref{sub:Freeing-the-target}
1993
1994\end_inset
1995
1996.
1997\layout Standard
1998
vlm68d43e92004-09-24 20:56:07 +00001999check_constraints Check that the contents of the target structure are semantical
2000ly valid and constrained to appropriate implicit or explicit subtype constraints.
2001 Please refer to Section
2002\begin_inset LatexCommand \vref{sub:Validating-the-target}
2003
2004\end_inset
2005
2006.
2007\layout Standard
2008
vlme18adea2004-06-03 03:49:45 +00002009Each of the above function takes the type descriptor (
2010\emph on
2011asn1_DEF_\SpecialChar \ldots{}
2012
2013\emph default
2014) and the target structure (
2015\emph on
2016rect
2017\emph default
2018, in the above example).
2019 The target structure is typically created by the generic BER decoder or
2020 by the application itself.
2021\layout Standard
2022
2023Here is how the buffer can be deserialized into the structure:
2024\layout LyX-Code
2025
2026Rectangle_t *
2027\layout LyX-Code
2028
vlmfcec8e52004-08-23 15:12:04 +00002029simple_deserializer(const void *buffer, size_t buf_size) {
vlme18adea2004-06-03 03:49:45 +00002030\layout LyX-Code
2031
2032 Rectangle_t *rect = 0; /* Note this 0! */
2033\layout LyX-Code
2034
2035 ber_dec_rval_t rval;
2036\layout LyX-Code
2037
2038
2039\layout LyX-Code
2040
2041 rval = asn1_DEF_Rectangle->ber_decoder(
2042\layout LyX-Code
2043
2044 &asn1_DEF_Rectangle,
2045\layout LyX-Code
2046
2047 (void **)&rect,
2048\layout LyX-Code
2049
2050 buffer, buf_size,
2051\layout LyX-Code
2052
2053 0);
2054\layout LyX-Code
2055
2056
2057\layout LyX-Code
2058
2059 if(rval
2060\series bold
2061.code
2062\series default
2063 == RC_OK) {
2064\layout LyX-Code
2065
2066 return rect; /* Decoding succeeded */
2067\layout LyX-Code
2068
2069 } else {
2070\layout LyX-Code
2071
vlmfcec8e52004-08-23 15:12:04 +00002072 /* Free partially decoded rect */
2073\layout LyX-Code
2074
vlme18adea2004-06-03 03:49:45 +00002075 asn1_DEF_Rectangle->free_struct(
2076\layout LyX-Code
2077
2078 &asn1_DEF_Rectangle, rect, 0);
2079\layout LyX-Code
2080
2081 return 0;
2082\layout LyX-Code
2083
2084 }
2085\layout LyX-Code
2086
2087}
2088\layout Standard
2089
2090The code above defines a function,
2091\emph on
2092simple_deserializer
2093\emph default
2094, which takes a buffer and its length and expected to return a pointer to
2095 the Rectangle_t structure.
2096 Inside, it tries to convert the bytes passed into the target structure
2097 (rect) using the generic BER decoder and returns the rect pointer afterwards.
2098 If the structure cannot be deserialized, it frees the memory which might
2099 be left allocated by the unfinished
2100\emph on
2101ber_decoder
2102\emph default
2103 routine and returns NULL.
2104
2105\series bold
2106This freeing is necessary
2107\series default
2108 because the ber_decoder is a restartable procedure, and may fail just because
2109 there is more data needs to be provided before decoding could be finalized.
2110 The code above obviously does not take into account the way the
2111\emph on
2112ber_decoder
2113\emph default
2114 failed, so the freeing is necessary because the part of the buffer may
2115 already be decoded into the structure by the time something goes wrong.
2116\layout Standard
2117
2118Restartable decoding is a little bit trickier: you need to provide the old
2119 target structure pointer (which might be already half-decoded) and react
2120 on RC_WMORE return code.
2121 This will be explained later in Section
2122\begin_inset LatexCommand \vref{sub:Decoding-BER}
2123
2124\end_inset
2125
2126
vlmfcec8e52004-08-23 15:12:04 +00002127\layout Subsection
vlme18adea2004-06-03 03:49:45 +00002128
2129
2130\begin_inset LatexCommand \label{sub:Decoding-BER}
2131
2132\end_inset
2133
2134Decoding BER
2135\layout Standard
2136
2137The Basic Encoding Rules describe the basic way how the structure can be
2138 encoded and decoded.
2139 Several other encoding rules (CER, DER) define a more restrictive versions
2140 of BER, so the generic BER parser is also capable of decoding the data
2141 encoded by CER and DER encoders.
2142 The opposite is not true.
2143\layout Standard
2144
2145The ASN.1 compiler provides the generic BER decoder which is implicitly capable
2146 of decoding BER, CER and DER encoded data.
2147\layout Standard
2148
2149The decoder is restartable (stream-oriented), which means that in case the
2150 buffer has less data than it is expected, the decoder will process whatever
2151 it is available and ask for more data to be provided.
2152 Please note that the decoder may actually process less data than it is
2153 given in the buffer, which means that you should be able to make the next
2154 buffer contain the unprocessed part of the previous buffer.
2155\layout Standard
2156
2157Suppose, you have two buffers of encoded data: 100 bytes and 200 bytes.
2158\layout Itemize
2159
2160You may concatenate these buffers and feed the BER decoder with 300 bytes
2161 of data, or
2162\layout Itemize
2163
2164You may feed it the first buffer of 100 bytes of data, realize that the
2165 ber_decoder consumed only 95 bytes from it and later feed the decoder with
2166 205 bytes buffer which consists of 5 unprocessed bytes from the first buffer
2167 and the latter 200 bytes from the second buffer.
2168\layout Standard
2169
2170This is not as convenient as it could be (like, the BER encoder would consume
2171 the whole 100 bytes and keep these 5 bytes in some temporary storage),
2172 but in case of stream-based processing it might actually be OK.
2173 Suggestions are welcome.
2174\layout Standard
2175
2176There are two ways to invoke a BER decoder.
2177 The first one is a direct reference of the type-specific decoder.
2178 This way was shown in the previous example of
2179\emph on
2180simple_deserializer
2181\emph default
2182 function.
2183 The second way is to invoke a
2184\emph on
2185ber_decode
2186\emph default
2187 function, which is just a simple wrapper of the former approach into a
2188 less wordy notation:
2189\layout LyX-Code
2190
2191rval = ber_decode(&asn1_DEF_Rectangle, (void **)&rect,
2192\layout LyX-Code
2193
2194 buffer, buf_size);
2195\layout Standard
2196
2197Note that the initial (asn1_DEF_Rectangle->ber_decoder) reference is gone,
2198 and also the last argument (0) is no longer necessary.
2199\layout Standard
2200
2201These two ways of invocations are fully equivalent.
2202\layout Standard
2203
2204The BER de
2205\emph on
2206coder
2207\emph default
2208 may fail because (
2209\emph on
2210the following RC_\SpecialChar \ldots{}
2211 codes are defined in ber_decoder.h
2212\emph default
2213):
2214\layout Itemize
2215
2216RC_WMORE: There is more data expected than it is provided (stream mode continuat
2217ion feature);
2218\layout Itemize
2219
2220RC_FAIL: General failure to decode the buffer;
2221\layout Itemize
2222
2223\SpecialChar \ldots{}
2224 other codes may be defined as well.
2225\layout Standard
2226
2227Together with the return code (.code) the ber_dec_rval_t type contains the
2228 number of bytes which is consumed from the buffer.
2229 In the previous hypothetical example of two buffers (of 100 and 200 bytes),
2230 the first call to ber_decode() would return with .code = RC_WMORE and .consumed
2231 = 95.
2232 The .consumed field of the BER decoder return value is
2233\series bold
2234always
2235\series default
2236 valid, even if the decoder succeeds or fails with any other return code.
2237\layout Standard
2238
2239Please look into ber_decoder.h for the precise definition of ber_decode()
2240 and related types.
vlmfcec8e52004-08-23 15:12:04 +00002241\layout Subsection
vlme18adea2004-06-03 03:49:45 +00002242
2243
2244\begin_inset LatexCommand \label{sub:Encoding-DER}
2245
2246\end_inset
2247
2248Encoding DER
2249\layout Standard
2250
vlm68d43e92004-09-24 20:56:07 +00002251The Distinguished Encoding Rules is the
2252\emph on
2253canonical
2254\emph default
2255 variant of BER encoding rules.
2256 The DER is best suited to encode the structures where all the lengths are
2257 known beforehand.
vlme18adea2004-06-03 03:49:45 +00002258 This is probably exactly how you want to encode: either after a BER decoding
2259 or after a manual fill-up, the target structure contains the data which
2260 size is implicitly known before encoding.
2261 The DER encoding is used, for example, to encode X.509 certificates.
2262\layout Standard
2263
2264As with BER decoder, the DER encoder may be invoked either directly from
2265 the ASN.1 type descriptor (asn1_DEF_Rectangle) or from the stand-alone function,
2266 which is somewhat simpler:
2267\layout LyX-Code
2268
2269/*
2270\layout LyX-Code
2271
2272 * This is a custom function which writes the
2273\layout LyX-Code
2274
2275 * encoded output into some FILE stream.
2276\layout LyX-Code
2277
2278 */
2279\layout LyX-Code
2280
vlmfcec8e52004-08-23 15:12:04 +00002281static int
2282\layout LyX-Code
2283
2284write_stream(const void *buffer, size_t size, void *app_key) {
vlme18adea2004-06-03 03:49:45 +00002285\layout LyX-Code
2286
2287 FILE *ostream = app_key;
2288\layout LyX-Code
2289
2290 size_t wrote;
2291\layout LyX-Code
2292
2293
2294\layout LyX-Code
2295
2296 wrote = fwrite(buffer, 1, size, ostream);
2297\layout LyX-Code
2298
2299
2300\layout LyX-Code
2301
2302 return (wrote == size) ? 0 : -1;
2303\layout LyX-Code
2304
2305}
2306\layout LyX-Code
2307
2308
2309\layout LyX-Code
2310
2311/*
2312\layout LyX-Code
2313
2314 * This is the serializer itself,
2315\layout LyX-Code
2316
2317 * it supplies the DER encoder with the
2318\layout LyX-Code
2319
2320 * pointer to the custom output function.
2321\layout LyX-Code
2322
2323 */
2324\layout LyX-Code
2325
2326ssize_t
2327\layout LyX-Code
2328
2329simple_serializer(FILE *ostream, Rectangle_t *rect) {
2330\layout LyX-Code
2331
vlm68d43e92004-09-24 20:56:07 +00002332 asn_enc_rval_t er; /* Encoder return value */
vlme18adea2004-06-03 03:49:45 +00002333\layout LyX-Code
2334
2335
2336\layout LyX-Code
2337
vlm68d43e92004-09-24 20:56:07 +00002338 er = der_encode(&asn1_DEF_Rect, rect,
vlme18adea2004-06-03 03:49:45 +00002339\layout LyX-Code
2340
vlmfcec8e52004-08-23 15:12:04 +00002341 write_stream, ostream);
vlme18adea2004-06-03 03:49:45 +00002342\layout LyX-Code
2343
vlm68d43e92004-09-24 20:56:07 +00002344 if(er.
vlme18adea2004-06-03 03:49:45 +00002345\series bold
vlm68d43e92004-09-24 20:56:07 +00002346encoded
vlme18adea2004-06-03 03:49:45 +00002347\series default
2348 == -1) {
2349\layout LyX-Code
2350
2351 /*
2352\layout LyX-Code
2353
vlm68d43e92004-09-24 20:56:07 +00002354 * Failed to encode the rectangle data.
vlme18adea2004-06-03 03:49:45 +00002355\layout LyX-Code
2356
2357 */
2358\layout LyX-Code
2359
2360 fprintf(stderr,
2361\begin_inset Quotes sld
2362\end_inset
2363
2364Cannot encode %s: %s
2365\backslash
2366n
2367\begin_inset Quotes srd
2368\end_inset
2369
2370,
2371\layout LyX-Code
2372
vlm68d43e92004-09-24 20:56:07 +00002373 er.
vlme18adea2004-06-03 03:49:45 +00002374\series bold
vlm68d43e92004-09-24 20:56:07 +00002375failed_type
vlme18adea2004-06-03 03:49:45 +00002376\series default
2377->name,
2378\layout LyX-Code
2379
2380 strerror(errno));
2381\layout LyX-Code
2382
2383 return -1;
2384\layout LyX-Code
2385
2386 } else {
2387\layout LyX-Code
2388
2389 /* Return the number of bytes */
2390\layout LyX-Code
2391
vlm68d43e92004-09-24 20:56:07 +00002392 return er.encoded;
vlme18adea2004-06-03 03:49:45 +00002393\layout LyX-Code
2394
2395 }
2396\layout LyX-Code
2397
2398}
2399\layout Standard
2400
2401As you see, the DER encoder does not write into some sort of buffer or something.
2402 It just invokes the custom function (possible, multiple times) which would
2403 save the data into appropriate storage.
2404 The optional argument
2405\emph on
2406app_key
2407\emph default
2408 is opaque for the DER encoder code and just used by
2409\emph on
2410_write_stream()
2411\emph default
2412 as the pointer to the appropriate output stream to be used.
2413\layout Standard
2414
2415If the custom write function is not given (passed as 0), then the DER encoder
2416 will essentially do the same thing (i.e., encode the data) but no callbacks
2417 will be invoked (so the data goes nowhere).
2418 It may prove useful to determine the size of the structure's encoding before
2419 actually doing the encoding
2420\begin_inset Foot
2421collapsed false
2422
2423\layout Standard
2424
2425It is actually faster too: the encoder might skip over some computations
2426 which aren't important for the size determination.
2427\end_inset
2428
2429.
2430\layout Standard
2431
2432Please look into der_encoder.h for the precise definition of der_encode()
2433 and related types.
vlmfcec8e52004-08-23 15:12:04 +00002434\layout Subsection
vlme18adea2004-06-03 03:49:45 +00002435
2436
vlm68d43e92004-09-24 20:56:07 +00002437\begin_inset LatexCommand \label{sub:Encoding-XER}
2438
2439\end_inset
2440
2441Encoding XER
2442\layout Standard
2443
2444The XER stands for XML Encoding Rules, where XML, in turn, is eXtensible
2445 Markup Language, a text-based format for information exchange.
2446 The encoder routine API comes in two flavors: stdio-based and callback-based.
2447 With the callback-based encoder, the encoding process is very similar to
2448 the DER one, described in Section
2449\begin_inset LatexCommand \vref{sub:Encoding-DER}
2450
2451\end_inset
2452
2453.
2454 The following example uses the definition of write_stream() from up there.
2455\layout LyX-Code
2456
2457/*
2458\layout LyX-Code
2459
2460 * This procedure generates the XML document
2461\layout LyX-Code
2462
2463 * by invoking the XER encoder.
2464\layout LyX-Code
2465
2466 * NOTE: Do not copy this code verbatim!
2467\layout LyX-Code
2468
2469 * If the stdio output is necessary,
2470\layout LyX-Code
2471
2472 * use the xer_fprint() procedure instead.
2473\layout LyX-Code
2474
2475 * See Section
2476\begin_inset LatexCommand \vref{sub:Printing-the-target}
2477
2478\end_inset
2479
2480.
2481\layout LyX-Code
2482
2483 */
2484\layout LyX-Code
2485
2486int
2487\layout LyX-Code
2488
2489print_as_XML(FILE *ostream, Rectangle_t *rect) {
2490\layout LyX-Code
2491
2492 asn_enc_rval_t er; /* Encoder return value */
2493\layout LyX-Code
2494
2495
2496\layout LyX-Code
2497
2498 er = xer_encode(&asn1_DEF_Rect, rect,
2499\layout LyX-Code
2500
2501 XER_F_BASIC, /* BASIC-XER or CANONICAL-XER */
2502\layout LyX-Code
2503
2504 write_stream, ostream);
2505\layout LyX-Code
2506
2507
2508\layout LyX-Code
2509
2510 return (er.encoded == -1) ? -1 : 0;
2511\layout LyX-Code
2512
2513}
2514\layout Standard
2515
2516Please look into xer_encoder.h for the precise definition of xer_encode()
2517 and related types.
2518\layout Standard
2519
2520See Section
2521\begin_inset LatexCommand \ref{sub:Printing-the-target}
2522
2523\end_inset
2524
2525 for the example of stdio-based XML encoder and other pretty-printing suggestion
2526s.
2527\layout Subsection
2528
2529
vlme18adea2004-06-03 03:49:45 +00002530\begin_inset LatexCommand \label{sub:Validating-the-target}
2531
2532\end_inset
2533
2534Validating the target structure
2535\layout Standard
2536
2537Sometimes the target structure needs to be validated.
2538 For example, if the structure was created by the application (as opposed
2539 to being decoded from some external source), some important information
2540 required by the ASN.1 specification might be missing.
2541 On the other hand, the successful decoding of the data from some external
2542 source does not necessarily mean that the data is fully valid either.
2543 It might well be the case that the specification describes some subtype
2544 constraints that were not taken into account during decoding, and it would
2545 actually be useful to perform the last check when the data is ready to
2546 be encoded or when the data has just been decoded to ensure its validity
2547 according to some stricter rules.
2548\layout Standard
2549
2550The asn_check_constraints() function checks the type for various implicit
2551 and explicit constraints.
2552 It is recommended to use asn_check_constraints() function after each decoding
2553 and before each encoding.
2554\layout Standard
2555
2556Please look into constraints.h for the precise definition of asn_check_constraint
2557s() and related types.
vlmfcec8e52004-08-23 15:12:04 +00002558\layout Subsection
vlme18adea2004-06-03 03:49:45 +00002559
2560
2561\begin_inset LatexCommand \label{sub:Printing-the-target}
2562
2563\end_inset
2564
2565Printing the target structure
2566\layout Standard
2567
2568There are two ways to print the target structure: either invoke the print_struct
2569 member of the ASN.1 type descriptor, or using the asn_fprint() function,
2570 which is a simpler wrapper of the former:
2571\layout LyX-Code
2572
2573asn_fprint(stdout, &asn1_DEF_Rectangle, rect);
2574\layout Standard
2575
2576Please look into constr_TYPE.h for the precise definition of asn_fprint()
2577 and related types.
vlm68d43e92004-09-24 20:56:07 +00002578\layout Standard
2579
2580Another practical alternative to this custom format printing would be to
2581 invoke XER encoder.
2582 The default BASIC-XER encoder performs reasonable formatting for the output
2583 to be useful and human readable.
2584 To invoke the XER decoder in a manner similar to asn_fprint(), use the
2585 xer_fprint() call:
2586\layout LyX-Code
2587
2588xer_fprint(stdout, &asn1_DEF_Rectangle, rect);
2589\layout Standard
2590
2591See Section
2592\begin_inset LatexCommand \vref{sub:Encoding-XER}
2593
2594\end_inset
2595
2596 for XML-related details.
vlmfcec8e52004-08-23 15:12:04 +00002597\layout Subsection
vlme18adea2004-06-03 03:49:45 +00002598
2599
2600\begin_inset LatexCommand \label{sub:Freeing-the-target}
2601
2602\end_inset
2603
2604Freeing the target structure
2605\layout Standard
2606
2607Freeing the structure is slightly more complex than it may seem to.
2608 When the ASN.1 structure is freed, all the members of the structure and
2609 their submembers etc etc are recursively freed too.
2610 But it might not be feasible to free the structure itself.
2611 Consider the following case:
2612\layout LyX-Code
2613
2614struct my_figure { /* The custom structure */
2615\layout LyX-Code
2616
2617 int flags; /* <some custom member> */
2618\layout LyX-Code
2619
2620 /* The type is generated by the ASN.1 compiler */
2621\layout LyX-Code
2622
2623
2624\emph on
2625Rectangle_t rect;
2626\layout LyX-Code
2627
2628 /* other members of the structure */
2629\layout LyX-Code
2630
2631};
2632\layout Standard
2633
2634In this example, the application programmer defined a custom structure with
2635 one ASN.1-derived member (rect).
2636 This member is not a reference to the Rectangle_t, but an in-place inclusion
2637 of the Rectangle_t structure.
2638 If the freeing is necessary, the usual procedure of freeing everything
2639 must not be applied to the &rect pointer itself, because it does not point
2640 to the memory block directly allocated by memory allocation routine, but
2641 instead lies within such a block allocated for my_figure structure.
2642\layout Standard
2643
2644To solve this problem, the free_struct routine has the additional argument
2645 (besides the intuitive type descriptor and target structure pointers),
2646 which is the flag specifying whether the outer pointer itself must be freed
2647 (0, default) or it should be left intact (non-zero value).
2648\layout LyX-Code
2649
2650/* Rectangle_t is defined within my_figure */
2651\layout LyX-Code
2652
2653struct my_figure *mf =
2654\series bold
2655...
2656\series default
2657;
2658\layout LyX-Code
2659
2660/*
2661\layout LyX-Code
2662
2663 * Freeing the Rectangle_td
2664\layout LyX-Code
2665
2666 * without freeing the mf->rect pointer
2667\layout LyX-Code
2668
2669 */
2670\layout LyX-Code
2671
2672asn1_DEF_Rectangle->free_struct(
2673\layout LyX-Code
2674
2675 &asn1_DEF_Rectangle, &mf->rect,
2676\emph on
26771
2678\emph default
2679 /* !free */);
2680\layout LyX-Code
2681
2682
2683\layout LyX-Code
2684
2685/* Rectangle_t is a stand-alone pointer */
2686\layout LyX-Code
2687
2688Rectangle_t *rect =
2689\series bold
2690...
2691\series default
2692;
2693\layout LyX-Code
2694
2695/*
2696\layout LyX-Code
2697
2698 * Freeing the Rectangle_t
2699\layout LyX-Code
2700
2701 * and freeing the rect pointer
2702\layout LyX-Code
2703
2704 */
2705\layout LyX-Code
2706
2707asn1_DEF_Rectangle->free_struct(
2708\layout LyX-Code
2709
2710 &asn1_DEF_Rectangle, rect,
2711\emph on
27120
2713\emph default
2714 /* free the pointer too */);
2715\layout Standard
2716
2717It is safe to invoke the
2718\emph on
2719free_struct
2720\emph default
2721 function with the target structure pointer set to 0 (NULL), the function
2722 will do nothing.
2723\layout Bibliography
vlmfcec8e52004-08-23 15:12:04 +00002724\bibitem [ASN1C]{ASN1C}
2725
vlm89d219b2004-09-08 03:01:06 +00002726The OpenSource ASN.1 Compiler.
vlmfcec8e52004-08-23 15:12:04 +00002727
2728\begin_inset LatexCommand \htmlurl{http://lionet.info/asn1/}
2729
2730\end_inset
2731
2732
2733\layout Bibliography
vlme18adea2004-06-03 03:49:45 +00002734\bibitem [Dub00]{Dub00}
2735
2736Olivier Dubuisson --
2737\emph on
2738ASN.1 Communication between heterogeneous systems
2739\emph default
2740 -- Morgan Kaufmann Publishers, 2000.
2741
2742\begin_inset LatexCommand \htmlurl{http://asn1.elibel.tm.fr/en/book/}
2743
2744\end_inset
2745
2746.
2747 ISBN:0-12-6333361-0.
2748\layout Bibliography
2749\bibitem [ITU-T/ASN.1]{ITU-T/ASN.1}
2750
2751ITU-T Study Group 17 -- Languages for Telecommunication Systems
2752\begin_inset LatexCommand \url{http://www.itu.int/ITU-T/studygroups/com17/languages/}
2753
2754\end_inset
2755
2756
2757\the_end