1*4882a593Smuzhiyun 2*4882a593Smuzhiyun #ifndef _IPCSOCKET_H 3*4882a593Smuzhiyun #define _IPCSOCKET_H 4*4882a593Smuzhiyun 5*4882a593Smuzhiyun 6*4882a593Smuzhiyun #define MAX_SOCK_NAME_LEN 64 7*4882a593Smuzhiyun 8*4882a593Smuzhiyun char sock_name[MAX_SOCK_NAME_LEN]; 9*4882a593Smuzhiyun 10*4882a593Smuzhiyun /* This structure is responsible for holding the IPC data 11*4882a593Smuzhiyun * data: hold the buffer fd 12*4882a593Smuzhiyun * len: just the length of 32-bit integer fd 13*4882a593Smuzhiyun */ 14*4882a593Smuzhiyun struct socketdata { 15*4882a593Smuzhiyun int data; 16*4882a593Smuzhiyun unsigned int len; 17*4882a593Smuzhiyun }; 18*4882a593Smuzhiyun 19*4882a593Smuzhiyun /* This API is used to open the IPC socket connection 20*4882a593Smuzhiyun * name: implies a unique socket name in the system 21*4882a593Smuzhiyun * connecttype: implies server(0) or client(1) 22*4882a593Smuzhiyun */ 23*4882a593Smuzhiyun int opensocket(int *sockfd, const char *name, int connecttype); 24*4882a593Smuzhiyun 25*4882a593Smuzhiyun /* This is the API to send socket data over IPC socket */ 26*4882a593Smuzhiyun int sendtosocket(int sockfd, struct socketdata *data); 27*4882a593Smuzhiyun 28*4882a593Smuzhiyun /* This is the API to receive socket data over IPC socket */ 29*4882a593Smuzhiyun int receivefromsocket(int sockfd, struct socketdata *data); 30*4882a593Smuzhiyun 31*4882a593Smuzhiyun /* This is the API to close the socket connection */ 32*4882a593Smuzhiyun int closesocket(int sockfd, char *name); 33*4882a593Smuzhiyun 34*4882a593Smuzhiyun 35*4882a593Smuzhiyun #endif 36