Removed dead code

This commit is contained in:
Gio 2015-12-11 11:44:26 +01:00
parent 1b2fa3600a
commit ca1a9707ef
5 changed files with 0 additions and 195 deletions

View File

@ -263,34 +263,6 @@ int inet_aton(const char *name, struct in_addr *addr)
return (((*addr).s_addr = inet_addr(name)) != INADDR_NONE);
}
// This returns in Net Byte Order.
// NB: Linux man page claims it is in Host Byte order, but
// this is blatantly wrong!..... (for Debian anyway)
// Making this consistent with the Actual behavior (rather than documented).
in_addr_t inet_netof(struct in_addr addr)
{
return pqi_inet_netof(addr);
}
// This returns in Host Byte Order. (as the man page says)
// Again, to be consistent with Linux.
in_addr_t inet_network(const char *inet_name)
{
struct in_addr addr;
if (inet_aton(inet_name, &addr))
{
#ifdef NET_DEBUG
// std::cerr << "inet_network(" << inet_name << ") : ";
// std::cerr << rs_inet_ntoa(addr) << std::endl;
#endif
return ntohl(inet_netof(addr));
}
return 0xffffffff;
//return -1;
}
#endif
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/

View File

@ -49,9 +49,6 @@
#include "util/rsnet.h" /* more generic networking header */
// Some Network functions that are missing from windows.
in_addr_t inet_netof(struct in_addr addr);
in_addr_t inet_network(const char *inet_name);
int inet_aton(const char *name, struct in_addr *addr);
extern int errno; /* Define extern errno, to duplicate unix behaviour */

View File

@ -59,7 +59,6 @@ net_test
Tested Code: pqinetwork.cc, rsnet.cc
Description:
(1) Tests ntohll / htonll
(2) Demonstrates inet_netof / inet_network strange behaviour.
(3) Tests socket binding.
------------------------------------------------------------
@ -71,7 +70,6 @@ Description:
(2) isPrivateNet()
(3) isLoopbackNet()
(5) isValidNet()
(7) pqi_inet_netof()
------------------------------------------------------------
pqiarchive_test

View File

@ -48,7 +48,6 @@ int main(int argc, char **argv)
std::cerr << "libretroshare:pqi " << argv[0] << std::endl;
test_byte_manipulation();
test_local_address_manipulation();
FINALREPORT("libretroshare Net Basics Tests");
return TESTRESULT();
@ -87,128 +86,6 @@ const char * localnet2_addrstr = "10.0.0.1";
const char * localnet3_addrstr = "10.5.63.78";
const char * localnet4_addrstr = "192.168.74.91";
/* test 2: address manipulation */
bool test_local_address_manipulation()
{
struct sockaddr_in loopback_addr;
struct sockaddr_in localnet1_addr;
struct sockaddr_in localnet2_addr;
struct sockaddr_in localnet3_addr;
struct sockaddr_in localnet4_addr;
std::cerr << "test_local_address_manipulation() NB: This function demonstrates ";
std::cerr << "the strange behaviour of inet_netof() and inet_network()";
std::cerr << std::endl;
std::cerr << "FAILures are not counted in the test!";
std::cerr << std::endl;
/* setup some addresses */
inet_aton(loopback_addrstr, &(loopback_addr.sin_addr));
inet_aton(localnet1_addrstr, &(localnet1_addr.sin_addr));
inet_aton(localnet2_addrstr, &(localnet2_addr.sin_addr));
inet_aton(localnet3_addrstr, &(localnet3_addr.sin_addr));
inet_aton(localnet4_addrstr, &(localnet4_addr.sin_addr));
std::cerr << "Loopback Addr " << rs_inet_ntoa(loopback_addr.sin_addr);
std::cerr << std::endl;
std::cerr << "Localnet1 Addr " << rs_inet_ntoa(localnet1_addr.sin_addr);
std::cerr << std::endl;
std::cerr << "Localnet2 Addr " << rs_inet_ntoa(localnet2_addr.sin_addr);
std::cerr << std::endl;
std::cerr << "Localnet3 Addr " << rs_inet_ntoa(localnet3_addr.sin_addr);
std::cerr << std::endl;
std::cerr << "Localnet4 Addr " << rs_inet_ntoa(localnet4_addr.sin_addr);
std::cerr << std::endl;
std::cerr << std::endl;
std::cerr << "Test 1a - networks";
std::cerr << std::endl;
struct sockaddr_in addr_ans, addr1, addr2;
std::string addr_ans_str;
addr_ans_str = "127.0.0.0";
inet_aton(addr_ans_str.c_str(), &(addr_ans.sin_addr));
addr1.sin_addr.s_addr = htonl(inet_netof(loopback_addr.sin_addr));
addr2.sin_addr.s_addr = htonl(inet_network(loopback_addrstr));
std::cerr << "Loopback Net(expected): " << addr_ans_str;
std::cerr << " -> " << rs_inet_ntoa(addr_ans.sin_addr);
std::cerr << " Net(1):" << rs_inet_ntoa(addr1.sin_addr);
std::cerr << " Net(2):" << rs_inet_ntoa(addr2.sin_addr);
std::cerr << std::endl;
//CHECK( 0 == strcmp(addr_ans_str.c_str(), rs_inet_ntoa(addr1.sin_addr)));
//CHECK( 0 == strcmp(addr_ans_str.c_str(), rs_inet_ntoa(addr2.sin_addr)));
addr_ans_str = "192.168.0.0";
inet_aton(addr_ans_str.c_str(), &(addr_ans.sin_addr));
addr1.sin_addr.s_addr = htonl(inet_netof(localnet1_addr.sin_addr));
addr2.sin_addr.s_addr = htonl(inet_network(localnet1_addrstr));
std::cerr << "Localnet1 Net(expected): " << addr_ans_str;
std::cerr << " -> " << rs_inet_ntoa(addr_ans.sin_addr);
std::cerr << " Net(1):" << rs_inet_ntoa(addr1.sin_addr);
std::cerr << " Net(2):" << rs_inet_ntoa(addr2.sin_addr);
std::cerr << std::endl;
//CHECK( 0 == strcmp(addr_ans_str.c_str(), rs_inet_ntoa(addr1.sin_addr)));
//CHECK( 0 == strcmp(addr_ans_str.c_str(), rs_inet_ntoa(addr2.sin_addr)));
addr_ans_str = "10.0.0.0";
inet_aton(addr_ans_str.c_str(), &(addr_ans.sin_addr));
addr1.sin_addr.s_addr = htonl(inet_netof(localnet2_addr.sin_addr));
addr2.sin_addr.s_addr = htonl(inet_network(localnet2_addrstr));
std::cerr << "Localnet2 Net(expected): " << addr_ans_str;
std::cerr << " -> " << rs_inet_ntoa(addr_ans.sin_addr);
std::cerr << " Net(1):" << rs_inet_ntoa(addr1.sin_addr);
std::cerr << " Net(2):" << rs_inet_ntoa(addr2.sin_addr);
std::cerr << std::endl;
//CHECK( 0 == strcmp(addr_ans_str.c_str(), rs_inet_ntoa(addr1.sin_addr)));
//CHECK( 0 == strcmp(addr_ans_str.c_str(), rs_inet_ntoa(addr2.sin_addr)));
addr_ans_str = "10.0.0.0";
inet_aton(addr_ans_str.c_str(), &(addr_ans.sin_addr));
addr1.sin_addr.s_addr = htonl(inet_netof(localnet3_addr.sin_addr));
addr2.sin_addr.s_addr = htonl(inet_network(localnet3_addrstr));
std::cerr << "Localnet3 Net(expected): " << addr_ans_str;
std::cerr << " -> " << rs_inet_ntoa(addr_ans.sin_addr);
std::cerr << " Net(1):" << rs_inet_ntoa(addr1.sin_addr);
std::cerr << " Net(2):" << rs_inet_ntoa(addr2.sin_addr);
std::cerr << std::endl;
//CHECK( 0 == strcmp(addr_ans_str.c_str(), rs_inet_ntoa(addr1.sin_addr)));
//CHECK( 0 == strcmp(addr_ans_str.c_str(), rs_inet_ntoa(addr2.sin_addr)));
addr_ans_str = "192.168.0.0";
inet_aton(addr_ans_str.c_str(), &(addr_ans.sin_addr));
addr1.sin_addr.s_addr = htonl(inet_netof(localnet4_addr.sin_addr));
addr2.sin_addr.s_addr = htonl(inet_network(localnet4_addrstr));
std::cerr << "Localnet4 Net(expected): " << addr_ans_str;
std::cerr << " -> " << rs_inet_ntoa(addr_ans.sin_addr);
std::cerr << " Net(1):" << rs_inet_ntoa(addr1.sin_addr);
std::cerr << " Net(2):" << rs_inet_ntoa(addr2.sin_addr);
std::cerr << std::endl;
//CHECK( 0 == strcmp(addr_ans_str.c_str(), rs_inet_ntoa(addr1.sin_addr)));
//CHECK( 0 == strcmp(addr_ans_str.c_str(), rs_inet_ntoa(addr2.sin_addr)));
REPORT("Test Local Address Manipulation");
return true;
}
bool test_bind_addr(struct sockaddr_in addr);
bool test_bind_addr(struct sockaddr_in addr)

View File

@ -54,7 +54,6 @@ int test_isExternalNet();
int test_isPrivateNet();
int test_isLoopbackNet();
int test_isValidNet();
int test_pqi_inet_netof();
INITTEST();
@ -66,7 +65,6 @@ int main(int argc, char **argv)
test_isPrivateNet();
test_isLoopbackNet();
test_isValidNet();
test_pqi_inet_netof();
FINALREPORT("net_test1");
@ -170,40 +168,3 @@ int test_isValidNet()
return 1;
}
int test_pqi_inet_netof()
{
struct in_addr localnet1_addr;
struct in_addr localnet2_addr;
struct in_addr localnet3_addr;
struct in_addr localnet4_addr;
struct in_addr localnet5_addr;
struct in_addr localnet6_addr;
struct in_addr localnet7_addr;
struct in_addr localnet8_addr;
struct in_addr external_addr;
inet_aton(localnet1_addrstr, &localnet1_addr);
inet_aton(localnet2_addrstr, &localnet2_addr);
inet_aton(localnet3_addrstr, &localnet3_addr);
inet_aton(localnet4_addrstr, &localnet4_addr);
inet_aton(localnet5_addrstr, &localnet5_addr);
inet_aton(localnet6_addrstr, &localnet6_addr);
inet_aton(localnet7_addrstr, &localnet7_addr);
inet_aton(localnet8_addrstr, &localnet8_addr);
inet_aton(external_addrstr, &external_addr);
CHECK(pqi_inet_netof(localnet1_addr)==htonl(10<<24));
CHECK(pqi_inet_netof(localnet2_addr)==htonl(169<<24 | 254<<16));
CHECK(pqi_inet_netof(localnet3_addr)==htonl(172<<24 | 16<<16));
CHECK(pqi_inet_netof(localnet4_addr)==htonl(192<<24 | 168<<16 | 1<<8));
CHECK(pqi_inet_netof(localnet5_addr)==htonl(10<<24));
CHECK(pqi_inet_netof(localnet6_addr)==htonl(169<<24 | 254<<16));
CHECK(pqi_inet_netof(localnet7_addr)==htonl(172<<24 | 20<<16));
CHECK(pqi_inet_netof(localnet8_addr)==htonl(192<<24 | 168<<16 | 1<<8));
CHECK(pqi_inet_netof(external_addr)==htonl(74<<24));
REPORT("pqi_inet_netof()");
return 1;
}