summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Wenzel <Alexander.AW.Wenzel@bmw.de>2013-12-02 09:02:28 +0100
committerAlexander Wenzel <Alexander.AW.Wenzel@bmw.de>2014-01-10 07:15:47 +0100
commite387e0d12020f7159dc2b3c53e24dc6bb58de4b9 (patch)
tree75695e8c05d078816c00970e67a7c1cd8f025407
parent67c51523071c338b9d800d47683a9a3417348508 (diff)
downloadDLT-daemon-e387e0d12020f7159dc2b3c53e24dc6bb58de4b9.tar.gz
Added conntection info and unregister context control messages.
Signed-off-by: Alexander Wenzel <Alexander.AW.Wenzel@bmw.de>
-rwxr-xr-xinclude/dlt/dlt_common.h23
-rwxr-xr-xinclude/dlt/dlt_protocol.h8
-rw-r--r--src/daemon/dlt-daemon.c31
-rw-r--r--src/daemon/dlt_daemon_common.c117
-rw-r--r--src/daemon/dlt_daemon_common.h20
5 files changed, 199 insertions, 0 deletions
diff --git a/include/dlt/dlt_common.h b/include/dlt/dlt_common.h
index b0b62eb..7f205c9 100755
--- a/include/dlt/dlt_common.h
+++ b/include/dlt/dlt_common.h
@@ -490,6 +490,29 @@ typedef struct
} 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;
+
+/**
* 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.
diff --git a/include/dlt/dlt_protocol.h b/include/dlt/dlt_protocol.h
index c2e91d7..7e941fe 100755
--- a/include/dlt/dlt_protocol.h
+++ b/include/dlt/dlt_protocol.h
@@ -187,6 +187,8 @@
#define DLT_SERVICE_ID_SET_DEFAULT_TRACE_STATUS 0x12 /**< Service ID: Set default trace status */
#define DLT_SERVICE_ID_GET_SOFTWARE_VERSION 0x13 /**< Service ID: Get software version */
#define DLT_SERVICE_ID_MESSAGE_BUFFER_OVERFLOW 0x14 /**< Service ID: Message buffer overflow */
+#define DLT_SERVICE_ID_UNREGISTER_CONTEXT 0xf01 /**< Service ID: Message unregister context */
+#define DLT_SERVICE_ID_CONNECTION_INFO 0xf02 /**< Service ID: Message connection info */
#define DLT_SERVICE_ID_CALLSW_CINJECTION 0xFFF /**< Service ID: Message Injection (minimal ID) */
/*
@@ -196,6 +198,12 @@
#define DLT_SERVICE_RESPONSE_NOT_SUPPORTED 0x01 /**< Control message response: Not supported */
#define DLT_SERVICE_RESPONSE_ERROR 0x02 /**< Control message response: Error */
+/*
+ * Definitions of DLT service connection state
+ */
+#define DLT_CONNECTION_STATUS_DISCONNECTED 0x01 /**< Client is disconnected */
+#define DLT_CONNECTION_STATUS_CONNECTED 0x02 /**< Client is connected */
+
/**
\}
*/
diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c
index 335e3e4..94e3520 100644
--- a/src/daemon/dlt-daemon.c
+++ b/src/daemon/dlt-daemon.c
@@ -1228,6 +1228,8 @@ int dlt_daemon_process_client_connect(DltDaemon *daemon, DltDaemonLocal *daemon_
dlt_log(LOG_INFO, str);
}
+ dlt_daemon_control_message_connection_info(in_sock,daemon,DLT_CONNECTION_STATUS_CONNECTED,"",verbose);
+
if (daemon_local->client_connections==1)
{
if (daemon_local->flags.vflag)
@@ -1284,6 +1286,7 @@ int dlt_daemon_process_client_messages(DltDaemon *daemon, DltDaemonLocal *daemon
dlt_log(LOG_INFO, str);
}
+ dlt_daemon_control_message_connection_info(DLT_DAEMON_STORE_TO_BUFFER,daemon,DLT_CONNECTION_STATUS_DISCONNECTED,"",verbose);
/* check: return 0; */
}
@@ -1996,6 +1999,34 @@ int dlt_daemon_process_user_message_unregister_context(DltDaemon *daemon, DltDae
}
}
+ /* Create automatic unregister context response for unregistered context */
+ if (daemon_local->flags.rflag)
+ {
+ int sent=0;
+ int j;
+
+ /* Send response to get log info request to DLT clients */
+ for (j = 0; j <= daemon_local->fdmax; j++)
+ {
+ /* send to everyone! */
+ if (FD_ISSET(j, &(daemon_local->master)))
+ {
+ /* except the listener and ourselves */
+ if ((j != daemon_local->fp) && (j != daemon_local->sock))
+ {
+ dlt_daemon_control_message_unregister_context(j,daemon,usercontext->apid, usercontext->ctid, "remo",verbose);
+ sent=1;
+ }
+ }
+ }
+
+ if (sent==0)
+ {
+ /* Store to buffer */
+ dlt_daemon_control_message_unregister_context(DLT_DAEMON_STORE_TO_BUFFER,daemon,usercontext->apid, usercontext->ctid, "remo",verbose);
+ }
+ }
+
/* keep not read data in buffer */
if (dlt_receiver_remove(&(daemon_local->receiver),sizeof(DltUserHeader)+sizeof(DltUserControlMsgUnregisterContext))==-1)
{
diff --git a/src/daemon/dlt_daemon_common.c b/src/daemon/dlt_daemon_common.c
index b817ce9..7a344db 100644
--- a/src/daemon/dlt_daemon_common.c
+++ b/src/daemon/dlt_daemon_common.c
@@ -2559,3 +2559,120 @@ void dlt_daemon_control_message_time(int sock, DltDaemon *daemon, int verbose)
/* free message */
dlt_message_free(&msg,0);
}
+
+int dlt_daemon_control_message_unregister_context(int sock, DltDaemon *daemon, char* apid, char* ctid, char* comid, int verbose)
+{
+ DltMessage msg;
+ DltServiceUnregisterContext *resp;
+
+ PRINT_FUNCTION_VERBOSE(verbose);
+
+ if (daemon==0)
+ {
+ return -1;
+ }
+
+ /* initialise new message */
+ if (dlt_message_init(&msg,0)==-1)
+ {
+ dlt_daemon_control_service_response(sock, daemon, DLT_SERVICE_ID_MESSAGE_BUFFER_OVERFLOW, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ return -1;
+ }
+
+ /* prepare payload of data */
+ msg.datasize = sizeof(DltServiceUnregisterContext);
+ if (msg.databuffer && (msg.databuffersize < msg.datasize))
+ {
+ free(msg.databuffer);
+ msg.databuffer=0;
+ }
+ if (msg.databuffer == 0){
+ msg.databuffer = (uint8_t *) malloc(msg.datasize);
+ msg.databuffersize = msg.datasize;
+ }
+ if (msg.databuffer==0)
+ {
+ if (sock!=DLT_DAEMON_STORE_TO_BUFFER)
+ {
+ dlt_daemon_control_service_response(sock, daemon, DLT_SERVICE_ID_MESSAGE_BUFFER_OVERFLOW, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ }
+ return -1;
+ }
+
+ resp = (DltServiceUnregisterContext*) msg.databuffer;
+ resp->service_id = DLT_SERVICE_ID_UNREGISTER_CONTEXT;
+ resp->status = DLT_SERVICE_RESPONSE_OK;
+ dlt_set_id(resp->apid, apid);
+ dlt_set_id(resp->apid, ctid);
+ dlt_set_id(resp->comid, comid);
+
+ /* send message */
+ if(dlt_daemon_control_send_control_message(sock,daemon,&msg,"","", verbose))
+ {
+ dlt_message_free(&msg,0);
+ return -1;
+ }
+
+ /* free message */
+ dlt_message_free(&msg,0);
+
+ return 0;
+}
+
+int dlt_daemon_control_message_connection_info(int sock, DltDaemon *daemon, uint8_t state, char* comid, int verbose)
+{
+ DltMessage msg;
+ DltServiceConnectionInfo *resp;
+
+ PRINT_FUNCTION_VERBOSE(verbose);
+
+ if (daemon==0)
+ {
+ return -1;
+ }
+
+ /* initialise new message */
+ if (dlt_message_init(&msg,0)==-1)
+ {
+ dlt_daemon_control_service_response(sock, daemon, DLT_SERVICE_ID_MESSAGE_BUFFER_OVERFLOW, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ return -1;
+ }
+
+ /* prepare payload of data */
+ msg.datasize = sizeof(DltServiceConnectionInfo);
+ if (msg.databuffer && (msg.databuffersize < msg.datasize))
+ {
+ free(msg.databuffer);
+ msg.databuffer=0;
+ }
+ if (msg.databuffer == 0){
+ msg.databuffer = (uint8_t *) malloc(msg.datasize);
+ msg.databuffersize = msg.datasize;
+ }
+ if (msg.databuffer==0)
+ {
+ if (sock!=DLT_DAEMON_STORE_TO_BUFFER)
+ {
+ dlt_daemon_control_service_response(sock, daemon, DLT_SERVICE_ID_MESSAGE_BUFFER_OVERFLOW, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ }
+ return -1;
+ }
+
+ resp = (DltServiceConnectionInfo*) msg.databuffer;
+ resp->service_id = DLT_SERVICE_ID_CONNECTION_INFO;
+ resp->status = DLT_SERVICE_RESPONSE_OK;
+ resp->state = state;
+ dlt_set_id(resp->comid, comid);
+
+ /* send message */
+ if(dlt_daemon_control_send_control_message(sock,daemon,&msg,"","", verbose))
+ {
+ dlt_message_free(&msg,0);
+ return -1;
+ }
+
+ /* free message */
+ dlt_message_free(&msg,0);
+
+ return 0;
+}
diff --git a/src/daemon/dlt_daemon_common.h b/src/daemon/dlt_daemon_common.h
index b93f0c2..46b59dd 100644
--- a/src/daemon/dlt_daemon_common.h
+++ b/src/daemon/dlt_daemon_common.h
@@ -458,6 +458,26 @@ void dlt_daemon_control_reset_to_factory_default(DltDaemon *daemon,const char *f
* @param verbose if set to true verbose information is printed out.
*/
void dlt_daemon_control_message_time(int sock, DltDaemon *daemon, int verbose);
+/**
+ * Send control message unregister context (add on to AUTOSAR standard)
+ * @param sock connection handle used for sending response
+ * @param daemon pointer to dlt daemon structure
+ * @param apid application id to be unregisteres
+ * @param ctid context id to be unregistered
+ * @param comid Communication id where apid is unregistered
+ * @param verbose if set to true verbose information is printed out.
+ */
+int dlt_daemon_control_message_unregister_context(int sock, DltDaemon *daemon, char* apid, char* ctid, char* comid, int verbose);
+/**
+ * Send control message connection info (add on to AUTOSAR standard)
+ * @param sock connection handle used for sending response
+ * @param daemon pointer to dlt daemon structure
+ * @param state state of connection
+ * @param comid Communication id where connection state changed
+ * @param verbose if set to true verbose information is printed out.
+ */
+int dlt_daemon_control_message_connection_info(int sock, DltDaemon *daemon, uint8_t state, char* comid, int verbose);
+
#ifdef __cplusplus
}
#endif