IBR-DTNSuite  0.10
DiscoveryAnnouncement.h
Go to the documentation of this file.
1 /*
2  * DiscoveryAnnouncement.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 DISCOVERYANNOUNCEMENT_H_
23 #define DISCOVERYANNOUNCEMENT_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:
53  {
57  };
58 
60 
61  virtual ~DiscoveryAnnouncement();
62 
63  void setEID(const dtn::data::EID &eid);
64  dtn::data::EID getEID() const;
65 
66  const std::list<DiscoveryService>& getServices() const;
67  void clearServices();
68  void addService(DiscoveryService service);
69  const DiscoveryService& getService(string name) const;
70 
71  string toString() const;
72 
73  void setSequencenumber(uint16_t sequence);
74 
75  bool isShort();
76 
77  private:
78  friend std::ostream &operator<<(std::ostream &stream, const DiscoveryAnnouncement &announcement);
79  friend std::istream &operator>>(std::istream &stream, DiscoveryAnnouncement &announcement);
80 
81  unsigned int _version;
82  unsigned char _flags;
83  dtn::data::EID _canonical_eid;
84  uint16_t _sn;
85  dtn::data::BundleString _bloomfilter;
86 
87  std::list<DiscoveryService> _services;
88  };
89  }
90 }
91 
92 #endif /* DISCOVERYANNOUNCEMENT_H_ */