added verbosity level to stroke
[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 bool hostaccess;
86 u_int8_t protocol;
87 u_int16_t port;
88 };
89
90 typedef struct stroke_msg_t stroke_msg_t;
91
92 /**
93 * @brief A stroke message sent over the unix socket.
94 */
95 struct stroke_msg_t {
96 /* length of this message with all strings */
97 u_int16_t length;
98
99 /* type of the message */
100 enum {
101 /* initiate a connection */
102 STR_INITIATE,
103 /* install SPD entries for a policy */
104 STR_ROUTE,
105 /* uninstall SPD entries for a policy */
106 STR_UNROUTE,
107 /* add a connection */
108 STR_ADD_CONN,
109 /* delete a connection */
110 STR_DEL_CONN,
111 /* terminate connection */
112 STR_TERMINATE,
113 /* show connection status */
114 STR_STATUS,
115 /* show verbose connection status */
116 STR_STATUS_ALL,
117 /* set a log type to log/not log */
118 STR_LOGLEVEL,
119 /* list various objects */
120 STR_LIST,
121 /* reread various objects */
122 STR_REREAD
123 /* more to come */
124 } type;
125
126 /* verbosity of output returned from charon (-from -1=silent to 4=private)*/
127 int output_verbosity;
128
129 union {
130 /* data for STR_INITIATE, STR_ROUTE, STR_UP, STR_DOWN, ... */
131 struct {
132 char *name;
133 } initiate, route, unroute, terminate, status, del_conn;
134
135 /* data for STR_ADD_CONN */
136 struct {
137 char *name;
138 bool ikev2;
139 int auth_method;
140 struct {
141 char *ike;
142 char *esp;
143 } algorithms;
144 struct {
145 time_t ipsec_lifetime;
146 time_t ike_lifetime;
147 time_t margin;
148 unsigned long tries;
149 unsigned long fuzz;
150 } rekey;
151 struct {
152 time_t delay;
153 int action;
154 } dpd;
155 stroke_end_t me, other;
156 } add_conn;
157
158 /* data for STR_LOGLEVEL */
159 struct {
160 char *type;
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_ */