//Editor-Info: -*- C++ -*-
//
//Subject: TOVE-project / UNI-SSCF
//
//File: usscfprotocol.cpp
//
//Version: $Revision: 1.20 $
//
//State: $State: Exp $
//
//Date: $Date: 1998/10/07 16:28:11 $
//
//Organisation:
//      Helsinki University of Technology
//      Laboratory of Telecommunications and Multimedia
//
//Author:
//      Vesa-Matti Puro 
//
//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 "pf/types.h"
#include "usscf.h"
#include "usscfprotocol.h"
#include "usscfstate1_1.h"
#include "usscfstate2_2.h"
#include "usscfstate2_5.h"
#include "usscfstate3_4.h"
#include "usscfstate4_10.h"
#include "protocol/saal/saalunilink.h"
#include "iface/aaif/aadownprimitives.h"
#include "iface/uaalif/uaalupprimitives.h"

//#include "switch/tovemanager.h"

// ----------------------------------------------------------------------

usscfProtocol :: usscfProtocol(saalUNIlink *manager_)
    : pfProtocol(),
      _manager(manager_)
{
    changeState(usscfConnectionReleased_Idle::instance());
    return;
}

usscfProtocol :: usscfProtocol(const usscfProtocol &other_, 
                               saalUNIlink *manager_)
    : pfProtocol(other_),
      _manager(manager_)
{
    return;
}

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

// ----------------------------------------------------------------------

void usscfProtocol :: sendUaalESTABLISHind(void)
{
    uaalESTABLISHind *messenger = new uaalESTABLISHind;
    assert(messenger);
    toB(messenger);
    return;
}

void usscfProtocol :: sendUaalESTABLISHconf(void)
{
    uaalESTABLISHconf *messenger = new uaalESTABLISHconf;
    assert(messenger);
    toB(messenger);
    return;
}

void usscfProtocol :: sendUaalRELEASEind(void)
{
    uaalRELEASEind *messenger = new uaalRELEASEind;
    assert(messenger);
    toB(messenger);
    return;
}

void usscfProtocol :: sendUaalRELEASEconf(void)
{
    uaalRELEASEconf *messenger = new uaalRELEASEconf;
    assert(messenger);
    toB(messenger);
    return;
}

void usscfProtocol :: sendUaalDATAind(const pfFrame &mu_)
{
    uaalDATAind *messenger = new uaalDATAind;
    assert(messenger);
    messenger->setMessageUnit(mu_);
    toB(messenger);
    return;
}

void usscfProtocol :: sendUaalUNITDATAind(const pfFrame &mu_)
{
    uaalUNITDATAind *messenger = new uaalUNITDATAind;
    assert(messenger);
    messenger->setMessageUnit(mu_);
    toB(messenger);
    return;
}


// ----------------------------------------------------------------------

void usscfProtocol :: sendAaESTABLISHreq(void)
{
    aaESTABLISHreq *messenger = new aaESTABLISHreq;
    assert(messenger);
    messenger->setBufferRelease(1);
    toA(messenger);
    return;
}


void usscfProtocol :: sendAaESTABLISHresp(void)
{
    aaESTABLISHresp *messenger = new aaESTABLISHresp;
    assert(messenger);
    messenger->setBufferRelease(1);
    toA(messenger);
    return;
}


void usscfProtocol :: sendAaRECOVERresp(void)
{
    aaRECOVERresp *messenger = new aaRECOVERresp;
    assert(messenger);
    toA(messenger);
    return;
}


void usscfProtocol :: sendAaRELEASEreq(void)
{
    aaRELEASEreq *messenger = new aaRELEASEreq;
    assert(messenger);
    toA(messenger);
    return;
}


void usscfProtocol :: sendAaDATAreq(const pfFrame &mu_)
{
    aaDATAreq *messenger = new aaDATAreq;
    assert(messenger);
    messenger->setMessageUnit(mu_);
    toA(messenger);
    return;
}


void usscfProtocol :: sendAaRESYNCreq(void)
{
    aaRESYNCreq *messenger = new aaRESYNCreq;
    assert(messenger);
    toA(messenger);
    return;
}


void usscfProtocol :: sendAaRESYNCresp(void)
{
    aaRESYNCresp *messenger = new aaRESYNCresp;
    assert(messenger);
    toA(messenger);
    return;
}


void usscfProtocol :: sendAaUNITDATAreq(const pfFrame &mu_)
{
    aaUNITDATAreq *messenger = new aaUNITDATAreq;
    assert(messenger);
    messenger->setMessageUnit(mu_);
    toA(messenger);
    return;
}


void usscfProtocol
    :: toUsscfConnectionReleased_Idle(void)
{
    changeState(usscfConnectionReleased_Idle::instance());
    linkDown();
    return;
}


void usscfProtocol
    :: toUsscfAwaitingEstablish_OutgoingConnectionPending(void)
{
    changeState(usscfAwaitingEstablish_OutgoingConnectionPending
        ::instance());
    return;
}


void usscfProtocol
    :: toUsscfAwaitingEstablish_OutgoingResynchronizationPending(void)
{
    changeState(usscfAwaitingEstablish_OutgoingResynchronizationPending
        ::instance());
    return;
}


void usscfProtocol
    :: toUsscfAwaitingRelease_OutgoingDisconnectionPending(void)
{
    changeState(usscfAwaitingRelease_OutgoingDisconnectionPending
        ::instance());
    return;
}


void usscfProtocol
     :: toUsscfConnectionEstablished_DataTransferReady(void)
{
    changeState(usscfConnectionEstablished_DataTransferReady
        ::instance());
    linkUp();
    return;
}

 

void usscfProtocol :: linkUp(void)
{
//    long id = (long)getId();
//    (toveManager::instance())->linkUp(id);
    return;
}


void usscfProtocol :: linkDown(void)
{
//    long id = (long)getId();
//    (toveManager::instance())->linkDown(id);
    return;
}

