stun/stun.patch

Mon, 28 Jan 2013 17:37:18 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Mon, 28 Jan 2013 17:37:18 +0100
changeset 758
a2c6460cfb16
parent 417
76ceb617f880
permissions
-rw-r--r--

Correct socket error reporting improvement with IPv6 portable code,
after helpful recommendation by Saúl Ibarra Corretgé on OSips devlist.

     1 Index: server.cxx
     2 diff -Nau server.cxx.orig server.cxx
     3 --- server.cxx.orig	2005-08-13 22:19:29 +0200
     4 +++ server.cxx	2005-11-16 10:33:51 +0100
     5 @@ -2,6 +2,7 @@
     6  #include <cstring>
     7  #include <iostream>
     8  #include <cstdlib>   
     9 +#include <cstdio>   
    11  #ifndef WIN32
    12  #include <sys/time.h>
    13 @@ -23,7 +24,7 @@
    14  usage()
    15  {
    16     cerr << "Usage: " << endl
    17 -        << " ./server [-v] [-h] [-h IP_Address] [-a IP_Address] [-p port] [-o port] [-m mediaport]" << endl
    18 +        << " ./server [-v] [-h] [-h IP_Address] [-a IP_Address] [-p port] [-o port] [-b] [-m mediaport] [-P pidfile]" << endl
    19          << " " << endl
    20          << " If the IP addresses of your NIC are 10.0.1.150 and 10.0.1.151, run this program with" << endl
    21          << "    ./server -v  -h 10.0.1.150 -a 10.0.1.151" << endl
    22 @@ -32,7 +33,7 @@
    23          << "  -a sets the secondary IP" << endl
    24          << "  -p sets the primary port and defaults to 3478" << endl
    25          << "  -o sets the secondary port and defaults to 3479" << endl
    26 -        << "  -b makes the program run in the backgroud" << endl
    27 +        << "  -b makes the program run in the background" << endl
    28          << "  -m sets up a STERN server starting at port m" << endl
    29          << "  -v runs in verbose mode" << endl
    30        // in makefile too
    31 @@ -55,6 +56,7 @@
    32     StunAddress4 altAddr;
    33     bool verbose=false;
    34     bool background=false;
    35 +   char *myPidFile = 0;
    37     myAddr.addr = 0;
    38     altAddr.addr = 0;
    39 @@ -135,6 +137,16 @@
    40           }
    41           myMediaPort = UInt16(strtol( argv[arg], NULL, 10));
    42        }
    43 +      else if ( !strcmp( argv[arg] , "-P" ) )
    44 +      {
    45 +         arg++;
    46 +         if ( argc <= arg ) 
    47 +         {
    48 +            usage();
    49 +            exit(-1);
    50 +         }
    51 +         myPidFile = argv[arg];
    52 +      }
    53        else
    54        {
    55           usage();
    56 @@ -213,6 +225,19 @@
    58     if (pid == 0) //child or not using background
    59     {
    60 +      /* write a daemon pidfile */
    61 +      if (myPidFile) {
    62 +          pid_t pid;
    63 +          FILE *fp;
    64 +          pid = getpid();
    65 +          if ((fp = fopen(myPidFile, "w")) == NULL) {
    66 +              fprintf(stderr, "stund: Can't write pidfile '%s'", myPidFile);
    67 +              exit(1);
    68 +          }
    69 +          fprintf(fp, "%ld\n", (long)pid);
    70 +          fclose(fp);
    71 +      }
    72 +
    73        StunServerInfo info;
    74        bool ok = stunInitServer(info, myAddr, altAddr, myMediaPort, verbose);
    76 Index: stun.cxx
    77 diff -Nau stun.cxx.orig stun.cxx
    78 --- stun.cxx.orig	2005-08-14 02:39:03.000000000 +0200
    79 +++ stun.cxx	2009-01-09 00:23:08.069498590 +0100
    80 @@ -16,6 +16,9 @@
    81  #include <string.h>
    82  #include <sys/ioctl.h>
    83  #include <sys/socket.h>
    84 +#if defined (__SVR4) && defined (__sun)
    85 +#include <sys/sockio.h>
    86 +#endif
    87  #include <sys/time.h>
    88  #include <sys/types.h> 
    89  #include <arpa/inet.h>

mercurial