OverSim
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 
55 
56 private:
57  enum LookupRpcId {
61  };
62 
63  class OverlayKeyObject : public OverlayKey, public cObject {
64  public:
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);
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 
93  P2pnsRegisterCall* registerCall);
95  P2pnsResolveCall* resolveCall);
96  void handleLookupResponse(LookupResponse* lookupResponse,
97  cObject* context, int rpcId);
98 
102  simtime_t keepaliveInterval;
103  simtime_t idCacheLifetime;
105 };
106 
107 #endif