Re-write ustcomm parts of UST v2
[ust.git] / libustcomm / ustcomm.h
index 7e1960fbc3ea0a4e0de19ac0a2fe5543a57fb15b..f3c07b691d128a96515a5cd8218c38593c4c7971 100644 (file)
 
 #include <sys/types.h>
 #include <sys/un.h>
+#include <urcu/list.h>
 
-#include "kcompat.h"
+#include <ust/kcompat/kcompat.h>
 
-#define SOCK_DIR "/tmp/socks"
+#define SOCK_DIR "/tmp/ust-app-socks"
 #define UST_SIGNAL SIGIO
 
-struct ustcomm_connection {
+struct ustcomm_sock {
        struct list_head list;
        int fd;
+       int epoll_fd;
 };
 
-/* ustcomm_server must be shallow-copyable */
-struct ustcomm_server {
-       /* the "server" socket for serving the external requests */
-       int listen_fd;
-       char *socketpath;
-
-       struct list_head connections;
-};
-
-struct ustcomm_ustd {
-       struct ustcomm_server server;
-};
-
-struct ustcomm_app {
-       struct ustcomm_server server;
+struct ustcomm_header {
+       int type;
+       long size;
+       int command;
+       int response;
+       int fd_included;
 };
 
-/* ustcomm_source must be shallow-copyable */
-struct ustcomm_source {
-       int fd;
-       void *priv;
-};
-
-extern char *strdup_malloc(const char *s);
 
 //int send_message_pid(pid_t pid, const char *msg, char **reply);
-extern int ustcomm_request_consumer(pid_t pid, const char *channel);
 
-extern int ustcomm_ustd_recv_message(struct ustcomm_ustd *ustd, char **msg, struct ustcomm_source *src, int timeout);
-extern int ustcomm_app_recv_message(struct ustcomm_app *app, char **msg, struct ustcomm_source *src, int timeout);
+/* Ensure directory existence, usefull for unix sockets */
+extern int ensure_dir_exists(const char *dir);
 
-extern int ustcomm_init_app(pid_t pid, struct ustcomm_app *handle);
-extern void ustcomm_fini_app(struct ustcomm_app *handle);
+/* Create and delete sockets */
+extern struct ustcomm_sock * ustcomm_init_sock(int fd, int epoll_fd,
+                                              struct list_head *list);
+extern void ustcomm_del_sock(struct ustcomm_sock *sock, int keep_in_epoll);
 
-extern int ustcomm_init_ustd(struct ustcomm_ustd *handle, const char *sock_path);
+/* Create and delete named sockets */
+extern struct ustcomm_sock * ustcomm_init_named_socket(const char *name,
+                                                      int epoll_fd);
+extern void ustcomm_del_named_sock(struct ustcomm_sock *sock,
+                                  int keep_socket_file);
 
-extern int ustcomm_connect_app(pid_t pid, struct ustcomm_connection *conn);
-extern int ustcomm_connect_path(const char *path, struct ustcomm_connection *conn, pid_t signalpid);
-extern int ustcomm_send_request(struct ustcomm_connection *conn, const char *req, char **reply);
-extern int ustcomm_send_reply(struct ustcomm_server *server, char *msg, struct ustcomm_source *src);
-extern int ustcomm_disconnect(struct ustcomm_connection *conn);
-extern int ustcomm_close_all_connections(struct ustcomm_server *server);
+/* Send and receive functions for file descriptors */
+extern int ustcomm_send_fd(int sock, const struct ustcomm_header *header,
+                          const char *data, int *fd);
+extern int ustcomm_recv_fd(int sock, struct ustcomm_header *header,
+                          char **data, int *fd);
 
-extern int nth_token_is(char *str, char *token, int tok_no);
+/* Normal send and receive functions */
+extern int ustcomm_send(int sock, const struct ustcomm_header *header,
+                       const char *data);
+extern int ustcomm_recv(int sock, struct ustcomm_header *header,
+                       char **data);
 
-extern char *nth_token(char *str, int tok_no);
 
-extern int pid_is_online(pid_t);
+extern int ustcomm_request_consumer(pid_t pid, const char *channel);
+extern int ustcomm_connect_app(pid_t pid, int *app_fd);
+extern int ustcomm_connect_path(const char *path, int *connection_fd);
+extern int ustcomm_send_request(int sock, const char *req, char **reply);
+extern int ustcomm_send_reply(char *msg, int sock);
+extern int recv_message_conn(int sock, char **msg);
+extern int nth_token_is(const char *str, const char *token, int tok_no);
+
+extern char *nth_token(const char *str, int tok_no);
 
 #endif /* USTCOMM_H */
This page took 0.024305 seconds and 4 git commands to generate.