Defined return value for dlt_message_read().
[profile/ivi/dlt-daemon.git] / include / dlt / dlt_common.h
index c3acf49..be04e68 100755 (executable)
@@ -13,7 +13,7 @@
  * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
  *
  *
- * \author Alexander Wenzel <alexander.wenzel@bmw.de> BMW 2011-2012
+ * \author Alexander Wenzel <alexander.aw.wenzel@bmw.de> BMW 2011-2012
  *
  * \file dlt_common.h
  * For further information see http://www.genivi.org/.
 #define DLT_SWAP_32(value) ((((value) >> 24)&0xff) | (((value) << 8)&0xff0000) | (((value) >> 8)&0xff00) | (((value) << 24)&0xff000000))
 
 /* Set Big Endian and Little Endian to a initial value, if not defined */
+#if !defined __USE_BSD
 #ifndef LITTLE_ENDIAN
 #define LITTLE_ENDIAN 1234
 #endif
 #ifndef BIG_ENDIAN
 #define BIG_ENDIAN    4321
 #endif
+#endif /* __USE_BSD */
 
 /* If byte order is not defined, default to little endian */
+#if !defined __USE_BSD
 #ifndef BYTE_ORDER
 #define BYTE_ORDER LITTLE_ENDIAN
 #endif
+#endif /* __USE_BSD */
 
 /* Check for byte-order */
 #if (BYTE_ORDER==BIG_ENDIAN)
 #define        LOG_DAEMON      (3<<3)
 #endif
 
+enum {
+    DLT_LOG_TO_CONSOLE=0,
+    DLT_LOG_TO_SYSLOG=1,
+    DLT_LOG_TO_FILE=2,
+    DLT_LOG_DROPPED=3
+};
+
 /**
  * The standard TCP Port used for DLT daemon
  */
 #define DLT_DAEMON_TCP_PORT 3490
 
+
+/* Initi value for file descritpor */
+#define DLT_FD_INIT -1
+
+/* Minimum value for a file descriptor except the POSIX Standards: stdin=0, stdout=1, stderr=2 */
+#define DLT_FD_MINIMUM 3
+
 /**
  * The size of a DLT ID
  */
     \
     if(_verbose) \
     { \
-               sprintf(_strbuf, "%s()\n",__func__); \
+               snprintf(_strbuf, 255, "%s()\n",__func__); \
                dlt_log(LOG_INFO, _strbuf); \
     } \
 }
@@ -376,6 +394,7 @@ typedef struct sDltMessage
     uint8_t headerbuffer[sizeof(DltStorageHeader)+
                          sizeof(DltStandardHeader)+sizeof(DltStandardHeaderExtra)+sizeof(DltExtendedHeader)]; /**< buffer for loading complete header */
     uint8_t *databuffer;         /**< buffer for loading payload */
+       int32_t databuffersize;
 
     /* header values of current loaded message */
     DltStorageHeader       *storageheader;  /**< pointer to storage header of current loaded header */
@@ -466,6 +485,7 @@ typedef struct
     uint32_t service_id;            /**< service ID */
     uint8_t status;                 /**< reponse status */
     uint8_t overflow;               /**< overflow status */
+    uint32_t overflow_counter;      /**< overflow counter */
 } PACKED DltServiceMessageBufferOverflowResponse;
 
 typedef struct
@@ -473,10 +493,44 @@ typedef struct
     uint32_t service_id;            /**< service ID */
     uint8_t  status;                /**< reponse status */
     uint32_t length;                /**< length of following payload */
-    /* char [] payload */
+    /*char [] payload;*/
 } PACKED DltServiceGetSoftwareVersionResponse;
 
 /**
+ * The structure of the DLT Service Unregister Context.
+ */
+typedef struct
+{
+    uint32_t service_id;            /**< service ID */
+    uint8_t status;                 /**< reponse status */
+    char apid[DLT_ID_SIZE];         /**< application id */
+    char ctid[DLT_ID_SIZE];         /**< context id */
+    char comid[DLT_ID_SIZE];        /**< communication interface */
+} PACKED DltServiceUnregisterContext;
+
+/**
+ * The structure of the DLT Service Connection Info
+ */
+typedef struct
+{
+    uint32_t service_id;            /**< service ID */
+    uint8_t status;                 /**< reponse status */
+    uint8_t state;                  /**< new state */
+    char comid[DLT_ID_SIZE];        /**< communication interface */
+} PACKED DltServiceConnectionInfo;
+
+/**
+ * The structure of the DLT Service Timezone
+ */
+typedef struct
+{
+    uint32_t service_id;            /**< service ID */
+    uint8_t status;                 /**< reponse status */
+    int32_t timezone;               /**< Timezone in seconds */
+    uint8_t isdst;                  /**< Is daylight saving time */
+} PACKED DltServiceTimezone;
+
+/**
  * Structure to store filter parameters.
  * ID are maximal four characters. Unused values are filled with zeros.
  * If every value as filter is valid, the id should be empty by having only zero values.
@@ -560,6 +614,11 @@ typedef struct
        int size;       
 } DltBufferBlockHead;
 
+#define DLT_MESSAGE_ERROR_OK                   0
+#define DLT_MESSAGE_ERROR_UNKNOWN              -1
+#define DLT_MESSAGE_ERROR_SIZE          -2
+#define DLT_MESSAGE_ERROR_CONTENT      -3
+
 #ifdef __cplusplus
 extern "C"
 {
@@ -1196,6 +1255,11 @@ extern "C"
      */
     int dlt_message_argument_print(DltMessage *msg,uint32_t type_info,uint8_t **ptr,int32_t *datalength,char *text,int textlength,int byteLength,int verbose);
 
+    /**
+     * Check environment variables.
+     */
+       void dlt_check_envvar();
+
 #ifdef __cplusplus
 }
 #endif