Changeset 915 in ntrip for trunk/ntripserver
- Timestamp:
- May 16, 2008, 9:33:31 AM (17 years ago)
- Location:
- trunk/ntripserver
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ntripserver
- Property svn:ignore
--- +++ @@ -1,2 +1,2 @@ -NtripServerLinux -NtripServerLinux.zip +ntripserver +ntripserver.tgz
- Property svn:ignore
-
trunk/ntripserver/.cvsignore
r470 r915 1 NtripServerLinux 2 NtripServerLinux.zip 1 ntripserver 2 ntripserver.tgz -
trunk/ntripserver/ntripserver.c
r768 r915 1 1 /* 2 * $Id: ntripserver.c,v 1. 392008/04/04 10:03:11 stoeckerExp $2 * $Id: ntripserver.c,v 1.40 2008/04/04 13:07:31 stuerze Exp $ 3 3 * 4 4 * Copyright (c) 2003...2007 … … 37 37 38 38 /* CVS revision and version */ 39 static char revisionstr[] = "$Revision: 1. 39$";40 static char datestr[] = "$Date: 2008/04/04 1 0:03:11 $";39 static char revisionstr[] = "$Revision: 1.40 $"; 40 static char datestr[] = "$Date: 2008/04/04 13:07:31 $"; 41 41 42 42 #include <ctype.h> … … 128 128 static int sigint_received = 0; 129 129 static int reconnect_sec = 1; 130 130 static const char * casterouthost = NTRIP_CASTER; 131 static char rtsp_extension[SZ] = ""; 132 static const char * mountpoint = NULL; 133 static int udp_cseq = 1; 131 134 132 135 /* Forward references */ … … 136 139 static int encode(char *buf, int size, const char *user, const char *pwd); 137 140 static int send_to_caster(char *input, sockettype socket, int input_size); 138 static void close_session(const char *caster_addr, const char *mountpoint, 139 int cseq, intsession, char *rtsp_ext, int fallback);141 static void close_session(const char *caster_addr, const char *mountpoint, 142 int session, char *rtsp_ext, int fallback); 140 143 static int reconnect(int rec_sec, int rec_sec_max); 141 144 static void handle_sigint(int sig); … … 184 187 185 188 struct hostent * he; 186 const char * mountpoint = NULL;187 189 188 190 const char * sisnetpassword = ""; … … 201 203 202 204 /*** OUTPUT ***/ 203 const char * casterouthost = NTRIP_CASTER;204 205 unsigned int casteroutport = NTRIP_PORT; 205 206 const char * outhost = 0; 206 207 unsigned int outport = 0; 207 208 char post_extension[SZ] = ""; 208 char rtsp_extension[SZ] = ""; 209 210 const char * ntrip_str = ""; 209 210 const char * ntrip_str = 0; 211 211 212 212 const char * user = ""; … … 220 220 int server_port = 0; 221 221 int session = 0; 222 int cseq = 0;223 222 socklen_t len = 0; 224 223 int i = 0; … … 443 442 } 444 443 445 if( *ntrip_str && (outputmode == NTRIP1))444 if(ntrip_str && (outputmode == NTRIP1)) 446 445 { 447 446 fprintf(stderr, "WARNING: OutputMode is Ntrip version 1.0" … … 849 848 fprintf(stderr, "ERROR: Destination caster or proxy host <%s> unknown\n", 850 849 outhost); 851 close_session(casterouthost, mountpoint, cseq,session, rtsp_extension, 0);850 close_session(casterouthost, mountpoint, session, rtsp_extension, 0); 852 851 usage(-2, argv[0]); 853 852 } … … 933 932 "Ntrip-Version: Ntrip/2.0\r\n" 934 933 "User-Agent: %s/%s\r\n" 935 "Authorization: Basic %s\r\n" 936 "Ntrip-STR: %s\r\n" 934 "Authorization: Basic %s%s%s\r\n" 937 935 "Connection: close\r\n" 938 936 "Transfer-Encoding: chunked\r\n\r\n", 939 937 post_extension, mountpoint, casterouthost, AGENTSTRING, 940 revisionstr, authorization, ntrip_str); 938 revisionstr, authorization, ntrip_str ? "\r\nNtrip-STR: " : "", 939 ntrip_str); 941 940 if((nBufferBytes > (int)sizeof(szSendBuffer)) || (nBufferBytes < 0)) 942 941 { … … 975 974 *proxyhost ? " or Proxy <" : "", proxyhost, *proxyhost ? ">" : "", 976 975 *proxyhost ? " or HTTP/1.1 not implemented at Proxy\n" : ""); 977 close_session(casterouthost, mountpoint, cseq,session, rtsp_extension, 1);976 close_session(casterouthost, mountpoint, session, rtsp_extension, 1); 978 977 outputmode = NTRIP1; 979 978 break; … … 1029 1028 nBufferBytes = snprintf(szSendBuffer, sizeof(szSendBuffer), 1030 1029 "SETUP rtsp://%s%s/%s RTSP/1.0\r\n" 1031 "CSeq: 1\r\n"1030 "CSeq: %d\r\n" 1032 1031 "Ntrip-Version: Ntrip/2.0\r\n" 1033 1032 "Ntrip-Component: Ntripserver\r\n" 1034 1033 "User-Agent: %s/%s\r\n" 1035 1034 "Transport: RTP/GNSS;unicast;client_port=%u\r\n" 1036 "Authorization: Basic %s \r\n"1037 "Ntrip-STR: %s\r\n\r\n",1038 casterouthost, rtsp_extension, mountpoint, AGENTSTRING,revisionstr,1039 client_port, authorization, ntrip_str);1035 "Authorization: Basic %s%s%s\r\n\r\n", 1036 casterouthost, rtsp_extension, mountpoint, udp_cseq++, AGENTSTRING, 1037 revisionstr, client_port, authorization, ntrip_str 1038 ? "\r\nNtrip-STR: " : "", ntrip_str); 1040 1039 if((nBufferBytes > (int)sizeof(szSendBuffer)) || (nBufferBytes < 0)) 1041 1040 { … … 1076 1075 " mode\n\n", casterouthost, 1077 1076 *proxyhost ? " or Proxy <" :"", proxyhost, *proxyhost ? ">":""); 1078 close_session(casterouthost, mountpoint, cseq,session, rtsp_extension, 1);1077 close_session(casterouthost, mountpoint, session, rtsp_extension, 1); 1079 1078 outputmode = HTTP; 1080 1079 break; … … 1091 1090 *proxyhost ? " or HTTP/1.1 not implemented at Proxy\n" : "", 1092 1091 *proxyhost ? " or Proxy" :""); 1093 close_session(casterouthost, mountpoint, cseq,session, rtsp_extension, 1);1092 close_session(casterouthost, mountpoint, session, rtsp_extension, 1); 1094 1093 outputmode = NTRIP1; 1095 1094 break; … … 1122 1121 nBufferBytes = snprintf(szSendBuffer, sizeof(szSendBuffer), 1123 1122 "RECORD rtsp://%s%s/%s RTSP/1.0\r\n" 1124 "CSeq: 2\r\n"1123 "CSeq: %d\r\n" 1125 1124 "Session: %d\r\n" 1126 1125 "\r\n", 1127 casterouthost, rtsp_extension, mountpoint, session); 1126 casterouthost, rtsp_extension, mountpoint, udp_cseq++, 1127 session); 1128 1128 if((nBufferBytes >= (int)sizeof(szSendBuffer)) 1129 1129 || (nBufferBytes < 0)) … … 1159 1159 he->h_addr_list[0], (size_t)he->h_length); 1160 1160 } 1161 cseq = 2;1162 1161 len = (socklen_t)sizeof(casterRTP); 1163 1162 send_receive_loop(socket_udp, outputmode, (struct sockaddr *)&casterRTP, … … 1171 1170 } 1172 1171 } 1173 close_session(casterouthost, mountpoint, cseq,session, rtsp_extension, 0);1172 close_session(casterouthost, mountpoint, session, rtsp_extension, 0); 1174 1173 if((reconnect_sec_max) && (!sigint_received)) 1175 1174 reconnect_sec = reconnect(reconnect_sec, reconnect_sec_max); … … 1195 1194 int rtpseq = 0; 1196 1195 int rtptime = 0; 1196 time_t laststate = time(0); 1197 1198 if(outmode == RTSP) 1199 { 1200 #ifdef WINDOWSVERSION 1201 u_long blockmode = 1; 1202 if(ioctlsocket(socket_tcp, FIONBIO, &blockmode)) 1203 #else /* WINDOWSVERSION */ 1204 if(fcntl(socket_tcp, F_SETFL, O_NONBLOCK) < 0) 1205 #endif /* WINDOWSVERSION */ 1206 { 1207 fprintf(stderr, "Could not set nonblocking mode\n"); 1208 return; 1209 } 1210 } 1197 1211 1198 1212 /* data transmission */ … … 1355 1369 else if((nBufferBytes) && (outmode == RTSP)) 1356 1370 { 1371 time_t ct; 1372 int r; 1357 1373 char rtpbuffer[BUFSZ+12]; 1358 1374 int i, j; … … 1409 1425 { 1410 1426 nBufferBytes = 0; 1427 } 1428 ct = time(0); 1429 if(ct-laststate > 15) 1430 { 1431 i = snprintf(buffer, sizeof(buffer), 1432 "GET_PARAMETER rtsp://%s%s/%s RTSP/1.0\r\n" 1433 "CSeq: %d\r\n" 1434 "Session: %d\r\n" 1435 "\r\n", 1436 casterouthost, rtsp_extension, mountpoint, udp_cseq++, rtpseq); 1437 if(i > (int)sizeof(buffer) || i < 0) 1438 { 1439 fprintf(stderr, "Requested data too long\n"); 1440 return; 1441 } 1442 else if(send(socket_tcp, buffer, (size_t)i, 0) != i) 1443 { 1444 perror("send"); 1445 return; 1446 } 1447 laststate = ct; 1448 } 1449 /* ignore RTSP server replies */ 1450 if((r=recv(socket_tcp, buffer, sizeof(buffer), 0)) < 0) 1451 { 1452 #ifdef WINDOWSVERSION 1453 if(WSAGetLastError() != WSAEWOULDBLOCK) 1454 #else /* WINDOWSVERSION */ 1455 if(errno != EAGAIN) 1456 #endif /* WINDOWSVERSION */ 1457 { 1458 fprintf(stderr, "Control connection closed\n"); 1459 return; 1460 } 1461 } 1462 else if(!r) 1463 { 1464 fprintf(stderr, "Control connection read error\n"); 1465 return; 1411 1466 } 1412 1467 } … … 1891 1946 *********************************************************************/ 1892 1947 static void close_session(const char *caster_addr, const char *mountpoint, 1893 int cseq, intsession, char *rtsp_ext, int fallback)1948 int session, char *rtsp_ext, int fallback) 1894 1949 { 1895 1950 int size_send_buf; … … 1955 2010 } 1956 2011 1957 if(socket_udp 1958 { 1959 if( cseq ==2)2012 if(socket_udp != INVALID_SOCKET) 2013 { 2014 if(udp_cseq > 2) 1960 2015 { 1961 2016 size_send_buf = snprintf(send_buf, sizeof(send_buf), 1962 2017 "TEARDOWN rtsp://%s%s/%s RTSP/1.0\r\n" 1963 "CSeq: 2\r\n"2018 "CSeq: %d\r\n" 1964 2019 "Session: %d\r\n" 1965 2020 "\r\n", 1966 caster_addr, rtsp_ext, mountpoint, session); 2021 caster_addr, rtsp_ext, mountpoint, udp_cseq++, session); 1967 2022 if((size_send_buf >= (int)sizeof(send_buf)) || (size_send_buf < 0)) 1968 2023 {
Note:
See TracChangeset
for help on using the changeset viewer.