IBR-DTNSuite  0.12
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  };
50 
51  public:
52  enum Protocol
53  {
57  };
58 
60 
61  virtual ~DiscoveryBeacon();
62 
63  typedef std::list<DiscoveryService> service_list;
64 
65  void setEID(const dtn::data::EID &eid);
66  const dtn::data::EID& getEID() const;
67 
69  const service_list& getServices() const;
70  void clearServices();
71  void addService(const DiscoveryService &service);
72  const DiscoveryService& getService(const std::string &name) const;
73  DiscoveryService& getService(const std::string &name);
74 
75  std::string toString() const;
76 
77  void setSequencenumber(uint16_t sequence);
78 
79  bool isShort() const;
80 
81  private:
82  friend std::ostream &operator<<(std::ostream &stream, const DiscoveryBeacon &announcement);
83  friend std::istream &operator>>(std::istream &stream, DiscoveryBeacon &announcement);
84 
85  unsigned int _version;
86  unsigned char _flags;
87  dtn::data::EID _canonical_eid;
88  uint16_t _sn;
89  dtn::data::BundleString _bloomfilter;
90 
91  service_list _services;
92  };
93  }
94 }
95 
96 #endif /* DISCOVERYBEACON_H_ */