OverSim
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
P2pns.h
Go to the documentation of this file.
1
//
2
// Copyright (C) 2007 Institut fuer Telematik, Universitaet Karlsruhe (TH)
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 __P2PNS_H_
25
#define __P2PNS_H_
26
27
#include <omnetpp.h>
28
29
#include <
OverlayKey.h
>
30
#include <
SHA1.h
>
31
#include <
CommonMessages_m.h
>
32
33
#include <
BaseApp.h
>
34
#include <
RpcMacros.h
>
35
36
class
XmlRpcInterface
;
37
38
#include "
P2pnsCache.h
"
39
45
class
P2pns
:
public
BaseApp
46
{
47
public
:
48
P2pns
();
49
virtual
~P2pns
();
50
51
void
tunnel
(
const
OverlayKey
& destKey,
const
BinaryValue
& payload);
52
void
registerId
(
const
std::string& addr);
53
54
void
handleReadyMessage
(
CompReadyMessage
* msg);
55
56
private
:
57
enum
LookupRpcId
{
58
RESOLVE_LOOKUP
= 0,
59
TUNNEL_LOOKUP
= 1,
60
REFRESH_LOOKUP
= 2
61
};
62
63
class
OverlayKeyObject
:
public
OverlayKey
,
public
cObject {
64
public
:
65
OverlayKeyObject
(
const
OverlayKey
&
key
) :
OverlayKey
(key) {};
66
};
67
68
void
initializeApp
(
int
stage);
69
void
finishApp
();
70
void
handleTimerEvent
(cMessage* msg);
71
void
deliver
(
OverlayKey
& key, cMessage* msg);
72
73
void
sendTunnelMessage
(
const
TransportAddress
& addr,
74
const
BinaryValue
& payload);
75
76
void
updateIdCacheWithNewTransport
(cMessage* msg);
77
78
void
handleTunnelLookupResponse
(
LookupResponse
* lookupResponse);
79
80
bool
handleRpcCall
(
BaseCallMessage
* msg);
81
void
handleRpcResponse
(
BaseResponseMessage
* msg,
82
cPolymorphic* context,
int
rpcId, simtime_t rtt);
83
84
void
pingRpcResponse
(
PingResponse
* response, cPolymorphic* context,
85
int
rpcId, simtime_t rtt);
86
void
pingTimeout
(
PingCall
* call,
const
TransportAddress
& dest,
87
cPolymorphic* context,
int
rpcId);
88
89
void
p2pnsRegisterRpc
(
P2pnsRegisterCall
* registerCall);
90
void
p2pnsResolveRpc
(
P2pnsResolveCall
* registerCall);
91
92
void
handleDHTputCAPIResponse
(
DHTputCAPIResponse
* putResponse,
93
P2pnsRegisterCall
* registerCall);
94
void
handleDHTgetCAPIResponse
(
DHTgetCAPIResponse
* gettResponse,
95
P2pnsResolveCall
* resolveCall);
96
void
handleLookupResponse
(
LookupResponse
* lookupResponse,
97
cObject* context,
int
rpcId);
98
99
P2pnsCache
*
p2pnsCache
;
100
XmlRpcInterface
*
xmlRpcInterface
;
101
bool
twoStageResolution
;
102
simtime_t
keepaliveInterval
;
103
simtime_t
idCacheLifetime
;
104
OverlayKey
thisId
;
105
};
106
107
#endif
src
tier2
p2pns
P2pns.h
Generated on Fri Dec 7 2012 13:37:53 for OverSim by
1.8.1.2