IBR-DTNSuite  0.8
daemon/src/net/DiscoveryAnnouncement.h
Go to the documentation of this file.
00001 /*
00002  * DiscoveryAnnouncement.h
00003  *
00004  *  Created on: 09.09.2009
00005  *      Author: morgenro
00006  */
00007 
00008 #ifndef DISCOVERYANNOUNCEMENT_H_
00009 #define DISCOVERYANNOUNCEMENT_H_
00010 
00011 #include <ibrdtn/data/SDNV.h>
00012 #include <ibrdtn/data/EID.h>
00013 #include <ibrdtn/data/BundleString.h>
00014 #include "net/DiscoveryService.h"
00015 #include <string>
00016 #include <list>
00017 
00018 namespace dtn
00019 {
00020         namespace net
00021         {
00022                 class DiscoveryAnnouncement
00023                 {
00024                         enum BEACON_FLAGS_V1
00025                         {
00026                                 BEACON_NO_FLAGS = 0x00,
00027                                 BEACON_SHORT = 0x01
00028                         };
00029 
00030                         enum BEACON_FLAGS_V2
00031                         {
00032                                 BEACON_CONTAINS_EID = 0x01,
00033                                 BEACON_SERVICE_BLOCK = 0x02,
00034                                 BEACON_BLOOMFILTER = 0x04
00035                         };
00036 
00037                 public:
00038                         enum DiscoveryVersion
00039                         {
00040                                 DTND_IPDISCOVERY = 0x00,
00041                                 DISCO_VERSION_00 = 0x01,
00042                                 DISCO_VERSION_01 = 0x02
00043                         };
00044 
00045                         DiscoveryAnnouncement(const DiscoveryVersion version = DISCO_VERSION_00, dtn::data::EID eid = dtn::data::EID());
00046 
00047                         virtual ~DiscoveryAnnouncement();
00048 
00049                         dtn::data::EID getEID() const;
00050 
00051                         const std::list<DiscoveryService> getServices() const;
00052                         void clearServices();
00053                         void addService(DiscoveryService service);
00054                         const DiscoveryService& getService(string name) const;
00055 
00056                         string toString() const;
00057 
00058                         void setSequencenumber(u_int16_t sequence);
00059 
00060                         bool isShort();
00061 
00062                 private:
00063                         friend std::ostream &operator<<(std::ostream &stream, const DiscoveryAnnouncement &announcement);
00064                         friend std::istream &operator>>(std::istream &stream, DiscoveryAnnouncement &announcement);
00065 
00066                         unsigned int _version;
00067                         unsigned char _flags;
00068                         dtn::data::EID _canonical_eid;
00069                         u_int16_t _sn;
00070                         dtn::data::BundleString _bloomfilter;
00071 
00072                         std::list<DiscoveryService> _services;
00073                 };
00074         }
00075 }
00076 
00077 #endif /* DISCOVERYANNOUNCEMENT_H_ */