From de739bbef33567bc4555780e56e6f31ee14c6b41 Mon Sep 17 00:00:00 2001 From: Philippe Houdoin Date: Wed, 24 Nov 2010 17:55:46 +0000 Subject: [PATCH] Factorized a bit more, and update fStatus in some place it was missing but make sense. Please review. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39612 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/network/libnetapi/NetworkAddress.cpp | 29 +++++++------------ 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/kits/network/libnetapi/NetworkAddress.cpp b/src/kits/network/libnetapi/NetworkAddress.cpp index 8f8db68e9c..f495b3938a 100644 --- a/src/kits/network/libnetapi/NetworkAddress.cpp +++ b/src/kits/network/libnetapi/NetworkAddress.cpp @@ -274,6 +274,7 @@ BNetworkAddress::SetTo(in_addr_t inetAddress, uint16 port) fAddress.ss_len = sizeof(sockaddr_in); SetAddress(inetAddress); SetPort(port); + fStatus = B_OK; } @@ -306,12 +307,8 @@ BNetworkAddress::SetToBroadcast(int family, uint16 port) if (family != AF_INET) return fStatus = B_NOT_SUPPORTED; - memset(&fAddress, 0, sizeof(sockaddr_storage)); - fAddress.ss_family = family; - fAddress.ss_len = sizeof(sockaddr_in); - SetAddress(INADDR_BROADCAST); - SetPort(port); - return fStatus = B_OK; + SetTo(INADDR_BROADCAST, port); + return B_OK; } @@ -319,7 +316,7 @@ status_t BNetworkAddress::SetToLocal() { // TODO: choose a local address from the network interfaces - return B_NOT_SUPPORTED; + return fStatus = B_NOT_SUPPORTED; } @@ -375,10 +372,10 @@ BNetworkAddress::SetToMask(int family, uint32 prefixLength) } default: - return B_NOT_SUPPORTED; + return fStatus = B_NOT_SUPPORTED; } - return B_OK; + return fStatus = B_OK; } @@ -387,24 +384,18 @@ BNetworkAddress::SetToWildcard(int family, uint16 port) { switch (family) { case AF_INET: - memset(&fAddress, 0, sizeof(sockaddr_storage)); - fAddress.ss_len = sizeof(sockaddr_in); - SetAddress(INADDR_ANY); + SetTo(INADDR_ANY, port); break; case AF_INET6: - memset(&fAddress, 0, sizeof(sockaddr_storage)); - fAddress.ss_len = sizeof(sockaddr_in6); - SetAddress(in6addr_any); + SetTo(in6addr_any, port); break; default: - return B_NOT_SUPPORTED; + return fStatus = B_NOT_SUPPORTED; } - fAddress.ss_family = family; - SetPort(port); - return fStatus = B_OK; + return B_OK; }