automotive-dlt
|
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <string.h>
#include <getopt.h>
#include <sys/epoll.h>
#include "sd-daemon.h"
#include "dlt_protocol.h"
#include "dlt_client.h"
#include "dlt-control-common.h"
#include "dlt-logstorage-common.h"
#include "dlt-logstorage-ctrl.h"
Go to the source code of this file.
Macros | |
#define | pr_fmt(fmt) "Logstorage control: "fmt |
#define | EPOLL_MAX_EVENTS 10 |
#define | EPOLL_TIME_OUT 500 |
#define | DLT_LOGSTORAGE_CTRL_EXIT 1 |
#define | MAX_RESPONSE_LENGTH 32 |
Functions | |
void | dlt_logstorage_exit (void) |
Triggers the application exit. More... | |
int | dlt_logstorage_must_exit (void) |
Check if the application must exit. More... | |
static void | catch_signal (int signo) |
Signal handler. More... | |
static void | install_signal_handler (void) |
Install a handler for some signals. More... | |
static int | analyze_response (char *data, void *payload, int len) |
Analyze the daemon answer to a request. More... | |
static int | dlt_logstorage_ctrl_add_event (int fd, void *cb) |
Add a new event to watch to the epoll instance. More... | |
static int | dlt_logstorage_ctrl_execute_event_loop (int efd) |
Main execution loop. More... | |
static int | dlt_logstorage_ctrl_setup_event_loop (void) |
Start event loop and receive messages from DLT. More... | |
static int | dlt_logstorage_ctrl_single_request () |
Send a single command to DLT daemon and wait for response. More... | |
static void | usage (void) |
Print out the application help. More... | |
static int | parse_args (int argc, char *argv[]) |
Parses the application arguments. More... | |
int | main (int argc, char *argv[]) |
Entry point. More... | |
Variables | |
static int | must_exit |
static int | efd |
static struct option | long_options [] |
app begin@ Copyright (C) 2013 - 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 console apps.
For further information see http://www.genivi.org/. end@
Definition in file dlt-logstorage-ctrl.c.
#define DLT_LOGSTORAGE_CTRL_EXIT 1 |
Definition at line 79 of file dlt-logstorage-ctrl.c.
Referenced by dlt_logstorage_exit().
#define EPOLL_MAX_EVENTS 10 |
Definition at line 76 of file dlt-logstorage-ctrl.c.
Referenced by dlt_logstorage_ctrl_execute_event_loop().
#define EPOLL_TIME_OUT 500 |
Definition at line 77 of file dlt-logstorage-ctrl.c.
Referenced by dlt_logstorage_ctrl_execute_event_loop().
#define MAX_RESPONSE_LENGTH 32 |
Definition at line 143 of file dlt-logstorage-ctrl.c.
Referenced by analyze_response().
#define pr_fmt | ( | fmt | ) | "Logstorage control: "fmt |
Definition at line 56 of file dlt-logstorage-ctrl.c.
|
static |
Analyze the daemon answer to a request.
This function checks whether if the daemon answered positively to the request or not.
data | The textual answer |
payload | The answer payload |
len | The answer payload length |
Definition at line 154 of file dlt-logstorage-ctrl.c.
References DLT_SERVICE_ID_OFFLINE_LOGSTORAGE, MAX_RESPONSE_LENGTH, NULL, and pr_verbose.
Referenced by dlt_logstorage_ctrl_setup_event_loop(), and dlt_logstorage_ctrl_single_request().
|
static |
Signal handler.
Triggers the exit of the application in case of specific signals
signo | The value of the signal received. |
Definition at line 107 of file dlt-logstorage-ctrl.c.
References dlt_logstorage_exit(), and pr_error.
Referenced by install_signal_handler().
|
static |
Add a new event to watch to the epoll instance.
This function could be exported to be used by udev/prop so that they can register several events. There is no remove function as the removal is done on efd closure.
fd | The file descriptor to watch |
cb | The callback to be called on event. |
Definition at line 195 of file dlt-logstorage-ctrl.c.
References efd, pr_error, and pr_verbose.
Referenced by dlt_logstorage_ctrl_setup_event_loop().
|
static |
Main execution loop.
Waits on events from the epoll fd, and executes the callbacks retrieved back from the event structure.
Definition at line 220 of file dlt-logstorage-ctrl.c.
References data, dlt_logstorage_exit(), EPOLL_MAX_EVENTS, EPOLL_TIME_OUT, pr_error, and pr_verbose.
Referenced by dlt_logstorage_ctrl_setup_event_loop().
|
static |
Start event loop and receive messages from DLT.
The function will first install the signal handler, then create the epoll instance, initialize the communication controller, initialize the event handler and finally start the polling.
Definition at line 301 of file dlt-logstorage-ctrl.c.
References analyze_response(), dlt_control_deinit(), dlt_control_init(), dlt_logstorage_ctrl_add_event(), dlt_logstorage_ctrl_execute_event_loop(), dlt_logstorage_deinit_handler(), dlt_logstorage_exit(), dlt_logstorage_get_handler_cb(), dlt_logstorage_get_handler_fd(), dlt_logstorage_init_handler(), dlt_logstorage_must_exit(), efd, get_ecuid(), get_timeout(), get_verbosity(), install_signal_handler(), pr_error, and pr_verbose.
Referenced by main().
|
static |
Send a single command to DLT daemon and wait for response.
Definition at line 366 of file dlt-logstorage-ctrl.c.
References analyze_response(), CONF_NAME, dlt_control_deinit(), dlt_control_init(), dlt_logstorage_check_config_file(), dlt_logstorage_check_directory_permission(), dlt_logstorage_must_exit(), dlt_logstorage_send_event(), EVENT_SYNC_CACHE, get_default_event_type(), get_default_path(), get_ecuid(), get_timeout(), get_verbosity(), pr_error, and pr_verbose.
Referenced by main().
void dlt_logstorage_exit | ( | void | ) |
Triggers the application exit.
The application will exit on next epoll timeout.
Definition at line 87 of file dlt-logstorage-ctrl.c.
References DLT_LOGSTORAGE_CTRL_EXIT, and must_exit.
Referenced by catch_signal(), dlt_logstorage_ctrl_execute_event_loop(), and dlt_logstorage_ctrl_setup_event_loop().
int dlt_logstorage_must_exit | ( | void | ) |
Check if the application must exit.
The application will exit on next epoll timeout.
Definition at line 96 of file dlt-logstorage-ctrl.c.
References must_exit.
Referenced by dlt_logstorage_ctrl_setup_event_loop(), and dlt_logstorage_ctrl_single_request().
|
static |
Install a handler for some signals.
Handler are installed on exit related signals. That allows to exit from the main loop gracefully.
Definition at line 121 of file dlt-logstorage-ctrl.c.
References catch_signal(), NULL, pr_error, and pr_verbose.
Referenced by dlt_logstorage_ctrl_setup_event_loop().
int main | ( | int | argc, |
char * | argv[] | ||
) |
Entry point.
Execute the argument parser and call the main feature accordingly.
argc | The amount of arguments |
argv | The table of arguments |
Definition at line 551 of file dlt-logstorage-ctrl.c.
References CTRL_NOHANDLER, DLT_CTRL_TIMEOUT, dlt_logstorage_ctrl_setup_event_loop(), dlt_logstorage_ctrl_single_request(), get_handler_type(), NULL, parse_args(), pr_error, pr_verbose, set_ecuid(), and set_timeout().
|
static |
Parses the application arguments.
The arguments are parsed and saved in static structure for future use.
argc | The amount of arguments |
argv | The table of arguments |
Definition at line 454 of file dlt-logstorage-ctrl.c.
References CTRL_NOHANDLER, DLT_MOUNT_PATH_MAX, EVENT_SYNC_CACHE, get_default_event_type(), get_handler_type(), long_options, NULL, pr_error, pr_verbose, set_default_event_type(), set_default_path(), set_ecuid(), set_handler_type(), set_timeout(), set_verbosity(), and usage().
Referenced by main().
|
static |
Print out the application help.
Definition at line 412 of file dlt-logstorage-ctrl.c.
References DLT_CTRL_DEFAULT_ECUID, DLT_CTRL_TIMEOUT, and get_verbosity().
Referenced by parse_args().
|
static |
Definition at line 81 of file dlt-logstorage-ctrl.c.
Referenced by dlt_logstorage_ctrl_add_event(), and dlt_logstorage_ctrl_setup_event_loop().
|
static |
Definition at line 433 of file dlt-logstorage-ctrl.c.
Referenced by parse_args().
|
static |
Definition at line 80 of file dlt-logstorage-ctrl.c.
Referenced by dlt_logstorage_exit(), and dlt_logstorage_must_exit().