2015-03-17 21:54:13 +00:00
|
|
|
#define ZT_NETCONF_SCHEMA_SQL \
|
|
|
|
"CREATE TABLE Config (\n"\
|
|
|
|
" k varchar(16) PRIMARY KEY NOT NULL,\n"\
|
|
|
|
" v varchar(1024) NOT NULL\n"\
|
|
|
|
");\n"\
|
|
|
|
"\n"\
|
2015-06-11 09:35:25 +00:00
|
|
|
"CREATE TABLE Network (\n"\
|
|
|
|
" id char(16) PRIMARY KEY NOT NULL,\n"\
|
|
|
|
" name varchar(128) NOT NULL,\n"\
|
|
|
|
" private integer NOT NULL DEFAULT(1),\n"\
|
|
|
|
" enableBroadcast integer NOT NULL DEFAULT(1),\n"\
|
|
|
|
" allowPassiveBridging integer NOT NULL DEFAULT(0),\n"\
|
|
|
|
" v4AssignMode varchar(8) NOT NULL DEFAULT('none'),\n"\
|
|
|
|
" v6AssignMode varchar(8) NOT NULL DEFAULT('none'),\n"\
|
|
|
|
" multicastLimit integer NOT NULL DEFAULT(32),\n"\
|
|
|
|
" creationTime integer NOT NULL DEFAULT(0),\n"\
|
2015-07-17 00:34:03 +00:00
|
|
|
" revision integer NOT NULL DEFAULT(1),\n"\
|
|
|
|
" memberRevisionCounter integer NOT NULL DEFAULT(1)\n"\
|
2015-06-11 09:35:25 +00:00
|
|
|
");\n"\
|
|
|
|
"\n"\
|
2015-07-29 22:09:23 +00:00
|
|
|
"CREATE TABLE AuthToken (\n"\
|
|
|
|
" id integer PRIMARY KEY NOT NULL,\n"\
|
|
|
|
" networkId char(16) NOT NULL REFERENCES Network(id) ON DELETE CASCADE,\n"\
|
|
|
|
" authMode integer NOT NULL DEFAULT(1),\n"\
|
|
|
|
" useCount integer NOT NULL DEFAULT(0),\n"\
|
|
|
|
" maxUses integer NOT NULL DEFAULT(0),\n"\
|
|
|
|
" expiresAt integer NOT NULL DEFAULT(0),\n"\
|
|
|
|
" token varchar(256) NOT NULL\n"\
|
|
|
|
");\n"\
|
|
|
|
"\n"\
|
|
|
|
"CREATE INDEX AuthToken_networkId_token ON AuthToken(networkId,token);\n"\
|
|
|
|
"\n"\
|
2015-06-11 09:35:25 +00:00
|
|
|
"CREATE TABLE Node (\n"\
|
|
|
|
" id char(10) PRIMARY KEY NOT NULL,\n"\
|
2015-06-29 21:52:09 +00:00
|
|
|
" identity varchar(4096) NOT NULL\n"\
|
2015-06-11 09:35:25 +00:00
|
|
|
");\n"\
|
|
|
|
"\n"\
|
2016-02-03 21:56:35 +00:00
|
|
|
"CREATE TABLE NodeHistory (\n"\
|
|
|
|
" nodeId char(10) NOT NULL REFERENCES Node(id) ON DELETE CASCADE,\n"\
|
|
|
|
" networkId char(16) NOT NULL REFERENCES Network(id) ON DELETE CASCADE,\n"\
|
|
|
|
" networkVisitCounter INTEGER NOT NULL DEFAULT(0),\n"\
|
|
|
|
" networkRequestAuthorized INTEGER NOT NULL DEFAULT(0),\n"\
|
|
|
|
" requestTime INTEGER NOT NULL DEFAULT(0),\n"\
|
2016-02-04 21:38:42 +00:00
|
|
|
" clientMajorVersion INTEGER NOT NULL DEFAULT(0),\n"\
|
|
|
|
" clientMinorVersion INTEGER NOT NULL DEFAULT(0),\n"\
|
|
|
|
" clientRevision INTEGER NOT NULL DEFAULT(0),\n"\
|
2016-02-03 21:56:35 +00:00
|
|
|
" networkRequestMetaData VARCHAR(1024),\n"\
|
|
|
|
" fromAddress VARCHAR(128)\n"\
|
|
|
|
");\n"\
|
|
|
|
"\n"\
|
|
|
|
"CREATE INDEX NodeHistory_nodeId ON NodeHistory (nodeId);\n"\
|
|
|
|
"CREATE INDEX NodeHistory_networkId ON NodeHistory (networkId);\n"\
|
|
|
|
"CREATE INDEX NodeHistory_requestTime ON NodeHistory (requestTime);\n"\
|
|
|
|
"\n"\
|
2015-03-17 21:54:13 +00:00
|
|
|
"CREATE TABLE IpAssignment (\n"\
|
2015-06-11 09:35:25 +00:00
|
|
|
" networkId char(16) NOT NULL REFERENCES Network(id) ON DELETE CASCADE,\n"\
|
2015-06-29 22:34:26 +00:00
|
|
|
" nodeId char(10) REFERENCES Node(id) ON DELETE CASCADE,\n"\
|
2015-06-29 17:40:31 +00:00
|
|
|
" type integer NOT NULL DEFAULT(0),\n"\
|
2015-03-18 23:10:48 +00:00
|
|
|
" ip blob(16) NOT NULL,\n"\
|
|
|
|
" ipNetmaskBits integer NOT NULL DEFAULT(0),\n"\
|
|
|
|
" ipVersion integer NOT NULL DEFAULT(4)\n"\
|
2015-03-17 21:54:13 +00:00
|
|
|
");\n"\
|
|
|
|
"\n"\
|
2015-06-13 08:05:34 +00:00
|
|
|
"CREATE UNIQUE INDEX IpAssignment_networkId_ip ON IpAssignment (networkId, ip);\n"\
|
2015-03-17 21:54:13 +00:00
|
|
|
"\n"\
|
|
|
|
"CREATE INDEX IpAssignment_networkId_nodeId ON IpAssignment (networkId, nodeId);\n"\
|
|
|
|
"\n"\
|
|
|
|
"CREATE TABLE IpAssignmentPool (\n"\
|
2015-06-11 09:35:25 +00:00
|
|
|
" networkId char(16) NOT NULL REFERENCES Network(id) ON DELETE CASCADE,\n"\
|
2015-06-29 17:40:31 +00:00
|
|
|
" ipRangeStart blob(16) NOT NULL,\n"\
|
|
|
|
" ipRangeEnd blob(16) NOT NULL,\n"\
|
2015-04-22 02:49:04 +00:00
|
|
|
" ipVersion integer NOT NULL DEFAULT(4)\n"\
|
2015-03-17 21:54:13 +00:00
|
|
|
");\n"\
|
|
|
|
"\n"\
|
2015-06-29 21:52:09 +00:00
|
|
|
"CREATE UNIQUE INDEX IpAssignmentPool_networkId_ipRangeStart ON IpAssignmentPool (networkId,ipRangeStart);\n"\
|
2015-03-17 21:54:13 +00:00
|
|
|
"\n"\
|
|
|
|
"CREATE TABLE Member (\n"\
|
2015-06-11 09:35:25 +00:00
|
|
|
" networkId char(16) NOT NULL REFERENCES Network(id) ON DELETE CASCADE,\n"\
|
|
|
|
" nodeId char(10) NOT NULL REFERENCES Node(id) ON DELETE CASCADE,\n"\
|
2015-03-18 23:10:48 +00:00
|
|
|
" authorized integer NOT NULL DEFAULT(0),\n"\
|
2015-06-11 09:35:25 +00:00
|
|
|
" activeBridge integer NOT NULL DEFAULT(0),\n"\
|
2015-07-17 00:42:47 +00:00
|
|
|
" memberRevision integer NOT NULL DEFAULT(0),\n"\
|
2015-06-11 09:35:25 +00:00
|
|
|
" PRIMARY KEY (networkId, nodeId)\n"\
|
2015-03-17 21:54:13 +00:00
|
|
|
");\n"\
|
|
|
|
"\n"\
|
2015-04-21 00:47:12 +00:00
|
|
|
"CREATE INDEX Member_networkId_activeBridge ON Member(networkId, activeBridge);\n"\
|
2015-07-17 00:34:03 +00:00
|
|
|
"CREATE INDEX Member_networkId_memberRevision ON Member(networkId, memberRevision);\n"\
|
2015-04-21 00:47:12 +00:00
|
|
|
"\n"\
|
2016-06-10 15:26:27 +00:00
|
|
|
"CREATE TABLE Route (\n"\
|
|
|
|
" networkId char(16) NOT NULL REFERENCES Network(id) ON DELETE CASCADE,\n"\
|
|
|
|
" target blob(16) NOT NULL,\n"\
|
2016-06-10 22:58:35 +00:00
|
|
|
" via blob(16),\n"\
|
2016-06-10 15:26:27 +00:00
|
|
|
" targetNetmaskBits integer NOT NULL,\n"\
|
|
|
|
" ipVersion integer NOT NULL,\n"\
|
|
|
|
" flags integer NOT NULL,\n"\
|
|
|
|
" metric integer NOT NULL\n"\
|
|
|
|
");\n"\
|
|
|
|
"\n"\
|
|
|
|
"CREATE INDEX Route_networkId ON Route (networkId);\n"\
|
|
|
|
"\n"\
|
2015-04-20 22:46:20 +00:00
|
|
|
"CREATE TABLE Relay (\n"\
|
2015-06-11 09:35:25 +00:00
|
|
|
" networkId char(16) NOT NULL REFERENCES Network(id) ON DELETE CASCADE,\n"\
|
2015-07-20 21:28:30 +00:00
|
|
|
" address char(10) NOT NULL,\n"\
|
|
|
|
" phyAddress varchar(64) NOT NULL\n"\
|
2015-04-20 22:46:20 +00:00
|
|
|
");\n"\
|
|
|
|
"\n"\
|
2015-07-20 21:28:30 +00:00
|
|
|
"CREATE UNIQUE INDEX Relay_networkId_address ON Relay (networkId,address);\n"\
|
2015-04-21 23:50:02 +00:00
|
|
|
"\n"\
|
2015-03-17 21:54:13 +00:00
|
|
|
"CREATE TABLE Rule (\n"\
|
2015-06-11 09:35:25 +00:00
|
|
|
" networkId char(16) NOT NULL REFERENCES Network(id) ON DELETE CASCADE,\n"\
|
2015-06-13 08:05:34 +00:00
|
|
|
" ruleNo integer NOT NULL,\n"\
|
2015-06-29 17:47:47 +00:00
|
|
|
" nodeId char(10) REFERENCES Node(id),\n"\
|
2015-06-29 22:34:26 +00:00
|
|
|
" sourcePort char(10),\n"\
|
|
|
|
" destPort char(10),\n"\
|
2015-03-18 23:10:48 +00:00
|
|
|
" vlanId integer,\n"\
|
|
|
|
" vlanPcp integer,\n"\
|
|
|
|
" etherType integer,\n"\
|
2015-03-17 21:54:13 +00:00
|
|
|
" macSource char(12),\n"\
|
|
|
|
" macDest char(12),\n"\
|
|
|
|
" ipSource varchar(64),\n"\
|
|
|
|
" ipDest varchar(64),\n"\
|
2015-03-18 23:10:48 +00:00
|
|
|
" ipTos integer,\n"\
|
|
|
|
" ipProtocol integer,\n"\
|
|
|
|
" ipSourcePort integer,\n"\
|
|
|
|
" ipDestPort integer,\n"\
|
2015-05-25 20:20:10 +00:00
|
|
|
" flags integer,\n"\
|
|
|
|
" invFlags integer,\n"\
|
2015-03-17 22:20:45 +00:00
|
|
|
" \"action\" varchar(4096) NOT NULL DEFAULT('accept')\n"\
|
2015-03-17 21:54:13 +00:00
|
|
|
");\n"\
|
|
|
|
"\n"\
|
2015-06-13 08:05:34 +00:00
|
|
|
"CREATE UNIQUE INDEX Rule_networkId_ruleNo ON Rule (networkId, ruleNo);\n"\
|
2015-03-17 21:54:13 +00:00
|
|
|
""
|