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