IBR-DTNSuite  0.12
WifiP2PManager.h
Go to the documentation of this file.
1 /*
2  * WifiP2PManager.h
3  *
4  * Copyright (C) 2011 IBR, TU Braunschweig
5  *
6  * Written-by: Johannes Morgenroth <morgenroth@ibr.cs.tu-bs.de>
7  * Written-by: Niels Wuerzbach <wuerzb@ibr.cs.tu-bs.de>
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  */
22 
23 #ifndef WIFIP2PMANAGER_H_
24 #define WIFIP2PMANAGER_H_
25 
26 #include "Component.h"
27 #include "net/P2PDialupExtension.h"
28 #include <ibrcommon/net/vsocket.h>
29 
30 #include <wifip2p/CoreEngine.h>
31 #include <wifip2p/WifiP2PInterface.h>
32 #include <wifip2p/Logger.h>
33 #include <list>
34 
35 namespace dtn
36 {
37  namespace net
38  {
39  class WifiP2PManager : public dtn::daemon::IndependentComponent, public dtn::net::P2PDialupExtension, public wifip2p::WifiP2PInterface, public wifip2p::Logger
40  {
41  static const std::string TAG;
42 
43  public:
44  WifiP2PManager(const std::string &ctrlpath);
45  virtual ~WifiP2PManager();
46 
50  virtual void __cancellation() throw ();
51 
55  virtual void componentUp() throw ();
56 
60  virtual void componentRun() throw ();
61 
65  virtual void componentDown() throw ();
66 
70  virtual const std::string getName() const;
71 
75  virtual dtn::core::Node::Protocol getProtocol() const;
76 
80  virtual void connect(const dtn::core::Node::URI &uri);
81 
85  virtual void disconnect(const dtn::core::Node::URI &uri);
86 
87 
91  virtual void peerFound(const wifip2p::Peer &peer);
92 
96  virtual void connectionRequest(const wifip2p::Peer &peer);
97 
101  virtual void connectionEstablished(const wifip2p::Connection &conn);
102 
106  virtual void connectionLost(const wifip2p::Connection &conn);
107 
111  virtual void log(const std::string &tag, const std::string &msg);
112 
116  virtual void log_err(const std::string &tag, const std::string &msg);
117 
121  virtual void log_debug(int debug, const std::string &tag, const std::string &msg);
122 
123  private:
124  bool _running;
125  size_t _timeout;
126  int _priority;
127 
128  wifip2p::CoreEngine ce;
129 
130  list<wifip2p::Peer> peers;
131  list<wifip2p::Connection> connections;
132  };
133  } /* namespace net */
134 } /* namespace dtn */
135 #endif /* WIFIP2PMANAGER_H_ */