Skip to content

Commit 06b46c2

Browse files
authored
fixes on unix systems (#9)
1 parent ae10f1c commit 06b46c2

5 files changed

Lines changed: 12 additions & 12 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.30)
1+
cmake_minimum_required(VERSION 3.28)
22
project(netkit LANGUAGES C CXX)
33

44
option(NETKIT_ENABLE_OPENSSL "Enable OpenSSL support in netkit" ON)
@@ -226,4 +226,4 @@ if (NETKIT_ENABLE_C_BINDINGS)
226226
endif()
227227
else()
228228
message(STATUS "C bindings disabled")
229-
endif()
229+
endif()

include/netkit-c/sock/sock_types.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ typedef enum netkit_sock_type {
1717
SOCK_NONE,
1818
SOCK_TCP,
1919
SOCK_UDP,
20-
SOCK_UNIX
20+
SOCK_UDS
2121
} netkit_sock_type_t;
2222

2323
typedef enum netkit_sock_status {
@@ -52,4 +52,4 @@ typedef struct netkit_recv_result {
5252
}
5353
#endif
5454
#endif
55-
#endif
55+
#endif

include/netkit/sock/addr_type.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace netkit::sock {
4444
enum class type {
4545
tcp, /* TCP socket */
4646
udp, /* UDP socket */
47-
unix, /* UNIX domain socket */
47+
uds, /* UNIX domain socket */
4848
};
4949
/**
5050
* @brief Socket options.
@@ -89,4 +89,4 @@ namespace netkit::sock {
8989
using T = std::underlying_type_t<opt>;
9090
return static_cast<T>(lhs) & static_cast<T>(rhs);
9191
}
92-
}
92+
}

src/c/sock/sync_sock.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ struct netkit_sync_sock {
1212
switch (type) {
1313
case SOCK_UDP:
1414
return netkit::sock::type::udp;
15-
case SOCK_UNIX:
16-
return netkit::sock::type::unix;
15+
case SOCK_UDS:
16+
return netkit::sock::type::uds;
1717
default:
1818
return netkit::sock::type::tcp;
1919
}
@@ -356,4 +356,4 @@ extern "C" NETKIT_C_API netkit_sock_addr_t* netkit_sync_sock_get_peer(netkit_syn
356356
} catch (...) {
357357
return nullptr;
358358
}
359-
}
359+
}

src/sock/sync_sock.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ netkit::sock::sync_sock::sync_sock(const sock::addr& addr, sock::type t, opt opt
186186
}
187187
}
188188

189-
if (t != type::unix) {
189+
if (t != type::uds) {
190190
this->sockfd = ::socket(addr.is_ipv6() ? AF_INET6 : AF_INET,
191191
t == type::tcp ? SOCK_STREAM : SOCK_DGRAM, 0);
192192
} else {
@@ -230,7 +230,7 @@ netkit::sock::sync_sock::sync_sock(const sock::addr& in_addr, sock::type t, opt
230230
int sock_type = SOCK_STREAM;
231231
int protocol = 0;
232232

233-
if (t != type::unix) {
233+
if (t != type::uds) {
234234
domain = this->addr_.is_ipv6() ? AF_INET6 : AF_INET;
235235
sock_type = (t == type::tcp) ? SOCK_STREAM : SOCK_DGRAM;
236236
protocol = (t == type::tcp) ? IPPROTO_TCP : IPPROTO_UDP;
@@ -365,7 +365,7 @@ std::unique_ptr<netkit::sock::basic_sync_sock> netkit::sock::sync_sock::accept()
365365
throw socket_error("failed to accept connection: " + std::string(strerror(errno)));
366366
}
367367

368-
if (this->type_ == type::unix) {
368+
if (this->type_ == type::uds) {
369369
return std::make_unique<sync_sock>(client_sockfd, sock::addr(reinterpret_cast<const sockaddr_un*>(&client_addr)->sun_path), this->type_);
370370
}
371371

0 commit comments

Comments
 (0)