From 33fbad18c814e13bd7ba2053525d8959fee437d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Sousa?= <48479050+joaodasousa@users.noreply.github.com> Date: Mon, 31 Aug 2020 00:56:03 +0100 Subject: Implement DLTClient for UDP multicast (#240) * Add UDP multicast support on client side UDP multicast support is already present on server side. This patch add seemless support for UDP multicast on client side in dlt-receive. Signed-off-by: Joao Sousa --- include/dlt/dlt_client.h | 22 ++++++++++++++++++++-- include/dlt/dlt_common.h | 11 +++++++---- 2 files changed, 27 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/dlt/dlt_client.h b/include/dlt/dlt_client.h index 1fac86a..f649b83 100644 --- a/include/dlt/dlt_client.h +++ b/include/dlt/dlt_client.h @@ -81,14 +81,16 @@ typedef enum DLT_CLIENT_MODE_UNDEFINED = -1, DLT_CLIENT_MODE_TCP, DLT_CLIENT_MODE_SERIAL, - DLT_CLIENT_MODE_UNIX + DLT_CLIENT_MODE_UNIX, + DLT_CLIENT_MODE_UDP_MULTICAST } DltClientMode; typedef struct { DltReceiver receiver; /**< receiver pointer to dlt receiver structure */ int sock; /**< sock Connection handle/socket */ - char *servIP; /**< servIP IP adress/Hostname of TCP/IP interface */ + char *servIP; /**< servIP IP adress/Hostname of interface */ + char *hostip; /**< hostip IP address of UDP host receiver interface */ int port; /**< Port for TCP connections (optional) */ char *serialDevice; /**< serialDevice Devicename of serial device */ char *socketPath; /**< socketPath Unix socket path */ @@ -269,6 +271,14 @@ DltReturnValue dlt_client_send_reset_to_factory_default(DltClient *client); */ DltReturnValue dlt_client_setbaudrate(DltClient *client, int baudrate); +/** + * Set mode within dlt client structure + * @param client pointer to dlt client structure + * @param mode DltClientMode + * @return Value from DltReturnValue enum + */ +DltReturnValue dlt_client_set_mode(DltClient *client, DltClientMode mode); + /** * Set server ip * @param client pointer to dlt client structure @@ -277,6 +287,14 @@ DltReturnValue dlt_client_setbaudrate(DltClient *client, int baudrate); */ int dlt_client_set_server_ip(DltClient *client, char *ipaddr); +/** + * Set server UDP host receiver interface address + * @param client pointer to dlt client structure + * @param hostip pointer to multicast group address + * @return negative value if there was an error + */ +int dlt_client_set_host_if_address(DltClient *client, char *hostip); + /** * Set serial device * @param client pointer to dlt client structure diff --git a/include/dlt/dlt_common.h b/include/dlt/dlt_common.h index 9f4096b..166395e 100644 --- a/include/dlt/dlt_common.h +++ b/include/dlt/dlt_common.h @@ -77,6 +77,7 @@ # include # ifdef __linux__ # include +# include # else # include # endif @@ -402,6 +403,7 @@ enum { typedef enum { DLT_RECEIVE_SOCKET, + DLT_RECEIVE_UDP_SOCKET, DLT_RECEIVE_FD } DltReceiverType; @@ -767,11 +769,12 @@ typedef struct int32_t lastBytesRcvd; /**< bytes received in last receive call */ int32_t bytesRcvd; /**< received bytes */ int32_t totalBytesRcvd; /**< total number of received bytes */ - char *buffer; /**< pointer to receiver buffer */ - char *buf; /**< pointer to position within receiver buffer */ - char *backup_buf; /** pointer to the buffer with partial messages if any **/ - int fd; /**< connection handle */ + char *buffer; /**< pointer to receiver buffer */ + char *buf; /**< pointer to position within receiver buffer */ + char *backup_buf; /** pointer to the buffer with partial messages if any **/ + int fd; /**< connection handle */ int32_t buffersize; /**< size of receiver buffer */ + struct sockaddr_in addr; /**< socket address information */ } DltReceiver; typedef struct -- cgit v1.2.1