AM243x MCU+ SDK  09.00.00
cb_ipcsock.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023 Texas Instruments Incorporated
3  * Copyright (c) 2023 Excelfore Corporation (https://excelfore.com)
4  *
5  * All rights reserved not granted herein.
6  * Limited License.
7  *
8  * Texas Instruments Incorporated grants a world-wide, royalty-free,
9  * non-exclusive license under copyrights and patents it now or hereafter
10  * owns or controls to make, have made, use, import, offer to sell and sell ("Utilize")
11  * this software subject to the terms herein. With respect to the foregoing patent
12  * license, such license is granted solely to the extent that any such patent is necessary
13  * to Utilize the software alone. The patent license shall not apply to any combinations which
14  * include this software, other than combinations with devices manufactured by or for TI ("TI Devices").
15  * No hardware patent is licensed hereunder.
16  *
17  * Redistributions must preserve existing copyright notices and reproduce this license (including the
18  * above copyright notice and the disclaimer and (if applicable) source code license limitations below)
19  * in the documentation and/or other materials provided with the distribution
20  *
21  * Redistribution and use in binary form, without modification, are permitted provided that the following
22  * conditions are met:
23  *
24  * * No reverse engineering, decompilation, or disassembly of this software is permitted with respect to any
25  * software provided in binary form.
26  * * any redistribution and use are licensed by TI for use only with TI Devices.
27  * * Nothing shall obligate TI to provide you with source code for the software licensed and provided to you in object code.
28  *
29  * If software source code is provided to you, modification and redistribution of the source code are permitted
30  * provided that the following conditions are met:
31  *
32  * * any redistribution and use of the source code, including any resulting derivative works, are licensed by
33  * TI for use only with TI Devices.
34  * * any redistribution and use of any object code compiled from the source code and any resulting derivative
35  * works, are licensed by TI for use only with TI Devices.
36  *
37  * Neither the name of Texas Instruments Incorporated nor the names of its suppliers may be used to endorse or
38  * promote products derived from this software without specific prior written permission.
39  *
40  * DISCLAIMER.
41  *
42  * THIS SOFTWARE IS PROVIDED BY TI AND TI"S LICENSORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
43  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
44  * IN NO EVENT SHALL TI AND TI"S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
45  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
46  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
47  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
48  * POSSIBILITY OF SUCH DAMAGE.
49 */
59 #ifndef CB_IPCSOCK_H_
60 #define CB_IPCSOCK_H_
61 
62 typedef enum {
66  CB_IPCCLIENT_LAST, // layer private numbers after here
68 
77 int cb_fdread_timeout(int fd, void *data, int size, int tout_ms);
78 
88 int cb_ipcsocket_init(CB_SOCKET_T *ipcfd, char *node, char *suffix, char *server_node);
89 
98 int cb_ipcsocket_udp_init(CB_SOCKET_T *ipcfd, char *own_ip, char *server_ip, int server_port);
99 
108 int cb_ipcsocket_close(CB_SOCKET_T ipcfd, char *node, char *suffix);
109 
110 /*
111  * this number of IPC clients can be allowed to connect.
112  * 2-connection memory data is expanded by increasing of connections,
113  * and when the disconnection is detected the data is removed and freed.
114  */
115 #define MAX_IPC_CLIENTS 16
116 typedef struct cb_ipcserverd cb_ipcserverd_t;
117 
125 cb_ipcserverd_t *cb_ipcsocket_server_init(char *node_ip, char *suffix, uint16_t port);
126 
132 
144  struct sockaddr *client_address);
145 
150 typedef int(* cb_ipcsocket_server_ddatacb)(void *cbdata, uint8_t **sdata,
151  int *size, struct sockaddr *addr);
152 
164 
165 
170 typedef int(* cb_ipcsocket_server_rdcb)(void *cbdata, uint8_t *rdata,
171  int size, struct sockaddr *addr);
172 
182  cb_ipcsocket_server_rdcb ipccb, void *cbdata);
183 
188 
192 int cb_ipcsocket_remove_client(cb_ipcserverd_t *ipcsd, struct sockaddr *client_address);
193 
194 
202  struct sockaddr *client_address);
203 
204 
212 int cb_ipcsocket_set_commode(cb_ipcserverd_t *ipcsd, struct sockaddr *client_address,
213  cb_ipcclient_commode_t commode);
214 
215 #endif
216 
CB_IPCCLIENT_DEFAULT
@ CB_IPCCLIENT_DEFAULT
Definition: cb_ipcsock.h:63
CB_IPCCLIENT_TEXT
@ CB_IPCCLIENT_TEXT
Definition: cb_ipcsock.h:65
size
uint16_t size
Definition: tisci_boardcfg.h:1
cb_ipcsocket_udp_init
int cb_ipcsocket_udp_init(CB_SOCKET_T *ipcfd, char *own_ip, char *server_ip, int server_port)
open Unix Domain Socket in UDP mode for IPC
cb_ipcsocket_server_init
cb_ipcserverd_t * cb_ipcsocket_server_init(char *node_ip, char *suffix, uint16_t port)
initialize the server mode ipc socket
cb_ipcsocket_server_rdcb
int(* cb_ipcsocket_server_rdcb)(void *cbdata, uint8_t *rdata, int size, struct sockaddr *addr)
callback function to be called from 'cb_ipcsocket_server_read'
Definition: cb_ipcsock.h:170
cb_ipcsocket_server_write
int cb_ipcsocket_server_write(cb_ipcserverd_t *ipcsd, uint8_t *data, int size, struct sockaddr *client_address)
send ipc data to a specific client_address or internally managed IPC clients
cb_ipcsocket_get_commode
cb_ipcclient_commode_t cb_ipcsocket_get_commode(cb_ipcserverd_t *ipcsd, struct sockaddr *client_address)
get IPC ipc communication mode
cb_ipcsocket_remove_client
int cb_ipcsocket_remove_client(cb_ipcserverd_t *ipcsd, struct sockaddr *client_address)
remove IPC client from the managed list
data
uint32_t data
Definition: tisci_rm_psil.h:1
cb_ipcsocket_server_write_ddata
int cb_ipcsocket_server_write_ddata(cb_ipcserverd_t *ipcsd, void *cbdata, cb_ipcsocket_server_ddatacb ddatacb)
send ipc data to all clients
addr
uint64_t addr
Definition: csl_udmap_tr.h:3
sockaddr
Definition: cb_lld_ethernet.h:141
CB_IPCCLIENT_BINARY
@ CB_IPCCLIENT_BINARY
Definition: cb_ipcsock.h:64
cb_ipcsocket_close
int cb_ipcsocket_close(CB_SOCKET_T ipcfd, char *node, char *suffix)
close Unix Domain Socket for IPC
cb_ipcsocket_set_commode
int cb_ipcsocket_set_commode(cb_ipcserverd_t *ipcsd, struct sockaddr *client_address, cb_ipcclient_commode_t commode)
get IPC ipc communication mode
cb_ipcsocket_getfd
CB_SOCKET_T cb_ipcsocket_getfd(cb_ipcserverd_t *ipcsd)
return ipc socket fd
cb_ipcsocket_server_ddatacb
int(* cb_ipcsocket_server_ddatacb)(void *cbdata, uint8_t **sdata, int *size, struct sockaddr *addr)
callback function to get sending data
Definition: cb_ipcsock.h:150
cb_fdread_timeout
int cb_fdread_timeout(int fd, void *data, int size, int tout_ms)
read from file descriptor with timeout
cb_ipcserverd_t
struct cb_ipcserverd cb_ipcserverd_t
Definition: cb_ipcsock.h:116
cb_ipcclient_commode_t
cb_ipcclient_commode_t
Definition: cb_ipcsock.h:62
cb_ipcsocket_init
int cb_ipcsocket_init(CB_SOCKET_T *ipcfd, char *node, char *suffix, char *server_node)
creats and initializes Unix Domain Socket for IPC
cb_ipcsocket_server_read
int cb_ipcsocket_server_read(cb_ipcserverd_t *ipcsd, cb_ipcsocket_server_rdcb ipccb, void *cbdata)
receive data on the IPC socket.
cb_ipcsocket_server_close
void cb_ipcsocket_server_close(cb_ipcserverd_t *ipcsd)
close the server mode ipc socket
CB_SOCKET_T
#define CB_SOCKET_T
Definition: cb_lld_ethernet.h:78
CB_IPCCLIENT_LAST
@ CB_IPCCLIENT_LAST
Definition: cb_ipcsock.h:66