summaryrefslogtreecommitdiff
path: root/src/lib/dlt_user.c
Commit message (Collapse)AuthorAgeFilesLines
* Size of Resend buffer less than or equal to DLT_USER_BUF_MAX_SIZE res… (#116)kundatipradeep2019-04-151-1/+4
| | | | | | | * Size of Resend buffer less than or equal to DLT_USER_BUF_MAX_SIZE results in Memory corruption. As older version of DLT DLT_USER_RESENDBUF_MAX_SIZE is [DLT_USER_BUF_MAX_SIZE + 100] which contains space for extra headers, where as in DLT 2.18 the resend buffer is bound to DLT_USER_BUF_MAX_SIZE which results in memory corruption in dlt_buffer_read_block when the size of the data is more than DLT_USER_BUF_MAX_SIZE. Reason for not using "DLT_USER_RESENDBUF_MAX_SIZE" during dynamic memory allocation of resend buffer is as user has got the feasibility to alter the DLT_USER_BUF_MAX_SIZE using the environmental variables the resend buffer in any scenario to be greater then dlt_user.log_buf_len to accommodate the extra headers.
* Fixed memory leak when receiving network traces of 0xFFFF lengthjiripopek2019-04-111-2/+4
| | | | | | | | 0xFFFF was used as a magic number in the length field of a network message in order to trigger a resend. DLT library will now use the nw_trace_type field and a custom type to do this, thus assuring no external client of the library can reach this value(DLT_NW_TRACE_RESEND).
* lib: Add mq_close/mq_unlink conditionsSaya Sugiura2019-03-271-5/+12
| | | | | | | | | | Even if network trace is not used in the application, the library will call mq_close() and mq_unlink() to segmented queue handles and queue names, which triggers unnecessary close(). It is now modified to call mq_close() and mq_unlink() only when network trace is initialized. Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* libdlt: Do not allow DLT usage in forked child (#95)Simon Herkenhoff2019-02-041-36/+58
| | | | | | | | | | | | | DLT shall not be used in a forked child until a variant of exec() is called, because DLT is using non async-signal-safe functions. The forking process can continue to use libdlt's logging facilities, but any attempt to use libdlt from the forked child will be denied. The fork-handler test is updated to reflect this by trying to log from the forked child which will fail. The fork then calls exec and runs another application that can continue to use DLT. Signed-off-by: Simon Herkenhoff <sherkenhoff@jp.adit-jv.com>
* Code beautification using uncrustifyChristoph Lipka2018-12-211-1734/+1358
| | | | Signed-off-by: Christoph Lipka <clipka@de.adit-jv.com>
* Cleanup of unit test fixesManikandan C2018-12-211-18/+10
| | | | Signed-off-by: Manikandan C <mchockalingam@de.adit-jv.com>
* libdlt: Add error handlingSaya Sugiura2018-12-211-70/+126
| | | | | | | Error handling was added in case it failed to send to daemon. Signed-off-by: S. Hameed <shameed@jp.adit-jv.com> Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* UnitTest: UpdatesManikandanC2018-12-211-34/+42
| | | | | | | | | | | | Gateway Logstorage Event Handler Signed-off-by: Christoph Lipka <clipka@de.adit-jv.com> Signed-off-by: S. Hameed <shameed@jp.adit-jv.com> Signed-off-by: Aditya Paluri <venkataaditya.paluri@in.bosch.com> Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com> Signed-off-by: ManikandanC <Manikandan.Chockalingam@in.bosch.com>
* lib: socket: Flush all data before closing socketSaya Sugiura2018-12-211-1/+35
| | | | | | | | | | | | | | Sometimes socket will be closed even not all of the data is flushed to daemon. So before closing, following will be handled: 1. Use shutdown() to shut down further transmissions 2. Subsequent read() to resend_buffer Also socket fd is reset in child fork handler since the socket itself will not be duplicated in the child process. Solves JIRA: SWGIII-28702 Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* Removed log level change callback notification while context register done ↵Ravi Sankar P2018-12-211-2/+2
| | | | | | with ll_ts API Signed-off-by: Ravi Sankar P <ponnurangamravi.sankar@in.bosch.com>
* Logging: avoided missing of log level change callback Added new context ↵Manikandan C2018-12-211-146/+205
| | | | | | registration Macro and API which has option to register log level change callback along with it. This will avoid missing of initial log level change callback when daemon sends the log level change control msg during context registration Signed-off-by: ManikandanC <Manikandan.Chockalingam@in.bosch.com>
* Injection: New callback with private data Added new injection callback with ↵ManikandanC2018-12-211-18/+66
| | | | | | private data as argument Signed-off-by: ManikandanC <Manikandan.Chockalingam@in.bosch.com>
* Dynamic allocation of msg bufferManikandanC2018-12-101-170/+284
| | | | | | | | | | | | | It is possible to change the default buffer size for log message creation via environment variable: export DLT_LOG_MSG_BUF_LEN=<value> Instead of using a static buffer with size of 1390 bytes, the buffer is allocated dynamically with the specified value.The max size is restricted to approx 65k. Signed-off-by: Christoph Lipka <clipka@de.adit-jv.com> Signed-off-by: ManikandanC <Manikandan.Chockalingam@in.bosch.com>
* Use poll in the dlt-daemon for POSIX complianceManikandanC2018-11-301-8/+38
| | | | | | | | | | | The poll system call is now used in the daemon to enable DLT use in POSIX compliant systems. Also added introduced new unregister_app macro to avoid missing of logs in startup buffer. Signed-off-by: Frederic Berat <fberat@de.adit-jv.com> Signed-off-by: ManikandanC <Manikandan.Chockalingam@in.bosch.com> Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com> Signed-off-by: S. Hameed <shameed@jp.adit-jv.com>
* Update dlt_user.c (#66)kundatipradeep2018-08-241-0/+13
| | | | In dlt_user_log_send_log and dlt_forward_msg API's when writing the data to DLT PIPE is not successful in scenario which returns "DLT_RETURN_PIPE_ERROR"(Non availability of dlt pipe post termination of DLT DAEMON) it ideally starts stores the data in internal buffer, and close the dlt user handle, which is quiet appropriate. The scenario were dlt application fails in writing data to dlt pipe returns DLT_RETURN_PIPE_ERROR and case were application buffer is full, the return value DLT_RETURN_PIPE_ERROR is over written to "DLT_RETURN_BUFFER_FULL" were dlt user handle will not be reset to -1, it till holds the former data which causes undefined behavior of dlt application(One behavior would be which calls dlt_user_queue_resend and internally allocates memory for segmented data and tries to free it at dlt_user_trace_network_segmented_thread which is not intended behavior, instead return silently when FIFO is not available)
* libdlt: Avoid busy loop in error case of mq_receive() (#59)Yusuke Sato2018-05-291-1/+13
| | | | | | | To avoid busy loop due to error of mq_receive() which is called in sub thread, 100ms sleep is added for the error case. Error log message for mq_receive() is also corrected to have errno. Signed-off-by: Yusuke Sato <yusuke-sato@apn.alpine.co.jp>
* IPC: Unix socket added (#43)ManikandanChockalingam2018-05-181-113/+208
| | | | | | | | | * IPC: Unix socket added The user can select either FIFO or UNIX socket as IPC between user library and daemon through CMakelist option. Socket path configurable for both FIFO and Unix Socket now configurable in CMake Signed-off-by: Christoph Lipka <clipka@de.adit-jv.com> Signed-off-by: ManikandanC <Manikandan.Chockalingam@in.bosch.com>
* minor compiler warning gcc 7.x (#30)Phong Tran2018-03-291-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * Fix -Wpointer-compare of compare with null char Signed-off-by: Phong Tran <tranmanphong@gmail.com> * dlt_common: fix -Wformat-truncation of snprintf Avoid snprintf output truncation by handling return value Signed-off-by: Phong Tran <tranmanphong@gmail.com> * dlt_offline_trace: Fix Wformat-truncation of snprintf Compile with Gcc 7.x has the warning of snprintf buffer length size. Check return value of snprintf() for avoiding the warning. Signed-off-by: Phong Tran <tranmanphong@gmail.com> * dlt_common_test: Fix memleak t_dlt_message_read some resources were not free after using. Detected by running valgrind --leak-check=full ./gtest_dlt_common Signed-off-by: Phong Tran <tranmanphong@gmail.com>
* Fix for initialization of buffer settings in DLT user library. (#25)baduras2017-09-131-2/+2
|
* CMake Option: Trigger segmentation fault in case of FATAL logChristoph Lipka2017-02-021-0/+14
| | | | | | | | When the user library receives a log with log level DLT_LOG_FATAL it triggers a segmentation fault to provide information to the developer via tools like coredump. Signed-off-by: Christoph Lipka <clipka@jp.adit-jv.com>
* Environment variables for library ringbufferChristoph Lipka2016-10-241-1/+51
| | | | | | | | | | | | This patch adds environment variables to configure user library ringbuffer and step size. The following variables can be set: DLT_USER_BUFFER_MIN - for minimal size DLT_USER_BUFFER_MAX - for maximal size DLT_USER_BUFFER_STEP - for step size Signed-off-by: Christoph Lipka <clipka@jp.adit-jv.com>
* DLT_PTR macro: Improve implementation and function API addedChristoph Lipka2016-10-241-0/+32
| | | | | | | | The original implementation result in a compile error when DLT_PTR is used with other macros like DLT_STRING. This patch overcomes that problem. Signed-off-by: Christoph Lipka <clipka@jp.adit-jv.com>
* Fix: Memory for context description is not freedYusuke Sato2016-09-231-0/+18
| | | | | | | | Currently, allocated memory for context description is not freed in dlt_free(). free() for each member variables of dlt_user.dlt_ll_ts[i] is added in the for block in dlt_free(). Signed-off-by: Yusuke Sato <yusuke-sato@apn.alpine.co.jp> Change-Id: I52a81cf2918cb0014fdcfc666cb8bb93ca7cb525
* Fix: Handle of /tmp/dlt never reset if dlt-daemon is killed during output ↵Yusuke Sato2016-09-231-1/+1
| | | | | | | | | | user buffer Handle of /tmp/dlt cannot be reset if dlt-daemon is killed during output user buffer because dlt_user_log_resend_buffer() never returns DLT_RETURN_PIPE_ERROR. Return value of dlt_user_log_resend_buffer() is modified to pass return value of dlt_user_log_out3() without change. Signed-off-by: Yusuke Sato <yusuke-sato@apn.alpine.co.jp> Change-Id: I506103ebebcdb3c145d1f0719a3c8caffc8d89c1
* Fix: Segfault in checking buffer usageYusuke Sato2016-09-231-0/+3
| | | | | | | | Segfault is caused by dlt_user_check_buffer() if this function is called during increasing the user buffer. To avoid this issue, semaphore has to be added. Signed-off-by: Yusuke Sato <yusuke-sato@apn.alpine.co.jp> Change-Id: Ie56f2fb73aeacb835180468e57c9338d2ffdb072
* Add dlt_user_is_logLevel_enabled APIChristoph Lipka2016-09-231-1/+1
| | | | | | | | | | This function allows an application developer to check if the DLT LogLevel is enabled before starting any log string creation. It can be used in application specific logging wrapper functions. Signed-off-by: Christoph Lipka <clipka@jp.adit-jv.com> Change-Id: I4c269b12bfdeae29a4e795385cdbc54a579ba621
* Fixed D-Bus tracing not working anymoreAlexander Wenzel2016-05-131-1/+1
| | | | | | | Signed-off-by: Alexander Wenzel <Alexander.AW.Wenzel@bmw.de> Topic: GENDLT-425 Change-Id: I4ec56d714804d9ee4fa904b71c58dafd00990b4f
* Fixed not working default log level.Alexander Wenzel2016-05-031-8/+12
| | | | | | Signed-off-by: Alexander Wenzel <Alexander.AW.Wenzel@bmw.de> Change-Id: Id01c9a11e4b5ccf4166f10c5e45363f3a7c00535
* Fixed not returning the correct number of lost messages at exit.Alexander Wenzel2016-05-031-1/+5
| | | | | | Signed-off-by: Alexander Wenzel <Alexander.AW.Wenzel@bmw.de> Change-Id: I211222d04350820098bf56dfc5b7aee50e2529f0
* DLT_RETURN_USER_BUFFER_FULL is returned when user buffer fullLutz Helwing2016-04-221-113/+59
| | | | | | | | | A new return value DLT_RETURN_USER_BUFFER_FULL is introduced which is returned by all dlt_user_log_write_* and dlt_log_* functions when the data to be added to the user buffer exceeds its size (datasize > DLT_USER_BUF_MAX_SIZE) Signed-off-by: Lutz Helwing <lutz_helwing@mentor.com>
* Revert truncation of string or raw blockLutz Helwing2016-04-221-26/+16
| | | | | | | | | | | | | | | Commit d319ebf4d2d449d70befae0eebbdd82c19c5315f introduced new handling of the situation when writing data to the user buffer would exceed its size. This was achieved by truncating the data to fit. This solution had a problem: It could lead to a buffer overflow when the updated arg_size gets negative (actually undefined value because it is unsigned). As a quick fix the behaviour is reverted to the state before the aforementioned commit. Signed-off-by: Lutz Helwing <lutz_helwing@mentor.com>
* Fix bug with truncation of string or raw blockLutz Helwing2016-02-251-46/+33
| | | | | | | | With commit d319ebf4d2d449d70befae0eebbdd82c19c5315f a bug was introduces which lead to some messages getting not transmitted. Change-Id: I9f20177fbc7db9d7caf527e14159444b5fec168a Signed-off-by: Lutz Helwing <lutz_helwing@mentor.com>
* Truncate of string or raw block, if length exceeds maximum message lengthLutz Helwing2016-02-191-46/+65
| | | | | | | | | | | | | Previously if messages containing strings or raw data were exceeding the maximum message size (DLT_USER_BUF_MAX_SIZE, currently set to 1390) they were discarded completely. This behaviour is changed so that too large data is truncated and sent anyway. Commented out part of unit test for dlt_log_raw abnormal where negative values for unsigned length were passed. Change-Id: I4f6bf152e7125924717c941ad7ebb8fd79787715 Signed-off-by: Lutz Helwing <lutz_helwing@mentor.com>
* Fix fork()-handler in libdltStefan Vacek2015-12-091-7/+21
| | | | Signed-off-by: Stefan Vacek <stefan.vacek@intel.com>
* Set default log-levels in dlt.confStefan Vacek2015-12-091-1/+3
| | | | | | | | - feature: allow to define a default-log-level in dlt.conf (see dlt.conf for documentation) - bugfix: make dlt_unlock_mutex not inline to fix linkage - bugfix: initial log-level was not set correctly when no dlt-daemon was running Signed-off-by: Stefan Vacek <stefan.vacek@intel.com>
* Fix register context before application is registeredStefan Vacek2015-12-081-10/+1
| | | | | | | | Additional: - include sd-daemon.h if watchdog is enabled - fix formatting for printf 64bit values Signed-off-by: Stefan Vacek <stefan.vacek@intel.com>
* Got rid of warnings from some older compilersLutz Helwing2015-10-281-5/+10
| | | | Signed-off-by: Alexander Wenzel <Alexander.AW.Wenzel@bmw.de>
* DLT daemon improvement - dlt_init()-checkLutz Helwing2015-10-071-1191/+1254
| | | | | | | | | | DLT daemon improvement - parameter value range check Adapt unit tests to check for enum return values Changed C version to gnu99 and C++ version to gnu++0c Signed-off-by: Alexander Wenzel <Alexander.AW.Wenzel@bmw.de>
* Make timeout on exit configurableStefan Vacek2015-10-071-1/+17
| | | | | | | | | - make timeout in at_exit handler configurable (was hardcoded to 10s), new api: int dlt_set_resend_timeout_atexit(uint32_t timeout_in_milliseconds); - add option -t to dlt-adaptor-stdin to set timeout in at_exit_handler - add option -t to dlt-example-user to set timeout in at_exit_handler Signed-off-by: Stefan Vacek <stefan.vacek@intel.com>
* Allow multiple instances of dlt-daemonStefan Vacek2015-10-071-13/+27
| | | | | | | | | | | | | | | | - Make dlt-daemon configurable to specify directory of fifos and port of dlt-daemon, this allows to run multiple instances of dlt-daemon at one node at the same time. This is useful in testing environment where simultanous tests should not interfere due to the same instance of dlt-daemon - dlt-daemon: add option -t <dir> to specify a directory where all fifos will be created - dlt-daemon: add option -p <port> to specify the port under which dlt-daemon can be connected - client-library: add environment variable DLT_PIPE_DIR to specify a non-default directory of fifos for logging applications - client-library: add environment variable DLT_DAEMON_TCP_PORT to specify the port under which dlt-daemon can be reached (especially when using dlt-receive) Signed-off-by: Stefan Vacek <stefan.vacek@intel.com> Signed-off-by: Lutz Helwing <lutz_helwing@mentor.com>
* Fixed whitespace and formatting of new code Fixed licence headersLutz Helwing2015-10-071-126/+132
| | | | Signed-off-by: Alexander Wenzel <Alexander.AW.Wenzel@bmw.de>
* Allow registration of contexts before application is registeredStefan Vacek2015-10-071-34/+60
| | | | Signed-off-by: Stefan Vacek <stefan.vacek@intel.com>
* Add env-var to set initial log-levelsStefan Vacek2015-10-071-20/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | name of environment variable: DLT_INITIAL_LOG_LEVEL Syntax: <apid1>:<ctid1>:<loglevel1>;<apid2>:<ctid2>:<loglevel2>;... apid: application id (up to 4 chars), if empty all applications will match ctid: context id (up to 4 chars), if empty all contexts will match loglevel: either -1..6 or a symbolic name (default, off, fatal, error, warning, info, debug, verbose) Examples: DLT_INITIAL_LOG_LEVEL=TEST:LOG:0 -> turn off logging for appid TEST and contextid LOG DLT_INITIAL_LOG_LEVEL=:LOG:warn -> for contexts with name "LOG" set log-level to warning (3) DLT_INITIAL_LOG_LEVEL=::VERBOSE -> set log-level of all contexts to VERBOSE DLT_INITIAL_LOG_LEVEL=::VERBOSE;TEST:LOG:3 -> set log-level of all contexts to VERBOSE except TEST:LOG, set this to WARNING dlt-example-user: add option -l to specify log-level to be used when sending messages Signed-off-by: Stefan Vacek <stefan.vacek@intel.com>
* Allow applications to fork()Stefan Vacek2015-10-071-48/+172
| | | | | | | | - if fork() is called from an application, dlt is reset and user application needs to re-register application and contexts in child-process Signed-off-by: Stefan Vacek <stefan.vacek@intel.com>
* Removed all trailing whitespacesLutz Helwing2015-07-211-26/+26
| | | | Signed-off-by: Alexander Wenzel <Alexander.AW.Wenzel@bmw.de>
* Rework of unit tests in gtest_dlt_userStefan Held2015-07-211-6/+26
| | | | | | | Fix all nullpointer errors in dlt_user.c Signed-off-by: Stefan Held <stefan_held@mentor.com> Signed-off-by: Alexander Wenzel <Alexander.AW.Wenzel@bmw.de>
* Fixed license headers and copyright doxygen commentsLutz Helwing2015-06-171-2/+2
| | | | Signed-off-by: Alexander Wenzel <Alexander.AW.Wenzel@bmw.de>
* Updated license headers to latest GENIVI license policy. Fixed further LRT ↵Lutz Helwing2015-06-171-11/+15
| | | | | | Scan findings. Renamed and cleanup further files. Signed-off-by: Alexander Wenzel <Alexander.AW.Wenzel@bmw.de>
* Open daemon connection in atexit functionSascha Philipp2015-03-251-11/+38
| | | | | Change-Id: I43f1a3b541720d1ae06912cc5d1026daa077245a Signed-off-by: Sascha Philipp <sascha.philipp@continental-corporation.com>
* Change loglevel of Request-Resend messageSascha Philipp2015-03-251-1/+1
| | | | | Change-Id: I82cf88ebc0503aae6f88ff1b407b18b5c9052d0a Signed-off-by: Sascha Philipp <sascha.philipp@continental-corporation.com>