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