bf182eb53230b0bd183577453fac0a0acf5c78ea
[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 *address;
81 char *subnet;
82 int subnet_mask;
83 int sendcert;
84 };
85
86 typedef struct stroke_msg_t stroke_msg_t;
87
88 /**
89 * @brief A stroke message sent over the unix socket.
90 */
91 struct stroke_msg_t {
92 /* length of this message with all strings */
93 u_int16_t length;
94
95 /* type of the message */
96 enum {
97 /* initiate a connection */
98 STR_INITIATE,
99 /* install SPD entries for a connection */
100 STR_INSTALL,
101 /* add a connection */
102 STR_ADD_CONN,
103 /* delete a connection */
104 STR_DEL_CONN,
105 /* terminate connection */
106 STR_TERMINATE,
107 /* show connection status */
108 STR_STATUS,
109 /* show verbose connection status */
110 STR_STATUS_ALL,
111 /* set a log type to log/not log */
112 STR_LOGTYPE,
113 /* set the verbosity of a logging context */
114 STR_LOGLEVEL,
115 /* list various objects */
116 STR_LIST,
117 /* reread various objects */
118 STR_REREAD
119 /* more to come */
120 } type;
121
122 union {
123 /* data for STR_INITIATE, STR_INSTALL, STR_UP, STR_DOWN, ... */
124 struct {
125 char *name;
126 } initiate, install, terminate, status, del_conn;
127
128 /* data for STR_ADD_CONN */
129 struct {
130 char *name;
131 bool ikev2;
132 struct {
133 char *ike;
134 char *esp;
135 } algorithms;
136 struct {
137 time_t ipsec_lifetime;
138 time_t ike_lifetime;
139 time_t margin;
140 unsigned long tries;
141 unsigned long fuzz;
142 } rekey;
143 stroke_end_t me, other;
144 } add_conn;
145
146 /* data for STR_LOGTYPE */
147 struct {
148 char *context;
149 char *type;
150 int enable;
151 } logtype;
152
153 /* data for STR_LOGLEVEL */
154 struct {
155 char *context;
156 int level;
157 } loglevel;
158
159 /* data for STR_LIST */
160 struct {
161 list_flag_t flags;
162 bool utc;
163 } list;
164
165 /* data for STR_REREAD */
166 struct {
167 reread_flag_t flags;
168 } reread;
169
170 };
171 char buffer[STROKE_BUF_LEN];
172 };
173
174 #endif /* STROKE_H_ */