/** \file
\brief BSDSocketAddress public header */
-#ifndef HH_BSDSocketAddress_
-#define HH_BSDSocketAddress_ 1
+#ifndef HH_SENF_Socket_Protocols_BSDSocketAddress_
+#define HH_SENF_Socket_Protocols_BSDSocketAddress_ 1
// Custom includes
+#include <boost/type_traits/alignment_of.hpp>
+#include <boost/type_traits/type_with_alignment.hpp>
#include "../../Utils/safe_bool.hh"
#include <sys/socket.h>
#include <iostream>
void socklen(socklen_t len);
private:
-
- socklen_t len_;
+
+ // The following incantation is needed to fix the alignment of the sockaddr data members
+ // which will be added by the derived classes later: The alignment must be forced
+ // to coincide with the struct sockaddr_storage alignment (which must have the largest
+ // alignment of all sockaddr types).
+ union {
+ socklen_t len_;
+ boost::type_with_alignment<boost::alignment_of<struct sockaddr_storage>::value> a_;
+ char _b[boost::alignment_of<struct sockaddr_storage>::value];
+ };
};
/** \brief Safe socket address down-cast