michael@52: Index: server.cxx michael@418: diff -Nau server.cxx.orig server.cxx michael@52: --- server.cxx.orig 2005-08-13 22:19:29 +0200 michael@52: +++ server.cxx 2005-11-16 10:33:51 +0100 michael@418: @@ -2,6 +2,7 @@ michael@418: #include michael@418: #include michael@418: #include michael@418: +#include michael@418: michael@418: #ifndef WIN32 michael@418: #include michael@418: @@ -23,7 +24,7 @@ michael@52: usage() michael@52: { michael@52: cerr << "Usage: " << endl michael@52: - << " ./server [-v] [-h] [-h IP_Address] [-a IP_Address] [-p port] [-o port] [-m mediaport]" << endl michael@52: + << " ./server [-v] [-h] [-h IP_Address] [-a IP_Address] [-p port] [-o port] [-b] [-m mediaport] [-P pidfile]" << endl michael@52: << " " << endl michael@52: << " If the IP addresses of your NIC are 10.0.1.150 and 10.0.1.151, run this program with" << endl michael@52: << " ./server -v -h 10.0.1.150 -a 10.0.1.151" << endl michael@418: @@ -32,7 +33,7 @@ michael@52: << " -a sets the secondary IP" << endl michael@52: << " -p sets the primary port and defaults to 3478" << endl michael@52: << " -o sets the secondary port and defaults to 3479" << endl michael@52: - << " -b makes the program run in the backgroud" << endl michael@52: + << " -b makes the program run in the background" << endl michael@52: << " -m sets up a STERN server starting at port m" << endl michael@52: << " -v runs in verbose mode" << endl michael@52: // in makefile too michael@418: @@ -55,6 +56,7 @@ michael@52: StunAddress4 altAddr; michael@52: bool verbose=false; michael@52: bool background=false; michael@52: + char *myPidFile = 0; michael@52: michael@52: myAddr.addr = 0; michael@52: altAddr.addr = 0; michael@418: @@ -135,6 +137,16 @@ michael@52: } michael@52: myMediaPort = UInt16(strtol( argv[arg], NULL, 10)); michael@52: } michael@52: + else if ( !strcmp( argv[arg] , "-P" ) ) michael@52: + { michael@52: + arg++; michael@52: + if ( argc <= arg ) michael@52: + { michael@52: + usage(); michael@52: + exit(-1); michael@52: + } michael@52: + myPidFile = argv[arg]; michael@52: + } michael@52: else michael@52: { michael@52: usage(); michael@418: @@ -213,6 +225,19 @@ michael@52: michael@52: if (pid == 0) //child or not using background michael@52: { michael@52: + /* write a daemon pidfile */ michael@52: + if (myPidFile) { michael@52: + pid_t pid; michael@52: + FILE *fp; michael@52: + pid = getpid(); michael@52: + if ((fp = fopen(myPidFile, "w")) == NULL) { michael@52: + fprintf(stderr, "stund: Can't write pidfile '%s'", myPidFile); michael@52: + exit(1); michael@52: + } michael@52: + fprintf(fp, "%ld\n", (long)pid); michael@52: + fclose(fp); michael@52: + } michael@52: + michael@52: StunServerInfo info; michael@52: bool ok = stunInitServer(info, myAddr, altAddr, myMediaPort, verbose); michael@52: michael@53: Index: stun.cxx michael@418: diff -Nau stun.cxx.orig stun.cxx michael@53: --- stun.cxx.orig 2005-08-14 02:39:03.000000000 +0200 michael@53: +++ stun.cxx 2009-01-09 00:23:08.069498590 +0100 michael@418: @@ -16,6 +16,9 @@ michael@53: #include michael@53: #include michael@53: #include michael@418: +#if defined (__SVR4) && defined (__sun) michael@53: +#include michael@418: +#endif michael@53: #include michael@53: #include michael@53: #include