added possibility to route CHILD_SAs, without to set them up
[strongswan.git] / src / stroke / stroke.h
1 /**
2 * @file stroke.h
3 *
4 * @brief Definition of stroke_msg_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 <sys/types.h>
27
28 /**
29 * Socket which is used to communicate between charon and stroke
30 */
31 #define STROKE_SOCKET "/var/run/charon.ctl"
32
33 #define STROKE_BUF_LEN 2048
34
35 typedef enum list_flag_t list_flag_t;
36
37 /**
38 * Definition of the LIST flags, used for
39 * the various stroke list* commands.
40 */
41 enum list_flag_t {
42 /** don't list anything */
43 LIST_NONE = 0x0000,
44 /** list all host/user certs */
45 LIST_CERTS = 0x0001,
46 /** list all ca certs */
47 LIST_CACERTS = 0x0002,
48 /** list all crls */
49 LIST_CRLS = 0x0004,
50 /** all list options */
51 LIST_ALL = 0x0007,
52 };
53
54 typedef enum reread_flag_t reread_flag_t;
55
56 /**
57 * Definition of the REREAD flags, used for
58 * the various stroke reread* commands.
59 */
60 enum reread_flag_t {
61 /** don't reread anything */
62 REREAD_NONE = 0x0000,
63 /** reread all ca certs */
64 REREAD_CACERTS = 0x0001,
65 /** reread all crls */
66 REREAD_CRLS = 0x0002,
67 /** all reread options */
68 REREAD_ALL = 0x0003,
69 };
70
71 typedef struct stroke_end_t stroke_end_t;
72
73 /**
74 * definition of a peer in a stroke message
75 */
76 struct stroke_end_t {
77 char *id;
78 char *cert;
79 char *ca;
80 char *updown;
81 char *address;
82 char *subnet;
83 int subnet_mask;
84 int sendcert;
85 u_int8_t protocol;
86 u_int16_t port;
87 };
88
89 typedef struct stroke_msg_t stroke_msg_t;
90
91 /**
92 * @brief A stroke message sent over the unix socket.
93 */
94 struct stroke_msg_t {
95 /* length of this message with all strings */
96 u_int16_t length;
97
98 /* type of the message */
99 enum {
100 /* initiate a connection */
101 STR_INITIATE,
102 /* install SPD entries for a policy */
103 STR_ROUTE,
104 /* uninstall SPD entries for a policy */
105 STR_UNROUTE,
106 /* add a connection */
107 STR_ADD_CONN,
108 /* delete a connection */
109 STR_DEL_CONN,
110 /* terminate connection */
111 STR_TERMINATE,
112 /* show connection status */
113 STR_STATUS,
114 /* show verbose connection status */
115 STR_STATUS_ALL,
116 /* set a log type to log/not log */
117 STR_LOGTYPE,
118 /* set the verbosity of a logging context */
119 STR_LOGLEVEL,
120 /* list various objects */
121 STR_LIST,
122 /* reread various objects */
123 STR_REREAD
124 /* more to come */
125 } type;
126
127 union {
128 /* data for STR_INITIATE, STR_ROUTE, STR_UP, STR_DOWN, ... */
129 struct {
130 char *name;
131 } initiate, route, unroute, terminate, status, del_conn;
132
133 /* data for STR_ADD_CONN */
134 struct {
135 char *name;
136 bool ikev2;
137 struct {
138 char *ike;
139 char *esp;
140 } algorithms;
141 struct {
142 time_t ipsec_lifetime;
143 time_t ike_lifetime;
144 time_t margin;
145 unsigned long tries;
146 unsigned long fuzz;
147 } rekey;
148 stroke_end_t me, other;
149 } add_conn;
150
151 /* data for STR_LOGTYPE */
152 struct {
153 char *context;
154 char *type;
155 int enable;
156 } logtype;
157
158 /* data for STR_LOGLEVEL */
159 struct {
160 char *context;
161 int level;
162 } loglevel;
163
164 /* data for STR_LIST */
165 struct {
166 list_flag_t flags;
167 bool utc;
168 } list;
169
170 /* data for STR_REREAD */
171 struct {
172 reread_flag_t flags;
173 } reread;
174
175 };
176 char buffer[STROKE_BUF_LEN];
177 };
178
179 #endif /* STROKE_H_ */