32 #include <sys/socket.h> 45 struct sockaddr_un addr;
47 if (sock ==
NULL || sock_path ==
NULL)
49 dlt_log(LOG_ERR,
"dlt_daemon_unix_socket_open: arguments invalid");
53 if ((*sock = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
55 dlt_log(LOG_WARNING,
"unix socket: socket() error");
59 memset(&addr, 0,
sizeof(addr));
60 addr.sun_family = AF_UNIX;
61 memcpy(addr.sun_path, sock_path,
sizeof(addr.sun_path));
65 if (bind(*sock, (
struct sockaddr *) &addr,
sizeof(addr)) == -1)
67 dlt_log(LOG_WARNING,
"unix socket: bind() error");
71 if (listen(*sock, 1) == -1)
73 dlt_log(LOG_WARNING,
"unix socket: listen error");
82 int ret = close(sock);
86 sprintf(
err_string,
"unix socket close failed: %s", strerror(errno));
DltReturnValue dlt_log(int prio, char *s)
int dlt_daemon_unix_socket_send(int sock, void *data1, int size1, void *data2, int size2, char serialheader)
char err_string[DLT_DAEMON_TEXTBUFSIZE]
int dlt_daemon_unix_socket_close(int sock)
int dlt_daemon_socket_send(int sock, void *data1, int size1, void *data2, int size2, char serialheader)
int dlt_daemon_unix_socket_open(int *sock, char *sock_path)
#define DLT_DAEMON_TEXTBUFSIZE