//Editor-Info: -*- C++ -*-
//
//Subject: TOVE project/CC
//
//File: ccostate_active.cpp
//
//Version: $Revision: 1.11 $
//
//State: $State: Exp $
//
//Date: $Date: 1999/03/01 15:18:48 $
//
//Organisation:
//      University of Technology
// 
//Author:
//      Pasi Nummisalo
//
//Description:
//     See header.
//
//Copyright:
//      Copyright 1999 Helsinki University of Technology
//      ALL RIGHTS RESERVED BETWEEN JANUARY 1996 AND JUNE 1999.
//      
//Licence:
//     
//
//History:
//

#include "protocol/cc/ccprotocol.h"
#include "ccodp_disconnect.h"
#include "iface/sigif/sigdownprimitives.h"
#include "ccostate_active.h"

ccOstateActive *ccOstateActive :: _only = 0;

ccOstateActive :: ccOstateActive(void)
    : ccOstate()
{
    return;
}

ccOstateActive :: ~ccOstateActive(void)
{
    _only = 0;
    return;
}

ccOstateActive *ccOstateActive :: instance(void)
{
    if(_only == 0)
    {
        _only = new ccOstateActive;
        assert(_only != 0);
    }
    return _only;
}

//
//Function: proceed
//
//Description:  
//   Entry event: Indication from terminating half BCSM that the
//   call is accepted and answered by terminating party.
//   (4.2.2.1.9)
//

void ccOstateActive :: proceed(ccProtocol *protocol_)
{
#if CC_DEBUG
traceSend(ccCC,ccDSS2,"Active","SETUPresp");
#endif

     sigSETUPresp *setup = new sigSETUPresp();
    
//   In future some optional values are negotiated
//   between users, and these will be copied here. 
//     protocol_->copyData(setup, "connect");
//

     protocol_->toDown(setup);       
     return;
}

//
//Functions: signalling inputs.
//
//Description: 
//    Signalling inputs from down layer.
//
//

void ccOstateActive :: sigRELEASEindAct(sigRELEASEind *release_,
                                        pfProtocol *protocol_)
{
#if CC_DEBUG
traceInput(ccDSS2,ccCC,"Active","RELEASEind");
#endif
    ccProtocol *ccprotocol = entryAction(protocol_);
    ccprotocol->saveData("releaseIndActive",  release_);
    exitAction(ccprotocol, ccOdpDisconnect::instance());
    return;
}

//
//Functions: T side inputs
//
//Description:
//    Inputs for messages from terminating side.
//
//

void ccOstateActive :: ccRELEASE_ACTIVEpduAct(ccRELEASE_ACTIVEpdu *release_,
                                              ccProtocol *protocol_)
{
#if CC_DEBUG
traceInput(ccCCT,ccCC,"Active","RELEASE_ACTIVE");
#endif
    protocol_->saveData("releaseActive", release_);
    exitAction(protocol_, ccOdpDisconnect::instance());
    return;
}

