OverSim
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
BaseTcpSupport.h
Go to the documentation of this file.
1
//
2
// Copyright (C) 2010 Institut fuer Telematik, Karlsruher Institut fuer Technologie (KIT)
3
//
4
// This program is free software; you can redistribute it and/or
5
// modify it under the terms of the GNU General Public License
6
// as published by the Free Software Foundation; either version 2
7
// of the License, or (at your option) any later version.
8
//
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with this program; if not, write to the Free Software
16
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
//
18
24
#ifndef BASETCPSUPPORT_H_
25
#define BASETCPSUPPORT_H_
26
27
#include <omnetpp.h>
28
#include <map>
29
#include <
TransportAddress.h
>
30
#include <TCPSocket.h>
31
#include <
ExtTCPSocketMap.h
>
32
33
class
BaseTcpSupport
:
public
TCPSocket::CallbackInterface
34
{
35
public
:
36
37
// Event codes
38
enum
EvCode
{
NO_EST_CONNECTION
,
PEER_CLOSED
,
PEER_TIMEDOUT
,
PEER_REFUSED
,
CONNECTION_RESET
,
CONNECTION_SUCC_ClOSED
};
39
40
// Utility methods of the CallbackInterface
41
virtual
void
socketDataArrived
(
int
connId,
void
*yourPtr, cPacket *msg,
bool
urgent);
42
virtual
void
socketEstablished
(
int
connId,
void
*yourPtr);
43
virtual
void
socketPeerClosed
(
int
connId,
void
*yourPtr);
44
// virtual void socketClosed(int connId, void *yourPtr);
45
virtual
void
socketFailure
(
int
connId,
void
*yourPtr,
int
code);
46
virtual
void
socketStatusArrived
(
int
connId,
void
*yourPtr, TCPStatusInfo *status) {
delete
status;}
47
48
protected
:
49
53
void
handleTCPMessage
(cMessage* msg);
54
60
void
bindAndListenTcp
(
int
port);
61
67
bool
isAlreadyConnected
(
TransportAddress
address);
68
74
void
establishTcpConnection
(
TransportAddress
address);
75
82
void
sendTcpData
(cPacket* msg,
TransportAddress
address);
83
90
virtual
void
handleConnectionEvent
(
EvCode
code,
TransportAddress
address);
91
99
virtual
void
handleDataReceived
(
TransportAddress
address, cPacket* msg,
bool
urgent);
100
106
virtual
void
handleIncomingConnection
(
TransportAddress
address);
107
113
void
closeTcpConnection
(
TransportAddress
address);
114
120
void
setTcpOut
(cGate* gate) {
tcpOut
= gate;}
121
127
cGate*
getTcpOut
() {
return
tcpOut
;}
128
129
private
:
130
131
ExtTCPSocketMap
sockets
;
132
typedef
std::vector<cMessage*>
msgQueue
;
133
typedef
std::map<TransportAddress, msgQueue*>
transQueue
;
134
transQueue
queuedTx
;
135
136
cGate*
tcpOut
;
137
};
138
139
#endif
/* BASETCPSUPPORT_H_ */
src
common
BaseTcpSupport.h
Generated on Fri Dec 7 2012 13:37:52 for OverSim by
1.8.1.2