//Editor-Info: -*- C++ -*-
//
//Subject: TOVE project / BISUP
//
//File: niprotocol.h
//
//Version: $Revision: 1.14 $
//
//State: $State: Exp $
//
//Date: $Date: 1999/03/08 07:42:31 $
//
//Organisation:
//      Helsinki University of Technology
//      Laboratory of Telecommunications Software and Multimedia
//
//Author:
//      Sami Raatikainen
//
//Description:
//      Implements the network interface between MTP3 and bisup.
//      Network interface protocol, coordinates messages between
//      different BISUP-instances (using SIDs) and MTP3-protocol.
//      Has pducoders as static datamembers, to be used for coding
//      received frames into sigPrimitives which will be sent to the
//      correct bisup instance.
//
//Copyright:
//      Copyright 1999 Helsinki University of Technology
//      ALL RIGHTS RESERVED BETWEEN JANUARY 1996 AND JUNE 1999.
//
//Licence:
//
//
//History: 

#ifndef __BISUP_NIPROTOCOL_H__
#define __BISUP_NIPROTOCOL_H__

#include <typeinfo>
#include "pf/protocol.h"
#include "bisuppducoders.h"

class niProtocol : public pfProtocol
{        
    public:
        static pfConduit create(
            pfUlong pointCode_, 
            pfUlong destinationPointCode_);
        virtual ~niProtocol(void);
        
        // to BISUP
        void toBisup(pfMessenger *msg_);
        
        // to MTP3
        void sendACMtoMtp(pfMessenger *msg_);
        void sendANMtoMtp(pfMessenger *msg_);
        void sendCPGtoMtp(pfMessenger *msg_);
        void sendIAAtoMtp(pfMessenger *msg_);
        void sendIARtoMtp(pfMessenger *msg_);
        void sendIAMtoMtp(pfMessenger *msg_);
        void sendRELtoMtp(pfMessenger *msg_);
        void sendRLCtoMtp(pfMessenger *msg_);
        
        static bisupPduCoder *getIAMCoder(void);
        static bisupPduCoder *getIAACoder(void);
        static bisupPduCoder *getIARCoder(void);
        static bisupPduCoder *getACMCoder(void);
        static bisupPduCoder *getCPGCoder(void);
        static bisupPduCoder *getANMCoder(void);
        static bisupPduCoder *getRELCoder(void);
        static bisupPduCoder *getRLCCoder(void);
        
    private:
        niProtocol(pfUlong pointCode_, pfUlong destinationPointCode_);
        pfUlong _OPC;
        pfUlong _DPC;
        pfUlong _SLS;
        pfUlong _SIO;
        
        static bisupIAMCoder *_IAMCoder;
        static bisupIAACoder *_IAACoder;
        static bisupIARCoder *_IARCoder;
        static bisupACMCoder *_ACMCoder;
        static bisupCPGCoder *_CPGCoder;
        static bisupANMCoder *_ANMCoder;
        static bisupRELCoder *_RELCoder;
        static bisupRLCCoder *_RLCCoder;

        void initMtpTransferVariables(void);
        pfBoolean isMuxKeyAllocated(const pfKey key_);
        pfUlong getDSID(pfMessenger *msg_) const;
        pfUlong getOSID(pfMessenger *msg_) const;  
        
        void encodeAndSendToMtp(pduCoder *pduCoder_, pfMessenger *msg_);
        void sendTRANSFERreqToMtp(pfFrame &frame_);
};

#endif //__BISUP_NIPROTOCOL_H__
