roar
Loading...
Searching...
No Matches
ipv4.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <boost/fusion/include/adapt_struct.hpp>
4
5#include <cstdint>
6#include <string>
7#include <vector>
8
9namespace Roar
10{
11 struct Ipv4
12 {
13 uint8_t octet0;
14 uint8_t octet1;
15 uint8_t octet2;
16 uint8_t octet3;
17
18 std::vector<uint16_t> toIpv6Segments() const
19 {
20 std::vector<uint16_t> segments(2);
21 segments[0] = static_cast<uint16_t>(static_cast<uint16_t>(octet0) << 8u) |
22 static_cast<uint16_t>(static_cast<uint16_t>(octet1));
23 segments[1] = static_cast<uint16_t>(static_cast<uint16_t>(octet2) << 8u) |
24 static_cast<uint16_t>(static_cast<uint16_t>(octet3));
25 return segments;
26 }
27
28 std::string toString() const;
29 };
30} // namespace Roar
31
32BOOST_FUSION_ADAPT_STRUCT(Roar::Ipv4, octet0, octet1, octet2, octet3)
Definition authorization.hpp:10
Definition ipv4.hpp:12
std::vector< uint16_t > toIpv6Segments() const
Definition ipv4.hpp:18
uint8_t octet0
Definition ipv4.hpp:13
uint8_t octet2
Definition ipv4.hpp:15
uint8_t octet3
Definition ipv4.hpp:16
std::string toString() const
Definition ipv4.cpp:7
uint8_t octet1
Definition ipv4.hpp:14