ooasn1.h

来自「一个非常美妙的proxy。功能强大。基于sip的协议。如果还要的话」· C头文件 代码 · 共 1,600 行 · 第 1/5 页

H
1,600
字号
/* * Copyright (C) 1997-2005 by Objective Systems, Inc. * * This software is furnished under an open source license and may be  * used and copied only in accordance with the terms of this license.  * The text of the license may generally be found in the root  * directory of this installation in the COPYING file.  It  * can also be viewed online at the following URL: * *   http://www.obj-sys.com/open/license.html * * Any redistributions of this file including modified versions must  * maintain this copyright notice. * *****************************************************************************//**  * @file ooasn1.h  * Common ASN.1 runtime constants, data structure definitions, and run-time * functions to support ASN.1 PER encoding/decoding as defined in the  * ITU-T standards. */#ifndef _OOASN1_H_#define _OOASN1_H_#include <limits.h>#include <stdio.h>#include <string.h>#include <stddef.h>#include "dlist.h"#include "ootrace.h"/**  * @defgroup cruntime C Runtime Common Functions  * @{ *//* Tagging Value and Mask Constants *//* tag class value constants */#define TV_UNIV         0       /* universal                    */#define TV_APPL         1       /* application-wide             */#define TV_CTXT         2       /* context-specific             */#define TV_PRIV         3       /* private-use                  *//* tag form value constants */#define TV_PRIM         0       /* primitive                    */#define TV_CONS         1       /* constructor                  *//* tag mask values - these can be logically or'd together to    *//* form tags compatible with the ASNTAG structure..             */#define TM_UNIV         0x00000000  /* universal class          */#define TM_APPL         0x40000000  /* application-wide class   */#define TM_CTXT         0x80000000  /* context-specific class   */#define TM_PRIV         0xC0000000  /* private-use class        */#define TM_PRIM         0x00000000  /* primitive form           */#define TM_CONS         0x20000000  /* constructor form         */#define TM_IDCODE       0x1FFFFFFF  /* ID code mask             */#define ASN_K_BADTAG    0xFFFFFFFF  /* invalid tag code         */#define ASN_K_NOTAG     0xFFFFFFFF  /* no tag input parameter   */#define TM_CLASS        0xC0    /* class mask                   */#define TM_FORM         0x20    /* form mask                    */#define TM_CLASS_FORM   0xE0    /* class/form mask              */#define TM_B_IDCODE     0x1F    /* id code mask (byte)          */#define MINMSGLEN       8       /* minimum message length               *//* Error Code Constants */#define ASN_OK            0      /* normal completion status             */#define ASN_OK_FRAG       2      /* message fragment detected            */#define ASN_E_BUFOVFLW   -1      /* encode buffer overflow               */#define ASN_E_ENDOFBUF   -2      /* unexpected end of buffer on decode   */#define ASN_E_IDNOTFOU   -3      /* identifer not found                  */#define ASN_E_INVOBJID   -4      /* invalid object identifier            */#define ASN_E_INVLEN     -5      /* invalid field length                 */#define ASN_E_INVENUM    -6      /* enumerated value not in defined set  */#define ASN_E_SETDUPL    -7      /* duplicate element in set             */#define ASN_E_SETMISRQ   -8      /* missing required element in set      */#define ASN_E_NOTINSET   -9      /* element not part of set              */#define ASN_E_SEQOVFLW   -10     /* sequence of field overflow           */#define ASN_E_INVOPT     -11     /* invalid option encountered in choice */#define ASN_E_NOMEM      -12     /* no dynamic memory available          */#define ASN_E_INVHEXS    -14     /* invalid hex string                   */#define ASN_E_INVBINS    -15     /* invalid binary string                */#define ASN_E_INVREAL    -16     /* invalid real value                   */#define ASN_E_STROVFLW   -17     /* octet or bit string field overflow   */#define ASN_E_BADVALUE   -18     /* invalid value specification          */#define ASN_E_UNDEFVAL   -19     /* no def found for ref'd defined value */#define ASN_E_UNDEFTYP   -20     /* no def found for ref'd defined type  */#define ASN_E_BADTAG     -21     /* invalid tag value                    */#define ASN_E_TOODEEP    -22     /* nesting level is too deep            */#define ASN_E_CONSVIO    -23     /* value constraint violation           */#define ASN_E_RANGERR    -24     /* invalid range (lower > upper)        */#define ASN_E_ENDOFFILE  -25     /* end of file on file decode           */#define ASN_E_INVUTF8    -26     /* invalid UTF-8 encoding               */#define ASN_E_CONCMODF   -27     /* Concurrent list modification         */#define ASN_E_ILLSTATE   -28     /* Illegal state error                  */#define ASN_E_OUTOFBND   -29     /* out of bounds (of array, etc)        */#define ASN_E_INVPARAM   -30     /* invalid parameter                    */#define ASN_E_INVFORMAT  -31     /* invalid time string format           */#define ASN_E_NOTINIT    -32     /* not initialized                      */#define ASN_E_TOOBIG     -33     /* value is too big for given data type */#define ASN_E_INVCHAR    -34     /* invalid character (not in char set)  */#define ASN_E_XMLSTATE   -35     /* XML state error                      */#define ASN_E_XMLPARSE   -36     /* XML parse error                      */#define ASN_E_SEQORDER   -37     /* SEQUENCE elements not in order       */#define ASN_E_INVINDEX   -38     /* invalid index for TC id              */#define ASN_E_INVTCVAL   -39     /* invalid value for TC field           */#define ASN_E_FILNOTFOU  -40     /* file not found                       */#define ASN_E_FILEREAD   -41     /* error occurred reading file          */#define ASN_E_FILEWRITE  -42     /* error occurred writing file          */#define ASN_E_INVBASE64  -43     /* invalid base64 encoding              */#define ASN_E_INVSOCKET  -44     /* invalid socket operation             */#define ASN_E_XMLLIBNFOU -45     /* XML library is not found             */#define ASN_E_XMLLIBINV  -46     /* XML library is invalid               */#define ASN_E_NOTSUPP    -99     /* non-supported ASN construct          */#define ASN_K_INDEFLEN   -9999   /* indefinite length message indicator  *//* universal built-in type ID code value constants */#define ASN_ID_EOC      0       /* end of contents              */#define ASN_ID_BOOL     1       /* boolean                      */#define ASN_ID_INT      2       /* integer                      */#define ASN_ID_BITSTR   3       /* bit string                   */#define ASN_ID_OCTSTR   4       /* byte (octet) string          */#define ASN_ID_NULL     5       /* null                         */#define ASN_ID_OBJID    6       /* object ID                    */#define ASN_ID_OBJDSC   7       /* object descriptor            */#define ASN_ID_EXTERN   8       /* external type                */#define ASN_ID_REAL     9       /* real                         */#define ASN_ID_ENUM     10      /* enumerated value             */#define ASN_ID_EPDV     11      /* EmbeddedPDV type             */#define ASN_ID_RELOID   13      /* relative object ID           */#define ASN_ID_SEQ      16      /* sequence, sequence of        */#define ASN_ID_SET      17      /* set, set of                  */#define ASN_SEQ_TAG     0x30    /* SEQUENCE universal tag byte  */#define ASN_SET_TAG     0x31    /* SET universal tag byte       *//* Restricted character string type ID's */#define ASN_ID_NumericString    18#define ASN_ID_PrintableString  19#define ASN_ID_TeletexString    20#define ASN_ID_T61String        ASN_ID_TeletexString#define ASN_ID_VideotexString   21#define ASN_ID_IA5String        22#define ASN_ID_UTCTime          23#define ASN_ID_GeneralTime      24#define ASN_ID_GraphicString    25#define ASN_ID_VisibleString    26#define ASN_ID_GeneralString    27#define ASN_ID_UniversalString  28#define ASN_ID_BMPString        30/* flag mask values */#define XM_SEEK         0x01    /* seek match until found or end-of-buf */#define XM_ADVANCE      0x02    /* advance pointer to contents on match */#define XM_DYNAMIC      0x04    /* alloc dyn mem for decoded variable   */#define XM_SKIP         0x08    /* skip to next field after parsing tag *//* Sizing Constants */#define ASN_K_MAXDEPTH  32      /* maximum nesting depth for messages   */#define ASN_K_MAXSUBIDS 128     /* maximum sub-id's in an object ID     */#define ASN_K_MAXENUM   100     /* maximum enum values in an enum type  */#define ASN_K_MAXERRP   5       /* maximum error parameters             */#define ASN_K_MAXERRSTK 8       /* maximum levels on error ctxt stack   */#define ASN_K_ENCBUFSIZ 2*1024 /* dynamic encode buffer extent size    */#define ASN_K_MEMBUFSEG 1024    /* memory buffer extent size            *//* Canonical character set definitions */#define NUM_ABITS  4#define NUM_UBITS  4#define NUM_CANSET \" 0123456789"#define PRN_ABITS  8#define PRN_UBITS  7#define PRN_CANSET \" '()+,-./0123456789:=?ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"#define VIS_ABITS  8#define VIS_UBITS  7#define VIS_CANSET \" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]"\"^_`abcdefghijklmnopqrstuvwxyz{|}~"#define T61_ABITS  8#define T61_UBITS  7#define T61_CANSET \" !\"%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]"\"_abcdefghijklmnopqrstuvwxyz"#define IA5_ABITS  8#define IA5_UBITS  7#define IA5_CANSET \"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017"\"\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"\" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]"\"^_`abcdefghijklmnopqrstuvwxyz{|}~"#define IA5_RANGE1_LOWER 0#define IA5_RANGE2_LOWER 0x5f#define GEN_ABITS  8#define GEN_UBITS  7#define GEN_CANSET \"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017"\"\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"\" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"\"`abcdefghijklmnopqrstuvwxyz{|}~\177\200\201\202\203\204\205\206\207"\"\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237"\"\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257"\"\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277"\"\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317"\"\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337"\"\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357"\"\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377"#define BMP_ABITS  16#define BMP_UBITS  16#define BMP_FIRST  0#define BMP_LAST   0xffff#define UCS_ABITS  32#define UCS_UBITS  32#define UCS_FIRST  0#define UCS_LAST   0xfffffffful/* ASN.1 Primitive Type Definitions */typedef char            ASN1CHAR;typedef unsigned char   ASN1OCTET;typedef ASN1OCTET       ASN1BOOL;typedef signed char     ASN1INT8;typedef unsigned char   ASN1UINT8;typedef int             ASN1INT;typedef unsigned int    ASN1UINT;typedef ASN1INT         ASN1ENUM;typedef double          ASN1REAL;typedef short           ASN1SINT;typedef unsigned short  ASN1USINT;typedef ASN1UINT        ASN1TAG;#define ASN1TAG_LSHIFT  24typedef ASN1USINT       ASN116BITCHAR;typedef ASN1UINT        ASN132BITCHAR;typedef void*           ASN1ANY;#define ASN1UINT_MAX    4294967295U#define ASN1INT_MAX     ((ASN1INT)2147483647L)#define ASN1INT_MIN     ((ASN1INT)(-ASN1INT_MAX-1))#ifndef ASN1INT64#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) || \defined(_WIN32)#define ASN1INT64 __int64#elif defined(__IBMC__) || defined(__GNUC__) || defined(__SUNPRO_C) || \defined(__SUNPRO_CC) || defined(__CC_ARM) || \defined(__HPUX_CC__) || defined(__HP_aCC) #define ASN1INT64 long long#else  /* !MSC_VER && !__IBMC__ etc */#define ASN1INT64 long#endif#endif /* ASN1INT64 */#ifndef FALSE#define FALSE           0#define TRUE            1#endiftypedef struct {        /* object identifier */   ASN1UINT     numids;   ASN1UINT     subid[ASN_K_MAXSUBIDS];} ASN1OBJID;typedef struct {        /* generic octet string structure */   ASN1UINT     numocts;   ASN1OCTET    data[1];} ASN1OctStr;typedef struct {        /* generic octet string structure (dynamic) */   ASN1UINT     numocts;   const ASN1OCTET* data;} ASN1DynOctStr;typedef struct {        /* generic bit string structure (dynamic) */   ASN1UINT     numbits;   const ASN1OCTET* data;} ASN1DynBitStr;typedef struct {                /* generic sequence of structure        */   ASN1UINT     n;   void*        elem;} ASN1SeqOf;typedef struct {                /* sequence of OCTET STRING             */   ASN1UINT     n;   ASN1DynOctStr* elem;} ASN1SeqOfOctStr;typedef struct {                /* generic open type data structure     */   ASN1UINT     numocts;   const ASN1OCTET* data;} ASN1OpenType;/* ASN.1 useful type definitions */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?