1
0
Fork 0

2000 17 Jan updates from "Oliver Delise" <delise@mail.isis.de>

This commit is contained in:
curt 2000-01-18 18:28:51 +00:00
parent e7c6f292a5
commit e61785f83b
16 changed files with 232 additions and 153 deletions

View file

@ -3,7 +3,9 @@ README - containing Network info
Makefile.am -
net_hud.cxx - display found player's info in bottom/left part of HUD
network.cxx - initialization of netcode and vars
network.h - declaration of used vars and functions for libnetwork.a
should be included from other files using libnetwork
fgd.h -
network.h - declaration of used vars and functions for libNetworkOLK.a
should be included from other files using libNetworkOLK
net_send.cxx - communication with deamon
Tools - directory containing network tools and toys
Tools - directory containing the deamon, tools and toys necessairy
for testing the network with and without FGFS.

View file

@ -31,4 +31,4 @@ b) Runtime - setting the "int net_hud_display" variable to 0 disables any
network display (default)
Have Phun
Oliver <delise@rp-plus.de>
Oliver <delise@mail.isis.de>

View file

@ -1,9 +1,11 @@
FILES - This file, describing the other files
HEADERS - Necessairy headers to compile the programs
README - Infos about programs
INSTALL -
README - Detailed explanation about the programs and how to use
Makefile -
fgd.h - Headerfile included by all programs
fgd.c - Flightgear deamon
fgd.c - Flightgear deamon, talkative, strongly recommended for start
fgd_silent.c - Flightgear deamon with no debug output, for advanced users
fgd_com.c - Sends commandos to fgd
fgd_scan.c - Scanner to detect Flightgear deamons via TCP
fgd_mcp.c - Master Control Program for fgd

View file

@ -1,4 +1,4 @@
Please check the presence of the following header files on your system
These includes must be available on any Un*x, Windoze and Mac Donald's
#include <stdio.h>
#include <sys/socket.h>
@ -8,4 +8,11 @@ Please check the presence of the following header files on your system
#include <netdb.h>
#include <sys/time.h>
#include <fcntl.h>
#include <sys/utsname.h>
#include <sys/utsname.h>
Please look also into *all* your systemwide "socket.h" and the header
files (mainly in /usr/include/sys or krnl-src) included by them for
declarations like "MSG_PEEK" etc.
In case of missing MSG_foo declarations please contact me:
Oliver Delise <delise@mail.isis.de>

View file

@ -2,7 +2,7 @@ CPPFLAGS =
CFLAGS =
CC = gcc
RM = rm
PROGS = fgd fgd_scan fgd_com fgd_mcp fgd_verbose
PROGS = fgd fgd_scan fgd_com fgd_mcp fgd_silent
BINDIR = /usr/local/bin
all: $(PROGS)
@ -10,7 +10,7 @@ all: $(PROGS)
fgd: fgd.c
$(CC) -o $@ $^
fgd_verbose: fgd_verbose.c
fgd_silent: fgd_silent.c
$(CC) -o $@ $^
fgd_scan: fgd_scan.c

View file

@ -1,7 +1,7 @@
Welcome to FlightGear Deamon fgd
--------------------------------
Here the first Tools to play with FlightGear Deamon.
This is yet alpha and the sources remain to be tidied up,
This is yet alpha moving to beta and the sources remain to be tidied up,
and to get documented.
@ -242,6 +242,8 @@ History:
Nov 29 1999 -> Implementing scenario functions like virtual
Pilots
Nov 30 1999 -> ???
v0.1-beta : Jan 16 2000 -> Several libc5, glibc-2.0 and glibc-2.1
issues cleaned up
Future Plans:
@ -284,4 +286,4 @@ You can do whatever you want with this software, even enhance it.
Send comments/flames/BEER/whatever to delise@mail.isis.de
Oliver Delise Nov/08/99
Oliver Delise Jan/16/00

View file

@ -2,10 +2,9 @@
/* FGD.C by Oliver Delise */
/* Contact info: */
/* e-mail: delise@mail.isis.de */
/* www: http://www.isis.de/members/~odelise/progs/mmx-emu/ */
/* ftp: http://www.isis.de/members/~odelise/progs/flightgear */
/* www: http://www.isis.de/members/odelise/progs/flightgear */
/* */
/* Version 0.1-alpha */
/* Version 0.1-beta */
/* The author of this program offers no waranty at all */
/* about the correct execution of this software material. */
/* Furthermore, the author can NOT be held responsible for */
@ -28,6 +27,8 @@
/* */
/* History: v0.1pre-alpha: May 25 1999 -> First release */
/* v0.1-alpha : Nov 08 1999 */
/* v0.1-beta : Jan 16 2000 */
/* libc5, glibc-2.0, 2.1 cleanups */
/*************************************************************/
@ -41,7 +42,7 @@
#include <fcntl.h>
#include <sys/utsname.h>
#define printf //
//#define printf //
/* Net-stuff */
fd_set rset, allset;
@ -217,7 +218,7 @@ int fgd_ele_len;
struct sockaddr_in address;
struct sockaddr_in my_address;
int result;
extern char *sys_errlist[];
extern int errno;
int current_port = 0;
u_short base_port = 0;
@ -301,6 +302,7 @@ struct { char *ip, *lon, *lat, *alt;} fg_id;
if (1 == 1) {
if ( bind(sock, (struct sockaddr *)&address, sizeof(address)) == -1) {
printf(" Aiiiieeehh...ADRESS ALSO IN USE...\7hmmm...please check another port\n");
printf(" Just wait a few seconds or do a netstat to see the port status.\n");
exit(-1);
}
listen(sock, 5);
@ -449,10 +451,12 @@ for (;;){
}
else strcpy( fgd_client.adr, "UNKNOWN");
/* writing answer back to client */
sprintf( (char*) buff, "%s %s", "FGD", fgd_client.adr);
buff[3] = strlen(fgd_client.adr);
sprintf( (char*) buff, "%sLH%s ", "FGD", fgd_client.adr);
buff[3] = strlen(fgd_client.adr) + 1;
buff[4] = 0;
buff[ buff[3] + 4] = 0;
printf(" IP : %s\n", fgd_client.adr);
write( my_sock, &buff, buff[3]+4);
write( my_sock, &buff, buff[3]+5);
// close(my_sock);
break;
case 17: printf(" fgd : Get Mat4 DATA from client\n");
@ -500,7 +504,7 @@ for (;;){
sprintf( (char*) buff, "%s %s", "FGD", fgd_client.adr);
buff[3] = 0;
fgd_cnt = 0;
fgd_curpos = 5;
fgd_curpos = 6;
test = head->next;
while (test != tail) {
printf(" IP : %-16s Callsign : %-16s\n", test->ipadr, test->callsign);
@ -533,7 +537,8 @@ for (;;){
if (fgd_cnt == 0) fgd_curpos --;
printf(" ele_len %d curpos %d\n", fgd_ele_len, fgd_curpos);
buff[3] = fgd_curpos;
buff[4] = fgd_cnt;
buff[4] = fgd_curpos / 256;
buff[5] = fgd_cnt;
write( my_sock, &buff, fgd_curpos);
// close(my_sock);
break;
@ -596,10 +601,19 @@ for (;;){
}
else strcpy( fgd_client.adr, "UNKNOWN");
/* writing answer back to client */
sprintf( (char*) buff, "%s %s", "FGD", fgd_client.adr);
buff[3] = strlen(fgd_client.adr);
sprintf( (char*) buff, "FGDLH%s", fgd_client.adr);
buff[3] = strlen(fgd_client.adr) + 1;
buff[4] = buff[buff[3]+5] = 0;
printf(" IP : %s\n", fgd_client.adr);
write( my_sock, &buff, buff[3]+4);
write( my_sock, &buff, buff[3]+5);
// Just leaving the old stuff in, to correct it for FGFS later...
// I'm sick of this f$%&ing libc5/glibc2.0/2.1 quirks
// Oliver...very angry...
// /* writing answer back to client */
// sprintf( (char*) buff, "%s %s", "FGD", fgd_client.adr);
// buff[3] = strlen(fgd_client.adr);
// printf(" IP : %s\n", fgd_client.adr);
// write( my_sock, &buff, buff[3]+4);
// close(my_sock);
break;
case 9: printf(" fgd : Shutdown\n");

View file

@ -6,3 +6,14 @@
#include <sys/time.h>
#include <fcntl.h>
#include <sys/utsname.h>
/* this seems to be missing for glibc-2.0.x */
/* libc5 & glibc-2.1 do have them */
#ifndef MSG_PEEK
int MSG_PEEK = 0x02; /* Peek at incoming messages. */
#define MSG_PEEK MSG_PEEK
#endif
#ifndef MSG_WAITALL
int MSG_WAITALL = 0x100; /* Wait for a full request. */
#define MSG_WAITALL MSG_WAITALL
#endif

View file

@ -1,34 +1,35 @@
/***********************************************************/
/* FGD_COM.C by Oliver Delise */
/* Contact info: */
/* e-mail: delise@mail-isis.de */
/* www: http://www.online-club.de/~olk/progs/mmx-emu/ */
/* ftp: http://www.online-club.de/~olk/progs/flightgear */
/* */
/* Version 0.1-alpha */
/* The author of this program offers no waranty at all */
/* about the correct execution of this software material. */
/* Furthermore, the author can NOT be held responsible for */
/* any physical or moral damage caused by the use of this */
/* software. */
/* */
/* This is a standalone Tool to communicate with any */
/* FlightGear-Deamon. */
/* This is Open Source Software with many parts */
/* shamelessly stolen from others... */
/* */
/* -> This program will use a TCP port listening on a */
/* remote or local host inside the range you give to it.*/
/* I offer no warranty over the accuracy though :) */
/* There are 3 verbose modes: No info, service info, and*/
/* full info. No info is good of you only want the list */
/* of the ports, no more info. The best mode is Full */
/* info, as you get error information,etc. The main */
/* output is STDOUT, and ALL the errors go to STDERR. */
/* */
/* History: v0.1pre-alpha: May 25 1999 -> First release */
/* v0.1-alpha Nov 08 1999 */
/***********************************************************/
/*************************************************************/
/* FGD_COM.C by Oliver Delise */
/* Contact info: */
/* e-mail: delise@mail-isis.de */
/* www: http://www.isis.de/members/odelise/progs/flightgear */
/* */
/* Version 0.1-beta */
/* The author of this program offers no waranty at all */
/* about the correct execution of this software material. */
/* Furthermore, the author can NOT be held responsible for */
/* any physical or moral damage caused by the use of this */
/* software. */
/* */
/* This is a standalone Tool to communicate with any */
/* FlightGear-Deamon. */
/* This is Open Source Software with many parts */
/* shamelessly stolen from others... */
/* */
/* -> This program will use a TCP port listening on a */
/* remote or local host inside the range you give to it. */
/* I offer no warranty over the accuracy though :) */
/* There are 3 verbose modes: No info, service info, and */
/* full info. No info is good of you only want the list */
/* of the ports, no more info. The best mode is Full */
/* info, as you get error information,etc. The main */
/* output is STDOUT, and ALL the errors go to STDERR. */
/* */
/* History: v0.1pre-alpha: May 25 1999 -> First release */
/* v0.1-alpha Nov 08 1999 */
/* v0.1-beta Jan 16 2000 -> libc5/glibc-2.0 */
/* glibc2.1 cleanups */
/*************************************************************/
#include <stdio.h>
#include <sys/socket.h>
@ -47,7 +48,6 @@ int my_sock;
struct sockaddr_in address;
struct sockaddr_in my_address;
int result;
extern char *sys_errlist[];
extern int errno;
int current_port = 0;
u_short base_port = 0;

View file

@ -2,10 +2,9 @@
/* FGD_MCP.C by Oliver Delise */
/* Contact info: */
/* e-mail: delise@mail.isis.de */
/* www: http://www.isis.de/members/~odelise/progs/mmx-emu/ */
/* ftp: http://www.isis.de/members/~odelise/progs/flightgear */
/* www: http://www.isis.de/members/odelise/progs/flightgear */
/* */
/* Version 0.1-alpha */
/* Version 0.1-beta */
/* The author of this program offers no waranty at all */
/* about the correct execution of this software material. */
/* Furthermore, the author can NOT be held responsible for */
@ -28,10 +27,13 @@
/* */
/* History: v0.1pre-alpha: May 25 1999 -> First release */
/* v0.1-alpha Nov 11 1999 */
/* v0.1-beta Jan 16 2000 libc5/glibc-2.0 */
/* glibc-2.1 cleanups */
/*************************************************************/
#include <stdio.h>
#include "fgd.h"
#include <math.h>
//#define printf //
@ -41,7 +43,6 @@ int my_sock;
struct sockaddr_in address;
struct sockaddr_in my_address;
int result;
extern char *sys_errlist[];
extern int errno;
int current_port = 10000;
u_short base_port = 10000;
@ -197,7 +198,7 @@ void fgd_init(void){
address.sin_family = AF_INET;
/* determinating the source/sending host */
if (uname(&myname) == 0) strcpy(src_host , myname.nodename);
printf("MCP: I'm running on HOST : %s ", src_host);
printf("MCP: I'm running on HOST : %s ", src_host);
if (host_info = gethostbyname( src_host)) {
bcopy(host_info->h_addr, (char *)&address.sin_addr,host_info->h_length);
strcpy((char *) fgd_mcp_ip, (char *) inet_ntoa(address.sin_addr));
@ -209,17 +210,19 @@ void fgd_init(void){
bcopy(host_info->h_addr, (char *)&address.sin_addr,host_info->h_length);
strcpy((char *) fgd_ip, (char *) inet_ntoa(address.sin_addr));
if (verbose == 2) {
printf(" resolved\n FGD running on HOST : %s", fgd_host);
printf(" IP : %s\n", fgd_ip);
}
printf(" resolved\n FGD running on HOST : %s", fgd_host);
printf(" IP : %s\n", fgd_ip);
}
} else if ((address.sin_addr.s_addr = inet_addr( fgd_host)) == INADDR_NONE) {
fprintf(stderr," Could not get %s host entry !\n", fgd_host);
printf(" NOT resolved !!!\n");
exit(1);
printf("MCP: Could not get %s host entry !\n", fgd_host);
printf("MCP: Enter '10' for deamon IP or fqdn or alias. (your choice)\n");
// exit(1);
} else if (verbose == 2) printf(" address valid\n");
if ((base_port > end_port) || ((short)base_port < 0)) {
fprintf(stderr,"Bad port range : start=%d end=%d !\n");
printf("MCP: Bad port range : start=%d end=%d !\n");
printf("MCP: Enter '10' for deamon IP/fqdn\n");
exit(1);
} else if (verbose == 2) {
printf(" Port range: %d to %d\n",base_port,end_port);
@ -319,10 +322,10 @@ void fgd_send_com( char *FGD_com, char *FGFS_host) {
/* The Receiving Part, fgd returns errormessages, succes, etc... */
do {
fgd_status = recv( sock, (char *) buffp, 4, MSG_WAITALL);
fgd_status = recv( sock, (char *) buffp, 5, MSG_WAITALL);
printf(" status %d\n", fgd_status);
}
// while ( (fgd_status != 4) && (fgd_status != 0) );
// while ( (fgd_status != 5) && (fgd_status != 0) );
while ( (fgd_status == -1) || (fgd_status == -1) );
if (verbose == 2) {
printf(" Got reply : %x %x %x\n", buffp[0], buffp[1], buffp[2]);
@ -337,15 +340,17 @@ void fgd_send_com( char *FGD_com, char *FGFS_host) {
case 1: printf("FGD: Registering Host %s\n", FGFS_host);
break;
case 2: printf("FGD: Showing registered Hosts at %s\n", fgd_host);
if (buffp[3] != 4) {
/* FIXME: replace with SELECT to avoid broken pipes, known bug (-; */
printf(" %d %d\n", buffp[3], buffp[4]);
if ( (buffp[3] + 256 * buffp[4]) != 5 ) {
/* FIXME: replace with SELECT to avoid broken pipes, known bug (-; */
/* but the transfer is calculated very accurately, null problemo */
do {
fgd_status = recv( sock, fgd_txt, buffp[3]-4, MSG_WAITALL);
fgd_status = recv( sock, fgd_txt, buffp[3]-5, MSG_WAITALL);
// printf(" status %d\n", fgd_status);
}
// while ( (fgd_status != 4) && (fgd_status != 0) );
while ( (fgd_status == -1) || (fgd_status == -1) );
// read( sock, fgd_txt, buffp[3]-4);
// read( sock, fgd_txt, buffp[3]-5);
fgd_curpos = 2;
for (fgd_cnt = 1; fgd_cnt < (fgd_txt[0]+1); fgd_cnt++) {
fgd_ele_len = fgd_txt[fgd_curpos-1];
@ -355,27 +360,26 @@ void fgd_send_com( char *FGD_com, char *FGFS_host) {
printf(" #%d %s\n", fgd_cnt, fgfs_host);
}
}
break;
case 5: printf("FGD: Receiving data from Host %s\n", FGFS_host);
read( sock, fgd_txt, buffp[3]);
read( sock, fgd_txt, (unsigned char) buffp[3] + 256 * (unsigned char) buffp[4]);
fgd_txt[buffp[3]] = 0;
if (strcmp(fgd_txt, "UNKNOWN") == -1) {
printf("FGD: Data from Host %s received\n", fgd_txt);
}
else printf("FGD: Host not in list, sorry...\n");
if (strcmp(fgd_txt, "UNKNOWN") == 0) {
printf("FGD: Host not in list, sorry...\n");
}
else printf("FGD: Data from Host %s received\n", fgd_txt);
break;
case 6: printf("FGD: Sending data to Host %s\n", FGFS_host);
if (buffp[3] != 4) {
if (buffp[3] != 5) {
/* FIXME: replace with SELECT */
if (verbose == 2) printf("Noch %d bytes\n", (unsigned char) buffp[3]);
if (verbose == 2) printf("Noch %d bytes\n", (unsigned char) buffp[3] + 256 * (unsigned char) buffp[4]);
do {
fgd_status = recv( sock, fgd_txt, (unsigned char) buffp[3]-4, MSG_PEEK);
fgd_status = recv( sock, fgd_txt, (unsigned char) buffp[3]-5, MSG_PEEK);
if (verbose == 2) printf("Status %d\n", fgd_status);
}
while ( (fgd_status == 4) || (fgd_status == -1) );
while ( (fgd_status == 5) || (fgd_status == -1) );
// while ( (fgd_status == -1) || (fgd_status == -1) );
read( sock, fgd_txt, buffp[3]-4);
read( sock, fgd_txt, buffp[3]-5);
fgd_curpos = 2;
fgd_ppl_old = fgd_ppl;
fgd_ppl = fgd_txt[0];
@ -432,10 +436,10 @@ void fgd_send_com( char *FGD_com, char *FGFS_host) {
case 8: printf("FGD: Unregistering Host %s\n", FGFS_host);
read( sock, fgd_txt, buffp[3]);
fgd_txt[buffp[3]] = 0;
if (strcmp(fgd_txt, "UNKNOWN") == -1) {
printf("FGD: Host %s unregistered\n", fgd_txt);
if (strcmp(fgd_txt, "UNKNOWN") == 0) {
printf("FGD: Host not in list, sorry...\n");
}
else printf("FGD: Host not in list, sorry...\n");
else printf("FGD: Host %s unregistered\n", fgd_txt);
break;
case 9: printf(" Shutdown FlightGear-Deamon %s .\n", fgd_name);
break;
@ -457,13 +461,13 @@ int main(int argc, char **argv) {
fgd_init();
for ( ; (atoi( (char*) fgd_job)) != 99;){
printf("MCP: ready...enter commando (42 help) ");
gets((char *) fgd_job);
if (verbose == 2) printf("MCP: got %s %d\n", (char *) fgd_job, strlen((char *) fgd_job));
if ( strcmp( fgd_job, "") > 0 ) switch( atoi((char*) fgd_job)) {
case 0 : if ( strcmp( (char *) fgd_job, "0") == 0 ){
fgets((char *) fgd_job, 5, stdin);
// if (verbose == 2) printf("MCP: got %s %d\n", (char *) fgd_job, strlen((char *) fgd_job));
if ( strcmp( fgd_job, "\n") > 0 ) switch( atoi((char*) fgd_job)) {
case 0 : if ( strncmp( (char *) fgd_job, "0", 1) == 0 ){
printf("MCP: Scan for fgd\n");
fgd_send_com( "0", src_host);
}
}
break;
case 1 : printf("MCP: Register to fgd\n");
fgd_send_com( "1", src_host);
@ -491,33 +495,39 @@ int main(int argc, char **argv) {
printf(" Deamon Host IP Port\n");
printf(" %-16s%-16s%-16s%-16d\n", fgd_name, fgd_host, fgd_ip, base_port);
printf("\n Enter new Host:[%s] ", fgd_host);
gets((char *) fgd_txt);
if ( strlen(fgd_txt) != 0 ) {
fgets((char *) fgd_txt, 32, stdin);
if ( strlen(fgd_txt) != 1 ) {
strcpy(fgd_host, fgd_txt);
fgd_host[ strlen( fgd_txt) - 1] = 0;
if (host_info = gethostbyname( fgd_host)) {
bcopy(host_info->h_addr, (char *)&address.sin_addr,host_info->h_length);
strcpy((char *) fgd_ip, (char *) inet_ntoa(address.sin_addr));
if (verbose == 2) {
printf(" resolved\n FGD running on HOST : %s", fgd_host);
printf("MCP: Resolved...FGD running on HOST : %s", fgd_host);
printf(" IP : %s\n", fgd_ip);
}
} else if ((address.sin_addr.s_addr = inet_addr( fgd_host)) == INADDR_NONE) {
fprintf(stderr," Could not get %s host entry !\n", fgd_host);
printf(" NOT resolved !!!\n");
exit(1);
fprintf(stderr,"MCP: Could not get %s host entry !\n", fgd_host);
printf(" NOT resolved !!!\n");
// exit(1);
} else if (verbose == 2) printf(" address valid\n");
}
break;
case 11 : printf("MCP: Choose default deamon Port:\n");
printf(" Deamon Host IP Port\n");
printf(" %-16s%-16s%-16s%-16d\n", fgd_name, fgd_host, fgd_ip, base_port);
printf(" Enter new Port: ");
gets((char *) buffp);
printf(" Enter new Port:[%d] ", base_port);
fgets((char *) buffp, 16, stdin);
current_port = atoi((char*) buffp);
if (current_port < 1025) {
printf("MCP: Be fair please...Ports below 1024 are not a good choice\n");
current_port = base_port;
break;
}
if (current_port != 0) {
base_port = atoi((char*) buffp);
end_port = base_port;
}
}
break;
case 20 : printf("MCP: Current values:\n");
printf(" Deamon Host IP Port\n");
@ -543,7 +553,8 @@ int main(int argc, char **argv) {
break;
case 21 : printf("MCP: Enter your callsign, Pilot ");
gets((char *) fgd_callsign);
fgets((char *) fgd_callsign, 32, stdin);
fgd_callsign[ strlen(fgd_callsign) - 1 ] = 0;
break;
case 42 : printf("MCP: Commands available:\n 0 Scan for fgd\n 1 Register\n");
printf(" 2 Show registered\n 3 Send MSG\n 4 Send MSG to ALL\n");
@ -551,7 +562,7 @@ int main(int argc, char **argv) {
printf(" 8 Unregister from fgd\n 9 Shutdown fgd\n");
printf("10 Set deamon HOST\n11 Set deamon PORT\n");
printf("20 Show values\n21 Set own callsign\n");
printf("31 Set deamon PORT\n");
// printf("31 Set deamon PORT\n");
printf("98 Stress test\n");
printf("99 Quit Master Control Program (not recommended)\n");
break;
@ -566,14 +577,16 @@ int main(int argc, char **argv) {
fgd_send_com( "5", src_host);
fgd_send_com( "6", src_host);
printf("other lat:%7.3f boss lat:%7.3f\n", other->latf, boss->latf);
if (fabs(boss->latf - other->latf) > 0.001) {
if (fabs( (double) boss->latf - (double) other->latf ) > 0.001) {
printf("other lat:%7.3f boss lat:%7.3f\n", other->latf, boss->latf);
fgd_loss++;
}
}
printf(" Packets lost: %d\n", fgd_loss);
break;
default: break;
case 99 : printf("MCP: Good bye...\n");
break;
default: printf("MCP: ???\n");
}
}
// fgd_send_com( argv[5], argv[6]);
@ -588,6 +601,5 @@ int main(int argc, char **argv) {
free(fgfs_pilot);
free(src_host);
free(fgd_txt);
printf("MCP: Exit...\n");
exit(0);
}

View file

@ -1,34 +1,35 @@
/***********************************************************/
/* FGD_SCAN.C by Oliver Delise */
/* Contact info: */
/* e-mail: delise@mail-isis.de */
/* www: http://www.online-club.de/~olk/progs/mmx-emu/ */
/* ftp: http://www.online-club.de/~olk/progs/flightgear */
/* */
/* Version 0.1-alpha */
/* The author of this program offers no waranty at all */
/* about the correct execution of this software material. */
/* Furthermore, the author can NOT be held responsible for */
/* any physical or moral damage caused by the use of this */
/* software. */
/* */
/* This is a standalone Tool to scan for any FlightGear */
/* Deamon. */
/* This is Open Source Software with many parts */
/* shamelessly stolen from others... */
/* */
/* -> This program will scan for TCP port listening on a */
/* remote or local host inside the range you give to it.*/
/* I offer no warranty over the accuracy though :) */
/* There are 3 verbose modes: No info, service info, and*/
/* full info. No info is good of you only want the list */
/* of the ports, no more info. The best mode is Full */
/* info, as you get error information,etc. The main */
/* output is STDOUT, and ALL the errors go to STDERR. */
/* */
/* History: v0.1pre-alpha: May 25 1999 -> First release */
/* v0.1-alpha Nov 08 1999 */
/***********************************************************/
/*************************************************************/
/* FGD_SCAN.C by Oliver Delise */
/* Contact info: */
/* e-mail: delise@mail-isis.de */
/* www: http://www.isis.de/members/odelise/progs/flightgear */
/* */
/* Version 0.1-beta */
/* The author of this program offers no waranty at all */
/* about the correct execution of this software material. */
/* Furthermore, the author can NOT be held responsible for */
/* any physical or moral damage caused by the use of this */
/* software. */
/* */
/* This is a standalone Tool to scan for any FlightGear */
/* Deamon. */
/* This is Open Source Software with many parts */
/* shamelessly stolen from others... */
/* */
/* -> This program will scan for TCP port listening on a */
/* remote or local host inside the range you give to it. */
/* I offer no warranty over the accuracy though :) */
/* There are 3 verbose modes: No info, service info, and */
/* full info. No info is good of you only want the list */
/* of the ports, no more info. The best mode is Full */
/* info, as you get error information,etc. The main */
/* output is STDOUT, and ALL the errors go to STDERR. */
/* */
/* History: v0.1pre-alpha: May 25 1999 -> First release */
/* v0.1-alpha Nov 08 1999 */
/* v0.1-beta Jan 16 2000 libc5/glibc-2.0 */
/* glibc-2.1 cleanups */
/*************************************************************/
#include <stdio.h>
@ -47,7 +48,6 @@ int my_sock;
struct sockaddr_in address;
struct sockaddr_in my_address;
int result;
extern char *sys_errlist[];
extern int errno;
int current_port = 20000;
u_short base_port = 20000;

View file

@ -5,4 +5,15 @@
#include <netdb.h>
#include <sys/time.h>
#include <fcntl.h>
#include <sys/utsname.h>
#include <sys/utsname.h>
/* this seems to be missing for glibc-2.0.x */
/* libc5 & glibc-2.1 do have them */
#ifndef MSG_PEEK
int MSG_PEEK = 0x02; /* Peek at incoming messages. */
#define MSG_PEEK MSG_PEEK
#endif
#ifndef MSG_WAITALL
int MSG_WAITALL = 0x100; /* Wait for a full request. */
#define MSG_WAITALL MSG_WAITALL
#endif

View file

@ -2,7 +2,7 @@
//
// Written by Oliver Delise, started May 1999.
//
// Copyleft (C) 1999 Oliver Delise - delise@rp-plus.de
// Copyleft (C) 1999 Oliver Delise - delise@mail.isis.de
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as

View file

@ -1,11 +1,10 @@
/*************************************************************/
/* FGD_MCP.C by Oliver Delise */
/* NET_SEND.CXX by Oliver Delise */
/* Contact info: */
/* e-mail: delise@mail.isis.de */
/* www: http://www.isis.de/members/~odelise/progs/mmx-emu/ */
/* ftp: http://www.isis.de/members/~odelise/progs/flightgear */
/* www: http://www.isis.de/members/odelise/progs/flightgear */
/* */
/* Version 0.1-alpha */
/* Version 0.1-beta */
/* The author of this program offers no waranty at all */
/* about the correct execution of this software material. */
/* Furthermore, the author can NOT be held responsible for */
@ -28,6 +27,8 @@
/* */
/* History: v0.1pre-alpha: May 25 1999 -> First release */
/* v0.1-alpha Nov 11 1999 */
/* v0.1-beta Jan 16 2000 -> libc5, glibc2.0 */
/* glibc-2.1 issues fixed */
/*************************************************************/
#include <stdio.h>
@ -256,12 +257,12 @@ void fgd_init(void){
} else if ((address.sin_addr.s_addr = inet_addr( fgd_host)) == INADDR_NONE) {
fprintf(stderr," Could not get %s host entry !\n", fgd_host);
printf(" NOT resolved !!!\n");
exit(1);
// exit(1);
} else if (verbose == 2) printf(" address valid\n");
if ((base_port > end_port) || ((short)base_port < 0)) {
fprintf(stderr,"Bad port range : start=%d end=%d !\n");
exit(1);
// exit(1);
} else if (verbose == 2) {
printf(" Port range: %d to %d\n",base_port,end_port);
}
@ -314,7 +315,8 @@ void fgd_send_com( char *FGD_com, char *FGFS_host) {
if (sock == -1)
{
fprintf(stderr, "Error assigning master socket: %s\n",sys_errlist[errno]);
exit(-1);
/* must check how severe this really is */
// exit(-1);
}
address.sin_port = htons(current_port);
@ -416,7 +418,8 @@ void fgd_send_com( char *FGD_com, char *FGFS_host) {
}
} else if (errno == 113) {
fprintf(stderr,"No route to host !\n");
exit(1);
/* must check this */
// exit(1);
}
/* fprintf(stderr,"Error %d connecting socket %d to port %d: %s\n",
errno,sock,current_port,sys_errlist[errno]); */
@ -473,10 +476,18 @@ void fgd_send_com( char *FGD_com, char *FGFS_host) {
case 5: printf("FGD: Receiving data from Host %s\n", FGFS_host);
read( sock, fgd_txt, buffp[3]);
fgd_txt[buffp[3]] = 0;
/* This works...
if (strcmp(fgd_txt, "UNKNOWN") == 0) {
printf("FGD: Host not in list, sorry...\n");
}
else printf("FGD: Data from Host %s received\n", fgd_txt);
*/
/* This has problem with glibc-2.1
if (strcmp(fgd_txt, "UNKNOWN") == -1) {
if (verbose == 2) printf("FGD: Data from Host %s received\n", fgd_txt);
}
else if (verbose == 2) printf("FGD: Host not in list, sorry...\n");
*/
break;
case 17: if (verbose == 2) printf("FGD: Receiving Mat4 data from Host %s\n", FGFS_host);
read( sock, fgd_txt, fgd_reply_len);
@ -634,11 +645,18 @@ void fgd_send_com( char *FGD_com, char *FGFS_host) {
test = test->next;
}
fgd_ppl = 0;
/*
/* This does...
if (strcmp(fgd_txt, "UNKNOWN") == 0) {
printf("FGD: Host not in list, sorry...\n");
}
else printf("FGD: Host %s unregistered\n", fgd_txt);
*/
/* This does not work on glibc-2.1
if (strcmp(fgd_txt, "UNKNOWN") == -1) {
printf("FGD: Host %s unregistered\n", fgd_txt);
}
else printf("FGD: Host not in list, sorry...\n"); */
else printf("FGD: Host not in list, sorry...\n");
*/
break;
case 9: printf(" Shutdown FlightGear-Deamon %s .\n", fgd_name);
break;

View file

@ -2,7 +2,7 @@
//
// Written by Oliver Delise, started May 1999.
//
// Copyleft (C) 1999 Oliver Delise - delise@rp-plus.de
// Copyleft (C) 1999 Oliver Delise - delise@mail.isis.de
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as

View file

@ -2,7 +2,7 @@
//
// Written by Oliver Delise, started May 1999.
//
// Copyleft (C) 1999 Oliver Delise - delise@rp-plus.de
// Copyleft (C) 1999 Oliver Delise - delise@mail.isis.de
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as