schema.sql.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 IpAssignment (\n"\
  8. " networkId char(16) NOT NULL,\n"\
  9. " nodeId char(10) NOT NULL,\n"\
  10. " ip blob(16) NOT NULL,\n"\
  11. " ipNetmaskBits integer NOT NULL DEFAULT(0),\n"\
  12. " ipVersion integer NOT NULL DEFAULT(4)\n"\
  13. ");\n"\
  14. "\n"\
  15. "CREATE INDEX IpAssignment_networkId_ip ON IpAssignment (networkId, ip);\n"\
  16. "\n"\
  17. "CREATE INDEX IpAssignment_networkId_nodeId ON IpAssignment (networkId, nodeId);\n"\
  18. "\n"\
  19. "CREATE INDEX IpAssignment_networkId ON IpAssignment (networkId);\n"\
  20. "\n"\
  21. "CREATE TABLE IpAssignmentPool (\n"\
  22. " networkId char(16) NOT NULL,\n"\
  23. " ipNetwork blob(16) NOT NULL,\n"\
  24. " ipNetmaskBits integer NOT NULL,\n"\
  25. " ipVersion integer NOT NULL DEFAULT(4),\n"\
  26. " active integer NOT NULL DEFAULT(1)\n"\
  27. ");\n"\
  28. "\n"\
  29. "CREATE INDEX IpAssignmentPool_networkId ON IpAssignmentPool (networkId);\n"\
  30. "\n"\
  31. "CREATE TABLE Member (\n"\
  32. " networkId char(16) NOT NULL,\n"\
  33. " nodeId char(10) NOT NULL,\n"\
  34. " cachedNetconf blob(4096),\n"\
  35. " cachedNetconfRevision integer NOT NULL DEFAULT(0),\n"\
  36. " cachedNetconfTimestamp integer NOT NULL DEFAULT(0),\n"\
  37. " clientReportedRevision integer NOT NULL DEFAULT(0),\n"\
  38. " authorized integer NOT NULL DEFAULT(0),\n"\
  39. " activeBridge integer NOT NULL DEFAULT(0)\n"\
  40. ");\n"\
  41. "\n"\
  42. "CREATE INDEX Member_networkId ON Member (networkId);\n"\
  43. "\n"\
  44. "CREATE INDEX Member_networkId_activeBridge ON Member(networkId, activeBridge);\n"\
  45. "\n"\
  46. "CREATE UNIQUE INDEX Member_networkId_nodeId ON Member (networkId, nodeId);\n"\
  47. "\n"\
  48. "CREATE TABLE MulticastRate (\n"\
  49. " networkId char(16) NOT NULL,\n"\
  50. " mgMac char(12) NOT NULL,\n"\
  51. " mgAdi integer NOT NULL DEFAULT(0),\n"\
  52. " preload integer NOT NULL,\n"\
  53. " maxBalance integer NOT NULL,\n"\
  54. " accrual integer NOT NULL\n"\
  55. ");\n"\
  56. "\n"\
  57. "CREATE INDEX MulticastRate_networkId ON MulticastRate (networkId);\n"\
  58. "\n"\
  59. "CREATE TABLE Network (\n"\
  60. " id char(16) PRIMARY KEY NOT NULL,\n"\
  61. " name varchar(128) NOT NULL,\n"\
  62. " private integer NOT NULL DEFAULT(1),\n"\
  63. " enableBroadcast integer NOT NULL DEFAULT(1),\n"\
  64. " allowPassiveBridging integer NOT NULL DEFAULT(0),\n"\
  65. " v4AssignMode varchar(8) NOT NULL DEFAULT('none'),\n"\
  66. " v6AssignMode varchar(8) NOT NULL DEFAULT('none'),\n"\
  67. " multicastLimit integer NOT NULL DEFAULT(32),\n"\
  68. " creationTime integer NOT NULL DEFAULT(0),\n"\
  69. " revision integer NOT NULL DEFAULT(1)\n"\
  70. ");\n"\
  71. "\n"\
  72. "CREATE TABLE Relay (\n"\
  73. " networkId char(16) NOT NULL,\n"\
  74. " nodeId char(10) NOT NULL,\n"\
  75. " address varchar(64) NOT NULL\n"\
  76. ");\n"\
  77. "\n"\
  78. "CREATE UNIQUE INDEX Relay_networkId_nodeId ON Relay (networkId, nodeId);\n"\
  79. "\n"\
  80. "CREATE TABLE Node (\n"\
  81. " id char(10) PRIMARY KEY NOT NULL,\n"\
  82. " identity varchar(4096) NOT NULL,\n"\
  83. " lastAt varchar(64),\n"\
  84. " lastSeen integer NOT NULL DEFAULT(0),\n"\
  85. " firstSeen integer NOT NULL DEFAULT(0)\n"\
  86. ");\n"\
  87. "\n"\
  88. "CREATE TABLE Rule (\n"\
  89. " networkId char(16) NOT NULL,\n"\
  90. " nodeId char(10),\n"\
  91. " vlanId integer,\n"\
  92. " vlanPcp integer,\n"\
  93. " etherType integer,\n"\
  94. " macSource char(12),\n"\
  95. " macDest char(12),\n"\
  96. " ipSource varchar(64),\n"\
  97. " ipDest varchar(64),\n"\
  98. " ipTos integer,\n"\
  99. " ipProtocol integer,\n"\
  100. " ipSourcePort integer,\n"\
  101. " ipDestPort integer,\n"\
  102. " \"action\" varchar(4096) NOT NULL DEFAULT('accept')\n"\
  103. ");\n"\
  104. "\n"\
  105. "CREATE INDEX Rule_networkId ON Rule (networkId);\n"\
  106. ""