How do I tell the compiler to generate a long instead of a short for each OBJECT IDENTIFIER node value? I'm using the linked list representation of the OBJECT IDENTIFIER and the ASN.1 compiler is generating a short to hold the node values. However, one of the nodes has a value of 25602, which is too large to fit in a short on my platform.

There are two choices: use the OSS.LONG directive, or use the OSS.ENCODED directive.

Suppose you add the OSS.LONG directive to your ASN.1 specification. For example, the ASN.1 specification with no OSS.LONG directive:

Module DEFINITIONS ::= BEGIN
    DataPacket ::= SEQUENCE {
        branchID OBJECT IDENTIFIER --<LINKED>-- ,
        branchName IA5String
    }
END

results in:

#define DataPacket_PDU 1

typedef struct DataPacket {
     struct _objid1 {
        struct _objid1 *next;
        unsigned short value;
    } *branchID;
    char *branchName;
} DataPacket;

However if you add the OSS.LONG directive as follows:

Module DEFINITIONS ::= BEGIN
    DataPacket ::= SEQUENCE {
        branchID OBJECT IDENTIFIER --<LINKED | LONG>-- ,
        branchName IA5String
    }
END

the resultant header file contains:

#define DataPacket_PDU 1

typedef struct DataPacket {
    struct _objid1 {
        struct _objid1 *next;
        unsigned long value;
    } *branchID;
    char *branchName;
} DataPacket;

However, note that OSS recommends you use the ENCODED representation for OBJECT IDENTIFIER values instead of the old linked-list representation. This representation consists of a structure which contains a length in octets and an address of an array of characters containing the BER-encoded contents of the OBJECT IDENTIFIER. (For example., {1 2 3 4 5} would be stored as: {0x2A, 0x03, 0x04, 0x05}). This permits the representation of OBJECT IDENTIFIER types with node values exceeding the maximum integer representation on a given machine (i.e. 64-bit OBJECT IDENTIFIERs are supported on all platforms through this representation). In addition, you will find values in this representation easier to copy and compare. Also, this representation results in the most CPU-efficient runtime handling.

Starting with version 5.0, the ENCODED representation is used by default. If you use a previous version, you can explicitly specify this representation by specifying the --<OBJECTID ENCODED>-- directive. For more information, refer to the description of the OSS.OBJECTID compiler directive.


The samples included with some of the Knowledge Center answers are meant for your general understanding of the OSS products. Different versions of the products might produce slightly different outputs. Consult the products documentation and samples for the most up-to-date products information and code examples.



Contact Support
contact Our office hours
24 hours/day, 7 days/week

  • Phone: 1-888-OSS-2761 (USA and Canada)
  • Phone: 1-732-302-9669 (International)
  • Fax: 1-732-302-0023
  • Email: support@oss.com
Free Trial
download

Test drive the OSS Nokalva ASN.1, LTE, and XML Tools now! Your trial includes complete software, documentation, sample programs, free 24x7 technical support and more.




Learn ASN.1
Learn ASN.1

Our expert personnel can help you learn ASN.1!

We offer 4-day ASN.1 courses at our headquarters or your premises.