IBR-DTNSuite  0.10
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  public:
41  static const std::string TAG;
42 
43  WifiP2PManager(const std::string &ctrlpath);
44  virtual ~WifiP2PManager();
45 
49  virtual void __cancellation() throw ();
50 
54  virtual void componentUp() throw ();
55 
59  virtual void componentRun() throw ();
60 
64  virtual void componentDown() throw ();
65 
69  virtual const std::string getName() const;
70 
74  virtual dtn::core::Node::Protocol getProtocol() const;
75 
79  virtual void connect(const dtn::core::Node::URI &uri);
80 
84  virtual void disconnect(const dtn::core::Node::URI &uri);
85 
86 
90  virtual void peerFound(wifip2p::Peer peer);
91 
95  virtual void connectionRequest(wifip2p::Peer peer);
96 
100  virtual void connectionEstablished(wifip2p::Connection conn);
101 
105  virtual void connectionLost(wifip2p::Connection conn);
106 
110  virtual void log(std::string tag, std::string msg);
111 
115  virtual void log_err(std::string tag, std::string msg);
116 
120  virtual void log_debug(int debug, std::string tag, std::string msg);
121 
122  private:
123  bool _running;
124  size_t _timeout;
125  int _priority;
126 
127  wifip2p::CoreEngine ce;
128 
129  list<wifip2p::Peer> peers;
130  list<wifip2p::Connection> connections;
131  };
132  } /* namespace net */
133 } /* namespace dtn */
134 #endif /* WIFIP2PMANAGER_H_ */