|
65 | 65 | #include "dlt_daemon_offline_logstorage.h"
|
66 | 66 | #include "dlt_gateway.h"
|
67 | 67 |
|
| 68 | +#ifdef UDP_CONNECTION_SUPPORT |
| 69 | +# include "dlt_daemon_udp_socket.h" |
| 70 | +#endif |
68 | 71 | #if defined(DLT_SYSTEMD_WATCHDOG_ENABLE) || defined(DLT_SYSTEMD_ENABLE)
|
69 | 72 | # include "sd-daemon.h"
|
70 | 73 | #endif
|
@@ -289,6 +292,11 @@ int option_file_parser(DltDaemonLocal *daemon_local)
|
289 | 292 | daemon_local->flags.contextLogLevel = DLT_LOG_INFO;
|
290 | 293 | daemon_local->flags.contextTraceStatus = DLT_TRACE_STATUS_OFF;
|
291 | 294 | daemon_local->flags.enforceContextLLAndTS = 0; /* default is off */
|
| 295 | +#ifdef UDP_CONNECTION_SUPPORT |
| 296 | + daemon_local->UDPConnectionSetup = MULTICAST_CONNECTION_ENABLED; |
| 297 | + strncpy(daemon_local->UDPMulticastIPAddress, MULTICASTIPADDRESS, MULTICASTIP_MAX_SIZE - 1); |
| 298 | + daemon_local->UDPMulticastIPPort = MULTICASTIPPORT; |
| 299 | +#endif |
292 | 300 |
|
293 | 301 | /* open configuration file */
|
294 | 302 | if (daemon_local->flags.cvalue[0])
|
@@ -597,6 +605,33 @@ int option_file_parser(DltDaemonLocal *daemon_local)
|
597 | 605 | strncpy(daemon_local->flags.daemonFifoGroup, value, NAME_MAX);
|
598 | 606 | daemon_local->flags.daemonFifoGroup[NAME_MAX] = 0;
|
599 | 607 | }
|
| 608 | +#endif |
| 609 | +#ifdef UDP_CONNECTION_SUPPORT |
| 610 | + else if (strcmp(token, "UDPConnectionSetup") == 0) |
| 611 | + { |
| 612 | + const long longval = strtol(value, NULL, 10); |
| 613 | + |
| 614 | + if ((longval == MULTICAST_CONNECTION_DISABLED) |
| 615 | + || (longval == MULTICAST_CONNECTION_ENABLED)) { |
| 616 | + daemon_local->UDPConnectionSetup = longval; |
| 617 | + printf("Option: %s=%s\n", token, value); |
| 618 | + } |
| 619 | + else { |
| 620 | + daemon_local->UDPConnectionSetup = MULTICAST_CONNECTION_DISABLED; |
| 621 | + fprintf(stderr, |
| 622 | + "Invalid value for UDPConnectionSetup set to default %ld\n", |
| 623 | + longval); |
| 624 | + } |
| 625 | + } |
| 626 | + else if (strcmp(token, "UDPMulticastIPAddress") == 0) |
| 627 | + { |
| 628 | + strncpy(daemon_local->UDPMulticastIPAddress, value, |
| 629 | + MULTICASTIP_MAX_SIZE - 1); |
| 630 | + } |
| 631 | + else if (strcmp(token, "UDPMulticastIPPort") == 0) |
| 632 | + { |
| 633 | + daemon_local->UDPMulticastIPPort = strtol(value, NULL, 10); |
| 634 | + } |
600 | 635 | #endif
|
601 | 636 | else {
|
602 | 637 | fprintf(stderr, "Unknown option: %s=%s\n", token, value);
|
@@ -1204,6 +1239,20 @@ int dlt_daemon_local_connection_init(DltDaemon *daemon,
|
1204 | 1239 | return DLT_RETURN_ERROR;
|
1205 | 1240 | }
|
1206 | 1241 |
|
| 1242 | +#ifdef UDP_CONNECTION_SUPPORT |
| 1243 | + |
| 1244 | + if (daemon_local->UDPConnectionSetup == MULTICAST_CONNECTION_ENABLED) { |
| 1245 | + if (dlt_daemon_udp_connection_setup(daemon_local) < 0) { |
| 1246 | + dlt_log(LOG_ERR, "UDP fd creation and register in epoll failed\n"); |
| 1247 | + return DLT_RETURN_ERROR; |
| 1248 | + } |
| 1249 | + else { |
| 1250 | + dlt_log(LOG_INFO, "UDP fd creation and register in epoll success\n"); |
| 1251 | + } |
| 1252 | + } |
| 1253 | + |
| 1254 | +#endif |
| 1255 | + |
1207 | 1256 | /* create and open unix socket to receive incoming connections from
|
1208 | 1257 | * control application
|
1209 | 1258 | * socket access permission set to srw-rw---- (660) */
|
|
0 commit comments