Re-write ustcomm parts of UST v2
[ust.git] / libustcomm / ustcomm.h
... / ...
CommitLineData
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
18#ifndef USTCOMM_H
19#define USTCOMM_H
20
21#include <sys/types.h>
22#include <sys/un.h>
23#include <urcu/list.h>
24
25#include <ust/kcompat/kcompat.h>
26
27#define SOCK_DIR "/tmp/ust-app-socks"
28#define UST_SIGNAL SIGIO
29
30struct ustcomm_sock {
31 struct list_head list;
32 int fd;
33 int epoll_fd;
34};
35
36struct ustcomm_header {
37 int type;
38 long size;
39 int command;
40 int response;
41 int fd_included;
42};
43
44
45//int send_message_pid(pid_t pid, const char *msg, char **reply);
46
47/* Ensure directory existence, usefull for unix sockets */
48extern int ensure_dir_exists(const char *dir);
49
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);
54
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);
60
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);
66
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);
72
73
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);
80extern int nth_token_is(const char *str, const char *token, int tok_no);
81
82extern char *nth_token(const char *str, int tok_no);
83
84#endif /* USTCOMM_H */
This page took 0.022641 seconds and 4 git commands to generate.