- belongs to previous commit ;-)
[strongswan.git] / Source / charon / threads / stroke.h
1 /**
2 * @file stroke.h
3 *
4 * @brief Interface of stroke_t.
5 *
6 */
7
8 /*
9 * Copyright (C) 2006 Martin Willi
10 * Hochschule fuer Technik Rapperswil
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
21 */
22
23 #ifndef STROKE_H_
24 #define STROKE_H_
25
26 #include <config/policy_store.h>
27 #include <config/connection_store.h>
28 #include <config/credential_store.h>
29
30
31 #define STROKE_SOCKET "/var/run/charon.ctl"
32
33 /**
34 * @brief A stroke message sent over the unix socket.
35 *
36 */
37 typedef struct stroke_msg_t stroke_msg_t;
38
39 struct stroke_msg_t {
40 /* length of this message with all strings */
41 u_int16_t length;
42 /* type of the message */
43 enum {
44 /* initiate a connection */
45 STR_INITIATE,
46 /* install SPD entries for a connection */
47 STR_INSTALL,
48 /* add a connection */
49 STR_ADD_CONN,
50 /* delete a connection */
51 STR_DEL_CONN,
52 /* more to come */
53 } type;
54 union {
55 /* data for STR_INITIATE, STR_INSTALL */
56 struct {
57 char *name;
58 } initiate, install;
59 /* data for STR_ADD_CONN */
60 struct {
61 char *name;
62 struct {
63 union {
64 u_int16_t family;
65 struct sockaddr saddr;
66 struct sockaddr_in v4;
67 struct sockaddr_in6 v6;
68 } address;
69 char *id;
70 union {
71 u_int16_t family;
72 struct sockaddr saddr;
73 struct sockaddr_in v4;
74 struct sockaddr_in6 v6;
75 } subnet;
76 u_int8_t subnet_netbits;
77 } me, other;
78 } add_conn;
79 };
80 u_int8_t buffer[];
81 };
82
83
84 typedef struct stroke_t stroke_t;
85
86 /**
87 * @brief Stroke is a configuration and control interface which
88 * allows other processes to modify charons behavior.
89 *
90 * stroke_t allows config manipulation (as whack in pluto).
91 * Messages of type stroke_msg_t's are sent over a unix socket
92 * (/var/run/charon.ctl). stroke_t implements the connections_t
93 * and the policies_t interface, which means it acts as a
94 * configuration backend for those too. stroke_t uses an own
95 * thread to read from the socket.
96 *
97 * @warning DO NOT cast stroke_t to any of the implemented interfaces!
98 * stroke_t implements multiple interfaces, so you must use
99 * stroke_t.interface_xy to access the specific interface! You have
100 * been warned...
101 *
102 * @b Constructors:
103 * - stroke_create()
104 *
105 * @ingroup config
106 */
107 struct stroke_t {
108
109 /**
110 * Implements connection_store_t interface
111 */
112 connection_store_t connections;
113
114 /**
115 * Implements policy_store_t interface
116 */
117 policy_store_t policies;
118
119 /**
120 * Implements credential_store_t interfacce
121 */
122 credential_store_t credentials;
123
124 /**
125 * @brief Destroy a stroke_t instance.
126 *
127 * @param this stroke_t objec to destroy
128 */
129 void (*destroy) (stroke_t *this);
130 };
131
132
133 /**
134 * @brief Create the stroke interface and listen on the socket.
135 *
136 * @return stroke_t object
137 *
138 * @ingroup config
139 */
140 stroke_t *stroke_create();
141
142 #endif /* STROKE_H_ */