summaryrefslogtreecommitdiff
path: root/src/gateway/dlt_gateway_types.h
blob: 20d21f9d09d84c9e651b8c537eed53eafec4f48a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/*
 * @licence app begin@
 * SPDX license identifier: MPL-2.0
 *
 * Copyright (C) 2015 Advanced Driver Information Technology.
 * This code is developed by Advanced Driver Information Technology.
 * Copyright of Advanced Driver Information Technology, Bosch and DENSO.
 *
 * This file is part of GENIVI Project DLT - Diagnostic Log and Trace.
 *
 * This Source Code Form is subject to the terms of the
 * Mozilla Public License (MPL), v. 2.0.
 * If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * For further information see http://www.genivi.org/.
 * @licence end@
 */

/*!
 * \author
 * Christoph Lipka <clipka@jp.adit-jv.com>
 *
 * \copyright Copyright © 2015 Advanced Driver Information Technology. \n
 * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
 *
 * \file dlt_gateway_types.h
 */

/*******************************************************************************
**                                                                            **
**  SRC-MODULE: dlt_gateway_types.h                                           **
**                                                                            **
**  TARGET    : linux                                                         **
**                                                                            **
**  PROJECT   : DLT                                                           **
**                                                                            **
**  AUTHOR    : Christoph Lipka clipka@jp.adit-jv.com                         **
**  PURPOSE   :                                                               **
**                                                                            **
**  REMARKS   :                                                               **
**                                                                            **
**  PLATFORM DEPENDANT [yes/no]: yes                                          **
**                                                                            **
**  TO BE CHANGED BY USER [yes/no]: no                                        **
**                                                                            **
*******************************************************************************/

/*******************************************************************************
**                      Author Identity                                       **
********************************************************************************
**                                                                            **
** Initials     Name                       Company                            **
** --------     -------------------------  ---------------------------------- **
**  cl          Christoph Lipka            ADIT                               **
*******************************************************************************/

#ifndef DLT_GATEWAY_TYPES_H_
#define DLT_GATEWAY_TYPES_H_

#include "dlt_protocol.h"
#include "dlt_client.h"

#define DLT_GATEWAY_CONFIG_PATH CONFIGURATION_FILES_DIR "/dlt_gateway.conf"
#define DLT_GATEWAY_TIMER_INTERVAL 1

#define DLT_GATEWAY_RECONNECT_MAX 1 /* reconnect once after connection loss */

/* maximum number of control messages that can be send after connection is
 * established */
#define DLT_GATEWAY_MAX_STARTUP_CTRL_MSG 10

typedef enum
{
    DLT_GATEWAY_UNINITIALIZED,
    DLT_GATEWAY_INITIALIZED,
    DLT_GATEWAY_CONNECTED,
    DLT_GATEWAY_DISCONNECTED
} connection_status;

typedef enum
{
    DLT_GATEWAY_UNDEFINED = -1,
    DLT_GATEWAY_ON_STARTUP,    /* connect directly on startup */
    DLT_GATEWAY_ON_DEMAND,     /* connect on demand only */
    DLT_GATEWAY_DISABLED       /* disable this connection due to problems */
} connection_trigger;

typedef enum
{
    CONTROL_MESSAGE_UNDEFINED = -1,
    CONTROL_MESSAGE_ON_STARTUP,     /* send on startup */
    CONTROL_MESSAGE_PERIODIC,       /* send periodically */
    CONTROL_MESSAGE_BOTH,           /* send on startup and periodically */
    CONTROL_MESSAGE_ON_DEMAND       /* send on demand only */
} control_msg_trigger;

typedef enum
{
    CONTROL_MESSAGE_REQUEST_UNDEFINED = -1,
    CONTROL_MESSAGE_NOT_REQUESTED,  /* control msg not requested (default) */
    CONTROL_MESSAGE_REQUESTED       /* control msg requested */
} control_msg_request;

/* Passive control message */
typedef struct DltPassiveControlMessage {
    uint32_t id;                /* msg ID */
    uint32_t user_id;
    control_msg_trigger type;   /* on startup or periodic or both */
    control_msg_request req;    /* whether it is requested from gateway or not */
    int interval;               /* interval for periodic sending. if on startup, -1 */
    struct DltPassiveControlMessage *next; /* for multiple passive control message */
} DltPassiveControlMessage;

/* DLT Gateway connection structure */
typedef struct {
    int handle;                 /* connection handle */
    connection_status status;   /* connected/disconnected */
    char *ecuid;                /* name of passive node */
    char *ip_address;           /* IP address */
    int sock_domain;            /* socket domain */
    int sock_type;              /* socket type */
    int sock_protocol;          /* socket protocol */
    int port;                   /* port */
    connection_trigger trigger; /* connection trigger */
    int timeout;                /* connection timeout */
    int timeout_cnt;            /* connection timeout counter */
    int reconnect_cnt;          /* reconnection counter */
    int sendtime;               /* periodic sending max time */
    int sendtime_cnt;           /* periodic sending counter */
    DltPassiveControlMessage *p_control_msgs; /* passive control msgs */
    DltPassiveControlMessage *head; /* to go back to the head pointer of p_control_msgs */
    int send_serial;            /* Send serial header with control messages */
    DltClient client;           /* DltClient structure */
    int default_log_level;      /* Default Log Level on passive node */
} DltGatewayConnection;

/* DltGateway structure */
typedef struct
{
    int send_serial;     /* Default: Send serial header with control messages */
    DltGatewayConnection *connections; /* pointer to connections */
    int num_connections; /* number of connections */
} DltGateway;

typedef struct {
    char *key;  /* The configuration key*/
    int (*func)(DltGatewayConnection *con, char *value); /* Conf handler */
    int is_opt; /* If the configuration is optional or not */
} DltGatewayConf;

typedef enum {
    GW_CONF_IP_ADDRESS = 0,
    GW_CONF_PORT,
    GW_CONF_ECUID,
    GW_CONF_CONNECT,
    GW_CONF_TIMEOUT,
    GW_CONF_SEND_CONTROL,
    GW_CONF_SEND_PERIODIC_CONTROL,
    GW_CONF_SEND_SERIAL_HEADER,
    GW_CONF_COUNT
} DltGatewayConfType;

#endif /* DLT_GATEWAY_TYPES_H_ */