5#include <cosmos/error/RuntimeError.hxx>
6#include <cosmos/net/IPAddress.hxx>
7#include <cosmos/net/ip_aux.hxx>
8#include <cosmos/net/traits.hxx>
12static_assert(
sizeof(IP4SocketError) ==
sizeof(
struct sock_extended_err),
"size mismatch between SocketError and struct sock_extended_err!");
14template <SocketFamily FAMILY>
15void SocketErrorMessage<FAMILY>::deserialize(
const ReceiveMessageHeader::ControlMessage &msg) {
16 this->checkMsg(msg, FamilyTraits<FAMILY>::CtrlMsg::RECVERR);
19 auto data = msg.data();
26 if (msg.dataLength() <
sizeof(SocketError)) {
27 cosmos_throw (RuntimeError(
"IP_RECVERR ancillary message too small"));
30 m_data.resize(msg.dataLength());
32 std::memcpy(m_data.data(), data, msg.dataLength());
35template class SocketErrorMessage<SocketFamily::INET>;
36template class SocketErrorMessage<SocketFamily::INET6>;