MRTKLIB 0.7.14
Modernized GNSS Positioning Library
Loading...
Searching...
No Matches
mrtk_stream.c File Reference
#include "mrtklib/mrtk_stream.h"
#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "mrtklib/mrtk_rcvraw.h"
#include "mrtklib/mrtk_sol.h"
#include "mrtklib/mrtk_sys.h"
#include "mrtklib/mrtk_time.h"
#include "mrtklib/mrtk_version.h"
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <errno.h>
#include <netdb.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <sys/socket.h>
#include <termios.h>
#include "mrtklib/mrtk_trace.h"
#include "ntrip_chunk.h"
Include dependency graph for mrtk_stream.c:

Go to the source code of this file.

Classes

struct  file_t
struct  tcp_t
struct  tcpsvr_tag
struct  tcpcli_t
struct  serial_t
struct  ntrip_t
struct  ntripc_con_t
struct  ntripc_t
struct  udp_t
struct  ftp_t
struct  membuf_t

Macros

#define __USE_MISC
#define CRTSCTS   020000000000
#define TINTACT   200 /* period for stream active (ms) */
#define SERIBUFFSIZE   4096 /* serial buffer size (bytes) */
#define TIMETAGH_LEN   64 /* time tag file header length */
#define MAXCLI   32 /* max client connection for tcp svr */
#define MAXSTATMSG   32 /* max length of status message */
#define DEFAULT_MEMBUF_SIZE   4096 /* default memory buffer size (bytes) */
#define NTRIP_AGENT   MRTKLIB_SOFTNAME "/" MRTKLIB_VERSION_STRING
#define NTRIP_CLI_PORT   2101 /* default ntrip-client connection port */
#define NTRIP_SVR_PORT   80 /* default ntrip-server connection port */
#define NTRIP_MAXRSP   32768 /* max size of ntrip response */
#define NTRIP_MAXSTR   256 /* max length of mountpoint string */
#define NTRIP_RSP_OK_CLI   "ICY 200 OK\r\n" /* ntrip response: client */
#define NTRIP_RSP_OK_SVR   "OK\r\n" /* ntrip response: server */
#define NTRIP_RSP_SRCTBL   "SOURCETABLE 200 OK\r\n" /* ntrip response: source table */
#define NTRIP_RSP_TBLEND   "ENDSOURCETABLE"
#define NTRIP_RSP_HTTP   "HTTP/" /* ntrip response: http */
#define NTRIP_RSP_ERROR   "ERROR" /* ntrip response: error */
#define NTRIP_RSP_UNAUTH   "HTTP/1.0 401 Unauthorized\r\n"
#define NTRIP_RSP_ERR_PWD   "ERROR - Bad Password\r\n"
#define NTRIP_RSP_ERR_MNTP   "ERROR - Bad Mountpoint\r\n"
#define FTP_CMD   "wget" /* ftp/http command */
#define FTP_TIMEOUT   30 /* ftp/http timeout (s) */
#define MIN(x, y)
#define dev_t   int
#define socket_t   int
#define closesocket   close
#define BUFADD(p, rem, ...)

Typedefs

typedef struct tcpsvr_tag tcpsvr_t

Functions

static tcpsvr_t * opentcpsvr (const char *path, char *msg)
static void closetcpsvr (tcpsvr_t *tcpsvr)
static int writetcpsvr (tcpsvr_t *tcpsvr, uint8_t *buff, int n, char *msg)
static serial_t * openserial (const char *path, int mode, char *msg)
static void closeserial (serial_t *serial)
static int readserial (serial_t *serial, uint8_t *buff, int n, char *msg)
static int writeserial (serial_t *serial, uint8_t *buff, int n, char *msg)
static int stateserial (serial_t *serial)
static int statexserial (serial_t *serial, char *msg)
static int openfile_ (file_t *file, gtime_t time, char *msg)
static void closefile_ (file_t *file)
static file_t * openfile (const char *path, int mode, char *msg)
static void closefile (file_t *file)
static void swapfile (file_t *file, gtime_t time, char *msg)
static void swapclose (file_t *file)
static int statefile (file_t *file)
static int statexfile (file_t *file, char *msg)
static int readfile (file_t *file, uint8_t *buff, int nmax, char *msg)
static int writefile (file_t *file, uint8_t *buff, int n, char *msg)
static void syncfile (file_t *file1, file_t *file2)
static void urldecode (char *str)
static void decodetcppath (const char *path, char *addr, char *port, char *user, char *passwd, char *mntpnt, char *str)
static int errsock (void)
static int setsock (int sock, char *msg)
static int accept_nb (int sock, struct sockaddr *addr, socklen_t *len)
static int connect_nb (int sock, struct sockaddr *addr, socklen_t len)
static int recv_nb (int sock, uint8_t *buff, int n)
static int send_nb (int sock, uint8_t *buff, int n)
static int gentcp (tcp_t *tcp, int type, char *msg)
static void discontcp (tcp_t *tcp, int tcon)
static void updatetcpsvr (tcpsvr_t *tcpsvr, char *msg)
static int accsock (tcpsvr_t *tcpsvr, char *msg)
static int waittcpsvr (tcpsvr_t *tcpsvr, char *msg)
static int readtcpsvr (tcpsvr_t *tcpsvr, uint8_t *buff, int n, char *msg)
static int statetcpsvr (tcpsvr_t *tcpsvr)
static int statextcp (tcp_t *tcp, char *msg)
static int statextcpsvr (tcpsvr_t *tcpsvr, char *msg)
static int consock (tcpcli_t *tcpcli, char *msg)
static tcpcli_t * opentcpcli (const char *path, char *msg)
static void closetcpcli (tcpcli_t *tcpcli)
static int waittcpcli (tcpcli_t *tcpcli, char *msg)
static int readtcpcli (tcpcli_t *tcpcli, uint8_t *buff, int n, char *msg)
static int writetcpcli (tcpcli_t *tcpcli, uint8_t *buff, int n, char *msg)
static int statetcpcli (tcpcli_t *tcpcli)
static int statextcpcli (tcpcli_t *tcpcli, char *msg)
static int encbase64 (char *str, const uint8_t *byte, int n)
static int reqntrip_s (ntrip_t *ntrip, char *msg)
static int reqntrip_c (ntrip_t *ntrip, char *msg)
static int rspntrip_s (ntrip_t *ntrip, char *msg)
static int rspntrip_c (ntrip_t *ntrip, char *msg)
static int waitntrip (ntrip_t *ntrip, char *msg)
static int parse_ntrip_query (char *mntpnt, char *host_override, int host_size)
static ntrip_t * openntrip (const char *path, int type, char *msg)
static void closentrip (ntrip_t *ntrip)
static int readntrip (ntrip_t *ntrip, uint8_t *buff, int n, char *msg)
static int writentrip (ntrip_t *ntrip, uint8_t *buff, int n, char *msg)
static int statentrip (ntrip_t *ntrip)
static int statexntrip (ntrip_t *ntrip, char *msg)
static ntripc_t * openntripc (const char *path, char *msg)
static void closentripc (ntripc_t *ntripc)
static void discon_ntripc (ntripc_t *ntripc, int i)
static void time_str_http (char *buff)
static void send_srctbl (ntripc_t *ntripc, int ver, int sock)
static void send_rsp_ok (int ver, int sock)
static void send_rsp_err (ntripc_t *ntripc, int ver, int err, int sock)
static void rsp_ntripc (ntripc_t *ntripc, int i)
static void wait_ntripc (ntripc_t *ntripc, char *msg)
static int readntripc (ntripc_t *ntripc, uint8_t *buff, int n, char *msg)
static int writentripc (ntripc_t *ntripc, uint8_t *buff, int n, char *msg)
static int statentripc (ntripc_t *ntripc)
static int statexntripc (ntripc_t *ntripc, char *msg)
static udp_t * genudp (int type, int port, const char *saddr, char *msg)
static udp_t * openudpsvr (const char *path, char *msg)
static void closeudpsvr (udp_t *udpsvr)
static int readudpsvr (udp_t *udpsvr, uint8_t *buff, int n, char *msg)
static int stateudpsvr (udp_t *udpsvr)
static int statexudpsvr (udp_t *udpsvr, char *msg)
static udp_t * openudpcli (const char *path, char *msg)
static void closeudpcli (udp_t *udpcli)
static int writeudpcli (udp_t *udpcli, uint8_t *buff, int n, char *msg)
static int stateudpcli (udp_t *udpcli)
static int statexudpcli (udp_t *udpcli, char *msg)
static void decodeftppath (const char *path, char *addr, char *file, char *user, char *passwd, int *topts)
static gtime_t nextdltime (const int *topts, int stat)
static void * ftpthread (void *arg)
static ftp_t * openftp (const char *path, int type, char *msg)
static void closeftp (ftp_t *ftp)
static int readftp (ftp_t *ftp, uint8_t *buff, int n, char *msg)
static int stateftp (ftp_t *ftp)
static int statexftp (ftp_t *ftp, char *msg)
static membuf_t * openmembuf (const char *path, char *msg)
static void closemembuf (membuf_t *membuf)
static int readmembuf (membuf_t *membuf, uint8_t *buff, int n, char *msg)
static int writemembuf (membuf_t *membuf, uint8_t *buff, int n, char *msg)
static int statemembuf (membuf_t *membuf)
static int statexmembuf (membuf_t *membuf, char *msg)
void strinitcom (void)
 Initialize stream communication system.
void strinit (stream_t *stream)
 Initialize stream structure.
int stropen (stream_t *stream, int type, int mode, const char *path)
 Open stream.
void strclose (stream_t *stream)
 Close stream.
void strsync (stream_t *stream1, stream_t *stream2)
 Sync streams.
void strlock (stream_t *stream)
 Lock stream.
void strunlock (stream_t *stream)
 Unlock stream.
int strread (stream_t *stream, uint8_t *buff, int n)
 Read data from stream.
int strwrite (stream_t *stream, uint8_t *buff, int n)
 Write data to stream.
int strstat (stream_t *stream, char *msg)
 Get stream status.
int strstatx (stream_t *stream, char *msg)
 Get stream extended status.
void strsum (stream_t *stream, uint64_t *inb, int *inr, uint64_t *outb, int *outr)
 Get stream statistics summary.
void strsetopt (const int *opt)
 Set stream options.
void strsettimeout (stream_t *stream, int toinact, int tirecon)
 Set stream timeout.
void strsetdir (const char *dir)
 Set FTP/HTTP local directory.
void strsetproxy (const char *addr)
 Set HTTP/NTRIP proxy address.
void strsetntripver (int ver)
 Set default NTRIP version for new connections.
gtime_t strgettime (stream_t *stream)
 Get stream time.
void strsendnmea (stream_t *stream, const sol_t *sol)
 Send NMEA request to stream.
static int gen_hex (const char *msg, uint8_t *buff)
static int set_brate (stream_t *str, int brate)
void strsendcmd (stream_t *str, const char *cmd)
 Send receiver command to stream.

Variables

const char * formatstrs [32]
static int toinact = 10000
static int ticonnect = 10000
static int tirate = 1000
static int buffsize = 32768
static char localdir [1024] = ""
static char proxyaddr [256] = ""
static int ntrip_ver_default = 0
static uint32_t tick_master = 0
static int fswapmargin = 30

Macro Definition Documentation

◆ __USE_MISC

#define __USE_MISC

Definition at line 35 of file mrtk_stream.c.

◆ BUFADD

#define BUFADD ( p,
rem,
... )
Value:
do { \
int _n = snprintf(p, rem, __VA_ARGS__); \
if (_n > 0 && _n < (rem)) { \
(p) += _n; \
(rem) -= _n; \
} else { \
(rem) = 0; \
} \
} while (0)

Definition at line 1489 of file mrtk_stream.c.

Referenced by reqntrip_c(), and reqntrip_s().

◆ closesocket

#define closesocket   close

◆ CRTSCTS

#define CRTSCTS   020000000000

Definition at line 37 of file mrtk_stream.c.

Referenced by openserial().

◆ DEFAULT_MEMBUF_SIZE

#define DEFAULT_MEMBUF_SIZE   4096 /* default memory buffer size (bytes) */

Definition at line 57 of file mrtk_stream.c.

Referenced by openmembuf().

◆ dev_t

#define dev_t   int

Definition at line 103 of file mrtk_stream.c.

◆ FTP_CMD

#define FTP_CMD   "wget" /* ftp/http command */

Definition at line 74 of file mrtk_stream.c.

Referenced by ftpthread().

◆ FTP_TIMEOUT

#define FTP_TIMEOUT   30 /* ftp/http timeout (s) */

Definition at line 75 of file mrtk_stream.c.

Referenced by ftpthread().

◆ MAXCLI

#define MAXCLI   32 /* max client connection for tcp svr */

◆ MAXSTATMSG

#define MAXSTATMSG   32 /* max length of status message */

Definition at line 56 of file mrtk_stream.c.

Referenced by rspntrip_c(), and rspntrip_s().

◆ MIN

#define MIN ( x,
y )
Value:
((x) < (y) ? (x) : (y))

Definition at line 77 of file mrtk_stream.c.

◆ NTRIP_AGENT

#define NTRIP_AGENT   MRTKLIB_SOFTNAME "/" MRTKLIB_VERSION_STRING

Definition at line 59 of file mrtk_stream.c.

Referenced by reqntrip_c(), and reqntrip_s().

◆ NTRIP_CLI_PORT

#define NTRIP_CLI_PORT   2101 /* default ntrip-client connection port */

Definition at line 60 of file mrtk_stream.c.

Referenced by openntrip(), and openntripc().

◆ NTRIP_MAXRSP

#define NTRIP_MAXRSP   32768 /* max size of ntrip response */

◆ NTRIP_MAXSTR

#define NTRIP_MAXSTR   256 /* max length of mountpoint string */

Definition at line 63 of file mrtk_stream.c.

Referenced by decodetcppath(), and send_srctbl().

◆ NTRIP_RSP_ERR_MNTP

#define NTRIP_RSP_ERR_MNTP   "ERROR - Bad Mountpoint\r\n"

Definition at line 72 of file mrtk_stream.c.

◆ NTRIP_RSP_ERR_PWD

#define NTRIP_RSP_ERR_PWD   "ERROR - Bad Password\r\n"

Definition at line 71 of file mrtk_stream.c.

◆ NTRIP_RSP_ERROR

#define NTRIP_RSP_ERROR   "ERROR" /* ntrip response: error */

Definition at line 69 of file mrtk_stream.c.

Referenced by rspntrip_s().

◆ NTRIP_RSP_HTTP

#define NTRIP_RSP_HTTP   "HTTP/" /* ntrip response: http */

Definition at line 68 of file mrtk_stream.c.

◆ NTRIP_RSP_OK_CLI

#define NTRIP_RSP_OK_CLI   "ICY 200 OK\r\n" /* ntrip response: client */

Definition at line 64 of file mrtk_stream.c.

Referenced by rspntrip_c(), and send_rsp_ok().

◆ NTRIP_RSP_OK_SVR

#define NTRIP_RSP_OK_SVR   "OK\r\n" /* ntrip response: server */

Definition at line 65 of file mrtk_stream.c.

Referenced by rspntrip_s().

◆ NTRIP_RSP_SRCTBL

#define NTRIP_RSP_SRCTBL   "SOURCETABLE 200 OK\r\n" /* ntrip response: source table */

Definition at line 66 of file mrtk_stream.c.

Referenced by rspntrip_c(), and send_srctbl().

◆ NTRIP_RSP_TBLEND

#define NTRIP_RSP_TBLEND   "ENDSOURCETABLE"

Definition at line 67 of file mrtk_stream.c.

Referenced by send_srctbl().

◆ NTRIP_RSP_UNAUTH

#define NTRIP_RSP_UNAUTH   "HTTP/1.0 401 Unauthorized\r\n"

Definition at line 70 of file mrtk_stream.c.

Referenced by send_rsp_err().

◆ NTRIP_SVR_PORT

#define NTRIP_SVR_PORT   80 /* default ntrip-server connection port */

Definition at line 61 of file mrtk_stream.c.

Referenced by openntrip().

◆ SERIBUFFSIZE

#define SERIBUFFSIZE   4096 /* serial buffer size (bytes) */

Definition at line 53 of file mrtk_stream.c.

◆ socket_t

#define socket_t   int

◆ TIMETAGH_LEN

#define TIMETAGH_LEN   64 /* time tag file header length */

Definition at line 54 of file mrtk_stream.c.

Referenced by openfile_().

◆ TINTACT

#define TINTACT   200 /* period for stream active (ms) */

Definition at line 52 of file mrtk_stream.c.

Referenced by strstat(), and strstatx().

Typedef Documentation

◆ tcpsvr_t

typedef struct tcpsvr_tag tcpsvr_t

Function Documentation

◆ accept_nb()

int accept_nb ( int sock,
struct sockaddr * addr,
socklen_t * len )
static

Definition at line 970 of file mrtk_stream.c.

References socket_t.

Referenced by accsock().

Here is the caller graph for this function:

◆ accsock()

int accsock ( tcpsvr_t * tcpsvr,
char * msg )
static

Definition at line 1169 of file mrtk_stream.c.

References accept_nb(), tcp_t::addr, tcpsvr_tag::cli, closesocket, errsock(), MAXCLI, tcp_t::saddr, setsock(), tcp_t::sock, socket_t, tcp_t::state, tcpsvr_tag::svr, tcp_t::tact, tickget(), and tracet().

Referenced by waittcpsvr().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ closefile()

void closefile ( file_t * file)
static

Definition at line 614 of file mrtk_stream.c.

References closefile_(), file_t::fp, free, and tracet().

Referenced by strclose().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ closefile_()

void closefile_ ( file_t * file)
static

Definition at line 527 of file mrtk_stream.c.

References file_t::fp, file_t::fp_tag, file_t::fp_tag_tmp, file_t::fp_tmp, file_t::path, timereset(), and tracet().

Referenced by closefile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ closeftp()

void closeftp ( ftp_t * ftp)
static

Definition at line 2852 of file mrtk_stream.c.

References free, ftp_t::state, and tracet().

Referenced by strclose().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ closemembuf()

void closemembuf ( membuf_t * membuf)
static

Definition at line 2963 of file mrtk_stream.c.

References membuf_t::buf, free, and tracet().

Referenced by strclose().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ closentrip()

void closentrip ( ntrip_t * ntrip)
static

Definition at line 1998 of file mrtk_stream.c.

References closetcpcli(), free, MAXSTRMSG, NTRIP_VER_2, ntrip_t::state, ntrip_t::tcp, tracet(), ntrip_t::type, ntrip_t::ver_neg, and writetcpcli().

Referenced by strclose().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ closentripc()

void closentripc ( ntripc_t * ntripc)
static

Definition at line 2177 of file mrtk_stream.c.

References tcpsvr_tag::cli, closetcpsvr(), ntripc_t::con, free, MAXCLI, send_nb(), tcp_t::sock, ntripc_con_t::state, ntripc_t::state, ntripc_t::tcp, tracet(), and ntripc_con_t::ver.

Referenced by strclose().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ closeserial()

void closeserial ( serial_t * serial)
static

Definition at line 373 of file mrtk_stream.c.

References closetcpsvr(), serial_t::dev, free, serial_t::tcpsvr, and tracet().

Referenced by strclose().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ closetcpcli()

void closetcpcli ( tcpcli_t * tcpcli)
static

Definition at line 1377 of file mrtk_stream.c.

References closesocket, free, tcp_t::sock, tcpcli_t::svr, and tracet().

Referenced by closentrip(), and strclose().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ closetcpsvr()

void closetcpsvr ( tcpsvr_t * tcpsvr)
static

Definition at line 1125 of file mrtk_stream.c.

References tcpsvr_tag::cli, closesocket, free, MAXCLI, tcp_t::sock, tcp_t::state, tcpsvr_tag::svr, and tracet().

Referenced by closentripc(), closeserial(), and strclose().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ closeudpcli()

void closeudpcli ( udp_t * udpcli)
static

Definition at line 2632 of file mrtk_stream.c.

References closesocket, free, udp_t::sock, and tracet().

Referenced by strclose().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ closeudpsvr()

void closeudpsvr ( udp_t * udpsvr)
static

Definition at line 2575 of file mrtk_stream.c.

References closesocket, free, udp_t::sock, and tracet().

Referenced by strclose().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ connect_nb()

int connect_nb ( int sock,
struct sockaddr * addr,
socklen_t len )
static

Definition at line 984 of file mrtk_stream.c.

References errsock(), and socket_t.

Referenced by consock().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ consock()

int consock ( tcpcli_t * tcpcli,
char * msg )
static

Definition at line 1325 of file mrtk_stream.c.

References tcp_t::addr, closesocket, connect_nb(), errsock(), tcp_t::saddr, tcp_t::sock, tcp_t::state, tcpcli_t::svr, tcp_t::tact, tcp_t::tcon, tcp_t::tdis, tickget(), and tracet().

Referenced by waittcpcli().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ decodeftppath()

void decodeftppath ( const char * path,
char * addr,
char * file,
char * user,
char * passwd,
int * topts )
static

Definition at line 2663 of file mrtk_stream.c.

References MAXSTRPATH, and tracet().

Referenced by openftp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ decodetcppath()

void decodetcppath ( const char * path,
char * addr,
char * port,
char * user,
char * passwd,
char * mntpnt,
char * str )
static

Definition at line 874 of file mrtk_stream.c.

References MAXSTRPATH, NTRIP_MAXSTR, tracet(), and urldecode().

Referenced by openntrip(), openntripc(), opentcpcli(), opentcpsvr(), openudpcli(), and openudpsvr().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ discon_ntripc()

void discon_ntripc ( ntripc_t * ntripc,
int i )
static

Definition at line 2192 of file mrtk_stream.c.

References ntripc_con_t::buff, tcpsvr_tag::cli, ntripc_t::con, discontcp(), ntripc_con_t::nb, send_nb(), tcp_t::sock, ntripc_con_t::state, ntripc_t::tcp, ticonnect, tracet(), and ntripc_con_t::ver.

Referenced by readntripc(), rsp_ntripc(), wait_ntripc(), and writentripc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ discontcp()

void discontcp ( tcp_t * tcp,
int tcon )
static

Definition at line 1091 of file mrtk_stream.c.

References closesocket, tcp_t::sock, tcp_t::state, tcp_t::tcon, tcp_t::tdis, tickget(), and tracet().

Referenced by discon_ntripc(), readtcpcli(), readtcpsvr(), rspntrip_c(), rspntrip_s(), waittcpcli(), writetcpcli(), and writetcpsvr().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ encbase64()

int encbase64 ( char * str,
const uint8_t * byte,
int n )
static

Definition at line 1466 of file mrtk_stream.c.

References tracet().

Referenced by reqntrip_c(), reqntrip_s(), and rsp_ntripc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ errsock()

int errsock ( void )
static

Definition at line 943 of file mrtk_stream.c.

Referenced by accsock(), connect_nb(), consock(), gentcp(), genudp(), readntripc(), readtcpcli(), readtcpsvr(), setsock(), wait_ntripc(), writentripc(), writetcpcli(), and writetcpsvr().

Here is the caller graph for this function:

◆ ftpthread()

void * ftpthread ( void * arg)
static

Definition at line 2738 of file mrtk_stream.c.

References ftp_t::addr, ftp_t::error, execcmd(), ftp_t::file, FILEPATHSEP, FTP_CMD, FTP_TIMEOUT, ftp_t::local, localdir, ftp_t::passwd, ftp_t::proto, proxyaddr, reppath(), rtk_uncompress(), ftp_t::state, timeadd(), timeget(), ftp_t::topts, tracet(), ftp_t::user, and utc2gpst().

Referenced by readftp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gen_hex()

int gen_hex ( const char * msg,
uint8_t * buff )
static

Definition at line 3713 of file mrtk_stream.c.

References trace().

Referenced by strsendcmd().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gentcp()

int gentcp ( tcp_t * tcp,
int type,
char * msg )
static

Definition at line 1036 of file mrtk_stream.c.

References tcp_t::addr, closesocket, errsock(), tcp_t::port, tcp_t::saddr, setsock(), tcp_t::sock, socket_t, tcp_t::state, tcp_t::tact, tcp_t::tcon, tcp_t::tdis, tickget(), ticonnect, and tracet().

Referenced by opentcpsvr(), and waittcpcli().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ genudp()

udp_t * genudp ( int type,
int port,
const char * saddr,
char * msg )
static

Definition at line 2502 of file mrtk_stream.c.

References udp_t::addr, buffsize, closesocket, errsock(), free, malloc, udp_t::port, udp_t::saddr, udp_t::sock, socket_t, udp_t::state, tracet(), and udp_t::type.

Referenced by openudpcli(), and openudpsvr().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nextdltime()

gtime_t nextdltime ( const int * topts,
int stat )
static

Definition at line 2714 of file mrtk_stream.c.

References gpst2time(), time2gpst(), timeget(), tracet(), and utc2gpst().

Referenced by readftp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ openfile()

file_t * openfile ( const char * path,
int mode,
char * msg )
static

Definition at line 548 of file mrtk_stream.c.

References file_t::fp, file_t::fp_tag, file_t::fp_tag_tmp, file_t::fp_tmp, file_t::fpos_n, free, file_t::lock, malloc, file_t::mode, file_t::offset, openfile_(), file_t::openpath, file_t::path, file_t::repmode, rtk_initlock, file_t::size_fpos, file_t::speed, file_t::start, STR_MODE_R, STR_MODE_W, file_t::swapintv, file_t::tick, file_t::tick_f, file_t::tick_n, file_t::time, timeget(), file_t::timetag, tracet(), utc2gpst(), and file_t::wtime.

Referenced by stropen().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ openfile_()

int openfile_ ( file_t * file,
gtime_t time,
char * msg )
static

Definition at line 441 of file mrtk_stream.c.

References createdir(), file_t::fp, file_t::fp_tag, file_t::fpos_n, gpst2utc(), MAXSTRPATH, file_t::mode, file_t::openpath, file_t::path, reppath(), gtime_t::sec, STR_MODE_R, STR_MODE_W, file_t::tick, file_t::tick_f, file_t::tick_n, tickget(), file_t::time, gtime_t::time, time_str(), timeget(), timeset(), file_t::timetag, TIMETAGH_LEN, tracet(), utc2gpst(), and file_t::wtime.

Referenced by openfile(), and swapfile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ openftp()

ftp_t * openftp ( const char * path,
int type,
char * msg )
static

Definition at line 2826 of file mrtk_stream.c.

References ftp_t::addr, decodeftppath(), ftp_t::error, ftp_t::file, ftp_t::local, malloc, ftp_t::passwd, ftp_t::proto, ftp_t::state, ftp_t::thread, timeadd(), timeget(), ftp_t::tnext, ftp_t::topts, tracet(), and ftp_t::user.

Referenced by stropen().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ openmembuf()

membuf_t * openmembuf ( const char * path,
char * msg )
static

Definition at line 2935 of file mrtk_stream.c.

References membuf_t::buf, membuf_t::bufsize, DEFAULT_MEMBUF_SIZE, free, membuf_t::lock, malloc, membuf_t::rp, rtk_initlock, membuf_t::state, tracet(), and membuf_t::wp.

Referenced by stropen().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ openntrip()

ntrip_t * openntrip ( const char * path,
int type,
char * msg )
static

Definition at line 1935 of file mrtk_stream.c.

References ntrip_t::buff, ntrip_t::cdec, chunk_dec_init(), ntrip_t::chunked, decodetcppath(), free, ntrip_t::host, malloc, MAXSTRPATH, ntrip_t::mntpnt, ntrip_t::nb, NTRIP_CLI_PORT, NTRIP_MAXRSP, NTRIP_SVR_PORT, NTRIP_VER_AUTO, opentcpcli(), parse_ntrip_query(), ntrip_t::passwd, proxyaddr, ntrip_t::state, ntrip_t::str, ntrip_t::tcp, tracet(), ntrip_t::type, ntrip_t::url, ntrip_t::user, ntrip_t::v2_tried, ntrip_t::ver, and ntrip_t::ver_neg.

Referenced by stropen().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ openntripc()

ntripc_t * openntripc ( const char * path,
char * msg )
static

Definition at line 2135 of file mrtk_stream.c.

References ntripc_con_t::buff, ntripc_t::con, decodetcppath(), free, malloc, MAXCLI, MAXSTRPATH, ntripc_t::mntpnt, ntripc_con_t::nb, NTRIP_CLI_PORT, NTRIP_MAXRSP, opentcpsvr(), ntripc_t::passwd, ntripc_t::srctbl, ntripc_con_t::state, ntripc_t::state, ntripc_t::tcp, tracet(), ntripc_t::user, and ntripc_con_t::ver.

Referenced by stropen().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ openserial()

serial_t * openserial ( const char * path,
int mode,
char * msg )
static

Definition at line 250 of file mrtk_stream.c.

References calloc, CRTSCTS, serial_t::dev, free, opentcpsvr(), STR_MODE_R, STR_MODE_W, serial_t::tcpsvr, and tracet().

Referenced by stropen().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ opentcpcli()

tcpcli_t * opentcpcli ( const char * path,
char * msg )
static

Definition at line 1354 of file mrtk_stream.c.

References decodetcppath(), free, malloc, tcp_t::port, tcp_t::saddr, tcpcli_t::svr, tcp_t::tcon, ticonnect, tcpcli_t::tirecon, tcpcli_t::toinact, toinact, and tracet().

Referenced by openntrip(), and stropen().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ opentcpsvr()

tcpsvr_t * opentcpsvr ( const char * path,
char * msg )
static

Definition at line 1100 of file mrtk_stream.c.

References decodetcppath(), free, gentcp(), malloc, tcp_t::port, tcp_t::saddr, tcpsvr_tag::svr, tcp_t::tcon, and tracet().

Referenced by openntripc(), openserial(), and stropen().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ openudpcli()

udp_t * openudpcli ( const char * path,
char * msg )
static

Definition at line 2616 of file mrtk_stream.c.

References decodetcppath(), genudp(), and tracet().

Referenced by stropen().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ openudpsvr()

udp_t * openudpsvr ( const char * path,
char * msg )
static

Definition at line 2559 of file mrtk_stream.c.

References decodetcppath(), genudp(), and tracet().

Referenced by stropen().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_ntrip_query()

int parse_ntrip_query ( char * mntpnt,
char * host_override,
int host_size )
static

Definition at line 1875 of file mrtk_stream.c.

References NTRIP_VER_1, NTRIP_VER_2, ntrip_ver_default, and tracet().

Referenced by openntrip().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readfile()

int readfile ( file_t * file,
uint8_t * buff,
int nmax,
char * msg )
static

Definition at line 690 of file mrtk_stream.c.

References file_t::fp, file_t::fp_tag, file_t::fpos_n, gpst2utc(), file_t::offset, file_t::repmode, file_t::size_fpos, file_t::speed, file_t::start, file_t::tick, tick_master, file_t::tick_n, tickget(), file_t::time, timeadd(), timeset(), tracet(), and file_t::wtime.

Referenced by strread().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readftp()

int readftp ( ftp_t * ftp,
uint8_t * buff,
int n,
char * msg )
static

Definition at line 2860 of file mrtk_stream.c.

References ftp_t::addr, ftp_t::error, ftpthread(), ftp_t::local, nextdltime(), ftp_t::proto, ftp_t::state, ftp_t::thread, timediff(), timeget(), ftp_t::tnext, ftp_t::topts, tracet(), and utc2gpst().

Referenced by strread().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readmembuf()

int readmembuf ( membuf_t * membuf,
uint8_t * buff,
int n,
char * msg )
static

Definition at line 2970 of file mrtk_stream.c.

References membuf_t::buf, membuf_t::bufsize, membuf_t::lock, membuf_t::rp, rtk_lock, rtk_unlock, tracet(), and membuf_t::wp.

Referenced by strread().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readntrip()

int readntrip ( ntrip_t * ntrip,
uint8_t * buff,
int n,
char * msg )
static

Definition at line 2011 of file mrtk_stream.c.

References ntrip_t::buff, ntrip_t::cdec, chunk_dec_init(), chunk_decode(), ntrip_t::chunked, ntrip_t::nb, NTRIP_MAXRSP, readtcpcli(), ntrip_t::tcp, tracet(), and waitntrip().

Referenced by strread().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readntripc()

int readntripc ( ntripc_t * ntripc,
uint8_t * buff,
int n,
char * msg )
static

Definition at line 2391 of file mrtk_stream.c.

References tcpsvr_tag::cli, ntripc_t::con, discon_ntripc(), errsock(), MAXCLI, recv_nb(), tcp_t::sock, ntripc_con_t::state, tcp_t::tact, ntripc_t::tcp, tickget(), tracet(), and wait_ntripc().

Referenced by strread().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readserial()

int readserial ( serial_t * serial,
uint8_t * buff,
int n,
char * msg )
static

Definition at line 386 of file mrtk_stream.c.

References serial_t::dev, serial_t::tcpsvr, tracet(), and writetcpsvr().

Referenced by strread().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readtcpcli()

int readtcpcli ( tcpcli_t * tcpcli,
uint8_t * buff,
int n,
char * msg )
static

Definition at line 1412 of file mrtk_stream.c.

References discontcp(), errsock(), recv_nb(), tcp_t::sock, tcpcli_t::svr, tcp_t::tact, tickget(), tcpcli_t::tirecon, tracet(), and waittcpcli().

Referenced by readntrip(), strread(), and waitntrip().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readtcpsvr()

int readtcpsvr ( tcpsvr_t * tcpsvr,
uint8_t * buff,
int n,
char * msg )
static

Definition at line 1226 of file mrtk_stream.c.

References tcpsvr_tag::cli, discontcp(), errsock(), MAXCLI, recv_nb(), tcp_t::sock, tcp_t::state, tcpsvr_tag::svr, tcp_t::tact, tickget(), ticonnect, tracet(), updatetcpsvr(), and waittcpsvr().

Referenced by strread().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readudpsvr()

int readudpsvr ( udp_t * udpsvr,
uint8_t * buff,
int n,
char * msg )
static

Definition at line 2582 of file mrtk_stream.c.

References udp_t::sock, and tracet().

Referenced by strread().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ recv_nb()

int recv_nb ( int sock,
uint8_t * buff,
int n )
static

Definition at line 1006 of file mrtk_stream.c.

References socket_t.

Referenced by readntripc(), readtcpcli(), readtcpsvr(), and wait_ntripc().

Here is the caller graph for this function:

◆ reqntrip_c()

int reqntrip_c ( ntrip_t * ntrip,
char * msg )
static

Definition at line 1557 of file mrtk_stream.c.

References BUFADD, encbase64(), ntrip_t::host, ntrip_t::mntpnt, NTRIP_AGENT, NTRIP_VER_2, NTRIP_VER_AUTO, ntrip_t::passwd, ntrip_t::state, ntrip_t::tcp, tracet(), ntrip_t::url, ntrip_t::user, ntrip_t::v2_tried, ntrip_t::ver, ntrip_t::ver_neg, and writetcpcli().

Referenced by waitntrip().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reqntrip_s()

int reqntrip_s ( ntrip_t * ntrip,
char * msg )
static

Definition at line 1500 of file mrtk_stream.c.

References BUFADD, encbase64(), ntrip_t::host, ntrip_t::mntpnt, NTRIP_AGENT, NTRIP_VER_2, NTRIP_VER_AUTO, ntrip_t::passwd, ntrip_t::state, ntrip_t::str, ntrip_t::tcp, tracet(), ntrip_t::url, ntrip_t::user, ntrip_t::v2_tried, ntrip_t::ver, ntrip_t::ver_neg, and writetcpcli().

Referenced by waitntrip().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rsp_ntripc()

void rsp_ntripc ( ntripc_t * ntripc,
int i )
static

Definition at line 2281 of file mrtk_stream.c.

References ntripc_con_t::buff, tcpsvr_tag::cli, ntripc_t::con, discon_ntripc(), encbase64(), ntripc_con_t::mntpnt, ntripc_t::mntpnt, ntripc_con_t::nb, NTRIP_MAXRSP, ntripc_t::passwd, send_rsp_err(), send_rsp_ok(), send_srctbl(), tcp_t::sock, ntripc_con_t::state, ntripc_t::tcp, tracet(), ntripc_t::user, and ntripc_con_t::ver.

Referenced by wait_ntripc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rspntrip_c()

int rspntrip_c ( ntrip_t * ntrip,
char * msg )
static

Definition at line 1698 of file mrtk_stream.c.

References ntrip_t::buff, ntrip_t::cdec, chunk_dec_init(), ntrip_t::chunked, discontcp(), http_find_header(), http_header_end(), http_status_code(), MAXSTATMSG, ntrip_t::mntpnt, ntrip_t::nb, NTRIP_MAXRSP, NTRIP_RSP_OK_CLI, NTRIP_RSP_SRCTBL, NTRIP_VER_1, NTRIP_VER_2, NTRIP_VER_AUTO, tcp_t::saddr, ntrip_t::state, stristr(), tcpcli_t::svr, ntrip_t::tcp, tcpcli_t::tirecon, tracet(), ntrip_t::v2_tried, ntrip_t::ver, and ntrip_t::ver_neg.

Referenced by waitntrip().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rspntrip_s()

int rspntrip_s ( ntrip_t * ntrip,
char * msg )
static

Definition at line 1629 of file mrtk_stream.c.

References ntrip_t::buff, discontcp(), http_header_end(), http_status_code(), MAXSTATMSG, ntrip_t::mntpnt, ntrip_t::nb, NTRIP_MAXRSP, NTRIP_RSP_ERROR, NTRIP_RSP_OK_SVR, NTRIP_VER_1, NTRIP_VER_2, tcp_t::saddr, ntrip_t::state, tcpcli_t::svr, ntrip_t::tcp, tcpcli_t::tirecon, tracet(), and ntrip_t::ver_neg.

Referenced by waitntrip().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_nb()

int send_nb ( int sock,
uint8_t * buff,
int n )
static

Definition at line 1021 of file mrtk_stream.c.

References socket_t.

Referenced by closentripc(), discon_ntripc(), send_rsp_err(), send_rsp_ok(), send_srctbl(), writentripc(), writetcpcli(), and writetcpsvr().

Here is the caller graph for this function:

◆ send_rsp_err()

void send_rsp_err ( ntripc_t * ntripc,
int ver,
int err,
int sock )
static

Definition at line 2259 of file mrtk_stream.c.

References NTRIP_RSP_UNAUTH, send_nb(), send_srctbl(), socket_t, and time_str_http().

Referenced by rsp_ntripc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_rsp_ok()

void send_rsp_ok ( int ver,
int sock )
static

Definition at line 2239 of file mrtk_stream.c.

References NTRIP_RSP_OK_CLI, send_nb(), socket_t, and time_str_http().

Referenced by rsp_ntripc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_srctbl()

void send_srctbl ( ntripc_t * ntripc,
int ver,
int sock )
static

Definition at line 2217 of file mrtk_stream.c.

References ntripc_t::mntpnt, NTRIP_MAXSTR, NTRIP_RSP_SRCTBL, NTRIP_RSP_TBLEND, send_nb(), socket_t, ntripc_t::srctbl, and time_str_http().

Referenced by rsp_ntripc(), and send_rsp_err().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_brate()

int set_brate ( stream_t * str,
int brate )
static

Definition at line 3733 of file mrtk_stream.c.

References stream_tag::mode, stream_tag::path, STR_SERIAL, strclose(), stropen(), and stream_tag::type.

Referenced by strsendcmd().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setsock()

int setsock ( int sock,
char * msg )
static

Definition at line 946 of file mrtk_stream.c.

References buffsize, closesocket, errsock(), socket_t, and tracet().

Referenced by accsock(), and gentcp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ statefile()

int statefile ( file_t * file)
static

Definition at line 661 of file mrtk_stream.c.

Referenced by strstat().

Here is the caller graph for this function:

◆ stateftp()

int stateftp ( ftp_t * ftp)
static

Definition at line 2911 of file mrtk_stream.c.

References ftp_t::state.

Referenced by strstat().

Here is the caller graph for this function:

◆ statemembuf()

int statemembuf ( membuf_t * membuf)
static

Definition at line 3022 of file mrtk_stream.c.

References membuf_t::state.

Referenced by strstat().

Here is the caller graph for this function:

◆ statentrip()

int statentrip ( ntrip_t * ntrip)
static

Definition at line 2105 of file mrtk_stream.c.

References ntrip_t::state, tcp_t::state, tcpcli_t::svr, and ntrip_t::tcp.

Referenced by strstat().

Here is the caller graph for this function:

◆ statentripc()

int statentripc ( ntripc_t * ntripc)
static

Definition at line 2472 of file mrtk_stream.c.

References ntripc_t::state.

Referenced by strstat().

Here is the caller graph for this function:

◆ stateserial()

int stateserial ( serial_t * serial)
static

Definition at line 425 of file mrtk_stream.c.

References serial_t::error.

Referenced by strstat().

Here is the caller graph for this function:

◆ statetcpcli()

int statetcpcli ( tcpcli_t * tcpcli)
static

Definition at line 1462 of file mrtk_stream.c.

References tcp_t::state, and tcpcli_t::svr.

Referenced by strstat().

Here is the caller graph for this function:

◆ statetcpsvr()

int statetcpsvr ( tcpsvr_t * tcpsvr)
static

Definition at line 1287 of file mrtk_stream.c.

References tcp_t::state, and tcpsvr_tag::svr.

Referenced by strstat().

Here is the caller graph for this function:

◆ stateudpcli()

int stateudpcli ( udp_t * udpcli)
static

Definition at line 2645 of file mrtk_stream.c.

References udp_t::state.

Referenced by strstat().

Here is the caller graph for this function:

◆ stateudpsvr()

int stateudpsvr ( udp_t * udpsvr)
static

Definition at line 2599 of file mrtk_stream.c.

References udp_t::state.

Referenced by strstat().

Here is the caller graph for this function:

◆ statexfile()

int statexfile ( file_t * file,
char * msg )
static

Definition at line 663 of file mrtk_stream.c.

References file_t::mode, file_t::offset, file_t::openpath, file_t::path, file_t::repmode, file_t::speed, file_t::start, file_t::swapintv, file_t::tick, file_t::tick_f, file_t::time, time2str(), file_t::timetag, and file_t::wtime.

Referenced by strstatx().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ statexftp()

int statexftp ( ftp_t * ftp,
char * msg )
static

Definition at line 2923 of file mrtk_stream.c.

References ftp_t::state.

Referenced by strstatx().

Here is the caller graph for this function:

◆ statexmembuf()

int statexmembuf ( membuf_t * membuf,
char * msg )
static

Definition at line 3024 of file mrtk_stream.c.

References membuf_t::bufsize, membuf_t::rp, membuf_t::state, and membuf_t::wp.

Referenced by strstatx().

Here is the caller graph for this function:

◆ statexntrip()

int statexntrip ( ntrip_t * ntrip,
char * msg )
static

Definition at line 2109 of file mrtk_stream.c.

References ntrip_t::chunked, ntrip_t::host, ntrip_t::mntpnt, ntrip_t::nb, ntrip_t::passwd, ntrip_t::state, tcp_t::state, statextcp(), ntrip_t::str, tcpcli_t::svr, ntrip_t::tcp, ntrip_t::type, ntrip_t::url, ntrip_t::user, ntrip_t::ver, and ntrip_t::ver_neg.

Referenced by strstatx().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ statexntripc()

int statexntripc ( ntripc_t * ntripc,
char * msg )
static

Definition at line 2474 of file mrtk_stream.c.

References tcpsvr_tag::cli, ntripc_t::con, MAXCLI, ntripc_con_t::mntpnt, ntripc_t::mntpnt, ntripc_con_t::nb, ntripc_t::passwd, ntripc_t::srctbl, ntripc_t::state, tcp_t::state, statextcp(), tcpsvr_tag::svr, ntripc_t::tcp, ntripc_t::type, and ntripc_t::user.

Referenced by strstatx().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ statexserial()

int statexserial ( serial_t * serial,
char * msg )
static

Definition at line 427 of file mrtk_stream.c.

References serial_t::dev, and serial_t::error.

Referenced by strstatx().

Here is the caller graph for this function:

◆ statextcp()

int statextcp ( tcp_t * tcp,
char * msg )
static

Definition at line 1289 of file mrtk_stream.c.

References tcp_t::port, tcp_t::saddr, tcp_t::sock, tcp_t::state, tcp_t::tact, tcp_t::tcon, and tcp_t::tdis.

Referenced by statexntrip(), statexntripc(), and statextcpsvr().

Here is the caller graph for this function:

◆ statextcpcli()

int statextcpcli ( tcpcli_t * tcpcli,
char * msg )
static

Definition at line 1464 of file mrtk_stream.c.

References tcp_t::state, and tcpcli_t::svr.

Referenced by strstatx().

Here is the caller graph for this function:

◆ statextcpsvr()

int statextcpsvr ( tcpsvr_t * tcpsvr,
char * msg )
static

Definition at line 1304 of file mrtk_stream.c.

References tcpsvr_tag::cli, MAXCLI, tcp_t::state, statextcp(), and tcpsvr_tag::svr.

Referenced by strstatx().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ statexudpcli()

int statexudpcli ( udp_t * udpcli,
char * msg )
static

Definition at line 2647 of file mrtk_stream.c.

References udp_t::port, udp_t::saddr, udp_t::sock, udp_t::state, and udp_t::type.

Referenced by strstatx().

Here is the caller graph for this function:

◆ statexudpsvr()

int statexudpsvr ( udp_t * udpsvr,
char * msg )
static

Definition at line 2601 of file mrtk_stream.c.

References udp_t::port, udp_t::sock, udp_t::state, and udp_t::type.

Referenced by strstatx().

Here is the caller graph for this function:

◆ strclose()

void strclose ( stream_t * stream)
extern

Close stream.

Parameters
[in,out]streamstream struct

Definition at line 3233 of file mrtk_stream.c.

References closefile(), closeftp(), closemembuf(), closentrip(), closentripc(), closeserial(), closetcpcli(), closetcpsvr(), closeudpcli(), closeudpsvr(), stream_tag::inr, stream_tag::mode, stream_tag::msg, stream_tag::outr, stream_tag::path, stream_tag::port, stream_tag::state, STR_FILE, STR_FTP, STR_HTTP, STR_MEMBUF, STR_NTRIPCAS, STR_NTRIPCLI, STR_NTRIPSVR, STR_SERIAL, STR_TCPCLI, STR_TCPSVR, STR_UDPCLI, STR_UDPSVR, strlock(), strunlock(), trace(), tracet(), and stream_tag::type.

Referenced by rtksvrclosestr(), rtksvrstart(), rtksvrthread(), set_brate(), strsvrstart(), and strsvrthread().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ strgettime()

gtime_t strgettime ( stream_t * stream)
extern

Get stream time.

Parameters
[in]streamstream struct
Returns
stream time

Definition at line 3690 of file mrtk_stream.c.

References stream_tag::mode, stream_tag::port, file_t::start, STR_FILE, STR_MODE_R, file_t::time, timeadd(), timeget(), stream_tag::type, and utc2gpst().

Referenced by rtksvrstart().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ strinit()

void strinit ( stream_t * stream)
extern

Initialize stream structure.

Parameters
[in,out]streamstream struct

Definition at line 3049 of file mrtk_stream.c.

References stream_tag::inb, stream_tag::inbt, stream_tag::inr, stream_tag::lock, stream_tag::mode, stream_tag::msg, stream_tag::outb, stream_tag::outbt, stream_tag::outr, stream_tag::path, stream_tag::port, rtk_initlock, stream_tag::state, stream_tag::tact, stream_tag::tick_i, stream_tag::tick_o, tracet(), and stream_tag::type.

Referenced by rtksvrinit(), and strsvrinit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ strinitcom()

void strinitcom ( void )
extern

Initialize stream communication system.

Definition at line 3043 of file mrtk_stream.c.

References tracet().

Referenced by rtksvrstart(), and strsvrstart().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ strlock()

void strlock ( stream_t * stream)
extern

Lock stream.

Parameters
[in,out]streamstream struct

Definition at line 3313 of file mrtk_stream.c.

References stream_tag::lock, and rtk_lock.

Referenced by strclose(), strread(), strstat(), strstatx(), strsum(), and strwrite().

Here is the caller graph for this function:

◆ stropen()

int stropen ( stream_t * stream,
int type,
int mode,
const char * path )
extern

Open stream.

Parameters
[in,out]streamstream struct
[in]typestream type (STR_???)
[in]modestream mode (STR_MODE_?)
[in]pathstream path
Returns
status (0:error,1:ok)

Definition at line 3173 of file mrtk_stream.c.

References stream_tag::inb, stream_tag::inbt, stream_tag::inr, stream_tag::mode, stream_tag::msg, openfile(), openftp(), openmembuf(), openntrip(), openntripc(), openserial(), opentcpcli(), opentcpsvr(), openudpcli(), openudpsvr(), stream_tag::outb, stream_tag::outbt, stream_tag::outr, stream_tag::path, stream_tag::port, stream_tag::state, STR_FILE, STR_FTP, STR_HTTP, STR_MEMBUF, STR_NTRIPCAS, STR_NTRIPCLI, STR_NTRIPSVR, STR_SERIAL, STR_TCPCLI, STR_TCPSVR, STR_UDPCLI, STR_UDPSVR, stream_tag::tick_i, stream_tag::tick_o, tickget(), tracet(), and stream_tag::type.

Referenced by rtksvropenstr(), rtksvrstart(), set_brate(), and strsvrstart().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ strread()

int strread ( stream_t * stream,
uint8_t * buff,
int n )
extern

Read data from stream.

Parameters
[in,out]streamstream struct
[out]buffdata buffer
[in]nmax data length (bytes)
Returns
data length (bytes)

Definition at line 3324 of file mrtk_stream.c.

References stream_tag::inb, stream_tag::inbt, stream_tag::inr, stream_tag::mode, stream_tag::msg, stream_tag::port, readfile(), readftp(), readmembuf(), readntrip(), readntripc(), readserial(), readtcpcli(), readtcpsvr(), readudpsvr(), STR_FILE, STR_FTP, STR_HTTP, STR_MEMBUF, STR_MODE_R, STR_NTRIPCAS, STR_NTRIPCLI, STR_NTRIPSVR, STR_SERIAL, STR_TCPCLI, STR_TCPSVR, STR_UDPSVR, strlock(), strunlock(), stream_tag::tact, stream_tag::tick_i, tickget(), tirate, tracet(), and stream_tag::type.

Referenced by rtksvrthread(), and strsvrthread().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ strsendcmd()

void strsendcmd ( stream_t * stream,
const char * cmd )
extern

Send receiver command to stream.

Parameters
[in,out]streamstream struct
[in]cmdreceiver command

Definition at line 3760 of file mrtk_stream.c.

References gen_hex(), gen_nvs(), gen_stq(), gen_ubx(), set_brate(), sleepms(), strwrite(), and tracet().

Referenced by periodic_cmd(), periodic_cmd(), rtksvrstart(), rtksvrstop(), send_nmea(), strsvrstart(), and strsvrstop().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ strsendnmea()

void strsendnmea ( stream_t * stream,
const sol_t * sol )
extern

Send NMEA request to stream.

Parameters
[in,out]streamstream struct
[in]solsolution data

Definition at line 3703 of file mrtk_stream.c.

References outnmea_gga(), sol_t::rr, strwrite(), and tracet().

Referenced by send_nmea(), and strsvrthread().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ strsetdir()

void strsetdir ( const char * dir)
extern

Set FTP/HTTP local directory.

Parameters
[in]dirlocal directory

Definition at line 3658 of file mrtk_stream.c.

References localdir, and tracet().

Here is the call graph for this function:

◆ strsetntripver()

void strsetntripver ( int ver)
extern

Set default NTRIP version for new connections.

Parameters
[in]verNTRIP version (0:auto, 1:v1, 2:v2)

When set to auto (0), the client tries NTRIP v2 first and falls back to v1 if the caster does not support it. Per-stream override is available via the ?ver=N query parameter in the stream path.

Definition at line 3678 of file mrtk_stream.c.

References ntrip_ver_default, and tracet().

Here is the call graph for this function:

◆ strsetopt()

void strsetopt ( const int * opt)
extern

Set stream options.

Parameters
[in]optstream options (timeout/reconnect/rate/buffsize/fswapmargin)

Definition at line 3620 of file mrtk_stream.c.

References buffsize, fswapmargin, ticonnect, tirate, toinact, and tracet().

Referenced by strsvrstart().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ strsetproxy()

void strsetproxy ( const char * addr)
extern

Set HTTP/NTRIP proxy address.

Parameters
[in]addrproxy address

Definition at line 3668 of file mrtk_stream.c.

References proxyaddr, and tracet().

Here is the call graph for this function:

◆ strsettimeout()

void strsettimeout ( stream_t * stream,
int toinact,
int tirecon )
extern

Set stream timeout.

Parameters
[in,out]streamstream struct
[in]toinactinactive timeout (ms) (0:no timeout)
[in]tireconreconnect interval (ms)

Definition at line 3637 of file mrtk_stream.c.

References stream_tag::port, STR_NTRIPCLI, STR_NTRIPSVR, STR_TCPCLI, tcpcli_t::tirecon, tcpcli_t::toinact, toinact, tracet(), and stream_tag::type.

Here is the call graph for this function:

◆ strstat()

int strstat ( stream_t * stream,
char * msg )
extern

Get stream status.

Parameters
[in]streamstream struct
[out]msgstatus message (NULL: no output)
Returns
stream status (-1:error,0:close,1:wait,2:connect,3:active)

Definition at line 3458 of file mrtk_stream.c.

References MAXSTRMSG, stream_tag::msg, stream_tag::port, stream_tag::state, statefile(), stateftp(), statemembuf(), statentrip(), statentripc(), stateserial(), statetcpcli(), statetcpsvr(), stateudpcli(), stateudpsvr(), STR_FILE, STR_FTP, STR_HTTP, STR_MEMBUF, STR_NTRIPCAS, STR_NTRIPCLI, STR_NTRIPSVR, STR_SERIAL, STR_TCPCLI, STR_TCPSVR, STR_UDPCLI, STR_UDPSVR, strlock(), strunlock(), stream_tag::tact, tickget(), TINTACT, tracet(), and stream_tag::type.

Referenced by rtksvrsstat(), and strsvrstat().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ strstatx()

int strstatx ( stream_t * stream,
char * msg )
extern

Get stream extended status.

Parameters
[in]streamstream struct
[out]msgstatus message (NULL: no output)
Returns
stream status

Definition at line 3523 of file mrtk_stream.c.

References stream_tag::port, stream_tag::state, statexfile(), statexftp(), statexmembuf(), statexntrip(), statexntripc(), statexserial(), statextcpcli(), statextcpsvr(), statexudpcli(), statexudpsvr(), STR_FILE, STR_FTP, STR_HTTP, STR_MEMBUF, STR_NTRIPCAS, STR_NTRIPCLI, STR_NTRIPSVR, STR_SERIAL, STR_TCPCLI, STR_TCPSVR, STR_UDPCLI, STR_UDPSVR, strlock(), strunlock(), stream_tag::tact, tickget(), TINTACT, tracet(), and stream_tag::type.

Here is the call graph for this function:

◆ strsum()

void strsum ( stream_t * stream,
uint64_t * inb,
int * inr,
uint64_t * outb,
int * outr )
extern

Get stream statistics summary.

Parameters
[in]streamstream struct
[out]inbinput bytes (NULL: not output)
[out]inrinput rate (bps) (NULL: not output)
[out]outboutput bytes (NULL: not output)
[out]outroutput rate (bps) (NULL: not output)

Definition at line 3589 of file mrtk_stream.c.

References stream_tag::inb, stream_tag::inr, stream_tag::outb, stream_tag::outr, strlock(), strunlock(), and tracet().

Referenced by strsvrstat().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ strsync()

void strsync ( stream_t * stream1,
stream_t * stream2 )
extern

Sync streams.

Parameters
[in,out]stream1stream struct 1
[in,out]stream2stream struct 2

Definition at line 3297 of file mrtk_stream.c.

References stream_tag::port, STR_FILE, syncfile(), and stream_tag::type.

Referenced by rtksvrstart().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ strunlock()

void strunlock ( stream_t * stream)
extern

Unlock stream.

Parameters
[in,out]streamstream struct

Definition at line 3314 of file mrtk_stream.c.

References stream_tag::lock, and rtk_unlock.

Referenced by strclose(), strread(), strstat(), strstatx(), strsum(), and strwrite().

Here is the caller graph for this function:

◆ strwrite()

int strwrite ( stream_t * stream,
uint8_t * buff,
int n )
extern

Write data to stream.

Parameters
[in,out]streamstream struct
[in]buffdata buffer
[in]ndata length (bytes)
Returns
bytes written (0: nothing written or error; some stream types return -1 on error)

Definition at line 3394 of file mrtk_stream.c.

References stream_tag::mode, stream_tag::msg, stream_tag::outb, stream_tag::outbt, stream_tag::outr, stream_tag::port, STR_FILE, STR_FTP, STR_HTTP, STR_MEMBUF, STR_MODE_W, STR_NTRIPCAS, STR_NTRIPCLI, STR_NTRIPSVR, STR_SERIAL, STR_TCPCLI, STR_TCPSVR, STR_UDPCLI, strlock(), strunlock(), stream_tag::tact, stream_tag::tick_o, tickget(), tirate, tracet(), stream_tag::type, writefile(), writemembuf(), writentrip(), writentripc(), writeserial(), writetcpcli(), writetcpsvr(), and writeudpcli().

Referenced by output_lclcmb(), rtksvrmark(), rtksvrstart(), rtksvrthread(), strsendcmd(), strsendnmea(), strsvrstart(), strsvrthread(), write_nav(), write_nav_cycle(), write_obs(), write_rtcm3_msm(), write_sta_cycle(), writesol(), and writesolhead().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ swapclose()

void swapclose ( file_t * file)
static

Definition at line 649 of file mrtk_stream.c.

References file_t::fp_tag_tmp, file_t::fp_tmp, and tracet().

Referenced by writefile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ swapfile()

void swapfile ( file_t * file,
gtime_t time,
char * msg )
static

Definition at line 624 of file mrtk_stream.c.

References file_t::fp, file_t::fp_tag, file_t::fp_tag_tmp, file_t::fp_tmp, MAXSTRPATH, openfile_(), file_t::openpath, file_t::path, reppath(), time_str(), and tracet().

Referenced by writefile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ syncfile()

void syncfile ( file_t * file1,
file_t * file2 )
static

Definition at line 834 of file mrtk_stream.c.

References file_t::fp_tag, file_t::offset, file_t::repmode, and file_t::tick_f.

Referenced by strsync().

Here is the caller graph for this function:

◆ time_str_http()

void time_str_http ( char * buff)
static

Definition at line 2207 of file mrtk_stream.c.

Referenced by send_rsp_err(), send_rsp_ok(), and send_srctbl().

Here is the caller graph for this function:

◆ updatetcpsvr()

void updatetcpsvr ( tcpsvr_t * tcpsvr,
char * msg )
static

Definition at line 1139 of file mrtk_stream.c.

References tcpsvr_tag::cli, MAXCLI, tcp_t::saddr, tcp_t::state, tcpsvr_tag::svr, and tracet().

Referenced by readtcpsvr(), waittcpsvr(), and writetcpsvr().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ urldecode()

void urldecode ( char * str)
static

Definition at line 843 of file mrtk_stream.c.

Referenced by decodetcppath().

Here is the caller graph for this function:

◆ wait_ntripc()

void wait_ntripc ( ntripc_t * ntripc,
char * msg )
static

Definition at line 2353 of file mrtk_stream.c.

References ntripc_con_t::buff, tcpsvr_tag::cli, ntripc_t::con, discon_ntripc(), errsock(), MAXCLI, ntripc_con_t::nb, NTRIP_MAXRSP, recv_nb(), rsp_ntripc(), tcp_t::sock, ntripc_con_t::state, ntripc_t::state, tcp_t::state, tcpsvr_tag::svr, ntripc_t::tcp, tracet(), and waittcpsvr().

Referenced by readntripc(), and writentripc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ waitntrip()

int waitntrip ( ntrip_t * ntrip,
char * msg )
static

Definition at line 1815 of file mrtk_stream.c.

References ntrip_t::buff, ntrip_t::nb, NTRIP_MAXRSP, NTRIP_VER_AUTO, readtcpcli(), reqntrip_c(), reqntrip_s(), rspntrip_c(), rspntrip_s(), ntrip_t::state, tcp_t::state, tcpcli_t::svr, ntrip_t::tcp, tracet(), ntrip_t::type, ntrip_t::v2_tried, ntrip_t::ver, and ntrip_t::ver_neg.

Referenced by readntrip(), and writentrip().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ waittcpcli()

int waittcpcli ( tcpcli_t * tcpcli,
char * msg )
static

Definition at line 1384 of file mrtk_stream.c.

References consock(), discontcp(), gentcp(), tcp_t::sock, tcp_t::state, tcpcli_t::svr, tcp_t::tact, tickget(), tcpcli_t::tirecon, tcpcli_t::toinact, and tracet().

Referenced by readtcpcli(), and writetcpcli().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ waittcpsvr()

int waittcpsvr ( tcpsvr_t * tcpsvr,
char * msg )
static

Definition at line 1211 of file mrtk_stream.c.

References accsock(), tcp_t::sock, tcp_t::state, tcpsvr_tag::svr, tracet(), and updatetcpsvr().

Referenced by readtcpsvr(), wait_ntripc(), and writetcpsvr().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writefile()

int writefile ( file_t * file,
uint8_t * buff,
int n,
char * msg )
static

Definition at line 759 of file mrtk_stream.c.

References file_t::fp, file_t::fp_tag, file_t::fp_tag_tmp, file_t::fp_tmp, fswapmargin, file_t::size_fpos, swapclose(), swapfile(), file_t::swapintv, file_t::tick, tickget(), gtime_t::time, time2gpst(), timeadd(), timeget(), tracet(), utc2gpst(), and file_t::wtime.

Referenced by strwrite().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writemembuf()

int writemembuf ( membuf_t * membuf,
uint8_t * buff,
int n,
char * msg )
static

Definition at line 2995 of file mrtk_stream.c.

References membuf_t::buf, membuf_t::bufsize, membuf_t::lock, membuf_t::rp, rtk_lock, rtk_unlock, membuf_t::state, tracet(), and membuf_t::wp.

Referenced by strwrite().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writentrip()

int writentrip ( ntrip_t * ntrip,
uint8_t * buff,
int n,
char * msg )
static

Definition at line 2079 of file mrtk_stream.c.

References chunk_encode(), NTRIP_VER_2, ntrip_t::tcp, tracet(), ntrip_t::type, ntrip_t::ver_neg, waitntrip(), and writetcpcli().

Referenced by strwrite().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writentripc()

int writentripc ( ntripc_t * ntripc,
uint8_t * buff,
int n,
char * msg )
static

Definition at line 2418 of file mrtk_stream.c.

References chunk_encode(), tcpsvr_tag::cli, ntripc_t::con, discon_ntripc(), errsock(), MAXCLI, send_nb(), tcp_t::sock, ntripc_con_t::state, tcp_t::tact, ntripc_t::tcp, tickget(), tracet(), ntripc_con_t::ver, and wait_ntripc().

Referenced by strwrite().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeserial()

int writeserial ( serial_t * serial,
uint8_t * buff,
int n,
char * msg )
static

Definition at line 405 of file mrtk_stream.c.

References serial_t::dev, serial_t::error, and tracet().

Referenced by strwrite().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writetcpcli()

int writetcpcli ( tcpcli_t * tcpcli,
uint8_t * buff,
int n,
char * msg )
static

Definition at line 1438 of file mrtk_stream.c.

References discontcp(), errsock(), send_nb(), tcp_t::sock, tcp_t::state, tcpcli_t::svr, tcp_t::tact, tickget(), tcpcli_t::tirecon, tracet(), and waittcpcli().

Referenced by closentrip(), reqntrip_c(), reqntrip_s(), strwrite(), and writentrip().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writetcpsvr()

int writetcpsvr ( tcpsvr_t * tcpsvr,
uint8_t * buff,
int n,
char * msg )
static

Definition at line 1255 of file mrtk_stream.c.

References tcpsvr_tag::cli, discontcp(), errsock(), MAXCLI, send_nb(), tcp_t::sock, tcp_t::state, tcpsvr_tag::svr, tcp_t::tact, tickget(), ticonnect, tracet(), updatetcpsvr(), and waittcpsvr().

Referenced by readserial(), and strwrite().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeudpcli()

int writeudpcli ( udp_t * udpcli,
uint8_t * buff,
int n,
char * msg )
static

Definition at line 2639 of file mrtk_stream.c.

References udp_t::addr, udp_t::sock, and tracet().

Referenced by strwrite().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ buffsize

int buffsize = 32768
static

Definition at line 242 of file mrtk_stream.c.

Referenced by genudp(), rtksvrstart(), setsock(), and strsetopt().

◆ formatstrs

const char* formatstrs[32]
Initial value:
= {
"RTCM 2",
"RTCM 3",
"NovAtel OEM7",
"NovAtel OEM3",
"u-blox UBX",
"Superstar II",
"Hemisphere",
"SkyTraq",
"Javad GREIS",
"NVS BINR",
"BINEX",
"Trimble RT17",
"Septentrio SBF",
"RINEX",
"SP3",
"RINEX CLK",
"SBAS",
"NMEA 0183",
NULL}

Definition at line 80 of file mrtk_stream.c.

Referenced by setopt_file().

◆ fswapmargin

int fswapmargin = 30
static

Definition at line 247 of file mrtk_stream.c.

Referenced by strsetopt(), and writefile().

◆ localdir

char localdir[1024] = ""
static

Definition at line 243 of file mrtk_stream.c.

Referenced by ftpthread(), and strsetdir().

◆ ntrip_ver_default

int ntrip_ver_default = 0
static

Definition at line 245 of file mrtk_stream.c.

Referenced by parse_ntrip_query(), and strsetntripver().

◆ proxyaddr

char proxyaddr[256] = ""
static

Definition at line 244 of file mrtk_stream.c.

Referenced by ftpthread(), openntrip(), and strsetproxy().

◆ tick_master

uint32_t tick_master = 0
static

Definition at line 246 of file mrtk_stream.c.

Referenced by readfile().

◆ ticonnect

int ticonnect = 10000
static

Definition at line 240 of file mrtk_stream.c.

Referenced by discon_ntripc(), gentcp(), opentcpcli(), readtcpsvr(), strsetopt(), and writetcpsvr().

◆ tirate

int tirate = 1000
static

Definition at line 241 of file mrtk_stream.c.

Referenced by strread(), strsetopt(), and strwrite().

◆ toinact

int toinact = 10000
static

Definition at line 239 of file mrtk_stream.c.

Referenced by opentcpcli(), strsetopt(), and strsettimeout().