2015-03-12 21:03:53 +00:00
|
|
|
CREATE TABLE Config (
|
|
|
|
k varchar(16) PRIMARY KEY NOT NULL,
|
|
|
|
v varchar(1024) NOT NULL
|
2015-03-13 20:53:15 +00:00
|
|
|
);
|
2015-03-12 21:03:53 +00:00
|
|
|
|
2015-06-11 09:35:25 +00:00
|
|
|
CREATE TABLE Network (
|
|
|
|
id char(16) PRIMARY KEY NOT NULL,
|
|
|
|
name varchar(128) NOT NULL,
|
|
|
|
private integer NOT NULL DEFAULT(1),
|
|
|
|
enableBroadcast integer NOT NULL DEFAULT(1),
|
|
|
|
allowPassiveBridging integer NOT NULL DEFAULT(0),
|
|
|
|
multicastLimit integer NOT NULL DEFAULT(32),
|
|
|
|
creationTime integer NOT NULL DEFAULT(0),
|
2015-07-17 00:34:03 +00:00
|
|
|
revision integer NOT NULL DEFAULT(1),
|
2016-06-24 12:21:25 +00:00
|
|
|
memberRevisionCounter integer NOT NULL DEFAULT(1),
|
|
|
|
flags integer NOT NULL DEFAULT(0)
|
2015-06-11 09:35:25 +00:00
|
|
|
);
|
|
|
|
|
2015-07-29 22:09:23 +00:00
|
|
|
CREATE TABLE AuthToken (
|
|
|
|
id integer PRIMARY KEY NOT NULL,
|
|
|
|
networkId char(16) NOT NULL REFERENCES Network(id) ON DELETE CASCADE,
|
|
|
|
authMode integer NOT NULL DEFAULT(1),
|
|
|
|
useCount integer NOT NULL DEFAULT(0),
|
|
|
|
maxUses integer NOT NULL DEFAULT(0),
|
|
|
|
expiresAt integer NOT NULL DEFAULT(0),
|
|
|
|
token varchar(256) NOT NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE INDEX AuthToken_networkId_token ON AuthToken(networkId,token);
|
|
|
|
|
2015-06-11 09:35:25 +00:00
|
|
|
CREATE TABLE Node (
|
|
|
|
id char(10) PRIMARY KEY NOT NULL,
|
2015-06-29 21:52:09 +00:00
|
|
|
identity varchar(4096) NOT NULL
|
2015-06-11 09:35:25 +00:00
|
|
|
);
|
|
|
|
|
2015-03-12 21:03:53 +00:00
|
|
|
CREATE TABLE IpAssignment (
|
2015-06-11 09:35:25 +00:00
|
|
|
networkId char(16) NOT NULL REFERENCES Network(id) ON DELETE CASCADE,
|
2015-06-29 22:34:26 +00:00
|
|
|
nodeId char(10) REFERENCES Node(id) ON DELETE CASCADE,
|
2015-06-29 17:40:31 +00:00
|
|
|
type integer NOT NULL DEFAULT(0),
|
2015-03-18 23:10:48 +00:00
|
|
|
ip blob(16) NOT NULL,
|
|
|
|
ipNetmaskBits integer NOT NULL DEFAULT(0),
|
|
|
|
ipVersion integer NOT NULL DEFAULT(4)
|
2015-03-12 21:03:53 +00:00
|
|
|
);
|
|
|
|
|
2015-06-13 08:05:34 +00:00
|
|
|
CREATE UNIQUE INDEX IpAssignment_networkId_ip ON IpAssignment (networkId, ip);
|
2015-03-12 21:03:53 +00:00
|
|
|
|
|
|
|
CREATE INDEX IpAssignment_networkId_nodeId ON IpAssignment (networkId, nodeId);
|
|
|
|
|
|
|
|
CREATE TABLE IpAssignmentPool (
|
2015-06-11 09:35:25 +00:00
|
|
|
networkId char(16) NOT NULL REFERENCES Network(id) ON DELETE CASCADE,
|
2015-06-29 17:40:31 +00:00
|
|
|
ipRangeStart blob(16) NOT NULL,
|
|
|
|
ipRangeEnd blob(16) NOT NULL,
|
2015-04-22 02:49:04 +00:00
|
|
|
ipVersion integer NOT NULL DEFAULT(4)
|
2015-03-12 21:03:53 +00:00
|
|
|
);
|
|
|
|
|
2015-06-29 21:52:09 +00:00
|
|
|
CREATE UNIQUE INDEX IpAssignmentPool_networkId_ipRangeStart ON IpAssignmentPool (networkId,ipRangeStart);
|
2015-03-12 21:03:53 +00:00
|
|
|
|
|
|
|
CREATE TABLE Member (
|
2015-06-11 09:35:25 +00:00
|
|
|
networkId char(16) NOT NULL REFERENCES Network(id) ON DELETE CASCADE,
|
|
|
|
nodeId char(10) NOT NULL REFERENCES Node(id) ON DELETE CASCADE,
|
2015-03-18 23:10:48 +00:00
|
|
|
authorized integer NOT NULL DEFAULT(0),
|
2015-06-11 09:35:25 +00:00
|
|
|
activeBridge integer NOT NULL DEFAULT(0),
|
2015-07-17 00:42:47 +00:00
|
|
|
memberRevision integer NOT NULL DEFAULT(0),
|
2016-06-24 13:40:50 +00:00
|
|
|
flags integer NOT NULL DEFAULT(0),
|
2016-06-28 19:44:47 +00:00
|
|
|
lastRequestTime integer NOT NULL DEFAULT(0),
|
|
|
|
lastPowDifficulty integer NOT NULL DEFAULT(0),
|
|
|
|
lastPowTime integer NOT NULL DEFAULT(0),
|
|
|
|
recentHistory blob,
|
2015-06-11 09:35:25 +00:00
|
|
|
PRIMARY KEY (networkId, nodeId)
|
2015-03-12 21:03:53 +00:00
|
|
|
);
|
|
|
|
|
2016-06-28 01:48:02 +00:00
|
|
|
CREATE INDEX Member_networkId_nodeId ON Member(networkId,nodeId);
|
2015-04-21 00:47:12 +00:00
|
|
|
CREATE INDEX Member_networkId_activeBridge ON Member(networkId, activeBridge);
|
2015-07-17 00:34:03 +00:00
|
|
|
CREATE INDEX Member_networkId_memberRevision ON Member(networkId, memberRevision);
|
2016-06-28 19:44:47 +00:00
|
|
|
CREATE INDEX Member_networkId_lastRequestTime ON Member(networkId, lastRequestTime);
|
2015-04-21 00:47:12 +00:00
|
|
|
|
2016-06-10 15:26:27 +00:00
|
|
|
CREATE TABLE Route (
|
|
|
|
networkId char(16) NOT NULL REFERENCES Network(id) ON DELETE CASCADE,
|
|
|
|
target blob(16) NOT NULL,
|
2016-06-10 22:58:35 +00:00
|
|
|
via blob(16),
|
2016-06-10 15:26:27 +00:00
|
|
|
targetNetmaskBits integer NOT NULL,
|
|
|
|
ipVersion integer NOT NULL,
|
|
|
|
flags integer NOT NULL,
|
|
|
|
metric integer NOT NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE INDEX Route_networkId ON Route (networkId);
|
|
|
|
|
2015-04-20 22:46:20 +00:00
|
|
|
CREATE TABLE Relay (
|
2015-06-11 09:35:25 +00:00
|
|
|
networkId char(16) NOT NULL REFERENCES Network(id) ON DELETE CASCADE,
|
2015-07-20 21:28:30 +00:00
|
|
|
address char(10) NOT NULL,
|
|
|
|
phyAddress varchar(64) NOT NULL
|
2015-04-20 22:46:20 +00:00
|
|
|
);
|
|
|
|
|
2015-07-20 21:28:30 +00:00
|
|
|
CREATE UNIQUE INDEX Relay_networkId_address ON Relay (networkId,address);
|
2015-04-21 23:41:35 +00:00
|
|
|
|
2015-03-12 21:03:53 +00:00
|
|
|
CREATE TABLE Rule (
|
2015-06-11 09:35:25 +00:00
|
|
|
networkId char(16) NOT NULL REFERENCES Network(id) ON DELETE CASCADE,
|
2015-06-13 08:05:34 +00:00
|
|
|
ruleNo integer NOT NULL,
|
2015-06-29 17:47:47 +00:00
|
|
|
nodeId char(10) REFERENCES Node(id),
|
2015-06-29 22:34:26 +00:00
|
|
|
sourcePort char(10),
|
|
|
|
destPort char(10),
|
2015-03-18 23:10:48 +00:00
|
|
|
vlanId integer,
|
|
|
|
vlanPcp integer,
|
|
|
|
etherType integer,
|
2015-03-12 21:03:53 +00:00
|
|
|
macSource char(12),
|
|
|
|
macDest char(12),
|
|
|
|
ipSource varchar(64),
|
|
|
|
ipDest varchar(64),
|
2015-03-18 23:10:48 +00:00
|
|
|
ipTos integer,
|
|
|
|
ipProtocol integer,
|
|
|
|
ipSourcePort integer,
|
|
|
|
ipDestPort integer,
|
2015-05-25 20:20:10 +00:00
|
|
|
flags integer,
|
|
|
|
invFlags integer,
|
2015-03-12 21:03:53 +00:00
|
|
|
"action" varchar(4096) NOT NULL DEFAULT('accept')
|
|
|
|
);
|
|
|
|
|
2015-06-13 08:05:34 +00:00
|
|
|
CREATE UNIQUE INDEX Rule_networkId_ruleNo ON Rule (networkId, ruleNo);
|