Import from old repository commit 61ef2b42a9c4ba8e1600f15bb0236765edc2ad45.
[cascardo/ovs.git] / lib / unixctl.h
1 /*
2  * Copyright (c) 2008, 2009 Nicira Networks.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16
17 #ifndef UNIXCTL_H
18 #define UNIXCTL_H 1
19
20 /* Server for Unix domain socket control connection. */
21 struct unixctl_server;
22 int unixctl_server_create(const char *path, struct unixctl_server **);
23 void unixctl_server_run(struct unixctl_server *);
24 void unixctl_server_wait(struct unixctl_server *);
25 void unixctl_server_destroy(struct unixctl_server *);
26
27 /* Client for Unix domain socket control connection. */
28 struct unixctl_client;
29 int unixctl_client_create(const char *path, struct unixctl_client **);
30 void unixctl_client_destroy(struct unixctl_client *);
31 int unixctl_client_transact(struct unixctl_client *,
32                             const char *request,
33                             int *reply_code, char **reply_body);
34 const char *unixctl_client_target(const struct unixctl_client *);
35
36 /* Command registration. */
37 struct unixctl_conn;
38 void unixctl_command_register(const char *name,
39                               void (*cb)(struct unixctl_conn *,
40                                          const char *args));
41 void unixctl_command_reply(struct unixctl_conn *, int code,
42                            const char *body);
43
44 #endif /* unixctl.h */