]> git.tdb.fi Git - libs/net.git/blobdiff - source/sockaddr.cpp
Style update: reorder class members
[libs/net.git] / source / sockaddr.cpp
index c3ae2db3091d06730b183a6ad51f886808b1fad9..08babb12c5f881c84a59471c06b178e4e2c173a1 100644 (file)
@@ -1,26 +1,27 @@
-/* $Id$
-
-This file is part of libmspnet
-Copyright © 2008  Mikkosoft Productions, Mikko Rasa
-Distributed under the LGPL
-*/
-
 #include <msp/core/except.h>
 #include "inet.h"
+#include "inet6.h"
 
 namespace Msp {
 namespace Net {
 
-SockAddr *SockAddr::create(sockaddr &sa)
+SockAddr *SockAddr::create(const sockaddr_storage &sa)
 {
-       switch(sa.sa_family)
+       switch(sa.ss_family)
        {
        case AF_INET:
-               return new InetAddr(reinterpret_cast<sockaddr_in &>(sa));
+               return new InetAddr(reinterpret_cast<const sockaddr_in &>(sa));
+       case AF_INET6:
+               return new Inet6Addr(reinterpret_cast<const sockaddr_in6 &>(sa));
        default:
                throw InvalidParameterValue("Unknown address family");
        }
 }
 
+unsigned SockAddr::fill_sockaddr(sockaddr_storage &sa) const
+{
+       return fill_sockaddr(reinterpret_cast<sockaddr &>(sa));
+}
+
 } // namespace Net
 } // namespace Msp