OverSim
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
XmlRpcInterface.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 _XMLRPCINTERFACE_H__
25
#define _XMLRPCINTERFACE_H__
26
27
#include <
tunoutscheduler.h
>
28
#include <
realtimescheduler.h
>
29
#include <omnetpp.h>
30
#include <
CommonMessages_m.h
>
31
#include <
DHTMessage_m.h
>
32
#include <
BaseOverlay.h
>
33
#include <
BaseApp.h
>
34
#include <
XmlRpc.h
>
35
36
class
P2pns
;
37
38
const
int
XMLRPC_TIMEOUT
=30;
39
40
44
class
XmlRpcInterface
:
public
BaseApp
,
public
XmlRpc::XmlRpcServer
45
{
46
protected
:
47
unsigned
int
mtu
;
48
49
cMessage*
packetNotification
;
// used by TunOutScheduler to notify about new packets
50
PacketBuffer
packetBuffer
;
// received packets are stored here
51
RealtimeScheduler
*
scheduler
;
52
54
bool
readHeader
(
char
*buf, uint32_t length);
55
57
bool
readRequest
(
char
*buf, uint32_t length);
58
60
bool
writeResponse
();
61
63
enum
ServerConnectionState
{
READ_HEADER
,
READ_REQUEST
,
EXECUTE_REQUEST
,
64
WRITE_RESPONSE
};
65
66
struct
XmlRpcConnectionState
{
68
ServerConnectionState
_connectionState
;
69
71
std::string
_header
;
72
74
int
_contentLength
;
75
77
std::string
_request
;
78
80
std::string
_response
;
81
83
int
_bytesWritten
;
84
86
bool
_keepAlive
;
87
89
SOCKET
appFd
;
90
92
bool
localhost
;
93
95
uint32_t
pendingRpc
;
96
};
97
98
std::map<int, XmlRpcConnectionState>
state
;
99
SOCKET
curAppFd
;
100
bool
limitAccess
;
101
102
XmlRpc::XmlRpcServerMethod
*
_localLookup
;
103
XmlRpc::XmlRpcServerMethod
*
_lookup
;
104
XmlRpc::XmlRpcServerMethod
*
_register
;
105
XmlRpc::XmlRpcServerMethod
*
_resolve
;
106
XmlRpc::XmlRpcServerMethod
*
_put
;
107
XmlRpc::XmlRpcServerMethod
*
_get
;
108
XmlRpc::XmlRpcServerMethod
*
_dumpDht
;
109
XmlRpc::XmlRpcServerMethod
*
_joinOverlay
;
110
111
// SODESSON interface
112
XmlRpc::XmlRpcServerMethod
*
_addContact
;
113
XmlRpc::XmlRpcServerMethod
*
_removeContact
;
114
XmlRpc::XmlRpcServerMethod
*
_getContacts
;
115
XmlRpc::XmlRpcServerMethod
*
_getUserId
;
116
XmlRpc::XmlRpcServerMethod
*
_searchContact
;
117
XmlRpc::XmlRpcServerMethod
*
_publish
;
118
XmlRpc::XmlRpcServerMethod
*
_pull_notification
;
119
XmlRpc::XmlRpcServerMethod
*
_subscribe
;
120
128
bool
isPrivileged
();
129
130
void
handleAppTunPacket
(
char
*buf, uint32_t len);
131
void
handleRealworldPacket
(
char
*buf, uint32_t len);
132
void
handleCommonAPIPacket
(cMessage *msg);
133
void
handleRpcResponse
(
BaseResponseMessage
* msg,
134
cPolymorphic* context,
135
int
rpcId,
136
simtime_t rtt);
141
void
resetConnectionState
();
142
143
void
closeConnection
();
144
void
sendInternalRpcWithTimeout
(
CompType
destComp,
BaseCallMessage
*call);
145
virtual
void
handleReadyMessage
(
CompReadyMessage
* msg);
146
147
SOCKET
appTunFd
;
148
P2pns
*
p2pns
;
150
public
:
151
XmlRpcInterface
();
152
~XmlRpcInterface
();
153
154
virtual
void
initializeApp
(
int
stage);
155
160
virtual
void
handleMessage
(cMessage *msg);
161
162
// see BaseRpc.cc
163
void
handleRpcTimeout
(
BaseCallMessage
* msg,
164
const
TransportAddress
& dest,
165
cPolymorphic* context,
int
rpcId,
166
const
OverlayKey
&);
167
168
void
deliverTunneledMessage
(
const
BinaryValue
& payload);
169
170
void
localLookup
(
XmlRpc::XmlRpcValue
& params,
XmlRpc::XmlRpcValue
& result);
171
void
lookup
(
XmlRpc::XmlRpcValue
& params,
XmlRpc::XmlRpcValue
& result);
172
void
p2pnsRegister
(
XmlRpc::XmlRpcValue
& params,
XmlRpc::XmlRpcValue
& result);
173
void
p2pnsResolve
(
XmlRpc::XmlRpcValue
& params,
XmlRpc::XmlRpcValue
& result);
174
void
put
(
XmlRpc::XmlRpcValue
& params,
XmlRpc::XmlRpcValue
& result);
175
void
get
(
XmlRpc::XmlRpcValue
& params,
XmlRpc::XmlRpcValue
& result);
176
void
dumpDht
(
XmlRpc::XmlRpcValue
& params,
XmlRpc::XmlRpcValue
& result);
177
void
joinOverlay
(
XmlRpc::XmlRpcValue
& params,
XmlRpc::XmlRpcValue
& result);
178
179
};
180
181
#endif
src
tier3
xmlrpcinterface
XmlRpcInterface.h
Generated on Fri Dec 7 2012 13:37:53 for OverSim by
1.8.1.2