Re-write ustcomm parts of UST v2
[ust.git] / libustcomm / ustcomm.h
CommitLineData
c39c72ee
PMF
1/* Copyright (C) 2009 Pierre-Marc Fournier
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17
f9e5ce61
PMF
18#ifndef USTCOMM_H
19#define USTCOMM_H
20
21#include <sys/types.h>
b02e31e5 22#include <sys/un.h>
22d9080d 23#include <urcu/list.h>
f9e5ce61 24
17bb07b4 25#include <ust/kcompat/kcompat.h>
aca1ad90 26
397d8454 27#define SOCK_DIR "/tmp/ust-app-socks"
ab33e65c
PP
28#define UST_SIGNAL SIGIO
29
4723ca09 30struct ustcomm_sock {
aca1ad90
PMF
31 struct list_head list;
32 int fd;
4723ca09 33 int epoll_fd;
aca1ad90
PMF
34};
35
4723ca09
NC
36struct ustcomm_header {
37 int type;
38 long size;
39 int command;
40 int response;
41 int fd_included;
811e4b93 42};
aca1ad90 43
d0b5f2b9 44
4723ca09 45//int send_message_pid(pid_t pid, const char *msg, char **reply);
b02e31e5 46
4723ca09
NC
47/* Ensure directory existence, usefull for unix sockets */
48extern int ensure_dir_exists(const char *dir);
0e4b45ac 49
4723ca09
NC
50/* Create and delete sockets */
51extern struct ustcomm_sock * ustcomm_init_sock(int fd, int epoll_fd,
52 struct list_head *list);
53extern void ustcomm_del_sock(struct ustcomm_sock *sock, int keep_in_epoll);
d0b5f2b9 54
4723ca09
NC
55/* Create and delete named sockets */
56extern struct ustcomm_sock * ustcomm_init_named_socket(const char *name,
57 int epoll_fd);
58extern void ustcomm_del_named_sock(struct ustcomm_sock *sock,
59 int keep_socket_file);
3847c3ba 60
4723ca09
NC
61/* Send and receive functions for file descriptors */
62extern int ustcomm_send_fd(int sock, const struct ustcomm_header *header,
63 const char *data, int *fd);
64extern int ustcomm_recv_fd(int sock, struct ustcomm_header *header,
65 char **data, int *fd);
d0b5f2b9 66
4723ca09
NC
67/* Normal send and receive functions */
68extern int ustcomm_send(int sock, const struct ustcomm_header *header,
69 const char *data);
70extern int ustcomm_recv(int sock, struct ustcomm_header *header,
71 char **data);
f9e5ce61 72
3bb56863 73
4723ca09
NC
74extern int ustcomm_request_consumer(pid_t pid, const char *channel);
75extern int ustcomm_connect_app(pid_t pid, int *app_fd);
76extern int ustcomm_connect_path(const char *path, int *connection_fd);
77extern int ustcomm_send_request(int sock, const char *req, char **reply);
78extern int ustcomm_send_reply(char *msg, int sock);
79extern int recv_message_conn(int sock, char **msg);
7e92827d 80extern int nth_token_is(const char *str, const char *token, int tok_no);
b02e31e5 81
7e92827d 82extern char *nth_token(const char *str, int tok_no);
b02e31e5 83
f9e5ce61 84#endif /* USTCOMM_H */
This page took 0.033483 seconds and 4 git commands to generate.