IBR-DTN  1.0.0
DiscoveryBeacon.h
Go to the documentation of this file.
1 /*
2  * DiscoveryBeacon.h
3  *
4  * Copyright (C) 2011 IBR, TU Braunschweig
5  *
6  * Written-by: Johannes Morgenroth <morgenroth@ibr.cs.tu-bs.de>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21 
22 #ifndef DISCOVERYBEACON_H_
23 #define DISCOVERYBEACON_H_
24 
25 #include <ibrdtn/data/SDNV.h>
26 #include <ibrdtn/data/EID.h>
28 #include "net/DiscoveryService.h"
29 #include <string>
30 #include <list>
31 
32 namespace dtn
33 {
34  namespace net
35  {
37  {
38  enum BEACON_FLAGS_V1
39  {
40  BEACON_NO_FLAGS = 0x00,
41  BEACON_SHORT = 0x01
42  };
43 
44  enum BEACON_FLAGS_V2
45  {
46  BEACON_CONTAINS_EID = 0x01,
47  BEACON_SERVICE_BLOCK = 0x02,
48  BEACON_BLOOMFILTER = 0x04,
49  BEACON_CONTAINS_PERIOD = 0x08
50  };
51 
52  public:
53  enum Protocol
54  {
58  };
59 
61 
62  virtual ~DiscoveryBeacon();
63 
64  typedef std::list<DiscoveryService> service_list;
65 
66  void setEID(const dtn::data::EID &eid);
67  const dtn::data::EID& getEID() const;
68 
70  const service_list& getServices() const;
71  void clearServices();
72  void addService(const DiscoveryService &service);
73  const DiscoveryService& getService(const std::string &name) const;
74  DiscoveryService& getService(const std::string &name);
75 
76  std::string toString() const;
77 
78  void setSequencenumber(uint16_t sequence);
79 
80  void setPeriod(const dtn::data::Number& period);
81  const dtn::data::Number& getPeriod() const;
82  bool hasPeriod() const;
83 
84  bool isShort() const;
85 
86  private:
87  friend std::ostream &operator<<(std::ostream &stream, const DiscoveryBeacon &announcement);
88  friend std::istream &operator>>(std::istream &stream, DiscoveryBeacon &announcement);
89 
90  unsigned int _version;
91  unsigned char _flags;
92  dtn::data::EID _canonical_eid;
93  uint16_t _sn;
94  dtn::data::BundleString _bloomfilter;
95  dtn::data::Number _period;
96 
97  service_list _services;
98  };
99  }
100 }
101 
102 #endif /* DISCOVERYBEACON_H_ */
const DiscoveryService & getService(const std::string &name) const
service_list & getServices()
std::list< DiscoveryService > service_list
void setEID(const dtn::data::EID &eid)
friend std::ostream & operator<<(std::ostream &stream, const DiscoveryBeacon &announcement)
const dtn::data::EID & getEID() const
const dtn::data::Number & getPeriod() const
friend std::istream & operator>>(std::istream &stream, DiscoveryBeacon &announcement)
void setPeriod(const dtn::data::Number &period)
std::string toString() const
DiscoveryBeacon(const Protocol version=DISCO_VERSION_00, const dtn::data::EID &eid=dtn::data::EID())
void addService(const DiscoveryService &service)
void setSequencenumber(uint16_t sequence)