Keep the colleague's microbu-esp32c5 tree in this repository
obu-firmware builds against vanetza-idf from microbu-esp32c5/external, but that tree was gitignored, so a clone of this repository could not build the firmware it ships. It is now committed here as ordinary files in its own folder, microbu-esp32c5/: the colleague's commit cf4b99f plus the V2X2MAP bridge's signature verification (--trust) used on the bench. Nothing is fetched from or pushed to the colleague's repository; this repository and its remotes carry everything. The folder's own .gitignore keeps build output, downloaded components and private key material out, as it did there; the committed file set is identical to that repository's tracked files. The ESP32-C5 is still flashed from obu-firmware/, which only takes vanetza-idf from microbu-esp32c5/, so the two stay separate folders. FLASHING.md says how to take a newer version of the colleague's tree (copy it over the folder, rebuild, test, commit).
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
#ifndef MAC_ADDRESS_HPP_FDINBLBS
|
||||
#define MAC_ADDRESS_HPP_FDINBLBS
|
||||
|
||||
#include <vanetza/common/serialization.hpp>
|
||||
#include <boost/operators.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <initializer_list>
|
||||
#include <functional>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
|
||||
namespace vanetza
|
||||
{
|
||||
|
||||
class MacAddress : public boost::totally_ordered<MacAddress>
|
||||
{
|
||||
public:
|
||||
static constexpr std::size_t length_bytes = 6;
|
||||
|
||||
MacAddress();
|
||||
MacAddress(std::initializer_list<uint8_t> args);
|
||||
MacAddress(const MacAddress&) = default;
|
||||
MacAddress& operator=(const MacAddress&) = default;
|
||||
MacAddress(MacAddress&&) = default;
|
||||
MacAddress& operator=(MacAddress&&) = default;
|
||||
|
||||
std::array<uint8_t, length_bytes> octets;
|
||||
};
|
||||
|
||||
extern const MacAddress cBroadcastMacAddress;
|
||||
bool operator==(const MacAddress& lhs, const MacAddress& rhs);
|
||||
bool operator<(const MacAddress& lhs, const MacAddress& rhs);
|
||||
std::ostream& operator<<(std::ostream& os, const MacAddress&);
|
||||
|
||||
/**
|
||||
* Try to parse MAC address from string
|
||||
* \param str source string with "XX:XX:XX:XX:XX:XX" format
|
||||
* \param addr pass parsed address by reference
|
||||
* \return true if successfully parsed
|
||||
*/
|
||||
bool parse_mac_address(const std::string& str, MacAddress& addr);
|
||||
|
||||
/**
|
||||
* Try to parse MAC address from string
|
||||
* \param str source string with "XX:XX:XX:XX:XX:XX" format
|
||||
* \return parsed address if successful
|
||||
*/
|
||||
boost::optional<MacAddress> parse_mac_address(const std::string& str);
|
||||
|
||||
/**
|
||||
* Derive a MAC address from an arbitrary integral value.
|
||||
* \param value used to derive MAC address, it's size does not matter
|
||||
* \return New MAC address
|
||||
*/
|
||||
template<typename T>
|
||||
MacAddress create_mac_address(T value)
|
||||
{
|
||||
MacAddress mac;
|
||||
const std::size_t octets = std::min(mac.octets.size(), sizeof(T));
|
||||
for (std::size_t i = 0; i < octets; ++i) {
|
||||
mac.octets[i] = value >> (8 * (octets - i - 1)) & 0xff;
|
||||
}
|
||||
return mac;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize MAC address
|
||||
* \param out output sink
|
||||
* \param addr MAC address
|
||||
*/
|
||||
void serialize(OutputArchive& out, const MacAddress& addr);
|
||||
|
||||
/**
|
||||
* Deserialize MAC address
|
||||
* \param in input source
|
||||
* \param addr deserialize into this object
|
||||
*/
|
||||
void deserialize(InputArchive& in, MacAddress& addr);
|
||||
|
||||
} // namespace vanetza
|
||||
|
||||
// specialization
|
||||
namespace std {
|
||||
|
||||
template<>
|
||||
struct hash<vanetza::MacAddress>
|
||||
{
|
||||
size_t operator()(const vanetza::MacAddress& addr) const
|
||||
{
|
||||
size_t tmp = 0;
|
||||
for (auto octet : addr.octets) {
|
||||
tmp ^= hash<decltype(octet)>()(octet);
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace std
|
||||
|
||||
#endif /* MAC_ADDRESS_HPP_FDINBLBS */
|
||||
|
||||
Reference in New Issue
Block a user