How it Works

The compiler generates parser functions. These functions have the following signature:

         int asn1PP_&type> (OSCTXT* pctxt, ASN1RawEventResp parseIndicator);
      

Your program will begin by calling one of these parser functions and passing ASN1RER_PARSE. The parser function will parse the ASN.1 value and fire events by invoking your event handlers.

The interface supports three events:

The component event fires when a component is ready to be parsed. You receive the numeric identifier for the component (componentID), and a flag (nestedValues) which indicates whether component events may fire for child components. You may respond with:

The actual-type event fires when an open type is ready to be parsed. It notifies you of the actual type, allowing you to make type-specific decisions. This event only is only fired when -table-unions is used (otherwise, the parser does not attempt to determine the actual type). You receive the numeric identifier for the actual type (actualTypeID), and a length. If the actual type is unknown, the actualTypeID will be 0. If an open type is encoded with fragmentation and -perindef was not used, an error will be returned. Otherwise, the length will represent the defragmented length of the actual type encoding, and the context will hold a defragmented version of the encoding. Thus, your event handler does not need to worry about fragmentation.

The actual-type event is always preceded by a component event with nestedValues equal to true. If you respond to the component event with ASN1RER_CONSUMED or ASN1RER_QUIET_PARSE, the actual-type event will not fire. If you are not interested in receiving events for the open type value, responding to the component event with ASN1RER_QUIET_PARSE lets the parser skip past the open type value in the most efficient way.

You may respond to the actual-type event with:

Implementing a handler for the actual-type event is optional. If you do not implement a handler, the behavior is the same as if you did and returned ASN1RER_PARSE for every event.

The component-end event indicates that the end of a component value has been reached. You receive the numeric component identifier, the same as with the component event. As mentioned above, whether or not you receive this event depends on the nestedValues parameter of the component event, as well as how you respond to the component and/or actual-type events. Basically, if the event is not needed in order for you to know that you won't receive further events for the component, then the event is not fired.

Implementing a handler for the component-end event is optional.