better normalized tables for SQL plugin (IDs)
[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 '1',
21 mode INTEGER NOT NULL DEFAULT '1'
22 );
23 DROP INDEX IF EXISTS child_configs_name;
24 CREATE INDEX child_configs_name ON child_configs (
25 name
26 );
27
28
29 DROP TABLE IF EXISTS child_config_traffic_selector;
30 CREATE TABLE child_config_traffic_selector (
31 child_cfg INTEGER NOT NULL,
32 traffic_selector INTEGER NOT NULL,
33 kind INTEGER NOT NULL
34 );
35 DROP INDEX IF EXISTS child_config_traffic_selector;
36 CREATE INDEX child_config_traffic_selector_all ON child_config_traffic_selector (
37 child_cfg, traffic_selector
38 );
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
51 DROP TABLE IF EXISTS peer_configs;
52 CREATE TABLE peer_configs (
53 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
54 name TEXT NOT NULL,
55 ike_version INTEGER NOT NULL DEFAULT '2',
56 ike_cfg INTEGER NOT NULL,
57 local_id TEXT NOT NULL,
58 remote_id TEXT NOT NULL,
59 cert_policy INTEGER NOT NULL DEFAULT '1',
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 '3',
64 rekeytime INTEGER NOT NULL DEFAULT '7200',
65 reauthtime INTEGER NOT NULL DEFAULT '0',
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 dpd_action INTEGER NOT NULL DEFAULT '1',
71 mediation INTEGER NOT NULL DEFAULT '0',
72 mediated_by INTEGER NOT NULL DEFAULT '0',
73 peer_id INTEGER NOT NULL DEFAULT '0'
74 );
75 DROP INDEX IF EXISTS peer_configs_name;
76 CREATE INDEX peer_configs_name ON peer_configs (
77 name
78 );
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
89 DROP TABLE IF EXISTS traffic_selectors;
90 CREATE TABLE traffic_selectors (
91 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
92 type INTEGER NOT NULL DEFAULT '7',
93 protocol INTEGER NOT NULL DEFAULT '0',
94 start_addr BLOB DEFAULT NULL,
95 end_addr BLOB DEFAULT NULL,
96 start_port INTEGER NOT NULL DEFAULT '0',
97 end_port INTEGER NOT NULL DEFAULT '65535'
98 );
99
100
101 DROP TABLE IF EXISTS certificates;
102 CREATE TABLE certificates (
103 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
104 type INTEGER NOT NULL,
105 keytype INTEGER NOT NULL,
106 data BLOB NOT NULL
107 );
108
109
110 DROP TABLE IF EXISTS certificate_identity;
111 CREATE TABLE certificate_identity (
112 certificate INTEGER NOT NULL,
113 identity INTEGER NOT NULL,
114 PRIMARY KEY (certificate, identity)
115 );
116
117
118 DROP TABLE IF EXISTS private_keys;
119 CREATE TABLE private_keys (
120 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
121 type INTEGER NOT NULL,
122 data BLOB NOT NULL
123 );
124
125
126 DROP TABLE IF EXISTS private_key_identity;
127 CREATE TABLE private_key_identity (
128 private_key INTEGER NOT NULL,
129 identity INTEGER NOT NULL,
130 PRIMARY KEY (private_key, identity)
131 );
132
133
134 DROP TABLE IF EXISTS shared_secrets;
135 CREATE TABLE shared_secrets (
136 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
137 type INTEGER NOT NULL,
138 data BLOB NOT NULL
139 );
140
141
142 DROP TABLE IF EXISTS shared_secret_identity;
143 CREATE TABLE shared_secret_identity (
144 shared_secret INTEGER NOT NULL,
145 identity INTEGER NOT NULL,
146 PRIMARY KEY (shared_secret, identity)
147 );
148
149
150 DROP TABLE IF EXISTS ike_sas;
151 CREATE TABLE ike_sas (
152 local_spi BLOB NOT NULL PRIMARY KEY,
153 remote_spi BLOB NOT NULL,
154 id INTEGER NOT NULL,
155 initiator INTEGER NOT NULL,
156 local_id_type INTEGER NOT NULL,
157 local_id_data BLOB NOT NULL,
158 remote_id_type INTEGER NOT NULL,
159 remote_id_data BLOB NOT NULL,
160 host_family INTEGER NOT NULL,
161 local_host_data BLOB NOT NULL,
162 remote_host_data BLOB NOT NULL,
163 created INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP
164 );
165
166
167 DROP TABLE IF EXISTS logs;
168 CREATE TABLE logs (
169 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
170 local_spi BLOB NOT NULL,
171 signal INTEGER NOT NULL,
172 level INTEGER NOT NULL,
173 msg TEXT NOT NULL,
174 time INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP
175 );
176