schema.sql.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #define ZT_NETCONF_SCHEMA_SQL \
  2. "CREATE TABLE Config (\n"\
  3. " k varchar(16) PRIMARY KEY NOT NULL,\n"\
  4. " v varchar(1024) NOT NULL\n"\
  5. ");\n"\
  6. "\n"\
  7. "CREATE TABLE Network (\n"\
  8. " id char(16) PRIMARY KEY NOT NULL,\n"\
  9. " name varchar(128) NOT NULL,\n"\
  10. " private integer NOT NULL DEFAULT(1),\n"\
  11. " enableBroadcast integer NOT NULL DEFAULT(1),\n"\
  12. " allowPassiveBridging integer NOT NULL DEFAULT(0),\n"\
  13. " v4AssignMode varchar(8) NOT NULL DEFAULT('none'),\n"\
  14. " v6AssignMode varchar(8) NOT NULL DEFAULT('none'),\n"\
  15. " multicastLimit integer NOT NULL DEFAULT(32),\n"\
  16. " creationTime integer NOT NULL DEFAULT(0),\n"\
  17. " revision integer NOT NULL DEFAULT(1),\n"\
  18. " memberRevisionCounter integer NOT NULL DEFAULT(1)\n"\
  19. ");\n"\
  20. "\n"\
  21. "CREATE TABLE Node (\n"\
  22. " id char(10) PRIMARY KEY NOT NULL,\n"\
  23. " identity varchar(4096) NOT NULL\n"\
  24. ");\n"\
  25. "\n"\
  26. "CREATE TABLE Gateway (\n"\
  27. " networkId char(16) NOT NULL REFERENCES Network(id) ON DELETE CASCADE,\n"\
  28. " ip blob(16) NOT NULL,\n"\
  29. " ipVersion integer NOT NULL DEFAULT(4),\n"\
  30. " metric integer NOT NULL DEFAULT(0)\n"\
  31. ");\n"\
  32. "\n"\
  33. "CREATE UNIQUE INDEX Gateway_networkId_ip ON Gateway (networkId, ip);\n"\
  34. "\n"\
  35. "CREATE TABLE IpAssignment (\n"\
  36. " networkId char(16) NOT NULL REFERENCES Network(id) ON DELETE CASCADE,\n"\
  37. " nodeId char(10) REFERENCES Node(id) ON DELETE CASCADE,\n"\
  38. " type integer NOT NULL DEFAULT(0),\n"\
  39. " ip blob(16) NOT NULL,\n"\
  40. " ipNetmaskBits integer NOT NULL DEFAULT(0),\n"\
  41. " ipVersion integer NOT NULL DEFAULT(4)\n"\
  42. ");\n"\
  43. "\n"\
  44. "CREATE UNIQUE INDEX IpAssignment_networkId_ip ON IpAssignment (networkId, ip);\n"\
  45. "\n"\
  46. "CREATE INDEX IpAssignment_networkId_nodeId ON IpAssignment (networkId, nodeId);\n"\
  47. "\n"\
  48. "CREATE TABLE IpAssignmentPool (\n"\
  49. " networkId char(16) NOT NULL REFERENCES Network(id) ON DELETE CASCADE,\n"\
  50. " ipRangeStart blob(16) NOT NULL,\n"\
  51. " ipRangeEnd blob(16) NOT NULL,\n"\
  52. " ipVersion integer NOT NULL DEFAULT(4)\n"\
  53. ");\n"\
  54. "\n"\
  55. "CREATE UNIQUE INDEX IpAssignmentPool_networkId_ipRangeStart ON IpAssignmentPool (networkId,ipRangeStart);\n"\
  56. "\n"\
  57. "CREATE TABLE Member (\n"\
  58. " networkId char(16) NOT NULL REFERENCES Network(id) ON DELETE CASCADE,\n"\
  59. " nodeId char(10) NOT NULL REFERENCES Node(id) ON DELETE CASCADE,\n"\
  60. " authorized integer NOT NULL DEFAULT(0),\n"\
  61. " activeBridge integer NOT NULL DEFAULT(0),\n"\
  62. " memberRevision integer NOT NULL DEFAULT(0),\n"\
  63. " PRIMARY KEY (networkId, nodeId)\n"\
  64. ");\n"\
  65. "\n"\
  66. "CREATE INDEX Member_networkId_activeBridge ON Member(networkId, activeBridge);\n"\
  67. "CREATE INDEX Member_networkId_memberRevision ON Member(networkId, memberRevision);\n"\
  68. "\n"\
  69. "CREATE TABLE Relay (\n"\
  70. " networkId char(16) NOT NULL REFERENCES Network(id) ON DELETE CASCADE,\n"\
  71. " address char(10) NOT NULL,\n"\
  72. " phyAddress varchar(64) NOT NULL\n"\
  73. ");\n"\
  74. "\n"\
  75. "CREATE UNIQUE INDEX Relay_networkId_address ON Relay (networkId,address);\n"\
  76. "\n"\
  77. "CREATE TABLE Rule (\n"\
  78. " networkId char(16) NOT NULL REFERENCES Network(id) ON DELETE CASCADE,\n"\
  79. " ruleNo integer NOT NULL,\n"\
  80. " nodeId char(10) REFERENCES Node(id),\n"\
  81. " sourcePort char(10),\n"\
  82. " destPort char(10),\n"\
  83. " vlanId integer,\n"\
  84. " vlanPcp integer,\n"\
  85. " etherType integer,\n"\
  86. " macSource char(12),\n"\
  87. " macDest char(12),\n"\
  88. " ipSource varchar(64),\n"\
  89. " ipDest varchar(64),\n"\
  90. " ipTos integer,\n"\
  91. " ipProtocol integer,\n"\
  92. " ipSourcePort integer,\n"\
  93. " ipDestPort integer,\n"\
  94. " flags integer,\n"\
  95. " invFlags integer,\n"\
  96. " \"action\" varchar(4096) NOT NULL DEFAULT('accept')\n"\
  97. ");\n"\
  98. "\n"\
  99. "CREATE UNIQUE INDEX Rule_networkId_ruleNo ON Rule (networkId, ruleNo);\n"\
  100. ""