Subject: Re: SDL-News: size_of_variable_structs
From: Rick Reed TSE (rickreed#tseng.co.uk)
Date: Thu May 10 2001 - 20:44:38 GMT
Become an SDL Forum Society member <http://www.sdl-forum.org/Society/members.htm>
The originator of this message is responsible for its content.
-----From Rick Reed TSE <rickreed#tseng.co.uk> to sdlnews -----
Rui Silva at rmss#cris.inesc.pt wrote on 09/05/2001 23:20:
> Dear Colleagues,
> I'm member of SDL Forum, but I just work on real SDL about some months, and
> I'm with a problem that probably for you more experienced with 'our'
> language could be simple, so here it goes:
> - I'm using ASN.1 in my SDL system, but the ASN.1 SEQUENCES, that are
> trasnlated to SDL structs, will have a variable length, because the size of
> some fields depends of the filling value(for instance, a 'name of a
> - This way, the point of my question to you is: "There are any way(SDL
> function) to calculate efficiently the number of bytes(the size) of a filled
> struct, like there is in C the siizeof function" ?
As you sent this request to the public news list, I have include that list
on this reply as well.
An ASN.1 SEQUENCE translates into an SDL STRUCT where each of the fields of
the STRUCT corresponds to a component of the SEQUENCE. The STRUCT will be of
"variable size" only if one or more of the components of the SEQUENCE is of
For the example that you give, the ASN.1 component would probably be of type
IA5String. Alternatively the ASN.1 type of a component may be some other
ASN.1 type that is a string of components all the same defined by SEQUENCE
OF type. IA5String translates into an SDL Charstring and other SEQUENCE OF
types translate into an SDL String with elements of the ASN.1 component
type. BIT STRING and OCTET STRING translate into the SDL Bit_String and
Octet_String. For all these String types the operator "length" is defined
which gives the length of the String in terms of the string elements.
An component of an ASN.1 SEQUENCE can also be of "variable size" if it as
SET OF type, which translates to an SDL Bag; or if it is a SEQUENCE (or SET
- these are treated the same as far as SDL is concerned) that contains a
component that is a "variable size".
Neither ASN.1 (syntax in X.680) nor SDL say anything about the encoding of
type, and (for example) both languages assume by default there is no upper
bound to the Integer type. Even for simple types, such as Integer, it is not
possible to know how large they might be unless you know how they are
encoded, and the size could be variable. While this might be just what you
need for specification, this means that any measure of size in terms of byte
must be implementation dependent.
The result is that as far as SDL is concerned there is no general function
or procedure that gives the size of a type in bytes or bits, and no function
that gives the size of in bytes or bits of a "variable size". To know the
size of a STRUCT you have to know the size of each of its components which
requires knowledge of how it is implemented. However, if you have that
knowledge you can then define an operator or procedure that gives the
dynamic size of the STRUCT.
This knowledge may not be easy to find for complex types, because usually
SDL is translated into C or C++ so that the actual encoding of ASN.1 types
will depend on the SDT to C translator and the C compiler.
NOTE that ASN.1 to SDL mapping should not be tool dependent but is defined
So the result is - you can measure the size of SEQUENCES in terms of
Components but you need additional information to turn this into bytes or
-- Rick Reed - rickreed#tseng.co.uk Tel:+44 1455 55 96 55 Fax:+44 1455 55 96 58 Mob.:+44 7970 50 96 50
--End text from Rick Reed TSE <rickreed#tseng.co.uk> to sdlnews --- For extra SDL Forum Society benefits join at <http://www.sdl-forum.org/Society/members.htm>
This archive was generated by hypermail 2a23 : Thu May 09 2013 - 16:05:49 GMT