//Editor-Info: -*- C++ -*-
//
//Subject: TOVE project / NNI SSCF protocol
//
//File: nsscfprotocol.h
//
//Version: $Revision: 1.16 $
//
//State: $State: Exp $
//
//Date: $Date: 1998/10/19 18:11:09 $
//
//Organisation:
//      Helsinki University of Technology
//      Laboratory of Telecommunications and Multimedia
//
//Author:
//      Juhana Räsänen
//
//Description:
//      Protocol conduit for NNI-SSCF
//
//Copyright:
//      Copyright 1999 Helsinki University of Technology
//      ALL RIGHTS RESERVED BETWEEN JANUARY 1996 AND JUNE 1999.
//
//Licence:
//
//
//History: 


#ifndef __NSSCFPROTOCOL_H__
#define __NSSCFPROTOCOL_H__

#include "nsscf.h"
#include "pf/protocol.h"
#include "pf/types.h"
#include "pf/timer.h"

class pfFrame;
class saalNNIlink;


//
// Class: nsscfProtocol
//
// Description:
//     Protocol conduit for the NNI-SSCF sublayer of SAAL as defined
//     in Q.2140. Conduit side B is the interface to Layer 3 protocol
//     (eg. MTP-3), side A is the interface to SSCOP.
//

class nsscfProtocol : public pfProtocol
{
    public:
        nsscfProtocol(saalNNIlink *manager_);
        nsscfProtocol(const nsscfProtocol &other_, saalNNIlink *manager_);

        virtual ~nsscfProtocol(void);

// Methods for protocol parameter handling
        bool isInService(void) const;
        void setInService(void);
        void setNotInService(void);
        bool isLPO(void) const;
        void setIsLPO(void);
        void setNoLPO(void);
        nsscfProvingStatus getUPS(void) const;
        void setUPSnormal(void);
        void setUPSemergency(void);
        nsscfProvingStatus getMPS(void) const;
        void setMPSneutral(void);
        void setMPSnormal(void);
        void setMPSemergency(void);
        pfUlong getN1(void) const;
        void setN1(pfUlong n1_);
        pfUlong getC1(void) const;
        void setC1(nsscfPDU pdu_);
        void decreaseC1(void);
        pfUlong getBSNT(void) const;
        void setBSNT(pfUlong bsnt_);

// Methods for timer handling
        void setT1timeout(pfUlong msec_);
        void timerT1start(void);
        void timerT1stop(void);
        void setT2timeout(pfUlong msec_);
        void timerT2start(void);
        void timerT2stop(void);
        void setT3timeout(pfUlong msec_);
        void timerT3start(void);
        void timerT3stop(void);

// Send methods for AA-primitives to SSCOP (conduit side A)
        void sendAaESTABLISHreq(void);
        void sendAaESTABLISHresp(void);
        void sendAaDATAreq(const pfFrame &frame_);
        void sendAaRELEASEreq(nsscfPDU pdu_);
        void sendAaRETRIEVEreq(pfUlong retrievalNumber_);
        void sendAaRECOVERresp(void);

// Send methods for NAAL-primitives to MTP-3 (conduit side B)
        void sendNaalRECEIVED_MESSAGEind(const pfFrame &frame_);
        void sendNaalLINK_CONGESTEDind(pfUlong congestion_);
        void sendNaalLINK_CONGESTION_CEASEDind(void);
        void sendNaalIN_SERVICEind(void);
        void sendNaalOUT_OF_SERVICEind(void);
        void sendNaalRETRIEVED_MESSAGESind(const pfFrame &frame_);
        void sendNaalRETRIEVAL_COMPLETEind(void);
        void sendNaalBSNTconf(pfUlong bsnt_);
        void sendNaalBSNT_NOT_RETRIEVABLEconf(void);

// Send methods for MAAL-primitivies to the Layer Management object
        void sendMaalPROVINGind(void);
        void sendMaalSTOP_PROVINGind(void);
        void sendMaalREPORTind(nsscfLBC lbc_ = LBC_EMPTY,
                               nsscfUBC ubc_ = UBC_EMPTY,
                               nsscfReason reason_ = R_EMPTY,
                               nsscfPDU sscop_uu_ = nsscfINVALIDpdu);

// Methods to change state
        void toNsscfOutOfService_Idle(void);
        void toNsscfOutOfService_OutgoingDisconnectionPending(void);
        void toNsscfProving_DataTransferReady(void);
        void toNsscfAlignedReady_DataTransferReady(void);
        void toNsscfAlignment_Idle(void);
        void toNsscfAlignment_OutgoingConnectionPending(void);
        void toNsscfAlignment_OutgoingDisconnectionPending(void);
        void toNsscfInService_DataTransferReady(void);

// PDU encode/decode methods
        pfFrame encodePDU(nsscfPDU pdu_) const;
        nsscfPDU decodePDU(const pfFrame &frame_) const;

// Method to acquire AALid
	pfId getAALid(void) const;


    private:
        // These constructors and operators not implemented
        nsscfProtocol(void);                 
        nsscfProtocol(const nsscfProtocol &other_);
        const nsscfProtocol &operator=(const nsscfProtocol &other_);

    private:
        pfTimer _timerT1;
        pfTimer _timerT2;
        pfTimer _timerT3;
        bool _INS;
        bool _LPO;
        nsscfProvingStatus _UPS;
        nsscfProvingStatus _MPS;
        pfUlong _n1;
        pfUlong _C1;
        pfUlong _BSNT;

        saalNNIlink *_manager;
};


#endif // __NSSCFPROTOCOL_H__

