Question

Declaration IpAddress using Abstract Syntax Notation:

IpAddress ::= [APPLICATION 1] INTEGER (0..4294967295)

What does [APPLICATION 1] means in this code?!

Was it helpful?

Solution

Note: This question is tagged SNMP, but this is not the proper declaration for SNMP's IpAddress type. This is actually a Counter32 type:

IpAddress ::= [APPLICATION 0] IMPLICIT OCTET STRING (SIZE (4))

Counter32 ::= [APPLICATION 1] IMPLICIT INTEGER (0..4294967295)

RFC 2578

However;

An ASN.1 type has both a notation and an on-the-wire encoding. New types can be defined based on built-in types. In your question, a new type "IpAddress" is being defined as a finite-ranged (0..4294967295) derivation of the built-in "INTEGER" type, which has no built-in range restriction.

An ASN.1 encoding consists of three parts: a one-byte tag indicating the data type, a length for the content, and the content (value) itself. Without the part in [brackets], the encoding of the new type would be identical to the base type--in this case INTEGER, which has a tag value of 0x02 (hex). [APPLICATION 1] indicates that the value is to be encoded with a different tag so that you can distinguish its encoding from an INTEGER.

This part in [brackets] consists of an Tag Class and a Number. The Class can be UNIVERSAL (only used for built-in ASN.1 types), APPLICATION (which means application specific, i.e. [APPLICATION 1] to SNMP may mean something entirely different to [APPLICATION 1] in another protocol), PRIVATE for enterprise-specific, or may be omitted (in which case it is context-specific).

The Tag Class and Number are essentially bit flags that are or'ed together to form the tag value in the encoding. APPLICATION = 0x40, so [APPLICATION 1] means the value defined as in your question is encoded with a tag byte of 0x41.

However, as I mentioned above, this would actually be taken by SNMP to be a Counter32 value, not an IpAddress. 0x40 would be an IpAddress, and the contents would be encoded as an OCTET STRING rather than an INTEGER.

OTHER TIPS

It simply means "application-wide". Such types are not available in ASN.1, but available in SNMP (an application of ASN.1).

https://www.rfc-editor.org/rfc/rfc1155

Section 3.2.3 gives more information on this.

The value behind APPLICATION is finally used in data encoding, to distinguish the types from each other.

You actually type something wrong, as IpAddress should use value 0, not 1.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top