00001 #include <stdio.h>
00002 #include "tables.h"
00003
00004
00005
00006
00007 int main ()
00008 {
00009 fprintf (stdout,
00010 "# WARNING: This file is generated by <./bin/create_database_read>. Do not edit this file by hand.");
00011
00012 fprintf (stdout,
00013 "\n\n\n");
00014
00015
00016
00017
00018
00019 fprintf (stdout,
00020 "CREATE DATABASE IF NOT EXISTS dhcp_adsl_read_only;\n");
00021
00022 fprintf (stdout,
00023 "USE dhcp_adsl_read_only;\n\n\n");
00024
00025 fprintf (stdout,
00026 "DROP TABLE IF EXISTS abonnes;\n");
00027
00028 fprintf (stdout,
00029 "DROP TABLE IF EXISTS abonne_ip;\n");
00030
00031 fprintf (stdout,
00032 "DROP TABLE IF EXISTS vlan;\n");
00033
00034 fprintf (stdout,
00035 "DROP TABLE IF EXISTS options;\n\n");
00036
00037
00038
00039
00040
00041 fprintf (stdout,
00042 "CREATE TABLE IF NOT EXISTS abonnes\n");
00043
00044 fprintf (stdout,
00045 "(\n");
00046
00047 fprintf (stdout,
00048 "\tUNIQUE INDEX option82_idx (node_id, shelf, numero_port, numero_slot),\n");
00049
00050 fprintf (stdout,
00051 "\tINDEX node_id_dix (node_id),\n");
00052
00053 fprintf (stdout,
00054 "\tINDEX shelf_idx (shelf),\n");
00055
00056 fprintf (stdout,
00057 "\tINDEX numero_port_idx (numero_port),\n");
00058
00059 fprintf (stdout,
00060 "\tINDEX numero_slot_idx (numero_slot),\n\n");
00061
00062 fprintf (stdout,
00063 "\tabonnes_id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT,\n");
00064
00065 fprintf (stdout,
00066 "\tnode_id VARCHAR(%d) NOT NULL,\n", NODE_ID_SIZE);
00067
00068 fprintf (stdout,
00069 "\tshelf INT(1) UNSIGNED NOT NULL,\n");
00070
00071 fprintf (stdout,
00072 "\tnumero_port INT(1) UNSIGNED NOT NULL,\n");
00073
00074 fprintf (stdout,
00075 "\tnumero_slot INT(1) UNSIGNED NOT NULL,\n");
00076
00077 fprintf (stdout,
00078 "\tlogin_radius VARCHAR(%d) NOT NULL,\n", LOGIN_RADIUS_SIZE-1);
00079
00080 fprintf (stdout,
00081 "\tfirst_connection INT(1) UNSIGNED NOT NULL,\n");
00082
00083 fprintf (stdout,
00084 "\tprofile VARCHAR(%d) NOT NULL DEFAULT 'STANDARD',\n", OPTIONNAL_PROFILE_SIZE-1);
00085
00086 fprintf (stdout,
00087 "\tdslam_ip VARCHAR(%d) NOT NULL,\n", IP_ADDRESS_STR_SIZE-1);
00088
00089 fprintf (stdout,
00090 "\tnack_flag INT(1) UNSIGNED NOT NULL,\n");
00091
00092 fprintf (stdout,
00093 "\tPRIMARY KEY (abonnes_id)\n");
00094
00095 fprintf (stdout,
00096 ");\n\n\n");
00097
00098
00099
00100
00101
00102 fprintf (stdout,
00103 "CREATE TABLE IF NOT EXISTS abonne_ip\n");
00104
00105 fprintf (stdout,
00106 "(\n");
00107
00108 fprintf (stdout,
00109 "\tUNIQUE INDEX ip_idx (ip),\n");
00110
00111 fprintf (stdout,
00112 "\tUNIQUE INDEX couple_idx (abonnes_id, vlan_id),\n");
00113
00114 fprintf (stdout,
00115 "\tINDEX vlan_id_idx (vlan_id),\n");
00116
00117 fprintf (stdout,
00118 "\tINDEX abonnes_id_dx (abonnes_id),\n\n");
00119
00120 fprintf (stdout,
00121 "\tabonne_ip_id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT,\n");
00122
00123 fprintf (stdout,
00124 "\tabonnes_id INT(4) UNSIGNED NOT NULL,\n");
00125
00126 fprintf (stdout,
00127 "\tvlan_id INT(4) UNSIGNED NOT NULL,\n");
00128
00129 fprintf (stdout,
00130 "\tip VARCHAR(%d) NOT NULL,\n", IP_ADDRESS_STR_SIZE-1);
00131
00132 fprintf (stdout,
00133 "\tgateway VARCHAR(%d) NOT NULL,\n", IP_ADDRESS_STR_SIZE-1);
00134
00135 fprintf (stdout,
00136 "\tsubnet VARCHAR(%d) NOT NULL,\n", IP_ADDRESS_STR_SIZE-1);
00137
00138 fprintf (stdout,
00139 "\tPRIMARY KEY (abonne_ip_id)\n");
00140
00141 fprintf (stdout,
00142 ");\n\n\n");
00143
00144
00145
00146
00147
00148 fprintf (stdout,
00149 "CREATE TABLE IF NOT EXISTS vlan\n");
00150
00151 fprintf (stdout,
00152 "(\n");
00153
00154 fprintf (stdout,
00155 "\tINDEX vlan_tag_idx (vlan_tag),\n");
00156
00157 fprintf (stdout,
00158 "\tINDEX vlan_gateway_idx (vlan_gateway),\n");
00159
00160 fprintf (stdout,
00161 "\tUNIQUE INDEX couple_idx (vlan_tag, vlan_gateway),\n\n");
00162
00163 fprintf (stdout,
00164 "\tvlan_id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT,\n");
00165
00166 fprintf (stdout,
00167 "\tprofile_optionnel VARCHAR(%d) NOT NULL,\n", OPTIONNAL_PROFILE_SIZE-1);
00168
00169 fprintf (stdout,
00170 "\tvlan_tag INT(4) UNSIGNED NOT NULL,\n");
00171
00172 fprintf (stdout,
00173 "\tvlan_gateway VARCHAR(%d) NOT NULL,\n", IP_ADDRESS_STR_SIZE-1);
00174
00175 fprintf (stdout,
00176 "\tradius_identifiant VARCHAR(%d) NOT NULL,\n", ACCT_IDENTIFIER_SIZE-1);
00177
00178 fprintf (stdout,
00179 "\tlibelle VARCHAR(%d) NOT NULL,\n", LABEL_SIZE-1);
00180
00181 fprintf (stdout,
00182 "\tcomment VARCHAR(%d) NOT NULL,\n", COMMENT_SIZE-1);
00183
00184 fprintf (stdout,
00185 "\toffer_timeout INT(4) UNSIGNED NOT NULL,\n");
00186
00187 fprintf (stdout,
00188 "\tPRIMARY KEY (vlan_id)\n");
00189
00190 fprintf (stdout,
00191 ");\n\n\n");
00192
00193
00194
00195
00196
00197 fprintf (stdout,
00198 "CREATE TABLE IF NOT EXISTS options\n");
00199
00200 fprintf (stdout,
00201 "(\n");
00202
00203 fprintf (stdout,
00204 "\tINDEX profile_optionnel_idx (profile_optionnel), \n\n");
00205
00206 fprintf (stdout,
00207 "\toptions_id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT,\n");
00208
00209 fprintf (stdout,
00210 "\tprofile_optionnel VARCHAR(%d) NOT NULL,\n", OPTIONNAL_PROFILE_SIZE-1);
00211
00212 fprintf (stdout,
00213 "\toption_code INT(4) UNSIGNED NOT NULL,\n");
00214
00215 fprintf (stdout,
00216 "\toption_type VARCHAR(%d) NOT NULL,\n", OPTION_TYPE_SIZE-1);
00217
00218 fprintf (stdout,
00219 "\toption_value VARCHAR(%d) NOT NULL,\n", OPTION_VALUE_SIZE-1);
00220
00221 fprintf (stdout,
00222 "\tcomment VARCHAR(%d),\n", COMMENT_SIZE-1);
00223
00224 fprintf (stdout,
00225 "\tPRIMARY KEY (options_id)\n");
00226
00227 fprintf (stdout,
00228 ");\n\n\n");
00229
00230
00231
00232
00233
00234 fprintf (stdout, "GRANT ALL ON dhcp_adsl_read_only.* TO dhcp_adsl@'localhost' IDENTIFIED BY 'liberty';\n");
00235
00236 fprintf (stdout, "GRANT ALL ON dhcp_adsl_read_only.* TO dhcp_adsl@'b-dhcp1' IDENTIFIED BY 'liberty';\n");
00237
00238 fprintf (stdout, "GRANT ALL ON dhcp_adsl_read_only.* TO dhcp_adsl@'b-dhcp2' IDENTIFIED BY 'liberty';\n");
00239
00240 fprintf (stdout, "GRANT ALL ON dhcp_adsl_read_only.* TO dba@'localhost' IDENTIFIED BY 'liberty';\n");
00241
00242 fprintf (stdout, "GRANT ALL ON dhcp_adsl_read_only.* TO dhcp_adsl@'devvoip' IDENTIFIED BY 'liberty';\n");
00243
00244 fprintf (stdout, "GRANT ALL ON dhcp_adsl_read_only.* TO dhcp_adsl@'devregister1' IDENTIFIED BY 'liberty';\n");
00245
00246 return 0;
00247 }