Mehmet Yilmaz wrote:
> hi,
>
> how can i represent the first field of an ip-header "version"
> in ASN.1 ?
>
> my mentor said, that INTEGER is not recommend.
>
Mehmet, actually mr. Sigona already answered you.
The key point is usage of unaligned PER as encoding rules.
I'd recommend to look through clauses 12, 13 and 10.5 from X691 (PER
encoding rules) for better understanding.
As for ASN notation, it may look like following:
-- version field definition using ENUMERATED
IP-VERSION-DEF-1 DEFINITIONS ::=
BEGIN
IPVersionId ::= ENUMERATED { ip-v4(4), st-dm(5), sip(6), tp-ix(7), pip(8),
tuba(9) }
END
-- version field definition using constained INTEGER
IP-VERSION-DEF-2 DEFINITIONS ::=
BEGIN
ip-v4 INTEGER ::= 4
st-dm INTEGER ::= 5
sip INTEGER ::= 6
tp-ix INTEGER ::= 7
pip INTEGER ::= 8
tuba INTEGER ::= 9
IPVersionId ::= INTEGER(0..15) (ip-v4 | st-dm | sip | tp-ix | pip | tuba)
END
-- IPVersionId may be inported from both IP-VERSION-DEF-1 and IP-VERSION-DEF-2
-- Encoding rules: PER UNALIGNED
IP-HEADER-DEF DEFINITIONS ::=
BEGIN
IMPORTS
IPVersionId
FROM IP-VERSION-DEF-1;
-- FROM IP-VERSION-DEF-2;
IPHeader-Octet1 ::= SEQUENCE {
version BIT STRING (SIZE(4)) ( CONTAINING IPVersionId ),
ihl BIT STRING (SIZE(4))
}
END
--
------------------
Roman V. Gerasimov
_______________________________________________
Asn1 mailing list
[email protected]
http://lists.asn1.org/mailman/listinfo/asn1