//Editor-Info: -*- C++ -*-
//
//Subject: TOVE project / NNI SSCF protocol
//
//File: nsscfstate1_4_1.cpp
//
//Version: $Revision: 1.8 $
//
//State: $State: Exp $
//
//Date: $Date: 1998/05/26 14:29:50 $
//
//Organisation:
//      Helsinki University of Technology
//      Laboratory of Telecommunications and Multimedia
//
//Author:
//      Juhana Räsänen
//
//Description:
//      See corresponding header file
//
//Copyright:
//      Copyright 1999 Helsinki University of Technology
//      ALL RIGHTS RESERVED BETWEEN JANUARY 1996 AND JUNE 1999.
//
//Licence:
//
//
//History: 


#include <assert.h>
#include "nsscfstate1_4_1.h"
#include "nsscfprotocol.h"
#include "iface/aaif/aaupprimitives.h"
#include "iface/naalif/naaldownprimitives.h"
#include "pf/frame.h"


//
// Variable: nsscfOutOfService_OutgoingDisconnectionPending :: _only
// Function: nsscfOutOfService_OutgoingDisconnectionPending :: instance()
//
// Description:
//     Implements the singleton pattern used for actual states
//

nsscfOutOfService_OutgoingDisconnectionPending *
nsscfOutOfService_OutgoingDisconnectionPending :: _only = 0;

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


nsscfOutOfService_OutgoingDisconnectionPending ::
nsscfOutOfService_OutgoingDisconnectionPending(void)
    : nsscfState()
{
    return;
}

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


///////////////////////////////////////////////////////////////////////////
// void nsscfOutOfService_OutgoingDisconnectionPending :: naalSTARTreqAct()
// Implemented as in Q.2140 page 48 SDL description

void nsscfOutOfService_OutgoingDisconnectionPending ::
naalSTARTreqAct(naalSTARTreq *, pfProtocol *protocol_)
{
    nsscfProtocol *nsscf = (nsscfProtocol *) protocol_;
    nsscf->sendAaESTABLISHreq();
    nsscf->sendMaalREPORTind(LBC_EMPTY, UBC_ALN);
    nsscf->timerT2start();
    nsscf->toNsscfAlignment_OutgoingConnectionPending();
    return;
}


///////////////////////////////////////////////////////////////////////////
// void nsscfOutOfService_OutgoingDisconnectionPending ::
// naalRETRIEVE_BSNTreqAct()
// Implemented as in Q.2140 page 48 SDL description

void nsscfOutOfService_OutgoingDisconnectionPending ::
naalRETRIEVE_BSNTreqAct(naalRETRIEVE_BSNTreq *,
                        pfProtocol *protocol_)
{
    nsscfProtocol *nsscf = (nsscfProtocol *) protocol_;
    pfUlong bsnt = nsscf->getBSNT();
    if (bsnt == NSSCF_NO_BSNT_AVAILABLE)
    {
        nsscf->sendNaalBSNT_NOT_RETRIEVABLEconf();
    }
    else
    {
        nsscf->sendNaalBSNTconf(bsnt);
    }
    return;
}


///////////////////////////////////////////////////////////////////////////
// void nsscfOutOfService_OutgoingDisconnectionPending ::
// naalRETRIEVAL_REQUEST_AND_FSNCreqAct()
// Implemented as in Q.2140 page 48 SDL description

void nsscfOutOfService_OutgoingDisconnectionPending ::
naalRETRIEVAL_REQUEST_AND_FSNCreqAct(
    naalRETRIEVAL_REQUEST_AND_FSNCreq *messenger_,
    pfProtocol *protocol_)
{
    ((nsscfProtocol *) protocol_)->sendAaRETRIEVEreq(messenger_->getFSNC());
    return;
}


////////////////////////////////////////////////////////////////////////////
// void nsscfOutOfService_OutgoingDisconnectionPending :: aaRELEASEconfAct()
// Implemented as in Q.2140 page 48 SDL description

void nsscfOutOfService_OutgoingDisconnectionPending :: aaRELEASEconfAct(
    aaRELEASEconf *,
    pfProtocol *protocol_)
{
    nsscfProtocol *nsscf = (nsscfProtocol *) protocol_;
    nsscf->toNsscfOutOfService_Idle();
    return;
}


////////////////////////////////////////////////////////////////////////////
// void nsscfOutOfService_OutgoingDisconnectionPending :: aaRETRIEVEindAct()
// Implemented as in Q.2140 page 48 SDL description

void nsscfOutOfService_OutgoingDisconnectionPending :: aaRETRIEVEindAct(
    aaRETRIEVEind *messenger_,
    pfProtocol *protocol_)
{
    pfFrame frame = messenger_->getMessageUnit();
    if (frame.length() > NSSCF_PDU_LENGTH)
    {
        ((nsscfProtocol *) protocol_)->sendNaalRETRIEVED_MESSAGESind(frame);
    }
    return;
}


///////////////////////////////////////////////////////////////////////////
// void nsscfOutOfService_OutgoingDisconnectionPending ::
// aaRETRIEVE_COMPLETEindAct()
// Implemented as in Q.2140 page 48 SDL description

void nsscfOutOfService_OutgoingDisconnectionPending ::
aaRETRIEVE_COMPLETEindAct(
    aaRETRIEVE_COMPLETEind *,
    pfProtocol *protocol_)
{
    ((nsscfProtocol *) protocol_)->sendNaalRETRIEVAL_COMPLETEind();
    return;
}

