version 1.1, 2012/02/21 22:30:18
|
version 1.1.1.1, 2012/10/09 09:06:54
|
Line 3
|
Line 3
|
Parser for dhcpd config file... */ |
Parser for dhcpd config file... */ |
|
|
/* |
/* |
* Copyright (c) 2004-2010 by Internet Systems Consortium, Inc. ("ISC") | * Copyright (c) 2004-2012 by Internet Systems Consortium, Inc. ("ISC") |
* Copyright (c) 1995-2003 by Internet Software Consortium |
* Copyright (c) 1995-2003 by Internet Software Consortium |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
Line 2741 void parse_group_declaration (cfile, group)
|
Line 2741 void parse_group_declaration (cfile, group)
|
enum dhcp_token token; |
enum dhcp_token token; |
struct group *g; |
struct group *g; |
int declaration = 0; |
int declaration = 0; |
struct group_object *t; | struct group_object *t = NULL; |
isc_result_t status; |
isc_result_t status; |
char *name = NULL; |
char *name = NULL; |
int deletedp = 0; |
int deletedp = 0; |
int dynamicp = 0; |
int dynamicp = 0; |
int staticp = 0; |
int staticp = 0; |
|
|
g = (struct group *)0; | g = NULL; |
if (!clone_group (&g, group, MDL)) | if (!clone_group(&g, group, MDL)) |
log_fatal ("no memory for explicit group."); | log_fatal("no memory for explicit group."); |
|
|
token = peek_token (&val, (unsigned *)0, cfile); | token = peek_token(&val, NULL, cfile); |
if (is_identifier (token) || token == STRING) { |
if (is_identifier (token) || token == STRING) { |
next_token (&val, (unsigned *)0, cfile); | next_token(&val, NULL, cfile); |
|
|
name = dmalloc (strlen (val) + 1, MDL); | name = dmalloc(strlen(val) + 1, MDL); |
if (!name) |
if (!name) |
log_fatal ("no memory for group decl name %s", val); | log_fatal("no memory for group decl name %s", val); |
strcpy (name, val); | strcpy(name, val); |
} |
} |
|
|
if (!parse_lbrace (cfile)) { | if (!parse_lbrace(cfile)) { |
group_dereference (&g, MDL); | group_dereference(&g, MDL); |
return; |
return; |
} |
} |
|
|
do { |
do { |
token = peek_token (&val, (unsigned *)0, cfile); | token = peek_token(&val, NULL, cfile); |
if (token == RBRACE) { |
if (token == RBRACE) { |
token = next_token (&val, (unsigned *)0, cfile); | token = next_token(&val, NULL, cfile); |
break; |
break; |
} else if (token == END_OF_FILE) { |
} else if (token == END_OF_FILE) { |
token = next_token (&val, (unsigned *)0, cfile); | token = next_token(&val, NULL, cfile); |
parse_warn (cfile, "unexpected end of file"); | parse_warn(cfile, "unexpected end of file"); |
break; |
break; |
} else if (token == TOKEN_DELETED) { |
} else if (token == TOKEN_DELETED) { |
token = next_token (&val, (unsigned *)0, cfile); | token = next_token(&val, NULL, cfile); |
parse_semi (cfile); | parse_semi(cfile); |
deletedp = 1; |
deletedp = 1; |
} else if (token == DYNAMIC) { |
} else if (token == DYNAMIC) { |
token = next_token (&val, (unsigned *)0, cfile); | token = next_token(&val, NULL, cfile); |
parse_semi (cfile); | parse_semi(cfile); |
dynamicp = 1; |
dynamicp = 1; |
} else if (token == STATIC) { |
} else if (token == STATIC) { |
token = next_token (&val, (unsigned *)0, cfile); | token = next_token(&val, NULL, cfile); |
parse_semi (cfile); | parse_semi(cfile); |
staticp = 1; |
staticp = 1; |
} |
} |
declaration = parse_statement (cfile, g, GROUP_DECL, | declaration = parse_statement(cfile, g, GROUP_DECL, |
(struct host_decl *)0, | NULL, declaration); |
declaration); | |
} while (1); |
} while (1); |
|
|
if (name) { |
if (name) { |
if (deletedp) { |
if (deletedp) { |
if (group_name_hash) { |
if (group_name_hash) { |
t = (struct group_object *)0; | t = NULL; |
if (group_hash_lookup (&t, group_name_hash, | if (group_hash_lookup(&t, group_name_hash, |
name, | name, |
strlen (name), MDL)) { | strlen(name), MDL)) { |
delete_group (t, 0); | delete_group(t, 0); |
} |
} |
} |
} |
} else { |
} else { |
t = (struct group_object *)0; | t = NULL; |
status = group_object_allocate (&t, MDL); | status = group_object_allocate(&t, MDL); |
if (status != ISC_R_SUCCESS) |
if (status != ISC_R_SUCCESS) |
log_fatal ("no memory for group decl %s: %s", | log_fatal("no memory for group decl %s: %s", |
val, isc_result_totext (status)); | val, isc_result_totext(status)); |
group_reference (&t -> group, g, MDL); | group_reference(&t->group, g, MDL); |
t -> name = name; | t->name = name; |
t -> flags = ((staticp ? GROUP_OBJECT_STATIC : 0) | | t->flags = ((staticp ? GROUP_OBJECT_STATIC : 0) | |
(dynamicp ? GROUP_OBJECT_DYNAMIC : 0) | | (dynamicp ? GROUP_OBJECT_DYNAMIC : 0) | |
(deletedp ? GROUP_OBJECT_DELETED : 0)); | (deletedp ? GROUP_OBJECT_DELETED : 0)); |
supersede_group (t, 0); | supersede_group(t, 0); |
} |
} |
if (t) | if (t != NULL) |
group_object_dereference (&t, MDL); | group_object_dereference(&t, MDL); |
} |
} |
} |
} |
|
|
Line 4432 parse_ia_na_declaration(struct parse *cfile) {
|
Line 4431 parse_ia_na_declaration(struct parse *cfile) {
|
binding_scope_dereference(&scope, MDL); |
binding_scope_dereference(&scope, MDL); |
} |
} |
|
|
/* add to our various structures */ | /* find the pool this address is in */ |
ia_add_iasubopt(ia, iaaddr, MDL); | |
ia_reference(&iaaddr->ia, ia, MDL); | |
pool = NULL; |
pool = NULL; |
if (find_ipv6_pool(&pool, D6O_IA_NA, |
if (find_ipv6_pool(&pool, D6O_IA_NA, |
&iaaddr->addr) != ISC_R_SUCCESS) { |
&iaaddr->addr) != ISC_R_SUCCESS) { |
inet_ntop(AF_INET6, &iaaddr->addr, |
inet_ntop(AF_INET6, &iaaddr->addr, |
addr_buf, sizeof(addr_buf)); |
addr_buf, sizeof(addr_buf)); |
parse_warn(cfile, "no pool found for address %s", | parse_warn(cfile, "no pool found for address %s", |
addr_buf); |
addr_buf); |
return; |
return; |
} |
} |
add_lease6(pool, iaaddr, end_time); | |
ipv6_pool_dereference(&pool, MDL); | /* remove old information */ |
| if (cleanup_lease6(ia_na_active, pool, |
| iaaddr, ia) != ISC_R_SUCCESS) { |
| inet_ntop(AF_INET6, &iaaddr->addr, |
| addr_buf, sizeof(addr_buf)); |
| parse_warn(cfile, "duplicate na lease for address %s", |
| addr_buf); |
| } |
| |
| /* |
| * if we like the lease we add it to our various structues |
| * otherwise we leave it and it will get cleaned when we |
| * do the iasubopt_dereference. |
| */ |
| if ((state == FTS_ACTIVE) || (state == FTS_ABANDONED)) { |
| ia_add_iasubopt(ia, iaaddr, MDL); |
| ia_reference(&iaaddr->ia, ia, MDL); |
| add_lease6(pool, iaaddr, end_time); |
| } |
| |
iasubopt_dereference(&iaaddr, MDL); |
iasubopt_dereference(&iaaddr, MDL); |
|
ipv6_pool_dereference(&pool, MDL); |
} |
} |
|
|
/* |
/* |
Line 4795 parse_ia_ta_declaration(struct parse *cfile) {
|
Line 4812 parse_ia_ta_declaration(struct parse *cfile) {
|
binding_scope_dereference(&scope, MDL); |
binding_scope_dereference(&scope, MDL); |
} |
} |
|
|
/* add to our various structures */ | /* find the pool this address is in */ |
ia_add_iasubopt(ia, iaaddr, MDL); | |
ia_reference(&iaaddr->ia, ia, MDL); | |
pool = NULL; |
pool = NULL; |
if (find_ipv6_pool(&pool, D6O_IA_TA, |
if (find_ipv6_pool(&pool, D6O_IA_TA, |
&iaaddr->addr) != ISC_R_SUCCESS) { |
&iaaddr->addr) != ISC_R_SUCCESS) { |
inet_ntop(AF_INET6, &iaaddr->addr, |
inet_ntop(AF_INET6, &iaaddr->addr, |
addr_buf, sizeof(addr_buf)); |
addr_buf, sizeof(addr_buf)); |
parse_warn(cfile, "no pool found for address %s", | parse_warn(cfile, "no pool found for address %s", |
addr_buf); |
addr_buf); |
return; |
return; |
} |
} |
add_lease6(pool, iaaddr, end_time); | |
| /* remove old information */ |
| if (cleanup_lease6(ia_ta_active, pool, |
| iaaddr, ia) != ISC_R_SUCCESS) { |
| inet_ntop(AF_INET6, &iaaddr->addr, |
| addr_buf, sizeof(addr_buf)); |
| parse_warn(cfile, "duplicate ta lease for address %s", |
| addr_buf); |
| } |
| |
| /* |
| * if we like the lease we add it to our various structues |
| * otherwise we leave it and it will get cleaned when we |
| * do the iasubopt_dereference. |
| */ |
| if ((state == FTS_ACTIVE) || (state == FTS_ABANDONED)) { |
| ia_add_iasubopt(ia, iaaddr, MDL); |
| ia_reference(&iaaddr->ia, ia, MDL); |
| add_lease6(pool, iaaddr, end_time); |
| } |
| |
ipv6_pool_dereference(&pool, MDL); |
ipv6_pool_dereference(&pool, MDL); |
iasubopt_dereference(&iaaddr, MDL); |
iasubopt_dereference(&iaaddr, MDL); |
} |
} |
Line 5159 parse_ia_pd_declaration(struct parse *cfile) {
|
Line 5194 parse_ia_pd_declaration(struct parse *cfile) {
|
binding_scope_dereference(&scope, MDL); |
binding_scope_dereference(&scope, MDL); |
} |
} |
|
|
/* add to our various structures */ | /* find the pool this address is in */ |
ia_add_iasubopt(ia, iapref, MDL); | |
ia_reference(&iapref->ia, ia, MDL); | |
pool = NULL; |
pool = NULL; |
if (find_ipv6_pool(&pool, D6O_IA_PD, |
if (find_ipv6_pool(&pool, D6O_IA_PD, |
&iapref->addr) != ISC_R_SUCCESS) { |
&iapref->addr) != ISC_R_SUCCESS) { |
inet_ntop(AF_INET6, &iapref->addr, |
inet_ntop(AF_INET6, &iapref->addr, |
addr_buf, sizeof(addr_buf)); |
addr_buf, sizeof(addr_buf)); |
parse_warn(cfile, "no pool found for address %s", | parse_warn(cfile, "no pool found for address %s", |
addr_buf); |
addr_buf); |
return; |
return; |
} |
} |
add_lease6(pool, iapref, end_time); | |
| /* remove old information */ |
| if (cleanup_lease6(ia_pd_active, pool, |
| iapref, ia) != ISC_R_SUCCESS) { |
| inet_ntop(AF_INET6, &iapref->addr, |
| addr_buf, sizeof(addr_buf)); |
| parse_warn(cfile, "duplicate pd lease for address %s", |
| addr_buf); |
| } |
| |
| /* |
| * if we like the lease we add it to our various structues |
| * otherwise we leave it and it will get cleaned when we |
| * do the iasubopt_dereference. |
| */ |
| if ((state == FTS_ACTIVE) || (state == FTS_ABANDONED)) { |
| ia_add_iasubopt(ia, iapref, MDL); |
| ia_reference(&iapref->ia, ia, MDL); |
| add_lease6(pool, iapref, end_time); |
| } |
| |
ipv6_pool_dereference(&pool, MDL); |
ipv6_pool_dereference(&pool, MDL); |
iasubopt_dereference(&iapref, MDL); |
iasubopt_dereference(&iapref, MDL); |
} |
} |