SilcAsn1Options

NAME

    typedef enum { ... } SilcAsn1Options;

DESCRIPTION

Options for ASN.1 encoder and decoder. The ASN.1 options can be given to the SILC_ASN1_*_T macros and/or SILC_ASN1_OPTS macro.

NOTES

The SILC_ASN1_ALLOC and SILC_ASN1_ACCUMUL flags can be given only with SILC_ASN1_OPTS macro. Other options can be given with various SILC_ASN1_*_T macros.

EXAMPLE

    // Encodes boolean value with explicit tag and private class, and
    // the result is allocated into `dest'.
    silc_asn1_encode(asn1, &dest,
                     SILC_ASN1_OPTS(SILC_ASN1_ALLOC),
                     SILC_ASN1_BOOLEAN_T(SILC_ASN1_PRIVATE |
                                         SILC_ASN1_EXPLICIT, 100, boolval),
                     SILC_ASN1_END);

    // Decode optional value, with SILC_ASN1_OPTIONAL the type must be
    // a pointer so that NULL can be returned if the type is not present.
    SilcBool *val;

    silc_asn1_decode(asn1, src,
                     SILC_ASN1_OPTS(SILC_ASN1_OPTIONAL),
                     SILC_ASN1_BOOLEAN(&val),
                     SILC_ASN1_END);

    // If val == NULL, the optional value was not present
    if (val == NULL)
      error;

SOURCE

typedef enum {
  /* Default. If only this is set then defaults are implied. */
  SILC_ASN1_DEFAULT      = 0x0000,

  /* Class options.  User does not need to set these unless specifically
     wanted to do so.  If SILC_ASN1_DEFAULT is set the SILC_ASN1_CONTEXT is
     implied if any of the tag options are set.  Otherwise SILC_ASN1_UNIVERSAL
     is implied. Only one of these can bet set at once. */
  SILC_ASN1_UNIVERSAL    = 0x0001,       /* Universal class (default) */
  SILC_ASN1_APP          = 0x0002,       /* Application specific class */
  SILC_ASN1_CONTEXT      = 0x0003,       /* Context specific class */
  SILC_ASN1_PRIVATE      = 0x0004,       /* Private class */

  /* Tag options (bitmask) */
  SILC_ASN1_IMPLICIT     = 0x0010,       /* Tag is implicit (default) */
  SILC_ASN1_EXPLICIT     = 0x0020,       /* Tag is explicit */
  SILC_ASN1_DEFINITE     = 0x0040,       /* Length is definite (default) */
  SILC_ASN1_INDEFINITE   = 0x0080,       /* Length is indefinite */

  /* Decoding options (bitmask) */
  SILC_ASN1_OPTIONAL     = 0x0100,       /* Zero or more may be found.  The
                                            argument must be pointer to the
                                            type pointer so that NULL can be
                                            returned if type is not found. */

  /* ASN.1 encoder/decoder options (bitmask).  These can be given
     only with SILC_ASN1_OPTS macro at the start of encoding/decoding. */
  SILC_ASN1_ALLOC        = 0x0400,       /* Dynamically allocate results,
                                            or if stack was given to
                                            silc_asn1_alloc, they are allocated
                                            and consumed from the stack. */
  SILC_ASN1_ACCUMUL      = 0x0800,       /* Accumulate memory for results,
                                            next call to silc_asn1_decode
                                            will not cancel old results. */
} SilcAsn1Options;