head 1.1; access; symbols OPENPKG_E1_MP_HEAD:1.1 OPENPKG_E1_MP:1.1 OPENPKG_E1_MP_2_STABLE:1.1.2.2 OPENPKG_E1_FP:1.1.2.2 OPENPKG_2_STABLE_MP:1.1 OPENPKG_2_STABLE_20061018:1.1.2.2 OPENPKG_2_STABLE:1.1.0.2; locks; strict; comment @# @; 1.1 date 2005.11.16.13.25.03; author rse; state Exp; branches 1.1.2.1; next ; commitid Zmtz7ZRJAeadhZ9r; 1.1.2.1 date 2005.11.16.13.25.03; author rse; state dead; branches; next 1.1.2.2; commitid iZxwRSmmWscPXUQr; 1.1.2.2 date 2006.10.16.14.56.52; author rse; state Exp; branches; next ; commitid iZxwRSmmWscPXUQr; desc @@ 1.1 log @new package: stun 0.96 (STUN Client & Server) @ text @Index: client.cxx --- client.cxx.orig 2005-08-14 02:43:10 +0200 +++ client.cxx 2005-11-16 10:28:17 +0100 @@@@ -178,13 +178,13 @@@@ retval[nic] = 0x02; break; case StunTypeDependentFilter: - cout << "Independedt Mapping, Address Dependendent Filter"; + cout << "Independedt Mapping, Address Dependent Filter"; if ( presPort ) cout << ", preserves ports"; else cout << ", random port"; if ( hairpin ) cout << ", will hairpin"; else cout << ", no hairpin"; retval[nic] = 0x04; break; case StunTypePortDependedFilter: - cout << "Indepndent Mapping, Port Dependent Filter"; + cout << "Independent Mapping, Port Dependent Filter"; if ( presPort ) cout << ", preserves ports"; else cout << ", random port"; if ( hairpin ) cout << ", will hairpin"; else cout << ", no hairpin"; retval[nic] = 0x06; Index: server.cxx --- server.cxx.orig 2005-08-13 22:19:29 +0200 +++ server.cxx 2005-11-16 10:33:51 +0100 @@@@ -23,7 +23,7 @@@@ usage() { cerr << "Usage: " << endl - << " ./server [-v] [-h] [-h IP_Address] [-a IP_Address] [-p port] [-o port] [-m mediaport]" << endl + << " ./server [-v] [-h] [-h IP_Address] [-a IP_Address] [-p port] [-o port] [-b] [-m mediaport] [-P pidfile]" << endl << " " << endl << " If the IP addresses of your NIC are 10.0.1.150 and 10.0.1.151, run this program with" << endl << " ./server -v -h 10.0.1.150 -a 10.0.1.151" << endl @@@@ -32,7 +32,7 @@@@ << " -a sets the secondary IP" << endl << " -p sets the primary port and defaults to 3478" << endl << " -o sets the secondary port and defaults to 3479" << endl - << " -b makes the program run in the backgroud" << endl + << " -b makes the program run in the background" << endl << " -m sets up a STERN server starting at port m" << endl << " -v runs in verbose mode" << endl // in makefile too @@@@ -55,6 +55,7 @@@@ StunAddress4 altAddr; bool verbose=false; bool background=false; + char *myPidFile = 0; myAddr.addr = 0; altAddr.addr = 0; @@@@ -135,6 +136,16 @@@@ } myMediaPort = UInt16(strtol( argv[arg], NULL, 10)); } + else if ( !strcmp( argv[arg] , "-P" ) ) + { + arg++; + if ( argc <= arg ) + { + usage(); + exit(-1); + } + myPidFile = argv[arg]; + } else { usage(); @@@@ -213,6 +224,19 @@@@ if (pid == 0) //child or not using background { + /* write a daemon pidfile */ + if (myPidFile) { + pid_t pid; + FILE *fp; + pid = getpid(); + if ((fp = fopen(myPidFile, "w")) == NULL) { + fprintf(stderr, "stund: Can't write pidfile '%s'", myPidFile); + exit(1); + } + fprintf(fp, "%ld\n", (long)pid); + fclose(fp); + } + StunServerInfo info; bool ok = stunInitServer(info, myAddr, altAddr, myMediaPort, verbose); @ 1.1.2.1 log @file stun.patch was added on branch OPENPKG_2_STABLE on 2006-10-16 14:56:52 +0000 @ text @d1 85 @ 1.1.2.2 log @Mass merge from CURRENT to 2-STABLE (all packages except those of JUNK class) @ text @a0 85 Index: client.cxx --- client.cxx.orig 2005-08-14 02:43:10 +0200 +++ client.cxx 2005-11-16 10:28:17 +0100 @@@@ -178,13 +178,13 @@@@ retval[nic] = 0x02; break; case StunTypeDependentFilter: - cout << "Independedt Mapping, Address Dependendent Filter"; + cout << "Independedt Mapping, Address Dependent Filter"; if ( presPort ) cout << ", preserves ports"; else cout << ", random port"; if ( hairpin ) cout << ", will hairpin"; else cout << ", no hairpin"; retval[nic] = 0x04; break; case StunTypePortDependedFilter: - cout << "Indepndent Mapping, Port Dependent Filter"; + cout << "Independent Mapping, Port Dependent Filter"; if ( presPort ) cout << ", preserves ports"; else cout << ", random port"; if ( hairpin ) cout << ", will hairpin"; else cout << ", no hairpin"; retval[nic] = 0x06; Index: server.cxx --- server.cxx.orig 2005-08-13 22:19:29 +0200 +++ server.cxx 2005-11-16 10:33:51 +0100 @@@@ -23,7 +23,7 @@@@ usage() { cerr << "Usage: " << endl - << " ./server [-v] [-h] [-h IP_Address] [-a IP_Address] [-p port] [-o port] [-m mediaport]" << endl + << " ./server [-v] [-h] [-h IP_Address] [-a IP_Address] [-p port] [-o port] [-b] [-m mediaport] [-P pidfile]" << endl << " " << endl << " If the IP addresses of your NIC are 10.0.1.150 and 10.0.1.151, run this program with" << endl << " ./server -v -h 10.0.1.150 -a 10.0.1.151" << endl @@@@ -32,7 +32,7 @@@@ << " -a sets the secondary IP" << endl << " -p sets the primary port and defaults to 3478" << endl << " -o sets the secondary port and defaults to 3479" << endl - << " -b makes the program run in the backgroud" << endl + << " -b makes the program run in the background" << endl << " -m sets up a STERN server starting at port m" << endl << " -v runs in verbose mode" << endl // in makefile too @@@@ -55,6 +55,7 @@@@ StunAddress4 altAddr; bool verbose=false; bool background=false; + char *myPidFile = 0; myAddr.addr = 0; altAddr.addr = 0; @@@@ -135,6 +136,16 @@@@ } myMediaPort = UInt16(strtol( argv[arg], NULL, 10)); } + else if ( !strcmp( argv[arg] , "-P" ) ) + { + arg++; + if ( argc <= arg ) + { + usage(); + exit(-1); + } + myPidFile = argv[arg]; + } else { usage(); @@@@ -213,6 +224,19 @@@@ if (pid == 0) //child or not using background { + /* write a daemon pidfile */ + if (myPidFile) { + pid_t pid; + FILE *fp; + pid = getpid(); + if ((fp = fopen(myPidFile, "w")) == NULL) { + fprintf(stderr, "stund: Can't write pidfile '%s'", myPidFile); + exit(1); + } + fprintf(fp, "%ld\n", (long)pid); + fclose(fp); + } + StunServerInfo info; bool ok = stunInitServer(info, myAddr, altAddr, myMediaPort, verbose); @