Date: 2005-02-15T16:53:10
   Editor: EmmanuelLecharny
   Wiki: Apache Directory Project Wiki
   Page: TLVPageInfo
   URL: http://wiki.apache.org/directory/TLVPageInfo

   no comment

Change Log:

------------------------------------------------------------------------------
@@ -7,7 +7,46 @@
  * The '''Value''' part may contents other '''TLVs'''. One can see '''TLVs''' 
as C structures, that can contain sub-structures.
  * The '''Length''' part may not give the '''Value''' length : it is called an 
indefinite '''Length'''. Whatever, in this - not so frequent - case, the 
'''Value''' must end with a specific terminator.
 
-=== Exemple ===
+=== A quick sample ===
 Let's begin with a simple example, without too many explanations :
 
 attachment:TLVs.png
+
+We can see in this picture that you have what I called a first level TLV. It 
encapsulates other TLVs. 
+
+==== Tag ====
+The '''Tag''' element value is 0x30, we will see later its meaning. 
+
+==== Length ====
+The '''Length''' value is 0x0C, which is 12 is base 10. If you count the bytes 
after this '''Length''', you can easily see that there are 12 bytes. Ok, so 
'''Length''' means the number of bytes that contains the '''TLV'''. You can 
check for other '''Length''' that it matches. Good !
+
+So, for each encapsulating '''TLV''', we have the relation : '''Length''' = 
sum(included '''TLV''' bytes)
+
+We also have two '''TLVs''' with a zero '''Length'''. It's ok as we don't have 
any '''Value''' following.
+
+==== Value ====
+
+What about the '''Values'''? '''Length''' was easy, it was totally 
context-free. Which kind of '''Value''' can ve have? How do we know the type of 
each '''Value'''?
+
+First, we have seen that some '''Values''' are composed with '''TLVs'''. But 
we must have some kind of primitive '''Values''', like ''integer'' or 
''string''?
+
+The '''Tag''' element is the key. It give the type of the '''Value'''. In the 
previous picture, for instance, the second '''TLV''' code for an integer : 
''''02'''' means "I contain an integer". One can read ''''02 01 01'''' as "''An 
integer (02) which is 1 byte long (01) and which value is 1 (01)''".
+
+So, let's see other '''Tags''' : 04 code for an ''Octet String''. Here, we 
have two empty strings : ''Octet String'' (04) zero '''Length''' (00) in the 
two last '''TLVs'''
+
+0A (forth '''TLV''') means ''Enumerated''. This is a way to code a constrained 
value (i.e something in a set of values). Here, it's a 0 : ''An enumerated (0A) 
value which is 1 byte long (01) and which value is 0 (00)''. It does not give 
you a lot of information, as you can see: which kind of value is it suppose to 
be? 
+
+So far, so good, we have a kind of way to decode simple '''TLV'''. Let's call 
them '''Primitive'''. What about '''TLVs''' taht contains other '''TLVs'''? We 
will call them '''Constructed'''
+
+The first '''TLV''' has a '''Tag''' value of 30. This is a ''SEQUENCE'' of 
'''TLVs'''. A ''SEQUENCE'' is constructed by ordered '''TLVs'''. We can't 
exchange two '''TLVs''' in a ''SEQUENCE'', there is another '''Tag''' for that 
: a ''SET''. 
+
+The last '''TLV''' has a '''Tag''' value of 61. This is specific of a 
'''CHOICE''', where you have to choose between different cases, and here it's 
the first value that has been choosen (we can read 61 has a '''SEQUENCE''' 
number 1 of the alternative. Accept the explanation, it's quite complicated to 
give the reason why 61 is a '''SEQUENCE''' while 30 is also a '''SEQUENCE''').
+
+
+For any further information, one should read 
[http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf] which 
explain this encoding, but be aware that you also need to read 
[http://www.itu.int/ITU-T/studygroups/com17/languages/X.680-0207.pdf]. They are 
availaible for free, which is quite cheap compared to sleeping pills !
+
+=== Decoding TLVs ===
+
+=== Encoding TLVs ===
+
+=== TLVs : Novlang ? ===

Reply via email to