Changeset 9403 in ntrip for trunk/ntripserver


Ignore:
Timestamp:
Apr 13, 2021, 4:53:54 PM (4 years ago)
Author:
stuerze
Message:

minor changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ntripserver/ntripserver.c

    r9402 r9403  
    120120#define NTRIP_PORT      2101
    121121
    122 #define DABPLUS_SERVER  "62.225.182.198"
    123 #define DABPLUS_PORT    10000
    124 
    125122#define SISNET_SERVER   "131.176.49.142"
    126123#define SISNET_PORT     7777
     
    233230  const char *ntrip_str = "";
    234231
     232  const char *dabplus_provider = 0;
     233  char dabplus_provider_str[17] = "";
     234
    235235  const char *user = "";
    236236  const char *password = "";
     
    296296  }
    297297  while ((c = getopt(argc, argv,
    298       "M:i:h:b:p:s:a:m:c:H:P:f:x:y:l:u:V:D:U:W:O:E:F:R:N:n:B")) != EOF) {
     298      "M:i:h:b:p:s:a:m:c:H:P:f:x:y:l:u:V:D:U:W:O:E:F:R:N:T:n:B")) != EOF) {
    299299    switch (c) {
    300300      case 'M': /*** InputMode ***/
     
    438438        ntrip_str = optarg;
    439439        break;
     440      case 'T':
     441        dabplus_provider = optarg;
     442        break;
    440443      case 'h': /* print help screen */
    441444      case '?':
     
    474477
    475478  if (outputmode == TDC) {
     479    fprintf(stderr, "ERROR: DABPLUS server upload implementation is so far not completed\n\n");
     480    exit(0);
     481
    476482    mountpoint = NULL;
    477     if (!strcmp(casterouthost, NTRIP_CASTER)) {
    478       casterouthost = DABPLUS_SERVER;
    479     }
    480     if (casteroutport == NTRIP_PORT) {
    481       casteroutport = DABPLUS_PORT;
     483    if (dabplus_provider) {
     484      i = snprintf(dabplus_provider_str, 17, "%16s", dabplus_provider);
     485      if ((i > 16) || (i < 0)) {
     486        fprintf(stderr, "ERROR: DABPLUS provider name to long - length = %d (max: %d)\n", i, 16);
     487        exit(0);
     488      }
     489    }
     490    else {
     491      fprintf(stderr, "ERROR: DABPLUS provider name required\n");
     492      exit(0);
    482493    }
    483494  }
     
    499510
    500511  if (stream_name && stream_user && !stream_password) {
    501     fprintf(stderr,
    502         "WARNING: Missing password argument for stream download - are you really sure?\n");
     512    fprintf(stderr, "WARNING: Missing password argument for stream download - are you really sure?\n");
    503513  }
    504514
    505515  /*** proxy server handling ***/
    506516  if (*proxyhost) {
    507     outhost = inhost = proxyhost;
    508     outport = inport = proxyport;
     517    if (outputmode == TDC) {
     518      fprintf(stderr, "\nWARNING: TDC is not able to support proxy servers, try direct connection\n\n");
     519      inhost = proxyhost;
     520      inport = proxyport;
     521      outhost = casterouthost;
     522      outport = casteroutport;
     523    } else {
     524      outhost = inhost = proxyhost;
     525      outport = inport = proxyport;
     526    }
    509527    i = snprintf(szSendBuffer, sizeof(szSendBuffer), "http://%s:%d", casterouthost, casteroutport);
    510528    if ((i > SZ) || (i < 0)) {
     
    530548      strcpy(szSendBuffer, "");
    531549      i = 0;
    532       fprintf(stdout, "%s",get_extension);
    533550    }
    534551  } else {
     
    711728        szSendBuffer[nBufferBytes++] = '\r';
    712729        szSendBuffer[nBufferBytes++] = '\n';
    713 fprintf(stdout, "%s", szSendBuffer);
     730        // fprintf(stdout, "%s\n", szSendBuffer);
    714731        if ((send(gps_socket, szSendBuffer, (size_t) nBufferBytes, 0)) != nBufferBytes) {
    715732          fprintf(stderr, "WARNING: could not send Source caster request\n");
     
    883900      if((sigalarm_received) || (sigint_received)) break;
    884901#endif
     902
    885903      if (!(he = gethostbyname(outhost))) {
    886904        fprintf(stderr,
     
    889907        close_session(casterouthost, mountpoint, session, rtsp_extension, 0);
    890908        usage(-2, argv[0]);
    891       }
     909      }else {fprintf(stderr,
     910          "Destination caster, server or proxy host <%s> \n",
     911          outhost);}
    892912
    893913      /* create socket */
     
    904924
    905925      /* connect to Destination caster, server or proxy host */
    906       fprintf(stderr, "caster output: host = %s, port = %d, mountpoint = %s"
     926      fprintf(stderr, "caster|server output: host = %s, port = %d, mountpoint = %s"
    907927          ", mode = %s\n\n", inet_ntoa(caster.sin_addr), outport, mountpoint,
    908           outputmode == NTRIP1 ? "ntrip1" : outputmode == HTTP ? "http" :
    909           outputmode == UDP ? "udp" : "rtsp");
     928          outputmode == NTRIP1 ? "ntrip1" :
     929          outputmode == HTTP   ? "http"   :
     930          outputmode == UDP    ? "udp"    :
     931          outputmode == RTSP   ? "rtsp"   : "tdc");
    910932
    911933      if (connect(socket_tcp, (struct sockaddr*) &caster, sizeof(caster)) < 0) {
     
    10651087          }
    10661088          /* check Destination caster's response */
    1067           nBufferBytes = recv(socket_tcp, szSendBuffer, sizeof(szSendBuffer),
    1068               0);
     1089          nBufferBytes = recv(socket_tcp, szSendBuffer, sizeof(szSendBuffer), 0);
    10691090          szSendBuffer[nBufferBytes] = '\0';
    10701091          if (!strstr(szSendBuffer, "OK")) {
     
    13071328          break;
    13081329        case TDC:
     1330          fallback = 0;
     1331          szSendBuffer[0] = 0x28;
     1332          szSendBuffer[1] = 0x11;
     1333          szSendBuffer[2] = 0x19;
     1334          szSendBuffer[3] = 0x69;
     1335          strncpy(szSendBuffer + 4, dabplus_provider_str, 16);
     1336          szSendBuffer[20] = 0; // mot
     1337          nBufferBytes =  strlen(szSendBuffer);
     1338          if ((nBufferBytes > 20) || (nBufferBytes < 0)) {
     1339            fprintf(stderr, "ERROR: Destination server request to long\n");
     1340            reconnect_sec_max = 0;
     1341            output_init = 0;
     1342            break;
     1343          }
     1344          if (!send_to_caster(szSendBuffer, socket_tcp, nBufferBytes)) {
     1345            output_init = 0;
     1346            break;
     1347          }
     1348          /* check Destination server's response
     1349          in case of a unidirectional connection muxd will close the connection
     1350          if an error occurs without transmitting any status information
     1351          */
     1352          send_receive_loop(socket_tcp, outputmode, NULL, 0, 0, chunkymode);
     1353          input_init = output_init = 0;
    13091354          break;
    13101355      }
     
    14091454        }
    14101455      }
    1411       /*** receiving data ****/
     1456      /***********************/
     1457      /* receiving data      */
     1458      /***********************/
     1459
     1460      /* INFILE  */
    14121461      if (inputmode == INFILE)
    14131462        nBufferBytes = read(gps_file, buffer, sizeof(buffer));
     1463
     1464      /* SERIAL */
    14141465      else if (inputmode == SERIAL) {
    14151466#ifndef WINDOWSVERSION
     
    14251476#endif
    14261477      }
     1478
     1479      /* ALL OTHER MODES */
    14271480      else
    14281481#ifdef WINDOWSVERSION
     
    15231576      }
    15241577    }
    1525     /**  send data ***/
    1526     if ((nBufferBytes) && (outmode == NTRIP1)) /*** Ntrip-Version 1.0 ***/
    1527     {
     1578
     1579    /*****************/
     1580    /*  send data    */
     1581    /*****************/
     1582    if ((nBufferBytes) && (outmode == NTRIP1)) {
    15281583      int i;
    15291584      if ((i = send(sock, buffer, (size_t) nBufferBytes, MSG_DONTWAIT)) != nBufferBytes) {
     
    16941749        return;
    16951750      }
     1751    }
     1752    else if ((nBufferBytes) && (outmode == TDC)) {
     1753
    16961754    }
    16971755    if (send_recv_success == 3)
     
    18821940      "   and forward that incoming stream (Output, Destination) to either\n\n");
    18831941  fprintf(stderr, "     - an NTRIP Version 1.0 Caster, or\n");
    1884   fprintf(stderr,
    1885       "     - an NTRIP Version 2.0 Caster via TCP/IP or RTSP/RTP, or \n");
     1942  fprintf(stderr, "     - an NTRIP Version 2.0 Caster via TCP/IP or RTSP/RTP, or \n");
    18861943  fprintf(stderr, "     - an DABPLUS Content Server via TCP/IP and TDC \n\n\n");
    18871944  fprintf(stderr, "OPTIONS\n");
    18881945  fprintf(stderr, "   -h|? print this help screen\n\n");
    1889   fprintf(stderr,
    1890       "    -E <ProxyHost>       Proxy server host name or address, required i.e. when\n");
    1891   fprintf(stderr,
    1892       "                         running the program in a proxy server protected LAN,\n");
     1946  fprintf(stderr, "    -E <ProxyHost>       Proxy server host name or address, required i.e. when\n");
     1947  fprintf(stderr, "                         running the program in a proxy server protected LAN,\n");
    18931948  fprintf(stderr, "                         optional\n");
    1894   fprintf(stderr,
    1895       "    -F <ProxyPort>       Proxy server IP port, required i.e. when running\n");
    1896   fprintf(stderr,
    1897       "                         the program in a proxy server protected LAN, optional\n");
    1898   fprintf(stderr,
    1899       "    -R <maxDelay>        Reconnect mechanism with maximum delay between reconnect\n");
    1900   fprintf(stderr,
    1901       "                         attemts in seconds, default: no reconnect activated,\n");
     1949  fprintf(stderr, "    -F <ProxyPort>       Proxy server IP port, required i.e. when running\n");
     1950  fprintf(stderr, "                         the program in a proxy server protected LAN, optional\n");
     1951  fprintf(stderr, "    -R <maxDelay>        Reconnect mechanism with maximum delay between reconnect\n");
     1952  fprintf(stderr, "                         attemts in seconds, default: no reconnect activated,\n");
    19021953  fprintf(stderr, "                         optional\n\n");
    1903   fprintf(stderr,
    1904       "    -M <InputMode> Sets the input mode (1 = Serial Port, 2 = IP server,\n");
    1905   fprintf(stderr,
    1906       "       3 = File, 4 = SISNeT Data Server, 5 = UDP server, 6 = NTRIP1 Caster, 7 = NTRIP2 Caster in HTTP mode),\n");
     1954  fprintf(stderr, "    -M <InputMode> Sets the input mode (1 = Serial Port, 2 = IP server,\n");
     1955  fprintf(stderr, "       3 = File, 4 = SISNeT Data Server, 5 = UDP server, 6 = NTRIP1 Caster, 7 = NTRIP2 Caster in HTTP mode),\n");
    19071956  fprintf(stderr, "       mandatory\n\n");
    19081957  fprintf(stderr, "       <InputMode> = 1 (Serial Port):\n");
    1909   fprintf(stderr,
    1910       "       -i <Device>       Serial input device, default: %s, mandatory if\n",
    1911       ttyport);
     1958  fprintf(stderr, "       -i <Device>       Serial input device, default: %s, mandatory if\n", ttyport);
    19121959  fprintf(stderr, "                         <InputMode>=1\n");
    1913   fprintf(stderr,
    1914       "       -b <BaudRate>     Serial input baud rate, default: 19200 bps, mandatory\n");
     1960  fprintf(stderr, "       -b <BaudRate>     Serial input baud rate, default: 19200 bps, mandatory\n");
    19151961  fprintf(stderr, "                         if <InputMode>=1\n");
    1916   fprintf(stderr,
    1917       "       -f <InitFile>     Name of initialization file to be send to input device,\n");
     1962  fprintf(stderr, "       -f <InitFile>     Name of initialization file to be send to input device,\n");
    19181963  fprintf(stderr, "                         optional\n\n");
    19191964  fprintf(stderr, "       <InputMode> = 2|5 (IP port | UDP port):\n");
    1920   fprintf(stderr,
    1921       "       -H <ServerHost>   Input host name or address, default: 127.0.0.1,\n");
     1965  fprintf(stderr, "       -H <ServerHost>   Input host name or address, default: 127.0.0.1,\n");
    19221966  fprintf(stderr, "                         mandatory if <InputMode> = 2|5\n");
    1923   fprintf(stderr,
    1924       "       -P <ServerPort>   Input port, default: 1025, mandatory if <InputMode>= 2|5\n");
    1925   fprintf(stderr,
    1926       "       -f <ServerFile>   Name of initialization file to be send to server,\n");
     1967  fprintf(stderr, "       -P <ServerPort>   Input port, default: 1025, mandatory if <InputMode>= 2|5\n");
     1968  fprintf(stderr, "       -f <ServerFile>   Name of initialization file to be send to server,\n");
    19271969  fprintf(stderr, "                         optional\n");
    1928   fprintf(stderr,
    1929       "       -x <ServerUser>   User ID to access incoming stream, optional\n");
    1930   fprintf(stderr,
    1931       "       -y <ServerPass>   Password, to access incoming stream, optional\n");
    1932   fprintf(stderr,
    1933       "       -B                Bind to incoming UDP stream, optional for <InputMode> = 5\n\n");
     1970  fprintf(stderr, "       -x <ServerUser>   User ID to access incoming stream, optional\n");
     1971  fprintf(stderr, "       -y <ServerPass>   Password, to access incoming stream, optional\n");
     1972  fprintf(stderr, "       -B                Bind to incoming UDP stream, optional for <InputMode> = 5\n\n");
    19341973  fprintf(stderr, "       <InputMode> = 3 (File):\n");
    1935   fprintf(stderr,
    1936       "       -s <File>         File name to simulate stream by reading data from (log)\n");
    1937   fprintf(stderr,
    1938       "                         file, default is %s, mandatory for <InputMode> = 3\n\n",
    1939       filepath);
     1974  fprintf(stderr, "       -s <File>         File name to simulate stream by reading data from (log)\n");
     1975  fprintf(stderr, "                         file, default is %s, mandatory for <InputMode> = 3\n\n",  filepath);
    19401976  fprintf(stderr, "       <InputMode> = 4 (SISNeT Data Server):\n");
    1941   fprintf(stderr,
    1942       "       -H <SisnetHost>   SISNeT Data Server name or address,\n");
    1943   fprintf(stderr,
    1944       "                         default: 131.176.49.142, mandatory if <InputMode> = 4\n");
    1945   fprintf(stderr,
    1946       "       -P <SisnetPort>   SISNeT Data Server port, default: 7777, mandatory if\n");
     1977  fprintf(stderr, "       -H <SisnetHost>   SISNeT Data Server name or address,\n");
     1978  fprintf(stderr, "                         default: 131.176.49.142, mandatory if <InputMode> = 4\n");
     1979  fprintf(stderr, "       -P <SisnetPort>   SISNeT Data Server port, default: 7777, mandatory if\n");
    19471980  fprintf(stderr, "                         <InputMode> = 4\n");
    1948   fprintf(stderr,
    1949       "       -u <SisnetUser>   SISNeT Data Server user ID, mandatory if <InputMode> = 4\n");
    1950   fprintf(stderr,
    1951       "       -l <SisnetPass>   SISNeT Data Server password, mandatory if <InputMode> = 4\n");
    1952   fprintf(stderr,
    1953       "       -V <SisnetVers>   SISNeT Data Server Version number, options are 2.1, 3.0\n");
    1954   fprintf(stderr,
    1955       "                         or 3.1, default: 3.1, mandatory if <InputMode> = 4\n\n");
    1956   fprintf(stderr, "       <InputMode> = 6 (NTRIP Version 1.0 Caster):\n");
    1957   fprintf(stderr,
    1958       "       -H <SourceHost>   Source caster name or address, default: 127.0.0.1,\n");
    1959   fprintf(stderr, "                         mandatory if <InputMode> = 6\n");
    1960   fprintf(stderr,
    1961       "       -P <SourcePort>   Source caster port, default: 2101, mandatory if\n");
    1962   fprintf(stderr, "                         <InputMode> = 6\n");
    1963   fprintf(stderr,
    1964       "       -D <SourceMount>  Source caster mountpoint for stream input, mandatory if\n");
     1981  fprintf(stderr, "       -u <SisnetUser>   SISNeT Data Server user ID, mandatory if <InputMode> = 4\n");
     1982  fprintf(stderr, "       -l <SisnetPass>   SISNeT Data Server password, mandatory if <InputMode> = 4\n");
     1983  fprintf(stderr, "       -V <SisnetVers>   SISNeT Data Server Version number, options are 2.1, 3.0\n");
     1984  fprintf(stderr, "                         or 3.1, default: 3.1, mandatory if <InputMode> = 4\n\n");
     1985  fprintf(stderr, "       <InputMode> = 6|7 (NTRIP Version 1.0|2.0 Caster):\n");
     1986  fprintf(stderr, "       -H <SourceHost>   Source caster name or address, default: 127.0.0.1,\n");
     1987  fprintf(stderr, "                         mandatory if <InputMode> = 6|7\n");
     1988  fprintf(stderr, "       -P <SourcePort>   Source caster port, default: 2101, mandatory if\n");
    19651989  fprintf(stderr, "                         <InputMode> = 6|7\n");
    1966   fprintf(stderr,
    1967       "       -U <SourceUser>   Source caster user Id for input stream access, mandatory\n");
    1968   fprintf(stderr,
    1969       "                         for protected streams if <InputMode> = 6|7\n");
    1970   fprintf(stderr,
    1971       "       -W <SourcePass>   Source caster password for input stream access, mandatory\n");
    1972   fprintf(stderr,
    1973       "                         for protected streams if <InputMode> = 6|7\n\n");
    1974   fprintf(stderr,
    1975       "    -O <OutputMode> Sets output mode for communication with destination caster / server\n");
    1976   fprintf(stderr,
    1977       "       1 = http:   NTRIP Version 2.0 Caster in TCP/IP mode\n");
    1978   fprintf(stderr,
    1979       "       2 = rtsp:   NTRIP Version 2.0 Caster in RTSP/RTP mode\n");
     1990  fprintf(stderr, "       -D <SourceMount>  Source caster mountpoint for stream input, mandatory if\n");
     1991  fprintf(stderr, "                         <InputMode> = 6|7\n");
     1992  fprintf(stderr, "       -U <SourceUser>   Source caster user Id for input stream access, mandatory\n");
     1993  fprintf(stderr, "                         for protected streams if <InputMode> = 6|7\n");
     1994  fprintf(stderr, "       -W <SourcePass>   Source caster password for input stream access, mandatory\n");
     1995  fprintf(stderr, "                         for protected streams if <InputMode> = 6|7\n\n");
     1996  fprintf(stderr, "    -O <OutputMode> Sets output mode for communication with destination caster / server\n");
     1997  fprintf(stderr, "       1 = http:   NTRIP Version 2.0 Caster in TCP/IP mode\n");
     1998  fprintf(stderr, "       2 = rtsp:   NTRIP Version 2.0 Caster in RTSP/RTP mode\n");
    19801999  fprintf(stderr, "       3 = ntrip1: NTRIP Version 1.0 Caster\n");
    1981   fprintf(stderr,
    1982       "       4 = udp:    NTRIP Version 2.0 Caster in Plain UDP mode\n");
    1983   fprintf(stderr,
    1984       "       5 = tdc:    DABPLUS Content Server in TDC mode\n\n\n");
    1985   fprintf(stderr,
    1986       "       Defaults to NTRIP1.0, but will change to 2.0 in future versions\n");
    1987   fprintf(stderr,
    1988       "       Note that the program automatically falls back from mode rtsp to mode http and\n");
     2000  fprintf(stderr, "       4 = udp:    NTRIP Version 2.0 Caster in Plain UDP mode\n");
     2001  fprintf(stderr, "       5 = tdc:    DABPLUS Content Server in TDC mode\n\n\n");
     2002  fprintf(stderr, "       Defaults to NTRIP1.0, but will change to 2.0 in future versions\n");
     2003  fprintf(stderr, "       Note that the program automatically falls back from mode rtsp to mode http and\n");
    19892004  fprintf(stderr, "       further to mode ntrip1 if necessary.\n\n");
    1990   fprintf(stderr,
    1991       "       -a <DestHost>     Destination caster name or address, default: 127.0.0.1,\n");
     2005  fprintf(stderr, "       -a <DestHost>     Destination caster name or address, default: 127.0.0.1,\n");
    19922006  fprintf(stderr, "                         mandatory\n");
    1993   fprintf(stderr,
    1994       "       -p <DestPort>     Destination caster port, default: 2101,\n");
     2007  fprintf(stderr, "       -p <DestPort>     Destination caster port, default: 2101,\n");
    19952008  fprintf(stderr, "                         mandatory\n");
    1996   fprintf(stderr,
    1997       "       -m <DestMount>    Destination caster mountpoint for stream upload,\n");
    1998   fprintf(stderr,
    1999       "                         only for NTRIP destination casters, mandatory\n");
    2000   fprintf(stderr,
    2001       "       -n <DestUser>     Destination caster user ID for stream upload to mountpoint,\n");
    2002   fprintf(stderr,
    2003       "                         only for NTRIP Version 2.0 destination casters, mandatory\n");
    2004   fprintf(stderr,
    2005       "       -c <DestPass>     Destination caster password for stream upload to mountpoint,\n");
    2006   fprintf(stderr,
    2007       "                         only for NTRIP destination casters, mandatory\n");
     2009  fprintf(stderr, "       -m <DestMount>    Destination caster mountpoint for stream upload,\n");
     2010  fprintf(stderr, "                         only for NTRIP destination casters, mandatory\n");
     2011  fprintf(stderr, "       -n <DestUser>     Destination caster user ID for stream upload to mountpoint,\n");
     2012  fprintf(stderr, "                         only for NTRIP Version 2.0 destination casters, mandatory\n");
     2013  fprintf(stderr, "       -c <DestPass>     Destination caster password for stream upload to mountpoint,\n");
     2014  fprintf(stderr, "                         only for NTRIP destination casters, mandatory\n");
    20082015  fprintf(stderr, "       -N <STR-record>   Sourcetable STR-record\n");
    2009   fprintf(stderr,
    2010       "                         optional for NTRIP Version 2.0 in RTSP/RTP and TCP/IP mode\n\n");
     2016  fprintf(stderr, "                         optional for NTRIP Version 2.0 in RTSP/RTP and TCP/IP mode\n\n");
     2017  fprintf(stderr, "       -T <DAB+provider> DAB+ provider name, not longer than 16 char, mandatory for \n");
     2018  fprintf(stderr, "                         upload to DABPLUS Content Server in TDC mode\n");
    20112019  exit(rc);
    20122020} /* usage */
     
    21302138  else {
    21312139    fprintf(stderr, "\nDestination caster request:\n");
    2132     fprintf(stderr, "%s", input);
     2140    fprintf(stderr, "%s\n", input);
    21332141  }
    21342142#endif
Note: See TracChangeset for help on using the changeset viewer.