IBR-DTNSuite  0.12
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 "core/EventReceiver.h"
32 #include <ibrcommon/net/vsocket.h>
34 #include <ibrcommon/thread/Mutex.h>
35 #include <list>
36 #include <map>
37 
38 using namespace dtn::data;
39 
40 namespace dtn
41 {
42  namespace net
43  {
45  {
46  static const std::string TAG;
47 
48  public:
49  IPNDAgent(int port);
50  virtual ~IPNDAgent();
51 
52  void add(const ibrcommon::vaddress &address);
53  void bind(const ibrcommon::vinterface &net);
54 
58  virtual const std::string getName() const;
59 
60  void eventNotify(const ibrcommon::LinkEvent &evt);
61 
65  void raiseEvent(const dtn::core::Event *evt) throw ();
66 
70  void onAdvertiseBeacon(const ibrcommon::vinterface &iface, const DiscoveryBeacon &beacon) throw ();
71 
72  protected:
73  virtual void componentRun() throw ();
74  virtual void componentUp() throw ();
75  virtual void componentDown() throw ();
76  void __cancellation() throw ();
77 
78  private:
79  void join(const ibrcommon::vinterface &iface) throw ();
80  void leave(const ibrcommon::vinterface &iface) throw ();
81 
82  void join(const ibrcommon::vinterface &iface, const ibrcommon::vaddress &addr) throw ();
83  void leave(const ibrcommon::vinterface &iface, const ibrcommon::vaddress &addr) throw ();
84 
85  void send(const DiscoveryBeacon &a, const ibrcommon::vinterface &iface, const ibrcommon::vaddress &addr);
86 
87 #ifndef __WIN32__
88  ibrcommon::vinterface _virtual_mcast_iface;
89 #endif
90 
91  ibrcommon::vsocket _socket;
92  bool _state;
93  int _port;
94 
95  std::set<ibrcommon::vaddress> _destinations;
96 
97  ibrcommon::Mutex _interface_lock;
98  std::set<ibrcommon::vinterface> _interfaces;
99  };
100  }
101 }
102 
103 #endif /* IPNDAGENT_H_ */