Using TranSAP by TcpTrans

Creating TcpTrans

#include <ovops/ptb.h>
#include <ovops/tcptrans.h>
// transport task
InetAddr ipaddr(port);         // create IP address
TcpTrans tran(&ds,&io,ipaddr); // create transport entity
STATIC_SYMBOL(tran, 0);        // inform tracing system about created object
tran.up.connect(upper_layer_port); // connect to upper layer

Request interface

Sending connect request

InetAddr addr();
TranSAP::Creq *cr = (TranSAP::Creq*)down.create(TranSAP::creq);
cr->addr = addr;

Connect request is replied by connect conform message, if making connection was succesful. Otherwise diccennect indication appears.

Sending connect responce

TranSAP::Cresp *cr =(TranSAP::Cresp*)down.create(TranSAP::cresp);
cr->cep = cep;

When connect indication appears from TranSAP, it's replied by sending connect responce.

On TcpTrans implementation connection responce is actually ignored, because this of TCP functionality, but it's good to send anyway.

Sending data request

TranSAP::Dtreq *dt = (TranSAP::Dtreq*)down.create(TranSAP::dtreq);
dt->cep = cep;    // set connection end point indentifier
dt->data = frame; // move data to message

Sending disconnect request

TranSAP::Dreq *dr = (TranSAP::Dreq*)down.create(TranSAP::dreq);
dr->cep = cep;

Disconnect request is replied by disconnect indication.

Indication interface

Receiving connect indication

TranSAP::Cind *ci = (TranSAP::Cind*)msg;
cep = ci->cep;

On cc->cep exist the new created CEP, store and remember it.

Receiving connect confirm

TranSAP::Cconf *cc = (TranSAP::Cconf*)msg;
cep = cc->cep;

On cc->cep exist the new created CEP, store and remember it.

Receiving data indication

TranSAP :: Dtind *cc = (TranSAP::Dtind*)msg;
cep = dt->cep;
frame = dt->data;

Receiving disconnect indication

TranSAP::Dind *di = (TranSAP::Dind*)msg;
cep = di->cep;