X-Git-Url: http://git.tdb.fi/?p=libs%2Fnet.git;a=blobdiff_plain;f=source%2Fsockaddr.cpp;h=26c77b643df8b4ae9b8180ddd1c38145f71dcc65;hp=c3ae2db3091d06730b183a6ad51f886808b1fad9;hb=1b2aabf076169e6d2049227188e464e95ac40514;hpb=35009eb3f51a6fd0f9261f892a85d97d81e69886 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"); }