Vanetza
 
Loading...
Searching...
No Matches
address.hpp
1#ifndef GEONET_ADDRESS_HPP_MB8J1IVQ
2#define GEONET_ADDRESS_HPP_MB8J1IVQ
3
4#include <vanetza/common/bit_number.hpp>
5#include <vanetza/net/mac_address.hpp>
6#include <vanetza/geonet/serialization.hpp>
7#include <vanetza/geonet/station_type.hpp>
8#include <functional>
9#include <type_traits>
10
11namespace vanetza
12{
13namespace geonet
14{
15
17{
18public:
19 static constexpr std::size_t length_bytes = 8;
20
21 Address();
22 explicit Address(const MacAddress&);
23 bool is_manually_configured() const { return m_manually_configured; }
24 void is_manually_configured(bool flag) { m_manually_configured = flag; }
25 StationType station_type() const { return m_station_type; }
26 void station_type(StationType type) { m_station_type = type; }
27 BitNumber<unsigned, 10> country_code() const { return m_country_code; }
28 void country_code(BitNumber<unsigned, 10> country) { m_country_code = country; }
29 const MacAddress& mid() const { return m_mid; }
30 void mid(const MacAddress& mid) { m_mid = mid; }
31
32 bool operator==(const Address& other) const;
33 bool operator!=(const Address& other) const;
34
35private:
36 bool m_manually_configured; // 1 bit
37 StationType m_station_type; // 5 bit
38 BitNumber<unsigned, 10> m_country_code; // 10 bit (deprecated since 1.3.1)
39 MacAddress m_mid; // 48 bit
40};
41
42void serialize(const Address&, OutputArchive&);
43void deserialize(Address&, InputArchive&);
44
45} // namespace geonet
46} // namespace vanetza
47
48
49namespace std {
50
51template<>
52struct hash<vanetza::geonet::Address>
53{
54 size_t operator()(const vanetza::geonet::Address& addr) const;
55};
56
57} // namespace std
58
59#endif /* GEONET_ADDRESS_HPP_MB8J1IVQ */
60
STL namespace.