start and route connections defined in an SQL database via start_action field and...
[strongswan.git] / src / libcharon / plugins / sql / sqlite.sql
1
2
3 DROP TABLE IF EXISTS identities;
4 CREATE TABLE identities (
5 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
6 type INTEGER NOT NULL,
7 data BLOB NOT NULL,
8 UNIQUE (type, data)
9 );
10
11
12 DROP TABLE IF EXISTS child_configs;
13 CREATE TABLE child_configs (
14 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
15 name TEXT NOT NULL,
16 lifetime INTEGER NOT NULL DEFAULT '1500',
17 rekeytime INTEGER NOT NULL DEFAULT '1200',
18 jitter INTEGER NOT NULL DEFAULT '60',
19 updown TEXT DEFAULT NULL,
20 hostaccess INTEGER NOT NULL DEFAULT '0',
21 mode INTEGER NOT NULL DEFAULT '2',
22 start_action INTEGER NOT NULL DEFAULT '0',
23 dpd_action INTEGER NOT NULL DEFAULT '0',
24 close_action INTEGER NOT NULL DEFAULT '0',
25 ipcomp INTEGER NOT NULL DEFAULT '0'
26 );
27 DROP INDEX IF EXISTS child_configs_name;
28 CREATE INDEX child_configs_name ON child_configs (
29 name
30 );
31
32
33 DROP TABLE IF EXISTS child_config_traffic_selector;
34 CREATE TABLE child_config_traffic_selector (
35 child_cfg INTEGER NOT NULL,
36 traffic_selector INTEGER NOT NULL,
37 kind INTEGER NOT NULL
38 );
39 DROP INDEX IF EXISTS child_config_traffic_selector;
40 CREATE INDEX child_config_traffic_selector_all ON child_config_traffic_selector (
41 child_cfg, traffic_selector
42 );
43
44
45 DROP TABLE IF EXISTS ike_configs;
46 CREATE TABLE ike_configs (
47 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
48 certreq INTEGER NOT NULL DEFAULT '1',
49 force_encap INTEGER NOT NULL DEFAULT '0',
50 local TEXT NOT NULL,
51 remote TEXT NOT NULL
52 );
53
54
55 DROP TABLE IF EXISTS peer_configs;
56 CREATE TABLE peer_configs (
57 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
58 name TEXT NOT NULL,
59 ike_version INTEGER NOT NULL DEFAULT '2',
60 ike_cfg INTEGER NOT NULL,
61 local_id TEXT NOT NULL,
62 remote_id TEXT NOT NULL,
63 cert_policy INTEGER NOT NULL DEFAULT '1',
64 uniqueid INTEGER NOT NULL DEFAULT '0',
65 auth_method INTEGER NOT NULL DEFAULT '1',
66 eap_type INTEGER NOT NULL DEFAULT '0',
67 eap_vendor INTEGER NOT NULL DEFAULT '0',
68 keyingtries INTEGER NOT NULL DEFAULT '3',
69 rekeytime INTEGER NOT NULL DEFAULT '7200',
70 reauthtime INTEGER NOT NULL DEFAULT '0',
71 jitter INTEGER NOT NULL DEFAULT '180',
72 overtime INTEGER NOT NULL DEFAULT '300',
73 mobike INTEGER NOT NULL DEFAULT '1',
74 dpd_delay INTEGER NOT NULL DEFAULT '120',
75 virtual TEXT DEFAULT NULL,
76 pool TEXT DEFAULT NULL,
77 mediation INTEGER NOT NULL DEFAULT '0',
78 mediated_by INTEGER NOT NULL DEFAULT '0',
79 peer_id INTEGER NOT NULL DEFAULT '0'
80 );
81 DROP INDEX IF EXISTS peer_configs_name;
82 CREATE INDEX peer_configs_name ON peer_configs (
83 name
84 );
85
86
87 DROP TABLE IF EXISTS peer_config_child_config;
88 CREATE TABLE peer_config_child_config (
89 peer_cfg INTEGER NOT NULL,
90 child_cfg INTEGER NOT NULL,
91 PRIMARY KEY (peer_cfg, child_cfg)
92 );
93
94
95 DROP TABLE IF EXISTS traffic_selectors;
96 CREATE TABLE traffic_selectors (
97 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
98 type INTEGER NOT NULL DEFAULT '7',
99 protocol INTEGER NOT NULL DEFAULT '0',
100 start_addr BLOB DEFAULT NULL,
101 end_addr BLOB DEFAULT NULL,
102 start_port INTEGER NOT NULL DEFAULT '0',
103 end_port INTEGER NOT NULL DEFAULT '65535'
104 );
105
106
107 DROP TABLE IF EXISTS certificates;
108 CREATE TABLE certificates (
109 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
110 type INTEGER NOT NULL,
111 keytype INTEGER NOT NULL,
112 data BLOB NOT NULL
113 );
114
115
116 DROP TABLE IF EXISTS certificate_identity;
117 CREATE TABLE certificate_identity (
118 certificate INTEGER NOT NULL,
119 identity INTEGER NOT NULL,
120 PRIMARY KEY (certificate, identity)
121 );
122
123
124 DROP TABLE IF EXISTS private_keys;
125 CREATE TABLE private_keys (
126 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
127 type INTEGER NOT NULL,
128 data BLOB NOT NULL
129 );
130
131
132 DROP TABLE IF EXISTS private_key_identity;
133 CREATE TABLE private_key_identity (
134 private_key INTEGER NOT NULL,
135 identity INTEGER NOT NULL,
136 PRIMARY KEY (private_key, identity)
137 );
138
139
140 DROP TABLE IF EXISTS shared_secrets;
141 CREATE TABLE shared_secrets (
142 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
143 type INTEGER NOT NULL,
144 data BLOB NOT NULL
145 );
146
147
148 DROP TABLE IF EXISTS shared_secret_identity;
149 CREATE TABLE shared_secret_identity (
150 shared_secret INTEGER NOT NULL,
151 identity INTEGER NOT NULL,
152 PRIMARY KEY (shared_secret, identity)
153 );
154
155
156 DROP TABLE IF EXISTS pools;
157 CREATE TABLE pools (
158 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
159 name TEXT NOT NULL UNIQUE,
160 start BLOB NOT NULL,
161 end BLOB NOT NULL,
162 timeout INTEGER NOT NULL
163 );
164
165 DROP TABLE IF EXISTS addresses;
166 CREATE TABLE addresses (
167 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
168 pool INTEGER NOT NULL,
169 address BLOB NOT NULL,
170 identity INTEGER NOT NULL,
171 acquired INTEGER NOT NULL,
172 released INTEGER NOT NULL
173 );
174 DROP INDEX IF EXISTS addresses_pool;
175 CREATE INDEX addresses_pool ON addresses (
176 pool
177 );
178 DROP INDEX IF EXISTS addresses_address;
179 CREATE INDEX addresses_address ON addresses (
180 address
181 );
182 DROP INDEX IF EXISTS addresses_identity;
183 CREATE INDEX addresses_identity ON addresses (
184 identity
185 );
186
187 DROP TABLE IF EXISTS leases;
188 CREATE TABLE leases (
189 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
190 address INTEGER NOT NULL,
191 identity INTEGER NOT NULL,
192 acquired INTEGER NOT NULL,
193 released INTEGER NOT NULL
194 );
195
196 DROP TABLE IF EXISTS attribute_pools;
197 CREATE TABLE attribute_pools (
198 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
199 name TEXT NOT NULL
200 );
201
202 DROP TABLE IF EXISTS attributes;
203 CREATE TABLE attributes (
204 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
205 identity INTEGER NOT NULL DEFAULT 0,
206 pool INTEGER NOT NULL DEFAULT 0,
207 type INTEGER NOT NULL,
208 value BLOB NOT NULL
209 );
210 DROP INDEX IF EXISTS attributes_identity;
211 CREATE INDEX attributes_identity ON attributes (
212 identity
213 );
214 DROP INDEX IF EXISTS attributes_pool;
215 CREATE INDEX attributes_pool ON attributes (
216 pool
217 );
218
219 DROP TABLE IF EXISTS ike_sas;
220 CREATE TABLE ike_sas (
221 local_spi BLOB NOT NULL PRIMARY KEY,
222 remote_spi BLOB NOT NULL,
223 id INTEGER NOT NULL,
224 initiator INTEGER NOT NULL,
225 local_id_type INTEGER NOT NULL,
226 local_id_data BLOB DEFAULT NULL,
227 remote_id_type INTEGER NOT NULL,
228 remote_id_data BLOB DEFAULT NULL,
229 host_family INTEGER NOT NULL,
230 local_host_data BLOB NOT NULL,
231 remote_host_data BLOB NOT NULL,
232 created INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP
233 );
234
235 DROP TABLE IF EXISTS logs;
236 CREATE TABLE logs (
237 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
238 local_spi BLOB NOT NULL,
239 signal INTEGER NOT NULL,
240 level INTEGER NOT NULL,
241 msg TEXT NOT NULL,
242 time INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP
243 );
244