Changeset 9403 in ntrip for trunk/ntripserver
- Timestamp:
- Apr 13, 2021, 4:53:54 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ntripserver/ntripserver.c
r9402 r9403 120 120 #define NTRIP_PORT 2101 121 121 122 #define DABPLUS_SERVER "62.225.182.198"123 #define DABPLUS_PORT 10000124 125 122 #define SISNET_SERVER "131.176.49.142" 126 123 #define SISNET_PORT 7777 … … 233 230 const char *ntrip_str = ""; 234 231 232 const char *dabplus_provider = 0; 233 char dabplus_provider_str[17] = ""; 234 235 235 const char *user = ""; 236 236 const char *password = ""; … … 296 296 } 297 297 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) { 299 299 switch (c) { 300 300 case 'M': /*** InputMode ***/ … … 438 438 ntrip_str = optarg; 439 439 break; 440 case 'T': 441 dabplus_provider = optarg; 442 break; 440 443 case 'h': /* print help screen */ 441 444 case '?': … … 474 477 475 478 if (outputmode == TDC) { 479 fprintf(stderr, "ERROR: DABPLUS server upload implementation is so far not completed\n\n"); 480 exit(0); 481 476 482 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); 482 493 } 483 494 } … … 499 510 500 511 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"); 503 513 } 504 514 505 515 /*** proxy server handling ***/ 506 516 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 } 509 527 i = snprintf(szSendBuffer, sizeof(szSendBuffer), "http://%s:%d", casterouthost, casteroutport); 510 528 if ((i > SZ) || (i < 0)) { … … 530 548 strcpy(szSendBuffer, ""); 531 549 i = 0; 532 fprintf(stdout, "%s",get_extension);533 550 } 534 551 } else { … … 711 728 szSendBuffer[nBufferBytes++] = '\r'; 712 729 szSendBuffer[nBufferBytes++] = '\n'; 713 fprintf(stdout, "%s", szSendBuffer);730 // fprintf(stdout, "%s\n", szSendBuffer); 714 731 if ((send(gps_socket, szSendBuffer, (size_t) nBufferBytes, 0)) != nBufferBytes) { 715 732 fprintf(stderr, "WARNING: could not send Source caster request\n"); … … 883 900 if((sigalarm_received) || (sigint_received)) break; 884 901 #endif 902 885 903 if (!(he = gethostbyname(outhost))) { 886 904 fprintf(stderr, … … 889 907 close_session(casterouthost, mountpoint, session, rtsp_extension, 0); 890 908 usage(-2, argv[0]); 891 } 909 }else {fprintf(stderr, 910 "Destination caster, server or proxy host <%s> \n", 911 outhost);} 892 912 893 913 /* create socket */ … … 904 924 905 925 /* 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" 907 927 ", 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"); 910 932 911 933 if (connect(socket_tcp, (struct sockaddr*) &caster, sizeof(caster)) < 0) { … … 1065 1087 } 1066 1088 /* check Destination caster's response */ 1067 nBufferBytes = recv(socket_tcp, szSendBuffer, sizeof(szSendBuffer), 1068 0); 1089 nBufferBytes = recv(socket_tcp, szSendBuffer, sizeof(szSendBuffer), 0); 1069 1090 szSendBuffer[nBufferBytes] = '\0'; 1070 1091 if (!strstr(szSendBuffer, "OK")) { … … 1307 1328 break; 1308 1329 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; 1309 1354 break; 1310 1355 } … … 1409 1454 } 1410 1455 } 1411 /*** receiving data ****/ 1456 /***********************/ 1457 /* receiving data */ 1458 /***********************/ 1459 1460 /* INFILE */ 1412 1461 if (inputmode == INFILE) 1413 1462 nBufferBytes = read(gps_file, buffer, sizeof(buffer)); 1463 1464 /* SERIAL */ 1414 1465 else if (inputmode == SERIAL) { 1415 1466 #ifndef WINDOWSVERSION … … 1425 1476 #endif 1426 1477 } 1478 1479 /* ALL OTHER MODES */ 1427 1480 else 1428 1481 #ifdef WINDOWSVERSION … … 1523 1576 } 1524 1577 } 1525 /** send data ***/ 1526 if ((nBufferBytes) && (outmode == NTRIP1)) /*** Ntrip-Version 1.0 ***/ 1527 { 1578 1579 /*****************/ 1580 /* send data */ 1581 /*****************/ 1582 if ((nBufferBytes) && (outmode == NTRIP1)) { 1528 1583 int i; 1529 1584 if ((i = send(sock, buffer, (size_t) nBufferBytes, MSG_DONTWAIT)) != nBufferBytes) { … … 1694 1749 return; 1695 1750 } 1751 } 1752 else if ((nBufferBytes) && (outmode == TDC)) { 1753 1696 1754 } 1697 1755 if (send_recv_success == 3) … … 1882 1940 " and forward that incoming stream (Output, Destination) to either\n\n"); 1883 1941 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"); 1886 1943 fprintf(stderr, " - an DABPLUS Content Server via TCP/IP and TDC \n\n\n"); 1887 1944 fprintf(stderr, "OPTIONS\n"); 1888 1945 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"); 1893 1948 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"); 1902 1953 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"); 1907 1956 fprintf(stderr, " mandatory\n\n"); 1908 1957 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); 1912 1959 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"); 1915 1961 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"); 1918 1963 fprintf(stderr, " optional\n\n"); 1919 1964 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"); 1922 1966 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"); 1927 1969 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"); 1934 1973 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); 1940 1976 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"); 1947 1980 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"); 1965 1989 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"); 1980 1999 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"); 1989 2004 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"); 1992 2006 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"); 1995 2008 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"); 2008 2015 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"); 2011 2019 exit(rc); 2012 2020 } /* usage */ … … 2130 2138 else { 2131 2139 fprintf(stderr, "\nDestination caster request:\n"); 2132 fprintf(stderr, "%s ", input);2140 fprintf(stderr, "%s\n", input); 2133 2141 } 2134 2142 #endif
Note:
See TracChangeset
for help on using the changeset viewer.