X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fsockaddr.cpp;h=26c77b643df8b4ae9b8180ddd1c38145f71dcc65;hb=a4f75be32827b00d9de9d8a68855fec2f5157a10;hp=c3ae2db3091d06730b183a6ad51f886808b1fad9;hpb=f59eded7c3e162bbdfc6db424c9badc730017698;p=libs%2Fnet.git diff --git a/source/sockaddr.cpp b/source/sockaddr.cpp index c3ae2db..26c77b6 100644 --- a/source/sockaddr.cpp +++ b/source/sockaddr.cpp @@ -1,22 +1,30 @@ /* $Id$ This file is part of libmspnet -Copyright © 2008 Mikkosoft Productions, Mikko Rasa +Copyright © 2008, 2011 Mikkosoft Productions, Mikko Rasa Distributed under the LGPL */ #include #include "inet.h" +#include "inet6.h" namespace Msp { namespace Net { -SockAddr *SockAddr::create(sockaddr &sa) +unsigned SockAddr::fill_sockaddr(sockaddr_storage &sa) const { - switch(sa.sa_family) + return fill_sockaddr(reinterpret_cast(sa)); +} + +SockAddr *SockAddr::create(const sockaddr_storage &sa) +{ + switch(sa.ss_family) { case AF_INET: - return new InetAddr(reinterpret_cast(sa)); + return new InetAddr(reinterpret_cast(sa)); + case AF_INET6: + return new Inet6Addr(reinterpret_cast(sa)); default: throw InvalidParameterValue("Unknown address family"); }