Commit 2fe778e8 authored by Francis Dupont's avatar Francis Dupont

[5096] Updated flex/bison parsers for databases

parent fbb1008e
...@@ -243,6 +243,33 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence} ...@@ -243,6 +243,33 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
} }
} }
\"memfile\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::DATABASE_TYPE:
return isc::dhcp::Dhcp4Parser::make_MEMFILE(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("memfile", driver.loc_);
}
}
\"mysql\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::DATABASE_TYPE:
return isc::dhcp::Dhcp4Parser::make_MYSQL(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("mysql", driver.loc_);
}
}
\"postgresql\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::DATABASE_TYPE:
return isc::dhcp::Dhcp4Parser::make_POSTGRESQL(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("postgresql", driver.loc_);
}
}
\"user\" { \"user\" {
switch(driver.ctx_) { switch(driver.ctx_) {
case isc::dhcp::Parser4Context::LEASE_DATABASE: case isc::dhcp::Parser4Context::LEASE_DATABASE:
...@@ -293,6 +320,16 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence} ...@@ -293,6 +320,16 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
} }
} }
\"connect-timeout\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::LEASE_DATABASE:
case isc::dhcp::Parser4Context::HOSTS_DATABASE:
return isc::dhcp::Dhcp4Parser::make_CONNECT_TIMEOUT(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("connect-timeout", driver.loc_);
}
}
\"valid-lifetime\" { \"valid-lifetime\" {
switch(driver.ctx_) { switch(driver.ctx_) {
case isc::dhcp::Parser4Context::DHCP4: case isc::dhcp::Parser4Context::DHCP4:
......
...@@ -63,12 +63,16 @@ using namespace std; ...@@ -63,12 +63,16 @@ using namespace std;
LEASE_DATABASE "lease-database" LEASE_DATABASE "lease-database"
HOSTS_DATABASE "hosts-database" HOSTS_DATABASE "hosts-database"
TYPE "type" TYPE "type"
MEMFILE "memfile"
MYSQL "mysql"
POSTGRESQL "postgresql"
USER "user" USER "user"
PASSWORD "password" PASSWORD "password"
HOST "host" HOST "host"
PERSIST "persist" PERSIST "persist"
LFC_INTERVAL "lfc-interval" LFC_INTERVAL "lfc-interval"
READONLY "readonly" READONLY "readonly"
CONNECT_TIMEOUT "connect-timeout"
VALID_LIFETIME "valid-lifetime" VALID_LIFETIME "valid-lifetime"
RENEW_TIMER "renew-timer" RENEW_TIMER "renew-timer"
...@@ -179,6 +183,7 @@ using namespace std; ...@@ -179,6 +183,7 @@ using namespace std;
%token <bool> BOOLEAN "boolean" %token <bool> BOOLEAN "boolean"
%type <ElementPtr> value %type <ElementPtr> value
%type <ElementPtr> db_type
%printer { yyoutput << $$; } <*>; %printer { yyoutput << $$; } <*>;
...@@ -476,17 +481,22 @@ database_map_param: database_type ...@@ -476,17 +481,22 @@ database_map_param: database_type
| persist | persist
| lfc_interval | lfc_interval
| readonly | readonly
| connect_timeout
| unknown_map_entry | unknown_map_entry
; ;
database_type: TYPE { database_type: TYPE {
ctx.enter(ctx.NO_KEYWORD); ctx.enter(ctx.DATABASE_TYPE);
} COLON STRING { } COLON db_type {
ElementPtr prf(new StringElement($4, ctx.loc2pos(@4))); ctx.stack_.back()->set("type", $4);
ctx.stack_.back()->set("type", prf);
ctx.leave(); ctx.leave();
}; };
db_type: MEMFILE { $$ = ElementPtr(new StringElement("memfile", ctx.loc2pos(@1))); }
| MYSQL { $$ = ElementPtr(new StringElement("mysql", ctx.loc2pos(@1))); }
| POSTGRESQL { $$ = ElementPtr(new StringElement("postgresql", ctx.loc2pos(@1))); }
;
user: USER { user: USER {
ctx.enter(ctx.NO_KEYWORD); ctx.enter(ctx.NO_KEYWORD);
} COLON STRING { } COLON STRING {
...@@ -534,9 +544,9 @@ readonly: READONLY COLON BOOLEAN { ...@@ -534,9 +544,9 @@ readonly: READONLY COLON BOOLEAN {
ctx.stack_.back()->set("readonly", n); ctx.stack_.back()->set("readonly", n);
}; };
duid_id : DUID { connect_timeout: CONNECT_TIMEOUT COLON INTEGER {
ElementPtr duid(new StringElement("duid", ctx.loc2pos(@1))); ElementPtr n(new IntElement($3, ctx.loc2pos(@3)));
ctx.stack_.back()->add(duid); ctx.stack_.back()->set("connect-timeout", n);
}; };
host_reservation_identifiers: HOST_RESERVATION_IDENTIFIERS { host_reservation_identifiers: HOST_RESERVATION_IDENTIFIERS {
...@@ -559,6 +569,11 @@ host_reservation_identifier: duid_id ...@@ -559,6 +569,11 @@ host_reservation_identifier: duid_id
| client_id | client_id
; ;
duid_id : DUID {
ElementPtr duid(new StringElement("duid", ctx.loc2pos(@1)));
ctx.stack_.back()->add(duid);
};
hw_address_id : HW_ADDRESS { hw_address_id : HW_ADDRESS {
ElementPtr hwaddr(new StringElement("hw-address", ctx.loc2pos(@1))); ElementPtr hwaddr(new StringElement("hw-address", ctx.loc2pos(@1)));
ctx.stack_.back()->add(hwaddr); ctx.stack_.back()->add(hwaddr);
......
...@@ -131,6 +131,8 @@ Parser4Context::contextName() ...@@ -131,6 +131,8 @@ Parser4Context::contextName()
return ("lease-database"); return ("lease-database");
case HOSTS_DATABASE: case HOSTS_DATABASE:
return ("hosts-database"); return ("hosts-database");
case DATABASE_TYPE:
return ("database-type");
case HOST_RESERVATION_IDENTIFIERS: case HOST_RESERVATION_IDENTIFIERS:
return ("host-reservation-identifiers"); return ("host-reservation-identifiers");
case HOOKS_LIBRARIES: case HOOKS_LIBRARIES:
......
...@@ -199,6 +199,9 @@ public: ...@@ -199,6 +199,9 @@ public:
/// Used while parsing Dhcp4/hosts-database structures. /// Used while parsing Dhcp4/hosts-database structures.
HOSTS_DATABASE, HOSTS_DATABASE,
/// Used while parsing Dhcp4/*-database/type.
DATABASE_TYPE,
/// Used while parsing Dhcp4/host-reservation-identifiers. /// Used while parsing Dhcp4/host-reservation-identifiers.
HOST_RESERVATION_IDENTIFIERS, HOST_RESERVATION_IDENTIFIERS,
......
...@@ -237,6 +237,33 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence} ...@@ -237,6 +237,33 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
} }
} }
\"memfile\" {
switch(driver.ctx_) {
case isc::dhcp::Parser6Context::DATABASE_TYPE:
return isc::dhcp::Dhcp6Parser::make_MEMFILE(driver.loc_);
default:
return isc::dhcp::Dhcp6Parser::make_STRING("memfile", driver.loc_);
}
}
\"mysql\" {
switch(driver.ctx_) {
case isc::dhcp::Parser6Context::DATABASE_TYPE:
return isc::dhcp::Dhcp6Parser::make_MYSQL(driver.loc_);
default:
return isc::dhcp::Dhcp6Parser::make_STRING("mysql", driver.loc_);
}
}
\"postgresql\" {
switch(driver.ctx_) {
case isc::dhcp::Parser6Context::DATABASE_TYPE:
return isc::dhcp::Dhcp6Parser::make_POSTGRESQL(driver.loc_);
default:
return isc::dhcp::Dhcp6Parser::make_STRING("postgresql", driver.loc_);
}
}
\"user\" { \"user\" {
switch(driver.ctx_) { switch(driver.ctx_) {
case isc::dhcp::Parser6Context::LEASE_DATABASE: case isc::dhcp::Parser6Context::LEASE_DATABASE:
...@@ -288,6 +315,16 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence} ...@@ -288,6 +315,16 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
} }
} }
\"connect-timeout\" {
switch(driver.ctx_) {
case isc::dhcp::Parser6Context::LEASE_DATABASE:
case isc::dhcp::Parser6Context::HOSTS_DATABASE:
return isc::dhcp::Dhcp6Parser::make_CONNECT_TIMEOUT(driver.loc_);
default:
return isc::dhcp::Dhcp6Parser::make_STRING("connect-timeout", driver.loc_);
}
}
\"preferred-lifetime\" { \"preferred-lifetime\" {
switch(driver.ctx_) { switch(driver.ctx_) {
case isc::dhcp::Parser6Context::DHCP6: case isc::dhcp::Parser6Context::DHCP6:
......
...@@ -56,12 +56,16 @@ using namespace std; ...@@ -56,12 +56,16 @@ using namespace std;
LEASE_DATABASE "lease-database" LEASE_DATABASE "lease-database"
HOSTS_DATABASE "hosts-database" HOSTS_DATABASE "hosts-database"
TYPE "type" TYPE "type"
MEMFILE "memfile"
MYSQL "mysql"
POSTGRESQL "postgresql"
USER "user" USER "user"
PASSWORD "password" PASSWORD "password"
HOST "host" HOST "host"
PERSIST "persist" PERSIST "persist"
LFC_INTERVAL "lfc-interval" LFC_INTERVAL "lfc-interval"
READONLY "readonly" READONLY "readonly"
CONNECT_TIMEOUT "connect-timeout"
PREFERRED_LIFETIME "preferred-lifetime" PREFERRED_LIFETIME "preferred-lifetime"
VALID_LIFETIME "valid-lifetime" VALID_LIFETIME "valid-lifetime"
...@@ -188,6 +192,7 @@ using namespace std; ...@@ -188,6 +192,7 @@ using namespace std;
%token <bool> BOOLEAN "boolean" %token <bool> BOOLEAN "boolean"
%type <ElementPtr> value %type <ElementPtr> value
%type <ElementPtr> db_type
%type <ElementPtr> duid_type %type <ElementPtr> duid_type
%printer { yyoutput << $$; } <*>; %printer { yyoutput << $$; } <*>;
...@@ -466,17 +471,22 @@ database_map_param: database_type ...@@ -466,17 +471,22 @@ database_map_param: database_type
| persist | persist
| lfc_interval | lfc_interval
| readonly | readonly
| connect_timeout
| unknown_map_entry | unknown_map_entry
; ;
database_type: TYPE { database_type: TYPE {
ctx.enter(ctx.NO_KEYWORD); ctx.enter(ctx.DATABASE_TYPE);
} COLON STRING { } COLON db_type {
ElementPtr prf(new StringElement($4, ctx.loc2pos(@4))); ctx.stack_.back()->set("type", $4);
ctx.stack_.back()->set("type", prf);
ctx.leave(); ctx.leave();
}; };
db_type: MEMFILE { $$ = ElementPtr(new StringElement("memfile", ctx.loc2pos(@1))); }
| MYSQL { $$ = ElementPtr(new StringElement("mysql", ctx.loc2pos(@1))); }
| POSTGRESQL { $$ = ElementPtr(new StringElement("postgresql", ctx.loc2pos(@1))); }
;
user: USER { user: USER {
ctx.enter(ctx.NO_KEYWORD); ctx.enter(ctx.NO_KEYWORD);
} COLON STRING { } COLON STRING {
...@@ -524,6 +534,11 @@ readonly: READONLY COLON BOOLEAN { ...@@ -524,6 +534,11 @@ readonly: READONLY COLON BOOLEAN {
ctx.stack_.back()->set("readonly", n); ctx.stack_.back()->set("readonly", n);
}; };
connect_timeout: CONNECT_TIMEOUT COLON INTEGER {
ElementPtr n(new IntElement($3, ctx.loc2pos(@3)));
ctx.stack_.back()->set("connect-timeout", n);
};
mac_sources: MAC_SOURCES { mac_sources: MAC_SOURCES {
ElementPtr l(new ListElement(ctx.loc2pos(@1))); ElementPtr l(new ListElement(ctx.loc2pos(@1)));
ctx.stack_.back()->set("mac-sources", l); ctx.stack_.back()->set("mac-sources", l);
......
...@@ -131,6 +131,8 @@ Parser6Context::contextName() ...@@ -131,6 +131,8 @@ Parser6Context::contextName()
return ("lease-database"); return ("lease-database");
case HOSTS_DATABASE: case HOSTS_DATABASE:
return ("hosts-database"); return ("hosts-database");
case DATABASE_TYPE:
return ("database-type");
case MAC_SOURCES: case MAC_SOURCES:
return ("mac-sources"); return ("mac-sources");
case HOST_RESERVATION_IDENTIFIERS: case HOST_RESERVATION_IDENTIFIERS:
......
...@@ -202,6 +202,9 @@ public: ...@@ -202,6 +202,9 @@ public:
/// Used while parsing Dhcp6/hosts-database structures. /// Used while parsing Dhcp6/hosts-database structures.
HOSTS_DATABASE, HOSTS_DATABASE,
/// Used while parsing Dhcp6/*-database/type.
DATABASE_TYPE,
/// Used while parsing Dhcp6/mac-sources structures. /// Used while parsing Dhcp6/mac-sources structures.
MAC_SOURCES, MAC_SOURCES,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment