- Timestamp:
- Jun 6, 2007, 4:56:59 PM (18 years ago)
- Location:
- trunk/ntripserver
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/ntripserver/NtripLinuxServer.c ¶
r467 r469 1 1 /* 2 * $Id: NtripLinuxServer.c,v 1.2 8 2007/06/06 09:44:27stoecker Exp $2 * $Id: NtripLinuxServer.c,v 1.29 2007/06/06 12:16:08 stoecker Exp $ 3 3 * 4 4 * Copyright (c) 2003...2007 … … 37 37 38 38 /* CVS revision and version */ 39 static char revisionstr[] = "$Revision: 1.2 8$";40 static char datestr[] = "$Date: 2007/06/06 09:44:27$";39 static char revisionstr[] = "$Revision: 1.29 $"; 40 static char datestr[] = "$Date: 2007/06/06 12:16:08 $"; 41 41 42 42 #include <ctype.h> … … 71 71 CASTER = 6, LAST }; 72 72 73 enum OUTMODE { NTRIPV1, HTTP, RTSP, END };73 enum OUTMODE { HTTP = 1, RTSP = 2, NTRIPV1 = 3, END }; 74 74 75 75 #define AGENTSTRING "NTRIP NtripServerLinux" … … 180 180 181 181 /*** OUTPUT ***/ 182 const char * casterouthost = 0;183 unsigned int casteroutport = 0;182 const char * casterouthost = NTRIP_CASTER; 183 unsigned int casteroutport = NTRIP_PORT; 184 184 const char * outhost = 0; 185 185 unsigned int outport = 0; … … 352 352 proxyport = atoi(optarg); 353 353 break; 354 case 'O': /* OutputMode - default: Ntrip-Version 2.0 TCP/IP */ 355 if (!strcmp(optarg,"f")) outputmode = NTRIPV1; 356 else if(!strcmp(optarg,"r")) outputmode = RTSP; 354 case 'O': /* OutputMode */ 355 outputmode = 0; 356 if (!strcmp(optarg,"n") || !strcmp(optarg,"ntrip1")) 357 outputmode = NTRIPV1; 358 else if(!strcmp(optarg,"h") || !strcmp(optarg,"http")) 359 outputmode = HTTP; 360 else if(!strcmp(optarg,"r") || !strcmp(optarg,"rtsp")) 361 outputmode = RTSP; 362 else outputmode = atoi(optarg); 363 if((outputmode == 0) || (outputmode >= END)) 364 { 365 fprintf(stderr, "ERROR: can't convert <%s> to a valid OutputMode\n", 366 optarg); 367 usage(-1, argv[0]); 368 } 357 369 break; 358 370 case 'n': /* Destination caster user ID for stream upload to mountpoint */ … … 504 516 { 505 517 if(!inport) inport = SERV_TCP_PORT; 506 if(!inhost) inhost = "127.0.0.1";518 if(!inhost) inhost = SERV_HOST_ADDR; 507 519 } 508 520 … … 765 777 766 778 /* connect to Destination caster or Proxy server*/ 767 fprintf(stderr, "caster output: host = %s, port = %d, mountpoint = %s\n", 768 inet_ntoa(caster.sin_addr), outport, mountpoint); 779 fprintf(stderr, "caster output: host = %s, port = %d, mountpoint = %s" 780 ", mode = %s\n", inet_ntoa(caster.sin_addr), outport, mountpoint, 781 outputmode == NTRIPV1 ? "ntrip1" : outputmode == HTTP ? "http" : "rtsp"); 769 782 770 783 if(connect(socket_tcp, (struct sockaddr *) &caster, sizeof(caster)) < 0) … … 810 823 break; 811 824 } 825 #ifndef NDEBUG 812 826 else 813 827 { … … 816 830 szSendBuffer); 817 831 } 832 #endif 818 833 send_receive_loop(socket_tcp, gpsfd, outputmode, NULL, 0); 819 834 break; … … 823 838 "Host: %s\r\n" 824 839 "Ntrip-Version: Ntrip/2.0\r\n" 825 "User-Agent: NTRIP%s\r\n"840 "User-Agent: %s/%s\r\n" 826 841 "Authorization: Basic %s\r\n" 827 842 "Ntrip-STR: %s\r\n" 828 843 "Transfer-Encoding: chunked\r\n\r\n", 829 844 post_extension, mountpoint, casterouthost, AGENTSTRING, 830 authorization, ntrip_str);845 revisionstr, authorization, ntrip_str); 831 846 if((nBufferBytes > (int)sizeof(szSendBuffer)) || (nBufferBytes < 0)) 832 847 { … … 847 862 char *a; 848 863 fprintf(stderr, 849 "ERROR: Destination caster's or Proxy's reply is not OK: "); 864 "ERROR: Destination caster's%s reply is not OK: ", 865 *proxyhost ? " or Proxy's" : ""); 850 866 for(a = szSendBuffer; *a && *a != '\n' && *a != '\r'; ++a) 851 867 { … … 857 873 { 858 874 fprintf(stderr, 859 " -Ntrip Version 2.0 not implemented at Destination caster"860 " <%s> or Proxy <%s> or\n"861 " - HTTP/1.1 not implemented at Proxy or\n"862 " - RTSP/1.0 not implemented at Destination caster or Proxy\n\n"863 "caster fallback: Fallback to Ntrip Version 1.0\n\n",864 casterouthost, proxyhost);875 " Ntrip Version 2.0 not implemented at Destination caster" 876 " <%s>%s%s%s\n%s\n" 877 "caster fallback: Fallback to Ntrip Version 1.0\n", 878 casterouthost, 879 *proxyhost ? " or Proxy <" : "", proxyhost, *proxyhost ? ">" : "", 880 *proxyhost ? " or HTTP/1.1 not implemented at Proxy\n" : ""); 865 881 outputmode = NTRIPV1; 866 882 break; … … 910 926 "Ntrip-Version: Ntrip/2.0\r\n" 911 927 "Ntrip-Component: Ntripserver\r\n" 912 "User-Agent: NTRIP %s\r\n"928 "User-Agent: %s/%s\r\n" 913 929 "Transport: RTP/GNSS;unicast;client_port=%u\r\n" 914 930 "Authorization: Basic %s\r\n" 915 931 "Ntrip-STR: %s\r\n\r\n", 916 casterouthost, rtsp_extension, mountpoint, AGENTSTRING, client_port,917 authorization, ntrip_str);932 casterouthost, rtsp_extension, mountpoint, AGENTSTRING, revisionstr, 933 client_port, authorization, ntrip_str); 918 934 if((nBufferBytes > (int)sizeof(szSendBuffer)) || (nBufferBytes < 0)) 919 935 { … … 936 952 char *a; 937 953 fprintf(stderr, 938 "ERROR: Destination caster's or Proxy's reply is not OK: "); 954 "ERROR: Destination caster's%s reply is not OK: ", 955 *proxyhost ? " or Proxy's" : ""); 939 956 for(a = szSendBuffer; *a && *a != '\n' && *a != '\r'; ++a) 940 957 { … … 948 965 { 949 966 fprintf(stderr, 950 " - RTSP not implemented at Destination caster <%s> or" 951 " Proxy <%s>\n\n" 967 " - RTSP not implemented at Destination caster <%s>%s%s%s\n\n" 952 968 "caster fallback: Fallback to Ntrip Version 2.0 in TCP/IP" 953 " mode\n\n", casterouthost, proxyhost); 969 " mode\n\n", casterouthost, 970 *proxyhost ? " or Proxy <" :"", proxyhost, *proxyhost ? ">":""); 954 971 outputmode = HTTP; 955 972 break; … … 958 975 { 959 976 fprintf(stderr, 960 " - Ntrip-Version 2.0 not implemented at Destination caster" 961 "<%s> or Proxy <%s> or\n" 962 " - HTTP/1.1 not implemented at Proxy or\n" 963 " - RTSP/1.0 not implemented at Destination caster or Proxy\n\n" 964 "caster fallback: Fallback to Ntrip Version 1.0\n\n", 965 casterouthost, proxyhost); 977 " Ntrip-Version 2.0 not implemented at Destination caster" 978 "<%s>%s%s%s\n%s" 979 " or RTSP/1.0 not implemented at Destination caster%s\n\n" 980 "caster fallback: Fallback to Ntrip Version 1.0\n", 981 casterouthost, *proxyhost ? " or Proxy <" :"", proxyhost, 982 *proxyhost ? ">":"", 983 *proxyhost ? " or HTTP/1.1 not implemented at Proxy\n" : "", 984 *proxyhost ? " or Proxy" :""); 966 985 outputmode = NTRIPV1; 967 986 break; … … 974 993 } 975 994 } 995 #ifndef NDEBUG 976 996 else 977 997 { 978 998 fprintf(stderr, "Destination caster response:\n%s\n",szSendBuffer); 979 999 } 1000 #endif 980 1001 if((strstr(szSendBuffer,"RTSP/1.0 200 OK\r\n")) 981 1002 && (strstr(szSendBuffer,"CSeq: 1\r\n"))) … … 1175 1196 if(signal_was_caught()) 1176 1197 { 1177 fprintf(stderr, "NtripLinuxServer exits send-receive mode 1198 fprintf(stderr, "NtripLinuxServer exits send-receive mode\n"); 1178 1199 break; 1179 1200 } … … 1440 1461 fprintf(stderr, " -W <SourcePass> Source caster password for input stream access, mandatory\n"); 1441 1462 fprintf(stderr, " for protected streams if <InputMode> = 6\n\n"); 1442 fprintf(stderr, " -O <OutputMode> Sets the output mode for communatation with the destination\n"); 1443 fprintf(stderr, " caster (r = NTRIP Version 2.0 Caster in RTSP/RTP mode, t = Ntrip Version 2.0\n"); 1444 fprintf(stderr, " Caster in TCP/IP mode, f = NTRIP Version 1.0 Caster)\n\n"); 1463 fprintf(stderr, " -O <OutputMode> Sets output mode for communatation with destination caster\n"); 1464 fprintf(stderr, " 0 = h = http: Ntrip Version 2.0 Caster in TCP/IP mode\n"); 1465 fprintf(stderr, " 1 = r = rtsp: NTRIP Version 2.0 Caster in RTSP/RTP mode\n"); 1466 fprintf(stderr, " 2 = n = ntrip1: NTRIP Version 1.0 Caster\n\n"); 1445 1467 fprintf(stderr, " Defaults to NTRIP1.0, but wil change to 2.0 in future versions\n"); 1446 1468 fprintf(stderr, " Note that the program automatically falls back from mode r to mode t and\n"); … … 1492 1514 fflush(stdout); 1493 1515 if(sigint_received) 1494 fprintf(stderr, " \nSIGINT received: ");1516 fprintf(stderr, "SIGINT received: "); 1495 1517 1496 1518 return (sigint_received); … … 1556 1578 static int send_to_caster(char *input, int socket, int input_size) 1557 1579 { 1558 int send_error = 1;1580 int send_error = 1; 1559 1581 1560 1582 if((send(socket, input, (size_t)input_size, 0)) != input_size) … … 1562 1584 fprintf(stderr, "ERROR: could not send full header to Destination caster\n"); 1563 1585 send_error = 0; 1564 }else{ 1586 } 1587 #ifndef NDEBUG 1588 else 1589 { 1565 1590 fprintf(stderr, "\nDestination caster request:\n"); 1566 1591 fprintf(stderr, "%s", input); 1567 1592 } 1593 #endif 1568 1594 return send_error; 1569 1595 }/* send_to_caster */ … … 1587 1613 exit(0); 1588 1614 } 1615 #ifndef NDEBUG 1589 1616 else 1590 1617 { 1591 1618 fprintf(stderr, "\nclose input device: successful\n"); 1592 1619 } 1620 #endif 1593 1621 } 1594 1622 … … 1611 1639 size_send_buf = recv(sock_tcp, send_buf, sizeof(send_buf), 0); 1612 1640 send_buf[size_send_buf] = '\0'; 1641 #ifndef NDEBUG 1613 1642 fprintf(stderr, "Destination caster response:\n%s", send_buf); 1643 #endif 1614 1644 } 1615 1645 if(close(sock_udp)==-1) … … 1618 1648 exit(0); 1619 1649 } 1650 #ifndef NDEBUG 1620 1651 else 1621 1652 { 1622 1653 fprintf(stderr, "close udp socket: successful\n"); 1623 1654 } 1655 #endif 1624 1656 } 1625 1657 … … 1629 1661 exit(0); 1630 1662 } 1663 #ifndef NDEBUG 1631 1664 else 1632 1665 { 1633 1666 fprintf(stderr, "close tcp socket: successful\n\n"); 1634 1667 } 1668 #endif 1635 1669 } /* close_session */ -
TabularUnified trunk/ntripserver/makefile ¶
r468 r469 2 2 3 3 NtripServerLinux: NtripLinuxServer.c 4 $(CC) -Wall -W -O3 $? -o $@ 4 $(CC) -Wall -W -O3 $? -DNDEBUG -o $@ 5 6 debug: NtripLinuxServer.c 7 $(CC) -Wall -W -O3 $? -o NtripServerLinux 5 8 6 9 clean:
Note:
See TracChangeset
for help on using the changeset viewer.