/* * client-lease-declaration :== * BOOTP | * INTERFACE string | * FIXED_ADDR ip_address | * FILENAME string | * SERVER_NAME string | * OPTION option-decl | * RENEW time-decl | * REBIND time-decl | * EXPIRE time-decl */ void parse_client_lease_declaration(FILE *cfile, struct client_lease *lease) { char *val; int token; switch (next_token(&val, cfile)) { case TOK_BOOTP: lease->is_bootp = 1; break; case TOK_INTERFACE: token = next_token(&val, cfile); if (token != TOK_STRING) { parse_warn("expecting interface name (in quotes)."); skip_to_semi(cfile); break; } if (strcmp(ifi->name, val) != 0) { parse_warn("wrong interface name. Expecting '%s'.", ifi->name); skip_to_semi(cfile); break; } break; case TOK_FIXED_ADDR: if (!parse_ip_addr(cfile, &lease->address)) return; break; case TOK_MEDIUM: parse_string_list(cfile, &lease->medium, 0); return; case TOK_FILENAME: lease->filename = parse_string(cfile); return; case TOK_SERVER_NAME: lease->server_name = parse_string(cfile); return; case TOK_RENEW: lease->renewal = parse_date(cfile); return; case TOK_REBIND: lease->rebind = parse_date(cfile); return; case TOK_EXPIRE: lease->expiry = parse_date(cfile); return; case TOK_OPTION: parse_option_decl(cfile, lease->options); return; default: parse_warn("expecting lease declaration."); skip_to_semi(cfile); break; } token = next_token(&val, cfile); if (token != ';') { parse_warn("expecting semicolon."); skip_to_semi(cfile); } }
/* * client-lease-declaration :== * BOOTP | * INTERFACE string | * FIXED_ADDR ip_address | * FILENAME string | * SERVER_NAME string | * OPTION option-decl | * RENEW time-decl | * REBIND time-decl | * EXPIRE time-decl */ void parse_client_lease_declaration(FILE *cfile, struct client_lease *lease, struct interface_info **ipp) { int token; char *val; struct interface_info *ip; switch (next_token(&val, cfile)) { case BOOTP: lease->is_bootp = 1; break; case INTERFACE: token = next_token(&val, cfile); if (token != STRING) { parse_warn("expecting interface name (in quotes)."); skip_to_semi(cfile); break; } ip = interface_or_dummy(val); *ipp = ip; break; case FIXED_ADDR: if (!parse_ip_addr(cfile, &lease->address)) return; break; case MEDIUM: parse_string_list(cfile, &lease->medium, 0); return; case FILENAME: lease->filename = parse_string(cfile); return; case SERVER_NAME: lease->server_name = parse_string(cfile); return; case RENEW: lease->renewal = parse_date(cfile); return; case REBIND: lease->rebind = parse_date(cfile); return; case EXPIRE: lease->expiry = parse_date(cfile); return; case OPTION: parse_option_decl(cfile, lease->options); return; default: parse_warn("expecting lease declaration."); skip_to_semi(cfile); break; } token = next_token(&val, cfile); if (token != SEMI) { parse_warn("expecting semicolon."); skip_to_semi(cfile); } }
/* * client-declaration :== * TOK_SEND option-decl | * TOK_DEFAULT option-decl | * TOK_SUPERSEDE option-decl | * TOK_APPEND option-decl | * TOK_PREPEND option-decl | * TOK_MEDIA string-list | * hardware-declaration | * TOK_REQUEST option-list | * TOK_REQUIRE option-list | * TOK_TIMEOUT number | * TOK_RETRY number | * TOK_SELECT_TIMEOUT number | * TOK_REBOOT number | * TOK_BACKOFF_CUTOFF number | * TOK_INITIAL_INTERVAL number | * TOK_SCRIPT string | * interface-declaration | * TOK_LEASE client-lease-statement | * TOK_ALIAS client-lease-statement | * TOK_REJECT reject-statement */ void parse_client_statement(FILE *cfile) { char *val; int token, code; switch (next_token(&val, cfile)) { case TOK_SEND: parse_option_decl(cfile, &config->send_options[0]); return; case TOK_DEFAULT: code = parse_option_decl(cfile, &config->defaults[0]); if (code != -1) config->default_actions[code] = ACTION_DEFAULT; return; case TOK_SUPERSEDE: code = parse_option_decl(cfile, &config->defaults[0]); if (code != -1) config->default_actions[code] = ACTION_SUPERSEDE; return; case TOK_APPEND: code = parse_option_decl(cfile, &config->defaults[0]); if (code != -1) config->default_actions[code] = ACTION_APPEND; return; case TOK_PREPEND: code = parse_option_decl(cfile, &config->defaults[0]); if (code != -1) config->default_actions[code] = ACTION_PREPEND; return; case TOK_MEDIA: parse_string_list(cfile, &config->media, 1); return; case TOK_HARDWARE: parse_hardware_param(cfile, &ifi->hw_address); return; case TOK_REQUEST: config->requested_option_count = parse_option_list(cfile, config->requested_options); return; case TOK_REQUIRE: memset(config->required_options, 0, sizeof(config->required_options)); parse_option_list(cfile, config->required_options); return; case TOK_LINK_TIMEOUT: parse_lease_time(cfile, &config->link_timeout); return; case TOK_TIMEOUT: parse_lease_time(cfile, &config->timeout); return; case TOK_RETRY: parse_lease_time(cfile, &config->retry_interval); return; case TOK_SELECT_TIMEOUT: parse_lease_time(cfile, &config->select_interval); return; case TOK_REBOOT: parse_lease_time(cfile, &config->reboot_timeout); return; case TOK_BACKOFF_CUTOFF: parse_lease_time(cfile, &config->backoff_cutoff); return; case TOK_INITIAL_INTERVAL: parse_lease_time(cfile, &config->initial_interval); return; case TOK_SCRIPT: config->script_name = parse_string(cfile); return; case TOK_INTERFACE: parse_interface_declaration(cfile); return; case TOK_LEASE: parse_client_lease_statement(cfile, 1); return; case TOK_ALIAS: parse_client_lease_statement(cfile, 2); return; case TOK_REJECT: parse_reject_statement(cfile); return; default: parse_warn("expecting a statement."); skip_to_semi(cfile); break; } token = next_token(&val, cfile); if (token != ';') { parse_warn("semicolon expected."); skip_to_semi(cfile); } }
/* * client-declaration :== * SEND option-decl | * DEFAULT option-decl | * SUPERSEDE option-decl | * PREPEND option-decl | * APPEND option-decl | * hardware-declaration | * REQUEST option-list | * REQUIRE option-list | * TIMEOUT number | * RETRY number | * REBOOT number | * SELECT_TIMEOUT number | * SCRIPT string | * interface-declaration | * LEASE client-lease-statement | * ALIAS client-lease-statement */ void parse_client_statement(FILE *cfile, struct interface_info *ip, struct client_config *config) { int token; char *val; struct option *option; switch (next_token(&val, cfile)) { case SEND: parse_option_decl(cfile, &config->send_options[0]); return; case DEFAULT: option = parse_option_decl(cfile, &config->defaults[0]); if (option) config->default_actions[option->code] = ACTION_DEFAULT; return; case SUPERSEDE: option = parse_option_decl(cfile, &config->defaults[0]); if (option) config->default_actions[option->code] = ACTION_SUPERSEDE; return; case APPEND: option = parse_option_decl(cfile, &config->defaults[0]); if (option) config->default_actions[option->code] = ACTION_APPEND; return; case PREPEND: option = parse_option_decl(cfile, &config->defaults[0]); if (option) config->default_actions[option->code] = ACTION_PREPEND; return; case MEDIA: parse_string_list(cfile, &config->media, 1); return; case HARDWARE: if (ip) parse_hardware_param(cfile, &ip->hw_address); else { parse_warn("hardware address parameter %s", "not allowed here."); skip_to_semi(cfile); } return; case REQUEST: config->requested_option_count = parse_option_list(cfile, config->requested_options); return; case REQUIRE: memset(config->required_options, 0, sizeof(config->required_options)); parse_option_list(cfile, config->required_options); return; case TIMEOUT: parse_lease_time(cfile, &config->timeout); return; case RETRY: parse_lease_time(cfile, &config->retry_interval); return; case SELECT_TIMEOUT: parse_lease_time(cfile, &config->select_interval); return; case REBOOT: parse_lease_time(cfile, &config->reboot_timeout); return; case BACKOFF_CUTOFF: parse_lease_time(cfile, &config->backoff_cutoff); return; case INITIAL_INTERVAL: parse_lease_time(cfile, &config->initial_interval); return; case SCRIPT: config->script_name = parse_string(cfile); return; case INTERFACE: if (ip) parse_warn("nested interface declaration."); parse_interface_declaration(cfile, config); return; case LEASE: parse_client_lease_statement(cfile, 1); return; case ALIAS: parse_client_lease_statement(cfile, 2); return; case REJECT: parse_reject_statement(cfile, config); return; default: parse_warn("expecting a statement."); skip_to_semi(cfile); break; } token = next_token(&val, cfile); if (token != SEMI) { parse_warn("semicolon expected."); skip_to_semi(cfile); } }