/*
** Command & Conquer Renegade(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see .
*/
/***********************************************************************************************
*** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
***********************************************************************************************
* *
* Project Name : Bandwidth Tester Tester *
* *
* $Archive:: /Commando/Code/Tests/Bandy/bandy.cpp $*
* *
* $Author:: Steve_t $*
* *
* $Modtime:: 1/05/02 10:22p $*
* *
* $Revision:: 4 $*
* *
* *
*---------------------------------------------------------------------------------------------*
* *
* *
*---------------------------------------------------------------------------------------------*
* *
* Functions: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include
#include
#include
#include
#include
char *ErrorList[13] = {
"BANDTEST_OK",
"BANDTEST_NO_WINSOCK2",
"BANDTEST_NO_RAW_SOCKET_PERMISSION",
"BANDTEST_NO_RAW_SOCKET_CREATE",
"BANDTEST_NO_UDP_SOCKET_BIND",
"BANDTEST_NO_TTL_SET",
"BANDTEST_NO_PING_RESPONSE",
"BANDTEST_NO_FINAL_PING_TIME",
"BANDTEST_NO_EXTERNAL_ROUTER",
"BANDTEST_NO_IP_DETECT",
"BANDTEST_UNKNOWN_ERROR",
"BANDTEST_WRONG_API_VERSION",
"BANDTEST_BAD_PARAM"
};
#define NUM_BANDS 12
unsigned long Bandwidths [NUM_BANDS * 2] = {
12000, 14400,
25000, 28800,
33600, 33600,
53000, 57600,
62000, 67200,
105000, 115200,
125000, 128000,
250000, 256000,
500000, 512000,
999999, 1024000,
1999999, 2048000,
3999999, 4096000
};
char *BandwidthNames [NUM_BANDS] = {
"14400",
"28800",
"33600",
"57600",
"67200",
"115200",
"128k",
"256k",
"512k",
"1M",
"2M",
"4M"
};
BandtestSettingsStruct DefaultSettings = {
0, //AlwaysICMP
0, //TTLScatter
50, //FastPingPackets
12, //SlowPingPackets
25, //def =
0, //Ping profile
};
ULONG Enumerate_Nics(ULONG * addresses, ULONG max_nics)
{
assert(addresses != NULL);
assert(max_nics > 0);
ULONG num_addresses = 0;
//
// Get the local hostname
//
char local_host_name[300];
#ifdef _DEBUG
int gethostname_rc =
#endif //DEBUG
gethostname(local_host_name, sizeof(local_host_name));
assert(gethostname_rc != SOCKET_ERROR);
//
// Resolve hostname for local adapter addresses.
// This does a DNS lookup (name resolution)
//
LPHOSTENT p_hostent = gethostbyname(local_host_name);
if (p_hostent == NULL)
{
}
while (num_addresses < max_nics && p_hostent->h_addr_list[num_addresses] != NULL)
{
IN_ADDR in_addr;
memcpy(&in_addr, p_hostent->h_addr_list[num_addresses], sizeof(in_addr));
addresses[num_addresses] = in_addr.s_addr;
num_addresses++;
}
return num_addresses;
}
char * Addr_As_String(unsigned char *addr)
{
static char _string[128];
sprintf(_string, "%d.%d.%d.%d", (int)(addr[0]), (int)(addr[1]), (int)(addr[2]), (int)(addr[3]));
return(_string);
}
int main(int argc, char **argv)
{
unsigned long my_addresses[8];
int use_addr = -1;
int retries = 3;
int failure_code = BANDTEST_OK;
struct sockaddr_in address;
BandtestSettingsStruct *settings = &DefaultSettings;
WSADATA wsa_data;
if (WSAStartup(MAKEWORD(1,1), &wsa_data) != 0) {
printf("Bandy: WSAStartup failed: error code %d\n", GetLastError());
return(0);
}
int nics = Enumerate_Nics(&my_addresses[0], 8);
struct hostent *host = gethostbyname("www.ea.com");
/*
** Usage.
*/
printf("Bandwidth tester tester\n");
printf("Programmer: Steve Tall\n");
printf("V1.0\n");
printf("Usage: bandy.exe \n");
printf("Options:\n");
printf(" -s - Use specified server (def = www.ea.com)\n");
printf(" -i - Use specified local ip index (def = auto discovery)\n");
printf(" -r - Retry attempts after failure (def = 3)\n");
printf(" -l - Number of packets to send on low ping times (def = 50)\n");
printf(" -h - Number of packets to send on high ping times (def = 12)\n");
printf(" -p