Woman, Life, Freedom


Adaptive AUTOSAR
ARA public interface header documentation
ipv4_endpoint_option.h
1#ifndef IPV4_ENDPOINT_OPTION_H
2#define IPV4_ENDPOINT_OPTION_H
3
4#include <stdexcept>
5#include <memory>
6#include "./option.h"
7#include "../helper/ipv4_address.h"
8
9namespace ara
10{
11 namespace com
12 {
13 namespace option
14 {
17 {
18 private:
19 static const Layer4ProtocolType cDefaultSdProtocol = Layer4ProtocolType::Udp;
20 static const uint16_t cDefaultSdPort = 30490;
21
22 helper::Ipv4Address mIpAddress;
23 Layer4ProtocolType mL4Proto;
24 uint16_t mPort;
25
26 constexpr Ipv4EndpointOption(
27 OptionType type,
28 bool discardable,
29 helper::Ipv4Address ipAddress,
30 Layer4ProtocolType protocol,
31 uint16_t port) noexcept : Option(type, discardable),
32 mIpAddress{ipAddress},
33 mL4Proto{protocol},
34 mPort{port}
35 {
36 }
37
38 public:
39 Ipv4EndpointOption() = delete;
40 virtual uint16_t Length() const noexcept override;
41
44 helper::Ipv4Address IpAddress() const noexcept;
45
48 Layer4ProtocolType L4Proto() const noexcept;
49
52 uint16_t Port() const noexcept;
53
54 virtual std::vector<uint8_t> Payload() const override;
55
62 static std::unique_ptr<Ipv4EndpointOption> CreateUnitcastEndpoint(
63 bool discardable,
64 helper::Ipv4Address ipAddress,
65 Layer4ProtocolType protocol,
66 uint16_t port) noexcept;
67
73 static std::unique_ptr<Ipv4EndpointOption> CreateMulticastEndpoint(
74 bool discardable,
75 helper::Ipv4Address ipAddress,
76 uint16_t port);
77
84 static std::unique_ptr<Ipv4EndpointOption> CreateSdEndpoint(
85 bool discardable,
86 helper::Ipv4Address ipAddress,
87 Layer4ProtocolType protocol = cDefaultSdProtocol,
88 uint16_t port = cDefaultSdPort) noexcept;
89
97 static std::unique_ptr<Ipv4EndpointOption> Deserialize(
98 const std::vector<uint8_t> &payload,
99 std::size_t &offset,
100 OptionType type,
101 bool discardable);
102 };
103 }
104 }
105}
106
107#endif
IPv4 endpoint option for both generic and service discovery purposes.
Definition: ipv4_endpoint_option.h:17
virtual std::vector< uint8_t > Payload() const override
Get option payload.
Definition: ipv4_endpoint_option.cpp:30
helper::Ipv4Address IpAddress() const noexcept
Get IP address.
Definition: ipv4_endpoint_option.cpp:15
uint16_t Port() const noexcept
Get port.
Definition: ipv4_endpoint_option.cpp:25
Layer4ProtocolType L4Proto() const noexcept
Get protocol.
Definition: ipv4_endpoint_option.cpp:20
static std::unique_ptr< Ipv4EndpointOption > CreateSdEndpoint(bool discardable, helper::Ipv4Address ipAddress, Layer4ProtocolType protocol=cDefaultSdProtocol, uint16_t port=cDefaultSdPort) noexcept
Service discovery factroy.
Definition: ipv4_endpoint_option.cpp:90
static std::unique_ptr< Ipv4EndpointOption > Deserialize(const std::vector< uint8_t > &payload, std::size_t &offset, OptionType type, bool discardable)
Deserialize an option payload.
Definition: ipv4_endpoint_option.cpp:106
static std::unique_ptr< Ipv4EndpointOption > CreateUnitcastEndpoint(bool discardable, helper::Ipv4Address ipAddress, Layer4ProtocolType protocol, uint16_t port) noexcept
Unitcast endpoint factory.
Definition: ipv4_endpoint_option.cpp:47
virtual uint16_t Length() const noexcept override
Get option length.
Definition: ipv4_endpoint_option.cpp:9
static std::unique_ptr< Ipv4EndpointOption > CreateMulticastEndpoint(bool discardable, helper::Ipv4Address ipAddress, uint16_t port)
Multicast endpoint factory.
Definition: ipv4_endpoint_option.cpp:64
Communication message entry abstract option.
Definition: option.h:37
constexpr Option(OptionType type, bool discardable) noexcept
Constructor.
Definition: option.h:46
OptionType
Entry option type.
Definition: option.h:17
Layer4ProtocolType
OSI layer-4 protocol type.
Definition: option.h:30
@ Udp
User datagram protocol.
IPv4 address wrapper helper.
Definition: ipv4_address.h:16