//  ==========================================================================
//  
//  @(#) $Id: TCAP_Codec.C,v 1.4 2000/10/19 03:21:57 brian Exp $
//  
//  --------------------------------------------------------------------------
//  
//  Copyright (C) 1997-2000  Brian Bidulock <bidulock@dallas.net>
//  
//  All Rights Reserved.
//  
//  This library is free software; you can redistribute it and/or modify it
//  under the terms of the GNU Lesser General Public License as published by
//  the Free Software Foundation; either version 2.1 of the License, or (at
//  your option) any later version.
//  
//  This library is distributed in the hope that it will be useful, but
//  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
//  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser Public License
//  for more details.
//  
//  You should have received a copy of the GNU Lesser General Public License
//  along with this library; if not, write to the Free Software Foundation,
//  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
// 
//  Last Modified $Date: 2000/10/19 03:21:57 $ by $Author: brian $
// 
//  --------------------------------------------------------------------------
// 
//  $Log: TCAP_Codec.C,v $
//  Revision 1.4  2000/10/19 03:21:57  brian
//  Whoops, messed up when adding headers.
//
//  Revision 1.3  2000/10/13 15:45:51  brian
//  First public release.
//
//  ==========================================================================

static char const ident[] = "$Id: TCAP_Codec.C,v 1.4 2000/10/19 03:21:57 brian Exp $";

#pragma implementation

#include "TCAP_Codec.H"

Codec_TAG::Codec_TAG(char* l,char* t,Field* prefix) :
{
};

Codec_LEN::Codec_LEN(char* l,char* t,int form,Field* prefix) :
{
};

Codec_TAGnLEN::Codec_TAGnLEN(char* l,char* t,int f,int c,Codec* cont) :
    Parameter(l,t,16,7,0,(Codec**)&PRE) {
    form  = f;  // expected form  (use -1 for don't care)
    class = c;  // expected class (use -1 for don't care)
    TAG_PRE = new Field("TAG-","Tag Prefix",5,0);
    FORM = new Set("FORM","Form",1,0,
        "FORM0",    0,  "Primitive",
        "FORM1",    1,  "Contructor",
        NULL);
    CLASS = new Set("CLASS","Class",2,0,
        "CLASS0",   0,  "Universal",
        "CLASS1",   1,  "Application-wide",
        "CLASS2",   2,  "Context-specific",
        "CLASS3",   3,  "Private use",
        NULL);
    TAG = new Codec_TAG("TAG","Tag",TAG_PRE);
    LEN_PRE = new Field("LEN-","Length Prefix",8,0);
    LEN = new Codec_LEN("LEN","Length",form,LEN_PRE);
    CONTENTS = cont->copy();
};

void
Codec_TAG::decode(FramePointer& p) {
};

void
Codec_TAG::encode(FramePointer& p) {
};

void
Codec_TAG::report() {
    if (!exists&&!invalid) return;
    frame.size -= spare;
    value = (

Codec_TCAP::Codec_TCAP() : Header("TCAP","TCAP Message",-1,?,?) {

    UPARM

    UNIV_B = new Bra(NULL,NULL,NULL,
        PSEQ,    16, // Parameter Sequence
        UTC,     23, // Universal Time
    NULL);

    CTXT_B = new Bra(NULL,NULL,NULL,
        ACG,      1, // ACG Indicators
        STA,      2, // Standard Announcement
        CUA,      3, // Customized Announcement
        TDIG,     4, // Digits
        SUEC,     5, // Standard User Error Code
        PDTA,     6, // Problem Data
        TCGPA,    7, // SCCP Calling Party Address
        TRANSID,  8, // Transaction ID
        PCTY,     9, // Package Type
        SKEY,    10, // Service Key (Constructor)
        BISTAT,  11, // Busy/Idle Status
        CFSTAT,  12, // Call Forwarding Status
        ORIGR,   13, // Originating Restrictions
        TERMR,   14, // Terminating Restrictions
        DNMAP,   15, // DN to Line Service Type Mapping
        DURTN,   16, // Duration
        RETD,    17, // Return Data (Constructor)
        BCRQ,    18, // Bearer Capability Requested
        BCSUP,   19, // Bearer Capability Supported
        REFID,   20, // Reference ID
        BGROUP,  21, // Business Group
        SNI,     22, // Signalling Networks Identifier
        MWIT,    23, // Message Waiting Indicator Type
    NULL);

    PRIV_B = new Bra(NULL,NULL,NULL,
        UNI ,     1, // Unidirectional
        QWP ,     2, // Query with permission
        QWOP,     3, // Query without permission
        RESP,     4, // Response
        CWP ,     5, // Conversation with permission
        CWOP,     6, // Conversation without permission
        TRSID,    7, // Transaction ID
        CSEQ,     8, // Component Sequence
        INKL,     9, // Invoke (Last)
        RRL ,    10, // Return Result (Last)
        RER ,    11, // Return Error
        REJ ,    12, // Reject
        INK ,    13, // Invoke (Not Last)
        RR  ,    14, // Return Result (Not Last)
        CORID,   15, // Correlation ID
        NOPCO,   16, // National Operation Code
        POPCO,   17, // Private Operation Code
        PSET,    18, // Parameter Set
        PBCODE,  21, // Problem Code
        ABRT,    22, // Abort
        BLGT,    65, // Billing Indicators
        CTIME,   66, // Connect Time
        ECHOD,   67, // Echo Data
        ONC,     68, // Originating Node Capabilities
        OLI,     69, // Originating Station Type
        TERMIND, 70, // Terminating Indicators
        ACGP,    71, // ACG Indicators (private)
        ALPHAS,  72, // Aphanumeric String
        PDIG,    73, // Digits (private)
        ASYNCTP, 74, // Asynchronous Terminal Profile
        ACBI,    75, // Automated Callback Indicator
        CSDI,    76, // Calling Card Account Number Service Denial Indicator
        CCSAN,   77, // Calling Card Subaccount Number
        CHGII,   78, // Charging Information Indicator
        CUGFC,   79, // CUG Facility Code
        CUGI,    80, // CUG Index
        CUGP,    81, // CUG Parameters
        COLL,    82, // Collect Acceptance Indicator
        CompID,  83, // Company ID
        DTPCL,   84, // Default Throughput Class
        FCNFI,   85, // Flow Control Negotiation Facility Indicator
        ICDR,    86, // IC Denial Check Response
        CARI,    87, // IC Indicators
        ICPre,   88, // IC Preselect
        ICPreI,  89, // IC Preselect Indicator
        ICPT,    90, // Intercept Indicator
        NSDPS,   91, // Non-standard Default Packet Size
        NSDWS,   92, // Non-standard Default Window Size
        MATCH,   93, // Match
        OBILL,   94, // Originaling Billing Indicators
        CCVI2,   95, // Calling Card Verification Information 2
        PIN,     96, // Personal Identification Number
        PINR,    97, // PIN Restriction Indicator
        PSDI,    98, // PIN Service Denial Indicator
        PPSN,    99, // PPSN Data Services Indicator
        PSNP,   102, // Private Subscriber Network Preselect
        RSI,    103, // Record Status Indicator
        SST,    104, // Service or Equipment Indicator
        TERMLI, 105, // Terminating Line Indicators
        TN,     106, // Third Number Acceptance indicator
        TCNFI,  107, // Throughput Class Negotiation Facility Indicator
        TREAT,  108, // Treatment Indicator
        RPOASB, 109, // RPOA Selection Barred Facility Indicator
        INTINF, 110, // Intercept Information
        OLNSI,  111, // Originating Line Number Screening Information
        CCVT1,  112, // Calling Card Verification Information
        BNS,    113, // Billed Number Screening Information
        TLNSI,  114, // Terminating Line Number Screening Information
        NUI,    115, // NUI Profile Screening Information
        SPAR1,  116, // Spare Indicator 1
        SPAR2,  117, // Spare Indicator 2
        TSPAR1, 118, // Telco Spare Indicator 1
        TSPAR2, 119, // Telco Spare Indicator 2
        TSPAR3, 120, // Telco Spare Indicator 3
        TSPAR4, 121, // Telco Spare Indicator 4
        OLST1,  122, // Originating Listing Services Indicator 1
        OLST2,  123, // Originating Listing Services Indicator 2
        LOCAL,  124, // Locality
        SPECA,  125, // Special Announcement
    NULL);

    UNIV  = new ParameterG("UNIV","Universal Parmeter",UPARM,NULL);
    CTXT  = new ParameterG("CTXT","Context Parmeter"  ,CPARM,NULL);
    PRIV  = new ParameterG("PRIV","Private Parmeter"  ,VPARM,NULL);

    SPI_B = new Bra(NULL,NULL,NULL, UNIV, 0, CTXT, 2, PRIV, 3, NULL);
    RPI_B = new Bra(NULL,NULL,NULL, UNIV, 0, CTXT, 2, PRIV, 3, NULL);

    SPI   = new PrimitiveSeq("SPI","Service Key Portion",  -1,SPI_B,NULL);
    RPI   = new PrimitiveSeq("RPI","Returned Data Portion",-1,RPI_B,NULL);

    SKEY  = new ParameterG("SKEY","Service Key"   ,SPI,NULL);
    RETD  = new ParameterG("RETD","Returned Data" ,RPI,NULL);

    PPIT_B  = new Bra(NULL,NULL,NULL, SKEY,   10, RETD,   17,          NULL); 
    PPIC0_B = new Bra(NULL,NULL,NULL, UNIV,0, APPL,1, CTXT,2, PRIV,3,  NULL);
    PPIC1_B = new Bra(NULL,NULL,NULL, PPIT_B,  2,                      NULL);
    PPIF_B  = new Bra(NULL,NULL,NULL, PPIC0_B, 0, PPIC1_B, 1,          NULL);

    PPI = new Portion("PPI","Parameter Portion",-1,PPIF_B,NULL);

    PPIF_B ->branch = PPI->FORM;
    PPIC0_B->branch = PPI->CLASS;
    PPIC1_B->branch = PPI->CLASS;
    PPIT_B ->branch = PPI->TAG;

    PSET = new PrivConstructor("PSET","Parameter Set",18,PPI,NULL);
    
    OPCODE = new Codec_OPCODE();
    ERCODE = new Codec_ERCODE();
    PBCODE = new Codec_PBCODE();

    INKID = new Field("INKID","Invoke ID",8,0);
    CORID = new Field("CORID","Correlation ID",8,0);

    INID = new PrivPrimitiveSeq("COID","Correlation ID",15,INKID,CORID,NULL);
    COID = new PrivPrimitiveSeq("COID","Correlation ID",15,CORID,NULL);

    INKL = new ParameterG("INKL","Invoke (Last)"           ,INID,OPCODE,PSET,NULL);
    RRL  = new ParameterG("RRL", "Return Result (Last)"    ,COID       ,PSET,NULL);
    RER  = new ParameterG("RER", "Return Error"            ,COID,ERCODE,PSET,NULL);
    REJ  = new ParameterG("REJ", "Reject"                  ,COID,PBCODE,PSET,NULL);
    INK  = new ParameterG("INK", "Invoke (Not Last)"       ,INID,OPCODE,PSET,NULL);
    RR   = new ParameterG("RR",  "Return Result (Not Last)",COID       ,PSET,NULL);

    CPI_B = new Bra(NULL,NULL,NULL,
        INKL,   9,
        RRL ,  10,
        RER ,  11,
        REJ ,  12,
        INK ,  13,
        RR  ,  14,
        NULL);

    CPI  = new PrivConstructor("CPI","Transaction Portion",-1,CPI_B,NULL);
    CPI_B->branch = CPI->TAG;

    CSEQ = new PrivConstructor("CSEQ","Component Portion",8,CPI,NULL);

    ORIGID = new Field("ORIGID","Originating ID",32,0);
    DESTID = new Field("DESTID","Destination ID",32,0);

    OID = new PrivPrimitiveSeq("TID","Transaction ID",7,ORIGID,DESTID,NULL);
    DID = new PrivPrimitiveSeq("TID","Transaction ID",7,DESTID,ORIGID,NULL);

    UNI  = new ParameterG("UNI" ,"Unidirectional",             DID,CSEQ,NULL);
    QWP  = new ParameterG("QWP" ,"Query w/ Permission",        OID,CSEQ,NULL);
    QWOP = new ParameterG("QWOP","Query w/o Permission",       OID,CSEQ,NULL);
    RESP = new ParameterG("RESP","Response",                   DID,CSEQ,NULL);
    CWP  = new ParameterG("CWP" ,"Conversation w/ Permission", OID,CSEQ,NULL);
    CWOP = new ParameterG("CWOP","Conversation w/o Permission",OID,CSEQ,NULL);

    TPI_B = new Bra(NULL,NULL,NULL,
        UNI ,  1,
        QWP ,  2,
        QWOP,  3,
        RESP,  4,
        CWP ,  5,
        CWOP,  6,
        ABRT, 22,
        NULL);
    
    TPI = new PrivConstructor("TPI","Transaction",-1,TPI_B,NULL);
    TPI_B->branch = TPI->TAG;
};

