summaryrefslogtreecommitdiff
path: root/indra/llmessage
diff options
context:
space:
mode:
authorRobert Knop <prospero@lindenlab.com>2009-04-09 00:20:15 +0000
committerRobert Knop <prospero@lindenlab.com>2009-04-09 00:20:15 +0000
commitfa121d8ee18978ffc25e9faeffcfa1d7c6e1592e (patch)
tree2fbe5f4a61cef96b932b198480991ea913daeca1 /indra/llmessage
parent2768539bfe2bf8f2d370fcef03ae7f15b55e0579 (diff)
svn merge -r115000:116937 svn+ssh://svn.lindenlab.com/svn/linden/branches/server/server-1.26
Merging from server-1.26 to trunk Only a few conflicts: scripts/farm_distribute : the upload rate in trunk was even more conservative than the one I switched to in 1.26, so kept the trunk version. indra/llcommon/llversionserver.h : did svn revert to keep trunk indra/newsim/lltask.cpp : svn is weird. The merge conflict was one that it's not obvious why it was there. However, Simon and I looked at it, and the solution was obvious : keep the trunk blob where the conflict was flagged. indra/lib/python : conflict was differing versions of the eventlib extern. did svn revert . to keep trunk.
Diffstat (limited to 'indra/llmessage')
-rw-r--r--indra/llmessage/llhost.cpp2
-rw-r--r--indra/llmessage/net.cpp22
-rw-r--r--indra/llmessage/net.h1
3 files changed, 20 insertions, 5 deletions
diff --git a/indra/llmessage/llhost.cpp b/indra/llmessage/llhost.cpp
index 8e9e23393d..238cf3e12b 100644
--- a/indra/llmessage/llhost.cpp
+++ b/indra/llmessage/llhost.cpp
@@ -124,7 +124,7 @@ BOOL LLHost::setHostByName(const std::string& hostname)
he = gethostbyname(local_name.c_str());
if(!he)
{
- U32 ip_address = inet_addr(hostname.c_str());
+ U32 ip_address = ip_string_to_u32(hostname.c_str());
he = gethostbyaddr((char *)&ip_address, sizeof(ip_address), AF_INET);
}
diff --git a/indra/llmessage/net.cpp b/indra/llmessage/net.cpp
index f63faa511a..cc93b2bf8e 100644
--- a/indra/llmessage/net.cpp
+++ b/indra/llmessage/net.cpp
@@ -83,6 +83,7 @@ typedef int socklen_t;
static U32 gsnReceivingIFAddr = INVALID_HOST_IP_ADDRESS; // Address to which datagram was sent
const char* LOOPBACK_ADDRESS_STRING = "127.0.0.1";
+const char* BROADCAST_ADDRESS_STRING = "255.255.255.255";
#if LL_DARWIN
// Mac OS X returns an error when trying to set these to 400000. Smaller values succeed.
@@ -170,7 +171,21 @@ char *u32_to_ip_string(U32 ip, char *ip_string)
// Wrapper for inet_addr()
U32 ip_string_to_u32(const char* ip_string)
{
- return inet_addr(ip_string);
+ // *NOTE: Windows doesn't support inet_aton(), so we are using
+ // inet_addr(). Unfortunately, INADDR_NONE == INADDR_BROADCAST, so
+ // we have to check whether the input is a broadcast address before
+ // deciding that @ip_string is invalid.
+ //
+ // Also, our definition of INVALID_HOST_IP_ADDRESS doesn't allow us to
+ // use wildcard addresses. -Ambroff
+ U32 ip = inet_addr(ip_string);
+ if (ip == INADDR_NONE
+ && strncmp(ip_string, BROADCAST_ADDRESS_STRING, MAXADDRSTR) != 0)
+ {
+ llwarns << "ip_string_to_u32() failed, Error: Invalid IP string '" << ip_string << "'" << llendl;
+ return INVALID_HOST_IP_ADDRESS;
+ }
+ return ip;
}
@@ -293,9 +308,8 @@ S32 start_net(S32& socket_out, int& nPort)
LL_DEBUGS("AppInit") << "startNet - send buffer size : " << snd_size << LL_ENDL;
// Setup a destination address
- char achMCAddr[MAXADDRSTR] = " "; /* Flawfinder: ignore */
stDstAddr.sin_family = AF_INET;
- stDstAddr.sin_addr.s_addr = inet_addr(achMCAddr);
+ stDstAddr.sin_addr.s_addr = INVALID_HOST_IP_ADDRESS;
stDstAddr.sin_port = htons(nPort);
socket_out = hSocket;
@@ -502,7 +516,7 @@ S32 start_net(S32& socket_out, int& nPort)
// Setup a destination address
char achMCAddr[MAXADDRSTR] = "127.0.0.1"; /* Flawfinder: ignore */
stDstAddr.sin_family = AF_INET;
- stDstAddr.sin_addr.s_addr = inet_addr(achMCAddr);
+ stDstAddr.sin_addr.s_addr = ip_string_to_u32(achMCAddr);
stDstAddr.sin_port = htons(nPort);
socket_out = hSocket;
diff --git a/indra/llmessage/net.h b/indra/llmessage/net.h
index 45b07a0ab8..f86e1f0a53 100644
--- a/indra/llmessage/net.h
+++ b/indra/llmessage/net.h
@@ -63,6 +63,7 @@ char* u32_to_ip_string(U32 ip, char *ip_string); // NULL on failure, ip_string
U32 ip_string_to_u32(const char* ip_string); // Wrapper for inet_addr()
extern const char* LOOPBACK_ADDRESS_STRING;
+extern const char* BROADCAST_ADDRESS_STRING;
// useful MTU consts