IBR-DTNSuite  0.8
daemon/src/net/IPNDAgent.h
Go to the documentation of this file.
00001 /*
00002  * IPNDAgent.h
00003  *
00004  *  Created on: 09.09.2009
00005  *      Author: morgenro
00006  *
00007  * IPND is based on the Internet-Draft for DTN-IPND.
00008  *
00009  * MUST support multicast
00010  * SHOULD support broadcast and unicast
00011  *
00012  *
00013  *
00014  */
00015 
00016 #ifndef IPNDAGENT_H_
00017 #define IPNDAGENT_H_
00018 
00019 #include "Component.h"
00020 #include "net/DiscoveryAgent.h"
00021 #include "net/DiscoveryAnnouncement.h"
00022 #include <ibrcommon/net/vinterface.h>
00023 #include <ibrcommon/net/udpsocket.h>
00024 #include <ibrcommon/net/vsocket.h>
00025 #include <ibrcommon/net/LinkManager.h>
00026 #include <list>
00027 #include <map>
00028 
00029 using namespace dtn::data;
00030 
00031 namespace dtn
00032 {
00033         namespace net
00034         {
00035                 class IPNDAgent : public DiscoveryAgent, public dtn::daemon::IndependentComponent, public ibrcommon::LinkManager::EventCallback
00036                 {
00037                 public:
00038                         IPNDAgent(int port, const ibrcommon::vaddress &address);
00039                         virtual ~IPNDAgent();
00040 
00041                         void bind(const ibrcommon::vinterface &net);
00042 
00046                         virtual const std::string getName() const;
00047 
00048                         void eventNotify(const ibrcommon::LinkManagerEvent &evt);
00049 
00050                 protected:
00051                         void sendAnnoucement(const u_int16_t &sn, std::list<DiscoveryService> &services);
00052                         virtual void componentRun();
00053                         virtual void componentUp();
00054                         virtual void componentDown();
00055                         void __cancellation();
00056 
00057                 private:
00058                         void send(const DiscoveryAnnouncement &a, const ibrcommon::vinterface &iface, const ibrcommon::vaddress &addr, const unsigned int port);
00059 
00060                         DiscoveryAnnouncement::DiscoveryVersion _version;
00061                         ibrcommon::vsocket _socket;
00062                         ibrcommon::vaddress _destination;
00063                         std::list<ibrcommon::vinterface> _interfaces;
00064 
00065                         int _port;
00066                         int _fd;
00067                 };
00068         }
00069 }
00070 
00071 #endif /* IPNDAGENT_H_ */