+#include <stdexcept>
+#include "inet.h"
+#include "inet6.h"
+#include "sockaddr_private.h"
+
+using namespace std;
+
+namespace Msp {
+namespace Net {
+
+SockAddr *SockAddr::new_from_sys(const SysAddr &sa)
+{
+ switch(sa.addr.ss_family)
+ {
+ case AF_INET:
+ return new InetAddr(sa);
+ case AF_INET6:
+ return new Inet6Addr(sa);
+ default:
+ throw invalid_argument("SockAddr::create");
+ }
+}
+
+SockAddr::SysAddr::SysAddr():
+ size(sizeof(sockaddr_storage))
+{
+ addr.ss_family = AF_UNSPEC;
+}
+
+} // namespace Net
+} // namespace Msp