updated sql plugin to respect config changes
[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 );
25 DROP INDEX IF EXISTS child_configs_name;
26 CREATE INDEX child_configs_name ON child_configs (
27 name
28 );
29
30
31 DROP TABLE IF EXISTS child_config_traffic_selector;
32 CREATE TABLE child_config_traffic_selector (
33 child_cfg INTEGER NOT NULL,
34 traffic_selector INTEGER NOT NULL,
35 kind INTEGER NOT NULL
36 );
37 DROP INDEX IF EXISTS child_config_traffic_selector;
38 CREATE INDEX child_config_traffic_selector_all ON child_config_traffic_selector (
39 child_cfg, traffic_selector
40 );
41
42
43 DROP TABLE IF EXISTS ike_configs;
44 CREATE TABLE ike_configs (
45 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
46 certreq INTEGER NOT NULL DEFAULT '1',
47 force_encap INTEGER NOT NULL DEFAULT '0',
48 local TEXT NOT NULL,
49 remote TEXT NOT NULL
50 );
51
52
53 DROP TABLE IF EXISTS peer_configs;
54 CREATE TABLE peer_configs (
55 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
56 name TEXT NOT NULL,
57 ike_version INTEGER NOT NULL DEFAULT '2',
58 ike_cfg INTEGER NOT NULL,
59 local_id TEXT NOT NULL,
60 remote_id TEXT NOT NULL,
61 cert_policy INTEGER NOT NULL DEFAULT '1',
62 uniqueid INTEGER NOT NULL DEFAULT '0',
63 auth_method INTEGER NOT NULL DEFAULT '1',
64 eap_type INTEGER NOT NULL DEFAULT '0',
65 eap_vendor INTEGER NOT NULL DEFAULT '0',
66 keyingtries INTEGER NOT NULL DEFAULT '3',
67 rekeytime INTEGER NOT NULL DEFAULT '7200',
68 reauthtime INTEGER NOT NULL DEFAULT '0',
69 jitter INTEGER NOT NULL DEFAULT '180',
70 overtime INTEGER NOT NULL DEFAULT '300',
71 mobike INTEGER NOT NULL DEFAULT '1',
72 dpd_delay INTEGER NOT NULL DEFAULT '120',
73 virtual TEXT DEFAULT NULL,
74 pool TEXT DEFAULT NULL,
75 mediation INTEGER NOT NULL DEFAULT '0',
76 mediated_by INTEGER NOT NULL DEFAULT '0',
77 peer_id INTEGER NOT NULL DEFAULT '0'
78 );
79 DROP INDEX IF EXISTS peer_configs_name;
80 CREATE INDEX peer_configs_name ON peer_configs (
81 name
82 );
83
84
85 DROP TABLE IF EXISTS peer_config_child_config;
86 CREATE TABLE peer_config_child_config (
87 peer_cfg INTEGER NOT NULL,
88 child_cfg INTEGER NOT NULL,
89 PRIMARY KEY (peer_cfg, child_cfg)
90 );
91
92
93 DROP TABLE IF EXISTS traffic_selectors;
94 CREATE TABLE traffic_selectors (
95 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
96 type INTEGER NOT NULL DEFAULT '7',
97 protocol INTEGER NOT NULL DEFAULT '0',
98 start_addr BLOB DEFAULT NULL,
99 end_addr BLOB DEFAULT NULL,
100 start_port INTEGER NOT NULL DEFAULT '0',
101 end_port INTEGER NOT NULL DEFAULT '65535'
102 );
103
104
105 DROP TABLE IF EXISTS certificates;
106 CREATE TABLE certificates (
107 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
108 type INTEGER NOT NULL,
109 keytype INTEGER NOT NULL,
110 data BLOB NOT NULL
111 );
112
113
114 DROP TABLE IF EXISTS certificate_identity;
115 CREATE TABLE certificate_identity (
116 certificate INTEGER NOT NULL,
117 identity INTEGER NOT NULL,
118 PRIMARY KEY (certificate, identity)
119 );
120
121
122 DROP TABLE IF EXISTS private_keys;
123 CREATE TABLE private_keys (
124 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
125 type INTEGER NOT NULL,
126 data BLOB NOT NULL
127 );
128
129
130 DROP TABLE IF EXISTS private_key_identity;
131 CREATE TABLE private_key_identity (
132 private_key INTEGER NOT NULL,
133 identity INTEGER NOT NULL,
134 PRIMARY KEY (private_key, identity)
135 );
136
137
138 DROP TABLE IF EXISTS shared_secrets;
139 CREATE TABLE shared_secrets (
140 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
141 type INTEGER NOT NULL,
142 data BLOB NOT NULL
143 );
144
145
146 DROP TABLE IF EXISTS shared_secret_identity;
147 CREATE TABLE shared_secret_identity (
148 shared_secret INTEGER NOT NULL,
149 identity INTEGER NOT NULL,
150 PRIMARY KEY (shared_secret, identity)
151 );
152
153
154 DROP TABLE IF EXISTS ike_sas;
155 CREATE TABLE ike_sas (
156 local_spi BLOB NOT NULL PRIMARY KEY,
157 remote_spi BLOB NOT NULL,
158 id INTEGER NOT NULL,
159 initiator INTEGER NOT NULL,
160 local_id_type INTEGER NOT NULL,
161 local_id_data BLOB NOT NULL,
162 remote_id_type INTEGER NOT NULL,
163 remote_id_data BLOB NOT NULL,
164 host_family INTEGER NOT NULL,
165 local_host_data BLOB NOT NULL,
166 remote_host_data BLOB NOT NULL,
167 created INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP
168 );
169
170
171 DROP TABLE IF EXISTS logs;
172 CREATE TABLE logs (
173 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
174 local_spi BLOB NOT NULL,
175 signal INTEGER NOT NULL,
176 level INTEGER NOT NULL,
177 msg TEXT NOT NULL,
178 time INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP
179 );
180