2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
42#include "net/un/SocketAddress.h"
44#include "core/socket/State.h"
45#include "net/SocketAddress.hpp"
47#ifndef DOXYGEN_SHOULD_SKIP_THIS
58 : Super
(AF_UNIX
, offsetof(sockaddr_un, sun_path
)) {
66 SocketAddress::
SocketAddress(
const SockAddr& sockAddr, SockLen sockAddrLen)
71 void SocketAddress::
init() {
72 if (
sunPath.length() <
sizeof(sockAddr.sun_path)) {
73 const std::size_t len =
sunPath.length();
74 std::memcpy(sockAddr.sun_path,
sunPath.data(), len);
75 sockAddr.sun_path[len] = 0;
76 sockAddrLen =
static_cast<SockLen>(offsetof(sockaddr_un, sun_path) + len + 1);
78 throw core::socket::SocketAddress::BadSocketAddress(
79 core::socket::STATE_FATAL,
80 "Unix-Domain error sun-path to long: Lenght is = " + std::to_string(sunPath.length()) +
81 ", should be: " + std::to_string(
sizeof(sockAddr.sun_path) - 1),
86 SocketAddress& SocketAddress::
setSunPath(
const std::string& sunPath) {
97 return sockAddr.sun_path[0] !=
'\0' ? sockAddr.sun_path : std::string(
"@").append(sockAddr.sun_path + 1);
SocketAddress(const SockAddr &sockAddr, SockLen sockAddrLen)
SocketAddress(sa_family_t af, SockLen sockAddrLen=sizeof(SockAddr))
SocketAddress & setSunPath(const std::string &sunPath)
SocketAddress(const std::string &sunPath)
std::string toString(bool expanded=true) const override
std::string getSunPath() const
SocketAddress(const SockAddr &sockAddr, SockLen sockAddrLen)