Skip to content

Commit

Permalink
Add default list to radius_str2tmpl
Browse files Browse the repository at this point in the history
  • Loading branch information
arr2036 committed Mar 21, 2014
1 parent 0b60fa2 commit 1dbdb03
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
4 changes: 3 additions & 1 deletion src/include/map.h
Expand Up @@ -139,7 +139,9 @@ value_pair_tmpl_t *radius_attr2tmpl(TALLOC_CTX *ctx, char const *name,
request_refs_t request_def,
pair_lists_t list_def);

value_pair_tmpl_t *radius_str2tmpl(TALLOC_CTX *ctx, char const *name, FR_TOKEN type);
value_pair_tmpl_t *radius_str2tmpl(TALLOC_CTX *ctx, char const *name, FR_TOKEN type,
request_refs_t request_def,
pair_lists_t list_def);
size_t radius_tmpl2str(char *buffer, size_t bufsize, value_pair_tmpl_t const *vpt);
int radius_attrmap(CONF_SECTION *cs, value_pair_map_t **head,
pair_lists_t dst_list_def, pair_lists_t src_list_def,
Expand Down
15 changes: 8 additions & 7 deletions src/main/map.c
Expand Up @@ -146,7 +146,8 @@ value_pair_tmpl_t *radius_attr2tmpl(TALLOC_CTX *ctx, char const *name,
* @param[in] type Type of quoting around value.
* @return pointer to new VPT.
*/
value_pair_tmpl_t *radius_str2tmpl(TALLOC_CTX *ctx, char const *name, FR_TOKEN type)
value_pair_tmpl_t *radius_str2tmpl(TALLOC_CTX *ctx, char const *name, FR_TOKEN type,
request_refs_t request_def, pair_lists_t list_def)
{
char const *p;
value_pair_tmpl_t *vpt;
Expand All @@ -163,10 +164,10 @@ value_pair_tmpl_t *radius_str2tmpl(TALLOC_CTX *ctx, char const *name, FR_TOKEN t
pair_lists_t list;

p = name;
ref = radius_request_name(&p, REQUEST_CURRENT);
ref = radius_request_name(&p, request_def);
if (ref == REQUEST_UNKNOWN) goto literal;

list = radius_list_name(&p, PAIR_LIST_REQUEST);
list = radius_list_name(&p, list_def);
if (list == PAIR_LIST_UNKNOWN) goto literal;

if ((p != name) && !*p) {
Expand Down Expand Up @@ -273,7 +274,7 @@ value_pair_map_t *radius_str2map(TALLOC_CTX *ctx, char const *lhs, FR_TOKEN lhs_
if ((lhs_type == T_BARE_WORD) && (*lhs == '&')) {
map->dst = radius_attr2tmpl(map, lhs + 1, dst_request_def, dst_list_def);
} else {
map->dst = radius_str2tmpl(map, lhs, lhs_type);
map->dst = radius_str2tmpl(map, lhs, lhs_type, dst_request_def, dst_list_def);
}

if (!map->dst) {
Expand All @@ -287,7 +288,7 @@ value_pair_map_t *radius_str2map(TALLOC_CTX *ctx, char const *lhs, FR_TOKEN lhs_
if ((rhs_type == T_BARE_WORD) && (*rhs == '&')) {
map->src = radius_attr2tmpl(map, rhs + 1, src_request_def, src_list_def);
} else {
map->src = radius_str2tmpl(map, rhs, rhs_type);
map->src = radius_str2tmpl(map, rhs, rhs_type, src_request_def, src_list_def);
}

if (!map->dst) goto error;
Expand Down Expand Up @@ -366,11 +367,11 @@ value_pair_map_t *radius_cp2map(TALLOC_CTX *ctx, CONF_PAIR *cp,
cf_pair_filename(cp), cf_pair_lineno(cp),
attr, value);
} else {
map->src = radius_str2tmpl(map, value, type);
map->src = radius_str2tmpl(map, value, type, src_request_def, src_list_def);
}
}
} else {
map->src = radius_str2tmpl(map, value, type);
map->src = radius_str2tmpl(map, value, type, src_request_def, src_list_def);
}

if (!map->src) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/parser.c
Expand Up @@ -482,7 +482,7 @@ static ssize_t condition_tokenize(TALLOC_CTX *ctx, CONF_ITEM *ci, char const *st

c->type = COND_TYPE_EXISTS;

c->data.vpt = radius_str2tmpl(c, lhs, lhs_type);
c->data.vpt = radius_str2tmpl(c, lhs, lhs_type, REQUEST_CURRENT, PAIR_LIST_REQUEST);
if (!c->data.vpt) {
return_P("Failed creating exists");
}
Expand Down

0 comments on commit 1dbdb03

Please sign in to comment.