Bug 44 - Don't print "Buffer full" message from DLT daemon for each trace.
[profile/ivi/dlt-daemon.git] / src / daemon / dlt_daemon_common.h
old mode 100755 (executable)
new mode 100644 (file)
index 1870295..b93f0c2
@@ -1,37 +1,22 @@
-/*\r
- * Dlt- Diagnostic Log and Trace daemon\r
- * @licence app begin@
- *
- * Copyright (C) 2011, BMW AG - Alexander Wenzel <alexander.wenzel@bmw.de>
- * 
- * This program is free software; you can redistribute it and/or modify it under the terms of the 
- * GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 
- * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General 
- * Public License, version 2.1, for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public License, version 2.1, along 
- * with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
- * 
- * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may 
- * also be applicable to programs even in cases in which the program is not a library in the technical sense.
- * 
- * Linking DLT statically or dynamically with other modules is making a combined work based on DLT. You may 
- * license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to 
- * license your linked modules under the GNU Lesser General Public License, version 2.1, you 
- * may use the program under the following exception.
- * 
- * As a special exception, the copyright holders of DLT give you permission to combine DLT 
- * with software programs or libraries that are released under any license unless such a combination is not
- * permitted by the license of such a software program or library. You may copy and distribute such a 
- * system following the terms of the GNU Lesser General Public License, version 2.1, including this
- * special exception, for DLT and the licenses of the other code concerned.
- * 
- * Note that people who make modified versions of DLT are not obligated to grant this special exception 
- * for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, 
- * version 2.1, gives permission to release a modified version without this exception; this exception 
- * also makes it possible to release a modified version which carries forward this exception.
- *
+/**\r
+ * @licence app begin@\r
+ * Copyright (C) 2012  BMW AG\r
+ *\r
+ * This file is part of GENIVI Project Dlt - Diagnostic Log and Trace console apps.\r
+ *\r
+ * Contributions are licensed to the GENIVI Alliance under one or more\r
+ * Contribution License Agreements.\r
+ *\r
+ * \copyright\r
+ * This Source Code Form is subject to the terms of the\r
+ * Mozilla Public License, v. 2.0. If a  copy of the MPL was not distributed with\r
+ * this file, You can obtain one at http://mozilla.org/MPL/2.0/.\r
+ *\r
+ *\r
+ * \author Alexander Wenzel <alexander.aw.wenzel@bmw.de> BMW 2011-2012\r
+ *\r
+ * \file dlt_daemon_common.h\r
+ * For further information see http://www.genivi.org/.\r
  * @licence end@\r
  */\r
 \r
@@ -88,6 +73,7 @@
   \{\r
 */\r
 \r
+#include <limits.h>\r
 #include <semaphore.h>\r
 #include "dlt_common.h"\r
 #include "dlt_user.h"\r
@@ -96,9 +82,9 @@
 extern "C" {\r
 #endif\r
 \r
-#define DLT_DAEMON_RINGBUFFER_MIN_SIZE  100000 /**< Ring buffer size for storing log messages while no client is connected */\r
-#define DLT_DAEMON_RINGBUFFER_MAX_SIZE  500000 /**< Ring buffer size for storing log messages while no client is connected */\r
-#define DLT_DAEMON_RINGBUFFER_STEP_SIZE 100000 /**< Ring buffer size for storing log messages while no client is connected */\r
+#define DLT_DAEMON_RINGBUFFER_MIN_SIZE    500000 /**< Ring buffer size for storing log messages while no client is connected */\r
+#define DLT_DAEMON_RINGBUFFER_MAX_SIZE  10000000 /**< Ring buffer size for storing log messages while no client is connected */\r
+#define DLT_DAEMON_RINGBUFFER_STEP_SIZE   500000 /**< Ring buffer size for storing log messages while no client is connected */\r
 \r
 #define DLT_DAEMON_STORE_TO_BUFFER -2   /**< Constant value to identify the command "store to buffer" */\r
 \r
@@ -147,16 +133,18 @@ typedef struct
        int8_t default_log_level;          /**< Default log level (of daemon) */\r
        int8_t default_trace_status;       /**< Default trace status (of daemon) */\r
        int message_buffer_overflow;   /**< Set to one, if buffer overflow has occured, zero otherwise */\r
+       unsigned int overflow_counter;   /**< counts the number of lost messages. */\r
        int runtime_context_cfg_loaded;         /**< Set to one, if runtime context configuration has been loaded, zero otherwise */\r
        char ecuid[DLT_ID_SIZE];       /**< ECU ID of daemon */\r
        int sendserialheader;          /**< 1: send serial header; 0 don't send serial header */\r
        int timingpackets;              /**< 1: send continous timing packets; 0 don't send continous timing packets */\r
        DltBuffer client_ringbuffer; /**< Ring-buffer for storing received logs while no client connection is available */\r
-       char runtime_application_cfg[256]; /**< Path and filename of persistent application configuration */\r
-       char runtime_context_cfg[256]; /**< Path and filename of persistent context configuration */\r
-       char runtime_configuration[256]; /**< Path and filename of persistent configuration */\r
+    char runtime_application_cfg[PATH_MAX + 1]; /**< Path and filename of persistent application configuration. Set to path max, as it specifies a full path*/\r
+    char runtime_context_cfg[PATH_MAX + 1]; /**< Path and filename of persistent context configuration */\r
+    char runtime_configuration[PATH_MAX + 1]; /**< Path and filename of persistent configuration */\r
     DltUserLogMode mode;       /**< Mode used for tracing: off, external, internal, both */\r
     char state;                                /**< state for tracing: 0 = no client connected, 1 = client connected */\r
+    char *ECUVersionString; /**< Version string to send to client. Loaded from a file at startup. May be null. */\r
 } DltDaemon;\r
 \r
 /**\r
@@ -219,6 +207,14 @@ int dlt_daemon_applications_load(DltDaemon *daemon,const char *filename, int ver
  */\r
 int dlt_daemon_applications_save(DltDaemon *daemon,const char *filename, int verbose);\r
 /**\r
+ * Invalidate all applications fd, if fd is reused\r
+ * @param daemon pointer to dlt daemon structure\r
+ * @param fd file descriptor\r
+ * @param verbose if set to true verbose information is printed out.\r
+ * @return negative value if there was an error\r
+ */\r
+int dlt_daemon_applications_invalidate_fd(DltDaemon *daemon,int fd,int verbose);\r
+/**\r
  * Clear all applications in internal application management\r
  * @param daemon pointer to dlt daemon structure\r
  * @param verbose if set to true verbose information is printed out.\r
@@ -258,6 +254,14 @@ int dlt_daemon_context_del(DltDaemon *daemon, DltDaemonContext* context, int ver
  */\r
 DltDaemonContext* dlt_daemon_context_find(DltDaemon *daemon,char *apid,char *ctid,int verbose);\r
 /**\r
+ * Invalidate all contexts fd, if fd is reused\r
+ * @param daemon pointer to dlt daemon structure\r
+ * @param fd file descriptor\r
+ * @param verbose if set to true verbose information is printed out.\r
+ * @return negative value if there was an error\r
+ */\r
+int dlt_daemon_contexts_invalidate_fd(DltDaemon *daemon,int fd,int verbose);\r
+/**\r
  * Clear all contexts in internal context management\r
  * @param daemon pointer to dlt daemon structure\r
  * @param verbose if set to true verbose information is printed out.\r
@@ -357,8 +361,9 @@ void dlt_daemon_control_service_response(int sock, DltDaemon *daemon, uint32_t s
  * @param appid pointer to application id to be used in response message\r
  * @param contid pointer to context id to be used in response message\r
  * @param verbose if set to true verbose information is printed out.\r
+ * @return -1 if there is an error or buffer is full\r
  */\r
-void dlt_daemon_control_send_control_message(int sock, DltDaemon *daemon, DltMessage *msg, char* appid, char* contid, int verbose);\r
+int dlt_daemon_control_send_control_message(int sock, DltDaemon *daemon, DltMessage *msg, char* appid, char* contid, int verbose);\r
 \r
 /**\r
  * Process and generate response to received sw injection control message\r
@@ -435,8 +440,9 @@ void dlt_daemon_control_get_log_info(int sock, DltDaemon *daemon, DltMessage *ms
  * @param sock connection handle used for sending response\r
  * @param daemon pointer to dlt daemon structure\r
  * @param verbose if set to true verbose information is printed out.\r
+ * @return -1 if there is an error or buffer overflow, else 0\r
  */\r
-void dlt_daemon_control_message_buffer_overflow(int sock, DltDaemon *daemon, int verbose);\r
+int dlt_daemon_control_message_buffer_overflow(int sock, DltDaemon *daemon, unsigned int overflow_counter,char* apid, int verbose);\r
 /**\r
  * Process reset to factory default control message\r
  * @param daemon pointer to dlt daemon structure\r
@@ -452,7 +458,6 @@ void dlt_daemon_control_reset_to_factory_default(DltDaemon *daemon,const char *f
  * @param verbose if set to true verbose information is printed out.\r
  */\r
 void dlt_daemon_control_message_time(int sock, DltDaemon *daemon, int verbose);\r
-\r
 #ifdef __cplusplus\r
 }\r
 #endif\r