OpenSS7
SS7 for the
Common Man

© Copyright 1997-2004,OpenSS7 Corporation, All Rights Reserved.
Last modified:

Home Overview Status News Documentation Resources About
   
 Overview
 Status
 News
 Documentation
 Resources
 About

   
Home Index Prev Next More Download Info FAQ Mail   Home -> Resources -> Browse Source -> ss7codec/sample1.cpp


File /code/ss7codec/sample1.cpp



#pragma implementation

#include "L3codec.h"
#include "ISUPcodec.h"
#include <iostream.h>

int len = 1000;
int len2 = 1000;
unsigned char fme1[1000];
unsigned char fme2[1000];
unsigned char *fme = fme1;

main() {
    Codec_L3 anMSU;
    Codec_L3* MSU = &anMSU;
    Codec_ISUP anISUP;
    Codec_ISUP* ISUP = &anISUP;

    int i,l;
    unsigned char num[5]= { 0x14, 0x36, 0x35, 0x96, 0x62 };
    unsigned char nu2[5]= { 0x16, 0x73, 0x52, 0x56, 0x28 };
    unsigned char nu3[5]= { 0x16, 0x73, 0x18, 0x06, 0x00 };
    unsigned char *p;
    char *s;

    len = 1000;
    Codec::rebuild();
    ISUP->CIC->set(157);
    ISUP->IAM->build();
    ISUP->CDPN->CDPN->NAI->set("SN");
    ISUP->CDPN->CDPN->INN->set("YES");
    ISUP->CDPN->CDPN->NPLAN->set("ISDN");
    ISUP->CDPN->CDPN->ADDI->set(num,5);
    ISUP->OPARMS->CGPN->build();
    ISUP->OPARMS->CGPN->NAI->set("SN");
    ISUP->OPARMS->CGPN->SCR->set("NP");
    ISUP->OPARMS->CGPN->PRES->set("NO");
    ISUP->OPARMS->CGPN->NPLAN->set("ISDN");
    ISUP->OPARMS->CGPN->ADDI->set(nu2,5);
    ISUP->OPARMS->CHGN->build();
    ISUP->OPARMS->CHGN->NAI->set("NSN");
    ISUP->OPARMS->CHGN->NPLAN->set("ISDN");
    ISUP->OPARMS->CHGN->ADDI->set(nu3,5);
    cout << "Encoding ISUP...\n";
    if (Codec::encode(ISUP,fme,len)) cout.form("Encoded %d bytes: ",len);
    for (i=0;i<len;i++) cout.form("%2x ",fme[i]&0xff); cout << '\n';

    len2 = 1000;
    Codec::rebuild();
    MSU->MP->set(2);
    MSU->NI->set("NAT");
    MSU->RL->OPC->NET->set(4);
    MSU->RL->OPC->CLS->set(6);
    MSU->RL->OPC->MEM->set(4);
    MSU->RL->DPC->NET->set(8);
    MSU->RL->DPC->CLS->set(12);
    MSU->RL->DPC->MEM->set(8);
    MSU->RL->SLS->set(5);
    MSU->ISUP->build();
    MSU->ISUP->PDU->set(fme,len);
    cout << "Encoding MSU...\n";
    if (Codec::encode(MSU,fme2,len2)) cout.form("Encoded %d bytes: ",len2);
    for (i=0;i<len2;i++) cout.form("%2x ",fme2[i]&0xff); cout << '\n';

    cout << "Decoding MSU...\n";
    if (Codec::decode(MSU,fme2,len2)) cout.form("Decoded %d bytes.\n",len2);
    cout << "Reporting...\n";
    Codec::report(MSU); cout << '\n';

    if ( !MSU->ISUP->exists ) {
        cout << "...ooops, no ISUP!\n";
        exit(1);
    }

    MSU->ISUP->PDU->get(fme,len);

    cout << "Routing label is...\n";
    MSU->RL->report();
    cout << "\n";

    cout << "Decoding ISUP...\n";
    if (Codec::decode(ISUP,fme,len)) cout.form("Decoded %d bytes.\n",len);
    cout << "Reporting...\n";
    Codec::report(ISUP); cout << '\n';
    cout << "\n";

    ISUP->CIC->get(l);
    cout << "CIC value is " << l << "\n\n";

    if ( ISUP->IAM->exists )
        cout << "Yes, we have an IAM...\n\n";
    else
        cout << "No, we don't have an IAM...\n\n";
    
    if ( ISUP->CDPN->exists ) {
        cout << "Yes, we have an Mandatory CPDN parameter...\n\n";
        ISUP->CDPN->report();
        cout << "\n";
        cout << "What is the telephone number?\n\n";
        ISUP->CDPN->CDPN->ADDI->report();
        cout << "\n";
        cout << "Notice that it's nibble swapped though..\n";
        ISUP->CDPN->CDPN->ADDI->get(p,l);
        for (i=0;i<l;i++) {
            cout << (p[i]&0xF);
            cout << ((p[i]>>4)&0xF);
        }; cout << "\n\n";
    } else {
        cout << "No, we don't have an Mandatory CPDN parameter...\n\n";
    }
    
    if ( ISUP->BCI->exists ) {
        cout << "Yes, we have an Mandatory BCI parameter...\n\n";
        ISUP->BCI->report();
        cout << "\n";
    } else {
        cout << "No, we don't have an Mandatory BCI parameter...\n";
        cout << "but, that's O.K.: we shouldn't, it's an IAM!\n\n";
    }

    if ( ISUP->OPARMS->CGPN->exists ) {
        cout << "Yes, we have an Optional CGPN parameter...\n\n";
        ISUP->OPARMS->CGPN->report();
        cout << "\n";
        cout << "What is the telephone number?\n\n";
        ISUP->OPARMS->CGPN->ADDI->report();
        cout << "\n";
        if ( ISUP->OPARMS->CGPN->PRES->test("NO") )
            cout << "Presentation is restricted!\n\n";
        else
            cout << "Presentation is allowed!\n\n";
        ISUP->OPARMS->CGPN->PRES->get(s);
        cout << "Presentation is set " << s << "!\n\n";
        ISUP->OPARMS->CGPN->PRES->get(i);
        cout << "Presentation has a value of " << i << "!\n\n";
    } else {
        cout << "No, we don't have an Optional CGPN parameter...\n\n";
    }

    cout << "...Done.\n";

    exit(0);
};


Home Index Prev Next More Download Info FAQ Mail   Home -> Resources -> Browse Source -> ss7codec/sample1.cpp

OpenSS7
SS7 for the
Common Man
Home Overview Status News Documentation Resources About

© Copyright 1997-2004,OpenSS7 Corporation, All Rights Reserved.
Last modified: