Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.30)
cmake_minimum_required(VERSION 3.28)
project(netkit LANGUAGES C CXX)

option(NETKIT_ENABLE_OPENSSL "Enable OpenSSL support in netkit" ON)
Expand Down Expand Up @@ -226,4 +226,4 @@ if (NETKIT_ENABLE_C_BINDINGS)
endif()
else()
message(STATUS "C bindings disabled")
endif()
endif()
4 changes: 2 additions & 2 deletions include/netkit-c/sock/sock_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ typedef enum netkit_sock_type {
SOCK_NONE,
SOCK_TCP,
SOCK_UDP,
SOCK_UNIX
SOCK_UDS
} netkit_sock_type_t;

typedef enum netkit_sock_status {
Expand Down Expand Up @@ -52,4 +52,4 @@ typedef struct netkit_recv_result {
}
#endif
#endif
#endif
#endif
4 changes: 2 additions & 2 deletions include/netkit/sock/addr_type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace netkit::sock {
enum class type {
tcp, /* TCP socket */
udp, /* UDP socket */
unix, /* UNIX domain socket */
uds, /* UNIX domain socket */
};
/**
* @brief Socket options.
Expand Down Expand Up @@ -89,4 +89,4 @@ namespace netkit::sock {
using T = std::underlying_type_t<opt>;
return static_cast<T>(lhs) & static_cast<T>(rhs);
}
}
}
6 changes: 3 additions & 3 deletions src/c/sock/sync_sock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ struct netkit_sync_sock {
switch (type) {
case SOCK_UDP:
return netkit::sock::type::udp;
case SOCK_UNIX:
return netkit::sock::type::unix;
case SOCK_UDS:
return netkit::sock::type::uds;
default:
return netkit::sock::type::tcp;
}
Expand Down Expand Up @@ -356,4 +356,4 @@ extern "C" NETKIT_C_API netkit_sock_addr_t* netkit_sync_sock_get_peer(netkit_syn
} catch (...) {
return nullptr;
}
}
}
6 changes: 3 additions & 3 deletions src/sock/sync_sock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ netkit::sock::sync_sock::sync_sock(const sock::addr& addr, sock::type t, opt opt
}
}

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

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

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

Expand Down
Loading