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/L2codec.cpp


File /code/ss7codec/L2codec.cpp



#pragma implementation

#include "L2codec.h"

#include <unistd.h>

Codec_SU::Codec_SU() :
    Header("SU","Signal Unit",24,6,4,(Codec**)&BSN)
{
    FISU = new Codec_FISU("FISU","Fill-In Signal Unit");
    LSSU = new Codec_LSSU("LSSU","Link Status Signal Unit (1 byte)",1);
    LSS2 = new Codec_LSSU("LSS2","Link Status Signal Unit (2 byte)",2);
    MSU  = new Codec_MSU ("MSU", "Message Signal Unit");

    BSN  = new Field("BSN","Backward Seq Number",   7,0);
    BIB  = new Field("BIB","Backward Indicator Bit",1,0);
    FSN  = new Field("FSN","Forward Seq Number",    7,0);
    FIB  = new Field("FIB","Forward Indicator Bit" ,1,0);
    LI   = new Field("LI" ,"Length Indicator"      ,6,2);
    LI_B = new Bra("LI:","Length Indicator Branch",(Codec*)LI,
        FISU,  0,
        LSSU,  1,
        LSS2,  2,
        MSU ,  3,
        MSU , -1,
        NULL);
};

void
Codec_SU::decode(FramePointer& p) {
    Header::decode(p);
    if (MSU->exists) {
        int v = MSU->frame.size>>3;
        if (v>63) v = 63;
        if (!LI->test(v)) { LI->invalid = true; invalid = true; throw Invalid(label); }
    }
};

void
Codec_SU::encode(FramePointer& p) {
    Header::encode(p);
    if (MSU->exists) {
        int v = MSU->frame.size>>3;
        if (v>63) v = 63;
        LI->set(v);
        FramePointer x(LI->frame);
        LI->encode(x);
    }
};

Codec_FISU::Codec_FISU(char* l,char* t) :
    Content(l,t,0,0,0,NULL) {
};

Codec_LSSU::Codec_LSSU(char* l,char* t,int s) :
    Content(l,t,s*8,1,0,(Codec**)&SF)
{
    SF  = new Set("SF","Sig Info Octet Field",5,(s*8)-5,
        "SIO",  0,  "'0' (out of alignment)",
        "SIN",  1,  "'N' (normal alignment)",
        "SIE",  2,  "'E' (emergency alignment)",
        "SIOS", 3,  "'OS' (out of service)",
        "SIPO", 4,  "'PO' (processor outage)",
        "SIB",  5,  "'B' (busy)",
        NULL);
};

Codec_MSU::Codec_MSU(char* l,char* t) :
    Content(l,t,-1,1,0,(Codec**)&PDU)
{
    PDU = new OctetString("PDU","Protocol Data Unit",-1);
};



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

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

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