interface-file: add support for inherit/inherits keyword

This commit is contained in:
Ariadne Conill 2020-08-04 11:46:56 -06:00
parent 3d5ca9050e
commit 6c7fa2919d

View file

@ -90,6 +90,22 @@ lif_interface_file_parse(struct lif_dict *collection, const char *filename)
cur_iface->is_dhcp = true; cur_iface->is_dhcp = true;
lif_dict_add(&cur_iface->vars, "use", strdup("dhcp")); lif_dict_add(&cur_iface->vars, "use", strdup("dhcp"));
} }
else if (!strcmp(token, "inherits"))
{
token = lif_next_token(&bufp);
if (!*token)
{
fprintf(stderr, "%s: inherits without interface\n", filename);
goto parse_error;
}
if (!lif_interface_collection_inherit(cur_iface, collection, token))
{
fprintf(stderr, "%s: could not inherit %s\n", filename, token);
goto parse_error;
}
}
token = lif_next_token(&bufp); token = lif_next_token(&bufp);
} }
@ -121,6 +137,22 @@ lif_interface_file_parse(struct lif_dict *collection, const char *filename)
lif_dict_add(&cur_iface->vars, token, strdup(executor)); lif_dict_add(&cur_iface->vars, token, strdup(executor));
} }
else if (!strcmp(token, "inherit"))
{
token = lif_next_token(&bufp);
if (!*token)
{
fprintf(stderr, "%s: inherits without interface\n", filename);
goto parse_error;
}
if (!lif_interface_collection_inherit(cur_iface, collection, token))
{
fprintf(stderr, "%s: could not inherit %s\n", filename, token);
goto parse_error;
}
}
else if (!strcmp(token, "address")) else if (!strcmp(token, "address"))
{ {
char *addr = lif_next_token(&bufp); char *addr = lif_next_token(&bufp);