⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ospasn1parse.c

📁 mgcp协议源代码。支持多种编码:g711
💻 C
📖 第 1 页 / 共 5 页
字号:
/**########################################################################*########################################################################*########################################################################*                                                               *   COPYRIGHT (c) 1998, 1999 by TransNexus, LLC                          *                                                                    *   This software contains proprietary and confidential information  *   of TransNexus, LLC. Except as may be set forth in the license    *   agreement under which this software is supplied, use, disclosure, *   or reproduction is prohibited without the prior, express, written*   consent of TransNexus, LLC.                                      *                                     *******#########################################################################*#########################################################################*#########################################################################*//* * ospasn1parse.c - Member functions for ASN1 parsing library */#include "osp.h"#include "ospasn1.h"#include "osptnlog.h"/* ---------------------------------------------------------*//* Member functions                                         *//* ---------------------------------------------------------*/#if 0THE PARSE RESULTS TABLE WILL HAVE:    The parse results table will provide a cross reference for values found in        the element info list (derived from breaking down the asn1 encoded data)        Only the fields found will be included.  It will be the respsibility of the        program that called the parser to handle missing fields correctly.  The        parseing program must also handle multiple occurrances of a field.  This        table will only be returned if the parse is error free.            datafieldid     Number referenceing the data structure field data is stored in.            This will come from the parse table for an entry.                Scan table looking for this reference number when trying to                    populate data structure fields.  Scanning program must know                    if field is required, whether it can have multiple                        entries. etc.                        datafieldindex  If a data field id can have multiple occurances, then this                        value indicates which occurance it is. 0 indicates it is                        the only one.                          treeAddress     Tree address to the data.                         Format is 1.2.3: Last index should be a primitive.  Other                         indexes must be constructed.                          Count index following next pointers. Follow child pointer at                        period.                          null indicates not found.                        use this value to walk the tree to find the eInfo element.                        used for diagnostics only.                            eInfoPtr        Pointer to eInfo structure that contains the element                            related to the data structure field.  Extractor can access                            data by value, element, or element content.                            null indicates not found.                             defaultValuePtr Null indicates eInfoPtr should be followed for data.  If                                not null, then a void pointer is set to point to the                                default data contained in the parse table.  It is                                appliation dependent what is actually stored there.                                THE PARSING TABLE WILL HAVE:                                A complete description of the structure being parsed.  Default fields, etc                                must be described. All elements will be described.  The description will                                Fields must be in the order they occur in the table.                                  componentname   Used for diagnostics.                                    Textual description of the expected element.                                    parsetableid    Enum indicating a parse table to use for recursive parse.                                        if PRIMITIVE, (datafieldid != NONE), then no parsetable should                                             be followed - generate a parse result record and write it to                                             result table.                                            If constructed, recursively parse current element using                                             parsetableid to reference the appropriate parse table for the                                                element.                                                If SEQUENCE, then get subsequent elements in parse table.                                                If SET, then get subsequent elements in table, repeat according                 to the min/max fields.                                                 If SET_OF, then get subsequent elements in table, repeat                                                 according to min/max fields                                                If ANY_DEFINED_BY   ?                                                If ANY, then ?                                                If CHOICE, then ?                                                datafieldid     Field reference (context specific) to  used by calling                                                routine to reference the fields in the data structure.                                                When a parse result record is written, this datafieldid is                                                written to it so the calling program will have something to                                                search for to find data for a particular data structure                                                    field.                                                      ex: When the calling program is ready to populate the                                                    version number field for a certificate.  It would look                                                        for a record in the parse results table whose                                                            datafieldid is OSPE_ASN1_X509_CERT_FIELD_ID_VERSION.                                                            If it finds the record, it can go to the data through                                                            the eInfo pointer field, or if the eInfo pointer field                                                                is empty, it can get default data from the defaultvalue                                                                field in the parse results table.                                                                minimumnumber   Minimum number of this type of element                                                                maximumnumber   Maximum number of this type of element                                                                defaultvaluePtr If null, then no default data is provided.  If not null,                                                                then it is a void pointer to something.  pointer to a                                                                number, pointer to a string (ASN1 encoding of the defualt value.                                                                Initialize the parse table as necessary.  Assume the                                                                reading application will figure out what to do with the                                                                    pointer it finds. If not null, then a parse error occurs                                                                    when an element is not found if a minimum is required.                                                                        BOOLEAN TYPE IS A PRIMITIVE 0x01 0x01 0xFF(TRUE) 0x00(FALSE)#endif                                                                              static OSPTASN1PARSETABLE ospgParseTable_NotDefined[] =                                                                        {                                                                            {"NotDefined",          OSPC_TAG_TYPE_NULL,                                                                                                         OSPEPTID_NOTDEFINED,    0x0, 0, 0, 0, 0},                                                                            {OSPC_OSNULL}                                                                        };static OSPTASN1PARSETABLE ospgParseTable_Certificate[] ={    {"Certificate",         OSPC_TAG_TYPE_SEQUENCE,                                     OSPEPTID_NOTDEFINED,    0x0, 1, 1, 0, 0},    {"tbsCertificate",      OSPC_TAG_TYPE_DERIVED,                                      OSPEPTID_TBSCERTIFICATE,0x1, 1, 1, 0, 0},    {"signatureAlgorithm",  OSPC_TAG_TYPE_DERIVED,                                      OSPEPTID_DERALGORITHMID,0x2, 1, 1, 0, 0},    {"signature",           OSPC_TAG_TYPE_BIT_STRING,                                   OSPEPTID_NOTDEFINED,    0x3, 1, 1, 0, 0},    {OSPC_OSNULL}}; static OSPTASN1PARSETABLE ospgParseTable_TBSCertificate[] ={    {"TBSCertificate",      OSPC_TAG_TYPE_SEQUENCE,                                 OSPEPTID_NOTDEFINED,    0x0, 1, 1, 0, 0},    {"version",             OSPC_TAG_TYPE_DERIVED,                                  OSPEPTID_EXPLICIT_VERSION,                                                          0x1, 1, 1, 1, 0},    {"serialNumber",        OSPC_TAG_TYPE_DERIVED,                                  OSPEPTID_CERTSERIALNUM, 0x2, 1, 1, 0, 0},    {"signature",           OSPC_TAG_TYPE_DERIVED,                                  OSPEPTID_DERALGORITHMID,0x3, 1, 1, 0, 0},    {"issuer",              OSPC_TAG_TYPE_DERIVED,                                  OSPEPTID_RDNSEQUENCE,   0x4, 1, 1, 0, 0},    {"validity",            OSPC_TAG_TYPE_DERIVED,                                  OSPEPTID_VALIDITY,      0x5, 1, 1, 0, 0},    {"subject",             OSPC_TAG_TYPE_DERIVED,                                  OSPEPTID_RDNSEQUENCE,   0x6, 1, 1, 0, 0},    {"subjectPublicKeyInfo",OSPC_TAG_TYPE_DERIVED,                                  OSPEPTID_SUBJPUBKEYINFO,0x7, 1, 1, 0, 0},    {"issuerUniqueID",      OSPC_TAG_TYPE_DERIVED,                                  OSPEPTID_ISSUERUNIQUEID,                                                        0x8, 0, 1, 0, 0},    {"subjectUniqueID",     OSPC_TAG_TYPE_DERIVED,                                  OSPEPTID_SUBJECTUNIQUEID,                                                        0x9, 0, 1, 0, 0},    {"extensions",          OSPC_TAG_TYPE_DERIVED,                                  OSPEPTID_EXPLICIT_EXTENSIONS,                                                           0xa, 0, 1, 0, 0},    {OSPC_OSNULL}}; static OSPTASN1PARSETABLE ospgParseTable_SignatureAlgorithm[] ={    {"SignatureAlgorithm",  OSPC_TAG_TYPE_DERIVED,                                  OSPEPTID_DERALGORITHMID,0x0, 1, 1, 0, 0},    {OSPC_OSNULL}}; static OSPTASN1PARSETABLE ospgParseTable_DERAlgorithmId[] ={    {"AlgorithmId",         OSPC_TAG_TYPE_DER_FORMAT,                                   OSPEPTID_NOTDEFINED,    0x0,1, 1, 0, 0},    {OSPC_OSNULL}    /* May need to expand this definition to get all the pieces. */}; static OSPTASN1PARSETABLE ospgParseTable_Explicit_Version[] ={    {"ExplicitVersion",     OSPM_TAG_TYPE_EXPLICIT_TAG(0),                                  OSPEPTID_NOTDEFINED,    0x0, 1, 1, 1, 0},    {"version",             OSPC_TAG_TYPE_DERIVED,                                      OSPEPTID_NOTDEFINED,    0x1, 1, 1, 1, 0},    {OSPC_OSNULL}}; static OSPTASN1PARSETABLE ospgParseTable_Version[] ={    {"Version",     OSPC_TAG_TYPE_INTEGER,                                  OSPEPTID_NOTDEFINED,    0x0, 1, 1, 1, 0},    {OSPC_OSNULL}}; static OSPTASN1PARSETABLE ospgParseTable_CertSerialNum[] ={    {"CertSerialNum",       OSPC_TAG_TYPE_INTEGER,                                      OSPEPTID_NOTDEFINED,    0x0, 1, 1, 0, 0},    {OSPC_OSNULL}}; static OSPTASN1PARSETABLE ospgParseTable_Name[] ={    {"Name",                OSPC_TAG_TYPE_DERIVED,                                  OSPEPTID_RDNSEQUENCE,   0x0, 1, 1, 0, 0},    {OSPC_OSNULL}    /* This definition is strange because Name is a CHOICE of RDNSequence.          Choice does not generate an element. Special handling at beginning         of element parse to handle parse tables with first entry of Type         Tag "CONSTRUCTED" to have it immediately parse new element. */}; static OSPTASN1PARSETABLE ospgParseTable_RDNSequence[] ={    {"RDNSequence",         OSPC_TAG_TYPE_SEQUENCE,                                     OSPEPTID_NOTDEFINED,    0x0, 1, 0xff, 0, 0},    {"relDisName",          OSPC_TAG_TYPE_DERIVED,                                  OSPEPTID_RELDISNAME,    0x1, 0, 0xff, 0, 0},    {OSPC_OSNULL}}; static OSPTASN1PARSETABLE ospgParseTable_RelDisName[] ={    {"RelDisName",          OSPC_TAG_TYPE_SET,                                      OSPEPTID_NOTDEFINED,    0x0, 1, 0xff, 0, 0},    {"attrTypeAndVal",      OSPC_TAG_TYPE_DERIVED,                                  OSPEPTID_ATTRTYPEANDVAL,0x1, 1, 0xff, 0, 0},    {OSPC_OSNULL}}; static OSPTASN1PARSETABLE ospgParseTable_AttrTypeAndValue[] ={    {"AttrTypeAndVal",      OSPC_TAG_TYPE_SEQUENCE,                                     OSPEPTID_NOTDEFINED,    0x0, 0, 1, 0, 0},    {"type",                OSPC_TAG_TYPE_DERIVED,                                  OSPEPTID_ATTRIBUTETYPE, 0x1, 1, 1, 0, 0},    {"value",               OSPC_TAG_TYPE_DERIVED,                                  OSPEPTID_ATTRIBUTEVALUE,0x2, 1, 1, 0, 0},    {OSPC_OSNULL}}; static OSPTASN1PARSETABLE ospgParseTable_AttributeType[] ={    {"AttributeType",       OSPC_TAG_TYPE_OBJECT_IDENTIFIER,                                OSPEPTID_NOTDEFINED,    0x0, 1, 1, 0, 0},    {OSPC_OSNULL}}; static OSPTASN1PARSETABLE ospgParseTable_AttributeValue[] ={    {"AttributeValue",      OSPC_TAG_TYPE_PRINTABLESTRING,                                  OSPEPTID_NOTDEFINED,    0x0, 0, 1, 0, 0},    {"AttributeValue",      OSPC_TAG_TYPE_T61STRING,                                    OSPEPTID_NOTDEFINED,    0x0, 0, 1, 0, 0},    {"AttributeValue",      OSPC_TAG_TYPE_IA5STRING,                                    OSPEPTID_NOTDEFINED,    0x0, 0, 1, 0, 0},    {OSPC_OSNULL}

⌨️ 快捷键说明

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