97c304a16f45593944215ac1948eabec337cab78
[strongswan.git] / src / charon / 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 '1',
22 dpd_action INTEGER NOT NULL DEFAULT '0',
23 close_action INTEGER NOT NULL DEFAULT '0',
24 ipcomp INTEGER NOT NULL DEFAULT '0'
25 );
26 DROP INDEX IF EXISTS child_configs_name;
27 CREATE INDEX child_configs_name ON child_configs (
28 name
29 );
30
31
32 DROP TABLE IF EXISTS child_config_traffic_selector;
33 CREATE TABLE child_config_traffic_selector (
34 child_cfg INTEGER NOT NULL,
35 traffic_selector INTEGER NOT NULL,
36 kind INTEGER NOT NULL
37 );
38 DROP INDEX IF EXISTS child_config_traffic_selector;
39 CREATE INDEX child_config_traffic_selector_all ON child_config_traffic_selector (
40 child_cfg, traffic_selector
41 );
42
43
44 DROP TABLE IF EXISTS ike_configs;
45 CREATE TABLE ike_configs (
46 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
47 certreq INTEGER NOT NULL DEFAULT '1',
48 force_encap INTEGER NOT NULL DEFAULT '0',
49 local TEXT NOT NULL,
50 remote TEXT NOT NULL
51 );
52
53
54 DROP TABLE IF EXISTS peer_configs;
55 CREATE TABLE peer_configs (
56 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
57 name TEXT NOT NULL,
58 ike_version INTEGER NOT NULL DEFAULT '2',
59 ike_cfg INTEGER NOT NULL,
60 local_id TEXT NOT NULL,
61 remote_id TEXT NOT NULL,
62 cert_policy INTEGER NOT NULL DEFAULT '1',
63 uniqueid INTEGER NOT NULL DEFAULT '0',
64 auth_method INTEGER NOT NULL DEFAULT '1',
65 eap_type INTEGER NOT NULL DEFAULT '0',
66 eap_vendor INTEGER NOT NULL DEFAULT '0',
67 keyingtries INTEGER NOT NULL DEFAULT '3',
68 rekeytime INTEGER NOT NULL DEFAULT '7200',
69 reauthtime INTEGER NOT NULL DEFAULT '0',
70 jitter INTEGER NOT NULL DEFAULT '180',
71 overtime INTEGER NOT NULL DEFAULT '300',
72 mobike INTEGER NOT NULL DEFAULT '1',
73 dpd_delay INTEGER NOT NULL DEFAULT '120',
74 virtual TEXT DEFAULT NULL,
75 pool TEXT DEFAULT NULL,
76 mediation INTEGER NOT NULL DEFAULT '0',
77 mediated_by INTEGER NOT NULL DEFAULT '0',
78 peer_id INTEGER NOT NULL DEFAULT '0'
79 );
80 DROP INDEX IF EXISTS peer_configs_name;
81 CREATE INDEX peer_configs_name ON peer_configs (
82 name
83 );
84
85
86 DROP TABLE IF EXISTS peer_config_child_config;
87 CREATE TABLE peer_config_child_config (
88 peer_cfg INTEGER NOT NULL,
89 child_cfg INTEGER NOT NULL,
90 PRIMARY KEY (peer_cfg, child_cfg)
91 );
92
93
94 DROP TABLE IF EXISTS traffic_selectors;
95 CREATE TABLE traffic_selectors (
96 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
97 type INTEGER NOT NULL DEFAULT '7',
98 protocol INTEGER NOT NULL DEFAULT '0',
99 start_addr BLOB DEFAULT NULL,
100 end_addr BLOB DEFAULT NULL,
101 start_port INTEGER NOT NULL DEFAULT '0',
102 end_port INTEGER NOT NULL DEFAULT '65535'
103 );
104
105
106 DROP TABLE IF EXISTS certificates;
107 CREATE TABLE certificates (
108 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
109 type INTEGER NOT NULL,
110 keytype INTEGER NOT NULL,
111 data BLOB NOT NULL
112 );
113
114
115 DROP TABLE IF EXISTS certificate_identity;
116 CREATE TABLE certificate_identity (
117 certificate INTEGER NOT NULL,
118 identity INTEGER NOT NULL,
119 PRIMARY KEY (certificate, identity)
120 );
121
122
123 DROP TABLE IF EXISTS private_keys;
124 CREATE TABLE private_keys (
125 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
126 type INTEGER NOT NULL,
127 data BLOB NOT NULL
128 );
129
130
131 DROP TABLE IF EXISTS private_key_identity;
132 CREATE TABLE private_key_identity (
133 private_key INTEGER NOT NULL,
134 identity INTEGER NOT NULL,
135 PRIMARY KEY (private_key, identity)
136 );
137
138
139 DROP TABLE IF EXISTS shared_secrets;
140 CREATE TABLE shared_secrets (
141 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
142 type INTEGER NOT NULL,
143 data BLOB NOT NULL
144 );
145
146
147 DROP TABLE IF EXISTS shared_secret_identity;
148 CREATE TABLE shared_secret_identity (
149 shared_secret INTEGER NOT NULL,
150 identity INTEGER NOT NULL,
151 PRIMARY KEY (shared_secret, identity)
152 );
153
154 DROP TABLE IF EXISTS pools;
155 CREATE TABLE pools (
156 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
157 name TEXT NOT NULL,
158 start BLOB NOT NULL,
159 end BLOB NOT NULL,
160 next BLOB NOT NULL,
161 timeout INTEGER DEFAULT NULL
162 );
163 DROP INDEX IF EXISTS pools_name;
164 CREATE INDEX pools_name ON pools (
165 name
166 );
167
168 DROP TABLE IF EXISTS leases;
169 CREATE TABLE leases (
170 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
171 pool INTEGER NOT NULL,
172 address BLOB NOT NULL,
173 identity INTEGER NOT NULL,
174 acquire INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP,
175 release INTEGER DEFAULT NULL
176 );
177 DROP INDEX IF EXISTS leases_pool;
178 CREATE INDEX leases_pool ON leases (
179 pool
180 );
181 DROP INDEX IF EXISTS leases_identity;
182 CREATE INDEX leases_identity ON leases (
183 identity
184 );
185 DROP INDEX IF EXISTS leases_release;
186 CREATE INDEX leases_release ON leases (
187 release
188 );
189
190 DROP TABLE IF EXISTS ike_sas;
191 CREATE TABLE ike_sas (
192 local_spi BLOB NOT NULL PRIMARY KEY,
193 remote_spi BLOB NOT NULL,
194 id INTEGER NOT NULL,
195 initiator INTEGER NOT NULL,
196 local_id_type INTEGER NOT NULL,
197 local_id_data BLOB NOT NULL,
198 remote_id_type INTEGER NOT NULL,
199 remote_id_data BLOB NOT NULL,
200 host_family INTEGER NOT NULL,
201 local_host_data BLOB NOT NULL,
202 remote_host_data BLOB NOT NULL,
203 created INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP
204 );
205
206 DROP TABLE IF EXISTS logs;
207 CREATE TABLE logs (
208 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
209 local_spi BLOB NOT NULL,
210 signal INTEGER NOT NULL,
211 level INTEGER NOT NULL,
212 msg TEXT NOT NULL,
213 time INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP
214 );
215