//  ==========================================================================
//  
//  @(#) $Id: test3.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: test3.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: test3.C,v 1.4 2000/10/19 03:21:57 brian Exp $";

#pragma implementation

#include "SCCP_Codec.H"
#include <iostream.h>

int len4 = 1000; char fme4[1000];
int len5 = 6; char fme5[] = { 1, 2, 3, 4, 5, 6 };
int len6 = 5; char fme6[] = { 0x04, 0x43, 0x36, 0x65, 0x78 };

main() {
    Codec_SCCP anSCCP;
    Codec_SCCP* SCCP = &anSCCP;

    int i;

    len4 = 1000;

    Codec::rebuild();
    SCCP->UDT->build();
    SCCP->PCL->build();
    SCCP->PCL->PCL->set("PC0");
    SCCP->PCL->OPT->set("NSO");
    SCCP->CDPA->build();
    SCCP->CDPA->CDPA->build();
    SCCP->CDPA->CDPA->SPC->set(4,6,4);
    SCCP->CDPA->CDPA->SSN->build();
    SCCP->CDPA->CDPA->GT4->build();
    SCCP->CDPA->CDPA->TT->set(252);
    SCCP->CDPA->CDPA->ES->set("BCDE");
    SCCP->CDPA->CDPA->NPLAN->set("ISDN");
    SCCP->CDPA->CDPA->NAI->set("NSN");
    SCCP->CDPA->CDPA->ADDI->set(fme6,len6);
    SCCP->CGPA->build();
    SCCP->CGPA->CGPA->build();
    SCCP->CGPA->CGPA->SPC->set(8,12,8);
    SCCP->CGPA->CGPA->SSN->build();
    SCCP->CGPA->CGPA->GT4->build();
    SCCP->CGPA->CGPA->TT->set(252);
    SCCP->CGPA->CGPA->ES->set("BCDE");
    SCCP->CGPA->CGPA->NPLAN->set("ISDN");
    SCCP->CGPA->CGPA->NAI->set("NSN");
    SCCP->CGPA->CGPA->ADDI->set(fme6,len6);
    SCCP->UPART->build();
    SCCP->UPART->SCMG->build();
    SCCP->UPART->SCMG->MTC->set("SOR");
    SCCP->UPART->SCMG->ASSN->set("MAP");
    SCCP->UPART->SCMG->APC->set(8,12,8);
    SCCP->UPART->SCMG->SMI->set("ASD");
    cout << "Encoding...\n";
    if (Codec::encode(SCCP,fme4,len4)) cout.form("Encoded %d bytes: ",len4);
    for (i=0;i<len4;i++) cout.form("%2x ",fme4[i]&0xff); cout << "\n";
    cout << "Reporting...\n";
    Codec::report(SCCP); cout << '\n';
    cout << "Decoding...\n";
    if (Codec::decode(SCCP,fme4,len4)) cout.form("Decoded %d bytes.\n",len4);
    //Codec::encode(SCCP,fme4,len4);
    //Codec::decode(SCCP,fme4,len4);
    Codec::report(SCCP); cout << '\n';

    len4 = 1000;

    Codec::rebuild();
    SCCP->XUDT->build();
    SCCP->PCL->build();
    SCCP->PCL->PCL->set("PC0");
    SCCP->PCL->OPT->set("NSO");
    SCCP->CDPA->build();
    SCCP->CDPA->CDPA->build();
    SCCP->CDPA->CDPA->SPC->set(4,6,4);
    SCCP->CDPA->CDPA->SSN->build();
    SCCP->CDPA->CDPA->GT4->build();
    SCCP->CDPA->CDPA->TT->set(252);
    SCCP->CDPA->CDPA->ES->set("BCDE");
    SCCP->CDPA->CDPA->NPLAN->set("ISDN");
    SCCP->CDPA->CDPA->NAI->set("NSN");
    SCCP->CDPA->CDPA->ADDI->set(fme6,len6);
    SCCP->CGPA->build();
    SCCP->CGPA->CGPA->build();
    SCCP->CGPA->CGPA->SPC->set(8,12,8);
    SCCP->CGPA->CGPA->SSN->build();
    SCCP->CGPA->CGPA->GT4->build();
    SCCP->CGPA->CGPA->TT->set(252);
    SCCP->CGPA->CGPA->ES->set("BCDE");
    SCCP->CGPA->CGPA->NPLAN->set("ISDN");
    SCCP->CGPA->CGPA->NAI->set("NSN");
    SCCP->CGPA->CGPA->ADDI->set(fme6,len6);
    SCCP->UPART->build();
    SCCP->UPART->SCMG->build();
    SCCP->UPART->SCMG->MTC->set("SOR");
    SCCP->UPART->SCMG->ASSN->set("MAP");
    SCCP->UPART->SCMG->APC->set(8,12,8);
    SCCP->UPART->SCMG->SMI->set("ASD");
    SCCP->OPARMS->SLR->build();
    SCCP->OPARMS->DLR->build();
    cout << "Encoding...\n";
    if (Codec::encode(SCCP,fme4,len4)) cout.form("Encoded %d bytes: ",len4);
    for (i=0;i<len4;i++) cout.form("%2x ",fme4[i]&0xff); cout << "\n";
    cout << "Reporting...\n";
    Codec::report(SCCP); cout << '\n';
    cout << "Decoding...\n";
    if (Codec::decode(SCCP,fme4,len4)) cout.form("Decoded %d bytes.\n",len4);
    //Codec::encode(SCCP,fme4,len4);
    //Codec::decode(SCCP,fme4,len4);
    Codec::report(SCCP); cout << '\n';


    len4 = 1000;
    Codec::rebuild();
    SCCP->XUDT->build();
    Codec** parm = (Codec**)&(SCCP->OPARMS->SLR);
    for (i=0;i<16;i++) parm[15-i]->build();
    if (Codec::encode(SCCP,fme4,len4)) cout.form("Encoded %d bytes: ",len4);
    for (i=0;i<len4;i++) cout.form("%2x ",fme4[i]&0xff); cout << "\n";
    cout << "Reporting...\n";
    Codec::report(SCCP); cout << '\n';
    cout << "Decoding...\n";
    if (Codec::decode(SCCP,fme4,len4)) cout.form("Decoded %d bytes.\n",len4);
    cout << "Reporting...\n";
    Codec::report(SCCP); cout << '\n';

    int j;

    Codec** msg = (Codec**)&(SCCP->CR);
    for (j=0;j<18;j++) {
        len4 = 1000;
        Codec::rebuild();
        msg[j]->build();
        if (Codec::encode(SCCP,fme4,len4)) cout.form("Encoded %d bytes: ",len4);
        for (i=0;i<len4;i++) cout.form("%2x ",fme4[i]&0xff); cout << "\n";
        cout << "Reporting...\n";
        Codec::report(SCCP); cout << '\n';
        cout << "Decoding...\n";
        if (Codec::decode(SCCP,fme4,len4)) cout.form("Decoded %d bytes.\n",len4);
        cout << "Reporting...\n";
        Codec::report(SCCP); cout << '\n';
    }

    cout << "...Done.\n";
    cout.flush();
};

