//Editor-Info: -*- C++ -*-
//
//Subject: TOVE project
//
//File: unistate_n.cpp
//
//Version: $Revision: 1.15 $
//
//State: $State: Exp $
//
//Date: $Date: 1998/12/11 08:24:32 $
//
//Organisation:
//      Helsinki University of Technology
//      Laboratory of Telecommunications Software and Multimedia
//
//Author:
//      Jari Pusa
//
//Description:
//      The base class of states for network mode. 
//
//Copyright:
//
//
//Licence:
//
//
//History: 

#include "unistate_n.h"

#include "iface/sigif/sigdownprimitives.h"

#include "unidefs.h"
#include "unistrings.h"
#include "uniprotocol.h"
#include "unipdu.h"

uniNetworkState :: uniNetworkState(void)
    : uniState()
{
    return;
}

uniNetworkState :: ~uniNetworkState(void)
{
    return;
}

void uniNetworkState :: sigRELEASEreqAct(sigRELEASEreq *message_,
                                         pfProtocol *protocol_)
{
    uniProtocol *protocol = dynamic_cast<uniProtocol*>(protocol_);
    pfUlong causeR = (*message_)[uniCauseStr].getInteger(uniCause_ValueStr);
    protocol->setInteger(uniCauseRStr, causeR);
    protocol->stopAllTimers();
    protocol->sendRELEASEpduToCoOrd(message_);
    protocol->setInteger(uniT308TimeoutsStr, 0);
    protocol->startTimer(uniT308Str);
    protocol->changeToReleaseIndicationState();
    return;
}

void uniNetworkState :: uniRELEASEpduAct(uniRELEASEpdu *message_,
                                         pfProtocol *protocol_)
{
    uniProtocol *protocol = dynamic_cast<uniProtocol*>(protocol_);
    if (protocol->verifyMessage(message_, uniState_ReleaseRequest) != 0)
    {
        protocol->stopAllTimers();
        protocol->sendRELEASEindToCC(message_);
        protocol->changeToReleaseRequestState();
    }
    else
    {
        protocol->startReleaseProcess(uniCauseValue_NormalUnspecified);
    }
    return;
}

