Woman, Life, Freedom


Adaptive AUTOSAR
ARA public interface header documentation
ipv4_address.h
1#ifndef IPV4_ADDRESS_H
2#define IPV4_ADDRESS_H
3
4#include <array>
5#include <vector>
6#include <stdint.h>
7
8namespace ara
9{
10 namespace com
11 {
12 namespace helper
13 {
16 {
18 std::array<uint8_t, 4> Octets;
19
20 Ipv4Address() = delete;
21
28 uint8_t octet0,
29 uint8_t octet1,
30 uint8_t octet2,
31 uint8_t octet3) noexcept;
32
35 Ipv4Address(std::string ipAddress);
36
39 std::string ToString() const;
40
41 ~Ipv4Address() noexcept = default;
42
46 static void Inject(
47 std::vector<uint8_t> &vector,
48 Ipv4Address ipAddress);
49
54 static Ipv4Address Extract(
55 const std::vector<uint8_t> &vector,
56 std::size_t &offset);
57 };
58
63 inline bool operator==(Ipv4Address address1, Ipv4Address address2)
64 {
65 bool _result =
66 (address1.Octets[0] == address2.Octets[0]) &&
67 (address1.Octets[1] == address2.Octets[1]) &&
68 (address1.Octets[2] == address2.Octets[2]) &&
69 (address1.Octets[3] == address2.Octets[3]);
70
71 return _result;
72 }
73
78 inline bool operator!=(Ipv4Address address1, Ipv4Address address2)
79 {
80 bool _result = !(address1 == address2);
81
82 return _result;
83 }
84 }
85 }
86}
87
88#endif
bool operator!=(Ipv4Address address1, Ipv4Address address2)
Ipv4Address inequality operator override.
Definition: ipv4_address.h:78
IPv4 address wrapper helper.
Definition: ipv4_address.h:16
static Ipv4Address Extract(const std::vector< uint8_t > &vector, std::size_t &offset)
Extract an IPv4 address from a byte vector.
Definition: ipv4_address.cpp:59
std::string ToString() const
Convert the IP address to string.
Definition: ipv4_address.cpp:38
std::array< uint8_t, 4 > Octets
IPv4 address octets.
Definition: ipv4_address.h:18
static void Inject(std::vector< uint8_t > &vector, Ipv4Address ipAddress)
Inject an IP address into a byte vector.
Definition: ipv4_address.cpp:49