//Editor-Info: -*- C++ -*-
//
//Subject: TOVE project
//
//File: unirrnprotocol.cpp
//
//Version: $Revision: 1.12 $
//
//State: $State: Exp $
//
//Date: $Date: 1998/12/14 06:56:32 $
//
//Organisation:
//      Helsinki University of Technology
//      Laboratory of Telecommunications Software and Multimedia
//
//Author:
//      Jari Pusa
//
//Description:
//
//
//Copyright:
//
//
//Licence:
//
//
//History: 

#include "unirrnprotocol.h"

#include "pf/debug.h"

#include "unidefs.h"
#include "unistrings.h"
#include "unipdu.h"
#include "uniprimitives.h"
#include "unirrnstate.h"

pfConduit uniRRNProtocol :: create(void)
{
    uniRRNProtocol *protocol = new uniRRNProtocol;
    pfConduit proxy(protocol);
    return proxy;
}
    
uniRRNProtocol :: uniRRNProtocol(void)
    : pfProtocol()
{
    defineTimer(uniT317Str, uniT317timeout::create(), uniT317expire);
    
    changeToNullState();
    return;
}

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

void uniRRNProtocol :: sendRESETind(uniRESTARTpdu *pdu_)
{
    uniRESETind *primitive = uniRESETind::create();
    primitive->copyIfPresent(*pdu_, uniConnectionIdentifierStr);
    primitive->copyIfPresent(*pdu_, uniRestartIndicatorStr);
    toA(primitive);
    return;
}

void uniRRNProtocol :: sendRESET_ERRORind(pfUlong reason_, pfUlong callState_)
{
    uniRESET_ERRORind *primitive =
        uniRESET_ERRORind::create(reason_, callState_);
    toA(primitive);
    return;
}

void uniRRNProtocol :: sendRESTART_ACKpdu(uniRESETresp *primitive_)
{
    uniRESTART_ACKpdu *message = uniRESTART_ACKpdu::create();
    message->copyIfPresent(*primitive_, uniRestartIndicatorStr);
    message->copyIfPresent(*primitive_, uniConnectionIdentifierStr);
    toA(message);
    return;
}

void uniRRNProtocol :: changeToNullState(void)
{
    debugUser("RRN in Null State");
    changeState(uniRRNNullState::instance());
    return;
}

void uniRRNProtocol :: changeToRestartState(void)
{
    debugUser("RRN in Restart State");
    changeState(uniRRNRestartState::instance());
    return;
}

