automotive-dlt
|
#include <pthread.h>
#include <unistd.h>
#include <libgen.h>
#include <dirent.h>
#include <zlib.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include "dlt-system.h"
#include "dlt.h"
#include "dlt_filetransfer.h"
Go to the source code of this file.
Macros | |
#define | Z_CHUNK_SZ 1024*128 |
#define | COMPRESS_EXTENSION ".gz" |
#define | SUBDIR_COMPRESS ".tocompress" |
#define | SUBDIR_TOSEND ".tosend" |
Functions | |
uint32_t | getFileSerialNumber (const char *file, int *ok) |
Get some information about the file serial number of a file. More... | |
DLT_IMPORT_CONTEXT (dltsystem) | |
char * | unique_name (char *src) |
void | send_dumped_file (FiletransferOptions const *opts, char *dst_tosend) |
int | compress_file_to (char *src, char *dst, int level) |
int | send_one (char *src, FiletransferOptions const *opts, int which) |
Sends one file over DLT. More... | |
int | flush_dir_send (FiletransferOptions const *opts, const char *compress_dir, const char *send_dir) |
int | flush_dir_compress (FiletransferOptions const *opts, int which, const char *compress_dir, const char *send_dir) |
int | flush_dir_original (FiletransferOptions const *opts, int which) |
int | flush_dir (FiletransferOptions const *opts, int which) |
Cleans the surveyed directories and subdirectories. Sends residing files into trace. More... | |
int | init_filetransfer_dirs (FiletransferOptions const *opts) |
Initializes the surveyed directories. More... | |
int | wait_for_files (FiletransferOptions const *opts) |
void | filetransfer_thread (void *v_conf) |
void | start_filetransfer (DltSystemConfiguration *conf) |
Variables | |
DltSystemThreads | threads |
Definition in file dlt-system-filetransfer.c.
#define COMPRESS_EXTENSION ".gz" |
Definition at line 76 of file dlt-system-filetransfer.c.
Referenced by flush_dir_compress(), flush_dir_send(), and send_one().
#define SUBDIR_COMPRESS ".tocompress" |
Definition at line 77 of file dlt-system-filetransfer.c.
Referenced by flush_dir(), init_filetransfer_dirs(), and send_one().
#define SUBDIR_TOSEND ".tosend" |
Definition at line 78 of file dlt-system-filetransfer.c.
Referenced by flush_dir(), init_filetransfer_dirs(), and send_one().
#define Z_CHUNK_SZ 1024*128 |
Definition at line 75 of file dlt-system-filetransfer.c.
Referenced by compress_file_to().
int compress_file_to | ( | char * | src, |
char * | dst, | ||
int | level | ||
) |
compress file, delete the source file modification: compress into subdirectory File whis is compress will be deleted afterwards
src | File to be sent |
dst | destination where to compress the file |
level | of compression |
Definition at line 191 of file dlt-system-filetransfer.c.
References DLT_LOG, DLT_LOG_DEBUG, DLT_LOG_WARN, DLT_STRING, MALLOC_ASSERT, NULL, and Z_CHUNK_SZ.
Referenced by flush_dir_compress(), and send_one().
DLT_IMPORT_CONTEXT | ( | dltsystem | ) |
Definition at line 86 of file dlt-system-filetransfer.c.
References DLT_LOG, DLT_LOG_ERROR, DLT_STRING, DLT_SYSTEM_LOG_DIRS_MAX, and NULL.
void filetransfer_thread | ( | void * | v_conf | ) |
Definition at line 721 of file dlt-system-filetransfer.c.
References FiletransferOptions::ContextId, DLT_LOG, DLT_LOG_DEBUG, DLT_LOG_ERROR, DLT_REGISTER_CONTEXT, DLT_STRING, DltSystemConfiguration::Filetransfer, init_filetransfer_dirs(), DltSystemThreads::shutdown, FiletransferOptions::TimeDelay, FiletransferOptions::TimeStartup, and wait_for_files().
Referenced by start_filetransfer().
int flush_dir | ( | FiletransferOptions const * | opts, |
int | which | ||
) |
Cleans the surveyed directories and subdirectories. Sends residing files into trace.
opts | FiletransferOptions |
which | which directory is affected -> position in list of opts->Directory |
Definition at line 556 of file dlt-system-filetransfer.c.
References FiletransferOptions::Directory, DLT_LOG, DLT_LOG_DEBUG, DLT_STRING, flush_dir_compress(), flush_dir_original(), flush_dir_send(), MALLOC_ASSERT, SUBDIR_COMPRESS, and SUBDIR_TOSEND.
Referenced by init_filetransfer_dirs().
int flush_dir_compress | ( | FiletransferOptions const * | opts, |
int | which, | ||
const char * | compress_dir, | ||
const char * | send_dir | ||
) |
Definition at line 457 of file dlt-system-filetransfer.c.
References COMPRESS_EXTENSION, compress_file_to(), FiletransferOptions::CompressionLevel, DLT_LOG, DLT_LOG_DEBUG, DLT_LOG_ERROR, DLT_STRING, MALLOC_ASSERT, NULL, and send_dumped_file().
Referenced by flush_dir().
int flush_dir_original | ( | FiletransferOptions const * | opts, |
int | which | ||
) |
Definition at line 511 of file dlt-system-filetransfer.c.
References FiletransferOptions::Directory, DLT_LOG, DLT_LOG_DEBUG, DLT_LOG_ERROR, DLT_STRING, MALLOC_ASSERT, NULL, and send_one().
Referenced by flush_dir().
int flush_dir_send | ( | FiletransferOptions const * | opts, |
const char * | compress_dir, | ||
const char * | send_dir | ||
) |
Definition at line 365 of file dlt-system-filetransfer.c.
References COMPRESS_EXTENSION, DLT_LOG, DLT_LOG_DEBUG, DLT_LOG_ERROR, DLT_STRING, MALLOC_ASSERT, NULL, and send_dumped_file().
Referenced by flush_dir().
uint32_t getFileSerialNumber | ( | const char * | file, |
int * | ok | ||
) |
Get some information about the file serial number of a file.
See stat(2) for more informations.
file | Absolute file path |
value | *ok == 0 -> error; *ok == 1 -> ok |
Definition at line 124 of file dlt_filetransfer.c.
References stringHash().
Referenced by dlt_user_log_file_data(), dlt_user_log_file_end(), dlt_user_log_file_errorMessage(), dlt_user_log_file_header(), dlt_user_log_file_header_alias(), dlt_user_log_file_infoAbout(), and unique_name().
int init_filetransfer_dirs | ( | FiletransferOptions const * | opts | ) |
Initializes the surveyed directories.
On startup, the inotifiy handlers are created, and existing files shall be sent into DLT stream
opts | FiletransferOptions |
Definition at line 605 of file dlt-system-filetransfer.c.
References FiletransferOptions::Count, FiletransferOptions::Directory, DLT_INT, DLT_LOG, DLT_LOG_DEBUG, DLT_LOG_ERROR, DLT_LOG_FATAL, DLT_STRING, flush_dir(), MALLOC_ASSERT, SUBDIR_COMPRESS, and SUBDIR_TOSEND.
Referenced by filetransfer_thread().
void send_dumped_file | ( | FiletransferOptions const * | opts, |
char * | dst_tosend | ||
) |
Function which only calls the relevant part to transfer the payload
Definition at line 141 of file dlt-system-filetransfer.c.
References dlt_get_log_state(), DLT_LOG, DLT_LOG_DEBUG, DLT_STRING, dlt_user_check_buffer(), dlt_user_log_file_data(), dlt_user_log_file_end(), dlt_user_log_file_header_alias(), dlt_user_log_file_packagesCount(), dlt_user_log_resend_buffer(), NULL, and FiletransferOptions::TimeoutBetweenLogs.
Referenced by flush_dir_compress(), flush_dir_send(), and send_one().
int send_one | ( | char * | src, |
FiletransferOptions const * | opts, | ||
int | which | ||
) |
Sends one file over DLT.
If configured in opts, compresses it, then sends it. uses subdirecties for compressing and before sending, to avoid that those files get changed in the meanwhile
Definition at line 252 of file dlt-system-filetransfer.c.
References COMPRESS_EXTENSION, compress_file_to(), FiletransferOptions::Compression, FiletransferOptions::CompressionLevel, DLT_LOG, DLT_LOG_DEBUG, DLT_LOG_ERROR, DLT_STRING, MALLOC_ASSERT, NULL, send_dumped_file(), SUBDIR_COMPRESS, SUBDIR_TOSEND, FiletransferOptions::TimeDelay, and unique_name().
Referenced by flush_dir_original(), and wait_for_files().
void start_filetransfer | ( | DltSystemConfiguration * | conf | ) |
Definition at line 744 of file dlt-system-filetransfer.c.
References DltSystemThreads::count, DLT_LOG, DLT_LOG_DEBUG, DLT_STRING, filetransfer_thread(), and DltSystemThreads::threads.
Referenced by start_threads().
char* unique_name | ( | char * | src | ) |
Definition at line 110 of file dlt-system-filetransfer.c.
References DLT_LOG, DLT_LOG_DEBUG, DLT_LOG_WARN, DLT_STRING, getFileSerialNumber(), MALLOC_ASSERT, and NULL.
Referenced by send_one().
int wait_for_files | ( | FiletransferOptions const * | opts | ) |
Definition at line 673 of file dlt-system-filetransfer.c.
References FiletransferOptions::Count, FiletransferOptions::Directory, DLT_INT, DLT_LOG, DLT_LOG_DEBUG, DLT_LOG_ERROR, DLT_STRING, and send_one().
Referenced by filetransfer_thread().
DltSystemThreads threads |
Definition at line 58 of file dlt-system-process-handling.c.
Referenced by logfile_thread(), and start_logfile().