added support for leftprotoport and rightprotoport
[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 connection */
103 STR_INSTALL,
104 /* add a connection */
105 STR_ADD_CONN,
106 /* delete a connection */
107 STR_DEL_CONN,
108 /* terminate connection */
109 STR_TERMINATE,
110 /* show connection status */
111 STR_STATUS,
112 /* show verbose connection status */
113 STR_STATUS_ALL,
114 /* set a log type to log/not log */
115 STR_LOGTYPE,
116 /* set the verbosity of a logging context */
117 STR_LOGLEVEL,
118 /* list various objects */
119 STR_LIST,
120 /* reread various objects */
121 STR_REREAD
122 /* more to come */
123 } type;
124
125 union {
126 /* data for STR_INITIATE, STR_INSTALL, STR_UP, STR_DOWN, ... */
127 struct {
128 char *name;
129 } initiate, install, terminate, status, del_conn;
130
131 /* data for STR_ADD_CONN */
132 struct {
133 char *name;
134 bool ikev2;
135 struct {
136 char *ike;
137 char *esp;
138 } algorithms;
139 struct {
140 time_t ipsec_lifetime;
141 time_t ike_lifetime;
142 time_t margin;
143 unsigned long tries;
144 unsigned long fuzz;
145 } rekey;
146 stroke_end_t me, other;
147 } add_conn;
148
149 /* data for STR_LOGTYPE */
150 struct {
151 char *context;
152 char *type;
153 int enable;
154 } logtype;
155
156 /* data for STR_LOGLEVEL */
157 struct {
158 char *context;
159 int level;
160 } loglevel;
161
162 /* data for STR_LIST */
163 struct {
164 list_flag_t flags;
165 bool utc;
166 } list;
167
168 /* data for STR_REREAD */
169 struct {
170 reread_flag_t flags;
171 } reread;
172
173 };
174 char buffer[STROKE_BUF_LEN];
175 };
176
177 #endif /* STROKE_H_ */