summaryrefslogtreecommitdiff
path: root/src/gateway/dlt_gateway.h
blob: 8c0e39a11a18d84aa2155d479b94f1b892816b8e (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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/*
 * @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.h
 */

/*******************************************************************************
**                                                                            **
**  SRC-MODULE: dlt_gateway.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_H_
#define DLT_GATEWAY_H_

#include "dlt-daemon.h"
#include "dlt_gateway_types.h"
/**
 * Initialize the gateway to passive nodes
 *
 * TODO: Make path to configuration file configurable
 *
 * @param daemon_local  pointer to DltDaemonLocal
 * @param verbose       verbose flag
 * @return 0 on success, -1 on error
 */
int dlt_gateway_init(DltDaemonLocal *daemon_local, int verbose);

/**
 * De-initialize the gateway. All internal data will be freed.
 *
 * @param g DltGateway pointer
 * @param verbose verbose flag
 */
void dlt_gateway_deinit(DltGateway *g, int verbose);

/**
 * Establish all connections to passive nodes that are configured to be started
 * on daemon startup and add this connections to the main event loop.
 *
 * TODO: This function is called during gateway initialization and in main loop
 *       whenever the poll returns. This may need to be improved.
 *
 * @param g             DltGateway
 * @param daemon_local  DltDaemonLocal
 * @param verbose       verbose flag
 * @return 0 on success, -1 on error
 */
int dlt_gateway_establish_connections(DltGateway *g,
                                      DltDaemonLocal *daemon_local,
                                      int verbose);

/**
 * Return the receiver for a given file descriptor
 *
 * @param g DltGateway
 * @param fd file descriptor
 * @return Pointer to DltReceiver on success, NULL otherwise
 */
DltReceiver *dlt_gateway_get_connection_receiver(DltGateway *g, int fd);


/**
 * Process incoming messages from passive nodes
 *
 * @param daemon          DltDaemon
 * @param daemon_local    DltDaemonLocal
 * @param recv            DltReceiver structure
 * @param verbose verbose flag
 * @return 0 on success, -1 otherwise
 */
int dlt_gateway_process_passive_node_messages(DltDaemon *daemon,
                                              DltDaemonLocal *daemon_local,
                                              DltReceiver *recv,
                                              int verbose);

/**
 * Process gateway timer
 *
 * @param daemon          DltDaemon
 * @param daemon_local    DltDaemonLocal
 * @param rec             DltReceiver
 * @param verbose verbose flag
 * @return 0 on success, -1 otherwise
 */
int dlt_gateway_process_gateway_timer(DltDaemon *daemon,
                                      DltDaemonLocal *daemon_local,
                                      DltReceiver *rec,
                                      int verbose);

/**
 * Forward control messages to the specified passive node DLT Daemon.
 *
 * @param g            DltGateway
 * @param daemon_local DltDaemonLocal
 * @param msg          DltMessage
 * @param ecu          Identifier of the passive node
 * @param verbose      verbose flag
 * @return 0 on success, -1 otherwise
 */
int dlt_gateway_forward_control_message(DltGateway *g,
                                        DltDaemonLocal *daemon_local,
                                        DltMessage *msg,
                                        char *ecu,
                                        int verbose);

/**
 * Process on demand connect/disconnect of passive nodes
 *
 * @param g                 DltGateway
 * @param daemon_local      DltDaemonLocal
 * @param node_id           Passive Node identifier
 * @param connection_status Connection status
 * @param verbose           verbose flag
 * @return 0 on success, -1 otherwise
 */
int dlt_gateway_process_on_demand_request(DltGateway *g,
                                          DltDaemonLocal *daemon_local,
                                          char *node_id,
                                          int connection_status,
                                          int verbose);

/**
 * Send control message to passive node
 *
 * @param con           DltGatewayConnection
 * @param control_msg   DltPassiveControlMessage
 * @param data          DltMessage
 * @param verbose       verbose flag
 * @return 0 on success, -1 otherwise
 */
int dlt_gateway_send_control_message(DltGatewayConnection *con,
                                     DltPassiveControlMessage *control_msg,
                                     void *data,
                                     int verbose);

/**
 * Gets the connection handle of passive node with specified ECU
 *
 * @param g             DltGateway
 * @param ecu           Identifier string
 * @param verbose       verbose flag
 * @returns Gateway connection handle on success, NULL otherwise
 */
DltGatewayConnection *dlt_gateway_get_connection(DltGateway *g,
                                                 char *ecu,
                                                 int verbose);

#endif