|
INET Framework for OMNeT++/OMNEST
|
Module for representing a connection in TcpLwip stack.
More...
#include <TcpLwipConnection.h>
|
| | TcpLwipConnection (const TcpLwipConnection &) |
| |
| void | listen (const L3Address &localAddr, unsigned short localPort) |
| |
| void | connect (const L3Address &localAddr, unsigned short localPort, const L3Address &remoteAddr, unsigned short remotePort) |
| |
| void | close () |
| |
| void | abort () |
| |
| void | accept () |
| |
| void | send (Packet *msgP) |
| |
| int | send_data (void *data, int len) |
| |
| void | recordSend (const TcpHeader &tcpsegP) |
| |
| void | recordReceive (const TcpHeader &tcpsegP) |
| |
| void | process_OPEN_ACTIVE (TcpOpenCommand *tcpCommandP, cMessage *msgP) |
| |
| void | process_OPEN_PASSIVE (TcpOpenCommand *tcpCommandP, cMessage *msgP) |
| |
| void | process_ACCEPT (TcpAcceptCommand *tcpCommand, cMessage *msg) |
| |
| void | process_SEND (Packet *msgP) |
| |
| void | process_CLOSE (TcpCommand *tcpCommandP, cMessage *msgP) |
| |
| void | process_ABORT (TcpCommand *tcpCommandP, cMessage *msgP) |
| |
| void | process_STATUS (TcpCommand *tcpCommandP, cMessage *msgP) |
| |
| void | fillStatusInfo (TcpStatusInfo &statusInfo) |
| |
Module for representing a connection in TcpLwip stack.
◆ TcpLwipConnection() [1/2]
◆ TcpLwipConnection() [2/2]
| inet::tcp::TcpLwipConnection::TcpLwipConnection |
( |
| ) |
|
|
inline |
◆ ~TcpLwipConnection()
| inet::tcp::TcpLwipConnection::~TcpLwipConnection |
( |
| ) |
|
90 pcbM->callback_arg =
nullptr;
◆ abort()
| void inet::tcp::TcpLwipConnection::abort |
( |
| ) |
|
|
protected |
◆ accept()
| void inet::tcp::TcpLwipConnection::accept |
( |
| ) |
|
|
protected |
246 throw cRuntimeError(
"socket already accepted/not a fork of a listening socket");
Referenced by process_ACCEPT().
◆ close()
| void inet::tcp::TcpLwipConnection::close |
( |
| ) |
|
|
protected |
◆ connect()
| void inet::tcp::TcpLwipConnection::connect |
( |
const L3Address & |
localAddr, |
|
|
unsigned short |
localPort, |
|
|
const L3Address & |
remoteAddr, |
|
|
unsigned short |
remotePort |
|
) |
| |
|
protected |
◆ do_SEND()
| void inet::tcp::TcpLwipConnection::do_SEND |
( |
| ) |
|
◆ fillStatusInfo()
| void inet::tcp::TcpLwipConnection::fillStatusInfo |
( |
TcpStatusInfo & |
statusInfo | ) |
|
|
protected |
180 statusInfo.setLocalAddr((
pcbM->local_ip.addr));
181 statusInfo.setLocalPort(
pcbM->local_port);
182 statusInfo.setRemoteAddr((
pcbM->remote_ip.addr));
183 statusInfo.setRemotePort(
pcbM->remote_port);
185 statusInfo.setSnd_mss(
pcbM->mss);
187 statusInfo.setSnd_nxt(
pcbM->snd_nxt);
189 statusInfo.setSnd_wnd(
pcbM->snd_wnd);
191 statusInfo.setSnd_wl1(
pcbM->snd_wl1);
192 statusInfo.setSnd_wl2(
pcbM->snd_wl2);
194 statusInfo.setRcv_nxt(
pcbM->rcv_nxt);
195 statusInfo.setRcv_wnd(
pcbM->rcv_wnd);
Referenced by process_STATUS().
◆ indicationName()
| const char * inet::tcp::TcpLwipConnection::indicationName |
( |
int |
code | ) |
|
|
static |
◆ initConnection() [1/2]
| void inet::tcp::TcpLwipConnection::initConnection |
( |
TcpLwip & |
tcpLwipP, |
|
|
int |
connIdP |
|
) |
| |
◆ initConnection() [2/2]
| void inet::tcp::TcpLwipConnection::initConnection |
( |
TcpLwipConnection & |
tcpLwipConnectionP, |
|
|
int |
connIdP, |
|
|
LwipTcpLayer::tcp_pcb * |
pcbP |
|
) |
| |
80 pcbM->callback_arg =
this;
◆ isSendUpEnabled()
| bool inet::tcp::TcpLwipConnection::isSendUpEnabled |
( |
| ) |
|
|
inline |
◆ listen()
| void inet::tcp::TcpLwipConnection::listen |
( |
const L3Address & |
localAddr, |
|
|
unsigned short |
localPort |
|
) |
| |
|
protected |
◆ notifyAboutSending()
| void inet::tcp::TcpLwipConnection::notifyAboutSending |
( |
const TcpHeader & |
tcpsegP | ) |
|
◆ process_ABORT()
| void inet::tcp::TcpLwipConnection::process_ABORT |
( |
TcpCommand * |
tcpCommandP, |
|
|
cMessage * |
msgP |
|
) |
| |
|
protected |
◆ process_ACCEPT()
| void inet::tcp::TcpLwipConnection::process_ACCEPT |
( |
TcpAcceptCommand * |
tcpCommand, |
|
|
cMessage * |
msg |
|
) |
| |
|
protected |
◆ process_CLOSE()
| void inet::tcp::TcpLwipConnection::process_CLOSE |
( |
TcpCommand * |
tcpCommandP, |
|
|
cMessage * |
msgP |
|
) |
| |
|
protected |
◆ process_OPEN_ACTIVE()
| void inet::tcp::TcpLwipConnection::process_OPEN_ACTIVE |
( |
TcpOpenCommand * |
tcpCommandP, |
|
|
cMessage * |
msgP |
|
) |
| |
|
protected |
407 if (tcpCommandP->getRemoteAddr().isUnspecified() || tcpCommandP->getRemotePort() == -1)
408 throw cRuntimeError(
"Error processing command OPEN_ACTIVE: remote address and port must be specified");
410 int localPort = tcpCommandP->getLocalPort();
414 EV_INFO <<
this <<
": OPEN: "
415 << tcpCommandP->getLocalAddr() <<
":" << localPort <<
" --> "
416 << tcpCommandP->getRemoteAddr() <<
":" << tcpCommandP->getRemotePort() <<
"\n";
417 connect(tcpCommandP->getLocalAddr(), localPort,
418 tcpCommandP->getRemoteAddr(), tcpCommandP->getRemotePort());
Referenced by processAppCommand().
◆ process_OPEN_PASSIVE()
| void inet::tcp::TcpLwipConnection::process_OPEN_PASSIVE |
( |
TcpOpenCommand * |
tcpCommandP, |
|
|
cMessage * |
msgP |
|
) |
| |
|
protected |
428 if (tcpCommandP->getFork() ==
false)
429 throw cRuntimeError(
"Error processing command OPEN_PASSIVE: non-forking listening connections are not supported yet");
431 if (tcpCommandP->getLocalPort() == -1)
432 throw cRuntimeError(
"Error processing command OPEN_PASSIVE: local port must be specified");
434 EV_INFO <<
this <<
"Starting to listen on: " << tcpCommandP->getLocalAddr() <<
":"
435 << tcpCommandP->getLocalPort() <<
"\n";
436 listen(tcpCommandP->getLocalAddr(), tcpCommandP->getLocalPort());
Referenced by processAppCommand().
◆ process_SEND()
| void inet::tcp::TcpLwipConnection::process_SEND |
( |
Packet * |
msgP | ) |
|
|
protected |
450 EV_INFO <<
this <<
": processing SEND command, len=" << msgP->getByteLength() << endl;
Referenced by processAppCommand().
◆ process_STATUS()
| void inet::tcp::TcpLwipConnection::process_STATUS |
( |
TcpCommand * |
tcpCommandP, |
|
|
cMessage * |
msgP |
|
) |
| |
|
protected |
472 EV_INFO <<
this <<
": processing STATUS(" <<
connIdM <<
") command\n";
474 TcpStatusInfo *statusInfo =
new TcpStatusInfo();
476 msgP->setControlInfo(statusInfo);
Referenced by processAppCommand().
◆ processAppCommand()
| void inet::tcp::TcpLwipConnection::processAppCommand |
( |
cMessage * |
msgP | ) |
|
364 TcpCommand *tcpCommand = check_and_cast_nullable<TcpCommand *>(msgP->removeControlInfo());
366 switch (msgP->getKind()) {
376 process_ACCEPT(check_and_cast<TcpAcceptCommand *>(tcpCommand), msgP);
399 throw cRuntimeError(
"Wrong command from app: %d", msgP->getKind());
Referenced by inet::tcp::TcpLwip::handleUpperCommand().
◆ recordReceive()
| void inet::tcp::TcpLwipConnection::recordReceive |
( |
const TcpHeader & |
tcpsegP | ) |
|
|
protected |
48 if (tcpsegP.getAckBit())
◆ recordSend()
| void inet::tcp::TcpLwipConnection::recordSend |
( |
const TcpHeader & |
tcpsegP | ) |
|
|
protected |
◆ send()
| void inet::tcp::TcpLwipConnection::send |
( |
Packet * |
msgP | ) |
|
|
protected |
◆ send_data()
| int inet::tcp::TcpLwipConnection::send_data |
( |
void * |
data, |
|
|
int |
len |
|
) |
| |
|
protected |
267 if (datalen > 0xFFFF)
285 if (datalen < snd_buf)
299 ASSERT(
pcbM->snd_lbb - ss == (
u32_t)written);
Referenced by do_SEND().
◆ sendAvailableIndicationToApp()
| void inet::tcp::TcpLwipConnection::sendAvailableIndicationToApp |
( |
int |
listenConnId | ) |
|
Utility: sends TCP_I_AVAILABLE indication with TcpAvailableInfo to application.
101 L3Address localAddr(
pcbM->local_ip.addr), remoteAddr(
pcbM->remote_ip.addr);
103 TcpAvailableInfo *ind =
new TcpAvailableInfo();
105 ind->setLocalAddr(localAddr);
106 ind->setRemoteAddr(remoteAddr);
107 ind->setLocalPort(
pcbM->local_port);
108 ind->setRemotePort(
pcbM->remote_port);
110 indication->setControlInfo(ind);
112 indication->addTag<SocketInd>()->setSocketId(listenConnId);
113 tcpLwipM->send(indication,
"appOut");
◆ sendEstablishedMsg()
| void inet::tcp::TcpLwipConnection::sendEstablishedMsg |
( |
| ) |
|
120 TcpConnectInfo *tcpConnectInfo =
new TcpConnectInfo();
122 L3Address localAddr(
pcbM->local_ip.addr), remoteAddr(
pcbM->remote_ip.addr);
124 tcpConnectInfo->setLocalAddr(localAddr);
125 tcpConnectInfo->setRemoteAddr(remoteAddr);
126 tcpConnectInfo->setLocalPort(
pcbM->local_port);
127 tcpConnectInfo->setRemotePort(
pcbM->remote_port);
129 indication->setControlInfo(tcpConnectInfo);
131 indication->addTag<SocketInd>()->setSocketId(
connIdM);
133 tcpLwipM->send(indication,
"appOut");
Referenced by accept(), and inet::tcp::TcpLwip::tcp_event_conn().
◆ sendIndicationToApp()
| void inet::tcp::TcpLwipConnection::sendIndicationToApp |
( |
int |
code | ) |
|
◆ sendUpData()
| void inet::tcp::TcpLwipConnection::sendUpData |
( |
| ) |
|
◆ connIdM
| int inet::tcp::TcpLwipConnection::connIdM |
Referenced by do_SEND(), initConnection(), inet::tcp::TcpLwip::ip_output(), inet::tcp::TcpLwip::printConnBrief(), process_ABORT(), process_CLOSE(), process_STATUS(), inet::tcp::TcpLwip::removeConnection(), sendAvailableIndicationToApp(), sendEstablishedMsg(), sendIndicationToApp(), sendUpData(), inet::tcp::TcpLwip::tcp_event_accept(), inet::tcp::TcpLwip::tcp_event_err(), and inet::tcp::TcpLwip::tcp_event_recv().
◆ isListenerM
| bool inet::tcp::TcpLwipConnection::isListenerM = false |
|
protected |
◆ onCloseM
| bool inet::tcp::TcpLwipConnection::onCloseM = false |
|
protected |
◆ pcbM
| LwipTcpLayer::tcp_pcb* inet::tcp::TcpLwipConnection::pcbM = nullptr |
Referenced by abort(), close(), connect(), do_SEND(), fillStatusInfo(), initConnection(), listen(), inet::tcp::TcpLwip::lwip_free_pcb_event(), inet::tcp::TcpLwip::lwip_tcp_event(), inet::tcp::TcpLwip::removeConnection(), send_data(), sendAvailableIndicationToApp(), sendEstablishedMsg(), inet::tcp::TcpLwip::tcp_event_recv(), and ~TcpLwipConnection().
◆ rcvAckSignal
| simsignal_t inet::tcp::TcpLwipConnection::rcvAckSignal = registerSignal("rcvAck") |
|
staticprotected |
◆ rcvSeqSignal
| simsignal_t inet::tcp::TcpLwipConnection::rcvSeqSignal = registerSignal("rcvSeq") |
|
staticprotected |
◆ rcvWndSignal
| simsignal_t inet::tcp::TcpLwipConnection::rcvWndSignal = registerSignal("rcvWnd") |
|
staticprotected |
◆ receiveQueueM
◆ sendQueueM
◆ sendUpEnabled
| bool inet::tcp::TcpLwipConnection::sendUpEnabled = false |
|
protected |
◆ sndAckSignal
| simsignal_t inet::tcp::TcpLwipConnection::sndAckSignal = registerSignal("sndAck") |
|
staticprotected |
◆ sndNxtSignal
| simsignal_t inet::tcp::TcpLwipConnection::sndNxtSignal = registerSignal("sndNxt") |
|
staticprotected |
◆ sndWndSignal
| simsignal_t inet::tcp::TcpLwipConnection::sndWndSignal = registerSignal("sndWnd") |
|
staticprotected |
◆ tcpLwipM
| TcpLwip* inet::tcp::TcpLwipConnection::tcpLwipM = nullptr |
Referenced by abort(), close(), connect(), do_SEND(), initConnection(), listen(), process_OPEN_ACTIVE(), process_OPEN_PASSIVE(), process_STATUS(), send_data(), sendAvailableIndicationToApp(), sendEstablishedMsg(), sendIndicationToApp(), sendUpData(), and ~TcpLwipConnection().
◆ totalSentM
| long int inet::tcp::TcpLwipConnection::totalSentM = 0 |
|
protected |
The documentation for this class was generated from the following files:
@ TCP_I_TIMED_OUT
Definition: TcpCommand_m.h:133
static simsignal_t sndAckSignal
Definition: TcpLwipConnection.h:94
static simsignal_t rcvWndSignal
Definition: TcpLwipConnection.h:96
void process_SEND(Packet *msgP)
Definition: TcpLwipConnection.cc:448
TcpLwipReceiveQueue * receiveQueueM
Definition: TcpLwipConnection.h:82
void recordSend(const TcpHeader &tcpsegP)
Definition: TcpLwipConnection.cc:34
@ TCP_I_CLOSED
Definition: TcpCommand_m.h:130
void send(Packet *msgP)
Definition: TcpLwipConnection.cc:251
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd TransportProtocolInd
Definition: IUdp-gates.txt:20
void sendUpData()
Definition: TcpLwipConnection.cc:342
Definition: ip_addr.h.txt:47
void process_ABORT(TcpCommand *tcpCommandP, cMessage *msgP)
Definition: TcpLwipConnection.cc:462
static const Protocol tcp
Definition: Protocol.h:112
@ TCP_I_ESTABLISHED
Definition: TcpCommand_m.h:128
void process_OPEN_ACTIVE(TcpOpenCommand *tcpCommandP, cMessage *msgP)
Definition: TcpLwipConnection.cc:403
virtual unsigned int getBytesForTcpLayer(void *bufferP, unsigned int bufferLengthP) const
Copy data to the buffer for send to LWIP.
Definition: TcpLwipQueues.cc:44
static simsignal_t rcvSeqSignal
Definition: TcpLwipConnection.h:97
void memp_free(memp_t type, void *mem)
Put an element back into its pool.
Definition: memp.cc:356
@ TCP_I_PEER_CLOSED
Definition: TcpCommand_m.h:129
int connIdM
Definition: TcpLwipConnection.h:79
static const char * indicationName(int code)
Definition: TcpLwipConnection.cc:140
virtual void setConnection(TcpLwipConnection *connP)
Add a connection queue.
Definition: TcpLwipQueues.cc:107
@ TCP_I_AVAILABLE
Definition: TcpCommand_m.h:127
bool onCloseM
Definition: TcpLwipConnection.h:88
virtual void notifyAboutSending(const TcpHeader *tcpsegP)
notify the queue about output messages
Definition: TcpLwipQueues.cc:163
virtual void enqueueAppData(Packet *msgP)
Called on SEND app command, it inserts in the queue the data the user wants to send.
Definition: TcpLwipQueues.cc:37
@ TCP_C_ACCEPT
Definition: TcpCommand_m.h:84
@ TCP_I_CONNECTION_RESET
Definition: TcpCommand_m.h:132
@ TCP_I_URGENT_DATA
Definition: TcpCommand_m.h:126
cObject * createOne(const char *className, const char *defaultNamespace)
Like cObjectFactory::createOne(), except it starts searching for the class in the given namespace.
Definition: INETUtils.cc:147
void listen(const L3Address &localAddr, unsigned short localPort)
Definition: TcpLwipConnection.cc:201
static simsignal_t rcvAckSignal
Definition: TcpLwipConnection.h:98
@ TCP_C_SEND
Definition: TcpCommand_m.h:85
static simsignal_t sndNxtSignal
Definition: TcpLwipConnection.h:93
bool isListenerM
Definition: TcpLwipConnection.h:87
#define ERR_MEM
Definition: err.h:57
LwipTcpLayer * getLwipTcpLayer()
Definition: TcpLwip.h:93
value< double, units::s > s
Definition: Units.h:1235
@ TCP_C_STATUS
Definition: TcpCommand_m.h:88
static const Protocol udp
Definition: Protocol.h:117
virtual void dequeueTcpLayerMsg(unsigned int msgLengthP)
This function should remove msgLengthP bytes from TCP layer queue.
Definition: TcpLwipQueues.cc:58
@ TCP_C_OPEN_PASSIVE
Definition: TcpCommand_m.h:83
void accept()
Definition: TcpLwipConnection.cc:243
void do_SEND()
Definition: TcpLwipConnection.cc:306
void close()
Definition: TcpLwipConnection.cc:227
void sendEstablishedMsg()
Definition: TcpLwipConnection.cc:117
virtual void setConnection(TcpLwipConnection *connP)
set connection queue, and initialise queue variables.
Definition: TcpLwipQueues.cc:31
TcpLwip * tcpLwipM
Definition: TcpLwipConnection.h:83
void fillStatusInfo(TcpStatusInfo &statusInfo)
Definition: TcpLwipConnection.cc:175
@ TCP_C_CLOSE
Definition: TcpCommand_m.h:86
uint32_t u32_t
Definition: cc.h:38
void process_CLOSE(TcpCommand *tcpCommandP, cMessage *msgP)
Definition: TcpLwipConnection.cc:454
@ TCP_C_ABORT
Definition: TcpCommand_m.h:87
bool sendUpEnabled
Definition: TcpLwipConnection.h:89
void abort()
Definition: TcpLwipConnection.cc:237
int send_data(void *data, int len)
Definition: TcpLwipConnection.cc:262
void process_OPEN_PASSIVE(TcpOpenCommand *tcpCommandP, cMessage *msgP)
Definition: TcpLwipConnection.cc:423
LwipTcpLayer::tcp_pcb * pcbM
Definition: TcpLwipConnection.h:80
void connect(const L3Address &localAddr, unsigned short localPort, const L3Address &remoteAddr, unsigned short remotePort)
Definition: TcpLwipConnection.cc:214
static simsignal_t sndWndSignal
Definition: TcpLwipConnection.h:92
uint16_t u16_t
Definition: cc.h:34
void process_ACCEPT(TcpAcceptCommand *tcpCommand, cMessage *msg)
Definition: TcpLwipConnection.cc:441
virtual Packet * extractBytesUpTo()
Should create a packet to be passed up to the app, up to (but NOT including) the given sequence no (u...
Definition: TcpLwipQueues.cc:132
TcpLwipSendQueue * sendQueueM
Definition: TcpLwipConnection.h:81
@ TCP_I_STATUS
Definition: TcpCommand_m.h:134
@ TCP_I_DATA
Definition: TcpCommand_m.h:125
long int totalSentM
Definition: TcpLwipConnection.h:86
void process_STATUS(TcpCommand *tcpCommandP, cMessage *msgP)
Definition: TcpLwipConnection.cc:470
#define ERR_OK
Definition: err.h:56
virtual unsigned long getBytesAvailable() const
Utility function: returns how many bytes are available in the queue.
Definition: TcpLwipQueues.cc:63
@ TCP_I_CONNECTION_REFUSED
Definition: TcpCommand_m.h:131
@ TCP_C_OPEN_ACTIVE
Definition: TcpCommand_m.h:82