Modifications to fix some networking/endian issues on PPC OSX.

* added sockaddr_clear() function to zero network addresses before use.
* used this function in p3connmgr.
* added htonll() and ntohll() functions to rsnet.h with compile-time ENDIAN checking
* use htonll() and ntohll() in serialiser.
* added net_test.cc to check network/endian/inet_addr issues.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@328 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2008-02-03 12:07:59 +00:00
parent cea158b77d
commit 31136da7cc
10 changed files with 374 additions and 40 deletions

View file

@ -46,6 +46,11 @@ int errno;
#endif
void sockaddr_clear(struct sockaddr_in *addr)
{
memset(addr, 0, sizeof(struct sockaddr_in));
addr->sin_family = AF_INET;
}
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
@ -142,8 +147,15 @@ std::list<std::string> getLocalInterfaces()
exit(1);
}
if (!ifptr)
{
pqioutput(PQL_ALERT, pqinetzone,
"getLocalInterfaces(): ERROR if_nameindex == NULL");
}
// loop through the interfaces.
for(; *(char *)ifptr != 0; ifptr++)
//for(; *(char *)ifptr != 0; ifptr++)
for(; ifptr->if_index != 0; ifptr++)
{
//copy in the interface name to look up address of
strncpy(ifreq.ifr_name, ifptr->if_name, IF_NAMESIZE);
@ -860,3 +872,4 @@ int WinToUnixError(int error)
#endif
/******************* WINDOWS SPECIFIC PART ******************/