X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Fnet%2Fsockaddr.cpp;fp=source%2Fnet%2Fsockaddr.cpp;h=9b41f81b948492dc077920dbe83ea06a80ea8a67;hb=50e9f9ea7f7385a2c5931fca2b8fb1103078e67c;hp=0000000000000000000000000000000000000000;hpb=21c596567e3b6fd794ed6af73d304ce2bc70e58f;p=libs%2Fnet.git diff --git a/source/net/sockaddr.cpp b/source/net/sockaddr.cpp new file mode 100644 index 0000000..9b41f81 --- /dev/null +++ b/source/net/sockaddr.cpp @@ -0,0 +1,31 @@ +#include +#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