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 -> strss7/daemons/isupmon/isupcol.hh


File /code/strss7/daemons/isupmon/isupcol.hh


#ident "@(#) $Id: isupcol.hh,v 0.8 2003/07/24 20:38:38 brian Exp $"

#ifndef __ISUPCOL_HH__
#define __ISUPCOL_HH__

#pragma interface

class Error;
class Pollable;
class StreamBuffer;
class RxStreamBuffer;
class TxStreamBuffer;
class SignallingTerminal;
class Message;
class Network;
class Call;

class Error {
  public:
    Error();
    Error(const char *function, int error);
};

#define BUFSIZE 384

class StreamBuffer {
  protected:
    SignallingTerminal & sigTerm;		// signalling terminal
    unsigned char cbuf[BUFSIZE];		// ctrl buffer
    unsigned char dbuf[BUFSIZE];		// data buffer
  public:
    struct strbuf ctrl;				// ctrl part for getmsg and putmsg
    struct strbuf data;				// data part for getmsg and putmsg
     virtual ~ StreamBuffer(void);
     StreamBuffer(SignallingTerminal & st);
};

class RxStreamBuffer:public StreamBuffer {
  public:
    RxStreamBuffer(SignallingTerminal & st);
    virtual ~ RxStreamBuffer(void);
};

class TxStreamBuffer:public StreamBuffer {
  public:
    TxStreamBuffer(SignallingTerminal &, ulong csize = 0, ulong dsize = 0);
     virtual ~ TxStreamBuffer(void);
    void send(int flags);
};

#define MAXPOLL 200

class Pollable {
  private:
    static Pollable *list;			// master list
    Pollable *next;				// next pointer
    Pollable **prev;				// previous next pointer
    static struct pollfd pfd[MAXPOLL];
    static int npfd;
    static void poll_recalc(Pollable *);
  protected:
     friend RxStreamBuffer::RxStreamBuffer(SignallingTerminal & st);
    friend void TxStreamBuffer::send(int);
    struct pollfd *pfdp;
    virtual int poll_open(const char *) = 0;	// pure virtual
    virtual void poll_event(void) = 0;		// pure virtual
    virtual void poll_close(int) = 0;		// pure virtual
  public:
     Pollable(const char *fname);
     virtual ~ Pollable(void);
    void poll_loop(int wait);
};

class SignallingTerminal:public Pollable {
  private:
    static SignallingTerminal *list;		// master list
    SignallingTerminal *next;			// next signalling terminal
    SignallingTerminal **prev;			// prev signalling terminal
    ulong state;				// signalling terminal state
    ulong style;				// ppa style
    ulong max_sdu;				// max SDU size
    ulong min_sdu;				// min SDU size
    ulong hdr_len;				// header length
    struct strbuf ctrl;				// ctrl part for getmsg and putmsg
    struct strbuf data;				// data part for getmsg and putmsg
    char cbuf[BUFSIZE];				// ctrl buffer
    char dbuf[BUFSIZE];				// data buffer
    virtual int poll_open(const char *);	// overloaded open function
    virtual void poll_event(void);		// overloaded event handler
    virtual void poll_close(int);		// overloaded close function
    inline void sdt_data(void);			// process data
  public:
     Network & network;				// network for this terminal
    ulong index;				// signalling terminal index
     virtual ~ SignallingTerminal(void);
     SignallingTerminal(const char *devname, ulong address, Network & n);
    void buffer(StreamBuffer *);
    void primitive(StreamBuffer *);
    void message(StreamBuffer *);
};

class Call {
  private:
    Network & network;				// network
    Call *next;					// hash linkage
    Call **prev;				// hash linkage
    ulong dpc;					// destination point code
    ulong opc;					// origination point code
    ulong cic;					// circuit identification code
    Message *list;				// message list
    enum {
	CTS_IDLE = 0,
	CTS_WAIT_ACM,
	CTS_WAIT_ANM,
	CTS_ANSWERED,
	CTS_SUSPENDED,
	CTS_WAIT_RLC,
	CTS_SEND_RLC,
    } state;					// call state
    void dump(void);				// dump our state
    void clear(void);
  public:
    void message(Message * m);			// add a message
    Call *lookup(ulong dpc, ulong opc, ulong cic);
    ~Call(void);
     Call(Network & n, ulong dpc, ulong opc, ulong cic);
};

class Message {
  private:
    friend void Call::dump();
    Message *next;				// linkage
    Message **prev;				// linkage
     Network & network;				// network
    StreamBuffer *buffer;			// buffer
    struct timeval timestamp;
    ulong index;				// sig term index
    friend void Call::message(Message *);
    friend Call *Call::lookup(ulong d, ulong o, ulong c);
    ulong si;					// service indicator
    ulong mp;					// message priority
    ulong ni;					// network indicator
  public:
    ulong dpc;					// destination point code
    ulong opc;					// originating point code
    ulong sls;					// signalling link selection
    ulong cic;					// circuit identification code
    enum {
	ISUP_MT_IAM = 0x01,			// 0b00000001 - Initial address
	ISUP_MT_SAM = 0x02,			// 0b00000010 - Subsequent address (not ANSI)
	ISUP_MT_INR = 0x03,			// 0b00000011 - Information request
	ISUP_MT_INF = 0x04,			// 0b00000100 - Information
	ISUP_MT_COT = 0x05,			// 0b00000101 - Continuity
	ISUP_MT_ACM = 0x06,			// 0b00000110 - Address complete
	ISUP_MT_CON = 0x07,			// 0b00000111 - Connect (not ANSI)
	ISUP_MT_FOT = 0x08,			// 0b00001000 - Forward transfer
	ISUP_MT_ANM = 0x09,			// 0b00001001 - Answer
	ISUP_MT_REL = 0x0c,			// 0b00001100 - Release
	ISUP_MT_SUS = 0x0d,			// 0b00001101 - Suspend
	ISUP_MT_RES = 0x0e,			// 0b00001110 - Resume
	ISUP_MT_RLC = 0x10,			// 0b00010000 - Release complete
	ISUP_MT_CCR = 0x11,			// 0b00010001 - Continuity check request
	ISUP_MT_RSC = 0x12,			// 0b00010010 - Reset circuit
	ISUP_MT_BLO = 0x13,			// 0b00010011 - Blocking
	ISUP_MT_UBL = 0x14,			// 0b00010100 - Unblcoking
	ISUP_MT_BLA = 0x15,			// 0b00010101 - Blocking acknowledgement
	ISUP_MT_UBA = 0x16,			// 0b00010110 - Unblocking acknowledgement
	ISUP_MT_GRS = 0x17,			// 0b00010111 - Circuit group reset
	ISUP_MT_CGB = 0x18,			// 0b00011000 - Circuit group blocking
	ISUP_MT_CGU = 0x19,			// 0b00011001 - Circuit group unblocking
	ISUP_MT_CGBA = 0x1a,			// 0b00011010 - Circuit group blocking acknowledgement
	ISUP_MT_CGUA = 0x1b,			// 0b00011011 - Circuit group unblocking acknowledgement
	ISUP_MT_CMR = 0x1c,			// 0b00011100 - Call Modification Request (not ANSI)
	ISUP_MT_CMC = 0x1d,			// 0b00011101 - Call Modification Completed (not ANSI)
	ISUP_MT_CMRJ = 0x1e,			// 0b00011110 - Call Modification Reject (not ANSI)
	ISUP_MT_FAR = 0x1f,			// 0b00011111 - Facility request (not ANSI)
	ISUP_MT_FAA = 0x20,			// 0b00100000 - Facility accepted (not ANSI)
	ISUP_MT_FRJ = 0x21,			// 0b00100001 - Facility reject (not ANSI)
	ISUP_MT_FAD = 0x22,			// 0b00100010 - Facility Deactivated (not ANSI)
	ISUP_MT_FAI = 0x23,			// 0b00100011 - Facility Information (not ANSI)
	ISUP_MT_LPA = 0x24,			// 0b00100100 - Loop back acknowledgement
	ISUP_MT_CSVQ = 0x25,			// 0b00100101 - CUG Selection and Validation Request (not ANSI)
	ISUP_MT_CSVR = 0x26,			// 0b00100110 - CUG Selection and Validation Response (not ANSI)
	ISUP_MT_DRS = 0x27,			// 0b00100111 - Delayed release (not ANSI)
	ISUP_MT_PAM = 0x28,			// 0b00101000 - Pass along
	ISUP_MT_GRA = 0x29,			// 0b00101001 - Circuit group reset acknowledgement
	ISUP_MT_CQM = 0x2a,			// 0b00101010 - Circuit group query
	ISUP_MT_CQR = 0x2b,			// 0b00101011 - Circuit group query response
	ISUP_MT_CPG = 0x2c,			// 0b00101100 - Call progress
	ISUP_MT_USR = 0x2d,			// 0b00101101 - User-to-user information (not ANSI)
	ISUP_MT_UCIC = 0x2e,			// 0b00101110 - Unequipped circuit identification code
	ISUP_MT_CFN = 0x2f,			// 0b00101111 - Confusion
	ISUP_MT_OLM = 0x30,			// 0b00110000 - Overload (not ANSI)
	ISUP_MT_CRG = 0x31,			// 0b00110001 - Charge information (not ANSI)
	ISUP_MT_NRM = 0x32,			// 0b00110010 - Network resource management (not ANSI)
	ISUP_MT_FAC = 0x33,			// 0b00110011 - Facility
	ISUP_MT_UPT = 0x34,			// 0b00110100 - User part test (not ANSI)
	ISUP_MT_UPA = 0x35,			// 0b00110101 - User part available (not ANSI)
	ISUP_MT_IDR = 0x36,			// 0b00110110 - Identification request (not ANSI)
	ISUP_MT_IRS = 0x37,			// 0b00110111 - Identification response (not ANSI)
	ISUP_MT_SGM = 0x38,			// 0b00111000 - Segmentation
	ISUP_MT_CRA = 0xe9,			// 0b11101001 - Circuit Reservation Ack (ANSI 2000)
	ISUP_MT_CRM = 0xea,			// 0b11101010 - Circuit Reservation (ANSI 2000)
	ISUP_MT_CVR = 0xeb,			// 0b11101011 - Circuit Validation Response (ANSI 2000)
	ISUP_MT_CVT = 0xec,			// 0b11101100 - Circuit Validation Test (ANSI 2000)
	ISUP_MT_EXM = 0xed,			// 0b11101101 - Exit (old Bellcore/ANSI 2000)
	ISUP_MT_NON = 0xf8,			// 0b11111000 - National Notification (Spain)
	ISUP_MT_LLM = 0xfc,			// 0b11111100 - National Malicious Call (Spain)
	ISUP_MT_CAK = 0xfd,			// 0b11111101 - Charge Acknowledgement (Singapore)
	ISUP_MT_TCM = 0xfe,			// 0b11111110 - Tariff Charge (Singapore)
	ISUP_MT_MCP = 0xff,			// 0b11111111 - Malicious Call Print (Singapore)
    } mt;					// message type
    unsigned char *p;				// buffer position
    unsigned char *e;				// buffer end
     virtual ~ Message(void);
     Message(SignallingTerminal & st, StreamBuffer * buf);
    // link message into list
    int link(Message * list);
    // unlink message from list
    void unlink(void);
    void dump(void);
};

#define HASH_TABLE_SIZE	 (1<<10)

class Network {
  private:
    friend void Call::dump();
    ulong index;				// network index
    friend Call::Call(Network &, ulong, ulong, ulong);
    Call *hash[HASH_TABLE_SIZE];		// call hash table
    Call *&hash_slot(ulong dpc, ulong cpc, ulong cic);
    Call *lookup(ulong dpc, ulong opc, ulong cic);
    friend Message::Message(SignallingTerminal & st, StreamBuffer * buf);
    void message(Message * m);
  public:
    ulong pvar;					// protocol variant
    ~Network(void);
     Network(ulong i, ulong var);
    // lookup the call by dpc, opc, cic
};

#endif				


Home Index Prev Next More Download Info FAQ Mail   Home -> Resources -> Browse Source -> strss7/daemons/isupmon/isupcol.hh

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

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