IBR-DTN  1.0.0
IPNDAgent.h
Go to the documentation of this file.
1 /*
2  * IPNDAgent.h
3  *
4  * IPND is based on the Internet-Draft for DTN-IPND.
5  *
6  *
7  * Copyright (C) 2011 IBR, TU Braunschweig
8  *
9  * Written-by: Johannes Morgenroth <morgenroth@ibr.cs.tu-bs.de>
10  *
11  * Licensed under the Apache License, Version 2.0 (the "License");
12  * you may not use this file except in compliance with the License.
13  * You may obtain a copy of the License at
14  *
15  * http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  *
23  */
24 
25 #ifndef IPNDAGENT_H_
26 #define IPNDAGENT_H_
27 
28 #include "Component.h"
30 #include "net/P2PDialupEvent.h"
31 #include "core/EventReceiver.h"
32 #include <ibrcommon/net/vinterface.h>
33 #include <ibrcommon/net/vsocket.h>
34 #include <ibrcommon/link/LinkManager.h>
35 #include <ibrcommon/thread/Mutex.h>
36 #include <list>
37 #include <map>
38 
39 using namespace dtn::data;
40 
41 namespace dtn
42 {
43  namespace net
44  {
45  class IPNDAgent : public dtn::core::EventReceiver<dtn::net::P2PDialupEvent>, public dtn::daemon::IndependentComponent, public ibrcommon::LinkManager::EventCallback, public DiscoveryBeaconHandler
46  {
47  static const std::string TAG;
48 
49  public:
50  IPNDAgent(int port);
51  virtual ~IPNDAgent();
52 
53  void add(const ibrcommon::vaddress &address);
54  void bind(const ibrcommon::vinterface &net);
55 
59  virtual const std::string getName() const;
60 
61  void eventNotify(const ibrcommon::LinkEvent &evt);
62 
66  void raiseEvent(const dtn::net::P2PDialupEvent &evt) throw ();
67 
71  void onAdvertiseBeacon(const ibrcommon::vinterface &iface, const DiscoveryBeacon &beacon) throw ();
72 
73  protected:
74  virtual void componentRun() throw ();
75  virtual void componentUp() throw ();
76  virtual void componentDown() throw ();
77  void __cancellation() throw ();
78 
79  private:
80  void join(const ibrcommon::vinterface &iface) throw ();
81  void leave(const ibrcommon::vinterface &iface) throw ();
82 
83  void join(const ibrcommon::vinterface &iface, const ibrcommon::vaddress &addr) throw ();
84  void leave(const ibrcommon::vinterface &iface, const ibrcommon::vaddress &addr) throw ();
85 
86  void send(const DiscoveryBeacon &a, const ibrcommon::vinterface &iface, const ibrcommon::vaddress &addr);
87 
88 #ifndef __WIN32__
89  ibrcommon::vinterface _virtual_mcast_iface;
90 #endif
91 
92  ibrcommon::vsocket _socket;
93  bool _state;
94  int _port;
95 
96  std::set<ibrcommon::vaddress> _destinations;
97 
98  ibrcommon::Mutex _interface_lock;
99  std::set<ibrcommon::vinterface> _interfaces;
100  };
101  }
102 }
103 
104 #endif /* IPNDAGENT_H_ */
const std::string TAG
Definition: dtnoutbox.cpp:62